blob: 74361bcb6f091c6be9a5e01590c7bb0e3bf79fb8 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* OSPF VTY interface.
vincentba682532005-09-29 13:52:57 +00002 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
paul718e3742002-12-13 20:15:29 +00003 * Copyright (C) 2000 Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23#include <zebra.h>
24
25#include "memory.h"
26#include "thread.h"
27#include "prefix.h"
28#include "table.h"
29#include "vty.h"
30#include "command.h"
31#include "plist.h"
32#include "log.h"
33#include "zclient.h"
34
35#include "ospfd/ospfd.h"
36#include "ospfd/ospf_asbr.h"
37#include "ospfd/ospf_lsa.h"
38#include "ospfd/ospf_lsdb.h"
39#include "ospfd/ospf_ism.h"
40#include "ospfd/ospf_interface.h"
41#include "ospfd/ospf_nsm.h"
42#include "ospfd/ospf_neighbor.h"
43#include "ospfd/ospf_flood.h"
44#include "ospfd/ospf_abr.h"
45#include "ospfd/ospf_spf.h"
46#include "ospfd/ospf_route.h"
47#include "ospfd/ospf_zebra.h"
48/*#include "ospfd/ospf_routemap.h" */
49#include "ospfd/ospf_vty.h"
50#include "ospfd/ospf_dump.h"
51
52
hassoeb1ce602004-10-08 08:17:22 +000053const static char *ospf_network_type_str[] =
paul718e3742002-12-13 20:15:29 +000054{
55 "Null",
56 "POINTOPOINT",
57 "BROADCAST",
58 "NBMA",
59 "POINTOMULTIPOINT",
60 "VIRTUALLINK",
61 "LOOPBACK"
62};
63
64
65/* Utility functions. */
paul4dadc292005-05-06 21:37:42 +000066static int
paul6c835672004-10-11 11:00:30 +000067ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
paul718e3742002-12-13 20:15:29 +000068{
69 char *endptr = NULL;
70 unsigned long ret;
71
72 /* match "A.B.C.D". */
73 if (strchr (str, '.') != NULL)
74 {
75 ret = inet_aton (str, area_id);
76 if (!ret)
77 return -1;
78 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
79 }
80 /* match "<0-4294967295>". */
81 else
82 {
83 ret = strtoul (str, &endptr, 10);
84 if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE))
85 return -1;
86
87 area_id->s_addr = htonl (ret);
88 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
89 }
90
91 return 0;
92}
93
94
paul4dadc292005-05-06 21:37:42 +000095static int
paul6c835672004-10-11 11:00:30 +000096str2distribute_source (const char *str, int *source)
paul718e3742002-12-13 20:15:29 +000097{
98 /* Sanity check. */
99 if (str == NULL)
100 return 0;
101
102 if (strncmp (str, "k", 1) == 0)
103 *source = ZEBRA_ROUTE_KERNEL;
104 else if (strncmp (str, "c", 1) == 0)
105 *source = ZEBRA_ROUTE_CONNECT;
106 else if (strncmp (str, "s", 1) == 0)
107 *source = ZEBRA_ROUTE_STATIC;
108 else if (strncmp (str, "r", 1) == 0)
109 *source = ZEBRA_ROUTE_RIP;
110 else if (strncmp (str, "b", 1) == 0)
111 *source = ZEBRA_ROUTE_BGP;
112 else
113 return 0;
114
115 return 1;
116}
117
paul4dadc292005-05-06 21:37:42 +0000118static int
paul6c835672004-10-11 11:00:30 +0000119str2metric (const char *str, int *metric)
paul718e3742002-12-13 20:15:29 +0000120{
121 /* Sanity check. */
122 if (str == NULL)
123 return 0;
124
125 *metric = strtol (str, NULL, 10);
126 if (*metric < 0 && *metric > 16777214)
127 {
128 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
129 return 0;
130 }
131
132 return 1;
133}
134
paul4dadc292005-05-06 21:37:42 +0000135static int
paul6c835672004-10-11 11:00:30 +0000136str2metric_type (const char *str, int *metric_type)
paul718e3742002-12-13 20:15:29 +0000137{
138 /* Sanity check. */
139 if (str == NULL)
140 return 0;
141
142 if (strncmp (str, "1", 1) == 0)
143 *metric_type = EXTERNAL_METRIC_TYPE_1;
144 else if (strncmp (str, "2", 1) == 0)
145 *metric_type = EXTERNAL_METRIC_TYPE_2;
146 else
147 return 0;
148
149 return 1;
150}
151
152int
153ospf_oi_count (struct interface *ifp)
154{
155 struct route_node *rn;
156 int i = 0;
157
158 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
159 if (rn->info)
160 i++;
161
162 return i;
163}
164
165
166DEFUN (router_ospf,
167 router_ospf_cmd,
168 "router ospf",
169 "Enable a routing process\n"
170 "Start OSPF configuration\n")
171{
172 vty->node = OSPF_NODE;
173 vty->index = ospf_get ();
174
175 return CMD_SUCCESS;
176}
177
178DEFUN (no_router_ospf,
179 no_router_ospf_cmd,
180 "no router ospf",
181 NO_STR
182 "Enable a routing process\n"
183 "Start OSPF configuration\n")
184{
paul020709f2003-04-04 02:44:16 +0000185 struct ospf *ospf;
186
187 ospf = ospf_lookup ();
188 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000189 {
paul020709f2003-04-04 02:44:16 +0000190 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000191 return CMD_WARNING;
192 }
193
paul020709f2003-04-04 02:44:16 +0000194 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000195
196 return CMD_SUCCESS;
197}
198
199DEFUN (ospf_router_id,
200 ospf_router_id_cmd,
201 "ospf router-id A.B.C.D",
202 "OSPF specific commands\n"
203 "router-id for the OSPF process\n"
204 "OSPF router-id in IP address format\n")
205{
paul68980082003-03-25 05:07:42 +0000206 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000207 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000208 int ret;
paul718e3742002-12-13 20:15:29 +0000209
210 ret = inet_aton (argv[0], &router_id);
211 if (!ret)
212 {
213 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
214 return CMD_WARNING;
215 }
216
paul68980082003-03-25 05:07:42 +0000217 ospf->router_id_static = router_id;
paulb29800a2005-11-20 14:50:45 +0000218
219 ospf_router_id_update (ospf);
220
paul718e3742002-12-13 20:15:29 +0000221 return CMD_SUCCESS;
222}
223
224ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000225 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000226 "router-id A.B.C.D",
227 "router-id for the OSPF process\n"
228 "OSPF router-id in IP address format\n")
229
230DEFUN (no_ospf_router_id,
231 no_ospf_router_id_cmd,
232 "no ospf router-id",
233 NO_STR
234 "OSPF specific commands\n"
235 "router-id for the OSPF process\n")
236{
paul68980082003-03-25 05:07:42 +0000237 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000238
paul68980082003-03-25 05:07:42 +0000239 ospf->router_id_static.s_addr = 0;
240
241 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000242
243 return CMD_SUCCESS;
244}
245
246ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000247 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000248 "no router-id",
249 NO_STR
250 "router-id for the OSPF process\n")
251
paula2c62832003-04-23 17:01:31 +0000252DEFUN (ospf_passive_interface,
253 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000254 "passive-interface IFNAME A.B.C.D",
255 "Suppress routing updates on an interface\n"
256 "Interface's name\n")
257{
258 struct interface *ifp;
259 struct in_addr addr;
260 int ret;
261 struct ospf_if_params *params;
ajsba6454e2005-02-08 15:37:30 +0000262 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000263
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;
ajsba6454e2005-02-08 15:37:30 +0000290
291 /* XXX We should call ospf_if_set_multicast on exactly those
292 * interfaces for which the passive property changed. It is too much
293 * work to determine this set, so we do this for every interface.
294 * This is safe and reasonable because ospf_if_set_multicast uses a
295 * record of joined groups to avoid systems calls if the desired
296 * memberships match the current memership.
297 */
298 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
299 {
300 struct ospf_interface *oi = rn->info;
301
302 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
303 ospf_if_set_multicast(oi);
304 }
305 /*
306 * XXX It is not clear what state transitions the interface needs to
307 * undergo when going from active to passive. Fixing this will
308 * require precise identification of interfaces having such a
309 * transition.
310 */
311
paul718e3742002-12-13 20:15:29 +0000312 return CMD_SUCCESS;
313}
314
paula2c62832003-04-23 17:01:31 +0000315ALIAS (ospf_passive_interface,
316 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000317 "passive-interface IFNAME",
318 "Suppress routing updates on an interface\n"
319 "Interface's name\n")
320
paula2c62832003-04-23 17:01:31 +0000321DEFUN (no_ospf_passive_interface,
322 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000323 "no passive-interface IFNAME A.B.C.D",
324 NO_STR
325 "Allow routing updates on an interface\n"
326 "Interface's name\n")
327{
328 struct interface *ifp;
329 struct in_addr addr;
330 struct ospf_if_params *params;
331 int ret;
ajsba6454e2005-02-08 15:37:30 +0000332 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000333
334 ifp = if_lookup_by_name (argv[0]);
335
336 if (ifp == NULL)
337 {
338 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
339 return CMD_WARNING;
340 }
341
342 params = IF_DEF_PARAMS (ifp);
343
344 if (argc == 2)
345 {
346 ret = inet_aton(argv[1], &addr);
347 if (!ret)
348 {
349 vty_out (vty, "Please specify interface address by A.B.C.D%s",
350 VTY_NEWLINE);
351 return CMD_WARNING;
352 }
353
354 params = ospf_lookup_if_params (ifp, addr);
355 if (params == NULL)
356 return CMD_SUCCESS;
357 }
358
359 UNSET_IF_PARAM (params, passive_interface);
360 params->passive_interface = OSPF_IF_ACTIVE;
361
362 if (params != IF_DEF_PARAMS (ifp))
363 {
364 ospf_free_if_params (ifp, addr);
365 ospf_if_update_params (ifp, addr);
366 }
ajsba6454e2005-02-08 15:37:30 +0000367
368 /* XXX We should call ospf_if_set_multicast on exactly those
369 * interfaces for which the passive property changed. It is too much
370 * work to determine this set, so we do this for every interface.
371 * This is safe and reasonable because ospf_if_set_multicast uses a
372 * record of joined groups to avoid systems calls if the desired
373 * memberships match the current memership.
374 */
375 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
376 {
377 struct ospf_interface *oi = rn->info;
378
379 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
380 ospf_if_set_multicast(oi);
381 }
382
paul718e3742002-12-13 20:15:29 +0000383 return CMD_SUCCESS;
384}
385
paula2c62832003-04-23 17:01:31 +0000386ALIAS (no_ospf_passive_interface,
387 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000388 "no passive-interface IFNAME",
389 NO_STR
390 "Allow routing updates on an interface\n"
391 "Interface's name\n")
392
paula2c62832003-04-23 17:01:31 +0000393DEFUN (ospf_network_area,
394 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000395 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
396 "Enable routing on an IP network\n"
397 "OSPF network prefix\n"
398 "Set the OSPF area ID\n"
399 "OSPF area ID in IP address format\n"
400 "OSPF area ID as a decimal value\n")
401{
402 struct ospf *ospf= vty->index;
403 struct prefix_ipv4 p;
404 struct in_addr area_id;
405 int ret, format;
406
407 /* Get network prefix and Area ID. */
408 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
409 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
410
411 ret = ospf_network_set (ospf, &p, area_id);
412 if (ret == 0)
413 {
414 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
415 return CMD_WARNING;
416 }
417
418 return CMD_SUCCESS;
419}
420
paula2c62832003-04-23 17:01:31 +0000421DEFUN (no_ospf_network_area,
422 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000423 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
424 NO_STR
425 "Enable routing on an IP network\n"
426 "OSPF network prefix\n"
427 "Set the OSPF area ID\n"
428 "OSPF area ID in IP address format\n"
429 "OSPF area ID as a decimal value\n")
430{
431 struct ospf *ospf = (struct ospf *) vty->index;
432 struct prefix_ipv4 p;
433 struct in_addr area_id;
434 int ret, format;
435
436 /* Get network prefix and Area ID. */
437 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
438 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
439
440 ret = ospf_network_unset (ospf, &p, area_id);
441 if (ret == 0)
442 {
443 vty_out (vty, "Can't find specified network area configuration.%s",
444 VTY_NEWLINE);
445 return CMD_WARNING;
446 }
447
448 return CMD_SUCCESS;
449}
450
451
paula2c62832003-04-23 17:01:31 +0000452DEFUN (ospf_area_range,
453 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000454 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
455 "OSPF area parameters\n"
456 "OSPF area ID in IP address format\n"
457 "OSPF area ID as a decimal value\n"
458 "Summarize routes matching address/mask (border routers only)\n"
459 "Area range prefix\n")
460{
461 struct ospf *ospf = vty->index;
462 struct prefix_ipv4 p;
463 struct in_addr area_id;
464 int format;
465 u_int32_t cost;
466
467 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
468 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
469
470 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
471 if (argc > 2)
472 {
paul4dadc292005-05-06 21:37:42 +0000473 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000474 ospf_area_range_cost_set (ospf, area_id, &p, cost);
475 }
476
477 return CMD_SUCCESS;
478}
479
paula2c62832003-04-23 17:01:31 +0000480ALIAS (ospf_area_range,
481 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000482 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
483 "OSPF area parameters\n"
484 "OSPF area ID in IP address format\n"
485 "OSPF area ID as a decimal value\n"
486 "OSPF area range for route advertise (default)\n"
487 "Area range prefix\n"
488 "Advertise this range (default)\n")
489
paula2c62832003-04-23 17:01:31 +0000490ALIAS (ospf_area_range,
491 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000492 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
493 "OSPF area parameters\n"
494 "OSPF area ID in IP address format\n"
495 "OSPF area ID as a decimal value\n"
496 "Summarize routes matching address/mask (border routers only)\n"
497 "Area range prefix\n"
498 "User specified metric for this range\n"
499 "Advertised metric for this range\n")
500
paula2c62832003-04-23 17:01:31 +0000501ALIAS (ospf_area_range,
502 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000503 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
504 "OSPF area parameters\n"
505 "OSPF area ID in IP address format\n"
506 "OSPF area ID as a decimal value\n"
507 "Summarize routes matching address/mask (border routers only)\n"
508 "Area range prefix\n"
509 "Advertise this range (default)\n"
510 "User specified metric for this range\n"
511 "Advertised metric for this range\n")
512
paula2c62832003-04-23 17:01:31 +0000513DEFUN (ospf_area_range_not_advertise,
514 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000515 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
516 "OSPF area parameters\n"
517 "OSPF area ID in IP address format\n"
518 "OSPF area ID as a decimal value\n"
519 "Summarize routes matching address/mask (border routers only)\n"
520 "Area range prefix\n"
521 "DoNotAdvertise this range\n")
522{
523 struct ospf *ospf = vty->index;
524 struct prefix_ipv4 p;
525 struct in_addr area_id;
526 int format;
527
528 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
529 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
530
531 ospf_area_range_set (ospf, area_id, &p, 0);
532
533 return CMD_SUCCESS;
534}
535
paula2c62832003-04-23 17:01:31 +0000536DEFUN (no_ospf_area_range,
537 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000538 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
539 NO_STR
540 "OSPF area parameters\n"
541 "OSPF area ID in IP address format\n"
542 "OSPF area ID as a decimal value\n"
543 "Summarize routes matching address/mask (border routers only)\n"
544 "Area range prefix\n")
545{
546 struct ospf *ospf = vty->index;
547 struct prefix_ipv4 p;
548 struct in_addr area_id;
549 int format;
550
551 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
552 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
553
554 ospf_area_range_unset (ospf, area_id, &p);
555
556 return CMD_SUCCESS;
557}
558
paula2c62832003-04-23 17:01:31 +0000559ALIAS (no_ospf_area_range,
560 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000561 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
562 NO_STR
563 "OSPF area parameters\n"
564 "OSPF area ID in IP address format\n"
565 "OSPF area ID as a decimal value\n"
566 "Summarize routes matching address/mask (border routers only)\n"
567 "Area range prefix\n"
568 "Advertise this range (default)\n"
569 "DoNotAdvertise this range\n")
570
paula2c62832003-04-23 17:01:31 +0000571ALIAS (no_ospf_area_range,
572 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000573 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
574 NO_STR
575 "OSPF area parameters\n"
576 "OSPF area ID in IP address format\n"
577 "OSPF area ID as a decimal value\n"
578 "Summarize routes matching address/mask (border routers only)\n"
579 "Area range prefix\n"
580 "User specified metric for this range\n"
581 "Advertised metric for this range\n")
582
paula2c62832003-04-23 17:01:31 +0000583ALIAS (no_ospf_area_range,
584 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000585 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
586 NO_STR
587 "OSPF area parameters\n"
588 "OSPF area ID in IP address format\n"
589 "OSPF area ID as a decimal value\n"
590 "Summarize routes matching address/mask (border routers only)\n"
591 "Area range prefix\n"
592 "Advertise this range (default)\n"
593 "User specified metric for this range\n"
594 "Advertised metric for this range\n")
595
paula2c62832003-04-23 17:01:31 +0000596DEFUN (ospf_area_range_substitute,
597 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000598 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
599 "OSPF area parameters\n"
600 "OSPF area ID in IP address format\n"
601 "OSPF area ID as a decimal value\n"
602 "Summarize routes matching address/mask (border routers only)\n"
603 "Area range prefix\n"
604 "Announce area range as another prefix\n"
605 "Network prefix to be announced instead of range\n")
606{
607 struct ospf *ospf = vty->index;
608 struct prefix_ipv4 p, s;
609 struct in_addr area_id;
610 int format;
611
612 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
613 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
614 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
615
616 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
617
618 return CMD_SUCCESS;
619}
620
paula2c62832003-04-23 17:01:31 +0000621DEFUN (no_ospf_area_range_substitute,
622 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000623 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
624 NO_STR
625 "OSPF area parameters\n"
626 "OSPF area ID in IP address format\n"
627 "OSPF area ID as a decimal value\n"
628 "Summarize routes matching address/mask (border routers only)\n"
629 "Area range prefix\n"
630 "Announce area range as another prefix\n"
631 "Network prefix to be announced instead of range\n")
632{
633 struct ospf *ospf = vty->index;
634 struct prefix_ipv4 p, s;
635 struct in_addr area_id;
636 int format;
637
638 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
639 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
640 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
641
642 ospf_area_range_substitute_unset (ospf, area_id, &p);
643
644 return CMD_SUCCESS;
645}
646
647
648/* Command Handler Logic in VLink stuff is delicate!!
649
650 ALTER AT YOUR OWN RISK!!!!
651
652 Various dummy values are used to represent 'NoChange' state for
653 VLink configuration NOT being changed by a VLink command, and
654 special syntax is used within the command strings so that the
655 typed in command verbs can be seen in the configuration command
656 bacckend handler. This is to drastically reduce the verbeage
657 required to coe up with a reasonably compatible Cisco VLink command
658
659 - Matthew Grant <grantma@anathoth.gen.nz>
660 Wed, 21 Feb 2001 15:13:52 +1300
661 */
662
663
664/* Configuration data for virtual links
665 */
666struct ospf_vl_config_data {
667 struct vty *vty; /* vty stuff */
668 struct in_addr area_id; /* area ID from command line */
669 int format; /* command line area ID format */
670 struct in_addr vl_peer; /* command line vl_peer */
671 int auth_type; /* Authehntication type, if given */
672 char *auth_key; /* simple password if present */
673 int crypto_key_id; /* Cryptographic key ID */
674 char *md5_key; /* MD5 authentication key */
675 int hello_interval; /* Obvious what these are... */
676 int retransmit_interval;
677 int transmit_delay;
678 int dead_interval;
679};
680
paul4dadc292005-05-06 21:37:42 +0000681static void
paul718e3742002-12-13 20:15:29 +0000682ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
683 struct vty *vty)
684{
685 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
686 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
687 vl_config->vty = vty;
688}
689
paul4dadc292005-05-06 21:37:42 +0000690static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000691ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000692{
693 struct ospf_area *area;
694 struct ospf_vl_data *vl_data;
695 struct vty *vty;
696 struct in_addr area_id;
697
698 vty = vl_config->vty;
699 area_id = vl_config->area_id;
700
701 if (area_id.s_addr == OSPF_AREA_BACKBONE)
702 {
703 vty_out (vty,
704 "Configuring VLs over the backbone is not allowed%s",
705 VTY_NEWLINE);
706 return NULL;
707 }
paul68980082003-03-25 05:07:42 +0000708 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000709
710 if (area->external_routing != OSPF_AREA_DEFAULT)
711 {
712 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
713 vty_out (vty, "Area %s is %s%s",
714 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000715 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000716 VTY_NEWLINE);
717 else
718 vty_out (vty, "Area %ld is %s%s",
719 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000720 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000721 VTY_NEWLINE);
722 return NULL;
723 }
724
Paul Jakma9c27ef92006-05-04 07:32:57 +0000725 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
paul718e3742002-12-13 20:15:29 +0000726 {
727 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
728 if (vl_data->vl_oi == NULL)
729 {
paul68980082003-03-25 05:07:42 +0000730 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
731 ospf_vl_add (ospf, vl_data);
732 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000733 }
734 }
735 return vl_data;
736}
737
738
paul4dadc292005-05-06 21:37:42 +0000739static int
paul718e3742002-12-13 20:15:29 +0000740ospf_vl_set_security (struct ospf_vl_data *vl_data,
741 struct ospf_vl_config_data *vl_config)
742{
743 struct crypt_key *ck;
744 struct vty *vty;
745 struct interface *ifp = vl_data->vl_oi->ifp;
746
747 vty = vl_config->vty;
748
749 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
750 {
751 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
752 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
753 }
754
755 if (vl_config->auth_key)
756 {
757 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000758 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000759 OSPF_AUTH_SIMPLE_SIZE);
760 }
761 else if (vl_config->md5_key)
762 {
763 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
764 != NULL)
765 {
766 vty_out (vty, "OSPF: Key %d already exists%s",
767 vl_config->crypto_key_id, VTY_NEWLINE);
768 return CMD_WARNING;
769 }
770 ck = ospf_crypt_key_new ();
771 ck->key_id = vl_config->crypto_key_id;
772 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000773 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000774
775 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
776 }
777 else if (vl_config->crypto_key_id != 0)
778 {
779 /* Delete a key */
780
781 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
782 vl_config->crypto_key_id) == NULL)
783 {
784 vty_out (vty, "OSPF: Key %d does not exist%s",
785 vl_config->crypto_key_id, VTY_NEWLINE);
786 return CMD_WARNING;
787 }
788
789 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
790
791 }
792
793 return CMD_SUCCESS;
794}
795
paul4dadc292005-05-06 21:37:42 +0000796static int
paul718e3742002-12-13 20:15:29 +0000797ospf_vl_set_timers (struct ospf_vl_data *vl_data,
798 struct ospf_vl_config_data *vl_config)
799{
800 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
801 /* Virtual Link data initialised to defaults, so only set
802 if a value given */
803 if (vl_config->hello_interval)
804 {
805 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
806 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
807 }
808
809 if (vl_config->dead_interval)
810 {
811 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
812 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
813 }
814
815 if (vl_config->retransmit_interval)
816 {
817 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
818 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
819 }
820
821 if (vl_config->transmit_delay)
822 {
823 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
824 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
825 }
826
827 return CMD_SUCCESS;
828}
829
830
831
832/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000833static int
paul68980082003-03-25 05:07:42 +0000834ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000835{
836 struct ospf_vl_data *vl_data;
837 int ret;
838
paul68980082003-03-25 05:07:42 +0000839 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000840 if (!vl_data)
841 return CMD_WARNING;
842
843 /* Process this one first as it can have a fatal result, which can
844 only logically occur if the virtual link exists already
845 Thus a command error does not result in a change to the
846 running configuration such as unexpectedly altered timer
847 values etc.*/
848 ret = ospf_vl_set_security (vl_data, vl_config);
849 if (ret != CMD_SUCCESS)
850 return ret;
851
852 /* Set any time based parameters, these area already range checked */
853
854 ret = ospf_vl_set_timers (vl_data, vl_config);
855 if (ret != CMD_SUCCESS)
856 return ret;
857
858 return CMD_SUCCESS;
859
860}
861
862/* This stuff exists to make specifying all the alias commands A LOT simpler
863 */
864#define VLINK_HELPSTR_IPADDR \
865 "OSPF area parameters\n" \
866 "OSPF area ID in IP address format\n" \
867 "OSPF area ID as a decimal value\n" \
868 "Configure a virtual link\n" \
869 "Router ID of the remote ABR\n"
870
871#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
872 "Enable authentication on this virtual link\n" \
873 "dummy string \n"
874
875#define VLINK_HELPSTR_AUTHTYPE_ALL \
876 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
877 "Use null authentication\n" \
878 "Use message-digest authentication\n"
879
880#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
881 "Time between HELLO packets\n" \
882 "Time between retransmitting lost link state advertisements\n" \
883 "Link state transmit delay\n" \
884 "Interval after which a neighbor is declared dead\n"
885
886#define VLINK_HELPSTR_TIME_PARAM \
887 VLINK_HELPSTR_TIME_PARAM_NOSECS \
888 "Seconds\n"
889
890#define VLINK_HELPSTR_AUTH_SIMPLE \
891 "Authentication password (key)\n" \
892 "The OSPF password (key)"
893
894#define VLINK_HELPSTR_AUTH_MD5 \
895 "Message digest authentication password (key)\n" \
896 "dummy string \n" \
897 "Key ID\n" \
898 "Use MD5 algorithm\n" \
899 "The OSPF password (key)"
900
paula2c62832003-04-23 17:01:31 +0000901DEFUN (ospf_area_vlink,
902 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000903 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
904 VLINK_HELPSTR_IPADDR)
905{
paul68980082003-03-25 05:07:42 +0000906 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000907 struct ospf_vl_config_data vl_config;
908 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
909 char md5_key[OSPF_AUTH_MD5_SIZE+1];
910 int i;
911 int ret;
912
913 ospf_vl_config_data_init(&vl_config, vty);
914
915 /* Read off first 2 parameters and check them */
916 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
917 if (ret < 0)
918 {
919 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
920 return CMD_WARNING;
921 }
922
923 ret = inet_aton (argv[1], &vl_config.vl_peer);
924 if (! ret)
925 {
926 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
927 VTY_NEWLINE);
928 return CMD_WARNING;
929 }
930
931 if (argc <=2)
932 {
933 /* Thats all folks! - BUGS B. strikes again!!!*/
934
paul68980082003-03-25 05:07:42 +0000935 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000936 }
937
938 /* Deal with other parameters */
939 for (i=2; i < argc; i++)
940 {
941
942 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
943
944 switch (argv[i][0])
945 {
946
947 case 'a':
948 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
949 {
950 /* authentication-key - this option can occur anywhere on
951 command line. At start of command line
952 must check for authentication option. */
953 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
954 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
955 vl_config.auth_key = auth_key;
956 i++;
957 }
958 else if (strncmp (argv[i], "authentication", 14) == 0)
959 {
960 /* authentication - this option can only occur at start
961 of command line */
962 vl_config.auth_type = OSPF_AUTH_SIMPLE;
963 if ((i+1) < argc)
964 {
965 if (strncmp (argv[i+1], "n", 1) == 0)
966 {
967 /* "authentication null" */
968 vl_config.auth_type = OSPF_AUTH_NULL;
969 i++;
970 }
971 else if (strncmp (argv[i+1], "m", 1) == 0
972 && strcmp (argv[i+1], "message-digest-") != 0)
973 {
974 /* "authentication message-digest" */
975 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
976 i++;
977 }
978 }
979 }
980 break;
981
982 case 'm':
983 /* message-digest-key */
984 i++;
985 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
986 if (vl_config.crypto_key_id < 0)
987 return CMD_WARNING;
988 i++;
989 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
990 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
991 vl_config.md5_key = md5_key;
992 break;
993
994 case 'h':
995 /* Hello interval */
996 i++;
997 vl_config.hello_interval = strtol (argv[i], NULL, 10);
998 if (vl_config.hello_interval < 0)
999 return CMD_WARNING;
1000 break;
1001
1002 case 'r':
1003 /* Retransmit Interval */
1004 i++;
1005 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1006 if (vl_config.retransmit_interval < 0)
1007 return CMD_WARNING;
1008 break;
1009
1010 case 't':
1011 /* Transmit Delay */
1012 i++;
1013 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1014 if (vl_config.transmit_delay < 0)
1015 return CMD_WARNING;
1016 break;
1017
1018 case 'd':
1019 /* Dead Interval */
1020 i++;
1021 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1022 if (vl_config.dead_interval < 0)
1023 return CMD_WARNING;
1024 break;
1025 }
1026 }
1027
1028
1029 /* Action configuration */
1030
paul68980082003-03-25 05:07:42 +00001031 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001032
1033}
1034
paula2c62832003-04-23 17:01:31 +00001035DEFUN (no_ospf_area_vlink,
1036 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001037 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1038 NO_STR
1039 VLINK_HELPSTR_IPADDR)
1040{
paul68980082003-03-25 05:07:42 +00001041 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001042 struct ospf_area *area;
1043 struct ospf_vl_config_data vl_config;
1044 struct ospf_vl_data *vl_data = NULL;
1045 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1046 int i;
1047 int ret, format;
1048
1049 ospf_vl_config_data_init(&vl_config, vty);
1050
1051 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1052 if (ret < 0)
1053 {
1054 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1055 return CMD_WARNING;
1056 }
1057
paul68980082003-03-25 05:07:42 +00001058 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001059 if (!area)
1060 {
1061 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1062 return CMD_WARNING;
1063 }
1064
1065 ret = inet_aton (argv[1], &vl_config.vl_peer);
1066 if (! ret)
1067 {
1068 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1069 VTY_NEWLINE);
1070 return CMD_WARNING;
1071 }
1072
1073 if (argc <=2)
1074 {
1075 /* Basic VLink no command */
1076 /* Thats all folks! - BUGS B. strikes again!!!*/
Paul Jakma9c27ef92006-05-04 07:32:57 +00001077 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001078 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001079
paul68980082003-03-25 05:07:42 +00001080 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001081
1082 return CMD_SUCCESS;
1083 }
1084
1085 /* If we are down here, we are reseting parameters */
1086
1087 /* Deal with other parameters */
1088 for (i=2; i < argc; i++)
1089 {
paul718e3742002-12-13 20:15:29 +00001090 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1091
1092 switch (argv[i][0])
1093 {
1094
1095 case 'a':
1096 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1097 {
1098 /* authentication-key - this option can occur anywhere on
1099 command line. At start of command line
1100 must check for authentication option. */
1101 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1102 vl_config.auth_key = auth_key;
1103 }
1104 else if (strncmp (argv[i], "authentication", 14) == 0)
1105 {
1106 /* authentication - this option can only occur at start
1107 of command line */
1108 vl_config.auth_type = OSPF_AUTH_NOTSET;
1109 }
1110 break;
1111
1112 case 'm':
1113 /* message-digest-key */
1114 /* Delete one key */
1115 i++;
1116 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1117 if (vl_config.crypto_key_id < 0)
1118 return CMD_WARNING;
1119 vl_config.md5_key = NULL;
1120 break;
1121
1122 case 'h':
1123 /* Hello interval */
1124 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1125 break;
1126
1127 case 'r':
1128 /* Retransmit Interval */
1129 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1130 break;
1131
1132 case 't':
1133 /* Transmit Delay */
1134 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1135 break;
1136
1137 case 'd':
1138 /* Dead Interval */
1139 i++;
1140 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1141 break;
1142 }
1143 }
1144
1145
1146 /* Action configuration */
1147
paul68980082003-03-25 05:07:42 +00001148 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001149}
1150
paula2c62832003-04-23 17:01:31 +00001151ALIAS (ospf_area_vlink,
1152 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001153 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1154 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1155 VLINK_HELPSTR_IPADDR
1156 VLINK_HELPSTR_TIME_PARAM)
1157
paula2c62832003-04-23 17:01:31 +00001158ALIAS (no_ospf_area_vlink,
1159 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001160 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1161 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1162 NO_STR
1163 VLINK_HELPSTR_IPADDR
1164 VLINK_HELPSTR_TIME_PARAM)
1165
paula2c62832003-04-23 17:01:31 +00001166ALIAS (ospf_area_vlink,
1167 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001168 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1169 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1170 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1171 VLINK_HELPSTR_IPADDR
1172 VLINK_HELPSTR_TIME_PARAM
1173 VLINK_HELPSTR_TIME_PARAM)
1174
paula2c62832003-04-23 17:01:31 +00001175ALIAS (no_ospf_area_vlink,
1176 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001177 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1178 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1179 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1180 NO_STR
1181 VLINK_HELPSTR_IPADDR
1182 VLINK_HELPSTR_TIME_PARAM
1183 VLINK_HELPSTR_TIME_PARAM)
1184
paula2c62832003-04-23 17:01:31 +00001185ALIAS (ospf_area_vlink,
1186 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001187 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1188 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1189 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1190 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1191 VLINK_HELPSTR_IPADDR
1192 VLINK_HELPSTR_TIME_PARAM
1193 VLINK_HELPSTR_TIME_PARAM
1194 VLINK_HELPSTR_TIME_PARAM)
1195
paula2c62832003-04-23 17:01:31 +00001196ALIAS (no_ospf_area_vlink,
1197 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001198 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1199 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1200 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1201 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1202 NO_STR
1203 VLINK_HELPSTR_IPADDR
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_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001210 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1211 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1212 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1213 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1214 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1215 VLINK_HELPSTR_IPADDR
1216 VLINK_HELPSTR_TIME_PARAM
1217 VLINK_HELPSTR_TIME_PARAM
1218 VLINK_HELPSTR_TIME_PARAM
1219 VLINK_HELPSTR_TIME_PARAM)
1220
paula2c62832003-04-23 17:01:31 +00001221ALIAS (no_ospf_area_vlink,
1222 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001223 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1224 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1225 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1226 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1227 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1228 NO_STR
1229 VLINK_HELPSTR_IPADDR
1230 VLINK_HELPSTR_TIME_PARAM
1231 VLINK_HELPSTR_TIME_PARAM
1232 VLINK_HELPSTR_TIME_PARAM
1233 VLINK_HELPSTR_TIME_PARAM)
1234
paula2c62832003-04-23 17:01:31 +00001235ALIAS (ospf_area_vlink,
1236 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001237 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1238 "(authentication|) (message-digest|null)",
1239 VLINK_HELPSTR_IPADDR
1240 VLINK_HELPSTR_AUTHTYPE_ALL)
1241
paula2c62832003-04-23 17:01:31 +00001242ALIAS (ospf_area_vlink,
1243 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001244 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1245 "(authentication|)",
1246 VLINK_HELPSTR_IPADDR
1247 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1248
paula2c62832003-04-23 17:01:31 +00001249ALIAS (no_ospf_area_vlink,
1250 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001251 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1252 "(authentication|)",
1253 NO_STR
1254 VLINK_HELPSTR_IPADDR
1255 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1256
paula2c62832003-04-23 17:01:31 +00001257ALIAS (ospf_area_vlink,
1258 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001259 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1260 "(message-digest-key|) <1-255> md5 KEY",
1261 VLINK_HELPSTR_IPADDR
1262 VLINK_HELPSTR_AUTH_MD5)
1263
paula2c62832003-04-23 17:01:31 +00001264ALIAS (no_ospf_area_vlink,
1265 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001266 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1267 "(message-digest-key|) <1-255>",
1268 NO_STR
1269 VLINK_HELPSTR_IPADDR
1270 VLINK_HELPSTR_AUTH_MD5)
1271
paula2c62832003-04-23 17:01:31 +00001272ALIAS (ospf_area_vlink,
1273 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001274 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1275 "(authentication-key|) AUTH_KEY",
1276 VLINK_HELPSTR_IPADDR
1277 VLINK_HELPSTR_AUTH_SIMPLE)
1278
paula2c62832003-04-23 17:01:31 +00001279ALIAS (no_ospf_area_vlink,
1280 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001281 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1282 "(authentication-key|)",
1283 NO_STR
1284 VLINK_HELPSTR_IPADDR
1285 VLINK_HELPSTR_AUTH_SIMPLE)
1286
paula2c62832003-04-23 17:01:31 +00001287ALIAS (ospf_area_vlink,
1288 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001289 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1290 "(authentication|) (message-digest|null) "
1291 "(authentication-key|) AUTH_KEY",
1292 VLINK_HELPSTR_IPADDR
1293 VLINK_HELPSTR_AUTHTYPE_ALL
1294 VLINK_HELPSTR_AUTH_SIMPLE)
1295
paula2c62832003-04-23 17:01:31 +00001296ALIAS (ospf_area_vlink,
1297 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001298 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1299 "(authentication|) "
1300 "(authentication-key|) AUTH_KEY",
1301 VLINK_HELPSTR_IPADDR
1302 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1303 VLINK_HELPSTR_AUTH_SIMPLE)
1304
paula2c62832003-04-23 17:01:31 +00001305ALIAS (no_ospf_area_vlink,
1306 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001307 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1308 "(authentication|) "
1309 "(authentication-key|)",
1310 NO_STR
1311 VLINK_HELPSTR_IPADDR
1312 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1313 VLINK_HELPSTR_AUTH_SIMPLE)
1314
paula2c62832003-04-23 17:01:31 +00001315ALIAS (ospf_area_vlink,
1316 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001317 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1318 "(authentication|) (message-digest|null) "
1319 "(message-digest-key|) <1-255> md5 KEY",
1320 VLINK_HELPSTR_IPADDR
1321 VLINK_HELPSTR_AUTHTYPE_ALL
1322 VLINK_HELPSTR_AUTH_MD5)
1323
paula2c62832003-04-23 17:01:31 +00001324ALIAS (ospf_area_vlink,
1325 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001326 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1327 "(authentication|) "
1328 "(message-digest-key|) <1-255> md5 KEY",
1329 VLINK_HELPSTR_IPADDR
1330 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1331 VLINK_HELPSTR_AUTH_MD5)
1332
paula2c62832003-04-23 17:01:31 +00001333ALIAS (no_ospf_area_vlink,
1334 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001335 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1336 "(authentication|) "
1337 "(message-digest-key|)",
1338 NO_STR
1339 VLINK_HELPSTR_IPADDR
1340 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1341 VLINK_HELPSTR_AUTH_MD5)
1342
1343
paula2c62832003-04-23 17:01:31 +00001344DEFUN (ospf_area_shortcut,
1345 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001346 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1347 "OSPF area parameters\n"
1348 "OSPF area ID in IP address format\n"
1349 "OSPF area ID as a decimal value\n"
1350 "Configure the area's shortcutting mode\n"
1351 "Set default shortcutting behavior\n"
1352 "Enable shortcutting through the area\n"
1353 "Disable shortcutting through the area\n")
1354{
paul68980082003-03-25 05:07:42 +00001355 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001356 struct ospf_area *area;
1357 struct in_addr area_id;
1358 int mode;
1359 int format;
1360
1361 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1362
paul68980082003-03-25 05:07:42 +00001363 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001364
1365 if (strncmp (argv[1], "de", 2) == 0)
1366 mode = OSPF_SHORTCUT_DEFAULT;
1367 else if (strncmp (argv[1], "di", 2) == 0)
1368 mode = OSPF_SHORTCUT_DISABLE;
1369 else if (strncmp (argv[1], "e", 1) == 0)
1370 mode = OSPF_SHORTCUT_ENABLE;
1371 else
1372 return CMD_WARNING;
1373
paul68980082003-03-25 05:07:42 +00001374 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001375
paul68980082003-03-25 05:07:42 +00001376 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001377 vty_out (vty, "Shortcut area setting will take effect "
1378 "only when the router is configured as Shortcut ABR%s",
1379 VTY_NEWLINE);
1380
1381 return CMD_SUCCESS;
1382}
1383
paula2c62832003-04-23 17:01:31 +00001384DEFUN (no_ospf_area_shortcut,
1385 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001386 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1387 NO_STR
1388 "OSPF area parameters\n"
1389 "OSPF area ID in IP address format\n"
1390 "OSPF area ID as a decimal value\n"
1391 "Deconfigure the area's shortcutting mode\n"
1392 "Deconfigure enabled shortcutting through the area\n"
1393 "Deconfigure disabled shortcutting through the area\n")
1394{
paul68980082003-03-25 05:07:42 +00001395 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001396 struct ospf_area *area;
1397 struct in_addr area_id;
1398 int format;
1399
1400 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1401
paul68980082003-03-25 05:07:42 +00001402 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001403 if (!area)
1404 return CMD_SUCCESS;
1405
paul68980082003-03-25 05:07:42 +00001406 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001407
1408 return CMD_SUCCESS;
1409}
1410
1411
paula2c62832003-04-23 17:01:31 +00001412DEFUN (ospf_area_stub,
1413 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001414 "area (A.B.C.D|<0-4294967295>) stub",
1415 "OSPF area 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{
1420 struct ospf *ospf = vty->index;
1421 struct in_addr area_id;
1422 int ret, format;
1423
1424 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1425
1426 ret = ospf_area_stub_set (ospf, area_id);
1427 if (ret == 0)
1428 {
1429 vty_out (vty, "First deconfigure all virtual link through this area%s",
1430 VTY_NEWLINE);
1431 return CMD_WARNING;
1432 }
1433
1434 ospf_area_no_summary_unset (ospf, area_id);
1435
1436 return CMD_SUCCESS;
1437}
1438
paula2c62832003-04-23 17:01:31 +00001439DEFUN (ospf_area_stub_no_summary,
1440 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001441 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1442 "OSPF stub parameters\n"
1443 "OSPF area ID in IP address format\n"
1444 "OSPF area ID as a decimal value\n"
1445 "Configure OSPF area as stub\n"
1446 "Do not inject inter-area routes into stub\n")
1447{
1448 struct ospf *ospf = vty->index;
1449 struct in_addr area_id;
1450 int ret, format;
1451
1452 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1453
1454 ret = ospf_area_stub_set (ospf, area_id);
1455 if (ret == 0)
1456 {
paulb0a053b2003-06-22 09:04:47 +00001457 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001458 VTY_NEWLINE);
1459 return CMD_WARNING;
1460 }
1461
1462 ospf_area_no_summary_set (ospf, area_id);
1463
1464 return CMD_SUCCESS;
1465}
1466
paula2c62832003-04-23 17:01:31 +00001467DEFUN (no_ospf_area_stub,
1468 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001469 "no area (A.B.C.D|<0-4294967295>) stub",
1470 NO_STR
1471 "OSPF area parameters\n"
1472 "OSPF area ID in IP address format\n"
1473 "OSPF area ID as a decimal value\n"
1474 "Configure OSPF area as stub\n")
1475{
1476 struct ospf *ospf = vty->index;
1477 struct in_addr area_id;
1478 int format;
1479
1480 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1481
1482 ospf_area_stub_unset (ospf, area_id);
1483 ospf_area_no_summary_unset (ospf, area_id);
1484
1485 return CMD_SUCCESS;
1486}
1487
paula2c62832003-04-23 17:01:31 +00001488DEFUN (no_ospf_area_stub_no_summary,
1489 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001490 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1491 NO_STR
1492 "OSPF area parameters\n"
1493 "OSPF area ID in IP address format\n"
1494 "OSPF area ID as a decimal value\n"
1495 "Configure OSPF area as stub\n"
1496 "Do not inject inter-area routes into area\n")
1497{
1498 struct ospf *ospf = vty->index;
1499 struct in_addr area_id;
1500 int format;
1501
1502 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1503 ospf_area_no_summary_unset (ospf, area_id);
1504
1505 return CMD_SUCCESS;
1506}
1507
paul4dadc292005-05-06 21:37:42 +00001508static int
paul6c835672004-10-11 11:00:30 +00001509ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1510 int nosum)
paul718e3742002-12-13 20:15:29 +00001511{
1512 struct ospf *ospf = vty->index;
1513 struct in_addr area_id;
1514 int ret, format;
1515
1516 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1517
1518 ret = ospf_area_nssa_set (ospf, area_id);
1519 if (ret == 0)
1520 {
1521 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1522 VTY_NEWLINE);
1523 return CMD_WARNING;
1524 }
1525
1526 if (argc > 1)
1527 {
1528 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001529 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001530 OSPF_NSSA_ROLE_CANDIDATE);
1531 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001532 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001533 OSPF_NSSA_ROLE_NEVER);
1534 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001535 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001536 OSPF_NSSA_ROLE_ALWAYS);
1537 }
paulb0a053b2003-06-22 09:04:47 +00001538 else
1539 {
1540 ospf_area_nssa_translator_role_set (ospf, area_id,
1541 OSPF_NSSA_ROLE_CANDIDATE);
1542 }
paul718e3742002-12-13 20:15:29 +00001543
paulb0a053b2003-06-22 09:04:47 +00001544 if (nosum)
paul718e3742002-12-13 20:15:29 +00001545 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001546 else
1547 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001548
paulb0a053b2003-06-22 09:04:47 +00001549 ospf_schedule_abr_task (ospf);
1550
paul718e3742002-12-13 20:15:29 +00001551 return CMD_SUCCESS;
1552}
1553
paulb0a053b2003-06-22 09:04:47 +00001554DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001555 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001556 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001557 "OSPF area parameters\n"
1558 "OSPF area ID in IP address format\n"
1559 "OSPF area ID as a decimal value\n"
1560 "Configure OSPF area as nssa\n"
1561 "Configure NSSA-ABR for translate election (default)\n"
1562 "Configure NSSA-ABR to never translate\n"
1563 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001564 "Do not inject inter-area routes into nssa\n")
1565{
1566 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1567}
paul718e3742002-12-13 20:15:29 +00001568
paulb0a053b2003-06-22 09:04:47 +00001569DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001570 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001571 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1572 "OSPF area parameters\n"
1573 "OSPF area ID in IP address format\n"
1574 "OSPF area ID as a decimal value\n"
1575 "Configure OSPF area as nssa\n"
1576 "Configure NSSA-ABR for translate election (default)\n"
1577 "Configure NSSA-ABR to never translate\n"
1578 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001579{
1580 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1581}
1582
1583DEFUN (ospf_area_nssa,
1584 ospf_area_nssa_cmd,
1585 "area (A.B.C.D|<0-4294967295>) nssa",
1586 "OSPF area parameters\n"
1587 "OSPF area ID in IP address format\n"
1588 "OSPF area ID as a decimal value\n"
1589 "Configure OSPF area as nssa\n")
1590{
1591 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1592}
paul718e3742002-12-13 20:15:29 +00001593
paula2c62832003-04-23 17:01:31 +00001594DEFUN (ospf_area_nssa_no_summary,
1595 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001596 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1597 "OSPF area parameters\n"
1598 "OSPF area ID in IP address format\n"
1599 "OSPF area ID as a decimal value\n"
1600 "Configure OSPF area as nssa\n"
1601 "Do not inject inter-area routes into nssa\n")
1602{
paulb0a053b2003-06-22 09:04:47 +00001603 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001604}
1605
paula2c62832003-04-23 17:01:31 +00001606DEFUN (no_ospf_area_nssa,
1607 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001608 "no area (A.B.C.D|<0-4294967295>) nssa",
1609 NO_STR
1610 "OSPF area parameters\n"
1611 "OSPF area ID in IP address format\n"
1612 "OSPF area ID as a decimal value\n"
1613 "Configure OSPF area as nssa\n")
1614{
1615 struct ospf *ospf = vty->index;
1616 struct in_addr area_id;
1617 int format;
1618
1619 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1620
1621 ospf_area_nssa_unset (ospf, area_id);
1622 ospf_area_no_summary_unset (ospf, area_id);
1623
paulb0a053b2003-06-22 09:04:47 +00001624 ospf_schedule_abr_task (ospf);
1625
paul718e3742002-12-13 20:15:29 +00001626 return CMD_SUCCESS;
1627}
1628
paula2c62832003-04-23 17:01:31 +00001629DEFUN (no_ospf_area_nssa_no_summary,
1630 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001631 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1632 NO_STR
1633 "OSPF area parameters\n"
1634 "OSPF area ID in IP address format\n"
1635 "OSPF area ID as a decimal value\n"
1636 "Configure OSPF area as nssa\n"
1637 "Do not inject inter-area routes into nssa\n")
1638{
1639 struct ospf *ospf = vty->index;
1640 struct in_addr area_id;
1641 int format;
1642
1643 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1644 ospf_area_no_summary_unset (ospf, area_id);
1645
1646 return CMD_SUCCESS;
1647}
1648
paula2c62832003-04-23 17:01:31 +00001649DEFUN (ospf_area_default_cost,
1650 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001651 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1652 "OSPF area parameters\n"
1653 "OSPF area ID in IP address format\n"
1654 "OSPF area ID as a decimal value\n"
1655 "Set the summary-default cost of a NSSA or stub area\n"
1656 "Stub's advertised default summary cost\n")
1657{
paul68980082003-03-25 05:07:42 +00001658 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001659 struct ospf_area *area;
1660 struct in_addr area_id;
1661 u_int32_t cost;
1662 int format;
vincentba682532005-09-29 13:52:57 +00001663 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001664
1665 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1666 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1667
paul68980082003-03-25 05:07:42 +00001668 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001669
1670 if (area->external_routing == OSPF_AREA_DEFAULT)
1671 {
1672 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1673 return CMD_WARNING;
1674 }
1675
1676 area->default_cost = cost;
1677
vincentba682532005-09-29 13:52:57 +00001678 p.family = AF_INET;
1679 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1680 p.prefixlen = 0;
1681 if (IS_DEBUG_OSPF_EVENT)
1682 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1683 "announcing 0.0.0.0/0 to area %s",
1684 inet_ntoa (area->area_id));
1685 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1686
paul718e3742002-12-13 20:15:29 +00001687 return CMD_SUCCESS;
1688}
1689
paula2c62832003-04-23 17:01:31 +00001690DEFUN (no_ospf_area_default_cost,
1691 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001692 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1693 NO_STR
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 summary-default cost of a NSSA or stub area\n"
1698 "Stub's advertised default summary cost\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 u_int32_t cost;
1704 int format;
vincentba682532005-09-29 13:52:57 +00001705 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001706
1707 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1708 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1709
paul68980082003-03-25 05:07:42 +00001710 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001711 if (area == NULL)
1712 return CMD_SUCCESS;
1713
1714 if (area->external_routing == OSPF_AREA_DEFAULT)
1715 {
1716 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1717 return CMD_WARNING;
1718 }
1719
1720 area->default_cost = 1;
1721
vincentba682532005-09-29 13:52:57 +00001722 p.family = AF_INET;
1723 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1724 p.prefixlen = 0;
1725 if (IS_DEBUG_OSPF_EVENT)
1726 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1727 "announcing 0.0.0.0/0 to area %s",
1728 inet_ntoa (area->area_id));
1729 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1730
1731
paul68980082003-03-25 05:07:42 +00001732 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001733
1734 return CMD_SUCCESS;
1735}
1736
paula2c62832003-04-23 17:01:31 +00001737DEFUN (ospf_area_export_list,
1738 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001739 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1740 "OSPF area parameters\n"
1741 "OSPF area ID in IP address format\n"
1742 "OSPF area ID as a decimal value\n"
1743 "Set the filter for networks announced to other areas\n"
1744 "Name of the access-list\n")
1745{
paul68980082003-03-25 05:07:42 +00001746 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001747 struct ospf_area *area;
1748 struct in_addr area_id;
1749 int format;
1750
hasso52930762004-04-19 18:26:53 +00001751 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1752
paul68980082003-03-25 05:07:42 +00001753 area = ospf_area_get (ospf, area_id, format);
1754 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001755
1756 return CMD_SUCCESS;
1757}
1758
paula2c62832003-04-23 17:01:31 +00001759DEFUN (no_ospf_area_export_list,
1760 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001761 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1762 NO_STR
1763 "OSPF area parameters\n"
1764 "OSPF area ID in IP address format\n"
1765 "OSPF area ID as a decimal value\n"
1766 "Unset the filter for networks announced to other areas\n"
1767 "Name of the access-list\n")
1768{
paul68980082003-03-25 05:07:42 +00001769 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001770 struct ospf_area *area;
1771 struct in_addr area_id;
1772 int format;
1773
hasso52930762004-04-19 18:26:53 +00001774 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1775
paul68980082003-03-25 05:07:42 +00001776 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001777 if (area == NULL)
1778 return CMD_SUCCESS;
1779
paul68980082003-03-25 05:07:42 +00001780 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001781
1782 return CMD_SUCCESS;
1783}
1784
1785
paula2c62832003-04-23 17:01:31 +00001786DEFUN (ospf_area_import_list,
1787 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001788 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1789 "OSPF area parameters\n"
1790 "OSPF area ID in IP address format\n"
1791 "OSPF area ID as a decimal value\n"
1792 "Set the filter for networks from other areas announced to the specified one\n"
1793 "Name of the access-list\n")
1794{
paul68980082003-03-25 05:07:42 +00001795 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001796 struct ospf_area *area;
1797 struct in_addr area_id;
1798 int format;
1799
hasso52930762004-04-19 18:26:53 +00001800 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1801
paul68980082003-03-25 05:07:42 +00001802 area = ospf_area_get (ospf, area_id, format);
1803 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001804
1805 return CMD_SUCCESS;
1806}
1807
paula2c62832003-04-23 17:01:31 +00001808DEFUN (no_ospf_area_import_list,
1809 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001810 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1811 NO_STR
1812 "OSPF area parameters\n"
1813 "OSPF area ID in IP address format\n"
1814 "OSPF area ID as a decimal value\n"
1815 "Unset the filter for networks announced to other areas\n"
1816 "Name of the access-list\n")
1817{
paul68980082003-03-25 05:07:42 +00001818 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001819 struct ospf_area *area;
1820 struct in_addr area_id;
1821 int format;
1822
hasso52930762004-04-19 18:26:53 +00001823 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1824
paul68980082003-03-25 05:07:42 +00001825 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001826 if (area == NULL)
1827 return CMD_SUCCESS;
1828
paul68980082003-03-25 05:07:42 +00001829 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001830
1831 return CMD_SUCCESS;
1832}
1833
paula2c62832003-04-23 17:01:31 +00001834DEFUN (ospf_area_filter_list,
1835 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001836 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1837 "OSPF area parameters\n"
1838 "OSPF area ID in IP address format\n"
1839 "OSPF area ID as a decimal value\n"
1840 "Filter networks between OSPF areas\n"
1841 "Filter prefixes between OSPF areas\n"
1842 "Name of an IP prefix-list\n"
1843 "Filter networks sent to this area\n"
1844 "Filter networks sent from this area\n")
1845{
paul68980082003-03-25 05:07:42 +00001846 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001847 struct ospf_area *area;
1848 struct in_addr area_id;
1849 struct prefix_list *plist;
1850 int format;
1851
1852 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1853
paul68980082003-03-25 05:07:42 +00001854 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001855 plist = prefix_list_lookup (AFI_IP, argv[1]);
1856 if (strncmp (argv[2], "in", 2) == 0)
1857 {
1858 PREFIX_LIST_IN (area) = plist;
1859 if (PREFIX_NAME_IN (area))
1860 free (PREFIX_NAME_IN (area));
1861
1862 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001863 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001864 }
1865 else
1866 {
1867 PREFIX_LIST_OUT (area) = plist;
1868 if (PREFIX_NAME_OUT (area))
1869 free (PREFIX_NAME_OUT (area));
1870
1871 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001872 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001873 }
1874
1875 return CMD_SUCCESS;
1876}
1877
paula2c62832003-04-23 17:01:31 +00001878DEFUN (no_ospf_area_filter_list,
1879 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001880 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1881 NO_STR
1882 "OSPF area parameters\n"
1883 "OSPF area ID in IP address format\n"
1884 "OSPF area ID as a decimal value\n"
1885 "Filter networks between OSPF areas\n"
1886 "Filter prefixes between OSPF areas\n"
1887 "Name of an IP prefix-list\n"
1888 "Filter networks sent to this area\n"
1889 "Filter networks sent from this area\n")
1890{
paul68980082003-03-25 05:07:42 +00001891 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001892 struct ospf_area *area;
1893 struct in_addr area_id;
1894 struct prefix_list *plist;
1895 int format;
1896
1897 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1898
paul68980082003-03-25 05:07:42 +00001899 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001900 plist = prefix_list_lookup (AFI_IP, argv[1]);
1901 if (strncmp (argv[2], "in", 2) == 0)
1902 {
1903 if (PREFIX_NAME_IN (area))
1904 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1905 return CMD_SUCCESS;
1906
1907 PREFIX_LIST_IN (area) = NULL;
1908 if (PREFIX_NAME_IN (area))
1909 free (PREFIX_NAME_IN (area));
1910
1911 PREFIX_NAME_IN (area) = NULL;
1912
paul68980082003-03-25 05:07:42 +00001913 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001914 }
1915 else
1916 {
1917 if (PREFIX_NAME_OUT (area))
1918 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1919 return CMD_SUCCESS;
1920
1921 PREFIX_LIST_OUT (area) = NULL;
1922 if (PREFIX_NAME_OUT (area))
1923 free (PREFIX_NAME_OUT (area));
1924
1925 PREFIX_NAME_OUT (area) = NULL;
1926
paul68980082003-03-25 05:07:42 +00001927 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001928 }
1929
1930 return CMD_SUCCESS;
1931}
1932
1933
paula2c62832003-04-23 17:01:31 +00001934DEFUN (ospf_area_authentication_message_digest,
1935 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001936 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1937 "OSPF area parameters\n"
1938 "Enable authentication\n"
1939 "Use message-digest authentication\n")
1940{
paul68980082003-03-25 05:07:42 +00001941 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001942 struct ospf_area *area;
1943 struct in_addr area_id;
1944 int format;
1945
1946 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1947
paul68980082003-03-25 05:07:42 +00001948 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001949 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1950
1951 return CMD_SUCCESS;
1952}
1953
paula2c62832003-04-23 17:01:31 +00001954DEFUN (ospf_area_authentication,
1955 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001956 "area (A.B.C.D|<0-4294967295>) authentication",
1957 "OSPF area parameters\n"
1958 "OSPF area ID in IP address format\n"
1959 "OSPF area ID as a decimal value\n"
1960 "Enable authentication\n")
1961{
paul68980082003-03-25 05:07:42 +00001962 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001963 struct ospf_area *area;
1964 struct in_addr area_id;
1965 int format;
1966
1967 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1968
paul68980082003-03-25 05:07:42 +00001969 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001970 area->auth_type = OSPF_AUTH_SIMPLE;
1971
1972 return CMD_SUCCESS;
1973}
1974
paula2c62832003-04-23 17:01:31 +00001975DEFUN (no_ospf_area_authentication,
1976 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001977 "no area (A.B.C.D|<0-4294967295>) authentication",
1978 NO_STR
1979 "OSPF area parameters\n"
1980 "OSPF area ID in IP address format\n"
1981 "OSPF area ID as a decimal value\n"
1982 "Enable authentication\n")
1983{
paul68980082003-03-25 05:07:42 +00001984 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001985 struct ospf_area *area;
1986 struct in_addr area_id;
1987 int format;
1988
1989 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1990
paul68980082003-03-25 05:07:42 +00001991 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001992 if (area == NULL)
1993 return CMD_SUCCESS;
1994
1995 area->auth_type = OSPF_AUTH_NULL;
1996
paul68980082003-03-25 05:07:42 +00001997 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001998
1999 return CMD_SUCCESS;
2000}
2001
2002
2003DEFUN (ospf_abr_type,
2004 ospf_abr_type_cmd,
2005 "ospf abr-type (cisco|ibm|shortcut|standard)",
2006 "OSPF specific commands\n"
2007 "Set OSPF ABR type\n"
2008 "Alternative ABR, cisco implementation\n"
2009 "Alternative ABR, IBM implementation\n"
2010 "Shortcut ABR\n"
2011 "Standard behavior (RFC2328)\n")
2012{
paul68980082003-03-25 05:07:42 +00002013 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002014 u_char abr_type = OSPF_ABR_UNKNOWN;
2015
2016 if (strncmp (argv[0], "c", 1) == 0)
2017 abr_type = OSPF_ABR_CISCO;
2018 else if (strncmp (argv[0], "i", 1) == 0)
2019 abr_type = OSPF_ABR_IBM;
2020 else if (strncmp (argv[0], "sh", 2) == 0)
2021 abr_type = OSPF_ABR_SHORTCUT;
2022 else if (strncmp (argv[0], "st", 2) == 0)
2023 abr_type = OSPF_ABR_STAND;
2024 else
2025 return CMD_WARNING;
2026
2027 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002028 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002029 {
paul68980082003-03-25 05:07:42 +00002030 ospf->abr_type = abr_type;
2031 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002032 }
2033
2034 return CMD_SUCCESS;
2035}
2036
2037DEFUN (no_ospf_abr_type,
2038 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002039 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002040 NO_STR
2041 "OSPF specific commands\n"
2042 "Set OSPF ABR type\n"
2043 "Alternative ABR, cisco implementation\n"
2044 "Alternative ABR, IBM implementation\n"
2045 "Shortcut ABR\n")
2046{
paul68980082003-03-25 05:07:42 +00002047 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002048 u_char abr_type = OSPF_ABR_UNKNOWN;
2049
2050 if (strncmp (argv[0], "c", 1) == 0)
2051 abr_type = OSPF_ABR_CISCO;
2052 else if (strncmp (argv[0], "i", 1) == 0)
2053 abr_type = OSPF_ABR_IBM;
2054 else if (strncmp (argv[0], "s", 1) == 0)
2055 abr_type = OSPF_ABR_SHORTCUT;
2056 else
2057 return CMD_WARNING;
2058
2059 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002060 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002061 {
pauld57834f2005-07-12 20:04:22 +00002062 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002063 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002064 }
2065
2066 return CMD_SUCCESS;
2067}
2068
2069DEFUN (ospf_compatible_rfc1583,
2070 ospf_compatible_rfc1583_cmd,
2071 "compatible rfc1583",
2072 "OSPF compatibility list\n"
2073 "compatible with RFC 1583\n")
2074{
2075 struct ospf *ospf = vty->index;
2076
2077 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2078 {
2079 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002080 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002081 }
2082 return CMD_SUCCESS;
2083}
2084
2085DEFUN (no_ospf_compatible_rfc1583,
2086 no_ospf_compatible_rfc1583_cmd,
2087 "no compatible rfc1583",
2088 NO_STR
2089 "OSPF compatibility list\n"
2090 "compatible with RFC 1583\n")
2091{
2092 struct ospf *ospf = vty->index;
2093
2094 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2095 {
2096 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002097 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002098 }
2099 return CMD_SUCCESS;
2100}
2101
2102ALIAS (ospf_compatible_rfc1583,
2103 ospf_rfc1583_flag_cmd,
2104 "ospf rfc1583compatibility",
2105 "OSPF specific commands\n"
2106 "Enable the RFC1583Compatibility flag\n")
2107
2108ALIAS (no_ospf_compatible_rfc1583,
2109 no_ospf_rfc1583_flag_cmd,
2110 "no ospf rfc1583compatibility",
2111 NO_STR
2112 "OSPF specific commands\n"
2113 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002114
2115static int
2116ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2117 unsigned int hold,
2118 unsigned int max)
2119{
2120 struct ospf *ospf = vty->index;
2121
2122 ospf->spf_delay = delay;
2123 ospf->spf_holdtime = hold;
2124 ospf->spf_max_holdtime = max;
2125
2126 return CMD_SUCCESS;
2127}
paul718e3742002-12-13 20:15:29 +00002128
pauld24f6e22005-10-21 09:23:12 +00002129DEFUN (ospf_timers_throttle_spf,
2130 ospf_timers_throttle_spf_cmd,
2131 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2132 "Adjust routing timers\n"
2133 "Throttling adaptive timer\n"
2134 "OSPF SPF timers\n"
2135 "Delay (msec) from first change received till SPF calculation\n"
2136 "Initial hold time (msec) between consecutive SPF calculations\n"
2137 "Maximum hold time (msec)\n")
2138{
2139 unsigned int delay, hold, max;
2140
2141 if (argc != 3)
2142 {
2143 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2144 return CMD_WARNING;
2145 }
2146
2147 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2148 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2149 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2150
2151 return ospf_timers_spf_set (vty, delay, hold, max);
2152}
2153
2154DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002155 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002156 "timers spf <0-4294967295> <0-4294967295>",
2157 "Adjust routing timers\n"
2158 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002159 "Delay (s) between receiving a change to SPF calculation\n"
2160 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002161{
pauld24f6e22005-10-21 09:23:12 +00002162 unsigned int delay, hold;
2163
2164 if (argc != 2)
2165 {
2166 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2167 return CMD_WARNING;
2168 }
2169
paul4dadc292005-05-06 21:37:42 +00002170 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2171 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002172
2173 /* truncate down the second values if they're greater than 600000ms */
2174 if (delay > (600000 / 1000))
2175 delay = 600000;
2176 else if (delay == 0)
2177 /* 0s delay was probably specified because of lack of ms resolution */
2178 delay = OSPF_SPF_DELAY_DEFAULT;
2179 if (hold > (600000 / 1000))
2180 hold = 600000;
2181
2182 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002183}
2184
pauld24f6e22005-10-21 09:23:12 +00002185DEFUN (no_ospf_timers_throttle_spf,
2186 no_ospf_timers_throttle_spf_cmd,
2187 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002188 NO_STR
2189 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002190 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002191 "OSPF SPF timers\n")
2192{
pauld24f6e22005-10-21 09:23:12 +00002193 return ospf_timers_spf_set (vty,
2194 OSPF_SPF_DELAY_DEFAULT,
2195 OSPF_SPF_HOLDTIME_DEFAULT,
2196 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002197}
2198
pauld24f6e22005-10-21 09:23:12 +00002199ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2200 no_ospf_timers_spf_cmd,
2201 "no timers spf",
2202 NO_STR
2203 "Adjust routing timers\n"
2204 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002205
paula2c62832003-04-23 17:01:31 +00002206DEFUN (ospf_neighbor,
2207 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002208 "neighbor A.B.C.D",
2209 NEIGHBOR_STR
2210 "Neighbor IP address\n")
2211{
2212 struct ospf *ospf = vty->index;
2213 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002214 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2215 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002216
2217 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2218
2219 if (argc > 1)
2220 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2221
2222 if (argc > 2)
2223 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2224
2225 ospf_nbr_nbma_set (ospf, nbr_addr);
2226 if (argc > 1)
2227 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2228 if (argc > 2)
2229 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2230
2231 return CMD_SUCCESS;
2232}
2233
paula2c62832003-04-23 17:01:31 +00002234ALIAS (ospf_neighbor,
2235 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002236 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2237 NEIGHBOR_STR
2238 "Neighbor IP address\n"
2239 "Neighbor Priority\n"
2240 "Priority\n"
2241 "Dead Neighbor Polling interval\n"
2242 "Seconds\n")
2243
paula2c62832003-04-23 17:01:31 +00002244ALIAS (ospf_neighbor,
2245 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002246 "neighbor A.B.C.D priority <0-255>",
2247 NEIGHBOR_STR
2248 "Neighbor IP address\n"
2249 "Neighbor Priority\n"
2250 "Seconds\n")
2251
paula2c62832003-04-23 17:01:31 +00002252DEFUN (ospf_neighbor_poll_interval,
2253 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002254 "neighbor A.B.C.D poll-interval <1-65535>",
2255 NEIGHBOR_STR
2256 "Neighbor IP address\n"
2257 "Dead Neighbor Polling interval\n"
2258 "Seconds\n")
2259{
2260 struct ospf *ospf = vty->index;
2261 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002262 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2263 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002264
2265 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2266
2267 if (argc > 1)
2268 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2269
2270 if (argc > 2)
2271 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2272
2273 ospf_nbr_nbma_set (ospf, nbr_addr);
2274 if (argc > 1)
2275 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2276 if (argc > 2)
2277 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2278
2279 return CMD_SUCCESS;
2280}
2281
paula2c62832003-04-23 17:01:31 +00002282ALIAS (ospf_neighbor_poll_interval,
2283 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002284 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2285 NEIGHBOR_STR
2286 "Neighbor address\n"
2287 "OSPF dead-router polling interval\n"
2288 "Seconds\n"
2289 "OSPF priority of non-broadcast neighbor\n"
2290 "Priority\n")
2291
paula2c62832003-04-23 17:01:31 +00002292DEFUN (no_ospf_neighbor,
2293 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002294 "no neighbor A.B.C.D",
2295 NO_STR
2296 NEIGHBOR_STR
2297 "Neighbor IP address\n")
2298{
2299 struct ospf *ospf = vty->index;
2300 struct in_addr nbr_addr;
2301 int ret;
2302
2303 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2304
2305 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2306
2307 return CMD_SUCCESS;
2308}
2309
paula2c62832003-04-23 17:01:31 +00002310ALIAS (no_ospf_neighbor,
2311 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002312 "no neighbor A.B.C.D priority <0-255>",
2313 NO_STR
2314 NEIGHBOR_STR
2315 "Neighbor IP address\n"
2316 "Neighbor Priority\n"
2317 "Priority\n")
2318
paula2c62832003-04-23 17:01:31 +00002319ALIAS (no_ospf_neighbor,
2320 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002321 "no neighbor A.B.C.D poll-interval <1-65535>",
2322 NO_STR
2323 NEIGHBOR_STR
2324 "Neighbor IP address\n"
2325 "Dead Neighbor Polling interval\n"
2326 "Seconds\n")
2327
paula2c62832003-04-23 17:01:31 +00002328ALIAS (no_ospf_neighbor,
2329 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002330 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2331 NO_STR
2332 NEIGHBOR_STR
2333 "Neighbor IP address\n"
2334 "Neighbor Priority\n"
2335 "Priority\n"
2336 "Dead Neighbor Polling interval\n"
2337 "Seconds\n")
2338
2339
paula2c62832003-04-23 17:01:31 +00002340DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002341 "refresh timer <10-1800>",
2342 "Adjust refresh parameters\n"
2343 "Set refresh timer\n"
2344 "Timer value in seconds\n")
2345{
2346 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002347 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002348
2349 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2350 interval = (interval / 10) * 10;
2351
2352 ospf_timers_refresh_set (ospf, interval);
2353
2354 return CMD_SUCCESS;
2355}
2356
paula2c62832003-04-23 17:01:31 +00002357DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002358 "no refresh timer <10-1800>",
2359 "Adjust refresh parameters\n"
2360 "Unset refresh timer\n"
2361 "Timer value in seconds\n")
2362{
2363 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002364 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002365
2366 if (argc == 1)
2367 {
2368 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2369
2370 if (ospf->lsa_refresh_interval != interval ||
2371 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2372 return CMD_SUCCESS;
2373 }
2374
2375 ospf_timers_refresh_unset (ospf);
2376
2377 return CMD_SUCCESS;
2378}
2379
paula2c62832003-04-23 17:01:31 +00002380ALIAS (no_ospf_refresh_timer,
2381 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002382 "no refresh timer",
2383 "Adjust refresh parameters\n"
2384 "Unset refresh timer\n")
2385
paula2c62832003-04-23 17:01:31 +00002386DEFUN (ospf_auto_cost_reference_bandwidth,
2387 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002388 "auto-cost reference-bandwidth <1-4294967>",
2389 "Calculate OSPF interface cost according to bandwidth\n"
2390 "Use reference bandwidth method to assign OSPF cost\n"
2391 "The reference bandwidth in terms of Mbits per second\n")
2392{
paul68980082003-03-25 05:07:42 +00002393 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002394 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002395 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002396 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002397
2398 refbw = strtol (argv[0], NULL, 10);
2399 if (refbw < 1 || refbw > 4294967)
2400 {
2401 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2402 return CMD_WARNING;
2403 }
2404
2405 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002406 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002407 return CMD_SUCCESS;
2408
paul68980082003-03-25 05:07:42 +00002409 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002410 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2411 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002412
2413 return CMD_SUCCESS;
2414}
2415
paula2c62832003-04-23 17:01:31 +00002416DEFUN (no_ospf_auto_cost_reference_bandwidth,
2417 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002418 "no auto-cost reference-bandwidth",
2419 NO_STR
2420 "Calculate OSPF interface cost according to bandwidth\n"
2421 "Use reference bandwidth method to assign OSPF cost\n")
2422{
paul68980082003-03-25 05:07:42 +00002423 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002424 struct listnode *node, *nnode;
2425 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002426
paul68980082003-03-25 05:07:42 +00002427 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002428 return CMD_SUCCESS;
2429
paul68980082003-03-25 05:07:42 +00002430 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002431 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2432 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2433
paul1eb8ef22005-04-07 07:30:20 +00002434 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2435 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002436
2437 return CMD_SUCCESS;
2438}
2439
hassoeb1ce602004-10-08 08:17:22 +00002440const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002441{
2442 "Unknown",
2443 "Standard (RFC2328)",
2444 "Alternative IBM",
2445 "Alternative Cisco",
2446 "Alternative Shortcut"
2447};
2448
hassoeb1ce602004-10-08 08:17:22 +00002449const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002450{
2451 "Default",
2452 "Enabled",
2453 "Disabled"
2454};
2455
2456
2457
paul4dadc292005-05-06 21:37:42 +00002458static void
paul718e3742002-12-13 20:15:29 +00002459show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2460{
2461 /* Show Area ID. */
2462 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2463
2464 /* Show Area type/mode. */
2465 if (OSPF_IS_AREA_BACKBONE (area))
2466 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2467 else
2468 {
2469 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002470 vty_out (vty, " (Stub%s%s)",
2471 area->no_summary ? ", no summary" : "",
2472 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002473
paulb0a053b2003-06-22 09:04:47 +00002474 else if (area->external_routing == OSPF_AREA_NSSA)
2475 vty_out (vty, " (NSSA%s%s)",
2476 area->no_summary ? ", no summary" : "",
2477 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002478
2479 vty_out (vty, "%s", VTY_NEWLINE);
2480 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002481 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002482 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002483 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002484 }
2485
2486 /* Show number of interfaces. */
2487 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2488 "Active: %d%s", listcount (area->oiflist),
2489 area->act_ints, VTY_NEWLINE);
2490
paul718e3742002-12-13 20:15:29 +00002491 if (area->external_routing == OSPF_AREA_NSSA)
2492 {
2493 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 +00002494 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002495 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2496 VTY_NEWLINE);
2497 else if (area->NSSATranslatorState)
2498 {
2499 vty_out (vty, " We are an ABR and ");
2500 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2501 vty_out (vty, "the NSSA Elected Translator. %s",
2502 VTY_NEWLINE);
2503 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2504 vty_out (vty, "always an NSSA Translator. %s",
2505 VTY_NEWLINE);
2506 }
paul718e3742002-12-13 20:15:29 +00002507 else
paulb0a053b2003-06-22 09:04:47 +00002508 {
2509 vty_out (vty, " We are an ABR, but ");
2510 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2511 vty_out (vty, "not the NSSA Elected Translator. %s",
2512 VTY_NEWLINE);
2513 else
hassoc6b87812004-12-22 13:09:59 +00002514 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002515 VTY_NEWLINE);
2516 }
paul718e3742002-12-13 20:15:29 +00002517 }
paul88d6cf32005-10-29 12:50:09 +00002518 /* Stub-router state for this area */
2519 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2520 {
ajs649654a2005-11-16 20:17:52 +00002521 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002522 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2523 VTY_NEWLINE);
2524 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2525 vty_out (vty, " Administratively activated (indefinitely)%s",
2526 VTY_NEWLINE);
2527 if (area->t_stub_router)
2528 vty_out (vty, " Active from startup, %s remaining%s",
2529 ospf_timer_dump (area->t_stub_router, timebuf,
2530 sizeof(timebuf)), VTY_NEWLINE);
2531 }
2532
paul718e3742002-12-13 20:15:29 +00002533 /* Show number of fully adjacent neighbors. */
2534 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002535 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002536
2537 /* Show authentication type. */
2538 vty_out (vty, " Area has ");
2539 if (area->auth_type == OSPF_AUTH_NULL)
2540 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2541 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2542 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2543 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2544 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2545
2546 if (!OSPF_IS_AREA_BACKBONE (area))
2547 vty_out (vty, " Number of full virtual adjacencies going through"
2548 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2549
2550 /* Show SPF calculation times. */
2551 vty_out (vty, " SPF algorithm executed %d times%s",
2552 area->spf_calculation, VTY_NEWLINE);
2553
2554 /* Show number of LSA. */
2555 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002556 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2557 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2558 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2559 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2560 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2561 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2562 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2563 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2564 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2565 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2566 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2567 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2568 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2569 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2570 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2571#ifdef HAVE_OPAQUE_LSA
2572 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2573 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2574 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2575 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2576 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2577 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2578#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002579 vty_out (vty, "%s", VTY_NEWLINE);
2580}
2581
2582DEFUN (show_ip_ospf,
2583 show_ip_ospf_cmd,
2584 "show ip ospf",
2585 SHOW_STR
2586 IP_STR
2587 "OSPF information\n")
2588{
paul1eb8ef22005-04-07 07:30:20 +00002589 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002590 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002591 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002592 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002593 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002594
2595 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002596 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002597 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002598 {
2599 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2600 return CMD_SUCCESS;
2601 }
2602
2603 /* Show Router ID. */
2604 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002605 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002606 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002607
2608 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002609 if (ospf->t_deferred_shutdown)
2610 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2611 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002612 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002613 /* Show capability. */
2614 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2615 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2616 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002617 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002618 "enabled" : "disabled", VTY_NEWLINE);
2619#ifdef HAVE_OPAQUE_LSA
2620 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002621 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002622 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002623 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002624 " (origination blocked)" : "",
2625 VTY_NEWLINE);
2626#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002627
2628 /* Show stub-router configuration */
2629 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2630 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2631 {
2632 vty_out (vty, " Stub router advertisement is configured%s",
2633 VTY_NEWLINE);
2634 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2635 vty_out (vty, " Enabled for %us after start-up%s",
2636 ospf->stub_router_startup_time, VTY_NEWLINE);
2637 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2638 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2639 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2640 }
2641
paul718e3742002-12-13 20:15:29 +00002642 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002643 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2644 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2645 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2646 " Hold time multiplier is currently %d%s",
2647 ospf->spf_delay, VTY_NEWLINE,
2648 ospf->spf_holdtime, VTY_NEWLINE,
2649 ospf->spf_max_holdtime, VTY_NEWLINE,
2650 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002651 vty_out (vty, " SPF algorithm ");
2652 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2653 {
paulc8c15212005-11-04 12:31:39 +00002654 result = tv_sub (recent_time, ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002655 vty_out (vty, "last executed %s ago%s",
2656 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2657 VTY_NEWLINE);
2658 }
2659 else
2660 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002661 vty_out (vty, " SPF timer %s%s%s",
2662 (ospf->t_spf_calc ? "due in " : "is "),
2663 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2664 VTY_NEWLINE);
2665
paul718e3742002-12-13 20:15:29 +00002666 /* Show refresh parameters. */
2667 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002668 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002669
2670 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002671 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002672 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002673 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002674
paul68980082003-03-25 05:07:42 +00002675 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002676 vty_out (vty, " This router is an ASBR "
2677 "(injecting external routing information)%s", VTY_NEWLINE);
2678
2679 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002680 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2681 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2682 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2683#ifdef HAVE_OPAQUE_LSA
2684 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2685 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2686 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2687#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002688 /* Show number of areas attached. */
2689 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002690 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002691
2692 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002693 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2694 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002695
2696 return CMD_SUCCESS;
2697}
2698
2699
ajsfd651fa2005-03-29 16:08:16 +00002700static void
paul68980082003-03-25 05:07:42 +00002701show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2702 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002703{
ajsfd651fa2005-03-29 16:08:16 +00002704 int is_up;
paul718e3742002-12-13 20:15:29 +00002705 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002706 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002707
paul718e3742002-12-13 20:15:29 +00002708 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002709 vty_out (vty, "%s is %s%s", ifp->name,
2710 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002711 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2712 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2713 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002714
2715 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002716 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002717 {
2718 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2719 return;
2720 }
ajsfd651fa2005-03-29 16:08:16 +00002721 else if (!is_up)
2722 {
2723 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2724 VTY_NEWLINE);
2725 return;
2726 }
2727
paul718e3742002-12-13 20:15:29 +00002728 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2729 {
2730 struct ospf_interface *oi = rn->info;
2731
2732 if (oi == NULL)
2733 continue;
2734
2735 /* Show OSPF interface information. */
2736 vty_out (vty, " Internet Address %s/%d,",
2737 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2738
Paul Jakma9c27ef92006-05-04 07:32:57 +00002739 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2740 {
2741 struct in_addr *dest;
2742 const char *dstr;
2743
2744 if ((ifp->flags & IFF_POINTOPOINT)
2745 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2746 dstr = "Peer";
2747 else
2748 dstr = "Broadcast";
2749
2750 /* For Vlinks, showing the peer address is probably more
2751 * informative than the local interface that is being used
2752 */
2753 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2754 dest = &oi->vl_data->peer_addr;
2755 else
2756 dest = &oi->connected->destination->u.prefix4;
2757
2758 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2759 }
hasso3fb9cd62004-10-19 19:44:43 +00002760
paul718e3742002-12-13 20:15:29 +00002761 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2762 VTY_NEWLINE);
2763
vincentba682532005-09-29 13:52:57 +00002764 vty_out (vty, " MTU mismatch detection:%s%s",
2765 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2766
paul718e3742002-12-13 20:15:29 +00002767 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002768 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002769 oi->output_cost, VTY_NEWLINE);
2770
2771 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2772 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2773 PRIORITY (oi), VTY_NEWLINE);
2774
2775 /* Show DR information. */
2776 if (DR (oi).s_addr == 0)
2777 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2778 else
2779 {
2780 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2781 if (nbr == NULL)
2782 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2783 else
2784 {
2785 vty_out (vty, " Designated Router (ID) %s,",
2786 inet_ntoa (nbr->router_id));
2787 vty_out (vty, " Interface Address %s%s",
2788 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2789 }
2790 }
2791
2792 /* Show BDR information. */
2793 if (BDR (oi).s_addr == 0)
2794 vty_out (vty, " No backup designated router on this network%s",
2795 VTY_NEWLINE);
2796 else
2797 {
2798 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2799 if (nbr == NULL)
2800 vty_out (vty, " No backup designated router on this network%s",
2801 VTY_NEWLINE);
2802 else
2803 {
2804 vty_out (vty, " Backup Designated Router (ID) %s,",
2805 inet_ntoa (nbr->router_id));
2806 vty_out (vty, " Interface Address %s%s",
2807 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2808 }
2809 }
ajsba6454e2005-02-08 15:37:30 +00002810
2811 vty_out (vty, " Multicast group memberships:");
2812 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2813 vty_out (vty, " OSPFAllRouters");
2814 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2815 vty_out (vty, " OSPFDesignatedRouters");
2816 if (!CHECK_FLAG(oi->multicast_memberships,
2817 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2818 vty_out (vty, " <None>");
2819 vty_out (vty, "%s", VTY_NEWLINE);
2820
paul718e3742002-12-13 20:15:29 +00002821 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002822 vty_out (vty, " Hello ");
2823 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2824 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2825 else
2826 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2827 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2828 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002829 OSPF_IF_PARAM (oi, v_wait),
2830 OSPF_IF_PARAM (oi, retransmit_interval),
2831 VTY_NEWLINE);
2832
2833 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002834 {
ajs649654a2005-11-16 20:17:52 +00002835 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002836 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002837 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002838 VTY_NEWLINE);
2839 }
paul718e3742002-12-13 20:15:29 +00002840 else /* OSPF_IF_PASSIVE is set */
2841 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2842
2843 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002844 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002845 VTY_NEWLINE);
2846 }
2847}
2848
2849DEFUN (show_ip_ospf_interface,
2850 show_ip_ospf_interface_cmd,
2851 "show ip ospf interface [INTERFACE]",
2852 SHOW_STR
2853 IP_STR
2854 "OSPF information\n"
2855 "Interface information\n"
2856 "Interface name\n")
2857{
2858 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002859 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002860 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002861
paul020709f2003-04-04 02:44:16 +00002862 ospf = ospf_lookup ();
2863
paul718e3742002-12-13 20:15:29 +00002864 /* Show All Interfaces. */
2865 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002866 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2867 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002868 /* Interface name is specified. */
2869 else
2870 {
2871 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2872 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2873 else
paul68980082003-03-25 05:07:42 +00002874 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002875 }
2876
2877 return CMD_SUCCESS;
2878}
2879
paul4dadc292005-05-06 21:37:42 +00002880static void
pauld24f6e22005-10-21 09:23:12 +00002881show_ip_ospf_neighbour_header (struct vty *vty)
2882{
2883 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2884 VTY_NEWLINE,
2885 "Neighbor ID", "Pri", "State", "Dead Time",
2886 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
2887 VTY_NEWLINE);
2888}
2889
2890static void
paul718e3742002-12-13 20:15:29 +00002891show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2892{
2893 struct route_node *rn;
2894 struct ospf_neighbor *nbr;
2895 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00002896 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002897
2898 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2899 if ((nbr = rn->info))
2900 /* Do not show myself. */
2901 if (nbr != oi->nbr_self)
2902 /* Down state is not shown. */
2903 if (nbr->state != NSM_Down)
2904 {
2905 ospf_nbr_state_message (nbr, msgbuf, 16);
2906
2907 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00002908 vty_out (vty, "%-15s %3d %-15s ",
2909 "-", nbr->priority,
2910 msgbuf);
2911 else
2912 vty_out (vty, "%-15s %3d %-15s ",
2913 inet_ntoa (nbr->router_id), nbr->priority,
2914 msgbuf);
2915
2916 vty_out (vty, "%9s ",
2917 ospf_timer_dump (nbr->t_inactivity, timebuf,
2918 sizeof(timebuf)));
2919
paul718e3742002-12-13 20:15:29 +00002920 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00002921 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00002922 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2923 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2924 VTY_NEWLINE);
2925 }
2926}
2927
2928DEFUN (show_ip_ospf_neighbor,
2929 show_ip_ospf_neighbor_cmd,
2930 "show ip ospf neighbor",
2931 SHOW_STR
2932 IP_STR
2933 "OSPF information\n"
2934 "Neighbor list\n")
2935{
paul020709f2003-04-04 02:44:16 +00002936 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002937 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002938 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002939
paul020709f2003-04-04 02:44:16 +00002940 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002941 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002942 {
2943 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2944 return CMD_SUCCESS;
2945 }
2946
pauld24f6e22005-10-21 09:23:12 +00002947 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00002948
paul1eb8ef22005-04-07 07:30:20 +00002949 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
2950 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00002951
2952 return CMD_SUCCESS;
2953}
2954
2955DEFUN (show_ip_ospf_neighbor_all,
2956 show_ip_ospf_neighbor_all_cmd,
2957 "show ip ospf neighbor all",
2958 SHOW_STR
2959 IP_STR
2960 "OSPF information\n"
2961 "Neighbor list\n"
2962 "include down status neighbor\n")
2963{
paul68980082003-03-25 05:07:42 +00002964 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002965 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002966 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002967
paul68980082003-03-25 05:07:42 +00002968 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002969 {
2970 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2971 return CMD_SUCCESS;
2972 }
pauld24f6e22005-10-21 09:23:12 +00002973
2974 show_ip_ospf_neighbour_header (vty);
2975
paul1eb8ef22005-04-07 07:30:20 +00002976 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00002977 {
hasso52dc7ee2004-09-23 19:18:23 +00002978 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00002979 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00002980
2981 show_ip_ospf_neighbor_sub (vty, oi);
2982
2983 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00002984 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00002985 {
paul718e3742002-12-13 20:15:29 +00002986 if (nbr_nbma->nbr == NULL
2987 || nbr_nbma->nbr->state == NSM_Down)
2988 {
pauld24f6e22005-10-21 09:23:12 +00002989 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00002990 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00002991 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00002992 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2993 0, 0, 0, VTY_NEWLINE);
2994 }
2995 }
2996 }
2997
2998 return CMD_SUCCESS;
2999}
3000
3001DEFUN (show_ip_ospf_neighbor_int,
3002 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003003 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003004 SHOW_STR
3005 IP_STR
3006 "OSPF information\n"
3007 "Neighbor list\n"
3008 "Interface name\n")
3009{
paul020709f2003-04-04 02:44:16 +00003010 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003011 struct interface *ifp;
3012 struct route_node *rn;
3013
3014 ifp = if_lookup_by_name (argv[0]);
3015 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003016 {
hassobb5b7552005-08-21 20:01:15 +00003017 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003018 return CMD_WARNING;
3019 }
3020
paul020709f2003-04-04 02:44:16 +00003021 ospf = ospf_lookup ();
3022 if (ospf == NULL)
3023 {
3024 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3025 return CMD_SUCCESS;
3026 }
pauld24f6e22005-10-21 09:23:12 +00003027
3028 show_ip_ospf_neighbour_header (vty);
3029
hassobb5b7552005-08-21 20:01:15 +00003030 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003031 {
hassobb5b7552005-08-21 20:01:15 +00003032 struct ospf_interface *oi = rn->info;
3033
3034 if (oi == NULL)
3035 continue;
3036
paul718e3742002-12-13 20:15:29 +00003037 show_ip_ospf_neighbor_sub (vty, oi);
3038 }
3039
3040 return CMD_SUCCESS;
3041}
3042
paul4dadc292005-05-06 21:37:42 +00003043static void
paul718e3742002-12-13 20:15:29 +00003044show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3045 struct ospf_nbr_nbma *nbr_nbma)
3046{
ajs649654a2005-11-16 20:17:52 +00003047 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003048
3049 /* Show neighbor ID. */
3050 vty_out (vty, " Neighbor %s,", "-");
3051
3052 /* Show interface address. */
3053 vty_out (vty, " interface address %s%s",
3054 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3055 /* Show Area ID. */
3056 vty_out (vty, " In the area %s via interface %s%s",
3057 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3058 /* Show neighbor priority and state. */
3059 vty_out (vty, " Neighbor priority is %d, State is %s,",
3060 nbr_nbma->priority, "Down");
3061 /* Show state changes. */
3062 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3063
3064 /* Show PollInterval */
3065 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3066
3067 /* Show poll-interval timer. */
3068 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003069 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3070 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003071
3072 /* Show poll-interval timer thread. */
3073 vty_out (vty, " Thread Poll Timer %s%s",
3074 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3075}
3076
paul4dadc292005-05-06 21:37:42 +00003077static void
paul718e3742002-12-13 20:15:29 +00003078show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3079 struct ospf_neighbor *nbr)
3080{
ajs649654a2005-11-16 20:17:52 +00003081 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003082
3083 /* Show neighbor ID. */
3084 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3085 vty_out (vty, " Neighbor %s,", "-");
3086 else
3087 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3088
3089 /* Show interface address. */
3090 vty_out (vty, " interface address %s%s",
3091 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3092 /* Show Area ID. */
3093 vty_out (vty, " In the area %s via interface %s%s",
3094 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3095 /* Show neighbor priority and state. */
3096 vty_out (vty, " Neighbor priority is %d, State is %s,",
3097 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3098 /* Show state changes. */
3099 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3100
3101 /* Show Designated Rotuer ID. */
3102 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3103 /* Show Backup Designated Rotuer ID. */
3104 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3105 /* Show options. */
3106 vty_out (vty, " Options %d %s%s", nbr->options,
3107 ospf_options_dump (nbr->options), VTY_NEWLINE);
3108 /* Show Router Dead interval timer. */
3109 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003110 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3111 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003112 /* Show Database Summary list. */
3113 vty_out (vty, " Database Summary List %d%s",
3114 ospf_db_summary_count (nbr), VTY_NEWLINE);
3115 /* Show Link State Request list. */
3116 vty_out (vty, " Link State Request List %ld%s",
3117 ospf_ls_request_count (nbr), VTY_NEWLINE);
3118 /* Show Link State Retransmission list. */
3119 vty_out (vty, " Link State Retransmission List %ld%s",
3120 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3121 /* Show inactivity timer thread. */
3122 vty_out (vty, " Thread Inactivity Timer %s%s",
3123 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3124 /* Show Database Description retransmission thread. */
3125 vty_out (vty, " Thread Database Description Retransmision %s%s",
3126 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3127 /* Show Link State Request Retransmission thread. */
3128 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3129 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3130 /* Show Link State Update Retransmission thread. */
3131 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3132 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3133}
3134
3135DEFUN (show_ip_ospf_neighbor_id,
3136 show_ip_ospf_neighbor_id_cmd,
3137 "show ip ospf neighbor A.B.C.D",
3138 SHOW_STR
3139 IP_STR
3140 "OSPF information\n"
3141 "Neighbor list\n"
3142 "Neighbor ID\n")
3143{
paul020709f2003-04-04 02:44:16 +00003144 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003145 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003146 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003147 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003148 struct in_addr router_id;
3149 int ret;
3150
3151 ret = inet_aton (argv[0], &router_id);
3152 if (!ret)
3153 {
3154 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3155 return CMD_WARNING;
3156 }
3157
paul020709f2003-04-04 02:44:16 +00003158 ospf = ospf_lookup ();
3159 if (ospf == NULL)
3160 {
3161 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3162 return CMD_SUCCESS;
3163 }
3164
paul1eb8ef22005-04-07 07:30:20 +00003165 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3166 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3167 {
3168 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3169 return CMD_SUCCESS;
3170 }
paul718e3742002-12-13 20:15:29 +00003171
3172 /* Nothing to show. */
3173 return CMD_SUCCESS;
3174}
3175
3176DEFUN (show_ip_ospf_neighbor_detail,
3177 show_ip_ospf_neighbor_detail_cmd,
3178 "show ip ospf neighbor detail",
3179 SHOW_STR
3180 IP_STR
3181 "OSPF information\n"
3182 "Neighbor list\n"
3183 "detail of all neighbors\n")
3184{
paul020709f2003-04-04 02:44:16 +00003185 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003186 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003187 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003188
paul020709f2003-04-04 02:44:16 +00003189 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003190 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003191 {
3192 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3193 return CMD_SUCCESS;
3194 }
paul718e3742002-12-13 20:15:29 +00003195
paul1eb8ef22005-04-07 07:30:20 +00003196 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003197 {
paul718e3742002-12-13 20:15:29 +00003198 struct route_node *rn;
3199 struct ospf_neighbor *nbr;
3200
3201 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3202 if ((nbr = rn->info))
3203 if (nbr != oi->nbr_self)
3204 if (nbr->state != NSM_Down)
3205 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3206 }
3207
3208 return CMD_SUCCESS;
3209}
3210
3211DEFUN (show_ip_ospf_neighbor_detail_all,
3212 show_ip_ospf_neighbor_detail_all_cmd,
3213 "show ip ospf neighbor detail all",
3214 SHOW_STR
3215 IP_STR
3216 "OSPF information\n"
3217 "Neighbor list\n"
3218 "detail of all neighbors\n"
3219 "include down status neighbor\n")
3220{
paul020709f2003-04-04 02:44:16 +00003221 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003222 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003223 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003224
paul020709f2003-04-04 02:44:16 +00003225 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003226 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003227 {
3228 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3229 return CMD_SUCCESS;
3230 }
paul718e3742002-12-13 20:15:29 +00003231
paul1eb8ef22005-04-07 07:30:20 +00003232 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003233 {
paul718e3742002-12-13 20:15:29 +00003234 struct route_node *rn;
3235 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003236 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003237
3238 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3239 if ((nbr = rn->info))
3240 if (nbr != oi->nbr_self)
3241 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3242 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3243
3244 if (oi->type == OSPF_IFTYPE_NBMA)
3245 {
hasso52dc7ee2004-09-23 19:18:23 +00003246 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003247
paul1eb8ef22005-04-07 07:30:20 +00003248 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3249 if (nbr_nbma->nbr == NULL
3250 || nbr_nbma->nbr->state == NSM_Down)
3251 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003252 }
3253 }
3254
3255 return CMD_SUCCESS;
3256}
3257
3258DEFUN (show_ip_ospf_neighbor_int_detail,
3259 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003260 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003261 SHOW_STR
3262 IP_STR
3263 "OSPF information\n"
3264 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003265 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003266 "detail of all neighbors")
3267{
paul020709f2003-04-04 02:44:16 +00003268 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003269 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003270 struct interface *ifp;
3271 struct route_node *rn, *nrn;
3272 struct ospf_neighbor *nbr;
3273
3274 ifp = if_lookup_by_name (argv[0]);
3275 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003276 {
hassobb5b7552005-08-21 20:01:15 +00003277 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003278 return CMD_WARNING;
3279 }
3280
paul020709f2003-04-04 02:44:16 +00003281 ospf = ospf_lookup ();
3282 if (ospf == NULL)
3283 {
3284 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3285 return CMD_SUCCESS;
3286 }
paul68980082003-03-25 05:07:42 +00003287
paul718e3742002-12-13 20:15:29 +00003288
hassobb5b7552005-08-21 20:01:15 +00003289 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3290 if ((oi = rn->info))
3291 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3292 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003293 if (nbr != oi->nbr_self)
3294 if (nbr->state != NSM_Down)
3295 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003296
3297 return CMD_SUCCESS;
3298}
3299
3300
3301/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003302static int
paul020709f2003-04-04 02:44:16 +00003303show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003304{
paul718e3742002-12-13 20:15:29 +00003305 struct router_lsa *rl;
3306 struct summary_lsa *sl;
3307 struct as_external_lsa *asel;
3308 struct prefix_ipv4 p;
3309
3310 if (lsa != NULL)
3311 /* If self option is set, check LSA self flag. */
3312 if (self == 0 || IS_LSA_SELF (lsa))
3313 {
3314 /* LSA common part show. */
3315 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3316 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3317 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3318 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3319 /* LSA specific part show. */
3320 switch (lsa->data->type)
3321 {
3322 case OSPF_ROUTER_LSA:
3323 rl = (struct router_lsa *) lsa->data;
3324 vty_out (vty, " %-d", ntohs (rl->links));
3325 break;
3326 case OSPF_SUMMARY_LSA:
3327 sl = (struct summary_lsa *) lsa->data;
3328
3329 p.family = AF_INET;
3330 p.prefix = sl->header.id;
3331 p.prefixlen = ip_masklen (sl->mask);
3332 apply_mask_ipv4 (&p);
3333
3334 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3335 break;
3336 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003337 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003338 asel = (struct as_external_lsa *) lsa->data;
3339
3340 p.family = AF_INET;
3341 p.prefix = asel->header.id;
3342 p.prefixlen = ip_masklen (asel->mask);
3343 apply_mask_ipv4 (&p);
3344
3345 vty_out (vty, " %s %s/%d [0x%lx]",
3346 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3347 inet_ntoa (p.prefix), p.prefixlen,
3348 (u_long)ntohl (asel->e[0].route_tag));
3349 break;
3350 case OSPF_NETWORK_LSA:
3351 case OSPF_ASBR_SUMMARY_LSA:
3352#ifdef HAVE_OPAQUE_LSA
3353 case OSPF_OPAQUE_LINK_LSA:
3354 case OSPF_OPAQUE_AREA_LSA:
3355 case OSPF_OPAQUE_AS_LSA:
3356#endif /* HAVE_OPAQUE_LSA */
3357 default:
3358 break;
3359 }
3360 vty_out (vty, VTY_NEWLINE);
3361 }
3362
3363 return 0;
3364}
3365
hassoeb1ce602004-10-08 08:17:22 +00003366const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003367{
3368 "unknown",
3369 "Router Link States",
3370 "Net Link States",
3371 "Summary Link States",
3372 "ASBR-Summary Link States",
3373 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003374 "Group Membership LSA",
3375 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003376#ifdef HAVE_OPAQUE_LSA
3377 "Type-8 LSA",
3378 "Link-Local Opaque-LSA",
3379 "Area-Local Opaque-LSA",
3380 "AS-external Opaque-LSA",
3381#endif /* HAVE_OPAQUE_LSA */
3382};
3383
3384#define SHOW_OSPF_COMMON_HEADER \
3385 "Link ID ADV Router Age Seq# CkSum"
3386
hassoeb1ce602004-10-08 08:17:22 +00003387const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003388{
3389 "",
3390 "Link ID ADV Router Age Seq# CkSum Link count",
3391 "Link ID ADV Router Age Seq# CkSum",
3392 "Link ID ADV Router Age Seq# CkSum Route",
3393 "Link ID ADV Router Age Seq# CkSum",
3394 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003395 " --- header for Group Member ----",
3396 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003397#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003398 " --- type-8 ---",
3399 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3400 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3401 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3402#endif /* HAVE_OPAQUE_LSA */
3403};
3404
hassoeb1ce602004-10-08 08:17:22 +00003405const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003406{
3407 "Self-originated",
3408 "Checked",
3409 "Received",
3410 "Approved",
3411 "Discard",
paul4957f492003-06-27 01:28:45 +00003412 "Translated",
paul4957f492003-06-27 01:28:45 +00003413};
3414
paul4dadc292005-05-06 21:37:42 +00003415static void
paul718e3742002-12-13 20:15:29 +00003416show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3417{
3418 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003419
paul718e3742002-12-13 20:15:29 +00003420 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003421 vty_out (vty, " Options: 0x%-2x : %s%s",
3422 lsa->data->options,
3423 ospf_options_dump(lsa->data->options),
3424 VTY_NEWLINE);
3425 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003426 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003427 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3428 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003429
3430 if (lsa->data->type == OSPF_ROUTER_LSA)
3431 {
3432 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3433
3434 if (rlsa->flags)
3435 vty_out (vty, " :%s%s%s%s",
3436 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3437 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3438 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3439 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3440
3441 vty_out (vty, "%s", VTY_NEWLINE);
3442 }
3443 vty_out (vty, " LS Type: %s%s",
3444 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3445 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3446 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3447 vty_out (vty, " Advertising Router: %s%s",
3448 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3449 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3450 VTY_NEWLINE);
3451 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3452 VTY_NEWLINE);
3453 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3454}
3455
hassoeb1ce602004-10-08 08:17:22 +00003456const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003457{
3458 "(null)",
3459 "another Router (point-to-point)",
3460 "a Transit Network",
3461 "Stub Network",
3462 "a Virtual Link",
3463};
3464
hassoeb1ce602004-10-08 08:17:22 +00003465const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003466{
3467 "(null)",
3468 "Neighboring Router ID",
3469 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003470 "Net",
paul718e3742002-12-13 20:15:29 +00003471 "Neighboring Router ID",
3472};
3473
hassoeb1ce602004-10-08 08:17:22 +00003474const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003475{
3476 "(null)",
3477 "Router Interface address",
3478 "Router Interface address",
3479 "Network Mask",
3480 "Router Interface address",
3481};
3482
3483/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003484static void
paul718e3742002-12-13 20:15:29 +00003485show_ip_ospf_database_router_links (struct vty *vty,
3486 struct router_lsa *rl)
3487{
3488 int len, i, type;
3489
3490 len = ntohs (rl->header.length) - 4;
3491 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3492 {
3493 type = rl->link[i].type;
3494
3495 vty_out (vty, " Link connected to: %s%s",
3496 link_type_desc[type], VTY_NEWLINE);
3497 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3498 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3499 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3500 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3501 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3502 vty_out (vty, " TOS 0 Metric: %d%s",
3503 ntohs (rl->link[i].metric), VTY_NEWLINE);
3504 vty_out (vty, "%s", VTY_NEWLINE);
3505 }
3506}
3507
3508/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003509static int
paul718e3742002-12-13 20:15:29 +00003510show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3511{
3512 if (lsa != NULL)
3513 {
3514 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3515
3516 show_ip_ospf_database_header (vty, lsa);
3517
3518 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3519 VTY_NEWLINE, VTY_NEWLINE);
3520
3521 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003522 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003523 }
3524
3525 return 0;
3526}
3527
3528/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003529static int
paul718e3742002-12-13 20:15:29 +00003530show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3531{
3532 int length, i;
3533
3534 if (lsa != NULL)
3535 {
3536 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3537
3538 show_ip_ospf_database_header (vty, lsa);
3539
3540 vty_out (vty, " Network Mask: /%d%s",
3541 ip_masklen (nl->mask), VTY_NEWLINE);
3542
3543 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3544
3545 for (i = 0; length > 0; i++, length -= 4)
3546 vty_out (vty, " Attached Router: %s%s",
3547 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3548
3549 vty_out (vty, "%s", VTY_NEWLINE);
3550 }
3551
3552 return 0;
3553}
3554
3555/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003556static int
paul718e3742002-12-13 20:15:29 +00003557show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3558{
3559 if (lsa != NULL)
3560 {
3561 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3562
3563 show_ip_ospf_database_header (vty, lsa);
3564
3565 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3566 VTY_NEWLINE);
3567 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3568 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003569 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003570 }
3571
3572 return 0;
3573}
3574
3575/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003576static int
paul718e3742002-12-13 20:15:29 +00003577show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3578{
3579 if (lsa != NULL)
3580 {
3581 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3582
3583 show_ip_ospf_database_header (vty, lsa);
3584
3585 vty_out (vty, " Network Mask: /%d%s",
3586 ip_masklen (sl->mask), VTY_NEWLINE);
3587 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3588 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003589 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003590 }
3591
3592 return 0;
3593}
3594
3595/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003596static int
paul718e3742002-12-13 20:15:29 +00003597show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3598{
3599 if (lsa != NULL)
3600 {
3601 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3602
3603 show_ip_ospf_database_header (vty, lsa);
3604
3605 vty_out (vty, " Network Mask: /%d%s",
3606 ip_masklen (al->mask), VTY_NEWLINE);
3607 vty_out (vty, " Metric Type: %s%s",
3608 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3609 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3610 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3611 vty_out (vty, " Metric: %d%s",
3612 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3613 vty_out (vty, " Forward Address: %s%s",
3614 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3615
3616 vty_out (vty, " External Route Tag: %lu%s%s",
3617 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3618 }
3619
3620 return 0;
3621}
3622
ajs2a42e282004-12-08 18:43:03 +00003623/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003624static int
paul718e3742002-12-13 20:15:29 +00003625show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3626{
3627 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3628
3629 /* show_ip_ospf_database_header (vty, lsa); */
3630
ajs2a42e282004-12-08 18:43:03 +00003631 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003632 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003633 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003634 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3635 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003636 zlog_debug( " TOS: 0%s", "\n");
3637 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003638 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003639 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003640 inet_ntoa (al->e[0].fwd_addr), "\n");
3641
ajs2a42e282004-12-08 18:43:03 +00003642 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003643 ntohl (al->e[0].route_tag), "\n", "\n");
3644
3645 return 0;
3646}
3647
3648/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003649static int
paul718e3742002-12-13 20:15:29 +00003650show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3651{
3652 if (lsa != NULL)
3653 {
3654 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3655
3656 show_ip_ospf_database_header (vty, lsa);
3657
3658 vty_out (vty, " Network Mask: /%d%s",
3659 ip_masklen (al->mask), VTY_NEWLINE);
3660 vty_out (vty, " Metric Type: %s%s",
3661 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3662 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3663 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3664 vty_out (vty, " Metric: %d%s",
3665 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3666 vty_out (vty, " NSSA: Forward Address: %s%s",
3667 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3668
3669 vty_out (vty, " External Route Tag: %u%s%s",
3670 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3671 }
3672
3673 return 0;
3674}
3675
paul4dadc292005-05-06 21:37:42 +00003676static int
paul718e3742002-12-13 20:15:29 +00003677show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3678{
3679 return 0;
3680}
3681
3682#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003683static int
paul718e3742002-12-13 20:15:29 +00003684show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3685{
3686 if (lsa != NULL)
3687 {
3688 show_ip_ospf_database_header (vty, lsa);
3689 show_opaque_info_detail (vty, lsa);
3690
3691 vty_out (vty, "%s", VTY_NEWLINE);
3692 }
3693 return 0;
3694}
3695#endif /* HAVE_OPAQUE_LSA */
3696
3697int (*show_function[])(struct vty *, struct ospf_lsa *) =
3698{
3699 NULL,
3700 show_router_lsa_detail,
3701 show_network_lsa_detail,
3702 show_summary_lsa_detail,
3703 show_summary_asbr_lsa_detail,
3704 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003705 show_func_dummy,
3706 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003707#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003708 NULL, /* type-8 */
3709 show_opaque_lsa_detail,
3710 show_opaque_lsa_detail,
3711 show_opaque_lsa_detail,
3712#endif /* HAVE_OPAQUE_LSA */
3713};
3714
paul4dadc292005-05-06 21:37:42 +00003715static void
paul718e3742002-12-13 20:15:29 +00003716show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3717 struct in_addr *adv_router)
3718{
3719 memset (lp, 0, sizeof (struct prefix_ls));
3720 lp->family = 0;
3721 if (id == NULL)
3722 lp->prefixlen = 0;
3723 else if (adv_router == NULL)
3724 {
3725 lp->prefixlen = 32;
3726 lp->id = *id;
3727 }
3728 else
3729 {
3730 lp->prefixlen = 64;
3731 lp->id = *id;
3732 lp->adv_router = *adv_router;
3733 }
3734}
3735
paul4dadc292005-05-06 21:37:42 +00003736static void
paul718e3742002-12-13 20:15:29 +00003737show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3738 struct in_addr *id, struct in_addr *adv_router)
3739{
3740 struct prefix_ls lp;
3741 struct route_node *rn, *start;
3742 struct ospf_lsa *lsa;
3743
3744 show_lsa_prefix_set (vty, &lp, id, adv_router);
3745 start = route_node_get (rt, (struct prefix *) &lp);
3746 if (start)
3747 {
3748 route_lock_node (start);
3749 for (rn = start; rn; rn = route_next_until (rn, start))
3750 if ((lsa = rn->info))
3751 {
paul718e3742002-12-13 20:15:29 +00003752 if (show_function[lsa->data->type] != NULL)
3753 show_function[lsa->data->type] (vty, lsa);
3754 }
3755 route_unlock_node (start);
3756 }
3757}
3758
3759/* Show detail LSA information
3760 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003761static void
paul020709f2003-04-04 02:44:16 +00003762show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003763 struct in_addr *id, struct in_addr *adv_router)
3764{
hasso52dc7ee2004-09-23 19:18:23 +00003765 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003766 struct ospf_area *area;
3767
paul718e3742002-12-13 20:15:29 +00003768 switch (type)
3769 {
3770 case OSPF_AS_EXTERNAL_LSA:
3771#ifdef HAVE_OPAQUE_LSA
3772 case OSPF_OPAQUE_AS_LSA:
3773#endif /* HAVE_OPAQUE_LSA */
3774 vty_out (vty, " %s %s%s",
3775 show_database_desc[type],
3776 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003777 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003778 break;
3779 default:
paul1eb8ef22005-04-07 07:30:20 +00003780 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003781 {
paul718e3742002-12-13 20:15:29 +00003782 vty_out (vty, "%s %s (Area %s)%s%s",
3783 VTY_NEWLINE, show_database_desc[type],
3784 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3785 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3786 }
3787 break;
3788 }
3789}
3790
paul4dadc292005-05-06 21:37:42 +00003791static void
paul718e3742002-12-13 20:15:29 +00003792show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3793 struct in_addr *adv_router)
3794{
3795 struct route_node *rn;
3796 struct ospf_lsa *lsa;
3797
3798 for (rn = route_top (rt); rn; rn = route_next (rn))
3799 if ((lsa = rn->info))
3800 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3801 {
paul718e3742002-12-13 20:15:29 +00003802 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3803 continue;
paul718e3742002-12-13 20:15:29 +00003804 if (show_function[lsa->data->type] != NULL)
3805 show_function[lsa->data->type] (vty, lsa);
3806 }
3807}
3808
3809/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003810static void
paul020709f2003-04-04 02:44:16 +00003811show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003812 struct in_addr *adv_router)
3813{
hasso52dc7ee2004-09-23 19:18:23 +00003814 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003815 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003816
3817 switch (type)
3818 {
3819 case OSPF_AS_EXTERNAL_LSA:
3820#ifdef HAVE_OPAQUE_LSA
3821 case OSPF_OPAQUE_AS_LSA:
3822#endif /* HAVE_OPAQUE_LSA */
3823 vty_out (vty, " %s %s%s",
3824 show_database_desc[type],
3825 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003826 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003827 adv_router);
3828 break;
3829 default:
paul1eb8ef22005-04-07 07:30:20 +00003830 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003831 {
paul718e3742002-12-13 20:15:29 +00003832 vty_out (vty, "%s %s (Area %s)%s%s",
3833 VTY_NEWLINE, show_database_desc[type],
3834 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3835 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3836 adv_router);
3837 }
3838 break;
3839 }
3840}
3841
paul4dadc292005-05-06 21:37:42 +00003842static void
paul020709f2003-04-04 02:44:16 +00003843show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003844{
paul020709f2003-04-04 02:44:16 +00003845 struct ospf_lsa *lsa;
3846 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003847 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003848 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003849 int type;
3850
paul1eb8ef22005-04-07 07:30:20 +00003851 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003852 {
paul718e3742002-12-13 20:15:29 +00003853 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3854 {
3855 switch (type)
3856 {
3857 case OSPF_AS_EXTERNAL_LSA:
3858#ifdef HAVE_OPAQUE_LSA
3859 case OSPF_OPAQUE_AS_LSA:
3860#endif /* HAVE_OPAQUE_LSA */
3861 continue;
3862 default:
3863 break;
3864 }
3865 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3866 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3867 {
3868 vty_out (vty, " %s (Area %s)%s%s",
3869 show_database_desc[type],
3870 ospf_area_desc_string (area),
3871 VTY_NEWLINE, VTY_NEWLINE);
3872 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3873
paul020709f2003-04-04 02:44:16 +00003874 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3875 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003876
3877 vty_out (vty, "%s", VTY_NEWLINE);
3878 }
3879 }
3880 }
3881
3882 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3883 {
3884 switch (type)
3885 {
3886 case OSPF_AS_EXTERNAL_LSA:
3887#ifdef HAVE_OPAQUE_LSA
3888 case OSPF_OPAQUE_AS_LSA:
3889#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00003890 break;
paul718e3742002-12-13 20:15:29 +00003891 default:
3892 continue;
3893 }
paul68980082003-03-25 05:07:42 +00003894 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3895 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003896 {
3897 vty_out (vty, " %s%s%s",
3898 show_database_desc[type],
3899 VTY_NEWLINE, VTY_NEWLINE);
3900 vty_out (vty, "%s%s", show_database_header[type],
3901 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003902
3903 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3904 show_lsa_summary (vty, lsa, self);
3905
paul718e3742002-12-13 20:15:29 +00003906 vty_out (vty, "%s", VTY_NEWLINE);
3907 }
3908 }
3909
3910 vty_out (vty, "%s", VTY_NEWLINE);
3911}
3912
paul4dadc292005-05-06 21:37:42 +00003913static void
paul020709f2003-04-04 02:44:16 +00003914show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003915{
hasso52dc7ee2004-09-23 19:18:23 +00003916 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003917 struct ospf_lsa *lsa;
3918
3919 vty_out (vty, "%s MaxAge Link States:%s%s",
3920 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3921
paul1eb8ef22005-04-07 07:30:20 +00003922 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3923 {
3924 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3925 vty_out (vty, "Link State ID: %s%s",
3926 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3927 vty_out (vty, "Advertising Router: %s%s",
3928 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3929 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3930 vty_out (vty, "%s", VTY_NEWLINE);
3931 }
paul718e3742002-12-13 20:15:29 +00003932}
3933
paul718e3742002-12-13 20:15:29 +00003934#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3935#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003936
3937#ifdef HAVE_OPAQUE_LSA
3938#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3939#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3940#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3941#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3942#else /* HAVE_OPAQUE_LSA */
3943#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3944#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3945#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3946#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3947#endif /* HAVE_OPAQUE_LSA */
3948
3949#define OSPF_LSA_TYPES_CMD_STR \
3950 "asbr-summary|external|network|router|summary" \
3951 OSPF_LSA_TYPE_NSSA_CMD_STR \
3952 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3953
3954#define OSPF_LSA_TYPES_DESC \
3955 "ASBR summary link states\n" \
3956 "External link states\n" \
3957 "Network link states\n" \
3958 "Router link states\n" \
3959 "Network summary link states\n" \
3960 OSPF_LSA_TYPE_NSSA_DESC \
3961 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3962 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3963 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3964
3965DEFUN (show_ip_ospf_database,
3966 show_ip_ospf_database_cmd,
3967 "show ip ospf database",
3968 SHOW_STR
3969 IP_STR
3970 "OSPF information\n"
3971 "Database summary\n")
3972{
paul020709f2003-04-04 02:44:16 +00003973 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003974 int type, ret;
3975 struct in_addr id, adv_router;
3976
paul020709f2003-04-04 02:44:16 +00003977 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003978 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003979 return CMD_SUCCESS;
3980
3981 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003982 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003983
3984 /* Show all LSA. */
3985 if (argc == 0)
3986 {
paul020709f2003-04-04 02:44:16 +00003987 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003988 return CMD_SUCCESS;
3989 }
3990
3991 /* Set database type to show. */
3992 if (strncmp (argv[0], "r", 1) == 0)
3993 type = OSPF_ROUTER_LSA;
3994 else if (strncmp (argv[0], "ne", 2) == 0)
3995 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003996 else if (strncmp (argv[0], "ns", 2) == 0)
3997 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003998 else if (strncmp (argv[0], "su", 2) == 0)
3999 type = OSPF_SUMMARY_LSA;
4000 else if (strncmp (argv[0], "a", 1) == 0)
4001 type = OSPF_ASBR_SUMMARY_LSA;
4002 else if (strncmp (argv[0], "e", 1) == 0)
4003 type = OSPF_AS_EXTERNAL_LSA;
4004 else if (strncmp (argv[0], "se", 2) == 0)
4005 {
paul020709f2003-04-04 02:44:16 +00004006 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004007 return CMD_SUCCESS;
4008 }
4009 else if (strncmp (argv[0], "m", 1) == 0)
4010 {
paul020709f2003-04-04 02:44:16 +00004011 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004012 return CMD_SUCCESS;
4013 }
4014#ifdef HAVE_OPAQUE_LSA
4015 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4016 type = OSPF_OPAQUE_LINK_LSA;
4017 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4018 type = OSPF_OPAQUE_AREA_LSA;
4019 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4020 type = OSPF_OPAQUE_AS_LSA;
4021#endif /* HAVE_OPAQUE_LSA */
4022 else
4023 return CMD_WARNING;
4024
4025 /* `show ip ospf database LSA'. */
4026 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004027 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004028 else if (argc >= 2)
4029 {
4030 ret = inet_aton (argv[1], &id);
4031 if (!ret)
4032 return CMD_WARNING;
4033
4034 /* `show ip ospf database LSA ID'. */
4035 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004036 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004037 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4038 else if (argc == 3)
4039 {
4040 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004041 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004042 else
4043 {
4044 ret = inet_aton (argv[2], &adv_router);
4045 if (!ret)
4046 return CMD_WARNING;
4047 }
paul020709f2003-04-04 02:44:16 +00004048 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004049 }
4050 }
4051
4052 return CMD_SUCCESS;
4053}
4054
4055ALIAS (show_ip_ospf_database,
4056 show_ip_ospf_database_type_cmd,
4057 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4058 SHOW_STR
4059 IP_STR
4060 "OSPF information\n"
4061 "Database summary\n"
4062 OSPF_LSA_TYPES_DESC
4063 "LSAs in MaxAge list\n"
4064 "Self-originated link states\n")
4065
4066ALIAS (show_ip_ospf_database,
4067 show_ip_ospf_database_type_id_cmd,
4068 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4069 SHOW_STR
4070 IP_STR
4071 "OSPF information\n"
4072 "Database summary\n"
4073 OSPF_LSA_TYPES_DESC
4074 "Link State ID (as an IP address)\n")
4075
4076ALIAS (show_ip_ospf_database,
4077 show_ip_ospf_database_type_id_adv_router_cmd,
4078 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4079 SHOW_STR
4080 IP_STR
4081 "OSPF information\n"
4082 "Database summary\n"
4083 OSPF_LSA_TYPES_DESC
4084 "Link State ID (as an IP address)\n"
4085 "Advertising Router link states\n"
4086 "Advertising Router (as an IP address)\n")
4087
4088ALIAS (show_ip_ospf_database,
4089 show_ip_ospf_database_type_id_self_cmd,
4090 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4091 SHOW_STR
4092 IP_STR
4093 "OSPF information\n"
4094 "Database summary\n"
4095 OSPF_LSA_TYPES_DESC
4096 "Link State ID (as an IP address)\n"
4097 "Self-originated link states\n"
4098 "\n")
4099
4100DEFUN (show_ip_ospf_database_type_adv_router,
4101 show_ip_ospf_database_type_adv_router_cmd,
4102 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4103 SHOW_STR
4104 IP_STR
4105 "OSPF information\n"
4106 "Database summary\n"
4107 OSPF_LSA_TYPES_DESC
4108 "Advertising Router link states\n"
4109 "Advertising Router (as an IP address)\n")
4110{
paul020709f2003-04-04 02:44:16 +00004111 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004112 int type, ret;
4113 struct in_addr adv_router;
4114
paul020709f2003-04-04 02:44:16 +00004115 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004116 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00004117 return CMD_SUCCESS;
4118
4119 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004120 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004121
4122 if (argc != 2)
4123 return CMD_WARNING;
4124
4125 /* Set database type to show. */
4126 if (strncmp (argv[0], "r", 1) == 0)
4127 type = OSPF_ROUTER_LSA;
4128 else if (strncmp (argv[0], "ne", 2) == 0)
4129 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004130 else if (strncmp (argv[0], "ns", 2) == 0)
4131 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004132 else if (strncmp (argv[0], "s", 1) == 0)
4133 type = OSPF_SUMMARY_LSA;
4134 else if (strncmp (argv[0], "a", 1) == 0)
4135 type = OSPF_ASBR_SUMMARY_LSA;
4136 else if (strncmp (argv[0], "e", 1) == 0)
4137 type = OSPF_AS_EXTERNAL_LSA;
4138#ifdef HAVE_OPAQUE_LSA
4139 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4140 type = OSPF_OPAQUE_LINK_LSA;
4141 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4142 type = OSPF_OPAQUE_AREA_LSA;
4143 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4144 type = OSPF_OPAQUE_AS_LSA;
4145#endif /* HAVE_OPAQUE_LSA */
4146 else
4147 return CMD_WARNING;
4148
4149 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4150 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004151 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004152 else
4153 {
4154 ret = inet_aton (argv[1], &adv_router);
4155 if (!ret)
4156 return CMD_WARNING;
4157 }
4158
paul020709f2003-04-04 02:44:16 +00004159 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004160
4161 return CMD_SUCCESS;
4162}
4163
4164ALIAS (show_ip_ospf_database_type_adv_router,
4165 show_ip_ospf_database_type_self_cmd,
4166 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4167 SHOW_STR
4168 IP_STR
4169 "OSPF information\n"
4170 "Database summary\n"
4171 OSPF_LSA_TYPES_DESC
4172 "Self-originated link states\n")
4173
4174
4175DEFUN (ip_ospf_authentication_args,
4176 ip_ospf_authentication_args_addr_cmd,
4177 "ip ospf authentication (null|message-digest) A.B.C.D",
4178 "IP Information\n"
4179 "OSPF interface commands\n"
4180 "Enable authentication on this interface\n"
4181 "Use null authentication\n"
4182 "Use message-digest authentication\n"
4183 "Address of interface")
4184{
4185 struct interface *ifp;
4186 struct in_addr addr;
4187 int ret;
4188 struct ospf_if_params *params;
4189
4190 ifp = vty->index;
4191 params = IF_DEF_PARAMS (ifp);
4192
4193 if (argc == 2)
4194 {
4195 ret = inet_aton(argv[1], &addr);
4196 if (!ret)
4197 {
4198 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4199 VTY_NEWLINE);
4200 return CMD_WARNING;
4201 }
4202
4203 params = ospf_get_if_params (ifp, addr);
4204 ospf_if_update_params (ifp, addr);
4205 }
4206
4207 /* Handle null authentication */
4208 if ( argv[0][0] == 'n' )
4209 {
4210 SET_IF_PARAM (params, auth_type);
4211 params->auth_type = OSPF_AUTH_NULL;
4212 return CMD_SUCCESS;
4213 }
4214
4215 /* Handle message-digest authentication */
4216 if ( argv[0][0] == 'm' )
4217 {
4218 SET_IF_PARAM (params, auth_type);
4219 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4220 return CMD_SUCCESS;
4221 }
4222
4223 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4224 return CMD_WARNING;
4225}
4226
4227ALIAS (ip_ospf_authentication_args,
4228 ip_ospf_authentication_args_cmd,
4229 "ip ospf authentication (null|message-digest)",
4230 "IP Information\n"
4231 "OSPF interface commands\n"
4232 "Enable authentication on this interface\n"
4233 "Use null authentication\n"
4234 "Use message-digest authentication\n")
4235
4236DEFUN (ip_ospf_authentication,
4237 ip_ospf_authentication_addr_cmd,
4238 "ip ospf authentication A.B.C.D",
4239 "IP Information\n"
4240 "OSPF interface commands\n"
4241 "Enable authentication on this interface\n"
4242 "Address of interface")
4243{
4244 struct interface *ifp;
4245 struct in_addr addr;
4246 int ret;
4247 struct ospf_if_params *params;
4248
4249 ifp = vty->index;
4250 params = IF_DEF_PARAMS (ifp);
4251
4252 if (argc == 1)
4253 {
4254 ret = inet_aton(argv[1], &addr);
4255 if (!ret)
4256 {
4257 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4258 VTY_NEWLINE);
4259 return CMD_WARNING;
4260 }
4261
4262 params = ospf_get_if_params (ifp, addr);
4263 ospf_if_update_params (ifp, addr);
4264 }
4265
4266 SET_IF_PARAM (params, auth_type);
4267 params->auth_type = OSPF_AUTH_SIMPLE;
4268
4269 return CMD_SUCCESS;
4270}
4271
4272ALIAS (ip_ospf_authentication,
4273 ip_ospf_authentication_cmd,
4274 "ip ospf authentication",
4275 "IP Information\n"
4276 "OSPF interface commands\n"
4277 "Enable authentication on this interface\n")
4278
4279DEFUN (no_ip_ospf_authentication,
4280 no_ip_ospf_authentication_addr_cmd,
4281 "no ip ospf authentication A.B.C.D",
4282 NO_STR
4283 "IP Information\n"
4284 "OSPF interface commands\n"
4285 "Enable authentication on this interface\n"
4286 "Address of interface")
4287{
4288 struct interface *ifp;
4289 struct in_addr addr;
4290 int ret;
4291 struct ospf_if_params *params;
4292
4293 ifp = vty->index;
4294 params = IF_DEF_PARAMS (ifp);
4295
4296 if (argc == 1)
4297 {
4298 ret = inet_aton(argv[1], &addr);
4299 if (!ret)
4300 {
4301 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4302 VTY_NEWLINE);
4303 return CMD_WARNING;
4304 }
4305
4306 params = ospf_lookup_if_params (ifp, addr);
4307 if (params == NULL)
4308 return CMD_SUCCESS;
4309 }
4310
4311 params->auth_type = OSPF_AUTH_NOTSET;
4312 UNSET_IF_PARAM (params, auth_type);
4313
4314 if (params != IF_DEF_PARAMS (ifp))
4315 {
4316 ospf_free_if_params (ifp, addr);
4317 ospf_if_update_params (ifp, addr);
4318 }
4319
4320 return CMD_SUCCESS;
4321}
4322
4323ALIAS (no_ip_ospf_authentication,
4324 no_ip_ospf_authentication_cmd,
4325 "no ip ospf authentication",
4326 NO_STR
4327 "IP Information\n"
4328 "OSPF interface commands\n"
4329 "Enable authentication on this interface\n")
4330
4331DEFUN (ip_ospf_authentication_key,
4332 ip_ospf_authentication_key_addr_cmd,
4333 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4334 "IP Information\n"
4335 "OSPF interface commands\n"
4336 "Authentication password (key)\n"
4337 "The OSPF password (key)\n"
4338 "Address of interface")
4339{
4340 struct interface *ifp;
4341 struct in_addr addr;
4342 int ret;
4343 struct ospf_if_params *params;
4344
4345 ifp = vty->index;
4346 params = IF_DEF_PARAMS (ifp);
4347
4348 if (argc == 2)
4349 {
4350 ret = inet_aton(argv[1], &addr);
4351 if (!ret)
4352 {
4353 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4354 VTY_NEWLINE);
4355 return CMD_WARNING;
4356 }
4357
4358 params = ospf_get_if_params (ifp, addr);
4359 ospf_if_update_params (ifp, addr);
4360 }
4361
4362
4363 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004364 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004365 SET_IF_PARAM (params, auth_simple);
4366
4367 return CMD_SUCCESS;
4368}
4369
4370ALIAS (ip_ospf_authentication_key,
4371 ip_ospf_authentication_key_cmd,
4372 "ip ospf authentication-key AUTH_KEY",
4373 "IP Information\n"
4374 "OSPF interface commands\n"
4375 "Authentication password (key)\n"
4376 "The OSPF password (key)")
4377
4378ALIAS (ip_ospf_authentication_key,
4379 ospf_authentication_key_cmd,
4380 "ospf authentication-key AUTH_KEY",
4381 "OSPF interface commands\n"
4382 "Authentication password (key)\n"
4383 "The OSPF password (key)")
4384
4385DEFUN (no_ip_ospf_authentication_key,
4386 no_ip_ospf_authentication_key_addr_cmd,
4387 "no ip ospf authentication-key A.B.C.D",
4388 NO_STR
4389 "IP Information\n"
4390 "OSPF interface commands\n"
4391 "Authentication password (key)\n"
4392 "Address of interface")
4393{
4394 struct interface *ifp;
4395 struct in_addr addr;
4396 int ret;
4397 struct ospf_if_params *params;
4398
4399 ifp = vty->index;
4400 params = IF_DEF_PARAMS (ifp);
4401
4402 if (argc == 2)
4403 {
4404 ret = inet_aton(argv[1], &addr);
4405 if (!ret)
4406 {
4407 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4408 VTY_NEWLINE);
4409 return CMD_WARNING;
4410 }
4411
4412 params = ospf_lookup_if_params (ifp, addr);
4413 if (params == NULL)
4414 return CMD_SUCCESS;
4415 }
4416
4417 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4418 UNSET_IF_PARAM (params, auth_simple);
4419
4420 if (params != IF_DEF_PARAMS (ifp))
4421 {
4422 ospf_free_if_params (ifp, addr);
4423 ospf_if_update_params (ifp, addr);
4424 }
4425
4426 return CMD_SUCCESS;
4427}
4428
4429ALIAS (no_ip_ospf_authentication_key,
4430 no_ip_ospf_authentication_key_cmd,
4431 "no ip ospf authentication-key",
4432 NO_STR
4433 "IP Information\n"
4434 "OSPF interface commands\n"
4435 "Authentication password (key)\n")
4436
4437ALIAS (no_ip_ospf_authentication_key,
4438 no_ospf_authentication_key_cmd,
4439 "no ospf authentication-key",
4440 NO_STR
4441 "OSPF interface commands\n"
4442 "Authentication password (key)\n")
4443
4444DEFUN (ip_ospf_message_digest_key,
4445 ip_ospf_message_digest_key_addr_cmd,
4446 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4447 "IP Information\n"
4448 "OSPF interface commands\n"
4449 "Message digest authentication password (key)\n"
4450 "Key ID\n"
4451 "Use MD5 algorithm\n"
4452 "The OSPF password (key)"
4453 "Address of interface")
4454{
4455 struct interface *ifp;
4456 struct crypt_key *ck;
4457 u_char key_id;
4458 struct in_addr addr;
4459 int ret;
4460 struct ospf_if_params *params;
4461
4462 ifp = vty->index;
4463 params = IF_DEF_PARAMS (ifp);
4464
4465 if (argc == 3)
4466 {
4467 ret = inet_aton(argv[2], &addr);
4468 if (!ret)
4469 {
4470 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4471 VTY_NEWLINE);
4472 return CMD_WARNING;
4473 }
4474
4475 params = ospf_get_if_params (ifp, addr);
4476 ospf_if_update_params (ifp, addr);
4477 }
4478
4479 key_id = strtol (argv[0], NULL, 10);
4480 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4481 {
4482 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4483 return CMD_WARNING;
4484 }
4485
4486 ck = ospf_crypt_key_new ();
4487 ck->key_id = (u_char) key_id;
4488 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004489 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004490
4491 ospf_crypt_key_add (params->auth_crypt, ck);
4492 SET_IF_PARAM (params, auth_crypt);
4493
4494 return CMD_SUCCESS;
4495}
4496
4497ALIAS (ip_ospf_message_digest_key,
4498 ip_ospf_message_digest_key_cmd,
4499 "ip ospf message-digest-key <1-255> md5 KEY",
4500 "IP Information\n"
4501 "OSPF interface commands\n"
4502 "Message digest authentication password (key)\n"
4503 "Key ID\n"
4504 "Use MD5 algorithm\n"
4505 "The OSPF password (key)")
4506
4507ALIAS (ip_ospf_message_digest_key,
4508 ospf_message_digest_key_cmd,
4509 "ospf message-digest-key <1-255> md5 KEY",
4510 "OSPF interface commands\n"
4511 "Message digest authentication password (key)\n"
4512 "Key ID\n"
4513 "Use MD5 algorithm\n"
4514 "The OSPF password (key)")
4515
4516DEFUN (no_ip_ospf_message_digest_key,
4517 no_ip_ospf_message_digest_key_addr_cmd,
4518 "no ip ospf message-digest-key <1-255> A.B.C.D",
4519 NO_STR
4520 "IP Information\n"
4521 "OSPF interface commands\n"
4522 "Message digest authentication password (key)\n"
4523 "Key ID\n"
4524 "Address of interface")
4525{
4526 struct interface *ifp;
4527 struct crypt_key *ck;
4528 int key_id;
4529 struct in_addr addr;
4530 int ret;
4531 struct ospf_if_params *params;
4532
4533 ifp = vty->index;
4534 params = IF_DEF_PARAMS (ifp);
4535
4536 if (argc == 2)
4537 {
4538 ret = inet_aton(argv[1], &addr);
4539 if (!ret)
4540 {
4541 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4542 VTY_NEWLINE);
4543 return CMD_WARNING;
4544 }
4545
4546 params = ospf_lookup_if_params (ifp, addr);
4547 if (params == NULL)
4548 return CMD_SUCCESS;
4549 }
4550
4551 key_id = strtol (argv[0], NULL, 10);
4552 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4553 if (ck == NULL)
4554 {
4555 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4556 return CMD_WARNING;
4557 }
4558
4559 ospf_crypt_key_delete (params->auth_crypt, key_id);
4560
4561 if (params != IF_DEF_PARAMS (ifp))
4562 {
4563 ospf_free_if_params (ifp, addr);
4564 ospf_if_update_params (ifp, addr);
4565 }
4566
4567 return CMD_SUCCESS;
4568}
4569
4570ALIAS (no_ip_ospf_message_digest_key,
4571 no_ip_ospf_message_digest_key_cmd,
4572 "no ip ospf message-digest-key <1-255>",
4573 NO_STR
4574 "IP Information\n"
4575 "OSPF interface commands\n"
4576 "Message digest authentication password (key)\n"
4577 "Key ID\n")
4578
4579ALIAS (no_ip_ospf_message_digest_key,
4580 no_ospf_message_digest_key_cmd,
4581 "no ospf message-digest-key <1-255>",
4582 NO_STR
4583 "OSPF interface commands\n"
4584 "Message digest authentication password (key)\n"
4585 "Key ID\n")
4586
4587DEFUN (ip_ospf_cost,
4588 ip_ospf_cost_addr_cmd,
4589 "ip ospf cost <1-65535> A.B.C.D",
4590 "IP Information\n"
4591 "OSPF interface commands\n"
4592 "Interface cost\n"
4593 "Cost\n"
4594 "Address of interface")
4595{
4596 struct interface *ifp = vty->index;
4597 u_int32_t cost;
4598 struct in_addr addr;
4599 int ret;
4600 struct ospf_if_params *params;
4601
4602 params = IF_DEF_PARAMS (ifp);
4603
4604 cost = strtol (argv[0], NULL, 10);
4605
4606 /* cost range is <1-65535>. */
4607 if (cost < 1 || cost > 65535)
4608 {
4609 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4610 return CMD_WARNING;
4611 }
4612
4613 if (argc == 2)
4614 {
4615 ret = inet_aton(argv[1], &addr);
4616 if (!ret)
4617 {
4618 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4619 VTY_NEWLINE);
4620 return CMD_WARNING;
4621 }
4622
4623 params = ospf_get_if_params (ifp, addr);
4624 ospf_if_update_params (ifp, addr);
4625 }
4626
4627 SET_IF_PARAM (params, output_cost_cmd);
4628 params->output_cost_cmd = cost;
4629
4630 ospf_if_recalculate_output_cost (ifp);
4631
4632 return CMD_SUCCESS;
4633}
4634
4635ALIAS (ip_ospf_cost,
4636 ip_ospf_cost_cmd,
4637 "ip ospf cost <1-65535>",
4638 "IP Information\n"
4639 "OSPF interface commands\n"
4640 "Interface cost\n"
4641 "Cost")
4642
4643ALIAS (ip_ospf_cost,
4644 ospf_cost_cmd,
4645 "ospf cost <1-65535>",
4646 "OSPF interface commands\n"
4647 "Interface cost\n"
4648 "Cost")
4649
4650DEFUN (no_ip_ospf_cost,
4651 no_ip_ospf_cost_addr_cmd,
4652 "no ip ospf cost A.B.C.D",
4653 NO_STR
4654 "IP Information\n"
4655 "OSPF interface commands\n"
4656 "Interface cost\n"
4657 "Address of interface")
4658{
4659 struct interface *ifp = vty->index;
4660 struct in_addr addr;
4661 int ret;
4662 struct ospf_if_params *params;
4663
4664 ifp = vty->index;
4665 params = IF_DEF_PARAMS (ifp);
4666
4667 if (argc == 1)
4668 {
4669 ret = inet_aton(argv[0], &addr);
4670 if (!ret)
4671 {
4672 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4673 VTY_NEWLINE);
4674 return CMD_WARNING;
4675 }
4676
4677 params = ospf_lookup_if_params (ifp, addr);
4678 if (params == NULL)
4679 return CMD_SUCCESS;
4680 }
4681
4682 UNSET_IF_PARAM (params, output_cost_cmd);
4683
4684 if (params != IF_DEF_PARAMS (ifp))
4685 {
4686 ospf_free_if_params (ifp, addr);
4687 ospf_if_update_params (ifp, addr);
4688 }
4689
4690 ospf_if_recalculate_output_cost (ifp);
4691
4692 return CMD_SUCCESS;
4693}
4694
4695ALIAS (no_ip_ospf_cost,
4696 no_ip_ospf_cost_cmd,
4697 "no ip ospf cost",
4698 NO_STR
4699 "IP Information\n"
4700 "OSPF interface commands\n"
4701 "Interface cost\n")
4702
4703ALIAS (no_ip_ospf_cost,
4704 no_ospf_cost_cmd,
4705 "no ospf cost",
4706 NO_STR
4707 "OSPF interface commands\n"
4708 "Interface cost\n")
4709
paul4dadc292005-05-06 21:37:42 +00004710static void
paul718e3742002-12-13 20:15:29 +00004711ospf_nbr_timer_update (struct ospf_interface *oi)
4712{
4713 struct route_node *rn;
4714 struct ospf_neighbor *nbr;
4715
4716 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4717 if ((nbr = rn->info))
4718 {
4719 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4720 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4721 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4722 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4723 }
4724}
4725
paulf9ad9372005-10-21 00:45:17 +00004726static int
4727ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4728 const char *nbr_str,
4729 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004730{
4731 struct interface *ifp = vty->index;
4732 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004733 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004734 struct in_addr addr;
4735 int ret;
4736 struct ospf_if_params *params;
4737 struct ospf_interface *oi;
4738 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004739 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004740
paul020709f2003-04-04 02:44:16 +00004741 ospf = ospf_lookup ();
4742
paul718e3742002-12-13 20:15:29 +00004743 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004744
4745 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004746 {
paulf9ad9372005-10-21 00:45:17 +00004747 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004748 if (!ret)
4749 {
4750 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4751 VTY_NEWLINE);
4752 return CMD_WARNING;
4753 }
4754
4755 params = ospf_get_if_params (ifp, addr);
4756 ospf_if_update_params (ifp, addr);
4757 }
4758
paulf9ad9372005-10-21 00:45:17 +00004759 if (interval_str)
4760 {
4761 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4762 1, 65535);
4763
4764 /* reset fast_hello too, just to be sure */
4765 UNSET_IF_PARAM (params, fast_hello);
4766 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4767 }
4768 else if (fast_hello_str)
4769 {
4770 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4771 1, 10);
4772 /* 1s dead-interval with sub-second hellos desired */
4773 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4774 SET_IF_PARAM (params, fast_hello);
4775 params->fast_hello = hellomult;
4776 }
4777 else
4778 {
4779 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4780 VTY_NEWLINE);
4781 return CMD_WARNING;
4782 }
4783
paul718e3742002-12-13 20:15:29 +00004784 SET_IF_PARAM (params, v_wait);
4785 params->v_wait = seconds;
4786
4787 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00004788 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004789 {
paul68980082003-03-25 05:07:42 +00004790 if (ospf)
4791 {
4792 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4793 if (oi)
4794 ospf_nbr_timer_update (oi);
4795 }
paul718e3742002-12-13 20:15:29 +00004796 }
4797 else
4798 {
4799 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4800 if ((oi = rn->info))
4801 ospf_nbr_timer_update (oi);
4802 }
4803
4804 return CMD_SUCCESS;
4805}
4806
paulf9ad9372005-10-21 00:45:17 +00004807
4808DEFUN (ip_ospf_dead_interval,
4809 ip_ospf_dead_interval_addr_cmd,
4810 "ip ospf dead-interval <1-65535> A.B.C.D",
4811 "IP Information\n"
4812 "OSPF interface commands\n"
4813 "Interval after which a neighbor is declared dead\n"
4814 "Seconds\n"
4815 "Address of interface\n")
4816{
4817 if (argc == 2)
4818 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4819 else
4820 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4821}
4822
paul718e3742002-12-13 20:15:29 +00004823ALIAS (ip_ospf_dead_interval,
4824 ip_ospf_dead_interval_cmd,
4825 "ip ospf dead-interval <1-65535>",
4826 "IP Information\n"
4827 "OSPF interface commands\n"
4828 "Interval after which a neighbor is declared dead\n"
4829 "Seconds\n")
4830
4831ALIAS (ip_ospf_dead_interval,
4832 ospf_dead_interval_cmd,
4833 "ospf dead-interval <1-65535>",
4834 "OSPF interface commands\n"
4835 "Interval after which a neighbor is declared dead\n"
4836 "Seconds\n")
4837
paulf9ad9372005-10-21 00:45:17 +00004838DEFUN (ip_ospf_dead_interval_minimal,
4839 ip_ospf_dead_interval_minimal_addr_cmd,
4840 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4841 "IP Information\n"
4842 "OSPF interface commands\n"
4843 "Interval after which a neighbor is declared dead\n"
4844 "Minimal 1s dead-interval with fast sub-second hellos\n"
4845 "Hello multiplier factor\n"
4846 "Number of Hellos to send each second\n"
4847 "Address of interface\n")
4848{
4849 if (argc == 2)
4850 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4851 else
4852 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4853}
4854
4855ALIAS (ip_ospf_dead_interval_minimal,
4856 ip_ospf_dead_interval_minimal_cmd,
4857 "ip ospf dead-interval minimal hello-multiplier <1-10>",
4858 "IP Information\n"
4859 "OSPF interface commands\n"
4860 "Interval after which a neighbor is declared dead\n"
4861 "Minimal 1s dead-interval with fast sub-second hellos\n"
4862 "Hello multiplier factor\n"
4863 "Number of Hellos to send each second\n")
4864
paul718e3742002-12-13 20:15:29 +00004865DEFUN (no_ip_ospf_dead_interval,
4866 no_ip_ospf_dead_interval_addr_cmd,
4867 "no ip ospf dead-interval A.B.C.D",
4868 NO_STR
4869 "IP Information\n"
4870 "OSPF interface commands\n"
4871 "Interval after which a neighbor is declared dead\n"
4872 "Address of interface")
4873{
4874 struct interface *ifp = vty->index;
4875 struct in_addr addr;
4876 int ret;
4877 struct ospf_if_params *params;
4878 struct ospf_interface *oi;
4879 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004880 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004881
paul020709f2003-04-04 02:44:16 +00004882 ospf = ospf_lookup ();
4883
paul718e3742002-12-13 20:15:29 +00004884 ifp = vty->index;
4885 params = IF_DEF_PARAMS (ifp);
4886
4887 if (argc == 1)
4888 {
4889 ret = inet_aton(argv[0], &addr);
4890 if (!ret)
4891 {
4892 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4893 VTY_NEWLINE);
4894 return CMD_WARNING;
4895 }
4896
4897 params = ospf_lookup_if_params (ifp, addr);
4898 if (params == NULL)
4899 return CMD_SUCCESS;
4900 }
4901
4902 UNSET_IF_PARAM (params, v_wait);
4903 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00004904
4905 UNSET_IF_PARAM (params, fast_hello);
4906 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4907
paul718e3742002-12-13 20:15:29 +00004908 if (params != IF_DEF_PARAMS (ifp))
4909 {
4910 ospf_free_if_params (ifp, addr);
4911 ospf_if_update_params (ifp, addr);
4912 }
4913
4914 /* Update timer values in neighbor structure. */
4915 if (argc == 1)
4916 {
paul68980082003-03-25 05:07:42 +00004917 if (ospf)
4918 {
4919 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4920 if (oi)
4921 ospf_nbr_timer_update (oi);
4922 }
paul718e3742002-12-13 20:15:29 +00004923 }
4924 else
4925 {
4926 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4927 if ((oi = rn->info))
4928 ospf_nbr_timer_update (oi);
4929 }
4930
4931 return CMD_SUCCESS;
4932}
4933
4934ALIAS (no_ip_ospf_dead_interval,
4935 no_ip_ospf_dead_interval_cmd,
4936 "no ip ospf dead-interval",
4937 NO_STR
4938 "IP Information\n"
4939 "OSPF interface commands\n"
4940 "Interval after which a neighbor is declared dead\n")
4941
4942ALIAS (no_ip_ospf_dead_interval,
4943 no_ospf_dead_interval_cmd,
4944 "no ospf dead-interval",
4945 NO_STR
4946 "OSPF interface commands\n"
4947 "Interval after which a neighbor is declared dead\n")
4948
4949DEFUN (ip_ospf_hello_interval,
4950 ip_ospf_hello_interval_addr_cmd,
4951 "ip ospf hello-interval <1-65535> A.B.C.D",
4952 "IP Information\n"
4953 "OSPF interface commands\n"
4954 "Time between HELLO packets\n"
4955 "Seconds\n"
4956 "Address of interface")
4957{
4958 struct interface *ifp = vty->index;
4959 u_int32_t seconds;
4960 struct in_addr addr;
4961 int ret;
4962 struct ospf_if_params *params;
4963
4964 params = IF_DEF_PARAMS (ifp);
4965
4966 seconds = strtol (argv[0], NULL, 10);
4967
4968 /* HelloInterval range is <1-65535>. */
4969 if (seconds < 1 || seconds > 65535)
4970 {
4971 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4972 return CMD_WARNING;
4973 }
4974
4975 if (argc == 2)
4976 {
4977 ret = inet_aton(argv[1], &addr);
4978 if (!ret)
4979 {
4980 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4981 VTY_NEWLINE);
4982 return CMD_WARNING;
4983 }
4984
4985 params = ospf_get_if_params (ifp, addr);
4986 ospf_if_update_params (ifp, addr);
4987 }
4988
paulf9ad9372005-10-21 00:45:17 +00004989 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00004990 params->v_hello = seconds;
4991
4992 return CMD_SUCCESS;
4993}
4994
4995ALIAS (ip_ospf_hello_interval,
4996 ip_ospf_hello_interval_cmd,
4997 "ip ospf hello-interval <1-65535>",
4998 "IP Information\n"
4999 "OSPF interface commands\n"
5000 "Time between HELLO packets\n"
5001 "Seconds\n")
5002
5003ALIAS (ip_ospf_hello_interval,
5004 ospf_hello_interval_cmd,
5005 "ospf hello-interval <1-65535>",
5006 "OSPF interface commands\n"
5007 "Time between HELLO packets\n"
5008 "Seconds\n")
5009
5010DEFUN (no_ip_ospf_hello_interval,
5011 no_ip_ospf_hello_interval_addr_cmd,
5012 "no ip ospf hello-interval A.B.C.D",
5013 NO_STR
5014 "IP Information\n"
5015 "OSPF interface commands\n"
5016 "Time between HELLO packets\n"
5017 "Address of interface")
5018{
5019 struct interface *ifp = vty->index;
5020 struct in_addr addr;
5021 int ret;
5022 struct ospf_if_params *params;
5023
5024 ifp = vty->index;
5025 params = IF_DEF_PARAMS (ifp);
5026
5027 if (argc == 1)
5028 {
5029 ret = inet_aton(argv[0], &addr);
5030 if (!ret)
5031 {
5032 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5033 VTY_NEWLINE);
5034 return CMD_WARNING;
5035 }
5036
5037 params = ospf_lookup_if_params (ifp, addr);
5038 if (params == NULL)
5039 return CMD_SUCCESS;
5040 }
5041
5042 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005043 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005044
5045 if (params != IF_DEF_PARAMS (ifp))
5046 {
5047 ospf_free_if_params (ifp, addr);
5048 ospf_if_update_params (ifp, addr);
5049 }
5050
5051 return CMD_SUCCESS;
5052}
5053
5054ALIAS (no_ip_ospf_hello_interval,
5055 no_ip_ospf_hello_interval_cmd,
5056 "no ip ospf hello-interval",
5057 NO_STR
5058 "IP Information\n"
5059 "OSPF interface commands\n"
5060 "Time between HELLO packets\n")
5061
5062ALIAS (no_ip_ospf_hello_interval,
5063 no_ospf_hello_interval_cmd,
5064 "no ospf hello-interval",
5065 NO_STR
5066 "OSPF interface commands\n"
5067 "Time between HELLO packets\n")
5068
5069DEFUN (ip_ospf_network,
5070 ip_ospf_network_cmd,
5071 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5072 "IP Information\n"
5073 "OSPF interface commands\n"
5074 "Network type\n"
5075 "Specify OSPF broadcast multi-access network\n"
5076 "Specify OSPF NBMA network\n"
5077 "Specify OSPF point-to-multipoint network\n"
5078 "Specify OSPF point-to-point network\n")
5079{
5080 struct interface *ifp = vty->index;
5081 int old_type = IF_DEF_PARAMS (ifp)->type;
5082 struct route_node *rn;
5083
5084 if (strncmp (argv[0], "b", 1) == 0)
5085 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5086 else if (strncmp (argv[0], "n", 1) == 0)
5087 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5088 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5089 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5090 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5091 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5092
5093 if (IF_DEF_PARAMS (ifp)->type == old_type)
5094 return CMD_SUCCESS;
5095
5096 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5097
5098 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5099 {
5100 struct ospf_interface *oi = rn->info;
5101
5102 if (!oi)
5103 continue;
5104
5105 oi->type = IF_DEF_PARAMS (ifp)->type;
5106
5107 if (oi->state > ISM_Down)
5108 {
5109 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5110 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5111 }
5112 }
5113
5114 return CMD_SUCCESS;
5115}
5116
5117ALIAS (ip_ospf_network,
5118 ospf_network_cmd,
5119 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5120 "OSPF interface commands\n"
5121 "Network type\n"
5122 "Specify OSPF broadcast multi-access network\n"
5123 "Specify OSPF NBMA network\n"
5124 "Specify OSPF point-to-multipoint network\n"
5125 "Specify OSPF point-to-point network\n")
5126
5127DEFUN (no_ip_ospf_network,
5128 no_ip_ospf_network_cmd,
5129 "no ip ospf network",
5130 NO_STR
5131 "IP Information\n"
5132 "OSPF interface commands\n"
5133 "Network type\n")
5134{
5135 struct interface *ifp = vty->index;
5136 int old_type = IF_DEF_PARAMS (ifp)->type;
5137 struct route_node *rn;
5138
ajsbc18d612004-12-15 15:07:19 +00005139 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005140
5141 if (IF_DEF_PARAMS (ifp)->type == old_type)
5142 return CMD_SUCCESS;
5143
5144 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5145 {
5146 struct ospf_interface *oi = rn->info;
5147
5148 if (!oi)
5149 continue;
5150
5151 oi->type = IF_DEF_PARAMS (ifp)->type;
5152
5153 if (oi->state > ISM_Down)
5154 {
5155 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5156 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5157 }
5158 }
5159
5160 return CMD_SUCCESS;
5161}
5162
5163ALIAS (no_ip_ospf_network,
5164 no_ospf_network_cmd,
5165 "no ospf network",
5166 NO_STR
5167 "OSPF interface commands\n"
5168 "Network type\n")
5169
5170DEFUN (ip_ospf_priority,
5171 ip_ospf_priority_addr_cmd,
5172 "ip ospf priority <0-255> A.B.C.D",
5173 "IP Information\n"
5174 "OSPF interface commands\n"
5175 "Router priority\n"
5176 "Priority\n"
5177 "Address of interface")
5178{
5179 struct interface *ifp = vty->index;
5180 u_int32_t priority;
5181 struct route_node *rn;
5182 struct in_addr addr;
5183 int ret;
5184 struct ospf_if_params *params;
5185
5186 params = IF_DEF_PARAMS (ifp);
5187
5188 priority = strtol (argv[0], NULL, 10);
5189
5190 /* Router Priority range is <0-255>. */
5191 if (priority < 0 || priority > 255)
5192 {
5193 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5194 return CMD_WARNING;
5195 }
5196
5197 if (argc == 2)
5198 {
5199 ret = inet_aton(argv[1], &addr);
5200 if (!ret)
5201 {
5202 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5203 VTY_NEWLINE);
5204 return CMD_WARNING;
5205 }
5206
5207 params = ospf_get_if_params (ifp, addr);
5208 ospf_if_update_params (ifp, addr);
5209 }
5210
5211 SET_IF_PARAM (params, priority);
5212 params->priority = priority;
5213
5214 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5215 {
5216 struct ospf_interface *oi = rn->info;
5217
5218 if (!oi)
5219 continue;
5220
5221
5222 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5223 {
5224 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5225 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5226 }
5227 }
5228
5229 return CMD_SUCCESS;
5230}
5231
5232ALIAS (ip_ospf_priority,
5233 ip_ospf_priority_cmd,
5234 "ip ospf priority <0-255>",
5235 "IP Information\n"
5236 "OSPF interface commands\n"
5237 "Router priority\n"
5238 "Priority\n")
5239
5240ALIAS (ip_ospf_priority,
5241 ospf_priority_cmd,
5242 "ospf priority <0-255>",
5243 "OSPF interface commands\n"
5244 "Router priority\n"
5245 "Priority\n")
5246
5247DEFUN (no_ip_ospf_priority,
5248 no_ip_ospf_priority_addr_cmd,
5249 "no ip ospf priority A.B.C.D",
5250 NO_STR
5251 "IP Information\n"
5252 "OSPF interface commands\n"
5253 "Router priority\n"
5254 "Address of interface")
5255{
5256 struct interface *ifp = vty->index;
5257 struct route_node *rn;
5258 struct in_addr addr;
5259 int ret;
5260 struct ospf_if_params *params;
5261
5262 ifp = vty->index;
5263 params = IF_DEF_PARAMS (ifp);
5264
5265 if (argc == 1)
5266 {
5267 ret = inet_aton(argv[0], &addr);
5268 if (!ret)
5269 {
5270 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5271 VTY_NEWLINE);
5272 return CMD_WARNING;
5273 }
5274
5275 params = ospf_lookup_if_params (ifp, addr);
5276 if (params == NULL)
5277 return CMD_SUCCESS;
5278 }
5279
5280 UNSET_IF_PARAM (params, priority);
5281 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5282
5283 if (params != IF_DEF_PARAMS (ifp))
5284 {
5285 ospf_free_if_params (ifp, addr);
5286 ospf_if_update_params (ifp, addr);
5287 }
5288
5289 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5290 {
5291 struct ospf_interface *oi = rn->info;
5292
5293 if (!oi)
5294 continue;
5295
5296
5297 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5298 {
5299 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5300 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5301 }
5302 }
5303
5304 return CMD_SUCCESS;
5305}
5306
5307ALIAS (no_ip_ospf_priority,
5308 no_ip_ospf_priority_cmd,
5309 "no ip ospf priority",
5310 NO_STR
5311 "IP Information\n"
5312 "OSPF interface commands\n"
5313 "Router priority\n")
5314
5315ALIAS (no_ip_ospf_priority,
5316 no_ospf_priority_cmd,
5317 "no ospf priority",
5318 NO_STR
5319 "OSPF interface commands\n"
5320 "Router priority\n")
5321
5322DEFUN (ip_ospf_retransmit_interval,
5323 ip_ospf_retransmit_interval_addr_cmd,
5324 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5325 "IP Information\n"
5326 "OSPF interface commands\n"
5327 "Time between retransmitting lost link state advertisements\n"
5328 "Seconds\n"
5329 "Address of interface")
5330{
5331 struct interface *ifp = vty->index;
5332 u_int32_t seconds;
5333 struct in_addr addr;
5334 int ret;
5335 struct ospf_if_params *params;
5336
5337 params = IF_DEF_PARAMS (ifp);
5338 seconds = strtol (argv[0], NULL, 10);
5339
5340 /* Retransmit Interval range is <3-65535>. */
5341 if (seconds < 3 || seconds > 65535)
5342 {
5343 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5344 return CMD_WARNING;
5345 }
5346
5347
5348 if (argc == 2)
5349 {
5350 ret = inet_aton(argv[1], &addr);
5351 if (!ret)
5352 {
5353 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5354 VTY_NEWLINE);
5355 return CMD_WARNING;
5356 }
5357
5358 params = ospf_get_if_params (ifp, addr);
5359 ospf_if_update_params (ifp, addr);
5360 }
5361
5362 SET_IF_PARAM (params, retransmit_interval);
5363 params->retransmit_interval = seconds;
5364
5365 return CMD_SUCCESS;
5366}
5367
5368ALIAS (ip_ospf_retransmit_interval,
5369 ip_ospf_retransmit_interval_cmd,
5370 "ip ospf retransmit-interval <3-65535>",
5371 "IP Information\n"
5372 "OSPF interface commands\n"
5373 "Time between retransmitting lost link state advertisements\n"
5374 "Seconds\n")
5375
5376ALIAS (ip_ospf_retransmit_interval,
5377 ospf_retransmit_interval_cmd,
5378 "ospf retransmit-interval <3-65535>",
5379 "OSPF interface commands\n"
5380 "Time between retransmitting lost link state advertisements\n"
5381 "Seconds\n")
5382
5383DEFUN (no_ip_ospf_retransmit_interval,
5384 no_ip_ospf_retransmit_interval_addr_cmd,
5385 "no ip ospf retransmit-interval A.B.C.D",
5386 NO_STR
5387 "IP Information\n"
5388 "OSPF interface commands\n"
5389 "Time between retransmitting lost link state advertisements\n"
5390 "Address of interface")
5391{
5392 struct interface *ifp = vty->index;
5393 struct in_addr addr;
5394 int ret;
5395 struct ospf_if_params *params;
5396
5397 ifp = vty->index;
5398 params = IF_DEF_PARAMS (ifp);
5399
5400 if (argc == 1)
5401 {
5402 ret = inet_aton(argv[0], &addr);
5403 if (!ret)
5404 {
5405 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5406 VTY_NEWLINE);
5407 return CMD_WARNING;
5408 }
5409
5410 params = ospf_lookup_if_params (ifp, addr);
5411 if (params == NULL)
5412 return CMD_SUCCESS;
5413 }
5414
5415 UNSET_IF_PARAM (params, retransmit_interval);
5416 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5417
5418 if (params != IF_DEF_PARAMS (ifp))
5419 {
5420 ospf_free_if_params (ifp, addr);
5421 ospf_if_update_params (ifp, addr);
5422 }
5423
5424 return CMD_SUCCESS;
5425}
5426
5427ALIAS (no_ip_ospf_retransmit_interval,
5428 no_ip_ospf_retransmit_interval_cmd,
5429 "no ip ospf retransmit-interval",
5430 NO_STR
5431 "IP Information\n"
5432 "OSPF interface commands\n"
5433 "Time between retransmitting lost link state advertisements\n")
5434
5435ALIAS (no_ip_ospf_retransmit_interval,
5436 no_ospf_retransmit_interval_cmd,
5437 "no ospf retransmit-interval",
5438 NO_STR
5439 "OSPF interface commands\n"
5440 "Time between retransmitting lost link state advertisements\n")
5441
5442DEFUN (ip_ospf_transmit_delay,
5443 ip_ospf_transmit_delay_addr_cmd,
5444 "ip ospf transmit-delay <1-65535> A.B.C.D",
5445 "IP Information\n"
5446 "OSPF interface commands\n"
5447 "Link state transmit delay\n"
5448 "Seconds\n"
5449 "Address of interface")
5450{
5451 struct interface *ifp = vty->index;
5452 u_int32_t seconds;
5453 struct in_addr addr;
5454 int ret;
5455 struct ospf_if_params *params;
5456
5457 params = IF_DEF_PARAMS (ifp);
5458 seconds = strtol (argv[0], NULL, 10);
5459
5460 /* Transmit Delay range is <1-65535>. */
5461 if (seconds < 1 || seconds > 65535)
5462 {
5463 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5464 return CMD_WARNING;
5465 }
5466
5467 if (argc == 2)
5468 {
5469 ret = inet_aton(argv[1], &addr);
5470 if (!ret)
5471 {
5472 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5473 VTY_NEWLINE);
5474 return CMD_WARNING;
5475 }
5476
5477 params = ospf_get_if_params (ifp, addr);
5478 ospf_if_update_params (ifp, addr);
5479 }
5480
5481 SET_IF_PARAM (params, transmit_delay);
5482 params->transmit_delay = seconds;
5483
5484 return CMD_SUCCESS;
5485}
5486
5487ALIAS (ip_ospf_transmit_delay,
5488 ip_ospf_transmit_delay_cmd,
5489 "ip ospf transmit-delay <1-65535>",
5490 "IP Information\n"
5491 "OSPF interface commands\n"
5492 "Link state transmit delay\n"
5493 "Seconds\n")
5494
5495ALIAS (ip_ospf_transmit_delay,
5496 ospf_transmit_delay_cmd,
5497 "ospf transmit-delay <1-65535>",
5498 "OSPF interface commands\n"
5499 "Link state transmit delay\n"
5500 "Seconds\n")
5501
5502DEFUN (no_ip_ospf_transmit_delay,
5503 no_ip_ospf_transmit_delay_addr_cmd,
5504 "no ip ospf transmit-delay A.B.C.D",
5505 NO_STR
5506 "IP Information\n"
5507 "OSPF interface commands\n"
5508 "Link state transmit delay\n"
5509 "Address of interface")
5510{
5511 struct interface *ifp = vty->index;
5512 struct in_addr addr;
5513 int ret;
5514 struct ospf_if_params *params;
5515
5516 ifp = vty->index;
5517 params = IF_DEF_PARAMS (ifp);
5518
5519 if (argc == 1)
5520 {
5521 ret = inet_aton(argv[0], &addr);
5522 if (!ret)
5523 {
5524 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5525 VTY_NEWLINE);
5526 return CMD_WARNING;
5527 }
5528
5529 params = ospf_lookup_if_params (ifp, addr);
5530 if (params == NULL)
5531 return CMD_SUCCESS;
5532 }
5533
5534 UNSET_IF_PARAM (params, transmit_delay);
5535 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5536
5537 if (params != IF_DEF_PARAMS (ifp))
5538 {
5539 ospf_free_if_params (ifp, addr);
5540 ospf_if_update_params (ifp, addr);
5541 }
5542
5543 return CMD_SUCCESS;
5544}
5545
5546ALIAS (no_ip_ospf_transmit_delay,
5547 no_ip_ospf_transmit_delay_cmd,
5548 "no ip ospf transmit-delay",
5549 NO_STR
5550 "IP Information\n"
5551 "OSPF interface commands\n"
5552 "Link state transmit delay\n")
5553
5554ALIAS (no_ip_ospf_transmit_delay,
5555 no_ospf_transmit_delay_cmd,
5556 "no ospf transmit-delay",
5557 NO_STR
5558 "OSPF interface commands\n"
5559 "Link state transmit delay\n")
5560
5561
5562DEFUN (ospf_redistribute_source_metric_type,
5563 ospf_redistribute_source_metric_type_routemap_cmd,
5564 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5565 "Redistribute information from another routing protocol\n"
5566 "Kernel routes\n"
5567 "Connected\n"
5568 "Static routes\n"
5569 "Routing Information Protocol (RIP)\n"
5570 "Border Gateway Protocol (BGP)\n"
5571 "Metric for redistributed routes\n"
5572 "OSPF default metric\n"
5573 "OSPF exterior metric type for redistributed routes\n"
5574 "Set OSPF External Type 1 metrics\n"
5575 "Set OSPF External Type 2 metrics\n"
5576 "Route map reference\n"
5577 "Pointer to route-map entries\n")
5578{
paul020709f2003-04-04 02:44:16 +00005579 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005580 int source;
5581 int type = -1;
5582 int metric = -1;
5583
5584 /* Get distribute source. */
5585 if (!str2distribute_source (argv[0], &source))
5586 return CMD_WARNING;
5587
5588 /* Get metric value. */
5589 if (argc >= 2)
5590 if (!str2metric (argv[1], &metric))
5591 return CMD_WARNING;
5592
5593 /* Get metric type. */
5594 if (argc >= 3)
5595 if (!str2metric_type (argv[2], &type))
5596 return CMD_WARNING;
5597
5598 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005599 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005600 else
paul020709f2003-04-04 02:44:16 +00005601 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005602
paul020709f2003-04-04 02:44:16 +00005603 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005604}
5605
5606ALIAS (ospf_redistribute_source_metric_type,
5607 ospf_redistribute_source_metric_type_cmd,
5608 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5609 "Redistribute information from another routing protocol\n"
5610 "Kernel routes\n"
5611 "Connected\n"
5612 "Static routes\n"
5613 "Routing Information Protocol (RIP)\n"
5614 "Border Gateway Protocol (BGP)\n"
5615 "Metric for redistributed routes\n"
5616 "OSPF default metric\n"
5617 "OSPF exterior metric type for redistributed routes\n"
5618 "Set OSPF External Type 1 metrics\n"
5619 "Set OSPF External Type 2 metrics\n")
5620
5621ALIAS (ospf_redistribute_source_metric_type,
5622 ospf_redistribute_source_metric_cmd,
5623 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5624 "Redistribute information from another routing protocol\n"
5625 "Kernel routes\n"
5626 "Connected\n"
5627 "Static routes\n"
5628 "Routing Information Protocol (RIP)\n"
5629 "Border Gateway Protocol (BGP)\n"
5630 "Metric for redistributed routes\n"
5631 "OSPF default metric\n")
5632
5633DEFUN (ospf_redistribute_source_type_metric,
5634 ospf_redistribute_source_type_metric_routemap_cmd,
5635 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5636 "Redistribute information from another routing protocol\n"
5637 "Kernel routes\n"
5638 "Connected\n"
5639 "Static routes\n"
5640 "Routing Information Protocol (RIP)\n"
5641 "Border Gateway Protocol (BGP)\n"
5642 "OSPF exterior metric type for redistributed routes\n"
5643 "Set OSPF External Type 1 metrics\n"
5644 "Set OSPF External Type 2 metrics\n"
5645 "Metric for redistributed routes\n"
5646 "OSPF default metric\n"
5647 "Route map reference\n"
5648 "Pointer to route-map entries\n")
5649{
paul020709f2003-04-04 02:44:16 +00005650 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005651 int source;
5652 int type = -1;
5653 int metric = -1;
5654
5655 /* Get distribute source. */
5656 if (!str2distribute_source (argv[0], &source))
5657 return CMD_WARNING;
5658
5659 /* Get metric value. */
5660 if (argc >= 2)
5661 if (!str2metric_type (argv[1], &type))
5662 return CMD_WARNING;
5663
5664 /* Get metric type. */
5665 if (argc >= 3)
5666 if (!str2metric (argv[2], &metric))
5667 return CMD_WARNING;
5668
5669 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005670 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005671 else
paul020709f2003-04-04 02:44:16 +00005672 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005673
paul020709f2003-04-04 02:44:16 +00005674 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005675}
5676
5677ALIAS (ospf_redistribute_source_type_metric,
5678 ospf_redistribute_source_type_metric_cmd,
5679 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5680 "Redistribute information from another routing protocol\n"
5681 "Kernel routes\n"
5682 "Connected\n"
5683 "Static routes\n"
5684 "Routing Information Protocol (RIP)\n"
5685 "Border Gateway Protocol (BGP)\n"
5686 "OSPF exterior metric type for redistributed routes\n"
5687 "Set OSPF External Type 1 metrics\n"
5688 "Set OSPF External Type 2 metrics\n"
5689 "Metric for redistributed routes\n"
5690 "OSPF default metric\n")
5691
5692ALIAS (ospf_redistribute_source_type_metric,
5693 ospf_redistribute_source_type_cmd,
5694 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5695 "Redistribute information from another routing protocol\n"
5696 "Kernel routes\n"
5697 "Connected\n"
5698 "Static routes\n"
5699 "Routing Information Protocol (RIP)\n"
5700 "Border Gateway Protocol (BGP)\n"
5701 "OSPF exterior metric type for redistributed routes\n"
5702 "Set OSPF External Type 1 metrics\n"
5703 "Set OSPF External Type 2 metrics\n")
5704
5705ALIAS (ospf_redistribute_source_type_metric,
5706 ospf_redistribute_source_cmd,
5707 "redistribute (kernel|connected|static|rip|bgp)",
5708 "Redistribute information from another routing protocol\n"
5709 "Kernel routes\n"
5710 "Connected\n"
5711 "Static routes\n"
5712 "Routing Information Protocol (RIP)\n"
5713 "Border Gateway Protocol (BGP)\n")
5714
5715DEFUN (ospf_redistribute_source_metric_routemap,
5716 ospf_redistribute_source_metric_routemap_cmd,
5717 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5718 "Redistribute information from another routing protocol\n"
5719 "Kernel routes\n"
5720 "Connected\n"
5721 "Static routes\n"
5722 "Routing Information Protocol (RIP)\n"
5723 "Border Gateway Protocol (BGP)\n"
5724 "Metric for redistributed routes\n"
5725 "OSPF default metric\n"
5726 "Route map reference\n"
5727 "Pointer to route-map entries\n")
5728{
paul020709f2003-04-04 02:44:16 +00005729 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005730 int source;
5731 int metric = -1;
5732
5733 /* Get distribute source. */
5734 if (!str2distribute_source (argv[0], &source))
5735 return CMD_WARNING;
5736
5737 /* Get metric value. */
5738 if (argc >= 2)
5739 if (!str2metric (argv[1], &metric))
5740 return CMD_WARNING;
5741
5742 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005743 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005744 else
paul020709f2003-04-04 02:44:16 +00005745 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005746
paul020709f2003-04-04 02:44:16 +00005747 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005748}
5749
5750DEFUN (ospf_redistribute_source_type_routemap,
5751 ospf_redistribute_source_type_routemap_cmd,
5752 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5753 "Redistribute information from another routing protocol\n"
5754 "Kernel routes\n"
5755 "Connected\n"
5756 "Static routes\n"
5757 "Routing Information Protocol (RIP)\n"
5758 "Border Gateway Protocol (BGP)\n"
5759 "OSPF exterior metric type for redistributed routes\n"
5760 "Set OSPF External Type 1 metrics\n"
5761 "Set OSPF External Type 2 metrics\n"
5762 "Route map reference\n"
5763 "Pointer to route-map entries\n")
5764{
paul020709f2003-04-04 02:44:16 +00005765 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005766 int source;
5767 int type = -1;
5768
5769 /* Get distribute source. */
5770 if (!str2distribute_source (argv[0], &source))
5771 return CMD_WARNING;
5772
5773 /* Get metric value. */
5774 if (argc >= 2)
5775 if (!str2metric_type (argv[1], &type))
5776 return CMD_WARNING;
5777
5778 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005779 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005780 else
paul020709f2003-04-04 02:44:16 +00005781 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005782
paul020709f2003-04-04 02:44:16 +00005783 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005784}
5785
5786DEFUN (ospf_redistribute_source_routemap,
5787 ospf_redistribute_source_routemap_cmd,
5788 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5789 "Redistribute information from another routing protocol\n"
5790 "Kernel routes\n"
5791 "Connected\n"
5792 "Static routes\n"
5793 "Routing Information Protocol (RIP)\n"
5794 "Border Gateway Protocol (BGP)\n"
5795 "Route map reference\n"
5796 "Pointer to route-map entries\n")
5797{
paul020709f2003-04-04 02:44:16 +00005798 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005799 int source;
5800
5801 /* Get distribute source. */
5802 if (!str2distribute_source (argv[0], &source))
5803 return CMD_WARNING;
5804
5805 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005806 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005807 else
paul020709f2003-04-04 02:44:16 +00005808 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005809
paul020709f2003-04-04 02:44:16 +00005810 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005811}
5812
5813DEFUN (no_ospf_redistribute_source,
5814 no_ospf_redistribute_source_cmd,
5815 "no redistribute (kernel|connected|static|rip|bgp)",
5816 NO_STR
5817 "Redistribute information from another routing protocol\n"
5818 "Kernel routes\n"
5819 "Connected\n"
5820 "Static routes\n"
5821 "Routing Information Protocol (RIP)\n"
5822 "Border Gateway Protocol (BGP)\n")
5823{
paul020709f2003-04-04 02:44:16 +00005824 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005825 int source;
5826
5827 if (!str2distribute_source (argv[0], &source))
5828 return CMD_WARNING;
5829
paul020709f2003-04-04 02:44:16 +00005830 ospf_routemap_unset (ospf, source);
5831 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005832}
5833
5834DEFUN (ospf_distribute_list_out,
5835 ospf_distribute_list_out_cmd,
5836 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5837 "Filter networks in routing updates\n"
5838 "Access-list name\n"
5839 OUT_STR
5840 "Kernel routes\n"
5841 "Connected\n"
5842 "Static routes\n"
5843 "Routing Information Protocol (RIP)\n"
5844 "Border Gateway Protocol (BGP)\n")
5845{
paul68980082003-03-25 05:07:42 +00005846 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005847 int source;
5848
5849 /* Get distribute source. */
5850 if (!str2distribute_source (argv[1], &source))
5851 return CMD_WARNING;
5852
paul68980082003-03-25 05:07:42 +00005853 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005854}
5855
5856DEFUN (no_ospf_distribute_list_out,
5857 no_ospf_distribute_list_out_cmd,
5858 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5859 NO_STR
5860 "Filter networks in routing updates\n"
5861 "Access-list name\n"
5862 OUT_STR
5863 "Kernel routes\n"
5864 "Connected\n"
5865 "Static routes\n"
5866 "Routing Information Protocol (RIP)\n"
5867 "Border Gateway Protocol (BGP)\n")
5868{
paul68980082003-03-25 05:07:42 +00005869 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005870 int source;
5871
5872 if (!str2distribute_source (argv[1], &source))
5873 return CMD_WARNING;
5874
paul68980082003-03-25 05:07:42 +00005875 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005876}
5877
5878/* Default information originate. */
5879DEFUN (ospf_default_information_originate_metric_type_routemap,
5880 ospf_default_information_originate_metric_type_routemap_cmd,
5881 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5882 "Control distribution of default information\n"
5883 "Distribute a default route\n"
5884 "OSPF default metric\n"
5885 "OSPF metric\n"
5886 "OSPF metric type for default routes\n"
5887 "Set OSPF External Type 1 metrics\n"
5888 "Set OSPF External Type 2 metrics\n"
5889 "Route map reference\n"
5890 "Pointer to route-map entries\n")
5891{
paul020709f2003-04-04 02:44:16 +00005892 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005893 int type = -1;
5894 int metric = -1;
5895
5896 /* Get metric value. */
5897 if (argc >= 1)
5898 if (!str2metric (argv[0], &metric))
5899 return CMD_WARNING;
5900
5901 /* Get metric type. */
5902 if (argc >= 2)
5903 if (!str2metric_type (argv[1], &type))
5904 return CMD_WARNING;
5905
5906 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005907 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005908 else
paul020709f2003-04-04 02:44:16 +00005909 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005910
paul020709f2003-04-04 02:44:16 +00005911 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5912 type, metric);
paul718e3742002-12-13 20:15:29 +00005913}
5914
5915ALIAS (ospf_default_information_originate_metric_type_routemap,
5916 ospf_default_information_originate_metric_type_cmd,
5917 "default-information originate metric <0-16777214> metric-type (1|2)",
5918 "Control distribution of default information\n"
5919 "Distribute a default route\n"
5920 "OSPF default metric\n"
5921 "OSPF metric\n"
5922 "OSPF metric type for default routes\n"
5923 "Set OSPF External Type 1 metrics\n"
5924 "Set OSPF External Type 2 metrics\n")
5925
5926ALIAS (ospf_default_information_originate_metric_type_routemap,
5927 ospf_default_information_originate_metric_cmd,
5928 "default-information originate metric <0-16777214>",
5929 "Control distribution of default information\n"
5930 "Distribute a default route\n"
5931 "OSPF default metric\n"
5932 "OSPF metric\n")
5933
5934ALIAS (ospf_default_information_originate_metric_type_routemap,
5935 ospf_default_information_originate_cmd,
5936 "default-information originate",
5937 "Control distribution of default information\n"
5938 "Distribute a default route\n")
5939
5940/* Default information originate. */
5941DEFUN (ospf_default_information_originate_metric_routemap,
5942 ospf_default_information_originate_metric_routemap_cmd,
5943 "default-information originate metric <0-16777214> route-map WORD",
5944 "Control distribution of default information\n"
5945 "Distribute a default route\n"
5946 "OSPF default metric\n"
5947 "OSPF metric\n"
5948 "Route map reference\n"
5949 "Pointer to route-map entries\n")
5950{
paul020709f2003-04-04 02:44:16 +00005951 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005952 int metric = -1;
5953
5954 /* Get metric value. */
5955 if (argc >= 1)
5956 if (!str2metric (argv[0], &metric))
5957 return CMD_WARNING;
5958
5959 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005960 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005961 else
paul020709f2003-04-04 02:44:16 +00005962 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005963
paul020709f2003-04-04 02:44:16 +00005964 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5965 -1, metric);
paul718e3742002-12-13 20:15:29 +00005966}
5967
5968/* Default information originate. */
5969DEFUN (ospf_default_information_originate_routemap,
5970 ospf_default_information_originate_routemap_cmd,
5971 "default-information originate route-map WORD",
5972 "Control distribution of default information\n"
5973 "Distribute a default route\n"
5974 "Route map reference\n"
5975 "Pointer to route-map entries\n")
5976{
paul020709f2003-04-04 02:44:16 +00005977 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005978
paul020709f2003-04-04 02:44:16 +00005979 if (argc == 1)
5980 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5981 else
5982 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5983
5984 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005985}
5986
5987DEFUN (ospf_default_information_originate_type_metric_routemap,
5988 ospf_default_information_originate_type_metric_routemap_cmd,
5989 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5990 "Control distribution of default information\n"
5991 "Distribute a default route\n"
5992 "OSPF metric type for default routes\n"
5993 "Set OSPF External Type 1 metrics\n"
5994 "Set OSPF External Type 2 metrics\n"
5995 "OSPF default metric\n"
5996 "OSPF metric\n"
5997 "Route map reference\n"
5998 "Pointer to route-map entries\n")
5999{
paul020709f2003-04-04 02:44:16 +00006000 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006001 int type = -1;
6002 int metric = -1;
6003
6004 /* Get metric type. */
6005 if (argc >= 1)
6006 if (!str2metric_type (argv[0], &type))
6007 return CMD_WARNING;
6008
6009 /* Get metric value. */
6010 if (argc >= 2)
6011 if (!str2metric (argv[1], &metric))
6012 return CMD_WARNING;
6013
6014 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006015 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006016 else
paul020709f2003-04-04 02:44:16 +00006017 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006018
paul020709f2003-04-04 02:44:16 +00006019 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6020 type, metric);
paul718e3742002-12-13 20:15:29 +00006021}
6022
6023ALIAS (ospf_default_information_originate_type_metric_routemap,
6024 ospf_default_information_originate_type_metric_cmd,
6025 "default-information originate metric-type (1|2) metric <0-16777214>",
6026 "Control distribution of default information\n"
6027 "Distribute a default route\n"
6028 "OSPF metric type for default routes\n"
6029 "Set OSPF External Type 1 metrics\n"
6030 "Set OSPF External Type 2 metrics\n"
6031 "OSPF default metric\n"
6032 "OSPF metric\n")
6033
6034ALIAS (ospf_default_information_originate_type_metric_routemap,
6035 ospf_default_information_originate_type_cmd,
6036 "default-information originate metric-type (1|2)",
6037 "Control distribution of default information\n"
6038 "Distribute a default route\n"
6039 "OSPF metric type for default routes\n"
6040 "Set OSPF External Type 1 metrics\n"
6041 "Set OSPF External Type 2 metrics\n")
6042
6043DEFUN (ospf_default_information_originate_type_routemap,
6044 ospf_default_information_originate_type_routemap_cmd,
6045 "default-information originate metric-type (1|2) route-map WORD",
6046 "Control distribution of default information\n"
6047 "Distribute a default route\n"
6048 "OSPF metric type for default routes\n"
6049 "Set OSPF External Type 1 metrics\n"
6050 "Set OSPF External Type 2 metrics\n"
6051 "Route map reference\n"
6052 "Pointer to route-map entries\n")
6053{
paul020709f2003-04-04 02:44:16 +00006054 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006055 int type = -1;
6056
6057 /* Get metric type. */
6058 if (argc >= 1)
6059 if (!str2metric_type (argv[0], &type))
6060 return CMD_WARNING;
6061
6062 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006063 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006064 else
paul020709f2003-04-04 02:44:16 +00006065 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006066
paul020709f2003-04-04 02:44:16 +00006067 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6068 type, -1);
paul718e3742002-12-13 20:15:29 +00006069}
6070
6071DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6072 ospf_default_information_originate_always_metric_type_routemap_cmd,
6073 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6074 "Control distribution of default information\n"
6075 "Distribute a default route\n"
6076 "Always advertise default route\n"
6077 "OSPF default metric\n"
6078 "OSPF metric\n"
6079 "OSPF metric type for default routes\n"
6080 "Set OSPF External Type 1 metrics\n"
6081 "Set OSPF External Type 2 metrics\n"
6082 "Route map reference\n"
6083 "Pointer to route-map entries\n")
6084{
paul020709f2003-04-04 02:44:16 +00006085 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006086 int type = -1;
6087 int metric = -1;
6088
6089 /* Get metric value. */
6090 if (argc >= 1)
6091 if (!str2metric (argv[0], &metric))
6092 return CMD_WARNING;
6093
6094 /* Get metric type. */
6095 if (argc >= 2)
6096 if (!str2metric_type (argv[1], &type))
6097 return CMD_WARNING;
6098
6099 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006100 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006101 else
paul020709f2003-04-04 02:44:16 +00006102 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006103
paul020709f2003-04-04 02:44:16 +00006104 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006105 type, metric);
6106}
6107
6108ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6109 ospf_default_information_originate_always_metric_type_cmd,
6110 "default-information originate always metric <0-16777214> metric-type (1|2)",
6111 "Control distribution of default information\n"
6112 "Distribute a default route\n"
6113 "Always advertise default route\n"
6114 "OSPF default metric\n"
6115 "OSPF metric\n"
6116 "OSPF metric type for default routes\n"
6117 "Set OSPF External Type 1 metrics\n"
6118 "Set OSPF External Type 2 metrics\n")
6119
6120ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6121 ospf_default_information_originate_always_metric_cmd,
6122 "default-information originate always metric <0-16777214>",
6123 "Control distribution of default information\n"
6124 "Distribute a default route\n"
6125 "Always advertise default route\n"
6126 "OSPF default metric\n"
6127 "OSPF metric\n"
6128 "OSPF metric type for default routes\n")
6129
6130ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6131 ospf_default_information_originate_always_cmd,
6132 "default-information originate always",
6133 "Control distribution of default information\n"
6134 "Distribute a default route\n"
6135 "Always advertise default route\n")
6136
6137DEFUN (ospf_default_information_originate_always_metric_routemap,
6138 ospf_default_information_originate_always_metric_routemap_cmd,
6139 "default-information originate always metric <0-16777214> route-map WORD",
6140 "Control distribution of default information\n"
6141 "Distribute a default route\n"
6142 "Always advertise default route\n"
6143 "OSPF default metric\n"
6144 "OSPF metric\n"
6145 "Route map reference\n"
6146 "Pointer to route-map entries\n")
6147{
paul020709f2003-04-04 02:44:16 +00006148 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006149 int metric = -1;
6150
6151 /* Get metric value. */
6152 if (argc >= 1)
6153 if (!str2metric (argv[0], &metric))
6154 return CMD_WARNING;
6155
6156 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006157 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006158 else
paul020709f2003-04-04 02:44:16 +00006159 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006160
paul020709f2003-04-04 02:44:16 +00006161 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6162 -1, metric);
paul718e3742002-12-13 20:15:29 +00006163}
6164
6165DEFUN (ospf_default_information_originate_always_routemap,
6166 ospf_default_information_originate_always_routemap_cmd,
6167 "default-information originate always route-map WORD",
6168 "Control distribution of default information\n"
6169 "Distribute a default route\n"
6170 "Always advertise default route\n"
6171 "Route map reference\n"
6172 "Pointer to route-map entries\n")
6173{
paul020709f2003-04-04 02:44:16 +00006174 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006175
paul020709f2003-04-04 02:44:16 +00006176 if (argc == 1)
6177 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6178 else
6179 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6180
6181 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006182}
6183
6184DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6185 ospf_default_information_originate_always_type_metric_routemap_cmd,
6186 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6187 "Control distribution of default information\n"
6188 "Distribute a default route\n"
6189 "Always advertise default route\n"
6190 "OSPF metric type for default routes\n"
6191 "Set OSPF External Type 1 metrics\n"
6192 "Set OSPF External Type 2 metrics\n"
6193 "OSPF default metric\n"
6194 "OSPF metric\n"
6195 "Route map reference\n"
6196 "Pointer to route-map entries\n")
6197{
paul020709f2003-04-04 02:44:16 +00006198 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006199 int type = -1;
6200 int metric = -1;
6201
6202 /* Get metric type. */
6203 if (argc >= 1)
6204 if (!str2metric_type (argv[0], &type))
6205 return CMD_WARNING;
6206
6207 /* Get metric value. */
6208 if (argc >= 2)
6209 if (!str2metric (argv[1], &metric))
6210 return CMD_WARNING;
6211
6212 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006213 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006214 else
paul020709f2003-04-04 02:44:16 +00006215 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006216
paul020709f2003-04-04 02:44:16 +00006217 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006218 type, metric);
6219}
6220
6221ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6222 ospf_default_information_originate_always_type_metric_cmd,
6223 "default-information originate always metric-type (1|2) metric <0-16777214>",
6224 "Control distribution of default information\n"
6225 "Distribute a default route\n"
6226 "Always advertise default route\n"
6227 "OSPF metric type for default routes\n"
6228 "Set OSPF External Type 1 metrics\n"
6229 "Set OSPF External Type 2 metrics\n"
6230 "OSPF default metric\n"
6231 "OSPF metric\n")
6232
6233ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6234 ospf_default_information_originate_always_type_cmd,
6235 "default-information originate always metric-type (1|2)",
6236 "Control distribution of default information\n"
6237 "Distribute a default route\n"
6238 "Always advertise default route\n"
6239 "OSPF metric type for default routes\n"
6240 "Set OSPF External Type 1 metrics\n"
6241 "Set OSPF External Type 2 metrics\n")
6242
6243DEFUN (ospf_default_information_originate_always_type_routemap,
6244 ospf_default_information_originate_always_type_routemap_cmd,
6245 "default-information originate always metric-type (1|2) route-map WORD",
6246 "Control distribution of default information\n"
6247 "Distribute a default route\n"
6248 "Always advertise default route\n"
6249 "OSPF metric type for default routes\n"
6250 "Set OSPF External Type 1 metrics\n"
6251 "Set OSPF External Type 2 metrics\n"
6252 "Route map reference\n"
6253 "Pointer to route-map entries\n")
6254{
paul020709f2003-04-04 02:44:16 +00006255 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006256 int type = -1;
6257
6258 /* Get metric type. */
6259 if (argc >= 1)
6260 if (!str2metric_type (argv[0], &type))
6261 return CMD_WARNING;
6262
6263 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006264 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006265 else
paul020709f2003-04-04 02:44:16 +00006266 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006267
paul020709f2003-04-04 02:44:16 +00006268 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006269 type, -1);
6270}
6271
6272DEFUN (no_ospf_default_information_originate,
6273 no_ospf_default_information_originate_cmd,
6274 "no default-information originate",
6275 NO_STR
6276 "Control distribution of default information\n"
6277 "Distribute a default route\n")
6278{
paul68980082003-03-25 05:07:42 +00006279 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006280 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006281
6282 p.family = AF_INET;
6283 p.prefix.s_addr = 0;
6284 p.prefixlen = 0;
6285
ajs5339cfd2005-09-19 13:28:05 +00006286 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006287
6288 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6289 ospf_external_info_delete (DEFAULT_ROUTE, p);
6290 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6291 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6292 }
6293
paul020709f2003-04-04 02:44:16 +00006294 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6295 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006296}
6297
6298DEFUN (ospf_default_metric,
6299 ospf_default_metric_cmd,
6300 "default-metric <0-16777214>",
6301 "Set metric of redistributed routes\n"
6302 "Default metric\n")
6303{
paul68980082003-03-25 05:07:42 +00006304 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006305 int metric = -1;
6306
6307 if (!str2metric (argv[0], &metric))
6308 return CMD_WARNING;
6309
paul68980082003-03-25 05:07:42 +00006310 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006311
6312 return CMD_SUCCESS;
6313}
6314
6315DEFUN (no_ospf_default_metric,
6316 no_ospf_default_metric_cmd,
6317 "no default-metric",
6318 NO_STR
6319 "Set metric of redistributed routes\n")
6320{
paul68980082003-03-25 05:07:42 +00006321 struct ospf *ospf = vty->index;
6322
6323 ospf->default_metric = -1;
6324
paul718e3742002-12-13 20:15:29 +00006325 return CMD_SUCCESS;
6326}
6327
6328ALIAS (no_ospf_default_metric,
6329 no_ospf_default_metric_val_cmd,
6330 "no default-metric <0-16777214>",
6331 NO_STR
6332 "Set metric of redistributed routes\n"
6333 "Default metric\n")
6334
6335DEFUN (ospf_distance,
6336 ospf_distance_cmd,
6337 "distance <1-255>",
6338 "Define an administrative distance\n"
6339 "OSPF Administrative distance\n")
6340{
paul68980082003-03-25 05:07:42 +00006341 struct ospf *ospf = vty->index;
6342
6343 ospf->distance_all = atoi (argv[0]);
6344
paul718e3742002-12-13 20:15:29 +00006345 return CMD_SUCCESS;
6346}
6347
6348DEFUN (no_ospf_distance,
6349 no_ospf_distance_cmd,
6350 "no distance <1-255>",
6351 NO_STR
6352 "Define an administrative distance\n"
6353 "OSPF Administrative distance\n")
6354{
paul68980082003-03-25 05:07:42 +00006355 struct ospf *ospf = vty->index;
6356
6357 ospf->distance_all = 0;
6358
paul718e3742002-12-13 20:15:29 +00006359 return CMD_SUCCESS;
6360}
6361
6362DEFUN (no_ospf_distance_ospf,
6363 no_ospf_distance_ospf_cmd,
6364 "no distance ospf",
6365 NO_STR
6366 "Define an administrative distance\n"
6367 "OSPF Administrative distance\n"
6368 "OSPF Distance\n")
6369{
paul68980082003-03-25 05:07:42 +00006370 struct ospf *ospf = vty->index;
6371
6372 ospf->distance_intra = 0;
6373 ospf->distance_inter = 0;
6374 ospf->distance_external = 0;
6375
paul718e3742002-12-13 20:15:29 +00006376 return CMD_SUCCESS;
6377}
6378
6379DEFUN (ospf_distance_ospf_intra,
6380 ospf_distance_ospf_intra_cmd,
6381 "distance ospf intra-area <1-255>",
6382 "Define an administrative distance\n"
6383 "OSPF Administrative distance\n"
6384 "Intra-area routes\n"
6385 "Distance for intra-area routes\n")
6386{
paul68980082003-03-25 05:07:42 +00006387 struct ospf *ospf = vty->index;
6388
6389 ospf->distance_intra = atoi (argv[0]);
6390
paul718e3742002-12-13 20:15:29 +00006391 return CMD_SUCCESS;
6392}
6393
6394DEFUN (ospf_distance_ospf_intra_inter,
6395 ospf_distance_ospf_intra_inter_cmd,
6396 "distance ospf intra-area <1-255> inter-area <1-255>",
6397 "Define an administrative distance\n"
6398 "OSPF Administrative distance\n"
6399 "Intra-area routes\n"
6400 "Distance for intra-area routes\n"
6401 "Inter-area routes\n"
6402 "Distance for inter-area routes\n")
6403{
paul68980082003-03-25 05:07:42 +00006404 struct ospf *ospf = vty->index;
6405
6406 ospf->distance_intra = atoi (argv[0]);
6407 ospf->distance_inter = atoi (argv[1]);
6408
paul718e3742002-12-13 20:15:29 +00006409 return CMD_SUCCESS;
6410}
6411
6412DEFUN (ospf_distance_ospf_intra_external,
6413 ospf_distance_ospf_intra_external_cmd,
6414 "distance ospf intra-area <1-255> external <1-255>",
6415 "Define an administrative distance\n"
6416 "OSPF Administrative distance\n"
6417 "Intra-area routes\n"
6418 "Distance for intra-area routes\n"
6419 "External routes\n"
6420 "Distance for external routes\n")
6421{
paul68980082003-03-25 05:07:42 +00006422 struct ospf *ospf = vty->index;
6423
6424 ospf->distance_intra = atoi (argv[0]);
6425 ospf->distance_external = atoi (argv[1]);
6426
paul718e3742002-12-13 20:15:29 +00006427 return CMD_SUCCESS;
6428}
6429
6430DEFUN (ospf_distance_ospf_intra_inter_external,
6431 ospf_distance_ospf_intra_inter_external_cmd,
6432 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6433 "Define an administrative distance\n"
6434 "OSPF Administrative distance\n"
6435 "Intra-area routes\n"
6436 "Distance for intra-area routes\n"
6437 "Inter-area routes\n"
6438 "Distance for inter-area routes\n"
6439 "External routes\n"
6440 "Distance for external routes\n")
6441{
paul68980082003-03-25 05:07:42 +00006442 struct ospf *ospf = vty->index;
6443
6444 ospf->distance_intra = atoi (argv[0]);
6445 ospf->distance_inter = atoi (argv[1]);
6446 ospf->distance_external = atoi (argv[2]);
6447
paul718e3742002-12-13 20:15:29 +00006448 return CMD_SUCCESS;
6449}
6450
6451DEFUN (ospf_distance_ospf_intra_external_inter,
6452 ospf_distance_ospf_intra_external_inter_cmd,
6453 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6454 "Define an administrative distance\n"
6455 "OSPF Administrative distance\n"
6456 "Intra-area routes\n"
6457 "Distance for intra-area routes\n"
6458 "External routes\n"
6459 "Distance for external routes\n"
6460 "Inter-area routes\n"
6461 "Distance for inter-area routes\n")
6462{
paul68980082003-03-25 05:07:42 +00006463 struct ospf *ospf = vty->index;
6464
6465 ospf->distance_intra = atoi (argv[0]);
6466 ospf->distance_external = atoi (argv[1]);
6467 ospf->distance_inter = atoi (argv[2]);
6468
paul718e3742002-12-13 20:15:29 +00006469 return CMD_SUCCESS;
6470}
6471
6472DEFUN (ospf_distance_ospf_inter,
6473 ospf_distance_ospf_inter_cmd,
6474 "distance ospf inter-area <1-255>",
6475 "Define an administrative distance\n"
6476 "OSPF Administrative distance\n"
6477 "Inter-area routes\n"
6478 "Distance for inter-area routes\n")
6479{
paul68980082003-03-25 05:07:42 +00006480 struct ospf *ospf = vty->index;
6481
6482 ospf->distance_inter = atoi (argv[0]);
6483
paul718e3742002-12-13 20:15:29 +00006484 return CMD_SUCCESS;
6485}
6486
6487DEFUN (ospf_distance_ospf_inter_intra,
6488 ospf_distance_ospf_inter_intra_cmd,
6489 "distance ospf inter-area <1-255> intra-area <1-255>",
6490 "Define an administrative distance\n"
6491 "OSPF Administrative distance\n"
6492 "Inter-area routes\n"
6493 "Distance for inter-area routes\n"
6494 "Intra-area routes\n"
6495 "Distance for intra-area routes\n")
6496{
paul68980082003-03-25 05:07:42 +00006497 struct ospf *ospf = vty->index;
6498
6499 ospf->distance_inter = atoi (argv[0]);
6500 ospf->distance_intra = atoi (argv[1]);
6501
paul718e3742002-12-13 20:15:29 +00006502 return CMD_SUCCESS;
6503}
6504
6505DEFUN (ospf_distance_ospf_inter_external,
6506 ospf_distance_ospf_inter_external_cmd,
6507 "distance ospf inter-area <1-255> external <1-255>",
6508 "Define an administrative distance\n"
6509 "OSPF Administrative distance\n"
6510 "Inter-area routes\n"
6511 "Distance for inter-area routes\n"
6512 "External routes\n"
6513 "Distance for external routes\n")
6514{
paul68980082003-03-25 05:07:42 +00006515 struct ospf *ospf = vty->index;
6516
6517 ospf->distance_inter = atoi (argv[0]);
6518 ospf->distance_external = atoi (argv[1]);
6519
paul718e3742002-12-13 20:15:29 +00006520 return CMD_SUCCESS;
6521}
6522
6523DEFUN (ospf_distance_ospf_inter_intra_external,
6524 ospf_distance_ospf_inter_intra_external_cmd,
6525 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6526 "Define an administrative distance\n"
6527 "OSPF Administrative distance\n"
6528 "Inter-area routes\n"
6529 "Distance for inter-area routes\n"
6530 "Intra-area routes\n"
6531 "Distance for intra-area routes\n"
6532 "External routes\n"
6533 "Distance for external routes\n")
6534{
paul68980082003-03-25 05:07:42 +00006535 struct ospf *ospf = vty->index;
6536
6537 ospf->distance_inter = atoi (argv[0]);
6538 ospf->distance_intra = atoi (argv[1]);
6539 ospf->distance_external = atoi (argv[2]);
6540
paul718e3742002-12-13 20:15:29 +00006541 return CMD_SUCCESS;
6542}
6543
6544DEFUN (ospf_distance_ospf_inter_external_intra,
6545 ospf_distance_ospf_inter_external_intra_cmd,
6546 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6547 "Define an administrative distance\n"
6548 "OSPF Administrative distance\n"
6549 "Inter-area routes\n"
6550 "Distance for inter-area routes\n"
6551 "External routes\n"
6552 "Distance for external routes\n"
6553 "Intra-area routes\n"
6554 "Distance for intra-area routes\n")
6555{
paul68980082003-03-25 05:07:42 +00006556 struct ospf *ospf = vty->index;
6557
6558 ospf->distance_inter = atoi (argv[0]);
6559 ospf->distance_external = atoi (argv[1]);
6560 ospf->distance_intra = atoi (argv[2]);
6561
paul718e3742002-12-13 20:15:29 +00006562 return CMD_SUCCESS;
6563}
6564
6565DEFUN (ospf_distance_ospf_external,
6566 ospf_distance_ospf_external_cmd,
6567 "distance ospf external <1-255>",
6568 "Define an administrative distance\n"
6569 "OSPF Administrative distance\n"
6570 "External routes\n"
6571 "Distance for external routes\n")
6572{
paul68980082003-03-25 05:07:42 +00006573 struct ospf *ospf = vty->index;
6574
6575 ospf->distance_external = atoi (argv[0]);
6576
paul718e3742002-12-13 20:15:29 +00006577 return CMD_SUCCESS;
6578}
6579
6580DEFUN (ospf_distance_ospf_external_intra,
6581 ospf_distance_ospf_external_intra_cmd,
6582 "distance ospf external <1-255> intra-area <1-255>",
6583 "Define an administrative distance\n"
6584 "OSPF Administrative distance\n"
6585 "External routes\n"
6586 "Distance for external routes\n"
6587 "Intra-area routes\n"
6588 "Distance for intra-area routes\n")
6589{
paul68980082003-03-25 05:07:42 +00006590 struct ospf *ospf = vty->index;
6591
6592 ospf->distance_external = atoi (argv[0]);
6593 ospf->distance_intra = atoi (argv[1]);
6594
paul718e3742002-12-13 20:15:29 +00006595 return CMD_SUCCESS;
6596}
6597
6598DEFUN (ospf_distance_ospf_external_inter,
6599 ospf_distance_ospf_external_inter_cmd,
6600 "distance ospf external <1-255> inter-area <1-255>",
6601 "Define an administrative distance\n"
6602 "OSPF Administrative distance\n"
6603 "External routes\n"
6604 "Distance for external routes\n"
6605 "Inter-area routes\n"
6606 "Distance for inter-area routes\n")
6607{
paul68980082003-03-25 05:07:42 +00006608 struct ospf *ospf = vty->index;
6609
6610 ospf->distance_external = atoi (argv[0]);
6611 ospf->distance_inter = atoi (argv[1]);
6612
paul718e3742002-12-13 20:15:29 +00006613 return CMD_SUCCESS;
6614}
6615
6616DEFUN (ospf_distance_ospf_external_intra_inter,
6617 ospf_distance_ospf_external_intra_inter_cmd,
6618 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6619 "Define an administrative distance\n"
6620 "OSPF Administrative distance\n"
6621 "External routes\n"
6622 "Distance for external routes\n"
6623 "Intra-area routes\n"
6624 "Distance for intra-area routes\n"
6625 "Inter-area routes\n"
6626 "Distance for inter-area routes\n")
6627{
paul68980082003-03-25 05:07:42 +00006628 struct ospf *ospf = vty->index;
6629
6630 ospf->distance_external = atoi (argv[0]);
6631 ospf->distance_intra = atoi (argv[1]);
6632 ospf->distance_inter = atoi (argv[2]);
6633
paul718e3742002-12-13 20:15:29 +00006634 return CMD_SUCCESS;
6635}
6636
6637DEFUN (ospf_distance_ospf_external_inter_intra,
6638 ospf_distance_ospf_external_inter_intra_cmd,
6639 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6640 "Define an administrative distance\n"
6641 "OSPF Administrative distance\n"
6642 "External routes\n"
6643 "Distance for external routes\n"
6644 "Inter-area routes\n"
6645 "Distance for inter-area routes\n"
6646 "Intra-area routes\n"
6647 "Distance for intra-area routes\n")
6648{
paul68980082003-03-25 05:07:42 +00006649 struct ospf *ospf = vty->index;
6650
6651 ospf->distance_external = atoi (argv[0]);
6652 ospf->distance_inter = atoi (argv[1]);
6653 ospf->distance_intra = atoi (argv[2]);
6654
paul718e3742002-12-13 20:15:29 +00006655 return CMD_SUCCESS;
6656}
6657
6658DEFUN (ospf_distance_source,
6659 ospf_distance_source_cmd,
6660 "distance <1-255> A.B.C.D/M",
6661 "Administrative distance\n"
6662 "Distance value\n"
6663 "IP source prefix\n")
6664{
paul020709f2003-04-04 02:44:16 +00006665 struct ospf *ospf = vty->index;
6666
6667 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006668
paul718e3742002-12-13 20:15:29 +00006669 return CMD_SUCCESS;
6670}
6671
6672DEFUN (no_ospf_distance_source,
6673 no_ospf_distance_source_cmd,
6674 "no distance <1-255> A.B.C.D/M",
6675 NO_STR
6676 "Administrative distance\n"
6677 "Distance value\n"
6678 "IP source prefix\n")
6679{
paul020709f2003-04-04 02:44:16 +00006680 struct ospf *ospf = vty->index;
6681
6682 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6683
paul718e3742002-12-13 20:15:29 +00006684 return CMD_SUCCESS;
6685}
6686
6687DEFUN (ospf_distance_source_access_list,
6688 ospf_distance_source_access_list_cmd,
6689 "distance <1-255> A.B.C.D/M WORD",
6690 "Administrative distance\n"
6691 "Distance value\n"
6692 "IP source prefix\n"
6693 "Access list name\n")
6694{
paul020709f2003-04-04 02:44:16 +00006695 struct ospf *ospf = vty->index;
6696
6697 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6698
paul718e3742002-12-13 20:15:29 +00006699 return CMD_SUCCESS;
6700}
6701
6702DEFUN (no_ospf_distance_source_access_list,
6703 no_ospf_distance_source_access_list_cmd,
6704 "no distance <1-255> A.B.C.D/M WORD",
6705 NO_STR
6706 "Administrative distance\n"
6707 "Distance value\n"
6708 "IP source prefix\n"
6709 "Access list name\n")
6710{
paul020709f2003-04-04 02:44:16 +00006711 struct ospf *ospf = vty->index;
6712
6713 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6714
paul718e3742002-12-13 20:15:29 +00006715 return CMD_SUCCESS;
6716}
6717
vincentba682532005-09-29 13:52:57 +00006718DEFUN (ip_ospf_mtu_ignore,
6719 ip_ospf_mtu_ignore_addr_cmd,
6720 "ip ospf mtu-ignore A.B.C.D",
6721 "IP Information\n"
6722 "OSPF interface commands\n"
6723 "Disable mtu mismatch detection\n"
6724 "Address of interface")
6725{
6726 struct interface *ifp = vty->index;
6727 struct in_addr addr;
6728 int ret;
6729
6730 struct ospf_if_params *params;
6731 params = IF_DEF_PARAMS (ifp);
6732
6733 if (argc == 1)
6734 {
6735 ret = inet_aton(argv[0], &addr);
6736 if (!ret)
6737 {
6738 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6739 VTY_NEWLINE);
6740 return CMD_WARNING;
6741 }
6742 params = ospf_get_if_params (ifp, addr);
6743 ospf_if_update_params (ifp, addr);
6744 }
6745 params->mtu_ignore = 1;
6746 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6747 SET_IF_PARAM (params, mtu_ignore);
6748 else
6749 {
6750 UNSET_IF_PARAM (params, mtu_ignore);
6751 if (params != IF_DEF_PARAMS (ifp))
6752 {
6753 ospf_free_if_params (ifp, addr);
6754 ospf_if_update_params (ifp, addr);
6755 }
6756 }
6757 return CMD_SUCCESS;
6758}
6759
6760ALIAS (ip_ospf_mtu_ignore,
6761 ip_ospf_mtu_ignore_cmd,
6762 "ip ospf mtu-ignore",
6763 "IP Information\n"
6764 "OSPF interface commands\n"
6765 "Disable mtu mismatch detection\n")
6766
6767
6768DEFUN (no_ip_ospf_mtu_ignore,
6769 no_ip_ospf_mtu_ignore_addr_cmd,
6770 "no ip ospf mtu-ignore A.B.C.D",
6771 "IP Information\n"
6772 "OSPF interface commands\n"
6773 "Disable mtu mismatch detection\n"
6774 "Address of interface")
6775{
6776 struct interface *ifp = vty->index;
6777 struct in_addr addr;
6778 int ret;
6779
6780 struct ospf_if_params *params;
6781 params = IF_DEF_PARAMS (ifp);
6782
6783 if (argc == 1)
6784 {
6785 ret = inet_aton(argv[0], &addr);
6786 if (!ret)
6787 {
6788 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6789 VTY_NEWLINE);
6790 return CMD_WARNING;
6791 }
6792 params = ospf_get_if_params (ifp, addr);
6793 ospf_if_update_params (ifp, addr);
6794 }
6795 params->mtu_ignore = 0;
6796 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6797 SET_IF_PARAM (params, mtu_ignore);
6798 else
6799 {
6800 UNSET_IF_PARAM (params, mtu_ignore);
6801 if (params != IF_DEF_PARAMS (ifp))
6802 {
6803 ospf_free_if_params (ifp, addr);
6804 ospf_if_update_params (ifp, addr);
6805 }
6806 }
6807 return CMD_SUCCESS;
6808}
6809
6810ALIAS (no_ip_ospf_mtu_ignore,
6811 no_ip_ospf_mtu_ignore_cmd,
6812 "no ip ospf mtu-ignore",
6813 "IP Information\n"
6814 "OSPF interface commands\n"
6815 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00006816
6817DEFUN (ospf_max_metric_router_lsa_admin,
6818 ospf_max_metric_router_lsa_admin_cmd,
6819 "max-metric router-lsa administrative",
6820 "OSPF maximum / infinite-distance metric\n"
6821 "Advertise own Router-LSA with infinite distance (stub router)\n"
6822 "Administratively applied, for an indefinite period\n")
6823{
6824 struct listnode *ln;
6825 struct ospf_area *area;
6826 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006827
paul88d6cf32005-10-29 12:50:09 +00006828 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6829 {
6830 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6831
6832 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
6833 ospf_router_lsa_timer_add (area);
6834 }
6835 return CMD_SUCCESS;
6836}
6837
6838DEFUN (no_ospf_max_metric_router_lsa_admin,
6839 no_ospf_max_metric_router_lsa_admin_cmd,
6840 "no max-metric router-lsa administrative",
6841 NO_STR
6842 "OSPF maximum / infinite-distance metric\n"
6843 "Advertise own Router-LSA with infinite distance (stub router)\n"
6844 "Administratively applied, for an indefinite period\n")
6845{
6846 struct listnode *ln;
6847 struct ospf_area *area;
6848 struct ospf *ospf = vty->index;
6849
6850 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6851 {
6852 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6853
6854 /* Don't trample on the start-up stub timer */
6855 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6856 && !area->t_stub_router)
6857 {
6858 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6859 ospf_router_lsa_timer_add (area);
6860 }
6861 }
6862 return CMD_SUCCESS;
6863}
6864
6865DEFUN (ospf_max_metric_router_lsa_startup,
6866 ospf_max_metric_router_lsa_startup_cmd,
6867 "max-metric router-lsa on-startup <5-86400>",
6868 "OSPF maximum / infinite-distance metric\n"
6869 "Advertise own Router-LSA with infinite distance (stub router)\n"
6870 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6871 "Time (seconds) to advertise self as stub-router\n")
6872{
6873 unsigned int seconds;
6874 struct ospf *ospf = vty->index;
6875
6876 if (argc != 1)
6877 {
6878 vty_out (vty, "%% Must supply stub-router period");
6879 return CMD_WARNING;
6880 }
6881
6882 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6883
6884 ospf->stub_router_startup_time = seconds;
6885
6886 return CMD_SUCCESS;
6887}
6888
6889DEFUN (no_ospf_max_metric_router_lsa_startup,
6890 no_ospf_max_metric_router_lsa_startup_cmd,
6891 "no max-metric router-lsa on-startup",
6892 NO_STR
6893 "OSPF maximum / infinite-distance metric\n"
6894 "Advertise own Router-LSA with infinite distance (stub router)\n"
6895 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6896{
6897 struct listnode *ln;
6898 struct ospf_area *area;
6899 struct ospf *ospf = vty->index;
6900
6901 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6902
6903 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6904 {
6905 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6906 OSPF_TIMER_OFF (area->t_stub_router);
6907
6908 /* Don't trample on admin stub routed */
6909 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6910 {
6911 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6912 ospf_router_lsa_timer_add (area);
6913 }
6914 }
6915 return CMD_SUCCESS;
6916}
6917
6918DEFUN (ospf_max_metric_router_lsa_shutdown,
6919 ospf_max_metric_router_lsa_shutdown_cmd,
6920 "max-metric router-lsa on-shutdown <5-86400>",
6921 "OSPF maximum / infinite-distance metric\n"
6922 "Advertise own Router-LSA with infinite distance (stub router)\n"
6923 "Advertise stub-router prior to full shutdown of OSPF\n"
6924 "Time (seconds) to wait till full shutdown\n")
6925{
6926 unsigned int seconds;
6927 struct ospf *ospf = vty->index;
6928
6929 if (argc != 1)
6930 {
6931 vty_out (vty, "%% Must supply stub-router shutdown period");
6932 return CMD_WARNING;
6933 }
6934
6935 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6936
6937 ospf->stub_router_shutdown_time = seconds;
6938
6939 return CMD_SUCCESS;
6940}
6941
6942DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6943 no_ospf_max_metric_router_lsa_shutdown_cmd,
6944 "no max-metric router-lsa on-shutdown",
6945 NO_STR
6946 "OSPF maximum / infinite-distance metric\n"
6947 "Advertise own Router-LSA with infinite distance (stub router)\n"
6948 "Advertise stub-router prior to full shutdown of OSPF\n")
6949{
6950 struct ospf *ospf = vty->index;
6951
6952 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6953
6954 return CMD_SUCCESS;
6955}
6956
6957static void
6958config_write_stub_router (struct vty *vty, struct ospf *ospf)
6959{
6960 struct listnode *ln;
6961 struct ospf_area *area;
6962
6963 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6964 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6965 ospf->stub_router_startup_time, VTY_NEWLINE);
6966 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6967 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6968 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6969 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6970 {
6971 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6972 {
6973 vty_out (vty, " max-metric router-lsa administrative%s",
6974 VTY_NEWLINE);
6975 break;
6976 }
6977 }
6978 return;
6979}
6980
paul4dadc292005-05-06 21:37:42 +00006981static void
paul718e3742002-12-13 20:15:29 +00006982show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6983{
6984 struct route_node *rn;
6985 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006986 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006987 struct ospf_path *path;
6988
6989 vty_out (vty, "============ OSPF network routing table ============%s",
6990 VTY_NEWLINE);
6991
6992 for (rn = route_top (rt); rn; rn = route_next (rn))
6993 if ((or = rn->info) != NULL)
6994 {
6995 char buf1[19];
6996 snprintf (buf1, 19, "%s/%d",
6997 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6998
6999 switch (or->path_type)
7000 {
7001 case OSPF_PATH_INTER_AREA:
7002 if (or->type == OSPF_DESTINATION_NETWORK)
7003 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7004 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7005 else if (or->type == OSPF_DESTINATION_DISCARD)
7006 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7007 break;
7008 case OSPF_PATH_INTRA_AREA:
7009 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7010 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7011 break;
7012 default:
7013 break;
7014 }
7015
7016 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007017 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007018 {
hasso54bedb52005-08-17 13:31:47 +00007019 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00007020 {
7021 if (path->nexthop.s_addr == 0)
7022 vty_out (vty, "%24s directly attached to %s%s",
7023 "", path->oi->ifp->name, VTY_NEWLINE);
7024 else
7025 vty_out (vty, "%24s via %s, %s%s", "",
7026 inet_ntoa (path->nexthop), path->oi->ifp->name,
7027 VTY_NEWLINE);
7028 }
7029 }
paul718e3742002-12-13 20:15:29 +00007030 }
7031 vty_out (vty, "%s", VTY_NEWLINE);
7032}
7033
paul4dadc292005-05-06 21:37:42 +00007034static void
paul718e3742002-12-13 20:15:29 +00007035show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7036{
7037 struct route_node *rn;
7038 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007039 struct listnode *pnode;
7040 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007041 struct ospf_path *path;
7042
7043 vty_out (vty, "============ OSPF router routing table =============%s",
7044 VTY_NEWLINE);
7045 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7046 if (rn->info)
7047 {
7048 int flag = 0;
7049
7050 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7051
paul1eb8ef22005-04-07 07:30:20 +00007052 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7053 {
7054 if (flag++)
7055 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007056
paul1eb8ef22005-04-07 07:30:20 +00007057 /* Show path. */
7058 vty_out (vty, "%s [%d] area: %s",
7059 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7060 or->cost, inet_ntoa (or->u.std.area_id));
7061 /* Show flags. */
7062 vty_out (vty, "%s%s%s",
7063 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7064 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7065 VTY_NEWLINE);
7066
7067 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7068 {
hasso54bedb52005-08-17 13:31:47 +00007069 if (path->oi != NULL && ospf_if_exists(path->oi))
7070 {
7071 if (path->nexthop.s_addr == 0)
7072 vty_out (vty, "%24s directly attached to %s%s",
7073 "", path->oi->ifp->name, VTY_NEWLINE);
7074 else
7075 vty_out (vty, "%24s via %s, %s%s", "",
7076 inet_ntoa (path->nexthop),
7077 path->oi->ifp->name, VTY_NEWLINE);
7078 }
paul1eb8ef22005-04-07 07:30:20 +00007079 }
7080 }
paul718e3742002-12-13 20:15:29 +00007081 }
7082 vty_out (vty, "%s", VTY_NEWLINE);
7083}
7084
paul4dadc292005-05-06 21:37:42 +00007085static void
paul718e3742002-12-13 20:15:29 +00007086show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7087{
7088 struct route_node *rn;
7089 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007090 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007091 struct ospf_path *path;
7092
7093 vty_out (vty, "============ OSPF external routing table ===========%s",
7094 VTY_NEWLINE);
7095 for (rn = route_top (rt); rn; rn = route_next (rn))
7096 if ((er = rn->info) != NULL)
7097 {
7098 char buf1[19];
7099 snprintf (buf1, 19, "%s/%d",
7100 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7101
7102 switch (er->path_type)
7103 {
7104 case OSPF_PATH_TYPE1_EXTERNAL:
7105 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7106 er->cost, er->u.ext.tag, VTY_NEWLINE);
7107 break;
7108 case OSPF_PATH_TYPE2_EXTERNAL:
7109 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7110 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7111 break;
7112 }
7113
paul1eb8ef22005-04-07 07:30:20 +00007114 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007115 {
hasso54bedb52005-08-17 13:31:47 +00007116 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00007117 {
7118 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007119 vty_out (vty, "%24s directly attached to %s%s",
7120 "", path->oi->ifp->name, VTY_NEWLINE);
7121 else
7122 vty_out (vty, "%24s via %s, %s%s", "",
7123 inet_ntoa (path->nexthop), path->oi->ifp->name,
7124 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007125 }
7126 }
7127 }
7128 vty_out (vty, "%s", VTY_NEWLINE);
7129}
7130
paul718e3742002-12-13 20:15:29 +00007131DEFUN (show_ip_ospf_border_routers,
7132 show_ip_ospf_border_routers_cmd,
7133 "show ip ospf border-routers",
7134 SHOW_STR
7135 IP_STR
7136 "show all the ABR's and ASBR's\n"
7137 "for this area\n")
7138{
paul020709f2003-04-04 02:44:16 +00007139 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007140
paul020709f2003-04-04 02:44:16 +00007141 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007142 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00007143 {
7144 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
7145 return CMD_SUCCESS;
7146 }
7147
paul68980082003-03-25 05:07:42 +00007148 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007149 {
7150 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7151 return CMD_SUCCESS;
7152 }
7153
7154 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007155 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007156
7157 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007158 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007159
7160 return CMD_SUCCESS;
7161}
paul718e3742002-12-13 20:15:29 +00007162
7163DEFUN (show_ip_ospf_route,
7164 show_ip_ospf_route_cmd,
7165 "show ip ospf route",
7166 SHOW_STR
7167 IP_STR
7168 "OSPF information\n"
7169 "OSPF routing table\n")
7170{
paul020709f2003-04-04 02:44:16 +00007171 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007172
paul020709f2003-04-04 02:44:16 +00007173 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007174 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00007175 {
7176 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
7177 return CMD_SUCCESS;
7178 }
7179
paul68980082003-03-25 05:07:42 +00007180 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007181 {
7182 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7183 return CMD_SUCCESS;
7184 }
7185
7186 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007187 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007188
7189 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007190 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007191
7192 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007193 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007194
7195 return CMD_SUCCESS;
7196}
7197
7198
hassoeb1ce602004-10-08 08:17:22 +00007199const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007200{
7201 "unknown",
7202 "standard",
7203 "ibm",
7204 "cisco",
7205 "shortcut"
7206};
7207
hassoeb1ce602004-10-08 08:17:22 +00007208const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007209{
7210 "default",
7211 "enable",
7212 "disable"
7213};
7214
7215
paul4dadc292005-05-06 21:37:42 +00007216static void
paul718e3742002-12-13 20:15:29 +00007217area_id2str (char *buf, int length, struct ospf_area *area)
7218{
7219 memset (buf, 0, length);
7220
7221 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7222 strncpy (buf, inet_ntoa (area->area_id), length);
7223 else
7224 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7225}
7226
7227
hassoeb1ce602004-10-08 08:17:22 +00007228const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007229{
7230 "unknown", /* should never be used. */
7231 "point-to-point",
7232 "broadcast",
7233 "non-broadcast",
7234 "point-to-multipoint",
7235 "virtual-link", /* should never be used. */
7236 "loopback"
7237};
7238
7239/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007240static int
paul718e3742002-12-13 20:15:29 +00007241config_write_interface (struct vty *vty)
7242{
hasso52dc7ee2004-09-23 19:18:23 +00007243 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007244 struct interface *ifp;
7245 struct crypt_key *ck;
7246 int write = 0;
7247 struct route_node *rn = NULL;
7248 struct ospf_if_params *params;
7249
paul1eb8ef22005-04-07 07:30:20 +00007250 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007251 {
paul718e3742002-12-13 20:15:29 +00007252 if (memcmp (ifp->name, "VLINK", 5) == 0)
7253 continue;
7254
7255 vty_out (vty, "!%s", VTY_NEWLINE);
7256 vty_out (vty, "interface %s%s", ifp->name,
7257 VTY_NEWLINE);
7258 if (ifp->desc)
7259 vty_out (vty, " description %s%s", ifp->desc,
7260 VTY_NEWLINE);
7261
7262 write++;
7263
7264 params = IF_DEF_PARAMS (ifp);
7265
7266 do {
7267 /* Interface Network print. */
7268 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007269 params->type != OSPF_IFTYPE_LOOPBACK)
7270 {
ajsbc18d612004-12-15 15:07:19 +00007271 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007272 {
7273 vty_out (vty, " ip ospf network %s",
7274 ospf_int_type_str[params->type]);
7275 if (params != IF_DEF_PARAMS (ifp))
7276 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7277 vty_out (vty, "%s", VTY_NEWLINE);
7278 }
paul718e3742002-12-13 20:15:29 +00007279 }
7280
7281 /* OSPF interface authentication print */
7282 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7283 params->auth_type != OSPF_AUTH_NOTSET)
7284 {
hassoeb1ce602004-10-08 08:17:22 +00007285 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007286
7287 /* Translation tables are not that much help here due to syntax
7288 of the simple option */
7289 switch (params->auth_type)
7290 {
7291
7292 case OSPF_AUTH_NULL:
7293 auth_str = " null";
7294 break;
7295
7296 case OSPF_AUTH_SIMPLE:
7297 auth_str = "";
7298 break;
7299
7300 case OSPF_AUTH_CRYPTOGRAPHIC:
7301 auth_str = " message-digest";
7302 break;
7303
7304 default:
7305 auth_str = "";
7306 break;
7307 }
7308
7309 vty_out (vty, " ip ospf authentication%s", auth_str);
7310 if (params != IF_DEF_PARAMS (ifp))
7311 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7312 vty_out (vty, "%s", VTY_NEWLINE);
7313 }
7314
7315 /* Simple Authentication Password print. */
7316 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7317 params->auth_simple[0] != '\0')
7318 {
7319 vty_out (vty, " ip ospf authentication-key %s",
7320 params->auth_simple);
7321 if (params != IF_DEF_PARAMS (ifp))
7322 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7323 vty_out (vty, "%s", VTY_NEWLINE);
7324 }
7325
7326 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007327 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007328 {
paul718e3742002-12-13 20:15:29 +00007329 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7330 ck->key_id, ck->auth_key);
7331 if (params != IF_DEF_PARAMS (ifp))
7332 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7333 vty_out (vty, "%s", VTY_NEWLINE);
7334 }
7335
7336 /* Interface Output Cost print. */
7337 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7338 {
7339 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7340 if (params != IF_DEF_PARAMS (ifp))
7341 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7342 vty_out (vty, "%s", VTY_NEWLINE);
7343 }
7344
7345 /* Hello Interval print. */
7346 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7347 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7348 {
7349 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7350 if (params != IF_DEF_PARAMS (ifp))
7351 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7352 vty_out (vty, "%s", VTY_NEWLINE);
7353 }
7354
7355
7356 /* Router Dead Interval print. */
7357 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7358 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7359 {
paulf9ad9372005-10-21 00:45:17 +00007360 vty_out (vty, " ip ospf dead-interval ");
7361
7362 /* fast hello ? */
7363 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7364 vty_out (vty, "minimal hello-multiplier %d",
7365 params->fast_hello);
7366 else
7367 vty_out (vty, "%u", params->v_wait);
7368
paul718e3742002-12-13 20:15:29 +00007369 if (params != IF_DEF_PARAMS (ifp))
7370 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7371 vty_out (vty, "%s", VTY_NEWLINE);
7372 }
7373
7374 /* Router Priority print. */
7375 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7376 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7377 {
7378 vty_out (vty, " ip ospf priority %u", params->priority);
7379 if (params != IF_DEF_PARAMS (ifp))
7380 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7381 vty_out (vty, "%s", VTY_NEWLINE);
7382 }
7383
7384 /* Retransmit Interval print. */
7385 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7386 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7387 {
7388 vty_out (vty, " ip ospf retransmit-interval %u",
7389 params->retransmit_interval);
7390 if (params != IF_DEF_PARAMS (ifp))
7391 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7392 vty_out (vty, "%s", VTY_NEWLINE);
7393 }
7394
7395 /* Transmit Delay print. */
7396 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7397 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7398 {
7399 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7400 if (params != IF_DEF_PARAMS (ifp))
7401 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7402 vty_out (vty, "%s", VTY_NEWLINE);
7403 }
7404
vincentba682532005-09-29 13:52:57 +00007405 /* MTU ignore print. */
7406 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7407 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7408 {
7409 if (params->mtu_ignore == 0)
7410 vty_out (vty, " no ip ospf mtu-ignore");
7411 else
7412 vty_out (vty, " ip ospf mtu-ignore");
7413 if (params != IF_DEF_PARAMS (ifp))
7414 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7415 vty_out (vty, "%s", VTY_NEWLINE);
7416 }
7417
7418
paul718e3742002-12-13 20:15:29 +00007419 while (1)
7420 {
7421 if (rn == NULL)
7422 rn = route_top (IF_OIFS_PARAMS (ifp));
7423 else
7424 rn = route_next (rn);
7425
7426 if (rn == NULL)
7427 break;
7428 params = rn->info;
7429 if (params != NULL)
7430 break;
7431 }
7432 } while (rn);
7433
7434#ifdef HAVE_OPAQUE_LSA
7435 ospf_opaque_config_write_if (vty, ifp);
7436#endif /* HAVE_OPAQUE_LSA */
7437 }
7438
7439 return write;
7440}
7441
paul4dadc292005-05-06 21:37:42 +00007442static int
paul68980082003-03-25 05:07:42 +00007443config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007444{
7445 struct route_node *rn;
7446 u_char buf[INET_ADDRSTRLEN];
7447
7448 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007449 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007450 if (rn->info)
7451 {
7452 struct ospf_network *n = rn->info;
7453
7454 memset (buf, 0, INET_ADDRSTRLEN);
7455
7456 /* Create Area ID string by specified Area ID format. */
7457 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007458 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007459 else
hassoc9e52be2004-09-26 16:09:34 +00007460 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007461 (unsigned long int) ntohl (n->area_id.s_addr));
7462
7463 /* Network print. */
7464 vty_out (vty, " network %s/%d area %s%s",
7465 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7466 buf, VTY_NEWLINE);
7467 }
7468
7469 return 0;
7470}
7471
paul4dadc292005-05-06 21:37:42 +00007472static int
paul68980082003-03-25 05:07:42 +00007473config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007474{
hasso52dc7ee2004-09-23 19:18:23 +00007475 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007476 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007477 u_char buf[INET_ADDRSTRLEN];
7478
7479 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007480 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007481 {
paul718e3742002-12-13 20:15:29 +00007482 struct route_node *rn1;
7483
hassoc9e52be2004-09-26 16:09:34 +00007484 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007485
7486 if (area->auth_type != OSPF_AUTH_NULL)
7487 {
7488 if (area->auth_type == OSPF_AUTH_SIMPLE)
7489 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7490 else
7491 vty_out (vty, " area %s authentication message-digest%s",
7492 buf, VTY_NEWLINE);
7493 }
7494
7495 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7496 vty_out (vty, " area %s shortcut %s%s", buf,
7497 ospf_shortcut_mode_str[area->shortcut_configured],
7498 VTY_NEWLINE);
7499
7500 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007501 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007502 )
7503 {
paulb0a053b2003-06-22 09:04:47 +00007504 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007505 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007506 else if (area->external_routing == OSPF_AREA_NSSA)
7507 {
7508 vty_out (vty, " area %s nssa", buf);
7509 switch (area->NSSATranslatorRole)
7510 {
7511 case OSPF_NSSA_ROLE_NEVER:
7512 vty_out (vty, " translate-never");
7513 break;
7514 case OSPF_NSSA_ROLE_ALWAYS:
7515 vty_out (vty, " translate-always");
7516 break;
7517 case OSPF_NSSA_ROLE_CANDIDATE:
7518 default:
7519 vty_out (vty, " translate-candidate");
7520 }
7521 }
paul718e3742002-12-13 20:15:29 +00007522
7523 if (area->no_summary)
7524 vty_out (vty, " no-summary");
7525
7526 vty_out (vty, "%s", VTY_NEWLINE);
7527
7528 if (area->default_cost != 1)
7529 vty_out (vty, " area %s default-cost %d%s", buf,
7530 area->default_cost, VTY_NEWLINE);
7531 }
7532
7533 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7534 if (rn1->info)
7535 {
7536 struct ospf_area_range *range = rn1->info;
7537
7538 vty_out (vty, " area %s range %s/%d", buf,
7539 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7540
paul6c835672004-10-11 11:00:30 +00007541 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007542 vty_out (vty, " cost %d", range->cost_config);
7543
7544 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7545 vty_out (vty, " not-advertise");
7546
7547 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7548 vty_out (vty, " substitute %s/%d",
7549 inet_ntoa (range->subst_addr), range->subst_masklen);
7550
7551 vty_out (vty, "%s", VTY_NEWLINE);
7552 }
7553
7554 if (EXPORT_NAME (area))
7555 vty_out (vty, " area %s export-list %s%s", buf,
7556 EXPORT_NAME (area), VTY_NEWLINE);
7557
7558 if (IMPORT_NAME (area))
7559 vty_out (vty, " area %s import-list %s%s", buf,
7560 IMPORT_NAME (area), VTY_NEWLINE);
7561
7562 if (PREFIX_NAME_IN (area))
7563 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7564 PREFIX_NAME_IN (area), VTY_NEWLINE);
7565
7566 if (PREFIX_NAME_OUT (area))
7567 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7568 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7569 }
7570
7571 return 0;
7572}
7573
paul4dadc292005-05-06 21:37:42 +00007574static int
paul68980082003-03-25 05:07:42 +00007575config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007576{
7577 struct ospf_nbr_nbma *nbr_nbma;
7578 struct route_node *rn;
7579
7580 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007581 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007582 if ((nbr_nbma = rn->info))
7583 {
7584 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7585
7586 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7587 vty_out (vty, " priority %d", nbr_nbma->priority);
7588
7589 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7590 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7591
7592 vty_out (vty, "%s", VTY_NEWLINE);
7593 }
7594
7595 return 0;
7596}
7597
paul4dadc292005-05-06 21:37:42 +00007598static int
paul68980082003-03-25 05:07:42 +00007599config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007600{
hasso52dc7ee2004-09-23 19:18:23 +00007601 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007602 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007603 u_char buf[INET_ADDRSTRLEN];
7604
7605 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007606 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007607 {
hasso52dc7ee2004-09-23 19:18:23 +00007608 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007609 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007610 struct ospf_interface *oi;
7611
7612 if (vl_data != NULL)
7613 {
7614 memset (buf, 0, INET_ADDRSTRLEN);
7615
7616 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007617 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007618 else
hassoc9e52be2004-09-26 16:09:34 +00007619 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007620 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7621 oi = vl_data->vl_oi;
7622
7623 /* timers */
7624 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7625 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7626 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7627 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7628 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7629 buf,
7630 inet_ntoa (vl_data->vl_peer),
7631 OSPF_IF_PARAM (oi, v_hello),
7632 OSPF_IF_PARAM (oi, retransmit_interval),
7633 OSPF_IF_PARAM (oi, transmit_delay),
7634 OSPF_IF_PARAM (oi, v_wait),
7635 VTY_NEWLINE);
7636 else
7637 vty_out (vty, " area %s virtual-link %s%s", buf,
7638 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7639 /* Auth key */
7640 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7641 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7642 buf,
7643 inet_ntoa (vl_data->vl_peer),
7644 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7645 VTY_NEWLINE);
7646 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007647 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7648 n2, ck))
7649 vty_out (vty, " area %s virtual-link %s"
7650 " message-digest-key %d md5 %s%s",
7651 buf,
7652 inet_ntoa (vl_data->vl_peer),
7653 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007654
7655 }
7656 }
7657
7658 return 0;
7659}
7660
7661
paul4dadc292005-05-06 21:37:42 +00007662static int
paul68980082003-03-25 05:07:42 +00007663config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007664{
7665 int type;
7666
7667 /* redistribute print. */
7668 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7669 if (type != zclient->redist_default && zclient->redist[type])
7670 {
ajsf52d13c2005-10-01 17:38:06 +00007671 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007672 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007673 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007674
paul68980082003-03-25 05:07:42 +00007675 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007676 vty_out (vty, " metric-type 1");
7677
paul020709f2003-04-04 02:44:16 +00007678 if (ROUTEMAP_NAME (ospf, type))
7679 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007680
7681 vty_out (vty, "%s", VTY_NEWLINE);
7682 }
7683
7684 return 0;
7685}
7686
paul4dadc292005-05-06 21:37:42 +00007687static int
paul68980082003-03-25 05:07:42 +00007688config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007689{
paul68980082003-03-25 05:07:42 +00007690 if (ospf->default_metric != -1)
7691 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007692 VTY_NEWLINE);
7693 return 0;
7694}
7695
paul4dadc292005-05-06 21:37:42 +00007696static int
paul68980082003-03-25 05:07:42 +00007697config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007698{
7699 int type;
7700
paul68980082003-03-25 05:07:42 +00007701 if (ospf)
paul718e3742002-12-13 20:15:29 +00007702 {
7703 /* distribute-list print. */
7704 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007705 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007706 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007707 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007708 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007709
7710 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007711 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007712 {
paulc42c1772006-01-10 20:36:49 +00007713 vty_out (vty, " default-information originate");
7714 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7715 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007716
paul68980082003-03-25 05:07:42 +00007717 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007718 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007719 ospf->dmetric[DEFAULT_ROUTE].value);
7720 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007721 vty_out (vty, " metric-type 1");
7722
paul020709f2003-04-04 02:44:16 +00007723 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7724 vty_out (vty, " route-map %s",
7725 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007726
7727 vty_out (vty, "%s", VTY_NEWLINE);
7728 }
7729
7730 }
7731
7732 return 0;
7733}
7734
paul4dadc292005-05-06 21:37:42 +00007735static int
paul68980082003-03-25 05:07:42 +00007736config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007737{
7738 struct route_node *rn;
7739 struct ospf_distance *odistance;
7740
paul68980082003-03-25 05:07:42 +00007741 if (ospf->distance_all)
7742 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007743
paul68980082003-03-25 05:07:42 +00007744 if (ospf->distance_intra
7745 || ospf->distance_inter
7746 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007747 {
7748 vty_out (vty, " distance ospf");
7749
paul68980082003-03-25 05:07:42 +00007750 if (ospf->distance_intra)
7751 vty_out (vty, " intra-area %d", ospf->distance_intra);
7752 if (ospf->distance_inter)
7753 vty_out (vty, " inter-area %d", ospf->distance_inter);
7754 if (ospf->distance_external)
7755 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007756
7757 vty_out (vty, "%s", VTY_NEWLINE);
7758 }
7759
paul68980082003-03-25 05:07:42 +00007760 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007761 if ((odistance = rn->info) != NULL)
7762 {
7763 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7764 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7765 odistance->access_list ? odistance->access_list : "",
7766 VTY_NEWLINE);
7767 }
7768 return 0;
7769}
7770
7771/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007772static int
paul718e3742002-12-13 20:15:29 +00007773ospf_config_write (struct vty *vty)
7774{
paul020709f2003-04-04 02:44:16 +00007775 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007776 struct interface *ifp;
7777 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007778 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007779 int write = 0;
7780
paul020709f2003-04-04 02:44:16 +00007781 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007782 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007783 {
7784 /* `router ospf' print. */
7785 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7786
7787 write++;
7788
paul68980082003-03-25 05:07:42 +00007789 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007790 return write;
7791
7792 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007793 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007794 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007795 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007796
7797 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007798 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007799 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007800 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007801
7802 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007803 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007804 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7805
7806 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007807 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007808 {
7809 vty_out (vty, "! Important: ensure reference bandwidth "
7810 "is consistent across all routers%s", VTY_NEWLINE);
7811 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7812 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7813 }
paul718e3742002-12-13 20:15:29 +00007814
7815 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007816 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007817 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7818 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7819 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007820 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007821 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007822
7823 /* Max-metric router-lsa print */
7824 config_write_stub_router (vty, ospf);
7825
paul718e3742002-12-13 20:15:29 +00007826 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007827 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007828 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007829 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007830
7831 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007832 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007833
7834 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007835 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7836 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7837 vty_out (vty, " passive-interface %s%s",
7838 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007839
paul1eb8ef22005-04-07 07:30:20 +00007840 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7841 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7842 oi->params->passive_interface == OSPF_IF_PASSIVE)
7843 vty_out (vty, " passive-interface %s %s%s",
7844 oi->ifp->name,
7845 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007846
7847 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007848 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007849
7850 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007851 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007852
7853 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007854 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007855
7856 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007857 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007858
7859 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007860 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007861
7862 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007863 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007864
7865 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007866 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007867
7868#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007869 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007870#endif /* HAVE_OPAQUE_LSA */
7871 }
7872
7873 return write;
7874}
7875
7876void
paul4dadc292005-05-06 21:37:42 +00007877ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007878{
7879 /* "show ip ospf" commands. */
7880 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7881 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7882
7883 /* "show ip ospf database" commands. */
7884 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7885 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7886 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7887 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7888 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7889 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7890 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7891 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7892 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7893 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7894 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7895 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7896 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7897 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7898
7899 /* "show ip ospf interface" commands. */
7900 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7901 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7902
7903 /* "show ip ospf neighbor" commands. */
7904 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7905 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7906 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7907 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7908 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7909 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7910 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7911 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7912 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7913 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7914 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7915 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7916 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7917 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7918
7919 /* "show ip ospf route" commands. */
7920 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7921 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007922 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7923 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007924}
7925
7926
7927/* ospfd's interface node. */
7928struct cmd_node interface_node =
7929{
7930 INTERFACE_NODE,
7931 "%s(config-if)# ",
7932 1
7933};
7934
7935/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007936static void
7937ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007938{
7939 /* Install interface node. */
7940 install_node (&interface_node, config_write_interface);
7941
7942 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007943 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007944 install_default (INTERFACE_NODE);
7945
7946 /* "description" commands. */
7947 install_element (INTERFACE_NODE, &interface_desc_cmd);
7948 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7949
7950 /* "ip ospf authentication" commands. */
7951 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7952 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7953 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7954 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7955 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7956 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7957 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7958 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7959 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7960 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7961
7962 /* "ip ospf message-digest-key" commands. */
7963 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7964 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7965 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7966 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7967
7968 /* "ip ospf cost" commands. */
7969 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7970 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7971 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7972 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7973
vincentba682532005-09-29 13:52:57 +00007974 /* "ip ospf mtu-ignore" commands. */
7975 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7976 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7977 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7978 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7979
paul718e3742002-12-13 20:15:29 +00007980 /* "ip ospf dead-interval" commands. */
7981 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7982 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007983 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7984 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007985 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7986 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007987
paul718e3742002-12-13 20:15:29 +00007988 /* "ip ospf hello-interval" commands. */
7989 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7990 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7991 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7992 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7993
7994 /* "ip ospf network" commands. */
7995 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7996 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7997
7998 /* "ip ospf priority" commands. */
7999 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8000 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8001 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8002 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8003
8004 /* "ip ospf retransmit-interval" commands. */
8005 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8006 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8007 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8008 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8009
8010 /* "ip ospf transmit-delay" commands. */
8011 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8012 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8013 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8014 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8015
8016 /* These commands are compatibitliy for previous version. */
8017 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8018 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8019 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8020 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
8021 install_element (INTERFACE_NODE, &ospf_cost_cmd);
8022 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
8023 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8024 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8025 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8026 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8027 install_element (INTERFACE_NODE, &ospf_network_cmd);
8028 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8029 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8030 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8031 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8032 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8033 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8034 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8035}
8036
8037/* Zebra node structure. */
8038struct cmd_node zebra_node =
8039{
8040 ZEBRA_NODE,
8041 "%s(config-router)#",
8042};
8043
paul4dadc292005-05-06 21:37:42 +00008044static void
8045ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008046{
8047 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8048 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8049 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8050 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8051 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8052 install_element (OSPF_NODE,
8053 &ospf_redistribute_source_metric_type_routemap_cmd);
8054 install_element (OSPF_NODE,
8055 &ospf_redistribute_source_type_metric_routemap_cmd);
8056 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8057 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8058 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8059
8060 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8061
8062 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8063 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8064
8065 install_element (OSPF_NODE,
8066 &ospf_default_information_originate_metric_type_cmd);
8067 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8068 install_element (OSPF_NODE,
8069 &ospf_default_information_originate_type_metric_cmd);
8070 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8071 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8072 install_element (OSPF_NODE,
8073 &ospf_default_information_originate_always_metric_type_cmd);
8074 install_element (OSPF_NODE,
8075 &ospf_default_information_originate_always_metric_cmd);
8076 install_element (OSPF_NODE,
8077 &ospf_default_information_originate_always_cmd);
8078 install_element (OSPF_NODE,
8079 &ospf_default_information_originate_always_type_metric_cmd);
8080 install_element (OSPF_NODE,
8081 &ospf_default_information_originate_always_type_cmd);
8082
8083 install_element (OSPF_NODE,
8084 &ospf_default_information_originate_metric_type_routemap_cmd);
8085 install_element (OSPF_NODE,
8086 &ospf_default_information_originate_metric_routemap_cmd);
8087 install_element (OSPF_NODE,
8088 &ospf_default_information_originate_routemap_cmd);
8089 install_element (OSPF_NODE,
8090 &ospf_default_information_originate_type_metric_routemap_cmd);
8091 install_element (OSPF_NODE,
8092 &ospf_default_information_originate_type_routemap_cmd);
8093 install_element (OSPF_NODE,
8094 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8095 install_element (OSPF_NODE,
8096 &ospf_default_information_originate_always_metric_routemap_cmd);
8097 install_element (OSPF_NODE,
8098 &ospf_default_information_originate_always_routemap_cmd);
8099 install_element (OSPF_NODE,
8100 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8101 install_element (OSPF_NODE,
8102 &ospf_default_information_originate_always_type_routemap_cmd);
8103
8104 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8105
8106 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8107 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8108 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8109
8110 install_element (OSPF_NODE, &ospf_distance_cmd);
8111 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8112 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8113 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8114 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8115 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8116 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8117 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8118 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8119 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8120 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8121 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8122 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8123 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8124 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8125 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8126 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8127 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8128#if 0
8129 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8130 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8131 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8132 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8133#endif /* 0 */
8134}
8135
8136struct cmd_node ospf_node =
8137{
8138 OSPF_NODE,
8139 "%s(config-router)# ",
8140 1
8141};
8142
8143
8144/* Install OSPF related vty commands. */
8145void
paul4dadc292005-05-06 21:37:42 +00008146ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008147{
8148 /* Install ospf top node. */
8149 install_node (&ospf_node, ospf_config_write);
8150
8151 /* "router ospf" commands. */
8152 install_element (CONFIG_NODE, &router_ospf_cmd);
8153 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8154
8155 install_default (OSPF_NODE);
8156
8157 /* "ospf router-id" commands. */
8158 install_element (OSPF_NODE, &ospf_router_id_cmd);
8159 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008160 install_element (OSPF_NODE, &router_ospf_id_cmd);
8161 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008162
8163 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008164 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8165 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8166 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8167 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008168
8169 /* "ospf abr-type" commands. */
8170 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8171 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8172
8173 /* "ospf rfc1583-compatible" commands. */
8174 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8175 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8176 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8177 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8178
8179 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008180 install_element (OSPF_NODE, &ospf_network_area_cmd);
8181 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008182
8183 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008184 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8185 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8186 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008187
8188 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008189 install_element (OSPF_NODE, &ospf_area_range_cmd);
8190 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8191 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8192 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8193 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8194 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8195 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8196 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8197 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8198 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8199 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008200
8201 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008202 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8203 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008204
paula2c62832003-04-23 17:01:31 +00008205 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8206 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008207
paula2c62832003-04-23 17:01:31 +00008208 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8209 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008210
paula2c62832003-04-23 17:01:31 +00008211 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8212 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008213
paula2c62832003-04-23 17:01:31 +00008214 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8215 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008216
paula2c62832003-04-23 17:01:31 +00008217 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8218 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8219 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008220
paula2c62832003-04-23 17:01:31 +00008221 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8222 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008223
paula2c62832003-04-23 17:01:31 +00008224 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8225 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008226
paula2c62832003-04-23 17:01:31 +00008227 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8228 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8229 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008230
paula2c62832003-04-23 17:01:31 +00008231 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8232 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8233 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008234
8235 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008236 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8237 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8238 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8239 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008240
paul718e3742002-12-13 20:15:29 +00008241 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008242 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8243 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8244 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8245 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8246 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8247 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008248
paula2c62832003-04-23 17:01:31 +00008249 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8250 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008251
paula2c62832003-04-23 17:01:31 +00008252 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8253 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008254
paula2c62832003-04-23 17:01:31 +00008255 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8256 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008257
paula2c62832003-04-23 17:01:31 +00008258 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8259 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008260
paula2c62832003-04-23 17:01:31 +00008261 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8262 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008263
8264 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008265 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8266 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008267 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8268 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8269
paul88d6cf32005-10-29 12:50:09 +00008270 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008271 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8272 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8273 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008274
paul88d6cf32005-10-29 12:50:09 +00008275 /* max-metric commands */
8276 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8277 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8278 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8279 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8280 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8281 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8282
8283 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008284 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8285 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008286
8287 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008288 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8289 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8290 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8291 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8292 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8293 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8294 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8295 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008296
8297 /* Init interface related vty commands. */
8298 ospf_vty_if_init ();
8299
8300 /* Init zebra related vty commands. */
8301 ospf_vty_zebra_init ();
8302}