]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Merge remote branch 'github/master'
authorMichael Richardson <[email protected]>
Sat, 10 Dec 2011 01:04:11 +0000 (20:04 -0500)
committerMichael Richardson <[email protected]>
Sat, 10 Dec 2011 01:04:11 +0000 (20:04 -0500)
24 files changed:
CREDITS
Makefile.in
interface.h
ipproto.c
ipproto.h
netdissect.h
ospf.h
print-arp.c
print-atm.c
print-carp.c [new file with mode: 0644]
print-eigrp.c
print-ether.c
print-ip.c
print-isoclns.c
print-ldp.c
print-lmp.c
print-lspping.c
print-ospf.c
print-ospf6.c
print-rsvp.c
print-slow.c
tcpdump.1.in
tcpdump.c
tests/espudp1.out

diff --git a/CREDITS b/CREDITS
index 205af0fe1a0e3bf78b1600428f6b0103c170cccf..9e7e875769beca4b62440aeaae0800429f6cf0a2 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -127,6 +127,7 @@ Additional people who have contributed patches:
     Michael Shalayeff             <mickey at openbsd dot org>
     Michael Shields               <shields at msrl dot com>
     Michael T. Stolarchuk         <mts at off dot to>
+    Michal Sekletar               <msekleta at redhat dot com>
     Michele "mydecay" Marchetto   <smarchetto1 at tin dot it>
     Mike Frysinger                <vapier at gmail dot com>
     Minto Jeyananth               <minto at juniper dot net>
index 5c1e7a72acd9fa30123262c618970b6a78f311f8..9e2eede898d4f220b146fab35c53126e85bb3de7 100644 (file)
@@ -73,8 +73,8 @@ CSRC =        addrtoname.c af.c checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c
        print-802_11.c print-802_15_4.c print-ap1394.c print-ah.c \
        print-arcnet.c print-aodv.c print-arp.c print-ascii.c print-atalk.c \
        print-atm.c print-beep.c print-bfd.c print-bgp.c \
-       print-bootp.c print-bt.c print-cdp.c print-cfm.c print-chdlc.c \
-       print-cip.c print-cnfp.c print-dccp.c print-decnet.c \
+       print-bootp.c print-bt.c print-carp.c print-cdp.c print-cfm.c \
+       print-chdlc.c print-cip.c print-cnfp.c print-dccp.c print-decnet.c \
        print-domain.c print-dtp.c print-dvmrp.c print-enc.c print-egp.c \
        print-eap.c print-eigrp.c\
        print-esp.c print-ether.c print-fddi.c print-fr.c \
index ae1cc2f9231aac3cf337dd4bad9afab8a44af4d1..18668a21f3773758056e53363af8007a7d4f210d 100644 (file)
@@ -70,6 +70,7 @@ extern char *strsep(char **, const char *);
 #define PT_CNFP                7       /* Cisco NetFlow protocol */
 #define PT_TFTP                8       /* trivial file transfer protocol */
 #define PT_AODV                9       /* Ad-hoc On-demand Distance Vector Protocol */
+#define PT_CARP         10      /* Common Address Redundancy Protocol */
 
 #ifndef min
 #define min(a,b) ((a)>(b)?(b):(a))
@@ -290,6 +291,7 @@ extern const char *nt_errstr(u_int32_t);
 extern void print_data(const unsigned char *, int);
 extern void l2tp_print(const u_char *, u_int);
 extern void vrrp_print(const u_char *, u_int, int);
+extern void carp_print(const u_char *, u_int, int);
 extern void slow_print(const u_char *, u_int);
 extern void sflow_print(const u_char *, u_int);
 extern void mpcp_print(const u_char *, u_int);
index 644b364277199ceba1c5892feb52d56d9a12c44c..cbb9bf3f74e6191f6b40896e13bbfffeb592974b 100755 (executable)
--- a/ipproto.c
+++ b/ipproto.c
@@ -55,6 +55,7 @@ const struct tok ipproto_values[] = {
     { IPPROTO_PGM, "PGM" },
     { IPPROTO_SCTP, "SCTP" },
     { IPPROTO_MOBILITY, "Mobility" },
+    { IPPROTO_CARP, "CARP" },
     { 0, NULL }
 };
 
index 96407541f64dd891e875cf15aab513c490f84fef..c9801a624a491dfc20c27acf40f6e0aa50ed5167 100644 (file)
--- a/ipproto.h
+++ b/ipproto.h
@@ -133,6 +133,9 @@ extern const struct tok ipproto_values[];
 #ifndef IPPROTO_VRRP
 #define IPPROTO_VRRP           112
 #endif
+#ifndef IPPROTO_CARP
+#define IPPROTO_CARP           112
+#endif
 #ifndef IPPROTO_PGM
 #define IPPROTO_PGM             113
 #endif
index 6834f95df181a8654642e42fa06ffe18049435aa..0c66dfaf809487800dcb10db80f5c8f89829ab4a 100644 (file)
@@ -298,7 +298,12 @@ extern void ether_print(netdissect_options *,
                         const u_char *);
 
 extern u_int ether_if_print(netdissect_options *, 
-                           const struct pcap_pkthdr *,const u_char *);
+                            const struct pcap_pkthdr *,const u_char *);
+extern u_int netanalyzer_if_print(netdissect_options *, 
+                                  const struct pcap_pkthdr *,const u_char *);
+extern u_int netanalyzer_transparent_if_print(netdissect_options *, 
+                                              const struct pcap_pkthdr *,
+                                              const u_char *);
 
 extern int ethertype_print(netdissect_options *,u_short, const u_char *,
                             u_int, u_int);
@@ -445,6 +450,8 @@ extern void l2tp_print(netdissect_options *,const u_char *, u_int);
 extern void lcp_print(netdissect_options *,const u_char *, u_int);
 extern void vrrp_print(netdissect_options *,const u_char *bp,
                       u_int len, int ttl);
+extern void carp_print(netdissect_options *,const u_char *bp,
+                      u_int len, int ttl);
 extern void cdp_print(netdissect_options *,const u_char *,
                      u_int, u_int, const u_char *, const u_char *);
 extern void stp_print(netdissect_options *,const u_char *p, u_int length);
diff --git a/ospf.h b/ospf.h
index 2b1c6ee4c6b749b9b59ba5d1f163ec1e56649039..b86458baa7eea9f7e8ec3387503e3503261c489f 100644 (file)
--- a/ospf.h
+++ b/ospf.h
@@ -324,5 +324,5 @@ struct ospfhdr {
 #define        ospf_lsa        ospf_un.un_lsa
 
 /* Functions shared by ospf and ospf6 */
-extern int ospf_print_te_lsa(u_int8_t *, u_int);
-extern int ospf_print_grace_lsa(u_int8_t *, u_int);
+extern int ospf_print_te_lsa(const u_int8_t *, u_int);
+extern int ospf_print_grace_lsa(const u_int8_t *, u_int);
index 0ca86cfca087d31c5214d64bcbec32df56a77742..905ef4656003a2c4f88b0ec719dc0cc161dd0be8 100644 (file)
@@ -318,6 +318,7 @@ arp_print(netdissect_options *ndo,
             return;
         case ARPHRD_FRELAY:
             linkaddr = LINKADDR_FRELAY;
+            break;
         default:
             linkaddr = LINKADDR_ETHER;
             break;
index 135898bad91a89e2d5ba777eceeed83594f2ad6e..935d182753b800122df6ed4b2165839b1051e81f 100644 (file)
@@ -270,10 +270,12 @@ sig_print(const u_char *p, int caplen)
                printf(":%s ",
                    tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]));
 
-               if (caplen < CALL_REF_POS+3) {
-                       printf("[|atm]");
-                       return;
-               }
+               /*
+                * The call reference comes before the message type,
+                * so if we know we have the message type, which we
+                * do from the caplen test above, we also know we have
+                * the call reference.
+                */
                call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
                printf("CALL_REF:0x%06x", call_ref);
        } else {
diff --git a/print-carp.c b/print-carp.c
new file mode 100644 (file)
index 0000000..ba5be7c
--- /dev/null
@@ -0,0 +1,88 @@
+/*     $OpenBSD: print-carp.c,v 1.6 2009/10/27 23:59:55 deraadt Exp $  */
+
+/*
+ * Copyright (c) 2000 William C. Fenner.
+ *                All rights reserved.
+ *
+ * Kevin Steves <[email protected]> July 2000
+ * Modified to:
+ * - print version, type string and packet length
+ * - print IP address count if > 1 (-v)
+ * - verify checksum (-v)
+ * - print authentication string (-v)
+ *
+ * Copyright (c) 2011 Advanced Computing Technologies
+ * George V. Neille-Neil
+ *
+ * Modified to:
+ * - work correctly with CARP
+ * - compile into the latest tcpdump
+ * - print out the counter
+ *
+ * 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.
+ * The name of William C. Fenner may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.  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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <netinet/in.h>
+
+#include "interface.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+void
+carp_print(register const u_char *bp, register u_int len, int ttl)
+{
+       int version, type;
+       const char *type_s;
+
+       TCHECK(bp[0]);
+       version = (bp[0] & 0xf0) >> 4;
+       type = bp[0] & 0x0f;
+       if (type == 1)
+               type_s = "advertise";
+       else
+               type_s = "unknown";
+       printf("CARPv%d-%s %d: ", version, type_s, len);
+       if (ttl != 255)
+               printf("[ttl=%d!] ", ttl);
+       if (version != 2 || type != 1)
+               return;
+       TCHECK(bp[2]);
+       TCHECK(bp[5]);
+       printf("vhid=%d advbase=%d advskew=%d authlen=%d ",
+           bp[1], bp[5], bp[2], bp[3]);
+       if (vflag) {
+               struct cksum_vec vec[1];
+               vec[0].ptr = (const u_int8_t *)bp;
+               vec[0].len = len;
+               if (TTEST2(bp[0], len) && in_cksum(vec, 1))
+                       printf(" (bad carp cksum %x!)",
+                               EXTRACT_16BITS(&bp[6]));
+       }
+       printf("counter=%" PRIu64, EXTRACT_64BITS(&bp[8]));
+
+       return;
+trunc:
+       printf("[|carp]");
+}
index 2787bafb9d2606c0f0596dc5b8c844561a604f88..4f941d96629e8517fc0825c6755afa58715082f2 100644 (file)
@@ -280,7 +280,7 @@ eigrp_print(register const u_char *pptr, register u_int len) {
 
         if (eigrp_tlv_len < sizeof(struct eigrp_tlv_header) ||
             eigrp_tlv_len > tlen) {
-            print_unknown_data(tptr+sizeof(sizeof(struct eigrp_tlv_header)),"\n\t    ",tlen);
+            print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t    ",tlen);
             return;
         }
 
@@ -468,7 +468,7 @@ eigrp_print(register const u_char *pptr, register u_int len) {
         }
         /* do we want to see an additionally hexdump ? */
         if (vflag > 1)
-            print_unknown_data(tptr+sizeof(sizeof(struct eigrp_tlv_header)),"\n\t    ",
+            print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t    ",
                                eigrp_tlv_len-sizeof(struct eigrp_tlv_header));
 
         tptr+=eigrp_tlv_len;
index 8727bff59d3dcdb7ebd881aba69a359b63af2724..76505721af3e0594589fd7caa449f8148d7525c9 100644 (file)
@@ -252,6 +252,63 @@ ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
        return (ETHER_HDRLEN);
 }
 
+/*
+ * This is the top level routine of the printer.  'p' points
+ * to the ether header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ *
+ * This is for DLT_NETANALYZER, which has a 4-byte pseudo-header
+ * before the Ethernet header.
+ */
+u_int
+netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+                     const u_char *p)
+{
+       /*
+        * Fail if we don't have enough data for the Hilscher pseudo-header.
+        */
+       if (h->len < 4 || h->caplen < 4) {
+               printf("[|netanalyzer]");
+               return (h->caplen);
+       }
+
+       /* Skip the pseudo-header. */
+       ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL);
+
+       return (4 + ETHER_HDRLEN);
+}
+
+/*
+ * This is the top level routine of the printer.  'p' points
+ * to the ether header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ *
+ * This is for DLT_NETANALYZER_TRANSPARENT, which has a 4-byte
+ * pseudo-header, a 7-byte Ethernet preamble, and a 1-byte Ethernet SOF
+ * before the Ethernet header.
+ */
+u_int
+netanalyzer_transparent_if_print(netdissect_options *ndo,
+                                 const struct pcap_pkthdr *h,
+                                 const u_char *p)
+{
+       /*
+        * Fail if we don't have enough data for the Hilscher pseudo-header,
+        * preamble, and SOF.
+        */
+       if (h->len < 12 || h->caplen < 12) {
+               printf("[|netanalyzer-transparent]");
+               return (h->caplen);
+       }
+
+       /* Skip the pseudo-header, preamble, and SOF. */
+       ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL);
+
+       return (12 + ETHER_HDRLEN);
+}
+
 /*
  * Prints the packet payload, given an Ethernet type code for the payload's
  * protocol.
index d2df0a898c999fb46ed497be53d9b1fadb924e1e..1fa7aab0d6cae8830aa92c9f8ac3cf37dfb9d01a 100644 (file)
@@ -462,7 +462,19 @@ again:
                break;
 
        case IPPROTO_VRRP:
-               vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+               if (packettype == PT_CARP) {
+                       if (vflag)
+                               (void)printf("carp %s > %s: ",
+                                            ipaddr_string(&ipds->ip->ip_src),
+                                            ipaddr_string(&ipds->ip->ip_dst));
+                       carp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+               } else {
+                       if (vflag)
+                               (void)printf("vrrp %s > %s: ",
+                                            ipaddr_string(&ipds->ip->ip_src),
+                                            ipaddr_string(&ipds->ip->ip_dst));
+                       vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+               }
                break;
 
        case IPPROTO_PGM:
index 7e2bba70a4024af63c92a97c60a218c934c7d8b0..57637055377b2c6c9c60f67e1b0ff076d08fee8e 100644 (file)
@@ -618,10 +618,6 @@ struct isis_tlv_lsp {
 
 void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
 {
-       const struct isis_common_header *header;
-
-       header = (const struct isis_common_header *)p;
-
         if (caplen <= 1) { /* enough bytes on the wire ? */
             printf("|OSI");
             return;
@@ -1179,15 +1175,15 @@ esis_print(const u_int8_t *pptr, u_int length)
        }
 
         /* now walk the options */
-        while (li >= 2) {
+        while (li != 0) {
             u_int op, opli;
             const u_int8_t *tptr;
             
-            TCHECK2(*pptr, 2);
             if (li < 2) {
                 printf(", bad opts/li");
                 return;
             }
+            TCHECK2(*pptr, 2);
             op = *pptr++;
             opli = *pptr++;
             li -= 2;
@@ -1206,8 +1202,11 @@ esis_print(const u_int8_t *pptr, u_int length)
             switch (op) {
 
             case ESIS_OPTION_ES_CONF_TIME:
-                TCHECK2(*pptr, 2);
-                printf("%us", EXTRACT_16BITS(tptr));
+                if (opli == 2) {
+                    TCHECK2(*pptr, 2);
+                    printf("%us", EXTRACT_16BITS(tptr));
+                } else
+                    printf("(bad length)");
                 break;
 
             case ESIS_OPTION_PROTOCOLS:
index de3b34e5b54f94d264863f8286a1956ccd85901b..1243104855b7414faaca60c2623b21695192199e 100644 (file)
@@ -609,7 +609,7 @@ ldp_msg_print(register const u_char *pptr) {
         }
         /* do we want to see an additionally hexdump ? */
         if (vflag > 1 || hexdump==TRUE)
-            print_unknown_data(tptr+sizeof(sizeof(struct ldp_msg_header)),"\n\t  ",
+            print_unknown_data(tptr+sizeof(struct ldp_msg_header),"\n\t  ",
                                msg_len);
 
         tptr += msg_len+4;
index 556db173e49bd33e2a9603185ef754a8de25379c..e09b89fc22ed22f5602d0739b6138dd0b8048a42 100644 (file)
@@ -871,7 +871,7 @@ lmp_print(register const u_char *pptr, register u_int len) {
         }
         /* do we want to see an additionally hexdump ? */
         if (vflag > 1 || hexdump==TRUE)
-            print_unknown_data(tptr+sizeof(sizeof(struct lmp_object_header)),"\n\t    ",
+            print_unknown_data(tptr+sizeof(struct lmp_object_header),"\n\t    ",
                                lmp_obj_len-sizeof(struct lmp_object_header));
 
         tptr+=lmp_obj_len;
index 6958bdac7e73fe9114e9e03b884bf3a9514637f4..2ca57fb05cf9dd48bfb243ae9a144b61f4bfa81c 100644 (file)
@@ -878,7 +878,7 @@ lspping_print(register const u_char *pptr, register u_int len) {
         }
         /* do we want to see an additionally tlv hexdump ? */
         if (vflag > 1 || tlv_hexdump==TRUE)
-            print_unknown_data(tptr+sizeof(sizeof(struct lspping_tlv_header)),"\n\t    ",
+            print_unknown_data(tptr+sizeof(struct lspping_tlv_header),"\n\t    ",
                                lspping_tlv_len);
 
 
index 738a13c279244a45ed3c2e21903681555cfe98cf..f8ff4aeac5b0d770ca4f72a99321e623b062f82d 100644 (file)
@@ -197,7 +197,7 @@ static int ospf_decode_v2(const struct ospfhdr *, const u_char *);
 static int ospf_decode_lls(const struct ospfhdr *, register u_int);
 
 int
-ospf_print_grace_lsa (u_int8_t *tptr, u_int ls_length) {
+ospf_print_grace_lsa (const u_int8_t *tptr, u_int ls_length) {
 
     u_int tlv_type, tlv_length;
 
@@ -279,7 +279,7 @@ trunc:
 }
 
 int
-ospf_print_te_lsa (u_int8_t *tptr, u_int ls_length) {
+ospf_print_te_lsa (const u_int8_t *tptr, u_int ls_length) {
 
     u_int tlv_type, tlv_length, subtlv_type, subtlv_length;
     u_int priority_level, te_class, count_srlg;
index 11004856705bcc88a3e96144617139e57016a710..fb62b3968597f64103e65dc994ae873191ba0968 100644 (file)
@@ -160,17 +160,25 @@ trunc:
 }
 
 static int
-ospf6_print_lsaprefix(register const struct lsa6_prefix *lsapp)
+ospf6_print_lsaprefix(const u_int8_t *tptr, u_int lsa_length)
 {
+       const struct lsa6_prefix *lsapp = (struct lsa6_prefix *)tptr;
        u_int wordlen;
        struct in6_addr prefix;
 
-       TCHECK(*lsapp);
+       if (lsa_length < sizeof (*lsapp) - 4)
+               goto trunc;
+       lsa_length -= sizeof (*lsapp) - 4;
+       TCHECK2(*lsapp, sizeof (*lsapp) - 4);
        wordlen = (lsapp->lsa_p_len + 31) / 32;
        if (wordlen * 4 > sizeof(struct in6_addr)) {
                printf(" bogus prefixlen /%d", lsapp->lsa_p_len);
                goto trunc;
        }
+       if (lsa_length < wordlen * 4)
+               goto trunc;
+       lsa_length -= wordlen * 4;
+       TCHECK2(lsapp->lsa_p_prefix, wordlen * 4);
        memset(&prefix, 0, sizeof(prefix));
        memcpy(&prefix, lsapp->lsa_p_prefix, wordlen * 4);
        printf("\n\t\t%s/%d", ip6addr_string(&prefix),
@@ -194,7 +202,6 @@ trunc:
 static int
 ospf6_print_lsa(register const struct lsa6 *lsap)
 {
-       register const u_char *ls_end, *ls_opt;
        register const struct rlalink6 *rlp;
 #if 0
        register const struct tos_metric *tosp;
@@ -210,34 +217,45 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
        register const u_int32_t *lp;
 #endif
        register u_int prefixes;
-       register int bytelen, length, lsa_length;
+       register int bytelen;
+       register u_int length, lsa_length;
        u_int32_t flags32;
-        u_int8_t *tptr;
+       const u_int8_t *tptr;
 
        if (ospf6_print_lshdr(&lsap->ls_hdr))
                return (1);
        TCHECK(lsap->ls_hdr.ls_length);
         length = EXTRACT_16BITS(&lsap->ls_hdr.ls_length);
+
+       /*
+        * The LSA length includes the length of the header;
+        * it must have a value that's at least that length.
+        * If it does, find the length of what follows the
+        * header.
+        */
+        if (length < sizeof(struct lsa6_hdr))
+               return (1);
         lsa_length = length - sizeof(struct lsa6_hdr);
-       ls_end = (u_char *)lsap + length;
         tptr = (u_int8_t *)lsap+sizeof(struct lsa6_hdr);
 
        switch (EXTRACT_16BITS(&lsap->ls_hdr.ls_type)) {
        case LS_TYPE_ROUTER | LS_SCOPE_AREA:
+               if (lsa_length < sizeof (lsap->lsa_un.un_rla.rla_options))
+                       return (1);
+               lsa_length -= sizeof (lsap->lsa_un.un_rla.rla_options);
                TCHECK(lsap->lsa_un.un_rla.rla_options);
                 printf("\n\t      Options [%s]",
                        bittok2str(ospf6_option_values, "none",
                                   EXTRACT_32BITS(&lsap->lsa_un.un_rla.rla_options)));
-
-               TCHECK(lsap->lsa_un.un_rla.rla_flags);
                 printf(", RLA-Flags [%s]",
                        bittok2str(ospf6_rla_flag_values, "none",
                                   lsap->lsa_un.un_rla.rla_flags));
 
-
-               TCHECK(lsap->lsa_un.un_rla.rla_link);
                rlp = lsap->lsa_un.un_rla.rla_link;
-               while (rlp + 1 <= (struct rlalink6 *)ls_end) {
+               while (lsa_length != 0) {
+                       if (lsa_length < sizeof (*rlp))
+                               return (1);
+                       lsa_length -= sizeof (*rlp);
                        TCHECK(*rlp);
                        switch (rlp->link_type) {
 
@@ -276,13 +294,20 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
                break;
 
        case LS_TYPE_NETWORK | LS_SCOPE_AREA:
+               if (lsa_length < sizeof (lsap->lsa_un.un_nla.nla_options))
+                       return (1);
+               lsa_length -= sizeof (lsap->lsa_un.un_nla.nla_options);
                TCHECK(lsap->lsa_un.un_nla.nla_options);
                 printf("\n\t      Options [%s]",
                        bittok2str(ospf6_option_values, "none",
                                   EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options)));
+
                printf("\n\t      Connected Routers:");
                ap = lsap->lsa_un.un_nla.nla_router;
-               while ((u_char *)ap < ls_end) {
+               while (lsa_length != 0) {
+                       if (lsa_length < sizeof (*ap))
+                               return (1);
+                       lsa_length -= sizeof (*ap);
                        TCHECK(*ap);
                        printf("\n\t\t%s", ipaddr_string(ap));
                        ++ap;
@@ -290,18 +315,27 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
                break;
 
        case LS_TYPE_INTER_AP | LS_SCOPE_AREA:
+               if (lsa_length < sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric))
+                       return (1);
+               lsa_length -= sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric);
                TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
                printf(", metric %u",
                        EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC);
-               lsapp = lsap->lsa_un.un_inter_ap.inter_ap_prefix;
-               while (lsapp + sizeof(lsapp) <= (struct lsa6_prefix *)ls_end) {
-                       bytelen = ospf6_print_lsaprefix(lsapp);
-                       if (bytelen)
+
+               tptr = (u_int8_t *)lsap->lsa_un.un_inter_ap.inter_ap_prefix;
+               while (lsa_length != 0) {
+                       bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+                       if (bytelen < 0)
                                goto trunc;
-                       lsapp = (struct lsa6_prefix *)(((u_char *)lsapp) + bytelen);
+                       lsa_length -= bytelen;
+                       tptr += bytelen;
                }
                break;
-       case LS_SCOPE_AS | LS_TYPE_ASE:
+
+       case LS_TYPE_ASE | LS_SCOPE_AS:
+               if (lsa_length < sizeof (lsap->lsa_un.un_asla.asla_metric))
+                       return (1);
+               lsa_length -= sizeof (lsap->lsa_un.un_asla.asla_metric);
                TCHECK(lsap->lsa_un.un_asla.asla_metric);
                flags32 = EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric);
                 printf("\n\t     Flags [%s]",
@@ -309,48 +343,63 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
                printf(" metric %u",
                       EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric) &
                       ASLA_MASK_METRIC);
-               lsapp = lsap->lsa_un.un_asla.asla_prefix;
-               bytelen = ospf6_print_lsaprefix(lsapp);
+
+               tptr = (u_int8_t *)lsap->lsa_un.un_asla.asla_prefix;
+               lsapp = (struct lsa6_prefix *)tptr;
+               bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
                if (bytelen < 0)
                        goto trunc;
-               if ((ls_opt = (u_char *)(((u_char *)lsapp) + bytelen)) < ls_end) {
-                       struct in6_addr *fwdaddr6;
+               lsa_length -= bytelen;
+               tptr += bytelen;
 
-                       if ((flags32 & ASLA_FLAG_FWDADDR) != 0) {
-                               fwdaddr6 = (struct in6_addr *)ls_opt;
-                               TCHECK(*fwdaddr6);
-                               printf(" forward %s",
-                                      ip6addr_string(fwdaddr6));
-
-                               ls_opt += sizeof(struct in6_addr);
-                       }
-
-                       if ((flags32 & ASLA_FLAG_ROUTETAG) != 0) {
-                               TCHECK(*(u_int32_t *)ls_opt);
-                               printf(" tag %s",
-                                      ipaddr_string((u_int32_t *)ls_opt));
+               if ((flags32 & ASLA_FLAG_FWDADDR) != 0) {
+                       struct in6_addr *fwdaddr6;
 
-                               ls_opt += sizeof(u_int32_t);
-                       }
+                       fwdaddr6 = (struct in6_addr *)tptr;
+                       if (lsa_length < sizeof (*fwdaddr6))
+                               return (1);
+                       lsa_length -= sizeof (*fwdaddr6);
+                       TCHECK(*fwdaddr6);
+                       printf(" forward %s",
+                              ip6addr_string(fwdaddr6));
+                       tptr += sizeof(*fwdaddr6);
+               }
 
-                       if (lsapp->lsa_p_metric) {
-                               TCHECK(*(u_int32_t *)ls_opt);
-                               printf(" RefLSID: %s",
-                                      ipaddr_string((u_int32_t *)ls_opt));
+               if ((flags32 & ASLA_FLAG_ROUTETAG) != 0) {
+                       if (lsa_length < sizeof (u_int32_t))
+                               return (1);
+                       lsa_length -= sizeof (u_int32_t);
+                       TCHECK(*(u_int32_t *)tptr);
+                       printf(" tag %s",
+                              ipaddr_string((u_int32_t *)tptr));
+                       tptr += sizeof(u_int32_t);
+               }
 
-                               ls_opt += sizeof(u_int32_t);
-                       }
+               if (lsapp->lsa_p_metric) {
+                       if (lsa_length < sizeof (u_int32_t))
+                               return (1);
+                       lsa_length -= sizeof (u_int32_t);
+                       TCHECK(*(u_int32_t *)tptr);
+                       printf(" RefLSID: %s",
+                              ipaddr_string((u_int32_t *)tptr));
+                       tptr += sizeof(u_int32_t);
                }
                break;
 
        case LS_TYPE_LINK:
                /* Link LSA */
                llsap = &lsap->lsa_un.un_llsa;
-               TCHECK(llsap->llsa_options);
+               if (lsa_length < sizeof (llsap->llsa_priandopt))
+                       return (1);
+               lsa_length -= sizeof (llsap->llsa_priandopt);
+               TCHECK(llsap->llsa_priandopt);
                 printf("\n\t      Options [%s]",
                        bittok2str(ospf6_option_values, "none",
                                   EXTRACT_32BITS(&llsap->llsa_options)));
-               TCHECK(llsap->llsa_nprefix);
+
+               if (lsa_length < sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix))
+                       return (1);
+               lsa_length -= sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix);
                 prefixes = EXTRACT_32BITS(&llsap->llsa_nprefix);
                printf("\n\t      Priority %d, Link-local address %s, Prefixes %d:",
                        llsap->llsa_priority,
@@ -358,57 +407,63 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
                        prefixes);
 
                tptr = (u_int8_t *)llsap->llsa_prefix;
-                while (prefixes > 0) {
-                    lsapp = (struct lsa6_prefix *)tptr;
-                    if ((bytelen = ospf6_print_lsaprefix(lsapp)) == -1) {
-                        goto trunc;
-                    }
-                    prefixes--;
-                    tptr += bytelen;
-                }
+               while (prefixes > 0) {
+                       bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+                       if (bytelen < 0)
+                               goto trunc;
+                       prefixes--;
+                       lsa_length -= bytelen;
+                       tptr += bytelen;
+               }
                break;
 
        case LS_TYPE_INTRA_AP | LS_SCOPE_AREA:
                /* Intra-Area-Prefix LSA */
+               if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid))
+                       return (1);
+               lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid);
                TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
                ospf6_print_ls_type(
                        EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_lstype),
                        &lsap->lsa_un.un_intra_ap.intra_ap_lsid);
+
+               if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix))
+                       return (1);
+               lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
                TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
                 prefixes = EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
                printf("\n\t      Prefixes %d:", prefixes);
 
-                tptr = (u_int8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
-
-                while (prefixes > 0) {
-                    lsapp = (struct lsa6_prefix *)tptr;
-                    if ((bytelen = ospf6_print_lsaprefix(lsapp)) == -1) {
-                        goto trunc;
-                    }
-                    prefixes--;
-                    tptr += bytelen;
-                }
+               tptr = (u_int8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
+               while (prefixes > 0) {
+                       bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+                       if (bytelen < 0)
+                               goto trunc;
+                       prefixes--;
+                       lsa_length -= bytelen;
+                       tptr += bytelen;
+               }
                break;
 
         case LS_TYPE_GRACE | LS_SCOPE_LINKLOCAL:
                 if (ospf_print_grace_lsa(tptr, lsa_length) == -1) {
                     return 1;
                 }
-            
-            break;
+                break;
 
         case LS_TYPE_INTRA_ATE | LS_SCOPE_LINKLOCAL:
-            if (ospf_print_te_lsa(tptr, lsa_length) == -1) {
-                return 1;
-            }
-            break;
+                if (ospf_print_te_lsa(tptr, lsa_length) == -1) {
+                    return 1;
+                }
+                break;
 
        default:
-            if(!print_unknown_data(tptr,
-                                   "\n\t      ",
-                                   lsa_length)) {
-                return (1);
-            }
+                if(!print_unknown_data(tptr,
+                                       "\n\t      ",
+                                       lsa_length)) {
+                    return (1);
+                }
+                break;
        }
 
        return (0);
index 6aa2f6d71bd6eeeb8eb3690084f0157edf3b75df..1c76dcbbf6a9ac85f05236581c8356947a5da807 100644 (file)
@@ -1790,7 +1790,7 @@ _U_
         }
         /* do we also want to see a hex dump ? */
         if (vflag > 1 || hexdump==TRUE)
-            print_unknown_data(tptr+sizeof(sizeof(struct rsvp_object_header)),"\n\t    ", /* FIXME indentation */
+            print_unknown_data(tptr+sizeof(struct rsvp_object_header),"\n\t    ", /* FIXME indentation */
                                rsvp_obj_len-sizeof(struct rsvp_object_header));
 
         tptr+=rsvp_obj_len;
index eaf94ed9bbbccdc92d7cf2eb608eb5358eb0337c..fdfefccf386a00c9596fe49bcff67bbbde121525 100644 (file)
@@ -368,7 +368,7 @@ void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
             tlv_header->type != LACP_TLV_TERMINATOR &&
             tlv_header->type != MARKER_TLV_TERMINATOR) {
             printf("\n\t-----trailing data-----");
-            print_unknown_data(tptr+sizeof(sizeof(struct tlv_header_t)),"\n\t  ",tlen);
+            print_unknown_data(tptr+sizeof(struct tlv_header_t),"\n\t  ",tlen);
             return;
         }
 
@@ -441,7 +441,7 @@ void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
         }
         /* do we want to see an additional hexdump ? */
         if (vflag > 1) {
-            print_unknown_data(tptr+sizeof(sizeof(struct tlv_header_t)),"\n\t  ",
+            print_unknown_data(tptr+sizeof(struct tlv_header_t),"\n\t  ",
                                tlv_len-sizeof(struct tlv_header_t));
         }
 
index 6871b67c0489508c08e4f55cbbadf4bccc811f2a..aabda7714900066f2a606b0dca8bc4023a981658 100644 (file)
@@ -1291,7 +1291,6 @@ RA, \fInot\fP set) and `|' (truncated message, TC, set).
 If the
 `question' section doesn't contain exactly one entry, `[\fIn\fPq]'
 is printed.
-
 .HD
 SMB/CIFS decoding
 .LP
@@ -1299,19 +1298,18 @@ SMB/CIFS decoding
 on UDP/137, UDP/138 and TCP/139.
 Some primitive decoding of IPX and
 NetBEUI SMB data is also done.
-
+.LP
 By default a fairly minimal decode is done, with a much more detailed
 decode done if -v is used.
 Be warned that with -v a single SMB packet
 may take up a page or more, so only use -v if you really want all the
 gory details.
-
-For information on SMB packet formats and what all te fields mean see
+.LP
+For information on SMB packet formats and what all the fields mean see
 www.cifs.org or the pub/samba/specs/ directory on your favorite
 samba.org mirror site.
 The SMB patches were written by Andrew Tridgell
-
 .HD
 NFS Requests and Replies
 .LP
index fe9227075c10a867e09ca0332cf20b8dc01304e3..ac35b2b3490986d3d8c08b16a1478f62e6a55a6f 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -314,6 +314,12 @@ static struct ndo_printer ndo_printers[] = {
 #endif
 #ifdef DLT_PPI
        { ppi_if_print,         DLT_PPI },
+#endif
+#ifdef DLT_NETANALYZER
+       { netanalyzer_if_print, DLT_NETANALYZER },
+#endif
+#ifdef DLT_NETANALYZER_TRANSPARENT
+       { netanalyzer_transparent_if_print, DLT_NETANALYZER_TRANSPARENT },
 #endif
        { NULL,                 0 },
 };
@@ -927,6 +933,8 @@ main(int argc, char **argv)
                                packettype = PT_TFTP;
                        else if (strcasecmp(optarg, "aodv") == 0)
                                packettype = PT_AODV;
+                       else if (strcasecmp(optarg, "carp") == 0)
+                               packettype = PT_CARP;
                        else
                                error("unknown packet type `%s'", optarg);
                        break;
index db8eafb848de026ddda253b92b9ef17231358d4a..f754c1542e16fa24d7c9221436a3928123276287 100644 (file)
@@ -4,5 +4,5 @@ IP 192.1.2.23.4500 > 192.1.2.45.4500: UDP-encap: ESP(spi=0x12345678,seq=0x3), le
 IP 192.1.2.23.4500 > 192.1.2.45.4500: UDP-encap: ESP(spi=0x12345678,seq=0x4), length 116
 IP 192.1.2.23.4500 > 192.1.2.45.4500: UDP-encap: ESP(spi=0x12345678,seq=0x5), length 116
 IP 192.1.2.23.4500 > 192.1.2.45.4500: UDP-encap: ESP(spi=0x12345678,seq=0x6), length 116:  ip-proto-183 28
-IP 192.1.2.23.4500 > 192.1.2.45.4500: UDP-encap: ESP(spi=0x12345678,seq=0x7), length 116:  ip-proto-72 34
+IP 192.1.2.23.4500 > 192.1.2.45.4500: UDP-encap: ESP(spi=0x12345678,seq=0x7), length 116:  cpnx 34
 IP 192.1.2.23.4500 > 192.1.2.45.4500: UDP-encap: ESP(spi=0x12345678,seq=0x8), length 116:  ip-proto-224 59