]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-udp.c
Allow tcpdump to work with earlier libpcaps.
[tcpdump] / print-udp.c
index eefec6db8f6156ae16fe031949d1c064b0ee468a..a95683ec45a48341d5567886b670850151ecc745 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.78 2000-09-23 08:26:39 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.89 2000-11-17 19:08:16 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -30,12 +30,8 @@ static const char rcsid[] =
 
 #include <sys/param.h>
 #include <sys/time.h>
-#include <sys/socket.h>
 
 #include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
 
 #ifdef SEGSIZE
 #undef SEGSIZE
@@ -45,10 +41,7 @@ static const char rcsid[] =
 #include <rpc/rpc.h>
 
 #include <stdio.h>
-
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
+#include <string.h>
 
 #include "interface.h"
 #include "addrtoname.h"
@@ -56,6 +49,11 @@ static const char rcsid[] =
 
 #include "udp.h"
 
+#include "ip.h"
+#ifdef INET6
+#include "ip6.h"
+#endif
+
 #ifdef NOERROR
 #undef NOERROR                                 /* Solaris sucks */
 #endif
@@ -394,6 +392,7 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
 #define NTP_PORT 123           /*XXX*/
 #define SNMPTRAP_PORT 162      /*XXX*/
 #define ISAKMP_PORT 500                /*XXX*/
+#define TIMED_PORT 525         /*XXX*/
 #define RIP_PORT 520           /*XXX*/
 #define KERBEROS_SEC_PORT 750  /*XXX*/
 #define L2TP_PORT 1701         /*XXX*/
@@ -404,6 +403,10 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
 #define NETBIOS_NS_PORT   137
 #define NETBIOS_DGRAM_PORT   138
 #define CISCO_AUTORP_PORT 496  /*XXX*/
+#define RADIUS_PORT 1645
+#define RADIUS_NEW_PORT 1812
+#define RADIUS_ACCOUNTING_PORT 1646
+#define RADIUS_NEW_ACCOUNTING_PORT 1813
 
 #ifdef INET6
 #define RIPNG_PORT 521         /*XXX*/
@@ -412,7 +415,8 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
 #endif
 
 void
-udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
+udp_print(register const u_char *bp, u_int length,
+         register const u_char *bp2, int fragmented)
 {
        register const struct udphdr *up;
        register const struct ip *ip;
@@ -428,7 +432,7 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
        up = (struct udphdr *)bp;
        ip = (struct ip *)bp2;
 #ifdef INET6
-       if (ip->ip_v == 6)
+       if (IP_V(ip) == 6)
                ip6 = (struct ip6_hdr *)bp2;
        else
                ip6 = NULL;
@@ -561,7 +565,7 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
                    (atalk_port(sport) || atalk_port(dport))) {
                        if (vflag)
                                fputs("kip ", stdout);
-                       atalk_print(cp, length);
+                       llap_print(cp, length);
                        return;
                }
        }
@@ -598,7 +602,7 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
        }
 #endif
 
-       if (ip->ip_v == 4 && vflag) {
+       if (IP_V(ip) == 4 && vflag && !fragmented) {
                int sum = up->uh_sum;
                if (sum == 0) {
                        (void)printf(" [no cksum]");
@@ -611,7 +615,7 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
                }
        }
 #ifdef INET6
-       if (ip->ip_v == 6 && ip6->ip6_plen && vflag) {
+       if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !fragmented) {
                int sum = up->uh_sum;
                /* for IPv6, UDP checksum is mandatory */
                if (TTEST2(cp[0], length)) {
@@ -628,6 +632,8 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
 #define ISPORT(p) (dport == (p) || sport == (p))
                if (ISPORT(NAMESERVER_PORT))
                        ns_print((const u_char *)(up + 1), length);
+               else if (ISPORT(TIMED_PORT))
+                       timed_print((const u_char *)(up + 1), length);
                else if (ISPORT(TFTP_PORT))
                        tftp_print((const u_char *)(up + 1), length);
                else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
@@ -680,6 +686,11 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
                        wb_print((const void *)(up + 1), length);
                else if (ISPORT(CISCO_AUTORP_PORT))
                        cisco_autorp_print((const void *)(up + 1), length);
+               else if (ISPORT(RADIUS_PORT) ||
+                        ISPORT(RADIUS_NEW_PORT) ||
+                        ISPORT(RADIUS_ACCOUNTING_PORT) || 
+                        ISPORT(RADIUS_NEW_ACCOUNTING_PORT) )
+                        radius_print((const u_char *)(up+1), length);
                else
                        (void)printf(" udp %u",
                            (u_int32_t)(ulen - sizeof(*up)));