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/dissectors/packet-nbipx.c | |
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/dissectors/packet-nbipx.c')
-rw-r--r-- | epan/dissectors/packet-nbipx.c | 127 |
1 files changed, 68 insertions, 59 deletions
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); } |