]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ripng.c
Remove the -a flag. It's nonsensical to apply the local netmask to all
[tcpdump] / print-ripng.c
index 4c90bd9dae33ca2b1923590f22f4cc9576a0b965..b1f7ec273d90dac17c6134cc36f3fa5f59d855af 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.9 2001-11-16 08:48:33 itojun Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.15 2002-12-11 22:29:22 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -30,19 +30,29 @@ static const char rcsid[] =
 
 #ifdef INET6
 
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#include <tcpdump-stdinc.h>
 
-#include <netinet/in.h>
+#ifdef WIN32
+const struct in6_addr in6addr_any;        /* :: */
+#endif /* WIN32 */
+
+#ifdef __MINGW32__
+int
+IN6_ADDR_EQUAL(const struct in6_addr *a, const struct in6_addr *b)
+{
+    return (memcmp(a, b, sizeof(struct in6_addr)) == 0);
+}
+
+#define IN6_IS_ADDR_UNSPECIFIED(a) IN6_ADDR_EQUAL((a), &in6addr_any)
+
+#endif /* __MINGW32__ */
 
-#include <errno.h>
 #include <stdio.h>
 
 #include "route6d.h"
 #include "interface.h"
 #include "addrtoname.h"
+#include "extract.h"
 
 static int
 rip6_entry_print(register const struct netinfo6 *ni, int metric)
@@ -50,25 +60,29 @@ rip6_entry_print(register const struct netinfo6 *ni, int metric)
        int l;
        l = printf("%s/%d", ip6addr_string(&ni->rip6_dest), ni->rip6_plen);
        if (ni->rip6_tag)
-               l += printf(" [%d]", ntohs(ni->rip6_tag));
+               l += printf(" [%d]", EXTRACT_16BITS(&ni->rip6_tag));
        if (metric)
                l += printf(" (%d)", ni->rip6_metric);
        return l;
 }
 
 void
-ripng_print(const u_char *dat, int length)
+ripng_print(const u_char *dat, unsigned int length)
 {
        register const struct rip6 *rp = (struct rip6 *)dat;
        register const struct netinfo6 *ni;
-       register int amt = snapend - dat;
-       register int i = min(length, amt) -
-                        (sizeof(struct rip6) - sizeof(struct netinfo6));
+       register u_int amt;
+       register u_int i;
        int j;
        int trunc;
 
-       if (i < 0)
+       if (snapend < dat)
+               return;
+       amt = snapend - dat;
+       i = min(length, amt);
+       if (i < (sizeof(struct rip6) - sizeof(struct netinfo6)))
                return;
+       i -= (sizeof(struct rip6) - sizeof(struct netinfo6));
 
        switch (rp->rip6_cmd) {
 
@@ -81,11 +95,12 @@ ripng_print(const u_char *dat, int length)
                        break;
                }
                if (j * sizeof(*ni) != length - 4)
-                       printf(" ripng-req %d[%d]:", j, length);
+                       printf(" ripng-req %d[%u]:", j, length);
                else
                        printf(" ripng-req %d:", j);
                trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
-               for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
+               for (ni = rp->rip6_nets; i >= sizeof(*ni);
+                   i -= sizeof(*ni), ++ni) {
                        if (vflag > 1)
                                printf("\n\t");
                        else
@@ -96,11 +111,12 @@ ripng_print(const u_char *dat, int length)
        case RIP6_RESPONSE:
                j = length / sizeof(*ni);
                if (j * sizeof(*ni) != length - 4)
-                       printf(" ripng-resp %d[%d]:", j, length);
+                       printf(" ripng-resp %d[%u]:", j, length);
                else
                        printf(" ripng-resp %d:", j);
                trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
-               for (ni = rp->rip6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
+               for (ni = rp->rip6_nets; i >= sizeof(*ni);
+                   i -= sizeof(*ni), ++ni) {
                        if (vflag > 1)
                                printf("\n\t");
                        else
@@ -111,7 +127,7 @@ ripng_print(const u_char *dat, int length)
                        printf("[|ripng]");
                break;
        default:
-               printf(" ripng-%d ?? %d", rp->rip6_cmd, length);
+               printf(" ripng-%d ?? %u", rp->rip6_cmd, length);
                break;
        }
        if (rp->rip6_vers != RIP6_VERSION)