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