blob: 7a5c49a8ea60d23cd96199905ed15a088ac8aba6 [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
paul68980082003-03-25 05:07:42 +00001705 area = ospf_area_get (ospf, area_id, format);
1706 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001707
1708 return CMD_SUCCESS;
1709}
1710
paula2c62832003-04-23 17:01:31 +00001711DEFUN (no_ospf_area_export_list,
1712 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001713 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1714 NO_STR
1715 "OSPF area parameters\n"
1716 "OSPF area ID in IP address format\n"
1717 "OSPF area ID as a decimal value\n"
1718 "Unset the filter for networks announced to other areas\n"
1719 "Name of the access-list\n")
1720{
paul68980082003-03-25 05:07:42 +00001721 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001722 struct ospf_area *area;
1723 struct in_addr area_id;
1724 int format;
1725
paul68980082003-03-25 05:07:42 +00001726 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001727 if (area == NULL)
1728 return CMD_SUCCESS;
1729
paul68980082003-03-25 05:07:42 +00001730 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001731
1732 return CMD_SUCCESS;
1733}
1734
1735
paula2c62832003-04-23 17:01:31 +00001736DEFUN (ospf_area_import_list,
1737 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001738 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1739 "OSPF area parameters\n"
1740 "OSPF area ID in IP address format\n"
1741 "OSPF area ID as a decimal value\n"
1742 "Set the filter for networks from other areas announced to the specified one\n"
1743 "Name of the access-list\n")
1744{
paul68980082003-03-25 05:07:42 +00001745 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001746 struct ospf_area *area;
1747 struct in_addr area_id;
1748 int format;
1749
paul68980082003-03-25 05:07:42 +00001750 area = ospf_area_get (ospf, area_id, format);
1751 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001752
1753 return CMD_SUCCESS;
1754}
1755
paula2c62832003-04-23 17:01:31 +00001756DEFUN (no_ospf_area_import_list,
1757 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001758 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1759 NO_STR
1760 "OSPF area parameters\n"
1761 "OSPF area ID in IP address format\n"
1762 "OSPF area ID as a decimal value\n"
1763 "Unset the filter for networks announced to other areas\n"
1764 "Name of the access-list\n")
1765{
paul68980082003-03-25 05:07:42 +00001766 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001767 struct ospf_area *area;
1768 struct in_addr area_id;
1769 int format;
1770
paul68980082003-03-25 05:07:42 +00001771 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001772 if (area == NULL)
1773 return CMD_SUCCESS;
1774
paul68980082003-03-25 05:07:42 +00001775 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001776
1777 return CMD_SUCCESS;
1778}
1779
paula2c62832003-04-23 17:01:31 +00001780DEFUN (ospf_area_filter_list,
1781 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001782 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1783 "OSPF area parameters\n"
1784 "OSPF area ID in IP address format\n"
1785 "OSPF area ID as a decimal value\n"
1786 "Filter networks between OSPF areas\n"
1787 "Filter prefixes between OSPF areas\n"
1788 "Name of an IP prefix-list\n"
1789 "Filter networks sent to this area\n"
1790 "Filter networks sent from this area\n")
1791{
paul68980082003-03-25 05:07:42 +00001792 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001793 struct ospf_area *area;
1794 struct in_addr area_id;
1795 struct prefix_list *plist;
1796 int format;
1797
1798 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1799
paul68980082003-03-25 05:07:42 +00001800 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001801 plist = prefix_list_lookup (AFI_IP, argv[1]);
1802 if (strncmp (argv[2], "in", 2) == 0)
1803 {
1804 PREFIX_LIST_IN (area) = plist;
1805 if (PREFIX_NAME_IN (area))
1806 free (PREFIX_NAME_IN (area));
1807
1808 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001809 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001810 }
1811 else
1812 {
1813 PREFIX_LIST_OUT (area) = plist;
1814 if (PREFIX_NAME_OUT (area))
1815 free (PREFIX_NAME_OUT (area));
1816
1817 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001818 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001819 }
1820
1821 return CMD_SUCCESS;
1822}
1823
paula2c62832003-04-23 17:01:31 +00001824DEFUN (no_ospf_area_filter_list,
1825 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001826 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1827 NO_STR
1828 "OSPF area parameters\n"
1829 "OSPF area ID in IP address format\n"
1830 "OSPF area ID as a decimal value\n"
1831 "Filter networks between OSPF areas\n"
1832 "Filter prefixes between OSPF areas\n"
1833 "Name of an IP prefix-list\n"
1834 "Filter networks sent to this area\n"
1835 "Filter networks sent from this area\n")
1836{
paul68980082003-03-25 05:07:42 +00001837 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001838 struct ospf_area *area;
1839 struct in_addr area_id;
1840 struct prefix_list *plist;
1841 int format;
1842
1843 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1844
paul68980082003-03-25 05:07:42 +00001845 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001846 plist = prefix_list_lookup (AFI_IP, argv[1]);
1847 if (strncmp (argv[2], "in", 2) == 0)
1848 {
1849 if (PREFIX_NAME_IN (area))
1850 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1851 return CMD_SUCCESS;
1852
1853 PREFIX_LIST_IN (area) = NULL;
1854 if (PREFIX_NAME_IN (area))
1855 free (PREFIX_NAME_IN (area));
1856
1857 PREFIX_NAME_IN (area) = NULL;
1858
paul68980082003-03-25 05:07:42 +00001859 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001860 }
1861 else
1862 {
1863 if (PREFIX_NAME_OUT (area))
1864 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1865 return CMD_SUCCESS;
1866
1867 PREFIX_LIST_OUT (area) = NULL;
1868 if (PREFIX_NAME_OUT (area))
1869 free (PREFIX_NAME_OUT (area));
1870
1871 PREFIX_NAME_OUT (area) = NULL;
1872
paul68980082003-03-25 05:07:42 +00001873 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001874 }
1875
1876 return CMD_SUCCESS;
1877}
1878
1879
paula2c62832003-04-23 17:01:31 +00001880DEFUN (ospf_area_authentication_message_digest,
1881 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001882 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1883 "OSPF area parameters\n"
1884 "Enable authentication\n"
1885 "Use message-digest authentication\n")
1886{
paul68980082003-03-25 05:07:42 +00001887 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001888 struct ospf_area *area;
1889 struct in_addr area_id;
1890 int format;
1891
1892 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1893
paul68980082003-03-25 05:07:42 +00001894 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001895 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1896
1897 return CMD_SUCCESS;
1898}
1899
paula2c62832003-04-23 17:01:31 +00001900DEFUN (ospf_area_authentication,
1901 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001902 "area (A.B.C.D|<0-4294967295>) authentication",
1903 "OSPF area parameters\n"
1904 "OSPF area ID in IP address format\n"
1905 "OSPF area ID as a decimal value\n"
1906 "Enable authentication\n")
1907{
paul68980082003-03-25 05:07:42 +00001908 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001909 struct ospf_area *area;
1910 struct in_addr area_id;
1911 int format;
1912
1913 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1914
paul68980082003-03-25 05:07:42 +00001915 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001916 area->auth_type = OSPF_AUTH_SIMPLE;
1917
1918 return CMD_SUCCESS;
1919}
1920
paula2c62832003-04-23 17:01:31 +00001921DEFUN (no_ospf_area_authentication,
1922 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001923 "no area (A.B.C.D|<0-4294967295>) authentication",
1924 NO_STR
1925 "OSPF area parameters\n"
1926 "OSPF area ID in IP address format\n"
1927 "OSPF area ID as a decimal value\n"
1928 "Enable authentication\n")
1929{
paul68980082003-03-25 05:07:42 +00001930 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001931 struct ospf_area *area;
1932 struct in_addr area_id;
1933 int format;
1934
1935 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1936
paul68980082003-03-25 05:07:42 +00001937 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001938 if (area == NULL)
1939 return CMD_SUCCESS;
1940
1941 area->auth_type = OSPF_AUTH_NULL;
1942
paul68980082003-03-25 05:07:42 +00001943 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001944
1945 return CMD_SUCCESS;
1946}
1947
1948
1949DEFUN (ospf_abr_type,
1950 ospf_abr_type_cmd,
1951 "ospf abr-type (cisco|ibm|shortcut|standard)",
1952 "OSPF specific commands\n"
1953 "Set OSPF ABR type\n"
1954 "Alternative ABR, cisco implementation\n"
1955 "Alternative ABR, IBM implementation\n"
1956 "Shortcut ABR\n"
1957 "Standard behavior (RFC2328)\n")
1958{
paul68980082003-03-25 05:07:42 +00001959 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001960 u_char abr_type = OSPF_ABR_UNKNOWN;
1961
1962 if (strncmp (argv[0], "c", 1) == 0)
1963 abr_type = OSPF_ABR_CISCO;
1964 else if (strncmp (argv[0], "i", 1) == 0)
1965 abr_type = OSPF_ABR_IBM;
1966 else if (strncmp (argv[0], "sh", 2) == 0)
1967 abr_type = OSPF_ABR_SHORTCUT;
1968 else if (strncmp (argv[0], "st", 2) == 0)
1969 abr_type = OSPF_ABR_STAND;
1970 else
1971 return CMD_WARNING;
1972
1973 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00001974 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00001975 {
paul68980082003-03-25 05:07:42 +00001976 ospf->abr_type = abr_type;
1977 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001978 }
1979
1980 return CMD_SUCCESS;
1981}
1982
1983DEFUN (no_ospf_abr_type,
1984 no_ospf_abr_type_cmd,
1985 "no ospf abr-type (cisco|ibm|shortcut)",
1986 NO_STR
1987 "OSPF specific commands\n"
1988 "Set OSPF ABR type\n"
1989 "Alternative ABR, cisco implementation\n"
1990 "Alternative ABR, IBM implementation\n"
1991 "Shortcut ABR\n")
1992{
paul68980082003-03-25 05:07:42 +00001993 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001994 u_char abr_type = OSPF_ABR_UNKNOWN;
1995
1996 if (strncmp (argv[0], "c", 1) == 0)
1997 abr_type = OSPF_ABR_CISCO;
1998 else if (strncmp (argv[0], "i", 1) == 0)
1999 abr_type = OSPF_ABR_IBM;
2000 else if (strncmp (argv[0], "s", 1) == 0)
2001 abr_type = OSPF_ABR_SHORTCUT;
2002 else
2003 return CMD_WARNING;
2004
2005 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002006 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002007 {
paul68980082003-03-25 05:07:42 +00002008 ospf->abr_type = OSPF_ABR_STAND;
2009 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002010 }
2011
2012 return CMD_SUCCESS;
2013}
2014
2015DEFUN (ospf_compatible_rfc1583,
2016 ospf_compatible_rfc1583_cmd,
2017 "compatible rfc1583",
2018 "OSPF compatibility list\n"
2019 "compatible with RFC 1583\n")
2020{
2021 struct ospf *ospf = vty->index;
2022
2023 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2024 {
2025 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002026 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002027 }
2028 return CMD_SUCCESS;
2029}
2030
2031DEFUN (no_ospf_compatible_rfc1583,
2032 no_ospf_compatible_rfc1583_cmd,
2033 "no compatible rfc1583",
2034 NO_STR
2035 "OSPF compatibility list\n"
2036 "compatible with RFC 1583\n")
2037{
2038 struct ospf *ospf = vty->index;
2039
2040 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2041 {
2042 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002043 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002044 }
2045 return CMD_SUCCESS;
2046}
2047
2048ALIAS (ospf_compatible_rfc1583,
2049 ospf_rfc1583_flag_cmd,
2050 "ospf rfc1583compatibility",
2051 "OSPF specific commands\n"
2052 "Enable the RFC1583Compatibility flag\n")
2053
2054ALIAS (no_ospf_compatible_rfc1583,
2055 no_ospf_rfc1583_flag_cmd,
2056 "no ospf rfc1583compatibility",
2057 NO_STR
2058 "OSPF specific commands\n"
2059 "Disable the RFC1583Compatibility flag\n")
2060
paula2c62832003-04-23 17:01:31 +00002061DEFUN (ospf_timers_spf,
2062 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002063 "timers spf <0-4294967295> <0-4294967295>",
2064 "Adjust routing timers\n"
2065 "OSPF SPF timers\n"
2066 "Delay between receiving a change to SPF calculation\n"
2067 "Hold time between consecutive SPF calculations\n")
2068{
2069 struct ospf *ospf = vty->index;
2070 u_int32_t delay, hold;
2071
2072 VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]);
2073 VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]);
2074
2075 ospf_timers_spf_set (ospf, delay, hold);
2076
2077 return CMD_SUCCESS;
2078}
2079
paula2c62832003-04-23 17:01:31 +00002080DEFUN (no_ospf_timers_spf,
2081 no_ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002082 "no timers spf",
2083 NO_STR
2084 "Adjust routing timers\n"
2085 "OSPF SPF timers\n")
2086{
paul68980082003-03-25 05:07:42 +00002087 struct ospf *ospf = vty->index;
2088
2089 ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT;
2090 ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002091
2092 return CMD_SUCCESS;
2093}
2094
2095
paula2c62832003-04-23 17:01:31 +00002096DEFUN (ospf_neighbor,
2097 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002098 "neighbor A.B.C.D",
2099 NEIGHBOR_STR
2100 "Neighbor IP address\n")
2101{
2102 struct ospf *ospf = vty->index;
2103 struct in_addr nbr_addr;
2104 int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2105 int interval = OSPF_POLL_INTERVAL_DEFAULT;
2106
2107 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2108
2109 if (argc > 1)
2110 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2111
2112 if (argc > 2)
2113 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2114
2115 ospf_nbr_nbma_set (ospf, nbr_addr);
2116 if (argc > 1)
2117 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2118 if (argc > 2)
2119 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2120
2121 return CMD_SUCCESS;
2122}
2123
paula2c62832003-04-23 17:01:31 +00002124ALIAS (ospf_neighbor,
2125 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002126 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2127 NEIGHBOR_STR
2128 "Neighbor IP address\n"
2129 "Neighbor Priority\n"
2130 "Priority\n"
2131 "Dead Neighbor Polling interval\n"
2132 "Seconds\n")
2133
paula2c62832003-04-23 17:01:31 +00002134ALIAS (ospf_neighbor,
2135 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002136 "neighbor A.B.C.D priority <0-255>",
2137 NEIGHBOR_STR
2138 "Neighbor IP address\n"
2139 "Neighbor Priority\n"
2140 "Seconds\n")
2141
paula2c62832003-04-23 17:01:31 +00002142DEFUN (ospf_neighbor_poll_interval,
2143 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002144 "neighbor A.B.C.D poll-interval <1-65535>",
2145 NEIGHBOR_STR
2146 "Neighbor IP address\n"
2147 "Dead Neighbor Polling interval\n"
2148 "Seconds\n")
2149{
2150 struct ospf *ospf = vty->index;
2151 struct in_addr nbr_addr;
2152 int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2153 int interval = OSPF_POLL_INTERVAL_DEFAULT;
2154
2155 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2156
2157 if (argc > 1)
2158 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2159
2160 if (argc > 2)
2161 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2162
2163 ospf_nbr_nbma_set (ospf, nbr_addr);
2164 if (argc > 1)
2165 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2166 if (argc > 2)
2167 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2168
2169 return CMD_SUCCESS;
2170}
2171
paula2c62832003-04-23 17:01:31 +00002172ALIAS (ospf_neighbor_poll_interval,
2173 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002174 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2175 NEIGHBOR_STR
2176 "Neighbor address\n"
2177 "OSPF dead-router polling interval\n"
2178 "Seconds\n"
2179 "OSPF priority of non-broadcast neighbor\n"
2180 "Priority\n")
2181
paula2c62832003-04-23 17:01:31 +00002182DEFUN (no_ospf_neighbor,
2183 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002184 "no neighbor A.B.C.D",
2185 NO_STR
2186 NEIGHBOR_STR
2187 "Neighbor IP address\n")
2188{
2189 struct ospf *ospf = vty->index;
2190 struct in_addr nbr_addr;
2191 int ret;
2192
2193 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2194
2195 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2196
2197 return CMD_SUCCESS;
2198}
2199
paula2c62832003-04-23 17:01:31 +00002200ALIAS (no_ospf_neighbor,
2201 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002202 "no neighbor A.B.C.D priority <0-255>",
2203 NO_STR
2204 NEIGHBOR_STR
2205 "Neighbor IP address\n"
2206 "Neighbor Priority\n"
2207 "Priority\n")
2208
paula2c62832003-04-23 17:01:31 +00002209ALIAS (no_ospf_neighbor,
2210 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002211 "no neighbor A.B.C.D poll-interval <1-65535>",
2212 NO_STR
2213 NEIGHBOR_STR
2214 "Neighbor IP address\n"
2215 "Dead Neighbor Polling interval\n"
2216 "Seconds\n")
2217
paula2c62832003-04-23 17:01:31 +00002218ALIAS (no_ospf_neighbor,
2219 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002220 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2221 NO_STR
2222 NEIGHBOR_STR
2223 "Neighbor IP address\n"
2224 "Neighbor Priority\n"
2225 "Priority\n"
2226 "Dead Neighbor Polling interval\n"
2227 "Seconds\n")
2228
2229
paula2c62832003-04-23 17:01:31 +00002230DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002231 "refresh timer <10-1800>",
2232 "Adjust refresh parameters\n"
2233 "Set refresh timer\n"
2234 "Timer value in seconds\n")
2235{
2236 struct ospf *ospf = vty->index;
2237 int interval;
2238
2239 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2240 interval = (interval / 10) * 10;
2241
2242 ospf_timers_refresh_set (ospf, interval);
2243
2244 return CMD_SUCCESS;
2245}
2246
paula2c62832003-04-23 17:01:31 +00002247DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002248 "no refresh timer <10-1800>",
2249 "Adjust refresh parameters\n"
2250 "Unset refresh timer\n"
2251 "Timer value in seconds\n")
2252{
2253 struct ospf *ospf = vty->index;
2254 int interval;
2255
2256 if (argc == 1)
2257 {
2258 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2259
2260 if (ospf->lsa_refresh_interval != interval ||
2261 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2262 return CMD_SUCCESS;
2263 }
2264
2265 ospf_timers_refresh_unset (ospf);
2266
2267 return CMD_SUCCESS;
2268}
2269
paula2c62832003-04-23 17:01:31 +00002270ALIAS (no_ospf_refresh_timer,
2271 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002272 "no refresh timer",
2273 "Adjust refresh parameters\n"
2274 "Unset refresh timer\n")
2275
paula2c62832003-04-23 17:01:31 +00002276DEFUN (ospf_auto_cost_reference_bandwidth,
2277 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002278 "auto-cost reference-bandwidth <1-4294967>",
2279 "Calculate OSPF interface cost according to bandwidth\n"
2280 "Use reference bandwidth method to assign OSPF cost\n"
2281 "The reference bandwidth in terms of Mbits per second\n")
2282{
paul68980082003-03-25 05:07:42 +00002283 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002284 u_int32_t refbw;
2285 listnode node;
2286
2287 refbw = strtol (argv[0], NULL, 10);
2288 if (refbw < 1 || refbw > 4294967)
2289 {
2290 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2291 return CMD_WARNING;
2292 }
2293
2294 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002295 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002296 return CMD_SUCCESS;
2297
paul68980082003-03-25 05:07:42 +00002298 ospf->ref_bandwidth = refbw * 1000;
paul718e3742002-12-13 20:15:29 +00002299 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2300 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2301
paul020709f2003-04-04 02:44:16 +00002302 for (node = listhead (om->iflist); node; nextnode (node))
2303 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002304
2305 return CMD_SUCCESS;
2306}
2307
paula2c62832003-04-23 17:01:31 +00002308DEFUN (no_ospf_auto_cost_reference_bandwidth,
2309 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002310 "no auto-cost reference-bandwidth",
2311 NO_STR
2312 "Calculate OSPF interface cost according to bandwidth\n"
2313 "Use reference bandwidth method to assign OSPF cost\n")
2314{
paul68980082003-03-25 05:07:42 +00002315 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002316 listnode node;
2317
paul68980082003-03-25 05:07:42 +00002318 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002319 return CMD_SUCCESS;
2320
paul68980082003-03-25 05:07:42 +00002321 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002322 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2323 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2324
paul020709f2003-04-04 02:44:16 +00002325 for (node = listhead (om->iflist); node; nextnode (node))
2326 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002327
2328 return CMD_SUCCESS;
2329}
2330
paul718e3742002-12-13 20:15:29 +00002331char *ospf_abr_type_descr_str[] =
2332{
2333 "Unknown",
2334 "Standard (RFC2328)",
2335 "Alternative IBM",
2336 "Alternative Cisco",
2337 "Alternative Shortcut"
2338};
2339
2340char *ospf_shortcut_mode_descr_str[] =
2341{
2342 "Default",
2343 "Enabled",
2344 "Disabled"
2345};
2346
2347
2348
2349void
2350show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2351{
2352 /* Show Area ID. */
2353 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2354
2355 /* Show Area type/mode. */
2356 if (OSPF_IS_AREA_BACKBONE (area))
2357 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2358 else
2359 {
2360 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002361 vty_out (vty, " (Stub%s%s)",
2362 area->no_summary ? ", no summary" : "",
2363 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002364
2365#ifdef HAVE_NSSA
2366
paulb0a053b2003-06-22 09:04:47 +00002367 else if (area->external_routing == OSPF_AREA_NSSA)
2368 vty_out (vty, " (NSSA%s%s)",
2369 area->no_summary ? ", no summary" : "",
2370 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002371#endif /* HAVE_NSSA */
2372
2373 vty_out (vty, "%s", VTY_NEWLINE);
2374 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002375 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002376 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002377 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002378 }
2379
2380 /* Show number of interfaces. */
2381 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2382 "Active: %d%s", listcount (area->oiflist),
2383 area->act_ints, VTY_NEWLINE);
2384
2385#ifdef HAVE_NSSA
2386 if (area->external_routing == OSPF_AREA_NSSA)
2387 {
2388 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 +00002389 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002390 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2391 VTY_NEWLINE);
2392 else if (area->NSSATranslatorState)
2393 {
2394 vty_out (vty, " We are an ABR and ");
2395 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2396 vty_out (vty, "the NSSA Elected Translator. %s",
2397 VTY_NEWLINE);
2398 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2399 vty_out (vty, "always an NSSA Translator. %s",
2400 VTY_NEWLINE);
2401 }
paul718e3742002-12-13 20:15:29 +00002402 else
paulb0a053b2003-06-22 09:04:47 +00002403 {
2404 vty_out (vty, " We are an ABR, but ");
2405 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2406 vty_out (vty, "not the NSSA Elected Translator. %s",
2407 VTY_NEWLINE);
2408 else
2409 vty_out (vty, "not the NSSA Elected Translator. %s",
2410 VTY_NEWLINE);
2411 }
paul718e3742002-12-13 20:15:29 +00002412 }
2413#endif /* HAVE_NSSA */
2414
2415 /* Show number of fully adjacent neighbors. */
2416 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002417 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002418
2419 /* Show authentication type. */
2420 vty_out (vty, " Area has ");
2421 if (area->auth_type == OSPF_AUTH_NULL)
2422 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2423 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2424 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2425 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2426 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2427
2428 if (!OSPF_IS_AREA_BACKBONE (area))
2429 vty_out (vty, " Number of full virtual adjacencies going through"
2430 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2431
2432 /* Show SPF calculation times. */
2433 vty_out (vty, " SPF algorithm executed %d times%s",
2434 area->spf_calculation, VTY_NEWLINE);
2435
2436 /* Show number of LSA. */
2437 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
2438
2439 vty_out (vty, "%s", VTY_NEWLINE);
2440}
2441
2442DEFUN (show_ip_ospf,
2443 show_ip_ospf_cmd,
2444 "show ip ospf",
2445 SHOW_STR
2446 IP_STR
2447 "OSPF information\n")
2448{
2449 listnode node;
2450 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002451 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002452
2453 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002454 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002455 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002456 {
2457 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2458 return CMD_SUCCESS;
2459 }
2460
2461 /* Show Router ID. */
2462 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002463 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002464 VTY_NEWLINE);
2465
2466 /* Show capability. */
2467 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2468 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2469 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002470 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002471 "enabled" : "disabled", VTY_NEWLINE);
2472#ifdef HAVE_OPAQUE_LSA
2473 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002474 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002475 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002476 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002477 " (origination blocked)" : "",
2478 VTY_NEWLINE);
2479#endif /* HAVE_OPAQUE_LSA */
2480
2481 /* Show SPF timers. */
2482 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
paul68980082003-03-25 05:07:42 +00002483 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002484
2485 /* Show refresh parameters. */
2486 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002487 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002488
2489 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002490 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002491 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002492 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002493
paul68980082003-03-25 05:07:42 +00002494 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002495 vty_out (vty, " This router is an ASBR "
2496 "(injecting external routing information)%s", VTY_NEWLINE);
2497
2498 /* Show Number of AS-external-LSAs. */
2499 vty_out (vty, " Number of external LSA %ld%s",
paul68980082003-03-25 05:07:42 +00002500 ospf_lsdb_count_all (ospf->lsdb), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002501
2502 /* Show number of areas attached. */
2503 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002504 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002505
2506 /* Show each area status. */
paul68980082003-03-25 05:07:42 +00002507 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002508 if ((area = getdata (node)) != NULL)
2509 show_ip_ospf_area (vty, area);
2510
2511 return CMD_SUCCESS;
2512}
2513
2514
2515void
paul68980082003-03-25 05:07:42 +00002516show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2517 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002518{
2519 struct ospf_neighbor *nbr;
2520 int oi_count;
2521 struct route_node *rn;
2522 char buf[9];
2523
2524 oi_count = ospf_oi_count (ifp);
2525
2526 /* Is interface up? */
paul2e3b2e42002-12-13 21:03:13 +00002527 if (if_is_operative (ifp)) {
2528 vty_out (vty, "%s is up%s", ifp->name, VTY_NEWLINE);
2529 } else
2530 {
2531 vty_out (vty, "%s is down%s", ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002532
2533
2534 if (oi_count == 0)
2535 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2536 else
2537 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2538 VTY_NEWLINE);
2539 return;
2540 }
2541
2542 /* Is interface OSPF enabled? */
2543 if (oi_count == 0)
2544 {
2545 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2546 return;
2547 }
2548
2549 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2550 {
2551 struct ospf_interface *oi = rn->info;
2552
2553 if (oi == NULL)
2554 continue;
2555
2556 /* Show OSPF interface information. */
2557 vty_out (vty, " Internet Address %s/%d,",
2558 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2559
2560 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2561 VTY_NEWLINE);
2562
2563 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002564 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002565 oi->output_cost, VTY_NEWLINE);
2566
2567 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2568 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2569 PRIORITY (oi), VTY_NEWLINE);
2570
2571 /* Show DR information. */
2572 if (DR (oi).s_addr == 0)
2573 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2574 else
2575 {
2576 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2577 if (nbr == NULL)
2578 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2579 else
2580 {
2581 vty_out (vty, " Designated Router (ID) %s,",
2582 inet_ntoa (nbr->router_id));
2583 vty_out (vty, " Interface Address %s%s",
2584 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2585 }
2586 }
2587
2588 /* Show BDR information. */
2589 if (BDR (oi).s_addr == 0)
2590 vty_out (vty, " No backup designated router on this network%s",
2591 VTY_NEWLINE);
2592 else
2593 {
2594 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2595 if (nbr == NULL)
2596 vty_out (vty, " No backup designated router on this network%s",
2597 VTY_NEWLINE);
2598 else
2599 {
2600 vty_out (vty, " Backup Designated Router (ID) %s,",
2601 inet_ntoa (nbr->router_id));
2602 vty_out (vty, " Interface Address %s%s",
2603 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2604 }
2605 }
2606 vty_out (vty, " Timer intervals configured,");
2607 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2608 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2609 OSPF_IF_PARAM (oi, v_wait),
2610 OSPF_IF_PARAM (oi, retransmit_interval),
2611 VTY_NEWLINE);
2612
2613 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2614 vty_out (vty, " Hello due in %s%s",
2615 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2616 else /* OSPF_IF_PASSIVE is set */
2617 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2618
2619 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002620 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002621 VTY_NEWLINE);
2622 }
2623}
2624
2625DEFUN (show_ip_ospf_interface,
2626 show_ip_ospf_interface_cmd,
2627 "show ip ospf interface [INTERFACE]",
2628 SHOW_STR
2629 IP_STR
2630 "OSPF information\n"
2631 "Interface information\n"
2632 "Interface name\n")
2633{
2634 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002635 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002636 listnode node;
2637
paul020709f2003-04-04 02:44:16 +00002638 ospf = ospf_lookup ();
2639
paul718e3742002-12-13 20:15:29 +00002640 /* Show All Interfaces. */
2641 if (argc == 0)
2642 for (node = listhead (iflist); node; nextnode (node))
paul68980082003-03-25 05:07:42 +00002643 show_ip_ospf_interface_sub (vty, ospf, node->data);
paul718e3742002-12-13 20:15:29 +00002644 /* Interface name is specified. */
2645 else
2646 {
2647 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2648 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2649 else
paul68980082003-03-25 05:07:42 +00002650 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002651 }
2652
2653 return CMD_SUCCESS;
2654}
2655
2656void
2657show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2658{
2659 struct route_node *rn;
2660 struct ospf_neighbor *nbr;
2661 char msgbuf[16];
2662 char timebuf[9];
2663
2664 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2665 if ((nbr = rn->info))
2666 /* Do not show myself. */
2667 if (nbr != oi->nbr_self)
2668 /* Down state is not shown. */
2669 if (nbr->state != NSM_Down)
2670 {
2671 ospf_nbr_state_message (nbr, msgbuf, 16);
2672
2673 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2674 vty_out (vty, "%-15s %3d %-15s %8s ",
2675 "-", nbr->priority,
2676 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2677 else
2678 vty_out (vty, "%-15s %3d %-15s %8s ",
2679 inet_ntoa (nbr->router_id), nbr->priority,
2680 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2681 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2682 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2683 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2684 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2685 VTY_NEWLINE);
2686 }
2687}
2688
2689DEFUN (show_ip_ospf_neighbor,
2690 show_ip_ospf_neighbor_cmd,
2691 "show ip ospf neighbor",
2692 SHOW_STR
2693 IP_STR
2694 "OSPF information\n"
2695 "Neighbor list\n")
2696{
paul020709f2003-04-04 02:44:16 +00002697 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002698 listnode node;
2699
paul020709f2003-04-04 02:44:16 +00002700 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002701 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002702 {
2703 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2704 return CMD_SUCCESS;
2705 }
2706
2707 /* Show All neighbors. */
2708 vty_out (vty, "%sNeighbor ID Pri State Dead "
2709 "Time Address Interface RXmtL "
2710 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2711
paul68980082003-03-25 05:07:42 +00002712 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul020709f2003-04-04 02:44:16 +00002713 show_ip_ospf_neighbor_sub (vty, getdata (node));
paul718e3742002-12-13 20:15:29 +00002714
2715 return CMD_SUCCESS;
2716}
2717
2718DEFUN (show_ip_ospf_neighbor_all,
2719 show_ip_ospf_neighbor_all_cmd,
2720 "show ip ospf neighbor all",
2721 SHOW_STR
2722 IP_STR
2723 "OSPF information\n"
2724 "Neighbor list\n"
2725 "include down status neighbor\n")
2726{
paul68980082003-03-25 05:07:42 +00002727 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002728 listnode node;
2729
paul68980082003-03-25 05:07:42 +00002730 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002731 {
2732 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2733 return CMD_SUCCESS;
2734 }
2735
2736 /* Show All neighbors. */
2737 vty_out (vty, "%sNeighbor ID Pri State Dead "
2738 "Time Address Interface RXmtL "
2739 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2740
paul68980082003-03-25 05:07:42 +00002741 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002742 {
2743 struct ospf_interface *oi = getdata (node);
2744 listnode nbr_node;
2745
2746 show_ip_ospf_neighbor_sub (vty, oi);
2747
2748 /* print Down neighbor status */
2749 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
2750 {
2751 struct ospf_nbr_nbma *nbr_nbma;
2752
2753 nbr_nbma = getdata (nbr_node);
2754
2755 if (nbr_nbma->nbr == NULL
2756 || nbr_nbma->nbr->state == NSM_Down)
2757 {
2758 vty_out (vty, "%-15s %3d %-15s %8s ",
2759 "-", nbr_nbma->priority, "Down", "-");
2760 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2761 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2762 0, 0, 0, VTY_NEWLINE);
2763 }
2764 }
2765 }
2766
2767 return CMD_SUCCESS;
2768}
2769
2770DEFUN (show_ip_ospf_neighbor_int,
2771 show_ip_ospf_neighbor_int_cmd,
2772 "show ip ospf neighbor A.B.C.D",
2773 SHOW_STR
2774 IP_STR
2775 "OSPF information\n"
2776 "Neighbor list\n"
2777 "Interface name\n")
2778{
paul020709f2003-04-04 02:44:16 +00002779 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002780 struct ospf_interface *oi;
2781 struct in_addr addr;
2782 int ret;
2783
paul718e3742002-12-13 20:15:29 +00002784 ret = inet_aton (argv[0], &addr);
2785 if (!ret)
2786 {
2787 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2788 VTY_NEWLINE);
2789 return CMD_WARNING;
2790 }
2791
paul020709f2003-04-04 02:44:16 +00002792 ospf = ospf_lookup ();
2793 if (ospf == NULL)
2794 {
2795 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2796 return CMD_SUCCESS;
2797 }
2798
paul68980082003-03-25 05:07:42 +00002799 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00002800 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2801 else
2802 {
2803 vty_out (vty, "%sNeighbor ID Pri State Dead "
2804 "Time Address Interface RXmtL "
2805 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2806 show_ip_ospf_neighbor_sub (vty, oi);
2807 }
2808
2809 return CMD_SUCCESS;
2810}
2811
2812void
2813show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2814 struct ospf_nbr_nbma *nbr_nbma)
2815{
2816 char timebuf[9];
2817
2818 /* Show neighbor ID. */
2819 vty_out (vty, " Neighbor %s,", "-");
2820
2821 /* Show interface address. */
2822 vty_out (vty, " interface address %s%s",
2823 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2824 /* Show Area ID. */
2825 vty_out (vty, " In the area %s via interface %s%s",
2826 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2827 /* Show neighbor priority and state. */
2828 vty_out (vty, " Neighbor priority is %d, State is %s,",
2829 nbr_nbma->priority, "Down");
2830 /* Show state changes. */
2831 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2832
2833 /* Show PollInterval */
2834 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2835
2836 /* Show poll-interval timer. */
2837 vty_out (vty, " Poll timer due in %s%s",
2838 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2839
2840 /* Show poll-interval timer thread. */
2841 vty_out (vty, " Thread Poll Timer %s%s",
2842 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2843}
2844
2845void
2846show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2847 struct ospf_neighbor *nbr)
2848{
2849 char timebuf[9];
2850
2851 /* Show neighbor ID. */
2852 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2853 vty_out (vty, " Neighbor %s,", "-");
2854 else
2855 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2856
2857 /* Show interface address. */
2858 vty_out (vty, " interface address %s%s",
2859 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2860 /* Show Area ID. */
2861 vty_out (vty, " In the area %s via interface %s%s",
2862 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2863 /* Show neighbor priority and state. */
2864 vty_out (vty, " Neighbor priority is %d, State is %s,",
2865 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2866 /* Show state changes. */
2867 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2868
2869 /* Show Designated Rotuer ID. */
2870 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2871 /* Show Backup Designated Rotuer ID. */
2872 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2873 /* Show options. */
2874 vty_out (vty, " Options %d %s%s", nbr->options,
2875 ospf_options_dump (nbr->options), VTY_NEWLINE);
2876 /* Show Router Dead interval timer. */
2877 vty_out (vty, " Dead timer due in %s%s",
2878 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2879 /* Show Database Summary list. */
2880 vty_out (vty, " Database Summary List %d%s",
2881 ospf_db_summary_count (nbr), VTY_NEWLINE);
2882 /* Show Link State Request list. */
2883 vty_out (vty, " Link State Request List %ld%s",
2884 ospf_ls_request_count (nbr), VTY_NEWLINE);
2885 /* Show Link State Retransmission list. */
2886 vty_out (vty, " Link State Retransmission List %ld%s",
2887 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2888 /* Show inactivity timer thread. */
2889 vty_out (vty, " Thread Inactivity Timer %s%s",
2890 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2891 /* Show Database Description retransmission thread. */
2892 vty_out (vty, " Thread Database Description Retransmision %s%s",
2893 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2894 /* Show Link State Request Retransmission thread. */
2895 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2896 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2897 /* Show Link State Update Retransmission thread. */
2898 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2899 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2900}
2901
2902DEFUN (show_ip_ospf_neighbor_id,
2903 show_ip_ospf_neighbor_id_cmd,
2904 "show ip ospf neighbor A.B.C.D",
2905 SHOW_STR
2906 IP_STR
2907 "OSPF information\n"
2908 "Neighbor list\n"
2909 "Neighbor ID\n")
2910{
paul020709f2003-04-04 02:44:16 +00002911 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002912 listnode node;
2913 struct ospf_neighbor *nbr;
2914 struct in_addr router_id;
2915 int ret;
2916
2917 ret = inet_aton (argv[0], &router_id);
2918 if (!ret)
2919 {
2920 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
2921 return CMD_WARNING;
2922 }
2923
paul020709f2003-04-04 02:44:16 +00002924 ospf = ospf_lookup ();
2925 if (ospf == NULL)
2926 {
2927 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2928 return CMD_SUCCESS;
2929 }
2930
paul68980082003-03-25 05:07:42 +00002931 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002932 {
2933 struct ospf_interface *oi = getdata (node);
2934
2935 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
2936 {
2937 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2938 return CMD_SUCCESS;
2939 }
2940 }
2941
2942 /* Nothing to show. */
2943 return CMD_SUCCESS;
2944}
2945
2946DEFUN (show_ip_ospf_neighbor_detail,
2947 show_ip_ospf_neighbor_detail_cmd,
2948 "show ip ospf neighbor detail",
2949 SHOW_STR
2950 IP_STR
2951 "OSPF information\n"
2952 "Neighbor list\n"
2953 "detail of all neighbors\n")
2954{
paul020709f2003-04-04 02:44:16 +00002955 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002956 listnode node;
2957
paul020709f2003-04-04 02:44:16 +00002958 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002959 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00002960 {
2961 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2962 return CMD_SUCCESS;
2963 }
paul718e3742002-12-13 20:15:29 +00002964
paul68980082003-03-25 05:07:42 +00002965 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002966 {
2967 struct ospf_interface *oi = getdata (node);
2968 struct route_node *rn;
2969 struct ospf_neighbor *nbr;
2970
2971 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2972 if ((nbr = rn->info))
2973 if (nbr != oi->nbr_self)
2974 if (nbr->state != NSM_Down)
2975 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2976 }
2977
2978 return CMD_SUCCESS;
2979}
2980
2981DEFUN (show_ip_ospf_neighbor_detail_all,
2982 show_ip_ospf_neighbor_detail_all_cmd,
2983 "show ip ospf neighbor detail all",
2984 SHOW_STR
2985 IP_STR
2986 "OSPF information\n"
2987 "Neighbor list\n"
2988 "detail of all neighbors\n"
2989 "include down status neighbor\n")
2990{
paul020709f2003-04-04 02:44:16 +00002991 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002992 listnode node;
2993
paul020709f2003-04-04 02:44:16 +00002994 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002995 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00002996 {
2997 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2998 return CMD_SUCCESS;
2999 }
paul718e3742002-12-13 20:15:29 +00003000
paul68980082003-03-25 05:07:42 +00003001 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003002 {
3003 struct ospf_interface *oi = getdata (node);
3004 struct route_node *rn;
3005 struct ospf_neighbor *nbr;
3006
3007 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3008 if ((nbr = rn->info))
3009 if (nbr != oi->nbr_self)
3010 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3011 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3012
3013 if (oi->type == OSPF_IFTYPE_NBMA)
3014 {
3015 listnode nd;
3016
3017 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
3018 {
3019 struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
3020 if (nbr_nbma->nbr == NULL
3021 || nbr_nbma->nbr->state == NSM_Down)
3022 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3023 }
3024 }
3025 }
3026
3027 return CMD_SUCCESS;
3028}
3029
3030DEFUN (show_ip_ospf_neighbor_int_detail,
3031 show_ip_ospf_neighbor_int_detail_cmd,
3032 "show ip ospf neighbor A.B.C.D detail",
3033 SHOW_STR
3034 IP_STR
3035 "OSPF information\n"
3036 "Neighbor list\n"
3037 "Interface address\n"
3038 "detail of all neighbors")
3039{
paul020709f2003-04-04 02:44:16 +00003040 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003041 struct ospf_interface *oi;
3042 struct in_addr addr;
3043 int ret;
3044
3045 ret = inet_aton (argv[0], &addr);
3046 if (!ret)
3047 {
3048 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3049 VTY_NEWLINE);
3050 return CMD_WARNING;
3051 }
3052
paul020709f2003-04-04 02:44:16 +00003053 ospf = ospf_lookup ();
3054 if (ospf == NULL)
3055 {
3056 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3057 return CMD_SUCCESS;
3058 }
paul68980082003-03-25 05:07:42 +00003059
paul020709f2003-04-04 02:44:16 +00003060 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00003061 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3062 else
3063 {
3064 struct route_node *rn;
3065 struct ospf_neighbor *nbr;
3066
3067 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3068 if ((nbr = rn->info))
3069 if (nbr != oi->nbr_self)
3070 if (nbr->state != NSM_Down)
3071 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3072 }
3073
3074 return CMD_SUCCESS;
3075}
3076
3077
3078/* Show functions */
3079int
paul020709f2003-04-04 02:44:16 +00003080show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003081{
paul718e3742002-12-13 20:15:29 +00003082 struct router_lsa *rl;
3083 struct summary_lsa *sl;
3084 struct as_external_lsa *asel;
3085 struct prefix_ipv4 p;
3086
3087 if (lsa != NULL)
3088 /* If self option is set, check LSA self flag. */
3089 if (self == 0 || IS_LSA_SELF (lsa))
3090 {
3091 /* LSA common part show. */
3092 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3093 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3094 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3095 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3096 /* LSA specific part show. */
3097 switch (lsa->data->type)
3098 {
3099 case OSPF_ROUTER_LSA:
3100 rl = (struct router_lsa *) lsa->data;
3101 vty_out (vty, " %-d", ntohs (rl->links));
3102 break;
3103 case OSPF_SUMMARY_LSA:
3104 sl = (struct summary_lsa *) lsa->data;
3105
3106 p.family = AF_INET;
3107 p.prefix = sl->header.id;
3108 p.prefixlen = ip_masklen (sl->mask);
3109 apply_mask_ipv4 (&p);
3110
3111 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3112 break;
3113 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003114#ifdef HAVE_NSSA
3115 case OSPF_AS_NSSA_LSA:
3116#endif /* HAVE_NSSA */
paul718e3742002-12-13 20:15:29 +00003117 asel = (struct as_external_lsa *) lsa->data;
3118
3119 p.family = AF_INET;
3120 p.prefix = asel->header.id;
3121 p.prefixlen = ip_masklen (asel->mask);
3122 apply_mask_ipv4 (&p);
3123
3124 vty_out (vty, " %s %s/%d [0x%lx]",
3125 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3126 inet_ntoa (p.prefix), p.prefixlen,
3127 (u_long)ntohl (asel->e[0].route_tag));
3128 break;
3129 case OSPF_NETWORK_LSA:
3130 case OSPF_ASBR_SUMMARY_LSA:
3131#ifdef HAVE_OPAQUE_LSA
3132 case OSPF_OPAQUE_LINK_LSA:
3133 case OSPF_OPAQUE_AREA_LSA:
3134 case OSPF_OPAQUE_AS_LSA:
3135#endif /* HAVE_OPAQUE_LSA */
3136 default:
3137 break;
3138 }
3139 vty_out (vty, VTY_NEWLINE);
3140 }
3141
3142 return 0;
3143}
3144
3145char *show_database_desc[] =
3146{
3147 "unknown",
3148 "Router Link States",
3149 "Net Link States",
3150 "Summary Link States",
3151 "ASBR-Summary Link States",
3152 "AS External Link States",
3153#if defined (HAVE_NSSA) || defined (HAVE_OPAQUE_LSA)
3154 "Group Membership LSA",
3155 "NSSA-external Link States",
3156#endif /* HAVE_NSSA */
3157#ifdef HAVE_OPAQUE_LSA
3158 "Type-8 LSA",
3159 "Link-Local Opaque-LSA",
3160 "Area-Local Opaque-LSA",
3161 "AS-external Opaque-LSA",
3162#endif /* HAVE_OPAQUE_LSA */
3163};
3164
3165#define SHOW_OSPF_COMMON_HEADER \
3166 "Link ID ADV Router Age Seq# CkSum"
3167
3168char *show_database_header[] =
3169{
3170 "",
3171 "Link ID ADV Router Age Seq# CkSum Link count",
3172 "Link ID ADV Router Age Seq# CkSum",
3173 "Link ID ADV Router Age Seq# CkSum Route",
3174 "Link ID ADV Router Age Seq# CkSum",
3175 "Link ID ADV Router Age Seq# CkSum Route",
3176#ifdef HAVE_NSSA
3177 " --- header for Group Member ----",
3178 "Link ID ADV Router Age Seq# CkSum Route",
3179#endif /* HAVE_NSSA */
3180#ifdef HAVE_OPAQUE_LSA
3181#ifndef HAVE_NSSA
3182 " --- type-6 ---",
3183 " --- type-7 ---",
3184#endif /* HAVE_NSSA */
3185 " --- type-8 ---",
3186 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3187 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3188 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3189#endif /* HAVE_OPAQUE_LSA */
3190};
3191
paul4957f492003-06-27 01:28:45 +00003192char *show_lsa_flags[] =
3193{
3194 "Self-originated",
3195 "Checked",
3196 "Received",
3197 "Approved",
3198 "Discard",
3199#ifdef HAVE_NSSA
3200 "Translated",
3201#endif
3202};
3203
paul718e3742002-12-13 20:15:29 +00003204void
3205show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3206{
3207 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003208
paul718e3742002-12-13 20:15:29 +00003209 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003210 vty_out (vty, " Options: 0x%-2x : %s%s",
3211 lsa->data->options,
3212 ospf_options_dump(lsa->data->options),
3213 VTY_NEWLINE);
3214 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003215 lsa->flags,
3216#ifdef HAVE_NSSA
paul4957f492003-06-27 01:28:45 +00003217 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
paul9d526032003-06-30 22:46:14 +00003218#else
3219 "",
3220#endif /* HAVE_NSSA */
paul4957f492003-06-27 01:28:45 +00003221 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003222
3223 if (lsa->data->type == OSPF_ROUTER_LSA)
3224 {
3225 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3226
3227 if (rlsa->flags)
3228 vty_out (vty, " :%s%s%s%s",
3229 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3230 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3231 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3232 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3233
3234 vty_out (vty, "%s", VTY_NEWLINE);
3235 }
3236 vty_out (vty, " LS Type: %s%s",
3237 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3238 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3239 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3240 vty_out (vty, " Advertising Router: %s%s",
3241 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3242 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3243 VTY_NEWLINE);
3244 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3245 VTY_NEWLINE);
3246 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3247}
3248
3249char *link_type_desc[] =
3250{
3251 "(null)",
3252 "another Router (point-to-point)",
3253 "a Transit Network",
3254 "Stub Network",
3255 "a Virtual Link",
3256};
3257
3258char *link_id_desc[] =
3259{
3260 "(null)",
3261 "Neighboring Router ID",
3262 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003263 "Net",
paul718e3742002-12-13 20:15:29 +00003264 "Neighboring Router ID",
3265};
3266
3267char *link_data_desc[] =
3268{
3269 "(null)",
3270 "Router Interface address",
3271 "Router Interface address",
3272 "Network Mask",
3273 "Router Interface address",
3274};
3275
3276/* Show router-LSA each Link information. */
3277void
3278show_ip_ospf_database_router_links (struct vty *vty,
3279 struct router_lsa *rl)
3280{
3281 int len, i, type;
3282
3283 len = ntohs (rl->header.length) - 4;
3284 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3285 {
3286 type = rl->link[i].type;
3287
3288 vty_out (vty, " Link connected to: %s%s",
3289 link_type_desc[type], VTY_NEWLINE);
3290 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3291 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3292 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3293 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3294 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3295 vty_out (vty, " TOS 0 Metric: %d%s",
3296 ntohs (rl->link[i].metric), VTY_NEWLINE);
3297 vty_out (vty, "%s", VTY_NEWLINE);
3298 }
3299}
3300
3301/* Show router-LSA detail information. */
3302int
3303show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3304{
3305 if (lsa != NULL)
3306 {
3307 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3308
3309 show_ip_ospf_database_header (vty, lsa);
3310
3311 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3312 VTY_NEWLINE, VTY_NEWLINE);
3313
3314 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003315 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003316 }
3317
3318 return 0;
3319}
3320
3321/* Show network-LSA detail information. */
3322int
3323show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3324{
3325 int length, i;
3326
3327 if (lsa != NULL)
3328 {
3329 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3330
3331 show_ip_ospf_database_header (vty, lsa);
3332
3333 vty_out (vty, " Network Mask: /%d%s",
3334 ip_masklen (nl->mask), VTY_NEWLINE);
3335
3336 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3337
3338 for (i = 0; length > 0; i++, length -= 4)
3339 vty_out (vty, " Attached Router: %s%s",
3340 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3341
3342 vty_out (vty, "%s", VTY_NEWLINE);
3343 }
3344
3345 return 0;
3346}
3347
3348/* Show summary-LSA detail information. */
3349int
3350show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3351{
3352 if (lsa != NULL)
3353 {
3354 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3355
3356 show_ip_ospf_database_header (vty, lsa);
3357
3358 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3359 VTY_NEWLINE);
3360 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3361 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003362 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003363 }
3364
3365 return 0;
3366}
3367
3368/* Show summary-ASBR-LSA detail information. */
3369int
3370show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3371{
3372 if (lsa != NULL)
3373 {
3374 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3375
3376 show_ip_ospf_database_header (vty, lsa);
3377
3378 vty_out (vty, " Network Mask: /%d%s",
3379 ip_masklen (sl->mask), VTY_NEWLINE);
3380 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3381 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003382 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003383 }
3384
3385 return 0;
3386}
3387
3388/* Show AS-external-LSA detail information. */
3389int
3390show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3391{
3392 if (lsa != NULL)
3393 {
3394 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3395
3396 show_ip_ospf_database_header (vty, lsa);
3397
3398 vty_out (vty, " Network Mask: /%d%s",
3399 ip_masklen (al->mask), VTY_NEWLINE);
3400 vty_out (vty, " Metric Type: %s%s",
3401 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3402 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3403 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3404 vty_out (vty, " Metric: %d%s",
3405 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3406 vty_out (vty, " Forward Address: %s%s",
3407 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3408
3409 vty_out (vty, " External Route Tag: %lu%s%s",
3410 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3411 }
3412
3413 return 0;
3414}
3415
3416#ifdef HAVE_NSSA
3417int
3418show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3419{
3420 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3421
3422 /* show_ip_ospf_database_header (vty, lsa); */
3423
3424 zlog_info( " Network Mask: /%d%s",
3425 ip_masklen (al->mask), "\n");
3426 zlog_info( " Metric Type: %s%s",
3427 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3428 "2 (Larger than any link state path)" : "1", "\n");
3429 zlog_info( " TOS: 0%s", "\n");
3430 zlog_info( " Metric: %d%s",
3431 GET_METRIC (al->e[0].metric), "\n");
3432 zlog_info( " Forward Address: %s%s",
3433 inet_ntoa (al->e[0].fwd_addr), "\n");
3434
3435 zlog_info( " External Route Tag: %u%s%s",
3436 ntohl (al->e[0].route_tag), "\n", "\n");
3437
3438 return 0;
3439}
3440
3441/* Show AS-NSSA-LSA detail information. */
3442int
3443show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3444{
3445 if (lsa != NULL)
3446 {
3447 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3448
3449 show_ip_ospf_database_header (vty, lsa);
3450
3451 vty_out (vty, " Network Mask: /%d%s",
3452 ip_masklen (al->mask), VTY_NEWLINE);
3453 vty_out (vty, " Metric Type: %s%s",
3454 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3455 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3456 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3457 vty_out (vty, " Metric: %d%s",
3458 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3459 vty_out (vty, " NSSA: Forward Address: %s%s",
3460 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3461
3462 vty_out (vty, " External Route Tag: %u%s%s",
3463 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3464 }
3465
3466 return 0;
3467}
3468
3469#endif /* HAVE_NSSA */
3470
3471int
3472show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3473{
3474 return 0;
3475}
3476
3477#ifdef HAVE_OPAQUE_LSA
3478int
3479show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3480{
3481 if (lsa != NULL)
3482 {
3483 show_ip_ospf_database_header (vty, lsa);
3484 show_opaque_info_detail (vty, lsa);
3485
3486 vty_out (vty, "%s", VTY_NEWLINE);
3487 }
3488 return 0;
3489}
3490#endif /* HAVE_OPAQUE_LSA */
3491
3492int (*show_function[])(struct vty *, struct ospf_lsa *) =
3493{
3494 NULL,
3495 show_router_lsa_detail,
3496 show_network_lsa_detail,
3497 show_summary_lsa_detail,
3498 show_summary_asbr_lsa_detail,
3499 show_as_external_lsa_detail,
3500#ifdef HAVE_NSSA
3501 show_func_dummy,
3502 show_as_nssa_lsa_detail, /* almost same as external */
3503#endif /* HAVE_NSSA */
3504#ifdef HAVE_OPAQUE_LSA
3505#ifndef HAVE_NSSA
3506 show_func_dummy,
3507 show_func_dummy,
3508#endif /* HAVE_NSSA */
3509 NULL, /* type-8 */
3510 show_opaque_lsa_detail,
3511 show_opaque_lsa_detail,
3512 show_opaque_lsa_detail,
3513#endif /* HAVE_OPAQUE_LSA */
3514};
3515
3516void
3517show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3518 struct in_addr *adv_router)
3519{
3520 memset (lp, 0, sizeof (struct prefix_ls));
3521 lp->family = 0;
3522 if (id == NULL)
3523 lp->prefixlen = 0;
3524 else if (adv_router == NULL)
3525 {
3526 lp->prefixlen = 32;
3527 lp->id = *id;
3528 }
3529 else
3530 {
3531 lp->prefixlen = 64;
3532 lp->id = *id;
3533 lp->adv_router = *adv_router;
3534 }
3535}
3536
3537void
3538show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3539 struct in_addr *id, struct in_addr *adv_router)
3540{
3541 struct prefix_ls lp;
3542 struct route_node *rn, *start;
3543 struct ospf_lsa *lsa;
3544
3545 show_lsa_prefix_set (vty, &lp, id, adv_router);
3546 start = route_node_get (rt, (struct prefix *) &lp);
3547 if (start)
3548 {
3549 route_lock_node (start);
3550 for (rn = start; rn; rn = route_next_until (rn, start))
3551 if ((lsa = rn->info))
3552 {
paul718e3742002-12-13 20:15:29 +00003553 if (show_function[lsa->data->type] != NULL)
3554 show_function[lsa->data->type] (vty, lsa);
3555 }
3556 route_unlock_node (start);
3557 }
3558}
3559
3560/* Show detail LSA information
3561 -- if id is NULL then show all LSAs. */
3562void
paul020709f2003-04-04 02:44:16 +00003563show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003564 struct in_addr *id, struct in_addr *adv_router)
3565{
3566 listnode node;
3567
3568 switch (type)
3569 {
3570 case OSPF_AS_EXTERNAL_LSA:
3571#ifdef HAVE_OPAQUE_LSA
3572 case OSPF_OPAQUE_AS_LSA:
3573#endif /* HAVE_OPAQUE_LSA */
3574 vty_out (vty, " %s %s%s",
3575 show_database_desc[type],
3576 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003577 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003578 break;
3579 default:
paul68980082003-03-25 05:07:42 +00003580 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003581 {
3582 struct ospf_area *area = node->data;
3583 vty_out (vty, "%s %s (Area %s)%s%s",
3584 VTY_NEWLINE, show_database_desc[type],
3585 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3586 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3587 }
3588 break;
3589 }
3590}
3591
3592void
3593show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3594 struct in_addr *adv_router)
3595{
3596 struct route_node *rn;
3597 struct ospf_lsa *lsa;
3598
3599 for (rn = route_top (rt); rn; rn = route_next (rn))
3600 if ((lsa = rn->info))
3601 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3602 {
3603#ifdef HAVE_NSSA
3604 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3605 continue;
3606#endif /* HAVE_NSSA */
3607 if (show_function[lsa->data->type] != NULL)
3608 show_function[lsa->data->type] (vty, lsa);
3609 }
3610}
3611
3612/* Show detail LSA information. */
3613void
paul020709f2003-04-04 02:44:16 +00003614show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003615 struct in_addr *adv_router)
3616{
3617 listnode node;
3618
3619 switch (type)
3620 {
3621 case OSPF_AS_EXTERNAL_LSA:
3622#ifdef HAVE_OPAQUE_LSA
3623 case OSPF_OPAQUE_AS_LSA:
3624#endif /* HAVE_OPAQUE_LSA */
3625 vty_out (vty, " %s %s%s",
3626 show_database_desc[type],
3627 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003628 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003629 adv_router);
3630 break;
3631 default:
paul68980082003-03-25 05:07:42 +00003632 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003633 {
3634 struct ospf_area *area = node->data;
3635 vty_out (vty, "%s %s (Area %s)%s%s",
3636 VTY_NEWLINE, show_database_desc[type],
3637 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3638 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3639 adv_router);
3640 }
3641 break;
3642 }
3643}
3644
3645void
paul020709f2003-04-04 02:44:16 +00003646show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003647{
paul020709f2003-04-04 02:44:16 +00003648 struct ospf_lsa *lsa;
3649 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00003650 listnode node;
3651 int type;
3652
paul68980082003-03-25 05:07:42 +00003653 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003654 {
3655 struct ospf_area *area = node->data;
3656 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3657 {
3658 switch (type)
3659 {
3660 case OSPF_AS_EXTERNAL_LSA:
3661#ifdef HAVE_OPAQUE_LSA
3662 case OSPF_OPAQUE_AS_LSA:
3663#endif /* HAVE_OPAQUE_LSA */
3664 continue;
3665 default:
3666 break;
3667 }
3668 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3669 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3670 {
3671 vty_out (vty, " %s (Area %s)%s%s",
3672 show_database_desc[type],
3673 ospf_area_desc_string (area),
3674 VTY_NEWLINE, VTY_NEWLINE);
3675 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3676
paul020709f2003-04-04 02:44:16 +00003677 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3678 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003679
3680 vty_out (vty, "%s", VTY_NEWLINE);
3681 }
3682 }
3683 }
3684
3685 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3686 {
3687 switch (type)
3688 {
3689 case OSPF_AS_EXTERNAL_LSA:
3690#ifdef HAVE_OPAQUE_LSA
3691 case OSPF_OPAQUE_AS_LSA:
3692#endif /* HAVE_OPAQUE_LSA */
3693 break;;
3694 default:
3695 continue;
3696 }
paul68980082003-03-25 05:07:42 +00003697 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3698 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003699 {
3700 vty_out (vty, " %s%s%s",
3701 show_database_desc[type],
3702 VTY_NEWLINE, VTY_NEWLINE);
3703 vty_out (vty, "%s%s", show_database_header[type],
3704 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003705
3706 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3707 show_lsa_summary (vty, lsa, self);
3708
paul718e3742002-12-13 20:15:29 +00003709 vty_out (vty, "%s", VTY_NEWLINE);
3710 }
3711 }
3712
3713 vty_out (vty, "%s", VTY_NEWLINE);
3714}
3715
3716void
paul020709f2003-04-04 02:44:16 +00003717show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003718{
3719 listnode node;
3720 struct ospf_lsa *lsa;
3721
3722 vty_out (vty, "%s MaxAge Link States:%s%s",
3723 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3724
paul68980082003-03-25 05:07:42 +00003725 for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003726 if ((lsa = node->data) != NULL)
3727 {
3728 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3729 vty_out (vty, "Link State ID: %s%s",
3730 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3731 vty_out (vty, "Advertising Router: %s%s",
3732 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3733 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3734 vty_out (vty, "%s", VTY_NEWLINE);
3735 }
3736}
3737
3738#ifdef HAVE_NSSA
3739#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3740#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
3741#else /* HAVE_NSSA */
3742#define OSPF_LSA_TYPE_NSSA_DESC ""
3743#define OSPF_LSA_TYPE_NSSA_CMD_STR ""
3744#endif /* HAVE_NSSA */
3745
3746#ifdef HAVE_OPAQUE_LSA
3747#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3748#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3749#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3750#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3751#else /* HAVE_OPAQUE_LSA */
3752#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3753#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3754#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3755#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3756#endif /* HAVE_OPAQUE_LSA */
3757
3758#define OSPF_LSA_TYPES_CMD_STR \
3759 "asbr-summary|external|network|router|summary" \
3760 OSPF_LSA_TYPE_NSSA_CMD_STR \
3761 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3762
3763#define OSPF_LSA_TYPES_DESC \
3764 "ASBR summary link states\n" \
3765 "External link states\n" \
3766 "Network link states\n" \
3767 "Router link states\n" \
3768 "Network summary link states\n" \
3769 OSPF_LSA_TYPE_NSSA_DESC \
3770 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3771 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3772 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3773
3774DEFUN (show_ip_ospf_database,
3775 show_ip_ospf_database_cmd,
3776 "show ip ospf database",
3777 SHOW_STR
3778 IP_STR
3779 "OSPF information\n"
3780 "Database summary\n")
3781{
paul020709f2003-04-04 02:44:16 +00003782 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003783 int type, ret;
3784 struct in_addr id, adv_router;
3785
paul020709f2003-04-04 02:44:16 +00003786 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003787 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003788 return CMD_SUCCESS;
3789
3790 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003791 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003792
3793 /* Show all LSA. */
3794 if (argc == 0)
3795 {
paul020709f2003-04-04 02:44:16 +00003796 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003797 return CMD_SUCCESS;
3798 }
3799
3800 /* Set database type to show. */
3801 if (strncmp (argv[0], "r", 1) == 0)
3802 type = OSPF_ROUTER_LSA;
3803 else if (strncmp (argv[0], "ne", 2) == 0)
3804 type = OSPF_NETWORK_LSA;
3805#ifdef HAVE_NSSA
3806 else if (strncmp (argv[0], "ns", 2) == 0)
3807 type = OSPF_AS_NSSA_LSA;
3808#endif /* HAVE_NSSA */
3809 else if (strncmp (argv[0], "su", 2) == 0)
3810 type = OSPF_SUMMARY_LSA;
3811 else if (strncmp (argv[0], "a", 1) == 0)
3812 type = OSPF_ASBR_SUMMARY_LSA;
3813 else if (strncmp (argv[0], "e", 1) == 0)
3814 type = OSPF_AS_EXTERNAL_LSA;
3815 else if (strncmp (argv[0], "se", 2) == 0)
3816 {
paul020709f2003-04-04 02:44:16 +00003817 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003818 return CMD_SUCCESS;
3819 }
3820 else if (strncmp (argv[0], "m", 1) == 0)
3821 {
paul020709f2003-04-04 02:44:16 +00003822 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003823 return CMD_SUCCESS;
3824 }
3825#ifdef HAVE_OPAQUE_LSA
3826 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3827 type = OSPF_OPAQUE_LINK_LSA;
3828 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3829 type = OSPF_OPAQUE_AREA_LSA;
3830 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3831 type = OSPF_OPAQUE_AS_LSA;
3832#endif /* HAVE_OPAQUE_LSA */
3833 else
3834 return CMD_WARNING;
3835
3836 /* `show ip ospf database LSA'. */
3837 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003838 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003839 else if (argc >= 2)
3840 {
3841 ret = inet_aton (argv[1], &id);
3842 if (!ret)
3843 return CMD_WARNING;
3844
3845 /* `show ip ospf database LSA ID'. */
3846 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003847 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003848 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3849 else if (argc == 3)
3850 {
3851 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003852 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003853 else
3854 {
3855 ret = inet_aton (argv[2], &adv_router);
3856 if (!ret)
3857 return CMD_WARNING;
3858 }
paul020709f2003-04-04 02:44:16 +00003859 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003860 }
3861 }
3862
3863 return CMD_SUCCESS;
3864}
3865
3866ALIAS (show_ip_ospf_database,
3867 show_ip_ospf_database_type_cmd,
3868 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3869 SHOW_STR
3870 IP_STR
3871 "OSPF information\n"
3872 "Database summary\n"
3873 OSPF_LSA_TYPES_DESC
3874 "LSAs in MaxAge list\n"
3875 "Self-originated link states\n")
3876
3877ALIAS (show_ip_ospf_database,
3878 show_ip_ospf_database_type_id_cmd,
3879 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3880 SHOW_STR
3881 IP_STR
3882 "OSPF information\n"
3883 "Database summary\n"
3884 OSPF_LSA_TYPES_DESC
3885 "Link State ID (as an IP address)\n")
3886
3887ALIAS (show_ip_ospf_database,
3888 show_ip_ospf_database_type_id_adv_router_cmd,
3889 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3890 SHOW_STR
3891 IP_STR
3892 "OSPF information\n"
3893 "Database summary\n"
3894 OSPF_LSA_TYPES_DESC
3895 "Link State ID (as an IP address)\n"
3896 "Advertising Router link states\n"
3897 "Advertising Router (as an IP address)\n")
3898
3899ALIAS (show_ip_ospf_database,
3900 show_ip_ospf_database_type_id_self_cmd,
3901 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3902 SHOW_STR
3903 IP_STR
3904 "OSPF information\n"
3905 "Database summary\n"
3906 OSPF_LSA_TYPES_DESC
3907 "Link State ID (as an IP address)\n"
3908 "Self-originated link states\n"
3909 "\n")
3910
3911DEFUN (show_ip_ospf_database_type_adv_router,
3912 show_ip_ospf_database_type_adv_router_cmd,
3913 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3914 SHOW_STR
3915 IP_STR
3916 "OSPF information\n"
3917 "Database summary\n"
3918 OSPF_LSA_TYPES_DESC
3919 "Advertising Router link states\n"
3920 "Advertising Router (as an IP address)\n")
3921{
paul020709f2003-04-04 02:44:16 +00003922 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003923 int type, ret;
3924 struct in_addr adv_router;
3925
paul020709f2003-04-04 02:44:16 +00003926 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003927 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003928 return CMD_SUCCESS;
3929
3930 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003931 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003932
3933 if (argc != 2)
3934 return CMD_WARNING;
3935
3936 /* Set database type to show. */
3937 if (strncmp (argv[0], "r", 1) == 0)
3938 type = OSPF_ROUTER_LSA;
3939 else if (strncmp (argv[0], "ne", 2) == 0)
3940 type = OSPF_NETWORK_LSA;
3941#ifdef HAVE_NSSA
3942 else if (strncmp (argv[0], "ns", 2) == 0)
3943 type = OSPF_AS_NSSA_LSA;
3944#endif /* HAVE_NSSA */
3945 else if (strncmp (argv[0], "s", 1) == 0)
3946 type = OSPF_SUMMARY_LSA;
3947 else if (strncmp (argv[0], "a", 1) == 0)
3948 type = OSPF_ASBR_SUMMARY_LSA;
3949 else if (strncmp (argv[0], "e", 1) == 0)
3950 type = OSPF_AS_EXTERNAL_LSA;
3951#ifdef HAVE_OPAQUE_LSA
3952 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3953 type = OSPF_OPAQUE_LINK_LSA;
3954 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3955 type = OSPF_OPAQUE_AREA_LSA;
3956 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3957 type = OSPF_OPAQUE_AS_LSA;
3958#endif /* HAVE_OPAQUE_LSA */
3959 else
3960 return CMD_WARNING;
3961
3962 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
3963 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003964 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003965 else
3966 {
3967 ret = inet_aton (argv[1], &adv_router);
3968 if (!ret)
3969 return CMD_WARNING;
3970 }
3971
paul020709f2003-04-04 02:44:16 +00003972 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00003973
3974 return CMD_SUCCESS;
3975}
3976
3977ALIAS (show_ip_ospf_database_type_adv_router,
3978 show_ip_ospf_database_type_self_cmd,
3979 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
3980 SHOW_STR
3981 IP_STR
3982 "OSPF information\n"
3983 "Database summary\n"
3984 OSPF_LSA_TYPES_DESC
3985 "Self-originated link states\n")
3986
3987
3988DEFUN (ip_ospf_authentication_args,
3989 ip_ospf_authentication_args_addr_cmd,
3990 "ip ospf authentication (null|message-digest) A.B.C.D",
3991 "IP Information\n"
3992 "OSPF interface commands\n"
3993 "Enable authentication on this interface\n"
3994 "Use null authentication\n"
3995 "Use message-digest authentication\n"
3996 "Address of interface")
3997{
3998 struct interface *ifp;
3999 struct in_addr addr;
4000 int ret;
4001 struct ospf_if_params *params;
4002
4003 ifp = vty->index;
4004 params = IF_DEF_PARAMS (ifp);
4005
4006 if (argc == 2)
4007 {
4008 ret = inet_aton(argv[1], &addr);
4009 if (!ret)
4010 {
4011 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4012 VTY_NEWLINE);
4013 return CMD_WARNING;
4014 }
4015
4016 params = ospf_get_if_params (ifp, addr);
4017 ospf_if_update_params (ifp, addr);
4018 }
4019
4020 /* Handle null authentication */
4021 if ( argv[0][0] == 'n' )
4022 {
4023 SET_IF_PARAM (params, auth_type);
4024 params->auth_type = OSPF_AUTH_NULL;
4025 return CMD_SUCCESS;
4026 }
4027
4028 /* Handle message-digest authentication */
4029 if ( argv[0][0] == 'm' )
4030 {
4031 SET_IF_PARAM (params, auth_type);
4032 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4033 return CMD_SUCCESS;
4034 }
4035
4036 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4037 return CMD_WARNING;
4038}
4039
4040ALIAS (ip_ospf_authentication_args,
4041 ip_ospf_authentication_args_cmd,
4042 "ip ospf authentication (null|message-digest)",
4043 "IP Information\n"
4044 "OSPF interface commands\n"
4045 "Enable authentication on this interface\n"
4046 "Use null authentication\n"
4047 "Use message-digest authentication\n")
4048
4049DEFUN (ip_ospf_authentication,
4050 ip_ospf_authentication_addr_cmd,
4051 "ip ospf authentication A.B.C.D",
4052 "IP Information\n"
4053 "OSPF interface commands\n"
4054 "Enable authentication on this interface\n"
4055 "Address of interface")
4056{
4057 struct interface *ifp;
4058 struct in_addr addr;
4059 int ret;
4060 struct ospf_if_params *params;
4061
4062 ifp = vty->index;
4063 params = IF_DEF_PARAMS (ifp);
4064
4065 if (argc == 1)
4066 {
4067 ret = inet_aton(argv[1], &addr);
4068 if (!ret)
4069 {
4070 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4071 VTY_NEWLINE);
4072 return CMD_WARNING;
4073 }
4074
4075 params = ospf_get_if_params (ifp, addr);
4076 ospf_if_update_params (ifp, addr);
4077 }
4078
4079 SET_IF_PARAM (params, auth_type);
4080 params->auth_type = OSPF_AUTH_SIMPLE;
4081
4082 return CMD_SUCCESS;
4083}
4084
4085ALIAS (ip_ospf_authentication,
4086 ip_ospf_authentication_cmd,
4087 "ip ospf authentication",
4088 "IP Information\n"
4089 "OSPF interface commands\n"
4090 "Enable authentication on this interface\n")
4091
4092DEFUN (no_ip_ospf_authentication,
4093 no_ip_ospf_authentication_addr_cmd,
4094 "no ip ospf authentication A.B.C.D",
4095 NO_STR
4096 "IP Information\n"
4097 "OSPF interface commands\n"
4098 "Enable authentication on this interface\n"
4099 "Address of interface")
4100{
4101 struct interface *ifp;
4102 struct in_addr addr;
4103 int ret;
4104 struct ospf_if_params *params;
4105
4106 ifp = vty->index;
4107 params = IF_DEF_PARAMS (ifp);
4108
4109 if (argc == 1)
4110 {
4111 ret = inet_aton(argv[1], &addr);
4112 if (!ret)
4113 {
4114 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4115 VTY_NEWLINE);
4116 return CMD_WARNING;
4117 }
4118
4119 params = ospf_lookup_if_params (ifp, addr);
4120 if (params == NULL)
4121 return CMD_SUCCESS;
4122 }
4123
4124 params->auth_type = OSPF_AUTH_NOTSET;
4125 UNSET_IF_PARAM (params, auth_type);
4126
4127 if (params != IF_DEF_PARAMS (ifp))
4128 {
4129 ospf_free_if_params (ifp, addr);
4130 ospf_if_update_params (ifp, addr);
4131 }
4132
4133 return CMD_SUCCESS;
4134}
4135
4136ALIAS (no_ip_ospf_authentication,
4137 no_ip_ospf_authentication_cmd,
4138 "no ip ospf authentication",
4139 NO_STR
4140 "IP Information\n"
4141 "OSPF interface commands\n"
4142 "Enable authentication on this interface\n")
4143
4144DEFUN (ip_ospf_authentication_key,
4145 ip_ospf_authentication_key_addr_cmd,
4146 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4147 "IP Information\n"
4148 "OSPF interface commands\n"
4149 "Authentication password (key)\n"
4150 "The OSPF password (key)\n"
4151 "Address of interface")
4152{
4153 struct interface *ifp;
4154 struct in_addr addr;
4155 int ret;
4156 struct ospf_if_params *params;
4157
4158 ifp = vty->index;
4159 params = IF_DEF_PARAMS (ifp);
4160
4161 if (argc == 2)
4162 {
4163 ret = inet_aton(argv[1], &addr);
4164 if (!ret)
4165 {
4166 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4167 VTY_NEWLINE);
4168 return CMD_WARNING;
4169 }
4170
4171 params = ospf_get_if_params (ifp, addr);
4172 ospf_if_update_params (ifp, addr);
4173 }
4174
4175
4176 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
4177 strncpy (params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
4178 SET_IF_PARAM (params, auth_simple);
4179
4180 return CMD_SUCCESS;
4181}
4182
4183ALIAS (ip_ospf_authentication_key,
4184 ip_ospf_authentication_key_cmd,
4185 "ip ospf authentication-key AUTH_KEY",
4186 "IP Information\n"
4187 "OSPF interface commands\n"
4188 "Authentication password (key)\n"
4189 "The OSPF password (key)")
4190
4191ALIAS (ip_ospf_authentication_key,
4192 ospf_authentication_key_cmd,
4193 "ospf authentication-key AUTH_KEY",
4194 "OSPF interface commands\n"
4195 "Authentication password (key)\n"
4196 "The OSPF password (key)")
4197
4198DEFUN (no_ip_ospf_authentication_key,
4199 no_ip_ospf_authentication_key_addr_cmd,
4200 "no ip ospf authentication-key A.B.C.D",
4201 NO_STR
4202 "IP Information\n"
4203 "OSPF interface commands\n"
4204 "Authentication password (key)\n"
4205 "Address of interface")
4206{
4207 struct interface *ifp;
4208 struct in_addr addr;
4209 int ret;
4210 struct ospf_if_params *params;
4211
4212 ifp = vty->index;
4213 params = IF_DEF_PARAMS (ifp);
4214
4215 if (argc == 2)
4216 {
4217 ret = inet_aton(argv[1], &addr);
4218 if (!ret)
4219 {
4220 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4221 VTY_NEWLINE);
4222 return CMD_WARNING;
4223 }
4224
4225 params = ospf_lookup_if_params (ifp, addr);
4226 if (params == NULL)
4227 return CMD_SUCCESS;
4228 }
4229
4230 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4231 UNSET_IF_PARAM (params, auth_simple);
4232
4233 if (params != IF_DEF_PARAMS (ifp))
4234 {
4235 ospf_free_if_params (ifp, addr);
4236 ospf_if_update_params (ifp, addr);
4237 }
4238
4239 return CMD_SUCCESS;
4240}
4241
4242ALIAS (no_ip_ospf_authentication_key,
4243 no_ip_ospf_authentication_key_cmd,
4244 "no ip ospf authentication-key",
4245 NO_STR
4246 "IP Information\n"
4247 "OSPF interface commands\n"
4248 "Authentication password (key)\n")
4249
4250ALIAS (no_ip_ospf_authentication_key,
4251 no_ospf_authentication_key_cmd,
4252 "no ospf authentication-key",
4253 NO_STR
4254 "OSPF interface commands\n"
4255 "Authentication password (key)\n")
4256
4257DEFUN (ip_ospf_message_digest_key,
4258 ip_ospf_message_digest_key_addr_cmd,
4259 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4260 "IP Information\n"
4261 "OSPF interface commands\n"
4262 "Message digest authentication password (key)\n"
4263 "Key ID\n"
4264 "Use MD5 algorithm\n"
4265 "The OSPF password (key)"
4266 "Address of interface")
4267{
4268 struct interface *ifp;
4269 struct crypt_key *ck;
4270 u_char key_id;
4271 struct in_addr addr;
4272 int ret;
4273 struct ospf_if_params *params;
4274
4275 ifp = vty->index;
4276 params = IF_DEF_PARAMS (ifp);
4277
4278 if (argc == 3)
4279 {
4280 ret = inet_aton(argv[2], &addr);
4281 if (!ret)
4282 {
4283 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4284 VTY_NEWLINE);
4285 return CMD_WARNING;
4286 }
4287
4288 params = ospf_get_if_params (ifp, addr);
4289 ospf_if_update_params (ifp, addr);
4290 }
4291
4292 key_id = strtol (argv[0], NULL, 10);
4293 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4294 {
4295 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4296 return CMD_WARNING;
4297 }
4298
4299 ck = ospf_crypt_key_new ();
4300 ck->key_id = (u_char) key_id;
4301 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
4302 strncpy (ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
4303
4304 ospf_crypt_key_add (params->auth_crypt, ck);
4305 SET_IF_PARAM (params, auth_crypt);
4306
4307 return CMD_SUCCESS;
4308}
4309
4310ALIAS (ip_ospf_message_digest_key,
4311 ip_ospf_message_digest_key_cmd,
4312 "ip ospf message-digest-key <1-255> md5 KEY",
4313 "IP Information\n"
4314 "OSPF interface commands\n"
4315 "Message digest authentication password (key)\n"
4316 "Key ID\n"
4317 "Use MD5 algorithm\n"
4318 "The OSPF password (key)")
4319
4320ALIAS (ip_ospf_message_digest_key,
4321 ospf_message_digest_key_cmd,
4322 "ospf message-digest-key <1-255> md5 KEY",
4323 "OSPF interface commands\n"
4324 "Message digest authentication password (key)\n"
4325 "Key ID\n"
4326 "Use MD5 algorithm\n"
4327 "The OSPF password (key)")
4328
4329DEFUN (no_ip_ospf_message_digest_key,
4330 no_ip_ospf_message_digest_key_addr_cmd,
4331 "no ip ospf message-digest-key <1-255> A.B.C.D",
4332 NO_STR
4333 "IP Information\n"
4334 "OSPF interface commands\n"
4335 "Message digest authentication password (key)\n"
4336 "Key ID\n"
4337 "Address of interface")
4338{
4339 struct interface *ifp;
4340 struct crypt_key *ck;
4341 int key_id;
4342 struct in_addr addr;
4343 int ret;
4344 struct ospf_if_params *params;
4345
4346 ifp = vty->index;
4347 params = IF_DEF_PARAMS (ifp);
4348
4349 if (argc == 2)
4350 {
4351 ret = inet_aton(argv[1], &addr);
4352 if (!ret)
4353 {
4354 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4355 VTY_NEWLINE);
4356 return CMD_WARNING;
4357 }
4358
4359 params = ospf_lookup_if_params (ifp, addr);
4360 if (params == NULL)
4361 return CMD_SUCCESS;
4362 }
4363
4364 key_id = strtol (argv[0], NULL, 10);
4365 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4366 if (ck == NULL)
4367 {
4368 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4369 return CMD_WARNING;
4370 }
4371
4372 ospf_crypt_key_delete (params->auth_crypt, key_id);
4373
4374 if (params != IF_DEF_PARAMS (ifp))
4375 {
4376 ospf_free_if_params (ifp, addr);
4377 ospf_if_update_params (ifp, addr);
4378 }
4379
4380 return CMD_SUCCESS;
4381}
4382
4383ALIAS (no_ip_ospf_message_digest_key,
4384 no_ip_ospf_message_digest_key_cmd,
4385 "no ip ospf message-digest-key <1-255>",
4386 NO_STR
4387 "IP Information\n"
4388 "OSPF interface commands\n"
4389 "Message digest authentication password (key)\n"
4390 "Key ID\n")
4391
4392ALIAS (no_ip_ospf_message_digest_key,
4393 no_ospf_message_digest_key_cmd,
4394 "no ospf message-digest-key <1-255>",
4395 NO_STR
4396 "OSPF interface commands\n"
4397 "Message digest authentication password (key)\n"
4398 "Key ID\n")
4399
4400DEFUN (ip_ospf_cost,
4401 ip_ospf_cost_addr_cmd,
4402 "ip ospf cost <1-65535> A.B.C.D",
4403 "IP Information\n"
4404 "OSPF interface commands\n"
4405 "Interface cost\n"
4406 "Cost\n"
4407 "Address of interface")
4408{
4409 struct interface *ifp = vty->index;
4410 u_int32_t cost;
4411 struct in_addr addr;
4412 int ret;
4413 struct ospf_if_params *params;
4414
4415 params = IF_DEF_PARAMS (ifp);
4416
4417 cost = strtol (argv[0], NULL, 10);
4418
4419 /* cost range is <1-65535>. */
4420 if (cost < 1 || cost > 65535)
4421 {
4422 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4423 return CMD_WARNING;
4424 }
4425
4426 if (argc == 2)
4427 {
4428 ret = inet_aton(argv[1], &addr);
4429 if (!ret)
4430 {
4431 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4432 VTY_NEWLINE);
4433 return CMD_WARNING;
4434 }
4435
4436 params = ospf_get_if_params (ifp, addr);
4437 ospf_if_update_params (ifp, addr);
4438 }
4439
4440 SET_IF_PARAM (params, output_cost_cmd);
4441 params->output_cost_cmd = cost;
4442
4443 ospf_if_recalculate_output_cost (ifp);
4444
4445 return CMD_SUCCESS;
4446}
4447
4448ALIAS (ip_ospf_cost,
4449 ip_ospf_cost_cmd,
4450 "ip ospf cost <1-65535>",
4451 "IP Information\n"
4452 "OSPF interface commands\n"
4453 "Interface cost\n"
4454 "Cost")
4455
4456ALIAS (ip_ospf_cost,
4457 ospf_cost_cmd,
4458 "ospf cost <1-65535>",
4459 "OSPF interface commands\n"
4460 "Interface cost\n"
4461 "Cost")
4462
4463DEFUN (no_ip_ospf_cost,
4464 no_ip_ospf_cost_addr_cmd,
4465 "no ip ospf cost A.B.C.D",
4466 NO_STR
4467 "IP Information\n"
4468 "OSPF interface commands\n"
4469 "Interface cost\n"
4470 "Address of interface")
4471{
4472 struct interface *ifp = vty->index;
4473 struct in_addr addr;
4474 int ret;
4475 struct ospf_if_params *params;
4476
4477 ifp = vty->index;
4478 params = IF_DEF_PARAMS (ifp);
4479
4480 if (argc == 1)
4481 {
4482 ret = inet_aton(argv[0], &addr);
4483 if (!ret)
4484 {
4485 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4486 VTY_NEWLINE);
4487 return CMD_WARNING;
4488 }
4489
4490 params = ospf_lookup_if_params (ifp, addr);
4491 if (params == NULL)
4492 return CMD_SUCCESS;
4493 }
4494
4495 UNSET_IF_PARAM (params, output_cost_cmd);
4496
4497 if (params != IF_DEF_PARAMS (ifp))
4498 {
4499 ospf_free_if_params (ifp, addr);
4500 ospf_if_update_params (ifp, addr);
4501 }
4502
4503 ospf_if_recalculate_output_cost (ifp);
4504
4505 return CMD_SUCCESS;
4506}
4507
4508ALIAS (no_ip_ospf_cost,
4509 no_ip_ospf_cost_cmd,
4510 "no ip ospf cost",
4511 NO_STR
4512 "IP Information\n"
4513 "OSPF interface commands\n"
4514 "Interface cost\n")
4515
4516ALIAS (no_ip_ospf_cost,
4517 no_ospf_cost_cmd,
4518 "no ospf cost",
4519 NO_STR
4520 "OSPF interface commands\n"
4521 "Interface cost\n")
4522
4523void
4524ospf_nbr_timer_update (struct ospf_interface *oi)
4525{
4526 struct route_node *rn;
4527 struct ospf_neighbor *nbr;
4528
4529 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4530 if ((nbr = rn->info))
4531 {
4532 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4533 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4534 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4535 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4536 }
4537}
4538
4539DEFUN (ip_ospf_dead_interval,
4540 ip_ospf_dead_interval_addr_cmd,
4541 "ip ospf dead-interval <1-65535> A.B.C.D",
4542 "IP Information\n"
4543 "OSPF interface commands\n"
4544 "Interval after which a neighbor is declared dead\n"
4545 "Seconds\n"
4546 "Address of interface")
4547{
4548 struct interface *ifp = vty->index;
4549 u_int32_t seconds;
4550 struct in_addr addr;
4551 int ret;
4552 struct ospf_if_params *params;
4553 struct ospf_interface *oi;
4554 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004555 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004556
paul020709f2003-04-04 02:44:16 +00004557 ospf = ospf_lookup ();
4558
paul718e3742002-12-13 20:15:29 +00004559 params = IF_DEF_PARAMS (ifp);
4560
4561 seconds = strtol (argv[0], NULL, 10);
4562
4563 /* dead_interval range is <1-65535>. */
4564 if (seconds < 1 || seconds > 65535)
4565 {
4566 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4567 return CMD_WARNING;
4568 }
4569
4570 if (argc == 2)
4571 {
4572 ret = inet_aton(argv[1], &addr);
4573 if (!ret)
4574 {
4575 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4576 VTY_NEWLINE);
4577 return CMD_WARNING;
4578 }
4579
4580 params = ospf_get_if_params (ifp, addr);
4581 ospf_if_update_params (ifp, addr);
4582 }
4583
4584 SET_IF_PARAM (params, v_wait);
4585 params->v_wait = seconds;
4586
4587 /* Update timer values in neighbor structure. */
4588 if (argc == 2)
4589 {
paul68980082003-03-25 05:07:42 +00004590 if (ospf)
4591 {
4592 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4593 if (oi)
4594 ospf_nbr_timer_update (oi);
4595 }
paul718e3742002-12-13 20:15:29 +00004596 }
4597 else
4598 {
4599 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4600 if ((oi = rn->info))
4601 ospf_nbr_timer_update (oi);
4602 }
4603
4604 return CMD_SUCCESS;
4605}
4606
4607ALIAS (ip_ospf_dead_interval,
4608 ip_ospf_dead_interval_cmd,
4609 "ip ospf dead-interval <1-65535>",
4610 "IP Information\n"
4611 "OSPF interface commands\n"
4612 "Interval after which a neighbor is declared dead\n"
4613 "Seconds\n")
4614
4615ALIAS (ip_ospf_dead_interval,
4616 ospf_dead_interval_cmd,
4617 "ospf dead-interval <1-65535>",
4618 "OSPF interface commands\n"
4619 "Interval after which a neighbor is declared dead\n"
4620 "Seconds\n")
4621
4622DEFUN (no_ip_ospf_dead_interval,
4623 no_ip_ospf_dead_interval_addr_cmd,
4624 "no ip ospf dead-interval A.B.C.D",
4625 NO_STR
4626 "IP Information\n"
4627 "OSPF interface commands\n"
4628 "Interval after which a neighbor is declared dead\n"
4629 "Address of interface")
4630{
4631 struct interface *ifp = vty->index;
4632 struct in_addr addr;
4633 int ret;
4634 struct ospf_if_params *params;
4635 struct ospf_interface *oi;
4636 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004637 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004638
paul020709f2003-04-04 02:44:16 +00004639 ospf = ospf_lookup ();
4640
paul718e3742002-12-13 20:15:29 +00004641 ifp = vty->index;
4642 params = IF_DEF_PARAMS (ifp);
4643
4644 if (argc == 1)
4645 {
4646 ret = inet_aton(argv[0], &addr);
4647 if (!ret)
4648 {
4649 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4650 VTY_NEWLINE);
4651 return CMD_WARNING;
4652 }
4653
4654 params = ospf_lookup_if_params (ifp, addr);
4655 if (params == NULL)
4656 return CMD_SUCCESS;
4657 }
4658
4659 UNSET_IF_PARAM (params, v_wait);
4660 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4661
4662 if (params != IF_DEF_PARAMS (ifp))
4663 {
4664 ospf_free_if_params (ifp, addr);
4665 ospf_if_update_params (ifp, addr);
4666 }
4667
4668 /* Update timer values in neighbor structure. */
4669 if (argc == 1)
4670 {
paul68980082003-03-25 05:07:42 +00004671 if (ospf)
4672 {
4673 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4674 if (oi)
4675 ospf_nbr_timer_update (oi);
4676 }
paul718e3742002-12-13 20:15:29 +00004677 }
4678 else
4679 {
4680 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4681 if ((oi = rn->info))
4682 ospf_nbr_timer_update (oi);
4683 }
4684
4685 return CMD_SUCCESS;
4686}
4687
4688ALIAS (no_ip_ospf_dead_interval,
4689 no_ip_ospf_dead_interval_cmd,
4690 "no ip ospf dead-interval",
4691 NO_STR
4692 "IP Information\n"
4693 "OSPF interface commands\n"
4694 "Interval after which a neighbor is declared dead\n")
4695
4696ALIAS (no_ip_ospf_dead_interval,
4697 no_ospf_dead_interval_cmd,
4698 "no ospf dead-interval",
4699 NO_STR
4700 "OSPF interface commands\n"
4701 "Interval after which a neighbor is declared dead\n")
4702
4703DEFUN (ip_ospf_hello_interval,
4704 ip_ospf_hello_interval_addr_cmd,
4705 "ip ospf hello-interval <1-65535> A.B.C.D",
4706 "IP Information\n"
4707 "OSPF interface commands\n"
4708 "Time between HELLO packets\n"
4709 "Seconds\n"
4710 "Address of interface")
4711{
4712 struct interface *ifp = vty->index;
4713 u_int32_t seconds;
4714 struct in_addr addr;
4715 int ret;
4716 struct ospf_if_params *params;
4717
4718 params = IF_DEF_PARAMS (ifp);
4719
4720 seconds = strtol (argv[0], NULL, 10);
4721
4722 /* HelloInterval range is <1-65535>. */
4723 if (seconds < 1 || seconds > 65535)
4724 {
4725 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4726 return CMD_WARNING;
4727 }
4728
4729 if (argc == 2)
4730 {
4731 ret = inet_aton(argv[1], &addr);
4732 if (!ret)
4733 {
4734 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4735 VTY_NEWLINE);
4736 return CMD_WARNING;
4737 }
4738
4739 params = ospf_get_if_params (ifp, addr);
4740 ospf_if_update_params (ifp, addr);
4741 }
4742
4743 SET_IF_PARAM (params, v_hello);
4744 params->v_hello = seconds;
4745
4746 return CMD_SUCCESS;
4747}
4748
4749ALIAS (ip_ospf_hello_interval,
4750 ip_ospf_hello_interval_cmd,
4751 "ip ospf hello-interval <1-65535>",
4752 "IP Information\n"
4753 "OSPF interface commands\n"
4754 "Time between HELLO packets\n"
4755 "Seconds\n")
4756
4757ALIAS (ip_ospf_hello_interval,
4758 ospf_hello_interval_cmd,
4759 "ospf hello-interval <1-65535>",
4760 "OSPF interface commands\n"
4761 "Time between HELLO packets\n"
4762 "Seconds\n")
4763
4764DEFUN (no_ip_ospf_hello_interval,
4765 no_ip_ospf_hello_interval_addr_cmd,
4766 "no ip ospf hello-interval A.B.C.D",
4767 NO_STR
4768 "IP Information\n"
4769 "OSPF interface commands\n"
4770 "Time between HELLO packets\n"
4771 "Address of interface")
4772{
4773 struct interface *ifp = vty->index;
4774 struct in_addr addr;
4775 int ret;
4776 struct ospf_if_params *params;
4777
4778 ifp = vty->index;
4779 params = IF_DEF_PARAMS (ifp);
4780
4781 if (argc == 1)
4782 {
4783 ret = inet_aton(argv[0], &addr);
4784 if (!ret)
4785 {
4786 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4787 VTY_NEWLINE);
4788 return CMD_WARNING;
4789 }
4790
4791 params = ospf_lookup_if_params (ifp, addr);
4792 if (params == NULL)
4793 return CMD_SUCCESS;
4794 }
4795
4796 UNSET_IF_PARAM (params, v_hello);
4797 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4798
4799 if (params != IF_DEF_PARAMS (ifp))
4800 {
4801 ospf_free_if_params (ifp, addr);
4802 ospf_if_update_params (ifp, addr);
4803 }
4804
4805 return CMD_SUCCESS;
4806}
4807
4808ALIAS (no_ip_ospf_hello_interval,
4809 no_ip_ospf_hello_interval_cmd,
4810 "no ip ospf hello-interval",
4811 NO_STR
4812 "IP Information\n"
4813 "OSPF interface commands\n"
4814 "Time between HELLO packets\n")
4815
4816ALIAS (no_ip_ospf_hello_interval,
4817 no_ospf_hello_interval_cmd,
4818 "no ospf hello-interval",
4819 NO_STR
4820 "OSPF interface commands\n"
4821 "Time between HELLO packets\n")
4822
4823DEFUN (ip_ospf_network,
4824 ip_ospf_network_cmd,
4825 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4826 "IP Information\n"
4827 "OSPF interface commands\n"
4828 "Network type\n"
4829 "Specify OSPF broadcast multi-access network\n"
4830 "Specify OSPF NBMA network\n"
4831 "Specify OSPF point-to-multipoint network\n"
4832 "Specify OSPF point-to-point network\n")
4833{
4834 struct interface *ifp = vty->index;
4835 int old_type = IF_DEF_PARAMS (ifp)->type;
4836 struct route_node *rn;
4837
4838 if (strncmp (argv[0], "b", 1) == 0)
4839 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4840 else if (strncmp (argv[0], "n", 1) == 0)
4841 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4842 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4843 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4844 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4845 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4846
4847 if (IF_DEF_PARAMS (ifp)->type == old_type)
4848 return CMD_SUCCESS;
4849
4850 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4851
4852 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4853 {
4854 struct ospf_interface *oi = rn->info;
4855
4856 if (!oi)
4857 continue;
4858
4859 oi->type = IF_DEF_PARAMS (ifp)->type;
4860
4861 if (oi->state > ISM_Down)
4862 {
4863 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4864 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4865 }
4866 }
4867
4868 return CMD_SUCCESS;
4869}
4870
4871ALIAS (ip_ospf_network,
4872 ospf_network_cmd,
4873 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4874 "OSPF interface commands\n"
4875 "Network type\n"
4876 "Specify OSPF broadcast multi-access network\n"
4877 "Specify OSPF NBMA network\n"
4878 "Specify OSPF point-to-multipoint network\n"
4879 "Specify OSPF point-to-point network\n")
4880
4881DEFUN (no_ip_ospf_network,
4882 no_ip_ospf_network_cmd,
4883 "no ip ospf network",
4884 NO_STR
4885 "IP Information\n"
4886 "OSPF interface commands\n"
4887 "Network type\n")
4888{
4889 struct interface *ifp = vty->index;
4890 int old_type = IF_DEF_PARAMS (ifp)->type;
4891 struct route_node *rn;
4892
4893 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4894
4895 if (IF_DEF_PARAMS (ifp)->type == old_type)
4896 return CMD_SUCCESS;
4897
4898 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4899 {
4900 struct ospf_interface *oi = rn->info;
4901
4902 if (!oi)
4903 continue;
4904
4905 oi->type = IF_DEF_PARAMS (ifp)->type;
4906
4907 if (oi->state > ISM_Down)
4908 {
4909 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4910 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4911 }
4912 }
4913
4914 return CMD_SUCCESS;
4915}
4916
4917ALIAS (no_ip_ospf_network,
4918 no_ospf_network_cmd,
4919 "no ospf network",
4920 NO_STR
4921 "OSPF interface commands\n"
4922 "Network type\n")
4923
4924DEFUN (ip_ospf_priority,
4925 ip_ospf_priority_addr_cmd,
4926 "ip ospf priority <0-255> A.B.C.D",
4927 "IP Information\n"
4928 "OSPF interface commands\n"
4929 "Router priority\n"
4930 "Priority\n"
4931 "Address of interface")
4932{
4933 struct interface *ifp = vty->index;
4934 u_int32_t priority;
4935 struct route_node *rn;
4936 struct in_addr addr;
4937 int ret;
4938 struct ospf_if_params *params;
4939
4940 params = IF_DEF_PARAMS (ifp);
4941
4942 priority = strtol (argv[0], NULL, 10);
4943
4944 /* Router Priority range is <0-255>. */
4945 if (priority < 0 || priority > 255)
4946 {
4947 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4948 return CMD_WARNING;
4949 }
4950
4951 if (argc == 2)
4952 {
4953 ret = inet_aton(argv[1], &addr);
4954 if (!ret)
4955 {
4956 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4957 VTY_NEWLINE);
4958 return CMD_WARNING;
4959 }
4960
4961 params = ospf_get_if_params (ifp, addr);
4962 ospf_if_update_params (ifp, addr);
4963 }
4964
4965 SET_IF_PARAM (params, priority);
4966 params->priority = priority;
4967
4968 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4969 {
4970 struct ospf_interface *oi = rn->info;
4971
4972 if (!oi)
4973 continue;
4974
4975
4976 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
4977 {
4978 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
4979 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
4980 }
4981 }
4982
4983 return CMD_SUCCESS;
4984}
4985
4986ALIAS (ip_ospf_priority,
4987 ip_ospf_priority_cmd,
4988 "ip ospf priority <0-255>",
4989 "IP Information\n"
4990 "OSPF interface commands\n"
4991 "Router priority\n"
4992 "Priority\n")
4993
4994ALIAS (ip_ospf_priority,
4995 ospf_priority_cmd,
4996 "ospf priority <0-255>",
4997 "OSPF interface commands\n"
4998 "Router priority\n"
4999 "Priority\n")
5000
5001DEFUN (no_ip_ospf_priority,
5002 no_ip_ospf_priority_addr_cmd,
5003 "no ip ospf priority A.B.C.D",
5004 NO_STR
5005 "IP Information\n"
5006 "OSPF interface commands\n"
5007 "Router priority\n"
5008 "Address of interface")
5009{
5010 struct interface *ifp = vty->index;
5011 struct route_node *rn;
5012 struct in_addr addr;
5013 int ret;
5014 struct ospf_if_params *params;
5015
5016 ifp = vty->index;
5017 params = IF_DEF_PARAMS (ifp);
5018
5019 if (argc == 1)
5020 {
5021 ret = inet_aton(argv[0], &addr);
5022 if (!ret)
5023 {
5024 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5025 VTY_NEWLINE);
5026 return CMD_WARNING;
5027 }
5028
5029 params = ospf_lookup_if_params (ifp, addr);
5030 if (params == NULL)
5031 return CMD_SUCCESS;
5032 }
5033
5034 UNSET_IF_PARAM (params, priority);
5035 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5036
5037 if (params != IF_DEF_PARAMS (ifp))
5038 {
5039 ospf_free_if_params (ifp, addr);
5040 ospf_if_update_params (ifp, addr);
5041 }
5042
5043 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5044 {
5045 struct ospf_interface *oi = rn->info;
5046
5047 if (!oi)
5048 continue;
5049
5050
5051 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5052 {
5053 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5054 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5055 }
5056 }
5057
5058 return CMD_SUCCESS;
5059}
5060
5061ALIAS (no_ip_ospf_priority,
5062 no_ip_ospf_priority_cmd,
5063 "no ip ospf priority",
5064 NO_STR
5065 "IP Information\n"
5066 "OSPF interface commands\n"
5067 "Router priority\n")
5068
5069ALIAS (no_ip_ospf_priority,
5070 no_ospf_priority_cmd,
5071 "no ospf priority",
5072 NO_STR
5073 "OSPF interface commands\n"
5074 "Router priority\n")
5075
5076DEFUN (ip_ospf_retransmit_interval,
5077 ip_ospf_retransmit_interval_addr_cmd,
5078 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5079 "IP Information\n"
5080 "OSPF interface commands\n"
5081 "Time between retransmitting lost link state advertisements\n"
5082 "Seconds\n"
5083 "Address of interface")
5084{
5085 struct interface *ifp = vty->index;
5086 u_int32_t seconds;
5087 struct in_addr addr;
5088 int ret;
5089 struct ospf_if_params *params;
5090
5091 params = IF_DEF_PARAMS (ifp);
5092 seconds = strtol (argv[0], NULL, 10);
5093
5094 /* Retransmit Interval range is <3-65535>. */
5095 if (seconds < 3 || seconds > 65535)
5096 {
5097 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5098 return CMD_WARNING;
5099 }
5100
5101
5102 if (argc == 2)
5103 {
5104 ret = inet_aton(argv[1], &addr);
5105 if (!ret)
5106 {
5107 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5108 VTY_NEWLINE);
5109 return CMD_WARNING;
5110 }
5111
5112 params = ospf_get_if_params (ifp, addr);
5113 ospf_if_update_params (ifp, addr);
5114 }
5115
5116 SET_IF_PARAM (params, retransmit_interval);
5117 params->retransmit_interval = seconds;
5118
5119 return CMD_SUCCESS;
5120}
5121
5122ALIAS (ip_ospf_retransmit_interval,
5123 ip_ospf_retransmit_interval_cmd,
5124 "ip ospf retransmit-interval <3-65535>",
5125 "IP Information\n"
5126 "OSPF interface commands\n"
5127 "Time between retransmitting lost link state advertisements\n"
5128 "Seconds\n")
5129
5130ALIAS (ip_ospf_retransmit_interval,
5131 ospf_retransmit_interval_cmd,
5132 "ospf retransmit-interval <3-65535>",
5133 "OSPF interface commands\n"
5134 "Time between retransmitting lost link state advertisements\n"
5135 "Seconds\n")
5136
5137DEFUN (no_ip_ospf_retransmit_interval,
5138 no_ip_ospf_retransmit_interval_addr_cmd,
5139 "no ip ospf retransmit-interval A.B.C.D",
5140 NO_STR
5141 "IP Information\n"
5142 "OSPF interface commands\n"
5143 "Time between retransmitting lost link state advertisements\n"
5144 "Address of interface")
5145{
5146 struct interface *ifp = vty->index;
5147 struct in_addr addr;
5148 int ret;
5149 struct ospf_if_params *params;
5150
5151 ifp = vty->index;
5152 params = IF_DEF_PARAMS (ifp);
5153
5154 if (argc == 1)
5155 {
5156 ret = inet_aton(argv[0], &addr);
5157 if (!ret)
5158 {
5159 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5160 VTY_NEWLINE);
5161 return CMD_WARNING;
5162 }
5163
5164 params = ospf_lookup_if_params (ifp, addr);
5165 if (params == NULL)
5166 return CMD_SUCCESS;
5167 }
5168
5169 UNSET_IF_PARAM (params, retransmit_interval);
5170 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5171
5172 if (params != IF_DEF_PARAMS (ifp))
5173 {
5174 ospf_free_if_params (ifp, addr);
5175 ospf_if_update_params (ifp, addr);
5176 }
5177
5178 return CMD_SUCCESS;
5179}
5180
5181ALIAS (no_ip_ospf_retransmit_interval,
5182 no_ip_ospf_retransmit_interval_cmd,
5183 "no ip ospf retransmit-interval",
5184 NO_STR
5185 "IP Information\n"
5186 "OSPF interface commands\n"
5187 "Time between retransmitting lost link state advertisements\n")
5188
5189ALIAS (no_ip_ospf_retransmit_interval,
5190 no_ospf_retransmit_interval_cmd,
5191 "no ospf retransmit-interval",
5192 NO_STR
5193 "OSPF interface commands\n"
5194 "Time between retransmitting lost link state advertisements\n")
5195
5196DEFUN (ip_ospf_transmit_delay,
5197 ip_ospf_transmit_delay_addr_cmd,
5198 "ip ospf transmit-delay <1-65535> A.B.C.D",
5199 "IP Information\n"
5200 "OSPF interface commands\n"
5201 "Link state transmit delay\n"
5202 "Seconds\n"
5203 "Address of interface")
5204{
5205 struct interface *ifp = vty->index;
5206 u_int32_t seconds;
5207 struct in_addr addr;
5208 int ret;
5209 struct ospf_if_params *params;
5210
5211 params = IF_DEF_PARAMS (ifp);
5212 seconds = strtol (argv[0], NULL, 10);
5213
5214 /* Transmit Delay range is <1-65535>. */
5215 if (seconds < 1 || seconds > 65535)
5216 {
5217 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5218 return CMD_WARNING;
5219 }
5220
5221 if (argc == 2)
5222 {
5223 ret = inet_aton(argv[1], &addr);
5224 if (!ret)
5225 {
5226 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5227 VTY_NEWLINE);
5228 return CMD_WARNING;
5229 }
5230
5231 params = ospf_get_if_params (ifp, addr);
5232 ospf_if_update_params (ifp, addr);
5233 }
5234
5235 SET_IF_PARAM (params, transmit_delay);
5236 params->transmit_delay = seconds;
5237
5238 return CMD_SUCCESS;
5239}
5240
5241ALIAS (ip_ospf_transmit_delay,
5242 ip_ospf_transmit_delay_cmd,
5243 "ip ospf transmit-delay <1-65535>",
5244 "IP Information\n"
5245 "OSPF interface commands\n"
5246 "Link state transmit delay\n"
5247 "Seconds\n")
5248
5249ALIAS (ip_ospf_transmit_delay,
5250 ospf_transmit_delay_cmd,
5251 "ospf transmit-delay <1-65535>",
5252 "OSPF interface commands\n"
5253 "Link state transmit delay\n"
5254 "Seconds\n")
5255
5256DEFUN (no_ip_ospf_transmit_delay,
5257 no_ip_ospf_transmit_delay_addr_cmd,
5258 "no ip ospf transmit-delay A.B.C.D",
5259 NO_STR
5260 "IP Information\n"
5261 "OSPF interface commands\n"
5262 "Link state transmit delay\n"
5263 "Address of interface")
5264{
5265 struct interface *ifp = vty->index;
5266 struct in_addr addr;
5267 int ret;
5268 struct ospf_if_params *params;
5269
5270 ifp = vty->index;
5271 params = IF_DEF_PARAMS (ifp);
5272
5273 if (argc == 1)
5274 {
5275 ret = inet_aton(argv[0], &addr);
5276 if (!ret)
5277 {
5278 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5279 VTY_NEWLINE);
5280 return CMD_WARNING;
5281 }
5282
5283 params = ospf_lookup_if_params (ifp, addr);
5284 if (params == NULL)
5285 return CMD_SUCCESS;
5286 }
5287
5288 UNSET_IF_PARAM (params, transmit_delay);
5289 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5290
5291 if (params != IF_DEF_PARAMS (ifp))
5292 {
5293 ospf_free_if_params (ifp, addr);
5294 ospf_if_update_params (ifp, addr);
5295 }
5296
5297 return CMD_SUCCESS;
5298}
5299
5300ALIAS (no_ip_ospf_transmit_delay,
5301 no_ip_ospf_transmit_delay_cmd,
5302 "no ip ospf transmit-delay",
5303 NO_STR
5304 "IP Information\n"
5305 "OSPF interface commands\n"
5306 "Link state transmit delay\n")
5307
5308ALIAS (no_ip_ospf_transmit_delay,
5309 no_ospf_transmit_delay_cmd,
5310 "no ospf transmit-delay",
5311 NO_STR
5312 "OSPF interface commands\n"
5313 "Link state transmit delay\n")
5314
5315
5316DEFUN (ospf_redistribute_source_metric_type,
5317 ospf_redistribute_source_metric_type_routemap_cmd,
5318 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5319 "Redistribute information from another routing protocol\n"
5320 "Kernel routes\n"
5321 "Connected\n"
5322 "Static routes\n"
5323 "Routing Information Protocol (RIP)\n"
5324 "Border Gateway Protocol (BGP)\n"
5325 "Metric for redistributed routes\n"
5326 "OSPF default metric\n"
5327 "OSPF exterior metric type for redistributed routes\n"
5328 "Set OSPF External Type 1 metrics\n"
5329 "Set OSPF External Type 2 metrics\n"
5330 "Route map reference\n"
5331 "Pointer to route-map entries\n")
5332{
paul020709f2003-04-04 02:44:16 +00005333 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005334 int source;
5335 int type = -1;
5336 int metric = -1;
5337
5338 /* Get distribute source. */
5339 if (!str2distribute_source (argv[0], &source))
5340 return CMD_WARNING;
5341
5342 /* Get metric value. */
5343 if (argc >= 2)
5344 if (!str2metric (argv[1], &metric))
5345 return CMD_WARNING;
5346
5347 /* Get metric type. */
5348 if (argc >= 3)
5349 if (!str2metric_type (argv[2], &type))
5350 return CMD_WARNING;
5351
5352 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005353 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005354 else
paul020709f2003-04-04 02:44:16 +00005355 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005356
paul020709f2003-04-04 02:44:16 +00005357 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005358}
5359
5360ALIAS (ospf_redistribute_source_metric_type,
5361 ospf_redistribute_source_metric_type_cmd,
5362 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5363 "Redistribute information from another routing protocol\n"
5364 "Kernel routes\n"
5365 "Connected\n"
5366 "Static routes\n"
5367 "Routing Information Protocol (RIP)\n"
5368 "Border Gateway Protocol (BGP)\n"
5369 "Metric for redistributed routes\n"
5370 "OSPF default metric\n"
5371 "OSPF exterior metric type for redistributed routes\n"
5372 "Set OSPF External Type 1 metrics\n"
5373 "Set OSPF External Type 2 metrics\n")
5374
5375ALIAS (ospf_redistribute_source_metric_type,
5376 ospf_redistribute_source_metric_cmd,
5377 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5378 "Redistribute information from another routing protocol\n"
5379 "Kernel routes\n"
5380 "Connected\n"
5381 "Static routes\n"
5382 "Routing Information Protocol (RIP)\n"
5383 "Border Gateway Protocol (BGP)\n"
5384 "Metric for redistributed routes\n"
5385 "OSPF default metric\n")
5386
5387DEFUN (ospf_redistribute_source_type_metric,
5388 ospf_redistribute_source_type_metric_routemap_cmd,
5389 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5390 "Redistribute information from another routing protocol\n"
5391 "Kernel routes\n"
5392 "Connected\n"
5393 "Static routes\n"
5394 "Routing Information Protocol (RIP)\n"
5395 "Border Gateway Protocol (BGP)\n"
5396 "OSPF exterior metric type for redistributed routes\n"
5397 "Set OSPF External Type 1 metrics\n"
5398 "Set OSPF External Type 2 metrics\n"
5399 "Metric for redistributed routes\n"
5400 "OSPF default metric\n"
5401 "Route map reference\n"
5402 "Pointer to route-map entries\n")
5403{
paul020709f2003-04-04 02:44:16 +00005404 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005405 int source;
5406 int type = -1;
5407 int metric = -1;
5408
5409 /* Get distribute source. */
5410 if (!str2distribute_source (argv[0], &source))
5411 return CMD_WARNING;
5412
5413 /* Get metric value. */
5414 if (argc >= 2)
5415 if (!str2metric_type (argv[1], &type))
5416 return CMD_WARNING;
5417
5418 /* Get metric type. */
5419 if (argc >= 3)
5420 if (!str2metric (argv[2], &metric))
5421 return CMD_WARNING;
5422
5423 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005424 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005425 else
paul020709f2003-04-04 02:44:16 +00005426 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005427
paul020709f2003-04-04 02:44:16 +00005428 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005429}
5430
5431ALIAS (ospf_redistribute_source_type_metric,
5432 ospf_redistribute_source_type_metric_cmd,
5433 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5434 "Redistribute information from another routing protocol\n"
5435 "Kernel routes\n"
5436 "Connected\n"
5437 "Static routes\n"
5438 "Routing Information Protocol (RIP)\n"
5439 "Border Gateway Protocol (BGP)\n"
5440 "OSPF exterior metric type for redistributed routes\n"
5441 "Set OSPF External Type 1 metrics\n"
5442 "Set OSPF External Type 2 metrics\n"
5443 "Metric for redistributed routes\n"
5444 "OSPF default metric\n")
5445
5446ALIAS (ospf_redistribute_source_type_metric,
5447 ospf_redistribute_source_type_cmd,
5448 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5449 "Redistribute information from another routing protocol\n"
5450 "Kernel routes\n"
5451 "Connected\n"
5452 "Static routes\n"
5453 "Routing Information Protocol (RIP)\n"
5454 "Border Gateway Protocol (BGP)\n"
5455 "OSPF exterior metric type for redistributed routes\n"
5456 "Set OSPF External Type 1 metrics\n"
5457 "Set OSPF External Type 2 metrics\n")
5458
5459ALIAS (ospf_redistribute_source_type_metric,
5460 ospf_redistribute_source_cmd,
5461 "redistribute (kernel|connected|static|rip|bgp)",
5462 "Redistribute information from another routing protocol\n"
5463 "Kernel routes\n"
5464 "Connected\n"
5465 "Static routes\n"
5466 "Routing Information Protocol (RIP)\n"
5467 "Border Gateway Protocol (BGP)\n")
5468
5469DEFUN (ospf_redistribute_source_metric_routemap,
5470 ospf_redistribute_source_metric_routemap_cmd,
5471 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5472 "Redistribute information from another routing protocol\n"
5473 "Kernel routes\n"
5474 "Connected\n"
5475 "Static routes\n"
5476 "Routing Information Protocol (RIP)\n"
5477 "Border Gateway Protocol (BGP)\n"
5478 "Metric for redistributed routes\n"
5479 "OSPF default metric\n"
5480 "Route map reference\n"
5481 "Pointer to route-map entries\n")
5482{
paul020709f2003-04-04 02:44:16 +00005483 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005484 int source;
5485 int metric = -1;
5486
5487 /* Get distribute source. */
5488 if (!str2distribute_source (argv[0], &source))
5489 return CMD_WARNING;
5490
5491 /* Get metric value. */
5492 if (argc >= 2)
5493 if (!str2metric (argv[1], &metric))
5494 return CMD_WARNING;
5495
5496 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005497 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005498 else
paul020709f2003-04-04 02:44:16 +00005499 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005500
paul020709f2003-04-04 02:44:16 +00005501 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005502}
5503
5504DEFUN (ospf_redistribute_source_type_routemap,
5505 ospf_redistribute_source_type_routemap_cmd,
5506 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5507 "Redistribute information from another routing protocol\n"
5508 "Kernel routes\n"
5509 "Connected\n"
5510 "Static routes\n"
5511 "Routing Information Protocol (RIP)\n"
5512 "Border Gateway Protocol (BGP)\n"
5513 "OSPF exterior metric type for redistributed routes\n"
5514 "Set OSPF External Type 1 metrics\n"
5515 "Set OSPF External Type 2 metrics\n"
5516 "Route map reference\n"
5517 "Pointer to route-map entries\n")
5518{
paul020709f2003-04-04 02:44:16 +00005519 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005520 int source;
5521 int type = -1;
5522
5523 /* Get distribute source. */
5524 if (!str2distribute_source (argv[0], &source))
5525 return CMD_WARNING;
5526
5527 /* Get metric value. */
5528 if (argc >= 2)
5529 if (!str2metric_type (argv[1], &type))
5530 return CMD_WARNING;
5531
5532 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005533 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005534 else
paul020709f2003-04-04 02:44:16 +00005535 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005536
paul020709f2003-04-04 02:44:16 +00005537 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005538}
5539
5540DEFUN (ospf_redistribute_source_routemap,
5541 ospf_redistribute_source_routemap_cmd,
5542 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5543 "Redistribute information from another routing protocol\n"
5544 "Kernel routes\n"
5545 "Connected\n"
5546 "Static routes\n"
5547 "Routing Information Protocol (RIP)\n"
5548 "Border Gateway Protocol (BGP)\n"
5549 "Route map reference\n"
5550 "Pointer to route-map entries\n")
5551{
paul020709f2003-04-04 02:44:16 +00005552 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005553 int source;
5554
5555 /* Get distribute source. */
5556 if (!str2distribute_source (argv[0], &source))
5557 return CMD_WARNING;
5558
5559 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005560 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005561 else
paul020709f2003-04-04 02:44:16 +00005562 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005563
paul020709f2003-04-04 02:44:16 +00005564 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005565}
5566
5567DEFUN (no_ospf_redistribute_source,
5568 no_ospf_redistribute_source_cmd,
5569 "no redistribute (kernel|connected|static|rip|bgp)",
5570 NO_STR
5571 "Redistribute information from another routing protocol\n"
5572 "Kernel routes\n"
5573 "Connected\n"
5574 "Static routes\n"
5575 "Routing Information Protocol (RIP)\n"
5576 "Border Gateway Protocol (BGP)\n")
5577{
paul020709f2003-04-04 02:44:16 +00005578 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005579 int source;
5580
5581 if (!str2distribute_source (argv[0], &source))
5582 return CMD_WARNING;
5583
paul020709f2003-04-04 02:44:16 +00005584 ospf_routemap_unset (ospf, source);
5585 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005586}
5587
5588DEFUN (ospf_distribute_list_out,
5589 ospf_distribute_list_out_cmd,
5590 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5591 "Filter networks in routing updates\n"
5592 "Access-list name\n"
5593 OUT_STR
5594 "Kernel routes\n"
5595 "Connected\n"
5596 "Static routes\n"
5597 "Routing Information Protocol (RIP)\n"
5598 "Border Gateway Protocol (BGP)\n")
5599{
paul68980082003-03-25 05:07:42 +00005600 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005601 int source;
5602
5603 /* Get distribute source. */
5604 if (!str2distribute_source (argv[1], &source))
5605 return CMD_WARNING;
5606
paul68980082003-03-25 05:07:42 +00005607 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005608}
5609
5610DEFUN (no_ospf_distribute_list_out,
5611 no_ospf_distribute_list_out_cmd,
5612 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5613 NO_STR
5614 "Filter networks in routing updates\n"
5615 "Access-list name\n"
5616 OUT_STR
5617 "Kernel routes\n"
5618 "Connected\n"
5619 "Static routes\n"
5620 "Routing Information Protocol (RIP)\n"
5621 "Border Gateway Protocol (BGP)\n")
5622{
paul68980082003-03-25 05:07:42 +00005623 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005624 int source;
5625
5626 if (!str2distribute_source (argv[1], &source))
5627 return CMD_WARNING;
5628
paul68980082003-03-25 05:07:42 +00005629 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005630}
5631
5632/* Default information originate. */
5633DEFUN (ospf_default_information_originate_metric_type_routemap,
5634 ospf_default_information_originate_metric_type_routemap_cmd,
5635 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5636 "Control distribution of default information\n"
5637 "Distribute a default route\n"
5638 "OSPF default metric\n"
5639 "OSPF metric\n"
5640 "OSPF metric type for default routes\n"
5641 "Set OSPF External Type 1 metrics\n"
5642 "Set OSPF External Type 2 metrics\n"
5643 "Route map reference\n"
5644 "Pointer to route-map entries\n")
5645{
paul020709f2003-04-04 02:44:16 +00005646 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005647 int type = -1;
5648 int metric = -1;
5649
5650 /* Get metric value. */
5651 if (argc >= 1)
5652 if (!str2metric (argv[0], &metric))
5653 return CMD_WARNING;
5654
5655 /* Get metric type. */
5656 if (argc >= 2)
5657 if (!str2metric_type (argv[1], &type))
5658 return CMD_WARNING;
5659
5660 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005661 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005662 else
paul020709f2003-04-04 02:44:16 +00005663 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005664
paul020709f2003-04-04 02:44:16 +00005665 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5666 type, metric);
paul718e3742002-12-13 20:15:29 +00005667}
5668
5669ALIAS (ospf_default_information_originate_metric_type_routemap,
5670 ospf_default_information_originate_metric_type_cmd,
5671 "default-information originate metric <0-16777214> metric-type (1|2)",
5672 "Control distribution of default information\n"
5673 "Distribute a default route\n"
5674 "OSPF default metric\n"
5675 "OSPF metric\n"
5676 "OSPF metric type for default routes\n"
5677 "Set OSPF External Type 1 metrics\n"
5678 "Set OSPF External Type 2 metrics\n")
5679
5680ALIAS (ospf_default_information_originate_metric_type_routemap,
5681 ospf_default_information_originate_metric_cmd,
5682 "default-information originate metric <0-16777214>",
5683 "Control distribution of default information\n"
5684 "Distribute a default route\n"
5685 "OSPF default metric\n"
5686 "OSPF metric\n")
5687
5688ALIAS (ospf_default_information_originate_metric_type_routemap,
5689 ospf_default_information_originate_cmd,
5690 "default-information originate",
5691 "Control distribution of default information\n"
5692 "Distribute a default route\n")
5693
5694/* Default information originate. */
5695DEFUN (ospf_default_information_originate_metric_routemap,
5696 ospf_default_information_originate_metric_routemap_cmd,
5697 "default-information originate metric <0-16777214> route-map WORD",
5698 "Control distribution of default information\n"
5699 "Distribute a default route\n"
5700 "OSPF default metric\n"
5701 "OSPF metric\n"
5702 "Route map reference\n"
5703 "Pointer to route-map entries\n")
5704{
paul020709f2003-04-04 02:44:16 +00005705 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005706 int metric = -1;
5707
5708 /* Get metric value. */
5709 if (argc >= 1)
5710 if (!str2metric (argv[0], &metric))
5711 return CMD_WARNING;
5712
5713 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005714 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005715 else
paul020709f2003-04-04 02:44:16 +00005716 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005717
paul020709f2003-04-04 02:44:16 +00005718 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5719 -1, metric);
paul718e3742002-12-13 20:15:29 +00005720}
5721
5722/* Default information originate. */
5723DEFUN (ospf_default_information_originate_routemap,
5724 ospf_default_information_originate_routemap_cmd,
5725 "default-information originate route-map WORD",
5726 "Control distribution of default information\n"
5727 "Distribute a default route\n"
5728 "Route map reference\n"
5729 "Pointer to route-map entries\n")
5730{
paul020709f2003-04-04 02:44:16 +00005731 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005732
paul020709f2003-04-04 02:44:16 +00005733 if (argc == 1)
5734 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5735 else
5736 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5737
5738 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005739}
5740
5741DEFUN (ospf_default_information_originate_type_metric_routemap,
5742 ospf_default_information_originate_type_metric_routemap_cmd,
5743 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5744 "Control distribution of default information\n"
5745 "Distribute a default route\n"
5746 "OSPF metric type for default routes\n"
5747 "Set OSPF External Type 1 metrics\n"
5748 "Set OSPF External Type 2 metrics\n"
5749 "OSPF default metric\n"
5750 "OSPF metric\n"
5751 "Route map reference\n"
5752 "Pointer to route-map entries\n")
5753{
paul020709f2003-04-04 02:44:16 +00005754 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005755 int type = -1;
5756 int metric = -1;
5757
5758 /* Get metric type. */
5759 if (argc >= 1)
5760 if (!str2metric_type (argv[0], &type))
5761 return CMD_WARNING;
5762
5763 /* Get metric value. */
5764 if (argc >= 2)
5765 if (!str2metric (argv[1], &metric))
5766 return CMD_WARNING;
5767
5768 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005769 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005770 else
paul020709f2003-04-04 02:44:16 +00005771 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005772
paul020709f2003-04-04 02:44:16 +00005773 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5774 type, metric);
paul718e3742002-12-13 20:15:29 +00005775}
5776
5777ALIAS (ospf_default_information_originate_type_metric_routemap,
5778 ospf_default_information_originate_type_metric_cmd,
5779 "default-information originate metric-type (1|2) metric <0-16777214>",
5780 "Control distribution of default information\n"
5781 "Distribute a default route\n"
5782 "OSPF metric type for default routes\n"
5783 "Set OSPF External Type 1 metrics\n"
5784 "Set OSPF External Type 2 metrics\n"
5785 "OSPF default metric\n"
5786 "OSPF metric\n")
5787
5788ALIAS (ospf_default_information_originate_type_metric_routemap,
5789 ospf_default_information_originate_type_cmd,
5790 "default-information originate metric-type (1|2)",
5791 "Control distribution of default information\n"
5792 "Distribute a default route\n"
5793 "OSPF metric type for default routes\n"
5794 "Set OSPF External Type 1 metrics\n"
5795 "Set OSPF External Type 2 metrics\n")
5796
5797DEFUN (ospf_default_information_originate_type_routemap,
5798 ospf_default_information_originate_type_routemap_cmd,
5799 "default-information originate metric-type (1|2) route-map WORD",
5800 "Control distribution of default information\n"
5801 "Distribute a default route\n"
5802 "OSPF metric type for default routes\n"
5803 "Set OSPF External Type 1 metrics\n"
5804 "Set OSPF External Type 2 metrics\n"
5805 "Route map reference\n"
5806 "Pointer to route-map entries\n")
5807{
paul020709f2003-04-04 02:44:16 +00005808 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005809 int type = -1;
5810
5811 /* Get metric type. */
5812 if (argc >= 1)
5813 if (!str2metric_type (argv[0], &type))
5814 return CMD_WARNING;
5815
5816 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005817 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005818 else
paul020709f2003-04-04 02:44:16 +00005819 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005820
paul020709f2003-04-04 02:44:16 +00005821 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5822 type, -1);
paul718e3742002-12-13 20:15:29 +00005823}
5824
5825DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5826 ospf_default_information_originate_always_metric_type_routemap_cmd,
5827 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5828 "Control distribution of default information\n"
5829 "Distribute a default route\n"
5830 "Always advertise default route\n"
5831 "OSPF default metric\n"
5832 "OSPF metric\n"
5833 "OSPF metric type for default routes\n"
5834 "Set OSPF External Type 1 metrics\n"
5835 "Set OSPF External Type 2 metrics\n"
5836 "Route map reference\n"
5837 "Pointer to route-map entries\n")
5838{
paul020709f2003-04-04 02:44:16 +00005839 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005840 int type = -1;
5841 int metric = -1;
5842
5843 /* Get metric value. */
5844 if (argc >= 1)
5845 if (!str2metric (argv[0], &metric))
5846 return CMD_WARNING;
5847
5848 /* Get metric type. */
5849 if (argc >= 2)
5850 if (!str2metric_type (argv[1], &type))
5851 return CMD_WARNING;
5852
5853 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005854 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005855 else
paul020709f2003-04-04 02:44:16 +00005856 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005857
paul020709f2003-04-04 02:44:16 +00005858 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005859 type, metric);
5860}
5861
5862ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5863 ospf_default_information_originate_always_metric_type_cmd,
5864 "default-information originate always metric <0-16777214> metric-type (1|2)",
5865 "Control distribution of default information\n"
5866 "Distribute a default route\n"
5867 "Always advertise default route\n"
5868 "OSPF default metric\n"
5869 "OSPF metric\n"
5870 "OSPF metric type for default routes\n"
5871 "Set OSPF External Type 1 metrics\n"
5872 "Set OSPF External Type 2 metrics\n")
5873
5874ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5875 ospf_default_information_originate_always_metric_cmd,
5876 "default-information originate always metric <0-16777214>",
5877 "Control distribution of default information\n"
5878 "Distribute a default route\n"
5879 "Always advertise default route\n"
5880 "OSPF default metric\n"
5881 "OSPF metric\n"
5882 "OSPF metric type for default routes\n")
5883
5884ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5885 ospf_default_information_originate_always_cmd,
5886 "default-information originate always",
5887 "Control distribution of default information\n"
5888 "Distribute a default route\n"
5889 "Always advertise default route\n")
5890
5891DEFUN (ospf_default_information_originate_always_metric_routemap,
5892 ospf_default_information_originate_always_metric_routemap_cmd,
5893 "default-information originate always metric <0-16777214> route-map WORD",
5894 "Control distribution of default information\n"
5895 "Distribute a default route\n"
5896 "Always advertise default route\n"
5897 "OSPF default metric\n"
5898 "OSPF metric\n"
5899 "Route map reference\n"
5900 "Pointer to route-map entries\n")
5901{
paul020709f2003-04-04 02:44:16 +00005902 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005903 int metric = -1;
5904
5905 /* Get metric value. */
5906 if (argc >= 1)
5907 if (!str2metric (argv[0], &metric))
5908 return CMD_WARNING;
5909
5910 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005911 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005912 else
paul020709f2003-04-04 02:44:16 +00005913 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005914
paul020709f2003-04-04 02:44:16 +00005915 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5916 -1, metric);
paul718e3742002-12-13 20:15:29 +00005917}
5918
5919DEFUN (ospf_default_information_originate_always_routemap,
5920 ospf_default_information_originate_always_routemap_cmd,
5921 "default-information originate always route-map WORD",
5922 "Control distribution of default information\n"
5923 "Distribute a default route\n"
5924 "Always advertise default route\n"
5925 "Route map reference\n"
5926 "Pointer to route-map entries\n")
5927{
paul020709f2003-04-04 02:44:16 +00005928 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005929
paul020709f2003-04-04 02:44:16 +00005930 if (argc == 1)
5931 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5932 else
5933 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5934
5935 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005936}
5937
5938DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5939 ospf_default_information_originate_always_type_metric_routemap_cmd,
5940 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5941 "Control distribution of default information\n"
5942 "Distribute a default route\n"
5943 "Always advertise default route\n"
5944 "OSPF metric type for default routes\n"
5945 "Set OSPF External Type 1 metrics\n"
5946 "Set OSPF External Type 2 metrics\n"
5947 "OSPF default metric\n"
5948 "OSPF metric\n"
5949 "Route map reference\n"
5950 "Pointer to route-map entries\n")
5951{
paul020709f2003-04-04 02:44:16 +00005952 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005953 int type = -1;
5954 int metric = -1;
5955
5956 /* Get metric type. */
5957 if (argc >= 1)
5958 if (!str2metric_type (argv[0], &type))
5959 return CMD_WARNING;
5960
5961 /* Get metric value. */
5962 if (argc >= 2)
5963 if (!str2metric (argv[1], &metric))
5964 return CMD_WARNING;
5965
5966 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005967 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005968 else
paul020709f2003-04-04 02:44:16 +00005969 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005970
paul020709f2003-04-04 02:44:16 +00005971 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005972 type, metric);
5973}
5974
5975ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5976 ospf_default_information_originate_always_type_metric_cmd,
5977 "default-information originate always metric-type (1|2) metric <0-16777214>",
5978 "Control distribution of default information\n"
5979 "Distribute a default route\n"
5980 "Always advertise default route\n"
5981 "OSPF metric type for default routes\n"
5982 "Set OSPF External Type 1 metrics\n"
5983 "Set OSPF External Type 2 metrics\n"
5984 "OSPF default metric\n"
5985 "OSPF metric\n")
5986
5987ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5988 ospf_default_information_originate_always_type_cmd,
5989 "default-information originate always metric-type (1|2)",
5990 "Control distribution of default information\n"
5991 "Distribute a default route\n"
5992 "Always advertise default route\n"
5993 "OSPF metric type for default routes\n"
5994 "Set OSPF External Type 1 metrics\n"
5995 "Set OSPF External Type 2 metrics\n")
5996
5997DEFUN (ospf_default_information_originate_always_type_routemap,
5998 ospf_default_information_originate_always_type_routemap_cmd,
5999 "default-information originate always metric-type (1|2) route-map WORD",
6000 "Control distribution of default information\n"
6001 "Distribute a default route\n"
6002 "Always advertise default route\n"
6003 "OSPF metric type for default routes\n"
6004 "Set OSPF External Type 1 metrics\n"
6005 "Set OSPF External Type 2 metrics\n"
6006 "Route map reference\n"
6007 "Pointer to route-map entries\n")
6008{
paul020709f2003-04-04 02:44:16 +00006009 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006010 int type = -1;
6011
6012 /* Get metric type. */
6013 if (argc >= 1)
6014 if (!str2metric_type (argv[0], &type))
6015 return CMD_WARNING;
6016
6017 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006018 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006019 else
paul020709f2003-04-04 02:44:16 +00006020 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006021
paul020709f2003-04-04 02:44:16 +00006022 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006023 type, -1);
6024}
6025
6026DEFUN (no_ospf_default_information_originate,
6027 no_ospf_default_information_originate_cmd,
6028 "no default-information originate",
6029 NO_STR
6030 "Control distribution of default information\n"
6031 "Distribute a default route\n")
6032{
paul68980082003-03-25 05:07:42 +00006033 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006034 struct prefix_ipv4 p;
6035 struct in_addr nexthop;
6036
6037 p.family = AF_INET;
6038 p.prefix.s_addr = 0;
6039 p.prefixlen = 0;
6040
paul68980082003-03-25 05:07:42 +00006041 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
paul718e3742002-12-13 20:15:29 +00006042
6043 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6044 ospf_external_info_delete (DEFAULT_ROUTE, p);
6045 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6046 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6047 }
6048
paul020709f2003-04-04 02:44:16 +00006049 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6050 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006051}
6052
6053DEFUN (ospf_default_metric,
6054 ospf_default_metric_cmd,
6055 "default-metric <0-16777214>",
6056 "Set metric of redistributed routes\n"
6057 "Default metric\n")
6058{
paul68980082003-03-25 05:07:42 +00006059 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006060 int metric = -1;
6061
6062 if (!str2metric (argv[0], &metric))
6063 return CMD_WARNING;
6064
paul68980082003-03-25 05:07:42 +00006065 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006066
6067 return CMD_SUCCESS;
6068}
6069
6070DEFUN (no_ospf_default_metric,
6071 no_ospf_default_metric_cmd,
6072 "no default-metric",
6073 NO_STR
6074 "Set metric of redistributed routes\n")
6075{
paul68980082003-03-25 05:07:42 +00006076 struct ospf *ospf = vty->index;
6077
6078 ospf->default_metric = -1;
6079
paul718e3742002-12-13 20:15:29 +00006080 return CMD_SUCCESS;
6081}
6082
6083ALIAS (no_ospf_default_metric,
6084 no_ospf_default_metric_val_cmd,
6085 "no default-metric <0-16777214>",
6086 NO_STR
6087 "Set metric of redistributed routes\n"
6088 "Default metric\n")
6089
6090DEFUN (ospf_distance,
6091 ospf_distance_cmd,
6092 "distance <1-255>",
6093 "Define an administrative distance\n"
6094 "OSPF Administrative distance\n")
6095{
paul68980082003-03-25 05:07:42 +00006096 struct ospf *ospf = vty->index;
6097
6098 ospf->distance_all = atoi (argv[0]);
6099
paul718e3742002-12-13 20:15:29 +00006100 return CMD_SUCCESS;
6101}
6102
6103DEFUN (no_ospf_distance,
6104 no_ospf_distance_cmd,
6105 "no distance <1-255>",
6106 NO_STR
6107 "Define an administrative distance\n"
6108 "OSPF Administrative distance\n")
6109{
paul68980082003-03-25 05:07:42 +00006110 struct ospf *ospf = vty->index;
6111
6112 ospf->distance_all = 0;
6113
paul718e3742002-12-13 20:15:29 +00006114 return CMD_SUCCESS;
6115}
6116
6117DEFUN (no_ospf_distance_ospf,
6118 no_ospf_distance_ospf_cmd,
6119 "no distance ospf",
6120 NO_STR
6121 "Define an administrative distance\n"
6122 "OSPF Administrative distance\n"
6123 "OSPF Distance\n")
6124{
paul68980082003-03-25 05:07:42 +00006125 struct ospf *ospf = vty->index;
6126
6127 ospf->distance_intra = 0;
6128 ospf->distance_inter = 0;
6129 ospf->distance_external = 0;
6130
paul718e3742002-12-13 20:15:29 +00006131 return CMD_SUCCESS;
6132}
6133
6134DEFUN (ospf_distance_ospf_intra,
6135 ospf_distance_ospf_intra_cmd,
6136 "distance ospf intra-area <1-255>",
6137 "Define an administrative distance\n"
6138 "OSPF Administrative distance\n"
6139 "Intra-area routes\n"
6140 "Distance for intra-area routes\n")
6141{
paul68980082003-03-25 05:07:42 +00006142 struct ospf *ospf = vty->index;
6143
6144 ospf->distance_intra = atoi (argv[0]);
6145
paul718e3742002-12-13 20:15:29 +00006146 return CMD_SUCCESS;
6147}
6148
6149DEFUN (ospf_distance_ospf_intra_inter,
6150 ospf_distance_ospf_intra_inter_cmd,
6151 "distance ospf intra-area <1-255> inter-area <1-255>",
6152 "Define an administrative distance\n"
6153 "OSPF Administrative distance\n"
6154 "Intra-area routes\n"
6155 "Distance for intra-area routes\n"
6156 "Inter-area routes\n"
6157 "Distance for inter-area routes\n")
6158{
paul68980082003-03-25 05:07:42 +00006159 struct ospf *ospf = vty->index;
6160
6161 ospf->distance_intra = atoi (argv[0]);
6162 ospf->distance_inter = atoi (argv[1]);
6163
paul718e3742002-12-13 20:15:29 +00006164 return CMD_SUCCESS;
6165}
6166
6167DEFUN (ospf_distance_ospf_intra_external,
6168 ospf_distance_ospf_intra_external_cmd,
6169 "distance ospf intra-area <1-255> external <1-255>",
6170 "Define an administrative distance\n"
6171 "OSPF Administrative distance\n"
6172 "Intra-area routes\n"
6173 "Distance for intra-area routes\n"
6174 "External routes\n"
6175 "Distance for external routes\n")
6176{
paul68980082003-03-25 05:07:42 +00006177 struct ospf *ospf = vty->index;
6178
6179 ospf->distance_intra = atoi (argv[0]);
6180 ospf->distance_external = atoi (argv[1]);
6181
paul718e3742002-12-13 20:15:29 +00006182 return CMD_SUCCESS;
6183}
6184
6185DEFUN (ospf_distance_ospf_intra_inter_external,
6186 ospf_distance_ospf_intra_inter_external_cmd,
6187 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6188 "Define an administrative distance\n"
6189 "OSPF Administrative distance\n"
6190 "Intra-area routes\n"
6191 "Distance for intra-area routes\n"
6192 "Inter-area routes\n"
6193 "Distance for inter-area routes\n"
6194 "External routes\n"
6195 "Distance for external routes\n")
6196{
paul68980082003-03-25 05:07:42 +00006197 struct ospf *ospf = vty->index;
6198
6199 ospf->distance_intra = atoi (argv[0]);
6200 ospf->distance_inter = atoi (argv[1]);
6201 ospf->distance_external = atoi (argv[2]);
6202
paul718e3742002-12-13 20:15:29 +00006203 return CMD_SUCCESS;
6204}
6205
6206DEFUN (ospf_distance_ospf_intra_external_inter,
6207 ospf_distance_ospf_intra_external_inter_cmd,
6208 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6209 "Define an administrative distance\n"
6210 "OSPF Administrative distance\n"
6211 "Intra-area routes\n"
6212 "Distance for intra-area routes\n"
6213 "External routes\n"
6214 "Distance for external routes\n"
6215 "Inter-area routes\n"
6216 "Distance for inter-area routes\n")
6217{
paul68980082003-03-25 05:07:42 +00006218 struct ospf *ospf = vty->index;
6219
6220 ospf->distance_intra = atoi (argv[0]);
6221 ospf->distance_external = atoi (argv[1]);
6222 ospf->distance_inter = atoi (argv[2]);
6223
paul718e3742002-12-13 20:15:29 +00006224 return CMD_SUCCESS;
6225}
6226
6227DEFUN (ospf_distance_ospf_inter,
6228 ospf_distance_ospf_inter_cmd,
6229 "distance ospf inter-area <1-255>",
6230 "Define an administrative distance\n"
6231 "OSPF Administrative distance\n"
6232 "Inter-area routes\n"
6233 "Distance for inter-area routes\n")
6234{
paul68980082003-03-25 05:07:42 +00006235 struct ospf *ospf = vty->index;
6236
6237 ospf->distance_inter = atoi (argv[0]);
6238
paul718e3742002-12-13 20:15:29 +00006239 return CMD_SUCCESS;
6240}
6241
6242DEFUN (ospf_distance_ospf_inter_intra,
6243 ospf_distance_ospf_inter_intra_cmd,
6244 "distance ospf inter-area <1-255> intra-area <1-255>",
6245 "Define an administrative distance\n"
6246 "OSPF Administrative distance\n"
6247 "Inter-area routes\n"
6248 "Distance for inter-area routes\n"
6249 "Intra-area routes\n"
6250 "Distance for intra-area routes\n")
6251{
paul68980082003-03-25 05:07:42 +00006252 struct ospf *ospf = vty->index;
6253
6254 ospf->distance_inter = atoi (argv[0]);
6255 ospf->distance_intra = atoi (argv[1]);
6256
paul718e3742002-12-13 20:15:29 +00006257 return CMD_SUCCESS;
6258}
6259
6260DEFUN (ospf_distance_ospf_inter_external,
6261 ospf_distance_ospf_inter_external_cmd,
6262 "distance ospf inter-area <1-255> external <1-255>",
6263 "Define an administrative distance\n"
6264 "OSPF Administrative distance\n"
6265 "Inter-area routes\n"
6266 "Distance for inter-area routes\n"
6267 "External routes\n"
6268 "Distance for external routes\n")
6269{
paul68980082003-03-25 05:07:42 +00006270 struct ospf *ospf = vty->index;
6271
6272 ospf->distance_inter = atoi (argv[0]);
6273 ospf->distance_external = atoi (argv[1]);
6274
paul718e3742002-12-13 20:15:29 +00006275 return CMD_SUCCESS;
6276}
6277
6278DEFUN (ospf_distance_ospf_inter_intra_external,
6279 ospf_distance_ospf_inter_intra_external_cmd,
6280 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6281 "Define an administrative distance\n"
6282 "OSPF Administrative distance\n"
6283 "Inter-area routes\n"
6284 "Distance for inter-area routes\n"
6285 "Intra-area routes\n"
6286 "Distance for intra-area routes\n"
6287 "External routes\n"
6288 "Distance for external routes\n")
6289{
paul68980082003-03-25 05:07:42 +00006290 struct ospf *ospf = vty->index;
6291
6292 ospf->distance_inter = atoi (argv[0]);
6293 ospf->distance_intra = atoi (argv[1]);
6294 ospf->distance_external = atoi (argv[2]);
6295
paul718e3742002-12-13 20:15:29 +00006296 return CMD_SUCCESS;
6297}
6298
6299DEFUN (ospf_distance_ospf_inter_external_intra,
6300 ospf_distance_ospf_inter_external_intra_cmd,
6301 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6302 "Define an administrative distance\n"
6303 "OSPF Administrative distance\n"
6304 "Inter-area routes\n"
6305 "Distance for inter-area routes\n"
6306 "External routes\n"
6307 "Distance for external routes\n"
6308 "Intra-area routes\n"
6309 "Distance for intra-area routes\n")
6310{
paul68980082003-03-25 05:07:42 +00006311 struct ospf *ospf = vty->index;
6312
6313 ospf->distance_inter = atoi (argv[0]);
6314 ospf->distance_external = atoi (argv[1]);
6315 ospf->distance_intra = atoi (argv[2]);
6316
paul718e3742002-12-13 20:15:29 +00006317 return CMD_SUCCESS;
6318}
6319
6320DEFUN (ospf_distance_ospf_external,
6321 ospf_distance_ospf_external_cmd,
6322 "distance ospf external <1-255>",
6323 "Define an administrative distance\n"
6324 "OSPF Administrative distance\n"
6325 "External routes\n"
6326 "Distance for external routes\n")
6327{
paul68980082003-03-25 05:07:42 +00006328 struct ospf *ospf = vty->index;
6329
6330 ospf->distance_external = atoi (argv[0]);
6331
paul718e3742002-12-13 20:15:29 +00006332 return CMD_SUCCESS;
6333}
6334
6335DEFUN (ospf_distance_ospf_external_intra,
6336 ospf_distance_ospf_external_intra_cmd,
6337 "distance ospf external <1-255> intra-area <1-255>",
6338 "Define an administrative distance\n"
6339 "OSPF Administrative distance\n"
6340 "External routes\n"
6341 "Distance for external routes\n"
6342 "Intra-area routes\n"
6343 "Distance for intra-area routes\n")
6344{
paul68980082003-03-25 05:07:42 +00006345 struct ospf *ospf = vty->index;
6346
6347 ospf->distance_external = atoi (argv[0]);
6348 ospf->distance_intra = atoi (argv[1]);
6349
paul718e3742002-12-13 20:15:29 +00006350 return CMD_SUCCESS;
6351}
6352
6353DEFUN (ospf_distance_ospf_external_inter,
6354 ospf_distance_ospf_external_inter_cmd,
6355 "distance ospf external <1-255> inter-area <1-255>",
6356 "Define an administrative distance\n"
6357 "OSPF Administrative distance\n"
6358 "External routes\n"
6359 "Distance for external routes\n"
6360 "Inter-area routes\n"
6361 "Distance for inter-area routes\n")
6362{
paul68980082003-03-25 05:07:42 +00006363 struct ospf *ospf = vty->index;
6364
6365 ospf->distance_external = atoi (argv[0]);
6366 ospf->distance_inter = atoi (argv[1]);
6367
paul718e3742002-12-13 20:15:29 +00006368 return CMD_SUCCESS;
6369}
6370
6371DEFUN (ospf_distance_ospf_external_intra_inter,
6372 ospf_distance_ospf_external_intra_inter_cmd,
6373 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6374 "Define an administrative distance\n"
6375 "OSPF Administrative distance\n"
6376 "External routes\n"
6377 "Distance for external routes\n"
6378 "Intra-area routes\n"
6379 "Distance for intra-area routes\n"
6380 "Inter-area routes\n"
6381 "Distance for inter-area routes\n")
6382{
paul68980082003-03-25 05:07:42 +00006383 struct ospf *ospf = vty->index;
6384
6385 ospf->distance_external = atoi (argv[0]);
6386 ospf->distance_intra = atoi (argv[1]);
6387 ospf->distance_inter = atoi (argv[2]);
6388
paul718e3742002-12-13 20:15:29 +00006389 return CMD_SUCCESS;
6390}
6391
6392DEFUN (ospf_distance_ospf_external_inter_intra,
6393 ospf_distance_ospf_external_inter_intra_cmd,
6394 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6395 "Define an administrative distance\n"
6396 "OSPF Administrative distance\n"
6397 "External routes\n"
6398 "Distance for external routes\n"
6399 "Inter-area routes\n"
6400 "Distance for inter-area routes\n"
6401 "Intra-area routes\n"
6402 "Distance for intra-area routes\n")
6403{
paul68980082003-03-25 05:07:42 +00006404 struct ospf *ospf = vty->index;
6405
6406 ospf->distance_external = atoi (argv[0]);
6407 ospf->distance_inter = atoi (argv[1]);
6408 ospf->distance_intra = atoi (argv[2]);
6409
paul718e3742002-12-13 20:15:29 +00006410 return CMD_SUCCESS;
6411}
6412
6413DEFUN (ospf_distance_source,
6414 ospf_distance_source_cmd,
6415 "distance <1-255> A.B.C.D/M",
6416 "Administrative distance\n"
6417 "Distance value\n"
6418 "IP source prefix\n")
6419{
paul020709f2003-04-04 02:44:16 +00006420 struct ospf *ospf = vty->index;
6421
6422 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006423
paul718e3742002-12-13 20:15:29 +00006424 return CMD_SUCCESS;
6425}
6426
6427DEFUN (no_ospf_distance_source,
6428 no_ospf_distance_source_cmd,
6429 "no distance <1-255> A.B.C.D/M",
6430 NO_STR
6431 "Administrative distance\n"
6432 "Distance value\n"
6433 "IP source prefix\n")
6434{
paul020709f2003-04-04 02:44:16 +00006435 struct ospf *ospf = vty->index;
6436
6437 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6438
paul718e3742002-12-13 20:15:29 +00006439 return CMD_SUCCESS;
6440}
6441
6442DEFUN (ospf_distance_source_access_list,
6443 ospf_distance_source_access_list_cmd,
6444 "distance <1-255> A.B.C.D/M WORD",
6445 "Administrative distance\n"
6446 "Distance value\n"
6447 "IP source prefix\n"
6448 "Access list name\n")
6449{
paul020709f2003-04-04 02:44:16 +00006450 struct ospf *ospf = vty->index;
6451
6452 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6453
paul718e3742002-12-13 20:15:29 +00006454 return CMD_SUCCESS;
6455}
6456
6457DEFUN (no_ospf_distance_source_access_list,
6458 no_ospf_distance_source_access_list_cmd,
6459 "no distance <1-255> A.B.C.D/M WORD",
6460 NO_STR
6461 "Administrative distance\n"
6462 "Distance value\n"
6463 "IP source prefix\n"
6464 "Access list name\n")
6465{
paul020709f2003-04-04 02:44:16 +00006466 struct ospf *ospf = vty->index;
6467
6468 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6469
paul718e3742002-12-13 20:15:29 +00006470 return CMD_SUCCESS;
6471}
6472
6473void
6474show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6475{
6476 struct route_node *rn;
6477 struct ospf_route *or;
6478 listnode pnode;
6479 struct ospf_path *path;
6480
6481 vty_out (vty, "============ OSPF network routing table ============%s",
6482 VTY_NEWLINE);
6483
6484 for (rn = route_top (rt); rn; rn = route_next (rn))
6485 if ((or = rn->info) != NULL)
6486 {
6487 char buf1[19];
6488 snprintf (buf1, 19, "%s/%d",
6489 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6490
6491 switch (or->path_type)
6492 {
6493 case OSPF_PATH_INTER_AREA:
6494 if (or->type == OSPF_DESTINATION_NETWORK)
6495 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6496 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6497 else if (or->type == OSPF_DESTINATION_DISCARD)
6498 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6499 break;
6500 case OSPF_PATH_INTRA_AREA:
6501 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6502 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6503 break;
6504 default:
6505 break;
6506 }
6507
6508 if (or->type == OSPF_DESTINATION_NETWORK)
paul96735ee2003-08-10 02:51:22 +00006509 LIST_LOOP (or->paths, path, pnode)
6510 {
6511 if (path->oi != NULL)
6512 {
6513 if (path->nexthop.s_addr == 0)
6514 vty_out (vty, "%24s directly attached to %s%s",
6515 "", path->oi->ifp->name, VTY_NEWLINE);
6516 else
6517 vty_out (vty, "%24s via %s, %s%s", "",
6518 inet_ntoa (path->nexthop), path->oi->ifp->name,
6519 VTY_NEWLINE);
6520 }
6521 }
paul718e3742002-12-13 20:15:29 +00006522 }
6523 vty_out (vty, "%s", VTY_NEWLINE);
6524}
6525
6526void
6527show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6528{
6529 struct route_node *rn;
6530 struct ospf_route *or;
6531 listnode pn, nn;
6532 struct ospf_path *path;
6533
6534 vty_out (vty, "============ OSPF router routing table =============%s",
6535 VTY_NEWLINE);
6536 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6537 if (rn->info)
6538 {
6539 int flag = 0;
6540
6541 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6542
6543 for (nn = listhead ((list) rn->info); nn; nextnode (nn))
6544 if ((or = getdata (nn)) != NULL)
6545 {
6546 if (flag++)
paulb0a053b2003-06-22 09:04:47 +00006547 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006548
6549 /* Show path. */
6550 vty_out (vty, "%s [%d] area: %s",
6551 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6552 or->cost, inet_ntoa (or->u.std.area_id));
6553 /* Show flags. */
6554 vty_out (vty, "%s%s%s",
6555 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6556 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6557 VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006558
6559 LIST_LOOP (or->paths, path, pn)
6560 {
6561 if (path->nexthop.s_addr == 0)
6562 vty_out (vty, "%24s directly attached to %s%s",
6563 "", path->oi->ifp->name, VTY_NEWLINE);
6564 else
6565 vty_out (vty, "%24s via %s, %s%s", "",
6566 inet_ntoa (path->nexthop), path->oi->ifp->name,
6567 VTY_NEWLINE);
6568 }
paul718e3742002-12-13 20:15:29 +00006569 }
6570 }
6571 vty_out (vty, "%s", VTY_NEWLINE);
6572}
6573
6574void
6575show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6576{
6577 struct route_node *rn;
6578 struct ospf_route *er;
6579 listnode pnode;
6580 struct ospf_path *path;
6581
6582 vty_out (vty, "============ OSPF external routing table ===========%s",
6583 VTY_NEWLINE);
6584 for (rn = route_top (rt); rn; rn = route_next (rn))
6585 if ((er = rn->info) != NULL)
6586 {
6587 char buf1[19];
6588 snprintf (buf1, 19, "%s/%d",
6589 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6590
6591 switch (er->path_type)
6592 {
6593 case OSPF_PATH_TYPE1_EXTERNAL:
6594 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6595 er->cost, er->u.ext.tag, VTY_NEWLINE);
6596 break;
6597 case OSPF_PATH_TYPE2_EXTERNAL:
6598 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6599 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6600 break;
6601 }
6602
paul96735ee2003-08-10 02:51:22 +00006603 LIST_LOOP (er->paths, path, pnode)
paul718e3742002-12-13 20:15:29 +00006604 {
paul718e3742002-12-13 20:15:29 +00006605 if (path->oi != NULL)
6606 {
6607 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006608 vty_out (vty, "%24s directly attached to %s%s",
6609 "", path->oi->ifp->name, VTY_NEWLINE);
6610 else
6611 vty_out (vty, "%24s via %s, %s%s", "",
6612 inet_ntoa (path->nexthop), path->oi->ifp->name,
6613 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006614 }
6615 }
6616 }
6617 vty_out (vty, "%s", VTY_NEWLINE);
6618}
6619
6620#ifdef HAVE_NSSA
6621DEFUN (show_ip_ospf_border_routers,
6622 show_ip_ospf_border_routers_cmd,
6623 "show ip ospf border-routers",
6624 SHOW_STR
6625 IP_STR
6626 "show all the ABR's and ASBR's\n"
6627 "for this area\n")
6628{
paul020709f2003-04-04 02:44:16 +00006629 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006630
paul020709f2003-04-04 02:44:16 +00006631 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006632 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006633 {
6634 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6635 return CMD_SUCCESS;
6636 }
6637
paul68980082003-03-25 05:07:42 +00006638 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006639 {
6640 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6641 return CMD_SUCCESS;
6642 }
6643
6644 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006645 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006646
6647 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006648 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006649
6650 return CMD_SUCCESS;
6651}
6652#endif /* HAVE_NSSA */
6653
6654DEFUN (show_ip_ospf_route,
6655 show_ip_ospf_route_cmd,
6656 "show ip ospf route",
6657 SHOW_STR
6658 IP_STR
6659 "OSPF information\n"
6660 "OSPF routing table\n")
6661{
paul020709f2003-04-04 02:44:16 +00006662 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006663
paul020709f2003-04-04 02:44:16 +00006664 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006665 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006666 {
6667 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6668 return CMD_SUCCESS;
6669 }
6670
paul68980082003-03-25 05:07:42 +00006671 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006672 {
6673 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6674 return CMD_SUCCESS;
6675 }
6676
6677 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006678 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006679
6680 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006681 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006682
6683 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006684 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006685
6686 return CMD_SUCCESS;
6687}
6688
6689
6690char *ospf_abr_type_str[] =
6691{
6692 "unknown",
6693 "standard",
6694 "ibm",
6695 "cisco",
6696 "shortcut"
6697};
6698
6699char *ospf_shortcut_mode_str[] =
6700{
6701 "default",
6702 "enable",
6703 "disable"
6704};
6705
6706
6707void
6708area_id2str (char *buf, int length, struct ospf_area *area)
6709{
6710 memset (buf, 0, length);
6711
6712 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6713 strncpy (buf, inet_ntoa (area->area_id), length);
6714 else
6715 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6716}
6717
6718
6719char *ospf_int_type_str[] =
6720{
6721 "unknown", /* should never be used. */
6722 "point-to-point",
6723 "broadcast",
6724 "non-broadcast",
6725 "point-to-multipoint",
6726 "virtual-link", /* should never be used. */
6727 "loopback"
6728};
6729
6730/* Configuration write function for ospfd. */
6731int
6732config_write_interface (struct vty *vty)
6733{
6734 listnode n1, n2;
6735 struct interface *ifp;
6736 struct crypt_key *ck;
6737 int write = 0;
6738 struct route_node *rn = NULL;
6739 struct ospf_if_params *params;
6740
6741 for (n1 = listhead (iflist); n1; nextnode (n1))
6742 {
6743 ifp = getdata (n1);
6744
6745 if (memcmp (ifp->name, "VLINK", 5) == 0)
6746 continue;
6747
6748 vty_out (vty, "!%s", VTY_NEWLINE);
6749 vty_out (vty, "interface %s%s", ifp->name,
6750 VTY_NEWLINE);
6751 if (ifp->desc)
6752 vty_out (vty, " description %s%s", ifp->desc,
6753 VTY_NEWLINE);
6754
6755 write++;
6756
6757 params = IF_DEF_PARAMS (ifp);
6758
6759 do {
6760 /* Interface Network print. */
6761 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
6762 params->type != OSPF_IFTYPE_BROADCAST &&
6763 params->type != OSPF_IFTYPE_LOOPBACK)
6764 {
6765 vty_out (vty, " ip ospf network %s",
6766 ospf_int_type_str[params->type]);
6767 if (params != IF_DEF_PARAMS (ifp))
6768 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6769 vty_out (vty, "%s", VTY_NEWLINE);
6770 }
6771
6772 /* OSPF interface authentication print */
6773 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6774 params->auth_type != OSPF_AUTH_NOTSET)
6775 {
6776 char *auth_str;
6777
6778 /* Translation tables are not that much help here due to syntax
6779 of the simple option */
6780 switch (params->auth_type)
6781 {
6782
6783 case OSPF_AUTH_NULL:
6784 auth_str = " null";
6785 break;
6786
6787 case OSPF_AUTH_SIMPLE:
6788 auth_str = "";
6789 break;
6790
6791 case OSPF_AUTH_CRYPTOGRAPHIC:
6792 auth_str = " message-digest";
6793 break;
6794
6795 default:
6796 auth_str = "";
6797 break;
6798 }
6799
6800 vty_out (vty, " ip ospf authentication%s", auth_str);
6801 if (params != IF_DEF_PARAMS (ifp))
6802 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6803 vty_out (vty, "%s", VTY_NEWLINE);
6804 }
6805
6806 /* Simple Authentication Password print. */
6807 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6808 params->auth_simple[0] != '\0')
6809 {
6810 vty_out (vty, " ip ospf authentication-key %s",
6811 params->auth_simple);
6812 if (params != IF_DEF_PARAMS (ifp))
6813 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6814 vty_out (vty, "%s", VTY_NEWLINE);
6815 }
6816
6817 /* Cryptographic Authentication Key print. */
6818 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
6819 {
6820 ck = getdata (n2);
6821 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6822 ck->key_id, ck->auth_key);
6823 if (params != IF_DEF_PARAMS (ifp))
6824 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6825 vty_out (vty, "%s", VTY_NEWLINE);
6826 }
6827
6828 /* Interface Output Cost print. */
6829 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6830 {
6831 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6832 if (params != IF_DEF_PARAMS (ifp))
6833 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6834 vty_out (vty, "%s", VTY_NEWLINE);
6835 }
6836
6837 /* Hello Interval print. */
6838 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6839 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6840 {
6841 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6842 if (params != IF_DEF_PARAMS (ifp))
6843 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6844 vty_out (vty, "%s", VTY_NEWLINE);
6845 }
6846
6847
6848 /* Router Dead Interval print. */
6849 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6850 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6851 {
6852 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6853 if (params != IF_DEF_PARAMS (ifp))
6854 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6855 vty_out (vty, "%s", VTY_NEWLINE);
6856 }
6857
6858 /* Router Priority print. */
6859 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6860 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6861 {
6862 vty_out (vty, " ip ospf priority %u", params->priority);
6863 if (params != IF_DEF_PARAMS (ifp))
6864 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6865 vty_out (vty, "%s", VTY_NEWLINE);
6866 }
6867
6868 /* Retransmit Interval print. */
6869 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6870 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6871 {
6872 vty_out (vty, " ip ospf retransmit-interval %u",
6873 params->retransmit_interval);
6874 if (params != IF_DEF_PARAMS (ifp))
6875 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6876 vty_out (vty, "%s", VTY_NEWLINE);
6877 }
6878
6879 /* Transmit Delay print. */
6880 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6881 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6882 {
6883 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6884 if (params != IF_DEF_PARAMS (ifp))
6885 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6886 vty_out (vty, "%s", VTY_NEWLINE);
6887 }
6888
6889 while (1)
6890 {
6891 if (rn == NULL)
6892 rn = route_top (IF_OIFS_PARAMS (ifp));
6893 else
6894 rn = route_next (rn);
6895
6896 if (rn == NULL)
6897 break;
6898 params = rn->info;
6899 if (params != NULL)
6900 break;
6901 }
6902 } while (rn);
6903
6904#ifdef HAVE_OPAQUE_LSA
6905 ospf_opaque_config_write_if (vty, ifp);
6906#endif /* HAVE_OPAQUE_LSA */
6907 }
6908
6909 return write;
6910}
6911
6912int
paul68980082003-03-25 05:07:42 +00006913config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006914{
6915 struct route_node *rn;
6916 u_char buf[INET_ADDRSTRLEN];
6917
6918 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006919 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006920 if (rn->info)
6921 {
6922 struct ospf_network *n = rn->info;
6923
6924 memset (buf, 0, INET_ADDRSTRLEN);
6925
6926 /* Create Area ID string by specified Area ID format. */
6927 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6928 strncpy (buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
6929 else
6930 sprintf (buf, "%lu",
6931 (unsigned long int) ntohl (n->area_id.s_addr));
6932
6933 /* Network print. */
6934 vty_out (vty, " network %s/%d area %s%s",
6935 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6936 buf, VTY_NEWLINE);
6937 }
6938
6939 return 0;
6940}
6941
6942int
paul68980082003-03-25 05:07:42 +00006943config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006944{
6945 listnode node;
6946 u_char buf[INET_ADDRSTRLEN];
6947
6948 /* Area configuration print. */
paul68980082003-03-25 05:07:42 +00006949 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00006950 {
6951 struct ospf_area *area = getdata (node);
6952 struct route_node *rn1;
6953
6954 area_id2str (buf, INET_ADDRSTRLEN, area);
6955
6956 if (area->auth_type != OSPF_AUTH_NULL)
6957 {
6958 if (area->auth_type == OSPF_AUTH_SIMPLE)
6959 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6960 else
6961 vty_out (vty, " area %s authentication message-digest%s",
6962 buf, VTY_NEWLINE);
6963 }
6964
6965 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6966 vty_out (vty, " area %s shortcut %s%s", buf,
6967 ospf_shortcut_mode_str[area->shortcut_configured],
6968 VTY_NEWLINE);
6969
6970 if ((area->external_routing == OSPF_AREA_STUB)
6971#ifdef HAVE_NSSA
6972 || (area->external_routing == OSPF_AREA_NSSA)
6973#endif /* HAVE_NSSA */
6974 )
6975 {
paulb0a053b2003-06-22 09:04:47 +00006976 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006977 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00006978#ifdef HAVE_NSSA
6979 else if (area->external_routing == OSPF_AREA_NSSA)
6980 {
6981 vty_out (vty, " area %s nssa", buf);
6982 switch (area->NSSATranslatorRole)
6983 {
6984 case OSPF_NSSA_ROLE_NEVER:
6985 vty_out (vty, " translate-never");
6986 break;
6987 case OSPF_NSSA_ROLE_ALWAYS:
6988 vty_out (vty, " translate-always");
6989 break;
6990 case OSPF_NSSA_ROLE_CANDIDATE:
6991 default:
6992 vty_out (vty, " translate-candidate");
6993 }
6994 }
6995#endif /* HAVE_NSSA */
paul718e3742002-12-13 20:15:29 +00006996
6997 if (area->no_summary)
6998 vty_out (vty, " no-summary");
6999
7000 vty_out (vty, "%s", VTY_NEWLINE);
7001
7002 if (area->default_cost != 1)
7003 vty_out (vty, " area %s default-cost %d%s", buf,
7004 area->default_cost, VTY_NEWLINE);
7005 }
7006
7007 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7008 if (rn1->info)
7009 {
7010 struct ospf_area_range *range = rn1->info;
7011
7012 vty_out (vty, " area %s range %s/%d", buf,
7013 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7014
7015 if (range->cost_config != -1)
7016 vty_out (vty, " cost %d", range->cost_config);
7017
7018 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7019 vty_out (vty, " not-advertise");
7020
7021 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7022 vty_out (vty, " substitute %s/%d",
7023 inet_ntoa (range->subst_addr), range->subst_masklen);
7024
7025 vty_out (vty, "%s", VTY_NEWLINE);
7026 }
7027
7028 if (EXPORT_NAME (area))
7029 vty_out (vty, " area %s export-list %s%s", buf,
7030 EXPORT_NAME (area), VTY_NEWLINE);
7031
7032 if (IMPORT_NAME (area))
7033 vty_out (vty, " area %s import-list %s%s", buf,
7034 IMPORT_NAME (area), VTY_NEWLINE);
7035
7036 if (PREFIX_NAME_IN (area))
7037 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7038 PREFIX_NAME_IN (area), VTY_NEWLINE);
7039
7040 if (PREFIX_NAME_OUT (area))
7041 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7042 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7043 }
7044
7045 return 0;
7046}
7047
7048int
paul68980082003-03-25 05:07:42 +00007049config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007050{
7051 struct ospf_nbr_nbma *nbr_nbma;
7052 struct route_node *rn;
7053
7054 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007055 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007056 if ((nbr_nbma = rn->info))
7057 {
7058 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7059
7060 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7061 vty_out (vty, " priority %d", nbr_nbma->priority);
7062
7063 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7064 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7065
7066 vty_out (vty, "%s", VTY_NEWLINE);
7067 }
7068
7069 return 0;
7070}
7071
7072int
paul68980082003-03-25 05:07:42 +00007073config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007074{
7075 listnode node;
7076 u_char buf[INET_ADDRSTRLEN];
7077
7078 /* Virtual-Link print */
paul68980082003-03-25 05:07:42 +00007079 for (node = listhead (ospf->vlinks); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007080 {
7081 listnode n2;
7082 struct crypt_key *ck;
7083 struct ospf_vl_data *vl_data = getdata (node);
7084 struct ospf_interface *oi;
7085
7086 if (vl_data != NULL)
7087 {
7088 memset (buf, 0, INET_ADDRSTRLEN);
7089
7090 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7091 strncpy (buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
7092 else
7093 sprintf (buf, "%lu",
7094 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7095 oi = vl_data->vl_oi;
7096
7097 /* timers */
7098 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7099 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7100 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7101 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7102 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7103 buf,
7104 inet_ntoa (vl_data->vl_peer),
7105 OSPF_IF_PARAM (oi, v_hello),
7106 OSPF_IF_PARAM (oi, retransmit_interval),
7107 OSPF_IF_PARAM (oi, transmit_delay),
7108 OSPF_IF_PARAM (oi, v_wait),
7109 VTY_NEWLINE);
7110 else
7111 vty_out (vty, " area %s virtual-link %s%s", buf,
7112 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7113 /* Auth key */
7114 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7115 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7116 buf,
7117 inet_ntoa (vl_data->vl_peer),
7118 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7119 VTY_NEWLINE);
7120 /* md5 keys */
7121 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
7122 {
7123 ck = getdata (n2);
7124 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
7125 buf,
7126 inet_ntoa (vl_data->vl_peer),
7127 ck->key_id, ck->auth_key, VTY_NEWLINE);
7128 }
7129
7130 }
7131 }
7132
7133 return 0;
7134}
7135
7136
7137char *distribute_str[] = { "system", "kernel", "connected", "static", "rip",
hasso42ed9da2004-03-20 18:59:59 +00007138 "ripng", "ospf", "ospf6", "isis", "bgp"};
paul718e3742002-12-13 20:15:29 +00007139int
paul68980082003-03-25 05:07:42 +00007140config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007141{
7142 int type;
7143
7144 /* redistribute print. */
7145 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7146 if (type != zclient->redist_default && zclient->redist[type])
7147 {
7148 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007149 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007150 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007151
paul68980082003-03-25 05:07:42 +00007152 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007153 vty_out (vty, " metric-type 1");
7154
paul020709f2003-04-04 02:44:16 +00007155 if (ROUTEMAP_NAME (ospf, type))
7156 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007157
7158 vty_out (vty, "%s", VTY_NEWLINE);
7159 }
7160
7161 return 0;
7162}
7163
7164int
paul68980082003-03-25 05:07:42 +00007165config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007166{
paul68980082003-03-25 05:07:42 +00007167 if (ospf->default_metric != -1)
7168 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007169 VTY_NEWLINE);
7170 return 0;
7171}
7172
7173int
paul68980082003-03-25 05:07:42 +00007174config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007175{
7176 int type;
7177
paul68980082003-03-25 05:07:42 +00007178 if (ospf)
paul718e3742002-12-13 20:15:29 +00007179 {
7180 /* distribute-list print. */
7181 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007182 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007183 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007184 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007185 distribute_str[type], VTY_NEWLINE);
7186
7187 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007188 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007189 {
paul68980082003-03-25 05:07:42 +00007190 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007191 vty_out (vty, " default-information originate");
7192 else
7193 vty_out (vty, " default-information originate always");
7194
paul68980082003-03-25 05:07:42 +00007195 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007196 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007197 ospf->dmetric[DEFAULT_ROUTE].value);
7198 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007199 vty_out (vty, " metric-type 1");
7200
paul020709f2003-04-04 02:44:16 +00007201 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7202 vty_out (vty, " route-map %s",
7203 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007204
7205 vty_out (vty, "%s", VTY_NEWLINE);
7206 }
7207
7208 }
7209
7210 return 0;
7211}
7212
7213int
paul68980082003-03-25 05:07:42 +00007214config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007215{
7216 struct route_node *rn;
7217 struct ospf_distance *odistance;
7218
paul68980082003-03-25 05:07:42 +00007219 if (ospf->distance_all)
7220 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007221
paul68980082003-03-25 05:07:42 +00007222 if (ospf->distance_intra
7223 || ospf->distance_inter
7224 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007225 {
7226 vty_out (vty, " distance ospf");
7227
paul68980082003-03-25 05:07:42 +00007228 if (ospf->distance_intra)
7229 vty_out (vty, " intra-area %d", ospf->distance_intra);
7230 if (ospf->distance_inter)
7231 vty_out (vty, " inter-area %d", ospf->distance_inter);
7232 if (ospf->distance_external)
7233 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007234
7235 vty_out (vty, "%s", VTY_NEWLINE);
7236 }
7237
paul68980082003-03-25 05:07:42 +00007238 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007239 if ((odistance = rn->info) != NULL)
7240 {
7241 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7242 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7243 odistance->access_list ? odistance->access_list : "",
7244 VTY_NEWLINE);
7245 }
7246 return 0;
7247}
7248
7249/* OSPF configuration write function. */
7250int
7251ospf_config_write (struct vty *vty)
7252{
paul020709f2003-04-04 02:44:16 +00007253 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00007254 listnode node;
7255 int write = 0;
7256
paul020709f2003-04-04 02:44:16 +00007257 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007258 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007259 {
7260 /* `router ospf' print. */
7261 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7262
7263 write++;
7264
paul68980082003-03-25 05:07:42 +00007265 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007266 return write;
7267
7268 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007269 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007270 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007271 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007272
7273 /* ABR type print. */
paul68980082003-03-25 05:07:42 +00007274 if (ospf->abr_type != OSPF_ABR_STAND)
paul718e3742002-12-13 20:15:29 +00007275 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007276 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007277
7278 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007279 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007280 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7281
7282 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007283 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007284 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007285 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007286
7287 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007288 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7289 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007290 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007291 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007292
7293 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007294 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007295 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007296 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007297
7298 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007299 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007300
7301 /* passive-interface print. */
paul020709f2003-04-04 02:44:16 +00007302 for (node = listhead (om->iflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007303 {
7304 struct interface *ifp = getdata (node);
7305
7306 if (!ifp)
7307 continue;
7308 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7309 vty_out (vty, " passive-interface %s%s",
7310 ifp->name, VTY_NEWLINE);
7311 }
7312
paul68980082003-03-25 05:07:42 +00007313 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007314 {
7315 struct ospf_interface *oi = getdata (node);
7316
7317 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7318 oi->params->passive_interface == OSPF_IF_PASSIVE)
paul96735ee2003-08-10 02:51:22 +00007319 vty_out (vty, " passive-interface %s %s%s",
7320 oi->ifp->name,
paul5fdc1e52003-08-06 22:41:29 +00007321 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007322 }
7323
7324
7325 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007326 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007327
7328 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007329 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007330
7331 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007332 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007333
7334 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007335 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007336
7337 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007338 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007339
7340 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007341 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007342
7343 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007344 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007345
7346#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007347 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007348#endif /* HAVE_OPAQUE_LSA */
7349 }
7350
7351 return write;
7352}
7353
7354void
7355ospf_vty_show_init ()
7356{
7357 /* "show ip ospf" commands. */
7358 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7359 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7360
7361 /* "show ip ospf database" commands. */
7362 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7363 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7364 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7365 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7366 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7367 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7368 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7369 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7370 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7371 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7372 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7373 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7374 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7375 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7376
7377 /* "show ip ospf interface" commands. */
7378 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7379 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7380
7381 /* "show ip ospf neighbor" commands. */
7382 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7383 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7384 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7385 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7386 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7387 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7388 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7389 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7390 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7391 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7392 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7393 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7394 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7395 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7396
7397 /* "show ip ospf route" commands. */
7398 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7399 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
7400#ifdef HAVE_NSSA
7401 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7402 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
7403#endif /* HAVE_NSSA */
7404}
7405
7406
7407/* ospfd's interface node. */
7408struct cmd_node interface_node =
7409{
7410 INTERFACE_NODE,
7411 "%s(config-if)# ",
7412 1
7413};
7414
7415/* Initialization of OSPF interface. */
7416void
7417ospf_vty_if_init ()
7418{
7419 /* Install interface node. */
7420 install_node (&interface_node, config_write_interface);
7421
7422 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007423 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007424 install_default (INTERFACE_NODE);
7425
7426 /* "description" commands. */
7427 install_element (INTERFACE_NODE, &interface_desc_cmd);
7428 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7429
7430 /* "ip ospf authentication" commands. */
7431 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7432 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7433 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7434 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7435 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7436 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7437 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7438 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7439 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7440 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7441
7442 /* "ip ospf message-digest-key" commands. */
7443 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7444 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7445 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7446 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7447
7448 /* "ip ospf cost" commands. */
7449 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7450 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7451 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7452 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7453
7454 /* "ip ospf dead-interval" commands. */
7455 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7456 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7457 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7458 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7459
7460 /* "ip ospf hello-interval" commands. */
7461 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7462 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7463 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7464 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7465
7466 /* "ip ospf network" commands. */
7467 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7468 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7469
7470 /* "ip ospf priority" commands. */
7471 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7472 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7473 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7474 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7475
7476 /* "ip ospf retransmit-interval" commands. */
7477 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7478 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7479 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7480 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7481
7482 /* "ip ospf transmit-delay" commands. */
7483 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7484 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7485 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7486 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7487
7488 /* These commands are compatibitliy for previous version. */
7489 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7490 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7491 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7492 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7493 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7494 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7495 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7496 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7497 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7498 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7499 install_element (INTERFACE_NODE, &ospf_network_cmd);
7500 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7501 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7502 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7503 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7504 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7505 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7506 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7507}
7508
7509/* Zebra node structure. */
7510struct cmd_node zebra_node =
7511{
7512 ZEBRA_NODE,
7513 "%s(config-router)#",
7514};
7515
7516void
7517ospf_vty_zebra_init ()
7518{
7519 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7520 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7521 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7522 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7523 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7524 install_element (OSPF_NODE,
7525 &ospf_redistribute_source_metric_type_routemap_cmd);
7526 install_element (OSPF_NODE,
7527 &ospf_redistribute_source_type_metric_routemap_cmd);
7528 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7529 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7530 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7531
7532 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7533
7534 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7535 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7536
7537 install_element (OSPF_NODE,
7538 &ospf_default_information_originate_metric_type_cmd);
7539 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7540 install_element (OSPF_NODE,
7541 &ospf_default_information_originate_type_metric_cmd);
7542 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7543 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7544 install_element (OSPF_NODE,
7545 &ospf_default_information_originate_always_metric_type_cmd);
7546 install_element (OSPF_NODE,
7547 &ospf_default_information_originate_always_metric_cmd);
7548 install_element (OSPF_NODE,
7549 &ospf_default_information_originate_always_cmd);
7550 install_element (OSPF_NODE,
7551 &ospf_default_information_originate_always_type_metric_cmd);
7552 install_element (OSPF_NODE,
7553 &ospf_default_information_originate_always_type_cmd);
7554
7555 install_element (OSPF_NODE,
7556 &ospf_default_information_originate_metric_type_routemap_cmd);
7557 install_element (OSPF_NODE,
7558 &ospf_default_information_originate_metric_routemap_cmd);
7559 install_element (OSPF_NODE,
7560 &ospf_default_information_originate_routemap_cmd);
7561 install_element (OSPF_NODE,
7562 &ospf_default_information_originate_type_metric_routemap_cmd);
7563 install_element (OSPF_NODE,
7564 &ospf_default_information_originate_type_routemap_cmd);
7565 install_element (OSPF_NODE,
7566 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7567 install_element (OSPF_NODE,
7568 &ospf_default_information_originate_always_metric_routemap_cmd);
7569 install_element (OSPF_NODE,
7570 &ospf_default_information_originate_always_routemap_cmd);
7571 install_element (OSPF_NODE,
7572 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7573 install_element (OSPF_NODE,
7574 &ospf_default_information_originate_always_type_routemap_cmd);
7575
7576 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7577
7578 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7579 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7580 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7581
7582 install_element (OSPF_NODE, &ospf_distance_cmd);
7583 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7584 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7585 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7586 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7587 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7588 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7589 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7590 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7591 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7592 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7593 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7594 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7595 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7596 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7597 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7598 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7599 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7600#if 0
7601 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7602 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7603 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7604 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7605#endif /* 0 */
7606}
7607
7608struct cmd_node ospf_node =
7609{
7610 OSPF_NODE,
7611 "%s(config-router)# ",
7612 1
7613};
7614
7615
7616/* Install OSPF related vty commands. */
7617void
7618ospf_vty_init ()
7619{
7620 /* Install ospf top node. */
7621 install_node (&ospf_node, ospf_config_write);
7622
7623 /* "router ospf" commands. */
7624 install_element (CONFIG_NODE, &router_ospf_cmd);
7625 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7626
7627 install_default (OSPF_NODE);
7628
7629 /* "ospf router-id" commands. */
7630 install_element (OSPF_NODE, &ospf_router_id_cmd);
7631 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007632 install_element (OSPF_NODE, &router_ospf_id_cmd);
7633 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007634
7635 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007636 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7637 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7638 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7639 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007640
7641 /* "ospf abr-type" commands. */
7642 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7643 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7644
7645 /* "ospf rfc1583-compatible" commands. */
7646 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7647 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7648 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7649 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7650
7651 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007652 install_element (OSPF_NODE, &ospf_network_area_cmd);
7653 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007654
7655 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007656 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7657 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7658 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007659
7660 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007661 install_element (OSPF_NODE, &ospf_area_range_cmd);
7662 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7663 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7664 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7665 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7666 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7667 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7668 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7669 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7670 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7671 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007672
7673 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007674 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7675 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007676
paula2c62832003-04-23 17:01:31 +00007677 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7678 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007679
paula2c62832003-04-23 17:01:31 +00007680 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7681 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007682
paula2c62832003-04-23 17:01:31 +00007683 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7684 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007685
paula2c62832003-04-23 17:01:31 +00007686 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7687 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007688
paula2c62832003-04-23 17:01:31 +00007689 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7690 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7691 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007692
paula2c62832003-04-23 17:01:31 +00007693 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7694 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007695
paula2c62832003-04-23 17:01:31 +00007696 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7697 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007698
paula2c62832003-04-23 17:01:31 +00007699 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7700 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7701 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007702
paula2c62832003-04-23 17:01:31 +00007703 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7704 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7705 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007706
7707 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007708 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7709 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7710 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7711 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007712
7713#ifdef HAVE_NSSA
7714 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007715 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7716 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7717 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7718 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7719 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7720 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007721#endif /* HAVE_NSSA */
7722
paula2c62832003-04-23 17:01:31 +00007723 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7724 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007725
paula2c62832003-04-23 17:01:31 +00007726 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7727 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007728
paula2c62832003-04-23 17:01:31 +00007729 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7730 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007731
paula2c62832003-04-23 17:01:31 +00007732 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7733 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007734
paula2c62832003-04-23 17:01:31 +00007735 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7736 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007737
paula2c62832003-04-23 17:01:31 +00007738 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7739 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007740
paula2c62832003-04-23 17:01:31 +00007741 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7742 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7743 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007744
paula2c62832003-04-23 17:01:31 +00007745 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7746 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007747
7748 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007749 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7750 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7751 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7752 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7753 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7754 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7755 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7756 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007757
7758 /* Init interface related vty commands. */
7759 ospf_vty_if_init ();
7760
7761 /* Init zebra related vty commands. */
7762 ospf_vty_zebra_init ();
7763}