/* packet-udp.c
* Routines for UDP packet disassembly
*
- * $Id: packet-udp.c,v 1.18 1999/06/25 07:15:02 guy Exp $
+ * $Id: packet-udp.c,v 1.23 1999/08/18 00:57:54 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
#include "packet.h"
#include "resolv.h"
-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 */
#define UDP_PORT_ISAKMP 500
#define UDP_PORT_RIP 520
#define UDP_PORT_VINES 573
+#define UDP_PORT_RADIUS 1645
+#define UDP_PORT_RADIUS_NEW 1812
+#define UDP_PORT_RADACCT 1646
+#define UDP_PORT_RADACCT_NEW 1813
struct hash_struct {
struct hash_struct *next;
};
-struct hash_struct *hash_table[256];
+static struct hash_struct *hash_table[256];
/*
* These routines are for UDP, will be generalized soon: RJS
struct hash_struct *dissect_routine = NULL;
proto_tree *udp_tree;
proto_item *ti;
- guint payload;
/* To do: Check for {cap len,pkt len} < struct len */
/* Avoids alignment problems on many architectures. */
uh_ulen = ntohs(uh.uh_ulen);
uh_sum = ntohs(uh.uh_sum);
- payload = pi.payload - sizeof(e_udphdr);
-
if (check_col(fd, COL_PROTOCOL))
col_add_str(fd, COL_PROTOCOL, "UDP");
if (check_col(fd, COL_INFO))
col_add_fstr(fd, COL_UNRES_DST_PORT, "%u", uh_dport);
if (tree) {
- ti = proto_tree_add_item(tree, offset, 8, "User Datagram Protocol");
- udp_tree = proto_tree_new();
- proto_item_add_subtree(ti, udp_tree, ETT_UDP);
- proto_tree_add_item(udp_tree, offset, 2, "Source port: %s (%u)",
- get_udp_port(uh_sport), uh_sport);
- proto_tree_add_item(udp_tree, offset + 2, 2, "Destination port: %s (%u)",
- get_udp_port(uh_dport), uh_dport);
- proto_tree_add_item(udp_tree, offset + 4, 2, "Length: %u", uh_ulen);
- proto_tree_add_item(udp_tree, offset + 6, 2, "Checksum: 0x%04x", uh_sum);
+ ti = proto_tree_add_item(tree, proto_udp, offset, 8);
+ udp_tree = proto_item_add_subtree(ti, ETT_UDP);
+
+ 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 */
} else if (PORT_IS(UDP_PORT_NBNS))
dissect_nbns(pd, offset, fd, tree);
else if (PORT_IS(UDP_PORT_NBDGM))
- dissect_nbdgm(pd, offset, fd, tree, payload);
+ dissect_nbdgm(pd, offset, fd, tree);
else if (PORT_IS(UDP_PORT_IPX)) /* RFC 1234 */
dissect_ipx(pd, offset, fd, tree);
#if defined(HAVE_UCD_SNMP_SNMP_H) || defined(HAVE_SNMP_SNMP_H)
/* This is the first point of call, but it adds a dynamic call */
udp_hash_add(MAX(uh_sport, uh_dport), dissect_tftp); /* Add to table */
dissect_tftp(pd, offset, fd, tree);
+ } else if (PORT_IS(UDP_PORT_RADIUS) ||
+ PORT_IS(UDP_PORT_RADACCT) ||
+ PORT_IS(UDP_PORT_RADIUS_NEW) ||
+ PORT_IS(UDP_PORT_RADACCT_NEW) ) {
+ dissect_radius(pd, offset, fd, tree);
} else {
/* OK, find a routine in the table, else use the default */
}
}
}
+
+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));
+}
+