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)
24 /* \summary: Open Shortest Path First (OSPF) printer */
30 #include "netdissect-stdinc.h"
32 #include "netdissect.h"
33 #include "addrtoname.h"
40 static const struct tok ospf_option_values
[] = {
41 { OSPF_OPTION_MT
, "MultiTopology" }, /* draft-ietf-ospf-mt-09 */
42 { OSPF_OPTION_E
, "External" },
43 { OSPF_OPTION_MC
, "Multicast" },
44 { OSPF_OPTION_NP
, "NSSA" },
45 { OSPF_OPTION_L
, "LLS" },
46 { OSPF_OPTION_DC
, "Demand Circuit" },
47 { OSPF_OPTION_O
, "Opaque" },
48 { OSPF_OPTION_DN
, "Up/Down" },
52 static const struct tok ospf_authtype_values
[] = {
53 { OSPF_AUTH_NONE
, "none" },
54 { OSPF_AUTH_SIMPLE
, "simple" },
55 { OSPF_AUTH_MD5
, "MD5" },
59 static const struct tok ospf_rla_flag_values
[] = {
60 { RLA_FLAG_B
, "ABR" },
61 { RLA_FLAG_E
, "ASBR" },
62 { RLA_FLAG_V
, "Virtual" },
63 { RLA_FLAG_W
, "Wildcard" },
64 { RLA_FLAG_NT
, "Nt" },
65 { RLA_FLAG_H
, "Host" },
69 static const struct tok type2str
[] = {
70 { OSPF_TYPE_HELLO
, "Hello" },
71 { OSPF_TYPE_DD
, "Database Description" },
72 { OSPF_TYPE_LS_REQ
, "LS-Request" },
73 { OSPF_TYPE_LS_UPDATE
, "LS-Update" },
74 { OSPF_TYPE_LS_ACK
, "LS-Ack" },
78 static const struct tok lsa_values
[] = {
79 { LS_TYPE_ROUTER
, "Router" },
80 { LS_TYPE_NETWORK
, "Network" },
81 { LS_TYPE_SUM_IP
, "Summary" },
82 { LS_TYPE_SUM_ABR
, "ASBR Summary" },
83 { LS_TYPE_ASE
, "External" },
84 { LS_TYPE_GROUP
, "Multicast Group" },
85 { LS_TYPE_NSSA
, "NSSA" },
86 { LS_TYPE_OPAQUE_LL
, "Link Local Opaque" },
87 { LS_TYPE_OPAQUE_AL
, "Area Local Opaque" },
88 { LS_TYPE_OPAQUE_DW
, "Domain Wide Opaque" },
92 static const struct tok ospf_dd_flag_values
[] = {
93 { OSPF_DB_INIT
, "Init" },
94 { OSPF_DB_MORE
, "More" },
95 { OSPF_DB_MASTER
, "Master" },
96 { OSPF_DB_RESYNC
, "OOBResync" },
100 static const struct tok lsa_opaque_values
[] = {
101 { LS_OPAQUE_TYPE_TE
, "Traffic Engineering" },
102 { LS_OPAQUE_TYPE_GRACE
, "Graceful restart" },
103 { LS_OPAQUE_TYPE_RI
, "Router Information" },
104 { LS_OPAQUE_TYPE_EP
, "Extended Prefix" },
108 static const struct tok lsa_opaque_ri_sid_subtlv_values
[] = {
109 { LS_OPAQUE_RI_SUBTLV_SID_LABEL
, "SID/Label" },
113 static const struct tok lsa_opaque_te_tlv_values
[] = {
114 { LS_OPAQUE_TE_TLV_ROUTER
, "Router Address" },
115 { LS_OPAQUE_TE_TLV_LINK
, "Link" },
119 static const struct tok lsa_opaque_ep_extd_prefix_subtlv_values
[] = {
120 { LS_OPAQUE_EP_SUBTLV_PREFIX_SID
, "Prefix-SID" },
124 static const struct tok ep_range_tlv_prefix_sid_subtlv_flag_values
[] = {
126 { 0x20, "Mapping-Server"},
127 { 0x10, "Explicit-NULL"},
134 static const struct tok lsa_opaque_ep_route_type_values
[] = {
135 { 0, "Unspecified" },
138 { 5, "AS External" },
139 { 7, "NSSA External" },
143 static const struct tok lsa_opaque_ep_tlv_values
[] = {
144 { LS_OPAQUE_EP_EXTD_PREFIX_TLV
, "Extended Prefix" },
145 { LS_OPAQUE_EP_EXTD_PREFIX_RANGE_TLV
, "Extended Prefix Range" },
149 static const struct tok ep_tlv_flag_values
[] = {
150 { 0x80, "Inter-Area"},
154 static const struct tok lsa_opaque_te_link_tlv_subtlv_values
[] = {
155 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE
, "Link Type" },
156 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID
, "Link ID" },
157 { LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP
, "Local Interface IP address" },
158 { LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP
, "Remote Interface IP address" },
159 { LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC
, "Traffic Engineering Metric" },
160 { LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW
, "Maximum Bandwidth" },
161 { LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW
, "Maximum Reservable Bandwidth" },
162 { LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW
, "Unreserved Bandwidth" },
163 { LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP
, "Administrative Group" },
164 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID
, "Link Local/Remote Identifier" },
165 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE
, "Link Protection Type" },
166 { LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR
, "Interface Switching Capability" },
167 { LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP
, "Shared Risk Link Group" },
168 { LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS
, "Bandwidth Constraints" },
172 static const struct tok lsa_opaque_grace_tlv_values
[] = {
173 { LS_OPAQUE_GRACE_TLV_PERIOD
, "Grace Period" },
174 { LS_OPAQUE_GRACE_TLV_REASON
, "Graceful restart Reason" },
175 { LS_OPAQUE_GRACE_TLV_INT_ADDRESS
, "IPv4 interface address" },
179 static const struct tok lsa_opaque_grace_tlv_reason_values
[] = {
180 { LS_OPAQUE_GRACE_TLV_REASON_UNKNOWN
, "Unknown" },
181 { LS_OPAQUE_GRACE_TLV_REASON_SW_RESTART
, "Software Restart" },
182 { LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE
, "Software Reload/Upgrade" },
183 { LS_OPAQUE_GRACE_TLV_REASON_CP_SWITCH
, "Control Processor Switch" },
187 static const struct tok lsa_opaque_te_tlv_link_type_sub_tlv_values
[] = {
188 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP
, "Point-to-point" },
189 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA
, "Multi-Access" },
193 static const struct tok lsa_opaque_ri_tlv_values
[] = {
194 { LS_OPAQUE_RI_TLV_CAP
, "Router Capabilities" },
195 { LS_OPAQUE_RI_TLV_HOSTNAME
, "Hostname" },
196 { LS_OPAQUE_RI_TLV_SID_LABEL_RANGE
, "SID/Label Range" },
200 static const struct tok lsa_opaque_ri_tlv_cap_values
[] = {
205 { 16, "graceful restart capable" },
206 { 32, "graceful restart helper" },
207 { 64, "Stub router support" },
208 { 128, "Traffic engineering" },
209 { 256, "p2p over LAN" },
210 { 512, "path computation server" },
214 static const struct tok ospf_lls_tlv_values
[] = {
215 { OSPF_LLS_EO
, "Extended Options" },
216 { OSPF_LLS_MD5
, "MD5 Authentication" },
220 static const struct tok ospf_lls_eo_options
[] = {
221 { OSPF_LLS_EO_LR
, "LSDB resync" },
222 { OSPF_LLS_EO_RS
, "Restart" },
227 ospf_grace_lsa_print(netdissect_options
*ndo
,
228 const u_char
*tptr
, u_int ls_length
)
230 u_int tlv_type
, tlv_length
;
233 while (ls_length
> 0) {
236 ND_PRINT("\n\t Remaining LS length %u < 4", ls_length
);
239 tlv_type
= GET_BE_U_2(tptr
);
240 tlv_length
= GET_BE_U_2(tptr
+ 2);
244 ND_PRINT("\n\t %s TLV (%u), length %u, value: ",
245 tok2str(lsa_opaque_grace_tlv_values
,"unknown",tlv_type
),
249 if (tlv_length
> ls_length
) {
250 ND_PRINT("\n\t Bogus length %u > %u", tlv_length
,
255 /* Infinite loop protection. */
256 if (tlv_type
== 0 || tlv_length
==0) {
257 nd_print_invalid(ndo
);
261 ND_TCHECK_LEN(tptr
, tlv_length
);
264 case LS_OPAQUE_GRACE_TLV_PERIOD
:
265 if (tlv_length
!= 4) {
266 ND_PRINT("\n\t Bogus length %u != 4", tlv_length
);
269 ND_PRINT("%us", GET_BE_U_4(tptr
));
272 case LS_OPAQUE_GRACE_TLV_REASON
:
273 if (tlv_length
!= 1) {
274 ND_PRINT("\n\t Bogus length %u != 1", tlv_length
);
278 tok2str(lsa_opaque_grace_tlv_reason_values
, "Unknown", GET_U_1(tptr
)),
282 case LS_OPAQUE_GRACE_TLV_INT_ADDRESS
:
283 if (tlv_length
!= 4) {
284 ND_PRINT("\n\t Bogus length %u != 4", tlv_length
);
287 ND_PRINT("%s", GET_IPADDR_STRING(tptr
));
291 if (ndo
->ndo_vflag
<= 1) {
292 if (!print_unknown_data(ndo
, tptr
, "\n\t ", tlv_length
))
298 /* in OSPF everything has to be 32-bit aligned, including TLVs */
299 if (tlv_length
%4 != 0)
300 tlv_length
+=4-(tlv_length
%4);
301 ls_length
-=tlv_length
;
311 ospf_te_lsa_print(netdissect_options
*ndo
,
312 const u_char
*tptr
, u_int ls_length
)
314 u_int tlv_type
, tlv_length
, subtlv_type
, subtlv_length
;
315 u_int priority_level
, te_class
, count_srlg
;
316 union { /* int to float conversion buffer for several subTLVs */
321 while (ls_length
!= 0) {
324 ND_PRINT("\n\t Remaining LS length %u < 4", ls_length
);
327 tlv_type
= GET_BE_U_2(tptr
);
328 tlv_length
= GET_BE_U_2(tptr
+ 2);
332 ND_PRINT("\n\t %s TLV (%u), length: %u",
333 tok2str(lsa_opaque_te_tlv_values
,"unknown",tlv_type
),
337 if (tlv_length
> ls_length
) {
338 ND_PRINT("\n\t Bogus length %u > %u", tlv_length
,
343 /* Infinite loop protection. */
344 if (tlv_type
== 0 || tlv_length
==0) {
345 nd_print_invalid(ndo
);
350 case LS_OPAQUE_TE_TLV_LINK
:
351 while (tlv_length
!= 0) {
352 if (tlv_length
< 4) {
353 ND_PRINT("\n\t Remaining TLV length %u < 4",
357 subtlv_type
= GET_BE_U_2(tptr
);
358 subtlv_length
= GET_BE_U_2(tptr
+ 2);
362 /* Infinite loop protection */
363 if (subtlv_type
== 0 || subtlv_length
== 0)
366 ND_PRINT("\n\t %s subTLV (%u), length: %u",
367 tok2str(lsa_opaque_te_link_tlv_subtlv_values
,"unknown",subtlv_type
),
371 if (tlv_length
< subtlv_length
) {
372 ND_PRINT("\n\t Remaining TLV length %u < %u",
373 tlv_length
+ 4, subtlv_length
+ 4);
376 ND_TCHECK_LEN(tptr
, subtlv_length
);
377 switch(subtlv_type
) {
378 case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP
:
379 if (subtlv_length
!= 4) {
383 ND_PRINT(", 0x%08x", GET_BE_U_4(tptr
));
385 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID
:
386 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID
:
387 if (subtlv_length
!= 4 && subtlv_length
!= 8) {
388 ND_PRINT(" != 4 && != 8");
391 ND_PRINT(", %s (0x%08x)",
392 GET_IPADDR_STRING(tptr
),
394 if (subtlv_length
== 8) /* rfc4203 */
395 ND_PRINT(", %s (0x%08x)",
396 GET_IPADDR_STRING(tptr
+4),
397 GET_BE_U_4(tptr
+ 4));
399 case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP
:
400 case LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP
:
401 if (subtlv_length
!= 4) {
405 ND_PRINT(", %s", GET_IPADDR_STRING(tptr
));
407 case LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW
:
408 case LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW
:
409 if (subtlv_length
!= 4) {
413 bw
.i
= GET_BE_U_4(tptr
);
414 ND_PRINT(", %.3f Mbps", bw
.f
* 8 / 1000000);
416 case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW
:
417 if (subtlv_length
!= 32) {
421 for (te_class
= 0; te_class
< 8; te_class
++) {
422 bw
.i
= GET_BE_U_4(tptr
+ te_class
* 4);
423 ND_PRINT("\n\t\tTE-Class %u: %.3f Mbps",
428 case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS
:
429 if (subtlv_length
< 4) {
433 /* BC Model Id (1 octet) + Reserved (3 octets) */
434 ND_PRINT("\n\t\tBandwidth Constraints Model ID: %s (%u)",
435 tok2str(diffserv_te_bc_values
, "unknown", GET_U_1(tptr
)),
437 if (subtlv_length
% 4 != 0) {
438 ND_PRINT("\n\t\tlength %u != N x 4", subtlv_length
);
441 if (subtlv_length
> 36) {
442 ND_PRINT("\n\t\tlength %u > 36", subtlv_length
);
445 /* decode BCs until the subTLV ends */
446 for (te_class
= 0; te_class
< (subtlv_length
-4)/4; te_class
++) {
447 bw
.i
= GET_BE_U_4(tptr
+ 4 + te_class
* 4);
448 ND_PRINT("\n\t\t Bandwidth constraint CT%u: %.3f Mbps",
453 case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC
:
454 if (subtlv_length
!= 4) {
458 ND_PRINT(", Metric %u", GET_BE_U_4(tptr
));
460 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE
:
461 /* Protection Cap (1 octet) + Reserved ((3 octets) */
462 if (subtlv_length
!= 4) {
467 bittok2str(gmpls_link_prot_values
, "none", GET_U_1(tptr
)));
469 case LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR
:
470 if (subtlv_length
< 36) {
474 /* Switching Cap (1 octet) + Encoding (1) + Reserved (2) */
475 ND_PRINT("\n\t\tInterface Switching Capability: %s",
476 tok2str(gmpls_switch_cap_values
, "Unknown", GET_U_1((tptr
))));
477 ND_PRINT("\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:",
478 tok2str(gmpls_encoding_values
, "Unknown", GET_U_1((tptr
+ 1))));
479 for (priority_level
= 0; priority_level
< 8; priority_level
++) {
480 bw
.i
= GET_BE_U_4(tptr
+ 4 + (priority_level
* 4));
481 ND_PRINT("\n\t\t priority level %u: %.3f Mbps",
486 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE
:
487 if (subtlv_length
!= 1) {
491 ND_PRINT(", %s (%u)",
492 tok2str(lsa_opaque_te_tlv_link_type_sub_tlv_values
,"unknown",GET_U_1(tptr
)),
496 case LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP
:
497 if (subtlv_length
% 4 != 0) {
498 ND_PRINT(" != N x 4");
501 count_srlg
= subtlv_length
/ 4;
503 ND_PRINT("\n\t\t Shared risk group: ");
504 while (count_srlg
> 0) {
505 bw
.i
= GET_BE_U_4(tptr
);
506 ND_PRINT("%u", bw
.i
);
515 if (ndo
->ndo_vflag
<= 1) {
516 if (!print_unknown_data(ndo
, tptr
, "\n\t\t", subtlv_length
))
521 /* in OSPF everything has to be 32-bit aligned, including subTLVs */
522 if (subtlv_length
%4 != 0)
523 subtlv_length
+=4-(subtlv_length
%4);
525 if (tlv_length
< subtlv_length
) {
526 ND_PRINT("\n\t Remaining TLV length %u < %u",
527 tlv_length
+ 4, subtlv_length
+ 4);
530 tlv_length
-=subtlv_length
;
536 case LS_OPAQUE_TE_TLV_ROUTER
:
537 if (tlv_length
< 4) {
538 ND_PRINT("\n\t TLV length %u < 4", tlv_length
);
541 ND_PRINT(", %s", GET_IPADDR_STRING(tptr
));
545 if (ndo
->ndo_vflag
<= 1) {
546 if (!print_unknown_data(ndo
, tptr
, "\n\t ", tlv_length
))
551 /* in OSPF everything has to be 32-bit aligned, including TLVs */
552 if (tlv_length
%4 != 0)
553 tlv_length
+=4-(tlv_length
%4);
554 if (tlv_length
> ls_length
) {
555 ND_PRINT("\n\t Bogus padded length %u > %u", tlv_length
,
559 ls_length
-=tlv_length
;
566 nd_print_invalid(ndo
);
571 ospf_print_lshdr(netdissect_options
*ndo
,
572 const struct lsa_hdr
*lshp
)
577 ls_length
= GET_BE_U_2(lshp
->ls_length
);
578 if (ls_length
< sizeof(struct lsa_hdr
)) {
579 ND_PRINT("\n\t Bogus length %u < header (%zu)", ls_length
,
580 sizeof(struct lsa_hdr
));
583 ND_PRINT("\n\t Advertising Router %s, seq 0x%08x, age %us, length %zu",
584 GET_IPADDR_STRING(lshp
->ls_router
),
585 GET_BE_U_4(lshp
->ls_seq
),
586 GET_BE_U_2(lshp
->ls_age
),
587 ls_length
- sizeof(struct lsa_hdr
));
588 ls_type
= GET_U_1(lshp
->ls_type
);
590 /* the LSA header for opaque LSAs was slightly changed */
591 case LS_TYPE_OPAQUE_LL
:
592 case LS_TYPE_OPAQUE_AL
:
593 case LS_TYPE_OPAQUE_DW
:
594 ND_PRINT("\n\t %s LSA (%u), Opaque-Type %s LSA (%u), Opaque-ID %u",
595 tok2str(lsa_values
,"unknown",ls_type
),
598 tok2str(lsa_opaque_values
,
600 GET_U_1(lshp
->un_lsa_id
.opaque_field
.opaque_type
)),
601 GET_U_1(lshp
->un_lsa_id
.opaque_field
.opaque_type
),
602 GET_BE_U_3(lshp
->un_lsa_id
.opaque_field
.opaque_id
)
607 /* all other LSA types use regular style LSA headers */
609 ND_PRINT("\n\t %s LSA (%u), LSA-ID: %s",
610 tok2str(lsa_values
,"unknown",ls_type
),
612 GET_IPADDR_STRING(lshp
->un_lsa_id
.lsa_id
));
615 ND_PRINT("\n\t Options: [%s]",
616 bittok2str(ospf_option_values
, "none", GET_U_1(lshp
->ls_options
)));
621 /* draft-ietf-ospf-mt-09 */
622 static const struct tok ospf_topology_values
[] = {
630 * Print all the per-topology metrics.
633 ospf_print_tos_metrics(netdissect_options
*ndo
,
634 const union un_tos
*tos
)
640 toscount
= GET_U_1(tos
->link
.link_tos_count
)+1;
644 * All but the first metric contain a valid topology id.
646 while (toscount
!= 0) {
647 tos_type
= GET_U_1(tos
->metrics
.tos_type
);
648 ND_PRINT("\n\t\ttopology %s (%u), metric %u",
649 tok2str(ospf_topology_values
, "Unknown",
650 metric_count
? tos_type
: 0),
651 metric_count
? tos_type
: 0,
652 GET_BE_U_2(tos
->metrics
.tos_metric
));
660 ospf_print_ri_lsa_sid_label_range_tlv(netdissect_options
*ndo
, const uint8_t *tptr
,
663 u_int subtlv_type
, subtlv_length
;
665 while (tlv_length
>= 4) {
667 subtlv_type
= GET_BE_U_2(tptr
);
668 subtlv_length
= GET_BE_U_2(tptr
+2);
672 /* Infinite loop protection. */
673 if (subtlv_type
== 0 || subtlv_length
== 0) {
674 nd_print_invalid(ndo
);
678 ND_PRINT("\n\t %s subTLV (%u), length: %u, value: ",
679 tok2str(lsa_opaque_ri_sid_subtlv_values
,"unknown",subtlv_type
),
683 switch (subtlv_type
) {
684 case LS_OPAQUE_RI_SUBTLV_SID_LABEL
:
685 if (subtlv_length
== 3) {
686 ND_PRINT("\n\t\tLabel: %u", GET_BE_U_3(tptr
));
687 } else if (subtlv_length
== 4) {
688 ND_PRINT("\n\t\tSID: %u", GET_BE_U_4(tptr
));
690 ND_PRINT("\n\t\tBogus subTLV length %u", subtlv_length
);
695 if (ndo
->ndo_vflag
<= 1) {
696 if (!print_unknown_data(ndo
, tptr
, "\n\t\t", subtlv_length
))
701 /* in OSPF everything has to be 32-bit aligned, including subTLVs */
702 if (subtlv_length
% 4) {
703 subtlv_length
+= (4 - (subtlv_length
% 4));
706 tlv_length
-=subtlv_length
;
712 ospf_print_ep_lsa_extd_prefix_tlv(netdissect_options
*ndo
, const uint8_t *tptr
,
715 u_int subtlv_type
, subtlv_length
;
716 uint8_t flags
, mt_id
, algo
;
718 while (tlv_length
>= 4) {
719 subtlv_type
= GET_BE_U_2(tptr
);
720 subtlv_length
= GET_BE_U_2(tptr
+2);
724 /* Infinite loop protection. */
725 if (subtlv_type
== 0 || subtlv_length
== 0) {
726 nd_print_invalid(ndo
);
730 ND_PRINT("\n\t\t%s subTLV (%u), length: %u, value: ",
731 tok2str(lsa_opaque_ep_extd_prefix_subtlv_values
,"unknown",subtlv_type
),
735 switch (subtlv_type
) {
736 case LS_OPAQUE_EP_SUBTLV_PREFIX_SID
:
737 flags
= GET_U_1(tptr
);
738 mt_id
= GET_U_1(tptr
+2);
739 algo
= GET_U_1(tptr
+3);
741 if (subtlv_length
== 7) {
742 ND_PRINT("\n\t\t Label: %u, MT-ID: %u, Algorithm: %u",
743 GET_BE_U_3(tptr
+4), mt_id
, algo
);
744 } else if (subtlv_length
== 8) {
745 ND_PRINT("\n\t\t Index: %u, MT-ID: %u, Algorithm: %u, Flags [%s]",
746 GET_BE_U_4(tptr
+4), mt_id
, algo
,
747 bittok2str(ep_range_tlv_prefix_sid_subtlv_flag_values
, "none", flags
));
749 ND_PRINT("\n\t\tBogus subTLV length %u", subtlv_length
);
754 if (ndo
->ndo_vflag
<= 1) {
755 if (!print_unknown_data(ndo
, tptr
, "\n\t\t", subtlv_length
))
760 /* in OSPF everything has to be 32-bit aligned, including subTLVs */
761 if (subtlv_length
% 4) {
762 subtlv_length
+= (4 - (subtlv_length
% 4));
765 tlv_length
-=subtlv_length
;
771 ospf_ep_lsa_print(netdissect_options
*ndo
, const uint8_t *tptr
, u_int lsa_length
)
773 u_int tlv_type
, tlv_length
;
775 uint8_t af
, prefix_length
, route_type
, flags
;
777 while (lsa_length
>= 4) {
779 tlv_type
= GET_BE_U_2(tptr
);
780 tlv_length
= GET_BE_U_2(tptr
+2);
784 /* Infinite loop protection. */
785 if (tlv_type
== 0 || tlv_length
== 0) {
786 nd_print_invalid(ndo
);
790 ND_PRINT("\n\t %s TLV (%u), length: %u, value: ",
791 tok2str(lsa_opaque_ep_tlv_values
,"unknown",tlv_type
),
796 case LS_OPAQUE_EP_EXTD_PREFIX_TLV
:
797 prefix_length
= GET_U_1(tptr
+1);
798 af
= GET_U_1(tptr
+2);
799 route_type
= GET_U_1(tptr
);
800 flags
= GET_U_1(tptr
+3);
803 ND_PRINT("\n\t Bogus AF %u", af
);
807 if (prefix_length
> 32) {
808 ND_PRINT("\n\t IPv4 prefix: bad bit length %u", prefix_length
);
812 ND_PRINT("\n\t IPv4 prefix: %15s/%u, Route Type: %s, Flags [%s]",
813 GET_IPADDR_STRING(tptr
+4), prefix_length
,
814 tok2str(lsa_opaque_ep_route_type_values
, "Unknown", route_type
),
815 bittok2str(ep_tlv_flag_values
, "none", flags
));
817 /* subTLVs present ? */
818 if (tlv_length
> 12) {
819 if (ospf_print_ep_lsa_extd_prefix_tlv(ndo
, tptr
+8, tlv_length
-8) == -1) {
825 case LS_OPAQUE_EP_EXTD_PREFIX_RANGE_TLV
:
826 prefix_length
= GET_U_1(tptr
);
827 af
= GET_U_1(tptr
+1);
828 range_size
= GET_BE_U_2(tptr
+2);
829 flags
= GET_U_1(tptr
+4);
832 ND_PRINT("\n\t Bogus AF %u", af
);
836 if (prefix_length
> 32) {
837 ND_PRINT("\n\t IPv4 prefix: bad bit length %u", prefix_length
);
841 ND_PRINT("\n\t IPv4 prefix: %15s/%u, Range size: %u, Flags [%s]",
842 GET_IPADDR_STRING(tptr
+8), prefix_length
,
844 bittok2str(ep_tlv_flag_values
, "none", flags
));
846 /* subTLVs present ? */
847 if (tlv_length
> 12) {
848 if (ospf_print_ep_lsa_extd_prefix_tlv(ndo
, tptr
+12, tlv_length
-12) == -1) {
855 if (ndo
->ndo_vflag
<= 1) {
856 if (!print_unknown_data(ndo
, tptr
, "\n\t\t", tlv_length
))
861 /* in OSPF everything has to be 32-bit aligned, including TLVs */
862 if (tlv_length
% 4) {
863 tlv_length
+= (4 - (tlv_length
% 4));
866 lsa_length
-=tlv_length
;
872 * Print a single link state advertisement. If truncated or if LSA length
873 * field is less than the length of the LSA header, return NULl, else
874 * return pointer to data past end of LSA.
876 static const uint8_t *
877 ospf_print_lsa(netdissect_options
*ndo
,
878 const struct lsa
*lsap
)
880 const uint8_t *ls_end
;
881 const struct rlalink
*rlp
;
883 const struct aslametric
*almp
;
884 const struct mcla
*mcp
;
886 u_int tlv_type
, tlv_length
, rla_count
, topology
;
887 int ospf_print_lshdr_ret
;
891 tptr
= (const uint8_t *)lsap
->lsa_un
.un_unknown
; /* squelch compiler warnings */
892 ospf_print_lshdr_ret
= ospf_print_lshdr(ndo
, &lsap
->ls_hdr
);
893 if (ospf_print_lshdr_ret
< 0)
895 ls_length
= (u_int
)ospf_print_lshdr_ret
;
896 ls_end
= (const uint8_t *)lsap
+ ls_length
;
898 * ospf_print_lshdr() returns -1 if the length is too short,
899 * so we know ls_length is >= sizeof(struct lsa_hdr).
901 ls_length
-= sizeof(struct lsa_hdr
);
903 switch (GET_U_1(lsap
->ls_hdr
.ls_type
)) {
906 ND_PRINT("\n\t Router LSA Options: [%s]",
907 bittok2str(ospf_rla_flag_values
, "none", GET_U_1(lsap
->lsa_un
.un_rla
.rla_flags
)));
909 rla_count
= GET_BE_U_2(lsap
->lsa_un
.un_rla
.rla_count
);
910 ND_TCHECK_SIZE(lsap
->lsa_un
.un_rla
.rla_link
);
911 rlp
= lsap
->lsa_un
.un_rla
.rla_link
;
912 for (u_int i
= rla_count
; i
!= 0; i
--) {
914 switch (GET_U_1(rlp
->un_tos
.link
.link_type
)) {
916 case RLA_TYPE_VIRTUAL
:
917 ND_PRINT("\n\t Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
918 GET_IPADDR_STRING(rlp
->link_id
),
919 GET_IPADDR_STRING(rlp
->link_data
));
922 case RLA_TYPE_ROUTER
:
923 ND_PRINT("\n\t Neighbor Router-ID: %s, Interface Address: %s",
924 GET_IPADDR_STRING(rlp
->link_id
),
925 GET_IPADDR_STRING(rlp
->link_data
));
928 case RLA_TYPE_TRANSIT
:
929 ND_PRINT("\n\t Neighbor Network-ID: %s, Interface Address: %s",
930 GET_IPADDR_STRING(rlp
->link_id
),
931 GET_IPADDR_STRING(rlp
->link_data
));
935 ND_PRINT("\n\t Stub Network: %s, Mask: %s",
936 GET_IPADDR_STRING(rlp
->link_id
),
937 GET_IPADDR_STRING(rlp
->link_data
));
941 ND_PRINT("\n\t Unknown Router Link Type (%u)",
942 GET_U_1(rlp
->un_tos
.link
.link_type
));
946 ospf_print_tos_metrics(ndo
, &rlp
->un_tos
);
948 rlp
= (const struct rlalink
*)((const u_char
*)(rlp
+ 1) +
949 (GET_U_1(rlp
->un_tos
.link
.link_tos_count
) * sizeof(union un_tos
)));
953 case LS_TYPE_NETWORK
:
954 ND_PRINT("\n\t Mask %s\n\t Connected Routers:",
955 GET_IPADDR_STRING(lsap
->lsa_un
.un_nla
.nla_mask
));
956 ap
= lsap
->lsa_un
.un_nla
.nla_router
;
957 while ((const u_char
*)ap
< ls_end
) {
958 ND_PRINT("\n\t %s", GET_IPADDR_STRING(ap
));
964 ND_TCHECK_4(lsap
->lsa_un
.un_nla
.nla_mask
);
965 ND_PRINT("\n\t Mask %s",
966 GET_IPADDR_STRING(lsap
->lsa_un
.un_sla
.sla_mask
));
967 ND_TCHECK_SIZE(lsap
->lsa_un
.un_sla
.sla_tosmetric
);
968 lp
= (const uint8_t *)lsap
->lsa_un
.un_sla
.sla_tosmetric
;
969 while (lp
< ls_end
) {
973 topology
= (ul
& SLA_MASK_TOS
) >> SLA_SHIFT_TOS
;
974 ND_PRINT("\n\t\ttopology %s (%u) metric %u",
975 tok2str(ospf_topology_values
, "Unknown", topology
),
977 ul
& SLA_MASK_METRIC
);
982 case LS_TYPE_SUM_ABR
:
983 ND_TCHECK_SIZE(lsap
->lsa_un
.un_sla
.sla_tosmetric
);
984 lp
= (const uint8_t *)lsap
->lsa_un
.un_sla
.sla_tosmetric
;
985 while (lp
< ls_end
) {
989 topology
= (ul
& SLA_MASK_TOS
) >> SLA_SHIFT_TOS
;
990 ND_PRINT("\n\t\ttopology %s (%u) metric %u",
991 tok2str(ospf_topology_values
, "Unknown", topology
),
993 ul
& SLA_MASK_METRIC
);
999 case LS_TYPE_NSSA
: /* fall through - those LSAs share the same format */
1000 ND_TCHECK_4(lsap
->lsa_un
.un_nla
.nla_mask
);
1001 ND_PRINT("\n\t Mask %s",
1002 GET_IPADDR_STRING(lsap
->lsa_un
.un_asla
.asla_mask
));
1004 ND_TCHECK_SIZE(lsap
->lsa_un
.un_sla
.sla_tosmetric
);
1005 almp
= lsap
->lsa_un
.un_asla
.asla_metric
;
1006 while ((const u_char
*)almp
< ls_end
) {
1009 ul
= GET_BE_U_4(almp
->asla_tosmetric
);
1010 topology
= ((ul
& ASLA_MASK_TOS
) >> ASLA_SHIFT_TOS
);
1011 ND_PRINT("\n\t\ttopology %s (%u), type %u, metric",
1012 tok2str(ospf_topology_values
, "Unknown", topology
),
1014 (ul
& ASLA_FLAG_EXTERNAL
) ? 2 : 1);
1015 if ((ul
& ASLA_MASK_METRIC
) == 0xffffff)
1016 ND_PRINT(" infinite");
1018 ND_PRINT(" %u", (ul
& ASLA_MASK_METRIC
));
1020 if (GET_IPV4_TO_NETWORK_ORDER(almp
->asla_forward
) != 0) {
1021 ND_PRINT(", forward %s", GET_IPADDR_STRING(almp
->asla_forward
));
1023 if (GET_IPV4_TO_NETWORK_ORDER(almp
->asla_tag
) != 0) {
1024 ND_PRINT(", tag %s", GET_IPADDR_STRING(almp
->asla_tag
));
1031 /* Multicast extensions as of 23 July 1991 */
1032 mcp
= lsap
->lsa_un
.un_mcla
;
1033 while ((const u_char
*)mcp
< ls_end
) {
1034 switch (GET_BE_U_4(mcp
->mcla_vtype
)) {
1036 case MCLA_VERTEX_ROUTER
:
1037 ND_PRINT("\n\t Router Router-ID %s",
1038 GET_IPADDR_STRING(mcp
->mcla_vid
));
1041 case MCLA_VERTEX_NETWORK
:
1042 ND_PRINT("\n\t Network Designated Router %s",
1043 GET_IPADDR_STRING(mcp
->mcla_vid
));
1047 ND_PRINT("\n\t unknown VertexType (%u)",
1048 GET_BE_U_4(mcp
->mcla_vtype
));
1055 case LS_TYPE_OPAQUE_LL
: /* fall through */
1056 case LS_TYPE_OPAQUE_AL
:
1057 case LS_TYPE_OPAQUE_DW
:
1059 switch (GET_U_1(lsap
->ls_hdr
.un_lsa_id
.opaque_field
.opaque_type
)) {
1060 case LS_OPAQUE_TYPE_RI
:
1061 tptr
= (const uint8_t *)(lsap
->lsa_un
.un_ri_tlv
);
1063 u_int ls_length_remaining
= ls_length
;
1064 while (ls_length_remaining
!= 0) {
1066 if (ls_length_remaining
< 4) {
1067 ND_PRINT("\n\t Remaining LS length %u < 4", ls_length_remaining
);
1070 tlv_type
= GET_BE_U_2(tptr
);
1071 tlv_length
= GET_BE_U_2(tptr
+ 2);
1073 ls_length_remaining
-=4;
1075 ND_PRINT("\n\t %s TLV (%u), length: %u, value: ",
1076 tok2str(lsa_opaque_ri_tlv_values
,"unknown",tlv_type
),
1080 if (tlv_length
> ls_length_remaining
) {
1081 ND_PRINT("\n\t Bogus length %u > remaining LS length %u", tlv_length
,
1082 ls_length_remaining
);
1085 ND_TCHECK_LEN(tptr
, tlv_length
);
1088 case LS_OPAQUE_RI_TLV_CAP
:
1089 if (tlv_length
!= 4) {
1090 ND_PRINT("\n\t Bogus length %u != 4", tlv_length
);
1093 ND_PRINT("Capabilities: %s",
1094 bittok2str(lsa_opaque_ri_tlv_cap_values
, "Unknown", GET_BE_U_4(tptr
)));
1097 case LS_OPAQUE_RI_TLV_HOSTNAME
:
1098 ND_PRINT("\n\t Hostname: ");
1099 nd_printjnp(ndo
, tptr
, tlv_length
);
1102 case LS_OPAQUE_RI_TLV_SID_LABEL_RANGE
:
1104 ND_PRINT("\n\t Range size: %u", GET_BE_U_3(tptr
));
1105 if (ospf_print_ri_lsa_sid_label_range_tlv(ndo
, tptr
+4, tlv_length
-4) == -1) {
1111 if (ndo
->ndo_vflag
<= 1) {
1112 if (!print_unknown_data(ndo
, tptr
, "\n\t ", tlv_length
))
1119 /* in OSPF everything has to be 32-bit aligned, including TLVs */
1120 if (tlv_length
% 4) {
1121 tlv_length
+= (4 - (tlv_length
% 4));
1124 ls_length_remaining
-=tlv_length
;
1128 case LS_OPAQUE_TYPE_GRACE
:
1129 if (ospf_grace_lsa_print(ndo
, (const u_char
*)(lsap
->lsa_un
.un_grace_tlv
),
1135 case LS_OPAQUE_TYPE_TE
:
1136 if (ospf_te_lsa_print(ndo
, (const u_char
*)(lsap
->lsa_un
.un_te_lsa_tlv
),
1142 case LS_OPAQUE_TYPE_EP
:
1143 if (ospf_ep_lsa_print(ndo
, (const u_char
*)(lsap
->lsa_un
.un_ep_tlv
),
1150 if (ndo
->ndo_vflag
<= 1) {
1151 if (!print_unknown_data(ndo
, (const uint8_t *)lsap
->lsa_un
.un_unknown
,
1152 "\n\t ", ls_length
))
1159 /* do we want to see an additionally hexdump ? */
1160 if (ndo
->ndo_vflag
> 1)
1161 if (!print_unknown_data(ndo
, (const uint8_t *)lsap
->lsa_un
.un_unknown
,
1162 "\n\t ", ls_length
)) {
1172 ospf_decode_lls(netdissect_options
*ndo
,
1173 const struct ospfhdr
*op
, u_int length
)
1176 const u_char
*dataend
;
1178 uint16_t lls_type
, lls_len
;
1181 switch (GET_U_1(op
->ospf_type
)) {
1183 case OSPF_TYPE_HELLO
:
1184 if (!(GET_U_1(op
->ospf_hello
.hello_options
) & OSPF_OPTION_L
))
1189 if (!(GET_U_1(op
->ospf_db
.db_options
) & OSPF_OPTION_L
))
1197 /* dig deeper if LLS data is available; see RFC4813 */
1198 length2
= GET_BE_U_2(op
->ospf_len
);
1199 dptr
= (const u_char
*)op
+ length2
;
1200 dataend
= (const u_char
*)op
+ length
;
1202 if (GET_BE_U_2(op
->ospf_authtype
) == OSPF_AUTH_MD5
) {
1203 dptr
= dptr
+ GET_U_1(op
->ospf_authdata
+ 3);
1204 length2
+= GET_U_1(op
->ospf_authdata
+ 3);
1206 if (length2
>= length
) {
1207 ND_PRINT("\n\t[LLS truncated]");
1210 ND_PRINT("\n\t LLS: checksum: 0x%04x", (u_int
) GET_BE_U_2(dptr
));
1213 length2
= GET_BE_U_2(dptr
);
1214 ND_PRINT(", length: %u", length2
);
1217 while (dptr
< dataend
) {
1218 lls_type
= GET_BE_U_2(dptr
);
1219 ND_PRINT("\n\t %s (%u)",
1220 tok2str(ospf_lls_tlv_values
,"Unknown TLV",lls_type
),
1223 lls_len
= GET_BE_U_2(dptr
);
1224 ND_PRINT(", length: %u", lls_len
);
1230 ND_PRINT(" [should be 4]");
1233 lls_flags
= GET_BE_U_4(dptr
);
1234 ND_PRINT("\n\t Options: 0x%08x [%s]", lls_flags
,
1235 bittok2str(ospf_lls_eo_options
, "?", lls_flags
));
1240 if (lls_len
!= 20) {
1241 ND_PRINT(" [should be 20]");
1244 ND_PRINT("\n\t Sequence number: 0x%08x", GET_BE_U_4(dptr
));
1253 ospf_decode_v2(netdissect_options
*ndo
,
1254 const struct ospfhdr
*op
, const u_char
*dataend
)
1257 const struct lsr
*lsrp
;
1258 const struct lsa_hdr
*lshp
;
1259 const struct lsa
*lsap
;
1260 uint32_t lsa_count
,lsa_count_max
;
1262 switch (GET_U_1(op
->ospf_type
)) {
1264 case OSPF_TYPE_HELLO
:
1265 ND_PRINT("\n\tOptions [%s]",
1266 bittok2str(ospf_option_values
,"none",GET_U_1(op
->ospf_hello
.hello_options
)));
1268 ND_PRINT("\n\t Hello Timer %us, Dead Timer %us, Mask %s, Priority %u",
1269 GET_BE_U_2(op
->ospf_hello
.hello_helloint
),
1270 GET_BE_U_4(op
->ospf_hello
.hello_deadint
),
1271 GET_IPADDR_STRING(op
->ospf_hello
.hello_mask
),
1272 GET_U_1(op
->ospf_hello
.hello_priority
));
1274 if (GET_IPV4_TO_NETWORK_ORDER(op
->ospf_hello
.hello_dr
) != 0)
1275 ND_PRINT("\n\t Designated Router %s",
1276 GET_IPADDR_STRING(op
->ospf_hello
.hello_dr
));
1278 if (GET_IPV4_TO_NETWORK_ORDER(op
->ospf_hello
.hello_bdr
) != 0)
1279 ND_PRINT(", Backup Designated Router %s",
1280 GET_IPADDR_STRING(op
->ospf_hello
.hello_bdr
));
1282 ap
= op
->ospf_hello
.hello_neighbor
;
1283 if ((const u_char
*)ap
< dataend
)
1284 ND_PRINT("\n\t Neighbor List:");
1285 while ((const u_char
*)ap
< dataend
) {
1286 ND_PRINT("\n\t %s", GET_IPADDR_STRING(ap
));
1292 ND_PRINT("\n\tOptions [%s]",
1293 bittok2str(ospf_option_values
, "none", GET_U_1(op
->ospf_db
.db_options
)));
1294 ND_PRINT(", DD Flags [%s]",
1295 bittok2str(ospf_dd_flag_values
, "none", GET_U_1(op
->ospf_db
.db_flags
)));
1296 if (GET_BE_U_2(op
->ospf_db
.db_ifmtu
)) {
1297 ND_PRINT(", MTU: %u",
1298 GET_BE_U_2(op
->ospf_db
.db_ifmtu
));
1300 ND_PRINT(", Sequence: 0x%08x", GET_BE_U_4(op
->ospf_db
.db_seq
));
1302 /* Print all the LS adv's */
1303 lshp
= op
->ospf_db
.db_lshdr
;
1304 while (((const u_char
*)lshp
< dataend
) && ospf_print_lshdr(ndo
, lshp
) != -1) {
1309 case OSPF_TYPE_LS_REQ
:
1310 lsrp
= op
->ospf_lsr
;
1311 while ((const u_char
*)lsrp
< dataend
) {
1312 ND_TCHECK_SIZE(lsrp
);
1314 ND_PRINT("\n\t Advertising Router: %s, %s LSA (%u)",
1315 GET_IPADDR_STRING(lsrp
->ls_router
),
1316 tok2str(lsa_values
,"unknown",GET_BE_U_4(lsrp
->ls_type
)),
1317 GET_BE_U_4(lsrp
->ls_type
));
1319 switch (GET_BE_U_4(lsrp
->ls_type
)) {
1320 /* the LSA header for opaque LSAs was slightly changed */
1321 case LS_TYPE_OPAQUE_LL
:
1322 case LS_TYPE_OPAQUE_AL
:
1323 case LS_TYPE_OPAQUE_DW
:
1324 ND_PRINT(", Opaque-Type: %s LSA (%u), Opaque-ID: %u",
1325 tok2str(lsa_opaque_values
, "unknown",GET_U_1(lsrp
->un_ls_stateid
.opaque_field
.opaque_type
)),
1326 GET_U_1(lsrp
->un_ls_stateid
.opaque_field
.opaque_type
),
1327 GET_BE_U_3(lsrp
->un_ls_stateid
.opaque_field
.opaque_id
));
1330 ND_PRINT(", LSA-ID: %s",
1331 GET_IPADDR_STRING(lsrp
->un_ls_stateid
.ls_stateid
));
1339 case OSPF_TYPE_LS_UPDATE
:
1340 lsap
= op
->ospf_lsu
.lsu_lsa
;
1341 lsa_count_max
= GET_BE_U_4(op
->ospf_lsu
.lsu_count
);
1342 ND_PRINT(", %u LSA%s", lsa_count_max
, PLURAL_SUFFIX(lsa_count_max
));
1343 for (lsa_count
=1;lsa_count
<= lsa_count_max
;lsa_count
++) {
1344 ND_PRINT("\n\t LSA #%u", lsa_count
);
1345 lsap
= (const struct lsa
*)ospf_print_lsa(ndo
, lsap
);
1351 case OSPF_TYPE_LS_ACK
:
1352 lshp
= op
->ospf_lsa
.lsa_lshdr
;
1353 while ((const u_char
*)lshp
< dataend
) {
1354 ospf_print_lshdr(ndo
, lshp
);
1368 ospf_print(netdissect_options
*ndo
,
1369 const u_char
*bp
, u_int length
,
1370 const u_char
*bp2 _U_
)
1372 const struct ospfhdr
*op
;
1373 const u_char
*dataend
;
1376 ndo
->ndo_protocol
= "ospf2";
1377 op
= (const struct ospfhdr
*)bp
;
1379 /* XXX Before we do anything else, strip off the MD5 trailer */
1380 if (GET_BE_U_2(op
->ospf_authtype
) == OSPF_AUTH_MD5
) {
1381 length
-= OSPF_AUTH_MD5_LEN
;
1382 ndo
->ndo_snapend
-= OSPF_AUTH_MD5_LEN
;
1385 /* If the type is valid translate it, or just print the type */
1386 /* value. If it's not valid, say so and return */
1387 cp
= tok2str(type2str
, "unknown LS-type %u", GET_U_1(op
->ospf_type
));
1388 ND_PRINT("OSPFv%u, %s, length %u", GET_U_1(op
->ospf_version
), cp
,
1393 if (!ndo
->ndo_vflag
) { /* non verbose - so lets bail out here */
1397 if (length
!= GET_BE_U_2(op
->ospf_len
)) {
1398 ND_PRINT(" [len %u]", GET_BE_U_2(op
->ospf_len
));
1401 if (length
> GET_BE_U_2(op
->ospf_len
)) {
1402 dataend
= bp
+ GET_BE_U_2(op
->ospf_len
);
1404 dataend
= bp
+ length
;
1407 ND_PRINT("\n\tRouter-ID %s", GET_IPADDR_STRING(op
->ospf_routerid
));
1409 if (GET_IPV4_TO_NETWORK_ORDER(op
->ospf_areaid
) != 0)
1410 ND_PRINT(", Area %s", GET_IPADDR_STRING(op
->ospf_areaid
));
1412 ND_PRINT(", Backbone Area");
1414 if (ndo
->ndo_vflag
) {
1415 /* Print authentication data (should we really do this?) */
1416 ND_TCHECK_LEN(op
->ospf_authdata
, sizeof(op
->ospf_authdata
));
1418 ND_PRINT(", Authentication Type: %s (%u)",
1419 tok2str(ospf_authtype_values
, "unknown", GET_BE_U_2(op
->ospf_authtype
)),
1420 GET_BE_U_2(op
->ospf_authtype
));
1422 switch (GET_BE_U_2(op
->ospf_authtype
)) {
1424 case OSPF_AUTH_NONE
:
1427 case OSPF_AUTH_SIMPLE
:
1428 ND_PRINT("\n\tSimple text password: ");
1429 nd_printjnp(ndo
, op
->ospf_authdata
, OSPF_AUTH_SIMPLE_LEN
);
1433 ND_PRINT("\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
1434 GET_U_1(op
->ospf_authdata
+ 2),
1435 GET_U_1(op
->ospf_authdata
+ 3),
1436 GET_BE_U_4((op
->ospf_authdata
) + 4));
1443 /* Do rest according to version. */
1444 switch (GET_U_1(op
->ospf_version
)) {
1447 /* ospf version 2 */
1448 if (ospf_decode_v2(ndo
, op
, dataend
))
1450 if (length
> GET_BE_U_2(op
->ospf_len
))
1451 ospf_decode_lls(ndo
, op
, length
);
1455 ND_PRINT(" ospf [version %u]", GET_U_1(op
->ospf_version
));
1457 } /* end switch on version */
1461 nd_trunc_longjmp(ndo
);