]> The Tcpdump Group git mirrors - tcpdump/commitdiff
CARP: NDOize
authorDenis Ovsienko <[email protected]>
Tue, 25 Feb 2014 14:23:45 +0000 (18:23 +0400)
committerDenis Ovsienko <[email protected]>
Tue, 25 Feb 2014 14:23:45 +0000 (18:23 +0400)
interface.h
netdissect.h
print-carp.c
print-ip.c

index f551752f87efcc0da35579796d2e960345656bef..86f62af36c6b6f1fc3aa5201f701e0c256bc48ff 100644 (file)
@@ -310,7 +310,6 @@ extern const char *nt_errstr(u_int32_t);
 extern void print_data(const unsigned char *, int);
 extern void l2tp_print(const u_char *, u_int);
 extern void vrrp_print(const u_char *, u_int, int);
-extern void carp_print(const u_char *, u_int, int);
 extern void slow_print(const u_char *, u_int);
 extern void sflow_print(const u_char *, u_int);
 extern void mpcp_print(const u_char *, u_int);
index 241f585ac0c99c4782d26614912145dcfe85d73f..80fcc520cd00b91ac07ed7e9c7bd68cbacbe4a7d 100644 (file)
@@ -346,6 +346,7 @@ extern void ip_print_inner(netdissect_options *ndo,
                           const u_char *bp2);
 extern void rrcp_print(netdissect_options *,const u_char *, u_int);
 extern void loopback_print(netdissect_options *, const u_char *, const u_int);
+extern void carp_print(netdissect_options *, const u_char *, u_int, int);
 
 extern void ether_print(netdissect_options *,
                         const u_char *, u_int, u_int,
index 05abff16065e8bf505f1bcab68ef2d3dc4088841..3602cdace7baf36ffdce6c877e2020afa5e72cd1 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "interface.h"
+#include "interface.h" /* for checksum structure and functions */
+#include "netdissect.h"
 #include "extract.h"
 
 void
-carp_print(register const u_char *bp, register u_int len, int ttl)
+carp_print(netdissect_options *ndo, register const u_char *bp, register u_int len, int ttl)
 {
        int version, type;
        const char *type_s;
 
-       TCHECK(bp[0]);
+       ND_TCHECK(bp[0]);
        version = (bp[0] & 0xf0) >> 4;
        type = bp[0] & 0x0f;
        if (type == 1)
                type_s = "advertise";
        else
                type_s = "unknown";
-       printf("CARPv%d-%s %d: ", version, type_s, len);
+       ND_PRINT((ndo, "CARPv%d-%s %d: ", version, type_s, len));
        if (ttl != 255)
-               printf("[ttl=%d!] ", ttl);
+               ND_PRINT((ndo, "[ttl=%d!] ", ttl));
        if (version != 2 || type != 1)
                return;
-       TCHECK(bp[2]);
-       TCHECK(bp[5]);
-       printf("vhid=%d advbase=%d advskew=%d authlen=%d ",
-           bp[1], bp[5], bp[2], bp[3]);
-       if (vflag) {
+       ND_TCHECK(bp[2]);
+       ND_TCHECK(bp[5]);
+       ND_PRINT((ndo, "vhid=%d advbase=%d advskew=%d authlen=%d ",
+           bp[1], bp[5], bp[2], bp[3]));
+       if (ndo->ndo_vflag) {
                struct cksum_vec vec[1];
                vec[0].ptr = (const u_int8_t *)bp;
                vec[0].len = len;
-               if (TTEST2(bp[0], len) && in_cksum(vec, 1))
-                       printf(" (bad carp cksum %x!)",
-                               EXTRACT_16BITS(&bp[6]));
+               if (ND_TTEST2(bp[0], len) && in_cksum(vec, 1))
+                       ND_PRINT((ndo, " (bad carp cksum %x!)",
+                               EXTRACT_16BITS(&bp[6])));
        }
-       printf("counter=%" PRIu64, EXTRACT_64BITS(&bp[8]));
+       ND_PRINT((ndo, "counter=%" PRIu64, EXTRACT_64BITS(&bp[8])));
 
        return;
 trunc:
-       printf("[|carp]");
+       ND_PRINT((ndo, "[|carp]"));
 }
index 3c7f107f31b76b98fcd478b967a9ba83d204382e..ef23bd5332199ee74c04a359c0fd81585c9ecd08 100644 (file)
@@ -464,7 +464,7 @@ again:
                                (void)printf("carp %s > %s: ",
                                             ipaddr_string(&ipds->ip->ip_src),
                                             ipaddr_string(&ipds->ip->ip_dst));
-                       carp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+                       carp_print(ndo, ipds->cp, ipds->len, ipds->ip->ip_ttl);
                } else {
                        if (vflag)
                                (void)printf("vrrp %s > %s: ",