From f540888bd4ae622605edff82ac7bdcab2d73902a Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 4 Apr 2000 05:37:36 +0000 Subject: Make a routine that takes a dissector table, a port number, and pd/offset/fd/tree arguments, looks up the port number in the dissector table, and: if it finds it, call the corresponding dissector routine with the pd/offset/fd/tree arguments, and return TRUE; if it doesn't find it, return FALSE. Use that in the TCP and UDP dissectors. Don't add arbitrary UDP ports for which a dissector is found in the table as ports that should be dissected as TFTP; this should only be done if we find a packet going from port XXX to the official TFTP port. Don't register TFTP in UDP's dissector table, as it has to be handled specially (i.e., we have to add the source port as a TFTP port, although we really should register the source port *and* IP address); eventually, we should move that registration to the TFTP dissector itself, at which point we can register TFTP normally. svn path=/trunk/; revision=1785 --- packet-udp.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'packet-udp.c') diff --git a/packet-udp.c b/packet-udp.c index feb8cffadb..199ee29d15 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.54 2000/04/03 09:41:12 guy Exp $ + * $Id: packet-udp.c,v 1.55 2000/04/04 05:37:36 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -135,7 +135,6 @@ 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; - dissector_t dissect_routine; proto_tree *udp_tree; proto_item *ti; @@ -263,27 +262,11 @@ dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { } else { /* OK, find a routine in the table, else use the default */ - if ((dissect_routine = dissector_lookup(udp_dissector_table, uh_sport))) { - - dissector_t dr2 = dissector_lookup(udp_dissector_table, uh_dport); - - if (dr2 == NULL) { /* Not in the table, add */ - - dissector_add("udp.port", uh_dport, dissect_tftp); - - } - - (*dissect_routine)(pd, offset, fd, tree); - } - else if ((dissect_routine = dissector_lookup(udp_dissector_table, uh_dport))) { - - (*dissect_routine)(pd, offset, fd, tree); - - } - else { - + 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); - } } } @@ -328,7 +311,6 @@ proto_register_udp(void) "packet-tcp.c". */ dissector_add("udp.port", UDP_PORT_BOOTPS, dissect_bootp); - dissector_add("udp.port", UDP_PORT_TFTP, dissect_tftp); dissector_add("udp.port", UDP_PORT_SAP, dissect_sap); dissector_add("udp.port", UDP_PORT_HSRP, dissect_hsrp); dissector_add("udp.port", UDP_PORT_PIM_RP_DISC, dissect_auto_rp); -- cgit v1.2.3