]> The Tcpdump Group git mirrors - tcpdump/blob - print-ospf.c
On Solaris, for 64-bit builds, use the 64-bit pcap-config.
[tcpdump] / print-ospf.c
1 /*
2 * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
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.
20 *
21 * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
22 */
23
24 /* \summary: Open Shortest Path First (OSPF) printer */
25
26 #ifdef HAVE_CONFIG_H
27 #include <config.h>
28 #endif
29
30 #include "netdissect-stdinc.h"
31
32 #include "netdissect.h"
33 #include "addrtoname.h"
34 #include "extract.h"
35 #include "gmpls.h"
36
37 #include "ospf.h"
38
39
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" },
49 { 0, NULL }
50 };
51
52 static const struct tok ospf_authtype_values[] = {
53 { OSPF_AUTH_NONE, "none" },
54 { OSPF_AUTH_SIMPLE, "simple" },
55 { OSPF_AUTH_MD5, "MD5" },
56 { 0, NULL }
57 };
58
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" },
66 { 0, NULL }
67 };
68
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" },
75 { 0, NULL }
76 };
77
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 }
90 };
91
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 }
98 };
99
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 }
105 };
106
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 }
111 };
112
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 }
129 };
130
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 }
136 };
137
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 }
144 };
145
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 }
150 };
151
152 static const struct tok lsa_opaque_ri_tlv_values[] = {
153 { LS_OPAQUE_RI_TLV_CAP, "Router Capabilities" },
154 { 0, NULL }
155 };
156
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 }
169 };
170
171 static const struct tok ospf_lls_tlv_values[] = {
172 { OSPF_LLS_EO, "Extended Options" },
173 { OSPF_LLS_MD5, "MD5 Authentication" },
174 { 0, NULL }
175 };
176
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 }
181 };
182
183 int
184 ospf_grace_lsa_print(netdissect_options *ndo,
185 const u_char *tptr, u_int ls_length)
186 {
187 u_int tlv_type, tlv_length;
188
189
190 while (ls_length > 0) {
191 ND_TCHECK_4(tptr);
192 if (ls_length < 4) {
193 ND_PRINT("\n\t Remaining LS length %u < 4", ls_length);
194 return -1;
195 }
196 tlv_type = GET_BE_U_2(tptr);
197 tlv_length = GET_BE_U_2(tptr + 2);
198 tptr+=4;
199 ls_length-=4;
200
201 ND_PRINT("\n\t %s TLV (%u), length %u, value: ",
202 tok2str(lsa_opaque_grace_tlv_values,"unknown",tlv_type),
203 tlv_type,
204 tlv_length);
205
206 if (tlv_length > ls_length) {
207 ND_PRINT("\n\t Bogus length %u > %u", tlv_length,
208 ls_length);
209 return -1;
210 }
211
212 /* Infinite loop protection. */
213 if (tlv_type == 0 || tlv_length ==0) {
214 return -1;
215 }
216
217 ND_TCHECK_LEN(tptr, tlv_length);
218 switch(tlv_type) {
219
220 case LS_OPAQUE_GRACE_TLV_PERIOD:
221 if (tlv_length != 4) {
222 ND_PRINT("\n\t Bogus length %u != 4", tlv_length);
223 return -1;
224 }
225 ND_PRINT("%us", GET_BE_U_4(tptr));
226 break;
227
228 case LS_OPAQUE_GRACE_TLV_REASON:
229 if (tlv_length != 1) {
230 ND_PRINT("\n\t Bogus length %u != 1", tlv_length);
231 return -1;
232 }
233 ND_PRINT("%s (%u)",
234 tok2str(lsa_opaque_grace_tlv_reason_values, "Unknown", GET_U_1(tptr)),
235 GET_U_1(tptr));
236 break;
237
238 case LS_OPAQUE_GRACE_TLV_INT_ADDRESS:
239 if (tlv_length != 4) {
240 ND_PRINT("\n\t Bogus length %u != 4", tlv_length);
241 return -1;
242 }
243 ND_PRINT("%s", GET_IPADDR_STRING(tptr));
244 break;
245
246 default:
247 if (ndo->ndo_vflag <= 1) {
248 if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
249 return -1;
250 }
251 break;
252
253 }
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;
259 }
260
261 return 0;
262 trunc:
263 return -1;
264 }
265
266 int
267 ospf_te_lsa_print(netdissect_options *ndo,
268 const u_char *tptr, u_int ls_length)
269 {
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;
276
277 while (ls_length != 0) {
278 ND_TCHECK_4(tptr);
279 if (ls_length < 4) {
280 ND_PRINT("\n\t Remaining LS length %u < 4", ls_length);
281 return -1;
282 }
283 tlv_type = GET_BE_U_2(tptr);
284 tlv_length = GET_BE_U_2(tptr + 2);
285 tptr+=4;
286 ls_length-=4;
287
288 ND_PRINT("\n\t %s TLV (%u), length: %u",
289 tok2str(lsa_opaque_te_tlv_values,"unknown",tlv_type),
290 tlv_type,
291 tlv_length);
292
293 if (tlv_length > ls_length) {
294 ND_PRINT("\n\t Bogus length %u > %u", tlv_length,
295 ls_length);
296 return -1;
297 }
298
299 /* Infinite loop protection. */
300 if (tlv_type == 0 || tlv_length ==0) {
301 return -1;
302 }
303
304 switch(tlv_type) {
305 case LS_OPAQUE_TE_TLV_LINK:
306 while (tlv_length != 0) {
307 if (tlv_length < 4) {
308 ND_PRINT("\n\t Remaining TLV length %u < 4",
309 tlv_length);
310 return -1;
311 }
312 subtlv_type = GET_BE_U_2(tptr);
313 subtlv_length = GET_BE_U_2(tptr + 2);
314 tptr+=4;
315 tlv_length-=4;
316
317 /* Infinite loop protection */
318 if (subtlv_type == 0 || subtlv_length == 0)
319 goto invalid;
320
321 ND_PRINT("\n\t %s subTLV (%u), length: %u",
322 tok2str(lsa_opaque_te_link_tlv_subtlv_values,"unknown",subtlv_type),
323 subtlv_type,
324 subtlv_length);
325
326 if (tlv_length < subtlv_length) {
327 ND_PRINT("\n\t Remaining TLV length %u < %u",
328 tlv_length + 4, subtlv_length + 4);
329 return -1;
330 }
331 ND_TCHECK_LEN(tptr, subtlv_length);
332 switch(subtlv_type) {
333 case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP:
334 if (subtlv_length != 4) {
335 ND_PRINT(" != 4");
336 goto invalid;
337 }
338 ND_PRINT(", 0x%08x", GET_BE_U_4(tptr));
339 break;
340 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID:
341 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID:
342 if (subtlv_length != 4 && subtlv_length != 8) {
343 ND_PRINT(" != 4 && != 8");
344 goto invalid;
345 }
346 ND_PRINT(", %s (0x%08x)",
347 GET_IPADDR_STRING(tptr),
348 GET_BE_U_4(tptr));
349 if (subtlv_length == 8) /* rfc4203 */
350 ND_PRINT(", %s (0x%08x)",
351 GET_IPADDR_STRING(tptr+4),
352 GET_BE_U_4(tptr + 4));
353 break;
354 case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP:
355 case LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP:
356 if (subtlv_length != 4) {
357 ND_PRINT(" != 4");
358 goto invalid;
359 }
360 ND_PRINT(", %s", GET_IPADDR_STRING(tptr));
361 break;
362 case LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW:
363 case LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW:
364 if (subtlv_length != 4) {
365 ND_PRINT(" != 4");
366 goto invalid;
367 }
368 bw.i = GET_BE_U_4(tptr);
369 ND_PRINT(", %.3f Mbps", bw.f * 8 / 1000000);
370 break;
371 case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW:
372 if (subtlv_length != 32) {
373 ND_PRINT(" != 32");
374 goto invalid;
375 }
376 for (te_class = 0; te_class < 8; te_class++) {
377 bw.i = GET_BE_U_4(tptr + te_class * 4);
378 ND_PRINT("\n\t\tTE-Class %u: %.3f Mbps",
379 te_class,
380 bw.f * 8 / 1000000);
381 }
382 break;
383 case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS:
384 if (subtlv_length < 4) {
385 ND_PRINT(" < 4");
386 goto invalid;
387 }
388 /* BC Model Id (1 octet) + Reserved (3 octets) */
389 ND_PRINT("\n\t\tBandwidth Constraints Model ID: %s (%u)",
390 tok2str(diffserv_te_bc_values, "unknown", GET_U_1(tptr)),
391 GET_U_1(tptr));
392 if (subtlv_length % 4 != 0) {
393 ND_PRINT("\n\t\tlength %u != N x 4", subtlv_length);
394 goto invalid;
395 }
396 if (subtlv_length > 36) {
397 ND_PRINT("\n\t\tlength %u > 36", subtlv_length);
398 goto invalid;
399 }
400 /* decode BCs until the subTLV ends */
401 for (te_class = 0; te_class < (subtlv_length-4)/4; te_class++) {
402 bw.i = GET_BE_U_4(tptr + 4 + te_class * 4);
403 ND_PRINT("\n\t\t Bandwidth constraint CT%u: %.3f Mbps",
404 te_class,
405 bw.f * 8 / 1000000);
406 }
407 break;
408 case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC:
409 if (subtlv_length != 4) {
410 ND_PRINT(" != 4");
411 goto invalid;
412 }
413 ND_PRINT(", Metric %u", GET_BE_U_4(tptr));
414 break;
415 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE:
416 /* Protection Cap (1 octet) + Reserved ((3 octets) */
417 if (subtlv_length != 4) {
418 ND_PRINT(" != 4");
419 goto invalid;
420 }
421 ND_PRINT(", %s",
422 bittok2str(gmpls_link_prot_values, "none", GET_U_1(tptr)));
423 break;
424 case LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR:
425 if (subtlv_length < 36) {
426 ND_PRINT(" < 36");
427 goto invalid;
428 }
429 /* Switching Cap (1 octet) + Encoding (1) + Reserved (2) */
430 ND_PRINT("\n\t\tInterface Switching Capability: %s",
431 tok2str(gmpls_switch_cap_values, "Unknown", GET_U_1((tptr))));
432 ND_PRINT("\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:",
433 tok2str(gmpls_encoding_values, "Unknown", GET_U_1((tptr + 1))));
434 for (priority_level = 0; priority_level < 8; priority_level++) {
435 bw.i = GET_BE_U_4(tptr + 4 + (priority_level * 4));
436 ND_PRINT("\n\t\t priority level %u: %.3f Mbps",
437 priority_level,
438 bw.f * 8 / 1000000);
439 }
440 break;
441 case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE:
442 if (subtlv_length != 1) {
443 ND_PRINT(" != 1");
444 goto invalid;
445 }
446 ND_PRINT(", %s (%u)",
447 tok2str(lsa_opaque_te_tlv_link_type_sub_tlv_values,"unknown",GET_U_1(tptr)),
448 GET_U_1(tptr));
449 break;
450
451 case LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP:
452 if (subtlv_length % 4 != 0) {
453 ND_PRINT(" != N x 4");
454 goto invalid;
455 }
456 count_srlg = subtlv_length / 4;
457 if (count_srlg != 0)
458 ND_PRINT("\n\t\t Shared risk group: ");
459 while (count_srlg > 0) {
460 bw.i = GET_BE_U_4(tptr);
461 ND_PRINT("%u", bw.i);
462 tptr+=4;
463 count_srlg--;
464 if (count_srlg > 0)
465 ND_PRINT(", ");
466 }
467 break;
468
469 default:
470 if (ndo->ndo_vflag <= 1) {
471 if (!print_unknown_data(ndo, tptr, "\n\t\t", subtlv_length))
472 return -1;
473 }
474 break;
475 }
476 /* in OSPF everything has to be 32-bit aligned, including subTLVs */
477 if (subtlv_length%4 != 0)
478 subtlv_length+=4-(subtlv_length%4);
479
480 if (tlv_length < subtlv_length) {
481 ND_PRINT("\n\t Remaining TLV length %u < %u",
482 tlv_length + 4, subtlv_length + 4);
483 return -1;
484 }
485 tlv_length-=subtlv_length;
486 tptr+=subtlv_length;
487
488 }
489 break;
490
491 case LS_OPAQUE_TE_TLV_ROUTER:
492 if (tlv_length < 4) {
493 ND_PRINT("\n\t TLV length %u < 4", tlv_length);
494 return -1;
495 }
496 ND_PRINT(", %s", GET_IPADDR_STRING(tptr));
497 break;
498
499 default:
500 if (ndo->ndo_vflag <= 1) {
501 if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
502 return -1;
503 }
504 break;
505 }
506 /* in OSPF everything has to be 32-bit aligned, including TLVs */
507 if (tlv_length%4 != 0)
508 tlv_length+=4-(tlv_length%4);
509 if (tlv_length > ls_length) {
510 ND_PRINT("\n\t Bogus padded length %u > %u", tlv_length,
511 ls_length);
512 return -1;
513 }
514 ls_length-=tlv_length;
515 tptr+=tlv_length;
516 }
517 return 0;
518 trunc:
519 return -1;
520 invalid:
521 nd_print_invalid(ndo);
522 return -1;
523 }
524
525 static int
526 ospf_print_lshdr(netdissect_options *ndo,
527 const struct lsa_hdr *lshp)
528 {
529 u_int ls_type;
530 u_int ls_length;
531
532 ls_length = GET_BE_U_2(lshp->ls_length);
533 if (ls_length < sizeof(struct lsa_hdr)) {
534 ND_PRINT("\n\t Bogus length %u < header (%zu)", ls_length,
535 sizeof(struct lsa_hdr));
536 return(-1);
537 }
538 ND_PRINT("\n\t Advertising Router %s, seq 0x%08x, age %us, length %zu",
539 GET_IPADDR_STRING(lshp->ls_router),
540 GET_BE_U_4(lshp->ls_seq),
541 GET_BE_U_2(lshp->ls_age),
542 ls_length - sizeof(struct lsa_hdr));
543 ls_type = GET_U_1(lshp->ls_type);
544 switch (ls_type) {
545 /* the LSA header for opaque LSAs was slightly changed */
546 case LS_TYPE_OPAQUE_LL:
547 case LS_TYPE_OPAQUE_AL:
548 case LS_TYPE_OPAQUE_DW:
549 ND_PRINT("\n\t %s LSA (%u), Opaque-Type %s LSA (%u), Opaque-ID %u",
550 tok2str(lsa_values,"unknown",ls_type),
551 ls_type,
552
553 tok2str(lsa_opaque_values,
554 "unknown",
555 GET_U_1(lshp->un_lsa_id.opaque_field.opaque_type)),
556 GET_U_1(lshp->un_lsa_id.opaque_field.opaque_type),
557 GET_BE_U_3(lshp->un_lsa_id.opaque_field.opaque_id)
558
559 );
560 break;
561
562 /* all other LSA types use regular style LSA headers */
563 default:
564 ND_PRINT("\n\t %s LSA (%u), LSA-ID: %s",
565 tok2str(lsa_values,"unknown",ls_type),
566 ls_type,
567 GET_IPADDR_STRING(lshp->un_lsa_id.lsa_id));
568 break;
569 }
570 ND_PRINT("\n\t Options: [%s]",
571 bittok2str(ospf_option_values, "none", GET_U_1(lshp->ls_options)));
572
573 return (ls_length);
574 }
575
576 /* draft-ietf-ospf-mt-09 */
577 static const struct tok ospf_topology_values[] = {
578 { 0, "default" },
579 { 1, "multicast" },
580 { 2, "management" },
581 { 0, NULL }
582 };
583
584 /*
585 * Print all the per-topology metrics.
586 */
587 static void
588 ospf_print_tos_metrics(netdissect_options *ndo,
589 const union un_tos *tos)
590 {
591 u_int metric_count;
592 u_int toscount;
593 u_int tos_type;
594
595 toscount = GET_U_1(tos->link.link_tos_count)+1;
596 metric_count = 0;
597
598 /*
599 * All but the first metric contain a valid topology id.
600 */
601 while (toscount != 0) {
602 tos_type = GET_U_1(tos->metrics.tos_type);
603 ND_PRINT("\n\t\ttopology %s (%u), metric %u",
604 tok2str(ospf_topology_values, "Unknown",
605 metric_count ? tos_type : 0),
606 metric_count ? tos_type : 0,
607 GET_BE_U_2(tos->metrics.tos_metric));
608 metric_count++;
609 tos++;
610 toscount--;
611 }
612 }
613
614 /*
615 * Print a single link state advertisement. If truncated or if LSA length
616 * field is less than the length of the LSA header, return NULl, else
617 * return pointer to data past end of LSA.
618 */
619 static const uint8_t *
620 ospf_print_lsa(netdissect_options *ndo,
621 const struct lsa *lsap)
622 {
623 const uint8_t *ls_end;
624 const struct rlalink *rlp;
625 const nd_ipv4 *ap;
626 const struct aslametric *almp;
627 const struct mcla *mcp;
628 const uint8_t *lp;
629 u_int tlv_type, tlv_length, rla_count, topology;
630 int ospf_print_lshdr_ret;
631 u_int ls_length;
632 const uint8_t *tptr;
633
634 tptr = (const uint8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */
635 ospf_print_lshdr_ret = ospf_print_lshdr(ndo, &lsap->ls_hdr);
636 if (ospf_print_lshdr_ret < 0)
637 return(NULL);
638 ls_length = (u_int)ospf_print_lshdr_ret;
639 ls_end = (const uint8_t *)lsap + ls_length;
640 /*
641 * ospf_print_lshdr() returns -1 if the length is too short,
642 * so we know ls_length is >= sizeof(struct lsa_hdr).
643 */
644 ls_length -= sizeof(struct lsa_hdr);
645
646 switch (GET_U_1(lsap->ls_hdr.ls_type)) {
647
648 case LS_TYPE_ROUTER:
649 ND_PRINT("\n\t Router LSA Options: [%s]",
650 bittok2str(ospf_rla_flag_values, "none", GET_U_1(lsap->lsa_un.un_rla.rla_flags)));
651
652 rla_count = GET_BE_U_2(lsap->lsa_un.un_rla.rla_count);
653 ND_TCHECK_SIZE(lsap->lsa_un.un_rla.rla_link);
654 rlp = lsap->lsa_un.un_rla.rla_link;
655 for (u_int i = rla_count; i != 0; i--) {
656 ND_TCHECK_SIZE(rlp);
657 switch (GET_U_1(rlp->un_tos.link.link_type)) {
658
659 case RLA_TYPE_VIRTUAL:
660 ND_PRINT("\n\t Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
661 GET_IPADDR_STRING(rlp->link_id),
662 GET_IPADDR_STRING(rlp->link_data));
663 break;
664
665 case RLA_TYPE_ROUTER:
666 ND_PRINT("\n\t Neighbor Router-ID: %s, Interface Address: %s",
667 GET_IPADDR_STRING(rlp->link_id),
668 GET_IPADDR_STRING(rlp->link_data));
669 break;
670
671 case RLA_TYPE_TRANSIT:
672 ND_PRINT("\n\t Neighbor Network-ID: %s, Interface Address: %s",
673 GET_IPADDR_STRING(rlp->link_id),
674 GET_IPADDR_STRING(rlp->link_data));
675 break;
676
677 case RLA_TYPE_STUB:
678 ND_PRINT("\n\t Stub Network: %s, Mask: %s",
679 GET_IPADDR_STRING(rlp->link_id),
680 GET_IPADDR_STRING(rlp->link_data));
681 break;
682
683 default:
684 ND_PRINT("\n\t Unknown Router Link Type (%u)",
685 GET_U_1(rlp->un_tos.link.link_type));
686 return (ls_end);
687 }
688
689 ospf_print_tos_metrics(ndo, &rlp->un_tos);
690
691 rlp = (const struct rlalink *)((const u_char *)(rlp + 1) +
692 (GET_U_1(rlp->un_tos.link.link_tos_count) * sizeof(union un_tos)));
693 }
694 break;
695
696 case LS_TYPE_NETWORK:
697 ND_PRINT("\n\t Mask %s\n\t Connected Routers:",
698 GET_IPADDR_STRING(lsap->lsa_un.un_nla.nla_mask));
699 ap = lsap->lsa_un.un_nla.nla_router;
700 while ((const u_char *)ap < ls_end) {
701 ND_TCHECK_SIZE(ap);
702 ND_PRINT("\n\t %s", GET_IPADDR_STRING(*ap));
703 ++ap;
704 }
705 break;
706
707 case LS_TYPE_SUM_IP:
708 ND_TCHECK_4(lsap->lsa_un.un_nla.nla_mask);
709 ND_PRINT("\n\t Mask %s",
710 GET_IPADDR_STRING(lsap->lsa_un.un_sla.sla_mask));
711 ND_TCHECK_SIZE(lsap->lsa_un.un_sla.sla_tosmetric);
712 lp = (const uint8_t *)lsap->lsa_un.un_sla.sla_tosmetric;
713 while (lp < ls_end) {
714 uint32_t ul;
715
716 ul = GET_BE_U_4(lp);
717 topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
718 ND_PRINT("\n\t\ttopology %s (%u) metric %u",
719 tok2str(ospf_topology_values, "Unknown", topology),
720 topology,
721 ul & SLA_MASK_METRIC);
722 lp += 4;
723 }
724 break;
725
726 case LS_TYPE_SUM_ABR:
727 ND_TCHECK_SIZE(lsap->lsa_un.un_sla.sla_tosmetric);
728 lp = (const uint8_t *)lsap->lsa_un.un_sla.sla_tosmetric;
729 while (lp < ls_end) {
730 uint32_t ul;
731
732 ul = GET_BE_U_4(lp);
733 topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
734 ND_PRINT("\n\t\ttopology %s (%u) metric %u",
735 tok2str(ospf_topology_values, "Unknown", topology),
736 topology,
737 ul & SLA_MASK_METRIC);
738 lp += 4;
739 }
740 break;
741
742 case LS_TYPE_ASE:
743 case LS_TYPE_NSSA: /* fall through - those LSAs share the same format */
744 ND_TCHECK_4(lsap->lsa_un.un_nla.nla_mask);
745 ND_PRINT("\n\t Mask %s",
746 GET_IPADDR_STRING(lsap->lsa_un.un_asla.asla_mask));
747
748 ND_TCHECK_SIZE(lsap->lsa_un.un_sla.sla_tosmetric);
749 almp = lsap->lsa_un.un_asla.asla_metric;
750 while ((const u_char *)almp < ls_end) {
751 uint32_t ul;
752
753 ul = GET_BE_U_4(almp->asla_tosmetric);
754 topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS);
755 ND_PRINT("\n\t\ttopology %s (%u), type %u, metric",
756 tok2str(ospf_topology_values, "Unknown", topology),
757 topology,
758 (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1);
759 if ((ul & ASLA_MASK_METRIC) == 0xffffff)
760 ND_PRINT(" infinite");
761 else
762 ND_PRINT(" %u", (ul & ASLA_MASK_METRIC));
763
764 if (GET_IPV4_TO_NETWORK_ORDER(almp->asla_forward) != 0) {
765 ND_PRINT(", forward %s", GET_IPADDR_STRING(almp->asla_forward));
766 }
767 if (GET_IPV4_TO_NETWORK_ORDER(almp->asla_tag) != 0) {
768 ND_PRINT(", tag %s", GET_IPADDR_STRING(almp->asla_tag));
769 }
770 ++almp;
771 }
772 break;
773
774 case LS_TYPE_GROUP:
775 /* Multicast extensions as of 23 July 1991 */
776 mcp = lsap->lsa_un.un_mcla;
777 while ((const u_char *)mcp < ls_end) {
778 switch (GET_BE_U_4(mcp->mcla_vtype)) {
779
780 case MCLA_VERTEX_ROUTER:
781 ND_PRINT("\n\t Router Router-ID %s",
782 GET_IPADDR_STRING(mcp->mcla_vid));
783 break;
784
785 case MCLA_VERTEX_NETWORK:
786 ND_PRINT("\n\t Network Designated Router %s",
787 GET_IPADDR_STRING(mcp->mcla_vid));
788 break;
789
790 default:
791 ND_PRINT("\n\t unknown VertexType (%u)",
792 GET_BE_U_4(mcp->mcla_vtype));
793 break;
794 }
795 ++mcp;
796 }
797 break;
798
799 case LS_TYPE_OPAQUE_LL: /* fall through */
800 case LS_TYPE_OPAQUE_AL:
801 case LS_TYPE_OPAQUE_DW:
802
803 switch (GET_U_1(lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) {
804 case LS_OPAQUE_TYPE_RI:
805 tptr = (const uint8_t *)(lsap->lsa_un.un_ri_tlv);
806
807 u_int ls_length_remaining = ls_length;
808 while (ls_length_remaining != 0) {
809 ND_TCHECK_4(tptr);
810 if (ls_length_remaining < 4) {
811 ND_PRINT("\n\t Remaining LS length %u < 4", ls_length_remaining);
812 return(ls_end);
813 }
814 tlv_type = GET_BE_U_2(tptr);
815 tlv_length = GET_BE_U_2(tptr + 2);
816 tptr+=4;
817 ls_length_remaining-=4;
818
819 ND_PRINT("\n\t %s TLV (%u), length: %u, value: ",
820 tok2str(lsa_opaque_ri_tlv_values,"unknown",tlv_type),
821 tlv_type,
822 tlv_length);
823
824 if (tlv_length > ls_length_remaining) {
825 ND_PRINT("\n\t Bogus length %u > remaining LS length %u", tlv_length,
826 ls_length_remaining);
827 return(ls_end);
828 }
829 ND_TCHECK_LEN(tptr, tlv_length);
830 switch(tlv_type) {
831
832 case LS_OPAQUE_RI_TLV_CAP:
833 if (tlv_length != 4) {
834 ND_PRINT("\n\t Bogus length %u != 4", tlv_length);
835 return(ls_end);
836 }
837 ND_PRINT("Capabilities: %s",
838 bittok2str(lsa_opaque_ri_tlv_cap_values, "Unknown", GET_BE_U_4(tptr)));
839 break;
840 default:
841 if (ndo->ndo_vflag <= 1) {
842 if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
843 return(ls_end);
844 }
845 break;
846
847 }
848 tptr+=tlv_length;
849 ls_length_remaining-=tlv_length;
850 }
851 break;
852
853 case LS_OPAQUE_TYPE_GRACE:
854 if (ospf_grace_lsa_print(ndo, (const u_char *)(lsap->lsa_un.un_grace_tlv),
855 ls_length) == -1) {
856 return(ls_end);
857 }
858 break;
859
860 case LS_OPAQUE_TYPE_TE:
861 if (ospf_te_lsa_print(ndo, (const u_char *)(lsap->lsa_un.un_te_lsa_tlv),
862 ls_length) == -1) {
863 return(ls_end);
864 }
865 break;
866
867 default:
868 if (ndo->ndo_vflag <= 1) {
869 if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown,
870 "\n\t ", ls_length))
871 return(ls_end);
872 }
873 break;
874 }
875 }
876
877 /* do we want to see an additionally hexdump ? */
878 if (ndo->ndo_vflag> 1)
879 if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown,
880 "\n\t ", ls_length)) {
881 return(ls_end);
882 }
883
884 return (ls_end);
885 trunc:
886 return (NULL);
887 }
888
889 static void
890 ospf_decode_lls(netdissect_options *ndo,
891 const struct ospfhdr *op, u_int length)
892 {
893 const u_char *dptr;
894 const u_char *dataend;
895 u_int length2;
896 uint16_t lls_type, lls_len;
897 uint32_t lls_flags;
898
899 switch (GET_U_1(op->ospf_type)) {
900
901 case OSPF_TYPE_HELLO:
902 if (!(GET_U_1(op->ospf_hello.hello_options) & OSPF_OPTION_L))
903 return;
904 break;
905
906 case OSPF_TYPE_DD:
907 if (!(GET_U_1(op->ospf_db.db_options) & OSPF_OPTION_L))
908 return;
909 break;
910
911 default:
912 return;
913 }
914
915 /* dig deeper if LLS data is available; see RFC4813 */
916 length2 = GET_BE_U_2(op->ospf_len);
917 dptr = (const u_char *)op + length2;
918 dataend = (const u_char *)op + length;
919
920 if (GET_BE_U_2(op->ospf_authtype) == OSPF_AUTH_MD5) {
921 dptr = dptr + GET_U_1(op->ospf_authdata + 3);
922 length2 += GET_U_1(op->ospf_authdata + 3);
923 }
924 if (length2 >= length) {
925 ND_PRINT("\n\t[LLS truncated]");
926 return;
927 }
928 ND_PRINT("\n\t LLS: checksum: 0x%04x", (u_int) GET_BE_U_2(dptr));
929
930 dptr += 2;
931 length2 = GET_BE_U_2(dptr);
932 ND_PRINT(", length: %u", length2);
933
934 dptr += 2;
935 while (dptr < dataend) {
936 lls_type = GET_BE_U_2(dptr);
937 ND_PRINT("\n\t %s (%u)",
938 tok2str(ospf_lls_tlv_values,"Unknown TLV",lls_type),
939 lls_type);
940 dptr += 2;
941 lls_len = GET_BE_U_2(dptr);
942 ND_PRINT(", length: %u", lls_len);
943 dptr += 2;
944 switch (lls_type) {
945
946 case OSPF_LLS_EO:
947 if (lls_len != 4) {
948 ND_PRINT(" [should be 4]");
949 lls_len = 4;
950 }
951 lls_flags = GET_BE_U_4(dptr);
952 ND_PRINT("\n\t Options: 0x%08x [%s]", lls_flags,
953 bittok2str(ospf_lls_eo_options, "?", lls_flags));
954
955 break;
956
957 case OSPF_LLS_MD5:
958 if (lls_len != 20) {
959 ND_PRINT(" [should be 20]");
960 lls_len = 20;
961 }
962 ND_PRINT("\n\t Sequence number: 0x%08x", GET_BE_U_4(dptr));
963 break;
964 }
965
966 dptr += lls_len;
967 }
968 }
969
970 static int
971 ospf_decode_v2(netdissect_options *ndo,
972 const struct ospfhdr *op, const u_char *dataend)
973 {
974 const nd_ipv4 *ap;
975 const struct lsr *lsrp;
976 const struct lsa_hdr *lshp;
977 const struct lsa *lsap;
978 uint32_t lsa_count,lsa_count_max;
979
980 switch (GET_U_1(op->ospf_type)) {
981
982 case OSPF_TYPE_HELLO:
983 ND_PRINT("\n\tOptions [%s]",
984 bittok2str(ospf_option_values,"none",GET_U_1(op->ospf_hello.hello_options)));
985
986 ND_PRINT("\n\t Hello Timer %us, Dead Timer %us, Mask %s, Priority %u",
987 GET_BE_U_2(op->ospf_hello.hello_helloint),
988 GET_BE_U_4(op->ospf_hello.hello_deadint),
989 GET_IPADDR_STRING(op->ospf_hello.hello_mask),
990 GET_U_1(op->ospf_hello.hello_priority));
991
992 if (GET_IPV4_TO_NETWORK_ORDER(op->ospf_hello.hello_dr) != 0)
993 ND_PRINT("\n\t Designated Router %s",
994 GET_IPADDR_STRING(op->ospf_hello.hello_dr));
995
996 if (GET_IPV4_TO_NETWORK_ORDER(op->ospf_hello.hello_bdr) != 0)
997 ND_PRINT(", Backup Designated Router %s",
998 GET_IPADDR_STRING(op->ospf_hello.hello_bdr));
999
1000 ap = op->ospf_hello.hello_neighbor;
1001 if ((const u_char *)ap < dataend)
1002 ND_PRINT("\n\t Neighbor List:");
1003 while ((const u_char *)ap < dataend) {
1004 ND_TCHECK_SIZE(ap);
1005 ND_PRINT("\n\t %s", GET_IPADDR_STRING(*ap));
1006 ++ap;
1007 }
1008 break; /* HELLO */
1009
1010 case OSPF_TYPE_DD:
1011 ND_PRINT("\n\tOptions [%s]",
1012 bittok2str(ospf_option_values, "none", GET_U_1(op->ospf_db.db_options)));
1013 ND_PRINT(", DD Flags [%s]",
1014 bittok2str(ospf_dd_flag_values, "none", GET_U_1(op->ospf_db.db_flags)));
1015 if (GET_BE_U_2(op->ospf_db.db_ifmtu)) {
1016 ND_PRINT(", MTU: %u",
1017 GET_BE_U_2(op->ospf_db.db_ifmtu));
1018 }
1019 ND_PRINT(", Sequence: 0x%08x", GET_BE_U_4(op->ospf_db.db_seq));
1020
1021 /* Print all the LS adv's */
1022 lshp = op->ospf_db.db_lshdr;
1023 while (((const u_char *)lshp < dataend) && ospf_print_lshdr(ndo, lshp) != -1) {
1024 ++lshp;
1025 }
1026 break;
1027
1028 case OSPF_TYPE_LS_REQ:
1029 lsrp = op->ospf_lsr;
1030 while ((const u_char *)lsrp < dataend) {
1031 ND_TCHECK_SIZE(lsrp);
1032
1033 ND_PRINT("\n\t Advertising Router: %s, %s LSA (%u)",
1034 GET_IPADDR_STRING(lsrp->ls_router),
1035 tok2str(lsa_values,"unknown",GET_BE_U_4(lsrp->ls_type)),
1036 GET_BE_U_4(lsrp->ls_type));
1037
1038 switch (GET_BE_U_4(lsrp->ls_type)) {
1039 /* the LSA header for opaque LSAs was slightly changed */
1040 case LS_TYPE_OPAQUE_LL:
1041 case LS_TYPE_OPAQUE_AL:
1042 case LS_TYPE_OPAQUE_DW:
1043 ND_PRINT(", Opaque-Type: %s LSA (%u), Opaque-ID: %u",
1044 tok2str(lsa_opaque_values, "unknown",GET_U_1(lsrp->un_ls_stateid.opaque_field.opaque_type)),
1045 GET_U_1(lsrp->un_ls_stateid.opaque_field.opaque_type),
1046 GET_BE_U_3(lsrp->un_ls_stateid.opaque_field.opaque_id));
1047 break;
1048 default:
1049 ND_PRINT(", LSA-ID: %s",
1050 GET_IPADDR_STRING(lsrp->un_ls_stateid.ls_stateid));
1051 break;
1052 }
1053
1054 ++lsrp;
1055 }
1056 break;
1057
1058 case OSPF_TYPE_LS_UPDATE:
1059 lsap = op->ospf_lsu.lsu_lsa;
1060 lsa_count_max = GET_BE_U_4(op->ospf_lsu.lsu_count);
1061 ND_PRINT(", %u LSA%s", lsa_count_max, PLURAL_SUFFIX(lsa_count_max));
1062 for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) {
1063 ND_PRINT("\n\t LSA #%u", lsa_count);
1064 lsap = (const struct lsa *)ospf_print_lsa(ndo, lsap);
1065 if (lsap == NULL)
1066 goto trunc;
1067 }
1068 break;
1069
1070 case OSPF_TYPE_LS_ACK:
1071 lshp = op->ospf_lsa.lsa_lshdr;
1072 while (ospf_print_lshdr(ndo, lshp) != -1) {
1073 ++lshp;
1074 }
1075 break;
1076
1077 default:
1078 break;
1079 }
1080 return (0);
1081 trunc:
1082 return (1);
1083 }
1084
1085 void
1086 ospf_print(netdissect_options *ndo,
1087 const u_char *bp, u_int length,
1088 const u_char *bp2 _U_)
1089 {
1090 const struct ospfhdr *op;
1091 const u_char *dataend;
1092 const char *cp;
1093
1094 ndo->ndo_protocol = "ospf2";
1095 op = (const struct ospfhdr *)bp;
1096
1097 /* XXX Before we do anything else, strip off the MD5 trailer */
1098 if (GET_BE_U_2(op->ospf_authtype) == OSPF_AUTH_MD5) {
1099 length -= OSPF_AUTH_MD5_LEN;
1100 ndo->ndo_snapend -= OSPF_AUTH_MD5_LEN;
1101 }
1102
1103 /* If the type is valid translate it, or just print the type */
1104 /* value. If it's not valid, say so and return */
1105 cp = tok2str(type2str, "unknown LS-type %u", GET_U_1(op->ospf_type));
1106 ND_PRINT("OSPFv%u, %s, length %u", GET_U_1(op->ospf_version), cp,
1107 length);
1108 if (*cp == 'u')
1109 return;
1110
1111 if (!ndo->ndo_vflag) { /* non verbose - so lets bail out here */
1112 return;
1113 }
1114
1115 if (length != GET_BE_U_2(op->ospf_len)) {
1116 ND_PRINT(" [len %u]", GET_BE_U_2(op->ospf_len));
1117 }
1118
1119 if (length > GET_BE_U_2(op->ospf_len)) {
1120 dataend = bp + GET_BE_U_2(op->ospf_len);
1121 } else {
1122 dataend = bp + length;
1123 }
1124
1125 ND_PRINT("\n\tRouter-ID %s", GET_IPADDR_STRING(op->ospf_routerid));
1126
1127 if (GET_IPV4_TO_NETWORK_ORDER(op->ospf_areaid) != 0)
1128 ND_PRINT(", Area %s", GET_IPADDR_STRING(op->ospf_areaid));
1129 else
1130 ND_PRINT(", Backbone Area");
1131
1132 if (ndo->ndo_vflag) {
1133 /* Print authentication data (should we really do this?) */
1134 ND_TCHECK_LEN(op->ospf_authdata, sizeof(op->ospf_authdata));
1135
1136 ND_PRINT(", Authentication Type: %s (%u)",
1137 tok2str(ospf_authtype_values, "unknown", GET_BE_U_2(op->ospf_authtype)),
1138 GET_BE_U_2(op->ospf_authtype));
1139
1140 switch (GET_BE_U_2(op->ospf_authtype)) {
1141
1142 case OSPF_AUTH_NONE:
1143 break;
1144
1145 case OSPF_AUTH_SIMPLE:
1146 ND_PRINT("\n\tSimple text password: ");
1147 nd_printjnp(ndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
1148 break;
1149
1150 case OSPF_AUTH_MD5:
1151 ND_PRINT("\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
1152 GET_U_1(op->ospf_authdata + 2),
1153 GET_U_1(op->ospf_authdata + 3),
1154 GET_BE_U_4((op->ospf_authdata) + 4));
1155 break;
1156
1157 default:
1158 return;
1159 }
1160 }
1161 /* Do rest according to version. */
1162 switch (GET_U_1(op->ospf_version)) {
1163
1164 case 2:
1165 /* ospf version 2 */
1166 if (ospf_decode_v2(ndo, op, dataend))
1167 goto trunc;
1168 if (length > GET_BE_U_2(op->ospf_len))
1169 ospf_decode_lls(ndo, op, length);
1170 break;
1171
1172 default:
1173 ND_PRINT(" ospf [version %u]", GET_U_1(op->ospf_version));
1174 break;
1175 } /* end switch on version */
1176
1177 return;
1178 trunc:
1179 nd_trunc_longjmp(ndo);
1180 }