diff options
author | Michael Mann <mmann78@netscape.net> | 2014-08-07 08:36:30 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-08-08 05:51:52 +0000 |
commit | a22b7075f84b8faf83a3ef05e45ea6d922c5001f (patch) | |
tree | 519e874bc10d1231b0dd9632dd91dabbb11502ef /epan | |
parent | 532a98dc8c827471e143c81517b7ebb321400f84 (diff) |
Eliminate proto_tree_add_text from some dissectors.
Change-Id: I6f1710a093fc548c718defa9b40ab68877ede977
Reviewed-on: https://code.wireshark.org/review/3470
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
27 files changed, 444 insertions, 292 deletions
diff --git a/epan/dissectors/packet-fcfzs.c b/epan/dissectors/packet-fcfzs.c index 421270a394..532bd72c2b 100644 --- a/epan/dissectors/packet-fcfzs.c +++ b/epan/dissectors/packet-fcfzs.c @@ -29,6 +29,7 @@ #include <epan/to_str.h> #include <epan/wmem/wmem.h> #include <epan/conversation.h> +#include <epan/expert.h> #include <epan/etypes.h> #include "packet-fc.h" #include "packet-fcct.h" @@ -72,6 +73,8 @@ static gint ett_fcfzs = -1; static gint ett_fcfzs_gzc_flags = -1; static gint ett_fcfzs_zone_state = -1; +static expert_field ei_fcfzs_no_exchange = EI_INIT; + typedef struct _fcfzs_conv_key { guint32 conv_idx; } fcfzs_conv_key_t; @@ -667,7 +670,7 @@ dissect_fcfzs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) val_to_str(opcode, fc_fzs_opcode_val, "0x%x")); /* No record of what this accept is for. Can't decode */ - proto_tree_add_text(fcfzs_tree, tvb, 0, tvb_length(tvb), + proto_tree_add_expert_format(fcfzs_tree, pinfo, &ei_fcfzs_no_exchange, tvb, 0, -1, "No record of Exchg. Unable to decode MSG_ACC"); return 0; } @@ -697,7 +700,7 @@ dissect_fcfzs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) if ((cdata == NULL) && (opcode != FCCT_MSG_RJT)) { /* No record of what this accept is for. Can't decode */ - proto_tree_add_text(fcfzs_tree, tvb, 0, tvb_length(tvb), + proto_tree_add_expert_format(fcfzs_tree, pinfo, &ei_fcfzs_no_exchange, tvb, 0, -1, "No record of Exchg. Unable to decode MSG_ACC/RJT"); return 0; } @@ -916,10 +919,18 @@ proto_register_fcfzs(void) &ett_fcfzs_zone_state, }; + static ei_register_info ei[] = { + { &ei_fcfzs_no_exchange, { "fcfzs.no_exchange", PI_UNDECODED, PI_WARN, "No record of Exchg. Unable to decode", EXPFILL }}, + }; + + expert_module_t* expert_fcfzs; + proto_fcfzs = proto_register_protocol("Fibre Channel Fabric Zone Server", "FC FZS", "fcfzs"); proto_register_field_array(proto_fcfzs, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_fcfzs = expert_register_protocol(proto_fcfzs); + expert_register_field_array(expert_fcfzs, ei, array_length(ei)); register_init_routine(&fcfzs_init_protocol); } diff --git a/epan/dissectors/packet-fcgi.c b/epan/dissectors/packet-fcgi.c index fec38bafc8..a7ce950b62 100644 --- a/epan/dissectors/packet-fcgi.c +++ b/epan/dissectors/packet-fcgi.c @@ -46,9 +46,11 @@ static int hf_fcgi_begin_request_flags = -1; static int hf_fcgi_begin_request_keep_conn = -1; static int hf_fcgi_end_request_app_status = -1; static int hf_fcgi_end_request_protocol_status = -1; +static int hf_fcgi_nv_name = -1; static int ett_fcgi = -1; static int ett_fcgi_begin_request = -1; +static int ett_fcgi_abort_request = -1; static int ett_fcgi_end_request = -1; static int ett_fcgi_params = -1; @@ -133,9 +135,11 @@ dissect_nv_pairs(tvbuff_t *tvb, proto_tree *fcgi_tree, gint offset, guint16 len) value = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, valuelen, ENC_ASCII); offset += valuelen; - proto_tree_add_text(fcgi_tree, tvb, start_offset, offset - start_offset, "%s = %s", name, value); + proto_tree_add_string_format(fcgi_tree, hf_fcgi_nv_name, tvb, start_offset, offset - start_offset, + name, "%s = %s", name, value); } else { - proto_tree_add_text(fcgi_tree, tvb, start_offset, offset - start_offset, "%s", name); + proto_tree_add_string_format(fcgi_tree, hf_fcgi_nv_name, tvb, start_offset, offset - start_offset, + name, "%s", name); } } } @@ -162,7 +166,7 @@ dissect_begin_request(tvbuff_t *tvb, proto_tree *fcgi_tree, gint offset, guint16 static void dissect_abort_request(tvbuff_t *tvb, proto_tree *fcgi_tree, gint offset, guint16 len) { - proto_tree_add_text(fcgi_tree, tvb, offset, len, "Abort Request:"); + proto_tree_add_subtree(fcgi_tree, tvb, offset, len, ett_fcgi_abort_request, NULL, "Abort Request:"); return; } @@ -366,11 +370,15 @@ proto_register_fcgi(void) FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { &hf_fcgi_end_request_protocol_status, { "Protocol Status", "fcgi.end_request.protocol_status", - FT_UINT32, BASE_DEC, VALS(protocol_statuses), 0x0, NULL, HFILL } } + FT_UINT32, BASE_DEC, VALS(protocol_statuses), 0x0, NULL, HFILL } }, + { &hf_fcgi_nv_name, + { "NV Pair name", "fcgi.nv_name", + FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } }, }; static gint *ett[] = { &ett_fcgi, &ett_fcgi_begin_request, + &ett_fcgi_abort_request, &ett_fcgi_end_request, &ett_fcgi_params }; diff --git a/epan/dissectors/packet-fcoe.c b/epan/dissectors/packet-fcoe.c index d8d9573285..ac05a98234 100644 --- a/epan/dissectors/packet-fcoe.c +++ b/epan/dissectors/packet-fcoe.c @@ -233,8 +233,8 @@ dissect_fcoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_set_appendix(fcoe_tree, tvb, crc_offset, tvb_length_remaining (tvb, crc_offset)); } else { - item = proto_tree_add_text(fcoe_tree, tvb, crc_offset, 0, - "CRC: [missing]"); + item = proto_tree_add_uint_format_value(fcoe_tree, hf_fcoe_crc, tvb, crc_offset, 0, + 0, "CRC: [missing]"); } crc_tree = proto_item_add_subtree(item, ett_fcoe_crc); ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_bad, tvb, diff --git a/epan/dissectors/packet-fcoib.c b/epan/dissectors/packet-fcoib.c index 53c088f9d6..c95bd27538 100644 --- a/epan/dissectors/packet-fcoib.c +++ b/epan/dissectors/packet-fcoib.c @@ -286,8 +286,8 @@ dissect_fcoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U proto_tree_set_appendix(fcoib_tree, tvb, crc_offset, tvb_length_remaining (tvb, crc_offset)); } else { - item = proto_tree_add_text(fcoib_tree, tvb, crc_offset, 0, - "CRC: [missing]"); + item = proto_tree_add_uint_format_value(fcoib_tree, hf_fcoib_crc, tvb, crc_offset, 0, + 0, "CRC: [missing]"); } crc_tree = proto_item_add_subtree(item, ett_fcoib_crc); ti = proto_tree_add_boolean(crc_tree, hf_fcoib_crc_bad, tvb, diff --git a/epan/dissectors/packet-fcp.c b/epan/dissectors/packet-fcp.c index 35d3b4e963..5558dc782d 100644 --- a/epan/dissectors/packet-fcp.c +++ b/epan/dissectors/packet-fcp.c @@ -54,6 +54,7 @@ static int hf_fcp_wrdata = -1; static int hf_fcp_dl = -1; static int hf_fcp_bidir_dl = -1; static int hf_fcp_data_ro = -1; +static int hf_fcp_r_ctl = -1; static int hf_fcp_burstlen = -1; static int hf_fcp_rspflags = -1; static int hf_fcp_retry_delay_timer = -1; @@ -81,10 +82,9 @@ static int hf_fcp_rsp_flags_res_vld = -1; static int hf_fcp_request_in = -1; static int hf_fcp_response_in = -1; static int hf_fcp_time = -1; -/* static int hf_fcp_srr_op = -1; */ +static int hf_fcp_els_op = -1; static int hf_fcp_srr_ox_id = -1; static int hf_fcp_srr_rx_id = -1; -/* static int hf_fcp_srr_r_ctl = -1; */ /* Initialize the subtree pointers */ static gint ett_fcp = -1; @@ -671,9 +671,7 @@ dissect_fcp_srr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, fc_hdr proto_tree_add_item(tree, hf_fcp_srr_ox_id, tvb, 4, 2, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_fcp_srr_rx_id, tvb, 6, 2, ENC_BIG_ENDIAN); proto_tree_add_item(tree, hf_fcp_data_ro, tvb, 8, 4, ENC_BIG_ENDIAN); - r_ctl = tvb_get_guint8(tvb, 12); - proto_tree_add_text(tree, tvb, 12, 1, "R_CTL: %s", - val_to_str(r_ctl, fcp_iu_val, "0x%02x")); + proto_tree_add_item(tree, hf_fcp_r_ctl, tvb, 12, 1, ENC_NA); } } @@ -693,9 +691,7 @@ dissect_fcp_els(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, fc_hdr *fch op = tvb_get_guint8(tvb, 0); col_add_str(pinfo->cinfo, COL_INFO, val_to_str_ext(op, &fc_els_proto_val_ext, "0x%x")); - proto_tree_add_text(tree, tvb, 0, 1, "Opcode: %s", - val_to_str_ext(op, &fc_els_proto_val_ext, - "ELS 0x%02x")); + proto_tree_add_item(tree, hf_fcp_els_op, tvb, 0, 1, ENC_NA); switch (op) { /* XXX should switch based on conv for LS_ACC */ case FC_ELS_SRR: @@ -885,7 +881,12 @@ proto_register_fcp(void) { &hf_fcp_data_ro, {"FCP_DATA_RO", "fcp.data_ro", - FT_UINT32, BASE_DEC, NULL, 0x0, + FT_UINT32, BASE_DEC, VALS(fcp_iu_val), 0x0, + NULL, HFILL}}, + + { &hf_fcp_r_ctl, + {"R_CTL", "fcp.r_ctl", + FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}}, { &hf_fcp_burstlen, @@ -1023,12 +1024,10 @@ proto_register_fcp(void) FT_RELATIVE_TIME, BASE_NONE, NULL, 0, "Time since the FCP_CMND frame", HFILL }}, -#if 0 - { &hf_fcp_srr_op, + { &hf_fcp_els_op, {"Opcode", "fcp.els.op", - FT_UINT8, BASE_HEX, NULL, 0x0, + FT_UINT8, BASE_HEX|BASE_EXT_STRING, &fc_els_proto_val_ext, 0x0, NULL, HFILL}}, -#endif { &hf_fcp_srr_ox_id, {"OX_ID", "fcp.els.srr.ox_id", @@ -1039,13 +1038,6 @@ proto_register_fcp(void) {"RX_ID", "fcp.els.srr.rx_id", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}}, - -#if 0 - { &hf_fcp_srr_r_ctl, - {"R_CTL", "fcp.els.srr.r_ctl", - FT_UINT8, BASE_HEX, NULL, 0x0, - NULL, HFILL}}, -#endif }; /* Setup protocol subtree array */ diff --git a/epan/dissectors/packet-fcsb3.c b/epan/dissectors/packet-fcsb3.c index fe6e94fab8..afd6dafcf5 100644 --- a/epan/dissectors/packet-fcsb3.c +++ b/epan/dissectors/packet-fcsb3.c @@ -105,6 +105,7 @@ static int hf_sbccs_dib_ctlparam_ro = -1; static int hf_sbccs_dib_linkctlinfo = -1; static int hf_sbccs_dib_linkctlinfo_ctcconn = -1; static int hf_sbccs_dib_linkctlinfo_ecrcg = -1; +static int hf_sbccs_logical_path = -1; /* Initialize the subtree pointers */ static gint ett_fc_sbccs = -1; @@ -800,8 +801,8 @@ static void dissect_fc_sbccs_dib_link_hdr (tvbuff_t *tvb, packet_info *pinfo, offset += 16; while (i < link_payload_len) { - proto_tree_add_text (tree, tvb, offset, 4, - "Logical Paths %d-%d: %s", + proto_tree_add_bytes_format(tree, hf_sbccs_logical_path, tvb, offset, 4, + NULL, "Logical Paths %d-%d: %s", i*8, ((i+4)*8) - 1, tvb_bytes_to_ep_str_punct (tvb, offset, 4, ':')); i += 4; @@ -1254,6 +1255,11 @@ proto_register_fcsbccs (void) { "Enhanced CRC Generation", "fcsb3.linkctlinfo.ecrcg", FT_BOOLEAN, 16, TFS(&tfs_supported_not_supported), 0x01, NULL, HFILL}}, + + { &hf_sbccs_logical_path, + { "Logical Path", "fcsb3.logical_path", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL}}, }; diff --git a/epan/dissectors/packet-fcsp.c b/epan/dissectors/packet-fcsp.c index ff1a836562..205ab0bf66 100644 --- a/epan/dissectors/packet-fcsp.c +++ b/epan/dissectors/packet-fcsp.c @@ -29,6 +29,7 @@ #include <epan/packet.h> #include <epan/to_str.h> #include <epan/conversation.h> +#include <epan/expert.h> #include <epan/etypes.h> #include "packet-fc.h" @@ -95,6 +96,8 @@ static int hf_auth_dhchap_rsp_value = -1; /* Initialize the subtree pointers */ static gint ett_fcsp = -1; +static expert_field ei_auth_fcap_undecoded = EI_INIT; + static const value_string fcauth_msgcode_vals[] = { {FC_AUTH_MSG_AUTH_REJECT, "AUTH_Reject"}, {FC_AUTH_MSG_AUTH_NEGOTIATE, "AUTH_Negotiate"}, @@ -426,8 +429,7 @@ static void dissect_fcsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case FC_AUTH_FCPAP_INIT: case FC_AUTH_FCPAP_ACCEPT: case FC_AUTH_FCPAP_COMPLETE: - proto_tree_add_text(fcsp_tree, tvb, offset+12, tvb_length(tvb), - "FCAP Decoding Not Supported"); + proto_tree_add_expert(fcsp_tree, pinfo, &ei_auth_fcap_undecoded, tvb, offset+12, -1); break; default: break; @@ -601,13 +603,20 @@ proto_register_fcsp(void) &ett_fcsp, }; + static ei_register_info ei[] = { + { &ei_auth_fcap_undecoded, { "fcsp.fcap_undecoded", PI_UNDECODED, PI_WARN, "FCAP Decoding Not Supported", EXPFILL }}, + }; + + expert_module_t* expert_fcsp; + /* Register the protocol name and description */ - proto_fcsp = proto_register_protocol("Fibre Channel Security Protocol", - "FC-SP", "fcsp"); + proto_fcsp = proto_register_protocol("Fibre Channel Security Protocol", "FC-SP", "fcsp"); register_dissector("fcsp", dissect_fcsp, proto_fcsp); proto_register_field_array(proto_fcsp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_fcsp = expert_register_protocol(proto_fcsp); + expert_register_field_array(expert_fcsp, ei, array_length(ei)); } diff --git a/epan/dissectors/packet-fefd.c b/epan/dissectors/packet-fefd.c index 603a0c4199..b11ffa509e 100644 --- a/epan/dissectors/packet-fefd.c +++ b/epan/dissectors/packet-fefd.c @@ -46,6 +46,9 @@ static int hf_fefd_flags_rsy = -1; static int hf_fefd_checksum = -1; static int hf_fefd_tlvtype = -1; static int hf_fefd_tlvlength = -1; +static int hf_fefd_device_id = -1; +static int hf_fefd_sent_through_interface = -1; +static int hf_fefd_data = -1; static gint ett_fefd = -1; static gint ett_fefd_flags = -1; @@ -94,7 +97,6 @@ dissect_fefd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) int offset = 0; guint16 type; guint16 length; - proto_item *tlvi; proto_tree *tlv_tree; int real_length; @@ -128,10 +130,9 @@ dissect_fefd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) length = tvb_get_ntohs(tvb, offset + TLV_LENGTH); if (length < 4) { if (tree) { - tlvi = proto_tree_add_text(fefd_tree, tvb, offset, 4, - "TLV with invalid length %u (< 4)", + tlv_tree = proto_tree_add_subtree_format(fefd_tree, tvb, offset, 4, /* XXX - expert info? */ + ett_fefd_tlv, NULL, "TLV with invalid length %u (< 4)", length); - tlv_tree = proto_item_add_subtree(tlvi, ett_fefd_tlv); proto_tree_add_uint(tlv_tree, hf_fefd_tlvtype, tvb, offset + TLV_TYPE, 2, type); proto_tree_add_uint(tlv_tree, hf_fefd_tlvlength, tvb, @@ -159,9 +160,8 @@ dissect_fefd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset + TLV_TYPE, 2, type); proto_tree_add_uint(tlv_tree, hf_fefd_tlvlength, tvb, offset + TLV_LENGTH, 2, length); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "Device ID: %s", - tvb_format_stringzpad(tvb, offset + 4, length - 4)); + proto_tree_add_item(tlv_tree, hf_fefd_device_id, tvb, offset + 4, + length - 4, ENC_NA|ENC_ASCII); } offset += length; break; @@ -190,10 +190,8 @@ dissect_fefd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset + TLV_TYPE, 2, type); proto_tree_add_uint(tlv_tree, hf_fefd_tlvlength, tvb, offset + TLV_LENGTH, 2, length); - proto_tree_add_text(tlv_tree, tvb, offset + 4, - real_length - 4, - "Sent through Interface: %s", - tvb_format_text(tvb, offset + 4, real_length - 4)); + proto_tree_add_item(tlv_tree, hf_fefd_sent_through_interface, tvb, offset + 4, + real_length - 4, ENC_NA|ENC_ASCII); } offset += real_length; break; @@ -213,8 +211,8 @@ dissect_fefd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint(tlv_tree, hf_fefd_tlvlength, tvb, offset + TLV_LENGTH, 2, length); if (length > 4) { - proto_tree_add_text(tlv_tree, tvb, offset + 4, - length - 4, "Data"); + proto_tree_add_item(tlv_tree, hf_fefd_data, tvb, offset + 4, + length - 4, ENC_NA); } else { return; } @@ -259,8 +257,21 @@ proto_register_fefd(void) { &hf_fefd_tlvlength, { "Length", "fefd.tlv.len", FT_UINT16, BASE_DEC, NULL, 0x0, - NULL, HFILL }} + NULL, HFILL }}, + + { &hf_fefd_device_id, + { "Device ID", "fefd.device_id", FT_STRINGZ, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_fefd_sent_through_interface, + { "Sent through Interface", "fefd.sent_through_interface", FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_fefd_data, + { "Data", "fefd.data", FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, }; + static gint *ett[] = { &ett_fefd, &ett_fefd_flags, diff --git a/epan/dissectors/packet-fip.c b/epan/dissectors/packet-fip.c index 0903c35a5e..dae528f04f 100644 --- a/epan/dissectors/packet-fip.c +++ b/epan/dissectors/packet-fip.c @@ -211,6 +211,7 @@ static int hf_fip_flag_rec_p2p = -1; static int hf_fip_flag_avail = -1; static int hf_fip_flag_sol = -1; static int hf_fip_flag_fport = -1; +static int hf_fip_descriptors = -1; static const int *hf_fip_flags_fields[] = { &hf_fip_flag_fpma, @@ -266,16 +267,24 @@ static int ett_fip_dt_fc4f = -1; static int ett_fip_dt_fc4f_types = -1; static int ett_fip_dt_fcp_feat = -1; +static expert_field ei_fip_descriptors = EI_INIT; + static dissector_handle_t fc_handle; /* * Insert common descriptor type and length fields. */ -static void -fip_desc_type_len(proto_tree *tree, tvbuff_t *tvb) +static proto_tree* +fip_desc_type_len(proto_tree *tree, tvbuff_t *tvb, guint8 dtype, int ett, proto_item** item) { - proto_tree_add_item(tree, hf_fip_desc_type, tvb, 0, 1, ENC_BIG_ENDIAN); - proto_tree_add_item(tree, hf_fip_desc_len, tvb, 1, 1, ENC_BIG_ENDIAN); + proto_tree* ret_tree; + + ret_tree = proto_tree_add_subtree_format(tree, tvb, 0, -1, ett, item, + "Descriptor: %s ", val_to_str(dtype, fip_desc_types, "Unknown 0x%x")); + proto_tree_add_item(ret_tree, hf_fip_desc_type, tvb, 0, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(ret_tree, hf_fip_desc_len, tvb, 1, 1, ENC_BIG_ENDIAN); + + return ret_tree; } /* @@ -419,13 +428,12 @@ dissect_fip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) desc_offset = FIP_HEADER_LEN; rlen *= FIP_BPW; - proto_tree_add_text(fip_tree, tvb, desc_offset, rlen, "Descriptors:"); + proto_tree_add_bytes_format(fip_tree, hf_fip_descriptors, tvb, desc_offset, rlen, NULL, "Descriptors"); while ((rlen > 0) && tvb_bytes_exist(tvb, desc_offset, 2)) { dlen = tvb_get_guint8(tvb, desc_offset + 1) * FIP_BPW; if (!dlen) { - proto_tree_add_text(fip_tree, tvb, desc_offset, -1, - "Descriptor [length error]"); + proto_tree_add_expert(fip_tree, pinfo, &ei_fip_descriptors, tvb, desc_offset, -1); break; } if (!tvb_bytes_exist(tvb, desc_offset, dlen) || dlen > rlen) { @@ -436,44 +444,36 @@ dissect_fip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) desc_offset += dlen; rlen -= dlen; - item = proto_tree_add_text(fip_tree, desc_tvb, 0, -1, "Descriptor: %s ", - val_to_str(dtype, fip_desc_types, "Unknown 0x%x")); - switch (dtype) { case FIP_DT_PRI: - subtree = proto_item_add_subtree(item, ett_fip_dt_pri); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_pri, &item); proto_tree_add_item(subtree, hf_fip_desc_pri, desc_tvb, 3, 1, ENC_BIG_ENDIAN); proto_item_append_text(item, "%u", tvb_get_guint8(desc_tvb, 3)); break; case FIP_DT_MAC: - subtree = proto_item_add_subtree(item, ett_fip_dt_mac); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_mac, &item); proto_tree_add_item(subtree, hf_fip_desc_mac, desc_tvb, 2, 6, ENC_NA); proto_item_append_text(item, "%s", tvb_bytes_to_ep_str_punct(desc_tvb, 2, 6, ':')); break; case FIP_DT_MAP_OUI: - subtree = proto_item_add_subtree(item, ett_fip_dt_map); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_map, &item); text = tvb_fc_to_str(desc_tvb, 5); proto_tree_add_string(subtree, hf_fip_desc_map, desc_tvb, 5, 3, text); proto_item_append_text(item, "%s", text); break; case FIP_DT_NAME: - subtree = proto_item_add_subtree(item, ett_fip_dt_name); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_name, &item); text = tvb_fcwwn_to_str(desc_tvb, 4); proto_tree_add_string(subtree, hf_fip_desc_name, desc_tvb, 4, 8, text); proto_item_append_text(item, "%s", text); break; case FIP_DT_FAB: - subtree = proto_item_add_subtree(item, ett_fip_dt_fab); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_fab, &item); proto_tree_add_item(subtree, hf_fip_desc_fab_vfid, desc_tvb, 2, 2, ENC_BIG_ENDIAN); text = tvb_fc_to_str(desc_tvb, 5); @@ -485,8 +485,7 @@ dissect_fip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item_append_text(item, "%s", text); break; case FIP_DT_FCOE_SIZE: - subtree = proto_item_add_subtree(item, ett_fip_dt_mdl); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_mdl, &item); proto_tree_add_item(subtree, hf_fip_desc_fcoe_size, desc_tvb, 2, 2, ENC_BIG_ENDIAN); proto_item_append_text(item, "%u", tvb_get_ntohs(desc_tvb, 2)); @@ -498,16 +497,14 @@ dissect_fip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvbuff_t *ls_tvb; fc_data_t fc_data = {ETHERTYPE_FIP, 0}; - subtree = proto_item_add_subtree(item, ett_fip_dt_caps); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_caps, &item); ls_tvb = tvb_new_subset(desc_tvb, 4, dlen - 4, -1); call_dissector_with_data(fc_handle, ls_tvb, pinfo, subtree, &fc_data); proto_item_append_text(item, "%u bytes", dlen - 4); } break; case FIP_DT_VN: - subtree = proto_item_add_subtree(item, ett_fip_dt_vn); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_vn, &item); proto_tree_add_item(subtree, hf_fip_desc_vn_mac, desc_tvb, 2, 6, ENC_NA); proto_tree_add_item(subtree, hf_fip_desc_vn_fid, desc_tvb, @@ -520,16 +517,14 @@ dissect_fip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tvb_get_ntoh24(desc_tvb, 9)); break; case FIP_DT_FKA: - subtree = proto_item_add_subtree(item, ett_fip_dt_fka); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_fka, &item); val = tvb_get_ntohl(desc_tvb, 4); proto_tree_add_uint_format_value(subtree, hf_fip_desc_fka, desc_tvb, 4, 4, val, "%u ms", val); proto_item_append_text(item, "%u ms", val); break; case FIP_DT_VEND: - subtree = proto_item_add_subtree(item, ett_fip_dt_vend); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_vend, &item); proto_tree_add_item(subtree, hf_fip_desc_vend, desc_tvb, 4, 8, ENC_NA); if (tvb_bytes_exist(desc_tvb, 9, -1)) { @@ -538,20 +533,17 @@ dissect_fip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } break; case FIP_DT_VLAN: - subtree = proto_item_add_subtree(item, ett_fip_dt_vlan); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_vlan, &item); proto_tree_add_item(subtree, hf_fip_desc_vlan, desc_tvb, 2, 2, ENC_BIG_ENDIAN); proto_item_append_text(item, "%u", tvb_get_ntohs(desc_tvb, 2)); break; case FIP_DT_FC4F: - subtree = proto_item_add_subtree(item, ett_fip_dt_fc4f); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_fc4f, &item); fip_desc_fc4f(desc_tvb, subtree, item); break; default: - subtree = proto_item_add_subtree(item, ett_fip_dt_unk); - fip_desc_type_len(subtree, desc_tvb); + subtree = fip_desc_type_len(fip_tree, desc_tvb, dtype, ett_fip_dt_unk, &item); proto_tree_add_item(subtree, hf_fip_desc_unk, desc_tvb, 2, -1, ENC_NA); break; @@ -772,9 +764,14 @@ proto_register_fip(void) NULL, HFILL}}, { &hf_fip_desc_unk, - { "Unknown Descriptor", "fip.desc", + { "Unknown Descriptor", "fip.desc_unk", + FT_BYTES, BASE_NONE, NULL, 0, + NULL, HFILL}}, + + { &hf_fip_descriptors, + { "Descriptors", "fip.descriptors", FT_BYTES, BASE_NONE, NULL, 0, - NULL, HFILL}} + NULL, HFILL}}, }; static gint *ett[] = { @@ -797,6 +794,12 @@ proto_register_fip(void) &ett_fip_dt_unk }; + static ei_register_info ei[] = { + { &ei_fip_descriptors, { "fip.descriptors.length_error", PI_MALFORMED, PI_ERROR, "Descriptor [length error]", EXPFILL }}, + }; + + expert_module_t* expert_fip; + /* Register the protocol name and description */ proto_fip = proto_register_protocol("FCoE Initialization Protocol", "FIP", "fip"); @@ -805,6 +808,8 @@ proto_register_fip(void) * subtrees used */ proto_register_field_array(proto_fip, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_fip = expert_register_protocol(proto_fip); + expert_register_field_array(expert_fip, ei, array_length(ei)); } /* diff --git a/epan/dissectors/packet-fix.c b/epan/dissectors/packet-fix.c index 82b30193cf..2afccc61da 100644 --- a/epan/dissectors/packet-fix.c +++ b/epan/dissectors/packet-fix.c @@ -299,8 +299,7 @@ dissect_fix_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* da tree) and then gives up, it leaves crud behind that messes up other dissectors that might process the packet. */ - ti = proto_tree_add_text(fix_tree, tvb, field_offset, tag->field_len, "%i: <missing value>", tag_value); - field_tree = proto_item_add_subtree(ti, ett_badfield); + field_tree = proto_tree_add_subtree_format(fix_tree, tvb, field_offset, tag->field_len, ett_badfield, NULL, "%i: <missing value>", tag_value); proto_tree_add_uint(field_tree, hf_fix_field_tag, tvb, field_offset, tag->tag_len, tag_value); field_offset = tag->ctrla_offset + 1; continue; diff --git a/epan/dissectors/packet-foundry.c b/epan/dissectors/packet-foundry.c index 624d2f90ed..9baf5afb93 100644 --- a/epan/dissectors/packet-foundry.c +++ b/epan/dissectors/packet-foundry.c @@ -27,6 +27,7 @@ #include <glib.h> #include <epan/packet.h> +#include <epan/expert.h> #include <epan/strutil.h> #include <epan/in_cksum.h> #include "packet-llc.h" @@ -75,6 +76,8 @@ static gint ett_fdp_net = -1; static gint ett_fdp_tag = -1; static gint ett_fdp_vlanmap = -1; +static expert_field ei_fdp_tlv_length = EI_INIT; + #define PROTO_SHORT_NAME "FDP" #define PROTO_LONG_NAME "Foundry Discovery Protocol" @@ -292,16 +295,15 @@ dissect_fdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Decode the individual TLVs */ while (offset < data_length) { if (data_length - offset < 4) { - proto_tree_add_text(fdp_tree, tvb, offset, 4, - "Too few bytes left for TLV: %u (< 4)", - data_length - offset); + proto_tree_add_expert_format(fdp_tree, pinfo, &ei_fdp_tlv_length, tvb, offset, 4, + "Too few bytes left for TLV: %u (< 4)", data_length - offset); break; } tlv_type = tvb_get_ntohs(tvb, offset); tlv_length = tvb_get_ntohs(tvb, offset + 2); if ((tlv_length < 4) || (tlv_length > (data_length - offset))) { - proto_tree_add_text(fdp_tree, tvb, offset, 0, + proto_tree_add_expert_format(fdp_tree, pinfo, &ei_fdp_tlv_length, tvb, offset, 0, "TLV with invalid length: %u", tlv_length); break; } @@ -438,10 +440,18 @@ proto_register_fdp(void) &ett_fdp_vlanmap, }; - proto_fdp = proto_register_protocol(PROTO_LONG_NAME, - PROTO_SHORT_NAME, "fdp"); - proto_register_field_array(proto_fdp, hf, array_length(hf)); + static ei_register_info ei[] = { + { &ei_fdp_tlv_length, { "fdp.tlv.length.invalid", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }}, + }; + + expert_module_t* expert_fdp; + + proto_fdp = proto_register_protocol(PROTO_LONG_NAME, PROTO_SHORT_NAME, "fdp"); + + proto_register_field_array(proto_fdp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_fdp = expert_register_protocol(proto_fdp); + expert_register_field_array(expert_fdp, ei, array_length(ei)); } void diff --git a/epan/dissectors/packet-fp_hint.c b/epan/dissectors/packet-fp_hint.c index 9934024511..ad4ab95c99 100644 --- a/epan/dissectors/packet-fp_hint.c +++ b/epan/dissectors/packet-fp_hint.c @@ -29,6 +29,7 @@ #include <wiretap/wtap.h> #include <epan/wmem/wmem.h> #include <epan/conversation.h> +#include <epan/expert.h> #include "packet-umts_fp.h" #include "packet-umts_mac.h" #include "packet-rlc.h" @@ -68,6 +69,10 @@ static int hf_fph_tf = -1; static int hf_fph_tf_n = -1; static int hf_fph_tf_size = -1; +static expert_field ei_fph_radio_bearers = EI_INIT; +static expert_field ei_fph_mac_frames = EI_INIT; +static expert_field ei_fph_fp_channels = EI_INIT; + static dissector_handle_t data_handle; static dissector_handle_t ethwithfcs_handle; static dissector_handle_t atm_untrunc_handle; @@ -175,13 +180,13 @@ static guint16 assign_rb_info(tvbuff_t *tvb, packet_info *pinfo, guint16 offset, deciphered = (next_byte >> 3) & 0x1; if (i >= MAX_RLC_CHANS) { - proto_tree_add_text(tree, tvb, offset, -1, + proto_tree_add_expert_format(tree, pinfo, &ei_fph_radio_bearers, tvb, offset, -1, "Frame contains more Radio Bearers than currently supported (%u present, %u supported)", rbcnt, MAX_RLC_CHANS); return -1; } if (i >= MAX_MAC_FRAMES) { - proto_tree_add_text(tree, tvb, offset, -1, + proto_tree_add_expert_format(tree, pinfo, &ei_fph_mac_frames, tvb, offset, -1, "Frame contains more MAC Frames than currently supported (%u present, %u supported)", rbcnt, MAX_MAC_FRAMES); return -1; @@ -325,7 +330,7 @@ static void assign_fph_dch(tvbuff_t *tvb, packet_info *pinfo, guint16 offset, fp } offset += 4; if (i > MAX_FP_CHANS) { - proto_tree_add_text(tree, tvb, offset, -1, + proto_tree_add_expert_format(tree, pinfo, &ei_fph_fp_channels, tvb, offset, -1, "Frame contains more FP channels than currently supported (%u supported)", MAX_FP_CHANS); return; @@ -415,7 +420,7 @@ static void assign_fph_edch(tvbuff_t *tvb, packet_info *pinfo, guint16 offset, f } i++; if (i >= MAX_EDCH_DDIS) { - proto_tree_add_text(tree, tvb, offset, -1, + proto_tree_add_expert_format(tree, pinfo, &ei_fph_fp_channels, tvb, offset, -1, "Frame contains more FP channels than currently supported (%u supported)", MAX_FP_CHANS); return; @@ -572,11 +577,21 @@ proto_register_fp_hint(void) &ett_fph_tf }; + static ei_register_info ei[] = { + { &ei_fph_radio_bearers, { "fp_hint.rb.invalid", PI_PROTOCOL, PI_WARN, "Frame contains more Radio Bearers than currently supported", EXPFILL }}, + { &ei_fph_mac_frames, { "cip.mac_frames.invalid", PI_PROTOCOL, PI_WARN, "Frame contains more MAC Frames than currently supported", EXPFILL }}, + { &ei_fph_fp_channels, { "fp_hint.fp_channels.invalid", PI_PROTOCOL, PI_WARN, "Frame contains more FP channels than currently supported", EXPFILL }}, + }; + + expert_module_t* expert_fp_hint; + proto_fp_hint = proto_register_protocol("FP Hint", "FP Hint", "fp_hint"); register_dissector("fp_hint", dissect_fp_hint, proto_fp_hint); proto_register_field_array(proto_fp_hint, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_fp_hint = expert_register_protocol(proto_fp_hint); + expert_register_field_array(expert_fp_hint, ei, array_length(ei)); } void diff --git a/epan/dissectors/packet-fr.c b/epan/dissectors/packet-fr.c index a44097f344..1f47356441 100644 --- a/epan/dissectors/packet-fr.c +++ b/epan/dissectors/packet-fr.c @@ -38,6 +38,7 @@ #include <epan/packet.h> #include <epan/prefs.h> +#include <epan/expert.h> #include <wiretap/wtap.h> #include "packet-llc.h" @@ -110,6 +111,13 @@ static gint hf_fr_oui = -1; static gint hf_fr_pid = -1; static gint hf_fr_snaptype = -1; static gint hf_fr_chdlctype = -1; +static gint hf_fr_first_addr_octet = -1; +static gint hf_fr_second_addr_octet = -1; +static gint hf_fr_third_addr_octet = -1; + +static expert_field ei_fr_bogus_address = EI_INIT; +static expert_field ei_fr_frame_relay_lapf = EI_INIT; +static expert_field ei_fr_frame_relay_xid = EI_INIT; static dissector_handle_t eth_withfcs_handle; static dissector_handle_t gprs_ns_handle; @@ -440,26 +448,24 @@ dissect_fr_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, * should dissect it as such, if possible. */ addr = 0; - if (tree) { - proto_tree_add_text(fr_tree, tvb, offset, 1, + proto_tree_add_expert_format(fr_tree, pinfo, &ei_fr_bogus_address, tvb, offset, 1, "Bogus 1-octet address field"); - offset++; - } + offset++; } else { + static const int *first_address_bits[] = {&hf_fr_upper_dlci, &hf_fr_cr, &hf_fr_ea, NULL}; + static const int *second_address_bits[] = {&hf_fr_second_dlci, &hf_fr_fecn, + &hf_fr_becn, &hf_fr_de, &hf_fr_ea, NULL}; + static const int *third_address_bits[] = {&hf_fr_third_dlci, &hf_fr_ea, NULL}; + /* * The first octet contains the upper 6 bits of the DLCI, as well * as the C/R bit. */ addr = (fr_octet & FRELAY_UPPER_DLCI) >> 2; is_response = (fr_octet & FRELAY_CR); - if (tree) { - octet_item = proto_tree_add_text(fr_tree, tvb, offset, 1, - "First address octet: 0x%02x", fr_octet); - octet_tree = proto_item_add_subtree(octet_item, ett_fr_address); - proto_tree_add_uint(octet_tree, hf_fr_upper_dlci, tvb, offset, 1, fr_octet); - proto_tree_add_boolean(octet_tree, hf_fr_cr, tvb, offset, 1, fr_octet); - proto_tree_add_boolean(octet_tree, hf_fr_ea, tvb, offset, 1, fr_octet); - } + + proto_tree_add_bitmask(fr_tree, tvb, offset, hf_fr_first_addr_octet, + ett_fr_address, first_address_bits, ENC_NA); offset++; /* @@ -468,17 +474,8 @@ dissect_fr_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, */ fr_octet = tvb_get_guint8(tvb, offset); addr = (addr << 4) | ((fr_octet & FRELAY_SECOND_DLCI) >> 4); - if (tree) { - octet_item = proto_tree_add_text(fr_tree, tvb, offset, 1, - "Second address octet: 0x%02x", - fr_octet); - octet_tree = proto_item_add_subtree(octet_item, ett_fr_address); - proto_tree_add_uint(octet_tree, hf_fr_second_dlci, tvb, offset, 1, fr_octet); - proto_tree_add_boolean(octet_tree, hf_fr_fecn, tvb, 0, offset, fr_octet); - proto_tree_add_boolean(octet_tree, hf_fr_becn, tvb, 0, offset, fr_octet); - proto_tree_add_boolean(octet_tree, hf_fr_de, tvb, 0, offset, fr_octet); - proto_tree_add_boolean(octet_tree, hf_fr_ea, tvb, offset, 1, fr_octet); - } + proto_tree_add_bitmask(fr_tree, tvb, offset, hf_fr_second_addr_octet, + ett_fr_address, second_address_bits, ENC_NA); offset++; if (!(fr_octet & FRELAY_EA)) { @@ -495,34 +492,24 @@ dissect_fr_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, * 7 more bits of DLCI. */ addr = (addr << 7) | ((fr_octet & FRELAY_THIRD_DLCI) >> 1); - if (tree) { - octet_item = proto_tree_add_text(fr_tree, tvb, offset, 1, - "Third address octet: 0x%02x", - fr_octet); - octet_tree = proto_item_add_subtree(octet_item, ett_fr_address); - proto_tree_add_uint(octet_tree, hf_fr_third_dlci, tvb, offset, 1, fr_octet); - proto_tree_add_boolean(octet_tree, hf_fr_ea, tvb, offset, 1, fr_octet); - } + proto_tree_add_bitmask(fr_tree, tvb, offset, hf_fr_third_addr_octet, + ett_fr_address, third_address_bits, ENC_NA); offset++; fr_octet = tvb_get_guint8(tvb, offset); while (!(fr_octet & FRELAY_EA)) { /* * Bogus! More than 4 octets of address. */ - if (tree) { - proto_tree_add_text(fr_tree, tvb, offset, 1, + proto_tree_add_expert_format(fr_tree, pinfo, &ei_fr_bogus_address, tvb, offset, 1, "Bogus extra address octet"); - } offset++; fr_octet = tvb_get_guint8(tvb, offset); } } - if (tree) { - octet_item = proto_tree_add_text(fr_tree, tvb, offset, 1, - "Final address octet: 0x%02x", + + octet_tree = proto_tree_add_subtree_format(fr_tree, tvb, offset, 1, + ett_fr_address, NULL, "Final address octet: 0x%02x", fr_octet); - octet_tree = proto_item_add_subtree(octet_item, ett_fr_address); - } /* * Last octet - contains lower DLCI or DL-CORE control, DLCI or @@ -681,8 +668,7 @@ dissect_fr_nlpid(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_item_set_end(ti, tvb, offset); fr_nlpid = tvb_get_guint8 (tvb,offset); if (fr_nlpid == 0) { - if (tree) - proto_tree_add_text(fr_tree, tvb, offset, 1, "Padding"); + proto_tree_add_uint_format(fr_tree, hf_fr_nlpid, tvb, offset, 1, fr_nlpid, "Padding"); offset++; if (ti != NULL) { /* Include the padding in the top-level protocol tree item. */ @@ -782,14 +768,14 @@ dissect_fr_nlpid(tvbuff_t *tvb, int offset, packet_info *pinfo, static void dissect_lapf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_tree_add_text(tree, tvb, 0, 0, "Frame relay lapf not yet implemented"); + proto_tree_add_expert(tree, pinfo, &ei_fr_frame_relay_lapf, tvb, 0, 0); call_dissector(data_handle,tvb_new_subset_remaining(tvb,0),pinfo,tree); } static void dissect_fr_xid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_tree_add_text(tree, tvb, 0, 0, "Frame relay xid not yet implemented"); + proto_tree_add_expert(tree, pinfo, &ei_fr_frame_relay_xid, tvb, 0, 0); call_dissector(data_handle,tvb_new_subset_remaining(tvb,0),pinfo,tree); } @@ -948,6 +934,21 @@ proto_register_fr(void) FT_UINT16, BASE_HEX, VALS(chdlc_vals), 0x0, "Frame Relay Cisco HDLC Encapsulated Protocol", HFILL }}, + { &hf_fr_first_addr_octet, + { "First address octet", "fr.first_addr_octet", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_fr_second_addr_octet, + { "Second address octet", "fr.second_addr_octet", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + + { &hf_fr_third_addr_octet, + { "Third address octet", "fr.third_addr_octet", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + }; /* Setup protocol subtree array */ @@ -956,6 +957,12 @@ proto_register_fr(void) &ett_fr_address, &ett_fr_control, }; + static ei_register_info ei[] = { + { &ei_fr_bogus_address, { "fr.bogus_address", PI_PROTOCOL, PI_WARN, "Bogus address", EXPFILL }}, + { &ei_fr_frame_relay_lapf, { "fr.frame_relay.lapf", PI_UNDECODED, PI_WARN, "Frame relay lapf not yet implemented", EXPFILL }}, + { &ei_fr_frame_relay_xid, { "fr.frame_relay.xid", PI_UNDECODED, PI_WARN, "Frame relay xid not yet implemented", EXPFILL }}, + }; + static const enum_val_t fr_encap_options[] = { { "frf-3.2", "FRF 3.2/Cisco HDLC", FRF_3_2 }, { "gprs-ns", "GPRS Network Service", GPRS_NS }, @@ -963,10 +970,13 @@ proto_register_fr(void) { NULL, NULL, 0 }, }; module_t *frencap_module; + expert_module_t* expert_fr; proto_fr = proto_register_protocol("Frame Relay", "FR", "fr"); proto_register_field_array(proto_fr, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_fr = expert_register_protocol(proto_fr); + expert_register_field_array(expert_fr, ei, array_length(ei)); fr_subdissector_table = register_dissector_table("fr.nlpid", "Frame Relay NLPID", FT_UINT8, BASE_HEX); diff --git a/epan/dissectors/packet-ftp.c b/epan/dissectors/packet-ftp.c index 0143d84637..6a4fa27b3b 100644 --- a/epan/dissectors/packet-ftp.c +++ b/epan/dissectors/packet-ftp.c @@ -811,10 +811,8 @@ dissect_ftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } } else { - proto_item *item; - item = proto_tree_add_text(reqresp_tree, - tvb, offset - linelen - 1, linelen, "Invalid EPRT arguments"); - expert_add_info(pinfo, item, &ei_ftp_eprt_args_invalid); + proto_tree_add_expert(reqresp_tree, pinfo, &ei_ftp_eprt_args_invalid, + tvb, offset - linelen - 1, linelen); } } @@ -861,10 +859,8 @@ dissect_ftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } } else { - proto_item *item; - item = proto_tree_add_text(reqresp_tree, - tvb, offset - linelen - 1, linelen, "Invalid EPSV arguments"); - expert_add_info(pinfo, item, &ei_ftp_epsv_args_invalid); + proto_tree_add_expert(reqresp_tree, pinfo, &ei_ftp_epsv_args_invalid, + tvb, offset - linelen - 1, linelen); } } } diff --git a/epan/dissectors/packet-gadu-gadu.c b/epan/dissectors/packet-gadu-gadu.c index 2e52e67e6c..649473cf22 100644 --- a/epan/dissectors/packet-gadu-gadu.c +++ b/epan/dissectors/packet-gadu-gadu.c @@ -497,6 +497,10 @@ static header_field_info hfi_gadu_gadu_userlist_format GADU_GADU_HFI_INIT = static header_field_info hfi_gadu_gadu_userlist_reply_type GADU_GADU_HFI_INIT = { "Reply type", "gadu-gadu.userlist.reply_type", FT_UINT32, BASE_HEX, gadu_gadu_userlist_reply_type_vals, 0x00, NULL, HFILL }; +static header_field_info hfi_gadu_gadu_userlist GADU_GADU_HFI_INIT = + { "Userlist XML data", "gadu-gadu.userlist", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }; + + /* Public Directory (gadu-gadu.pubdir.*) */ static header_field_info hfi_gadu_gadu_pubdir_request_type GADU_GADU_HFI_INIT = { "Request type", "gadu-gadu.pubdir.request_type", FT_UINT8, BASE_HEX, gadu_gadu_pubdir_type_vals, 0x00, NULL, HFILL }; @@ -1440,14 +1444,14 @@ dissect_gadu_gadu_userlist_xml_compressed(tvbuff_t *tvb, packet_info *pinfo, pro return offset; if ((uncomp_tvb = tvb_child_uncompress(tvb, tvb, offset, remain))) { - proto_tree_add_text(tree, tvb, offset, remain, "Userlist XML data: [Decompression succeeded]"); + proto_tree_add_bytes_format_value(tree, hfi_gadu_gadu_userlist.id, tvb, offset, remain, NULL, "[Decompression succeeded]"); add_new_data_source(pinfo, uncomp_tvb, "Uncompressed userlist"); /* XXX add DTD (pinfo->match_string) */ call_dissector_only(xml_handle, uncomp_tvb, pinfo, tree, NULL); } else - proto_tree_add_text(tree, tvb, offset, remain, "Userlist XML data: [Error: Decompression failed] (or no libz)"); + proto_tree_add_bytes_format_value(tree, hfi_gadu_gadu_userlist.id, tvb, offset, remain, NULL, "[Error: Decompression failed] (or no libz)"); offset += remain; diff --git a/epan/dissectors/packet-gift.c b/epan/dissectors/packet-gift.c index 3769ff84f4..067607efc2 100644 --- a/epan/dissectors/packet-gift.c +++ b/epan/dissectors/packet-gift.c @@ -38,6 +38,10 @@ void proto_reg_handoff_gift(void); static int proto_gift = -1; static int hf_gift_response = -1; static int hf_gift_request = -1; +static int hf_gift_response_cmd = -1; +static int hf_gift_response_arg = -1; +static int hf_gift_request_cmd = -1; +static int hf_gift_request_arg = -1; static gint ett_gift = -1; static gint ett_gift_cmd = -1; @@ -90,13 +94,11 @@ dissect_gift(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tokenlen = get_token_len(line, line + linelen, &next_token); if (tokenlen != 0) { if (is_request) { - proto_tree_add_text(cmd_tree, tvb, offset, - tokenlen, "Request Command: %s", - format_text(line, tokenlen)); + proto_tree_add_string(cmd_tree, hf_gift_request_cmd, tvb, offset, + tokenlen, format_text(line, tokenlen)); } else { - proto_tree_add_text(cmd_tree, tvb, offset, - tokenlen, "Response Command: %s", - format_text(line, tokenlen)); + proto_tree_add_string(cmd_tree, hf_gift_response_cmd, tvb, offset, + tokenlen, format_text(line, tokenlen)); } offset += (gint) (next_token - line); linelen -= (int) (next_token - line); @@ -105,13 +107,11 @@ dissect_gift(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (linelen != 0) { if (is_request) { - proto_tree_add_text(cmd_tree, tvb, offset, - linelen, "Request Arg: %s", - format_text(line, linelen)); + proto_tree_add_string(cmd_tree, hf_gift_request_arg, tvb, offset, + linelen, format_text(line, linelen)); } else { - proto_tree_add_text(cmd_tree, tvb, offset, - linelen, "Response Arg: %s", - format_text(line, linelen)); + proto_tree_add_string(cmd_tree, hf_gift_response_arg, tvb, offset, + linelen, format_text(line, linelen)); } } } @@ -126,7 +126,19 @@ proto_register_gift(void) }, { &hf_gift_request, { "Request", "gift.request", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "TRUE if giFT request", HFILL } - } + }, + { &hf_gift_response_cmd, + { "Response Command", "gift.response_cmd", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } + }, + { &hf_gift_response_arg, + { "Response Arg", "gift.response_arg", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } + }, + { &hf_gift_request_cmd, + { "Request Command", "gift.request_cmd", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } + }, + { &hf_gift_request_arg, + { "Request Arg", "gift.request_arg", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } + }, }; static gint *ett[] = { diff --git a/epan/dissectors/packet-giop.c b/epan/dissectors/packet-giop.c index b6a723a5b8..8de212b862 100644 --- a/epan/dissectors/packet-giop.c +++ b/epan/dissectors/packet-giop.c @@ -358,6 +358,7 @@ static int hf_giop_string_length = -1; static int hf_giop_sequence_length = -1; static int hf_giop_profile_id = -1; static int hf_giop_type_id = -1; +static int hf_giop_type_id_match = -1; static int hf_giop_iiop_v_maj = -1; static int hf_giop_iiop_v_min = -1; static int hf_giop_endianness = -1; /* esp encapsulations */ @@ -838,6 +839,7 @@ static const value_string reply_status_types[] = { { 0, NULL } }; +const true_false_string tfs_matched_not_matched = { "Matched", "Not matched" }; typedef enum LocateStatusType @@ -4086,9 +4088,9 @@ dissect_reply_body (tvbuff_t *tvb, guint offset, packet_info *pinfo, exres = try_heuristic_giop_dissector(tvb, pinfo, clnp_tree, &offset, header, entry->operation); } - if (!exres && !strcmp(giop_op_is_a, entry->operation) && tree) { - proto_tree_add_text(tree, tvb, offset - 1, 1, "Type Id%s matched", - get_CDR_boolean(tvb, &offset) ? "" : " not"); + if (!exres && !strcmp(giop_op_is_a, entry->operation)) { + proto_tree_add_boolean(tree, hf_giop_type_id_match, tvb, offset - 1, 1, + get_CDR_boolean(tvb, &offset)); } if (! exres) { @@ -4345,7 +4347,7 @@ dissect_giop_request_1_1 (tvbuff_t * tvb, packet_info * pinfo, if (miop[0] == 'M' && miop[1] == 'I' && miop[2] == 'O' && miop[3] == 'P') { - proto_tree_add_text (request_tree, tvb, offset - 4, 4, "Magic number: MIOP"); + proto_tree_add_string(request_tree, hf_giop_message_magic, tvb, offset - 4, 4, "MIOP"); decode_TaggedProfile (tvb, pinfo, request_tree, &offset, GIOP_HEADER_SIZE, stream_is_big_endian, NULL); } @@ -4746,11 +4748,7 @@ static int dissect_giop_common (tvbuff_t * tvb, packet_info * pinfo, proto_tree proto_item_append_text(ti, ", (Big Endian)"); /* hack to show "Big Endian" when endianness flag == 0 */ break; case 0: - proto_tree_add_text (header_version_tree, tvb, 6, 1, - "Byte ordering: %s-endian", - (stream_is_big_endian) ? "big" : "little"); - ti = proto_tree_add_boolean(header_tree, hf_giop_message_flags_little_endian, tvb, 6, 1, stream_is_big_endian ? 0 : 1); - PROTO_ITEM_SET_HIDDEN(ti); + proto_tree_add_boolean(header_tree, hf_giop_message_flags_little_endian, tvb, 6, 1, stream_is_big_endian ? 0 : 1); break; } @@ -5023,12 +5021,16 @@ proto_register_giop (void) FT_UINT32, BASE_DEC, VALS(profile_id_vals), 0x0, NULL, HFILL } }, - { &hf_giop_type_id, { "IOR::type_id", "giop.typeid", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } }, + { &hf_giop_type_id_match, + { "Type Id", "giop.typeid.match", + FT_BOOLEAN, BASE_NONE, TFS(&tfs_matched_not_matched), 0x0, NULL, HFILL } + }, + { &hf_giop_type_id_len, { "Type Id length", "giop.typeid_len", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } diff --git a/epan/dissectors/packet-gmr1_common.c b/epan/dissectors/packet-gmr1_common.c index a792d611c3..4952a2872f 100644 --- a/epan/dissectors/packet-gmr1_common.c +++ b/epan/dissectors/packet-gmr1_common.c @@ -105,6 +105,7 @@ static int hf_com_cm2_cm3_presence = -1; static int hf_com_cm2_spare4 = -1; static int hf_com_cm2_a5_3 = -1; static int hf_com_cm2_a5_2_gmr1 = -1; +static int hf_com_spare_nibble = -1; /* [1] 11.5.1.6 - Mobile Earth Station Classmark 2 */ static const value_string com_cm2_revision_vals[] = { @@ -229,7 +230,7 @@ GMR1_IE_FUNC(gmr1_ie_com_cm2) /* [1] 11.5.1.8 - Spare Half Octet */ GMR1_IE_FUNC(gmr1_ie_com_spare_nibble) { - proto_tree_add_text(tree, tvb, offset, 1, "Spare Half Octet"); + proto_tree_add_item(tree, hf_com_spare_nibble, tvb, offset, 1, ENC_NA); return 1; } @@ -360,6 +361,11 @@ proto_register_gmr1_common(void) FT_UINT8, BASE_DEC, VALS(com_cm2_a5_2_gmr1_vals), 0x01, NULL, HFILL } }, + { &hf_com_spare_nibble, + { "Spare Half Octet", "gmr1.common.spare_nibble", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL } + }, }; /* Register the protocol name and field description */ diff --git a/epan/dissectors/packet-gmr1_dtap.c b/epan/dissectors/packet-gmr1_dtap.c index f80395743c..9d8e7d58ea 100644 --- a/epan/dissectors/packet-gmr1_dtap.c +++ b/epan/dissectors/packet-gmr1_dtap.c @@ -40,6 +40,9 @@ void proto_reg_handoff_gmr1_dtap(void); /* GMR-1 DTAP proto */ static int proto_gmr1_dtap = -1; +static int hf_gmr1_dtap_protocol_discriminator = -1; +static int hf_gmr1_dtap_message_elements = -1; + /* GMR-1 DTAP sub tree */ static gint ett_gmr1_dtap = -1; static gint ett_gmr1_pd = -1; @@ -114,11 +117,8 @@ dissect_gmr1_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset = 0; /* Protocol discriminator item */ - /*pd_item =*/ proto_tree_add_text( - dtap_tree, tvb, 1, 1, - "Protocol Discriminator: %s", - val_to_str(pd, gmr1_pd_vals, "Unknown (%u)") - ); + /*pd_item =*/ proto_tree_add_uint( + dtap_tree, hf_gmr1_dtap_protocol_discriminator, tvb, 1, 1, pd); /*pd_tree = proto_item_add_subtree(pd_item, ett_gmr1_pd);*/ @@ -137,8 +137,7 @@ dissect_gmr1_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (msg_func) { (*msg_func)(tvb, dtap_tree, pinfo, offset, len - offset); } else { - proto_tree_add_text(dtap_tree, tvb, offset, len - offset, - "Message Elements"); + proto_tree_add_item(dtap_tree, hf_gmr1_dtap_message_elements, tvb, offset, len - offset, ENC_NA); } /* Done ! */ @@ -149,10 +148,19 @@ dissect_gmr1_dtap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) void proto_register_gmr1_dtap(void) { -#if 0 static hf_register_info hf[] = { + { &hf_gmr1_dtap_protocol_discriminator, + { "Protocol Discriminator", "gmr1.dtap.protocol_discriminator", + FT_UINT8, BASE_DEC, VALS(gmr1_pd_vals), 0x0, + NULL, HFILL } + }, + { &hf_gmr1_dtap_message_elements, + { "Message elements", "gmr1.dtap.message_elements", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, }; -#endif + static gint *ett[] = { &ett_gmr1_dtap, &ett_gmr1_pd, @@ -163,9 +171,8 @@ proto_register_gmr1_dtap(void) /* Register the protocol name and field description */ proto_gmr1_dtap = proto_register_protocol("GEO-Mobile Radio (1) DTAP", "GMR-1 DTAP", "gmr1.dtap"); -#if 0 proto_register_field_array(proto_gmr1_dtap, hf, array_length(hf)); -#endif + /* Register dissector */ register_dissector("gmr1_dtap", dissect_gmr1_dtap, proto_gmr1_dtap); } diff --git a/epan/dissectors/packet-gmr1_rach.c b/epan/dissectors/packet-gmr1_rach.c index c53a2db214..bae0aec6a9 100644 --- a/epan/dissectors/packet-gmr1_rach.c +++ b/epan/dissectors/packet-gmr1_rach.c @@ -263,7 +263,7 @@ dissect_gmr1_rach_gps_pos(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, pro /* Check for NULL */ lat = (tvb_get_ntohl(tvb, offset) >> 4) & 0x7ffff; if (lat == 0x40000) { - proto_tree_add_text(tree, tvb, offset, 5, "NULL GPS Position"); + proto_tree_add_uint_format(tree, hf_rach_gps_pos_lat, tvb, offset, 5, 0x40000, "NULL GPS Position"); return; } diff --git a/epan/dissectors/packet-gmr1_rr.c b/epan/dissectors/packet-gmr1_rr.c index 96c5eed9f3..f1e4a3fa2c 100644 --- a/epan/dissectors/packet-gmr1_rr.c +++ b/epan/dissectors/packet-gmr1_rr.c @@ -216,6 +216,7 @@ static int hf_rr_bcch_carrier_spare = -1; static int hf_rr_reject_cause = -1; static int hf_rr_reject_cause_b = -1; static int hf_rr_gps_timestamp = -1; +static int hf_rr_gps_power_control_params = -1; static int hf_rr_tmsi_avail_msk_tmsi[4] = { -1, -1, -1, -1 }; static int hf_rr_gps_almanac_pn = -1; static int hf_rr_gps_almanac_wn = -1; @@ -264,7 +265,8 @@ static int hf_rr_tlli = -1; static int hf_rr_pkt_pwr_ctrl_prm_par = -1; static int hf_rr_pkt_pwr_ctrl_prm_spare = -1; static int hf_rr_persistence_lvl[4] = { -1, -1, -1, -1 }; - +static int hf_rr_protocol_discriminator = -1; +static int hf_rr_message_elements = -1; /* Generic display vals/func */ static const value_string rr_gen_ie_presence_vals[] = { @@ -807,7 +809,7 @@ GMR1_IE_FUNC(gmr1_ie_rr_pwr_ctrl_prm) /* It's CSN1 encoded and we have no real world sample. Until we do, * we don't pollute the code with a bunch of untested stuff ... */ - proto_tree_add_text(tree, tvb, offset, 5, "Power Control Parameters"); + proto_tree_add_item(tree, hf_rr_gps_power_control_params, tvb, offset, 5, ENC_NA); return 5; } @@ -1861,11 +1863,8 @@ dissect_gmr1_ccch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset += elem_v(tvb, ccch_tree, pinfo, GMR1_IE_RR, GMR1_IE_RR_L2_PSEUDO_LEN, offset, NULL); /* Protocol discriminator item */ - pd_item = proto_tree_add_text( - ccch_tree, tvb, 1, 1, - "Protocol Discriminator: %s", - val_to_str(pd, gmr1_pd_vals, "Unknown (%u)") - ); + pd_item = proto_tree_add_uint( + ccch_tree, hf_rr_protocol_discriminator, tvb, 1, 1, pd); pd_tree = proto_item_add_subtree(pd_item, ett_rr_pd); @@ -1895,8 +1894,7 @@ dissect_gmr1_ccch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (msg_func) { (*msg_func)(tvb, ccch_tree, pinfo, offset, len - offset); } else { - proto_tree_add_text(ccch_tree, tvb, offset, len - offset, - "Message Elements"); + proto_tree_add_item(ccch_tree, hf_rr_message_elements, tvb, offset, len - offset, ENC_NA); } /* Done ! */ @@ -2141,6 +2139,11 @@ proto_register_gmr1_rr(void) FT_UINT16, BASE_CUSTOM, rr_gps_timestamp_fmt, 0xffff, NULL, HFILL } }, + { &hf_rr_gps_power_control_params, + { "Power Control Parameters", "gmr1.rr.power_control_params", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, { &hf_rr_tmsi_avail_msk_tmsi[0], { "TMSI 1 Presence", "gmr1.rr.tmsi_avail_msk.tmsi1", FT_UINT8, BASE_DEC, VALS(rr_gen_ie_presence_vals), 0x10, @@ -2411,6 +2414,16 @@ proto_register_gmr1_rr(void) FT_UINT8, BASE_DEC, NULL, 0x0f, NULL, HFILL } }, + { &hf_rr_protocol_discriminator, + { "Protocol Discriminator", "gmr1.rr.protocol_discriminator", + FT_UINT8, BASE_DEC, VALS(gmr1_pd_vals), 0x0, + NULL, HFILL } + }, + { &hf_rr_message_elements, + { "Message elements", "gmr1.rr.message_elements", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, }; #define NUM_INDIVIDUAL_ELEMS 2 diff --git a/epan/dissectors/packet-gmrp.c b/epan/dissectors/packet-gmrp.c index 9247682ac3..7d9d1aad3d 100644 --- a/epan/dissectors/packet-gmrp.c +++ b/epan/dissectors/packet-gmrp.c @@ -29,6 +29,7 @@ #include <glib.h> #include <epan/packet.h> +#include <epan/expert.h> #include <epan/llcsaps.h> void proto_register_gmrp(void); @@ -42,13 +43,16 @@ static int hf_gmrp_attribute_length = -1; static int hf_gmrp_attribute_event = -1; static int hf_gmrp_attribute_value_group_membership = -1; static int hf_gmrp_attribute_value_service_requirement = -1; -/*static int hf_gmrp_end_of_mark = -1;*/ +static int hf_gmrp_end_of_mark = -1; /* Initialize the subtree pointers */ static gint ett_gmrp = -1; -/*static gint ett_gmrp_message = -1; +static gint ett_gmrp_message = -1; static gint ett_gmrp_attribute_list = -1; -static gint ett_gmrp_attribute = -1;*/ +/*static gint ett_gmrp_attribute = -1;*/ + +static expert_field ei_gmrp_proto_id = EI_INIT; + static dissector_handle_t data_handle; @@ -109,7 +113,7 @@ static void dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *ti; - proto_tree *gmrp_tree; + proto_tree *gmrp_tree, *msg_tree, *attr_tree; guint16 protocol_id; guint8 octet; guint8 attribute_type; @@ -119,8 +123,6 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_set_str(pinfo->cinfo, COL_INFO, "GMRP"); - if (tree) - { ti = proto_tree_add_item(tree, proto_gmrp, tvb, 0, -1, ENC_NA); gmrp_tree = proto_item_add_subtree(ti, ett_gmrp); @@ -128,11 +130,9 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Read in GARP protocol ID */ protocol_id = tvb_get_ntohs(tvb, GARP_PROTOCOL_ID); - proto_tree_add_uint_format(gmrp_tree, hf_gmrp_proto_id, tvb, - GARP_PROTOCOL_ID, (int)sizeof(guint16), - protocol_id, - "Protocol Identifier: 0x%04x (%s)", - protocol_id, + ti = proto_tree_add_uint_format_value(gmrp_tree, hf_gmrp_proto_id, tvb, + GARP_PROTOCOL_ID, 2, protocol_id, + "0x%04x (%s)", protocol_id, protocol_id == GARP_DEFAULT_PROTOCOL_ID ? "GARP Multicast Registration Protocol" : "Unknown Protocol"); @@ -140,16 +140,15 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Currently only one protocol ID is supported */ if (protocol_id != GARP_DEFAULT_PROTOCOL_ID) { - proto_tree_add_text(gmrp_tree, tvb, GARP_PROTOCOL_ID, (int)sizeof(guint16), - " (Warning: this version of Wireshark only knows about protocol id = 1)"); + expert_add_info(pinfo, ti, &ei_gmrp_proto_id); call_dissector(data_handle, - tvb_new_subset_remaining(tvb, GARP_PROTOCOL_ID + (int)sizeof(guint16)), + tvb_new_subset_remaining(tvb, GARP_PROTOCOL_ID + 2), pinfo, tree); return; } - offset += (int)sizeof(guint16); - length -= (int)sizeof(guint16); + offset += 2; + length -= 2; msg_index = 0; @@ -168,8 +167,7 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* End of GARP PDU */ if (msg_index) { - proto_tree_add_text(gmrp_tree, tvb, offset, (int)sizeof(guint8), - "End of pdu"); + proto_tree_add_uint_format(gmrp_tree, hf_gmrp_end_of_mark, tvb, offset, 1, octet, "End of pdu"); break; } else @@ -181,14 +179,14 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } } - offset += (int)sizeof(guint8); - length -= (int)sizeof(guint8); + offset += 1; + length -= 1; - msg_item = proto_tree_add_text(gmrp_tree, tvb, msg_start, -1, - "Message %d", msg_index + 1); + msg_tree = proto_tree_add_subtree_format(gmrp_tree, tvb, msg_start, -1, + ett_gmrp_message, &msg_item, "Message %d", msg_index + 1); - proto_tree_add_uint(gmrp_tree, hf_gmrp_attribute_type, tvb, - msg_start, (int)sizeof(guint8), octet); + proto_tree_add_uint(msg_tree, hf_gmrp_attribute_type, tvb, + msg_start, 1, octet); /* GMRP supports Group Membership and Service Requirement as attribute types */ if ( (octet != GMRP_ATTRIBUTE_TYPE_GROUP_MEMBERSHIP) && (octet != GMRP_ATTRIBUTE_TYPE_SERVICE_REQUIREMENT) ) @@ -217,11 +215,11 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ if (attr_index) { - proto_tree_add_text(gmrp_tree, tvb, offset, - (int)sizeof(guint8), " End of mark"); + proto_tree_add_uint_format(msg_tree, hf_gmrp_end_of_mark, tvb, offset, + 1, octet, " End of mark"); - offset += (int)sizeof(guint8); - length -= (int)sizeof(guint8); + offset += 1; + length -= 1; proto_item_set_len(msg_item, offset - msg_start); break; @@ -238,23 +236,23 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint8 event; - offset += (int)sizeof(guint8); - length -= (int)sizeof(guint8); + offset += 1; + length -= 1; - attr_item = proto_tree_add_text(gmrp_tree, tvb, - attr_start, -1, " Attribute %d", attr_index + 1); + attr_tree = proto_tree_add_subtree_format(msg_tree, tvb, attr_start, -1, + ett_gmrp_attribute_list, &attr_item, " Attribute %d", attr_index + 1); - proto_tree_add_uint(gmrp_tree, hf_gmrp_attribute_length, - tvb, attr_start, (int)sizeof(guint8), octet); + proto_tree_add_uint(attr_tree, hf_gmrp_attribute_length, + tvb, attr_start, 1, octet); /* Read in attribute event */ event = tvb_get_guint8(tvb, offset); - proto_tree_add_uint(gmrp_tree, hf_gmrp_attribute_event, - tvb, offset, (int)sizeof(guint8), event); + proto_tree_add_uint(attr_tree, hf_gmrp_attribute_event, + tvb, offset, 1, event); - offset += (int)sizeof(guint8); - length -= (int)sizeof(guint8); + offset += 1; + length -= 1; switch (event) { @@ -287,21 +285,21 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if ( GMRP_ATTRIBUTE_TYPE_GROUP_MEMBERSHIP == attribute_type ) { /* Group Membership */ - proto_tree_add_item(gmrp_tree, hf_gmrp_attribute_value_group_membership, - tvb, offset, (int)(6*sizeof(guint8)), ENC_NA); + proto_tree_add_item(attr_tree, hf_gmrp_attribute_value_group_membership, + tvb, offset, 6, ENC_NA); - offset += (int)(6*sizeof(guint8)); - length -= (int)(6*sizeof(guint8)); + offset += 6; + length -= 6; } else if ( GMRP_ATTRIBUTE_TYPE_SERVICE_REQUIREMENT == attribute_type ) { /* Service Requirement */ - proto_tree_add_item(gmrp_tree, hf_gmrp_attribute_value_service_requirement, - tvb, offset, (int)sizeof(guint8), ENC_BIG_ENDIAN); + proto_tree_add_item(attr_tree, hf_gmrp_attribute_value_service_requirement, + tvb, offset, 1, ENC_BIG_ENDIAN); - offset += (int)sizeof(guint8); - length -= (int)sizeof(guint8); + offset += 1; + length -= 1; } else { @@ -328,7 +326,6 @@ dissect_gmrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) msg_index++; } - } } @@ -339,7 +336,7 @@ proto_register_gmrp(void) { static hf_register_info hf[] = { { &hf_gmrp_proto_id, - { "Protocol ID", "gmrp.protocol_id", + { "Protocol Identifier", "gmrp.protocol_id", FT_UINT16, BASE_HEX, NULL, 0x0, NULL , HFILL } }, @@ -367,14 +364,27 @@ proto_register_gmrp(void) { "Value", "gmrp.attribute_value_service_requirement", FT_UINT8, BASE_HEX, NULL, 0x0, NULL , HFILL } + }, + { &hf_gmrp_end_of_mark, + { "End of mark", "gmrp.end_of_mark", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL , HFILL } } }; static gint *ett[] = { - &ett_gmrp + &ett_gmrp, + &ett_gmrp_message, + &ett_gmrp_attribute_list + }; + + static ei_register_info ei[] = { + { &ei_gmrp_proto_id, { "gmrp.protocol_id.not_gmrp", PI_UNDECODED, PI_WARN, "This version of Wireshark only knows about protocol id = 1", EXPFILL }}, }; + expert_module_t* expert_gmrp; + /* Register the protocol name and description for GMRP */ proto_gmrp = proto_register_protocol("GARP Multicast Registration Protocol", "GMRP", "gmrp"); @@ -382,6 +392,8 @@ proto_register_gmrp(void) * used by GMRP */ proto_register_field_array(proto_gmrp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_gmrp = expert_register_protocol(proto_gmrp); + expert_register_field_array(expert_gmrp, ei, array_length(ei)); register_dissector("gmrp", dissect_gmrp, proto_gmrp); diff --git a/epan/dissectors/packet-gnutella.c b/epan/dissectors/packet-gnutella.c index 490e58e077..4414a74f79 100644 --- a/epan/dissectors/packet-gnutella.c +++ b/epan/dissectors/packet-gnutella.c @@ -131,11 +131,10 @@ static void dissect_gnutella_query(tvbuff_t *tvb, guint offset, proto_tree *tree ENC_ASCII|ENC_NA); } else { - proto_tree_add_text(tree, - tvb, + proto_tree_add_string_format(tree, + hf_gnutella_query_search, tvb, offset + GNUTELLA_QUERY_SEARCH_OFFSET, - 0, - "Missing data for Query Search."); + 0, "", "Missing data for Query Search."); } } diff --git a/epan/dissectors/packet-gprs-llc.c b/epan/dissectors/packet-gprs-llc.c index ce855f2d96..e9b39da7db 100644 --- a/epan/dissectors/packet-gprs-llc.c +++ b/epan/dissectors/packet-gprs-llc.c @@ -27,6 +27,7 @@ #include <epan/packet.h> #include <epan/prefs.h> +#include <epan/expert.h> #include <wiretap/wtap.h> void proto_register_llcgprs(void); @@ -51,6 +52,7 @@ void proto_reg_handoff_llcgprs(void); /* Initialize the protocol and registered fields */ static int proto_llcgprs = -1; static int hf_llcgprs_pd = -1; +static int hf_llcgprs_fcs = -1; static int hf_llcgprs_cr = -1; static int hf_llcgprs_sapi = -1; static int hf_llcgprs_sapib = -1; @@ -125,6 +127,8 @@ static gint ett_llcgprs_ctrlf = -1; static gint ett_ui = -1; static gint ett_llcgprs_sframe = -1; +static expert_field ei_llcgprs_no_info_field = EI_INIT; + static dissector_handle_t data_handle; static dissector_handle_t sndcp_xid_handle; @@ -326,7 +330,6 @@ static void llc_gprs_dissect_xid(tvbuff_t *tvb, guint8 xid_param_len = 0, byte1 = 0, byte2 = 0, item_len = 0, tmp = 0; guint16 location = 0; guint16 loop_counter = 0; - proto_item *uinfo_field = NULL; proto_tree *uinfo_tree = NULL; proto_tree *xid_tree = NULL; guint16 info_len; @@ -415,17 +418,16 @@ static void llc_gprs_dissect_xid(tvbuff_t *tvb, value <<= 8; value |= (guint32)tvb_get_guint8(tvb, location+i ); } - uinfo_field = proto_tree_add_text(xid_tree, tvb, location, item_len, - "XID Parameter Type: %s - Value: %u", + uinfo_tree = proto_tree_add_subtree_format(xid_tree, tvb, location, item_len, + ett_ui, NULL, "XID Parameter Type: %s - Value: %u", val_to_str_ext_const(tmp, &xid_param_type_str_ext, "Reserved Type:%X"), value); } else { - uinfo_field = proto_tree_add_text(xid_tree, tvb, location, item_len, - "XID Parameter Type: %s", + uinfo_tree = proto_tree_add_subtree_format(xid_tree, tvb, location, item_len, + ett_ui, NULL, "XID Parameter Type: %s", val_to_str_ext_const(tmp, &xid_param_type_str_ext, "Reserved Type:%X")); } - uinfo_tree = proto_item_add_subtree(uinfo_field, ett_ui); proto_tree_add_uint(uinfo_tree, hf_llcgprs_xid_xl, tvb, location, 1, byte1); proto_tree_add_uint(uinfo_tree, hf_llcgprs_xid_type, tvb, location, @@ -465,7 +467,7 @@ dissect_llcgprs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint8 addr_fld=0, sapi=0, ctrl_fld_fb=0, frame_format, tmp=0; guint16 offset=0 , epm = 0, nu=0, ctrl_fld_ui_s=0; guint16 crc_length=0, llc_data_reported_length=0, llc_data_length = 0; - proto_item *ti, *addres_field_item, *ui_ti; + proto_item *ti, *addres_field_item; proto_tree *llcgprs_tree=NULL , *ad_f_tree =NULL, *ctrl_f_tree=NULL, *ui_tree=NULL; tvbuff_t *next_tvb; guint length; @@ -597,24 +599,23 @@ dissect_llcgprs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) switch (fcs_status) { case FCS_VALID: - proto_tree_add_text (llcgprs_tree, tvb, llc_data_reported_length, CRC_LENGTH, - "FCS: 0x%06x (correct)", fcs_calc&0xffffff); + proto_tree_add_uint_format_value(llcgprs_tree, hf_llcgprs_fcs, tvb, llc_data_reported_length, CRC_LENGTH, + fcs_calc&0xffffff, "0x%06x (correct)", fcs_calc&0xffffff); break; case FCS_NOT_VALID: - proto_tree_add_text (llcgprs_tree, tvb, llc_data_reported_length, CRC_LENGTH, - "FCS: 0x%06x (incorrect, should be 0x%06x)", fcs, fcs_calc ); + proto_tree_add_uint_format_value(llcgprs_tree, hf_llcgprs_fcs, tvb, llc_data_reported_length, CRC_LENGTH, + fcs, "0x%06x (incorrect, should be 0x%06x)", fcs, fcs_calc ); break; case FCS_NOT_VALID_DUE_TO_CIPHERING: - proto_tree_add_text (llcgprs_tree, tvb, llc_data_reported_length, CRC_LENGTH, - "FCS: 0x%06x (incorrect, maybe due to ciphering, calculated 0x%06x)", fcs, fcs_calc ); + proto_tree_add_uint_format_value(llcgprs_tree, hf_llcgprs_fcs, tvb, llc_data_reported_length, CRC_LENGTH, + fcs, "0x%06x (incorrect, maybe due to ciphering, calculated 0x%06x)", fcs, fcs_calc ); break; case FCS_NOT_COMPUTED: - fcs_item = proto_tree_add_text (llcgprs_tree, tvb, 0, 0, + proto_tree_add_uint_format_value(llcgprs_tree, hf_llcgprs_fcs, tvb, 0, 0, 0, "FCS: Not enough data to compute the FCS"); - PROTO_ITEM_SET_GENERATED(fcs_item); break; /* FCS not present */ } @@ -1024,17 +1025,13 @@ dissect_llcgprs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_append_str(pinfo->cinfo, COL_INFO, val_to_str(tmp, cr_formats_unnumb, "Unknown/invalid code:%X")); - if(tree){ - ui_ti = proto_tree_add_text(llcgprs_tree, tvb, (offset-1), (llc_data_reported_length-1), - "Unnumbered frame: %s", + ui_tree = proto_tree_add_subtree_format(llcgprs_tree, tvb, (offset-1), (llc_data_reported_length-1), + ett_ui, NULL, "Unnumbered frame: %s", val_to_str(tmp, cr_formats_unnumb, "Unknown/invalid code:%X")); - ui_tree = proto_item_add_subtree(ui_ti, ett_ui); - proto_tree_add_uint(ui_tree, hf_llcgprs_Un, tvb, (offset-1), 1, ctrl_fld_fb); - proto_tree_add_boolean(ui_tree, hf_llcgprs_PF, tvb, (offset-1), 1, ctrl_fld_fb); - proto_tree_add_uint(ui_tree, hf_llcgprs_ucom, tvb, (offset-1), 1, ctrl_fld_fb); - - } + proto_tree_add_uint(ui_tree, hf_llcgprs_Un, tvb, (offset-1), 1, ctrl_fld_fb); + proto_tree_add_boolean(ui_tree, hf_llcgprs_PF, tvb, (offset-1), 1, ctrl_fld_fb); + proto_tree_add_uint(ui_tree, hf_llcgprs_ucom, tvb, (offset-1), 1, ctrl_fld_fb); /* MLT CHANGES - parse rest of the message based on type (M Bits) */ m_bits = ctrl_fld_fb & 0x0F; @@ -1047,11 +1044,7 @@ dissect_llcgprs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case U_DISC: case U_NULL: /* These frames SHOULD NOT have an info field */ - if (tree) - { - proto_tree_add_text(llcgprs_tree, tvb, offset, (llc_data_reported_length-2), - "No Information Field"); - } + proto_tree_add_expert(llcgprs_tree, pinfo, &ei_llcgprs_no_info_field, tvb, offset, (llc_data_reported_length-2)); break; case U_UA: /* This frame MAY or MAY NOT have an info field */ @@ -1150,6 +1143,10 @@ proto_register_llcgprs(void) { "Protocol Discriminator_bit", "llcgprs.pd", FT_BOOLEAN, 8, TFS(&pd_bit), 0x80, "Protocol Discriminator bit (should be 0)", HFILL }}, + { &hf_llcgprs_fcs, + { "FCS", "llcgprs.fcs", FT_UINT24, BASE_HEX, + NULL, 0, NULL, HFILL }}, + {&hf_llcgprs_sjsd, { "Supervisory function bits", "llcgprs.s1s2", FT_UINT16, BASE_HEX, VALS(cr_formats_ipluss), 0x3, NULL, HFILL }}, @@ -1336,7 +1333,12 @@ proto_register_llcgprs(void) &ett_llcgprs_sframe, }; + static ei_register_info ei[] = { + { &ei_llcgprs_no_info_field, { "llcgprs.no_info_field", PI_PROTOCOL, PI_WARN, "No Information Field", EXPFILL }}, + }; + module_t *llcgprs_module; + expert_module_t* expert_llcgprs; /* Register the protocol name and description */ proto_llcgprs = proto_register_protocol("Logical Link Control GPRS", @@ -1346,6 +1348,8 @@ proto_register_llcgprs(void) /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_llcgprs, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_llcgprs = expert_register_protocol(proto_llcgprs); + expert_register_field_array(expert_llcgprs, ei, array_length(ei)); register_dissector("llcgprs", dissect_llcgprs, proto_llcgprs); llcgprs_module = prefs_register_protocol ( proto_llcgprs, NULL ); diff --git a/epan/dissectors/packet-gsm_ipa.c b/epan/dissectors/packet-gsm_ipa.c index bb693bca52..50fd2e81b6 100644 --- a/epan/dissectors/packet-gsm_ipa.c +++ b/epan/dissectors/packet-gsm_ipa.c @@ -97,6 +97,7 @@ static int hf_ipa_osmo_ctrl_data = -1; static int hf_ipaccess_msgtype = -1; static int hf_ipaccess_attr_tag = -1; static int hf_ipaccess_attr_string = -1; +static int hf_ipaccess_attribute_unk = -1; /* Initialize the subtree pointers */ static gint ett_ipa = -1; @@ -198,8 +199,7 @@ dissect_ipa_attr(tvbuff_t *tvb, int base_offs, proto_tree *tree) break; default: len = 0; - proto_tree_add_text(tree, tvb, offset+1, 1, - "unknown attribute type 0x%02x", + proto_tree_add_uint(tree, hf_ipaccess_attribute_unk, tvb, offset+1, 1, attr_type); break; }; @@ -421,6 +421,11 @@ void proto_register_ipa(void) FT_STRING, BASE_NONE, NULL, 0x0, "String attribute", HFILL} }, + {&hf_ipaccess_attribute_unk, + {"Unknown attribute type", "ipaccess.attr_unk", + FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL} + }, }; static gint *ett[] = { diff --git a/epan/dissectors/packet-gsm_sms_ud.c b/epan/dissectors/packet-gsm_sms_ud.c index dc986c9fa2..6baf74e098 100644 --- a/epan/dissectors/packet-gsm_sms_ud.c +++ b/epan/dissectors/packet-gsm_sms_ud.c @@ -83,6 +83,7 @@ static int hf_gsm_sms_ud_fragment_error = -1; static int hf_gsm_sms_ud_fragment_count = -1; static int hf_gsm_sms_ud_reassembled_in = -1; static int hf_gsm_sms_ud_reassembled_length = -1; +static int hf_gsm_sms_ud_short_msg = -1; /* * User Data Header section */ @@ -406,8 +407,7 @@ parse_gsm_sms_ud_message(proto_tree *sm_tree, tvbuff_t *tvb, packet_info *pinfo, if (! dissector_try_uint(gsm_sms_dissector_table, p_dst, sm_tvb, pinfo, top_tree)) { if (sm_tree) { /* Only display if needed */ - proto_tree_add_text(sm_tree, sm_tvb, 0, -1, - "Short Message body"); + proto_tree_add_item(sm_tree, hf_gsm_sms_ud_short_msg, sm_tvb, 0, -1, ENC_NA); } } } @@ -416,14 +416,13 @@ parse_gsm_sms_ud_message(proto_tree *sm_tree, tvbuff_t *tvb, packet_info *pinfo, if (disallow_write) col_set_writable(pinfo->cinfo, TRUE); } else { /* No ports IE */ - proto_tree_add_text(sm_tree, sm_tvb, 0, -1, - "Short Message body"); + proto_tree_add_item(sm_tree, hf_gsm_sms_ud_short_msg, sm_tvb, 0, -1, ENC_NA); } } else { /* The packet is not reassembled, * or it is reassembled in another packet */ - proto_tree_add_text(sm_tree, sm_tvb, 0, -1, - "Unreassembled Short Message fragment %u of %u", + proto_tree_add_bytes_format(sm_tree, hf_gsm_sms_ud_short_msg, sm_tvb, 0, -1, + NULL, "Unreassembled Short Message fragment %u of %u", frag, frags); } } @@ -600,6 +599,12 @@ proto_register_gsm_sms_ud(void) HFILL } }, + { &hf_gsm_sms_ud_short_msg, + { "Short Message body", + "gsm_sms_ud.short_msg", + FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL + } + }, }; static gint *ett[] = { diff --git a/epan/dissectors/packet-gsm_um.c b/epan/dissectors/packet-gsm_um.c index c6190f8f42..7f6715584c 100644 --- a/epan/dissectors/packet-gsm_um.c +++ b/epan/dissectors/packet-gsm_um.c @@ -39,6 +39,8 @@ static int hf_gsm_um_direction = -1; static int hf_gsm_um_channel = -1; static int hf_gsm_um_bsic = -1; static int hf_gsm_um_arfcn = -1; +static int hf_gsm_um_band = -1; +static int hf_gsm_um_frequency = -1; static int hf_gsm_um_frame = -1; static int hf_gsm_um_error = -1; static int hf_gsm_um_timeshift = -1; @@ -173,9 +175,10 @@ dissect_gsm_um(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint(gsm_um_tree, hf_gsm_um_arfcn, tvb, 0, 0, pinfo->pseudo_header->gsm_um.arfcn); - proto_tree_add_text(gsm_um_tree, tvb, 0, 0, - "Band: %s, Frequency: %u.%03uMHz", band, - downlink / 1000, downlink % 1000); + proto_tree_add_string(gsm_um_tree, hf_gsm_um_band, tvb, 0, 0, + band); + proto_tree_add_uint_format_value(gsm_um_tree, hf_gsm_um_frequency, tvb, 0, 0, + downlink, "%u.%03uMHz", downlink / 1000, downlink % 1000); proto_tree_add_uint(gsm_um_tree, hf_gsm_um_bsic, tvb, 0, 0, pinfo->pseudo_header->gsm_um.bsic); proto_tree_add_uint(gsm_um_tree, hf_gsm_um_frame, tvb, 0, 0, @@ -249,6 +252,14 @@ proto_register_gsm_um(void) { "ARFCN", "gsm_um.arfcn", FT_UINT16, BASE_DEC, NULL, 0x0, "Absolute radio frequency channel number", HFILL }}, + { &hf_gsm_um_band, + { "Band", "gsm_um.band", FT_STRING, BASE_NONE, + NULL, 0x0, NULL, HFILL }}, + + { &hf_gsm_um_frequency, + { "Frequency", "gsm_um.frequency", FT_UINT32, BASE_DEC, + NULL, 0x0, NULL, HFILL }}, + { &hf_gsm_um_frame, { "TDMA Frame", "gsm_um.frame", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, |