blob: 2b2c000e6bfec3870b6adb82d5590a3a3af5d573 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* OSPF VTY interface.
2 * Copyright (C) 2000 Toshiaki Takada
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22#include <zebra.h>
23
24#include "memory.h"
25#include "thread.h"
26#include "prefix.h"
27#include "table.h"
28#include "vty.h"
29#include "command.h"
30#include "plist.h"
31#include "log.h"
32#include "zclient.h"
33
34#include "ospfd/ospfd.h"
35#include "ospfd/ospf_asbr.h"
36#include "ospfd/ospf_lsa.h"
37#include "ospfd/ospf_lsdb.h"
38#include "ospfd/ospf_ism.h"
39#include "ospfd/ospf_interface.h"
40#include "ospfd/ospf_nsm.h"
41#include "ospfd/ospf_neighbor.h"
42#include "ospfd/ospf_flood.h"
43#include "ospfd/ospf_abr.h"
44#include "ospfd/ospf_spf.h"
45#include "ospfd/ospf_route.h"
46#include "ospfd/ospf_zebra.h"
47/*#include "ospfd/ospf_routemap.h" */
48#include "ospfd/ospf_vty.h"
49#include "ospfd/ospf_dump.h"
50
51
52static char *ospf_network_type_str[] =
53{
54 "Null",
55 "POINTOPOINT",
56 "BROADCAST",
57 "NBMA",
58 "POINTOMULTIPOINT",
59 "VIRTUALLINK",
60 "LOOPBACK"
61};
62
63
64/* Utility functions. */
65int
66ospf_str2area_id (char *str, struct in_addr *area_id, int *format)
67{
68 char *endptr = NULL;
69 unsigned long ret;
70
71 /* match "A.B.C.D". */
72 if (strchr (str, '.') != NULL)
73 {
74 ret = inet_aton (str, area_id);
75 if (!ret)
76 return -1;
77 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
78 }
79 /* match "<0-4294967295>". */
80 else
81 {
82 ret = strtoul (str, &endptr, 10);
83 if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE))
84 return -1;
85
86 area_id->s_addr = htonl (ret);
87 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
88 }
89
90 return 0;
91}
92
93
94int
95str2distribute_source (char *str, int *source)
96{
97 /* Sanity check. */
98 if (str == NULL)
99 return 0;
100
101 if (strncmp (str, "k", 1) == 0)
102 *source = ZEBRA_ROUTE_KERNEL;
103 else if (strncmp (str, "c", 1) == 0)
104 *source = ZEBRA_ROUTE_CONNECT;
105 else if (strncmp (str, "s", 1) == 0)
106 *source = ZEBRA_ROUTE_STATIC;
107 else if (strncmp (str, "r", 1) == 0)
108 *source = ZEBRA_ROUTE_RIP;
109 else if (strncmp (str, "b", 1) == 0)
110 *source = ZEBRA_ROUTE_BGP;
111 else
112 return 0;
113
114 return 1;
115}
116
117int
118str2metric (char *str, int *metric)
119{
120 /* Sanity check. */
121 if (str == NULL)
122 return 0;
123
124 *metric = strtol (str, NULL, 10);
125 if (*metric < 0 && *metric > 16777214)
126 {
127 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
128 return 0;
129 }
130
131 return 1;
132}
133
134int
135str2metric_type (char *str, int *metric_type)
136{
137 /* Sanity check. */
138 if (str == NULL)
139 return 0;
140
141 if (strncmp (str, "1", 1) == 0)
142 *metric_type = EXTERNAL_METRIC_TYPE_1;
143 else if (strncmp (str, "2", 1) == 0)
144 *metric_type = EXTERNAL_METRIC_TYPE_2;
145 else
146 return 0;
147
148 return 1;
149}
150
151int
152ospf_oi_count (struct interface *ifp)
153{
154 struct route_node *rn;
155 int i = 0;
156
157 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
158 if (rn->info)
159 i++;
160
161 return i;
162}
163
164
165DEFUN (router_ospf,
166 router_ospf_cmd,
167 "router ospf",
168 "Enable a routing process\n"
169 "Start OSPF configuration\n")
170{
171 vty->node = OSPF_NODE;
172 vty->index = ospf_get ();
173
174 return CMD_SUCCESS;
175}
176
177DEFUN (no_router_ospf,
178 no_router_ospf_cmd,
179 "no router ospf",
180 NO_STR
181 "Enable a routing process\n"
182 "Start OSPF configuration\n")
183{
paul020709f2003-04-04 02:44:16 +0000184 struct ospf *ospf;
185
186 ospf = ospf_lookup ();
187 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000188 {
paul020709f2003-04-04 02:44:16 +0000189 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000190 return CMD_WARNING;
191 }
192
paul020709f2003-04-04 02:44:16 +0000193 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000194
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{
paul68980082003-03-25 05:07:42 +0000205 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000206 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000207 int ret;
paul718e3742002-12-13 20:15:29 +0000208
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
paul68980082003-03-25 05:07:42 +0000216 ospf->router_id_static = router_id;
paul718e3742002-12-13 20:15:29 +0000217
paul68980082003-03-25 05:07:42 +0000218 if (ospf->t_router_id_update == NULL)
paul020709f2003-04-04 02:44:16 +0000219 OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer,
220 OSPF_ROUTER_ID_UPDATE_DELAY);
paul718e3742002-12-13 20:15:29 +0000221
222 return CMD_SUCCESS;
223}
224
225ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000226 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000227 "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{
paul68980082003-03-25 05:07:42 +0000238 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000239
paul68980082003-03-25 05:07:42 +0000240 ospf->router_id_static.s_addr = 0;
241
242 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000243
244 return CMD_SUCCESS;
245}
246
247ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000248 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000249 "no router-id",
250 NO_STR
251 "router-id for the OSPF process\n")
252
paula2c62832003-04-23 17:01:31 +0000253DEFUN (ospf_passive_interface,
254 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000255 "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
paula2c62832003-04-23 17:01:31 +0000294ALIAS (ospf_passive_interface,
295 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000296 "passive-interface IFNAME",
297 "Suppress routing updates on an interface\n"
298 "Interface's name\n")
299
paula2c62832003-04-23 17:01:31 +0000300DEFUN (no_ospf_passive_interface,
301 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000302 "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
paula2c62832003-04-23 17:01:31 +0000349ALIAS (no_ospf_passive_interface,
350 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000351 "no passive-interface IFNAME",
352 NO_STR
353 "Allow routing updates on an interface\n"
354 "Interface's name\n")
355
paula2c62832003-04-23 17:01:31 +0000356DEFUN (ospf_network_area,
357 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000358 "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
paula2c62832003-04-23 17:01:31 +0000384DEFUN (no_ospf_network_area,
385 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000386 "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
paula2c62832003-04-23 17:01:31 +0000415DEFUN (ospf_area_range,
416 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000417 "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
paula2c62832003-04-23 17:01:31 +0000443ALIAS (ospf_area_range,
444 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000445 "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
paula2c62832003-04-23 17:01:31 +0000453ALIAS (ospf_area_range,
454 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000455 "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
paula2c62832003-04-23 17:01:31 +0000464ALIAS (ospf_area_range,
465 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000466 "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
paula2c62832003-04-23 17:01:31 +0000476DEFUN (ospf_area_range_not_advertise,
477 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000478 "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
paula2c62832003-04-23 17:01:31 +0000499DEFUN (no_ospf_area_range,
500 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000501 "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
paula2c62832003-04-23 17:01:31 +0000522ALIAS (no_ospf_area_range,
523 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000524 "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
paula2c62832003-04-23 17:01:31 +0000534ALIAS (no_ospf_area_range,
535 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000536 "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
paula2c62832003-04-23 17:01:31 +0000546ALIAS (no_ospf_area_range,
547 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000548 "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
paula2c62832003-04-23 17:01:31 +0000559DEFUN (ospf_area_range_substitute,
560 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000561 "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
paula2c62832003-04-23 17:01:31 +0000584DEFUN (no_ospf_area_range_substitute,
585 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000586 "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
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 *
paul68980082003-03-25 05:07:42 +0000654ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000655{
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 }
paul68980082003-03-25 05:07:42 +0000671 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000672
673 if (area->external_routing != OSPF_AREA_DEFAULT)
674 {
675 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
676 vty_out (vty, "Area %s is %s%s",
677 inet_ntoa (area_id),
678#ifdef HAVE_NSSA
679 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
680#else
681 "stub",
682#endif /* HAVE_NSSA */
683 VTY_NEWLINE);
684 else
685 vty_out (vty, "Area %ld is %s%s",
686 (u_long)ntohl (area_id.s_addr),
687#ifdef HAVE_NSSA
688 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
689#else
690 "stub",
691#endif /* HAVE_NSSA */
692 VTY_NEWLINE);
693 return NULL;
694 }
695
696 if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)
697 {
698 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
699 if (vl_data->vl_oi == NULL)
700 {
paul68980082003-03-25 05:07:42 +0000701 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
702 ospf_vl_add (ospf, vl_data);
703 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000704 }
705 }
706 return vl_data;
707}
708
709
710int
711ospf_vl_set_security (struct ospf_vl_data *vl_data,
712 struct ospf_vl_config_data *vl_config)
713{
714 struct crypt_key *ck;
715 struct vty *vty;
716 struct interface *ifp = vl_data->vl_oi->ifp;
717
718 vty = vl_config->vty;
719
720 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
721 {
722 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
723 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
724 }
725
726 if (vl_config->auth_key)
727 {
728 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
729 strncpy (IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
730 OSPF_AUTH_SIMPLE_SIZE);
731 }
732 else if (vl_config->md5_key)
733 {
734 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
735 != NULL)
736 {
737 vty_out (vty, "OSPF: Key %d already exists%s",
738 vl_config->crypto_key_id, VTY_NEWLINE);
739 return CMD_WARNING;
740 }
741 ck = ospf_crypt_key_new ();
742 ck->key_id = vl_config->crypto_key_id;
743 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
744 strncpy (ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
745
746 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
747 }
748 else if (vl_config->crypto_key_id != 0)
749 {
750 /* Delete a key */
751
752 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
753 vl_config->crypto_key_id) == NULL)
754 {
755 vty_out (vty, "OSPF: Key %d does not exist%s",
756 vl_config->crypto_key_id, VTY_NEWLINE);
757 return CMD_WARNING;
758 }
759
760 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
761
762 }
763
764 return CMD_SUCCESS;
765}
766
767
768
769int
770ospf_vl_set_timers (struct ospf_vl_data *vl_data,
771 struct ospf_vl_config_data *vl_config)
772{
773 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
774 /* Virtual Link data initialised to defaults, so only set
775 if a value given */
776 if (vl_config->hello_interval)
777 {
778 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
779 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
780 }
781
782 if (vl_config->dead_interval)
783 {
784 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
785 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
786 }
787
788 if (vl_config->retransmit_interval)
789 {
790 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
791 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
792 }
793
794 if (vl_config->transmit_delay)
795 {
796 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
797 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
798 }
799
800 return CMD_SUCCESS;
801}
802
803
804
805/* The business end of all of the above */
806int
paul68980082003-03-25 05:07:42 +0000807ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000808{
809 struct ospf_vl_data *vl_data;
810 int ret;
811
paul68980082003-03-25 05:07:42 +0000812 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000813 if (!vl_data)
814 return CMD_WARNING;
815
816 /* Process this one first as it can have a fatal result, which can
817 only logically occur if the virtual link exists already
818 Thus a command error does not result in a change to the
819 running configuration such as unexpectedly altered timer
820 values etc.*/
821 ret = ospf_vl_set_security (vl_data, vl_config);
822 if (ret != CMD_SUCCESS)
823 return ret;
824
825 /* Set any time based parameters, these area already range checked */
826
827 ret = ospf_vl_set_timers (vl_data, vl_config);
828 if (ret != CMD_SUCCESS)
829 return ret;
830
831 return CMD_SUCCESS;
832
833}
834
835/* This stuff exists to make specifying all the alias commands A LOT simpler
836 */
837#define VLINK_HELPSTR_IPADDR \
838 "OSPF area parameters\n" \
839 "OSPF area ID in IP address format\n" \
840 "OSPF area ID as a decimal value\n" \
841 "Configure a virtual link\n" \
842 "Router ID of the remote ABR\n"
843
844#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
845 "Enable authentication on this virtual link\n" \
846 "dummy string \n"
847
848#define VLINK_HELPSTR_AUTHTYPE_ALL \
849 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
850 "Use null authentication\n" \
851 "Use message-digest authentication\n"
852
853#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
854 "Time between HELLO packets\n" \
855 "Time between retransmitting lost link state advertisements\n" \
856 "Link state transmit delay\n" \
857 "Interval after which a neighbor is declared dead\n"
858
859#define VLINK_HELPSTR_TIME_PARAM \
860 VLINK_HELPSTR_TIME_PARAM_NOSECS \
861 "Seconds\n"
862
863#define VLINK_HELPSTR_AUTH_SIMPLE \
864 "Authentication password (key)\n" \
865 "The OSPF password (key)"
866
867#define VLINK_HELPSTR_AUTH_MD5 \
868 "Message digest authentication password (key)\n" \
869 "dummy string \n" \
870 "Key ID\n" \
871 "Use MD5 algorithm\n" \
872 "The OSPF password (key)"
873
paula2c62832003-04-23 17:01:31 +0000874DEFUN (ospf_area_vlink,
875 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000876 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
877 VLINK_HELPSTR_IPADDR)
878{
paul68980082003-03-25 05:07:42 +0000879 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000880 struct ospf_vl_config_data vl_config;
881 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
882 char md5_key[OSPF_AUTH_MD5_SIZE+1];
883 int i;
884 int ret;
885
886 ospf_vl_config_data_init(&vl_config, vty);
887
888 /* Read off first 2 parameters and check them */
889 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
890 if (ret < 0)
891 {
892 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
893 return CMD_WARNING;
894 }
895
896 ret = inet_aton (argv[1], &vl_config.vl_peer);
897 if (! ret)
898 {
899 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
900 VTY_NEWLINE);
901 return CMD_WARNING;
902 }
903
904 if (argc <=2)
905 {
906 /* Thats all folks! - BUGS B. strikes again!!!*/
907
paul68980082003-03-25 05:07:42 +0000908 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000909 }
910
911 /* Deal with other parameters */
912 for (i=2; i < argc; i++)
913 {
914
915 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
916
917 switch (argv[i][0])
918 {
919
920 case 'a':
921 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
922 {
923 /* authentication-key - this option can occur anywhere on
924 command line. At start of command line
925 must check for authentication option. */
926 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
927 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
928 vl_config.auth_key = auth_key;
929 i++;
930 }
931 else if (strncmp (argv[i], "authentication", 14) == 0)
932 {
933 /* authentication - this option can only occur at start
934 of command line */
935 vl_config.auth_type = OSPF_AUTH_SIMPLE;
936 if ((i+1) < argc)
937 {
938 if (strncmp (argv[i+1], "n", 1) == 0)
939 {
940 /* "authentication null" */
941 vl_config.auth_type = OSPF_AUTH_NULL;
942 i++;
943 }
944 else if (strncmp (argv[i+1], "m", 1) == 0
945 && strcmp (argv[i+1], "message-digest-") != 0)
946 {
947 /* "authentication message-digest" */
948 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
949 i++;
950 }
951 }
952 }
953 break;
954
955 case 'm':
956 /* message-digest-key */
957 i++;
958 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
959 if (vl_config.crypto_key_id < 0)
960 return CMD_WARNING;
961 i++;
962 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
963 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
964 vl_config.md5_key = md5_key;
965 break;
966
967 case 'h':
968 /* Hello interval */
969 i++;
970 vl_config.hello_interval = strtol (argv[i], NULL, 10);
971 if (vl_config.hello_interval < 0)
972 return CMD_WARNING;
973 break;
974
975 case 'r':
976 /* Retransmit Interval */
977 i++;
978 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
979 if (vl_config.retransmit_interval < 0)
980 return CMD_WARNING;
981 break;
982
983 case 't':
984 /* Transmit Delay */
985 i++;
986 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
987 if (vl_config.transmit_delay < 0)
988 return CMD_WARNING;
989 break;
990
991 case 'd':
992 /* Dead Interval */
993 i++;
994 vl_config.dead_interval = strtol (argv[i], NULL, 10);
995 if (vl_config.dead_interval < 0)
996 return CMD_WARNING;
997 break;
998 }
999 }
1000
1001
1002 /* Action configuration */
1003
paul68980082003-03-25 05:07:42 +00001004 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001005
1006}
1007
paula2c62832003-04-23 17:01:31 +00001008DEFUN (no_ospf_area_vlink,
1009 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001010 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1011 NO_STR
1012 VLINK_HELPSTR_IPADDR)
1013{
paul68980082003-03-25 05:07:42 +00001014 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001015 struct ospf_area *area;
1016 struct ospf_vl_config_data vl_config;
1017 struct ospf_vl_data *vl_data = NULL;
1018 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1019 int i;
1020 int ret, format;
1021
1022 ospf_vl_config_data_init(&vl_config, vty);
1023
1024 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1025 if (ret < 0)
1026 {
1027 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1028 return CMD_WARNING;
1029 }
1030
paul68980082003-03-25 05:07:42 +00001031 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001032 if (!area)
1033 {
1034 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1035 return CMD_WARNING;
1036 }
1037
1038 ret = inet_aton (argv[1], &vl_config.vl_peer);
1039 if (! ret)
1040 {
1041 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1042 VTY_NEWLINE);
1043 return CMD_WARNING;
1044 }
1045
1046 if (argc <=2)
1047 {
1048 /* Basic VLink no command */
1049 /* Thats all folks! - BUGS B. strikes again!!!*/
1050 if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001051 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001052
paul68980082003-03-25 05:07:42 +00001053 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001054
1055 return CMD_SUCCESS;
1056 }
1057
1058 /* If we are down here, we are reseting parameters */
1059
1060 /* Deal with other parameters */
1061 for (i=2; i < argc; i++)
1062 {
paul718e3742002-12-13 20:15:29 +00001063 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1064
1065 switch (argv[i][0])
1066 {
1067
1068 case 'a':
1069 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1070 {
1071 /* authentication-key - this option can occur anywhere on
1072 command line. At start of command line
1073 must check for authentication option. */
1074 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1075 vl_config.auth_key = auth_key;
1076 }
1077 else if (strncmp (argv[i], "authentication", 14) == 0)
1078 {
1079 /* authentication - this option can only occur at start
1080 of command line */
1081 vl_config.auth_type = OSPF_AUTH_NOTSET;
1082 }
1083 break;
1084
1085 case 'm':
1086 /* message-digest-key */
1087 /* Delete one key */
1088 i++;
1089 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1090 if (vl_config.crypto_key_id < 0)
1091 return CMD_WARNING;
1092 vl_config.md5_key = NULL;
1093 break;
1094
1095 case 'h':
1096 /* Hello interval */
1097 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1098 break;
1099
1100 case 'r':
1101 /* Retransmit Interval */
1102 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1103 break;
1104
1105 case 't':
1106 /* Transmit Delay */
1107 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1108 break;
1109
1110 case 'd':
1111 /* Dead Interval */
1112 i++;
1113 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1114 break;
1115 }
1116 }
1117
1118
1119 /* Action configuration */
1120
paul68980082003-03-25 05:07:42 +00001121 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001122}
1123
paula2c62832003-04-23 17:01:31 +00001124ALIAS (ospf_area_vlink,
1125 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001126 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1127 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1128 VLINK_HELPSTR_IPADDR
1129 VLINK_HELPSTR_TIME_PARAM)
1130
paula2c62832003-04-23 17:01:31 +00001131ALIAS (no_ospf_area_vlink,
1132 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001133 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1134 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1135 NO_STR
1136 VLINK_HELPSTR_IPADDR
1137 VLINK_HELPSTR_TIME_PARAM)
1138
paula2c62832003-04-23 17:01:31 +00001139ALIAS (ospf_area_vlink,
1140 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001141 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1142 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1143 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1144 VLINK_HELPSTR_IPADDR
1145 VLINK_HELPSTR_TIME_PARAM
1146 VLINK_HELPSTR_TIME_PARAM)
1147
paula2c62832003-04-23 17:01:31 +00001148ALIAS (no_ospf_area_vlink,
1149 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001150 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1151 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1152 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1153 NO_STR
1154 VLINK_HELPSTR_IPADDR
1155 VLINK_HELPSTR_TIME_PARAM
1156 VLINK_HELPSTR_TIME_PARAM)
1157
paula2c62832003-04-23 17:01:31 +00001158ALIAS (ospf_area_vlink,
1159 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001160 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1161 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1162 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1163 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1164 VLINK_HELPSTR_IPADDR
1165 VLINK_HELPSTR_TIME_PARAM
1166 VLINK_HELPSTR_TIME_PARAM
1167 VLINK_HELPSTR_TIME_PARAM)
1168
paula2c62832003-04-23 17:01:31 +00001169ALIAS (no_ospf_area_vlink,
1170 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001171 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1172 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1173 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1174 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1175 NO_STR
1176 VLINK_HELPSTR_IPADDR
1177 VLINK_HELPSTR_TIME_PARAM
1178 VLINK_HELPSTR_TIME_PARAM
1179 VLINK_HELPSTR_TIME_PARAM)
1180
paula2c62832003-04-23 17:01:31 +00001181ALIAS (ospf_area_vlink,
1182 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001183 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1184 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1185 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1186 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1187 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1188 VLINK_HELPSTR_IPADDR
1189 VLINK_HELPSTR_TIME_PARAM
1190 VLINK_HELPSTR_TIME_PARAM
1191 VLINK_HELPSTR_TIME_PARAM
1192 VLINK_HELPSTR_TIME_PARAM)
1193
paula2c62832003-04-23 17:01:31 +00001194ALIAS (no_ospf_area_vlink,
1195 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001196 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1197 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1198 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1199 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1200 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1201 NO_STR
1202 VLINK_HELPSTR_IPADDR
1203 VLINK_HELPSTR_TIME_PARAM
1204 VLINK_HELPSTR_TIME_PARAM
1205 VLINK_HELPSTR_TIME_PARAM
1206 VLINK_HELPSTR_TIME_PARAM)
1207
paula2c62832003-04-23 17:01:31 +00001208ALIAS (ospf_area_vlink,
1209 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001210 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1211 "(authentication|) (message-digest|null)",
1212 VLINK_HELPSTR_IPADDR
1213 VLINK_HELPSTR_AUTHTYPE_ALL)
1214
paula2c62832003-04-23 17:01:31 +00001215ALIAS (ospf_area_vlink,
1216 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001217 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1218 "(authentication|)",
1219 VLINK_HELPSTR_IPADDR
1220 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1221
paula2c62832003-04-23 17:01:31 +00001222ALIAS (no_ospf_area_vlink,
1223 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001224 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1225 "(authentication|)",
1226 NO_STR
1227 VLINK_HELPSTR_IPADDR
1228 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1229
paula2c62832003-04-23 17:01:31 +00001230ALIAS (ospf_area_vlink,
1231 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001232 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1233 "(message-digest-key|) <1-255> md5 KEY",
1234 VLINK_HELPSTR_IPADDR
1235 VLINK_HELPSTR_AUTH_MD5)
1236
paula2c62832003-04-23 17:01:31 +00001237ALIAS (no_ospf_area_vlink,
1238 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001239 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1240 "(message-digest-key|) <1-255>",
1241 NO_STR
1242 VLINK_HELPSTR_IPADDR
1243 VLINK_HELPSTR_AUTH_MD5)
1244
paula2c62832003-04-23 17:01:31 +00001245ALIAS (ospf_area_vlink,
1246 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001247 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1248 "(authentication-key|) AUTH_KEY",
1249 VLINK_HELPSTR_IPADDR
1250 VLINK_HELPSTR_AUTH_SIMPLE)
1251
paula2c62832003-04-23 17:01:31 +00001252ALIAS (no_ospf_area_vlink,
1253 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001254 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1255 "(authentication-key|)",
1256 NO_STR
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_AUTH_SIMPLE)
1259
paula2c62832003-04-23 17:01:31 +00001260ALIAS (ospf_area_vlink,
1261 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001262 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1263 "(authentication|) (message-digest|null) "
1264 "(authentication-key|) AUTH_KEY",
1265 VLINK_HELPSTR_IPADDR
1266 VLINK_HELPSTR_AUTHTYPE_ALL
1267 VLINK_HELPSTR_AUTH_SIMPLE)
1268
paula2c62832003-04-23 17:01:31 +00001269ALIAS (ospf_area_vlink,
1270 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001271 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1272 "(authentication|) "
1273 "(authentication-key|) AUTH_KEY",
1274 VLINK_HELPSTR_IPADDR
1275 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1276 VLINK_HELPSTR_AUTH_SIMPLE)
1277
paula2c62832003-04-23 17:01:31 +00001278ALIAS (no_ospf_area_vlink,
1279 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001280 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1281 "(authentication|) "
1282 "(authentication-key|)",
1283 NO_STR
1284 VLINK_HELPSTR_IPADDR
1285 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1286 VLINK_HELPSTR_AUTH_SIMPLE)
1287
paula2c62832003-04-23 17:01:31 +00001288ALIAS (ospf_area_vlink,
1289 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001290 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1291 "(authentication|) (message-digest|null) "
1292 "(message-digest-key|) <1-255> md5 KEY",
1293 VLINK_HELPSTR_IPADDR
1294 VLINK_HELPSTR_AUTHTYPE_ALL
1295 VLINK_HELPSTR_AUTH_MD5)
1296
paula2c62832003-04-23 17:01:31 +00001297ALIAS (ospf_area_vlink,
1298 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001299 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1300 "(authentication|) "
1301 "(message-digest-key|) <1-255> md5 KEY",
1302 VLINK_HELPSTR_IPADDR
1303 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1304 VLINK_HELPSTR_AUTH_MD5)
1305
paula2c62832003-04-23 17:01:31 +00001306ALIAS (no_ospf_area_vlink,
1307 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001308 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1309 "(authentication|) "
1310 "(message-digest-key|)",
1311 NO_STR
1312 VLINK_HELPSTR_IPADDR
1313 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1314 VLINK_HELPSTR_AUTH_MD5)
1315
1316
paula2c62832003-04-23 17:01:31 +00001317DEFUN (ospf_area_shortcut,
1318 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001319 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1320 "OSPF area parameters\n"
1321 "OSPF area ID in IP address format\n"
1322 "OSPF area ID as a decimal value\n"
1323 "Configure the area's shortcutting mode\n"
1324 "Set default shortcutting behavior\n"
1325 "Enable shortcutting through the area\n"
1326 "Disable shortcutting through the area\n")
1327{
paul68980082003-03-25 05:07:42 +00001328 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001329 struct ospf_area *area;
1330 struct in_addr area_id;
1331 int mode;
1332 int format;
1333
1334 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1335
paul68980082003-03-25 05:07:42 +00001336 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001337
1338 if (strncmp (argv[1], "de", 2) == 0)
1339 mode = OSPF_SHORTCUT_DEFAULT;
1340 else if (strncmp (argv[1], "di", 2) == 0)
1341 mode = OSPF_SHORTCUT_DISABLE;
1342 else if (strncmp (argv[1], "e", 1) == 0)
1343 mode = OSPF_SHORTCUT_ENABLE;
1344 else
1345 return CMD_WARNING;
1346
paul68980082003-03-25 05:07:42 +00001347 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001348
paul68980082003-03-25 05:07:42 +00001349 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001350 vty_out (vty, "Shortcut area setting will take effect "
1351 "only when the router is configured as Shortcut ABR%s",
1352 VTY_NEWLINE);
1353
1354 return CMD_SUCCESS;
1355}
1356
paula2c62832003-04-23 17:01:31 +00001357DEFUN (no_ospf_area_shortcut,
1358 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001359 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1360 NO_STR
1361 "OSPF area parameters\n"
1362 "OSPF area ID in IP address format\n"
1363 "OSPF area ID as a decimal value\n"
1364 "Deconfigure the area's shortcutting mode\n"
1365 "Deconfigure enabled shortcutting through the area\n"
1366 "Deconfigure disabled shortcutting through the area\n")
1367{
paul68980082003-03-25 05:07:42 +00001368 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001369 struct ospf_area *area;
1370 struct in_addr area_id;
1371 int format;
1372
1373 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1374
paul68980082003-03-25 05:07:42 +00001375 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001376 if (!area)
1377 return CMD_SUCCESS;
1378
paul68980082003-03-25 05:07:42 +00001379 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001380
1381 return CMD_SUCCESS;
1382}
1383
1384
paula2c62832003-04-23 17:01:31 +00001385DEFUN (ospf_area_stub,
1386 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001387 "area (A.B.C.D|<0-4294967295>) stub",
1388 "OSPF area parameters\n"
1389 "OSPF area ID in IP address format\n"
1390 "OSPF area ID as a decimal value\n"
1391 "Configure OSPF area as stub\n")
1392{
1393 struct ospf *ospf = vty->index;
1394 struct in_addr area_id;
1395 int ret, format;
1396
1397 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1398
1399 ret = ospf_area_stub_set (ospf, area_id);
1400 if (ret == 0)
1401 {
1402 vty_out (vty, "First deconfigure all virtual link through this area%s",
1403 VTY_NEWLINE);
1404 return CMD_WARNING;
1405 }
1406
1407 ospf_area_no_summary_unset (ospf, area_id);
1408
1409 return CMD_SUCCESS;
1410}
1411
paula2c62832003-04-23 17:01:31 +00001412DEFUN (ospf_area_stub_no_summary,
1413 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001414 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1415 "OSPF stub parameters\n"
1416 "OSPF area ID in IP address format\n"
1417 "OSPF area ID as a decimal value\n"
1418 "Configure OSPF area as stub\n"
1419 "Do not inject inter-area routes into stub\n")
1420{
1421 struct ospf *ospf = vty->index;
1422 struct in_addr area_id;
1423 int ret, format;
1424
1425 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1426
1427 ret = ospf_area_stub_set (ospf, area_id);
1428 if (ret == 0)
1429 {
paulb0a053b2003-06-22 09:04:47 +00001430 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001431 VTY_NEWLINE);
1432 return CMD_WARNING;
1433 }
1434
1435 ospf_area_no_summary_set (ospf, area_id);
1436
1437 return CMD_SUCCESS;
1438}
1439
paula2c62832003-04-23 17:01:31 +00001440DEFUN (no_ospf_area_stub,
1441 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001442 "no area (A.B.C.D|<0-4294967295>) stub",
1443 NO_STR
1444 "OSPF area parameters\n"
1445 "OSPF area ID in IP address format\n"
1446 "OSPF area ID as a decimal value\n"
1447 "Configure OSPF area as stub\n")
1448{
1449 struct ospf *ospf = vty->index;
1450 struct in_addr area_id;
1451 int format;
1452
1453 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1454
1455 ospf_area_stub_unset (ospf, area_id);
1456 ospf_area_no_summary_unset (ospf, area_id);
1457
1458 return CMD_SUCCESS;
1459}
1460
paula2c62832003-04-23 17:01:31 +00001461DEFUN (no_ospf_area_stub_no_summary,
1462 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001463 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1464 NO_STR
1465 "OSPF area parameters\n"
1466 "OSPF area ID in IP address format\n"
1467 "OSPF area ID as a decimal value\n"
1468 "Configure OSPF area as stub\n"
1469 "Do not inject inter-area routes into area\n")
1470{
1471 struct ospf *ospf = vty->index;
1472 struct in_addr area_id;
1473 int format;
1474
1475 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1476 ospf_area_no_summary_unset (ospf, area_id);
1477
1478 return CMD_SUCCESS;
1479}
1480
1481#ifdef HAVE_NSSA
paulb0a053b2003-06-22 09:04:47 +00001482int
1483ospf_area_nssa_cmd_handler (struct vty *vty, int argc, char **argv, int nosum)
paul718e3742002-12-13 20:15:29 +00001484{
1485 struct ospf *ospf = vty->index;
1486 struct in_addr area_id;
1487 int ret, format;
1488
1489 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1490
1491 ret = ospf_area_nssa_set (ospf, area_id);
1492 if (ret == 0)
1493 {
1494 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1495 VTY_NEWLINE);
1496 return CMD_WARNING;
1497 }
1498
1499 if (argc > 1)
1500 {
1501 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001502 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001503 OSPF_NSSA_ROLE_CANDIDATE);
1504 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001505 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001506 OSPF_NSSA_ROLE_NEVER);
1507 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001508 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001509 OSPF_NSSA_ROLE_ALWAYS);
1510 }
paulb0a053b2003-06-22 09:04:47 +00001511 else
1512 {
1513 ospf_area_nssa_translator_role_set (ospf, area_id,
1514 OSPF_NSSA_ROLE_CANDIDATE);
1515 }
paul718e3742002-12-13 20:15:29 +00001516
paulb0a053b2003-06-22 09:04:47 +00001517 if (nosum)
paul718e3742002-12-13 20:15:29 +00001518 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001519 else
1520 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001521
paulb0a053b2003-06-22 09:04:47 +00001522 ospf_schedule_abr_task (ospf);
1523
paul718e3742002-12-13 20:15:29 +00001524 return CMD_SUCCESS;
1525}
1526
paulb0a053b2003-06-22 09:04:47 +00001527DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001528 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001529 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001530 "OSPF area parameters\n"
1531 "OSPF area ID in IP address format\n"
1532 "OSPF area ID as a decimal value\n"
1533 "Configure OSPF area as nssa\n"
1534 "Configure NSSA-ABR for translate election (default)\n"
1535 "Configure NSSA-ABR to never translate\n"
1536 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001537 "Do not inject inter-area routes into nssa\n")
1538{
1539 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1540}
paul718e3742002-12-13 20:15:29 +00001541
paulb0a053b2003-06-22 09:04:47 +00001542DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001543 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001544 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1545 "OSPF area parameters\n"
1546 "OSPF area ID in IP address format\n"
1547 "OSPF area ID as a decimal value\n"
1548 "Configure OSPF area as nssa\n"
1549 "Configure NSSA-ABR for translate election (default)\n"
1550 "Configure NSSA-ABR to never translate\n"
1551 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001552{
1553 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1554}
1555
1556DEFUN (ospf_area_nssa,
1557 ospf_area_nssa_cmd,
1558 "area (A.B.C.D|<0-4294967295>) nssa",
1559 "OSPF area parameters\n"
1560 "OSPF area ID in IP address format\n"
1561 "OSPF area ID as a decimal value\n"
1562 "Configure OSPF area as nssa\n")
1563{
1564 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1565}
paul718e3742002-12-13 20:15:29 +00001566
paula2c62832003-04-23 17:01:31 +00001567DEFUN (ospf_area_nssa_no_summary,
1568 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001569 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1570 "OSPF area parameters\n"
1571 "OSPF area ID in IP address format\n"
1572 "OSPF area ID as a decimal value\n"
1573 "Configure OSPF area as nssa\n"
1574 "Do not inject inter-area routes into nssa\n")
1575{
paulb0a053b2003-06-22 09:04:47 +00001576 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001577}
1578
paula2c62832003-04-23 17:01:31 +00001579DEFUN (no_ospf_area_nssa,
1580 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001581 "no area (A.B.C.D|<0-4294967295>) nssa",
1582 NO_STR
1583 "OSPF area parameters\n"
1584 "OSPF area ID in IP address format\n"
1585 "OSPF area ID as a decimal value\n"
1586 "Configure OSPF area as nssa\n")
1587{
1588 struct ospf *ospf = vty->index;
1589 struct in_addr area_id;
1590 int format;
1591
1592 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1593
1594 ospf_area_nssa_unset (ospf, area_id);
1595 ospf_area_no_summary_unset (ospf, area_id);
1596
paulb0a053b2003-06-22 09:04:47 +00001597 ospf_schedule_abr_task (ospf);
1598
paul718e3742002-12-13 20:15:29 +00001599 return CMD_SUCCESS;
1600}
1601
paula2c62832003-04-23 17:01:31 +00001602DEFUN (no_ospf_area_nssa_no_summary,
1603 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001604 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1605 NO_STR
1606 "OSPF area parameters\n"
1607 "OSPF area ID in IP address format\n"
1608 "OSPF area ID as a decimal value\n"
1609 "Configure OSPF area as nssa\n"
1610 "Do not inject inter-area routes into nssa\n")
1611{
1612 struct ospf *ospf = vty->index;
1613 struct in_addr area_id;
1614 int format;
1615
1616 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1617 ospf_area_no_summary_unset (ospf, area_id);
1618
1619 return CMD_SUCCESS;
1620}
1621
1622#endif /* HAVE_NSSA */
1623
paula2c62832003-04-23 17:01:31 +00001624DEFUN (ospf_area_default_cost,
1625 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001626 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1627 "OSPF area parameters\n"
1628 "OSPF area ID in IP address format\n"
1629 "OSPF area ID as a decimal value\n"
1630 "Set the summary-default cost of a NSSA or stub area\n"
1631 "Stub's advertised default summary cost\n")
1632{
paul68980082003-03-25 05:07:42 +00001633 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001634 struct ospf_area *area;
1635 struct in_addr area_id;
1636 u_int32_t cost;
1637 int format;
1638
1639 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1640 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1641
paul68980082003-03-25 05:07:42 +00001642 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001643
1644 if (area->external_routing == OSPF_AREA_DEFAULT)
1645 {
1646 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1647 return CMD_WARNING;
1648 }
1649
1650 area->default_cost = cost;
1651
1652 return CMD_SUCCESS;
1653}
1654
paula2c62832003-04-23 17:01:31 +00001655DEFUN (no_ospf_area_default_cost,
1656 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001657 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1658 NO_STR
1659 "OSPF area parameters\n"
1660 "OSPF area ID in IP address format\n"
1661 "OSPF area ID as a decimal value\n"
1662 "Set the summary-default cost of a NSSA or stub area\n"
1663 "Stub's advertised default summary cost\n")
1664{
paul68980082003-03-25 05:07:42 +00001665 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001666 struct ospf_area *area;
1667 struct in_addr area_id;
1668 u_int32_t cost;
1669 int format;
1670
1671 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1672 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1673
paul68980082003-03-25 05:07:42 +00001674 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001675 if (area == NULL)
1676 return CMD_SUCCESS;
1677
1678 if (area->external_routing == OSPF_AREA_DEFAULT)
1679 {
1680 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1681 return CMD_WARNING;
1682 }
1683
1684 area->default_cost = 1;
1685
paul68980082003-03-25 05:07:42 +00001686 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001687
1688 return CMD_SUCCESS;
1689}
1690
paula2c62832003-04-23 17:01:31 +00001691DEFUN (ospf_area_export_list,
1692 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001693 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1694 "OSPF area parameters\n"
1695 "OSPF area ID in IP address format\n"
1696 "OSPF area ID as a decimal value\n"
1697 "Set the filter for networks announced to other areas\n"
1698 "Name of the access-list\n")
1699{
paul68980082003-03-25 05:07:42 +00001700 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001701 struct ospf_area *area;
1702 struct in_addr area_id;
1703 int format;
1704
hasso52930762004-04-19 18:26:53 +00001705 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1706
paul68980082003-03-25 05:07:42 +00001707 area = ospf_area_get (ospf, area_id, format);
1708 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001709
1710 return CMD_SUCCESS;
1711}
1712
paula2c62832003-04-23 17:01:31 +00001713DEFUN (no_ospf_area_export_list,
1714 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001715 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1716 NO_STR
1717 "OSPF area parameters\n"
1718 "OSPF area ID in IP address format\n"
1719 "OSPF area ID as a decimal value\n"
1720 "Unset the filter for networks announced to other areas\n"
1721 "Name of the access-list\n")
1722{
paul68980082003-03-25 05:07:42 +00001723 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001724 struct ospf_area *area;
1725 struct in_addr area_id;
1726 int format;
1727
hasso52930762004-04-19 18:26:53 +00001728 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1729
paul68980082003-03-25 05:07:42 +00001730 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001731 if (area == NULL)
1732 return CMD_SUCCESS;
1733
paul68980082003-03-25 05:07:42 +00001734 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001735
1736 return CMD_SUCCESS;
1737}
1738
1739
paula2c62832003-04-23 17:01:31 +00001740DEFUN (ospf_area_import_list,
1741 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001742 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1743 "OSPF area parameters\n"
1744 "OSPF area ID in IP address format\n"
1745 "OSPF area ID as a decimal value\n"
1746 "Set the filter for networks from other areas announced to the specified one\n"
1747 "Name of the access-list\n")
1748{
paul68980082003-03-25 05:07:42 +00001749 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001750 struct ospf_area *area;
1751 struct in_addr area_id;
1752 int format;
1753
hasso52930762004-04-19 18:26:53 +00001754 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1755
paul68980082003-03-25 05:07:42 +00001756 area = ospf_area_get (ospf, area_id, format);
1757 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001758
1759 return CMD_SUCCESS;
1760}
1761
paula2c62832003-04-23 17:01:31 +00001762DEFUN (no_ospf_area_import_list,
1763 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001764 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1765 NO_STR
1766 "OSPF area parameters\n"
1767 "OSPF area ID in IP address format\n"
1768 "OSPF area ID as a decimal value\n"
1769 "Unset the filter for networks announced to other areas\n"
1770 "Name of the access-list\n")
1771{
paul68980082003-03-25 05:07:42 +00001772 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001773 struct ospf_area *area;
1774 struct in_addr area_id;
1775 int format;
1776
hasso52930762004-04-19 18:26:53 +00001777 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1778
paul68980082003-03-25 05:07:42 +00001779 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001780 if (area == NULL)
1781 return CMD_SUCCESS;
1782
paul68980082003-03-25 05:07:42 +00001783 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001784
1785 return CMD_SUCCESS;
1786}
1787
paula2c62832003-04-23 17:01:31 +00001788DEFUN (ospf_area_filter_list,
1789 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001790 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1791 "OSPF area parameters\n"
1792 "OSPF area ID in IP address format\n"
1793 "OSPF area ID as a decimal value\n"
1794 "Filter networks between OSPF areas\n"
1795 "Filter prefixes between OSPF areas\n"
1796 "Name of an IP prefix-list\n"
1797 "Filter networks sent to this area\n"
1798 "Filter networks sent from this area\n")
1799{
paul68980082003-03-25 05:07:42 +00001800 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001801 struct ospf_area *area;
1802 struct in_addr area_id;
1803 struct prefix_list *plist;
1804 int format;
1805
1806 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1807
paul68980082003-03-25 05:07:42 +00001808 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001809 plist = prefix_list_lookup (AFI_IP, argv[1]);
1810 if (strncmp (argv[2], "in", 2) == 0)
1811 {
1812 PREFIX_LIST_IN (area) = plist;
1813 if (PREFIX_NAME_IN (area))
1814 free (PREFIX_NAME_IN (area));
1815
1816 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001817 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001818 }
1819 else
1820 {
1821 PREFIX_LIST_OUT (area) = plist;
1822 if (PREFIX_NAME_OUT (area))
1823 free (PREFIX_NAME_OUT (area));
1824
1825 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001826 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001827 }
1828
1829 return CMD_SUCCESS;
1830}
1831
paula2c62832003-04-23 17:01:31 +00001832DEFUN (no_ospf_area_filter_list,
1833 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001834 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1835 NO_STR
1836 "OSPF area parameters\n"
1837 "OSPF area ID in IP address format\n"
1838 "OSPF area ID as a decimal value\n"
1839 "Filter networks between OSPF areas\n"
1840 "Filter prefixes between OSPF areas\n"
1841 "Name of an IP prefix-list\n"
1842 "Filter networks sent to this area\n"
1843 "Filter networks sent from this area\n")
1844{
paul68980082003-03-25 05:07:42 +00001845 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001846 struct ospf_area *area;
1847 struct in_addr area_id;
1848 struct prefix_list *plist;
1849 int format;
1850
1851 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1852
paul68980082003-03-25 05:07:42 +00001853 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001854 plist = prefix_list_lookup (AFI_IP, argv[1]);
1855 if (strncmp (argv[2], "in", 2) == 0)
1856 {
1857 if (PREFIX_NAME_IN (area))
1858 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1859 return CMD_SUCCESS;
1860
1861 PREFIX_LIST_IN (area) = NULL;
1862 if (PREFIX_NAME_IN (area))
1863 free (PREFIX_NAME_IN (area));
1864
1865 PREFIX_NAME_IN (area) = NULL;
1866
paul68980082003-03-25 05:07:42 +00001867 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001868 }
1869 else
1870 {
1871 if (PREFIX_NAME_OUT (area))
1872 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1873 return CMD_SUCCESS;
1874
1875 PREFIX_LIST_OUT (area) = NULL;
1876 if (PREFIX_NAME_OUT (area))
1877 free (PREFIX_NAME_OUT (area));
1878
1879 PREFIX_NAME_OUT (area) = NULL;
1880
paul68980082003-03-25 05:07:42 +00001881 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001882 }
1883
1884 return CMD_SUCCESS;
1885}
1886
1887
paula2c62832003-04-23 17:01:31 +00001888DEFUN (ospf_area_authentication_message_digest,
1889 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001890 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1891 "OSPF area parameters\n"
1892 "Enable authentication\n"
1893 "Use message-digest authentication\n")
1894{
paul68980082003-03-25 05:07:42 +00001895 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001896 struct ospf_area *area;
1897 struct in_addr area_id;
1898 int format;
1899
1900 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1901
paul68980082003-03-25 05:07:42 +00001902 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001903 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1904
1905 return CMD_SUCCESS;
1906}
1907
paula2c62832003-04-23 17:01:31 +00001908DEFUN (ospf_area_authentication,
1909 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001910 "area (A.B.C.D|<0-4294967295>) authentication",
1911 "OSPF area parameters\n"
1912 "OSPF area ID in IP address format\n"
1913 "OSPF area ID as a decimal value\n"
1914 "Enable authentication\n")
1915{
paul68980082003-03-25 05:07:42 +00001916 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001917 struct ospf_area *area;
1918 struct in_addr area_id;
1919 int format;
1920
1921 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1922
paul68980082003-03-25 05:07:42 +00001923 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001924 area->auth_type = OSPF_AUTH_SIMPLE;
1925
1926 return CMD_SUCCESS;
1927}
1928
paula2c62832003-04-23 17:01:31 +00001929DEFUN (no_ospf_area_authentication,
1930 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001931 "no area (A.B.C.D|<0-4294967295>) authentication",
1932 NO_STR
1933 "OSPF area parameters\n"
1934 "OSPF area ID in IP address format\n"
1935 "OSPF area ID as a decimal value\n"
1936 "Enable authentication\n")
1937{
paul68980082003-03-25 05:07:42 +00001938 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001939 struct ospf_area *area;
1940 struct in_addr area_id;
1941 int format;
1942
1943 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1944
paul68980082003-03-25 05:07:42 +00001945 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001946 if (area == NULL)
1947 return CMD_SUCCESS;
1948
1949 area->auth_type = OSPF_AUTH_NULL;
1950
paul68980082003-03-25 05:07:42 +00001951 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001952
1953 return CMD_SUCCESS;
1954}
1955
1956
1957DEFUN (ospf_abr_type,
1958 ospf_abr_type_cmd,
1959 "ospf abr-type (cisco|ibm|shortcut|standard)",
1960 "OSPF specific commands\n"
1961 "Set OSPF ABR type\n"
1962 "Alternative ABR, cisco implementation\n"
1963 "Alternative ABR, IBM implementation\n"
1964 "Shortcut ABR\n"
1965 "Standard behavior (RFC2328)\n")
1966{
paul68980082003-03-25 05:07:42 +00001967 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001968 u_char abr_type = OSPF_ABR_UNKNOWN;
1969
1970 if (strncmp (argv[0], "c", 1) == 0)
1971 abr_type = OSPF_ABR_CISCO;
1972 else if (strncmp (argv[0], "i", 1) == 0)
1973 abr_type = OSPF_ABR_IBM;
1974 else if (strncmp (argv[0], "sh", 2) == 0)
1975 abr_type = OSPF_ABR_SHORTCUT;
1976 else if (strncmp (argv[0], "st", 2) == 0)
1977 abr_type = OSPF_ABR_STAND;
1978 else
1979 return CMD_WARNING;
1980
1981 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00001982 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00001983 {
paul68980082003-03-25 05:07:42 +00001984 ospf->abr_type = abr_type;
1985 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001986 }
1987
1988 return CMD_SUCCESS;
1989}
1990
1991DEFUN (no_ospf_abr_type,
1992 no_ospf_abr_type_cmd,
1993 "no ospf abr-type (cisco|ibm|shortcut)",
1994 NO_STR
1995 "OSPF specific commands\n"
1996 "Set OSPF ABR type\n"
1997 "Alternative ABR, cisco implementation\n"
1998 "Alternative ABR, IBM implementation\n"
1999 "Shortcut ABR\n")
2000{
paul68980082003-03-25 05:07:42 +00002001 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002002 u_char abr_type = OSPF_ABR_UNKNOWN;
2003
2004 if (strncmp (argv[0], "c", 1) == 0)
2005 abr_type = OSPF_ABR_CISCO;
2006 else if (strncmp (argv[0], "i", 1) == 0)
2007 abr_type = OSPF_ABR_IBM;
2008 else if (strncmp (argv[0], "s", 1) == 0)
2009 abr_type = OSPF_ABR_SHORTCUT;
2010 else
2011 return CMD_WARNING;
2012
2013 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002014 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002015 {
paul68980082003-03-25 05:07:42 +00002016 ospf->abr_type = OSPF_ABR_STAND;
2017 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002018 }
2019
2020 return CMD_SUCCESS;
2021}
2022
2023DEFUN (ospf_compatible_rfc1583,
2024 ospf_compatible_rfc1583_cmd,
2025 "compatible rfc1583",
2026 "OSPF compatibility list\n"
2027 "compatible with RFC 1583\n")
2028{
2029 struct ospf *ospf = vty->index;
2030
2031 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2032 {
2033 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002034 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002035 }
2036 return CMD_SUCCESS;
2037}
2038
2039DEFUN (no_ospf_compatible_rfc1583,
2040 no_ospf_compatible_rfc1583_cmd,
2041 "no compatible rfc1583",
2042 NO_STR
2043 "OSPF compatibility list\n"
2044 "compatible with RFC 1583\n")
2045{
2046 struct ospf *ospf = vty->index;
2047
2048 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2049 {
2050 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002051 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002052 }
2053 return CMD_SUCCESS;
2054}
2055
2056ALIAS (ospf_compatible_rfc1583,
2057 ospf_rfc1583_flag_cmd,
2058 "ospf rfc1583compatibility",
2059 "OSPF specific commands\n"
2060 "Enable the RFC1583Compatibility flag\n")
2061
2062ALIAS (no_ospf_compatible_rfc1583,
2063 no_ospf_rfc1583_flag_cmd,
2064 "no ospf rfc1583compatibility",
2065 NO_STR
2066 "OSPF specific commands\n"
2067 "Disable the RFC1583Compatibility flag\n")
2068
paula2c62832003-04-23 17:01:31 +00002069DEFUN (ospf_timers_spf,
2070 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002071 "timers spf <0-4294967295> <0-4294967295>",
2072 "Adjust routing timers\n"
2073 "OSPF SPF timers\n"
2074 "Delay between receiving a change to SPF calculation\n"
2075 "Hold time between consecutive SPF calculations\n")
2076{
2077 struct ospf *ospf = vty->index;
2078 u_int32_t delay, hold;
2079
2080 VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]);
2081 VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]);
2082
2083 ospf_timers_spf_set (ospf, delay, hold);
2084
2085 return CMD_SUCCESS;
2086}
2087
paula2c62832003-04-23 17:01:31 +00002088DEFUN (no_ospf_timers_spf,
2089 no_ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002090 "no timers spf",
2091 NO_STR
2092 "Adjust routing timers\n"
2093 "OSPF SPF timers\n")
2094{
paul68980082003-03-25 05:07:42 +00002095 struct ospf *ospf = vty->index;
2096
2097 ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT;
2098 ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002099
2100 return CMD_SUCCESS;
2101}
2102
2103
paula2c62832003-04-23 17:01:31 +00002104DEFUN (ospf_neighbor,
2105 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002106 "neighbor A.B.C.D",
2107 NEIGHBOR_STR
2108 "Neighbor IP address\n")
2109{
2110 struct ospf *ospf = vty->index;
2111 struct in_addr nbr_addr;
2112 int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2113 int interval = OSPF_POLL_INTERVAL_DEFAULT;
2114
2115 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2116
2117 if (argc > 1)
2118 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2119
2120 if (argc > 2)
2121 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2122
2123 ospf_nbr_nbma_set (ospf, nbr_addr);
2124 if (argc > 1)
2125 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2126 if (argc > 2)
2127 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2128
2129 return CMD_SUCCESS;
2130}
2131
paula2c62832003-04-23 17:01:31 +00002132ALIAS (ospf_neighbor,
2133 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002134 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2135 NEIGHBOR_STR
2136 "Neighbor IP address\n"
2137 "Neighbor Priority\n"
2138 "Priority\n"
2139 "Dead Neighbor Polling interval\n"
2140 "Seconds\n")
2141
paula2c62832003-04-23 17:01:31 +00002142ALIAS (ospf_neighbor,
2143 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002144 "neighbor A.B.C.D priority <0-255>",
2145 NEIGHBOR_STR
2146 "Neighbor IP address\n"
2147 "Neighbor Priority\n"
2148 "Seconds\n")
2149
paula2c62832003-04-23 17:01:31 +00002150DEFUN (ospf_neighbor_poll_interval,
2151 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002152 "neighbor A.B.C.D poll-interval <1-65535>",
2153 NEIGHBOR_STR
2154 "Neighbor IP address\n"
2155 "Dead Neighbor Polling interval\n"
2156 "Seconds\n")
2157{
2158 struct ospf *ospf = vty->index;
2159 struct in_addr nbr_addr;
2160 int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2161 int interval = OSPF_POLL_INTERVAL_DEFAULT;
2162
2163 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2164
2165 if (argc > 1)
2166 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2167
2168 if (argc > 2)
2169 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2170
2171 ospf_nbr_nbma_set (ospf, nbr_addr);
2172 if (argc > 1)
2173 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2174 if (argc > 2)
2175 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2176
2177 return CMD_SUCCESS;
2178}
2179
paula2c62832003-04-23 17:01:31 +00002180ALIAS (ospf_neighbor_poll_interval,
2181 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002182 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2183 NEIGHBOR_STR
2184 "Neighbor address\n"
2185 "OSPF dead-router polling interval\n"
2186 "Seconds\n"
2187 "OSPF priority of non-broadcast neighbor\n"
2188 "Priority\n")
2189
paula2c62832003-04-23 17:01:31 +00002190DEFUN (no_ospf_neighbor,
2191 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002192 "no neighbor A.B.C.D",
2193 NO_STR
2194 NEIGHBOR_STR
2195 "Neighbor IP address\n")
2196{
2197 struct ospf *ospf = vty->index;
2198 struct in_addr nbr_addr;
2199 int ret;
2200
2201 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2202
2203 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2204
2205 return CMD_SUCCESS;
2206}
2207
paula2c62832003-04-23 17:01:31 +00002208ALIAS (no_ospf_neighbor,
2209 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002210 "no neighbor A.B.C.D priority <0-255>",
2211 NO_STR
2212 NEIGHBOR_STR
2213 "Neighbor IP address\n"
2214 "Neighbor Priority\n"
2215 "Priority\n")
2216
paula2c62832003-04-23 17:01:31 +00002217ALIAS (no_ospf_neighbor,
2218 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002219 "no neighbor A.B.C.D poll-interval <1-65535>",
2220 NO_STR
2221 NEIGHBOR_STR
2222 "Neighbor IP address\n"
2223 "Dead Neighbor Polling interval\n"
2224 "Seconds\n")
2225
paula2c62832003-04-23 17:01:31 +00002226ALIAS (no_ospf_neighbor,
2227 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002228 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2229 NO_STR
2230 NEIGHBOR_STR
2231 "Neighbor IP address\n"
2232 "Neighbor Priority\n"
2233 "Priority\n"
2234 "Dead Neighbor Polling interval\n"
2235 "Seconds\n")
2236
2237
paula2c62832003-04-23 17:01:31 +00002238DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002239 "refresh timer <10-1800>",
2240 "Adjust refresh parameters\n"
2241 "Set refresh timer\n"
2242 "Timer value in seconds\n")
2243{
2244 struct ospf *ospf = vty->index;
2245 int interval;
2246
2247 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2248 interval = (interval / 10) * 10;
2249
2250 ospf_timers_refresh_set (ospf, interval);
2251
2252 return CMD_SUCCESS;
2253}
2254
paula2c62832003-04-23 17:01:31 +00002255DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002256 "no refresh timer <10-1800>",
2257 "Adjust refresh parameters\n"
2258 "Unset refresh timer\n"
2259 "Timer value in seconds\n")
2260{
2261 struct ospf *ospf = vty->index;
2262 int interval;
2263
2264 if (argc == 1)
2265 {
2266 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2267
2268 if (ospf->lsa_refresh_interval != interval ||
2269 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2270 return CMD_SUCCESS;
2271 }
2272
2273 ospf_timers_refresh_unset (ospf);
2274
2275 return CMD_SUCCESS;
2276}
2277
paula2c62832003-04-23 17:01:31 +00002278ALIAS (no_ospf_refresh_timer,
2279 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002280 "no refresh timer",
2281 "Adjust refresh parameters\n"
2282 "Unset refresh timer\n")
2283
paula2c62832003-04-23 17:01:31 +00002284DEFUN (ospf_auto_cost_reference_bandwidth,
2285 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002286 "auto-cost reference-bandwidth <1-4294967>",
2287 "Calculate OSPF interface cost according to bandwidth\n"
2288 "Use reference bandwidth method to assign OSPF cost\n"
2289 "The reference bandwidth in terms of Mbits per second\n")
2290{
paul68980082003-03-25 05:07:42 +00002291 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002292 u_int32_t refbw;
2293 listnode node;
2294
2295 refbw = strtol (argv[0], NULL, 10);
2296 if (refbw < 1 || refbw > 4294967)
2297 {
2298 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2299 return CMD_WARNING;
2300 }
2301
2302 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002303 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002304 return CMD_SUCCESS;
2305
paul68980082003-03-25 05:07:42 +00002306 ospf->ref_bandwidth = refbw * 1000;
paul718e3742002-12-13 20:15:29 +00002307 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2308 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2309
paul020709f2003-04-04 02:44:16 +00002310 for (node = listhead (om->iflist); node; nextnode (node))
2311 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002312
2313 return CMD_SUCCESS;
2314}
2315
paula2c62832003-04-23 17:01:31 +00002316DEFUN (no_ospf_auto_cost_reference_bandwidth,
2317 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002318 "no auto-cost reference-bandwidth",
2319 NO_STR
2320 "Calculate OSPF interface cost according to bandwidth\n"
2321 "Use reference bandwidth method to assign OSPF cost\n")
2322{
paul68980082003-03-25 05:07:42 +00002323 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002324 listnode node;
2325
paul68980082003-03-25 05:07:42 +00002326 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002327 return CMD_SUCCESS;
2328
paul68980082003-03-25 05:07:42 +00002329 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002330 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2331 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2332
paul020709f2003-04-04 02:44:16 +00002333 for (node = listhead (om->iflist); node; nextnode (node))
2334 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002335
2336 return CMD_SUCCESS;
2337}
2338
paul718e3742002-12-13 20:15:29 +00002339char *ospf_abr_type_descr_str[] =
2340{
2341 "Unknown",
2342 "Standard (RFC2328)",
2343 "Alternative IBM",
2344 "Alternative Cisco",
2345 "Alternative Shortcut"
2346};
2347
2348char *ospf_shortcut_mode_descr_str[] =
2349{
2350 "Default",
2351 "Enabled",
2352 "Disabled"
2353};
2354
2355
2356
2357void
2358show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2359{
2360 /* Show Area ID. */
2361 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2362
2363 /* Show Area type/mode. */
2364 if (OSPF_IS_AREA_BACKBONE (area))
2365 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2366 else
2367 {
2368 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002369 vty_out (vty, " (Stub%s%s)",
2370 area->no_summary ? ", no summary" : "",
2371 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002372
2373#ifdef HAVE_NSSA
2374
paulb0a053b2003-06-22 09:04:47 +00002375 else if (area->external_routing == OSPF_AREA_NSSA)
2376 vty_out (vty, " (NSSA%s%s)",
2377 area->no_summary ? ", no summary" : "",
2378 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002379#endif /* HAVE_NSSA */
2380
2381 vty_out (vty, "%s", VTY_NEWLINE);
2382 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002383 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002384 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002385 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002386 }
2387
2388 /* Show number of interfaces. */
2389 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2390 "Active: %d%s", listcount (area->oiflist),
2391 area->act_ints, VTY_NEWLINE);
2392
2393#ifdef HAVE_NSSA
2394 if (area->external_routing == OSPF_AREA_NSSA)
2395 {
2396 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00002397 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002398 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2399 VTY_NEWLINE);
2400 else if (area->NSSATranslatorState)
2401 {
2402 vty_out (vty, " We are an ABR and ");
2403 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2404 vty_out (vty, "the NSSA Elected Translator. %s",
2405 VTY_NEWLINE);
2406 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2407 vty_out (vty, "always an NSSA Translator. %s",
2408 VTY_NEWLINE);
2409 }
paul718e3742002-12-13 20:15:29 +00002410 else
paulb0a053b2003-06-22 09:04:47 +00002411 {
2412 vty_out (vty, " We are an ABR, but ");
2413 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2414 vty_out (vty, "not the NSSA Elected Translator. %s",
2415 VTY_NEWLINE);
2416 else
2417 vty_out (vty, "not the NSSA Elected Translator. %s",
2418 VTY_NEWLINE);
2419 }
paul718e3742002-12-13 20:15:29 +00002420 }
2421#endif /* HAVE_NSSA */
2422
2423 /* Show number of fully adjacent neighbors. */
2424 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002425 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002426
2427 /* Show authentication type. */
2428 vty_out (vty, " Area has ");
2429 if (area->auth_type == OSPF_AUTH_NULL)
2430 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2431 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2432 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2433 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2434 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2435
2436 if (!OSPF_IS_AREA_BACKBONE (area))
2437 vty_out (vty, " Number of full virtual adjacencies going through"
2438 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2439
2440 /* Show SPF calculation times. */
2441 vty_out (vty, " SPF algorithm executed %d times%s",
2442 area->spf_calculation, VTY_NEWLINE);
2443
2444 /* Show number of LSA. */
2445 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
2446
2447 vty_out (vty, "%s", VTY_NEWLINE);
2448}
2449
2450DEFUN (show_ip_ospf,
2451 show_ip_ospf_cmd,
2452 "show ip ospf",
2453 SHOW_STR
2454 IP_STR
2455 "OSPF information\n")
2456{
2457 listnode node;
2458 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002459 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002460
2461 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002462 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002463 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002464 {
2465 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2466 return CMD_SUCCESS;
2467 }
2468
2469 /* Show Router ID. */
2470 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002471 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002472 VTY_NEWLINE);
2473
2474 /* Show capability. */
2475 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2476 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2477 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002478 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002479 "enabled" : "disabled", VTY_NEWLINE);
2480#ifdef HAVE_OPAQUE_LSA
2481 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002482 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002483 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002484 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002485 " (origination blocked)" : "",
2486 VTY_NEWLINE);
2487#endif /* HAVE_OPAQUE_LSA */
2488
2489 /* Show SPF timers. */
2490 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
paul68980082003-03-25 05:07:42 +00002491 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002492
2493 /* Show refresh parameters. */
2494 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002495 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002496
2497 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002498 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002499 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002500 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002501
paul68980082003-03-25 05:07:42 +00002502 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002503 vty_out (vty, " This router is an ASBR "
2504 "(injecting external routing information)%s", VTY_NEWLINE);
2505
2506 /* Show Number of AS-external-LSAs. */
2507 vty_out (vty, " Number of external LSA %ld%s",
paul68980082003-03-25 05:07:42 +00002508 ospf_lsdb_count_all (ospf->lsdb), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002509
2510 /* Show number of areas attached. */
2511 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002512 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002513
2514 /* Show each area status. */
paul68980082003-03-25 05:07:42 +00002515 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002516 if ((area = getdata (node)) != NULL)
2517 show_ip_ospf_area (vty, area);
2518
2519 return CMD_SUCCESS;
2520}
2521
2522
2523void
paul68980082003-03-25 05:07:42 +00002524show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2525 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002526{
2527 struct ospf_neighbor *nbr;
2528 int oi_count;
2529 struct route_node *rn;
2530 char buf[9];
2531
2532 oi_count = ospf_oi_count (ifp);
2533
2534 /* Is interface up? */
paul2e3b2e42002-12-13 21:03:13 +00002535 if (if_is_operative (ifp)) {
2536 vty_out (vty, "%s is up%s", ifp->name, VTY_NEWLINE);
2537 } else
2538 {
2539 vty_out (vty, "%s is down%s", ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002540
2541
2542 if (oi_count == 0)
2543 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2544 else
2545 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2546 VTY_NEWLINE);
2547 return;
2548 }
2549
2550 /* Is interface OSPF enabled? */
2551 if (oi_count == 0)
2552 {
2553 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2554 return;
2555 }
2556
2557 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2558 {
2559 struct ospf_interface *oi = rn->info;
2560
2561 if (oi == NULL)
2562 continue;
2563
2564 /* Show OSPF interface information. */
2565 vty_out (vty, " Internet Address %s/%d,",
2566 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2567
2568 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2569 VTY_NEWLINE);
2570
2571 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002572 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002573 oi->output_cost, VTY_NEWLINE);
2574
2575 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2576 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2577 PRIORITY (oi), VTY_NEWLINE);
2578
2579 /* Show DR information. */
2580 if (DR (oi).s_addr == 0)
2581 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2582 else
2583 {
2584 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2585 if (nbr == NULL)
2586 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2587 else
2588 {
2589 vty_out (vty, " Designated Router (ID) %s,",
2590 inet_ntoa (nbr->router_id));
2591 vty_out (vty, " Interface Address %s%s",
2592 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2593 }
2594 }
2595
2596 /* Show BDR information. */
2597 if (BDR (oi).s_addr == 0)
2598 vty_out (vty, " No backup designated router on this network%s",
2599 VTY_NEWLINE);
2600 else
2601 {
2602 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2603 if (nbr == NULL)
2604 vty_out (vty, " No backup designated router on this network%s",
2605 VTY_NEWLINE);
2606 else
2607 {
2608 vty_out (vty, " Backup Designated Router (ID) %s,",
2609 inet_ntoa (nbr->router_id));
2610 vty_out (vty, " Interface Address %s%s",
2611 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2612 }
2613 }
2614 vty_out (vty, " Timer intervals configured,");
2615 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2616 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2617 OSPF_IF_PARAM (oi, v_wait),
2618 OSPF_IF_PARAM (oi, retransmit_interval),
2619 VTY_NEWLINE);
2620
2621 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2622 vty_out (vty, " Hello due in %s%s",
2623 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2624 else /* OSPF_IF_PASSIVE is set */
2625 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2626
2627 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002628 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002629 VTY_NEWLINE);
2630 }
2631}
2632
2633DEFUN (show_ip_ospf_interface,
2634 show_ip_ospf_interface_cmd,
2635 "show ip ospf interface [INTERFACE]",
2636 SHOW_STR
2637 IP_STR
2638 "OSPF information\n"
2639 "Interface information\n"
2640 "Interface name\n")
2641{
2642 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002643 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002644 listnode node;
2645
paul020709f2003-04-04 02:44:16 +00002646 ospf = ospf_lookup ();
2647
paul718e3742002-12-13 20:15:29 +00002648 /* Show All Interfaces. */
2649 if (argc == 0)
2650 for (node = listhead (iflist); node; nextnode (node))
paul68980082003-03-25 05:07:42 +00002651 show_ip_ospf_interface_sub (vty, ospf, node->data);
paul718e3742002-12-13 20:15:29 +00002652 /* Interface name is specified. */
2653 else
2654 {
2655 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2656 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2657 else
paul68980082003-03-25 05:07:42 +00002658 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002659 }
2660
2661 return CMD_SUCCESS;
2662}
2663
2664void
2665show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2666{
2667 struct route_node *rn;
2668 struct ospf_neighbor *nbr;
2669 char msgbuf[16];
2670 char timebuf[9];
2671
2672 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2673 if ((nbr = rn->info))
2674 /* Do not show myself. */
2675 if (nbr != oi->nbr_self)
2676 /* Down state is not shown. */
2677 if (nbr->state != NSM_Down)
2678 {
2679 ospf_nbr_state_message (nbr, msgbuf, 16);
2680
2681 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2682 vty_out (vty, "%-15s %3d %-15s %8s ",
2683 "-", nbr->priority,
2684 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2685 else
2686 vty_out (vty, "%-15s %3d %-15s %8s ",
2687 inet_ntoa (nbr->router_id), nbr->priority,
2688 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2689 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2690 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2691 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2692 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2693 VTY_NEWLINE);
2694 }
2695}
2696
2697DEFUN (show_ip_ospf_neighbor,
2698 show_ip_ospf_neighbor_cmd,
2699 "show ip ospf neighbor",
2700 SHOW_STR
2701 IP_STR
2702 "OSPF information\n"
2703 "Neighbor list\n")
2704{
paul020709f2003-04-04 02:44:16 +00002705 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002706 listnode node;
2707
paul020709f2003-04-04 02:44:16 +00002708 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002709 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002710 {
2711 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2712 return CMD_SUCCESS;
2713 }
2714
2715 /* Show All neighbors. */
2716 vty_out (vty, "%sNeighbor ID Pri State Dead "
2717 "Time Address Interface RXmtL "
2718 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2719
paul68980082003-03-25 05:07:42 +00002720 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul020709f2003-04-04 02:44:16 +00002721 show_ip_ospf_neighbor_sub (vty, getdata (node));
paul718e3742002-12-13 20:15:29 +00002722
2723 return CMD_SUCCESS;
2724}
2725
2726DEFUN (show_ip_ospf_neighbor_all,
2727 show_ip_ospf_neighbor_all_cmd,
2728 "show ip ospf neighbor all",
2729 SHOW_STR
2730 IP_STR
2731 "OSPF information\n"
2732 "Neighbor list\n"
2733 "include down status neighbor\n")
2734{
paul68980082003-03-25 05:07:42 +00002735 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002736 listnode node;
2737
paul68980082003-03-25 05:07:42 +00002738 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002739 {
2740 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2741 return CMD_SUCCESS;
2742 }
2743
2744 /* Show All neighbors. */
2745 vty_out (vty, "%sNeighbor ID Pri State Dead "
2746 "Time Address Interface RXmtL "
2747 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2748
paul68980082003-03-25 05:07:42 +00002749 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002750 {
2751 struct ospf_interface *oi = getdata (node);
2752 listnode nbr_node;
2753
2754 show_ip_ospf_neighbor_sub (vty, oi);
2755
2756 /* print Down neighbor status */
2757 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
2758 {
2759 struct ospf_nbr_nbma *nbr_nbma;
2760
2761 nbr_nbma = getdata (nbr_node);
2762
2763 if (nbr_nbma->nbr == NULL
2764 || nbr_nbma->nbr->state == NSM_Down)
2765 {
2766 vty_out (vty, "%-15s %3d %-15s %8s ",
2767 "-", nbr_nbma->priority, "Down", "-");
2768 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2769 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2770 0, 0, 0, VTY_NEWLINE);
2771 }
2772 }
2773 }
2774
2775 return CMD_SUCCESS;
2776}
2777
2778DEFUN (show_ip_ospf_neighbor_int,
2779 show_ip_ospf_neighbor_int_cmd,
2780 "show ip ospf neighbor A.B.C.D",
2781 SHOW_STR
2782 IP_STR
2783 "OSPF information\n"
2784 "Neighbor list\n"
2785 "Interface name\n")
2786{
paul020709f2003-04-04 02:44:16 +00002787 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002788 struct ospf_interface *oi;
2789 struct in_addr addr;
2790 int ret;
2791
paul718e3742002-12-13 20:15:29 +00002792 ret = inet_aton (argv[0], &addr);
2793 if (!ret)
2794 {
2795 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2796 VTY_NEWLINE);
2797 return CMD_WARNING;
2798 }
2799
paul020709f2003-04-04 02:44:16 +00002800 ospf = ospf_lookup ();
2801 if (ospf == NULL)
2802 {
2803 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2804 return CMD_SUCCESS;
2805 }
2806
paul68980082003-03-25 05:07:42 +00002807 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00002808 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2809 else
2810 {
2811 vty_out (vty, "%sNeighbor ID Pri State Dead "
2812 "Time Address Interface RXmtL "
2813 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2814 show_ip_ospf_neighbor_sub (vty, oi);
2815 }
2816
2817 return CMD_SUCCESS;
2818}
2819
2820void
2821show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2822 struct ospf_nbr_nbma *nbr_nbma)
2823{
2824 char timebuf[9];
2825
2826 /* Show neighbor ID. */
2827 vty_out (vty, " Neighbor %s,", "-");
2828
2829 /* Show interface address. */
2830 vty_out (vty, " interface address %s%s",
2831 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2832 /* Show Area ID. */
2833 vty_out (vty, " In the area %s via interface %s%s",
2834 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2835 /* Show neighbor priority and state. */
2836 vty_out (vty, " Neighbor priority is %d, State is %s,",
2837 nbr_nbma->priority, "Down");
2838 /* Show state changes. */
2839 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2840
2841 /* Show PollInterval */
2842 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2843
2844 /* Show poll-interval timer. */
2845 vty_out (vty, " Poll timer due in %s%s",
2846 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2847
2848 /* Show poll-interval timer thread. */
2849 vty_out (vty, " Thread Poll Timer %s%s",
2850 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2851}
2852
2853void
2854show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2855 struct ospf_neighbor *nbr)
2856{
2857 char timebuf[9];
2858
2859 /* Show neighbor ID. */
2860 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2861 vty_out (vty, " Neighbor %s,", "-");
2862 else
2863 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2864
2865 /* Show interface address. */
2866 vty_out (vty, " interface address %s%s",
2867 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2868 /* Show Area ID. */
2869 vty_out (vty, " In the area %s via interface %s%s",
2870 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2871 /* Show neighbor priority and state. */
2872 vty_out (vty, " Neighbor priority is %d, State is %s,",
2873 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2874 /* Show state changes. */
2875 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2876
2877 /* Show Designated Rotuer ID. */
2878 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2879 /* Show Backup Designated Rotuer ID. */
2880 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2881 /* Show options. */
2882 vty_out (vty, " Options %d %s%s", nbr->options,
2883 ospf_options_dump (nbr->options), VTY_NEWLINE);
2884 /* Show Router Dead interval timer. */
2885 vty_out (vty, " Dead timer due in %s%s",
2886 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2887 /* Show Database Summary list. */
2888 vty_out (vty, " Database Summary List %d%s",
2889 ospf_db_summary_count (nbr), VTY_NEWLINE);
2890 /* Show Link State Request list. */
2891 vty_out (vty, " Link State Request List %ld%s",
2892 ospf_ls_request_count (nbr), VTY_NEWLINE);
2893 /* Show Link State Retransmission list. */
2894 vty_out (vty, " Link State Retransmission List %ld%s",
2895 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2896 /* Show inactivity timer thread. */
2897 vty_out (vty, " Thread Inactivity Timer %s%s",
2898 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2899 /* Show Database Description retransmission thread. */
2900 vty_out (vty, " Thread Database Description Retransmision %s%s",
2901 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2902 /* Show Link State Request Retransmission thread. */
2903 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2904 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2905 /* Show Link State Update Retransmission thread. */
2906 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2907 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2908}
2909
2910DEFUN (show_ip_ospf_neighbor_id,
2911 show_ip_ospf_neighbor_id_cmd,
2912 "show ip ospf neighbor A.B.C.D",
2913 SHOW_STR
2914 IP_STR
2915 "OSPF information\n"
2916 "Neighbor list\n"
2917 "Neighbor ID\n")
2918{
paul020709f2003-04-04 02:44:16 +00002919 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002920 listnode node;
2921 struct ospf_neighbor *nbr;
2922 struct in_addr router_id;
2923 int ret;
2924
2925 ret = inet_aton (argv[0], &router_id);
2926 if (!ret)
2927 {
2928 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
2929 return CMD_WARNING;
2930 }
2931
paul020709f2003-04-04 02:44:16 +00002932 ospf = ospf_lookup ();
2933 if (ospf == NULL)
2934 {
2935 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2936 return CMD_SUCCESS;
2937 }
2938
paul68980082003-03-25 05:07:42 +00002939 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002940 {
2941 struct ospf_interface *oi = getdata (node);
2942
2943 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
2944 {
2945 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2946 return CMD_SUCCESS;
2947 }
2948 }
2949
2950 /* Nothing to show. */
2951 return CMD_SUCCESS;
2952}
2953
2954DEFUN (show_ip_ospf_neighbor_detail,
2955 show_ip_ospf_neighbor_detail_cmd,
2956 "show ip ospf neighbor detail",
2957 SHOW_STR
2958 IP_STR
2959 "OSPF information\n"
2960 "Neighbor list\n"
2961 "detail of all neighbors\n")
2962{
paul020709f2003-04-04 02:44:16 +00002963 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002964 listnode node;
2965
paul020709f2003-04-04 02:44:16 +00002966 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002967 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00002968 {
2969 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2970 return CMD_SUCCESS;
2971 }
paul718e3742002-12-13 20:15:29 +00002972
paul68980082003-03-25 05:07:42 +00002973 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002974 {
2975 struct ospf_interface *oi = getdata (node);
2976 struct route_node *rn;
2977 struct ospf_neighbor *nbr;
2978
2979 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2980 if ((nbr = rn->info))
2981 if (nbr != oi->nbr_self)
2982 if (nbr->state != NSM_Down)
2983 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2984 }
2985
2986 return CMD_SUCCESS;
2987}
2988
2989DEFUN (show_ip_ospf_neighbor_detail_all,
2990 show_ip_ospf_neighbor_detail_all_cmd,
2991 "show ip ospf neighbor detail all",
2992 SHOW_STR
2993 IP_STR
2994 "OSPF information\n"
2995 "Neighbor list\n"
2996 "detail of all neighbors\n"
2997 "include down status neighbor\n")
2998{
paul020709f2003-04-04 02:44:16 +00002999 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003000 listnode node;
3001
paul020709f2003-04-04 02:44:16 +00003002 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003003 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003004 {
3005 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3006 return CMD_SUCCESS;
3007 }
paul718e3742002-12-13 20:15:29 +00003008
paul68980082003-03-25 05:07:42 +00003009 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003010 {
3011 struct ospf_interface *oi = getdata (node);
3012 struct route_node *rn;
3013 struct ospf_neighbor *nbr;
3014
3015 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3016 if ((nbr = rn->info))
3017 if (nbr != oi->nbr_self)
3018 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3019 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3020
3021 if (oi->type == OSPF_IFTYPE_NBMA)
3022 {
3023 listnode nd;
3024
3025 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
3026 {
3027 struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
3028 if (nbr_nbma->nbr == NULL
3029 || nbr_nbma->nbr->state == NSM_Down)
3030 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3031 }
3032 }
3033 }
3034
3035 return CMD_SUCCESS;
3036}
3037
3038DEFUN (show_ip_ospf_neighbor_int_detail,
3039 show_ip_ospf_neighbor_int_detail_cmd,
3040 "show ip ospf neighbor A.B.C.D detail",
3041 SHOW_STR
3042 IP_STR
3043 "OSPF information\n"
3044 "Neighbor list\n"
3045 "Interface address\n"
3046 "detail of all neighbors")
3047{
paul020709f2003-04-04 02:44:16 +00003048 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003049 struct ospf_interface *oi;
3050 struct in_addr addr;
3051 int ret;
3052
3053 ret = inet_aton (argv[0], &addr);
3054 if (!ret)
3055 {
3056 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3057 VTY_NEWLINE);
3058 return CMD_WARNING;
3059 }
3060
paul020709f2003-04-04 02:44:16 +00003061 ospf = ospf_lookup ();
3062 if (ospf == NULL)
3063 {
3064 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3065 return CMD_SUCCESS;
3066 }
paul68980082003-03-25 05:07:42 +00003067
paul020709f2003-04-04 02:44:16 +00003068 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00003069 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3070 else
3071 {
3072 struct route_node *rn;
3073 struct ospf_neighbor *nbr;
3074
3075 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3076 if ((nbr = rn->info))
3077 if (nbr != oi->nbr_self)
3078 if (nbr->state != NSM_Down)
3079 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3080 }
3081
3082 return CMD_SUCCESS;
3083}
3084
3085
3086/* Show functions */
3087int
paul020709f2003-04-04 02:44:16 +00003088show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003089{
paul718e3742002-12-13 20:15:29 +00003090 struct router_lsa *rl;
3091 struct summary_lsa *sl;
3092 struct as_external_lsa *asel;
3093 struct prefix_ipv4 p;
3094
3095 if (lsa != NULL)
3096 /* If self option is set, check LSA self flag. */
3097 if (self == 0 || IS_LSA_SELF (lsa))
3098 {
3099 /* LSA common part show. */
3100 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3101 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3102 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3103 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3104 /* LSA specific part show. */
3105 switch (lsa->data->type)
3106 {
3107 case OSPF_ROUTER_LSA:
3108 rl = (struct router_lsa *) lsa->data;
3109 vty_out (vty, " %-d", ntohs (rl->links));
3110 break;
3111 case OSPF_SUMMARY_LSA:
3112 sl = (struct summary_lsa *) lsa->data;
3113
3114 p.family = AF_INET;
3115 p.prefix = sl->header.id;
3116 p.prefixlen = ip_masklen (sl->mask);
3117 apply_mask_ipv4 (&p);
3118
3119 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3120 break;
3121 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003122#ifdef HAVE_NSSA
3123 case OSPF_AS_NSSA_LSA:
3124#endif /* HAVE_NSSA */
paul718e3742002-12-13 20:15:29 +00003125 asel = (struct as_external_lsa *) lsa->data;
3126
3127 p.family = AF_INET;
3128 p.prefix = asel->header.id;
3129 p.prefixlen = ip_masklen (asel->mask);
3130 apply_mask_ipv4 (&p);
3131
3132 vty_out (vty, " %s %s/%d [0x%lx]",
3133 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3134 inet_ntoa (p.prefix), p.prefixlen,
3135 (u_long)ntohl (asel->e[0].route_tag));
3136 break;
3137 case OSPF_NETWORK_LSA:
3138 case OSPF_ASBR_SUMMARY_LSA:
3139#ifdef HAVE_OPAQUE_LSA
3140 case OSPF_OPAQUE_LINK_LSA:
3141 case OSPF_OPAQUE_AREA_LSA:
3142 case OSPF_OPAQUE_AS_LSA:
3143#endif /* HAVE_OPAQUE_LSA */
3144 default:
3145 break;
3146 }
3147 vty_out (vty, VTY_NEWLINE);
3148 }
3149
3150 return 0;
3151}
3152
3153char *show_database_desc[] =
3154{
3155 "unknown",
3156 "Router Link States",
3157 "Net Link States",
3158 "Summary Link States",
3159 "ASBR-Summary Link States",
3160 "AS External Link States",
3161#if defined (HAVE_NSSA) || defined (HAVE_OPAQUE_LSA)
3162 "Group Membership LSA",
3163 "NSSA-external Link States",
3164#endif /* HAVE_NSSA */
3165#ifdef HAVE_OPAQUE_LSA
3166 "Type-8 LSA",
3167 "Link-Local Opaque-LSA",
3168 "Area-Local Opaque-LSA",
3169 "AS-external Opaque-LSA",
3170#endif /* HAVE_OPAQUE_LSA */
3171};
3172
3173#define SHOW_OSPF_COMMON_HEADER \
3174 "Link ID ADV Router Age Seq# CkSum"
3175
3176char *show_database_header[] =
3177{
3178 "",
3179 "Link ID ADV Router Age Seq# CkSum Link count",
3180 "Link ID ADV Router Age Seq# CkSum",
3181 "Link ID ADV Router Age Seq# CkSum Route",
3182 "Link ID ADV Router Age Seq# CkSum",
3183 "Link ID ADV Router Age Seq# CkSum Route",
3184#ifdef HAVE_NSSA
3185 " --- header for Group Member ----",
3186 "Link ID ADV Router Age Seq# CkSum Route",
3187#endif /* HAVE_NSSA */
3188#ifdef HAVE_OPAQUE_LSA
3189#ifndef HAVE_NSSA
3190 " --- type-6 ---",
3191 " --- type-7 ---",
3192#endif /* HAVE_NSSA */
3193 " --- type-8 ---",
3194 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3195 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3196 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3197#endif /* HAVE_OPAQUE_LSA */
3198};
3199
paul4957f492003-06-27 01:28:45 +00003200char *show_lsa_flags[] =
3201{
3202 "Self-originated",
3203 "Checked",
3204 "Received",
3205 "Approved",
3206 "Discard",
3207#ifdef HAVE_NSSA
3208 "Translated",
3209#endif
3210};
3211
paul718e3742002-12-13 20:15:29 +00003212void
3213show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3214{
3215 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003216
paul718e3742002-12-13 20:15:29 +00003217 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003218 vty_out (vty, " Options: 0x%-2x : %s%s",
3219 lsa->data->options,
3220 ospf_options_dump(lsa->data->options),
3221 VTY_NEWLINE);
3222 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003223 lsa->flags,
3224#ifdef HAVE_NSSA
paul4957f492003-06-27 01:28:45 +00003225 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
paul9d526032003-06-30 22:46:14 +00003226#else
3227 "",
3228#endif /* HAVE_NSSA */
paul4957f492003-06-27 01:28:45 +00003229 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003230
3231 if (lsa->data->type == OSPF_ROUTER_LSA)
3232 {
3233 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3234
3235 if (rlsa->flags)
3236 vty_out (vty, " :%s%s%s%s",
3237 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3238 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3239 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3240 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3241
3242 vty_out (vty, "%s", VTY_NEWLINE);
3243 }
3244 vty_out (vty, " LS Type: %s%s",
3245 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3246 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3247 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3248 vty_out (vty, " Advertising Router: %s%s",
3249 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3250 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3251 VTY_NEWLINE);
3252 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3253 VTY_NEWLINE);
3254 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3255}
3256
3257char *link_type_desc[] =
3258{
3259 "(null)",
3260 "another Router (point-to-point)",
3261 "a Transit Network",
3262 "Stub Network",
3263 "a Virtual Link",
3264};
3265
3266char *link_id_desc[] =
3267{
3268 "(null)",
3269 "Neighboring Router ID",
3270 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003271 "Net",
paul718e3742002-12-13 20:15:29 +00003272 "Neighboring Router ID",
3273};
3274
3275char *link_data_desc[] =
3276{
3277 "(null)",
3278 "Router Interface address",
3279 "Router Interface address",
3280 "Network Mask",
3281 "Router Interface address",
3282};
3283
3284/* Show router-LSA each Link information. */
3285void
3286show_ip_ospf_database_router_links (struct vty *vty,
3287 struct router_lsa *rl)
3288{
3289 int len, i, type;
3290
3291 len = ntohs (rl->header.length) - 4;
3292 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3293 {
3294 type = rl->link[i].type;
3295
3296 vty_out (vty, " Link connected to: %s%s",
3297 link_type_desc[type], VTY_NEWLINE);
3298 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3299 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3300 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3301 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3302 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3303 vty_out (vty, " TOS 0 Metric: %d%s",
3304 ntohs (rl->link[i].metric), VTY_NEWLINE);
3305 vty_out (vty, "%s", VTY_NEWLINE);
3306 }
3307}
3308
3309/* Show router-LSA detail information. */
3310int
3311show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3312{
3313 if (lsa != NULL)
3314 {
3315 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3316
3317 show_ip_ospf_database_header (vty, lsa);
3318
3319 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3320 VTY_NEWLINE, VTY_NEWLINE);
3321
3322 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003323 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003324 }
3325
3326 return 0;
3327}
3328
3329/* Show network-LSA detail information. */
3330int
3331show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3332{
3333 int length, i;
3334
3335 if (lsa != NULL)
3336 {
3337 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3338
3339 show_ip_ospf_database_header (vty, lsa);
3340
3341 vty_out (vty, " Network Mask: /%d%s",
3342 ip_masklen (nl->mask), VTY_NEWLINE);
3343
3344 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3345
3346 for (i = 0; length > 0; i++, length -= 4)
3347 vty_out (vty, " Attached Router: %s%s",
3348 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3349
3350 vty_out (vty, "%s", VTY_NEWLINE);
3351 }
3352
3353 return 0;
3354}
3355
3356/* Show summary-LSA detail information. */
3357int
3358show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3359{
3360 if (lsa != NULL)
3361 {
3362 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3363
3364 show_ip_ospf_database_header (vty, lsa);
3365
3366 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3367 VTY_NEWLINE);
3368 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3369 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003370 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003371 }
3372
3373 return 0;
3374}
3375
3376/* Show summary-ASBR-LSA detail information. */
3377int
3378show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3379{
3380 if (lsa != NULL)
3381 {
3382 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3383
3384 show_ip_ospf_database_header (vty, lsa);
3385
3386 vty_out (vty, " Network Mask: /%d%s",
3387 ip_masklen (sl->mask), VTY_NEWLINE);
3388 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3389 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003390 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003391 }
3392
3393 return 0;
3394}
3395
3396/* Show AS-external-LSA detail information. */
3397int
3398show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3399{
3400 if (lsa != NULL)
3401 {
3402 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3403
3404 show_ip_ospf_database_header (vty, lsa);
3405
3406 vty_out (vty, " Network Mask: /%d%s",
3407 ip_masklen (al->mask), VTY_NEWLINE);
3408 vty_out (vty, " Metric Type: %s%s",
3409 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3410 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3411 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3412 vty_out (vty, " Metric: %d%s",
3413 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3414 vty_out (vty, " Forward Address: %s%s",
3415 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3416
3417 vty_out (vty, " External Route Tag: %lu%s%s",
3418 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3419 }
3420
3421 return 0;
3422}
3423
3424#ifdef HAVE_NSSA
3425int
3426show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3427{
3428 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3429
3430 /* show_ip_ospf_database_header (vty, lsa); */
3431
3432 zlog_info( " Network Mask: /%d%s",
3433 ip_masklen (al->mask), "\n");
3434 zlog_info( " Metric Type: %s%s",
3435 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3436 "2 (Larger than any link state path)" : "1", "\n");
3437 zlog_info( " TOS: 0%s", "\n");
3438 zlog_info( " Metric: %d%s",
3439 GET_METRIC (al->e[0].metric), "\n");
3440 zlog_info( " Forward Address: %s%s",
3441 inet_ntoa (al->e[0].fwd_addr), "\n");
3442
3443 zlog_info( " External Route Tag: %u%s%s",
3444 ntohl (al->e[0].route_tag), "\n", "\n");
3445
3446 return 0;
3447}
3448
3449/* Show AS-NSSA-LSA detail information. */
3450int
3451show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3452{
3453 if (lsa != NULL)
3454 {
3455 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3456
3457 show_ip_ospf_database_header (vty, lsa);
3458
3459 vty_out (vty, " Network Mask: /%d%s",
3460 ip_masklen (al->mask), VTY_NEWLINE);
3461 vty_out (vty, " Metric Type: %s%s",
3462 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3463 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3464 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3465 vty_out (vty, " Metric: %d%s",
3466 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3467 vty_out (vty, " NSSA: Forward Address: %s%s",
3468 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3469
3470 vty_out (vty, " External Route Tag: %u%s%s",
3471 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3472 }
3473
3474 return 0;
3475}
3476
3477#endif /* HAVE_NSSA */
3478
3479int
3480show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3481{
3482 return 0;
3483}
3484
3485#ifdef HAVE_OPAQUE_LSA
3486int
3487show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3488{
3489 if (lsa != NULL)
3490 {
3491 show_ip_ospf_database_header (vty, lsa);
3492 show_opaque_info_detail (vty, lsa);
3493
3494 vty_out (vty, "%s", VTY_NEWLINE);
3495 }
3496 return 0;
3497}
3498#endif /* HAVE_OPAQUE_LSA */
3499
3500int (*show_function[])(struct vty *, struct ospf_lsa *) =
3501{
3502 NULL,
3503 show_router_lsa_detail,
3504 show_network_lsa_detail,
3505 show_summary_lsa_detail,
3506 show_summary_asbr_lsa_detail,
3507 show_as_external_lsa_detail,
3508#ifdef HAVE_NSSA
3509 show_func_dummy,
3510 show_as_nssa_lsa_detail, /* almost same as external */
3511#endif /* HAVE_NSSA */
3512#ifdef HAVE_OPAQUE_LSA
3513#ifndef HAVE_NSSA
3514 show_func_dummy,
3515 show_func_dummy,
3516#endif /* HAVE_NSSA */
3517 NULL, /* type-8 */
3518 show_opaque_lsa_detail,
3519 show_opaque_lsa_detail,
3520 show_opaque_lsa_detail,
3521#endif /* HAVE_OPAQUE_LSA */
3522};
3523
3524void
3525show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3526 struct in_addr *adv_router)
3527{
3528 memset (lp, 0, sizeof (struct prefix_ls));
3529 lp->family = 0;
3530 if (id == NULL)
3531 lp->prefixlen = 0;
3532 else if (adv_router == NULL)
3533 {
3534 lp->prefixlen = 32;
3535 lp->id = *id;
3536 }
3537 else
3538 {
3539 lp->prefixlen = 64;
3540 lp->id = *id;
3541 lp->adv_router = *adv_router;
3542 }
3543}
3544
3545void
3546show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3547 struct in_addr *id, struct in_addr *adv_router)
3548{
3549 struct prefix_ls lp;
3550 struct route_node *rn, *start;
3551 struct ospf_lsa *lsa;
3552
3553 show_lsa_prefix_set (vty, &lp, id, adv_router);
3554 start = route_node_get (rt, (struct prefix *) &lp);
3555 if (start)
3556 {
3557 route_lock_node (start);
3558 for (rn = start; rn; rn = route_next_until (rn, start))
3559 if ((lsa = rn->info))
3560 {
paul718e3742002-12-13 20:15:29 +00003561 if (show_function[lsa->data->type] != NULL)
3562 show_function[lsa->data->type] (vty, lsa);
3563 }
3564 route_unlock_node (start);
3565 }
3566}
3567
3568/* Show detail LSA information
3569 -- if id is NULL then show all LSAs. */
3570void
paul020709f2003-04-04 02:44:16 +00003571show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003572 struct in_addr *id, struct in_addr *adv_router)
3573{
3574 listnode node;
3575
3576 switch (type)
3577 {
3578 case OSPF_AS_EXTERNAL_LSA:
3579#ifdef HAVE_OPAQUE_LSA
3580 case OSPF_OPAQUE_AS_LSA:
3581#endif /* HAVE_OPAQUE_LSA */
3582 vty_out (vty, " %s %s%s",
3583 show_database_desc[type],
3584 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003585 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003586 break;
3587 default:
paul68980082003-03-25 05:07:42 +00003588 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003589 {
3590 struct ospf_area *area = node->data;
3591 vty_out (vty, "%s %s (Area %s)%s%s",
3592 VTY_NEWLINE, show_database_desc[type],
3593 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3594 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3595 }
3596 break;
3597 }
3598}
3599
3600void
3601show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3602 struct in_addr *adv_router)
3603{
3604 struct route_node *rn;
3605 struct ospf_lsa *lsa;
3606
3607 for (rn = route_top (rt); rn; rn = route_next (rn))
3608 if ((lsa = rn->info))
3609 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3610 {
3611#ifdef HAVE_NSSA
3612 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3613 continue;
3614#endif /* HAVE_NSSA */
3615 if (show_function[lsa->data->type] != NULL)
3616 show_function[lsa->data->type] (vty, lsa);
3617 }
3618}
3619
3620/* Show detail LSA information. */
3621void
paul020709f2003-04-04 02:44:16 +00003622show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003623 struct in_addr *adv_router)
3624{
3625 listnode node;
3626
3627 switch (type)
3628 {
3629 case OSPF_AS_EXTERNAL_LSA:
3630#ifdef HAVE_OPAQUE_LSA
3631 case OSPF_OPAQUE_AS_LSA:
3632#endif /* HAVE_OPAQUE_LSA */
3633 vty_out (vty, " %s %s%s",
3634 show_database_desc[type],
3635 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003636 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003637 adv_router);
3638 break;
3639 default:
paul68980082003-03-25 05:07:42 +00003640 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003641 {
3642 struct ospf_area *area = node->data;
3643 vty_out (vty, "%s %s (Area %s)%s%s",
3644 VTY_NEWLINE, show_database_desc[type],
3645 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3646 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3647 adv_router);
3648 }
3649 break;
3650 }
3651}
3652
3653void
paul020709f2003-04-04 02:44:16 +00003654show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003655{
paul020709f2003-04-04 02:44:16 +00003656 struct ospf_lsa *lsa;
3657 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00003658 listnode node;
3659 int type;
3660
paul68980082003-03-25 05:07:42 +00003661 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003662 {
3663 struct ospf_area *area = node->data;
3664 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3665 {
3666 switch (type)
3667 {
3668 case OSPF_AS_EXTERNAL_LSA:
3669#ifdef HAVE_OPAQUE_LSA
3670 case OSPF_OPAQUE_AS_LSA:
3671#endif /* HAVE_OPAQUE_LSA */
3672 continue;
3673 default:
3674 break;
3675 }
3676 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3677 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3678 {
3679 vty_out (vty, " %s (Area %s)%s%s",
3680 show_database_desc[type],
3681 ospf_area_desc_string (area),
3682 VTY_NEWLINE, VTY_NEWLINE);
3683 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3684
paul020709f2003-04-04 02:44:16 +00003685 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3686 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003687
3688 vty_out (vty, "%s", VTY_NEWLINE);
3689 }
3690 }
3691 }
3692
3693 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3694 {
3695 switch (type)
3696 {
3697 case OSPF_AS_EXTERNAL_LSA:
3698#ifdef HAVE_OPAQUE_LSA
3699 case OSPF_OPAQUE_AS_LSA:
3700#endif /* HAVE_OPAQUE_LSA */
3701 break;;
3702 default:
3703 continue;
3704 }
paul68980082003-03-25 05:07:42 +00003705 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3706 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003707 {
3708 vty_out (vty, " %s%s%s",
3709 show_database_desc[type],
3710 VTY_NEWLINE, VTY_NEWLINE);
3711 vty_out (vty, "%s%s", show_database_header[type],
3712 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003713
3714 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3715 show_lsa_summary (vty, lsa, self);
3716
paul718e3742002-12-13 20:15:29 +00003717 vty_out (vty, "%s", VTY_NEWLINE);
3718 }
3719 }
3720
3721 vty_out (vty, "%s", VTY_NEWLINE);
3722}
3723
3724void
paul020709f2003-04-04 02:44:16 +00003725show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003726{
3727 listnode node;
3728 struct ospf_lsa *lsa;
3729
3730 vty_out (vty, "%s MaxAge Link States:%s%s",
3731 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3732
paul68980082003-03-25 05:07:42 +00003733 for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003734 if ((lsa = node->data) != NULL)
3735 {
3736 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3737 vty_out (vty, "Link State ID: %s%s",
3738 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3739 vty_out (vty, "Advertising Router: %s%s",
3740 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3741 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3742 vty_out (vty, "%s", VTY_NEWLINE);
3743 }
3744}
3745
3746#ifdef HAVE_NSSA
3747#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3748#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
3749#else /* HAVE_NSSA */
3750#define OSPF_LSA_TYPE_NSSA_DESC ""
3751#define OSPF_LSA_TYPE_NSSA_CMD_STR ""
3752#endif /* HAVE_NSSA */
3753
3754#ifdef HAVE_OPAQUE_LSA
3755#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3756#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3757#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3758#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3759#else /* HAVE_OPAQUE_LSA */
3760#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3761#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3762#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3763#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3764#endif /* HAVE_OPAQUE_LSA */
3765
3766#define OSPF_LSA_TYPES_CMD_STR \
3767 "asbr-summary|external|network|router|summary" \
3768 OSPF_LSA_TYPE_NSSA_CMD_STR \
3769 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3770
3771#define OSPF_LSA_TYPES_DESC \
3772 "ASBR summary link states\n" \
3773 "External link states\n" \
3774 "Network link states\n" \
3775 "Router link states\n" \
3776 "Network summary link states\n" \
3777 OSPF_LSA_TYPE_NSSA_DESC \
3778 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3779 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3780 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3781
3782DEFUN (show_ip_ospf_database,
3783 show_ip_ospf_database_cmd,
3784 "show ip ospf database",
3785 SHOW_STR
3786 IP_STR
3787 "OSPF information\n"
3788 "Database summary\n")
3789{
paul020709f2003-04-04 02:44:16 +00003790 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003791 int type, ret;
3792 struct in_addr id, adv_router;
3793
paul020709f2003-04-04 02:44:16 +00003794 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003795 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003796 return CMD_SUCCESS;
3797
3798 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003799 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003800
3801 /* Show all LSA. */
3802 if (argc == 0)
3803 {
paul020709f2003-04-04 02:44:16 +00003804 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003805 return CMD_SUCCESS;
3806 }
3807
3808 /* Set database type to show. */
3809 if (strncmp (argv[0], "r", 1) == 0)
3810 type = OSPF_ROUTER_LSA;
3811 else if (strncmp (argv[0], "ne", 2) == 0)
3812 type = OSPF_NETWORK_LSA;
3813#ifdef HAVE_NSSA
3814 else if (strncmp (argv[0], "ns", 2) == 0)
3815 type = OSPF_AS_NSSA_LSA;
3816#endif /* HAVE_NSSA */
3817 else if (strncmp (argv[0], "su", 2) == 0)
3818 type = OSPF_SUMMARY_LSA;
3819 else if (strncmp (argv[0], "a", 1) == 0)
3820 type = OSPF_ASBR_SUMMARY_LSA;
3821 else if (strncmp (argv[0], "e", 1) == 0)
3822 type = OSPF_AS_EXTERNAL_LSA;
3823 else if (strncmp (argv[0], "se", 2) == 0)
3824 {
paul020709f2003-04-04 02:44:16 +00003825 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003826 return CMD_SUCCESS;
3827 }
3828 else if (strncmp (argv[0], "m", 1) == 0)
3829 {
paul020709f2003-04-04 02:44:16 +00003830 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003831 return CMD_SUCCESS;
3832 }
3833#ifdef HAVE_OPAQUE_LSA
3834 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3835 type = OSPF_OPAQUE_LINK_LSA;
3836 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3837 type = OSPF_OPAQUE_AREA_LSA;
3838 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3839 type = OSPF_OPAQUE_AS_LSA;
3840#endif /* HAVE_OPAQUE_LSA */
3841 else
3842 return CMD_WARNING;
3843
3844 /* `show ip ospf database LSA'. */
3845 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003846 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003847 else if (argc >= 2)
3848 {
3849 ret = inet_aton (argv[1], &id);
3850 if (!ret)
3851 return CMD_WARNING;
3852
3853 /* `show ip ospf database LSA ID'. */
3854 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003855 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003856 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3857 else if (argc == 3)
3858 {
3859 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003860 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003861 else
3862 {
3863 ret = inet_aton (argv[2], &adv_router);
3864 if (!ret)
3865 return CMD_WARNING;
3866 }
paul020709f2003-04-04 02:44:16 +00003867 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003868 }
3869 }
3870
3871 return CMD_SUCCESS;
3872}
3873
3874ALIAS (show_ip_ospf_database,
3875 show_ip_ospf_database_type_cmd,
3876 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3877 SHOW_STR
3878 IP_STR
3879 "OSPF information\n"
3880 "Database summary\n"
3881 OSPF_LSA_TYPES_DESC
3882 "LSAs in MaxAge list\n"
3883 "Self-originated link states\n")
3884
3885ALIAS (show_ip_ospf_database,
3886 show_ip_ospf_database_type_id_cmd,
3887 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3888 SHOW_STR
3889 IP_STR
3890 "OSPF information\n"
3891 "Database summary\n"
3892 OSPF_LSA_TYPES_DESC
3893 "Link State ID (as an IP address)\n")
3894
3895ALIAS (show_ip_ospf_database,
3896 show_ip_ospf_database_type_id_adv_router_cmd,
3897 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3898 SHOW_STR
3899 IP_STR
3900 "OSPF information\n"
3901 "Database summary\n"
3902 OSPF_LSA_TYPES_DESC
3903 "Link State ID (as an IP address)\n"
3904 "Advertising Router link states\n"
3905 "Advertising Router (as an IP address)\n")
3906
3907ALIAS (show_ip_ospf_database,
3908 show_ip_ospf_database_type_id_self_cmd,
3909 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3910 SHOW_STR
3911 IP_STR
3912 "OSPF information\n"
3913 "Database summary\n"
3914 OSPF_LSA_TYPES_DESC
3915 "Link State ID (as an IP address)\n"
3916 "Self-originated link states\n"
3917 "\n")
3918
3919DEFUN (show_ip_ospf_database_type_adv_router,
3920 show_ip_ospf_database_type_adv_router_cmd,
3921 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3922 SHOW_STR
3923 IP_STR
3924 "OSPF information\n"
3925 "Database summary\n"
3926 OSPF_LSA_TYPES_DESC
3927 "Advertising Router link states\n"
3928 "Advertising Router (as an IP address)\n")
3929{
paul020709f2003-04-04 02:44:16 +00003930 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003931 int type, ret;
3932 struct in_addr adv_router;
3933
paul020709f2003-04-04 02:44:16 +00003934 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003935 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003936 return CMD_SUCCESS;
3937
3938 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003939 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003940
3941 if (argc != 2)
3942 return CMD_WARNING;
3943
3944 /* Set database type to show. */
3945 if (strncmp (argv[0], "r", 1) == 0)
3946 type = OSPF_ROUTER_LSA;
3947 else if (strncmp (argv[0], "ne", 2) == 0)
3948 type = OSPF_NETWORK_LSA;
3949#ifdef HAVE_NSSA
3950 else if (strncmp (argv[0], "ns", 2) == 0)
3951 type = OSPF_AS_NSSA_LSA;
3952#endif /* HAVE_NSSA */
3953 else if (strncmp (argv[0], "s", 1) == 0)
3954 type = OSPF_SUMMARY_LSA;
3955 else if (strncmp (argv[0], "a", 1) == 0)
3956 type = OSPF_ASBR_SUMMARY_LSA;
3957 else if (strncmp (argv[0], "e", 1) == 0)
3958 type = OSPF_AS_EXTERNAL_LSA;
3959#ifdef HAVE_OPAQUE_LSA
3960 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3961 type = OSPF_OPAQUE_LINK_LSA;
3962 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3963 type = OSPF_OPAQUE_AREA_LSA;
3964 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3965 type = OSPF_OPAQUE_AS_LSA;
3966#endif /* HAVE_OPAQUE_LSA */
3967 else
3968 return CMD_WARNING;
3969
3970 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
3971 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003972 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003973 else
3974 {
3975 ret = inet_aton (argv[1], &adv_router);
3976 if (!ret)
3977 return CMD_WARNING;
3978 }
3979
paul020709f2003-04-04 02:44:16 +00003980 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00003981
3982 return CMD_SUCCESS;
3983}
3984
3985ALIAS (show_ip_ospf_database_type_adv_router,
3986 show_ip_ospf_database_type_self_cmd,
3987 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
3988 SHOW_STR
3989 IP_STR
3990 "OSPF information\n"
3991 "Database summary\n"
3992 OSPF_LSA_TYPES_DESC
3993 "Self-originated link states\n")
3994
3995
3996DEFUN (ip_ospf_authentication_args,
3997 ip_ospf_authentication_args_addr_cmd,
3998 "ip ospf authentication (null|message-digest) A.B.C.D",
3999 "IP Information\n"
4000 "OSPF interface commands\n"
4001 "Enable authentication on this interface\n"
4002 "Use null authentication\n"
4003 "Use message-digest authentication\n"
4004 "Address of interface")
4005{
4006 struct interface *ifp;
4007 struct in_addr addr;
4008 int ret;
4009 struct ospf_if_params *params;
4010
4011 ifp = vty->index;
4012 params = IF_DEF_PARAMS (ifp);
4013
4014 if (argc == 2)
4015 {
4016 ret = inet_aton(argv[1], &addr);
4017 if (!ret)
4018 {
4019 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4020 VTY_NEWLINE);
4021 return CMD_WARNING;
4022 }
4023
4024 params = ospf_get_if_params (ifp, addr);
4025 ospf_if_update_params (ifp, addr);
4026 }
4027
4028 /* Handle null authentication */
4029 if ( argv[0][0] == 'n' )
4030 {
4031 SET_IF_PARAM (params, auth_type);
4032 params->auth_type = OSPF_AUTH_NULL;
4033 return CMD_SUCCESS;
4034 }
4035
4036 /* Handle message-digest authentication */
4037 if ( argv[0][0] == 'm' )
4038 {
4039 SET_IF_PARAM (params, auth_type);
4040 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4041 return CMD_SUCCESS;
4042 }
4043
4044 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4045 return CMD_WARNING;
4046}
4047
4048ALIAS (ip_ospf_authentication_args,
4049 ip_ospf_authentication_args_cmd,
4050 "ip ospf authentication (null|message-digest)",
4051 "IP Information\n"
4052 "OSPF interface commands\n"
4053 "Enable authentication on this interface\n"
4054 "Use null authentication\n"
4055 "Use message-digest authentication\n")
4056
4057DEFUN (ip_ospf_authentication,
4058 ip_ospf_authentication_addr_cmd,
4059 "ip ospf authentication A.B.C.D",
4060 "IP Information\n"
4061 "OSPF interface commands\n"
4062 "Enable authentication on this interface\n"
4063 "Address of interface")
4064{
4065 struct interface *ifp;
4066 struct in_addr addr;
4067 int ret;
4068 struct ospf_if_params *params;
4069
4070 ifp = vty->index;
4071 params = IF_DEF_PARAMS (ifp);
4072
4073 if (argc == 1)
4074 {
4075 ret = inet_aton(argv[1], &addr);
4076 if (!ret)
4077 {
4078 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4079 VTY_NEWLINE);
4080 return CMD_WARNING;
4081 }
4082
4083 params = ospf_get_if_params (ifp, addr);
4084 ospf_if_update_params (ifp, addr);
4085 }
4086
4087 SET_IF_PARAM (params, auth_type);
4088 params->auth_type = OSPF_AUTH_SIMPLE;
4089
4090 return CMD_SUCCESS;
4091}
4092
4093ALIAS (ip_ospf_authentication,
4094 ip_ospf_authentication_cmd,
4095 "ip ospf authentication",
4096 "IP Information\n"
4097 "OSPF interface commands\n"
4098 "Enable authentication on this interface\n")
4099
4100DEFUN (no_ip_ospf_authentication,
4101 no_ip_ospf_authentication_addr_cmd,
4102 "no ip ospf authentication A.B.C.D",
4103 NO_STR
4104 "IP Information\n"
4105 "OSPF interface commands\n"
4106 "Enable authentication on this interface\n"
4107 "Address of interface")
4108{
4109 struct interface *ifp;
4110 struct in_addr addr;
4111 int ret;
4112 struct ospf_if_params *params;
4113
4114 ifp = vty->index;
4115 params = IF_DEF_PARAMS (ifp);
4116
4117 if (argc == 1)
4118 {
4119 ret = inet_aton(argv[1], &addr);
4120 if (!ret)
4121 {
4122 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4123 VTY_NEWLINE);
4124 return CMD_WARNING;
4125 }
4126
4127 params = ospf_lookup_if_params (ifp, addr);
4128 if (params == NULL)
4129 return CMD_SUCCESS;
4130 }
4131
4132 params->auth_type = OSPF_AUTH_NOTSET;
4133 UNSET_IF_PARAM (params, auth_type);
4134
4135 if (params != IF_DEF_PARAMS (ifp))
4136 {
4137 ospf_free_if_params (ifp, addr);
4138 ospf_if_update_params (ifp, addr);
4139 }
4140
4141 return CMD_SUCCESS;
4142}
4143
4144ALIAS (no_ip_ospf_authentication,
4145 no_ip_ospf_authentication_cmd,
4146 "no ip ospf authentication",
4147 NO_STR
4148 "IP Information\n"
4149 "OSPF interface commands\n"
4150 "Enable authentication on this interface\n")
4151
4152DEFUN (ip_ospf_authentication_key,
4153 ip_ospf_authentication_key_addr_cmd,
4154 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4155 "IP Information\n"
4156 "OSPF interface commands\n"
4157 "Authentication password (key)\n"
4158 "The OSPF password (key)\n"
4159 "Address of interface")
4160{
4161 struct interface *ifp;
4162 struct in_addr addr;
4163 int ret;
4164 struct ospf_if_params *params;
4165
4166 ifp = vty->index;
4167 params = IF_DEF_PARAMS (ifp);
4168
4169 if (argc == 2)
4170 {
4171 ret = inet_aton(argv[1], &addr);
4172 if (!ret)
4173 {
4174 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4175 VTY_NEWLINE);
4176 return CMD_WARNING;
4177 }
4178
4179 params = ospf_get_if_params (ifp, addr);
4180 ospf_if_update_params (ifp, addr);
4181 }
4182
4183
4184 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
4185 strncpy (params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
4186 SET_IF_PARAM (params, auth_simple);
4187
4188 return CMD_SUCCESS;
4189}
4190
4191ALIAS (ip_ospf_authentication_key,
4192 ip_ospf_authentication_key_cmd,
4193 "ip ospf authentication-key AUTH_KEY",
4194 "IP Information\n"
4195 "OSPF interface commands\n"
4196 "Authentication password (key)\n"
4197 "The OSPF password (key)")
4198
4199ALIAS (ip_ospf_authentication_key,
4200 ospf_authentication_key_cmd,
4201 "ospf authentication-key AUTH_KEY",
4202 "OSPF interface commands\n"
4203 "Authentication password (key)\n"
4204 "The OSPF password (key)")
4205
4206DEFUN (no_ip_ospf_authentication_key,
4207 no_ip_ospf_authentication_key_addr_cmd,
4208 "no ip ospf authentication-key A.B.C.D",
4209 NO_STR
4210 "IP Information\n"
4211 "OSPF interface commands\n"
4212 "Authentication password (key)\n"
4213 "Address of interface")
4214{
4215 struct interface *ifp;
4216 struct in_addr addr;
4217 int ret;
4218 struct ospf_if_params *params;
4219
4220 ifp = vty->index;
4221 params = IF_DEF_PARAMS (ifp);
4222
4223 if (argc == 2)
4224 {
4225 ret = inet_aton(argv[1], &addr);
4226 if (!ret)
4227 {
4228 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4229 VTY_NEWLINE);
4230 return CMD_WARNING;
4231 }
4232
4233 params = ospf_lookup_if_params (ifp, addr);
4234 if (params == NULL)
4235 return CMD_SUCCESS;
4236 }
4237
4238 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4239 UNSET_IF_PARAM (params, auth_simple);
4240
4241 if (params != IF_DEF_PARAMS (ifp))
4242 {
4243 ospf_free_if_params (ifp, addr);
4244 ospf_if_update_params (ifp, addr);
4245 }
4246
4247 return CMD_SUCCESS;
4248}
4249
4250ALIAS (no_ip_ospf_authentication_key,
4251 no_ip_ospf_authentication_key_cmd,
4252 "no ip ospf authentication-key",
4253 NO_STR
4254 "IP Information\n"
4255 "OSPF interface commands\n"
4256 "Authentication password (key)\n")
4257
4258ALIAS (no_ip_ospf_authentication_key,
4259 no_ospf_authentication_key_cmd,
4260 "no ospf authentication-key",
4261 NO_STR
4262 "OSPF interface commands\n"
4263 "Authentication password (key)\n")
4264
4265DEFUN (ip_ospf_message_digest_key,
4266 ip_ospf_message_digest_key_addr_cmd,
4267 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4268 "IP Information\n"
4269 "OSPF interface commands\n"
4270 "Message digest authentication password (key)\n"
4271 "Key ID\n"
4272 "Use MD5 algorithm\n"
4273 "The OSPF password (key)"
4274 "Address of interface")
4275{
4276 struct interface *ifp;
4277 struct crypt_key *ck;
4278 u_char key_id;
4279 struct in_addr addr;
4280 int ret;
4281 struct ospf_if_params *params;
4282
4283 ifp = vty->index;
4284 params = IF_DEF_PARAMS (ifp);
4285
4286 if (argc == 3)
4287 {
4288 ret = inet_aton(argv[2], &addr);
4289 if (!ret)
4290 {
4291 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4292 VTY_NEWLINE);
4293 return CMD_WARNING;
4294 }
4295
4296 params = ospf_get_if_params (ifp, addr);
4297 ospf_if_update_params (ifp, addr);
4298 }
4299
4300 key_id = strtol (argv[0], NULL, 10);
4301 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4302 {
4303 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4304 return CMD_WARNING;
4305 }
4306
4307 ck = ospf_crypt_key_new ();
4308 ck->key_id = (u_char) key_id;
4309 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
4310 strncpy (ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
4311
4312 ospf_crypt_key_add (params->auth_crypt, ck);
4313 SET_IF_PARAM (params, auth_crypt);
4314
4315 return CMD_SUCCESS;
4316}
4317
4318ALIAS (ip_ospf_message_digest_key,
4319 ip_ospf_message_digest_key_cmd,
4320 "ip ospf message-digest-key <1-255> md5 KEY",
4321 "IP Information\n"
4322 "OSPF interface commands\n"
4323 "Message digest authentication password (key)\n"
4324 "Key ID\n"
4325 "Use MD5 algorithm\n"
4326 "The OSPF password (key)")
4327
4328ALIAS (ip_ospf_message_digest_key,
4329 ospf_message_digest_key_cmd,
4330 "ospf message-digest-key <1-255> md5 KEY",
4331 "OSPF interface commands\n"
4332 "Message digest authentication password (key)\n"
4333 "Key ID\n"
4334 "Use MD5 algorithm\n"
4335 "The OSPF password (key)")
4336
4337DEFUN (no_ip_ospf_message_digest_key,
4338 no_ip_ospf_message_digest_key_addr_cmd,
4339 "no ip ospf message-digest-key <1-255> A.B.C.D",
4340 NO_STR
4341 "IP Information\n"
4342 "OSPF interface commands\n"
4343 "Message digest authentication password (key)\n"
4344 "Key ID\n"
4345 "Address of interface")
4346{
4347 struct interface *ifp;
4348 struct crypt_key *ck;
4349 int key_id;
4350 struct in_addr addr;
4351 int ret;
4352 struct ospf_if_params *params;
4353
4354 ifp = vty->index;
4355 params = IF_DEF_PARAMS (ifp);
4356
4357 if (argc == 2)
4358 {
4359 ret = inet_aton(argv[1], &addr);
4360 if (!ret)
4361 {
4362 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4363 VTY_NEWLINE);
4364 return CMD_WARNING;
4365 }
4366
4367 params = ospf_lookup_if_params (ifp, addr);
4368 if (params == NULL)
4369 return CMD_SUCCESS;
4370 }
4371
4372 key_id = strtol (argv[0], NULL, 10);
4373 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4374 if (ck == NULL)
4375 {
4376 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4377 return CMD_WARNING;
4378 }
4379
4380 ospf_crypt_key_delete (params->auth_crypt, key_id);
4381
4382 if (params != IF_DEF_PARAMS (ifp))
4383 {
4384 ospf_free_if_params (ifp, addr);
4385 ospf_if_update_params (ifp, addr);
4386 }
4387
4388 return CMD_SUCCESS;
4389}
4390
4391ALIAS (no_ip_ospf_message_digest_key,
4392 no_ip_ospf_message_digest_key_cmd,
4393 "no ip ospf message-digest-key <1-255>",
4394 NO_STR
4395 "IP Information\n"
4396 "OSPF interface commands\n"
4397 "Message digest authentication password (key)\n"
4398 "Key ID\n")
4399
4400ALIAS (no_ip_ospf_message_digest_key,
4401 no_ospf_message_digest_key_cmd,
4402 "no ospf message-digest-key <1-255>",
4403 NO_STR
4404 "OSPF interface commands\n"
4405 "Message digest authentication password (key)\n"
4406 "Key ID\n")
4407
4408DEFUN (ip_ospf_cost,
4409 ip_ospf_cost_addr_cmd,
4410 "ip ospf cost <1-65535> A.B.C.D",
4411 "IP Information\n"
4412 "OSPF interface commands\n"
4413 "Interface cost\n"
4414 "Cost\n"
4415 "Address of interface")
4416{
4417 struct interface *ifp = vty->index;
4418 u_int32_t cost;
4419 struct in_addr addr;
4420 int ret;
4421 struct ospf_if_params *params;
4422
4423 params = IF_DEF_PARAMS (ifp);
4424
4425 cost = strtol (argv[0], NULL, 10);
4426
4427 /* cost range is <1-65535>. */
4428 if (cost < 1 || cost > 65535)
4429 {
4430 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4431 return CMD_WARNING;
4432 }
4433
4434 if (argc == 2)
4435 {
4436 ret = inet_aton(argv[1], &addr);
4437 if (!ret)
4438 {
4439 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4440 VTY_NEWLINE);
4441 return CMD_WARNING;
4442 }
4443
4444 params = ospf_get_if_params (ifp, addr);
4445 ospf_if_update_params (ifp, addr);
4446 }
4447
4448 SET_IF_PARAM (params, output_cost_cmd);
4449 params->output_cost_cmd = cost;
4450
4451 ospf_if_recalculate_output_cost (ifp);
4452
4453 return CMD_SUCCESS;
4454}
4455
4456ALIAS (ip_ospf_cost,
4457 ip_ospf_cost_cmd,
4458 "ip ospf cost <1-65535>",
4459 "IP Information\n"
4460 "OSPF interface commands\n"
4461 "Interface cost\n"
4462 "Cost")
4463
4464ALIAS (ip_ospf_cost,
4465 ospf_cost_cmd,
4466 "ospf cost <1-65535>",
4467 "OSPF interface commands\n"
4468 "Interface cost\n"
4469 "Cost")
4470
4471DEFUN (no_ip_ospf_cost,
4472 no_ip_ospf_cost_addr_cmd,
4473 "no ip ospf cost A.B.C.D",
4474 NO_STR
4475 "IP Information\n"
4476 "OSPF interface commands\n"
4477 "Interface cost\n"
4478 "Address of interface")
4479{
4480 struct interface *ifp = vty->index;
4481 struct in_addr addr;
4482 int ret;
4483 struct ospf_if_params *params;
4484
4485 ifp = vty->index;
4486 params = IF_DEF_PARAMS (ifp);
4487
4488 if (argc == 1)
4489 {
4490 ret = inet_aton(argv[0], &addr);
4491 if (!ret)
4492 {
4493 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4494 VTY_NEWLINE);
4495 return CMD_WARNING;
4496 }
4497
4498 params = ospf_lookup_if_params (ifp, addr);
4499 if (params == NULL)
4500 return CMD_SUCCESS;
4501 }
4502
4503 UNSET_IF_PARAM (params, output_cost_cmd);
4504
4505 if (params != IF_DEF_PARAMS (ifp))
4506 {
4507 ospf_free_if_params (ifp, addr);
4508 ospf_if_update_params (ifp, addr);
4509 }
4510
4511 ospf_if_recalculate_output_cost (ifp);
4512
4513 return CMD_SUCCESS;
4514}
4515
4516ALIAS (no_ip_ospf_cost,
4517 no_ip_ospf_cost_cmd,
4518 "no ip ospf cost",
4519 NO_STR
4520 "IP Information\n"
4521 "OSPF interface commands\n"
4522 "Interface cost\n")
4523
4524ALIAS (no_ip_ospf_cost,
4525 no_ospf_cost_cmd,
4526 "no ospf cost",
4527 NO_STR
4528 "OSPF interface commands\n"
4529 "Interface cost\n")
4530
4531void
4532ospf_nbr_timer_update (struct ospf_interface *oi)
4533{
4534 struct route_node *rn;
4535 struct ospf_neighbor *nbr;
4536
4537 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4538 if ((nbr = rn->info))
4539 {
4540 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4541 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4542 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4543 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4544 }
4545}
4546
4547DEFUN (ip_ospf_dead_interval,
4548 ip_ospf_dead_interval_addr_cmd,
4549 "ip ospf dead-interval <1-65535> A.B.C.D",
4550 "IP Information\n"
4551 "OSPF interface commands\n"
4552 "Interval after which a neighbor is declared dead\n"
4553 "Seconds\n"
4554 "Address of interface")
4555{
4556 struct interface *ifp = vty->index;
4557 u_int32_t seconds;
4558 struct in_addr addr;
4559 int ret;
4560 struct ospf_if_params *params;
4561 struct ospf_interface *oi;
4562 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004563 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004564
paul020709f2003-04-04 02:44:16 +00004565 ospf = ospf_lookup ();
4566
paul718e3742002-12-13 20:15:29 +00004567 params = IF_DEF_PARAMS (ifp);
4568
4569 seconds = strtol (argv[0], NULL, 10);
4570
4571 /* dead_interval range is <1-65535>. */
4572 if (seconds < 1 || seconds > 65535)
4573 {
4574 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4575 return CMD_WARNING;
4576 }
4577
4578 if (argc == 2)
4579 {
4580 ret = inet_aton(argv[1], &addr);
4581 if (!ret)
4582 {
4583 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4584 VTY_NEWLINE);
4585 return CMD_WARNING;
4586 }
4587
4588 params = ospf_get_if_params (ifp, addr);
4589 ospf_if_update_params (ifp, addr);
4590 }
4591
4592 SET_IF_PARAM (params, v_wait);
4593 params->v_wait = seconds;
4594
4595 /* Update timer values in neighbor structure. */
4596 if (argc == 2)
4597 {
paul68980082003-03-25 05:07:42 +00004598 if (ospf)
4599 {
4600 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4601 if (oi)
4602 ospf_nbr_timer_update (oi);
4603 }
paul718e3742002-12-13 20:15:29 +00004604 }
4605 else
4606 {
4607 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4608 if ((oi = rn->info))
4609 ospf_nbr_timer_update (oi);
4610 }
4611
4612 return CMD_SUCCESS;
4613}
4614
4615ALIAS (ip_ospf_dead_interval,
4616 ip_ospf_dead_interval_cmd,
4617 "ip ospf dead-interval <1-65535>",
4618 "IP Information\n"
4619 "OSPF interface commands\n"
4620 "Interval after which a neighbor is declared dead\n"
4621 "Seconds\n")
4622
4623ALIAS (ip_ospf_dead_interval,
4624 ospf_dead_interval_cmd,
4625 "ospf dead-interval <1-65535>",
4626 "OSPF interface commands\n"
4627 "Interval after which a neighbor is declared dead\n"
4628 "Seconds\n")
4629
4630DEFUN (no_ip_ospf_dead_interval,
4631 no_ip_ospf_dead_interval_addr_cmd,
4632 "no ip ospf dead-interval A.B.C.D",
4633 NO_STR
4634 "IP Information\n"
4635 "OSPF interface commands\n"
4636 "Interval after which a neighbor is declared dead\n"
4637 "Address of interface")
4638{
4639 struct interface *ifp = vty->index;
4640 struct in_addr addr;
4641 int ret;
4642 struct ospf_if_params *params;
4643 struct ospf_interface *oi;
4644 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004645 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004646
paul020709f2003-04-04 02:44:16 +00004647 ospf = ospf_lookup ();
4648
paul718e3742002-12-13 20:15:29 +00004649 ifp = vty->index;
4650 params = IF_DEF_PARAMS (ifp);
4651
4652 if (argc == 1)
4653 {
4654 ret = inet_aton(argv[0], &addr);
4655 if (!ret)
4656 {
4657 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4658 VTY_NEWLINE);
4659 return CMD_WARNING;
4660 }
4661
4662 params = ospf_lookup_if_params (ifp, addr);
4663 if (params == NULL)
4664 return CMD_SUCCESS;
4665 }
4666
4667 UNSET_IF_PARAM (params, v_wait);
4668 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4669
4670 if (params != IF_DEF_PARAMS (ifp))
4671 {
4672 ospf_free_if_params (ifp, addr);
4673 ospf_if_update_params (ifp, addr);
4674 }
4675
4676 /* Update timer values in neighbor structure. */
4677 if (argc == 1)
4678 {
paul68980082003-03-25 05:07:42 +00004679 if (ospf)
4680 {
4681 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4682 if (oi)
4683 ospf_nbr_timer_update (oi);
4684 }
paul718e3742002-12-13 20:15:29 +00004685 }
4686 else
4687 {
4688 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4689 if ((oi = rn->info))
4690 ospf_nbr_timer_update (oi);
4691 }
4692
4693 return CMD_SUCCESS;
4694}
4695
4696ALIAS (no_ip_ospf_dead_interval,
4697 no_ip_ospf_dead_interval_cmd,
4698 "no ip ospf dead-interval",
4699 NO_STR
4700 "IP Information\n"
4701 "OSPF interface commands\n"
4702 "Interval after which a neighbor is declared dead\n")
4703
4704ALIAS (no_ip_ospf_dead_interval,
4705 no_ospf_dead_interval_cmd,
4706 "no ospf dead-interval",
4707 NO_STR
4708 "OSPF interface commands\n"
4709 "Interval after which a neighbor is declared dead\n")
4710
4711DEFUN (ip_ospf_hello_interval,
4712 ip_ospf_hello_interval_addr_cmd,
4713 "ip ospf hello-interval <1-65535> A.B.C.D",
4714 "IP Information\n"
4715 "OSPF interface commands\n"
4716 "Time between HELLO packets\n"
4717 "Seconds\n"
4718 "Address of interface")
4719{
4720 struct interface *ifp = vty->index;
4721 u_int32_t seconds;
4722 struct in_addr addr;
4723 int ret;
4724 struct ospf_if_params *params;
4725
4726 params = IF_DEF_PARAMS (ifp);
4727
4728 seconds = strtol (argv[0], NULL, 10);
4729
4730 /* HelloInterval range is <1-65535>. */
4731 if (seconds < 1 || seconds > 65535)
4732 {
4733 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4734 return CMD_WARNING;
4735 }
4736
4737 if (argc == 2)
4738 {
4739 ret = inet_aton(argv[1], &addr);
4740 if (!ret)
4741 {
4742 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4743 VTY_NEWLINE);
4744 return CMD_WARNING;
4745 }
4746
4747 params = ospf_get_if_params (ifp, addr);
4748 ospf_if_update_params (ifp, addr);
4749 }
4750
4751 SET_IF_PARAM (params, v_hello);
4752 params->v_hello = seconds;
4753
4754 return CMD_SUCCESS;
4755}
4756
4757ALIAS (ip_ospf_hello_interval,
4758 ip_ospf_hello_interval_cmd,
4759 "ip ospf hello-interval <1-65535>",
4760 "IP Information\n"
4761 "OSPF interface commands\n"
4762 "Time between HELLO packets\n"
4763 "Seconds\n")
4764
4765ALIAS (ip_ospf_hello_interval,
4766 ospf_hello_interval_cmd,
4767 "ospf hello-interval <1-65535>",
4768 "OSPF interface commands\n"
4769 "Time between HELLO packets\n"
4770 "Seconds\n")
4771
4772DEFUN (no_ip_ospf_hello_interval,
4773 no_ip_ospf_hello_interval_addr_cmd,
4774 "no ip ospf hello-interval A.B.C.D",
4775 NO_STR
4776 "IP Information\n"
4777 "OSPF interface commands\n"
4778 "Time between HELLO packets\n"
4779 "Address of interface")
4780{
4781 struct interface *ifp = vty->index;
4782 struct in_addr addr;
4783 int ret;
4784 struct ospf_if_params *params;
4785
4786 ifp = vty->index;
4787 params = IF_DEF_PARAMS (ifp);
4788
4789 if (argc == 1)
4790 {
4791 ret = inet_aton(argv[0], &addr);
4792 if (!ret)
4793 {
4794 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4795 VTY_NEWLINE);
4796 return CMD_WARNING;
4797 }
4798
4799 params = ospf_lookup_if_params (ifp, addr);
4800 if (params == NULL)
4801 return CMD_SUCCESS;
4802 }
4803
4804 UNSET_IF_PARAM (params, v_hello);
4805 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4806
4807 if (params != IF_DEF_PARAMS (ifp))
4808 {
4809 ospf_free_if_params (ifp, addr);
4810 ospf_if_update_params (ifp, addr);
4811 }
4812
4813 return CMD_SUCCESS;
4814}
4815
4816ALIAS (no_ip_ospf_hello_interval,
4817 no_ip_ospf_hello_interval_cmd,
4818 "no ip ospf hello-interval",
4819 NO_STR
4820 "IP Information\n"
4821 "OSPF interface commands\n"
4822 "Time between HELLO packets\n")
4823
4824ALIAS (no_ip_ospf_hello_interval,
4825 no_ospf_hello_interval_cmd,
4826 "no ospf hello-interval",
4827 NO_STR
4828 "OSPF interface commands\n"
4829 "Time between HELLO packets\n")
4830
4831DEFUN (ip_ospf_network,
4832 ip_ospf_network_cmd,
4833 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4834 "IP Information\n"
4835 "OSPF interface commands\n"
4836 "Network type\n"
4837 "Specify OSPF broadcast multi-access network\n"
4838 "Specify OSPF NBMA network\n"
4839 "Specify OSPF point-to-multipoint network\n"
4840 "Specify OSPF point-to-point network\n")
4841{
4842 struct interface *ifp = vty->index;
4843 int old_type = IF_DEF_PARAMS (ifp)->type;
4844 struct route_node *rn;
4845
4846 if (strncmp (argv[0], "b", 1) == 0)
4847 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4848 else if (strncmp (argv[0], "n", 1) == 0)
4849 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4850 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4851 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4852 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4853 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4854
4855 if (IF_DEF_PARAMS (ifp)->type == old_type)
4856 return CMD_SUCCESS;
4857
4858 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
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 (ip_ospf_network,
4880 ospf_network_cmd,
4881 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4882 "OSPF interface commands\n"
4883 "Network type\n"
4884 "Specify OSPF broadcast multi-access network\n"
4885 "Specify OSPF NBMA network\n"
4886 "Specify OSPF point-to-multipoint network\n"
4887 "Specify OSPF point-to-point network\n")
4888
4889DEFUN (no_ip_ospf_network,
4890 no_ip_ospf_network_cmd,
4891 "no ip ospf network",
4892 NO_STR
4893 "IP Information\n"
4894 "OSPF interface commands\n"
4895 "Network type\n")
4896{
4897 struct interface *ifp = vty->index;
4898 int old_type = IF_DEF_PARAMS (ifp)->type;
4899 struct route_node *rn;
4900
4901 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4902
4903 if (IF_DEF_PARAMS (ifp)->type == old_type)
4904 return CMD_SUCCESS;
4905
4906 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4907 {
4908 struct ospf_interface *oi = rn->info;
4909
4910 if (!oi)
4911 continue;
4912
4913 oi->type = IF_DEF_PARAMS (ifp)->type;
4914
4915 if (oi->state > ISM_Down)
4916 {
4917 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4918 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4919 }
4920 }
4921
4922 return CMD_SUCCESS;
4923}
4924
4925ALIAS (no_ip_ospf_network,
4926 no_ospf_network_cmd,
4927 "no ospf network",
4928 NO_STR
4929 "OSPF interface commands\n"
4930 "Network type\n")
4931
4932DEFUN (ip_ospf_priority,
4933 ip_ospf_priority_addr_cmd,
4934 "ip ospf priority <0-255> A.B.C.D",
4935 "IP Information\n"
4936 "OSPF interface commands\n"
4937 "Router priority\n"
4938 "Priority\n"
4939 "Address of interface")
4940{
4941 struct interface *ifp = vty->index;
4942 u_int32_t priority;
4943 struct route_node *rn;
4944 struct in_addr addr;
4945 int ret;
4946 struct ospf_if_params *params;
4947
4948 params = IF_DEF_PARAMS (ifp);
4949
4950 priority = strtol (argv[0], NULL, 10);
4951
4952 /* Router Priority range is <0-255>. */
4953 if (priority < 0 || priority > 255)
4954 {
4955 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4956 return CMD_WARNING;
4957 }
4958
4959 if (argc == 2)
4960 {
4961 ret = inet_aton(argv[1], &addr);
4962 if (!ret)
4963 {
4964 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4965 VTY_NEWLINE);
4966 return CMD_WARNING;
4967 }
4968
4969 params = ospf_get_if_params (ifp, addr);
4970 ospf_if_update_params (ifp, addr);
4971 }
4972
4973 SET_IF_PARAM (params, priority);
4974 params->priority = priority;
4975
4976 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4977 {
4978 struct ospf_interface *oi = rn->info;
4979
4980 if (!oi)
4981 continue;
4982
4983
4984 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
4985 {
4986 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
4987 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
4988 }
4989 }
4990
4991 return CMD_SUCCESS;
4992}
4993
4994ALIAS (ip_ospf_priority,
4995 ip_ospf_priority_cmd,
4996 "ip ospf priority <0-255>",
4997 "IP Information\n"
4998 "OSPF interface commands\n"
4999 "Router priority\n"
5000 "Priority\n")
5001
5002ALIAS (ip_ospf_priority,
5003 ospf_priority_cmd,
5004 "ospf priority <0-255>",
5005 "OSPF interface commands\n"
5006 "Router priority\n"
5007 "Priority\n")
5008
5009DEFUN (no_ip_ospf_priority,
5010 no_ip_ospf_priority_addr_cmd,
5011 "no ip ospf priority A.B.C.D",
5012 NO_STR
5013 "IP Information\n"
5014 "OSPF interface commands\n"
5015 "Router priority\n"
5016 "Address of interface")
5017{
5018 struct interface *ifp = vty->index;
5019 struct route_node *rn;
5020 struct in_addr addr;
5021 int ret;
5022 struct ospf_if_params *params;
5023
5024 ifp = vty->index;
5025 params = IF_DEF_PARAMS (ifp);
5026
5027 if (argc == 1)
5028 {
5029 ret = inet_aton(argv[0], &addr);
5030 if (!ret)
5031 {
5032 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5033 VTY_NEWLINE);
5034 return CMD_WARNING;
5035 }
5036
5037 params = ospf_lookup_if_params (ifp, addr);
5038 if (params == NULL)
5039 return CMD_SUCCESS;
5040 }
5041
5042 UNSET_IF_PARAM (params, priority);
5043 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5044
5045 if (params != IF_DEF_PARAMS (ifp))
5046 {
5047 ospf_free_if_params (ifp, addr);
5048 ospf_if_update_params (ifp, addr);
5049 }
5050
5051 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5052 {
5053 struct ospf_interface *oi = rn->info;
5054
5055 if (!oi)
5056 continue;
5057
5058
5059 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5060 {
5061 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5062 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5063 }
5064 }
5065
5066 return CMD_SUCCESS;
5067}
5068
5069ALIAS (no_ip_ospf_priority,
5070 no_ip_ospf_priority_cmd,
5071 "no ip ospf priority",
5072 NO_STR
5073 "IP Information\n"
5074 "OSPF interface commands\n"
5075 "Router priority\n")
5076
5077ALIAS (no_ip_ospf_priority,
5078 no_ospf_priority_cmd,
5079 "no ospf priority",
5080 NO_STR
5081 "OSPF interface commands\n"
5082 "Router priority\n")
5083
5084DEFUN (ip_ospf_retransmit_interval,
5085 ip_ospf_retransmit_interval_addr_cmd,
5086 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5087 "IP Information\n"
5088 "OSPF interface commands\n"
5089 "Time between retransmitting lost link state advertisements\n"
5090 "Seconds\n"
5091 "Address of interface")
5092{
5093 struct interface *ifp = vty->index;
5094 u_int32_t seconds;
5095 struct in_addr addr;
5096 int ret;
5097 struct ospf_if_params *params;
5098
5099 params = IF_DEF_PARAMS (ifp);
5100 seconds = strtol (argv[0], NULL, 10);
5101
5102 /* Retransmit Interval range is <3-65535>. */
5103 if (seconds < 3 || seconds > 65535)
5104 {
5105 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5106 return CMD_WARNING;
5107 }
5108
5109
5110 if (argc == 2)
5111 {
5112 ret = inet_aton(argv[1], &addr);
5113 if (!ret)
5114 {
5115 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5116 VTY_NEWLINE);
5117 return CMD_WARNING;
5118 }
5119
5120 params = ospf_get_if_params (ifp, addr);
5121 ospf_if_update_params (ifp, addr);
5122 }
5123
5124 SET_IF_PARAM (params, retransmit_interval);
5125 params->retransmit_interval = seconds;
5126
5127 return CMD_SUCCESS;
5128}
5129
5130ALIAS (ip_ospf_retransmit_interval,
5131 ip_ospf_retransmit_interval_cmd,
5132 "ip ospf retransmit-interval <3-65535>",
5133 "IP Information\n"
5134 "OSPF interface commands\n"
5135 "Time between retransmitting lost link state advertisements\n"
5136 "Seconds\n")
5137
5138ALIAS (ip_ospf_retransmit_interval,
5139 ospf_retransmit_interval_cmd,
5140 "ospf retransmit-interval <3-65535>",
5141 "OSPF interface commands\n"
5142 "Time between retransmitting lost link state advertisements\n"
5143 "Seconds\n")
5144
5145DEFUN (no_ip_ospf_retransmit_interval,
5146 no_ip_ospf_retransmit_interval_addr_cmd,
5147 "no ip ospf retransmit-interval A.B.C.D",
5148 NO_STR
5149 "IP Information\n"
5150 "OSPF interface commands\n"
5151 "Time between retransmitting lost link state advertisements\n"
5152 "Address of interface")
5153{
5154 struct interface *ifp = vty->index;
5155 struct in_addr addr;
5156 int ret;
5157 struct ospf_if_params *params;
5158
5159 ifp = vty->index;
5160 params = IF_DEF_PARAMS (ifp);
5161
5162 if (argc == 1)
5163 {
5164 ret = inet_aton(argv[0], &addr);
5165 if (!ret)
5166 {
5167 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5168 VTY_NEWLINE);
5169 return CMD_WARNING;
5170 }
5171
5172 params = ospf_lookup_if_params (ifp, addr);
5173 if (params == NULL)
5174 return CMD_SUCCESS;
5175 }
5176
5177 UNSET_IF_PARAM (params, retransmit_interval);
5178 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5179
5180 if (params != IF_DEF_PARAMS (ifp))
5181 {
5182 ospf_free_if_params (ifp, addr);
5183 ospf_if_update_params (ifp, addr);
5184 }
5185
5186 return CMD_SUCCESS;
5187}
5188
5189ALIAS (no_ip_ospf_retransmit_interval,
5190 no_ip_ospf_retransmit_interval_cmd,
5191 "no ip ospf retransmit-interval",
5192 NO_STR
5193 "IP Information\n"
5194 "OSPF interface commands\n"
5195 "Time between retransmitting lost link state advertisements\n")
5196
5197ALIAS (no_ip_ospf_retransmit_interval,
5198 no_ospf_retransmit_interval_cmd,
5199 "no ospf retransmit-interval",
5200 NO_STR
5201 "OSPF interface commands\n"
5202 "Time between retransmitting lost link state advertisements\n")
5203
5204DEFUN (ip_ospf_transmit_delay,
5205 ip_ospf_transmit_delay_addr_cmd,
5206 "ip ospf transmit-delay <1-65535> A.B.C.D",
5207 "IP Information\n"
5208 "OSPF interface commands\n"
5209 "Link state transmit delay\n"
5210 "Seconds\n"
5211 "Address of interface")
5212{
5213 struct interface *ifp = vty->index;
5214 u_int32_t seconds;
5215 struct in_addr addr;
5216 int ret;
5217 struct ospf_if_params *params;
5218
5219 params = IF_DEF_PARAMS (ifp);
5220 seconds = strtol (argv[0], NULL, 10);
5221
5222 /* Transmit Delay range is <1-65535>. */
5223 if (seconds < 1 || seconds > 65535)
5224 {
5225 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5226 return CMD_WARNING;
5227 }
5228
5229 if (argc == 2)
5230 {
5231 ret = inet_aton(argv[1], &addr);
5232 if (!ret)
5233 {
5234 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5235 VTY_NEWLINE);
5236 return CMD_WARNING;
5237 }
5238
5239 params = ospf_get_if_params (ifp, addr);
5240 ospf_if_update_params (ifp, addr);
5241 }
5242
5243 SET_IF_PARAM (params, transmit_delay);
5244 params->transmit_delay = seconds;
5245
5246 return CMD_SUCCESS;
5247}
5248
5249ALIAS (ip_ospf_transmit_delay,
5250 ip_ospf_transmit_delay_cmd,
5251 "ip ospf transmit-delay <1-65535>",
5252 "IP Information\n"
5253 "OSPF interface commands\n"
5254 "Link state transmit delay\n"
5255 "Seconds\n")
5256
5257ALIAS (ip_ospf_transmit_delay,
5258 ospf_transmit_delay_cmd,
5259 "ospf transmit-delay <1-65535>",
5260 "OSPF interface commands\n"
5261 "Link state transmit delay\n"
5262 "Seconds\n")
5263
5264DEFUN (no_ip_ospf_transmit_delay,
5265 no_ip_ospf_transmit_delay_addr_cmd,
5266 "no ip ospf transmit-delay A.B.C.D",
5267 NO_STR
5268 "IP Information\n"
5269 "OSPF interface commands\n"
5270 "Link state transmit delay\n"
5271 "Address of interface")
5272{
5273 struct interface *ifp = vty->index;
5274 struct in_addr addr;
5275 int ret;
5276 struct ospf_if_params *params;
5277
5278 ifp = vty->index;
5279 params = IF_DEF_PARAMS (ifp);
5280
5281 if (argc == 1)
5282 {
5283 ret = inet_aton(argv[0], &addr);
5284 if (!ret)
5285 {
5286 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5287 VTY_NEWLINE);
5288 return CMD_WARNING;
5289 }
5290
5291 params = ospf_lookup_if_params (ifp, addr);
5292 if (params == NULL)
5293 return CMD_SUCCESS;
5294 }
5295
5296 UNSET_IF_PARAM (params, transmit_delay);
5297 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5298
5299 if (params != IF_DEF_PARAMS (ifp))
5300 {
5301 ospf_free_if_params (ifp, addr);
5302 ospf_if_update_params (ifp, addr);
5303 }
5304
5305 return CMD_SUCCESS;
5306}
5307
5308ALIAS (no_ip_ospf_transmit_delay,
5309 no_ip_ospf_transmit_delay_cmd,
5310 "no ip ospf transmit-delay",
5311 NO_STR
5312 "IP Information\n"
5313 "OSPF interface commands\n"
5314 "Link state transmit delay\n")
5315
5316ALIAS (no_ip_ospf_transmit_delay,
5317 no_ospf_transmit_delay_cmd,
5318 "no ospf transmit-delay",
5319 NO_STR
5320 "OSPF interface commands\n"
5321 "Link state transmit delay\n")
5322
5323
5324DEFUN (ospf_redistribute_source_metric_type,
5325 ospf_redistribute_source_metric_type_routemap_cmd,
5326 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5327 "Redistribute information from another routing protocol\n"
5328 "Kernel routes\n"
5329 "Connected\n"
5330 "Static routes\n"
5331 "Routing Information Protocol (RIP)\n"
5332 "Border Gateway Protocol (BGP)\n"
5333 "Metric for redistributed routes\n"
5334 "OSPF default metric\n"
5335 "OSPF exterior metric type for redistributed routes\n"
5336 "Set OSPF External Type 1 metrics\n"
5337 "Set OSPF External Type 2 metrics\n"
5338 "Route map reference\n"
5339 "Pointer to route-map entries\n")
5340{
paul020709f2003-04-04 02:44:16 +00005341 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005342 int source;
5343 int type = -1;
5344 int metric = -1;
5345
5346 /* Get distribute source. */
5347 if (!str2distribute_source (argv[0], &source))
5348 return CMD_WARNING;
5349
5350 /* Get metric value. */
5351 if (argc >= 2)
5352 if (!str2metric (argv[1], &metric))
5353 return CMD_WARNING;
5354
5355 /* Get metric type. */
5356 if (argc >= 3)
5357 if (!str2metric_type (argv[2], &type))
5358 return CMD_WARNING;
5359
5360 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005361 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005362 else
paul020709f2003-04-04 02:44:16 +00005363 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005364
paul020709f2003-04-04 02:44:16 +00005365 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005366}
5367
5368ALIAS (ospf_redistribute_source_metric_type,
5369 ospf_redistribute_source_metric_type_cmd,
5370 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5371 "Redistribute information from another routing protocol\n"
5372 "Kernel routes\n"
5373 "Connected\n"
5374 "Static routes\n"
5375 "Routing Information Protocol (RIP)\n"
5376 "Border Gateway Protocol (BGP)\n"
5377 "Metric for redistributed routes\n"
5378 "OSPF default metric\n"
5379 "OSPF exterior metric type for redistributed routes\n"
5380 "Set OSPF External Type 1 metrics\n"
5381 "Set OSPF External Type 2 metrics\n")
5382
5383ALIAS (ospf_redistribute_source_metric_type,
5384 ospf_redistribute_source_metric_cmd,
5385 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5386 "Redistribute information from another routing protocol\n"
5387 "Kernel routes\n"
5388 "Connected\n"
5389 "Static routes\n"
5390 "Routing Information Protocol (RIP)\n"
5391 "Border Gateway Protocol (BGP)\n"
5392 "Metric for redistributed routes\n"
5393 "OSPF default metric\n")
5394
5395DEFUN (ospf_redistribute_source_type_metric,
5396 ospf_redistribute_source_type_metric_routemap_cmd,
5397 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5398 "Redistribute information from another routing protocol\n"
5399 "Kernel routes\n"
5400 "Connected\n"
5401 "Static routes\n"
5402 "Routing Information Protocol (RIP)\n"
5403 "Border Gateway Protocol (BGP)\n"
5404 "OSPF exterior metric type for redistributed routes\n"
5405 "Set OSPF External Type 1 metrics\n"
5406 "Set OSPF External Type 2 metrics\n"
5407 "Metric for redistributed routes\n"
5408 "OSPF default metric\n"
5409 "Route map reference\n"
5410 "Pointer to route-map entries\n")
5411{
paul020709f2003-04-04 02:44:16 +00005412 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005413 int source;
5414 int type = -1;
5415 int metric = -1;
5416
5417 /* Get distribute source. */
5418 if (!str2distribute_source (argv[0], &source))
5419 return CMD_WARNING;
5420
5421 /* Get metric value. */
5422 if (argc >= 2)
5423 if (!str2metric_type (argv[1], &type))
5424 return CMD_WARNING;
5425
5426 /* Get metric type. */
5427 if (argc >= 3)
5428 if (!str2metric (argv[2], &metric))
5429 return CMD_WARNING;
5430
5431 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005432 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005433 else
paul020709f2003-04-04 02:44:16 +00005434 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005435
paul020709f2003-04-04 02:44:16 +00005436 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005437}
5438
5439ALIAS (ospf_redistribute_source_type_metric,
5440 ospf_redistribute_source_type_metric_cmd,
5441 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5442 "Redistribute information from another routing protocol\n"
5443 "Kernel routes\n"
5444 "Connected\n"
5445 "Static routes\n"
5446 "Routing Information Protocol (RIP)\n"
5447 "Border Gateway Protocol (BGP)\n"
5448 "OSPF exterior metric type for redistributed routes\n"
5449 "Set OSPF External Type 1 metrics\n"
5450 "Set OSPF External Type 2 metrics\n"
5451 "Metric for redistributed routes\n"
5452 "OSPF default metric\n")
5453
5454ALIAS (ospf_redistribute_source_type_metric,
5455 ospf_redistribute_source_type_cmd,
5456 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5457 "Redistribute information from another routing protocol\n"
5458 "Kernel routes\n"
5459 "Connected\n"
5460 "Static routes\n"
5461 "Routing Information Protocol (RIP)\n"
5462 "Border Gateway Protocol (BGP)\n"
5463 "OSPF exterior metric type for redistributed routes\n"
5464 "Set OSPF External Type 1 metrics\n"
5465 "Set OSPF External Type 2 metrics\n")
5466
5467ALIAS (ospf_redistribute_source_type_metric,
5468 ospf_redistribute_source_cmd,
5469 "redistribute (kernel|connected|static|rip|bgp)",
5470 "Redistribute information from another routing protocol\n"
5471 "Kernel routes\n"
5472 "Connected\n"
5473 "Static routes\n"
5474 "Routing Information Protocol (RIP)\n"
5475 "Border Gateway Protocol (BGP)\n")
5476
5477DEFUN (ospf_redistribute_source_metric_routemap,
5478 ospf_redistribute_source_metric_routemap_cmd,
5479 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5480 "Redistribute information from another routing protocol\n"
5481 "Kernel routes\n"
5482 "Connected\n"
5483 "Static routes\n"
5484 "Routing Information Protocol (RIP)\n"
5485 "Border Gateway Protocol (BGP)\n"
5486 "Metric for redistributed routes\n"
5487 "OSPF default metric\n"
5488 "Route map reference\n"
5489 "Pointer to route-map entries\n")
5490{
paul020709f2003-04-04 02:44:16 +00005491 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005492 int source;
5493 int metric = -1;
5494
5495 /* Get distribute source. */
5496 if (!str2distribute_source (argv[0], &source))
5497 return CMD_WARNING;
5498
5499 /* Get metric value. */
5500 if (argc >= 2)
5501 if (!str2metric (argv[1], &metric))
5502 return CMD_WARNING;
5503
5504 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005505 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005506 else
paul020709f2003-04-04 02:44:16 +00005507 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005508
paul020709f2003-04-04 02:44:16 +00005509 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005510}
5511
5512DEFUN (ospf_redistribute_source_type_routemap,
5513 ospf_redistribute_source_type_routemap_cmd,
5514 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5515 "Redistribute information from another routing protocol\n"
5516 "Kernel routes\n"
5517 "Connected\n"
5518 "Static routes\n"
5519 "Routing Information Protocol (RIP)\n"
5520 "Border Gateway Protocol (BGP)\n"
5521 "OSPF exterior metric type for redistributed routes\n"
5522 "Set OSPF External Type 1 metrics\n"
5523 "Set OSPF External Type 2 metrics\n"
5524 "Route map reference\n"
5525 "Pointer to route-map entries\n")
5526{
paul020709f2003-04-04 02:44:16 +00005527 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005528 int source;
5529 int type = -1;
5530
5531 /* Get distribute source. */
5532 if (!str2distribute_source (argv[0], &source))
5533 return CMD_WARNING;
5534
5535 /* Get metric value. */
5536 if (argc >= 2)
5537 if (!str2metric_type (argv[1], &type))
5538 return CMD_WARNING;
5539
5540 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005541 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005542 else
paul020709f2003-04-04 02:44:16 +00005543 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005544
paul020709f2003-04-04 02:44:16 +00005545 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005546}
5547
5548DEFUN (ospf_redistribute_source_routemap,
5549 ospf_redistribute_source_routemap_cmd,
5550 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5551 "Redistribute information from another routing protocol\n"
5552 "Kernel routes\n"
5553 "Connected\n"
5554 "Static routes\n"
5555 "Routing Information Protocol (RIP)\n"
5556 "Border Gateway Protocol (BGP)\n"
5557 "Route map reference\n"
5558 "Pointer to route-map entries\n")
5559{
paul020709f2003-04-04 02:44:16 +00005560 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005561 int source;
5562
5563 /* Get distribute source. */
5564 if (!str2distribute_source (argv[0], &source))
5565 return CMD_WARNING;
5566
5567 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005568 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005569 else
paul020709f2003-04-04 02:44:16 +00005570 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005571
paul020709f2003-04-04 02:44:16 +00005572 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005573}
5574
5575DEFUN (no_ospf_redistribute_source,
5576 no_ospf_redistribute_source_cmd,
5577 "no redistribute (kernel|connected|static|rip|bgp)",
5578 NO_STR
5579 "Redistribute information from another routing protocol\n"
5580 "Kernel routes\n"
5581 "Connected\n"
5582 "Static routes\n"
5583 "Routing Information Protocol (RIP)\n"
5584 "Border Gateway Protocol (BGP)\n")
5585{
paul020709f2003-04-04 02:44:16 +00005586 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005587 int source;
5588
5589 if (!str2distribute_source (argv[0], &source))
5590 return CMD_WARNING;
5591
paul020709f2003-04-04 02:44:16 +00005592 ospf_routemap_unset (ospf, source);
5593 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005594}
5595
5596DEFUN (ospf_distribute_list_out,
5597 ospf_distribute_list_out_cmd,
5598 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5599 "Filter networks in routing updates\n"
5600 "Access-list name\n"
5601 OUT_STR
5602 "Kernel routes\n"
5603 "Connected\n"
5604 "Static routes\n"
5605 "Routing Information Protocol (RIP)\n"
5606 "Border Gateway Protocol (BGP)\n")
5607{
paul68980082003-03-25 05:07:42 +00005608 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005609 int source;
5610
5611 /* Get distribute source. */
5612 if (!str2distribute_source (argv[1], &source))
5613 return CMD_WARNING;
5614
paul68980082003-03-25 05:07:42 +00005615 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005616}
5617
5618DEFUN (no_ospf_distribute_list_out,
5619 no_ospf_distribute_list_out_cmd,
5620 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5621 NO_STR
5622 "Filter networks in routing updates\n"
5623 "Access-list name\n"
5624 OUT_STR
5625 "Kernel routes\n"
5626 "Connected\n"
5627 "Static routes\n"
5628 "Routing Information Protocol (RIP)\n"
5629 "Border Gateway Protocol (BGP)\n")
5630{
paul68980082003-03-25 05:07:42 +00005631 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005632 int source;
5633
5634 if (!str2distribute_source (argv[1], &source))
5635 return CMD_WARNING;
5636
paul68980082003-03-25 05:07:42 +00005637 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005638}
5639
5640/* Default information originate. */
5641DEFUN (ospf_default_information_originate_metric_type_routemap,
5642 ospf_default_information_originate_metric_type_routemap_cmd,
5643 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5644 "Control distribution of default information\n"
5645 "Distribute a default route\n"
5646 "OSPF default metric\n"
5647 "OSPF metric\n"
5648 "OSPF metric type for default routes\n"
5649 "Set OSPF External Type 1 metrics\n"
5650 "Set OSPF External Type 2 metrics\n"
5651 "Route map reference\n"
5652 "Pointer to route-map entries\n")
5653{
paul020709f2003-04-04 02:44:16 +00005654 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005655 int type = -1;
5656 int metric = -1;
5657
5658 /* Get metric value. */
5659 if (argc >= 1)
5660 if (!str2metric (argv[0], &metric))
5661 return CMD_WARNING;
5662
5663 /* Get metric type. */
5664 if (argc >= 2)
5665 if (!str2metric_type (argv[1], &type))
5666 return CMD_WARNING;
5667
5668 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005669 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005670 else
paul020709f2003-04-04 02:44:16 +00005671 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005672
paul020709f2003-04-04 02:44:16 +00005673 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5674 type, metric);
paul718e3742002-12-13 20:15:29 +00005675}
5676
5677ALIAS (ospf_default_information_originate_metric_type_routemap,
5678 ospf_default_information_originate_metric_type_cmd,
5679 "default-information originate metric <0-16777214> metric-type (1|2)",
5680 "Control distribution of default information\n"
5681 "Distribute a default route\n"
5682 "OSPF default metric\n"
5683 "OSPF metric\n"
5684 "OSPF metric type for default routes\n"
5685 "Set OSPF External Type 1 metrics\n"
5686 "Set OSPF External Type 2 metrics\n")
5687
5688ALIAS (ospf_default_information_originate_metric_type_routemap,
5689 ospf_default_information_originate_metric_cmd,
5690 "default-information originate metric <0-16777214>",
5691 "Control distribution of default information\n"
5692 "Distribute a default route\n"
5693 "OSPF default metric\n"
5694 "OSPF metric\n")
5695
5696ALIAS (ospf_default_information_originate_metric_type_routemap,
5697 ospf_default_information_originate_cmd,
5698 "default-information originate",
5699 "Control distribution of default information\n"
5700 "Distribute a default route\n")
5701
5702/* Default information originate. */
5703DEFUN (ospf_default_information_originate_metric_routemap,
5704 ospf_default_information_originate_metric_routemap_cmd,
5705 "default-information originate metric <0-16777214> route-map WORD",
5706 "Control distribution of default information\n"
5707 "Distribute a default route\n"
5708 "OSPF default metric\n"
5709 "OSPF metric\n"
5710 "Route map reference\n"
5711 "Pointer to route-map entries\n")
5712{
paul020709f2003-04-04 02:44:16 +00005713 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005714 int metric = -1;
5715
5716 /* Get metric value. */
5717 if (argc >= 1)
5718 if (!str2metric (argv[0], &metric))
5719 return CMD_WARNING;
5720
5721 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005722 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005723 else
paul020709f2003-04-04 02:44:16 +00005724 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005725
paul020709f2003-04-04 02:44:16 +00005726 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5727 -1, metric);
paul718e3742002-12-13 20:15:29 +00005728}
5729
5730/* Default information originate. */
5731DEFUN (ospf_default_information_originate_routemap,
5732 ospf_default_information_originate_routemap_cmd,
5733 "default-information originate route-map WORD",
5734 "Control distribution of default information\n"
5735 "Distribute a default route\n"
5736 "Route map reference\n"
5737 "Pointer to route-map entries\n")
5738{
paul020709f2003-04-04 02:44:16 +00005739 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005740
paul020709f2003-04-04 02:44:16 +00005741 if (argc == 1)
5742 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5743 else
5744 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5745
5746 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005747}
5748
5749DEFUN (ospf_default_information_originate_type_metric_routemap,
5750 ospf_default_information_originate_type_metric_routemap_cmd,
5751 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5752 "Control distribution of default information\n"
5753 "Distribute a default route\n"
5754 "OSPF metric type for default routes\n"
5755 "Set OSPF External Type 1 metrics\n"
5756 "Set OSPF External Type 2 metrics\n"
5757 "OSPF default metric\n"
5758 "OSPF metric\n"
5759 "Route map reference\n"
5760 "Pointer to route-map entries\n")
5761{
paul020709f2003-04-04 02:44:16 +00005762 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005763 int type = -1;
5764 int metric = -1;
5765
5766 /* Get metric type. */
5767 if (argc >= 1)
5768 if (!str2metric_type (argv[0], &type))
5769 return CMD_WARNING;
5770
5771 /* Get metric value. */
5772 if (argc >= 2)
5773 if (!str2metric (argv[1], &metric))
5774 return CMD_WARNING;
5775
5776 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005777 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005778 else
paul020709f2003-04-04 02:44:16 +00005779 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005780
paul020709f2003-04-04 02:44:16 +00005781 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5782 type, metric);
paul718e3742002-12-13 20:15:29 +00005783}
5784
5785ALIAS (ospf_default_information_originate_type_metric_routemap,
5786 ospf_default_information_originate_type_metric_cmd,
5787 "default-information originate metric-type (1|2) metric <0-16777214>",
5788 "Control distribution of default information\n"
5789 "Distribute a default route\n"
5790 "OSPF metric type for default routes\n"
5791 "Set OSPF External Type 1 metrics\n"
5792 "Set OSPF External Type 2 metrics\n"
5793 "OSPF default metric\n"
5794 "OSPF metric\n")
5795
5796ALIAS (ospf_default_information_originate_type_metric_routemap,
5797 ospf_default_information_originate_type_cmd,
5798 "default-information originate metric-type (1|2)",
5799 "Control distribution of default information\n"
5800 "Distribute a default route\n"
5801 "OSPF metric type for default routes\n"
5802 "Set OSPF External Type 1 metrics\n"
5803 "Set OSPF External Type 2 metrics\n")
5804
5805DEFUN (ospf_default_information_originate_type_routemap,
5806 ospf_default_information_originate_type_routemap_cmd,
5807 "default-information originate metric-type (1|2) route-map WORD",
5808 "Control distribution of default information\n"
5809 "Distribute a default route\n"
5810 "OSPF metric type for default routes\n"
5811 "Set OSPF External Type 1 metrics\n"
5812 "Set OSPF External Type 2 metrics\n"
5813 "Route map reference\n"
5814 "Pointer to route-map entries\n")
5815{
paul020709f2003-04-04 02:44:16 +00005816 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005817 int type = -1;
5818
5819 /* Get metric type. */
5820 if (argc >= 1)
5821 if (!str2metric_type (argv[0], &type))
5822 return CMD_WARNING;
5823
5824 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005825 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005826 else
paul020709f2003-04-04 02:44:16 +00005827 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005828
paul020709f2003-04-04 02:44:16 +00005829 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5830 type, -1);
paul718e3742002-12-13 20:15:29 +00005831}
5832
5833DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5834 ospf_default_information_originate_always_metric_type_routemap_cmd,
5835 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5836 "Control distribution of default information\n"
5837 "Distribute a default route\n"
5838 "Always advertise default route\n"
5839 "OSPF default metric\n"
5840 "OSPF metric\n"
5841 "OSPF metric type for default routes\n"
5842 "Set OSPF External Type 1 metrics\n"
5843 "Set OSPF External Type 2 metrics\n"
5844 "Route map reference\n"
5845 "Pointer to route-map entries\n")
5846{
paul020709f2003-04-04 02:44:16 +00005847 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005848 int type = -1;
5849 int metric = -1;
5850
5851 /* Get metric value. */
5852 if (argc >= 1)
5853 if (!str2metric (argv[0], &metric))
5854 return CMD_WARNING;
5855
5856 /* Get metric type. */
5857 if (argc >= 2)
5858 if (!str2metric_type (argv[1], &type))
5859 return CMD_WARNING;
5860
5861 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005862 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005863 else
paul020709f2003-04-04 02:44:16 +00005864 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005865
paul020709f2003-04-04 02:44:16 +00005866 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005867 type, metric);
5868}
5869
5870ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5871 ospf_default_information_originate_always_metric_type_cmd,
5872 "default-information originate always metric <0-16777214> metric-type (1|2)",
5873 "Control distribution of default information\n"
5874 "Distribute a default route\n"
5875 "Always advertise default route\n"
5876 "OSPF default metric\n"
5877 "OSPF metric\n"
5878 "OSPF metric type for default routes\n"
5879 "Set OSPF External Type 1 metrics\n"
5880 "Set OSPF External Type 2 metrics\n")
5881
5882ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5883 ospf_default_information_originate_always_metric_cmd,
5884 "default-information originate always metric <0-16777214>",
5885 "Control distribution of default information\n"
5886 "Distribute a default route\n"
5887 "Always advertise default route\n"
5888 "OSPF default metric\n"
5889 "OSPF metric\n"
5890 "OSPF metric type for default routes\n")
5891
5892ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5893 ospf_default_information_originate_always_cmd,
5894 "default-information originate always",
5895 "Control distribution of default information\n"
5896 "Distribute a default route\n"
5897 "Always advertise default route\n")
5898
5899DEFUN (ospf_default_information_originate_always_metric_routemap,
5900 ospf_default_information_originate_always_metric_routemap_cmd,
5901 "default-information originate always metric <0-16777214> route-map WORD",
5902 "Control distribution of default information\n"
5903 "Distribute a default route\n"
5904 "Always advertise default route\n"
5905 "OSPF default metric\n"
5906 "OSPF metric\n"
5907 "Route map reference\n"
5908 "Pointer to route-map entries\n")
5909{
paul020709f2003-04-04 02:44:16 +00005910 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005911 int metric = -1;
5912
5913 /* Get metric value. */
5914 if (argc >= 1)
5915 if (!str2metric (argv[0], &metric))
5916 return CMD_WARNING;
5917
5918 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005919 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005920 else
paul020709f2003-04-04 02:44:16 +00005921 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005922
paul020709f2003-04-04 02:44:16 +00005923 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5924 -1, metric);
paul718e3742002-12-13 20:15:29 +00005925}
5926
5927DEFUN (ospf_default_information_originate_always_routemap,
5928 ospf_default_information_originate_always_routemap_cmd,
5929 "default-information originate always route-map WORD",
5930 "Control distribution of default information\n"
5931 "Distribute a default route\n"
5932 "Always advertise default route\n"
5933 "Route map reference\n"
5934 "Pointer to route-map entries\n")
5935{
paul020709f2003-04-04 02:44:16 +00005936 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005937
paul020709f2003-04-04 02:44:16 +00005938 if (argc == 1)
5939 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5940 else
5941 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5942
5943 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005944}
5945
5946DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5947 ospf_default_information_originate_always_type_metric_routemap_cmd,
5948 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5949 "Control distribution of default information\n"
5950 "Distribute a default route\n"
5951 "Always advertise default route\n"
5952 "OSPF metric type for default routes\n"
5953 "Set OSPF External Type 1 metrics\n"
5954 "Set OSPF External Type 2 metrics\n"
5955 "OSPF default metric\n"
5956 "OSPF metric\n"
5957 "Route map reference\n"
5958 "Pointer to route-map entries\n")
5959{
paul020709f2003-04-04 02:44:16 +00005960 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005961 int type = -1;
5962 int metric = -1;
5963
5964 /* Get metric type. */
5965 if (argc >= 1)
5966 if (!str2metric_type (argv[0], &type))
5967 return CMD_WARNING;
5968
5969 /* Get metric value. */
5970 if (argc >= 2)
5971 if (!str2metric (argv[1], &metric))
5972 return CMD_WARNING;
5973
5974 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005975 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005976 else
paul020709f2003-04-04 02:44:16 +00005977 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005978
paul020709f2003-04-04 02:44:16 +00005979 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005980 type, metric);
5981}
5982
5983ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5984 ospf_default_information_originate_always_type_metric_cmd,
5985 "default-information originate always metric-type (1|2) metric <0-16777214>",
5986 "Control distribution of default information\n"
5987 "Distribute a default route\n"
5988 "Always advertise default route\n"
5989 "OSPF metric type for default routes\n"
5990 "Set OSPF External Type 1 metrics\n"
5991 "Set OSPF External Type 2 metrics\n"
5992 "OSPF default metric\n"
5993 "OSPF metric\n")
5994
5995ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5996 ospf_default_information_originate_always_type_cmd,
5997 "default-information originate always metric-type (1|2)",
5998 "Control distribution of default information\n"
5999 "Distribute a default route\n"
6000 "Always advertise default route\n"
6001 "OSPF metric type for default routes\n"
6002 "Set OSPF External Type 1 metrics\n"
6003 "Set OSPF External Type 2 metrics\n")
6004
6005DEFUN (ospf_default_information_originate_always_type_routemap,
6006 ospf_default_information_originate_always_type_routemap_cmd,
6007 "default-information originate always metric-type (1|2) route-map WORD",
6008 "Control distribution of default information\n"
6009 "Distribute a default route\n"
6010 "Always advertise default route\n"
6011 "OSPF metric type for default routes\n"
6012 "Set OSPF External Type 1 metrics\n"
6013 "Set OSPF External Type 2 metrics\n"
6014 "Route map reference\n"
6015 "Pointer to route-map entries\n")
6016{
paul020709f2003-04-04 02:44:16 +00006017 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006018 int type = -1;
6019
6020 /* Get metric type. */
6021 if (argc >= 1)
6022 if (!str2metric_type (argv[0], &type))
6023 return CMD_WARNING;
6024
6025 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006026 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006027 else
paul020709f2003-04-04 02:44:16 +00006028 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006029
paul020709f2003-04-04 02:44:16 +00006030 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006031 type, -1);
6032}
6033
6034DEFUN (no_ospf_default_information_originate,
6035 no_ospf_default_information_originate_cmd,
6036 "no default-information originate",
6037 NO_STR
6038 "Control distribution of default information\n"
6039 "Distribute a default route\n")
6040{
paul68980082003-03-25 05:07:42 +00006041 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006042 struct prefix_ipv4 p;
6043 struct in_addr nexthop;
6044
6045 p.family = AF_INET;
6046 p.prefix.s_addr = 0;
6047 p.prefixlen = 0;
6048
paul68980082003-03-25 05:07:42 +00006049 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
paul718e3742002-12-13 20:15:29 +00006050
6051 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6052 ospf_external_info_delete (DEFAULT_ROUTE, p);
6053 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6054 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6055 }
6056
paul020709f2003-04-04 02:44:16 +00006057 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6058 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006059}
6060
6061DEFUN (ospf_default_metric,
6062 ospf_default_metric_cmd,
6063 "default-metric <0-16777214>",
6064 "Set metric of redistributed routes\n"
6065 "Default metric\n")
6066{
paul68980082003-03-25 05:07:42 +00006067 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006068 int metric = -1;
6069
6070 if (!str2metric (argv[0], &metric))
6071 return CMD_WARNING;
6072
paul68980082003-03-25 05:07:42 +00006073 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006074
6075 return CMD_SUCCESS;
6076}
6077
6078DEFUN (no_ospf_default_metric,
6079 no_ospf_default_metric_cmd,
6080 "no default-metric",
6081 NO_STR
6082 "Set metric of redistributed routes\n")
6083{
paul68980082003-03-25 05:07:42 +00006084 struct ospf *ospf = vty->index;
6085
6086 ospf->default_metric = -1;
6087
paul718e3742002-12-13 20:15:29 +00006088 return CMD_SUCCESS;
6089}
6090
6091ALIAS (no_ospf_default_metric,
6092 no_ospf_default_metric_val_cmd,
6093 "no default-metric <0-16777214>",
6094 NO_STR
6095 "Set metric of redistributed routes\n"
6096 "Default metric\n")
6097
6098DEFUN (ospf_distance,
6099 ospf_distance_cmd,
6100 "distance <1-255>",
6101 "Define an administrative distance\n"
6102 "OSPF Administrative distance\n")
6103{
paul68980082003-03-25 05:07:42 +00006104 struct ospf *ospf = vty->index;
6105
6106 ospf->distance_all = atoi (argv[0]);
6107
paul718e3742002-12-13 20:15:29 +00006108 return CMD_SUCCESS;
6109}
6110
6111DEFUN (no_ospf_distance,
6112 no_ospf_distance_cmd,
6113 "no distance <1-255>",
6114 NO_STR
6115 "Define an administrative distance\n"
6116 "OSPF Administrative distance\n")
6117{
paul68980082003-03-25 05:07:42 +00006118 struct ospf *ospf = vty->index;
6119
6120 ospf->distance_all = 0;
6121
paul718e3742002-12-13 20:15:29 +00006122 return CMD_SUCCESS;
6123}
6124
6125DEFUN (no_ospf_distance_ospf,
6126 no_ospf_distance_ospf_cmd,
6127 "no distance ospf",
6128 NO_STR
6129 "Define an administrative distance\n"
6130 "OSPF Administrative distance\n"
6131 "OSPF Distance\n")
6132{
paul68980082003-03-25 05:07:42 +00006133 struct ospf *ospf = vty->index;
6134
6135 ospf->distance_intra = 0;
6136 ospf->distance_inter = 0;
6137 ospf->distance_external = 0;
6138
paul718e3742002-12-13 20:15:29 +00006139 return CMD_SUCCESS;
6140}
6141
6142DEFUN (ospf_distance_ospf_intra,
6143 ospf_distance_ospf_intra_cmd,
6144 "distance ospf intra-area <1-255>",
6145 "Define an administrative distance\n"
6146 "OSPF Administrative distance\n"
6147 "Intra-area routes\n"
6148 "Distance for intra-area routes\n")
6149{
paul68980082003-03-25 05:07:42 +00006150 struct ospf *ospf = vty->index;
6151
6152 ospf->distance_intra = atoi (argv[0]);
6153
paul718e3742002-12-13 20:15:29 +00006154 return CMD_SUCCESS;
6155}
6156
6157DEFUN (ospf_distance_ospf_intra_inter,
6158 ospf_distance_ospf_intra_inter_cmd,
6159 "distance ospf intra-area <1-255> inter-area <1-255>",
6160 "Define an administrative distance\n"
6161 "OSPF Administrative distance\n"
6162 "Intra-area routes\n"
6163 "Distance for intra-area routes\n"
6164 "Inter-area routes\n"
6165 "Distance for inter-area routes\n")
6166{
paul68980082003-03-25 05:07:42 +00006167 struct ospf *ospf = vty->index;
6168
6169 ospf->distance_intra = atoi (argv[0]);
6170 ospf->distance_inter = atoi (argv[1]);
6171
paul718e3742002-12-13 20:15:29 +00006172 return CMD_SUCCESS;
6173}
6174
6175DEFUN (ospf_distance_ospf_intra_external,
6176 ospf_distance_ospf_intra_external_cmd,
6177 "distance ospf intra-area <1-255> external <1-255>",
6178 "Define an administrative distance\n"
6179 "OSPF Administrative distance\n"
6180 "Intra-area routes\n"
6181 "Distance for intra-area routes\n"
6182 "External routes\n"
6183 "Distance for external routes\n")
6184{
paul68980082003-03-25 05:07:42 +00006185 struct ospf *ospf = vty->index;
6186
6187 ospf->distance_intra = atoi (argv[0]);
6188 ospf->distance_external = atoi (argv[1]);
6189
paul718e3742002-12-13 20:15:29 +00006190 return CMD_SUCCESS;
6191}
6192
6193DEFUN (ospf_distance_ospf_intra_inter_external,
6194 ospf_distance_ospf_intra_inter_external_cmd,
6195 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6196 "Define an administrative distance\n"
6197 "OSPF Administrative distance\n"
6198 "Intra-area routes\n"
6199 "Distance for intra-area routes\n"
6200 "Inter-area routes\n"
6201 "Distance for inter-area routes\n"
6202 "External routes\n"
6203 "Distance for external routes\n")
6204{
paul68980082003-03-25 05:07:42 +00006205 struct ospf *ospf = vty->index;
6206
6207 ospf->distance_intra = atoi (argv[0]);
6208 ospf->distance_inter = atoi (argv[1]);
6209 ospf->distance_external = atoi (argv[2]);
6210
paul718e3742002-12-13 20:15:29 +00006211 return CMD_SUCCESS;
6212}
6213
6214DEFUN (ospf_distance_ospf_intra_external_inter,
6215 ospf_distance_ospf_intra_external_inter_cmd,
6216 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6217 "Define an administrative distance\n"
6218 "OSPF Administrative distance\n"
6219 "Intra-area routes\n"
6220 "Distance for intra-area routes\n"
6221 "External routes\n"
6222 "Distance for external routes\n"
6223 "Inter-area routes\n"
6224 "Distance for inter-area routes\n")
6225{
paul68980082003-03-25 05:07:42 +00006226 struct ospf *ospf = vty->index;
6227
6228 ospf->distance_intra = atoi (argv[0]);
6229 ospf->distance_external = atoi (argv[1]);
6230 ospf->distance_inter = atoi (argv[2]);
6231
paul718e3742002-12-13 20:15:29 +00006232 return CMD_SUCCESS;
6233}
6234
6235DEFUN (ospf_distance_ospf_inter,
6236 ospf_distance_ospf_inter_cmd,
6237 "distance ospf inter-area <1-255>",
6238 "Define an administrative distance\n"
6239 "OSPF Administrative distance\n"
6240 "Inter-area routes\n"
6241 "Distance for inter-area routes\n")
6242{
paul68980082003-03-25 05:07:42 +00006243 struct ospf *ospf = vty->index;
6244
6245 ospf->distance_inter = atoi (argv[0]);
6246
paul718e3742002-12-13 20:15:29 +00006247 return CMD_SUCCESS;
6248}
6249
6250DEFUN (ospf_distance_ospf_inter_intra,
6251 ospf_distance_ospf_inter_intra_cmd,
6252 "distance ospf inter-area <1-255> intra-area <1-255>",
6253 "Define an administrative distance\n"
6254 "OSPF Administrative distance\n"
6255 "Inter-area routes\n"
6256 "Distance for inter-area routes\n"
6257 "Intra-area routes\n"
6258 "Distance for intra-area routes\n")
6259{
paul68980082003-03-25 05:07:42 +00006260 struct ospf *ospf = vty->index;
6261
6262 ospf->distance_inter = atoi (argv[0]);
6263 ospf->distance_intra = atoi (argv[1]);
6264
paul718e3742002-12-13 20:15:29 +00006265 return CMD_SUCCESS;
6266}
6267
6268DEFUN (ospf_distance_ospf_inter_external,
6269 ospf_distance_ospf_inter_external_cmd,
6270 "distance ospf inter-area <1-255> external <1-255>",
6271 "Define an administrative distance\n"
6272 "OSPF Administrative distance\n"
6273 "Inter-area routes\n"
6274 "Distance for inter-area routes\n"
6275 "External routes\n"
6276 "Distance for external routes\n")
6277{
paul68980082003-03-25 05:07:42 +00006278 struct ospf *ospf = vty->index;
6279
6280 ospf->distance_inter = atoi (argv[0]);
6281 ospf->distance_external = atoi (argv[1]);
6282
paul718e3742002-12-13 20:15:29 +00006283 return CMD_SUCCESS;
6284}
6285
6286DEFUN (ospf_distance_ospf_inter_intra_external,
6287 ospf_distance_ospf_inter_intra_external_cmd,
6288 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6289 "Define an administrative distance\n"
6290 "OSPF Administrative distance\n"
6291 "Inter-area routes\n"
6292 "Distance for inter-area routes\n"
6293 "Intra-area routes\n"
6294 "Distance for intra-area routes\n"
6295 "External routes\n"
6296 "Distance for external routes\n")
6297{
paul68980082003-03-25 05:07:42 +00006298 struct ospf *ospf = vty->index;
6299
6300 ospf->distance_inter = atoi (argv[0]);
6301 ospf->distance_intra = atoi (argv[1]);
6302 ospf->distance_external = atoi (argv[2]);
6303
paul718e3742002-12-13 20:15:29 +00006304 return CMD_SUCCESS;
6305}
6306
6307DEFUN (ospf_distance_ospf_inter_external_intra,
6308 ospf_distance_ospf_inter_external_intra_cmd,
6309 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6310 "Define an administrative distance\n"
6311 "OSPF Administrative distance\n"
6312 "Inter-area routes\n"
6313 "Distance for inter-area routes\n"
6314 "External routes\n"
6315 "Distance for external routes\n"
6316 "Intra-area routes\n"
6317 "Distance for intra-area routes\n")
6318{
paul68980082003-03-25 05:07:42 +00006319 struct ospf *ospf = vty->index;
6320
6321 ospf->distance_inter = atoi (argv[0]);
6322 ospf->distance_external = atoi (argv[1]);
6323 ospf->distance_intra = atoi (argv[2]);
6324
paul718e3742002-12-13 20:15:29 +00006325 return CMD_SUCCESS;
6326}
6327
6328DEFUN (ospf_distance_ospf_external,
6329 ospf_distance_ospf_external_cmd,
6330 "distance ospf external <1-255>",
6331 "Define an administrative distance\n"
6332 "OSPF Administrative distance\n"
6333 "External routes\n"
6334 "Distance for external routes\n")
6335{
paul68980082003-03-25 05:07:42 +00006336 struct ospf *ospf = vty->index;
6337
6338 ospf->distance_external = atoi (argv[0]);
6339
paul718e3742002-12-13 20:15:29 +00006340 return CMD_SUCCESS;
6341}
6342
6343DEFUN (ospf_distance_ospf_external_intra,
6344 ospf_distance_ospf_external_intra_cmd,
6345 "distance ospf external <1-255> intra-area <1-255>",
6346 "Define an administrative distance\n"
6347 "OSPF Administrative distance\n"
6348 "External routes\n"
6349 "Distance for external routes\n"
6350 "Intra-area routes\n"
6351 "Distance for intra-area routes\n")
6352{
paul68980082003-03-25 05:07:42 +00006353 struct ospf *ospf = vty->index;
6354
6355 ospf->distance_external = atoi (argv[0]);
6356 ospf->distance_intra = atoi (argv[1]);
6357
paul718e3742002-12-13 20:15:29 +00006358 return CMD_SUCCESS;
6359}
6360
6361DEFUN (ospf_distance_ospf_external_inter,
6362 ospf_distance_ospf_external_inter_cmd,
6363 "distance ospf external <1-255> inter-area <1-255>",
6364 "Define an administrative distance\n"
6365 "OSPF Administrative distance\n"
6366 "External routes\n"
6367 "Distance for external routes\n"
6368 "Inter-area routes\n"
6369 "Distance for inter-area routes\n")
6370{
paul68980082003-03-25 05:07:42 +00006371 struct ospf *ospf = vty->index;
6372
6373 ospf->distance_external = atoi (argv[0]);
6374 ospf->distance_inter = atoi (argv[1]);
6375
paul718e3742002-12-13 20:15:29 +00006376 return CMD_SUCCESS;
6377}
6378
6379DEFUN (ospf_distance_ospf_external_intra_inter,
6380 ospf_distance_ospf_external_intra_inter_cmd,
6381 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6382 "Define an administrative distance\n"
6383 "OSPF Administrative distance\n"
6384 "External routes\n"
6385 "Distance for external routes\n"
6386 "Intra-area routes\n"
6387 "Distance for intra-area routes\n"
6388 "Inter-area routes\n"
6389 "Distance for inter-area routes\n")
6390{
paul68980082003-03-25 05:07:42 +00006391 struct ospf *ospf = vty->index;
6392
6393 ospf->distance_external = atoi (argv[0]);
6394 ospf->distance_intra = atoi (argv[1]);
6395 ospf->distance_inter = atoi (argv[2]);
6396
paul718e3742002-12-13 20:15:29 +00006397 return CMD_SUCCESS;
6398}
6399
6400DEFUN (ospf_distance_ospf_external_inter_intra,
6401 ospf_distance_ospf_external_inter_intra_cmd,
6402 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6403 "Define an administrative distance\n"
6404 "OSPF Administrative distance\n"
6405 "External routes\n"
6406 "Distance for external routes\n"
6407 "Inter-area routes\n"
6408 "Distance for inter-area routes\n"
6409 "Intra-area routes\n"
6410 "Distance for intra-area routes\n")
6411{
paul68980082003-03-25 05:07:42 +00006412 struct ospf *ospf = vty->index;
6413
6414 ospf->distance_external = atoi (argv[0]);
6415 ospf->distance_inter = atoi (argv[1]);
6416 ospf->distance_intra = atoi (argv[2]);
6417
paul718e3742002-12-13 20:15:29 +00006418 return CMD_SUCCESS;
6419}
6420
6421DEFUN (ospf_distance_source,
6422 ospf_distance_source_cmd,
6423 "distance <1-255> A.B.C.D/M",
6424 "Administrative distance\n"
6425 "Distance value\n"
6426 "IP source prefix\n")
6427{
paul020709f2003-04-04 02:44:16 +00006428 struct ospf *ospf = vty->index;
6429
6430 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006431
paul718e3742002-12-13 20:15:29 +00006432 return CMD_SUCCESS;
6433}
6434
6435DEFUN (no_ospf_distance_source,
6436 no_ospf_distance_source_cmd,
6437 "no distance <1-255> A.B.C.D/M",
6438 NO_STR
6439 "Administrative distance\n"
6440 "Distance value\n"
6441 "IP source prefix\n")
6442{
paul020709f2003-04-04 02:44:16 +00006443 struct ospf *ospf = vty->index;
6444
6445 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6446
paul718e3742002-12-13 20:15:29 +00006447 return CMD_SUCCESS;
6448}
6449
6450DEFUN (ospf_distance_source_access_list,
6451 ospf_distance_source_access_list_cmd,
6452 "distance <1-255> A.B.C.D/M WORD",
6453 "Administrative distance\n"
6454 "Distance value\n"
6455 "IP source prefix\n"
6456 "Access list name\n")
6457{
paul020709f2003-04-04 02:44:16 +00006458 struct ospf *ospf = vty->index;
6459
6460 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6461
paul718e3742002-12-13 20:15:29 +00006462 return CMD_SUCCESS;
6463}
6464
6465DEFUN (no_ospf_distance_source_access_list,
6466 no_ospf_distance_source_access_list_cmd,
6467 "no distance <1-255> A.B.C.D/M WORD",
6468 NO_STR
6469 "Administrative distance\n"
6470 "Distance value\n"
6471 "IP source prefix\n"
6472 "Access list name\n")
6473{
paul020709f2003-04-04 02:44:16 +00006474 struct ospf *ospf = vty->index;
6475
6476 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6477
paul718e3742002-12-13 20:15:29 +00006478 return CMD_SUCCESS;
6479}
6480
6481void
6482show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6483{
6484 struct route_node *rn;
6485 struct ospf_route *or;
6486 listnode pnode;
6487 struct ospf_path *path;
6488
6489 vty_out (vty, "============ OSPF network routing table ============%s",
6490 VTY_NEWLINE);
6491
6492 for (rn = route_top (rt); rn; rn = route_next (rn))
6493 if ((or = rn->info) != NULL)
6494 {
6495 char buf1[19];
6496 snprintf (buf1, 19, "%s/%d",
6497 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6498
6499 switch (or->path_type)
6500 {
6501 case OSPF_PATH_INTER_AREA:
6502 if (or->type == OSPF_DESTINATION_NETWORK)
6503 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6504 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6505 else if (or->type == OSPF_DESTINATION_DISCARD)
6506 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6507 break;
6508 case OSPF_PATH_INTRA_AREA:
6509 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6510 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6511 break;
6512 default:
6513 break;
6514 }
6515
6516 if (or->type == OSPF_DESTINATION_NETWORK)
paul96735ee2003-08-10 02:51:22 +00006517 LIST_LOOP (or->paths, path, pnode)
6518 {
6519 if (path->oi != NULL)
6520 {
6521 if (path->nexthop.s_addr == 0)
6522 vty_out (vty, "%24s directly attached to %s%s",
6523 "", path->oi->ifp->name, VTY_NEWLINE);
6524 else
6525 vty_out (vty, "%24s via %s, %s%s", "",
6526 inet_ntoa (path->nexthop), path->oi->ifp->name,
6527 VTY_NEWLINE);
6528 }
6529 }
paul718e3742002-12-13 20:15:29 +00006530 }
6531 vty_out (vty, "%s", VTY_NEWLINE);
6532}
6533
6534void
6535show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6536{
6537 struct route_node *rn;
6538 struct ospf_route *or;
6539 listnode pn, nn;
6540 struct ospf_path *path;
6541
6542 vty_out (vty, "============ OSPF router routing table =============%s",
6543 VTY_NEWLINE);
6544 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6545 if (rn->info)
6546 {
6547 int flag = 0;
6548
6549 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6550
6551 for (nn = listhead ((list) rn->info); nn; nextnode (nn))
6552 if ((or = getdata (nn)) != NULL)
6553 {
6554 if (flag++)
paulb0a053b2003-06-22 09:04:47 +00006555 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006556
6557 /* Show path. */
6558 vty_out (vty, "%s [%d] area: %s",
6559 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6560 or->cost, inet_ntoa (or->u.std.area_id));
6561 /* Show flags. */
6562 vty_out (vty, "%s%s%s",
6563 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6564 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6565 VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006566
6567 LIST_LOOP (or->paths, path, pn)
6568 {
6569 if (path->nexthop.s_addr == 0)
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);
6576 }
paul718e3742002-12-13 20:15:29 +00006577 }
6578 }
6579 vty_out (vty, "%s", VTY_NEWLINE);
6580}
6581
6582void
6583show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6584{
6585 struct route_node *rn;
6586 struct ospf_route *er;
6587 listnode pnode;
6588 struct ospf_path *path;
6589
6590 vty_out (vty, "============ OSPF external routing table ===========%s",
6591 VTY_NEWLINE);
6592 for (rn = route_top (rt); rn; rn = route_next (rn))
6593 if ((er = rn->info) != NULL)
6594 {
6595 char buf1[19];
6596 snprintf (buf1, 19, "%s/%d",
6597 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6598
6599 switch (er->path_type)
6600 {
6601 case OSPF_PATH_TYPE1_EXTERNAL:
6602 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6603 er->cost, er->u.ext.tag, VTY_NEWLINE);
6604 break;
6605 case OSPF_PATH_TYPE2_EXTERNAL:
6606 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6607 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6608 break;
6609 }
6610
paul96735ee2003-08-10 02:51:22 +00006611 LIST_LOOP (er->paths, path, pnode)
paul718e3742002-12-13 20:15:29 +00006612 {
paul718e3742002-12-13 20:15:29 +00006613 if (path->oi != NULL)
6614 {
6615 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006616 vty_out (vty, "%24s directly attached to %s%s",
6617 "", path->oi->ifp->name, VTY_NEWLINE);
6618 else
6619 vty_out (vty, "%24s via %s, %s%s", "",
6620 inet_ntoa (path->nexthop), path->oi->ifp->name,
6621 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006622 }
6623 }
6624 }
6625 vty_out (vty, "%s", VTY_NEWLINE);
6626}
6627
6628#ifdef HAVE_NSSA
6629DEFUN (show_ip_ospf_border_routers,
6630 show_ip_ospf_border_routers_cmd,
6631 "show ip ospf border-routers",
6632 SHOW_STR
6633 IP_STR
6634 "show all the ABR's and ASBR's\n"
6635 "for this area\n")
6636{
paul020709f2003-04-04 02:44:16 +00006637 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006638
paul020709f2003-04-04 02:44:16 +00006639 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006640 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006641 {
6642 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6643 return CMD_SUCCESS;
6644 }
6645
paul68980082003-03-25 05:07:42 +00006646 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006647 {
6648 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6649 return CMD_SUCCESS;
6650 }
6651
6652 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006653 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006654
6655 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006656 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006657
6658 return CMD_SUCCESS;
6659}
6660#endif /* HAVE_NSSA */
6661
6662DEFUN (show_ip_ospf_route,
6663 show_ip_ospf_route_cmd,
6664 "show ip ospf route",
6665 SHOW_STR
6666 IP_STR
6667 "OSPF information\n"
6668 "OSPF routing table\n")
6669{
paul020709f2003-04-04 02:44:16 +00006670 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006671
paul020709f2003-04-04 02:44:16 +00006672 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006673 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006674 {
6675 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6676 return CMD_SUCCESS;
6677 }
6678
paul68980082003-03-25 05:07:42 +00006679 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006680 {
6681 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6682 return CMD_SUCCESS;
6683 }
6684
6685 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006686 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006687
6688 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006689 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006690
6691 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006692 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006693
6694 return CMD_SUCCESS;
6695}
6696
6697
6698char *ospf_abr_type_str[] =
6699{
6700 "unknown",
6701 "standard",
6702 "ibm",
6703 "cisco",
6704 "shortcut"
6705};
6706
6707char *ospf_shortcut_mode_str[] =
6708{
6709 "default",
6710 "enable",
6711 "disable"
6712};
6713
6714
6715void
6716area_id2str (char *buf, int length, struct ospf_area *area)
6717{
6718 memset (buf, 0, length);
6719
6720 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6721 strncpy (buf, inet_ntoa (area->area_id), length);
6722 else
6723 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6724}
6725
6726
6727char *ospf_int_type_str[] =
6728{
6729 "unknown", /* should never be used. */
6730 "point-to-point",
6731 "broadcast",
6732 "non-broadcast",
6733 "point-to-multipoint",
6734 "virtual-link", /* should never be used. */
6735 "loopback"
6736};
6737
6738/* Configuration write function for ospfd. */
6739int
6740config_write_interface (struct vty *vty)
6741{
6742 listnode n1, n2;
6743 struct interface *ifp;
6744 struct crypt_key *ck;
6745 int write = 0;
6746 struct route_node *rn = NULL;
6747 struct ospf_if_params *params;
6748
6749 for (n1 = listhead (iflist); n1; nextnode (n1))
6750 {
6751 ifp = getdata (n1);
6752
6753 if (memcmp (ifp->name, "VLINK", 5) == 0)
6754 continue;
6755
6756 vty_out (vty, "!%s", VTY_NEWLINE);
6757 vty_out (vty, "interface %s%s", ifp->name,
6758 VTY_NEWLINE);
6759 if (ifp->desc)
6760 vty_out (vty, " description %s%s", ifp->desc,
6761 VTY_NEWLINE);
6762
6763 write++;
6764
6765 params = IF_DEF_PARAMS (ifp);
6766
6767 do {
6768 /* Interface Network print. */
6769 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
6770 params->type != OSPF_IFTYPE_BROADCAST &&
6771 params->type != OSPF_IFTYPE_LOOPBACK)
6772 {
6773 vty_out (vty, " ip ospf network %s",
6774 ospf_int_type_str[params->type]);
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 /* OSPF interface authentication print */
6781 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6782 params->auth_type != OSPF_AUTH_NOTSET)
6783 {
6784 char *auth_str;
6785
6786 /* Translation tables are not that much help here due to syntax
6787 of the simple option */
6788 switch (params->auth_type)
6789 {
6790
6791 case OSPF_AUTH_NULL:
6792 auth_str = " null";
6793 break;
6794
6795 case OSPF_AUTH_SIMPLE:
6796 auth_str = "";
6797 break;
6798
6799 case OSPF_AUTH_CRYPTOGRAPHIC:
6800 auth_str = " message-digest";
6801 break;
6802
6803 default:
6804 auth_str = "";
6805 break;
6806 }
6807
6808 vty_out (vty, " ip ospf authentication%s", auth_str);
6809 if (params != IF_DEF_PARAMS (ifp))
6810 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6811 vty_out (vty, "%s", VTY_NEWLINE);
6812 }
6813
6814 /* Simple Authentication Password print. */
6815 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6816 params->auth_simple[0] != '\0')
6817 {
6818 vty_out (vty, " ip ospf authentication-key %s",
6819 params->auth_simple);
6820 if (params != IF_DEF_PARAMS (ifp))
6821 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6822 vty_out (vty, "%s", VTY_NEWLINE);
6823 }
6824
6825 /* Cryptographic Authentication Key print. */
6826 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
6827 {
6828 ck = getdata (n2);
6829 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6830 ck->key_id, ck->auth_key);
6831 if (params != IF_DEF_PARAMS (ifp))
6832 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6833 vty_out (vty, "%s", VTY_NEWLINE);
6834 }
6835
6836 /* Interface Output Cost print. */
6837 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6838 {
6839 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6840 if (params != IF_DEF_PARAMS (ifp))
6841 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6842 vty_out (vty, "%s", VTY_NEWLINE);
6843 }
6844
6845 /* Hello Interval print. */
6846 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6847 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6848 {
6849 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6850 if (params != IF_DEF_PARAMS (ifp))
6851 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6852 vty_out (vty, "%s", VTY_NEWLINE);
6853 }
6854
6855
6856 /* Router Dead Interval print. */
6857 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6858 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6859 {
6860 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6861 if (params != IF_DEF_PARAMS (ifp))
6862 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6863 vty_out (vty, "%s", VTY_NEWLINE);
6864 }
6865
6866 /* Router Priority print. */
6867 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6868 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6869 {
6870 vty_out (vty, " ip ospf priority %u", params->priority);
6871 if (params != IF_DEF_PARAMS (ifp))
6872 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6873 vty_out (vty, "%s", VTY_NEWLINE);
6874 }
6875
6876 /* Retransmit Interval print. */
6877 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6878 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6879 {
6880 vty_out (vty, " ip ospf retransmit-interval %u",
6881 params->retransmit_interval);
6882 if (params != IF_DEF_PARAMS (ifp))
6883 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6884 vty_out (vty, "%s", VTY_NEWLINE);
6885 }
6886
6887 /* Transmit Delay print. */
6888 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6889 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6890 {
6891 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6892 if (params != IF_DEF_PARAMS (ifp))
6893 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6894 vty_out (vty, "%s", VTY_NEWLINE);
6895 }
6896
6897 while (1)
6898 {
6899 if (rn == NULL)
6900 rn = route_top (IF_OIFS_PARAMS (ifp));
6901 else
6902 rn = route_next (rn);
6903
6904 if (rn == NULL)
6905 break;
6906 params = rn->info;
6907 if (params != NULL)
6908 break;
6909 }
6910 } while (rn);
6911
6912#ifdef HAVE_OPAQUE_LSA
6913 ospf_opaque_config_write_if (vty, ifp);
6914#endif /* HAVE_OPAQUE_LSA */
6915 }
6916
6917 return write;
6918}
6919
6920int
paul68980082003-03-25 05:07:42 +00006921config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006922{
6923 struct route_node *rn;
6924 u_char buf[INET_ADDRSTRLEN];
6925
6926 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006927 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006928 if (rn->info)
6929 {
6930 struct ospf_network *n = rn->info;
6931
6932 memset (buf, 0, INET_ADDRSTRLEN);
6933
6934 /* Create Area ID string by specified Area ID format. */
6935 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6936 strncpy (buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
6937 else
6938 sprintf (buf, "%lu",
6939 (unsigned long int) ntohl (n->area_id.s_addr));
6940
6941 /* Network print. */
6942 vty_out (vty, " network %s/%d area %s%s",
6943 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6944 buf, VTY_NEWLINE);
6945 }
6946
6947 return 0;
6948}
6949
6950int
paul68980082003-03-25 05:07:42 +00006951config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006952{
6953 listnode node;
6954 u_char buf[INET_ADDRSTRLEN];
6955
6956 /* Area configuration print. */
paul68980082003-03-25 05:07:42 +00006957 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00006958 {
6959 struct ospf_area *area = getdata (node);
6960 struct route_node *rn1;
6961
6962 area_id2str (buf, INET_ADDRSTRLEN, area);
6963
6964 if (area->auth_type != OSPF_AUTH_NULL)
6965 {
6966 if (area->auth_type == OSPF_AUTH_SIMPLE)
6967 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6968 else
6969 vty_out (vty, " area %s authentication message-digest%s",
6970 buf, VTY_NEWLINE);
6971 }
6972
6973 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6974 vty_out (vty, " area %s shortcut %s%s", buf,
6975 ospf_shortcut_mode_str[area->shortcut_configured],
6976 VTY_NEWLINE);
6977
6978 if ((area->external_routing == OSPF_AREA_STUB)
6979#ifdef HAVE_NSSA
6980 || (area->external_routing == OSPF_AREA_NSSA)
6981#endif /* HAVE_NSSA */
6982 )
6983 {
paulb0a053b2003-06-22 09:04:47 +00006984 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006985 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00006986#ifdef HAVE_NSSA
6987 else if (area->external_routing == OSPF_AREA_NSSA)
6988 {
6989 vty_out (vty, " area %s nssa", buf);
6990 switch (area->NSSATranslatorRole)
6991 {
6992 case OSPF_NSSA_ROLE_NEVER:
6993 vty_out (vty, " translate-never");
6994 break;
6995 case OSPF_NSSA_ROLE_ALWAYS:
6996 vty_out (vty, " translate-always");
6997 break;
6998 case OSPF_NSSA_ROLE_CANDIDATE:
6999 default:
7000 vty_out (vty, " translate-candidate");
7001 }
7002 }
7003#endif /* HAVE_NSSA */
paul718e3742002-12-13 20:15:29 +00007004
7005 if (area->no_summary)
7006 vty_out (vty, " no-summary");
7007
7008 vty_out (vty, "%s", VTY_NEWLINE);
7009
7010 if (area->default_cost != 1)
7011 vty_out (vty, " area %s default-cost %d%s", buf,
7012 area->default_cost, VTY_NEWLINE);
7013 }
7014
7015 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7016 if (rn1->info)
7017 {
7018 struct ospf_area_range *range = rn1->info;
7019
7020 vty_out (vty, " area %s range %s/%d", buf,
7021 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7022
7023 if (range->cost_config != -1)
7024 vty_out (vty, " cost %d", range->cost_config);
7025
7026 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7027 vty_out (vty, " not-advertise");
7028
7029 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7030 vty_out (vty, " substitute %s/%d",
7031 inet_ntoa (range->subst_addr), range->subst_masklen);
7032
7033 vty_out (vty, "%s", VTY_NEWLINE);
7034 }
7035
7036 if (EXPORT_NAME (area))
7037 vty_out (vty, " area %s export-list %s%s", buf,
7038 EXPORT_NAME (area), VTY_NEWLINE);
7039
7040 if (IMPORT_NAME (area))
7041 vty_out (vty, " area %s import-list %s%s", buf,
7042 IMPORT_NAME (area), VTY_NEWLINE);
7043
7044 if (PREFIX_NAME_IN (area))
7045 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7046 PREFIX_NAME_IN (area), VTY_NEWLINE);
7047
7048 if (PREFIX_NAME_OUT (area))
7049 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7050 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7051 }
7052
7053 return 0;
7054}
7055
7056int
paul68980082003-03-25 05:07:42 +00007057config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007058{
7059 struct ospf_nbr_nbma *nbr_nbma;
7060 struct route_node *rn;
7061
7062 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007063 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007064 if ((nbr_nbma = rn->info))
7065 {
7066 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7067
7068 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7069 vty_out (vty, " priority %d", nbr_nbma->priority);
7070
7071 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7072 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7073
7074 vty_out (vty, "%s", VTY_NEWLINE);
7075 }
7076
7077 return 0;
7078}
7079
7080int
paul68980082003-03-25 05:07:42 +00007081config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007082{
7083 listnode node;
7084 u_char buf[INET_ADDRSTRLEN];
7085
7086 /* Virtual-Link print */
paul68980082003-03-25 05:07:42 +00007087 for (node = listhead (ospf->vlinks); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007088 {
7089 listnode n2;
7090 struct crypt_key *ck;
7091 struct ospf_vl_data *vl_data = getdata (node);
7092 struct ospf_interface *oi;
7093
7094 if (vl_data != NULL)
7095 {
7096 memset (buf, 0, INET_ADDRSTRLEN);
7097
7098 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7099 strncpy (buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
7100 else
7101 sprintf (buf, "%lu",
7102 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7103 oi = vl_data->vl_oi;
7104
7105 /* timers */
7106 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7107 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7108 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7109 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7110 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7111 buf,
7112 inet_ntoa (vl_data->vl_peer),
7113 OSPF_IF_PARAM (oi, v_hello),
7114 OSPF_IF_PARAM (oi, retransmit_interval),
7115 OSPF_IF_PARAM (oi, transmit_delay),
7116 OSPF_IF_PARAM (oi, v_wait),
7117 VTY_NEWLINE);
7118 else
7119 vty_out (vty, " area %s virtual-link %s%s", buf,
7120 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7121 /* Auth key */
7122 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7123 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7124 buf,
7125 inet_ntoa (vl_data->vl_peer),
7126 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7127 VTY_NEWLINE);
7128 /* md5 keys */
7129 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
7130 {
7131 ck = getdata (n2);
7132 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
7133 buf,
7134 inet_ntoa (vl_data->vl_peer),
7135 ck->key_id, ck->auth_key, VTY_NEWLINE);
7136 }
7137
7138 }
7139 }
7140
7141 return 0;
7142}
7143
7144
7145char *distribute_str[] = { "system", "kernel", "connected", "static", "rip",
hasso42ed9da2004-03-20 18:59:59 +00007146 "ripng", "ospf", "ospf6", "isis", "bgp"};
paul718e3742002-12-13 20:15:29 +00007147int
paul68980082003-03-25 05:07:42 +00007148config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007149{
7150 int type;
7151
7152 /* redistribute print. */
7153 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7154 if (type != zclient->redist_default && zclient->redist[type])
7155 {
7156 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007157 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007158 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007159
paul68980082003-03-25 05:07:42 +00007160 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007161 vty_out (vty, " metric-type 1");
7162
paul020709f2003-04-04 02:44:16 +00007163 if (ROUTEMAP_NAME (ospf, type))
7164 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007165
7166 vty_out (vty, "%s", VTY_NEWLINE);
7167 }
7168
7169 return 0;
7170}
7171
7172int
paul68980082003-03-25 05:07:42 +00007173config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007174{
paul68980082003-03-25 05:07:42 +00007175 if (ospf->default_metric != -1)
7176 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007177 VTY_NEWLINE);
7178 return 0;
7179}
7180
7181int
paul68980082003-03-25 05:07:42 +00007182config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007183{
7184 int type;
7185
paul68980082003-03-25 05:07:42 +00007186 if (ospf)
paul718e3742002-12-13 20:15:29 +00007187 {
7188 /* distribute-list print. */
7189 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007190 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007191 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007192 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007193 distribute_str[type], VTY_NEWLINE);
7194
7195 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007196 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007197 {
paul68980082003-03-25 05:07:42 +00007198 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007199 vty_out (vty, " default-information originate");
7200 else
7201 vty_out (vty, " default-information originate always");
7202
paul68980082003-03-25 05:07:42 +00007203 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007204 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007205 ospf->dmetric[DEFAULT_ROUTE].value);
7206 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007207 vty_out (vty, " metric-type 1");
7208
paul020709f2003-04-04 02:44:16 +00007209 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7210 vty_out (vty, " route-map %s",
7211 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007212
7213 vty_out (vty, "%s", VTY_NEWLINE);
7214 }
7215
7216 }
7217
7218 return 0;
7219}
7220
7221int
paul68980082003-03-25 05:07:42 +00007222config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007223{
7224 struct route_node *rn;
7225 struct ospf_distance *odistance;
7226
paul68980082003-03-25 05:07:42 +00007227 if (ospf->distance_all)
7228 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007229
paul68980082003-03-25 05:07:42 +00007230 if (ospf->distance_intra
7231 || ospf->distance_inter
7232 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007233 {
7234 vty_out (vty, " distance ospf");
7235
paul68980082003-03-25 05:07:42 +00007236 if (ospf->distance_intra)
7237 vty_out (vty, " intra-area %d", ospf->distance_intra);
7238 if (ospf->distance_inter)
7239 vty_out (vty, " inter-area %d", ospf->distance_inter);
7240 if (ospf->distance_external)
7241 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007242
7243 vty_out (vty, "%s", VTY_NEWLINE);
7244 }
7245
paul68980082003-03-25 05:07:42 +00007246 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007247 if ((odistance = rn->info) != NULL)
7248 {
7249 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7250 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7251 odistance->access_list ? odistance->access_list : "",
7252 VTY_NEWLINE);
7253 }
7254 return 0;
7255}
7256
7257/* OSPF configuration write function. */
7258int
7259ospf_config_write (struct vty *vty)
7260{
paul020709f2003-04-04 02:44:16 +00007261 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00007262 listnode node;
7263 int write = 0;
7264
paul020709f2003-04-04 02:44:16 +00007265 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007266 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007267 {
7268 /* `router ospf' print. */
7269 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7270
7271 write++;
7272
paul68980082003-03-25 05:07:42 +00007273 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007274 return write;
7275
7276 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007277 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007278 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007279 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007280
7281 /* ABR type print. */
paul68980082003-03-25 05:07:42 +00007282 if (ospf->abr_type != OSPF_ABR_STAND)
paul718e3742002-12-13 20:15:29 +00007283 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007284 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007285
7286 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007287 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007288 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7289
7290 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007291 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007292 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007293 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007294
7295 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007296 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7297 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007298 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007299 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007300
7301 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007302 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007303 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007304 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007305
7306 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007307 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007308
7309 /* passive-interface print. */
paul020709f2003-04-04 02:44:16 +00007310 for (node = listhead (om->iflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007311 {
7312 struct interface *ifp = getdata (node);
7313
7314 if (!ifp)
7315 continue;
7316 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7317 vty_out (vty, " passive-interface %s%s",
7318 ifp->name, VTY_NEWLINE);
7319 }
7320
paul68980082003-03-25 05:07:42 +00007321 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007322 {
7323 struct ospf_interface *oi = getdata (node);
7324
7325 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7326 oi->params->passive_interface == OSPF_IF_PASSIVE)
paul96735ee2003-08-10 02:51:22 +00007327 vty_out (vty, " passive-interface %s %s%s",
7328 oi->ifp->name,
paul5fdc1e52003-08-06 22:41:29 +00007329 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007330 }
7331
7332
7333 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007334 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007335
7336 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007337 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007338
7339 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007340 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007341
7342 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007343 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007344
7345 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007346 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007347
7348 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007349 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007350
7351 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007352 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007353
7354#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007355 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007356#endif /* HAVE_OPAQUE_LSA */
7357 }
7358
7359 return write;
7360}
7361
7362void
7363ospf_vty_show_init ()
7364{
7365 /* "show ip ospf" commands. */
7366 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7367 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7368
7369 /* "show ip ospf database" commands. */
7370 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7371 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7372 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7373 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7374 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7375 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7376 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7377 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7378 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7379 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7380 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7381 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7382 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7383 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7384
7385 /* "show ip ospf interface" commands. */
7386 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7387 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7388
7389 /* "show ip ospf neighbor" commands. */
7390 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7391 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7392 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7393 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7394 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7395 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7396 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7397 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7398 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7399 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7400 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7401 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7402 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7403 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7404
7405 /* "show ip ospf route" commands. */
7406 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7407 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
7408#ifdef HAVE_NSSA
7409 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7410 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
7411#endif /* HAVE_NSSA */
7412}
7413
7414
7415/* ospfd's interface node. */
7416struct cmd_node interface_node =
7417{
7418 INTERFACE_NODE,
7419 "%s(config-if)# ",
7420 1
7421};
7422
7423/* Initialization of OSPF interface. */
7424void
7425ospf_vty_if_init ()
7426{
7427 /* Install interface node. */
7428 install_node (&interface_node, config_write_interface);
7429
7430 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007431 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007432 install_default (INTERFACE_NODE);
7433
7434 /* "description" commands. */
7435 install_element (INTERFACE_NODE, &interface_desc_cmd);
7436 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7437
7438 /* "ip ospf authentication" commands. */
7439 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7440 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7441 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7442 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7443 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7444 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7445 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7446 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7447 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7448 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7449
7450 /* "ip ospf message-digest-key" commands. */
7451 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7452 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7453 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7454 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7455
7456 /* "ip ospf cost" commands. */
7457 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7458 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7459 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7460 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7461
7462 /* "ip ospf dead-interval" commands. */
7463 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7464 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7465 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7466 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7467
7468 /* "ip ospf hello-interval" commands. */
7469 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7470 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7471 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7472 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7473
7474 /* "ip ospf network" commands. */
7475 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7476 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7477
7478 /* "ip ospf priority" commands. */
7479 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7480 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7481 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7482 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7483
7484 /* "ip ospf retransmit-interval" commands. */
7485 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7486 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7487 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7488 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7489
7490 /* "ip ospf transmit-delay" commands. */
7491 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7492 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7493 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7494 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7495
7496 /* These commands are compatibitliy for previous version. */
7497 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7498 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7499 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7500 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7501 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7502 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7503 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7504 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7505 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7506 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7507 install_element (INTERFACE_NODE, &ospf_network_cmd);
7508 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7509 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7510 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7511 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7512 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7513 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7514 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7515}
7516
7517/* Zebra node structure. */
7518struct cmd_node zebra_node =
7519{
7520 ZEBRA_NODE,
7521 "%s(config-router)#",
7522};
7523
7524void
7525ospf_vty_zebra_init ()
7526{
7527 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7528 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7529 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7530 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7531 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7532 install_element (OSPF_NODE,
7533 &ospf_redistribute_source_metric_type_routemap_cmd);
7534 install_element (OSPF_NODE,
7535 &ospf_redistribute_source_type_metric_routemap_cmd);
7536 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7537 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7538 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7539
7540 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7541
7542 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7543 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7544
7545 install_element (OSPF_NODE,
7546 &ospf_default_information_originate_metric_type_cmd);
7547 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7548 install_element (OSPF_NODE,
7549 &ospf_default_information_originate_type_metric_cmd);
7550 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7551 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7552 install_element (OSPF_NODE,
7553 &ospf_default_information_originate_always_metric_type_cmd);
7554 install_element (OSPF_NODE,
7555 &ospf_default_information_originate_always_metric_cmd);
7556 install_element (OSPF_NODE,
7557 &ospf_default_information_originate_always_cmd);
7558 install_element (OSPF_NODE,
7559 &ospf_default_information_originate_always_type_metric_cmd);
7560 install_element (OSPF_NODE,
7561 &ospf_default_information_originate_always_type_cmd);
7562
7563 install_element (OSPF_NODE,
7564 &ospf_default_information_originate_metric_type_routemap_cmd);
7565 install_element (OSPF_NODE,
7566 &ospf_default_information_originate_metric_routemap_cmd);
7567 install_element (OSPF_NODE,
7568 &ospf_default_information_originate_routemap_cmd);
7569 install_element (OSPF_NODE,
7570 &ospf_default_information_originate_type_metric_routemap_cmd);
7571 install_element (OSPF_NODE,
7572 &ospf_default_information_originate_type_routemap_cmd);
7573 install_element (OSPF_NODE,
7574 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7575 install_element (OSPF_NODE,
7576 &ospf_default_information_originate_always_metric_routemap_cmd);
7577 install_element (OSPF_NODE,
7578 &ospf_default_information_originate_always_routemap_cmd);
7579 install_element (OSPF_NODE,
7580 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7581 install_element (OSPF_NODE,
7582 &ospf_default_information_originate_always_type_routemap_cmd);
7583
7584 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7585
7586 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7587 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7588 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7589
7590 install_element (OSPF_NODE, &ospf_distance_cmd);
7591 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7592 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7593 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7594 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7595 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7596 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7597 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7598 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7599 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7600 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7601 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7602 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7603 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7604 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7605 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7606 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7607 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7608#if 0
7609 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7610 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7611 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7612 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7613#endif /* 0 */
7614}
7615
7616struct cmd_node ospf_node =
7617{
7618 OSPF_NODE,
7619 "%s(config-router)# ",
7620 1
7621};
7622
7623
7624/* Install OSPF related vty commands. */
7625void
7626ospf_vty_init ()
7627{
7628 /* Install ospf top node. */
7629 install_node (&ospf_node, ospf_config_write);
7630
7631 /* "router ospf" commands. */
7632 install_element (CONFIG_NODE, &router_ospf_cmd);
7633 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7634
7635 install_default (OSPF_NODE);
7636
7637 /* "ospf router-id" commands. */
7638 install_element (OSPF_NODE, &ospf_router_id_cmd);
7639 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007640 install_element (OSPF_NODE, &router_ospf_id_cmd);
7641 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007642
7643 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007644 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7645 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7646 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7647 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007648
7649 /* "ospf abr-type" commands. */
7650 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7651 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7652
7653 /* "ospf rfc1583-compatible" commands. */
7654 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7655 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7656 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7657 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7658
7659 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007660 install_element (OSPF_NODE, &ospf_network_area_cmd);
7661 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007662
7663 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007664 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7665 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7666 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007667
7668 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007669 install_element (OSPF_NODE, &ospf_area_range_cmd);
7670 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7671 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7672 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7673 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7674 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7675 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7676 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7677 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7678 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7679 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007680
7681 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007682 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7683 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007684
paula2c62832003-04-23 17:01:31 +00007685 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7686 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007687
paula2c62832003-04-23 17:01:31 +00007688 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7689 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007690
paula2c62832003-04-23 17:01:31 +00007691 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7692 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007693
paula2c62832003-04-23 17:01:31 +00007694 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7695 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007696
paula2c62832003-04-23 17:01:31 +00007697 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7698 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7699 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007700
paula2c62832003-04-23 17:01:31 +00007701 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7702 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007703
paula2c62832003-04-23 17:01:31 +00007704 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7705 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007706
paula2c62832003-04-23 17:01:31 +00007707 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7708 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7709 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007710
paula2c62832003-04-23 17:01:31 +00007711 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7712 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7713 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007714
7715 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007716 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7717 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7718 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7719 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007720
7721#ifdef HAVE_NSSA
7722 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007723 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7724 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7725 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7726 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7727 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7728 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007729#endif /* HAVE_NSSA */
7730
paula2c62832003-04-23 17:01:31 +00007731 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7732 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007733
paula2c62832003-04-23 17:01:31 +00007734 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7735 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007736
paula2c62832003-04-23 17:01:31 +00007737 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7738 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007739
paula2c62832003-04-23 17:01:31 +00007740 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7741 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007742
paula2c62832003-04-23 17:01:31 +00007743 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7744 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007745
paula2c62832003-04-23 17:01:31 +00007746 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7747 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007748
paula2c62832003-04-23 17:01:31 +00007749 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7750 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7751 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007752
paula2c62832003-04-23 17:01:31 +00007753 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7754 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007755
7756 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007757 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7758 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7759 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7760 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7761 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7762 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7763 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7764 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007765
7766 /* Init interface related vty commands. */
7767 ospf_vty_if_init ();
7768
7769 /* Init zebra related vty commands. */
7770 ospf_vty_zebra_init ();
7771}