From 62a5184ed49a1735c903c1556a30d938e8463f57 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Thu, 27 Mar 2014 14:58:23 +0400 Subject: [PATCH] NDOize ForCES, MPLS LSP ping and OLSR decoders --- interface.h | 3 - netdissect.h | 3 + print-forces.c | 614 +++++++++++++++++++++++++----------------------- print-lspping.c | 148 ++++++------ print-olsr.c | 129 +++++----- print-sctp.c | 2 +- print-udp.c | 4 +- 7 files changed, 458 insertions(+), 445 deletions(-) diff --git a/interface.h b/interface.h index 0402e762..1b0f059d 100644 --- a/interface.h +++ b/interface.h @@ -182,10 +182,8 @@ extern void nfsreply_print_noaddr(const u_char *, u_int, const u_char *); extern void nfsreq_print(const u_char *, u_int, const u_char *); extern void nfsreq_print_noaddr(const u_char *, u_int, const u_char *); extern void ospf_print(const u_char *, u_int, const u_char *); -extern void olsr_print (const u_char *, u_int, int); extern void rsvp_print(const u_char *, u_int); extern void lldp_print(const u_char *, u_int); -extern void lspping_print(const u_char *, u_int); extern u_int ppp_print(register const u_char *, u_int); extern u_int ppp_if_print(const struct pcap_pkthdr *, const u_char *); extern u_int ppp_hdlc_if_print(const struct pcap_pkthdr *, const u_char *); @@ -222,7 +220,6 @@ extern void print_data(const unsigned char *, int); extern void cfm_print(const u_char *, u_int); extern void cdp_print(const u_char *, u_int, u_int); extern void lwres_print(const u_char *, u_int); -extern void forces_print(const u_char *, u_int); extern void mpls_lsp_ping_print(const u_char *, u_int); extern void sip_print(const u_char *, u_int); extern void syslog_print(const u_char *, u_int); diff --git a/netdissect.h b/netdissect.h index 6733483c..7284c43e 100644 --- a/netdissect.h +++ b/netdissect.h @@ -471,6 +471,9 @@ extern void aodv_print(netdissect_options *, const u_char *, u_int, int); extern void sctp_print(netdissect_options *, const u_char *, const u_char *, u_int); extern char *bgp_vpn_rd_print (netdissect_options *, const u_char *); extern void bgp_print(netdissect_options *, const u_char *, int); +extern void olsr_print(netdissect_options *, const u_char *, u_int, int); +extern void forces_print(netdissect_options *, const u_char *, u_int); +extern void lspping_print(netdissect_options *, const u_char *, u_int); /* stuff that has not yet been rototiled */ diff --git a/print-forces.c b/print-forces.c index 13bfd128..3a12d03f 100644 --- a/print-forces.c +++ b/print-forces.c @@ -14,15 +14,13 @@ * */ +#define NETDISSECT_REWORKED #ifdef HAVE_CONFIG_H #include "config.h" #endif #include -#include -#include - #include "interface.h" #include "extract.h" @@ -68,7 +66,7 @@ struct tom_h { u_int16_t flags; u_int16_t op_msk; const char *s; - int (*print) (register const u_char * pptr, register u_int len, + int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); }; @@ -230,15 +228,15 @@ struct optlv_h { u_int16_t flags; u_int16_t op_msk; const char *s; - int (*print) (register const u_char * pptr, register u_int len, + int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); }; -static int genoptlv_print(register const u_char * pptr, register u_int len, +static int genoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); -static int recpdoptlv_print(register const u_char * pptr, register u_int len, +static int recpdoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); -static int invoptlv_print(register const u_char * pptr, register u_int len, +static int invoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); #define OP_MIN_SIZ 8 @@ -442,13 +440,13 @@ static inline int ilv_valid(const struct forces_ilv *ilv, u_int rlen) return 0; } -static int lfbselect_print(register const u_char * pptr, register u_int len, +static int lfbselect_print(netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); -static int redirect_print(register const u_char * pptr, register u_int len, +static int redirect_print(netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); -static int asrtlv_print(register const u_char * pptr, register u_int len, +static int asrtlv_print(netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); -static int asttlv_print(register const u_char * pptr, register u_int len, +static int asttlv_print(netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); struct forces_lfbsh { @@ -500,7 +498,7 @@ struct pdata_ops { u_int16_t flags; u_int16_t op_msk; const char *s; - int (*print) (register const u_char * pptr, register u_int len, + int (*print) (netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); }; @@ -522,19 +520,19 @@ static inline int pd_valid(u_int16_t pd) return 0; } -static inline void chk_op_type(u_int16_t type, u_int16_t msk, u_int16_t omsk) +static inline void +chk_op_type(netdissect_options *ndo, + u_int16_t type, u_int16_t msk, u_int16_t omsk) { if (type != F_TLV_PDAT) { if (msk & B_KEYIN) { if (type != F_TLV_KEYI) { - printf - ("Based on flags expected KEYINFO TLV!\n"); + ND_PRINT((ndo, "Based on flags expected KEYINFO TLV!\n")); } } else { if (!(msk & omsk)) { - printf - ("Illegal DATA encoding for type 0x%x programmed %x got %x \n", - type, omsk, msk); + ND_PRINT((ndo, "Illegal DATA encoding for type 0x%x programmed %x got %x \n", + type, omsk, msk)); } } } @@ -551,13 +549,13 @@ struct res_val { u_int16_t resv2; }; -static int prestlv_print(register const u_char * pptr, register u_int len, +static int prestlv_print(netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); -static int pkeyitlv_print(register const u_char * pptr, register u_int len, +static int pkeyitlv_print(netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); -static int fdatatlv_print(register const u_char * pptr, register u_int len, +static int fdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); -static int sdatatlv_print(register const u_char * pptr, register u_int len, +static int sdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len, u_int16_t op_msk, int indent); static const struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = { @@ -642,8 +640,9 @@ static const struct tok ForCES_errs[] = { #define RESLEN 4 static int -prestlv_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk _U_, int indent) +prestlv_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) { const struct forces_tlv *tlv = (struct forces_tlv *)pptr; register const u_char *tdp = (u_char *) TLV_DATA(tlv); @@ -656,31 +655,32 @@ prestlv_print(register const u_char * pptr, register u_int len, */ dlen = len - TLV_HDRL; if (dlen != RESLEN) { - printf("illegal RESULT-TLV: %d bytes!\n", dlen); + ND_PRINT((ndo, "illegal RESULT-TLV: %d bytes!\n", dlen)); return -1; } - TCHECK(*r); + ND_TCHECK(*r); if (r->result >= 0x18 && r->result <= 0xFE) { - printf("illegal reserved result code: 0x%x!\n", r->result); + ND_PRINT((ndo, "illegal reserved result code: 0x%x!\n", r->result)); return -1; } - if (vflag >= 3) { + if (ndo->ndo_vflag >= 3) { char *ib = indent_pr(indent, 0); - printf("%s Result: %s (code 0x%x)\n", ib, - tok2str(ForCES_errs, NULL, r->result), r->result); + ND_PRINT((ndo, "%s Result: %s (code 0x%x)\n", ib, + tok2str(ForCES_errs, NULL, r->result), r->result)); } return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } static int -fdatatlv_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk _U_, int indent) +fdatatlv_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) { const struct forces_tlv *tlv = (struct forces_tlv *)pptr; u_int rlen; @@ -692,59 +692,60 @@ fdatatlv_print(register const u_char * pptr, register u_int len, * (the TLV length) >= TLV_HDRL. */ rlen = len - TLV_HDRL; - TCHECK(*tlv); + ND_TCHECK(*tlv); type = EXTRACT_16BITS(&tlv->type); if (type != F_TLV_FULD) { - printf("Error: expecting FULLDATA!\n"); + ND_PRINT((ndo, "Error: expecting FULLDATA!\n")); return -1; } - if (vflag >= 3) { + if (ndo->ndo_vflag >= 3) { char *ib = indent_pr(indent + 2, 1); - printf("%s[", &ib[1]); - hex_print_with_offset(gndo,ib, tdp, rlen, 0); - printf("\n%s]\n", &ib[1]); + ND_PRINT((ndo, "%s[", &ib[1])); + hex_print_with_offset(ndo, ib, tdp, rlen, 0); + ND_PRINT((ndo, "\n%s]\n", &ib[1])); } return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } static int -sdatailv_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk _U_, int indent) +sdatailv_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) { u_int rlen; const struct forces_ilv *ilv = (struct forces_ilv *)pptr; int invilv; if (len < ILV_HDRL) { - printf("Error: BAD SPARSEDATA-TLV!\n"); + ND_PRINT((ndo, "Error: BAD SPARSEDATA-TLV!\n")); return -1; } rlen = len; indent += 1; while (rlen != 0) { #if 0 - printf("Jamal - outstanding length <%d>\n", rlen); + ND_PRINT((ndo, "Jamal - outstanding length <%d>\n", rlen)); #endif char *ib = indent_pr(indent, 1); register const u_char *tdp = (u_char *) ILV_DATA(ilv); - TCHECK(*ilv); + ND_TCHECK(*ilv); invilv = ilv_valid(ilv, rlen); if (invilv) { - printf("%s[", &ib[1]); - hex_print_with_offset(gndo,ib, tdp, rlen, 0); - printf("\n%s]\n", &ib[1]); + ND_PRINT((ndo, "%s[", &ib[1])); + hex_print_with_offset(ndo, ib, tdp, rlen, 0); + ND_PRINT((ndo, "\n%s]\n", &ib[1])); return -1; } - if (vflag >= 3) { + if (ndo->ndo_vflag >= 3) { int ilvl = EXTRACT_32BITS(&ilv->length); - printf("\n%s ILV: type %x length %d\n", &ib[1], - EXTRACT_32BITS(&ilv->type), ilvl); - hex_print_with_offset(gndo,"\t\t[", tdp, ilvl-ILV_HDRL, 0); + ND_PRINT((ndo, "\n%s ILV: type %x length %d\n", &ib[1], + EXTRACT_32BITS(&ilv->type), ilvl)); + hex_print_with_offset(ndo, "\t\t[", tdp, ilvl-ILV_HDRL, 0); } ilv = GO_NXT_ILV(ilv, rlen); @@ -753,13 +754,14 @@ sdatailv_print(register const u_char * pptr, register u_int len, return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } static int -sdatatlv_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk, int indent) +sdatatlv_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) { const struct forces_tlv *tlv = (struct forces_tlv *)pptr; u_int rlen; @@ -771,23 +773,24 @@ sdatatlv_print(register const u_char * pptr, register u_int len, * >= TLV_HDRL. */ rlen = len - TLV_HDRL; - TCHECK(*tlv); + ND_TCHECK(*tlv); type = EXTRACT_16BITS(&tlv->type); if (type != F_TLV_SPAD) { - printf("Error: expecting SPARSEDATA!\n"); + ND_PRINT((ndo, "Error: expecting SPARSEDATA!\n")); return -1; } - return sdatailv_print(tdp, rlen, op_msk, indent); + return sdatailv_print(ndo, tdp, rlen, op_msk, indent); trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } static int -pkeyitlv_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk, int indent) +pkeyitlv_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) { const struct forces_tlv *tlv = (struct forces_tlv *)pptr; register const u_char *tdp = (u_char *) TLV_DATA(tlv); @@ -798,17 +801,17 @@ pkeyitlv_print(register const u_char * pptr, register u_int len, u_int16_t type, tll; u_int invtlv; - TCHECK(*tdp); + ND_TCHECK(*tdp); id = EXTRACT_32BITS(tdp); - printf("%sKeyinfo: Key 0x%x\n", ib, id); - TCHECK(*kdtlv); + ND_PRINT((ndo, "%sKeyinfo: Key 0x%x\n", ib, id)); + ND_TCHECK(*kdtlv); type = EXTRACT_16BITS(&kdtlv->type); invtlv = tlv_valid(kdtlv, len); if (invtlv) { - printf("%s TLV type 0x%x len %d\n", + ND_PRINT((ndo, "%s TLV type 0x%x len %d\n", tok2str(ForCES_TLV_err, NULL, invtlv), type, - EXTRACT_16BITS(&kdtlv->length)); + EXTRACT_16BITS(&kdtlv->length))); return -1; } /* @@ -818,33 +821,34 @@ pkeyitlv_print(register const u_char * pptr, register u_int len, */ tll = EXTRACT_16BITS(&kdtlv->length); dp = (u_char *) TLV_DATA(kdtlv); - return fdatatlv_print(dp, tll, op_msk, indent); + return fdatatlv_print(ndo, dp, tll, op_msk, indent); trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } #define PTH_DESC_SIZE 12 static int -pdatacnt_print(register const u_char * pptr, register u_int len, - u_int16_t IDcnt, u_int16_t op_msk, int indent) +pdatacnt_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t IDcnt, u_int16_t op_msk, int indent) { u_int i; u_int32_t id; char *ib = indent_pr(indent, 0); - if ((op_msk & B_APPND) && vflag >= 3) { - printf("%sTABLE APPEND\n", ib); + if ((op_msk & B_APPND) && ndo->ndo_vflag >= 3) { + ND_PRINT((ndo, "%sTABLE APPEND\n", ib)); } for (i = 0; i < IDcnt; i++) { - TCHECK2(*pptr, 4); + ND_TCHECK2(*pptr, 4); if (len < 4) goto trunc; id = EXTRACT_32BITS(pptr); - if (vflag >= 3) - printf("%sID#%02u: %d\n", ib, i + 1, id); + if (ndo->ndo_vflag >= 3) + ND_PRINT((ndo, "%sID#%02u: %d\n", ib, i + 1, id)); len -= 4; pptr += 4; } @@ -854,8 +858,8 @@ pdatacnt_print(register const u_char * pptr, register u_int len, u_int32_t starti, endi; if (len < PTH_DESC_SIZE) { - printf("pathlength %d with key/range too short %d\n", - len, PTH_DESC_SIZE); + ND_PRINT((ndo, "pathlength %d with key/range too short %d\n", + len, PTH_DESC_SIZE)); return -1; } @@ -870,8 +874,8 @@ pdatacnt_print(register const u_char * pptr, register u_int len, pptr += 4; len -= 4; - if (vflag >= 3) - printf("%sTable range: [%d,%d]\n", ib, starti, endi); + if (ndo->ndo_vflag >= 3) + ND_PRINT((ndo, "%sTable range: [%d,%d]\n", ib, starti, endi)); } if (op_msk & B_KEYIN) { @@ -879,8 +883,8 @@ pdatacnt_print(register const u_char * pptr, register u_int len, u_int16_t tll; if (len < PTH_DESC_SIZE) { - printf("pathlength %d with key/range too short %d\n", - len, PTH_DESC_SIZE); + ND_PRINT((ndo, "pathlength %d with key/range too short %d\n", + len, PTH_DESC_SIZE)); return -1; } @@ -894,13 +898,13 @@ pdatacnt_print(register const u_char * pptr, register u_int len, /* skip key content */ tll = EXTRACT_16BITS(&keytlv->length); if (tll < TLV_HDRL) { - printf("key content length %u < %u\n", - tll, TLV_HDRL); + ND_PRINT((ndo, "key content length %u < %u\n", + tll, TLV_HDRL)); return -1; } tll -= TLV_HDRL; if (len < tll) { - printf("key content too short\n"); + ND_PRINT((ndo, "key content too short\n")); return -1; } pptr += tll; @@ -917,14 +921,13 @@ pdatacnt_print(register const u_char * pptr, register u_int len, u_int aln; u_int invtlv; - TCHECK(*pdtlv); + ND_TCHECK(*pdtlv); type = EXTRACT_16BITS(&pdtlv->type); invtlv = tlv_valid(pdtlv, len); if (invtlv) { - printf - ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n", - tok2str(ForCES_TLV_err, NULL, invtlv), len, type, - EXTRACT_16BITS(&pdtlv->length)); + ND_PRINT((ndo, "%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n", + tok2str(ForCES_TLV_err, NULL, invtlv), len, type, + EXTRACT_16BITS(&pdtlv->length))); goto pd_err; } /* @@ -936,9 +939,9 @@ pdatacnt_print(register const u_char * pptr, register u_int len, aln = F_ALN_LEN(EXTRACT_16BITS(&pdtlv->length)); if (aln > EXTRACT_16BITS(&pdtlv->length)) { if (aln > len) { - printf - ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n", - type, EXTRACT_16BITS(&pdtlv->length), aln - len); + ND_PRINT((ndo, + "Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n", + type, EXTRACT_16BITS(&pdtlv->length), aln - len)); } else { pad = aln - EXTRACT_16BITS(&pdtlv->length); } @@ -946,34 +949,30 @@ pdatacnt_print(register const u_char * pptr, register u_int len, if (pd_valid(type)) { const struct pdata_ops *ops = get_forces_pd(type); - if (vflag >= 3 && ops->v != F_TLV_PDAT) { + if (ndo->ndo_vflag >= 3 && ops->v != F_TLV_PDAT) { if (pad) - printf - ("%s %s (Length %d DataLen %d pad %d Bytes)\n", - ib, ops->s, EXTRACT_16BITS(&pdtlv->length), - tll, pad); + ND_PRINT((ndo, "%s %s (Length %d DataLen %d pad %d Bytes)\n", + ib, ops->s, EXTRACT_16BITS(&pdtlv->length), tll, pad)); else - printf - ("%s %s (Length %d DataLen %d Bytes)\n", - ib, ops->s, EXTRACT_16BITS(&pdtlv->length), - tll); + ND_PRINT((ndo, "%s %s (Length %d DataLen %d Bytes)\n", + ib, ops->s, EXTRACT_16BITS(&pdtlv->length), tll)); } - chk_op_type(type, op_msk, ops->op_msk); + chk_op_type(ndo, type, op_msk, ops->op_msk); - if (ops->print((const u_char *)pdtlv, + if (ops->print(ndo, (const u_char *)pdtlv, tll + pad + TLV_HDRL, op_msk, indent + 2) == -1) return -1; len -= (TLV_HDRL + pad + tll); } else { - printf("Invalid path data content type 0x%x len %d\n", - type, EXTRACT_16BITS(&pdtlv->length)); + ND_PRINT((ndo, "Invalid path data content type 0x%x len %d\n", + type, EXTRACT_16BITS(&pdtlv->length))); pd_err: if (EXTRACT_16BITS(&pdtlv->length)) { - hex_print_with_offset(gndo,"Bad Data val\n\t [", + hex_print_with_offset(ndo, "Bad Data val\n\t [", pptr, len, 0); - printf("]\n"); + ND_PRINT((ndo, "]\n")); return -1; } @@ -982,13 +981,14 @@ pd_err: return len; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } static int -pdata_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk, int indent) +pdata_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) { const struct pathdata_h *pdh = (struct pathdata_h *)pptr; char *ib = indent_pr(indent, 0); @@ -996,12 +996,12 @@ pdata_print(register const u_char * pptr, register u_int len, int more_pd = 0; u_int16_t idcnt = 0; - TCHECK(*pdh); + ND_TCHECK(*pdh); if (len < sizeof(struct pathdata_h)) goto trunc; - if (vflag >= 3) { - printf("\n%sPathdata: Flags 0x%x ID count %d\n", - ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt)); + if (ndo->ndo_vflag >= 3) { + ND_PRINT((ndo, "\n%sPathdata: Flags 0x%x ID count %d\n", + ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt))); } if (EXTRACT_16BITS(&pdh->pflags) & F_SELKEY) { @@ -1022,36 +1022,37 @@ pdata_print(register const u_char * pptr, register u_int len, idcnt = EXTRACT_16BITS(&pdh->pIDcnt); minsize = idcnt * 4; if (len < minsize) { - printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize, - len); - hex_print_with_offset(gndo,"\t\t\tID Data[", pptr, len, 0); - printf("]\n"); + ND_PRINT((ndo, "\t\t\ttruncated IDs expected %uB got %uB\n", minsize, + len)); + hex_print_with_offset(ndo, "\t\t\tID Data[", pptr, len, 0); + ND_PRINT((ndo, "]\n")); return -1; } if ((op_msk & B_TRNG) && (op_msk & B_KEYIN)) { - printf("\t\t\tIllegal to have both Table ranges and keys\n"); + ND_PRINT((ndo, "\t\t\tIllegal to have both Table ranges and keys\n")); return -1; } - more_pd = pdatacnt_print(pptr, len, idcnt, op_msk, indent); + more_pd = pdatacnt_print(ndo, pptr, len, idcnt, op_msk, indent); if (more_pd > 0) { int consumed = len - more_pd; pptr += consumed; len = more_pd; /* XXX: Argh, recurse some more */ - return recpdoptlv_print(pptr, len, op_msk, indent+1); + return recpdoptlv_print(ndo, pptr, len, op_msk, indent+1); } else return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } static int -genoptlv_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk, int indent) +genoptlv_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) { const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr; u_int16_t type; @@ -1059,12 +1060,12 @@ genoptlv_print(register const u_char * pptr, register u_int len, u_int invtlv; char *ib = indent_pr(indent, 0); - TCHECK(*pdtlv); + ND_TCHECK(*pdtlv); type = EXTRACT_16BITS(&pdtlv->type); tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL; invtlv = tlv_valid(pdtlv, len); - printf("genoptlvprint - %s TLV type 0x%x len %d\n", - tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length)); + ND_PRINT((ndo, "genoptlvprint - %s TLV type 0x%x len %d\n", + tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length))); if (!invtlv) { /* * At this point, tlv_valid() has ensured that the TLV @@ -1073,30 +1074,31 @@ genoptlv_print(register const u_char * pptr, register u_int len, */ register const u_char *dp = (u_char *) TLV_DATA(pdtlv); if (!ttlv_valid(type)) { - printf("%s TLV type 0x%x len %d\n", + ND_PRINT((ndo, "%s TLV type 0x%x len %d\n", tok2str(ForCES_TLV_err, NULL, invtlv), type, - EXTRACT_16BITS(&pdtlv->length)); + EXTRACT_16BITS(&pdtlv->length))); return -1; } - if (vflag >= 3) - printf("%s%s, length %d (data length %d Bytes)", + if (ndo->ndo_vflag >= 3) + ND_PRINT((ndo, "%s%s, length %d (data length %d Bytes)", ib, tok2str(ForCES_TLV, NULL, type), - EXTRACT_16BITS(&pdtlv->length), tll); + EXTRACT_16BITS(&pdtlv->length), tll)); - return pdata_print(dp, tll, op_msk, indent + 1); + return pdata_print(ndo, dp, tll, op_msk, indent + 1); } else { - printf("\t\t\tInvalid ForCES TLV type=%x", type); + ND_PRINT((ndo, "\t\t\tInvalid ForCES TLV type=%x", type)); return -1; } trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } static int -recpdoptlv_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk, int indent) +recpdoptlv_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) { const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr; int tll; @@ -1106,7 +1108,7 @@ recpdoptlv_print(register const u_char * pptr, register u_int len, char *ib; while (len != 0) { - TCHECK(*pdtlv); + ND_TCHECK(*pdtlv); invtlv = tlv_valid(pdtlv, len); if (invtlv) { break; @@ -1122,48 +1124,49 @@ recpdoptlv_print(register const u_char * pptr, register u_int len, dp = (u_char *) TLV_DATA(pdtlv); tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL; - if (vflag >= 3) - printf - ("%s%s, length %d (data encapsulated %d Bytes)", - ib, tok2str(ForCES_TLV, NULL, type), - EXTRACT_16BITS(&pdtlv->length), - EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL); + if (ndo->ndo_vflag >= 3) + ND_PRINT((ndo, "%s%s, length %d (data encapsulated %d Bytes)", + ib, tok2str(ForCES_TLV, NULL, type), + EXTRACT_16BITS(&pdtlv->length), + EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL)); - if (pdata_print(dp, tll, op_msk, indent + 1) == -1) + if (pdata_print(ndo, dp, tll, op_msk, indent + 1) == -1) return -1; pdtlv = GO_NXT_TLV(pdtlv, len); } if (len) { - printf - ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ", - EXTRACT_16BITS(&pdtlv->type), len - EXTRACT_16BITS(&pdtlv->length)); + ND_PRINT((ndo, + "\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ", + EXTRACT_16BITS(&pdtlv->type), len - EXTRACT_16BITS(&pdtlv->length))); return -1; } return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } static int -invoptlv_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk _U_, int indent) +invoptlv_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) { char *ib = indent_pr(indent, 1); - if (vflag >= 3) { - printf("%sData[", &ib[1]); - hex_print_with_offset(gndo,ib, pptr, len, 0); - printf("%s]\n", ib); + if (ndo->ndo_vflag >= 3) { + ND_PRINT((ndo, "%sData[", &ib[1])); + hex_print_with_offset(ndo, ib, pptr, len, 0); + ND_PRINT((ndo, "%s]\n", ib)); } return -1; } static int -otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent) +otlv_print(netdissect_options *ndo, + const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent) { int rc = 0; register const u_char *dp = (u_char *) TLV_DATA(otlv); @@ -1176,43 +1179,44 @@ otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent) * lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length) * >= TLV_HDRL. */ - TCHECK(*otlv); + ND_TCHECK(*otlv); type = EXTRACT_16BITS(&otlv->type); tll = EXTRACT_16BITS(&otlv->length) - TLV_HDRL; ops = get_forces_optlv_h(type); - if (vflag >= 3) { - printf("%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type, - EXTRACT_16BITS(&otlv->length)); + if (ndo->ndo_vflag >= 3) { + ND_PRINT((ndo, "%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type, + EXTRACT_16BITS(&otlv->length))); } /* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */ if (!ops->flags & ZERO_TTLV) { if (tll != 0) /* instead of "if (tll)" - for readability .. */ - printf("%s: Illegal - MUST be empty\n", ops->s); + ND_PRINT((ndo, "%s: Illegal - MUST be empty\n", ops->s)); return rc; } /* rest of ops must at least have 12B {pathinfo} */ if (tll < OP_MIN_SIZ) { - printf("\t\tOper TLV %s(0x%x) length %d\n", ops->s, type, - EXTRACT_16BITS(&otlv->length)); - printf("\t\tTruncated data size %d minimum required %d\n", tll, - OP_MIN_SIZ); - return invoptlv_print(dp, tll, ops->op_msk, indent); + ND_PRINT((ndo, "\t\tOper TLV %s(0x%x) length %d\n", ops->s, type, + EXTRACT_16BITS(&otlv->length))); + ND_PRINT((ndo, "\t\tTruncated data size %d minimum required %d\n", tll, + OP_MIN_SIZ)); + return invoptlv_print(ndo, dp, tll, ops->op_msk, indent); } - rc = ops->print(dp, tll, ops->op_msk, indent + 1); + rc = ops->print(ndo, dp, tll, ops->op_msk, indent + 1); return rc; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } #define ASTDLN 4 #define ASTMCD 255 static int -asttlv_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk _U_, int indent) +asttlv_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) { u_int32_t rescode; u_int dlen; @@ -1224,52 +1228,53 @@ asttlv_print(register const u_char * pptr, register u_int len, */ dlen = len - TLV_HDRL; if (dlen != ASTDLN) { - printf("illegal ASTresult-TLV: %d bytes!\n", dlen); + ND_PRINT((ndo, "illegal ASTresult-TLV: %d bytes!\n", dlen)); return -1; } - TCHECK2(*pptr, 4); + ND_TCHECK2(*pptr, 4); rescode = EXTRACT_32BITS(pptr); if (rescode > ASTMCD) { - printf("illegal ASTresult result code: %d!\n", rescode); + ND_PRINT((ndo, "illegal ASTresult result code: %d!\n", rescode)); return -1; } - if (vflag >= 3) { - printf("Teardown reason:\n%s", ib); + if (ndo->ndo_vflag >= 3) { + ND_PRINT((ndo, "Teardown reason:\n%s", ib)); switch (rescode) { case 0: - printf("Normal Teardown"); + ND_PRINT((ndo, "Normal Teardown")); break; case 1: - printf("Loss of Heartbeats"); + ND_PRINT((ndo, "Loss of Heartbeats")); break; case 2: - printf("Out of bandwidth"); + ND_PRINT((ndo, "Out of bandwidth")); break; case 3: - printf("Out of Memory"); + ND_PRINT((ndo, "Out of Memory")); break; case 4: - printf("Application Crash"); + ND_PRINT((ndo, "Application Crash")); break; default: - printf("Unknown Teardown reason"); + ND_PRINT((ndo, "Unknown Teardown reason")); break; } - printf("(%x)\n%s", rescode, ib); + ND_PRINT((ndo, "(%x)\n%s", rescode, ib)); } return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } #define ASRDLN 4 #define ASRMCD 3 static int -asrtlv_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk _U_, int indent) +asrtlv_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) { u_int32_t rescode; u_int dlen; @@ -1281,39 +1286,39 @@ asrtlv_print(register const u_char * pptr, register u_int len, */ dlen = len - TLV_HDRL; if (dlen != ASRDLN) { /* id, instance, oper tlv */ - printf("illegal ASRresult-TLV: %d bytes!\n", dlen); + ND_PRINT((ndo, "illegal ASRresult-TLV: %d bytes!\n", dlen)); return -1; } - TCHECK2(*pptr, 4); + ND_TCHECK2(*pptr, 4); rescode = EXTRACT_32BITS(pptr); if (rescode > ASRMCD) { - printf("illegal ASRresult result code: %d!\n", rescode); + ND_PRINT((ndo, "illegal ASRresult result code: %d!\n", rescode)); return -1; } - if (vflag >= 3) { - printf("\n%s", ib); + if (ndo->ndo_vflag >= 3) { + ND_PRINT((ndo, "\n%s", ib)); switch (rescode) { case 0: - printf("Success "); + ND_PRINT((ndo, "Success ")); break; case 1: - printf("FE ID invalid "); + ND_PRINT((ndo, "FE ID invalid ")); break; case 2: - printf("permission denied "); + ND_PRINT((ndo, "permission denied ")); break; default: - printf("Unknown "); + ND_PRINT((ndo, "Unknown ")); break; } - printf("(%x)\n%s", rescode, ib); + ND_PRINT((ndo, "(%x)\n%s", rescode, ib)); } return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } @@ -1322,13 +1327,14 @@ trunc: * XXX - not used. */ static int -gentltlv_print(register const u_char * pptr _U_, register u_int len, - u_int16_t op_msk _U_, int indent _U_) +gentltlv_print(netdissect_options *ndo, + register const u_char * pptr _U_, register u_int len, + u_int16_t op_msk _U_, int indent _U_) { u_int dlen = len - TLV_HDRL; if (dlen < 4) { /* at least 32 bits must exist */ - printf("truncated TLV: %d bytes missing! ", 4 - dlen); + ND_PRINT((ndo, "truncated TLV: %d bytes missing! ", 4 - dlen)); return -1; } return 0; @@ -1338,7 +1344,8 @@ gentltlv_print(register const u_char * pptr _U_, register u_int len, #define RD_MIN 8 static int -print_metailv(register const u_char * pptr, u_int16_t op_msk _U_, int indent) +print_metailv(netdissect_options *ndo, + register const u_char * pptr, u_int16_t op_msk _U_, int indent) { u_int rlen; char *ib = indent_pr(indent, 0); @@ -1350,23 +1357,24 @@ print_metailv(register const u_char * pptr, u_int16_t op_msk _U_, int indent) * ILV) >= ILV_HDRL. */ rlen = EXTRACT_32BITS(&ilv->length) - ILV_HDRL; - TCHECK(*ilv); - printf("%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type), - EXTRACT_32BITS(&ilv->length)); - if (vflag >= 3) { - hex_print_with_offset(gndo,"\t\t[", ILV_DATA(ilv), rlen, 0); - printf(" ]\n"); + ND_TCHECK(*ilv); + ND_PRINT((ndo, "%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type), + EXTRACT_32BITS(&ilv->length))); + if (ndo->ndo_vflag >= 3) { + hex_print_with_offset(ndo, "\t\t[", ILV_DATA(ilv), rlen, 0); + ND_PRINT((ndo, " ]\n")); } return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } static int -print_metatlv(register const u_char * pptr, register u_int len, - u_int16_t op_msk _U_, int indent) +print_metatlv(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) { u_int dlen; char *ib = indent_pr(indent, 0); @@ -1380,9 +1388,9 @@ print_metatlv(register const u_char * pptr, register u_int len, */ dlen = len - TLV_HDRL; rlen = dlen; - printf("\n%s METADATA length %d \n", ib, rlen); + ND_PRINT((ndo, "\n%s METADATA length %d \n", ib, rlen)); while (rlen != 0) { - TCHECK(*ilv); + ND_TCHECK(*ilv); invilv = ilv_valid(ilv, rlen); if (invilv) { break; @@ -1393,21 +1401,22 @@ print_metatlv(register const u_char * pptr, register u_int len, * length is large enough but not too large (it doesn't * go past the end of the containing TLV). */ - print_metailv((u_char *) ilv, 0, indent + 1); + print_metailv(ndo, (u_char *) ilv, 0, indent + 1); ilv = GO_NXT_ILV(ilv, rlen); } return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } static int -print_reddata(register const u_char * pptr, register u_int len, - u_int16_t op_msk _U_, int indent _U_) +print_reddata(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent _U_) { u_int dlen; char *ib = indent_pr(indent, 0); @@ -1415,20 +1424,21 @@ print_reddata(register const u_char * pptr, register u_int len, dlen = len - TLV_HDRL; rlen = dlen; - printf("\n%s Redirect Data length %d \n", ib, rlen); + ND_PRINT((ndo, "\n%s Redirect Data length %d \n", ib, rlen)); - if (vflag >= 3) { - printf("\t\t["); - hex_print_with_offset(gndo,"\n\t\t", pptr, rlen, 0); - printf("\n\t\t]"); + if (ndo->ndo_vflag >= 3) { + ND_PRINT((ndo, "\t\t[")); + hex_print_with_offset(ndo, "\n\t\t", pptr, rlen, 0); + ND_PRINT((ndo, "\n\t\t]")); } return 0; } static int -redirect_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk _U_, int indent) +redirect_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk _U_, int indent) { const struct forces_tlv *tlv = (struct forces_tlv *)pptr; u_int dlen; @@ -1441,18 +1451,18 @@ redirect_print(register const u_char * pptr, register u_int len, */ dlen = len - TLV_HDRL; if (dlen <= RD_MIN) { - printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ", - RD_MIN - dlen); + ND_PRINT((ndo, "\n\t\ttruncated Redirect TLV: %d bytes missing! ", + RD_MIN - dlen)); return -1; } rlen = dlen; indent += 1; while (rlen != 0) { - TCHECK(*tlv); + ND_TCHECK(*tlv); invtlv = tlv_valid(tlv, rlen); if (invtlv) { - printf("Bad Redirect data\n"); + ND_PRINT((ndo, "Bad Redirect data\n")); break; } @@ -1462,32 +1472,32 @@ redirect_print(register const u_char * pptr, register u_int len, * go past the end of the containing TLV). */ if (EXTRACT_16BITS(&tlv->type) == F_TLV_METD) { - print_metatlv((u_char *) TLV_DATA(tlv), + print_metatlv(ndo, (u_char *) TLV_DATA(tlv), EXTRACT_16BITS(&tlv->length), 0, indent); } else if ((EXTRACT_16BITS(&tlv->type) == F_TLV_REDD)) { - print_reddata((u_char *) TLV_DATA(tlv), + print_reddata(ndo, (u_char *) TLV_DATA(tlv), EXTRACT_16BITS(&tlv->length), 0, indent); } else { - printf("Unknown REDIRECT TLV 0x%x len %d\n", + ND_PRINT((ndo, "Unknown REDIRECT TLV 0x%x len %d\n", EXTRACT_16BITS(&tlv->type), - EXTRACT_16BITS(&tlv->length)); + EXTRACT_16BITS(&tlv->length))); } tlv = GO_NXT_TLV(tlv, rlen); } if (rlen) { - printf - ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ", - EXTRACT_16BITS(&tlv->type), - rlen - EXTRACT_16BITS(&tlv->length)); + ND_PRINT((ndo, + "\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ", + EXTRACT_16BITS(&tlv->type), + rlen - EXTRACT_16BITS(&tlv->length))); return -1; } return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } @@ -1495,8 +1505,9 @@ trunc: #define OP_MIN 12 static int -lfbselect_print(register const u_char * pptr, register u_int len, - u_int16_t op_msk, int indent) +lfbselect_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len, + u_int16_t op_msk, int indent) { const struct forces_lfbsh *lfbs; const struct forces_tlv *otlv; @@ -1511,8 +1522,8 @@ lfbselect_print(register const u_char * pptr, register u_int len, */ dlen = len - TLV_HDRL; if (dlen <= OP_MIN) { /* id, instance, oper tlv header .. */ - printf("\n\t\ttruncated lfb selector: %d bytes missing! ", - OP_MIN - dlen); + ND_PRINT((ndo, "\n\t\ttruncated lfb selector: %d bytes missing! ", + OP_MIN - dlen)); return -1; } @@ -1523,19 +1534,19 @@ lfbselect_print(register const u_char * pptr, register u_int len, rlen = dlen - OP_OFF; lfbs = (const struct forces_lfbsh *)pptr; - TCHECK(*lfbs); - if (vflag >= 3) { - printf("\n%s%s(Classid %x) instance %x\n", + ND_TCHECK(*lfbs); + if (ndo->ndo_vflag >= 3) { + ND_PRINT((ndo, "\n%s%s(Classid %x) instance %x\n", ib, tok2str(ForCES_LFBs, NULL, EXTRACT_32BITS(&lfbs->class)), EXTRACT_32BITS(&lfbs->class), - EXTRACT_32BITS(&lfbs->instance)); + EXTRACT_32BITS(&lfbs->instance))); } otlv = (struct forces_tlv *)(lfbs + 1); indent += 1; while (rlen != 0) { - TCHECK(*otlv); + ND_TCHECK(*otlv); invtlv = tlv_valid(otlv, rlen); if (invtlv) break; @@ -1546,35 +1557,36 @@ lfbselect_print(register const u_char * pptr, register u_int len, * go past the end of the containing TLV). */ if (op_valid(EXTRACT_16BITS(&otlv->type), op_msk)) { - otlv_print(otlv, 0, indent); + otlv_print(ndo, otlv, 0, indent); } else { - if (vflag < 3) - printf("\n"); - printf - ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n", - EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length)); - invoptlv_print((u_char *)otlv, rlen, 0, indent); + if (ndo->ndo_vflag < 3) + ND_PRINT((ndo, "\n")); + ND_PRINT((ndo, + "\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n", + EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length))); + invoptlv_print(ndo, (u_char *)otlv, rlen, 0, indent); } otlv = GO_NXT_TLV(otlv, rlen); } if (rlen) { - printf - ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ", - EXTRACT_16BITS(&otlv->type), rlen - EXTRACT_16BITS(&otlv->length)); + ND_PRINT((ndo, + "\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ", + EXTRACT_16BITS(&otlv->type), rlen - EXTRACT_16BITS(&otlv->length))); return -1; } return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } static int -forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_, - register u_int mlen, const struct tom_h *tops) +forces_type_print(netdissect_options *ndo, + register const u_char * pptr, const struct forcesh *fhdr _U_, + register u_int mlen, const struct tom_h *tops) { const struct forces_tlv *tltlv; u_int rlen; @@ -1590,14 +1602,14 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_, if (rlen > TLV_HLN) { if (tops->flags & ZERO_TTLV) { - printf("<0x%x>Illegal Top level TLV!\n", tops->flags); + ND_PRINT((ndo, "<0x%x>Illegal Top level TLV!\n", tops->flags)); return -1; } } else { if (tops->flags & ZERO_MORE_TTLV) return 0; if (tops->flags & ONE_MORE_TTLV) { - printf("\tTop level TLV Data missing!\n"); + ND_PRINT((ndo, "\tTop level TLV Data missing!\n")); return -1; } } @@ -1612,7 +1624,7 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_, /*XXX: 15 top level tlvs will probably be fine You are nuts if you send more ;-> */ while (rlen != 0) { - TCHECK(*tltlv); + ND_TCHECK(*tltlv); invtlv = tlv_valid(tltlv, rlen); if (invtlv) break; @@ -1623,18 +1635,18 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_, * go past the end of the packet). */ if (!ttlv_valid(EXTRACT_16BITS(&tltlv->type))) { - printf("\n\tInvalid ForCES Top TLV type=0x%x", - EXTRACT_16BITS(&tltlv->type)); + ND_PRINT((ndo, "\n\tInvalid ForCES Top TLV type=0x%x", + EXTRACT_16BITS(&tltlv->type))); return -1; } - if (vflag >= 3) - printf("\t%s, length %d (data length %d Bytes)", + if (ndo->ndo_vflag >= 3) + ND_PRINT((ndo, "\t%s, length %d (data length %d Bytes)", tok2str(ForCES_TLV, NULL, EXTRACT_16BITS(&tltlv->type)), EXTRACT_16BITS(&tltlv->length), - EXTRACT_16BITS(&tltlv->length) - TLV_HDRL); + EXTRACT_16BITS(&tltlv->length) - TLV_HDRL)); - rc = tops->print((u_char *) TLV_DATA(tltlv), + rc = tops->print(ndo, (u_char *) TLV_DATA(tltlv), EXTRACT_16BITS(&tltlv->length), tops->op_msk, 9); if (rc < 0) { return -1; @@ -1649,20 +1661,21 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_, * short, and didn't have *enough* TLVs in it? */ if (rlen) { - printf("\tMess TopTLV header: min %u, total %d advertised %d ", - TLV_HDRL, rlen, EXTRACT_16BITS(&tltlv->length)); + ND_PRINT((ndo, "\tMess TopTLV header: min %u, total %d advertised %d ", + TLV_HDRL, rlen, EXTRACT_16BITS(&tltlv->length))); return -1; } return 0; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); return -1; } void -forces_print(register const u_char * pptr, register u_int len) +forces_print(netdissect_options *ndo, + register const u_char * pptr, register u_int len) { const struct forcesh *fhdr; u_int mlen; @@ -1671,9 +1684,9 @@ forces_print(register const u_char * pptr, register u_int len) int rc = 0; fhdr = (const struct forcesh *)pptr; - TCHECK(*fhdr); + ND_TCHECK(*fhdr); if (!tom_valid(fhdr->fm_tom)) { - printf("Invalid ForCES message type %d\n", fhdr->fm_tom); + ND_PRINT((ndo, "Invalid ForCES message type %d\n", fhdr->fm_tom)); goto error; } @@ -1681,32 +1694,33 @@ forces_print(register const u_char * pptr, register u_int len) tops = get_forces_tom(fhdr->fm_tom); if (tops->v == TOM_RSVD) { - printf("\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom); + ND_PRINT((ndo, "\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom)); goto error; } - printf("\n\tForCES %s ", tops->s); + ND_PRINT((ndo, "\n\tForCES %s ", tops->s)); if (!ForCES_HLN_VALID(mlen, len)) { - printf - ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ", - ForCES_HDRL, len, ForCES_BLN(fhdr)); + ND_PRINT((ndo, + "Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ", + ForCES_HDRL, len, ForCES_BLN(fhdr))); goto error; } - TCHECK2(*(pptr + 20), 4); + ND_TCHECK2(*(pptr + 20), 4); flg_raw = EXTRACT_32BITS(pptr + 20); - if (vflag >= 1) { - printf("\n\tForCES Version %d len %uB flags 0x%08x ", - ForCES_V(fhdr), mlen, flg_raw); - printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64, + if (ndo->ndo_vflag >= 1) { + ND_PRINT((ndo, "\n\tForCES Version %d len %uB flags 0x%08x ", + ForCES_V(fhdr), mlen, flg_raw)); + ND_PRINT((ndo, + "\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64, ForCES_SID(fhdr), ForCES_node(ForCES_SID(fhdr)), ForCES_DID(fhdr), ForCES_node(ForCES_DID(fhdr)), - EXTRACT_64BITS(fhdr->fm_cor)); + EXTRACT_64BITS(fhdr->fm_cor))); } - if (vflag >= 2) { - printf - ("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n", + if (ndo->ndo_vflag >= 2) { + ND_PRINT((ndo, + "\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n", tok2str(ForCES_ACKs, "ACKUnknown", ForCES_ACK(fhdr)), ForCES_ACK(fhdr), ForCES_PRI(fhdr), @@ -1715,29 +1729,29 @@ forces_print(register const u_char * pptr, register u_int len) tok2str(ForCES_ATs, "ATUnknown", ForCES_AT(fhdr)), ForCES_AT(fhdr), tok2str(ForCES_TPs, "TPUnknown", ForCES_TP(fhdr)), - ForCES_TP(fhdr)); - printf - ("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n", - ForCES_RS1(fhdr), ForCES_RS2(fhdr)); + ForCES_TP(fhdr))); + ND_PRINT((ndo, + "\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n", + ForCES_RS1(fhdr), ForCES_RS2(fhdr))); } - rc = forces_type_print(pptr, fhdr, mlen, tops); + rc = forces_type_print(ndo, pptr, fhdr, mlen, tops); if (rc < 0) { error: - hex_print_with_offset(gndo,"\n\t[", pptr, len, 0); - printf("\n\t]"); + hex_print_with_offset(ndo, "\n\t[", pptr, len, 0); + ND_PRINT((ndo, "\n\t]")); return; } - if (vflag >= 4) { - printf("\n\t Raw ForCES message\n\t ["); - hex_print_with_offset(gndo,"\n\t ", pptr, len, 0); - printf("\n\t ]"); + if (ndo->ndo_vflag >= 4) { + ND_PRINT((ndo, "\n\t Raw ForCES message\n\t [")); + hex_print_with_offset(ndo, "\n\t ", pptr, len, 0); + ND_PRINT((ndo, "\n\t ]")); } - printf("\n"); + ND_PRINT((ndo, "\n")); return; trunc: - printf("%s", tstr); + ND_PRINT((ndo, "%s", tstr)); } /* * Local Variables: diff --git a/print-lspping.c b/print-lspping.c index e0e6c0b4..9ecc77ed 100644 --- a/print-lspping.c +++ b/print-lspping.c @@ -13,16 +13,13 @@ * Original code by Hannes Gredler (hannes@juniper.net) */ +#define NETDISSECT_REWORKED #ifdef HAVE_CONFIG_H #include "config.h" #endif #include -#include -#include -#include - #include "interface.h" #include "extract.h" #include "addrtoname.h" @@ -460,7 +457,8 @@ static const struct tok lspping_tlv_downstream_addr_values[] = { }; void -lspping_print(register const u_char *pptr, register u_int len) { +lspping_print(netdissect_options *ndo, + register const u_char *pptr, register u_int len) { const struct lspping_common_header *lspping_com_header; const struct lspping_tlv_header *lspping_tlv_header; @@ -493,24 +491,24 @@ lspping_print(register const u_char *pptr, register u_int len) { tptr=pptr; lspping_com_header = (const struct lspping_common_header *)pptr; - TCHECK(*lspping_com_header); + ND_TCHECK(*lspping_com_header); /* * Sanity checking of the header. */ if (EXTRACT_16BITS(&lspping_com_header->version[0]) != LSPPING_VERSION) { - printf("LSP-PING version %u packet not supported", - EXTRACT_16BITS(&lspping_com_header->version[0])); + ND_PRINT((ndo, "LSP-PING version %u packet not supported", + EXTRACT_16BITS(&lspping_com_header->version[0]))); return; } /* in non-verbose mode just lets print the basic Message Type*/ - if (vflag < 1) { - printf("LSP-PINGv%u, %s, seq %u, length: %u", + if (ndo->ndo_vflag < 1) { + ND_PRINT((ndo, "LSP-PINGv%u, %s, seq %u, length: %u", EXTRACT_16BITS(&lspping_com_header->version[0]), tok2str(lspping_msg_type_values, "unknown (%u)",lspping_com_header->msg_type), EXTRACT_32BITS(lspping_com_header->seq_number), - len); + len)); return; } @@ -518,13 +516,13 @@ lspping_print(register const u_char *pptr, register u_int len) { tlen=len; - printf("\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)", + ND_PRINT((ndo, "\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)", EXTRACT_16BITS(&lspping_com_header->version[0]), tok2str(lspping_msg_type_values, "unknown",lspping_com_header->msg_type), lspping_com_header->msg_type, len, tok2str(lspping_reply_mode_values, "unknown",lspping_com_header->reply_mode), - lspping_com_header->reply_mode); + lspping_com_header->reply_mode)); /* * the following return codes require that the subcode is attached @@ -536,33 +534,33 @@ lspping_print(register const u_char *pptr, register u_int len) { lspping_com_header->return_code == 10 || lspping_com_header->return_code == 11 || lspping_com_header->return_code == 12 ) - printf("\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)", + ND_PRINT((ndo, "\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)", tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code), lspping_com_header->return_subcode, lspping_com_header->return_code, - lspping_com_header->return_subcode); + lspping_com_header->return_subcode)); else - printf("\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)", + ND_PRINT((ndo, "\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)", tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code), lspping_com_header->return_code, - lspping_com_header->return_subcode); + lspping_com_header->return_subcode)); - printf("\n\t Sender Handle: 0x%08x, Sequence: %u", + ND_PRINT((ndo, "\n\t Sender Handle: 0x%08x, Sequence: %u", EXTRACT_32BITS(lspping_com_header->sender_handle), - EXTRACT_32BITS(lspping_com_header->seq_number)); + EXTRACT_32BITS(lspping_com_header->seq_number))); timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec); timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec); - printf("\n\t Sender Timestamp: "); + ND_PRINT((ndo, "\n\t Sender Timestamp: ")); ts_print(×tamp); timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec); timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec); - printf("Receiver Timestamp: "); + ND_PRINT((ndo, "Receiver Timestamp: ")); if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0)) ts_print(×tamp); else - printf("no timestamp"); + ND_PRINT((ndo, "no timestamp")); tptr+=sizeof(const struct lspping_common_header); tlen-=sizeof(const struct lspping_common_header); @@ -570,7 +568,7 @@ lspping_print(register const u_char *pptr, register u_int len) { while(tlen>(int)sizeof(struct lspping_tlv_header)) { /* did we capture enough for fully decoding the tlv header ? */ - if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header))) + if (!ND_TTEST2(*tptr, sizeof(struct lspping_tlv_header))) goto trunc; lspping_tlv_header = (const struct lspping_tlv_header *)tptr; @@ -582,22 +580,22 @@ lspping_print(register const u_char *pptr, register u_int len) { return; if(lspping_tlv_len < 4) { - printf("\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len); + ND_PRINT((ndo, "\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len)); return; } - printf("\n\t %s TLV (%u), length: %u", + ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u", tok2str(lspping_tlv_values, "Unknown", lspping_tlv_type), lspping_tlv_type, - lspping_tlv_len); + lspping_tlv_len)); tlv_tptr=tptr+sizeof(struct lspping_tlv_header); tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */ /* did we capture enough for fully decoding the tlv ? */ - if (!TTEST2(*tptr, lspping_tlv_len)) + if (!ND_TTEST2(*tptr, lspping_tlv_len)) goto trunc; tlv_hexdump=FALSE; @@ -606,7 +604,7 @@ lspping_print(register const u_char *pptr, register u_int len) { while(tlv_tlen>(int)sizeof(struct lspping_tlv_header)) { /* did we capture enough for fully decoding the subtlv header ? */ - if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header))) + if (!ND_TTEST2(*tptr, sizeof(struct lspping_tlv_header))) goto trunc; subtlv_hexdump=FALSE; @@ -618,111 +616,111 @@ lspping_print(register const u_char *pptr, register u_int len) { if (lspping_subtlv_len == 0) break; - printf("\n\t %s subTLV (%u), length: %u", + ND_PRINT((ndo, "\n\t %s subTLV (%u), length: %u", tok2str(lspping_tlvtargetfec_subtlv_values, "Unknown", lspping_subtlv_type), lspping_subtlv_type, - lspping_subtlv_len); + lspping_subtlv_len)); switch(lspping_subtlv_type) { case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4: subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \ (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr; - printf("\n\t %s/%u", + ND_PRINT((ndo, "\n\t %s/%u", ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix), - subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len); + subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len)); break; #ifdef INET6 case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6: subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \ (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr; - printf("\n\t %s/%u", + ND_PRINT((ndo, "\n\t %s/%u", ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix), - subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len); + subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len)); break; #endif case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4: subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \ (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr; - printf("\n\t %s/%u, sender-id %s", + ND_PRINT((ndo, "\n\t %s/%u, sender-id %s", ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix), subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len, - ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id)); + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id))); break; #ifdef INET6 case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6: subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \ (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr; - printf("\n\t %s/%u, sender-id %s", + ND_PRINT((ndo, "\n\t %s/%u, sender-id %s", ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix), subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len, - ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id)); + ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id))); break; #endif case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4: subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \ (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr; - printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \ + ND_PRINT((ndo, "\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \ "\n\t tunnel-id 0x%04x, extended tunnel-id %s", ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint), ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender), EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id), EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id), - ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id)); + ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id))); break; #ifdef INET6 case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6: subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \ (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr; - printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \ + ND_PRINT((ndo, "\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \ "\n\t tunnel-id 0x%04x, extended tunnel-id %s", ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint), ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender), EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id), EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id), - ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id)); + ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id))); break; #endif case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4: subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \ (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr; - printf("\n\t RD: %s, %s/%u", - bgp_vpn_rd_print(gndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd), + ND_PRINT((ndo, "\n\t RD: %s, %s/%u", + bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd), ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix), - subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len); + subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len)); break; #ifdef INET6 case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6: subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \ (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr; - printf("\n\t RD: %s, %s/%u", - bgp_vpn_rd_print(gndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd), + ND_PRINT((ndo, "\n\t RD: %s, %s/%u", + bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd), ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix), - subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len); + subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len)); break; #endif case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT: subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \ (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr; - printf("\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \ + ND_PRINT((ndo, "\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \ "\n\t Encapsulation Type: %s (%u)", - bgp_vpn_rd_print(gndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd), + bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd), EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ce_id), EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ce_id), tok2str(l2vpn_encaps_values, "unknown", EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)), - EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)); + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation))); break; @@ -730,21 +728,21 @@ lspping_print(register const u_char *pptr, register u_int len) { case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD: subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \ (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *)subtlv_tptr; - printf("\n\t Remote PE: %s" \ + ND_PRINT((ndo, "\n\t Remote PE: %s" \ "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)", ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address), EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->vc_id), tok2str(l2vpn_encaps_values, "unknown", EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)), - EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)); + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation))); break; case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID: subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid = \ (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *)subtlv_tptr; - printf("\n\t Sender PE: %s, Remote PE: %s" \ + ND_PRINT((ndo, "\n\t Sender PE: %s, Remote PE: %s" \ "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)", ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address), ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address), @@ -752,7 +750,7 @@ lspping_print(register const u_char *pptr, register u_int len) { tok2str(l2vpn_encaps_values, "unknown", EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)), - EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)); + EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation))); break; @@ -761,8 +759,8 @@ lspping_print(register const u_char *pptr, register u_int len) { break; } /* do we want to see an additionally subtlv hexdump ? */ - if (vflag > 1 || subtlv_hexdump==TRUE) - print_unknown_data(gndo,tlv_tptr+sizeof(struct lspping_tlv_header), \ + if (ndo->ndo_vflag > 1 || subtlv_hexdump==TRUE) + print_unknown_data(ndo, tlv_tptr+sizeof(struct lspping_tlv_header), \ "\n\t ", lspping_subtlv_len); @@ -780,38 +778,38 @@ lspping_print(register const u_char *pptr, register u_int len) { (const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr; tlv_ptr.lspping_tlv_downstream_map_ipv6= \ (const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr; - printf("\n\t MTU: %u, Address-Type: %s (%u)", + ND_PRINT((ndo, "\n\t MTU: %u, Address-Type: %s (%u)", EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->mtu), tok2str(lspping_tlv_downstream_addr_values, "unknown", tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type), - tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type); + tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type)); switch(tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type) { case LSPPING_AFI_IPV4: - printf("\n\t Downstream IP: %s" \ + ND_PRINT((ndo, "\n\t Downstream IP: %s" \ "\n\t Downstream Interface IP: %s", ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip), - ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)); + ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface))); tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t); tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t); break; #ifdef INET6 case LSPPING_AFI_IPV6: - printf("\n\t Downstream IP: %s" \ + ND_PRINT((ndo, "\n\t Downstream IP: %s" \ "\n\t Downstream Interface IP: %s", ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip), - ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface)); + ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface))); tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t); tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t); break; #endif case LSPPING_AFI_UNMB: - printf("\n\t Downstream IP: %s" \ + ND_PRINT((ndo, "\n\t Downstream IP: %s" \ "\n\t Downstream Interface Index: 0x%08x", ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip), - EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)); + EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface))); tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t); tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t); break; @@ -839,21 +837,21 @@ lspping_print(register const u_char *pptr, register u_int len) { case LSPPING_TLV_BFD_DISCRIMINATOR: tptr += sizeof(struct lspping_tlv_header); - if (!TTEST2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN)) + if (!ND_TTEST2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN)) goto trunc; - printf("\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr)); + ND_PRINT((ndo, "\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr))); break; case LSPPING_TLV_VENDOR_ENTERPRISE: { u_int32_t vendor_id; - if (!TTEST2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN)) + if (!ND_TTEST2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN)) goto trunc; vendor_id = EXTRACT_32BITS(tlv_tptr); - printf("\n\t Vendor: %s (0x%04x)", + ND_PRINT((ndo, "\n\t Vendor: %s (0x%04x)", tok2str(smi_values, "Unknown", vendor_id), - vendor_id); + vendor_id)); } break; @@ -866,13 +864,13 @@ lspping_print(register const u_char *pptr, register u_int len) { case LSPPING_TLV_VENDOR_PRIVATE: default: - if (vflag <= 1) - print_unknown_data(gndo,tlv_tptr,"\n\t ",tlv_tlen); + if (ndo->ndo_vflag <= 1) + print_unknown_data(ndo, tlv_tptr, "\n\t ", tlv_tlen); break; } /* do we want to see an additionally tlv hexdump ? */ - if (vflag > 1 || tlv_hexdump==TRUE) - print_unknown_data(gndo,tptr+sizeof(struct lspping_tlv_header),"\n\t ", + if (ndo->ndo_vflag > 1 || tlv_hexdump==TRUE) + print_unknown_data(ndo, tptr+sizeof(struct lspping_tlv_header), "\n\t ", lspping_tlv_len); @@ -886,7 +884,7 @@ lspping_print(register const u_char *pptr, register u_int len) { } return; trunc: - printf("\n\t\t packet exceeded snapshot"); + ND_PRINT((ndo, "\n\t\t packet exceeded snapshot")); } /* * Local Variables: diff --git a/print-olsr.c b/print-olsr.c index 6b4e2ac7..3073a8a8 100644 --- a/print-olsr.c +++ b/print-olsr.c @@ -19,19 +19,16 @@ * IPv6 additions by Florian Forster */ +#define NETDISSECT_REWORKED #ifdef HAVE_CONFIG_H #include "config.h" #endif #include -#include -#include - #include "interface.h" #include "addrtoname.h" #include "extract.h" -#include "ip.h" /* * RFC 3626 common header @@ -182,7 +179,8 @@ struct olsr_lq_neighbor6 { * print a neighbor list with LQ extensions. */ static void -olsr_print_lq_neighbor4 (const u_char *msg_data, u_int hello_len) +olsr_print_lq_neighbor4(netdissect_options *ndo, + const u_char *msg_data, u_int hello_len) { struct olsr_lq_neighbor4 *lq_neighbor; @@ -190,11 +188,11 @@ olsr_print_lq_neighbor4 (const u_char *msg_data, u_int hello_len) lq_neighbor = (struct olsr_lq_neighbor4 *)msg_data; - printf("\n\t neighbor %s, link-quality %.2lf%%" + ND_PRINT((ndo, "\n\t neighbor %s, link-quality %.2lf%%" ", neighbor-link-quality %.2lf%%", ipaddr_string(lq_neighbor->neighbor), ((double)lq_neighbor->link_quality/2.55), - ((double)lq_neighbor->neighbor_link_quality/2.55)); + ((double)lq_neighbor->neighbor_link_quality/2.55))); msg_data += sizeof(struct olsr_lq_neighbor4); hello_len -= sizeof(struct olsr_lq_neighbor4); @@ -203,7 +201,8 @@ olsr_print_lq_neighbor4 (const u_char *msg_data, u_int hello_len) #if INET6 static void -olsr_print_lq_neighbor6 (const u_char *msg_data, u_int hello_len) +olsr_print_lq_neighbor6(netdissect_options *ndo, + const u_char *msg_data, u_int hello_len) { struct olsr_lq_neighbor6 *lq_neighbor; @@ -211,11 +210,11 @@ olsr_print_lq_neighbor6 (const u_char *msg_data, u_int hello_len) lq_neighbor = (struct olsr_lq_neighbor6 *)msg_data; - printf("\n\t neighbor %s, link-quality %.2lf%%" + ND_PRINT((ndo, "\n\t neighbor %s, link-quality %.2lf%%" ", neighbor-link-quality %.2lf%%", ip6addr_string(lq_neighbor->neighbor), ((double)lq_neighbor->link_quality/2.55), - ((double)lq_neighbor->neighbor_link_quality/2.55)); + ((double)lq_neighbor->neighbor_link_quality/2.55))); msg_data += sizeof(struct olsr_lq_neighbor6); hello_len -= sizeof(struct olsr_lq_neighbor6); @@ -227,19 +226,20 @@ olsr_print_lq_neighbor6 (const u_char *msg_data, u_int hello_len) * print a neighbor list. */ static void -olsr_print_neighbor (const u_char *msg_data, u_int hello_len) +olsr_print_neighbor(netdissect_options *ndo, + const u_char *msg_data, u_int hello_len) { int neighbor; - printf("\n\t neighbor\n\t\t"); + ND_PRINT((ndo, "\n\t neighbor\n\t\t")); neighbor = 1; while (hello_len >= sizeof(struct in_addr)) { /* print 4 neighbors per line */ - printf("%s%s", ipaddr_string(msg_data), - neighbor % 4 == 0 ? "\n\t\t" : " "); + ND_PRINT((ndo, "%s%s", ipaddr_string(msg_data), + neighbor % 4 == 0 ? "\n\t\t" : " ")); msg_data += sizeof(struct in_addr); hello_len -= sizeof(struct in_addr); @@ -248,7 +248,8 @@ olsr_print_neighbor (const u_char *msg_data, u_int hello_len) void -olsr_print (const u_char *pptr, u_int length, int is_ipv6) +olsr_print(netdissect_options *ndo, + const u_char *pptr, u_int length, int is_ipv6) { union { const struct olsr_common *common; @@ -272,24 +273,24 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) goto trunc; } - if (!TTEST2(*tptr, sizeof(struct olsr_common))) { + if (!ND_TTEST2(*tptr, sizeof(struct olsr_common))) { goto trunc; } ptr.common = (struct olsr_common *)tptr; length = min(length, EXTRACT_16BITS(ptr.common->packet_len)); - printf("OLSRv%i, seq 0x%04x, length %u", + ND_PRINT((ndo, "OLSRv%i, seq 0x%04x, length %u", (is_ipv6 == 0) ? 4 : 6, EXTRACT_16BITS(ptr.common->packet_seq), - length); + length)); tptr += sizeof(struct olsr_common); /* * In non-verbose mode, just print version. */ - if (vflag < 1) { + if (ndo->ndo_vflag < 1) { return; } @@ -301,7 +302,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) } msgptr; int msg_len_valid = 0; - if (!TTEST2(*tptr, sizeof(struct olsr_msg4))) + if (!ND_TTEST2(*tptr, sizeof(struct olsr_msg4))) goto trunc; #if INET6 @@ -319,7 +320,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) return; } - printf("\n\t%s Message (%#04x), originator %s, ttl %u, hop %u" + ND_PRINT((ndo, "\n\t%s Message (%#04x), originator %s, ttl %u, hop %u" "\n\t vtime %.3lfs, msg-seq 0x%04x, length %u%s", tok2str(olsr_msg_values, "Unknown", msg_type), msg_type, ip6addr_string(msgptr.v6->originator), @@ -327,7 +328,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) msgptr.v6->hopcount, ME_TO_DOUBLE(msgptr.v6->vtime), EXTRACT_16BITS(msgptr.v6->msg_seq), - msg_len, (msg_len_valid == 0) ? " (invalid)" : ""); + msg_len, (msg_len_valid == 0) ? " (invalid)" : "")); msg_tlen = msg_len - sizeof(struct olsr_msg6); msg_data = tptr + sizeof(struct olsr_msg6); @@ -347,7 +348,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) return; } - printf("\n\t%s Message (%#04x), originator %s, ttl %u, hop %u" + ND_PRINT((ndo, "\n\t%s Message (%#04x), originator %s, ttl %u, hop %u" "\n\t vtime %.3lfs, msg-seq 0x%04x, length %u%s", tok2str(olsr_msg_values, "Unknown", msg_type), msg_type, ipaddr_string(msgptr.v4->originator), @@ -355,7 +356,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) msgptr.v4->hopcount, ME_TO_DOUBLE(msgptr.v4->vtime), EXTRACT_16BITS(msgptr.v4->msg_seq), - msg_len, (msg_len_valid == 0) ? " (invalid)" : ""); + msg_len, (msg_len_valid == 0) ? " (invalid)" : "")); msg_tlen = msg_len - sizeof(struct olsr_msg4); msg_data = tptr + sizeof(struct olsr_msg4); @@ -364,12 +365,12 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) switch (msg_type) { case OLSR_HELLO_MSG: case OLSR_HELLO_LQ_MSG: - if (!TTEST2(*msg_data, sizeof(struct olsr_hello))) + if (!ND_TTEST2(*msg_data, sizeof(struct olsr_hello))) goto trunc; ptr.hello = (struct olsr_hello *)msg_data; - printf("\n\t hello-time %.3lfs, MPR willingness %u", - ME_TO_DOUBLE(ptr.hello->htime), ptr.hello->will); + ND_PRINT((ndo, "\n\t hello-time %.3lfs, MPR willingness %u", + ME_TO_DOUBLE(ptr.hello->htime), ptr.hello->will)); msg_data += sizeof(struct olsr_hello); msg_tlen -= sizeof(struct olsr_hello); @@ -379,7 +380,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) /* * link-type. */ - if (!TTEST2(*msg_data, sizeof(struct olsr_hello_link))) + if (!ND_TTEST2(*msg_data, sizeof(struct olsr_hello_link))) goto trunc; ptr.hello_link = (struct olsr_hello_link *)msg_data; @@ -392,11 +393,11 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) && (hello_len >= sizeof(struct olsr_hello_link))) hello_len_valid = 1; - printf("\n\t link-type %s, neighbor-type %s, len %u%s", + ND_PRINT((ndo, "\n\t link-type %s, neighbor-type %s, len %u%s", tok2str(olsr_link_type_values, "Unknown", link_type), tok2str(olsr_neighbor_type_values, "Unknown", neighbor_type), hello_len, - (hello_len_valid == 0) ? " (invalid)" : ""); + (hello_len_valid == 0) ? " (invalid)" : "")); if (hello_len_valid == 0) break; @@ -406,14 +407,14 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) hello_len -= sizeof(struct olsr_hello_link); if (msg_type == OLSR_HELLO_MSG) { - olsr_print_neighbor(msg_data, hello_len); + olsr_print_neighbor(ndo, msg_data, hello_len); } else { #if INET6 if (is_ipv6) - olsr_print_lq_neighbor6(msg_data, hello_len); + olsr_print_lq_neighbor6(ndo, msg_data, hello_len); else #endif - olsr_print_lq_neighbor4(msg_data, hello_len); + olsr_print_lq_neighbor4(ndo, msg_data, hello_len); } msg_data += hello_len; @@ -423,24 +424,24 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) case OLSR_TC_MSG: case OLSR_TC_LQ_MSG: - if (!TTEST2(*msg_data, sizeof(struct olsr_tc))) + if (!ND_TTEST2(*msg_data, sizeof(struct olsr_tc))) goto trunc; ptr.tc = (struct olsr_tc *)msg_data; - printf("\n\t advertised neighbor seq 0x%04x", - EXTRACT_16BITS(ptr.tc->ans_seq)); + ND_PRINT((ndo, "\n\t advertised neighbor seq 0x%04x", + EXTRACT_16BITS(ptr.tc->ans_seq))); msg_data += sizeof(struct olsr_tc); msg_tlen -= sizeof(struct olsr_tc); if (msg_type == OLSR_TC_MSG) { - olsr_print_neighbor(msg_data, msg_tlen); + olsr_print_neighbor(ndo, msg_data, msg_tlen); } else { #if INET6 if (is_ipv6) - olsr_print_lq_neighbor6(msg_data, msg_tlen); + olsr_print_lq_neighbor6(ndo, msg_data, msg_tlen); else #endif - olsr_print_lq_neighbor4(msg_data, msg_tlen); + olsr_print_lq_neighbor4(ndo, msg_data, msg_tlen); } break; @@ -454,14 +455,14 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) #endif while (msg_tlen >= addr_size) { - if (!TTEST2(*msg_data, addr_size)) + if (!ND_TTEST2(*msg_data, addr_size)) goto trunc; - printf("\n\t interface address %s", + ND_PRINT((ndo, "\n\t interface address %s", #if INET6 is_ipv6 ? ip6addr_string(msg_data) : #endif - ipaddr_string(msg_data)); + ipaddr_string(msg_data))); msg_data += addr_size; msg_tlen -= addr_size; } @@ -469,8 +470,8 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) } case OLSR_HNA_MSG: - printf("\n\t Advertised networks (total %u)", - (unsigned int) (msg_tlen / sizeof(struct olsr_hna6))); + ND_PRINT((ndo, "\n\t Advertised networks (total %u)", + (unsigned int) (msg_tlen / sizeof(struct olsr_hna6)))); #if INET6 if (is_ipv6) { @@ -478,14 +479,14 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) while (msg_tlen >= sizeof(struct olsr_hna6)) { struct olsr_hna6 *hna6; - if (!TTEST2(*msg_data, sizeof(struct olsr_hna6))) + if (!ND_TTEST2(*msg_data, sizeof(struct olsr_hna6))) goto trunc; hna6 = (struct olsr_hna6 *)msg_data; - printf("\n\t #%i: %s/%u", + ND_PRINT((ndo, "\n\t #%i: %s/%u", i, ip6addr_string(hna6->network), - mask62plen (hna6->mask)); + mask62plen (hna6->mask))); msg_data += sizeof(struct olsr_hna6); msg_tlen -= sizeof(struct olsr_hna6); @@ -496,7 +497,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) { int col = 0; while (msg_tlen >= sizeof(struct olsr_hna4)) { - if (!TTEST2(*msg_data, sizeof(struct olsr_hna4))) + if (!ND_TTEST2(*msg_data, sizeof(struct olsr_hna4))) goto trunc; ptr.hna = (struct olsr_hna4 *)msg_data; @@ -507,9 +508,9 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) else printf (", "); - printf("%s/%u", + ND_PRINT((ndo, "%s/%u", ipaddr_string(ptr.hna->network), - mask2plen(EXTRACT_32BITS(ptr.hna->mask))); + mask2plen(EXTRACT_32BITS(ptr.hna->mask)))); msg_data += sizeof(struct olsr_hna4); msg_tlen -= sizeof(struct olsr_hna4); @@ -535,12 +536,12 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) if (msg_tlen < 4) goto trunc; - if (!TTEST2(*msg_data, 4)) + if (!ND_TTEST2(*msg_data, 4)) goto trunc; - printf("\n\t Version %u, Entries %u%s", + ND_PRINT((ndo, "\n\t Version %u, Entries %u%s", EXTRACT_16BITS(msg_data), - name_entries, (name_entries_valid == 0) ? " (invalid)" : ""); + name_entries, (name_entries_valid == 0) ? " (invalid)" : "")); if (name_entries_valid == 0) break; @@ -553,7 +554,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) if (msg_tlen < 4) break; - if (!TTEST2(*msg_data, 4)) + if (!ND_TTEST2(*msg_data, 4)) goto trunc; name_entry_type = EXTRACT_16BITS(msg_data); @@ -565,9 +566,9 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) if ((name_entry_len > 0) && ((addr_size + name_entry_len) <= msg_tlen)) name_entry_len_valid = 1; - printf("\n\t #%u: type %#06x, length %u%s", + ND_PRINT((ndo, "\n\t #%u: type %#06x, length %u%s", (unsigned int) i, name_entry_type, - name_entry_len, (name_entry_len_valid == 0) ? " (invalid)" : ""); + name_entry_len, (name_entry_len_valid == 0) ? " (invalid)" : "")); if (name_entry_len_valid == 0) break; @@ -580,19 +581,19 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) if (msg_tlen < addr_size + name_entry_len + name_entry_padding) goto trunc; - if (!TTEST2(*msg_data, addr_size + name_entry_len + name_entry_padding)) + if (!ND_TTEST2(*msg_data, addr_size + name_entry_len + name_entry_padding)) goto trunc; #if INET6 if (is_ipv6) - printf(", address %s, name \"", - ip6addr_string(msg_data)); + ND_PRINT((ndo, ", address %s, name \"", + ip6addr_string(msg_data))); else #endif - printf(", address %s, name \"", - ipaddr_string(msg_data)); + ND_PRINT((ndo, ", address %s, name \"", + ipaddr_string(msg_data))); fn_printn(msg_data + addr_size, name_entry_len, NULL); - printf("\""); + ND_PRINT((ndo, "\"")); msg_data += addr_size + name_entry_len + name_entry_padding; msg_tlen -= addr_size + name_entry_len + name_entry_padding; @@ -606,7 +607,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) */ case OLSR_POWERINFO_MSG: default: - print_unknown_data(gndo,msg_data, "\n\t ", msg_tlen); + print_unknown_data(ndo, msg_data, "\n\t ", msg_tlen); break; } /* switch (msg_type) */ tptr += msg_len; @@ -615,7 +616,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6) return; trunc: - printf("[|olsr]"); + ND_PRINT((ndo, "[|olsr]")); } /* diff --git a/print-sctp.c b/print-sctp.c index a90359df..351a02c7 100644 --- a/print-sctp.c +++ b/print-sctp.c @@ -567,7 +567,7 @@ void sctp_print(netdissect_options *ndo, return; } - forces_print(payloadPtr, EXTRACT_16BITS(&chunkDescPtr->chunkLength)- chunksize); + forces_print(ndo, payloadPtr, EXTRACT_16BITS(&chunkDescPtr->chunkLength)- chunksize); } else if (ndo->ndo_vflag >= 2) { /* if verbose output is specified */ /* at the command line */ const u_char *payloadPtr; diff --git a/print-udp.c b/print-udp.c index 90a53c41..a5412a16 100644 --- a/print-udp.c +++ b/print-udp.c @@ -645,14 +645,14 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length, else if (ISPORT(LDP_PORT)) ldp_print(ndo, (const u_char *)(up + 1), length); else if (ISPORT(OLSR_PORT)) - olsr_print((const u_char *)(up + 1), length, + olsr_print(ndo, (const u_char *)(up + 1), length, #if INET6 (IP_V(ip) == 6) ? 1 : 0); #else 0); #endif else if (ISPORT(MPLS_LSP_PING_PORT)) - lspping_print((const u_char *)(up + 1), length); + lspping_print(ndo, (const u_char *)(up + 1), length); else if (dport == BFD_CONTROL_PORT || dport == BFD_ECHO_PORT ) bfd_print(ndo, (const u_char *)(up+1), length, dport);