2 * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
25 static const char rcsid
[] _U_
=
26 "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.15 2006-09-13 06:31:11 guy Exp $ (LBL)";
33 #include <tcpdump-stdinc.h>
38 #include "interface.h"
39 #include "addrtoname.h"
45 static const char tstr
[] = " [|ospf3]";
47 static const struct tok ospf6_option_values
[] = {
48 { OSPF6_OPTION_V6
, "V6" },
49 { OSPF6_OPTION_E
, "External" },
50 { OSPF6_OPTION_MC
, "Deprecated" },
51 { OSPF6_OPTION_N
, "NSSA" },
52 { OSPF6_OPTION_R
, "Router" },
53 { OSPF6_OPTION_DC
, "Demand Circuit" },
54 { OSPF6_OPTION_AF
, "AFs Support" },
55 { OSPF6_OPTION_L
, "LLS" },
56 { OSPF6_OPTION_AT
, "Authentication Trailer" },
60 static const struct tok ospf6_rla_flag_values
[] = {
61 { RLA_FLAG_B
, "ABR" },
62 { RLA_FLAG_E
, "External" },
63 { RLA_FLAG_V
, "Virtual-Link Endpoint" },
64 { RLA_FLAG_W
, "Wildcard Receiver" },
65 { RLA_FLAG_N
, "NSSA Translator" },
69 static const struct tok ospf6_asla_flag_values
[] = {
70 { ASLA_FLAG_EXTERNAL
, "External Type 2" },
71 { ASLA_FLAG_FWDADDR
, "Forwarding" },
72 { ASLA_FLAG_ROUTETAG
, "Tag" },
76 static const struct tok ospf6_type_values
[] = {
77 { OSPF_TYPE_HELLO
, "Hello" },
78 { OSPF_TYPE_DD
, "Database Description" },
79 { OSPF_TYPE_LS_REQ
, "LS-Request" },
80 { OSPF_TYPE_LS_UPDATE
, "LS-Update" },
81 { OSPF_TYPE_LS_ACK
, "LS-Ack" },
85 static const struct tok ospf6_lsa_values
[] = {
86 { LS_TYPE_ROUTER
, "Router" },
87 { LS_TYPE_NETWORK
, "Network" },
88 { LS_TYPE_INTER_AP
, "Inter-Area Prefix" },
89 { LS_TYPE_INTER_AR
, "Inter-Area Router" },
90 { LS_TYPE_ASE
, "External" },
91 { LS_TYPE_GROUP
, "Deprecated" },
92 { LS_TYPE_NSSA
, "NSSA" },
93 { LS_TYPE_LINK
, "Link" },
94 { LS_TYPE_INTRA_AP
, "Intra-Area Prefix" },
95 { LS_TYPE_INTRA_ATE
, "Intra-Area TE" },
96 { LS_TYPE_GRACE
, "Grace" },
97 { LS_TYPE_RI
, "Router Information" },
98 { LS_TYPE_INTER_ASTE
, "Inter-AS-TE" },
99 { LS_TYPE_L1VPN
, "Layer 1 VPN" },
103 static const struct tok ospf6_ls_scope_values
[] = {
104 { LS_SCOPE_LINKLOCAL
, "Link Local" },
105 { LS_SCOPE_AREA
, "Area Local" },
106 { LS_SCOPE_AS
, "Domain Wide" },
110 static const struct tok ospf6_dd_flag_values
[] = {
111 { OSPF6_DB_INIT
, "Init" },
112 { OSPF6_DB_MORE
, "More" },
113 { OSPF6_DB_MASTER
, "Master" },
114 { OSPF6_DB_M6
, "IPv6 MTU" },
118 static const struct tok ospf6_lsa_prefix_option_values
[] = {
119 { LSA_PREFIX_OPT_NU
, "No Unicast" },
120 { LSA_PREFIX_OPT_LA
, "Local address" },
121 { LSA_PREFIX_OPT_MC
, "Deprecated" },
122 { LSA_PREFIX_OPT_P
, "Propagate" },
123 { LSA_PREFIX_OPT_DN
, "Down" },
127 static const struct tok ospf6_auth_type_str
[] = {
128 { OSPF6_AUTH_TYPE_HMAC
, "HMAC" },
133 ospf6_print_ls_type(register u_int ls_type
, register const rtrid_t
*ls_stateid
)
135 printf("\n\t %s LSA (%d), %s Scope%s, LSA-ID %s",
136 tok2str(ospf6_lsa_values
, "Unknown", ls_type
& LS_TYPE_MASK
),
137 ls_type
& LS_TYPE_MASK
,
138 tok2str(ospf6_ls_scope_values
, "Unknown", ls_type
& LS_SCOPE_MASK
),
139 ls_type
&0x8000 ? ", transitive" : "", /* U-bit */
140 ipaddr_string(ls_stateid
));
144 ospf6_print_lshdr(register const struct lsa6_hdr
*lshp
, const u_char
*dataend
)
146 if ((u_char
*)(lshp
+ 1) > dataend
)
148 TCHECK(lshp
->ls_type
);
149 TCHECK(lshp
->ls_seq
);
151 printf("\n\t Advertising Router %s, seq 0x%08x, age %us, length %u",
152 ipaddr_string(&lshp
->ls_router
),
153 EXTRACT_32BITS(&lshp
->ls_seq
),
154 EXTRACT_16BITS(&lshp
->ls_age
),
155 EXTRACT_16BITS(&lshp
->ls_length
)-(u_int
)sizeof(struct lsa6_hdr
));
157 ospf6_print_ls_type(EXTRACT_16BITS(&lshp
->ls_type
), &lshp
->ls_stateid
);
165 ospf6_print_lsaprefix(const u_int8_t
*tptr
, u_int lsa_length
)
167 const struct lsa6_prefix
*lsapp
= (struct lsa6_prefix
*)tptr
;
169 struct in6_addr prefix
;
171 if (lsa_length
< sizeof (*lsapp
) - 4)
173 lsa_length
-= sizeof (*lsapp
) - 4;
174 TCHECK2(*lsapp
, sizeof (*lsapp
) - 4);
175 wordlen
= (lsapp
->lsa_p_len
+ 31) / 32;
176 if (wordlen
* 4 > sizeof(struct in6_addr
)) {
177 printf(" bogus prefixlen /%d", lsapp
->lsa_p_len
);
180 if (lsa_length
< wordlen
* 4)
182 lsa_length
-= wordlen
* 4;
183 TCHECK2(lsapp
->lsa_p_prefix
, wordlen
* 4);
184 memset(&prefix
, 0, sizeof(prefix
));
185 memcpy(&prefix
, lsapp
->lsa_p_prefix
, wordlen
* 4);
186 printf("\n\t\t%s/%d", ip6addr_string(&prefix
),
188 if (lsapp
->lsa_p_opt
) {
189 printf(", Options [%s]",
190 bittok2str(ospf6_lsa_prefix_option_values
,
191 "none", lsapp
->lsa_p_opt
));
193 printf(", metric %u", EXTRACT_16BITS(&lsapp
->lsa_p_metric
));
194 return sizeof(*lsapp
) - 4 + wordlen
* 4;
202 * Print a single link state advertisement. If truncated return 1, else 0.
205 ospf6_print_lsa(register const struct lsa6
*lsap
, const u_char
*dataend
)
207 register const struct rlalink6
*rlp
;
209 register const struct tos_metric
*tosp
;
211 register const rtrid_t
*ap
;
213 register const struct aslametric
*almp
;
214 register const struct mcla
*mcp
;
216 register const struct llsa
*llsap
;
217 register const struct lsa6_prefix
*lsapp
;
219 register const u_int32_t
*lp
;
221 register u_int prefixes
;
222 register int bytelen
;
223 register u_int length
, lsa_length
;
225 const u_int8_t
*tptr
;
227 if (ospf6_print_lshdr(&lsap
->ls_hdr
, dataend
))
229 TCHECK(lsap
->ls_hdr
.ls_length
);
230 length
= EXTRACT_16BITS(&lsap
->ls_hdr
.ls_length
);
233 * The LSA length includes the length of the header;
234 * it must have a value that's at least that length.
235 * If it does, find the length of what follows the
238 if (length
< sizeof(struct lsa6_hdr
) || (u_char
*)lsap
+ length
> dataend
)
240 lsa_length
= length
- sizeof(struct lsa6_hdr
);
241 tptr
= (u_int8_t
*)lsap
+sizeof(struct lsa6_hdr
);
243 switch (EXTRACT_16BITS(&lsap
->ls_hdr
.ls_type
)) {
244 case LS_TYPE_ROUTER
| LS_SCOPE_AREA
:
245 if (lsa_length
< sizeof (lsap
->lsa_un
.un_rla
.rla_options
))
247 lsa_length
-= sizeof (lsap
->lsa_un
.un_rla
.rla_options
);
248 TCHECK(lsap
->lsa_un
.un_rla
.rla_options
);
249 printf("\n\t Options [%s]",
250 bittok2str(ospf6_option_values
, "none",
251 EXTRACT_32BITS(&lsap
->lsa_un
.un_rla
.rla_options
)));
252 printf(", RLA-Flags [%s]",
253 bittok2str(ospf6_rla_flag_values
, "none",
254 lsap
->lsa_un
.un_rla
.rla_flags
));
256 rlp
= lsap
->lsa_un
.un_rla
.rla_link
;
257 while (lsa_length
!= 0) {
258 if (lsa_length
< sizeof (*rlp
))
260 lsa_length
-= sizeof (*rlp
);
262 switch (rlp
->link_type
) {
264 case RLA_TYPE_VIRTUAL
:
265 printf("\n\t Virtual Link: Neighbor Router-ID %s"
266 "\n\t Neighbor Interface-ID %s, Interface %s",
267 ipaddr_string(&rlp
->link_nrtid
),
268 ipaddr_string(&rlp
->link_nifid
),
269 ipaddr_string(&rlp
->link_ifid
));
272 case RLA_TYPE_ROUTER
:
273 printf("\n\t Neighbor Router-ID %s"
274 "\n\t Neighbor Interface-ID %s, Interface %s",
275 ipaddr_string(&rlp
->link_nrtid
),
276 ipaddr_string(&rlp
->link_nifid
),
277 ipaddr_string(&rlp
->link_ifid
));
280 case RLA_TYPE_TRANSIT
:
281 printf("\n\t Neighbor Network-ID %s"
282 "\n\t Neighbor Interface-ID %s, Interface %s",
283 ipaddr_string(&rlp
->link_nrtid
),
284 ipaddr_string(&rlp
->link_nifid
),
285 ipaddr_string(&rlp
->link_ifid
));
289 printf("\n\t Unknown Router Links Type 0x%02x",
293 printf(", metric %d", EXTRACT_16BITS(&rlp
->link_metric
));
298 case LS_TYPE_NETWORK
| LS_SCOPE_AREA
:
299 if (lsa_length
< sizeof (lsap
->lsa_un
.un_nla
.nla_options
))
301 lsa_length
-= sizeof (lsap
->lsa_un
.un_nla
.nla_options
);
302 TCHECK(lsap
->lsa_un
.un_nla
.nla_options
);
303 printf("\n\t Options [%s]",
304 bittok2str(ospf6_option_values
, "none",
305 EXTRACT_32BITS(&lsap
->lsa_un
.un_nla
.nla_options
)));
307 printf("\n\t Connected Routers:");
308 ap
= lsap
->lsa_un
.un_nla
.nla_router
;
309 while (lsa_length
!= 0) {
310 if (lsa_length
< sizeof (*ap
))
312 lsa_length
-= sizeof (*ap
);
314 printf("\n\t\t%s", ipaddr_string(ap
));
319 case LS_TYPE_INTER_AP
| LS_SCOPE_AREA
:
320 if (lsa_length
< sizeof (lsap
->lsa_un
.un_inter_ap
.inter_ap_metric
))
322 lsa_length
-= sizeof (lsap
->lsa_un
.un_inter_ap
.inter_ap_metric
);
323 TCHECK(lsap
->lsa_un
.un_inter_ap
.inter_ap_metric
);
324 printf(", metric %u",
325 EXTRACT_32BITS(&lsap
->lsa_un
.un_inter_ap
.inter_ap_metric
) & SLA_MASK_METRIC
);
327 tptr
= (u_int8_t
*)lsap
->lsa_un
.un_inter_ap
.inter_ap_prefix
;
328 while (lsa_length
!= 0) {
329 bytelen
= ospf6_print_lsaprefix(tptr
, lsa_length
);
332 lsa_length
-= bytelen
;
337 case LS_TYPE_ASE
| LS_SCOPE_AS
:
338 if (lsa_length
< sizeof (lsap
->lsa_un
.un_asla
.asla_metric
))
340 lsa_length
-= sizeof (lsap
->lsa_un
.un_asla
.asla_metric
);
341 TCHECK(lsap
->lsa_un
.un_asla
.asla_metric
);
342 flags32
= EXTRACT_32BITS(&lsap
->lsa_un
.un_asla
.asla_metric
);
343 printf("\n\t Flags [%s]",
344 bittok2str(ospf6_asla_flag_values
, "none", flags32
));
346 EXTRACT_32BITS(&lsap
->lsa_un
.un_asla
.asla_metric
) &
349 tptr
= (u_int8_t
*)lsap
->lsa_un
.un_asla
.asla_prefix
;
350 lsapp
= (struct lsa6_prefix
*)tptr
;
351 bytelen
= ospf6_print_lsaprefix(tptr
, lsa_length
);
354 lsa_length
-= bytelen
;
357 if ((flags32
& ASLA_FLAG_FWDADDR
) != 0) {
358 struct in6_addr
*fwdaddr6
;
360 fwdaddr6
= (struct in6_addr
*)tptr
;
361 if (lsa_length
< sizeof (*fwdaddr6
))
363 lsa_length
-= sizeof (*fwdaddr6
);
365 printf(" forward %s",
366 ip6addr_string(fwdaddr6
));
367 tptr
+= sizeof(*fwdaddr6
);
370 if ((flags32
& ASLA_FLAG_ROUTETAG
) != 0) {
371 if (lsa_length
< sizeof (u_int32_t
))
373 lsa_length
-= sizeof (u_int32_t
);
374 TCHECK(*(u_int32_t
*)tptr
);
376 ipaddr_string((u_int32_t
*)tptr
));
377 tptr
+= sizeof(u_int32_t
);
380 if (lsapp
->lsa_p_metric
) {
381 if (lsa_length
< sizeof (u_int32_t
))
383 lsa_length
-= sizeof (u_int32_t
);
384 TCHECK(*(u_int32_t
*)tptr
);
385 printf(" RefLSID: %s",
386 ipaddr_string((u_int32_t
*)tptr
));
387 tptr
+= sizeof(u_int32_t
);
393 llsap
= &lsap
->lsa_un
.un_llsa
;
394 if (lsa_length
< sizeof (llsap
->llsa_priandopt
))
396 lsa_length
-= sizeof (llsap
->llsa_priandopt
);
397 TCHECK(llsap
->llsa_priandopt
);
398 printf("\n\t Options [%s]",
399 bittok2str(ospf6_option_values
, "none",
400 EXTRACT_32BITS(&llsap
->llsa_options
)));
402 if (lsa_length
< sizeof (llsap
->llsa_lladdr
) + sizeof (llsap
->llsa_nprefix
))
404 lsa_length
-= sizeof (llsap
->llsa_lladdr
) + sizeof (llsap
->llsa_nprefix
);
405 prefixes
= EXTRACT_32BITS(&llsap
->llsa_nprefix
);
406 printf("\n\t Priority %d, Link-local address %s, Prefixes %d:",
407 llsap
->llsa_priority
,
408 ip6addr_string(&llsap
->llsa_lladdr
),
411 tptr
= (u_int8_t
*)llsap
->llsa_prefix
;
412 while (prefixes
> 0) {
413 bytelen
= ospf6_print_lsaprefix(tptr
, lsa_length
);
417 lsa_length
-= bytelen
;
422 case LS_TYPE_INTRA_AP
| LS_SCOPE_AREA
:
423 /* Intra-Area-Prefix LSA */
424 if (lsa_length
< sizeof (lsap
->lsa_un
.un_intra_ap
.intra_ap_rtid
))
426 lsa_length
-= sizeof (lsap
->lsa_un
.un_intra_ap
.intra_ap_rtid
);
427 TCHECK(lsap
->lsa_un
.un_intra_ap
.intra_ap_rtid
);
429 EXTRACT_16BITS(&lsap
->lsa_un
.un_intra_ap
.intra_ap_lstype
),
430 &lsap
->lsa_un
.un_intra_ap
.intra_ap_lsid
);
432 if (lsa_length
< sizeof (lsap
->lsa_un
.un_intra_ap
.intra_ap_nprefix
))
434 lsa_length
-= sizeof (lsap
->lsa_un
.un_intra_ap
.intra_ap_nprefix
);
435 TCHECK(lsap
->lsa_un
.un_intra_ap
.intra_ap_nprefix
);
436 prefixes
= EXTRACT_16BITS(&lsap
->lsa_un
.un_intra_ap
.intra_ap_nprefix
);
437 printf("\n\t Prefixes %d:", prefixes
);
439 tptr
= (u_int8_t
*)lsap
->lsa_un
.un_intra_ap
.intra_ap_prefix
;
440 while (prefixes
> 0) {
441 bytelen
= ospf6_print_lsaprefix(tptr
, lsa_length
);
445 lsa_length
-= bytelen
;
450 case LS_TYPE_GRACE
| LS_SCOPE_LINKLOCAL
:
451 if (ospf_print_grace_lsa(tptr
, lsa_length
) == -1) {
456 case LS_TYPE_INTRA_ATE
| LS_SCOPE_LINKLOCAL
:
457 if (ospf_print_te_lsa(tptr
, lsa_length
) == -1) {
463 if(!print_unknown_data(tptr
,
477 ospf6_decode_v3(register const struct ospf6hdr
*op
,
478 register const u_char
*dataend
)
480 register const rtrid_t
*ap
;
481 register const struct lsr6
*lsrp
;
482 register const struct lsa6_hdr
*lshp
;
483 register const struct lsa6
*lsap
;
486 switch (op
->ospf6_type
) {
488 case OSPF_TYPE_HELLO
:
489 printf("\n\tOptions [%s]",
490 bittok2str(ospf6_option_values
, "none",
491 EXTRACT_32BITS(&op
->ospf6_hello
.hello_options
)));
493 TCHECK(op
->ospf6_hello
.hello_deadint
);
494 printf("\n\t Hello Timer %us, Dead Timer %us, Interface-ID %s, Priority %u",
495 EXTRACT_16BITS(&op
->ospf6_hello
.hello_helloint
),
496 EXTRACT_16BITS(&op
->ospf6_hello
.hello_deadint
),
497 ipaddr_string(&op
->ospf6_hello
.hello_ifid
),
498 op
->ospf6_hello
.hello_priority
);
500 TCHECK(op
->ospf6_hello
.hello_dr
);
501 if (op
->ospf6_hello
.hello_dr
!= 0)
502 printf("\n\t Designated Router %s",
503 ipaddr_string(&op
->ospf6_hello
.hello_dr
));
504 TCHECK(op
->ospf6_hello
.hello_bdr
);
505 if (op
->ospf6_hello
.hello_bdr
!= 0)
506 printf(", Backup Designated Router %s",
507 ipaddr_string(&op
->ospf6_hello
.hello_bdr
));
509 printf("\n\t Neighbor List:");
510 ap
= op
->ospf6_hello
.hello_neighbor
;
511 while ((u_char
*)ap
< dataend
) {
513 printf("\n\t %s", ipaddr_string(ap
));
520 TCHECK(op
->ospf6_db
.db_options
);
521 printf("\n\tOptions [%s]",
522 bittok2str(ospf6_option_values
, "none",
523 EXTRACT_32BITS(&op
->ospf6_db
.db_options
)));
524 TCHECK(op
->ospf6_db
.db_flags
);
525 printf(", DD Flags [%s]",
526 bittok2str(ospf6_dd_flag_values
,"none",op
->ospf6_db
.db_flags
));
528 TCHECK(op
->ospf6_db
.db_seq
);
529 printf(", MTU %u, DD-Sequence 0x%08x",
530 EXTRACT_16BITS(&op
->ospf6_db
.db_mtu
),
531 EXTRACT_32BITS(&op
->ospf6_db
.db_seq
));
533 /* Print all the LS adv's */
534 lshp
= op
->ospf6_db
.db_lshdr
;
535 while ((u_char
*)lshp
< dataend
) {
536 if (ospf6_print_lshdr(lshp
++, dataend
))
542 case OSPF_TYPE_LS_REQ
:
544 lsrp
= op
->ospf6_lsr
;
545 while ((u_char
*)lsrp
< dataend
) {
547 printf("\n\t Advertising Router %s",
548 ipaddr_string(&lsrp
->ls_router
));
549 ospf6_print_ls_type(EXTRACT_16BITS(&lsrp
->ls_type
),
556 case OSPF_TYPE_LS_UPDATE
:
558 lsap
= op
->ospf6_lsu
.lsu_lsa
;
559 TCHECK(op
->ospf6_lsu
.lsu_count
);
560 i
= EXTRACT_32BITS(&op
->ospf6_lsu
.lsu_count
);
561 while ((u_char
*)lsap
< dataend
&& i
--) {
562 if (ospf6_print_lsa(lsap
, dataend
))
564 lsap
= (struct lsa6
*)((u_char
*)lsap
+
565 EXTRACT_16BITS(&lsap
->ls_hdr
.ls_length
));
571 case OSPF_TYPE_LS_ACK
:
573 lshp
= op
->ospf6_lsa
.lsa_lshdr
;
574 while ((u_char
*)lshp
< dataend
) {
575 if (ospf6_print_lshdr(lshp
++, dataend
))
589 /* RFC5613 Section 2.2 (w/o the TLVs) */
591 ospf6_print_lls(const u_char
*cp
, const u_int len
)
597 if (len
< OSPF_LLS_HDRLEN
)
601 printf("\n\tLLS Checksum 0x%04x", EXTRACT_16BITS(cp
));
603 /* LLS Data Length */
605 llsdatalen
= EXTRACT_16BITS(cp
);
606 printf(", Data Length %u", llsdatalen
);
607 if (llsdatalen
< OSPF_LLS_HDRLEN
|| llsdatalen
> len
)
611 TCHECK2(*cp
, llsdatalen
- OSPF_LLS_HDRLEN
);
612 /* FIXME: code in print-ospf.c can be reused to decode the TLVs */
619 /* RFC6506 Section 4.1 */
621 ospf6_decode_at(const u_char
*cp
, const u_int len
)
623 uint16_t authdatalen
;
627 if (len
< OSPF6_AT_HDRLEN
)
629 /* Authentication Type */
631 printf("\n\tAuthentication Type %s", tok2str(ospf6_auth_type_str
, "unknown (0x%04x)", EXTRACT_16BITS(cp
)));
635 authdatalen
= EXTRACT_16BITS(cp
);
636 printf(", Length %u", authdatalen
);
637 if (authdatalen
< OSPF6_AT_HDRLEN
|| authdatalen
> len
)
643 /* Security Association ID */
645 printf(", SAID %u", EXTRACT_16BITS(cp
));
647 /* Cryptographic Sequence Number (High-Order 32 Bits) */
649 printf(", CSN 0x%08x", EXTRACT_32BITS(cp
));
651 /* Cryptographic Sequence Number (Low-Order 32 Bits) */
653 printf(":%08x", EXTRACT_32BITS(cp
));
655 /* Authentication Data */
656 TCHECK2(*cp
, authdatalen
- OSPF6_AT_HDRLEN
);
658 print_unknown_data(cp
, "\n\tAuthentication Data ", authdatalen
- OSPF6_AT_HDRLEN
);
665 /* The trailing data may include LLS and/or AT data (in this specific order).
666 * LLS data may be present only in Hello and DBDesc packets with the L-bit set.
667 * AT data may be present in Hello and DBDesc packets with the AT-bit set or in
668 * any other packet type, thus decode the AT data regardless of the AT-bit.
671 ospf6_decode_v3_trailer(const struct ospf6hdr
*op
, const u_char
*cp
, const unsigned len
)
674 u_char lls_hello
= op
->ospf6_type
== OSPF_TYPE_HELLO
&&
675 op
->ospf6_hello
.hello_options
& OSPF6_OPTION_L
;
676 u_char lls_dd
= op
->ospf6_type
== OSPF_TYPE_DD
&&
677 op
->ospf6_db
.db_options
& OSPF6_OPTION_L
;
679 if ((lls_hello
|| lls_dd
) && (llslen
= ospf6_print_lls(cp
, len
)) < 0)
681 return ospf6_decode_at(cp
+ llslen
, len
- llslen
);
688 ospf6_print(register const u_char
*bp
, register u_int length
)
690 register const struct ospf6hdr
*op
;
691 register const u_char
*dataend
;
692 register const char *cp
;
695 op
= (struct ospf6hdr
*)bp
;
697 /* If the type is valid translate it, or just print the type */
698 /* value. If it's not valid, say so and return */
699 TCHECK(op
->ospf6_type
);
700 cp
= tok2str(ospf6_type_values
, "unknown packet type (%u)", op
->ospf6_type
);
701 printf("OSPFv%u, %s, length %d", op
->ospf6_version
, cp
, length
);
706 if(!vflag
) { /* non verbose - so lets bail out here */
710 /* OSPFv3 data always comes first and optional trailing data may follow. */
711 TCHECK(op
->ospf6_len
);
712 datalen
= EXTRACT_16BITS(&op
->ospf6_len
);
713 if (datalen
> length
) {
714 printf(" [len %d]", datalen
);
717 dataend
= bp
+ datalen
;
719 TCHECK(op
->ospf6_routerid
);
720 printf("\n\tRouter-ID %s", ipaddr_string(&op
->ospf6_routerid
));
722 TCHECK(op
->ospf6_areaid
);
723 if (op
->ospf6_areaid
!= 0)
724 printf(", Area %s", ipaddr_string(&op
->ospf6_areaid
));
726 printf(", Backbone Area");
727 TCHECK(op
->ospf6_instanceid
);
728 if (op
->ospf6_instanceid
)
729 printf(", Instance %u", op
->ospf6_instanceid
);
731 /* Do rest according to version. */
732 switch (op
->ospf6_version
) {
736 if (ospf6_decode_v3(op
, dataend
) ||
737 ospf6_decode_v3_trailer(op
, dataend
, length
- datalen
))
740 } /* end switch on version */