From ecc29ee7ecff81ba128e79813b856a87562c4754 Mon Sep 17 00:00:00 2001 From: Martin Mathieson Date: Fri, 3 Jul 2015 18:28:22 +0100 Subject: [PATCH] DHCP: Lookup OUI for TR111 suboption. Also add Ubiquisys OUI to oui_vals. Change-Id: I49b833ee4df01d37cfabb11fd177c00f34f41eb4 Reviewed-on: https://code.wireshark.org/review/9481 Petri-Dish: Martin Mathieson Tested-by: Petri Dish Buildbot Reviewed-by: Martin Mathieson --- epan/dissectors/packet-bootp.c | 28 +++++++++++++++++++--------- epan/oui.c | 1 + epan/oui.h | 1 + 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/epan/dissectors/packet-bootp.c b/epan/dissectors/packet-bootp.c index 7f0bd6e453..a659a8b7be 100644 --- a/epan/dissectors/packet-bootp.c +++ b/epan/dissectors/packet-bootp.c @@ -119,6 +119,7 @@ #include #include #include +#include void proto_register_bootp(void); void proto_reg_handoff_bootp(void); @@ -780,7 +781,8 @@ enum field_type { time_in_s_secs, /* Signed */ time_in_u_secs, /* Unsigned (not micro) */ fqdn, - ipv4_or_fqdn + ipv4_or_fqdn, + oui }; struct opt_info { @@ -3616,12 +3618,12 @@ dissect_vendor_tr111_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree static struct opt_info o125_tr111_opt[]= { /* 0 */ {"nop", special, NULL}, /* dummy */ - /* 1 */ {"DeviceManufacturerOUI", string, &hf_bootp_option125_tr111_device_manufacturer_oui}, - /* 2 */ {"DeviceSerialNumber", string, &hf_bootp_option125_tr111_device_serial_number}, - /* 3 */ {"DeviceProductClass", string, &hf_bootp_option125_tr111_device_product_class}, + /* 1 */ {"DeviceManufacturerOUI", oui, &hf_bootp_option125_tr111_device_manufacturer_oui}, + /* 2 */ {"DeviceSerialNumber", string, &hf_bootp_option125_tr111_device_serial_number}, + /* 3 */ {"DeviceProductClass", string, &hf_bootp_option125_tr111_device_product_class}, /* 4 */ {"GatewayManufacturerOUI", string, &hf_bootp_option125_tr111_gateway_manufacturer_oui}, - /* 5 */ {"GatewaySerialNumber", string, &hf_bootp_option125_tr111_gateway_serial_number}, - /* 6 */ {"GatewayProductClass", string, &hf_bootp_option125_tr111_gateway_product_class}, + /* 5 */ {"GatewaySerialNumber", string, &hf_bootp_option125_tr111_gateway_serial_number}, + /* 6 */ {"GatewayProductClass", string, &hf_bootp_option125_tr111_gateway_product_class}, }; subopt = tvb_get_guint8(tvb, optoff); @@ -3629,7 +3631,7 @@ dissect_vendor_tr111_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree if (suboptoff >= optend) { expert_add_info_format(pinfo, v_ti, &ei_bootp_missing_subopt_length, - "Suboption %d: no room left in option for suboption length", subopt); + "Suboption %d: no room left in option for suboption length", subopt); return (optend); } @@ -3653,12 +3655,20 @@ dissect_vendor_tr111_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree if (subopt < array_length(o125_tr111_opt)) { if (bootp_handle_basic_types(pinfo, o125_v_tree, vti, tvb, o125_tr111_opt[subopt].ftype, - suboptoff, subopt_len, o125_tr111_opt[subopt].phf, &default_hfs) == 0) { + suboptoff, subopt_len, o125_tr111_opt[subopt].phf, &default_hfs) == 0) { if (o125_tr111_opt[subopt].ftype == special) { if (o125_tr111_opt[subopt].phf != NULL) proto_tree_add_item(v_tree, *o125_tr111_opt[subopt].phf, tvb, suboptoff, subopt_len, ENC_BIG_ENDIAN); else proto_tree_add_item(v_tree, hf_bootp_option125_value, tvb, suboptoff, subopt_len, ENC_NA); + } + else if (o125_tr111_opt[subopt].ftype == oui) { + /* Get hex string. Expecting 6 characters. */ + gchar *oui_string = tvb_get_string_enc(wmem_packet_scope(), tvb, suboptoff, subopt_len, ENC_ASCII); + /* Convert to OUI number */ + long oui_number = strtol(oui_string, NULL, 16); + /* Add item using oui_vals */ + proto_tree_add_uint(v_tree, *o125_tr111_opt[subopt].phf, tvb, suboptoff, subopt_len, oui_number); } else if (o125_tr111_opt[subopt].phf == NULL) proto_tree_add_item(v_tree, hf_bootp_option125_value, tvb, suboptoff, subopt_len, ENC_NA); } @@ -7190,7 +7200,7 @@ proto_register_bootp(void) { &hf_bootp_option125_tr111_device_manufacturer_oui, { "DeviceManufacturerOUI", "bootp.option.vi.tr111.device_manufacturer_oui", - FT_STRINGZ, BASE_NONE, NULL, 0x0, + FT_UINT24, BASE_HEX, VALS(oui_vals), 0x0, "Option 125:TR 111 1 DeviceManufacturerOUI", HFILL }}, { &hf_bootp_option125_tr111_device_serial_number, diff --git a/epan/oui.c b/epan/oui.c index 1e441b48ba..cc20cdb3da 100644 --- a/epan/oui.c +++ b/epan/oui.c @@ -64,6 +64,7 @@ http://www.cisco.com/univercd/cc/td/doc/product/software/ios113ed/113ed_cr/ibm_r { OUI_IEEE_802_1QBG, "IEEE 802.1Qbg" }, { OUI_TURBOCELL, "Karlnet (Turbocell)" }, { OUI_CISCOWL, "Cisco Wireless (Aironet) L2" }, + { OUI_CISCO_UBI, "Cisco (Ubiquisys)"}, { OUI_MARVELL, "Marvell Semiconductor" }, /* Used for RFC 2427 bridged Frame Relay and RFC 2684 bridged ATM */ { OUI_IEEE_802_1, "IEEE 802.1" }, diff --git a/epan/oui.h b/epan/oui.h index d9647dbb66..4240967f74 100644 --- a/epan/oui.h +++ b/epan/oui.h @@ -62,6 +62,7 @@ #define OUI_BLUETOOTH 0x001958 /* Bluetooth SIG */ #define OUI_SONY_ERICSSON_8 0x001963 /* Sony Ericsson Mobile Communications AB */ #define OUI_DCBX 0x001B21 /* Data Center Bridging Capabilities Exchange Protocol */ +#define OUI_CISCO_UBI 0X001B67 /* Cisco/Ubiquisys */ #define OUI_IEEE_802_1QBG 0x001B3F /* IEEE 802.1 Qbg */ #define OUI_NINTENDO 0x001F32 #define OUI_TURBOCELL 0x0020F6 /* KarlNet, who brought you Turbocell */