8447 uts: acpica_check_bios_date() instead of bios-free, use efi-systab
[unleashed.git] / contrib / tcpdump / print-ospf.c
blobdb4231ba0f85eec030c4fca34682cf4719c396dd
1 /*
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
16 * written permission.
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 */
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
30 #include <netdissect-stdinc.h>
32 #include "netdissect.h"
33 #include "addrtoname.h"
34 #include "extract.h"
35 #include "gmpls.h"
37 #include "ospf.h"
39 static const char tstr[] = " [|ospf2]";
41 static const struct tok ospf_option_values[] = {
42 { OSPF_OPTION_T, "MultiTopology" }, /* draft-ietf-ospf-mt-09 */
43 { OSPF_OPTION_E, "External" },
44 { OSPF_OPTION_MC, "Multicast" },
45 { OSPF_OPTION_NP, "NSSA" },
46 { OSPF_OPTION_L, "LLS" },
47 { OSPF_OPTION_DC, "Demand Circuit" },
48 { OSPF_OPTION_O, "Opaque" },
49 { OSPF_OPTION_DN, "Up/Down" },
50 { 0, NULL }
53 static const struct tok ospf_authtype_values[] = {
54 { OSPF_AUTH_NONE, "none" },
55 { OSPF_AUTH_SIMPLE, "simple" },
56 { OSPF_AUTH_MD5, "MD5" },
57 { 0, NULL }
60 static const struct tok ospf_rla_flag_values[] = {
61 { RLA_FLAG_B, "ABR" },
62 { RLA_FLAG_E, "ASBR" },
63 { RLA_FLAG_W1, "Virtual" },
64 { RLA_FLAG_W2, "W2" },
65 { 0, NULL }
68 static const struct tok type2str[] = {
69 { OSPF_TYPE_UMD, "UMD" },
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" },
75 { 0, NULL }
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" },
89 { 0, NULL }
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" },
97 { 0, NULL }
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 { 0, NULL }
107 static const struct tok lsa_opaque_te_tlv_values[] = {
108 { LS_OPAQUE_TE_TLV_ROUTER, "Router Address" },
109 { LS_OPAQUE_TE_TLV_LINK, "Link" },
110 { 0, NULL }
113 static const struct tok lsa_opaque_te_link_tlv_subtlv_values[] = {
114 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE, "Link Type" },
115 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID, "Link ID" },
116 { LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP, "Local Interface IP address" },
117 { LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP, "Remote Interface IP address" },
118 { LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC, "Traffic Engineering Metric" },
119 { LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW, "Maximum Bandwidth" },
120 { LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW, "Maximum Reservable Bandwidth" },
121 { LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW, "Unreserved Bandwidth" },
122 { LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP, "Administrative Group" },
123 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
124 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE, "Link Protection Type" },
125 { LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR, "Interface Switching Capability" },
126 { LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP, "Shared Risk Link Group" },
127 { LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS, "Bandwidth Constraints" },
128 { 0, NULL }
131 static const struct tok lsa_opaque_grace_tlv_values[] = {
132 { LS_OPAQUE_GRACE_TLV_PERIOD, "Grace Period" },
133 { LS_OPAQUE_GRACE_TLV_REASON, "Graceful restart Reason" },
134 { LS_OPAQUE_GRACE_TLV_INT_ADDRESS, "IPv4 interface address" },
135 { 0, NULL }
138 static const struct tok lsa_opaque_grace_tlv_reason_values[] = {
139 { LS_OPAQUE_GRACE_TLV_REASON_UNKNOWN, "Unknown" },
140 { LS_OPAQUE_GRACE_TLV_REASON_SW_RESTART, "Software Restart" },
141 { LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE, "Software Reload/Upgrade" },
142 { LS_OPAQUE_GRACE_TLV_REASON_CP_SWITCH, "Control Processor Switch" },
143 { 0, NULL }
146 static const struct tok lsa_opaque_te_tlv_link_type_sub_tlv_values[] = {
147 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP, "Point-to-point" },
148 { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA, "Multi-Access" },
149 { 0, NULL }
152 static const struct tok lsa_opaque_ri_tlv_values[] = {
153 { LS_OPAQUE_RI_TLV_CAP, "Router Capabilities" },
154 { 0, NULL }
157 static const struct tok lsa_opaque_ri_tlv_cap_values[] = {
158 { 1, "Reserved" },
159 { 2, "Reserved" },
160 { 4, "Reserved" },
161 { 8, "Reserved" },
162 { 16, "graceful restart capable" },
163 { 32, "graceful restart helper" },
164 { 64, "Stub router support" },
165 { 128, "Traffic engineering" },
166 { 256, "p2p over LAN" },
167 { 512, "path computation server" },
168 { 0, NULL }
171 static const struct tok ospf_lls_tlv_values[] = {
172 { OSPF_LLS_EO, "Extended Options" },
173 { OSPF_LLS_MD5, "MD5 Authentication" },
174 { 0, NULL }
177 static const struct tok ospf_lls_eo_options[] = {
178 { OSPF_LLS_EO_LR, "LSDB resync" },
179 { OSPF_LLS_EO_RS, "Restart" },
180 { 0, NULL }
184 ospf_print_grace_lsa(netdissect_options *ndo,
185 const uint8_t *tptr, u_int ls_length)
187 u_int tlv_type, tlv_length;
190 while (ls_length > 0) {
191 ND_TCHECK2(*tptr, 4);
192 if (ls_length < 4) {
193 ND_PRINT((ndo, "\n\t Remaining LS length %u < 4", ls_length));
194 return -1;
196 tlv_type = EXTRACT_16BITS(tptr);
197 tlv_length = EXTRACT_16BITS(tptr+2);
198 tptr+=4;
199 ls_length-=4;
201 ND_PRINT((ndo, "\n\t %s TLV (%u), length %u, value: ",
202 tok2str(lsa_opaque_grace_tlv_values,"unknown",tlv_type),
203 tlv_type,
204 tlv_length));
206 if (tlv_length > ls_length) {
207 ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length,
208 ls_length));
209 return -1;
212 /* Infinite loop protection. */
213 if (tlv_type == 0 || tlv_length ==0) {
214 return -1;
217 ND_TCHECK2(*tptr, tlv_length);
218 switch(tlv_type) {
220 case LS_OPAQUE_GRACE_TLV_PERIOD:
221 if (tlv_length != 4) {
222 ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length));
223 return -1;
225 ND_PRINT((ndo, "%us", EXTRACT_32BITS(tptr)));
226 break;
228 case LS_OPAQUE_GRACE_TLV_REASON:
229 if (tlv_length != 1) {
230 ND_PRINT((ndo, "\n\t Bogus length %u != 1", tlv_length));
231 return -1;
233 ND_PRINT((ndo, "%s (%u)",
234 tok2str(lsa_opaque_grace_tlv_reason_values, "Unknown", *tptr),
235 *tptr));
236 break;
238 case LS_OPAQUE_GRACE_TLV_INT_ADDRESS:
239 if (tlv_length != 4) {
240 ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length));
241 return -1;
243 ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
244 break;
246 default:
247 if (ndo->ndo_vflag <= 1) {
248 if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
249 return -1;
251 break;
254 /* in OSPF everything has to be 32-bit aligned, including TLVs */
255 if (tlv_length%4 != 0)
256 tlv_length+=4-(tlv_length%4);
257 ls_length-=tlv_length;
258 tptr+=tlv_length;
261 return 0;
262 trunc:
263 return -1;
267 ospf_print_te_lsa(netdissect_options *ndo,
268 const uint8_t *tptr, u_int ls_length)
270 u_int tlv_type, tlv_length, subtlv_type, subtlv_length;
271 u_int priority_level, te_class, count_srlg;
272 union { /* int to float conversion buffer for several subTLVs */
273 float f;
274 uint32_t i;
275 } bw;
277 while (ls_length != 0) {
278 ND_TCHECK2(*tptr, 4);
279 if (ls_length < 4) {
280 ND_PRINT((ndo, "\n\t Remaining LS length %u < 4", ls_length));
281 return -1;
283 tlv_type = EXTRACT_16BITS(tptr);
284 tlv_length = EXTRACT_16BITS(tptr+2);
285 tptr+=4;
286 ls_length-=4;
288 ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u",
289 tok2str(lsa_opaque_te_tlv_values,"unknown",tlv_type),
290 tlv_type,
291 tlv_length));
293 if (tlv_length > ls_length) {
294 ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length,
295 ls_length));
296 return -1;
299 /* Infinite loop protection. */
300 if (tlv_type == 0 || tlv_length ==0) {
301 return -1;
304 switch(tlv_type) {
305 case LS_OPAQUE_TE_TLV_LINK:
306 while (tlv_length >= sizeof(subtlv_type) + sizeof(subtlv_length)) {
307 if (tlv_length < 4) {
308 ND_PRINT((ndo, "\n\t Remaining TLV length %u < 4",
309 tlv_length));
310 return -1;
312 ND_TCHECK2(*tptr, 4);
313 subtlv_type = EXTRACT_16BITS(tptr);
314 subtlv_length = EXTRACT_16BITS(tptr+2);
315 tptr+=4;
316 tlv_length-=4;
318 /* Infinite loop protection */
319 if (subtlv_type == 0 || subtlv_length == 0)
320 goto invalid;
322 ND_PRINT((ndo, "\n\t %s subTLV (%u), length: %u",
323 tok2str(lsa_opaque_te_link_tlv_subtlv_values,"unknown",subtlv_type),
324 subtlv_type,
325 subtlv_length));
327 ND_TCHECK2(*tptr, subtlv_length);
328 switch(subtlv_type) {
329 case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP:
330 if (subtlv_length != 4) {
331 ND_PRINT((ndo, " != 4"));
332 goto invalid;
334 ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr)));
335 break;
336 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID:
337 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID:
338 if (subtlv_length != 4 && subtlv_length != 8) {
339 ND_PRINT((ndo, " != 4 && != 8"));
340 goto invalid;
342 ND_PRINT((ndo, ", %s (0x%08x)",
343 ipaddr_string(ndo, tptr),
344 EXTRACT_32BITS(tptr)));
345 if (subtlv_length == 8) /* rfc4203 */
346 ND_PRINT((ndo, ", %s (0x%08x)",
347 ipaddr_string(ndo, tptr+4),
348 EXTRACT_32BITS(tptr + 4)));
349 break;
350 case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP:
351 case LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP:
352 if (subtlv_length != 4) {
353 ND_PRINT((ndo, " != 4"));
354 goto invalid;
356 ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
357 break;
358 case LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW:
359 case LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW:
360 if (subtlv_length != 4) {
361 ND_PRINT((ndo, " != 4"));
362 goto invalid;
364 bw.i = EXTRACT_32BITS(tptr);
365 ND_PRINT((ndo, ", %.3f Mbps", bw.f * 8 / 1000000));
366 break;
367 case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW:
368 if (subtlv_length != 32) {
369 ND_PRINT((ndo, " != 32"));
370 goto invalid;
372 for (te_class = 0; te_class < 8; te_class++) {
373 bw.i = EXTRACT_32BITS(tptr+te_class*4);
374 ND_PRINT((ndo, "\n\t\tTE-Class %u: %.3f Mbps",
375 te_class,
376 bw.f * 8 / 1000000));
378 break;
379 case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS:
380 if (subtlv_length < 4) {
381 ND_PRINT((ndo, " < 4"));
382 goto invalid;
384 /* BC Model Id (1 octet) + Reserved (3 octets) */
385 ND_PRINT((ndo, "\n\t\tBandwidth Constraints Model ID: %s (%u)",
386 tok2str(diffserv_te_bc_values, "unknown", *tptr),
387 *tptr));
388 if (subtlv_length % 4 != 0) {
389 ND_PRINT((ndo, "\n\t\tlength %u != N x 4", subtlv_length));
390 goto invalid;
392 if (subtlv_length > 36) {
393 ND_PRINT((ndo, "\n\t\tlength %u > 36", subtlv_length));
394 goto invalid;
396 /* decode BCs until the subTLV ends */
397 for (te_class = 0; te_class < (subtlv_length-4)/4; te_class++) {
398 bw.i = EXTRACT_32BITS(tptr+4+te_class*4);
399 ND_PRINT((ndo, "\n\t\t Bandwidth constraint CT%u: %.3f Mbps",
400 te_class,
401 bw.f * 8 / 1000000));
403 break;
404 case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC:
405 if (subtlv_length != 4) {
406 ND_PRINT((ndo, " != 4"));
407 goto invalid;
409 ND_PRINT((ndo, ", Metric %u", EXTRACT_32BITS(tptr)));
410 break;
411 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE:
412 /* Protection Cap (1 octet) + Reserved ((3 octets) */
413 if (subtlv_length != 4) {
414 ND_PRINT((ndo, " != 4"));
415 goto invalid;
417 ND_PRINT((ndo, ", %s",
418 bittok2str(gmpls_link_prot_values, "none", *tptr)));
419 break;
420 case LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR:
421 if (subtlv_length < 36) {
422 ND_PRINT((ndo, " < 36"));
423 goto invalid;
425 /* Switching Cap (1 octet) + Encoding (1) + Reserved (2) */
426 ND_PRINT((ndo, "\n\t\tInterface Switching Capability: %s",
427 tok2str(gmpls_switch_cap_values, "Unknown", *(tptr))));
428 ND_PRINT((ndo, "\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:",
429 tok2str(gmpls_encoding_values, "Unknown", *(tptr + 1))));
430 for (priority_level = 0; priority_level < 8; priority_level++) {
431 bw.i = EXTRACT_32BITS(tptr+4+(priority_level*4));
432 ND_PRINT((ndo, "\n\t\t priority level %d: %.3f Mbps",
433 priority_level,
434 bw.f * 8 / 1000000));
436 break;
437 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE:
438 if (subtlv_length != 1) {
439 ND_PRINT((ndo, " != 1"));
440 goto invalid;
442 ND_PRINT((ndo, ", %s (%u)",
443 tok2str(lsa_opaque_te_tlv_link_type_sub_tlv_values,"unknown",*tptr),
444 *tptr));
445 break;
447 case LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP:
448 if (subtlv_length % 4 != 0) {
449 ND_PRINT((ndo, " != N x 4"));
450 goto invalid;
452 count_srlg = subtlv_length / 4;
453 if (count_srlg != 0)
454 ND_PRINT((ndo, "\n\t\t Shared risk group: "));
455 while (count_srlg > 0) {
456 bw.i = EXTRACT_32BITS(tptr);
457 ND_PRINT((ndo, "%d", bw.i));
458 tptr+=4;
459 count_srlg--;
460 if (count_srlg > 0)
461 ND_PRINT((ndo, ", "));
463 break;
465 default:
466 if (ndo->ndo_vflag <= 1) {
467 if (!print_unknown_data(ndo, tptr, "\n\t\t", subtlv_length))
468 return -1;
470 break;
472 /* in OSPF everything has to be 32-bit aligned, including subTLVs */
473 if (subtlv_length%4 != 0)
474 subtlv_length+=4-(subtlv_length%4);
476 tlv_length-=subtlv_length;
477 tptr+=subtlv_length;
480 break;
482 case LS_OPAQUE_TE_TLV_ROUTER:
483 if (tlv_length < 4) {
484 ND_PRINT((ndo, "\n\t TLV length %u < 4", tlv_length));
485 return -1;
487 ND_TCHECK2(*tptr, 4);
488 ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
489 break;
491 default:
492 if (ndo->ndo_vflag <= 1) {
493 if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
494 return -1;
496 break;
498 /* in OSPF everything has to be 32-bit aligned, including TLVs */
499 if (tlv_length%4 != 0)
500 tlv_length+=4-(tlv_length%4);
501 ls_length-=tlv_length;
502 tptr+=tlv_length;
504 return 0;
505 trunc:
506 return -1;
507 invalid:
508 ND_PRINT((ndo, "%s", istr));
509 return -1;
512 static int
513 ospf_print_lshdr(netdissect_options *ndo,
514 register const struct lsa_hdr *lshp)
516 u_int ls_length;
518 ND_TCHECK(lshp->ls_length);
519 ls_length = EXTRACT_16BITS(&lshp->ls_length);
520 if (ls_length < sizeof(struct lsa_hdr)) {
521 ND_PRINT((ndo, "\n\t Bogus length %u < header (%lu)", ls_length,
522 (unsigned long)sizeof(struct lsa_hdr)));
523 return(-1);
526 ND_TCHECK(lshp->ls_seq); /* XXX - ls_length check checked this */
527 ND_PRINT((ndo, "\n\t Advertising Router %s, seq 0x%08x, age %us, length %u",
528 ipaddr_string(ndo, &lshp->ls_router),
529 EXTRACT_32BITS(&lshp->ls_seq),
530 EXTRACT_16BITS(&lshp->ls_age),
531 ls_length - (u_int)sizeof(struct lsa_hdr)));
533 ND_TCHECK(lshp->ls_type); /* XXX - ls_length check checked this */
534 switch (lshp->ls_type) {
535 /* the LSA header for opaque LSAs was slightly changed */
536 case LS_TYPE_OPAQUE_LL:
537 case LS_TYPE_OPAQUE_AL:
538 case LS_TYPE_OPAQUE_DW:
539 ND_PRINT((ndo, "\n\t %s LSA (%d), Opaque-Type %s LSA (%u), Opaque-ID %u",
540 tok2str(lsa_values,"unknown",lshp->ls_type),
541 lshp->ls_type,
543 tok2str(lsa_opaque_values,
544 "unknown",
545 *(&lshp->un_lsa_id.opaque_field.opaque_type)),
546 *(&lshp->un_lsa_id.opaque_field.opaque_type),
547 EXTRACT_24BITS(&lshp->un_lsa_id.opaque_field.opaque_id)
550 break;
552 /* all other LSA types use regular style LSA headers */
553 default:
554 ND_PRINT((ndo, "\n\t %s LSA (%d), LSA-ID: %s",
555 tok2str(lsa_values,"unknown",lshp->ls_type),
556 lshp->ls_type,
557 ipaddr_string(ndo, &lshp->un_lsa_id.lsa_id)));
558 break;
561 ND_TCHECK(lshp->ls_options); /* XXX - ls_length check checked this */
562 ND_PRINT((ndo, "\n\t Options: [%s]", bittok2str(ospf_option_values, "none", lshp->ls_options)));
564 return (ls_length);
565 trunc:
566 return (-1);
569 /* draft-ietf-ospf-mt-09 */
570 static const struct tok ospf_topology_values[] = {
571 { 0, "default" },
572 { 1, "multicast" },
573 { 2, "management" },
574 { 0, NULL }
578 * Print all the per-topology metrics.
580 static int
581 ospf_print_tos_metrics(netdissect_options *ndo,
582 const union un_tos *tos)
584 int metric_count;
585 int toscount;
587 toscount = tos->link.link_tos_count+1;
588 metric_count = 0;
591 * All but the first metric contain a valid topology id.
593 while (toscount > 0) {
594 ND_TCHECK(*tos);
595 ND_PRINT((ndo, "\n\t\ttopology %s (%u), metric %u",
596 tok2str(ospf_topology_values, "Unknown",
597 metric_count ? tos->metrics.tos_type : 0),
598 metric_count ? tos->metrics.tos_type : 0,
599 EXTRACT_16BITS(&tos->metrics.tos_metric)));
600 metric_count++;
601 tos++;
602 toscount--;
604 return 0;
605 trunc:
606 return 1;
610 * Print a single link state advertisement. If truncated or if LSA length
611 * field is less than the length of the LSA header, return NULl, else
612 * return pointer to data past end of LSA.
614 static const uint8_t *
615 ospf_print_lsa(netdissect_options *ndo,
616 register const struct lsa *lsap)
618 register const uint8_t *ls_end;
619 register const struct rlalink *rlp;
620 register const struct in_addr *ap;
621 register const struct aslametric *almp;
622 register const struct mcla *mcp;
623 register const uint32_t *lp;
624 register int j, tlv_type, tlv_length, topology;
625 register int ls_length;
626 const uint8_t *tptr;
628 tptr = (const uint8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */
629 ls_length = ospf_print_lshdr(ndo, &lsap->ls_hdr);
630 if (ls_length == -1)
631 return(NULL);
632 ls_end = (const uint8_t *)lsap + ls_length;
633 ls_length -= sizeof(struct lsa_hdr);
635 switch (lsap->ls_hdr.ls_type) {
637 case LS_TYPE_ROUTER:
638 ND_TCHECK(lsap->lsa_un.un_rla.rla_flags);
639 ND_PRINT((ndo, "\n\t Router LSA Options: [%s]",
640 bittok2str(ospf_rla_flag_values, "none", lsap->lsa_un.un_rla.rla_flags)));
642 ND_TCHECK(lsap->lsa_un.un_rla.rla_count);
643 j = EXTRACT_16BITS(&lsap->lsa_un.un_rla.rla_count);
644 ND_TCHECK(lsap->lsa_un.un_rla.rla_link);
645 rlp = lsap->lsa_un.un_rla.rla_link;
646 while (j--) {
647 ND_TCHECK(*rlp);
648 switch (rlp->un_tos.link.link_type) {
650 case RLA_TYPE_VIRTUAL:
651 ND_PRINT((ndo, "\n\t Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
652 ipaddr_string(ndo, &rlp->link_id),
653 ipaddr_string(ndo, &rlp->link_data)));
654 break;
656 case RLA_TYPE_ROUTER:
657 ND_PRINT((ndo, "\n\t Neighbor Router-ID: %s, Interface Address: %s",
658 ipaddr_string(ndo, &rlp->link_id),
659 ipaddr_string(ndo, &rlp->link_data)));
660 break;
662 case RLA_TYPE_TRANSIT:
663 ND_PRINT((ndo, "\n\t Neighbor Network-ID: %s, Interface Address: %s",
664 ipaddr_string(ndo, &rlp->link_id),
665 ipaddr_string(ndo, &rlp->link_data)));
666 break;
668 case RLA_TYPE_STUB:
669 ND_PRINT((ndo, "\n\t Stub Network: %s, Mask: %s",
670 ipaddr_string(ndo, &rlp->link_id),
671 ipaddr_string(ndo, &rlp->link_data)));
672 break;
674 default:
675 ND_PRINT((ndo, "\n\t Unknown Router Link Type (%u)",
676 rlp->un_tos.link.link_type));
677 return (ls_end);
680 if (ospf_print_tos_metrics(ndo, &rlp->un_tos))
681 goto trunc;
683 rlp = (const struct rlalink *)((const u_char *)(rlp + 1) +
684 ((rlp->un_tos.link.link_tos_count) * sizeof(union un_tos)));
686 break;
688 case LS_TYPE_NETWORK:
689 ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
690 ND_PRINT((ndo, "\n\t Mask %s\n\t Connected Routers:",
691 ipaddr_string(ndo, &lsap->lsa_un.un_nla.nla_mask)));
692 ap = lsap->lsa_un.un_nla.nla_router;
693 while ((const u_char *)ap < ls_end) {
694 ND_TCHECK(*ap);
695 ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
696 ++ap;
698 break;
700 case LS_TYPE_SUM_IP:
701 ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
702 ND_PRINT((ndo, "\n\t Mask %s",
703 ipaddr_string(ndo, &lsap->lsa_un.un_sla.sla_mask)));
704 ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
705 lp = lsap->lsa_un.un_sla.sla_tosmetric;
706 while ((const u_char *)lp < ls_end) {
707 register uint32_t ul;
709 ND_TCHECK(*lp);
710 ul = EXTRACT_32BITS(lp);
711 topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
712 ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d",
713 tok2str(ospf_topology_values, "Unknown", topology),
714 topology,
715 ul & SLA_MASK_METRIC));
716 ++lp;
718 break;
720 case LS_TYPE_SUM_ABR:
721 ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
722 lp = lsap->lsa_un.un_sla.sla_tosmetric;
723 while ((const u_char *)lp < ls_end) {
724 register uint32_t ul;
726 ND_TCHECK(*lp);
727 ul = EXTRACT_32BITS(lp);
728 topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
729 ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d",
730 tok2str(ospf_topology_values, "Unknown", topology),
731 topology,
732 ul & SLA_MASK_METRIC));
733 ++lp;
735 break;
737 case LS_TYPE_ASE:
738 case LS_TYPE_NSSA: /* fall through - those LSAs share the same format */
739 ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
740 ND_PRINT((ndo, "\n\t Mask %s",
741 ipaddr_string(ndo, &lsap->lsa_un.un_asla.asla_mask)));
743 ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
744 almp = lsap->lsa_un.un_asla.asla_metric;
745 while ((const u_char *)almp < ls_end) {
746 register uint32_t ul;
748 ND_TCHECK(almp->asla_tosmetric);
749 ul = EXTRACT_32BITS(&almp->asla_tosmetric);
750 topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS);
751 ND_PRINT((ndo, "\n\t\ttopology %s (%u), type %d, metric",
752 tok2str(ospf_topology_values, "Unknown", topology),
753 topology,
754 (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1));
755 if ((ul & ASLA_MASK_METRIC) == 0xffffff)
756 ND_PRINT((ndo, " infinite"));
757 else
758 ND_PRINT((ndo, " %d", (ul & ASLA_MASK_METRIC)));
760 ND_TCHECK(almp->asla_forward);
761 if (almp->asla_forward.s_addr) {
762 ND_PRINT((ndo, ", forward %s", ipaddr_string(ndo, &almp->asla_forward)));
764 ND_TCHECK(almp->asla_tag);
765 if (almp->asla_tag.s_addr) {
766 ND_PRINT((ndo, ", tag %s", ipaddr_string(ndo, &almp->asla_tag)));
768 ++almp;
770 break;
772 case LS_TYPE_GROUP:
773 /* Multicast extensions as of 23 July 1991 */
774 mcp = lsap->lsa_un.un_mcla;
775 while ((const u_char *)mcp < ls_end) {
776 ND_TCHECK(mcp->mcla_vid);
777 switch (EXTRACT_32BITS(&mcp->mcla_vtype)) {
779 case MCLA_VERTEX_ROUTER:
780 ND_PRINT((ndo, "\n\t Router Router-ID %s",
781 ipaddr_string(ndo, &mcp->mcla_vid)));
782 break;
784 case MCLA_VERTEX_NETWORK:
785 ND_PRINT((ndo, "\n\t Network Designated Router %s",
786 ipaddr_string(ndo, &mcp->mcla_vid)));
787 break;
789 default:
790 ND_PRINT((ndo, "\n\t unknown VertexType (%u)",
791 EXTRACT_32BITS(&mcp->mcla_vtype)));
792 break;
794 ++mcp;
796 break;
798 case LS_TYPE_OPAQUE_LL: /* fall through */
799 case LS_TYPE_OPAQUE_AL:
800 case LS_TYPE_OPAQUE_DW:
802 switch (*(&lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) {
803 case LS_OPAQUE_TYPE_RI:
804 tptr = (const uint8_t *)(&lsap->lsa_un.un_ri_tlv.type);
806 while (ls_length != 0) {
807 ND_TCHECK2(*tptr, 4);
808 if (ls_length < 4) {
809 ND_PRINT((ndo, "\n\t Remaining LS length %u < 4", ls_length));
810 return(ls_end);
812 tlv_type = EXTRACT_16BITS(tptr);
813 tlv_length = EXTRACT_16BITS(tptr+2);
814 tptr+=4;
815 ls_length-=4;
817 ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u, value: ",
818 tok2str(lsa_opaque_ri_tlv_values,"unknown",tlv_type),
819 tlv_type,
820 tlv_length));
822 if (tlv_length > ls_length) {
823 ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length,
824 ls_length));
825 return(ls_end);
827 ND_TCHECK2(*tptr, tlv_length);
828 switch(tlv_type) {
830 case LS_OPAQUE_RI_TLV_CAP:
831 if (tlv_length != 4) {
832 ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length));
833 return(ls_end);
835 ND_PRINT((ndo, "Capabilities: %s",
836 bittok2str(lsa_opaque_ri_tlv_cap_values, "Unknown", EXTRACT_32BITS(tptr))));
837 break;
838 default:
839 if (ndo->ndo_vflag <= 1) {
840 if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
841 return(ls_end);
843 break;
846 tptr+=tlv_length;
847 ls_length-=tlv_length;
849 break;
851 case LS_OPAQUE_TYPE_GRACE:
852 if (ospf_print_grace_lsa(ndo, (const uint8_t *)(&lsap->lsa_un.un_grace_tlv.type),
853 ls_length) == -1) {
854 return(ls_end);
856 break;
858 case LS_OPAQUE_TYPE_TE:
859 if (ospf_print_te_lsa(ndo, (const uint8_t *)(&lsap->lsa_un.un_te_lsa_tlv.type),
860 ls_length) == -1) {
861 return(ls_end);
863 break;
865 default:
866 if (ndo->ndo_vflag <= 1) {
867 if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown,
868 "\n\t ", ls_length))
869 return(ls_end);
871 break;
875 /* do we want to see an additionally hexdump ? */
876 if (ndo->ndo_vflag> 1)
877 if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown,
878 "\n\t ", ls_length)) {
879 return(ls_end);
882 return (ls_end);
883 trunc:
884 return (NULL);
887 static int
888 ospf_decode_lls(netdissect_options *ndo,
889 register const struct ospfhdr *op, register u_int length)
891 register const u_char *dptr;
892 register const u_char *dataend;
893 register u_int length2;
894 register uint16_t lls_type, lls_len;
895 register uint32_t lls_flags;
897 switch (op->ospf_type) {
899 case OSPF_TYPE_HELLO:
900 if (!(op->ospf_hello.hello_options & OSPF_OPTION_L))
901 return (0);
902 break;
904 case OSPF_TYPE_DD:
905 if (!(op->ospf_db.db_options & OSPF_OPTION_L))
906 return (0);
907 break;
909 default:
910 return (0);
913 /* dig deeper if LLS data is available; see RFC4813 */
914 length2 = EXTRACT_16BITS(&op->ospf_len);
915 dptr = (const u_char *)op + length2;
916 dataend = (const u_char *)op + length;
918 if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) {
919 dptr = dptr + op->ospf_authdata[3];
920 length2 += op->ospf_authdata[3];
922 if (length2 >= length) {
923 ND_PRINT((ndo, "\n\t[LLS truncated]"));
924 return (1);
926 ND_TCHECK2(*dptr, 2);
927 ND_PRINT((ndo, "\n\t LLS: checksum: 0x%04x", (u_int)EXTRACT_16BITS(dptr)));
929 dptr += 2;
930 ND_TCHECK2(*dptr, 2);
931 length2 = EXTRACT_16BITS(dptr);
932 ND_PRINT((ndo, ", length: %u", length2));
934 dptr += 2;
935 ND_TCHECK(*dptr);
936 while (dptr < dataend) {
937 ND_TCHECK2(*dptr, 2);
938 lls_type = EXTRACT_16BITS(dptr);
939 ND_PRINT((ndo, "\n\t %s (%u)",
940 tok2str(ospf_lls_tlv_values,"Unknown TLV",lls_type),
941 lls_type));
942 dptr += 2;
943 ND_TCHECK2(*dptr, 2);
944 lls_len = EXTRACT_16BITS(dptr);
945 ND_PRINT((ndo, ", length: %u", lls_len));
946 dptr += 2;
947 switch (lls_type) {
949 case OSPF_LLS_EO:
950 if (lls_len != 4) {
951 ND_PRINT((ndo, " [should be 4]"));
952 lls_len = 4;
954 ND_TCHECK2(*dptr, 4);
955 lls_flags = EXTRACT_32BITS(dptr);
956 ND_PRINT((ndo, "\n\t Options: 0x%08x [%s]", lls_flags,
957 bittok2str(ospf_lls_eo_options, "?", lls_flags)));
959 break;
961 case OSPF_LLS_MD5:
962 if (lls_len != 20) {
963 ND_PRINT((ndo, " [should be 20]"));
964 lls_len = 20;
966 ND_TCHECK2(*dptr, 4);
967 ND_PRINT((ndo, "\n\t Sequence number: 0x%08x", EXTRACT_32BITS(dptr)));
968 break;
971 dptr += lls_len;
974 return (0);
975 trunc:
976 return (1);
979 static int
980 ospf_decode_v2(netdissect_options *ndo,
981 register const struct ospfhdr *op, register const u_char *dataend)
983 register const struct in_addr *ap;
984 register const struct lsr *lsrp;
985 register const struct lsa_hdr *lshp;
986 register const struct lsa *lsap;
987 register uint32_t lsa_count,lsa_count_max;
989 switch (op->ospf_type) {
991 case OSPF_TYPE_UMD:
993 * Rob Coltun's special monitoring packets;
994 * do nothing
996 break;
998 case OSPF_TYPE_HELLO:
999 ND_TCHECK(op->ospf_hello.hello_options);
1000 ND_PRINT((ndo, "\n\tOptions [%s]",
1001 bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options)));
1003 ND_TCHECK(op->ospf_hello.hello_deadint);
1004 ND_PRINT((ndo, "\n\t Hello Timer %us, Dead Timer %us, Mask %s, Priority %u",
1005 EXTRACT_16BITS(&op->ospf_hello.hello_helloint),
1006 EXTRACT_32BITS(&op->ospf_hello.hello_deadint),
1007 ipaddr_string(ndo, &op->ospf_hello.hello_mask),
1008 op->ospf_hello.hello_priority));
1010 ND_TCHECK(op->ospf_hello.hello_dr);
1011 if (op->ospf_hello.hello_dr.s_addr != 0)
1012 ND_PRINT((ndo, "\n\t Designated Router %s",
1013 ipaddr_string(ndo, &op->ospf_hello.hello_dr)));
1015 ND_TCHECK(op->ospf_hello.hello_bdr);
1016 if (op->ospf_hello.hello_bdr.s_addr != 0)
1017 ND_PRINT((ndo, ", Backup Designated Router %s",
1018 ipaddr_string(ndo, &op->ospf_hello.hello_bdr)));
1020 ap = op->ospf_hello.hello_neighbor;
1021 if ((const u_char *)ap < dataend)
1022 ND_PRINT((ndo, "\n\t Neighbor List:"));
1023 while ((const u_char *)ap < dataend) {
1024 ND_TCHECK(*ap);
1025 ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
1026 ++ap;
1028 break; /* HELLO */
1030 case OSPF_TYPE_DD:
1031 ND_TCHECK(op->ospf_db.db_options);
1032 ND_PRINT((ndo, "\n\tOptions [%s]",
1033 bittok2str(ospf_option_values, "none", op->ospf_db.db_options)));
1034 ND_TCHECK(op->ospf_db.db_flags);
1035 ND_PRINT((ndo, ", DD Flags [%s]",
1036 bittok2str(ospf_dd_flag_values, "none", op->ospf_db.db_flags)));
1037 ND_TCHECK(op->ospf_db.db_ifmtu);
1038 if (op->ospf_db.db_ifmtu) {
1039 ND_PRINT((ndo, ", MTU: %u", EXTRACT_16BITS(&op->ospf_db.db_ifmtu)));
1041 ND_TCHECK(op->ospf_db.db_seq);
1042 ND_PRINT((ndo, ", Sequence: 0x%08x", EXTRACT_32BITS(&op->ospf_db.db_seq)));
1044 /* Print all the LS adv's */
1045 lshp = op->ospf_db.db_lshdr;
1046 while (((const u_char *)lshp < dataend) && ospf_print_lshdr(ndo, lshp) != -1) {
1047 ++lshp;
1049 break;
1051 case OSPF_TYPE_LS_REQ:
1052 lsrp = op->ospf_lsr;
1053 while ((const u_char *)lsrp < dataend) {
1054 ND_TCHECK(*lsrp);
1056 ND_PRINT((ndo, "\n\t Advertising Router: %s, %s LSA (%u)",
1057 ipaddr_string(ndo, &lsrp->ls_router),
1058 tok2str(lsa_values,"unknown",EXTRACT_32BITS(lsrp->ls_type)),
1059 EXTRACT_32BITS(&lsrp->ls_type)));
1061 switch (EXTRACT_32BITS(lsrp->ls_type)) {
1062 /* the LSA header for opaque LSAs was slightly changed */
1063 case LS_TYPE_OPAQUE_LL:
1064 case LS_TYPE_OPAQUE_AL:
1065 case LS_TYPE_OPAQUE_DW:
1066 ND_PRINT((ndo, ", Opaque-Type: %s LSA (%u), Opaque-ID: %u",
1067 tok2str(lsa_opaque_values, "unknown",lsrp->un_ls_stateid.opaque_field.opaque_type),
1068 lsrp->un_ls_stateid.opaque_field.opaque_type,
1069 EXTRACT_24BITS(&lsrp->un_ls_stateid.opaque_field.opaque_id)));
1070 break;
1071 default:
1072 ND_PRINT((ndo, ", LSA-ID: %s",
1073 ipaddr_string(ndo, &lsrp->un_ls_stateid.ls_stateid)));
1074 break;
1077 ++lsrp;
1079 break;
1081 case OSPF_TYPE_LS_UPDATE:
1082 lsap = op->ospf_lsu.lsu_lsa;
1083 ND_TCHECK(op->ospf_lsu.lsu_count);
1084 lsa_count_max = EXTRACT_32BITS(&op->ospf_lsu.lsu_count);
1085 ND_PRINT((ndo, ", %d LSA%s", lsa_count_max, PLURAL_SUFFIX(lsa_count_max)));
1086 for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) {
1087 ND_PRINT((ndo, "\n\t LSA #%u", lsa_count));
1088 lsap = (const struct lsa *)ospf_print_lsa(ndo, lsap);
1089 if (lsap == NULL)
1090 goto trunc;
1092 break;
1094 case OSPF_TYPE_LS_ACK:
1095 lshp = op->ospf_lsa.lsa_lshdr;
1096 while (ospf_print_lshdr(ndo, lshp) != -1) {
1097 ++lshp;
1099 break;
1101 default:
1102 break;
1104 return (0);
1105 trunc:
1106 return (1);
1109 void
1110 ospf_print(netdissect_options *ndo,
1111 register const u_char *bp, register u_int length,
1112 const u_char *bp2 _U_)
1114 register const struct ospfhdr *op;
1115 register const u_char *dataend;
1116 register const char *cp;
1118 op = (const struct ospfhdr *)bp;
1120 /* XXX Before we do anything else, strip off the MD5 trailer */
1121 ND_TCHECK(op->ospf_authtype);
1122 if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) {
1123 length -= OSPF_AUTH_MD5_LEN;
1124 ndo->ndo_snapend -= OSPF_AUTH_MD5_LEN;
1127 /* If the type is valid translate it, or just print the type */
1128 /* value. If it's not valid, say so and return */
1129 ND_TCHECK(op->ospf_type);
1130 cp = tok2str(type2str, "unknown LS-type", op->ospf_type);
1131 ND_PRINT((ndo, "OSPFv%u, %s, length %u", op->ospf_version, cp, length));
1132 if (*cp == 'u')
1133 return;
1135 if (!ndo->ndo_vflag) { /* non verbose - so lets bail out here */
1136 return;
1139 ND_TCHECK(op->ospf_len);
1140 if (length != EXTRACT_16BITS(&op->ospf_len)) {
1141 ND_PRINT((ndo, " [len %d]", EXTRACT_16BITS(&op->ospf_len)));
1144 if (length > EXTRACT_16BITS(&op->ospf_len)) {
1145 dataend = bp + EXTRACT_16BITS(&op->ospf_len);
1146 } else {
1147 dataend = bp + length;
1150 ND_TCHECK(op->ospf_routerid);
1151 ND_PRINT((ndo, "\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf_routerid)));
1153 ND_TCHECK(op->ospf_areaid);
1154 if (op->ospf_areaid.s_addr != 0)
1155 ND_PRINT((ndo, ", Area %s", ipaddr_string(ndo, &op->ospf_areaid)));
1156 else
1157 ND_PRINT((ndo, ", Backbone Area"));
1159 if (ndo->ndo_vflag) {
1160 /* Print authentication data (should we really do this?) */
1161 ND_TCHECK2(op->ospf_authdata[0], sizeof(op->ospf_authdata));
1163 ND_PRINT((ndo, ", Authentication Type: %s (%u)",
1164 tok2str(ospf_authtype_values, "unknown", EXTRACT_16BITS(&op->ospf_authtype)),
1165 EXTRACT_16BITS(&op->ospf_authtype)));
1167 switch (EXTRACT_16BITS(&op->ospf_authtype)) {
1169 case OSPF_AUTH_NONE:
1170 break;
1172 case OSPF_AUTH_SIMPLE:
1173 ND_PRINT((ndo, "\n\tSimple text password: "));
1174 safeputs(ndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
1175 break;
1177 case OSPF_AUTH_MD5:
1178 ND_PRINT((ndo, "\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
1179 *((op->ospf_authdata) + 2),
1180 *((op->ospf_authdata) + 3),
1181 EXTRACT_32BITS((op->ospf_authdata) + 4)));
1182 break;
1184 default:
1185 return;
1188 /* Do rest according to version. */
1189 switch (op->ospf_version) {
1191 case 2:
1192 /* ospf version 2 */
1193 if (ospf_decode_v2(ndo, op, dataend))
1194 goto trunc;
1195 if (length > EXTRACT_16BITS(&op->ospf_len)) {
1196 if (ospf_decode_lls(ndo, op, length))
1197 goto trunc;
1199 break;
1201 default:
1202 ND_PRINT((ndo, " ospf [version %d]", op->ospf_version));
1203 break;
1204 } /* end switch on version */
1206 return;
1207 trunc:
1208 ND_PRINT((ndo, "%s", tstr));