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