diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 1999-07-22 16:41:22 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 1999-07-22 16:41:22 +0000 |
commit | 0e7a2d905adb67f334d3bdc3cc5139ee2fabef04 (patch) | |
tree | 405b160d91b05d181663adbd23571944f85829ff | |
parent | 4dcaf2d853d3cc33fff380b827a55475f753c0b2 (diff) | |
download | wireshark-0e7a2d905adb67f334d3bdc3cc5139ee2fabef04.tar.gz wireshark-0e7a2d905adb67f334d3bdc3cc5139ee2fabef04.tar.bz2 wireshark-0e7a2d905adb67f334d3bdc3cc5139ee2fabef04.zip |
Converted UDP fields to new proto_tree functions.
svn path=/trunk/; revision=376
-rw-r--r-- | packet-udp.c | 54 | ||||
-rw-r--r-- | proto.c | 4 |
2 files changed, 49 insertions, 9 deletions
diff --git a/packet-udp.c b/packet-udp.c index 1797409ea5..9bbc9f5dbc 100644 --- a/packet-udp.c +++ b/packet-udp.c @@ -1,7 +1,7 @@ /* packet-udp.c * Routines for UDP packet disassembly * - * $Id: packet-udp.c,v 1.20 1999/07/08 04:23:04 gram Exp $ + * $Id: packet-udp.c,v 1.21 1999/07/22 16:41:22 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -46,6 +46,13 @@ extern packet_info pi; +int proto_udp = -1; +int hf_udp_srcport = -1; +int hf_udp_dstport = -1; +int hf_udp_port = -1; +int hf_udp_length = -1; +int hf_udp_checksum = -1; + /* UDP structs and definitions */ typedef struct _e_udphdr { @@ -195,14 +202,20 @@ dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { col_add_fstr(fd, COL_UNRES_DST_PORT, "%u", uh_dport); if (tree) { - ti = proto_tree_add_text(tree, offset, 8, "User Datagram Protocol"); + ti = proto_tree_add_item(tree, proto_udp, offset, 8); udp_tree = proto_item_add_subtree(ti, ETT_UDP); - proto_tree_add_text(udp_tree, offset, 2, "Source port: %s (%u)", - get_udp_port(uh_sport), uh_sport); - proto_tree_add_text(udp_tree, offset + 2, 2, "Destination port: %s (%u)", - get_udp_port(uh_dport), uh_dport); - proto_tree_add_text(udp_tree, offset + 4, 2, "Length: %u", uh_ulen); - proto_tree_add_text(udp_tree, offset + 6, 2, "Checksum: 0x%04x", uh_sum); + + proto_tree_add_item_format(udp_tree, hf_udp_srcport, offset, 2, uh_sport, + "Source port: %s (%u)", get_udp_port(uh_sport), uh_sport); + proto_tree_add_item_format(udp_tree, hf_udp_dstport, offset + 2, 2, uh_dport, + "Destination port: %s (%u)", get_udp_port(uh_dport), uh_dport); + + proto_tree_add_item_hidden(udp_tree, hf_udp_port, offset, 2, uh_sport); + proto_tree_add_item_hidden(udp_tree, hf_udp_port, offset+2, 2, uh_dport); + + proto_tree_add_item(udp_tree, hf_udp_length, offset + 4, 2, uh_ulen); + proto_tree_add_item_format(udp_tree, hf_udp_checksum, offset + 6, 2, uh_sum, + "Checksum: 0x%04x", uh_sum); } /* Skip over header */ @@ -267,3 +280,28 @@ dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { } } } + +void +proto_register_udp(void) +{ + static hf_register_info hf[] = { + { &hf_udp_srcport, + { "Source Port", "udp.srcport", FT_UINT16, NULL }}, + + { &hf_udp_dstport, + { "Destination Port", "udp.dstport", FT_UINT16, NULL }}, + + { &hf_udp_port, + { "Source or Destination Port", "udp.port", FT_UINT16, NULL }}, + + { &hf_udp_length, + { "Length", "udp.length", FT_UINT16, NULL }}, + + { &hf_udp_checksum, + { "Checksum", "udp.checksum", FT_UINT16, NULL }} + }; + + proto_udp = proto_register_protocol("User Datagram Protocol", "udp"); + proto_register_field_array(proto_udp, hf, array_length(hf)); +} + @@ -1,7 +1,7 @@ /* proto.c * Routines for protocol tree * - * $Id: proto.c,v 1.3 1999/07/17 04:19:05 gram Exp $ + * $Id: proto.c,v 1.4 1999/07/22 16:41:22 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -91,6 +91,7 @@ void proto_register_llc(void); void proto_register_null(void); void proto_register_tcp(void); void proto_register_tr(void); +void proto_register_udp(void); /* special-case header field used within proto.c */ int hf_text_only = 1; @@ -148,6 +149,7 @@ proto_init(void) proto_register_null(); proto_register_tr(); proto_register_tcp(); + proto_register_udp(); /* Register one special-case FT_TEXT_ONLY field for use when converting ethereal to new-style proto_tree. These fields |