]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_vty.c
ospfd: remove unused code
[mirror_frr.git] / ospfd / ospf_vty.c
1 /* OSPF VTY interface.
2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
3 * Copyright (C) 2000 Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23 #include <zebra.h>
24
25 #include "memory.h"
26 #include "thread.h"
27 #include "prefix.h"
28 #include "table.h"
29 #include "vty.h"
30 #include "command.h"
31 #include "plist.h"
32 #include "log.h"
33 #include "zclient.h"
34
35 #include "ospfd/ospfd.h"
36 #include "ospfd/ospf_asbr.h"
37 #include "ospfd/ospf_lsa.h"
38 #include "ospfd/ospf_lsdb.h"
39 #include "ospfd/ospf_ism.h"
40 #include "ospfd/ospf_interface.h"
41 #include "ospfd/ospf_nsm.h"
42 #include "ospfd/ospf_neighbor.h"
43 #include "ospfd/ospf_flood.h"
44 #include "ospfd/ospf_abr.h"
45 #include "ospfd/ospf_spf.h"
46 #include "ospfd/ospf_route.h"
47 #include "ospfd/ospf_zebra.h"
48 /*#include "ospfd/ospf_routemap.h" */
49 #include "ospfd/ospf_vty.h"
50 #include "ospfd/ospf_dump.h"
51
52 \f
53 static const char *ospf_network_type_str[] =
54 {
55 "Null",
56 "POINTOPOINT",
57 "BROADCAST",
58 "NBMA",
59 "POINTOMULTIPOINT",
60 "VIRTUALLINK",
61 "LOOPBACK"
62 };
63
64 \f
65 /* Utility functions. */
66 static int
67 ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
68 {
69 char *endptr = NULL;
70 unsigned long ret;
71
72 /* match "A.B.C.D". */
73 if (strchr (str, '.') != NULL)
74 {
75 ret = inet_aton (str, area_id);
76 if (!ret)
77 return -1;
78 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
79 }
80 /* match "<0-4294967295>". */
81 else
82 {
83 ret = strtoul (str, &endptr, 10);
84 if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE))
85 return -1;
86
87 area_id->s_addr = htonl (ret);
88 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
89 }
90
91 return 0;
92 }
93
94 \f
95 static int
96 str2metric (const char *str, int *metric)
97 {
98 /* Sanity check. */
99 if (str == NULL)
100 return 0;
101
102 *metric = strtol (str, NULL, 10);
103 if (*metric < 0 && *metric > 16777214)
104 {
105 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
106 return 0;
107 }
108
109 return 1;
110 }
111
112 static int
113 str2metric_type (const char *str, int *metric_type)
114 {
115 /* Sanity check. */
116 if (str == NULL)
117 return 0;
118
119 if (strncmp (str, "1", 1) == 0)
120 *metric_type = EXTERNAL_METRIC_TYPE_1;
121 else if (strncmp (str, "2", 1) == 0)
122 *metric_type = EXTERNAL_METRIC_TYPE_2;
123 else
124 return 0;
125
126 return 1;
127 }
128
129 int
130 ospf_oi_count (struct interface *ifp)
131 {
132 struct route_node *rn;
133 int i = 0;
134
135 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
136 if (rn->info)
137 i++;
138
139 return i;
140 }
141
142 \f
143 DEFUN (router_ospf,
144 router_ospf_cmd,
145 "router ospf",
146 "Enable a routing process\n"
147 "Start OSPF configuration\n")
148 {
149 vty->node = OSPF_NODE;
150 vty->index = ospf_get ();
151
152 return CMD_SUCCESS;
153 }
154
155 DEFUN (no_router_ospf,
156 no_router_ospf_cmd,
157 "no router ospf",
158 NO_STR
159 "Enable a routing process\n"
160 "Start OSPF configuration\n")
161 {
162 struct ospf *ospf;
163
164 ospf = ospf_lookup ();
165 if (ospf == NULL)
166 {
167 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
168 return CMD_WARNING;
169 }
170
171 ospf_finish (ospf);
172
173 return CMD_SUCCESS;
174 }
175
176 DEFUN (ospf_router_id,
177 ospf_router_id_cmd,
178 "ospf router-id A.B.C.D",
179 "OSPF specific commands\n"
180 "router-id for the OSPF process\n"
181 "OSPF router-id in IP address format\n")
182 {
183 struct ospf *ospf = vty->index;
184 struct in_addr router_id;
185 int ret;
186
187 ret = inet_aton (argv[0], &router_id);
188 if (!ret)
189 {
190 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
191 return CMD_WARNING;
192 }
193
194 ospf->router_id_static = router_id;
195
196 ospf_router_id_update (ospf);
197
198 return CMD_SUCCESS;
199 }
200
201 ALIAS (ospf_router_id,
202 router_ospf_id_cmd,
203 "router-id A.B.C.D",
204 "router-id for the OSPF process\n"
205 "OSPF router-id in IP address format\n")
206
207 DEFUN (no_ospf_router_id,
208 no_ospf_router_id_cmd,
209 "no ospf router-id",
210 NO_STR
211 "OSPF specific commands\n"
212 "router-id for the OSPF process\n")
213 {
214 struct ospf *ospf = vty->index;
215
216 ospf->router_id_static.s_addr = 0;
217
218 ospf_router_id_update (ospf);
219
220 return CMD_SUCCESS;
221 }
222
223 ALIAS (no_ospf_router_id,
224 no_router_ospf_id_cmd,
225 "no router-id",
226 NO_STR
227 "router-id for the OSPF process\n")
228
229 static void
230 ospf_passive_interface_default (struct ospf *ospf, u_char newval)
231 {
232 struct listnode *ln;
233 struct interface *ifp;
234 struct ospf_interface *oi;
235
236 ospf->passive_interface_default = newval;
237
238 for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp))
239 {
240 if (ifp &&
241 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
242 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface);
243 }
244 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi))
245 {
246 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
247 UNSET_IF_PARAM (oi->params, passive_interface);
248 /* update multicast memberships */
249 ospf_if_set_multicast(oi);
250 }
251 }
252
253 static void
254 ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
255 struct in_addr addr,
256 struct ospf_if_params *params, u_char value)
257 {
258 u_char dflt;
259
260 params->passive_interface = value;
261 if (params != IF_DEF_PARAMS (ifp))
262 {
263 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
264 dflt = IF_DEF_PARAMS (ifp)->passive_interface;
265 else
266 dflt = ospf->passive_interface_default;
267
268 if (value != dflt)
269 SET_IF_PARAM (params, passive_interface);
270 else
271 UNSET_IF_PARAM (params, passive_interface);
272
273 ospf_free_if_params (ifp, addr);
274 ospf_if_update_params (ifp, addr);
275 }
276 else
277 {
278 if (value != ospf->passive_interface_default)
279 SET_IF_PARAM (params, passive_interface);
280 else
281 UNSET_IF_PARAM (params, passive_interface);
282 }
283 }
284
285 DEFUN (ospf_passive_interface,
286 ospf_passive_interface_addr_cmd,
287 "passive-interface IFNAME A.B.C.D",
288 "Suppress routing updates on an interface\n"
289 "Interface's name\n")
290 {
291 struct interface *ifp;
292 struct in_addr addr;
293 int ret;
294 struct ospf_if_params *params;
295 struct route_node *rn;
296 struct ospf *ospf = vty->index;
297
298 if (argc == 0)
299 {
300 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
301 return CMD_SUCCESS;
302 }
303
304 ifp = if_get_by_name (argv[0]);
305
306 params = IF_DEF_PARAMS (ifp);
307
308 if (argc == 2)
309 {
310 ret = inet_aton(argv[1], &addr);
311 if (!ret)
312 {
313 vty_out (vty, "Please specify interface address by A.B.C.D%s",
314 VTY_NEWLINE);
315 return CMD_WARNING;
316 }
317
318 params = ospf_get_if_params (ifp, addr);
319 ospf_if_update_params (ifp, addr);
320 }
321 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE);
322
323 /* XXX We should call ospf_if_set_multicast on exactly those
324 * interfaces for which the passive property changed. It is too much
325 * work to determine this set, so we do this for every interface.
326 * This is safe and reasonable because ospf_if_set_multicast uses a
327 * record of joined groups to avoid systems calls if the desired
328 * memberships match the current memership.
329 */
330
331 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
332 {
333 struct ospf_interface *oi = rn->info;
334
335 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
336 ospf_if_set_multicast(oi);
337 }
338 /*
339 * XXX It is not clear what state transitions the interface needs to
340 * undergo when going from active to passive. Fixing this will
341 * require precise identification of interfaces having such a
342 * transition.
343 */
344
345 return CMD_SUCCESS;
346 }
347
348 ALIAS (ospf_passive_interface,
349 ospf_passive_interface_cmd,
350 "passive-interface IFNAME",
351 "Suppress routing updates on an interface\n"
352 "Interface's name\n")
353
354 ALIAS (ospf_passive_interface,
355 ospf_passive_interface_default_cmd,
356 "passive-interface default",
357 "Suppress routing updates on an interface\n"
358 "Suppress routing updates on interfaces by default\n")
359
360 DEFUN (no_ospf_passive_interface,
361 no_ospf_passive_interface_addr_cmd,
362 "no passive-interface IFNAME A.B.C.D",
363 NO_STR
364 "Allow routing updates on an interface\n"
365 "Interface's name\n")
366 {
367 struct interface *ifp;
368 struct in_addr addr;
369 struct ospf_if_params *params;
370 int ret;
371 struct route_node *rn;
372 struct ospf *ospf = vty->index;
373
374 if (argc == 0)
375 {
376 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
377 return CMD_SUCCESS;
378 }
379
380 ifp = if_get_by_name (argv[0]);
381
382 params = IF_DEF_PARAMS (ifp);
383
384 if (argc == 2)
385 {
386 ret = inet_aton(argv[1], &addr);
387 if (!ret)
388 {
389 vty_out (vty, "Please specify interface address by A.B.C.D%s",
390 VTY_NEWLINE);
391 return CMD_WARNING;
392 }
393
394 params = ospf_lookup_if_params (ifp, addr);
395 if (params == NULL)
396 return CMD_SUCCESS;
397 }
398 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE);
399
400 /* XXX We should call ospf_if_set_multicast on exactly those
401 * interfaces for which the passive property changed. It is too much
402 * work to determine this set, so we do this for every interface.
403 * This is safe and reasonable because ospf_if_set_multicast uses a
404 * record of joined groups to avoid systems calls if the desired
405 * memberships match the current memership.
406 */
407 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
408 {
409 struct ospf_interface *oi = rn->info;
410
411 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
412 ospf_if_set_multicast(oi);
413 }
414
415 return CMD_SUCCESS;
416 }
417
418 ALIAS (no_ospf_passive_interface,
419 no_ospf_passive_interface_cmd,
420 "no passive-interface IFNAME",
421 NO_STR
422 "Allow routing updates on an interface\n"
423 "Interface's name\n")
424
425 ALIAS (no_ospf_passive_interface,
426 no_ospf_passive_interface_default_cmd,
427 "no passive-interface default",
428 NO_STR
429 "Allow routing updates on an interface\n"
430 "Allow routing updates on interfaces by default\n")
431
432 DEFUN (ospf_network_area,
433 ospf_network_area_cmd,
434 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
435 "Enable routing on an IP network\n"
436 "OSPF network prefix\n"
437 "Set the OSPF area ID\n"
438 "OSPF area ID in IP address format\n"
439 "OSPF area ID as a decimal value\n")
440 {
441 struct ospf *ospf= vty->index;
442 struct prefix_ipv4 p;
443 struct in_addr area_id;
444 int ret, format;
445
446 /* Get network prefix and Area ID. */
447 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
448 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
449
450 ret = ospf_network_set (ospf, &p, area_id);
451 if (ret == 0)
452 {
453 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
454 return CMD_WARNING;
455 }
456
457 return CMD_SUCCESS;
458 }
459
460 DEFUN (no_ospf_network_area,
461 no_ospf_network_area_cmd,
462 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
463 NO_STR
464 "Enable routing on an IP network\n"
465 "OSPF network prefix\n"
466 "Set the OSPF area ID\n"
467 "OSPF area ID in IP address format\n"
468 "OSPF area ID as a decimal value\n")
469 {
470 struct ospf *ospf = (struct ospf *) vty->index;
471 struct prefix_ipv4 p;
472 struct in_addr area_id;
473 int ret, format;
474
475 /* Get network prefix and Area ID. */
476 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
477 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
478
479 ret = ospf_network_unset (ospf, &p, area_id);
480 if (ret == 0)
481 {
482 vty_out (vty, "Can't find specified network area configuration.%s",
483 VTY_NEWLINE);
484 return CMD_WARNING;
485 }
486
487 return CMD_SUCCESS;
488 }
489
490 \f
491 DEFUN (ospf_area_range,
492 ospf_area_range_cmd,
493 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
494 "OSPF area parameters\n"
495 "OSPF area ID in IP address format\n"
496 "OSPF area ID as a decimal value\n"
497 "Summarize routes matching address/mask (border routers only)\n"
498 "Area range prefix\n")
499 {
500 struct ospf *ospf = vty->index;
501 struct prefix_ipv4 p;
502 struct in_addr area_id;
503 int format;
504 u_int32_t cost;
505
506 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
507 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
508
509 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
510 if (argc > 2)
511 {
512 VTY_GET_INTEGER ("range cost", cost, argv[2]);
513 ospf_area_range_cost_set (ospf, area_id, &p, cost);
514 }
515
516 return CMD_SUCCESS;
517 }
518
519 ALIAS (ospf_area_range,
520 ospf_area_range_advertise_cmd,
521 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
522 "OSPF area parameters\n"
523 "OSPF area ID in IP address format\n"
524 "OSPF area ID as a decimal value\n"
525 "OSPF area range for route advertise (default)\n"
526 "Area range prefix\n"
527 "Advertise this range (default)\n")
528
529 ALIAS (ospf_area_range,
530 ospf_area_range_cost_cmd,
531 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
532 "OSPF area parameters\n"
533 "OSPF area ID in IP address format\n"
534 "OSPF area ID as a decimal value\n"
535 "Summarize routes matching address/mask (border routers only)\n"
536 "Area range prefix\n"
537 "User specified metric for this range\n"
538 "Advertised metric for this range\n")
539
540 ALIAS (ospf_area_range,
541 ospf_area_range_advertise_cost_cmd,
542 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
543 "OSPF area parameters\n"
544 "OSPF area ID in IP address format\n"
545 "OSPF area ID as a decimal value\n"
546 "Summarize routes matching address/mask (border routers only)\n"
547 "Area range prefix\n"
548 "Advertise this range (default)\n"
549 "User specified metric for this range\n"
550 "Advertised metric for this range\n")
551
552 DEFUN (ospf_area_range_not_advertise,
553 ospf_area_range_not_advertise_cmd,
554 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
555 "OSPF area parameters\n"
556 "OSPF area ID in IP address format\n"
557 "OSPF area ID as a decimal value\n"
558 "Summarize routes matching address/mask (border routers only)\n"
559 "Area range prefix\n"
560 "DoNotAdvertise this range\n")
561 {
562 struct ospf *ospf = vty->index;
563 struct prefix_ipv4 p;
564 struct in_addr area_id;
565 int format;
566
567 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
568 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
569
570 ospf_area_range_set (ospf, area_id, &p, 0);
571
572 return CMD_SUCCESS;
573 }
574
575 DEFUN (no_ospf_area_range,
576 no_ospf_area_range_cmd,
577 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
578 NO_STR
579 "OSPF area parameters\n"
580 "OSPF area ID in IP address format\n"
581 "OSPF area ID as a decimal value\n"
582 "Summarize routes matching address/mask (border routers only)\n"
583 "Area range prefix\n")
584 {
585 struct ospf *ospf = vty->index;
586 struct prefix_ipv4 p;
587 struct in_addr area_id;
588 int format;
589
590 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
591 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
592
593 ospf_area_range_unset (ospf, area_id, &p);
594
595 return CMD_SUCCESS;
596 }
597
598 ALIAS (no_ospf_area_range,
599 no_ospf_area_range_advertise_cmd,
600 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
601 NO_STR
602 "OSPF area parameters\n"
603 "OSPF area ID in IP address format\n"
604 "OSPF area ID as a decimal value\n"
605 "Summarize routes matching address/mask (border routers only)\n"
606 "Area range prefix\n"
607 "Advertise this range (default)\n"
608 "DoNotAdvertise this range\n")
609
610 ALIAS (no_ospf_area_range,
611 no_ospf_area_range_cost_cmd,
612 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
613 NO_STR
614 "OSPF area parameters\n"
615 "OSPF area ID in IP address format\n"
616 "OSPF area ID as a decimal value\n"
617 "Summarize routes matching address/mask (border routers only)\n"
618 "Area range prefix\n"
619 "User specified metric for this range\n"
620 "Advertised metric for this range\n")
621
622 ALIAS (no_ospf_area_range,
623 no_ospf_area_range_advertise_cost_cmd,
624 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
625 NO_STR
626 "OSPF area parameters\n"
627 "OSPF area ID in IP address format\n"
628 "OSPF area ID as a decimal value\n"
629 "Summarize routes matching address/mask (border routers only)\n"
630 "Area range prefix\n"
631 "Advertise this range (default)\n"
632 "User specified metric for this range\n"
633 "Advertised metric for this range\n")
634 \f
635 DEFUN (ospf_area_range_substitute,
636 ospf_area_range_substitute_cmd,
637 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
638 "OSPF area parameters\n"
639 "OSPF area ID in IP address format\n"
640 "OSPF area ID as a decimal value\n"
641 "Summarize routes matching address/mask (border routers only)\n"
642 "Area range prefix\n"
643 "Announce area range as another prefix\n"
644 "Network prefix to be announced instead of range\n")
645 {
646 struct ospf *ospf = vty->index;
647 struct prefix_ipv4 p, s;
648 struct in_addr area_id;
649 int format;
650
651 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
652 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
653 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
654
655 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
656
657 return CMD_SUCCESS;
658 }
659
660 DEFUN (no_ospf_area_range_substitute,
661 no_ospf_area_range_substitute_cmd,
662 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
663 NO_STR
664 "OSPF area parameters\n"
665 "OSPF area ID in IP address format\n"
666 "OSPF area ID as a decimal value\n"
667 "Summarize routes matching address/mask (border routers only)\n"
668 "Area range prefix\n"
669 "Announce area range as another prefix\n"
670 "Network prefix to be announced instead of range\n")
671 {
672 struct ospf *ospf = vty->index;
673 struct prefix_ipv4 p, s;
674 struct in_addr area_id;
675 int format;
676
677 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
678 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
679 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
680
681 ospf_area_range_substitute_unset (ospf, area_id, &p);
682
683 return CMD_SUCCESS;
684 }
685
686 \f
687 /* Command Handler Logic in VLink stuff is delicate!!
688
689 ALTER AT YOUR OWN RISK!!!!
690
691 Various dummy values are used to represent 'NoChange' state for
692 VLink configuration NOT being changed by a VLink command, and
693 special syntax is used within the command strings so that the
694 typed in command verbs can be seen in the configuration command
695 bacckend handler. This is to drastically reduce the verbeage
696 required to coe up with a reasonably compatible Cisco VLink command
697
698 - Matthew Grant <grantma@anathoth.gen.nz>
699 Wed, 21 Feb 2001 15:13:52 +1300
700 */
701
702
703 /* Configuration data for virtual links
704 */
705 struct ospf_vl_config_data {
706 struct vty *vty; /* vty stuff */
707 struct in_addr area_id; /* area ID from command line */
708 int format; /* command line area ID format */
709 struct in_addr vl_peer; /* command line vl_peer */
710 int auth_type; /* Authehntication type, if given */
711 char *auth_key; /* simple password if present */
712 int crypto_key_id; /* Cryptographic key ID */
713 char *md5_key; /* MD5 authentication key */
714 int hello_interval; /* Obvious what these are... */
715 int retransmit_interval;
716 int transmit_delay;
717 int dead_interval;
718 };
719
720 static void
721 ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
722 struct vty *vty)
723 {
724 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
725 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
726 vl_config->vty = vty;
727 }
728
729 static struct ospf_vl_data *
730 ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
731 {
732 struct ospf_area *area;
733 struct ospf_vl_data *vl_data;
734 struct vty *vty;
735 struct in_addr area_id;
736
737 vty = vl_config->vty;
738 area_id = vl_config->area_id;
739
740 if (area_id.s_addr == OSPF_AREA_BACKBONE)
741 {
742 vty_out (vty,
743 "Configuring VLs over the backbone is not allowed%s",
744 VTY_NEWLINE);
745 return NULL;
746 }
747 area = ospf_area_get (ospf, area_id, vl_config->format);
748
749 if (area->external_routing != OSPF_AREA_DEFAULT)
750 {
751 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
752 vty_out (vty, "Area %s is %s%s",
753 inet_ntoa (area_id),
754 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
755 VTY_NEWLINE);
756 else
757 vty_out (vty, "Area %ld is %s%s",
758 (u_long)ntohl (area_id.s_addr),
759 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
760 VTY_NEWLINE);
761 return NULL;
762 }
763
764 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
765 {
766 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
767 if (vl_data->vl_oi == NULL)
768 {
769 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
770 ospf_vl_add (ospf, vl_data);
771 ospf_spf_calculate_schedule (ospf);
772 }
773 }
774 return vl_data;
775 }
776
777
778 static int
779 ospf_vl_set_security (struct ospf_vl_data *vl_data,
780 struct ospf_vl_config_data *vl_config)
781 {
782 struct crypt_key *ck;
783 struct vty *vty;
784 struct interface *ifp = vl_data->vl_oi->ifp;
785
786 vty = vl_config->vty;
787
788 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
789 {
790 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
791 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
792 }
793
794 if (vl_config->auth_key)
795 {
796 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
797 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
798 OSPF_AUTH_SIMPLE_SIZE);
799 }
800 else if (vl_config->md5_key)
801 {
802 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
803 != NULL)
804 {
805 vty_out (vty, "OSPF: Key %d already exists%s",
806 vl_config->crypto_key_id, VTY_NEWLINE);
807 return CMD_WARNING;
808 }
809 ck = ospf_crypt_key_new ();
810 ck->key_id = vl_config->crypto_key_id;
811 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
812 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
813
814 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
815 }
816 else if (vl_config->crypto_key_id != 0)
817 {
818 /* Delete a key */
819
820 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
821 vl_config->crypto_key_id) == NULL)
822 {
823 vty_out (vty, "OSPF: Key %d does not exist%s",
824 vl_config->crypto_key_id, VTY_NEWLINE);
825 return CMD_WARNING;
826 }
827
828 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
829
830 }
831
832 return CMD_SUCCESS;
833 }
834
835 static int
836 ospf_vl_set_timers (struct ospf_vl_data *vl_data,
837 struct ospf_vl_config_data *vl_config)
838 {
839 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
840 /* Virtual Link data initialised to defaults, so only set
841 if a value given */
842 if (vl_config->hello_interval)
843 {
844 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
845 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
846 }
847
848 if (vl_config->dead_interval)
849 {
850 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
851 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
852 }
853
854 if (vl_config->retransmit_interval)
855 {
856 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
857 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
858 }
859
860 if (vl_config->transmit_delay)
861 {
862 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
863 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
864 }
865
866 return CMD_SUCCESS;
867 }
868
869
870
871 /* The business end of all of the above */
872 static int
873 ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
874 {
875 struct ospf_vl_data *vl_data;
876 int ret;
877
878 vl_data = ospf_find_vl_data (ospf, vl_config);
879 if (!vl_data)
880 return CMD_WARNING;
881
882 /* Process this one first as it can have a fatal result, which can
883 only logically occur if the virtual link exists already
884 Thus a command error does not result in a change to the
885 running configuration such as unexpectedly altered timer
886 values etc.*/
887 ret = ospf_vl_set_security (vl_data, vl_config);
888 if (ret != CMD_SUCCESS)
889 return ret;
890
891 /* Set any time based parameters, these area already range checked */
892
893 ret = ospf_vl_set_timers (vl_data, vl_config);
894 if (ret != CMD_SUCCESS)
895 return ret;
896
897 return CMD_SUCCESS;
898
899 }
900
901 /* This stuff exists to make specifying all the alias commands A LOT simpler
902 */
903 #define VLINK_HELPSTR_IPADDR \
904 "OSPF area parameters\n" \
905 "OSPF area ID in IP address format\n" \
906 "OSPF area ID as a decimal value\n" \
907 "Configure a virtual link\n" \
908 "Router ID of the remote ABR\n"
909
910 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
911 "Enable authentication on this virtual link\n" \
912 "dummy string \n"
913
914 #define VLINK_HELPSTR_AUTHTYPE_ALL \
915 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
916 "Use null authentication\n" \
917 "Use message-digest authentication\n"
918
919 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
920 "Time between HELLO packets\n" \
921 "Time between retransmitting lost link state advertisements\n" \
922 "Link state transmit delay\n" \
923 "Interval after which a neighbor is declared dead\n"
924
925 #define VLINK_HELPSTR_TIME_PARAM \
926 VLINK_HELPSTR_TIME_PARAM_NOSECS \
927 "Seconds\n"
928
929 #define VLINK_HELPSTR_AUTH_SIMPLE \
930 "Authentication password (key)\n" \
931 "The OSPF password (key)"
932
933 #define VLINK_HELPSTR_AUTH_MD5 \
934 "Message digest authentication password (key)\n" \
935 "dummy string \n" \
936 "Key ID\n" \
937 "Use MD5 algorithm\n" \
938 "The OSPF password (key)"
939
940 DEFUN (ospf_area_vlink,
941 ospf_area_vlink_cmd,
942 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
943 VLINK_HELPSTR_IPADDR)
944 {
945 struct ospf *ospf = vty->index;
946 struct ospf_vl_config_data vl_config;
947 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
948 char md5_key[OSPF_AUTH_MD5_SIZE+1];
949 int i;
950 int ret;
951
952 ospf_vl_config_data_init(&vl_config, vty);
953
954 /* Read off first 2 parameters and check them */
955 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
956 if (ret < 0)
957 {
958 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
959 return CMD_WARNING;
960 }
961
962 ret = inet_aton (argv[1], &vl_config.vl_peer);
963 if (! ret)
964 {
965 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
966 VTY_NEWLINE);
967 return CMD_WARNING;
968 }
969
970 if (argc <=2)
971 {
972 /* Thats all folks! - BUGS B. strikes again!!!*/
973
974 return ospf_vl_set (ospf, &vl_config);
975 }
976
977 /* Deal with other parameters */
978 for (i=2; i < argc; i++)
979 {
980
981 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
982
983 switch (argv[i][0])
984 {
985
986 case 'a':
987 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
988 {
989 /* authentication-key - this option can occur anywhere on
990 command line. At start of command line
991 must check for authentication option. */
992 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
993 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
994 vl_config.auth_key = auth_key;
995 i++;
996 }
997 else if (strncmp (argv[i], "authentication", 14) == 0)
998 {
999 /* authentication - this option can only occur at start
1000 of command line */
1001 vl_config.auth_type = OSPF_AUTH_SIMPLE;
1002 if ((i+1) < argc)
1003 {
1004 if (strncmp (argv[i+1], "n", 1) == 0)
1005 {
1006 /* "authentication null" */
1007 vl_config.auth_type = OSPF_AUTH_NULL;
1008 i++;
1009 }
1010 else if (strncmp (argv[i+1], "m", 1) == 0
1011 && strcmp (argv[i+1], "message-digest-") != 0)
1012 {
1013 /* "authentication message-digest" */
1014 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1015 i++;
1016 }
1017 }
1018 }
1019 break;
1020
1021 case 'm':
1022 /* message-digest-key */
1023 i++;
1024 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1025 if (vl_config.crypto_key_id < 0)
1026 return CMD_WARNING;
1027 i++;
1028 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
1029 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
1030 vl_config.md5_key = md5_key;
1031 break;
1032
1033 case 'h':
1034 /* Hello interval */
1035 i++;
1036 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1037 if (vl_config.hello_interval < 0)
1038 return CMD_WARNING;
1039 break;
1040
1041 case 'r':
1042 /* Retransmit Interval */
1043 i++;
1044 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1045 if (vl_config.retransmit_interval < 0)
1046 return CMD_WARNING;
1047 break;
1048
1049 case 't':
1050 /* Transmit Delay */
1051 i++;
1052 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1053 if (vl_config.transmit_delay < 0)
1054 return CMD_WARNING;
1055 break;
1056
1057 case 'd':
1058 /* Dead Interval */
1059 i++;
1060 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1061 if (vl_config.dead_interval < 0)
1062 return CMD_WARNING;
1063 break;
1064 }
1065 }
1066
1067
1068 /* Action configuration */
1069
1070 return ospf_vl_set (ospf, &vl_config);
1071
1072 }
1073
1074 DEFUN (no_ospf_area_vlink,
1075 no_ospf_area_vlink_cmd,
1076 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1077 NO_STR
1078 VLINK_HELPSTR_IPADDR)
1079 {
1080 struct ospf *ospf = vty->index;
1081 struct ospf_area *area;
1082 struct ospf_vl_config_data vl_config;
1083 struct ospf_vl_data *vl_data = NULL;
1084 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1085 int i;
1086 int ret, format;
1087
1088 ospf_vl_config_data_init(&vl_config, vty);
1089
1090 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1091 if (ret < 0)
1092 {
1093 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1094 return CMD_WARNING;
1095 }
1096
1097 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
1098 if (!area)
1099 {
1100 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1101 return CMD_WARNING;
1102 }
1103
1104 ret = inet_aton (argv[1], &vl_config.vl_peer);
1105 if (! ret)
1106 {
1107 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1108 VTY_NEWLINE);
1109 return CMD_WARNING;
1110 }
1111
1112 if (argc <=2)
1113 {
1114 /* Basic VLink no command */
1115 /* Thats all folks! - BUGS B. strikes again!!!*/
1116 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
1117 ospf_vl_delete (ospf, vl_data);
1118
1119 ospf_area_check_free (ospf, vl_config.area_id);
1120
1121 return CMD_SUCCESS;
1122 }
1123
1124 /* If we are down here, we are reseting parameters */
1125
1126 /* Deal with other parameters */
1127 for (i=2; i < argc; i++)
1128 {
1129 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1130
1131 switch (argv[i][0])
1132 {
1133
1134 case 'a':
1135 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1136 {
1137 /* authentication-key - this option can occur anywhere on
1138 command line. At start of command line
1139 must check for authentication option. */
1140 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1141 vl_config.auth_key = auth_key;
1142 }
1143 else if (strncmp (argv[i], "authentication", 14) == 0)
1144 {
1145 /* authentication - this option can only occur at start
1146 of command line */
1147 vl_config.auth_type = OSPF_AUTH_NOTSET;
1148 }
1149 break;
1150
1151 case 'm':
1152 /* message-digest-key */
1153 /* Delete one key */
1154 i++;
1155 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1156 if (vl_config.crypto_key_id < 0)
1157 return CMD_WARNING;
1158 vl_config.md5_key = NULL;
1159 break;
1160
1161 case 'h':
1162 /* Hello interval */
1163 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1164 break;
1165
1166 case 'r':
1167 /* Retransmit Interval */
1168 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1169 break;
1170
1171 case 't':
1172 /* Transmit Delay */
1173 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1174 break;
1175
1176 case 'd':
1177 /* Dead Interval */
1178 i++;
1179 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1180 break;
1181 }
1182 }
1183
1184
1185 /* Action configuration */
1186
1187 return ospf_vl_set (ospf, &vl_config);
1188 }
1189
1190 ALIAS (ospf_area_vlink,
1191 ospf_area_vlink_param1_cmd,
1192 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1193 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1194 VLINK_HELPSTR_IPADDR
1195 VLINK_HELPSTR_TIME_PARAM)
1196
1197 ALIAS (no_ospf_area_vlink,
1198 no_ospf_area_vlink_param1_cmd,
1199 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1200 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1201 NO_STR
1202 VLINK_HELPSTR_IPADDR
1203 VLINK_HELPSTR_TIME_PARAM)
1204
1205 ALIAS (ospf_area_vlink,
1206 ospf_area_vlink_param2_cmd,
1207 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1208 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1209 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1210 VLINK_HELPSTR_IPADDR
1211 VLINK_HELPSTR_TIME_PARAM
1212 VLINK_HELPSTR_TIME_PARAM)
1213
1214 ALIAS (no_ospf_area_vlink,
1215 no_ospf_area_vlink_param2_cmd,
1216 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1217 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1218 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1219 NO_STR
1220 VLINK_HELPSTR_IPADDR
1221 VLINK_HELPSTR_TIME_PARAM
1222 VLINK_HELPSTR_TIME_PARAM)
1223
1224 ALIAS (ospf_area_vlink,
1225 ospf_area_vlink_param3_cmd,
1226 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1227 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1228 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1229 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1230 VLINK_HELPSTR_IPADDR
1231 VLINK_HELPSTR_TIME_PARAM
1232 VLINK_HELPSTR_TIME_PARAM
1233 VLINK_HELPSTR_TIME_PARAM)
1234
1235 ALIAS (no_ospf_area_vlink,
1236 no_ospf_area_vlink_param3_cmd,
1237 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1238 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1239 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1240 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1241 NO_STR
1242 VLINK_HELPSTR_IPADDR
1243 VLINK_HELPSTR_TIME_PARAM
1244 VLINK_HELPSTR_TIME_PARAM
1245 VLINK_HELPSTR_TIME_PARAM)
1246
1247 ALIAS (ospf_area_vlink,
1248 ospf_area_vlink_param4_cmd,
1249 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1250 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1251 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1252 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1253 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1254 VLINK_HELPSTR_IPADDR
1255 VLINK_HELPSTR_TIME_PARAM
1256 VLINK_HELPSTR_TIME_PARAM
1257 VLINK_HELPSTR_TIME_PARAM
1258 VLINK_HELPSTR_TIME_PARAM)
1259
1260 ALIAS (no_ospf_area_vlink,
1261 no_ospf_area_vlink_param4_cmd,
1262 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1263 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1264 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1265 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1266 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1267 NO_STR
1268 VLINK_HELPSTR_IPADDR
1269 VLINK_HELPSTR_TIME_PARAM
1270 VLINK_HELPSTR_TIME_PARAM
1271 VLINK_HELPSTR_TIME_PARAM
1272 VLINK_HELPSTR_TIME_PARAM)
1273
1274 ALIAS (ospf_area_vlink,
1275 ospf_area_vlink_authtype_args_cmd,
1276 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1277 "(authentication|) (message-digest|null)",
1278 VLINK_HELPSTR_IPADDR
1279 VLINK_HELPSTR_AUTHTYPE_ALL)
1280
1281 ALIAS (ospf_area_vlink,
1282 ospf_area_vlink_authtype_cmd,
1283 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1284 "(authentication|)",
1285 VLINK_HELPSTR_IPADDR
1286 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1287
1288 ALIAS (no_ospf_area_vlink,
1289 no_ospf_area_vlink_authtype_cmd,
1290 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1291 "(authentication|)",
1292 NO_STR
1293 VLINK_HELPSTR_IPADDR
1294 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1295
1296 ALIAS (ospf_area_vlink,
1297 ospf_area_vlink_md5_cmd,
1298 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1299 "(message-digest-key|) <1-255> md5 KEY",
1300 VLINK_HELPSTR_IPADDR
1301 VLINK_HELPSTR_AUTH_MD5)
1302
1303 ALIAS (no_ospf_area_vlink,
1304 no_ospf_area_vlink_md5_cmd,
1305 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1306 "(message-digest-key|) <1-255>",
1307 NO_STR
1308 VLINK_HELPSTR_IPADDR
1309 VLINK_HELPSTR_AUTH_MD5)
1310
1311 ALIAS (ospf_area_vlink,
1312 ospf_area_vlink_authkey_cmd,
1313 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1314 "(authentication-key|) AUTH_KEY",
1315 VLINK_HELPSTR_IPADDR
1316 VLINK_HELPSTR_AUTH_SIMPLE)
1317
1318 ALIAS (no_ospf_area_vlink,
1319 no_ospf_area_vlink_authkey_cmd,
1320 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1321 "(authentication-key|)",
1322 NO_STR
1323 VLINK_HELPSTR_IPADDR
1324 VLINK_HELPSTR_AUTH_SIMPLE)
1325
1326 ALIAS (ospf_area_vlink,
1327 ospf_area_vlink_authtype_args_authkey_cmd,
1328 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1329 "(authentication|) (message-digest|null) "
1330 "(authentication-key|) AUTH_KEY",
1331 VLINK_HELPSTR_IPADDR
1332 VLINK_HELPSTR_AUTHTYPE_ALL
1333 VLINK_HELPSTR_AUTH_SIMPLE)
1334
1335 ALIAS (ospf_area_vlink,
1336 ospf_area_vlink_authtype_authkey_cmd,
1337 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1338 "(authentication|) "
1339 "(authentication-key|) AUTH_KEY",
1340 VLINK_HELPSTR_IPADDR
1341 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1342 VLINK_HELPSTR_AUTH_SIMPLE)
1343
1344 ALIAS (no_ospf_area_vlink,
1345 no_ospf_area_vlink_authtype_authkey_cmd,
1346 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1347 "(authentication|) "
1348 "(authentication-key|)",
1349 NO_STR
1350 VLINK_HELPSTR_IPADDR
1351 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1352 VLINK_HELPSTR_AUTH_SIMPLE)
1353
1354 ALIAS (ospf_area_vlink,
1355 ospf_area_vlink_authtype_args_md5_cmd,
1356 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1357 "(authentication|) (message-digest|null) "
1358 "(message-digest-key|) <1-255> md5 KEY",
1359 VLINK_HELPSTR_IPADDR
1360 VLINK_HELPSTR_AUTHTYPE_ALL
1361 VLINK_HELPSTR_AUTH_MD5)
1362
1363 ALIAS (ospf_area_vlink,
1364 ospf_area_vlink_authtype_md5_cmd,
1365 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1366 "(authentication|) "
1367 "(message-digest-key|) <1-255> md5 KEY",
1368 VLINK_HELPSTR_IPADDR
1369 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1370 VLINK_HELPSTR_AUTH_MD5)
1371
1372 ALIAS (no_ospf_area_vlink,
1373 no_ospf_area_vlink_authtype_md5_cmd,
1374 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1375 "(authentication|) "
1376 "(message-digest-key|)",
1377 NO_STR
1378 VLINK_HELPSTR_IPADDR
1379 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1380 VLINK_HELPSTR_AUTH_MD5)
1381
1382 \f
1383 DEFUN (ospf_area_shortcut,
1384 ospf_area_shortcut_cmd,
1385 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1386 "OSPF area parameters\n"
1387 "OSPF area ID in IP address format\n"
1388 "OSPF area ID as a decimal value\n"
1389 "Configure the area's shortcutting mode\n"
1390 "Set default shortcutting behavior\n"
1391 "Enable shortcutting through the area\n"
1392 "Disable shortcutting through the area\n")
1393 {
1394 struct ospf *ospf = vty->index;
1395 struct ospf_area *area;
1396 struct in_addr area_id;
1397 int mode;
1398 int format;
1399
1400 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1401
1402 area = ospf_area_get (ospf, area_id, format);
1403
1404 if (strncmp (argv[1], "de", 2) == 0)
1405 mode = OSPF_SHORTCUT_DEFAULT;
1406 else if (strncmp (argv[1], "di", 2) == 0)
1407 mode = OSPF_SHORTCUT_DISABLE;
1408 else if (strncmp (argv[1], "e", 1) == 0)
1409 mode = OSPF_SHORTCUT_ENABLE;
1410 else
1411 return CMD_WARNING;
1412
1413 ospf_area_shortcut_set (ospf, area, mode);
1414
1415 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
1416 vty_out (vty, "Shortcut area setting will take effect "
1417 "only when the router is configured as Shortcut ABR%s",
1418 VTY_NEWLINE);
1419
1420 return CMD_SUCCESS;
1421 }
1422
1423 DEFUN (no_ospf_area_shortcut,
1424 no_ospf_area_shortcut_cmd,
1425 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1426 NO_STR
1427 "OSPF area parameters\n"
1428 "OSPF area ID in IP address format\n"
1429 "OSPF area ID as a decimal value\n"
1430 "Deconfigure the area's shortcutting mode\n"
1431 "Deconfigure enabled shortcutting through the area\n"
1432 "Deconfigure disabled shortcutting through the area\n")
1433 {
1434 struct ospf *ospf = vty->index;
1435 struct ospf_area *area;
1436 struct in_addr area_id;
1437 int format;
1438
1439 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1440
1441 area = ospf_area_lookup_by_area_id (ospf, area_id);
1442 if (!area)
1443 return CMD_SUCCESS;
1444
1445 ospf_area_shortcut_unset (ospf, area);
1446
1447 return CMD_SUCCESS;
1448 }
1449
1450 \f
1451 DEFUN (ospf_area_stub,
1452 ospf_area_stub_cmd,
1453 "area (A.B.C.D|<0-4294967295>) stub",
1454 "OSPF area parameters\n"
1455 "OSPF area ID in IP address format\n"
1456 "OSPF area ID as a decimal value\n"
1457 "Configure OSPF area as stub\n")
1458 {
1459 struct ospf *ospf = vty->index;
1460 struct in_addr area_id;
1461 int ret, format;
1462
1463 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1464
1465 ret = ospf_area_stub_set (ospf, area_id);
1466 if (ret == 0)
1467 {
1468 vty_out (vty, "First deconfigure all virtual link through this area%s",
1469 VTY_NEWLINE);
1470 return CMD_WARNING;
1471 }
1472
1473 ospf_area_no_summary_unset (ospf, area_id);
1474
1475 return CMD_SUCCESS;
1476 }
1477
1478 DEFUN (ospf_area_stub_no_summary,
1479 ospf_area_stub_no_summary_cmd,
1480 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1481 "OSPF stub parameters\n"
1482 "OSPF area ID in IP address format\n"
1483 "OSPF area ID as a decimal value\n"
1484 "Configure OSPF area as stub\n"
1485 "Do not inject inter-area routes into stub\n")
1486 {
1487 struct ospf *ospf = vty->index;
1488 struct in_addr area_id;
1489 int ret, format;
1490
1491 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1492
1493 ret = ospf_area_stub_set (ospf, area_id);
1494 if (ret == 0)
1495 {
1496 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
1497 VTY_NEWLINE);
1498 return CMD_WARNING;
1499 }
1500
1501 ospf_area_no_summary_set (ospf, area_id);
1502
1503 return CMD_SUCCESS;
1504 }
1505
1506 DEFUN (no_ospf_area_stub,
1507 no_ospf_area_stub_cmd,
1508 "no area (A.B.C.D|<0-4294967295>) stub",
1509 NO_STR
1510 "OSPF area parameters\n"
1511 "OSPF area ID in IP address format\n"
1512 "OSPF area ID as a decimal value\n"
1513 "Configure OSPF area as stub\n")
1514 {
1515 struct ospf *ospf = vty->index;
1516 struct in_addr area_id;
1517 int format;
1518
1519 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1520
1521 ospf_area_stub_unset (ospf, area_id);
1522 ospf_area_no_summary_unset (ospf, area_id);
1523
1524 return CMD_SUCCESS;
1525 }
1526
1527 DEFUN (no_ospf_area_stub_no_summary,
1528 no_ospf_area_stub_no_summary_cmd,
1529 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1530 NO_STR
1531 "OSPF area parameters\n"
1532 "OSPF area ID in IP address format\n"
1533 "OSPF area ID as a decimal value\n"
1534 "Configure OSPF area as stub\n"
1535 "Do not inject inter-area routes into area\n")
1536 {
1537 struct ospf *ospf = vty->index;
1538 struct in_addr area_id;
1539 int format;
1540
1541 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1542 ospf_area_no_summary_unset (ospf, area_id);
1543
1544 return CMD_SUCCESS;
1545 }
1546
1547 static int
1548 ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1549 int nosum)
1550 {
1551 struct ospf *ospf = vty->index;
1552 struct in_addr area_id;
1553 int ret, format;
1554
1555 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1556
1557 ret = ospf_area_nssa_set (ospf, area_id);
1558 if (ret == 0)
1559 {
1560 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1561 VTY_NEWLINE);
1562 return CMD_WARNING;
1563 }
1564
1565 if (argc > 1)
1566 {
1567 if (strncmp (argv[1], "translate-c", 11) == 0)
1568 ospf_area_nssa_translator_role_set (ospf, area_id,
1569 OSPF_NSSA_ROLE_CANDIDATE);
1570 else if (strncmp (argv[1], "translate-n", 11) == 0)
1571 ospf_area_nssa_translator_role_set (ospf, area_id,
1572 OSPF_NSSA_ROLE_NEVER);
1573 else if (strncmp (argv[1], "translate-a", 11) == 0)
1574 ospf_area_nssa_translator_role_set (ospf, area_id,
1575 OSPF_NSSA_ROLE_ALWAYS);
1576 }
1577 else
1578 {
1579 ospf_area_nssa_translator_role_set (ospf, area_id,
1580 OSPF_NSSA_ROLE_CANDIDATE);
1581 }
1582
1583 if (nosum)
1584 ospf_area_no_summary_set (ospf, area_id);
1585 else
1586 ospf_area_no_summary_unset (ospf, area_id);
1587
1588 ospf_schedule_abr_task (ospf);
1589
1590 return CMD_SUCCESS;
1591 }
1592
1593 DEFUN (ospf_area_nssa_translate_no_summary,
1594 ospf_area_nssa_translate_no_summary_cmd,
1595 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
1596 "OSPF area parameters\n"
1597 "OSPF area ID in IP address format\n"
1598 "OSPF area ID as a decimal value\n"
1599 "Configure OSPF area as nssa\n"
1600 "Configure NSSA-ABR for translate election (default)\n"
1601 "Configure NSSA-ABR to never translate\n"
1602 "Configure NSSA-ABR to always translate\n"
1603 "Do not inject inter-area routes into nssa\n")
1604 {
1605 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1606 }
1607
1608 DEFUN (ospf_area_nssa_translate,
1609 ospf_area_nssa_translate_cmd,
1610 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1611 "OSPF area parameters\n"
1612 "OSPF area ID in IP address format\n"
1613 "OSPF area ID as a decimal value\n"
1614 "Configure OSPF area as nssa\n"
1615 "Configure NSSA-ABR for translate election (default)\n"
1616 "Configure NSSA-ABR to never translate\n"
1617 "Configure NSSA-ABR to always translate\n")
1618 {
1619 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1620 }
1621
1622 DEFUN (ospf_area_nssa,
1623 ospf_area_nssa_cmd,
1624 "area (A.B.C.D|<0-4294967295>) nssa",
1625 "OSPF area parameters\n"
1626 "OSPF area ID in IP address format\n"
1627 "OSPF area ID as a decimal value\n"
1628 "Configure OSPF area as nssa\n")
1629 {
1630 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1631 }
1632
1633 DEFUN (ospf_area_nssa_no_summary,
1634 ospf_area_nssa_no_summary_cmd,
1635 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1636 "OSPF area parameters\n"
1637 "OSPF area ID in IP address format\n"
1638 "OSPF area ID as a decimal value\n"
1639 "Configure OSPF area as nssa\n"
1640 "Do not inject inter-area routes into nssa\n")
1641 {
1642 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1643 }
1644
1645 DEFUN (no_ospf_area_nssa,
1646 no_ospf_area_nssa_cmd,
1647 "no area (A.B.C.D|<0-4294967295>) nssa",
1648 NO_STR
1649 "OSPF area parameters\n"
1650 "OSPF area ID in IP address format\n"
1651 "OSPF area ID as a decimal value\n"
1652 "Configure OSPF area as nssa\n")
1653 {
1654 struct ospf *ospf = vty->index;
1655 struct in_addr area_id;
1656 int format;
1657
1658 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1659
1660 ospf_area_nssa_unset (ospf, area_id);
1661 ospf_area_no_summary_unset (ospf, area_id);
1662
1663 ospf_schedule_abr_task (ospf);
1664
1665 return CMD_SUCCESS;
1666 }
1667
1668 DEFUN (no_ospf_area_nssa_no_summary,
1669 no_ospf_area_nssa_no_summary_cmd,
1670 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1671 NO_STR
1672 "OSPF area parameters\n"
1673 "OSPF area ID in IP address format\n"
1674 "OSPF area ID as a decimal value\n"
1675 "Configure OSPF area as nssa\n"
1676 "Do not inject inter-area routes into nssa\n")
1677 {
1678 struct ospf *ospf = vty->index;
1679 struct in_addr area_id;
1680 int format;
1681
1682 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1683 ospf_area_no_summary_unset (ospf, area_id);
1684
1685 return CMD_SUCCESS;
1686 }
1687
1688 DEFUN (ospf_area_default_cost,
1689 ospf_area_default_cost_cmd,
1690 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1691 "OSPF area parameters\n"
1692 "OSPF area ID in IP address format\n"
1693 "OSPF area ID as a decimal value\n"
1694 "Set the summary-default cost of a NSSA or stub area\n"
1695 "Stub's advertised default summary cost\n")
1696 {
1697 struct ospf *ospf = vty->index;
1698 struct ospf_area *area;
1699 struct in_addr area_id;
1700 u_int32_t cost;
1701 int format;
1702 struct prefix_ipv4 p;
1703
1704 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1705 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1706
1707 area = ospf_area_get (ospf, area_id, format);
1708
1709 if (area->external_routing == OSPF_AREA_DEFAULT)
1710 {
1711 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1712 return CMD_WARNING;
1713 }
1714
1715 area->default_cost = cost;
1716
1717 p.family = AF_INET;
1718 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1719 p.prefixlen = 0;
1720 if (IS_DEBUG_OSPF_EVENT)
1721 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1722 "announcing 0.0.0.0/0 to area %s",
1723 inet_ntoa (area->area_id));
1724 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1725
1726 return CMD_SUCCESS;
1727 }
1728
1729 DEFUN (no_ospf_area_default_cost,
1730 no_ospf_area_default_cost_cmd,
1731 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1732 NO_STR
1733 "OSPF area parameters\n"
1734 "OSPF area ID in IP address format\n"
1735 "OSPF area ID as a decimal value\n"
1736 "Set the summary-default cost of a NSSA or stub area\n"
1737 "Stub's advertised default summary cost\n")
1738 {
1739 struct ospf *ospf = vty->index;
1740 struct ospf_area *area;
1741 struct in_addr area_id;
1742 u_int32_t cost;
1743 int format;
1744 struct prefix_ipv4 p;
1745
1746 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1747 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1748
1749 area = ospf_area_lookup_by_area_id (ospf, area_id);
1750 if (area == NULL)
1751 return CMD_SUCCESS;
1752
1753 if (area->external_routing == OSPF_AREA_DEFAULT)
1754 {
1755 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1756 return CMD_WARNING;
1757 }
1758
1759 area->default_cost = 1;
1760
1761 p.family = AF_INET;
1762 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1763 p.prefixlen = 0;
1764 if (IS_DEBUG_OSPF_EVENT)
1765 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1766 "announcing 0.0.0.0/0 to area %s",
1767 inet_ntoa (area->area_id));
1768 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1769
1770
1771 ospf_area_check_free (ospf, area_id);
1772
1773 return CMD_SUCCESS;
1774 }
1775
1776 DEFUN (ospf_area_export_list,
1777 ospf_area_export_list_cmd,
1778 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1779 "OSPF area parameters\n"
1780 "OSPF area ID in IP address format\n"
1781 "OSPF area ID as a decimal value\n"
1782 "Set the filter for networks announced to other areas\n"
1783 "Name of the access-list\n")
1784 {
1785 struct ospf *ospf = vty->index;
1786 struct ospf_area *area;
1787 struct in_addr area_id;
1788 int format;
1789
1790 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1791
1792 area = ospf_area_get (ospf, area_id, format);
1793 ospf_area_export_list_set (ospf, area, argv[1]);
1794
1795 return CMD_SUCCESS;
1796 }
1797
1798 DEFUN (no_ospf_area_export_list,
1799 no_ospf_area_export_list_cmd,
1800 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1801 NO_STR
1802 "OSPF area parameters\n"
1803 "OSPF area ID in IP address format\n"
1804 "OSPF area ID as a decimal value\n"
1805 "Unset the filter for networks announced to other areas\n"
1806 "Name of the access-list\n")
1807 {
1808 struct ospf *ospf = vty->index;
1809 struct ospf_area *area;
1810 struct in_addr area_id;
1811 int format;
1812
1813 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1814
1815 area = ospf_area_lookup_by_area_id (ospf, area_id);
1816 if (area == NULL)
1817 return CMD_SUCCESS;
1818
1819 ospf_area_export_list_unset (ospf, area);
1820
1821 return CMD_SUCCESS;
1822 }
1823
1824
1825 DEFUN (ospf_area_import_list,
1826 ospf_area_import_list_cmd,
1827 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1828 "OSPF area parameters\n"
1829 "OSPF area ID in IP address format\n"
1830 "OSPF area ID as a decimal value\n"
1831 "Set the filter for networks from other areas announced to the specified one\n"
1832 "Name of the access-list\n")
1833 {
1834 struct ospf *ospf = vty->index;
1835 struct ospf_area *area;
1836 struct in_addr area_id;
1837 int format;
1838
1839 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1840
1841 area = ospf_area_get (ospf, area_id, format);
1842 ospf_area_import_list_set (ospf, area, argv[1]);
1843
1844 return CMD_SUCCESS;
1845 }
1846
1847 DEFUN (no_ospf_area_import_list,
1848 no_ospf_area_import_list_cmd,
1849 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1850 NO_STR
1851 "OSPF area parameters\n"
1852 "OSPF area ID in IP address format\n"
1853 "OSPF area ID as a decimal value\n"
1854 "Unset the filter for networks announced to other areas\n"
1855 "Name of the access-list\n")
1856 {
1857 struct ospf *ospf = vty->index;
1858 struct ospf_area *area;
1859 struct in_addr area_id;
1860 int format;
1861
1862 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1863
1864 area = ospf_area_lookup_by_area_id (ospf, area_id);
1865 if (area == NULL)
1866 return CMD_SUCCESS;
1867
1868 ospf_area_import_list_unset (ospf, area);
1869
1870 return CMD_SUCCESS;
1871 }
1872
1873 DEFUN (ospf_area_filter_list,
1874 ospf_area_filter_list_cmd,
1875 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1876 "OSPF area parameters\n"
1877 "OSPF area ID in IP address format\n"
1878 "OSPF area ID as a decimal value\n"
1879 "Filter networks between OSPF areas\n"
1880 "Filter prefixes between OSPF areas\n"
1881 "Name of an IP prefix-list\n"
1882 "Filter networks sent to this area\n"
1883 "Filter networks sent from this area\n")
1884 {
1885 struct ospf *ospf = vty->index;
1886 struct ospf_area *area;
1887 struct in_addr area_id;
1888 struct prefix_list *plist;
1889 int format;
1890
1891 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1892
1893 area = ospf_area_get (ospf, area_id, format);
1894 plist = prefix_list_lookup (AFI_IP, argv[1]);
1895 if (strncmp (argv[2], "in", 2) == 0)
1896 {
1897 PREFIX_LIST_IN (area) = plist;
1898 if (PREFIX_NAME_IN (area))
1899 free (PREFIX_NAME_IN (area));
1900
1901 PREFIX_NAME_IN (area) = strdup (argv[1]);
1902 ospf_schedule_abr_task (ospf);
1903 }
1904 else
1905 {
1906 PREFIX_LIST_OUT (area) = plist;
1907 if (PREFIX_NAME_OUT (area))
1908 free (PREFIX_NAME_OUT (area));
1909
1910 PREFIX_NAME_OUT (area) = strdup (argv[1]);
1911 ospf_schedule_abr_task (ospf);
1912 }
1913
1914 return CMD_SUCCESS;
1915 }
1916
1917 DEFUN (no_ospf_area_filter_list,
1918 no_ospf_area_filter_list_cmd,
1919 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1920 NO_STR
1921 "OSPF area parameters\n"
1922 "OSPF area ID in IP address format\n"
1923 "OSPF area ID as a decimal value\n"
1924 "Filter networks between OSPF areas\n"
1925 "Filter prefixes between OSPF areas\n"
1926 "Name of an IP prefix-list\n"
1927 "Filter networks sent to this area\n"
1928 "Filter networks sent from this area\n")
1929 {
1930 struct ospf *ospf = vty->index;
1931 struct ospf_area *area;
1932 struct in_addr area_id;
1933 struct prefix_list *plist;
1934 int format;
1935
1936 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1937
1938 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1939 return CMD_SUCCESS;
1940
1941 plist = prefix_list_lookup (AFI_IP, argv[1]);
1942 if (strncmp (argv[2], "in", 2) == 0)
1943 {
1944 if (PREFIX_NAME_IN (area))
1945 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1946 return CMD_SUCCESS;
1947
1948 PREFIX_LIST_IN (area) = NULL;
1949 if (PREFIX_NAME_IN (area))
1950 free (PREFIX_NAME_IN (area));
1951
1952 PREFIX_NAME_IN (area) = NULL;
1953
1954 ospf_schedule_abr_task (ospf);
1955 }
1956 else
1957 {
1958 if (PREFIX_NAME_OUT (area))
1959 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1960 return CMD_SUCCESS;
1961
1962 PREFIX_LIST_OUT (area) = NULL;
1963 if (PREFIX_NAME_OUT (area))
1964 free (PREFIX_NAME_OUT (area));
1965
1966 PREFIX_NAME_OUT (area) = NULL;
1967
1968 ospf_schedule_abr_task (ospf);
1969 }
1970
1971 return CMD_SUCCESS;
1972 }
1973
1974 \f
1975 DEFUN (ospf_area_authentication_message_digest,
1976 ospf_area_authentication_message_digest_cmd,
1977 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1978 "OSPF area parameters\n"
1979 "Enable authentication\n"
1980 "Use message-digest authentication\n")
1981 {
1982 struct ospf *ospf = vty->index;
1983 struct ospf_area *area;
1984 struct in_addr area_id;
1985 int format;
1986
1987 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1988
1989 area = ospf_area_get (ospf, area_id, format);
1990 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1991
1992 return CMD_SUCCESS;
1993 }
1994
1995 DEFUN (ospf_area_authentication,
1996 ospf_area_authentication_cmd,
1997 "area (A.B.C.D|<0-4294967295>) authentication",
1998 "OSPF area parameters\n"
1999 "OSPF area ID in IP address format\n"
2000 "OSPF area ID as a decimal value\n"
2001 "Enable authentication\n")
2002 {
2003 struct ospf *ospf = vty->index;
2004 struct ospf_area *area;
2005 struct in_addr area_id;
2006 int format;
2007
2008 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2009
2010 area = ospf_area_get (ospf, area_id, format);
2011 area->auth_type = OSPF_AUTH_SIMPLE;
2012
2013 return CMD_SUCCESS;
2014 }
2015
2016 DEFUN (no_ospf_area_authentication,
2017 no_ospf_area_authentication_cmd,
2018 "no area (A.B.C.D|<0-4294967295>) authentication",
2019 NO_STR
2020 "OSPF area parameters\n"
2021 "OSPF area ID in IP address format\n"
2022 "OSPF area ID as a decimal value\n"
2023 "Enable authentication\n")
2024 {
2025 struct ospf *ospf = vty->index;
2026 struct ospf_area *area;
2027 struct in_addr area_id;
2028 int format;
2029
2030 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2031
2032 area = ospf_area_lookup_by_area_id (ospf, area_id);
2033 if (area == NULL)
2034 return CMD_SUCCESS;
2035
2036 area->auth_type = OSPF_AUTH_NULL;
2037
2038 ospf_area_check_free (ospf, area_id);
2039
2040 return CMD_SUCCESS;
2041 }
2042
2043 \f
2044 DEFUN (ospf_abr_type,
2045 ospf_abr_type_cmd,
2046 "ospf abr-type (cisco|ibm|shortcut|standard)",
2047 "OSPF specific commands\n"
2048 "Set OSPF ABR type\n"
2049 "Alternative ABR, cisco implementation\n"
2050 "Alternative ABR, IBM implementation\n"
2051 "Shortcut ABR\n"
2052 "Standard behavior (RFC2328)\n")
2053 {
2054 struct ospf *ospf = vty->index;
2055 u_char abr_type = OSPF_ABR_UNKNOWN;
2056
2057 if (strncmp (argv[0], "c", 1) == 0)
2058 abr_type = OSPF_ABR_CISCO;
2059 else if (strncmp (argv[0], "i", 1) == 0)
2060 abr_type = OSPF_ABR_IBM;
2061 else if (strncmp (argv[0], "sh", 2) == 0)
2062 abr_type = OSPF_ABR_SHORTCUT;
2063 else if (strncmp (argv[0], "st", 2) == 0)
2064 abr_type = OSPF_ABR_STAND;
2065 else
2066 return CMD_WARNING;
2067
2068 /* If ABR type value is changed, schedule ABR task. */
2069 if (ospf->abr_type != abr_type)
2070 {
2071 ospf->abr_type = abr_type;
2072 ospf_schedule_abr_task (ospf);
2073 }
2074
2075 return CMD_SUCCESS;
2076 }
2077
2078 DEFUN (no_ospf_abr_type,
2079 no_ospf_abr_type_cmd,
2080 "no ospf abr-type (cisco|ibm|shortcut|standard)",
2081 NO_STR
2082 "OSPF specific commands\n"
2083 "Set OSPF ABR type\n"
2084 "Alternative ABR, cisco implementation\n"
2085 "Alternative ABR, IBM implementation\n"
2086 "Shortcut ABR\n")
2087 {
2088 struct ospf *ospf = vty->index;
2089 u_char abr_type = OSPF_ABR_UNKNOWN;
2090
2091 if (strncmp (argv[0], "c", 1) == 0)
2092 abr_type = OSPF_ABR_CISCO;
2093 else if (strncmp (argv[0], "i", 1) == 0)
2094 abr_type = OSPF_ABR_IBM;
2095 else if (strncmp (argv[0], "sh", 2) == 0)
2096 abr_type = OSPF_ABR_SHORTCUT;
2097 else if (strncmp (argv[0], "st", 2) == 0)
2098 abr_type = OSPF_ABR_STAND;
2099 else
2100 return CMD_WARNING;
2101
2102 /* If ABR type value is changed, schedule ABR task. */
2103 if (ospf->abr_type == abr_type)
2104 {
2105 ospf->abr_type = OSPF_ABR_DEFAULT;
2106 ospf_schedule_abr_task (ospf);
2107 }
2108
2109 return CMD_SUCCESS;
2110 }
2111
2112 DEFUN (ospf_log_adjacency_changes,
2113 ospf_log_adjacency_changes_cmd,
2114 "log-adjacency-changes",
2115 "Log changes in adjacency state\n")
2116 {
2117 struct ospf *ospf = vty->index;
2118
2119 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2120 return CMD_SUCCESS;
2121 }
2122
2123 DEFUN (ospf_log_adjacency_changes_detail,
2124 ospf_log_adjacency_changes_detail_cmd,
2125 "log-adjacency-changes detail",
2126 "Log changes in adjacency state\n"
2127 "Log all state changes\n")
2128 {
2129 struct ospf *ospf = vty->index;
2130
2131 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2132 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2133 return CMD_SUCCESS;
2134 }
2135
2136 DEFUN (no_ospf_log_adjacency_changes,
2137 no_ospf_log_adjacency_changes_cmd,
2138 "no log-adjacency-changes",
2139 NO_STR
2140 "Log changes in adjacency state\n")
2141 {
2142 struct ospf *ospf = vty->index;
2143
2144 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2145 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2146 return CMD_SUCCESS;
2147 }
2148
2149 DEFUN (no_ospf_log_adjacency_changes_detail,
2150 no_ospf_log_adjacency_changes_detail_cmd,
2151 "no log-adjacency-changes detail",
2152 NO_STR
2153 "Log changes in adjacency state\n"
2154 "Log all state changes\n")
2155 {
2156 struct ospf *ospf = vty->index;
2157
2158 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2159 return CMD_SUCCESS;
2160 }
2161
2162 DEFUN (ospf_compatible_rfc1583,
2163 ospf_compatible_rfc1583_cmd,
2164 "compatible rfc1583",
2165 "OSPF compatibility list\n"
2166 "compatible with RFC 1583\n")
2167 {
2168 struct ospf *ospf = vty->index;
2169
2170 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2171 {
2172 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
2173 ospf_spf_calculate_schedule (ospf);
2174 }
2175 return CMD_SUCCESS;
2176 }
2177
2178 DEFUN (no_ospf_compatible_rfc1583,
2179 no_ospf_compatible_rfc1583_cmd,
2180 "no compatible rfc1583",
2181 NO_STR
2182 "OSPF compatibility list\n"
2183 "compatible with RFC 1583\n")
2184 {
2185 struct ospf *ospf = vty->index;
2186
2187 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2188 {
2189 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
2190 ospf_spf_calculate_schedule (ospf);
2191 }
2192 return CMD_SUCCESS;
2193 }
2194
2195 ALIAS (ospf_compatible_rfc1583,
2196 ospf_rfc1583_flag_cmd,
2197 "ospf rfc1583compatibility",
2198 "OSPF specific commands\n"
2199 "Enable the RFC1583Compatibility flag\n")
2200
2201 ALIAS (no_ospf_compatible_rfc1583,
2202 no_ospf_rfc1583_flag_cmd,
2203 "no ospf rfc1583compatibility",
2204 NO_STR
2205 "OSPF specific commands\n"
2206 "Disable the RFC1583Compatibility flag\n")
2207 \f
2208 static int
2209 ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2210 unsigned int hold,
2211 unsigned int max)
2212 {
2213 struct ospf *ospf = vty->index;
2214
2215 ospf->spf_delay = delay;
2216 ospf->spf_holdtime = hold;
2217 ospf->spf_max_holdtime = max;
2218
2219 return CMD_SUCCESS;
2220 }
2221
2222 DEFUN (ospf_timers_throttle_spf,
2223 ospf_timers_throttle_spf_cmd,
2224 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2225 "Adjust routing timers\n"
2226 "Throttling adaptive timer\n"
2227 "OSPF SPF timers\n"
2228 "Delay (msec) from first change received till SPF calculation\n"
2229 "Initial hold time (msec) between consecutive SPF calculations\n"
2230 "Maximum hold time (msec)\n")
2231 {
2232 unsigned int delay, hold, max;
2233
2234 if (argc != 3)
2235 {
2236 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2237 return CMD_WARNING;
2238 }
2239
2240 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2241 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2242 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2243
2244 return ospf_timers_spf_set (vty, delay, hold, max);
2245 }
2246
2247 DEFUN_DEPRECATED (ospf_timers_spf,
2248 ospf_timers_spf_cmd,
2249 "timers spf <0-4294967295> <0-4294967295>",
2250 "Adjust routing timers\n"
2251 "OSPF SPF timers\n"
2252 "Delay (s) between receiving a change to SPF calculation\n"
2253 "Hold time (s) between consecutive SPF calculations\n")
2254 {
2255 unsigned int delay, hold;
2256
2257 if (argc != 2)
2258 {
2259 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2260 return CMD_WARNING;
2261 }
2262
2263 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2264 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
2265
2266 /* truncate down the second values if they're greater than 600000ms */
2267 if (delay > (600000 / 1000))
2268 delay = 600000;
2269 else if (delay == 0)
2270 /* 0s delay was probably specified because of lack of ms resolution */
2271 delay = OSPF_SPF_DELAY_DEFAULT;
2272 if (hold > (600000 / 1000))
2273 hold = 600000;
2274
2275 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
2276 }
2277
2278 DEFUN (no_ospf_timers_throttle_spf,
2279 no_ospf_timers_throttle_spf_cmd,
2280 "no timers throttle spf",
2281 NO_STR
2282 "Adjust routing timers\n"
2283 "Throttling adaptive timer\n"
2284 "OSPF SPF timers\n")
2285 {
2286 return ospf_timers_spf_set (vty,
2287 OSPF_SPF_DELAY_DEFAULT,
2288 OSPF_SPF_HOLDTIME_DEFAULT,
2289 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
2290 }
2291
2292 ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2293 no_ospf_timers_spf_cmd,
2294 "no timers spf",
2295 NO_STR
2296 "Adjust routing timers\n"
2297 "OSPF SPF timers\n")
2298 \f
2299 DEFUN (ospf_neighbor,
2300 ospf_neighbor_cmd,
2301 "neighbor A.B.C.D",
2302 NEIGHBOR_STR
2303 "Neighbor IP address\n")
2304 {
2305 struct ospf *ospf = vty->index;
2306 struct in_addr nbr_addr;
2307 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2308 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
2309
2310 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2311
2312 if (argc > 1)
2313 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2314
2315 if (argc > 2)
2316 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2317
2318 ospf_nbr_nbma_set (ospf, nbr_addr);
2319 if (argc > 1)
2320 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2321 if (argc > 2)
2322 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2323
2324 return CMD_SUCCESS;
2325 }
2326
2327 ALIAS (ospf_neighbor,
2328 ospf_neighbor_priority_poll_interval_cmd,
2329 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2330 NEIGHBOR_STR
2331 "Neighbor IP address\n"
2332 "Neighbor Priority\n"
2333 "Priority\n"
2334 "Dead Neighbor Polling interval\n"
2335 "Seconds\n")
2336
2337 ALIAS (ospf_neighbor,
2338 ospf_neighbor_priority_cmd,
2339 "neighbor A.B.C.D priority <0-255>",
2340 NEIGHBOR_STR
2341 "Neighbor IP address\n"
2342 "Neighbor Priority\n"
2343 "Seconds\n")
2344
2345 DEFUN (ospf_neighbor_poll_interval,
2346 ospf_neighbor_poll_interval_cmd,
2347 "neighbor A.B.C.D poll-interval <1-65535>",
2348 NEIGHBOR_STR
2349 "Neighbor IP address\n"
2350 "Dead Neighbor Polling interval\n"
2351 "Seconds\n")
2352 {
2353 struct ospf *ospf = vty->index;
2354 struct in_addr nbr_addr;
2355 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2356 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
2357
2358 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2359
2360 if (argc > 1)
2361 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2362
2363 if (argc > 2)
2364 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2365
2366 ospf_nbr_nbma_set (ospf, nbr_addr);
2367 if (argc > 1)
2368 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2369 if (argc > 2)
2370 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2371
2372 return CMD_SUCCESS;
2373 }
2374
2375 ALIAS (ospf_neighbor_poll_interval,
2376 ospf_neighbor_poll_interval_priority_cmd,
2377 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2378 NEIGHBOR_STR
2379 "Neighbor address\n"
2380 "OSPF dead-router polling interval\n"
2381 "Seconds\n"
2382 "OSPF priority of non-broadcast neighbor\n"
2383 "Priority\n")
2384
2385 DEFUN (no_ospf_neighbor,
2386 no_ospf_neighbor_cmd,
2387 "no neighbor A.B.C.D",
2388 NO_STR
2389 NEIGHBOR_STR
2390 "Neighbor IP address\n")
2391 {
2392 struct ospf *ospf = vty->index;
2393 struct in_addr nbr_addr;
2394 int ret;
2395
2396 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2397
2398 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2399
2400 return CMD_SUCCESS;
2401 }
2402
2403 ALIAS (no_ospf_neighbor,
2404 no_ospf_neighbor_priority_cmd,
2405 "no neighbor A.B.C.D priority <0-255>",
2406 NO_STR
2407 NEIGHBOR_STR
2408 "Neighbor IP address\n"
2409 "Neighbor Priority\n"
2410 "Priority\n")
2411
2412 ALIAS (no_ospf_neighbor,
2413 no_ospf_neighbor_poll_interval_cmd,
2414 "no neighbor A.B.C.D poll-interval <1-65535>",
2415 NO_STR
2416 NEIGHBOR_STR
2417 "Neighbor IP address\n"
2418 "Dead Neighbor Polling interval\n"
2419 "Seconds\n")
2420
2421 ALIAS (no_ospf_neighbor,
2422 no_ospf_neighbor_priority_pollinterval_cmd,
2423 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2424 NO_STR
2425 NEIGHBOR_STR
2426 "Neighbor IP address\n"
2427 "Neighbor Priority\n"
2428 "Priority\n"
2429 "Dead Neighbor Polling interval\n"
2430 "Seconds\n")
2431
2432 \f
2433 DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
2434 "refresh timer <10-1800>",
2435 "Adjust refresh parameters\n"
2436 "Set refresh timer\n"
2437 "Timer value in seconds\n")
2438 {
2439 struct ospf *ospf = vty->index;
2440 unsigned int interval;
2441
2442 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2443 interval = (interval / 10) * 10;
2444
2445 ospf_timers_refresh_set (ospf, interval);
2446
2447 return CMD_SUCCESS;
2448 }
2449
2450 DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
2451 "no refresh timer <10-1800>",
2452 "Adjust refresh parameters\n"
2453 "Unset refresh timer\n"
2454 "Timer value in seconds\n")
2455 {
2456 struct ospf *ospf = vty->index;
2457 unsigned int interval;
2458
2459 if (argc == 1)
2460 {
2461 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2462
2463 if (ospf->lsa_refresh_interval != interval ||
2464 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2465 return CMD_SUCCESS;
2466 }
2467
2468 ospf_timers_refresh_unset (ospf);
2469
2470 return CMD_SUCCESS;
2471 }
2472
2473 ALIAS (no_ospf_refresh_timer,
2474 no_ospf_refresh_timer_cmd,
2475 "no refresh timer",
2476 "Adjust refresh parameters\n"
2477 "Unset refresh timer\n")
2478
2479 DEFUN (ospf_auto_cost_reference_bandwidth,
2480 ospf_auto_cost_reference_bandwidth_cmd,
2481 "auto-cost reference-bandwidth <1-4294967>",
2482 "Calculate OSPF interface cost according to bandwidth\n"
2483 "Use reference bandwidth method to assign OSPF cost\n"
2484 "The reference bandwidth in terms of Mbits per second\n")
2485 {
2486 struct ospf *ospf = vty->index;
2487 u_int32_t refbw;
2488 struct listnode *node;
2489 struct interface *ifp;
2490
2491 refbw = strtol (argv[0], NULL, 10);
2492 if (refbw < 1 || refbw > 4294967)
2493 {
2494 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2495 return CMD_WARNING;
2496 }
2497
2498 /* If reference bandwidth is changed. */
2499 if ((refbw * 1000) == ospf->ref_bandwidth)
2500 return CMD_SUCCESS;
2501
2502 ospf->ref_bandwidth = refbw * 1000;
2503 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2504 ospf_if_recalculate_output_cost (ifp);
2505
2506 return CMD_SUCCESS;
2507 }
2508
2509 DEFUN (no_ospf_auto_cost_reference_bandwidth,
2510 no_ospf_auto_cost_reference_bandwidth_cmd,
2511 "no auto-cost reference-bandwidth",
2512 NO_STR
2513 "Calculate OSPF interface cost according to bandwidth\n"
2514 "Use reference bandwidth method to assign OSPF cost\n")
2515 {
2516 struct ospf *ospf = vty->index;
2517 struct listnode *node, *nnode;
2518 struct interface *ifp;
2519
2520 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
2521 return CMD_SUCCESS;
2522
2523 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
2524 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2525 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2526
2527 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2528 ospf_if_recalculate_output_cost (ifp);
2529
2530 return CMD_SUCCESS;
2531 }
2532
2533 const char *ospf_abr_type_descr_str[] =
2534 {
2535 "Unknown",
2536 "Standard (RFC2328)",
2537 "Alternative IBM",
2538 "Alternative Cisco",
2539 "Alternative Shortcut"
2540 };
2541
2542 const char *ospf_shortcut_mode_descr_str[] =
2543 {
2544 "Default",
2545 "Enabled",
2546 "Disabled"
2547 };
2548
2549
2550 \f
2551 static void
2552 show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2553 {
2554 /* Show Area ID. */
2555 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2556
2557 /* Show Area type/mode. */
2558 if (OSPF_IS_AREA_BACKBONE (area))
2559 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2560 else
2561 {
2562 if (area->external_routing == OSPF_AREA_STUB)
2563 vty_out (vty, " (Stub%s%s)",
2564 area->no_summary ? ", no summary" : "",
2565 area->shortcut_configured ? "; " : "");
2566
2567 else if (area->external_routing == OSPF_AREA_NSSA)
2568 vty_out (vty, " (NSSA%s%s)",
2569 area->no_summary ? ", no summary" : "",
2570 area->shortcut_configured ? "; " : "");
2571
2572 vty_out (vty, "%s", VTY_NEWLINE);
2573 vty_out (vty, " Shortcutting mode: %s",
2574 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
2575 vty_out (vty, ", S-bit consensus: %s%s",
2576 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
2577 }
2578
2579 /* Show number of interfaces. */
2580 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2581 "Active: %d%s", listcount (area->oiflist),
2582 area->act_ints, VTY_NEWLINE);
2583
2584 if (area->external_routing == OSPF_AREA_NSSA)
2585 {
2586 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
2587 if (! IS_OSPF_ABR (area->ospf))
2588 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2589 VTY_NEWLINE);
2590 else if (area->NSSATranslatorState)
2591 {
2592 vty_out (vty, " We are an ABR and ");
2593 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2594 vty_out (vty, "the NSSA Elected Translator. %s",
2595 VTY_NEWLINE);
2596 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2597 vty_out (vty, "always an NSSA Translator. %s",
2598 VTY_NEWLINE);
2599 }
2600 else
2601 {
2602 vty_out (vty, " We are an ABR, but ");
2603 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2604 vty_out (vty, "not the NSSA Elected Translator. %s",
2605 VTY_NEWLINE);
2606 else
2607 vty_out (vty, "never an NSSA Translator. %s",
2608 VTY_NEWLINE);
2609 }
2610 }
2611 /* Stub-router state for this area */
2612 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2613 {
2614 char timebuf[OSPF_TIME_DUMP_SIZE];
2615 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2616 VTY_NEWLINE);
2617 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2618 vty_out (vty, " Administratively activated (indefinitely)%s",
2619 VTY_NEWLINE);
2620 if (area->t_stub_router)
2621 vty_out (vty, " Active from startup, %s remaining%s",
2622 ospf_timer_dump (area->t_stub_router, timebuf,
2623 sizeof(timebuf)), VTY_NEWLINE);
2624 }
2625
2626 /* Show number of fully adjacent neighbors. */
2627 vty_out (vty, " Number of fully adjacent neighbors in this area:"
2628 " %d%s", area->full_nbrs, VTY_NEWLINE);
2629
2630 /* Show authentication type. */
2631 vty_out (vty, " Area has ");
2632 if (area->auth_type == OSPF_AUTH_NULL)
2633 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2634 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2635 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2636 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2637 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2638
2639 if (!OSPF_IS_AREA_BACKBONE (area))
2640 vty_out (vty, " Number of full virtual adjacencies going through"
2641 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2642
2643 /* Show SPF calculation times. */
2644 vty_out (vty, " SPF algorithm executed %d times%s",
2645 area->spf_calculation, VTY_NEWLINE);
2646
2647 /* Show number of LSA. */
2648 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
2649 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2650 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2651 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2652 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2653 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2654 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2655 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2656 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2657 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2658 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2659 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2660 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2661 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2662 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2663 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2664 #ifdef HAVE_OPAQUE_LSA
2665 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2666 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2667 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2668 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2669 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2670 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2671 #endif /* HAVE_OPAQUE_LSA */
2672 vty_out (vty, "%s", VTY_NEWLINE);
2673 }
2674
2675 DEFUN (show_ip_ospf,
2676 show_ip_ospf_cmd,
2677 "show ip ospf",
2678 SHOW_STR
2679 IP_STR
2680 "OSPF information\n")
2681 {
2682 struct listnode *node, *nnode;
2683 struct ospf_area * area;
2684 struct ospf *ospf;
2685 struct timeval result;
2686 char timebuf[OSPF_TIME_DUMP_SIZE];
2687
2688 /* Check OSPF is enable. */
2689 ospf = ospf_lookup ();
2690 if (ospf == NULL)
2691 {
2692 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2693 return CMD_SUCCESS;
2694 }
2695
2696 /* Show Router ID. */
2697 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
2698 inet_ntoa (ospf->router_id),
2699 VTY_NEWLINE);
2700
2701 /* Graceful shutdown */
2702 if (ospf->t_deferred_shutdown)
2703 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2704 ospf_timer_dump (ospf->t_deferred_shutdown,
2705 timebuf, sizeof (timebuf)), VTY_NEWLINE);
2706 /* Show capability. */
2707 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2708 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2709 vty_out (vty, " RFC1583Compatibility flag is %s%s",
2710 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
2711 "enabled" : "disabled", VTY_NEWLINE);
2712 #ifdef HAVE_OPAQUE_LSA
2713 vty_out (vty, " OpaqueCapability flag is %s%s%s",
2714 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
2715 "enabled" : "disabled",
2716 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
2717 " (origination blocked)" : "",
2718 VTY_NEWLINE);
2719 #endif /* HAVE_OPAQUE_LSA */
2720
2721 /* Show stub-router configuration */
2722 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2723 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2724 {
2725 vty_out (vty, " Stub router advertisement is configured%s",
2726 VTY_NEWLINE);
2727 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2728 vty_out (vty, " Enabled for %us after start-up%s",
2729 ospf->stub_router_startup_time, VTY_NEWLINE);
2730 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2731 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2732 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2733 }
2734
2735 /* Show SPF timers. */
2736 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2737 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2738 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2739 " Hold time multiplier is currently %d%s",
2740 ospf->spf_delay, VTY_NEWLINE,
2741 ospf->spf_holdtime, VTY_NEWLINE,
2742 ospf->spf_max_holdtime, VTY_NEWLINE,
2743 ospf->spf_hold_multiplier, VTY_NEWLINE);
2744 vty_out (vty, " SPF algorithm ");
2745 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2746 {
2747 result = tv_sub (recent_relative_time (), ospf->ts_spf);
2748 vty_out (vty, "last executed %s ago%s",
2749 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2750 VTY_NEWLINE);
2751 }
2752 else
2753 vty_out (vty, "has not been run%s", VTY_NEWLINE);
2754 vty_out (vty, " SPF timer %s%s%s",
2755 (ospf->t_spf_calc ? "due in " : "is "),
2756 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2757 VTY_NEWLINE);
2758
2759 /* Show refresh parameters. */
2760 vty_out (vty, " Refresh timer %d secs%s",
2761 ospf->lsa_refresh_interval, VTY_NEWLINE);
2762
2763 /* Show ABR/ASBR flags. */
2764 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
2765 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
2766 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
2767
2768 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
2769 vty_out (vty, " This router is an ASBR "
2770 "(injecting external routing information)%s", VTY_NEWLINE);
2771
2772 /* Show Number of AS-external-LSAs. */
2773 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2774 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2775 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2776 #ifdef HAVE_OPAQUE_LSA
2777 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2778 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2779 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2780 #endif /* HAVE_OPAQUE_LSA */
2781 /* Show number of areas attached. */
2782 vty_out (vty, " Number of areas attached to this router: %d%s",
2783 listcount (ospf->areas), VTY_NEWLINE);
2784
2785 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2786 {
2787 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2788 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2789 else
2790 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2791 }
2792
2793 vty_out (vty, "%s",VTY_NEWLINE);
2794
2795 /* Show each area status. */
2796 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2797 show_ip_ospf_area (vty, area);
2798
2799 return CMD_SUCCESS;
2800 }
2801
2802 \f
2803 static void
2804 show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2805 struct interface *ifp)
2806 {
2807 int is_up;
2808 struct ospf_neighbor *nbr;
2809 struct route_node *rn;
2810
2811 /* Is interface up? */
2812 vty_out (vty, "%s is %s%s", ifp->name,
2813 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
2814 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2815 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2816 VTY_NEWLINE);
2817
2818 /* Is interface OSPF enabled? */
2819 if (ospf_oi_count(ifp) == 0)
2820 {
2821 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2822 return;
2823 }
2824 else if (!is_up)
2825 {
2826 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2827 VTY_NEWLINE);
2828 return;
2829 }
2830
2831 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2832 {
2833 struct ospf_interface *oi = rn->info;
2834
2835 if (oi == NULL)
2836 continue;
2837
2838 /* Show OSPF interface information. */
2839 vty_out (vty, " Internet Address %s/%d,",
2840 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2841
2842 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2843 {
2844 struct in_addr *dest;
2845 const char *dstr;
2846
2847 if (CONNECTED_PEER(oi->connected)
2848 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2849 dstr = "Peer";
2850 else
2851 dstr = "Broadcast";
2852
2853 /* For Vlinks, showing the peer address is probably more
2854 * informative than the local interface that is being used
2855 */
2856 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2857 dest = &oi->vl_data->peer_addr;
2858 else
2859 dest = &oi->connected->destination->u.prefix4;
2860
2861 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2862 }
2863
2864 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2865 VTY_NEWLINE);
2866
2867 vty_out (vty, " MTU mismatch detection:%s%s",
2868 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2869
2870 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
2871 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
2872 oi->output_cost, VTY_NEWLINE);
2873
2874 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2875 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2876 PRIORITY (oi), VTY_NEWLINE);
2877
2878 /* Show DR information. */
2879 if (DR (oi).s_addr == 0)
2880 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2881 else
2882 {
2883 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2884 if (nbr == NULL)
2885 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2886 else
2887 {
2888 vty_out (vty, " Designated Router (ID) %s,",
2889 inet_ntoa (nbr->router_id));
2890 vty_out (vty, " Interface Address %s%s",
2891 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2892 }
2893 }
2894
2895 /* Show BDR information. */
2896 if (BDR (oi).s_addr == 0)
2897 vty_out (vty, " No backup designated router on this network%s",
2898 VTY_NEWLINE);
2899 else
2900 {
2901 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2902 if (nbr == NULL)
2903 vty_out (vty, " No backup designated router on this network%s",
2904 VTY_NEWLINE);
2905 else
2906 {
2907 vty_out (vty, " Backup Designated Router (ID) %s,",
2908 inet_ntoa (nbr->router_id));
2909 vty_out (vty, " Interface Address %s%s",
2910 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2911 }
2912 }
2913
2914 vty_out (vty, " Multicast group memberships:");
2915 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2916 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2917 {
2918 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2919 vty_out (vty, " OSPFAllRouters");
2920 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2921 vty_out (vty, " OSPFDesignatedRouters");
2922 }
2923 else
2924 vty_out (vty, " <None>");
2925 vty_out (vty, "%s", VTY_NEWLINE);
2926
2927 vty_out (vty, " Timer intervals configured,");
2928 vty_out (vty, " Hello ");
2929 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2930 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2931 else
2932 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2933 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2934 OSPF_IF_PARAM (oi, v_wait),
2935 OSPF_IF_PARAM (oi, v_wait),
2936 OSPF_IF_PARAM (oi, retransmit_interval),
2937 VTY_NEWLINE);
2938
2939 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
2940 {
2941 char timebuf[OSPF_TIME_DUMP_SIZE];
2942 vty_out (vty, " Hello due in %s%s",
2943 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
2944 VTY_NEWLINE);
2945 }
2946 else /* passive-interface is set */
2947 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2948
2949 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
2950 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
2951 VTY_NEWLINE);
2952 }
2953 }
2954
2955 DEFUN (show_ip_ospf_interface,
2956 show_ip_ospf_interface_cmd,
2957 "show ip ospf interface [INTERFACE]",
2958 SHOW_STR
2959 IP_STR
2960 "OSPF information\n"
2961 "Interface information\n"
2962 "Interface name\n")
2963 {
2964 struct interface *ifp;
2965 struct ospf *ospf;
2966 struct listnode *node;
2967
2968 ospf = ospf_lookup ();
2969 if (ospf == NULL)
2970 {
2971 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2972 return CMD_SUCCESS;
2973 }
2974
2975 /* Show All Interfaces. */
2976 if (argc == 0)
2977 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2978 show_ip_ospf_interface_sub (vty, ospf, ifp);
2979 /* Interface name is specified. */
2980 else
2981 {
2982 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2983 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2984 else
2985 show_ip_ospf_interface_sub (vty, ospf, ifp);
2986 }
2987
2988 return CMD_SUCCESS;
2989 }
2990
2991 static void
2992 show_ip_ospf_neighbour_header (struct vty *vty)
2993 {
2994 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2995 VTY_NEWLINE,
2996 "Neighbor ID", "Pri", "State", "Dead Time",
2997 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
2998 VTY_NEWLINE);
2999 }
3000
3001 static void
3002 show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3003 {
3004 struct route_node *rn;
3005 struct ospf_neighbor *nbr;
3006 char msgbuf[16];
3007 char timebuf[OSPF_TIME_DUMP_SIZE];
3008
3009 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3010 if ((nbr = rn->info))
3011 /* Do not show myself. */
3012 if (nbr != oi->nbr_self)
3013 /* Down state is not shown. */
3014 if (nbr->state != NSM_Down)
3015 {
3016 ospf_nbr_state_message (nbr, msgbuf, 16);
3017
3018 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3019 vty_out (vty, "%-15s %3d %-15s ",
3020 "-", nbr->priority,
3021 msgbuf);
3022 else
3023 vty_out (vty, "%-15s %3d %-15s ",
3024 inet_ntoa (nbr->router_id), nbr->priority,
3025 msgbuf);
3026
3027 vty_out (vty, "%9s ",
3028 ospf_timer_dump (nbr->t_inactivity, timebuf,
3029 sizeof(timebuf)));
3030
3031 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
3032 vty_out (vty, "%-20s %5ld %5ld %5d%s",
3033 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3034 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3035 VTY_NEWLINE);
3036 }
3037 }
3038
3039 DEFUN (show_ip_ospf_neighbor,
3040 show_ip_ospf_neighbor_cmd,
3041 "show ip ospf neighbor",
3042 SHOW_STR
3043 IP_STR
3044 "OSPF information\n"
3045 "Neighbor list\n")
3046 {
3047 struct ospf *ospf;
3048 struct ospf_interface *oi;
3049 struct listnode *node;
3050
3051 ospf = ospf_lookup ();
3052 if (ospf == NULL)
3053 {
3054 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3055 return CMD_SUCCESS;
3056 }
3057
3058 show_ip_ospf_neighbour_header (vty);
3059
3060 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3061 show_ip_ospf_neighbor_sub (vty, oi);
3062
3063 return CMD_SUCCESS;
3064 }
3065
3066 DEFUN (show_ip_ospf_neighbor_all,
3067 show_ip_ospf_neighbor_all_cmd,
3068 "show ip ospf neighbor all",
3069 SHOW_STR
3070 IP_STR
3071 "OSPF information\n"
3072 "Neighbor list\n"
3073 "include down status neighbor\n")
3074 {
3075 struct ospf *ospf = ospf_lookup ();
3076 struct listnode *node;
3077 struct ospf_interface *oi;
3078
3079 if (ospf == NULL)
3080 {
3081 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3082 return CMD_SUCCESS;
3083 }
3084
3085 show_ip_ospf_neighbour_header (vty);
3086
3087 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3088 {
3089 struct listnode *nbr_node;
3090 struct ospf_nbr_nbma *nbr_nbma;
3091
3092 show_ip_ospf_neighbor_sub (vty, oi);
3093
3094 /* print Down neighbor status */
3095 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
3096 {
3097 if (nbr_nbma->nbr == NULL
3098 || nbr_nbma->nbr->state == NSM_Down)
3099 {
3100 vty_out (vty, "%-15s %3d %-15s %9s ",
3101 "-", nbr_nbma->priority, "Down", "-");
3102 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
3103 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3104 0, 0, 0, VTY_NEWLINE);
3105 }
3106 }
3107 }
3108
3109 return CMD_SUCCESS;
3110 }
3111
3112 DEFUN (show_ip_ospf_neighbor_int,
3113 show_ip_ospf_neighbor_int_cmd,
3114 "show ip ospf neighbor IFNAME",
3115 SHOW_STR
3116 IP_STR
3117 "OSPF information\n"
3118 "Neighbor list\n"
3119 "Interface name\n")
3120 {
3121 struct ospf *ospf;
3122 struct interface *ifp;
3123 struct route_node *rn;
3124
3125 ifp = if_lookup_by_name (argv[0]);
3126 if (!ifp)
3127 {
3128 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
3129 return CMD_WARNING;
3130 }
3131
3132 ospf = ospf_lookup ();
3133 if (ospf == NULL)
3134 {
3135 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3136 return CMD_SUCCESS;
3137 }
3138
3139 show_ip_ospf_neighbour_header (vty);
3140
3141 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3142 {
3143 struct ospf_interface *oi = rn->info;
3144
3145 if (oi == NULL)
3146 continue;
3147
3148 show_ip_ospf_neighbor_sub (vty, oi);
3149 }
3150
3151 return CMD_SUCCESS;
3152 }
3153
3154 static void
3155 show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3156 struct ospf_nbr_nbma *nbr_nbma)
3157 {
3158 char timebuf[OSPF_TIME_DUMP_SIZE];
3159
3160 /* Show neighbor ID. */
3161 vty_out (vty, " Neighbor %s,", "-");
3162
3163 /* Show interface address. */
3164 vty_out (vty, " interface address %s%s",
3165 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3166 /* Show Area ID. */
3167 vty_out (vty, " In the area %s via interface %s%s",
3168 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3169 /* Show neighbor priority and state. */
3170 vty_out (vty, " Neighbor priority is %d, State is %s,",
3171 nbr_nbma->priority, "Down");
3172 /* Show state changes. */
3173 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3174
3175 /* Show PollInterval */
3176 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3177
3178 /* Show poll-interval timer. */
3179 vty_out (vty, " Poll timer due in %s%s",
3180 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3181 VTY_NEWLINE);
3182
3183 /* Show poll-interval timer thread. */
3184 vty_out (vty, " Thread Poll Timer %s%s",
3185 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3186 }
3187
3188 static void
3189 show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3190 struct ospf_neighbor *nbr)
3191 {
3192 char timebuf[OSPF_TIME_DUMP_SIZE];
3193
3194 /* Show neighbor ID. */
3195 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3196 vty_out (vty, " Neighbor %s,", "-");
3197 else
3198 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3199
3200 /* Show interface address. */
3201 vty_out (vty, " interface address %s%s",
3202 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3203 /* Show Area ID. */
3204 vty_out (vty, " In the area %s via interface %s%s",
3205 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3206 /* Show neighbor priority and state. */
3207 vty_out (vty, " Neighbor priority is %d, State is %s,",
3208 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3209 /* Show state changes. */
3210 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3211 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
3212 {
3213 struct timeval res
3214 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
3215 vty_out (vty, " Most recent state change statistics:%s",
3216 VTY_NEWLINE);
3217 vty_out (vty, " Progressive change %s ago%s",
3218 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3219 VTY_NEWLINE);
3220 }
3221 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3222 {
3223 struct timeval res
3224 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
3225 vty_out (vty, " Regressive change %s ago, due to %s%s",
3226 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3227 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
3228 VTY_NEWLINE);
3229 }
3230 /* Show Designated Rotuer ID. */
3231 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3232 /* Show Backup Designated Rotuer ID. */
3233 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3234 /* Show options. */
3235 vty_out (vty, " Options %d %s%s", nbr->options,
3236 ospf_options_dump (nbr->options), VTY_NEWLINE);
3237 /* Show Router Dead interval timer. */
3238 vty_out (vty, " Dead timer due in %s%s",
3239 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3240 VTY_NEWLINE);
3241 /* Show Database Summary list. */
3242 vty_out (vty, " Database Summary List %d%s",
3243 ospf_db_summary_count (nbr), VTY_NEWLINE);
3244 /* Show Link State Request list. */
3245 vty_out (vty, " Link State Request List %ld%s",
3246 ospf_ls_request_count (nbr), VTY_NEWLINE);
3247 /* Show Link State Retransmission list. */
3248 vty_out (vty, " Link State Retransmission List %ld%s",
3249 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3250 /* Show inactivity timer thread. */
3251 vty_out (vty, " Thread Inactivity Timer %s%s",
3252 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3253 /* Show Database Description retransmission thread. */
3254 vty_out (vty, " Thread Database Description Retransmision %s%s",
3255 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3256 /* Show Link State Request Retransmission thread. */
3257 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3258 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3259 /* Show Link State Update Retransmission thread. */
3260 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3261 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3262 }
3263
3264 DEFUN (show_ip_ospf_neighbor_id,
3265 show_ip_ospf_neighbor_id_cmd,
3266 "show ip ospf neighbor A.B.C.D",
3267 SHOW_STR
3268 IP_STR
3269 "OSPF information\n"
3270 "Neighbor list\n"
3271 "Neighbor ID\n")
3272 {
3273 struct ospf *ospf;
3274 struct listnode *node;
3275 struct ospf_neighbor *nbr;
3276 struct ospf_interface *oi;
3277 struct in_addr router_id;
3278 int ret;
3279
3280 ret = inet_aton (argv[0], &router_id);
3281 if (!ret)
3282 {
3283 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3284 return CMD_WARNING;
3285 }
3286
3287 ospf = ospf_lookup ();
3288 if (ospf == NULL)
3289 {
3290 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3291 return CMD_SUCCESS;
3292 }
3293
3294 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3295 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3296 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3297
3298 return CMD_SUCCESS;
3299 }
3300
3301 DEFUN (show_ip_ospf_neighbor_detail,
3302 show_ip_ospf_neighbor_detail_cmd,
3303 "show ip ospf neighbor detail",
3304 SHOW_STR
3305 IP_STR
3306 "OSPF information\n"
3307 "Neighbor list\n"
3308 "detail of all neighbors\n")
3309 {
3310 struct ospf *ospf;
3311 struct ospf_interface *oi;
3312 struct listnode *node;
3313
3314 ospf = ospf_lookup ();
3315 if (ospf == NULL)
3316 {
3317 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3318 return CMD_SUCCESS;
3319 }
3320
3321 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3322 {
3323 struct route_node *rn;
3324 struct ospf_neighbor *nbr;
3325
3326 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3327 if ((nbr = rn->info))
3328 if (nbr != oi->nbr_self)
3329 if (nbr->state != NSM_Down)
3330 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3331 }
3332
3333 return CMD_SUCCESS;
3334 }
3335
3336 DEFUN (show_ip_ospf_neighbor_detail_all,
3337 show_ip_ospf_neighbor_detail_all_cmd,
3338 "show ip ospf neighbor detail all",
3339 SHOW_STR
3340 IP_STR
3341 "OSPF information\n"
3342 "Neighbor list\n"
3343 "detail of all neighbors\n"
3344 "include down status neighbor\n")
3345 {
3346 struct ospf *ospf;
3347 struct listnode *node;
3348 struct ospf_interface *oi;
3349
3350 ospf = ospf_lookup ();
3351 if (ospf == NULL)
3352 {
3353 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3354 return CMD_SUCCESS;
3355 }
3356
3357 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3358 {
3359 struct route_node *rn;
3360 struct ospf_neighbor *nbr;
3361 struct ospf_nbr_nbma *nbr_nbma;
3362
3363 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3364 if ((nbr = rn->info))
3365 if (nbr != oi->nbr_self)
3366 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3367 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3368
3369 if (oi->type == OSPF_IFTYPE_NBMA)
3370 {
3371 struct listnode *nd;
3372
3373 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3374 if (nbr_nbma->nbr == NULL
3375 || nbr_nbma->nbr->state == NSM_Down)
3376 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3377 }
3378 }
3379
3380 return CMD_SUCCESS;
3381 }
3382
3383 DEFUN (show_ip_ospf_neighbor_int_detail,
3384 show_ip_ospf_neighbor_int_detail_cmd,
3385 "show ip ospf neighbor IFNAME detail",
3386 SHOW_STR
3387 IP_STR
3388 "OSPF information\n"
3389 "Neighbor list\n"
3390 "Interface name\n"
3391 "detail of all neighbors")
3392 {
3393 struct ospf *ospf;
3394 struct ospf_interface *oi;
3395 struct interface *ifp;
3396 struct route_node *rn, *nrn;
3397 struct ospf_neighbor *nbr;
3398
3399 ifp = if_lookup_by_name (argv[0]);
3400 if (!ifp)
3401 {
3402 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
3403 return CMD_WARNING;
3404 }
3405
3406 ospf = ospf_lookup ();
3407 if (ospf == NULL)
3408 {
3409 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3410 return CMD_SUCCESS;
3411 }
3412
3413
3414 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3415 if ((oi = rn->info))
3416 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3417 if ((nbr = nrn->info))
3418 if (nbr != oi->nbr_self)
3419 if (nbr->state != NSM_Down)
3420 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3421
3422 return CMD_SUCCESS;
3423 }
3424
3425 \f
3426 /* Show functions */
3427 static int
3428 show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
3429 {
3430 struct router_lsa *rl;
3431 struct summary_lsa *sl;
3432 struct as_external_lsa *asel;
3433 struct prefix_ipv4 p;
3434
3435 if (lsa != NULL)
3436 /* If self option is set, check LSA self flag. */
3437 if (self == 0 || IS_LSA_SELF (lsa))
3438 {
3439 /* LSA common part show. */
3440 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3441 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3442 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3443 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3444 /* LSA specific part show. */
3445 switch (lsa->data->type)
3446 {
3447 case OSPF_ROUTER_LSA:
3448 rl = (struct router_lsa *) lsa->data;
3449 vty_out (vty, " %-d", ntohs (rl->links));
3450 break;
3451 case OSPF_SUMMARY_LSA:
3452 sl = (struct summary_lsa *) lsa->data;
3453
3454 p.family = AF_INET;
3455 p.prefix = sl->header.id;
3456 p.prefixlen = ip_masklen (sl->mask);
3457 apply_mask_ipv4 (&p);
3458
3459 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3460 break;
3461 case OSPF_AS_EXTERNAL_LSA:
3462 case OSPF_AS_NSSA_LSA:
3463 asel = (struct as_external_lsa *) lsa->data;
3464
3465 p.family = AF_INET;
3466 p.prefix = asel->header.id;
3467 p.prefixlen = ip_masklen (asel->mask);
3468 apply_mask_ipv4 (&p);
3469
3470 vty_out (vty, " %s %s/%d [0x%lx]",
3471 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3472 inet_ntoa (p.prefix), p.prefixlen,
3473 (u_long)ntohl (asel->e[0].route_tag));
3474 break;
3475 case OSPF_NETWORK_LSA:
3476 case OSPF_ASBR_SUMMARY_LSA:
3477 #ifdef HAVE_OPAQUE_LSA
3478 case OSPF_OPAQUE_LINK_LSA:
3479 case OSPF_OPAQUE_AREA_LSA:
3480 case OSPF_OPAQUE_AS_LSA:
3481 #endif /* HAVE_OPAQUE_LSA */
3482 default:
3483 break;
3484 }
3485 vty_out (vty, VTY_NEWLINE);
3486 }
3487
3488 return 0;
3489 }
3490
3491 static const char *show_database_desc[] =
3492 {
3493 "unknown",
3494 "Router Link States",
3495 "Net Link States",
3496 "Summary Link States",
3497 "ASBR-Summary Link States",
3498 "AS External Link States",
3499 "Group Membership LSA",
3500 "NSSA-external Link States",
3501 #ifdef HAVE_OPAQUE_LSA
3502 "Type-8 LSA",
3503 "Link-Local Opaque-LSA",
3504 "Area-Local Opaque-LSA",
3505 "AS-external Opaque-LSA",
3506 #endif /* HAVE_OPAQUE_LSA */
3507 };
3508
3509 static const char *show_database_header[] =
3510 {
3511 "",
3512 "Link ID ADV Router Age Seq# CkSum Link count",
3513 "Link ID ADV Router Age Seq# CkSum",
3514 "Link ID ADV Router Age Seq# CkSum Route",
3515 "Link ID ADV Router Age Seq# CkSum",
3516 "Link ID ADV Router Age Seq# CkSum Route",
3517 " --- header for Group Member ----",
3518 "Link ID ADV Router Age Seq# CkSum Route",
3519 #ifdef HAVE_OPAQUE_LSA
3520 " --- type-8 ---",
3521 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3522 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3523 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3524 #endif /* HAVE_OPAQUE_LSA */
3525 };
3526
3527 static void
3528 show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3529 {
3530 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
3531
3532 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
3533 vty_out (vty, " Options: 0x%-2x : %s%s",
3534 lsa->data->options,
3535 ospf_options_dump(lsa->data->options),
3536 VTY_NEWLINE);
3537 vty_out (vty, " LS Flags: 0x%-2x %s%s",
3538 lsa->flags,
3539 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3540 VTY_NEWLINE);
3541
3542 if (lsa->data->type == OSPF_ROUTER_LSA)
3543 {
3544 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3545
3546 if (rlsa->flags)
3547 vty_out (vty, " :%s%s%s%s",
3548 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3549 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3550 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3551 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3552
3553 vty_out (vty, "%s", VTY_NEWLINE);
3554 }
3555 vty_out (vty, " LS Type: %s%s",
3556 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3557 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3558 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3559 vty_out (vty, " Advertising Router: %s%s",
3560 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3561 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3562 VTY_NEWLINE);
3563 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3564 VTY_NEWLINE);
3565 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3566 }
3567
3568 const char *link_type_desc[] =
3569 {
3570 "(null)",
3571 "another Router (point-to-point)",
3572 "a Transit Network",
3573 "Stub Network",
3574 "a Virtual Link",
3575 };
3576
3577 const char *link_id_desc[] =
3578 {
3579 "(null)",
3580 "Neighboring Router ID",
3581 "Designated Router address",
3582 "Net",
3583 "Neighboring Router ID",
3584 };
3585
3586 const char *link_data_desc[] =
3587 {
3588 "(null)",
3589 "Router Interface address",
3590 "Router Interface address",
3591 "Network Mask",
3592 "Router Interface address",
3593 };
3594
3595 /* Show router-LSA each Link information. */
3596 static void
3597 show_ip_ospf_database_router_links (struct vty *vty,
3598 struct router_lsa *rl)
3599 {
3600 int len, i, type;
3601
3602 len = ntohs (rl->header.length) - 4;
3603 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3604 {
3605 type = rl->link[i].type;
3606
3607 vty_out (vty, " Link connected to: %s%s",
3608 link_type_desc[type], VTY_NEWLINE);
3609 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3610 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3611 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3612 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3613 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3614 vty_out (vty, " TOS 0 Metric: %d%s",
3615 ntohs (rl->link[i].metric), VTY_NEWLINE);
3616 vty_out (vty, "%s", VTY_NEWLINE);
3617 }
3618 }
3619
3620 /* Show router-LSA detail information. */
3621 static int
3622 show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3623 {
3624 if (lsa != NULL)
3625 {
3626 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3627
3628 show_ip_ospf_database_header (vty, lsa);
3629
3630 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3631 VTY_NEWLINE, VTY_NEWLINE);
3632
3633 show_ip_ospf_database_router_links (vty, rl);
3634 vty_out (vty, "%s", VTY_NEWLINE);
3635 }
3636
3637 return 0;
3638 }
3639
3640 /* Show network-LSA detail information. */
3641 static int
3642 show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3643 {
3644 int length, i;
3645
3646 if (lsa != NULL)
3647 {
3648 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3649
3650 show_ip_ospf_database_header (vty, lsa);
3651
3652 vty_out (vty, " Network Mask: /%d%s",
3653 ip_masklen (nl->mask), VTY_NEWLINE);
3654
3655 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3656
3657 for (i = 0; length > 0; i++, length -= 4)
3658 vty_out (vty, " Attached Router: %s%s",
3659 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3660
3661 vty_out (vty, "%s", VTY_NEWLINE);
3662 }
3663
3664 return 0;
3665 }
3666
3667 /* Show summary-LSA detail information. */
3668 static int
3669 show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3670 {
3671 if (lsa != NULL)
3672 {
3673 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3674
3675 show_ip_ospf_database_header (vty, lsa);
3676
3677 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3678 VTY_NEWLINE);
3679 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3680 VTY_NEWLINE);
3681 vty_out (vty, "%s", VTY_NEWLINE);
3682 }
3683
3684 return 0;
3685 }
3686
3687 /* Show summary-ASBR-LSA detail information. */
3688 static int
3689 show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3690 {
3691 if (lsa != NULL)
3692 {
3693 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3694
3695 show_ip_ospf_database_header (vty, lsa);
3696
3697 vty_out (vty, " Network Mask: /%d%s",
3698 ip_masklen (sl->mask), VTY_NEWLINE);
3699 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3700 VTY_NEWLINE);
3701 vty_out (vty, "%s", VTY_NEWLINE);
3702 }
3703
3704 return 0;
3705 }
3706
3707 /* Show AS-external-LSA detail information. */
3708 static int
3709 show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3710 {
3711 if (lsa != NULL)
3712 {
3713 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3714
3715 show_ip_ospf_database_header (vty, lsa);
3716
3717 vty_out (vty, " Network Mask: /%d%s",
3718 ip_masklen (al->mask), VTY_NEWLINE);
3719 vty_out (vty, " Metric Type: %s%s",
3720 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3721 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3722 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3723 vty_out (vty, " Metric: %d%s",
3724 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3725 vty_out (vty, " Forward Address: %s%s",
3726 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3727
3728 vty_out (vty, " External Route Tag: %lu%s%s",
3729 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3730 }
3731
3732 return 0;
3733 }
3734
3735 #if 0
3736 static int
3737 show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3738 {
3739 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3740
3741 /* show_ip_ospf_database_header (vty, lsa); */
3742
3743 zlog_debug( " Network Mask: /%d%s",
3744 ip_masklen (al->mask), "\n");
3745 zlog_debug( " Metric Type: %s%s",
3746 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3747 "2 (Larger than any link state path)" : "1", "\n");
3748 zlog_debug( " TOS: 0%s", "\n");
3749 zlog_debug( " Metric: %d%s",
3750 GET_METRIC (al->e[0].metric), "\n");
3751 zlog_debug( " Forward Address: %s%s",
3752 inet_ntoa (al->e[0].fwd_addr), "\n");
3753
3754 zlog_debug( " External Route Tag: %u%s%s",
3755 ntohl (al->e[0].route_tag), "\n", "\n");
3756
3757 return 0;
3758 }
3759 #endif
3760
3761 /* Show AS-NSSA-LSA detail information. */
3762 static int
3763 show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3764 {
3765 if (lsa != NULL)
3766 {
3767 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3768
3769 show_ip_ospf_database_header (vty, lsa);
3770
3771 vty_out (vty, " Network Mask: /%d%s",
3772 ip_masklen (al->mask), VTY_NEWLINE);
3773 vty_out (vty, " Metric Type: %s%s",
3774 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3775 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3776 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3777 vty_out (vty, " Metric: %d%s",
3778 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3779 vty_out (vty, " NSSA: Forward Address: %s%s",
3780 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3781
3782 vty_out (vty, " External Route Tag: %u%s%s",
3783 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3784 }
3785
3786 return 0;
3787 }
3788
3789 static int
3790 show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3791 {
3792 return 0;
3793 }
3794
3795 #ifdef HAVE_OPAQUE_LSA
3796 static int
3797 show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3798 {
3799 if (lsa != NULL)
3800 {
3801 show_ip_ospf_database_header (vty, lsa);
3802 show_opaque_info_detail (vty, lsa);
3803
3804 vty_out (vty, "%s", VTY_NEWLINE);
3805 }
3806 return 0;
3807 }
3808 #endif /* HAVE_OPAQUE_LSA */
3809
3810 int (*show_function[])(struct vty *, struct ospf_lsa *) =
3811 {
3812 NULL,
3813 show_router_lsa_detail,
3814 show_network_lsa_detail,
3815 show_summary_lsa_detail,
3816 show_summary_asbr_lsa_detail,
3817 show_as_external_lsa_detail,
3818 show_func_dummy,
3819 show_as_nssa_lsa_detail, /* almost same as external */
3820 #ifdef HAVE_OPAQUE_LSA
3821 NULL, /* type-8 */
3822 show_opaque_lsa_detail,
3823 show_opaque_lsa_detail,
3824 show_opaque_lsa_detail,
3825 #endif /* HAVE_OPAQUE_LSA */
3826 };
3827
3828 static void
3829 show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3830 struct in_addr *adv_router)
3831 {
3832 memset (lp, 0, sizeof (struct prefix_ls));
3833 lp->family = 0;
3834 if (id == NULL)
3835 lp->prefixlen = 0;
3836 else if (adv_router == NULL)
3837 {
3838 lp->prefixlen = 32;
3839 lp->id = *id;
3840 }
3841 else
3842 {
3843 lp->prefixlen = 64;
3844 lp->id = *id;
3845 lp->adv_router = *adv_router;
3846 }
3847 }
3848
3849 static void
3850 show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3851 struct in_addr *id, struct in_addr *adv_router)
3852 {
3853 struct prefix_ls lp;
3854 struct route_node *rn, *start;
3855 struct ospf_lsa *lsa;
3856
3857 show_lsa_prefix_set (vty, &lp, id, adv_router);
3858 start = route_node_get (rt, (struct prefix *) &lp);
3859 if (start)
3860 {
3861 route_lock_node (start);
3862 for (rn = start; rn; rn = route_next_until (rn, start))
3863 if ((lsa = rn->info))
3864 {
3865 if (show_function[lsa->data->type] != NULL)
3866 show_function[lsa->data->type] (vty, lsa);
3867 }
3868 route_unlock_node (start);
3869 }
3870 }
3871
3872 /* Show detail LSA information
3873 -- if id is NULL then show all LSAs. */
3874 static void
3875 show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
3876 struct in_addr *id, struct in_addr *adv_router)
3877 {
3878 struct listnode *node;
3879 struct ospf_area *area;
3880
3881 switch (type)
3882 {
3883 case OSPF_AS_EXTERNAL_LSA:
3884 #ifdef HAVE_OPAQUE_LSA
3885 case OSPF_OPAQUE_AS_LSA:
3886 #endif /* HAVE_OPAQUE_LSA */
3887 vty_out (vty, " %s %s%s",
3888 show_database_desc[type],
3889 VTY_NEWLINE, VTY_NEWLINE);
3890 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
3891 break;
3892 default:
3893 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
3894 {
3895 vty_out (vty, "%s %s (Area %s)%s%s",
3896 VTY_NEWLINE, show_database_desc[type],
3897 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3898 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3899 }
3900 break;
3901 }
3902 }
3903
3904 static void
3905 show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3906 struct in_addr *adv_router)
3907 {
3908 struct route_node *rn;
3909 struct ospf_lsa *lsa;
3910
3911 for (rn = route_top (rt); rn; rn = route_next (rn))
3912 if ((lsa = rn->info))
3913 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3914 {
3915 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3916 continue;
3917 if (show_function[lsa->data->type] != NULL)
3918 show_function[lsa->data->type] (vty, lsa);
3919 }
3920 }
3921
3922 /* Show detail LSA information. */
3923 static void
3924 show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
3925 struct in_addr *adv_router)
3926 {
3927 struct listnode *node;
3928 struct ospf_area *area;
3929
3930 switch (type)
3931 {
3932 case OSPF_AS_EXTERNAL_LSA:
3933 #ifdef HAVE_OPAQUE_LSA
3934 case OSPF_OPAQUE_AS_LSA:
3935 #endif /* HAVE_OPAQUE_LSA */
3936 vty_out (vty, " %s %s%s",
3937 show_database_desc[type],
3938 VTY_NEWLINE, VTY_NEWLINE);
3939 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
3940 adv_router);
3941 break;
3942 default:
3943 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
3944 {
3945 vty_out (vty, "%s %s (Area %s)%s%s",
3946 VTY_NEWLINE, show_database_desc[type],
3947 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3948 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3949 adv_router);
3950 }
3951 break;
3952 }
3953 }
3954
3955 static void
3956 show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
3957 {
3958 struct ospf_lsa *lsa;
3959 struct route_node *rn;
3960 struct ospf_area *area;
3961 struct listnode *node;
3962 int type;
3963
3964 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
3965 {
3966 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3967 {
3968 switch (type)
3969 {
3970 case OSPF_AS_EXTERNAL_LSA:
3971 #ifdef HAVE_OPAQUE_LSA
3972 case OSPF_OPAQUE_AS_LSA:
3973 #endif /* HAVE_OPAQUE_LSA */
3974 continue;
3975 default:
3976 break;
3977 }
3978 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3979 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3980 {
3981 vty_out (vty, " %s (Area %s)%s%s",
3982 show_database_desc[type],
3983 ospf_area_desc_string (area),
3984 VTY_NEWLINE, VTY_NEWLINE);
3985 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3986
3987 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3988 show_lsa_summary (vty, lsa, self);
3989
3990 vty_out (vty, "%s", VTY_NEWLINE);
3991 }
3992 }
3993 }
3994
3995 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3996 {
3997 switch (type)
3998 {
3999 case OSPF_AS_EXTERNAL_LSA:
4000 #ifdef HAVE_OPAQUE_LSA
4001 case OSPF_OPAQUE_AS_LSA:
4002 #endif /* HAVE_OPAQUE_LSA */
4003 break;
4004 default:
4005 continue;
4006 }
4007 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4008 (!self && ospf_lsdb_count (ospf->lsdb, type)))
4009 {
4010 vty_out (vty, " %s%s%s",
4011 show_database_desc[type],
4012 VTY_NEWLINE, VTY_NEWLINE);
4013 vty_out (vty, "%s%s", show_database_header[type],
4014 VTY_NEWLINE);
4015
4016 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4017 show_lsa_summary (vty, lsa, self);
4018
4019 vty_out (vty, "%s", VTY_NEWLINE);
4020 }
4021 }
4022
4023 vty_out (vty, "%s", VTY_NEWLINE);
4024 }
4025
4026 static void
4027 show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
4028 {
4029 struct listnode *node;
4030 struct ospf_lsa *lsa;
4031
4032 vty_out (vty, "%s MaxAge Link States:%s%s",
4033 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4034
4035 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
4036 {
4037 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4038 vty_out (vty, "Link State ID: %s%s",
4039 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4040 vty_out (vty, "Advertising Router: %s%s",
4041 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4042 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4043 vty_out (vty, "%s", VTY_NEWLINE);
4044 }
4045 }
4046
4047 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4048 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
4049
4050 #ifdef HAVE_OPAQUE_LSA
4051 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4052 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4053 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4054 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4055 #else /* HAVE_OPAQUE_LSA */
4056 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4057 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4058 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4059 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4060 #endif /* HAVE_OPAQUE_LSA */
4061
4062 #define OSPF_LSA_TYPES_CMD_STR \
4063 "asbr-summary|external|network|router|summary" \
4064 OSPF_LSA_TYPE_NSSA_CMD_STR \
4065 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4066
4067 #define OSPF_LSA_TYPES_DESC \
4068 "ASBR summary link states\n" \
4069 "External link states\n" \
4070 "Network link states\n" \
4071 "Router link states\n" \
4072 "Network summary link states\n" \
4073 OSPF_LSA_TYPE_NSSA_DESC \
4074 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4075 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4076 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4077
4078 DEFUN (show_ip_ospf_database,
4079 show_ip_ospf_database_cmd,
4080 "show ip ospf database",
4081 SHOW_STR
4082 IP_STR
4083 "OSPF information\n"
4084 "Database summary\n")
4085 {
4086 struct ospf *ospf;
4087 int type, ret;
4088 struct in_addr id, adv_router;
4089
4090 ospf = ospf_lookup ();
4091 if (ospf == NULL)
4092 {
4093 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4094 return CMD_SUCCESS;
4095 }
4096
4097 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
4098 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
4099
4100 /* Show all LSA. */
4101 if (argc == 0)
4102 {
4103 show_ip_ospf_database_summary (vty, ospf, 0);
4104 return CMD_SUCCESS;
4105 }
4106
4107 /* Set database type to show. */
4108 if (strncmp (argv[0], "r", 1) == 0)
4109 type = OSPF_ROUTER_LSA;
4110 else if (strncmp (argv[0], "ne", 2) == 0)
4111 type = OSPF_NETWORK_LSA;
4112 else if (strncmp (argv[0], "ns", 2) == 0)
4113 type = OSPF_AS_NSSA_LSA;
4114 else if (strncmp (argv[0], "su", 2) == 0)
4115 type = OSPF_SUMMARY_LSA;
4116 else if (strncmp (argv[0], "a", 1) == 0)
4117 type = OSPF_ASBR_SUMMARY_LSA;
4118 else if (strncmp (argv[0], "e", 1) == 0)
4119 type = OSPF_AS_EXTERNAL_LSA;
4120 else if (strncmp (argv[0], "se", 2) == 0)
4121 {
4122 show_ip_ospf_database_summary (vty, ospf, 1);
4123 return CMD_SUCCESS;
4124 }
4125 else if (strncmp (argv[0], "m", 1) == 0)
4126 {
4127 show_ip_ospf_database_maxage (vty, ospf);
4128 return CMD_SUCCESS;
4129 }
4130 #ifdef HAVE_OPAQUE_LSA
4131 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4132 type = OSPF_OPAQUE_LINK_LSA;
4133 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4134 type = OSPF_OPAQUE_AREA_LSA;
4135 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4136 type = OSPF_OPAQUE_AS_LSA;
4137 #endif /* HAVE_OPAQUE_LSA */
4138 else
4139 return CMD_WARNING;
4140
4141 /* `show ip ospf database LSA'. */
4142 if (argc == 1)
4143 show_lsa_detail (vty, ospf, type, NULL, NULL);
4144 else if (argc >= 2)
4145 {
4146 ret = inet_aton (argv[1], &id);
4147 if (!ret)
4148 return CMD_WARNING;
4149
4150 /* `show ip ospf database LSA ID'. */
4151 if (argc == 2)
4152 show_lsa_detail (vty, ospf, type, &id, NULL);
4153 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4154 else if (argc == 3)
4155 {
4156 if (strncmp (argv[2], "s", 1) == 0)
4157 adv_router = ospf->router_id;
4158 else
4159 {
4160 ret = inet_aton (argv[2], &adv_router);
4161 if (!ret)
4162 return CMD_WARNING;
4163 }
4164 show_lsa_detail (vty, ospf, type, &id, &adv_router);
4165 }
4166 }
4167
4168 return CMD_SUCCESS;
4169 }
4170
4171 ALIAS (show_ip_ospf_database,
4172 show_ip_ospf_database_type_cmd,
4173 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4174 SHOW_STR
4175 IP_STR
4176 "OSPF information\n"
4177 "Database summary\n"
4178 OSPF_LSA_TYPES_DESC
4179 "LSAs in MaxAge list\n"
4180 "Self-originated link states\n")
4181
4182 ALIAS (show_ip_ospf_database,
4183 show_ip_ospf_database_type_id_cmd,
4184 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4185 SHOW_STR
4186 IP_STR
4187 "OSPF information\n"
4188 "Database summary\n"
4189 OSPF_LSA_TYPES_DESC
4190 "Link State ID (as an IP address)\n")
4191
4192 ALIAS (show_ip_ospf_database,
4193 show_ip_ospf_database_type_id_adv_router_cmd,
4194 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4195 SHOW_STR
4196 IP_STR
4197 "OSPF information\n"
4198 "Database summary\n"
4199 OSPF_LSA_TYPES_DESC
4200 "Link State ID (as an IP address)\n"
4201 "Advertising Router link states\n"
4202 "Advertising Router (as an IP address)\n")
4203
4204 ALIAS (show_ip_ospf_database,
4205 show_ip_ospf_database_type_id_self_cmd,
4206 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4207 SHOW_STR
4208 IP_STR
4209 "OSPF information\n"
4210 "Database summary\n"
4211 OSPF_LSA_TYPES_DESC
4212 "Link State ID (as an IP address)\n"
4213 "Self-originated link states\n"
4214 "\n")
4215
4216 DEFUN (show_ip_ospf_database_type_adv_router,
4217 show_ip_ospf_database_type_adv_router_cmd,
4218 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4219 SHOW_STR
4220 IP_STR
4221 "OSPF information\n"
4222 "Database summary\n"
4223 OSPF_LSA_TYPES_DESC
4224 "Advertising Router link states\n"
4225 "Advertising Router (as an IP address)\n")
4226 {
4227 struct ospf *ospf;
4228 int type, ret;
4229 struct in_addr adv_router;
4230
4231 ospf = ospf_lookup ();
4232 if (ospf == NULL)
4233 {
4234 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4235 return CMD_SUCCESS;
4236 }
4237
4238 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
4239 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
4240
4241 if (argc != 2)
4242 return CMD_WARNING;
4243
4244 /* Set database type to show. */
4245 if (strncmp (argv[0], "r", 1) == 0)
4246 type = OSPF_ROUTER_LSA;
4247 else if (strncmp (argv[0], "ne", 2) == 0)
4248 type = OSPF_NETWORK_LSA;
4249 else if (strncmp (argv[0], "ns", 2) == 0)
4250 type = OSPF_AS_NSSA_LSA;
4251 else if (strncmp (argv[0], "s", 1) == 0)
4252 type = OSPF_SUMMARY_LSA;
4253 else if (strncmp (argv[0], "a", 1) == 0)
4254 type = OSPF_ASBR_SUMMARY_LSA;
4255 else if (strncmp (argv[0], "e", 1) == 0)
4256 type = OSPF_AS_EXTERNAL_LSA;
4257 #ifdef HAVE_OPAQUE_LSA
4258 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4259 type = OSPF_OPAQUE_LINK_LSA;
4260 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4261 type = OSPF_OPAQUE_AREA_LSA;
4262 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4263 type = OSPF_OPAQUE_AS_LSA;
4264 #endif /* HAVE_OPAQUE_LSA */
4265 else
4266 return CMD_WARNING;
4267
4268 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4269 if (strncmp (argv[1], "s", 1) == 0)
4270 adv_router = ospf->router_id;
4271 else
4272 {
4273 ret = inet_aton (argv[1], &adv_router);
4274 if (!ret)
4275 return CMD_WARNING;
4276 }
4277
4278 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
4279
4280 return CMD_SUCCESS;
4281 }
4282
4283 ALIAS (show_ip_ospf_database_type_adv_router,
4284 show_ip_ospf_database_type_self_cmd,
4285 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4286 SHOW_STR
4287 IP_STR
4288 "OSPF information\n"
4289 "Database summary\n"
4290 OSPF_LSA_TYPES_DESC
4291 "Self-originated link states\n")
4292
4293 \f
4294 DEFUN (ip_ospf_authentication_args,
4295 ip_ospf_authentication_args_addr_cmd,
4296 "ip ospf authentication (null|message-digest) A.B.C.D",
4297 "IP Information\n"
4298 "OSPF interface commands\n"
4299 "Enable authentication on this interface\n"
4300 "Use null authentication\n"
4301 "Use message-digest authentication\n"
4302 "Address of interface")
4303 {
4304 struct interface *ifp;
4305 struct in_addr addr;
4306 int ret;
4307 struct ospf_if_params *params;
4308
4309 ifp = vty->index;
4310 params = IF_DEF_PARAMS (ifp);
4311
4312 if (argc == 2)
4313 {
4314 ret = inet_aton(argv[1], &addr);
4315 if (!ret)
4316 {
4317 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4318 VTY_NEWLINE);
4319 return CMD_WARNING;
4320 }
4321
4322 params = ospf_get_if_params (ifp, addr);
4323 ospf_if_update_params (ifp, addr);
4324 }
4325
4326 /* Handle null authentication */
4327 if ( argv[0][0] == 'n' )
4328 {
4329 SET_IF_PARAM (params, auth_type);
4330 params->auth_type = OSPF_AUTH_NULL;
4331 return CMD_SUCCESS;
4332 }
4333
4334 /* Handle message-digest authentication */
4335 if ( argv[0][0] == 'm' )
4336 {
4337 SET_IF_PARAM (params, auth_type);
4338 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4339 return CMD_SUCCESS;
4340 }
4341
4342 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4343 return CMD_WARNING;
4344 }
4345
4346 ALIAS (ip_ospf_authentication_args,
4347 ip_ospf_authentication_args_cmd,
4348 "ip ospf authentication (null|message-digest)",
4349 "IP Information\n"
4350 "OSPF interface commands\n"
4351 "Enable authentication on this interface\n"
4352 "Use null authentication\n"
4353 "Use message-digest authentication\n")
4354
4355 DEFUN (ip_ospf_authentication,
4356 ip_ospf_authentication_addr_cmd,
4357 "ip ospf authentication A.B.C.D",
4358 "IP Information\n"
4359 "OSPF interface commands\n"
4360 "Enable authentication on this interface\n"
4361 "Address of interface")
4362 {
4363 struct interface *ifp;
4364 struct in_addr addr;
4365 int ret;
4366 struct ospf_if_params *params;
4367
4368 ifp = vty->index;
4369 params = IF_DEF_PARAMS (ifp);
4370
4371 if (argc == 1)
4372 {
4373 ret = inet_aton(argv[0], &addr);
4374 if (!ret)
4375 {
4376 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4377 VTY_NEWLINE);
4378 return CMD_WARNING;
4379 }
4380
4381 params = ospf_get_if_params (ifp, addr);
4382 ospf_if_update_params (ifp, addr);
4383 }
4384
4385 SET_IF_PARAM (params, auth_type);
4386 params->auth_type = OSPF_AUTH_SIMPLE;
4387
4388 return CMD_SUCCESS;
4389 }
4390
4391 ALIAS (ip_ospf_authentication,
4392 ip_ospf_authentication_cmd,
4393 "ip ospf authentication",
4394 "IP Information\n"
4395 "OSPF interface commands\n"
4396 "Enable authentication on this interface\n")
4397
4398 DEFUN (no_ip_ospf_authentication,
4399 no_ip_ospf_authentication_addr_cmd,
4400 "no ip ospf authentication A.B.C.D",
4401 NO_STR
4402 "IP Information\n"
4403 "OSPF interface commands\n"
4404 "Enable authentication on this interface\n"
4405 "Address of interface")
4406 {
4407 struct interface *ifp;
4408 struct in_addr addr;
4409 int ret;
4410 struct ospf_if_params *params;
4411
4412 ifp = vty->index;
4413 params = IF_DEF_PARAMS (ifp);
4414
4415 if (argc == 1)
4416 {
4417 ret = inet_aton(argv[0], &addr);
4418 if (!ret)
4419 {
4420 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4421 VTY_NEWLINE);
4422 return CMD_WARNING;
4423 }
4424
4425 params = ospf_lookup_if_params (ifp, addr);
4426 if (params == NULL)
4427 return CMD_SUCCESS;
4428 }
4429
4430 params->auth_type = OSPF_AUTH_NOTSET;
4431 UNSET_IF_PARAM (params, auth_type);
4432
4433 if (params != IF_DEF_PARAMS (ifp))
4434 {
4435 ospf_free_if_params (ifp, addr);
4436 ospf_if_update_params (ifp, addr);
4437 }
4438
4439 return CMD_SUCCESS;
4440 }
4441
4442 ALIAS (no_ip_ospf_authentication,
4443 no_ip_ospf_authentication_cmd,
4444 "no ip ospf authentication",
4445 NO_STR
4446 "IP Information\n"
4447 "OSPF interface commands\n"
4448 "Enable authentication on this interface\n")
4449
4450 DEFUN (ip_ospf_authentication_key,
4451 ip_ospf_authentication_key_addr_cmd,
4452 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4453 "IP Information\n"
4454 "OSPF interface commands\n"
4455 "Authentication password (key)\n"
4456 "The OSPF password (key)\n"
4457 "Address of interface")
4458 {
4459 struct interface *ifp;
4460 struct in_addr addr;
4461 int ret;
4462 struct ospf_if_params *params;
4463
4464 ifp = vty->index;
4465 params = IF_DEF_PARAMS (ifp);
4466
4467 if (argc == 2)
4468 {
4469 ret = inet_aton(argv[1], &addr);
4470 if (!ret)
4471 {
4472 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4473 VTY_NEWLINE);
4474 return CMD_WARNING;
4475 }
4476
4477 params = ospf_get_if_params (ifp, addr);
4478 ospf_if_update_params (ifp, addr);
4479 }
4480
4481
4482 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
4483 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
4484 SET_IF_PARAM (params, auth_simple);
4485
4486 return CMD_SUCCESS;
4487 }
4488
4489 ALIAS (ip_ospf_authentication_key,
4490 ip_ospf_authentication_key_cmd,
4491 "ip ospf authentication-key AUTH_KEY",
4492 "IP Information\n"
4493 "OSPF interface commands\n"
4494 "Authentication password (key)\n"
4495 "The OSPF password (key)")
4496
4497 ALIAS (ip_ospf_authentication_key,
4498 ospf_authentication_key_cmd,
4499 "ospf authentication-key AUTH_KEY",
4500 "OSPF interface commands\n"
4501 "Authentication password (key)\n"
4502 "The OSPF password (key)")
4503
4504 DEFUN (no_ip_ospf_authentication_key,
4505 no_ip_ospf_authentication_key_addr_cmd,
4506 "no ip ospf authentication-key A.B.C.D",
4507 NO_STR
4508 "IP Information\n"
4509 "OSPF interface commands\n"
4510 "Authentication password (key)\n"
4511 "Address of interface")
4512 {
4513 struct interface *ifp;
4514 struct in_addr addr;
4515 int ret;
4516 struct ospf_if_params *params;
4517
4518 ifp = vty->index;
4519 params = IF_DEF_PARAMS (ifp);
4520
4521 if (argc == 1)
4522 {
4523 ret = inet_aton(argv[0], &addr);
4524 if (!ret)
4525 {
4526 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4527 VTY_NEWLINE);
4528 return CMD_WARNING;
4529 }
4530
4531 params = ospf_lookup_if_params (ifp, addr);
4532 if (params == NULL)
4533 return CMD_SUCCESS;
4534 }
4535
4536 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4537 UNSET_IF_PARAM (params, auth_simple);
4538
4539 if (params != IF_DEF_PARAMS (ifp))
4540 {
4541 ospf_free_if_params (ifp, addr);
4542 ospf_if_update_params (ifp, addr);
4543 }
4544
4545 return CMD_SUCCESS;
4546 }
4547
4548 ALIAS (no_ip_ospf_authentication_key,
4549 no_ip_ospf_authentication_key_cmd,
4550 "no ip ospf authentication-key",
4551 NO_STR
4552 "IP Information\n"
4553 "OSPF interface commands\n"
4554 "Authentication password (key)\n")
4555
4556 ALIAS (no_ip_ospf_authentication_key,
4557 no_ospf_authentication_key_cmd,
4558 "no ospf authentication-key",
4559 NO_STR
4560 "OSPF interface commands\n"
4561 "Authentication password (key)\n")
4562
4563 DEFUN (ip_ospf_message_digest_key,
4564 ip_ospf_message_digest_key_addr_cmd,
4565 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4566 "IP Information\n"
4567 "OSPF interface commands\n"
4568 "Message digest authentication password (key)\n"
4569 "Key ID\n"
4570 "Use MD5 algorithm\n"
4571 "The OSPF password (key)"
4572 "Address of interface")
4573 {
4574 struct interface *ifp;
4575 struct crypt_key *ck;
4576 u_char key_id;
4577 struct in_addr addr;
4578 int ret;
4579 struct ospf_if_params *params;
4580
4581 ifp = vty->index;
4582 params = IF_DEF_PARAMS (ifp);
4583
4584 if (argc == 3)
4585 {
4586 ret = inet_aton(argv[2], &addr);
4587 if (!ret)
4588 {
4589 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4590 VTY_NEWLINE);
4591 return CMD_WARNING;
4592 }
4593
4594 params = ospf_get_if_params (ifp, addr);
4595 ospf_if_update_params (ifp, addr);
4596 }
4597
4598 key_id = strtol (argv[0], NULL, 10);
4599 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4600 {
4601 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4602 return CMD_WARNING;
4603 }
4604
4605 ck = ospf_crypt_key_new ();
4606 ck->key_id = (u_char) key_id;
4607 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
4608 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
4609
4610 ospf_crypt_key_add (params->auth_crypt, ck);
4611 SET_IF_PARAM (params, auth_crypt);
4612
4613 return CMD_SUCCESS;
4614 }
4615
4616 ALIAS (ip_ospf_message_digest_key,
4617 ip_ospf_message_digest_key_cmd,
4618 "ip ospf message-digest-key <1-255> md5 KEY",
4619 "IP Information\n"
4620 "OSPF interface commands\n"
4621 "Message digest authentication password (key)\n"
4622 "Key ID\n"
4623 "Use MD5 algorithm\n"
4624 "The OSPF password (key)")
4625
4626 ALIAS (ip_ospf_message_digest_key,
4627 ospf_message_digest_key_cmd,
4628 "ospf message-digest-key <1-255> md5 KEY",
4629 "OSPF interface commands\n"
4630 "Message digest authentication password (key)\n"
4631 "Key ID\n"
4632 "Use MD5 algorithm\n"
4633 "The OSPF password (key)")
4634
4635 DEFUN (no_ip_ospf_message_digest_key,
4636 no_ip_ospf_message_digest_key_addr_cmd,
4637 "no ip ospf message-digest-key <1-255> A.B.C.D",
4638 NO_STR
4639 "IP Information\n"
4640 "OSPF interface commands\n"
4641 "Message digest authentication password (key)\n"
4642 "Key ID\n"
4643 "Address of interface")
4644 {
4645 struct interface *ifp;
4646 struct crypt_key *ck;
4647 int key_id;
4648 struct in_addr addr;
4649 int ret;
4650 struct ospf_if_params *params;
4651
4652 ifp = vty->index;
4653 params = IF_DEF_PARAMS (ifp);
4654
4655 if (argc == 2)
4656 {
4657 ret = inet_aton(argv[1], &addr);
4658 if (!ret)
4659 {
4660 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4661 VTY_NEWLINE);
4662 return CMD_WARNING;
4663 }
4664
4665 params = ospf_lookup_if_params (ifp, addr);
4666 if (params == NULL)
4667 return CMD_SUCCESS;
4668 }
4669
4670 key_id = strtol (argv[0], NULL, 10);
4671 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4672 if (ck == NULL)
4673 {
4674 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4675 return CMD_WARNING;
4676 }
4677
4678 ospf_crypt_key_delete (params->auth_crypt, key_id);
4679
4680 if (params != IF_DEF_PARAMS (ifp))
4681 {
4682 ospf_free_if_params (ifp, addr);
4683 ospf_if_update_params (ifp, addr);
4684 }
4685
4686 return CMD_SUCCESS;
4687 }
4688
4689 ALIAS (no_ip_ospf_message_digest_key,
4690 no_ip_ospf_message_digest_key_cmd,
4691 "no ip ospf message-digest-key <1-255>",
4692 NO_STR
4693 "IP Information\n"
4694 "OSPF interface commands\n"
4695 "Message digest authentication password (key)\n"
4696 "Key ID\n")
4697
4698 ALIAS (no_ip_ospf_message_digest_key,
4699 no_ospf_message_digest_key_cmd,
4700 "no ospf message-digest-key <1-255>",
4701 NO_STR
4702 "OSPF interface commands\n"
4703 "Message digest authentication password (key)\n"
4704 "Key ID\n")
4705
4706 DEFUN (ip_ospf_cost,
4707 ip_ospf_cost_u32_inet4_cmd,
4708 "ip ospf cost <1-65535> A.B.C.D",
4709 "IP Information\n"
4710 "OSPF interface commands\n"
4711 "Interface cost\n"
4712 "Cost\n"
4713 "Address of interface")
4714 {
4715 struct interface *ifp = vty->index;
4716 u_int32_t cost;
4717 struct in_addr addr;
4718 int ret;
4719 struct ospf_if_params *params;
4720
4721 params = IF_DEF_PARAMS (ifp);
4722
4723 cost = strtol (argv[0], NULL, 10);
4724
4725 /* cost range is <1-65535>. */
4726 if (cost < 1 || cost > 65535)
4727 {
4728 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4729 return CMD_WARNING;
4730 }
4731
4732 if (argc == 2)
4733 {
4734 ret = inet_aton(argv[1], &addr);
4735 if (!ret)
4736 {
4737 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4738 VTY_NEWLINE);
4739 return CMD_WARNING;
4740 }
4741
4742 params = ospf_get_if_params (ifp, addr);
4743 ospf_if_update_params (ifp, addr);
4744 }
4745
4746 SET_IF_PARAM (params, output_cost_cmd);
4747 params->output_cost_cmd = cost;
4748
4749 ospf_if_recalculate_output_cost (ifp);
4750
4751 return CMD_SUCCESS;
4752 }
4753
4754 ALIAS (ip_ospf_cost,
4755 ip_ospf_cost_u32_cmd,
4756 "ip ospf cost <1-65535>",
4757 "IP Information\n"
4758 "OSPF interface commands\n"
4759 "Interface cost\n"
4760 "Cost")
4761
4762 ALIAS (ip_ospf_cost,
4763 ospf_cost_u32_cmd,
4764 "ospf cost <1-65535>",
4765 "OSPF interface commands\n"
4766 "Interface cost\n"
4767 "Cost")
4768
4769 ALIAS (ip_ospf_cost,
4770 ospf_cost_u32_inet4_cmd,
4771 "ospf cost <1-65535> A.B.C.D",
4772 "OSPF interface commands\n"
4773 "Interface cost\n"
4774 "Cost\n"
4775 "Address of interface")
4776
4777 DEFUN (no_ip_ospf_cost,
4778 no_ip_ospf_cost_inet4_cmd,
4779 "no ip ospf cost A.B.C.D",
4780 NO_STR
4781 "IP Information\n"
4782 "OSPF interface commands\n"
4783 "Interface cost\n"
4784 "Address of interface")
4785 {
4786 struct interface *ifp = vty->index;
4787 struct in_addr addr;
4788 int ret;
4789 struct ospf_if_params *params;
4790
4791 ifp = vty->index;
4792 params = IF_DEF_PARAMS (ifp);
4793
4794 if (argc == 1)
4795 {
4796 ret = inet_aton(argv[0], &addr);
4797 if (!ret)
4798 {
4799 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4800 VTY_NEWLINE);
4801 return CMD_WARNING;
4802 }
4803
4804 params = ospf_lookup_if_params (ifp, addr);
4805 if (params == NULL)
4806 return CMD_SUCCESS;
4807 }
4808
4809 UNSET_IF_PARAM (params, output_cost_cmd);
4810
4811 if (params != IF_DEF_PARAMS (ifp))
4812 {
4813 ospf_free_if_params (ifp, addr);
4814 ospf_if_update_params (ifp, addr);
4815 }
4816
4817 ospf_if_recalculate_output_cost (ifp);
4818
4819 return CMD_SUCCESS;
4820 }
4821
4822 ALIAS (no_ip_ospf_cost,
4823 no_ip_ospf_cost_cmd,
4824 "no ip ospf cost",
4825 NO_STR
4826 "IP Information\n"
4827 "OSPF interface commands\n"
4828 "Interface cost\n")
4829
4830 ALIAS (no_ip_ospf_cost,
4831 no_ospf_cost_cmd,
4832 "no ospf cost",
4833 NO_STR
4834 "OSPF interface commands\n"
4835 "Interface cost\n")
4836
4837 ALIAS (no_ip_ospf_cost,
4838 no_ospf_cost_inet4_cmd,
4839 "no ospf cost A.B.C.D",
4840 NO_STR
4841 "OSPF interface commands\n"
4842 "Interface cost\n"
4843 "Address of interface")
4844
4845 DEFUN (no_ip_ospf_cost2,
4846 no_ip_ospf_cost_u32_cmd,
4847 "no ip ospf cost <1-65535>",
4848 NO_STR
4849 "IP Information\n"
4850 "OSPF interface commands\n"
4851 "Interface cost\n"
4852 "Cost")
4853 {
4854 struct interface *ifp = vty->index;
4855 struct in_addr addr;
4856 u_int32_t cost;
4857 int ret;
4858 struct ospf_if_params *params;
4859
4860 ifp = vty->index;
4861 params = IF_DEF_PARAMS (ifp);
4862
4863 /* According to the semantics we are mimicking "no ip ospf cost N" is
4864 * always treated as "no ip ospf cost" regardless of the actual value
4865 * of N already configured for the interface. Thus the first argument
4866 * is always checked to be a number, but is ignored after that.
4867 */
4868 cost = strtol (argv[0], NULL, 10);
4869 if (cost < 1 || cost > 65535)
4870 {
4871 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4872 return CMD_WARNING;
4873 }
4874
4875 if (argc == 2)
4876 {
4877 ret = inet_aton(argv[1], &addr);
4878 if (!ret)
4879 {
4880 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4881 VTY_NEWLINE);
4882 return CMD_WARNING;
4883 }
4884
4885 params = ospf_lookup_if_params (ifp, addr);
4886 if (params == NULL)
4887 return CMD_SUCCESS;
4888 }
4889
4890 UNSET_IF_PARAM (params, output_cost_cmd);
4891
4892 if (params != IF_DEF_PARAMS (ifp))
4893 {
4894 ospf_free_if_params (ifp, addr);
4895 ospf_if_update_params (ifp, addr);
4896 }
4897
4898 ospf_if_recalculate_output_cost (ifp);
4899
4900 return CMD_SUCCESS;
4901 }
4902
4903 ALIAS (no_ip_ospf_cost2,
4904 no_ospf_cost_u32_cmd,
4905 "no ospf cost <1-65535>",
4906 NO_STR
4907 "OSPF interface commands\n"
4908 "Interface cost\n"
4909 "Cost")
4910
4911 ALIAS (no_ip_ospf_cost2,
4912 no_ip_ospf_cost_u32_inet4_cmd,
4913 "no ip ospf cost <1-65535> A.B.C.D",
4914 NO_STR
4915 "IP Information\n"
4916 "OSPF interface commands\n"
4917 "Interface cost\n"
4918 "Cost\n"
4919 "Address of interface")
4920
4921 ALIAS (no_ip_ospf_cost2,
4922 no_ospf_cost_u32_inet4_cmd,
4923 "no ospf cost <1-65535> A.B.C.D",
4924 NO_STR
4925 "OSPF interface commands\n"
4926 "Interface cost\n"
4927 "Cost\n"
4928 "Address of interface")
4929
4930 static void
4931 ospf_nbr_timer_update (struct ospf_interface *oi)
4932 {
4933 struct route_node *rn;
4934 struct ospf_neighbor *nbr;
4935
4936 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4937 if ((nbr = rn->info))
4938 {
4939 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4940 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4941 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4942 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4943 }
4944 }
4945
4946 static int
4947 ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4948 const char *nbr_str,
4949 const char *fast_hello_str)
4950 {
4951 struct interface *ifp = vty->index;
4952 u_int32_t seconds;
4953 u_char hellomult;
4954 struct in_addr addr;
4955 int ret;
4956 struct ospf_if_params *params;
4957 struct ospf_interface *oi;
4958 struct route_node *rn;
4959
4960 params = IF_DEF_PARAMS (ifp);
4961
4962 if (nbr_str)
4963 {
4964 ret = inet_aton(nbr_str, &addr);
4965 if (!ret)
4966 {
4967 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4968 VTY_NEWLINE);
4969 return CMD_WARNING;
4970 }
4971
4972 params = ospf_get_if_params (ifp, addr);
4973 ospf_if_update_params (ifp, addr);
4974 }
4975
4976 if (interval_str)
4977 {
4978 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4979 1, 65535);
4980
4981 /* reset fast_hello too, just to be sure */
4982 UNSET_IF_PARAM (params, fast_hello);
4983 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4984 }
4985 else if (fast_hello_str)
4986 {
4987 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4988 1, 10);
4989 /* 1s dead-interval with sub-second hellos desired */
4990 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4991 SET_IF_PARAM (params, fast_hello);
4992 params->fast_hello = hellomult;
4993 }
4994 else
4995 {
4996 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4997 VTY_NEWLINE);
4998 return CMD_WARNING;
4999 }
5000
5001 SET_IF_PARAM (params, v_wait);
5002 params->v_wait = seconds;
5003
5004 /* Update timer values in neighbor structure. */
5005 if (nbr_str)
5006 {
5007 struct ospf *ospf;
5008 if ((ospf = ospf_lookup()))
5009 {
5010 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5011 if (oi)
5012 ospf_nbr_timer_update (oi);
5013 }
5014 }
5015 else
5016 {
5017 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5018 if ((oi = rn->info))
5019 ospf_nbr_timer_update (oi);
5020 }
5021
5022 return CMD_SUCCESS;
5023 }
5024
5025
5026 DEFUN (ip_ospf_dead_interval,
5027 ip_ospf_dead_interval_addr_cmd,
5028 "ip ospf dead-interval <1-65535> A.B.C.D",
5029 "IP Information\n"
5030 "OSPF interface commands\n"
5031 "Interval after which a neighbor is declared dead\n"
5032 "Seconds\n"
5033 "Address of interface\n")
5034 {
5035 if (argc == 2)
5036 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5037 else
5038 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5039 }
5040
5041 ALIAS (ip_ospf_dead_interval,
5042 ip_ospf_dead_interval_cmd,
5043 "ip ospf dead-interval <1-65535>",
5044 "IP Information\n"
5045 "OSPF interface commands\n"
5046 "Interval after which a neighbor is declared dead\n"
5047 "Seconds\n")
5048
5049 ALIAS (ip_ospf_dead_interval,
5050 ospf_dead_interval_cmd,
5051 "ospf dead-interval <1-65535>",
5052 "OSPF interface commands\n"
5053 "Interval after which a neighbor is declared dead\n"
5054 "Seconds\n")
5055
5056 DEFUN (ip_ospf_dead_interval_minimal,
5057 ip_ospf_dead_interval_minimal_addr_cmd,
5058 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5059 "IP Information\n"
5060 "OSPF interface commands\n"
5061 "Interval after which a neighbor is declared dead\n"
5062 "Minimal 1s dead-interval with fast sub-second hellos\n"
5063 "Hello multiplier factor\n"
5064 "Number of Hellos to send each second\n"
5065 "Address of interface\n")
5066 {
5067 if (argc == 2)
5068 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5069 else
5070 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5071 }
5072
5073 ALIAS (ip_ospf_dead_interval_minimal,
5074 ip_ospf_dead_interval_minimal_cmd,
5075 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5076 "IP Information\n"
5077 "OSPF interface commands\n"
5078 "Interval after which a neighbor is declared dead\n"
5079 "Minimal 1s dead-interval with fast sub-second hellos\n"
5080 "Hello multiplier factor\n"
5081 "Number of Hellos to send each second\n")
5082
5083 DEFUN (no_ip_ospf_dead_interval,
5084 no_ip_ospf_dead_interval_addr_cmd,
5085 "no ip ospf dead-interval A.B.C.D",
5086 NO_STR
5087 "IP Information\n"
5088 "OSPF interface commands\n"
5089 "Interval after which a neighbor is declared dead\n"
5090 "Address of interface")
5091 {
5092 struct interface *ifp = vty->index;
5093 struct in_addr addr;
5094 int ret;
5095 struct ospf_if_params *params;
5096 struct ospf_interface *oi;
5097 struct route_node *rn;
5098
5099 ifp = vty->index;
5100 params = IF_DEF_PARAMS (ifp);
5101
5102 if (argc == 1)
5103 {
5104 ret = inet_aton(argv[0], &addr);
5105 if (!ret)
5106 {
5107 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5108 VTY_NEWLINE);
5109 return CMD_WARNING;
5110 }
5111
5112 params = ospf_lookup_if_params (ifp, addr);
5113 if (params == NULL)
5114 return CMD_SUCCESS;
5115 }
5116
5117 UNSET_IF_PARAM (params, v_wait);
5118 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
5119
5120 UNSET_IF_PARAM (params, fast_hello);
5121 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5122
5123 if (params != IF_DEF_PARAMS (ifp))
5124 {
5125 ospf_free_if_params (ifp, addr);
5126 ospf_if_update_params (ifp, addr);
5127 }
5128
5129 /* Update timer values in neighbor structure. */
5130 if (argc == 1)
5131 {
5132 struct ospf *ospf;
5133
5134 if ((ospf = ospf_lookup()))
5135 {
5136 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5137 if (oi)
5138 ospf_nbr_timer_update (oi);
5139 }
5140 }
5141 else
5142 {
5143 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5144 if ((oi = rn->info))
5145 ospf_nbr_timer_update (oi);
5146 }
5147
5148 return CMD_SUCCESS;
5149 }
5150
5151 ALIAS (no_ip_ospf_dead_interval,
5152 no_ip_ospf_dead_interval_cmd,
5153 "no ip ospf dead-interval",
5154 NO_STR
5155 "IP Information\n"
5156 "OSPF interface commands\n"
5157 "Interval after which a neighbor is declared dead\n")
5158
5159 ALIAS (no_ip_ospf_dead_interval,
5160 no_ospf_dead_interval_cmd,
5161 "no ospf dead-interval",
5162 NO_STR
5163 "OSPF interface commands\n"
5164 "Interval after which a neighbor is declared dead\n")
5165
5166 DEFUN (ip_ospf_hello_interval,
5167 ip_ospf_hello_interval_addr_cmd,
5168 "ip ospf hello-interval <1-65535> A.B.C.D",
5169 "IP Information\n"
5170 "OSPF interface commands\n"
5171 "Time between HELLO packets\n"
5172 "Seconds\n"
5173 "Address of interface")
5174 {
5175 struct interface *ifp = vty->index;
5176 u_int32_t seconds;
5177 struct in_addr addr;
5178 int ret;
5179 struct ospf_if_params *params;
5180
5181 params = IF_DEF_PARAMS (ifp);
5182
5183 seconds = strtol (argv[0], NULL, 10);
5184
5185 /* HelloInterval range is <1-65535>. */
5186 if (seconds < 1 || seconds > 65535)
5187 {
5188 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5189 return CMD_WARNING;
5190 }
5191
5192 if (argc == 2)
5193 {
5194 ret = inet_aton(argv[1], &addr);
5195 if (!ret)
5196 {
5197 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5198 VTY_NEWLINE);
5199 return CMD_WARNING;
5200 }
5201
5202 params = ospf_get_if_params (ifp, addr);
5203 ospf_if_update_params (ifp, addr);
5204 }
5205
5206 SET_IF_PARAM (params, v_hello);
5207 params->v_hello = seconds;
5208
5209 return CMD_SUCCESS;
5210 }
5211
5212 ALIAS (ip_ospf_hello_interval,
5213 ip_ospf_hello_interval_cmd,
5214 "ip ospf hello-interval <1-65535>",
5215 "IP Information\n"
5216 "OSPF interface commands\n"
5217 "Time between HELLO packets\n"
5218 "Seconds\n")
5219
5220 ALIAS (ip_ospf_hello_interval,
5221 ospf_hello_interval_cmd,
5222 "ospf hello-interval <1-65535>",
5223 "OSPF interface commands\n"
5224 "Time between HELLO packets\n"
5225 "Seconds\n")
5226
5227 DEFUN (no_ip_ospf_hello_interval,
5228 no_ip_ospf_hello_interval_addr_cmd,
5229 "no ip ospf hello-interval A.B.C.D",
5230 NO_STR
5231 "IP Information\n"
5232 "OSPF interface commands\n"
5233 "Time between HELLO packets\n"
5234 "Address of interface")
5235 {
5236 struct interface *ifp = vty->index;
5237 struct in_addr addr;
5238 int ret;
5239 struct ospf_if_params *params;
5240
5241 ifp = vty->index;
5242 params = IF_DEF_PARAMS (ifp);
5243
5244 if (argc == 1)
5245 {
5246 ret = inet_aton(argv[0], &addr);
5247 if (!ret)
5248 {
5249 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5250 VTY_NEWLINE);
5251 return CMD_WARNING;
5252 }
5253
5254 params = ospf_lookup_if_params (ifp, addr);
5255 if (params == NULL)
5256 return CMD_SUCCESS;
5257 }
5258
5259 UNSET_IF_PARAM (params, v_hello);
5260 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
5261
5262 if (params != IF_DEF_PARAMS (ifp))
5263 {
5264 ospf_free_if_params (ifp, addr);
5265 ospf_if_update_params (ifp, addr);
5266 }
5267
5268 return CMD_SUCCESS;
5269 }
5270
5271 ALIAS (no_ip_ospf_hello_interval,
5272 no_ip_ospf_hello_interval_cmd,
5273 "no ip ospf hello-interval",
5274 NO_STR
5275 "IP Information\n"
5276 "OSPF interface commands\n"
5277 "Time between HELLO packets\n")
5278
5279 ALIAS (no_ip_ospf_hello_interval,
5280 no_ospf_hello_interval_cmd,
5281 "no ospf hello-interval",
5282 NO_STR
5283 "OSPF interface commands\n"
5284 "Time between HELLO packets\n")
5285
5286 DEFUN (ip_ospf_network,
5287 ip_ospf_network_cmd,
5288 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5289 "IP Information\n"
5290 "OSPF interface commands\n"
5291 "Network type\n"
5292 "Specify OSPF broadcast multi-access network\n"
5293 "Specify OSPF NBMA network\n"
5294 "Specify OSPF point-to-multipoint network\n"
5295 "Specify OSPF point-to-point network\n")
5296 {
5297 struct interface *ifp = vty->index;
5298 int old_type = IF_DEF_PARAMS (ifp)->type;
5299 struct route_node *rn;
5300
5301 if (strncmp (argv[0], "b", 1) == 0)
5302 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5303 else if (strncmp (argv[0], "n", 1) == 0)
5304 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5305 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5306 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5307 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5308 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5309
5310 if (IF_DEF_PARAMS (ifp)->type == old_type)
5311 return CMD_SUCCESS;
5312
5313 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5314
5315 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5316 {
5317 struct ospf_interface *oi = rn->info;
5318
5319 if (!oi)
5320 continue;
5321
5322 oi->type = IF_DEF_PARAMS (ifp)->type;
5323
5324 if (oi->state > ISM_Down)
5325 {
5326 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5327 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5328 }
5329 }
5330
5331 return CMD_SUCCESS;
5332 }
5333
5334 ALIAS (ip_ospf_network,
5335 ospf_network_cmd,
5336 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5337 "OSPF interface commands\n"
5338 "Network type\n"
5339 "Specify OSPF broadcast multi-access network\n"
5340 "Specify OSPF NBMA network\n"
5341 "Specify OSPF point-to-multipoint network\n"
5342 "Specify OSPF point-to-point network\n")
5343
5344 DEFUN (no_ip_ospf_network,
5345 no_ip_ospf_network_cmd,
5346 "no ip ospf network",
5347 NO_STR
5348 "IP Information\n"
5349 "OSPF interface commands\n"
5350 "Network type\n")
5351 {
5352 struct interface *ifp = vty->index;
5353 int old_type = IF_DEF_PARAMS (ifp)->type;
5354 struct route_node *rn;
5355
5356 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
5357
5358 if (IF_DEF_PARAMS (ifp)->type == old_type)
5359 return CMD_SUCCESS;
5360
5361 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5362 {
5363 struct ospf_interface *oi = rn->info;
5364
5365 if (!oi)
5366 continue;
5367
5368 oi->type = IF_DEF_PARAMS (ifp)->type;
5369
5370 if (oi->state > ISM_Down)
5371 {
5372 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5373 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5374 }
5375 }
5376
5377 return CMD_SUCCESS;
5378 }
5379
5380 ALIAS (no_ip_ospf_network,
5381 no_ospf_network_cmd,
5382 "no ospf network",
5383 NO_STR
5384 "OSPF interface commands\n"
5385 "Network type\n")
5386
5387 DEFUN (ip_ospf_priority,
5388 ip_ospf_priority_addr_cmd,
5389 "ip ospf priority <0-255> A.B.C.D",
5390 "IP Information\n"
5391 "OSPF interface commands\n"
5392 "Router priority\n"
5393 "Priority\n"
5394 "Address of interface")
5395 {
5396 struct interface *ifp = vty->index;
5397 u_int32_t priority;
5398 struct route_node *rn;
5399 struct in_addr addr;
5400 int ret;
5401 struct ospf_if_params *params;
5402
5403 params = IF_DEF_PARAMS (ifp);
5404
5405 priority = strtol (argv[0], NULL, 10);
5406
5407 /* Router Priority range is <0-255>. */
5408 if (priority < 0 || priority > 255)
5409 {
5410 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5411 return CMD_WARNING;
5412 }
5413
5414 if (argc == 2)
5415 {
5416 ret = inet_aton(argv[1], &addr);
5417 if (!ret)
5418 {
5419 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5420 VTY_NEWLINE);
5421 return CMD_WARNING;
5422 }
5423
5424 params = ospf_get_if_params (ifp, addr);
5425 ospf_if_update_params (ifp, addr);
5426 }
5427
5428 SET_IF_PARAM (params, priority);
5429 params->priority = priority;
5430
5431 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5432 {
5433 struct ospf_interface *oi = rn->info;
5434
5435 if (!oi)
5436 continue;
5437
5438
5439 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5440 {
5441 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5442 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5443 }
5444 }
5445
5446 return CMD_SUCCESS;
5447 }
5448
5449 ALIAS (ip_ospf_priority,
5450 ip_ospf_priority_cmd,
5451 "ip ospf priority <0-255>",
5452 "IP Information\n"
5453 "OSPF interface commands\n"
5454 "Router priority\n"
5455 "Priority\n")
5456
5457 ALIAS (ip_ospf_priority,
5458 ospf_priority_cmd,
5459 "ospf priority <0-255>",
5460 "OSPF interface commands\n"
5461 "Router priority\n"
5462 "Priority\n")
5463
5464 DEFUN (no_ip_ospf_priority,
5465 no_ip_ospf_priority_addr_cmd,
5466 "no ip ospf priority A.B.C.D",
5467 NO_STR
5468 "IP Information\n"
5469 "OSPF interface commands\n"
5470 "Router priority\n"
5471 "Address of interface")
5472 {
5473 struct interface *ifp = vty->index;
5474 struct route_node *rn;
5475 struct in_addr addr;
5476 int ret;
5477 struct ospf_if_params *params;
5478
5479 ifp = vty->index;
5480 params = IF_DEF_PARAMS (ifp);
5481
5482 if (argc == 1)
5483 {
5484 ret = inet_aton(argv[0], &addr);
5485 if (!ret)
5486 {
5487 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5488 VTY_NEWLINE);
5489 return CMD_WARNING;
5490 }
5491
5492 params = ospf_lookup_if_params (ifp, addr);
5493 if (params == NULL)
5494 return CMD_SUCCESS;
5495 }
5496
5497 UNSET_IF_PARAM (params, priority);
5498 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5499
5500 if (params != IF_DEF_PARAMS (ifp))
5501 {
5502 ospf_free_if_params (ifp, addr);
5503 ospf_if_update_params (ifp, addr);
5504 }
5505
5506 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5507 {
5508 struct ospf_interface *oi = rn->info;
5509
5510 if (!oi)
5511 continue;
5512
5513
5514 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5515 {
5516 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5517 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5518 }
5519 }
5520
5521 return CMD_SUCCESS;
5522 }
5523
5524 ALIAS (no_ip_ospf_priority,
5525 no_ip_ospf_priority_cmd,
5526 "no ip ospf priority",
5527 NO_STR
5528 "IP Information\n"
5529 "OSPF interface commands\n"
5530 "Router priority\n")
5531
5532 ALIAS (no_ip_ospf_priority,
5533 no_ospf_priority_cmd,
5534 "no ospf priority",
5535 NO_STR
5536 "OSPF interface commands\n"
5537 "Router priority\n")
5538
5539 DEFUN (ip_ospf_retransmit_interval,
5540 ip_ospf_retransmit_interval_addr_cmd,
5541 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5542 "IP Information\n"
5543 "OSPF interface commands\n"
5544 "Time between retransmitting lost link state advertisements\n"
5545 "Seconds\n"
5546 "Address of interface")
5547 {
5548 struct interface *ifp = vty->index;
5549 u_int32_t seconds;
5550 struct in_addr addr;
5551 int ret;
5552 struct ospf_if_params *params;
5553
5554 params = IF_DEF_PARAMS (ifp);
5555 seconds = strtol (argv[0], NULL, 10);
5556
5557 /* Retransmit Interval range is <3-65535>. */
5558 if (seconds < 3 || seconds > 65535)
5559 {
5560 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5561 return CMD_WARNING;
5562 }
5563
5564
5565 if (argc == 2)
5566 {
5567 ret = inet_aton(argv[1], &addr);
5568 if (!ret)
5569 {
5570 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5571 VTY_NEWLINE);
5572 return CMD_WARNING;
5573 }
5574
5575 params = ospf_get_if_params (ifp, addr);
5576 ospf_if_update_params (ifp, addr);
5577 }
5578
5579 SET_IF_PARAM (params, retransmit_interval);
5580 params->retransmit_interval = seconds;
5581
5582 return CMD_SUCCESS;
5583 }
5584
5585 ALIAS (ip_ospf_retransmit_interval,
5586 ip_ospf_retransmit_interval_cmd,
5587 "ip ospf retransmit-interval <3-65535>",
5588 "IP Information\n"
5589 "OSPF interface commands\n"
5590 "Time between retransmitting lost link state advertisements\n"
5591 "Seconds\n")
5592
5593 ALIAS (ip_ospf_retransmit_interval,
5594 ospf_retransmit_interval_cmd,
5595 "ospf retransmit-interval <3-65535>",
5596 "OSPF interface commands\n"
5597 "Time between retransmitting lost link state advertisements\n"
5598 "Seconds\n")
5599
5600 DEFUN (no_ip_ospf_retransmit_interval,
5601 no_ip_ospf_retransmit_interval_addr_cmd,
5602 "no ip ospf retransmit-interval A.B.C.D",
5603 NO_STR
5604 "IP Information\n"
5605 "OSPF interface commands\n"
5606 "Time between retransmitting lost link state advertisements\n"
5607 "Address of interface")
5608 {
5609 struct interface *ifp = vty->index;
5610 struct in_addr addr;
5611 int ret;
5612 struct ospf_if_params *params;
5613
5614 ifp = vty->index;
5615 params = IF_DEF_PARAMS (ifp);
5616
5617 if (argc == 1)
5618 {
5619 ret = inet_aton(argv[0], &addr);
5620 if (!ret)
5621 {
5622 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5623 VTY_NEWLINE);
5624 return CMD_WARNING;
5625 }
5626
5627 params = ospf_lookup_if_params (ifp, addr);
5628 if (params == NULL)
5629 return CMD_SUCCESS;
5630 }
5631
5632 UNSET_IF_PARAM (params, retransmit_interval);
5633 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5634
5635 if (params != IF_DEF_PARAMS (ifp))
5636 {
5637 ospf_free_if_params (ifp, addr);
5638 ospf_if_update_params (ifp, addr);
5639 }
5640
5641 return CMD_SUCCESS;
5642 }
5643
5644 ALIAS (no_ip_ospf_retransmit_interval,
5645 no_ip_ospf_retransmit_interval_cmd,
5646 "no ip ospf retransmit-interval",
5647 NO_STR
5648 "IP Information\n"
5649 "OSPF interface commands\n"
5650 "Time between retransmitting lost link state advertisements\n")
5651
5652 ALIAS (no_ip_ospf_retransmit_interval,
5653 no_ospf_retransmit_interval_cmd,
5654 "no ospf retransmit-interval",
5655 NO_STR
5656 "OSPF interface commands\n"
5657 "Time between retransmitting lost link state advertisements\n")
5658
5659 DEFUN (ip_ospf_transmit_delay,
5660 ip_ospf_transmit_delay_addr_cmd,
5661 "ip ospf transmit-delay <1-65535> A.B.C.D",
5662 "IP Information\n"
5663 "OSPF interface commands\n"
5664 "Link state transmit delay\n"
5665 "Seconds\n"
5666 "Address of interface")
5667 {
5668 struct interface *ifp = vty->index;
5669 u_int32_t seconds;
5670 struct in_addr addr;
5671 int ret;
5672 struct ospf_if_params *params;
5673
5674 params = IF_DEF_PARAMS (ifp);
5675 seconds = strtol (argv[0], NULL, 10);
5676
5677 /* Transmit Delay range is <1-65535>. */
5678 if (seconds < 1 || seconds > 65535)
5679 {
5680 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5681 return CMD_WARNING;
5682 }
5683
5684 if (argc == 2)
5685 {
5686 ret = inet_aton(argv[1], &addr);
5687 if (!ret)
5688 {
5689 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5690 VTY_NEWLINE);
5691 return CMD_WARNING;
5692 }
5693
5694 params = ospf_get_if_params (ifp, addr);
5695 ospf_if_update_params (ifp, addr);
5696 }
5697
5698 SET_IF_PARAM (params, transmit_delay);
5699 params->transmit_delay = seconds;
5700
5701 return CMD_SUCCESS;
5702 }
5703
5704 ALIAS (ip_ospf_transmit_delay,
5705 ip_ospf_transmit_delay_cmd,
5706 "ip ospf transmit-delay <1-65535>",
5707 "IP Information\n"
5708 "OSPF interface commands\n"
5709 "Link state transmit delay\n"
5710 "Seconds\n")
5711
5712 ALIAS (ip_ospf_transmit_delay,
5713 ospf_transmit_delay_cmd,
5714 "ospf transmit-delay <1-65535>",
5715 "OSPF interface commands\n"
5716 "Link state transmit delay\n"
5717 "Seconds\n")
5718
5719 DEFUN (no_ip_ospf_transmit_delay,
5720 no_ip_ospf_transmit_delay_addr_cmd,
5721 "no ip ospf transmit-delay A.B.C.D",
5722 NO_STR
5723 "IP Information\n"
5724 "OSPF interface commands\n"
5725 "Link state transmit delay\n"
5726 "Address of interface")
5727 {
5728 struct interface *ifp = vty->index;
5729 struct in_addr addr;
5730 int ret;
5731 struct ospf_if_params *params;
5732
5733 ifp = vty->index;
5734 params = IF_DEF_PARAMS (ifp);
5735
5736 if (argc == 1)
5737 {
5738 ret = inet_aton(argv[0], &addr);
5739 if (!ret)
5740 {
5741 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5742 VTY_NEWLINE);
5743 return CMD_WARNING;
5744 }
5745
5746 params = ospf_lookup_if_params (ifp, addr);
5747 if (params == NULL)
5748 return CMD_SUCCESS;
5749 }
5750
5751 UNSET_IF_PARAM (params, transmit_delay);
5752 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5753
5754 if (params != IF_DEF_PARAMS (ifp))
5755 {
5756 ospf_free_if_params (ifp, addr);
5757 ospf_if_update_params (ifp, addr);
5758 }
5759
5760 return CMD_SUCCESS;
5761 }
5762
5763 ALIAS (no_ip_ospf_transmit_delay,
5764 no_ip_ospf_transmit_delay_cmd,
5765 "no ip ospf transmit-delay",
5766 NO_STR
5767 "IP Information\n"
5768 "OSPF interface commands\n"
5769 "Link state transmit delay\n")
5770
5771 ALIAS (no_ip_ospf_transmit_delay,
5772 no_ospf_transmit_delay_cmd,
5773 "no ospf transmit-delay",
5774 NO_STR
5775 "OSPF interface commands\n"
5776 "Link state transmit delay\n")
5777
5778 \f
5779 DEFUN (ospf_redistribute_source_metric_type,
5780 ospf_redistribute_source_metric_type_routemap_cmd,
5781 "redistribute " QUAGGA_REDIST_STR_OSPFD
5782 " metric <0-16777214> metric-type (1|2) route-map WORD",
5783 REDIST_STR
5784 QUAGGA_REDIST_HELP_STR_OSPFD
5785 "Metric for redistributed routes\n"
5786 "OSPF default metric\n"
5787 "OSPF exterior metric type for redistributed routes\n"
5788 "Set OSPF External Type 1 metrics\n"
5789 "Set OSPF External Type 2 metrics\n"
5790 "Route map reference\n"
5791 "Pointer to route-map entries\n")
5792 {
5793 struct ospf *ospf = vty->index;
5794 int source;
5795 int type = -1;
5796 int metric = -1;
5797
5798 /* Get distribute source. */
5799 source = proto_redistnum(AFI_IP, argv[0]);
5800 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5801 return CMD_WARNING;
5802
5803 /* Get metric value. */
5804 if (argc >= 2)
5805 if (!str2metric (argv[1], &metric))
5806 return CMD_WARNING;
5807
5808 /* Get metric type. */
5809 if (argc >= 3)
5810 if (!str2metric_type (argv[2], &type))
5811 return CMD_WARNING;
5812
5813 if (argc == 4)
5814 ospf_routemap_set (ospf, source, argv[3]);
5815 else
5816 ospf_routemap_unset (ospf, source);
5817
5818 return ospf_redistribute_set (ospf, source, type, metric);
5819 }
5820
5821 ALIAS (ospf_redistribute_source_metric_type,
5822 ospf_redistribute_source_metric_type_cmd,
5823 "redistribute " QUAGGA_REDIST_STR_OSPFD
5824 " metric <0-16777214> metric-type (1|2)",
5825 REDIST_STR
5826 QUAGGA_REDIST_HELP_STR_OSPFD
5827 "Metric for redistributed routes\n"
5828 "OSPF default metric\n"
5829 "OSPF exterior metric type for redistributed routes\n"
5830 "Set OSPF External Type 1 metrics\n"
5831 "Set OSPF External Type 2 metrics\n")
5832
5833 ALIAS (ospf_redistribute_source_metric_type,
5834 ospf_redistribute_source_metric_cmd,
5835 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5836 REDIST_STR
5837 QUAGGA_REDIST_HELP_STR_OSPFD
5838 "Metric for redistributed routes\n"
5839 "OSPF default metric\n")
5840
5841 DEFUN (ospf_redistribute_source_type_metric,
5842 ospf_redistribute_source_type_metric_routemap_cmd,
5843 "redistribute " QUAGGA_REDIST_STR_OSPFD
5844 " metric-type (1|2) metric <0-16777214> route-map WORD",
5845 REDIST_STR
5846 QUAGGA_REDIST_HELP_STR_OSPFD
5847 "OSPF exterior metric type for redistributed routes\n"
5848 "Set OSPF External Type 1 metrics\n"
5849 "Set OSPF External Type 2 metrics\n"
5850 "Metric for redistributed routes\n"
5851 "OSPF default metric\n"
5852 "Route map reference\n"
5853 "Pointer to route-map entries\n")
5854 {
5855 struct ospf *ospf = vty->index;
5856 int source;
5857 int type = -1;
5858 int metric = -1;
5859
5860 /* Get distribute source. */
5861 source = proto_redistnum(AFI_IP, argv[0]);
5862 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5863 return CMD_WARNING;
5864
5865 /* Get metric value. */
5866 if (argc >= 2)
5867 if (!str2metric_type (argv[1], &type))
5868 return CMD_WARNING;
5869
5870 /* Get metric type. */
5871 if (argc >= 3)
5872 if (!str2metric (argv[2], &metric))
5873 return CMD_WARNING;
5874
5875 if (argc == 4)
5876 ospf_routemap_set (ospf, source, argv[3]);
5877 else
5878 ospf_routemap_unset (ospf, source);
5879
5880 return ospf_redistribute_set (ospf, source, type, metric);
5881 }
5882
5883 ALIAS (ospf_redistribute_source_type_metric,
5884 ospf_redistribute_source_type_metric_cmd,
5885 "redistribute " QUAGGA_REDIST_STR_OSPFD
5886 " metric-type (1|2) metric <0-16777214>",
5887 REDIST_STR
5888 QUAGGA_REDIST_HELP_STR_OSPFD
5889 "OSPF exterior metric type for redistributed routes\n"
5890 "Set OSPF External Type 1 metrics\n"
5891 "Set OSPF External Type 2 metrics\n"
5892 "Metric for redistributed routes\n"
5893 "OSPF default metric\n")
5894
5895 ALIAS (ospf_redistribute_source_type_metric,
5896 ospf_redistribute_source_type_cmd,
5897 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5898 REDIST_STR
5899 QUAGGA_REDIST_HELP_STR_OSPFD
5900 "OSPF exterior metric type for redistributed routes\n"
5901 "Set OSPF External Type 1 metrics\n"
5902 "Set OSPF External Type 2 metrics\n")
5903
5904 ALIAS (ospf_redistribute_source_type_metric,
5905 ospf_redistribute_source_cmd,
5906 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5907 REDIST_STR
5908 QUAGGA_REDIST_HELP_STR_OSPFD)
5909
5910 DEFUN (ospf_redistribute_source_metric_routemap,
5911 ospf_redistribute_source_metric_routemap_cmd,
5912 "redistribute " QUAGGA_REDIST_STR_OSPFD
5913 " metric <0-16777214> route-map WORD",
5914 REDIST_STR
5915 QUAGGA_REDIST_HELP_STR_OSPFD
5916 "Metric for redistributed routes\n"
5917 "OSPF default metric\n"
5918 "Route map reference\n"
5919 "Pointer to route-map entries\n")
5920 {
5921 struct ospf *ospf = vty->index;
5922 int source;
5923 int metric = -1;
5924
5925 /* Get distribute source. */
5926 source = proto_redistnum(AFI_IP, argv[0]);
5927 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5928 return CMD_WARNING;
5929
5930 /* Get metric value. */
5931 if (argc >= 2)
5932 if (!str2metric (argv[1], &metric))
5933 return CMD_WARNING;
5934
5935 if (argc == 3)
5936 ospf_routemap_set (ospf, source, argv[2]);
5937 else
5938 ospf_routemap_unset (ospf, source);
5939
5940 return ospf_redistribute_set (ospf, source, -1, metric);
5941 }
5942
5943 DEFUN (ospf_redistribute_source_type_routemap,
5944 ospf_redistribute_source_type_routemap_cmd,
5945 "redistribute " QUAGGA_REDIST_STR_OSPFD
5946 " metric-type (1|2) route-map WORD",
5947 REDIST_STR
5948 QUAGGA_REDIST_HELP_STR_OSPFD
5949 "OSPF exterior metric type for redistributed routes\n"
5950 "Set OSPF External Type 1 metrics\n"
5951 "Set OSPF External Type 2 metrics\n"
5952 "Route map reference\n"
5953 "Pointer to route-map entries\n")
5954 {
5955 struct ospf *ospf = vty->index;
5956 int source;
5957 int type = -1;
5958
5959 /* Get distribute source. */
5960 source = proto_redistnum(AFI_IP, argv[0]);
5961 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5962 return CMD_WARNING;
5963
5964 /* Get metric value. */
5965 if (argc >= 2)
5966 if (!str2metric_type (argv[1], &type))
5967 return CMD_WARNING;
5968
5969 if (argc == 3)
5970 ospf_routemap_set (ospf, source, argv[2]);
5971 else
5972 ospf_routemap_unset (ospf, source);
5973
5974 return ospf_redistribute_set (ospf, source, type, -1);
5975 }
5976
5977 DEFUN (ospf_redistribute_source_routemap,
5978 ospf_redistribute_source_routemap_cmd,
5979 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5980 REDIST_STR
5981 QUAGGA_REDIST_HELP_STR_OSPFD
5982 "Route map reference\n"
5983 "Pointer to route-map entries\n")
5984 {
5985 struct ospf *ospf = vty->index;
5986 int source;
5987
5988 /* Get distribute source. */
5989 source = proto_redistnum(AFI_IP, argv[0]);
5990 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5991 return CMD_WARNING;
5992
5993 if (argc == 2)
5994 ospf_routemap_set (ospf, source, argv[1]);
5995 else
5996 ospf_routemap_unset (ospf, source);
5997
5998 return ospf_redistribute_set (ospf, source, -1, -1);
5999 }
6000
6001 DEFUN (no_ospf_redistribute_source,
6002 no_ospf_redistribute_source_cmd,
6003 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
6004 NO_STR
6005 REDIST_STR
6006 QUAGGA_REDIST_HELP_STR_OSPFD)
6007 {
6008 struct ospf *ospf = vty->index;
6009 int source;
6010
6011 source = proto_redistnum(AFI_IP, argv[0]);
6012 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
6013 return CMD_WARNING;
6014
6015 ospf_routemap_unset (ospf, source);
6016 return ospf_redistribute_unset (ospf, source);
6017 }
6018
6019 DEFUN (ospf_distribute_list_out,
6020 ospf_distribute_list_out_cmd,
6021 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
6022 "Filter networks in routing updates\n"
6023 "Access-list name\n"
6024 OUT_STR
6025 QUAGGA_REDIST_HELP_STR_OSPFD)
6026 {
6027 struct ospf *ospf = vty->index;
6028 int source;
6029
6030 /* Get distribute source. */
6031 source = proto_redistnum(AFI_IP, argv[0]);
6032 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
6033 return CMD_WARNING;
6034
6035 return ospf_distribute_list_out_set (ospf, source, argv[0]);
6036 }
6037
6038 DEFUN (no_ospf_distribute_list_out,
6039 no_ospf_distribute_list_out_cmd,
6040 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
6041 NO_STR
6042 "Filter networks in routing updates\n"
6043 "Access-list name\n"
6044 OUT_STR
6045 QUAGGA_REDIST_HELP_STR_OSPFD)
6046 {
6047 struct ospf *ospf = vty->index;
6048 int source;
6049
6050 source = proto_redistnum(AFI_IP, argv[0]);
6051 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
6052 return CMD_WARNING;
6053
6054 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
6055 }
6056
6057 /* Default information originate. */
6058 DEFUN (ospf_default_information_originate_metric_type_routemap,
6059 ospf_default_information_originate_metric_type_routemap_cmd,
6060 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
6061 "Control distribution of default information\n"
6062 "Distribute a default route\n"
6063 "OSPF default metric\n"
6064 "OSPF metric\n"
6065 "OSPF metric type for default routes\n"
6066 "Set OSPF External Type 1 metrics\n"
6067 "Set OSPF External Type 2 metrics\n"
6068 "Route map reference\n"
6069 "Pointer to route-map entries\n")
6070 {
6071 struct ospf *ospf = vty->index;
6072 int type = -1;
6073 int metric = -1;
6074
6075 /* Get metric value. */
6076 if (argc >= 1)
6077 if (!str2metric (argv[0], &metric))
6078 return CMD_WARNING;
6079
6080 /* Get metric type. */
6081 if (argc >= 2)
6082 if (!str2metric_type (argv[1], &type))
6083 return CMD_WARNING;
6084
6085 if (argc == 3)
6086 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6087 else
6088 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6089
6090 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6091 type, metric);
6092 }
6093
6094 ALIAS (ospf_default_information_originate_metric_type_routemap,
6095 ospf_default_information_originate_metric_type_cmd,
6096 "default-information originate metric <0-16777214> metric-type (1|2)",
6097 "Control distribution of default information\n"
6098 "Distribute a default route\n"
6099 "OSPF default metric\n"
6100 "OSPF metric\n"
6101 "OSPF metric type for default routes\n"
6102 "Set OSPF External Type 1 metrics\n"
6103 "Set OSPF External Type 2 metrics\n")
6104
6105 ALIAS (ospf_default_information_originate_metric_type_routemap,
6106 ospf_default_information_originate_metric_cmd,
6107 "default-information originate metric <0-16777214>",
6108 "Control distribution of default information\n"
6109 "Distribute a default route\n"
6110 "OSPF default metric\n"
6111 "OSPF metric\n")
6112
6113 ALIAS (ospf_default_information_originate_metric_type_routemap,
6114 ospf_default_information_originate_cmd,
6115 "default-information originate",
6116 "Control distribution of default information\n"
6117 "Distribute a default route\n")
6118
6119 /* Default information originate. */
6120 DEFUN (ospf_default_information_originate_metric_routemap,
6121 ospf_default_information_originate_metric_routemap_cmd,
6122 "default-information originate metric <0-16777214> route-map WORD",
6123 "Control distribution of default information\n"
6124 "Distribute a default route\n"
6125 "OSPF default metric\n"
6126 "OSPF metric\n"
6127 "Route map reference\n"
6128 "Pointer to route-map entries\n")
6129 {
6130 struct ospf *ospf = vty->index;
6131 int metric = -1;
6132
6133 /* Get metric value. */
6134 if (argc >= 1)
6135 if (!str2metric (argv[0], &metric))
6136 return CMD_WARNING;
6137
6138 if (argc == 2)
6139 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6140 else
6141 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6142
6143 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6144 -1, metric);
6145 }
6146
6147 /* Default information originate. */
6148 DEFUN (ospf_default_information_originate_routemap,
6149 ospf_default_information_originate_routemap_cmd,
6150 "default-information originate route-map WORD",
6151 "Control distribution of default information\n"
6152 "Distribute a default route\n"
6153 "Route map reference\n"
6154 "Pointer to route-map entries\n")
6155 {
6156 struct ospf *ospf = vty->index;
6157
6158 if (argc == 1)
6159 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6160 else
6161 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6162
6163 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
6164 }
6165
6166 DEFUN (ospf_default_information_originate_type_metric_routemap,
6167 ospf_default_information_originate_type_metric_routemap_cmd,
6168 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6169 "Control distribution of default information\n"
6170 "Distribute a default route\n"
6171 "OSPF metric type for default routes\n"
6172 "Set OSPF External Type 1 metrics\n"
6173 "Set OSPF External Type 2 metrics\n"
6174 "OSPF default metric\n"
6175 "OSPF metric\n"
6176 "Route map reference\n"
6177 "Pointer to route-map entries\n")
6178 {
6179 struct ospf *ospf = vty->index;
6180 int type = -1;
6181 int metric = -1;
6182
6183 /* Get metric type. */
6184 if (argc >= 1)
6185 if (!str2metric_type (argv[0], &type))
6186 return CMD_WARNING;
6187
6188 /* Get metric value. */
6189 if (argc >= 2)
6190 if (!str2metric (argv[1], &metric))
6191 return CMD_WARNING;
6192
6193 if (argc == 3)
6194 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6195 else
6196 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6197
6198 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6199 type, metric);
6200 }
6201
6202 ALIAS (ospf_default_information_originate_type_metric_routemap,
6203 ospf_default_information_originate_type_metric_cmd,
6204 "default-information originate metric-type (1|2) metric <0-16777214>",
6205 "Control distribution of default information\n"
6206 "Distribute a default route\n"
6207 "OSPF metric type for default routes\n"
6208 "Set OSPF External Type 1 metrics\n"
6209 "Set OSPF External Type 2 metrics\n"
6210 "OSPF default metric\n"
6211 "OSPF metric\n")
6212
6213 ALIAS (ospf_default_information_originate_type_metric_routemap,
6214 ospf_default_information_originate_type_cmd,
6215 "default-information originate metric-type (1|2)",
6216 "Control distribution of default information\n"
6217 "Distribute a default route\n"
6218 "OSPF metric type for default routes\n"
6219 "Set OSPF External Type 1 metrics\n"
6220 "Set OSPF External Type 2 metrics\n")
6221
6222 DEFUN (ospf_default_information_originate_type_routemap,
6223 ospf_default_information_originate_type_routemap_cmd,
6224 "default-information originate metric-type (1|2) route-map WORD",
6225 "Control distribution of default information\n"
6226 "Distribute a default route\n"
6227 "OSPF metric type for default routes\n"
6228 "Set OSPF External Type 1 metrics\n"
6229 "Set OSPF External Type 2 metrics\n"
6230 "Route map reference\n"
6231 "Pointer to route-map entries\n")
6232 {
6233 struct ospf *ospf = vty->index;
6234 int type = -1;
6235
6236 /* Get metric type. */
6237 if (argc >= 1)
6238 if (!str2metric_type (argv[0], &type))
6239 return CMD_WARNING;
6240
6241 if (argc == 2)
6242 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6243 else
6244 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6245
6246 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6247 type, -1);
6248 }
6249
6250 DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6251 ospf_default_information_originate_always_metric_type_routemap_cmd,
6252 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6253 "Control distribution of default information\n"
6254 "Distribute a default route\n"
6255 "Always advertise default route\n"
6256 "OSPF default metric\n"
6257 "OSPF metric\n"
6258 "OSPF metric type for default routes\n"
6259 "Set OSPF External Type 1 metrics\n"
6260 "Set OSPF External Type 2 metrics\n"
6261 "Route map reference\n"
6262 "Pointer to route-map entries\n")
6263 {
6264 struct ospf *ospf = vty->index;
6265 int type = -1;
6266 int metric = -1;
6267
6268 /* Get metric value. */
6269 if (argc >= 1)
6270 if (!str2metric (argv[0], &metric))
6271 return CMD_WARNING;
6272
6273 /* Get metric type. */
6274 if (argc >= 2)
6275 if (!str2metric_type (argv[1], &type))
6276 return CMD_WARNING;
6277
6278 if (argc == 3)
6279 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6280 else
6281 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6282
6283 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6284 type, metric);
6285 }
6286
6287 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6288 ospf_default_information_originate_always_metric_type_cmd,
6289 "default-information originate always metric <0-16777214> metric-type (1|2)",
6290 "Control distribution of default information\n"
6291 "Distribute a default route\n"
6292 "Always advertise default route\n"
6293 "OSPF default metric\n"
6294 "OSPF metric\n"
6295 "OSPF metric type for default routes\n"
6296 "Set OSPF External Type 1 metrics\n"
6297 "Set OSPF External Type 2 metrics\n")
6298
6299 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6300 ospf_default_information_originate_always_metric_cmd,
6301 "default-information originate always metric <0-16777214>",
6302 "Control distribution of default information\n"
6303 "Distribute a default route\n"
6304 "Always advertise default route\n"
6305 "OSPF default metric\n"
6306 "OSPF metric\n"
6307 "OSPF metric type for default routes\n")
6308
6309 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6310 ospf_default_information_originate_always_cmd,
6311 "default-information originate always",
6312 "Control distribution of default information\n"
6313 "Distribute a default route\n"
6314 "Always advertise default route\n")
6315
6316 DEFUN (ospf_default_information_originate_always_metric_routemap,
6317 ospf_default_information_originate_always_metric_routemap_cmd,
6318 "default-information originate always metric <0-16777214> route-map WORD",
6319 "Control distribution of default information\n"
6320 "Distribute a default route\n"
6321 "Always advertise default route\n"
6322 "OSPF default metric\n"
6323 "OSPF metric\n"
6324 "Route map reference\n"
6325 "Pointer to route-map entries\n")
6326 {
6327 struct ospf *ospf = vty->index;
6328 int metric = -1;
6329
6330 /* Get metric value. */
6331 if (argc >= 1)
6332 if (!str2metric (argv[0], &metric))
6333 return CMD_WARNING;
6334
6335 if (argc == 2)
6336 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6337 else
6338 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6339
6340 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6341 -1, metric);
6342 }
6343
6344 DEFUN (ospf_default_information_originate_always_routemap,
6345 ospf_default_information_originate_always_routemap_cmd,
6346 "default-information originate always route-map WORD",
6347 "Control distribution of default information\n"
6348 "Distribute a default route\n"
6349 "Always advertise default route\n"
6350 "Route map reference\n"
6351 "Pointer to route-map entries\n")
6352 {
6353 struct ospf *ospf = vty->index;
6354
6355 if (argc == 1)
6356 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6357 else
6358 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6359
6360 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
6361 }
6362
6363 DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6364 ospf_default_information_originate_always_type_metric_routemap_cmd,
6365 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6366 "Control distribution of default information\n"
6367 "Distribute a default route\n"
6368 "Always advertise default route\n"
6369 "OSPF metric type for default routes\n"
6370 "Set OSPF External Type 1 metrics\n"
6371 "Set OSPF External Type 2 metrics\n"
6372 "OSPF default metric\n"
6373 "OSPF metric\n"
6374 "Route map reference\n"
6375 "Pointer to route-map entries\n")
6376 {
6377 struct ospf *ospf = vty->index;
6378 int type = -1;
6379 int metric = -1;
6380
6381 /* Get metric type. */
6382 if (argc >= 1)
6383 if (!str2metric_type (argv[0], &type))
6384 return CMD_WARNING;
6385
6386 /* Get metric value. */
6387 if (argc >= 2)
6388 if (!str2metric (argv[1], &metric))
6389 return CMD_WARNING;
6390
6391 if (argc == 3)
6392 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6393 else
6394 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6395
6396 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6397 type, metric);
6398 }
6399
6400 ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6401 ospf_default_information_originate_always_type_metric_cmd,
6402 "default-information originate always metric-type (1|2) metric <0-16777214>",
6403 "Control distribution of default information\n"
6404 "Distribute a default route\n"
6405 "Always advertise default route\n"
6406 "OSPF metric type for default routes\n"
6407 "Set OSPF External Type 1 metrics\n"
6408 "Set OSPF External Type 2 metrics\n"
6409 "OSPF default metric\n"
6410 "OSPF metric\n")
6411
6412 ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6413 ospf_default_information_originate_always_type_cmd,
6414 "default-information originate always metric-type (1|2)",
6415 "Control distribution of default information\n"
6416 "Distribute a default route\n"
6417 "Always advertise default route\n"
6418 "OSPF metric type for default routes\n"
6419 "Set OSPF External Type 1 metrics\n"
6420 "Set OSPF External Type 2 metrics\n")
6421
6422 DEFUN (ospf_default_information_originate_always_type_routemap,
6423 ospf_default_information_originate_always_type_routemap_cmd,
6424 "default-information originate always metric-type (1|2) route-map WORD",
6425 "Control distribution of default information\n"
6426 "Distribute a default route\n"
6427 "Always advertise default route\n"
6428 "OSPF metric type for default routes\n"
6429 "Set OSPF External Type 1 metrics\n"
6430 "Set OSPF External Type 2 metrics\n"
6431 "Route map reference\n"
6432 "Pointer to route-map entries\n")
6433 {
6434 struct ospf *ospf = vty->index;
6435 int type = -1;
6436
6437 /* Get metric type. */
6438 if (argc >= 1)
6439 if (!str2metric_type (argv[0], &type))
6440 return CMD_WARNING;
6441
6442 if (argc == 2)
6443 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6444 else
6445 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6446
6447 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6448 type, -1);
6449 }
6450
6451 DEFUN (no_ospf_default_information_originate,
6452 no_ospf_default_information_originate_cmd,
6453 "no default-information originate",
6454 NO_STR
6455 "Control distribution of default information\n"
6456 "Distribute a default route\n")
6457 {
6458 struct ospf *ospf = vty->index;
6459 struct prefix_ipv4 p;
6460
6461 p.family = AF_INET;
6462 p.prefix.s_addr = 0;
6463 p.prefixlen = 0;
6464
6465 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
6466
6467 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6468 ospf_external_info_delete (DEFAULT_ROUTE, p);
6469 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6470 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6471 }
6472
6473 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6474 return ospf_redistribute_default_unset (ospf);
6475 }
6476
6477 DEFUN (ospf_default_metric,
6478 ospf_default_metric_cmd,
6479 "default-metric <0-16777214>",
6480 "Set metric of redistributed routes\n"
6481 "Default metric\n")
6482 {
6483 struct ospf *ospf = vty->index;
6484 int metric = -1;
6485
6486 if (!str2metric (argv[0], &metric))
6487 return CMD_WARNING;
6488
6489 ospf->default_metric = metric;
6490
6491 return CMD_SUCCESS;
6492 }
6493
6494 DEFUN (no_ospf_default_metric,
6495 no_ospf_default_metric_cmd,
6496 "no default-metric",
6497 NO_STR
6498 "Set metric of redistributed routes\n")
6499 {
6500 struct ospf *ospf = vty->index;
6501
6502 ospf->default_metric = -1;
6503
6504 return CMD_SUCCESS;
6505 }
6506
6507 ALIAS (no_ospf_default_metric,
6508 no_ospf_default_metric_val_cmd,
6509 "no default-metric <0-16777214>",
6510 NO_STR
6511 "Set metric of redistributed routes\n"
6512 "Default metric\n")
6513
6514 DEFUN (ospf_distance,
6515 ospf_distance_cmd,
6516 "distance <1-255>",
6517 "Define an administrative distance\n"
6518 "OSPF Administrative distance\n")
6519 {
6520 struct ospf *ospf = vty->index;
6521
6522 ospf->distance_all = atoi (argv[0]);
6523
6524 return CMD_SUCCESS;
6525 }
6526
6527 DEFUN (no_ospf_distance,
6528 no_ospf_distance_cmd,
6529 "no distance <1-255>",
6530 NO_STR
6531 "Define an administrative distance\n"
6532 "OSPF Administrative distance\n")
6533 {
6534 struct ospf *ospf = vty->index;
6535
6536 ospf->distance_all = 0;
6537
6538 return CMD_SUCCESS;
6539 }
6540
6541 DEFUN (no_ospf_distance_ospf,
6542 no_ospf_distance_ospf_cmd,
6543 "no distance ospf",
6544 NO_STR
6545 "Define an administrative distance\n"
6546 "OSPF Administrative distance\n"
6547 "OSPF Distance\n")
6548 {
6549 struct ospf *ospf = vty->index;
6550
6551 ospf->distance_intra = 0;
6552 ospf->distance_inter = 0;
6553 ospf->distance_external = 0;
6554
6555 return CMD_SUCCESS;
6556 }
6557
6558 DEFUN (ospf_distance_ospf_intra,
6559 ospf_distance_ospf_intra_cmd,
6560 "distance ospf intra-area <1-255>",
6561 "Define an administrative distance\n"
6562 "OSPF Administrative distance\n"
6563 "Intra-area routes\n"
6564 "Distance for intra-area routes\n")
6565 {
6566 struct ospf *ospf = vty->index;
6567
6568 ospf->distance_intra = atoi (argv[0]);
6569
6570 return CMD_SUCCESS;
6571 }
6572
6573 DEFUN (ospf_distance_ospf_intra_inter,
6574 ospf_distance_ospf_intra_inter_cmd,
6575 "distance ospf intra-area <1-255> inter-area <1-255>",
6576 "Define an administrative distance\n"
6577 "OSPF Administrative distance\n"
6578 "Intra-area routes\n"
6579 "Distance for intra-area routes\n"
6580 "Inter-area routes\n"
6581 "Distance for inter-area routes\n")
6582 {
6583 struct ospf *ospf = vty->index;
6584
6585 ospf->distance_intra = atoi (argv[0]);
6586 ospf->distance_inter = atoi (argv[1]);
6587
6588 return CMD_SUCCESS;
6589 }
6590
6591 DEFUN (ospf_distance_ospf_intra_external,
6592 ospf_distance_ospf_intra_external_cmd,
6593 "distance ospf intra-area <1-255> external <1-255>",
6594 "Define an administrative distance\n"
6595 "OSPF Administrative distance\n"
6596 "Intra-area routes\n"
6597 "Distance for intra-area routes\n"
6598 "External routes\n"
6599 "Distance for external routes\n")
6600 {
6601 struct ospf *ospf = vty->index;
6602
6603 ospf->distance_intra = atoi (argv[0]);
6604 ospf->distance_external = atoi (argv[1]);
6605
6606 return CMD_SUCCESS;
6607 }
6608
6609 DEFUN (ospf_distance_ospf_intra_inter_external,
6610 ospf_distance_ospf_intra_inter_external_cmd,
6611 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6612 "Define an administrative distance\n"
6613 "OSPF Administrative distance\n"
6614 "Intra-area routes\n"
6615 "Distance for intra-area routes\n"
6616 "Inter-area routes\n"
6617 "Distance for inter-area routes\n"
6618 "External routes\n"
6619 "Distance for external routes\n")
6620 {
6621 struct ospf *ospf = vty->index;
6622
6623 ospf->distance_intra = atoi (argv[0]);
6624 ospf->distance_inter = atoi (argv[1]);
6625 ospf->distance_external = atoi (argv[2]);
6626
6627 return CMD_SUCCESS;
6628 }
6629
6630 DEFUN (ospf_distance_ospf_intra_external_inter,
6631 ospf_distance_ospf_intra_external_inter_cmd,
6632 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6633 "Define an administrative distance\n"
6634 "OSPF Administrative distance\n"
6635 "Intra-area routes\n"
6636 "Distance for intra-area routes\n"
6637 "External routes\n"
6638 "Distance for external routes\n"
6639 "Inter-area routes\n"
6640 "Distance for inter-area routes\n")
6641 {
6642 struct ospf *ospf = vty->index;
6643
6644 ospf->distance_intra = atoi (argv[0]);
6645 ospf->distance_external = atoi (argv[1]);
6646 ospf->distance_inter = atoi (argv[2]);
6647
6648 return CMD_SUCCESS;
6649 }
6650
6651 DEFUN (ospf_distance_ospf_inter,
6652 ospf_distance_ospf_inter_cmd,
6653 "distance ospf inter-area <1-255>",
6654 "Define an administrative distance\n"
6655 "OSPF Administrative distance\n"
6656 "Inter-area routes\n"
6657 "Distance for inter-area routes\n")
6658 {
6659 struct ospf *ospf = vty->index;
6660
6661 ospf->distance_inter = atoi (argv[0]);
6662
6663 return CMD_SUCCESS;
6664 }
6665
6666 DEFUN (ospf_distance_ospf_inter_intra,
6667 ospf_distance_ospf_inter_intra_cmd,
6668 "distance ospf inter-area <1-255> intra-area <1-255>",
6669 "Define an administrative distance\n"
6670 "OSPF Administrative distance\n"
6671 "Inter-area routes\n"
6672 "Distance for inter-area routes\n"
6673 "Intra-area routes\n"
6674 "Distance for intra-area routes\n")
6675 {
6676 struct ospf *ospf = vty->index;
6677
6678 ospf->distance_inter = atoi (argv[0]);
6679 ospf->distance_intra = atoi (argv[1]);
6680
6681 return CMD_SUCCESS;
6682 }
6683
6684 DEFUN (ospf_distance_ospf_inter_external,
6685 ospf_distance_ospf_inter_external_cmd,
6686 "distance ospf inter-area <1-255> external <1-255>",
6687 "Define an administrative distance\n"
6688 "OSPF Administrative distance\n"
6689 "Inter-area routes\n"
6690 "Distance for inter-area routes\n"
6691 "External routes\n"
6692 "Distance for external routes\n")
6693 {
6694 struct ospf *ospf = vty->index;
6695
6696 ospf->distance_inter = atoi (argv[0]);
6697 ospf->distance_external = atoi (argv[1]);
6698
6699 return CMD_SUCCESS;
6700 }
6701
6702 DEFUN (ospf_distance_ospf_inter_intra_external,
6703 ospf_distance_ospf_inter_intra_external_cmd,
6704 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6705 "Define an administrative distance\n"
6706 "OSPF Administrative distance\n"
6707 "Inter-area routes\n"
6708 "Distance for inter-area routes\n"
6709 "Intra-area routes\n"
6710 "Distance for intra-area routes\n"
6711 "External routes\n"
6712 "Distance for external routes\n")
6713 {
6714 struct ospf *ospf = vty->index;
6715
6716 ospf->distance_inter = atoi (argv[0]);
6717 ospf->distance_intra = atoi (argv[1]);
6718 ospf->distance_external = atoi (argv[2]);
6719
6720 return CMD_SUCCESS;
6721 }
6722
6723 DEFUN (ospf_distance_ospf_inter_external_intra,
6724 ospf_distance_ospf_inter_external_intra_cmd,
6725 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6726 "Define an administrative distance\n"
6727 "OSPF Administrative distance\n"
6728 "Inter-area routes\n"
6729 "Distance for inter-area routes\n"
6730 "External routes\n"
6731 "Distance for external routes\n"
6732 "Intra-area routes\n"
6733 "Distance for intra-area routes\n")
6734 {
6735 struct ospf *ospf = vty->index;
6736
6737 ospf->distance_inter = atoi (argv[0]);
6738 ospf->distance_external = atoi (argv[1]);
6739 ospf->distance_intra = atoi (argv[2]);
6740
6741 return CMD_SUCCESS;
6742 }
6743
6744 DEFUN (ospf_distance_ospf_external,
6745 ospf_distance_ospf_external_cmd,
6746 "distance ospf external <1-255>",
6747 "Define an administrative distance\n"
6748 "OSPF Administrative distance\n"
6749 "External routes\n"
6750 "Distance for external routes\n")
6751 {
6752 struct ospf *ospf = vty->index;
6753
6754 ospf->distance_external = atoi (argv[0]);
6755
6756 return CMD_SUCCESS;
6757 }
6758
6759 DEFUN (ospf_distance_ospf_external_intra,
6760 ospf_distance_ospf_external_intra_cmd,
6761 "distance ospf external <1-255> intra-area <1-255>",
6762 "Define an administrative distance\n"
6763 "OSPF Administrative distance\n"
6764 "External routes\n"
6765 "Distance for external routes\n"
6766 "Intra-area routes\n"
6767 "Distance for intra-area routes\n")
6768 {
6769 struct ospf *ospf = vty->index;
6770
6771 ospf->distance_external = atoi (argv[0]);
6772 ospf->distance_intra = atoi (argv[1]);
6773
6774 return CMD_SUCCESS;
6775 }
6776
6777 DEFUN (ospf_distance_ospf_external_inter,
6778 ospf_distance_ospf_external_inter_cmd,
6779 "distance ospf external <1-255> inter-area <1-255>",
6780 "Define an administrative distance\n"
6781 "OSPF Administrative distance\n"
6782 "External routes\n"
6783 "Distance for external routes\n"
6784 "Inter-area routes\n"
6785 "Distance for inter-area routes\n")
6786 {
6787 struct ospf *ospf = vty->index;
6788
6789 ospf->distance_external = atoi (argv[0]);
6790 ospf->distance_inter = atoi (argv[1]);
6791
6792 return CMD_SUCCESS;
6793 }
6794
6795 DEFUN (ospf_distance_ospf_external_intra_inter,
6796 ospf_distance_ospf_external_intra_inter_cmd,
6797 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6798 "Define an administrative distance\n"
6799 "OSPF Administrative distance\n"
6800 "External routes\n"
6801 "Distance for external routes\n"
6802 "Intra-area routes\n"
6803 "Distance for intra-area routes\n"
6804 "Inter-area routes\n"
6805 "Distance for inter-area routes\n")
6806 {
6807 struct ospf *ospf = vty->index;
6808
6809 ospf->distance_external = atoi (argv[0]);
6810 ospf->distance_intra = atoi (argv[1]);
6811 ospf->distance_inter = atoi (argv[2]);
6812
6813 return CMD_SUCCESS;
6814 }
6815
6816 DEFUN (ospf_distance_ospf_external_inter_intra,
6817 ospf_distance_ospf_external_inter_intra_cmd,
6818 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6819 "Define an administrative distance\n"
6820 "OSPF Administrative distance\n"
6821 "External routes\n"
6822 "Distance for external routes\n"
6823 "Inter-area routes\n"
6824 "Distance for inter-area routes\n"
6825 "Intra-area routes\n"
6826 "Distance for intra-area routes\n")
6827 {
6828 struct ospf *ospf = vty->index;
6829
6830 ospf->distance_external = atoi (argv[0]);
6831 ospf->distance_inter = atoi (argv[1]);
6832 ospf->distance_intra = atoi (argv[2]);
6833
6834 return CMD_SUCCESS;
6835 }
6836
6837 DEFUN (ospf_distance_source,
6838 ospf_distance_source_cmd,
6839 "distance <1-255> A.B.C.D/M",
6840 "Administrative distance\n"
6841 "Distance value\n"
6842 "IP source prefix\n")
6843 {
6844 struct ospf *ospf = vty->index;
6845
6846 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
6847
6848 return CMD_SUCCESS;
6849 }
6850
6851 DEFUN (no_ospf_distance_source,
6852 no_ospf_distance_source_cmd,
6853 "no distance <1-255> A.B.C.D/M",
6854 NO_STR
6855 "Administrative distance\n"
6856 "Distance value\n"
6857 "IP source prefix\n")
6858 {
6859 struct ospf *ospf = vty->index;
6860
6861 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6862
6863 return CMD_SUCCESS;
6864 }
6865
6866 DEFUN (ospf_distance_source_access_list,
6867 ospf_distance_source_access_list_cmd,
6868 "distance <1-255> A.B.C.D/M WORD",
6869 "Administrative distance\n"
6870 "Distance value\n"
6871 "IP source prefix\n"
6872 "Access list name\n")
6873 {
6874 struct ospf *ospf = vty->index;
6875
6876 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6877
6878 return CMD_SUCCESS;
6879 }
6880
6881 DEFUN (no_ospf_distance_source_access_list,
6882 no_ospf_distance_source_access_list_cmd,
6883 "no distance <1-255> A.B.C.D/M WORD",
6884 NO_STR
6885 "Administrative distance\n"
6886 "Distance value\n"
6887 "IP source prefix\n"
6888 "Access list name\n")
6889 {
6890 struct ospf *ospf = vty->index;
6891
6892 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6893
6894 return CMD_SUCCESS;
6895 }
6896
6897 DEFUN (ip_ospf_mtu_ignore,
6898 ip_ospf_mtu_ignore_addr_cmd,
6899 "ip ospf mtu-ignore A.B.C.D",
6900 "IP Information\n"
6901 "OSPF interface commands\n"
6902 "Disable mtu mismatch detection\n"
6903 "Address of interface")
6904 {
6905 struct interface *ifp = vty->index;
6906 struct in_addr addr;
6907 int ret;
6908
6909 struct ospf_if_params *params;
6910 params = IF_DEF_PARAMS (ifp);
6911
6912 if (argc == 1)
6913 {
6914 ret = inet_aton(argv[0], &addr);
6915 if (!ret)
6916 {
6917 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6918 VTY_NEWLINE);
6919 return CMD_WARNING;
6920 }
6921 params = ospf_get_if_params (ifp, addr);
6922 ospf_if_update_params (ifp, addr);
6923 }
6924 params->mtu_ignore = 1;
6925 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6926 SET_IF_PARAM (params, mtu_ignore);
6927 else
6928 {
6929 UNSET_IF_PARAM (params, mtu_ignore);
6930 if (params != IF_DEF_PARAMS (ifp))
6931 {
6932 ospf_free_if_params (ifp, addr);
6933 ospf_if_update_params (ifp, addr);
6934 }
6935 }
6936 return CMD_SUCCESS;
6937 }
6938
6939 ALIAS (ip_ospf_mtu_ignore,
6940 ip_ospf_mtu_ignore_cmd,
6941 "ip ospf mtu-ignore",
6942 "IP Information\n"
6943 "OSPF interface commands\n"
6944 "Disable mtu mismatch detection\n")
6945
6946
6947 DEFUN (no_ip_ospf_mtu_ignore,
6948 no_ip_ospf_mtu_ignore_addr_cmd,
6949 "no ip ospf mtu-ignore A.B.C.D",
6950 "IP Information\n"
6951 "OSPF interface commands\n"
6952 "Disable mtu mismatch detection\n"
6953 "Address of interface")
6954 {
6955 struct interface *ifp = vty->index;
6956 struct in_addr addr;
6957 int ret;
6958
6959 struct ospf_if_params *params;
6960 params = IF_DEF_PARAMS (ifp);
6961
6962 if (argc == 1)
6963 {
6964 ret = inet_aton(argv[0], &addr);
6965 if (!ret)
6966 {
6967 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6968 VTY_NEWLINE);
6969 return CMD_WARNING;
6970 }
6971 params = ospf_get_if_params (ifp, addr);
6972 ospf_if_update_params (ifp, addr);
6973 }
6974 params->mtu_ignore = 0;
6975 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6976 SET_IF_PARAM (params, mtu_ignore);
6977 else
6978 {
6979 UNSET_IF_PARAM (params, mtu_ignore);
6980 if (params != IF_DEF_PARAMS (ifp))
6981 {
6982 ospf_free_if_params (ifp, addr);
6983 ospf_if_update_params (ifp, addr);
6984 }
6985 }
6986 return CMD_SUCCESS;
6987 }
6988
6989 ALIAS (no_ip_ospf_mtu_ignore,
6990 no_ip_ospf_mtu_ignore_cmd,
6991 "no ip ospf mtu-ignore",
6992 "IP Information\n"
6993 "OSPF interface commands\n"
6994 "Disable mtu mismatch detection\n")
6995 \f
6996 DEFUN (ospf_max_metric_router_lsa_admin,
6997 ospf_max_metric_router_lsa_admin_cmd,
6998 "max-metric router-lsa administrative",
6999 "OSPF maximum / infinite-distance metric\n"
7000 "Advertise own Router-LSA with infinite distance (stub router)\n"
7001 "Administratively applied, for an indefinite period\n")
7002 {
7003 struct listnode *ln;
7004 struct ospf_area *area;
7005 struct ospf *ospf = vty->index;
7006
7007 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7008 {
7009 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7010
7011 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
7012 ospf_router_lsa_timer_add (area);
7013 }
7014 return CMD_SUCCESS;
7015 }
7016
7017 DEFUN (no_ospf_max_metric_router_lsa_admin,
7018 no_ospf_max_metric_router_lsa_admin_cmd,
7019 "no max-metric router-lsa administrative",
7020 NO_STR
7021 "OSPF maximum / infinite-distance metric\n"
7022 "Advertise own Router-LSA with infinite distance (stub router)\n"
7023 "Administratively applied, for an indefinite period\n")
7024 {
7025 struct listnode *ln;
7026 struct ospf_area *area;
7027 struct ospf *ospf = vty->index;
7028
7029 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7030 {
7031 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7032
7033 /* Don't trample on the start-up stub timer */
7034 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
7035 && !area->t_stub_router)
7036 {
7037 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
7038 ospf_router_lsa_timer_add (area);
7039 }
7040 }
7041 return CMD_SUCCESS;
7042 }
7043
7044 DEFUN (ospf_max_metric_router_lsa_startup,
7045 ospf_max_metric_router_lsa_startup_cmd,
7046 "max-metric router-lsa on-startup <5-86400>",
7047 "OSPF maximum / infinite-distance metric\n"
7048 "Advertise own Router-LSA with infinite distance (stub router)\n"
7049 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7050 "Time (seconds) to advertise self as stub-router\n")
7051 {
7052 unsigned int seconds;
7053 struct ospf *ospf = vty->index;
7054
7055 if (argc != 1)
7056 {
7057 vty_out (vty, "%% Must supply stub-router period");
7058 return CMD_WARNING;
7059 }
7060
7061 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
7062
7063 ospf->stub_router_startup_time = seconds;
7064
7065 return CMD_SUCCESS;
7066 }
7067
7068 DEFUN (no_ospf_max_metric_router_lsa_startup,
7069 no_ospf_max_metric_router_lsa_startup_cmd,
7070 "no max-metric router-lsa on-startup",
7071 NO_STR
7072 "OSPF maximum / infinite-distance metric\n"
7073 "Advertise own Router-LSA with infinite distance (stub router)\n"
7074 "Automatically advertise stub Router-LSA on startup of OSPF\n")
7075 {
7076 struct listnode *ln;
7077 struct ospf_area *area;
7078 struct ospf *ospf = vty->index;
7079
7080 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7081
7082 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7083 {
7084 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
7085 OSPF_TIMER_OFF (area->t_stub_router);
7086
7087 /* Don't trample on admin stub routed */
7088 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7089 {
7090 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
7091 ospf_router_lsa_timer_add (area);
7092 }
7093 }
7094 return CMD_SUCCESS;
7095 }
7096
7097 DEFUN (ospf_max_metric_router_lsa_shutdown,
7098 ospf_max_metric_router_lsa_shutdown_cmd,
7099 "max-metric router-lsa on-shutdown <5-86400>",
7100 "OSPF maximum / infinite-distance metric\n"
7101 "Advertise own Router-LSA with infinite distance (stub router)\n"
7102 "Advertise stub-router prior to full shutdown of OSPF\n"
7103 "Time (seconds) to wait till full shutdown\n")
7104 {
7105 unsigned int seconds;
7106 struct ospf *ospf = vty->index;
7107
7108 if (argc != 1)
7109 {
7110 vty_out (vty, "%% Must supply stub-router shutdown period");
7111 return CMD_WARNING;
7112 }
7113
7114 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
7115
7116 ospf->stub_router_shutdown_time = seconds;
7117
7118 return CMD_SUCCESS;
7119 }
7120
7121 DEFUN (no_ospf_max_metric_router_lsa_shutdown,
7122 no_ospf_max_metric_router_lsa_shutdown_cmd,
7123 "no max-metric router-lsa on-shutdown",
7124 NO_STR
7125 "OSPF maximum / infinite-distance metric\n"
7126 "Advertise own Router-LSA with infinite distance (stub router)\n"
7127 "Advertise stub-router prior to full shutdown of OSPF\n")
7128 {
7129 struct ospf *ospf = vty->index;
7130
7131 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7132
7133 return CMD_SUCCESS;
7134 }
7135
7136 static void
7137 config_write_stub_router (struct vty *vty, struct ospf *ospf)
7138 {
7139 struct listnode *ln;
7140 struct ospf_area *area;
7141
7142 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7143 vty_out (vty, " max-metric router-lsa on-startup %u%s",
7144 ospf->stub_router_startup_time, VTY_NEWLINE);
7145 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7146 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
7147 ospf->stub_router_shutdown_time, VTY_NEWLINE);
7148 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7149 {
7150 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7151 {
7152 vty_out (vty, " max-metric router-lsa administrative%s",
7153 VTY_NEWLINE);
7154 break;
7155 }
7156 }
7157 return;
7158 }
7159 \f
7160 static void
7161 show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7162 {
7163 struct route_node *rn;
7164 struct ospf_route *or;
7165 struct listnode *pnode, *pnnode;
7166 struct ospf_path *path;
7167
7168 vty_out (vty, "============ OSPF network routing table ============%s",
7169 VTY_NEWLINE);
7170
7171 for (rn = route_top (rt); rn; rn = route_next (rn))
7172 if ((or = rn->info) != NULL)
7173 {
7174 char buf1[19];
7175 snprintf (buf1, 19, "%s/%d",
7176 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7177
7178 switch (or->path_type)
7179 {
7180 case OSPF_PATH_INTER_AREA:
7181 if (or->type == OSPF_DESTINATION_NETWORK)
7182 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7183 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7184 else if (or->type == OSPF_DESTINATION_DISCARD)
7185 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7186 break;
7187 case OSPF_PATH_INTRA_AREA:
7188 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7189 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7190 break;
7191 default:
7192 break;
7193 }
7194
7195 if (or->type == OSPF_DESTINATION_NETWORK)
7196 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
7197 {
7198 if (if_lookup_by_index(path->ifindex))
7199 {
7200 if (path->nexthop.s_addr == 0)
7201 vty_out (vty, "%24s directly attached to %s%s",
7202 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
7203 else
7204 vty_out (vty, "%24s via %s, %s%s", "",
7205 inet_ntoa (path->nexthop),
7206 ifindex2ifname (path->ifindex), VTY_NEWLINE);
7207 }
7208 }
7209 }
7210 vty_out (vty, "%s", VTY_NEWLINE);
7211 }
7212
7213 static void
7214 show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7215 {
7216 struct route_node *rn;
7217 struct ospf_route *or;
7218 struct listnode *pnode;
7219 struct listnode *node;
7220 struct ospf_path *path;
7221
7222 vty_out (vty, "============ OSPF router routing table =============%s",
7223 VTY_NEWLINE);
7224 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7225 if (rn->info)
7226 {
7227 int flag = 0;
7228
7229 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7230
7231 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7232 {
7233 if (flag++)
7234 vty_out (vty, "%24s", "");
7235
7236 /* Show path. */
7237 vty_out (vty, "%s [%d] area: %s",
7238 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7239 or->cost, inet_ntoa (or->u.std.area_id));
7240 /* Show flags. */
7241 vty_out (vty, "%s%s%s",
7242 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7243 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7244 VTY_NEWLINE);
7245
7246 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7247 {
7248 if (if_lookup_by_index(path->ifindex))
7249 {
7250 if (path->nexthop.s_addr == 0)
7251 vty_out (vty, "%24s directly attached to %s%s",
7252 "", ifindex2ifname (path->ifindex),
7253 VTY_NEWLINE);
7254 else
7255 vty_out (vty, "%24s via %s, %s%s", "",
7256 inet_ntoa (path->nexthop),
7257 ifindex2ifname (path->ifindex),
7258 VTY_NEWLINE);
7259 }
7260 }
7261 }
7262 }
7263 vty_out (vty, "%s", VTY_NEWLINE);
7264 }
7265
7266 static void
7267 show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7268 {
7269 struct route_node *rn;
7270 struct ospf_route *er;
7271 struct listnode *pnode, *pnnode;
7272 struct ospf_path *path;
7273
7274 vty_out (vty, "============ OSPF external routing table ===========%s",
7275 VTY_NEWLINE);
7276 for (rn = route_top (rt); rn; rn = route_next (rn))
7277 if ((er = rn->info) != NULL)
7278 {
7279 char buf1[19];
7280 snprintf (buf1, 19, "%s/%d",
7281 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7282
7283 switch (er->path_type)
7284 {
7285 case OSPF_PATH_TYPE1_EXTERNAL:
7286 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7287 er->cost, er->u.ext.tag, VTY_NEWLINE);
7288 break;
7289 case OSPF_PATH_TYPE2_EXTERNAL:
7290 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7291 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7292 break;
7293 }
7294
7295 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
7296 {
7297 if (if_lookup_by_index(path->ifindex))
7298 {
7299 if (path->nexthop.s_addr == 0)
7300 vty_out (vty, "%24s directly attached to %s%s",
7301 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
7302 else
7303 vty_out (vty, "%24s via %s, %s%s", "",
7304 inet_ntoa (path->nexthop),
7305 ifindex2ifname (path->ifindex),
7306 VTY_NEWLINE);
7307 }
7308 }
7309 }
7310 vty_out (vty, "%s", VTY_NEWLINE);
7311 }
7312
7313 DEFUN (show_ip_ospf_border_routers,
7314 show_ip_ospf_border_routers_cmd,
7315 "show ip ospf border-routers",
7316 SHOW_STR
7317 IP_STR
7318 "show all the ABR's and ASBR's\n"
7319 "for this area\n")
7320 {
7321 struct ospf *ospf;
7322
7323 if ((ospf = ospf_lookup ()) == NULL)
7324 {
7325 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
7326 return CMD_SUCCESS;
7327 }
7328
7329 if (ospf->new_table == NULL)
7330 {
7331 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7332 return CMD_SUCCESS;
7333 }
7334
7335 /* Show Network routes.
7336 show_ip_ospf_route_network (vty, ospf->new_table); */
7337
7338 /* Show Router routes. */
7339 show_ip_ospf_route_router (vty, ospf->new_rtrs);
7340
7341 return CMD_SUCCESS;
7342 }
7343
7344 DEFUN (show_ip_ospf_route,
7345 show_ip_ospf_route_cmd,
7346 "show ip ospf route",
7347 SHOW_STR
7348 IP_STR
7349 "OSPF information\n"
7350 "OSPF routing table\n")
7351 {
7352 struct ospf *ospf;
7353
7354 if ((ospf = ospf_lookup ()) == NULL)
7355 {
7356 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
7357 return CMD_SUCCESS;
7358 }
7359
7360 if (ospf->new_table == NULL)
7361 {
7362 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7363 return CMD_SUCCESS;
7364 }
7365
7366 /* Show Network routes. */
7367 show_ip_ospf_route_network (vty, ospf->new_table);
7368
7369 /* Show Router routes. */
7370 show_ip_ospf_route_router (vty, ospf->new_rtrs);
7371
7372 /* Show AS External routes. */
7373 show_ip_ospf_route_external (vty, ospf->old_external_route);
7374
7375 return CMD_SUCCESS;
7376 }
7377
7378 \f
7379 const char *ospf_abr_type_str[] =
7380 {
7381 "unknown",
7382 "standard",
7383 "ibm",
7384 "cisco",
7385 "shortcut"
7386 };
7387
7388 const char *ospf_shortcut_mode_str[] =
7389 {
7390 "default",
7391 "enable",
7392 "disable"
7393 };
7394
7395
7396 static void
7397 area_id2str (char *buf, int length, struct ospf_area *area)
7398 {
7399 memset (buf, 0, length);
7400
7401 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7402 strncpy (buf, inet_ntoa (area->area_id), length);
7403 else
7404 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7405 }
7406
7407 \f
7408 const char *ospf_int_type_str[] =
7409 {
7410 "unknown", /* should never be used. */
7411 "point-to-point",
7412 "broadcast",
7413 "non-broadcast",
7414 "point-to-multipoint",
7415 "virtual-link", /* should never be used. */
7416 "loopback"
7417 };
7418
7419 /* Configuration write function for ospfd. */
7420 static int
7421 config_write_interface (struct vty *vty)
7422 {
7423 struct listnode *n1, *n2;
7424 struct interface *ifp;
7425 struct crypt_key *ck;
7426 int write = 0;
7427 struct route_node *rn = NULL;
7428 struct ospf_if_params *params;
7429
7430 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
7431 {
7432 if (memcmp (ifp->name, "VLINK", 5) == 0)
7433 continue;
7434
7435 vty_out (vty, "!%s", VTY_NEWLINE);
7436 vty_out (vty, "interface %s%s", ifp->name,
7437 VTY_NEWLINE);
7438 if (ifp->desc)
7439 vty_out (vty, " description %s%s", ifp->desc,
7440 VTY_NEWLINE);
7441
7442 write++;
7443
7444 params = IF_DEF_PARAMS (ifp);
7445
7446 do {
7447 /* Interface Network print. */
7448 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
7449 params->type != OSPF_IFTYPE_LOOPBACK)
7450 {
7451 if (params->type != ospf_default_iftype(ifp))
7452 {
7453 vty_out (vty, " ip ospf network %s",
7454 ospf_int_type_str[params->type]);
7455 if (params != IF_DEF_PARAMS (ifp))
7456 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7457 vty_out (vty, "%s", VTY_NEWLINE);
7458 }
7459 }
7460
7461 /* OSPF interface authentication print */
7462 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7463 params->auth_type != OSPF_AUTH_NOTSET)
7464 {
7465 const char *auth_str;
7466
7467 /* Translation tables are not that much help here due to syntax
7468 of the simple option */
7469 switch (params->auth_type)
7470 {
7471
7472 case OSPF_AUTH_NULL:
7473 auth_str = " null";
7474 break;
7475
7476 case OSPF_AUTH_SIMPLE:
7477 auth_str = "";
7478 break;
7479
7480 case OSPF_AUTH_CRYPTOGRAPHIC:
7481 auth_str = " message-digest";
7482 break;
7483
7484 default:
7485 auth_str = "";
7486 break;
7487 }
7488
7489 vty_out (vty, " ip ospf authentication%s", auth_str);
7490 if (params != IF_DEF_PARAMS (ifp))
7491 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7492 vty_out (vty, "%s", VTY_NEWLINE);
7493 }
7494
7495 /* Simple Authentication Password print. */
7496 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7497 params->auth_simple[0] != '\0')
7498 {
7499 vty_out (vty, " ip ospf authentication-key %s",
7500 params->auth_simple);
7501 if (params != IF_DEF_PARAMS (ifp))
7502 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7503 vty_out (vty, "%s", VTY_NEWLINE);
7504 }
7505
7506 /* Cryptographic Authentication Key print. */
7507 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
7508 {
7509 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7510 ck->key_id, ck->auth_key);
7511 if (params != IF_DEF_PARAMS (ifp))
7512 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7513 vty_out (vty, "%s", VTY_NEWLINE);
7514 }
7515
7516 /* Interface Output Cost print. */
7517 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7518 {
7519 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7520 if (params != IF_DEF_PARAMS (ifp))
7521 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7522 vty_out (vty, "%s", VTY_NEWLINE);
7523 }
7524
7525 /* Hello Interval print. */
7526 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7527 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7528 {
7529 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7530 if (params != IF_DEF_PARAMS (ifp))
7531 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7532 vty_out (vty, "%s", VTY_NEWLINE);
7533 }
7534
7535
7536 /* Router Dead Interval print. */
7537 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7538 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7539 {
7540 vty_out (vty, " ip ospf dead-interval ");
7541
7542 /* fast hello ? */
7543 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7544 vty_out (vty, "minimal hello-multiplier %d",
7545 params->fast_hello);
7546 else
7547 vty_out (vty, "%u", params->v_wait);
7548
7549 if (params != IF_DEF_PARAMS (ifp))
7550 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7551 vty_out (vty, "%s", VTY_NEWLINE);
7552 }
7553
7554 /* Router Priority print. */
7555 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7556 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7557 {
7558 vty_out (vty, " ip ospf priority %u", params->priority);
7559 if (params != IF_DEF_PARAMS (ifp))
7560 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7561 vty_out (vty, "%s", VTY_NEWLINE);
7562 }
7563
7564 /* Retransmit Interval print. */
7565 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7566 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7567 {
7568 vty_out (vty, " ip ospf retransmit-interval %u",
7569 params->retransmit_interval);
7570 if (params != IF_DEF_PARAMS (ifp))
7571 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7572 vty_out (vty, "%s", VTY_NEWLINE);
7573 }
7574
7575 /* Transmit Delay print. */
7576 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7577 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7578 {
7579 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7580 if (params != IF_DEF_PARAMS (ifp))
7581 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7582 vty_out (vty, "%s", VTY_NEWLINE);
7583 }
7584
7585 /* MTU ignore print. */
7586 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7587 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7588 {
7589 if (params->mtu_ignore == 0)
7590 vty_out (vty, " no ip ospf mtu-ignore");
7591 else
7592 vty_out (vty, " ip ospf mtu-ignore");
7593 if (params != IF_DEF_PARAMS (ifp))
7594 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7595 vty_out (vty, "%s", VTY_NEWLINE);
7596 }
7597
7598
7599 while (1)
7600 {
7601 if (rn == NULL)
7602 rn = route_top (IF_OIFS_PARAMS (ifp));
7603 else
7604 rn = route_next (rn);
7605
7606 if (rn == NULL)
7607 break;
7608 params = rn->info;
7609 if (params != NULL)
7610 break;
7611 }
7612 } while (rn);
7613
7614 #ifdef HAVE_OPAQUE_LSA
7615 ospf_opaque_config_write_if (vty, ifp);
7616 #endif /* HAVE_OPAQUE_LSA */
7617 }
7618
7619 return write;
7620 }
7621
7622 static int
7623 config_write_network_area (struct vty *vty, struct ospf *ospf)
7624 {
7625 struct route_node *rn;
7626 u_char buf[INET_ADDRSTRLEN];
7627
7628 /* `network area' print. */
7629 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
7630 if (rn->info)
7631 {
7632 struct ospf_network *n = rn->info;
7633
7634 memset (buf, 0, INET_ADDRSTRLEN);
7635
7636 /* Create Area ID string by specified Area ID format. */
7637 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7638 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
7639 else
7640 sprintf ((char *) buf, "%lu",
7641 (unsigned long int) ntohl (n->area_id.s_addr));
7642
7643 /* Network print. */
7644 vty_out (vty, " network %s/%d area %s%s",
7645 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7646 buf, VTY_NEWLINE);
7647 }
7648
7649 return 0;
7650 }
7651
7652 static int
7653 config_write_ospf_area (struct vty *vty, struct ospf *ospf)
7654 {
7655 struct listnode *node;
7656 struct ospf_area *area;
7657 u_char buf[INET_ADDRSTRLEN];
7658
7659 /* Area configuration print. */
7660 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
7661 {
7662 struct route_node *rn1;
7663
7664 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
7665
7666 if (area->auth_type != OSPF_AUTH_NULL)
7667 {
7668 if (area->auth_type == OSPF_AUTH_SIMPLE)
7669 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7670 else
7671 vty_out (vty, " area %s authentication message-digest%s",
7672 buf, VTY_NEWLINE);
7673 }
7674
7675 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7676 vty_out (vty, " area %s shortcut %s%s", buf,
7677 ospf_shortcut_mode_str[area->shortcut_configured],
7678 VTY_NEWLINE);
7679
7680 if ((area->external_routing == OSPF_AREA_STUB)
7681 || (area->external_routing == OSPF_AREA_NSSA)
7682 )
7683 {
7684 if (area->external_routing == OSPF_AREA_STUB)
7685 vty_out (vty, " area %s stub", buf);
7686 else if (area->external_routing == OSPF_AREA_NSSA)
7687 {
7688 vty_out (vty, " area %s nssa", buf);
7689 switch (area->NSSATranslatorRole)
7690 {
7691 case OSPF_NSSA_ROLE_NEVER:
7692 vty_out (vty, " translate-never");
7693 break;
7694 case OSPF_NSSA_ROLE_ALWAYS:
7695 vty_out (vty, " translate-always");
7696 break;
7697 case OSPF_NSSA_ROLE_CANDIDATE:
7698 default:
7699 vty_out (vty, " translate-candidate");
7700 }
7701 }
7702
7703 if (area->no_summary)
7704 vty_out (vty, " no-summary");
7705
7706 vty_out (vty, "%s", VTY_NEWLINE);
7707
7708 if (area->default_cost != 1)
7709 vty_out (vty, " area %s default-cost %d%s", buf,
7710 area->default_cost, VTY_NEWLINE);
7711 }
7712
7713 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7714 if (rn1->info)
7715 {
7716 struct ospf_area_range *range = rn1->info;
7717
7718 vty_out (vty, " area %s range %s/%d", buf,
7719 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7720
7721 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
7722 vty_out (vty, " cost %d", range->cost_config);
7723
7724 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7725 vty_out (vty, " not-advertise");
7726
7727 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7728 vty_out (vty, " substitute %s/%d",
7729 inet_ntoa (range->subst_addr), range->subst_masklen);
7730
7731 vty_out (vty, "%s", VTY_NEWLINE);
7732 }
7733
7734 if (EXPORT_NAME (area))
7735 vty_out (vty, " area %s export-list %s%s", buf,
7736 EXPORT_NAME (area), VTY_NEWLINE);
7737
7738 if (IMPORT_NAME (area))
7739 vty_out (vty, " area %s import-list %s%s", buf,
7740 IMPORT_NAME (area), VTY_NEWLINE);
7741
7742 if (PREFIX_NAME_IN (area))
7743 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7744 PREFIX_NAME_IN (area), VTY_NEWLINE);
7745
7746 if (PREFIX_NAME_OUT (area))
7747 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7748 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7749 }
7750
7751 return 0;
7752 }
7753
7754 static int
7755 config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
7756 {
7757 struct ospf_nbr_nbma *nbr_nbma;
7758 struct route_node *rn;
7759
7760 /* Static Neighbor configuration print. */
7761 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
7762 if ((nbr_nbma = rn->info))
7763 {
7764 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7765
7766 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7767 vty_out (vty, " priority %d", nbr_nbma->priority);
7768
7769 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7770 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7771
7772 vty_out (vty, "%s", VTY_NEWLINE);
7773 }
7774
7775 return 0;
7776 }
7777
7778 static int
7779 config_write_virtual_link (struct vty *vty, struct ospf *ospf)
7780 {
7781 struct listnode *node;
7782 struct ospf_vl_data *vl_data;
7783 u_char buf[INET_ADDRSTRLEN];
7784
7785 /* Virtual-Link print */
7786 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
7787 {
7788 struct listnode *n2;
7789 struct crypt_key *ck;
7790 struct ospf_interface *oi;
7791
7792 if (vl_data != NULL)
7793 {
7794 memset (buf, 0, INET_ADDRSTRLEN);
7795
7796 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7797 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
7798 else
7799 sprintf ((char *) buf, "%lu",
7800 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7801 oi = vl_data->vl_oi;
7802
7803 /* timers */
7804 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7805 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7806 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7807 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7808 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7809 buf,
7810 inet_ntoa (vl_data->vl_peer),
7811 OSPF_IF_PARAM (oi, v_hello),
7812 OSPF_IF_PARAM (oi, retransmit_interval),
7813 OSPF_IF_PARAM (oi, transmit_delay),
7814 OSPF_IF_PARAM (oi, v_wait),
7815 VTY_NEWLINE);
7816 else
7817 vty_out (vty, " area %s virtual-link %s%s", buf,
7818 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7819 /* Auth key */
7820 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7821 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7822 buf,
7823 inet_ntoa (vl_data->vl_peer),
7824 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7825 VTY_NEWLINE);
7826 /* md5 keys */
7827 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7828 n2, ck))
7829 vty_out (vty, " area %s virtual-link %s"
7830 " message-digest-key %d md5 %s%s",
7831 buf,
7832 inet_ntoa (vl_data->vl_peer),
7833 ck->key_id, ck->auth_key, VTY_NEWLINE);
7834
7835 }
7836 }
7837
7838 return 0;
7839 }
7840
7841 \f
7842 static int
7843 config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
7844 {
7845 int type;
7846
7847 /* redistribute print. */
7848 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7849 if (type != zclient->redist_default && zclient->redist[type])
7850 {
7851 vty_out (vty, " redistribute %s", zebra_route_string(type));
7852 if (ospf->dmetric[type].value >= 0)
7853 vty_out (vty, " metric %d", ospf->dmetric[type].value);
7854
7855 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
7856 vty_out (vty, " metric-type 1");
7857
7858 if (ROUTEMAP_NAME (ospf, type))
7859 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
7860
7861 vty_out (vty, "%s", VTY_NEWLINE);
7862 }
7863
7864 return 0;
7865 }
7866
7867 static int
7868 config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
7869 {
7870 if (ospf->default_metric != -1)
7871 vty_out (vty, " default-metric %d%s", ospf->default_metric,
7872 VTY_NEWLINE);
7873 return 0;
7874 }
7875
7876 static int
7877 config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
7878 {
7879 int type;
7880
7881 if (ospf)
7882 {
7883 /* distribute-list print. */
7884 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7885 if (DISTRIBUTE_NAME (ospf, type))
7886 vty_out (vty, " distribute-list %s out %s%s",
7887 DISTRIBUTE_NAME (ospf, type),
7888 zebra_route_string(type), VTY_NEWLINE);
7889
7890 /* default-information print. */
7891 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
7892 {
7893 vty_out (vty, " default-information originate");
7894 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7895 vty_out (vty, " always");
7896
7897 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
7898 vty_out (vty, " metric %d",
7899 ospf->dmetric[DEFAULT_ROUTE].value);
7900 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
7901 vty_out (vty, " metric-type 1");
7902
7903 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7904 vty_out (vty, " route-map %s",
7905 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
7906
7907 vty_out (vty, "%s", VTY_NEWLINE);
7908 }
7909
7910 }
7911
7912 return 0;
7913 }
7914
7915 static int
7916 config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
7917 {
7918 struct route_node *rn;
7919 struct ospf_distance *odistance;
7920
7921 if (ospf->distance_all)
7922 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
7923
7924 if (ospf->distance_intra
7925 || ospf->distance_inter
7926 || ospf->distance_external)
7927 {
7928 vty_out (vty, " distance ospf");
7929
7930 if (ospf->distance_intra)
7931 vty_out (vty, " intra-area %d", ospf->distance_intra);
7932 if (ospf->distance_inter)
7933 vty_out (vty, " inter-area %d", ospf->distance_inter);
7934 if (ospf->distance_external)
7935 vty_out (vty, " external %d", ospf->distance_external);
7936
7937 vty_out (vty, "%s", VTY_NEWLINE);
7938 }
7939
7940 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
7941 if ((odistance = rn->info) != NULL)
7942 {
7943 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7944 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7945 odistance->access_list ? odistance->access_list : "",
7946 VTY_NEWLINE);
7947 }
7948 return 0;
7949 }
7950
7951 /* OSPF configuration write function. */
7952 static int
7953 ospf_config_write (struct vty *vty)
7954 {
7955 struct ospf *ospf;
7956 struct interface *ifp;
7957 struct ospf_interface *oi;
7958 struct listnode *node;
7959 int write = 0;
7960
7961 ospf = ospf_lookup ();
7962 if (ospf != NULL)
7963 {
7964 /* `router ospf' print. */
7965 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7966
7967 write++;
7968
7969 if (!ospf->networks)
7970 return write;
7971
7972 /* Router ID print. */
7973 if (ospf->router_id_static.s_addr != 0)
7974 vty_out (vty, " ospf router-id %s%s",
7975 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
7976
7977 /* ABR type print. */
7978 if (ospf->abr_type != OSPF_ABR_DEFAULT)
7979 vty_out (vty, " ospf abr-type %s%s",
7980 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
7981
7982 /* log-adjacency-changes flag print. */
7983 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7984 {
7985 vty_out(vty, " log-adjacency-changes");
7986 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7987 vty_out(vty, " detail");
7988 vty_out(vty, "%s", VTY_NEWLINE);
7989 }
7990
7991 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
7992 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
7993 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7994
7995 /* auto-cost reference-bandwidth configuration. */
7996 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
7997 {
7998 vty_out (vty, "! Important: ensure reference bandwidth "
7999 "is consistent across all routers%s", VTY_NEWLINE);
8000 vty_out (vty, " auto-cost reference-bandwidth %d%s",
8001 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
8002 }
8003
8004 /* SPF timers print. */
8005 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
8006 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
8007 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
8008 vty_out (vty, " timers throttle spf %d %d %d%s",
8009 ospf->spf_delay, ospf->spf_holdtime,
8010 ospf->spf_max_holdtime, VTY_NEWLINE);
8011
8012 /* Max-metric router-lsa print */
8013 config_write_stub_router (vty, ospf);
8014
8015 /* SPF refresh parameters print. */
8016 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
8017 vty_out (vty, " refresh timer %d%s",
8018 ospf->lsa_refresh_interval, VTY_NEWLINE);
8019
8020 /* Redistribute information print. */
8021 config_write_ospf_redistribute (vty, ospf);
8022
8023 /* passive-interface print. */
8024 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
8025 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
8026
8027 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
8028 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
8029 && IF_DEF_PARAMS (ifp)->passive_interface !=
8030 ospf->passive_interface_default)
8031 {
8032 vty_out (vty, " %spassive-interface %s%s",
8033 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
8034 ifp->name, VTY_NEWLINE);
8035 }
8036 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
8037 {
8038 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
8039 continue;
8040 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
8041 passive_interface))
8042 {
8043 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
8044 continue;
8045 }
8046 else if (oi->params->passive_interface == ospf->passive_interface_default)
8047 continue;
8048
8049 vty_out (vty, " %spassive-interface %s %s%s",
8050 oi->params->passive_interface ? "" : "no ",
8051 oi->ifp->name,
8052 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
8053 }
8054
8055 /* Network area print. */
8056 config_write_network_area (vty, ospf);
8057
8058 /* Area config print. */
8059 config_write_ospf_area (vty, ospf);
8060
8061 /* static neighbor print. */
8062 config_write_ospf_nbr_nbma (vty, ospf);
8063
8064 /* Virtual-Link print. */
8065 config_write_virtual_link (vty, ospf);
8066
8067 /* Default metric configuration. */
8068 config_write_ospf_default_metric (vty, ospf);
8069
8070 /* Distribute-list and default-information print. */
8071 config_write_ospf_distribute (vty, ospf);
8072
8073 /* Distance configuration. */
8074 config_write_ospf_distance (vty, ospf);
8075
8076 #ifdef HAVE_OPAQUE_LSA
8077 ospf_opaque_config_write_router (vty, ospf);
8078 #endif /* HAVE_OPAQUE_LSA */
8079 }
8080
8081 return write;
8082 }
8083
8084 void
8085 ospf_vty_show_init (void)
8086 {
8087 /* "show ip ospf" commands. */
8088 install_element (VIEW_NODE, &show_ip_ospf_cmd);
8089 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
8090
8091 /* "show ip ospf database" commands. */
8092 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
8093 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
8094 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8095 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8096 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
8097 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
8098 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
8099 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
8100 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
8101 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8102 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8103 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
8104 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
8105 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
8106
8107 /* "show ip ospf interface" commands. */
8108 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
8109 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
8110
8111 /* "show ip ospf neighbor" commands. */
8112 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8113 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
8114 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
8115 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8116 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
8117 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
8118 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
8119 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8120 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
8121 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
8122 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8123 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
8124 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
8125 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
8126
8127 /* "show ip ospf route" commands. */
8128 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
8129 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
8130 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
8131 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
8132 }
8133
8134 \f
8135 /* ospfd's interface node. */
8136 static struct cmd_node interface_node =
8137 {
8138 INTERFACE_NODE,
8139 "%s(config-if)# ",
8140 1
8141 };
8142
8143 /* Initialization of OSPF interface. */
8144 static void
8145 ospf_vty_if_init (void)
8146 {
8147 /* Install interface node. */
8148 install_node (&interface_node, config_write_interface);
8149
8150 install_element (CONFIG_NODE, &interface_cmd);
8151 install_element (CONFIG_NODE, &no_interface_cmd);
8152 install_default (INTERFACE_NODE);
8153
8154 /* "description" commands. */
8155 install_element (INTERFACE_NODE, &interface_desc_cmd);
8156 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
8157
8158 /* "ip ospf authentication" commands. */
8159 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
8160 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
8161 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
8162 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
8163 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
8164 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
8165 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
8166 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
8167 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
8168 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
8169
8170 /* "ip ospf message-digest-key" commands. */
8171 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
8172 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
8173 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8174 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8175
8176 /* "ip ospf cost" commands. */
8177 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
8178 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
8179 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
8180 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
8181 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
8182 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8183
8184 /* "ip ospf mtu-ignore" commands. */
8185 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8186 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8187 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8188 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8189
8190 /* "ip ospf dead-interval" commands. */
8191 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8192 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
8193 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8194 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
8195 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8196 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
8197
8198 /* "ip ospf hello-interval" commands. */
8199 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8200 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8201 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8202 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8203
8204 /* "ip ospf network" commands. */
8205 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8206 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8207
8208 /* "ip ospf priority" commands. */
8209 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8210 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8211 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8212 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8213
8214 /* "ip ospf retransmit-interval" commands. */
8215 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8216 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8217 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8218 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8219
8220 /* "ip ospf transmit-delay" commands. */
8221 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8222 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8223 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8224 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8225
8226 /* These commands are compatibitliy for previous version. */
8227 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8228 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8229 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8230 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
8231 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
8232 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
8233 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
8234 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
8235 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
8236 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
8237 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8238 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8239 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8240 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8241 install_element (INTERFACE_NODE, &ospf_network_cmd);
8242 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8243 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8244 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8245 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8246 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8247 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8248 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8249 }
8250
8251 static void
8252 ospf_vty_zebra_init (void)
8253 {
8254 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8255 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8256 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8257 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8258 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8259 install_element (OSPF_NODE,
8260 &ospf_redistribute_source_metric_type_routemap_cmd);
8261 install_element (OSPF_NODE,
8262 &ospf_redistribute_source_type_metric_routemap_cmd);
8263 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8264 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8265 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8266
8267 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8268
8269 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8270 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8271
8272 install_element (OSPF_NODE,
8273 &ospf_default_information_originate_metric_type_cmd);
8274 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8275 install_element (OSPF_NODE,
8276 &ospf_default_information_originate_type_metric_cmd);
8277 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8278 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8279 install_element (OSPF_NODE,
8280 &ospf_default_information_originate_always_metric_type_cmd);
8281 install_element (OSPF_NODE,
8282 &ospf_default_information_originate_always_metric_cmd);
8283 install_element (OSPF_NODE,
8284 &ospf_default_information_originate_always_cmd);
8285 install_element (OSPF_NODE,
8286 &ospf_default_information_originate_always_type_metric_cmd);
8287 install_element (OSPF_NODE,
8288 &ospf_default_information_originate_always_type_cmd);
8289
8290 install_element (OSPF_NODE,
8291 &ospf_default_information_originate_metric_type_routemap_cmd);
8292 install_element (OSPF_NODE,
8293 &ospf_default_information_originate_metric_routemap_cmd);
8294 install_element (OSPF_NODE,
8295 &ospf_default_information_originate_routemap_cmd);
8296 install_element (OSPF_NODE,
8297 &ospf_default_information_originate_type_metric_routemap_cmd);
8298 install_element (OSPF_NODE,
8299 &ospf_default_information_originate_type_routemap_cmd);
8300 install_element (OSPF_NODE,
8301 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8302 install_element (OSPF_NODE,
8303 &ospf_default_information_originate_always_metric_routemap_cmd);
8304 install_element (OSPF_NODE,
8305 &ospf_default_information_originate_always_routemap_cmd);
8306 install_element (OSPF_NODE,
8307 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8308 install_element (OSPF_NODE,
8309 &ospf_default_information_originate_always_type_routemap_cmd);
8310
8311 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8312
8313 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8314 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8315 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8316
8317 install_element (OSPF_NODE, &ospf_distance_cmd);
8318 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8319 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8320 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8321 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8322 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8323 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8324 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8325 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8326 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8327 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8328 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8329 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8330 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8331 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8332 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8333 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8334 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8335 #if 0
8336 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8337 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8338 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8339 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8340 #endif /* 0 */
8341 }
8342
8343 static struct cmd_node ospf_node =
8344 {
8345 OSPF_NODE,
8346 "%s(config-router)# ",
8347 1
8348 };
8349
8350 \f
8351 /* Install OSPF related vty commands. */
8352 void
8353 ospf_vty_init (void)
8354 {
8355 /* Install ospf top node. */
8356 install_node (&ospf_node, ospf_config_write);
8357
8358 /* "router ospf" commands. */
8359 install_element (CONFIG_NODE, &router_ospf_cmd);
8360 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8361
8362 install_default (OSPF_NODE);
8363
8364 /* "ospf router-id" commands. */
8365 install_element (OSPF_NODE, &ospf_router_id_cmd);
8366 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
8367 install_element (OSPF_NODE, &router_ospf_id_cmd);
8368 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
8369
8370 /* "passive-interface" commands. */
8371 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8372 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8373 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
8374 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8375 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
8376 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
8377
8378 /* "ospf abr-type" commands. */
8379 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8380 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8381
8382 /* "ospf log-adjacency-changes" commands. */
8383 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8384 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8385 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8386 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8387
8388 /* "ospf rfc1583-compatible" commands. */
8389 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8390 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8391 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8392 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8393
8394 /* "network area" commands. */
8395 install_element (OSPF_NODE, &ospf_network_area_cmd);
8396 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
8397
8398 /* "area authentication" commands. */
8399 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8400 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8401 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
8402
8403 /* "area range" commands. */
8404 install_element (OSPF_NODE, &ospf_area_range_cmd);
8405 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8406 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8407 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8408 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8409 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8410 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8411 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8412 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8413 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8414 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
8415
8416 /* "area virtual-link" commands. */
8417 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8418 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
8419
8420 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8421 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
8422
8423 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8424 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
8425
8426 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8427 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
8428
8429 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8430 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
8431
8432 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8433 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8434 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
8435
8436 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8437 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
8438
8439 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8440 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
8441
8442 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8443 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8444 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
8445
8446 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8447 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8448 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
8449
8450 /* "area stub" commands. */
8451 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8452 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8453 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8454 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
8455
8456 /* "area nssa" commands. */
8457 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8458 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8459 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8460 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8461 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8462 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
8463
8464 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8465 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
8466
8467 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8468 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
8469
8470 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8471 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
8472
8473 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8474 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
8475
8476 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8477 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
8478
8479 /* SPF timer commands */
8480 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8481 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
8482 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8483 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8484
8485 /* refresh timer commands */
8486 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8487 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8488 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
8489
8490 /* max-metric commands */
8491 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8492 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8493 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8494 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8495 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8496 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8497
8498 /* reference bandwidth commands */
8499 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8500 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
8501
8502 /* "neighbor" commands. */
8503 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8504 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8505 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8506 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8507 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8508 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8509 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8510 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
8511
8512 /* Init interface related vty commands. */
8513 ospf_vty_if_init ();
8514
8515 /* Init zebra related vty commands. */
8516 ospf_vty_zebra_init ();
8517 }