diff --git a/doc/README.dissector b/doc/README.dissector index 89a1e75900..0bcab9a891 100644 --- a/doc/README.dissector +++ b/doc/README.dissector @@ -136,6 +136,10 @@ FIELDDISPLAY --For FT_UINT{8,16,24,32,40,48,56,64} and BASE_PT_UDP, BASE_PT_TCP, BASE_PT_DCCP or BASE_PT_SCTP + --For FT_UINT24: + + BASE_OUI + --For FT_CHAR: BASE_HEX, BASE_OCT, BASE_CUSTOM, or BASE_NONE, possibly ORed with BASE_RANGE_STRING, BASE_EXT_STRING or diff --git a/epan/dissectors/packet-cfm.c b/epan/dissectors/packet-cfm.c index 0dbb6c70a0..cf273028d2 100644 --- a/epan/dissectors/packet-cfm.c +++ b/epan/dissectors/packet-cfm.c @@ -890,7 +890,6 @@ static int dissect_cfm_mcc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr gint cfm_tlv_offset; proto_item *ti; proto_item *fi; - proto_item *oi; proto_tree *cfm_pdu_tree; proto_tree *cfm_flag_tree; @@ -905,8 +904,7 @@ static int dissect_cfm_mcc(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr proto_tree_add_item(cfm_pdu_tree, hf_cfm_first_tlv_offset, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - oi = proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_oui, tvb, offset, 3, ENC_BIG_ENDIAN); - proto_item_append_text(oi, " (%s)", tvb_get_manuf_name(tvb, offset)); + proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_oui, tvb, offset, 3, ENC_BIG_ENDIAN); offset += 3; proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_subtype, tvb, offset, 1, ENC_NA); offset += 1; @@ -1072,7 +1070,6 @@ static int dissect_cfm_exm(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr gint cfm_tlv_offset; proto_item *ti; proto_item *fi; - proto_item *oi; proto_tree *cfm_pdu_tree; proto_tree *cfm_flag_tree; @@ -1087,8 +1084,7 @@ static int dissect_cfm_exm(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr proto_tree_add_item(cfm_pdu_tree, hf_cfm_first_tlv_offset, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - oi = proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_oui, tvb, offset, 3, ENC_BIG_ENDIAN); - proto_item_append_text(oi, " (%s)", tvb_get_manuf_name(tvb, offset)); + proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_oui, tvb, offset, 3, ENC_BIG_ENDIAN); offset += 3; proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_subtype, tvb, offset, 1, ENC_NA); offset += 1; @@ -1112,7 +1108,6 @@ static int dissect_cfm_exr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr gint cfm_tlv_offset; proto_item *ti; proto_item *fi; - proto_item *oi; proto_tree *cfm_pdu_tree; proto_tree *cfm_flag_tree; @@ -1127,8 +1122,7 @@ static int dissect_cfm_exr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr proto_tree_add_item(cfm_pdu_tree, hf_cfm_first_tlv_offset, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - oi = proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_oui, tvb, offset, 3, ENC_BIG_ENDIAN); - proto_item_append_text(oi, " (%s)", tvb_get_manuf_name(tvb, offset)); + proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_oui, tvb, offset, 3, ENC_BIG_ENDIAN); offset += 3; proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_subtype, tvb, offset, 1, ENC_NA); offset += 1; @@ -1152,7 +1146,6 @@ static int dissect_cfm_vsm(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr gint cfm_tlv_offset; proto_item *ti; proto_item *fi; - proto_item *oi; proto_tree *cfm_pdu_tree; proto_tree *cfm_flag_tree; @@ -1167,8 +1160,7 @@ static int dissect_cfm_vsm(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr proto_tree_add_item(cfm_pdu_tree, hf_cfm_first_tlv_offset, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - oi = proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_oui, tvb, offset, 3, ENC_BIG_ENDIAN); - proto_item_append_text(oi, " (%s)", tvb_get_manuf_name(tvb, offset)); + proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_oui, tvb, offset, 3, ENC_BIG_ENDIAN); offset += 3; proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_subtype, tvb, offset, 1, ENC_NA); offset += 1; @@ -1192,7 +1184,6 @@ static int dissect_cfm_vsr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr gint cfm_tlv_offset; proto_item *ti; proto_item *fi; - proto_item *oi; proto_tree *cfm_pdu_tree; proto_tree *cfm_flag_tree; @@ -1207,8 +1198,7 @@ static int dissect_cfm_vsr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr proto_tree_add_item(cfm_pdu_tree, hf_cfm_first_tlv_offset, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - oi = proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_oui, tvb, offset, 3, ENC_BIG_ENDIAN); - proto_item_append_text(oi, " (%s)", tvb_get_manuf_name(tvb, offset)); + proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_oui, tvb, offset, 3, ENC_BIG_ENDIAN); offset += 3; proto_tree_add_item(cfm_pdu_tree, hf_tlv_org_spec_subtype, tvb, offset, 1, ENC_NA); offset += 1; @@ -1313,7 +1303,6 @@ static int dissect_cfm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void if (tree) { /* we are being asked for details */ gint cfm_tlv_offset; proto_item *ti; - proto_item *oi; proto_tree *cfm_tree; /* isolate the payload of the packet */ @@ -1593,9 +1582,8 @@ static int dissect_cfm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * and the subtype. */ if (cfm_tlv_length > 3) { - oi = proto_tree_add_item(cfm_tlv_tree, hf_tlv_org_spec_oui, + proto_tree_add_item(cfm_tlv_tree, hf_tlv_org_spec_oui, tvb, tlv_data_offset, 3, ENC_BIG_ENDIAN); - proto_item_append_text(oi, " (%s)", tvb_get_manuf_name(tvb, tlv_data_offset)); tlv_data_offset += 3; proto_tree_add_item(cfm_tlv_tree, hf_tlv_org_spec_subtype, tvb, tlv_data_offset, 1, ENC_NA); @@ -2223,7 +2211,7 @@ void proto_register_cfm(void) /* Organization-Specific TLV */ { &hf_tlv_org_spec_oui, { "OUI", "cfm.tlv.org.spec.oui", FT_UINT24, - BASE_HEX, NULL, 0x0, NULL, HFILL } + BASE_OUI, NULL, 0x0, NULL, HFILL } }, { &hf_tlv_org_spec_subtype, { "Sub-Type", "cfm.tlv.org.spec.subtype", FT_BYTES, diff --git a/epan/dissectors/packet-ieee80211-radiotap.c b/epan/dissectors/packet-ieee80211-radiotap.c index fe84e951d9..47b34bb191 100644 --- a/epan/dissectors/packet-ieee80211-radiotap.c +++ b/epan/dissectors/packet-ieee80211-radiotap.c @@ -909,7 +909,8 @@ dissect_radiotap(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* u if (iter.this_arg_index == IEEE80211_RADIOTAP_VENDOR_NAMESPACE && tree) { - proto_tree *vt, *ven_tree = NULL; + proto_tree *ven_tree; + proto_item *vt; const gchar *manuf_name; guint8 subns; @@ -924,10 +925,8 @@ dissect_radiotap(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* u "%s-%d", manuf_name, subns); ven_tree = proto_item_add_subtree(vt, ett_radiotap_vendor); - proto_tree_add_bytes_format_value(ven_tree, - hf_radiotap_ven_oui, tvb, - offset, 3, NULL, - "%s", manuf_name); + proto_tree_add_item(ven_tree, hf_radiotap_ven_oui, + tvb, offset, 3, ENC_BIG_ENDIAN); proto_tree_add_item(ven_tree, hf_radiotap_ven_subns, tvb, offset + 3, 1, ENC_BIG_ENDIAN); proto_tree_add_item(ven_tree, hf_radiotap_ven_skip, tvb, @@ -2777,7 +2776,7 @@ void proto_register_radiotap(void) {&hf_radiotap_ven_oui, {"Vendor OUI", "radiotap.vendor_oui", - FT_BYTES, BASE_NONE, NULL, 0x0, + FT_UINT24, BASE_OUI, NULL, 0x0, NULL, HFILL}}, {&hf_radiotap_ven_subns, diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index 574cb45f6c..0c932f3126 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -6034,8 +6034,7 @@ dissect_advertisement_protocol_common(packet_info *pinfo, proto_tree *tree, "Vendor specific info length error"); return 2 + tag_len; } - oui = tvb_get_ntoh24(tvb, offset); - proto_tree_add_item(adv_tuple_tree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_NA); + proto_tree_add_item_ret_uint(adv_tuple_tree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_BIG_ENDIAN, &oui); offset += 3; left -= 3; wfa_subtype = tvb_get_guint8(tvb, offset); @@ -6117,8 +6116,7 @@ dissect_anqp_capab_list(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int expert_add_info(pinfo, tree, &ei_ieee80211_ff_anqp_capability); return; } - oui = tvb_get_ntoh24(tvb, offset); - proto_tree_add_item(vtree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_NA); + proto_tree_add_item_ret_uint(vtree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_BIG_ENDIAN, &oui); offset += 3; len -= 3; @@ -6795,8 +6793,7 @@ dissect_anqp_info(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offse dissect_domain_name_list(tree, tvb, offset, offset + len); break; case ANQP_INFO_ANQP_VENDOR_SPECIFIC_LIST: - oui = tvb_get_ntoh24(tvb, offset); - proto_tree_add_item(tree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_NA); + proto_tree_add_item_ret_uint(tree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_BIG_ENDIAN, &oui); offset += 3; vendor_tvb = tvb_new_subset_length(tvb, offset, len); @@ -8105,8 +8102,7 @@ add_ff_action_public_fields(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, offset += add_ff_extended_channel_switch_announcement(tree, tvb, pinfo, offset); break; case PA_VENDOR_SPECIFIC: - oui = tvb_get_ntoh24(tvb, offset); - proto_tree_add_item(tree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_NA); + proto_tree_add_item_ret_uint(tree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_BIG_ENDIAN, &oui); offset += 3; switch (oui) { case OUI_WFA: @@ -8674,8 +8670,7 @@ add_ff_action_vendor_specific(proto_tree *tree, tvbuff_t *tvb, packet_info *pinf int dissected; offset += add_ff_category_code(tree, tvb, pinfo, offset); - oui = tvb_get_ntoh24(tvb, offset); - proto_tree_add_item(tree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_NA); + proto_tree_add_item_ret_uint(tree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_BIG_ENDIAN, &oui); offset += 3; vendor_tvb = tvb_new_subset_remaining(tvb, offset); @@ -9974,14 +9969,14 @@ oui_base_custom(gchar *result, guint32 oui) p_oui[2] = oui & 0xFF; /* Attempt an OUI lookup. */ - manuf_name = get_manuf_name_if_known(p_oui); + manuf_name = uint_get_manuf_name_if_known(oui); if (manuf_name == NULL) { /* Could not find an OUI. */ - g_snprintf(result, ITEM_LABEL_LENGTH, "%.2x-%.2x-%.2x", p_oui[0], p_oui[1], p_oui[2]); + g_snprintf(result, ITEM_LABEL_LENGTH, "%02x:%02x:%02x", p_oui[0], p_oui[1], p_oui[2]); } else { /* Found an address string. */ - g_snprintf(result, ITEM_LABEL_LENGTH, "%.2x-%.2x-%.2x (%s)", p_oui[0], p_oui[1], p_oui[2], manuf_name); + g_snprintf(result, ITEM_LABEL_LENGTH, "%02x:%02x:%02x (%s)", p_oui[0], p_oui[1], p_oui[2], manuf_name); } } @@ -12610,7 +12605,7 @@ dissect_wapi_param_set(tvbuff_t *tvb, packet_info *pinfo, proto_item_append_text(ti, " Unicast Cipher List:"); for (loop_cnt = 0; loop_cnt < ucast_cnt; loop_cnt++) { subtree = proto_item_add_subtree(item, ett_tag_wapi_param_set_ucast_tree); - proto_tree_add_item(subtree, hf_ieee80211_tag_wapi_param_set_ucast_cipher_suite_oui, tvb, offset, 3, ENC_NA); + proto_tree_add_item(subtree, hf_ieee80211_tag_wapi_param_set_ucast_cipher_suite_oui, tvb, offset, 3, ENC_BIG_ENDIAN); offset += 3; ucast_cipher_type = tvb_get_guint8(tvb, offset); proto_tree_add_item(subtree, hf_ieee80211_tag_wapi_param_set_ucast_cipher_suite_type, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -15940,8 +15935,7 @@ ieee80211_tag_vendor_specific_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree * return tvb_captured_length(tvb); } - oui = tvb_get_ntoh24(tvb, offset); - proto_tree_add_item(tree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_NA); + proto_tree_add_item_ret_uint(tree, hf_ieee80211_tag_oui, tvb, offset, 3, ENC_BIG_ENDIAN, &oui); proto_item_append_text(field_data->item_tag, ": %s", uint_get_manuf_name_if_known(oui)); offset += 3; tag_vs_len -= 3; @@ -23523,7 +23517,7 @@ proto_register_ieee80211(void) {&hf_ieee80211_tag_oui, {"OUI", "wlan.tag.oui", - FT_UINT24, BASE_CUSTOM, CF_FUNC(oui_base_custom), 0, + FT_UINT24, BASE_OUI, NULL, 0, "OUI of vendor specific IE", HFILL }}, {&hf_ieee80211_tag_oui_wfa_subtype, @@ -23851,7 +23845,7 @@ proto_register_ieee80211(void) {&hf_ieee80211_rsn_gcs_oui, {"Group Cipher Suite OUI", "wlan.rsn.gcs.oui", - FT_UINT24, BASE_CUSTOM, CF_FUNC(oui_base_custom), 0, + FT_UINT24, BASE_OUI, NULL, 0, NULL, HFILL }}, {&hf_ieee80211_rsn_gcs_type, @@ -23881,7 +23875,7 @@ proto_register_ieee80211(void) {&hf_ieee80211_rsn_pcs_oui, {"Pairwise Cipher Suite OUI", "wlan.rsn.pcs.oui", - FT_UINT24, BASE_CUSTOM, CF_FUNC(oui_base_custom), 0, + FT_UINT24, BASE_OUI, NULL, 0, NULL, HFILL }}, {&hf_ieee80211_rsn_pcs_type, @@ -23911,7 +23905,7 @@ proto_register_ieee80211(void) {&hf_ieee80211_rsn_akms_oui, {"Auth Key Management (AKM) OUI", "wlan.rsn.akms.oui", - FT_UINT24, BASE_CUSTOM, CF_FUNC(oui_base_custom), 0, + FT_UINT24, BASE_OUI, NULL, 0, NULL, HFILL }}, {&hf_ieee80211_rsn_akms_type, @@ -23991,7 +23985,7 @@ proto_register_ieee80211(void) {&hf_ieee80211_rsn_gmcs_oui, {"Group Management Cipher Suite OUI", "wlan.rsn.gmcs.oui", - FT_UINT24, BASE_CUSTOM, CF_FUNC(oui_base_custom), 0, + FT_UINT24, BASE_OUI, NULL, 0, NULL, HFILL }}, {&hf_ieee80211_rsn_gmcs_type, @@ -26346,7 +26340,7 @@ proto_register_ieee80211(void) {&hf_ieee80211_wfa_ie_wpa_mcs_oui, {"Multicast Cipher Suite OUI", "wlan.wfa.ie.wpa.mcs.oui", - FT_UINT24, BASE_CUSTOM, CF_FUNC(oui_base_custom), 0, + FT_UINT24, BASE_OUI, NULL, 0, NULL, HFILL }}, {&hf_ieee80211_wfa_ie_wpa_mcs_type, @@ -26376,7 +26370,7 @@ proto_register_ieee80211(void) {&hf_ieee80211_wfa_ie_wpa_ucs_oui, {"Unicast Cipher Suite OUI", "wlan.wfa.ie.wpau.cs.oui", - FT_UINT24, BASE_CUSTOM, CF_FUNC(oui_base_custom), 0, + FT_UINT24, BASE_OUI, NULL, 0, NULL, HFILL }}, {&hf_ieee80211_wfa_ie_wpa_ucs_type, @@ -26406,7 +26400,7 @@ proto_register_ieee80211(void) {&hf_ieee80211_wfa_ie_wpa_akms_oui, {"Auth Key Management (AKM) OUI", "wlan.wfa.ie.wpa.akms.oui", - FT_UINT24, BASE_CUSTOM, CF_FUNC(oui_base_custom), 0, + FT_UINT24, BASE_OUI, NULL, 0, NULL, HFILL }}, {&hf_ieee80211_wfa_ie_wpa_akms_type, @@ -27576,7 +27570,7 @@ proto_register_ieee80211(void) {&hf_ieee80211_tag_wapi_param_set_akm_suite_oui, {"AKM Suite OUI", "wlan.wapi.akm_suite.oui", - FT_UINT24, BASE_CUSTOM, CF_FUNC(oui_base_custom), 0, + FT_UINT24, BASE_OUI, NULL, 0, NULL, HFILL }}, {&hf_ieee80211_tag_wapi_param_set_akm_suite_type, @@ -27591,7 +27585,7 @@ proto_register_ieee80211(void) {&hf_ieee80211_tag_wapi_param_set_ucast_cipher_suite_oui, {"Unicast Cipher Suite OUI", "wlan.wapi.unicast_cipher.suite.oui", - FT_UINT24, BASE_CUSTOM, CF_FUNC(oui_base_custom), 0, + FT_UINT24, BASE_OUI, NULL, 0, NULL, HFILL }}, {&hf_ieee80211_tag_wapi_param_set_ucast_cipher_suite_type, @@ -27601,7 +27595,7 @@ proto_register_ieee80211(void) {&hf_ieee80211_tag_wapi_param_set_mcast_cipher_suite_oui, {"Multicast Cipher Suite OUI", "wlan.wapi.multicast_cipher.suite.oui", - FT_UINT24, BASE_CUSTOM, CF_FUNC(oui_base_custom), 0, + FT_UINT24, BASE_OUI, NULL, 0, NULL, HFILL }}, {&hf_ieee80211_tag_wapi_param_set_mcast_cipher_suite_type, diff --git a/epan/dissectors/packet-ieee802a.c b/epan/dissectors/packet-ieee802a.c index f2eb0b08ce..ce4e35c19c 100644 --- a/epan/dissectors/packet-ieee802a.c +++ b/epan/dissectors/packet-ieee802a.c @@ -81,7 +81,6 @@ dissect_ieee802a(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data proto_item *ti; tvbuff_t *next_tvb; const gchar *manuf; - guint8 oui[3]; guint32 oui32; guint16 pid; oui_info_t *oui_info; @@ -94,18 +93,13 @@ dissect_ieee802a(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data ti = proto_tree_add_item(tree, proto_ieee802a, tvb, 0, 5, ENC_NA); ieee802a_tree = proto_item_add_subtree(ti, ett_ieee802a); - tvb_memcpy(tvb, oui, 0, 3); - oui32 = oui[0] << 16 | oui[1] << 8 | oui[2]; - manuf = get_manuf_name_if_known(oui); + proto_tree_add_item_ret_uint(ieee802a_tree, hf_ieee802a_oui, tvb, 0, 3, ENC_BIG_ENDIAN, &oui32); + manuf = uint_get_manuf_name_if_known(oui32); pid = tvb_get_ntohs(tvb, 3); col_add_fstr(pinfo->cinfo, COL_INFO, "OUI %s (%s), PID 0x%04X", - bytestring_to_str(wmem_packet_scope(), oui, 3, ':'), - manuf ? manuf : "Unknown", pid); - - proto_tree_add_uint_format_value(ieee802a_tree, hf_ieee802a_oui, - tvb, 0, 3, oui32, "%s (%s)", - bytestring_to_str(wmem_packet_scope(), oui, 3, ':'), manuf ? manuf : "Unknown"); + tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, 0, 3, ':'), + manuf ? manuf : "Unknown", pid); /* * Do we have information for this OUI? @@ -148,7 +142,7 @@ proto_register_ieee802a(void) { static hf_register_info hf[] = { { &hf_ieee802a_oui, - { "Organization Code", "ieee802a.oui", FT_UINT24, BASE_HEX, + { "Organization Code", "ieee802a.oui", FT_UINT24, BASE_OUI, NULL, 0x0, NULL, HFILL }}, { &hf_ieee802a_pid, diff --git a/epan/dissectors/packet-nhrp.c b/epan/dissectors/packet-nhrp.c index 45601cb782..371f84587b 100644 --- a/epan/dissectors/packet-nhrp.c +++ b/epan/dissectors/packet-nhrp.c @@ -909,16 +909,24 @@ static void dissect_nhrp_ext(tvbuff_t *tvb, } else { proto_tree *vendor_tree; - gchar manuf[3]; + proto_item *vendor_item; + guint32 manuf; + const gchar* oui; - tvb_memcpy(tvb, manuf, offset, 3); - vendor_tree = proto_tree_add_subtree_format(nhrp_tree, tvb, offset, len, - ett_nhrp_vendor_ext, NULL, "Extension Data: Vendor ID=%s, Data=%s", get_manuf_name(manuf), - tvb_bytes_to_str(wmem_packet_scope(), tvb, offset + 3, len - 3)); - proto_tree_add_bytes_format_value(vendor_tree, hf_nhrp_vendor_ext_id, tvb, - offset, 3, manuf, "%s", get_manuf_name(manuf)); + vendor_tree = proto_tree_add_subtree(nhrp_tree, tvb, offset, len, + ett_nhrp_vendor_ext, &vendor_item, "Extension Data:"); + proto_tree_add_item_ret_uint(vendor_tree, hf_nhrp_vendor_ext_id, tvb, offset, 3, ENC_BIG_ENDIAN, &manuf); + oui = uint_get_manuf_name_if_known(manuf); + if (oui != NULL) { + proto_item_append_text(vendor_item, " Vendor ID=%s", oui); + } else { + proto_item_append_text(vendor_item, " Vendor ID=Unknown"); + } if (len > 3) { proto_tree_add_item(vendor_tree, hf_nhrp_vendor_ext_data, tvb, offset + 3, len - 3, ENC_NA); + proto_item_append_text(vendor_item, ", Data=%s", tvb_bytes_to_str(wmem_packet_scope(), tvb, offset + 3, len - 3)); + } else { + proto_item_append_text(vendor_item, ", Data="); } } break; diff --git a/epan/dissectors/packet-oampdu.c b/epan/dissectors/packet-oampdu.c index d68e9fe4cc..4cdffeb112 100644 --- a/epan/dissectors/packet-oampdu.c +++ b/epan/dissectors/packet-oampdu.c @@ -957,10 +957,6 @@ static gint ett_oampdu_lpbk_ctrl = -1; static expert_field ei_oampdu_event_length_bad = EI_INIT; -#define APPEND_OUI_NAME(item, string, tvb, offset) \ - string = tvb_get_manuf_name(tvb, offset); \ - proto_item_append_text(item, " (%s)", string); - static void dissect_oampdu_information(tvbuff_t *tvb, proto_tree *tree); @@ -1097,11 +1093,8 @@ dissect_oampdu_information(tvbuff_t *tvb, proto_tree *tree) guint32 offset; guint16 bytes; - const guint8 *ptr; - proto_tree *info_tree; proto_item *info_item; - proto_item *oui_item; offset = OAMPDU_HEADER_SIZE; @@ -1190,10 +1183,8 @@ dissect_oampdu_information(tvbuff_t *tvb, proto_tree *tree) offset += OAMPDU_INFO_OAMPDU_CONFIG_SZ; - oui_item = proto_tree_add_item(info_tree, hf_oampdu_info_oui, - tvb, offset, 3, ENC_NA); - - APPEND_OUI_NAME(oui_item, ptr, tvb, offset); + proto_tree_add_item(info_tree, hf_oampdu_info_oui, + tvb, offset, 3, ENC_BIG_ENDIAN); offset += OAMPDU_INFO_OUI_SZ; @@ -1211,11 +1202,7 @@ dissect_oampdu_information(tvbuff_t *tvb, proto_tree *tree) offset += OAMPDU_INFO_LENGTH_SZ; - oui_item = proto_tree_add_item(info_tree, hf_oampdu_info_oui, - tvb, offset, 3, ENC_NA); - - APPEND_OUI_NAME(oui_item, ptr, tvb, offset); - + proto_tree_add_item(info_tree, hf_oampdu_info_oui, tvb, offset, 3, ENC_BIG_ENDIAN); offset += OAMPDU_INFO_OUI_SZ; proto_tree_add_item(info_tree, hf_oampdu_info_vendor, @@ -1685,7 +1672,6 @@ dissect_oampdu_vendor_specific(tvbuff_t *tvb, proto_tree *tree) guint8 pir_subtype; guint8 rr_byte; - const guint8 *ptr; const guint8 oui_cl[] = {OUI_CL_0, OUI_CL_1, OUI_CL_2}; proto_item *oui_item; @@ -1699,8 +1685,7 @@ dissect_oampdu_vendor_specific(tvbuff_t *tvb, proto_tree *tree) bytes = tvb_captured_length_remaining(tvb, offset); if (bytes >= 3) { - oui_item = proto_tree_add_item(tree, hf_oampdu_info_oui, tvb, offset, 3, ENC_NA); - APPEND_OUI_NAME(oui_item, ptr, tvb, offset); + oui_item = proto_tree_add_item(tree, hf_oampdu_info_oui, tvb, offset, 3, ENC_BIG_ENDIAN); if (tvb_memeql(tvb, offset, oui_cl, OUI_SIZE) == 0) { @@ -2062,7 +2047,7 @@ proto_register_oampdu(void) { &hf_oampdu_info_oui, { "Organizationally Unique Identifier", "oampdu.info.oui", - FT_BYTES, BASE_NONE, NULL, 0x0, + FT_UINT24, BASE_OUI, NULL, 0x0, NULL, HFILL }}, { &hf_oampdu_info_vendor, diff --git a/epan/dissectors/packet-ossp.c b/epan/dissectors/packet-ossp.c index 2d524d72e7..bee1be7a4d 100644 --- a/epan/dissectors/packet-ossp.c +++ b/epan/dissectors/packet-ossp.c @@ -226,24 +226,21 @@ dissect_ossp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data { gint offset = 0; const gchar *str; - proto_item *oui_item, *ossp_item; + proto_item *ossp_item; proto_tree *ossp_tree; tvbuff_t *ossp_tvb; + guint32 oui; const guint8 itu_oui[] = {ITU_OUI_0, ITU_OUI_1, ITU_OUI_2}; - /* OUI of the organization defining the protocol */ - str = tvb_get_manuf_name(tvb, offset); - col_set_str(pinfo->cinfo, COL_PROTOCOL, "OSSP"); - col_add_fstr(pinfo->cinfo, COL_INFO, "OUI: %s", str); ossp_item = proto_tree_add_protocol_format(tree, proto_ossp, tvb, 0, -1, "Organization Specific Slow Protocol"); ossp_tree = proto_item_add_subtree(ossp_item, ett_ossppdu); - oui_item = proto_tree_add_item(ossp_tree, hf_ossp_oui, - tvb, offset, OUI_SIZE, ENC_NA); - proto_item_append_text(oui_item, " (%s)", str); + proto_tree_add_item_ret_uint(ossp_tree, hf_ossp_oui, tvb, offset, OUI_SIZE, ENC_BIG_ENDIAN, &oui); + str = uint_get_manuf_name_if_known(oui); + col_add_fstr(pinfo->cinfo, COL_INFO, "OUI: %s", (str != NULL) ? str : "(Unknown OSSP organization)"); offset += 3; /* @@ -266,10 +263,7 @@ dissect_ossp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data dissect_yyy_ossp(ossp_tvb, pinfo, ossp_tree); } #endif - else - { - proto_item_append_text(oui_item, " (Unknown OSSP organization)"); - } + return tvb_captured_length(tvb); } @@ -569,7 +563,7 @@ proto_register_ossp(void) static hf_register_info hf[] = { { &hf_ossp_oui, { "OUI", "ossp.oui", - FT_BYTES, BASE_NONE, NULL, 0, + FT_UINT24, BASE_OUI, NULL, 0, "IEEE assigned Organizationally Unique Identifier", HFILL }}, { &hf_itu_subtype, diff --git a/epan/dissectors/packet-ppp.c b/epan/dissectors/packet-ppp.c index bfc17bfba5..ac6a43b7b2 100644 --- a/epan/dissectors/packet-ppp.c +++ b/epan/dissectors/packet-ppp.c @@ -1825,8 +1825,6 @@ dissect_lcp_vendor_opt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void { proto_tree *field_tree; proto_item *ti; - guint32 oui; - const gchar *manuf; int offset = 0; int len = tvb_reported_length(tvb); @@ -1834,13 +1832,7 @@ dissect_lcp_vendor_opt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void &field_tree, &ti)) return tvb_captured_length(tvb); - oui = tvb_get_ntoh24(tvb, offset + 2); - ti = proto_tree_add_uint_format_value(field_tree, hf_lcp_opt_oui, tvb, - offset + 2, 3, oui, "%02x:%02x:%02x", - (oui >> 16) & 0xff, (oui >> 8) & 0xff, oui & 0xff); - manuf = uint_get_manuf_name_if_known(oui); - if (manuf) - proto_item_append_text(ti, "(%s)", manuf); + proto_tree_add_item(field_tree, hf_lcp_opt_oui, tvb, offset + 2, 3, ENC_BIG_ENDIAN); proto_tree_add_item(field_tree, hf_lcp_opt_kind, tvb, offset + 5, 1, ENC_BIG_ENDIAN); @@ -3532,21 +3524,15 @@ dissect_ccp_var_opt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, static int dissect_ccp_oui_opt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { proto_tree *field_tree; - proto_item *tf, *ti; + proto_item *tf; int offset = 0; int length = tvb_reported_length(tvb); - guint32 oui; - const gchar *manuf; if (!dissect_ccp_var_opt(tvb, pinfo, tree, proto_ccp_option_oui, ett_ccp_oui_opt, 6, &field_tree, &tf)) return tvb_captured_length(tvb); - oui = tvb_get_ntoh24(tvb, offset + 2); - ti = proto_tree_add_item(field_tree, hf_ccp_opt_oui, tvb, offset + 2, 3, ENC_NA); - manuf = uint_get_manuf_name_if_known(oui); - if (manuf) - proto_item_append_text(ti, "(%s)", manuf); + proto_tree_add_item(field_tree, hf_ccp_opt_oui, tvb, offset + 2, 3, ENC_BIG_ENDIAN); proto_tree_add_item(field_tree, hf_ccp_opt_subtype, tvb, offset + 5, 1, ENC_BIG_ENDIAN); @@ -6686,7 +6672,7 @@ proto_register_lcp(void) { "Length", "lcp.opt.length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_lcp_opt_oui, - { "OUI", "lcp.opt.oui", FT_UINT24, BASE_HEX, + { "OUI", "lcp.opt.oui", FT_UINT24, BASE_OUI, NULL, 0x0, NULL, HFILL }}, { &hf_lcp_opt_kind, { "Kind", "lcp.opt.kind", FT_UINT8, BASE_DEC_HEX, @@ -7523,7 +7509,7 @@ proto_register_ccp(void) { "Length", "ccp.opt.length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_ccp_opt_oui, - { "OUI", "ccp.opt.oui", FT_BYTES, SEP_COLON, + { "OUI", "ccp.opt.oui", FT_UINT24, BASE_OUI, NULL, 0x0, NULL, HFILL }}, { &hf_ccp_opt_subtype, { "Subtype", "ccp.opt.subtype", FT_UINT8, BASE_DEC_HEX, diff --git a/epan/proto.c b/epan/proto.c index 129fac57ca..56fd690594 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -7339,6 +7339,7 @@ static const value_string hf_display[] = { { BASE_PT_TCP, "BASE_PT_TCP" }, { BASE_PT_DCCP, "BASE_PT_DCCP" }, { BASE_PT_SCTP, "BASE_PT_SCTP" }, + { BASE_OUI, "BASE_OUI" }, { 0, NULL } }; const char* proto_field_display_to_string(int field_display) @@ -7579,6 +7580,27 @@ tmp_fld_check_assert(header_field_info *hfinfo) break; } + if (hfinfo->display == BASE_OUI) { + tmp_str = val_to_str_wmem(NULL, hfinfo->display, hf_display, "(Unknown: 0x%x)"); + if (hfinfo->type != FT_UINT24) { + g_error("Field '%s' (%s) has 'display' value %s but it can only be used with FT_UINT24, not %s\n", + hfinfo->name, hfinfo->abbrev, + tmp_str, ftype_name(hfinfo->type)); + } + if (hfinfo->strings != NULL) { + g_error("Field '%s' (%s) is an %s (%s) but has a strings value\n", + hfinfo->name, hfinfo->abbrev, + ftype_name(hfinfo->type), tmp_str); + } + if (hfinfo->bitmask != 0) { + g_error("Field '%s' (%s) is an %s (%s) but has a bitmask\n", + hfinfo->name, hfinfo->abbrev, + ftype_name(hfinfo->type), tmp_str); + } + wmem_free(NULL, tmp_str); + break; + } + /* Require integral types (other than frame number, * which is always displayed in decimal) to have a * number base. @@ -9186,6 +9208,27 @@ hfinfo_number_value_format_display(const header_field_info *hfinfo, int display, port_with_resolution_to_str_buf(buf, 32, display_to_port_type((field_display_e)display), value); return buf; + case BASE_OUI: + { + guint8 p_oui[3]; + const gchar *manuf_name; + + p_oui[0] = value >> 16 & 0xFF; + p_oui[1] = value >> 8 & 0xFF; + p_oui[2] = value & 0xFF; + + /* Attempt an OUI lookup. */ + manuf_name = uint_get_manuf_name_if_known(value); + if (manuf_name == NULL) { + /* Could not find an OUI. */ + g_snprintf(buf, 32, "%02x:%02x:%02x", p_oui[0], p_oui[1], p_oui[2]); + } + else { + /* Found an address string. */ + g_snprintf(buf, 32, "%02x:%02x:%02x (%s)", p_oui[0], p_oui[1], p_oui[2], manuf_name); + } + return buf; + } default: g_assert_not_reached(); @@ -9287,6 +9330,8 @@ hfinfo_numeric_value_format(const header_field_info *hfinfo, char buf[32], guint if (IS_BASE_PORT(display)) { display = BASE_DEC; + } else if (display == BASE_OUI) { + display = BASE_HEX; } switch (display) { @@ -10079,6 +10124,7 @@ proto_registrar_dump_fields(void) case BASE_PT_TCP: case BASE_PT_DCCP: case BASE_PT_SCTP: + case BASE_OUI: base_name = val_to_str_const(FIELD_DISPLAY(hfinfo->display), hf_display, "????"); break; default: diff --git a/epan/proto.h b/epan/proto.h index 163bbca51b..e749979b8e 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -594,7 +594,11 @@ typedef enum { BASE_PT_UDP = 13, /**< UDP port */ BASE_PT_TCP = 14, /**< TCP port */ BASE_PT_DCCP = 15, /**< DCCP port */ - BASE_PT_SCTP = 16 /**< SCTP port */ + BASE_PT_SCTP = 16, /**< SCTP port */ + +/* OUI types */ + BASE_OUI = 17 /**< OUI resolution */ + } field_display_e; #define FIELD_DISPLAY(d) ((d) & FIELD_DISPLAY_E_MASK)