From 553bec65bab1b29317a4a2882af9e36bcf92aafd Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Tue, 28 May 2013 03:11:44 +0000 Subject: [PATCH] Batch of filterable expert infos. This (mostly) completes the non-ASN.1 list of (built-in) dissectors that only had a small handful of add_expert_info_format calls. svn path=/trunk/; revision=49602 --- epan/dissectors/packet-tacacs.c | 12 ++- epan/dissectors/packet-tftp.c | 15 +++- epan/dissectors/packet-usb-video.c | 14 ++- epan/dissectors/packet-usb.c | 18 +++- epan/dissectors/packet-user_encap.c | 12 ++- epan/dissectors/packet-wcp.c | 18 +++- epan/dissectors/packet-websocket.c | 11 ++- epan/dissectors/packet-x11.c | 12 ++- epan/dissectors/packet-x25.c | 22 +++-- epan/dissectors/packet-xdmcp.c | 12 ++- epan/dissectors/packet-xmpp.c | 114 +++++++++++++------------ epan/dissectors/packet-xtp.c | 15 +++- epan/dissectors/packet-zbee-aps.c | 16 +++- epan/dissectors/packet-zbee-nwk.c | 13 ++- epan/dissectors/packet-zbee-security.c | 12 ++- 15 files changed, 233 insertions(+), 83 deletions(-) diff --git a/epan/dissectors/packet-tacacs.c b/epan/dissectors/packet-tacacs.c index 544a81f803..e53d1b0267 100644 --- a/epan/dissectors/packet-tacacs.c +++ b/epan/dissectors/packet-tacacs.c @@ -87,6 +87,8 @@ static int hf_tacacs_password = -1; static gint ett_tacacs = -1; +static expert_field ei_tacplus_packet_len_invalid = EI_INIT; + static gboolean tacplus_preference_desegment = TRUE; static const char *tacplus_opt_key; @@ -955,7 +957,7 @@ dissect_tacplus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tmp_pi = proto_tree_add_uint(tacplus_tree, hf_tacplus_packet_len, tvb, 8, 4, len); if ((gint)len < 1) { - expert_add_info_format(pinfo, tmp_pi, PI_PROTOCOL, PI_WARN, "Invalid length: %u", len); + expert_add_info_format_text(pinfo, tmp_pi, &ei_tacplus_packet_len_invalid, "Invalid length: %u", len); } tmp_pi = proto_tree_add_text(tacplus_tree, tvb, TAC_PLUS_HDR_SIZE, len, "%s%s", @@ -1238,11 +1240,19 @@ proto_register_tacplus(void) &ett_tacplus_body, &ett_tacplus_body_chap, }; + + static ei_register_info ei[] = { + { &ei_tacplus_packet_len_invalid, { "tacplus.packet_len.invalid", PI_PROTOCOL, PI_WARN, "Invalid length", EXPFILL }}, + }; + module_t *tacplus_module; + expert_module_t* expert_tacplus; proto_tacplus = proto_register_protocol("TACACS+", "TACACS+", "tacplus"); proto_register_field_array(proto_tacplus, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_tacplus = expert_register_protocol(proto_tacplus); + expert_register_field_array(expert_tacplus, ei, array_length(ei)); tacplus_module = prefs_register_protocol (proto_tacplus, tacplus_pref_cb ); prefs_register_bool_preference(tacplus_module, "desegment", "Reassemble TACACS+ messages spanning multiple TCP segments.", "Whether the TACACS+ dissector should reassemble messages spanning multiple TCP segments. To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &tacplus_preference_desegment); diff --git a/epan/dissectors/packet-tftp.c b/epan/dissectors/packet-tftp.c index 76c8014d0d..fd013af800 100644 --- a/epan/dissectors/packet-tftp.c +++ b/epan/dissectors/packet-tftp.c @@ -72,6 +72,8 @@ static int hf_tftp_option_value = -1; static gint ett_tftp = -1; static gint ett_tftp_option = -1; +static expert_field ei_tftp_blocksize_range = EI_INIT; + static dissector_handle_t tftp_handle; static dissector_handle_t data_handle; @@ -150,8 +152,7 @@ tftp_dissect_options(tvbuff_t *tvb, packet_info *pinfo, int offset, opcode == TFTP_OACK) { gint blocksize = (gint)strtol((const char *)optionvalue, NULL, 10); if (blocksize < 8 || blocksize > 65464) { - expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, - PI_WARN, "TFTP blocksize out of range"); + expert_add_info(pinfo, NULL, &ei_tftp_blocksize_range); } else { tftp_info->blocksize = blocksize; } @@ -303,8 +304,7 @@ static void dissect_tftp_message(tftp_conv_info_t *tftp_info, col_append_fstr(pinfo->cinfo, COL_INFO, ", Message: %s", tvb_format_stringzpad(tvb, offset, i1)); - expert_add_info_format(pinfo, NULL, PI_RESPONSE_CODE, - PI_NOTE, "TFTP blocksize out of range"); + expert_add_info(pinfo, NULL, &ei_tftp_blocksize_range); break; case TFTP_OACK: @@ -476,12 +476,19 @@ proto_register_tftp(void) &ett_tftp_option, }; + static ei_register_info ei[] = { + { &ei_tftp_blocksize_range, { "tftp.blocksize_range", PI_RESPONSE_CODE, PI_WARN, "TFTP blocksize out of range", EXPFILL }}, + }; + module_t *tftp_module; + expert_module_t* expert_tftp; proto_tftp = proto_register_protocol("Trivial File Transfer Protocol", "TFTP", "tftp"); proto_register_field_array(proto_tftp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_tftp = expert_register_protocol(proto_tftp); + expert_register_field_array(expert_tftp, ei, array_length(ei)); register_dissector("tftp", dissect_tftp, proto_tftp); diff --git a/epan/dissectors/packet-usb-video.c b/epan/dissectors/packet-usb-video.c index 04a01fc710..5f8d2913a6 100644 --- a/epan/dissectors/packet-usb-video.c +++ b/epan/dissectors/packet-usb-video.c @@ -347,6 +347,8 @@ static gint ett_probe_framing = -1; static gint ett_video_standards = -1; static gint ett_control_capabilities = -1; +static expert_field ei_usb_vid_subtype_unknown = EI_INIT; + /* Lookup tables */ static const value_string vc_ep_descriptor_subtypes[] = { { EP_INTERRUPT, "Interrupt" }, @@ -992,9 +994,9 @@ dissect_usb_video_control_interface_descriptor(proto_tree *parent_tree, tvbuff_t { /* @todo UVC 1.5 */ } - else + else { - expert_add_info_format(pinfo, subtype_item, PI_UNDECODED, PI_WARN, + expert_add_info_format_text(pinfo, subtype_item, &ei_usb_vid_subtype_unknown, "Unknown VC subtype %u", subtype); } } @@ -3216,9 +3218,17 @@ proto_register_usb_vid(void) &ett_control_capabilities }; + static ei_register_info ei[] = { + { &ei_usb_vid_subtype_unknown, { "usbvideo.subtype.unknown", PI_UNDECODED, PI_WARN, "Unknown VC subtype", EXPFILL }}, + }; + + expert_module_t* expert_usb_vid; + proto_usb_vid = proto_register_protocol("USB Video", "USBVIDEO", "usbvideo"); proto_register_field_array(proto_usb_vid, hf, array_length(hf)); proto_register_subtree_array(usb_vid_subtrees, array_length(usb_vid_subtrees)); + expert_usb_vid = expert_register_protocol(proto_usb_vid); + expert_register_field_array(expert_usb_vid, ei, array_length(ei)); } void diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c index c4faa83736..93145c3e4e 100644 --- a/epan/dissectors/packet-usb.c +++ b/epan/dissectors/packet-usb.c @@ -180,6 +180,9 @@ static gint ett_configuration_bEndpointAddress = -1; static gint ett_endpoint_bmAttributes = -1; static gint ett_endpoint_wMaxPacketSize = -1; +static expert_field ei_usb_bLength_even = EI_INIT; +static expert_field ei_usb_desc_length_invalid = EI_INIT; + static const int *usb_endpoint_fields[] = { &hf_usb_endpoint_direction, &hf_usb_endpoint_number_value, @@ -1396,8 +1399,7 @@ dissect_usb_string_descriptor(packet_info *pinfo _U_, proto_tree *parent_tree, /* bLength */ len_item = proto_tree_add_item(tree, hf_usb_bLength, tvb, offset, 1, ENC_LITTLE_ENDIAN); - expert_add_info_format(pinfo, len_item, PI_PROTOCOL, PI_WARN, - "Invalid STRING DESCRIPTOR Length (must be even)"); + expert_add_info(pinfo, len_item, &ei_usb_bLength_even); /* bDescriptorType */ proto_tree_add_item(tree, hf_usb_bDescriptorType, tvb, offset+1, 1, ENC_LITTLE_ENDIAN); @@ -1827,7 +1829,7 @@ dissect_usb_configuration_descriptor(packet_info *pinfo _U_, proto_tree *parent_ item = proto_tree_add_text(parent_tree, tvb, offset, 1, "Invalid descriptor length: %u", next_len); proto_item_set_len(item, 1); - expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, + expert_add_info_format_text(pinfo, item, &ei_usb_desc_length_invalid, "Invalid descriptor length: %u", next_len); item = NULL; break; @@ -3932,6 +3934,16 @@ proto_register_usb(void) &ett_endpoint_wMaxPacketSize }; + static ei_register_info ei[] = { + { &ei_usb_bLength_even, { "usb.bLength.even", PI_PROTOCOL, PI_WARN, "Invalid STRING DESCRIPTOR Length (must be even)", EXPFILL }}, + { &ei_usb_desc_length_invalid, { "usb.desc_length.invalid", PI_MALFORMED, PI_ERROR, "Invalid descriptor length", EXPFILL }}, + }; + + expert_module_t* expert_usb; + + expert_usb = expert_register_protocol(proto_usb); + expert_register_field_array(expert_usb, ei, array_length(ei)); + device_to_product_table = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "usb device_address, bus_id and frame number to vendor_product"); device_to_protocol_table = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "usb device_address, bus_id and frame number to class_subclass_protocol"); device_to_dissector = register_dissector_table("usb.device", "USB device", FT_UINT32, BASE_HEX); diff --git a/epan/dissectors/packet-user_encap.c b/epan/dissectors/packet-user_encap.c index bf94e1df45..5cc5bdd124 100644 --- a/epan/dissectors/packet-user_encap.c +++ b/epan/dissectors/packet-user_encap.c @@ -71,6 +71,8 @@ static const value_string user_dlts[] = { }; static int proto_user_encap = -1; +static expert_field ei_user_encap_not_handled = EI_INIT; + static user_encap_t* encaps = NULL; static guint num_encaps = 0; static uat_t* encaps_uat; @@ -96,7 +98,7 @@ static void dissect_user(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) { "check your Preferences->Protocols->DLT_USER", pinfo->match_uint + 147 - WTAP_ENCAP_USER0); proto_item_set_text(item,"%s",msg); - expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN, "%s", msg); + expert_add_info_format_text(pinfo, item, &ei_user_encap_not_handled, "%s", msg); call_dissector(data_handle, tvb, pinfo, tree); return; @@ -107,7 +109,7 @@ static void dissect_user(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) { encap->payload_proto_name, pinfo->match_uint + 147 - WTAP_ENCAP_USER0); proto_item_set_text(item,"%s",msg); - expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN, "%s", msg); + expert_add_info_format_text(pinfo, item, &ei_user_encap_not_handled, "%s", msg); call_dissector(data_handle, tvb, pinfo, tree); return; @@ -195,6 +197,7 @@ void proto_reg_handoff_user_encap(void) void proto_register_user_encap(void) { module_t *module; + expert_module_t* expert_user_encap; static uat_field_t user_flds[] = { UAT_FLD_VS(user_encap,encap,"DLT",user_dlts,"The DLT"), @@ -211,8 +214,13 @@ void proto_register_user_encap(void) UAT_END_FIELDS }; + static ei_register_info ei[] = { + { &ei_user_encap_not_handled, { "user_dlt.not_handled", PI_UNDECODED, PI_WARN, "Formatted text", EXPFILL }}, + }; proto_user_encap = proto_register_protocol("DLT User","DLT_USER","user_dlt"); + expert_user_encap = expert_register_protocol(proto_user_encap); + expert_register_field_array(expert_user_encap, ei, array_length(ei)); module = prefs_register_protocol(proto_user_encap, NULL); diff --git a/epan/dissectors/packet-wcp.c b/epan/dissectors/packet-wcp.c index f3e6a06ac2..f20e724e94 100644 --- a/epan/dissectors/packet-wcp.c +++ b/epan/dissectors/packet-wcp.c @@ -167,6 +167,9 @@ static gint ett_wcp = -1; static gint ett_wcp_comp_data = -1; static gint ett_wcp_field = -1; +static expert_field ei_wcp_compressed_data_exceeds = EI_INIT; +static expert_field ei_wcp_uncompressed_data_exceeds = EI_INIT; + static dissector_handle_t fr_uncompressed_handle; /* @@ -489,7 +492,7 @@ static tvbuff_t *wcp_uncompress( tvbuff_t *src_tvb, int offset, packet_info *pin src_tvb, offset, cnt - offset, ENC_NA); cd_tree = proto_item_add_subtree(cd_item, ett_wcp_comp_data); if (cnt - offset > MAX_WCP_BUF_LEN) { - expert_add_info_format(pinfo, cd_item, PI_MALFORMED, PI_ERROR, + expert_add_info_format_text(pinfo, cd_item, &ei_wcp_compressed_data_exceeds, "Compressed data exceeds maximum buffer length (%d > %d)", cnt - offset, MAX_WCP_BUF_LEN); return NULL; @@ -508,7 +511,7 @@ static tvbuff_t *wcp_uncompress( tvbuff_t *src_tvb, int offset, packet_info *pin if ( !pinfo->fd->flags.visited){ /* if first pass */ dst = decompressed_entry( src, dst, &len, buf_start, buf_end); if (dst == NULL){ - expert_add_info_format(pinfo, cd_item, PI_MALFORMED, PI_ERROR, + expert_add_info_format_text(pinfo, cd_item, &ei_wcp_uncompressed_data_exceeds, "Uncompressed data exceeds maximum buffer length (%d > %d)", len, MAX_WCP_BUF_LEN); return NULL; @@ -542,7 +545,7 @@ static tvbuff_t *wcp_uncompress( tvbuff_t *src_tvb, int offset, packet_info *pin } }else { if ( ++len >MAX_WCP_BUF_LEN){ - expert_add_info_format(pinfo, cd_item, PI_MALFORMED, PI_ERROR, + expert_add_info_format_text(pinfo, cd_item, &ei_wcp_uncompressed_data_exceeds, "Uncompressed data exceeds maximum buffer length (%d > %d)", len, MAX_WCP_BUF_LEN); return NULL; @@ -697,9 +700,18 @@ proto_register_wcp(void) &ett_wcp_field, }; + static ei_register_info ei[] = { + { &ei_wcp_compressed_data_exceeds, { "wcp.compressed_data.exceeds", PI_MALFORMED, PI_ERROR, "Compressed data exceeds maximum buffer length", EXPFILL }}, + { &ei_wcp_uncompressed_data_exceeds, { "wcp.uncompressed_data.exceeds", PI_MALFORMED, PI_ERROR, "Uncompressed data exceeds maximum buffer length", EXPFILL }}, + }; + + expert_module_t* expert_wcp; + proto_wcp = proto_register_protocol ("Wellfleet Compression", "WCP", "wcp"); proto_register_field_array (proto_wcp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_wcp = expert_register_protocol(proto_wcp); + expert_register_field_array(expert_wcp, ei, array_length(ei)); } diff --git a/epan/dissectors/packet-websocket.c b/epan/dissectors/packet-websocket.c index 04b0391180..66bbd0ad08 100644 --- a/epan/dissectors/packet-websocket.c +++ b/epan/dissectors/packet-websocket.c @@ -85,6 +85,8 @@ static gint ett_ws = -1; static gint ett_ws_pl = -1; static gint ett_ws_mask = -1; +static expert_field ei_ws_payload_unknown = EI_INIT; + #define WS_CONTINUE 0x0 #define WS_TEXT 0x1 #define WS_BINARY 0x2 @@ -289,7 +291,7 @@ dissect_websocket_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, p default: /* Unknown */ ti = proto_tree_add_item(pl_tree, hf_ws_payload_unknown, tvb, offset, payload_length, ENC_NA); - expert_add_info_format(pinfo, ti, PI_UNDECODED, PI_NOTE, "Dissector for Websocket Opcode (%d)" + expert_add_info_format_text(pinfo, ti, &ei_ws_payload_unknown, "Dissector for Websocket Opcode (%d)" " code not implemented, Contact Wireshark developers" " if you want this supported", opcode); break; @@ -571,6 +573,10 @@ proto_register_websocket(void) &ett_ws_mask }; + static ei_register_info ei[] = { + { &ei_ws_payload_unknown, { "websocket.payload.unknown.expert", PI_UNDECODED, PI_NOTE, "Dissector for Websocket Opcode", EXPFILL }}, + }; + static const enum_val_t text_types[] = { {"None", "No subdissection", WEBSOCKET_NONE}, {"Line based text", "Line based text", WEBSOCKET_TEXT}, @@ -579,6 +585,7 @@ proto_register_websocket(void) }; module_t *websocket_module; + expert_module_t* expert_websocket; proto_websocket = proto_register_protocol("WebSocket", "WebSocket", "websocket"); @@ -595,6 +602,8 @@ proto_register_websocket(void) proto_register_field_array(proto_websocket, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_websocket = expert_register_protocol(proto_websocket); + expert_register_field_array(expert_websocket, ei, array_length(ei)); new_register_dissector("websocket", dissect_websocket, proto_websocket); diff --git a/epan/dissectors/packet-x11.c b/epan/dissectors/packet-x11.c index 6d49ee6c79..9591e07de0 100644 --- a/epan/dissectors/packet-x11.c +++ b/epan/dissectors/packet-x11.c @@ -201,6 +201,8 @@ static gint ett_x11_keyboard_value_mask = -1; /* XXX - unused */ static gint ett_x11_same_screen_focus = -1; static gint ett_x11_event = -1; +static expert_field ei_x11_invalid_format = EI_INIT; + /* desegmentation of X11 messages */ static gboolean x11_desegment = TRUE; @@ -3397,7 +3399,7 @@ static void dissect_x11_request(tvbuff_t *tvb, packet_info *pinfo, LISTofCARD32(data32, v32 * 4); break; default: - expert_add_info_format(pinfo, ti, PI_PROTOCOL, PI_WARN, "Invalid Format"); + expert_add_info(pinfo, ti, &ei_x11_invalid_format); break; } PAD(); @@ -5601,7 +5603,13 @@ void proto_register_x11(void) &ett_x11_same_screen_focus, &ett_x11_event, }; + + static ei_register_info ei[] = { + { &ei_x11_invalid_format, { "x11.invalid_format", PI_PROTOCOL, PI_WARN, "Invalid Format", EXPFILL }}, + }; + module_t *x11_module; + expert_module_t* expert_x11; /* Register the protocol name and description */ proto_x11 = proto_register_protocol("X11", "X11", "x11"); @@ -5609,6 +5617,8 @@ void proto_register_x11(void) /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_x11, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_x11 = expert_register_protocol(proto_x11); + expert_register_field_array(expert_x11, ei, array_length(ei)); register_init_routine(x11_init_protocol); diff --git a/epan/dissectors/packet-x25.c b/epan/dissectors/packet-x25.c index ab7579a559..67bcee451c 100644 --- a/epan/dissectors/packet-x25.c +++ b/epan/dissectors/packet-x25.c @@ -220,6 +220,8 @@ static gint hf_x25_icrd = -1; static gint hf_x25_reg_confirm_cause = -1; static gint hf_x25_reg_confirm_diagnostic = -1; +static expert_field ei_x25_facility_length = EI_INIT; + static const value_string vals_modulo[] = { { 1, "8" }, { 2, "128" }, @@ -828,7 +830,7 @@ dump_facilities(proto_tree *tree, int *offset, tvbuff_t *tvb, packet_info *pinfo int i; if ((byte1 < 4) || (byte1 % 4)) { - expert_add_info_format(pinfo, ti, PI_PROTOCOL, PI_WARN, "Bogus length"); + expert_add_info(pinfo, ti, &ei_x25_facility_length); return; } for (i = 0; (icinfo, COL_INFO, "(XML dissector disabled, can't dissect XMPP)"); - expert_add_info_format(pinfo, xmpp_item, PI_UNDECODED, PI_WARN, "XML dissector disabled, can't dissect XMPP"); + expert_add_info(pinfo, xmpp_item, &ei_xmpp_xml_disabled); return; } @@ -477,63 +481,59 @@ dissect_xmpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { xmpp_ibb_session_track(pinfo, packet, xmpp_info); } - if (tree) { /* we are being asked for details */ - proto_item *outin_item; + if (out_packet) + outin_item = proto_tree_add_boolean(xmpp_tree, hf_xmpp_out, tvb, 0, 0, TRUE); + else + outin_item = proto_tree_add_boolean(xmpp_tree, hf_xmpp_in, tvb, 0, 0, TRUE); - if (out_packet) - outin_item = proto_tree_add_boolean(xmpp_tree, hf_xmpp_out, tvb, 0, 0, TRUE); - else - outin_item = proto_tree_add_boolean(xmpp_tree, hf_xmpp_in, tvb, 0, 0, TRUE); - - PROTO_ITEM_SET_HIDDEN(outin_item); + PROTO_ITEM_SET_HIDDEN(outin_item); - /*it hides tree generated by XML dissector*/ - xmpp_proto_tree_hide_first_child(xmpp_tree); + /*it hides tree generated by XML dissector*/ + xmpp_proto_tree_hide_first_child(xmpp_tree); - if (strcmp(packet->name, "iq") == 0) { - xmpp_iq(xmpp_tree, tvb, pinfo, packet); - } else if (strcmp(packet->name, "presence") == 0) { - xmpp_presence(xmpp_tree, tvb, pinfo, packet); - } else if (strcmp(packet->name, "message") == 0) { - xmpp_message(xmpp_tree, tvb, pinfo, packet); - } else if (strcmp(packet->name, "auth") == 0) { - xmpp_auth(xmpp_tree, tvb, pinfo, packet); - } else if (strcmp(packet->name, "challenge") == 0) { - xmpp_challenge_response_success(xmpp_tree, tvb, pinfo, packet, hf_xmpp_challenge, ett_xmpp_challenge, "CHALLENGE"); - } else if (strcmp(packet->name, "response") == 0) { - xmpp_challenge_response_success(xmpp_tree, tvb, pinfo, packet, hf_xmpp_response, ett_xmpp_response, "RESPONSE"); - } else if (strcmp(packet->name, "success") == 0) { - xmpp_challenge_response_success(xmpp_tree, tvb, pinfo, packet, hf_xmpp_success, ett_xmpp_success, "SUCCESS"); - } else if (strcmp(packet->name, "failure") == 0) { - xmpp_failure(xmpp_tree, tvb, pinfo, packet); - } else if (strcmp(packet->name, "xml") == 0) { - xmpp_xml_header(xmpp_tree, tvb, pinfo, packet); - } else if (strcmp(packet->name, "stream") == 0) { - xmpp_stream(xmpp_tree, tvb, pinfo, packet); - } else if (strcmp(packet->name, "features") == 0) { - xmpp_features(xmpp_tree, tvb, pinfo, packet); - } else if (strcmp(packet->name, "starttls") == 0) { - xmpp_starttls(xmpp_tree, tvb, pinfo, packet, xmpp_info); - }else if (strcmp(packet->name, "proceed") == 0) { - xmpp_proceed(xmpp_tree, tvb, pinfo, packet, xmpp_info); - }else { - xmpp_proto_tree_show_first_child(xmpp_tree); - expert_add_info_format(pinfo, xmpp_tree, PI_UNDECODED, PI_NOTE, "Unknown packet: %s", packet->name); - col_clear(pinfo->cinfo, COL_INFO); - col_append_fstr(pinfo->cinfo, COL_INFO, "UNKNOWN PACKET "); - } + if (strcmp(packet->name, "iq") == 0) { + xmpp_iq(xmpp_tree, tvb, pinfo, packet); + } else if (strcmp(packet->name, "presence") == 0) { + xmpp_presence(xmpp_tree, tvb, pinfo, packet); + } else if (strcmp(packet->name, "message") == 0) { + xmpp_message(xmpp_tree, tvb, pinfo, packet); + } else if (strcmp(packet->name, "auth") == 0) { + xmpp_auth(xmpp_tree, tvb, pinfo, packet); + } else if (strcmp(packet->name, "challenge") == 0) { + xmpp_challenge_response_success(xmpp_tree, tvb, pinfo, packet, hf_xmpp_challenge, ett_xmpp_challenge, "CHALLENGE"); + } else if (strcmp(packet->name, "response") == 0) { + xmpp_challenge_response_success(xmpp_tree, tvb, pinfo, packet, hf_xmpp_response, ett_xmpp_response, "RESPONSE"); + } else if (strcmp(packet->name, "success") == 0) { + xmpp_challenge_response_success(xmpp_tree, tvb, pinfo, packet, hf_xmpp_success, ett_xmpp_success, "SUCCESS"); + } else if (strcmp(packet->name, "failure") == 0) { + xmpp_failure(xmpp_tree, tvb, pinfo, packet); + } else if (strcmp(packet->name, "xml") == 0) { + xmpp_xml_header(xmpp_tree, tvb, pinfo, packet); + } else if (strcmp(packet->name, "stream") == 0) { + xmpp_stream(xmpp_tree, tvb, pinfo, packet); + } else if (strcmp(packet->name, "features") == 0) { + xmpp_features(xmpp_tree, tvb, pinfo, packet); + } else if (strcmp(packet->name, "starttls") == 0) { + xmpp_starttls(xmpp_tree, tvb, pinfo, packet, xmpp_info); + }else if (strcmp(packet->name, "proceed") == 0) { + xmpp_proceed(xmpp_tree, tvb, pinfo, packet, xmpp_info); + }else { + xmpp_proto_tree_show_first_child(xmpp_tree); + expert_add_info_format_text(pinfo, xmpp_tree, &ei_xmpp_packet_unknown, "Unknown packet: %s", packet->name); + col_clear(pinfo->cinfo, COL_INFO); + col_append_fstr(pinfo->cinfo, COL_INFO, "UNKNOWN PACKET "); + } - /*appends to COL_INFO information about src or dst*/ - if (pinfo->match_uint == pinfo->destport) { - xmpp_attr_t *to = xmpp_get_attr(packet, "to"); - if (to) - col_append_fstr(pinfo->cinfo, COL_INFO, "> %s ", to->value); - } else { - xmpp_attr_t *from = xmpp_get_attr(packet, "from"); - if (from) - col_append_fstr(pinfo->cinfo, COL_INFO, "< %s ", from->value); - } + /*appends to COL_INFO information about src or dst*/ + if (pinfo->match_uint == pinfo->destport) { + xmpp_attr_t *to = xmpp_get_attr(packet, "to"); + if (to) + col_append_fstr(pinfo->cinfo, COL_INFO, "> %s ", to->value); + } else { + xmpp_attr_t *from = xmpp_get_attr(packet, "from"); + if (from) + col_append_fstr(pinfo->cinfo, COL_INFO, "< %s ", from->value); } xmpp_element_t_tree_free(packet); @@ -1384,7 +1384,13 @@ proto_register_xmpp(void) { &ett_xmpp_proceed, }; + static ei_register_info ei[] = { + { &ei_xmpp_xml_disabled, { "xmpp.xml_disabled", PI_UNDECODED, PI_WARN, "XML dissector disabled, can't dissect XMPP", EXPFILL }}, + { &ei_xmpp_packet_unknown, { "xmpp.packet_unknown", PI_UNDECODED, PI_NOTE, "Unknown packet", EXPFILL }}, + }; + module_t *xmpp_module; + expert_module_t* expert_xmpp; static gint* ett_unknown_ptr[ETT_UNKNOWN_LEN]; gint i; @@ -1412,6 +1418,8 @@ proto_register_xmpp(void) { proto_register_field_array(proto_xmpp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); proto_register_subtree_array(ett_unknown_ptr, array_length(ett_unknown_ptr)); + expert_xmpp = expert_register_protocol(proto_xmpp); + expert_register_field_array(expert_xmpp, ei, array_length(ei)); register_dissector("xmpp", dissect_xmpp, proto_xmpp); diff --git a/epan/dissectors/packet-xtp.c b/epan/dissectors/packet-xtp.c index aa7d9f3883..297be19ae5 100644 --- a/epan/dissectors/packet-xtp.c +++ b/epan/dissectors/packet-xtp.c @@ -317,6 +317,8 @@ static gint ett_xtp_aseg = -1; static gint ett_xtp_data = -1; static gint ett_xtp_diag = -1; +static expert_field ei_xtp_spans_bad = EI_INIT; + /* dissector of each payload */ static int dissect_xtp_aseg(tvbuff_t *tvb, proto_tree *tree, guint32 offset) { @@ -770,12 +772,12 @@ dissect_xtp_ecntl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, spans_len = 16 * ecntl->nspan; if (len != spans_len) { - expert_add_info_format(pinfo, top_ti, PI_MALFORMED, PI_ERROR, "Number of spans (%u) incorrect. Should be %u.", ecntl->nspan, len); + expert_add_info_format_text(pinfo, top_ti, &ei_xtp_spans_bad, "Number of spans (%u) incorrect. Should be %u.", ecntl->nspan, len); THROW(ReportedBoundsError); } if (ecntl->nspan > XTP_MAX_NSPANS) { - expert_add_info_format(pinfo, top_ti, PI_MALFORMED, PI_ERROR, "Too many spans: %u", ecntl->nspan); + expert_add_info_format_text(pinfo, top_ti, &ei_xtp_spans_bad, "Too many spans: %u", ecntl->nspan); THROW(ReportedBoundsError); } @@ -1410,6 +1412,15 @@ proto_register_xtp(void) &ett_xtp_diag, }; + static ei_register_info ei[] = { + { &ei_xtp_spans_bad, { "xtp.spans_bad", PI_MALFORMED, PI_ERROR, "Number of spans incorrect", EXPFILL }}, + }; + + expert_module_t* expert_xtp; + + expert_xtp = expert_register_protocol(proto_xtp); + expert_register_field_array(expert_xtp, ei, array_length(ei)); + proto_xtp = proto_register_protocol("Xpress Transport Protocol", "XTP", "xtp"); proto_register_field_array(proto_xtp, hf, array_length(hf)); diff --git a/epan/dissectors/packet-zbee-aps.c b/epan/dissectors/packet-zbee-aps.c index c54bace73b..9150b2712a 100644 --- a/epan/dissectors/packet-zbee-aps.c +++ b/epan/dissectors/packet-zbee-aps.c @@ -135,6 +135,9 @@ static gint ett_zbee_aps_fragments = -1; /* Subtree indices for the ZigBee 2004 & earlier Application Framework. */ static gint ett_zbee_apf = -1; +static expert_field ei_zbee_aps_invalid_delivery_mode = EI_INIT; +static expert_field ei_zbee_aps_missing_payload = EI_INIT; + /* Dissector Handles. */ static dissector_handle_t data_handle; static dissector_handle_t zbee_aps_handle; @@ -704,7 +707,7 @@ dissect_zbee_aps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } else { /* Illegal Delivery Mode. */ - expert_add_info_format(pinfo, proto_root, PI_MALFORMED, PI_WARN, "Invalid Delivery Mode"); + expert_add_info(pinfo, proto_root, &ei_zbee_aps_invalid_delivery_mode); return; } @@ -933,7 +936,7 @@ dissect_zbee_aps_no_endpt: case ZBEE_APS_FCF_CMD: if (!payload_tvb) { /* Command packets MUST contain a payload. */ - expert_add_info_format(pinfo, proto_root, PI_MALFORMED, PI_ERROR, "Missing Payload"); + expert_add_info(pinfo, proto_root, &ei_zbee_aps_missing_payload); THROW(BoundsError); return; } @@ -1956,10 +1959,19 @@ void proto_register_zbee_aps(void) &ett_zbee_apf }; + static ei_register_info ei[] = { + { &ei_zbee_aps_invalid_delivery_mode, { "zbee_aps.invalid_delivery_mode", PI_PROTOCOL, PI_WARN, "Invalid Delivery Mode", EXPFILL }}, + { &ei_zbee_aps_missing_payload, { "zbee_aps.missing_payload", PI_MALFORMED, PI_ERROR, "Missing Payload", EXPFILL }}, + }; + + expert_module_t* expert_zbee_aps; + /* Register ZigBee APS protocol with Wireshark. */ proto_zbee_aps = proto_register_protocol("ZigBee Application Support Layer", "ZigBee APS", ZBEE_PROTOABBREV_APS); proto_register_field_array(proto_zbee_aps, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_zbee_aps = expert_register_protocol(proto_zbee_aps); + expert_register_field_array(expert_zbee_aps, ei, array_length(ei)); /* Register the APS dissector and subdissector list. */ zbee_aps_dissector_table = register_dissector_table("zbee.profile", "ZigBee Profile ID", FT_UINT16, BASE_HEX); diff --git a/epan/dissectors/packet-zbee-nwk.c b/epan/dissectors/packet-zbee-nwk.c index 44ac257bf6..11c680fd80 100644 --- a/epan/dissectors/packet-zbee-nwk.c +++ b/epan/dissectors/packet-zbee-nwk.c @@ -151,6 +151,8 @@ static gint ett_zbee_nwk_cmd = -1; static gint ett_zbee_nwk_cmd_options = -1; static gint ett_zbee_nwk_cmd_cinfo = -1; +static expert_field ei_zbee_nwk_missing_payload = EI_INIT; + static dissector_handle_t data_handle; static dissector_handle_t aps_handle; @@ -668,7 +670,7 @@ dissect_zbee_nwk(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) */ if (offset >= tvb_length(tvb)) { /* Non-existent or truncated payload. */ - expert_add_info_format(pinfo, proto_root, PI_MALFORMED, PI_ERROR, "Missing Payload"); + expert_add_info(pinfo, proto_root, &ei_zbee_nwk_missing_payload); THROW(BoundsError); } /* Payload is encrypted, attempt security operations. */ @@ -1819,6 +1821,15 @@ void proto_register_zbee_nwk(void) &ett_zbee_nwk_cmd_cinfo }; + static ei_register_info ei[] = { + { &ei_zbee_nwk_missing_payload, { "zbee_nwk.missing_payload", PI_MALFORMED, PI_ERROR, "Missing Payload", EXPFILL }}, + }; + + expert_module_t* expert_zbee_nwk; + + expert_zbee_nwk = expert_register_protocol(proto_zbee_nwk); + expert_register_field_array(expert_zbee_nwk, ei, array_length(ei)); + register_init_routine(proto_init_zbee_nwk); /* Register the protocol with Wireshark. */ diff --git a/epan/dissectors/packet-zbee-security.c b/epan/dissectors/packet-zbee-security.c index 14fdb0aebc..8892a2f448 100644 --- a/epan/dissectors/packet-zbee-security.c +++ b/epan/dissectors/packet-zbee-security.c @@ -72,6 +72,8 @@ static int hf_zbee_sec_key_origin = -1; static gint ett_zbee_sec = -1; static gint ett_zbee_sec_control = -1; +static expert_field ei_zbee_sec_encrypted_payload = EI_INIT; + static dissector_handle_t data_handle; static const value_string zbee_sec_key_names[] = { @@ -243,6 +245,12 @@ void zbee_security_register(module_t *zbee_prefs, int proto) &ett_zbee_sec_control }; + static ei_register_info ei[] = { + { &ei_zbee_sec_encrypted_payload, { "zbee_sec.encrypted_payload", PI_UNDECODED, PI_WARN, "Encrypted Payload", EXPFILL }}, + }; + + expert_module_t* expert_zbee_sec; + static uat_field_t key_uat_fields[] = { UAT_FLD_CSTRING(uat_key_records, string, "Key", "A 16-byte key in hexadecimal with optional dash-,\n" @@ -288,6 +296,8 @@ void zbee_security_register(module_t *zbee_prefs, int proto) proto_register_field_array(proto, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_zbee_sec = expert_register_protocol(proto); + expert_register_field_array(expert_zbee_sec, ei, array_length(ei)); /* Register the init routine. */ register_init_routine(proto_init_zbee_security); @@ -719,7 +729,7 @@ dissect_zbee_secure(tvbuff_t *tvb, packet_info *pinfo, proto_tree* tree, guint o #endif /* HAVE_LIBGCRYPT */ /* Add expert info. */ - expert_add_info_format(pinfo, sec_tree, PI_UNDECODED, PI_WARN, "Encrypted Payload"); + expert_add_info(pinfo, sec_tree, &ei_zbee_sec_encrypted_payload); /* Create a buffer for the undecrypted payload. */ payload_tvb = tvb_new_subset(tvb, offset, payload_len, -1); /* Dump the payload to the data dissector. */