Update the Win32 Nmakefiles to reflect the move of the color code into
[obnox/wireshark/wip.git] / packet-udp.c
index 76b9fd967d29fc19f8e0e954f927d4d29c989d62..d1fcea283bdb8c05cd80ed45c2144e1b099074ee 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-udp.c
  * Routines for UDP packet disassembly
  *
- * $Id: packet-udp.c,v 1.40 1999/12/05 02:32:39 guy Exp $
+ * $Id: packet-udp.c,v 1.49 2000/02/09 19:09:02 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
 #include <stdlib.h>
 
 #include <glib.h>
-#include "packet.h"
+#include "globals.h"
 #include "resolv.h"
 
+#include "plugins.h"
+
 static int proto_udp = -1;             
 static int hf_udp_srcport = -1;
 static int hf_udp_dstport = -1;
@@ -64,6 +66,7 @@ typedef struct _e_udphdr {
 
 /* UDP Ports -> should go in packet-udp.h */
 
+#define UDP_PORT_TIME    37
 #define UDP_PORT_TACACS  49
 #define UDP_PORT_DNS     53
 #define UDP_PORT_BOOTPS  67
@@ -73,12 +76,17 @@ typedef struct _e_udphdr {
 #define UDP_PORT_NBNS  137
 #define UDP_PORT_NBDGM 138
 #define UDP_PORT_SNMP   161
+#define UDP_PORT_SNMP_TRAP 162
+#define UDP_PORT_SRVLOC 427
 #define UDP_PORT_PIM_RP_DISC 496
 #define UDP_PORT_ISAKMP        500
+#define UDP_PORT_WHO    513
 #define UDP_PORT_RIP    520
 #define UDP_PORT_RIPNG  521
+#define UDP_PORT_NCP    524
 #define UDP_PORT_VINES 573
 #define UDP_PORT_RADIUS 1645
+#define UDP_PORT_L2TP   1701
 #define UDP_PORT_RADIUS_NEW 1812
 #define UDP_PORT_RADACCT 1646
 #define UDP_PORT_RADACCT_NEW 1813
@@ -89,6 +97,7 @@ typedef struct _e_udphdr {
 #define UDP_PORT_RX_LOW 7000
 #define UDP_PORT_RX_HIGH 7009
 #define UDP_PORT_RX_AFS_BACKUPS 7021
+#define UDP_PORT_WCCP  2048
 
 struct hash_struct {
   guint16 proto;
@@ -237,12 +246,32 @@ dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
   if (dissect_rpc(pd, offset, fd, tree))
     return;
 
+  /* try to apply the plugins */
+#ifdef HAVE_PLUGINS
+  {
+      plugin *pt_plug = plugin_list;
+
+      if (pt_plug) {
+         while (pt_plug) {
+             if (pt_plug->enabled && !strcmp(pt_plug->protocol, "udp") &&
+                 tree && dfilter_apply(pt_plug->filter, tree, pd)) {
+                 pt_plug->dissector(pd, offset, fd, tree);
+                 return;
+             }
+             pt_plug = pt_plug->next;
+         }
+      }
+  }
+#endif
+
   /* XXX - we should do all of this through the table of ports. */
 #define PORT_IS(port)  (uh_sport == port || uh_dport == port)
   if (PORT_IS(UDP_PORT_BOOTPS))
       dissect_bootp(pd, offset, fd, tree);
   else if (PORT_IS(UDP_PORT_DNS))
       dissect_dns(pd, offset, fd, tree);
+  else if (PORT_IS(UDP_PORT_SRVLOC))
+      dissect_srvloc(pd, offset, fd, tree);
   else if (PORT_IS(UDP_PORT_ISAKMP))
       dissect_isakmp(pd, offset, fd, tree);
   else if (PORT_IS(UDP_PORT_RIP)) {
@@ -250,19 +279,23 @@ dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
       dissect_rip(pd, offset, fd, tree);
   } else if (PORT_IS(UDP_PORT_RIPNG))
       dissect_ripng(pd, offset, fd, tree);
+  else if (PORT_IS(UDP_PORT_NCP))
+      dissect_ncp(pd, offset, fd, tree);
   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);
   else if (PORT_IS(UDP_PORT_NTP))
       dissect_ntp(pd, offset, fd, tree);
+  else if (PORT_IS(UDP_PORT_WHO))
+      dissect_who(pd, offset, fd, tree);
   else if (PORT_IS(UDP_PORT_IPX)) /* RFC 1234 */
       dissect_ipx(pd, offset, fd, tree);
   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_SNMP))
+  else if (PORT_IS(UDP_PORT_SNMP) || PORT_IS(UDP_PORT_SNMP_TRAP))
       dissect_snmp(pd, offset, fd, tree);
   else if (PORT_IS(UDP_PORT_VINES)) {
       /* FIXME: AFAIK, src and dst port must be the same */
@@ -271,15 +304,21 @@ dissect_udp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
       /* 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_TIME)) {
+      dissect_time(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 if ( PORT_IS(UDP_PORT_L2TP)) {
+      dissect_l2tp(pd,offset,fd,tree);
   } else if ( PORT_IS(UDP_PORT_ICP)) {
        dissect_icp(pd,offset,fd,tree);
  } else if ( PORT_IS(UDP_PORT_ICQ)) {
         dissect_icq(pd,offset,fd,tree);
+ } else if (PORT_IS(UDP_PORT_WCCP) ) {
+       dissect_wccp(pd, offset, fd, tree);
  } else {
       /* OK, find a routine in the table, else use the default */