2005-05-21 05:02:29 +08:00
|
|
|
/*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that: (1) source code
|
|
|
|
* distributions retain the above copyright notice and this paragraph
|
|
|
|
* in its entirety, and (2) distributions including binary code include
|
|
|
|
* the above copyright notice and this paragraph in its entirety in
|
|
|
|
* the documentation or other materials provided with the distribution.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND
|
|
|
|
* WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
|
|
|
|
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* Original code by Andy Heffernan (ahh@juniper.net)
|
|
|
|
*/
|
|
|
|
|
2016-08-14 21:42:19 +08:00
|
|
|
/* \summary: Pragmatic General Multicast (PGM) printer */
|
|
|
|
|
2005-05-21 05:02:29 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-09-10 04:42:38 +08:00
|
|
|
#include <netdissect-stdinc.h>
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2015-09-06 05:35:58 +08:00
|
|
|
#include "netdissect.h"
|
2005-05-21 05:02:29 +08:00
|
|
|
#include "extract.h"
|
|
|
|
#include "addrtoname.h"
|
2015-09-18 05:56:44 +08:00
|
|
|
#include "addrtostr.h"
|
2005-05-21 05:02:29 +08:00
|
|
|
|
|
|
|
#include "ip.h"
|
|
|
|
#include "ip6.h"
|
|
|
|
#include "ipproto.h"
|
2014-03-19 20:45:12 +08:00
|
|
|
#include "af.h"
|
2005-05-21 05:02:29 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* PGM header (RFC 3208)
|
|
|
|
*/
|
|
|
|
struct pgm_header {
|
2017-12-31 09:56:56 +08:00
|
|
|
nd_uint16_t pgm_sport;
|
|
|
|
nd_uint16_t pgm_dport;
|
|
|
|
nd_uint8_t pgm_type;
|
|
|
|
nd_uint8_t pgm_options;
|
|
|
|
nd_uint16_t pgm_sum;
|
|
|
|
nd_byte pgm_gsid[6];
|
|
|
|
nd_uint16_t pgm_length;
|
2005-05-21 05:02:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct pgm_spm {
|
2017-12-31 09:56:56 +08:00
|
|
|
nd_uint32_t pgms_seq;
|
|
|
|
nd_uint32_t pgms_trailseq;
|
|
|
|
nd_uint32_t pgms_leadseq;
|
|
|
|
nd_uint16_t pgms_nla_afi;
|
|
|
|
nd_uint16_t pgms_reserved;
|
2014-04-23 15:20:40 +08:00
|
|
|
/* ... uint8_t pgms_nla[0]; */
|
2005-05-21 05:02:29 +08:00
|
|
|
/* ... options */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pgm_nak {
|
2017-12-31 09:56:56 +08:00
|
|
|
nd_uint32_t pgmn_seq;
|
|
|
|
nd_uint16_t pgmn_source_afi;
|
|
|
|
nd_uint16_t pgmn_reserved;
|
2014-04-23 15:20:40 +08:00
|
|
|
/* ... uint8_t pgmn_source[0]; */
|
|
|
|
/* ... uint16_t pgmn_group_afi */
|
|
|
|
/* ... uint16_t pgmn_reserved2; */
|
|
|
|
/* ... uint8_t pgmn_group[0]; */
|
2005-05-21 05:02:29 +08:00
|
|
|
/* ... options */
|
|
|
|
};
|
|
|
|
|
2010-05-30 09:50:37 +08:00
|
|
|
struct pgm_ack {
|
2017-12-31 09:56:56 +08:00
|
|
|
nd_uint32_t pgma_rx_max_seq;
|
|
|
|
nd_uint32_t pgma_bitmap;
|
2010-05-30 09:50:37 +08:00
|
|
|
/* ... options */
|
|
|
|
};
|
|
|
|
|
2005-05-21 05:02:29 +08:00
|
|
|
struct pgm_poll {
|
2017-12-31 09:56:56 +08:00
|
|
|
nd_uint32_t pgmp_seq;
|
|
|
|
nd_uint16_t pgmp_round;
|
|
|
|
nd_uint16_t pgmp_reserved;
|
2005-05-21 05:02:29 +08:00
|
|
|
/* ... options */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pgm_polr {
|
2017-12-31 09:56:56 +08:00
|
|
|
nd_uint32_t pgmp_seq;
|
|
|
|
nd_uint16_t pgmp_round;
|
|
|
|
nd_uint16_t pgmp_subtype;
|
|
|
|
nd_uint16_t pgmp_nla_afi;
|
|
|
|
nd_uint16_t pgmp_reserved;
|
2014-04-23 15:20:40 +08:00
|
|
|
/* ... uint8_t pgmp_nla[0]; */
|
2005-05-21 05:02:29 +08:00
|
|
|
/* ... options */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pgm_data {
|
2017-12-31 09:56:56 +08:00
|
|
|
nd_uint32_t pgmd_seq;
|
|
|
|
nd_uint32_t pgmd_trailseq;
|
2005-05-21 05:02:29 +08:00
|
|
|
/* ... options */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum _pgm_type {
|
|
|
|
PGM_SPM = 0, /* source path message */
|
|
|
|
PGM_POLL = 1, /* POLL Request */
|
|
|
|
PGM_POLR = 2, /* POLL Response */
|
|
|
|
PGM_ODATA = 4, /* original data */
|
|
|
|
PGM_RDATA = 5, /* repair data */
|
|
|
|
PGM_NAK = 8, /* NAK */
|
|
|
|
PGM_NULLNAK = 9, /* Null NAK */
|
|
|
|
PGM_NCF = 10, /* NAK Confirmation */
|
|
|
|
PGM_ACK = 11, /* ACK for congestion control */
|
|
|
|
PGM_SPMR = 12, /* SPM request */
|
|
|
|
PGM_MAX = 255
|
|
|
|
} pgm_type;
|
|
|
|
|
|
|
|
#define PGM_OPT_BIT_PRESENT 0x01
|
|
|
|
#define PGM_OPT_BIT_NETWORK 0x02
|
|
|
|
#define PGM_OPT_BIT_VAR_PKTLEN 0x40
|
|
|
|
#define PGM_OPT_BIT_PARITY 0x80
|
|
|
|
|
|
|
|
#define PGM_OPT_LENGTH 0x00
|
|
|
|
#define PGM_OPT_FRAGMENT 0x01
|
|
|
|
#define PGM_OPT_NAK_LIST 0x02
|
|
|
|
#define PGM_OPT_JOIN 0x03
|
|
|
|
#define PGM_OPT_NAK_BO_IVL 0x04
|
|
|
|
#define PGM_OPT_NAK_BO_RNG 0x05
|
|
|
|
|
|
|
|
#define PGM_OPT_REDIRECT 0x07
|
|
|
|
#define PGM_OPT_PARITY_PRM 0x08
|
|
|
|
#define PGM_OPT_PARITY_GRP 0x09
|
|
|
|
#define PGM_OPT_CURR_TGSIZE 0x0A
|
|
|
|
#define PGM_OPT_NBR_UNREACH 0x0B
|
|
|
|
#define PGM_OPT_PATH_NLA 0x0C
|
|
|
|
|
|
|
|
#define PGM_OPT_SYN 0x0D
|
|
|
|
#define PGM_OPT_FIN 0x0E
|
|
|
|
#define PGM_OPT_RST 0x0F
|
|
|
|
#define PGM_OPT_CR 0x10
|
|
|
|
#define PGM_OPT_CRQST 0x11
|
2010-05-30 09:50:37 +08:00
|
|
|
|
|
|
|
#define PGM_OPT_PGMCC_DATA 0x12
|
|
|
|
#define PGM_OPT_PGMCC_FEEDBACK 0x13
|
2014-01-02 10:27:54 +08:00
|
|
|
|
2005-05-21 05:02:29 +08:00
|
|
|
#define PGM_OPT_MASK 0x7f
|
|
|
|
|
|
|
|
#define PGM_OPT_END 0x80 /* end of options marker */
|
|
|
|
|
|
|
|
#define PGM_MIN_OPT_LEN 4
|
|
|
|
|
|
|
|
void
|
2014-03-19 17:57:56 +08:00
|
|
|
pgm_print(netdissect_options *ndo,
|
2017-12-14 02:17:47 +08:00
|
|
|
const u_char *bp, u_int length,
|
|
|
|
const u_char *bp2)
|
2005-05-21 05:02:29 +08:00
|
|
|
{
|
2017-12-14 02:17:47 +08:00
|
|
|
const struct pgm_header *pgm;
|
|
|
|
const struct ip *ip;
|
|
|
|
char ch;
|
2017-12-31 09:56:56 +08:00
|
|
|
uint8_t pgm_type;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t sport, dport;
|
2015-09-18 05:56:44 +08:00
|
|
|
u_int nla_afnum;
|
2005-06-08 06:05:58 +08:00
|
|
|
char nla_buf[INET6_ADDRSTRLEN];
|
2017-12-14 02:17:47 +08:00
|
|
|
const struct ip6_hdr *ip6;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint8_t opt_type, opt_len;
|
|
|
|
uint32_t seq, opts_len, len, offset;
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2015-04-27 08:24:42 +08:00
|
|
|
pgm = (const struct pgm_header *)bp;
|
|
|
|
ip = (const struct ip *)bp2;
|
2005-05-21 05:02:29 +08:00
|
|
|
if (IP_V(ip) == 6)
|
2015-04-27 08:24:42 +08:00
|
|
|
ip6 = (const struct ip6_hdr *)bp2;
|
2005-05-21 05:02:29 +08:00
|
|
|
else
|
|
|
|
ip6 = NULL;
|
|
|
|
ch = '\0';
|
2017-12-31 09:56:56 +08:00
|
|
|
if (!ND_TTEST_2(pgm->pgm_dport)) {
|
2005-05-21 05:02:29 +08:00
|
|
|
if (ip6) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "%s > %s: [|pgm]",
|
2014-04-04 15:43:46 +08:00
|
|
|
ip6addr_string(ndo, &ip6->ip6_src),
|
|
|
|
ip6addr_string(ndo, &ip6->ip6_dst)));
|
2015-09-18 05:56:44 +08:00
|
|
|
} else {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "%s > %s: [|pgm]",
|
2014-04-04 15:43:46 +08:00
|
|
|
ipaddr_string(ndo, &ip->ip_src),
|
|
|
|
ipaddr_string(ndo, &ip->ip_dst)));
|
2005-05-21 05:02:29 +08:00
|
|
|
}
|
2017-03-24 05:11:30 +08:00
|
|
|
return;
|
2005-05-21 05:02:29 +08:00
|
|
|
}
|
|
|
|
|
2017-12-31 09:56:56 +08:00
|
|
|
sport = EXTRACT_BE_U_2(pgm->pgm_sport);
|
|
|
|
dport = EXTRACT_BE_U_2(pgm->pgm_dport);
|
2005-05-21 05:02:29 +08:00
|
|
|
|
|
|
|
if (ip6) {
|
2017-12-12 11:38:35 +08:00
|
|
|
if (EXTRACT_U_1(ip6->ip6_nxt) == IPPROTO_PGM) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "%s.%s > %s.%s: ",
|
2014-04-04 15:43:46 +08:00
|
|
|
ip6addr_string(ndo, &ip6->ip6_src),
|
2015-09-06 04:28:04 +08:00
|
|
|
tcpport_string(ndo, sport),
|
2014-04-04 15:43:46 +08:00
|
|
|
ip6addr_string(ndo, &ip6->ip6_dst),
|
2015-09-06 04:28:04 +08:00
|
|
|
tcpport_string(ndo, dport)));
|
2005-05-21 05:02:29 +08:00
|
|
|
} else {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "%s > %s: ",
|
2015-09-06 04:28:04 +08:00
|
|
|
tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
|
2005-05-21 05:02:29 +08:00
|
|
|
}
|
2015-09-18 05:56:44 +08:00
|
|
|
} else {
|
2017-12-11 08:23:34 +08:00
|
|
|
if (EXTRACT_U_1(ip->ip_p) == IPPROTO_PGM) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "%s.%s > %s.%s: ",
|
2014-04-04 15:43:46 +08:00
|
|
|
ipaddr_string(ndo, &ip->ip_src),
|
2015-09-06 04:28:04 +08:00
|
|
|
tcpport_string(ndo, sport),
|
2014-04-04 15:43:46 +08:00
|
|
|
ipaddr_string(ndo, &ip->ip_dst),
|
2015-09-06 04:28:04 +08:00
|
|
|
tcpport_string(ndo, dport)));
|
2005-05-21 05:02:29 +08:00
|
|
|
} else {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "%s > %s: ",
|
2015-09-06 04:28:04 +08:00
|
|
|
tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
|
2005-05-21 05:02:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_TCHECK(*pgm);
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2017-12-31 09:56:56 +08:00
|
|
|
ND_PRINT((ndo, "PGM, length %u", EXTRACT_BE_U_2(pgm->pgm_length)));
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2014-03-19 17:57:56 +08:00
|
|
|
if (!ndo->ndo_vflag)
|
2005-05-21 05:02:29 +08:00
|
|
|
return;
|
|
|
|
|
2017-12-31 09:56:56 +08:00
|
|
|
pgm_type = EXTRACT_U_1(pgm->pgm_type);
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " 0x%02x%02x%02x%02x%02x%02x ",
|
2005-05-21 05:02:29 +08:00
|
|
|
pgm->pgm_gsid[0],
|
|
|
|
pgm->pgm_gsid[1],
|
|
|
|
pgm->pgm_gsid[2],
|
|
|
|
pgm->pgm_gsid[3],
|
|
|
|
pgm->pgm_gsid[4],
|
2014-03-19 17:57:56 +08:00
|
|
|
pgm->pgm_gsid[5]));
|
2017-12-31 09:56:56 +08:00
|
|
|
switch (pgm_type) {
|
2005-05-21 05:02:29 +08:00
|
|
|
case PGM_SPM: {
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct pgm_spm *spm;
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2015-04-27 08:24:42 +08:00
|
|
|
spm = (const struct pgm_spm *)(pgm + 1);
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_TCHECK(*spm);
|
2015-09-18 05:56:44 +08:00
|
|
|
bp = (const u_char *) (spm + 1);
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2017-12-31 09:56:56 +08:00
|
|
|
switch (EXTRACT_BE_U_2(spm->pgms_nla_afi)) {
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET:
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr(bp, nla_buf, sizeof(nla_buf));
|
|
|
|
bp += sizeof(struct in_addr);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET6:
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in6_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr6(bp, nla_buf, sizeof(nla_buf));
|
|
|
|
bp += sizeof(struct in6_addr);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto trunc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "SPM seq %u trail %u lead %u nla %s",
|
2017-12-31 09:56:56 +08:00
|
|
|
EXTRACT_BE_U_4(spm->pgms_seq),
|
|
|
|
EXTRACT_BE_U_4(spm->pgms_trailseq),
|
|
|
|
EXTRACT_BE_U_4(spm->pgms_leadseq),
|
2017-11-18 18:52:52 +08:00
|
|
|
nla_buf));
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PGM_POLL: {
|
2015-09-18 03:19:22 +08:00
|
|
|
const struct pgm_poll *poll_msg;
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2015-09-18 03:19:22 +08:00
|
|
|
poll_msg = (const struct pgm_poll *)(pgm + 1);
|
|
|
|
ND_TCHECK(*poll_msg);
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "POLL seq %u round %u",
|
2017-12-31 09:56:56 +08:00
|
|
|
EXTRACT_BE_U_4(poll_msg->pgmp_seq),
|
|
|
|
EXTRACT_BE_U_2(poll_msg->pgmp_round)));
|
2015-09-18 03:19:22 +08:00
|
|
|
bp = (const u_char *) (poll_msg + 1);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PGM_POLR: {
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct pgm_polr *polr;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint32_t ivl, rnd, mask;
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2015-04-27 08:24:42 +08:00
|
|
|
polr = (const struct pgm_polr *)(pgm + 1);
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_TCHECK(*polr);
|
2015-09-18 05:56:44 +08:00
|
|
|
bp = (const u_char *) (polr + 1);
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2017-12-31 09:56:56 +08:00
|
|
|
switch (EXTRACT_BE_U_2(polr->pgmp_nla_afi)) {
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET:
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr(bp, nla_buf, sizeof(nla_buf));
|
|
|
|
bp += sizeof(struct in_addr);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET6:
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in6_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr6(bp, nla_buf, sizeof(nla_buf));
|
|
|
|
bp += sizeof(struct in6_addr);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto trunc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(uint32_t));
|
2017-11-23 06:54:09 +08:00
|
|
|
ivl = EXTRACT_BE_U_4(bp);
|
2014-04-23 15:20:40 +08:00
|
|
|
bp += sizeof(uint32_t);
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(uint32_t));
|
2017-11-23 06:54:09 +08:00
|
|
|
rnd = EXTRACT_BE_U_4(bp);
|
2014-04-23 15:20:40 +08:00
|
|
|
bp += sizeof(uint32_t);
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(uint32_t));
|
2017-11-23 06:54:09 +08:00
|
|
|
mask = EXTRACT_BE_U_4(bp);
|
2014-04-23 15:20:40 +08:00
|
|
|
bp += sizeof(uint32_t);
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "POLR seq %u round %u nla %s ivl %u rnd 0x%08x "
|
2017-12-31 09:56:56 +08:00
|
|
|
"mask 0x%08x", EXTRACT_BE_U_4(polr->pgmp_seq),
|
|
|
|
EXTRACT_BE_U_2(polr->pgmp_round), nla_buf, ivl, rnd, mask));
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PGM_ODATA: {
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct pgm_data *odata;
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2015-04-27 08:24:42 +08:00
|
|
|
odata = (const struct pgm_data *)(pgm + 1);
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_TCHECK(*odata);
|
|
|
|
ND_PRINT((ndo, "ODATA trail %u seq %u",
|
2017-12-31 09:56:56 +08:00
|
|
|
EXTRACT_BE_U_4(odata->pgmd_trailseq),
|
|
|
|
EXTRACT_BE_U_4(odata->pgmd_seq)));
|
2015-04-27 08:24:42 +08:00
|
|
|
bp = (const u_char *) (odata + 1);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PGM_RDATA: {
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct pgm_data *rdata;
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2015-04-27 08:24:42 +08:00
|
|
|
rdata = (const struct pgm_data *)(pgm + 1);
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_TCHECK(*rdata);
|
|
|
|
ND_PRINT((ndo, "RDATA trail %u seq %u",
|
2017-12-31 09:56:56 +08:00
|
|
|
EXTRACT_BE_U_4(rdata->pgmd_trailseq),
|
|
|
|
EXTRACT_BE_U_4(rdata->pgmd_seq)));
|
2015-04-27 08:24:42 +08:00
|
|
|
bp = (const u_char *) (rdata + 1);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PGM_NAK:
|
|
|
|
case PGM_NULLNAK:
|
|
|
|
case PGM_NCF: {
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct pgm_nak *nak;
|
2005-05-21 05:02:29 +08:00
|
|
|
char source_buf[INET6_ADDRSTRLEN], group_buf[INET6_ADDRSTRLEN];
|
|
|
|
|
2015-04-27 08:24:42 +08:00
|
|
|
nak = (const struct pgm_nak *)(pgm + 1);
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_TCHECK(*nak);
|
2015-09-18 05:56:44 +08:00
|
|
|
bp = (const u_char *) (nak + 1);
|
2005-05-21 05:02:29 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip past the source, saving info along the way
|
|
|
|
* and stopping if we don't have enough.
|
|
|
|
*/
|
2017-12-31 09:56:56 +08:00
|
|
|
switch (EXTRACT_BE_U_2(nak->pgmn_source_afi)) {
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET:
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr(bp, source_buf, sizeof(source_buf));
|
|
|
|
bp += sizeof(struct in_addr);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET6:
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in6_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr6(bp, source_buf, sizeof(source_buf));
|
|
|
|
bp += sizeof(struct in6_addr);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto trunc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip past the group, saving info along the way
|
|
|
|
* and stopping if we don't have enough.
|
|
|
|
*/
|
2015-09-18 05:56:44 +08:00
|
|
|
bp += (2 * sizeof(uint16_t));
|
2017-11-23 04:58:44 +08:00
|
|
|
ND_TCHECK_2(bp);
|
2017-11-23 06:54:09 +08:00
|
|
|
switch (EXTRACT_BE_U_2(bp)) {
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET:
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr(bp, group_buf, sizeof(group_buf));
|
|
|
|
bp += sizeof(struct in_addr);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET6:
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in6_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr6(bp, group_buf, sizeof(group_buf));
|
|
|
|
bp += sizeof(struct in6_addr);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto trunc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Options decoding can go here.
|
|
|
|
*/
|
2017-12-31 09:56:56 +08:00
|
|
|
switch (pgm_type) {
|
2005-05-21 05:02:29 +08:00
|
|
|
case PGM_NAK:
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "NAK "));
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
case PGM_NULLNAK:
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "NNAK "));
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
case PGM_NCF:
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "NCF "));
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "(%s -> %s), seq %u",
|
2017-12-31 09:56:56 +08:00
|
|
|
source_buf, group_buf, EXTRACT_BE_U_4(nak->pgmn_seq)));
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-05-30 09:50:37 +08:00
|
|
|
case PGM_ACK: {
|
2015-04-27 08:24:42 +08:00
|
|
|
const struct pgm_ack *ack;
|
2010-05-30 09:50:37 +08:00
|
|
|
|
2015-04-27 08:24:42 +08:00
|
|
|
ack = (const struct pgm_ack *)(pgm + 1);
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_TCHECK(*ack);
|
|
|
|
ND_PRINT((ndo, "ACK seq %u",
|
2017-12-31 09:56:56 +08:00
|
|
|
EXTRACT_BE_U_4(ack->pgma_rx_max_seq)));
|
2015-04-27 08:24:42 +08:00
|
|
|
bp = (const u_char *) (ack + 1);
|
2010-05-30 09:50:37 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-05-21 05:02:29 +08:00
|
|
|
case PGM_SPMR:
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "SPMR"));
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2017-12-31 09:56:56 +08:00
|
|
|
ND_PRINT((ndo, "UNKNOWN type 0x%02x", pgm_type));
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2017-12-31 09:56:56 +08:00
|
|
|
if (EXTRACT_U_1(pgm->pgm_options) & PGM_OPT_BIT_PRESENT) {
|
2005-05-21 05:02:29 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* make sure there's enough for the first option header
|
|
|
|
*/
|
2017-12-11 19:46:51 +08:00
|
|
|
if (!ND_TTEST_LEN(bp, PGM_MIN_OPT_LEN)) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "[|OPT]"));
|
2005-05-21 05:02:29 +08:00
|
|
|
return;
|
2014-01-02 10:27:54 +08:00
|
|
|
}
|
2005-05-21 05:02:29 +08:00
|
|
|
|
2005-05-24 05:38:06 +08:00
|
|
|
/*
|
|
|
|
* That option header MUST be an OPT_LENGTH option
|
|
|
|
* (see the first paragraph of section 9.1 in RFC 3208).
|
|
|
|
*/
|
2017-11-23 06:54:09 +08:00
|
|
|
opt_type = EXTRACT_U_1(bp);
|
2017-11-22 03:23:59 +08:00
|
|
|
bp++;
|
2005-05-24 05:38:06 +08:00
|
|
|
if ((opt_type & PGM_OPT_MASK) != PGM_OPT_LENGTH) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-11-23 06:54:09 +08:00
|
|
|
opt_len = EXTRACT_U_1(bp);
|
2017-11-22 03:23:59 +08:00
|
|
|
bp++;
|
2005-05-24 05:38:06 +08:00
|
|
|
if (opt_len != 4) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != 4]", opt_len));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-11-23 06:54:09 +08:00
|
|
|
opts_len = EXTRACT_BE_U_2(bp);
|
2017-12-11 08:23:34 +08:00
|
|
|
bp += sizeof(uint16_t);
|
2005-05-24 05:38:06 +08:00
|
|
|
if (opts_len < 4) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "[Bad total option length %u < 4]", opts_len));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-12-31 09:56:56 +08:00
|
|
|
ND_PRINT((ndo, " OPTS LEN %u", opts_len));
|
2005-05-24 05:38:06 +08:00
|
|
|
opts_len -= 4;
|
|
|
|
|
|
|
|
while (opts_len) {
|
|
|
|
if (opts_len < PGM_MIN_OPT_LEN) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "[Total option length leaves no room for final option]"));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-11-25 05:48:55 +08:00
|
|
|
if (!ND_TTEST_2(bp)) {
|
2017-03-22 10:49:28 +08:00
|
|
|
ND_PRINT((ndo, " [|OPT]"));
|
|
|
|
return;
|
|
|
|
}
|
2017-11-23 06:54:09 +08:00
|
|
|
opt_type = EXTRACT_U_1(bp);
|
2017-11-22 03:23:59 +08:00
|
|
|
bp++;
|
2017-11-23 06:54:09 +08:00
|
|
|
opt_len = EXTRACT_U_1(bp);
|
2017-11-22 03:23:59 +08:00
|
|
|
bp++;
|
2005-05-24 05:38:06 +08:00
|
|
|
if (opt_len < PGM_MIN_OPT_LEN) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "[Bad option, length %u < %u]", opt_len,
|
|
|
|
PGM_MIN_OPT_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (opts_len < opt_len) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "[Total option length leaves no room for final option]"));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-12-11 19:46:51 +08:00
|
|
|
if (!ND_TTEST_LEN(bp, opt_len - 2)) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " [|OPT]"));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
2014-01-02 10:27:54 +08:00
|
|
|
}
|
2005-05-21 05:02:29 +08:00
|
|
|
|
|
|
|
switch (opt_type & PGM_OPT_MASK) {
|
|
|
|
case PGM_OPT_LENGTH:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_LENGTH_LEN (2+2)
|
|
|
|
if (opt_len != PGM_OPT_LENGTH_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_LENGTH_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-12-31 09:56:56 +08:00
|
|
|
ND_PRINT((ndo, " OPTS LEN (extra?) %u", EXTRACT_BE_U_2(bp)));
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 2;
|
|
|
|
opts_len -= PGM_OPT_LENGTH_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_FRAGMENT:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_FRAGMENT_LEN (2+2+4+4+4)
|
|
|
|
if (opt_len != PGM_OPT_FRAGMENT_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_FRAGMENT option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_FRAGMENT_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2017-11-23 06:54:09 +08:00
|
|
|
seq = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2017-11-23 06:54:09 +08:00
|
|
|
offset = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2017-11-23 06:54:09 +08:00
|
|
|
len = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " FRAG seq %u off %u len %u", seq, offset, len));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_FRAGMENT_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_NAK_LIST:
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2017-03-22 12:49:45 +08:00
|
|
|
opt_len -= 4; /* option header */
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " NAK LIST"));
|
2005-05-21 05:02:29 +08:00
|
|
|
while (opt_len) {
|
2017-03-22 12:49:45 +08:00
|
|
|
if (opt_len < 4) {
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "[Option length not a multiple of 4]"));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-11-25 05:48:55 +08:00
|
|
|
ND_TCHECK_4(bp);
|
2017-11-23 06:54:09 +08:00
|
|
|
ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(bp)));
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
|
|
|
opt_len -= 4;
|
|
|
|
opts_len -= 4;
|
2005-05-21 05:02:29 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_JOIN:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_JOIN_LEN (2+2+4)
|
|
|
|
if (opt_len != PGM_OPT_JOIN_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_JOIN option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_JOIN_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2017-11-23 06:54:09 +08:00
|
|
|
seq = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " JOIN %u", seq));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_JOIN_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_NAK_BO_IVL:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_NAK_BO_IVL_LEN (2+2+4+4)
|
|
|
|
if (opt_len != PGM_OPT_NAK_BO_IVL_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_NAK_BO_IVL option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_NAK_BO_IVL_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2017-11-23 06:54:09 +08:00
|
|
|
offset = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2017-11-23 06:54:09 +08:00
|
|
|
seq = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " BACKOFF ivl %u ivlseq %u", offset, seq));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_NAK_BO_IVL_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_NAK_BO_RNG:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_NAK_BO_RNG_LEN (2+2+4+4)
|
|
|
|
if (opt_len != PGM_OPT_NAK_BO_RNG_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_NAK_BO_RNG option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_NAK_BO_RNG_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2017-11-23 06:54:09 +08:00
|
|
|
offset = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2017-11-23 06:54:09 +08:00
|
|
|
seq = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " BACKOFF max %u min %u", offset, seq));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_NAK_BO_RNG_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_REDIRECT:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_REDIRECT_FIXED_LEN (2+2+2+2)
|
|
|
|
if (opt_len < PGM_OPT_REDIRECT_FIXED_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u < %u]",
|
|
|
|
opt_len, PGM_OPT_REDIRECT_FIXED_LEN));
|
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2017-11-23 06:54:09 +08:00
|
|
|
nla_afnum = EXTRACT_BE_U_2(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 2+2;
|
2015-09-18 05:56:44 +08:00
|
|
|
switch (nla_afnum) {
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET:
|
2017-03-22 12:49:45 +08:00
|
|
|
if (opt_len != PGM_OPT_REDIRECT_FIXED_LEN + sizeof(struct in_addr)) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != %u + address size]",
|
|
|
|
opt_len, PGM_OPT_REDIRECT_FIXED_LEN));
|
2015-09-18 05:56:44 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr(bp, nla_buf, sizeof(nla_buf));
|
|
|
|
bp += sizeof(struct in_addr);
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_REDIRECT_FIXED_LEN + sizeof(struct in_addr);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET6:
|
2017-03-22 12:49:45 +08:00
|
|
|
if (opt_len != PGM_OPT_REDIRECT_FIXED_LEN + sizeof(struct in6_addr)) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != %u + address size]",
|
|
|
|
PGM_OPT_REDIRECT_FIXED_LEN, opt_len));
|
2015-09-18 05:56:44 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in6_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr6(bp, nla_buf, sizeof(nla_buf));
|
|
|
|
bp += sizeof(struct in6_addr);
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_REDIRECT_FIXED_LEN + sizeof(struct in6_addr);
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto trunc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-04-27 06:34:13 +08:00
|
|
|
ND_PRINT((ndo, " REDIRECT %s", nla_buf));
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_PARITY_PRM:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_PARITY_PRM_LEN (2+2+4)
|
|
|
|
if (opt_len != PGM_OPT_PARITY_PRM_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_PARITY_PRM option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_PARITY_PRM_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2017-11-23 06:54:09 +08:00
|
|
|
len = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " PARITY MAXTGS %u", len));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_PARITY_PRM_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_PARITY_GRP:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_PARITY_GRP_LEN (2+2+4)
|
|
|
|
if (opt_len != PGM_OPT_PARITY_GRP_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_PARITY_GRP option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_PARITY_GRP_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2017-11-23 06:54:09 +08:00
|
|
|
seq = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " PARITY GROUP %u", seq));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_PARITY_GRP_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_CURR_TGSIZE:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_CURR_TGSIZE_LEN (2+2+4)
|
|
|
|
if (opt_len != PGM_OPT_CURR_TGSIZE_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_CURR_TGSIZE option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_CURR_TGSIZE_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2017-11-23 06:54:09 +08:00
|
|
|
len = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " PARITY ATGS %u", len));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_CURR_TGSIZE_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_NBR_UNREACH:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_NBR_UNREACH_LEN (2+2)
|
|
|
|
if (opt_len != PGM_OPT_NBR_UNREACH_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_NBR_UNREACH option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_NBR_UNREACH_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " NBR_UNREACH"));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_NBR_UNREACH_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_PATH_NLA:
|
2017-12-31 09:56:56 +08:00
|
|
|
ND_PRINT((ndo, " PATH_NLA [%u]", opt_len));
|
2005-05-21 05:02:29 +08:00
|
|
|
bp += opt_len;
|
2005-05-24 05:38:06 +08:00
|
|
|
opts_len -= opt_len;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_SYN:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_SYN_LEN (2+2)
|
|
|
|
if (opt_len != PGM_OPT_SYN_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_SYN option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_SYN_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " SYN"));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_SYN_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_FIN:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_FIN_LEN (2+2)
|
|
|
|
if (opt_len != PGM_OPT_FIN_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_FIN option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_FIN_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " FIN"));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_FIN_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_RST:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_RST_LEN (2+2)
|
|
|
|
if (opt_len != PGM_OPT_RST_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_RST option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_RST_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " RST"));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_RST_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_CR:
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " CR"));
|
2005-05-21 05:02:29 +08:00
|
|
|
bp += opt_len;
|
2005-05-24 05:38:06 +08:00
|
|
|
opts_len -= opt_len;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_CRQST:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_CRQST_LEN (2+2)
|
|
|
|
if (opt_len != PGM_OPT_CRQST_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_CRQST option, length %u != %u]",
|
|
|
|
opt_len, PGM_OPT_CRQST_LEN));
|
2005-05-24 05:38:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " CRQST"));
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_CRQST_LEN;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
|
2010-05-30 09:50:37 +08:00
|
|
|
case PGM_OPT_PGMCC_DATA:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_PGMCC_DATA_FIXED_LEN (2+2+4+2+2)
|
|
|
|
if (opt_len < PGM_OPT_PGMCC_DATA_FIXED_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u < %u]",
|
|
|
|
opt_len, PGM_OPT_PGMCC_DATA_FIXED_LEN));
|
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2017-11-23 06:54:09 +08:00
|
|
|
offset = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2017-11-23 06:54:09 +08:00
|
|
|
nla_afnum = EXTRACT_BE_U_2(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 2+2;
|
2015-09-18 05:56:44 +08:00
|
|
|
switch (nla_afnum) {
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET:
|
2017-03-22 12:49:45 +08:00
|
|
|
if (opt_len != PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(struct in_addr)) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != %u + address size]",
|
|
|
|
opt_len, PGM_OPT_PGMCC_DATA_FIXED_LEN));
|
2015-09-18 05:56:44 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr(bp, nla_buf, sizeof(nla_buf));
|
|
|
|
bp += sizeof(struct in_addr);
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(struct in_addr);
|
2010-05-30 09:50:37 +08:00
|
|
|
break;
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET6:
|
2017-03-22 12:49:45 +08:00
|
|
|
if (opt_len != PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(struct in6_addr)) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != %u + address size]",
|
|
|
|
opt_len, PGM_OPT_PGMCC_DATA_FIXED_LEN));
|
2015-09-18 05:56:44 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in6_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr6(bp, nla_buf, sizeof(nla_buf));
|
|
|
|
bp += sizeof(struct in6_addr);
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(struct in6_addr);
|
2010-05-30 09:50:37 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto trunc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-04-27 06:34:13 +08:00
|
|
|
ND_PRINT((ndo, " PGMCC DATA %u %s", offset, nla_buf));
|
2010-05-30 09:50:37 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PGM_OPT_PGMCC_FEEDBACK:
|
2017-03-22 12:49:45 +08:00
|
|
|
#define PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN (2+2+4+2+2)
|
|
|
|
if (opt_len < PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN) {
|
|
|
|
ND_PRINT((ndo, "[Bad PGM_OPT_PGMCC_FEEDBACK option, length %u < %u]",
|
|
|
|
opt_len, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN));
|
|
|
|
return;
|
|
|
|
}
|
2013-11-26 04:16:47 +08:00
|
|
|
bp += 2;
|
2017-11-23 06:54:09 +08:00
|
|
|
offset = EXTRACT_BE_U_4(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 4;
|
2017-11-23 06:54:09 +08:00
|
|
|
nla_afnum = EXTRACT_BE_U_2(bp);
|
2017-03-22 12:49:45 +08:00
|
|
|
bp += 2+2;
|
2015-09-18 05:56:44 +08:00
|
|
|
switch (nla_afnum) {
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET:
|
2017-03-22 12:49:45 +08:00
|
|
|
if (opt_len != PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(struct in_addr)) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_PGMCC_FEEDBACK option, length %u != %u + address size]",
|
|
|
|
opt_len, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN));
|
2015-09-18 05:56:44 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr(bp, nla_buf, sizeof(nla_buf));
|
|
|
|
bp += sizeof(struct in_addr);
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(struct in_addr);
|
2010-05-30 09:50:37 +08:00
|
|
|
break;
|
2014-03-19 20:45:12 +08:00
|
|
|
case AFNUM_INET6:
|
2017-03-22 12:49:45 +08:00
|
|
|
if (opt_len != PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(struct in6_addr)) {
|
|
|
|
ND_PRINT((ndo, "[Bad OPT_PGMCC_FEEDBACK option, length %u != %u + address size]",
|
|
|
|
opt_len, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN));
|
2015-09-18 05:56:44 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-12-11 19:46:51 +08:00
|
|
|
ND_TCHECK_LEN(bp, sizeof(struct in6_addr));
|
2015-09-18 05:56:44 +08:00
|
|
|
addrtostr6(bp, nla_buf, sizeof(nla_buf));
|
|
|
|
bp += sizeof(struct in6_addr);
|
2017-03-22 12:49:45 +08:00
|
|
|
opts_len -= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(struct in6_addr);
|
2010-05-30 09:50:37 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto trunc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-04-27 06:34:13 +08:00
|
|
|
ND_PRINT((ndo, " PGMCC FEEDBACK %u %s", offset, nla_buf));
|
2010-05-30 09:50:37 +08:00
|
|
|
break;
|
|
|
|
|
2005-05-21 05:02:29 +08:00
|
|
|
default:
|
2017-12-31 09:56:56 +08:00
|
|
|
ND_PRINT((ndo, " OPT_%02X [%u] ", opt_type, opt_len));
|
2005-05-21 05:02:29 +08:00
|
|
|
bp += opt_len;
|
2005-05-24 05:38:06 +08:00
|
|
|
opts_len -= opt_len;
|
2005-05-21 05:02:29 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opt_type & PGM_OPT_END)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, " [%u]", length));
|
|
|
|
if (ndo->ndo_packettype == PT_PGM_ZMTP1 &&
|
2017-12-31 09:56:56 +08:00
|
|
|
(pgm_type == PGM_ODATA || pgm_type == PGM_RDATA))
|
2017-11-18 18:52:52 +08:00
|
|
|
zmtp1_datagram_print(ndo, bp,
|
2017-12-31 09:56:56 +08:00
|
|
|
EXTRACT_BE_U_2(pgm->pgm_length));
|
2005-05-21 05:02:29 +08:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
trunc:
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, "[|pgm]"));
|
2005-05-21 05:02:29 +08:00
|
|
|
if (ch != '\0')
|
2014-03-19 17:57:56 +08:00
|
|
|
ND_PRINT((ndo, ">"));
|
2005-05-21 05:02:29 +08:00
|
|
|
}
|