diff --git a/epan/address_to_str.c b/epan/address_to_str.c index ac3be78b5a..de02c5dc4d 100644 --- a/epan/address_to_str.c +++ b/epan/address_to_str.c @@ -288,14 +288,6 @@ ipx_addr_to_str(const guint32 net, const guint8 *ad) return buf; } -gchar* -ipxnet_to_string(const guint8 *ad) -{ - guint32 addr = pntoh32(ad); - return ipxnet_to_str_punct(addr, ' '); -} - - gchar* tvb_ipxnet_to_string(tvbuff_t *tvb, const gint offset) { diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c index 4ce7fc211f..e3996c923b 100644 --- a/epan/dissectors/packet-ipx.c +++ b/epan/dissectors/packet-ipx.c @@ -100,6 +100,7 @@ static int hf_spx_ack_nr = -1; static int hf_spx_all_nr = -1; static int hf_spx_neg_size = -1; static int hf_spx_rexmt_frame = -1; +static int hf_spx_rexmt_data = -1; static gint ett_spx = -1; static gint ett_spx_connctrl = -1; @@ -107,16 +108,28 @@ static gint ett_spx_connctrl = -1; static int proto_ipxrip = -1; static int hf_ipxrip_request = -1; static int hf_ipxrip_response = -1; +static int hf_ipxrip_packet_type = -1; +static int hf_ipxrip_route_vector = -1; +static int hf_ipxrip_hops = -1; +static int hf_ipxrip_ticks = -1; static gint ett_ipxrip = -1; static int proto_serialization = -1; - +static int hf_serial_number = -1; static gint ett_serialization = -1; static int proto_sap = -1; static int hf_sap_request = -1; static int hf_sap_response = -1; +/* Generated from convert_proto_tree_add_text.pl */ +static int hf_sap_intermediate_networks = -1; +static int hf_sap_server_type = -1; +static int hf_sap_packet_type = -1; +static int hf_sap_node = -1; +static int hf_sap_network = -1; +static int hf_sap_server_name = -1; +static int hf_sap_socket = -1; static gint ett_ipxsap = -1; static gint ett_ipxsap_server = -1; @@ -245,12 +258,6 @@ static const value_string ipx_socket_vals[] = { value_string_ext ipx_socket_vals_ext = VALUE_STRING_EXT_INIT(ipx_socket_vals); -static const char* -socket_text(guint16 socket) -{ - return val_to_str_ext_const(socket, &ipx_socket_vals_ext, "Unknown"); -} - static const value_string ipx_packet_type_vals[] = { { IPX_PACKET_TYPE_IPX, "IPX" }, { IPX_PACKET_TYPE_RIP, "RIP" }, @@ -341,8 +348,7 @@ dissect_ipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) SET_ADDRESS(&pinfo->dst, AT_IPX, 10, dst_net_node); SET_ADDRESS(&ipxh->ipx_dst, AT_IPX, 10, dst_net_node); - col_add_fstr(pinfo->cinfo, COL_INFO, "%s (0x%04x)", - socket_text(ipxh->ipx_dsocket), ipxh->ipx_dsocket); + col_add_str(pinfo->cinfo, COL_INFO, val_to_str_ext(ipxh->ipx_dsocket, &ipx_socket_vals_ext, "Unknown (0x%04x)")); if (tree) { @@ -842,9 +848,7 @@ dissect_spx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) "This is a retransmission of frame %u", spx_rexmit_info_p->num); if (tvb_length_remaining(tvb, hdr_len) > 0) { - proto_tree_add_text(spx_tree, tvb, - hdr_len, -1, - "Retransmitted data"); + proto_tree_add_item(spx_tree, hf_spx_rexmt_data, tvb, hdr_len, -1, ENC_NA); } } return; @@ -928,70 +932,63 @@ dissect_ipxmsg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* ================================================================= */ /* IPX RIP */ /* ================================================================= */ +static const value_string ipxrip_packet_vals[] = { + { IPX_RIP_REQUEST, "Request"}, + { IPX_RIP_RESPONSE, "Response"}, + { 0, NULL} +}; + static void dissect_ipxrip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_tree *rip_tree; proto_item *ti, *hidden_item; - guint16 operation; - ipx_rt_def_t route; + guint16 operation, ticks; int cursor; int available_length; - static const char *rip_type[3] = { "Request", "Response", "Unknown" }; - col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPX RIP"); col_clear(pinfo->cinfo, COL_INFO); - operation = tvb_get_ntohs(tvb, 0) - 1; + operation = tvb_get_ntohs(tvb, 0); /* rip_types 0 and 1 are valid, anything else becomes 2 or "Unknown" */ - col_set_str(pinfo->cinfo, COL_INFO, rip_type[MIN(operation, 2)]); + col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(operation, ipxrip_packet_vals, "Unknown")); if (tree) { ti = proto_tree_add_item(tree, proto_ipxrip, tvb, 0, -1, ENC_NA); rip_tree = proto_item_add_subtree(ti, ett_ipxrip); - if (operation < 2) { - proto_tree_add_text(rip_tree, tvb, 0, 2, - "RIP packet type: %s", rip_type[operation]); + proto_tree_add_item(rip_tree, hf_ipxrip_packet_type, tvb, 0, 2, ENC_BIG_ENDIAN); - if (operation == 0) { - hidden_item = proto_tree_add_boolean(rip_tree, + switch(operation) + { + case IPX_RIP_REQUEST: + hidden_item = proto_tree_add_boolean(rip_tree, hf_ipxrip_request, tvb, 0, 2, 1); - } else { - hidden_item = proto_tree_add_boolean(rip_tree, + PROTO_ITEM_SET_HIDDEN(hidden_item); + break; + case IPX_RIP_RESPONSE: + hidden_item = proto_tree_add_boolean(rip_tree, hf_ipxrip_response, tvb, 0, 2, 1); - } PROTO_ITEM_SET_HIDDEN(hidden_item); - - } - else { - proto_tree_add_text(rip_tree, tvb, 0, 2, "Unknown RIP packet type"); + break; } available_length = tvb_reported_length(tvb); for (cursor = 2; cursor < available_length; cursor += 8) { - tvb_memcpy(tvb, (guint8 *)&route.network, cursor, 4); - route.hops = tvb_get_ntohs(tvb, cursor+4); - route.ticks = tvb_get_ntohs(tvb, cursor+6); + ticks = tvb_get_ntohs(tvb, cursor+6); + proto_tree_add_item(rip_tree, hf_ipxrip_route_vector, tvb, cursor, 4, ENC_NA); + proto_tree_add_item(rip_tree, hf_ipxrip_hops, tvb, cursor+4, 2, ENC_BIG_ENDIAN); if (operation == IPX_RIP_REQUEST - 1) { - proto_tree_add_text(rip_tree, tvb, cursor, 8, - "Route Vector: %s, %d hop%s, %d tick%s", - ipxnet_to_string((guint8*)&route.network), - route.hops, route.hops == 1 ? "" : "s", - route.ticks, route.ticks == 1 ? "" : "s"); + proto_tree_add_item(rip_tree, hf_ipxrip_ticks, tvb, cursor+6, 2, ENC_BIG_ENDIAN); } else { - proto_tree_add_text(rip_tree, tvb, cursor, 8, - "Route Vector: %s, %d hop%s, %d tick%s (%d ms)", - ipxnet_to_string((guint8*)&route.network), - route.hops, route.hops == 1 ? "" : "s", - route.ticks, route.ticks == 1 ? "" : "s", - route.ticks * 1000 / 18); + proto_tree_add_uint_format_value(rip_tree, hf_ipxrip_ticks, tvb, cursor+6, 2, ticks, + "%d ms", ticks * 1000 / 18); } } } @@ -1018,8 +1015,7 @@ dissect_serialization(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_add_fstr(pinfo->cinfo, COL_INFO, "Serial number %s", tvb_bytes_to_ep_str(tvb, 0, 6)); - proto_tree_add_text(ser_tree, tvb, 0, 6, - "Serial number: %s", tvb_bytes_to_ep_str(tvb, 0, 6)); + proto_tree_add_item(ser_tree, hf_serial_number, tvb, 0, 6, ENC_NA); } /* @@ -1260,6 +1256,14 @@ static const value_string novell_server_vals[] = { value_string_ext novell_server_vals_ext = VALUE_STRING_EXT_INIT(novell_server_vals); +static const value_string ipxsap_packet_vals[] = { + { IPX_SAP_GENERAL_QUERY, "General Query"}, + { IPX_SAP_GENERAL_RESPONSE, "General Response"}, + { IPX_SAP_NEAREST_QUERY, "Nearest Query"}, + { IPX_SAP_NEAREST_RESPONSE, "Nearest Response"}, + { 0, NULL} +}; + static void dissect_ipxsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { @@ -1267,13 +1271,6 @@ dissect_ipxsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti, *hidden_item; int cursor; struct sap_query query; - guint16 server_type; - gchar *server_name; - guint16 server_port; - guint16 intermediate_network; - - static const char *sap_type[4] = { "General Query", "General Response", - "Nearest Query", "Nearest Response" }; col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPX SAP"); col_clear(pinfo->cinfo, COL_INFO); @@ -1281,33 +1278,30 @@ dissect_ipxsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) query.query_type = tvb_get_ntohs(tvb, 0); query.server_type = tvb_get_ntohs(tvb, 2); - if (query.query_type >= 1 && query.query_type <= 4) { - col_set_str(pinfo->cinfo, COL_INFO, sap_type[query.query_type - 1]); - } - else { - col_set_str(pinfo->cinfo, COL_INFO, "Unknown Packet Type"); - } + col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(query.query_type, ipxsap_packet_vals, "Unknown Packet Type")); if (tree) { ti = proto_tree_add_item(tree, proto_sap, tvb, 0, -1, ENC_NA); sap_tree = proto_item_add_subtree(ti, ett_ipxsap); - if (query.query_type >= 1 && query.query_type <= 4) { - proto_tree_add_text(sap_tree, tvb, 0, 2, "%s", sap_type[query.query_type - 1]); - if ((query.query_type - 1) % 2) { - hidden_item = proto_tree_add_boolean(sap_tree, + proto_tree_add_item(sap_tree, hf_sap_packet_type, tvb, 0, 2, ENC_BIG_ENDIAN); + + switch(query.query_type) + { + case IPX_SAP_GENERAL_QUERY: + case IPX_SAP_NEAREST_QUERY: + hidden_item = proto_tree_add_boolean(sap_tree, hf_sap_response, tvb, 0, 2, 1); - } else { - hidden_item = proto_tree_add_boolean(sap_tree, + PROTO_ITEM_SET_HIDDEN(hidden_item); + break; + case IPX_SAP_GENERAL_RESPONSE: + case IPX_SAP_NEAREST_RESPONSE: + hidden_item = proto_tree_add_boolean(sap_tree, hf_sap_request, tvb, 0, 2, 1); - } PROTO_ITEM_SET_HIDDEN(hidden_item); - } - else { - proto_tree_add_text(sap_tree, tvb, 0, 2, - "Unknown SAP Packet Type %d", query.query_type); + break; } if (query.query_type == IPX_SAP_GENERAL_RESPONSE || @@ -1315,34 +1309,19 @@ dissect_ipxsap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) int available_length = tvb_reported_length(tvb); for (cursor = 2; (cursor + 64) <= available_length; cursor += 64) { - server_type = tvb_get_ntohs(tvb, cursor); - server_name = tvb_format_stringzpad(tvb, cursor+2, 48); - ti = proto_tree_add_text(sap_tree, tvb, cursor+2, 48, - "Server Name: %s", server_name); + ti = proto_tree_add_item(sap_tree, hf_sap_server_name, tvb, cursor+2, 48, ENC_ASCII|ENC_NA); s_tree = proto_item_add_subtree(ti, ett_ipxsap_server); - proto_tree_add_text(s_tree, tvb, cursor, 2, "Server Type: %s (0x%04X)", - val_to_str_ext_const(server_type, &novell_server_vals_ext, "Unknown"), - server_type); - proto_tree_add_text(s_tree, tvb, cursor+50, 4, "Network: %s", - tvb_ipxnet_to_string(tvb, cursor+50)); - proto_tree_add_text(s_tree, tvb, cursor+54, 6, "Node: %s", - tvb_ether_to_str(tvb, cursor+54)); - server_port = tvb_get_ntohs(tvb, cursor+60); - proto_tree_add_text(s_tree, tvb, cursor+60, 2, "Socket: %s (0x%04x)", - socket_text(server_port), - server_port); - intermediate_network = tvb_get_ntohs(tvb, cursor+62); - proto_tree_add_text(s_tree, tvb, cursor+62, 2, - "Intermediate Networks: %d", - intermediate_network); + proto_tree_add_item(s_tree, hf_sap_server_type, tvb, cursor, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(s_tree, hf_sap_network, tvb, cursor+50, 4, ENC_NA); + proto_tree_add_item(s_tree, hf_sap_node, tvb, cursor+54, 6, ENC_NA); + proto_tree_add_item(s_tree, hf_sap_socket, tvb, cursor+60, 2, ENC_BIG_ENDIAN); + proto_tree_add_item(s_tree, hf_sap_intermediate_networks, tvb, cursor+62, 2, ENC_BIG_ENDIAN); } } else { /* queries */ - proto_tree_add_text(sap_tree, tvb, 2, 2, "Server Type: %s (0x%04X)", - val_to_str_ext_const(query.server_type, &novell_server_vals_ext, "Unknown"), - query.server_type); + proto_tree_add_item(sap_tree, hf_sap_server_type, tvb, 2, 2, ENC_BIG_ENDIAN); } } } @@ -1504,6 +1483,11 @@ proto_register_ipx(void) { "Retransmitted Frame Number", "spx.rexmt_frame", FT_FRAMENUM, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + + { &hf_spx_rexmt_data, + { "Retransmitted data", "spx.rexmt_data", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, }; static hf_register_info hf_ipxrip[] = { @@ -1515,7 +1499,27 @@ proto_register_ipx(void) { &hf_ipxrip_response, { "Response", "ipxrip.response", FT_BOOLEAN, BASE_NONE, NULL, 0x0, - "TRUE if IPX RIP response", HFILL }} + "TRUE if IPX RIP response", HFILL }}, + + { &hf_ipxrip_packet_type, + { "RIP packet type", "ipxrip.packet_type", + FT_UINT16, BASE_DEC, VALS(ipxrip_packet_vals), 0x0, + NULL, HFILL }}, + + { &hf_ipxrip_route_vector, + { "Route Vector", "ipxrip.route_vector", + FT_IPXNET, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + + { &hf_ipxrip_hops, + { "Hops", "ipxrip.hops", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, + + { &hf_ipxrip_ticks, + { "Ticks", "ipxrip.ticks", + FT_UINT16, BASE_DEC, NULL, 0x0, + NULL, HFILL }}, }; static hf_register_info hf_sap[] = { @@ -1527,7 +1531,17 @@ proto_register_ipx(void) { &hf_sap_response, { "Response", "ipxsap.response", FT_BOOLEAN, BASE_NONE, NULL, 0x0, - "TRUE if SAP response", HFILL }} + "TRUE if SAP response", HFILL }}, + + /* Generated from convert_proto_tree_add_text.pl */ + { &hf_sap_packet_type, { "SAP packet type", "ipxsap.packet_type", FT_UINT16, BASE_DEC, VALS(ipxsap_packet_vals), 0x0, NULL, HFILL }}, + { &hf_sap_server_name, { "Server Name", "ipxsap.server_name", FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_sap_server_type, { "Server Type", "ipxsap.server_type", FT_UINT16, BASE_HEX|BASE_EXT_STRING, &novell_server_vals_ext, 0x0, NULL, HFILL }}, + { &hf_sap_network, { "Network", "ipxsap.network", FT_IPXNET, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_sap_node, { "Node", "ipxsap.node", FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_sap_socket, { "Socket", "ipxsap.socket", FT_UINT16, BASE_HEX|BASE_EXT_STRING, &ipx_socket_vals_ext, 0x0, NULL, HFILL }}, + { &hf_sap_intermediate_networks, { "Intermediate Networks", "ipxsap.intermediate_networks", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + }; static hf_register_info hf_ipxmsg[] = { @@ -1542,6 +1556,13 @@ proto_register_ipx(void) NULL, HFILL }} }; + static hf_register_info hf_serial[] = { + { &hf_serial_number, + { "Serial number", "nw_serial.serial_number", + FT_BYTES, BASE_NONE, NULL, 0x0, + NULL, HFILL }}, + }; + static gint *ett[] = { &ett_ipx, &ett_spx, @@ -1569,6 +1590,7 @@ proto_register_ipx(void) proto_serialization = proto_register_protocol("NetWare Serialization Protocol", "NW_SERIAL", "nw_serial"); + proto_register_field_array(proto_serialization, hf_serial, array_length(hf_serial)); proto_ipxmsg = proto_register_protocol("IPX Message", "IPX MSG", "ipxmsg"); diff --git a/epan/to_str.h b/epan/to_str.h index 963d228856..2b6f8debd9 100644 --- a/epan/to_str.h +++ b/epan/to_str.h @@ -69,7 +69,6 @@ WS_DLL_PUBLIC const gchar* ip6_guint8_to_str(const guint8 *ad); WS_DLL_PUBLIC const gchar* tvb_ip6_to_str(tvbuff_t *tvb, const gint offset); void ip6_to_str_buf(const struct e_in6_addr *, gchar *); extern gchar* ipx_addr_to_str(const guint32, const guint8 *); -extern gchar* ipxnet_to_string(const guint8 *ad); extern gchar* tvb_ipxnet_to_string(tvbuff_t *tvb, const gint offset); extern gchar* ipxnet_to_str_punct(const guint32 ad, const char punct); extern gchar* tvb_vines_addr_to_str(tvbuff_t *tvb, const gint offset);