Eliminate proto_tree_add_text from packet-arp.c

Change-Id: Ie9596df97a135b411693eefc39fdbd03316166a0
Reviewed-on: https://code.wireshark.org/review/4828
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2014-10-18 09:26:52 -04:00
parent c347eb965b
commit e0e03ee7e7
3 changed files with 72 additions and 58 deletions

View File

@ -77,6 +77,18 @@ static int hf_atmarp_src_atm_subaddr = -1;
static int hf_atmarp_dst_atm_num_e164 = -1;
static int hf_atmarp_dst_atm_num_nsap = -1;
static int hf_atmarp_dst_atm_subaddr = -1;
/* Generated from convert_proto_tree_add_text.pl */
static int hf_atmarp_src_atm_data_country_code = -1;
static int hf_atmarp_src_atm_data_country_code_group = -1;
static int hf_atmarp_src_atm_e_164_isdn = -1;
static int hf_atmarp_src_atm_e_164_isdn_group = -1;
static int hf_atmarp_src_atm_rest_of_address = -1;
static int hf_atmarp_src_atm_end_system_identifier = -1;
static int hf_atmarp_src_atm_high_order_dsp = -1;
static int hf_atmarp_src_atm_selector = -1;
static int hf_atmarp_src_atm_international_code_designator = -1;
static int hf_atmarp_src_atm_international_code_designator_group = -1;
static int hf_atmarp_src_atm_afi = -1;
static int hf_arp_dst_hw_ax25 = -1;
static int hf_arp_src_hw_ax25 = -1;
@ -88,6 +100,7 @@ static gint ett_arp_duplicate_address = -1;
static expert_field ei_seq_arp_dup_ip = EI_INIT;
static expert_field ei_seq_arp_storm = EI_INIT;
static expert_field ei_atmarp_src_atm_unknown_afi = EI_INIT;
static dissector_handle_t arp_handle;
@ -502,7 +515,7 @@ const value_string arp_hrd_vals[] = {
#define MIN_ATMARP_HEADER_SIZE 12
static void
dissect_atm_number(tvbuff_t *tvb, int offset, int tl, int hf_e164,
dissect_atm_number(tvbuff_t *tvb, packet_info* pinfo, int offset, int tl, int hf_e164,
int hf_nsap, proto_tree *tree)
{
int len = tl & ATMARP_LEN_MASK;
@ -515,78 +528,66 @@ dissect_atm_number(tvbuff_t *tvb, int offset, int tl, int hf_e164,
ti = proto_tree_add_item(tree, hf_nsap, tvb, offset, len, ENC_BIG_ENDIAN);
if (len >= 20) {
nsap_tree = proto_item_add_subtree(ti, ett_atmarp_nsap);
dissect_atm_nsap(tvb, offset, len, nsap_tree);
dissect_atm_nsap(tvb, pinfo, offset, len, nsap_tree);
}
}
}
static const value_string atm_nsap_afi_vals[] = {
{ 0x39, "DCC ATM format"},
{ 0xBD, "DCC ATM group format"},
{ 0x47, "ICD ATM format"},
{ 0xC5, "ICD ATM group format"},
{ 0x45, "E.164 ATM format"},
{ 0xC3, "E.164 ATM group format"},
{ 0, NULL}
};
/*
* XXX - shouldn't there be a centralized routine for dissecting NSAPs?
* See also "dissect_nsap()" in epan/dissectors/packet-isup.c and
* "print_nsap_net_buf()" and "print_nsap_net()" in epan/osi=utils.c.
*/
void
dissect_atm_nsap(tvbuff_t *tvb, int offset, int len, proto_tree *tree)
dissect_atm_nsap(tvbuff_t *tvb, packet_info* pinfo, int offset, int len, proto_tree *tree)
{
guint8 afi;
proto_item* ti;
afi = tvb_get_guint8(tvb, offset);
ti = proto_tree_add_item(tree, hf_atmarp_src_atm_afi, tvb, offset, 1, ENC_NA);
switch (afi) {
case 0x39: /* DCC ATM format */
case 0xBD: /* DCC ATM group format */
proto_tree_add_text(tree, tvb, offset + 0, 3,
"Data Country Code%s: 0x%04X",
(afi == 0xBD) ? " (group)" : "",
tvb_get_ntohs(tvb, offset + 1));
proto_tree_add_text(tree, tvb, offset + 3, 10,
"High Order DSP: %s",
tvb_bytes_to_ep_str(tvb, offset + 3, 10));
proto_tree_add_text(tree, tvb, offset + 13, 6,
"End System Identifier: %s",
tvb_bytes_to_ep_str(tvb, offset + 13, 6));
proto_tree_add_text(tree, tvb, offset + 19, 1,
"Selector: 0x%02X", tvb_get_guint8(tvb, offset + 19));
proto_tree_add_item(tree, (afi == 0xBD) ? hf_atmarp_src_atm_data_country_code_group : hf_atmarp_src_atm_data_country_code,
tvb, offset + 1, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_atmarp_src_atm_high_order_dsp, tvb, offset + 3, 10, ENC_NA);
proto_tree_add_item(tree, hf_atmarp_src_atm_end_system_identifier, tvb, offset + 13, 6, ENC_NA);
proto_tree_add_item(tree, hf_atmarp_src_atm_selector, tvb, offset + 19, 1, ENC_NA);
break;
case 0x47: /* ICD ATM format */
case 0xC5: /* ICD ATM group format */
proto_tree_add_text(tree, tvb, offset + 0, 3,
"International Code Designator%s: 0x%04X",
(afi == 0xC5) ? " (group)" : "",
tvb_get_ntohs(tvb, offset + 1));
proto_tree_add_text(tree, tvb, offset + 3, 10,
"High Order DSP: %s",
tvb_bytes_to_ep_str(tvb, offset + 3, 10));
proto_tree_add_text(tree, tvb, offset + 13, 6,
"End System Identifier: %s",
tvb_bytes_to_ep_str(tvb, offset + 13, 6));
proto_tree_add_text(tree, tvb, offset + 19, 1,
"Selector: 0x%02X", tvb_get_guint8(tvb, offset + 19));
proto_tree_add_item(tree, (afi == 0xC5) ? hf_atmarp_src_atm_international_code_designator_group : hf_atmarp_src_atm_international_code_designator,
tvb, offset + 1, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_atmarp_src_atm_high_order_dsp, tvb, offset + 3, 10, ENC_NA);
proto_tree_add_item(tree, hf_atmarp_src_atm_end_system_identifier, tvb, offset + 13, 6, ENC_NA);
proto_tree_add_item(tree, hf_atmarp_src_atm_selector, tvb, offset + 19, 1, ENC_NA);
break;
case 0x45: /* E.164 ATM format */
case 0xC3: /* E.164 ATM group format */
proto_tree_add_text(tree, tvb, offset + 0, 9,
"E.164 ISDN%s: %s",
(afi == 0xC3) ? " (group)" : "",
tvb_bytes_to_ep_str(tvb, offset + 1, 8));
proto_tree_add_text(tree, tvb, offset + 9, 4,
"High Order DSP: %s",
tvb_bytes_to_ep_str(tvb, offset + 3, 10));
proto_tree_add_text(tree, tvb, offset + 13, 6,
"End System Identifier: %s",
tvb_bytes_to_ep_str(tvb, offset + 13, 6));
proto_tree_add_text(tree, tvb, offset + 19, 1,
"Selector: 0x%02X", tvb_get_guint8(tvb, offset + 19));
proto_tree_add_item(tree, (afi == 0xC5) ? hf_atmarp_src_atm_e_164_isdn_group : hf_atmarp_src_atm_e_164_isdn,
tvb, offset + 1, 8, ENC_NA);
proto_tree_add_item(tree, hf_atmarp_src_atm_high_order_dsp, tvb, offset + 9, 4, ENC_NA);
proto_tree_add_item(tree, hf_atmarp_src_atm_end_system_identifier, tvb, offset + 13, 6, ENC_NA);
proto_tree_add_item(tree, hf_atmarp_src_atm_selector, tvb, offset + 19, 1, ENC_NA);
break;
default:
proto_tree_add_text(tree, tvb, offset, 1,
"Unknown AFI: 0x%02X", afi);
proto_tree_add_text(tree, tvb, offset + 1, len - 1,
"Rest of address: %s",
tvb_bytes_to_ep_str(tvb, offset + 1, len - 1));
expert_add_info(pinfo, ti, &ei_atmarp_src_atm_unknown_afi);
proto_tree_add_item(tree, hf_atmarp_src_atm_rest_of_address, tvb, offset + 1, len - 1, ENC_NA);
break;
}
}
@ -1168,7 +1169,7 @@ dissect_atmarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree_add_uint(arp_tree, hf_atmarp_tpln, tvb, ATM_AR_TPLN, 1, ar_tpln);
if (ar_shl != 0)
dissect_atm_number(tvb, sha_offset, ar_shtl, hf_atmarp_src_atm_num_e164,
dissect_atm_number(tvb, pinfo, sha_offset, ar_shtl, hf_atmarp_src_atm_num_e164,
hf_atmarp_src_atm_num_nsap, arp_tree);
if (ar_ssl != 0)
@ -1185,7 +1186,7 @@ dissect_atmarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
if (ar_thl != 0)
dissect_atm_number(tvb, tha_offset, ar_thtl, hf_atmarp_dst_atm_num_e164,
dissect_atm_number(tvb, pinfo, tha_offset, ar_thtl, hf_atmarp_dst_atm_num_e164,
hf_atmarp_dst_atm_num_nsap, arp_tree);
if (ar_tsl != 0)
@ -1955,6 +1956,18 @@ proto_register_arp(void)
FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
/* Generated from convert_proto_tree_add_text.pl */
{ &hf_atmarp_src_atm_data_country_code, { "Data Country Code", "arp.src.atm_data_country_code", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_atmarp_src_atm_data_country_code_group, { "Data Country Code (group)", "arp.src.atm_data_country_code_group", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_atmarp_src_atm_high_order_dsp, { "High Order DSP", "arp.src.atm_high_order_dsp", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_atmarp_src_atm_end_system_identifier, { "End System Identifier", "arp.src.atm_end_system_identifier", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_atmarp_src_atm_selector, { "Selector", "arp.src.atm_selector", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_atmarp_src_atm_international_code_designator, { "International Code Designator", "arp.src.atm_international_code_designator", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_atmarp_src_atm_international_code_designator_group, { "International Code Designator (group)", "arp.src.atm_international_code_designator_group", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_atmarp_src_atm_e_164_isdn, { "E.164 ISDN", "arp.src.atm_e.164_isdn", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_atmarp_src_atm_e_164_isdn_group, { "E.164 ISDN", "arp.src.atm_e.164_isdn_group", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_atmarp_src_atm_rest_of_address, { "Rest of address", "arp.src.atm_rest_of_address", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_atmarp_src_atm_afi, { "AFI", "arp.src.atm_afi", FT_UINT8, BASE_HEX, VALS(atm_nsap_afi_vals), 0x0, NULL, HFILL }},
};
static gint *ett[] = {
@ -1967,6 +1980,7 @@ proto_register_arp(void)
static ei_register_info ei[] = {
{ &ei_seq_arp_dup_ip, { "arp.duplicate-address-detected", PI_SEQUENCE, PI_WARN, "Duplicate IP address configured", EXPFILL }},
{ &ei_seq_arp_storm, { "arp.packet-storm-detected", PI_SEQUENCE, PI_NOTE, "ARP packet storm detected", EXPFILL }},
{ &ei_atmarp_src_atm_unknown_afi, { "arp.src.atm_afi.unknown", PI_PROTOCOL, PI_WARN, "Unknown AFI", EXPFILL }},
};
module_t *arp_module;

View File

@ -26,7 +26,7 @@
const gchar *tvb_arphrdaddr_to_str(tvbuff_t *tvb, gint offset, int ad_len, guint16 type);
void dissect_atm_nsap(tvbuff_t *tvb, int offset, int len, proto_tree *tree);
void dissect_atm_nsap(tvbuff_t *tvb, packet_info* pinfo, int offset, int len, proto_tree *tree);
extern const value_string arp_hrd_vals[];

View File

@ -143,7 +143,7 @@ static gint ett_q2931_ie = -1;
static gint ett_q2931_ie_ext = -1;
static gint ett_q2931_nsap = -1;
static void dissect_q2931_ie(tvbuff_t *tvb, int offset, int len,
static void dissect_q2931_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
proto_tree *tree, guint8 info_element, guint8 info_element_ext);
/*
@ -1140,7 +1140,7 @@ static const value_string q2931_rejection_reason_vals[] = {
};
static void
dissect_q2931_cause_ie(tvbuff_t *tvb, int offset, int len,
dissect_q2931_cause_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@ -1222,7 +1222,7 @@ dissect_q2931_cause_ie(tvbuff_t *tvb, int offset, int len,
info_element = tvb_get_guint8(tvb, offset);
info_element_ext = tvb_get_guint8(tvb, offset + 1);
info_element_len = tvb_get_ntohs(tvb, offset + 2);
dissect_q2931_ie(tvb, offset, info_element_len, tree,
dissect_q2931_ie(tvb, pinfo, offset, info_element_len, tree,
info_element, info_element_ext);
break;
@ -1349,7 +1349,7 @@ static const value_string q2931_screening_indicator_vals[] = {
};
static void
dissect_q2931_number_ie(tvbuff_t *tvb, int offset, int len,
dissect_q2931_number_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
proto_tree *tree)
{
guint8 octet;
@ -1391,7 +1391,7 @@ dissect_q2931_number_ie(tvbuff_t *tvb, int offset, int len,
return;
}
nsap_tree = proto_tree_add_subtree(tree, tvb, offset, len, ett_q2931_nsap, NULL, "Number");
dissect_atm_nsap(tvb, offset, len, nsap_tree);
dissect_atm_nsap(tvb, pinfo, offset, len, nsap_tree);
break;
default:
@ -1745,7 +1745,7 @@ dissect_q2931_endpoint_state_ie(tvbuff_t *tvb, int offset, int len,
}
static void
dissect_q2931_ie_contents(tvbuff_t *tvb, int offset, int len,
dissect_q2931_ie_contents(tvbuff_t *tvb, packet_info* pinfo, int offset, int len,
proto_tree *tree, guint8 info_element)
{
switch (info_element) {
@ -1794,7 +1794,7 @@ dissect_q2931_ie_contents(tvbuff_t *tvb, int offset, int len,
case Q2931_IE_CALLED_PARTY_NUMBER:
case Q2931_IE_CALLING_PARTY_NUMBER:
dissect_q2931_number_ie(tvb, offset, len, tree);
dissect_q2931_number_ie(tvb, pinfo, offset, len, tree);
break;
case Q2931_IE_CALLED_PARTY_SUBADDR:
@ -1803,7 +1803,7 @@ dissect_q2931_ie_contents(tvbuff_t *tvb, int offset, int len,
break;
case Q2931_IE_CAUSE:
dissect_q2931_cause_ie(tvb, offset, len, tree);
dissect_q2931_cause_ie(tvb, pinfo, offset, len, tree);
break;
case Q2931_IE_CONNECTION_IDENTIFIER:
@ -1849,7 +1849,7 @@ dissect_q2931_ie_contents(tvbuff_t *tvb, int offset, int len,
}
static void
dissect_q2931_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
dissect_q2931_ie(tvbuff_t *tvb, packet_info* pinfo, int offset, int len, proto_tree *tree,
guint8 info_element, guint8 info_element_ext)
{
proto_item *ti;
@ -1871,7 +1871,7 @@ dissect_q2931_ie(tvbuff_t *tvb, int offset, int len, proto_tree *tree,
if ((info_element_ext & Q2931_IE_COMPAT_CODING_STD)
== Q2931_ITU_STANDARDIZED_CODING) {
dissect_q2931_ie_contents(tvb, offset + 4,
dissect_q2931_ie_contents(tvb, pinfo, offset + 4,
len, ie_tree, info_element);
} else {
/*
@ -1966,7 +1966,7 @@ dissect_q2931(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
info_element_ext = tvb_get_guint8(tvb, offset + 1);
info_element_len = tvb_get_ntohs(tvb, offset + 2);
if (q2931_tree != NULL) {
dissect_q2931_ie(tvb, offset, info_element_len,
dissect_q2931_ie(tvb, pinfo, offset, info_element_len,
q2931_tree, info_element, info_element_ext);
}
#if 0 /* XXX: Is codeset & etc supoosed to be used somehow ? */