/* packet-udp.c
* Routines for UDP packet disassembly
*
- * $Id: packet-udp.c,v 1.61 2000/04/13 18:18:50 gram Exp $
+ * $Id: packet-udp.c,v 1.71 2000/05/30 03:35:55 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
#include "resolv.h"
#include "plugins.h"
+#include "packet-udp.h"
-#include "packet-ncp.h"
-#include "packet-rip.h"
+#include "packet-ip.h"
#include "packet-rpc.h"
-#include "packet-rx.h"
#include "packet-tftp.h"
#include "packet-vines.h"
/* UDP Ports -> should go in packet-udp.h */
#define UDP_PORT_TFTP 69
-#define UDP_PORT_RIP 520
-#define UDP_PORT_NCP 524
#define UDP_PORT_VINES 573
-#define UDP_PORT_RX_LOW 7000
-#define UDP_PORT_RX_HIGH 7009
-#define UDP_PORT_RX_AFS_BACKUPS 7021
static dissector_table_t udp_dissector_table;
-
-void
-decode_udp_ports( const u_char *pd, int offset, frame_data *fd,
- proto_tree *tree, int uh_sport, int uh_dport){
-
/* Determine if there is a sub-dissector and call it. This has been */
/* separated into a stand alone routine to other protocol dissectors */
/* can call to it, ie. socks */
+void
+decode_udp_ports( const u_char *pd, int offset, frame_data *fd,
+ proto_tree *tree, int uh_sport, int uh_dport){
dissector_t sub_dissector;
-
/* determine if this packet is part of a conversation and call dissector */
/* for the conversation if available */
if (enabled_plugins_number > 0) {
while (pt_plug) {
if (pt_plug->enabled && !strcmp(pt_plug->protocol, "udp") &&
- tree && dfilter_apply(pt_plug->filter, tree, pd)) {
+ tree && dfilter_apply(pt_plug->filter, tree, pd, fd->cap_len)) {
pt_plug->dissector(pd, offset, fd, tree);
return;
}
}
#endif
- /* XXX - we should do all of this through the table of ports. */
+ /* do lookup with the subdissector table */
+ if (dissector_try_port(udp_dissector_table, uh_sport, pd, offset, fd, tree) ||
+ dissector_try_port(udp_dissector_table, uh_dport, pd, offset, fd, tree))
+ return;
+
+ /* XXX - we should do these with the subdissector table as well. */
#define PORT_IS(port) (uh_sport == port || uh_dport == port)
- if (PORT_IS(UDP_PORT_RIP)) {
- /* we should check the source port too (RIP: UDP src and dst port 520) */
- dissect_rip(pd, offset, fd, tree);
- } else if (PORT_IS(UDP_PORT_NCP))
- dissect_ncp(pd, offset, fd, tree); /* XXX -- need to handle nw_server_address */
- else if ((uh_sport >= UDP_PORT_RX_LOW && uh_sport <= UDP_PORT_RX_HIGH) ||
- (uh_dport >= UDP_PORT_RX_LOW && uh_dport <= UDP_PORT_RX_HIGH) ||
- PORT_IS(UDP_PORT_RX_AFS_BACKUPS))
- dissect_rx(pd, offset, fd, tree); /* transarc AFS's RX protocol */
- else if (PORT_IS(UDP_PORT_VINES)) {
- /* FIXME: AFAIK, src and dst port must be the same */
- dissect_vines_frp(pd, offset, fd, tree);
+ if (PORT_IS(UDP_PORT_VINES)) {
+ /* FIXME: AFAIK, src and dst port must be the same */
+ dissect_vines_frp(pd, offset, fd, tree);
} else if (PORT_IS(UDP_PORT_TFTP)) {
- /* This is the first point of call, but it adds a dynamic call */
- dissector_add("udp.port", MAX(uh_sport, uh_dport), dissect_tftp); /* Add to table */
- dissect_tftp(pd, offset, fd, tree);
- } else {
- /* OK, find a routine in the table, else use the default */
-
- if (!dissector_try_port(udp_dissector_table, uh_sport, pd, offset,
- fd, tree) &&
- !dissector_try_port(udp_dissector_table, uh_dport, pd, offset,
- fd, tree))
- dissect_data(pd, offset, fd, tree);
- }
+ /* This is the first point of call, but it adds a dynamic call */
+ dissector_add("udp.port", MAX(uh_sport, uh_dport), dissect_tftp); /* Add to table */
+ dissect_tftp(pd, offset, fd, tree);
+ } else
+ dissect_data(pd, offset, fd, tree);
}
-void
+static void
dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
e_udphdr uh;
guint16 uh_sport, uh_dport, uh_ulen, uh_sum;
get_udp_port(uh_sport), get_udp_port(uh_dport));
if (tree) {
- ti = proto_tree_add_item(tree, proto_udp, offset, 8);
+ ti = proto_tree_add_item(tree, proto_udp, NullTVB, offset, 8);
udp_tree = proto_item_add_subtree(ti, ett_udp);
- proto_tree_add_uint_format(udp_tree, hf_udp_srcport, offset, 2, uh_sport,
+ proto_tree_add_uint_format(udp_tree, hf_udp_srcport, NullTVB, offset, 2, uh_sport,
"Source port: %s (%u)", get_udp_port(uh_sport), uh_sport);
- proto_tree_add_uint_format(udp_tree, hf_udp_dstport, offset + 2, 2, uh_dport,
+ proto_tree_add_uint_format(udp_tree, hf_udp_dstport, NullTVB, 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_hidden(udp_tree, hf_udp_port, NullTVB, offset, 2, uh_sport);
+ proto_tree_add_item_hidden(udp_tree, hf_udp_port, NullTVB, offset+2, 2, uh_dport);
- proto_tree_add_item(udp_tree, hf_udp_length, offset + 4, 2, uh_ulen);
- proto_tree_add_uint_format(udp_tree, hf_udp_checksum, offset + 6, 2, uh_sum,
+ proto_tree_add_item(udp_tree, hf_udp_length, NullTVB, offset + 4, 2, uh_ulen);
+ proto_tree_add_uint_format(udp_tree, hf_udp_checksum, NullTVB, offset + 6, 2, uh_sum,
"Checksum: 0x%04x", uh_sum);
}
/* subdissector code */
udp_dissector_table = register_dissector_table("udp.port");
}
+
+void
+proto_reg_handoff_udp(void)
+{
+ dissector_add("ip.proto", IP_PROTO_UDP, dissect_udp);
+}