This parameter will be needed at the next step.
/* Unpack a 64-bit unsigned integer. */
int
-cpack_uint64(struct cpack_state *cs, uint64_t *u)
+cpack_uint64(netdissect_options *ndo, struct cpack_state *cs, uint64_t *u)
{
const uint8_t *next;
/* Unpack a 64-bit signed integer. */
int
-cpack_int64(struct cpack_state *cs, int64_t *u)
+cpack_int64(netdissect_options *ndo, struct cpack_state *cs, int64_t *u)
{
const uint8_t *next;
/* Unpack a 32-bit unsigned integer. */
int
-cpack_uint32(struct cpack_state *cs, uint32_t *u)
+cpack_uint32(netdissect_options *ndo, struct cpack_state *cs, uint32_t *u)
{
const uint8_t *next;
/* Unpack a 32-bit signed integer. */
int
-cpack_int32(struct cpack_state *cs, int32_t *u)
+cpack_int32(netdissect_options *ndo, struct cpack_state *cs, int32_t *u)
{
const uint8_t *next;
/* Unpack a 16-bit unsigned integer. */
int
-cpack_uint16(struct cpack_state *cs, uint16_t *u)
+cpack_uint16(netdissect_options *ndo, struct cpack_state *cs, uint16_t *u)
{
const uint8_t *next;
/* Unpack a 16-bit signed integer. */
int
-cpack_int16(struct cpack_state *cs, int16_t *u)
+cpack_int16(netdissect_options *ndo, struct cpack_state *cs, int16_t *u)
{
const uint8_t *next;
/* Unpack an 8-bit unsigned integer. */
int
-cpack_uint8(struct cpack_state *cs, uint8_t *u)
+cpack_uint8(netdissect_options *ndo, struct cpack_state *cs, uint8_t *u)
{
/* No space left? */
if ((size_t)(cs->c_next - cs->c_buf) >= cs->c_len)
/* Unpack an 8-bit signed integer. */
int
-cpack_int8(struct cpack_state *cs, int8_t *u)
+cpack_int8(netdissect_options *ndo, struct cpack_state *cs, int8_t *u)
{
/* No space left? */
if ((size_t)(cs->c_next - cs->c_buf) >= cs->c_len)
#ifndef _CPACK_H
#define _CPACK_H
+#include "netdissect.h"
+
struct cpack_state {
const uint8_t *c_buf;
const uint8_t *c_next;
int cpack_init(struct cpack_state *, const uint8_t *, size_t);
-int cpack_uint8(struct cpack_state *, uint8_t *);
-int cpack_int8(struct cpack_state *, int8_t *);
-int cpack_uint16(struct cpack_state *, uint16_t *);
-int cpack_int16(struct cpack_state *, int16_t *);
-int cpack_uint32(struct cpack_state *, uint32_t *);
-int cpack_int32(struct cpack_state *, int32_t *);
-int cpack_uint64(struct cpack_state *, uint64_t *);
-int cpack_int64(struct cpack_state *, int64_t *);
+int cpack_uint8(netdissect_options *, struct cpack_state *, uint8_t *);
+int cpack_int8(netdissect_options *, struct cpack_state *, int8_t *);
+int cpack_uint16(netdissect_options *, struct cpack_state *, uint16_t *);
+int cpack_int16(netdissect_options *, struct cpack_state *, int16_t *);
+int cpack_uint32(netdissect_options *, struct cpack_state *, uint32_t *);
+int cpack_int32(netdissect_options *, struct cpack_state *, int32_t *);
+int cpack_uint64(netdissect_options *, struct cpack_state *, uint64_t *);
+int cpack_int64(netdissect_options *, struct cpack_state *, int64_t *);
const uint8_t *cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment);
const uint8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\
dev_eq(a.Fsid_dev, b.Fsid_dev))
-extern void Parse_fh(const unsigned char *, u_int, my_fsid *, uint32_t *, const char **, const char **, int);
+extern void Parse_fh(netdissect_options *, const unsigned char *, u_int, my_fsid *, uint32_t *, const char **, const char **, int);
#define FHT_HPUX9 11
#define FHT_BSD44 12
-static int is_UCX(const unsigned char *, u_int);
+static int is_UCX(netdissect_options *, const unsigned char *, u_int);
void
-Parse_fh(const unsigned char *fh, u_int len, my_fsid *fsidp,
- uint32_t *inop,
+Parse_fh(netdissect_options *ndo, const unsigned char *fh, u_int len,
+ my_fsid *fsidp, uint32_t *inop,
const char **osnamep, /* if non-NULL, return OS name here */
const char **fsnamep, /* if non-NULL, return server fs name here (for VMS) */
int ourself) /* true if file handle was generated on this host */
}
}
else {
- if (is_UCX(fhp, len)) {
+ if (is_UCX(ndo, fhp, len)) {
fhtype = FHT_VMSUCX;
}
else {
* (3) followed by string of nulls
*/
static int
-is_UCX(const unsigned char *fhp, u_int len)
+is_UCX(netdissect_options *ndo, const unsigned char *fhp, u_int len)
{
u_int i;
int seen_null = 0;
}
static int
-extract_mesh_header_length(const u_char *p)
+extract_mesh_header_length(netdissect_options *ndo, const u_char *p)
{
return (EXTRACT_U_1(p) &~ 3) ? 0 : 6*(1 + (EXTRACT_U_1(p) & 3));
}
nd_print_trunc(ndo);
return hdrlen;
}
- meshdrlen = extract_mesh_header_length(p+hdrlen);
+ meshdrlen = extract_mesh_header_length(ndo, p + hdrlen);
hdrlen += meshdrlen;
} else
meshdrlen = 0;
case IEEE80211_RADIOTAP_TSFT: {
uint64_t tsft;
- rc = cpack_uint64(s, &tsft);
+ rc = cpack_uint64(ndo, s, &tsft);
if (rc != 0)
goto trunc;
ND_PRINT("%" PRIu64 "us tsft ", tsft);
case IEEE80211_RADIOTAP_FLAGS: {
uint8_t flagsval;
- rc = cpack_uint8(s, &flagsval);
+ rc = cpack_uint8(ndo, s, &flagsval);
if (rc != 0)
goto trunc;
*flagsp = flagsval;
case IEEE80211_RADIOTAP_RATE: {
uint8_t rate;
- rc = cpack_uint8(s, &rate);
+ rc = cpack_uint8(ndo, s, &rate);
if (rc != 0)
goto trunc;
/*
uint16_t frequency;
uint16_t flags;
- rc = cpack_uint16(s, &frequency);
+ rc = cpack_uint16(ndo, s, &frequency);
if (rc != 0)
goto trunc;
- rc = cpack_uint16(s, &flags);
+ rc = cpack_uint16(ndo, s, &flags);
if (rc != 0)
goto trunc;
/*
uint8_t hopset;
uint8_t hoppat;
- rc = cpack_uint8(s, &hopset);
+ rc = cpack_uint8(ndo, s, &hopset);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(s, &hoppat);
+ rc = cpack_uint8(ndo, s, &hoppat);
if (rc != 0)
goto trunc;
ND_PRINT("fhset %u fhpat %u ", hopset, hoppat);
case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: {
int8_t dbm_antsignal;
- rc = cpack_int8(s, &dbm_antsignal);
+ rc = cpack_int8(ndo, s, &dbm_antsignal);
if (rc != 0)
goto trunc;
ND_PRINT("%ddBm signal ", dbm_antsignal);
case IEEE80211_RADIOTAP_DBM_ANTNOISE: {
int8_t dbm_antnoise;
- rc = cpack_int8(s, &dbm_antnoise);
+ rc = cpack_int8(ndo, s, &dbm_antnoise);
if (rc != 0)
goto trunc;
ND_PRINT("%ddBm noise ", dbm_antnoise);
case IEEE80211_RADIOTAP_LOCK_QUALITY: {
uint16_t lock_quality;
- rc = cpack_uint16(s, &lock_quality);
+ rc = cpack_uint16(ndo, s, &lock_quality);
if (rc != 0)
goto trunc;
ND_PRINT("%u sq ", lock_quality);
case IEEE80211_RADIOTAP_TX_ATTENUATION: {
int16_t tx_attenuation;
- rc = cpack_int16(s, &tx_attenuation);
+ rc = cpack_int16(ndo, s, &tx_attenuation);
if (rc != 0)
goto trunc;
ND_PRINT("%d tx power ", -tx_attenuation);
case IEEE80211_RADIOTAP_DB_TX_ATTENUATION: {
int8_t db_tx_attenuation;
- rc = cpack_int8(s, &db_tx_attenuation);
+ rc = cpack_int8(ndo, s, &db_tx_attenuation);
if (rc != 0)
goto trunc;
ND_PRINT("%ddB tx attenuation ", -db_tx_attenuation);
case IEEE80211_RADIOTAP_DBM_TX_POWER: {
int8_t dbm_tx_power;
- rc = cpack_int8(s, &dbm_tx_power);
+ rc = cpack_int8(ndo, s, &dbm_tx_power);
if (rc != 0)
goto trunc;
ND_PRINT("%ddBm tx power ", dbm_tx_power);
case IEEE80211_RADIOTAP_ANTENNA: {
uint8_t antenna;
- rc = cpack_uint8(s, &antenna);
+ rc = cpack_uint8(ndo, s, &antenna);
if (rc != 0)
goto trunc;
ND_PRINT("antenna %u ", antenna);
case IEEE80211_RADIOTAP_DB_ANTSIGNAL: {
uint8_t db_antsignal;
- rc = cpack_uint8(s, &db_antsignal);
+ rc = cpack_uint8(ndo, s, &db_antsignal);
if (rc != 0)
goto trunc;
ND_PRINT("%udB signal ", db_antsignal);
case IEEE80211_RADIOTAP_DB_ANTNOISE: {
uint8_t db_antnoise;
- rc = cpack_uint8(s, &db_antnoise);
+ rc = cpack_uint8(ndo, s, &db_antnoise);
if (rc != 0)
goto trunc;
ND_PRINT("%udB noise ", db_antnoise);
case IEEE80211_RADIOTAP_RX_FLAGS: {
uint16_t rx_flags;
- rc = cpack_uint16(s, &rx_flags);
+ rc = cpack_uint16(ndo, s, &rx_flags);
if (rc != 0)
goto trunc;
/* Do nothing for now */
uint8_t channel;
uint8_t maxpower;
- rc = cpack_uint32(s, &flags);
+ rc = cpack_uint32(ndo, s, &flags);
if (rc != 0)
goto trunc;
- rc = cpack_uint16(s, &frequency);
+ rc = cpack_uint16(ndo, s, &frequency);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(s, &channel);
+ rc = cpack_uint8(ndo, s, &channel);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(s, &maxpower);
+ rc = cpack_uint8(ndo, s, &maxpower);
if (rc != 0)
goto trunc;
print_chaninfo(ndo, frequency, flags, presentflags);
};
float htrate;
- rc = cpack_uint8(s, &known);
+ rc = cpack_uint8(ndo, s, &known);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(s, &flags);
+ rc = cpack_uint8(ndo, s, &flags);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(s, &mcs_index);
+ rc = cpack_uint8(ndo, s, &mcs_index);
if (rc != 0)
goto trunc;
if (known & IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN) {
uint8_t delim_crc;
uint8_t reserved;
- rc = cpack_uint32(s, &reference_num);
+ rc = cpack_uint32(ndo, s, &reference_num);
if (rc != 0)
goto trunc;
- rc = cpack_uint16(s, &flags);
+ rc = cpack_uint16(ndo, s, &flags);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(s, &delim_crc);
+ rc = cpack_uint8(ndo, s, &delim_crc);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(s, &reserved);
+ rc = cpack_uint8(ndo, s, &reserved);
if (rc != 0)
goto trunc;
/* Do nothing for now */
"unknown (31)"
};
- rc = cpack_uint16(s, &known);
+ rc = cpack_uint16(ndo, s, &known);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(s, &flags);
+ rc = cpack_uint8(ndo, s, &flags);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(s, &bandwidth);
+ rc = cpack_uint8(ndo, s, &bandwidth);
if (rc != 0)
goto trunc;
for (i = 0; i < 4; i++) {
- rc = cpack_uint8(s, &mcs_nss[i]);
+ rc = cpack_uint8(ndo, s, &mcs_nss[i]);
if (rc != 0)
goto trunc;
}
- rc = cpack_uint8(s, &coding);
+ rc = cpack_uint8(ndo, s, &coding);
if (rc != 0)
goto trunc;
- rc = cpack_uint8(s, &group_id);
+ rc = cpack_uint8(ndo, s, &group_id);
if (rc != 0)
goto trunc;
- rc = cpack_uint16(s, &partial_aid);
+ rc = cpack_uint16(ndo, s, &partial_aid);
if (rc != 0)
goto trunc;
for (i = 0; i < 4; i++) {
nd_print_trunc(ndo);
break;
}
- if (cpack_uint8(&cpacker, &vendor_oui[0]) != 0) {
+ if (cpack_uint8(ndo, &cpacker, &vendor_oui[0]) != 0) {
nd_print_trunc(ndo);
break;
}
- if (cpack_uint8(&cpacker, &vendor_oui[1]) != 0) {
+ if (cpack_uint8(ndo, &cpacker, &vendor_oui[1]) != 0) {
nd_print_trunc(ndo);
break;
}
- if (cpack_uint8(&cpacker, &vendor_oui[2]) != 0) {
+ if (cpack_uint8(ndo, &cpacker, &vendor_oui[2]) != 0) {
nd_print_trunc(ndo);
break;
}
- if (cpack_uint8(&cpacker, &vendor_subnamespace) != 0) {
+ if (cpack_uint8(ndo, &cpacker, &vendor_subnamespace) != 0) {
nd_print_trunc(ndo);
break;
}
- if (cpack_uint16(&cpacker, &skip_length) != 0) {
+ if (cpack_uint16(ndo, &cpacker, &skip_length) != 0) {
nd_print_trunc(ndo);
break;
}
#define ATMTPA(ap) (aar_tpa(ap))
static int
-isnonzero(const u_char *a, size_t len)
+isnonzero(netdissect_options *ndo, const u_char *a, size_t len)
{
while (len > 0) {
if (EXTRACT_U_1(a) != 0)
case ARPOP_REQUEST:
ND_PRINT("who-has ");
tpaddr_print_ip(ndo, ap, pro);
- if (isnonzero((const u_char *)THA(ap), HRD_LEN(ap)))
+ if (isnonzero(ndo, (const u_char *)THA(ap), HRD_LEN(ap)))
ND_PRINT(" (%s)",
linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)));
ND_PRINT(" tell ");
};
static const char *
-format_id(const u_char *id)
+format_id(netdissect_options *ndo, const u_char *id)
{
static char buf[25];
nd_snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
else {
ND_PRINT("\n\tRouter Id");
if(len < 10) goto invalid;
- ND_PRINT(" %s", format_id(message + 4));
+ ND_PRINT(" %s", format_id(ndo, message + 4));
}
}
break;
ND_PRINT("(%u hops) for %s seqno %u id %s",
EXTRACT_U_1(message + 6),
ae == 0 ? "invalid AE 0" : format_prefix(ndo, prefix, plen),
- seqno, format_id(message + 8));
+ seqno, format_id(ndo, message + 8));
}
}
break;
hopc, format_prefix(ndo, prefix, plen));
ND_PRINT("%s) seqno %u id %s",
format_prefix(ndo, src_prefix, src_plen),
- seqno, format_id(router_id));
+ seqno, format_id(ndo, router_id));
}
}
break;
static int cdp_print_addr(netdissect_options *, const u_char *, u_int);
static int cdp_print_prefixes(netdissect_options *, const u_char *, u_int);
-static unsigned int cdp_get_number(const u_char *, u_int);
+static unsigned int cdp_get_number(netdissect_options *, const u_char *, u_int);
void
cdp_print(netdissect_options *ndo,
ND_PRINT("app %u, vlan %u", EXTRACT_U_1(tptr), EXTRACT_BE_U_2(tptr + 1));
break;
case 0x10: /* Power - not documented */
- ND_PRINT("%1.2fW", cdp_get_number(tptr, len) / 1000.0);
+ ND_PRINT("%1.2fW", cdp_get_number(ndo, tptr, len) / 1000.0);
break;
case 0x11: /* MTU - not documented */
if (len < 4)
/* read in a <n>-byte number, MSB first
* (of course this can handle max sizeof(int))
*/
-static unsigned int cdp_get_number(const u_char * p, u_int l)
+static unsigned int
+cdp_get_number(netdissect_options *ndo, const u_char * p, u_int l)
{
unsigned int res=0;
while( l>0 )
};
static u_int
-dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
+dccp_csum_coverage(netdissect_options *ndo,
+ const struct dccp_hdr* dh, u_int len)
{
u_int cov;
const struct dccp_hdr *dh, u_int len)
{
return nextproto4_cksum(ndo, ip, (const uint8_t *)(const void *)dh, len,
- dccp_csum_coverage(dh, len), IPPROTO_DCCP);
+ dccp_csum_coverage(ndo, dh, len), IPPROTO_DCCP);
}
static uint16_t dccp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6,
const struct dccp_hdr *dh, u_int len)
{
return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)dh, len,
- dccp_csum_coverage(dh, len), IPPROTO_DCCP);
+ dccp_csum_coverage(ndo, dh, len), IPPROTO_DCCP);
}
static const char *dccp_reset_code(uint8_t code)
return dccp_reset_codes[code];
}
-static uint64_t dccp_seqno(const u_char *bp)
+static uint64_t
+dccp_seqno(netdissect_options *ndo, const u_char *bp)
{
const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
uint64_t seqno;
}
static unsigned int
-dccp_basic_hdr_len(const struct dccp_hdr *dh)
+dccp_basic_hdr_len(netdissect_options *ndo, const struct dccp_hdr *dh)
{
return DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : sizeof(struct dccp_hdr);
}
static void dccp_print_ack_no(netdissect_options *ndo, const u_char *bp)
{
const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
- const u_char *ackp = bp + dccp_basic_hdr_len(dh);
+ const u_char *ackp = bp + dccp_basic_hdr_len(ndo, dh);
uint64_t ackno;
if (DCCPH_X(dh) != 0) {
}
/* get the length of the generic header */
- fixed_hdrlen = dccp_basic_hdr_len(dh);
+ fixed_hdrlen = dccp_basic_hdr_len(ndo, dh);
if (len < fixed_hdrlen) {
ND_PRINT("truncated-dccp - %u bytes missing!",
fixed_hdrlen - len);
if (ndo->ndo_vflag < 2)
return;
- ND_PRINT("seq %" PRIu64, dccp_seqno(bp));
+ ND_PRINT("seq %" PRIu64, dccp_seqno(ndo, bp));
/* process options */
if (hlen > fixed_hdrlen){
}
static int
-ilv_valid(const struct forces_ilv *ilv, u_int rlen)
+ilv_valid(netdissect_options *ndo, const struct forces_ilv *ilv, u_int rlen)
{
if (rlen < ILV_HDRL)
return INVALID_RLEN;
char *ib = indent_pr(indent, 1);
const u_char *tdp = (const u_char *) ILV_DATA(ilv);
ND_TCHECK_SIZE(ilv);
- invilv = ilv_valid(ilv, rlen);
+ invilv = ilv_valid(ndo, ilv, rlen);
if (invilv) {
ND_PRINT("%s[", ib + 1);
hex_print_with_offset(ndo, ib, tdp, rlen, 0);
ND_PRINT("\n%s METADATA length %u\n", ib, rlen);
while (rlen != 0) {
ND_TCHECK_SIZE(ilv);
- invilv = ilv_valid(ilv, rlen);
+ invilv = ilv_valid(ndo, ilv, rlen);
if (invilv) {
break;
}
}
static const char *
-format_nid(const u_char *data)
+format_nid(netdissect_options *ndo, const u_char *data)
{
static char buf[4][sizeof("01:01:01:01")];
static int i = 0;
}
static const char *
-format_256(const u_char *data)
+format_256(netdissect_options *ndo, const u_char *data)
{
static char buf[4][sizeof("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")];
static int i = 0;
nd_print_invalid(ndo);
break;
}
- node_identifier = format_nid(value);
+ node_identifier = format_nid(ndo, value);
ND_PRINT(" NID: %s", node_identifier);
}
break;
nd_print_invalid(ndo);
break;
}
- node_identifier = format_nid(value);
+ node_identifier = format_nid(ndo, value);
endpoint_identifier = EXTRACT_BE_U_4(value + 4);
ND_PRINT(" NID: %s EPID: %08x",
node_identifier,
nd_print_invalid(ndo);
break;
}
- node_identifier = format_nid(value);
+ node_identifier = format_nid(ndo, value);
sequence_number = EXTRACT_BE_U_4(value + 4);
interval = format_interval(EXTRACT_BE_U_4(value + 8));
hash = EXTRACT_BE_U_8(value + 12);
nd_print_invalid(ndo);
break;
}
- peer_node_identifier = format_nid(value);
+ peer_node_identifier = format_nid(ndo, value);
peer_endpoint_identifier = EXTRACT_BE_U_4(value + 4);
endpoint_identifier = EXTRACT_BE_U_4(value + 8);
ND_PRINT(" Peer-NID: %s Peer-EPID: %08x Local-EPID: %08x",
}
ND_PRINT(" Verdict: %u Fingerprint: %s Common Name: ",
EXTRACT_U_1(value),
- format_256(value + 4));
+ format_256(ndo, value + 4));
(void)nd_printzp(ndo, value + 36, bodylen - 36, NULL);
}
break;
nd_print_invalid(ndo);
break;
}
- ND_PRINT(" PSK: %s", format_256(value));
+ ND_PRINT(" PSK: %s", format_256(ndo, value));
hncp_print_rec(ndo, value + 32, bodylen - 32, indent+1);
}
break;
#define ipxSize 30
-static const char *ipxaddr_string(uint32_t, const u_char *);
+static const char *ipxaddr_string(netdissect_options *, uint32_t, const u_char *);
static void ipx_decode(netdissect_options *, const struct ipxHdr *, const u_char *, u_int);
static void ipx_sap_print(netdissect_options *, const u_char *, u_int);
static void ipx_rip_print(netdissect_options *, const u_char *, u_int);
ND_TCHECK_2(ipx->srcSkt);
ND_PRINT("%s.%04x > ",
- ipxaddr_string(EXTRACT_BE_U_4(ipx->srcNet), ipx->srcNode),
+ ipxaddr_string(ndo, EXTRACT_BE_U_4(ipx->srcNet), ipx->srcNode),
EXTRACT_BE_U_2(ipx->srcSkt));
ND_PRINT("%s.%04x: ",
- ipxaddr_string(EXTRACT_BE_U_4(ipx->dstNet), ipx->dstNode),
+ ipxaddr_string(ndo, EXTRACT_BE_U_4(ipx->dstNet), ipx->dstNode),
EXTRACT_BE_U_2(ipx->dstSkt));
/* take length from ipx header */
}
static const char *
-ipxaddr_string(uint32_t net, const u_char *node)
+ipxaddr_string(netdissect_options *ndo, uint32_t net, const u_char *node)
{
static char line[256];
if (length < 10)
goto trunc;
ND_PRINT(" addr %s",
- ipxaddr_string(EXTRACT_BE_U_4(ipx), ipx + 4));
+ ipxaddr_string(ndo, EXTRACT_BE_U_4(ipx), ipx + 4));
ipx += 10;
length -= 10;
/*
/* record initiator */
static void
-cookie_record(const cookie_t *in, const u_char *bp2)
+cookie_record(netdissect_options *ndo, const cookie_t *in, const u_char *bp2)
{
int i;
const struct ip *ip;
ninitiator = (ninitiator + 1) % MAXINITIATORS;
}
-#define cookie_isinitiator(x, y) cookie_sidecheck((x), (y), 1)
-#define cookie_isresponder(x, y) cookie_sidecheck((x), (y), 0)
+#define cookie_isinitiator(ndo, x, y) cookie_sidecheck(ndo, (x), (y), 1)
+#define cookie_isresponder(ndo, x, y) cookie_sidecheck(ndo, (x), (y), 0)
static int
-cookie_sidecheck(int i, const u_char *bp2, int initiator)
+cookie_sidecheck(netdissect_options *ndo, int i, const u_char *bp2, int initiator)
{
const struct ip *ip;
const struct ip6_hdr *ip6;
/* the first packet */
ND_PRINT(" I");
if (bp2)
- cookie_record(&base->i_ck, bp2);
+ cookie_record(ndo, &base->i_ck, bp2);
} else
ND_PRINT(" ?");
} else {
- if (bp2 && cookie_isinitiator(i, bp2))
+ if (bp2 && cookie_isinitiator(ndo, i, bp2))
ND_PRINT(" I");
- else if (bp2 && cookie_isresponder(i, bp2))
+ else if (bp2 && cookie_isresponder(ndo, i, bp2))
ND_PRINT(" R");
else
ND_PRINT(" ?");
/* shared routine for printing system, node and lsp-ids */
static char *
-isis_print_id(const uint8_t *cp, u_int id_len)
+isis_print_id(netdissect_options *ndo, const uint8_t *cp, u_int id_len)
{
u_int i;
static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
if (tlv_remaining < NODE_ID_LEN)
return(0);
- ND_PRINT("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN));
+ ND_PRINT("%sIS Neighbor: %s", ident, isis_print_id(ndo, tptr, NODE_ID_LEN));
tptr+=NODE_ID_LEN;
tlv_remaining-=NODE_ID_LEN;
goto trunc;
if (ndo->ndo_vflag == 0) {
ND_PRINT(", src-id %s",
- isis_print_id(header_iih_lan->source_id, SYSTEM_ID_LEN));
+ isis_print_id(ndo, header_iih_lan->source_id, SYSTEM_ID_LEN));
ND_PRINT(", lan-id %s, prio %u",
- isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
+ isis_print_id(ndo, header_iih_lan->lan_id,NODE_ID_LEN),
EXTRACT_U_1(header_iih_lan->priority));
ND_PRINT(", length %u", length);
return (1);
}
ND_PRINT("\n\t source-id: %s, holding time: %us, Flags: [%s]",
- isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
+ isis_print_id(ndo, header_iih_lan->source_id,SYSTEM_ID_LEN),
EXTRACT_BE_U_2(header_iih_lan->holding_time),
tok2str(isis_iih_circuit_type_values,
"unknown circuit type 0x%02x",
EXTRACT_U_1(header_iih_lan->circuit_type)));
ND_PRINT("\n\t lan-id: %s, Priority: %u, PDU length: %u",
- isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
+ isis_print_id(ndo, header_iih_lan->lan_id, NODE_ID_LEN),
EXTRACT_U_1(header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
pdu_len);
if (length < ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)
goto trunc;
if (ndo->ndo_vflag == 0) {
- ND_PRINT(", src-id %s", isis_print_id(header_iih_ptp->source_id, SYSTEM_ID_LEN));
+ ND_PRINT(", src-id %s", isis_print_id(ndo, header_iih_ptp->source_id, SYSTEM_ID_LEN));
ND_PRINT(", length %u", length);
return (1);
}
}
ND_PRINT("\n\t source-id: %s, holding time: %us, Flags: [%s]",
- isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN),
+ isis_print_id(ndo, header_iih_ptp->source_id,SYSTEM_ID_LEN),
EXTRACT_BE_U_2(header_iih_ptp->holding_time),
tok2str(isis_iih_circuit_type_values,
"unknown circuit type 0x%02x",
goto trunc;
if (ndo->ndo_vflag == 0) {
ND_PRINT(", lsp-id %s, seq 0x%08x, lifetime %5us",
- isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
+ isis_print_id(ndo, header_lsp->lsp_id, LSP_ID_LEN),
EXTRACT_BE_U_4(header_lsp->sequence_number),
EXTRACT_BE_U_2(header_lsp->remaining_lifetime));
ND_PRINT(", length %u", length);
}
ND_PRINT("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
- isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
+ isis_print_id(ndo, header_lsp->lsp_id, LSP_ID_LEN),
EXTRACT_BE_U_4(header_lsp->sequence_number),
EXTRACT_BE_U_2(header_lsp->remaining_lifetime),
EXTRACT_BE_U_2(header_lsp->checksum));
if (length < ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)
goto trunc;
if (ndo->ndo_vflag == 0) {
- ND_PRINT(", src-id %s", isis_print_id(header_csnp->source_id, NODE_ID_LEN));
+ ND_PRINT(", src-id %s", isis_print_id(ndo, header_csnp->source_id, NODE_ID_LEN));
ND_PRINT(", length %u", length);
return (1);
}
}
ND_PRINT("\n\t source-id: %s, PDU length: %u",
- isis_print_id(header_csnp->source_id, NODE_ID_LEN),
+ isis_print_id(ndo, header_csnp->source_id, NODE_ID_LEN),
pdu_len);
ND_PRINT("\n\t start lsp-id: %s",
- isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN));
+ isis_print_id(ndo, header_csnp->start_lsp_id, LSP_ID_LEN));
ND_PRINT("\n\t end lsp-id: %s",
- isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN));
+ isis_print_id(ndo, header_csnp->end_lsp_id, LSP_ID_LEN));
if (ndo->ndo_vflag > 1) {
if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_CSNP_HEADER_SIZE))
if (length < ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)
goto trunc;
if (ndo->ndo_vflag == 0) {
- ND_PRINT(", src-id %s", isis_print_id(header_psnp->source_id, NODE_ID_LEN));
+ ND_PRINT(", src-id %s", isis_print_id(ndo, header_psnp->source_id, NODE_ID_LEN));
ND_PRINT(", length %u", length);
return (1);
}
}
ND_PRINT("\n\t source-id: %s, PDU length: %u",
- isis_print_id(header_psnp->source_id, NODE_ID_LEN),
+ isis_print_id(ndo, header_psnp->source_id, NODE_ID_LEN),
pdu_len);
if (ndo->ndo_vflag > 1) {
case ISIS_TLV_ISNEIGH:
while (tlen >= MAC_ADDR_LEN) {
ND_TCHECK_LEN(tptr, MAC_ADDR_LEN);
- ND_PRINT("\n\t SNPA: %s", isis_print_id(tptr, MAC_ADDR_LEN));
+ ND_PRINT("\n\t SNPA: %s", isis_print_id(ndo, tptr, MAC_ADDR_LEN));
tlen -= MAC_ADDR_LEN;
tptr += MAC_ADDR_LEN;
}
ND_PRINT("\n\t LAN address length %u bytes ", lan_alen);
while (tlen >= lan_alen) {
ND_TCHECK_LEN(tptr, lan_alen);
- ND_PRINT("\n\t\tIS Neighbor: %s", isis_print_id(tptr, lan_alen));
+ ND_PRINT("\n\t\tIS Neighbor: %s", isis_print_id(ndo, tptr, lan_alen));
tlen -= lan_alen;
tptr +=lan_alen;
}
while (tlen >= sizeof(struct isis_tlv_is_reach)) {
ND_TCHECK_SIZE(tlv_is_reach);
ND_PRINT("\n\t IS Neighbor: %s",
- isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN));
+ isis_print_id(ndo, tlv_is_reach->neighbor_nodeid, NODE_ID_LEN));
isis_print_metric_block(ndo, &tlv_is_reach->isis_metric_block);
tlen -= sizeof(struct isis_tlv_is_reach);
tlv_is_reach++;
while (tlen >= sizeof(struct isis_tlv_es_reach)) {
ND_TCHECK_SIZE(tlv_es_reach);
ND_PRINT("\n\t ES Neighbor: %s",
- isis_print_id(tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN));
+ isis_print_id(ndo, tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN));
isis_print_metric_block(ndo, &tlv_es_reach->isis_metric_block);
tlen -= sizeof(struct isis_tlv_es_reach);
tlv_es_reach++;
if(tlen>=SYSTEM_ID_LEN) {
ND_TCHECK_LEN(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN);
ND_PRINT("\n\t Neighbor System-ID: %s",
- isis_print_id(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN));
+ isis_print_id(ndo, tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN));
tlen-=SYSTEM_ID_LEN;
}
if(tlen>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) {
if (tlen < NODE_ID_LEN)
break;
ND_TCHECK_LEN(tptr, NODE_ID_LEN);
- ND_PRINT("\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN));
+ ND_PRINT("\n\t IS Neighbor: %s", isis_print_id(ndo, tptr, NODE_ID_LEN));
tptr+=NODE_ID_LEN;
tlen-=NODE_ID_LEN;
while(tlen>=sizeof(struct isis_tlv_lsp)) {
ND_TCHECK_1(tlv_lsp->lsp_id + LSP_ID_LEN - 1);
ND_PRINT("\n\t lsp-id: %s",
- isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN));
+ isis_print_id(ndo, tlv_lsp->lsp_id, LSP_ID_LEN));
ND_TCHECK_4(tlv_lsp->sequence_number);
ND_PRINT(", seq: 0x%08x", EXTRACT_BE_U_4(tlv_lsp->sequence_number));
ND_TCHECK_2(tlv_lsp->remaining_lifetime);
if (tlv_len >= SYSTEM_ID_LEN + 1) {
ND_TCHECK_LEN(tptr, SYSTEM_ID_LEN + 1);
ND_PRINT("\n\t Purge Originator System-ID: %s",
- isis_print_id(tptr + 1, SYSTEM_ID_LEN));
+ isis_print_id(ndo, tptr + 1, SYSTEM_ID_LEN));
}
if (tlv_len == 2 * SYSTEM_ID_LEN + 1) {
ND_TCHECK_LEN(tptr, 2 * SYSTEM_ID_LEN + 1);
ND_PRINT("\n\t Received from System-ID: %s",
- isis_print_id(tptr + SYSTEM_ID_LEN + 1, SYSTEM_ID_LEN));
+ isis_print_id(ndo, tptr + SYSTEM_ID_LEN + 1, SYSTEM_ID_LEN));
}
break;
/* is there an additional sysid field present ?*/
if (tlen == SYSTEM_ID_LEN) {
ND_TCHECK_LEN(tptr, SYSTEM_ID_LEN);
- ND_PRINT(", for %s", isis_print_id(tptr,SYSTEM_ID_LEN));
+ ND_PRINT(", for %s", isis_print_id(ndo, tptr,SYSTEM_ID_LEN));
}
break;
case ISIS_TLV_PART_DIS:
while (tlen >= SYSTEM_ID_LEN) {
ND_TCHECK_LEN(tptr, SYSTEM_ID_LEN);
- ND_PRINT("\n\t %s", isis_print_id(tptr, SYSTEM_ID_LEN));
+ ND_PRINT("\n\t %s", isis_print_id(ndo, tptr, SYSTEM_ID_LEN));
tptr+=SYSTEM_ID_LEN;
tlen-=SYSTEM_ID_LEN;
}
}
static int
-juniper_read_tlv_value(const u_char *p, u_int tlv_type, u_int tlv_len)
+juniper_read_tlv_value(netdissect_options *ndo,
+ const u_char *p, u_int tlv_type, u_int tlv_len)
{
int tlv_value;
tlv_type,
tlv_len);
- tlv_value = juniper_read_tlv_value(tptr, tlv_type, tlv_len);
+ tlv_value = juniper_read_tlv_value(ndo, tptr, tlv_type, tlv_len);
switch (tlv_type) {
case JUNIPER_EXT_TLV_IFD_NAME:
/* FIXME */
* Extract 34bits of latitude/longitude coordinates.
*/
static uint64_t
-lldp_extract_latlon(const u_char *tptr)
+lldp_extract_latlon(netdissect_options *ndo, const u_char *tptr)
{
uint64_t latlon;
return hexdump;
}
ND_PRINT("\n\t Latitude resolution %u, latitude value %" PRIu64,
- (EXTRACT_U_1(tptr + 5) >> 2), lldp_extract_latlon(tptr + 5));
+ (EXTRACT_U_1(tptr + 5) >> 2), lldp_extract_latlon(ndo, tptr + 5));
ND_PRINT("\n\t Longitude resolution %u, longitude value %" PRIu64,
- (EXTRACT_U_1(tptr + 10) >> 2), lldp_extract_latlon(tptr + 10));
+ (EXTRACT_U_1(tptr + 10) >> 2), lldp_extract_latlon(ndo, tptr + 10));
ND_PRINT("\n\t Altitude type %s (%u)",
tok2str(lldp_tia_location_altitude_type_values, "unknown",EXTRACT_U_1(tptr + 15) >> 4),
(EXTRACT_U_1(tptr + 15) >> 4));
static void nfs_printfh(netdissect_options *, const uint32_t *, const u_int);
static int xid_map_enter(netdissect_options *, const struct sunrpc_msg *, const u_char *);
-static int xid_map_find(const struct sunrpc_msg *, const u_char *,
- uint32_t *, uint32_t *);
+static int xid_map_find(netdissect_options *, const struct sunrpc_msg *, const u_char *, uint32_t *, uint32_t *);
static void interp_reply(netdissect_options *, const struct sunrpc_msg *, uint32_t, uint32_t, int);
static const uint32_t *parse_post_op_attr(netdissect_options *, const uint32_t *, int);
case SUNRPC_MSG_ACCEPTED:
ND_PRINT("reply ok %u", length);
- if (xid_map_find(rp, bp2, &proc, &vers) >= 0)
+ if (xid_map_find(ndo, rp, bp2, &proc, &vers) >= 0)
interp_reply(ndo, rp, proc, vers, length);
break;
return;
}
- Parse_fh((const u_char *)dp, len, &fsid, &ino, NULL, &sfsname, 0);
+ Parse_fh(ndo, (const u_char *)dp, len, &fsid, &ino, NULL, &sfsname, 0);
if (sfsname) {
/* file system ID is ASCII, not numeric, for this server OS */
* version in vers return, or returns -1 on failure
*/
static int
-xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc,
- uint32_t *vers)
+xid_map_find(netdissect_options *ndo, const struct sunrpc_msg *rp,
+ const u_char *bp, uint32_t *proc, uint32_t *vers)
{
int i;
struct xid_map_entry *xmep;
static uint32_t rx_cache_next = 0;
static uint32_t rx_cache_hint = 0;
static void rx_cache_insert(netdissect_options *, const u_char *, const struct ip *, u_int);
-static int rx_cache_find(const struct rx_header *, const struct ip *,
- uint32_t, uint32_t *);
+static int rx_cache_find(netdissect_options *, const struct rx_header *,
+ const struct ip *, uint32_t, uint32_t *);
static void fs_print(netdissect_options *, const u_char *, u_int);
static void fs_reply_print(netdissect_options *, const u_char *, u_int, uint32_t);
EXTRACT_BE_U_4(rxh->seq) == 1) ||
type == RX_PACKET_TYPE_ABORT) &&
(flags & RX_CLIENT_INITIATED) == 0 &&
- rx_cache_find(rxh, (const struct ip *) bp2,
+ rx_cache_find(ndo, rxh, (const struct ip *) bp2,
sport, &opcode)) {
switch (sport) {
*/
static int
-rx_cache_find(const struct rx_header *rxh, const struct ip *ip, u_int sport,
- uint32_t *opcode)
+rx_cache_find(netdissect_options *ndo, const struct rx_header *rxh,
+ const struct ip *ip, u_int sport, uint32_t *opcode)
{
uint32_t i;
struct rx_cache_entry *rxent;
#define ND_TCHECK_BRIDGE_ID(p) ND_TCHECK_8(p)
static char *
-stp_print_bridge_id(const u_char *p)
+stp_print_bridge_id(netdissect_options *ndo, const u_char *p)
{
static char bridge_id_str[sizeof("pppp.aa:bb:cc:dd:ee:ff")];
ND_TCHECK_2(stp_bpdu->port_id);
ND_PRINT(", bridge-id %s.%04x, length %u",
- stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id),
+ stp_print_bridge_id(ndo, (const u_char *)&stp_bpdu->bridge_id),
EXTRACT_BE_U_2(stp_bpdu->port_id), length);
/* in non-verbose mode just print the bridge-id */
(float) EXTRACT_BE_U_2(stp_bpdu->forward_delay) / STP_TIME_BASE);
ND_PRINT("\n\troot-id %s, root-pathcost %u",
- stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
+ stp_print_bridge_id(ndo, (const u_char *)&stp_bpdu->root_id),
EXTRACT_BE_U_4(stp_bpdu->root_path_cost));
/* Port role is only valid for 802.1w */
ND_TCHECK_4(stp_bpdu->root_path_cost);
ND_PRINT("CIST root-id %s, CIST ext-pathcost %u",
- stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
+ stp_print_bridge_id(ndo, (const u_char *)&stp_bpdu->root_id),
EXTRACT_BE_U_4(stp_bpdu->root_path_cost));
ND_TCHECK_SIZE(&stp_bpdu->bridge_id);
ND_PRINT("\n\tCIST regional-root-id %s, ",
- stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id));
+ stp_print_bridge_id(ndo, (const u_char *)&stp_bpdu->bridge_id));
ND_TCHECK_2(stp_bpdu->port_id);
ND_PRINT("CIST port-id %04x,", EXTRACT_BE_U_2(stp_bpdu->port_id));
ND_TCHECK_BRIDGE_ID(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET);
ND_PRINT("\n\tCIST bridge-id %s, ",
- stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET));
+ stp_print_bridge_id(ndo, ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET));
ND_TCHECK_1(ptr + MST_BPDU_CIST_REMAIN_HOPS_OFFSET);
ND_PRINT("CIST remaining-hops %u", EXTRACT_U_1(ptr + MST_BPDU_CIST_REMAIN_HOPS_OFFSET));
tok2str(rstp_obj_port_role_values, "Unknown",
RSTP_EXTRACT_PORT_ROLE(EXTRACT_U_1(ptr + offset))));
ND_PRINT("\n\t\tMSTI regional-root-id %s, pathcost %u",
- stp_print_bridge_id(ptr + offset +
+ stp_print_bridge_id(ndo, ptr + offset +
MST_BPDU_MSTI_ROOT_PRIO_OFFSET),
EXTRACT_BE_U_4(ptr + offset + MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET));
ND_PRINT("\n\t\tMSTI bridge-prio %u, port-prio %u, hops %u",
* in network byte order
*/
static time_t
-make_unix_date(const u_char *date_ptr)
+make_unix_date(netdissect_options *ndo, const u_char *date_ptr)
{
uint32_t dos_date = 0;
* in halfword-swapped network byte order!
*/
static time_t
-make_unix_date2(const u_char *date_ptr)
+make_unix_date2(netdissect_options *ndo, const u_char *date_ptr)
{
uint32_t x, x2;
* It's originally in "100ns units since jan 1st 1601"
*/
static time_t
-interpret_long_date(const u_char *p)
+interpret_long_date(netdissect_options *ndo, const u_char *p)
{
double d;
time_t ret;
if (x == 0 || x == 0xFFFFFFFF)
t = 0;
else
- t = make_unix_date(buf);
+ t = make_unix_date(ndo, buf);
buf += 4;
break;
case 2:
if (x == 0 || x == 0xFFFFFFFF)
t = 0;
else
- t = make_unix_date2(buf);
+ t = make_unix_date2(ndo, buf);
buf += 4;
break;
case 3:
ND_TCHECK_8(buf);
- t = interpret_long_date(buf);
+ t = interpret_long_date(ndo, buf);
buf += 8;
break;
default: