blob: accf7a8c7e1b3a12bd4348259052e50795f21015 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* 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
52static char *ospf_network_type_str[] =
53{
54 "Null",
55 "POINTOPOINT",
56 "BROADCAST",
57 "NBMA",
58 "POINTOMULTIPOINT",
59 "VIRTUALLINK",
60 "LOOPBACK"
61};
62
63
64/* Utility functions. */
65int
66ospf_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
94int
95str2distribute_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
117int
118str2metric (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
134int
135str2metric_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
151int
152ospf_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
165DEFUN (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
177DEFUN (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
195DEFUN (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
223ALIAS (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
229DEFUN (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
243ALIAS (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
249DEFUN (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
290ALIAS (passive_interface,
291 passive_interface_cmd,
292 "passive-interface IFNAME",
293 "Suppress routing updates on an interface\n"
294 "Interface's name\n")
295
296DEFUN (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
345ALIAS (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
352DEFUN (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
380DEFUN (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
411DEFUN (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
439ALIAS (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
449ALIAS (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
460ALIAS (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
472DEFUN (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
495DEFUN (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
518ALIAS (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
530ALIAS (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
542ALIAS (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
555DEFUN (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
580DEFUN (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
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 */
625struct 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
640void
641ospf_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
649struct ospf_vl_data *
650ospf_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
706int
707ospf_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
765int
766ospf_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 */
802int
803ospf_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
870DEFUN (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
1003DEFUN (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
1119ALIAS (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
1126ALIAS (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
1134ALIAS (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
1143ALIAS (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
1153ALIAS (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
1164ALIAS (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
1176ALIAS (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
1189ALIAS (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
1203ALIAS (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
1210ALIAS (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
1217ALIAS (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
1225ALIAS (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
1232ALIAS (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
1240ALIAS (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
1247ALIAS (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
1255ALIAS (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
1264ALIAS (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
1273ALIAS (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
1283ALIAS (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
1292ALIAS (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
1301ALIAS (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
1312DEFUN (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
1351DEFUN (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
1378DEFUN (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
1405DEFUN (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
1433DEFUN (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
1454DEFUN (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
1475DEFUN (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
1516ALIAS (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
1529ALIAS (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
1540DEFUN (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
1568DEFUN (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
1589DEFUN (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
1611DEFUN (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
1641DEFUN (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
1676DEFUN (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
1697DEFUN (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
1723DEFUN (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
1744DEFUN (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
1768DEFUN (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
1811DEFUN (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
1866DEFUN (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
1885DEFUN (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
1905DEFUN (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
1932DEFUN (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
1965DEFUN (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
1996DEFUN (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
2012DEFUN (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
2029ALIAS (ospf_compatible_rfc1583,
2030 ospf_rfc1583_flag_cmd,
2031 "ospf rfc1583compatibility",
2032 "OSPF specific commands\n"
2033 "Enable the RFC1583Compatibility flag\n")
2034
2035ALIAS (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
2042DEFUN (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
2061DEFUN (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
2075DEFUN (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
2103ALIAS (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
2113ALIAS (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
2121DEFUN (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
2151ALIAS (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
2161DEFUN (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
2179ALIAS (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
2188ALIAS (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
2197ALIAS (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
2209DEFUN (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
2226DEFUN (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
2249ALIAS (no_refresh_timer,
2250 no_refresh_timer_cmd,
2251 "no refresh timer",
2252 "Adjust refresh parameters\n"
2253 "Unset refresh timer\n")
2254
2255DEFUN (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
2286DEFUN (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
2310DEFUN (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
2348char *ospf_abr_type_descr_str[] =
2349{
2350 "Unknown",
2351 "Standard (RFC2328)",
2352 "Alternative IBM",
2353 "Alternative Cisco",
2354 "Alternative Shortcut"
2355};
2356
2357char *ospf_shortcut_mode_descr_str[] =
2358{
2359 "Default",
2360 "Enabled",
2361 "Disabled"
2362};
2363
2364
2365
2366void
2367show_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
2447DEFUN (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
2518void
2519show_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? */
paul2e3b2e42002-12-13 21:03:13 +00002529 if (if_is_operative (ifp)) {
2530 vty_out (vty, "%s is up%s", ifp->name, VTY_NEWLINE);
2531 } else
2532 {
2533 vty_out (vty, "%s is down%s", ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002534
2535
2536 if (oi_count == 0)
2537 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2538 else
2539 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2540 VTY_NEWLINE);
2541 return;
2542 }
2543
2544 /* Is interface OSPF enabled? */
2545 if (oi_count == 0)
2546 {
2547 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2548 return;
2549 }
2550
2551 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2552 {
2553 struct ospf_interface *oi = rn->info;
2554
2555 if (oi == NULL)
2556 continue;
2557
2558 /* Show OSPF interface information. */
2559 vty_out (vty, " Internet Address %s/%d,",
2560 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2561
2562 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2563 VTY_NEWLINE);
2564
2565 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
2566 inet_ntoa (ospf_top->router_id), ospf_network_type_str[oi->type],
2567 oi->output_cost, VTY_NEWLINE);
2568
2569 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2570 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2571 PRIORITY (oi), VTY_NEWLINE);
2572
2573 /* Show DR information. */
2574 if (DR (oi).s_addr == 0)
2575 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2576 else
2577 {
2578 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2579 if (nbr == NULL)
2580 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2581 else
2582 {
2583 vty_out (vty, " Designated Router (ID) %s,",
2584 inet_ntoa (nbr->router_id));
2585 vty_out (vty, " Interface Address %s%s",
2586 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2587 }
2588 }
2589
2590 /* Show BDR information. */
2591 if (BDR (oi).s_addr == 0)
2592 vty_out (vty, " No backup designated router on this network%s",
2593 VTY_NEWLINE);
2594 else
2595 {
2596 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2597 if (nbr == NULL)
2598 vty_out (vty, " No backup designated router on this network%s",
2599 VTY_NEWLINE);
2600 else
2601 {
2602 vty_out (vty, " Backup Designated Router (ID) %s,",
2603 inet_ntoa (nbr->router_id));
2604 vty_out (vty, " Interface Address %s%s",
2605 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2606 }
2607 }
2608 vty_out (vty, " Timer intervals configured,");
2609 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2610 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2611 OSPF_IF_PARAM (oi, v_wait),
2612 OSPF_IF_PARAM (oi, retransmit_interval),
2613 VTY_NEWLINE);
2614
2615 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2616 vty_out (vty, " Hello due in %s%s",
2617 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2618 else /* OSPF_IF_PASSIVE is set */
2619 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2620
2621 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
2622 ospf_nbr_count (oi->nbrs, 0), ospf_nbr_count (oi->nbrs, NSM_Full),
2623 VTY_NEWLINE);
2624 }
2625}
2626
2627DEFUN (show_ip_ospf_interface,
2628 show_ip_ospf_interface_cmd,
2629 "show ip ospf interface [INTERFACE]",
2630 SHOW_STR
2631 IP_STR
2632 "OSPF information\n"
2633 "Interface information\n"
2634 "Interface name\n")
2635{
2636 struct interface *ifp;
2637 listnode node;
2638
2639 /* Show All Interfaces. */
2640 if (argc == 0)
2641 for (node = listhead (iflist); node; nextnode (node))
2642 show_ip_ospf_interface_sub (vty, node->data);
2643 /* Interface name is specified. */
2644 else
2645 {
2646 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2647 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2648 else
2649 show_ip_ospf_interface_sub (vty, ifp);
2650 }
2651
2652 return CMD_SUCCESS;
2653}
2654
2655void
2656show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2657{
2658 struct route_node *rn;
2659 struct ospf_neighbor *nbr;
2660 char msgbuf[16];
2661 char timebuf[9];
2662
2663 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2664 if ((nbr = rn->info))
2665 /* Do not show myself. */
2666 if (nbr != oi->nbr_self)
2667 /* Down state is not shown. */
2668 if (nbr->state != NSM_Down)
2669 {
2670 ospf_nbr_state_message (nbr, msgbuf, 16);
2671
2672 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2673 vty_out (vty, "%-15s %3d %-15s %8s ",
2674 "-", nbr->priority,
2675 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2676 else
2677 vty_out (vty, "%-15s %3d %-15s %8s ",
2678 inet_ntoa (nbr->router_id), nbr->priority,
2679 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2680 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2681 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2682 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2683 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2684 VTY_NEWLINE);
2685 }
2686}
2687
2688DEFUN (show_ip_ospf_neighbor,
2689 show_ip_ospf_neighbor_cmd,
2690 "show ip ospf neighbor",
2691 SHOW_STR
2692 IP_STR
2693 "OSPF information\n"
2694 "Neighbor list\n")
2695{
2696 listnode node;
2697
2698 if (!ospf_top)
2699 {
2700 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2701 return CMD_SUCCESS;
2702 }
2703
2704 /* Show All neighbors. */
2705 vty_out (vty, "%sNeighbor ID Pri State Dead "
2706 "Time Address Interface RXmtL "
2707 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2708
2709 for (node = listhead (ospf_top->oiflist); node; nextnode (node))
2710 show_ip_ospf_neighbor_sub (vty, getdata (node));
2711
2712 return CMD_SUCCESS;
2713}
2714
2715DEFUN (show_ip_ospf_neighbor_all,
2716 show_ip_ospf_neighbor_all_cmd,
2717 "show ip ospf neighbor all",
2718 SHOW_STR
2719 IP_STR
2720 "OSPF information\n"
2721 "Neighbor list\n"
2722 "include down status neighbor\n")
2723{
2724 listnode node;
2725
2726 if (!ospf_top)
2727 {
2728 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2729 return CMD_SUCCESS;
2730 }
2731
2732 /* Show All neighbors. */
2733 vty_out (vty, "%sNeighbor ID Pri State Dead "
2734 "Time Address Interface RXmtL "
2735 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2736
2737 for (node = listhead (ospf_top->oiflist); node; nextnode (node))
2738 {
2739 struct ospf_interface *oi = getdata (node);
2740 listnode nbr_node;
2741
2742 show_ip_ospf_neighbor_sub (vty, oi);
2743
2744 /* print Down neighbor status */
2745 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
2746 {
2747 struct ospf_nbr_nbma *nbr_nbma;
2748
2749 nbr_nbma = getdata (nbr_node);
2750
2751 if (nbr_nbma->nbr == NULL
2752 || nbr_nbma->nbr->state == NSM_Down)
2753 {
2754 vty_out (vty, "%-15s %3d %-15s %8s ",
2755 "-", nbr_nbma->priority, "Down", "-");
2756 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2757 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2758 0, 0, 0, VTY_NEWLINE);
2759 }
2760 }
2761 }
2762
2763 return CMD_SUCCESS;
2764}
2765
2766DEFUN (show_ip_ospf_neighbor_int,
2767 show_ip_ospf_neighbor_int_cmd,
2768 "show ip ospf neighbor A.B.C.D",
2769 SHOW_STR
2770 IP_STR
2771 "OSPF information\n"
2772 "Neighbor list\n"
2773 "Interface name\n")
2774{
2775 struct ospf_interface *oi;
2776 struct in_addr addr;
2777 int ret;
2778
2779 if (!ospf_top)
2780 {
2781 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2782 return CMD_SUCCESS;
2783 }
2784
2785 ret = inet_aton (argv[0], &addr);
2786 if (!ret)
2787 {
2788 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2789 VTY_NEWLINE);
2790 return CMD_WARNING;
2791 }
2792
2793 if ((oi = ospf_if_is_configured (&addr)) == NULL)
2794 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2795 else
2796 {
2797 vty_out (vty, "%sNeighbor ID Pri State Dead "
2798 "Time Address Interface RXmtL "
2799 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2800 show_ip_ospf_neighbor_sub (vty, oi);
2801 }
2802
2803 return CMD_SUCCESS;
2804}
2805
2806void
2807show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2808 struct ospf_nbr_nbma *nbr_nbma)
2809{
2810 char timebuf[9];
2811
2812 /* Show neighbor ID. */
2813 vty_out (vty, " Neighbor %s,", "-");
2814
2815 /* Show interface address. */
2816 vty_out (vty, " interface address %s%s",
2817 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2818 /* Show Area ID. */
2819 vty_out (vty, " In the area %s via interface %s%s",
2820 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2821 /* Show neighbor priority and state. */
2822 vty_out (vty, " Neighbor priority is %d, State is %s,",
2823 nbr_nbma->priority, "Down");
2824 /* Show state changes. */
2825 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2826
2827 /* Show PollInterval */
2828 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2829
2830 /* Show poll-interval timer. */
2831 vty_out (vty, " Poll timer due in %s%s",
2832 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2833
2834 /* Show poll-interval timer thread. */
2835 vty_out (vty, " Thread Poll Timer %s%s",
2836 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2837}
2838
2839void
2840show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2841 struct ospf_neighbor *nbr)
2842{
2843 char timebuf[9];
2844
2845 /* Show neighbor ID. */
2846 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2847 vty_out (vty, " Neighbor %s,", "-");
2848 else
2849 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2850
2851 /* Show interface address. */
2852 vty_out (vty, " interface address %s%s",
2853 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2854 /* Show Area ID. */
2855 vty_out (vty, " In the area %s via interface %s%s",
2856 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2857 /* Show neighbor priority and state. */
2858 vty_out (vty, " Neighbor priority is %d, State is %s,",
2859 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2860 /* Show state changes. */
2861 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2862
2863 /* Show Designated Rotuer ID. */
2864 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2865 /* Show Backup Designated Rotuer ID. */
2866 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2867 /* Show options. */
2868 vty_out (vty, " Options %d %s%s", nbr->options,
2869 ospf_options_dump (nbr->options), VTY_NEWLINE);
2870 /* Show Router Dead interval timer. */
2871 vty_out (vty, " Dead timer due in %s%s",
2872 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2873 /* Show Database Summary list. */
2874 vty_out (vty, " Database Summary List %d%s",
2875 ospf_db_summary_count (nbr), VTY_NEWLINE);
2876 /* Show Link State Request list. */
2877 vty_out (vty, " Link State Request List %ld%s",
2878 ospf_ls_request_count (nbr), VTY_NEWLINE);
2879 /* Show Link State Retransmission list. */
2880 vty_out (vty, " Link State Retransmission List %ld%s",
2881 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2882 /* Show inactivity timer thread. */
2883 vty_out (vty, " Thread Inactivity Timer %s%s",
2884 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2885 /* Show Database Description retransmission thread. */
2886 vty_out (vty, " Thread Database Description Retransmision %s%s",
2887 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2888 /* Show Link State Request Retransmission thread. */
2889 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2890 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2891 /* Show Link State Update Retransmission thread. */
2892 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2893 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2894}
2895
2896DEFUN (show_ip_ospf_neighbor_id,
2897 show_ip_ospf_neighbor_id_cmd,
2898 "show ip ospf neighbor A.B.C.D",
2899 SHOW_STR
2900 IP_STR
2901 "OSPF information\n"
2902 "Neighbor list\n"
2903 "Neighbor ID\n")
2904{
2905 listnode node;
2906 struct ospf_neighbor *nbr;
2907 struct in_addr router_id;
2908 int ret;
2909
2910 ret = inet_aton (argv[0], &router_id);
2911 if (!ret)
2912 {
2913 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
2914 return CMD_WARNING;
2915 }
2916
2917 for (node = listhead (ospf_top->oiflist); node; nextnode (node))
2918 {
2919 struct ospf_interface *oi = getdata (node);
2920
2921 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
2922 {
2923 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2924 return CMD_SUCCESS;
2925 }
2926 }
2927
2928 /* Nothing to show. */
2929 return CMD_SUCCESS;
2930}
2931
2932DEFUN (show_ip_ospf_neighbor_detail,
2933 show_ip_ospf_neighbor_detail_cmd,
2934 "show ip ospf neighbor detail",
2935 SHOW_STR
2936 IP_STR
2937 "OSPF information\n"
2938 "Neighbor list\n"
2939 "detail of all neighbors\n")
2940{
2941 listnode node;
2942
2943 if (!ospf_top)
2944 return CMD_SUCCESS;
2945
2946 for (node = listhead (ospf_top->oiflist); node; nextnode (node))
2947 {
2948 struct ospf_interface *oi = getdata (node);
2949 struct route_node *rn;
2950 struct ospf_neighbor *nbr;
2951
2952 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2953 if ((nbr = rn->info))
2954 if (nbr != oi->nbr_self)
2955 if (nbr->state != NSM_Down)
2956 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2957 }
2958
2959 return CMD_SUCCESS;
2960}
2961
2962DEFUN (show_ip_ospf_neighbor_detail_all,
2963 show_ip_ospf_neighbor_detail_all_cmd,
2964 "show ip ospf neighbor detail all",
2965 SHOW_STR
2966 IP_STR
2967 "OSPF information\n"
2968 "Neighbor list\n"
2969 "detail of all neighbors\n"
2970 "include down status neighbor\n")
2971{
2972 listnode node;
2973
2974 if (!ospf_top)
2975 return CMD_SUCCESS;
2976
2977 for (node = listhead (ospf_top->oiflist); node; nextnode (node))
2978 {
2979 struct ospf_interface *oi = getdata (node);
2980 struct route_node *rn;
2981 struct ospf_neighbor *nbr;
2982
2983 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2984 if ((nbr = rn->info))
2985 if (nbr != oi->nbr_self)
2986 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
2987 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
2988
2989 if (oi->type == OSPF_IFTYPE_NBMA)
2990 {
2991 listnode nd;
2992
2993 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
2994 {
2995 struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
2996 if (nbr_nbma->nbr == NULL
2997 || nbr_nbma->nbr->state == NSM_Down)
2998 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
2999 }
3000 }
3001 }
3002
3003 return CMD_SUCCESS;
3004}
3005
3006DEFUN (show_ip_ospf_neighbor_int_detail,
3007 show_ip_ospf_neighbor_int_detail_cmd,
3008 "show ip ospf neighbor A.B.C.D detail",
3009 SHOW_STR
3010 IP_STR
3011 "OSPF information\n"
3012 "Neighbor list\n"
3013 "Interface address\n"
3014 "detail of all neighbors")
3015{
3016 struct ospf_interface *oi;
3017 struct in_addr addr;
3018 int ret;
3019
3020 ret = inet_aton (argv[0], &addr);
3021 if (!ret)
3022 {
3023 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3024 VTY_NEWLINE);
3025 return CMD_WARNING;
3026 }
3027
3028 if ((oi = ospf_if_is_configured (&addr)) == NULL)
3029 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3030 else
3031 {
3032 struct route_node *rn;
3033 struct ospf_neighbor *nbr;
3034
3035 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3036 if ((nbr = rn->info))
3037 if (nbr != oi->nbr_self)
3038 if (nbr->state != NSM_Down)
3039 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3040 }
3041
3042 return CMD_SUCCESS;
3043}
3044
3045
3046/* Show functions */
3047int
3048show_lsa_summary (struct ospf_lsa *lsa, void *v, int self)
3049{
3050 struct vty *vty = (struct vty *) v;
3051 struct router_lsa *rl;
3052 struct summary_lsa *sl;
3053 struct as_external_lsa *asel;
3054 struct prefix_ipv4 p;
3055
3056 if (lsa != NULL)
3057 /* If self option is set, check LSA self flag. */
3058 if (self == 0 || IS_LSA_SELF (lsa))
3059 {
3060 /* LSA common part show. */
3061 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3062 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3063 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3064 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3065 /* LSA specific part show. */
3066 switch (lsa->data->type)
3067 {
3068 case OSPF_ROUTER_LSA:
3069 rl = (struct router_lsa *) lsa->data;
3070 vty_out (vty, " %-d", ntohs (rl->links));
3071 break;
3072 case OSPF_SUMMARY_LSA:
3073 sl = (struct summary_lsa *) lsa->data;
3074
3075 p.family = AF_INET;
3076 p.prefix = sl->header.id;
3077 p.prefixlen = ip_masklen (sl->mask);
3078 apply_mask_ipv4 (&p);
3079
3080 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3081 break;
3082 case OSPF_AS_EXTERNAL_LSA:
3083 asel = (struct as_external_lsa *) lsa->data;
3084
3085 p.family = AF_INET;
3086 p.prefix = asel->header.id;
3087 p.prefixlen = ip_masklen (asel->mask);
3088 apply_mask_ipv4 (&p);
3089
3090 vty_out (vty, " %s %s/%d [0x%lx]",
3091 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3092 inet_ntoa (p.prefix), p.prefixlen,
3093 (u_long)ntohl (asel->e[0].route_tag));
3094 break;
3095 case OSPF_NETWORK_LSA:
3096 case OSPF_ASBR_SUMMARY_LSA:
3097#ifdef HAVE_OPAQUE_LSA
3098 case OSPF_OPAQUE_LINK_LSA:
3099 case OSPF_OPAQUE_AREA_LSA:
3100 case OSPF_OPAQUE_AS_LSA:
3101#endif /* HAVE_OPAQUE_LSA */
3102 default:
3103 break;
3104 }
3105 vty_out (vty, VTY_NEWLINE);
3106 }
3107
3108 return 0;
3109}
3110
3111char *show_database_desc[] =
3112{
3113 "unknown",
3114 "Router Link States",
3115 "Net Link States",
3116 "Summary Link States",
3117 "ASBR-Summary Link States",
3118 "AS External Link States",
3119#if defined (HAVE_NSSA) || defined (HAVE_OPAQUE_LSA)
3120 "Group Membership LSA",
3121 "NSSA-external Link States",
3122#endif /* HAVE_NSSA */
3123#ifdef HAVE_OPAQUE_LSA
3124 "Type-8 LSA",
3125 "Link-Local Opaque-LSA",
3126 "Area-Local Opaque-LSA",
3127 "AS-external Opaque-LSA",
3128#endif /* HAVE_OPAQUE_LSA */
3129};
3130
3131#define SHOW_OSPF_COMMON_HEADER \
3132 "Link ID ADV Router Age Seq# CkSum"
3133
3134char *show_database_header[] =
3135{
3136 "",
3137 "Link ID ADV Router Age Seq# CkSum Link count",
3138 "Link ID ADV Router Age Seq# CkSum",
3139 "Link ID ADV Router Age Seq# CkSum Route",
3140 "Link ID ADV Router Age Seq# CkSum",
3141 "Link ID ADV Router Age Seq# CkSum Route",
3142#ifdef HAVE_NSSA
3143 " --- header for Group Member ----",
3144 "Link ID ADV Router Age Seq# CkSum Route",
3145#endif /* HAVE_NSSA */
3146#ifdef HAVE_OPAQUE_LSA
3147#ifndef HAVE_NSSA
3148 " --- type-6 ---",
3149 " --- type-7 ---",
3150#endif /* HAVE_NSSA */
3151 " --- type-8 ---",
3152 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3153 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3154 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3155#endif /* HAVE_OPAQUE_LSA */
3156};
3157
3158void
3159show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3160{
3161 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
3162
3163 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
3164 vty_out (vty, " Options: %d%s", lsa->data->options, VTY_NEWLINE);
3165
3166 if (lsa->data->type == OSPF_ROUTER_LSA)
3167 {
3168 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3169
3170 if (rlsa->flags)
3171 vty_out (vty, " :%s%s%s%s",
3172 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3173 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3174 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3175 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3176
3177 vty_out (vty, "%s", VTY_NEWLINE);
3178 }
3179 vty_out (vty, " LS Type: %s%s",
3180 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3181 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3182 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3183 vty_out (vty, " Advertising Router: %s%s",
3184 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3185 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3186 VTY_NEWLINE);
3187 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3188 VTY_NEWLINE);
3189 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3190}
3191
3192char *link_type_desc[] =
3193{
3194 "(null)",
3195 "another Router (point-to-point)",
3196 "a Transit Network",
3197 "Stub Network",
3198 "a Virtual Link",
3199};
3200
3201char *link_id_desc[] =
3202{
3203 "(null)",
3204 "Neighboring Router ID",
3205 "Designated Router address",
3206 "Network/subnet number",
3207 "Neighboring Router ID",
3208};
3209
3210char *link_data_desc[] =
3211{
3212 "(null)",
3213 "Router Interface address",
3214 "Router Interface address",
3215 "Network Mask",
3216 "Router Interface address",
3217};
3218
3219/* Show router-LSA each Link information. */
3220void
3221show_ip_ospf_database_router_links (struct vty *vty,
3222 struct router_lsa *rl)
3223{
3224 int len, i, type;
3225
3226 len = ntohs (rl->header.length) - 4;
3227 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3228 {
3229 type = rl->link[i].type;
3230
3231 vty_out (vty, " Link connected to: %s%s",
3232 link_type_desc[type], VTY_NEWLINE);
3233 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3234 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3235 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3236 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3237 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3238 vty_out (vty, " TOS 0 Metric: %d%s",
3239 ntohs (rl->link[i].metric), VTY_NEWLINE);
3240 vty_out (vty, "%s", VTY_NEWLINE);
3241 }
3242}
3243
3244/* Show router-LSA detail information. */
3245int
3246show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3247{
3248 if (lsa != NULL)
3249 {
3250 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3251
3252 show_ip_ospf_database_header (vty, lsa);
3253
3254 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3255 VTY_NEWLINE, VTY_NEWLINE);
3256
3257 show_ip_ospf_database_router_links (vty, rl);
3258 }
3259
3260 return 0;
3261}
3262
3263/* Show network-LSA detail information. */
3264int
3265show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3266{
3267 int length, i;
3268
3269 if (lsa != NULL)
3270 {
3271 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3272
3273 show_ip_ospf_database_header (vty, lsa);
3274
3275 vty_out (vty, " Network Mask: /%d%s",
3276 ip_masklen (nl->mask), VTY_NEWLINE);
3277
3278 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3279
3280 for (i = 0; length > 0; i++, length -= 4)
3281 vty_out (vty, " Attached Router: %s%s",
3282 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3283
3284 vty_out (vty, "%s", VTY_NEWLINE);
3285 }
3286
3287 return 0;
3288}
3289
3290/* Show summary-LSA detail information. */
3291int
3292show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3293{
3294 if (lsa != NULL)
3295 {
3296 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3297
3298 show_ip_ospf_database_header (vty, lsa);
3299
3300 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3301 VTY_NEWLINE);
3302 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3303 VTY_NEWLINE);
3304 }
3305
3306 return 0;
3307}
3308
3309/* Show summary-ASBR-LSA detail information. */
3310int
3311show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3312{
3313 if (lsa != NULL)
3314 {
3315 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3316
3317 show_ip_ospf_database_header (vty, lsa);
3318
3319 vty_out (vty, " Network Mask: /%d%s",
3320 ip_masklen (sl->mask), VTY_NEWLINE);
3321 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3322 VTY_NEWLINE);
3323 }
3324
3325 return 0;
3326}
3327
3328/* Show AS-external-LSA detail information. */
3329int
3330show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3331{
3332 if (lsa != NULL)
3333 {
3334 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3335
3336 show_ip_ospf_database_header (vty, lsa);
3337
3338 vty_out (vty, " Network Mask: /%d%s",
3339 ip_masklen (al->mask), VTY_NEWLINE);
3340 vty_out (vty, " Metric Type: %s%s",
3341 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3342 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3343 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3344 vty_out (vty, " Metric: %d%s",
3345 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3346 vty_out (vty, " Forward Address: %s%s",
3347 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3348
3349 vty_out (vty, " External Route Tag: %lu%s%s",
3350 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3351 }
3352
3353 return 0;
3354}
3355
3356#ifdef HAVE_NSSA
3357int
3358show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3359{
3360 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3361
3362 /* show_ip_ospf_database_header (vty, lsa); */
3363
3364 zlog_info( " Network Mask: /%d%s",
3365 ip_masklen (al->mask), "\n");
3366 zlog_info( " Metric Type: %s%s",
3367 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3368 "2 (Larger than any link state path)" : "1", "\n");
3369 zlog_info( " TOS: 0%s", "\n");
3370 zlog_info( " Metric: %d%s",
3371 GET_METRIC (al->e[0].metric), "\n");
3372 zlog_info( " Forward Address: %s%s",
3373 inet_ntoa (al->e[0].fwd_addr), "\n");
3374
3375 zlog_info( " External Route Tag: %u%s%s",
3376 ntohl (al->e[0].route_tag), "\n", "\n");
3377
3378 return 0;
3379}
3380
3381/* Show AS-NSSA-LSA detail information. */
3382int
3383show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3384{
3385 if (lsa != NULL)
3386 {
3387 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3388
3389 show_ip_ospf_database_header (vty, lsa);
3390
3391 vty_out (vty, " Network Mask: /%d%s",
3392 ip_masklen (al->mask), VTY_NEWLINE);
3393 vty_out (vty, " Metric Type: %s%s",
3394 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3395 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3396 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3397 vty_out (vty, " Metric: %d%s",
3398 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3399 vty_out (vty, " NSSA: Forward Address: %s%s",
3400 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3401
3402 vty_out (vty, " External Route Tag: %u%s%s",
3403 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3404 }
3405
3406 return 0;
3407}
3408
3409#endif /* HAVE_NSSA */
3410
3411int
3412show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3413{
3414 return 0;
3415}
3416
3417#ifdef HAVE_OPAQUE_LSA
3418int
3419show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3420{
3421 if (lsa != NULL)
3422 {
3423 show_ip_ospf_database_header (vty, lsa);
3424 show_opaque_info_detail (vty, lsa);
3425
3426 vty_out (vty, "%s", VTY_NEWLINE);
3427 }
3428 return 0;
3429}
3430#endif /* HAVE_OPAQUE_LSA */
3431
3432int (*show_function[])(struct vty *, struct ospf_lsa *) =
3433{
3434 NULL,
3435 show_router_lsa_detail,
3436 show_network_lsa_detail,
3437 show_summary_lsa_detail,
3438 show_summary_asbr_lsa_detail,
3439 show_as_external_lsa_detail,
3440#ifdef HAVE_NSSA
3441 show_func_dummy,
3442 show_as_nssa_lsa_detail, /* almost same as external */
3443#endif /* HAVE_NSSA */
3444#ifdef HAVE_OPAQUE_LSA
3445#ifndef HAVE_NSSA
3446 show_func_dummy,
3447 show_func_dummy,
3448#endif /* HAVE_NSSA */
3449 NULL, /* type-8 */
3450 show_opaque_lsa_detail,
3451 show_opaque_lsa_detail,
3452 show_opaque_lsa_detail,
3453#endif /* HAVE_OPAQUE_LSA */
3454};
3455
3456void
3457show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3458 struct in_addr *adv_router)
3459{
3460 memset (lp, 0, sizeof (struct prefix_ls));
3461 lp->family = 0;
3462 if (id == NULL)
3463 lp->prefixlen = 0;
3464 else if (adv_router == NULL)
3465 {
3466 lp->prefixlen = 32;
3467 lp->id = *id;
3468 }
3469 else
3470 {
3471 lp->prefixlen = 64;
3472 lp->id = *id;
3473 lp->adv_router = *adv_router;
3474 }
3475}
3476
3477void
3478show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3479 struct in_addr *id, struct in_addr *adv_router)
3480{
3481 struct prefix_ls lp;
3482 struct route_node *rn, *start;
3483 struct ospf_lsa *lsa;
3484
3485 show_lsa_prefix_set (vty, &lp, id, adv_router);
3486 start = route_node_get (rt, (struct prefix *) &lp);
3487 if (start)
3488 {
3489 route_lock_node (start);
3490 for (rn = start; rn; rn = route_next_until (rn, start))
3491 if ((lsa = rn->info))
3492 {
3493#ifdef HAVE_NSSA
3494 /* Stay away from any Local Translated Type-7 LSAs */
3495 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3496 continue;
3497#endif /* HAVE_NSSA */
3498
3499 if (show_function[lsa->data->type] != NULL)
3500 show_function[lsa->data->type] (vty, lsa);
3501 }
3502 route_unlock_node (start);
3503 }
3504}
3505
3506/* Show detail LSA information
3507 -- if id is NULL then show all LSAs. */
3508void
3509show_lsa_detail (struct vty *vty, int type,
3510 struct in_addr *id, struct in_addr *adv_router)
3511{
3512 listnode node;
3513
3514 switch (type)
3515 {
3516 case OSPF_AS_EXTERNAL_LSA:
3517#ifdef HAVE_OPAQUE_LSA
3518 case OSPF_OPAQUE_AS_LSA:
3519#endif /* HAVE_OPAQUE_LSA */
3520 vty_out (vty, " %s %s%s",
3521 show_database_desc[type],
3522 VTY_NEWLINE, VTY_NEWLINE);
3523 show_lsa_detail_proc (vty, AS_LSDB (ospf_top, type), id, adv_router);
3524 break;
3525 default:
3526 for (node = listhead (ospf_top->areas); node; nextnode (node))
3527 {
3528 struct ospf_area *area = node->data;
3529 vty_out (vty, "%s %s (Area %s)%s%s",
3530 VTY_NEWLINE, show_database_desc[type],
3531 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3532 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3533 }
3534 break;
3535 }
3536}
3537
3538void
3539show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3540 struct in_addr *adv_router)
3541{
3542 struct route_node *rn;
3543 struct ospf_lsa *lsa;
3544
3545 for (rn = route_top (rt); rn; rn = route_next (rn))
3546 if ((lsa = rn->info))
3547 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3548 {
3549#ifdef HAVE_NSSA
3550 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3551 continue;
3552#endif /* HAVE_NSSA */
3553 if (show_function[lsa->data->type] != NULL)
3554 show_function[lsa->data->type] (vty, lsa);
3555 }
3556}
3557
3558/* Show detail LSA information. */
3559void
3560show_lsa_detail_adv_router (struct vty *vty, int type,
3561 struct in_addr *adv_router)
3562{
3563 listnode node;
3564
3565 switch (type)
3566 {
3567 case OSPF_AS_EXTERNAL_LSA:
3568#ifdef HAVE_OPAQUE_LSA
3569 case OSPF_OPAQUE_AS_LSA:
3570#endif /* HAVE_OPAQUE_LSA */
3571 vty_out (vty, " %s %s%s",
3572 show_database_desc[type],
3573 VTY_NEWLINE, VTY_NEWLINE);
3574 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf_top, type),
3575 adv_router);
3576 break;
3577 default:
3578 for (node = listhead (ospf_top->areas); node; nextnode (node))
3579 {
3580 struct ospf_area *area = node->data;
3581 vty_out (vty, "%s %s (Area %s)%s%s",
3582 VTY_NEWLINE, show_database_desc[type],
3583 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3584 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3585 adv_router);
3586 }
3587 break;
3588 }
3589}
3590
3591void
3592show_ip_ospf_database_summary (struct vty *vty, int self)
3593{
3594 listnode node;
3595 int type;
3596
3597 for (node = listhead (ospf_top->areas); node; nextnode (node))
3598 {
3599 struct ospf_area *area = node->data;
3600 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3601 {
3602 switch (type)
3603 {
3604 case OSPF_AS_EXTERNAL_LSA:
3605#ifdef HAVE_OPAQUE_LSA
3606 case OSPF_OPAQUE_AS_LSA:
3607#endif /* HAVE_OPAQUE_LSA */
3608 continue;
3609 default:
3610 break;
3611 }
3612 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3613 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3614 {
3615 vty_out (vty, " %s (Area %s)%s%s",
3616 show_database_desc[type],
3617 ospf_area_desc_string (area),
3618 VTY_NEWLINE, VTY_NEWLINE);
3619 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3620
3621 foreach_lsa (AREA_LSDB (area, type), vty, self, show_lsa_summary);
3622
3623 vty_out (vty, "%s", VTY_NEWLINE);
3624 }
3625 }
3626 }
3627
3628 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3629 {
3630 switch (type)
3631 {
3632 case OSPF_AS_EXTERNAL_LSA:
3633#ifdef HAVE_OPAQUE_LSA
3634 case OSPF_OPAQUE_AS_LSA:
3635#endif /* HAVE_OPAQUE_LSA */
3636 break;;
3637 default:
3638 continue;
3639 }
3640 if (ospf_lsdb_count_self (ospf_top->lsdb, type) ||
3641 (!self && ospf_lsdb_count (ospf_top->lsdb, type)))
3642 {
3643 vty_out (vty, " %s%s%s",
3644 show_database_desc[type],
3645 VTY_NEWLINE, VTY_NEWLINE);
3646 vty_out (vty, "%s%s", show_database_header[type],
3647 VTY_NEWLINE);
3648 foreach_lsa (AS_LSDB (ospf_top, type), vty, self, show_lsa_summary);
3649 vty_out (vty, "%s", VTY_NEWLINE);
3650 }
3651 }
3652
3653 vty_out (vty, "%s", VTY_NEWLINE);
3654}
3655
3656void
3657show_ip_ospf_database_maxage (struct vty *vty)
3658{
3659 listnode node;
3660 struct ospf_lsa *lsa;
3661
3662 vty_out (vty, "%s MaxAge Link States:%s%s",
3663 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3664
3665 for (node = listhead (ospf_top->maxage_lsa); node; nextnode (node))
3666 if ((lsa = node->data) != NULL)
3667 {
3668 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3669 vty_out (vty, "Link State ID: %s%s",
3670 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3671 vty_out (vty, "Advertising Router: %s%s",
3672 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3673 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3674 vty_out (vty, "%s", VTY_NEWLINE);
3675 }
3676}
3677
3678#ifdef HAVE_NSSA
3679#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3680#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
3681#else /* HAVE_NSSA */
3682#define OSPF_LSA_TYPE_NSSA_DESC ""
3683#define OSPF_LSA_TYPE_NSSA_CMD_STR ""
3684#endif /* HAVE_NSSA */
3685
3686#ifdef HAVE_OPAQUE_LSA
3687#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3688#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3689#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3690#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3691#else /* HAVE_OPAQUE_LSA */
3692#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3693#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3694#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3695#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3696#endif /* HAVE_OPAQUE_LSA */
3697
3698#define OSPF_LSA_TYPES_CMD_STR \
3699 "asbr-summary|external|network|router|summary" \
3700 OSPF_LSA_TYPE_NSSA_CMD_STR \
3701 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3702
3703#define OSPF_LSA_TYPES_DESC \
3704 "ASBR summary link states\n" \
3705 "External link states\n" \
3706 "Network link states\n" \
3707 "Router link states\n" \
3708 "Network summary link states\n" \
3709 OSPF_LSA_TYPE_NSSA_DESC \
3710 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3711 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3712 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3713
3714DEFUN (show_ip_ospf_database,
3715 show_ip_ospf_database_cmd,
3716 "show ip ospf database",
3717 SHOW_STR
3718 IP_STR
3719 "OSPF information\n"
3720 "Database summary\n")
3721{
3722 int type, ret;
3723 struct in_addr id, adv_router;
3724
3725 if (ospf_top == NULL)
3726 return CMD_SUCCESS;
3727
3728 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
3729 inet_ntoa (ospf_top->router_id), VTY_NEWLINE, VTY_NEWLINE);
3730
3731 /* Show all LSA. */
3732 if (argc == 0)
3733 {
3734 show_ip_ospf_database_summary (vty, 0);
3735 return CMD_SUCCESS;
3736 }
3737
3738 /* Set database type to show. */
3739 if (strncmp (argv[0], "r", 1) == 0)
3740 type = OSPF_ROUTER_LSA;
3741 else if (strncmp (argv[0], "ne", 2) == 0)
3742 type = OSPF_NETWORK_LSA;
3743#ifdef HAVE_NSSA
3744 else if (strncmp (argv[0], "ns", 2) == 0)
3745 type = OSPF_AS_NSSA_LSA;
3746#endif /* HAVE_NSSA */
3747 else if (strncmp (argv[0], "su", 2) == 0)
3748 type = OSPF_SUMMARY_LSA;
3749 else if (strncmp (argv[0], "a", 1) == 0)
3750 type = OSPF_ASBR_SUMMARY_LSA;
3751 else if (strncmp (argv[0], "e", 1) == 0)
3752 type = OSPF_AS_EXTERNAL_LSA;
3753 else if (strncmp (argv[0], "se", 2) == 0)
3754 {
3755 show_ip_ospf_database_summary (vty, 1);
3756 return CMD_SUCCESS;
3757 }
3758 else if (strncmp (argv[0], "m", 1) == 0)
3759 {
3760 show_ip_ospf_database_maxage (vty);
3761 return CMD_SUCCESS;
3762 }
3763#ifdef HAVE_OPAQUE_LSA
3764 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3765 type = OSPF_OPAQUE_LINK_LSA;
3766 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3767 type = OSPF_OPAQUE_AREA_LSA;
3768 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3769 type = OSPF_OPAQUE_AS_LSA;
3770#endif /* HAVE_OPAQUE_LSA */
3771 else
3772 return CMD_WARNING;
3773
3774 /* `show ip ospf database LSA'. */
3775 if (argc == 1)
3776 show_lsa_detail (vty, type, NULL, NULL);
3777 else if (argc >= 2)
3778 {
3779 ret = inet_aton (argv[1], &id);
3780 if (!ret)
3781 return CMD_WARNING;
3782
3783 /* `show ip ospf database LSA ID'. */
3784 if (argc == 2)
3785 show_lsa_detail (vty, type, &id, NULL);
3786 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3787 else if (argc == 3)
3788 {
3789 if (strncmp (argv[2], "s", 1) == 0)
3790 adv_router = ospf_top->router_id;
3791 else
3792 {
3793 ret = inet_aton (argv[2], &adv_router);
3794 if (!ret)
3795 return CMD_WARNING;
3796 }
3797 show_lsa_detail (vty, type, &id, &adv_router);
3798 }
3799 }
3800
3801 return CMD_SUCCESS;
3802}
3803
3804ALIAS (show_ip_ospf_database,
3805 show_ip_ospf_database_type_cmd,
3806 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3807 SHOW_STR
3808 IP_STR
3809 "OSPF information\n"
3810 "Database summary\n"
3811 OSPF_LSA_TYPES_DESC
3812 "LSAs in MaxAge list\n"
3813 "Self-originated link states\n")
3814
3815ALIAS (show_ip_ospf_database,
3816 show_ip_ospf_database_type_id_cmd,
3817 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3818 SHOW_STR
3819 IP_STR
3820 "OSPF information\n"
3821 "Database summary\n"
3822 OSPF_LSA_TYPES_DESC
3823 "Link State ID (as an IP address)\n")
3824
3825ALIAS (show_ip_ospf_database,
3826 show_ip_ospf_database_type_id_adv_router_cmd,
3827 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3828 SHOW_STR
3829 IP_STR
3830 "OSPF information\n"
3831 "Database summary\n"
3832 OSPF_LSA_TYPES_DESC
3833 "Link State ID (as an IP address)\n"
3834 "Advertising Router link states\n"
3835 "Advertising Router (as an IP address)\n")
3836
3837ALIAS (show_ip_ospf_database,
3838 show_ip_ospf_database_type_id_self_cmd,
3839 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3840 SHOW_STR
3841 IP_STR
3842 "OSPF information\n"
3843 "Database summary\n"
3844 OSPF_LSA_TYPES_DESC
3845 "Link State ID (as an IP address)\n"
3846 "Self-originated link states\n"
3847 "\n")
3848
3849DEFUN (show_ip_ospf_database_type_adv_router,
3850 show_ip_ospf_database_type_adv_router_cmd,
3851 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3852 SHOW_STR
3853 IP_STR
3854 "OSPF information\n"
3855 "Database summary\n"
3856 OSPF_LSA_TYPES_DESC
3857 "Advertising Router link states\n"
3858 "Advertising Router (as an IP address)\n")
3859{
3860 int type, ret;
3861 struct in_addr adv_router;
3862
3863 if (ospf_top == NULL)
3864 return CMD_SUCCESS;
3865
3866 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
3867 inet_ntoa (ospf_top->router_id), VTY_NEWLINE, VTY_NEWLINE);
3868
3869 if (argc != 2)
3870 return CMD_WARNING;
3871
3872 /* Set database type to show. */
3873 if (strncmp (argv[0], "r", 1) == 0)
3874 type = OSPF_ROUTER_LSA;
3875 else if (strncmp (argv[0], "ne", 2) == 0)
3876 type = OSPF_NETWORK_LSA;
3877#ifdef HAVE_NSSA
3878 else if (strncmp (argv[0], "ns", 2) == 0)
3879 type = OSPF_AS_NSSA_LSA;
3880#endif /* HAVE_NSSA */
3881 else if (strncmp (argv[0], "s", 1) == 0)
3882 type = OSPF_SUMMARY_LSA;
3883 else if (strncmp (argv[0], "a", 1) == 0)
3884 type = OSPF_ASBR_SUMMARY_LSA;
3885 else if (strncmp (argv[0], "e", 1) == 0)
3886 type = OSPF_AS_EXTERNAL_LSA;
3887#ifdef HAVE_OPAQUE_LSA
3888 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3889 type = OSPF_OPAQUE_LINK_LSA;
3890 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3891 type = OSPF_OPAQUE_AREA_LSA;
3892 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3893 type = OSPF_OPAQUE_AS_LSA;
3894#endif /* HAVE_OPAQUE_LSA */
3895 else
3896 return CMD_WARNING;
3897
3898 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
3899 if (strncmp (argv[1], "s", 1) == 0)
3900 adv_router = ospf_top->router_id;
3901 else
3902 {
3903 ret = inet_aton (argv[1], &adv_router);
3904 if (!ret)
3905 return CMD_WARNING;
3906 }
3907
3908 show_lsa_detail_adv_router (vty, type, &adv_router);
3909
3910 return CMD_SUCCESS;
3911}
3912
3913ALIAS (show_ip_ospf_database_type_adv_router,
3914 show_ip_ospf_database_type_self_cmd,
3915 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
3916 SHOW_STR
3917 IP_STR
3918 "OSPF information\n"
3919 "Database summary\n"
3920 OSPF_LSA_TYPES_DESC
3921 "Self-originated link states\n")
3922
3923
3924DEFUN (ip_ospf_authentication_args,
3925 ip_ospf_authentication_args_addr_cmd,
3926 "ip ospf authentication (null|message-digest) A.B.C.D",
3927 "IP Information\n"
3928 "OSPF interface commands\n"
3929 "Enable authentication on this interface\n"
3930 "Use null authentication\n"
3931 "Use message-digest authentication\n"
3932 "Address of interface")
3933{
3934 struct interface *ifp;
3935 struct in_addr addr;
3936 int ret;
3937 struct ospf_if_params *params;
3938
3939 ifp = vty->index;
3940 params = IF_DEF_PARAMS (ifp);
3941
3942 if (argc == 2)
3943 {
3944 ret = inet_aton(argv[1], &addr);
3945 if (!ret)
3946 {
3947 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3948 VTY_NEWLINE);
3949 return CMD_WARNING;
3950 }
3951
3952 params = ospf_get_if_params (ifp, addr);
3953 ospf_if_update_params (ifp, addr);
3954 }
3955
3956 /* Handle null authentication */
3957 if ( argv[0][0] == 'n' )
3958 {
3959 SET_IF_PARAM (params, auth_type);
3960 params->auth_type = OSPF_AUTH_NULL;
3961 return CMD_SUCCESS;
3962 }
3963
3964 /* Handle message-digest authentication */
3965 if ( argv[0][0] == 'm' )
3966 {
3967 SET_IF_PARAM (params, auth_type);
3968 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
3969 return CMD_SUCCESS;
3970 }
3971
3972 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
3973 return CMD_WARNING;
3974}
3975
3976ALIAS (ip_ospf_authentication_args,
3977 ip_ospf_authentication_args_cmd,
3978 "ip ospf authentication (null|message-digest)",
3979 "IP Information\n"
3980 "OSPF interface commands\n"
3981 "Enable authentication on this interface\n"
3982 "Use null authentication\n"
3983 "Use message-digest authentication\n")
3984
3985DEFUN (ip_ospf_authentication,
3986 ip_ospf_authentication_addr_cmd,
3987 "ip ospf authentication A.B.C.D",
3988 "IP Information\n"
3989 "OSPF interface commands\n"
3990 "Enable authentication on this interface\n"
3991 "Address of interface")
3992{
3993 struct interface *ifp;
3994 struct in_addr addr;
3995 int ret;
3996 struct ospf_if_params *params;
3997
3998 ifp = vty->index;
3999 params = IF_DEF_PARAMS (ifp);
4000
4001 if (argc == 1)
4002 {
4003 ret = inet_aton(argv[1], &addr);
4004 if (!ret)
4005 {
4006 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4007 VTY_NEWLINE);
4008 return CMD_WARNING;
4009 }
4010
4011 params = ospf_get_if_params (ifp, addr);
4012 ospf_if_update_params (ifp, addr);
4013 }
4014
4015 SET_IF_PARAM (params, auth_type);
4016 params->auth_type = OSPF_AUTH_SIMPLE;
4017
4018 return CMD_SUCCESS;
4019}
4020
4021ALIAS (ip_ospf_authentication,
4022 ip_ospf_authentication_cmd,
4023 "ip ospf authentication",
4024 "IP Information\n"
4025 "OSPF interface commands\n"
4026 "Enable authentication on this interface\n")
4027
4028DEFUN (no_ip_ospf_authentication,
4029 no_ip_ospf_authentication_addr_cmd,
4030 "no ip ospf authentication A.B.C.D",
4031 NO_STR
4032 "IP Information\n"
4033 "OSPF interface commands\n"
4034 "Enable authentication on this interface\n"
4035 "Address of interface")
4036{
4037 struct interface *ifp;
4038 struct in_addr addr;
4039 int ret;
4040 struct ospf_if_params *params;
4041
4042 ifp = vty->index;
4043 params = IF_DEF_PARAMS (ifp);
4044
4045 if (argc == 1)
4046 {
4047 ret = inet_aton(argv[1], &addr);
4048 if (!ret)
4049 {
4050 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4051 VTY_NEWLINE);
4052 return CMD_WARNING;
4053 }
4054
4055 params = ospf_lookup_if_params (ifp, addr);
4056 if (params == NULL)
4057 return CMD_SUCCESS;
4058 }
4059
4060 params->auth_type = OSPF_AUTH_NOTSET;
4061 UNSET_IF_PARAM (params, auth_type);
4062
4063 if (params != IF_DEF_PARAMS (ifp))
4064 {
4065 ospf_free_if_params (ifp, addr);
4066 ospf_if_update_params (ifp, addr);
4067 }
4068
4069 return CMD_SUCCESS;
4070}
4071
4072ALIAS (no_ip_ospf_authentication,
4073 no_ip_ospf_authentication_cmd,
4074 "no ip ospf authentication",
4075 NO_STR
4076 "IP Information\n"
4077 "OSPF interface commands\n"
4078 "Enable authentication on this interface\n")
4079
4080DEFUN (ip_ospf_authentication_key,
4081 ip_ospf_authentication_key_addr_cmd,
4082 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4083 "IP Information\n"
4084 "OSPF interface commands\n"
4085 "Authentication password (key)\n"
4086 "The OSPF password (key)\n"
4087 "Address of interface")
4088{
4089 struct interface *ifp;
4090 struct in_addr addr;
4091 int ret;
4092 struct ospf_if_params *params;
4093
4094 ifp = vty->index;
4095 params = IF_DEF_PARAMS (ifp);
4096
4097 if (argc == 2)
4098 {
4099 ret = inet_aton(argv[1], &addr);
4100 if (!ret)
4101 {
4102 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4103 VTY_NEWLINE);
4104 return CMD_WARNING;
4105 }
4106
4107 params = ospf_get_if_params (ifp, addr);
4108 ospf_if_update_params (ifp, addr);
4109 }
4110
4111
4112 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
4113 strncpy (params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
4114 SET_IF_PARAM (params, auth_simple);
4115
4116 return CMD_SUCCESS;
4117}
4118
4119ALIAS (ip_ospf_authentication_key,
4120 ip_ospf_authentication_key_cmd,
4121 "ip ospf authentication-key AUTH_KEY",
4122 "IP Information\n"
4123 "OSPF interface commands\n"
4124 "Authentication password (key)\n"
4125 "The OSPF password (key)")
4126
4127ALIAS (ip_ospf_authentication_key,
4128 ospf_authentication_key_cmd,
4129 "ospf authentication-key AUTH_KEY",
4130 "OSPF interface commands\n"
4131 "Authentication password (key)\n"
4132 "The OSPF password (key)")
4133
4134DEFUN (no_ip_ospf_authentication_key,
4135 no_ip_ospf_authentication_key_addr_cmd,
4136 "no ip ospf authentication-key A.B.C.D",
4137 NO_STR
4138 "IP Information\n"
4139 "OSPF interface commands\n"
4140 "Authentication password (key)\n"
4141 "Address of interface")
4142{
4143 struct interface *ifp;
4144 struct in_addr addr;
4145 int ret;
4146 struct ospf_if_params *params;
4147
4148 ifp = vty->index;
4149 params = IF_DEF_PARAMS (ifp);
4150
4151 if (argc == 2)
4152 {
4153 ret = inet_aton(argv[1], &addr);
4154 if (!ret)
4155 {
4156 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4157 VTY_NEWLINE);
4158 return CMD_WARNING;
4159 }
4160
4161 params = ospf_lookup_if_params (ifp, addr);
4162 if (params == NULL)
4163 return CMD_SUCCESS;
4164 }
4165
4166 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4167 UNSET_IF_PARAM (params, auth_simple);
4168
4169 if (params != IF_DEF_PARAMS (ifp))
4170 {
4171 ospf_free_if_params (ifp, addr);
4172 ospf_if_update_params (ifp, addr);
4173 }
4174
4175 return CMD_SUCCESS;
4176}
4177
4178ALIAS (no_ip_ospf_authentication_key,
4179 no_ip_ospf_authentication_key_cmd,
4180 "no ip ospf authentication-key",
4181 NO_STR
4182 "IP Information\n"
4183 "OSPF interface commands\n"
4184 "Authentication password (key)\n")
4185
4186ALIAS (no_ip_ospf_authentication_key,
4187 no_ospf_authentication_key_cmd,
4188 "no ospf authentication-key",
4189 NO_STR
4190 "OSPF interface commands\n"
4191 "Authentication password (key)\n")
4192
4193DEFUN (ip_ospf_message_digest_key,
4194 ip_ospf_message_digest_key_addr_cmd,
4195 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4196 "IP Information\n"
4197 "OSPF interface commands\n"
4198 "Message digest authentication password (key)\n"
4199 "Key ID\n"
4200 "Use MD5 algorithm\n"
4201 "The OSPF password (key)"
4202 "Address of interface")
4203{
4204 struct interface *ifp;
4205 struct crypt_key *ck;
4206 u_char key_id;
4207 struct in_addr addr;
4208 int ret;
4209 struct ospf_if_params *params;
4210
4211 ifp = vty->index;
4212 params = IF_DEF_PARAMS (ifp);
4213
4214 if (argc == 3)
4215 {
4216 ret = inet_aton(argv[2], &addr);
4217 if (!ret)
4218 {
4219 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4220 VTY_NEWLINE);
4221 return CMD_WARNING;
4222 }
4223
4224 params = ospf_get_if_params (ifp, addr);
4225 ospf_if_update_params (ifp, addr);
4226 }
4227
4228 key_id = strtol (argv[0], NULL, 10);
4229 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4230 {
4231 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4232 return CMD_WARNING;
4233 }
4234
4235 ck = ospf_crypt_key_new ();
4236 ck->key_id = (u_char) key_id;
4237 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
4238 strncpy (ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
4239
4240 ospf_crypt_key_add (params->auth_crypt, ck);
4241 SET_IF_PARAM (params, auth_crypt);
4242
4243 return CMD_SUCCESS;
4244}
4245
4246ALIAS (ip_ospf_message_digest_key,
4247 ip_ospf_message_digest_key_cmd,
4248 "ip ospf message-digest-key <1-255> md5 KEY",
4249 "IP Information\n"
4250 "OSPF interface commands\n"
4251 "Message digest authentication password (key)\n"
4252 "Key ID\n"
4253 "Use MD5 algorithm\n"
4254 "The OSPF password (key)")
4255
4256ALIAS (ip_ospf_message_digest_key,
4257 ospf_message_digest_key_cmd,
4258 "ospf message-digest-key <1-255> md5 KEY",
4259 "OSPF interface commands\n"
4260 "Message digest authentication password (key)\n"
4261 "Key ID\n"
4262 "Use MD5 algorithm\n"
4263 "The OSPF password (key)")
4264
4265DEFUN (no_ip_ospf_message_digest_key,
4266 no_ip_ospf_message_digest_key_addr_cmd,
4267 "no ip ospf message-digest-key <1-255> A.B.C.D",
4268 NO_STR
4269 "IP Information\n"
4270 "OSPF interface commands\n"
4271 "Message digest authentication password (key)\n"
4272 "Key ID\n"
4273 "Address of interface")
4274{
4275 struct interface *ifp;
4276 struct crypt_key *ck;
4277 int key_id;
4278 struct in_addr addr;
4279 int ret;
4280 struct ospf_if_params *params;
4281
4282 ifp = vty->index;
4283 params = IF_DEF_PARAMS (ifp);
4284
4285 if (argc == 2)
4286 {
4287 ret = inet_aton(argv[1], &addr);
4288 if (!ret)
4289 {
4290 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4291 VTY_NEWLINE);
4292 return CMD_WARNING;
4293 }
4294
4295 params = ospf_lookup_if_params (ifp, addr);
4296 if (params == NULL)
4297 return CMD_SUCCESS;
4298 }
4299
4300 key_id = strtol (argv[0], NULL, 10);
4301 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4302 if (ck == NULL)
4303 {
4304 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4305 return CMD_WARNING;
4306 }
4307
4308 ospf_crypt_key_delete (params->auth_crypt, key_id);
4309
4310 if (params != IF_DEF_PARAMS (ifp))
4311 {
4312 ospf_free_if_params (ifp, addr);
4313 ospf_if_update_params (ifp, addr);
4314 }
4315
4316 return CMD_SUCCESS;
4317}
4318
4319ALIAS (no_ip_ospf_message_digest_key,
4320 no_ip_ospf_message_digest_key_cmd,
4321 "no ip ospf message-digest-key <1-255>",
4322 NO_STR
4323 "IP Information\n"
4324 "OSPF interface commands\n"
4325 "Message digest authentication password (key)\n"
4326 "Key ID\n")
4327
4328ALIAS (no_ip_ospf_message_digest_key,
4329 no_ospf_message_digest_key_cmd,
4330 "no ospf message-digest-key <1-255>",
4331 NO_STR
4332 "OSPF interface commands\n"
4333 "Message digest authentication password (key)\n"
4334 "Key ID\n")
4335
4336DEFUN (ip_ospf_cost,
4337 ip_ospf_cost_addr_cmd,
4338 "ip ospf cost <1-65535> A.B.C.D",
4339 "IP Information\n"
4340 "OSPF interface commands\n"
4341 "Interface cost\n"
4342 "Cost\n"
4343 "Address of interface")
4344{
4345 struct interface *ifp = vty->index;
4346 u_int32_t cost;
4347 struct in_addr addr;
4348 int ret;
4349 struct ospf_if_params *params;
4350
4351 params = IF_DEF_PARAMS (ifp);
4352
4353 cost = strtol (argv[0], NULL, 10);
4354
4355 /* cost range is <1-65535>. */
4356 if (cost < 1 || cost > 65535)
4357 {
4358 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4359 return CMD_WARNING;
4360 }
4361
4362 if (argc == 2)
4363 {
4364 ret = inet_aton(argv[1], &addr);
4365 if (!ret)
4366 {
4367 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4368 VTY_NEWLINE);
4369 return CMD_WARNING;
4370 }
4371
4372 params = ospf_get_if_params (ifp, addr);
4373 ospf_if_update_params (ifp, addr);
4374 }
4375
4376 SET_IF_PARAM (params, output_cost_cmd);
4377 params->output_cost_cmd = cost;
4378
4379 ospf_if_recalculate_output_cost (ifp);
4380
4381 return CMD_SUCCESS;
4382}
4383
4384ALIAS (ip_ospf_cost,
4385 ip_ospf_cost_cmd,
4386 "ip ospf cost <1-65535>",
4387 "IP Information\n"
4388 "OSPF interface commands\n"
4389 "Interface cost\n"
4390 "Cost")
4391
4392ALIAS (ip_ospf_cost,
4393 ospf_cost_cmd,
4394 "ospf cost <1-65535>",
4395 "OSPF interface commands\n"
4396 "Interface cost\n"
4397 "Cost")
4398
4399DEFUN (no_ip_ospf_cost,
4400 no_ip_ospf_cost_addr_cmd,
4401 "no ip ospf cost A.B.C.D",
4402 NO_STR
4403 "IP Information\n"
4404 "OSPF interface commands\n"
4405 "Interface cost\n"
4406 "Address of interface")
4407{
4408 struct interface *ifp = vty->index;
4409 struct in_addr addr;
4410 int ret;
4411 struct ospf_if_params *params;
4412
4413 ifp = vty->index;
4414 params = IF_DEF_PARAMS (ifp);
4415
4416 if (argc == 1)
4417 {
4418 ret = inet_aton(argv[0], &addr);
4419 if (!ret)
4420 {
4421 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4422 VTY_NEWLINE);
4423 return CMD_WARNING;
4424 }
4425
4426 params = ospf_lookup_if_params (ifp, addr);
4427 if (params == NULL)
4428 return CMD_SUCCESS;
4429 }
4430
4431 UNSET_IF_PARAM (params, output_cost_cmd);
4432
4433 if (params != IF_DEF_PARAMS (ifp))
4434 {
4435 ospf_free_if_params (ifp, addr);
4436 ospf_if_update_params (ifp, addr);
4437 }
4438
4439 ospf_if_recalculate_output_cost (ifp);
4440
4441 return CMD_SUCCESS;
4442}
4443
4444ALIAS (no_ip_ospf_cost,
4445 no_ip_ospf_cost_cmd,
4446 "no ip ospf cost",
4447 NO_STR
4448 "IP Information\n"
4449 "OSPF interface commands\n"
4450 "Interface cost\n")
4451
4452ALIAS (no_ip_ospf_cost,
4453 no_ospf_cost_cmd,
4454 "no ospf cost",
4455 NO_STR
4456 "OSPF interface commands\n"
4457 "Interface cost\n")
4458
4459void
4460ospf_nbr_timer_update (struct ospf_interface *oi)
4461{
4462 struct route_node *rn;
4463 struct ospf_neighbor *nbr;
4464
4465 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4466 if ((nbr = rn->info))
4467 {
4468 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4469 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4470 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4471 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4472 }
4473}
4474
4475DEFUN (ip_ospf_dead_interval,
4476 ip_ospf_dead_interval_addr_cmd,
4477 "ip ospf dead-interval <1-65535> A.B.C.D",
4478 "IP Information\n"
4479 "OSPF interface commands\n"
4480 "Interval after which a neighbor is declared dead\n"
4481 "Seconds\n"
4482 "Address of interface")
4483{
4484 struct interface *ifp = vty->index;
4485 u_int32_t seconds;
4486 struct in_addr addr;
4487 int ret;
4488 struct ospf_if_params *params;
4489 struct ospf_interface *oi;
4490 struct route_node *rn;
4491
4492 params = IF_DEF_PARAMS (ifp);
4493
4494 seconds = strtol (argv[0], NULL, 10);
4495
4496 /* dead_interval range is <1-65535>. */
4497 if (seconds < 1 || seconds > 65535)
4498 {
4499 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4500 return CMD_WARNING;
4501 }
4502
4503 if (argc == 2)
4504 {
4505 ret = inet_aton(argv[1], &addr);
4506 if (!ret)
4507 {
4508 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4509 VTY_NEWLINE);
4510 return CMD_WARNING;
4511 }
4512
4513 params = ospf_get_if_params (ifp, addr);
4514 ospf_if_update_params (ifp, addr);
4515 }
4516
4517 SET_IF_PARAM (params, v_wait);
4518 params->v_wait = seconds;
4519
4520 /* Update timer values in neighbor structure. */
4521 if (argc == 2)
4522 {
4523 oi = ospf_if_lookup_by_local_addr (ifp, addr);
4524 if (oi)
4525 ospf_nbr_timer_update (oi);
4526 }
4527 else
4528 {
4529 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4530 if ((oi = rn->info))
4531 ospf_nbr_timer_update (oi);
4532 }
4533
4534 return CMD_SUCCESS;
4535}
4536
4537ALIAS (ip_ospf_dead_interval,
4538 ip_ospf_dead_interval_cmd,
4539 "ip ospf dead-interval <1-65535>",
4540 "IP Information\n"
4541 "OSPF interface commands\n"
4542 "Interval after which a neighbor is declared dead\n"
4543 "Seconds\n")
4544
4545ALIAS (ip_ospf_dead_interval,
4546 ospf_dead_interval_cmd,
4547 "ospf dead-interval <1-65535>",
4548 "OSPF interface commands\n"
4549 "Interval after which a neighbor is declared dead\n"
4550 "Seconds\n")
4551
4552DEFUN (no_ip_ospf_dead_interval,
4553 no_ip_ospf_dead_interval_addr_cmd,
4554 "no ip ospf dead-interval A.B.C.D",
4555 NO_STR
4556 "IP Information\n"
4557 "OSPF interface commands\n"
4558 "Interval after which a neighbor is declared dead\n"
4559 "Address of interface")
4560{
4561 struct interface *ifp = vty->index;
4562 struct in_addr addr;
4563 int ret;
4564 struct ospf_if_params *params;
4565 struct ospf_interface *oi;
4566 struct route_node *rn;
4567
4568 ifp = vty->index;
4569 params = IF_DEF_PARAMS (ifp);
4570
4571 if (argc == 1)
4572 {
4573 ret = inet_aton(argv[0], &addr);
4574 if (!ret)
4575 {
4576 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4577 VTY_NEWLINE);
4578 return CMD_WARNING;
4579 }
4580
4581 params = ospf_lookup_if_params (ifp, addr);
4582 if (params == NULL)
4583 return CMD_SUCCESS;
4584 }
4585
4586 UNSET_IF_PARAM (params, v_wait);
4587 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4588
4589 if (params != IF_DEF_PARAMS (ifp))
4590 {
4591 ospf_free_if_params (ifp, addr);
4592 ospf_if_update_params (ifp, addr);
4593 }
4594
4595 /* Update timer values in neighbor structure. */
4596 if (argc == 1)
4597 {
4598 oi = ospf_if_lookup_by_local_addr (ifp, addr);
4599 if (oi)
4600 ospf_nbr_timer_update (oi);
4601 }
4602 else
4603 {
4604 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4605 if ((oi = rn->info))
4606 ospf_nbr_timer_update (oi);
4607 }
4608
4609 return CMD_SUCCESS;
4610}
4611
4612ALIAS (no_ip_ospf_dead_interval,
4613 no_ip_ospf_dead_interval_cmd,
4614 "no ip ospf dead-interval",
4615 NO_STR
4616 "IP Information\n"
4617 "OSPF interface commands\n"
4618 "Interval after which a neighbor is declared dead\n")
4619
4620ALIAS (no_ip_ospf_dead_interval,
4621 no_ospf_dead_interval_cmd,
4622 "no ospf dead-interval",
4623 NO_STR
4624 "OSPF interface commands\n"
4625 "Interval after which a neighbor is declared dead\n")
4626
4627DEFUN (ip_ospf_hello_interval,
4628 ip_ospf_hello_interval_addr_cmd,
4629 "ip ospf hello-interval <1-65535> A.B.C.D",
4630 "IP Information\n"
4631 "OSPF interface commands\n"
4632 "Time between HELLO packets\n"
4633 "Seconds\n"
4634 "Address of interface")
4635{
4636 struct interface *ifp = vty->index;
4637 u_int32_t seconds;
4638 struct in_addr addr;
4639 int ret;
4640 struct ospf_if_params *params;
4641
4642 params = IF_DEF_PARAMS (ifp);
4643
4644 seconds = strtol (argv[0], NULL, 10);
4645
4646 /* HelloInterval range is <1-65535>. */
4647 if (seconds < 1 || seconds > 65535)
4648 {
4649 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4650 return CMD_WARNING;
4651 }
4652
4653 if (argc == 2)
4654 {
4655 ret = inet_aton(argv[1], &addr);
4656 if (!ret)
4657 {
4658 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4659 VTY_NEWLINE);
4660 return CMD_WARNING;
4661 }
4662
4663 params = ospf_get_if_params (ifp, addr);
4664 ospf_if_update_params (ifp, addr);
4665 }
4666
4667 SET_IF_PARAM (params, v_hello);
4668 params->v_hello = seconds;
4669
4670 return CMD_SUCCESS;
4671}
4672
4673ALIAS (ip_ospf_hello_interval,
4674 ip_ospf_hello_interval_cmd,
4675 "ip ospf hello-interval <1-65535>",
4676 "IP Information\n"
4677 "OSPF interface commands\n"
4678 "Time between HELLO packets\n"
4679 "Seconds\n")
4680
4681ALIAS (ip_ospf_hello_interval,
4682 ospf_hello_interval_cmd,
4683 "ospf hello-interval <1-65535>",
4684 "OSPF interface commands\n"
4685 "Time between HELLO packets\n"
4686 "Seconds\n")
4687
4688DEFUN (no_ip_ospf_hello_interval,
4689 no_ip_ospf_hello_interval_addr_cmd,
4690 "no ip ospf hello-interval A.B.C.D",
4691 NO_STR
4692 "IP Information\n"
4693 "OSPF interface commands\n"
4694 "Time between HELLO packets\n"
4695 "Address of interface")
4696{
4697 struct interface *ifp = vty->index;
4698 struct in_addr addr;
4699 int ret;
4700 struct ospf_if_params *params;
4701
4702 ifp = vty->index;
4703 params = IF_DEF_PARAMS (ifp);
4704
4705 if (argc == 1)
4706 {
4707 ret = inet_aton(argv[0], &addr);
4708 if (!ret)
4709 {
4710 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4711 VTY_NEWLINE);
4712 return CMD_WARNING;
4713 }
4714
4715 params = ospf_lookup_if_params (ifp, addr);
4716 if (params == NULL)
4717 return CMD_SUCCESS;
4718 }
4719
4720 UNSET_IF_PARAM (params, v_hello);
4721 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4722
4723 if (params != IF_DEF_PARAMS (ifp))
4724 {
4725 ospf_free_if_params (ifp, addr);
4726 ospf_if_update_params (ifp, addr);
4727 }
4728
4729 return CMD_SUCCESS;
4730}
4731
4732ALIAS (no_ip_ospf_hello_interval,
4733 no_ip_ospf_hello_interval_cmd,
4734 "no ip ospf hello-interval",
4735 NO_STR
4736 "IP Information\n"
4737 "OSPF interface commands\n"
4738 "Time between HELLO packets\n")
4739
4740ALIAS (no_ip_ospf_hello_interval,
4741 no_ospf_hello_interval_cmd,
4742 "no ospf hello-interval",
4743 NO_STR
4744 "OSPF interface commands\n"
4745 "Time between HELLO packets\n")
4746
4747DEFUN (ip_ospf_network,
4748 ip_ospf_network_cmd,
4749 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4750 "IP Information\n"
4751 "OSPF interface commands\n"
4752 "Network type\n"
4753 "Specify OSPF broadcast multi-access network\n"
4754 "Specify OSPF NBMA network\n"
4755 "Specify OSPF point-to-multipoint network\n"
4756 "Specify OSPF point-to-point network\n")
4757{
4758 struct interface *ifp = vty->index;
4759 int old_type = IF_DEF_PARAMS (ifp)->type;
4760 struct route_node *rn;
4761
4762 if (strncmp (argv[0], "b", 1) == 0)
4763 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4764 else if (strncmp (argv[0], "n", 1) == 0)
4765 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4766 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4767 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4768 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4769 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4770
4771 if (IF_DEF_PARAMS (ifp)->type == old_type)
4772 return CMD_SUCCESS;
4773
4774 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4775
4776 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4777 {
4778 struct ospf_interface *oi = rn->info;
4779
4780 if (!oi)
4781 continue;
4782
4783 oi->type = IF_DEF_PARAMS (ifp)->type;
4784
4785 if (oi->state > ISM_Down)
4786 {
4787 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4788 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4789 }
4790 }
4791
4792 return CMD_SUCCESS;
4793}
4794
4795ALIAS (ip_ospf_network,
4796 ospf_network_cmd,
4797 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4798 "OSPF interface commands\n"
4799 "Network type\n"
4800 "Specify OSPF broadcast multi-access network\n"
4801 "Specify OSPF NBMA network\n"
4802 "Specify OSPF point-to-multipoint network\n"
4803 "Specify OSPF point-to-point network\n")
4804
4805DEFUN (no_ip_ospf_network,
4806 no_ip_ospf_network_cmd,
4807 "no ip ospf network",
4808 NO_STR
4809 "IP Information\n"
4810 "OSPF interface commands\n"
4811 "Network type\n")
4812{
4813 struct interface *ifp = vty->index;
4814 int old_type = IF_DEF_PARAMS (ifp)->type;
4815 struct route_node *rn;
4816
4817 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4818
4819 if (IF_DEF_PARAMS (ifp)->type == old_type)
4820 return CMD_SUCCESS;
4821
4822 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4823 {
4824 struct ospf_interface *oi = rn->info;
4825
4826 if (!oi)
4827 continue;
4828
4829 oi->type = IF_DEF_PARAMS (ifp)->type;
4830
4831 if (oi->state > ISM_Down)
4832 {
4833 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4834 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4835 }
4836 }
4837
4838 return CMD_SUCCESS;
4839}
4840
4841ALIAS (no_ip_ospf_network,
4842 no_ospf_network_cmd,
4843 "no ospf network",
4844 NO_STR
4845 "OSPF interface commands\n"
4846 "Network type\n")
4847
4848DEFUN (ip_ospf_priority,
4849 ip_ospf_priority_addr_cmd,
4850 "ip ospf priority <0-255> A.B.C.D",
4851 "IP Information\n"
4852 "OSPF interface commands\n"
4853 "Router priority\n"
4854 "Priority\n"
4855 "Address of interface")
4856{
4857 struct interface *ifp = vty->index;
4858 u_int32_t priority;
4859 struct route_node *rn;
4860 struct in_addr addr;
4861 int ret;
4862 struct ospf_if_params *params;
4863
4864 params = IF_DEF_PARAMS (ifp);
4865
4866 priority = strtol (argv[0], NULL, 10);
4867
4868 /* Router Priority range is <0-255>. */
4869 if (priority < 0 || priority > 255)
4870 {
4871 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4872 return CMD_WARNING;
4873 }
4874
4875 if (argc == 2)
4876 {
4877 ret = inet_aton(argv[1], &addr);
4878 if (!ret)
4879 {
4880 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4881 VTY_NEWLINE);
4882 return CMD_WARNING;
4883 }
4884
4885 params = ospf_get_if_params (ifp, addr);
4886 ospf_if_update_params (ifp, addr);
4887 }
4888
4889 SET_IF_PARAM (params, priority);
4890 params->priority = priority;
4891
4892 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4893 {
4894 struct ospf_interface *oi = rn->info;
4895
4896 if (!oi)
4897 continue;
4898
4899
4900 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
4901 {
4902 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
4903 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
4904 }
4905 }
4906
4907 return CMD_SUCCESS;
4908}
4909
4910ALIAS (ip_ospf_priority,
4911 ip_ospf_priority_cmd,
4912 "ip ospf priority <0-255>",
4913 "IP Information\n"
4914 "OSPF interface commands\n"
4915 "Router priority\n"
4916 "Priority\n")
4917
4918ALIAS (ip_ospf_priority,
4919 ospf_priority_cmd,
4920 "ospf priority <0-255>",
4921 "OSPF interface commands\n"
4922 "Router priority\n"
4923 "Priority\n")
4924
4925DEFUN (no_ip_ospf_priority,
4926 no_ip_ospf_priority_addr_cmd,
4927 "no ip ospf priority A.B.C.D",
4928 NO_STR
4929 "IP Information\n"
4930 "OSPF interface commands\n"
4931 "Router priority\n"
4932 "Address of interface")
4933{
4934 struct interface *ifp = vty->index;
4935 struct route_node *rn;
4936 struct in_addr addr;
4937 int ret;
4938 struct ospf_if_params *params;
4939
4940 ifp = vty->index;
4941 params = IF_DEF_PARAMS (ifp);
4942
4943 if (argc == 1)
4944 {
4945 ret = inet_aton(argv[0], &addr);
4946 if (!ret)
4947 {
4948 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4949 VTY_NEWLINE);
4950 return CMD_WARNING;
4951 }
4952
4953 params = ospf_lookup_if_params (ifp, addr);
4954 if (params == NULL)
4955 return CMD_SUCCESS;
4956 }
4957
4958 UNSET_IF_PARAM (params, priority);
4959 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
4960
4961 if (params != IF_DEF_PARAMS (ifp))
4962 {
4963 ospf_free_if_params (ifp, addr);
4964 ospf_if_update_params (ifp, addr);
4965 }
4966
4967 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4968 {
4969 struct ospf_interface *oi = rn->info;
4970
4971 if (!oi)
4972 continue;
4973
4974
4975 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
4976 {
4977 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
4978 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
4979 }
4980 }
4981
4982 return CMD_SUCCESS;
4983}
4984
4985ALIAS (no_ip_ospf_priority,
4986 no_ip_ospf_priority_cmd,
4987 "no ip ospf priority",
4988 NO_STR
4989 "IP Information\n"
4990 "OSPF interface commands\n"
4991 "Router priority\n")
4992
4993ALIAS (no_ip_ospf_priority,
4994 no_ospf_priority_cmd,
4995 "no ospf priority",
4996 NO_STR
4997 "OSPF interface commands\n"
4998 "Router priority\n")
4999
5000DEFUN (ip_ospf_retransmit_interval,
5001 ip_ospf_retransmit_interval_addr_cmd,
5002 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5003 "IP Information\n"
5004 "OSPF interface commands\n"
5005 "Time between retransmitting lost link state advertisements\n"
5006 "Seconds\n"
5007 "Address of interface")
5008{
5009 struct interface *ifp = vty->index;
5010 u_int32_t seconds;
5011 struct in_addr addr;
5012 int ret;
5013 struct ospf_if_params *params;
5014
5015 params = IF_DEF_PARAMS (ifp);
5016 seconds = strtol (argv[0], NULL, 10);
5017
5018 /* Retransmit Interval range is <3-65535>. */
5019 if (seconds < 3 || seconds > 65535)
5020 {
5021 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5022 return CMD_WARNING;
5023 }
5024
5025
5026 if (argc == 2)
5027 {
5028 ret = inet_aton(argv[1], &addr);
5029 if (!ret)
5030 {
5031 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5032 VTY_NEWLINE);
5033 return CMD_WARNING;
5034 }
5035
5036 params = ospf_get_if_params (ifp, addr);
5037 ospf_if_update_params (ifp, addr);
5038 }
5039
5040 SET_IF_PARAM (params, retransmit_interval);
5041 params->retransmit_interval = seconds;
5042
5043 return CMD_SUCCESS;
5044}
5045
5046ALIAS (ip_ospf_retransmit_interval,
5047 ip_ospf_retransmit_interval_cmd,
5048 "ip ospf retransmit-interval <3-65535>",
5049 "IP Information\n"
5050 "OSPF interface commands\n"
5051 "Time between retransmitting lost link state advertisements\n"
5052 "Seconds\n")
5053
5054ALIAS (ip_ospf_retransmit_interval,
5055 ospf_retransmit_interval_cmd,
5056 "ospf retransmit-interval <3-65535>",
5057 "OSPF interface commands\n"
5058 "Time between retransmitting lost link state advertisements\n"
5059 "Seconds\n")
5060
5061DEFUN (no_ip_ospf_retransmit_interval,
5062 no_ip_ospf_retransmit_interval_addr_cmd,
5063 "no ip ospf retransmit-interval A.B.C.D",
5064 NO_STR
5065 "IP Information\n"
5066 "OSPF interface commands\n"
5067 "Time between retransmitting lost link state advertisements\n"
5068 "Address of interface")
5069{
5070 struct interface *ifp = vty->index;
5071 struct in_addr addr;
5072 int ret;
5073 struct ospf_if_params *params;
5074
5075 ifp = vty->index;
5076 params = IF_DEF_PARAMS (ifp);
5077
5078 if (argc == 1)
5079 {
5080 ret = inet_aton(argv[0], &addr);
5081 if (!ret)
5082 {
5083 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5084 VTY_NEWLINE);
5085 return CMD_WARNING;
5086 }
5087
5088 params = ospf_lookup_if_params (ifp, addr);
5089 if (params == NULL)
5090 return CMD_SUCCESS;
5091 }
5092
5093 UNSET_IF_PARAM (params, retransmit_interval);
5094 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5095
5096 if (params != IF_DEF_PARAMS (ifp))
5097 {
5098 ospf_free_if_params (ifp, addr);
5099 ospf_if_update_params (ifp, addr);
5100 }
5101
5102 return CMD_SUCCESS;
5103}
5104
5105ALIAS (no_ip_ospf_retransmit_interval,
5106 no_ip_ospf_retransmit_interval_cmd,
5107 "no ip ospf retransmit-interval",
5108 NO_STR
5109 "IP Information\n"
5110 "OSPF interface commands\n"
5111 "Time between retransmitting lost link state advertisements\n")
5112
5113ALIAS (no_ip_ospf_retransmit_interval,
5114 no_ospf_retransmit_interval_cmd,
5115 "no ospf retransmit-interval",
5116 NO_STR
5117 "OSPF interface commands\n"
5118 "Time between retransmitting lost link state advertisements\n")
5119
5120DEFUN (ip_ospf_transmit_delay,
5121 ip_ospf_transmit_delay_addr_cmd,
5122 "ip ospf transmit-delay <1-65535> A.B.C.D",
5123 "IP Information\n"
5124 "OSPF interface commands\n"
5125 "Link state transmit delay\n"
5126 "Seconds\n"
5127 "Address of interface")
5128{
5129 struct interface *ifp = vty->index;
5130 u_int32_t seconds;
5131 struct in_addr addr;
5132 int ret;
5133 struct ospf_if_params *params;
5134
5135 params = IF_DEF_PARAMS (ifp);
5136 seconds = strtol (argv[0], NULL, 10);
5137
5138 /* Transmit Delay range is <1-65535>. */
5139 if (seconds < 1 || seconds > 65535)
5140 {
5141 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5142 return CMD_WARNING;
5143 }
5144
5145 if (argc == 2)
5146 {
5147 ret = inet_aton(argv[1], &addr);
5148 if (!ret)
5149 {
5150 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5151 VTY_NEWLINE);
5152 return CMD_WARNING;
5153 }
5154
5155 params = ospf_get_if_params (ifp, addr);
5156 ospf_if_update_params (ifp, addr);
5157 }
5158
5159 SET_IF_PARAM (params, transmit_delay);
5160 params->transmit_delay = seconds;
5161
5162 return CMD_SUCCESS;
5163}
5164
5165ALIAS (ip_ospf_transmit_delay,
5166 ip_ospf_transmit_delay_cmd,
5167 "ip ospf transmit-delay <1-65535>",
5168 "IP Information\n"
5169 "OSPF interface commands\n"
5170 "Link state transmit delay\n"
5171 "Seconds\n")
5172
5173ALIAS (ip_ospf_transmit_delay,
5174 ospf_transmit_delay_cmd,
5175 "ospf transmit-delay <1-65535>",
5176 "OSPF interface commands\n"
5177 "Link state transmit delay\n"
5178 "Seconds\n")
5179
5180DEFUN (no_ip_ospf_transmit_delay,
5181 no_ip_ospf_transmit_delay_addr_cmd,
5182 "no ip ospf transmit-delay A.B.C.D",
5183 NO_STR
5184 "IP Information\n"
5185 "OSPF interface commands\n"
5186 "Link state transmit delay\n"
5187 "Address of interface")
5188{
5189 struct interface *ifp = vty->index;
5190 struct in_addr addr;
5191 int ret;
5192 struct ospf_if_params *params;
5193
5194 ifp = vty->index;
5195 params = IF_DEF_PARAMS (ifp);
5196
5197 if (argc == 1)
5198 {
5199 ret = inet_aton(argv[0], &addr);
5200 if (!ret)
5201 {
5202 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5203 VTY_NEWLINE);
5204 return CMD_WARNING;
5205 }
5206
5207 params = ospf_lookup_if_params (ifp, addr);
5208 if (params == NULL)
5209 return CMD_SUCCESS;
5210 }
5211
5212 UNSET_IF_PARAM (params, transmit_delay);
5213 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5214
5215 if (params != IF_DEF_PARAMS (ifp))
5216 {
5217 ospf_free_if_params (ifp, addr);
5218 ospf_if_update_params (ifp, addr);
5219 }
5220
5221 return CMD_SUCCESS;
5222}
5223
5224ALIAS (no_ip_ospf_transmit_delay,
5225 no_ip_ospf_transmit_delay_cmd,
5226 "no ip ospf transmit-delay",
5227 NO_STR
5228 "IP Information\n"
5229 "OSPF interface commands\n"
5230 "Link state transmit delay\n")
5231
5232ALIAS (no_ip_ospf_transmit_delay,
5233 no_ospf_transmit_delay_cmd,
5234 "no ospf transmit-delay",
5235 NO_STR
5236 "OSPF interface commands\n"
5237 "Link state transmit delay\n")
5238
5239
5240DEFUN (ospf_redistribute_source_metric_type,
5241 ospf_redistribute_source_metric_type_routemap_cmd,
5242 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5243 "Redistribute information from another routing protocol\n"
5244 "Kernel routes\n"
5245 "Connected\n"
5246 "Static routes\n"
5247 "Routing Information Protocol (RIP)\n"
5248 "Border Gateway Protocol (BGP)\n"
5249 "Metric for redistributed routes\n"
5250 "OSPF default metric\n"
5251 "OSPF exterior metric type for redistributed routes\n"
5252 "Set OSPF External Type 1 metrics\n"
5253 "Set OSPF External Type 2 metrics\n"
5254 "Route map reference\n"
5255 "Pointer to route-map entries\n")
5256{
5257 int source;
5258 int type = -1;
5259 int metric = -1;
5260
5261 /* Get distribute source. */
5262 if (!str2distribute_source (argv[0], &source))
5263 return CMD_WARNING;
5264
5265 /* Get metric value. */
5266 if (argc >= 2)
5267 if (!str2metric (argv[1], &metric))
5268 return CMD_WARNING;
5269
5270 /* Get metric type. */
5271 if (argc >= 3)
5272 if (!str2metric_type (argv[2], &type))
5273 return CMD_WARNING;
5274
5275 if (argc == 4)
5276 ospf_routemap_set (source, argv[3]);
5277 else
5278 ospf_routemap_unset (source);
5279
5280 return ospf_redistribute_set (source, type, metric);
5281}
5282
5283ALIAS (ospf_redistribute_source_metric_type,
5284 ospf_redistribute_source_metric_type_cmd,
5285 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5286 "Redistribute information from another routing protocol\n"
5287 "Kernel routes\n"
5288 "Connected\n"
5289 "Static routes\n"
5290 "Routing Information Protocol (RIP)\n"
5291 "Border Gateway Protocol (BGP)\n"
5292 "Metric for redistributed routes\n"
5293 "OSPF default metric\n"
5294 "OSPF exterior metric type for redistributed routes\n"
5295 "Set OSPF External Type 1 metrics\n"
5296 "Set OSPF External Type 2 metrics\n")
5297
5298ALIAS (ospf_redistribute_source_metric_type,
5299 ospf_redistribute_source_metric_cmd,
5300 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5301 "Redistribute information from another routing protocol\n"
5302 "Kernel routes\n"
5303 "Connected\n"
5304 "Static routes\n"
5305 "Routing Information Protocol (RIP)\n"
5306 "Border Gateway Protocol (BGP)\n"
5307 "Metric for redistributed routes\n"
5308 "OSPF default metric\n")
5309
5310DEFUN (ospf_redistribute_source_type_metric,
5311 ospf_redistribute_source_type_metric_routemap_cmd,
5312 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5313 "Redistribute information from another routing protocol\n"
5314 "Kernel routes\n"
5315 "Connected\n"
5316 "Static routes\n"
5317 "Routing Information Protocol (RIP)\n"
5318 "Border Gateway Protocol (BGP)\n"
5319 "OSPF exterior metric type for redistributed routes\n"
5320 "Set OSPF External Type 1 metrics\n"
5321 "Set OSPF External Type 2 metrics\n"
5322 "Metric for redistributed routes\n"
5323 "OSPF default metric\n"
5324 "Route map reference\n"
5325 "Pointer to route-map entries\n")
5326{
5327 int source;
5328 int type = -1;
5329 int metric = -1;
5330
5331 /* Get distribute source. */
5332 if (!str2distribute_source (argv[0], &source))
5333 return CMD_WARNING;
5334
5335 /* Get metric value. */
5336 if (argc >= 2)
5337 if (!str2metric_type (argv[1], &type))
5338 return CMD_WARNING;
5339
5340 /* Get metric type. */
5341 if (argc >= 3)
5342 if (!str2metric (argv[2], &metric))
5343 return CMD_WARNING;
5344
5345 if (argc == 4)
5346 ospf_routemap_set (source, argv[3]);
5347 else
5348 ospf_routemap_unset (source);
5349
5350 return ospf_redistribute_set (source, type, metric);
5351}
5352
5353ALIAS (ospf_redistribute_source_type_metric,
5354 ospf_redistribute_source_type_metric_cmd,
5355 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5356 "Redistribute information from another routing protocol\n"
5357 "Kernel routes\n"
5358 "Connected\n"
5359 "Static routes\n"
5360 "Routing Information Protocol (RIP)\n"
5361 "Border Gateway Protocol (BGP)\n"
5362 "OSPF exterior metric type for redistributed routes\n"
5363 "Set OSPF External Type 1 metrics\n"
5364 "Set OSPF External Type 2 metrics\n"
5365 "Metric for redistributed routes\n"
5366 "OSPF default metric\n")
5367
5368ALIAS (ospf_redistribute_source_type_metric,
5369 ospf_redistribute_source_type_cmd,
5370 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5371 "Redistribute information from another routing protocol\n"
5372 "Kernel routes\n"
5373 "Connected\n"
5374 "Static routes\n"
5375 "Routing Information Protocol (RIP)\n"
5376 "Border Gateway Protocol (BGP)\n"
5377 "OSPF exterior metric type for redistributed routes\n"
5378 "Set OSPF External Type 1 metrics\n"
5379 "Set OSPF External Type 2 metrics\n")
5380
5381ALIAS (ospf_redistribute_source_type_metric,
5382 ospf_redistribute_source_cmd,
5383 "redistribute (kernel|connected|static|rip|bgp)",
5384 "Redistribute information from another routing protocol\n"
5385 "Kernel routes\n"
5386 "Connected\n"
5387 "Static routes\n"
5388 "Routing Information Protocol (RIP)\n"
5389 "Border Gateway Protocol (BGP)\n")
5390
5391DEFUN (ospf_redistribute_source_metric_routemap,
5392 ospf_redistribute_source_metric_routemap_cmd,
5393 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5394 "Redistribute information from another routing protocol\n"
5395 "Kernel routes\n"
5396 "Connected\n"
5397 "Static routes\n"
5398 "Routing Information Protocol (RIP)\n"
5399 "Border Gateway Protocol (BGP)\n"
5400 "Metric for redistributed routes\n"
5401 "OSPF default metric\n"
5402 "Route map reference\n"
5403 "Pointer to route-map entries\n")
5404{
5405 int source;
5406 int metric = -1;
5407
5408 /* Get distribute source. */
5409 if (!str2distribute_source (argv[0], &source))
5410 return CMD_WARNING;
5411
5412 /* Get metric value. */
5413 if (argc >= 2)
5414 if (!str2metric (argv[1], &metric))
5415 return CMD_WARNING;
5416
5417 if (argc == 3)
5418 ospf_routemap_set (source, argv[2]);
5419 else
5420 ospf_routemap_unset (source);
5421
5422 return ospf_redistribute_set (source, -1, metric);
5423}
5424
5425DEFUN (ospf_redistribute_source_type_routemap,
5426 ospf_redistribute_source_type_routemap_cmd,
5427 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5428 "Redistribute information from another routing protocol\n"
5429 "Kernel routes\n"
5430 "Connected\n"
5431 "Static routes\n"
5432 "Routing Information Protocol (RIP)\n"
5433 "Border Gateway Protocol (BGP)\n"
5434 "OSPF exterior metric type for redistributed routes\n"
5435 "Set OSPF External Type 1 metrics\n"
5436 "Set OSPF External Type 2 metrics\n"
5437 "Route map reference\n"
5438 "Pointer to route-map entries\n")
5439{
5440 int source;
5441 int type = -1;
5442
5443 /* Get distribute source. */
5444 if (!str2distribute_source (argv[0], &source))
5445 return CMD_WARNING;
5446
5447 /* Get metric value. */
5448 if (argc >= 2)
5449 if (!str2metric_type (argv[1], &type))
5450 return CMD_WARNING;
5451
5452 if (argc == 3)
5453 ospf_routemap_set (source, argv[2]);
5454 else
5455 ospf_routemap_unset (source);
5456
5457 return ospf_redistribute_set (source, type, -1);
5458}
5459
5460DEFUN (ospf_redistribute_source_routemap,
5461 ospf_redistribute_source_routemap_cmd,
5462 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5463 "Redistribute information from another routing protocol\n"
5464 "Kernel routes\n"
5465 "Connected\n"
5466 "Static routes\n"
5467 "Routing Information Protocol (RIP)\n"
5468 "Border Gateway Protocol (BGP)\n"
5469 "Route map reference\n"
5470 "Pointer to route-map entries\n")
5471{
5472 int source;
5473
5474 /* Get distribute source. */
5475 if (!str2distribute_source (argv[0], &source))
5476 return CMD_WARNING;
5477
5478 if (argc == 2)
5479 ospf_routemap_set (source, argv[1]);
5480 else
5481 ospf_routemap_unset (source);
5482
5483 return ospf_redistribute_set (source, -1, -1);
5484}
5485
5486DEFUN (no_ospf_redistribute_source,
5487 no_ospf_redistribute_source_cmd,
5488 "no redistribute (kernel|connected|static|rip|bgp)",
5489 NO_STR
5490 "Redistribute information from another routing protocol\n"
5491 "Kernel routes\n"
5492 "Connected\n"
5493 "Static routes\n"
5494 "Routing Information Protocol (RIP)\n"
5495 "Border Gateway Protocol (BGP)\n")
5496{
5497 int source;
5498
5499 if (!str2distribute_source (argv[0], &source))
5500 return CMD_WARNING;
5501
5502 ospf_routemap_unset (source);
5503 return ospf_redistribute_unset (source);
5504}
5505
5506DEFUN (ospf_distribute_list_out,
5507 ospf_distribute_list_out_cmd,
5508 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5509 "Filter networks in routing updates\n"
5510 "Access-list name\n"
5511 OUT_STR
5512 "Kernel routes\n"
5513 "Connected\n"
5514 "Static routes\n"
5515 "Routing Information Protocol (RIP)\n"
5516 "Border Gateway Protocol (BGP)\n")
5517{
5518 int source;
5519
5520 /* Get distribute source. */
5521 if (!str2distribute_source (argv[1], &source))
5522 return CMD_WARNING;
5523
5524 return ospf_distribute_list_out_set (source, argv[0]);
5525}
5526
5527DEFUN (no_ospf_distribute_list_out,
5528 no_ospf_distribute_list_out_cmd,
5529 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5530 NO_STR
5531 "Filter networks in routing updates\n"
5532 "Access-list name\n"
5533 OUT_STR
5534 "Kernel routes\n"
5535 "Connected\n"
5536 "Static routes\n"
5537 "Routing Information Protocol (RIP)\n"
5538 "Border Gateway Protocol (BGP)\n")
5539{
5540 int source;
5541
5542 if (!str2distribute_source (argv[1], &source))
5543 return CMD_WARNING;
5544
5545 return ospf_distribute_list_out_unset (source, argv[0]);
5546}
5547
5548/* Default information originate. */
5549DEFUN (ospf_default_information_originate_metric_type_routemap,
5550 ospf_default_information_originate_metric_type_routemap_cmd,
5551 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5552 "Control distribution of default information\n"
5553 "Distribute a default route\n"
5554 "OSPF default metric\n"
5555 "OSPF metric\n"
5556 "OSPF metric type for default routes\n"
5557 "Set OSPF External Type 1 metrics\n"
5558 "Set OSPF External Type 2 metrics\n"
5559 "Route map reference\n"
5560 "Pointer to route-map entries\n")
5561{
5562 int type = -1;
5563 int metric = -1;
5564
5565 /* Get metric value. */
5566 if (argc >= 1)
5567 if (!str2metric (argv[0], &metric))
5568 return CMD_WARNING;
5569
5570 /* Get metric type. */
5571 if (argc >= 2)
5572 if (!str2metric_type (argv[1], &type))
5573 return CMD_WARNING;
5574
5575 if (argc == 3)
5576 ospf_routemap_set (DEFAULT_ROUTE, argv[2]);
5577 else
5578 ospf_routemap_unset (DEFAULT_ROUTE);
5579
5580 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, type, metric);
5581}
5582
5583ALIAS (ospf_default_information_originate_metric_type_routemap,
5584 ospf_default_information_originate_metric_type_cmd,
5585 "default-information originate metric <0-16777214> metric-type (1|2)",
5586 "Control distribution of default information\n"
5587 "Distribute a default route\n"
5588 "OSPF default metric\n"
5589 "OSPF metric\n"
5590 "OSPF metric type for default routes\n"
5591 "Set OSPF External Type 1 metrics\n"
5592 "Set OSPF External Type 2 metrics\n")
5593
5594ALIAS (ospf_default_information_originate_metric_type_routemap,
5595 ospf_default_information_originate_metric_cmd,
5596 "default-information originate metric <0-16777214>",
5597 "Control distribution of default information\n"
5598 "Distribute a default route\n"
5599 "OSPF default metric\n"
5600 "OSPF metric\n")
5601
5602ALIAS (ospf_default_information_originate_metric_type_routemap,
5603 ospf_default_information_originate_cmd,
5604 "default-information originate",
5605 "Control distribution of default information\n"
5606 "Distribute a default route\n")
5607
5608/* Default information originate. */
5609DEFUN (ospf_default_information_originate_metric_routemap,
5610 ospf_default_information_originate_metric_routemap_cmd,
5611 "default-information originate metric <0-16777214> route-map WORD",
5612 "Control distribution of default information\n"
5613 "Distribute a default route\n"
5614 "OSPF default metric\n"
5615 "OSPF metric\n"
5616 "Route map reference\n"
5617 "Pointer to route-map entries\n")
5618{
5619 int metric = -1;
5620
5621 /* Get metric value. */
5622 if (argc >= 1)
5623 if (!str2metric (argv[0], &metric))
5624 return CMD_WARNING;
5625
5626 if (argc == 2)
5627 ospf_routemap_set (DEFAULT_ROUTE, argv[1]);
5628 else
5629 ospf_routemap_unset (DEFAULT_ROUTE);
5630
5631 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, -1, metric);
5632}
5633
5634/* Default information originate. */
5635DEFUN (ospf_default_information_originate_routemap,
5636 ospf_default_information_originate_routemap_cmd,
5637 "default-information originate route-map WORD",
5638 "Control distribution of default information\n"
5639 "Distribute a default route\n"
5640 "Route map reference\n"
5641 "Pointer to route-map entries\n")
5642{
5643 if (argc == 1)
5644 ospf_routemap_set (DEFAULT_ROUTE, argv[0]);
5645 else
5646 ospf_routemap_unset (DEFAULT_ROUTE);
5647
5648 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, -1, -1);
5649}
5650
5651DEFUN (ospf_default_information_originate_type_metric_routemap,
5652 ospf_default_information_originate_type_metric_routemap_cmd,
5653 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5654 "Control distribution of default information\n"
5655 "Distribute a default route\n"
5656 "OSPF metric type for default routes\n"
5657 "Set OSPF External Type 1 metrics\n"
5658 "Set OSPF External Type 2 metrics\n"
5659 "OSPF default metric\n"
5660 "OSPF metric\n"
5661 "Route map reference\n"
5662 "Pointer to route-map entries\n")
5663{
5664 int type = -1;
5665 int metric = -1;
5666
5667 /* Get metric type. */
5668 if (argc >= 1)
5669 if (!str2metric_type (argv[0], &type))
5670 return CMD_WARNING;
5671
5672 /* Get metric value. */
5673 if (argc >= 2)
5674 if (!str2metric (argv[1], &metric))
5675 return CMD_WARNING;
5676
5677 if (argc == 3)
5678 ospf_routemap_set (DEFAULT_ROUTE, argv[2]);
5679 else
5680 ospf_routemap_unset (DEFAULT_ROUTE);
5681
5682 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, type, metric);
5683}
5684
5685ALIAS (ospf_default_information_originate_type_metric_routemap,
5686 ospf_default_information_originate_type_metric_cmd,
5687 "default-information originate metric-type (1|2) metric <0-16777214>",
5688 "Control distribution of default information\n"
5689 "Distribute a default route\n"
5690 "OSPF metric type for default routes\n"
5691 "Set OSPF External Type 1 metrics\n"
5692 "Set OSPF External Type 2 metrics\n"
5693 "OSPF default metric\n"
5694 "OSPF metric\n")
5695
5696ALIAS (ospf_default_information_originate_type_metric_routemap,
5697 ospf_default_information_originate_type_cmd,
5698 "default-information originate metric-type (1|2)",
5699 "Control distribution of default information\n"
5700 "Distribute a default route\n"
5701 "OSPF metric type for default routes\n"
5702 "Set OSPF External Type 1 metrics\n"
5703 "Set OSPF External Type 2 metrics\n")
5704
5705DEFUN (ospf_default_information_originate_type_routemap,
5706 ospf_default_information_originate_type_routemap_cmd,
5707 "default-information originate metric-type (1|2) route-map WORD",
5708 "Control distribution of default information\n"
5709 "Distribute a default route\n"
5710 "OSPF metric type for default routes\n"
5711 "Set OSPF External Type 1 metrics\n"
5712 "Set OSPF External Type 2 metrics\n"
5713 "Route map reference\n"
5714 "Pointer to route-map entries\n")
5715{
5716 int type = -1;
5717
5718 /* Get metric type. */
5719 if (argc >= 1)
5720 if (!str2metric_type (argv[0], &type))
5721 return CMD_WARNING;
5722
5723 if (argc == 2)
5724 ospf_routemap_set (DEFAULT_ROUTE, argv[1]);
5725 else
5726 ospf_routemap_unset (DEFAULT_ROUTE);
5727
5728 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ZEBRA, type, -1);
5729}
5730
5731DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5732 ospf_default_information_originate_always_metric_type_routemap_cmd,
5733 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5734 "Control distribution of default information\n"
5735 "Distribute a default route\n"
5736 "Always advertise default route\n"
5737 "OSPF default metric\n"
5738 "OSPF metric\n"
5739 "OSPF metric type for default routes\n"
5740 "Set OSPF External Type 1 metrics\n"
5741 "Set OSPF External Type 2 metrics\n"
5742 "Route map reference\n"
5743 "Pointer to route-map entries\n")
5744{
5745 int type = -1;
5746 int metric = -1;
5747
5748 /* Get metric value. */
5749 if (argc >= 1)
5750 if (!str2metric (argv[0], &metric))
5751 return CMD_WARNING;
5752
5753 /* Get metric type. */
5754 if (argc >= 2)
5755 if (!str2metric_type (argv[1], &type))
5756 return CMD_WARNING;
5757
5758 if (argc == 3)
5759 ospf_routemap_set (DEFAULT_ROUTE, argv[2]);
5760 else
5761 ospf_routemap_unset (DEFAULT_ROUTE);
5762
5763 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS,
5764 type, metric);
5765}
5766
5767ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5768 ospf_default_information_originate_always_metric_type_cmd,
5769 "default-information originate always metric <0-16777214> metric-type (1|2)",
5770 "Control distribution of default information\n"
5771 "Distribute a default route\n"
5772 "Always advertise default route\n"
5773 "OSPF default metric\n"
5774 "OSPF metric\n"
5775 "OSPF metric type for default routes\n"
5776 "Set OSPF External Type 1 metrics\n"
5777 "Set OSPF External Type 2 metrics\n")
5778
5779ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5780 ospf_default_information_originate_always_metric_cmd,
5781 "default-information originate always metric <0-16777214>",
5782 "Control distribution of default information\n"
5783 "Distribute a default route\n"
5784 "Always advertise default route\n"
5785 "OSPF default metric\n"
5786 "OSPF metric\n"
5787 "OSPF metric type for default routes\n")
5788
5789ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5790 ospf_default_information_originate_always_cmd,
5791 "default-information originate always",
5792 "Control distribution of default information\n"
5793 "Distribute a default route\n"
5794 "Always advertise default route\n")
5795
5796DEFUN (ospf_default_information_originate_always_metric_routemap,
5797 ospf_default_information_originate_always_metric_routemap_cmd,
5798 "default-information originate always metric <0-16777214> route-map WORD",
5799 "Control distribution of default information\n"
5800 "Distribute a default route\n"
5801 "Always advertise default route\n"
5802 "OSPF default metric\n"
5803 "OSPF metric\n"
5804 "Route map reference\n"
5805 "Pointer to route-map entries\n")
5806{
5807 int metric = -1;
5808
5809 /* Get metric value. */
5810 if (argc >= 1)
5811 if (!str2metric (argv[0], &metric))
5812 return CMD_WARNING;
5813
5814 if (argc == 2)
5815 ospf_routemap_set (DEFAULT_ROUTE, argv[1]);
5816 else
5817 ospf_routemap_unset (DEFAULT_ROUTE);
5818
5819 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS, -1, metric);
5820}
5821
5822DEFUN (ospf_default_information_originate_always_routemap,
5823 ospf_default_information_originate_always_routemap_cmd,
5824 "default-information originate always route-map WORD",
5825 "Control distribution of default information\n"
5826 "Distribute a default route\n"
5827 "Always advertise default route\n"
5828 "Route map reference\n"
5829 "Pointer to route-map entries\n")
5830{
5831 if (argc == 1)
5832 ospf_routemap_set (DEFAULT_ROUTE, argv[0]);
5833 else
5834 ospf_routemap_unset (DEFAULT_ROUTE);
5835
5836 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS, -1, -1);
5837}
5838
5839DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5840 ospf_default_information_originate_always_type_metric_routemap_cmd,
5841 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5842 "Control distribution of default information\n"
5843 "Distribute a default route\n"
5844 "Always advertise default route\n"
5845 "OSPF metric type for default routes\n"
5846 "Set OSPF External Type 1 metrics\n"
5847 "Set OSPF External Type 2 metrics\n"
5848 "OSPF default metric\n"
5849 "OSPF metric\n"
5850 "Route map reference\n"
5851 "Pointer to route-map entries\n")
5852{
5853 int type = -1;
5854 int metric = -1;
5855
5856 /* Get metric type. */
5857 if (argc >= 1)
5858 if (!str2metric_type (argv[0], &type))
5859 return CMD_WARNING;
5860
5861 /* Get metric value. */
5862 if (argc >= 2)
5863 if (!str2metric (argv[1], &metric))
5864 return CMD_WARNING;
5865
5866 if (argc == 3)
5867 ospf_routemap_set (DEFAULT_ROUTE, argv[2]);
5868 else
5869 ospf_routemap_unset (DEFAULT_ROUTE);
5870
5871 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS,
5872 type, metric);
5873}
5874
5875ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5876 ospf_default_information_originate_always_type_metric_cmd,
5877 "default-information originate always metric-type (1|2) metric <0-16777214>",
5878 "Control distribution of default information\n"
5879 "Distribute a default route\n"
5880 "Always advertise default route\n"
5881 "OSPF metric type for default routes\n"
5882 "Set OSPF External Type 1 metrics\n"
5883 "Set OSPF External Type 2 metrics\n"
5884 "OSPF default metric\n"
5885 "OSPF metric\n")
5886
5887ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5888 ospf_default_information_originate_always_type_cmd,
5889 "default-information originate always metric-type (1|2)",
5890 "Control distribution of default information\n"
5891 "Distribute a default route\n"
5892 "Always advertise default route\n"
5893 "OSPF metric type for default routes\n"
5894 "Set OSPF External Type 1 metrics\n"
5895 "Set OSPF External Type 2 metrics\n")
5896
5897DEFUN (ospf_default_information_originate_always_type_routemap,
5898 ospf_default_information_originate_always_type_routemap_cmd,
5899 "default-information originate always metric-type (1|2) route-map WORD",
5900 "Control distribution of default information\n"
5901 "Distribute a default route\n"
5902 "Always advertise default route\n"
5903 "OSPF metric type for default routes\n"
5904 "Set OSPF External Type 1 metrics\n"
5905 "Set OSPF External Type 2 metrics\n"
5906 "Route map reference\n"
5907 "Pointer to route-map entries\n")
5908{
5909 int type = -1;
5910
5911 /* Get metric type. */
5912 if (argc >= 1)
5913 if (!str2metric_type (argv[0], &type))
5914 return CMD_WARNING;
5915
5916 if (argc == 2)
5917 ospf_routemap_set (DEFAULT_ROUTE, argv[1]);
5918 else
5919 ospf_routemap_unset (DEFAULT_ROUTE);
5920
5921 return ospf_redistribute_default_set (DEFAULT_ORIGINATE_ALWAYS,
5922 type, -1);
5923}
5924
5925DEFUN (no_ospf_default_information_originate,
5926 no_ospf_default_information_originate_cmd,
5927 "no default-information originate",
5928 NO_STR
5929 "Control distribution of default information\n"
5930 "Distribute a default route\n")
5931{
5932 struct prefix_ipv4 p;
5933 struct in_addr nexthop;
5934
5935 p.family = AF_INET;
5936 p.prefix.s_addr = 0;
5937 p.prefixlen = 0;
5938
5939 ospf_external_lsa_flush (DEFAULT_ROUTE, &p, 0, nexthop);
5940
5941 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
5942 ospf_external_info_delete (DEFAULT_ROUTE, p);
5943 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
5944 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
5945 }
5946
5947 ospf_routemap_unset (DEFAULT_ROUTE);
5948 return ospf_redistribute_default_unset ();
5949}
5950
5951DEFUN (ospf_default_metric,
5952 ospf_default_metric_cmd,
5953 "default-metric <0-16777214>",
5954 "Set metric of redistributed routes\n"
5955 "Default metric\n")
5956{
5957 int metric = -1;
5958
5959 if (!str2metric (argv[0], &metric))
5960 return CMD_WARNING;
5961
5962 ospf_top->default_metric = metric;
5963
5964 return CMD_SUCCESS;
5965}
5966
5967DEFUN (no_ospf_default_metric,
5968 no_ospf_default_metric_cmd,
5969 "no default-metric",
5970 NO_STR
5971 "Set metric of redistributed routes\n")
5972{
5973 ospf_top->default_metric = -1;
5974 return CMD_SUCCESS;
5975}
5976
5977ALIAS (no_ospf_default_metric,
5978 no_ospf_default_metric_val_cmd,
5979 "no default-metric <0-16777214>",
5980 NO_STR
5981 "Set metric of redistributed routes\n"
5982 "Default metric\n")
5983
5984DEFUN (ospf_distance,
5985 ospf_distance_cmd,
5986 "distance <1-255>",
5987 "Define an administrative distance\n"
5988 "OSPF Administrative distance\n")
5989{
5990 ospf_top->distance_all = atoi (argv[0]);
5991 return CMD_SUCCESS;
5992}
5993
5994DEFUN (no_ospf_distance,
5995 no_ospf_distance_cmd,
5996 "no distance <1-255>",
5997 NO_STR
5998 "Define an administrative distance\n"
5999 "OSPF Administrative distance\n")
6000{
6001 ospf_top->distance_all = 0;
6002 return CMD_SUCCESS;
6003}
6004
6005DEFUN (no_ospf_distance_ospf,
6006 no_ospf_distance_ospf_cmd,
6007 "no distance ospf",
6008 NO_STR
6009 "Define an administrative distance\n"
6010 "OSPF Administrative distance\n"
6011 "OSPF Distance\n")
6012{
6013 ospf_top->distance_intra = 0;
6014 ospf_top->distance_inter = 0;
6015 ospf_top->distance_external = 0;
6016 return CMD_SUCCESS;
6017}
6018
6019DEFUN (ospf_distance_ospf_intra,
6020 ospf_distance_ospf_intra_cmd,
6021 "distance ospf intra-area <1-255>",
6022 "Define an administrative distance\n"
6023 "OSPF Administrative distance\n"
6024 "Intra-area routes\n"
6025 "Distance for intra-area routes\n")
6026{
6027 ospf_top->distance_intra = atoi (argv[0]);
6028 return CMD_SUCCESS;
6029}
6030
6031DEFUN (ospf_distance_ospf_intra_inter,
6032 ospf_distance_ospf_intra_inter_cmd,
6033 "distance ospf intra-area <1-255> inter-area <1-255>",
6034 "Define an administrative distance\n"
6035 "OSPF Administrative distance\n"
6036 "Intra-area routes\n"
6037 "Distance for intra-area routes\n"
6038 "Inter-area routes\n"
6039 "Distance for inter-area routes\n")
6040{
6041 ospf_top->distance_intra = atoi (argv[0]);
6042 ospf_top->distance_inter = atoi (argv[1]);
6043 return CMD_SUCCESS;
6044}
6045
6046DEFUN (ospf_distance_ospf_intra_external,
6047 ospf_distance_ospf_intra_external_cmd,
6048 "distance ospf intra-area <1-255> external <1-255>",
6049 "Define an administrative distance\n"
6050 "OSPF Administrative distance\n"
6051 "Intra-area routes\n"
6052 "Distance for intra-area routes\n"
6053 "External routes\n"
6054 "Distance for external routes\n")
6055{
6056 ospf_top->distance_intra = atoi (argv[0]);
6057 ospf_top->distance_external = atoi (argv[1]);
6058 return CMD_SUCCESS;
6059}
6060
6061DEFUN (ospf_distance_ospf_intra_inter_external,
6062 ospf_distance_ospf_intra_inter_external_cmd,
6063 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6064 "Define an administrative distance\n"
6065 "OSPF Administrative distance\n"
6066 "Intra-area routes\n"
6067 "Distance for intra-area routes\n"
6068 "Inter-area routes\n"
6069 "Distance for inter-area routes\n"
6070 "External routes\n"
6071 "Distance for external routes\n")
6072{
6073 ospf_top->distance_intra = atoi (argv[0]);
6074 ospf_top->distance_inter = atoi (argv[1]);
6075 ospf_top->distance_external = atoi (argv[2]);
6076 return CMD_SUCCESS;
6077}
6078
6079DEFUN (ospf_distance_ospf_intra_external_inter,
6080 ospf_distance_ospf_intra_external_inter_cmd,
6081 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6082 "Define an administrative distance\n"
6083 "OSPF Administrative distance\n"
6084 "Intra-area routes\n"
6085 "Distance for intra-area routes\n"
6086 "External routes\n"
6087 "Distance for external routes\n"
6088 "Inter-area routes\n"
6089 "Distance for inter-area routes\n")
6090{
6091 ospf_top->distance_intra = atoi (argv[0]);
6092 ospf_top->distance_external = atoi (argv[1]);
6093 ospf_top->distance_inter = atoi (argv[2]);
6094 return CMD_SUCCESS;
6095}
6096
6097DEFUN (ospf_distance_ospf_inter,
6098 ospf_distance_ospf_inter_cmd,
6099 "distance ospf inter-area <1-255>",
6100 "Define an administrative distance\n"
6101 "OSPF Administrative distance\n"
6102 "Inter-area routes\n"
6103 "Distance for inter-area routes\n")
6104{
6105 ospf_top->distance_inter = atoi (argv[0]);
6106 return CMD_SUCCESS;
6107}
6108
6109DEFUN (ospf_distance_ospf_inter_intra,
6110 ospf_distance_ospf_inter_intra_cmd,
6111 "distance ospf inter-area <1-255> intra-area <1-255>",
6112 "Define an administrative distance\n"
6113 "OSPF Administrative distance\n"
6114 "Inter-area routes\n"
6115 "Distance for inter-area routes\n"
6116 "Intra-area routes\n"
6117 "Distance for intra-area routes\n")
6118{
6119 ospf_top->distance_inter = atoi (argv[0]);
6120 ospf_top->distance_intra = atoi (argv[1]);
6121 return CMD_SUCCESS;
6122}
6123
6124DEFUN (ospf_distance_ospf_inter_external,
6125 ospf_distance_ospf_inter_external_cmd,
6126 "distance ospf inter-area <1-255> external <1-255>",
6127 "Define an administrative distance\n"
6128 "OSPF Administrative distance\n"
6129 "Inter-area routes\n"
6130 "Distance for inter-area routes\n"
6131 "External routes\n"
6132 "Distance for external routes\n")
6133{
6134 ospf_top->distance_inter = atoi (argv[0]);
6135 ospf_top->distance_external = atoi (argv[1]);
6136 return CMD_SUCCESS;
6137}
6138
6139DEFUN (ospf_distance_ospf_inter_intra_external,
6140 ospf_distance_ospf_inter_intra_external_cmd,
6141 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6142 "Define an administrative distance\n"
6143 "OSPF Administrative distance\n"
6144 "Inter-area routes\n"
6145 "Distance for inter-area routes\n"
6146 "Intra-area routes\n"
6147 "Distance for intra-area routes\n"
6148 "External routes\n"
6149 "Distance for external routes\n")
6150{
6151 ospf_top->distance_inter = atoi (argv[0]);
6152 ospf_top->distance_intra = atoi (argv[1]);
6153 ospf_top->distance_external = atoi (argv[2]);
6154 return CMD_SUCCESS;
6155}
6156
6157DEFUN (ospf_distance_ospf_inter_external_intra,
6158 ospf_distance_ospf_inter_external_intra_cmd,
6159 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6160 "Define an administrative distance\n"
6161 "OSPF Administrative distance\n"
6162 "Inter-area routes\n"
6163 "Distance for inter-area routes\n"
6164 "External routes\n"
6165 "Distance for external routes\n"
6166 "Intra-area routes\n"
6167 "Distance for intra-area routes\n")
6168{
6169 ospf_top->distance_inter = atoi (argv[0]);
6170 ospf_top->distance_external = atoi (argv[1]);
6171 ospf_top->distance_intra = atoi (argv[2]);
6172 return CMD_SUCCESS;
6173}
6174
6175DEFUN (ospf_distance_ospf_external,
6176 ospf_distance_ospf_external_cmd,
6177 "distance ospf external <1-255>",
6178 "Define an administrative distance\n"
6179 "OSPF Administrative distance\n"
6180 "External routes\n"
6181 "Distance for external routes\n")
6182{
6183 ospf_top->distance_external = atoi (argv[0]);
6184 return CMD_SUCCESS;
6185}
6186
6187DEFUN (ospf_distance_ospf_external_intra,
6188 ospf_distance_ospf_external_intra_cmd,
6189 "distance ospf external <1-255> intra-area <1-255>",
6190 "Define an administrative distance\n"
6191 "OSPF Administrative distance\n"
6192 "External routes\n"
6193 "Distance for external routes\n"
6194 "Intra-area routes\n"
6195 "Distance for intra-area routes\n")
6196{
6197 ospf_top->distance_external = atoi (argv[0]);
6198 ospf_top->distance_intra = atoi (argv[1]);
6199 return CMD_SUCCESS;
6200}
6201
6202DEFUN (ospf_distance_ospf_external_inter,
6203 ospf_distance_ospf_external_inter_cmd,
6204 "distance ospf external <1-255> inter-area <1-255>",
6205 "Define an administrative distance\n"
6206 "OSPF Administrative distance\n"
6207 "External routes\n"
6208 "Distance for external routes\n"
6209 "Inter-area routes\n"
6210 "Distance for inter-area routes\n")
6211{
6212 ospf_top->distance_external = atoi (argv[0]);
6213 ospf_top->distance_inter = atoi (argv[1]);
6214 return CMD_SUCCESS;
6215}
6216
6217DEFUN (ospf_distance_ospf_external_intra_inter,
6218 ospf_distance_ospf_external_intra_inter_cmd,
6219 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6220 "Define an administrative distance\n"
6221 "OSPF Administrative distance\n"
6222 "External routes\n"
6223 "Distance for external routes\n"
6224 "Intra-area routes\n"
6225 "Distance for intra-area routes\n"
6226 "Inter-area routes\n"
6227 "Distance for inter-area routes\n")
6228{
6229 ospf_top->distance_external = atoi (argv[0]);
6230 ospf_top->distance_intra = atoi (argv[1]);
6231 ospf_top->distance_inter = atoi (argv[2]);
6232 return CMD_SUCCESS;
6233}
6234
6235DEFUN (ospf_distance_ospf_external_inter_intra,
6236 ospf_distance_ospf_external_inter_intra_cmd,
6237 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6238 "Define an administrative distance\n"
6239 "OSPF Administrative distance\n"
6240 "External routes\n"
6241 "Distance for external routes\n"
6242 "Inter-area routes\n"
6243 "Distance for inter-area routes\n"
6244 "Intra-area routes\n"
6245 "Distance for intra-area routes\n")
6246{
6247 ospf_top->distance_external = atoi (argv[0]);
6248 ospf_top->distance_inter = atoi (argv[1]);
6249 ospf_top->distance_intra = atoi (argv[2]);
6250 return CMD_SUCCESS;
6251}
6252
6253DEFUN (ospf_distance_source,
6254 ospf_distance_source_cmd,
6255 "distance <1-255> A.B.C.D/M",
6256 "Administrative distance\n"
6257 "Distance value\n"
6258 "IP source prefix\n")
6259{
6260 ospf_distance_set (vty, argv[0], argv[1], NULL);
6261 return CMD_SUCCESS;
6262}
6263
6264DEFUN (no_ospf_distance_source,
6265 no_ospf_distance_source_cmd,
6266 "no distance <1-255> A.B.C.D/M",
6267 NO_STR
6268 "Administrative distance\n"
6269 "Distance value\n"
6270 "IP source prefix\n")
6271{
6272 ospf_distance_unset (vty, argv[0], argv[1], NULL);
6273 return CMD_SUCCESS;
6274}
6275
6276DEFUN (ospf_distance_source_access_list,
6277 ospf_distance_source_access_list_cmd,
6278 "distance <1-255> A.B.C.D/M WORD",
6279 "Administrative distance\n"
6280 "Distance value\n"
6281 "IP source prefix\n"
6282 "Access list name\n")
6283{
6284 ospf_distance_set (vty, argv[0], argv[1], argv[2]);
6285 return CMD_SUCCESS;
6286}
6287
6288DEFUN (no_ospf_distance_source_access_list,
6289 no_ospf_distance_source_access_list_cmd,
6290 "no distance <1-255> A.B.C.D/M WORD",
6291 NO_STR
6292 "Administrative distance\n"
6293 "Distance value\n"
6294 "IP source prefix\n"
6295 "Access list name\n")
6296{
6297 ospf_distance_unset (vty, argv[0], argv[1], argv[2]);
6298 return CMD_SUCCESS;
6299}
6300
6301void
6302show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6303{
6304 struct route_node *rn;
6305 struct ospf_route *or;
6306 listnode pnode;
6307 struct ospf_path *path;
6308
6309 vty_out (vty, "============ OSPF network routing table ============%s",
6310 VTY_NEWLINE);
6311
6312 for (rn = route_top (rt); rn; rn = route_next (rn))
6313 if ((or = rn->info) != NULL)
6314 {
6315 char buf1[19];
6316 snprintf (buf1, 19, "%s/%d",
6317 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6318
6319 switch (or->path_type)
6320 {
6321 case OSPF_PATH_INTER_AREA:
6322 if (or->type == OSPF_DESTINATION_NETWORK)
6323 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6324 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6325 else if (or->type == OSPF_DESTINATION_DISCARD)
6326 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6327 break;
6328 case OSPF_PATH_INTRA_AREA:
6329 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6330 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6331 break;
6332 default:
6333 break;
6334 }
6335
6336 if (or->type == OSPF_DESTINATION_NETWORK)
6337 for (pnode = listhead (or->path); pnode; nextnode (pnode))
6338 {
6339 path = getdata (pnode);
6340 if (path->oi != NULL)
6341 {
6342 if (path->nexthop.s_addr == 0)
6343 vty_out (vty, "%24s directly attached to %s%s",
6344 "", path->oi->ifp->name, VTY_NEWLINE);
6345 else
6346 vty_out (vty, "%24s via %s, %s%s", "",
6347 inet_ntoa (path->nexthop), path->oi->ifp->name,
6348 VTY_NEWLINE);
6349 }
6350 }
6351 }
6352 vty_out (vty, "%s", VTY_NEWLINE);
6353}
6354
6355void
6356show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6357{
6358 struct route_node *rn;
6359 struct ospf_route *or;
6360 listnode pn, nn;
6361 struct ospf_path *path;
6362
6363 vty_out (vty, "============ OSPF router routing table =============%s",
6364 VTY_NEWLINE);
6365 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6366 if (rn->info)
6367 {
6368 int flag = 0;
6369
6370 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6371
6372 for (nn = listhead ((list) rn->info); nn; nextnode (nn))
6373 if ((or = getdata (nn)) != NULL)
6374 {
6375 if (flag++)
6376 vty_out(vty," " );
6377
6378 /* Show path. */
6379 vty_out (vty, "%s [%d] area: %s",
6380 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6381 or->cost, inet_ntoa (or->u.std.area_id));
6382 /* Show flags. */
6383 vty_out (vty, "%s%s%s",
6384 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6385 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6386 VTY_NEWLINE);
6387
6388 for (pn = listhead (or->path); pn; nextnode (pn))
6389 {
6390 path = getdata (pn);
6391 if (path->nexthop.s_addr == 0)
6392 vty_out (vty, "%24s directly attached to %s%s",
6393 "", path->oi->ifp->name, VTY_NEWLINE);
6394 else
6395 vty_out (vty, "%24s via %s, %s%s", "",
6396 inet_ntoa (path->nexthop), path->oi->ifp->name,
6397 VTY_NEWLINE);
6398 }
6399 }
6400 }
6401 vty_out (vty, "%s", VTY_NEWLINE);
6402}
6403
6404void
6405show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6406{
6407 struct route_node *rn;
6408 struct ospf_route *er;
6409 listnode pnode;
6410 struct ospf_path *path;
6411
6412 vty_out (vty, "============ OSPF external routing table ===========%s",
6413 VTY_NEWLINE);
6414 for (rn = route_top (rt); rn; rn = route_next (rn))
6415 if ((er = rn->info) != NULL)
6416 {
6417 char buf1[19];
6418 snprintf (buf1, 19, "%s/%d",
6419 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6420
6421 switch (er->path_type)
6422 {
6423 case OSPF_PATH_TYPE1_EXTERNAL:
6424 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6425 er->cost, er->u.ext.tag, VTY_NEWLINE);
6426 break;
6427 case OSPF_PATH_TYPE2_EXTERNAL:
6428 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6429 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6430 break;
6431 }
6432
6433 for (pnode = listhead (er->path); pnode; nextnode (pnode))
6434 {
6435 path = getdata (pnode);
6436 if (path->oi != NULL)
6437 {
6438 if (path->nexthop.s_addr == 0)
6439 vty_out (vty, "%24s directly attached to %s%s",
6440 "", path->oi->ifp->name, VTY_NEWLINE);
6441 else
6442 vty_out (vty, "%24s via %s, %s%s", "",
6443 inet_ntoa (path->nexthop), path->oi->ifp->name,
6444 VTY_NEWLINE);
6445 }
6446 }
6447 }
6448 vty_out (vty, "%s", VTY_NEWLINE);
6449}
6450
6451#ifdef HAVE_NSSA
6452DEFUN (show_ip_ospf_border_routers,
6453 show_ip_ospf_border_routers_cmd,
6454 "show ip ospf border-routers",
6455 SHOW_STR
6456 IP_STR
6457 "show all the ABR's and ASBR's\n"
6458 "for this area\n")
6459{
6460 if (ospf_top == NULL)
6461 {
6462 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6463 return CMD_SUCCESS;
6464 }
6465
6466 if (ospf_top->new_table == NULL)
6467 {
6468 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6469 return CMD_SUCCESS;
6470 }
6471
6472 /* Show Network routes.
6473 show_ip_ospf_route_network (vty, ospf_top->new_table); */
6474
6475 /* Show Router routes. */
6476 show_ip_ospf_route_router (vty, ospf_top->new_rtrs);
6477
6478 return CMD_SUCCESS;
6479}
6480#endif /* HAVE_NSSA */
6481
6482DEFUN (show_ip_ospf_route,
6483 show_ip_ospf_route_cmd,
6484 "show ip ospf route",
6485 SHOW_STR
6486 IP_STR
6487 "OSPF information\n"
6488 "OSPF routing table\n")
6489{
6490 if (ospf_top == NULL)
6491 {
6492 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6493 return CMD_SUCCESS;
6494 }
6495
6496 if (ospf_top->new_table == NULL)
6497 {
6498 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6499 return CMD_SUCCESS;
6500 }
6501
6502 /* Show Network routes. */
6503 show_ip_ospf_route_network (vty, ospf_top->new_table);
6504
6505 /* Show Router routes. */
6506 show_ip_ospf_route_router (vty, ospf_top->new_rtrs);
6507
6508 /* Show AS External routes. */
6509 show_ip_ospf_route_external (vty, ospf_top->old_external_route);
6510
6511 return CMD_SUCCESS;
6512}
6513
6514
6515char *ospf_abr_type_str[] =
6516{
6517 "unknown",
6518 "standard",
6519 "ibm",
6520 "cisco",
6521 "shortcut"
6522};
6523
6524char *ospf_shortcut_mode_str[] =
6525{
6526 "default",
6527 "enable",
6528 "disable"
6529};
6530
6531
6532void
6533area_id2str (char *buf, int length, struct ospf_area *area)
6534{
6535 memset (buf, 0, length);
6536
6537 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6538 strncpy (buf, inet_ntoa (area->area_id), length);
6539 else
6540 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6541}
6542
6543
6544char *ospf_int_type_str[] =
6545{
6546 "unknown", /* should never be used. */
6547 "point-to-point",
6548 "broadcast",
6549 "non-broadcast",
6550 "point-to-multipoint",
6551 "virtual-link", /* should never be used. */
6552 "loopback"
6553};
6554
6555/* Configuration write function for ospfd. */
6556int
6557config_write_interface (struct vty *vty)
6558{
6559 listnode n1, n2;
6560 struct interface *ifp;
6561 struct crypt_key *ck;
6562 int write = 0;
6563 struct route_node *rn = NULL;
6564 struct ospf_if_params *params;
6565
6566 for (n1 = listhead (iflist); n1; nextnode (n1))
6567 {
6568 ifp = getdata (n1);
6569
6570 if (memcmp (ifp->name, "VLINK", 5) == 0)
6571 continue;
6572
6573 vty_out (vty, "!%s", VTY_NEWLINE);
6574 vty_out (vty, "interface %s%s", ifp->name,
6575 VTY_NEWLINE);
6576 if (ifp->desc)
6577 vty_out (vty, " description %s%s", ifp->desc,
6578 VTY_NEWLINE);
6579
6580 write++;
6581
6582 params = IF_DEF_PARAMS (ifp);
6583
6584 do {
6585 /* Interface Network print. */
6586 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
6587 params->type != OSPF_IFTYPE_BROADCAST &&
6588 params->type != OSPF_IFTYPE_LOOPBACK)
6589 {
6590 vty_out (vty, " ip ospf network %s",
6591 ospf_int_type_str[params->type]);
6592 if (params != IF_DEF_PARAMS (ifp))
6593 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6594 vty_out (vty, "%s", VTY_NEWLINE);
6595 }
6596
6597 /* OSPF interface authentication print */
6598 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6599 params->auth_type != OSPF_AUTH_NOTSET)
6600 {
6601 char *auth_str;
6602
6603 /* Translation tables are not that much help here due to syntax
6604 of the simple option */
6605 switch (params->auth_type)
6606 {
6607
6608 case OSPF_AUTH_NULL:
6609 auth_str = " null";
6610 break;
6611
6612 case OSPF_AUTH_SIMPLE:
6613 auth_str = "";
6614 break;
6615
6616 case OSPF_AUTH_CRYPTOGRAPHIC:
6617 auth_str = " message-digest";
6618 break;
6619
6620 default:
6621 auth_str = "";
6622 break;
6623 }
6624
6625 vty_out (vty, " ip ospf authentication%s", auth_str);
6626 if (params != IF_DEF_PARAMS (ifp))
6627 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6628 vty_out (vty, "%s", VTY_NEWLINE);
6629 }
6630
6631 /* Simple Authentication Password print. */
6632 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6633 params->auth_simple[0] != '\0')
6634 {
6635 vty_out (vty, " ip ospf authentication-key %s",
6636 params->auth_simple);
6637 if (params != IF_DEF_PARAMS (ifp))
6638 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6639 vty_out (vty, "%s", VTY_NEWLINE);
6640 }
6641
6642 /* Cryptographic Authentication Key print. */
6643 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
6644 {
6645 ck = getdata (n2);
6646 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6647 ck->key_id, ck->auth_key);
6648 if (params != IF_DEF_PARAMS (ifp))
6649 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6650 vty_out (vty, "%s", VTY_NEWLINE);
6651 }
6652
6653 /* Interface Output Cost print. */
6654 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6655 {
6656 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6657 if (params != IF_DEF_PARAMS (ifp))
6658 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6659 vty_out (vty, "%s", VTY_NEWLINE);
6660 }
6661
6662 /* Hello Interval print. */
6663 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6664 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6665 {
6666 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6667 if (params != IF_DEF_PARAMS (ifp))
6668 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6669 vty_out (vty, "%s", VTY_NEWLINE);
6670 }
6671
6672
6673 /* Router Dead Interval print. */
6674 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6675 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6676 {
6677 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6678 if (params != IF_DEF_PARAMS (ifp))
6679 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6680 vty_out (vty, "%s", VTY_NEWLINE);
6681 }
6682
6683 /* Router Priority print. */
6684 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6685 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6686 {
6687 vty_out (vty, " ip ospf priority %u", params->priority);
6688 if (params != IF_DEF_PARAMS (ifp))
6689 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6690 vty_out (vty, "%s", VTY_NEWLINE);
6691 }
6692
6693 /* Retransmit Interval print. */
6694 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6695 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6696 {
6697 vty_out (vty, " ip ospf retransmit-interval %u",
6698 params->retransmit_interval);
6699 if (params != IF_DEF_PARAMS (ifp))
6700 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6701 vty_out (vty, "%s", VTY_NEWLINE);
6702 }
6703
6704 /* Transmit Delay print. */
6705 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6706 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6707 {
6708 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6709 if (params != IF_DEF_PARAMS (ifp))
6710 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6711 vty_out (vty, "%s", VTY_NEWLINE);
6712 }
6713
6714 while (1)
6715 {
6716 if (rn == NULL)
6717 rn = route_top (IF_OIFS_PARAMS (ifp));
6718 else
6719 rn = route_next (rn);
6720
6721 if (rn == NULL)
6722 break;
6723 params = rn->info;
6724 if (params != NULL)
6725 break;
6726 }
6727 } while (rn);
6728
6729#ifdef HAVE_OPAQUE_LSA
6730 ospf_opaque_config_write_if (vty, ifp);
6731#endif /* HAVE_OPAQUE_LSA */
6732 }
6733
6734 return write;
6735}
6736
6737int
6738config_write_network_area (struct vty *vty)
6739{
6740 struct route_node *rn;
6741 u_char buf[INET_ADDRSTRLEN];
6742
6743 /* `network area' print. */
6744 for (rn = route_top (ospf_top->networks); rn; rn = route_next (rn))
6745 if (rn->info)
6746 {
6747 struct ospf_network *n = rn->info;
6748
6749 memset (buf, 0, INET_ADDRSTRLEN);
6750
6751 /* Create Area ID string by specified Area ID format. */
6752 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6753 strncpy (buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
6754 else
6755 sprintf (buf, "%lu",
6756 (unsigned long int) ntohl (n->area_id.s_addr));
6757
6758 /* Network print. */
6759 vty_out (vty, " network %s/%d area %s%s",
6760 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6761 buf, VTY_NEWLINE);
6762 }
6763
6764 return 0;
6765}
6766
6767int
6768config_write_ospf_area (struct vty *vty)
6769{
6770 listnode node;
6771 u_char buf[INET_ADDRSTRLEN];
6772
6773 /* Area configuration print. */
6774 for (node = listhead (ospf_top->areas); node; nextnode (node))
6775 {
6776 struct ospf_area *area = getdata (node);
6777 struct route_node *rn1;
6778
6779 area_id2str (buf, INET_ADDRSTRLEN, area);
6780
6781 if (area->auth_type != OSPF_AUTH_NULL)
6782 {
6783 if (area->auth_type == OSPF_AUTH_SIMPLE)
6784 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6785 else
6786 vty_out (vty, " area %s authentication message-digest%s",
6787 buf, VTY_NEWLINE);
6788 }
6789
6790 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6791 vty_out (vty, " area %s shortcut %s%s", buf,
6792 ospf_shortcut_mode_str[area->shortcut_configured],
6793 VTY_NEWLINE);
6794
6795 if ((area->external_routing == OSPF_AREA_STUB)
6796#ifdef HAVE_NSSA
6797 || (area->external_routing == OSPF_AREA_NSSA)
6798#endif /* HAVE_NSSA */
6799 )
6800 {
6801#ifdef HAVE_NSSA
6802 if (area->external_routing == OSPF_AREA_NSSA)
6803 vty_out (vty, " area %s nssa", buf);
6804 else
6805#endif /* HAVE_NSSA */
6806 vty_out (vty, " area %s stub", buf);
6807
6808 if (area->no_summary)
6809 vty_out (vty, " no-summary");
6810
6811 vty_out (vty, "%s", VTY_NEWLINE);
6812
6813 if (area->default_cost != 1)
6814 vty_out (vty, " area %s default-cost %d%s", buf,
6815 area->default_cost, VTY_NEWLINE);
6816 }
6817
6818 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
6819 if (rn1->info)
6820 {
6821 struct ospf_area_range *range = rn1->info;
6822
6823 vty_out (vty, " area %s range %s/%d", buf,
6824 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
6825
6826 if (range->cost_config != -1)
6827 vty_out (vty, " cost %d", range->cost_config);
6828
6829 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
6830 vty_out (vty, " not-advertise");
6831
6832 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
6833 vty_out (vty, " substitute %s/%d",
6834 inet_ntoa (range->subst_addr), range->subst_masklen);
6835
6836 vty_out (vty, "%s", VTY_NEWLINE);
6837 }
6838
6839 if (EXPORT_NAME (area))
6840 vty_out (vty, " area %s export-list %s%s", buf,
6841 EXPORT_NAME (area), VTY_NEWLINE);
6842
6843 if (IMPORT_NAME (area))
6844 vty_out (vty, " area %s import-list %s%s", buf,
6845 IMPORT_NAME (area), VTY_NEWLINE);
6846
6847 if (PREFIX_NAME_IN (area))
6848 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
6849 PREFIX_NAME_IN (area), VTY_NEWLINE);
6850
6851 if (PREFIX_NAME_OUT (area))
6852 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
6853 PREFIX_NAME_OUT (area), VTY_NEWLINE);
6854 }
6855
6856 return 0;
6857}
6858
6859int
6860config_write_ospf_nbr_nbma (struct vty *vty)
6861{
6862 struct ospf_nbr_nbma *nbr_nbma;
6863 struct route_node *rn;
6864
6865 /* Static Neighbor configuration print. */
6866 for (rn = route_top (ospf_top->nbr_nbma); rn; rn = route_next (rn))
6867 if ((nbr_nbma = rn->info))
6868 {
6869 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
6870
6871 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
6872 vty_out (vty, " priority %d", nbr_nbma->priority);
6873
6874 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
6875 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
6876
6877 vty_out (vty, "%s", VTY_NEWLINE);
6878 }
6879
6880 return 0;
6881}
6882
6883int
6884config_write_virtual_link (struct vty *vty)
6885{
6886 listnode node;
6887 u_char buf[INET_ADDRSTRLEN];
6888
6889 /* Virtual-Link print */
6890 for (node = listhead (ospf_top->vlinks); node; nextnode (node))
6891 {
6892 listnode n2;
6893 struct crypt_key *ck;
6894 struct ospf_vl_data *vl_data = getdata (node);
6895 struct ospf_interface *oi;
6896
6897 if (vl_data != NULL)
6898 {
6899 memset (buf, 0, INET_ADDRSTRLEN);
6900
6901 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6902 strncpy (buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
6903 else
6904 sprintf (buf, "%lu",
6905 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
6906 oi = vl_data->vl_oi;
6907
6908 /* timers */
6909 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
6910 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
6911 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
6912 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
6913 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
6914 buf,
6915 inet_ntoa (vl_data->vl_peer),
6916 OSPF_IF_PARAM (oi, v_hello),
6917 OSPF_IF_PARAM (oi, retransmit_interval),
6918 OSPF_IF_PARAM (oi, transmit_delay),
6919 OSPF_IF_PARAM (oi, v_wait),
6920 VTY_NEWLINE);
6921 else
6922 vty_out (vty, " area %s virtual-link %s%s", buf,
6923 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
6924 /* Auth key */
6925 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
6926 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
6927 buf,
6928 inet_ntoa (vl_data->vl_peer),
6929 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
6930 VTY_NEWLINE);
6931 /* md5 keys */
6932 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
6933 {
6934 ck = getdata (n2);
6935 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
6936 buf,
6937 inet_ntoa (vl_data->vl_peer),
6938 ck->key_id, ck->auth_key, VTY_NEWLINE);
6939 }
6940
6941 }
6942 }
6943
6944 return 0;
6945}
6946
6947
6948char *distribute_str[] = { "system", "kernel", "connected", "static", "rip",
6949 "ripng", "ospf", "ospf6", "bgp"};
6950int
6951config_write_ospf_redistribute (struct vty *vty)
6952{
6953 int type;
6954
6955 /* redistribute print. */
6956 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
6957 if (type != zclient->redist_default && zclient->redist[type])
6958 {
6959 vty_out (vty, " redistribute %s", distribute_str[type]);
6960 if (ospf_top->dmetric[type].value >= 0)
6961 vty_out (vty, " metric %d", ospf_top->dmetric[type].value);
6962
6963 if (ospf_top->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
6964 vty_out (vty, " metric-type 1");
6965
6966 if (ROUTEMAP_NAME (type))
6967 vty_out (vty, " route-map %s", ROUTEMAP_NAME (type));
6968
6969 vty_out (vty, "%s", VTY_NEWLINE);
6970 }
6971
6972 return 0;
6973}
6974
6975int
6976config_write_ospf_default_metric (struct vty *vty)
6977{
6978 if (ospf_top->default_metric != -1)
6979 vty_out (vty, " default-metric %d%s", ospf_top->default_metric,
6980 VTY_NEWLINE);
6981 return 0;
6982}
6983
6984int
6985config_write_ospf_distribute (struct vty *vty)
6986{
6987 int type;
6988
6989 if (ospf_top)
6990 {
6991 /* distribute-list print. */
6992 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
6993 if (ospf_top->dlist[type].name)
6994 vty_out (vty, " distribute-list %s out %s%s",
6995 ospf_top->dlist[type].name,
6996 distribute_str[type], VTY_NEWLINE);
6997
6998 /* default-information print. */
6999 if (ospf_top->default_originate != DEFAULT_ORIGINATE_NONE)
7000 {
7001 if (ospf_top->default_originate == DEFAULT_ORIGINATE_ZEBRA)
7002 vty_out (vty, " default-information originate");
7003 else
7004 vty_out (vty, " default-information originate always");
7005
7006 if (ospf_top->dmetric[DEFAULT_ROUTE].value >= 0)
7007 vty_out (vty, " metric %d",
7008 ospf_top->dmetric[DEFAULT_ROUTE].value);
7009 if (ospf_top->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
7010 vty_out (vty, " metric-type 1");
7011
7012 if (ROUTEMAP_NAME (DEFAULT_ROUTE))
7013 vty_out (vty, " route-map %s", ROUTEMAP_NAME (DEFAULT_ROUTE));
7014
7015 vty_out (vty, "%s", VTY_NEWLINE);
7016 }
7017
7018 }
7019
7020 return 0;
7021}
7022
7023int
7024config_write_ospf_distance (struct vty *vty)
7025{
7026 struct route_node *rn;
7027 struct ospf_distance *odistance;
7028
7029 if (ospf_top->distance_all)
7030 vty_out (vty, " distance %d%s", ospf_top->distance_all, VTY_NEWLINE);
7031
7032 if (ospf_top->distance_intra
7033 || ospf_top->distance_inter
7034 || ospf_top->distance_external)
7035 {
7036 vty_out (vty, " distance ospf");
7037
7038 if (ospf_top->distance_intra)
7039 vty_out (vty, " intra-area %d", ospf_top->distance_intra);
7040 if (ospf_top->distance_inter)
7041 vty_out (vty, " inter-area %d", ospf_top->distance_inter);
7042 if (ospf_top->distance_external)
7043 vty_out (vty, " external %d", ospf_top->distance_external);
7044
7045 vty_out (vty, "%s", VTY_NEWLINE);
7046 }
7047
7048 for (rn = route_top (ospf_top->distance_table); rn; rn = route_next (rn))
7049 if ((odistance = rn->info) != NULL)
7050 {
7051 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7052 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7053 odistance->access_list ? odistance->access_list : "",
7054 VTY_NEWLINE);
7055 }
7056 return 0;
7057}
7058
7059/* OSPF configuration write function. */
7060int
7061ospf_config_write (struct vty *vty)
7062{
7063 listnode node;
7064 int write = 0;
7065
7066 if (ospf_top != NULL)
7067 {
7068 /* `router ospf' print. */
7069 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7070
7071 write++;
7072
7073 if (!ospf_top->networks)
7074 return write;
7075
7076 /* Router ID print. */
7077 if (ospf_top->router_id_static.s_addr != 0)
7078 vty_out (vty, " ospf router-id %s%s",
7079 inet_ntoa (ospf_top->router_id_static), VTY_NEWLINE);
7080
7081 /* ABR type print. */
7082 if (ospf_top->abr_type != OSPF_ABR_STAND)
7083 vty_out (vty, " ospf abr-type %s%s",
7084 ospf_abr_type_str[ospf_top->abr_type], VTY_NEWLINE);
7085
7086 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
7087 if (CHECK_FLAG (ospf_top->config, OSPF_RFC1583_COMPATIBLE))
7088 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7089
7090 /* auto-cost reference-bandwidth configuration. */
7091 if (ospf_top->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
7092 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7093 ospf_top->ref_bandwidth / 1000, VTY_NEWLINE);
7094
7095 /* SPF timers print. */
7096 if (ospf_top->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7097 ospf_top->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
7098 vty_out (vty, " timers spf %d %d%s",
7099 ospf_top->spf_delay, ospf_top->spf_holdtime, VTY_NEWLINE);
7100
7101 /* SPF refresh parameters print. */
7102 if (ospf_top->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
7103 vty_out (vty, " refresh timer %d%s",
7104 ospf_top->lsa_refresh_interval, VTY_NEWLINE);
7105
7106 /* Redistribute information print. */
7107 config_write_ospf_redistribute (vty);
7108
7109 /* passive-interface print. */
7110 for (node = listhead (ospf_top->iflist); node; nextnode (node))
7111 {
7112 struct interface *ifp = getdata (node);
7113
7114 if (!ifp)
7115 continue;
7116 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7117 vty_out (vty, " passive-interface %s%s",
7118 ifp->name, VTY_NEWLINE);
7119 }
7120
7121 for (node = listhead (ospf_top->oiflist); node; nextnode (node))
7122 {
7123 struct ospf_interface *oi = getdata (node);
7124
7125 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7126 oi->params->passive_interface == OSPF_IF_PASSIVE)
7127 vty_out (vty, " passive-interface %s%s",
7128 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
7129 }
7130
7131
7132 /* Network area print. */
7133 config_write_network_area (vty);
7134
7135 /* Area config print. */
7136 config_write_ospf_area (vty);
7137
7138 /* static neighbor print. */
7139 config_write_ospf_nbr_nbma (vty);
7140
7141 /* Virtual-Link print. */
7142 config_write_virtual_link (vty);
7143
7144 /* Default metric configuration. */
7145 config_write_ospf_default_metric (vty);
7146
7147 /* Distribute-list and default-information print. */
7148 config_write_ospf_distribute (vty);
7149
7150 /* Distance configuration. */
7151 config_write_ospf_distance (vty);
7152
7153#ifdef HAVE_OPAQUE_LSA
7154 ospf_opaque_config_write_router (vty, ospf_top);
7155#endif /* HAVE_OPAQUE_LSA */
7156 }
7157
7158 return write;
7159}
7160
7161void
7162ospf_vty_show_init ()
7163{
7164 /* "show ip ospf" commands. */
7165 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7166 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7167
7168 /* "show ip ospf database" commands. */
7169 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7170 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7171 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7172 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7173 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7174 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7175 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7176 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7177 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7178 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7179 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7180 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7181 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7182 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7183
7184 /* "show ip ospf interface" commands. */
7185 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7186 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7187
7188 /* "show ip ospf neighbor" commands. */
7189 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7190 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7191 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7192 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7193 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7194 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7195 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7196 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7197 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7198 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7199 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7200 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7201 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7202 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7203
7204 /* "show ip ospf route" commands. */
7205 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7206 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
7207#ifdef HAVE_NSSA
7208 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7209 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
7210#endif /* HAVE_NSSA */
7211}
7212
7213
7214/* ospfd's interface node. */
7215struct cmd_node interface_node =
7216{
7217 INTERFACE_NODE,
7218 "%s(config-if)# ",
7219 1
7220};
7221
7222/* Initialization of OSPF interface. */
7223void
7224ospf_vty_if_init ()
7225{
7226 /* Install interface node. */
7227 install_node (&interface_node, config_write_interface);
7228
7229 install_element (CONFIG_NODE, &interface_cmd);
7230 install_default (INTERFACE_NODE);
7231
7232 /* "description" commands. */
7233 install_element (INTERFACE_NODE, &interface_desc_cmd);
7234 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7235
7236 /* "ip ospf authentication" commands. */
7237 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7238 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7239 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7240 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7241 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7242 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7243 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7244 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7245 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7246 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7247
7248 /* "ip ospf message-digest-key" commands. */
7249 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7250 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7251 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7252 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7253
7254 /* "ip ospf cost" commands. */
7255 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7256 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7257 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7258 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7259
7260 /* "ip ospf dead-interval" commands. */
7261 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7262 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7263 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7264 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7265
7266 /* "ip ospf hello-interval" commands. */
7267 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7268 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7269 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7270 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7271
7272 /* "ip ospf network" commands. */
7273 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7274 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7275
7276 /* "ip ospf priority" commands. */
7277 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7278 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7279 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7280 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7281
7282 /* "ip ospf retransmit-interval" commands. */
7283 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7284 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7285 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7286 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7287
7288 /* "ip ospf transmit-delay" commands. */
7289 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7290 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7291 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7292 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7293
7294 /* These commands are compatibitliy for previous version. */
7295 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7296 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7297 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7298 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7299 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7300 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7301 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7302 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7303 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7304 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7305 install_element (INTERFACE_NODE, &ospf_network_cmd);
7306 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7307 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7308 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7309 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7310 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7311 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7312 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7313}
7314
7315/* Zebra node structure. */
7316struct cmd_node zebra_node =
7317{
7318 ZEBRA_NODE,
7319 "%s(config-router)#",
7320};
7321
7322void
7323ospf_vty_zebra_init ()
7324{
7325 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7326 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7327 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7328 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7329 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7330 install_element (OSPF_NODE,
7331 &ospf_redistribute_source_metric_type_routemap_cmd);
7332 install_element (OSPF_NODE,
7333 &ospf_redistribute_source_type_metric_routemap_cmd);
7334 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7335 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7336 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7337
7338 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7339
7340 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7341 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7342
7343 install_element (OSPF_NODE,
7344 &ospf_default_information_originate_metric_type_cmd);
7345 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7346 install_element (OSPF_NODE,
7347 &ospf_default_information_originate_type_metric_cmd);
7348 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7349 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7350 install_element (OSPF_NODE,
7351 &ospf_default_information_originate_always_metric_type_cmd);
7352 install_element (OSPF_NODE,
7353 &ospf_default_information_originate_always_metric_cmd);
7354 install_element (OSPF_NODE,
7355 &ospf_default_information_originate_always_cmd);
7356 install_element (OSPF_NODE,
7357 &ospf_default_information_originate_always_type_metric_cmd);
7358 install_element (OSPF_NODE,
7359 &ospf_default_information_originate_always_type_cmd);
7360
7361 install_element (OSPF_NODE,
7362 &ospf_default_information_originate_metric_type_routemap_cmd);
7363 install_element (OSPF_NODE,
7364 &ospf_default_information_originate_metric_routemap_cmd);
7365 install_element (OSPF_NODE,
7366 &ospf_default_information_originate_routemap_cmd);
7367 install_element (OSPF_NODE,
7368 &ospf_default_information_originate_type_metric_routemap_cmd);
7369 install_element (OSPF_NODE,
7370 &ospf_default_information_originate_type_routemap_cmd);
7371 install_element (OSPF_NODE,
7372 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7373 install_element (OSPF_NODE,
7374 &ospf_default_information_originate_always_metric_routemap_cmd);
7375 install_element (OSPF_NODE,
7376 &ospf_default_information_originate_always_routemap_cmd);
7377 install_element (OSPF_NODE,
7378 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7379 install_element (OSPF_NODE,
7380 &ospf_default_information_originate_always_type_routemap_cmd);
7381
7382 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7383
7384 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7385 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7386 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7387
7388 install_element (OSPF_NODE, &ospf_distance_cmd);
7389 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7390 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7391 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7392 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7393 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7394 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7395 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7396 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7397 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7398 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7399 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7400 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7401 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7402 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7403 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7404 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7405 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7406#if 0
7407 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7408 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7409 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7410 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7411#endif /* 0 */
7412}
7413
7414struct cmd_node ospf_node =
7415{
7416 OSPF_NODE,
7417 "%s(config-router)# ",
7418 1
7419};
7420
7421
7422/* Install OSPF related vty commands. */
7423void
7424ospf_vty_init ()
7425{
7426 /* Install ospf top node. */
7427 install_node (&ospf_node, ospf_config_write);
7428
7429 /* "router ospf" commands. */
7430 install_element (CONFIG_NODE, &router_ospf_cmd);
7431 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7432
7433 install_default (OSPF_NODE);
7434
7435 /* "ospf router-id" commands. */
7436 install_element (OSPF_NODE, &ospf_router_id_cmd);
7437 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
7438 install_element (OSPF_NODE, &router_id_cmd);
7439 install_element (OSPF_NODE, &no_router_id_cmd);
7440
7441 /* "passive-interface" commands. */
7442 install_element (OSPF_NODE, &passive_interface_addr_cmd);
7443 install_element (OSPF_NODE, &passive_interface_cmd);
7444 install_element (OSPF_NODE, &no_passive_interface_addr_cmd);
7445 install_element (OSPF_NODE, &no_passive_interface_cmd);
7446
7447 /* "ospf abr-type" commands. */
7448 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7449 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7450
7451 /* "ospf rfc1583-compatible" commands. */
7452 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7453 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7454 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7455 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7456
7457 /* "network area" commands. */
7458 install_element (OSPF_NODE, &network_area_cmd);
7459 install_element (OSPF_NODE, &no_network_area_cmd);
7460
7461 /* "area authentication" commands. */
7462 install_element (OSPF_NODE, &area_authentication_message_digest_cmd);
7463 install_element (OSPF_NODE, &area_authentication_cmd);
7464 install_element (OSPF_NODE, &no_area_authentication_cmd);
7465
7466 /* "area range" commands. */
7467 install_element (OSPF_NODE, &area_range_cmd);
7468 install_element (OSPF_NODE, &area_range_advertise_cmd);
7469 install_element (OSPF_NODE, &area_range_cost_cmd);
7470 install_element (OSPF_NODE, &area_range_advertise_cost_cmd);
7471 install_element (OSPF_NODE, &area_range_not_advertise_cmd);
7472 install_element (OSPF_NODE, &no_area_range_cmd);
7473 install_element (OSPF_NODE, &no_area_range_advertise_cmd);
7474 install_element (OSPF_NODE, &no_area_range_cost_cmd);
7475 install_element (OSPF_NODE, &no_area_range_advertise_cost_cmd);
7476 install_element (OSPF_NODE, &area_range_substitute_cmd);
7477 install_element (OSPF_NODE, &no_area_range_substitute_cmd);
7478
7479 /* "area virtual-link" commands. */
7480 install_element (OSPF_NODE, &area_vlink_cmd);
7481 install_element (OSPF_NODE, &no_area_vlink_cmd);
7482
7483 install_element (OSPF_NODE, &area_vlink_param1_cmd);
7484 install_element (OSPF_NODE, &no_area_vlink_param1_cmd);
7485
7486 install_element (OSPF_NODE, &area_vlink_param2_cmd);
7487 install_element (OSPF_NODE, &no_area_vlink_param2_cmd);
7488
7489 install_element (OSPF_NODE, &area_vlink_param3_cmd);
7490 install_element (OSPF_NODE, &no_area_vlink_param3_cmd);
7491
7492 install_element (OSPF_NODE, &area_vlink_param4_cmd);
7493 install_element (OSPF_NODE, &no_area_vlink_param4_cmd);
7494
7495 install_element (OSPF_NODE, &area_vlink_authtype_args_cmd);
7496 install_element (OSPF_NODE, &area_vlink_authtype_cmd);
7497 install_element (OSPF_NODE, &no_area_vlink_authtype_cmd);
7498
7499 install_element (OSPF_NODE, &area_vlink_md5_cmd);
7500 install_element (OSPF_NODE, &no_area_vlink_md5_cmd);
7501
7502 install_element (OSPF_NODE, &area_vlink_authkey_cmd);
7503 install_element (OSPF_NODE, &no_area_vlink_authkey_cmd);
7504
7505 install_element (OSPF_NODE, &area_vlink_authtype_args_authkey_cmd);
7506 install_element (OSPF_NODE, &area_vlink_authtype_authkey_cmd);
7507 install_element (OSPF_NODE, &no_area_vlink_authtype_authkey_cmd);
7508
7509 install_element (OSPF_NODE, &area_vlink_authtype_args_md5_cmd);
7510 install_element (OSPF_NODE, &area_vlink_authtype_md5_cmd);
7511 install_element (OSPF_NODE, &no_area_vlink_authtype_md5_cmd);
7512
7513 /* "area stub" commands. */
7514 install_element (OSPF_NODE, &area_stub_no_summary_cmd);
7515 install_element (OSPF_NODE, &area_stub_cmd);
7516 install_element (OSPF_NODE, &no_area_stub_no_summary_cmd);
7517 install_element (OSPF_NODE, &no_area_stub_cmd);
7518
7519#ifdef HAVE_NSSA
7520 /* "area nssa" commands. */
7521 install_element (OSPF_NODE, &area_nssa_cmd);
7522 install_element (OSPF_NODE, &area_nssa_translate_no_summary_cmd);
7523 install_element (OSPF_NODE, &area_nssa_translate_cmd);
7524 install_element (OSPF_NODE, &area_nssa_no_summary_cmd);
7525 install_element (OSPF_NODE, &no_area_nssa_cmd);
7526 install_element (OSPF_NODE, &no_area_nssa_no_summary_cmd);
7527#endif /* HAVE_NSSA */
7528
7529 install_element (OSPF_NODE, &area_default_cost_cmd);
7530 install_element (OSPF_NODE, &no_area_default_cost_cmd);
7531
7532 install_element (OSPF_NODE, &area_shortcut_cmd);
7533 install_element (OSPF_NODE, &no_area_shortcut_cmd);
7534
7535 install_element (OSPF_NODE, &area_export_list_cmd);
7536 install_element (OSPF_NODE, &no_area_export_list_cmd);
7537
7538 install_element (OSPF_NODE, &area_filter_list_cmd);
7539 install_element (OSPF_NODE, &no_area_filter_list_cmd);
7540
7541 install_element (OSPF_NODE, &area_import_list_cmd);
7542 install_element (OSPF_NODE, &no_area_import_list_cmd);
7543
7544 install_element (OSPF_NODE, &timers_spf_cmd);
7545 install_element (OSPF_NODE, &no_timers_spf_cmd);
7546
7547 install_element (OSPF_NODE, &refresh_timer_cmd);
7548 install_element (OSPF_NODE, &no_refresh_timer_val_cmd);
7549 install_element (OSPF_NODE, &no_refresh_timer_cmd);
7550
7551 install_element (OSPF_NODE, &auto_cost_reference_bandwidth_cmd);
7552 install_element (OSPF_NODE, &no_auto_cost_reference_bandwidth_cmd);
7553
7554 /* "neighbor" commands. */
7555 install_element (OSPF_NODE, &neighbor_cmd);
7556 install_element (OSPF_NODE, &neighbor_priority_poll_interval_cmd);
7557 install_element (OSPF_NODE, &neighbor_priority_cmd);
7558 install_element (OSPF_NODE, &neighbor_poll_interval_cmd);
7559 install_element (OSPF_NODE, &neighbor_poll_interval_priority_cmd);
7560 install_element (OSPF_NODE, &no_neighbor_cmd);
7561 install_element (OSPF_NODE, &no_neighbor_priority_cmd);
7562 install_element (OSPF_NODE, &no_neighbor_poll_interval_cmd);
7563
7564 /* Init interface related vty commands. */
7565 ospf_vty_if_init ();
7566
7567 /* Init zebra related vty commands. */
7568 ospf_vty_zebra_init ();
7569}
7570