summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/print-pgm.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2015-01-07 19:55:18 +0000
committerdelphij <delphij@FreeBSD.org>2015-01-07 19:55:18 +0000
commitf49c5d523af9076a4a59e8dd664f9a897108432e (patch)
treee268839e08c106e178b33bd461d8d0a9c6fb5ad9 /contrib/tcpdump/print-pgm.c
parentc371846049d370ab78d943e60e789cdffe0aad3d (diff)
parent08263d19579d35a7a65e0c8bcb768504ce76d04e (diff)
downloadFreeBSD-src-f49c5d523af9076a4a59e8dd664f9a897108432e.zip
FreeBSD-src-f49c5d523af9076a4a59e8dd664f9a897108432e.tar.gz
MFV r276761: tcpdump 4.6.2.
MFC after: 1 month
Diffstat (limited to 'contrib/tcpdump/print-pgm.c')
-rw-r--r--contrib/tcpdump/print-pgm.c469
1 files changed, 221 insertions, 248 deletions
diff --git a/contrib/tcpdump/print-pgm.c b/contrib/tcpdump/print-pgm.c
index 2d4d744..6a83425 100644
--- a/contrib/tcpdump/print-pgm.c
+++ b/contrib/tcpdump/print-pgm.c
@@ -13,21 +13,13 @@
* Original code by Andy Heffernan (ahh@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pgm.c,v 1.5 2005-06-07 22:05:58 guy Exp $";
-#endif
-
+#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tcpdump-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
@@ -37,67 +29,68 @@ static const char rcsid[] _U_ =
#include "ip6.h"
#endif
#include "ipproto.h"
+#include "af.h"
/*
* PGM header (RFC 3208)
*/
struct pgm_header {
- u_int16_t pgm_sport;
- u_int16_t pgm_dport;
- u_int8_t pgm_type;
- u_int8_t pgm_options;
- u_int16_t pgm_sum;
- u_int8_t pgm_gsid[6];
- u_int16_t pgm_length;
+ uint16_t pgm_sport;
+ uint16_t pgm_dport;
+ uint8_t pgm_type;
+ uint8_t pgm_options;
+ uint16_t pgm_sum;
+ uint8_t pgm_gsid[6];
+ uint16_t pgm_length;
};
struct pgm_spm {
- u_int32_t pgms_seq;
- u_int32_t pgms_trailseq;
- u_int32_t pgms_leadseq;
- u_int16_t pgms_nla_afi;
- u_int16_t pgms_reserved;
- /* ... u_int8_t pgms_nla[0]; */
+ uint32_t pgms_seq;
+ uint32_t pgms_trailseq;
+ uint32_t pgms_leadseq;
+ uint16_t pgms_nla_afi;
+ uint16_t pgms_reserved;
+ /* ... uint8_t pgms_nla[0]; */
/* ... options */
};
struct pgm_nak {
- u_int32_t pgmn_seq;
- u_int16_t pgmn_source_afi;
- u_int16_t pgmn_reserved;
- /* ... u_int8_t pgmn_source[0]; */
- /* ... u_int16_t pgmn_group_afi */
- /* ... u_int16_t pgmn_reserved2; */
- /* ... u_int8_t pgmn_group[0]; */
+ uint32_t pgmn_seq;
+ uint16_t pgmn_source_afi;
+ uint16_t pgmn_reserved;
+ /* ... uint8_t pgmn_source[0]; */
+ /* ... uint16_t pgmn_group_afi */
+ /* ... uint16_t pgmn_reserved2; */
+ /* ... uint8_t pgmn_group[0]; */
/* ... options */
};
struct pgm_ack {
- u_int32_t pgma_rx_max_seq;
- u_int32_t pgma_bitmap;
+ uint32_t pgma_rx_max_seq;
+ uint32_t pgma_bitmap;
/* ... options */
};
struct pgm_poll {
- u_int32_t pgmp_seq;
- u_int16_t pgmp_round;
- u_int16_t pgmp_reserved;
+ uint32_t pgmp_seq;
+ uint16_t pgmp_round;
+ uint16_t pgmp_reserved;
/* ... options */
};
struct pgm_polr {
- u_int32_t pgmp_seq;
- u_int16_t pgmp_round;
- u_int16_t pgmp_subtype;
- u_int16_t pgmp_nla_afi;
- u_int16_t pgmp_reserved;
- /* ... u_int8_t pgmp_nla[0]; */
+ uint32_t pgmp_seq;
+ uint16_t pgmp_round;
+ uint16_t pgmp_subtype;
+ uint16_t pgmp_nla_afi;
+ uint16_t pgmp_reserved;
+ /* ... uint8_t pgmp_nla[0]; */
/* ... options */
};
struct pgm_data {
- u_int32_t pgmd_seq;
- u_int32_t pgmd_trailseq;
+ uint32_t pgmd_seq;
+ uint32_t pgmd_trailseq;
/* ... options */
};
@@ -142,26 +135,22 @@ typedef enum _pgm_type {
#define PGM_OPT_PGMCC_DATA 0x12
#define PGM_OPT_PGMCC_FEEDBACK 0x13
-
+
#define PGM_OPT_MASK 0x7f
#define PGM_OPT_END 0x80 /* end of options marker */
#define PGM_MIN_OPT_LEN 4
-#ifndef AFI_IP
-#define AFI_IP 1
-#define AFI_IP6 2
-#endif
-
void
-pgm_print(register const u_char *bp, register u_int length,
- register const u_char *bp2)
+pgm_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int length,
+ register const u_char *bp2)
{
register const struct pgm_header *pgm;
register const struct ip *ip;
register char ch;
- u_int16_t sport, dport;
+ uint16_t sport, dport;
int addr_size;
const void *nla;
int nla_af;
@@ -171,8 +160,8 @@ pgm_print(register const u_char *bp, register u_int length,
#else
char nla_buf[INET_ADDRSTRLEN];
#endif
- u_int8_t opt_type, opt_len, flags1, flags2;
- u_int32_t seq, opts_len, len, offset;
+ uint8_t opt_type, opt_len;
+ uint32_t seq, opts_len, len, offset;
pgm = (struct pgm_header *)bp;
ip = (struct ip *)bp2;
@@ -183,24 +172,24 @@ pgm_print(register const u_char *bp, register u_int length,
ip6 = NULL;
#else /* INET6 */
if (IP_V(ip) == 6) {
- (void)printf("Can't handle IPv6");
+ ND_PRINT((ndo, "Can't handle IPv6"));
return;
}
#endif /* INET6 */
ch = '\0';
- if (!TTEST(pgm->pgm_dport)) {
+ if (!ND_TTEST(pgm->pgm_dport)) {
#ifdef INET6
if (ip6) {
- (void)printf("%s > %s: [|pgm]",
- ip6addr_string(&ip6->ip6_src),
- ip6addr_string(&ip6->ip6_dst));
+ ND_PRINT((ndo, "%s > %s: [|pgm]",
+ ip6addr_string(ndo, &ip6->ip6_src),
+ ip6addr_string(ndo, &ip6->ip6_dst)));
return;
} else
#endif /* INET6 */
{
- (void)printf("%s > %s: [|pgm]",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ ND_PRINT((ndo, "%s > %s: [|pgm]",
+ ipaddr_string(ndo, &ip->ip_src),
+ ipaddr_string(ndo, &ip->ip_dst)));
return;
}
}
@@ -211,61 +200,58 @@ pgm_print(register const u_char *bp, register u_int length,
#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_PGM) {
- (void)printf("%s.%s > %s.%s: ",
- ip6addr_string(&ip6->ip6_src),
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ip6addr_string(ndo, &ip6->ip6_src),
tcpport_string(sport),
- ip6addr_string(&ip6->ip6_dst),
- tcpport_string(dport));
+ ip6addr_string(ndo, &ip6->ip6_dst),
+ tcpport_string(dport)));
} else {
- (void)printf("%s > %s: ",
- tcpport_string(sport), tcpport_string(dport));
+ ND_PRINT((ndo, "%s > %s: ",
+ tcpport_string(sport), tcpport_string(dport)));
}
} else
#endif /*INET6*/
{
if (ip->ip_p == IPPROTO_PGM) {
- (void)printf("%s.%s > %s.%s: ",
- ipaddr_string(&ip->ip_src),
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ipaddr_string(ndo, &ip->ip_src),
tcpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- tcpport_string(dport));
+ ipaddr_string(ndo, &ip->ip_dst),
+ tcpport_string(dport)));
} else {
- (void)printf("%s > %s: ",
- tcpport_string(sport), tcpport_string(dport));
+ ND_PRINT((ndo, "%s > %s: ",
+ tcpport_string(sport), tcpport_string(dport)));
}
}
- TCHECK(*pgm);
+ ND_TCHECK(*pgm);
- (void)printf("PGM, length %u", pgm->pgm_length);
+ ND_PRINT((ndo, "PGM, length %u", EXTRACT_16BITS(&pgm->pgm_length)));
- if (!vflag)
+ if (!ndo->ndo_vflag)
return;
- if (length > pgm->pgm_length)
- length = pgm->pgm_length;
-
- (void)printf(" 0x%02x%02x%02x%02x%02x%02x ",
+ ND_PRINT((ndo, " 0x%02x%02x%02x%02x%02x%02x ",
pgm->pgm_gsid[0],
pgm->pgm_gsid[1],
pgm->pgm_gsid[2],
pgm->pgm_gsid[3],
pgm->pgm_gsid[4],
- pgm->pgm_gsid[5]);
+ pgm->pgm_gsid[5]));
switch (pgm->pgm_type) {
case PGM_SPM: {
struct pgm_spm *spm;
spm = (struct pgm_spm *)(pgm + 1);
- TCHECK(*spm);
+ ND_TCHECK(*spm);
switch (EXTRACT_16BITS(&spm->pgms_nla_afi)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
nla_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
nla_af = AF_INET6;
break;
@@ -275,16 +261,16 @@ pgm_print(register const u_char *bp, register u_int length,
break;
}
bp = (u_char *) (spm + 1);
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
nla = bp;
bp += addr_size;
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf("SPM seq %u trail %u lead %u nla %s",
+ ND_PRINT((ndo, "SPM seq %u trail %u lead %u nla %s",
EXTRACT_32BITS(&spm->pgms_seq),
EXTRACT_32BITS(&spm->pgms_trailseq),
EXTRACT_32BITS(&spm->pgms_leadseq),
- nla_buf);
+ nla_buf));
break;
}
@@ -292,27 +278,27 @@ pgm_print(register const u_char *bp, register u_int length,
struct pgm_poll *poll;
poll = (struct pgm_poll *)(pgm + 1);
- TCHECK(*poll);
- (void)printf("POLL seq %u round %u",
+ ND_TCHECK(*poll);
+ ND_PRINT((ndo, "POLL seq %u round %u",
EXTRACT_32BITS(&poll->pgmp_seq),
- EXTRACT_16BITS(&poll->pgmp_round));
+ EXTRACT_16BITS(&poll->pgmp_round)));
bp = (u_char *) (poll + 1);
break;
}
case PGM_POLR: {
struct pgm_polr *polr;
- u_int32_t ivl, rnd, mask;
+ uint32_t ivl, rnd, mask;
polr = (struct pgm_polr *)(pgm + 1);
- TCHECK(*polr);
+ ND_TCHECK(*polr);
switch (EXTRACT_16BITS(&polr->pgmp_nla_afi)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
nla_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
nla_af = AF_INET6;
break;
@@ -322,37 +308,37 @@ pgm_print(register const u_char *bp, register u_int length,
break;
}
bp = (u_char *) (polr + 1);
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
nla = bp;
bp += addr_size;
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- TCHECK2(*bp, sizeof(u_int32_t));
+ ND_TCHECK2(*bp, sizeof(uint32_t));
ivl = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
- TCHECK2(*bp, sizeof(u_int32_t));
+ ND_TCHECK2(*bp, sizeof(uint32_t));
rnd = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
- TCHECK2(*bp, sizeof(u_int32_t));
+ ND_TCHECK2(*bp, sizeof(uint32_t));
mask = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
- (void)printf("POLR seq %u round %u nla %s ivl %u rnd 0x%08x "
+ ND_PRINT((ndo, "POLR seq %u round %u nla %s ivl %u rnd 0x%08x "
"mask 0x%08x", EXTRACT_32BITS(&polr->pgmp_seq),
- EXTRACT_16BITS(&polr->pgmp_round), nla_buf, ivl, rnd, mask);
+ EXTRACT_16BITS(&polr->pgmp_round), nla_buf, ivl, rnd, mask));
break;
}
case PGM_ODATA: {
struct pgm_data *odata;
odata = (struct pgm_data *)(pgm + 1);
- TCHECK(*odata);
- (void)printf("ODATA trail %u seq %u",
+ ND_TCHECK(*odata);
+ ND_PRINT((ndo, "ODATA trail %u seq %u",
EXTRACT_32BITS(&odata->pgmd_trailseq),
- EXTRACT_32BITS(&odata->pgmd_seq));
+ EXTRACT_32BITS(&odata->pgmd_seq)));
bp = (u_char *) (odata + 1);
break;
}
@@ -361,10 +347,10 @@ pgm_print(register const u_char *bp, register u_int length,
struct pgm_data *rdata;
rdata = (struct pgm_data *)(pgm + 1);
- TCHECK(*rdata);
- (void)printf("RDATA trail %u seq %u",
+ ND_TCHECK(*rdata);
+ ND_PRINT((ndo, "RDATA trail %u seq %u",
EXTRACT_32BITS(&rdata->pgmd_trailseq),
- EXTRACT_32BITS(&rdata->pgmd_seq));
+ EXTRACT_32BITS(&rdata->pgmd_seq)));
bp = (u_char *) (rdata + 1);
break;
}
@@ -382,19 +368,19 @@ pgm_print(register const u_char *bp, register u_int length,
#endif
nak = (struct pgm_nak *)(pgm + 1);
- TCHECK(*nak);
+ ND_TCHECK(*nak);
/*
* Skip past the source, saving info along the way
* and stopping if we don't have enough.
*/
switch (EXTRACT_16BITS(&nak->pgmn_source_afi)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
source_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
source_af = AF_INET6;
break;
@@ -404,7 +390,7 @@ pgm_print(register const u_char *bp, register u_int length,
break;
}
bp = (u_char *) (nak + 1);
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
source = bp;
bp += addr_size;
@@ -413,12 +399,12 @@ pgm_print(register const u_char *bp, register u_int length,
* and stopping if we don't have enough.
*/
switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
group_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
group_af = AF_INET6;
break;
@@ -427,8 +413,8 @@ pgm_print(register const u_char *bp, register u_int length,
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
- TCHECK2(*bp, addr_size);
+ bp += (2 * sizeof(uint16_t));
+ ND_TCHECK2(*bp, addr_size);
group = bp;
bp += addr_size;
@@ -439,19 +425,19 @@ pgm_print(register const u_char *bp, register u_int length,
inet_ntop(group_af, group, group_buf, sizeof(group_buf));
switch (pgm->pgm_type) {
case PGM_NAK:
- (void)printf("NAK ");
+ ND_PRINT((ndo, "NAK "));
break;
case PGM_NULLNAK:
- (void)printf("NNAK ");
+ ND_PRINT((ndo, "NNAK "));
break;
case PGM_NCF:
- (void)printf("NCF ");
+ ND_PRINT((ndo, "NCF "));
break;
default:
break;
}
- (void)printf("(%s -> %s), seq %u",
- source_buf, group_buf, EXTRACT_32BITS(&nak->pgmn_seq));
+ ND_PRINT((ndo, "(%s -> %s), seq %u",
+ source_buf, group_buf, EXTRACT_32BITS(&nak->pgmn_seq)));
break;
}
@@ -459,31 +445,31 @@ pgm_print(register const u_char *bp, register u_int length,
struct pgm_ack *ack;
ack = (struct pgm_ack *)(pgm + 1);
- TCHECK(*ack);
- (void)printf("ACK seq %u",
- EXTRACT_32BITS(&ack->pgma_rx_max_seq));
+ ND_TCHECK(*ack);
+ ND_PRINT((ndo, "ACK seq %u",
+ EXTRACT_32BITS(&ack->pgma_rx_max_seq)));
bp = (u_char *) (ack + 1);
break;
}
case PGM_SPMR:
- (void)printf("SPMR");
+ ND_PRINT((ndo, "SPMR"));
break;
default:
- (void)printf("UNKNOWN type %0x02x", pgm->pgm_type);
+ ND_PRINT((ndo, "UNKNOWN type 0x%02x", pgm->pgm_type));
break;
}
- if (pgm->pgm_options & PGM_OPT_BIT_PRESENT) {
+ if (pgm->pgm_options & PGM_OPT_BIT_PRESENT) {
/*
* make sure there's enough for the first option header
*/
- if (!TTEST2(*bp, PGM_MIN_OPT_LEN)) {
- (void)printf("[|OPT]");
+ if (!ND_TTEST2(*bp, PGM_MIN_OPT_LEN)) {
+ ND_PRINT((ndo, "[|OPT]"));
return;
- }
+ }
/*
* That option header MUST be an OPT_LENGTH option
@@ -491,143 +477,137 @@ pgm_print(register const u_char *bp, register u_int length,
*/
opt_type = *bp++;
if ((opt_type & PGM_OPT_MASK) != PGM_OPT_LENGTH) {
- (void)printf("[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK);
+ ND_PRINT((ndo, "[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK));
return;
}
opt_len = *bp++;
if (opt_len != 4) {
- (void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != 4]", opt_len));
return;
}
opts_len = EXTRACT_16BITS(bp);
if (opts_len < 4) {
- (void)printf("[Bad total option length %u < 4]", opts_len);
+ ND_PRINT((ndo, "[Bad total option length %u < 4]", opts_len));
return;
}
- bp += sizeof(u_int16_t);
- (void)printf(" OPTS LEN %d", opts_len);
+ bp += sizeof(uint16_t);
+ ND_PRINT((ndo, " OPTS LEN %d", opts_len));
opts_len -= 4;
while (opts_len) {
if (opts_len < PGM_MIN_OPT_LEN) {
- (void)printf("[Total option length leaves no room for final option]");
+ ND_PRINT((ndo, "[Total option length leaves no room for final option]"));
return;
}
opt_type = *bp++;
opt_len = *bp++;
if (opt_len < PGM_MIN_OPT_LEN) {
- (void)printf("[Bad option, length %u < %u]", opt_len,
- PGM_MIN_OPT_LEN);
+ ND_PRINT((ndo, "[Bad option, length %u < %u]", opt_len,
+ PGM_MIN_OPT_LEN));
break;
}
if (opts_len < opt_len) {
- (void)printf("[Total option length leaves no room for final option]");
+ ND_PRINT((ndo, "[Total option length leaves no room for final option]"));
return;
}
- if (!TTEST2(*bp, opt_len - 2)) {
- (void)printf(" [|OPT]");
+ if (!ND_TTEST2(*bp, opt_len - 2)) {
+ ND_PRINT((ndo, " [|OPT]"));
return;
- }
+ }
switch (opt_type & PGM_OPT_MASK) {
case PGM_OPT_LENGTH:
if (opt_len != 4) {
- (void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != 4]", opt_len));
return;
}
- (void)printf(" OPTS LEN (extra?) %d", EXTRACT_16BITS(bp));
- bp += sizeof(u_int16_t);
+ ND_PRINT((ndo, " OPTS LEN (extra?) %d", EXTRACT_16BITS(bp)));
+ bp += sizeof(uint16_t);
opts_len -= 4;
break;
case PGM_OPT_FRAGMENT:
if (opt_len != 16) {
- (void)printf("[Bad OPT_FRAGMENT option, length %u != 16]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_FRAGMENT option, length %u != 16]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
len = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" FRAG seq %u off %u len %u", seq, offset, len);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " FRAG seq %u off %u len %u", seq, offset, len));
opts_len -= 16;
break;
case PGM_OPT_NAK_LIST:
- flags1 = *bp++;
- flags2 = *bp++;
- opt_len -= sizeof(u_int32_t); /* option header */
- (void)printf(" NAK LIST");
+ bp += 2;
+ opt_len -= sizeof(uint32_t); /* option header */
+ ND_PRINT((ndo, " NAK LIST"));
while (opt_len) {
- if (opt_len < sizeof(u_int32_t)) {
- (void)printf("[Option length not a multiple of 4]");
+ if (opt_len < sizeof(uint32_t)) {
+ ND_PRINT((ndo, "[Option length not a multiple of 4]"));
return;
}
- TCHECK2(*bp, sizeof(u_int32_t));
- (void)printf(" %u", EXTRACT_32BITS(bp));
- bp += sizeof(u_int32_t);
- opt_len -= sizeof(u_int32_t);
- opts_len -= sizeof(u_int32_t);
+ ND_TCHECK2(*bp, sizeof(uint32_t));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(bp)));
+ bp += sizeof(uint32_t);
+ opt_len -= sizeof(uint32_t);
+ opts_len -= sizeof(uint32_t);
}
break;
case PGM_OPT_JOIN:
if (opt_len != 8) {
- (void)printf("[Bad OPT_JOIN option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_JOIN option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" JOIN %u", seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " JOIN %u", seq));
opts_len -= 8;
break;
case PGM_OPT_NAK_BO_IVL:
if (opt_len != 12) {
- (void)printf("[Bad OPT_NAK_BO_IVL option, length %u != 12]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_NAK_BO_IVL option, length %u != 12]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" BACKOFF ivl %u ivlseq %u", offset, seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " BACKOFF ivl %u ivlseq %u", offset, seq));
opts_len -= 12;
break;
case PGM_OPT_NAK_BO_RNG:
if (opt_len != 12) {
- (void)printf("[Bad OPT_NAK_BO_RNG option, length %u != 12]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_NAK_BO_RNG option, length %u != 12]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" BACKOFF max %u min %u", offset, seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " BACKOFF max %u min %u", offset, seq));
opts_len -= 12;
break;
case PGM_OPT_REDIRECT:
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
nla_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
nla_af = AF_INET6;
break;
@@ -636,138 +616,129 @@ pgm_print(register const u_char *bp, register u_int length,
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
+ bp += (2 * sizeof(uint16_t));
if (opt_len != 4 + addr_size) {
- (void)printf("[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
return;
}
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
nla = bp;
bp += addr_size;
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf(" REDIRECT %s", (char *)nla);
+ ND_PRINT((ndo, " REDIRECT %s", (char *)nla));
opts_len -= 4 + addr_size;
break;
case PGM_OPT_PARITY_PRM:
if (opt_len != 8) {
- (void)printf("[Bad OPT_PARITY_PRM option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_PARITY_PRM option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
len = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" PARITY MAXTGS %u", len);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " PARITY MAXTGS %u", len));
opts_len -= 8;
break;
case PGM_OPT_PARITY_GRP:
if (opt_len != 8) {
- (void)printf("[Bad OPT_PARITY_GRP option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_PARITY_GRP option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" PARITY GROUP %u", seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " PARITY GROUP %u", seq));
opts_len -= 8;
break;
case PGM_OPT_CURR_TGSIZE:
if (opt_len != 8) {
- (void)printf("[Bad OPT_CURR_TGSIZE option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_CURR_TGSIZE option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
len = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" PARITY ATGS %u", len);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " PARITY ATGS %u", len));
opts_len -= 8;
break;
case PGM_OPT_NBR_UNREACH:
if (opt_len != 4) {
- (void)printf("[Bad OPT_NBR_UNREACH option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_NBR_UNREACH option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" NBR_UNREACH");
+ bp += 2;
+ ND_PRINT((ndo, " NBR_UNREACH"));
opts_len -= 4;
break;
case PGM_OPT_PATH_NLA:
- (void)printf(" PATH_NLA [%d]", opt_len);
+ ND_PRINT((ndo, " PATH_NLA [%d]", opt_len));
bp += opt_len;
opts_len -= opt_len;
break;
case PGM_OPT_SYN:
if (opt_len != 4) {
- (void)printf("[Bad OPT_SYN option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_SYN option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" SYN");
+ bp += 2;
+ ND_PRINT((ndo, " SYN"));
opts_len -= 4;
break;
case PGM_OPT_FIN:
if (opt_len != 4) {
- (void)printf("[Bad OPT_FIN option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_FIN option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" FIN");
+ bp += 2;
+ ND_PRINT((ndo, " FIN"));
opts_len -= 4;
break;
case PGM_OPT_RST:
if (opt_len != 4) {
- (void)printf("[Bad OPT_RST option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_RST option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" RST");
+ bp += 2;
+ ND_PRINT((ndo, " RST"));
opts_len -= 4;
break;
case PGM_OPT_CR:
- (void)printf(" CR");
+ ND_PRINT((ndo, " CR"));
bp += opt_len;
opts_len -= opt_len;
break;
case PGM_OPT_CRQST:
if (opt_len != 4) {
- (void)printf("[Bad OPT_CRQST option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_CRQST option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" CRQST");
+ bp += 2;
+ ND_PRINT((ndo, " CRQST"));
opts_len -= 4;
break;
case PGM_OPT_PGMCC_DATA:
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
nla_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
nla_af = AF_INET6;
break;
@@ -776,32 +747,31 @@ pgm_print(register const u_char *bp, register u_int length,
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
+ bp += (2 * sizeof(uint16_t));
if (opt_len != 12 + addr_size) {
- (void)printf("[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
return;
}
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
nla = bp;
bp += addr_size;
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf(" PGMCC DATA %u %s", offset, (char*)nla);
+ ND_PRINT((ndo, " PGMCC DATA %u %s", offset, (char*)nla));
opts_len -= 16;
break;
case PGM_OPT_PGMCC_FEEDBACK:
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
+ case AFNUM_INET:
addr_size = sizeof(struct in_addr);
nla_af = AF_INET;
break;
#ifdef INET6
- case AFI_IP6:
+ case AFNUM_INET6:
addr_size = sizeof(struct in6_addr);
nla_af = AF_INET6;
break;
@@ -810,22 +780,22 @@ pgm_print(register const u_char *bp, register u_int length,
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
+ bp += (2 * sizeof(uint16_t));
if (opt_len != 12 + addr_size) {
- (void)printf("[Bad OPT_PGMCC_FEEDBACK option, length %u != 12 + address size]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_FEEDBACK option, length %u != 12 + address size]", opt_len));
return;
}
- TCHECK2(*bp, addr_size);
+ ND_TCHECK2(*bp, addr_size);
nla = bp;
bp += addr_size;
inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf(" PGMCC FEEDBACK %u %s", offset, (char*)nla);
+ ND_PRINT((ndo, " PGMCC FEEDBACK %u %s", offset, (char*)nla));
opts_len -= 16;
break;
default:
- (void)printf(" OPT_%02X [%d] ", opt_type, opt_len);
+ ND_PRINT((ndo, " OPT_%02X [%d] ", opt_type, opt_len));
bp += opt_len;
opts_len -= opt_len;
break;
@@ -836,12 +806,15 @@ pgm_print(register const u_char *bp, register u_int length,
}
}
- (void)printf(" [%u]", EXTRACT_16BITS(&pgm->pgm_length));
+ ND_PRINT((ndo, " [%u]", length));
+ if (ndo->ndo_packettype == PT_PGM_ZMTP1 &&
+ (pgm->pgm_type == PGM_ODATA || pgm->pgm_type == PGM_RDATA))
+ zmtp1_print_datagram(ndo, bp, EXTRACT_16BITS(&pgm->pgm_length));
return;
trunc:
- fputs("[|pgm]", stdout);
+ ND_PRINT((ndo, "[|pgm]"));
if (ch != '\0')
- putchar('>');
+ ND_PRINT((ndo, ">"));
}
OpenPOWER on IntegriCloud