/* Bail if "var" was not captured */
#define TCHECK(var) TCHECK2(var, sizeof(var))
-extern void ts_print(const struct timeval *);
-extern void relts_print(int);
-
extern int fn_print(const u_char *, const u_char *);
extern int fn_printn(const u_char *, u_int, const u_char *);
extern int fn_printzp(const u_char *, u_int, const u_char *);
#define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF
#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
-#if 0
-extern void ts_print(netdissect_options *ipdo,
- const struct timeval *);
-extern void relts_print(int);
-#endif
+extern void ts_print(netdissect_options *, const struct timeval *);
+extern void relts_print(netdissect_options *, int);
extern int fn_print(const u_char *, const u_char *);
extern int fn_printn(const u_char *, u_int, const u_char *);
} else if (ndo->ndo_vflag > 2) {
/* print ttl */
ND_PRINT((ndo, " ["));
- relts_print(EXTRACT_32BITS(cp));
+ relts_print(ndo, EXTRACT_32BITS(cp));
ND_PRINT((ndo, "]"));
cp += 4;
} else {
ND_PRINT((ndo, " src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4)));
bp += 8;
ND_PRINT((ndo, " timer "));
- relts_print(EXTRACT_32BITS(bp));
+ relts_print(ndo, EXTRACT_32BITS(bp));
return (0);
trunc:
return (-1);
case MFR_CTRL_IE_TIMESTAMP:
if (ie_len == sizeof(struct timeval)) {
- ts_print((const struct timeval *)tptr);
+ ts_print(ndo, (const struct timeval *)tptr);
break;
}
/* fall through and hexdump if no unix timestamp */
ND_PRINT((ndo, "addr=%s", ipaddr_string(&hp->hsrp_virtaddr)));
if (ndo->ndo_vflag) {
ND_PRINT((ndo, " hellotime="));
- relts_print(hp->hsrp_hellotime);
+ relts_print(ndo, hp->hsrp_hellotime);
ND_PRINT((ndo, " holdtime="));
- relts_print(hp->hsrp_holdtime);
+ relts_print(ndo, hp->hsrp_holdtime);
ND_PRINT((ndo, " priority=%d", hp->hsrp_priority));
ND_PRINT((ndo, " auth=\""));
if (fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata),
if (mrt < 600) {
ND_PRINT((ndo, "%.1fs", mrt * 0.1));
} else {
- relts_print(mrt / 10);
+ relts_print(ndo, mrt / 10);
}
ND_PRINT((ndo, "]"));
}
ND_PRINT((ndo, ", (malformed subTLV) "));
#ifdef HAVE_LIBCRYPTO
- sigcheck = signature_verify(optr, length,
+ sigcheck = signature_verify(ndo, optr, length,
(unsigned char *)tptr + 1);
#else
sigcheck = CANT_CHECK_SIGNATURE;
timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec);
timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec);
ND_PRINT((ndo, "\n\t Sender Timestamp: "));
- ts_print(×tamp);
+ ts_print(ndo, ×tamp);
timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec);
timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec);
ND_PRINT((ndo, "Receiver Timestamp: "));
if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0))
- ts_print(×tamp);
+ ts_print(ndo, ×tamp);
else
ND_PRINT((ndo, "no timestamp"));
EXTRACT_16BITS(&grbn->rdclass))));
}
ND_PRINT((ndo, " TTL "));
- relts_print(EXTRACT_32BITS(&grbn->ttl));
+ relts_print(ndo, EXTRACT_32BITS(&grbn->ttl));
ND_PRINT((ndo, " %u/%u", EXTRACT_16BITS(&grbn->nrdatas),
EXTRACT_16BITS(&grbn->nsigs)));
hold = EXTRACT_16BITS(&bp[6]);
if (hold != 180) {
ND_PRINT((ndo, "Hold "));
- relts_print(hold);
+ relts_print(ndo, hold);
}
ND_PRINT((ndo, "%s (%s/%d, %s", njoin ? "Join" : "Prune",
ipaddr_string(&bp[26]), bp[25] & 0x3f,
if (ndo->ndo_vflag > 1)
ND_PRINT((ndo, "\n"));
ND_PRINT((ndo, " Hold time: "));
- relts_print(EXTRACT_16BITS(&bp[6]));
+ relts_print(ndo, EXTRACT_16BITS(&bp[6]));
if (ndo->ndo_vflag < 2)
return;
bp += 8;
if (ndo->ndo_vflag) {
ND_TCHECK2(bp[10],2);
ND_PRINT((ndo, " (Hold-time "));
- relts_print(EXTRACT_16BITS(&bp[10]));
+ relts_print(ndo, EXTRACT_16BITS(&bp[10]));
ND_PRINT((ndo, ")"));
}
break;
if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
ND_PRINT((ndo, "/%s", ipaddr_string(&bp[12])));
ND_PRINT((ndo, " RP %s hold ", ipaddr_string(&bp[16])));
- relts_print(EXTRACT_16BITS(&bp[22]));
+ relts_print(ndo, EXTRACT_16BITS(&bp[22]));
}
break;
case 5:
ND_PRINT((ndo, " Hold "));
hold = EXTRACT_16BITS(&bp[2]);
if (hold)
- relts_print(EXTRACT_16BITS(&bp[2]));
+ relts_print(ndo, EXTRACT_16BITS(&bp[2]));
else
ND_PRINT((ndo, "FOREVER"));
switch (otype) {
case PIMV2_HELLO_OPTION_HOLDTIME:
- relts_print(EXTRACT_16BITS(bp));
+ relts_print(ndo, EXTRACT_16BITS(bp));
break;
case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
ND_PRINT((ndo, "v%d", *bp));
if (*(bp+1) != 0) {
ND_PRINT((ndo, ", interval "));
- relts_print(*(bp+1));
+ relts_print(ndo, *(bp+1));
}
if (EXTRACT_16BITS(bp+2) != 0) {
ND_PRINT((ndo, " ?0x%04x?", EXTRACT_16BITS(bp+2)));
if (holdtime == 0xffff)
ND_PRINT((ndo, "infinite"));
else
- relts_print(holdtime);
+ relts_print(ndo, holdtime);
}
bp += 4; len -= 4;
for (i = 0; i < ngroup; i++) {
goto bs_done;
}
ND_PRINT((ndo, ",holdtime="));
- relts_print(EXTRACT_16BITS(bp));
+ relts_print(ndo, EXTRACT_16BITS(bp));
if (bp + 2 >= ep) {
ND_PRINT((ndo, "...)"));
goto bs_done;
ND_PRINT((ndo, " prio=%d", bp[1]));
if (bp + 3 >= ep) break;
ND_PRINT((ndo, " holdtime="));
- relts_print(EXTRACT_16BITS(&bp[2]));
+ relts_print(ndo, EXTRACT_16BITS(&bp[2]));
bp += 4;
/* Encoded-Unicast-RP-Address */
bp += advance;
ND_TCHECK2(bp[0], 2);
ND_PRINT((ndo, " TUNR "));
- relts_print(EXTRACT_16BITS(bp));
+ relts_print(ndo, EXTRACT_16BITS(bp));
break;
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest + 12)));
#ifdef HAVE_LIBCRYPTO
- sigcheck = signature_verify(pptr, plen, (unsigned char *)obj_ptr.\
+ sigcheck = signature_verify(ndo, pptr, plen, (unsigned char *)obj_ptr.\
rsvp_obj_integrity->digest);
#else
sigcheck = CANT_CHECK_SIGNATURE;
* Currently only MD5 is supported.
*/
int
-signature_verify (const u_char *pptr, u_int plen, u_char *sig_ptr)
+signature_verify(netdissect_options *ndo,
+ const u_char *pptr, u_int plen, u_char *sig_ptr)
{
u_int8_t rcvsig[16];
u_int8_t sig[16];
} else {
for (i = 0; i < sizeof(sig); ++i) {
- (void)printf("%02x", sig[i]);
+ ND_PRINT((ndo, "%02x", sig[i]));
}
return (SIGNATURE_INVALID);
*/
+/* for netdissect_options */
+#include "netdissect.h"
+
/* signature checking result codes */
#define SIGNATURE_VALID 0
#define SIGNATURE_INVALID 1
#define CANT_CHECK_SIGNATURE 2
extern const struct tok signature_check_values[];
-extern int signature_verify (const u_char *, u_int, u_char *);
+extern int signature_verify(netdissect_options *, const u_char *, u_int, u_char *);
++packets_captured;
++infodelay;
- ts_print(&h->ts);
print_info = (struct print_info *)user;
ndo = print_info->ndo;
+ ts_print(ndo, &h->ts);
/*
* Some printers want to check that they're not walking off the
#include "interface.h"
-char * ts_format(register int, register int);
-
/*
* Print out a null-terminated filename (or other ascii string).
* If ep is NULL, assume no truncation check is needed.
/*
* Format the timestamp
*/
-char *
+static char *
ts_format(register int sec, register int usec)
{
static char buf[sizeof("00:00:00.000000")];
* Print the timestamp
*/
void
-ts_print(register const struct timeval *tvp)
+ts_print(netdissect_options *ndo,
+ register const struct timeval *tvp)
{
register int s;
struct tm *tm;
int d_usec;
int d_sec;
- switch (tflag) {
+ switch (ndo->ndo_tflag) {
case 0: /* Default */
s = (tvp->tv_sec + thiszone) % 86400;
- (void)printf("%s ", ts_format(s, tvp->tv_usec));
+ ND_PRINT((ndo, "%s ", ts_format(s, tvp->tv_usec)));
break;
case 1: /* No time stamp */
break;
case 2: /* Unix timeval style */
- (void)printf("%u.%06u ",
+ ND_PRINT((ndo, "%u.%06u ",
(unsigned)tvp->tv_sec,
- (unsigned)tvp->tv_usec);
+ (unsigned)tvp->tv_usec));
break;
case 3: /* Microseconds since previous packet */
d_sec--;
}
- (void)printf("%s ", ts_format(d_sec, d_usec));
+ ND_PRINT((ndo, "%s ", ts_format(d_sec, d_usec)));
- if (tflag == 3) { /* set timestamp for last packet */
+ if (ndo->ndo_tflag == 3) { /* set timestamp for last packet */
b_sec = tvp->tv_sec;
b_usec = tvp->tv_usec;
}
Time = (tvp->tv_sec + thiszone) - s;
tm = gmtime (&Time);
if (!tm)
- printf("Date fail ");
+ ND_PRINT((ndo, "Date fail "));
else
- printf("%04d-%02d-%02d %s ",
+ ND_PRINT((ndo, "%04d-%02d-%02d %s ",
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
- ts_format(s, tvp->tv_usec));
+ ts_format(s, tvp->tv_usec)));
break;
}
}
* is represented as 1y1w1d1h1m1s.
*/
void
-relts_print(int secs)
+relts_print(netdissect_options *ndo,
+ int secs)
{
static const char *lengths[] = {"y", "w", "d", "h", "m", "s"};
static const int seconds[] = {31536000, 604800, 86400, 3600, 60, 1};
const int *s = seconds;
if (secs == 0) {
- (void)printf("0s");
+ ND_PRINT((ndo, "0s"));
return;
}
if (secs < 0) {
- (void)printf("-");
+ ND_PRINT((ndo, "-"));
secs = -secs;
}
while (secs > 0) {
if (secs >= *s) {
- (void)printf("%d%s", secs / *s, *l);
+ ND_PRINT((ndo, "%d%s", secs / *s, *l));
secs -= (secs / *s) * *s;
}
s++;
ident));
return(0);
}
- if (snapend - cp < len)
- len = snapend - cp;
+ if (ndo->ndo_snapend - cp < len)
+ len = ndo->ndo_snapend - cp;
if (len < 0) {
ND_PRINT((ndo,"%sDissector error: print_unknown_data called with pointer past end of packet",
ident));