]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Merge pull request #534 from MisterDA/hncp-20160728
authorMichael Richardson <[email protected]>
Fri, 29 Jul 2016 14:38:05 +0000 (16:38 +0200)
committerGitHub <[email protected]>
Fri, 29 Jul 2016 14:38:05 +0000 (16:38 +0200)
HNCP support (RFCs 7787 and 7788)

18 files changed:
VERSION
configure
configure.in
netdissect-stdinc.h
print-bgp.c
print-geneve.c
print-icmp6.c
print-lisp.c
print-lldp.c
print-ospf.c
print-resp.c
print-rpki-rtr.c
print-rsvp.c
tcpdump.c
tests/rpl-14-daovvv.out
tests/rpl-19-pickdag.out
tests/rpl-19-pickdagvvv.out
tests/rpl-26-senddaovv.out

diff --git a/VERSION b/VERSION
index 9fd56319967da0957d3374e53b10a5a901f50ccf..4a343b0d35999b291b5c92a74eb59401b0f8f14b 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.8.0-PRE-GIT
+4.9.0-PRE-GIT
index aab7239a1671d52bd8a74687f69e9c62de39967a..a5c1026a69e3192e0130e0d620e363c6d48a8338 100755 (executable)
--- a/configure
+++ b/configure
@@ -1343,7 +1343,8 @@ Optional Packages:
   --with-sandbox-capsicum use Capsicum security functions [default=yes, if
                           available]
   --with-system-libpcap   don't use local pcap library
-  --with-crypto           use OpenSSL libcrypto [default=yes, if available]
+  --with-crypto[=DIR]     use OpenSSL/libressl libcrypto (located in directory
+                          DIR, if specified) [default=yes, if available]
   --with-cap-ng           use libcap-ng [default=yes, if available]
 
 Some influential environment variables:
@@ -7951,9 +7952,9 @@ $as_echo "#define LBL_ALIGN 1" >>confdefs.h
 
     fi
 
-# Check for OpenSSL libcrypto
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use OpenSSL libcrypto" >&5
-$as_echo_n "checking whether to use OpenSSL libcrypto... " >&6; }
+# Check for OpenSSL/libressl libcrypto
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use OpenSSL/libressl libcrypto" >&5
+$as_echo_n "checking whether to use OpenSSL/libressl libcrypto... " >&6; }
 # Specify location for both includes and libraries.
 want_libcrypto=ifavailable
 
@@ -7962,20 +7963,38 @@ if test "${with_crypto+set}" = set; then :
   withval=$with_crypto;
        if test $withval = no
        then
+               # User doesn't want to link with libcrypto.
                want_libcrypto=no
                { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
        elif test $withval = yes
        then
+               # User wants to link with libcrypto but hasn't specified
+               # a directory.
                want_libcrypto=yes
                { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
+       else
+               # User wants to link with libcrypto and has specified
+               # a directory, so use the provided value.
+               want_libcrypto=yes
+               libcrypto_root=$withval
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, using the version installed in $withval" >&5
+$as_echo "yes, using the version installed in $withval" >&6; }
+
+               #
+               # Put the subdirectories of the libcrypto root directory
+               # at the front of the header and library search path.
+               #
+               CFLAGS="-I$withval/include $CFLAGS"
+               LIBS="-L$withval/lib $LIBS"
        fi
 
 else
 
        #
-       # Use libcrypto if it's present, otherwise don't.
+       # Use libcrypto if it's present, otherwise don't; no directory
+       # was specified.
        #
        want_libcrypto=ifavailable
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, if available" >&5
index 22ecee6fccb789886626849ca4098675e4b6e27a..d7484ede34bfe34b9982eec63b8335d91568db1f 100644 (file)
@@ -881,26 +881,43 @@ AC_LBL_SOCKADDR_SA_LEN
 
 AC_LBL_UNALIGNED_ACCESS
 
-# Check for OpenSSL libcrypto
-AC_MSG_CHECKING(whether to use OpenSSL libcrypto)
+# Check for OpenSSL/libressl libcrypto
+AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
 # Specify location for both includes and libraries.
 want_libcrypto=ifavailable
 AC_ARG_WITH(crypto,
-    AS_HELP_STRING([--with-crypto],
-                  [use OpenSSL libcrypto @<:@default=yes, if available@:>@]),
+    AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
+                  [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
 [
        if test $withval = no
        then
+               # User doesn't want to link with libcrypto.
                want_libcrypto=no
                AC_MSG_RESULT(no)
        elif test $withval = yes
        then
+               # User wants to link with libcrypto but hasn't specified
+               # a directory.
                want_libcrypto=yes
                AC_MSG_RESULT(yes)
+       else
+               # User wants to link with libcrypto and has specified
+               # a directory, so use the provided value.
+               want_libcrypto=yes
+               libcrypto_root=$withval
+               AC_MSG_RESULT([yes, using the version installed in $withval])
+
+               #
+               # Put the subdirectories of the libcrypto root directory
+               # at the front of the header and library search path.
+               #
+               CFLAGS="-I$withval/include $CFLAGS"
+               LIBS="-L$withval/lib $LIBS"
        fi
 ],[
        #
-       # Use libcrypto if it's present, otherwise don't.
+       # Use libcrypto if it's present, otherwise don't; no directory
+       # was specified.
        #
        want_libcrypto=ifavailable
        AC_MSG_RESULT([yes, if available])
index e201afa45a317a2826138ccca281eaab9fa4f88e..c7070f0a04c25453fc7aba7e50da66c4d1aa1401 100755 (executable)
@@ -319,6 +319,7 @@ typedef char* caddr_t;
  * define struct in6_addr so that we can use it for IPv6 addresses.
  */
 #ifndef HAVE_OS_IPV6_SUPPORT
+#ifndef AF_INET6
 #define AF_INET6       24
 
 struct in6_addr {
@@ -329,11 +330,12 @@ struct in6_addr {
        } __u6_addr;                    /* 128-bit IP6 address */
 };
 #endif
+#endif
 
 #ifndef NI_MAXHOST
 #define        NI_MAXHOST      1025
 #endif
-  
+
 #ifndef INET_ADDRSTRLEN
 #define INET_ADDRSTRLEN 16
 #endif
index fd25ba84cdbf6e475b40e3614374b2c9bfab9832..09f3fe6606d446d48e9cf8cc1d1474f1119e698f 100644 (file)
@@ -520,7 +520,7 @@ decode_prefix4(netdissect_options *ndo,
                ((u_char *)&addr)[plenbytes - 1] &=
                        ((0xff00 >> (plen % 8)) & 0xff);
        }
-       snprintf(buf, buflen, "%s/%d", getname(ndo, (u_char *)&addr), plen);
+       snprintf(buf, buflen, "%s/%d", ipaddr_string(ndo, &addr), plen);
        return 1 + plenbytes;
 
 trunc:
@@ -570,7 +570,7 @@ decode_labeled_prefix4(netdissect_options *ndo,
        }
         /* the label may get offsetted by 4 bits so lets shift it right */
        snprintf(buf, buflen, "%s/%d, label:%u %s",
-                 getname(ndo, (u_char *)&addr),
+                 ipaddr_string(ndo, &addr),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -790,7 +790,7 @@ decode_labeled_vpn_prefix4(netdissect_options *ndo,
         /* the label may get offsetted by 4 bits so lets shift it right */
        snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
                  bgp_vpn_rd_print(ndo, pptr+4),
-                 getname(ndo, (u_char *)&addr),
+                 ipaddr_string(ndo, &addr),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -996,8 +996,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
            buf[0]='\0';
            stringlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s",
                               bgp_vpn_rd_print(ndo, pptr),
-                              /* need something like getname(ndo, ) here */
-                              getname(ndo, pptr+8)
+                              ipaddr_string(ndo, pptr+8)
                               );
            UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
            pptr+=12;
@@ -1092,7 +1091,7 @@ decode_prefix6(netdissect_options *ndo,
                addr.s6_addr[plenbytes - 1] &=
                        ((0xff00 >> (plen % 8)) & 0xff);
        }
-       snprintf(buf, buflen, "%s/%d", getname6(ndo, (u_char *)&addr), plen);
+       snprintf(buf, buflen, "%s/%d", ip6addr_string(ndo, &addr), plen);
        return 1 + plenbytes;
 
 trunc:
@@ -1133,7 +1132,7 @@ decode_labeled_prefix6(netdissect_options *ndo,
        }
         /* the label may get offsetted by 4 bits so lets shift it right */
        snprintf(buf, buflen, "%s/%d, label:%u %s",
-                 getname6(ndo, (u_char *)&addr),
+                 ip6addr_string(ndo, &addr),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1175,7 +1174,7 @@ decode_labeled_vpn_prefix6(netdissect_options *ndo,
         /* the label may get offsetted by 4 bits so lets shift it right */
        snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
                  bgp_vpn_rd_print(ndo, pptr+4),
-                 getname6(ndo, (u_char *)&addr),
+                 ip6addr_string(ndo, &addr),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1394,7 +1393,7 @@ bgp_attr_print(netdissect_options *ndo,
                        ND_PRINT((ndo, "invalid len"));
                else {
                        ND_TCHECK2(tptr[0], 4);
-                       ND_PRINT((ndo, "%s", getname(ndo, tptr)));
+                       ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
                }
                break;
        case BGPTYPE_MULTI_EXIT_DISC:
@@ -1424,11 +1423,11 @@ bgp_attr_print(netdissect_options *ndo,
                 if (len == 6) {
                    ND_PRINT((ndo, " AS #%s, origin %s",
                        as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)),
-                       getname(ndo, tptr + 2)));
+                       ipaddr_string(ndo, tptr + 2)));
                 } else {
                    ND_PRINT((ndo, " AS #%s, origin %s",
                        as_printf(ndo, astostr, sizeof(astostr),
-                       EXTRACT_32BITS(tptr)), getname(ndo, tptr + 4)));
+                       EXTRACT_32BITS(tptr)), ipaddr_string(ndo, tptr + 4)));
                 }
                 break;
        case BGPTYPE_AGGREGATOR4:
@@ -1439,7 +1438,7 @@ bgp_attr_print(netdissect_options *ndo,
                ND_TCHECK2(tptr[0], 8);
                ND_PRINT((ndo, " AS #%s, origin %s",
                    as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
-                   getname(ndo, tptr + 4)));
+                   ipaddr_string(ndo, tptr + 4)));
                break;
        case BGPTYPE_COMMUNITIES:
                if (len % 4) {
@@ -1477,7 +1476,7 @@ bgp_attr_print(netdissect_options *ndo,
                        break;
                }
                ND_TCHECK2(tptr[0], 4);
-                ND_PRINT((ndo, "%s",getname(ndo, tptr)));
+                ND_PRINT((ndo, "%s",ipaddr_string(ndo, tptr)));
                 break;
         case BGPTYPE_CLUSTER_LIST:
                if (len % 4) {
@@ -1487,7 +1486,7 @@ bgp_attr_print(netdissect_options *ndo,
                 while (tlen>0) {
                        ND_TCHECK2(tptr[0], 4);
                         ND_PRINT((ndo, "%s%s",
-                               getname(ndo, tptr),
+                               ipaddr_string(ndo, tptr),
                                 (tlen>4) ? ", " : ""));
                         tlen -=4;
                         tptr +=4;
@@ -1570,7 +1569,7 @@ bgp_attr_print(netdissect_options *ndo,
                                 tlen = 0;
                             } else {
                                 ND_TCHECK2(tptr[0], sizeof(struct in_addr));
-                                ND_PRINT((ndo, "%s",getname(ndo, tptr)));
+                                ND_PRINT((ndo, "%s",ipaddr_string(ndo, tptr)));
                                 tlen -= sizeof(struct in_addr);
                                 tptr += sizeof(struct in_addr);
                             }
@@ -1585,7 +1584,7 @@ bgp_attr_print(netdissect_options *ndo,
                                 ND_TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN);
                                 ND_PRINT((ndo, "RD: %s, %s",
                                        bgp_vpn_rd_print(ndo, tptr),
-                                       getname(ndo, tptr+BGP_VPN_RD_LEN)));
+                                       ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN)));
                                 tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
                                 tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
                             }
@@ -1599,7 +1598,7 @@ bgp_attr_print(netdissect_options *ndo,
                                 tlen = 0;
                             } else {
                                 ND_TCHECK2(tptr[0], sizeof(struct in6_addr));
-                                ND_PRINT((ndo, "%s", getname6(ndo, tptr)));
+                                ND_PRINT((ndo, "%s", ip6addr_string(ndo, tptr)));
                                 tlen -= sizeof(struct in6_addr);
                                 tptr += sizeof(struct in6_addr);
                             }
@@ -1614,7 +1613,7 @@ bgp_attr_print(netdissect_options *ndo,
                                 ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
                                 ND_PRINT((ndo, "RD: %s, %s",
                                        bgp_vpn_rd_print(ndo, tptr),
-                                       getname6(ndo, tptr+BGP_VPN_RD_LEN)));
+                                       ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN)));
                                 tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
                                 tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
                             }
@@ -1628,7 +1627,7 @@ bgp_attr_print(netdissect_options *ndo,
                                 tlen = 0;
                             } else {
                                 ND_TCHECK2(tptr[0], sizeof(struct in_addr));
-                                ND_PRINT((ndo, "%s", getname(ndo, tptr)));
+                                ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
                                 tlen -= (sizeof(struct in_addr));
                                 tptr += (sizeof(struct in_addr));
                             }
@@ -1655,10 +1654,10 @@ bgp_attr_print(netdissect_options *ndo,
                                        isonsap_string(ndo, tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN)));
                                 /* rfc986 mapped IPv4 address ? */
                                 if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) ==  0x47000601)
-                                    ND_PRINT((ndo, " = %s", getname(ndo, tptr+BGP_VPN_RD_LEN+4)));
+                                    ND_PRINT((ndo, " = %s", ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN+4)));
                                 /* rfc1888 mapped IPv6 address ? */
                                 else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) ==  0x350000)
-                                    ND_PRINT((ndo, " = %s", getname6(ndo, tptr+BGP_VPN_RD_LEN+3)));
+                                    ND_PRINT((ndo, " = %s", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3)));
                                 tptr += tlen;
                                 tlen = 0;
                             }
@@ -2026,14 +2025,14 @@ bgp_attr_print(netdissect_options *ndo,
                         ND_PRINT((ndo, ": %u:%u (= %s)",
                                EXTRACT_16BITS(tptr+2),
                                EXTRACT_32BITS(tptr+4),
-                               getname(ndo, tptr+4)));
+                               ipaddr_string(ndo, tptr+4)));
                         break;
                     case BGP_EXT_COM_RT_1:
                     case BGP_EXT_COM_RO_1:
                     case BGP_EXT_COM_L2VPN_RT_1:
                     case BGP_EXT_COM_VRF_RT_IMP:
                         ND_PRINT((ndo, ": %s:%u",
-                               getname(ndo, tptr+2),
+                               ipaddr_string(ndo, tptr+2),
                                EXTRACT_16BITS(tptr+6)));
                         break;
                     case BGP_EXT_COM_RT_2:
@@ -2053,12 +2052,12 @@ bgp_attr_print(netdissect_options *ndo,
                     case BGP_EXT_COM_VPN_ORIGIN4:
                     case BGP_EXT_COM_OSPF_RID:
                     case BGP_EXT_COM_OSPF_RID2:
-                        ND_PRINT((ndo, "%s", getname(ndo, tptr+2)));
+                        ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr+2)));
                         break;
                     case BGP_EXT_COM_OSPF_RTYPE:
                     case BGP_EXT_COM_OSPF_RTYPE2:
                         ND_PRINT((ndo, ": area:%s, router-type:%s, metric-type:%s%s",
-                               getname(ndo, tptr+2),
+                               ipaddr_string(ndo, tptr+2),
                                tok2str(bgp_extd_comm_ospf_rtype_values,
                                          "unknown (0x%02x)",
                                          *(tptr+6)),
@@ -2373,7 +2372,7 @@ bgp_open_print(netdissect_options *ndo,
        ND_PRINT((ndo, "my AS %s, ",
            as_printf(ndo, astostr, sizeof(astostr), ntohs(bgpo.bgpo_myas))));
        ND_PRINT((ndo, "Holdtime %us, ", ntohs(bgpo.bgpo_holdtime)));
-       ND_PRINT((ndo, "ID %s", getname(ndo, (u_char *)&bgpo.bgpo_id)));
+       ND_PRINT((ndo, "ID %s", ipaddr_string(ndo, &bgpo.bgpo_id)));
        ND_PRINT((ndo, "\n\t  Optional parameters, length: %u", bgpo.bgpo_optlen));
 
         /* some little sanity checking */
index 7550ba06a1c3435243cd89970a71f9a328332be0..c4645dbee09dfb4b4b56b05630d697dded7e966f 100644 (file)
@@ -26,7 +26,7 @@
 #include "ethertype.h"
 
 /*
- * Geneve header, draft-gross-geneve-02
+ * Geneve header, draft-ietf-nvo3-geneve
  *
  *    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
@@ -76,12 +76,25 @@ static const struct tok geneve_flag_values[] = {
 static const char *
 format_opt_class(uint16_t opt_class)
 {
-    if (opt_class <= 0xff)
-        return "Standard";
-    else if (opt_class == 0xffff)
-        return "Experimental";
-    else
-        return "Unknown";
+    switch (opt_class) {
+    case 0x0100:
+        return "Linux";
+    case 0x0101:
+        return "Open vSwitch";
+    case 0x0102:
+        return "Open Virtual Networking (OVN)";
+    case 0x0103:
+        return "In-band Network Telemetry (INT)";
+    case 0x0104:
+        return "VMware";
+    default:
+        if (opt_class <= 0x00ff)
+            return "Standard";
+        else if (opt_class >= 0xfff0)
+            return "Experimental";
+    }
+
+    return "Unknown";
 }
 
 static void
@@ -183,7 +196,7 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
 
     if (len < opts_len) {
         ND_PRINT((ndo, " truncated-geneve - %u bytes missing",
-                  len - opts_len));
+                  opts_len - len));
         return;
     }
 
index ae53187452f6d0263ede548747f1082fcff58648..135f6ef981e9daed9d09dd0dcf71300a811e4af3 100644 (file)
@@ -648,23 +648,6 @@ const struct tok rpl_subopt_values[] = {
         { 0, NULL},
 };
 
-static void
-rpl_format_dagid(char dagid_str[65], const u_char *dagid)
-{
-        char *d = dagid_str;
-        int  i;
-
-        for(i=0;i<16;i++) {
-                if(isprint(dagid[i])) {
-                        *d++ = dagid[i];
-                } else {
-                        snprintf(d,5,"0x%02x", dagid[i]); /* 4 + null char */
-                        d += 4;
-                }
-        }
-        *d++ = '\0';
-}
-
 static void
 rpl_dio_printopt(netdissect_options *ndo,
                  const struct rpl_dio_genoption *opt,
@@ -710,10 +693,10 @@ rpl_dio_print(netdissect_options *ndo,
               const u_char *bp, u_int length)
 {
         const struct nd_rpl_dio *dio = (const struct nd_rpl_dio *)bp;
-        char dagid_str[65];
+        const char *dagid_str;
 
         ND_TCHECK(*dio);
-        rpl_format_dagid(dagid_str, dio->rpl_dagid);
+        dagid_str = ip6addr_string (ndo, dio->rpl_dagid);
 
         ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]",
                   dagid_str,
@@ -739,20 +722,19 @@ rpl_dao_print(netdissect_options *ndo,
               const u_char *bp, u_int length)
 {
         const struct nd_rpl_dao *dao = (const struct nd_rpl_dao *)bp;
-        char dagid_str[65];
+        const char *dagid_str = "<elided>";
 
         ND_TCHECK(*dao);
         if (length < ND_RPL_DAO_MIN_LEN)
                goto tooshort;
 
-        strcpy(dagid_str,"<elided>");
         bp += ND_RPL_DAO_MIN_LEN;
         length -= ND_RPL_DAO_MIN_LEN;
         if(RPL_DAO_D(dao->rpl_flags)) {
                 ND_TCHECK2(dao->rpl_dagid, DAGID_LEN);
                 if (length < DAGID_LEN)
                        goto tooshort;
-                rpl_format_dagid(dagid_str, dao->rpl_dagid);
+                dagid_str = ip6addr_string (ndo, dao->rpl_dagid);
                 bp += DAGID_LEN;
                 length -= DAGID_LEN;
         }
@@ -785,20 +767,19 @@ rpl_daoack_print(netdissect_options *ndo,
                  const u_char *bp, u_int length)
 {
         const struct nd_rpl_daoack *daoack = (const struct nd_rpl_daoack *)bp;
-        char dagid_str[65];
+        const char *dagid_str = "<elided>";
 
         ND_TCHECK2(*daoack, ND_RPL_DAOACK_MIN_LEN);
         if (length < ND_RPL_DAOACK_MIN_LEN)
                goto tooshort;
 
-        strcpy(dagid_str,"<elided>");
         bp += ND_RPL_DAOACK_MIN_LEN;
         length -= ND_RPL_DAOACK_MIN_LEN;
         if(RPL_DAOACK_D(daoack->rpl_flags)) {
-                ND_TCHECK2(daoack->rpl_dagid, 16);
+                ND_TCHECK2(daoack->rpl_dagid, DAGID_LEN);
                 if (length < DAGID_LEN)
                        goto tooshort;
-                rpl_format_dagid(dagid_str, daoack->rpl_dagid);
+                dagid_str = ip6addr_string (ndo, daoack->rpl_dagid);
                 bp += DAGID_LEN;
                 length -= DAGID_LEN;
         }
@@ -1099,10 +1080,10 @@ icmp6_print(netdissect_options *ndo,
        case ND_REDIRECT:
 #define RDR(i) ((const struct nd_redirect *)(i))
                          ND_TCHECK(RDR(dp)->nd_rd_dst);
-                         ND_PRINT((ndo,", %s", getname6(ndo, (const u_char *)&RDR(dp)->nd_rd_dst)));
+                         ND_PRINT((ndo,", %s", ip6addr_string(ndo, &RDR(dp)->nd_rd_dst)));
                ND_TCHECK(RDR(dp)->nd_rd_target);
                ND_PRINT((ndo," to %s",
-                          getname6(ndo, (const u_char*)&RDR(dp)->nd_rd_target)));
+                          ip6addr_string(ndo, &RDR(dp)->nd_rd_target)));
 #define REDIRECTLEN 40
                if (ndo->ndo_vflag) {
                        icmp6_opt_print(ndo, (const u_char *)dp + REDIRECTLEN,
@@ -1668,7 +1649,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                                break;
                        }
                        ND_PRINT((ndo,", subject=%s",
-                                  getname6(ndo, (const u_char *)(ni6 + 1))));
+                                  ip6addr_string(ndo, ni6 + 1)));
                        break;
                case ICMP6_NI_SUBJ_FQDN:
                        ND_PRINT((ndo,", subject=DNS name"));
@@ -1696,7 +1677,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                                break;
                        }
                        ND_PRINT((ndo,", subject=%s",
-                                  getname(ndo, (const u_char *)(ni6 + 1))));
+                                  ipaddr_string(ndo, ni6 + 1)));
                        break;
                default:
                        ND_PRINT((ndo,", unknown subject"));
@@ -1793,7 +1774,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                        while (i < siz) {
                                if (i + sizeof(struct in6_addr) + sizeof(int32_t) > siz)
                                        break;
-                               ND_PRINT((ndo," %s", getname6(ndo, bp + i)));
+                               ND_PRINT((ndo," %s", ip6addr_string(ndo, bp + i)));
                                i += sizeof(struct in6_addr);
                                ND_PRINT((ndo,"(%d)", (int32_t)EXTRACT_32BITS(bp + i)));
                                i += sizeof(int32_t);
index 757326dcf69e1facfb6401e27f02c6ca2bf5e55d..e9a2bc136df83de043a84d8aaecd8561395ec79c 100644 (file)
@@ -305,13 +305,13 @@ void lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
                switch (eid_afi) {
                case IPv4_AFI:
                        ND_TCHECK2(*(packet_iterator + packet_offset), 4);
-                       ND_PRINT((ndo, " EID %s/%u,", getname(ndo,
+                       ND_PRINT((ndo, " EID %s/%u,", ipaddr_string(ndo,
                                packet_iterator + packet_offset), mask_len));
                        packet_offset += 4;
                        break;
                case IPv6_AFI:
                        ND_TCHECK2(*(packet_iterator + packet_offset), 16);
-                       ND_PRINT((ndo, " EID %s/%u,", getname6(ndo,
+                       ND_PRINT((ndo, " EID %s/%u,", ip6addr_string(ndo,
                                packet_iterator + packet_offset), mask_len));
                        packet_offset += 16;
                        break;
@@ -338,12 +338,12 @@ void lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
                        switch (loc_afi) {
                        case IPv4_AFI:
                                ND_TCHECK2(*(packet_iterator + packet_offset), 4);
-                               ND_PRINT((ndo, " LOC %s", getname(ndo, loc_ip_pointer)));
+                               ND_PRINT((ndo, " LOC %s", ipaddr_string(ndo, loc_ip_pointer)));
                                packet_offset += 4;
                                break;
                        case IPv6_AFI:
                                ND_TCHECK2(*(packet_iterator + packet_offset), 16);
-                               ND_PRINT((ndo, " LOC %s", getname6(ndo, loc_ip_pointer)));
+                               ND_PRINT((ndo, " LOC %s", ip6addr_string(ndo, loc_ip_pointer)));
                                packet_offset += 16;
                                break;
                        default:
index 82b7ebec1508e2cf727151c70bf732e1725feae9..a0ca70092e4e3855b3fc62e4aebe2c4e1e20e310 100644 (file)
@@ -1278,11 +1278,13 @@ lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len)
     case AFNUM_INET:
         if (len < 4)
           return NULL;
+        /* This cannot be assigned to ipaddr_string(), which is a macro. */
         pfunc = getname;
         break;
     case AFNUM_INET6:
         if (len < 16)
           return NULL;
+        /* This cannot be assigned to ip6addr_string(), which is a macro. */
         pfunc = getname6;
         break;
     case AFNUM_802:
index e8aa26ce203a485792df0d64aa61dacc5763a67b..0e84e584dee7eca56201d9c9e8bb5b9e55a2e4d0 100644 (file)
@@ -566,16 +566,16 @@ trunc:
 
 /* draft-ietf-ospf-mt-09 */
 static const struct tok ospf_topology_values[] = {
-    { 0, "default " },
-    { 1, "multicast " },
-    { 2, "management " },
+    { 0, "default" },
+    { 1, "multicast" },
+    { 2, "management" },
     { 0, NULL }
 };
 
 /*
  * Print all the per-topology metrics.
  */
-static void
+static int
 ospf_print_tos_metrics(netdissect_options *ndo,
                        const union un_tos *tos)
 {
@@ -588,9 +588,10 @@ ospf_print_tos_metrics(netdissect_options *ndo,
     /*
      * All but the first metric contain a valid topology id.
      */
-    while (toscount) {
-        ND_PRINT((ndo, "\n\t\ttopology %s(%u), metric %u",
-               tok2str(ospf_topology_values, "",
+    while (toscount > 0) {
+        ND_TCHECK(*tos);
+        ND_PRINT((ndo, "\n\t\ttopology %s (%u), metric %u",
+               tok2str(ospf_topology_values, "Unknown",
                        metric_count ? tos->metrics.tos_type : 0),
                metric_count ? tos->metrics.tos_type : 0,
                EXTRACT_16BITS(&tos->metrics.tos_metric)));
@@ -598,6 +599,9 @@ ospf_print_tos_metrics(netdissect_options *ndo,
         tos++;
         toscount--;
     }
+    return 0;
+trunc:
+    return 1;
 }
 
 /*
@@ -671,7 +675,8 @@ ospf_print_lsa(netdissect_options *ndo,
                                return (ls_end);
                        }
 
-                       ospf_print_tos_metrics(ndo, &rlp->un_tos);
+                       if (ospf_print_tos_metrics(ndo, &rlp->un_tos))
+                               goto trunc;
 
                        rlp = (const struct rlalink *)((const u_char *)(rlp + 1) +
                            ((rlp->un_tos.link.link_tos_count) * sizeof(union un_tos)));
@@ -702,8 +707,8 @@ ospf_print_lsa(netdissect_options *ndo,
                        ND_TCHECK(*lp);
                        ul = EXTRACT_32BITS(lp);
                         topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
-                       ND_PRINT((ndo, "\n\t\ttopology %s(%u) metric %d",
-                               tok2str(ospf_topology_values, "", topology),
+                       ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d",
+                               tok2str(ospf_topology_values, "Unknown", topology),
                                topology,
                                ul & SLA_MASK_METRIC));
                        ++lp;
@@ -719,8 +724,8 @@ ospf_print_lsa(netdissect_options *ndo,
                        ND_TCHECK(*lp);
                        ul = EXTRACT_32BITS(lp);
                         topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
-                       ND_PRINT((ndo, "\n\t\ttopology %s(%u) metric %d",
-                               tok2str(ospf_topology_values, "", topology),
+                       ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d",
+                               tok2str(ospf_topology_values, "Unknown", topology),
                                topology,
                                ul & SLA_MASK_METRIC));
                        ++lp;
@@ -741,8 +746,8 @@ ospf_print_lsa(netdissect_options *ndo,
                        ND_TCHECK(almp->asla_tosmetric);
                        ul = EXTRACT_32BITS(&almp->asla_tosmetric);
                         topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS);
-                       ND_PRINT((ndo, "\n\t\ttopology %s(%u), type %d, metric",
-                               tok2str(ospf_topology_values, "", topology),
+                       ND_PRINT((ndo, "\n\t\ttopology %s (%u), type %d, metric",
+                               tok2str(ospf_topology_values, "Unknown", topology),
                                topology,
                                (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1));
                        if ((ul & ASLA_MASK_METRIC) == 0xffffff)
index 0aa3d69e6775c2781f39de366aa441fc30838399..5e36edafdae5398e69f48292238d42c8ef77674e 100644 (file)
@@ -141,7 +141,8 @@ static int resp_print_inline(netdissect_options *, register const u_char *, int)
  */
 #define RESP_PRINT_SEGMENT(_ndo, _bp, _len)            \
         ND_PRINT((_ndo, " \""));                       \
-        fn_printn(_ndo, _bp, _len, _ndo->ndo_snapend); \
+        if (fn_printn(_ndo, _bp, _len, _ndo->ndo_snapend)) \
+               goto trunc; \
         fn_print_char(_ndo, '"');
 
 void
index 3d2f383cd47f8c64eb12da55f51dfa77f99765ba..569bc4ea7f65a4e2fabc0eac8e8ade2ee62e14e4 100644 (file)
@@ -287,7 +287,8 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
            ND_TCHECK2(*tptr, text_length);
            if (text_length && (text_length <= tlen )) {
                ND_PRINT((ndo, "%sError text: ", indent_string(indent+2)));
-               fn_printn(ndo, tptr, text_length, ndo->ndo_snapend);
+               if (fn_printn(ndo, tptr, text_length, ndo->ndo_snapend))
+                       goto trunc;
            }
        }
        break;
index 93f6d670958d7faf64dc90971fa8097a040dc8f0..fa571036e5f74630d19218f42d9c8a6ae755381f 100644 (file)
@@ -1061,20 +1061,37 @@ rsvp_obj_print(netdissect_options *ndo,
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_IPV4:
                 while(obj_tlen >= 4 ) {
+                   u_char length;
+
+                   ND_TCHECK2(*obj_tptr, 4);
+                   length = *(obj_tptr + 1);
                     ND_PRINT((ndo, "%s  Subobject Type: %s, length %u",
                            ident,
                            tok2str(rsvp_obj_xro_values,
                                    "Unknown %u",
                                    RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)),
-                           *(obj_tptr + 1)));
+                           length));
 
-                    if (*(obj_tptr+1) == 0) { /* prevent infinite loops */
+                    if (length == 0) { /* prevent infinite loops */
                         ND_PRINT((ndo, "%s  ERROR: zero length ERO subtype", ident));
                         break;
                     }
 
                     switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) {
+                   u_char prefix_length;
+
                     case RSVP_OBJ_XRO_IPV4:
+                       if (length != 8) {
+                               ND_PRINT((ndo, " ERROR: length != 8"));
+                               goto invalid;
+                       }
+                       ND_TCHECK2(*obj_tptr, 8);
+                       prefix_length = *(obj_tptr+6);
+                       if (prefix_length != 32) {
+                               ND_PRINT((ndo, " ERROR: Prefix length %u != 32",
+                                         prefix_length));
+                               goto invalid;
+                       }
                         ND_PRINT((ndo, ", %s, %s/%u, Flags: [%s]",
                                RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? "Loose" : "Strict",
                                ipaddr_string(ndo, obj_tptr+2),
@@ -1084,6 +1101,11 @@ rsvp_obj_print(netdissect_options *ndo,
                                    *(obj_tptr + 7)))); /* rfc3209 says that this field is rsvd. */
                     break;
                     case RSVP_OBJ_XRO_LABEL:
+                       if (length != 8) {
+                               ND_PRINT((ndo, " ERROR: length != 8"));
+                               goto invalid;
+                       }
+                       ND_TCHECK2(*obj_tptr, 8);
                         ND_PRINT((ndo, ", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
                                bittok2str(rsvp_obj_rro_label_flag_values,
                                    "none",
index 1db35daafd5837f6a26ada69e1d6d5d06d593da8..5598ec282f2dff91f000a78075325c85ba319022 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -864,7 +864,7 @@ main(int argc, char **argv)
 
                case 'C':
                        Cflag = atoi(optarg) * 1000000;
-                       if (Cflag < 0)
+                       if (Cflag <= 0)
                                error("invalid file size %s", optarg);
                        break;
 
@@ -1115,8 +1115,8 @@ main(int argc, char **argv)
                                ndo->ndo_packettype = PT_PGM_ZMTP1;
                        else if (ascii_strcasecmp(optarg, "lmp") == 0)
                                ndo->ndo_packettype = PT_LMP;
-            else if (strcasecmp(optarg, "resp") == 0)
-                ndo->ndo_packettype = PT_RESP;
+                       else if (ascii_strcasecmp(optarg, "resp") == 0)
+                               ndo->ndo_packettype = PT_RESP;
                        else
                                error("unknown packet type `%s'", optarg);
                        break;
@@ -1145,7 +1145,7 @@ main(int argc, char **argv)
 
                case 'W':
                        Wflag = atoi(optarg);
-                       if (Wflag < 0)
+                       if (Wflag <= 0)
                                error("invalid number of output files %s", optarg);
                        WflagChars = getWflagChars(Wflag);
                        break;
index 7869e6bf7f4562c8f19bf11023b00b1b5c7ab6b1..7e4b8a5f60054f5bb2e22664d2147a9378d44af7 100644 (file)
@@ -1 +1 @@
-IP6 (hlim 64, next-header ICMPv6 (58) payload length: 24) fe80::216:3eff:fe11:3424 > ff02::1: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:pandora is fun0x0al,seq:1,instance:1,Dagid,40]
+IP6 (hlim 64, next-header ICMPv6 (58) payload length: 24) fe80::216:3eff:fe11:3424 > ff02::1: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:7061:6e64:6f72:6120:6973:2066:756e:a6c,seq:1,instance:1,Dagid,40]
index 2460ada4fa87a8ac7fd613a333320f68134c324a..d3c41eedeccf18970e73e502eaefc1359b71ffa3 100644 (file)
@@ -1 +1 @@
-IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:T10x000x000x000x000x000x000x000x000x000x000x000x000x000x00,seq:10,instance:42,Dagid,40] opt:rpltarget len:25  opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0
+IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:5431::,seq:10,instance:42,Dagid,40] opt:rpltarget len:25  opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0
index bd934537dc810998a9db95441730dc4324431e90..deee0331519878d7c39b0716edad17e5cc7a26fa 100644 (file)
@@ -1 +1 @@
-IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:T10x000x000x000x000x000x000x000x000x000x000x000x000x000x00,seq:10,instance:42,Dagid,40] opt:rpltarget len:25  0x0000:  0080 2001 0db8 0001 0000 0216 3eff fe11 0x0010:  3424 0000 0000 00 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0
+IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:5431::,seq:10,instance:42,Dagid,40] opt:rpltarget len:25  0x0000:  0080 2001 0db8 0001 0000 0216 3eff fe11 0x0010:  3424 0000 0000 00 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0
index 6d11c81c9904d8a50771b200ce0c9536f052ece0..1b642bb723d87413f77f0be84f8355c5480dfede 100644 (file)
@@ -1 +1 @@
-IP6 (hlim 64, next-header ICMPv6 (58) payload length: 24) fe80::216:3eff:fe11:3424 > ff02::1: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object Ack [dagid:thisismydicedag2,seq:11,instance:43,status:0]
+IP6 (hlim 64, next-header ICMPv6 (58) payload length: 24) fe80::216:3eff:fe11:3424 > ff02::1: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object Ack [dagid:7468:6973:6973:6d79:6469:6365:6461:6732,seq:11,instance:43,status:0]