]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ip6opts.c
Update ND_PRINT() as a variadic macro
[tcpdump] / print-ip6opts.c
index 00cad3912b413dc2dffb5d9e1583475bb682b4f9..8448d905d8fc37af9e203a62dd7b6589b8818a43 100644 (file)
@@ -61,28 +61,28 @@ ip6_sopt_print(netdissect_options *ndo, const u_char *bp, int len)
 
        switch (EXTRACT_U_1(bp + i)) {
        case IP6OPT_PAD1:
-            ND_PRINT((ndo, ", pad1"));
+            ND_PRINT(", pad1");
            break;
        case IP6OPT_PADN:
            if (len - i < IP6OPT_MINLEN) {
-               ND_PRINT((ndo, ", padn: trunc"));
+               ND_PRINT(", padn: trunc");
                goto trunc;
            }
-            ND_PRINT((ndo, ", padn"));
+            ND_PRINT(", padn");
            break;
        default:
            if (len - i < IP6OPT_MINLEN) {
-               ND_PRINT((ndo, ", sopt_type %d: trunc)", EXTRACT_U_1(bp + i)));
+               ND_PRINT(", sopt_type %d: trunc)", EXTRACT_U_1(bp + i));
                goto trunc;
            }
-           ND_PRINT((ndo, ", sopt_type 0x%02x: len=%d", EXTRACT_U_1(bp + i), EXTRACT_U_1(bp + i + 1)));
+           ND_PRINT(", sopt_type 0x%02x: len=%d", EXTRACT_U_1(bp + i), EXTRACT_U_1(bp + i + 1));
            break;
        }
     }
     return;
 
 trunc:
-    ND_PRINT((ndo, "[trunc] "));
+    ND_PRINT("[trunc] ");
 }
 
 static void
@@ -107,67 +107,67 @@ ip6_opt_print(netdissect_options *ndo, const u_char *bp, int len)
 
        switch (EXTRACT_U_1(bp + i)) {
        case IP6OPT_PAD1:
-            ND_PRINT((ndo, "(pad1)"));
+            ND_PRINT("(pad1)");
            break;
        case IP6OPT_PADN:
            if (len - i < IP6OPT_MINLEN) {
-               ND_PRINT((ndo, "(padn: trunc)"));
+               ND_PRINT("(padn: trunc)");
                goto trunc;
            }
-            ND_PRINT((ndo, "(padn)"));
+            ND_PRINT("(padn)");
            break;
        case IP6OPT_ROUTER_ALERT:
            if (len - i < IP6OPT_RTALERT_LEN) {
-               ND_PRINT((ndo, "(rtalert: trunc)"));
+               ND_PRINT("(rtalert: trunc)");
                goto trunc;
            }
            if (EXTRACT_U_1(bp + i + 1) != IP6OPT_RTALERT_LEN - 2) {
-               ND_PRINT((ndo, "(rtalert: invalid len %d)", EXTRACT_U_1(bp + i + 1)));
+               ND_PRINT("(rtalert: invalid len %d)", EXTRACT_U_1(bp + i + 1));
                goto trunc;
            }
-           ND_PRINT((ndo, "(rtalert: 0x%04x) ", EXTRACT_BE_U_2(bp + i + 2)));
+           ND_PRINT("(rtalert: 0x%04x) ", EXTRACT_BE_U_2(bp + i + 2));
            break;
        case IP6OPT_JUMBO:
            if (len - i < IP6OPT_JUMBO_LEN) {
-               ND_PRINT((ndo, "(jumbo: trunc)"));
+               ND_PRINT("(jumbo: trunc)");
                goto trunc;
            }
            if (EXTRACT_U_1(bp + i + 1) != IP6OPT_JUMBO_LEN - 2) {
-               ND_PRINT((ndo, "(jumbo: invalid len %d)", EXTRACT_U_1(bp + i + 1)));
+               ND_PRINT("(jumbo: invalid len %d)", EXTRACT_U_1(bp + i + 1));
                goto trunc;
            }
-           ND_PRINT((ndo, "(jumbo: %u) ", EXTRACT_BE_U_4(bp + i + 2)));
+           ND_PRINT("(jumbo: %u) ", EXTRACT_BE_U_4(bp + i + 2));
            break;
         case IP6OPT_HOME_ADDRESS:
            if (len - i < IP6OPT_HOMEADDR_MINLEN) {
-               ND_PRINT((ndo, "(homeaddr: trunc)"));
+               ND_PRINT("(homeaddr: trunc)");
                goto trunc;
            }
            if (EXTRACT_U_1(bp + i + 1) < IP6OPT_HOMEADDR_MINLEN - 2) {
-               ND_PRINT((ndo, "(homeaddr: invalid len %d)", EXTRACT_U_1(bp + i + 1)));
+               ND_PRINT("(homeaddr: invalid len %d)", EXTRACT_U_1(bp + i + 1));
                goto trunc;
            }
-           ND_PRINT((ndo, "(homeaddr: %s", ip6addr_string(ndo, bp + i + 2)));
+           ND_PRINT("(homeaddr: %s", ip6addr_string(ndo, bp + i + 2));
             if (EXTRACT_U_1(bp + i + 1) > IP6OPT_HOMEADDR_MINLEN - 2) {
                ip6_sopt_print(ndo, bp + i + IP6OPT_HOMEADDR_MINLEN,
                                (optlen - IP6OPT_HOMEADDR_MINLEN));
            }
-            ND_PRINT((ndo, ")"));
+            ND_PRINT(")");
            break;
        default:
            if (len - i < IP6OPT_MINLEN) {
-               ND_PRINT((ndo, "(type %d: trunc)", EXTRACT_U_1(bp + i)));
+               ND_PRINT("(type %d: trunc)", EXTRACT_U_1(bp + i));
                goto trunc;
            }
-           ND_PRINT((ndo, "(opt_type 0x%02x: len=%d)", EXTRACT_U_1(bp + i), EXTRACT_U_1(bp + i + 1)));
+           ND_PRINT("(opt_type 0x%02x: len=%d)", EXTRACT_U_1(bp + i), EXTRACT_U_1(bp + i + 1));
            break;
        }
     }
-    ND_PRINT((ndo, " "));
+    ND_PRINT(" ");
     return;
 
 trunc:
-    ND_PRINT((ndo, "[trunc] "));
+    ND_PRINT("[trunc] ");
 }
 
 int
@@ -179,14 +179,14 @@ hbhopt_print(netdissect_options *ndo, const u_char *bp)
     ND_TCHECK(dp->ip6h_len);
     hbhlen = (EXTRACT_U_1(dp->ip6h_len) + 1) << 3;
     ND_TCHECK_LEN(dp, hbhlen);
-    ND_PRINT((ndo, "HBH "));
+    ND_PRINT("HBH ");
     if (ndo->ndo_vflag)
        ip6_opt_print(ndo, (const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
 
     return(hbhlen);
 
   trunc:
-    ND_PRINT((ndo, "[|HBH]"));
+    ND_PRINT("[|HBH]");
     return(-1);
 }
 
@@ -199,7 +199,7 @@ dstopt_print(netdissect_options *ndo, const u_char *bp)
     ND_TCHECK(dp->ip6d_len);
     dstoptlen = (EXTRACT_U_1(dp->ip6d_len) + 1) << 3;
     ND_TCHECK_LEN(dp, dstoptlen);
-    ND_PRINT((ndo, "DSTOPT "));
+    ND_PRINT("DSTOPT ");
     if (ndo->ndo_vflag) {
        ip6_opt_print(ndo, (const u_char *)dp + sizeof(*dp),
            dstoptlen - sizeof(*dp));
@@ -208,6 +208,6 @@ dstopt_print(netdissect_options *ndo, const u_char *bp)
     return(dstoptlen);
 
   trunc:
-    ND_PRINT((ndo, "[|DSTOPT]"));
+    ND_PRINT("[|DSTOPT]");
     return(-1);
 }