]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-vxlan-gpe.c
On Solaris, for 64-bit builds, use the 64-bit pcap-config.
[tcpdump] / print-vxlan-gpe.c
index fb903c2105e88d1d28b00a5c9943d136ccb0f4ab..13cba422937778626aaf9c212c908b4748a80679 100644 (file)
@@ -23,7 +23,7 @@
 
 /* \summary: Generic Protocol Extension for VXLAN (VXLAN GPE) printer */
 
-/* specification: draft-ietf-nvo3-vxlan-gpe-01 */
+/* specification: draft-ietf-nvo3-vxlan-gpe-10 */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 
 #include "netdissect-stdinc.h"
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "extract.h"
 
-static const char tstr[] = " [|VXLAN-GPE]";
 static const struct tok vxlan_gpe_flags [] = {
     { 0x08, "I" },
     { 0x04, "P" },
+    { 0x02, "B" },
     { 0x01, "O" },
     { 0, NULL }
 };
@@ -65,50 +66,59 @@ vxlan_gpe_print(netdissect_options *ndo, const u_char *bp, u_int len)
     uint32_t vni;
 
     ndo->ndo_protocol = "vxlan_gpe";
-    if (len < VXLAN_GPE_HDR_LEN)
-        goto trunc;
+    ND_PRINT("VXLAN-GPE, ");
+    if (len < VXLAN_GPE_HDR_LEN) {
+        ND_PRINT(" (len %u < %u)", len, VXLAN_GPE_HDR_LEN);
+        goto invalid;
+    }
 
-    ND_TCHECK_LEN(bp, VXLAN_GPE_HDR_LEN);
+    flags = GET_U_1(bp);
+    bp += 1;
+    len -= 1;
+    ND_PRINT("flags [%s], ",
+              bittok2str_nosep(vxlan_gpe_flags, "none", flags));
 
-    flags = EXTRACT_U_1(bp);
-    bp += 3;
+    /* Reserved */
+    bp += 2;
+    len -= 2;
 
-    next_protocol = EXTRACT_U_1(bp);
+    next_protocol = GET_U_1(bp);
     bp += 1;
+    len -= 1;
 
-    vni = EXTRACT_BE_U_3(bp);
-    bp += 4;
+    vni = GET_BE_U_3(bp);
+    bp += 3;
+    len -= 3;
+
+    /* Reserved */
+    ND_TCHECK_1(bp);
+    bp += 1;
+    len -= 1;
 
-    ND_PRINT("VXLAN-GPE, ");
-    ND_PRINT("flags [%s], ",
-              bittok2str_nosep(vxlan_gpe_flags, "none", flags));
     ND_PRINT("vni %u", vni);
     ND_PRINT(ndo->ndo_vflag ? "\n    " : ": ");
 
     switch (next_protocol) {
     case 0x1:
-        ip_print(ndo, bp, len - VXLAN_GPE_HDR_LEN);
+        ip_print(ndo, bp, len);
         break;
     case 0x2:
-        ip6_print(ndo, bp, len - VXLAN_GPE_HDR_LEN);
+        ip6_print(ndo, bp, len);
         break;
     case 0x3:
-        ether_print(ndo, bp, len - VXLAN_GPE_HDR_LEN, ndo->ndo_snapend - bp, NULL, NULL);
+        ether_print(ndo, bp, len, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
         break;
     case 0x4:
-        nsh_print(ndo, bp, len - VXLAN_GPE_HDR_LEN);
-        break;
-    case 0x5:
-        mpls_print(ndo, bp, len - VXLAN_GPE_HDR_LEN);
+        nsh_print(ndo, bp, len);
         break;
     default:
         ND_PRINT("ERROR: unknown-next-protocol");
-        return;
+        goto invalid;
     }
 
        return;
 
-trunc:
-       ND_PRINT("%s", tstr);
+invalid:
+    nd_print_invalid(ndo);
 }