2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that: (1) source code
4 * distributions retain the above copyright notice and this paragraph
5 * in its entirety, and (2) distributions including binary code include
6 * the above copyright notice and this paragraph in its entirety in
7 * the documentation or other materials provided with the distribution.
8 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
9 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
10 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11 * FOR A PARTICULAR PURPOSE.
13 * Original code by Andy Heffernan (ahh@juniper.net)
16 /* \summary: Pragmatic General Multicast (PGM) printer */
22 #include <netdissect-stdinc.h>
24 #include "netdissect.h"
26 #include "addrtoname.h"
27 #include "addrtostr.h"
35 * PGM header (RFC 3208)
38 nd_uint16_t pgm_sport
;
39 nd_uint16_t pgm_dport
;
41 nd_uint8_t pgm_options
;
44 nd_uint16_t pgm_length
;
49 nd_uint32_t pgms_trailseq
;
50 nd_uint32_t pgms_leadseq
;
51 nd_uint16_t pgms_nla_afi
;
52 nd_uint16_t pgms_reserved
;
53 /* ... uint8_t pgms_nla[0]; */
59 nd_uint16_t pgmn_source_afi
;
60 nd_uint16_t pgmn_reserved
;
61 /* ... uint8_t pgmn_source[0]; */
62 /* ... uint16_t pgmn_group_afi */
63 /* ... uint16_t pgmn_reserved2; */
64 /* ... uint8_t pgmn_group[0]; */
69 nd_uint32_t pgma_rx_max_seq
;
70 nd_uint32_t pgma_bitmap
;
76 nd_uint16_t pgmp_round
;
77 nd_uint16_t pgmp_reserved
;
83 nd_uint16_t pgmp_round
;
84 nd_uint16_t pgmp_subtype
;
85 nd_uint16_t pgmp_nla_afi
;
86 nd_uint16_t pgmp_reserved
;
87 /* ... uint8_t pgmp_nla[0]; */
93 nd_uint32_t pgmd_trailseq
;
97 typedef enum _pgm_type
{
98 PGM_SPM
= 0, /* source path message */
99 PGM_POLL
= 1, /* POLL Request */
100 PGM_POLR
= 2, /* POLL Response */
101 PGM_ODATA
= 4, /* original data */
102 PGM_RDATA
= 5, /* repair data */
103 PGM_NAK
= 8, /* NAK */
104 PGM_NULLNAK
= 9, /* Null NAK */
105 PGM_NCF
= 10, /* NAK Confirmation */
106 PGM_ACK
= 11, /* ACK for congestion control */
107 PGM_SPMR
= 12, /* SPM request */
111 #define PGM_OPT_BIT_PRESENT 0x01
112 #define PGM_OPT_BIT_NETWORK 0x02
113 #define PGM_OPT_BIT_VAR_PKTLEN 0x40
114 #define PGM_OPT_BIT_PARITY 0x80
116 #define PGM_OPT_LENGTH 0x00
117 #define PGM_OPT_FRAGMENT 0x01
118 #define PGM_OPT_NAK_LIST 0x02
119 #define PGM_OPT_JOIN 0x03
120 #define PGM_OPT_NAK_BO_IVL 0x04
121 #define PGM_OPT_NAK_BO_RNG 0x05
123 #define PGM_OPT_REDIRECT 0x07
124 #define PGM_OPT_PARITY_PRM 0x08
125 #define PGM_OPT_PARITY_GRP 0x09
126 #define PGM_OPT_CURR_TGSIZE 0x0A
127 #define PGM_OPT_NBR_UNREACH 0x0B
128 #define PGM_OPT_PATH_NLA 0x0C
130 #define PGM_OPT_SYN 0x0D
131 #define PGM_OPT_FIN 0x0E
132 #define PGM_OPT_RST 0x0F
133 #define PGM_OPT_CR 0x10
134 #define PGM_OPT_CRQST 0x11
136 #define PGM_OPT_PGMCC_DATA 0x12
137 #define PGM_OPT_PGMCC_FEEDBACK 0x13
139 #define PGM_OPT_MASK 0x7f
141 #define PGM_OPT_END 0x80 /* end of options marker */
143 #define PGM_MIN_OPT_LEN 4
146 pgm_print(netdissect_options
*ndo
,
147 const u_char
*bp
, u_int length
,
150 const struct pgm_header
*pgm
;
153 uint8_t pgm_type_val
;
154 uint16_t sport
, dport
;
156 char nla_buf
[INET6_ADDRSTRLEN
];
157 const struct ip6_hdr
*ip6
;
158 uint8_t opt_type
, opt_len
;
159 uint32_t seq
, opts_len
, len
, offset
;
161 pgm
= (const struct pgm_header
*)bp
;
162 ip
= (const struct ip
*)bp2
;
164 ip6
= (const struct ip6_hdr
*)bp2
;
168 if (!ND_TTEST_2(pgm
->pgm_dport
)) {
170 ND_PRINT((ndo
, "%s > %s: [|pgm]",
171 ip6addr_string(ndo
, &ip6
->ip6_src
),
172 ip6addr_string(ndo
, &ip6
->ip6_dst
)));
174 ND_PRINT((ndo
, "%s > %s: [|pgm]",
175 ipaddr_string(ndo
, &ip
->ip_src
),
176 ipaddr_string(ndo
, &ip
->ip_dst
)));
181 sport
= EXTRACT_BE_U_2(pgm
->pgm_sport
);
182 dport
= EXTRACT_BE_U_2(pgm
->pgm_dport
);
185 if (EXTRACT_U_1(ip6
->ip6_nxt
) == IPPROTO_PGM
) {
186 ND_PRINT((ndo
, "%s.%s > %s.%s: ",
187 ip6addr_string(ndo
, &ip6
->ip6_src
),
188 tcpport_string(ndo
, sport
),
189 ip6addr_string(ndo
, &ip6
->ip6_dst
),
190 tcpport_string(ndo
, dport
)));
192 ND_PRINT((ndo
, "%s > %s: ",
193 tcpport_string(ndo
, sport
), tcpport_string(ndo
, dport
)));
196 if (EXTRACT_U_1(ip
->ip_p
) == IPPROTO_PGM
) {
197 ND_PRINT((ndo
, "%s.%s > %s.%s: ",
198 ipaddr_string(ndo
, &ip
->ip_src
),
199 tcpport_string(ndo
, sport
),
200 ipaddr_string(ndo
, &ip
->ip_dst
),
201 tcpport_string(ndo
, dport
)));
203 ND_PRINT((ndo
, "%s > %s: ",
204 tcpport_string(ndo
, sport
), tcpport_string(ndo
, dport
)));
210 ND_PRINT((ndo
, "PGM, length %u", EXTRACT_BE_U_2(pgm
->pgm_length
)));
215 pgm_type_val
= EXTRACT_U_1(pgm
->pgm_type
);
216 ND_PRINT((ndo
, " 0x%02x%02x%02x%02x%02x%02x ",
223 switch (pgm_type_val
) {
225 const struct pgm_spm
*spm
;
227 spm
= (const struct pgm_spm
*)(pgm
+ 1);
229 bp
= (const u_char
*) (spm
+ 1);
231 switch (EXTRACT_BE_U_2(spm
->pgms_nla_afi
)) {
233 ND_TCHECK_LEN(bp
, sizeof(struct in_addr
));
234 addrtostr(bp
, nla_buf
, sizeof(nla_buf
));
235 bp
+= sizeof(struct in_addr
);
238 ND_TCHECK_LEN(bp
, sizeof(struct in6_addr
));
239 addrtostr6(bp
, nla_buf
, sizeof(nla_buf
));
240 bp
+= sizeof(struct in6_addr
);
247 ND_PRINT((ndo
, "SPM seq %u trail %u lead %u nla %s",
248 EXTRACT_BE_U_4(spm
->pgms_seq
),
249 EXTRACT_BE_U_4(spm
->pgms_trailseq
),
250 EXTRACT_BE_U_4(spm
->pgms_leadseq
),
256 const struct pgm_poll
*poll_msg
;
258 poll_msg
= (const struct pgm_poll
*)(pgm
+ 1);
259 ND_TCHECK_SIZE(poll_msg
);
260 ND_PRINT((ndo
, "POLL seq %u round %u",
261 EXTRACT_BE_U_4(poll_msg
->pgmp_seq
),
262 EXTRACT_BE_U_2(poll_msg
->pgmp_round
)));
263 bp
= (const u_char
*) (poll_msg
+ 1);
267 const struct pgm_polr
*polr
;
268 uint32_t ivl
, rnd
, mask
;
270 polr
= (const struct pgm_polr
*)(pgm
+ 1);
271 ND_TCHECK_SIZE(polr
);
272 bp
= (const u_char
*) (polr
+ 1);
274 switch (EXTRACT_BE_U_2(polr
->pgmp_nla_afi
)) {
276 ND_TCHECK_LEN(bp
, sizeof(struct in_addr
));
277 addrtostr(bp
, nla_buf
, sizeof(nla_buf
));
278 bp
+= sizeof(struct in_addr
);
281 ND_TCHECK_LEN(bp
, sizeof(struct in6_addr
));
282 addrtostr6(bp
, nla_buf
, sizeof(nla_buf
));
283 bp
+= sizeof(struct in6_addr
);
290 ND_TCHECK_LEN(bp
, sizeof(uint32_t));
291 ivl
= EXTRACT_BE_U_4(bp
);
292 bp
+= sizeof(uint32_t);
294 ND_TCHECK_LEN(bp
, sizeof(uint32_t));
295 rnd
= EXTRACT_BE_U_4(bp
);
296 bp
+= sizeof(uint32_t);
298 ND_TCHECK_LEN(bp
, sizeof(uint32_t));
299 mask
= EXTRACT_BE_U_4(bp
);
300 bp
+= sizeof(uint32_t);
302 ND_PRINT((ndo
, "POLR seq %u round %u nla %s ivl %u rnd 0x%08x "
303 "mask 0x%08x", EXTRACT_BE_U_4(polr
->pgmp_seq
),
304 EXTRACT_BE_U_2(polr
->pgmp_round
), nla_buf
, ivl
, rnd
, mask
));
308 const struct pgm_data
*odata
;
310 odata
= (const struct pgm_data
*)(pgm
+ 1);
311 ND_TCHECK_SIZE(odata
);
312 ND_PRINT((ndo
, "ODATA trail %u seq %u",
313 EXTRACT_BE_U_4(odata
->pgmd_trailseq
),
314 EXTRACT_BE_U_4(odata
->pgmd_seq
)));
315 bp
= (const u_char
*) (odata
+ 1);
320 const struct pgm_data
*rdata
;
322 rdata
= (const struct pgm_data
*)(pgm
+ 1);
323 ND_TCHECK_SIZE(rdata
);
324 ND_PRINT((ndo
, "RDATA trail %u seq %u",
325 EXTRACT_BE_U_4(rdata
->pgmd_trailseq
),
326 EXTRACT_BE_U_4(rdata
->pgmd_seq
)));
327 bp
= (const u_char
*) (rdata
+ 1);
334 const struct pgm_nak
*nak
;
335 char source_buf
[INET6_ADDRSTRLEN
], group_buf
[INET6_ADDRSTRLEN
];
337 nak
= (const struct pgm_nak
*)(pgm
+ 1);
339 bp
= (const u_char
*) (nak
+ 1);
342 * Skip past the source, saving info along the way
343 * and stopping if we don't have enough.
345 switch (EXTRACT_BE_U_2(nak
->pgmn_source_afi
)) {
347 ND_TCHECK_LEN(bp
, sizeof(struct in_addr
));
348 addrtostr(bp
, source_buf
, sizeof(source_buf
));
349 bp
+= sizeof(struct in_addr
);
352 ND_TCHECK_LEN(bp
, sizeof(struct in6_addr
));
353 addrtostr6(bp
, source_buf
, sizeof(source_buf
));
354 bp
+= sizeof(struct in6_addr
);
362 * Skip past the group, saving info along the way
363 * and stopping if we don't have enough.
365 bp
+= (2 * sizeof(uint16_t));
367 switch (EXTRACT_BE_U_2(bp
)) {
369 ND_TCHECK_LEN(bp
, sizeof(struct in_addr
));
370 addrtostr(bp
, group_buf
, sizeof(group_buf
));
371 bp
+= sizeof(struct in_addr
);
374 ND_TCHECK_LEN(bp
, sizeof(struct in6_addr
));
375 addrtostr6(bp
, group_buf
, sizeof(group_buf
));
376 bp
+= sizeof(struct in6_addr
);
384 * Options decoding can go here.
386 switch (pgm_type_val
) {
388 ND_PRINT((ndo
, "NAK "));
391 ND_PRINT((ndo
, "NNAK "));
394 ND_PRINT((ndo
, "NCF "));
399 ND_PRINT((ndo
, "(%s -> %s), seq %u",
400 source_buf
, group_buf
, EXTRACT_BE_U_4(nak
->pgmn_seq
)));
405 const struct pgm_ack
*ack
;
407 ack
= (const struct pgm_ack
*)(pgm
+ 1);
409 ND_PRINT((ndo
, "ACK seq %u",
410 EXTRACT_BE_U_4(ack
->pgma_rx_max_seq
)));
411 bp
= (const u_char
*) (ack
+ 1);
416 ND_PRINT((ndo
, "SPMR"));
420 ND_PRINT((ndo
, "UNKNOWN type 0x%02x", pgm_type_val
));
424 if (EXTRACT_U_1(pgm
->pgm_options
) & PGM_OPT_BIT_PRESENT
) {
427 * make sure there's enough for the first option header
429 if (!ND_TTEST_LEN(bp
, PGM_MIN_OPT_LEN
)) {
430 ND_PRINT((ndo
, "[|OPT]"));
435 * That option header MUST be an OPT_LENGTH option
436 * (see the first paragraph of section 9.1 in RFC 3208).
438 opt_type
= EXTRACT_U_1(bp
);
440 if ((opt_type
& PGM_OPT_MASK
) != PGM_OPT_LENGTH
) {
441 ND_PRINT((ndo
, "[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type
& PGM_OPT_MASK
));
444 opt_len
= EXTRACT_U_1(bp
);
447 ND_PRINT((ndo
, "[Bad OPT_LENGTH option, length %u != 4]", opt_len
));
450 opts_len
= EXTRACT_BE_U_2(bp
);
451 bp
+= sizeof(uint16_t);
453 ND_PRINT((ndo
, "[Bad total option length %u < 4]", opts_len
));
456 ND_PRINT((ndo
, " OPTS LEN %u", opts_len
));
460 if (opts_len
< PGM_MIN_OPT_LEN
) {
461 ND_PRINT((ndo
, "[Total option length leaves no room for final option]"));
464 if (!ND_TTEST_2(bp
)) {
465 ND_PRINT((ndo
, " [|OPT]"));
468 opt_type
= EXTRACT_U_1(bp
);
470 opt_len
= EXTRACT_U_1(bp
);
472 if (opt_len
< PGM_MIN_OPT_LEN
) {
473 ND_PRINT((ndo
, "[Bad option, length %u < %u]", opt_len
,
477 if (opts_len
< opt_len
) {
478 ND_PRINT((ndo
, "[Total option length leaves no room for final option]"));
481 if (!ND_TTEST_LEN(bp
, opt_len
- 2)) {
482 ND_PRINT((ndo
, " [|OPT]"));
486 switch (opt_type
& PGM_OPT_MASK
) {
488 #define PGM_OPT_LENGTH_LEN (2+2)
489 if (opt_len
!= PGM_OPT_LENGTH_LEN
) {
490 ND_PRINT((ndo
, "[Bad OPT_LENGTH option, length %u != %u]",
491 opt_len
, PGM_OPT_LENGTH_LEN
));
494 ND_PRINT((ndo
, " OPTS LEN (extra?) %u", EXTRACT_BE_U_2(bp
)));
496 opts_len
-= PGM_OPT_LENGTH_LEN
;
499 case PGM_OPT_FRAGMENT
:
500 #define PGM_OPT_FRAGMENT_LEN (2+2+4+4+4)
501 if (opt_len
!= PGM_OPT_FRAGMENT_LEN
) {
502 ND_PRINT((ndo
, "[Bad OPT_FRAGMENT option, length %u != %u]",
503 opt_len
, PGM_OPT_FRAGMENT_LEN
));
507 seq
= EXTRACT_BE_U_4(bp
);
509 offset
= EXTRACT_BE_U_4(bp
);
511 len
= EXTRACT_BE_U_4(bp
);
513 ND_PRINT((ndo
, " FRAG seq %u off %u len %u", seq
, offset
, len
));
514 opts_len
-= PGM_OPT_FRAGMENT_LEN
;
517 case PGM_OPT_NAK_LIST
:
519 opt_len
-= 4; /* option header */
520 ND_PRINT((ndo
, " NAK LIST"));
523 ND_PRINT((ndo
, "[Option length not a multiple of 4]"));
527 ND_PRINT((ndo
, " %u", EXTRACT_BE_U_4(bp
)));
535 #define PGM_OPT_JOIN_LEN (2+2+4)
536 if (opt_len
!= PGM_OPT_JOIN_LEN
) {
537 ND_PRINT((ndo
, "[Bad OPT_JOIN option, length %u != %u]",
538 opt_len
, PGM_OPT_JOIN_LEN
));
542 seq
= EXTRACT_BE_U_4(bp
);
544 ND_PRINT((ndo
, " JOIN %u", seq
));
545 opts_len
-= PGM_OPT_JOIN_LEN
;
548 case PGM_OPT_NAK_BO_IVL
:
549 #define PGM_OPT_NAK_BO_IVL_LEN (2+2+4+4)
550 if (opt_len
!= PGM_OPT_NAK_BO_IVL_LEN
) {
551 ND_PRINT((ndo
, "[Bad OPT_NAK_BO_IVL option, length %u != %u]",
552 opt_len
, PGM_OPT_NAK_BO_IVL_LEN
));
556 offset
= EXTRACT_BE_U_4(bp
);
558 seq
= EXTRACT_BE_U_4(bp
);
560 ND_PRINT((ndo
, " BACKOFF ivl %u ivlseq %u", offset
, seq
));
561 opts_len
-= PGM_OPT_NAK_BO_IVL_LEN
;
564 case PGM_OPT_NAK_BO_RNG
:
565 #define PGM_OPT_NAK_BO_RNG_LEN (2+2+4+4)
566 if (opt_len
!= PGM_OPT_NAK_BO_RNG_LEN
) {
567 ND_PRINT((ndo
, "[Bad OPT_NAK_BO_RNG option, length %u != %u]",
568 opt_len
, PGM_OPT_NAK_BO_RNG_LEN
));
572 offset
= EXTRACT_BE_U_4(bp
);
574 seq
= EXTRACT_BE_U_4(bp
);
576 ND_PRINT((ndo
, " BACKOFF max %u min %u", offset
, seq
));
577 opts_len
-= PGM_OPT_NAK_BO_RNG_LEN
;
580 case PGM_OPT_REDIRECT
:
581 #define PGM_OPT_REDIRECT_FIXED_LEN (2+2+2+2)
582 if (opt_len
< PGM_OPT_REDIRECT_FIXED_LEN
) {
583 ND_PRINT((ndo
, "[Bad OPT_REDIRECT option, length %u < %u]",
584 opt_len
, PGM_OPT_REDIRECT_FIXED_LEN
));
588 nla_afnum
= EXTRACT_BE_U_2(bp
);
592 if (opt_len
!= PGM_OPT_REDIRECT_FIXED_LEN
+ sizeof(struct in_addr
)) {
593 ND_PRINT((ndo
, "[Bad OPT_REDIRECT option, length %u != %u + address size]",
594 opt_len
, PGM_OPT_REDIRECT_FIXED_LEN
));
597 ND_TCHECK_LEN(bp
, sizeof(struct in_addr
));
598 addrtostr(bp
, nla_buf
, sizeof(nla_buf
));
599 bp
+= sizeof(struct in_addr
);
600 opts_len
-= PGM_OPT_REDIRECT_FIXED_LEN
+ sizeof(struct in_addr
);
603 if (opt_len
!= PGM_OPT_REDIRECT_FIXED_LEN
+ sizeof(struct in6_addr
)) {
604 ND_PRINT((ndo
, "[Bad OPT_REDIRECT option, length %u != %u + address size]",
605 PGM_OPT_REDIRECT_FIXED_LEN
, opt_len
));
608 ND_TCHECK_LEN(bp
, sizeof(struct in6_addr
));
609 addrtostr6(bp
, nla_buf
, sizeof(nla_buf
));
610 bp
+= sizeof(struct in6_addr
);
611 opts_len
-= PGM_OPT_REDIRECT_FIXED_LEN
+ sizeof(struct in6_addr
);
618 ND_PRINT((ndo
, " REDIRECT %s", nla_buf
));
621 case PGM_OPT_PARITY_PRM
:
622 #define PGM_OPT_PARITY_PRM_LEN (2+2+4)
623 if (opt_len
!= PGM_OPT_PARITY_PRM_LEN
) {
624 ND_PRINT((ndo
, "[Bad OPT_PARITY_PRM option, length %u != %u]",
625 opt_len
, PGM_OPT_PARITY_PRM_LEN
));
629 len
= EXTRACT_BE_U_4(bp
);
631 ND_PRINT((ndo
, " PARITY MAXTGS %u", len
));
632 opts_len
-= PGM_OPT_PARITY_PRM_LEN
;
635 case PGM_OPT_PARITY_GRP
:
636 #define PGM_OPT_PARITY_GRP_LEN (2+2+4)
637 if (opt_len
!= PGM_OPT_PARITY_GRP_LEN
) {
638 ND_PRINT((ndo
, "[Bad OPT_PARITY_GRP option, length %u != %u]",
639 opt_len
, PGM_OPT_PARITY_GRP_LEN
));
643 seq
= EXTRACT_BE_U_4(bp
);
645 ND_PRINT((ndo
, " PARITY GROUP %u", seq
));
646 opts_len
-= PGM_OPT_PARITY_GRP_LEN
;
649 case PGM_OPT_CURR_TGSIZE
:
650 #define PGM_OPT_CURR_TGSIZE_LEN (2+2+4)
651 if (opt_len
!= PGM_OPT_CURR_TGSIZE_LEN
) {
652 ND_PRINT((ndo
, "[Bad OPT_CURR_TGSIZE option, length %u != %u]",
653 opt_len
, PGM_OPT_CURR_TGSIZE_LEN
));
657 len
= EXTRACT_BE_U_4(bp
);
659 ND_PRINT((ndo
, " PARITY ATGS %u", len
));
660 opts_len
-= PGM_OPT_CURR_TGSIZE_LEN
;
663 case PGM_OPT_NBR_UNREACH
:
664 #define PGM_OPT_NBR_UNREACH_LEN (2+2)
665 if (opt_len
!= PGM_OPT_NBR_UNREACH_LEN
) {
666 ND_PRINT((ndo
, "[Bad OPT_NBR_UNREACH option, length %u != %u]",
667 opt_len
, PGM_OPT_NBR_UNREACH_LEN
));
671 ND_PRINT((ndo
, " NBR_UNREACH"));
672 opts_len
-= PGM_OPT_NBR_UNREACH_LEN
;
675 case PGM_OPT_PATH_NLA
:
676 ND_PRINT((ndo
, " PATH_NLA [%u]", opt_len
));
682 #define PGM_OPT_SYN_LEN (2+2)
683 if (opt_len
!= PGM_OPT_SYN_LEN
) {
684 ND_PRINT((ndo
, "[Bad OPT_SYN option, length %u != %u]",
685 opt_len
, PGM_OPT_SYN_LEN
));
689 ND_PRINT((ndo
, " SYN"));
690 opts_len
-= PGM_OPT_SYN_LEN
;
694 #define PGM_OPT_FIN_LEN (2+2)
695 if (opt_len
!= PGM_OPT_FIN_LEN
) {
696 ND_PRINT((ndo
, "[Bad OPT_FIN option, length %u != %u]",
697 opt_len
, PGM_OPT_FIN_LEN
));
701 ND_PRINT((ndo
, " FIN"));
702 opts_len
-= PGM_OPT_FIN_LEN
;
706 #define PGM_OPT_RST_LEN (2+2)
707 if (opt_len
!= PGM_OPT_RST_LEN
) {
708 ND_PRINT((ndo
, "[Bad OPT_RST option, length %u != %u]",
709 opt_len
, PGM_OPT_RST_LEN
));
713 ND_PRINT((ndo
, " RST"));
714 opts_len
-= PGM_OPT_RST_LEN
;
718 ND_PRINT((ndo
, " CR"));
724 #define PGM_OPT_CRQST_LEN (2+2)
725 if (opt_len
!= PGM_OPT_CRQST_LEN
) {
726 ND_PRINT((ndo
, "[Bad OPT_CRQST option, length %u != %u]",
727 opt_len
, PGM_OPT_CRQST_LEN
));
731 ND_PRINT((ndo
, " CRQST"));
732 opts_len
-= PGM_OPT_CRQST_LEN
;
735 case PGM_OPT_PGMCC_DATA
:
736 #define PGM_OPT_PGMCC_DATA_FIXED_LEN (2+2+4+2+2)
737 if (opt_len
< PGM_OPT_PGMCC_DATA_FIXED_LEN
) {
738 ND_PRINT((ndo
, "[Bad OPT_PGMCC_DATA option, length %u < %u]",
739 opt_len
, PGM_OPT_PGMCC_DATA_FIXED_LEN
));
743 offset
= EXTRACT_BE_U_4(bp
);
745 nla_afnum
= EXTRACT_BE_U_2(bp
);
749 if (opt_len
!= PGM_OPT_PGMCC_DATA_FIXED_LEN
+ sizeof(struct in_addr
)) {
750 ND_PRINT((ndo
, "[Bad OPT_PGMCC_DATA option, length %u != %u + address size]",
751 opt_len
, PGM_OPT_PGMCC_DATA_FIXED_LEN
));
754 ND_TCHECK_LEN(bp
, sizeof(struct in_addr
));
755 addrtostr(bp
, nla_buf
, sizeof(nla_buf
));
756 bp
+= sizeof(struct in_addr
);
757 opts_len
-= PGM_OPT_PGMCC_DATA_FIXED_LEN
+ sizeof(struct in_addr
);
760 if (opt_len
!= PGM_OPT_PGMCC_DATA_FIXED_LEN
+ sizeof(struct in6_addr
)) {
761 ND_PRINT((ndo
, "[Bad OPT_PGMCC_DATA option, length %u != %u + address size]",
762 opt_len
, PGM_OPT_PGMCC_DATA_FIXED_LEN
));
765 ND_TCHECK_LEN(bp
, sizeof(struct in6_addr
));
766 addrtostr6(bp
, nla_buf
, sizeof(nla_buf
));
767 bp
+= sizeof(struct in6_addr
);
768 opts_len
-= PGM_OPT_PGMCC_DATA_FIXED_LEN
+ sizeof(struct in6_addr
);
775 ND_PRINT((ndo
, " PGMCC DATA %u %s", offset
, nla_buf
));
778 case PGM_OPT_PGMCC_FEEDBACK
:
779 #define PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN (2+2+4+2+2)
780 if (opt_len
< PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN
) {
781 ND_PRINT((ndo
, "[Bad PGM_OPT_PGMCC_FEEDBACK option, length %u < %u]",
782 opt_len
, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN
));
786 offset
= EXTRACT_BE_U_4(bp
);
788 nla_afnum
= EXTRACT_BE_U_2(bp
);
792 if (opt_len
!= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN
+ sizeof(struct in_addr
)) {
793 ND_PRINT((ndo
, "[Bad OPT_PGMCC_FEEDBACK option, length %u != %u + address size]",
794 opt_len
, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN
));
797 ND_TCHECK_LEN(bp
, sizeof(struct in_addr
));
798 addrtostr(bp
, nla_buf
, sizeof(nla_buf
));
799 bp
+= sizeof(struct in_addr
);
800 opts_len
-= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN
+ sizeof(struct in_addr
);
803 if (opt_len
!= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN
+ sizeof(struct in6_addr
)) {
804 ND_PRINT((ndo
, "[Bad OPT_PGMCC_FEEDBACK option, length %u != %u + address size]",
805 opt_len
, PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN
));
808 ND_TCHECK_LEN(bp
, sizeof(struct in6_addr
));
809 addrtostr6(bp
, nla_buf
, sizeof(nla_buf
));
810 bp
+= sizeof(struct in6_addr
);
811 opts_len
-= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN
+ sizeof(struct in6_addr
);
818 ND_PRINT((ndo
, " PGMCC FEEDBACK %u %s", offset
, nla_buf
));
822 ND_PRINT((ndo
, " OPT_%02X [%u] ", opt_type
, opt_len
));
828 if (opt_type
& PGM_OPT_END
)
833 ND_PRINT((ndo
, " [%u]", length
));
834 if (ndo
->ndo_packettype
== PT_PGM_ZMTP1
&&
835 (pgm_type_val
== PGM_ODATA
|| pgm_type_val
== PGM_RDATA
))
836 zmtp1_datagram_print(ndo
, bp
,
837 EXTRACT_BE_U_2(pgm
->pgm_length
));
842 ND_PRINT((ndo
, "[|pgm]"));
844 ND_PRINT((ndo
, ">"));