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
This commit is contained in:
parent
05fe159e74
commit
f540888bd4
20
packet-tcp.c
20
packet-tcp.c
|
@ -1,7 +1,7 @@
|
|||
/* packet-tcp.c
|
||||
* Routines for TCP packet disassembly
|
||||
*
|
||||
* $Id: packet-tcp.c,v 1.62 2000/04/03 09:37:39 guy Exp $
|
||||
* $Id: packet-tcp.c,v 1.63 2000/04/04 05:37:35 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -406,7 +406,6 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
guint hlen;
|
||||
guint optlen;
|
||||
guint packet_max = pi.len;
|
||||
dissector_t subdissector;
|
||||
|
||||
/* To do: Check for {cap len,pkt len} < struct len */
|
||||
/* Avoids alignment problems on many architectures. */
|
||||
|
@ -534,20 +533,11 @@ dissect_tcp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
|
|||
#endif
|
||||
|
||||
/* do lookup with the subdissector table */
|
||||
|
||||
subdissector = dissector_lookup( subdissector_table, th.th_sport);
|
||||
if ( subdissector){
|
||||
pi.match_port = th.th_sport;
|
||||
(subdissector)( pd, offset, fd, tree);
|
||||
if (dissector_try_port(subdissector_table, th.th_sport, pd, offset,
|
||||
fd, tree) ||
|
||||
dissector_try_port(subdissector_table, th.th_dport, pd, offset,
|
||||
fd, tree))
|
||||
goto reas;
|
||||
}
|
||||
|
||||
subdissector = dissector_lookup( subdissector_table, th.th_dport);
|
||||
if ( subdissector){
|
||||
pi.match_port = th.th_dport;
|
||||
(subdissector)( pd, offset, fd, tree);
|
||||
goto reas;
|
||||
}
|
||||
|
||||
/* check existence of high level protocols */
|
||||
|
||||
|
|
28
packet-udp.c
28
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 <gerald@zing.org>
|
||||
|
@ -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);
|
||||
|
|
19
packet.c
19
packet.c
|
@ -1,7 +1,7 @@
|
|||
/* packet.c
|
||||
* Routines for packet disassembly
|
||||
*
|
||||
* $Id: packet.c,v 1.71 2000/04/04 02:34:38 gram Exp $
|
||||
* $Id: packet.c,v 1.72 2000/04/04 05:37:36 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -1289,6 +1289,23 @@ void dissector_delete( char *name, guint32 pattern, dissector_t dissector) {
|
|||
g_hash_table_remove( sub_dissectors, GUINT_TO_POINTER( pattern));
|
||||
}
|
||||
|
||||
/* Look for a given port in a given dissector table and, if found, call
|
||||
the dissector with the arguments supplied, and return TRUE, otherwise
|
||||
return FALSE. */
|
||||
gboolean
|
||||
dissector_try_port(dissector_table_t sub_dissectors, guint32 port,
|
||||
const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
||||
{
|
||||
dissector_t subdissector;
|
||||
|
||||
subdissector = dissector_lookup(sub_dissectors, port);
|
||||
if (subdissector != NULL) {
|
||||
pi.match_port = port;
|
||||
(subdissector)(pd, offset, fd, tree);
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dissector_table_t register_dissector_table( int id){
|
||||
|
||||
|
|
7
packet.h
7
packet.h
|
@ -1,7 +1,7 @@
|
|||
/* packet.h
|
||||
* Definitions for packet disassembly structures and routines
|
||||
*
|
||||
* $Id: packet.h,v 1.177 2000/04/03 09:41:13 guy Exp $
|
||||
* $Id: packet.h,v 1.178 2000/04/04 05:37:34 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -228,6 +228,11 @@ void dissector_add( char *abbrev, guint32 pattern, dissector_t dissector);
|
|||
/* that wants to de-register a sub-dissector. */
|
||||
void dissector_delete( char *abbrev, guint32 pattern, dissector_t dissector);
|
||||
|
||||
/* Look for a given port in a given dissector table and, if found, call
|
||||
the dissector with the arguments supplied, and return TRUE, otherwise
|
||||
return FALSE. */
|
||||
gboolean dissector_try_port(dissector_table_t sub_dissectors, guint32 port,
|
||||
const u_char *pd, int offset, frame_data *fd, proto_tree *tree);
|
||||
|
||||
/* Many of the structs and definitions below and in packet-*.c files
|
||||
* were taken from include files in the Linux distribution. */
|
||||
|
|
Loading…
Reference in New Issue