aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packet-tcp.c20
-rw-r--r--packet-udp.c28
-rw-r--r--packet.c19
-rw-r--r--packet.h7
4 files changed, 34 insertions, 40 deletions
diff --git a/packet-tcp.c b/packet-tcp.c
index 11cacec0a5..cb23b3a0f9 100644
--- a/packet-tcp.c
+++ b/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);
- goto reas;
- }
-
- subdissector = dissector_lookup( subdissector_table, th.th_dport);
- if ( subdissector){
- pi.match_port = th.th_dport;
- (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;
- }
/* check existence of high level protocols */
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 <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);
diff --git a/packet.c b/packet.c
index 2a1c7f1307..57427e21e9 100644
--- a/packet.c
+++ b/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){
diff --git a/packet.h b/packet.h
index de900131a1..fc56c19e6a 100644
--- a/packet.h
+++ b/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. */