blob: 32dfdea055515c228c4ecbe20335c82b2605c219 [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
725 if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)
726 {
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!!!*/
1077 if ((vl_data = ospf_vl_lookup (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
hasso3fb9cd62004-10-19 19:44:43 +00002739 if (oi->connected->destination)
2740 vty_out (vty, " %s %s,",
2741 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2742 inet_ntoa (oi->connected->destination->u.prefix4));
2743
paul718e3742002-12-13 20:15:29 +00002744 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2745 VTY_NEWLINE);
2746
vincentba682532005-09-29 13:52:57 +00002747 vty_out (vty, " MTU mismatch detection:%s%s",
2748 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2749
paul718e3742002-12-13 20:15:29 +00002750 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002751 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002752 oi->output_cost, VTY_NEWLINE);
2753
2754 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2755 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2756 PRIORITY (oi), VTY_NEWLINE);
2757
2758 /* Show DR information. */
2759 if (DR (oi).s_addr == 0)
2760 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2761 else
2762 {
2763 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2764 if (nbr == NULL)
2765 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2766 else
2767 {
2768 vty_out (vty, " Designated Router (ID) %s,",
2769 inet_ntoa (nbr->router_id));
2770 vty_out (vty, " Interface Address %s%s",
2771 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2772 }
2773 }
2774
2775 /* Show BDR information. */
2776 if (BDR (oi).s_addr == 0)
2777 vty_out (vty, " No backup designated router on this network%s",
2778 VTY_NEWLINE);
2779 else
2780 {
2781 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2782 if (nbr == NULL)
2783 vty_out (vty, " No backup designated router on this network%s",
2784 VTY_NEWLINE);
2785 else
2786 {
2787 vty_out (vty, " Backup Designated Router (ID) %s,",
2788 inet_ntoa (nbr->router_id));
2789 vty_out (vty, " Interface Address %s%s",
2790 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2791 }
2792 }
ajsba6454e2005-02-08 15:37:30 +00002793
2794 vty_out (vty, " Multicast group memberships:");
2795 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2796 vty_out (vty, " OSPFAllRouters");
2797 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2798 vty_out (vty, " OSPFDesignatedRouters");
2799 if (!CHECK_FLAG(oi->multicast_memberships,
2800 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2801 vty_out (vty, " <None>");
2802 vty_out (vty, "%s", VTY_NEWLINE);
2803
paul718e3742002-12-13 20:15:29 +00002804 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002805 vty_out (vty, " Hello ");
2806 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2807 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2808 else
2809 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2810 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2811 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002812 OSPF_IF_PARAM (oi, v_wait),
2813 OSPF_IF_PARAM (oi, retransmit_interval),
2814 VTY_NEWLINE);
2815
2816 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002817 {
ajs649654a2005-11-16 20:17:52 +00002818 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002819 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002820 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002821 VTY_NEWLINE);
2822 }
paul718e3742002-12-13 20:15:29 +00002823 else /* OSPF_IF_PASSIVE is set */
2824 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2825
2826 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002827 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002828 VTY_NEWLINE);
2829 }
2830}
2831
2832DEFUN (show_ip_ospf_interface,
2833 show_ip_ospf_interface_cmd,
2834 "show ip ospf interface [INTERFACE]",
2835 SHOW_STR
2836 IP_STR
2837 "OSPF information\n"
2838 "Interface information\n"
2839 "Interface name\n")
2840{
2841 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002842 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002843 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002844
paul020709f2003-04-04 02:44:16 +00002845 ospf = ospf_lookup ();
2846
paul718e3742002-12-13 20:15:29 +00002847 /* Show All Interfaces. */
2848 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002849 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2850 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002851 /* Interface name is specified. */
2852 else
2853 {
2854 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2855 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2856 else
paul68980082003-03-25 05:07:42 +00002857 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002858 }
2859
2860 return CMD_SUCCESS;
2861}
2862
paul4dadc292005-05-06 21:37:42 +00002863static void
pauld24f6e22005-10-21 09:23:12 +00002864show_ip_ospf_neighbour_header (struct vty *vty)
2865{
2866 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2867 VTY_NEWLINE,
2868 "Neighbor ID", "Pri", "State", "Dead Time",
2869 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
2870 VTY_NEWLINE);
2871}
2872
2873static void
paul718e3742002-12-13 20:15:29 +00002874show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2875{
2876 struct route_node *rn;
2877 struct ospf_neighbor *nbr;
2878 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00002879 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002880
2881 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2882 if ((nbr = rn->info))
2883 /* Do not show myself. */
2884 if (nbr != oi->nbr_self)
2885 /* Down state is not shown. */
2886 if (nbr->state != NSM_Down)
2887 {
2888 ospf_nbr_state_message (nbr, msgbuf, 16);
2889
2890 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00002891 vty_out (vty, "%-15s %3d %-15s ",
2892 "-", nbr->priority,
2893 msgbuf);
2894 else
2895 vty_out (vty, "%-15s %3d %-15s ",
2896 inet_ntoa (nbr->router_id), nbr->priority,
2897 msgbuf);
2898
2899 vty_out (vty, "%9s ",
2900 ospf_timer_dump (nbr->t_inactivity, timebuf,
2901 sizeof(timebuf)));
2902
paul718e3742002-12-13 20:15:29 +00002903 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00002904 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00002905 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2906 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2907 VTY_NEWLINE);
2908 }
2909}
2910
2911DEFUN (show_ip_ospf_neighbor,
2912 show_ip_ospf_neighbor_cmd,
2913 "show ip ospf neighbor",
2914 SHOW_STR
2915 IP_STR
2916 "OSPF information\n"
2917 "Neighbor list\n")
2918{
paul020709f2003-04-04 02:44:16 +00002919 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002920 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002921 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002922
paul020709f2003-04-04 02:44:16 +00002923 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002924 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002925 {
2926 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2927 return CMD_SUCCESS;
2928 }
2929
pauld24f6e22005-10-21 09:23:12 +00002930 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00002931
paul1eb8ef22005-04-07 07:30:20 +00002932 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
2933 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00002934
2935 return CMD_SUCCESS;
2936}
2937
2938DEFUN (show_ip_ospf_neighbor_all,
2939 show_ip_ospf_neighbor_all_cmd,
2940 "show ip ospf neighbor all",
2941 SHOW_STR
2942 IP_STR
2943 "OSPF information\n"
2944 "Neighbor list\n"
2945 "include down status neighbor\n")
2946{
paul68980082003-03-25 05:07:42 +00002947 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002948 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002949 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002950
paul68980082003-03-25 05:07:42 +00002951 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002952 {
2953 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2954 return CMD_SUCCESS;
2955 }
pauld24f6e22005-10-21 09:23:12 +00002956
2957 show_ip_ospf_neighbour_header (vty);
2958
paul1eb8ef22005-04-07 07:30:20 +00002959 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00002960 {
hasso52dc7ee2004-09-23 19:18:23 +00002961 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00002962 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00002963
2964 show_ip_ospf_neighbor_sub (vty, oi);
2965
2966 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00002967 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00002968 {
paul718e3742002-12-13 20:15:29 +00002969 if (nbr_nbma->nbr == NULL
2970 || nbr_nbma->nbr->state == NSM_Down)
2971 {
pauld24f6e22005-10-21 09:23:12 +00002972 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00002973 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00002974 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00002975 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2976 0, 0, 0, VTY_NEWLINE);
2977 }
2978 }
2979 }
2980
2981 return CMD_SUCCESS;
2982}
2983
2984DEFUN (show_ip_ospf_neighbor_int,
2985 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00002986 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00002987 SHOW_STR
2988 IP_STR
2989 "OSPF information\n"
2990 "Neighbor list\n"
2991 "Interface name\n")
2992{
paul020709f2003-04-04 02:44:16 +00002993 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00002994 struct interface *ifp;
2995 struct route_node *rn;
2996
2997 ifp = if_lookup_by_name (argv[0]);
2998 if (!ifp)
paul718e3742002-12-13 20:15:29 +00002999 {
hassobb5b7552005-08-21 20:01:15 +00003000 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003001 return CMD_WARNING;
3002 }
3003
paul020709f2003-04-04 02:44:16 +00003004 ospf = ospf_lookup ();
3005 if (ospf == NULL)
3006 {
3007 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3008 return CMD_SUCCESS;
3009 }
pauld24f6e22005-10-21 09:23:12 +00003010
3011 show_ip_ospf_neighbour_header (vty);
3012
hassobb5b7552005-08-21 20:01:15 +00003013 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003014 {
hassobb5b7552005-08-21 20:01:15 +00003015 struct ospf_interface *oi = rn->info;
3016
3017 if (oi == NULL)
3018 continue;
3019
paul718e3742002-12-13 20:15:29 +00003020 show_ip_ospf_neighbor_sub (vty, oi);
3021 }
3022
3023 return CMD_SUCCESS;
3024}
3025
paul4dadc292005-05-06 21:37:42 +00003026static void
paul718e3742002-12-13 20:15:29 +00003027show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3028 struct ospf_nbr_nbma *nbr_nbma)
3029{
ajs649654a2005-11-16 20:17:52 +00003030 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003031
3032 /* Show neighbor ID. */
3033 vty_out (vty, " Neighbor %s,", "-");
3034
3035 /* Show interface address. */
3036 vty_out (vty, " interface address %s%s",
3037 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3038 /* Show Area ID. */
3039 vty_out (vty, " In the area %s via interface %s%s",
3040 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3041 /* Show neighbor priority and state. */
3042 vty_out (vty, " Neighbor priority is %d, State is %s,",
3043 nbr_nbma->priority, "Down");
3044 /* Show state changes. */
3045 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3046
3047 /* Show PollInterval */
3048 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3049
3050 /* Show poll-interval timer. */
3051 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003052 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3053 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003054
3055 /* Show poll-interval timer thread. */
3056 vty_out (vty, " Thread Poll Timer %s%s",
3057 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3058}
3059
paul4dadc292005-05-06 21:37:42 +00003060static void
paul718e3742002-12-13 20:15:29 +00003061show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3062 struct ospf_neighbor *nbr)
3063{
ajs649654a2005-11-16 20:17:52 +00003064 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003065
3066 /* Show neighbor ID. */
3067 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3068 vty_out (vty, " Neighbor %s,", "-");
3069 else
3070 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3071
3072 /* Show interface address. */
3073 vty_out (vty, " interface address %s%s",
3074 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3075 /* Show Area ID. */
3076 vty_out (vty, " In the area %s via interface %s%s",
3077 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3078 /* Show neighbor priority and state. */
3079 vty_out (vty, " Neighbor priority is %d, State is %s,",
3080 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3081 /* Show state changes. */
3082 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3083
3084 /* Show Designated Rotuer ID. */
3085 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3086 /* Show Backup Designated Rotuer ID. */
3087 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3088 /* Show options. */
3089 vty_out (vty, " Options %d %s%s", nbr->options,
3090 ospf_options_dump (nbr->options), VTY_NEWLINE);
3091 /* Show Router Dead interval timer. */
3092 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003093 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3094 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003095 /* Show Database Summary list. */
3096 vty_out (vty, " Database Summary List %d%s",
3097 ospf_db_summary_count (nbr), VTY_NEWLINE);
3098 /* Show Link State Request list. */
3099 vty_out (vty, " Link State Request List %ld%s",
3100 ospf_ls_request_count (nbr), VTY_NEWLINE);
3101 /* Show Link State Retransmission list. */
3102 vty_out (vty, " Link State Retransmission List %ld%s",
3103 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3104 /* Show inactivity timer thread. */
3105 vty_out (vty, " Thread Inactivity Timer %s%s",
3106 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3107 /* Show Database Description retransmission thread. */
3108 vty_out (vty, " Thread Database Description Retransmision %s%s",
3109 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3110 /* Show Link State Request Retransmission thread. */
3111 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3112 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3113 /* Show Link State Update Retransmission thread. */
3114 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3115 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3116}
3117
3118DEFUN (show_ip_ospf_neighbor_id,
3119 show_ip_ospf_neighbor_id_cmd,
3120 "show ip ospf neighbor A.B.C.D",
3121 SHOW_STR
3122 IP_STR
3123 "OSPF information\n"
3124 "Neighbor list\n"
3125 "Neighbor ID\n")
3126{
paul020709f2003-04-04 02:44:16 +00003127 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003128 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003129 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003130 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003131 struct in_addr router_id;
3132 int ret;
3133
3134 ret = inet_aton (argv[0], &router_id);
3135 if (!ret)
3136 {
3137 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3138 return CMD_WARNING;
3139 }
3140
paul020709f2003-04-04 02:44:16 +00003141 ospf = ospf_lookup ();
3142 if (ospf == NULL)
3143 {
3144 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3145 return CMD_SUCCESS;
3146 }
3147
paul1eb8ef22005-04-07 07:30:20 +00003148 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3149 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3150 {
3151 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3152 return CMD_SUCCESS;
3153 }
paul718e3742002-12-13 20:15:29 +00003154
3155 /* Nothing to show. */
3156 return CMD_SUCCESS;
3157}
3158
3159DEFUN (show_ip_ospf_neighbor_detail,
3160 show_ip_ospf_neighbor_detail_cmd,
3161 "show ip ospf neighbor detail",
3162 SHOW_STR
3163 IP_STR
3164 "OSPF information\n"
3165 "Neighbor list\n"
3166 "detail of all neighbors\n")
3167{
paul020709f2003-04-04 02:44:16 +00003168 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003169 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003170 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003171
paul020709f2003-04-04 02:44:16 +00003172 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003173 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003174 {
3175 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3176 return CMD_SUCCESS;
3177 }
paul718e3742002-12-13 20:15:29 +00003178
paul1eb8ef22005-04-07 07:30:20 +00003179 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003180 {
paul718e3742002-12-13 20:15:29 +00003181 struct route_node *rn;
3182 struct ospf_neighbor *nbr;
3183
3184 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3185 if ((nbr = rn->info))
3186 if (nbr != oi->nbr_self)
3187 if (nbr->state != NSM_Down)
3188 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3189 }
3190
3191 return CMD_SUCCESS;
3192}
3193
3194DEFUN (show_ip_ospf_neighbor_detail_all,
3195 show_ip_ospf_neighbor_detail_all_cmd,
3196 "show ip ospf neighbor detail all",
3197 SHOW_STR
3198 IP_STR
3199 "OSPF information\n"
3200 "Neighbor list\n"
3201 "detail of all neighbors\n"
3202 "include down status neighbor\n")
3203{
paul020709f2003-04-04 02:44:16 +00003204 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003205 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003206 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003207
paul020709f2003-04-04 02:44:16 +00003208 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003209 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003210 {
3211 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3212 return CMD_SUCCESS;
3213 }
paul718e3742002-12-13 20:15:29 +00003214
paul1eb8ef22005-04-07 07:30:20 +00003215 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003216 {
paul718e3742002-12-13 20:15:29 +00003217 struct route_node *rn;
3218 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003219 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003220
3221 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3222 if ((nbr = rn->info))
3223 if (nbr != oi->nbr_self)
3224 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3225 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3226
3227 if (oi->type == OSPF_IFTYPE_NBMA)
3228 {
hasso52dc7ee2004-09-23 19:18:23 +00003229 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003230
paul1eb8ef22005-04-07 07:30:20 +00003231 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3232 if (nbr_nbma->nbr == NULL
3233 || nbr_nbma->nbr->state == NSM_Down)
3234 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003235 }
3236 }
3237
3238 return CMD_SUCCESS;
3239}
3240
3241DEFUN (show_ip_ospf_neighbor_int_detail,
3242 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003243 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003244 SHOW_STR
3245 IP_STR
3246 "OSPF information\n"
3247 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003248 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003249 "detail of all neighbors")
3250{
paul020709f2003-04-04 02:44:16 +00003251 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003252 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003253 struct interface *ifp;
3254 struct route_node *rn, *nrn;
3255 struct ospf_neighbor *nbr;
3256
3257 ifp = if_lookup_by_name (argv[0]);
3258 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003259 {
hassobb5b7552005-08-21 20:01:15 +00003260 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003261 return CMD_WARNING;
3262 }
3263
paul020709f2003-04-04 02:44:16 +00003264 ospf = ospf_lookup ();
3265 if (ospf == NULL)
3266 {
3267 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3268 return CMD_SUCCESS;
3269 }
paul68980082003-03-25 05:07:42 +00003270
paul718e3742002-12-13 20:15:29 +00003271
hassobb5b7552005-08-21 20:01:15 +00003272 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3273 if ((oi = rn->info))
3274 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3275 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003276 if (nbr != oi->nbr_self)
3277 if (nbr->state != NSM_Down)
3278 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003279
3280 return CMD_SUCCESS;
3281}
3282
3283
3284/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003285static int
paul020709f2003-04-04 02:44:16 +00003286show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003287{
paul718e3742002-12-13 20:15:29 +00003288 struct router_lsa *rl;
3289 struct summary_lsa *sl;
3290 struct as_external_lsa *asel;
3291 struct prefix_ipv4 p;
3292
3293 if (lsa != NULL)
3294 /* If self option is set, check LSA self flag. */
3295 if (self == 0 || IS_LSA_SELF (lsa))
3296 {
3297 /* LSA common part show. */
3298 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3299 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3300 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3301 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3302 /* LSA specific part show. */
3303 switch (lsa->data->type)
3304 {
3305 case OSPF_ROUTER_LSA:
3306 rl = (struct router_lsa *) lsa->data;
3307 vty_out (vty, " %-d", ntohs (rl->links));
3308 break;
3309 case OSPF_SUMMARY_LSA:
3310 sl = (struct summary_lsa *) lsa->data;
3311
3312 p.family = AF_INET;
3313 p.prefix = sl->header.id;
3314 p.prefixlen = ip_masklen (sl->mask);
3315 apply_mask_ipv4 (&p);
3316
3317 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3318 break;
3319 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003320 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003321 asel = (struct as_external_lsa *) lsa->data;
3322
3323 p.family = AF_INET;
3324 p.prefix = asel->header.id;
3325 p.prefixlen = ip_masklen (asel->mask);
3326 apply_mask_ipv4 (&p);
3327
3328 vty_out (vty, " %s %s/%d [0x%lx]",
3329 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3330 inet_ntoa (p.prefix), p.prefixlen,
3331 (u_long)ntohl (asel->e[0].route_tag));
3332 break;
3333 case OSPF_NETWORK_LSA:
3334 case OSPF_ASBR_SUMMARY_LSA:
3335#ifdef HAVE_OPAQUE_LSA
3336 case OSPF_OPAQUE_LINK_LSA:
3337 case OSPF_OPAQUE_AREA_LSA:
3338 case OSPF_OPAQUE_AS_LSA:
3339#endif /* HAVE_OPAQUE_LSA */
3340 default:
3341 break;
3342 }
3343 vty_out (vty, VTY_NEWLINE);
3344 }
3345
3346 return 0;
3347}
3348
hassoeb1ce602004-10-08 08:17:22 +00003349const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003350{
3351 "unknown",
3352 "Router Link States",
3353 "Net Link States",
3354 "Summary Link States",
3355 "ASBR-Summary Link States",
3356 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003357 "Group Membership LSA",
3358 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003359#ifdef HAVE_OPAQUE_LSA
3360 "Type-8 LSA",
3361 "Link-Local Opaque-LSA",
3362 "Area-Local Opaque-LSA",
3363 "AS-external Opaque-LSA",
3364#endif /* HAVE_OPAQUE_LSA */
3365};
3366
3367#define SHOW_OSPF_COMMON_HEADER \
3368 "Link ID ADV Router Age Seq# CkSum"
3369
hassoeb1ce602004-10-08 08:17:22 +00003370const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003371{
3372 "",
3373 "Link ID ADV Router Age Seq# CkSum Link count",
3374 "Link ID ADV Router Age Seq# CkSum",
3375 "Link ID ADV Router Age Seq# CkSum Route",
3376 "Link ID ADV Router Age Seq# CkSum",
3377 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003378 " --- header for Group Member ----",
3379 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003380#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003381 " --- type-8 ---",
3382 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3383 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3384 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3385#endif /* HAVE_OPAQUE_LSA */
3386};
3387
hassoeb1ce602004-10-08 08:17:22 +00003388const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003389{
3390 "Self-originated",
3391 "Checked",
3392 "Received",
3393 "Approved",
3394 "Discard",
paul4957f492003-06-27 01:28:45 +00003395 "Translated",
paul4957f492003-06-27 01:28:45 +00003396};
3397
paul4dadc292005-05-06 21:37:42 +00003398static void
paul718e3742002-12-13 20:15:29 +00003399show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3400{
3401 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003402
paul718e3742002-12-13 20:15:29 +00003403 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003404 vty_out (vty, " Options: 0x%-2x : %s%s",
3405 lsa->data->options,
3406 ospf_options_dump(lsa->data->options),
3407 VTY_NEWLINE);
3408 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003409 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003410 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3411 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003412
3413 if (lsa->data->type == OSPF_ROUTER_LSA)
3414 {
3415 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3416
3417 if (rlsa->flags)
3418 vty_out (vty, " :%s%s%s%s",
3419 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3420 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3421 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3422 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3423
3424 vty_out (vty, "%s", VTY_NEWLINE);
3425 }
3426 vty_out (vty, " LS Type: %s%s",
3427 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3428 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3429 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3430 vty_out (vty, " Advertising Router: %s%s",
3431 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3432 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3433 VTY_NEWLINE);
3434 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3435 VTY_NEWLINE);
3436 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3437}
3438
hassoeb1ce602004-10-08 08:17:22 +00003439const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003440{
3441 "(null)",
3442 "another Router (point-to-point)",
3443 "a Transit Network",
3444 "Stub Network",
3445 "a Virtual Link",
3446};
3447
hassoeb1ce602004-10-08 08:17:22 +00003448const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003449{
3450 "(null)",
3451 "Neighboring Router ID",
3452 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003453 "Net",
paul718e3742002-12-13 20:15:29 +00003454 "Neighboring Router ID",
3455};
3456
hassoeb1ce602004-10-08 08:17:22 +00003457const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003458{
3459 "(null)",
3460 "Router Interface address",
3461 "Router Interface address",
3462 "Network Mask",
3463 "Router Interface address",
3464};
3465
3466/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003467static void
paul718e3742002-12-13 20:15:29 +00003468show_ip_ospf_database_router_links (struct vty *vty,
3469 struct router_lsa *rl)
3470{
3471 int len, i, type;
3472
3473 len = ntohs (rl->header.length) - 4;
3474 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3475 {
3476 type = rl->link[i].type;
3477
3478 vty_out (vty, " Link connected to: %s%s",
3479 link_type_desc[type], VTY_NEWLINE);
3480 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3481 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3482 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3483 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3484 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3485 vty_out (vty, " TOS 0 Metric: %d%s",
3486 ntohs (rl->link[i].metric), VTY_NEWLINE);
3487 vty_out (vty, "%s", VTY_NEWLINE);
3488 }
3489}
3490
3491/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003492static int
paul718e3742002-12-13 20:15:29 +00003493show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3494{
3495 if (lsa != NULL)
3496 {
3497 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3498
3499 show_ip_ospf_database_header (vty, lsa);
3500
3501 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3502 VTY_NEWLINE, VTY_NEWLINE);
3503
3504 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003505 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003506 }
3507
3508 return 0;
3509}
3510
3511/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003512static int
paul718e3742002-12-13 20:15:29 +00003513show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3514{
3515 int length, i;
3516
3517 if (lsa != NULL)
3518 {
3519 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3520
3521 show_ip_ospf_database_header (vty, lsa);
3522
3523 vty_out (vty, " Network Mask: /%d%s",
3524 ip_masklen (nl->mask), VTY_NEWLINE);
3525
3526 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3527
3528 for (i = 0; length > 0; i++, length -= 4)
3529 vty_out (vty, " Attached Router: %s%s",
3530 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3531
3532 vty_out (vty, "%s", VTY_NEWLINE);
3533 }
3534
3535 return 0;
3536}
3537
3538/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003539static int
paul718e3742002-12-13 20:15:29 +00003540show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3541{
3542 if (lsa != NULL)
3543 {
3544 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3545
3546 show_ip_ospf_database_header (vty, lsa);
3547
3548 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3549 VTY_NEWLINE);
3550 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3551 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003552 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003553 }
3554
3555 return 0;
3556}
3557
3558/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003559static int
paul718e3742002-12-13 20:15:29 +00003560show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3561{
3562 if (lsa != NULL)
3563 {
3564 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3565
3566 show_ip_ospf_database_header (vty, lsa);
3567
3568 vty_out (vty, " Network Mask: /%d%s",
3569 ip_masklen (sl->mask), VTY_NEWLINE);
3570 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3571 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003572 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003573 }
3574
3575 return 0;
3576}
3577
3578/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003579static int
paul718e3742002-12-13 20:15:29 +00003580show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3581{
3582 if (lsa != NULL)
3583 {
3584 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3585
3586 show_ip_ospf_database_header (vty, lsa);
3587
3588 vty_out (vty, " Network Mask: /%d%s",
3589 ip_masklen (al->mask), VTY_NEWLINE);
3590 vty_out (vty, " Metric Type: %s%s",
3591 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3592 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3593 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3594 vty_out (vty, " Metric: %d%s",
3595 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3596 vty_out (vty, " Forward Address: %s%s",
3597 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3598
3599 vty_out (vty, " External Route Tag: %lu%s%s",
3600 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3601 }
3602
3603 return 0;
3604}
3605
ajs2a42e282004-12-08 18:43:03 +00003606/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003607static int
paul718e3742002-12-13 20:15:29 +00003608show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3609{
3610 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3611
3612 /* show_ip_ospf_database_header (vty, lsa); */
3613
ajs2a42e282004-12-08 18:43:03 +00003614 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003615 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003616 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003617 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3618 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003619 zlog_debug( " TOS: 0%s", "\n");
3620 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003621 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003622 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003623 inet_ntoa (al->e[0].fwd_addr), "\n");
3624
ajs2a42e282004-12-08 18:43:03 +00003625 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003626 ntohl (al->e[0].route_tag), "\n", "\n");
3627
3628 return 0;
3629}
3630
3631/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003632static int
paul718e3742002-12-13 20:15:29 +00003633show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3634{
3635 if (lsa != NULL)
3636 {
3637 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3638
3639 show_ip_ospf_database_header (vty, lsa);
3640
3641 vty_out (vty, " Network Mask: /%d%s",
3642 ip_masklen (al->mask), VTY_NEWLINE);
3643 vty_out (vty, " Metric Type: %s%s",
3644 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3645 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3646 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3647 vty_out (vty, " Metric: %d%s",
3648 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3649 vty_out (vty, " NSSA: Forward Address: %s%s",
3650 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3651
3652 vty_out (vty, " External Route Tag: %u%s%s",
3653 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3654 }
3655
3656 return 0;
3657}
3658
paul4dadc292005-05-06 21:37:42 +00003659static int
paul718e3742002-12-13 20:15:29 +00003660show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3661{
3662 return 0;
3663}
3664
3665#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003666static int
paul718e3742002-12-13 20:15:29 +00003667show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3668{
3669 if (lsa != NULL)
3670 {
3671 show_ip_ospf_database_header (vty, lsa);
3672 show_opaque_info_detail (vty, lsa);
3673
3674 vty_out (vty, "%s", VTY_NEWLINE);
3675 }
3676 return 0;
3677}
3678#endif /* HAVE_OPAQUE_LSA */
3679
3680int (*show_function[])(struct vty *, struct ospf_lsa *) =
3681{
3682 NULL,
3683 show_router_lsa_detail,
3684 show_network_lsa_detail,
3685 show_summary_lsa_detail,
3686 show_summary_asbr_lsa_detail,
3687 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003688 show_func_dummy,
3689 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003690#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003691 NULL, /* type-8 */
3692 show_opaque_lsa_detail,
3693 show_opaque_lsa_detail,
3694 show_opaque_lsa_detail,
3695#endif /* HAVE_OPAQUE_LSA */
3696};
3697
paul4dadc292005-05-06 21:37:42 +00003698static void
paul718e3742002-12-13 20:15:29 +00003699show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3700 struct in_addr *adv_router)
3701{
3702 memset (lp, 0, sizeof (struct prefix_ls));
3703 lp->family = 0;
3704 if (id == NULL)
3705 lp->prefixlen = 0;
3706 else if (adv_router == NULL)
3707 {
3708 lp->prefixlen = 32;
3709 lp->id = *id;
3710 }
3711 else
3712 {
3713 lp->prefixlen = 64;
3714 lp->id = *id;
3715 lp->adv_router = *adv_router;
3716 }
3717}
3718
paul4dadc292005-05-06 21:37:42 +00003719static void
paul718e3742002-12-13 20:15:29 +00003720show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3721 struct in_addr *id, struct in_addr *adv_router)
3722{
3723 struct prefix_ls lp;
3724 struct route_node *rn, *start;
3725 struct ospf_lsa *lsa;
3726
3727 show_lsa_prefix_set (vty, &lp, id, adv_router);
3728 start = route_node_get (rt, (struct prefix *) &lp);
3729 if (start)
3730 {
3731 route_lock_node (start);
3732 for (rn = start; rn; rn = route_next_until (rn, start))
3733 if ((lsa = rn->info))
3734 {
paul718e3742002-12-13 20:15:29 +00003735 if (show_function[lsa->data->type] != NULL)
3736 show_function[lsa->data->type] (vty, lsa);
3737 }
3738 route_unlock_node (start);
3739 }
3740}
3741
3742/* Show detail LSA information
3743 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003744static void
paul020709f2003-04-04 02:44:16 +00003745show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003746 struct in_addr *id, struct in_addr *adv_router)
3747{
hasso52dc7ee2004-09-23 19:18:23 +00003748 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003749 struct ospf_area *area;
3750
paul718e3742002-12-13 20:15:29 +00003751 switch (type)
3752 {
3753 case OSPF_AS_EXTERNAL_LSA:
3754#ifdef HAVE_OPAQUE_LSA
3755 case OSPF_OPAQUE_AS_LSA:
3756#endif /* HAVE_OPAQUE_LSA */
3757 vty_out (vty, " %s %s%s",
3758 show_database_desc[type],
3759 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003760 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003761 break;
3762 default:
paul1eb8ef22005-04-07 07:30:20 +00003763 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003764 {
paul718e3742002-12-13 20:15:29 +00003765 vty_out (vty, "%s %s (Area %s)%s%s",
3766 VTY_NEWLINE, show_database_desc[type],
3767 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3768 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3769 }
3770 break;
3771 }
3772}
3773
paul4dadc292005-05-06 21:37:42 +00003774static void
paul718e3742002-12-13 20:15:29 +00003775show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3776 struct in_addr *adv_router)
3777{
3778 struct route_node *rn;
3779 struct ospf_lsa *lsa;
3780
3781 for (rn = route_top (rt); rn; rn = route_next (rn))
3782 if ((lsa = rn->info))
3783 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3784 {
paul718e3742002-12-13 20:15:29 +00003785 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3786 continue;
paul718e3742002-12-13 20:15:29 +00003787 if (show_function[lsa->data->type] != NULL)
3788 show_function[lsa->data->type] (vty, lsa);
3789 }
3790}
3791
3792/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003793static void
paul020709f2003-04-04 02:44:16 +00003794show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003795 struct in_addr *adv_router)
3796{
hasso52dc7ee2004-09-23 19:18:23 +00003797 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003798 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003799
3800 switch (type)
3801 {
3802 case OSPF_AS_EXTERNAL_LSA:
3803#ifdef HAVE_OPAQUE_LSA
3804 case OSPF_OPAQUE_AS_LSA:
3805#endif /* HAVE_OPAQUE_LSA */
3806 vty_out (vty, " %s %s%s",
3807 show_database_desc[type],
3808 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003809 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003810 adv_router);
3811 break;
3812 default:
paul1eb8ef22005-04-07 07:30:20 +00003813 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003814 {
paul718e3742002-12-13 20:15:29 +00003815 vty_out (vty, "%s %s (Area %s)%s%s",
3816 VTY_NEWLINE, show_database_desc[type],
3817 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3818 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3819 adv_router);
3820 }
3821 break;
3822 }
3823}
3824
paul4dadc292005-05-06 21:37:42 +00003825static void
paul020709f2003-04-04 02:44:16 +00003826show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003827{
paul020709f2003-04-04 02:44:16 +00003828 struct ospf_lsa *lsa;
3829 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003830 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003831 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003832 int type;
3833
paul1eb8ef22005-04-07 07:30:20 +00003834 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003835 {
paul718e3742002-12-13 20:15:29 +00003836 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3837 {
3838 switch (type)
3839 {
3840 case OSPF_AS_EXTERNAL_LSA:
3841#ifdef HAVE_OPAQUE_LSA
3842 case OSPF_OPAQUE_AS_LSA:
3843#endif /* HAVE_OPAQUE_LSA */
3844 continue;
3845 default:
3846 break;
3847 }
3848 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3849 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3850 {
3851 vty_out (vty, " %s (Area %s)%s%s",
3852 show_database_desc[type],
3853 ospf_area_desc_string (area),
3854 VTY_NEWLINE, VTY_NEWLINE);
3855 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3856
paul020709f2003-04-04 02:44:16 +00003857 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3858 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003859
3860 vty_out (vty, "%s", VTY_NEWLINE);
3861 }
3862 }
3863 }
3864
3865 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3866 {
3867 switch (type)
3868 {
3869 case OSPF_AS_EXTERNAL_LSA:
3870#ifdef HAVE_OPAQUE_LSA
3871 case OSPF_OPAQUE_AS_LSA:
3872#endif /* HAVE_OPAQUE_LSA */
3873 break;;
3874 default:
3875 continue;
3876 }
paul68980082003-03-25 05:07:42 +00003877 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3878 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003879 {
3880 vty_out (vty, " %s%s%s",
3881 show_database_desc[type],
3882 VTY_NEWLINE, VTY_NEWLINE);
3883 vty_out (vty, "%s%s", show_database_header[type],
3884 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003885
3886 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3887 show_lsa_summary (vty, lsa, self);
3888
paul718e3742002-12-13 20:15:29 +00003889 vty_out (vty, "%s", VTY_NEWLINE);
3890 }
3891 }
3892
3893 vty_out (vty, "%s", VTY_NEWLINE);
3894}
3895
paul4dadc292005-05-06 21:37:42 +00003896static void
paul020709f2003-04-04 02:44:16 +00003897show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003898{
hasso52dc7ee2004-09-23 19:18:23 +00003899 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003900 struct ospf_lsa *lsa;
3901
3902 vty_out (vty, "%s MaxAge Link States:%s%s",
3903 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3904
paul1eb8ef22005-04-07 07:30:20 +00003905 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3906 {
3907 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3908 vty_out (vty, "Link State ID: %s%s",
3909 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3910 vty_out (vty, "Advertising Router: %s%s",
3911 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3912 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3913 vty_out (vty, "%s", VTY_NEWLINE);
3914 }
paul718e3742002-12-13 20:15:29 +00003915}
3916
paul718e3742002-12-13 20:15:29 +00003917#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3918#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003919
3920#ifdef HAVE_OPAQUE_LSA
3921#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3922#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3923#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3924#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3925#else /* HAVE_OPAQUE_LSA */
3926#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3927#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3928#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3929#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3930#endif /* HAVE_OPAQUE_LSA */
3931
3932#define OSPF_LSA_TYPES_CMD_STR \
3933 "asbr-summary|external|network|router|summary" \
3934 OSPF_LSA_TYPE_NSSA_CMD_STR \
3935 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3936
3937#define OSPF_LSA_TYPES_DESC \
3938 "ASBR summary link states\n" \
3939 "External link states\n" \
3940 "Network link states\n" \
3941 "Router link states\n" \
3942 "Network summary link states\n" \
3943 OSPF_LSA_TYPE_NSSA_DESC \
3944 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3945 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3946 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3947
3948DEFUN (show_ip_ospf_database,
3949 show_ip_ospf_database_cmd,
3950 "show ip ospf database",
3951 SHOW_STR
3952 IP_STR
3953 "OSPF information\n"
3954 "Database summary\n")
3955{
paul020709f2003-04-04 02:44:16 +00003956 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003957 int type, ret;
3958 struct in_addr id, adv_router;
3959
paul020709f2003-04-04 02:44:16 +00003960 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003961 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003962 return CMD_SUCCESS;
3963
3964 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003965 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003966
3967 /* Show all LSA. */
3968 if (argc == 0)
3969 {
paul020709f2003-04-04 02:44:16 +00003970 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003971 return CMD_SUCCESS;
3972 }
3973
3974 /* Set database type to show. */
3975 if (strncmp (argv[0], "r", 1) == 0)
3976 type = OSPF_ROUTER_LSA;
3977 else if (strncmp (argv[0], "ne", 2) == 0)
3978 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003979 else if (strncmp (argv[0], "ns", 2) == 0)
3980 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003981 else if (strncmp (argv[0], "su", 2) == 0)
3982 type = OSPF_SUMMARY_LSA;
3983 else if (strncmp (argv[0], "a", 1) == 0)
3984 type = OSPF_ASBR_SUMMARY_LSA;
3985 else if (strncmp (argv[0], "e", 1) == 0)
3986 type = OSPF_AS_EXTERNAL_LSA;
3987 else if (strncmp (argv[0], "se", 2) == 0)
3988 {
paul020709f2003-04-04 02:44:16 +00003989 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003990 return CMD_SUCCESS;
3991 }
3992 else if (strncmp (argv[0], "m", 1) == 0)
3993 {
paul020709f2003-04-04 02:44:16 +00003994 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003995 return CMD_SUCCESS;
3996 }
3997#ifdef HAVE_OPAQUE_LSA
3998 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3999 type = OSPF_OPAQUE_LINK_LSA;
4000 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4001 type = OSPF_OPAQUE_AREA_LSA;
4002 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4003 type = OSPF_OPAQUE_AS_LSA;
4004#endif /* HAVE_OPAQUE_LSA */
4005 else
4006 return CMD_WARNING;
4007
4008 /* `show ip ospf database LSA'. */
4009 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004010 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004011 else if (argc >= 2)
4012 {
4013 ret = inet_aton (argv[1], &id);
4014 if (!ret)
4015 return CMD_WARNING;
4016
4017 /* `show ip ospf database LSA ID'. */
4018 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004019 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004020 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4021 else if (argc == 3)
4022 {
4023 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004024 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004025 else
4026 {
4027 ret = inet_aton (argv[2], &adv_router);
4028 if (!ret)
4029 return CMD_WARNING;
4030 }
paul020709f2003-04-04 02:44:16 +00004031 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004032 }
4033 }
4034
4035 return CMD_SUCCESS;
4036}
4037
4038ALIAS (show_ip_ospf_database,
4039 show_ip_ospf_database_type_cmd,
4040 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4041 SHOW_STR
4042 IP_STR
4043 "OSPF information\n"
4044 "Database summary\n"
4045 OSPF_LSA_TYPES_DESC
4046 "LSAs in MaxAge list\n"
4047 "Self-originated link states\n")
4048
4049ALIAS (show_ip_ospf_database,
4050 show_ip_ospf_database_type_id_cmd,
4051 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4052 SHOW_STR
4053 IP_STR
4054 "OSPF information\n"
4055 "Database summary\n"
4056 OSPF_LSA_TYPES_DESC
4057 "Link State ID (as an IP address)\n")
4058
4059ALIAS (show_ip_ospf_database,
4060 show_ip_ospf_database_type_id_adv_router_cmd,
4061 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4062 SHOW_STR
4063 IP_STR
4064 "OSPF information\n"
4065 "Database summary\n"
4066 OSPF_LSA_TYPES_DESC
4067 "Link State ID (as an IP address)\n"
4068 "Advertising Router link states\n"
4069 "Advertising Router (as an IP address)\n")
4070
4071ALIAS (show_ip_ospf_database,
4072 show_ip_ospf_database_type_id_self_cmd,
4073 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4074 SHOW_STR
4075 IP_STR
4076 "OSPF information\n"
4077 "Database summary\n"
4078 OSPF_LSA_TYPES_DESC
4079 "Link State ID (as an IP address)\n"
4080 "Self-originated link states\n"
4081 "\n")
4082
4083DEFUN (show_ip_ospf_database_type_adv_router,
4084 show_ip_ospf_database_type_adv_router_cmd,
4085 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4086 SHOW_STR
4087 IP_STR
4088 "OSPF information\n"
4089 "Database summary\n"
4090 OSPF_LSA_TYPES_DESC
4091 "Advertising Router link states\n"
4092 "Advertising Router (as an IP address)\n")
4093{
paul020709f2003-04-04 02:44:16 +00004094 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004095 int type, ret;
4096 struct in_addr adv_router;
4097
paul020709f2003-04-04 02:44:16 +00004098 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004099 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00004100 return CMD_SUCCESS;
4101
4102 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004103 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004104
4105 if (argc != 2)
4106 return CMD_WARNING;
4107
4108 /* Set database type to show. */
4109 if (strncmp (argv[0], "r", 1) == 0)
4110 type = OSPF_ROUTER_LSA;
4111 else if (strncmp (argv[0], "ne", 2) == 0)
4112 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004113 else if (strncmp (argv[0], "ns", 2) == 0)
4114 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004115 else if (strncmp (argv[0], "s", 1) == 0)
4116 type = OSPF_SUMMARY_LSA;
4117 else if (strncmp (argv[0], "a", 1) == 0)
4118 type = OSPF_ASBR_SUMMARY_LSA;
4119 else if (strncmp (argv[0], "e", 1) == 0)
4120 type = OSPF_AS_EXTERNAL_LSA;
4121#ifdef HAVE_OPAQUE_LSA
4122 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4123 type = OSPF_OPAQUE_LINK_LSA;
4124 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4125 type = OSPF_OPAQUE_AREA_LSA;
4126 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4127 type = OSPF_OPAQUE_AS_LSA;
4128#endif /* HAVE_OPAQUE_LSA */
4129 else
4130 return CMD_WARNING;
4131
4132 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4133 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004134 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004135 else
4136 {
4137 ret = inet_aton (argv[1], &adv_router);
4138 if (!ret)
4139 return CMD_WARNING;
4140 }
4141
paul020709f2003-04-04 02:44:16 +00004142 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004143
4144 return CMD_SUCCESS;
4145}
4146
4147ALIAS (show_ip_ospf_database_type_adv_router,
4148 show_ip_ospf_database_type_self_cmd,
4149 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4150 SHOW_STR
4151 IP_STR
4152 "OSPF information\n"
4153 "Database summary\n"
4154 OSPF_LSA_TYPES_DESC
4155 "Self-originated link states\n")
4156
4157
4158DEFUN (ip_ospf_authentication_args,
4159 ip_ospf_authentication_args_addr_cmd,
4160 "ip ospf authentication (null|message-digest) A.B.C.D",
4161 "IP Information\n"
4162 "OSPF interface commands\n"
4163 "Enable authentication on this interface\n"
4164 "Use null authentication\n"
4165 "Use message-digest authentication\n"
4166 "Address of interface")
4167{
4168 struct interface *ifp;
4169 struct in_addr addr;
4170 int ret;
4171 struct ospf_if_params *params;
4172
4173 ifp = vty->index;
4174 params = IF_DEF_PARAMS (ifp);
4175
4176 if (argc == 2)
4177 {
4178 ret = inet_aton(argv[1], &addr);
4179 if (!ret)
4180 {
4181 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4182 VTY_NEWLINE);
4183 return CMD_WARNING;
4184 }
4185
4186 params = ospf_get_if_params (ifp, addr);
4187 ospf_if_update_params (ifp, addr);
4188 }
4189
4190 /* Handle null authentication */
4191 if ( argv[0][0] == 'n' )
4192 {
4193 SET_IF_PARAM (params, auth_type);
4194 params->auth_type = OSPF_AUTH_NULL;
4195 return CMD_SUCCESS;
4196 }
4197
4198 /* Handle message-digest authentication */
4199 if ( argv[0][0] == 'm' )
4200 {
4201 SET_IF_PARAM (params, auth_type);
4202 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4203 return CMD_SUCCESS;
4204 }
4205
4206 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4207 return CMD_WARNING;
4208}
4209
4210ALIAS (ip_ospf_authentication_args,
4211 ip_ospf_authentication_args_cmd,
4212 "ip ospf authentication (null|message-digest)",
4213 "IP Information\n"
4214 "OSPF interface commands\n"
4215 "Enable authentication on this interface\n"
4216 "Use null authentication\n"
4217 "Use message-digest authentication\n")
4218
4219DEFUN (ip_ospf_authentication,
4220 ip_ospf_authentication_addr_cmd,
4221 "ip ospf authentication A.B.C.D",
4222 "IP Information\n"
4223 "OSPF interface commands\n"
4224 "Enable authentication on this interface\n"
4225 "Address of interface")
4226{
4227 struct interface *ifp;
4228 struct in_addr addr;
4229 int ret;
4230 struct ospf_if_params *params;
4231
4232 ifp = vty->index;
4233 params = IF_DEF_PARAMS (ifp);
4234
4235 if (argc == 1)
4236 {
4237 ret = inet_aton(argv[1], &addr);
4238 if (!ret)
4239 {
4240 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4241 VTY_NEWLINE);
4242 return CMD_WARNING;
4243 }
4244
4245 params = ospf_get_if_params (ifp, addr);
4246 ospf_if_update_params (ifp, addr);
4247 }
4248
4249 SET_IF_PARAM (params, auth_type);
4250 params->auth_type = OSPF_AUTH_SIMPLE;
4251
4252 return CMD_SUCCESS;
4253}
4254
4255ALIAS (ip_ospf_authentication,
4256 ip_ospf_authentication_cmd,
4257 "ip ospf authentication",
4258 "IP Information\n"
4259 "OSPF interface commands\n"
4260 "Enable authentication on this interface\n")
4261
4262DEFUN (no_ip_ospf_authentication,
4263 no_ip_ospf_authentication_addr_cmd,
4264 "no ip ospf authentication A.B.C.D",
4265 NO_STR
4266 "IP Information\n"
4267 "OSPF interface commands\n"
4268 "Enable authentication on this interface\n"
4269 "Address of interface")
4270{
4271 struct interface *ifp;
4272 struct in_addr addr;
4273 int ret;
4274 struct ospf_if_params *params;
4275
4276 ifp = vty->index;
4277 params = IF_DEF_PARAMS (ifp);
4278
4279 if (argc == 1)
4280 {
4281 ret = inet_aton(argv[1], &addr);
4282 if (!ret)
4283 {
4284 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4285 VTY_NEWLINE);
4286 return CMD_WARNING;
4287 }
4288
4289 params = ospf_lookup_if_params (ifp, addr);
4290 if (params == NULL)
4291 return CMD_SUCCESS;
4292 }
4293
4294 params->auth_type = OSPF_AUTH_NOTSET;
4295 UNSET_IF_PARAM (params, auth_type);
4296
4297 if (params != IF_DEF_PARAMS (ifp))
4298 {
4299 ospf_free_if_params (ifp, addr);
4300 ospf_if_update_params (ifp, addr);
4301 }
4302
4303 return CMD_SUCCESS;
4304}
4305
4306ALIAS (no_ip_ospf_authentication,
4307 no_ip_ospf_authentication_cmd,
4308 "no ip ospf authentication",
4309 NO_STR
4310 "IP Information\n"
4311 "OSPF interface commands\n"
4312 "Enable authentication on this interface\n")
4313
4314DEFUN (ip_ospf_authentication_key,
4315 ip_ospf_authentication_key_addr_cmd,
4316 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4317 "IP Information\n"
4318 "OSPF interface commands\n"
4319 "Authentication password (key)\n"
4320 "The OSPF password (key)\n"
4321 "Address of interface")
4322{
4323 struct interface *ifp;
4324 struct in_addr addr;
4325 int ret;
4326 struct ospf_if_params *params;
4327
4328 ifp = vty->index;
4329 params = IF_DEF_PARAMS (ifp);
4330
4331 if (argc == 2)
4332 {
4333 ret = inet_aton(argv[1], &addr);
4334 if (!ret)
4335 {
4336 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4337 VTY_NEWLINE);
4338 return CMD_WARNING;
4339 }
4340
4341 params = ospf_get_if_params (ifp, addr);
4342 ospf_if_update_params (ifp, addr);
4343 }
4344
4345
4346 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004347 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004348 SET_IF_PARAM (params, auth_simple);
4349
4350 return CMD_SUCCESS;
4351}
4352
4353ALIAS (ip_ospf_authentication_key,
4354 ip_ospf_authentication_key_cmd,
4355 "ip ospf authentication-key AUTH_KEY",
4356 "IP Information\n"
4357 "OSPF interface commands\n"
4358 "Authentication password (key)\n"
4359 "The OSPF password (key)")
4360
4361ALIAS (ip_ospf_authentication_key,
4362 ospf_authentication_key_cmd,
4363 "ospf authentication-key AUTH_KEY",
4364 "OSPF interface commands\n"
4365 "Authentication password (key)\n"
4366 "The OSPF password (key)")
4367
4368DEFUN (no_ip_ospf_authentication_key,
4369 no_ip_ospf_authentication_key_addr_cmd,
4370 "no ip ospf authentication-key A.B.C.D",
4371 NO_STR
4372 "IP Information\n"
4373 "OSPF interface commands\n"
4374 "Authentication password (key)\n"
4375 "Address of interface")
4376{
4377 struct interface *ifp;
4378 struct in_addr addr;
4379 int ret;
4380 struct ospf_if_params *params;
4381
4382 ifp = vty->index;
4383 params = IF_DEF_PARAMS (ifp);
4384
4385 if (argc == 2)
4386 {
4387 ret = inet_aton(argv[1], &addr);
4388 if (!ret)
4389 {
4390 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4391 VTY_NEWLINE);
4392 return CMD_WARNING;
4393 }
4394
4395 params = ospf_lookup_if_params (ifp, addr);
4396 if (params == NULL)
4397 return CMD_SUCCESS;
4398 }
4399
4400 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4401 UNSET_IF_PARAM (params, auth_simple);
4402
4403 if (params != IF_DEF_PARAMS (ifp))
4404 {
4405 ospf_free_if_params (ifp, addr);
4406 ospf_if_update_params (ifp, addr);
4407 }
4408
4409 return CMD_SUCCESS;
4410}
4411
4412ALIAS (no_ip_ospf_authentication_key,
4413 no_ip_ospf_authentication_key_cmd,
4414 "no ip ospf authentication-key",
4415 NO_STR
4416 "IP Information\n"
4417 "OSPF interface commands\n"
4418 "Authentication password (key)\n")
4419
4420ALIAS (no_ip_ospf_authentication_key,
4421 no_ospf_authentication_key_cmd,
4422 "no ospf authentication-key",
4423 NO_STR
4424 "OSPF interface commands\n"
4425 "Authentication password (key)\n")
4426
4427DEFUN (ip_ospf_message_digest_key,
4428 ip_ospf_message_digest_key_addr_cmd,
4429 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4430 "IP Information\n"
4431 "OSPF interface commands\n"
4432 "Message digest authentication password (key)\n"
4433 "Key ID\n"
4434 "Use MD5 algorithm\n"
4435 "The OSPF password (key)"
4436 "Address of interface")
4437{
4438 struct interface *ifp;
4439 struct crypt_key *ck;
4440 u_char key_id;
4441 struct in_addr addr;
4442 int ret;
4443 struct ospf_if_params *params;
4444
4445 ifp = vty->index;
4446 params = IF_DEF_PARAMS (ifp);
4447
4448 if (argc == 3)
4449 {
4450 ret = inet_aton(argv[2], &addr);
4451 if (!ret)
4452 {
4453 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4454 VTY_NEWLINE);
4455 return CMD_WARNING;
4456 }
4457
4458 params = ospf_get_if_params (ifp, addr);
4459 ospf_if_update_params (ifp, addr);
4460 }
4461
4462 key_id = strtol (argv[0], NULL, 10);
4463 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4464 {
4465 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4466 return CMD_WARNING;
4467 }
4468
4469 ck = ospf_crypt_key_new ();
4470 ck->key_id = (u_char) key_id;
4471 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004472 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004473
4474 ospf_crypt_key_add (params->auth_crypt, ck);
4475 SET_IF_PARAM (params, auth_crypt);
4476
4477 return CMD_SUCCESS;
4478}
4479
4480ALIAS (ip_ospf_message_digest_key,
4481 ip_ospf_message_digest_key_cmd,
4482 "ip ospf message-digest-key <1-255> md5 KEY",
4483 "IP Information\n"
4484 "OSPF interface commands\n"
4485 "Message digest authentication password (key)\n"
4486 "Key ID\n"
4487 "Use MD5 algorithm\n"
4488 "The OSPF password (key)")
4489
4490ALIAS (ip_ospf_message_digest_key,
4491 ospf_message_digest_key_cmd,
4492 "ospf message-digest-key <1-255> md5 KEY",
4493 "OSPF interface commands\n"
4494 "Message digest authentication password (key)\n"
4495 "Key ID\n"
4496 "Use MD5 algorithm\n"
4497 "The OSPF password (key)")
4498
4499DEFUN (no_ip_ospf_message_digest_key,
4500 no_ip_ospf_message_digest_key_addr_cmd,
4501 "no ip ospf message-digest-key <1-255> A.B.C.D",
4502 NO_STR
4503 "IP Information\n"
4504 "OSPF interface commands\n"
4505 "Message digest authentication password (key)\n"
4506 "Key ID\n"
4507 "Address of interface")
4508{
4509 struct interface *ifp;
4510 struct crypt_key *ck;
4511 int key_id;
4512 struct in_addr addr;
4513 int ret;
4514 struct ospf_if_params *params;
4515
4516 ifp = vty->index;
4517 params = IF_DEF_PARAMS (ifp);
4518
4519 if (argc == 2)
4520 {
4521 ret = inet_aton(argv[1], &addr);
4522 if (!ret)
4523 {
4524 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4525 VTY_NEWLINE);
4526 return CMD_WARNING;
4527 }
4528
4529 params = ospf_lookup_if_params (ifp, addr);
4530 if (params == NULL)
4531 return CMD_SUCCESS;
4532 }
4533
4534 key_id = strtol (argv[0], NULL, 10);
4535 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4536 if (ck == NULL)
4537 {
4538 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4539 return CMD_WARNING;
4540 }
4541
4542 ospf_crypt_key_delete (params->auth_crypt, key_id);
4543
4544 if (params != IF_DEF_PARAMS (ifp))
4545 {
4546 ospf_free_if_params (ifp, addr);
4547 ospf_if_update_params (ifp, addr);
4548 }
4549
4550 return CMD_SUCCESS;
4551}
4552
4553ALIAS (no_ip_ospf_message_digest_key,
4554 no_ip_ospf_message_digest_key_cmd,
4555 "no ip ospf message-digest-key <1-255>",
4556 NO_STR
4557 "IP Information\n"
4558 "OSPF interface commands\n"
4559 "Message digest authentication password (key)\n"
4560 "Key ID\n")
4561
4562ALIAS (no_ip_ospf_message_digest_key,
4563 no_ospf_message_digest_key_cmd,
4564 "no ospf message-digest-key <1-255>",
4565 NO_STR
4566 "OSPF interface commands\n"
4567 "Message digest authentication password (key)\n"
4568 "Key ID\n")
4569
4570DEFUN (ip_ospf_cost,
4571 ip_ospf_cost_addr_cmd,
4572 "ip ospf cost <1-65535> A.B.C.D",
4573 "IP Information\n"
4574 "OSPF interface commands\n"
4575 "Interface cost\n"
4576 "Cost\n"
4577 "Address of interface")
4578{
4579 struct interface *ifp = vty->index;
4580 u_int32_t cost;
4581 struct in_addr addr;
4582 int ret;
4583 struct ospf_if_params *params;
4584
4585 params = IF_DEF_PARAMS (ifp);
4586
4587 cost = strtol (argv[0], NULL, 10);
4588
4589 /* cost range is <1-65535>. */
4590 if (cost < 1 || cost > 65535)
4591 {
4592 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4593 return CMD_WARNING;
4594 }
4595
4596 if (argc == 2)
4597 {
4598 ret = inet_aton(argv[1], &addr);
4599 if (!ret)
4600 {
4601 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4602 VTY_NEWLINE);
4603 return CMD_WARNING;
4604 }
4605
4606 params = ospf_get_if_params (ifp, addr);
4607 ospf_if_update_params (ifp, addr);
4608 }
4609
4610 SET_IF_PARAM (params, output_cost_cmd);
4611 params->output_cost_cmd = cost;
4612
4613 ospf_if_recalculate_output_cost (ifp);
4614
4615 return CMD_SUCCESS;
4616}
4617
4618ALIAS (ip_ospf_cost,
4619 ip_ospf_cost_cmd,
4620 "ip ospf cost <1-65535>",
4621 "IP Information\n"
4622 "OSPF interface commands\n"
4623 "Interface cost\n"
4624 "Cost")
4625
4626ALIAS (ip_ospf_cost,
4627 ospf_cost_cmd,
4628 "ospf cost <1-65535>",
4629 "OSPF interface commands\n"
4630 "Interface cost\n"
4631 "Cost")
4632
4633DEFUN (no_ip_ospf_cost,
4634 no_ip_ospf_cost_addr_cmd,
4635 "no ip ospf cost A.B.C.D",
4636 NO_STR
4637 "IP Information\n"
4638 "OSPF interface commands\n"
4639 "Interface cost\n"
4640 "Address of interface")
4641{
4642 struct interface *ifp = vty->index;
4643 struct in_addr addr;
4644 int ret;
4645 struct ospf_if_params *params;
4646
4647 ifp = vty->index;
4648 params = IF_DEF_PARAMS (ifp);
4649
4650 if (argc == 1)
4651 {
4652 ret = inet_aton(argv[0], &addr);
4653 if (!ret)
4654 {
4655 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4656 VTY_NEWLINE);
4657 return CMD_WARNING;
4658 }
4659
4660 params = ospf_lookup_if_params (ifp, addr);
4661 if (params == NULL)
4662 return CMD_SUCCESS;
4663 }
4664
4665 UNSET_IF_PARAM (params, output_cost_cmd);
4666
4667 if (params != IF_DEF_PARAMS (ifp))
4668 {
4669 ospf_free_if_params (ifp, addr);
4670 ospf_if_update_params (ifp, addr);
4671 }
4672
4673 ospf_if_recalculate_output_cost (ifp);
4674
4675 return CMD_SUCCESS;
4676}
4677
4678ALIAS (no_ip_ospf_cost,
4679 no_ip_ospf_cost_cmd,
4680 "no ip ospf cost",
4681 NO_STR
4682 "IP Information\n"
4683 "OSPF interface commands\n"
4684 "Interface cost\n")
4685
4686ALIAS (no_ip_ospf_cost,
4687 no_ospf_cost_cmd,
4688 "no ospf cost",
4689 NO_STR
4690 "OSPF interface commands\n"
4691 "Interface cost\n")
4692
paul4dadc292005-05-06 21:37:42 +00004693static void
paul718e3742002-12-13 20:15:29 +00004694ospf_nbr_timer_update (struct ospf_interface *oi)
4695{
4696 struct route_node *rn;
4697 struct ospf_neighbor *nbr;
4698
4699 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4700 if ((nbr = rn->info))
4701 {
4702 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4703 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4704 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4705 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4706 }
4707}
4708
paulf9ad9372005-10-21 00:45:17 +00004709static int
4710ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4711 const char *nbr_str,
4712 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004713{
4714 struct interface *ifp = vty->index;
4715 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004716 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004717 struct in_addr addr;
4718 int ret;
4719 struct ospf_if_params *params;
4720 struct ospf_interface *oi;
4721 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004722 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004723
paul020709f2003-04-04 02:44:16 +00004724 ospf = ospf_lookup ();
4725
paul718e3742002-12-13 20:15:29 +00004726 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004727
4728 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004729 {
paulf9ad9372005-10-21 00:45:17 +00004730 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004731 if (!ret)
4732 {
4733 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4734 VTY_NEWLINE);
4735 return CMD_WARNING;
4736 }
4737
4738 params = ospf_get_if_params (ifp, addr);
4739 ospf_if_update_params (ifp, addr);
4740 }
4741
paulf9ad9372005-10-21 00:45:17 +00004742 if (interval_str)
4743 {
4744 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4745 1, 65535);
4746
4747 /* reset fast_hello too, just to be sure */
4748 UNSET_IF_PARAM (params, fast_hello);
4749 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4750 }
4751 else if (fast_hello_str)
4752 {
4753 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4754 1, 10);
4755 /* 1s dead-interval with sub-second hellos desired */
4756 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4757 SET_IF_PARAM (params, fast_hello);
4758 params->fast_hello = hellomult;
4759 }
4760 else
4761 {
4762 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4763 VTY_NEWLINE);
4764 return CMD_WARNING;
4765 }
4766
paul718e3742002-12-13 20:15:29 +00004767 SET_IF_PARAM (params, v_wait);
4768 params->v_wait = seconds;
4769
4770 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00004771 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004772 {
paul68980082003-03-25 05:07:42 +00004773 if (ospf)
4774 {
4775 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4776 if (oi)
4777 ospf_nbr_timer_update (oi);
4778 }
paul718e3742002-12-13 20:15:29 +00004779 }
4780 else
4781 {
4782 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4783 if ((oi = rn->info))
4784 ospf_nbr_timer_update (oi);
4785 }
4786
4787 return CMD_SUCCESS;
4788}
4789
paulf9ad9372005-10-21 00:45:17 +00004790
4791DEFUN (ip_ospf_dead_interval,
4792 ip_ospf_dead_interval_addr_cmd,
4793 "ip ospf dead-interval <1-65535> A.B.C.D",
4794 "IP Information\n"
4795 "OSPF interface commands\n"
4796 "Interval after which a neighbor is declared dead\n"
4797 "Seconds\n"
4798 "Address of interface\n")
4799{
4800 if (argc == 2)
4801 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4802 else
4803 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4804}
4805
paul718e3742002-12-13 20:15:29 +00004806ALIAS (ip_ospf_dead_interval,
4807 ip_ospf_dead_interval_cmd,
4808 "ip ospf dead-interval <1-65535>",
4809 "IP Information\n"
4810 "OSPF interface commands\n"
4811 "Interval after which a neighbor is declared dead\n"
4812 "Seconds\n")
4813
4814ALIAS (ip_ospf_dead_interval,
4815 ospf_dead_interval_cmd,
4816 "ospf dead-interval <1-65535>",
4817 "OSPF interface commands\n"
4818 "Interval after which a neighbor is declared dead\n"
4819 "Seconds\n")
4820
paulf9ad9372005-10-21 00:45:17 +00004821DEFUN (ip_ospf_dead_interval_minimal,
4822 ip_ospf_dead_interval_minimal_addr_cmd,
4823 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4824 "IP Information\n"
4825 "OSPF interface commands\n"
4826 "Interval after which a neighbor is declared dead\n"
4827 "Minimal 1s dead-interval with fast sub-second hellos\n"
4828 "Hello multiplier factor\n"
4829 "Number of Hellos to send each second\n"
4830 "Address of interface\n")
4831{
4832 if (argc == 2)
4833 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4834 else
4835 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4836}
4837
4838ALIAS (ip_ospf_dead_interval_minimal,
4839 ip_ospf_dead_interval_minimal_cmd,
4840 "ip ospf dead-interval minimal hello-multiplier <1-10>",
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
paul718e3742002-12-13 20:15:29 +00004848DEFUN (no_ip_ospf_dead_interval,
4849 no_ip_ospf_dead_interval_addr_cmd,
4850 "no ip ospf dead-interval A.B.C.D",
4851 NO_STR
4852 "IP Information\n"
4853 "OSPF interface commands\n"
4854 "Interval after which a neighbor is declared dead\n"
4855 "Address of interface")
4856{
4857 struct interface *ifp = vty->index;
4858 struct in_addr addr;
4859 int ret;
4860 struct ospf_if_params *params;
4861 struct ospf_interface *oi;
4862 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004863 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004864
paul020709f2003-04-04 02:44:16 +00004865 ospf = ospf_lookup ();
4866
paul718e3742002-12-13 20:15:29 +00004867 ifp = vty->index;
4868 params = IF_DEF_PARAMS (ifp);
4869
4870 if (argc == 1)
4871 {
4872 ret = inet_aton(argv[0], &addr);
4873 if (!ret)
4874 {
4875 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4876 VTY_NEWLINE);
4877 return CMD_WARNING;
4878 }
4879
4880 params = ospf_lookup_if_params (ifp, addr);
4881 if (params == NULL)
4882 return CMD_SUCCESS;
4883 }
4884
4885 UNSET_IF_PARAM (params, v_wait);
4886 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00004887
4888 UNSET_IF_PARAM (params, fast_hello);
4889 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4890
paul718e3742002-12-13 20:15:29 +00004891 if (params != IF_DEF_PARAMS (ifp))
4892 {
4893 ospf_free_if_params (ifp, addr);
4894 ospf_if_update_params (ifp, addr);
4895 }
4896
4897 /* Update timer values in neighbor structure. */
4898 if (argc == 1)
4899 {
paul68980082003-03-25 05:07:42 +00004900 if (ospf)
4901 {
4902 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4903 if (oi)
4904 ospf_nbr_timer_update (oi);
4905 }
paul718e3742002-12-13 20:15:29 +00004906 }
4907 else
4908 {
4909 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4910 if ((oi = rn->info))
4911 ospf_nbr_timer_update (oi);
4912 }
4913
4914 return CMD_SUCCESS;
4915}
4916
4917ALIAS (no_ip_ospf_dead_interval,
4918 no_ip_ospf_dead_interval_cmd,
4919 "no ip ospf dead-interval",
4920 NO_STR
4921 "IP Information\n"
4922 "OSPF interface commands\n"
4923 "Interval after which a neighbor is declared dead\n")
4924
4925ALIAS (no_ip_ospf_dead_interval,
4926 no_ospf_dead_interval_cmd,
4927 "no ospf dead-interval",
4928 NO_STR
4929 "OSPF interface commands\n"
4930 "Interval after which a neighbor is declared dead\n")
4931
4932DEFUN (ip_ospf_hello_interval,
4933 ip_ospf_hello_interval_addr_cmd,
4934 "ip ospf hello-interval <1-65535> A.B.C.D",
4935 "IP Information\n"
4936 "OSPF interface commands\n"
4937 "Time between HELLO packets\n"
4938 "Seconds\n"
4939 "Address of interface")
4940{
4941 struct interface *ifp = vty->index;
4942 u_int32_t seconds;
4943 struct in_addr addr;
4944 int ret;
4945 struct ospf_if_params *params;
4946
4947 params = IF_DEF_PARAMS (ifp);
4948
4949 seconds = strtol (argv[0], NULL, 10);
4950
4951 /* HelloInterval range is <1-65535>. */
4952 if (seconds < 1 || seconds > 65535)
4953 {
4954 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4955 return CMD_WARNING;
4956 }
4957
4958 if (argc == 2)
4959 {
4960 ret = inet_aton(argv[1], &addr);
4961 if (!ret)
4962 {
4963 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4964 VTY_NEWLINE);
4965 return CMD_WARNING;
4966 }
4967
4968 params = ospf_get_if_params (ifp, addr);
4969 ospf_if_update_params (ifp, addr);
4970 }
4971
paulf9ad9372005-10-21 00:45:17 +00004972 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00004973 params->v_hello = seconds;
4974
4975 return CMD_SUCCESS;
4976}
4977
4978ALIAS (ip_ospf_hello_interval,
4979 ip_ospf_hello_interval_cmd,
4980 "ip ospf hello-interval <1-65535>",
4981 "IP Information\n"
4982 "OSPF interface commands\n"
4983 "Time between HELLO packets\n"
4984 "Seconds\n")
4985
4986ALIAS (ip_ospf_hello_interval,
4987 ospf_hello_interval_cmd,
4988 "ospf hello-interval <1-65535>",
4989 "OSPF interface commands\n"
4990 "Time between HELLO packets\n"
4991 "Seconds\n")
4992
4993DEFUN (no_ip_ospf_hello_interval,
4994 no_ip_ospf_hello_interval_addr_cmd,
4995 "no ip ospf hello-interval A.B.C.D",
4996 NO_STR
4997 "IP Information\n"
4998 "OSPF interface commands\n"
4999 "Time between HELLO packets\n"
5000 "Address of interface")
5001{
5002 struct interface *ifp = vty->index;
5003 struct in_addr addr;
5004 int ret;
5005 struct ospf_if_params *params;
5006
5007 ifp = vty->index;
5008 params = IF_DEF_PARAMS (ifp);
5009
5010 if (argc == 1)
5011 {
5012 ret = inet_aton(argv[0], &addr);
5013 if (!ret)
5014 {
5015 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5016 VTY_NEWLINE);
5017 return CMD_WARNING;
5018 }
5019
5020 params = ospf_lookup_if_params (ifp, addr);
5021 if (params == NULL)
5022 return CMD_SUCCESS;
5023 }
5024
5025 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005026 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005027
5028 if (params != IF_DEF_PARAMS (ifp))
5029 {
5030 ospf_free_if_params (ifp, addr);
5031 ospf_if_update_params (ifp, addr);
5032 }
5033
5034 return CMD_SUCCESS;
5035}
5036
5037ALIAS (no_ip_ospf_hello_interval,
5038 no_ip_ospf_hello_interval_cmd,
5039 "no ip ospf hello-interval",
5040 NO_STR
5041 "IP Information\n"
5042 "OSPF interface commands\n"
5043 "Time between HELLO packets\n")
5044
5045ALIAS (no_ip_ospf_hello_interval,
5046 no_ospf_hello_interval_cmd,
5047 "no ospf hello-interval",
5048 NO_STR
5049 "OSPF interface commands\n"
5050 "Time between HELLO packets\n")
5051
5052DEFUN (ip_ospf_network,
5053 ip_ospf_network_cmd,
5054 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5055 "IP Information\n"
5056 "OSPF interface commands\n"
5057 "Network type\n"
5058 "Specify OSPF broadcast multi-access network\n"
5059 "Specify OSPF NBMA network\n"
5060 "Specify OSPF point-to-multipoint network\n"
5061 "Specify OSPF point-to-point network\n")
5062{
5063 struct interface *ifp = vty->index;
5064 int old_type = IF_DEF_PARAMS (ifp)->type;
5065 struct route_node *rn;
5066
5067 if (strncmp (argv[0], "b", 1) == 0)
5068 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5069 else if (strncmp (argv[0], "n", 1) == 0)
5070 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5071 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5072 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5073 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5074 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5075
5076 if (IF_DEF_PARAMS (ifp)->type == old_type)
5077 return CMD_SUCCESS;
5078
5079 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5080
5081 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5082 {
5083 struct ospf_interface *oi = rn->info;
5084
5085 if (!oi)
5086 continue;
5087
5088 oi->type = IF_DEF_PARAMS (ifp)->type;
5089
5090 if (oi->state > ISM_Down)
5091 {
5092 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5093 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5094 }
5095 }
5096
5097 return CMD_SUCCESS;
5098}
5099
5100ALIAS (ip_ospf_network,
5101 ospf_network_cmd,
5102 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5103 "OSPF interface commands\n"
5104 "Network type\n"
5105 "Specify OSPF broadcast multi-access network\n"
5106 "Specify OSPF NBMA network\n"
5107 "Specify OSPF point-to-multipoint network\n"
5108 "Specify OSPF point-to-point network\n")
5109
5110DEFUN (no_ip_ospf_network,
5111 no_ip_ospf_network_cmd,
5112 "no ip ospf network",
5113 NO_STR
5114 "IP Information\n"
5115 "OSPF interface commands\n"
5116 "Network type\n")
5117{
5118 struct interface *ifp = vty->index;
5119 int old_type = IF_DEF_PARAMS (ifp)->type;
5120 struct route_node *rn;
5121
ajsbc18d612004-12-15 15:07:19 +00005122 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005123
5124 if (IF_DEF_PARAMS (ifp)->type == old_type)
5125 return CMD_SUCCESS;
5126
5127 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5128 {
5129 struct ospf_interface *oi = rn->info;
5130
5131 if (!oi)
5132 continue;
5133
5134 oi->type = IF_DEF_PARAMS (ifp)->type;
5135
5136 if (oi->state > ISM_Down)
5137 {
5138 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5139 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5140 }
5141 }
5142
5143 return CMD_SUCCESS;
5144}
5145
5146ALIAS (no_ip_ospf_network,
5147 no_ospf_network_cmd,
5148 "no ospf network",
5149 NO_STR
5150 "OSPF interface commands\n"
5151 "Network type\n")
5152
5153DEFUN (ip_ospf_priority,
5154 ip_ospf_priority_addr_cmd,
5155 "ip ospf priority <0-255> A.B.C.D",
5156 "IP Information\n"
5157 "OSPF interface commands\n"
5158 "Router priority\n"
5159 "Priority\n"
5160 "Address of interface")
5161{
5162 struct interface *ifp = vty->index;
5163 u_int32_t priority;
5164 struct route_node *rn;
5165 struct in_addr addr;
5166 int ret;
5167 struct ospf_if_params *params;
5168
5169 params = IF_DEF_PARAMS (ifp);
5170
5171 priority = strtol (argv[0], NULL, 10);
5172
5173 /* Router Priority range is <0-255>. */
5174 if (priority < 0 || priority > 255)
5175 {
5176 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5177 return CMD_WARNING;
5178 }
5179
5180 if (argc == 2)
5181 {
5182 ret = inet_aton(argv[1], &addr);
5183 if (!ret)
5184 {
5185 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5186 VTY_NEWLINE);
5187 return CMD_WARNING;
5188 }
5189
5190 params = ospf_get_if_params (ifp, addr);
5191 ospf_if_update_params (ifp, addr);
5192 }
5193
5194 SET_IF_PARAM (params, priority);
5195 params->priority = priority;
5196
5197 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5198 {
5199 struct ospf_interface *oi = rn->info;
5200
5201 if (!oi)
5202 continue;
5203
5204
5205 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5206 {
5207 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5208 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5209 }
5210 }
5211
5212 return CMD_SUCCESS;
5213}
5214
5215ALIAS (ip_ospf_priority,
5216 ip_ospf_priority_cmd,
5217 "ip ospf priority <0-255>",
5218 "IP Information\n"
5219 "OSPF interface commands\n"
5220 "Router priority\n"
5221 "Priority\n")
5222
5223ALIAS (ip_ospf_priority,
5224 ospf_priority_cmd,
5225 "ospf priority <0-255>",
5226 "OSPF interface commands\n"
5227 "Router priority\n"
5228 "Priority\n")
5229
5230DEFUN (no_ip_ospf_priority,
5231 no_ip_ospf_priority_addr_cmd,
5232 "no ip ospf priority A.B.C.D",
5233 NO_STR
5234 "IP Information\n"
5235 "OSPF interface commands\n"
5236 "Router priority\n"
5237 "Address of interface")
5238{
5239 struct interface *ifp = vty->index;
5240 struct route_node *rn;
5241 struct in_addr addr;
5242 int ret;
5243 struct ospf_if_params *params;
5244
5245 ifp = vty->index;
5246 params = IF_DEF_PARAMS (ifp);
5247
5248 if (argc == 1)
5249 {
5250 ret = inet_aton(argv[0], &addr);
5251 if (!ret)
5252 {
5253 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5254 VTY_NEWLINE);
5255 return CMD_WARNING;
5256 }
5257
5258 params = ospf_lookup_if_params (ifp, addr);
5259 if (params == NULL)
5260 return CMD_SUCCESS;
5261 }
5262
5263 UNSET_IF_PARAM (params, priority);
5264 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5265
5266 if (params != IF_DEF_PARAMS (ifp))
5267 {
5268 ospf_free_if_params (ifp, addr);
5269 ospf_if_update_params (ifp, addr);
5270 }
5271
5272 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5273 {
5274 struct ospf_interface *oi = rn->info;
5275
5276 if (!oi)
5277 continue;
5278
5279
5280 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5281 {
5282 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5283 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5284 }
5285 }
5286
5287 return CMD_SUCCESS;
5288}
5289
5290ALIAS (no_ip_ospf_priority,
5291 no_ip_ospf_priority_cmd,
5292 "no ip ospf priority",
5293 NO_STR
5294 "IP Information\n"
5295 "OSPF interface commands\n"
5296 "Router priority\n")
5297
5298ALIAS (no_ip_ospf_priority,
5299 no_ospf_priority_cmd,
5300 "no ospf priority",
5301 NO_STR
5302 "OSPF interface commands\n"
5303 "Router priority\n")
5304
5305DEFUN (ip_ospf_retransmit_interval,
5306 ip_ospf_retransmit_interval_addr_cmd,
5307 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5308 "IP Information\n"
5309 "OSPF interface commands\n"
5310 "Time between retransmitting lost link state advertisements\n"
5311 "Seconds\n"
5312 "Address of interface")
5313{
5314 struct interface *ifp = vty->index;
5315 u_int32_t seconds;
5316 struct in_addr addr;
5317 int ret;
5318 struct ospf_if_params *params;
5319
5320 params = IF_DEF_PARAMS (ifp);
5321 seconds = strtol (argv[0], NULL, 10);
5322
5323 /* Retransmit Interval range is <3-65535>. */
5324 if (seconds < 3 || seconds > 65535)
5325 {
5326 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5327 return CMD_WARNING;
5328 }
5329
5330
5331 if (argc == 2)
5332 {
5333 ret = inet_aton(argv[1], &addr);
5334 if (!ret)
5335 {
5336 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5337 VTY_NEWLINE);
5338 return CMD_WARNING;
5339 }
5340
5341 params = ospf_get_if_params (ifp, addr);
5342 ospf_if_update_params (ifp, addr);
5343 }
5344
5345 SET_IF_PARAM (params, retransmit_interval);
5346 params->retransmit_interval = seconds;
5347
5348 return CMD_SUCCESS;
5349}
5350
5351ALIAS (ip_ospf_retransmit_interval,
5352 ip_ospf_retransmit_interval_cmd,
5353 "ip ospf retransmit-interval <3-65535>",
5354 "IP Information\n"
5355 "OSPF interface commands\n"
5356 "Time between retransmitting lost link state advertisements\n"
5357 "Seconds\n")
5358
5359ALIAS (ip_ospf_retransmit_interval,
5360 ospf_retransmit_interval_cmd,
5361 "ospf retransmit-interval <3-65535>",
5362 "OSPF interface commands\n"
5363 "Time between retransmitting lost link state advertisements\n"
5364 "Seconds\n")
5365
5366DEFUN (no_ip_ospf_retransmit_interval,
5367 no_ip_ospf_retransmit_interval_addr_cmd,
5368 "no ip ospf retransmit-interval A.B.C.D",
5369 NO_STR
5370 "IP Information\n"
5371 "OSPF interface commands\n"
5372 "Time between retransmitting lost link state advertisements\n"
5373 "Address of interface")
5374{
5375 struct interface *ifp = vty->index;
5376 struct in_addr addr;
5377 int ret;
5378 struct ospf_if_params *params;
5379
5380 ifp = vty->index;
5381 params = IF_DEF_PARAMS (ifp);
5382
5383 if (argc == 1)
5384 {
5385 ret = inet_aton(argv[0], &addr);
5386 if (!ret)
5387 {
5388 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5389 VTY_NEWLINE);
5390 return CMD_WARNING;
5391 }
5392
5393 params = ospf_lookup_if_params (ifp, addr);
5394 if (params == NULL)
5395 return CMD_SUCCESS;
5396 }
5397
5398 UNSET_IF_PARAM (params, retransmit_interval);
5399 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5400
5401 if (params != IF_DEF_PARAMS (ifp))
5402 {
5403 ospf_free_if_params (ifp, addr);
5404 ospf_if_update_params (ifp, addr);
5405 }
5406
5407 return CMD_SUCCESS;
5408}
5409
5410ALIAS (no_ip_ospf_retransmit_interval,
5411 no_ip_ospf_retransmit_interval_cmd,
5412 "no ip ospf retransmit-interval",
5413 NO_STR
5414 "IP Information\n"
5415 "OSPF interface commands\n"
5416 "Time between retransmitting lost link state advertisements\n")
5417
5418ALIAS (no_ip_ospf_retransmit_interval,
5419 no_ospf_retransmit_interval_cmd,
5420 "no ospf retransmit-interval",
5421 NO_STR
5422 "OSPF interface commands\n"
5423 "Time between retransmitting lost link state advertisements\n")
5424
5425DEFUN (ip_ospf_transmit_delay,
5426 ip_ospf_transmit_delay_addr_cmd,
5427 "ip ospf transmit-delay <1-65535> A.B.C.D",
5428 "IP Information\n"
5429 "OSPF interface commands\n"
5430 "Link state transmit delay\n"
5431 "Seconds\n"
5432 "Address of interface")
5433{
5434 struct interface *ifp = vty->index;
5435 u_int32_t seconds;
5436 struct in_addr addr;
5437 int ret;
5438 struct ospf_if_params *params;
5439
5440 params = IF_DEF_PARAMS (ifp);
5441 seconds = strtol (argv[0], NULL, 10);
5442
5443 /* Transmit Delay range is <1-65535>. */
5444 if (seconds < 1 || seconds > 65535)
5445 {
5446 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5447 return CMD_WARNING;
5448 }
5449
5450 if (argc == 2)
5451 {
5452 ret = inet_aton(argv[1], &addr);
5453 if (!ret)
5454 {
5455 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5456 VTY_NEWLINE);
5457 return CMD_WARNING;
5458 }
5459
5460 params = ospf_get_if_params (ifp, addr);
5461 ospf_if_update_params (ifp, addr);
5462 }
5463
5464 SET_IF_PARAM (params, transmit_delay);
5465 params->transmit_delay = seconds;
5466
5467 return CMD_SUCCESS;
5468}
5469
5470ALIAS (ip_ospf_transmit_delay,
5471 ip_ospf_transmit_delay_cmd,
5472 "ip ospf transmit-delay <1-65535>",
5473 "IP Information\n"
5474 "OSPF interface commands\n"
5475 "Link state transmit delay\n"
5476 "Seconds\n")
5477
5478ALIAS (ip_ospf_transmit_delay,
5479 ospf_transmit_delay_cmd,
5480 "ospf transmit-delay <1-65535>",
5481 "OSPF interface commands\n"
5482 "Link state transmit delay\n"
5483 "Seconds\n")
5484
5485DEFUN (no_ip_ospf_transmit_delay,
5486 no_ip_ospf_transmit_delay_addr_cmd,
5487 "no ip ospf transmit-delay A.B.C.D",
5488 NO_STR
5489 "IP Information\n"
5490 "OSPF interface commands\n"
5491 "Link state transmit delay\n"
5492 "Address of interface")
5493{
5494 struct interface *ifp = vty->index;
5495 struct in_addr addr;
5496 int ret;
5497 struct ospf_if_params *params;
5498
5499 ifp = vty->index;
5500 params = IF_DEF_PARAMS (ifp);
5501
5502 if (argc == 1)
5503 {
5504 ret = inet_aton(argv[0], &addr);
5505 if (!ret)
5506 {
5507 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5508 VTY_NEWLINE);
5509 return CMD_WARNING;
5510 }
5511
5512 params = ospf_lookup_if_params (ifp, addr);
5513 if (params == NULL)
5514 return CMD_SUCCESS;
5515 }
5516
5517 UNSET_IF_PARAM (params, transmit_delay);
5518 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5519
5520 if (params != IF_DEF_PARAMS (ifp))
5521 {
5522 ospf_free_if_params (ifp, addr);
5523 ospf_if_update_params (ifp, addr);
5524 }
5525
5526 return CMD_SUCCESS;
5527}
5528
5529ALIAS (no_ip_ospf_transmit_delay,
5530 no_ip_ospf_transmit_delay_cmd,
5531 "no ip ospf transmit-delay",
5532 NO_STR
5533 "IP Information\n"
5534 "OSPF interface commands\n"
5535 "Link state transmit delay\n")
5536
5537ALIAS (no_ip_ospf_transmit_delay,
5538 no_ospf_transmit_delay_cmd,
5539 "no ospf transmit-delay",
5540 NO_STR
5541 "OSPF interface commands\n"
5542 "Link state transmit delay\n")
5543
5544
5545DEFUN (ospf_redistribute_source_metric_type,
5546 ospf_redistribute_source_metric_type_routemap_cmd,
5547 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5548 "Redistribute information from another routing protocol\n"
5549 "Kernel routes\n"
5550 "Connected\n"
5551 "Static routes\n"
5552 "Routing Information Protocol (RIP)\n"
5553 "Border Gateway Protocol (BGP)\n"
5554 "Metric for redistributed routes\n"
5555 "OSPF default metric\n"
5556 "OSPF exterior metric type for redistributed routes\n"
5557 "Set OSPF External Type 1 metrics\n"
5558 "Set OSPF External Type 2 metrics\n"
5559 "Route map reference\n"
5560 "Pointer to route-map entries\n")
5561{
paul020709f2003-04-04 02:44:16 +00005562 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005563 int source;
5564 int type = -1;
5565 int metric = -1;
5566
5567 /* Get distribute source. */
5568 if (!str2distribute_source (argv[0], &source))
5569 return CMD_WARNING;
5570
5571 /* Get metric value. */
5572 if (argc >= 2)
5573 if (!str2metric (argv[1], &metric))
5574 return CMD_WARNING;
5575
5576 /* Get metric type. */
5577 if (argc >= 3)
5578 if (!str2metric_type (argv[2], &type))
5579 return CMD_WARNING;
5580
5581 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005582 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005583 else
paul020709f2003-04-04 02:44:16 +00005584 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005585
paul020709f2003-04-04 02:44:16 +00005586 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005587}
5588
5589ALIAS (ospf_redistribute_source_metric_type,
5590 ospf_redistribute_source_metric_type_cmd,
5591 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5592 "Redistribute information from another routing protocol\n"
5593 "Kernel routes\n"
5594 "Connected\n"
5595 "Static routes\n"
5596 "Routing Information Protocol (RIP)\n"
5597 "Border Gateway Protocol (BGP)\n"
5598 "Metric for redistributed routes\n"
5599 "OSPF default metric\n"
5600 "OSPF exterior metric type for redistributed routes\n"
5601 "Set OSPF External Type 1 metrics\n"
5602 "Set OSPF External Type 2 metrics\n")
5603
5604ALIAS (ospf_redistribute_source_metric_type,
5605 ospf_redistribute_source_metric_cmd,
5606 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5607 "Redistribute information from another routing protocol\n"
5608 "Kernel routes\n"
5609 "Connected\n"
5610 "Static routes\n"
5611 "Routing Information Protocol (RIP)\n"
5612 "Border Gateway Protocol (BGP)\n"
5613 "Metric for redistributed routes\n"
5614 "OSPF default metric\n")
5615
5616DEFUN (ospf_redistribute_source_type_metric,
5617 ospf_redistribute_source_type_metric_routemap_cmd,
5618 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5619 "Redistribute information from another routing protocol\n"
5620 "Kernel routes\n"
5621 "Connected\n"
5622 "Static routes\n"
5623 "Routing Information Protocol (RIP)\n"
5624 "Border Gateway Protocol (BGP)\n"
5625 "OSPF exterior metric type for redistributed routes\n"
5626 "Set OSPF External Type 1 metrics\n"
5627 "Set OSPF External Type 2 metrics\n"
5628 "Metric for redistributed routes\n"
5629 "OSPF default metric\n"
5630 "Route map reference\n"
5631 "Pointer to route-map entries\n")
5632{
paul020709f2003-04-04 02:44:16 +00005633 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005634 int source;
5635 int type = -1;
5636 int metric = -1;
5637
5638 /* Get distribute source. */
5639 if (!str2distribute_source (argv[0], &source))
5640 return CMD_WARNING;
5641
5642 /* Get metric value. */
5643 if (argc >= 2)
5644 if (!str2metric_type (argv[1], &type))
5645 return CMD_WARNING;
5646
5647 /* Get metric type. */
5648 if (argc >= 3)
5649 if (!str2metric (argv[2], &metric))
5650 return CMD_WARNING;
5651
5652 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005653 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005654 else
paul020709f2003-04-04 02:44:16 +00005655 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005656
paul020709f2003-04-04 02:44:16 +00005657 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005658}
5659
5660ALIAS (ospf_redistribute_source_type_metric,
5661 ospf_redistribute_source_type_metric_cmd,
5662 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5663 "Redistribute information from another routing protocol\n"
5664 "Kernel routes\n"
5665 "Connected\n"
5666 "Static routes\n"
5667 "Routing Information Protocol (RIP)\n"
5668 "Border Gateway Protocol (BGP)\n"
5669 "OSPF exterior metric type for redistributed routes\n"
5670 "Set OSPF External Type 1 metrics\n"
5671 "Set OSPF External Type 2 metrics\n"
5672 "Metric for redistributed routes\n"
5673 "OSPF default metric\n")
5674
5675ALIAS (ospf_redistribute_source_type_metric,
5676 ospf_redistribute_source_type_cmd,
5677 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5678 "Redistribute information from another routing protocol\n"
5679 "Kernel routes\n"
5680 "Connected\n"
5681 "Static routes\n"
5682 "Routing Information Protocol (RIP)\n"
5683 "Border Gateway Protocol (BGP)\n"
5684 "OSPF exterior metric type for redistributed routes\n"
5685 "Set OSPF External Type 1 metrics\n"
5686 "Set OSPF External Type 2 metrics\n")
5687
5688ALIAS (ospf_redistribute_source_type_metric,
5689 ospf_redistribute_source_cmd,
5690 "redistribute (kernel|connected|static|rip|bgp)",
5691 "Redistribute information from another routing protocol\n"
5692 "Kernel routes\n"
5693 "Connected\n"
5694 "Static routes\n"
5695 "Routing Information Protocol (RIP)\n"
5696 "Border Gateway Protocol (BGP)\n")
5697
5698DEFUN (ospf_redistribute_source_metric_routemap,
5699 ospf_redistribute_source_metric_routemap_cmd,
5700 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5701 "Redistribute information from another routing protocol\n"
5702 "Kernel routes\n"
5703 "Connected\n"
5704 "Static routes\n"
5705 "Routing Information Protocol (RIP)\n"
5706 "Border Gateway Protocol (BGP)\n"
5707 "Metric for redistributed routes\n"
5708 "OSPF default metric\n"
5709 "Route map reference\n"
5710 "Pointer to route-map entries\n")
5711{
paul020709f2003-04-04 02:44:16 +00005712 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005713 int source;
5714 int metric = -1;
5715
5716 /* Get distribute source. */
5717 if (!str2distribute_source (argv[0], &source))
5718 return CMD_WARNING;
5719
5720 /* Get metric value. */
5721 if (argc >= 2)
5722 if (!str2metric (argv[1], &metric))
5723 return CMD_WARNING;
5724
5725 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005726 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005727 else
paul020709f2003-04-04 02:44:16 +00005728 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005729
paul020709f2003-04-04 02:44:16 +00005730 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005731}
5732
5733DEFUN (ospf_redistribute_source_type_routemap,
5734 ospf_redistribute_source_type_routemap_cmd,
5735 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5736 "Redistribute information from another routing protocol\n"
5737 "Kernel routes\n"
5738 "Connected\n"
5739 "Static routes\n"
5740 "Routing Information Protocol (RIP)\n"
5741 "Border Gateway Protocol (BGP)\n"
5742 "OSPF exterior metric type for redistributed routes\n"
5743 "Set OSPF External Type 1 metrics\n"
5744 "Set OSPF External Type 2 metrics\n"
5745 "Route map reference\n"
5746 "Pointer to route-map entries\n")
5747{
paul020709f2003-04-04 02:44:16 +00005748 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005749 int source;
5750 int type = -1;
5751
5752 /* Get distribute source. */
5753 if (!str2distribute_source (argv[0], &source))
5754 return CMD_WARNING;
5755
5756 /* Get metric value. */
5757 if (argc >= 2)
5758 if (!str2metric_type (argv[1], &type))
5759 return CMD_WARNING;
5760
5761 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005762 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005763 else
paul020709f2003-04-04 02:44:16 +00005764 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005765
paul020709f2003-04-04 02:44:16 +00005766 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005767}
5768
5769DEFUN (ospf_redistribute_source_routemap,
5770 ospf_redistribute_source_routemap_cmd,
5771 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5772 "Redistribute information from another routing protocol\n"
5773 "Kernel routes\n"
5774 "Connected\n"
5775 "Static routes\n"
5776 "Routing Information Protocol (RIP)\n"
5777 "Border Gateway Protocol (BGP)\n"
5778 "Route map reference\n"
5779 "Pointer to route-map entries\n")
5780{
paul020709f2003-04-04 02:44:16 +00005781 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005782 int source;
5783
5784 /* Get distribute source. */
5785 if (!str2distribute_source (argv[0], &source))
5786 return CMD_WARNING;
5787
5788 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005789 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005790 else
paul020709f2003-04-04 02:44:16 +00005791 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005792
paul020709f2003-04-04 02:44:16 +00005793 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005794}
5795
5796DEFUN (no_ospf_redistribute_source,
5797 no_ospf_redistribute_source_cmd,
5798 "no redistribute (kernel|connected|static|rip|bgp)",
5799 NO_STR
5800 "Redistribute information from another routing protocol\n"
5801 "Kernel routes\n"
5802 "Connected\n"
5803 "Static routes\n"
5804 "Routing Information Protocol (RIP)\n"
5805 "Border Gateway Protocol (BGP)\n")
5806{
paul020709f2003-04-04 02:44:16 +00005807 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005808 int source;
5809
5810 if (!str2distribute_source (argv[0], &source))
5811 return CMD_WARNING;
5812
paul020709f2003-04-04 02:44:16 +00005813 ospf_routemap_unset (ospf, source);
5814 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005815}
5816
5817DEFUN (ospf_distribute_list_out,
5818 ospf_distribute_list_out_cmd,
5819 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5820 "Filter networks in routing updates\n"
5821 "Access-list name\n"
5822 OUT_STR
5823 "Kernel routes\n"
5824 "Connected\n"
5825 "Static routes\n"
5826 "Routing Information Protocol (RIP)\n"
5827 "Border Gateway Protocol (BGP)\n")
5828{
paul68980082003-03-25 05:07:42 +00005829 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005830 int source;
5831
5832 /* Get distribute source. */
5833 if (!str2distribute_source (argv[1], &source))
5834 return CMD_WARNING;
5835
paul68980082003-03-25 05:07:42 +00005836 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005837}
5838
5839DEFUN (no_ospf_distribute_list_out,
5840 no_ospf_distribute_list_out_cmd,
5841 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5842 NO_STR
5843 "Filter networks in routing updates\n"
5844 "Access-list name\n"
5845 OUT_STR
5846 "Kernel routes\n"
5847 "Connected\n"
5848 "Static routes\n"
5849 "Routing Information Protocol (RIP)\n"
5850 "Border Gateway Protocol (BGP)\n")
5851{
paul68980082003-03-25 05:07:42 +00005852 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005853 int source;
5854
5855 if (!str2distribute_source (argv[1], &source))
5856 return CMD_WARNING;
5857
paul68980082003-03-25 05:07:42 +00005858 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005859}
5860
5861/* Default information originate. */
5862DEFUN (ospf_default_information_originate_metric_type_routemap,
5863 ospf_default_information_originate_metric_type_routemap_cmd,
5864 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5865 "Control distribution of default information\n"
5866 "Distribute a default route\n"
5867 "OSPF default metric\n"
5868 "OSPF metric\n"
5869 "OSPF metric type for default routes\n"
5870 "Set OSPF External Type 1 metrics\n"
5871 "Set OSPF External Type 2 metrics\n"
5872 "Route map reference\n"
5873 "Pointer to route-map entries\n")
5874{
paul020709f2003-04-04 02:44:16 +00005875 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005876 int type = -1;
5877 int metric = -1;
5878
5879 /* Get metric value. */
5880 if (argc >= 1)
5881 if (!str2metric (argv[0], &metric))
5882 return CMD_WARNING;
5883
5884 /* Get metric type. */
5885 if (argc >= 2)
5886 if (!str2metric_type (argv[1], &type))
5887 return CMD_WARNING;
5888
5889 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005890 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005891 else
paul020709f2003-04-04 02:44:16 +00005892 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005893
paul020709f2003-04-04 02:44:16 +00005894 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5895 type, metric);
paul718e3742002-12-13 20:15:29 +00005896}
5897
5898ALIAS (ospf_default_information_originate_metric_type_routemap,
5899 ospf_default_information_originate_metric_type_cmd,
5900 "default-information originate metric <0-16777214> metric-type (1|2)",
5901 "Control distribution of default information\n"
5902 "Distribute a default route\n"
5903 "OSPF default metric\n"
5904 "OSPF metric\n"
5905 "OSPF metric type for default routes\n"
5906 "Set OSPF External Type 1 metrics\n"
5907 "Set OSPF External Type 2 metrics\n")
5908
5909ALIAS (ospf_default_information_originate_metric_type_routemap,
5910 ospf_default_information_originate_metric_cmd,
5911 "default-information originate metric <0-16777214>",
5912 "Control distribution of default information\n"
5913 "Distribute a default route\n"
5914 "OSPF default metric\n"
5915 "OSPF metric\n")
5916
5917ALIAS (ospf_default_information_originate_metric_type_routemap,
5918 ospf_default_information_originate_cmd,
5919 "default-information originate",
5920 "Control distribution of default information\n"
5921 "Distribute a default route\n")
5922
5923/* Default information originate. */
5924DEFUN (ospf_default_information_originate_metric_routemap,
5925 ospf_default_information_originate_metric_routemap_cmd,
5926 "default-information originate metric <0-16777214> route-map WORD",
5927 "Control distribution of default information\n"
5928 "Distribute a default route\n"
5929 "OSPF default metric\n"
5930 "OSPF metric\n"
5931 "Route map reference\n"
5932 "Pointer to route-map entries\n")
5933{
paul020709f2003-04-04 02:44:16 +00005934 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005935 int metric = -1;
5936
5937 /* Get metric value. */
5938 if (argc >= 1)
5939 if (!str2metric (argv[0], &metric))
5940 return CMD_WARNING;
5941
5942 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005943 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005944 else
paul020709f2003-04-04 02:44:16 +00005945 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005946
paul020709f2003-04-04 02:44:16 +00005947 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5948 -1, metric);
paul718e3742002-12-13 20:15:29 +00005949}
5950
5951/* Default information originate. */
5952DEFUN (ospf_default_information_originate_routemap,
5953 ospf_default_information_originate_routemap_cmd,
5954 "default-information originate route-map WORD",
5955 "Control distribution of default information\n"
5956 "Distribute a default route\n"
5957 "Route map reference\n"
5958 "Pointer to route-map entries\n")
5959{
paul020709f2003-04-04 02:44:16 +00005960 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005961
paul020709f2003-04-04 02:44:16 +00005962 if (argc == 1)
5963 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5964 else
5965 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5966
5967 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005968}
5969
5970DEFUN (ospf_default_information_originate_type_metric_routemap,
5971 ospf_default_information_originate_type_metric_routemap_cmd,
5972 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5973 "Control distribution of default information\n"
5974 "Distribute a default route\n"
5975 "OSPF metric type for default routes\n"
5976 "Set OSPF External Type 1 metrics\n"
5977 "Set OSPF External Type 2 metrics\n"
5978 "OSPF default metric\n"
5979 "OSPF metric\n"
5980 "Route map reference\n"
5981 "Pointer to route-map entries\n")
5982{
paul020709f2003-04-04 02:44:16 +00005983 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005984 int type = -1;
5985 int metric = -1;
5986
5987 /* Get metric type. */
5988 if (argc >= 1)
5989 if (!str2metric_type (argv[0], &type))
5990 return CMD_WARNING;
5991
5992 /* Get metric value. */
5993 if (argc >= 2)
5994 if (!str2metric (argv[1], &metric))
5995 return CMD_WARNING;
5996
5997 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005998 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005999 else
paul020709f2003-04-04 02:44:16 +00006000 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006001
paul020709f2003-04-04 02:44:16 +00006002 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6003 type, metric);
paul718e3742002-12-13 20:15:29 +00006004}
6005
6006ALIAS (ospf_default_information_originate_type_metric_routemap,
6007 ospf_default_information_originate_type_metric_cmd,
6008 "default-information originate metric-type (1|2) metric <0-16777214>",
6009 "Control distribution of default information\n"
6010 "Distribute a default route\n"
6011 "OSPF metric type for default routes\n"
6012 "Set OSPF External Type 1 metrics\n"
6013 "Set OSPF External Type 2 metrics\n"
6014 "OSPF default metric\n"
6015 "OSPF metric\n")
6016
6017ALIAS (ospf_default_information_originate_type_metric_routemap,
6018 ospf_default_information_originate_type_cmd,
6019 "default-information originate metric-type (1|2)",
6020 "Control distribution of default information\n"
6021 "Distribute a default route\n"
6022 "OSPF metric type for default routes\n"
6023 "Set OSPF External Type 1 metrics\n"
6024 "Set OSPF External Type 2 metrics\n")
6025
6026DEFUN (ospf_default_information_originate_type_routemap,
6027 ospf_default_information_originate_type_routemap_cmd,
6028 "default-information originate metric-type (1|2) route-map WORD",
6029 "Control distribution of default information\n"
6030 "Distribute a default route\n"
6031 "OSPF metric type for default routes\n"
6032 "Set OSPF External Type 1 metrics\n"
6033 "Set OSPF External Type 2 metrics\n"
6034 "Route map reference\n"
6035 "Pointer to route-map entries\n")
6036{
paul020709f2003-04-04 02:44:16 +00006037 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006038 int type = -1;
6039
6040 /* Get metric type. */
6041 if (argc >= 1)
6042 if (!str2metric_type (argv[0], &type))
6043 return CMD_WARNING;
6044
6045 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006046 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006047 else
paul020709f2003-04-04 02:44:16 +00006048 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006049
paul020709f2003-04-04 02:44:16 +00006050 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6051 type, -1);
paul718e3742002-12-13 20:15:29 +00006052}
6053
6054DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6055 ospf_default_information_originate_always_metric_type_routemap_cmd,
6056 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6057 "Control distribution of default information\n"
6058 "Distribute a default route\n"
6059 "Always advertise default route\n"
6060 "OSPF default metric\n"
6061 "OSPF metric\n"
6062 "OSPF metric type for default routes\n"
6063 "Set OSPF External Type 1 metrics\n"
6064 "Set OSPF External Type 2 metrics\n"
6065 "Route map reference\n"
6066 "Pointer to route-map entries\n")
6067{
paul020709f2003-04-04 02:44:16 +00006068 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006069 int type = -1;
6070 int metric = -1;
6071
6072 /* Get metric value. */
6073 if (argc >= 1)
6074 if (!str2metric (argv[0], &metric))
6075 return CMD_WARNING;
6076
6077 /* Get metric type. */
6078 if (argc >= 2)
6079 if (!str2metric_type (argv[1], &type))
6080 return CMD_WARNING;
6081
6082 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006083 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006084 else
paul020709f2003-04-04 02:44:16 +00006085 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006086
paul020709f2003-04-04 02:44:16 +00006087 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006088 type, metric);
6089}
6090
6091ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6092 ospf_default_information_originate_always_metric_type_cmd,
6093 "default-information originate always metric <0-16777214> metric-type (1|2)",
6094 "Control distribution of default information\n"
6095 "Distribute a default route\n"
6096 "Always advertise default route\n"
6097 "OSPF default metric\n"
6098 "OSPF metric\n"
6099 "OSPF metric type for default routes\n"
6100 "Set OSPF External Type 1 metrics\n"
6101 "Set OSPF External Type 2 metrics\n")
6102
6103ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6104 ospf_default_information_originate_always_metric_cmd,
6105 "default-information originate always metric <0-16777214>",
6106 "Control distribution of default information\n"
6107 "Distribute a default route\n"
6108 "Always advertise default route\n"
6109 "OSPF default metric\n"
6110 "OSPF metric\n"
6111 "OSPF metric type for default routes\n")
6112
6113ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6114 ospf_default_information_originate_always_cmd,
6115 "default-information originate always",
6116 "Control distribution of default information\n"
6117 "Distribute a default route\n"
6118 "Always advertise default route\n")
6119
6120DEFUN (ospf_default_information_originate_always_metric_routemap,
6121 ospf_default_information_originate_always_metric_routemap_cmd,
6122 "default-information originate always metric <0-16777214> route-map WORD",
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 "Route map reference\n"
6129 "Pointer to route-map entries\n")
6130{
paul020709f2003-04-04 02:44:16 +00006131 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006132 int metric = -1;
6133
6134 /* Get metric value. */
6135 if (argc >= 1)
6136 if (!str2metric (argv[0], &metric))
6137 return CMD_WARNING;
6138
6139 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006140 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006141 else
paul020709f2003-04-04 02:44:16 +00006142 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006143
paul020709f2003-04-04 02:44:16 +00006144 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6145 -1, metric);
paul718e3742002-12-13 20:15:29 +00006146}
6147
6148DEFUN (ospf_default_information_originate_always_routemap,
6149 ospf_default_information_originate_always_routemap_cmd,
6150 "default-information originate always route-map WORD",
6151 "Control distribution of default information\n"
6152 "Distribute a default route\n"
6153 "Always advertise default route\n"
6154 "Route map reference\n"
6155 "Pointer to route-map entries\n")
6156{
paul020709f2003-04-04 02:44:16 +00006157 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006158
paul020709f2003-04-04 02:44:16 +00006159 if (argc == 1)
6160 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6161 else
6162 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6163
6164 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006165}
6166
6167DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6168 ospf_default_information_originate_always_type_metric_routemap_cmd,
6169 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6170 "Control distribution of default information\n"
6171 "Distribute a default route\n"
6172 "Always advertise default route\n"
6173 "OSPF metric type for default routes\n"
6174 "Set OSPF External Type 1 metrics\n"
6175 "Set OSPF External Type 2 metrics\n"
6176 "OSPF default metric\n"
6177 "OSPF metric\n"
6178 "Route map reference\n"
6179 "Pointer to route-map entries\n")
6180{
paul020709f2003-04-04 02:44:16 +00006181 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006182 int type = -1;
6183 int metric = -1;
6184
6185 /* Get metric type. */
6186 if (argc >= 1)
6187 if (!str2metric_type (argv[0], &type))
6188 return CMD_WARNING;
6189
6190 /* Get metric value. */
6191 if (argc >= 2)
6192 if (!str2metric (argv[1], &metric))
6193 return CMD_WARNING;
6194
6195 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006196 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006197 else
paul020709f2003-04-04 02:44:16 +00006198 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006199
paul020709f2003-04-04 02:44:16 +00006200 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006201 type, metric);
6202}
6203
6204ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6205 ospf_default_information_originate_always_type_metric_cmd,
6206 "default-information originate always metric-type (1|2) metric <0-16777214>",
6207 "Control distribution of default information\n"
6208 "Distribute a default route\n"
6209 "Always advertise default route\n"
6210 "OSPF metric type for default routes\n"
6211 "Set OSPF External Type 1 metrics\n"
6212 "Set OSPF External Type 2 metrics\n"
6213 "OSPF default metric\n"
6214 "OSPF metric\n")
6215
6216ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6217 ospf_default_information_originate_always_type_cmd,
6218 "default-information originate always metric-type (1|2)",
6219 "Control distribution of default information\n"
6220 "Distribute a default route\n"
6221 "Always advertise default route\n"
6222 "OSPF metric type for default routes\n"
6223 "Set OSPF External Type 1 metrics\n"
6224 "Set OSPF External Type 2 metrics\n")
6225
6226DEFUN (ospf_default_information_originate_always_type_routemap,
6227 ospf_default_information_originate_always_type_routemap_cmd,
6228 "default-information originate always metric-type (1|2) route-map WORD",
6229 "Control distribution of default information\n"
6230 "Distribute a default route\n"
6231 "Always advertise default route\n"
6232 "OSPF metric type for default routes\n"
6233 "Set OSPF External Type 1 metrics\n"
6234 "Set OSPF External Type 2 metrics\n"
6235 "Route map reference\n"
6236 "Pointer to route-map entries\n")
6237{
paul020709f2003-04-04 02:44:16 +00006238 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006239 int type = -1;
6240
6241 /* Get metric type. */
6242 if (argc >= 1)
6243 if (!str2metric_type (argv[0], &type))
6244 return CMD_WARNING;
6245
6246 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006247 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006248 else
paul020709f2003-04-04 02:44:16 +00006249 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006250
paul020709f2003-04-04 02:44:16 +00006251 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006252 type, -1);
6253}
6254
6255DEFUN (no_ospf_default_information_originate,
6256 no_ospf_default_information_originate_cmd,
6257 "no default-information originate",
6258 NO_STR
6259 "Control distribution of default information\n"
6260 "Distribute a default route\n")
6261{
paul68980082003-03-25 05:07:42 +00006262 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006263 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006264
6265 p.family = AF_INET;
6266 p.prefix.s_addr = 0;
6267 p.prefixlen = 0;
6268
ajs5339cfd2005-09-19 13:28:05 +00006269 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006270
6271 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6272 ospf_external_info_delete (DEFAULT_ROUTE, p);
6273 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6274 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6275 }
6276
paul020709f2003-04-04 02:44:16 +00006277 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6278 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006279}
6280
6281DEFUN (ospf_default_metric,
6282 ospf_default_metric_cmd,
6283 "default-metric <0-16777214>",
6284 "Set metric of redistributed routes\n"
6285 "Default metric\n")
6286{
paul68980082003-03-25 05:07:42 +00006287 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006288 int metric = -1;
6289
6290 if (!str2metric (argv[0], &metric))
6291 return CMD_WARNING;
6292
paul68980082003-03-25 05:07:42 +00006293 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006294
6295 return CMD_SUCCESS;
6296}
6297
6298DEFUN (no_ospf_default_metric,
6299 no_ospf_default_metric_cmd,
6300 "no default-metric",
6301 NO_STR
6302 "Set metric of redistributed routes\n")
6303{
paul68980082003-03-25 05:07:42 +00006304 struct ospf *ospf = vty->index;
6305
6306 ospf->default_metric = -1;
6307
paul718e3742002-12-13 20:15:29 +00006308 return CMD_SUCCESS;
6309}
6310
6311ALIAS (no_ospf_default_metric,
6312 no_ospf_default_metric_val_cmd,
6313 "no default-metric <0-16777214>",
6314 NO_STR
6315 "Set metric of redistributed routes\n"
6316 "Default metric\n")
6317
6318DEFUN (ospf_distance,
6319 ospf_distance_cmd,
6320 "distance <1-255>",
6321 "Define an administrative distance\n"
6322 "OSPF Administrative distance\n")
6323{
paul68980082003-03-25 05:07:42 +00006324 struct ospf *ospf = vty->index;
6325
6326 ospf->distance_all = atoi (argv[0]);
6327
paul718e3742002-12-13 20:15:29 +00006328 return CMD_SUCCESS;
6329}
6330
6331DEFUN (no_ospf_distance,
6332 no_ospf_distance_cmd,
6333 "no distance <1-255>",
6334 NO_STR
6335 "Define an administrative distance\n"
6336 "OSPF Administrative distance\n")
6337{
paul68980082003-03-25 05:07:42 +00006338 struct ospf *ospf = vty->index;
6339
6340 ospf->distance_all = 0;
6341
paul718e3742002-12-13 20:15:29 +00006342 return CMD_SUCCESS;
6343}
6344
6345DEFUN (no_ospf_distance_ospf,
6346 no_ospf_distance_ospf_cmd,
6347 "no distance ospf",
6348 NO_STR
6349 "Define an administrative distance\n"
6350 "OSPF Administrative distance\n"
6351 "OSPF Distance\n")
6352{
paul68980082003-03-25 05:07:42 +00006353 struct ospf *ospf = vty->index;
6354
6355 ospf->distance_intra = 0;
6356 ospf->distance_inter = 0;
6357 ospf->distance_external = 0;
6358
paul718e3742002-12-13 20:15:29 +00006359 return CMD_SUCCESS;
6360}
6361
6362DEFUN (ospf_distance_ospf_intra,
6363 ospf_distance_ospf_intra_cmd,
6364 "distance ospf intra-area <1-255>",
6365 "Define an administrative distance\n"
6366 "OSPF Administrative distance\n"
6367 "Intra-area routes\n"
6368 "Distance for intra-area routes\n")
6369{
paul68980082003-03-25 05:07:42 +00006370 struct ospf *ospf = vty->index;
6371
6372 ospf->distance_intra = atoi (argv[0]);
6373
paul718e3742002-12-13 20:15:29 +00006374 return CMD_SUCCESS;
6375}
6376
6377DEFUN (ospf_distance_ospf_intra_inter,
6378 ospf_distance_ospf_intra_inter_cmd,
6379 "distance ospf intra-area <1-255> inter-area <1-255>",
6380 "Define an administrative distance\n"
6381 "OSPF Administrative distance\n"
6382 "Intra-area routes\n"
6383 "Distance for intra-area routes\n"
6384 "Inter-area routes\n"
6385 "Distance for inter-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 ospf->distance_inter = atoi (argv[1]);
6391
paul718e3742002-12-13 20:15:29 +00006392 return CMD_SUCCESS;
6393}
6394
6395DEFUN (ospf_distance_ospf_intra_external,
6396 ospf_distance_ospf_intra_external_cmd,
6397 "distance ospf intra-area <1-255> external <1-255>",
6398 "Define an administrative distance\n"
6399 "OSPF Administrative distance\n"
6400 "Intra-area routes\n"
6401 "Distance for intra-area routes\n"
6402 "External routes\n"
6403 "Distance for external routes\n")
6404{
paul68980082003-03-25 05:07:42 +00006405 struct ospf *ospf = vty->index;
6406
6407 ospf->distance_intra = atoi (argv[0]);
6408 ospf->distance_external = atoi (argv[1]);
6409
paul718e3742002-12-13 20:15:29 +00006410 return CMD_SUCCESS;
6411}
6412
6413DEFUN (ospf_distance_ospf_intra_inter_external,
6414 ospf_distance_ospf_intra_inter_external_cmd,
6415 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6416 "Define an administrative distance\n"
6417 "OSPF Administrative distance\n"
6418 "Intra-area routes\n"
6419 "Distance for intra-area routes\n"
6420 "Inter-area routes\n"
6421 "Distance for inter-area routes\n"
6422 "External routes\n"
6423 "Distance for external routes\n")
6424{
paul68980082003-03-25 05:07:42 +00006425 struct ospf *ospf = vty->index;
6426
6427 ospf->distance_intra = atoi (argv[0]);
6428 ospf->distance_inter = atoi (argv[1]);
6429 ospf->distance_external = atoi (argv[2]);
6430
paul718e3742002-12-13 20:15:29 +00006431 return CMD_SUCCESS;
6432}
6433
6434DEFUN (ospf_distance_ospf_intra_external_inter,
6435 ospf_distance_ospf_intra_external_inter_cmd,
6436 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6437 "Define an administrative distance\n"
6438 "OSPF Administrative distance\n"
6439 "Intra-area routes\n"
6440 "Distance for intra-area routes\n"
6441 "External routes\n"
6442 "Distance for external routes\n"
6443 "Inter-area routes\n"
6444 "Distance for inter-area routes\n")
6445{
paul68980082003-03-25 05:07:42 +00006446 struct ospf *ospf = vty->index;
6447
6448 ospf->distance_intra = atoi (argv[0]);
6449 ospf->distance_external = atoi (argv[1]);
6450 ospf->distance_inter = atoi (argv[2]);
6451
paul718e3742002-12-13 20:15:29 +00006452 return CMD_SUCCESS;
6453}
6454
6455DEFUN (ospf_distance_ospf_inter,
6456 ospf_distance_ospf_inter_cmd,
6457 "distance ospf inter-area <1-255>",
6458 "Define an administrative distance\n"
6459 "OSPF Administrative distance\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_inter = atoi (argv[0]);
6466
paul718e3742002-12-13 20:15:29 +00006467 return CMD_SUCCESS;
6468}
6469
6470DEFUN (ospf_distance_ospf_inter_intra,
6471 ospf_distance_ospf_inter_intra_cmd,
6472 "distance ospf inter-area <1-255> intra-area <1-255>",
6473 "Define an administrative distance\n"
6474 "OSPF Administrative distance\n"
6475 "Inter-area routes\n"
6476 "Distance for inter-area routes\n"
6477 "Intra-area routes\n"
6478 "Distance for intra-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 ospf->distance_intra = atoi (argv[1]);
6484
paul718e3742002-12-13 20:15:29 +00006485 return CMD_SUCCESS;
6486}
6487
6488DEFUN (ospf_distance_ospf_inter_external,
6489 ospf_distance_ospf_inter_external_cmd,
6490 "distance ospf inter-area <1-255> external <1-255>",
6491 "Define an administrative distance\n"
6492 "OSPF Administrative distance\n"
6493 "Inter-area routes\n"
6494 "Distance for inter-area routes\n"
6495 "External routes\n"
6496 "Distance for external routes\n")
6497{
paul68980082003-03-25 05:07:42 +00006498 struct ospf *ospf = vty->index;
6499
6500 ospf->distance_inter = atoi (argv[0]);
6501 ospf->distance_external = atoi (argv[1]);
6502
paul718e3742002-12-13 20:15:29 +00006503 return CMD_SUCCESS;
6504}
6505
6506DEFUN (ospf_distance_ospf_inter_intra_external,
6507 ospf_distance_ospf_inter_intra_external_cmd,
6508 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6509 "Define an administrative distance\n"
6510 "OSPF Administrative distance\n"
6511 "Inter-area routes\n"
6512 "Distance for inter-area routes\n"
6513 "Intra-area routes\n"
6514 "Distance for intra-area routes\n"
6515 "External routes\n"
6516 "Distance for external routes\n")
6517{
paul68980082003-03-25 05:07:42 +00006518 struct ospf *ospf = vty->index;
6519
6520 ospf->distance_inter = atoi (argv[0]);
6521 ospf->distance_intra = atoi (argv[1]);
6522 ospf->distance_external = atoi (argv[2]);
6523
paul718e3742002-12-13 20:15:29 +00006524 return CMD_SUCCESS;
6525}
6526
6527DEFUN (ospf_distance_ospf_inter_external_intra,
6528 ospf_distance_ospf_inter_external_intra_cmd,
6529 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6530 "Define an administrative distance\n"
6531 "OSPF Administrative distance\n"
6532 "Inter-area routes\n"
6533 "Distance for inter-area routes\n"
6534 "External routes\n"
6535 "Distance for external routes\n"
6536 "Intra-area routes\n"
6537 "Distance for intra-area routes\n")
6538{
paul68980082003-03-25 05:07:42 +00006539 struct ospf *ospf = vty->index;
6540
6541 ospf->distance_inter = atoi (argv[0]);
6542 ospf->distance_external = atoi (argv[1]);
6543 ospf->distance_intra = atoi (argv[2]);
6544
paul718e3742002-12-13 20:15:29 +00006545 return CMD_SUCCESS;
6546}
6547
6548DEFUN (ospf_distance_ospf_external,
6549 ospf_distance_ospf_external_cmd,
6550 "distance ospf external <1-255>",
6551 "Define an administrative distance\n"
6552 "OSPF Administrative distance\n"
6553 "External routes\n"
6554 "Distance for external routes\n")
6555{
paul68980082003-03-25 05:07:42 +00006556 struct ospf *ospf = vty->index;
6557
6558 ospf->distance_external = atoi (argv[0]);
6559
paul718e3742002-12-13 20:15:29 +00006560 return CMD_SUCCESS;
6561}
6562
6563DEFUN (ospf_distance_ospf_external_intra,
6564 ospf_distance_ospf_external_intra_cmd,
6565 "distance ospf external <1-255> intra-area <1-255>",
6566 "Define an administrative distance\n"
6567 "OSPF Administrative distance\n"
6568 "External routes\n"
6569 "Distance for external routes\n"
6570 "Intra-area routes\n"
6571 "Distance for intra-area routes\n")
6572{
paul68980082003-03-25 05:07:42 +00006573 struct ospf *ospf = vty->index;
6574
6575 ospf->distance_external = atoi (argv[0]);
6576 ospf->distance_intra = atoi (argv[1]);
6577
paul718e3742002-12-13 20:15:29 +00006578 return CMD_SUCCESS;
6579}
6580
6581DEFUN (ospf_distance_ospf_external_inter,
6582 ospf_distance_ospf_external_inter_cmd,
6583 "distance ospf external <1-255> inter-area <1-255>",
6584 "Define an administrative distance\n"
6585 "OSPF Administrative distance\n"
6586 "External routes\n"
6587 "Distance for external routes\n"
6588 "Inter-area routes\n"
6589 "Distance for inter-area routes\n")
6590{
paul68980082003-03-25 05:07:42 +00006591 struct ospf *ospf = vty->index;
6592
6593 ospf->distance_external = atoi (argv[0]);
6594 ospf->distance_inter = atoi (argv[1]);
6595
paul718e3742002-12-13 20:15:29 +00006596 return CMD_SUCCESS;
6597}
6598
6599DEFUN (ospf_distance_ospf_external_intra_inter,
6600 ospf_distance_ospf_external_intra_inter_cmd,
6601 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6602 "Define an administrative distance\n"
6603 "OSPF Administrative distance\n"
6604 "External routes\n"
6605 "Distance for external routes\n"
6606 "Intra-area routes\n"
6607 "Distance for intra-area routes\n"
6608 "Inter-area routes\n"
6609 "Distance for inter-area routes\n")
6610{
paul68980082003-03-25 05:07:42 +00006611 struct ospf *ospf = vty->index;
6612
6613 ospf->distance_external = atoi (argv[0]);
6614 ospf->distance_intra = atoi (argv[1]);
6615 ospf->distance_inter = atoi (argv[2]);
6616
paul718e3742002-12-13 20:15:29 +00006617 return CMD_SUCCESS;
6618}
6619
6620DEFUN (ospf_distance_ospf_external_inter_intra,
6621 ospf_distance_ospf_external_inter_intra_cmd,
6622 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6623 "Define an administrative distance\n"
6624 "OSPF Administrative distance\n"
6625 "External routes\n"
6626 "Distance for external routes\n"
6627 "Inter-area routes\n"
6628 "Distance for inter-area routes\n"
6629 "Intra-area routes\n"
6630 "Distance for intra-area routes\n")
6631{
paul68980082003-03-25 05:07:42 +00006632 struct ospf *ospf = vty->index;
6633
6634 ospf->distance_external = atoi (argv[0]);
6635 ospf->distance_inter = atoi (argv[1]);
6636 ospf->distance_intra = atoi (argv[2]);
6637
paul718e3742002-12-13 20:15:29 +00006638 return CMD_SUCCESS;
6639}
6640
6641DEFUN (ospf_distance_source,
6642 ospf_distance_source_cmd,
6643 "distance <1-255> A.B.C.D/M",
6644 "Administrative distance\n"
6645 "Distance value\n"
6646 "IP source prefix\n")
6647{
paul020709f2003-04-04 02:44:16 +00006648 struct ospf *ospf = vty->index;
6649
6650 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006651
paul718e3742002-12-13 20:15:29 +00006652 return CMD_SUCCESS;
6653}
6654
6655DEFUN (no_ospf_distance_source,
6656 no_ospf_distance_source_cmd,
6657 "no distance <1-255> A.B.C.D/M",
6658 NO_STR
6659 "Administrative distance\n"
6660 "Distance value\n"
6661 "IP source prefix\n")
6662{
paul020709f2003-04-04 02:44:16 +00006663 struct ospf *ospf = vty->index;
6664
6665 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6666
paul718e3742002-12-13 20:15:29 +00006667 return CMD_SUCCESS;
6668}
6669
6670DEFUN (ospf_distance_source_access_list,
6671 ospf_distance_source_access_list_cmd,
6672 "distance <1-255> A.B.C.D/M WORD",
6673 "Administrative distance\n"
6674 "Distance value\n"
6675 "IP source prefix\n"
6676 "Access list name\n")
6677{
paul020709f2003-04-04 02:44:16 +00006678 struct ospf *ospf = vty->index;
6679
6680 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6681
paul718e3742002-12-13 20:15:29 +00006682 return CMD_SUCCESS;
6683}
6684
6685DEFUN (no_ospf_distance_source_access_list,
6686 no_ospf_distance_source_access_list_cmd,
6687 "no distance <1-255> A.B.C.D/M WORD",
6688 NO_STR
6689 "Administrative distance\n"
6690 "Distance value\n"
6691 "IP source prefix\n"
6692 "Access list name\n")
6693{
paul020709f2003-04-04 02:44:16 +00006694 struct ospf *ospf = vty->index;
6695
6696 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6697
paul718e3742002-12-13 20:15:29 +00006698 return CMD_SUCCESS;
6699}
6700
vincentba682532005-09-29 13:52:57 +00006701DEFUN (ip_ospf_mtu_ignore,
6702 ip_ospf_mtu_ignore_addr_cmd,
6703 "ip ospf mtu-ignore A.B.C.D",
6704 "IP Information\n"
6705 "OSPF interface commands\n"
6706 "Disable mtu mismatch detection\n"
6707 "Address of interface")
6708{
6709 struct interface *ifp = vty->index;
6710 struct in_addr addr;
6711 int ret;
6712
6713 struct ospf_if_params *params;
6714 params = IF_DEF_PARAMS (ifp);
6715
6716 if (argc == 1)
6717 {
6718 ret = inet_aton(argv[0], &addr);
6719 if (!ret)
6720 {
6721 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6722 VTY_NEWLINE);
6723 return CMD_WARNING;
6724 }
6725 params = ospf_get_if_params (ifp, addr);
6726 ospf_if_update_params (ifp, addr);
6727 }
6728 params->mtu_ignore = 1;
6729 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6730 SET_IF_PARAM (params, mtu_ignore);
6731 else
6732 {
6733 UNSET_IF_PARAM (params, mtu_ignore);
6734 if (params != IF_DEF_PARAMS (ifp))
6735 {
6736 ospf_free_if_params (ifp, addr);
6737 ospf_if_update_params (ifp, addr);
6738 }
6739 }
6740 return CMD_SUCCESS;
6741}
6742
6743ALIAS (ip_ospf_mtu_ignore,
6744 ip_ospf_mtu_ignore_cmd,
6745 "ip ospf mtu-ignore",
6746 "IP Information\n"
6747 "OSPF interface commands\n"
6748 "Disable mtu mismatch detection\n")
6749
6750
6751DEFUN (no_ip_ospf_mtu_ignore,
6752 no_ip_ospf_mtu_ignore_addr_cmd,
6753 "no ip ospf mtu-ignore A.B.C.D",
6754 "IP Information\n"
6755 "OSPF interface commands\n"
6756 "Disable mtu mismatch detection\n"
6757 "Address of interface")
6758{
6759 struct interface *ifp = vty->index;
6760 struct in_addr addr;
6761 int ret;
6762
6763 struct ospf_if_params *params;
6764 params = IF_DEF_PARAMS (ifp);
6765
6766 if (argc == 1)
6767 {
6768 ret = inet_aton(argv[0], &addr);
6769 if (!ret)
6770 {
6771 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6772 VTY_NEWLINE);
6773 return CMD_WARNING;
6774 }
6775 params = ospf_get_if_params (ifp, addr);
6776 ospf_if_update_params (ifp, addr);
6777 }
6778 params->mtu_ignore = 0;
6779 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6780 SET_IF_PARAM (params, mtu_ignore);
6781 else
6782 {
6783 UNSET_IF_PARAM (params, mtu_ignore);
6784 if (params != IF_DEF_PARAMS (ifp))
6785 {
6786 ospf_free_if_params (ifp, addr);
6787 ospf_if_update_params (ifp, addr);
6788 }
6789 }
6790 return CMD_SUCCESS;
6791}
6792
6793ALIAS (no_ip_ospf_mtu_ignore,
6794 no_ip_ospf_mtu_ignore_cmd,
6795 "no ip ospf mtu-ignore",
6796 "IP Information\n"
6797 "OSPF interface commands\n"
6798 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00006799
6800DEFUN (ospf_max_metric_router_lsa_admin,
6801 ospf_max_metric_router_lsa_admin_cmd,
6802 "max-metric router-lsa administrative",
6803 "OSPF maximum / infinite-distance metric\n"
6804 "Advertise own Router-LSA with infinite distance (stub router)\n"
6805 "Administratively applied, for an indefinite period\n")
6806{
6807 struct listnode *ln;
6808 struct ospf_area *area;
6809 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006810
paul88d6cf32005-10-29 12:50:09 +00006811 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6812 {
6813 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6814
6815 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
6816 ospf_router_lsa_timer_add (area);
6817 }
6818 return CMD_SUCCESS;
6819}
6820
6821DEFUN (no_ospf_max_metric_router_lsa_admin,
6822 no_ospf_max_metric_router_lsa_admin_cmd,
6823 "no max-metric router-lsa administrative",
6824 NO_STR
6825 "OSPF maximum / infinite-distance metric\n"
6826 "Advertise own Router-LSA with infinite distance (stub router)\n"
6827 "Administratively applied, for an indefinite period\n")
6828{
6829 struct listnode *ln;
6830 struct ospf_area *area;
6831 struct ospf *ospf = vty->index;
6832
6833 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6834 {
6835 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6836
6837 /* Don't trample on the start-up stub timer */
6838 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6839 && !area->t_stub_router)
6840 {
6841 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6842 ospf_router_lsa_timer_add (area);
6843 }
6844 }
6845 return CMD_SUCCESS;
6846}
6847
6848DEFUN (ospf_max_metric_router_lsa_startup,
6849 ospf_max_metric_router_lsa_startup_cmd,
6850 "max-metric router-lsa on-startup <5-86400>",
6851 "OSPF maximum / infinite-distance metric\n"
6852 "Advertise own Router-LSA with infinite distance (stub router)\n"
6853 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6854 "Time (seconds) to advertise self as stub-router\n")
6855{
6856 unsigned int seconds;
6857 struct ospf *ospf = vty->index;
6858
6859 if (argc != 1)
6860 {
6861 vty_out (vty, "%% Must supply stub-router period");
6862 return CMD_WARNING;
6863 }
6864
6865 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6866
6867 ospf->stub_router_startup_time = seconds;
6868
6869 return CMD_SUCCESS;
6870}
6871
6872DEFUN (no_ospf_max_metric_router_lsa_startup,
6873 no_ospf_max_metric_router_lsa_startup_cmd,
6874 "no max-metric router-lsa on-startup",
6875 NO_STR
6876 "OSPF maximum / infinite-distance metric\n"
6877 "Advertise own Router-LSA with infinite distance (stub router)\n"
6878 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6879{
6880 struct listnode *ln;
6881 struct ospf_area *area;
6882 struct ospf *ospf = vty->index;
6883
6884 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6885
6886 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6887 {
6888 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6889 OSPF_TIMER_OFF (area->t_stub_router);
6890
6891 /* Don't trample on admin stub routed */
6892 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6893 {
6894 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6895 ospf_router_lsa_timer_add (area);
6896 }
6897 }
6898 return CMD_SUCCESS;
6899}
6900
6901DEFUN (ospf_max_metric_router_lsa_shutdown,
6902 ospf_max_metric_router_lsa_shutdown_cmd,
6903 "max-metric router-lsa on-shutdown <5-86400>",
6904 "OSPF maximum / infinite-distance metric\n"
6905 "Advertise own Router-LSA with infinite distance (stub router)\n"
6906 "Advertise stub-router prior to full shutdown of OSPF\n"
6907 "Time (seconds) to wait till full shutdown\n")
6908{
6909 unsigned int seconds;
6910 struct ospf *ospf = vty->index;
6911
6912 if (argc != 1)
6913 {
6914 vty_out (vty, "%% Must supply stub-router shutdown period");
6915 return CMD_WARNING;
6916 }
6917
6918 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6919
6920 ospf->stub_router_shutdown_time = seconds;
6921
6922 return CMD_SUCCESS;
6923}
6924
6925DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6926 no_ospf_max_metric_router_lsa_shutdown_cmd,
6927 "no max-metric router-lsa on-shutdown",
6928 NO_STR
6929 "OSPF maximum / infinite-distance metric\n"
6930 "Advertise own Router-LSA with infinite distance (stub router)\n"
6931 "Advertise stub-router prior to full shutdown of OSPF\n")
6932{
6933 struct ospf *ospf = vty->index;
6934
6935 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6936
6937 return CMD_SUCCESS;
6938}
6939
6940static void
6941config_write_stub_router (struct vty *vty, struct ospf *ospf)
6942{
6943 struct listnode *ln;
6944 struct ospf_area *area;
6945
6946 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6947 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6948 ospf->stub_router_startup_time, VTY_NEWLINE);
6949 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6950 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6951 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6952 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6953 {
6954 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6955 {
6956 vty_out (vty, " max-metric router-lsa administrative%s",
6957 VTY_NEWLINE);
6958 break;
6959 }
6960 }
6961 return;
6962}
6963
paul4dadc292005-05-06 21:37:42 +00006964static void
paul718e3742002-12-13 20:15:29 +00006965show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6966{
6967 struct route_node *rn;
6968 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006969 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006970 struct ospf_path *path;
6971
6972 vty_out (vty, "============ OSPF network routing table ============%s",
6973 VTY_NEWLINE);
6974
6975 for (rn = route_top (rt); rn; rn = route_next (rn))
6976 if ((or = rn->info) != NULL)
6977 {
6978 char buf1[19];
6979 snprintf (buf1, 19, "%s/%d",
6980 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6981
6982 switch (or->path_type)
6983 {
6984 case OSPF_PATH_INTER_AREA:
6985 if (or->type == OSPF_DESTINATION_NETWORK)
6986 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6987 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6988 else if (or->type == OSPF_DESTINATION_DISCARD)
6989 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6990 break;
6991 case OSPF_PATH_INTRA_AREA:
6992 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6993 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6994 break;
6995 default:
6996 break;
6997 }
6998
6999 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007000 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007001 {
hasso54bedb52005-08-17 13:31:47 +00007002 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00007003 {
7004 if (path->nexthop.s_addr == 0)
7005 vty_out (vty, "%24s directly attached to %s%s",
7006 "", path->oi->ifp->name, VTY_NEWLINE);
7007 else
7008 vty_out (vty, "%24s via %s, %s%s", "",
7009 inet_ntoa (path->nexthop), path->oi->ifp->name,
7010 VTY_NEWLINE);
7011 }
7012 }
paul718e3742002-12-13 20:15:29 +00007013 }
7014 vty_out (vty, "%s", VTY_NEWLINE);
7015}
7016
paul4dadc292005-05-06 21:37:42 +00007017static void
paul718e3742002-12-13 20:15:29 +00007018show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7019{
7020 struct route_node *rn;
7021 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007022 struct listnode *pnode;
7023 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007024 struct ospf_path *path;
7025
7026 vty_out (vty, "============ OSPF router routing table =============%s",
7027 VTY_NEWLINE);
7028 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7029 if (rn->info)
7030 {
7031 int flag = 0;
7032
7033 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7034
paul1eb8ef22005-04-07 07:30:20 +00007035 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7036 {
7037 if (flag++)
7038 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007039
paul1eb8ef22005-04-07 07:30:20 +00007040 /* Show path. */
7041 vty_out (vty, "%s [%d] area: %s",
7042 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7043 or->cost, inet_ntoa (or->u.std.area_id));
7044 /* Show flags. */
7045 vty_out (vty, "%s%s%s",
7046 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7047 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7048 VTY_NEWLINE);
7049
7050 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7051 {
hasso54bedb52005-08-17 13:31:47 +00007052 if (path->oi != NULL && ospf_if_exists(path->oi))
7053 {
7054 if (path->nexthop.s_addr == 0)
7055 vty_out (vty, "%24s directly attached to %s%s",
7056 "", path->oi->ifp->name, VTY_NEWLINE);
7057 else
7058 vty_out (vty, "%24s via %s, %s%s", "",
7059 inet_ntoa (path->nexthop),
7060 path->oi->ifp->name, VTY_NEWLINE);
7061 }
paul1eb8ef22005-04-07 07:30:20 +00007062 }
7063 }
paul718e3742002-12-13 20:15:29 +00007064 }
7065 vty_out (vty, "%s", VTY_NEWLINE);
7066}
7067
paul4dadc292005-05-06 21:37:42 +00007068static void
paul718e3742002-12-13 20:15:29 +00007069show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7070{
7071 struct route_node *rn;
7072 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007073 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007074 struct ospf_path *path;
7075
7076 vty_out (vty, "============ OSPF external routing table ===========%s",
7077 VTY_NEWLINE);
7078 for (rn = route_top (rt); rn; rn = route_next (rn))
7079 if ((er = rn->info) != NULL)
7080 {
7081 char buf1[19];
7082 snprintf (buf1, 19, "%s/%d",
7083 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7084
7085 switch (er->path_type)
7086 {
7087 case OSPF_PATH_TYPE1_EXTERNAL:
7088 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7089 er->cost, er->u.ext.tag, VTY_NEWLINE);
7090 break;
7091 case OSPF_PATH_TYPE2_EXTERNAL:
7092 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7093 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7094 break;
7095 }
7096
paul1eb8ef22005-04-07 07:30:20 +00007097 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007098 {
hasso54bedb52005-08-17 13:31:47 +00007099 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00007100 {
7101 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007102 vty_out (vty, "%24s directly attached to %s%s",
7103 "", path->oi->ifp->name, VTY_NEWLINE);
7104 else
7105 vty_out (vty, "%24s via %s, %s%s", "",
7106 inet_ntoa (path->nexthop), path->oi->ifp->name,
7107 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007108 }
7109 }
7110 }
7111 vty_out (vty, "%s", VTY_NEWLINE);
7112}
7113
paul718e3742002-12-13 20:15:29 +00007114DEFUN (show_ip_ospf_border_routers,
7115 show_ip_ospf_border_routers_cmd,
7116 "show ip ospf border-routers",
7117 SHOW_STR
7118 IP_STR
7119 "show all the ABR's and ASBR's\n"
7120 "for this area\n")
7121{
paul020709f2003-04-04 02:44:16 +00007122 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007123
paul020709f2003-04-04 02:44:16 +00007124 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007125 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00007126 {
7127 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
7128 return CMD_SUCCESS;
7129 }
7130
paul68980082003-03-25 05:07:42 +00007131 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007132 {
7133 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7134 return CMD_SUCCESS;
7135 }
7136
7137 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007138 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007139
7140 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007141 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007142
7143 return CMD_SUCCESS;
7144}
paul718e3742002-12-13 20:15:29 +00007145
7146DEFUN (show_ip_ospf_route,
7147 show_ip_ospf_route_cmd,
7148 "show ip ospf route",
7149 SHOW_STR
7150 IP_STR
7151 "OSPF information\n"
7152 "OSPF routing table\n")
7153{
paul020709f2003-04-04 02:44:16 +00007154 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007155
paul020709f2003-04-04 02:44:16 +00007156 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007157 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00007158 {
7159 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
7160 return CMD_SUCCESS;
7161 }
7162
paul68980082003-03-25 05:07:42 +00007163 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007164 {
7165 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7166 return CMD_SUCCESS;
7167 }
7168
7169 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007170 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007171
7172 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007173 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007174
7175 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007176 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007177
7178 return CMD_SUCCESS;
7179}
7180
7181
hassoeb1ce602004-10-08 08:17:22 +00007182const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007183{
7184 "unknown",
7185 "standard",
7186 "ibm",
7187 "cisco",
7188 "shortcut"
7189};
7190
hassoeb1ce602004-10-08 08:17:22 +00007191const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007192{
7193 "default",
7194 "enable",
7195 "disable"
7196};
7197
7198
paul4dadc292005-05-06 21:37:42 +00007199static void
paul718e3742002-12-13 20:15:29 +00007200area_id2str (char *buf, int length, struct ospf_area *area)
7201{
7202 memset (buf, 0, length);
7203
7204 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7205 strncpy (buf, inet_ntoa (area->area_id), length);
7206 else
7207 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7208}
7209
7210
hassoeb1ce602004-10-08 08:17:22 +00007211const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007212{
7213 "unknown", /* should never be used. */
7214 "point-to-point",
7215 "broadcast",
7216 "non-broadcast",
7217 "point-to-multipoint",
7218 "virtual-link", /* should never be used. */
7219 "loopback"
7220};
7221
7222/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007223static int
paul718e3742002-12-13 20:15:29 +00007224config_write_interface (struct vty *vty)
7225{
hasso52dc7ee2004-09-23 19:18:23 +00007226 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007227 struct interface *ifp;
7228 struct crypt_key *ck;
7229 int write = 0;
7230 struct route_node *rn = NULL;
7231 struct ospf_if_params *params;
7232
paul1eb8ef22005-04-07 07:30:20 +00007233 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007234 {
paul718e3742002-12-13 20:15:29 +00007235 if (memcmp (ifp->name, "VLINK", 5) == 0)
7236 continue;
7237
7238 vty_out (vty, "!%s", VTY_NEWLINE);
7239 vty_out (vty, "interface %s%s", ifp->name,
7240 VTY_NEWLINE);
7241 if (ifp->desc)
7242 vty_out (vty, " description %s%s", ifp->desc,
7243 VTY_NEWLINE);
7244
7245 write++;
7246
7247 params = IF_DEF_PARAMS (ifp);
7248
7249 do {
7250 /* Interface Network print. */
7251 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007252 params->type != OSPF_IFTYPE_LOOPBACK)
7253 {
ajsbc18d612004-12-15 15:07:19 +00007254 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007255 {
7256 vty_out (vty, " ip ospf network %s",
7257 ospf_int_type_str[params->type]);
7258 if (params != IF_DEF_PARAMS (ifp))
7259 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7260 vty_out (vty, "%s", VTY_NEWLINE);
7261 }
paul718e3742002-12-13 20:15:29 +00007262 }
7263
7264 /* OSPF interface authentication print */
7265 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7266 params->auth_type != OSPF_AUTH_NOTSET)
7267 {
hassoeb1ce602004-10-08 08:17:22 +00007268 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007269
7270 /* Translation tables are not that much help here due to syntax
7271 of the simple option */
7272 switch (params->auth_type)
7273 {
7274
7275 case OSPF_AUTH_NULL:
7276 auth_str = " null";
7277 break;
7278
7279 case OSPF_AUTH_SIMPLE:
7280 auth_str = "";
7281 break;
7282
7283 case OSPF_AUTH_CRYPTOGRAPHIC:
7284 auth_str = " message-digest";
7285 break;
7286
7287 default:
7288 auth_str = "";
7289 break;
7290 }
7291
7292 vty_out (vty, " ip ospf authentication%s", auth_str);
7293 if (params != IF_DEF_PARAMS (ifp))
7294 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7295 vty_out (vty, "%s", VTY_NEWLINE);
7296 }
7297
7298 /* Simple Authentication Password print. */
7299 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7300 params->auth_simple[0] != '\0')
7301 {
7302 vty_out (vty, " ip ospf authentication-key %s",
7303 params->auth_simple);
7304 if (params != IF_DEF_PARAMS (ifp))
7305 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7306 vty_out (vty, "%s", VTY_NEWLINE);
7307 }
7308
7309 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007310 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007311 {
paul718e3742002-12-13 20:15:29 +00007312 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7313 ck->key_id, ck->auth_key);
7314 if (params != IF_DEF_PARAMS (ifp))
7315 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7316 vty_out (vty, "%s", VTY_NEWLINE);
7317 }
7318
7319 /* Interface Output Cost print. */
7320 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7321 {
7322 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7323 if (params != IF_DEF_PARAMS (ifp))
7324 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7325 vty_out (vty, "%s", VTY_NEWLINE);
7326 }
7327
7328 /* Hello Interval print. */
7329 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7330 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7331 {
7332 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7333 if (params != IF_DEF_PARAMS (ifp))
7334 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7335 vty_out (vty, "%s", VTY_NEWLINE);
7336 }
7337
7338
7339 /* Router Dead Interval print. */
7340 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7341 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7342 {
paulf9ad9372005-10-21 00:45:17 +00007343 vty_out (vty, " ip ospf dead-interval ");
7344
7345 /* fast hello ? */
7346 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7347 vty_out (vty, "minimal hello-multiplier %d",
7348 params->fast_hello);
7349 else
7350 vty_out (vty, "%u", params->v_wait);
7351
paul718e3742002-12-13 20:15:29 +00007352 if (params != IF_DEF_PARAMS (ifp))
7353 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7354 vty_out (vty, "%s", VTY_NEWLINE);
7355 }
7356
7357 /* Router Priority print. */
7358 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7359 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7360 {
7361 vty_out (vty, " ip ospf priority %u", params->priority);
7362 if (params != IF_DEF_PARAMS (ifp))
7363 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7364 vty_out (vty, "%s", VTY_NEWLINE);
7365 }
7366
7367 /* Retransmit Interval print. */
7368 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7369 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7370 {
7371 vty_out (vty, " ip ospf retransmit-interval %u",
7372 params->retransmit_interval);
7373 if (params != IF_DEF_PARAMS (ifp))
7374 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7375 vty_out (vty, "%s", VTY_NEWLINE);
7376 }
7377
7378 /* Transmit Delay print. */
7379 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7380 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7381 {
7382 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7383 if (params != IF_DEF_PARAMS (ifp))
7384 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7385 vty_out (vty, "%s", VTY_NEWLINE);
7386 }
7387
vincentba682532005-09-29 13:52:57 +00007388 /* MTU ignore print. */
7389 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7390 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7391 {
7392 if (params->mtu_ignore == 0)
7393 vty_out (vty, " no ip ospf mtu-ignore");
7394 else
7395 vty_out (vty, " ip ospf mtu-ignore");
7396 if (params != IF_DEF_PARAMS (ifp))
7397 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7398 vty_out (vty, "%s", VTY_NEWLINE);
7399 }
7400
7401
paul718e3742002-12-13 20:15:29 +00007402 while (1)
7403 {
7404 if (rn == NULL)
7405 rn = route_top (IF_OIFS_PARAMS (ifp));
7406 else
7407 rn = route_next (rn);
7408
7409 if (rn == NULL)
7410 break;
7411 params = rn->info;
7412 if (params != NULL)
7413 break;
7414 }
7415 } while (rn);
7416
7417#ifdef HAVE_OPAQUE_LSA
7418 ospf_opaque_config_write_if (vty, ifp);
7419#endif /* HAVE_OPAQUE_LSA */
7420 }
7421
7422 return write;
7423}
7424
paul4dadc292005-05-06 21:37:42 +00007425static int
paul68980082003-03-25 05:07:42 +00007426config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007427{
7428 struct route_node *rn;
7429 u_char buf[INET_ADDRSTRLEN];
7430
7431 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007432 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007433 if (rn->info)
7434 {
7435 struct ospf_network *n = rn->info;
7436
7437 memset (buf, 0, INET_ADDRSTRLEN);
7438
7439 /* Create Area ID string by specified Area ID format. */
7440 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007441 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007442 else
hassoc9e52be2004-09-26 16:09:34 +00007443 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007444 (unsigned long int) ntohl (n->area_id.s_addr));
7445
7446 /* Network print. */
7447 vty_out (vty, " network %s/%d area %s%s",
7448 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7449 buf, VTY_NEWLINE);
7450 }
7451
7452 return 0;
7453}
7454
paul4dadc292005-05-06 21:37:42 +00007455static int
paul68980082003-03-25 05:07:42 +00007456config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007457{
hasso52dc7ee2004-09-23 19:18:23 +00007458 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007459 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007460 u_char buf[INET_ADDRSTRLEN];
7461
7462 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007463 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007464 {
paul718e3742002-12-13 20:15:29 +00007465 struct route_node *rn1;
7466
hassoc9e52be2004-09-26 16:09:34 +00007467 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007468
7469 if (area->auth_type != OSPF_AUTH_NULL)
7470 {
7471 if (area->auth_type == OSPF_AUTH_SIMPLE)
7472 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7473 else
7474 vty_out (vty, " area %s authentication message-digest%s",
7475 buf, VTY_NEWLINE);
7476 }
7477
7478 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7479 vty_out (vty, " area %s shortcut %s%s", buf,
7480 ospf_shortcut_mode_str[area->shortcut_configured],
7481 VTY_NEWLINE);
7482
7483 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007484 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007485 )
7486 {
paulb0a053b2003-06-22 09:04:47 +00007487 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007488 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007489 else if (area->external_routing == OSPF_AREA_NSSA)
7490 {
7491 vty_out (vty, " area %s nssa", buf);
7492 switch (area->NSSATranslatorRole)
7493 {
7494 case OSPF_NSSA_ROLE_NEVER:
7495 vty_out (vty, " translate-never");
7496 break;
7497 case OSPF_NSSA_ROLE_ALWAYS:
7498 vty_out (vty, " translate-always");
7499 break;
7500 case OSPF_NSSA_ROLE_CANDIDATE:
7501 default:
7502 vty_out (vty, " translate-candidate");
7503 }
7504 }
paul718e3742002-12-13 20:15:29 +00007505
7506 if (area->no_summary)
7507 vty_out (vty, " no-summary");
7508
7509 vty_out (vty, "%s", VTY_NEWLINE);
7510
7511 if (area->default_cost != 1)
7512 vty_out (vty, " area %s default-cost %d%s", buf,
7513 area->default_cost, VTY_NEWLINE);
7514 }
7515
7516 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7517 if (rn1->info)
7518 {
7519 struct ospf_area_range *range = rn1->info;
7520
7521 vty_out (vty, " area %s range %s/%d", buf,
7522 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7523
paul6c835672004-10-11 11:00:30 +00007524 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007525 vty_out (vty, " cost %d", range->cost_config);
7526
7527 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7528 vty_out (vty, " not-advertise");
7529
7530 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7531 vty_out (vty, " substitute %s/%d",
7532 inet_ntoa (range->subst_addr), range->subst_masklen);
7533
7534 vty_out (vty, "%s", VTY_NEWLINE);
7535 }
7536
7537 if (EXPORT_NAME (area))
7538 vty_out (vty, " area %s export-list %s%s", buf,
7539 EXPORT_NAME (area), VTY_NEWLINE);
7540
7541 if (IMPORT_NAME (area))
7542 vty_out (vty, " area %s import-list %s%s", buf,
7543 IMPORT_NAME (area), VTY_NEWLINE);
7544
7545 if (PREFIX_NAME_IN (area))
7546 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7547 PREFIX_NAME_IN (area), VTY_NEWLINE);
7548
7549 if (PREFIX_NAME_OUT (area))
7550 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7551 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7552 }
7553
7554 return 0;
7555}
7556
paul4dadc292005-05-06 21:37:42 +00007557static int
paul68980082003-03-25 05:07:42 +00007558config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007559{
7560 struct ospf_nbr_nbma *nbr_nbma;
7561 struct route_node *rn;
7562
7563 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007564 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007565 if ((nbr_nbma = rn->info))
7566 {
7567 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7568
7569 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7570 vty_out (vty, " priority %d", nbr_nbma->priority);
7571
7572 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7573 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7574
7575 vty_out (vty, "%s", VTY_NEWLINE);
7576 }
7577
7578 return 0;
7579}
7580
paul4dadc292005-05-06 21:37:42 +00007581static int
paul68980082003-03-25 05:07:42 +00007582config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007583{
hasso52dc7ee2004-09-23 19:18:23 +00007584 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007585 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007586 u_char buf[INET_ADDRSTRLEN];
7587
7588 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007589 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007590 {
hasso52dc7ee2004-09-23 19:18:23 +00007591 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007592 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007593 struct ospf_interface *oi;
7594
7595 if (vl_data != NULL)
7596 {
7597 memset (buf, 0, INET_ADDRSTRLEN);
7598
7599 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007600 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007601 else
hassoc9e52be2004-09-26 16:09:34 +00007602 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007603 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7604 oi = vl_data->vl_oi;
7605
7606 /* timers */
7607 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7608 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7609 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7610 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7611 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7612 buf,
7613 inet_ntoa (vl_data->vl_peer),
7614 OSPF_IF_PARAM (oi, v_hello),
7615 OSPF_IF_PARAM (oi, retransmit_interval),
7616 OSPF_IF_PARAM (oi, transmit_delay),
7617 OSPF_IF_PARAM (oi, v_wait),
7618 VTY_NEWLINE);
7619 else
7620 vty_out (vty, " area %s virtual-link %s%s", buf,
7621 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7622 /* Auth key */
7623 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7624 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7625 buf,
7626 inet_ntoa (vl_data->vl_peer),
7627 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7628 VTY_NEWLINE);
7629 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007630 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7631 n2, ck))
7632 vty_out (vty, " area %s virtual-link %s"
7633 " message-digest-key %d md5 %s%s",
7634 buf,
7635 inet_ntoa (vl_data->vl_peer),
7636 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007637
7638 }
7639 }
7640
7641 return 0;
7642}
7643
7644
paul4dadc292005-05-06 21:37:42 +00007645static int
paul68980082003-03-25 05:07:42 +00007646config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007647{
7648 int type;
7649
7650 /* redistribute print. */
7651 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7652 if (type != zclient->redist_default && zclient->redist[type])
7653 {
ajsf52d13c2005-10-01 17:38:06 +00007654 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007655 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007656 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007657
paul68980082003-03-25 05:07:42 +00007658 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007659 vty_out (vty, " metric-type 1");
7660
paul020709f2003-04-04 02:44:16 +00007661 if (ROUTEMAP_NAME (ospf, type))
7662 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007663
7664 vty_out (vty, "%s", VTY_NEWLINE);
7665 }
7666
7667 return 0;
7668}
7669
paul4dadc292005-05-06 21:37:42 +00007670static int
paul68980082003-03-25 05:07:42 +00007671config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007672{
paul68980082003-03-25 05:07:42 +00007673 if (ospf->default_metric != -1)
7674 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007675 VTY_NEWLINE);
7676 return 0;
7677}
7678
paul4dadc292005-05-06 21:37:42 +00007679static int
paul68980082003-03-25 05:07:42 +00007680config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007681{
7682 int type;
7683
paul68980082003-03-25 05:07:42 +00007684 if (ospf)
paul718e3742002-12-13 20:15:29 +00007685 {
7686 /* distribute-list print. */
7687 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007688 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007689 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007690 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007691 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007692
7693 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007694 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007695 {
paulc42c1772006-01-10 20:36:49 +00007696 vty_out (vty, " default-information originate");
7697 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7698 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007699
paul68980082003-03-25 05:07:42 +00007700 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007701 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007702 ospf->dmetric[DEFAULT_ROUTE].value);
7703 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007704 vty_out (vty, " metric-type 1");
7705
paul020709f2003-04-04 02:44:16 +00007706 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7707 vty_out (vty, " route-map %s",
7708 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007709
7710 vty_out (vty, "%s", VTY_NEWLINE);
7711 }
7712
7713 }
7714
7715 return 0;
7716}
7717
paul4dadc292005-05-06 21:37:42 +00007718static int
paul68980082003-03-25 05:07:42 +00007719config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007720{
7721 struct route_node *rn;
7722 struct ospf_distance *odistance;
7723
paul68980082003-03-25 05:07:42 +00007724 if (ospf->distance_all)
7725 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007726
paul68980082003-03-25 05:07:42 +00007727 if (ospf->distance_intra
7728 || ospf->distance_inter
7729 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007730 {
7731 vty_out (vty, " distance ospf");
7732
paul68980082003-03-25 05:07:42 +00007733 if (ospf->distance_intra)
7734 vty_out (vty, " intra-area %d", ospf->distance_intra);
7735 if (ospf->distance_inter)
7736 vty_out (vty, " inter-area %d", ospf->distance_inter);
7737 if (ospf->distance_external)
7738 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007739
7740 vty_out (vty, "%s", VTY_NEWLINE);
7741 }
7742
paul68980082003-03-25 05:07:42 +00007743 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007744 if ((odistance = rn->info) != NULL)
7745 {
7746 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7747 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7748 odistance->access_list ? odistance->access_list : "",
7749 VTY_NEWLINE);
7750 }
7751 return 0;
7752}
7753
7754/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007755static int
paul718e3742002-12-13 20:15:29 +00007756ospf_config_write (struct vty *vty)
7757{
paul020709f2003-04-04 02:44:16 +00007758 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007759 struct interface *ifp;
7760 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007761 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007762 int write = 0;
7763
paul020709f2003-04-04 02:44:16 +00007764 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007765 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007766 {
7767 /* `router ospf' print. */
7768 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7769
7770 write++;
7771
paul68980082003-03-25 05:07:42 +00007772 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007773 return write;
7774
7775 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007776 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007777 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007778 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007779
7780 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007781 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007782 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007783 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007784
7785 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007786 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007787 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7788
7789 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007790 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007791 {
7792 vty_out (vty, "! Important: ensure reference bandwidth "
7793 "is consistent across all routers%s", VTY_NEWLINE);
7794 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7795 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7796 }
paul718e3742002-12-13 20:15:29 +00007797
7798 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007799 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007800 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7801 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7802 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007803 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007804 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007805
7806 /* Max-metric router-lsa print */
7807 config_write_stub_router (vty, ospf);
7808
paul718e3742002-12-13 20:15:29 +00007809 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007810 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007811 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007812 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007813
7814 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007815 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007816
7817 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007818 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7819 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7820 vty_out (vty, " passive-interface %s%s",
7821 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007822
paul1eb8ef22005-04-07 07:30:20 +00007823 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7824 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7825 oi->params->passive_interface == OSPF_IF_PASSIVE)
7826 vty_out (vty, " passive-interface %s %s%s",
7827 oi->ifp->name,
7828 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007829
7830 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007831 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007832
7833 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007834 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007835
7836 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007837 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007838
7839 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007840 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007841
7842 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007843 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007844
7845 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007846 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007847
7848 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007849 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007850
7851#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007852 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007853#endif /* HAVE_OPAQUE_LSA */
7854 }
7855
7856 return write;
7857}
7858
7859void
paul4dadc292005-05-06 21:37:42 +00007860ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007861{
7862 /* "show ip ospf" commands. */
7863 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7864 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7865
7866 /* "show ip ospf database" commands. */
7867 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7868 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7869 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7870 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7871 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7872 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7873 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7874 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7875 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7876 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7877 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7878 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7879 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7880 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7881
7882 /* "show ip ospf interface" commands. */
7883 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7884 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7885
7886 /* "show ip ospf neighbor" commands. */
7887 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7888 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7889 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7890 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7891 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7892 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7893 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7894 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7895 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7896 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7897 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7898 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7899 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7900 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7901
7902 /* "show ip ospf route" commands. */
7903 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7904 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007905 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7906 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007907}
7908
7909
7910/* ospfd's interface node. */
7911struct cmd_node interface_node =
7912{
7913 INTERFACE_NODE,
7914 "%s(config-if)# ",
7915 1
7916};
7917
7918/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007919static void
7920ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007921{
7922 /* Install interface node. */
7923 install_node (&interface_node, config_write_interface);
7924
7925 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007926 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007927 install_default (INTERFACE_NODE);
7928
7929 /* "description" commands. */
7930 install_element (INTERFACE_NODE, &interface_desc_cmd);
7931 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7932
7933 /* "ip ospf authentication" commands. */
7934 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7935 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7936 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7937 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7938 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7939 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7940 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7941 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7942 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7943 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7944
7945 /* "ip ospf message-digest-key" commands. */
7946 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7947 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7948 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7949 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7950
7951 /* "ip ospf cost" commands. */
7952 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7953 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7954 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7955 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7956
vincentba682532005-09-29 13:52:57 +00007957 /* "ip ospf mtu-ignore" commands. */
7958 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7959 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7960 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7961 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7962
paul718e3742002-12-13 20:15:29 +00007963 /* "ip ospf dead-interval" commands. */
7964 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7965 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007966 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7967 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007968 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7969 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007970
paul718e3742002-12-13 20:15:29 +00007971 /* "ip ospf hello-interval" commands. */
7972 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7973 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7974 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7975 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7976
7977 /* "ip ospf network" commands. */
7978 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7979 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7980
7981 /* "ip ospf priority" commands. */
7982 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7983 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7984 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7985 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7986
7987 /* "ip ospf retransmit-interval" commands. */
7988 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7989 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7990 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7991 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7992
7993 /* "ip ospf transmit-delay" commands. */
7994 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7995 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7996 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7997 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7998
7999 /* These commands are compatibitliy for previous version. */
8000 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8001 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8002 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8003 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
8004 install_element (INTERFACE_NODE, &ospf_cost_cmd);
8005 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
8006 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8007 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8008 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8009 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8010 install_element (INTERFACE_NODE, &ospf_network_cmd);
8011 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8012 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8013 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8014 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8015 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8016 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8017 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8018}
8019
8020/* Zebra node structure. */
8021struct cmd_node zebra_node =
8022{
8023 ZEBRA_NODE,
8024 "%s(config-router)#",
8025};
8026
paul4dadc292005-05-06 21:37:42 +00008027static void
8028ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008029{
8030 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8031 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8032 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8033 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8034 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8035 install_element (OSPF_NODE,
8036 &ospf_redistribute_source_metric_type_routemap_cmd);
8037 install_element (OSPF_NODE,
8038 &ospf_redistribute_source_type_metric_routemap_cmd);
8039 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8040 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8041 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8042
8043 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8044
8045 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8046 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8047
8048 install_element (OSPF_NODE,
8049 &ospf_default_information_originate_metric_type_cmd);
8050 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8051 install_element (OSPF_NODE,
8052 &ospf_default_information_originate_type_metric_cmd);
8053 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8054 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8055 install_element (OSPF_NODE,
8056 &ospf_default_information_originate_always_metric_type_cmd);
8057 install_element (OSPF_NODE,
8058 &ospf_default_information_originate_always_metric_cmd);
8059 install_element (OSPF_NODE,
8060 &ospf_default_information_originate_always_cmd);
8061 install_element (OSPF_NODE,
8062 &ospf_default_information_originate_always_type_metric_cmd);
8063 install_element (OSPF_NODE,
8064 &ospf_default_information_originate_always_type_cmd);
8065
8066 install_element (OSPF_NODE,
8067 &ospf_default_information_originate_metric_type_routemap_cmd);
8068 install_element (OSPF_NODE,
8069 &ospf_default_information_originate_metric_routemap_cmd);
8070 install_element (OSPF_NODE,
8071 &ospf_default_information_originate_routemap_cmd);
8072 install_element (OSPF_NODE,
8073 &ospf_default_information_originate_type_metric_routemap_cmd);
8074 install_element (OSPF_NODE,
8075 &ospf_default_information_originate_type_routemap_cmd);
8076 install_element (OSPF_NODE,
8077 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8078 install_element (OSPF_NODE,
8079 &ospf_default_information_originate_always_metric_routemap_cmd);
8080 install_element (OSPF_NODE,
8081 &ospf_default_information_originate_always_routemap_cmd);
8082 install_element (OSPF_NODE,
8083 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8084 install_element (OSPF_NODE,
8085 &ospf_default_information_originate_always_type_routemap_cmd);
8086
8087 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8088
8089 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8090 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8091 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8092
8093 install_element (OSPF_NODE, &ospf_distance_cmd);
8094 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8095 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8096 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8097 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8098 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8099 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8100 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8101 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8102 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8103 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8104 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8105 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8106 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8107 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8108 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8109 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8110 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8111#if 0
8112 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8113 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8114 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8115 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8116#endif /* 0 */
8117}
8118
8119struct cmd_node ospf_node =
8120{
8121 OSPF_NODE,
8122 "%s(config-router)# ",
8123 1
8124};
8125
8126
8127/* Install OSPF related vty commands. */
8128void
paul4dadc292005-05-06 21:37:42 +00008129ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008130{
8131 /* Install ospf top node. */
8132 install_node (&ospf_node, ospf_config_write);
8133
8134 /* "router ospf" commands. */
8135 install_element (CONFIG_NODE, &router_ospf_cmd);
8136 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8137
8138 install_default (OSPF_NODE);
8139
8140 /* "ospf router-id" commands. */
8141 install_element (OSPF_NODE, &ospf_router_id_cmd);
8142 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008143 install_element (OSPF_NODE, &router_ospf_id_cmd);
8144 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008145
8146 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008147 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8148 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8149 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8150 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008151
8152 /* "ospf abr-type" commands. */
8153 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8154 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8155
8156 /* "ospf rfc1583-compatible" commands. */
8157 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8158 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8159 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8160 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8161
8162 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008163 install_element (OSPF_NODE, &ospf_network_area_cmd);
8164 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008165
8166 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008167 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8168 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8169 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008170
8171 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008172 install_element (OSPF_NODE, &ospf_area_range_cmd);
8173 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8174 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8175 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8176 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8177 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8178 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8179 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8180 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8181 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8182 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008183
8184 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008185 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8186 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008187
paula2c62832003-04-23 17:01:31 +00008188 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8189 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008190
paula2c62832003-04-23 17:01:31 +00008191 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8192 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008193
paula2c62832003-04-23 17:01:31 +00008194 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8195 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008196
paula2c62832003-04-23 17:01:31 +00008197 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8198 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008199
paula2c62832003-04-23 17:01:31 +00008200 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8201 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8202 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008203
paula2c62832003-04-23 17:01:31 +00008204 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8205 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008206
paula2c62832003-04-23 17:01:31 +00008207 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8208 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008209
paula2c62832003-04-23 17:01:31 +00008210 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8211 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8212 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008213
paula2c62832003-04-23 17:01:31 +00008214 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8215 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8216 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008217
8218 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008219 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8220 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8221 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8222 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008223
paul718e3742002-12-13 20:15:29 +00008224 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008225 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8226 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8227 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8228 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8229 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8230 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008231
paula2c62832003-04-23 17:01:31 +00008232 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8233 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008234
paula2c62832003-04-23 17:01:31 +00008235 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8236 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008237
paula2c62832003-04-23 17:01:31 +00008238 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8239 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008240
paula2c62832003-04-23 17:01:31 +00008241 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8242 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008243
paula2c62832003-04-23 17:01:31 +00008244 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8245 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008246
8247 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008248 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8249 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008250 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8251 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8252
paul88d6cf32005-10-29 12:50:09 +00008253 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008254 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8255 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8256 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008257
paul88d6cf32005-10-29 12:50:09 +00008258 /* max-metric commands */
8259 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8260 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8261 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8262 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8263 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8264 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8265
8266 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008267 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8268 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008269
8270 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008271 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8272 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8273 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8274 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8275 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8276 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8277 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8278 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008279
8280 /* Init interface related vty commands. */
8281 ospf_vty_if_init ();
8282
8283 /* Init zebra related vty commands. */
8284 ospf_vty_zebra_init ();
8285}