tcpdump mailing list archives

print-ahcp.c on MSVC


From: "Gisle Vanem" <gvanem () yahoo no>
Date: Tue, 11 Mar 2014 19:40:11 +0100

I'm sure my old MSVC v16 has a bit stupid C-preprocessor. At least when
expanding this (line 153):

 ND_PRINT((ndo, "%s%s", sep,
#ifdef INET6
        ip6addr_string(cp)
#else
        "(compiled w/o IPv6)"
#endif /* INET6 */

into this (all on one line):

        (*ndo->ndo_printf)(ndo, "%s%s", sep, #ifdef 1 getname6((const u_char *)
 (cp)) #else "(compiled w/o IPv6)" #endif );

(verified by cl -E).  Applying this patch fixes it though:

--- Git-Latest/print-ahcp.c     2014-03-11 18:33:14 +0000
+++ print-ahcp.c        2014-03-11 19:29:41 +0000
@@ -150,13 +150,12 @@
               if (cp + 16 > ep)
                       goto corrupt;
               ND_TCHECK2(*cp, 16);
-               ND_PRINT((ndo, "%s%s", sep,
#ifdef INET6
-                      ip6addr_string(cp)
+               ND_PRINT((ndo, "%s%s", sep, ip6addr_string(cp)));
#else
-                      "(compiled w/o IPv6)"
+               ND_PRINT((ndo, "%s%s", sep, "(compiled w/o IPv6)"));
#endif /* INET6 */
-                      ));
+
               cp += 16;
               sep = ", ";
       }
@@ -202,13 +201,12 @@
               if (cp + 17 > ep)
                       goto corrupt;
               ND_TCHECK2(*cp, 17);
-               ND_PRINT((ndo, "%s%s/%u", sep,
#ifdef INET6
-                      ip6addr_string(cp),
+               ND_PRINT((ndo, "%s%s/%u", sep, ip6addr_string(cp), *(cp + 16)));
#else
-                      "(compiled w/o IPv6)",
+               ND_PRINT((ndo, "%s%s/%u", sep, "(compiled w/o IPv6)", *(cp + 16)));
#endif /* INET6 */
-                      *(cp + 16)));
+
               cp += 17;
               sep = ", ";
       }

----------

Time for an INET6 aware util.c print-function for these cases?

--gv


_______________________________________________
tcpdump-workers mailing list
tcpdump-workers () lists tcpdump org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers


Current thread: