diff options
author | Michael Mann <mmann78@netscape.net> | 2014-08-17 16:11:15 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-08-18 07:53:39 +0000 |
commit | 945b371a259ef8ed4fb94b13798162e688234f64 (patch) | |
tree | bdc7bc1620287a6b95452a5f7a0db9ed83d86f5f /epan | |
parent | 83ad0d063c47aa3cc8da53a8f3c61cdd68027145 (diff) |
Eliminate proto_tree_add_text from some dissectors.
Other minor cleanup while in the neighborhood.
Change-Id: I77cac916d617f56f92f686e9cd9f15fba058facf
Reviewed-on: https://code.wireshark.org/review/3675
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')
-rw-r--r-- | epan/dissectors/packet-nb_rtpmux.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-nbipx.c | 127 | ||||
-rw-r--r-- | epan/dissectors/packet-ncp-nmas.c | 26 | ||||
-rw-r--r-- | epan/dissectors/packet-ncp-sss.c | 16 | ||||
-rw-r--r-- | epan/dissectors/packet-ncp.c | 12 | ||||
-rw-r--r-- | epan/dissectors/packet-ndmp.c | 313 | ||||
-rw-r--r-- | epan/dissectors/packet-ndps.c | 76 | ||||
-rw-r--r-- | epan/dissectors/packet-negoex.c | 8 | ||||
-rw-r--r-- | epan/dissectors/packet-netanalyzer.c | 28 | ||||
-rw-r--r-- | epan/dissectors/packet-netlink.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-noe.c | 46 | ||||
-rw-r--r-- | epan/dissectors/packet-nt-tpcp.c | 113 | ||||
-rw-r--r-- | epan/dissectors/packet-ntlmssp.c | 23 | ||||
-rw-r--r-- | epan/dissectors/packet-ntp.c | 71 | ||||
-rw-r--r-- | epan/dissectors/packet-openflow.c | 15 | ||||
-rw-r--r-- | epan/dissectors/packet-openflow_v1.c | 32 |
16 files changed, 468 insertions, 449 deletions
diff --git a/epan/dissectors/packet-nb_rtpmux.c b/epan/dissectors/packet-nb_rtpmux.c index c3dd29a725..3bf398cc83 100644 --- a/epan/dissectors/packet-nb_rtpmux.c +++ b/epan/dissectors/packet-nb_rtpmux.c @@ -53,7 +53,7 @@ static int dissect_nb_rtpmux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { /* Set up structures needed to add the protocol subtree and manage it */ - proto_item *ti, *cmp_rtp_item; + proto_item *ti; proto_tree *nb_rtpmux_tree, *nb_rtpmux_cmp_rtp_tree; unsigned int offset = 0; @@ -117,8 +117,7 @@ dissect_nb_rtpmux(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat proto_tree_add_item(nb_rtpmux_tree, hf_nb_r_bit, tvb, offset+3, 2, ENC_BIG_ENDIAN); srcport = (tvb_get_ntohs(tvb, offset+3) & 0x7fff) << 1; proto_tree_add_uint(nb_rtpmux_tree, hf_nb_rtpmux_srcport, tvb, offset+3, 2, srcport ); - cmp_rtp_item = proto_tree_add_text( nb_rtpmux_tree, tvb, offset+5, 3, "Compressed RTP header" ); - nb_rtpmux_cmp_rtp_tree = proto_item_add_subtree(cmp_rtp_item, ett_nb_rtpmux_cmp_rtp_hdr); + nb_rtpmux_cmp_rtp_tree = proto_tree_add_subtree( nb_rtpmux_tree, tvb, offset+5, 3, ett_nb_rtpmux_cmp_rtp_hdr, NULL, "Compressed RTP header" ); /* Sequence Number (SN) */ proto_tree_add_item(nb_rtpmux_cmp_rtp_tree, hf_nb_rtpmux_cmp_rtp_sequence_no, tvb, offset+5, 1, ENC_BIG_ENDIAN); /* Timestamp (TS) */ diff --git a/epan/dissectors/packet-nbipx.c b/epan/dissectors/packet-nbipx.c index 23b4d5e051..77d15e4d1b 100644 --- a/epan/dissectors/packet-nbipx.c +++ b/epan/dissectors/packet-nbipx.c @@ -56,6 +56,10 @@ static int hf_nbipx_session_offset = -1; static int hf_nbipx_session_data_length = -1; static int hf_nbipx_session_recv_seq_number = -1; static int hf_nbipx_session_bytes_received = -1; +static int hf_nbipx_ipx_network = -1; +static int hf_nbipx_opcode = -1; +static int hf_nbipx_name_type = -1; +static int hf_nbipx_messageid = -1; static gint ett_nbipx = -1; static gint ett_nbipx_conn_ctrl = -1; @@ -204,25 +208,57 @@ static const value_string nbipx_data_stream_type_vals[] = { {0, NULL} }; +/* + * Opcodes. + */ +#define INAME_CLAIM 0xf1 +#define INAME_DELETE 0xf2 +#define INAME_QUERY 0xf3 +#define INAME_FOUND 0xf4 +#define IMSG_HANGUP 0xf5 +#define IMSLOT_SEND 0xfc +#define IMSLOT_FIND 0xfd +#define IMSLOT_NAME 0xfe + +static const value_string nmpi_opcode_vals[] = { + {INAME_CLAIM, "Claim name"}, + {INAME_DELETE, "Delete name"}, + {INAME_QUERY, "Query name"}, + {INAME_FOUND, "Name found"}, + {IMSG_HANGUP, "Messenger hangup"}, + {IMSLOT_SEND, "Mailslot write"}, + {IMSLOT_FIND, "Find mailslot name"}, + {IMSLOT_NAME, "Mailslot name found"}, + {0, NULL} +}; + +/* + * Name types. + */ +#define INTYPE_MACHINE 1 +#define INTYPE_WORKGROUP 2 +#define INTYPE_BROWSER 3 + +static const value_string nmpi_name_type_vals[] = { + {INTYPE_MACHINE, "Machine"}, + {INTYPE_WORKGROUP, "Workgroup"}, + {INTYPE_BROWSER, "Browser"}, + {0, NULL} +}; + static const true_false_string tfs_system_non_system = { "System packet", "Non-system packet" }; static void add_routers(proto_tree *tree, tvbuff_t *tvb, int offset) { int i; - int rtr_offset; - guint32 router; /* Eight routers are listed */ for (i = 0; i < 8; i++) { - rtr_offset = offset + (i << 2); - tvb_memcpy(tvb, (guint8 *)&router, rtr_offset, 4); - if (router != 0) { - /* XXX - proto_tree_add_item with FT_IPXNET type? */ - proto_tree_add_text(tree, tvb, rtr_offset, 4, - "IPX Network: %s", - ipxnet_to_string((guint8*)&router)); + if (tvb_get_ntohl(tvb, offset) != 0) { + proto_tree_add_item(tree, hf_nbipx_ipx_network, tvb, offset, 4, ENC_NA); } + offset += 4; } } @@ -567,6 +603,26 @@ proto_register_nbipx(void) FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } }, + { &hf_nbipx_ipx_network, + { "IPX Network", "nmpi.ipx_network", + FT_IPXNET, BASE_NONE, NULL, 0, + NULL, HFILL } + }, + { &hf_nbipx_opcode, + { "Opcode", "nmpi.opcode", + FT_UINT8, BASE_HEX, VALS(nmpi_opcode_vals), 0, + NULL, HFILL } + }, + { &hf_nbipx_name_type, + { "Name Type", "nmpi.name_type", + FT_UINT8, BASE_HEX, VALS(nmpi_name_type_vals), 0, + NULL, HFILL } + }, + { &hf_nbipx_messageid, + { "Message ID", "nmpi.messageid", + FT_UINT16, BASE_HEX, NULL, 0, + NULL, HFILL } + }, }; static gint *ett[] = { @@ -673,43 +729,6 @@ static int proto_nmpi = -1; static gint ett_nmpi = -1; static gint ett_nmpi_name_type_flags = -1; -/* - * Opcodes. - */ -#define INAME_CLAIM 0xf1 -#define INAME_DELETE 0xf2 -#define INAME_QUERY 0xf3 -#define INAME_FOUND 0xf4 -#define IMSG_HANGUP 0xf5 -#define IMSLOT_SEND 0xfc -#define IMSLOT_FIND 0xfd -#define IMSLOT_NAME 0xfe - -static const value_string nmpi_opcode_vals[] = { - {INAME_CLAIM, "Claim name"}, - {INAME_DELETE, "Delete name"}, - {INAME_QUERY, "Query name"}, - {INAME_FOUND, "Name found"}, - {IMSG_HANGUP, "Messenger hangup"}, - {IMSLOT_SEND, "Mailslot write"}, - {IMSLOT_FIND, "Find mailslot name"}, - {IMSLOT_NAME, "Mailslot name found"}, - {0, NULL} -}; - -/* - * Name types. - */ -#define INTYPE_MACHINE 1 -#define INTYPE_WORKGROUP 2 -#define INTYPE_BROWSER 3 - -static const value_string nmpi_name_type_vals[] = { - {INTYPE_MACHINE, "Machine"}, - {INTYPE_WORKGROUP, "Workgroup"}, - {INTYPE_BROWSER, "Browser"}, - {0, NULL} -}; static void dissect_nmpi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) @@ -718,7 +737,6 @@ dissect_nmpi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti; int offset = 0; guint8 opcode; - guint8 nmpi_name_type; char name[(NETBIOS_NAME_LEN - 1)*4 + 1]; int name_type; char node_name[(NETBIOS_NAME_LEN - 1)*4 + 1]; @@ -741,7 +759,6 @@ dissect_nmpi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) * XXX - we don't use "node_name" or "node_name_type". */ opcode = tvb_get_guint8(tvb, offset); - nmpi_name_type = tvb_get_guint8(tvb, offset+1); name_type = get_netbios_name(tvb, offset+4, name, (NETBIOS_NAME_LEN - 1)*4 + 1); /*node_name_type = */get_netbios_name(tvb, offset+20, node_name, (NETBIOS_NAME_LEN - 1)*4 + 1); @@ -795,17 +812,9 @@ dissect_nmpi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (tree) { - proto_tree_add_text(nmpi_tree, tvb, offset, 1, - "Opcode: %s (0x%02x)", - val_to_str_const(opcode, nmpi_opcode_vals, "Unknown"), - opcode); - proto_tree_add_text(nmpi_tree, tvb, offset+1, 1, - "Name Type: %s (0x%02x)", - val_to_str_const(nmpi_name_type, nmpi_name_type_vals, "Unknown"), - nmpi_name_type); - proto_tree_add_text(nmpi_tree, tvb, offset+2, 2, - "Message ID: 0x%04x", - tvb_get_letohs(tvb, offset+2)); + proto_tree_add_item(nmpi_tree, hf_nbipx_opcode, tvb, offset, 1, ENC_NA); + proto_tree_add_item(nmpi_tree, hf_nbipx_name_type, tvb, offset+1, 1, ENC_NA); + proto_tree_add_item(nmpi_tree, hf_nbipx_messageid, tvb, offset+2, 2, ENC_LITTLE_ENDIAN); netbios_add_name("Requested name", tvb, offset+4, nmpi_tree); netbios_add_name("Source name", tvb, offset+20, nmpi_tree); } diff --git a/epan/dissectors/packet-ncp-nmas.c b/epan/dissectors/packet-ncp-nmas.c index a20aadef95..e29f88ffee 100644 --- a/epan/dissectors/packet-ncp-nmas.c +++ b/epan/dissectors/packet-ncp-nmas.c @@ -47,6 +47,7 @@ static int hf_user = -1; static int hf_nmas_version = -1; static int hf_msg_version = -1; static int hf_session_ident = -1; +static int hf_verb = -1; static int hf_msg_verb = -1; /* static int hf_attribute = -1; */ static int hf_clearance = -1; @@ -276,7 +277,6 @@ dissect_nmas_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, nc guint32 attribute=0; guint8 msgverb=0; proto_tree *atree; - proto_item *aitem; foffset = 6; /*func = tvb_get_guint8(tvb, foffset);*/ @@ -289,9 +289,8 @@ dissect_nmas_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, nc col_add_fstr(pinfo->cinfo, COL_INFO, "C NMAS - %s", val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)")); - aitem = proto_tree_add_text(ncp_tree, tvb, foffset, -1, "Packet Type: %s", + atree = proto_tree_add_subtree_format(ncp_tree, tvb, foffset, -1, ett_nmas, NULL, "Packet Type: %s", val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)")); - atree = proto_item_add_subtree(aitem, ett_nmas); switch (subfunc) { case 1: proto_tree_add_item(atree, hf_ping_version, tvb, foffset, 4, ENC_LITTLE_ENDIAN); @@ -461,7 +460,6 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin guint32 msg_length=0; guint32 return_code=0, encrypt_error=0; proto_tree *atree; - proto_item *aitem; proto_item *expert_item; const gchar *str; @@ -476,9 +474,8 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin return; } - aitem = proto_tree_add_text(ncp_tree, tvb, foffset, -1, "Packet Type: %s", + atree = proto_tree_add_subtree_format(ncp_tree, tvb, foffset, -1, ett_nmas, NULL, "Packet Type: %s", val_to_str(subfunc, nmas_func_enum, "Unknown (0x%02x)")); - atree = proto_item_add_subtree(aitem, ett_nmas); switch (subfunc) { case 1: proto_tree_add_item(atree, hf_ping_flags, tvb, foffset, 4, ENC_LITTLE_ENDIAN); @@ -487,8 +484,7 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin /*foffset += 4;*/ break; case 2: - proto_tree_add_text(atree, tvb, foffset, -1, "Verb: %s", - val_to_str(subverb, nmas_subverb_enum, "Unknown (%u)")); + proto_tree_add_uint(atree, hf_verb, tvb, foffset, -1, subverb); proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_LITTLE_ENDIAN); msg_length = tvb_get_letohl(tvb, foffset); foffset +=4; @@ -532,8 +528,8 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin /*foffset += msg_length;*/ break; case 8: /* Login Store Management */ - proto_tree_add_text(atree, tvb, foffset, -1, "Subverb: %s", - val_to_str(msgverb, nmas_lsmverb_enum, "Unknown (%u)")); + proto_tree_add_uint_format(atree, hf_lsm_verb, tvb, foffset, -1, msgverb, + "Subverb: %s", val_to_str(msgverb, nmas_lsmverb_enum, "Unknown (%u)")); switch(msgverb) { /* The data within these structures is all encrypted. */ case 1: @@ -553,8 +549,8 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin /*foffset += 4;*/ break; case 1242: /* Message Handler */ - proto_tree_add_text(atree, tvb, foffset, -1, "Subverb: %s", - val_to_str(msgverb, nmas_msgverb_enum, "Unknown (%u)")); + proto_tree_add_uint_format(atree, hf_msg_verb, tvb, foffset, 1, msgverb, + "Subverb: %s", val_to_str(msgverb, nmas_msgverb_enum, "Unknown (%u)")); switch(msgverb) { case 1: msg_length = tvb_get_ntohl(tvb, foffset); @@ -607,7 +603,7 @@ dissect_nmas_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guin } if (return_code == 0) { - proto_tree_add_text(atree, tvb, roffset, 4, "Return Code: Success (0x00000000)"); + proto_tree_add_uint_format_value(atree, hf_return_code, tvb, roffset, 4, return_code, "Success (0x00000000)"); } break; case 3: @@ -673,6 +669,10 @@ proto_register_nmas(void) { "Session Identifier", "nmas.session_ident", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_verb, + { "Verb", "nmas.verb", + FT_UINT8, BASE_HEX, VALS(nmas_subverb_enum), 0x0, NULL, HFILL }}, + { &hf_msg_verb, { "Message Verb", "nmas.msg_verb", FT_UINT8, BASE_HEX, VALS(nmas_msgverb_enum), 0x0, NULL, HFILL }}, diff --git a/epan/dissectors/packet-ncp-sss.c b/epan/dissectors/packet-ncp-sss.c index cfee0d9ac6..60a307b67e 100644 --- a/epan/dissectors/packet-ncp-sss.c +++ b/epan/dissectors/packet-ncp-sss.c @@ -508,8 +508,7 @@ dissect_sss_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, ncp switch (subfunc) { case 1: - aitem = proto_tree_add_text(ncp_tree, tvb, foffset, -1, "Packet Type: %s", val_to_str(subfunc, sss_func_enum, "Unknown (%d)")); - atree = proto_item_add_subtree(aitem, ett_sss); + atree = proto_tree_add_subtree_format(ncp_tree, tvb, foffset, -1, ett_sss, NULL, "Packet Type: %s", val_to_str(subfunc, sss_func_enum, "Unknown (%d)")); proto_tree_add_item(atree, hf_ping_version, tvb, foffset, 4, ENC_LITTLE_ENDIAN); foffset += 4; proto_tree_add_item(atree, hf_flags, tvb, foffset, 4, ENC_LITTLE_ENDIAN); @@ -594,7 +593,6 @@ dissect_sss_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, ncp } } else { col_set_str(pinfo->cinfo, COL_INFO, "C SecretStore - fragment"); - proto_tree_add_text(ncp_tree, tvb, foffset, 4, "Fragment"); /* Fragments don't really carry a subverb so store 0xff as the subverb number */ if (request_value) { @@ -602,7 +600,7 @@ dissect_sss_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, ncp } if (tvb_length_remaining(tvb, foffset) > 8) { foffset += 4; - proto_tree_add_item(ncp_tree, hf_enc_data, tvb, foffset, tvb_length_remaining(tvb, foffset), ENC_NA); + proto_tree_add_item(ncp_tree, hf_enc_data, tvb, foffset, -1, ENC_NA); } } break; @@ -627,7 +625,6 @@ dissect_sss_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guint const gchar *str; proto_tree *atree; - proto_item *aitem; proto_item *expert_item; foffset = 8; @@ -635,8 +632,7 @@ dissect_sss_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guint if (tvb_length_remaining(tvb, foffset)<4) { return; } - aitem = proto_tree_add_text(ncp_tree, tvb, foffset, -1, "Function: %s", val_to_str_const(subfunc, sss_func_enum, "Unknown")); - atree = proto_item_add_subtree(aitem, ett_sss); + atree = proto_tree_add_subtree_format(ncp_tree, tvb, foffset, -1, ett_sss, NULL, "Function: %s", val_to_str_const(subfunc, sss_func_enum, "Unknown")); switch (subfunc) { case 1: proto_tree_add_item(atree, hf_flags, tvb, foffset, 4, ENC_LITTLE_ENDIAN); @@ -649,7 +645,7 @@ dissect_sss_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guint subverb = request_value->req_nds_flags; str = try_val_to_str(subverb, sss_verb_enum); if (str) { - proto_tree_add_text(atree, tvb, foffset, tvb_length_remaining(tvb, foffset), "Verb: %s", str); + proto_tree_add_uint(atree, hf_verb, tvb, foffset, -1, subverb); } } proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_LITTLE_ENDIAN); @@ -668,7 +664,7 @@ dissect_sss_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guint col_add_fstr(pinfo->cinfo, COL_INFO, "R Error - %s", val_to_str(return_code, sss_errors_enum, "Unknown (%d)")); /*foffset+=4;*/ } else { - proto_tree_add_text(atree, tvb, foffset, 4, "Return Code: Success (0x00000000)"); + proto_tree_add_uint_format_value(atree, hf_return_code, tvb, foffset, 4, 0, "Success (0x00000000)"); if (tvb_length_remaining(tvb, foffset) > 8) { foffset += 4; if (request_value && subverb == 6) { @@ -692,7 +688,7 @@ dissect_sss_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ncp_tree, guint } } } else { - proto_tree_add_text(atree, tvb, foffset, 4, "Return Code: Success (0x00000000)"); + proto_tree_add_uint_format_value(atree, hf_return_code, tvb, foffset, 4, 0, "Success (0x00000000)"); if (tvb_length_remaining(tvb, foffset) > 8) { foffset += 4; proto_tree_add_item(atree, hf_enc_data, tvb, foffset, tvb_length_remaining(tvb, foffset), ENC_NA); diff --git a/epan/dissectors/packet-ncp.c b/epan/dissectors/packet-ncp.c index 503262fd10..a855a3d4a5 100644 --- a/epan/dissectors/packet-ncp.c +++ b/epan/dissectors/packet-ncp.c @@ -375,7 +375,6 @@ dissect_ncp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 missing_fraglist_count = 0; mncp_rhash_value *request_value = NULL; conversation_t *conversation; - proto_item *expert_item; col_set_str(pinfo->cinfo, COL_PROTOCOL, "NCP"); col_clear(pinfo->cinfo, COL_INFO); @@ -737,8 +736,7 @@ dissect_ncp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (length_remaining > 4) { testvar = tvb_get_ntohl(tvb, commhdr+4); if (testvar == 0x4c495020) { - proto_tree_add_text(ncp_tree, tvb, commhdr, -1, - "Lip Echo Packet"); + proto_tree_add_item(ncp_tree, hf_lip_echo, tvb, commhdr, -1, ENC_ASCII|ENC_NA); /*break;*/ } } @@ -862,18 +860,14 @@ dissect_ncp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, break; case NCP_LIP_ECHO: /* LIP Echo Packet */ - proto_tree_add_text(ncp_tree, tvb, commhdr, -1, - "Lip Echo Packet"); + proto_tree_add_item(ncp_tree, hf_lip_echo, tvb, commhdr, -1, ENC_ASCII|ENC_NA); break; default: - expert_item = proto_tree_add_text(ncp_tree, tvb, commhdr + 6, -1, + proto_tree_add_expert_format(ncp_tree, pinfo, &ei_ncp_type, tvb, commhdr + 6, -1, "%s packets not supported yet", val_to_str(header.type, ncp_type_vals, "Unknown type (0x%04x)")); - if (ncp_echo_err) { - expert_add_info_format(pinfo, expert_item, &ei_ncp_type, "%s packets not supported yet", val_to_str(header.type, ncp_type_vals, "Unknown type (0x%04x)")); - } break; } } diff --git a/epan/dissectors/packet-ndmp.c b/epan/dissectors/packet-ndmp.c index 370748b529..4a47162611 100644 --- a/epan/dissectors/packet-ndmp.c +++ b/epan/dissectors/packet-ndmp.c @@ -35,6 +35,7 @@ #include <epan/packet.h> #include <epan/conversation.h> +#include <epan/expert.h> #include <epan/wmem/wmem.h> #include "packet-rpc.h" #include "packet-ndmp.h" @@ -79,6 +80,7 @@ static int hf_ndmp_auth_password = -1; static int hf_ndmp_butype_info = -1; static int hf_ndmp_butype_name = -1; static int hf_ndmp_butype_default_env = -1; +static int hf_ndmp_butype_attr = -1; static int hf_ndmp_butype_attr_backup_file_history = -1; static int hf_ndmp_butype_attr_backup_filelist = -1; static int hf_ndmp_butype_attr_recover_filelist = -1; @@ -95,6 +97,7 @@ static int hf_ndmp_tcp_env_value = -1; static int hf_ndmp_tcp_default_env = -1; static int hf_ndmp_tcp_addr_list = -1; static int hf_ndmp_fs_info = -1; +static int hf_ndmp_fs_invalid = -1; static int hf_ndmp_fs_invalid_total_size = -1; static int hf_ndmp_fs_invalid_used_size = -1; static int hf_ndmp_fs_invalid_avail_size = -1; @@ -117,6 +120,7 @@ static int hf_ndmp_tape_model = -1; static int hf_ndmp_tape_dev_cap = -1; static int hf_ndmp_tape_device = -1; static int hf_ndmp_tape_open_mode = -1; +static int hf_ndmp_tape_attr = -1; static int hf_ndmp_tape_attr_rewind = -1; static int hf_ndmp_tape_attr_unload = -1; static int hf_ndmp_tape_capability = -1; @@ -131,6 +135,7 @@ static int hf_ndmp_scsi_device = -1; static int hf_ndmp_scsi_controller = -1; static int hf_ndmp_scsi_id = -1; static int hf_ndmp_scsi_lun = -1; +static int hf_ndmp_execute_cdb_flags = -1; static int hf_ndmp_execute_cdb_flags_data_in = -1; static int hf_ndmp_execute_cdb_flags_data_out = -1; static int hf_ndmp_execute_cdb_timeout = -1; @@ -141,6 +146,7 @@ static int hf_ndmp_execute_cdb_status = -1; static int hf_ndmp_execute_cdb_dataout_len = -1; /* static int hf_ndmp_execute_cdb_datain = -1; */ static int hf_ndmp_execute_cdb_sns_len = -1; +static int hf_ndmp_tape_invalid = -1; static int hf_ndmp_tape_invalid_file_num = -1; static int hf_ndmp_tape_invalid_soft_errors = -1; static int hf_ndmp_tape_invalid_block_size = -1; @@ -148,6 +154,7 @@ static int hf_ndmp_tape_invalid_block_no = -1; static int hf_ndmp_tape_invalid_total_space = -1; static int hf_ndmp_tape_invalid_space_remain = -1; static int hf_ndmp_tape_invalid_partition = -1; +static int hf_ndmp_tape_flags = -1; static int hf_ndmp_tape_flags_no_rewind = -1; static int hf_ndmp_tape_flags_write_protect = -1; static int hf_ndmp_tape_flags_error = -1; @@ -194,6 +201,7 @@ static int hf_ndmp_file_stats = -1; static int hf_ndmp_file_node = -1; static int hf_ndmp_file_parent = -1; static int hf_ndmp_file_fh_info = -1; +static int hf_ndmp_file_invalid = -1; static int hf_ndmp_file_invalid_atime = -1; static int hf_ndmp_file_invalid_ctime = -1; static int hf_ndmp_file_invalid_group = -1; @@ -213,6 +221,7 @@ static int hf_ndmp_bu_original_path = -1; static int hf_ndmp_bu_destination_dir = -1; static int hf_ndmp_bu_new_name = -1; static int hf_ndmp_bu_other_name = -1; +static int hf_ndmp_state_invalid = -1; static int hf_ndmp_state_invalid_ebr = -1; static int hf_ndmp_state_invalid_etr = -1; static int hf_ndmp_bu_operation = -1; @@ -228,6 +237,7 @@ static int hf_ndmp_ext_version_list = -1; static int hf_ndmp_class_version = -1; static int hf_ndmp_ex_class_version = -1; +static int hf_ndmp_fragment_data = -1; static int hf_ndmp_fragments = -1; static int hf_ndmp_fragment = -1; static int hf_ndmp_fragment_overlap = -1; @@ -260,6 +270,8 @@ static gint ett_ndmp_state_invalids = -1; static gint ett_ndmp_fragment = -1; static gint ett_ndmp_fragments = -1; +static expert_field ei_ndmp_msg = EI_INIT; + static const fragment_items ndmp_frag_items = { /* Fragment subtrees */ &ett_ndmp_fragment, @@ -865,35 +877,20 @@ static int dissect_butype_attrs(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *parent_tree) { - proto_item* item = NULL; - proto_tree* tree = NULL; - guint32 flags; - - flags=tvb_get_ntohl(tvb, offset); - if (parent_tree) { - item = proto_tree_add_text(parent_tree, tvb, offset, 4, - "Attributes: 0x%08x", flags); - tree = proto_item_add_subtree(item, ett_ndmp_butype_attrs); - } - - proto_tree_add_boolean(tree, hf_ndmp_butype_attr_recover_utf8, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_butype_attr_backup_utf8, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_butype_attr_recover_incremental, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_butype_attr_backup_incremental, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_butype_attr_recover_direct, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_butype_attr_backup_direct, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_butype_attr_recover_filelist, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_butype_attr_backup_filelist, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_butype_attr_backup_file_history, - tvb, offset, 4, flags); + static const int * attribute_flags[] = { + &hf_ndmp_butype_attr_recover_utf8, + &hf_ndmp_butype_attr_backup_utf8, + &hf_ndmp_butype_attr_recover_incremental, + &hf_ndmp_butype_attr_backup_incremental, + &hf_ndmp_butype_attr_recover_direct, + &hf_ndmp_butype_attr_backup_direct, + &hf_ndmp_butype_attr_recover_filelist, + &hf_ndmp_butype_attr_backup_filelist, + &hf_ndmp_butype_attr_backup_file_history, + NULL + }; + + proto_tree_add_bitmask(parent_tree, tvb, offset, hf_ndmp_butype_attr, ett_ndmp_butype_attrs, attribute_flags, ENC_NA); offset += 4; return offset; @@ -954,27 +951,16 @@ static int dissect_fs_invalid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *parent_tree) { - proto_item* item = NULL; - proto_tree* tree = NULL; - guint32 flags; - - flags=tvb_get_ntohl(tvb, offset); - if (parent_tree) { - item = proto_tree_add_text(parent_tree, tvb, offset, 4, - "Invalids: 0x%08x", flags); - tree = proto_item_add_subtree(item, ett_ndmp_fs_invalid); - } + static const int * invalid_flags[] = { + &hf_ndmp_fs_invalid_used_inodes, + &hf_ndmp_fs_invalid_total_inodes, + &hf_ndmp_fs_invalid_avail_size, + &hf_ndmp_fs_invalid_used_size, + &hf_ndmp_fs_invalid_total_size, + NULL + }; - proto_tree_add_boolean(tree, hf_ndmp_fs_invalid_used_inodes, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_fs_invalid_total_inodes, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_fs_invalid_avail_size, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_fs_invalid_used_size, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_fs_invalid_total_size, - tvb, offset, 4, flags); + proto_tree_add_bitmask(parent_tree, tvb, offset, hf_ndmp_fs_invalid, ett_ndmp_fs_invalid, invalid_flags, ENC_NA); offset+=4; return offset; @@ -1070,21 +1056,13 @@ static int dissect_tape_attr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *parent_tree) { - proto_item* item = NULL; - proto_tree* tree = NULL; - guint32 flags; - - flags=tvb_get_ntohl(tvb, offset); - if (parent_tree) { - item = proto_tree_add_text(parent_tree, tvb, offset, 4, - "Attributes: 0x%08x", flags); - tree = proto_item_add_subtree(item, ett_ndmp_tape_attr); - } + static const int * attribute_flags[] = { + &hf_ndmp_tape_attr_unload, + &hf_ndmp_tape_attr_rewind, + NULL + }; - proto_tree_add_boolean(tree, hf_ndmp_tape_attr_unload, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_tape_attr_rewind, - tvb, offset, 4, flags); + proto_tree_add_bitmask(parent_tree, tvb, offset, hf_ndmp_tape_attr, ett_ndmp_tape_attr, attribute_flags, ENC_NA); offset+=4; return offset; @@ -1350,21 +1328,14 @@ static int dissect_execute_cdb_flags(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *parent_tree) { - proto_item* item = NULL; - proto_tree* tree = NULL; - guint32 flags; - - flags = tvb_get_ntohl(tvb, offset); - if (parent_tree) { - item = proto_tree_add_text(parent_tree, tvb, offset, 4, - "Flags: 0x%08x", flags); - tree = proto_item_add_subtree(item, ett_ndmp_execute_cdb_flags); - } + static const int * cdb_flags[] = { + &hf_ndmp_execute_cdb_flags_data_in, + &hf_ndmp_execute_cdb_flags_data_out, + NULL + }; + + proto_tree_add_bitmask(parent_tree, tvb, offset, hf_ndmp_execute_cdb_flags, ett_ndmp_execute_cdb_flags, cdb_flags, ENC_NA); - proto_tree_add_boolean(tree, hf_ndmp_execute_cdb_flags_data_in, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_execute_cdb_flags_data_out, - tvb, offset, 4, flags); offset += 4; return offset; } @@ -1646,31 +1617,18 @@ static int dissect_tape_invalid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *parent_tree) { - proto_item* item = NULL; - proto_tree* tree = NULL; - guint32 flags; - - flags=tvb_get_ntohl(tvb, offset); - if (parent_tree) { - item = proto_tree_add_text(parent_tree, tvb, offset, 4, - "Invalids: 0x%08x", flags); - tree = proto_item_add_subtree(item, ett_ndmp_tape_invalid); - } - - proto_tree_add_boolean(tree, hf_ndmp_tape_invalid_partition, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_tape_invalid_space_remain, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_tape_invalid_total_space, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_tape_invalid_block_no, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_tape_invalid_block_size, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_tape_invalid_soft_errors, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_tape_invalid_file_num, - tvb, offset, 4, flags); + static const int * invalid_tapes[] = { + &hf_ndmp_tape_invalid_partition, + &hf_ndmp_tape_invalid_space_remain, + &hf_ndmp_tape_invalid_total_space, + &hf_ndmp_tape_invalid_block_no, + &hf_ndmp_tape_invalid_block_size, + &hf_ndmp_tape_invalid_soft_errors, + &hf_ndmp_tape_invalid_file_num, + NULL + }; + + proto_tree_add_bitmask(parent_tree, tvb, offset, hf_ndmp_tape_invalid, ett_ndmp_tape_invalid, invalid_tapes, ENC_NA); offset+=4; return offset; @@ -1696,26 +1654,15 @@ static int dissect_tape_flags(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *parent_tree) { - proto_item* item = NULL; - proto_tree* tree = NULL; - guint32 flags; - - flags=tvb_get_ntohl(tvb, offset); - if (parent_tree) { - item = proto_tree_add_text(parent_tree, tvb, offset, 4, - "Flags: 0x%08x", flags); - tree = proto_item_add_subtree(item, ett_ndmp_tape_flags); - } - + static const int * tape_flags[] = { + &hf_ndmp_tape_flags_unload, + &hf_ndmp_tape_flags_error, + &hf_ndmp_tape_flags_write_protect, + &hf_ndmp_tape_flags_no_rewind, + NULL + }; - proto_tree_add_boolean(tree, hf_ndmp_tape_flags_unload, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_tape_flags_error, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_tape_flags_write_protect, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_tape_flags_no_rewind, - tvb, offset, 4, flags); + proto_tree_add_bitmask(parent_tree, tvb, offset, hf_ndmp_tape_flags, ett_ndmp_tape_flags, tape_flags, ENC_NA); offset+=4; return offset; @@ -2410,23 +2357,14 @@ static int dissect_file_invalids(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *parent_tree) { - proto_item* item = NULL; - proto_tree* tree = NULL; - guint32 flags; - - flags=tvb_get_ntohl(tvb, offset); - if (parent_tree) { - item = proto_tree_add_text(parent_tree, tvb, offset, 4, - "Invalids: 0x%08x", flags); - tree = proto_item_add_subtree(item, ett_ndmp_file_invalids); - } + static const int * invalid_files[] = { + &hf_ndmp_file_invalid_group, + &hf_ndmp_file_invalid_ctime, + &hf_ndmp_file_invalid_atime, + NULL + }; - proto_tree_add_boolean(tree, hf_ndmp_file_invalid_group, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_file_invalid_ctime, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_file_invalid_atime, - tvb, offset, 4, flags); + proto_tree_add_bitmask(parent_tree, tvb, offset, hf_ndmp_file_invalid, ett_ndmp_file_invalids, invalid_files, ENC_NA); offset+=4; return offset; @@ -2724,21 +2662,13 @@ static int dissect_state_invalids(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *parent_tree) { - proto_item* item = NULL; - proto_tree* tree = NULL; - guint32 flags; - - flags=tvb_get_ntohl(tvb, offset); - if (parent_tree) { - item = proto_tree_add_text(parent_tree, tvb, offset, 4, - "Invalids: 0x%08x", flags); - tree = proto_item_add_subtree(item, ett_ndmp_state_invalids); - } + static const int * invalid_states[] = { + &hf_ndmp_state_invalid_etr, + &hf_ndmp_state_invalid_ebr, + NULL + }; - proto_tree_add_boolean(tree, hf_ndmp_state_invalid_etr, - tvb, offset, 4, flags); - proto_tree_add_boolean(tree, hf_ndmp_state_invalid_ebr, - tvb, offset, 4, flags); + proto_tree_add_bitmask(parent_tree, tvb, offset, hf_ndmp_state_invalid, ett_ndmp_state_invalids, invalid_states, ENC_NA); offset+=4; return offset; @@ -2960,17 +2890,15 @@ static const ndmp_command ndmp_commands[] = { static int -dissect_ndmp_header(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, struct ndmp_header *nh) +dissect_ndmp_header(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, struct ndmp_header *nh, proto_item** msg_item) { - proto_item* item = NULL; - proto_tree* tree = NULL; + proto_item* item; + proto_tree* tree; nstime_t ns; - if (parent_tree) { - item = proto_tree_add_item(parent_tree, hf_ndmp_header, tvb, + item = proto_tree_add_item(parent_tree, hf_ndmp_header, tvb, offset, 24, ENC_NA); - tree = proto_item_add_subtree(item, ett_ndmp_header); - } + tree = proto_item_add_subtree(item, ett_ndmp_header); /* sequence number */ proto_tree_add_uint(tree, hf_ndmp_sequence, tvb, offset, 4, nh->seq); @@ -2987,7 +2915,7 @@ dissect_ndmp_header(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *p offset += 4; /* Message */ - proto_tree_add_uint(tree, hf_ndmp_msg, tvb, offset, 4, nh->msg); + *msg_item = proto_tree_add_uint(tree, hf_ndmp_msg, tvb, offset, 4, nh->msg); offset += 4; /* Reply sequence number */ @@ -3011,8 +2939,9 @@ dissect_ndmp_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree { int i; proto_tree *cmd_tree=NULL; + proto_item *msg_item=NULL; - offset=dissect_ndmp_header(tvb, offset, pinfo, tree, nh); + offset=dissect_ndmp_header(tvb, offset, pinfo, tree, nh, &msg_item); for(i=0;ndmp_commands[i].cmd!=0;i++){ if(ndmp_commands[i].cmd==nh->msg){ @@ -3023,7 +2952,7 @@ dissect_ndmp_cmd(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree if(ndmp_commands[i].cmd==0){ /* we do not know this message */ - proto_tree_add_text(tree, tvb, offset, -1, "Unknown type of NDMP message: 0x%02x", nh->msg); + expert_add_info(pinfo, msg_item, &ei_ndmp_msg); offset+=tvb_length_remaining(tvb, offset); return offset; } @@ -3057,7 +2986,6 @@ dissect_ndmp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* struct ndmp_header nh; guint32 size; guint32 seq, len, nxt, frag_num; - gint nbytes; int direction; struct tcpinfo *tcpinfo; ndmp_frag_info* nfi; @@ -3247,8 +3175,7 @@ dissect_ndmp_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* /* * Decode the remaining bytes as generic NDMP fragment data */ - nbytes = tvb_reported_length_remaining(tvb, 4); - proto_tree_add_text(ndmp_tree, tvb, 4, nbytes, "NDMP fragment data (%u byte%s)", nbytes, plurality(nbytes, "", "s")); + proto_tree_add_item(ndmp_tree, hf_ndmp_fragment_data, tvb, 4, -1, ENC_NA); pinfo->fragmented = save_fragmented; return tvb_length(tvb); @@ -3603,6 +3530,10 @@ proto_register_ndmp(void) "Default Env", "ndmp.tcp.default_env", FT_NONE, BASE_NONE, NULL, 0, "Default Env's for this Butype Info", HFILL }}, + { &hf_ndmp_butype_attr, { + "Attributes", "ndmp.butype.attr", FT_UINT32, BASE_HEX, + NULL, 0, NULL, HFILL }}, + { &hf_ndmp_butype_attr_backup_file_history, { "Backup file history", "ndmp.butype.attr.backup_file_history", FT_BOOLEAN, 32, TFS(&tfs_butype_attr_backup_file_history), 0x00000001, "backup_file_history", HFILL }}, @@ -3659,6 +3590,10 @@ proto_register_ndmp(void) "FS Info", "ndmp.fs.info", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }}, + { &hf_ndmp_fs_invalid, { + "Invalids", "ndmp.fs.invalid", FT_UINT32, BASE_HEX, + NULL, 0, NULL, HFILL }}, + { &hf_ndmp_fs_invalid_total_size, { "Total size invalid", "ndmp.fs.invalid.total_size", FT_BOOLEAN, 32, TFS(&tfs_fs_invalid_total_size), 0x00000001, "If total size is invalid", HFILL }}, @@ -3743,6 +3678,10 @@ proto_register_ndmp(void) "Device", "ndmp.tape.device", FT_STRING, BASE_NONE, NULL, 0, "Name of TAPE Device", HFILL }}, + { &hf_ndmp_tape_attr, { + "Attributes", "ndmp.tape.attr", FT_UINT32, BASE_HEX, + NULL, 0, NULL, HFILL }}, + { &hf_ndmp_tape_attr_rewind, { "Device supports rewind", "ndmp.tape.attr.rewind", FT_BOOLEAN, 32, TFS(&tfs_tape_attr_rewind), 0x00000001, "If this device supports rewind", HFILL }}, @@ -3803,6 +3742,10 @@ proto_register_ndmp(void) "LUN", "ndmp.scsi.lun", FT_UINT32, BASE_DEC, NULL, 0, "Target LUN", HFILL }}, + { &hf_ndmp_execute_cdb_flags, { + "Flags", "ndmp.execute_cdb.flags", FT_UINT32, BASE_HEX, + NULL, 0, NULL, HFILL }}, + { &hf_ndmp_execute_cdb_flags_data_in, { "DATA_IN", "ndmp.execute_cdb.flags.data_in", FT_BOOLEAN, 32, NULL, 0x00000001, NULL, HFILL }}, @@ -3851,6 +3794,10 @@ proto_register_ndmp(void) "Mode", "ndmp.tape.open_mode", FT_UINT32, BASE_DEC, VALS(tape_open_mode_vals), 0, "Mode to open tape in", HFILL }}, + { &hf_ndmp_tape_invalid, { + "Invalids", "ndmp.tape.invalid", FT_UINT32, BASE_HEX, + NULL, 0, NULL, HFILL }}, + { &hf_ndmp_tape_invalid_file_num, { "Invalid file num", "ndmp.tape.invalid.file_num", FT_BOOLEAN, 32, TFS(&tfs_ndmp_tape_invalid_file_num), 0x00000001, "invalid_file_num", HFILL }}, @@ -3879,6 +3826,10 @@ proto_register_ndmp(void) "Invalid partition", "ndmp.tape.invalid.partition", FT_BOOLEAN, 32, TFS(&tfs_ndmp_tape_invalid_partition), 0x00000040, "partition", HFILL }}, + { &hf_ndmp_tape_flags, { + "Flags", "ndmp.tape.flags", FT_UINT32, BASE_HEX, + NULL, 0, NULL, HFILL }}, + { &hf_ndmp_tape_flags_no_rewind, { "No rewind", "ndmp.tape.flags.no_rewind", FT_BOOLEAN, 32, TFS(&tfs_ndmp_tape_flags_no_rewind), 0x00000008, "no_rewind", HFILL, }}, @@ -4075,17 +4026,21 @@ proto_register_ndmp(void) "FH Info", "ndmp.file.fh_info", FT_UINT64, BASE_DEC, NULL, 0, "FH Info used for direct access", HFILL }}, + { &hf_ndmp_file_invalid, { + "Invalids", "ndmp.file.invalid", FT_UINT32, BASE_HEX, + VALS(file_type_vals), 0, NULL, HFILL }}, + { &hf_ndmp_file_invalid_atime, { - "Invalid atime", "ndmp.file.invalid_atime", FT_BOOLEAN, 32, - TFS(&tfs_ndmp_file_invalid_atime), 0x00000001, "invalid_atime", HFILL, }}, + "Invalid atime", "ndmp.file.invalid.atime", FT_BOOLEAN, 32, + TFS(&tfs_ndmp_file_invalid_atime), 0x00000001, NULL, HFILL, }}, { &hf_ndmp_file_invalid_ctime, { - "Invalid ctime", "ndmp.file.invalid_ctime", FT_BOOLEAN, 32, - TFS(&tfs_ndmp_file_invalid_ctime), 0x00000002, "invalid_ctime", HFILL, }}, + "Invalid ctime", "ndmp.file.invalid.ctime", FT_BOOLEAN, 32, + TFS(&tfs_ndmp_file_invalid_ctime), 0x00000002, NULL, HFILL, }}, { &hf_ndmp_file_invalid_group, { - "Invalid group", "ndmp.file.invalid_group", FT_BOOLEAN, 32, - TFS(&tfs_ndmp_file_invalid_group), 0x00000004, "invalid_group", HFILL, }}, + "Invalid group", "ndmp.file.invalid.group", FT_BOOLEAN, 32, + TFS(&tfs_ndmp_file_invalid_group), 0x00000004, NULL, HFILL, }}, { &hf_ndmp_file_mtime, { "mtime", "ndmp.file.mtime", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, @@ -4147,12 +4102,16 @@ proto_register_ndmp(void) "Other Name", "ndmp.bu.other_name", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }}, + { &hf_ndmp_state_invalid, { + "Invalids", "ndmp.bu.state.invalid", FT_UINT32, BASE_HEX, + VALS(file_type_vals), 0, NULL, HFILL }}, + { &hf_ndmp_state_invalid_ebr, { - "EstimatedBytesLeft valid", "ndmp.bu.state.invalid_ebr", FT_BOOLEAN, 32, + "EstimatedBytesLeft valid", "ndmp.bu.state.invalid.ebr", FT_BOOLEAN, 32, TFS(&tfs_ndmp_state_invalid_ebr), 0x00000001, "Whether EstimatedBytesLeft is valid or not", HFILL, }}, { &hf_ndmp_state_invalid_etr, { - "EstimatedTimeLeft valid", "ndmp.bu.state.invalid_etr", FT_BOOLEAN, 32, + "EstimatedTimeLeft valid", "ndmp.bu.state.invalid.etr", FT_BOOLEAN, 32, TFS(&tfs_ndmp_state_invalid_etr), 0x00000002, "Whether EstimatedTimeLeft is valid or not", HFILL, }}, { &hf_ndmp_bu_operation, { @@ -4202,6 +4161,9 @@ proto_register_ndmp(void) { &hf_ndmp_ex_class_version, { "Class Version", "ndmp.class.version", FT_UINT32, BASE_HEX, NULL, 0, NULL, HFILL }}, + { &hf_ndmp_fragment_data, { + "NDMP fragment data", "ndmp.fragment_data", FT_BYTES, BASE_NONE, + NULL, 0, NULL, HFILL }}, {&hf_ndmp_fragments, { "NDMP fragments", "ndmp.fragments", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } }, @@ -4259,12 +4221,19 @@ proto_register_ndmp(void) &ett_ndmp_fragments, }; + static ei_register_info ei[] = { + { &ei_ndmp_msg, { "ndmp.msg.unknown", PI_PROTOCOL, PI_WARN, "Unknown type of NDMP message", EXPFILL }}, + }; + module_t *ndmp_module; + expert_module_t* expert_ndmp; proto_ndmp = proto_register_protocol("Network Data Management Protocol", "NDMP", "ndmp"); proto_register_field_array(proto_ndmp, hf_ndmp, array_length(hf_ndmp)); proto_register_subtree_array(ett, array_length(ett)); + expert_ndmp = expert_register_protocol(proto_ndmp); + expert_register_field_array(expert_ndmp, ei, array_length(ei)); /* desegmentation */ ndmp_module = prefs_register_protocol(proto_ndmp, NULL); diff --git a/epan/dissectors/packet-ndps.c b/epan/dissectors/packet-ndps.c index d25456a510..08c036ce01 100644 --- a/epan/dissectors/packet-ndps.c +++ b/epan/dissectors/packet-ndps.c @@ -2110,113 +2110,103 @@ objectidentifier(tvbuff_t* tvb, proto_tree *ndps_tree, int foffset) label = try_val_to_str(label_value, object_ids_7); if (label==NULL) { - aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); + label = wmem_strdup(wmem_packet_scope(), "Unknown ID"); found=FALSE; - break; } - aitem = proto_tree_add_none_format(ndps_tree, hf_ndps_object_ids_7, tvb, foffset, length, "%s", label); + aitem = proto_tree_add_uint_format(ndps_tree, hf_ndps_object_ids_7, tvb, foffset, length, label_value, "%s", label); break; case 10: label_value = tvb_get_ntohl(tvb, foffset+6); label = try_val_to_str(label_value, object_ids_8); if (label==NULL) { - aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); + label = wmem_strdup(wmem_packet_scope(), "Unknown ID"); found=FALSE; - break; } - aitem = proto_tree_add_none_format(ndps_tree, hf_ndps_object_ids_8, tvb, foffset, length, "%s", label); + aitem = proto_tree_add_uint_format(ndps_tree, hf_ndps_object_ids_8, tvb, foffset, length, label_value, "%s", label); break; case 11: label_value = tvb_get_ntohl(tvb, foffset+7); label = try_val_to_str(label_value, object_ids_9); if (label==NULL) { - aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); + label = wmem_strdup(wmem_packet_scope(), "Unknown ID"); found=FALSE; - break; } - aitem = proto_tree_add_none_format(ndps_tree, hf_ndps_object_ids_9, tvb, foffset, length, "%s", label); + aitem = proto_tree_add_uint_format(ndps_tree, hf_ndps_object_ids_9, tvb, foffset, length, label_value, "%s", label); break; case 12: label_value = tvb_get_ntohl(tvb, foffset+8); label = try_val_to_str(label_value, object_ids_10); if (label==NULL) { - aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); + label = wmem_strdup(wmem_packet_scope(), "Unknown ID"); found=FALSE; - break; } - aitem = proto_tree_add_none_format(ndps_tree, hf_ndps_object_ids_10, tvb, foffset, length, "%s", label); + aitem = proto_tree_add_uint_format(ndps_tree, hf_ndps_object_ids_10, tvb, foffset, length, label_value, "%s", label); break; case 13: label_value = tvb_get_ntohl(tvb, foffset+9); label = try_val_to_str(label_value, object_ids_11); if (label==NULL) { - aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); + label = wmem_strdup(wmem_packet_scope(), "Unknown ID"); found=FALSE; - break; } - aitem = proto_tree_add_none_format(ndps_tree, hf_ndps_object_ids_11, tvb, foffset, length, "%s", label); + aitem = proto_tree_add_uint_format(ndps_tree, hf_ndps_object_ids_11, tvb, foffset, length, label_value, "%s", label); break; case 14: label_value = tvb_get_ntohl(tvb, foffset+10); label = try_val_to_str(label_value, object_ids_12); if (label==NULL) { - aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); + label = wmem_strdup(wmem_packet_scope(), "Unknown ID"); found=FALSE; - break; } - aitem = proto_tree_add_none_format(ndps_tree, hf_ndps_object_ids_12, tvb, foffset, length, "%s", label); + aitem = proto_tree_add_uint_format(ndps_tree, hf_ndps_object_ids_12, tvb, foffset, length, label_value, "%s", label); break; case 15: label_value = tvb_get_ntohl(tvb, foffset+11); label = try_val_to_str(label_value, object_ids_13); if (label==NULL) { - aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); + label = wmem_strdup(wmem_packet_scope(), "Unknown ID"); found=FALSE; - break; } - aitem = proto_tree_add_none_format(ndps_tree, hf_ndps_object_ids_13, tvb, foffset, length, "%s", label); + aitem = proto_tree_add_uint_format(ndps_tree, hf_ndps_object_ids_13, tvb, foffset, length, label_value, "%s", label); break; case 16: label_value = tvb_get_ntohl(tvb, foffset+12); label = try_val_to_str(label_value, object_ids_14); if (label==NULL) { - aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); + label = wmem_strdup(wmem_packet_scope(), "Unknown ID"); found=FALSE; - break; } - aitem = proto_tree_add_none_format(ndps_tree, hf_ndps_object_ids_14, tvb, foffset, length, "%s", label); + aitem = proto_tree_add_uint_format(ndps_tree, hf_ndps_object_ids_14, tvb, foffset, length, label_value, "%s", label); break; case 17: label_value = tvb_get_ntohl(tvb, foffset+13); label = try_val_to_str(label_value, object_ids_15); if (label==NULL) { - aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); + label = wmem_strdup(wmem_packet_scope(), "Unknown ID"); found=FALSE; - break; } - aitem = proto_tree_add_none_format(ndps_tree, hf_ndps_object_ids_15, tvb, foffset, length, "%s", label); + aitem = proto_tree_add_uint_format(ndps_tree, hf_ndps_object_ids_15, tvb, foffset, length, label_value, "%s", label); break; case 18: label_value = tvb_get_ntohl(tvb, foffset+14); label = try_val_to_str(label_value, object_ids_16); if (label==NULL) { - aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); + label = wmem_strdup(wmem_packet_scope(), "Unknown ID"); found=FALSE; - break; } - aitem = proto_tree_add_none_format(ndps_tree, hf_ndps_object_ids_16, tvb, foffset, length, "%s", label); + aitem = proto_tree_add_uint_format(ndps_tree, hf_ndps_object_ids_16, tvb, foffset, length, label_value, "%s", label); break; default: - aitem = proto_tree_add_text(ndps_tree, tvb, foffset, length, "Unknown ID"); + aitem = proto_tree_add_uint_format(ndps_tree, hf_ndps_object_ids_7, tvb, foffset, length, 1, "Unknown ID"); found=FALSE; break; } @@ -4182,7 +4172,7 @@ dissect_ndps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ndps_tree) ndps_packet_type = tvb_get_ntohl(tvb, 8); if (ndps_packet_type != 0 && ndps_packet_type != 1) { /* Packet Type */ col_set_str(pinfo->cinfo, COL_INFO, "(Continuation Data)"); - proto_tree_add_text(ndps_tree, tvb, 0, tvb_length(tvb), "Data - (%d Bytes)", tvb_length(tvb)); + proto_tree_add_bytes_format(ndps_tree, hf_ndps_data, tvb, 0, -1, NULL, "Data - (%d Bytes)", tvb_reported_length(tvb)); return; } foffset = 0; @@ -9151,7 +9141,7 @@ proto_register_ndps(void) NULL, 0x0, NULL, HFILL }}, { &hf_ndps_data, - { "[Data]", "ndps.data", FT_NONE, BASE_NONE, + { "Data", "ndps.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_get_status_flag, @@ -9429,52 +9419,52 @@ proto_register_ndps(void) { &hf_ndps_object_ids_7, { "Object ID Definition", "ndps.objectid_def7", - FT_NONE, BASE_NONE, NULL, + FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_ndps_object_ids_8, { "Object ID Definition", "ndps.objectid_def8", - FT_NONE, BASE_NONE, NULL, + FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_ndps_object_ids_9, { "Object ID Definition", "ndps.objectid_def9", - FT_NONE, BASE_NONE, NULL, + FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_ndps_object_ids_10, { "Object ID Definition", "ndps.objectid_def10", - FT_NONE, BASE_NONE, NULL, + FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_ndps_object_ids_11, { "Object ID Definition", "ndps.objectid_def11", - FT_NONE, BASE_NONE, NULL, + FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_ndps_object_ids_12, { "Object ID Definition", "ndps.objectid_def12", - FT_NONE, BASE_NONE, NULL, + FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_ndps_object_ids_13, { "Object ID Definition", "ndps.objectid_def13", - FT_NONE, BASE_NONE, NULL, + FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_ndps_object_ids_14, { "Object ID Definition", "ndps.objectid_def14", - FT_NONE, BASE_NONE, NULL, + FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_ndps_object_ids_15, { "Object ID Definition", "ndps.objectid_def15", - FT_NONE, BASE_NONE, NULL, + FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_ndps_object_ids_16, { "Object ID Definition", "ndps.objectid_def16", - FT_NONE, BASE_NONE, NULL, + FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, #if 0 diff --git a/epan/dissectors/packet-negoex.c b/epan/dissectors/packet-negoex.c index 81e3173435..b3228db219 100644 --- a/epan/dissectors/packet-negoex.c +++ b/epan/dissectors/packet-negoex.c @@ -64,6 +64,7 @@ static int hf_negoex_checksum_vector_count = -1; static int hf_negoex_checksum_vector_pad = -1; static int hf_negoex_checksum = -1; static int hf_negoex_errorcode = -1; +static int hf_negoex_data = -1; static gint ett_negoex = -1; static gint ett_negoex_msg = -1; @@ -134,7 +135,7 @@ dissect_negoex_alert_message(tvbuff_t *tvb, offset += 4; /* The rest */ - proto_tree_add_text(tree, tvb, offset, tvb_length(tvb) - offset, + proto_tree_add_bytes_format(tree, hf_negoex_data, tvb, offset, -1, NULL, "The rest of the alert message"); } @@ -485,7 +486,7 @@ dissect_negoex(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; default: - proto_tree_add_text(negoex_msg_tree, tvb, offset, message_len - 40, + proto_tree_add_bytes_format(negoex_msg_tree, hf_negoex_data, tvb, offset, message_len - 40, NULL, "The rest of the message"); } @@ -589,6 +590,9 @@ proto_register_negoex(void) { &hf_negoex_errorcode, { "ErrorCode", "negoex.errorcode", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}}, + { &hf_negoex_data, + { "Data", "negoex.data", FT_BYTES, BASE_NONE, + NULL, 0x0, NULL, HFILL}}, }; static gint *ett[] = { diff --git a/epan/dissectors/packet-netanalyzer.c b/epan/dissectors/packet-netanalyzer.c index 29132b4401..9251f8d7ae 100644 --- a/epan/dissectors/packet-netanalyzer.c +++ b/epan/dissectors/packet-netanalyzer.c @@ -138,6 +138,8 @@ static gint ett_netanalyzer_transparent = -1; static expert_field ei_netanalyzer_header_version_wrong = EI_INIT; static expert_field ei_netanalyzer_gpio_def_none = EI_INIT; static expert_field ei_netanalyzer_header_version_none = EI_INIT; +static expert_field ei_netanalyzer_transparent_frame = EI_INIT; +static expert_field ei_netanalyzer_alignment_error = EI_INIT; /* common routine for Ethernet and transparent mode */ static int @@ -193,8 +195,8 @@ dissect_netanalyzer_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) packet_status = tvb_get_guint8(tvb, 0); if (packet_status == 0) { - ti_status = proto_tree_add_uint_format(netanalyzer_header_tree, hf_netanalyzer_status, tvb, 0, 1, - packet_status, "Status: No Error"); + ti_status = proto_tree_add_uint_format_value(netanalyzer_header_tree, hf_netanalyzer_status, tvb, 0, 1, + packet_status, "No Error"); proto_item_append_text(ti, "No Error)"); } else @@ -202,8 +204,8 @@ dissect_netanalyzer_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) wmem_strbuf_t *strbuf; gboolean first = TRUE; - ti_status = proto_tree_add_uint_format(netanalyzer_header_tree, hf_netanalyzer_status, tvb, 0, 1, - packet_status, "Status: Error present (expand tree for details)"); + ti_status = proto_tree_add_uint_format_value(netanalyzer_header_tree, hf_netanalyzer_status, tvb, 0, 1, + packet_status, "Error present (expand tree for details)"); strbuf = wmem_strbuf_new_label(wmem_epan_scope()); for (idx = 0; idx < 8; idx++) { @@ -236,12 +238,12 @@ dissect_netanalyzer_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* decode transparent mode */ if (tvb_get_guint8(tvb, 1) & MSK_TRANSPARENT_MODE) { - proto_tree_add_text(netanalyzer_header_tree, tvb, 0, 4, "This frame was captured in transparent mode"); + proto_tree_add_expert(netanalyzer_header_tree, pinfo, &ei_netanalyzer_transparent_frame, tvb, 0, 4); proto_item_append_text(ti, ", Transparent Mode"); if (packet_status & MSK_ALIGN_ERR) { - proto_tree_add_text(netanalyzer_header_tree, tvb, tvb_length(tvb)-1, 1, "Displayed frame data contains additional nibble due to alignment error (upper nibble is not valid)"); + proto_tree_add_expert(netanalyzer_header_tree, pinfo, &ei_netanalyzer_alignment_error, tvb, tvb_length(tvb)-1, 1); } } } @@ -302,7 +304,6 @@ static void dissect_netanalyzer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { tvbuff_t *next_tvb; - proto_item *ti = NULL; if (tvb_length(tvb) >= 4) { @@ -317,8 +318,8 @@ dissect_netanalyzer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) else { /* something is wrong */ - ti = proto_tree_add_text(tree, tvb, 4, tvb_length(tvb)-4, "netANALYZER"); - expert_add_info(pinfo, ti, &ei_netanalyzer_header_version_none); + proto_tree_add_expert_format(tree, pinfo, &ei_netanalyzer_header_version_none, tvb, 4, -1, + "netANALYZER - No netANALYZER header found"); } } @@ -327,7 +328,6 @@ dissect_netanalyzer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) static void dissect_netanalyzer_transparent(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_item *ti = NULL; proto_tree *transparent_payload_tree = NULL; tvbuff_t *next_tvb; @@ -352,8 +352,8 @@ dissect_netanalyzer_transparent(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t else { /* something is wrong */ - ti = proto_tree_add_text(tree, tvb, 4, tvb_length(tvb)-4, "netANALYZER transparent mode"); - expert_add_info(pinfo, ti, &ei_netanalyzer_header_version_none); + proto_tree_add_expert_format(tree, pinfo, &ei_netanalyzer_header_version_none, tvb, 4, -1, + "netANALYZER transparent mode - No netANALYZER header found"); } } @@ -382,7 +382,7 @@ void proto_register_netanalyzer(void) "Actual Ethernet frame length", HFILL } }, { &hf_netanalyzer_status, - { "Frame Status", "netanalyzer.packetstatus", + { "Status", "netanalyzer.packetstatus", FT_UINT8, BASE_HEX, NULL, MSK_PACKET_STATUS, "Status of Ethernet frame", HFILL } }, @@ -438,6 +438,8 @@ void proto_register_netanalyzer(void) { &ei_netanalyzer_header_version_wrong, { "netanalyzer.header_version.wrong", PI_PROTOCOL, PI_ERROR, "Wrong netANALYZER header version", EXPFILL }}, { &ei_netanalyzer_gpio_def_none, { "netanalyzer.gpio_def_none", PI_MALFORMED, PI_ERROR, "No valid netANALYZER GPIO definition found", EXPFILL }}, { &ei_netanalyzer_header_version_none, { "netanalyzer.header_version.none", PI_MALFORMED, PI_ERROR, "No netANALYZER header found", EXPFILL }}, + { &ei_netanalyzer_transparent_frame, { "netanalyzer.transparent_frame", PI_PROTOCOL, PI_NOTE, "This frame was captured in transparent mode", EXPFILL }}, + { &ei_netanalyzer_alignment_error, { "netanalyzer.alignment_error", PI_PROTOCOL, PI_WARN, "Displayed frame data contains additional nibble due to alignment error (upper nibble is not valid)", EXPFILL }}, }; expert_module_t* expert_netanalyzer; diff --git a/epan/dissectors/packet-netlink.c b/epan/dissectors/packet-netlink.c index 14a02300bd..08bb8b44d6 100644 --- a/epan/dissectors/packet-netlink.c +++ b/epan/dissectors/packet-netlink.c @@ -112,6 +112,10 @@ static header_field_info hfi_netlink_hdr_pid NETLINK_HFI_INIT = { "Port ID", "netlink.hdr_pid", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }; +static header_field_info hfi_netlink_len NETLINK_HFI_INIT = + { "Len", "netlink.len", FT_UINT16, BASE_DEC, + NULL, 0x00, NULL, HFILL }; + static gint ett_netlink_cooked = -1; static gint ett_netlink_msghdr = -1; static gint ett_netlink_msg = -1; @@ -142,7 +146,7 @@ dissect_netlink_attributes(tvbuff_t *tvb, header_field_info *hfi_type, int ett, attr_tree = proto_tree_add_subtree(tree, tvb, offset, end_offset - offset, ett, &ti, "Attribute"); - proto_tree_add_text(attr_tree, tvb, offset, 2, "Len: %d", rta_len); + proto_tree_add_item(attr_tree, &hfi_netlink_len, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; rta_type = tvb_get_letohs(tvb, offset); diff --git a/epan/dissectors/packet-noe.c b/epan/dissectors/packet-noe.c index ad695f20e5..90f42e0f3b 100644 --- a/epan/dissectors/packet-noe.c +++ b/epan/dissectors/packet-noe.c @@ -609,6 +609,8 @@ static int hf_noe_aindx = -1; static int hf_noe_errcode = -1; static int hf_noe_value = -1; static int hf_noe_message = -1; +static int hf_noe_key_name = -1; +static int hf_noe_bonded = -1; static int hf_noe_property_item_u8 = -1; static int hf_noe_property_item_u16 = -1; static int hf_noe_property_item_u24 = -1; @@ -1122,11 +1124,11 @@ static void decode_evt(proto_tree *tree, proto_item_append_text(tree, ", %s", key_name); - proto_tree_add_text(tree, + proto_tree_add_string_format_value(tree, hf_noe_key_name, tvb, offset, - length, - "Key Name: %s (UTF-8 Value: %s, Unicode Value: 0x%" G_GINT64_MODIFIER "x)", + length, key_name, + "%s (UTF-8 Value: %s, Unicode Value: 0x%" G_GINT64_MODIFIER "x)", key_name, tvb_bytes_to_ep_str(tvb, offset, length), unicode_value); @@ -1160,21 +1162,15 @@ static void decode_evt(proto_tree *tree, offset += 2; /*length -= 2;*/ - /* XXX - should a 16-bit value be gotten if the size is only 8-bit? */ - proto_tree_add_text(tree, - tvb, - offset, - 1, - "Bonded: %d", - tvb_get_ntohs(tvb, offset)); + proto_tree_add_item(tree, hf_noe_bonded, tvb, offset, 1, ENC_NA); offset += 1; /*length -= 1;*/ - proto_tree_add_text(tree, + proto_tree_add_uint_format_value(tree, hf_noe_value, tvb, offset, - 1, - "Value: %d", + 1, tvb_get_ntohs(tvb, offset), + "%d", tvb_get_ntohs(tvb, offset)); break; } @@ -1620,6 +1616,30 @@ void proto_register_noe(void) HFILL } }, + { &hf_noe_bonded, + { + "Bonded", + "noe.bonded", + FT_UINT8, + BASE_DEC, + NULL, + 0x0, + NULL, + HFILL + } + }, + { &hf_noe_key_name, + { + "Key name", + "noe.keyname", + FT_STRING, + BASE_NONE, + NULL, + 0x0, + NULL, + HFILL + } + }, }; static gint *ett[] = diff --git a/epan/dissectors/packet-nt-tpcp.c b/epan/dissectors/packet-nt-tpcp.c index 2a21060159..4d03c3ccc4 100644 --- a/epan/dissectors/packet-nt-tpcp.c +++ b/epan/dissectors/packet-nt-tpcp.c @@ -1,4 +1,4 @@ -/* packet-tpcp.c +/* packet-nt-tpcp.c * Routines for Transparent Proxy Cache Protocol packet disassembly * (c) Copyright Giles Scott <giles.scott1 [AT] btinternet.com> * @@ -83,6 +83,7 @@ static const value_string type_vals[] = { /* things we can do filters on */ static int hf_tpcp_version = -1; static int hf_tpcp_type = -1; +static int hf_tpcp_flags = -1; static int hf_tpcp_flags_tcp = -1; static int hf_tpcp_flags_redir = -1; static int hf_tpcp_flags_xon = -1; @@ -93,6 +94,7 @@ static int hf_tpcp_caddr = -1; static int hf_tpcp_saddr = -1; static int hf_tpcp_vaddr = -1; static int hf_tpcp_rasaddr = -1; +static int hf_tpcp_signature = -1; static int proto_tpcp = -1; @@ -100,78 +102,74 @@ static gint ett_tpcp = -1; static gint ett_tpcp_flags = -1; -static void -dissect_tpcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static int +dissect_tpcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { - tpcpdu_t tpcph; - proto_tree *tpcp_tree = NULL, *field_tree = NULL; - proto_item *ti, *tf; - guint8 length = TPCP_VER_1_LENGTH; + proto_tree *tpcp_tree = NULL; + proto_item *ti; + guint8 version, type; + guint16 id, cport; + guint32 caddr, saddr; + + static const int * tpcp_flags[] = { + &hf_tpcp_flags_tcp, + &hf_tpcp_flags_redir, + &hf_tpcp_flags_xon, + &hf_tpcp_flags_xoff, + NULL + }; col_set_str(pinfo->cinfo, COL_PROTOCOL, "TPCP"); col_clear(pinfo->cinfo, COL_INFO); /* need to find out which version!! */ - tpcph.version = tvb_get_guint8(tvb, 0); - /* as version 1 and 2 are so similar use the same structure, just don't use as much for version 1*/ - /* XXX: Doing a memcpy into a struct is *not* kosher */ - if (tpcph.version == TPCP_VER_1) { - length = TPCP_VER_1_LENGTH; - tvb_memcpy(tvb, (guint8 *) &tpcph, 0, length); - } else if (tpcph.version == TPCP_VER_2){ - length = TPCP_VER_2_LENGTH; - tvb_memcpy(tvb, (guint8 *) &tpcph, 0, length); - } else { - memset (&tpcph, 0, sizeof (tpcph)); + version = tvb_get_guint8(tvb, 0); + if ((version != TPCP_VER_1) && (version != TPCP_VER_2)) { + /* Not us */ + return 0; } - - tpcph.id = g_ntohs(tpcph.id); - tpcph.flags = g_ntohs(tpcph.flags); - tpcph.cport = g_ntohs(tpcph.cport); - tpcph.signature = g_ntohl(tpcph.signature); - - col_add_fstr(pinfo->cinfo, COL_INFO,"%s id %d CPort %s CIP %s SIP %s", - val_to_str_const(tpcph.type, type_vals, "Unknown"), - tpcph.id, - ep_udp_port_to_display(tpcph.cport), - ip_to_str((guint8 *)&tpcph.caddr), - ip_to_str((guint8 *)&tpcph.saddr)); - - if (tree) { - ti = proto_tree_add_protocol_format(tree, proto_tpcp, tvb, 0, length, + ti = proto_tree_add_protocol_format(tree, proto_tpcp, tvb, 0, -1, "Alteon WebSystems - Transparent Proxy Cache Protocol"); tpcp_tree = proto_item_add_subtree(ti, ett_tpcp); - proto_tree_add_uint(tpcp_tree, hf_tpcp_version, tvb, 0, 1, tpcph.version); - proto_tree_add_uint(tpcp_tree, hf_tpcp_type, tvb, 1, 1, tpcph.type); + proto_tree_add_item(tpcp_tree, hf_tpcp_version, tvb, 0, 1, ENC_NA); + type = tvb_get_guint8(tvb, 1); + proto_tree_add_item(tpcp_tree, hf_tpcp_type, tvb, 1, 1, ENC_NA); - /* flags next , i'll do that when I can work out how to do it :-( */ - tf = proto_tree_add_text(tpcp_tree, tvb, 2, 2, "Flags: 0x%04x",tpcph.flags); + proto_tree_add_bitmask(tpcp_tree, tvb, 2, hf_tpcp_flags, ett_tpcp_flags, tpcp_flags, ENC_NA); - field_tree = proto_item_add_subtree(tf, ett_tpcp_flags); - proto_tree_add_boolean(field_tree, hf_tpcp_flags_tcp, tvb, 2, 2, tpcph.flags); - proto_tree_add_boolean(field_tree, hf_tpcp_flags_redir, tvb, 2,2, tpcph.flags); - proto_tree_add_boolean(field_tree, hf_tpcp_flags_xon, tvb, 2, 2, tpcph.flags); - proto_tree_add_boolean(field_tree, hf_tpcp_flags_xoff, tvb, 2, 2, tpcph.flags); + id = tvb_get_ntohs(tvb, 4); + proto_tree_add_item(tpcp_tree, hf_tpcp_id, tvb, 4, 2, ENC_BIG_ENDIAN); - proto_tree_add_uint(tpcp_tree, hf_tpcp_id, tvb, 4, 2, tpcph.id); + cport = tvb_get_ntohs(tvb, 6); + proto_tree_add_uint_format_value(tpcp_tree, hf_tpcp_cport, tvb, 6, 2, cport, + "%s", ep_udp_port_to_display(cport)); - proto_tree_add_uint_format_value(tpcp_tree, hf_tpcp_cport, tvb, 6, 2, tpcph.cport, - "%s", ep_udp_port_to_display(tpcph.cport)); + caddr = tvb_get_ntohl(tvb, 8); + proto_tree_add_item(tpcp_tree, hf_tpcp_caddr, tvb, 8, 4, ENC_BIG_ENDIAN); - proto_tree_add_ipv4(tpcp_tree, hf_tpcp_caddr, tvb, 8, 4, tpcph.caddr); + saddr = tvb_get_ntohl(tvb, 12); + proto_tree_add_item(tpcp_tree, hf_tpcp_saddr, tvb, 12, 4, ENC_BIG_ENDIAN); - proto_tree_add_ipv4(tpcp_tree, hf_tpcp_saddr, tvb, 12, 4, tpcph.saddr); - - if (tpcph.version == TPCP_VER_2) { - proto_tree_add_ipv4(tpcp_tree, hf_tpcp_vaddr, tvb, 16, 4, tpcph.vaddr); - proto_tree_add_ipv4(tpcp_tree, hf_tpcp_rasaddr, tvb, 20, 4, tpcph.rasaddr); - proto_tree_add_text(tpcp_tree, tvb, 24, 4, "Signature: %u", tpcph.signature); + if (version == TPCP_VER_2) { + proto_tree_add_item(tpcp_tree, hf_tpcp_vaddr, tvb, 16, 4, ENC_BIG_ENDIAN); + proto_tree_add_item(tpcp_tree, hf_tpcp_rasaddr, tvb, 20, 4, ENC_BIG_ENDIAN); + proto_tree_add_item(tpcp_tree, hf_tpcp_signature, tvb, 24, 4, ENC_BIG_ENDIAN); } - } + col_add_fstr(pinfo->cinfo, COL_INFO,"%s id %d CPort %s CIP %s SIP %s", + val_to_str_const(type, type_vals, "Unknown"), + id, + ep_udp_port_to_display(cport), + ip_to_str((guint8 *)&caddr), + ip_to_str((guint8 *)&saddr)); + + if (version == TPCP_VER_1) + return TPCP_VER_1_LENGTH; + + return TPCP_VER_2_LENGTH; } void @@ -186,6 +184,10 @@ proto_register_tpcp(void) { "Type", "tpcp.type", FT_UINT8, BASE_DEC, VALS(type_vals), 0x0, "PDU type", HFILL }}, + { &hf_tpcp_flags, + { "Flags", "tpcp.flags", FT_UINT16, BASE_HEX, NULL, 0x0, + NULL, HFILL }}, + { &hf_tpcp_flags_tcp, { "UDP/TCP", "tpcp.flags.tcp", FT_BOOLEAN, 8, TFS(&tfs_set_notset), TF_TPCP_UDPTCP, "Protocol type", HFILL }}, @@ -226,6 +228,9 @@ proto_register_tpcp(void) { "RAS server IP address", "tpcp.rasaddr", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_tpcp_signature, + { "Signature", "tpcp.signature", FT_UINT32, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, }; @@ -245,6 +250,6 @@ proto_reg_handoff_tpcp(void) { dissector_handle_t tpcp_handle; - tpcp_handle = create_dissector_handle(dissect_tpcp, proto_tpcp); + tpcp_handle = new_create_dissector_handle(dissect_tpcp, proto_tpcp); dissector_add_uint("udp.port", UDP_PORT_TPCP, tpcp_handle); } diff --git a/epan/dissectors/packet-ntlmssp.c b/epan/dissectors/packet-ntlmssp.c index 4af0f2abf7..9ad86796ce 100644 --- a/epan/dissectors/packet-ntlmssp.c +++ b/epan/dissectors/packet-ntlmssp.c @@ -271,6 +271,7 @@ static gint ett_ntlmssp_ntlmv2_response_item = -1; static expert_field ei_ntlmssp_v2_key_too_long = EI_INIT; static expert_field ei_ntlmssp_blob_len_too_long = EI_INIT; static expert_field ei_ntlmssp_target_info_attr = EI_INIT; +static expert_field ei_ntlmssp_message_type = EI_INIT; /* Configuration variables */ const char *gbl_nt_password = NULL; @@ -961,9 +962,7 @@ dissect_ntlmssp_blob (tvbuff_t *tvb, packet_info *pinfo, if (0 == blob_length) { *end = (blob_offset > ((guint)offset)+8 ? blob_offset : ((guint)offset)+8); - if (ntlmssp_tree) - proto_tree_add_text(ntlmssp_tree, tvb, offset, 8, "%s: Empty", - proto_registrar_get_name(blob_hf)); + proto_tree_add_bytes_format_value(ntlmssp_tree, blob_hf, tvb, offset, 8, NULL, "Empty"); result->length = 0; result->contents = NULL; return offset+8; @@ -1450,8 +1449,7 @@ dissect_ntlmssp_challenge_target_info_blob (packet_info *pinfo, tvbuff_t *tvb, i /* the target info list is just a blob */ if (0 == challenge_target_info_length) { *end = (challenge_target_info_offset > ((guint)offset)+8 ? challenge_target_info_offset : ((guint)offset)+8); - if (ntlmssp_tree) - proto_tree_add_text(ntlmssp_tree, tvb, offset, 8, + proto_tree_add_none_format(ntlmssp_tree, hf_ntlmssp_challenge_target_info, tvb, offset, 8, "Target Info List: Empty"); return offset+8; } @@ -2138,7 +2136,7 @@ dissect_ntlmssp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { volatile int offset = 0; proto_tree *volatile ntlmssp_tree = NULL; - proto_item *tf = NULL; + proto_item *tf, *type_item; ntlmssp_header_t *ntlmssph; void *pd_save; @@ -2150,14 +2148,11 @@ dissect_ntlmssp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) memset(ntlmssph->session_key, 0, NTLMSSP_KEY_LEN); /* Setup a new tree for the NTLMSSP payload */ - if (tree) { - tf = proto_tree_add_item (tree, + tf = proto_tree_add_item (tree, proto_ntlmssp, tvb, offset, -1, ENC_NA); - ntlmssp_tree = proto_item_add_subtree (tf, - ett_ntlmssp); - } + ntlmssp_tree = proto_item_add_subtree (tf, ett_ntlmssp); /* * Catch the ReportedBoundsError exception; the stuff we've been @@ -2179,7 +2174,7 @@ dissect_ntlmssp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) offset += 8; /* NTLMSSP Message Type */ - proto_tree_add_item (ntlmssp_tree, hf_ntlmssp_message_type, + type_item = proto_tree_add_item (ntlmssp_tree, hf_ntlmssp_message_type, tvb, offset, 4, ENC_LITTLE_ENDIAN); ntlmssph->type = tvb_get_letohl (tvb, offset); offset += 4; @@ -2206,8 +2201,7 @@ dissect_ntlmssp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) default: /* Unrecognized message type */ - proto_tree_add_text (ntlmssp_tree, tvb, offset, -1, - "Unrecognized NTLMSSP Message"); + expert_add_info(pinfo, type_item, &ei_ntlmssp_message_type); break; } } CATCH_NONFATAL_ERRORS { @@ -3325,6 +3319,7 @@ proto_register_ntlmssp(void) { &ei_ntlmssp_v2_key_too_long, { "ntlmssp.v2_key_too_long", PI_UNDECODED, PI_WARN, "NTLM v2 key is too long", EXPFILL }}, { &ei_ntlmssp_blob_len_too_long, { "ntlmssp.blob.length.too_long", PI_UNDECODED, PI_WARN, "Session blob length too long", EXPFILL }}, { &ei_ntlmssp_target_info_attr, { "ntlmssp.target_info_attr.unknown", PI_UNDECODED, PI_WARN, "unknown NTLMSSP Target Info Attribute", EXPFILL }}, + { &ei_ntlmssp_message_type, { "ntlmssp.messagetype.unknown", PI_PROTOCOL, PI_WARN, "Unrecognized NTLMSSP Message", EXPFILL }}, }; module_t *ntlmssp_module; expert_module_t* expert_ntlmssp; diff --git a/epan/dissectors/packet-ntp.c b/epan/dissectors/packet-ntp.c index 9a4753b0ce..1632c903ea 100644 --- a/epan/dissectors/packet-ntp.c +++ b/epan/dissectors/packet-ntp.c @@ -30,6 +30,7 @@ #include <glib.h> #include <epan/packet.h> +#include <epan/expert.h> #include <epan/addr_resolv.h> #include <epan/wmem/wmem.h> @@ -580,10 +581,14 @@ static gint ett_ntpctrl_item = -1; static gint ett_ntppriv_auth_seq = -1; static gint ett_monlist_item = -1; -static void dissect_ntp_std (tvbuff_t *, proto_tree *, guint8); -static void dissect_ntp_ctrl(tvbuff_t *, proto_tree *, guint8); -static void dissect_ntp_priv(tvbuff_t *, proto_tree *, guint8); -static int dissect_ntp_ext (tvbuff_t *, proto_tree *, int); +static expert_field ei_ntp_ext = EI_INIT; + + + +static void dissect_ntp_std (tvbuff_t *, packet_info *, proto_tree *, guint8); +static void dissect_ntp_ctrl(tvbuff_t *, packet_info *, proto_tree *, guint8); +static void dissect_ntp_priv(tvbuff_t *, packet_info *, proto_tree *, guint8); +static int dissect_ntp_ext (tvbuff_t *, packet_info *, proto_tree *, int); static const char *mon_names[12] = { "Jan", @@ -732,7 +737,7 @@ dissect_ntp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree *ntp_tree; proto_item *ti = NULL; guint8 flags; - void (*dissector)(tvbuff_t *, proto_item *, guint8); + void (*dissector)(tvbuff_t *, packet_info *, proto_item *, guint8); col_set_str(pinfo->cinfo, COL_PROTOCOL, "NTP"); @@ -767,11 +772,11 @@ dissect_ntp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) val_to_str_const(flags & NTP_MODE_MASK, info_mode_types, "Unknown")); /* Dissect according to mode */ - (*dissector)(tvb, ntp_tree, flags); + (*dissector)(tvb, pinfo, ntp_tree, flags); } static void -dissect_ntp_std(tvbuff_t *tvb, proto_tree *ntp_tree, guint8 flags) +dissect_ntp_std(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree, guint8 flags) { proto_tree *flags_tree; proto_item *tf; @@ -919,7 +924,7 @@ dissect_ntp_std(tvbuff_t *tvb, proto_tree *ntp_tree, guint8 flags) */ macofs = 48; while (tvb_reported_length_remaining(tvb, macofs) > (gint)MAX_MAC_LEN) - macofs = dissect_ntp_ext(tvb, ntp_tree, macofs); + macofs = dissect_ntp_ext(tvb, pinfo, ntp_tree, macofs); /* When the NTP authentication scheme is implemented, the * Key Identifier and Message Digest fields contain the @@ -937,43 +942,39 @@ dissect_ntp_std(tvbuff_t *tvb, proto_tree *ntp_tree, guint8 flags) } static int -dissect_ntp_ext(tvbuff_t *tvb, proto_tree *ntp_tree, int offset) +dissect_ntp_ext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree, int offset) { proto_tree *ext_tree, *flags_tree; - proto_item *tf; + proto_item *tf, *ext_item; guint16 extlen; int endoffset; guint8 flags; guint32 vallen, vallen_round, siglen; extlen = tvb_get_ntohs(tvb, offset+2); + tf = proto_tree_add_item(ntp_tree, hf_ntp_ext, tvb, offset, extlen, + ENC_NA); + ext_tree = proto_item_add_subtree(tf, ett_ntp_ext); + if (extlen < 8) { /* Extension length isn't enough for the extension header. * Report the error, and return an offset that goes to * the end of the tvbuff, so we stop dissecting. */ - proto_tree_add_text(ntp_tree, tvb, offset+2, 2, - "Extension length %u < 8", extlen); - offset += tvb_length_remaining(tvb, offset); - return offset; + expert_add_info_format(pinfo, tf, &ei_ntp_ext, "Extension length %u < 8", extlen); + return tvb_reported_length(tvb); } if (extlen % 4) { /* Extension length isn't a multiple of 4. * Report the error, and return an offset that goes * to the end of the tvbuff, so we stop dissecting. */ - proto_tree_add_text(ntp_tree, tvb, offset+2, 2, - "Extension length %u isn't a multiple of 4", + expert_add_info_format(pinfo, tf, &ei_ntp_ext, "Extension length %u isn't a multiple of 4", extlen); - offset += tvb_length_remaining(tvb, offset); - return offset; + return tvb_reported_length(tvb); } endoffset = offset + extlen; - tf = proto_tree_add_item(ntp_tree, hf_ntp_ext, tvb, offset, extlen, - ENC_NA); - ext_tree = proto_item_add_subtree(tf, ett_ntp_ext); - flags = tvb_get_guint8(tvb, offset); tf = proto_tree_add_uint(ext_tree, hf_ntp_ext_flags, tvb, offset, 1, flags); @@ -1016,7 +1017,7 @@ dissect_ntp_ext(tvbuff_t *tvb, proto_tree *ntp_tree, int offset) /* XXX fstamp can be server flags */ vallen = tvb_get_ntohl(tvb, offset); - proto_tree_add_uint(ext_tree, hf_ntp_ext_vallen, tvb, offset, 4, + ext_item = proto_tree_add_uint(ext_tree, hf_ntp_ext_vallen, tvb, offset, 4, vallen); offset += 4; vallen_round = (vallen + 3) & (-4); @@ -1026,8 +1027,7 @@ dissect_ntp_ext(tvbuff_t *tvb, proto_tree *ntp_tree, int offset) * Value goes past the length of the extension * field. */ - proto_tree_add_text(ext_tree, tvb, offset, - endoffset - offset, + expert_add_info_format(pinfo, ext_item, &ei_ntp_ext, "Value length makes value go past the end of the extension field"); return endoffset; } @@ -1037,7 +1037,7 @@ dissect_ntp_ext(tvbuff_t *tvb, proto_tree *ntp_tree, int offset) offset += vallen_round; siglen = tvb_get_ntohl(tvb, offset); - proto_tree_add_uint(ext_tree, hf_ntp_ext_siglen, tvb, offset, 4, + ext_item = proto_tree_add_uint(ext_tree, hf_ntp_ext_siglen, tvb, offset, 4, siglen); offset += 4; if (siglen != 0) { @@ -1046,8 +1046,7 @@ dissect_ntp_ext(tvbuff_t *tvb, proto_tree *ntp_tree, int offset) * Value goes past the length of the extension * field. */ - proto_tree_add_text(ext_tree, tvb, offset, - endoffset - offset, + expert_add_info_format(pinfo, ext_item, &ei_ntp_ext, "Signature length makes value go past the end of the extension field"); return endoffset; } @@ -1125,7 +1124,7 @@ dissect_ntp_ctrl_clockstatus(tvbuff_t *tvb, proto_tree *status_tree, guint16 off } static void -dissect_ntp_ctrl(tvbuff_t *tvb, proto_tree *ntp_tree, guint8 flags) +dissect_ntp_ctrl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ntp_tree, guint8 flags) { proto_tree *flags_tree; proto_item *tf; @@ -1286,7 +1285,7 @@ init_parser(void) } static void -dissect_ntp_priv(tvbuff_t *tvb, proto_tree *ntp_tree, guint8 flags) +dissect_ntp_priv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ntp_tree, guint8 flags) { proto_tree *flags_tree; proto_item *tf; @@ -1359,8 +1358,8 @@ dissect_ntp_priv(tvbuff_t *tvb, proto_tree *ntp_tree, guint8 flags) proto_tree_add_boolean(monlist_item_tree, hf_ntppriv_v6_flag, tvb, offset + 32, 4, v6_flag); if (v6_flag != 0) { - proto_tree_add_item(monlist_item_tree, hf_ntppriv_addr6, tvb, offset + 36, 16, ENC_BIG_ENDIAN); - proto_tree_add_item(monlist_item_tree, hf_ntppriv_daddr6, tvb, offset + 52, 16, ENC_BIG_ENDIAN); + proto_tree_add_item(monlist_item_tree, hf_ntppriv_addr6, tvb, offset + 36, 16, ENC_NA); + proto_tree_add_item(monlist_item_tree, hf_ntppriv_daddr6, tvb, offset + 52, 16, ENC_NA); } } } @@ -1636,10 +1635,18 @@ proto_register_ntp(void) &ett_monlist_item }; + static ei_register_info ei[] = { + { &ei_ntp_ext, { "ntp.ext.invalid_length", PI_PROTOCOL, PI_WARN, "Extension invalid length", EXPFILL }}, + }; + + expert_module_t* expert_ntp; + proto_ntp = proto_register_protocol("Network Time Protocol", "NTP", "ntp"); proto_register_field_array(proto_ntp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_ntp = expert_register_protocol(proto_ntp); + expert_register_field_array(expert_ntp, ei, array_length(ei)); init_parser(); } diff --git a/epan/dissectors/packet-openflow.c b/epan/dissectors/packet-openflow.c index d98b6b85fa..3d8d87965d 100644 --- a/epan/dissectors/packet-openflow.c +++ b/epan/dissectors/packet-openflow.c @@ -29,6 +29,7 @@ #include <glib.h> #include <epan/packet.h> +#include <epan/expert.h> #include <epan/prefs.h> #include "packet-tcp.h" @@ -51,6 +52,8 @@ static dissector_handle_t openflow_v5_handle; static int proto_openflow = -1; static int hf_openflow_version = -1; +static expert_field ei_openflow_version = EI_INIT; + static gboolean openflow_desegment = TRUE; #define OFP_VERSION_1_0 1 @@ -79,6 +82,7 @@ dissect_openflow_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo { guint offset = 0; guint8 version; + proto_item* ti; version = tvb_get_guint8(tvb, 0); /* Set the Protocol column to the constant string of openflow */ @@ -96,8 +100,8 @@ dissect_openflow_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo call_dissector(openflow_v5_handle, tvb, pinfo, tree); break; default: - proto_tree_add_item(tree, hf_openflow_version, tvb, offset, 1, ENC_BIG_ENDIAN); - proto_tree_add_text(tree, tvb, offset, -1, "Unsuported version not dissected"); + ti = proto_tree_add_item(tree, hf_openflow_version, tvb, offset, 1, ENC_BIG_ENDIAN); + expert_add_info(pinfo, ti, &ei_openflow_version); break; } return tvb_reported_length(tvb); @@ -150,7 +154,12 @@ proto_register_openflow(void) } }; + static ei_register_info ei[] = { + { &ei_openflow_version, { "openflow.version.unknown", PI_UNDECODED, PI_WARN, "Unsupported version not dissected", EXPFILL }}, + }; + module_t *openflow_module; + expert_module_t* expert_openflow; /* Register the protocol name and description */ proto_openflow = proto_register_protocol("OpenFlow", @@ -160,6 +169,8 @@ proto_register_openflow(void) /* Required function calls to register the header fields and subtrees */ proto_register_field_array(proto_openflow, hf, array_length(hf)); + expert_openflow = expert_register_protocol(proto_openflow); + expert_register_field_array(expert_openflow, ei, array_length(ei)); openflow_module = prefs_register_protocol(proto_openflow, proto_reg_handoff_openflow); diff --git a/epan/dissectors/packet-openflow_v1.c b/epan/dissectors/packet-openflow_v1.c index 2b93a773b1..40600ece0e 100644 --- a/epan/dissectors/packet-openflow_v1.c +++ b/epan/dissectors/packet-openflow_v1.c @@ -29,6 +29,7 @@ #include <glib.h> #include <epan/packet.h> +#include <epan/expert.h> void proto_register_openflow_v1(void); void proto_reg_handoff_openflow_v1(void); @@ -149,6 +150,10 @@ static gint ett_openflow_port_cnf = -1; static gint ett_openflow_port_state = -1; static gint ett_openflow_port_cf = -1; +static expert_field ei_openflow_undecoded_data = EI_INIT; +static expert_field ei_openflow_action_type = EI_INIT; +static expert_field ei_openflow_1_0_type = EI_INIT; + static const value_string openflow_version_values[] = { { 0x01, "1.0" }, { 0, NULL } @@ -288,7 +293,7 @@ static const value_string openflow_1_0_type_values[] = { #define OFPAT_VENDOR 0xffff static int -dissect_openflow_ofp_match_v1(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset) +dissect_openflow_ofp_match_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) { /* uint32_t wildcards; Wildcard fields. */ @@ -323,7 +328,7 @@ dissect_openflow_ofp_match_v1(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree /* uint32_t nw_dst; IP destination address. */ /* uint16_t tp_src; TCP/UDP source port. */ /* uint16_t tp_dst; TCP/UDP destination port. */ - proto_tree_add_text(tree, tvb, offset, 18, "Data not dissected yet"); + proto_tree_add_expert(tree, pinfo, &ei_openflow_undecoded_data, tvb, offset, 18); offset +=18; return offset; @@ -349,10 +354,11 @@ static int dissect_openflow_action_header(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset) { guint16 action_type, action_len; + proto_item* ti; /* uint16_t type; One of OFPAT_*. */ action_type = tvb_get_ntohs(tvb, offset); - proto_tree_add_item(tree, hf_openflow_action_type, tvb, offset, 2, ENC_BIG_ENDIAN); + ti = proto_tree_add_item(tree, hf_openflow_action_type, tvb, offset, 2, ENC_BIG_ENDIAN); offset+=2; /* Length of action, including this * header. This is the length of action, @@ -373,7 +379,7 @@ dissect_openflow_action_header(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree offset+=2; break; default: - proto_tree_add_text(tree, tvb, offset, action_len-4, "Action not dissected yet"); + expert_add_info(pinfo, ti, &ei_openflow_action_type); offset+=(action_len-4); break; } @@ -603,7 +609,6 @@ dissect_openflow_pkt_in(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_tree_add_item(tree, hf_openflow_padd8, tvb, offset, 1, ENC_BIG_ENDIAN); offset+=1; - /*proto_tree_add_text(tree, tvb, offset, length-offset, "Offset=%u, remaining %u", offset, length-offset);*/ next_tvb = tvb_new_subset_length(tvb, offset, length-offset); call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree); @@ -635,7 +640,6 @@ dissect_openflow_pkt_out(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree (Only meaningful if buffer_id == -1.) */ if(buffer_id == -1){ - /* proto_tree_add_text(tree, tvb, offset, -1, "Packet data"); */ next_tvb = tvb_new_subset_length(tvb, offset, length-offset); call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree); } @@ -700,7 +704,7 @@ dissect_openflow_flow_mod(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, i static int dissect_openflow_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - proto_item *ti; + proto_item *ti, *type_item; proto_tree *openflow_tree; guint offset = 0; guint8 type; @@ -726,7 +730,7 @@ dissect_openflow_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d offset++; /* One of the OFPT_ constants. */ - proto_tree_add_item(openflow_tree, hf_openflow_1_0_type, tvb, offset, 1, ENC_BIG_ENDIAN); + type_item = proto_tree_add_item(openflow_tree, hf_openflow_1_0_type, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; /* Length including this ofp_header. */ @@ -774,7 +778,7 @@ dissect_openflow_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d break; default: if(length>8){ - proto_tree_add_text(tree, tvb, offset, -1, "Message data not dissected yet"); + expert_add_info(pinfo, type_item, &ei_openflow_1_0_type); } break; } @@ -1275,6 +1279,14 @@ proto_register_openflow_v1(void) &ett_openflow_port_cf }; + static ei_register_info ei[] = { + { &ei_openflow_undecoded_data, { "openflow.undecoded_data", PI_UNDECODED, PI_WARN, "Data not dissected yet", EXPFILL }}, + { &ei_openflow_action_type, { "openflow.action_typ.undecoded", PI_UNDECODED, PI_WARN, "Action not dissected yet", EXPFILL }}, + { &ei_openflow_1_0_type, { "openflow_1_0.type.undecoded", PI_UNDECODED, PI_WARN, "Message data not dissected yet", EXPFILL }}, + }; + + expert_module_t* expert_openflow_v1; + /* Register the protocol name and description */ proto_openflow_v1 = proto_register_protocol("OpenFlow 1.0", "openflow_v1", "openflow_v1"); @@ -1286,6 +1298,8 @@ proto_register_openflow_v1(void) /* Required function calls to register the header fields and subtrees */ proto_register_field_array(proto_openflow_v1, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_openflow_v1 = expert_register_protocol(proto_openflow_v1); + expert_register_field_array(expert_openflow_v1, ei, array_length(ei)); } /* |