diff options
author | Michael Mann <mmann78@netscape.net> | 2014-10-15 12:55:08 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-10-15 19:16:37 +0000 |
commit | 371e4ae1c787bfbfd292fbf2474624241ea942f9 (patch) | |
tree | cd6d8f47ccda3ab752699009e347b900fc00ef9c /epan/dissectors/packet-gsm_a_rp.c | |
parent | 9b7ee18f8bbbbb4737158564a43be040ee4da263 (diff) |
Eliminate some proto_tree_add_text from GSM dissectors (so now there are no dissectors with 100+ proto_tree_add_text calls).
Add tfs_allocated_by_receiver_sender to tfs.h because it seems "popular" enough.
Change-Id: I478461d9b951a2c3e3aec6aaf996d95ba2c0feee
Reviewed-on: https://code.wireshark.org/review/4708
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-gsm_a_rp.c')
-rw-r--r-- | epan/dissectors/packet-gsm_a_rp.c | 119 |
1 files changed, 54 insertions, 65 deletions
diff --git a/epan/dissectors/packet-gsm_a_rp.c b/epan/dissectors/packet-gsm_a_rp.c index 32f93b52ed..fc47e79043 100644 --- a/epan/dissectors/packet-gsm_a_rp.c +++ b/epan/dissectors/packet-gsm_a_rp.c @@ -85,12 +85,17 @@ static int proto_a_rp = -1; static int hf_gsm_a_rp_msg_type = -1; int hf_gsm_a_rp_elem_id = -1; +/* Generated from convert_proto_tree_add_text.pl */ +static int hf_gsm_a_rp_tpdu = -1; +static int hf_gsm_a_rp_extension = -1; +static int hf_gsm_a_rp_diagnostic_field = -1; +static int hf_gsm_a_rp_cause = -1; +static int hf_gsm_a_rp_message_elements = -1; +static int hf_gsm_a_rp_rp_message_reference = -1; /* Initialize the subtree pointers */ static gint ett_rp_msg = -1; -static char a_bigbuf[1024]; - static dissector_handle_t gsm_sms_handle; /* SMS TPDU */ static proto_tree *g_tree; @@ -104,18 +109,11 @@ gint ett_gsm_rp_elem[NUM_GSM_RP_ELEM]; static guint16 de_rp_message_ref(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_) { - guint8 oct; guint32 curr_offset; curr_offset = offset; - oct = tvb_get_guint8(tvb, curr_offset); - - proto_tree_add_text(tree, - tvb, curr_offset, 1, - "RP-Message Reference: 0x%02x (%u)", - oct, - oct); + proto_tree_add_item(tree, hf_gsm_a_rp_rp_message_reference, tvb, curr_offset, 1, ENC_NA); curr_offset++; @@ -153,8 +151,7 @@ de_rp_user_data(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 off curr_offset = offset; - proto_tree_add_text(tree, tvb, curr_offset, len, - "TPDU (not displayed)"); + proto_tree_add_bytes_format(tree, hf_gsm_a_rp_tpdu, tvb, curr_offset, len, NULL, "TPDU (not displayed)"); /* * dissect the embedded TPDU message @@ -173,73 +170,59 @@ de_rp_user_data(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 off /* * [5] 8.2.5.4 */ +static const value_string gsm_rp_cause_vals[] = { + { 1, "Unassigned (unallocated) number" }, + { 8, "Operator determined barring" }, + { 10, "Call barred" }, + { 11, "Reserved" }, + { 21, "Short message transfer rejected" }, + { 22, "Memory capacity exceeded" }, + { 27, "Destination out of order" }, + { 28, "Unidentified subscriber" }, + { 29, "Facility rejected" }, + { 30, "Unknown subscriber" }, + { 38, "Network out of order" }, + { 41, "Temporary failure" }, + { 42, "Congestion" }, + { 47, "Resources unavailable, unspecified" }, + { 50, "Requested facility not subscribed" }, + { 69, "Requested facility not implemented" }, + { 81, "Invalid short message transfer reference value" }, + { 95, "Semantically incorrect message" }, + { 96, "Invalid mandatory information" }, + { 97, "Message type non-existent or not implemented" }, + { 98, "Message not compatible with short message protocol state" }, + { 99, "Information element non-existent or not implemented" }, + { 111, "Protocol error, unspecified" }, + { 127, "Interworking, unspecified" }, + { 0, NULL } +}; + +value_string_ext gsm_rp_cause_vals_ext = VALUE_STRING_EXT_INIT(gsm_rp_cause_vals); + +static const true_false_string tfs_extended_no_extension = { "Extended", "No extension"}; + static guint16 de_rp_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len) { guint8 oct; guint32 curr_offset; - const gchar *str; curr_offset = offset; oct = tvb_get_guint8(tvb, curr_offset); - other_decode_bitfield_value(a_bigbuf, oct, 0x80, 8); - proto_tree_add_text(tree, - tvb, curr_offset, 1, - "%s : Extension: %s", - a_bigbuf, - (oct & 0x80) ? "extended" : "not extended"); - - switch (oct & 0x7f) - { - case 1: str = "Unassigned (unallocated) number"; break; - case 8: str = "Operator determined barring"; break; - case 10: str = "Call barred"; break; - case 11: str = "Reserved"; break; - case 21: str = "Short message transfer rejected"; break; - case 22: str = "Memory capacity exceeded"; break; - case 27: str = "Destination out of order"; break; - case 28: str = "Unidentified subscriber"; break; - case 29: str = "Facility rejected"; break; - case 30: str = "Unknown subscriber"; break; - case 38: str = "Network out of order"; break; - case 41: str = "Temporary failure"; break; - case 42: str = "Congestion"; break; - case 47: str = "Resources unavailable, unspecified"; break; - case 50: str = "Requested facility not subscribed"; break; - case 69: str = "Requested facility not implemented"; break; - case 81: str = "Invalid short message transfer reference value"; break; - case 95: str = "Semantically incorrect message"; break; - case 96: str = "Invalid mandatory information"; break; - case 97: str = "Message type non-existent or not implemented"; break; - case 98: str = "Message not compatible with short message protocol state"; break; - case 99: str = "Information element non-existent or not implemented"; break; - case 111: str = "Protocol error, unspecified"; break; - case 127: str = "Interworking, unspecified"; break; - default: - str = "Reserved"; - break; - } - - other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8); - proto_tree_add_text(tree, - tvb, curr_offset, 1, - "%s : Cause: (%u) %s", - a_bigbuf, - oct & 0x7f, - str); + proto_tree_add_item(tree, hf_gsm_a_rp_extension, tvb, curr_offset, 1, ENC_NA); + proto_tree_add_item(tree, hf_gsm_a_rp_cause, tvb, curr_offset, 1, ENC_NA); curr_offset++; if (add_string) - g_snprintf(add_string, string_len, " - (%u) %s", oct & 0x7f, str); + g_snprintf(add_string, string_len, " - (%u) %s", oct & 0x7f, val_to_str_ext_const(oct & 0x7f, &gsm_rp_cause_vals_ext, "Reserved")); NO_MORE_DATA_CHECK(len); - proto_tree_add_text(tree, - tvb, curr_offset, len - (curr_offset - offset), - "Diagnostic field"); + proto_tree_add_item(tree, hf_gsm_a_rp_diagnostic_field, tvb, curr_offset, len - (curr_offset - offset), ENC_NA); curr_offset += len - (curr_offset - offset); @@ -503,9 +486,7 @@ dissect_rp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ if (rp_msg_fcn[idx] == NULL) { - proto_tree_add_text(rp_tree, - tvb, offset, len - offset, - "Message Elements"); + proto_tree_add_item(rp_tree, hf_gsm_a_rp_message_elements, tvb, offset, len - offset, ENC_NA); } else { @@ -533,6 +514,14 @@ proto_register_gsm_a_rp(void) FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } }, + + /* Generated from convert_proto_tree_add_text.pl */ + { &hf_gsm_a_rp_rp_message_reference, { "RP-Message Reference", "gsm_a.rp.rp_message_reference", FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_gsm_a_rp_tpdu, { "TPDU", "gsm_a.rp.tpdu", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_gsm_a_rp_extension, { "Extension", "gsm_a.rp.extension", FT_BOOLEAN, 8, TFS(&tfs_extended_no_extension), 0x80, NULL, HFILL }}, + { &hf_gsm_a_rp_cause, { "Cause", "gsm_a.rp.cause", FT_UINT8, BASE_DEC|BASE_EXT_STRING, &gsm_rp_cause_vals_ext, 0x7F, NULL, HFILL }}, + { &hf_gsm_a_rp_diagnostic_field, { "Diagnostic field", "gsm_a.rp.diagnostic_field", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_gsm_a_rp_message_elements, { "Message Elements", "gsm_a.rp.message_elements", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, }; /* Setup protocol subtree array */ |