]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_vty.c
lib: put route_types.txt to real use
[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 /* Next network-LSA sequence number we'll use, if we're elected DR */
2915 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
2916 != OSPF_INITIAL_SEQUENCE_NUMBER)
2917 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
2918 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
2919
2920 vty_out (vty, " Multicast group memberships:");
2921 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2922 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2923 {
2924 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2925 vty_out (vty, " OSPFAllRouters");
2926 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2927 vty_out (vty, " OSPFDesignatedRouters");
2928 }
2929 else
2930 vty_out (vty, " <None>");
2931 vty_out (vty, "%s", VTY_NEWLINE);
2932
2933 vty_out (vty, " Timer intervals configured,");
2934 vty_out (vty, " Hello ");
2935 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2936 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2937 else
2938 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2939 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2940 OSPF_IF_PARAM (oi, v_wait),
2941 OSPF_IF_PARAM (oi, v_wait),
2942 OSPF_IF_PARAM (oi, retransmit_interval),
2943 VTY_NEWLINE);
2944
2945 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
2946 {
2947 char timebuf[OSPF_TIME_DUMP_SIZE];
2948 vty_out (vty, " Hello due in %s%s",
2949 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
2950 VTY_NEWLINE);
2951 }
2952 else /* passive-interface is set */
2953 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2954
2955 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
2956 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
2957 VTY_NEWLINE);
2958 }
2959 }
2960
2961 DEFUN (show_ip_ospf_interface,
2962 show_ip_ospf_interface_cmd,
2963 "show ip ospf interface [INTERFACE]",
2964 SHOW_STR
2965 IP_STR
2966 "OSPF information\n"
2967 "Interface information\n"
2968 "Interface name\n")
2969 {
2970 struct interface *ifp;
2971 struct ospf *ospf;
2972 struct listnode *node;
2973
2974 ospf = ospf_lookup ();
2975 if (ospf == NULL)
2976 {
2977 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2978 return CMD_SUCCESS;
2979 }
2980
2981 /* Show All Interfaces. */
2982 if (argc == 0)
2983 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2984 show_ip_ospf_interface_sub (vty, ospf, ifp);
2985 /* Interface name is specified. */
2986 else
2987 {
2988 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2989 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2990 else
2991 show_ip_ospf_interface_sub (vty, ospf, ifp);
2992 }
2993
2994 return CMD_SUCCESS;
2995 }
2996
2997 static void
2998 show_ip_ospf_neighbour_header (struct vty *vty)
2999 {
3000 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3001 VTY_NEWLINE,
3002 "Neighbor ID", "Pri", "State", "Dead Time",
3003 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3004 VTY_NEWLINE);
3005 }
3006
3007 static void
3008 show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3009 {
3010 struct route_node *rn;
3011 struct ospf_neighbor *nbr;
3012 char msgbuf[16];
3013 char timebuf[OSPF_TIME_DUMP_SIZE];
3014
3015 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3016 if ((nbr = rn->info))
3017 /* Do not show myself. */
3018 if (nbr != oi->nbr_self)
3019 /* Down state is not shown. */
3020 if (nbr->state != NSM_Down)
3021 {
3022 ospf_nbr_state_message (nbr, msgbuf, 16);
3023
3024 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3025 vty_out (vty, "%-15s %3d %-15s ",
3026 "-", nbr->priority,
3027 msgbuf);
3028 else
3029 vty_out (vty, "%-15s %3d %-15s ",
3030 inet_ntoa (nbr->router_id), nbr->priority,
3031 msgbuf);
3032
3033 vty_out (vty, "%9s ",
3034 ospf_timer_dump (nbr->t_inactivity, timebuf,
3035 sizeof(timebuf)));
3036
3037 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
3038 vty_out (vty, "%-20s %5ld %5ld %5d%s",
3039 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3040 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3041 VTY_NEWLINE);
3042 }
3043 }
3044
3045 DEFUN (show_ip_ospf_neighbor,
3046 show_ip_ospf_neighbor_cmd,
3047 "show ip ospf neighbor",
3048 SHOW_STR
3049 IP_STR
3050 "OSPF information\n"
3051 "Neighbor list\n")
3052 {
3053 struct ospf *ospf;
3054 struct ospf_interface *oi;
3055 struct listnode *node;
3056
3057 ospf = ospf_lookup ();
3058 if (ospf == NULL)
3059 {
3060 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3061 return CMD_SUCCESS;
3062 }
3063
3064 show_ip_ospf_neighbour_header (vty);
3065
3066 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3067 show_ip_ospf_neighbor_sub (vty, oi);
3068
3069 return CMD_SUCCESS;
3070 }
3071
3072 DEFUN (show_ip_ospf_neighbor_all,
3073 show_ip_ospf_neighbor_all_cmd,
3074 "show ip ospf neighbor all",
3075 SHOW_STR
3076 IP_STR
3077 "OSPF information\n"
3078 "Neighbor list\n"
3079 "include down status neighbor\n")
3080 {
3081 struct ospf *ospf = ospf_lookup ();
3082 struct listnode *node;
3083 struct ospf_interface *oi;
3084
3085 if (ospf == NULL)
3086 {
3087 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3088 return CMD_SUCCESS;
3089 }
3090
3091 show_ip_ospf_neighbour_header (vty);
3092
3093 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3094 {
3095 struct listnode *nbr_node;
3096 struct ospf_nbr_nbma *nbr_nbma;
3097
3098 show_ip_ospf_neighbor_sub (vty, oi);
3099
3100 /* print Down neighbor status */
3101 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
3102 {
3103 if (nbr_nbma->nbr == NULL
3104 || nbr_nbma->nbr->state == NSM_Down)
3105 {
3106 vty_out (vty, "%-15s %3d %-15s %9s ",
3107 "-", nbr_nbma->priority, "Down", "-");
3108 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
3109 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3110 0, 0, 0, VTY_NEWLINE);
3111 }
3112 }
3113 }
3114
3115 return CMD_SUCCESS;
3116 }
3117
3118 DEFUN (show_ip_ospf_neighbor_int,
3119 show_ip_ospf_neighbor_int_cmd,
3120 "show ip ospf neighbor IFNAME",
3121 SHOW_STR
3122 IP_STR
3123 "OSPF information\n"
3124 "Neighbor list\n"
3125 "Interface name\n")
3126 {
3127 struct ospf *ospf;
3128 struct interface *ifp;
3129 struct route_node *rn;
3130
3131 ifp = if_lookup_by_name (argv[0]);
3132 if (!ifp)
3133 {
3134 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
3135 return CMD_WARNING;
3136 }
3137
3138 ospf = ospf_lookup ();
3139 if (ospf == NULL)
3140 {
3141 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3142 return CMD_SUCCESS;
3143 }
3144
3145 show_ip_ospf_neighbour_header (vty);
3146
3147 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3148 {
3149 struct ospf_interface *oi = rn->info;
3150
3151 if (oi == NULL)
3152 continue;
3153
3154 show_ip_ospf_neighbor_sub (vty, oi);
3155 }
3156
3157 return CMD_SUCCESS;
3158 }
3159
3160 static void
3161 show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3162 struct ospf_nbr_nbma *nbr_nbma)
3163 {
3164 char timebuf[OSPF_TIME_DUMP_SIZE];
3165
3166 /* Show neighbor ID. */
3167 vty_out (vty, " Neighbor %s,", "-");
3168
3169 /* Show interface address. */
3170 vty_out (vty, " interface address %s%s",
3171 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3172 /* Show Area ID. */
3173 vty_out (vty, " In the area %s via interface %s%s",
3174 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3175 /* Show neighbor priority and state. */
3176 vty_out (vty, " Neighbor priority is %d, State is %s,",
3177 nbr_nbma->priority, "Down");
3178 /* Show state changes. */
3179 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3180
3181 /* Show PollInterval */
3182 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3183
3184 /* Show poll-interval timer. */
3185 vty_out (vty, " Poll timer due in %s%s",
3186 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3187 VTY_NEWLINE);
3188
3189 /* Show poll-interval timer thread. */
3190 vty_out (vty, " Thread Poll Timer %s%s",
3191 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3192 }
3193
3194 static void
3195 show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3196 struct ospf_neighbor *nbr)
3197 {
3198 char timebuf[OSPF_TIME_DUMP_SIZE];
3199
3200 /* Show neighbor ID. */
3201 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3202 vty_out (vty, " Neighbor %s,", "-");
3203 else
3204 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3205
3206 /* Show interface address. */
3207 vty_out (vty, " interface address %s%s",
3208 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3209 /* Show Area ID. */
3210 vty_out (vty, " In the area %s via interface %s%s",
3211 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3212 /* Show neighbor priority and state. */
3213 vty_out (vty, " Neighbor priority is %d, State is %s,",
3214 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3215 /* Show state changes. */
3216 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3217 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
3218 {
3219 struct timeval res
3220 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
3221 vty_out (vty, " Most recent state change statistics:%s",
3222 VTY_NEWLINE);
3223 vty_out (vty, " Progressive change %s ago%s",
3224 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3225 VTY_NEWLINE);
3226 }
3227 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3228 {
3229 struct timeval res
3230 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
3231 vty_out (vty, " Regressive change %s ago, due to %s%s",
3232 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3233 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
3234 VTY_NEWLINE);
3235 }
3236 /* Show Designated Rotuer ID. */
3237 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3238 /* Show Backup Designated Rotuer ID. */
3239 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3240 /* Show options. */
3241 vty_out (vty, " Options %d %s%s", nbr->options,
3242 ospf_options_dump (nbr->options), VTY_NEWLINE);
3243 /* Show Router Dead interval timer. */
3244 vty_out (vty, " Dead timer due in %s%s",
3245 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3246 VTY_NEWLINE);
3247 /* Show Database Summary list. */
3248 vty_out (vty, " Database Summary List %d%s",
3249 ospf_db_summary_count (nbr), VTY_NEWLINE);
3250 /* Show Link State Request list. */
3251 vty_out (vty, " Link State Request List %ld%s",
3252 ospf_ls_request_count (nbr), VTY_NEWLINE);
3253 /* Show Link State Retransmission list. */
3254 vty_out (vty, " Link State Retransmission List %ld%s",
3255 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3256 /* Show inactivity timer thread. */
3257 vty_out (vty, " Thread Inactivity Timer %s%s",
3258 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3259 /* Show Database Description retransmission thread. */
3260 vty_out (vty, " Thread Database Description Retransmision %s%s",
3261 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3262 /* Show Link State Request Retransmission thread. */
3263 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3264 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3265 /* Show Link State Update Retransmission thread. */
3266 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3267 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3268 }
3269
3270 DEFUN (show_ip_ospf_neighbor_id,
3271 show_ip_ospf_neighbor_id_cmd,
3272 "show ip ospf neighbor A.B.C.D",
3273 SHOW_STR
3274 IP_STR
3275 "OSPF information\n"
3276 "Neighbor list\n"
3277 "Neighbor ID\n")
3278 {
3279 struct ospf *ospf;
3280 struct listnode *node;
3281 struct ospf_neighbor *nbr;
3282 struct ospf_interface *oi;
3283 struct in_addr router_id;
3284 int ret;
3285
3286 ret = inet_aton (argv[0], &router_id);
3287 if (!ret)
3288 {
3289 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3290 return CMD_WARNING;
3291 }
3292
3293 ospf = ospf_lookup ();
3294 if (ospf == NULL)
3295 {
3296 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3297 return CMD_SUCCESS;
3298 }
3299
3300 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3301 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3302 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3303
3304 return CMD_SUCCESS;
3305 }
3306
3307 DEFUN (show_ip_ospf_neighbor_detail,
3308 show_ip_ospf_neighbor_detail_cmd,
3309 "show ip ospf neighbor detail",
3310 SHOW_STR
3311 IP_STR
3312 "OSPF information\n"
3313 "Neighbor list\n"
3314 "detail of all neighbors\n")
3315 {
3316 struct ospf *ospf;
3317 struct ospf_interface *oi;
3318 struct listnode *node;
3319
3320 ospf = ospf_lookup ();
3321 if (ospf == NULL)
3322 {
3323 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3324 return CMD_SUCCESS;
3325 }
3326
3327 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3328 {
3329 struct route_node *rn;
3330 struct ospf_neighbor *nbr;
3331
3332 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3333 if ((nbr = rn->info))
3334 if (nbr != oi->nbr_self)
3335 if (nbr->state != NSM_Down)
3336 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3337 }
3338
3339 return CMD_SUCCESS;
3340 }
3341
3342 DEFUN (show_ip_ospf_neighbor_detail_all,
3343 show_ip_ospf_neighbor_detail_all_cmd,
3344 "show ip ospf neighbor detail all",
3345 SHOW_STR
3346 IP_STR
3347 "OSPF information\n"
3348 "Neighbor list\n"
3349 "detail of all neighbors\n"
3350 "include down status neighbor\n")
3351 {
3352 struct ospf *ospf;
3353 struct listnode *node;
3354 struct ospf_interface *oi;
3355
3356 ospf = ospf_lookup ();
3357 if (ospf == NULL)
3358 {
3359 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3360 return CMD_SUCCESS;
3361 }
3362
3363 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3364 {
3365 struct route_node *rn;
3366 struct ospf_neighbor *nbr;
3367 struct ospf_nbr_nbma *nbr_nbma;
3368
3369 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3370 if ((nbr = rn->info))
3371 if (nbr != oi->nbr_self)
3372 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3373 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3374
3375 if (oi->type == OSPF_IFTYPE_NBMA)
3376 {
3377 struct listnode *nd;
3378
3379 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3380 if (nbr_nbma->nbr == NULL
3381 || nbr_nbma->nbr->state == NSM_Down)
3382 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3383 }
3384 }
3385
3386 return CMD_SUCCESS;
3387 }
3388
3389 DEFUN (show_ip_ospf_neighbor_int_detail,
3390 show_ip_ospf_neighbor_int_detail_cmd,
3391 "show ip ospf neighbor IFNAME detail",
3392 SHOW_STR
3393 IP_STR
3394 "OSPF information\n"
3395 "Neighbor list\n"
3396 "Interface name\n"
3397 "detail of all neighbors")
3398 {
3399 struct ospf *ospf;
3400 struct ospf_interface *oi;
3401 struct interface *ifp;
3402 struct route_node *rn, *nrn;
3403 struct ospf_neighbor *nbr;
3404
3405 ifp = if_lookup_by_name (argv[0]);
3406 if (!ifp)
3407 {
3408 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
3409 return CMD_WARNING;
3410 }
3411
3412 ospf = ospf_lookup ();
3413 if (ospf == NULL)
3414 {
3415 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3416 return CMD_SUCCESS;
3417 }
3418
3419
3420 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3421 if ((oi = rn->info))
3422 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3423 if ((nbr = nrn->info))
3424 if (nbr != oi->nbr_self)
3425 if (nbr->state != NSM_Down)
3426 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3427
3428 return CMD_SUCCESS;
3429 }
3430
3431 \f
3432 /* Show functions */
3433 static int
3434 show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
3435 {
3436 struct router_lsa *rl;
3437 struct summary_lsa *sl;
3438 struct as_external_lsa *asel;
3439 struct prefix_ipv4 p;
3440
3441 if (lsa != NULL)
3442 /* If self option is set, check LSA self flag. */
3443 if (self == 0 || IS_LSA_SELF (lsa))
3444 {
3445 /* LSA common part show. */
3446 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3447 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3448 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3449 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3450 /* LSA specific part show. */
3451 switch (lsa->data->type)
3452 {
3453 case OSPF_ROUTER_LSA:
3454 rl = (struct router_lsa *) lsa->data;
3455 vty_out (vty, " %-d", ntohs (rl->links));
3456 break;
3457 case OSPF_SUMMARY_LSA:
3458 sl = (struct summary_lsa *) lsa->data;
3459
3460 p.family = AF_INET;
3461 p.prefix = sl->header.id;
3462 p.prefixlen = ip_masklen (sl->mask);
3463 apply_mask_ipv4 (&p);
3464
3465 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3466 break;
3467 case OSPF_AS_EXTERNAL_LSA:
3468 case OSPF_AS_NSSA_LSA:
3469 asel = (struct as_external_lsa *) lsa->data;
3470
3471 p.family = AF_INET;
3472 p.prefix = asel->header.id;
3473 p.prefixlen = ip_masklen (asel->mask);
3474 apply_mask_ipv4 (&p);
3475
3476 vty_out (vty, " %s %s/%d [0x%lx]",
3477 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3478 inet_ntoa (p.prefix), p.prefixlen,
3479 (u_long)ntohl (asel->e[0].route_tag));
3480 break;
3481 case OSPF_NETWORK_LSA:
3482 case OSPF_ASBR_SUMMARY_LSA:
3483 #ifdef HAVE_OPAQUE_LSA
3484 case OSPF_OPAQUE_LINK_LSA:
3485 case OSPF_OPAQUE_AREA_LSA:
3486 case OSPF_OPAQUE_AS_LSA:
3487 #endif /* HAVE_OPAQUE_LSA */
3488 default:
3489 break;
3490 }
3491 vty_out (vty, VTY_NEWLINE);
3492 }
3493
3494 return 0;
3495 }
3496
3497 static const char *show_database_desc[] =
3498 {
3499 "unknown",
3500 "Router Link States",
3501 "Net Link States",
3502 "Summary Link States",
3503 "ASBR-Summary Link States",
3504 "AS External Link States",
3505 "Group Membership LSA",
3506 "NSSA-external Link States",
3507 #ifdef HAVE_OPAQUE_LSA
3508 "Type-8 LSA",
3509 "Link-Local Opaque-LSA",
3510 "Area-Local Opaque-LSA",
3511 "AS-external Opaque-LSA",
3512 #endif /* HAVE_OPAQUE_LSA */
3513 };
3514
3515 static const char *show_database_header[] =
3516 {
3517 "",
3518 "Link ID ADV Router Age Seq# CkSum Link count",
3519 "Link ID ADV Router Age Seq# CkSum",
3520 "Link ID ADV Router Age Seq# CkSum Route",
3521 "Link ID ADV Router Age Seq# CkSum",
3522 "Link ID ADV Router Age Seq# CkSum Route",
3523 " --- header for Group Member ----",
3524 "Link ID ADV Router Age Seq# CkSum Route",
3525 #ifdef HAVE_OPAQUE_LSA
3526 " --- type-8 ---",
3527 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3528 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3529 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3530 #endif /* HAVE_OPAQUE_LSA */
3531 };
3532
3533 static void
3534 show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3535 {
3536 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
3537
3538 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
3539 vty_out (vty, " Options: 0x%-2x : %s%s",
3540 lsa->data->options,
3541 ospf_options_dump(lsa->data->options),
3542 VTY_NEWLINE);
3543 vty_out (vty, " LS Flags: 0x%-2x %s%s",
3544 lsa->flags,
3545 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3546 VTY_NEWLINE);
3547
3548 if (lsa->data->type == OSPF_ROUTER_LSA)
3549 {
3550 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3551
3552 if (rlsa->flags)
3553 vty_out (vty, " :%s%s%s%s",
3554 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3555 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3556 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3557 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3558
3559 vty_out (vty, "%s", VTY_NEWLINE);
3560 }
3561 vty_out (vty, " LS Type: %s%s",
3562 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3563 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3564 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3565 vty_out (vty, " Advertising Router: %s%s",
3566 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3567 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3568 VTY_NEWLINE);
3569 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3570 VTY_NEWLINE);
3571 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3572 }
3573
3574 const char *link_type_desc[] =
3575 {
3576 "(null)",
3577 "another Router (point-to-point)",
3578 "a Transit Network",
3579 "Stub Network",
3580 "a Virtual Link",
3581 };
3582
3583 const char *link_id_desc[] =
3584 {
3585 "(null)",
3586 "Neighboring Router ID",
3587 "Designated Router address",
3588 "Net",
3589 "Neighboring Router ID",
3590 };
3591
3592 const char *link_data_desc[] =
3593 {
3594 "(null)",
3595 "Router Interface address",
3596 "Router Interface address",
3597 "Network Mask",
3598 "Router Interface address",
3599 };
3600
3601 /* Show router-LSA each Link information. */
3602 static void
3603 show_ip_ospf_database_router_links (struct vty *vty,
3604 struct router_lsa *rl)
3605 {
3606 int len, i, type;
3607
3608 len = ntohs (rl->header.length) - 4;
3609 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3610 {
3611 type = rl->link[i].type;
3612
3613 vty_out (vty, " Link connected to: %s%s",
3614 link_type_desc[type], VTY_NEWLINE);
3615 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3616 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3617 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3618 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3619 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3620 vty_out (vty, " TOS 0 Metric: %d%s",
3621 ntohs (rl->link[i].metric), VTY_NEWLINE);
3622 vty_out (vty, "%s", VTY_NEWLINE);
3623 }
3624 }
3625
3626 /* Show router-LSA detail information. */
3627 static int
3628 show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3629 {
3630 if (lsa != NULL)
3631 {
3632 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3633
3634 show_ip_ospf_database_header (vty, lsa);
3635
3636 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3637 VTY_NEWLINE, VTY_NEWLINE);
3638
3639 show_ip_ospf_database_router_links (vty, rl);
3640 vty_out (vty, "%s", VTY_NEWLINE);
3641 }
3642
3643 return 0;
3644 }
3645
3646 /* Show network-LSA detail information. */
3647 static int
3648 show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3649 {
3650 int length, i;
3651
3652 if (lsa != NULL)
3653 {
3654 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3655
3656 show_ip_ospf_database_header (vty, lsa);
3657
3658 vty_out (vty, " Network Mask: /%d%s",
3659 ip_masklen (nl->mask), VTY_NEWLINE);
3660
3661 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3662
3663 for (i = 0; length > 0; i++, length -= 4)
3664 vty_out (vty, " Attached Router: %s%s",
3665 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3666
3667 vty_out (vty, "%s", VTY_NEWLINE);
3668 }
3669
3670 return 0;
3671 }
3672
3673 /* Show summary-LSA detail information. */
3674 static int
3675 show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3676 {
3677 if (lsa != NULL)
3678 {
3679 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3680
3681 show_ip_ospf_database_header (vty, lsa);
3682
3683 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3684 VTY_NEWLINE);
3685 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3686 VTY_NEWLINE);
3687 vty_out (vty, "%s", VTY_NEWLINE);
3688 }
3689
3690 return 0;
3691 }
3692
3693 /* Show summary-ASBR-LSA detail information. */
3694 static int
3695 show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3696 {
3697 if (lsa != NULL)
3698 {
3699 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3700
3701 show_ip_ospf_database_header (vty, lsa);
3702
3703 vty_out (vty, " Network Mask: /%d%s",
3704 ip_masklen (sl->mask), VTY_NEWLINE);
3705 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3706 VTY_NEWLINE);
3707 vty_out (vty, "%s", VTY_NEWLINE);
3708 }
3709
3710 return 0;
3711 }
3712
3713 /* Show AS-external-LSA detail information. */
3714 static int
3715 show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3716 {
3717 if (lsa != NULL)
3718 {
3719 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3720
3721 show_ip_ospf_database_header (vty, lsa);
3722
3723 vty_out (vty, " Network Mask: /%d%s",
3724 ip_masklen (al->mask), VTY_NEWLINE);
3725 vty_out (vty, " Metric Type: %s%s",
3726 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3727 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3728 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3729 vty_out (vty, " Metric: %d%s",
3730 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3731 vty_out (vty, " Forward Address: %s%s",
3732 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3733
3734 vty_out (vty, " External Route Tag: %lu%s%s",
3735 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3736 }
3737
3738 return 0;
3739 }
3740
3741 #if 0
3742 static int
3743 show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3744 {
3745 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3746
3747 /* show_ip_ospf_database_header (vty, lsa); */
3748
3749 zlog_debug( " Network Mask: /%d%s",
3750 ip_masklen (al->mask), "\n");
3751 zlog_debug( " Metric Type: %s%s",
3752 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3753 "2 (Larger than any link state path)" : "1", "\n");
3754 zlog_debug( " TOS: 0%s", "\n");
3755 zlog_debug( " Metric: %d%s",
3756 GET_METRIC (al->e[0].metric), "\n");
3757 zlog_debug( " Forward Address: %s%s",
3758 inet_ntoa (al->e[0].fwd_addr), "\n");
3759
3760 zlog_debug( " External Route Tag: %u%s%s",
3761 ntohl (al->e[0].route_tag), "\n", "\n");
3762
3763 return 0;
3764 }
3765 #endif
3766
3767 /* Show AS-NSSA-LSA detail information. */
3768 static int
3769 show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3770 {
3771 if (lsa != NULL)
3772 {
3773 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3774
3775 show_ip_ospf_database_header (vty, lsa);
3776
3777 vty_out (vty, " Network Mask: /%d%s",
3778 ip_masklen (al->mask), VTY_NEWLINE);
3779 vty_out (vty, " Metric Type: %s%s",
3780 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3781 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3782 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3783 vty_out (vty, " Metric: %d%s",
3784 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3785 vty_out (vty, " NSSA: Forward Address: %s%s",
3786 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3787
3788 vty_out (vty, " External Route Tag: %u%s%s",
3789 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3790 }
3791
3792 return 0;
3793 }
3794
3795 static int
3796 show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3797 {
3798 return 0;
3799 }
3800
3801 #ifdef HAVE_OPAQUE_LSA
3802 static int
3803 show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3804 {
3805 if (lsa != NULL)
3806 {
3807 show_ip_ospf_database_header (vty, lsa);
3808 show_opaque_info_detail (vty, lsa);
3809
3810 vty_out (vty, "%s", VTY_NEWLINE);
3811 }
3812 return 0;
3813 }
3814 #endif /* HAVE_OPAQUE_LSA */
3815
3816 int (*show_function[])(struct vty *, struct ospf_lsa *) =
3817 {
3818 NULL,
3819 show_router_lsa_detail,
3820 show_network_lsa_detail,
3821 show_summary_lsa_detail,
3822 show_summary_asbr_lsa_detail,
3823 show_as_external_lsa_detail,
3824 show_func_dummy,
3825 show_as_nssa_lsa_detail, /* almost same as external */
3826 #ifdef HAVE_OPAQUE_LSA
3827 NULL, /* type-8 */
3828 show_opaque_lsa_detail,
3829 show_opaque_lsa_detail,
3830 show_opaque_lsa_detail,
3831 #endif /* HAVE_OPAQUE_LSA */
3832 };
3833
3834 static void
3835 show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3836 struct in_addr *adv_router)
3837 {
3838 memset (lp, 0, sizeof (struct prefix_ls));
3839 lp->family = 0;
3840 if (id == NULL)
3841 lp->prefixlen = 0;
3842 else if (adv_router == NULL)
3843 {
3844 lp->prefixlen = 32;
3845 lp->id = *id;
3846 }
3847 else
3848 {
3849 lp->prefixlen = 64;
3850 lp->id = *id;
3851 lp->adv_router = *adv_router;
3852 }
3853 }
3854
3855 static void
3856 show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3857 struct in_addr *id, struct in_addr *adv_router)
3858 {
3859 struct prefix_ls lp;
3860 struct route_node *rn, *start;
3861 struct ospf_lsa *lsa;
3862
3863 show_lsa_prefix_set (vty, &lp, id, adv_router);
3864 start = route_node_get (rt, (struct prefix *) &lp);
3865 if (start)
3866 {
3867 route_lock_node (start);
3868 for (rn = start; rn; rn = route_next_until (rn, start))
3869 if ((lsa = rn->info))
3870 {
3871 if (show_function[lsa->data->type] != NULL)
3872 show_function[lsa->data->type] (vty, lsa);
3873 }
3874 route_unlock_node (start);
3875 }
3876 }
3877
3878 /* Show detail LSA information
3879 -- if id is NULL then show all LSAs. */
3880 static void
3881 show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
3882 struct in_addr *id, struct in_addr *adv_router)
3883 {
3884 struct listnode *node;
3885 struct ospf_area *area;
3886
3887 switch (type)
3888 {
3889 case OSPF_AS_EXTERNAL_LSA:
3890 #ifdef HAVE_OPAQUE_LSA
3891 case OSPF_OPAQUE_AS_LSA:
3892 #endif /* HAVE_OPAQUE_LSA */
3893 vty_out (vty, " %s %s%s",
3894 show_database_desc[type],
3895 VTY_NEWLINE, VTY_NEWLINE);
3896 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
3897 break;
3898 default:
3899 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
3900 {
3901 vty_out (vty, "%s %s (Area %s)%s%s",
3902 VTY_NEWLINE, show_database_desc[type],
3903 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3904 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3905 }
3906 break;
3907 }
3908 }
3909
3910 static void
3911 show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3912 struct in_addr *adv_router)
3913 {
3914 struct route_node *rn;
3915 struct ospf_lsa *lsa;
3916
3917 for (rn = route_top (rt); rn; rn = route_next (rn))
3918 if ((lsa = rn->info))
3919 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3920 {
3921 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3922 continue;
3923 if (show_function[lsa->data->type] != NULL)
3924 show_function[lsa->data->type] (vty, lsa);
3925 }
3926 }
3927
3928 /* Show detail LSA information. */
3929 static void
3930 show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
3931 struct in_addr *adv_router)
3932 {
3933 struct listnode *node;
3934 struct ospf_area *area;
3935
3936 switch (type)
3937 {
3938 case OSPF_AS_EXTERNAL_LSA:
3939 #ifdef HAVE_OPAQUE_LSA
3940 case OSPF_OPAQUE_AS_LSA:
3941 #endif /* HAVE_OPAQUE_LSA */
3942 vty_out (vty, " %s %s%s",
3943 show_database_desc[type],
3944 VTY_NEWLINE, VTY_NEWLINE);
3945 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
3946 adv_router);
3947 break;
3948 default:
3949 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
3950 {
3951 vty_out (vty, "%s %s (Area %s)%s%s",
3952 VTY_NEWLINE, show_database_desc[type],
3953 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3954 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3955 adv_router);
3956 }
3957 break;
3958 }
3959 }
3960
3961 static void
3962 show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
3963 {
3964 struct ospf_lsa *lsa;
3965 struct route_node *rn;
3966 struct ospf_area *area;
3967 struct listnode *node;
3968 int type;
3969
3970 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
3971 {
3972 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3973 {
3974 switch (type)
3975 {
3976 case OSPF_AS_EXTERNAL_LSA:
3977 #ifdef HAVE_OPAQUE_LSA
3978 case OSPF_OPAQUE_AS_LSA:
3979 #endif /* HAVE_OPAQUE_LSA */
3980 continue;
3981 default:
3982 break;
3983 }
3984 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3985 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3986 {
3987 vty_out (vty, " %s (Area %s)%s%s",
3988 show_database_desc[type],
3989 ospf_area_desc_string (area),
3990 VTY_NEWLINE, VTY_NEWLINE);
3991 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3992
3993 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3994 show_lsa_summary (vty, lsa, self);
3995
3996 vty_out (vty, "%s", VTY_NEWLINE);
3997 }
3998 }
3999 }
4000
4001 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4002 {
4003 switch (type)
4004 {
4005 case OSPF_AS_EXTERNAL_LSA:
4006 #ifdef HAVE_OPAQUE_LSA
4007 case OSPF_OPAQUE_AS_LSA:
4008 #endif /* HAVE_OPAQUE_LSA */
4009 break;
4010 default:
4011 continue;
4012 }
4013 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4014 (!self && ospf_lsdb_count (ospf->lsdb, type)))
4015 {
4016 vty_out (vty, " %s%s%s",
4017 show_database_desc[type],
4018 VTY_NEWLINE, VTY_NEWLINE);
4019 vty_out (vty, "%s%s", show_database_header[type],
4020 VTY_NEWLINE);
4021
4022 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4023 show_lsa_summary (vty, lsa, self);
4024
4025 vty_out (vty, "%s", VTY_NEWLINE);
4026 }
4027 }
4028
4029 vty_out (vty, "%s", VTY_NEWLINE);
4030 }
4031
4032 static void
4033 show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
4034 {
4035 struct listnode *node;
4036 struct ospf_lsa *lsa;
4037
4038 vty_out (vty, "%s MaxAge Link States:%s%s",
4039 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4040
4041 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
4042 {
4043 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4044 vty_out (vty, "Link State ID: %s%s",
4045 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4046 vty_out (vty, "Advertising Router: %s%s",
4047 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4048 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4049 vty_out (vty, "%s", VTY_NEWLINE);
4050 }
4051 }
4052
4053 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4054 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
4055
4056 #ifdef HAVE_OPAQUE_LSA
4057 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4058 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4059 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4060 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4061 #else /* HAVE_OPAQUE_LSA */
4062 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4063 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4064 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4065 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4066 #endif /* HAVE_OPAQUE_LSA */
4067
4068 #define OSPF_LSA_TYPES_CMD_STR \
4069 "asbr-summary|external|network|router|summary" \
4070 OSPF_LSA_TYPE_NSSA_CMD_STR \
4071 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4072
4073 #define OSPF_LSA_TYPES_DESC \
4074 "ASBR summary link states\n" \
4075 "External link states\n" \
4076 "Network link states\n" \
4077 "Router link states\n" \
4078 "Network summary link states\n" \
4079 OSPF_LSA_TYPE_NSSA_DESC \
4080 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4081 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4082 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4083
4084 DEFUN (show_ip_ospf_database,
4085 show_ip_ospf_database_cmd,
4086 "show ip ospf database",
4087 SHOW_STR
4088 IP_STR
4089 "OSPF information\n"
4090 "Database summary\n")
4091 {
4092 struct ospf *ospf;
4093 int type, ret;
4094 struct in_addr id, adv_router;
4095
4096 ospf = ospf_lookup ();
4097 if (ospf == NULL)
4098 {
4099 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4100 return CMD_SUCCESS;
4101 }
4102
4103 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
4104 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
4105
4106 /* Show all LSA. */
4107 if (argc == 0)
4108 {
4109 show_ip_ospf_database_summary (vty, ospf, 0);
4110 return CMD_SUCCESS;
4111 }
4112
4113 /* Set database type to show. */
4114 if (strncmp (argv[0], "r", 1) == 0)
4115 type = OSPF_ROUTER_LSA;
4116 else if (strncmp (argv[0], "ne", 2) == 0)
4117 type = OSPF_NETWORK_LSA;
4118 else if (strncmp (argv[0], "ns", 2) == 0)
4119 type = OSPF_AS_NSSA_LSA;
4120 else if (strncmp (argv[0], "su", 2) == 0)
4121 type = OSPF_SUMMARY_LSA;
4122 else if (strncmp (argv[0], "a", 1) == 0)
4123 type = OSPF_ASBR_SUMMARY_LSA;
4124 else if (strncmp (argv[0], "e", 1) == 0)
4125 type = OSPF_AS_EXTERNAL_LSA;
4126 else if (strncmp (argv[0], "se", 2) == 0)
4127 {
4128 show_ip_ospf_database_summary (vty, ospf, 1);
4129 return CMD_SUCCESS;
4130 }
4131 else if (strncmp (argv[0], "m", 1) == 0)
4132 {
4133 show_ip_ospf_database_maxage (vty, ospf);
4134 return CMD_SUCCESS;
4135 }
4136 #ifdef HAVE_OPAQUE_LSA
4137 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4138 type = OSPF_OPAQUE_LINK_LSA;
4139 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4140 type = OSPF_OPAQUE_AREA_LSA;
4141 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4142 type = OSPF_OPAQUE_AS_LSA;
4143 #endif /* HAVE_OPAQUE_LSA */
4144 else
4145 return CMD_WARNING;
4146
4147 /* `show ip ospf database LSA'. */
4148 if (argc == 1)
4149 show_lsa_detail (vty, ospf, type, NULL, NULL);
4150 else if (argc >= 2)
4151 {
4152 ret = inet_aton (argv[1], &id);
4153 if (!ret)
4154 return CMD_WARNING;
4155
4156 /* `show ip ospf database LSA ID'. */
4157 if (argc == 2)
4158 show_lsa_detail (vty, ospf, type, &id, NULL);
4159 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4160 else if (argc == 3)
4161 {
4162 if (strncmp (argv[2], "s", 1) == 0)
4163 adv_router = ospf->router_id;
4164 else
4165 {
4166 ret = inet_aton (argv[2], &adv_router);
4167 if (!ret)
4168 return CMD_WARNING;
4169 }
4170 show_lsa_detail (vty, ospf, type, &id, &adv_router);
4171 }
4172 }
4173
4174 return CMD_SUCCESS;
4175 }
4176
4177 ALIAS (show_ip_ospf_database,
4178 show_ip_ospf_database_type_cmd,
4179 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4180 SHOW_STR
4181 IP_STR
4182 "OSPF information\n"
4183 "Database summary\n"
4184 OSPF_LSA_TYPES_DESC
4185 "LSAs in MaxAge list\n"
4186 "Self-originated link states\n")
4187
4188 ALIAS (show_ip_ospf_database,
4189 show_ip_ospf_database_type_id_cmd,
4190 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4191 SHOW_STR
4192 IP_STR
4193 "OSPF information\n"
4194 "Database summary\n"
4195 OSPF_LSA_TYPES_DESC
4196 "Link State ID (as an IP address)\n")
4197
4198 ALIAS (show_ip_ospf_database,
4199 show_ip_ospf_database_type_id_adv_router_cmd,
4200 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4201 SHOW_STR
4202 IP_STR
4203 "OSPF information\n"
4204 "Database summary\n"
4205 OSPF_LSA_TYPES_DESC
4206 "Link State ID (as an IP address)\n"
4207 "Advertising Router link states\n"
4208 "Advertising Router (as an IP address)\n")
4209
4210 ALIAS (show_ip_ospf_database,
4211 show_ip_ospf_database_type_id_self_cmd,
4212 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4213 SHOW_STR
4214 IP_STR
4215 "OSPF information\n"
4216 "Database summary\n"
4217 OSPF_LSA_TYPES_DESC
4218 "Link State ID (as an IP address)\n"
4219 "Self-originated link states\n"
4220 "\n")
4221
4222 DEFUN (show_ip_ospf_database_type_adv_router,
4223 show_ip_ospf_database_type_adv_router_cmd,
4224 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4225 SHOW_STR
4226 IP_STR
4227 "OSPF information\n"
4228 "Database summary\n"
4229 OSPF_LSA_TYPES_DESC
4230 "Advertising Router link states\n"
4231 "Advertising Router (as an IP address)\n")
4232 {
4233 struct ospf *ospf;
4234 int type, ret;
4235 struct in_addr adv_router;
4236
4237 ospf = ospf_lookup ();
4238 if (ospf == NULL)
4239 {
4240 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4241 return CMD_SUCCESS;
4242 }
4243
4244 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
4245 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
4246
4247 if (argc != 2)
4248 return CMD_WARNING;
4249
4250 /* Set database type to show. */
4251 if (strncmp (argv[0], "r", 1) == 0)
4252 type = OSPF_ROUTER_LSA;
4253 else if (strncmp (argv[0], "ne", 2) == 0)
4254 type = OSPF_NETWORK_LSA;
4255 else if (strncmp (argv[0], "ns", 2) == 0)
4256 type = OSPF_AS_NSSA_LSA;
4257 else if (strncmp (argv[0], "s", 1) == 0)
4258 type = OSPF_SUMMARY_LSA;
4259 else if (strncmp (argv[0], "a", 1) == 0)
4260 type = OSPF_ASBR_SUMMARY_LSA;
4261 else if (strncmp (argv[0], "e", 1) == 0)
4262 type = OSPF_AS_EXTERNAL_LSA;
4263 #ifdef HAVE_OPAQUE_LSA
4264 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4265 type = OSPF_OPAQUE_LINK_LSA;
4266 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4267 type = OSPF_OPAQUE_AREA_LSA;
4268 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4269 type = OSPF_OPAQUE_AS_LSA;
4270 #endif /* HAVE_OPAQUE_LSA */
4271 else
4272 return CMD_WARNING;
4273
4274 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4275 if (strncmp (argv[1], "s", 1) == 0)
4276 adv_router = ospf->router_id;
4277 else
4278 {
4279 ret = inet_aton (argv[1], &adv_router);
4280 if (!ret)
4281 return CMD_WARNING;
4282 }
4283
4284 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
4285
4286 return CMD_SUCCESS;
4287 }
4288
4289 ALIAS (show_ip_ospf_database_type_adv_router,
4290 show_ip_ospf_database_type_self_cmd,
4291 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4292 SHOW_STR
4293 IP_STR
4294 "OSPF information\n"
4295 "Database summary\n"
4296 OSPF_LSA_TYPES_DESC
4297 "Self-originated link states\n")
4298
4299 \f
4300 DEFUN (ip_ospf_authentication_args,
4301 ip_ospf_authentication_args_addr_cmd,
4302 "ip ospf authentication (null|message-digest) A.B.C.D",
4303 "IP Information\n"
4304 "OSPF interface commands\n"
4305 "Enable authentication on this interface\n"
4306 "Use null authentication\n"
4307 "Use message-digest authentication\n"
4308 "Address of interface")
4309 {
4310 struct interface *ifp;
4311 struct in_addr addr;
4312 int ret;
4313 struct ospf_if_params *params;
4314
4315 ifp = vty->index;
4316 params = IF_DEF_PARAMS (ifp);
4317
4318 if (argc == 2)
4319 {
4320 ret = inet_aton(argv[1], &addr);
4321 if (!ret)
4322 {
4323 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4324 VTY_NEWLINE);
4325 return CMD_WARNING;
4326 }
4327
4328 params = ospf_get_if_params (ifp, addr);
4329 ospf_if_update_params (ifp, addr);
4330 }
4331
4332 /* Handle null authentication */
4333 if ( argv[0][0] == 'n' )
4334 {
4335 SET_IF_PARAM (params, auth_type);
4336 params->auth_type = OSPF_AUTH_NULL;
4337 return CMD_SUCCESS;
4338 }
4339
4340 /* Handle message-digest authentication */
4341 if ( argv[0][0] == 'm' )
4342 {
4343 SET_IF_PARAM (params, auth_type);
4344 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4345 return CMD_SUCCESS;
4346 }
4347
4348 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4349 return CMD_WARNING;
4350 }
4351
4352 ALIAS (ip_ospf_authentication_args,
4353 ip_ospf_authentication_args_cmd,
4354 "ip ospf authentication (null|message-digest)",
4355 "IP Information\n"
4356 "OSPF interface commands\n"
4357 "Enable authentication on this interface\n"
4358 "Use null authentication\n"
4359 "Use message-digest authentication\n")
4360
4361 DEFUN (ip_ospf_authentication,
4362 ip_ospf_authentication_addr_cmd,
4363 "ip ospf authentication A.B.C.D",
4364 "IP Information\n"
4365 "OSPF interface commands\n"
4366 "Enable authentication on this interface\n"
4367 "Address of interface")
4368 {
4369 struct interface *ifp;
4370 struct in_addr addr;
4371 int ret;
4372 struct ospf_if_params *params;
4373
4374 ifp = vty->index;
4375 params = IF_DEF_PARAMS (ifp);
4376
4377 if (argc == 1)
4378 {
4379 ret = inet_aton(argv[0], &addr);
4380 if (!ret)
4381 {
4382 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4383 VTY_NEWLINE);
4384 return CMD_WARNING;
4385 }
4386
4387 params = ospf_get_if_params (ifp, addr);
4388 ospf_if_update_params (ifp, addr);
4389 }
4390
4391 SET_IF_PARAM (params, auth_type);
4392 params->auth_type = OSPF_AUTH_SIMPLE;
4393
4394 return CMD_SUCCESS;
4395 }
4396
4397 ALIAS (ip_ospf_authentication,
4398 ip_ospf_authentication_cmd,
4399 "ip ospf authentication",
4400 "IP Information\n"
4401 "OSPF interface commands\n"
4402 "Enable authentication on this interface\n")
4403
4404 DEFUN (no_ip_ospf_authentication,
4405 no_ip_ospf_authentication_addr_cmd,
4406 "no ip ospf authentication A.B.C.D",
4407 NO_STR
4408 "IP Information\n"
4409 "OSPF interface commands\n"
4410 "Enable authentication on this interface\n"
4411 "Address of interface")
4412 {
4413 struct interface *ifp;
4414 struct in_addr addr;
4415 int ret;
4416 struct ospf_if_params *params;
4417
4418 ifp = vty->index;
4419 params = IF_DEF_PARAMS (ifp);
4420
4421 if (argc == 1)
4422 {
4423 ret = inet_aton(argv[0], &addr);
4424 if (!ret)
4425 {
4426 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4427 VTY_NEWLINE);
4428 return CMD_WARNING;
4429 }
4430
4431 params = ospf_lookup_if_params (ifp, addr);
4432 if (params == NULL)
4433 return CMD_SUCCESS;
4434 }
4435
4436 params->auth_type = OSPF_AUTH_NOTSET;
4437 UNSET_IF_PARAM (params, auth_type);
4438
4439 if (params != IF_DEF_PARAMS (ifp))
4440 {
4441 ospf_free_if_params (ifp, addr);
4442 ospf_if_update_params (ifp, addr);
4443 }
4444
4445 return CMD_SUCCESS;
4446 }
4447
4448 ALIAS (no_ip_ospf_authentication,
4449 no_ip_ospf_authentication_cmd,
4450 "no ip ospf authentication",
4451 NO_STR
4452 "IP Information\n"
4453 "OSPF interface commands\n"
4454 "Enable authentication on this interface\n")
4455
4456 DEFUN (ip_ospf_authentication_key,
4457 ip_ospf_authentication_key_addr_cmd,
4458 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4459 "IP Information\n"
4460 "OSPF interface commands\n"
4461 "Authentication password (key)\n"
4462 "The OSPF password (key)\n"
4463 "Address of interface")
4464 {
4465 struct interface *ifp;
4466 struct in_addr addr;
4467 int ret;
4468 struct ospf_if_params *params;
4469
4470 ifp = vty->index;
4471 params = IF_DEF_PARAMS (ifp);
4472
4473 if (argc == 2)
4474 {
4475 ret = inet_aton(argv[1], &addr);
4476 if (!ret)
4477 {
4478 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4479 VTY_NEWLINE);
4480 return CMD_WARNING;
4481 }
4482
4483 params = ospf_get_if_params (ifp, addr);
4484 ospf_if_update_params (ifp, addr);
4485 }
4486
4487
4488 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
4489 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
4490 SET_IF_PARAM (params, auth_simple);
4491
4492 return CMD_SUCCESS;
4493 }
4494
4495 ALIAS (ip_ospf_authentication_key,
4496 ip_ospf_authentication_key_cmd,
4497 "ip ospf authentication-key AUTH_KEY",
4498 "IP Information\n"
4499 "OSPF interface commands\n"
4500 "Authentication password (key)\n"
4501 "The OSPF password (key)")
4502
4503 ALIAS (ip_ospf_authentication_key,
4504 ospf_authentication_key_cmd,
4505 "ospf authentication-key AUTH_KEY",
4506 "OSPF interface commands\n"
4507 "Authentication password (key)\n"
4508 "The OSPF password (key)")
4509
4510 DEFUN (no_ip_ospf_authentication_key,
4511 no_ip_ospf_authentication_key_addr_cmd,
4512 "no ip ospf authentication-key A.B.C.D",
4513 NO_STR
4514 "IP Information\n"
4515 "OSPF interface commands\n"
4516 "Authentication password (key)\n"
4517 "Address of interface")
4518 {
4519 struct interface *ifp;
4520 struct in_addr addr;
4521 int ret;
4522 struct ospf_if_params *params;
4523
4524 ifp = vty->index;
4525 params = IF_DEF_PARAMS (ifp);
4526
4527 if (argc == 1)
4528 {
4529 ret = inet_aton(argv[0], &addr);
4530 if (!ret)
4531 {
4532 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4533 VTY_NEWLINE);
4534 return CMD_WARNING;
4535 }
4536
4537 params = ospf_lookup_if_params (ifp, addr);
4538 if (params == NULL)
4539 return CMD_SUCCESS;
4540 }
4541
4542 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4543 UNSET_IF_PARAM (params, auth_simple);
4544
4545 if (params != IF_DEF_PARAMS (ifp))
4546 {
4547 ospf_free_if_params (ifp, addr);
4548 ospf_if_update_params (ifp, addr);
4549 }
4550
4551 return CMD_SUCCESS;
4552 }
4553
4554 ALIAS (no_ip_ospf_authentication_key,
4555 no_ip_ospf_authentication_key_cmd,
4556 "no ip ospf authentication-key",
4557 NO_STR
4558 "IP Information\n"
4559 "OSPF interface commands\n"
4560 "Authentication password (key)\n")
4561
4562 ALIAS (no_ip_ospf_authentication_key,
4563 no_ospf_authentication_key_cmd,
4564 "no ospf authentication-key",
4565 NO_STR
4566 "OSPF interface commands\n"
4567 "Authentication password (key)\n")
4568
4569 DEFUN (ip_ospf_message_digest_key,
4570 ip_ospf_message_digest_key_addr_cmd,
4571 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4572 "IP Information\n"
4573 "OSPF interface commands\n"
4574 "Message digest authentication password (key)\n"
4575 "Key ID\n"
4576 "Use MD5 algorithm\n"
4577 "The OSPF password (key)"
4578 "Address of interface")
4579 {
4580 struct interface *ifp;
4581 struct crypt_key *ck;
4582 u_char key_id;
4583 struct in_addr addr;
4584 int ret;
4585 struct ospf_if_params *params;
4586
4587 ifp = vty->index;
4588 params = IF_DEF_PARAMS (ifp);
4589
4590 if (argc == 3)
4591 {
4592 ret = inet_aton(argv[2], &addr);
4593 if (!ret)
4594 {
4595 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4596 VTY_NEWLINE);
4597 return CMD_WARNING;
4598 }
4599
4600 params = ospf_get_if_params (ifp, addr);
4601 ospf_if_update_params (ifp, addr);
4602 }
4603
4604 key_id = strtol (argv[0], NULL, 10);
4605 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4606 {
4607 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4608 return CMD_WARNING;
4609 }
4610
4611 ck = ospf_crypt_key_new ();
4612 ck->key_id = (u_char) key_id;
4613 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
4614 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
4615
4616 ospf_crypt_key_add (params->auth_crypt, ck);
4617 SET_IF_PARAM (params, auth_crypt);
4618
4619 return CMD_SUCCESS;
4620 }
4621
4622 ALIAS (ip_ospf_message_digest_key,
4623 ip_ospf_message_digest_key_cmd,
4624 "ip ospf message-digest-key <1-255> md5 KEY",
4625 "IP Information\n"
4626 "OSPF interface commands\n"
4627 "Message digest authentication password (key)\n"
4628 "Key ID\n"
4629 "Use MD5 algorithm\n"
4630 "The OSPF password (key)")
4631
4632 ALIAS (ip_ospf_message_digest_key,
4633 ospf_message_digest_key_cmd,
4634 "ospf message-digest-key <1-255> md5 KEY",
4635 "OSPF interface commands\n"
4636 "Message digest authentication password (key)\n"
4637 "Key ID\n"
4638 "Use MD5 algorithm\n"
4639 "The OSPF password (key)")
4640
4641 DEFUN (no_ip_ospf_message_digest_key,
4642 no_ip_ospf_message_digest_key_addr_cmd,
4643 "no ip ospf message-digest-key <1-255> A.B.C.D",
4644 NO_STR
4645 "IP Information\n"
4646 "OSPF interface commands\n"
4647 "Message digest authentication password (key)\n"
4648 "Key ID\n"
4649 "Address of interface")
4650 {
4651 struct interface *ifp;
4652 struct crypt_key *ck;
4653 int key_id;
4654 struct in_addr addr;
4655 int ret;
4656 struct ospf_if_params *params;
4657
4658 ifp = vty->index;
4659 params = IF_DEF_PARAMS (ifp);
4660
4661 if (argc == 2)
4662 {
4663 ret = inet_aton(argv[1], &addr);
4664 if (!ret)
4665 {
4666 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4667 VTY_NEWLINE);
4668 return CMD_WARNING;
4669 }
4670
4671 params = ospf_lookup_if_params (ifp, addr);
4672 if (params == NULL)
4673 return CMD_SUCCESS;
4674 }
4675
4676 key_id = strtol (argv[0], NULL, 10);
4677 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4678 if (ck == NULL)
4679 {
4680 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4681 return CMD_WARNING;
4682 }
4683
4684 ospf_crypt_key_delete (params->auth_crypt, key_id);
4685
4686 if (params != IF_DEF_PARAMS (ifp))
4687 {
4688 ospf_free_if_params (ifp, addr);
4689 ospf_if_update_params (ifp, addr);
4690 }
4691
4692 return CMD_SUCCESS;
4693 }
4694
4695 ALIAS (no_ip_ospf_message_digest_key,
4696 no_ip_ospf_message_digest_key_cmd,
4697 "no ip ospf message-digest-key <1-255>",
4698 NO_STR
4699 "IP Information\n"
4700 "OSPF interface commands\n"
4701 "Message digest authentication password (key)\n"
4702 "Key ID\n")
4703
4704 ALIAS (no_ip_ospf_message_digest_key,
4705 no_ospf_message_digest_key_cmd,
4706 "no ospf message-digest-key <1-255>",
4707 NO_STR
4708 "OSPF interface commands\n"
4709 "Message digest authentication password (key)\n"
4710 "Key ID\n")
4711
4712 DEFUN (ip_ospf_cost,
4713 ip_ospf_cost_u32_inet4_cmd,
4714 "ip ospf cost <1-65535> A.B.C.D",
4715 "IP Information\n"
4716 "OSPF interface commands\n"
4717 "Interface cost\n"
4718 "Cost\n"
4719 "Address of interface")
4720 {
4721 struct interface *ifp = vty->index;
4722 u_int32_t cost;
4723 struct in_addr addr;
4724 int ret;
4725 struct ospf_if_params *params;
4726
4727 params = IF_DEF_PARAMS (ifp);
4728
4729 cost = strtol (argv[0], NULL, 10);
4730
4731 /* cost range is <1-65535>. */
4732 if (cost < 1 || cost > 65535)
4733 {
4734 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4735 return CMD_WARNING;
4736 }
4737
4738 if (argc == 2)
4739 {
4740 ret = inet_aton(argv[1], &addr);
4741 if (!ret)
4742 {
4743 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4744 VTY_NEWLINE);
4745 return CMD_WARNING;
4746 }
4747
4748 params = ospf_get_if_params (ifp, addr);
4749 ospf_if_update_params (ifp, addr);
4750 }
4751
4752 SET_IF_PARAM (params, output_cost_cmd);
4753 params->output_cost_cmd = cost;
4754
4755 ospf_if_recalculate_output_cost (ifp);
4756
4757 return CMD_SUCCESS;
4758 }
4759
4760 ALIAS (ip_ospf_cost,
4761 ip_ospf_cost_u32_cmd,
4762 "ip ospf cost <1-65535>",
4763 "IP Information\n"
4764 "OSPF interface commands\n"
4765 "Interface cost\n"
4766 "Cost")
4767
4768 ALIAS (ip_ospf_cost,
4769 ospf_cost_u32_cmd,
4770 "ospf cost <1-65535>",
4771 "OSPF interface commands\n"
4772 "Interface cost\n"
4773 "Cost")
4774
4775 ALIAS (ip_ospf_cost,
4776 ospf_cost_u32_inet4_cmd,
4777 "ospf cost <1-65535> A.B.C.D",
4778 "OSPF interface commands\n"
4779 "Interface cost\n"
4780 "Cost\n"
4781 "Address of interface")
4782
4783 DEFUN (no_ip_ospf_cost,
4784 no_ip_ospf_cost_inet4_cmd,
4785 "no ip ospf cost A.B.C.D",
4786 NO_STR
4787 "IP Information\n"
4788 "OSPF interface commands\n"
4789 "Interface cost\n"
4790 "Address of interface")
4791 {
4792 struct interface *ifp = vty->index;
4793 struct in_addr addr;
4794 int ret;
4795 struct ospf_if_params *params;
4796
4797 ifp = vty->index;
4798 params = IF_DEF_PARAMS (ifp);
4799
4800 if (argc == 1)
4801 {
4802 ret = inet_aton(argv[0], &addr);
4803 if (!ret)
4804 {
4805 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4806 VTY_NEWLINE);
4807 return CMD_WARNING;
4808 }
4809
4810 params = ospf_lookup_if_params (ifp, addr);
4811 if (params == NULL)
4812 return CMD_SUCCESS;
4813 }
4814
4815 UNSET_IF_PARAM (params, output_cost_cmd);
4816
4817 if (params != IF_DEF_PARAMS (ifp))
4818 {
4819 ospf_free_if_params (ifp, addr);
4820 ospf_if_update_params (ifp, addr);
4821 }
4822
4823 ospf_if_recalculate_output_cost (ifp);
4824
4825 return CMD_SUCCESS;
4826 }
4827
4828 ALIAS (no_ip_ospf_cost,
4829 no_ip_ospf_cost_cmd,
4830 "no ip ospf cost",
4831 NO_STR
4832 "IP Information\n"
4833 "OSPF interface commands\n"
4834 "Interface cost\n")
4835
4836 ALIAS (no_ip_ospf_cost,
4837 no_ospf_cost_cmd,
4838 "no ospf cost",
4839 NO_STR
4840 "OSPF interface commands\n"
4841 "Interface cost\n")
4842
4843 ALIAS (no_ip_ospf_cost,
4844 no_ospf_cost_inet4_cmd,
4845 "no ospf cost A.B.C.D",
4846 NO_STR
4847 "OSPF interface commands\n"
4848 "Interface cost\n"
4849 "Address of interface")
4850
4851 DEFUN (no_ip_ospf_cost2,
4852 no_ip_ospf_cost_u32_cmd,
4853 "no ip ospf cost <1-65535>",
4854 NO_STR
4855 "IP Information\n"
4856 "OSPF interface commands\n"
4857 "Interface cost\n"
4858 "Cost")
4859 {
4860 struct interface *ifp = vty->index;
4861 struct in_addr addr;
4862 u_int32_t cost;
4863 int ret;
4864 struct ospf_if_params *params;
4865
4866 ifp = vty->index;
4867 params = IF_DEF_PARAMS (ifp);
4868
4869 /* According to the semantics we are mimicking "no ip ospf cost N" is
4870 * always treated as "no ip ospf cost" regardless of the actual value
4871 * of N already configured for the interface. Thus the first argument
4872 * is always checked to be a number, but is ignored after that.
4873 */
4874 cost = strtol (argv[0], NULL, 10);
4875 if (cost < 1 || cost > 65535)
4876 {
4877 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4878 return CMD_WARNING;
4879 }
4880
4881 if (argc == 2)
4882 {
4883 ret = inet_aton(argv[1], &addr);
4884 if (!ret)
4885 {
4886 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4887 VTY_NEWLINE);
4888 return CMD_WARNING;
4889 }
4890
4891 params = ospf_lookup_if_params (ifp, addr);
4892 if (params == NULL)
4893 return CMD_SUCCESS;
4894 }
4895
4896 UNSET_IF_PARAM (params, output_cost_cmd);
4897
4898 if (params != IF_DEF_PARAMS (ifp))
4899 {
4900 ospf_free_if_params (ifp, addr);
4901 ospf_if_update_params (ifp, addr);
4902 }
4903
4904 ospf_if_recalculate_output_cost (ifp);
4905
4906 return CMD_SUCCESS;
4907 }
4908
4909 ALIAS (no_ip_ospf_cost2,
4910 no_ospf_cost_u32_cmd,
4911 "no ospf cost <1-65535>",
4912 NO_STR
4913 "OSPF interface commands\n"
4914 "Interface cost\n"
4915 "Cost")
4916
4917 ALIAS (no_ip_ospf_cost2,
4918 no_ip_ospf_cost_u32_inet4_cmd,
4919 "no ip ospf cost <1-65535> A.B.C.D",
4920 NO_STR
4921 "IP Information\n"
4922 "OSPF interface commands\n"
4923 "Interface cost\n"
4924 "Cost\n"
4925 "Address of interface")
4926
4927 ALIAS (no_ip_ospf_cost2,
4928 no_ospf_cost_u32_inet4_cmd,
4929 "no ospf cost <1-65535> A.B.C.D",
4930 NO_STR
4931 "OSPF interface commands\n"
4932 "Interface cost\n"
4933 "Cost\n"
4934 "Address of interface")
4935
4936 static void
4937 ospf_nbr_timer_update (struct ospf_interface *oi)
4938 {
4939 struct route_node *rn;
4940 struct ospf_neighbor *nbr;
4941
4942 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4943 if ((nbr = rn->info))
4944 {
4945 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4946 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4947 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4948 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4949 }
4950 }
4951
4952 static int
4953 ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4954 const char *nbr_str,
4955 const char *fast_hello_str)
4956 {
4957 struct interface *ifp = vty->index;
4958 u_int32_t seconds;
4959 u_char hellomult;
4960 struct in_addr addr;
4961 int ret;
4962 struct ospf_if_params *params;
4963 struct ospf_interface *oi;
4964 struct route_node *rn;
4965
4966 params = IF_DEF_PARAMS (ifp);
4967
4968 if (nbr_str)
4969 {
4970 ret = inet_aton(nbr_str, &addr);
4971 if (!ret)
4972 {
4973 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4974 VTY_NEWLINE);
4975 return CMD_WARNING;
4976 }
4977
4978 params = ospf_get_if_params (ifp, addr);
4979 ospf_if_update_params (ifp, addr);
4980 }
4981
4982 if (interval_str)
4983 {
4984 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4985 1, 65535);
4986
4987 /* reset fast_hello too, just to be sure */
4988 UNSET_IF_PARAM (params, fast_hello);
4989 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4990 }
4991 else if (fast_hello_str)
4992 {
4993 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4994 1, 10);
4995 /* 1s dead-interval with sub-second hellos desired */
4996 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4997 SET_IF_PARAM (params, fast_hello);
4998 params->fast_hello = hellomult;
4999 }
5000 else
5001 {
5002 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5003 VTY_NEWLINE);
5004 return CMD_WARNING;
5005 }
5006
5007 SET_IF_PARAM (params, v_wait);
5008 params->v_wait = seconds;
5009
5010 /* Update timer values in neighbor structure. */
5011 if (nbr_str)
5012 {
5013 struct ospf *ospf;
5014 if ((ospf = ospf_lookup()))
5015 {
5016 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5017 if (oi)
5018 ospf_nbr_timer_update (oi);
5019 }
5020 }
5021 else
5022 {
5023 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5024 if ((oi = rn->info))
5025 ospf_nbr_timer_update (oi);
5026 }
5027
5028 return CMD_SUCCESS;
5029 }
5030
5031
5032 DEFUN (ip_ospf_dead_interval,
5033 ip_ospf_dead_interval_addr_cmd,
5034 "ip ospf dead-interval <1-65535> A.B.C.D",
5035 "IP Information\n"
5036 "OSPF interface commands\n"
5037 "Interval after which a neighbor is declared dead\n"
5038 "Seconds\n"
5039 "Address of interface\n")
5040 {
5041 if (argc == 2)
5042 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5043 else
5044 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5045 }
5046
5047 ALIAS (ip_ospf_dead_interval,
5048 ip_ospf_dead_interval_cmd,
5049 "ip ospf dead-interval <1-65535>",
5050 "IP Information\n"
5051 "OSPF interface commands\n"
5052 "Interval after which a neighbor is declared dead\n"
5053 "Seconds\n")
5054
5055 ALIAS (ip_ospf_dead_interval,
5056 ospf_dead_interval_cmd,
5057 "ospf dead-interval <1-65535>",
5058 "OSPF interface commands\n"
5059 "Interval after which a neighbor is declared dead\n"
5060 "Seconds\n")
5061
5062 DEFUN (ip_ospf_dead_interval_minimal,
5063 ip_ospf_dead_interval_minimal_addr_cmd,
5064 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5065 "IP Information\n"
5066 "OSPF interface commands\n"
5067 "Interval after which a neighbor is declared dead\n"
5068 "Minimal 1s dead-interval with fast sub-second hellos\n"
5069 "Hello multiplier factor\n"
5070 "Number of Hellos to send each second\n"
5071 "Address of interface\n")
5072 {
5073 if (argc == 2)
5074 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5075 else
5076 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5077 }
5078
5079 ALIAS (ip_ospf_dead_interval_minimal,
5080 ip_ospf_dead_interval_minimal_cmd,
5081 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5082 "IP Information\n"
5083 "OSPF interface commands\n"
5084 "Interval after which a neighbor is declared dead\n"
5085 "Minimal 1s dead-interval with fast sub-second hellos\n"
5086 "Hello multiplier factor\n"
5087 "Number of Hellos to send each second\n")
5088
5089 DEFUN (no_ip_ospf_dead_interval,
5090 no_ip_ospf_dead_interval_addr_cmd,
5091 "no ip ospf dead-interval A.B.C.D",
5092 NO_STR
5093 "IP Information\n"
5094 "OSPF interface commands\n"
5095 "Interval after which a neighbor is declared dead\n"
5096 "Address of interface")
5097 {
5098 struct interface *ifp = vty->index;
5099 struct in_addr addr;
5100 int ret;
5101 struct ospf_if_params *params;
5102 struct ospf_interface *oi;
5103 struct route_node *rn;
5104
5105 ifp = vty->index;
5106 params = IF_DEF_PARAMS (ifp);
5107
5108 if (argc == 1)
5109 {
5110 ret = inet_aton(argv[0], &addr);
5111 if (!ret)
5112 {
5113 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5114 VTY_NEWLINE);
5115 return CMD_WARNING;
5116 }
5117
5118 params = ospf_lookup_if_params (ifp, addr);
5119 if (params == NULL)
5120 return CMD_SUCCESS;
5121 }
5122
5123 UNSET_IF_PARAM (params, v_wait);
5124 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
5125
5126 UNSET_IF_PARAM (params, fast_hello);
5127 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5128
5129 if (params != IF_DEF_PARAMS (ifp))
5130 {
5131 ospf_free_if_params (ifp, addr);
5132 ospf_if_update_params (ifp, addr);
5133 }
5134
5135 /* Update timer values in neighbor structure. */
5136 if (argc == 1)
5137 {
5138 struct ospf *ospf;
5139
5140 if ((ospf = ospf_lookup()))
5141 {
5142 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5143 if (oi)
5144 ospf_nbr_timer_update (oi);
5145 }
5146 }
5147 else
5148 {
5149 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5150 if ((oi = rn->info))
5151 ospf_nbr_timer_update (oi);
5152 }
5153
5154 return CMD_SUCCESS;
5155 }
5156
5157 ALIAS (no_ip_ospf_dead_interval,
5158 no_ip_ospf_dead_interval_cmd,
5159 "no ip ospf dead-interval",
5160 NO_STR
5161 "IP Information\n"
5162 "OSPF interface commands\n"
5163 "Interval after which a neighbor is declared dead\n")
5164
5165 ALIAS (no_ip_ospf_dead_interval,
5166 no_ospf_dead_interval_cmd,
5167 "no ospf dead-interval",
5168 NO_STR
5169 "OSPF interface commands\n"
5170 "Interval after which a neighbor is declared dead\n")
5171
5172 DEFUN (ip_ospf_hello_interval,
5173 ip_ospf_hello_interval_addr_cmd,
5174 "ip ospf hello-interval <1-65535> A.B.C.D",
5175 "IP Information\n"
5176 "OSPF interface commands\n"
5177 "Time between HELLO packets\n"
5178 "Seconds\n"
5179 "Address of interface")
5180 {
5181 struct interface *ifp = vty->index;
5182 u_int32_t seconds;
5183 struct in_addr addr;
5184 int ret;
5185 struct ospf_if_params *params;
5186
5187 params = IF_DEF_PARAMS (ifp);
5188
5189 seconds = strtol (argv[0], NULL, 10);
5190
5191 /* HelloInterval range is <1-65535>. */
5192 if (seconds < 1 || seconds > 65535)
5193 {
5194 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5195 return CMD_WARNING;
5196 }
5197
5198 if (argc == 2)
5199 {
5200 ret = inet_aton(argv[1], &addr);
5201 if (!ret)
5202 {
5203 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5204 VTY_NEWLINE);
5205 return CMD_WARNING;
5206 }
5207
5208 params = ospf_get_if_params (ifp, addr);
5209 ospf_if_update_params (ifp, addr);
5210 }
5211
5212 SET_IF_PARAM (params, v_hello);
5213 params->v_hello = seconds;
5214
5215 return CMD_SUCCESS;
5216 }
5217
5218 ALIAS (ip_ospf_hello_interval,
5219 ip_ospf_hello_interval_cmd,
5220 "ip ospf hello-interval <1-65535>",
5221 "IP Information\n"
5222 "OSPF interface commands\n"
5223 "Time between HELLO packets\n"
5224 "Seconds\n")
5225
5226 ALIAS (ip_ospf_hello_interval,
5227 ospf_hello_interval_cmd,
5228 "ospf hello-interval <1-65535>",
5229 "OSPF interface commands\n"
5230 "Time between HELLO packets\n"
5231 "Seconds\n")
5232
5233 DEFUN (no_ip_ospf_hello_interval,
5234 no_ip_ospf_hello_interval_addr_cmd,
5235 "no ip ospf hello-interval A.B.C.D",
5236 NO_STR
5237 "IP Information\n"
5238 "OSPF interface commands\n"
5239 "Time between HELLO packets\n"
5240 "Address of interface")
5241 {
5242 struct interface *ifp = vty->index;
5243 struct in_addr addr;
5244 int ret;
5245 struct ospf_if_params *params;
5246
5247 ifp = vty->index;
5248 params = IF_DEF_PARAMS (ifp);
5249
5250 if (argc == 1)
5251 {
5252 ret = inet_aton(argv[0], &addr);
5253 if (!ret)
5254 {
5255 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5256 VTY_NEWLINE);
5257 return CMD_WARNING;
5258 }
5259
5260 params = ospf_lookup_if_params (ifp, addr);
5261 if (params == NULL)
5262 return CMD_SUCCESS;
5263 }
5264
5265 UNSET_IF_PARAM (params, v_hello);
5266 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
5267
5268 if (params != IF_DEF_PARAMS (ifp))
5269 {
5270 ospf_free_if_params (ifp, addr);
5271 ospf_if_update_params (ifp, addr);
5272 }
5273
5274 return CMD_SUCCESS;
5275 }
5276
5277 ALIAS (no_ip_ospf_hello_interval,
5278 no_ip_ospf_hello_interval_cmd,
5279 "no ip ospf hello-interval",
5280 NO_STR
5281 "IP Information\n"
5282 "OSPF interface commands\n"
5283 "Time between HELLO packets\n")
5284
5285 ALIAS (no_ip_ospf_hello_interval,
5286 no_ospf_hello_interval_cmd,
5287 "no ospf hello-interval",
5288 NO_STR
5289 "OSPF interface commands\n"
5290 "Time between HELLO packets\n")
5291
5292 DEFUN (ip_ospf_network,
5293 ip_ospf_network_cmd,
5294 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5295 "IP Information\n"
5296 "OSPF interface commands\n"
5297 "Network type\n"
5298 "Specify OSPF broadcast multi-access network\n"
5299 "Specify OSPF NBMA network\n"
5300 "Specify OSPF point-to-multipoint network\n"
5301 "Specify OSPF point-to-point network\n")
5302 {
5303 struct interface *ifp = vty->index;
5304 int old_type = IF_DEF_PARAMS (ifp)->type;
5305 struct route_node *rn;
5306
5307 if (strncmp (argv[0], "b", 1) == 0)
5308 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5309 else if (strncmp (argv[0], "n", 1) == 0)
5310 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5311 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5312 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5313 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5314 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5315
5316 if (IF_DEF_PARAMS (ifp)->type == old_type)
5317 return CMD_SUCCESS;
5318
5319 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5320
5321 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5322 {
5323 struct ospf_interface *oi = rn->info;
5324
5325 if (!oi)
5326 continue;
5327
5328 oi->type = IF_DEF_PARAMS (ifp)->type;
5329
5330 if (oi->state > ISM_Down)
5331 {
5332 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5333 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5334 }
5335 }
5336
5337 return CMD_SUCCESS;
5338 }
5339
5340 ALIAS (ip_ospf_network,
5341 ospf_network_cmd,
5342 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5343 "OSPF interface commands\n"
5344 "Network type\n"
5345 "Specify OSPF broadcast multi-access network\n"
5346 "Specify OSPF NBMA network\n"
5347 "Specify OSPF point-to-multipoint network\n"
5348 "Specify OSPF point-to-point network\n")
5349
5350 DEFUN (no_ip_ospf_network,
5351 no_ip_ospf_network_cmd,
5352 "no ip ospf network",
5353 NO_STR
5354 "IP Information\n"
5355 "OSPF interface commands\n"
5356 "Network type\n")
5357 {
5358 struct interface *ifp = vty->index;
5359 int old_type = IF_DEF_PARAMS (ifp)->type;
5360 struct route_node *rn;
5361
5362 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
5363
5364 if (IF_DEF_PARAMS (ifp)->type == old_type)
5365 return CMD_SUCCESS;
5366
5367 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5368 {
5369 struct ospf_interface *oi = rn->info;
5370
5371 if (!oi)
5372 continue;
5373
5374 oi->type = IF_DEF_PARAMS (ifp)->type;
5375
5376 if (oi->state > ISM_Down)
5377 {
5378 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5379 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5380 }
5381 }
5382
5383 return CMD_SUCCESS;
5384 }
5385
5386 ALIAS (no_ip_ospf_network,
5387 no_ospf_network_cmd,
5388 "no ospf network",
5389 NO_STR
5390 "OSPF interface commands\n"
5391 "Network type\n")
5392
5393 DEFUN (ip_ospf_priority,
5394 ip_ospf_priority_addr_cmd,
5395 "ip ospf priority <0-255> A.B.C.D",
5396 "IP Information\n"
5397 "OSPF interface commands\n"
5398 "Router priority\n"
5399 "Priority\n"
5400 "Address of interface")
5401 {
5402 struct interface *ifp = vty->index;
5403 u_int32_t priority;
5404 struct route_node *rn;
5405 struct in_addr addr;
5406 int ret;
5407 struct ospf_if_params *params;
5408
5409 params = IF_DEF_PARAMS (ifp);
5410
5411 priority = strtol (argv[0], NULL, 10);
5412
5413 /* Router Priority range is <0-255>. */
5414 if (priority < 0 || priority > 255)
5415 {
5416 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5417 return CMD_WARNING;
5418 }
5419
5420 if (argc == 2)
5421 {
5422 ret = inet_aton(argv[1], &addr);
5423 if (!ret)
5424 {
5425 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5426 VTY_NEWLINE);
5427 return CMD_WARNING;
5428 }
5429
5430 params = ospf_get_if_params (ifp, addr);
5431 ospf_if_update_params (ifp, addr);
5432 }
5433
5434 SET_IF_PARAM (params, priority);
5435 params->priority = priority;
5436
5437 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5438 {
5439 struct ospf_interface *oi = rn->info;
5440
5441 if (!oi)
5442 continue;
5443
5444
5445 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5446 {
5447 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5448 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5449 }
5450 }
5451
5452 return CMD_SUCCESS;
5453 }
5454
5455 ALIAS (ip_ospf_priority,
5456 ip_ospf_priority_cmd,
5457 "ip ospf priority <0-255>",
5458 "IP Information\n"
5459 "OSPF interface commands\n"
5460 "Router priority\n"
5461 "Priority\n")
5462
5463 ALIAS (ip_ospf_priority,
5464 ospf_priority_cmd,
5465 "ospf priority <0-255>",
5466 "OSPF interface commands\n"
5467 "Router priority\n"
5468 "Priority\n")
5469
5470 DEFUN (no_ip_ospf_priority,
5471 no_ip_ospf_priority_addr_cmd,
5472 "no ip ospf priority A.B.C.D",
5473 NO_STR
5474 "IP Information\n"
5475 "OSPF interface commands\n"
5476 "Router priority\n"
5477 "Address of interface")
5478 {
5479 struct interface *ifp = vty->index;
5480 struct route_node *rn;
5481 struct in_addr addr;
5482 int ret;
5483 struct ospf_if_params *params;
5484
5485 ifp = vty->index;
5486 params = IF_DEF_PARAMS (ifp);
5487
5488 if (argc == 1)
5489 {
5490 ret = inet_aton(argv[0], &addr);
5491 if (!ret)
5492 {
5493 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5494 VTY_NEWLINE);
5495 return CMD_WARNING;
5496 }
5497
5498 params = ospf_lookup_if_params (ifp, addr);
5499 if (params == NULL)
5500 return CMD_SUCCESS;
5501 }
5502
5503 UNSET_IF_PARAM (params, priority);
5504 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5505
5506 if (params != IF_DEF_PARAMS (ifp))
5507 {
5508 ospf_free_if_params (ifp, addr);
5509 ospf_if_update_params (ifp, addr);
5510 }
5511
5512 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5513 {
5514 struct ospf_interface *oi = rn->info;
5515
5516 if (!oi)
5517 continue;
5518
5519
5520 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5521 {
5522 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5523 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5524 }
5525 }
5526
5527 return CMD_SUCCESS;
5528 }
5529
5530 ALIAS (no_ip_ospf_priority,
5531 no_ip_ospf_priority_cmd,
5532 "no ip ospf priority",
5533 NO_STR
5534 "IP Information\n"
5535 "OSPF interface commands\n"
5536 "Router priority\n")
5537
5538 ALIAS (no_ip_ospf_priority,
5539 no_ospf_priority_cmd,
5540 "no ospf priority",
5541 NO_STR
5542 "OSPF interface commands\n"
5543 "Router priority\n")
5544
5545 DEFUN (ip_ospf_retransmit_interval,
5546 ip_ospf_retransmit_interval_addr_cmd,
5547 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5548 "IP Information\n"
5549 "OSPF interface commands\n"
5550 "Time between retransmitting lost link state advertisements\n"
5551 "Seconds\n"
5552 "Address of interface")
5553 {
5554 struct interface *ifp = vty->index;
5555 u_int32_t seconds;
5556 struct in_addr addr;
5557 int ret;
5558 struct ospf_if_params *params;
5559
5560 params = IF_DEF_PARAMS (ifp);
5561 seconds = strtol (argv[0], NULL, 10);
5562
5563 /* Retransmit Interval range is <3-65535>. */
5564 if (seconds < 3 || seconds > 65535)
5565 {
5566 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5567 return CMD_WARNING;
5568 }
5569
5570
5571 if (argc == 2)
5572 {
5573 ret = inet_aton(argv[1], &addr);
5574 if (!ret)
5575 {
5576 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5577 VTY_NEWLINE);
5578 return CMD_WARNING;
5579 }
5580
5581 params = ospf_get_if_params (ifp, addr);
5582 ospf_if_update_params (ifp, addr);
5583 }
5584
5585 SET_IF_PARAM (params, retransmit_interval);
5586 params->retransmit_interval = seconds;
5587
5588 return CMD_SUCCESS;
5589 }
5590
5591 ALIAS (ip_ospf_retransmit_interval,
5592 ip_ospf_retransmit_interval_cmd,
5593 "ip ospf retransmit-interval <3-65535>",
5594 "IP Information\n"
5595 "OSPF interface commands\n"
5596 "Time between retransmitting lost link state advertisements\n"
5597 "Seconds\n")
5598
5599 ALIAS (ip_ospf_retransmit_interval,
5600 ospf_retransmit_interval_cmd,
5601 "ospf retransmit-interval <3-65535>",
5602 "OSPF interface commands\n"
5603 "Time between retransmitting lost link state advertisements\n"
5604 "Seconds\n")
5605
5606 DEFUN (no_ip_ospf_retransmit_interval,
5607 no_ip_ospf_retransmit_interval_addr_cmd,
5608 "no ip ospf retransmit-interval A.B.C.D",
5609 NO_STR
5610 "IP Information\n"
5611 "OSPF interface commands\n"
5612 "Time between retransmitting lost link state advertisements\n"
5613 "Address of interface")
5614 {
5615 struct interface *ifp = vty->index;
5616 struct in_addr addr;
5617 int ret;
5618 struct ospf_if_params *params;
5619
5620 ifp = vty->index;
5621 params = IF_DEF_PARAMS (ifp);
5622
5623 if (argc == 1)
5624 {
5625 ret = inet_aton(argv[0], &addr);
5626 if (!ret)
5627 {
5628 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5629 VTY_NEWLINE);
5630 return CMD_WARNING;
5631 }
5632
5633 params = ospf_lookup_if_params (ifp, addr);
5634 if (params == NULL)
5635 return CMD_SUCCESS;
5636 }
5637
5638 UNSET_IF_PARAM (params, retransmit_interval);
5639 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5640
5641 if (params != IF_DEF_PARAMS (ifp))
5642 {
5643 ospf_free_if_params (ifp, addr);
5644 ospf_if_update_params (ifp, addr);
5645 }
5646
5647 return CMD_SUCCESS;
5648 }
5649
5650 ALIAS (no_ip_ospf_retransmit_interval,
5651 no_ip_ospf_retransmit_interval_cmd,
5652 "no ip ospf retransmit-interval",
5653 NO_STR
5654 "IP Information\n"
5655 "OSPF interface commands\n"
5656 "Time between retransmitting lost link state advertisements\n")
5657
5658 ALIAS (no_ip_ospf_retransmit_interval,
5659 no_ospf_retransmit_interval_cmd,
5660 "no ospf retransmit-interval",
5661 NO_STR
5662 "OSPF interface commands\n"
5663 "Time between retransmitting lost link state advertisements\n")
5664
5665 DEFUN (ip_ospf_transmit_delay,
5666 ip_ospf_transmit_delay_addr_cmd,
5667 "ip ospf transmit-delay <1-65535> A.B.C.D",
5668 "IP Information\n"
5669 "OSPF interface commands\n"
5670 "Link state transmit delay\n"
5671 "Seconds\n"
5672 "Address of interface")
5673 {
5674 struct interface *ifp = vty->index;
5675 u_int32_t seconds;
5676 struct in_addr addr;
5677 int ret;
5678 struct ospf_if_params *params;
5679
5680 params = IF_DEF_PARAMS (ifp);
5681 seconds = strtol (argv[0], NULL, 10);
5682
5683 /* Transmit Delay range is <1-65535>. */
5684 if (seconds < 1 || seconds > 65535)
5685 {
5686 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5687 return CMD_WARNING;
5688 }
5689
5690 if (argc == 2)
5691 {
5692 ret = inet_aton(argv[1], &addr);
5693 if (!ret)
5694 {
5695 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5696 VTY_NEWLINE);
5697 return CMD_WARNING;
5698 }
5699
5700 params = ospf_get_if_params (ifp, addr);
5701 ospf_if_update_params (ifp, addr);
5702 }
5703
5704 SET_IF_PARAM (params, transmit_delay);
5705 params->transmit_delay = seconds;
5706
5707 return CMD_SUCCESS;
5708 }
5709
5710 ALIAS (ip_ospf_transmit_delay,
5711 ip_ospf_transmit_delay_cmd,
5712 "ip ospf transmit-delay <1-65535>",
5713 "IP Information\n"
5714 "OSPF interface commands\n"
5715 "Link state transmit delay\n"
5716 "Seconds\n")
5717
5718 ALIAS (ip_ospf_transmit_delay,
5719 ospf_transmit_delay_cmd,
5720 "ospf transmit-delay <1-65535>",
5721 "OSPF interface commands\n"
5722 "Link state transmit delay\n"
5723 "Seconds\n")
5724
5725 DEFUN (no_ip_ospf_transmit_delay,
5726 no_ip_ospf_transmit_delay_addr_cmd,
5727 "no ip ospf transmit-delay A.B.C.D",
5728 NO_STR
5729 "IP Information\n"
5730 "OSPF interface commands\n"
5731 "Link state transmit delay\n"
5732 "Address of interface")
5733 {
5734 struct interface *ifp = vty->index;
5735 struct in_addr addr;
5736 int ret;
5737 struct ospf_if_params *params;
5738
5739 ifp = vty->index;
5740 params = IF_DEF_PARAMS (ifp);
5741
5742 if (argc == 1)
5743 {
5744 ret = inet_aton(argv[0], &addr);
5745 if (!ret)
5746 {
5747 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5748 VTY_NEWLINE);
5749 return CMD_WARNING;
5750 }
5751
5752 params = ospf_lookup_if_params (ifp, addr);
5753 if (params == NULL)
5754 return CMD_SUCCESS;
5755 }
5756
5757 UNSET_IF_PARAM (params, transmit_delay);
5758 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5759
5760 if (params != IF_DEF_PARAMS (ifp))
5761 {
5762 ospf_free_if_params (ifp, addr);
5763 ospf_if_update_params (ifp, addr);
5764 }
5765
5766 return CMD_SUCCESS;
5767 }
5768
5769 ALIAS (no_ip_ospf_transmit_delay,
5770 no_ip_ospf_transmit_delay_cmd,
5771 "no ip ospf transmit-delay",
5772 NO_STR
5773 "IP Information\n"
5774 "OSPF interface commands\n"
5775 "Link state transmit delay\n")
5776
5777 ALIAS (no_ip_ospf_transmit_delay,
5778 no_ospf_transmit_delay_cmd,
5779 "no ospf transmit-delay",
5780 NO_STR
5781 "OSPF interface commands\n"
5782 "Link state transmit delay\n")
5783
5784 \f
5785 DEFUN (ospf_redistribute_source_metric_type,
5786 ospf_redistribute_source_metric_type_routemap_cmd,
5787 "redistribute " QUAGGA_REDIST_STR_OSPFD
5788 " metric <0-16777214> metric-type (1|2) route-map WORD",
5789 REDIST_STR
5790 QUAGGA_REDIST_HELP_STR_OSPFD
5791 "Metric for redistributed routes\n"
5792 "OSPF default metric\n"
5793 "OSPF exterior metric type for redistributed routes\n"
5794 "Set OSPF External Type 1 metrics\n"
5795 "Set OSPF External Type 2 metrics\n"
5796 "Route map reference\n"
5797 "Pointer to route-map entries\n")
5798 {
5799 struct ospf *ospf = vty->index;
5800 int source;
5801 int type = -1;
5802 int metric = -1;
5803
5804 /* Get distribute source. */
5805 source = proto_redistnum(AFI_IP, argv[0]);
5806 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5807 return CMD_WARNING;
5808
5809 /* Get metric value. */
5810 if (argc >= 2)
5811 if (!str2metric (argv[1], &metric))
5812 return CMD_WARNING;
5813
5814 /* Get metric type. */
5815 if (argc >= 3)
5816 if (!str2metric_type (argv[2], &type))
5817 return CMD_WARNING;
5818
5819 if (argc == 4)
5820 ospf_routemap_set (ospf, source, argv[3]);
5821 else
5822 ospf_routemap_unset (ospf, source);
5823
5824 return ospf_redistribute_set (ospf, source, type, metric);
5825 }
5826
5827 ALIAS (ospf_redistribute_source_metric_type,
5828 ospf_redistribute_source_metric_type_cmd,
5829 "redistribute " QUAGGA_REDIST_STR_OSPFD
5830 " metric <0-16777214> metric-type (1|2)",
5831 REDIST_STR
5832 QUAGGA_REDIST_HELP_STR_OSPFD
5833 "Metric for redistributed routes\n"
5834 "OSPF default metric\n"
5835 "OSPF exterior metric type for redistributed routes\n"
5836 "Set OSPF External Type 1 metrics\n"
5837 "Set OSPF External Type 2 metrics\n")
5838
5839 ALIAS (ospf_redistribute_source_metric_type,
5840 ospf_redistribute_source_metric_cmd,
5841 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5842 REDIST_STR
5843 QUAGGA_REDIST_HELP_STR_OSPFD
5844 "Metric for redistributed routes\n"
5845 "OSPF default metric\n")
5846
5847 DEFUN (ospf_redistribute_source_type_metric,
5848 ospf_redistribute_source_type_metric_routemap_cmd,
5849 "redistribute " QUAGGA_REDIST_STR_OSPFD
5850 " metric-type (1|2) metric <0-16777214> route-map WORD",
5851 REDIST_STR
5852 QUAGGA_REDIST_HELP_STR_OSPFD
5853 "OSPF exterior metric type for redistributed routes\n"
5854 "Set OSPF External Type 1 metrics\n"
5855 "Set OSPF External Type 2 metrics\n"
5856 "Metric for redistributed routes\n"
5857 "OSPF default metric\n"
5858 "Route map reference\n"
5859 "Pointer to route-map entries\n")
5860 {
5861 struct ospf *ospf = vty->index;
5862 int source;
5863 int type = -1;
5864 int metric = -1;
5865
5866 /* Get distribute source. */
5867 source = proto_redistnum(AFI_IP, argv[0]);
5868 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5869 return CMD_WARNING;
5870
5871 /* Get metric value. */
5872 if (argc >= 2)
5873 if (!str2metric_type (argv[1], &type))
5874 return CMD_WARNING;
5875
5876 /* Get metric type. */
5877 if (argc >= 3)
5878 if (!str2metric (argv[2], &metric))
5879 return CMD_WARNING;
5880
5881 if (argc == 4)
5882 ospf_routemap_set (ospf, source, argv[3]);
5883 else
5884 ospf_routemap_unset (ospf, source);
5885
5886 return ospf_redistribute_set (ospf, source, type, metric);
5887 }
5888
5889 ALIAS (ospf_redistribute_source_type_metric,
5890 ospf_redistribute_source_type_metric_cmd,
5891 "redistribute " QUAGGA_REDIST_STR_OSPFD
5892 " metric-type (1|2) metric <0-16777214>",
5893 REDIST_STR
5894 QUAGGA_REDIST_HELP_STR_OSPFD
5895 "OSPF exterior metric type for redistributed routes\n"
5896 "Set OSPF External Type 1 metrics\n"
5897 "Set OSPF External Type 2 metrics\n"
5898 "Metric for redistributed routes\n"
5899 "OSPF default metric\n")
5900
5901 ALIAS (ospf_redistribute_source_type_metric,
5902 ospf_redistribute_source_type_cmd,
5903 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5904 REDIST_STR
5905 QUAGGA_REDIST_HELP_STR_OSPFD
5906 "OSPF exterior metric type for redistributed routes\n"
5907 "Set OSPF External Type 1 metrics\n"
5908 "Set OSPF External Type 2 metrics\n")
5909
5910 ALIAS (ospf_redistribute_source_type_metric,
5911 ospf_redistribute_source_cmd,
5912 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5913 REDIST_STR
5914 QUAGGA_REDIST_HELP_STR_OSPFD)
5915
5916 DEFUN (ospf_redistribute_source_metric_routemap,
5917 ospf_redistribute_source_metric_routemap_cmd,
5918 "redistribute " QUAGGA_REDIST_STR_OSPFD
5919 " metric <0-16777214> route-map WORD",
5920 REDIST_STR
5921 QUAGGA_REDIST_HELP_STR_OSPFD
5922 "Metric for redistributed routes\n"
5923 "OSPF default metric\n"
5924 "Route map reference\n"
5925 "Pointer to route-map entries\n")
5926 {
5927 struct ospf *ospf = vty->index;
5928 int source;
5929 int metric = -1;
5930
5931 /* Get distribute source. */
5932 source = proto_redistnum(AFI_IP, argv[0]);
5933 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5934 return CMD_WARNING;
5935
5936 /* Get metric value. */
5937 if (argc >= 2)
5938 if (!str2metric (argv[1], &metric))
5939 return CMD_WARNING;
5940
5941 if (argc == 3)
5942 ospf_routemap_set (ospf, source, argv[2]);
5943 else
5944 ospf_routemap_unset (ospf, source);
5945
5946 return ospf_redistribute_set (ospf, source, -1, metric);
5947 }
5948
5949 DEFUN (ospf_redistribute_source_type_routemap,
5950 ospf_redistribute_source_type_routemap_cmd,
5951 "redistribute " QUAGGA_REDIST_STR_OSPFD
5952 " metric-type (1|2) route-map WORD",
5953 REDIST_STR
5954 QUAGGA_REDIST_HELP_STR_OSPFD
5955 "OSPF exterior metric type for redistributed routes\n"
5956 "Set OSPF External Type 1 metrics\n"
5957 "Set OSPF External Type 2 metrics\n"
5958 "Route map reference\n"
5959 "Pointer to route-map entries\n")
5960 {
5961 struct ospf *ospf = vty->index;
5962 int source;
5963 int type = -1;
5964
5965 /* Get distribute source. */
5966 source = proto_redistnum(AFI_IP, argv[0]);
5967 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5968 return CMD_WARNING;
5969
5970 /* Get metric value. */
5971 if (argc >= 2)
5972 if (!str2metric_type (argv[1], &type))
5973 return CMD_WARNING;
5974
5975 if (argc == 3)
5976 ospf_routemap_set (ospf, source, argv[2]);
5977 else
5978 ospf_routemap_unset (ospf, source);
5979
5980 return ospf_redistribute_set (ospf, source, type, -1);
5981 }
5982
5983 DEFUN (ospf_redistribute_source_routemap,
5984 ospf_redistribute_source_routemap_cmd,
5985 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5986 REDIST_STR
5987 QUAGGA_REDIST_HELP_STR_OSPFD
5988 "Route map reference\n"
5989 "Pointer to route-map entries\n")
5990 {
5991 struct ospf *ospf = vty->index;
5992 int source;
5993
5994 /* Get distribute source. */
5995 source = proto_redistnum(AFI_IP, argv[0]);
5996 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5997 return CMD_WARNING;
5998
5999 if (argc == 2)
6000 ospf_routemap_set (ospf, source, argv[1]);
6001 else
6002 ospf_routemap_unset (ospf, source);
6003
6004 return ospf_redistribute_set (ospf, source, -1, -1);
6005 }
6006
6007 DEFUN (no_ospf_redistribute_source,
6008 no_ospf_redistribute_source_cmd,
6009 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
6010 NO_STR
6011 REDIST_STR
6012 QUAGGA_REDIST_HELP_STR_OSPFD)
6013 {
6014 struct ospf *ospf = vty->index;
6015 int source;
6016
6017 source = proto_redistnum(AFI_IP, argv[0]);
6018 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
6019 return CMD_WARNING;
6020
6021 ospf_routemap_unset (ospf, source);
6022 return ospf_redistribute_unset (ospf, source);
6023 }
6024
6025 DEFUN (ospf_distribute_list_out,
6026 ospf_distribute_list_out_cmd,
6027 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
6028 "Filter networks in routing updates\n"
6029 "Access-list name\n"
6030 OUT_STR
6031 QUAGGA_REDIST_HELP_STR_OSPFD)
6032 {
6033 struct ospf *ospf = vty->index;
6034 int source;
6035
6036 /* Get distribute source. */
6037 source = proto_redistnum(AFI_IP, argv[0]);
6038 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
6039 return CMD_WARNING;
6040
6041 return ospf_distribute_list_out_set (ospf, source, argv[0]);
6042 }
6043
6044 DEFUN (no_ospf_distribute_list_out,
6045 no_ospf_distribute_list_out_cmd,
6046 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
6047 NO_STR
6048 "Filter networks in routing updates\n"
6049 "Access-list name\n"
6050 OUT_STR
6051 QUAGGA_REDIST_HELP_STR_OSPFD)
6052 {
6053 struct ospf *ospf = vty->index;
6054 int source;
6055
6056 source = proto_redistnum(AFI_IP, argv[0]);
6057 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
6058 return CMD_WARNING;
6059
6060 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
6061 }
6062
6063 /* Default information originate. */
6064 DEFUN (ospf_default_information_originate_metric_type_routemap,
6065 ospf_default_information_originate_metric_type_routemap_cmd,
6066 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
6067 "Control distribution of default information\n"
6068 "Distribute a default route\n"
6069 "OSPF default metric\n"
6070 "OSPF metric\n"
6071 "OSPF metric type for default routes\n"
6072 "Set OSPF External Type 1 metrics\n"
6073 "Set OSPF External Type 2 metrics\n"
6074 "Route map reference\n"
6075 "Pointer to route-map entries\n")
6076 {
6077 struct ospf *ospf = vty->index;
6078 int type = -1;
6079 int metric = -1;
6080
6081 /* Get metric value. */
6082 if (argc >= 1)
6083 if (!str2metric (argv[0], &metric))
6084 return CMD_WARNING;
6085
6086 /* Get metric type. */
6087 if (argc >= 2)
6088 if (!str2metric_type (argv[1], &type))
6089 return CMD_WARNING;
6090
6091 if (argc == 3)
6092 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6093 else
6094 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6095
6096 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6097 type, metric);
6098 }
6099
6100 ALIAS (ospf_default_information_originate_metric_type_routemap,
6101 ospf_default_information_originate_metric_type_cmd,
6102 "default-information originate metric <0-16777214> metric-type (1|2)",
6103 "Control distribution of default information\n"
6104 "Distribute a default route\n"
6105 "OSPF default metric\n"
6106 "OSPF metric\n"
6107 "OSPF metric type for default routes\n"
6108 "Set OSPF External Type 1 metrics\n"
6109 "Set OSPF External Type 2 metrics\n")
6110
6111 ALIAS (ospf_default_information_originate_metric_type_routemap,
6112 ospf_default_information_originate_metric_cmd,
6113 "default-information originate metric <0-16777214>",
6114 "Control distribution of default information\n"
6115 "Distribute a default route\n"
6116 "OSPF default metric\n"
6117 "OSPF metric\n")
6118
6119 ALIAS (ospf_default_information_originate_metric_type_routemap,
6120 ospf_default_information_originate_cmd,
6121 "default-information originate",
6122 "Control distribution of default information\n"
6123 "Distribute a default route\n")
6124
6125 /* Default information originate. */
6126 DEFUN (ospf_default_information_originate_metric_routemap,
6127 ospf_default_information_originate_metric_routemap_cmd,
6128 "default-information originate metric <0-16777214> route-map WORD",
6129 "Control distribution of default information\n"
6130 "Distribute a default route\n"
6131 "OSPF default metric\n"
6132 "OSPF metric\n"
6133 "Route map reference\n"
6134 "Pointer to route-map entries\n")
6135 {
6136 struct ospf *ospf = vty->index;
6137 int metric = -1;
6138
6139 /* Get metric value. */
6140 if (argc >= 1)
6141 if (!str2metric (argv[0], &metric))
6142 return CMD_WARNING;
6143
6144 if (argc == 2)
6145 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6146 else
6147 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6148
6149 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6150 -1, metric);
6151 }
6152
6153 /* Default information originate. */
6154 DEFUN (ospf_default_information_originate_routemap,
6155 ospf_default_information_originate_routemap_cmd,
6156 "default-information originate route-map WORD",
6157 "Control distribution of default information\n"
6158 "Distribute a default route\n"
6159 "Route map reference\n"
6160 "Pointer to route-map entries\n")
6161 {
6162 struct ospf *ospf = vty->index;
6163
6164 if (argc == 1)
6165 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6166 else
6167 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6168
6169 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
6170 }
6171
6172 DEFUN (ospf_default_information_originate_type_metric_routemap,
6173 ospf_default_information_originate_type_metric_routemap_cmd,
6174 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6175 "Control distribution of default information\n"
6176 "Distribute a default route\n"
6177 "OSPF metric type for default routes\n"
6178 "Set OSPF External Type 1 metrics\n"
6179 "Set OSPF External Type 2 metrics\n"
6180 "OSPF default metric\n"
6181 "OSPF metric\n"
6182 "Route map reference\n"
6183 "Pointer to route-map entries\n")
6184 {
6185 struct ospf *ospf = vty->index;
6186 int type = -1;
6187 int metric = -1;
6188
6189 /* Get metric type. */
6190 if (argc >= 1)
6191 if (!str2metric_type (argv[0], &type))
6192 return CMD_WARNING;
6193
6194 /* Get metric value. */
6195 if (argc >= 2)
6196 if (!str2metric (argv[1], &metric))
6197 return CMD_WARNING;
6198
6199 if (argc == 3)
6200 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6201 else
6202 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6203
6204 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6205 type, metric);
6206 }
6207
6208 ALIAS (ospf_default_information_originate_type_metric_routemap,
6209 ospf_default_information_originate_type_metric_cmd,
6210 "default-information originate metric-type (1|2) metric <0-16777214>",
6211 "Control distribution of default information\n"
6212 "Distribute a default route\n"
6213 "OSPF metric type for default routes\n"
6214 "Set OSPF External Type 1 metrics\n"
6215 "Set OSPF External Type 2 metrics\n"
6216 "OSPF default metric\n"
6217 "OSPF metric\n")
6218
6219 ALIAS (ospf_default_information_originate_type_metric_routemap,
6220 ospf_default_information_originate_type_cmd,
6221 "default-information originate metric-type (1|2)",
6222 "Control distribution of default information\n"
6223 "Distribute a default route\n"
6224 "OSPF metric type for default routes\n"
6225 "Set OSPF External Type 1 metrics\n"
6226 "Set OSPF External Type 2 metrics\n")
6227
6228 DEFUN (ospf_default_information_originate_type_routemap,
6229 ospf_default_information_originate_type_routemap_cmd,
6230 "default-information originate metric-type (1|2) route-map WORD",
6231 "Control distribution of default information\n"
6232 "Distribute a default route\n"
6233 "OSPF metric type for default routes\n"
6234 "Set OSPF External Type 1 metrics\n"
6235 "Set OSPF External Type 2 metrics\n"
6236 "Route map reference\n"
6237 "Pointer to route-map entries\n")
6238 {
6239 struct ospf *ospf = vty->index;
6240 int type = -1;
6241
6242 /* Get metric type. */
6243 if (argc >= 1)
6244 if (!str2metric_type (argv[0], &type))
6245 return CMD_WARNING;
6246
6247 if (argc == 2)
6248 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6249 else
6250 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6251
6252 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6253 type, -1);
6254 }
6255
6256 DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6257 ospf_default_information_originate_always_metric_type_routemap_cmd,
6258 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6259 "Control distribution of default information\n"
6260 "Distribute a default route\n"
6261 "Always advertise default route\n"
6262 "OSPF default metric\n"
6263 "OSPF metric\n"
6264 "OSPF metric type for default routes\n"
6265 "Set OSPF External Type 1 metrics\n"
6266 "Set OSPF External Type 2 metrics\n"
6267 "Route map reference\n"
6268 "Pointer to route-map entries\n")
6269 {
6270 struct ospf *ospf = vty->index;
6271 int type = -1;
6272 int metric = -1;
6273
6274 /* Get metric value. */
6275 if (argc >= 1)
6276 if (!str2metric (argv[0], &metric))
6277 return CMD_WARNING;
6278
6279 /* Get metric type. */
6280 if (argc >= 2)
6281 if (!str2metric_type (argv[1], &type))
6282 return CMD_WARNING;
6283
6284 if (argc == 3)
6285 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6286 else
6287 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6288
6289 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6290 type, metric);
6291 }
6292
6293 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6294 ospf_default_information_originate_always_metric_type_cmd,
6295 "default-information originate always metric <0-16777214> metric-type (1|2)",
6296 "Control distribution of default information\n"
6297 "Distribute a default route\n"
6298 "Always advertise default route\n"
6299 "OSPF default metric\n"
6300 "OSPF metric\n"
6301 "OSPF metric type for default routes\n"
6302 "Set OSPF External Type 1 metrics\n"
6303 "Set OSPF External Type 2 metrics\n")
6304
6305 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6306 ospf_default_information_originate_always_metric_cmd,
6307 "default-information originate always metric <0-16777214>",
6308 "Control distribution of default information\n"
6309 "Distribute a default route\n"
6310 "Always advertise default route\n"
6311 "OSPF default metric\n"
6312 "OSPF metric\n"
6313 "OSPF metric type for default routes\n")
6314
6315 ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6316 ospf_default_information_originate_always_cmd,
6317 "default-information originate always",
6318 "Control distribution of default information\n"
6319 "Distribute a default route\n"
6320 "Always advertise default route\n")
6321
6322 DEFUN (ospf_default_information_originate_always_metric_routemap,
6323 ospf_default_information_originate_always_metric_routemap_cmd,
6324 "default-information originate always metric <0-16777214> route-map WORD",
6325 "Control distribution of default information\n"
6326 "Distribute a default route\n"
6327 "Always advertise default route\n"
6328 "OSPF default metric\n"
6329 "OSPF metric\n"
6330 "Route map reference\n"
6331 "Pointer to route-map entries\n")
6332 {
6333 struct ospf *ospf = vty->index;
6334 int metric = -1;
6335
6336 /* Get metric value. */
6337 if (argc >= 1)
6338 if (!str2metric (argv[0], &metric))
6339 return CMD_WARNING;
6340
6341 if (argc == 2)
6342 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6343 else
6344 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6345
6346 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6347 -1, metric);
6348 }
6349
6350 DEFUN (ospf_default_information_originate_always_routemap,
6351 ospf_default_information_originate_always_routemap_cmd,
6352 "default-information originate always route-map WORD",
6353 "Control distribution of default information\n"
6354 "Distribute a default route\n"
6355 "Always advertise default route\n"
6356 "Route map reference\n"
6357 "Pointer to route-map entries\n")
6358 {
6359 struct ospf *ospf = vty->index;
6360
6361 if (argc == 1)
6362 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6363 else
6364 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6365
6366 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
6367 }
6368
6369 DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6370 ospf_default_information_originate_always_type_metric_routemap_cmd,
6371 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6372 "Control distribution of default information\n"
6373 "Distribute a default route\n"
6374 "Always advertise default route\n"
6375 "OSPF metric type for default routes\n"
6376 "Set OSPF External Type 1 metrics\n"
6377 "Set OSPF External Type 2 metrics\n"
6378 "OSPF default metric\n"
6379 "OSPF metric\n"
6380 "Route map reference\n"
6381 "Pointer to route-map entries\n")
6382 {
6383 struct ospf *ospf = vty->index;
6384 int type = -1;
6385 int metric = -1;
6386
6387 /* Get metric type. */
6388 if (argc >= 1)
6389 if (!str2metric_type (argv[0], &type))
6390 return CMD_WARNING;
6391
6392 /* Get metric value. */
6393 if (argc >= 2)
6394 if (!str2metric (argv[1], &metric))
6395 return CMD_WARNING;
6396
6397 if (argc == 3)
6398 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
6399 else
6400 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6401
6402 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6403 type, metric);
6404 }
6405
6406 ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6407 ospf_default_information_originate_always_type_metric_cmd,
6408 "default-information originate always metric-type (1|2) metric <0-16777214>",
6409 "Control distribution of default information\n"
6410 "Distribute a default route\n"
6411 "Always advertise default route\n"
6412 "OSPF metric type for default routes\n"
6413 "Set OSPF External Type 1 metrics\n"
6414 "Set OSPF External Type 2 metrics\n"
6415 "OSPF default metric\n"
6416 "OSPF metric\n")
6417
6418 ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6419 ospf_default_information_originate_always_type_cmd,
6420 "default-information originate always metric-type (1|2)",
6421 "Control distribution of default information\n"
6422 "Distribute a default route\n"
6423 "Always advertise default route\n"
6424 "OSPF metric type for default routes\n"
6425 "Set OSPF External Type 1 metrics\n"
6426 "Set OSPF External Type 2 metrics\n")
6427
6428 DEFUN (ospf_default_information_originate_always_type_routemap,
6429 ospf_default_information_originate_always_type_routemap_cmd,
6430 "default-information originate always metric-type (1|2) route-map WORD",
6431 "Control distribution of default information\n"
6432 "Distribute a default route\n"
6433 "Always advertise default route\n"
6434 "OSPF metric type for default routes\n"
6435 "Set OSPF External Type 1 metrics\n"
6436 "Set OSPF External Type 2 metrics\n"
6437 "Route map reference\n"
6438 "Pointer to route-map entries\n")
6439 {
6440 struct ospf *ospf = vty->index;
6441 int type = -1;
6442
6443 /* Get metric type. */
6444 if (argc >= 1)
6445 if (!str2metric_type (argv[0], &type))
6446 return CMD_WARNING;
6447
6448 if (argc == 2)
6449 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
6450 else
6451 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6452
6453 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6454 type, -1);
6455 }
6456
6457 DEFUN (no_ospf_default_information_originate,
6458 no_ospf_default_information_originate_cmd,
6459 "no default-information originate",
6460 NO_STR
6461 "Control distribution of default information\n"
6462 "Distribute a default route\n")
6463 {
6464 struct ospf *ospf = vty->index;
6465 struct prefix_ipv4 p;
6466
6467 p.family = AF_INET;
6468 p.prefix.s_addr = 0;
6469 p.prefixlen = 0;
6470
6471 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
6472
6473 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6474 ospf_external_info_delete (DEFAULT_ROUTE, p);
6475 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6476 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6477 }
6478
6479 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6480 return ospf_redistribute_default_unset (ospf);
6481 }
6482
6483 DEFUN (ospf_default_metric,
6484 ospf_default_metric_cmd,
6485 "default-metric <0-16777214>",
6486 "Set metric of redistributed routes\n"
6487 "Default metric\n")
6488 {
6489 struct ospf *ospf = vty->index;
6490 int metric = -1;
6491
6492 if (!str2metric (argv[0], &metric))
6493 return CMD_WARNING;
6494
6495 ospf->default_metric = metric;
6496
6497 return CMD_SUCCESS;
6498 }
6499
6500 DEFUN (no_ospf_default_metric,
6501 no_ospf_default_metric_cmd,
6502 "no default-metric",
6503 NO_STR
6504 "Set metric of redistributed routes\n")
6505 {
6506 struct ospf *ospf = vty->index;
6507
6508 ospf->default_metric = -1;
6509
6510 return CMD_SUCCESS;
6511 }
6512
6513 ALIAS (no_ospf_default_metric,
6514 no_ospf_default_metric_val_cmd,
6515 "no default-metric <0-16777214>",
6516 NO_STR
6517 "Set metric of redistributed routes\n"
6518 "Default metric\n")
6519
6520 DEFUN (ospf_distance,
6521 ospf_distance_cmd,
6522 "distance <1-255>",
6523 "Define an administrative distance\n"
6524 "OSPF Administrative distance\n")
6525 {
6526 struct ospf *ospf = vty->index;
6527
6528 ospf->distance_all = atoi (argv[0]);
6529
6530 return CMD_SUCCESS;
6531 }
6532
6533 DEFUN (no_ospf_distance,
6534 no_ospf_distance_cmd,
6535 "no distance <1-255>",
6536 NO_STR
6537 "Define an administrative distance\n"
6538 "OSPF Administrative distance\n")
6539 {
6540 struct ospf *ospf = vty->index;
6541
6542 ospf->distance_all = 0;
6543
6544 return CMD_SUCCESS;
6545 }
6546
6547 DEFUN (no_ospf_distance_ospf,
6548 no_ospf_distance_ospf_cmd,
6549 "no distance ospf",
6550 NO_STR
6551 "Define an administrative distance\n"
6552 "OSPF Administrative distance\n"
6553 "OSPF Distance\n")
6554 {
6555 struct ospf *ospf = vty->index;
6556
6557 ospf->distance_intra = 0;
6558 ospf->distance_inter = 0;
6559 ospf->distance_external = 0;
6560
6561 return CMD_SUCCESS;
6562 }
6563
6564 DEFUN (ospf_distance_ospf_intra,
6565 ospf_distance_ospf_intra_cmd,
6566 "distance ospf intra-area <1-255>",
6567 "Define an administrative distance\n"
6568 "OSPF Administrative distance\n"
6569 "Intra-area routes\n"
6570 "Distance for intra-area routes\n")
6571 {
6572 struct ospf *ospf = vty->index;
6573
6574 ospf->distance_intra = atoi (argv[0]);
6575
6576 return CMD_SUCCESS;
6577 }
6578
6579 DEFUN (ospf_distance_ospf_intra_inter,
6580 ospf_distance_ospf_intra_inter_cmd,
6581 "distance ospf intra-area <1-255> inter-area <1-255>",
6582 "Define an administrative distance\n"
6583 "OSPF Administrative distance\n"
6584 "Intra-area routes\n"
6585 "Distance for intra-area routes\n"
6586 "Inter-area routes\n"
6587 "Distance for inter-area routes\n")
6588 {
6589 struct ospf *ospf = vty->index;
6590
6591 ospf->distance_intra = atoi (argv[0]);
6592 ospf->distance_inter = atoi (argv[1]);
6593
6594 return CMD_SUCCESS;
6595 }
6596
6597 DEFUN (ospf_distance_ospf_intra_external,
6598 ospf_distance_ospf_intra_external_cmd,
6599 "distance ospf intra-area <1-255> external <1-255>",
6600 "Define an administrative distance\n"
6601 "OSPF Administrative distance\n"
6602 "Intra-area routes\n"
6603 "Distance for intra-area routes\n"
6604 "External routes\n"
6605 "Distance for external routes\n")
6606 {
6607 struct ospf *ospf = vty->index;
6608
6609 ospf->distance_intra = atoi (argv[0]);
6610 ospf->distance_external = atoi (argv[1]);
6611
6612 return CMD_SUCCESS;
6613 }
6614
6615 DEFUN (ospf_distance_ospf_intra_inter_external,
6616 ospf_distance_ospf_intra_inter_external_cmd,
6617 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6618 "Define an administrative distance\n"
6619 "OSPF Administrative distance\n"
6620 "Intra-area routes\n"
6621 "Distance for intra-area routes\n"
6622 "Inter-area routes\n"
6623 "Distance for inter-area routes\n"
6624 "External routes\n"
6625 "Distance for external routes\n")
6626 {
6627 struct ospf *ospf = vty->index;
6628
6629 ospf->distance_intra = atoi (argv[0]);
6630 ospf->distance_inter = atoi (argv[1]);
6631 ospf->distance_external = atoi (argv[2]);
6632
6633 return CMD_SUCCESS;
6634 }
6635
6636 DEFUN (ospf_distance_ospf_intra_external_inter,
6637 ospf_distance_ospf_intra_external_inter_cmd,
6638 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6639 "Define an administrative distance\n"
6640 "OSPF Administrative distance\n"
6641 "Intra-area routes\n"
6642 "Distance for intra-area routes\n"
6643 "External routes\n"
6644 "Distance for external routes\n"
6645 "Inter-area routes\n"
6646 "Distance for inter-area routes\n")
6647 {
6648 struct ospf *ospf = vty->index;
6649
6650 ospf->distance_intra = atoi (argv[0]);
6651 ospf->distance_external = atoi (argv[1]);
6652 ospf->distance_inter = atoi (argv[2]);
6653
6654 return CMD_SUCCESS;
6655 }
6656
6657 DEFUN (ospf_distance_ospf_inter,
6658 ospf_distance_ospf_inter_cmd,
6659 "distance ospf inter-area <1-255>",
6660 "Define an administrative distance\n"
6661 "OSPF Administrative distance\n"
6662 "Inter-area routes\n"
6663 "Distance for inter-area routes\n")
6664 {
6665 struct ospf *ospf = vty->index;
6666
6667 ospf->distance_inter = atoi (argv[0]);
6668
6669 return CMD_SUCCESS;
6670 }
6671
6672 DEFUN (ospf_distance_ospf_inter_intra,
6673 ospf_distance_ospf_inter_intra_cmd,
6674 "distance ospf inter-area <1-255> intra-area <1-255>",
6675 "Define an administrative distance\n"
6676 "OSPF Administrative distance\n"
6677 "Inter-area routes\n"
6678 "Distance for inter-area routes\n"
6679 "Intra-area routes\n"
6680 "Distance for intra-area routes\n")
6681 {
6682 struct ospf *ospf = vty->index;
6683
6684 ospf->distance_inter = atoi (argv[0]);
6685 ospf->distance_intra = atoi (argv[1]);
6686
6687 return CMD_SUCCESS;
6688 }
6689
6690 DEFUN (ospf_distance_ospf_inter_external,
6691 ospf_distance_ospf_inter_external_cmd,
6692 "distance ospf inter-area <1-255> external <1-255>",
6693 "Define an administrative distance\n"
6694 "OSPF Administrative distance\n"
6695 "Inter-area routes\n"
6696 "Distance for inter-area routes\n"
6697 "External routes\n"
6698 "Distance for external routes\n")
6699 {
6700 struct ospf *ospf = vty->index;
6701
6702 ospf->distance_inter = atoi (argv[0]);
6703 ospf->distance_external = atoi (argv[1]);
6704
6705 return CMD_SUCCESS;
6706 }
6707
6708 DEFUN (ospf_distance_ospf_inter_intra_external,
6709 ospf_distance_ospf_inter_intra_external_cmd,
6710 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6711 "Define an administrative distance\n"
6712 "OSPF Administrative distance\n"
6713 "Inter-area routes\n"
6714 "Distance for inter-area routes\n"
6715 "Intra-area routes\n"
6716 "Distance for intra-area routes\n"
6717 "External routes\n"
6718 "Distance for external routes\n")
6719 {
6720 struct ospf *ospf = vty->index;
6721
6722 ospf->distance_inter = atoi (argv[0]);
6723 ospf->distance_intra = atoi (argv[1]);
6724 ospf->distance_external = atoi (argv[2]);
6725
6726 return CMD_SUCCESS;
6727 }
6728
6729 DEFUN (ospf_distance_ospf_inter_external_intra,
6730 ospf_distance_ospf_inter_external_intra_cmd,
6731 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6732 "Define an administrative distance\n"
6733 "OSPF Administrative distance\n"
6734 "Inter-area routes\n"
6735 "Distance for inter-area routes\n"
6736 "External routes\n"
6737 "Distance for external routes\n"
6738 "Intra-area routes\n"
6739 "Distance for intra-area routes\n")
6740 {
6741 struct ospf *ospf = vty->index;
6742
6743 ospf->distance_inter = atoi (argv[0]);
6744 ospf->distance_external = atoi (argv[1]);
6745 ospf->distance_intra = atoi (argv[2]);
6746
6747 return CMD_SUCCESS;
6748 }
6749
6750 DEFUN (ospf_distance_ospf_external,
6751 ospf_distance_ospf_external_cmd,
6752 "distance ospf external <1-255>",
6753 "Define an administrative distance\n"
6754 "OSPF Administrative distance\n"
6755 "External routes\n"
6756 "Distance for external routes\n")
6757 {
6758 struct ospf *ospf = vty->index;
6759
6760 ospf->distance_external = atoi (argv[0]);
6761
6762 return CMD_SUCCESS;
6763 }
6764
6765 DEFUN (ospf_distance_ospf_external_intra,
6766 ospf_distance_ospf_external_intra_cmd,
6767 "distance ospf external <1-255> intra-area <1-255>",
6768 "Define an administrative distance\n"
6769 "OSPF Administrative distance\n"
6770 "External routes\n"
6771 "Distance for external routes\n"
6772 "Intra-area routes\n"
6773 "Distance for intra-area routes\n")
6774 {
6775 struct ospf *ospf = vty->index;
6776
6777 ospf->distance_external = atoi (argv[0]);
6778 ospf->distance_intra = atoi (argv[1]);
6779
6780 return CMD_SUCCESS;
6781 }
6782
6783 DEFUN (ospf_distance_ospf_external_inter,
6784 ospf_distance_ospf_external_inter_cmd,
6785 "distance ospf external <1-255> inter-area <1-255>",
6786 "Define an administrative distance\n"
6787 "OSPF Administrative distance\n"
6788 "External routes\n"
6789 "Distance for external routes\n"
6790 "Inter-area routes\n"
6791 "Distance for inter-area routes\n")
6792 {
6793 struct ospf *ospf = vty->index;
6794
6795 ospf->distance_external = atoi (argv[0]);
6796 ospf->distance_inter = atoi (argv[1]);
6797
6798 return CMD_SUCCESS;
6799 }
6800
6801 DEFUN (ospf_distance_ospf_external_intra_inter,
6802 ospf_distance_ospf_external_intra_inter_cmd,
6803 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6804 "Define an administrative distance\n"
6805 "OSPF Administrative distance\n"
6806 "External routes\n"
6807 "Distance for external routes\n"
6808 "Intra-area routes\n"
6809 "Distance for intra-area routes\n"
6810 "Inter-area routes\n"
6811 "Distance for inter-area routes\n")
6812 {
6813 struct ospf *ospf = vty->index;
6814
6815 ospf->distance_external = atoi (argv[0]);
6816 ospf->distance_intra = atoi (argv[1]);
6817 ospf->distance_inter = atoi (argv[2]);
6818
6819 return CMD_SUCCESS;
6820 }
6821
6822 DEFUN (ospf_distance_ospf_external_inter_intra,
6823 ospf_distance_ospf_external_inter_intra_cmd,
6824 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6825 "Define an administrative distance\n"
6826 "OSPF Administrative distance\n"
6827 "External routes\n"
6828 "Distance for external routes\n"
6829 "Inter-area routes\n"
6830 "Distance for inter-area routes\n"
6831 "Intra-area routes\n"
6832 "Distance for intra-area routes\n")
6833 {
6834 struct ospf *ospf = vty->index;
6835
6836 ospf->distance_external = atoi (argv[0]);
6837 ospf->distance_inter = atoi (argv[1]);
6838 ospf->distance_intra = atoi (argv[2]);
6839
6840 return CMD_SUCCESS;
6841 }
6842
6843 DEFUN (ospf_distance_source,
6844 ospf_distance_source_cmd,
6845 "distance <1-255> A.B.C.D/M",
6846 "Administrative distance\n"
6847 "Distance value\n"
6848 "IP source prefix\n")
6849 {
6850 struct ospf *ospf = vty->index;
6851
6852 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
6853
6854 return CMD_SUCCESS;
6855 }
6856
6857 DEFUN (no_ospf_distance_source,
6858 no_ospf_distance_source_cmd,
6859 "no distance <1-255> A.B.C.D/M",
6860 NO_STR
6861 "Administrative distance\n"
6862 "Distance value\n"
6863 "IP source prefix\n")
6864 {
6865 struct ospf *ospf = vty->index;
6866
6867 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6868
6869 return CMD_SUCCESS;
6870 }
6871
6872 DEFUN (ospf_distance_source_access_list,
6873 ospf_distance_source_access_list_cmd,
6874 "distance <1-255> A.B.C.D/M WORD",
6875 "Administrative distance\n"
6876 "Distance value\n"
6877 "IP source prefix\n"
6878 "Access list name\n")
6879 {
6880 struct ospf *ospf = vty->index;
6881
6882 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6883
6884 return CMD_SUCCESS;
6885 }
6886
6887 DEFUN (no_ospf_distance_source_access_list,
6888 no_ospf_distance_source_access_list_cmd,
6889 "no distance <1-255> A.B.C.D/M WORD",
6890 NO_STR
6891 "Administrative distance\n"
6892 "Distance value\n"
6893 "IP source prefix\n"
6894 "Access list name\n")
6895 {
6896 struct ospf *ospf = vty->index;
6897
6898 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6899
6900 return CMD_SUCCESS;
6901 }
6902
6903 DEFUN (ip_ospf_mtu_ignore,
6904 ip_ospf_mtu_ignore_addr_cmd,
6905 "ip ospf mtu-ignore A.B.C.D",
6906 "IP Information\n"
6907 "OSPF interface commands\n"
6908 "Disable mtu mismatch detection\n"
6909 "Address of interface")
6910 {
6911 struct interface *ifp = vty->index;
6912 struct in_addr addr;
6913 int ret;
6914
6915 struct ospf_if_params *params;
6916 params = IF_DEF_PARAMS (ifp);
6917
6918 if (argc == 1)
6919 {
6920 ret = inet_aton(argv[0], &addr);
6921 if (!ret)
6922 {
6923 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6924 VTY_NEWLINE);
6925 return CMD_WARNING;
6926 }
6927 params = ospf_get_if_params (ifp, addr);
6928 ospf_if_update_params (ifp, addr);
6929 }
6930 params->mtu_ignore = 1;
6931 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6932 SET_IF_PARAM (params, mtu_ignore);
6933 else
6934 {
6935 UNSET_IF_PARAM (params, mtu_ignore);
6936 if (params != IF_DEF_PARAMS (ifp))
6937 {
6938 ospf_free_if_params (ifp, addr);
6939 ospf_if_update_params (ifp, addr);
6940 }
6941 }
6942 return CMD_SUCCESS;
6943 }
6944
6945 ALIAS (ip_ospf_mtu_ignore,
6946 ip_ospf_mtu_ignore_cmd,
6947 "ip ospf mtu-ignore",
6948 "IP Information\n"
6949 "OSPF interface commands\n"
6950 "Disable mtu mismatch detection\n")
6951
6952
6953 DEFUN (no_ip_ospf_mtu_ignore,
6954 no_ip_ospf_mtu_ignore_addr_cmd,
6955 "no ip ospf mtu-ignore A.B.C.D",
6956 "IP Information\n"
6957 "OSPF interface commands\n"
6958 "Disable mtu mismatch detection\n"
6959 "Address of interface")
6960 {
6961 struct interface *ifp = vty->index;
6962 struct in_addr addr;
6963 int ret;
6964
6965 struct ospf_if_params *params;
6966 params = IF_DEF_PARAMS (ifp);
6967
6968 if (argc == 1)
6969 {
6970 ret = inet_aton(argv[0], &addr);
6971 if (!ret)
6972 {
6973 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6974 VTY_NEWLINE);
6975 return CMD_WARNING;
6976 }
6977 params = ospf_get_if_params (ifp, addr);
6978 ospf_if_update_params (ifp, addr);
6979 }
6980 params->mtu_ignore = 0;
6981 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6982 SET_IF_PARAM (params, mtu_ignore);
6983 else
6984 {
6985 UNSET_IF_PARAM (params, mtu_ignore);
6986 if (params != IF_DEF_PARAMS (ifp))
6987 {
6988 ospf_free_if_params (ifp, addr);
6989 ospf_if_update_params (ifp, addr);
6990 }
6991 }
6992 return CMD_SUCCESS;
6993 }
6994
6995 ALIAS (no_ip_ospf_mtu_ignore,
6996 no_ip_ospf_mtu_ignore_cmd,
6997 "no ip ospf mtu-ignore",
6998 "IP Information\n"
6999 "OSPF interface commands\n"
7000 "Disable mtu mismatch detection\n")
7001 \f
7002 DEFUN (ospf_max_metric_router_lsa_admin,
7003 ospf_max_metric_router_lsa_admin_cmd,
7004 "max-metric router-lsa administrative",
7005 "OSPF maximum / infinite-distance metric\n"
7006 "Advertise own Router-LSA with infinite distance (stub router)\n"
7007 "Administratively applied, for an indefinite period\n")
7008 {
7009 struct listnode *ln;
7010 struct ospf_area *area;
7011 struct ospf *ospf = vty->index;
7012
7013 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7014 {
7015 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7016
7017 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
7018 ospf_router_lsa_update_area (area);
7019 }
7020 return CMD_SUCCESS;
7021 }
7022
7023 DEFUN (no_ospf_max_metric_router_lsa_admin,
7024 no_ospf_max_metric_router_lsa_admin_cmd,
7025 "no max-metric router-lsa administrative",
7026 NO_STR
7027 "OSPF maximum / infinite-distance metric\n"
7028 "Advertise own Router-LSA with infinite distance (stub router)\n"
7029 "Administratively applied, for an indefinite period\n")
7030 {
7031 struct listnode *ln;
7032 struct ospf_area *area;
7033 struct ospf *ospf = vty->index;
7034
7035 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7036 {
7037 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7038
7039 /* Don't trample on the start-up stub timer */
7040 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
7041 && !area->t_stub_router)
7042 {
7043 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
7044 ospf_router_lsa_update_area (area);
7045 }
7046 }
7047 return CMD_SUCCESS;
7048 }
7049
7050 DEFUN (ospf_max_metric_router_lsa_startup,
7051 ospf_max_metric_router_lsa_startup_cmd,
7052 "max-metric router-lsa on-startup <5-86400>",
7053 "OSPF maximum / infinite-distance metric\n"
7054 "Advertise own Router-LSA with infinite distance (stub router)\n"
7055 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7056 "Time (seconds) to advertise self as stub-router\n")
7057 {
7058 unsigned int seconds;
7059 struct ospf *ospf = vty->index;
7060
7061 if (argc != 1)
7062 {
7063 vty_out (vty, "%% Must supply stub-router period");
7064 return CMD_WARNING;
7065 }
7066
7067 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
7068
7069 ospf->stub_router_startup_time = seconds;
7070
7071 return CMD_SUCCESS;
7072 }
7073
7074 DEFUN (no_ospf_max_metric_router_lsa_startup,
7075 no_ospf_max_metric_router_lsa_startup_cmd,
7076 "no max-metric router-lsa on-startup",
7077 NO_STR
7078 "OSPF maximum / infinite-distance metric\n"
7079 "Advertise own Router-LSA with infinite distance (stub router)\n"
7080 "Automatically advertise stub Router-LSA on startup of OSPF\n")
7081 {
7082 struct listnode *ln;
7083 struct ospf_area *area;
7084 struct ospf *ospf = vty->index;
7085
7086 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7087
7088 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7089 {
7090 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
7091 OSPF_TIMER_OFF (area->t_stub_router);
7092
7093 /* Don't trample on admin stub routed */
7094 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7095 {
7096 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
7097 ospf_router_lsa_update_area (area);
7098 }
7099 }
7100 return CMD_SUCCESS;
7101 }
7102
7103 DEFUN (ospf_max_metric_router_lsa_shutdown,
7104 ospf_max_metric_router_lsa_shutdown_cmd,
7105 "max-metric router-lsa on-shutdown <5-86400>",
7106 "OSPF maximum / infinite-distance metric\n"
7107 "Advertise own Router-LSA with infinite distance (stub router)\n"
7108 "Advertise stub-router prior to full shutdown of OSPF\n"
7109 "Time (seconds) to wait till full shutdown\n")
7110 {
7111 unsigned int seconds;
7112 struct ospf *ospf = vty->index;
7113
7114 if (argc != 1)
7115 {
7116 vty_out (vty, "%% Must supply stub-router shutdown period");
7117 return CMD_WARNING;
7118 }
7119
7120 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
7121
7122 ospf->stub_router_shutdown_time = seconds;
7123
7124 return CMD_SUCCESS;
7125 }
7126
7127 DEFUN (no_ospf_max_metric_router_lsa_shutdown,
7128 no_ospf_max_metric_router_lsa_shutdown_cmd,
7129 "no max-metric router-lsa on-shutdown",
7130 NO_STR
7131 "OSPF maximum / infinite-distance metric\n"
7132 "Advertise own Router-LSA with infinite distance (stub router)\n"
7133 "Advertise stub-router prior to full shutdown of OSPF\n")
7134 {
7135 struct ospf *ospf = vty->index;
7136
7137 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7138
7139 return CMD_SUCCESS;
7140 }
7141
7142 static void
7143 config_write_stub_router (struct vty *vty, struct ospf *ospf)
7144 {
7145 struct listnode *ln;
7146 struct ospf_area *area;
7147
7148 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7149 vty_out (vty, " max-metric router-lsa on-startup %u%s",
7150 ospf->stub_router_startup_time, VTY_NEWLINE);
7151 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7152 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
7153 ospf->stub_router_shutdown_time, VTY_NEWLINE);
7154 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7155 {
7156 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7157 {
7158 vty_out (vty, " max-metric router-lsa administrative%s",
7159 VTY_NEWLINE);
7160 break;
7161 }
7162 }
7163 return;
7164 }
7165 \f
7166 static void
7167 show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7168 {
7169 struct route_node *rn;
7170 struct ospf_route *or;
7171 struct listnode *pnode, *pnnode;
7172 struct ospf_path *path;
7173
7174 vty_out (vty, "============ OSPF network routing table ============%s",
7175 VTY_NEWLINE);
7176
7177 for (rn = route_top (rt); rn; rn = route_next (rn))
7178 if ((or = rn->info) != NULL)
7179 {
7180 char buf1[19];
7181 snprintf (buf1, 19, "%s/%d",
7182 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7183
7184 switch (or->path_type)
7185 {
7186 case OSPF_PATH_INTER_AREA:
7187 if (or->type == OSPF_DESTINATION_NETWORK)
7188 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7189 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7190 else if (or->type == OSPF_DESTINATION_DISCARD)
7191 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7192 break;
7193 case OSPF_PATH_INTRA_AREA:
7194 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7195 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7196 break;
7197 default:
7198 break;
7199 }
7200
7201 if (or->type == OSPF_DESTINATION_NETWORK)
7202 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
7203 {
7204 if (if_lookup_by_index(path->ifindex))
7205 {
7206 if (path->nexthop.s_addr == 0)
7207 vty_out (vty, "%24s directly attached to %s%s",
7208 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
7209 else
7210 vty_out (vty, "%24s via %s, %s%s", "",
7211 inet_ntoa (path->nexthop),
7212 ifindex2ifname (path->ifindex), VTY_NEWLINE);
7213 }
7214 }
7215 }
7216 vty_out (vty, "%s", VTY_NEWLINE);
7217 }
7218
7219 static void
7220 show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7221 {
7222 struct route_node *rn;
7223 struct ospf_route *or;
7224 struct listnode *pnode;
7225 struct listnode *node;
7226 struct ospf_path *path;
7227
7228 vty_out (vty, "============ OSPF router routing table =============%s",
7229 VTY_NEWLINE);
7230 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7231 if (rn->info)
7232 {
7233 int flag = 0;
7234
7235 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7236
7237 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7238 {
7239 if (flag++)
7240 vty_out (vty, "%24s", "");
7241
7242 /* Show path. */
7243 vty_out (vty, "%s [%d] area: %s",
7244 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7245 or->cost, inet_ntoa (or->u.std.area_id));
7246 /* Show flags. */
7247 vty_out (vty, "%s%s%s",
7248 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7249 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7250 VTY_NEWLINE);
7251
7252 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7253 {
7254 if (if_lookup_by_index(path->ifindex))
7255 {
7256 if (path->nexthop.s_addr == 0)
7257 vty_out (vty, "%24s directly attached to %s%s",
7258 "", ifindex2ifname (path->ifindex),
7259 VTY_NEWLINE);
7260 else
7261 vty_out (vty, "%24s via %s, %s%s", "",
7262 inet_ntoa (path->nexthop),
7263 ifindex2ifname (path->ifindex),
7264 VTY_NEWLINE);
7265 }
7266 }
7267 }
7268 }
7269 vty_out (vty, "%s", VTY_NEWLINE);
7270 }
7271
7272 static void
7273 show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7274 {
7275 struct route_node *rn;
7276 struct ospf_route *er;
7277 struct listnode *pnode, *pnnode;
7278 struct ospf_path *path;
7279
7280 vty_out (vty, "============ OSPF external routing table ===========%s",
7281 VTY_NEWLINE);
7282 for (rn = route_top (rt); rn; rn = route_next (rn))
7283 if ((er = rn->info) != NULL)
7284 {
7285 char buf1[19];
7286 snprintf (buf1, 19, "%s/%d",
7287 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7288
7289 switch (er->path_type)
7290 {
7291 case OSPF_PATH_TYPE1_EXTERNAL:
7292 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7293 er->cost, er->u.ext.tag, VTY_NEWLINE);
7294 break;
7295 case OSPF_PATH_TYPE2_EXTERNAL:
7296 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7297 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7298 break;
7299 }
7300
7301 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
7302 {
7303 if (if_lookup_by_index(path->ifindex))
7304 {
7305 if (path->nexthop.s_addr == 0)
7306 vty_out (vty, "%24s directly attached to %s%s",
7307 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
7308 else
7309 vty_out (vty, "%24s via %s, %s%s", "",
7310 inet_ntoa (path->nexthop),
7311 ifindex2ifname (path->ifindex),
7312 VTY_NEWLINE);
7313 }
7314 }
7315 }
7316 vty_out (vty, "%s", VTY_NEWLINE);
7317 }
7318
7319 DEFUN (show_ip_ospf_border_routers,
7320 show_ip_ospf_border_routers_cmd,
7321 "show ip ospf border-routers",
7322 SHOW_STR
7323 IP_STR
7324 "show all the ABR's and ASBR's\n"
7325 "for this area\n")
7326 {
7327 struct ospf *ospf;
7328
7329 if ((ospf = ospf_lookup ()) == NULL)
7330 {
7331 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
7332 return CMD_SUCCESS;
7333 }
7334
7335 if (ospf->new_table == NULL)
7336 {
7337 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7338 return CMD_SUCCESS;
7339 }
7340
7341 /* Show Network routes.
7342 show_ip_ospf_route_network (vty, ospf->new_table); */
7343
7344 /* Show Router routes. */
7345 show_ip_ospf_route_router (vty, ospf->new_rtrs);
7346
7347 return CMD_SUCCESS;
7348 }
7349
7350 DEFUN (show_ip_ospf_route,
7351 show_ip_ospf_route_cmd,
7352 "show ip ospf route",
7353 SHOW_STR
7354 IP_STR
7355 "OSPF information\n"
7356 "OSPF routing table\n")
7357 {
7358 struct ospf *ospf;
7359
7360 if ((ospf = ospf_lookup ()) == NULL)
7361 {
7362 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
7363 return CMD_SUCCESS;
7364 }
7365
7366 if (ospf->new_table == NULL)
7367 {
7368 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7369 return CMD_SUCCESS;
7370 }
7371
7372 /* Show Network routes. */
7373 show_ip_ospf_route_network (vty, ospf->new_table);
7374
7375 /* Show Router routes. */
7376 show_ip_ospf_route_router (vty, ospf->new_rtrs);
7377
7378 /* Show AS External routes. */
7379 show_ip_ospf_route_external (vty, ospf->old_external_route);
7380
7381 return CMD_SUCCESS;
7382 }
7383
7384 \f
7385 const char *ospf_abr_type_str[] =
7386 {
7387 "unknown",
7388 "standard",
7389 "ibm",
7390 "cisco",
7391 "shortcut"
7392 };
7393
7394 const char *ospf_shortcut_mode_str[] =
7395 {
7396 "default",
7397 "enable",
7398 "disable"
7399 };
7400
7401
7402 static void
7403 area_id2str (char *buf, int length, struct ospf_area *area)
7404 {
7405 memset (buf, 0, length);
7406
7407 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7408 strncpy (buf, inet_ntoa (area->area_id), length);
7409 else
7410 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7411 }
7412
7413 \f
7414 const char *ospf_int_type_str[] =
7415 {
7416 "unknown", /* should never be used. */
7417 "point-to-point",
7418 "broadcast",
7419 "non-broadcast",
7420 "point-to-multipoint",
7421 "virtual-link", /* should never be used. */
7422 "loopback"
7423 };
7424
7425 /* Configuration write function for ospfd. */
7426 static int
7427 config_write_interface (struct vty *vty)
7428 {
7429 struct listnode *n1, *n2;
7430 struct interface *ifp;
7431 struct crypt_key *ck;
7432 int write = 0;
7433 struct route_node *rn = NULL;
7434 struct ospf_if_params *params;
7435
7436 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
7437 {
7438 if (memcmp (ifp->name, "VLINK", 5) == 0)
7439 continue;
7440
7441 vty_out (vty, "!%s", VTY_NEWLINE);
7442 vty_out (vty, "interface %s%s", ifp->name,
7443 VTY_NEWLINE);
7444 if (ifp->desc)
7445 vty_out (vty, " description %s%s", ifp->desc,
7446 VTY_NEWLINE);
7447
7448 write++;
7449
7450 params = IF_DEF_PARAMS (ifp);
7451
7452 do {
7453 /* Interface Network print. */
7454 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
7455 params->type != OSPF_IFTYPE_LOOPBACK)
7456 {
7457 if (params->type != ospf_default_iftype(ifp))
7458 {
7459 vty_out (vty, " ip ospf network %s",
7460 ospf_int_type_str[params->type]);
7461 if (params != IF_DEF_PARAMS (ifp))
7462 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7463 vty_out (vty, "%s", VTY_NEWLINE);
7464 }
7465 }
7466
7467 /* OSPF interface authentication print */
7468 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7469 params->auth_type != OSPF_AUTH_NOTSET)
7470 {
7471 const char *auth_str;
7472
7473 /* Translation tables are not that much help here due to syntax
7474 of the simple option */
7475 switch (params->auth_type)
7476 {
7477
7478 case OSPF_AUTH_NULL:
7479 auth_str = " null";
7480 break;
7481
7482 case OSPF_AUTH_SIMPLE:
7483 auth_str = "";
7484 break;
7485
7486 case OSPF_AUTH_CRYPTOGRAPHIC:
7487 auth_str = " message-digest";
7488 break;
7489
7490 default:
7491 auth_str = "";
7492 break;
7493 }
7494
7495 vty_out (vty, " ip ospf authentication%s", auth_str);
7496 if (params != IF_DEF_PARAMS (ifp))
7497 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7498 vty_out (vty, "%s", VTY_NEWLINE);
7499 }
7500
7501 /* Simple Authentication Password print. */
7502 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7503 params->auth_simple[0] != '\0')
7504 {
7505 vty_out (vty, " ip ospf authentication-key %s",
7506 params->auth_simple);
7507 if (params != IF_DEF_PARAMS (ifp))
7508 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7509 vty_out (vty, "%s", VTY_NEWLINE);
7510 }
7511
7512 /* Cryptographic Authentication Key print. */
7513 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
7514 {
7515 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7516 ck->key_id, ck->auth_key);
7517 if (params != IF_DEF_PARAMS (ifp))
7518 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7519 vty_out (vty, "%s", VTY_NEWLINE);
7520 }
7521
7522 /* Interface Output Cost print. */
7523 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7524 {
7525 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7526 if (params != IF_DEF_PARAMS (ifp))
7527 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7528 vty_out (vty, "%s", VTY_NEWLINE);
7529 }
7530
7531 /* Hello Interval print. */
7532 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7533 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7534 {
7535 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7536 if (params != IF_DEF_PARAMS (ifp))
7537 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7538 vty_out (vty, "%s", VTY_NEWLINE);
7539 }
7540
7541
7542 /* Router Dead Interval print. */
7543 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7544 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7545 {
7546 vty_out (vty, " ip ospf dead-interval ");
7547
7548 /* fast hello ? */
7549 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7550 vty_out (vty, "minimal hello-multiplier %d",
7551 params->fast_hello);
7552 else
7553 vty_out (vty, "%u", params->v_wait);
7554
7555 if (params != IF_DEF_PARAMS (ifp))
7556 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7557 vty_out (vty, "%s", VTY_NEWLINE);
7558 }
7559
7560 /* Router Priority print. */
7561 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7562 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7563 {
7564 vty_out (vty, " ip ospf priority %u", params->priority);
7565 if (params != IF_DEF_PARAMS (ifp))
7566 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7567 vty_out (vty, "%s", VTY_NEWLINE);
7568 }
7569
7570 /* Retransmit Interval print. */
7571 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7572 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7573 {
7574 vty_out (vty, " ip ospf retransmit-interval %u",
7575 params->retransmit_interval);
7576 if (params != IF_DEF_PARAMS (ifp))
7577 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7578 vty_out (vty, "%s", VTY_NEWLINE);
7579 }
7580
7581 /* Transmit Delay print. */
7582 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7583 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7584 {
7585 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7586 if (params != IF_DEF_PARAMS (ifp))
7587 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7588 vty_out (vty, "%s", VTY_NEWLINE);
7589 }
7590
7591 /* MTU ignore print. */
7592 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7593 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7594 {
7595 if (params->mtu_ignore == 0)
7596 vty_out (vty, " no ip ospf mtu-ignore");
7597 else
7598 vty_out (vty, " ip ospf mtu-ignore");
7599 if (params != IF_DEF_PARAMS (ifp))
7600 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7601 vty_out (vty, "%s", VTY_NEWLINE);
7602 }
7603
7604
7605 while (1)
7606 {
7607 if (rn == NULL)
7608 rn = route_top (IF_OIFS_PARAMS (ifp));
7609 else
7610 rn = route_next (rn);
7611
7612 if (rn == NULL)
7613 break;
7614 params = rn->info;
7615 if (params != NULL)
7616 break;
7617 }
7618 } while (rn);
7619
7620 #ifdef HAVE_OPAQUE_LSA
7621 ospf_opaque_config_write_if (vty, ifp);
7622 #endif /* HAVE_OPAQUE_LSA */
7623 }
7624
7625 return write;
7626 }
7627
7628 static int
7629 config_write_network_area (struct vty *vty, struct ospf *ospf)
7630 {
7631 struct route_node *rn;
7632 u_char buf[INET_ADDRSTRLEN];
7633
7634 /* `network area' print. */
7635 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
7636 if (rn->info)
7637 {
7638 struct ospf_network *n = rn->info;
7639
7640 memset (buf, 0, INET_ADDRSTRLEN);
7641
7642 /* Create Area ID string by specified Area ID format. */
7643 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7644 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
7645 else
7646 sprintf ((char *) buf, "%lu",
7647 (unsigned long int) ntohl (n->area_id.s_addr));
7648
7649 /* Network print. */
7650 vty_out (vty, " network %s/%d area %s%s",
7651 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7652 buf, VTY_NEWLINE);
7653 }
7654
7655 return 0;
7656 }
7657
7658 static int
7659 config_write_ospf_area (struct vty *vty, struct ospf *ospf)
7660 {
7661 struct listnode *node;
7662 struct ospf_area *area;
7663 u_char buf[INET_ADDRSTRLEN];
7664
7665 /* Area configuration print. */
7666 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
7667 {
7668 struct route_node *rn1;
7669
7670 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
7671
7672 if (area->auth_type != OSPF_AUTH_NULL)
7673 {
7674 if (area->auth_type == OSPF_AUTH_SIMPLE)
7675 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7676 else
7677 vty_out (vty, " area %s authentication message-digest%s",
7678 buf, VTY_NEWLINE);
7679 }
7680
7681 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7682 vty_out (vty, " area %s shortcut %s%s", buf,
7683 ospf_shortcut_mode_str[area->shortcut_configured],
7684 VTY_NEWLINE);
7685
7686 if ((area->external_routing == OSPF_AREA_STUB)
7687 || (area->external_routing == OSPF_AREA_NSSA)
7688 )
7689 {
7690 if (area->external_routing == OSPF_AREA_STUB)
7691 vty_out (vty, " area %s stub", buf);
7692 else if (area->external_routing == OSPF_AREA_NSSA)
7693 {
7694 vty_out (vty, " area %s nssa", buf);
7695 switch (area->NSSATranslatorRole)
7696 {
7697 case OSPF_NSSA_ROLE_NEVER:
7698 vty_out (vty, " translate-never");
7699 break;
7700 case OSPF_NSSA_ROLE_ALWAYS:
7701 vty_out (vty, " translate-always");
7702 break;
7703 case OSPF_NSSA_ROLE_CANDIDATE:
7704 default:
7705 vty_out (vty, " translate-candidate");
7706 }
7707 }
7708
7709 if (area->no_summary)
7710 vty_out (vty, " no-summary");
7711
7712 vty_out (vty, "%s", VTY_NEWLINE);
7713
7714 if (area->default_cost != 1)
7715 vty_out (vty, " area %s default-cost %d%s", buf,
7716 area->default_cost, VTY_NEWLINE);
7717 }
7718
7719 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7720 if (rn1->info)
7721 {
7722 struct ospf_area_range *range = rn1->info;
7723
7724 vty_out (vty, " area %s range %s/%d", buf,
7725 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7726
7727 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
7728 vty_out (vty, " cost %d", range->cost_config);
7729
7730 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7731 vty_out (vty, " not-advertise");
7732
7733 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7734 vty_out (vty, " substitute %s/%d",
7735 inet_ntoa (range->subst_addr), range->subst_masklen);
7736
7737 vty_out (vty, "%s", VTY_NEWLINE);
7738 }
7739
7740 if (EXPORT_NAME (area))
7741 vty_out (vty, " area %s export-list %s%s", buf,
7742 EXPORT_NAME (area), VTY_NEWLINE);
7743
7744 if (IMPORT_NAME (area))
7745 vty_out (vty, " area %s import-list %s%s", buf,
7746 IMPORT_NAME (area), VTY_NEWLINE);
7747
7748 if (PREFIX_NAME_IN (area))
7749 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7750 PREFIX_NAME_IN (area), VTY_NEWLINE);
7751
7752 if (PREFIX_NAME_OUT (area))
7753 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7754 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7755 }
7756
7757 return 0;
7758 }
7759
7760 static int
7761 config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
7762 {
7763 struct ospf_nbr_nbma *nbr_nbma;
7764 struct route_node *rn;
7765
7766 /* Static Neighbor configuration print. */
7767 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
7768 if ((nbr_nbma = rn->info))
7769 {
7770 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7771
7772 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7773 vty_out (vty, " priority %d", nbr_nbma->priority);
7774
7775 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7776 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7777
7778 vty_out (vty, "%s", VTY_NEWLINE);
7779 }
7780
7781 return 0;
7782 }
7783
7784 static int
7785 config_write_virtual_link (struct vty *vty, struct ospf *ospf)
7786 {
7787 struct listnode *node;
7788 struct ospf_vl_data *vl_data;
7789 u_char buf[INET_ADDRSTRLEN];
7790
7791 /* Virtual-Link print */
7792 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
7793 {
7794 struct listnode *n2;
7795 struct crypt_key *ck;
7796 struct ospf_interface *oi;
7797
7798 if (vl_data != NULL)
7799 {
7800 memset (buf, 0, INET_ADDRSTRLEN);
7801
7802 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7803 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
7804 else
7805 sprintf ((char *) buf, "%lu",
7806 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7807 oi = vl_data->vl_oi;
7808
7809 /* timers */
7810 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7811 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7812 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7813 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7814 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7815 buf,
7816 inet_ntoa (vl_data->vl_peer),
7817 OSPF_IF_PARAM (oi, v_hello),
7818 OSPF_IF_PARAM (oi, retransmit_interval),
7819 OSPF_IF_PARAM (oi, transmit_delay),
7820 OSPF_IF_PARAM (oi, v_wait),
7821 VTY_NEWLINE);
7822 else
7823 vty_out (vty, " area %s virtual-link %s%s", buf,
7824 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7825 /* Auth key */
7826 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7827 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7828 buf,
7829 inet_ntoa (vl_data->vl_peer),
7830 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7831 VTY_NEWLINE);
7832 /* md5 keys */
7833 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7834 n2, ck))
7835 vty_out (vty, " area %s virtual-link %s"
7836 " message-digest-key %d md5 %s%s",
7837 buf,
7838 inet_ntoa (vl_data->vl_peer),
7839 ck->key_id, ck->auth_key, VTY_NEWLINE);
7840
7841 }
7842 }
7843
7844 return 0;
7845 }
7846
7847 \f
7848 static int
7849 config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
7850 {
7851 int type;
7852
7853 /* redistribute print. */
7854 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7855 if (type != zclient->redist_default && zclient->redist[type])
7856 {
7857 vty_out (vty, " redistribute %s", zebra_route_string(type));
7858 if (ospf->dmetric[type].value >= 0)
7859 vty_out (vty, " metric %d", ospf->dmetric[type].value);
7860
7861 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
7862 vty_out (vty, " metric-type 1");
7863
7864 if (ROUTEMAP_NAME (ospf, type))
7865 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
7866
7867 vty_out (vty, "%s", VTY_NEWLINE);
7868 }
7869
7870 return 0;
7871 }
7872
7873 static int
7874 config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
7875 {
7876 if (ospf->default_metric != -1)
7877 vty_out (vty, " default-metric %d%s", ospf->default_metric,
7878 VTY_NEWLINE);
7879 return 0;
7880 }
7881
7882 static int
7883 config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
7884 {
7885 int type;
7886
7887 if (ospf)
7888 {
7889 /* distribute-list print. */
7890 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7891 if (DISTRIBUTE_NAME (ospf, type))
7892 vty_out (vty, " distribute-list %s out %s%s",
7893 DISTRIBUTE_NAME (ospf, type),
7894 zebra_route_string(type), VTY_NEWLINE);
7895
7896 /* default-information print. */
7897 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
7898 {
7899 vty_out (vty, " default-information originate");
7900 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7901 vty_out (vty, " always");
7902
7903 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
7904 vty_out (vty, " metric %d",
7905 ospf->dmetric[DEFAULT_ROUTE].value);
7906 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
7907 vty_out (vty, " metric-type 1");
7908
7909 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7910 vty_out (vty, " route-map %s",
7911 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
7912
7913 vty_out (vty, "%s", VTY_NEWLINE);
7914 }
7915
7916 }
7917
7918 return 0;
7919 }
7920
7921 static int
7922 config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
7923 {
7924 struct route_node *rn;
7925 struct ospf_distance *odistance;
7926
7927 if (ospf->distance_all)
7928 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
7929
7930 if (ospf->distance_intra
7931 || ospf->distance_inter
7932 || ospf->distance_external)
7933 {
7934 vty_out (vty, " distance ospf");
7935
7936 if (ospf->distance_intra)
7937 vty_out (vty, " intra-area %d", ospf->distance_intra);
7938 if (ospf->distance_inter)
7939 vty_out (vty, " inter-area %d", ospf->distance_inter);
7940 if (ospf->distance_external)
7941 vty_out (vty, " external %d", ospf->distance_external);
7942
7943 vty_out (vty, "%s", VTY_NEWLINE);
7944 }
7945
7946 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
7947 if ((odistance = rn->info) != NULL)
7948 {
7949 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7950 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7951 odistance->access_list ? odistance->access_list : "",
7952 VTY_NEWLINE);
7953 }
7954 return 0;
7955 }
7956
7957 /* OSPF configuration write function. */
7958 static int
7959 ospf_config_write (struct vty *vty)
7960 {
7961 struct ospf *ospf;
7962 struct interface *ifp;
7963 struct ospf_interface *oi;
7964 struct listnode *node;
7965 int write = 0;
7966
7967 ospf = ospf_lookup ();
7968 if (ospf != NULL)
7969 {
7970 /* `router ospf' print. */
7971 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7972
7973 write++;
7974
7975 if (!ospf->networks)
7976 return write;
7977
7978 /* Router ID print. */
7979 if (ospf->router_id_static.s_addr != 0)
7980 vty_out (vty, " ospf router-id %s%s",
7981 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
7982
7983 /* ABR type print. */
7984 if (ospf->abr_type != OSPF_ABR_DEFAULT)
7985 vty_out (vty, " ospf abr-type %s%s",
7986 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
7987
7988 /* log-adjacency-changes flag print. */
7989 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7990 {
7991 vty_out(vty, " log-adjacency-changes");
7992 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7993 vty_out(vty, " detail");
7994 vty_out(vty, "%s", VTY_NEWLINE);
7995 }
7996
7997 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
7998 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
7999 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
8000
8001 /* auto-cost reference-bandwidth configuration. */
8002 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
8003 {
8004 vty_out (vty, "! Important: ensure reference bandwidth "
8005 "is consistent across all routers%s", VTY_NEWLINE);
8006 vty_out (vty, " auto-cost reference-bandwidth %d%s",
8007 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
8008 }
8009
8010 /* SPF timers print. */
8011 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
8012 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
8013 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
8014 vty_out (vty, " timers throttle spf %d %d %d%s",
8015 ospf->spf_delay, ospf->spf_holdtime,
8016 ospf->spf_max_holdtime, VTY_NEWLINE);
8017
8018 /* Max-metric router-lsa print */
8019 config_write_stub_router (vty, ospf);
8020
8021 /* SPF refresh parameters print. */
8022 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
8023 vty_out (vty, " refresh timer %d%s",
8024 ospf->lsa_refresh_interval, VTY_NEWLINE);
8025
8026 /* Redistribute information print. */
8027 config_write_ospf_redistribute (vty, ospf);
8028
8029 /* passive-interface print. */
8030 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
8031 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
8032
8033 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
8034 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
8035 && IF_DEF_PARAMS (ifp)->passive_interface !=
8036 ospf->passive_interface_default)
8037 {
8038 vty_out (vty, " %spassive-interface %s%s",
8039 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
8040 ifp->name, VTY_NEWLINE);
8041 }
8042 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
8043 {
8044 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
8045 continue;
8046 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
8047 passive_interface))
8048 {
8049 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
8050 continue;
8051 }
8052 else if (oi->params->passive_interface == ospf->passive_interface_default)
8053 continue;
8054
8055 vty_out (vty, " %spassive-interface %s %s%s",
8056 oi->params->passive_interface ? "" : "no ",
8057 oi->ifp->name,
8058 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
8059 }
8060
8061 /* Network area print. */
8062 config_write_network_area (vty, ospf);
8063
8064 /* Area config print. */
8065 config_write_ospf_area (vty, ospf);
8066
8067 /* static neighbor print. */
8068 config_write_ospf_nbr_nbma (vty, ospf);
8069
8070 /* Virtual-Link print. */
8071 config_write_virtual_link (vty, ospf);
8072
8073 /* Default metric configuration. */
8074 config_write_ospf_default_metric (vty, ospf);
8075
8076 /* Distribute-list and default-information print. */
8077 config_write_ospf_distribute (vty, ospf);
8078
8079 /* Distance configuration. */
8080 config_write_ospf_distance (vty, ospf);
8081
8082 #ifdef HAVE_OPAQUE_LSA
8083 ospf_opaque_config_write_router (vty, ospf);
8084 #endif /* HAVE_OPAQUE_LSA */
8085 }
8086
8087 return write;
8088 }
8089
8090 void
8091 ospf_vty_show_init (void)
8092 {
8093 /* "show ip ospf" commands. */
8094 install_element (VIEW_NODE, &show_ip_ospf_cmd);
8095 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
8096
8097 /* "show ip ospf database" commands. */
8098 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
8099 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
8100 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8101 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8102 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
8103 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
8104 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
8105 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
8106 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
8107 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8108 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8109 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
8110 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
8111 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
8112
8113 /* "show ip ospf interface" commands. */
8114 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
8115 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
8116
8117 /* "show ip ospf neighbor" commands. */
8118 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8119 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
8120 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
8121 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8122 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
8123 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
8124 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
8125 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8126 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
8127 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
8128 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8129 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
8130 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
8131 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
8132
8133 /* "show ip ospf route" commands. */
8134 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
8135 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
8136 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
8137 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
8138 }
8139
8140 \f
8141 /* ospfd's interface node. */
8142 static struct cmd_node interface_node =
8143 {
8144 INTERFACE_NODE,
8145 "%s(config-if)# ",
8146 1
8147 };
8148
8149 /* Initialization of OSPF interface. */
8150 static void
8151 ospf_vty_if_init (void)
8152 {
8153 /* Install interface node. */
8154 install_node (&interface_node, config_write_interface);
8155
8156 install_element (CONFIG_NODE, &interface_cmd);
8157 install_element (CONFIG_NODE, &no_interface_cmd);
8158 install_default (INTERFACE_NODE);
8159
8160 /* "description" commands. */
8161 install_element (INTERFACE_NODE, &interface_desc_cmd);
8162 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
8163
8164 /* "ip ospf authentication" commands. */
8165 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
8166 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
8167 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
8168 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
8169 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
8170 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
8171 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
8172 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
8173 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
8174 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
8175
8176 /* "ip ospf message-digest-key" commands. */
8177 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
8178 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
8179 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8180 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8181
8182 /* "ip ospf cost" commands. */
8183 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
8184 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
8185 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
8186 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
8187 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
8188 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8189
8190 /* "ip ospf mtu-ignore" commands. */
8191 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8192 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8193 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8194 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8195
8196 /* "ip ospf dead-interval" commands. */
8197 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8198 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
8199 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8200 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
8201 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8202 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
8203
8204 /* "ip ospf hello-interval" commands. */
8205 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8206 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8207 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8208 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8209
8210 /* "ip ospf network" commands. */
8211 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8212 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8213
8214 /* "ip ospf priority" commands. */
8215 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8216 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8217 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8218 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8219
8220 /* "ip ospf retransmit-interval" commands. */
8221 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8222 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8223 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8224 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8225
8226 /* "ip ospf transmit-delay" commands. */
8227 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8228 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8229 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8230 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8231
8232 /* These commands are compatibitliy for previous version. */
8233 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8234 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8235 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8236 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
8237 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
8238 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
8239 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
8240 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
8241 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
8242 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
8243 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8244 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8245 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8246 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8247 install_element (INTERFACE_NODE, &ospf_network_cmd);
8248 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8249 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8250 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8251 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8252 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8253 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8254 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8255 }
8256
8257 static void
8258 ospf_vty_zebra_init (void)
8259 {
8260 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8261 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8262 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8263 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8264 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8265 install_element (OSPF_NODE,
8266 &ospf_redistribute_source_metric_type_routemap_cmd);
8267 install_element (OSPF_NODE,
8268 &ospf_redistribute_source_type_metric_routemap_cmd);
8269 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8270 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8271 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8272
8273 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8274
8275 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8276 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8277
8278 install_element (OSPF_NODE,
8279 &ospf_default_information_originate_metric_type_cmd);
8280 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8281 install_element (OSPF_NODE,
8282 &ospf_default_information_originate_type_metric_cmd);
8283 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8284 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8285 install_element (OSPF_NODE,
8286 &ospf_default_information_originate_always_metric_type_cmd);
8287 install_element (OSPF_NODE,
8288 &ospf_default_information_originate_always_metric_cmd);
8289 install_element (OSPF_NODE,
8290 &ospf_default_information_originate_always_cmd);
8291 install_element (OSPF_NODE,
8292 &ospf_default_information_originate_always_type_metric_cmd);
8293 install_element (OSPF_NODE,
8294 &ospf_default_information_originate_always_type_cmd);
8295
8296 install_element (OSPF_NODE,
8297 &ospf_default_information_originate_metric_type_routemap_cmd);
8298 install_element (OSPF_NODE,
8299 &ospf_default_information_originate_metric_routemap_cmd);
8300 install_element (OSPF_NODE,
8301 &ospf_default_information_originate_routemap_cmd);
8302 install_element (OSPF_NODE,
8303 &ospf_default_information_originate_type_metric_routemap_cmd);
8304 install_element (OSPF_NODE,
8305 &ospf_default_information_originate_type_routemap_cmd);
8306 install_element (OSPF_NODE,
8307 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8308 install_element (OSPF_NODE,
8309 &ospf_default_information_originate_always_metric_routemap_cmd);
8310 install_element (OSPF_NODE,
8311 &ospf_default_information_originate_always_routemap_cmd);
8312 install_element (OSPF_NODE,
8313 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8314 install_element (OSPF_NODE,
8315 &ospf_default_information_originate_always_type_routemap_cmd);
8316
8317 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8318
8319 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8320 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8321 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8322
8323 install_element (OSPF_NODE, &ospf_distance_cmd);
8324 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8325 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8326 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8327 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8328 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8329 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8330 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8331 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8332 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8333 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8334 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8335 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8336 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8337 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8338 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8339 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8340 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8341 #if 0
8342 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8343 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8344 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8345 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8346 #endif /* 0 */
8347 }
8348
8349 static struct cmd_node ospf_node =
8350 {
8351 OSPF_NODE,
8352 "%s(config-router)# ",
8353 1
8354 };
8355
8356 \f
8357 /* Install OSPF related vty commands. */
8358 void
8359 ospf_vty_init (void)
8360 {
8361 /* Install ospf top node. */
8362 install_node (&ospf_node, ospf_config_write);
8363
8364 /* "router ospf" commands. */
8365 install_element (CONFIG_NODE, &router_ospf_cmd);
8366 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8367
8368 install_default (OSPF_NODE);
8369
8370 /* "ospf router-id" commands. */
8371 install_element (OSPF_NODE, &ospf_router_id_cmd);
8372 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
8373 install_element (OSPF_NODE, &router_ospf_id_cmd);
8374 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
8375
8376 /* "passive-interface" commands. */
8377 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8378 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8379 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
8380 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8381 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
8382 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
8383
8384 /* "ospf abr-type" commands. */
8385 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8386 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8387
8388 /* "ospf log-adjacency-changes" commands. */
8389 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8390 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8391 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8392 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8393
8394 /* "ospf rfc1583-compatible" commands. */
8395 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8396 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8397 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8398 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8399
8400 /* "network area" commands. */
8401 install_element (OSPF_NODE, &ospf_network_area_cmd);
8402 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
8403
8404 /* "area authentication" commands. */
8405 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8406 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8407 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
8408
8409 /* "area range" commands. */
8410 install_element (OSPF_NODE, &ospf_area_range_cmd);
8411 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8412 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8413 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8414 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8415 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8416 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8417 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8418 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8419 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8420 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
8421
8422 /* "area virtual-link" commands. */
8423 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8424 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
8425
8426 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8427 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
8428
8429 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8430 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
8431
8432 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8433 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
8434
8435 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8436 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
8437
8438 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8439 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8440 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
8441
8442 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8443 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
8444
8445 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8446 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
8447
8448 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8449 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8450 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
8451
8452 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8453 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8454 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
8455
8456 /* "area stub" commands. */
8457 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8458 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8459 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8460 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
8461
8462 /* "area nssa" commands. */
8463 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8464 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8465 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8466 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8467 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8468 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
8469
8470 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8471 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
8472
8473 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8474 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
8475
8476 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8477 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
8478
8479 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8480 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
8481
8482 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8483 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
8484
8485 /* SPF timer commands */
8486 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8487 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
8488 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8489 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8490
8491 /* refresh timer commands */
8492 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8493 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8494 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
8495
8496 /* max-metric commands */
8497 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8498 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8499 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8500 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8501 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8502 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8503
8504 /* reference bandwidth commands */
8505 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8506 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
8507
8508 /* "neighbor" commands. */
8509 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8510 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8511 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8512 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8513 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8514 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8515 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8516 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
8517
8518 /* Init interface related vty commands. */
8519 ospf_vty_if_init ();
8520
8521 /* Init zebra related vty commands. */
8522 ospf_vty_zebra_init ();
8523 }