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