summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface.h1
-rw-r--r--netdissect.h1
-rw-r--r--print-carp.c31
-rw-r--r--print-ip.c2
4 files changed, 18 insertions, 17 deletions
diff --git a/interface.h b/interface.h
index f551752f..86f62af3 100644
--- a/interface.h
+++ b/interface.h
@@ -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);
diff --git a/netdissect.h b/netdissect.h
index 241f585a..80fcc520 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -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,
diff --git a/print-carp.c b/print-carp.c
index 05abff16..3602cdac 100644
--- a/print-carp.c
+++ b/print-carp.c
@@ -43,42 +43,43 @@
#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]"));
}
diff --git a/print-ip.c b/print-ip.c
index 3c7f107f..ef23bd53 100644
--- a/print-ip.c
+++ b/print-ip.c
@@ -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: ",