Import tcpdump-3.9.7
authorPeter Avalos <pavalos@dragonflybsd.org>
Tue, 7 Aug 2007 17:58:03 +0000 (17:58 +0000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Tue, 7 Aug 2007 17:58:03 +0000 (17:58 +0000)
34 files changed:
contrib/tcpdump-3.9/CHANGES
contrib/tcpdump-3.9/VERSION
contrib/tcpdump-3.9/af.c [new file with mode: 0644]
contrib/tcpdump-3.9/af.h [new file with mode: 0644]
contrib/tcpdump-3.9/bootp.h
contrib/tcpdump-3.9/ieee802_11.h
contrib/tcpdump-3.9/interface.h
contrib/tcpdump-3.9/llc.h
contrib/tcpdump-3.9/nameser.h
contrib/tcpdump-3.9/ospf.h
contrib/tcpdump-3.9/parsenfsfh.c
contrib/tcpdump-3.9/print-802_11.c
contrib/tcpdump-3.9/print-bgp.c
contrib/tcpdump-3.9/print-bootp.c
contrib/tcpdump-3.9/print-dhcp6.c
contrib/tcpdump-3.9/print-domain.c
contrib/tcpdump-3.9/print-icmp.c
contrib/tcpdump-3.9/print-ip.c
contrib/tcpdump-3.9/print-isoclns.c
contrib/tcpdump-3.9/print-ldp.c
contrib/tcpdump-3.9/print-llc.c
contrib/tcpdump-3.9/print-nfs.c
contrib/tcpdump-3.9/print-null.c
contrib/tcpdump-3.9/print-olsr.c [new file with mode: 0644]
contrib/tcpdump-3.9/print-ospf.c
contrib/tcpdump-3.9/print-pflog.c
contrib/tcpdump-3.9/print-rsvp.c
contrib/tcpdump-3.9/print-rx.c
contrib/tcpdump-3.9/print-smb.c
contrib/tcpdump-3.9/print-stp.c
contrib/tcpdump-3.9/print-udp.c
contrib/tcpdump-3.9/smbutil.c
contrib/tcpdump-3.9/tcpdump.1
contrib/tcpdump-3.9/udp.h

index deadb90..3eb70dc 100644 (file)
@@ -1,4 +1,49 @@
-$Header: /tcpdump/master/tcpdump/CHANGES,v 1.87.2.12 2006/09/19 18:24:44 ken Exp $
+$Header: /tcpdump/master/tcpdump/CHANGES,v 1.87.2.14 2007/07/24 02:17:13 mcr Exp $
+
+Wed.   July 23, 2007.  mcr@xelerance.com.  Summary for 0.9.7 libpcap release
+
+       NFS: Print unsigned values as such. 
+       RX: parse safely.
+       BGP: fixes for IPv6-less builds.
+       801.1ag: use standard codepoint.
+       use /dev/bpf on systems with such a device.
+       802.11: print QoS data, avoid dissect of no-data frame, ignore padding.
+       smb: make sure that we haven't gone past the end of the captured data.
+       smb: squelch an uninitialized complaint from coverity.
+       NFS: from NetBSD; don't interpret the reply as a possible NFS reply
+               if it got MSG_DENIED.
+       BGP: don't print TLV values that didn't fit, from www.digit-labs.org. 
+       revised INSTALL.txt about libpcap dependancy.
+
+Wed.   April 25, 2007. ken@xelerance.com.  Summary for 3.9.6 tcpdump release
+       Update man page to reflect changes to libpcap
+       Changes to both TCP and IP Printer Output
+       Fix a potential buffer overflow in the 802.11 printer
+       Print basic info about a few more Cisco LAN protocols.
+       mDNS cleanup
+       ICMP MPLS rework of the extension code
+       bugfix: use the correct codepoint for the OSPF simple text auth token
+        entry, and use safeputs to print the password.
+       Add support in pflog for additional values
+       Add support for OIF RSVP Extensions UNI 1.0 Rev. 2 and additional RSVP objects
+       Add support for the Message-id NACK c-type.
+       Add support for 802.3ah loopback ctrl msg
+       Add support for Multiple-STP as per 802.1s
+       Add support for rapid-SPT as per 802.1w
+       Add support for CFM Link-trace msg, Link-trace-Reply msg, 
+        Sender-ID tlv, private tlv, port, interface status
+       Add support for unidirectional link detection as per
+        http://www.ietf.org/internet-drafts/draft-foschiano-udld-02.txt
+       Add support for the olsr protocol as per RFC 3626 plus the LQ 
+        extensions from olsr.org
+       Add support for variable-length checksum in DCCP, as per section 9 of
+        RFC 4340.
+       Add support for per-VLAN spanning tree and per-VLAN rapid spanning tree
+       Add support for Multiple-STP as per 802.1s
+       Add support for the cisco propriatry 'dynamic trunking protocol'
+       Add support for the cisco proprietary VTP protocol
+       Update dhcp6 options table as per IETF standardization activities
+
 
 Tue.   September 19, 2006. ken@xelerance.com. Summary for 3.9.5 tcpdump release
        
diff --git a/contrib/tcpdump-3.9/af.c b/contrib/tcpdump-3.9/af.c
new file mode 100644 (file)
index 0000000..76d6178
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 1998-2006 The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ *
+ * Original code by Hannes Gredler (hannes@juniper.net)
+ */
+
+#ifndef lint
+static const char rcsid[] _U_ =
+    "@(#) $Header: /tcpdump/master/tcpdump/af.c,v 1.3.2.1 2007/02/26 13:33:17 hannes Exp $ (LBL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+#include "interface.h"
+#include "af.h"
+
+struct tok af_values[] = {
+    { 0,                      "Reserved"},
+    { AFNUM_INET,             "IPv4"},
+    { AFNUM_INET6,            "IPv6"},
+    { AFNUM_NSAP,             "NSAP"},
+    { AFNUM_HDLC,             "HDLC"},
+    { AFNUM_BBN1822,          "BBN 1822"},
+    { AFNUM_802,              "802"},
+    { AFNUM_E163,             "E.163"},
+    { AFNUM_E164,             "E.164"},
+    { AFNUM_F69,              "F.69"},
+    { AFNUM_X121,             "X.121"},
+    { AFNUM_IPX,              "Novell IPX"},
+    { AFNUM_ATALK,            "Appletalk"},
+    { AFNUM_DECNET,           "Decnet IV"},
+    { AFNUM_BANYAN,           "Banyan Vines"},
+    { AFNUM_E164NSAP,         "E.164 with NSAP subaddress"},
+    { AFNUM_L2VPN,            "Layer-2 VPN"},
+    { AFNUM_VPLS,             "VPLS"},
+    { 0, NULL},
+};
+
+struct tok bsd_af_values[] = {
+    { BSD_AFNUM_INET, "IPv4" },
+    { BSD_AFNUM_NS, "NS" },
+    { BSD_AFNUM_ISO, "ISO" },
+    { BSD_AFNUM_APPLETALK, "Appletalk" },
+    { BSD_AFNUM_IPX, "IPX" },
+    { BSD_AFNUM_INET6_BSD, "IPv6" },
+    { BSD_AFNUM_INET6_FREEBSD, "IPv6" },
+    { BSD_AFNUM_INET6_DARWIN, "IPv6" },
+    { 0, NULL}
+};
diff --git a/contrib/tcpdump-3.9/af.h b/contrib/tcpdump-3.9/af.h
new file mode 100644 (file)
index 0000000..1ba7662
--- /dev/null
@@ -0,0 +1,57 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/af.h,v 1.3.2.1 2007/02/26 13:33:17 hannes Exp $ (LBL) */
+
+/*
+ * Copyright (c) 1998-2006 The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ *
+ * Original code by Hannes Gredler (hannes@juniper.net)
+ */
+
+extern struct tok af_values[];
+extern struct tok bsd_af_values[];
+
+/* RFC1700 address family numbers */
+#define AFNUM_INET     1
+#define AFNUM_INET6    2
+#define AFNUM_NSAP     3
+#define AFNUM_HDLC     4
+#define AFNUM_BBN1822  5
+#define AFNUM_802      6
+#define AFNUM_E163     7
+#define AFNUM_E164     8
+#define AFNUM_F69      9
+#define AFNUM_X121     10
+#define AFNUM_IPX      11
+#define AFNUM_ATALK    12
+#define AFNUM_DECNET   13
+#define AFNUM_BANYAN   14
+#define AFNUM_E164NSAP 15
+#define AFNUM_VPLS      25
+/* draft-kompella-ppvpn-l2vpn */
+#define AFNUM_L2VPN     196 /* still to be approved by IANA */
+
+/*
+ * BSD AF_ values.
+ *
+ * Unfortunately, the BSDs don't all use the same value for AF_INET6,
+ * so, because we want to be able to read captures from all of the BSDs,
+ * we check for all of them.
+ */
+#define BSD_AFNUM_INET         2
+#define BSD_AFNUM_NS           6               /* XEROX NS protocols */
+#define BSD_AFNUM_ISO          7
+#define BSD_AFNUM_APPLETALK    16
+#define BSD_AFNUM_IPX          23
+#define BSD_AFNUM_INET6_BSD    24      /* OpenBSD (and probably NetBSD), BSD/OS */
+#define BSD_AFNUM_INET6_FREEBSD        28
+#define BSD_AFNUM_INET6_DARWIN 30
index 2e5d401..1519f2d 100644 (file)
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.15 2003/07/01 19:16:06 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.15.4.1 2007/01/29 20:56:00 guy Exp $ (LBL) */
 /*
  * Bootstrap Protocol (BOOTP).  RFC951 and RFC1048.
  *
@@ -218,3 +218,10 @@ struct cmu_vend {
 
 /* v_flags values */
 #define VF_SMASK       1       /* Subnet mask field contains valid data */
+
+/* RFC 4702 DHCP Client FQDN Option */
+
+#define CLIENT_FQDN_FLAGS_S    0x01
+#define CLIENT_FQDN_FLAGS_O    0x02
+#define CLIENT_FQDN_FLAGS_E    0x04
+#define CLIENT_FQDN_FLAGS_N    0x08
index 98f3db1..f578a43 100644 (file)
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.9.4.2 2005/11/13 12:07:44 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.9.4.3 2007/07/22 20:01:16 guy Exp $ (LBL) */
 /*
  * Copyright (c) 2001
  *     Fortress Technologies
 #define        CTRL_CF_END     0xE
 #define        CTRL_END_ACK    0xF
 
-#define        DATA_DATA               0x0
-#define        DATA_DATA_CF_ACK        0x1
-#define        DATA_DATA_CF_POLL       0x2
-#define        DATA_DATA_CF_ACK_POLL   0x3
-#define        DATA_NODATA             0x4
-#define        DATA_NODATA_CF_ACK      0x5
-#define        DATA_NODATA_CF_POLL     0x6
-#define        DATA_NODATA_CF_ACK_POLL 0x7
+#define        DATA_DATA                       0x0
+#define        DATA_DATA_CF_ACK                0x1
+#define        DATA_DATA_CF_POLL               0x2
+#define        DATA_DATA_CF_ACK_POLL           0x3
+#define        DATA_NODATA                     0x4
+#define        DATA_NODATA_CF_ACK              0x5
+#define        DATA_NODATA_CF_POLL             0x6
+#define        DATA_NODATA_CF_ACK_POLL         0x7
+
+#define DATA_QOS_DATA                  0x8
+#define DATA_QOS_DATA_CF_ACK           0x9
+#define DATA_QOS_DATA_CF_POLL          0xA
+#define DATA_QOS_DATA_CF_ACK_POLL      0xB
+#define DATA_QOS_NODATA                        0xC
+#define DATA_QOS_CF_POLL_NODATA                0xE
+#define DATA_QOS_CF_ACK_POLL_NODATA    0xF
+
+/*
+ * The subtype field of a data frame is, in effect, composed of 4 flag
+ * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
+ * any data), and QoS.
+ */
+#define DATA_FRAME_IS_CF_ACK(x)                ((x) & 0x01)
+#define DATA_FRAME_IS_CF_POLL(x)       ((x) & 0x02)
+#define DATA_FRAME_IS_NULL(x)          ((x) & 0x04)
+#define DATA_FRAME_IS_QOS(x)           ((x) & 0x08)
 
 /*
  * Bits in the frame control field.
index f8c8bc9..49ba87d 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244.2.20 2006/02/08 01:40:09 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244.2.21 2007/03/28 07:45:46 hannes Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -108,6 +108,10 @@ extern char *strsep(char **, const char *);
 #endif
 #endif
 
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+
 extern char *program_name;     /* used to generate self-identifying messages */
 
 extern int32_t thiszone;       /* seconds offset from gmt to local time */
@@ -227,6 +231,7 @@ extern void ns_print(const u_char *, u_int, int);
 extern void ntp_print(const u_char *, u_int);
 extern u_int null_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void ospf_print(const u_char *, u_int, const u_char *);
+extern void olsr_print (const u_char *, u_int);
 extern void pimv1_print(const u_char *, u_int);
 extern void cisco_autorp_print(const u_char *, u_int);
 extern void rsvp_print(const u_char *, u_int);
index c42b137..fc04c67 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.17.2.3 2005/12/01 17:48:25 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.17.2.4 2007/02/08 07:07:51 guy Exp $ (LBL)
  */
 
 /*
  * PIDs for use with OUI_CISCO.
  */
 #define        PID_CISCO_CDP           0x2000  /* Cisco Discovery Protocol */
+#define        PID_CISCO_VTP           0x2003  /* Cisco VLAN Trunk Protocol */
+#define        PID_CISCO_DTP           0x2004  /* Cisco Dynamic Trunk Protocol */
 
 /*
  * PIDs for use with OUI_RFC2684.
index 3d2b5a3..e6391f4 100644 (file)
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.14.4.1 2006/04/07 08:48:09 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.14.4.2 2006/11/10 03:15:35 guy Exp $ (LBL) */
 /*
  * Copyright (c) 1983, 1989, 1993
  *     The Regents of the University of California.  All rights reserved.
  * Internet nameserver port number
  */
 #define NAMESERVER_PORT        53
+
+/*
+ * Port for multicast DNS; see
+ *
+ *     http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt
+ *
+ * for the current mDNS spec.
+ */
 #define MULTICASTDNS_PORT      5353
 
 /*
 #define C_HS           4               /* for Hesiod name server (MIT) (XXX) */
        /* Query class values which do not appear in resource records */
 #define C_ANY          255             /* wildcard match */
-#define C_CACHE_FLUSH  0x8000          /* mDNS cache flush flag */
+#define C_QU           0x8000          /* mDNS QU flag in queries */
+#define C_CACHE_FLUSH  0x8000          /* mDNS cache flush flag in replies */
 
 /*
  * Status return codes for T_UNSPEC conversion routines
index 27a45a5..91a904f 100644 (file)
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.16.2.1 2005/08/23 11:16:30 hannes Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.16.2.2 2006/12/13 08:24:27 hannes Exp $ (LBL) */
 /*
  * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
  *     The Regents of the University of California.  All rights reserved.
@@ -48,6 +48,7 @@
 /* ospf_authtype       */
 #define        OSPF_AUTH_NONE          0       /* No auth-data */
 #define        OSPF_AUTH_SIMPLE        1       /* Simple password */
+#define OSPF_AUTH_SIMPLE_LEN   8       /* max length of simple authentication */
 #define OSPF_AUTH_MD5          2       /* MD5 authentication */
 #define OSPF_AUTH_MD5_LEN      16      /* length of MD5 authentication */
 
index 686d01e..ef1e0ba 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.28 2004/03/25 03:30:55 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.28.2.1 2007/06/15 19:15:04 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -79,6 +79,7 @@ static const char rcsid[] _U_ =
 #define        FHT_SUNOS5      9
 #define        FHT_AIX32       10
 #define        FHT_HPUX9       11
+#define        FHT_BSD44       12
 
 #ifdef ultrix
 /* Nasty hack to keep the Ultrix C compiler from emitting bogus warnings */
@@ -145,6 +146,10 @@ int ourself;               /* true if file handle was generated on this host */
 #endif
 #if    defined(__osf__)
            fhtype = FHT_DECOSF;
+#endif
+#if    defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) \
+     || defined(__OpenBSD__)
+           fhtype = FHT_BSD44;
 #endif
        }
        /*
@@ -196,8 +201,11 @@ int ourself;               /* true if file handle was generated on this host */
                 * could be Ultrix, IRIX5, AIX, or SUNOS5
                 * might be HP-UX (depends on their values for minor devs)
                 */
+               if ((fhp[6] == 0) && (fhp[7] == 0)) {
+                   fhtype = FHT_BSD44;
+               }
                /*XXX we probably only need to test of these two bytes */
-               if ((fhp[21] == 0) && (fhp[23] == 0)) {
+               else if ((fhp[21] == 0) && (fhp[23] == 0)) {
                    fhtype = FHT_ULTRIX;
                }
                else {
@@ -263,6 +271,18 @@ int ourself;               /* true if file handle was generated on this host */
                *osnamep = "Auspex";
            break;
 
+       case FHT_BSD44:
+           fsidp->Fsid_dev.Minor = fhp[0];
+           fsidp->Fsid_dev.Major = fhp[1];
+           fsidp->fsid_code = 0;
+
+           temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
+           *inop = temp;
+
+           if (osnamep)
+               *osnamep = "BSD 4.4";
+           break;
+
        case FHT_DECOSF:
            fsidp->fsid_code = make_uint32(fhp[7], fhp[6], fhp[5], fhp[4]);
                        /* XXX could ignore 3 high-order bytes */
@@ -301,10 +321,16 @@ int ourself;              /* true if file handle was generated on this host */
                *osnamep = "IRIX5";
            break;
 
+#ifdef notdef
        case FHT_SUNOS3:
+           /*
+            * XXX - none of the heuristics above return this.
+            * Are there any SunOS 3.x systems around to care about?
+            */
            if (osnamep)
                *osnamep = "SUNOS3";
            break;
+#endif
 
        case FHT_SUNOS4:
            fsidp->Fsid_dev.Minor = fhp[3];
index 82583dc..21e316d 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.11 2006/06/13 22:25:43 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.15 2007/07/22 23:14:14 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -264,7 +264,7 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset)
 
                        if (pbody->tim.length <= 3)
                                break;
-                       if (pbody->rates.length > sizeof pbody->tim.bitmap)
+                       if (pbody->tim.length - 3 > sizeof pbody->tim.bitmap)
                                return;
                        if (!TTEST2(*(p + offset), pbody->tim.length - 3))
                                return;
@@ -687,22 +687,23 @@ static void
 data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
     const u_int8_t **dstp)
 {
-       switch (FC_SUBTYPE(fc)) {
-       case DATA_DATA:
-       case DATA_NODATA:
-               break;
-       case DATA_DATA_CF_ACK:
-       case DATA_NODATA_CF_ACK:
-               printf("CF Ack ");
-               break;
-       case DATA_DATA_CF_POLL:
-       case DATA_NODATA_CF_POLL:
-               printf("CF Poll ");
-               break;
-       case DATA_DATA_CF_ACK_POLL:
-       case DATA_NODATA_CF_ACK_POLL:
-               printf("CF Ack/Poll ");
-               break;
+       u_int subtype = FC_SUBTYPE(fc);
+
+       if (DATA_FRAME_IS_CF_ACK(subtype) || DATA_FRAME_IS_CF_POLL(subtype) ||
+           DATA_FRAME_IS_QOS(subtype)) {
+               printf("CF ");
+               if (DATA_FRAME_IS_CF_ACK(subtype)) {
+                       if (DATA_FRAME_IS_CF_POLL(subtype))
+                               printf("Ack/Poll");
+                       else
+                               printf("Ack");
+               } else {
+                       if (DATA_FRAME_IS_CF_POLL(subtype))
+                               printf("Poll");
+               }
+               if (DATA_FRAME_IS_QOS(subtype))
+                       printf("+QoS");
+               printf(" ");
        }
 
 #define ADDR1  (p + 4)
@@ -825,6 +826,8 @@ ctrl_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
 static int
 extract_header_length(u_int16_t fc)
 {
+       int len;
+
        switch (FC_TYPE(fc)) {
        case T_MGMT:
                return MGMT_HDRLEN;
@@ -846,7 +849,10 @@ extract_header_length(u_int16_t fc)
                        return 0;
                }
        case T_DATA:
-               return (FC_TO_DS(fc) && FC_FROM_DS(fc)) ? 30 : 24;
+               len = (FC_TO_DS(fc) && FC_FROM_DS(fc)) ? 30 : 24;
+               if (DATA_FRAME_IS_QOS(FC_SUBTYPE(fc)))
+                       len += 2;
+               return len;
        default:
                printf("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc));
                return 0;
@@ -900,8 +906,12 @@ ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
        }
 }
 
+#ifndef roundup2
+#define        roundup2(x, y)  (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
+#endif
+
 static u_int
-ieee802_11_print(const u_char *p, u_int length, u_int caplen)
+ieee802_11_print(const u_char *p, u_int length, u_int caplen, int pad)
 {
        u_int16_t fc;
        u_int hdrlen;
@@ -915,6 +925,8 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen)
 
        fc = EXTRACT_LE_16BITS(p);
        hdrlen = extract_header_length(fc);
+       if (pad)
+               hdrlen = roundup2(hdrlen, 4);
 
        if (caplen < hdrlen) {
                printf("[|802.11]");
@@ -945,6 +957,8 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen)
                }
                break;
        case T_DATA:
+               if (DATA_FRAME_IS_NULL(FC_SUBTYPE(fc)))
+                       return hdrlen;  /* no-data frame */
                /* There may be a problem w/ AP not having this bit set */
                if (FC_WEP(fc)) {
                        if (!wep_print(p)) {
@@ -985,11 +999,11 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen)
 u_int
 ieee802_11_if_print(const struct pcap_pkthdr *h, const u_char *p)
 {
-       return ieee802_11_print(p, h->len, h->caplen);
+       return ieee802_11_print(p, h->len, h->caplen, 0);
 }
 
 static int
-print_radiotap_field(struct cpack_state *s, u_int32_t bit)
+print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad)
 {
        union {
                int8_t          i8;
@@ -1003,6 +1017,10 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit)
 
        switch (bit) {
        case IEEE80211_RADIOTAP_FLAGS:
+               rc = cpack_uint8(s, &u.u8);
+               if (u.u8 & IEEE80211_RADIOTAP_F_DATAPAD)
+                       *pad = 1;
+               break;
        case IEEE80211_RADIOTAP_RATE:
        case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
        case IEEE80211_RADIOTAP_DB_ANTNOISE:
@@ -1125,6 +1143,7 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
        int bit0;
        const u_char *iter;
        u_int len;
+       int pad;
 
        if (caplen < sizeof(*hdr)) {
                printf("[|802.11]");
@@ -1158,6 +1177,8 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
                return caplen;
        }
 
+       /* Assume no Atheros padding between 802.11 header and body */
+       pad = 0;
        for (bit0 = 0, presentp = &hdr->it_present; presentp <= last_presentp;
             presentp++, bit0 += 32) {
                for (present = EXTRACT_LE_32BITS(presentp); present;
@@ -1169,12 +1190,12 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
                        bit = (enum ieee80211_radiotap_type)
                            (bit0 + BITNO_32(present ^ next_present));
 
-                       if (print_radiotap_field(&cpacker, bit) != 0)
+                       if (print_radiotap_field(&cpacker, bit, &pad) != 0)
                                goto out;
                }
        }
 out:
-       return len + ieee802_11_print(p + len, length - len, caplen - len);
+       return len + ieee802_11_print(p + len, length - len, caplen - len, pad);
 #undef BITNO_32
 #undef BITNO_16
 #undef BITNO_8
@@ -1205,7 +1226,7 @@ ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen)
        }
 
        return caphdr_len + ieee802_11_print(p + caphdr_len,
-           length - caphdr_len, caplen - caphdr_len);
+           length - caphdr_len, caplen - caphdr_len, 0);
 }
 
 #define PRISM_HDR_LEN          144
@@ -1244,7 +1265,7 @@ prism_if_print(const struct pcap_pkthdr *h, const u_char *p)
        }
 
        return PRISM_HDR_LEN + ieee802_11_print(p + PRISM_HDR_LEN,
-           length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN);
+           length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN, 0);
 }
 
 /*
index 299beba..34aa798 100644 (file)
@@ -36,7 +36,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.91.2.9 2006/02/02 12:36:46 hannes Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.91.2.12 2007/07/14 22:26:35 guy Exp $";
 #endif
 
 #include <tcpdump-stdinc.h>
@@ -50,6 +50,7 @@ static const char rcsid[] _U_ =
 #include "extract.h"
 #include "bgp.h"
 #include "l2vpn.h"
+#include "af.h"
 
 struct bgp {
        u_int8_t bgp_marker[16];
@@ -339,48 +340,6 @@ static struct tok bgp_safi_values[] = {
 #define BGP_COMMUNITY_NO_ADVERT                        0xffffff02
 #define BGP_COMMUNITY_NO_EXPORT_SUBCONFED      0xffffff03
 
-/* RFC1700 address family numbers */
-#define AFNUM_INET     1
-#define AFNUM_INET6    2
-#define AFNUM_NSAP     3
-#define AFNUM_HDLC     4
-#define AFNUM_BBN1822  5
-#define AFNUM_802      6
-#define AFNUM_E163     7
-#define AFNUM_E164     8
-#define AFNUM_F69      9
-#define AFNUM_X121     10
-#define AFNUM_IPX      11
-#define AFNUM_ATALK    12
-#define AFNUM_DECNET   13
-#define AFNUM_BANYAN   14
-#define AFNUM_E164NSAP 15
-#define AFNUM_VPLS      25
-/* draft-kompella-ppvpn-l2vpn */
-#define AFNUM_L2VPN     196 /* still to be approved by IANA */
-
-static struct tok bgp_afi_values[] = {
-    { 0,                      "Reserved"},
-    { AFNUM_INET,             "IPv4"},
-    { AFNUM_INET6,            "IPv6"},
-    { AFNUM_NSAP,             "NSAP"},
-    { AFNUM_HDLC,             "HDLC"},
-    { AFNUM_BBN1822,          "BBN 1822"},
-    { AFNUM_802,              "802"},
-    { AFNUM_E163,             "E.163"},
-    { AFNUM_E164,             "E.164"},
-    { AFNUM_F69,              "F.69"},
-    { AFNUM_X121,             "X.121"},
-    { AFNUM_IPX,              "Novell IPX"},
-    { AFNUM_ATALK,            "Appletalk"},
-    { AFNUM_DECNET,           "Decnet IV"},
-    { AFNUM_BANYAN,           "Banyan Vines"},
-    { AFNUM_E164NSAP,         "E.164 with NSAP subaddress"},
-    { AFNUM_L2VPN,            "Layer-2 VPN"},
-    { AFNUM_VPLS,             "VPLS"},
-    { 0, NULL},
-};
-
 /* Extended community type - draft-ietf-idr-bgp-ext-communities-05 */
 #define BGP_EXT_COM_RT_0        0x0002  /* Route Target,Format AS(2bytes):AN(4bytes) */
 #define BGP_EXT_COM_RT_1        0x0102  /* Route Target,Format IP address:AN(2bytes) */
@@ -650,6 +609,26 @@ trunc:
        return -2;
 }
 
+/*
+ * As I remember, some versions of systems have an snprintf() that
+ * returns -1 if the buffer would have overflowed.  If the return
+ * value is negative, set buflen to 0, to indicate that we've filled
+ * the buffer up.
+ *
+ * If the return value is greater than buflen, that means that
+ * the buffer would have overflowed; again, set buflen to 0 in
+ * that case.
+ */
+#define UPDATE_BUF_BUFLEN(buf, buflen, strlen) \
+    if (strlen<0) \
+               buflen=0; \
+    else if ((u_int)strlen>buflen) \
+        buflen=0; \
+    else { \
+        buflen-=strlen; \
+       buf+=strlen; \
+    }
+
 static int
 decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
 {
@@ -660,11 +639,13 @@ decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
         tlen=plen;
         pptr+=2;
        TCHECK2(pptr[0],15);
+       buf[0]='\0';
         strlen=snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
                         bgp_vpn_rd_print(pptr),
                         EXTRACT_16BITS(pptr+8),
                         EXTRACT_16BITS(pptr+10),
                         EXTRACT_24BITS(pptr+12)>>4); /* the label is offsetted by 4 bits so lets shift it right */
+        UPDATE_BUF_BUFLEN(buf, buflen, strlen);
         pptr+=15;
         tlen-=15;
 
@@ -680,23 +661,32 @@ decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
 
             switch(tlv_type) {
             case 1:
-                strlen+=snprintf(buf+strlen,buflen-strlen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
-                                 tlv_type,
-                                 tlv_len);
+                if (buflen!=0) {
+                    strlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
+                                    tlv_type,
+                                    tlv_len);
+                    UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+                }
                 ttlv_len=ttlv_len/8+1; /* how many bytes do we need to read ? */
                 while (ttlv_len>0) {
                     TCHECK(pptr[0]);
-                    strlen+=snprintf(buf+strlen,buflen-strlen, "%02x",*pptr++);
+                    if (buflen!=0) {
+                        strlen=snprintf(buf,buflen, "%02x",*pptr++);
+                        UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+                    }
                     ttlv_len--;
                 }
                 break;
             default:
-                snprintf(buf+strlen,buflen-strlen, "\n\t\tunknown TLV #%u, length: %u",
-                         tlv_type,
-                         tlv_len);
+                if (buflen!=0) {
+                    strlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
+                                    tlv_type,
+                                    tlv_len);
+                    UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+                }
                 break;
             }
-            tlen-=(tlv_len<<3); /* the tlv-length is expressed in bits so lets shift it tright */
+            tlen-=(tlv_len<<3); /* the tlv-length is expressed in bits so lets shift it right */
         }
         return plen+2;
 
@@ -1020,7 +1010,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
                safi = tptr[2];
        
                 printf("\n\t    AFI: %s (%u), %sSAFI: %s (%u)",
-                       tok2strbuf(bgp_afi_values, "Unknown AFI", af,
+                       tok2strbuf(af_values, "Unknown AFI", af,
                                  tokbuf, sizeof(tokbuf)),
                        af,
                        (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
@@ -1356,7 +1346,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
                safi = tptr[2];
 
                 printf("\n\t    AFI: %s (%u), %sSAFI: %s (%u)",
-                       tok2strbuf(bgp_afi_values, "Unknown AFI", af,
+                       tok2strbuf(af_values, "Unknown AFI", af,
                                  tokbuf, sizeof(tokbuf)),
                        af,
                        (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
@@ -1548,7 +1538,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
                                          *(tptr+6),
                                          tokbuf, sizeof(tokbuf)),
                                (*(tptr+7) &  BGP_OSPF_RTYPE_METRIC_TYPE) ? "E2" : "",
-                               (*(tptr+6) == (BGP_OSPF_RTYPE_EXT ||BGP_OSPF_RTYPE_NSSA )) ? "E1" : "");
+                               ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : "");
                         break;
                     case BGP_EXT_COM_L2INFO:
                         printf(": %s Control Flags [0x%02x]:MTU %u",
@@ -1685,7 +1675,7 @@ bgp_open_print(const u_char *dat, int length)
                     switch(cap_type) {
                     case BGP_CAPCODE_MP:
                         printf("\n\t\tAFI %s (%u), SAFI %s (%u)",
-                               tok2strbuf(bgp_afi_values, "Unknown",
+                               tok2strbuf(af_values, "Unknown",
                                          EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2),
                                          tokbuf, sizeof(tokbuf)),
                                EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2),
@@ -1702,7 +1692,7 @@ bgp_open_print(const u_char *dat, int length)
                         cap_offset=4;
                         while(tcap_len>=4) {
                             printf("\n\t\t  AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
-                                   tok2strbuf(bgp_afi_values,"Unknown",
+                                   tok2strbuf(af_values,"Unknown",
                                              EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+cap_offset),
                                              tokbuf, sizeof(tokbuf)),
                                    EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+cap_offset),
@@ -1916,7 +1906,7 @@ bgp_notification_print(const u_char *dat, int length)
                tptr = dat + BGP_NOTIFICATION_SIZE;
                TCHECK2(*tptr, 7);
                printf(", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
-                      tok2strbuf(bgp_afi_values, "Unknown",
+                      tok2strbuf(af_values, "Unknown",
                                  EXTRACT_16BITS(tptr), tokbuf, sizeof(tokbuf)),
                       EXTRACT_16BITS(tptr),
                       tok2strbuf(bgp_safi_values, "Unknown", *(tptr+2),
@@ -1950,7 +1940,7 @@ bgp_route_refresh_print(const u_char *pptr, int len) {
         bgp_route_refresh_header = (const struct bgp_route_refresh *)pptr;
 
         printf("\n\t  AFI %s (%u), SAFI %s (%u)",
-               tok2strbuf(bgp_afi_values,"Unknown",
+               tok2strbuf(af_values,"Unknown",
                          /* this stinks but the compiler pads the structure
                           * weird */
                          EXTRACT_16BITS(&bgp_route_refresh_header->afi),
index 88ff849..b3acdf5 100644 (file)
@@ -22,7 +22,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78.2.3 2006/02/13 19:02:05 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78.2.7 2007/01/29 20:56:00 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -42,6 +42,7 @@ static const char rcsid[] _U_ =
 
 static void rfc1048_print(const u_char *);
 static void cmu_print(const u_char *);
+static char *client_fqdn_flags(u_int flags);
 
 static char tstr[] = " [|bootp]";
 
@@ -100,10 +101,10 @@ bootp_print(register const u_char *cp, u_int length)
        if (bp->bp_secs)
                printf(", secs %d", EXTRACT_16BITS(&bp->bp_secs));
 
-       printf(", Flags [ %s ]",
-              bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags)));
-       if (vflag>1)
-         printf( " (0x%04x)", EXTRACT_16BITS(&bp->bp_flags));
+       printf(", Flags [%s]",
+               bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags)));
+       if (vflag > 1)
+               printf(" (0x%04x)", EXTRACT_16BITS(&bp->bp_flags));
 
        /* Client's ip address */
        TCHECK(bp->bp_ciaddr);
@@ -374,11 +375,11 @@ rfc1048_print(register const u_char *bp)
        bp += sizeof(int32_t);
 
        /* Loop while we there is a tag left in the buffer */
-       while (bp + 1 < snapend) {
+       while (TTEST2(*bp, 1)) {
                tag = *bp++;
-               if (tag == TAG_PAD)
+               if (tag == TAG_PAD && vflag < 3)
                        continue;
-               if (tag == TAG_END)
+               if (tag == TAG_END && vflag < 3)
                        return;
                if (tag == TAG_EXTENDED_OPTION) {
                        TCHECK2(*(bp + 1), 2);
@@ -392,17 +393,29 @@ rfc1048_print(register const u_char *bp)
                        cp = tok2str(tag2str, "?T%u", tag);
                c = *cp++;
 
-               /* Get the length; check for truncation */
-               if (bp + 1 >= snapend) {
-                       fputs(tstr, stdout);
-                       return;
+               if (tag == TAG_PAD || tag == TAG_END)
+                       len = 0;
+               else {
+                       /* Get the length; check for truncation */
+                       TCHECK2(*bp, 1);
+                       len = *bp++;
                }
-               len = *bp++;
 
-               printf("\n\t    %s Option %u, length %u: ", cp, tag, len);
+               printf("\n\t    %s Option %u, length %u%s", cp, tag, len,
+                   len > 0 ? ": " : "");
+
+               if (tag == TAG_PAD && vflag > 2) {
+                       u_int ntag = 1;
+                       while (TTEST2(*bp, 1) && *bp == TAG_PAD) {
+                               bp++;
+                               ntag++;
+                       }
+                       if (ntag > 1)
+                               printf(", occurs %u", ntag);
+               }
 
-               if (bp + len >= snapend) {
-                       printf("[|bootp %u]", len);
+               if (!TTEST2(*bp, len)) {
+                       printf("[|rfc1048 %u]", len);
                        return;
                }
 
@@ -413,22 +426,20 @@ rfc1048_print(register const u_char *bp)
                }
 
                if (tag == TAG_PARM_REQUEST) {
-                       first = 1;
-                        idx = 0;
-                        printf("\n\t      ");
+                       idx = 0;
                        while (len-- > 0) {
                                uc = *bp++;
                                cp = tok2str(tag2str, "?Option %u", uc);
-                               printf("%s%s", (first || (!(idx %4))) ? "" : ", ", cp + 1);
-
-                                if ((idx %4) == 3) {
-                                    printf("\n\t      ");
-                                }
-                               first = 0;
-                                idx ++;
+                               if (idx % 4 == 0)
+                                       printf("\n\t      ");
+                               else
+                                       printf(", ");
+                               printf("%s", cp + 1);
+                               idx++;
                        }
                        continue;
                }
+
                if (tag == TAG_EXTENDED_REQUEST) {
                        first = 1;
                        while (len > 1) {
@@ -576,15 +587,16 @@ rfc1048_print(register const u_char *bp)
                                break;
 
                        case TAG_CLIENT_FQDN:
-                               /* option 81 should be at least 4 bytes long */
-                               if (len < 4)  {
-                                        printf("ERROR: options 81 len %u < 4 bytes", len);
+                               /* option 81 should be at least 3 bytes long */
+                               if (len < 3)  {
+                                       printf("ERROR: option 81 len %u < 3 bytes", len);
                                        break;
                                }
-                               if (*bp++)
-                                       printf("[svrreg]");
                                if (*bp)
-                                       printf("%u/%u/", *bp, *(bp+1));
+                                       printf("[%s] ", client_fqdn_flags(*bp));
+                               bp++;
+                               if (*bp || *(bp+1))
+                                       printf("%u/%u ", *bp, *(bp+1));
                                bp += 2;
                                putchar('"');
                                if (fn_printn(bp, size - 3, snapend)) {
@@ -704,3 +716,22 @@ trunc:
        fputs(tstr, stdout);
 #undef PRINTCMUADDR
 }
+
+static char *
+client_fqdn_flags(u_int flags)
+{
+       static char buf[8+1];
+       int i = 0;
+
+       if (flags & CLIENT_FQDN_FLAGS_S)
+               buf[i++] = 'S';
+       if (flags & CLIENT_FQDN_FLAGS_O)
+               buf[i++] = 'O';
+       if (flags & CLIENT_FQDN_FLAGS_E)
+               buf[i++] = 'E';
+       if (flags & CLIENT_FQDN_FLAGS_N)
+               buf[i++] = 'N';
+       buf[i] = '\0';
+
+       return buf;
+}
index b304f87..9f4999d 100644 (file)
  *  RFC3319,
  *  RFC3633,
  *  RFC3646,
- *  draft-ietf-dhc-dhcpv6-opt-timeconfig-03.txt,
- *  draft-ietf-dhc-lifetime-00.txt,
+ *  RFC3898,
+ *  RFC4075,
+ *  RFC4242,
+ *  RFC4280,
  */
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.35 2004/07/06 22:16:03 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.35.2.1 2006/10/25 22:04:36 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -104,8 +106,8 @@ struct dhcp6_relay {
 #define DH6OPT_CLIENTID        1
 #define DH6OPT_SERVERID        2
 #define DH6OPT_IA_NA 3
-#define DH6OPT_IA_TMP 4
-#define DH6OPT_IADDR 5
+#define DH6OPT_IA_TA 4
+#define DH6OPT_IA_ADDR 5
 #define DH6OPT_ORO 6
 #define DH6OPT_PREFERENCE 7
 #  define DH6OPT_PREF_MAX 255
@@ -141,21 +143,18 @@ struct dhcp6_relay {
 #define DH6OPT_DNSNAME 24
 #define DH6OPT_IA_PD 25
 #define DH6OPT_IA_PD_PREFIX 26
-
-/*
- * The old prefix delegation option used in the service specification document
- * (200206xx version) by NTT Communications.
- */
-#define DH6OPT_PREFIX_DELEGATION 30
-#define DH6OPT_PREFIX_INFORMATION 31
-#define DH6OPT_PREFIX_REQUEST 32
-
-/*
- * The following one is an unassigned number.
- * We temporarily use values as of KAME snap 20040322.
- */
-#define DH6OPT_NTP_SERVERS 35
-#define DH6OPT_LIFETIME 36
+#define DH6OPT_NIS_SERVERS 27
+#define DH6OPT_NISP_SERVERS 28
+#define DH6OPT_NIS_NAME 29
+#define DH6OPT_NISP_NAME 30
+#define DH6OPT_NTP_SERVERS 31
+#define DH6OPT_LIFETIME 32
+#define DH6OPT_BCMCS_SERVER_D 33
+#define DH6OPT_BCMCS_SERVER_A 34
+#define DH6OPT_GEOCONF_CIVIC 36
+#define DH6OPT_REMOTE_ID 37
+#define DH6OPT_SUBSCRIBER_ID 38
+#define DH6OPT_CLIENT_FQDN 39
 
 struct dhcp6opt {
        u_int16_t dh6opt_type;
@@ -171,6 +170,14 @@ struct dhcp6_ia {
        u_int32_t dh6opt_ia_t2;
 };
 
+struct dhcp6_ia_addr {
+       u_int16_t dh6opt_ia_addr_type;
+       u_int16_t dh6opt_ia_addr_len;
+       struct in6_addr dh6opt_ia_addr_addr;
+       u_int32_t dh6opt_ia_addr_pltime;
+       u_int32_t dh6opt_ia_addr_vltime;
+}  __attribute__ ((__packed__));
+
 struct dhcp6_ia_prefix {
        u_int16_t dh6opt_ia_prefix_type;
        u_int16_t dh6opt_ia_prefix_len;
@@ -205,6 +212,10 @@ dhcp6opt_name(int type)
                return "server ID";
        case DH6OPT_IA_NA:
                return "IA_NA";
+       case DH6OPT_IA_TA:
+               return "IA_TA";
+       case DH6OPT_IA_ADDR:
+               return "IA_ADDR";
        case DH6OPT_ORO:
                return "option request";
        case DH6OPT_PREFERENCE:
@@ -241,10 +252,6 @@ dhcp6opt_name(int type)
                return "DNS";
        case DH6OPT_DNSNAME:
                return "DNS name";
-       case DH6OPT_PREFIX_DELEGATION:
-               return "prefix delegation";
-       case DH6OPT_PREFIX_INFORMATION:
-               return "prefix information";
        case DH6OPT_IA_PD:
                return "IA_PD";
        case DH6OPT_IA_PD_PREFIX:
@@ -253,6 +260,26 @@ dhcp6opt_name(int type)
                return "NTP Server";
        case DH6OPT_LIFETIME:
                return "lifetime";
+       case DH6OPT_NIS_SERVERS:
+               return "NIS server";
+       case DH6OPT_NISP_SERVERS:
+               return "NIS+ server";
+       case DH6OPT_NIS_NAME:
+               return "NIS domain name";
+       case DH6OPT_NISP_NAME:
+               return "NIS+ domain name";
+       case DH6OPT_BCMCS_SERVER_D:
+               return "BCMCS domain name";
+       case DH6OPT_BCMCS_SERVER_A:
+               return "BCMCS server";
+       case DH6OPT_GEOCONF_CIVIC:
+               return "Geoconf Civic";
+       case DH6OPT_REMOTE_ID:
+               return "Remote ID";
+       case DH6OPT_SUBSCRIBER_ID:
+               return "Subscriber ID";
+       case DH6OPT_CLIENT_FQDN:
+               return "Client FQDN";
        default:
                snprintf(genstr, sizeof(genstr), "opt_%d", type);
                return(genstr);
@@ -298,9 +325,9 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
        size_t optlen;
        u_int16_t val16;
        u_int32_t val32;
-       struct in6_addr addr6;
        struct dhcp6_ia ia;
        struct dhcp6_ia_prefix ia_prefix;
+       struct dhcp6_ia_addr ia_addr;
        struct dhcp6_auth authopt;
        u_int authinfolen, authrealmlen;
 
@@ -369,6 +396,29 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
                                break;
                        }
                        break;
+               case DH6OPT_IA_ADDR:
+                       if (optlen < sizeof(ia_addr) - 4) {
+                               printf(" ?)");
+                               break;
+                       }
+                       memcpy(&ia_addr, (u_char *)dh6o, sizeof(ia_addr));
+                       printf(" %s",
+                           ip6addr_string(&ia_addr.dh6opt_ia_addr_addr));
+                       ia_addr.dh6opt_ia_addr_pltime =
+                           ntohl(ia_addr.dh6opt_ia_addr_pltime);
+                       ia_addr.dh6opt_ia_addr_vltime =
+                           ntohl(ia_addr.dh6opt_ia_addr_vltime);
+                       printf(" pltime:%lu vltime:%lu",
+                           (unsigned long)ia_addr.dh6opt_ia_addr_pltime,
+                           (unsigned long)ia_addr.dh6opt_ia_addr_vltime);
+                       if (optlen > sizeof(ia_addr) - 4) {
+                               /* there are sub-options */
+                               dhcp6opt_print((u_char *)dh6o +
+                                   sizeof(ia_addr),
+                                   (u_char *)(dh6o + 1) + optlen);
+                       }
+                       printf(")");
+                       break;
                case DH6OPT_ORO:
                        if (optlen % 2) {
                                printf(" ?)");
@@ -526,6 +576,9 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
                case DH6OPT_SIP_SERVER_A:
                case DH6OPT_DNS:
                case DH6OPT_NTP_SERVERS:
+               case DH6OPT_NIS_SERVERS:
+               case DH6OPT_NISP_SERVERS:
+               case DH6OPT_BCMCS_SERVER_A:
                        if (optlen % 16) {
                                printf(" ?)");
                                break;
@@ -535,25 +588,6 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
                                printf(" %s", ip6addr_string(&tp[i]));
                        printf(")");
                        break;
-               case DH6OPT_PREFIX_DELEGATION:
-                       dhcp6opt_print((u_char *)(dh6o + 1),
-                           (u_char *)(dh6o + 1) + optlen);
-                       printf(")");
-                       break;
-               case DH6OPT_PREFIX_INFORMATION:
-                       if (optlen % 21)
-                               printf(" ?)");
-                       memcpy(&addr6, (u_char *)(dh6o + 1) + 5,
-                           sizeof(addr6));
-                       printf(" %s/%d", ip6addr_string(&addr6),
-                           (int)*((u_char *)(dh6o + 1) + 4));
-                       memcpy(&val32, dh6o + 1, sizeof(val32));
-                       val32 = ntohl(val32);
-                       if (val32 == DHCP6_DURATITION_INFINITE)
-                               printf(" lease-duration: infinite)");
-                       else
-                               printf(" lease-duration: %u)", val32);
-                       break;
                case DH6OPT_STATUS_CODE:
                        if (optlen < 2) {
                                printf(" ?)");
index cc8f0c0..d4a35d8 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.89.2.3 2006/04/07 08:58:43 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.89.2.8 2007/02/13 19:19:27 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -320,23 +320,32 @@ static const u_char *
 ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns)
 {
        register const u_char *np = cp;
-       register u_int i;
+       register u_int i, class;
 
        cp = ns_nskip(cp);
 
        if (cp == NULL || !TTEST2(*cp, 4))
                return(NULL);
 
-       /* print the qtype and qclass (if it's not IN) */
+       /* print the qtype */
        i = EXTRACT_16BITS(cp);
        cp += 2;
        printf(" %s", tok2str(ns_type2str, "Type%d", i));
+       /* print the qclass (if it's not IN) */
        i = EXTRACT_16BITS(cp);
        cp += 2;
-       if (is_mdns && i == (C_IN|C_CACHE_FLUSH))
-               printf(" (Cache flush)");
-       else if (i != C_IN)
-               printf(" %s", tok2str(ns_class2str, "(Class %d)", i));
+       if (is_mdns)
+               class = (i & ~C_QU);
+       else
+               class = i;
+       if (class != C_IN)
+               printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
+       if (is_mdns) {
+               if (i & C_QU)
+                       printf(" (QU)");
+               else
+                       printf(" (QM)");
+       }
 
        fputs("? ", stdout);
        cp = ns_nprint(np, bp);
@@ -347,7 +356,7 @@ ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns)
 static const u_char *
 ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
 {
-       register u_int class, opt_flags = 0;
+       register u_int i, class, opt_flags = 0;
        register u_short typ, len;
        register const u_char *rp;
 
@@ -361,15 +370,22 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
        if (cp == NULL || !TTEST2(*cp, 10))
                return (snapend);
 
-       /* print the type/qtype and class (if it's not IN) */
+       /* print the type/qtype */
        typ = EXTRACT_16BITS(cp);
        cp += 2;
-       class = EXTRACT_16BITS(cp);
+       /* print the class (if it's not IN and the type isn't OPT) */
+       i = EXTRACT_16BITS(cp);
        cp += 2;
-       if (is_mdns && class == (C_IN|C_CACHE_FLUSH))
-               printf(" (Cache flush)");
-       else if (class != C_IN && typ != T_OPT)
+       if (is_mdns)
+               class = (i & ~C_CACHE_FLUSH);
+       else
+               class = i;
+       if (class != C_IN && typ != T_OPT)
                printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
+       if (is_mdns) {
+               if (i & C_CACHE_FLUSH)
+                       printf(" (Cache flush)");
+       }
 
        /* ignore ttl */
        cp += 2;
@@ -558,7 +574,7 @@ ns_print(register const u_char *bp, u_int length, int is_mdns)
 
        if (DNS_QR(np)) {
                /* this is a response */
-               printf(" %d%s%s%s%s%s%s",
+               printf("%d%s%s%s%s%s%s",
                        EXTRACT_16BITS(&np->id),
                        ns_ops[DNS_OPCODE(np)],
                        ns_resp[DNS_RCODE(np)],
@@ -626,7 +642,7 @@ ns_print(register const u_char *bp, u_int length, int is_mdns)
        }
        else {
                /* this is a request */
-               printf(" %d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)],
+               printf("%d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)],
                    DNS_RD(np) ? "+" : "",
                    DNS_CD(np) ? "%" : "");
 
index 191005c..5197811 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.81.2.2 2005/07/01 16:13:37 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.81.2.4 2006/12/12 14:33:20 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -62,20 +62,12 @@ struct icmp {
                        u_int16_t icd_seq;
                } ih_idseq;
                u_int32_t ih_void;
-
-               /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
-               struct ih_pmtu {
-                       u_int16_t ipm_void;
-                       u_int16_t ipm_nextmtu;
-               } ih_pmtu;
        } icmp_hun;
 #define        icmp_pptr       icmp_hun.ih_pptr
 #define        icmp_gwaddr     icmp_hun.ih_gwaddr
 #define        icmp_id         icmp_hun.ih_idseq.icd_id
 #define        icmp_seq        icmp_hun.ih_idseq.icd_seq
 #define        icmp_void       icmp_hun.ih_void
-#define        icmp_pmvoid     icmp_hun.ih_pmtu.ipm_void
-#define        icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu
        union {
                struct id_ts {
                        u_int32_t its_otime;
@@ -86,12 +78,6 @@ struct icmp {
                        struct ip idi_ip;
                        /* options and then 64 bits of data */
                } id_ip;
-                struct mpls_ext {
-                    u_int8_t legacy_header[128]; /* extension header starts 128 bytes after ICMP header */
-                    u_int8_t version_res[2];
-                    u_int8_t checksum[2];
-                    u_int8_t data[1];
-                } mpls_ext;
                u_int32_t id_mask;
                u_int8_t id_data[1];
        } icmp_dun;
@@ -101,9 +87,6 @@ struct icmp {
 #define        icmp_ip         icmp_dun.id_ip.idi_ip
 #define        icmp_mask       icmp_dun.id_mask
 #define        icmp_data       icmp_dun.id_data
-#define        icmp_mpls_ext_version   icmp_dun.mpls_ext.version_res
-#define        icmp_mpls_ext_checksum  icmp_dun.mpls_ext.checksum
-#define        icmp_mpls_ext_data      icmp_dun.mpls_ext.data
 };
 
 #define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4) 
@@ -118,7 +101,7 @@ struct icmp {
  * ip header length.
  */
 #define        ICMP_MINLEN     8                               /* abs minimum */
-#define ICMP_EXTD_MINLEN (156 - sizeof (struct ip))     /* draft-bonica-icmp-mpls-02 */
+#define ICMP_EXTD_MINLEN (156 - sizeof (struct ip))     /* draft-bonica-internet-icmp-08 */
 #define        ICMP_TSLEN      (8 + 3 * sizeof (u_int32_t))    /* timestamp */
 #define        ICMP_MASKLEN    12                              /* address mask */
 #define        ICMP_ADVLENMIN  (8 + sizeof (struct ip) + 8)    /* min */
@@ -173,7 +156,9 @@ struct icmp {
        (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
        (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
 #define        ICMP_MPLS_EXT_TYPE(type) \
-       ((type) == ICMP_UNREACH || (type) == ICMP_TIMXCEED)
+       ((type) == ICMP_UNREACH || \
+         (type) == ICMP_TIMXCEED || \
+         (type) == ICMP_PARAMPROB)
 /* rfc1700 */
 #ifndef ICMP_UNREACH_NET_UNKNOWN
 #define ICMP_UNREACH_NET_UNKNOWN       6       /* destination net unknown */
@@ -276,7 +261,48 @@ struct id_rdiscovery {
        u_int32_t ird_pref;
 };
 
-/* draft-bonica-icmp-mpls-02 */
+/*
+ * draft-bonica-internet-icmp-08
+ *
+ * The Destination Unreachable, Time Exceeded
+ * and Parameter Problem messages are slighly changed as per
+ * the above draft. A new Length field gets added to give
+ * the caller an idea about the length of the piggypacked
+ * IP packet before the MPLS extension header starts.
+ *
+ * The Length field represents length of the padded "original datagram"
+ * field  measured in 32-bit words.
+ *
+ * 0                   1                   2                   3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |     Type      |     Code      |          Checksum             |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |     unused    |    Length     |          unused               |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |      Internet Header + leading octets of original datagram    |
+ * |                                                               |
+ * |                           //                                  |
+ * |                                                               |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+struct icmp_ext_t {
+    u_int8_t icmp_type;
+    u_int8_t icmp_code;
+    u_int8_t icmp_checksum[2];
+    u_int8_t icmp_reserved;
+    u_int8_t icmp_length;
+    u_int8_t icmp_reserved2[2];
+    u_int8_t icmp_ext_legacy_header[128]; /* extension header starts 128 bytes after ICMP header */
+    u_int8_t icmp_ext_version_res[2];
+    u_int8_t icmp_ext_checksum[2];
+    u_int8_t icmp_ext_data[1];
+};
+
+struct icmp_mpls_ext_common_header_t {
+};
+
 struct icmp_mpls_ext_object_header_t {
     u_int8_t length[2];
     u_int8_t class_num;
@@ -312,17 +338,20 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
 {
        char *cp;
        const struct icmp *dp;
+        const struct icmp_ext_t *ext_dp;
        const struct ip *ip;
        const char *str, *fmt;
        const struct ip *oip;
        const struct udphdr *ouh;
         const u_int8_t *obj_tptr;
         u_int32_t raw_label;
+        const u_char *snapend_save;
        const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header;
        u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype;
        char buf[MAXHOSTNAMELEN + 100];
 
        dp = (struct icmp *)bp;
+        ext_dp = (struct icmp_ext_t *)bp;
        ip = (struct ip *)bp2;
        str = buf;
 
@@ -544,35 +573,61 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
                        }
                }
        }
+
+        /*
+         * print the remnants of the IP packet.
+         * save the snaplength as this may get overidden in the IP printer.
+         */
        if (vflag >= 1 && !ICMP_INFOTYPE(dp->icmp_type)) {
                bp += 8;
                (void)printf("\n\t");
                ip = (struct ip *)bp;
                snaplen = snapend - bp;
+                snapend_save = snapend;
                ip_print(gndo, bp, EXTRACT_16BITS(&ip->ip_len));
+                snapend = snapend_save;
        }
 
+        /*
+         * Attempt to decode the MPLS extensions only for some ICMP types.
+         */
         if (vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) {
 
-            TCHECK(*(dp->icmp_mpls_ext_version));
-            printf("\n\tMPLS extension v%u",ICMP_MPLS_EXT_EXTRACT_VERSION(*(dp->icmp_mpls_ext_version)));
+            TCHECK(*ext_dp);
+
+            /*
+             * Check first if the mpls extension header shows a non-zero length.
+             * If the length field is not set then silently verify the checksum
+             * to check if an extension header is present. This is expedient,
+             * however not all implementations set the length field proper.
+             */
+            if (!ext_dp->icmp_length &&
+                in_cksum((const u_short *)&ext_dp->icmp_ext_version_res,
+                         plen - ICMP_EXTD_MINLEN, 0)) {
+                return;
+            }
+
+            printf("\n\tMPLS extension v%u",
+                   ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)));
             
             /*
              * Sanity checking of the header.
              */
-            if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(dp->icmp_mpls_ext_version)) != ICMP_MPLS_EXT_VERSION) {
+            if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)) !=
+                ICMP_MPLS_EXT_VERSION) {
                 printf(" packet not supported");
                 return;
             }
 
             hlen = plen - ICMP_EXTD_MINLEN;
-            TCHECK2(*(dp->icmp_mpls_ext_checksum), 2);
-            printf(", checksum 0x%04x (unverified), length %u", /* FIXME */
-                   EXTRACT_16BITS(dp->icmp_mpls_ext_checksum),
+            printf(", checksum 0x%04x (%scorrect), length %u",
+                   EXTRACT_16BITS(ext_dp->icmp_ext_checksum),
+                   in_cksum((const u_short *)&ext_dp->icmp_ext_version_res,
+                            plen - ICMP_EXTD_MINLEN, 0) ? "in" : "",
                    hlen);
 
             hlen -= 4; /* subtract common header size */
-            obj_tptr = (u_int8_t *)dp->icmp_mpls_ext_data;
+            obj_tptr = (u_int8_t *)ext_dp->icmp_ext_data;
 
             while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) {
 
@@ -590,8 +645,12 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
                        obj_tlen);
 
                 hlen-=sizeof(struct icmp_mpls_ext_object_header_t); /* length field includes tlv header */
-                if (obj_tlen < sizeof(struct icmp_mpls_ext_object_header_t))
-                    break;
+
+                /* infinite loop protection */                
+                if ((obj_class_num == 0) ||
+                    (obj_tlen < sizeof(struct icmp_mpls_ext_object_header_t))) {
+                    return;
+                }
                 obj_tlen-=sizeof(struct icmp_mpls_ext_object_header_t);
 
                 switch (obj_class_num) {
index 40bf46e..f054691 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.149.2.6 2006/02/19 05:01:07 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.149.2.8 2007/01/29 20:57:47 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -633,7 +633,7 @@ ip_print(netdissect_options *ndo,
             }
 
             if (ipds->ip->ip_ttl >= 1)
-                (void)printf(", ttl %3u", ipds->ip->ip_ttl);    
+                (void)printf(", ttl %u", ipds->ip->ip_ttl);    
 
            /*
             * for the firewall guys, print id, offset.
@@ -641,14 +641,14 @@ ip_print(netdissect_options *ndo,
             * For unfragmented datagrams, note the don't fragment flag.
             */
 
-           (void)printf(", id %u, offset %u, flags [%s], proto: %s (%u)",
+           (void)printf(", id %u, offset %u, flags [%s], proto %s (%u)",
                          EXTRACT_16BITS(&ipds->ip->ip_id),
                          (ipds->off & 0x1fff) * 8,
-                         bittok2str(ip_frag_values, "none", ipds->off&0xe000 ),
+                         bittok2str(ip_frag_values, "none", ipds->off&0xe000),
                          tok2str(ipproto_values,"unknown",ipds->ip->ip_p),
                          ipds->ip->ip_p);
 
-            (void)printf(", length: %u", EXTRACT_16BITS(&ipds->ip->ip_len));
+            (void)printf(", length %u", EXTRACT_16BITS(&ipds->ip->ip_len));
 
             if ((hlen - sizeof(struct ip)) > 0) {
                 printf(", options (");
index fa0aa25..d3935fc 100644 (file)
@@ -26,7 +26,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133.2.23 2006/06/16 18:22:56 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133.2.25 2007/03/02 09:20:27 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -475,7 +475,7 @@ static struct tok isis_lsp_istype_values[] = {
     { ISIS_LSP_TYPE_UNUSED0,   "Unused 0x0 (invalid)"},
     { ISIS_LSP_TYPE_LEVEL_1,   "L1 IS"},
     { ISIS_LSP_TYPE_UNUSED2,   "Unused 0x2 (invalid)"},
-    { ISIS_LSP_TYPE_LEVEL_2,   "L1L2 IS"},
+    { ISIS_LSP_TYPE_LEVEL_2,   "L2 IS"},
     { 0, NULL }
 };
 
@@ -2247,13 +2247,14 @@ static int isis_print (const u_int8_t *p, u_int length)
            break;
 
         case ISIS_TLV_MT_IP_REACH:
-           while (tmp>0) {
-                mt_len = isis_print_mtid(tptr, "\n\t      ");
-                if (mt_len == 0) /* did something go wrong ? */
-                    goto trunctlv;
-                tptr+=mt_len;
-                tmp-=mt_len;
+            mt_len = isis_print_mtid(tptr, "\n\t      ");
+            if (mt_len == 0) { /* did something go wrong ? */
+                goto trunctlv;
+            }
+            tptr+=mt_len;
+            tmp-=mt_len;
 
+            while (tmp>0) {
                 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", IPV4);
                 if (ext_ip_len == 0) /* did something go wrong ? */
                     goto trunctlv;
@@ -2274,13 +2275,14 @@ static int isis_print (const u_int8_t *p, u_int length)
            break;
 
        case ISIS_TLV_MT_IP6_REACH:
-           while (tmp>0) {
-                mt_len = isis_print_mtid(tptr, "\n\t      ");
-                if (mt_len == 0) /* did something go wrong ? */
-                    goto trunctlv;
-                tptr+=mt_len;
-                tmp-=mt_len;
+            mt_len = isis_print_mtid(tptr, "\n\t      ");
+            if (mt_len == 0) { /* did something go wrong ? */
+                goto trunctlv;
+            }
+            tptr+=mt_len;
+            tmp-=mt_len;
 
+           while (tmp>0) {
                 ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", IPV6);
                 if (ext_ip_len == 0) /* did something go wrong ? */
                     goto trunctlv;
index deb8a94..3280d8c 100644 (file)
@@ -16,7 +16,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.8.2.9 2006/06/23 02:07:27 hannes Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.8.2.10 2007/02/26 13:31:33 hannes Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -33,6 +33,7 @@ static const char rcsid[] _U_ =
 #include "decode_prefix.h"
 #include "extract.h"
 #include "addrtoname.h"
+#include "af.h"
 
 #include "l2vpn.h"
 
@@ -214,10 +215,6 @@ static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = {
     { 0, NULL}
 };
 
-/* RFC1700 address family numbers, same definition in print-bgp.c */
-/* FIXME: move all AF stuff into dedicated files */
-#define AFNUM_INET     1
-#define AFNUM_INET6    2
 #define AFNUM_LEN       2 
 
 int ldp_msg_print(register const u_char *);
index 4c9fc4f..bc41985 100644 (file)
@@ -24,7 +24,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61.2.9 2006/01/17 17:44:46 hannes Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61.2.10 2007/02/08 07:07:51 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -103,6 +103,8 @@ static const struct tok llc_supervisory_values[] = {
 
 static const struct tok cisco_values[] = { 
        { PID_CISCO_CDP, "CDP" },
+       { PID_CISCO_VTP, "VTP" },
+       { PID_CISCO_DTP, "DTP" },
        { 0,             NULL }
 };
 
index a702170..45e8869 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.106.2.2 2005/05/06 07:57:18 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.106.2.4 2007/06/15 23:17:40 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -287,8 +287,12 @@ nfsreply_print(register const u_char *bp, u_int length,
               register const u_char *bp2)
 {
        register const struct sunrpc_msg *rp;
-       u_int32_t proc, vers;
+       u_int32_t proc, vers, reply_stat;
        char srcid[20], dstid[20];      /*fits 32bit*/
+       enum sunrpc_reject_stat rstat;
+       u_int32_t rlow;
+       u_int32_t rhigh;
+       enum sunrpc_auth_stat rwhy;
 
        nfserr = 0;             /* assume no error */
        rp = (const struct sunrpc_msg *)bp;
@@ -303,13 +307,83 @@ nfsreply_print(register const u_char *bp, u_int length,
                    EXTRACT_32BITS(&rp->rm_xid));
        }
        print_nfsaddr(bp2, srcid, dstid);
-       (void)printf("reply %s %d",
-            EXTRACT_32BITS(&rp->rm_reply.rp_stat) == SUNRPC_MSG_ACCEPTED?
-                    "ok":"ERR",
-            length);
+       reply_stat = EXTRACT_32BITS(&rp->rm_reply.rp_stat);
+       switch (reply_stat) {
 
-       if (xid_map_find(rp, bp2, &proc, &vers) >= 0)
-               interp_reply(rp, proc, vers, length);
+       case SUNRPC_MSG_ACCEPTED:
+               (void)printf("reply ok %u", length);
+               if (xid_map_find(rp, bp2, &proc, &vers) >= 0)
+                       interp_reply(rp, proc, vers, length);
+               break;
+
+       case SUNRPC_MSG_DENIED:
+               (void)printf("reply ERR %u: ", length);
+               rstat = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_stat);
+               switch (rstat) {
+
+               case SUNRPC_RPC_MISMATCH:
+                       rlow = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.low);
+                       rhigh = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.high);
+                       (void)printf("RPC Version mismatch (%u-%u)",
+                           rlow, rhigh);
+                       break;
+
+               case SUNRPC_AUTH_ERROR:
+                       rwhy = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_why);
+                       (void)printf("Auth ");
+                       switch (rwhy) {
+
+                       case SUNRPC_AUTH_OK:
+                               (void)printf("OK");
+                               break;
+
+                       case SUNRPC_AUTH_BADCRED:
+                               (void)printf("Bogus Credentials (seal broken)");
+                               break;
+
+                       case SUNRPC_AUTH_REJECTEDCRED:
+                               (void)printf("Rejected Credentials (client should begin new session)");
+                               break;
+
+                       case SUNRPC_AUTH_BADVERF:
+                               (void)printf("Bogus Verifier (seal broken)");
+                               break;
+
+                       case SUNRPC_AUTH_REJECTEDVERF:
+                               (void)printf("Verifier expired or was replayed");
+                               break;
+
+                       case SUNRPC_AUTH_TOOWEAK:
+                               (void)printf("Credentials are too weak");
+                               break;
+
+                       case SUNRPC_AUTH_INVALIDRESP:
+                               (void)printf("Bogus response verifier");
+                               break;
+
+                       case SUNRPC_AUTH_FAILED:
+                               (void)printf("Unknown failure");
+                               break;
+
+                       default:
+                               (void)printf("Invalid failure code %u",
+                                   (unsigned int)rwhy);
+                               break;
+                       }
+                       break;
+
+               default:
+                       (void)printf("Unknown reason for rejecting rpc message %u",
+                           (unsigned int)rstat);
+                       break;
+               }
+               break;
+
+       default:
+               (void)printf("reply Unknown rpc response code=%u %u",
+                   reply_stat, length);
+               break;
+       }
 }
 
 /*
index 7fd4541..3d203da 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.3 2005/07/07 01:24:38 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.4 2007/02/26 13:31:33 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -36,6 +36,7 @@ static const char rcsid[] _U_ =
 
 #include "interface.h"
 #include "addrtoname.h"
+#include "af.h"
 
 #include "ip.h"
 #ifdef INET6
@@ -54,34 +55,6 @@ static const char rcsid[] _U_ =
  */
 #define        NULL_HDRLEN 4
 
-/*
- * BSD AF_ values.
- *
- * Unfortunately, the BSDs don't all use the same value for AF_INET6,
- * so, because we want to be able to read captures from all of the BSDs,
- * we check for all of them.
- */
-#define BSD_AF_INET            2
-#define BSD_AF_NS              6               /* XEROX NS protocols */
-#define BSD_AF_ISO             7
-#define BSD_AF_APPLETALK       16
-#define BSD_AF_IPX             23
-#define BSD_AF_INET6_BSD       24      /* OpenBSD (and probably NetBSD), BSD/OS */
-#define BSD_AF_INET6_FREEBSD   28
-#define BSD_AF_INET6_DARWIN    30
-
-const struct tok bsd_af_values[] = {
-        { BSD_AF_INET, "IPv4" },
-        { BSD_AF_NS, "NS" },
-        { BSD_AF_ISO, "ISO" },
-        { BSD_AF_APPLETALK, "Appletalk" },
-        { BSD_AF_IPX, "IPX" },
-        { BSD_AF_INET6_BSD, "IPv6" },
-        { BSD_AF_INET6_FREEBSD, "IPv6" },
-        { BSD_AF_INET6_DARWIN, "IPv6" },
-        { 0, NULL}
-};
-
 
 /*
  * Byte-swap a 32-bit number.
@@ -145,27 +118,27 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
 
        switch (family) {
 
-       case BSD_AF_INET:
+       case BSD_AFNUM_INET:
                ip_print(gndo, p, length);
                break;
 
 #ifdef INET6
-       case BSD_AF_INET6_BSD:
-       case BSD_AF_INET6_FREEBSD:
-       case BSD_AF_INET6_DARWIN:
+       case BSD_AFNUM_INET6_BSD:
+       case BSD_AFNUM_INET6_FREEBSD:
+       case BSD_AFNUM_INET6_DARWIN:
                ip6_print(p, length);
                break;
 #endif
 
-       case BSD_AF_ISO:
+       case BSD_AFNUM_ISO:
                isoclns_print(p, length, caplen);
                break;
 
-       case BSD_AF_APPLETALK:
+       case BSD_AFNUM_APPLETALK:
                atalk_print(p, length);
                break;
 
-       case BSD_AF_IPX:
+       case BSD_AFNUM_IPX:
                ipx_print(p, length);
                break;
 
diff --git a/contrib/tcpdump-3.9/print-olsr.c b/contrib/tcpdump-3.9/print-olsr.c
new file mode 100644 (file)
index 0000000..174a51e
--- /dev/null
@@ -0,0 +1,397 @@
+/*
+ * Copyright (c) 1998-2007 The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ *
+ * Optimized Link State Protocl (OLSR) as per rfc3626
+ *
+ * Original code by Hannes Gredler <hannes@juniper.net>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "extract.h"           
+#include "ip.h"
+
+/*
+ * RFC 3626 common header
+ *
+ *  0                   1                   2                   3
+ *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |         Packet Length         |    Packet Sequence Number     |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |  Message Type |     Vtime     |         Message Size          |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                      Originator Address                       |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |  Time To Live |   Hop Count   |    Message Sequence Number    |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                                                               |
+ * :                            MESSAGE                            :
+ * |                                                               |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |  Message Type |     Vtime     |         Message Size          |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                      Originator Address                       |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |  Time To Live |   Hop Count   |    Message Sequence Number    |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                                                               |
+ * :                            MESSAGE                            :
+ * |                                                               |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * :                                                               :
+ */
+
+struct olsr_common {
+    u_int8_t packet_len[2];
+    u_int8_t packet_seq[2];
+};
+
+#define OLSR_HELLO_MSG         1 /* rfc3626 */
+#define OLSR_TC_MSG            2 /* rfc3626 */
+#define OLSR_MID_MSG           3 /* rfc3626 */
+#define OLSR_HNA_MSG           4 /* rfc3626 */
+#define OLSR_POWERINFO_MSG   128
+#define OLSR_NAMESERVICE_MSG 130
+#define OLSR_HELLO_LQ_MSG    201 /* LQ extensions olsr.org */
+#define OLSR_TC_LQ_MSG       202 /* LQ extensions olsr.org */
+
+static struct tok olsr_msg_values[] = {
+    { OLSR_HELLO_MSG, "Hello" },
+    { OLSR_TC_MSG, "TC" },
+    { OLSR_MID_MSG, "MID" },
+    { OLSR_HNA_MSG, "HNA" },
+    { OLSR_POWERINFO_MSG, "Powerinfo" },
+    { OLSR_NAMESERVICE_MSG, "Nameservice" },
+    { OLSR_HELLO_LQ_MSG, "Hello-LQ" },
+    { OLSR_TC_LQ_MSG, "TC-LQ" },
+    { 0, NULL}
+};
+
+struct olsr_msg {
+    u_int8_t msg_type;
+    u_int8_t vtime;
+    u_int8_t msg_len[2];
+    u_int8_t originator[4];
+    u_int8_t ttl;
+    u_int8_t hopcount;
+    u_int8_t msg_seq[2];
+};
+
+struct olsr_hello {
+    u_int8_t res[2];
+    u_int8_t htime;
+    u_int8_t will;
+};
+
+struct olsr_hello_link {
+    u_int8_t link_code;
+    u_int8_t res;
+    u_int8_t len[2];
+};
+
+struct olsr_tc {
+    u_int8_t ans_seq[2];
+    u_int8_t res[2];
+};
+
+struct olsr_hna {
+    u_int8_t network[4];
+    u_int8_t mask[4];
+};
+
+
+#define OLSR_EXTRACT_LINK_TYPE(link_code) (link_code & 0x3)
+#define OLSR_EXTRACT_NEIGHBOR_TYPE(link_code) (link_code >> 2)
+
+static struct tok olsr_link_type_values[] = {
+    { 0, "Unspecified" },
+    { 1, "Asymmetric" },
+    { 2, "Symmetric" },
+    { 3, "Lost" },
+    { 0, NULL}
+};
+
+static struct tok olsr_neighbor_type_values[] = {
+    { 0, "Not-Neighbor" },
+    { 1, "Symmetric" },
+    { 2, "Symmetric-MPR" },
+    { 0, NULL}
+};
+
+struct olsr_lq_neighbor {
+    u_int8_t neighbor[4];
+    u_int8_t link_quality;
+    u_int8_t neighbor_link_quality;
+    u_int8_t res[2];
+};
+
+/*
+ * macro to convert the 8-bit mantissa/exponent to a double float
+ * taken from olsr.org.
+ */
+#define VTIME_SCALE_FACTOR    0.0625
+#define ME_TO_DOUBLE(me) \
+  (double)(VTIME_SCALE_FACTOR*(1+(double)(me>>4)/16)*(double)(1<<(me&0x0F)))
+
+/*
+ * print a neighbor list with LQ extensions.
+ */
+static void
+olsr_print_lq_neighbor (const u_char *msg_data, u_int hello_len)
+{
+    struct olsr_lq_neighbor *lq_neighbor;
+
+    while (hello_len >= sizeof(struct olsr_lq_neighbor)) {
+
+        lq_neighbor = (struct olsr_lq_neighbor *)msg_data;
+
+        printf("\n\t      neighbor %s, link-quality %.2lf%%"
+               ", neighbor-link-quality %.2lf%%",
+               ipaddr_string(lq_neighbor->neighbor),
+               ((double)lq_neighbor->link_quality/2.55),
+               ((double)lq_neighbor->neighbor_link_quality/2.55));
+
+        msg_data += sizeof(struct olsr_lq_neighbor);
+        hello_len -= sizeof(struct olsr_lq_neighbor);
+    }
+}
+
+/*
+ * print a neighbor list.
+ */
+static void
+olsr_print_neighbor (const u_char *msg_data, u_int hello_len)
+{
+    int neighbor;
+
+    printf("\n\t      neighbor\n\t\t");
+    neighbor = 1;
+
+    while (hello_len >= sizeof(struct in_addr)) {
+
+        /* print 4 neighbors per line */
+
+        printf("%s%s", ipaddr_string(msg_data),
+               neighbor % 4 == 0 ? "\n\t\t" : " ");
+
+        msg_data += sizeof(struct in_addr);
+        hello_len -= sizeof(struct in_addr);
+    }
+}
+
+
+void
+olsr_print (const u_char *pptr, u_int length)
+{
+    union {
+        const struct olsr_common *common;
+        const struct olsr_msg *msg;
+        const struct olsr_hello *hello;
+        const struct olsr_hello_link *hello_link;
+        const struct olsr_lq_neighbor *lq_neighbor;
+        const struct olsr_tc *tc;
+        const struct olsr_hna *hna;
+    } ptr;
+
+    u_int msg_type, msg_len, msg_tlen, hello_len, prefix;
+    u_int8_t link_type, neighbor_type;
+    const u_char *tptr, *msg_data;
+
+    tptr = pptr; 
+
+    if (length < sizeof(struct olsr_common)) {
+        goto trunc;
+    }
+
+    if (!TTEST2(*tptr, sizeof(struct olsr_common))) {
+       goto trunc;
+    }
+
+    ptr.common = (struct olsr_common *)tptr;
+    length = MIN(length, EXTRACT_16BITS(ptr.common->packet_len));
+
+    printf("OLSR, seq 0x%04x, length %u",
+           EXTRACT_16BITS(ptr.common->packet_seq),
+           length);
+
+    tptr += sizeof(struct olsr_common);
+
+    /*
+     * In non-verbose mode, just print version.
+     */
+    if (vflag < 1) {
+       return;
+    }
+
+    while (tptr < (pptr+length)) {
+
+        if (!TTEST2(*tptr, sizeof(struct olsr_msg)))   
+            goto trunc;
+
+        ptr.msg = (struct olsr_msg *)tptr;
+
+        msg_type = ptr.msg->msg_type;
+        msg_len = EXTRACT_16BITS(ptr.msg->msg_len);
+
+        /* infinite loop check */
+        if (msg_type == 0 || msg_len == 0) {
+            return;
+        }
+
+        printf("\n\t%s Message (%u), originator %s, ttl %u, hop %u"
+               "\n\t  vtime %.3lfs, msg-seq 0x%04x, length %u",
+               tok2str(olsr_msg_values, "Unknown", msg_type),
+               msg_type, ipaddr_string(ptr.msg->originator),
+               ptr.msg->ttl,
+               ptr.msg->hopcount,
+               ME_TO_DOUBLE(ptr.msg->vtime),
+               EXTRACT_16BITS(ptr.msg->msg_seq),
+               msg_len);
+
+        msg_tlen = msg_len - sizeof(struct olsr_msg);
+        msg_data = tptr + sizeof(struct olsr_msg);
+
+        switch (msg_type) {
+        case OLSR_HELLO_MSG:
+        case OLSR_HELLO_LQ_MSG:
+            if (!TTEST2(*msg_data, sizeof(struct olsr_hello))) 
+                goto trunc;
+
+            ptr.hello = (struct olsr_hello *)msg_data;
+            printf("\n\t  hello-time %.3lfs, MPR willingness %u",
+                   ME_TO_DOUBLE(ptr.hello->htime), ptr.hello->will);
+            msg_data += sizeof(struct olsr_hello);
+            msg_tlen -= sizeof(struct olsr_hello);
+
+            while (msg_tlen >= sizeof(struct olsr_hello_link)) {
+
+                /*
+                 * link-type.
+                 */
+                if (!TTEST2(*msg_data, sizeof(struct olsr_hello_link)))        
+                    goto trunc;
+
+                ptr.hello_link = (struct olsr_hello_link *)msg_data;
+
+                hello_len = EXTRACT_16BITS(ptr.hello_link->len);
+                link_type = OLSR_EXTRACT_LINK_TYPE(ptr.hello_link->link_code);
+                neighbor_type = OLSR_EXTRACT_NEIGHBOR_TYPE(ptr.hello_link->link_code);
+
+                printf("\n\t    link-type %s, neighbor-type %s, len %u",
+                       tok2str(olsr_link_type_values, "Unknown", link_type),
+                       tok2str(olsr_neighbor_type_values, "Unknown", neighbor_type),
+                       hello_len);
+
+                msg_data += sizeof(struct olsr_hello_link);
+                msg_tlen -= sizeof(struct olsr_hello_link);
+                hello_len -= sizeof(struct olsr_hello_link);
+
+                if (msg_type == OLSR_HELLO_MSG) {
+                    olsr_print_neighbor(msg_data, hello_len);
+                } else {
+                    olsr_print_lq_neighbor(msg_data, hello_len);
+                }
+
+                msg_data += hello_len;
+                msg_tlen -= hello_len;
+            }
+            break;
+
+        case OLSR_TC_MSG:
+        case OLSR_TC_LQ_MSG:
+            if (!TTEST2(*msg_data, sizeof(struct olsr_tc)))    
+                goto trunc;
+
+            ptr.tc = (struct olsr_tc *)msg_data;
+            printf("\n\t    advertised neighbor seq 0x%04x",
+                   EXTRACT_16BITS(ptr.tc->ans_seq));
+            msg_data += sizeof(struct olsr_tc);
+            msg_tlen -= sizeof(struct olsr_tc);
+
+            if (msg_type == OLSR_TC_MSG) {
+                olsr_print_neighbor(msg_data, msg_tlen);
+            } else {
+                olsr_print_lq_neighbor(msg_data, msg_tlen);
+            }
+            break;
+
+        case OLSR_MID_MSG:
+            if (!TTEST2(*msg_data, sizeof(struct in_addr)))    
+                goto trunc;
+
+            while (msg_tlen >= sizeof(struct in_addr)) {
+                printf("\n\t  interface address %s", ipaddr_string(msg_data));
+                msg_data += sizeof(struct in_addr);
+                msg_tlen -= sizeof(struct in_addr);
+            }
+            break;
+
+        case OLSR_HNA_MSG:
+            prefix = 1;
+            printf("\n\t  advertised networks\n\t    ");
+            while (msg_tlen >= sizeof(struct olsr_hna)) {
+                if (!TTEST2(*msg_data, sizeof(struct olsr_hna)))       
+                    goto trunc;
+
+                ptr.hna = (struct olsr_hna *)msg_data;
+
+                /* print 4 prefixes per line */
+
+                printf("%s/%u%s",
+                       ipaddr_string(ptr.hna->network),
+                       mask2plen(EXTRACT_32BITS(ptr.hna->mask)),                       
+                       prefix % 4 == 0 ? "\n\t    " : " ");
+
+                msg_data += sizeof(struct olsr_hna);
+                msg_tlen -= sizeof(struct olsr_hna);
+                prefix ++;
+            }
+            break;
+
+            /*
+             * FIXME those are the defined messages that lack a decoder
+             * you are welcome to contribute code ;-)
+             */
+
+        case OLSR_POWERINFO_MSG:
+        case OLSR_NAMESERVICE_MSG:
+        default:
+           print_unknown_data(msg_data, "\n\t    ", msg_tlen);
+            break;
+        }      
+        tptr += msg_len;
+    }
+
+    return;
+
+ trunc:
+    printf("[|olsr]");
+}
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 4
+ * End:
+ */
index 634849b..fd8f111 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.56.2.3 2005/08/23 11:16:29 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.56.2.4 2006/12/13 08:24:27 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -57,7 +57,7 @@ static struct tok ospf_option_values[] = {
 
 static struct tok ospf_authtype_values[] = {
        { OSPF_AUTH_NONE,       "none" },
-       { OSPF_AUTH_NONE,       "simple" },
+       { OSPF_AUTH_SIMPLE,     "simple" },
        { OSPF_AUTH_MD5,        "MD5" },
        { 0,                    NULL }
 };
@@ -932,12 +932,8 @@ ospf_print(register const u_char *bp, register u_int length,
                        break;
 
                case OSPF_AUTH_SIMPLE:
-                       if (fn_printn(op->ospf_authdata,
-                           sizeof(op->ospf_authdata), snapend)) {
-                               printf("\"");
-                               goto trunc;
-                       }
-                       printf("\"");
+                        printf("\n\tSimple text password: ");
+                        safeputs(op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
                        break;
 
                case OSPF_AUTH_MD5:
index 4d70e05..76a2a99 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.13.2.1 2005/07/07 01:24:38 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.13.2.2 2006/10/25 22:13:30 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -44,6 +44,15 @@ static struct tok pf_reasons[] = {
        { 3,    "3(short)" },
        { 4,    "4(normalize)" },
        { 5,    "5(memory)" },
+       { 6,    "6(bad-timestamp)" },
+       { 7,    "7(congestion)" },
+       { 8,    "8(ip-option)" },
+       { 9,    "9(proto-cksum)" },
+       { 10,   "10(state-mismatch)" },
+       { 11,   "11(state-insert)" },
+       { 12,   "12(state-limit)" },
+       { 13,   "13(src-limit)" },
+       { 14,   "14(synproxy)" },
        { 0,    NULL }
 };
 
index 7eda0a6..50d3b1f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998-2005 The TCPDUMP project
+ * Copyright (c) 1998-2007 The TCPDUMP project
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that: (1) source code
@@ -17,7 +17,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.33.2.9 2006/06/23 02:07:27 hannes Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.33.2.14 2007/02/26 13:32:36 hannes Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -35,6 +35,7 @@ static const char rcsid[] _U_ =
 #include "addrtoname.h"
 #include "ethertype.h"
 #include "gmpls.h"
+#include "af.h"
 
 /*
  * RFC 2205 common header
@@ -134,9 +135,9 @@ static const struct tok rsvp_header_flag_values[] = {
 #define        RSVP_OBJ_ERO                20  /* rfc3209 */
 #define        RSVP_OBJ_RRO                21  /* rfc3209 */
 #define        RSVP_OBJ_HELLO              22  /* rfc3209 */
-#define        RSVP_OBJ_MESSAGE_ID         23
-#define        RSVP_OBJ_MESSAGE_ID_ACK     24
-#define        RSVP_OBJ_MESSAGE_ID_LIST    25
+#define        RSVP_OBJ_MESSAGE_ID         23  /* rfc2961 */
+#define        RSVP_OBJ_MESSAGE_ID_ACK     24  /* rfc2961 */
+#define        RSVP_OBJ_MESSAGE_ID_LIST    25  /* rfc2961 */
 #define        RSVP_OBJ_RECOVERY_LABEL     34  /* rfc3473 */
 #define        RSVP_OBJ_UPSTREAM_LABEL     35  /* rfc3473 */
 #define        RSVP_OBJ_LABEL_SET          36  /* rfc3473 */
@@ -152,6 +153,7 @@ static const struct tok rsvp_header_flag_values[] = {
 #define        RSVP_OBJ_PROPERTIES         204 /* juniper proprietary */
 #define        RSVP_OBJ_FASTREROUTE        205 /* draft-ietf-mpls-rsvp-lsp-fastreroute-07 */
 #define        RSVP_OBJ_SESSION_ATTRIBUTE  207 /* rfc3209 */
+#define RSVP_OBJ_GENERALIZED_UNI    229 /* OIF RSVP extensions UNI 1.0 Signaling, Rel. 2 */
 #define RSVP_OBJ_CALL_ID            230 /* rfc3474 */
 #define RSVP_OBJ_CALL_OPS           236 /* rfc3474 */
 
@@ -189,6 +191,7 @@ static const struct tok rsvp_obj_values[] = {
     { RSVP_OBJ_PROPERTIES,         "Properties" },
     { RSVP_OBJ_FASTREROUTE,        "Fast Re-Route" },
     { RSVP_OBJ_SESSION_ATTRIBUTE,  "Session Attribute" },
+    { RSVP_OBJ_GENERALIZED_UNI,    "Generalized UNI" },
     { RSVP_OBJ_CALL_ID,            "Call-ID" },
     { RSVP_OBJ_CALL_OPS,           "Call Capability" },
     { RSVP_OBJ_RESTART_CAPABILITY, "Restart Capability" },
@@ -202,6 +205,7 @@ static const struct tok rsvp_obj_values[] = {
 #define        RSVP_CTYPE_IPV6        2
 #define        RSVP_CTYPE_TUNNEL_IPV4 7
 #define        RSVP_CTYPE_TUNNEL_IPV6 8
+#define        RSVP_CTYPE_UNI_IPV4    11 /* OIF RSVP extensions UNI 1.0 Signaling Rel. 2 */
 #define RSVP_CTYPE_1           1
 #define RSVP_CTYPE_2           2
 #define RSVP_CTYPE_3           3
@@ -234,11 +238,13 @@ static const struct tok rsvp_ctype_values[] = {
     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV4,                 "IPv4" },
     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV6,                 "IPv6" },
     { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_TUNNEL_IPV4,           "Tunnel IPv4" },
+    { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_UNI_IPV4,              "UNI IPv4" },
     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV4,          "IPv4" },
     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV6,          "IPv6" },
     { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_TUNNEL_IPV4,   "Tunnel IPv4" },
     { 256*RSVP_OBJ_MESSAGE_ID+RSVP_CTYPE_1,                  "1" },
-    { 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_1,              "1" },
+    { 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_1,              "Message id ack" },
+    { 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_2,              "Message id nack" },
     { 256*RSVP_OBJ_MESSAGE_ID_LIST+RSVP_CTYPE_1,             "1" },
     { 256*RSVP_OBJ_STYLE+RSVP_CTYPE_1,                       "1" },
     { 256*RSVP_OBJ_HELLO+RSVP_CTYPE_1,                       "Hello Request" },
@@ -271,8 +277,11 @@ static const struct tok rsvp_ctype_values[] = {
     { 256*RSVP_OBJ_FASTREROUTE+RSVP_CTYPE_1,                 "1" }, /* new style */
     { 256*RSVP_OBJ_DETOUR+RSVP_CTYPE_TUNNEL_IPV4,            "Tunnel IPv4" },
     { 256*RSVP_OBJ_PROPERTIES+RSVP_CTYPE_1,                  "1" },
+    { 256*RSVP_OBJ_ADMIN_STATUS+RSVP_CTYPE_1,                "1" },
     { 256*RSVP_OBJ_CLASSTYPE+RSVP_CTYPE_1,                   "1" },
     { 256*RSVP_OBJ_CLASSTYPE_OLD+RSVP_CTYPE_1,               "1" },
+    { 256*RSVP_OBJ_LABEL_SET+RSVP_CTYPE_1,                   "1" },
+    { 256*RSVP_OBJ_GENERALIZED_UNI+RSVP_CTYPE_1,             "1" },
     { 0, NULL}
 };
 
@@ -416,6 +425,45 @@ static struct tok rsvp_obj_error_code_diffserv_te_values[] = {
    { 0, NULL}
 };
 
+/* rfc3473 / rfc 3471 */
+static const struct tok rsvp_obj_admin_status_flag_values[] = {
+    { 0x80000000, "Reflect" },
+    { 0x00000004, "Testing" },
+    { 0x00000002, "Admin-down" },
+    { 0x00000001, "Delete-in-progress" },
+    { 0, NULL}
+};
+
+/* label set actions - rfc3471 */
+#define LABEL_SET_INCLUSIVE_LIST  0
+#define LABEL_SET_EXCLUSIVE_LIST  1
+#define LABEL_SET_INCLUSIVE_RANGE 2
+#define LABEL_SET_EXCLUSIVE_RANGE 3
+
+static const struct tok rsvp_obj_label_set_action_values[] = {
+    { LABEL_SET_INCLUSIVE_LIST, "Inclusive list" },
+    { LABEL_SET_EXCLUSIVE_LIST, "Exclusive list" },
+    { LABEL_SET_INCLUSIVE_RANGE, "Inclusive range" },
+    { LABEL_SET_EXCLUSIVE_RANGE, "Exclusive range" },
+    { 0, NULL}
+};
+
+/* OIF RSVP extensions UNI 1.0 Signaling, release 2 */
+#define RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS     1
+#define RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS 2
+#define RSVP_GEN_UNI_SUBOBJ_DIVERSITY              3
+#define RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL            4
+#define RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL           5
+
+static const struct tok rsvp_obj_generalized_uni_values[] = {
+    { RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS, "Source TNA address" },
+    { RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS, "Destination TNA address" },
+    { RSVP_GEN_UNI_SUBOBJ_DIVERSITY, "Diversity" },
+    { RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL, "Egress label" },
+    { RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL, "Service level" },
+    { 0, NULL}
+};
+
 static int rsvp_intserv_print(const u_char *, u_short);
 
 /* 
@@ -680,6 +728,7 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
                 break;
 #endif
             case RSVP_CTYPE_TUNNEL_IPV4:
+            case RSVP_CTYPE_UNI_IPV4:
                 if (obj_tlen < 12)
                     return -1;
                 printf("%s  IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
@@ -896,7 +945,7 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
                 obj_tptr+=12;
                 break;
             case RSVP_CTYPE_4:
-                if (obj_tlen < 8)
+                if (obj_tlen < 4)
                     return-1;
                 printf("%s  LSP Encoding Type: %s (%u)",
                        ident,
@@ -914,8 +963,8 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
                                "Unknown",
                                EXTRACT_16BITS(obj_tptr+2)),
                       EXTRACT_16BITS(obj_tptr+2));
-                obj_tlen-=8;
-                obj_tptr+=8;
+                obj_tlen-=4;
+                obj_tptr+=4;
                 break;
             default:
                 hexdump=TRUE;
@@ -1020,6 +1069,106 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
             }
             break;
 
+       case RSVP_OBJ_GENERALIZED_UNI:
+            switch(rsvp_obj_ctype) {
+               int subobj_type,af,subobj_len,total_subobj_len;
+
+            case RSVP_CTYPE_1: 
+
+                if (obj_tlen < 4)
+                    return-1;
+
+               /* read variable length subobjects */
+               total_subobj_len = obj_tlen;
+                while(total_subobj_len > 0) {
+                    subobj_len  = EXTRACT_16BITS(obj_tptr);
+                    subobj_type = (EXTRACT_16BITS(obj_tptr+2))>>8;
+                    af = (EXTRACT_16BITS(obj_tptr+2))&0x00FF;
+
+                    printf("%s  Subobject Type: %s (%u), AF: %s (%u), length: %u",
+                           ident,
+                           tok2str(rsvp_obj_generalized_uni_values, "Unknown", subobj_type),
+                           subobj_type,
+                           tok2str(af_values, "Unknown", af), af,
+                           subobj_len);
+
+                    switch(subobj_type) {
+                    case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS:
+                    case RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS:
+
+                        switch(af) {
+                        case AFNUM_INET:
+                            if (subobj_len < 8)
+                                return -1;
+                            printf("%s    UNI IPv4 TNA address: %s",
+                                   ident, ipaddr_string(obj_tptr+4));
+                            break;
+#ifdef INET6
+                        case AFNUM_INET6:
+                            if (subobj_len < 20)
+                                return -1;
+                            printf("%s    UNI IPv6 TNA address: %s",
+                                   ident, ip6addr_string(obj_tptr+4));
+                            break;
+#endif
+                        case AFNUM_NSAP:
+                            if (subobj_len) {
+                                /* unless we have a TLV parser lets just hexdump */
+                                hexdump=TRUE;
+                            }
+                            break;
+                        }
+                        break;
+
+                    case RSVP_GEN_UNI_SUBOBJ_DIVERSITY:
+                        if (subobj_len) {
+                            /* unless we have a TLV parser lets just hexdump */
+                            hexdump=TRUE;
+                        }
+                        break;
+
+                    case RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL:
+                        if (subobj_len < 16) {
+                            return -1;
+                        }
+
+                        printf("%s    U-bit: %x, Label type: %u, Logical port id: %u, Label: %u",
+                               ident,
+                               ((EXTRACT_32BITS(obj_tptr+4))>>31),
+                               ((EXTRACT_32BITS(obj_tptr+4))&0xFF),
+                               EXTRACT_32BITS(obj_tptr+8),
+                               EXTRACT_32BITS(obj_tptr+12));
+                        break;
+
+                    case RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL:
+                        if (subobj_len < 8) {
+                            return -1;
+                        }
+
+                        printf("%s    Service level: %u",
+                               ident, (EXTRACT_32BITS(obj_tptr+4))>>24);
+                        break;
+
+                    default:
+                        hexdump=TRUE;
+                        break;
+                    }
+                    total_subobj_len-=subobj_len;
+                    obj_tptr+=subobj_len;
+                    obj_tlen+=subobj_len;
+               }
+
+                if (total_subobj_len) {
+                    /* unless we have a TLV parser lets just hexdump */
+                    hexdump=TRUE;
+                }
+                break;
+
+            default:
+                hexdump=TRUE;
+            }
+            break;
+
         case RSVP_OBJ_RSVP_HOP:
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */
@@ -1354,6 +1503,7 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
         case RSVP_OBJ_MESSAGE_ID_LIST:
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_1:
+            case RSVP_CTYPE_2:
                 if (obj_tlen < 8)
                     return-1;
                 printf("%s  Flags [0x%02x], epoch: %u",
@@ -1406,6 +1556,68 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
             }
             break;           
 
+        case RSVP_OBJ_ADMIN_STATUS:
+            switch(rsvp_obj_ctype) {
+            case RSVP_CTYPE_1: 
+                if (obj_tlen < 4)
+                    return-1;
+                printf("%s  Flags [%s]", ident,
+                       bittok2str(rsvp_obj_admin_status_flag_values, "none",
+                                  EXTRACT_32BITS(obj_tptr)));
+                obj_tlen-=4;
+                obj_tptr+=4;
+                break;
+            default:
+                hexdump=TRUE;
+            }
+            break;
+
+        case RSVP_OBJ_LABEL_SET:
+            switch(rsvp_obj_ctype) {
+            case RSVP_CTYPE_1: 
+                if (obj_tlen < 4)
+                    return-1;
+
+                u_int action, subchannel;
+                action = (EXTRACT_16BITS(obj_tptr)>>8);
+
+                printf("%s  Action: %s (%u), Label type: %u", ident,
+                       tok2str(rsvp_obj_label_set_action_values, "Unknown", action),
+                       action, ((EXTRACT_32BITS(obj_tptr) & 0x7F)));
+
+                switch (action) {
+                case LABEL_SET_INCLUSIVE_RANGE:
+                case LABEL_SET_EXCLUSIVE_RANGE: /* fall through */
+
+                   /* only a couple of subchannels are expected */
+                   if (obj_tlen < 12)
+                       return -1;
+                   printf("%s  Start range: %u, End range: %u", ident,
+                           EXTRACT_32BITS(obj_tptr+4),
+                           EXTRACT_32BITS(obj_tptr+8));
+                   obj_tlen-=12;
+                   obj_tptr+=12;
+                    break;
+
+                default:
+                    obj_tlen-=4;
+                    obj_tptr+=4;
+                    subchannel = 1;
+                    while(obj_tlen >= 4 ) {
+                        printf("%s  Subchannel #%u: %u", ident, subchannel,
+                               EXTRACT_32BITS(obj_tptr));
+                        obj_tptr+=4;
+                        obj_tlen-=4;
+                        subchannel++;
+                    }
+                    break;
+                }
+                break;
+
+            default:
+                hexdump=TRUE;
+            }
+
         /*
          *  FIXME those are the defined objects that lack a decoder
          *  you are welcome to contribute code ;-)
@@ -1413,7 +1625,6 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {
 
         case RSVP_OBJ_SCOPE:
         case RSVP_OBJ_POLICY_DATA:
-        case RSVP_OBJ_LABEL_SET:
         case RSVP_OBJ_ACCEPT_LABEL_SET:
         case RSVP_OBJ_PROTECTION:
         default:
index d84e0fa..d991066 100644 (file)
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.37.2.1 2006/04/07 08:40:20 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.37.2.2 2007/06/15 19:43:15 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -1013,6 +1013,7 @@ acl_print(u_char *s, int maxsize, u_char *end)
        int pos, neg, acl;
        int n, i;
        char *user;
+       char fmt[1024];
 
        if ((user = (char *)malloc(maxsize)) == NULL)
                return;
@@ -1046,7 +1047,8 @@ acl_print(u_char *s, int maxsize, u_char *end)
                printf("a");
 
        for (i = 0; i < pos; i++) {
-               if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2)
+               snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
+               if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
                        goto finish;
                s += n;
                printf(" +{");
@@ -1059,7 +1061,8 @@ acl_print(u_char *s, int maxsize, u_char *end)
        }
 
        for (i = 0; i < neg; i++) {
-               if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2)
+               snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
+               if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
                        goto finish;
                s += n;
                printf(" -{");
index 3c8cfbf..5b963de 100644 (file)
@@ -12,7 +12,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.41.2.2 2005/05/08 20:01:09 guy Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.41.2.4 2007/07/14 22:29:05 guy Exp $";
 #endif
 
 #include <tcpdump-stdinc.h>
@@ -904,8 +904,8 @@ print_smb(const u_char *buf, const u_char *maxbuf)
 
        printf("\nSMB PACKET: %s (%s) (CHAINED)\n",
            fn->name, request ? "REQUEST" : "REPLY");
-       if (newsmboffset < smboffset) {
-           printf("Bad andX offset: %u < %u\n", newsmboffset, smboffset);
+       if (newsmboffset <= smboffset) {
+           printf("Bad andX offset: %u <= %u\n", newsmboffset, smboffset);
            break;
        }
        smboffset = newsmboffset;
index 3f631d2..4308ae0 100644 (file)
@@ -11,7 +11,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.13.2.1 2005/04/26 07:27:17 guy Exp $";
+"@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.13.2.7 2007/03/18 17:12:36 hannes Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -28,75 +28,338 @@ static const char rcsid[] _U_ =
 #include "addrtoname.h"
 #include "extract.h"
 
-static void
+#define        RSTP_EXTRACT_PORT_ROLE(x) (((x)&0x0C)>>2) 
+/* STP timers are expressed in multiples of 1/256th second */
+#define STP_TIME_BASE 256
+#define STP_BPDU_MSTP_MIN_LEN 102
+
+struct stp_bpdu_ {
+    u_int8_t protocol_id[2];
+    u_int8_t protocol_version;
+    u_int8_t bpdu_type;
+    u_int8_t flags;
+    u_int8_t root_id[8];
+    u_int8_t root_path_cost[4];
+    u_int8_t bridge_id[8];
+    u_int8_t port_id[2];
+    u_int8_t message_age[2];
+    u_int8_t max_age[2];
+    u_int8_t hello_time[2];
+    u_int8_t forward_delay[2];
+    u_int8_t v1_length;
+};
+
+#define STP_PROTO_REGULAR 0x00
+#define STP_PROTO_RAPID   0x02
+#define STP_PROTO_MSTP    0x03
+
+struct tok stp_proto_values[] = {
+    { STP_PROTO_REGULAR, "802.1d" },
+    { STP_PROTO_RAPID, "802.1w" },
+    { STP_PROTO_MSTP, "802.1s" },
+    { 0, NULL}
+};
+
+#define STP_BPDU_TYPE_CONFIG      0x00
+#define STP_BPDU_TYPE_RSTP        0x02
+#define STP_BPDU_TYPE_TOPO_CHANGE 0x80
+
+struct tok stp_bpdu_flag_values[] = {
+    { 0x01, "Topology change" },
+    { 0x02, "Proposal" },
+    { 0x10, "Learn" },
+    { 0x20, "Forward" },
+    { 0x40, "Agreement" },
+    { 0x80, "Topology change ACK" },
+    { 0, NULL}
+};
+
+struct tok stp_bpdu_type_values[] = {
+    { STP_BPDU_TYPE_CONFIG, "Config" },
+    { STP_BPDU_TYPE_RSTP, "Rapid STP" },
+    { STP_BPDU_TYPE_TOPO_CHANGE, "Topology Change" },
+    { 0, NULL}
+};
+
+struct tok rstp_obj_port_role_values[] = {
+    { 0x00, "Unknown" },
+    { 0x01, "Alternate" },
+    { 0x02, "Root" },
+    { 0x03, "Designated" },
+    { 0, NULL}
+};
+
+static char *
 stp_print_bridge_id(const u_char *p)
 {
-       printf("%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
-              p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
+    static char bridge_id_str[sizeof("pppp.aa:bb:cc:dd:ee:ff")];
+
+    snprintf(bridge_id_str, sizeof(bridge_id_str),
+             "%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
+             p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
+
+    return bridge_id_str;
 }
 
 static void
-stp_print_config_bpdu(const u_char *p)
+stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
 {
-       printf("config ");
-       if (p[4] & 1)
-               printf("TOP_CHANGE ");
-       if (p[4] & 0x80)
-               printf("TOP_CHANGE_ACK ");
+    printf(", Flags [%s]",
+           bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags));
+
+    printf(", bridge-id %s.%04x, length %u",
+           stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id),
+           EXTRACT_16BITS(&stp_bpdu->port_id), length);
 
-       stp_print_bridge_id(p+17);
-       printf(".%.2x%.2x ", p[25], p[26]);
+    /* in non-verbose mode just print the bridge-id */
+    if (!vflag) {
+        return;
+    }
 
-       printf("root ");
-       stp_print_bridge_id(p+5);
+    printf("\n\tmessage-age %.2fs, max-age %.2fs"
+           ", hello-time %.2fs, forwarding-delay %.2fs",
+           (float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE,
+           (float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE,
+           (float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
+           (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE);
 
-       printf(" pathcost %i ", (p[13] << 24) | (p[14] << 16) | (p[15] << 8) | p[16]);
+    printf("\n\troot-id %s, root-pathcost %u",
+           stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
+           EXTRACT_32BITS(&stp_bpdu->root_path_cost));
 
-       printf("age %i ", p[27]);
-       printf("max %i ", p[29]);
-       printf("hello %i ", p[31]);
-       printf("fdelay %i ", p[33]);
+    /* Port role is only valid for 802.1w */
+    if (stp_bpdu->protocol_version == STP_PROTO_RAPID) {
+        printf(", port-role %s",
+               tok2str(rstp_obj_port_role_values, "Unknown",
+                       RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)));
+    }
 }
 
+/*
+ * MSTP packet format
+ * Ref. IEEE 802.1Q 2003 Ed. Section 14
+ *
+ * MSTP BPDU
+ *
+ * 2 -  bytes Protocol Id
+ * 1 -  byte  Protocol Ver. 
+ * 1 -  byte  BPDU tye
+ * 1 -  byte  Flags
+ * 8 -  bytes CIST Root Identifier
+ * 4 -  bytes CIST External Path Cost
+ * 8 -  bytes CIST Regional Root Identifier
+ * 2 -  bytes CIST Port Identifier
+ * 2 -  bytes Message Age
+ * 2 -  bytes Max age
+ * 2 -  bytes Hello Time
+ * 2 -  bytes Forward delay
+ * 1 -  byte  Version 1 length. Must be 0
+ * 2 -  bytes Version 3 length
+ * 1 -  byte  Config Identifier
+ * 32 - bytes Config Name
+ * 2 -  bytes Revision level
+ * 16 - bytes Config Digest [MD5]
+ * 4 -  bytes CIST Internal Root Path Cost
+ * 8 -  bytes CIST Bridge Identifier
+ * 1 -  byte  CIST Remaining Hops
+ * 16 - bytes MSTI information [Max 64 MSTI, each 16 bytes]
+ *
+ * MSTI Payload
+ *
+ * 1 - byte  MSTI flag
+ * 8 - bytes MSTI Regional Root Identifier
+ * 4 - bytes MSTI Regional Path Cost
+ * 1 - byte  MSTI Bridge Priority
+ * 1 - byte  MSTI Port Priority
+ * 1 - byte  MSTI Remaining Hops
+ */
+
+#define MST_BPDU_MSTI_LENGTH               16
+#define MST_BPDU_CONFIG_INFO_LENGTH        64
+
+/* Offsets of fields from the begginning for the packet */
+#define MST_BPDU_VER3_LEN_OFFSET           36
+#define MST_BPDU_CONFIG_NAME_OFFSET        39
+#define MST_BPDU_CONFIG_DIGEST_OFFSET      73
+#define MST_BPDU_CIST_INT_PATH_COST_OFFSET  89
+#define MST_BPDU_CIST_BRIDGE_ID_OFFSET     93
+#define MST_BPDU_CIST_REMAIN_HOPS_OFFSET    101
+#define MST_BPDU_MSTI_OFFSET               102
+/* Offsets within  an MSTI */
+#define MST_BPDU_MSTI_ROOT_PRIO_OFFSET     1
+#define MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET 9
+#define MST_BPDU_MSTI_BRIDGE_PRIO_OFFSET    13
+#define MST_BPDU_MSTI_PORT_PRIO_OFFSET     14
+#define MST_BPDU_MSTI_REMAIN_HOPS_OFFSET    15
+
 static void
-stp_print_tcn_bpdu(void)
+stp_print_mstp_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
 {
-       printf("tcn");
+    const u_char    *ptr;
+    u_int16_t      v3len;
+    u_int16_t      len;
+    u_int16_t      msti;
+    u_int16_t      offset;
+
+    ptr = (const u_char *)stp_bpdu;
+    printf(", CIST Flags [%s]",
+           bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags));
+
+    /*
+     * in non-verbose mode just print the flags. We dont read that much
+     * of the packet (DEFAULT_SNAPLEN) to print out cist bridge-id
+     */
+    if (!vflag) {
+        return;
+    }
+
+    printf(", CIST bridge-id %s.%04x, length %u",
+           stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET),
+           EXTRACT_16BITS(&stp_bpdu->port_id), length);
+
+
+    printf("\n\tmessage-age %.2fs, max-age %.2fs"
+           ", hello-time %.2fs, forwarding-delay %.2fs",
+           (float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE,
+           (float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE,
+           (float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
+           (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE);
+
+    printf("\n\tCIST root-id %s, ext-pathcost %u int-pathcost %u",
+           stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
+           EXTRACT_32BITS(&stp_bpdu->root_path_cost),
+           EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET));
+
+    printf(", port-role %s",
+           tok2str(rstp_obj_port_role_values, "Unknown",
+                   RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)));
+
+    printf("\n\tCIST regional-root-id %s",
+           stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id));
+
+    printf("\n\tMSTP Configuration Name %s, revision %u, digest %08x%08x%08x%08x",
+           ptr + MST_BPDU_CONFIG_NAME_OFFSET,
+          EXTRACT_16BITS(ptr + MST_BPDU_CONFIG_NAME_OFFSET + 32),
+          EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET),
+          EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 4),
+          EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 8),
+          EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12));
+
+    printf("\n\tCIST remaining-hops %d", ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]);
+
+    /* Dump all MSTI's */
+    v3len = EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET);
+    if (v3len > MST_BPDU_CONFIG_INFO_LENGTH) {
+        len = v3len - MST_BPDU_CONFIG_INFO_LENGTH;
+        offset = MST_BPDU_MSTI_OFFSET;
+        while (len >= MST_BPDU_MSTI_LENGTH) {
+            msti = EXTRACT_16BITS(ptr + offset +
+                                  MST_BPDU_MSTI_ROOT_PRIO_OFFSET);
+            msti = msti & 0x0FFF;
+
+            printf("\n\tMSTI %d, Flags [%s], port-role %s", 
+                   msti, bittok2str(stp_bpdu_flag_values, "none", ptr[offset]),
+                   tok2str(rstp_obj_port_role_values, "Unknown",
+                           RSTP_EXTRACT_PORT_ROLE(ptr[offset])));
+            printf("\n\t\tMSTI regional-root-id %s, pathcost %u",
+                   stp_print_bridge_id(ptr + offset +
+                                       MST_BPDU_MSTI_ROOT_PRIO_OFFSET),
+                   EXTRACT_32BITS(ptr + offset +
+                                  MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET));
+            printf("\n\t\tMSTI bridge-prio %d, port-prio %d, hops %d",
+                   ptr[offset + MST_BPDU_MSTI_BRIDGE_PRIO_OFFSET] >> 4,
+                   ptr[offset + MST_BPDU_MSTI_PORT_PRIO_OFFSET] >> 4,
+                   ptr[offset + MST_BPDU_MSTI_REMAIN_HOPS_OFFSET]);
+
+            len -= MST_BPDU_MSTI_LENGTH;
+            offset += MST_BPDU_MSTI_LENGTH;
+        }
+    }
 }
 
 /*
- * Print 802.1d packets.
+ * Print 802.1d / 802.1w / 802.1q (mstp) packets.
  */
 void
 stp_print(const u_char *p, u_int length)
 {
-       if (length < 4)
-               goto trunc;
-
-       printf("802.1d ");
-       if (p[0] || p[1] || p[2]) {
-               printf("unknown version");
-               return;
-       }
-
-       switch (p[3])
-       {
-       case 0x00:
-               if (length < 10)
-                       goto trunc;
-               stp_print_config_bpdu(p);
-               break;
-
-       case 0x80:
-               stp_print_tcn_bpdu();
-               break;
-
-       default:
-               printf("unknown type %i", p[3]);
-               break;
-       }
-
-       return;
-trunc:
-       printf("[|stp %d]", length);
+    const struct stp_bpdu_ *stp_bpdu;
+    u_int16_t              mstp_len;
+    
+    stp_bpdu = (struct stp_bpdu_*)p;
+
+    /* Minimum STP Frame size. */
+    if (length < 4)
+        goto trunc;
+        
+    if (EXTRACT_16BITS(&stp_bpdu->protocol_id)) {
+        printf("unknown STP version, length %u", length);
+        return;
+    }
+
+    printf("STP %s", tok2str(stp_proto_values, "Unknown STP protocol (0x%02x)",
+                         stp_bpdu->protocol_version));
+
+    switch (stp_bpdu->protocol_version) {
+    case STP_PROTO_REGULAR:
+    case STP_PROTO_RAPID:
+    case STP_PROTO_MSTP:
+        break;
+    default:
+        return;
+    }
+
+    printf(", %s", tok2str(stp_bpdu_type_values, "Unknown BPDU Type (0x%02x)",
+                           stp_bpdu->bpdu_type));
+
+    switch (stp_bpdu->bpdu_type) {
+    case STP_BPDU_TYPE_CONFIG:
+        if (length < sizeof(struct stp_bpdu_) - 1) {
+            goto trunc;
+        }
+        stp_print_config_bpdu(stp_bpdu, length);
+        break;
+
+    case STP_BPDU_TYPE_RSTP:
+        if (stp_bpdu->protocol_version == STP_PROTO_RAPID) {
+            if (length < sizeof(struct stp_bpdu_)) {
+                goto trunc;
+            }
+            stp_print_config_bpdu(stp_bpdu, length);
+        } else if (stp_bpdu->protocol_version == STP_PROTO_MSTP) {
+            if (length < STP_BPDU_MSTP_MIN_LEN) {
+                goto trunc;
+            }
+            if (stp_bpdu->v1_length != 0) {
+                /* FIX ME: Emit a message here ? */
+                goto trunc;
+            }
+            /* Validate v3 length */
+            mstp_len = EXTRACT_16BITS(p + MST_BPDU_VER3_LEN_OFFSET);
+            mstp_len += 2;  /* length encoding itself is 2 bytes */
+            if (length < (sizeof(struct stp_bpdu_) + mstp_len)) {
+                goto trunc;
+            }
+            stp_print_mstp_bpdu(stp_bpdu, length);
+        }
+        break;
+
+    case STP_BPDU_TYPE_TOPO_CHANGE:
+        /* always empty message - just break out */
+        break;
+
+    default:
+        break;
+    }
+
+    return;
+ trunc:
+    printf("[|stp %d]", length);
 }
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 4
+ * End:
+ */
index 87da886..3f08a1c 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.138 2005/04/07 00:28:17 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.138.2.1 2007/03/28 07:45:46 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -674,6 +674,8 @@ udp_print(register const u_char *bp, u_int length,
                        lwres_print((const u_char *)(up + 1), length);
                 else if (ISPORT(LDP_PORT))
                        ldp_print((const u_char *)(up + 1), length);
+                else if (ISPORT(OLSR_PORT))
+                       olsr_print((const u_char *)(up + 1), length);
                 else if (ISPORT(MPLS_LSP_PING_PORT))
                        lspping_print((const u_char *)(up + 1), length);
                else if (dport == BFD_CONTROL_PORT ||
index b3d4b5f..86bcb4c 100644 (file)
@@ -12,7 +12,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.36.2.1 2005/04/21 04:09:58 guy Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.36.2.3 2007/07/15 19:08:25 guy Exp $";
 #endif
 
 #include <tcpdump-stdinc.h>
@@ -279,6 +279,7 @@ print_data(const unsigned char *buf, int len)
        return;
     printf("[%03X] ", i);
     for (i = 0; i < len; /*nothing*/) {
+        TCHECK(buf[i]);
        printf("%02X ", buf[i] & 0xff);
        i++;
        if (i%8 == 0)
@@ -310,6 +311,11 @@ print_data(const unsigned char *buf, int len)
            print_asc(&buf[i - n], n);
        printf("\n");
     }
+    return;
+
+trunc:
+    printf("\n");
+    printf("WARNING: Short packet. Try increasing the snap length\n");
 }
 
 
@@ -745,6 +751,9 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
                t = interpret_long_date(buf);
                buf += 8;
                break;
+           default:
+               t = 0;
+               break;
            }
            if (t != 0) {
                lt = localtime(&t);
index c4d570d..d13b4de 100644 (file)
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.167.2.10 2005/12/05 20:11:19 guy Exp $ (LBL)
+.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.167.2.11 2007/06/15 20:13:49 guy Exp $ (LBL)
 .\"
 .\"    $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $
 .\"
@@ -234,7 +234,10 @@ operation, be enabled on that interface.
 .TP
 .B Under BSD (this includes Mac OS X):
 You must have read access to
-.IR /dev/bpf* .
+.I /dev/bpf*
+on systems that don't have a cloning BPF device, or to
+.I /dev/bpf
+on systems that do.
 On BSDs with a devfs (this includes Mac OS X), this might involve more
 than just having somebody with super-user access setting the ownership
 or permissions on the BPF devices - it might involve configuring devfs
index 31b366e..dedc9c1 100644 (file)
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.8.2.1 2006/02/09 23:34:07 hannes Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.8.2.2 2007/03/28 07:45:46 hannes Exp $ (LBL) */
 /*
  * Copyright (c) 1982, 1986, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -57,6 +57,7 @@ struct udphdr {
 #define RIP_PORT 520           /*XXX*/
 #define LDP_PORT 646
 #define AODV_PORT 654          /*XXX*/
+#define OLSR_PORT 698           /* rfc3626 */
 #define KERBEROS_SEC_PORT 750  /*XXX*/
 #define L2TP_PORT 1701         /*XXX*/
 #define SIP_PORT 5060