blob: 10580ab7ca19e546d6d1a663bcef9e41cf04356d [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* OSPF VTY interface.
vincentba682532005-09-29 13:52:57 +00002 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
paul718e3742002-12-13 20:15:29 +00003 * Copyright (C) 2000 Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23#include <zebra.h>
24
25#include "memory.h"
26#include "thread.h"
27#include "prefix.h"
28#include "table.h"
29#include "vty.h"
30#include "command.h"
31#include "plist.h"
32#include "log.h"
33#include "zclient.h"
34
35#include "ospfd/ospfd.h"
36#include "ospfd/ospf_asbr.h"
37#include "ospfd/ospf_lsa.h"
38#include "ospfd/ospf_lsdb.h"
39#include "ospfd/ospf_ism.h"
40#include "ospfd/ospf_interface.h"
41#include "ospfd/ospf_nsm.h"
42#include "ospfd/ospf_neighbor.h"
43#include "ospfd/ospf_flood.h"
44#include "ospfd/ospf_abr.h"
45#include "ospfd/ospf_spf.h"
46#include "ospfd/ospf_route.h"
47#include "ospfd/ospf_zebra.h"
48/*#include "ospfd/ospf_routemap.h" */
49#include "ospfd/ospf_vty.h"
50#include "ospfd/ospf_dump.h"
51
52
hassoeb1ce602004-10-08 08:17:22 +000053const static char *ospf_network_type_str[] =
paul718e3742002-12-13 20:15:29 +000054{
55 "Null",
56 "POINTOPOINT",
57 "BROADCAST",
58 "NBMA",
59 "POINTOMULTIPOINT",
60 "VIRTUALLINK",
61 "LOOPBACK"
62};
63
64
65/* Utility functions. */
paul4dadc292005-05-06 21:37:42 +000066static int
paul6c835672004-10-11 11:00:30 +000067ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
paul718e3742002-12-13 20:15:29 +000068{
69 char *endptr = NULL;
70 unsigned long ret;
71
72 /* match "A.B.C.D". */
73 if (strchr (str, '.') != NULL)
74 {
75 ret = inet_aton (str, area_id);
76 if (!ret)
77 return -1;
78 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
79 }
80 /* match "<0-4294967295>". */
81 else
82 {
83 ret = strtoul (str, &endptr, 10);
84 if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE))
85 return -1;
86
87 area_id->s_addr = htonl (ret);
88 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
89 }
90
91 return 0;
92}
93
94
paul4dadc292005-05-06 21:37:42 +000095static int
paul6c835672004-10-11 11:00:30 +000096str2distribute_source (const char *str, int *source)
paul718e3742002-12-13 20:15:29 +000097{
98 /* Sanity check. */
99 if (str == NULL)
100 return 0;
101
102 if (strncmp (str, "k", 1) == 0)
103 *source = ZEBRA_ROUTE_KERNEL;
104 else if (strncmp (str, "c", 1) == 0)
105 *source = ZEBRA_ROUTE_CONNECT;
106 else if (strncmp (str, "s", 1) == 0)
107 *source = ZEBRA_ROUTE_STATIC;
108 else if (strncmp (str, "r", 1) == 0)
109 *source = ZEBRA_ROUTE_RIP;
110 else if (strncmp (str, "b", 1) == 0)
111 *source = ZEBRA_ROUTE_BGP;
112 else
113 return 0;
114
115 return 1;
116}
117
paul4dadc292005-05-06 21:37:42 +0000118static int
paul6c835672004-10-11 11:00:30 +0000119str2metric (const char *str, int *metric)
paul718e3742002-12-13 20:15:29 +0000120{
121 /* Sanity check. */
122 if (str == NULL)
123 return 0;
124
125 *metric = strtol (str, NULL, 10);
126 if (*metric < 0 && *metric > 16777214)
127 {
128 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
129 return 0;
130 }
131
132 return 1;
133}
134
paul4dadc292005-05-06 21:37:42 +0000135static int
paul6c835672004-10-11 11:00:30 +0000136str2metric_type (const char *str, int *metric_type)
paul718e3742002-12-13 20:15:29 +0000137{
138 /* Sanity check. */
139 if (str == NULL)
140 return 0;
141
142 if (strncmp (str, "1", 1) == 0)
143 *metric_type = EXTERNAL_METRIC_TYPE_1;
144 else if (strncmp (str, "2", 1) == 0)
145 *metric_type = EXTERNAL_METRIC_TYPE_2;
146 else
147 return 0;
148
149 return 1;
150}
151
152int
153ospf_oi_count (struct interface *ifp)
154{
155 struct route_node *rn;
156 int i = 0;
157
158 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
159 if (rn->info)
160 i++;
161
162 return i;
163}
164
165
166DEFUN (router_ospf,
167 router_ospf_cmd,
168 "router ospf",
169 "Enable a routing process\n"
170 "Start OSPF configuration\n")
171{
172 vty->node = OSPF_NODE;
173 vty->index = ospf_get ();
174
175 return CMD_SUCCESS;
176}
177
178DEFUN (no_router_ospf,
179 no_router_ospf_cmd,
180 "no router ospf",
181 NO_STR
182 "Enable a routing process\n"
183 "Start OSPF configuration\n")
184{
paul020709f2003-04-04 02:44:16 +0000185 struct ospf *ospf;
186
187 ospf = ospf_lookup ();
188 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000189 {
paul020709f2003-04-04 02:44:16 +0000190 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000191 return CMD_WARNING;
192 }
193
paul020709f2003-04-04 02:44:16 +0000194 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000195
196 return CMD_SUCCESS;
197}
198
199DEFUN (ospf_router_id,
200 ospf_router_id_cmd,
201 "ospf router-id A.B.C.D",
202 "OSPF specific commands\n"
203 "router-id for the OSPF process\n"
204 "OSPF router-id in IP address format\n")
205{
paul68980082003-03-25 05:07:42 +0000206 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000207 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000208 int ret;
paul718e3742002-12-13 20:15:29 +0000209
210 ret = inet_aton (argv[0], &router_id);
211 if (!ret)
212 {
213 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
214 return CMD_WARNING;
215 }
216
paul68980082003-03-25 05:07:42 +0000217 ospf->router_id_static = router_id;
paulb29800a2005-11-20 14:50:45 +0000218
219 ospf_router_id_update (ospf);
220
paul718e3742002-12-13 20:15:29 +0000221 return CMD_SUCCESS;
222}
223
224ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000225 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000226 "router-id A.B.C.D",
227 "router-id for the OSPF process\n"
228 "OSPF router-id in IP address format\n")
229
230DEFUN (no_ospf_router_id,
231 no_ospf_router_id_cmd,
232 "no ospf router-id",
233 NO_STR
234 "OSPF specific commands\n"
235 "router-id for the OSPF process\n")
236{
paul68980082003-03-25 05:07:42 +0000237 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000238
paul68980082003-03-25 05:07:42 +0000239 ospf->router_id_static.s_addr = 0;
240
241 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000242
243 return CMD_SUCCESS;
244}
245
246ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000247 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000248 "no router-id",
249 NO_STR
250 "router-id for the OSPF process\n")
251
paula2c62832003-04-23 17:01:31 +0000252DEFUN (ospf_passive_interface,
253 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000254 "passive-interface IFNAME A.B.C.D",
255 "Suppress routing updates on an interface\n"
256 "Interface's name\n")
257{
258 struct interface *ifp;
259 struct in_addr addr;
260 int ret;
261 struct ospf_if_params *params;
ajsba6454e2005-02-08 15:37:30 +0000262 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000263
264 ifp = if_lookup_by_name (argv[0]);
265
266 if (ifp == NULL)
267 {
268 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
269 return CMD_WARNING;
270 }
271
272 params = IF_DEF_PARAMS (ifp);
273
274 if (argc == 2)
275 {
276 ret = inet_aton(argv[1], &addr);
277 if (!ret)
278 {
279 vty_out (vty, "Please specify interface address by A.B.C.D%s",
280 VTY_NEWLINE);
281 return CMD_WARNING;
282 }
283
284 params = ospf_get_if_params (ifp, addr);
285 ospf_if_update_params (ifp, addr);
286 }
287
288 SET_IF_PARAM (params, passive_interface);
289 params->passive_interface = OSPF_IF_PASSIVE;
ajsba6454e2005-02-08 15:37:30 +0000290
291 /* XXX We should call ospf_if_set_multicast on exactly those
292 * interfaces for which the passive property changed. It is too much
293 * work to determine this set, so we do this for every interface.
294 * This is safe and reasonable because ospf_if_set_multicast uses a
295 * record of joined groups to avoid systems calls if the desired
296 * memberships match the current memership.
297 */
298 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
299 {
300 struct ospf_interface *oi = rn->info;
301
302 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
303 ospf_if_set_multicast(oi);
304 }
305 /*
306 * XXX It is not clear what state transitions the interface needs to
307 * undergo when going from active to passive. Fixing this will
308 * require precise identification of interfaces having such a
309 * transition.
310 */
311
paul718e3742002-12-13 20:15:29 +0000312 return CMD_SUCCESS;
313}
314
paula2c62832003-04-23 17:01:31 +0000315ALIAS (ospf_passive_interface,
316 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000317 "passive-interface IFNAME",
318 "Suppress routing updates on an interface\n"
319 "Interface's name\n")
320
paula2c62832003-04-23 17:01:31 +0000321DEFUN (no_ospf_passive_interface,
322 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000323 "no passive-interface IFNAME A.B.C.D",
324 NO_STR
325 "Allow routing updates on an interface\n"
326 "Interface's name\n")
327{
328 struct interface *ifp;
329 struct in_addr addr;
330 struct ospf_if_params *params;
331 int ret;
ajsba6454e2005-02-08 15:37:30 +0000332 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000333
334 ifp = if_lookup_by_name (argv[0]);
335
336 if (ifp == NULL)
337 {
338 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
339 return CMD_WARNING;
340 }
341
342 params = IF_DEF_PARAMS (ifp);
343
344 if (argc == 2)
345 {
346 ret = inet_aton(argv[1], &addr);
347 if (!ret)
348 {
349 vty_out (vty, "Please specify interface address by A.B.C.D%s",
350 VTY_NEWLINE);
351 return CMD_WARNING;
352 }
353
354 params = ospf_lookup_if_params (ifp, addr);
355 if (params == NULL)
356 return CMD_SUCCESS;
357 }
358
359 UNSET_IF_PARAM (params, passive_interface);
360 params->passive_interface = OSPF_IF_ACTIVE;
361
362 if (params != IF_DEF_PARAMS (ifp))
363 {
364 ospf_free_if_params (ifp, addr);
365 ospf_if_update_params (ifp, addr);
366 }
ajsba6454e2005-02-08 15:37:30 +0000367
368 /* XXX We should call ospf_if_set_multicast on exactly those
369 * interfaces for which the passive property changed. It is too much
370 * work to determine this set, so we do this for every interface.
371 * This is safe and reasonable because ospf_if_set_multicast uses a
372 * record of joined groups to avoid systems calls if the desired
373 * memberships match the current memership.
374 */
375 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
376 {
377 struct ospf_interface *oi = rn->info;
378
379 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
380 ospf_if_set_multicast(oi);
381 }
382
paul718e3742002-12-13 20:15:29 +0000383 return CMD_SUCCESS;
384}
385
paula2c62832003-04-23 17:01:31 +0000386ALIAS (no_ospf_passive_interface,
387 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000388 "no passive-interface IFNAME",
389 NO_STR
390 "Allow routing updates on an interface\n"
391 "Interface's name\n")
392
paula2c62832003-04-23 17:01:31 +0000393DEFUN (ospf_network_area,
394 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000395 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
396 "Enable routing on an IP network\n"
397 "OSPF network prefix\n"
398 "Set the OSPF area ID\n"
399 "OSPF area ID in IP address format\n"
400 "OSPF area ID as a decimal value\n")
401{
402 struct ospf *ospf= vty->index;
403 struct prefix_ipv4 p;
404 struct in_addr area_id;
405 int ret, format;
406
407 /* Get network prefix and Area ID. */
408 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
409 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
410
411 ret = ospf_network_set (ospf, &p, area_id);
412 if (ret == 0)
413 {
414 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
415 return CMD_WARNING;
416 }
417
418 return CMD_SUCCESS;
419}
420
paula2c62832003-04-23 17:01:31 +0000421DEFUN (no_ospf_network_area,
422 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000423 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
424 NO_STR
425 "Enable routing on an IP network\n"
426 "OSPF network prefix\n"
427 "Set the OSPF area ID\n"
428 "OSPF area ID in IP address format\n"
429 "OSPF area ID as a decimal value\n")
430{
431 struct ospf *ospf = (struct ospf *) vty->index;
432 struct prefix_ipv4 p;
433 struct in_addr area_id;
434 int ret, format;
435
436 /* Get network prefix and Area ID. */
437 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
438 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
439
440 ret = ospf_network_unset (ospf, &p, area_id);
441 if (ret == 0)
442 {
443 vty_out (vty, "Can't find specified network area configuration.%s",
444 VTY_NEWLINE);
445 return CMD_WARNING;
446 }
447
448 return CMD_SUCCESS;
449}
450
451
paula2c62832003-04-23 17:01:31 +0000452DEFUN (ospf_area_range,
453 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000454 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
455 "OSPF area parameters\n"
456 "OSPF area ID in IP address format\n"
457 "OSPF area ID as a decimal value\n"
458 "Summarize routes matching address/mask (border routers only)\n"
459 "Area range prefix\n")
460{
461 struct ospf *ospf = vty->index;
462 struct prefix_ipv4 p;
463 struct in_addr area_id;
464 int format;
465 u_int32_t cost;
466
467 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
468 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
469
470 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
471 if (argc > 2)
472 {
paul4dadc292005-05-06 21:37:42 +0000473 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000474 ospf_area_range_cost_set (ospf, area_id, &p, cost);
475 }
476
477 return CMD_SUCCESS;
478}
479
paula2c62832003-04-23 17:01:31 +0000480ALIAS (ospf_area_range,
481 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000482 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
483 "OSPF area parameters\n"
484 "OSPF area ID in IP address format\n"
485 "OSPF area ID as a decimal value\n"
486 "OSPF area range for route advertise (default)\n"
487 "Area range prefix\n"
488 "Advertise this range (default)\n")
489
paula2c62832003-04-23 17:01:31 +0000490ALIAS (ospf_area_range,
491 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000492 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
493 "OSPF area parameters\n"
494 "OSPF area ID in IP address format\n"
495 "OSPF area ID as a decimal value\n"
496 "Summarize routes matching address/mask (border routers only)\n"
497 "Area range prefix\n"
498 "User specified metric for this range\n"
499 "Advertised metric for this range\n")
500
paula2c62832003-04-23 17:01:31 +0000501ALIAS (ospf_area_range,
502 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000503 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
504 "OSPF area parameters\n"
505 "OSPF area ID in IP address format\n"
506 "OSPF area ID as a decimal value\n"
507 "Summarize routes matching address/mask (border routers only)\n"
508 "Area range prefix\n"
509 "Advertise this range (default)\n"
510 "User specified metric for this range\n"
511 "Advertised metric for this range\n")
512
paula2c62832003-04-23 17:01:31 +0000513DEFUN (ospf_area_range_not_advertise,
514 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000515 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
516 "OSPF area parameters\n"
517 "OSPF area ID in IP address format\n"
518 "OSPF area ID as a decimal value\n"
519 "Summarize routes matching address/mask (border routers only)\n"
520 "Area range prefix\n"
521 "DoNotAdvertise this range\n")
522{
523 struct ospf *ospf = vty->index;
524 struct prefix_ipv4 p;
525 struct in_addr area_id;
526 int format;
527
528 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
529 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
530
531 ospf_area_range_set (ospf, area_id, &p, 0);
532
533 return CMD_SUCCESS;
534}
535
paula2c62832003-04-23 17:01:31 +0000536DEFUN (no_ospf_area_range,
537 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000538 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
539 NO_STR
540 "OSPF area parameters\n"
541 "OSPF area ID in IP address format\n"
542 "OSPF area ID as a decimal value\n"
543 "Summarize routes matching address/mask (border routers only)\n"
544 "Area range prefix\n")
545{
546 struct ospf *ospf = vty->index;
547 struct prefix_ipv4 p;
548 struct in_addr area_id;
549 int format;
550
551 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
552 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
553
554 ospf_area_range_unset (ospf, area_id, &p);
555
556 return CMD_SUCCESS;
557}
558
paula2c62832003-04-23 17:01:31 +0000559ALIAS (no_ospf_area_range,
560 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000561 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
562 NO_STR
563 "OSPF area parameters\n"
564 "OSPF area ID in IP address format\n"
565 "OSPF area ID as a decimal value\n"
566 "Summarize routes matching address/mask (border routers only)\n"
567 "Area range prefix\n"
568 "Advertise this range (default)\n"
569 "DoNotAdvertise this range\n")
570
paula2c62832003-04-23 17:01:31 +0000571ALIAS (no_ospf_area_range,
572 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000573 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
574 NO_STR
575 "OSPF area parameters\n"
576 "OSPF area ID in IP address format\n"
577 "OSPF area ID as a decimal value\n"
578 "Summarize routes matching address/mask (border routers only)\n"
579 "Area range prefix\n"
580 "User specified metric for this range\n"
581 "Advertised metric for this range\n")
582
paula2c62832003-04-23 17:01:31 +0000583ALIAS (no_ospf_area_range,
584 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000585 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
586 NO_STR
587 "OSPF area parameters\n"
588 "OSPF area ID in IP address format\n"
589 "OSPF area ID as a decimal value\n"
590 "Summarize routes matching address/mask (border routers only)\n"
591 "Area range prefix\n"
592 "Advertise this range (default)\n"
593 "User specified metric for this range\n"
594 "Advertised metric for this range\n")
595
paula2c62832003-04-23 17:01:31 +0000596DEFUN (ospf_area_range_substitute,
597 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000598 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
599 "OSPF area parameters\n"
600 "OSPF area ID in IP address format\n"
601 "OSPF area ID as a decimal value\n"
602 "Summarize routes matching address/mask (border routers only)\n"
603 "Area range prefix\n"
604 "Announce area range as another prefix\n"
605 "Network prefix to be announced instead of range\n")
606{
607 struct ospf *ospf = vty->index;
608 struct prefix_ipv4 p, s;
609 struct in_addr area_id;
610 int format;
611
612 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
613 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
614 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
615
616 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
617
618 return CMD_SUCCESS;
619}
620
paula2c62832003-04-23 17:01:31 +0000621DEFUN (no_ospf_area_range_substitute,
622 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000623 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
624 NO_STR
625 "OSPF area parameters\n"
626 "OSPF area ID in IP address format\n"
627 "OSPF area ID as a decimal value\n"
628 "Summarize routes matching address/mask (border routers only)\n"
629 "Area range prefix\n"
630 "Announce area range as another prefix\n"
631 "Network prefix to be announced instead of range\n")
632{
633 struct ospf *ospf = vty->index;
634 struct prefix_ipv4 p, s;
635 struct in_addr area_id;
636 int format;
637
638 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
639 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
640 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
641
642 ospf_area_range_substitute_unset (ospf, area_id, &p);
643
644 return CMD_SUCCESS;
645}
646
647
648/* Command Handler Logic in VLink stuff is delicate!!
649
650 ALTER AT YOUR OWN RISK!!!!
651
652 Various dummy values are used to represent 'NoChange' state for
653 VLink configuration NOT being changed by a VLink command, and
654 special syntax is used within the command strings so that the
655 typed in command verbs can be seen in the configuration command
656 bacckend handler. This is to drastically reduce the verbeage
657 required to coe up with a reasonably compatible Cisco VLink command
658
659 - Matthew Grant <grantma@anathoth.gen.nz>
660 Wed, 21 Feb 2001 15:13:52 +1300
661 */
662
663
664/* Configuration data for virtual links
665 */
666struct ospf_vl_config_data {
667 struct vty *vty; /* vty stuff */
668 struct in_addr area_id; /* area ID from command line */
669 int format; /* command line area ID format */
670 struct in_addr vl_peer; /* command line vl_peer */
671 int auth_type; /* Authehntication type, if given */
672 char *auth_key; /* simple password if present */
673 int crypto_key_id; /* Cryptographic key ID */
674 char *md5_key; /* MD5 authentication key */
675 int hello_interval; /* Obvious what these are... */
676 int retransmit_interval;
677 int transmit_delay;
678 int dead_interval;
679};
680
paul4dadc292005-05-06 21:37:42 +0000681static void
paul718e3742002-12-13 20:15:29 +0000682ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
683 struct vty *vty)
684{
685 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
686 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
687 vl_config->vty = vty;
688}
689
paul4dadc292005-05-06 21:37:42 +0000690static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000691ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000692{
693 struct ospf_area *area;
694 struct ospf_vl_data *vl_data;
695 struct vty *vty;
696 struct in_addr area_id;
697
698 vty = vl_config->vty;
699 area_id = vl_config->area_id;
700
701 if (area_id.s_addr == OSPF_AREA_BACKBONE)
702 {
703 vty_out (vty,
704 "Configuring VLs over the backbone is not allowed%s",
705 VTY_NEWLINE);
706 return NULL;
707 }
paul68980082003-03-25 05:07:42 +0000708 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000709
710 if (area->external_routing != OSPF_AREA_DEFAULT)
711 {
712 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
713 vty_out (vty, "Area %s is %s%s",
714 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000715 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000716 VTY_NEWLINE);
717 else
718 vty_out (vty, "Area %ld is %s%s",
719 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000720 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000721 VTY_NEWLINE);
722 return NULL;
723 }
724
Paul Jakma9c27ef92006-05-04 07:32:57 +0000725 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
paul718e3742002-12-13 20:15:29 +0000726 {
727 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
728 if (vl_data->vl_oi == NULL)
729 {
paul68980082003-03-25 05:07:42 +0000730 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
731 ospf_vl_add (ospf, vl_data);
732 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000733 }
734 }
735 return vl_data;
736}
737
738
paul4dadc292005-05-06 21:37:42 +0000739static int
paul718e3742002-12-13 20:15:29 +0000740ospf_vl_set_security (struct ospf_vl_data *vl_data,
741 struct ospf_vl_config_data *vl_config)
742{
743 struct crypt_key *ck;
744 struct vty *vty;
745 struct interface *ifp = vl_data->vl_oi->ifp;
746
747 vty = vl_config->vty;
748
749 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
750 {
751 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
752 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
753 }
754
755 if (vl_config->auth_key)
756 {
757 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000758 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000759 OSPF_AUTH_SIMPLE_SIZE);
760 }
761 else if (vl_config->md5_key)
762 {
763 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
764 != NULL)
765 {
766 vty_out (vty, "OSPF: Key %d already exists%s",
767 vl_config->crypto_key_id, VTY_NEWLINE);
768 return CMD_WARNING;
769 }
770 ck = ospf_crypt_key_new ();
771 ck->key_id = vl_config->crypto_key_id;
772 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000773 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000774
775 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
776 }
777 else if (vl_config->crypto_key_id != 0)
778 {
779 /* Delete a key */
780
781 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
782 vl_config->crypto_key_id) == NULL)
783 {
784 vty_out (vty, "OSPF: Key %d does not exist%s",
785 vl_config->crypto_key_id, VTY_NEWLINE);
786 return CMD_WARNING;
787 }
788
789 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
790
791 }
792
793 return CMD_SUCCESS;
794}
795
paul4dadc292005-05-06 21:37:42 +0000796static int
paul718e3742002-12-13 20:15:29 +0000797ospf_vl_set_timers (struct ospf_vl_data *vl_data,
798 struct ospf_vl_config_data *vl_config)
799{
800 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
801 /* Virtual Link data initialised to defaults, so only set
802 if a value given */
803 if (vl_config->hello_interval)
804 {
805 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
806 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
807 }
808
809 if (vl_config->dead_interval)
810 {
811 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
812 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
813 }
814
815 if (vl_config->retransmit_interval)
816 {
817 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
818 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
819 }
820
821 if (vl_config->transmit_delay)
822 {
823 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
824 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
825 }
826
827 return CMD_SUCCESS;
828}
829
830
831
832/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000833static int
paul68980082003-03-25 05:07:42 +0000834ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000835{
836 struct ospf_vl_data *vl_data;
837 int ret;
838
paul68980082003-03-25 05:07:42 +0000839 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000840 if (!vl_data)
841 return CMD_WARNING;
842
843 /* Process this one first as it can have a fatal result, which can
844 only logically occur if the virtual link exists already
845 Thus a command error does not result in a change to the
846 running configuration such as unexpectedly altered timer
847 values etc.*/
848 ret = ospf_vl_set_security (vl_data, vl_config);
849 if (ret != CMD_SUCCESS)
850 return ret;
851
852 /* Set any time based parameters, these area already range checked */
853
854 ret = ospf_vl_set_timers (vl_data, vl_config);
855 if (ret != CMD_SUCCESS)
856 return ret;
857
858 return CMD_SUCCESS;
859
860}
861
862/* This stuff exists to make specifying all the alias commands A LOT simpler
863 */
864#define VLINK_HELPSTR_IPADDR \
865 "OSPF area parameters\n" \
866 "OSPF area ID in IP address format\n" \
867 "OSPF area ID as a decimal value\n" \
868 "Configure a virtual link\n" \
869 "Router ID of the remote ABR\n"
870
871#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
872 "Enable authentication on this virtual link\n" \
873 "dummy string \n"
874
875#define VLINK_HELPSTR_AUTHTYPE_ALL \
876 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
877 "Use null authentication\n" \
878 "Use message-digest authentication\n"
879
880#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
881 "Time between HELLO packets\n" \
882 "Time between retransmitting lost link state advertisements\n" \
883 "Link state transmit delay\n" \
884 "Interval after which a neighbor is declared dead\n"
885
886#define VLINK_HELPSTR_TIME_PARAM \
887 VLINK_HELPSTR_TIME_PARAM_NOSECS \
888 "Seconds\n"
889
890#define VLINK_HELPSTR_AUTH_SIMPLE \
891 "Authentication password (key)\n" \
892 "The OSPF password (key)"
893
894#define VLINK_HELPSTR_AUTH_MD5 \
895 "Message digest authentication password (key)\n" \
896 "dummy string \n" \
897 "Key ID\n" \
898 "Use MD5 algorithm\n" \
899 "The OSPF password (key)"
900
paula2c62832003-04-23 17:01:31 +0000901DEFUN (ospf_area_vlink,
902 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000903 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
904 VLINK_HELPSTR_IPADDR)
905{
paul68980082003-03-25 05:07:42 +0000906 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000907 struct ospf_vl_config_data vl_config;
908 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
909 char md5_key[OSPF_AUTH_MD5_SIZE+1];
910 int i;
911 int ret;
912
913 ospf_vl_config_data_init(&vl_config, vty);
914
915 /* Read off first 2 parameters and check them */
916 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
917 if (ret < 0)
918 {
919 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
920 return CMD_WARNING;
921 }
922
923 ret = inet_aton (argv[1], &vl_config.vl_peer);
924 if (! ret)
925 {
926 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
927 VTY_NEWLINE);
928 return CMD_WARNING;
929 }
930
931 if (argc <=2)
932 {
933 /* Thats all folks! - BUGS B. strikes again!!!*/
934
paul68980082003-03-25 05:07:42 +0000935 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000936 }
937
938 /* Deal with other parameters */
939 for (i=2; i < argc; i++)
940 {
941
942 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
943
944 switch (argv[i][0])
945 {
946
947 case 'a':
948 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
949 {
950 /* authentication-key - this option can occur anywhere on
951 command line. At start of command line
952 must check for authentication option. */
953 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
954 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
955 vl_config.auth_key = auth_key;
956 i++;
957 }
958 else if (strncmp (argv[i], "authentication", 14) == 0)
959 {
960 /* authentication - this option can only occur at start
961 of command line */
962 vl_config.auth_type = OSPF_AUTH_SIMPLE;
963 if ((i+1) < argc)
964 {
965 if (strncmp (argv[i+1], "n", 1) == 0)
966 {
967 /* "authentication null" */
968 vl_config.auth_type = OSPF_AUTH_NULL;
969 i++;
970 }
971 else if (strncmp (argv[i+1], "m", 1) == 0
972 && strcmp (argv[i+1], "message-digest-") != 0)
973 {
974 /* "authentication message-digest" */
975 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
976 i++;
977 }
978 }
979 }
980 break;
981
982 case 'm':
983 /* message-digest-key */
984 i++;
985 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
986 if (vl_config.crypto_key_id < 0)
987 return CMD_WARNING;
988 i++;
989 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
990 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
991 vl_config.md5_key = md5_key;
992 break;
993
994 case 'h':
995 /* Hello interval */
996 i++;
997 vl_config.hello_interval = strtol (argv[i], NULL, 10);
998 if (vl_config.hello_interval < 0)
999 return CMD_WARNING;
1000 break;
1001
1002 case 'r':
1003 /* Retransmit Interval */
1004 i++;
1005 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1006 if (vl_config.retransmit_interval < 0)
1007 return CMD_WARNING;
1008 break;
1009
1010 case 't':
1011 /* Transmit Delay */
1012 i++;
1013 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1014 if (vl_config.transmit_delay < 0)
1015 return CMD_WARNING;
1016 break;
1017
1018 case 'd':
1019 /* Dead Interval */
1020 i++;
1021 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1022 if (vl_config.dead_interval < 0)
1023 return CMD_WARNING;
1024 break;
1025 }
1026 }
1027
1028
1029 /* Action configuration */
1030
paul68980082003-03-25 05:07:42 +00001031 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001032
1033}
1034
paula2c62832003-04-23 17:01:31 +00001035DEFUN (no_ospf_area_vlink,
1036 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001037 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1038 NO_STR
1039 VLINK_HELPSTR_IPADDR)
1040{
paul68980082003-03-25 05:07:42 +00001041 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001042 struct ospf_area *area;
1043 struct ospf_vl_config_data vl_config;
1044 struct ospf_vl_data *vl_data = NULL;
1045 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1046 int i;
1047 int ret, format;
1048
1049 ospf_vl_config_data_init(&vl_config, vty);
1050
1051 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1052 if (ret < 0)
1053 {
1054 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1055 return CMD_WARNING;
1056 }
1057
paul68980082003-03-25 05:07:42 +00001058 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001059 if (!area)
1060 {
1061 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1062 return CMD_WARNING;
1063 }
1064
1065 ret = inet_aton (argv[1], &vl_config.vl_peer);
1066 if (! ret)
1067 {
1068 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1069 VTY_NEWLINE);
1070 return CMD_WARNING;
1071 }
1072
1073 if (argc <=2)
1074 {
1075 /* Basic VLink no command */
1076 /* Thats all folks! - BUGS B. strikes again!!!*/
Paul Jakma9c27ef92006-05-04 07:32:57 +00001077 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001078 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001079
paul68980082003-03-25 05:07:42 +00001080 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001081
1082 return CMD_SUCCESS;
1083 }
1084
1085 /* If we are down here, we are reseting parameters */
1086
1087 /* Deal with other parameters */
1088 for (i=2; i < argc; i++)
1089 {
paul718e3742002-12-13 20:15:29 +00001090 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1091
1092 switch (argv[i][0])
1093 {
1094
1095 case 'a':
1096 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1097 {
1098 /* authentication-key - this option can occur anywhere on
1099 command line. At start of command line
1100 must check for authentication option. */
1101 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1102 vl_config.auth_key = auth_key;
1103 }
1104 else if (strncmp (argv[i], "authentication", 14) == 0)
1105 {
1106 /* authentication - this option can only occur at start
1107 of command line */
1108 vl_config.auth_type = OSPF_AUTH_NOTSET;
1109 }
1110 break;
1111
1112 case 'm':
1113 /* message-digest-key */
1114 /* Delete one key */
1115 i++;
1116 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1117 if (vl_config.crypto_key_id < 0)
1118 return CMD_WARNING;
1119 vl_config.md5_key = NULL;
1120 break;
1121
1122 case 'h':
1123 /* Hello interval */
1124 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1125 break;
1126
1127 case 'r':
1128 /* Retransmit Interval */
1129 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1130 break;
1131
1132 case 't':
1133 /* Transmit Delay */
1134 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1135 break;
1136
1137 case 'd':
1138 /* Dead Interval */
1139 i++;
1140 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1141 break;
1142 }
1143 }
1144
1145
1146 /* Action configuration */
1147
paul68980082003-03-25 05:07:42 +00001148 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001149}
1150
paula2c62832003-04-23 17:01:31 +00001151ALIAS (ospf_area_vlink,
1152 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001153 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1154 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1155 VLINK_HELPSTR_IPADDR
1156 VLINK_HELPSTR_TIME_PARAM)
1157
paula2c62832003-04-23 17:01:31 +00001158ALIAS (no_ospf_area_vlink,
1159 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001160 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1161 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1162 NO_STR
1163 VLINK_HELPSTR_IPADDR
1164 VLINK_HELPSTR_TIME_PARAM)
1165
paula2c62832003-04-23 17:01:31 +00001166ALIAS (ospf_area_vlink,
1167 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001168 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1169 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1170 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1171 VLINK_HELPSTR_IPADDR
1172 VLINK_HELPSTR_TIME_PARAM
1173 VLINK_HELPSTR_TIME_PARAM)
1174
paula2c62832003-04-23 17:01:31 +00001175ALIAS (no_ospf_area_vlink,
1176 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001177 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1178 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1179 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1180 NO_STR
1181 VLINK_HELPSTR_IPADDR
1182 VLINK_HELPSTR_TIME_PARAM
1183 VLINK_HELPSTR_TIME_PARAM)
1184
paula2c62832003-04-23 17:01:31 +00001185ALIAS (ospf_area_vlink,
1186 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001187 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1188 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1189 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1190 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1191 VLINK_HELPSTR_IPADDR
1192 VLINK_HELPSTR_TIME_PARAM
1193 VLINK_HELPSTR_TIME_PARAM
1194 VLINK_HELPSTR_TIME_PARAM)
1195
paula2c62832003-04-23 17:01:31 +00001196ALIAS (no_ospf_area_vlink,
1197 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001198 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1199 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1200 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1201 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1202 NO_STR
1203 VLINK_HELPSTR_IPADDR
1204 VLINK_HELPSTR_TIME_PARAM
1205 VLINK_HELPSTR_TIME_PARAM
1206 VLINK_HELPSTR_TIME_PARAM)
1207
paula2c62832003-04-23 17:01:31 +00001208ALIAS (ospf_area_vlink,
1209 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001210 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1211 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1212 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1213 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1214 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1215 VLINK_HELPSTR_IPADDR
1216 VLINK_HELPSTR_TIME_PARAM
1217 VLINK_HELPSTR_TIME_PARAM
1218 VLINK_HELPSTR_TIME_PARAM
1219 VLINK_HELPSTR_TIME_PARAM)
1220
paula2c62832003-04-23 17:01:31 +00001221ALIAS (no_ospf_area_vlink,
1222 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001223 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1224 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1225 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1226 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1227 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1228 NO_STR
1229 VLINK_HELPSTR_IPADDR
1230 VLINK_HELPSTR_TIME_PARAM
1231 VLINK_HELPSTR_TIME_PARAM
1232 VLINK_HELPSTR_TIME_PARAM
1233 VLINK_HELPSTR_TIME_PARAM)
1234
paula2c62832003-04-23 17:01:31 +00001235ALIAS (ospf_area_vlink,
1236 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001237 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1238 "(authentication|) (message-digest|null)",
1239 VLINK_HELPSTR_IPADDR
1240 VLINK_HELPSTR_AUTHTYPE_ALL)
1241
paula2c62832003-04-23 17:01:31 +00001242ALIAS (ospf_area_vlink,
1243 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001244 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1245 "(authentication|)",
1246 VLINK_HELPSTR_IPADDR
1247 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1248
paula2c62832003-04-23 17:01:31 +00001249ALIAS (no_ospf_area_vlink,
1250 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001251 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1252 "(authentication|)",
1253 NO_STR
1254 VLINK_HELPSTR_IPADDR
1255 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1256
paula2c62832003-04-23 17:01:31 +00001257ALIAS (ospf_area_vlink,
1258 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001259 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1260 "(message-digest-key|) <1-255> md5 KEY",
1261 VLINK_HELPSTR_IPADDR
1262 VLINK_HELPSTR_AUTH_MD5)
1263
paula2c62832003-04-23 17:01:31 +00001264ALIAS (no_ospf_area_vlink,
1265 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001266 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1267 "(message-digest-key|) <1-255>",
1268 NO_STR
1269 VLINK_HELPSTR_IPADDR
1270 VLINK_HELPSTR_AUTH_MD5)
1271
paula2c62832003-04-23 17:01:31 +00001272ALIAS (ospf_area_vlink,
1273 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001274 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1275 "(authentication-key|) AUTH_KEY",
1276 VLINK_HELPSTR_IPADDR
1277 VLINK_HELPSTR_AUTH_SIMPLE)
1278
paula2c62832003-04-23 17:01:31 +00001279ALIAS (no_ospf_area_vlink,
1280 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001281 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1282 "(authentication-key|)",
1283 NO_STR
1284 VLINK_HELPSTR_IPADDR
1285 VLINK_HELPSTR_AUTH_SIMPLE)
1286
paula2c62832003-04-23 17:01:31 +00001287ALIAS (ospf_area_vlink,
1288 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001289 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1290 "(authentication|) (message-digest|null) "
1291 "(authentication-key|) AUTH_KEY",
1292 VLINK_HELPSTR_IPADDR
1293 VLINK_HELPSTR_AUTHTYPE_ALL
1294 VLINK_HELPSTR_AUTH_SIMPLE)
1295
paula2c62832003-04-23 17:01:31 +00001296ALIAS (ospf_area_vlink,
1297 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001298 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1299 "(authentication|) "
1300 "(authentication-key|) AUTH_KEY",
1301 VLINK_HELPSTR_IPADDR
1302 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1303 VLINK_HELPSTR_AUTH_SIMPLE)
1304
paula2c62832003-04-23 17:01:31 +00001305ALIAS (no_ospf_area_vlink,
1306 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001307 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1308 "(authentication|) "
1309 "(authentication-key|)",
1310 NO_STR
1311 VLINK_HELPSTR_IPADDR
1312 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1313 VLINK_HELPSTR_AUTH_SIMPLE)
1314
paula2c62832003-04-23 17:01:31 +00001315ALIAS (ospf_area_vlink,
1316 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001317 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1318 "(authentication|) (message-digest|null) "
1319 "(message-digest-key|) <1-255> md5 KEY",
1320 VLINK_HELPSTR_IPADDR
1321 VLINK_HELPSTR_AUTHTYPE_ALL
1322 VLINK_HELPSTR_AUTH_MD5)
1323
paula2c62832003-04-23 17:01:31 +00001324ALIAS (ospf_area_vlink,
1325 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001326 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1327 "(authentication|) "
1328 "(message-digest-key|) <1-255> md5 KEY",
1329 VLINK_HELPSTR_IPADDR
1330 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1331 VLINK_HELPSTR_AUTH_MD5)
1332
paula2c62832003-04-23 17:01:31 +00001333ALIAS (no_ospf_area_vlink,
1334 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001335 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1336 "(authentication|) "
1337 "(message-digest-key|)",
1338 NO_STR
1339 VLINK_HELPSTR_IPADDR
1340 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1341 VLINK_HELPSTR_AUTH_MD5)
1342
1343
paula2c62832003-04-23 17:01:31 +00001344DEFUN (ospf_area_shortcut,
1345 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001346 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1347 "OSPF area parameters\n"
1348 "OSPF area ID in IP address format\n"
1349 "OSPF area ID as a decimal value\n"
1350 "Configure the area's shortcutting mode\n"
1351 "Set default shortcutting behavior\n"
1352 "Enable shortcutting through the area\n"
1353 "Disable shortcutting through the area\n")
1354{
paul68980082003-03-25 05:07:42 +00001355 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001356 struct ospf_area *area;
1357 struct in_addr area_id;
1358 int mode;
1359 int format;
1360
1361 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1362
paul68980082003-03-25 05:07:42 +00001363 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001364
1365 if (strncmp (argv[1], "de", 2) == 0)
1366 mode = OSPF_SHORTCUT_DEFAULT;
1367 else if (strncmp (argv[1], "di", 2) == 0)
1368 mode = OSPF_SHORTCUT_DISABLE;
1369 else if (strncmp (argv[1], "e", 1) == 0)
1370 mode = OSPF_SHORTCUT_ENABLE;
1371 else
1372 return CMD_WARNING;
1373
paul68980082003-03-25 05:07:42 +00001374 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001375
paul68980082003-03-25 05:07:42 +00001376 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001377 vty_out (vty, "Shortcut area setting will take effect "
1378 "only when the router is configured as Shortcut ABR%s",
1379 VTY_NEWLINE);
1380
1381 return CMD_SUCCESS;
1382}
1383
paula2c62832003-04-23 17:01:31 +00001384DEFUN (no_ospf_area_shortcut,
1385 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001386 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1387 NO_STR
1388 "OSPF area parameters\n"
1389 "OSPF area ID in IP address format\n"
1390 "OSPF area ID as a decimal value\n"
1391 "Deconfigure the area's shortcutting mode\n"
1392 "Deconfigure enabled shortcutting through the area\n"
1393 "Deconfigure disabled shortcutting through the area\n")
1394{
paul68980082003-03-25 05:07:42 +00001395 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001396 struct ospf_area *area;
1397 struct in_addr area_id;
1398 int format;
1399
1400 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1401
paul68980082003-03-25 05:07:42 +00001402 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001403 if (!area)
1404 return CMD_SUCCESS;
1405
paul68980082003-03-25 05:07:42 +00001406 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001407
1408 return CMD_SUCCESS;
1409}
1410
1411
paula2c62832003-04-23 17:01:31 +00001412DEFUN (ospf_area_stub,
1413 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001414 "area (A.B.C.D|<0-4294967295>) stub",
1415 "OSPF area parameters\n"
1416 "OSPF area ID in IP address format\n"
1417 "OSPF area ID as a decimal value\n"
1418 "Configure OSPF area as stub\n")
1419{
1420 struct ospf *ospf = vty->index;
1421 struct in_addr area_id;
1422 int ret, format;
1423
1424 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1425
1426 ret = ospf_area_stub_set (ospf, area_id);
1427 if (ret == 0)
1428 {
1429 vty_out (vty, "First deconfigure all virtual link through this area%s",
1430 VTY_NEWLINE);
1431 return CMD_WARNING;
1432 }
1433
1434 ospf_area_no_summary_unset (ospf, area_id);
1435
1436 return CMD_SUCCESS;
1437}
1438
paula2c62832003-04-23 17:01:31 +00001439DEFUN (ospf_area_stub_no_summary,
1440 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001441 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1442 "OSPF stub parameters\n"
1443 "OSPF area ID in IP address format\n"
1444 "OSPF area ID as a decimal value\n"
1445 "Configure OSPF area as stub\n"
1446 "Do not inject inter-area routes into stub\n")
1447{
1448 struct ospf *ospf = vty->index;
1449 struct in_addr area_id;
1450 int ret, format;
1451
1452 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1453
1454 ret = ospf_area_stub_set (ospf, area_id);
1455 if (ret == 0)
1456 {
paulb0a053b2003-06-22 09:04:47 +00001457 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001458 VTY_NEWLINE);
1459 return CMD_WARNING;
1460 }
1461
1462 ospf_area_no_summary_set (ospf, area_id);
1463
1464 return CMD_SUCCESS;
1465}
1466
paula2c62832003-04-23 17:01:31 +00001467DEFUN (no_ospf_area_stub,
1468 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001469 "no area (A.B.C.D|<0-4294967295>) stub",
1470 NO_STR
1471 "OSPF area parameters\n"
1472 "OSPF area ID in IP address format\n"
1473 "OSPF area ID as a decimal value\n"
1474 "Configure OSPF area as stub\n")
1475{
1476 struct ospf *ospf = vty->index;
1477 struct in_addr area_id;
1478 int format;
1479
1480 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1481
1482 ospf_area_stub_unset (ospf, area_id);
1483 ospf_area_no_summary_unset (ospf, area_id);
1484
1485 return CMD_SUCCESS;
1486}
1487
paula2c62832003-04-23 17:01:31 +00001488DEFUN (no_ospf_area_stub_no_summary,
1489 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001490 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1491 NO_STR
1492 "OSPF area parameters\n"
1493 "OSPF area ID in IP address format\n"
1494 "OSPF area ID as a decimal value\n"
1495 "Configure OSPF area as stub\n"
1496 "Do not inject inter-area routes into area\n")
1497{
1498 struct ospf *ospf = vty->index;
1499 struct in_addr area_id;
1500 int format;
1501
1502 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1503 ospf_area_no_summary_unset (ospf, area_id);
1504
1505 return CMD_SUCCESS;
1506}
1507
paul4dadc292005-05-06 21:37:42 +00001508static int
paul6c835672004-10-11 11:00:30 +00001509ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1510 int nosum)
paul718e3742002-12-13 20:15:29 +00001511{
1512 struct ospf *ospf = vty->index;
1513 struct in_addr area_id;
1514 int ret, format;
1515
1516 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1517
1518 ret = ospf_area_nssa_set (ospf, area_id);
1519 if (ret == 0)
1520 {
1521 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1522 VTY_NEWLINE);
1523 return CMD_WARNING;
1524 }
1525
1526 if (argc > 1)
1527 {
1528 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001529 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001530 OSPF_NSSA_ROLE_CANDIDATE);
1531 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001532 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001533 OSPF_NSSA_ROLE_NEVER);
1534 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001535 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001536 OSPF_NSSA_ROLE_ALWAYS);
1537 }
paulb0a053b2003-06-22 09:04:47 +00001538 else
1539 {
1540 ospf_area_nssa_translator_role_set (ospf, area_id,
1541 OSPF_NSSA_ROLE_CANDIDATE);
1542 }
paul718e3742002-12-13 20:15:29 +00001543
paulb0a053b2003-06-22 09:04:47 +00001544 if (nosum)
paul718e3742002-12-13 20:15:29 +00001545 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001546 else
1547 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001548
paulb0a053b2003-06-22 09:04:47 +00001549 ospf_schedule_abr_task (ospf);
1550
paul718e3742002-12-13 20:15:29 +00001551 return CMD_SUCCESS;
1552}
1553
paulb0a053b2003-06-22 09:04:47 +00001554DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001555 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001556 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001557 "OSPF area parameters\n"
1558 "OSPF area ID in IP address format\n"
1559 "OSPF area ID as a decimal value\n"
1560 "Configure OSPF area as nssa\n"
1561 "Configure NSSA-ABR for translate election (default)\n"
1562 "Configure NSSA-ABR to never translate\n"
1563 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001564 "Do not inject inter-area routes into nssa\n")
1565{
1566 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1567}
paul718e3742002-12-13 20:15:29 +00001568
paulb0a053b2003-06-22 09:04:47 +00001569DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001570 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001571 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1572 "OSPF area parameters\n"
1573 "OSPF area ID in IP address format\n"
1574 "OSPF area ID as a decimal value\n"
1575 "Configure OSPF area as nssa\n"
1576 "Configure NSSA-ABR for translate election (default)\n"
1577 "Configure NSSA-ABR to never translate\n"
1578 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001579{
1580 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1581}
1582
1583DEFUN (ospf_area_nssa,
1584 ospf_area_nssa_cmd,
1585 "area (A.B.C.D|<0-4294967295>) nssa",
1586 "OSPF area parameters\n"
1587 "OSPF area ID in IP address format\n"
1588 "OSPF area ID as a decimal value\n"
1589 "Configure OSPF area as nssa\n")
1590{
1591 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1592}
paul718e3742002-12-13 20:15:29 +00001593
paula2c62832003-04-23 17:01:31 +00001594DEFUN (ospf_area_nssa_no_summary,
1595 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001596 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1597 "OSPF area parameters\n"
1598 "OSPF area ID in IP address format\n"
1599 "OSPF area ID as a decimal value\n"
1600 "Configure OSPF area as nssa\n"
1601 "Do not inject inter-area routes into nssa\n")
1602{
paulb0a053b2003-06-22 09:04:47 +00001603 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001604}
1605
paula2c62832003-04-23 17:01:31 +00001606DEFUN (no_ospf_area_nssa,
1607 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001608 "no area (A.B.C.D|<0-4294967295>) nssa",
1609 NO_STR
1610 "OSPF area parameters\n"
1611 "OSPF area ID in IP address format\n"
1612 "OSPF area ID as a decimal value\n"
1613 "Configure OSPF area as nssa\n")
1614{
1615 struct ospf *ospf = vty->index;
1616 struct in_addr area_id;
1617 int format;
1618
1619 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1620
1621 ospf_area_nssa_unset (ospf, area_id);
1622 ospf_area_no_summary_unset (ospf, area_id);
1623
paulb0a053b2003-06-22 09:04:47 +00001624 ospf_schedule_abr_task (ospf);
1625
paul718e3742002-12-13 20:15:29 +00001626 return CMD_SUCCESS;
1627}
1628
paula2c62832003-04-23 17:01:31 +00001629DEFUN (no_ospf_area_nssa_no_summary,
1630 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001631 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1632 NO_STR
1633 "OSPF area parameters\n"
1634 "OSPF area ID in IP address format\n"
1635 "OSPF area ID as a decimal value\n"
1636 "Configure OSPF area as nssa\n"
1637 "Do not inject inter-area routes into nssa\n")
1638{
1639 struct ospf *ospf = vty->index;
1640 struct in_addr area_id;
1641 int format;
1642
1643 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1644 ospf_area_no_summary_unset (ospf, area_id);
1645
1646 return CMD_SUCCESS;
1647}
1648
paula2c62832003-04-23 17:01:31 +00001649DEFUN (ospf_area_default_cost,
1650 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001651 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1652 "OSPF area parameters\n"
1653 "OSPF area ID in IP address format\n"
1654 "OSPF area ID as a decimal value\n"
1655 "Set the summary-default cost of a NSSA or stub area\n"
1656 "Stub's advertised default summary cost\n")
1657{
paul68980082003-03-25 05:07:42 +00001658 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001659 struct ospf_area *area;
1660 struct in_addr area_id;
1661 u_int32_t cost;
1662 int format;
vincentba682532005-09-29 13:52:57 +00001663 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001664
1665 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1666 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1667
paul68980082003-03-25 05:07:42 +00001668 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001669
1670 if (area->external_routing == OSPF_AREA_DEFAULT)
1671 {
1672 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1673 return CMD_WARNING;
1674 }
1675
1676 area->default_cost = cost;
1677
vincentba682532005-09-29 13:52:57 +00001678 p.family = AF_INET;
1679 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1680 p.prefixlen = 0;
1681 if (IS_DEBUG_OSPF_EVENT)
1682 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1683 "announcing 0.0.0.0/0 to area %s",
1684 inet_ntoa (area->area_id));
1685 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1686
paul718e3742002-12-13 20:15:29 +00001687 return CMD_SUCCESS;
1688}
1689
paula2c62832003-04-23 17:01:31 +00001690DEFUN (no_ospf_area_default_cost,
1691 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001692 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1693 NO_STR
1694 "OSPF area parameters\n"
1695 "OSPF area ID in IP address format\n"
1696 "OSPF area ID as a decimal value\n"
1697 "Set the summary-default cost of a NSSA or stub area\n"
1698 "Stub's advertised default summary cost\n")
1699{
paul68980082003-03-25 05:07:42 +00001700 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001701 struct ospf_area *area;
1702 struct in_addr area_id;
1703 u_int32_t cost;
1704 int format;
vincentba682532005-09-29 13:52:57 +00001705 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001706
1707 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1708 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1709
paul68980082003-03-25 05:07:42 +00001710 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001711 if (area == NULL)
1712 return CMD_SUCCESS;
1713
1714 if (area->external_routing == OSPF_AREA_DEFAULT)
1715 {
1716 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1717 return CMD_WARNING;
1718 }
1719
1720 area->default_cost = 1;
1721
vincentba682532005-09-29 13:52:57 +00001722 p.family = AF_INET;
1723 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1724 p.prefixlen = 0;
1725 if (IS_DEBUG_OSPF_EVENT)
1726 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1727 "announcing 0.0.0.0/0 to area %s",
1728 inet_ntoa (area->area_id));
1729 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1730
1731
paul68980082003-03-25 05:07:42 +00001732 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001733
1734 return CMD_SUCCESS;
1735}
1736
paula2c62832003-04-23 17:01:31 +00001737DEFUN (ospf_area_export_list,
1738 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001739 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1740 "OSPF area parameters\n"
1741 "OSPF area ID in IP address format\n"
1742 "OSPF area ID as a decimal value\n"
1743 "Set the filter for networks announced to other areas\n"
1744 "Name of the access-list\n")
1745{
paul68980082003-03-25 05:07:42 +00001746 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001747 struct ospf_area *area;
1748 struct in_addr area_id;
1749 int format;
1750
hasso52930762004-04-19 18:26:53 +00001751 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1752
paul68980082003-03-25 05:07:42 +00001753 area = ospf_area_get (ospf, area_id, format);
1754 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001755
1756 return CMD_SUCCESS;
1757}
1758
paula2c62832003-04-23 17:01:31 +00001759DEFUN (no_ospf_area_export_list,
1760 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001761 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1762 NO_STR
1763 "OSPF area parameters\n"
1764 "OSPF area ID in IP address format\n"
1765 "OSPF area ID as a decimal value\n"
1766 "Unset the filter for networks announced to other areas\n"
1767 "Name of the access-list\n")
1768{
paul68980082003-03-25 05:07:42 +00001769 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001770 struct ospf_area *area;
1771 struct in_addr area_id;
1772 int format;
1773
hasso52930762004-04-19 18:26:53 +00001774 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1775
paul68980082003-03-25 05:07:42 +00001776 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001777 if (area == NULL)
1778 return CMD_SUCCESS;
1779
paul68980082003-03-25 05:07:42 +00001780 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001781
1782 return CMD_SUCCESS;
1783}
1784
1785
paula2c62832003-04-23 17:01:31 +00001786DEFUN (ospf_area_import_list,
1787 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001788 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1789 "OSPF area parameters\n"
1790 "OSPF area ID in IP address format\n"
1791 "OSPF area ID as a decimal value\n"
1792 "Set the filter for networks from other areas announced to the specified one\n"
1793 "Name of the access-list\n")
1794{
paul68980082003-03-25 05:07:42 +00001795 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001796 struct ospf_area *area;
1797 struct in_addr area_id;
1798 int format;
1799
hasso52930762004-04-19 18:26:53 +00001800 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1801
paul68980082003-03-25 05:07:42 +00001802 area = ospf_area_get (ospf, area_id, format);
1803 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001804
1805 return CMD_SUCCESS;
1806}
1807
paula2c62832003-04-23 17:01:31 +00001808DEFUN (no_ospf_area_import_list,
1809 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001810 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1811 NO_STR
1812 "OSPF area parameters\n"
1813 "OSPF area ID in IP address format\n"
1814 "OSPF area ID as a decimal value\n"
1815 "Unset the filter for networks announced to other areas\n"
1816 "Name of the access-list\n")
1817{
paul68980082003-03-25 05:07:42 +00001818 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001819 struct ospf_area *area;
1820 struct in_addr area_id;
1821 int format;
1822
hasso52930762004-04-19 18:26:53 +00001823 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1824
paul68980082003-03-25 05:07:42 +00001825 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001826 if (area == NULL)
1827 return CMD_SUCCESS;
1828
paul68980082003-03-25 05:07:42 +00001829 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001830
1831 return CMD_SUCCESS;
1832}
1833
paula2c62832003-04-23 17:01:31 +00001834DEFUN (ospf_area_filter_list,
1835 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001836 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1837 "OSPF area parameters\n"
1838 "OSPF area ID in IP address format\n"
1839 "OSPF area ID as a decimal value\n"
1840 "Filter networks between OSPF areas\n"
1841 "Filter prefixes between OSPF areas\n"
1842 "Name of an IP prefix-list\n"
1843 "Filter networks sent to this area\n"
1844 "Filter networks sent from this area\n")
1845{
paul68980082003-03-25 05:07:42 +00001846 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001847 struct ospf_area *area;
1848 struct in_addr area_id;
1849 struct prefix_list *plist;
1850 int format;
1851
1852 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1853
paul68980082003-03-25 05:07:42 +00001854 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001855 plist = prefix_list_lookup (AFI_IP, argv[1]);
1856 if (strncmp (argv[2], "in", 2) == 0)
1857 {
1858 PREFIX_LIST_IN (area) = plist;
1859 if (PREFIX_NAME_IN (area))
1860 free (PREFIX_NAME_IN (area));
1861
1862 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001863 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001864 }
1865 else
1866 {
1867 PREFIX_LIST_OUT (area) = plist;
1868 if (PREFIX_NAME_OUT (area))
1869 free (PREFIX_NAME_OUT (area));
1870
1871 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001872 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001873 }
1874
1875 return CMD_SUCCESS;
1876}
1877
paula2c62832003-04-23 17:01:31 +00001878DEFUN (no_ospf_area_filter_list,
1879 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001880 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1881 NO_STR
1882 "OSPF area parameters\n"
1883 "OSPF area ID in IP address format\n"
1884 "OSPF area ID as a decimal value\n"
1885 "Filter networks between OSPF areas\n"
1886 "Filter prefixes between OSPF areas\n"
1887 "Name of an IP prefix-list\n"
1888 "Filter networks sent to this area\n"
1889 "Filter networks sent from this area\n")
1890{
paul68980082003-03-25 05:07:42 +00001891 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001892 struct ospf_area *area;
1893 struct in_addr area_id;
1894 struct prefix_list *plist;
1895 int format;
1896
1897 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1898
Paul Jakma1a8ec2b2006-05-11 13:34:08 +00001899 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1900 return CMD_SUCCESS;
1901
paul718e3742002-12-13 20:15:29 +00001902 plist = prefix_list_lookup (AFI_IP, argv[1]);
1903 if (strncmp (argv[2], "in", 2) == 0)
1904 {
1905 if (PREFIX_NAME_IN (area))
1906 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1907 return CMD_SUCCESS;
1908
1909 PREFIX_LIST_IN (area) = NULL;
1910 if (PREFIX_NAME_IN (area))
1911 free (PREFIX_NAME_IN (area));
1912
1913 PREFIX_NAME_IN (area) = NULL;
1914
paul68980082003-03-25 05:07:42 +00001915 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001916 }
1917 else
1918 {
1919 if (PREFIX_NAME_OUT (area))
1920 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1921 return CMD_SUCCESS;
1922
1923 PREFIX_LIST_OUT (area) = NULL;
1924 if (PREFIX_NAME_OUT (area))
1925 free (PREFIX_NAME_OUT (area));
1926
1927 PREFIX_NAME_OUT (area) = NULL;
1928
paul68980082003-03-25 05:07:42 +00001929 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001930 }
1931
1932 return CMD_SUCCESS;
1933}
1934
1935
paula2c62832003-04-23 17:01:31 +00001936DEFUN (ospf_area_authentication_message_digest,
1937 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001938 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1939 "OSPF area parameters\n"
1940 "Enable authentication\n"
1941 "Use message-digest authentication\n")
1942{
paul68980082003-03-25 05:07:42 +00001943 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001944 struct ospf_area *area;
1945 struct in_addr area_id;
1946 int format;
1947
1948 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1949
paul68980082003-03-25 05:07:42 +00001950 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001951 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1952
1953 return CMD_SUCCESS;
1954}
1955
paula2c62832003-04-23 17:01:31 +00001956DEFUN (ospf_area_authentication,
1957 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001958 "area (A.B.C.D|<0-4294967295>) authentication",
1959 "OSPF area parameters\n"
1960 "OSPF area ID in IP address format\n"
1961 "OSPF area ID as a decimal value\n"
1962 "Enable authentication\n")
1963{
paul68980082003-03-25 05:07:42 +00001964 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001965 struct ospf_area *area;
1966 struct in_addr area_id;
1967 int format;
1968
1969 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1970
paul68980082003-03-25 05:07:42 +00001971 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001972 area->auth_type = OSPF_AUTH_SIMPLE;
1973
1974 return CMD_SUCCESS;
1975}
1976
paula2c62832003-04-23 17:01:31 +00001977DEFUN (no_ospf_area_authentication,
1978 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001979 "no area (A.B.C.D|<0-4294967295>) authentication",
1980 NO_STR
1981 "OSPF area parameters\n"
1982 "OSPF area ID in IP address format\n"
1983 "OSPF area ID as a decimal value\n"
1984 "Enable authentication\n")
1985{
paul68980082003-03-25 05:07:42 +00001986 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001987 struct ospf_area *area;
1988 struct in_addr area_id;
1989 int format;
1990
1991 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1992
paul68980082003-03-25 05:07:42 +00001993 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001994 if (area == NULL)
1995 return CMD_SUCCESS;
1996
1997 area->auth_type = OSPF_AUTH_NULL;
1998
paul68980082003-03-25 05:07:42 +00001999 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002000
2001 return CMD_SUCCESS;
2002}
2003
2004
2005DEFUN (ospf_abr_type,
2006 ospf_abr_type_cmd,
2007 "ospf abr-type (cisco|ibm|shortcut|standard)",
2008 "OSPF specific commands\n"
2009 "Set OSPF ABR type\n"
2010 "Alternative ABR, cisco implementation\n"
2011 "Alternative ABR, IBM implementation\n"
2012 "Shortcut ABR\n"
2013 "Standard behavior (RFC2328)\n")
2014{
paul68980082003-03-25 05:07:42 +00002015 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002016 u_char abr_type = OSPF_ABR_UNKNOWN;
2017
2018 if (strncmp (argv[0], "c", 1) == 0)
2019 abr_type = OSPF_ABR_CISCO;
2020 else if (strncmp (argv[0], "i", 1) == 0)
2021 abr_type = OSPF_ABR_IBM;
2022 else if (strncmp (argv[0], "sh", 2) == 0)
2023 abr_type = OSPF_ABR_SHORTCUT;
2024 else if (strncmp (argv[0], "st", 2) == 0)
2025 abr_type = OSPF_ABR_STAND;
2026 else
2027 return CMD_WARNING;
2028
2029 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002030 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002031 {
paul68980082003-03-25 05:07:42 +00002032 ospf->abr_type = abr_type;
2033 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002034 }
2035
2036 return CMD_SUCCESS;
2037}
2038
2039DEFUN (no_ospf_abr_type,
2040 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002041 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002042 NO_STR
2043 "OSPF specific commands\n"
2044 "Set OSPF ABR type\n"
2045 "Alternative ABR, cisco implementation\n"
2046 "Alternative ABR, IBM implementation\n"
2047 "Shortcut ABR\n")
2048{
paul68980082003-03-25 05:07:42 +00002049 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002050 u_char abr_type = OSPF_ABR_UNKNOWN;
2051
2052 if (strncmp (argv[0], "c", 1) == 0)
2053 abr_type = OSPF_ABR_CISCO;
2054 else if (strncmp (argv[0], "i", 1) == 0)
2055 abr_type = OSPF_ABR_IBM;
2056 else if (strncmp (argv[0], "s", 1) == 0)
2057 abr_type = OSPF_ABR_SHORTCUT;
2058 else
2059 return CMD_WARNING;
2060
2061 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002062 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002063 {
pauld57834f2005-07-12 20:04:22 +00002064 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002065 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002066 }
2067
2068 return CMD_SUCCESS;
2069}
2070
2071DEFUN (ospf_compatible_rfc1583,
2072 ospf_compatible_rfc1583_cmd,
2073 "compatible rfc1583",
2074 "OSPF compatibility list\n"
2075 "compatible with RFC 1583\n")
2076{
2077 struct ospf *ospf = vty->index;
2078
2079 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2080 {
2081 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002082 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002083 }
2084 return CMD_SUCCESS;
2085}
2086
2087DEFUN (no_ospf_compatible_rfc1583,
2088 no_ospf_compatible_rfc1583_cmd,
2089 "no compatible rfc1583",
2090 NO_STR
2091 "OSPF compatibility list\n"
2092 "compatible with RFC 1583\n")
2093{
2094 struct ospf *ospf = vty->index;
2095
2096 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2097 {
2098 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002099 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002100 }
2101 return CMD_SUCCESS;
2102}
2103
2104ALIAS (ospf_compatible_rfc1583,
2105 ospf_rfc1583_flag_cmd,
2106 "ospf rfc1583compatibility",
2107 "OSPF specific commands\n"
2108 "Enable the RFC1583Compatibility flag\n")
2109
2110ALIAS (no_ospf_compatible_rfc1583,
2111 no_ospf_rfc1583_flag_cmd,
2112 "no ospf rfc1583compatibility",
2113 NO_STR
2114 "OSPF specific commands\n"
2115 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002116
2117static int
2118ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2119 unsigned int hold,
2120 unsigned int max)
2121{
2122 struct ospf *ospf = vty->index;
2123
2124 ospf->spf_delay = delay;
2125 ospf->spf_holdtime = hold;
2126 ospf->spf_max_holdtime = max;
2127
2128 return CMD_SUCCESS;
2129}
paul718e3742002-12-13 20:15:29 +00002130
pauld24f6e22005-10-21 09:23:12 +00002131DEFUN (ospf_timers_throttle_spf,
2132 ospf_timers_throttle_spf_cmd,
2133 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2134 "Adjust routing timers\n"
2135 "Throttling adaptive timer\n"
2136 "OSPF SPF timers\n"
2137 "Delay (msec) from first change received till SPF calculation\n"
2138 "Initial hold time (msec) between consecutive SPF calculations\n"
2139 "Maximum hold time (msec)\n")
2140{
2141 unsigned int delay, hold, max;
2142
2143 if (argc != 3)
2144 {
2145 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2146 return CMD_WARNING;
2147 }
2148
2149 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2150 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2151 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2152
2153 return ospf_timers_spf_set (vty, delay, hold, max);
2154}
2155
2156DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002157 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002158 "timers spf <0-4294967295> <0-4294967295>",
2159 "Adjust routing timers\n"
2160 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002161 "Delay (s) between receiving a change to SPF calculation\n"
2162 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002163{
pauld24f6e22005-10-21 09:23:12 +00002164 unsigned int delay, hold;
2165
2166 if (argc != 2)
2167 {
2168 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2169 return CMD_WARNING;
2170 }
2171
paul4dadc292005-05-06 21:37:42 +00002172 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2173 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002174
2175 /* truncate down the second values if they're greater than 600000ms */
2176 if (delay > (600000 / 1000))
2177 delay = 600000;
2178 else if (delay == 0)
2179 /* 0s delay was probably specified because of lack of ms resolution */
2180 delay = OSPF_SPF_DELAY_DEFAULT;
2181 if (hold > (600000 / 1000))
2182 hold = 600000;
2183
2184 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002185}
2186
pauld24f6e22005-10-21 09:23:12 +00002187DEFUN (no_ospf_timers_throttle_spf,
2188 no_ospf_timers_throttle_spf_cmd,
2189 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002190 NO_STR
2191 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002192 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002193 "OSPF SPF timers\n")
2194{
pauld24f6e22005-10-21 09:23:12 +00002195 return ospf_timers_spf_set (vty,
2196 OSPF_SPF_DELAY_DEFAULT,
2197 OSPF_SPF_HOLDTIME_DEFAULT,
2198 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002199}
2200
pauld24f6e22005-10-21 09:23:12 +00002201ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2202 no_ospf_timers_spf_cmd,
2203 "no timers spf",
2204 NO_STR
2205 "Adjust routing timers\n"
2206 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002207
paula2c62832003-04-23 17:01:31 +00002208DEFUN (ospf_neighbor,
2209 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002210 "neighbor A.B.C.D",
2211 NEIGHBOR_STR
2212 "Neighbor IP address\n")
2213{
2214 struct ospf *ospf = vty->index;
2215 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002216 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2217 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002218
2219 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2220
2221 if (argc > 1)
2222 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2223
2224 if (argc > 2)
2225 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2226
2227 ospf_nbr_nbma_set (ospf, nbr_addr);
2228 if (argc > 1)
2229 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2230 if (argc > 2)
2231 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2232
2233 return CMD_SUCCESS;
2234}
2235
paula2c62832003-04-23 17:01:31 +00002236ALIAS (ospf_neighbor,
2237 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002238 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2239 NEIGHBOR_STR
2240 "Neighbor IP address\n"
2241 "Neighbor Priority\n"
2242 "Priority\n"
2243 "Dead Neighbor Polling interval\n"
2244 "Seconds\n")
2245
paula2c62832003-04-23 17:01:31 +00002246ALIAS (ospf_neighbor,
2247 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002248 "neighbor A.B.C.D priority <0-255>",
2249 NEIGHBOR_STR
2250 "Neighbor IP address\n"
2251 "Neighbor Priority\n"
2252 "Seconds\n")
2253
paula2c62832003-04-23 17:01:31 +00002254DEFUN (ospf_neighbor_poll_interval,
2255 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002256 "neighbor A.B.C.D poll-interval <1-65535>",
2257 NEIGHBOR_STR
2258 "Neighbor IP address\n"
2259 "Dead Neighbor Polling interval\n"
2260 "Seconds\n")
2261{
2262 struct ospf *ospf = vty->index;
2263 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002264 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2265 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002266
2267 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2268
2269 if (argc > 1)
2270 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2271
2272 if (argc > 2)
2273 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2274
2275 ospf_nbr_nbma_set (ospf, nbr_addr);
2276 if (argc > 1)
2277 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2278 if (argc > 2)
2279 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2280
2281 return CMD_SUCCESS;
2282}
2283
paula2c62832003-04-23 17:01:31 +00002284ALIAS (ospf_neighbor_poll_interval,
2285 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002286 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2287 NEIGHBOR_STR
2288 "Neighbor address\n"
2289 "OSPF dead-router polling interval\n"
2290 "Seconds\n"
2291 "OSPF priority of non-broadcast neighbor\n"
2292 "Priority\n")
2293
paula2c62832003-04-23 17:01:31 +00002294DEFUN (no_ospf_neighbor,
2295 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002296 "no neighbor A.B.C.D",
2297 NO_STR
2298 NEIGHBOR_STR
2299 "Neighbor IP address\n")
2300{
2301 struct ospf *ospf = vty->index;
2302 struct in_addr nbr_addr;
2303 int ret;
2304
2305 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2306
2307 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2308
2309 return CMD_SUCCESS;
2310}
2311
paula2c62832003-04-23 17:01:31 +00002312ALIAS (no_ospf_neighbor,
2313 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002314 "no neighbor A.B.C.D priority <0-255>",
2315 NO_STR
2316 NEIGHBOR_STR
2317 "Neighbor IP address\n"
2318 "Neighbor Priority\n"
2319 "Priority\n")
2320
paula2c62832003-04-23 17:01:31 +00002321ALIAS (no_ospf_neighbor,
2322 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002323 "no neighbor A.B.C.D poll-interval <1-65535>",
2324 NO_STR
2325 NEIGHBOR_STR
2326 "Neighbor IP address\n"
2327 "Dead Neighbor Polling interval\n"
2328 "Seconds\n")
2329
paula2c62832003-04-23 17:01:31 +00002330ALIAS (no_ospf_neighbor,
2331 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002332 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2333 NO_STR
2334 NEIGHBOR_STR
2335 "Neighbor IP address\n"
2336 "Neighbor Priority\n"
2337 "Priority\n"
2338 "Dead Neighbor Polling interval\n"
2339 "Seconds\n")
2340
2341
paula2c62832003-04-23 17:01:31 +00002342DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002343 "refresh timer <10-1800>",
2344 "Adjust refresh parameters\n"
2345 "Set refresh timer\n"
2346 "Timer value in seconds\n")
2347{
2348 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002349 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002350
2351 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2352 interval = (interval / 10) * 10;
2353
2354 ospf_timers_refresh_set (ospf, interval);
2355
2356 return CMD_SUCCESS;
2357}
2358
paula2c62832003-04-23 17:01:31 +00002359DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002360 "no refresh timer <10-1800>",
2361 "Adjust refresh parameters\n"
2362 "Unset refresh timer\n"
2363 "Timer value in seconds\n")
2364{
2365 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002366 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002367
2368 if (argc == 1)
2369 {
2370 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2371
2372 if (ospf->lsa_refresh_interval != interval ||
2373 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2374 return CMD_SUCCESS;
2375 }
2376
2377 ospf_timers_refresh_unset (ospf);
2378
2379 return CMD_SUCCESS;
2380}
2381
paula2c62832003-04-23 17:01:31 +00002382ALIAS (no_ospf_refresh_timer,
2383 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002384 "no refresh timer",
2385 "Adjust refresh parameters\n"
2386 "Unset refresh timer\n")
2387
paula2c62832003-04-23 17:01:31 +00002388DEFUN (ospf_auto_cost_reference_bandwidth,
2389 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002390 "auto-cost reference-bandwidth <1-4294967>",
2391 "Calculate OSPF interface cost according to bandwidth\n"
2392 "Use reference bandwidth method to assign OSPF cost\n"
2393 "The reference bandwidth in terms of Mbits per second\n")
2394{
paul68980082003-03-25 05:07:42 +00002395 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002396 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002397 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002398 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002399
2400 refbw = strtol (argv[0], NULL, 10);
2401 if (refbw < 1 || refbw > 4294967)
2402 {
2403 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2404 return CMD_WARNING;
2405 }
2406
2407 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002408 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002409 return CMD_SUCCESS;
2410
paul68980082003-03-25 05:07:42 +00002411 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002412 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2413 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002414
2415 return CMD_SUCCESS;
2416}
2417
paula2c62832003-04-23 17:01:31 +00002418DEFUN (no_ospf_auto_cost_reference_bandwidth,
2419 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002420 "no auto-cost reference-bandwidth",
2421 NO_STR
2422 "Calculate OSPF interface cost according to bandwidth\n"
2423 "Use reference bandwidth method to assign OSPF cost\n")
2424{
paul68980082003-03-25 05:07:42 +00002425 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002426 struct listnode *node, *nnode;
2427 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002428
paul68980082003-03-25 05:07:42 +00002429 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002430 return CMD_SUCCESS;
2431
paul68980082003-03-25 05:07:42 +00002432 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002433 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2434 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2435
paul1eb8ef22005-04-07 07:30:20 +00002436 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2437 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002438
2439 return CMD_SUCCESS;
2440}
2441
hassoeb1ce602004-10-08 08:17:22 +00002442const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002443{
2444 "Unknown",
2445 "Standard (RFC2328)",
2446 "Alternative IBM",
2447 "Alternative Cisco",
2448 "Alternative Shortcut"
2449};
2450
hassoeb1ce602004-10-08 08:17:22 +00002451const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002452{
2453 "Default",
2454 "Enabled",
2455 "Disabled"
2456};
2457
2458
2459
paul4dadc292005-05-06 21:37:42 +00002460static void
paul718e3742002-12-13 20:15:29 +00002461show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2462{
2463 /* Show Area ID. */
2464 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2465
2466 /* Show Area type/mode. */
2467 if (OSPF_IS_AREA_BACKBONE (area))
2468 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2469 else
2470 {
2471 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002472 vty_out (vty, " (Stub%s%s)",
2473 area->no_summary ? ", no summary" : "",
2474 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002475
paulb0a053b2003-06-22 09:04:47 +00002476 else if (area->external_routing == OSPF_AREA_NSSA)
2477 vty_out (vty, " (NSSA%s%s)",
2478 area->no_summary ? ", no summary" : "",
2479 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002480
2481 vty_out (vty, "%s", VTY_NEWLINE);
2482 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002483 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002484 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002485 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002486 }
2487
2488 /* Show number of interfaces. */
2489 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2490 "Active: %d%s", listcount (area->oiflist),
2491 area->act_ints, VTY_NEWLINE);
2492
paul718e3742002-12-13 20:15:29 +00002493 if (area->external_routing == OSPF_AREA_NSSA)
2494 {
2495 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 +00002496 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002497 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2498 VTY_NEWLINE);
2499 else if (area->NSSATranslatorState)
2500 {
2501 vty_out (vty, " We are an ABR and ");
2502 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2503 vty_out (vty, "the NSSA Elected Translator. %s",
2504 VTY_NEWLINE);
2505 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2506 vty_out (vty, "always an NSSA Translator. %s",
2507 VTY_NEWLINE);
2508 }
paul718e3742002-12-13 20:15:29 +00002509 else
paulb0a053b2003-06-22 09:04:47 +00002510 {
2511 vty_out (vty, " We are an ABR, but ");
2512 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2513 vty_out (vty, "not the NSSA Elected Translator. %s",
2514 VTY_NEWLINE);
2515 else
hassoc6b87812004-12-22 13:09:59 +00002516 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002517 VTY_NEWLINE);
2518 }
paul718e3742002-12-13 20:15:29 +00002519 }
paul88d6cf32005-10-29 12:50:09 +00002520 /* Stub-router state for this area */
2521 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2522 {
ajs649654a2005-11-16 20:17:52 +00002523 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002524 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2525 VTY_NEWLINE);
2526 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2527 vty_out (vty, " Administratively activated (indefinitely)%s",
2528 VTY_NEWLINE);
2529 if (area->t_stub_router)
2530 vty_out (vty, " Active from startup, %s remaining%s",
2531 ospf_timer_dump (area->t_stub_router, timebuf,
2532 sizeof(timebuf)), VTY_NEWLINE);
2533 }
2534
paul718e3742002-12-13 20:15:29 +00002535 /* Show number of fully adjacent neighbors. */
2536 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002537 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002538
2539 /* Show authentication type. */
2540 vty_out (vty, " Area has ");
2541 if (area->auth_type == OSPF_AUTH_NULL)
2542 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2543 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2544 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2545 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2546 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2547
2548 if (!OSPF_IS_AREA_BACKBONE (area))
2549 vty_out (vty, " Number of full virtual adjacencies going through"
2550 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2551
2552 /* Show SPF calculation times. */
2553 vty_out (vty, " SPF algorithm executed %d times%s",
2554 area->spf_calculation, VTY_NEWLINE);
2555
2556 /* Show number of LSA. */
2557 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002558 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2559 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2560 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2561 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2562 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2563 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2564 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2565 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2566 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2567 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2568 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2569 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2570 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2571 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2572 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2573#ifdef HAVE_OPAQUE_LSA
2574 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2575 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2576 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2577 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2578 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2579 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2580#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002581 vty_out (vty, "%s", VTY_NEWLINE);
2582}
2583
2584DEFUN (show_ip_ospf,
2585 show_ip_ospf_cmd,
2586 "show ip ospf",
2587 SHOW_STR
2588 IP_STR
2589 "OSPF information\n")
2590{
paul1eb8ef22005-04-07 07:30:20 +00002591 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002592 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002593 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002594 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002595 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002596
2597 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002598 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002599 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002600 {
2601 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2602 return CMD_SUCCESS;
2603 }
2604
2605 /* Show Router ID. */
2606 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002607 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002608 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002609
2610 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002611 if (ospf->t_deferred_shutdown)
2612 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2613 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002614 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002615 /* Show capability. */
2616 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2617 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2618 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002619 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002620 "enabled" : "disabled", VTY_NEWLINE);
2621#ifdef HAVE_OPAQUE_LSA
2622 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002623 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002624 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002625 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002626 " (origination blocked)" : "",
2627 VTY_NEWLINE);
2628#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002629
2630 /* Show stub-router configuration */
2631 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2632 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2633 {
2634 vty_out (vty, " Stub router advertisement is configured%s",
2635 VTY_NEWLINE);
2636 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2637 vty_out (vty, " Enabled for %us after start-up%s",
2638 ospf->stub_router_startup_time, VTY_NEWLINE);
2639 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2640 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2641 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2642 }
2643
paul718e3742002-12-13 20:15:29 +00002644 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002645 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2646 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2647 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2648 " Hold time multiplier is currently %d%s",
2649 ospf->spf_delay, VTY_NEWLINE,
2650 ospf->spf_holdtime, VTY_NEWLINE,
2651 ospf->spf_max_holdtime, VTY_NEWLINE,
2652 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002653 vty_out (vty, " SPF algorithm ");
2654 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2655 {
paulc8c15212005-11-04 12:31:39 +00002656 result = tv_sub (recent_time, ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002657 vty_out (vty, "last executed %s ago%s",
2658 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2659 VTY_NEWLINE);
2660 }
2661 else
2662 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002663 vty_out (vty, " SPF timer %s%s%s",
2664 (ospf->t_spf_calc ? "due in " : "is "),
2665 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2666 VTY_NEWLINE);
2667
paul718e3742002-12-13 20:15:29 +00002668 /* Show refresh parameters. */
2669 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002670 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002671
2672 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002673 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002674 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002675 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002676
paul68980082003-03-25 05:07:42 +00002677 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002678 vty_out (vty, " This router is an ASBR "
2679 "(injecting external routing information)%s", VTY_NEWLINE);
2680
2681 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002682 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2683 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2684 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2685#ifdef HAVE_OPAQUE_LSA
2686 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2687 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2688 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2689#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002690 /* Show number of areas attached. */
2691 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002692 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002693
2694 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002695 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2696 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002697
2698 return CMD_SUCCESS;
2699}
2700
2701
ajsfd651fa2005-03-29 16:08:16 +00002702static void
paul68980082003-03-25 05:07:42 +00002703show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2704 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002705{
ajsfd651fa2005-03-29 16:08:16 +00002706 int is_up;
paul718e3742002-12-13 20:15:29 +00002707 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002708 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002709
paul718e3742002-12-13 20:15:29 +00002710 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002711 vty_out (vty, "%s is %s%s", ifp->name,
2712 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002713 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2714 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2715 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002716
2717 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002718 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002719 {
2720 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2721 return;
2722 }
ajsfd651fa2005-03-29 16:08:16 +00002723 else if (!is_up)
2724 {
2725 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2726 VTY_NEWLINE);
2727 return;
2728 }
2729
paul718e3742002-12-13 20:15:29 +00002730 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2731 {
2732 struct ospf_interface *oi = rn->info;
2733
2734 if (oi == NULL)
2735 continue;
2736
2737 /* Show OSPF interface information. */
2738 vty_out (vty, " Internet Address %s/%d,",
2739 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2740
Paul Jakma9c27ef92006-05-04 07:32:57 +00002741 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2742 {
2743 struct in_addr *dest;
2744 const char *dstr;
2745
2746 if ((ifp->flags & IFF_POINTOPOINT)
2747 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2748 dstr = "Peer";
2749 else
2750 dstr = "Broadcast";
2751
2752 /* For Vlinks, showing the peer address is probably more
2753 * informative than the local interface that is being used
2754 */
2755 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2756 dest = &oi->vl_data->peer_addr;
2757 else
2758 dest = &oi->connected->destination->u.prefix4;
2759
2760 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2761 }
hasso3fb9cd62004-10-19 19:44:43 +00002762
paul718e3742002-12-13 20:15:29 +00002763 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2764 VTY_NEWLINE);
2765
vincentba682532005-09-29 13:52:57 +00002766 vty_out (vty, " MTU mismatch detection:%s%s",
2767 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2768
paul718e3742002-12-13 20:15:29 +00002769 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002770 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002771 oi->output_cost, VTY_NEWLINE);
2772
2773 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2774 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2775 PRIORITY (oi), VTY_NEWLINE);
2776
2777 /* Show DR information. */
2778 if (DR (oi).s_addr == 0)
2779 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2780 else
2781 {
2782 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2783 if (nbr == NULL)
2784 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2785 else
2786 {
2787 vty_out (vty, " 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 }
2793
2794 /* Show BDR information. */
2795 if (BDR (oi).s_addr == 0)
2796 vty_out (vty, " No backup designated router on this network%s",
2797 VTY_NEWLINE);
2798 else
2799 {
2800 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2801 if (nbr == NULL)
2802 vty_out (vty, " No backup designated router on this network%s",
2803 VTY_NEWLINE);
2804 else
2805 {
2806 vty_out (vty, " Backup Designated Router (ID) %s,",
2807 inet_ntoa (nbr->router_id));
2808 vty_out (vty, " Interface Address %s%s",
2809 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2810 }
2811 }
ajsba6454e2005-02-08 15:37:30 +00002812
2813 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002814 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2815 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2816 {
2817 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2818 vty_out (vty, " OSPFAllRouters");
2819 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2820 vty_out (vty, " OSPFDesignatedRouters");
2821 }
2822 else
ajsba6454e2005-02-08 15:37:30 +00002823 vty_out (vty, " <None>");
2824 vty_out (vty, "%s", VTY_NEWLINE);
2825
paul718e3742002-12-13 20:15:29 +00002826 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002827 vty_out (vty, " Hello ");
2828 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2829 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2830 else
2831 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2832 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2833 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002834 OSPF_IF_PARAM (oi, v_wait),
2835 OSPF_IF_PARAM (oi, retransmit_interval),
2836 VTY_NEWLINE);
2837
2838 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002839 {
ajs649654a2005-11-16 20:17:52 +00002840 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002841 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002842 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002843 VTY_NEWLINE);
2844 }
paul718e3742002-12-13 20:15:29 +00002845 else /* OSPF_IF_PASSIVE is set */
2846 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2847
2848 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002849 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002850 VTY_NEWLINE);
2851 }
2852}
2853
2854DEFUN (show_ip_ospf_interface,
2855 show_ip_ospf_interface_cmd,
2856 "show ip ospf interface [INTERFACE]",
2857 SHOW_STR
2858 IP_STR
2859 "OSPF information\n"
2860 "Interface information\n"
2861 "Interface name\n")
2862{
2863 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002864 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002865 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002866
paul020709f2003-04-04 02:44:16 +00002867 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002868 if (ospf == NULL)
2869 {
2870 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2871 return CMD_SUCCESS;
2872 }
paul020709f2003-04-04 02:44:16 +00002873
paul718e3742002-12-13 20:15:29 +00002874 /* Show All Interfaces. */
2875 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002876 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2877 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002878 /* Interface name is specified. */
2879 else
2880 {
2881 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2882 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2883 else
paul68980082003-03-25 05:07:42 +00002884 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002885 }
2886
2887 return CMD_SUCCESS;
2888}
2889
paul4dadc292005-05-06 21:37:42 +00002890static void
pauld24f6e22005-10-21 09:23:12 +00002891show_ip_ospf_neighbour_header (struct vty *vty)
2892{
2893 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2894 VTY_NEWLINE,
2895 "Neighbor ID", "Pri", "State", "Dead Time",
2896 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
2897 VTY_NEWLINE);
2898}
2899
2900static void
paul718e3742002-12-13 20:15:29 +00002901show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2902{
2903 struct route_node *rn;
2904 struct ospf_neighbor *nbr;
2905 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00002906 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002907
2908 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2909 if ((nbr = rn->info))
2910 /* Do not show myself. */
2911 if (nbr != oi->nbr_self)
2912 /* Down state is not shown. */
2913 if (nbr->state != NSM_Down)
2914 {
2915 ospf_nbr_state_message (nbr, msgbuf, 16);
2916
2917 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00002918 vty_out (vty, "%-15s %3d %-15s ",
2919 "-", nbr->priority,
2920 msgbuf);
2921 else
2922 vty_out (vty, "%-15s %3d %-15s ",
2923 inet_ntoa (nbr->router_id), nbr->priority,
2924 msgbuf);
2925
2926 vty_out (vty, "%9s ",
2927 ospf_timer_dump (nbr->t_inactivity, timebuf,
2928 sizeof(timebuf)));
2929
paul718e3742002-12-13 20:15:29 +00002930 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00002931 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00002932 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2933 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2934 VTY_NEWLINE);
2935 }
2936}
2937
2938DEFUN (show_ip_ospf_neighbor,
2939 show_ip_ospf_neighbor_cmd,
2940 "show ip ospf neighbor",
2941 SHOW_STR
2942 IP_STR
2943 "OSPF information\n"
2944 "Neighbor list\n")
2945{
paul020709f2003-04-04 02:44:16 +00002946 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002947 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002948 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002949
paul020709f2003-04-04 02:44:16 +00002950 ospf = ospf_lookup ();
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 }
2956
pauld24f6e22005-10-21 09:23:12 +00002957 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00002958
paul1eb8ef22005-04-07 07:30:20 +00002959 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
2960 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00002961
2962 return CMD_SUCCESS;
2963}
2964
2965DEFUN (show_ip_ospf_neighbor_all,
2966 show_ip_ospf_neighbor_all_cmd,
2967 "show ip ospf neighbor all",
2968 SHOW_STR
2969 IP_STR
2970 "OSPF information\n"
2971 "Neighbor list\n"
2972 "include down status neighbor\n")
2973{
paul68980082003-03-25 05:07:42 +00002974 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002975 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002976 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002977
paul68980082003-03-25 05:07:42 +00002978 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002979 {
2980 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2981 return CMD_SUCCESS;
2982 }
pauld24f6e22005-10-21 09:23:12 +00002983
2984 show_ip_ospf_neighbour_header (vty);
2985
paul1eb8ef22005-04-07 07:30:20 +00002986 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00002987 {
hasso52dc7ee2004-09-23 19:18:23 +00002988 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00002989 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00002990
2991 show_ip_ospf_neighbor_sub (vty, oi);
2992
2993 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00002994 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00002995 {
paul718e3742002-12-13 20:15:29 +00002996 if (nbr_nbma->nbr == NULL
2997 || nbr_nbma->nbr->state == NSM_Down)
2998 {
pauld24f6e22005-10-21 09:23:12 +00002999 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003000 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003001 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003002 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3003 0, 0, 0, VTY_NEWLINE);
3004 }
3005 }
3006 }
3007
3008 return CMD_SUCCESS;
3009}
3010
3011DEFUN (show_ip_ospf_neighbor_int,
3012 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003013 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003014 SHOW_STR
3015 IP_STR
3016 "OSPF information\n"
3017 "Neighbor list\n"
3018 "Interface name\n")
3019{
paul020709f2003-04-04 02:44:16 +00003020 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003021 struct interface *ifp;
3022 struct route_node *rn;
3023
3024 ifp = if_lookup_by_name (argv[0]);
3025 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003026 {
hassobb5b7552005-08-21 20:01:15 +00003027 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003028 return CMD_WARNING;
3029 }
3030
paul020709f2003-04-04 02:44:16 +00003031 ospf = ospf_lookup ();
3032 if (ospf == NULL)
3033 {
3034 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3035 return CMD_SUCCESS;
3036 }
pauld24f6e22005-10-21 09:23:12 +00003037
3038 show_ip_ospf_neighbour_header (vty);
3039
hassobb5b7552005-08-21 20:01:15 +00003040 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003041 {
hassobb5b7552005-08-21 20:01:15 +00003042 struct ospf_interface *oi = rn->info;
3043
3044 if (oi == NULL)
3045 continue;
3046
paul718e3742002-12-13 20:15:29 +00003047 show_ip_ospf_neighbor_sub (vty, oi);
3048 }
3049
3050 return CMD_SUCCESS;
3051}
3052
paul4dadc292005-05-06 21:37:42 +00003053static void
paul718e3742002-12-13 20:15:29 +00003054show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3055 struct ospf_nbr_nbma *nbr_nbma)
3056{
ajs649654a2005-11-16 20:17:52 +00003057 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003058
3059 /* Show neighbor ID. */
3060 vty_out (vty, " Neighbor %s,", "-");
3061
3062 /* Show interface address. */
3063 vty_out (vty, " interface address %s%s",
3064 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3065 /* Show Area ID. */
3066 vty_out (vty, " In the area %s via interface %s%s",
3067 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3068 /* Show neighbor priority and state. */
3069 vty_out (vty, " Neighbor priority is %d, State is %s,",
3070 nbr_nbma->priority, "Down");
3071 /* Show state changes. */
3072 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3073
3074 /* Show PollInterval */
3075 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3076
3077 /* Show poll-interval timer. */
3078 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003079 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3080 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003081
3082 /* Show poll-interval timer thread. */
3083 vty_out (vty, " Thread Poll Timer %s%s",
3084 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3085}
3086
paul4dadc292005-05-06 21:37:42 +00003087static void
paul718e3742002-12-13 20:15:29 +00003088show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3089 struct ospf_neighbor *nbr)
3090{
ajs649654a2005-11-16 20:17:52 +00003091 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003092
3093 /* Show neighbor ID. */
3094 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3095 vty_out (vty, " Neighbor %s,", "-");
3096 else
3097 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3098
3099 /* Show interface address. */
3100 vty_out (vty, " interface address %s%s",
3101 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3102 /* Show Area ID. */
3103 vty_out (vty, " In the area %s via interface %s%s",
3104 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3105 /* Show neighbor priority and state. */
3106 vty_out (vty, " Neighbor priority is %d, State is %s,",
3107 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3108 /* Show state changes. */
3109 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3110
3111 /* Show Designated Rotuer ID. */
3112 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3113 /* Show Backup Designated Rotuer ID. */
3114 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3115 /* Show options. */
3116 vty_out (vty, " Options %d %s%s", nbr->options,
3117 ospf_options_dump (nbr->options), VTY_NEWLINE);
3118 /* Show Router Dead interval timer. */
3119 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003120 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3121 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003122 /* Show Database Summary list. */
3123 vty_out (vty, " Database Summary List %d%s",
3124 ospf_db_summary_count (nbr), VTY_NEWLINE);
3125 /* Show Link State Request list. */
3126 vty_out (vty, " Link State Request List %ld%s",
3127 ospf_ls_request_count (nbr), VTY_NEWLINE);
3128 /* Show Link State Retransmission list. */
3129 vty_out (vty, " Link State Retransmission List %ld%s",
3130 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3131 /* Show inactivity timer thread. */
3132 vty_out (vty, " Thread Inactivity Timer %s%s",
3133 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3134 /* Show Database Description retransmission thread. */
3135 vty_out (vty, " Thread Database Description Retransmision %s%s",
3136 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3137 /* Show Link State Request Retransmission thread. */
3138 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3139 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3140 /* Show Link State Update Retransmission thread. */
3141 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3142 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3143}
3144
3145DEFUN (show_ip_ospf_neighbor_id,
3146 show_ip_ospf_neighbor_id_cmd,
3147 "show ip ospf neighbor A.B.C.D",
3148 SHOW_STR
3149 IP_STR
3150 "OSPF information\n"
3151 "Neighbor list\n"
3152 "Neighbor ID\n")
3153{
paul020709f2003-04-04 02:44:16 +00003154 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003155 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003156 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003157 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003158 struct in_addr router_id;
3159 int ret;
3160
3161 ret = inet_aton (argv[0], &router_id);
3162 if (!ret)
3163 {
3164 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3165 return CMD_WARNING;
3166 }
3167
paul020709f2003-04-04 02:44:16 +00003168 ospf = ospf_lookup ();
3169 if (ospf == NULL)
3170 {
3171 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3172 return CMD_SUCCESS;
3173 }
3174
paul1eb8ef22005-04-07 07:30:20 +00003175 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3176 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3177 {
3178 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3179 return CMD_SUCCESS;
3180 }
paul718e3742002-12-13 20:15:29 +00003181
3182 /* Nothing to show. */
3183 return CMD_SUCCESS;
3184}
3185
3186DEFUN (show_ip_ospf_neighbor_detail,
3187 show_ip_ospf_neighbor_detail_cmd,
3188 "show ip ospf neighbor detail",
3189 SHOW_STR
3190 IP_STR
3191 "OSPF information\n"
3192 "Neighbor list\n"
3193 "detail of all neighbors\n")
3194{
paul020709f2003-04-04 02:44:16 +00003195 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003196 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003197 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003198
paul020709f2003-04-04 02:44:16 +00003199 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003200 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003201 {
3202 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3203 return CMD_SUCCESS;
3204 }
paul718e3742002-12-13 20:15:29 +00003205
paul1eb8ef22005-04-07 07:30:20 +00003206 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003207 {
paul718e3742002-12-13 20:15:29 +00003208 struct route_node *rn;
3209 struct ospf_neighbor *nbr;
3210
3211 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3212 if ((nbr = rn->info))
3213 if (nbr != oi->nbr_self)
3214 if (nbr->state != NSM_Down)
3215 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3216 }
3217
3218 return CMD_SUCCESS;
3219}
3220
3221DEFUN (show_ip_ospf_neighbor_detail_all,
3222 show_ip_ospf_neighbor_detail_all_cmd,
3223 "show ip ospf neighbor detail all",
3224 SHOW_STR
3225 IP_STR
3226 "OSPF information\n"
3227 "Neighbor list\n"
3228 "detail of all neighbors\n"
3229 "include down status neighbor\n")
3230{
paul020709f2003-04-04 02:44:16 +00003231 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003232 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003233 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003234
paul020709f2003-04-04 02:44:16 +00003235 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003236 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003237 {
3238 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3239 return CMD_SUCCESS;
3240 }
paul718e3742002-12-13 20:15:29 +00003241
paul1eb8ef22005-04-07 07:30:20 +00003242 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003243 {
paul718e3742002-12-13 20:15:29 +00003244 struct route_node *rn;
3245 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003246 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003247
3248 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3249 if ((nbr = rn->info))
3250 if (nbr != oi->nbr_self)
3251 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3252 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3253
3254 if (oi->type == OSPF_IFTYPE_NBMA)
3255 {
hasso52dc7ee2004-09-23 19:18:23 +00003256 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003257
paul1eb8ef22005-04-07 07:30:20 +00003258 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3259 if (nbr_nbma->nbr == NULL
3260 || nbr_nbma->nbr->state == NSM_Down)
3261 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003262 }
3263 }
3264
3265 return CMD_SUCCESS;
3266}
3267
3268DEFUN (show_ip_ospf_neighbor_int_detail,
3269 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003270 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003271 SHOW_STR
3272 IP_STR
3273 "OSPF information\n"
3274 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003275 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003276 "detail of all neighbors")
3277{
paul020709f2003-04-04 02:44:16 +00003278 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003279 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003280 struct interface *ifp;
3281 struct route_node *rn, *nrn;
3282 struct ospf_neighbor *nbr;
3283
3284 ifp = if_lookup_by_name (argv[0]);
3285 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003286 {
hassobb5b7552005-08-21 20:01:15 +00003287 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003288 return CMD_WARNING;
3289 }
3290
paul020709f2003-04-04 02:44:16 +00003291 ospf = ospf_lookup ();
3292 if (ospf == NULL)
3293 {
3294 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3295 return CMD_SUCCESS;
3296 }
paul68980082003-03-25 05:07:42 +00003297
paul718e3742002-12-13 20:15:29 +00003298
hassobb5b7552005-08-21 20:01:15 +00003299 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3300 if ((oi = rn->info))
3301 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3302 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003303 if (nbr != oi->nbr_self)
3304 if (nbr->state != NSM_Down)
3305 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003306
3307 return CMD_SUCCESS;
3308}
3309
3310
3311/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003312static int
paul020709f2003-04-04 02:44:16 +00003313show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003314{
paul718e3742002-12-13 20:15:29 +00003315 struct router_lsa *rl;
3316 struct summary_lsa *sl;
3317 struct as_external_lsa *asel;
3318 struct prefix_ipv4 p;
3319
3320 if (lsa != NULL)
3321 /* If self option is set, check LSA self flag. */
3322 if (self == 0 || IS_LSA_SELF (lsa))
3323 {
3324 /* LSA common part show. */
3325 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3326 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3327 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3328 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3329 /* LSA specific part show. */
3330 switch (lsa->data->type)
3331 {
3332 case OSPF_ROUTER_LSA:
3333 rl = (struct router_lsa *) lsa->data;
3334 vty_out (vty, " %-d", ntohs (rl->links));
3335 break;
3336 case OSPF_SUMMARY_LSA:
3337 sl = (struct summary_lsa *) lsa->data;
3338
3339 p.family = AF_INET;
3340 p.prefix = sl->header.id;
3341 p.prefixlen = ip_masklen (sl->mask);
3342 apply_mask_ipv4 (&p);
3343
3344 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3345 break;
3346 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003347 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003348 asel = (struct as_external_lsa *) lsa->data;
3349
3350 p.family = AF_INET;
3351 p.prefix = asel->header.id;
3352 p.prefixlen = ip_masklen (asel->mask);
3353 apply_mask_ipv4 (&p);
3354
3355 vty_out (vty, " %s %s/%d [0x%lx]",
3356 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3357 inet_ntoa (p.prefix), p.prefixlen,
3358 (u_long)ntohl (asel->e[0].route_tag));
3359 break;
3360 case OSPF_NETWORK_LSA:
3361 case OSPF_ASBR_SUMMARY_LSA:
3362#ifdef HAVE_OPAQUE_LSA
3363 case OSPF_OPAQUE_LINK_LSA:
3364 case OSPF_OPAQUE_AREA_LSA:
3365 case OSPF_OPAQUE_AS_LSA:
3366#endif /* HAVE_OPAQUE_LSA */
3367 default:
3368 break;
3369 }
3370 vty_out (vty, VTY_NEWLINE);
3371 }
3372
3373 return 0;
3374}
3375
hassoeb1ce602004-10-08 08:17:22 +00003376const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003377{
3378 "unknown",
3379 "Router Link States",
3380 "Net Link States",
3381 "Summary Link States",
3382 "ASBR-Summary Link States",
3383 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003384 "Group Membership LSA",
3385 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003386#ifdef HAVE_OPAQUE_LSA
3387 "Type-8 LSA",
3388 "Link-Local Opaque-LSA",
3389 "Area-Local Opaque-LSA",
3390 "AS-external Opaque-LSA",
3391#endif /* HAVE_OPAQUE_LSA */
3392};
3393
3394#define SHOW_OSPF_COMMON_HEADER \
3395 "Link ID ADV Router Age Seq# CkSum"
3396
hassoeb1ce602004-10-08 08:17:22 +00003397const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003398{
3399 "",
3400 "Link ID ADV Router Age Seq# CkSum Link count",
3401 "Link ID ADV Router Age Seq# CkSum",
3402 "Link ID ADV Router Age Seq# CkSum Route",
3403 "Link ID ADV Router Age Seq# CkSum",
3404 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003405 " --- header for Group Member ----",
3406 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003407#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003408 " --- type-8 ---",
3409 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3410 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3411 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3412#endif /* HAVE_OPAQUE_LSA */
3413};
3414
hassoeb1ce602004-10-08 08:17:22 +00003415const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003416{
3417 "Self-originated",
3418 "Checked",
3419 "Received",
3420 "Approved",
3421 "Discard",
paul4957f492003-06-27 01:28:45 +00003422 "Translated",
paul4957f492003-06-27 01:28:45 +00003423};
3424
paul4dadc292005-05-06 21:37:42 +00003425static void
paul718e3742002-12-13 20:15:29 +00003426show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3427{
3428 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003429
paul718e3742002-12-13 20:15:29 +00003430 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003431 vty_out (vty, " Options: 0x%-2x : %s%s",
3432 lsa->data->options,
3433 ospf_options_dump(lsa->data->options),
3434 VTY_NEWLINE);
3435 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003436 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003437 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3438 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003439
3440 if (lsa->data->type == OSPF_ROUTER_LSA)
3441 {
3442 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3443
3444 if (rlsa->flags)
3445 vty_out (vty, " :%s%s%s%s",
3446 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3447 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3448 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3449 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3450
3451 vty_out (vty, "%s", VTY_NEWLINE);
3452 }
3453 vty_out (vty, " LS Type: %s%s",
3454 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3455 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3456 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3457 vty_out (vty, " Advertising Router: %s%s",
3458 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3459 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3460 VTY_NEWLINE);
3461 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3462 VTY_NEWLINE);
3463 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3464}
3465
hassoeb1ce602004-10-08 08:17:22 +00003466const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003467{
3468 "(null)",
3469 "another Router (point-to-point)",
3470 "a Transit Network",
3471 "Stub Network",
3472 "a Virtual Link",
3473};
3474
hassoeb1ce602004-10-08 08:17:22 +00003475const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003476{
3477 "(null)",
3478 "Neighboring Router ID",
3479 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003480 "Net",
paul718e3742002-12-13 20:15:29 +00003481 "Neighboring Router ID",
3482};
3483
hassoeb1ce602004-10-08 08:17:22 +00003484const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003485{
3486 "(null)",
3487 "Router Interface address",
3488 "Router Interface address",
3489 "Network Mask",
3490 "Router Interface address",
3491};
3492
3493/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003494static void
paul718e3742002-12-13 20:15:29 +00003495show_ip_ospf_database_router_links (struct vty *vty,
3496 struct router_lsa *rl)
3497{
3498 int len, i, type;
3499
3500 len = ntohs (rl->header.length) - 4;
3501 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3502 {
3503 type = rl->link[i].type;
3504
3505 vty_out (vty, " Link connected to: %s%s",
3506 link_type_desc[type], VTY_NEWLINE);
3507 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3508 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3509 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3510 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3511 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3512 vty_out (vty, " TOS 0 Metric: %d%s",
3513 ntohs (rl->link[i].metric), VTY_NEWLINE);
3514 vty_out (vty, "%s", VTY_NEWLINE);
3515 }
3516}
3517
3518/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003519static int
paul718e3742002-12-13 20:15:29 +00003520show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3521{
3522 if (lsa != NULL)
3523 {
3524 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3525
3526 show_ip_ospf_database_header (vty, lsa);
3527
3528 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3529 VTY_NEWLINE, VTY_NEWLINE);
3530
3531 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003532 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003533 }
3534
3535 return 0;
3536}
3537
3538/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003539static int
paul718e3742002-12-13 20:15:29 +00003540show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3541{
3542 int length, i;
3543
3544 if (lsa != NULL)
3545 {
3546 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3547
3548 show_ip_ospf_database_header (vty, lsa);
3549
3550 vty_out (vty, " Network Mask: /%d%s",
3551 ip_masklen (nl->mask), VTY_NEWLINE);
3552
3553 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3554
3555 for (i = 0; length > 0; i++, length -= 4)
3556 vty_out (vty, " Attached Router: %s%s",
3557 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3558
3559 vty_out (vty, "%s", VTY_NEWLINE);
3560 }
3561
3562 return 0;
3563}
3564
3565/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003566static int
paul718e3742002-12-13 20:15:29 +00003567show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3568{
3569 if (lsa != NULL)
3570 {
3571 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3572
3573 show_ip_ospf_database_header (vty, lsa);
3574
3575 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3576 VTY_NEWLINE);
3577 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3578 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003579 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003580 }
3581
3582 return 0;
3583}
3584
3585/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003586static int
paul718e3742002-12-13 20:15:29 +00003587show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3588{
3589 if (lsa != NULL)
3590 {
3591 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3592
3593 show_ip_ospf_database_header (vty, lsa);
3594
3595 vty_out (vty, " Network Mask: /%d%s",
3596 ip_masklen (sl->mask), VTY_NEWLINE);
3597 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3598 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003599 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003600 }
3601
3602 return 0;
3603}
3604
3605/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003606static int
paul718e3742002-12-13 20:15:29 +00003607show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3608{
3609 if (lsa != NULL)
3610 {
3611 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3612
3613 show_ip_ospf_database_header (vty, lsa);
3614
3615 vty_out (vty, " Network Mask: /%d%s",
3616 ip_masklen (al->mask), VTY_NEWLINE);
3617 vty_out (vty, " Metric Type: %s%s",
3618 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3619 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3620 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3621 vty_out (vty, " Metric: %d%s",
3622 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3623 vty_out (vty, " Forward Address: %s%s",
3624 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3625
3626 vty_out (vty, " External Route Tag: %lu%s%s",
3627 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3628 }
3629
3630 return 0;
3631}
3632
ajs2a42e282004-12-08 18:43:03 +00003633/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003634static int
paul718e3742002-12-13 20:15:29 +00003635show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3636{
3637 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3638
3639 /* show_ip_ospf_database_header (vty, lsa); */
3640
ajs2a42e282004-12-08 18:43:03 +00003641 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003642 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003643 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003644 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3645 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003646 zlog_debug( " TOS: 0%s", "\n");
3647 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003648 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003649 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003650 inet_ntoa (al->e[0].fwd_addr), "\n");
3651
ajs2a42e282004-12-08 18:43:03 +00003652 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003653 ntohl (al->e[0].route_tag), "\n", "\n");
3654
3655 return 0;
3656}
3657
3658/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003659static int
paul718e3742002-12-13 20:15:29 +00003660show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3661{
3662 if (lsa != NULL)
3663 {
3664 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3665
3666 show_ip_ospf_database_header (vty, lsa);
3667
3668 vty_out (vty, " Network Mask: /%d%s",
3669 ip_masklen (al->mask), VTY_NEWLINE);
3670 vty_out (vty, " Metric Type: %s%s",
3671 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3672 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3673 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3674 vty_out (vty, " Metric: %d%s",
3675 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3676 vty_out (vty, " NSSA: Forward Address: %s%s",
3677 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3678
3679 vty_out (vty, " External Route Tag: %u%s%s",
3680 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3681 }
3682
3683 return 0;
3684}
3685
paul4dadc292005-05-06 21:37:42 +00003686static int
paul718e3742002-12-13 20:15:29 +00003687show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3688{
3689 return 0;
3690}
3691
3692#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003693static int
paul718e3742002-12-13 20:15:29 +00003694show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3695{
3696 if (lsa != NULL)
3697 {
3698 show_ip_ospf_database_header (vty, lsa);
3699 show_opaque_info_detail (vty, lsa);
3700
3701 vty_out (vty, "%s", VTY_NEWLINE);
3702 }
3703 return 0;
3704}
3705#endif /* HAVE_OPAQUE_LSA */
3706
3707int (*show_function[])(struct vty *, struct ospf_lsa *) =
3708{
3709 NULL,
3710 show_router_lsa_detail,
3711 show_network_lsa_detail,
3712 show_summary_lsa_detail,
3713 show_summary_asbr_lsa_detail,
3714 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003715 show_func_dummy,
3716 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003717#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003718 NULL, /* type-8 */
3719 show_opaque_lsa_detail,
3720 show_opaque_lsa_detail,
3721 show_opaque_lsa_detail,
3722#endif /* HAVE_OPAQUE_LSA */
3723};
3724
paul4dadc292005-05-06 21:37:42 +00003725static void
paul718e3742002-12-13 20:15:29 +00003726show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3727 struct in_addr *adv_router)
3728{
3729 memset (lp, 0, sizeof (struct prefix_ls));
3730 lp->family = 0;
3731 if (id == NULL)
3732 lp->prefixlen = 0;
3733 else if (adv_router == NULL)
3734 {
3735 lp->prefixlen = 32;
3736 lp->id = *id;
3737 }
3738 else
3739 {
3740 lp->prefixlen = 64;
3741 lp->id = *id;
3742 lp->adv_router = *adv_router;
3743 }
3744}
3745
paul4dadc292005-05-06 21:37:42 +00003746static void
paul718e3742002-12-13 20:15:29 +00003747show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3748 struct in_addr *id, struct in_addr *adv_router)
3749{
3750 struct prefix_ls lp;
3751 struct route_node *rn, *start;
3752 struct ospf_lsa *lsa;
3753
3754 show_lsa_prefix_set (vty, &lp, id, adv_router);
3755 start = route_node_get (rt, (struct prefix *) &lp);
3756 if (start)
3757 {
3758 route_lock_node (start);
3759 for (rn = start; rn; rn = route_next_until (rn, start))
3760 if ((lsa = rn->info))
3761 {
paul718e3742002-12-13 20:15:29 +00003762 if (show_function[lsa->data->type] != NULL)
3763 show_function[lsa->data->type] (vty, lsa);
3764 }
3765 route_unlock_node (start);
3766 }
3767}
3768
3769/* Show detail LSA information
3770 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003771static void
paul020709f2003-04-04 02:44:16 +00003772show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003773 struct in_addr *id, struct in_addr *adv_router)
3774{
hasso52dc7ee2004-09-23 19:18:23 +00003775 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003776 struct ospf_area *area;
3777
paul718e3742002-12-13 20:15:29 +00003778 switch (type)
3779 {
3780 case OSPF_AS_EXTERNAL_LSA:
3781#ifdef HAVE_OPAQUE_LSA
3782 case OSPF_OPAQUE_AS_LSA:
3783#endif /* HAVE_OPAQUE_LSA */
3784 vty_out (vty, " %s %s%s",
3785 show_database_desc[type],
3786 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003787 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003788 break;
3789 default:
paul1eb8ef22005-04-07 07:30:20 +00003790 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003791 {
paul718e3742002-12-13 20:15:29 +00003792 vty_out (vty, "%s %s (Area %s)%s%s",
3793 VTY_NEWLINE, show_database_desc[type],
3794 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3795 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3796 }
3797 break;
3798 }
3799}
3800
paul4dadc292005-05-06 21:37:42 +00003801static void
paul718e3742002-12-13 20:15:29 +00003802show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3803 struct in_addr *adv_router)
3804{
3805 struct route_node *rn;
3806 struct ospf_lsa *lsa;
3807
3808 for (rn = route_top (rt); rn; rn = route_next (rn))
3809 if ((lsa = rn->info))
3810 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3811 {
paul718e3742002-12-13 20:15:29 +00003812 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3813 continue;
paul718e3742002-12-13 20:15:29 +00003814 if (show_function[lsa->data->type] != NULL)
3815 show_function[lsa->data->type] (vty, lsa);
3816 }
3817}
3818
3819/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003820static void
paul020709f2003-04-04 02:44:16 +00003821show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003822 struct in_addr *adv_router)
3823{
hasso52dc7ee2004-09-23 19:18:23 +00003824 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003825 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003826
3827 switch (type)
3828 {
3829 case OSPF_AS_EXTERNAL_LSA:
3830#ifdef HAVE_OPAQUE_LSA
3831 case OSPF_OPAQUE_AS_LSA:
3832#endif /* HAVE_OPAQUE_LSA */
3833 vty_out (vty, " %s %s%s",
3834 show_database_desc[type],
3835 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003836 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003837 adv_router);
3838 break;
3839 default:
paul1eb8ef22005-04-07 07:30:20 +00003840 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003841 {
paul718e3742002-12-13 20:15:29 +00003842 vty_out (vty, "%s %s (Area %s)%s%s",
3843 VTY_NEWLINE, show_database_desc[type],
3844 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3845 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3846 adv_router);
3847 }
3848 break;
3849 }
3850}
3851
paul4dadc292005-05-06 21:37:42 +00003852static void
paul020709f2003-04-04 02:44:16 +00003853show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003854{
paul020709f2003-04-04 02:44:16 +00003855 struct ospf_lsa *lsa;
3856 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003857 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003858 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003859 int type;
3860
paul1eb8ef22005-04-07 07:30:20 +00003861 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003862 {
paul718e3742002-12-13 20:15:29 +00003863 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3864 {
3865 switch (type)
3866 {
3867 case OSPF_AS_EXTERNAL_LSA:
3868#ifdef HAVE_OPAQUE_LSA
3869 case OSPF_OPAQUE_AS_LSA:
3870#endif /* HAVE_OPAQUE_LSA */
3871 continue;
3872 default:
3873 break;
3874 }
3875 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3876 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3877 {
3878 vty_out (vty, " %s (Area %s)%s%s",
3879 show_database_desc[type],
3880 ospf_area_desc_string (area),
3881 VTY_NEWLINE, VTY_NEWLINE);
3882 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3883
paul020709f2003-04-04 02:44:16 +00003884 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3885 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003886
3887 vty_out (vty, "%s", VTY_NEWLINE);
3888 }
3889 }
3890 }
3891
3892 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3893 {
3894 switch (type)
3895 {
3896 case OSPF_AS_EXTERNAL_LSA:
3897#ifdef HAVE_OPAQUE_LSA
3898 case OSPF_OPAQUE_AS_LSA:
3899#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00003900 break;
paul718e3742002-12-13 20:15:29 +00003901 default:
3902 continue;
3903 }
paul68980082003-03-25 05:07:42 +00003904 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3905 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003906 {
3907 vty_out (vty, " %s%s%s",
3908 show_database_desc[type],
3909 VTY_NEWLINE, VTY_NEWLINE);
3910 vty_out (vty, "%s%s", show_database_header[type],
3911 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003912
3913 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3914 show_lsa_summary (vty, lsa, self);
3915
paul718e3742002-12-13 20:15:29 +00003916 vty_out (vty, "%s", VTY_NEWLINE);
3917 }
3918 }
3919
3920 vty_out (vty, "%s", VTY_NEWLINE);
3921}
3922
paul4dadc292005-05-06 21:37:42 +00003923static void
paul020709f2003-04-04 02:44:16 +00003924show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003925{
hasso52dc7ee2004-09-23 19:18:23 +00003926 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003927 struct ospf_lsa *lsa;
3928
3929 vty_out (vty, "%s MaxAge Link States:%s%s",
3930 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3931
paul1eb8ef22005-04-07 07:30:20 +00003932 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3933 {
3934 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3935 vty_out (vty, "Link State ID: %s%s",
3936 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3937 vty_out (vty, "Advertising Router: %s%s",
3938 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3939 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3940 vty_out (vty, "%s", VTY_NEWLINE);
3941 }
paul718e3742002-12-13 20:15:29 +00003942}
3943
paul718e3742002-12-13 20:15:29 +00003944#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3945#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003946
3947#ifdef HAVE_OPAQUE_LSA
3948#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3949#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3950#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3951#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3952#else /* HAVE_OPAQUE_LSA */
3953#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3954#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3955#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3956#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3957#endif /* HAVE_OPAQUE_LSA */
3958
3959#define OSPF_LSA_TYPES_CMD_STR \
3960 "asbr-summary|external|network|router|summary" \
3961 OSPF_LSA_TYPE_NSSA_CMD_STR \
3962 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3963
3964#define OSPF_LSA_TYPES_DESC \
3965 "ASBR summary link states\n" \
3966 "External link states\n" \
3967 "Network link states\n" \
3968 "Router link states\n" \
3969 "Network summary link states\n" \
3970 OSPF_LSA_TYPE_NSSA_DESC \
3971 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3972 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3973 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3974
3975DEFUN (show_ip_ospf_database,
3976 show_ip_ospf_database_cmd,
3977 "show ip ospf database",
3978 SHOW_STR
3979 IP_STR
3980 "OSPF information\n"
3981 "Database summary\n")
3982{
paul020709f2003-04-04 02:44:16 +00003983 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003984 int type, ret;
3985 struct in_addr id, adv_router;
3986
paul020709f2003-04-04 02:44:16 +00003987 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003988 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00003989 {
3990 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3991 return CMD_SUCCESS;
3992 }
paul718e3742002-12-13 20:15:29 +00003993
3994 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003995 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003996
3997 /* Show all LSA. */
3998 if (argc == 0)
3999 {
paul020709f2003-04-04 02:44:16 +00004000 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004001 return CMD_SUCCESS;
4002 }
4003
4004 /* Set database type to show. */
4005 if (strncmp (argv[0], "r", 1) == 0)
4006 type = OSPF_ROUTER_LSA;
4007 else if (strncmp (argv[0], "ne", 2) == 0)
4008 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004009 else if (strncmp (argv[0], "ns", 2) == 0)
4010 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004011 else if (strncmp (argv[0], "su", 2) == 0)
4012 type = OSPF_SUMMARY_LSA;
4013 else if (strncmp (argv[0], "a", 1) == 0)
4014 type = OSPF_ASBR_SUMMARY_LSA;
4015 else if (strncmp (argv[0], "e", 1) == 0)
4016 type = OSPF_AS_EXTERNAL_LSA;
4017 else if (strncmp (argv[0], "se", 2) == 0)
4018 {
paul020709f2003-04-04 02:44:16 +00004019 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004020 return CMD_SUCCESS;
4021 }
4022 else if (strncmp (argv[0], "m", 1) == 0)
4023 {
paul020709f2003-04-04 02:44:16 +00004024 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004025 return CMD_SUCCESS;
4026 }
4027#ifdef HAVE_OPAQUE_LSA
4028 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4029 type = OSPF_OPAQUE_LINK_LSA;
4030 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4031 type = OSPF_OPAQUE_AREA_LSA;
4032 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4033 type = OSPF_OPAQUE_AS_LSA;
4034#endif /* HAVE_OPAQUE_LSA */
4035 else
4036 return CMD_WARNING;
4037
4038 /* `show ip ospf database LSA'. */
4039 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004040 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004041 else if (argc >= 2)
4042 {
4043 ret = inet_aton (argv[1], &id);
4044 if (!ret)
4045 return CMD_WARNING;
4046
4047 /* `show ip ospf database LSA ID'. */
4048 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004049 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004050 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4051 else if (argc == 3)
4052 {
4053 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004054 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004055 else
4056 {
4057 ret = inet_aton (argv[2], &adv_router);
4058 if (!ret)
4059 return CMD_WARNING;
4060 }
paul020709f2003-04-04 02:44:16 +00004061 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004062 }
4063 }
4064
4065 return CMD_SUCCESS;
4066}
4067
4068ALIAS (show_ip_ospf_database,
4069 show_ip_ospf_database_type_cmd,
4070 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4071 SHOW_STR
4072 IP_STR
4073 "OSPF information\n"
4074 "Database summary\n"
4075 OSPF_LSA_TYPES_DESC
4076 "LSAs in MaxAge list\n"
4077 "Self-originated link states\n")
4078
4079ALIAS (show_ip_ospf_database,
4080 show_ip_ospf_database_type_id_cmd,
4081 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4082 SHOW_STR
4083 IP_STR
4084 "OSPF information\n"
4085 "Database summary\n"
4086 OSPF_LSA_TYPES_DESC
4087 "Link State ID (as an IP address)\n")
4088
4089ALIAS (show_ip_ospf_database,
4090 show_ip_ospf_database_type_id_adv_router_cmd,
4091 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4092 SHOW_STR
4093 IP_STR
4094 "OSPF information\n"
4095 "Database summary\n"
4096 OSPF_LSA_TYPES_DESC
4097 "Link State ID (as an IP address)\n"
4098 "Advertising Router link states\n"
4099 "Advertising Router (as an IP address)\n")
4100
4101ALIAS (show_ip_ospf_database,
4102 show_ip_ospf_database_type_id_self_cmd,
4103 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4104 SHOW_STR
4105 IP_STR
4106 "OSPF information\n"
4107 "Database summary\n"
4108 OSPF_LSA_TYPES_DESC
4109 "Link State ID (as an IP address)\n"
4110 "Self-originated link states\n"
4111 "\n")
4112
4113DEFUN (show_ip_ospf_database_type_adv_router,
4114 show_ip_ospf_database_type_adv_router_cmd,
4115 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4116 SHOW_STR
4117 IP_STR
4118 "OSPF information\n"
4119 "Database summary\n"
4120 OSPF_LSA_TYPES_DESC
4121 "Advertising Router link states\n"
4122 "Advertising Router (as an IP address)\n")
4123{
paul020709f2003-04-04 02:44:16 +00004124 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004125 int type, ret;
4126 struct in_addr adv_router;
4127
paul020709f2003-04-04 02:44:16 +00004128 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004129 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004130 {
4131 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4132 return CMD_SUCCESS;
4133 }
paul718e3742002-12-13 20:15:29 +00004134
4135 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004136 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004137
4138 if (argc != 2)
4139 return CMD_WARNING;
4140
4141 /* Set database type to show. */
4142 if (strncmp (argv[0], "r", 1) == 0)
4143 type = OSPF_ROUTER_LSA;
4144 else if (strncmp (argv[0], "ne", 2) == 0)
4145 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004146 else if (strncmp (argv[0], "ns", 2) == 0)
4147 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004148 else if (strncmp (argv[0], "s", 1) == 0)
4149 type = OSPF_SUMMARY_LSA;
4150 else if (strncmp (argv[0], "a", 1) == 0)
4151 type = OSPF_ASBR_SUMMARY_LSA;
4152 else if (strncmp (argv[0], "e", 1) == 0)
4153 type = OSPF_AS_EXTERNAL_LSA;
4154#ifdef HAVE_OPAQUE_LSA
4155 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4156 type = OSPF_OPAQUE_LINK_LSA;
4157 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4158 type = OSPF_OPAQUE_AREA_LSA;
4159 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4160 type = OSPF_OPAQUE_AS_LSA;
4161#endif /* HAVE_OPAQUE_LSA */
4162 else
4163 return CMD_WARNING;
4164
4165 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4166 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004167 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004168 else
4169 {
4170 ret = inet_aton (argv[1], &adv_router);
4171 if (!ret)
4172 return CMD_WARNING;
4173 }
4174
paul020709f2003-04-04 02:44:16 +00004175 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004176
4177 return CMD_SUCCESS;
4178}
4179
4180ALIAS (show_ip_ospf_database_type_adv_router,
4181 show_ip_ospf_database_type_self_cmd,
4182 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4183 SHOW_STR
4184 IP_STR
4185 "OSPF information\n"
4186 "Database summary\n"
4187 OSPF_LSA_TYPES_DESC
4188 "Self-originated link states\n")
4189
4190
4191DEFUN (ip_ospf_authentication_args,
4192 ip_ospf_authentication_args_addr_cmd,
4193 "ip ospf authentication (null|message-digest) A.B.C.D",
4194 "IP Information\n"
4195 "OSPF interface commands\n"
4196 "Enable authentication on this interface\n"
4197 "Use null authentication\n"
4198 "Use message-digest authentication\n"
4199 "Address of interface")
4200{
4201 struct interface *ifp;
4202 struct in_addr addr;
4203 int ret;
4204 struct ospf_if_params *params;
4205
4206 ifp = vty->index;
4207 params = IF_DEF_PARAMS (ifp);
4208
4209 if (argc == 2)
4210 {
4211 ret = inet_aton(argv[1], &addr);
4212 if (!ret)
4213 {
4214 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4215 VTY_NEWLINE);
4216 return CMD_WARNING;
4217 }
4218
4219 params = ospf_get_if_params (ifp, addr);
4220 ospf_if_update_params (ifp, addr);
4221 }
4222
4223 /* Handle null authentication */
4224 if ( argv[0][0] == 'n' )
4225 {
4226 SET_IF_PARAM (params, auth_type);
4227 params->auth_type = OSPF_AUTH_NULL;
4228 return CMD_SUCCESS;
4229 }
4230
4231 /* Handle message-digest authentication */
4232 if ( argv[0][0] == 'm' )
4233 {
4234 SET_IF_PARAM (params, auth_type);
4235 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4236 return CMD_SUCCESS;
4237 }
4238
4239 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4240 return CMD_WARNING;
4241}
4242
4243ALIAS (ip_ospf_authentication_args,
4244 ip_ospf_authentication_args_cmd,
4245 "ip ospf authentication (null|message-digest)",
4246 "IP Information\n"
4247 "OSPF interface commands\n"
4248 "Enable authentication on this interface\n"
4249 "Use null authentication\n"
4250 "Use message-digest authentication\n")
4251
4252DEFUN (ip_ospf_authentication,
4253 ip_ospf_authentication_addr_cmd,
4254 "ip ospf authentication A.B.C.D",
4255 "IP Information\n"
4256 "OSPF interface commands\n"
4257 "Enable authentication on this interface\n"
4258 "Address of interface")
4259{
4260 struct interface *ifp;
4261 struct in_addr addr;
4262 int ret;
4263 struct ospf_if_params *params;
4264
4265 ifp = vty->index;
4266 params = IF_DEF_PARAMS (ifp);
4267
4268 if (argc == 1)
4269 {
4270 ret = inet_aton(argv[1], &addr);
4271 if (!ret)
4272 {
4273 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4274 VTY_NEWLINE);
4275 return CMD_WARNING;
4276 }
4277
4278 params = ospf_get_if_params (ifp, addr);
4279 ospf_if_update_params (ifp, addr);
4280 }
4281
4282 SET_IF_PARAM (params, auth_type);
4283 params->auth_type = OSPF_AUTH_SIMPLE;
4284
4285 return CMD_SUCCESS;
4286}
4287
4288ALIAS (ip_ospf_authentication,
4289 ip_ospf_authentication_cmd,
4290 "ip ospf authentication",
4291 "IP Information\n"
4292 "OSPF interface commands\n"
4293 "Enable authentication on this interface\n")
4294
4295DEFUN (no_ip_ospf_authentication,
4296 no_ip_ospf_authentication_addr_cmd,
4297 "no ip ospf authentication A.B.C.D",
4298 NO_STR
4299 "IP Information\n"
4300 "OSPF interface commands\n"
4301 "Enable authentication on this interface\n"
4302 "Address of interface")
4303{
4304 struct interface *ifp;
4305 struct in_addr addr;
4306 int ret;
4307 struct ospf_if_params *params;
4308
4309 ifp = vty->index;
4310 params = IF_DEF_PARAMS (ifp);
4311
4312 if (argc == 1)
4313 {
4314 ret = inet_aton(argv[1], &addr);
4315 if (!ret)
4316 {
4317 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4318 VTY_NEWLINE);
4319 return CMD_WARNING;
4320 }
4321
4322 params = ospf_lookup_if_params (ifp, addr);
4323 if (params == NULL)
4324 return CMD_SUCCESS;
4325 }
4326
4327 params->auth_type = OSPF_AUTH_NOTSET;
4328 UNSET_IF_PARAM (params, auth_type);
4329
4330 if (params != IF_DEF_PARAMS (ifp))
4331 {
4332 ospf_free_if_params (ifp, addr);
4333 ospf_if_update_params (ifp, addr);
4334 }
4335
4336 return CMD_SUCCESS;
4337}
4338
4339ALIAS (no_ip_ospf_authentication,
4340 no_ip_ospf_authentication_cmd,
4341 "no ip ospf authentication",
4342 NO_STR
4343 "IP Information\n"
4344 "OSPF interface commands\n"
4345 "Enable authentication on this interface\n")
4346
4347DEFUN (ip_ospf_authentication_key,
4348 ip_ospf_authentication_key_addr_cmd,
4349 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4350 "IP Information\n"
4351 "OSPF interface commands\n"
4352 "Authentication password (key)\n"
4353 "The OSPF password (key)\n"
4354 "Address of interface")
4355{
4356 struct interface *ifp;
4357 struct in_addr addr;
4358 int ret;
4359 struct ospf_if_params *params;
4360
4361 ifp = vty->index;
4362 params = IF_DEF_PARAMS (ifp);
4363
4364 if (argc == 2)
4365 {
4366 ret = inet_aton(argv[1], &addr);
4367 if (!ret)
4368 {
4369 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4370 VTY_NEWLINE);
4371 return CMD_WARNING;
4372 }
4373
4374 params = ospf_get_if_params (ifp, addr);
4375 ospf_if_update_params (ifp, addr);
4376 }
4377
4378
4379 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004380 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004381 SET_IF_PARAM (params, auth_simple);
4382
4383 return CMD_SUCCESS;
4384}
4385
4386ALIAS (ip_ospf_authentication_key,
4387 ip_ospf_authentication_key_cmd,
4388 "ip ospf authentication-key AUTH_KEY",
4389 "IP Information\n"
4390 "OSPF interface commands\n"
4391 "Authentication password (key)\n"
4392 "The OSPF password (key)")
4393
4394ALIAS (ip_ospf_authentication_key,
4395 ospf_authentication_key_cmd,
4396 "ospf authentication-key AUTH_KEY",
4397 "OSPF interface commands\n"
4398 "Authentication password (key)\n"
4399 "The OSPF password (key)")
4400
4401DEFUN (no_ip_ospf_authentication_key,
4402 no_ip_ospf_authentication_key_addr_cmd,
4403 "no ip ospf authentication-key A.B.C.D",
4404 NO_STR
4405 "IP Information\n"
4406 "OSPF interface commands\n"
4407 "Authentication password (key)\n"
4408 "Address of interface")
4409{
4410 struct interface *ifp;
4411 struct in_addr addr;
4412 int ret;
4413 struct ospf_if_params *params;
4414
4415 ifp = vty->index;
4416 params = IF_DEF_PARAMS (ifp);
4417
4418 if (argc == 2)
4419 {
4420 ret = inet_aton(argv[1], &addr);
4421 if (!ret)
4422 {
4423 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4424 VTY_NEWLINE);
4425 return CMD_WARNING;
4426 }
4427
4428 params = ospf_lookup_if_params (ifp, addr);
4429 if (params == NULL)
4430 return CMD_SUCCESS;
4431 }
4432
4433 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4434 UNSET_IF_PARAM (params, auth_simple);
4435
4436 if (params != IF_DEF_PARAMS (ifp))
4437 {
4438 ospf_free_if_params (ifp, addr);
4439 ospf_if_update_params (ifp, addr);
4440 }
4441
4442 return CMD_SUCCESS;
4443}
4444
4445ALIAS (no_ip_ospf_authentication_key,
4446 no_ip_ospf_authentication_key_cmd,
4447 "no ip ospf authentication-key",
4448 NO_STR
4449 "IP Information\n"
4450 "OSPF interface commands\n"
4451 "Authentication password (key)\n")
4452
4453ALIAS (no_ip_ospf_authentication_key,
4454 no_ospf_authentication_key_cmd,
4455 "no ospf authentication-key",
4456 NO_STR
4457 "OSPF interface commands\n"
4458 "Authentication password (key)\n")
4459
4460DEFUN (ip_ospf_message_digest_key,
4461 ip_ospf_message_digest_key_addr_cmd,
4462 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4463 "IP Information\n"
4464 "OSPF interface commands\n"
4465 "Message digest authentication password (key)\n"
4466 "Key ID\n"
4467 "Use MD5 algorithm\n"
4468 "The OSPF password (key)"
4469 "Address of interface")
4470{
4471 struct interface *ifp;
4472 struct crypt_key *ck;
4473 u_char key_id;
4474 struct in_addr addr;
4475 int ret;
4476 struct ospf_if_params *params;
4477
4478 ifp = vty->index;
4479 params = IF_DEF_PARAMS (ifp);
4480
4481 if (argc == 3)
4482 {
4483 ret = inet_aton(argv[2], &addr);
4484 if (!ret)
4485 {
4486 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4487 VTY_NEWLINE);
4488 return CMD_WARNING;
4489 }
4490
4491 params = ospf_get_if_params (ifp, addr);
4492 ospf_if_update_params (ifp, addr);
4493 }
4494
4495 key_id = strtol (argv[0], NULL, 10);
4496 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4497 {
4498 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4499 return CMD_WARNING;
4500 }
4501
4502 ck = ospf_crypt_key_new ();
4503 ck->key_id = (u_char) key_id;
4504 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004505 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004506
4507 ospf_crypt_key_add (params->auth_crypt, ck);
4508 SET_IF_PARAM (params, auth_crypt);
4509
4510 return CMD_SUCCESS;
4511}
4512
4513ALIAS (ip_ospf_message_digest_key,
4514 ip_ospf_message_digest_key_cmd,
4515 "ip ospf message-digest-key <1-255> md5 KEY",
4516 "IP Information\n"
4517 "OSPF interface commands\n"
4518 "Message digest authentication password (key)\n"
4519 "Key ID\n"
4520 "Use MD5 algorithm\n"
4521 "The OSPF password (key)")
4522
4523ALIAS (ip_ospf_message_digest_key,
4524 ospf_message_digest_key_cmd,
4525 "ospf message-digest-key <1-255> md5 KEY",
4526 "OSPF interface commands\n"
4527 "Message digest authentication password (key)\n"
4528 "Key ID\n"
4529 "Use MD5 algorithm\n"
4530 "The OSPF password (key)")
4531
4532DEFUN (no_ip_ospf_message_digest_key,
4533 no_ip_ospf_message_digest_key_addr_cmd,
4534 "no ip ospf message-digest-key <1-255> A.B.C.D",
4535 NO_STR
4536 "IP Information\n"
4537 "OSPF interface commands\n"
4538 "Message digest authentication password (key)\n"
4539 "Key ID\n"
4540 "Address of interface")
4541{
4542 struct interface *ifp;
4543 struct crypt_key *ck;
4544 int key_id;
4545 struct in_addr addr;
4546 int ret;
4547 struct ospf_if_params *params;
4548
4549 ifp = vty->index;
4550 params = IF_DEF_PARAMS (ifp);
4551
4552 if (argc == 2)
4553 {
4554 ret = inet_aton(argv[1], &addr);
4555 if (!ret)
4556 {
4557 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4558 VTY_NEWLINE);
4559 return CMD_WARNING;
4560 }
4561
4562 params = ospf_lookup_if_params (ifp, addr);
4563 if (params == NULL)
4564 return CMD_SUCCESS;
4565 }
4566
4567 key_id = strtol (argv[0], NULL, 10);
4568 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4569 if (ck == NULL)
4570 {
4571 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4572 return CMD_WARNING;
4573 }
4574
4575 ospf_crypt_key_delete (params->auth_crypt, key_id);
4576
4577 if (params != IF_DEF_PARAMS (ifp))
4578 {
4579 ospf_free_if_params (ifp, addr);
4580 ospf_if_update_params (ifp, addr);
4581 }
4582
4583 return CMD_SUCCESS;
4584}
4585
4586ALIAS (no_ip_ospf_message_digest_key,
4587 no_ip_ospf_message_digest_key_cmd,
4588 "no ip ospf message-digest-key <1-255>",
4589 NO_STR
4590 "IP Information\n"
4591 "OSPF interface commands\n"
4592 "Message digest authentication password (key)\n"
4593 "Key ID\n")
4594
4595ALIAS (no_ip_ospf_message_digest_key,
4596 no_ospf_message_digest_key_cmd,
4597 "no ospf message-digest-key <1-255>",
4598 NO_STR
4599 "OSPF interface commands\n"
4600 "Message digest authentication password (key)\n"
4601 "Key ID\n")
4602
4603DEFUN (ip_ospf_cost,
4604 ip_ospf_cost_addr_cmd,
4605 "ip ospf cost <1-65535> A.B.C.D",
4606 "IP Information\n"
4607 "OSPF interface commands\n"
4608 "Interface cost\n"
4609 "Cost\n"
4610 "Address of interface")
4611{
4612 struct interface *ifp = vty->index;
4613 u_int32_t cost;
4614 struct in_addr addr;
4615 int ret;
4616 struct ospf_if_params *params;
4617
4618 params = IF_DEF_PARAMS (ifp);
4619
4620 cost = strtol (argv[0], NULL, 10);
4621
4622 /* cost range is <1-65535>. */
4623 if (cost < 1 || cost > 65535)
4624 {
4625 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4626 return CMD_WARNING;
4627 }
4628
4629 if (argc == 2)
4630 {
4631 ret = inet_aton(argv[1], &addr);
4632 if (!ret)
4633 {
4634 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4635 VTY_NEWLINE);
4636 return CMD_WARNING;
4637 }
4638
4639 params = ospf_get_if_params (ifp, addr);
4640 ospf_if_update_params (ifp, addr);
4641 }
4642
4643 SET_IF_PARAM (params, output_cost_cmd);
4644 params->output_cost_cmd = cost;
4645
4646 ospf_if_recalculate_output_cost (ifp);
4647
4648 return CMD_SUCCESS;
4649}
4650
4651ALIAS (ip_ospf_cost,
4652 ip_ospf_cost_cmd,
4653 "ip ospf cost <1-65535>",
4654 "IP Information\n"
4655 "OSPF interface commands\n"
4656 "Interface cost\n"
4657 "Cost")
4658
4659ALIAS (ip_ospf_cost,
4660 ospf_cost_cmd,
4661 "ospf cost <1-65535>",
4662 "OSPF interface commands\n"
4663 "Interface cost\n"
4664 "Cost")
4665
4666DEFUN (no_ip_ospf_cost,
4667 no_ip_ospf_cost_addr_cmd,
4668 "no ip ospf cost A.B.C.D",
4669 NO_STR
4670 "IP Information\n"
4671 "OSPF interface commands\n"
4672 "Interface cost\n"
4673 "Address of interface")
4674{
4675 struct interface *ifp = vty->index;
4676 struct in_addr addr;
4677 int ret;
4678 struct ospf_if_params *params;
4679
4680 ifp = vty->index;
4681 params = IF_DEF_PARAMS (ifp);
4682
4683 if (argc == 1)
4684 {
4685 ret = inet_aton(argv[0], &addr);
4686 if (!ret)
4687 {
4688 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4689 VTY_NEWLINE);
4690 return CMD_WARNING;
4691 }
4692
4693 params = ospf_lookup_if_params (ifp, addr);
4694 if (params == NULL)
4695 return CMD_SUCCESS;
4696 }
4697
4698 UNSET_IF_PARAM (params, output_cost_cmd);
4699
4700 if (params != IF_DEF_PARAMS (ifp))
4701 {
4702 ospf_free_if_params (ifp, addr);
4703 ospf_if_update_params (ifp, addr);
4704 }
4705
4706 ospf_if_recalculate_output_cost (ifp);
4707
4708 return CMD_SUCCESS;
4709}
4710
4711ALIAS (no_ip_ospf_cost,
4712 no_ip_ospf_cost_cmd,
4713 "no ip ospf cost",
4714 NO_STR
4715 "IP Information\n"
4716 "OSPF interface commands\n"
4717 "Interface cost\n")
4718
4719ALIAS (no_ip_ospf_cost,
4720 no_ospf_cost_cmd,
4721 "no ospf cost",
4722 NO_STR
4723 "OSPF interface commands\n"
4724 "Interface cost\n")
4725
paul4dadc292005-05-06 21:37:42 +00004726static void
paul718e3742002-12-13 20:15:29 +00004727ospf_nbr_timer_update (struct ospf_interface *oi)
4728{
4729 struct route_node *rn;
4730 struct ospf_neighbor *nbr;
4731
4732 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4733 if ((nbr = rn->info))
4734 {
4735 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4736 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4737 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4738 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4739 }
4740}
4741
paulf9ad9372005-10-21 00:45:17 +00004742static int
4743ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4744 const char *nbr_str,
4745 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004746{
4747 struct interface *ifp = vty->index;
4748 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004749 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004750 struct in_addr addr;
4751 int ret;
4752 struct ospf_if_params *params;
4753 struct ospf_interface *oi;
4754 struct route_node *rn;
4755
4756 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004757
4758 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004759 {
paulf9ad9372005-10-21 00:45:17 +00004760 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004761 if (!ret)
4762 {
4763 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4764 VTY_NEWLINE);
4765 return CMD_WARNING;
4766 }
4767
4768 params = ospf_get_if_params (ifp, addr);
4769 ospf_if_update_params (ifp, addr);
4770 }
4771
paulf9ad9372005-10-21 00:45:17 +00004772 if (interval_str)
4773 {
4774 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4775 1, 65535);
4776
4777 /* reset fast_hello too, just to be sure */
4778 UNSET_IF_PARAM (params, fast_hello);
4779 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4780 }
4781 else if (fast_hello_str)
4782 {
4783 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4784 1, 10);
4785 /* 1s dead-interval with sub-second hellos desired */
4786 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4787 SET_IF_PARAM (params, fast_hello);
4788 params->fast_hello = hellomult;
4789 }
4790 else
4791 {
4792 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4793 VTY_NEWLINE);
4794 return CMD_WARNING;
4795 }
4796
paul718e3742002-12-13 20:15:29 +00004797 SET_IF_PARAM (params, v_wait);
4798 params->v_wait = seconds;
4799
4800 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00004801 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004802 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004803 struct ospf *ospf;
4804 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00004805 {
4806 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4807 if (oi)
4808 ospf_nbr_timer_update (oi);
4809 }
paul718e3742002-12-13 20:15:29 +00004810 }
4811 else
4812 {
4813 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4814 if ((oi = rn->info))
4815 ospf_nbr_timer_update (oi);
4816 }
4817
4818 return CMD_SUCCESS;
4819}
4820
paulf9ad9372005-10-21 00:45:17 +00004821
4822DEFUN (ip_ospf_dead_interval,
4823 ip_ospf_dead_interval_addr_cmd,
4824 "ip ospf dead-interval <1-65535> A.B.C.D",
4825 "IP Information\n"
4826 "OSPF interface commands\n"
4827 "Interval after which a neighbor is declared dead\n"
4828 "Seconds\n"
4829 "Address of interface\n")
4830{
4831 if (argc == 2)
4832 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4833 else
4834 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4835}
4836
paul718e3742002-12-13 20:15:29 +00004837ALIAS (ip_ospf_dead_interval,
4838 ip_ospf_dead_interval_cmd,
4839 "ip ospf dead-interval <1-65535>",
4840 "IP Information\n"
4841 "OSPF interface commands\n"
4842 "Interval after which a neighbor is declared dead\n"
4843 "Seconds\n")
4844
4845ALIAS (ip_ospf_dead_interval,
4846 ospf_dead_interval_cmd,
4847 "ospf dead-interval <1-65535>",
4848 "OSPF interface commands\n"
4849 "Interval after which a neighbor is declared dead\n"
4850 "Seconds\n")
4851
paulf9ad9372005-10-21 00:45:17 +00004852DEFUN (ip_ospf_dead_interval_minimal,
4853 ip_ospf_dead_interval_minimal_addr_cmd,
4854 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4855 "IP Information\n"
4856 "OSPF interface commands\n"
4857 "Interval after which a neighbor is declared dead\n"
4858 "Minimal 1s dead-interval with fast sub-second hellos\n"
4859 "Hello multiplier factor\n"
4860 "Number of Hellos to send each second\n"
4861 "Address of interface\n")
4862{
4863 if (argc == 2)
4864 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4865 else
4866 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4867}
4868
4869ALIAS (ip_ospf_dead_interval_minimal,
4870 ip_ospf_dead_interval_minimal_cmd,
4871 "ip ospf dead-interval minimal hello-multiplier <1-10>",
4872 "IP Information\n"
4873 "OSPF interface commands\n"
4874 "Interval after which a neighbor is declared dead\n"
4875 "Minimal 1s dead-interval with fast sub-second hellos\n"
4876 "Hello multiplier factor\n"
4877 "Number of Hellos to send each second\n")
4878
paul718e3742002-12-13 20:15:29 +00004879DEFUN (no_ip_ospf_dead_interval,
4880 no_ip_ospf_dead_interval_addr_cmd,
4881 "no ip ospf dead-interval A.B.C.D",
4882 NO_STR
4883 "IP Information\n"
4884 "OSPF interface commands\n"
4885 "Interval after which a neighbor is declared dead\n"
4886 "Address of interface")
4887{
4888 struct interface *ifp = vty->index;
4889 struct in_addr addr;
4890 int ret;
4891 struct ospf_if_params *params;
4892 struct ospf_interface *oi;
4893 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004894
paul718e3742002-12-13 20:15:29 +00004895 ifp = vty->index;
4896 params = IF_DEF_PARAMS (ifp);
4897
4898 if (argc == 1)
4899 {
4900 ret = inet_aton(argv[0], &addr);
4901 if (!ret)
4902 {
4903 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4904 VTY_NEWLINE);
4905 return CMD_WARNING;
4906 }
4907
4908 params = ospf_lookup_if_params (ifp, addr);
4909 if (params == NULL)
4910 return CMD_SUCCESS;
4911 }
4912
4913 UNSET_IF_PARAM (params, v_wait);
4914 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00004915
4916 UNSET_IF_PARAM (params, fast_hello);
4917 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4918
paul718e3742002-12-13 20:15:29 +00004919 if (params != IF_DEF_PARAMS (ifp))
4920 {
4921 ospf_free_if_params (ifp, addr);
4922 ospf_if_update_params (ifp, addr);
4923 }
4924
4925 /* Update timer values in neighbor structure. */
4926 if (argc == 1)
4927 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004928 struct ospf *ospf;
4929
4930 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00004931 {
4932 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4933 if (oi)
4934 ospf_nbr_timer_update (oi);
4935 }
paul718e3742002-12-13 20:15:29 +00004936 }
4937 else
4938 {
4939 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4940 if ((oi = rn->info))
4941 ospf_nbr_timer_update (oi);
4942 }
4943
4944 return CMD_SUCCESS;
4945}
4946
4947ALIAS (no_ip_ospf_dead_interval,
4948 no_ip_ospf_dead_interval_cmd,
4949 "no ip ospf dead-interval",
4950 NO_STR
4951 "IP Information\n"
4952 "OSPF interface commands\n"
4953 "Interval after which a neighbor is declared dead\n")
4954
4955ALIAS (no_ip_ospf_dead_interval,
4956 no_ospf_dead_interval_cmd,
4957 "no ospf dead-interval",
4958 NO_STR
4959 "OSPF interface commands\n"
4960 "Interval after which a neighbor is declared dead\n")
4961
4962DEFUN (ip_ospf_hello_interval,
4963 ip_ospf_hello_interval_addr_cmd,
4964 "ip ospf hello-interval <1-65535> A.B.C.D",
4965 "IP Information\n"
4966 "OSPF interface commands\n"
4967 "Time between HELLO packets\n"
4968 "Seconds\n"
4969 "Address of interface")
4970{
4971 struct interface *ifp = vty->index;
4972 u_int32_t seconds;
4973 struct in_addr addr;
4974 int ret;
4975 struct ospf_if_params *params;
4976
4977 params = IF_DEF_PARAMS (ifp);
4978
4979 seconds = strtol (argv[0], NULL, 10);
4980
4981 /* HelloInterval range is <1-65535>. */
4982 if (seconds < 1 || seconds > 65535)
4983 {
4984 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4985 return CMD_WARNING;
4986 }
4987
4988 if (argc == 2)
4989 {
4990 ret = inet_aton(argv[1], &addr);
4991 if (!ret)
4992 {
4993 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4994 VTY_NEWLINE);
4995 return CMD_WARNING;
4996 }
4997
4998 params = ospf_get_if_params (ifp, addr);
4999 ospf_if_update_params (ifp, addr);
5000 }
5001
paulf9ad9372005-10-21 00:45:17 +00005002 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005003 params->v_hello = seconds;
5004
5005 return CMD_SUCCESS;
5006}
5007
5008ALIAS (ip_ospf_hello_interval,
5009 ip_ospf_hello_interval_cmd,
5010 "ip ospf hello-interval <1-65535>",
5011 "IP Information\n"
5012 "OSPF interface commands\n"
5013 "Time between HELLO packets\n"
5014 "Seconds\n")
5015
5016ALIAS (ip_ospf_hello_interval,
5017 ospf_hello_interval_cmd,
5018 "ospf hello-interval <1-65535>",
5019 "OSPF interface commands\n"
5020 "Time between HELLO packets\n"
5021 "Seconds\n")
5022
5023DEFUN (no_ip_ospf_hello_interval,
5024 no_ip_ospf_hello_interval_addr_cmd,
5025 "no ip ospf hello-interval A.B.C.D",
5026 NO_STR
5027 "IP Information\n"
5028 "OSPF interface commands\n"
5029 "Time between HELLO packets\n"
5030 "Address of interface")
5031{
5032 struct interface *ifp = vty->index;
5033 struct in_addr addr;
5034 int ret;
5035 struct ospf_if_params *params;
5036
5037 ifp = vty->index;
5038 params = IF_DEF_PARAMS (ifp);
5039
5040 if (argc == 1)
5041 {
5042 ret = inet_aton(argv[0], &addr);
5043 if (!ret)
5044 {
5045 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5046 VTY_NEWLINE);
5047 return CMD_WARNING;
5048 }
5049
5050 params = ospf_lookup_if_params (ifp, addr);
5051 if (params == NULL)
5052 return CMD_SUCCESS;
5053 }
5054
5055 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005056 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005057
5058 if (params != IF_DEF_PARAMS (ifp))
5059 {
5060 ospf_free_if_params (ifp, addr);
5061 ospf_if_update_params (ifp, addr);
5062 }
5063
5064 return CMD_SUCCESS;
5065}
5066
5067ALIAS (no_ip_ospf_hello_interval,
5068 no_ip_ospf_hello_interval_cmd,
5069 "no ip ospf hello-interval",
5070 NO_STR
5071 "IP Information\n"
5072 "OSPF interface commands\n"
5073 "Time between HELLO packets\n")
5074
5075ALIAS (no_ip_ospf_hello_interval,
5076 no_ospf_hello_interval_cmd,
5077 "no ospf hello-interval",
5078 NO_STR
5079 "OSPF interface commands\n"
5080 "Time between HELLO packets\n")
5081
5082DEFUN (ip_ospf_network,
5083 ip_ospf_network_cmd,
5084 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5085 "IP Information\n"
5086 "OSPF interface commands\n"
5087 "Network type\n"
5088 "Specify OSPF broadcast multi-access network\n"
5089 "Specify OSPF NBMA network\n"
5090 "Specify OSPF point-to-multipoint network\n"
5091 "Specify OSPF point-to-point network\n")
5092{
5093 struct interface *ifp = vty->index;
5094 int old_type = IF_DEF_PARAMS (ifp)->type;
5095 struct route_node *rn;
5096
5097 if (strncmp (argv[0], "b", 1) == 0)
5098 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5099 else if (strncmp (argv[0], "n", 1) == 0)
5100 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5101 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5102 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5103 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5104 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5105
5106 if (IF_DEF_PARAMS (ifp)->type == old_type)
5107 return CMD_SUCCESS;
5108
5109 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5110
5111 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5112 {
5113 struct ospf_interface *oi = rn->info;
5114
5115 if (!oi)
5116 continue;
5117
5118 oi->type = IF_DEF_PARAMS (ifp)->type;
5119
5120 if (oi->state > ISM_Down)
5121 {
5122 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5123 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5124 }
5125 }
5126
5127 return CMD_SUCCESS;
5128}
5129
5130ALIAS (ip_ospf_network,
5131 ospf_network_cmd,
5132 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5133 "OSPF interface commands\n"
5134 "Network type\n"
5135 "Specify OSPF broadcast multi-access network\n"
5136 "Specify OSPF NBMA network\n"
5137 "Specify OSPF point-to-multipoint network\n"
5138 "Specify OSPF point-to-point network\n")
5139
5140DEFUN (no_ip_ospf_network,
5141 no_ip_ospf_network_cmd,
5142 "no ip ospf network",
5143 NO_STR
5144 "IP Information\n"
5145 "OSPF interface commands\n"
5146 "Network type\n")
5147{
5148 struct interface *ifp = vty->index;
5149 int old_type = IF_DEF_PARAMS (ifp)->type;
5150 struct route_node *rn;
5151
ajsbc18d612004-12-15 15:07:19 +00005152 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005153
5154 if (IF_DEF_PARAMS (ifp)->type == old_type)
5155 return CMD_SUCCESS;
5156
5157 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5158 {
5159 struct ospf_interface *oi = rn->info;
5160
5161 if (!oi)
5162 continue;
5163
5164 oi->type = IF_DEF_PARAMS (ifp)->type;
5165
5166 if (oi->state > ISM_Down)
5167 {
5168 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5169 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5170 }
5171 }
5172
5173 return CMD_SUCCESS;
5174}
5175
5176ALIAS (no_ip_ospf_network,
5177 no_ospf_network_cmd,
5178 "no ospf network",
5179 NO_STR
5180 "OSPF interface commands\n"
5181 "Network type\n")
5182
5183DEFUN (ip_ospf_priority,
5184 ip_ospf_priority_addr_cmd,
5185 "ip ospf priority <0-255> A.B.C.D",
5186 "IP Information\n"
5187 "OSPF interface commands\n"
5188 "Router priority\n"
5189 "Priority\n"
5190 "Address of interface")
5191{
5192 struct interface *ifp = vty->index;
5193 u_int32_t priority;
5194 struct route_node *rn;
5195 struct in_addr addr;
5196 int ret;
5197 struct ospf_if_params *params;
5198
5199 params = IF_DEF_PARAMS (ifp);
5200
5201 priority = strtol (argv[0], NULL, 10);
5202
5203 /* Router Priority range is <0-255>. */
5204 if (priority < 0 || priority > 255)
5205 {
5206 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5207 return CMD_WARNING;
5208 }
5209
5210 if (argc == 2)
5211 {
5212 ret = inet_aton(argv[1], &addr);
5213 if (!ret)
5214 {
5215 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5216 VTY_NEWLINE);
5217 return CMD_WARNING;
5218 }
5219
5220 params = ospf_get_if_params (ifp, addr);
5221 ospf_if_update_params (ifp, addr);
5222 }
5223
5224 SET_IF_PARAM (params, priority);
5225 params->priority = priority;
5226
5227 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5228 {
5229 struct ospf_interface *oi = rn->info;
5230
5231 if (!oi)
5232 continue;
5233
5234
5235 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5236 {
5237 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5238 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5239 }
5240 }
5241
5242 return CMD_SUCCESS;
5243}
5244
5245ALIAS (ip_ospf_priority,
5246 ip_ospf_priority_cmd,
5247 "ip ospf priority <0-255>",
5248 "IP Information\n"
5249 "OSPF interface commands\n"
5250 "Router priority\n"
5251 "Priority\n")
5252
5253ALIAS (ip_ospf_priority,
5254 ospf_priority_cmd,
5255 "ospf priority <0-255>",
5256 "OSPF interface commands\n"
5257 "Router priority\n"
5258 "Priority\n")
5259
5260DEFUN (no_ip_ospf_priority,
5261 no_ip_ospf_priority_addr_cmd,
5262 "no ip ospf priority A.B.C.D",
5263 NO_STR
5264 "IP Information\n"
5265 "OSPF interface commands\n"
5266 "Router priority\n"
5267 "Address of interface")
5268{
5269 struct interface *ifp = vty->index;
5270 struct route_node *rn;
5271 struct in_addr addr;
5272 int ret;
5273 struct ospf_if_params *params;
5274
5275 ifp = vty->index;
5276 params = IF_DEF_PARAMS (ifp);
5277
5278 if (argc == 1)
5279 {
5280 ret = inet_aton(argv[0], &addr);
5281 if (!ret)
5282 {
5283 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5284 VTY_NEWLINE);
5285 return CMD_WARNING;
5286 }
5287
5288 params = ospf_lookup_if_params (ifp, addr);
5289 if (params == NULL)
5290 return CMD_SUCCESS;
5291 }
5292
5293 UNSET_IF_PARAM (params, priority);
5294 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5295
5296 if (params != IF_DEF_PARAMS (ifp))
5297 {
5298 ospf_free_if_params (ifp, addr);
5299 ospf_if_update_params (ifp, addr);
5300 }
5301
5302 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5303 {
5304 struct ospf_interface *oi = rn->info;
5305
5306 if (!oi)
5307 continue;
5308
5309
5310 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5311 {
5312 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5313 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5314 }
5315 }
5316
5317 return CMD_SUCCESS;
5318}
5319
5320ALIAS (no_ip_ospf_priority,
5321 no_ip_ospf_priority_cmd,
5322 "no ip ospf priority",
5323 NO_STR
5324 "IP Information\n"
5325 "OSPF interface commands\n"
5326 "Router priority\n")
5327
5328ALIAS (no_ip_ospf_priority,
5329 no_ospf_priority_cmd,
5330 "no ospf priority",
5331 NO_STR
5332 "OSPF interface commands\n"
5333 "Router priority\n")
5334
5335DEFUN (ip_ospf_retransmit_interval,
5336 ip_ospf_retransmit_interval_addr_cmd,
5337 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5338 "IP Information\n"
5339 "OSPF interface commands\n"
5340 "Time between retransmitting lost link state advertisements\n"
5341 "Seconds\n"
5342 "Address of interface")
5343{
5344 struct interface *ifp = vty->index;
5345 u_int32_t seconds;
5346 struct in_addr addr;
5347 int ret;
5348 struct ospf_if_params *params;
5349
5350 params = IF_DEF_PARAMS (ifp);
5351 seconds = strtol (argv[0], NULL, 10);
5352
5353 /* Retransmit Interval range is <3-65535>. */
5354 if (seconds < 3 || seconds > 65535)
5355 {
5356 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5357 return CMD_WARNING;
5358 }
5359
5360
5361 if (argc == 2)
5362 {
5363 ret = inet_aton(argv[1], &addr);
5364 if (!ret)
5365 {
5366 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5367 VTY_NEWLINE);
5368 return CMD_WARNING;
5369 }
5370
5371 params = ospf_get_if_params (ifp, addr);
5372 ospf_if_update_params (ifp, addr);
5373 }
5374
5375 SET_IF_PARAM (params, retransmit_interval);
5376 params->retransmit_interval = seconds;
5377
5378 return CMD_SUCCESS;
5379}
5380
5381ALIAS (ip_ospf_retransmit_interval,
5382 ip_ospf_retransmit_interval_cmd,
5383 "ip ospf retransmit-interval <3-65535>",
5384 "IP Information\n"
5385 "OSPF interface commands\n"
5386 "Time between retransmitting lost link state advertisements\n"
5387 "Seconds\n")
5388
5389ALIAS (ip_ospf_retransmit_interval,
5390 ospf_retransmit_interval_cmd,
5391 "ospf retransmit-interval <3-65535>",
5392 "OSPF interface commands\n"
5393 "Time between retransmitting lost link state advertisements\n"
5394 "Seconds\n")
5395
5396DEFUN (no_ip_ospf_retransmit_interval,
5397 no_ip_ospf_retransmit_interval_addr_cmd,
5398 "no ip ospf retransmit-interval A.B.C.D",
5399 NO_STR
5400 "IP Information\n"
5401 "OSPF interface commands\n"
5402 "Time between retransmitting lost link state advertisements\n"
5403 "Address of interface")
5404{
5405 struct interface *ifp = vty->index;
5406 struct in_addr addr;
5407 int ret;
5408 struct ospf_if_params *params;
5409
5410 ifp = vty->index;
5411 params = IF_DEF_PARAMS (ifp);
5412
5413 if (argc == 1)
5414 {
5415 ret = inet_aton(argv[0], &addr);
5416 if (!ret)
5417 {
5418 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5419 VTY_NEWLINE);
5420 return CMD_WARNING;
5421 }
5422
5423 params = ospf_lookup_if_params (ifp, addr);
5424 if (params == NULL)
5425 return CMD_SUCCESS;
5426 }
5427
5428 UNSET_IF_PARAM (params, retransmit_interval);
5429 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5430
5431 if (params != IF_DEF_PARAMS (ifp))
5432 {
5433 ospf_free_if_params (ifp, addr);
5434 ospf_if_update_params (ifp, addr);
5435 }
5436
5437 return CMD_SUCCESS;
5438}
5439
5440ALIAS (no_ip_ospf_retransmit_interval,
5441 no_ip_ospf_retransmit_interval_cmd,
5442 "no ip ospf retransmit-interval",
5443 NO_STR
5444 "IP Information\n"
5445 "OSPF interface commands\n"
5446 "Time between retransmitting lost link state advertisements\n")
5447
5448ALIAS (no_ip_ospf_retransmit_interval,
5449 no_ospf_retransmit_interval_cmd,
5450 "no ospf retransmit-interval",
5451 NO_STR
5452 "OSPF interface commands\n"
5453 "Time between retransmitting lost link state advertisements\n")
5454
5455DEFUN (ip_ospf_transmit_delay,
5456 ip_ospf_transmit_delay_addr_cmd,
5457 "ip ospf transmit-delay <1-65535> A.B.C.D",
5458 "IP Information\n"
5459 "OSPF interface commands\n"
5460 "Link state transmit delay\n"
5461 "Seconds\n"
5462 "Address of interface")
5463{
5464 struct interface *ifp = vty->index;
5465 u_int32_t seconds;
5466 struct in_addr addr;
5467 int ret;
5468 struct ospf_if_params *params;
5469
5470 params = IF_DEF_PARAMS (ifp);
5471 seconds = strtol (argv[0], NULL, 10);
5472
5473 /* Transmit Delay range is <1-65535>. */
5474 if (seconds < 1 || seconds > 65535)
5475 {
5476 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5477 return CMD_WARNING;
5478 }
5479
5480 if (argc == 2)
5481 {
5482 ret = inet_aton(argv[1], &addr);
5483 if (!ret)
5484 {
5485 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5486 VTY_NEWLINE);
5487 return CMD_WARNING;
5488 }
5489
5490 params = ospf_get_if_params (ifp, addr);
5491 ospf_if_update_params (ifp, addr);
5492 }
5493
5494 SET_IF_PARAM (params, transmit_delay);
5495 params->transmit_delay = seconds;
5496
5497 return CMD_SUCCESS;
5498}
5499
5500ALIAS (ip_ospf_transmit_delay,
5501 ip_ospf_transmit_delay_cmd,
5502 "ip ospf transmit-delay <1-65535>",
5503 "IP Information\n"
5504 "OSPF interface commands\n"
5505 "Link state transmit delay\n"
5506 "Seconds\n")
5507
5508ALIAS (ip_ospf_transmit_delay,
5509 ospf_transmit_delay_cmd,
5510 "ospf transmit-delay <1-65535>",
5511 "OSPF interface commands\n"
5512 "Link state transmit delay\n"
5513 "Seconds\n")
5514
5515DEFUN (no_ip_ospf_transmit_delay,
5516 no_ip_ospf_transmit_delay_addr_cmd,
5517 "no ip ospf transmit-delay A.B.C.D",
5518 NO_STR
5519 "IP Information\n"
5520 "OSPF interface commands\n"
5521 "Link state transmit delay\n"
5522 "Address of interface")
5523{
5524 struct interface *ifp = vty->index;
5525 struct in_addr addr;
5526 int ret;
5527 struct ospf_if_params *params;
5528
5529 ifp = vty->index;
5530 params = IF_DEF_PARAMS (ifp);
5531
5532 if (argc == 1)
5533 {
5534 ret = inet_aton(argv[0], &addr);
5535 if (!ret)
5536 {
5537 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5538 VTY_NEWLINE);
5539 return CMD_WARNING;
5540 }
5541
5542 params = ospf_lookup_if_params (ifp, addr);
5543 if (params == NULL)
5544 return CMD_SUCCESS;
5545 }
5546
5547 UNSET_IF_PARAM (params, transmit_delay);
5548 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5549
5550 if (params != IF_DEF_PARAMS (ifp))
5551 {
5552 ospf_free_if_params (ifp, addr);
5553 ospf_if_update_params (ifp, addr);
5554 }
5555
5556 return CMD_SUCCESS;
5557}
5558
5559ALIAS (no_ip_ospf_transmit_delay,
5560 no_ip_ospf_transmit_delay_cmd,
5561 "no ip ospf transmit-delay",
5562 NO_STR
5563 "IP Information\n"
5564 "OSPF interface commands\n"
5565 "Link state transmit delay\n")
5566
5567ALIAS (no_ip_ospf_transmit_delay,
5568 no_ospf_transmit_delay_cmd,
5569 "no ospf transmit-delay",
5570 NO_STR
5571 "OSPF interface commands\n"
5572 "Link state transmit delay\n")
5573
5574
5575DEFUN (ospf_redistribute_source_metric_type,
5576 ospf_redistribute_source_metric_type_routemap_cmd,
5577 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5578 "Redistribute information from another routing protocol\n"
5579 "Kernel routes\n"
5580 "Connected\n"
5581 "Static routes\n"
5582 "Routing Information Protocol (RIP)\n"
5583 "Border Gateway Protocol (BGP)\n"
5584 "Metric for redistributed routes\n"
5585 "OSPF default metric\n"
5586 "OSPF exterior metric type for redistributed routes\n"
5587 "Set OSPF External Type 1 metrics\n"
5588 "Set OSPF External Type 2 metrics\n"
5589 "Route map reference\n"
5590 "Pointer to route-map entries\n")
5591{
paul020709f2003-04-04 02:44:16 +00005592 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005593 int source;
5594 int type = -1;
5595 int metric = -1;
5596
5597 /* Get distribute source. */
5598 if (!str2distribute_source (argv[0], &source))
5599 return CMD_WARNING;
5600
5601 /* Get metric value. */
5602 if (argc >= 2)
5603 if (!str2metric (argv[1], &metric))
5604 return CMD_WARNING;
5605
5606 /* Get metric type. */
5607 if (argc >= 3)
5608 if (!str2metric_type (argv[2], &type))
5609 return CMD_WARNING;
5610
5611 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005612 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005613 else
paul020709f2003-04-04 02:44:16 +00005614 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005615
paul020709f2003-04-04 02:44:16 +00005616 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005617}
5618
5619ALIAS (ospf_redistribute_source_metric_type,
5620 ospf_redistribute_source_metric_type_cmd,
5621 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5622 "Redistribute information from another routing protocol\n"
5623 "Kernel routes\n"
5624 "Connected\n"
5625 "Static routes\n"
5626 "Routing Information Protocol (RIP)\n"
5627 "Border Gateway Protocol (BGP)\n"
5628 "Metric for redistributed routes\n"
5629 "OSPF default metric\n"
5630 "OSPF exterior metric type for redistributed routes\n"
5631 "Set OSPF External Type 1 metrics\n"
5632 "Set OSPF External Type 2 metrics\n")
5633
5634ALIAS (ospf_redistribute_source_metric_type,
5635 ospf_redistribute_source_metric_cmd,
5636 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5637 "Redistribute information from another routing protocol\n"
5638 "Kernel routes\n"
5639 "Connected\n"
5640 "Static routes\n"
5641 "Routing Information Protocol (RIP)\n"
5642 "Border Gateway Protocol (BGP)\n"
5643 "Metric for redistributed routes\n"
5644 "OSPF default metric\n")
5645
5646DEFUN (ospf_redistribute_source_type_metric,
5647 ospf_redistribute_source_type_metric_routemap_cmd,
5648 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5649 "Redistribute information from another routing protocol\n"
5650 "Kernel routes\n"
5651 "Connected\n"
5652 "Static routes\n"
5653 "Routing Information Protocol (RIP)\n"
5654 "Border Gateway Protocol (BGP)\n"
5655 "OSPF exterior metric type for redistributed routes\n"
5656 "Set OSPF External Type 1 metrics\n"
5657 "Set OSPF External Type 2 metrics\n"
5658 "Metric for redistributed routes\n"
5659 "OSPF default metric\n"
5660 "Route map reference\n"
5661 "Pointer to route-map entries\n")
5662{
paul020709f2003-04-04 02:44:16 +00005663 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005664 int source;
5665 int type = -1;
5666 int metric = -1;
5667
5668 /* Get distribute source. */
5669 if (!str2distribute_source (argv[0], &source))
5670 return CMD_WARNING;
5671
5672 /* Get metric value. */
5673 if (argc >= 2)
5674 if (!str2metric_type (argv[1], &type))
5675 return CMD_WARNING;
5676
5677 /* Get metric type. */
5678 if (argc >= 3)
5679 if (!str2metric (argv[2], &metric))
5680 return CMD_WARNING;
5681
5682 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005683 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005684 else
paul020709f2003-04-04 02:44:16 +00005685 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005686
paul020709f2003-04-04 02:44:16 +00005687 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005688}
5689
5690ALIAS (ospf_redistribute_source_type_metric,
5691 ospf_redistribute_source_type_metric_cmd,
5692 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5693 "Redistribute information from another routing protocol\n"
5694 "Kernel routes\n"
5695 "Connected\n"
5696 "Static routes\n"
5697 "Routing Information Protocol (RIP)\n"
5698 "Border Gateway Protocol (BGP)\n"
5699 "OSPF exterior metric type for redistributed routes\n"
5700 "Set OSPF External Type 1 metrics\n"
5701 "Set OSPF External Type 2 metrics\n"
5702 "Metric for redistributed routes\n"
5703 "OSPF default metric\n")
5704
5705ALIAS (ospf_redistribute_source_type_metric,
5706 ospf_redistribute_source_type_cmd,
5707 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5708 "Redistribute information from another routing protocol\n"
5709 "Kernel routes\n"
5710 "Connected\n"
5711 "Static routes\n"
5712 "Routing Information Protocol (RIP)\n"
5713 "Border Gateway Protocol (BGP)\n"
5714 "OSPF exterior metric type for redistributed routes\n"
5715 "Set OSPF External Type 1 metrics\n"
5716 "Set OSPF External Type 2 metrics\n")
5717
5718ALIAS (ospf_redistribute_source_type_metric,
5719 ospf_redistribute_source_cmd,
5720 "redistribute (kernel|connected|static|rip|bgp)",
5721 "Redistribute information from another routing protocol\n"
5722 "Kernel routes\n"
5723 "Connected\n"
5724 "Static routes\n"
5725 "Routing Information Protocol (RIP)\n"
5726 "Border Gateway Protocol (BGP)\n")
5727
5728DEFUN (ospf_redistribute_source_metric_routemap,
5729 ospf_redistribute_source_metric_routemap_cmd,
5730 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5731 "Redistribute information from another routing protocol\n"
5732 "Kernel routes\n"
5733 "Connected\n"
5734 "Static routes\n"
5735 "Routing Information Protocol (RIP)\n"
5736 "Border Gateway Protocol (BGP)\n"
5737 "Metric for redistributed routes\n"
5738 "OSPF default metric\n"
5739 "Route map reference\n"
5740 "Pointer to route-map entries\n")
5741{
paul020709f2003-04-04 02:44:16 +00005742 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005743 int source;
5744 int metric = -1;
5745
5746 /* Get distribute source. */
5747 if (!str2distribute_source (argv[0], &source))
5748 return CMD_WARNING;
5749
5750 /* Get metric value. */
5751 if (argc >= 2)
5752 if (!str2metric (argv[1], &metric))
5753 return CMD_WARNING;
5754
5755 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005756 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005757 else
paul020709f2003-04-04 02:44:16 +00005758 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005759
paul020709f2003-04-04 02:44:16 +00005760 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005761}
5762
5763DEFUN (ospf_redistribute_source_type_routemap,
5764 ospf_redistribute_source_type_routemap_cmd,
5765 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5766 "Redistribute information from another routing protocol\n"
5767 "Kernel routes\n"
5768 "Connected\n"
5769 "Static routes\n"
5770 "Routing Information Protocol (RIP)\n"
5771 "Border Gateway Protocol (BGP)\n"
5772 "OSPF exterior metric type for redistributed routes\n"
5773 "Set OSPF External Type 1 metrics\n"
5774 "Set OSPF External Type 2 metrics\n"
5775 "Route map reference\n"
5776 "Pointer to route-map entries\n")
5777{
paul020709f2003-04-04 02:44:16 +00005778 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005779 int source;
5780 int type = -1;
5781
5782 /* Get distribute source. */
5783 if (!str2distribute_source (argv[0], &source))
5784 return CMD_WARNING;
5785
5786 /* Get metric value. */
5787 if (argc >= 2)
5788 if (!str2metric_type (argv[1], &type))
5789 return CMD_WARNING;
5790
5791 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005792 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005793 else
paul020709f2003-04-04 02:44:16 +00005794 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005795
paul020709f2003-04-04 02:44:16 +00005796 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005797}
5798
5799DEFUN (ospf_redistribute_source_routemap,
5800 ospf_redistribute_source_routemap_cmd,
5801 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5802 "Redistribute information from another routing protocol\n"
5803 "Kernel routes\n"
5804 "Connected\n"
5805 "Static routes\n"
5806 "Routing Information Protocol (RIP)\n"
5807 "Border Gateway Protocol (BGP)\n"
5808 "Route map reference\n"
5809 "Pointer to route-map entries\n")
5810{
paul020709f2003-04-04 02:44:16 +00005811 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005812 int source;
5813
5814 /* Get distribute source. */
5815 if (!str2distribute_source (argv[0], &source))
5816 return CMD_WARNING;
5817
5818 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005819 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005820 else
paul020709f2003-04-04 02:44:16 +00005821 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005822
paul020709f2003-04-04 02:44:16 +00005823 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005824}
5825
5826DEFUN (no_ospf_redistribute_source,
5827 no_ospf_redistribute_source_cmd,
5828 "no redistribute (kernel|connected|static|rip|bgp)",
5829 NO_STR
5830 "Redistribute information from another routing protocol\n"
5831 "Kernel routes\n"
5832 "Connected\n"
5833 "Static routes\n"
5834 "Routing Information Protocol (RIP)\n"
5835 "Border Gateway Protocol (BGP)\n")
5836{
paul020709f2003-04-04 02:44:16 +00005837 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005838 int source;
5839
5840 if (!str2distribute_source (argv[0], &source))
5841 return CMD_WARNING;
5842
paul020709f2003-04-04 02:44:16 +00005843 ospf_routemap_unset (ospf, source);
5844 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005845}
5846
5847DEFUN (ospf_distribute_list_out,
5848 ospf_distribute_list_out_cmd,
5849 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5850 "Filter networks in routing updates\n"
5851 "Access-list name\n"
5852 OUT_STR
5853 "Kernel routes\n"
5854 "Connected\n"
5855 "Static routes\n"
5856 "Routing Information Protocol (RIP)\n"
5857 "Border Gateway Protocol (BGP)\n")
5858{
paul68980082003-03-25 05:07:42 +00005859 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005860 int source;
5861
5862 /* Get distribute source. */
5863 if (!str2distribute_source (argv[1], &source))
5864 return CMD_WARNING;
5865
paul68980082003-03-25 05:07:42 +00005866 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005867}
5868
5869DEFUN (no_ospf_distribute_list_out,
5870 no_ospf_distribute_list_out_cmd,
5871 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5872 NO_STR
5873 "Filter networks in routing updates\n"
5874 "Access-list name\n"
5875 OUT_STR
5876 "Kernel routes\n"
5877 "Connected\n"
5878 "Static routes\n"
5879 "Routing Information Protocol (RIP)\n"
5880 "Border Gateway Protocol (BGP)\n")
5881{
paul68980082003-03-25 05:07:42 +00005882 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005883 int source;
5884
5885 if (!str2distribute_source (argv[1], &source))
5886 return CMD_WARNING;
5887
paul68980082003-03-25 05:07:42 +00005888 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005889}
5890
5891/* Default information originate. */
5892DEFUN (ospf_default_information_originate_metric_type_routemap,
5893 ospf_default_information_originate_metric_type_routemap_cmd,
5894 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5895 "Control distribution of default information\n"
5896 "Distribute a default route\n"
5897 "OSPF default metric\n"
5898 "OSPF metric\n"
5899 "OSPF metric type for default routes\n"
5900 "Set OSPF External Type 1 metrics\n"
5901 "Set OSPF External Type 2 metrics\n"
5902 "Route map reference\n"
5903 "Pointer to route-map entries\n")
5904{
paul020709f2003-04-04 02:44:16 +00005905 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005906 int type = -1;
5907 int metric = -1;
5908
5909 /* Get metric value. */
5910 if (argc >= 1)
5911 if (!str2metric (argv[0], &metric))
5912 return CMD_WARNING;
5913
5914 /* Get metric type. */
5915 if (argc >= 2)
5916 if (!str2metric_type (argv[1], &type))
5917 return CMD_WARNING;
5918
5919 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005920 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005921 else
paul020709f2003-04-04 02:44:16 +00005922 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005923
paul020709f2003-04-04 02:44:16 +00005924 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5925 type, metric);
paul718e3742002-12-13 20:15:29 +00005926}
5927
5928ALIAS (ospf_default_information_originate_metric_type_routemap,
5929 ospf_default_information_originate_metric_type_cmd,
5930 "default-information originate metric <0-16777214> metric-type (1|2)",
5931 "Control distribution of default information\n"
5932 "Distribute a default route\n"
5933 "OSPF default metric\n"
5934 "OSPF metric\n"
5935 "OSPF metric type for default routes\n"
5936 "Set OSPF External Type 1 metrics\n"
5937 "Set OSPF External Type 2 metrics\n")
5938
5939ALIAS (ospf_default_information_originate_metric_type_routemap,
5940 ospf_default_information_originate_metric_cmd,
5941 "default-information originate metric <0-16777214>",
5942 "Control distribution of default information\n"
5943 "Distribute a default route\n"
5944 "OSPF default metric\n"
5945 "OSPF metric\n")
5946
5947ALIAS (ospf_default_information_originate_metric_type_routemap,
5948 ospf_default_information_originate_cmd,
5949 "default-information originate",
5950 "Control distribution of default information\n"
5951 "Distribute a default route\n")
5952
5953/* Default information originate. */
5954DEFUN (ospf_default_information_originate_metric_routemap,
5955 ospf_default_information_originate_metric_routemap_cmd,
5956 "default-information originate metric <0-16777214> route-map WORD",
5957 "Control distribution of default information\n"
5958 "Distribute a default route\n"
5959 "OSPF default metric\n"
5960 "OSPF metric\n"
5961 "Route map reference\n"
5962 "Pointer to route-map entries\n")
5963{
paul020709f2003-04-04 02:44:16 +00005964 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005965 int metric = -1;
5966
5967 /* Get metric value. */
5968 if (argc >= 1)
5969 if (!str2metric (argv[0], &metric))
5970 return CMD_WARNING;
5971
5972 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005973 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005974 else
paul020709f2003-04-04 02:44:16 +00005975 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005976
paul020709f2003-04-04 02:44:16 +00005977 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5978 -1, metric);
paul718e3742002-12-13 20:15:29 +00005979}
5980
5981/* Default information originate. */
5982DEFUN (ospf_default_information_originate_routemap,
5983 ospf_default_information_originate_routemap_cmd,
5984 "default-information originate route-map WORD",
5985 "Control distribution of default information\n"
5986 "Distribute a default route\n"
5987 "Route map reference\n"
5988 "Pointer to route-map entries\n")
5989{
paul020709f2003-04-04 02:44:16 +00005990 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005991
paul020709f2003-04-04 02:44:16 +00005992 if (argc == 1)
5993 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5994 else
5995 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5996
5997 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005998}
5999
6000DEFUN (ospf_default_information_originate_type_metric_routemap,
6001 ospf_default_information_originate_type_metric_routemap_cmd,
6002 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6003 "Control distribution of default information\n"
6004 "Distribute a default route\n"
6005 "OSPF metric type for default routes\n"
6006 "Set OSPF External Type 1 metrics\n"
6007 "Set OSPF External Type 2 metrics\n"
6008 "OSPF default metric\n"
6009 "OSPF metric\n"
6010 "Route map reference\n"
6011 "Pointer to route-map entries\n")
6012{
paul020709f2003-04-04 02:44:16 +00006013 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006014 int type = -1;
6015 int metric = -1;
6016
6017 /* Get metric type. */
6018 if (argc >= 1)
6019 if (!str2metric_type (argv[0], &type))
6020 return CMD_WARNING;
6021
6022 /* Get metric value. */
6023 if (argc >= 2)
6024 if (!str2metric (argv[1], &metric))
6025 return CMD_WARNING;
6026
6027 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006028 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006029 else
paul020709f2003-04-04 02:44:16 +00006030 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006031
paul020709f2003-04-04 02:44:16 +00006032 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6033 type, metric);
paul718e3742002-12-13 20:15:29 +00006034}
6035
6036ALIAS (ospf_default_information_originate_type_metric_routemap,
6037 ospf_default_information_originate_type_metric_cmd,
6038 "default-information originate metric-type (1|2) metric <0-16777214>",
6039 "Control distribution of default information\n"
6040 "Distribute a default route\n"
6041 "OSPF metric type for default routes\n"
6042 "Set OSPF External Type 1 metrics\n"
6043 "Set OSPF External Type 2 metrics\n"
6044 "OSPF default metric\n"
6045 "OSPF metric\n")
6046
6047ALIAS (ospf_default_information_originate_type_metric_routemap,
6048 ospf_default_information_originate_type_cmd,
6049 "default-information originate metric-type (1|2)",
6050 "Control distribution of default information\n"
6051 "Distribute a default route\n"
6052 "OSPF metric type for default routes\n"
6053 "Set OSPF External Type 1 metrics\n"
6054 "Set OSPF External Type 2 metrics\n")
6055
6056DEFUN (ospf_default_information_originate_type_routemap,
6057 ospf_default_information_originate_type_routemap_cmd,
6058 "default-information originate metric-type (1|2) route-map WORD",
6059 "Control distribution of default information\n"
6060 "Distribute a default route\n"
6061 "OSPF metric type for default routes\n"
6062 "Set OSPF External Type 1 metrics\n"
6063 "Set OSPF External Type 2 metrics\n"
6064 "Route map reference\n"
6065 "Pointer to route-map entries\n")
6066{
paul020709f2003-04-04 02:44:16 +00006067 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006068 int type = -1;
6069
6070 /* Get metric type. */
6071 if (argc >= 1)
6072 if (!str2metric_type (argv[0], &type))
6073 return CMD_WARNING;
6074
6075 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006076 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006077 else
paul020709f2003-04-04 02:44:16 +00006078 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006079
paul020709f2003-04-04 02:44:16 +00006080 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6081 type, -1);
paul718e3742002-12-13 20:15:29 +00006082}
6083
6084DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6085 ospf_default_information_originate_always_metric_type_routemap_cmd,
6086 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6087 "Control distribution of default information\n"
6088 "Distribute a default route\n"
6089 "Always advertise default route\n"
6090 "OSPF default metric\n"
6091 "OSPF metric\n"
6092 "OSPF metric type for default routes\n"
6093 "Set OSPF External Type 1 metrics\n"
6094 "Set OSPF External Type 2 metrics\n"
6095 "Route map reference\n"
6096 "Pointer to route-map entries\n")
6097{
paul020709f2003-04-04 02:44:16 +00006098 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006099 int type = -1;
6100 int metric = -1;
6101
6102 /* Get metric value. */
6103 if (argc >= 1)
6104 if (!str2metric (argv[0], &metric))
6105 return CMD_WARNING;
6106
6107 /* Get metric type. */
6108 if (argc >= 2)
6109 if (!str2metric_type (argv[1], &type))
6110 return CMD_WARNING;
6111
6112 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006113 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006114 else
paul020709f2003-04-04 02:44:16 +00006115 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006116
paul020709f2003-04-04 02:44:16 +00006117 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006118 type, metric);
6119}
6120
6121ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6122 ospf_default_information_originate_always_metric_type_cmd,
6123 "default-information originate always metric <0-16777214> metric-type (1|2)",
6124 "Control distribution of default information\n"
6125 "Distribute a default route\n"
6126 "Always advertise default route\n"
6127 "OSPF default metric\n"
6128 "OSPF metric\n"
6129 "OSPF metric type for default routes\n"
6130 "Set OSPF External Type 1 metrics\n"
6131 "Set OSPF External Type 2 metrics\n")
6132
6133ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6134 ospf_default_information_originate_always_metric_cmd,
6135 "default-information originate always metric <0-16777214>",
6136 "Control distribution of default information\n"
6137 "Distribute a default route\n"
6138 "Always advertise default route\n"
6139 "OSPF default metric\n"
6140 "OSPF metric\n"
6141 "OSPF metric type for default routes\n")
6142
6143ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6144 ospf_default_information_originate_always_cmd,
6145 "default-information originate always",
6146 "Control distribution of default information\n"
6147 "Distribute a default route\n"
6148 "Always advertise default route\n")
6149
6150DEFUN (ospf_default_information_originate_always_metric_routemap,
6151 ospf_default_information_originate_always_metric_routemap_cmd,
6152 "default-information originate always metric <0-16777214> route-map WORD",
6153 "Control distribution of default information\n"
6154 "Distribute a default route\n"
6155 "Always advertise default route\n"
6156 "OSPF default metric\n"
6157 "OSPF metric\n"
6158 "Route map reference\n"
6159 "Pointer to route-map entries\n")
6160{
paul020709f2003-04-04 02:44:16 +00006161 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006162 int metric = -1;
6163
6164 /* Get metric value. */
6165 if (argc >= 1)
6166 if (!str2metric (argv[0], &metric))
6167 return CMD_WARNING;
6168
6169 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006170 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006171 else
paul020709f2003-04-04 02:44:16 +00006172 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006173
paul020709f2003-04-04 02:44:16 +00006174 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6175 -1, metric);
paul718e3742002-12-13 20:15:29 +00006176}
6177
6178DEFUN (ospf_default_information_originate_always_routemap,
6179 ospf_default_information_originate_always_routemap_cmd,
6180 "default-information originate always route-map WORD",
6181 "Control distribution of default information\n"
6182 "Distribute a default route\n"
6183 "Always advertise default route\n"
6184 "Route map reference\n"
6185 "Pointer to route-map entries\n")
6186{
paul020709f2003-04-04 02:44:16 +00006187 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006188
paul020709f2003-04-04 02:44:16 +00006189 if (argc == 1)
6190 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6191 else
6192 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6193
6194 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006195}
6196
6197DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6198 ospf_default_information_originate_always_type_metric_routemap_cmd,
6199 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6200 "Control distribution of default information\n"
6201 "Distribute a default route\n"
6202 "Always advertise default route\n"
6203 "OSPF metric type for default routes\n"
6204 "Set OSPF External Type 1 metrics\n"
6205 "Set OSPF External Type 2 metrics\n"
6206 "OSPF default metric\n"
6207 "OSPF metric\n"
6208 "Route map reference\n"
6209 "Pointer to route-map entries\n")
6210{
paul020709f2003-04-04 02:44:16 +00006211 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006212 int type = -1;
6213 int metric = -1;
6214
6215 /* Get metric type. */
6216 if (argc >= 1)
6217 if (!str2metric_type (argv[0], &type))
6218 return CMD_WARNING;
6219
6220 /* Get metric value. */
6221 if (argc >= 2)
6222 if (!str2metric (argv[1], &metric))
6223 return CMD_WARNING;
6224
6225 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006226 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006227 else
paul020709f2003-04-04 02:44:16 +00006228 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006229
paul020709f2003-04-04 02:44:16 +00006230 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006231 type, metric);
6232}
6233
6234ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6235 ospf_default_information_originate_always_type_metric_cmd,
6236 "default-information originate always metric-type (1|2) metric <0-16777214>",
6237 "Control distribution of default information\n"
6238 "Distribute a default route\n"
6239 "Always advertise default route\n"
6240 "OSPF metric type for default routes\n"
6241 "Set OSPF External Type 1 metrics\n"
6242 "Set OSPF External Type 2 metrics\n"
6243 "OSPF default metric\n"
6244 "OSPF metric\n")
6245
6246ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6247 ospf_default_information_originate_always_type_cmd,
6248 "default-information originate always metric-type (1|2)",
6249 "Control distribution of default information\n"
6250 "Distribute a default route\n"
6251 "Always advertise default route\n"
6252 "OSPF metric type for default routes\n"
6253 "Set OSPF External Type 1 metrics\n"
6254 "Set OSPF External Type 2 metrics\n")
6255
6256DEFUN (ospf_default_information_originate_always_type_routemap,
6257 ospf_default_information_originate_always_type_routemap_cmd,
6258 "default-information originate always metric-type (1|2) route-map WORD",
6259 "Control distribution of default information\n"
6260 "Distribute a default route\n"
6261 "Always advertise default route\n"
6262 "OSPF metric type for default routes\n"
6263 "Set OSPF External Type 1 metrics\n"
6264 "Set OSPF External Type 2 metrics\n"
6265 "Route map reference\n"
6266 "Pointer to route-map entries\n")
6267{
paul020709f2003-04-04 02:44:16 +00006268 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006269 int type = -1;
6270
6271 /* Get metric type. */
6272 if (argc >= 1)
6273 if (!str2metric_type (argv[0], &type))
6274 return CMD_WARNING;
6275
6276 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006277 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006278 else
paul020709f2003-04-04 02:44:16 +00006279 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006280
paul020709f2003-04-04 02:44:16 +00006281 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006282 type, -1);
6283}
6284
6285DEFUN (no_ospf_default_information_originate,
6286 no_ospf_default_information_originate_cmd,
6287 "no default-information originate",
6288 NO_STR
6289 "Control distribution of default information\n"
6290 "Distribute a default route\n")
6291{
paul68980082003-03-25 05:07:42 +00006292 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006293 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006294
6295 p.family = AF_INET;
6296 p.prefix.s_addr = 0;
6297 p.prefixlen = 0;
6298
ajs5339cfd2005-09-19 13:28:05 +00006299 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006300
6301 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6302 ospf_external_info_delete (DEFAULT_ROUTE, p);
6303 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6304 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6305 }
6306
paul020709f2003-04-04 02:44:16 +00006307 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6308 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006309}
6310
6311DEFUN (ospf_default_metric,
6312 ospf_default_metric_cmd,
6313 "default-metric <0-16777214>",
6314 "Set metric of redistributed routes\n"
6315 "Default metric\n")
6316{
paul68980082003-03-25 05:07:42 +00006317 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006318 int metric = -1;
6319
6320 if (!str2metric (argv[0], &metric))
6321 return CMD_WARNING;
6322
paul68980082003-03-25 05:07:42 +00006323 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006324
6325 return CMD_SUCCESS;
6326}
6327
6328DEFUN (no_ospf_default_metric,
6329 no_ospf_default_metric_cmd,
6330 "no default-metric",
6331 NO_STR
6332 "Set metric of redistributed routes\n")
6333{
paul68980082003-03-25 05:07:42 +00006334 struct ospf *ospf = vty->index;
6335
6336 ospf->default_metric = -1;
6337
paul718e3742002-12-13 20:15:29 +00006338 return CMD_SUCCESS;
6339}
6340
6341ALIAS (no_ospf_default_metric,
6342 no_ospf_default_metric_val_cmd,
6343 "no default-metric <0-16777214>",
6344 NO_STR
6345 "Set metric of redistributed routes\n"
6346 "Default metric\n")
6347
6348DEFUN (ospf_distance,
6349 ospf_distance_cmd,
6350 "distance <1-255>",
6351 "Define an administrative distance\n"
6352 "OSPF Administrative distance\n")
6353{
paul68980082003-03-25 05:07:42 +00006354 struct ospf *ospf = vty->index;
6355
6356 ospf->distance_all = atoi (argv[0]);
6357
paul718e3742002-12-13 20:15:29 +00006358 return CMD_SUCCESS;
6359}
6360
6361DEFUN (no_ospf_distance,
6362 no_ospf_distance_cmd,
6363 "no distance <1-255>",
6364 NO_STR
6365 "Define an administrative distance\n"
6366 "OSPF Administrative distance\n")
6367{
paul68980082003-03-25 05:07:42 +00006368 struct ospf *ospf = vty->index;
6369
6370 ospf->distance_all = 0;
6371
paul718e3742002-12-13 20:15:29 +00006372 return CMD_SUCCESS;
6373}
6374
6375DEFUN (no_ospf_distance_ospf,
6376 no_ospf_distance_ospf_cmd,
6377 "no distance ospf",
6378 NO_STR
6379 "Define an administrative distance\n"
6380 "OSPF Administrative distance\n"
6381 "OSPF Distance\n")
6382{
paul68980082003-03-25 05:07:42 +00006383 struct ospf *ospf = vty->index;
6384
6385 ospf->distance_intra = 0;
6386 ospf->distance_inter = 0;
6387 ospf->distance_external = 0;
6388
paul718e3742002-12-13 20:15:29 +00006389 return CMD_SUCCESS;
6390}
6391
6392DEFUN (ospf_distance_ospf_intra,
6393 ospf_distance_ospf_intra_cmd,
6394 "distance ospf intra-area <1-255>",
6395 "Define an administrative distance\n"
6396 "OSPF Administrative distance\n"
6397 "Intra-area routes\n"
6398 "Distance for intra-area routes\n")
6399{
paul68980082003-03-25 05:07:42 +00006400 struct ospf *ospf = vty->index;
6401
6402 ospf->distance_intra = atoi (argv[0]);
6403
paul718e3742002-12-13 20:15:29 +00006404 return CMD_SUCCESS;
6405}
6406
6407DEFUN (ospf_distance_ospf_intra_inter,
6408 ospf_distance_ospf_intra_inter_cmd,
6409 "distance ospf intra-area <1-255> inter-area <1-255>",
6410 "Define an administrative distance\n"
6411 "OSPF Administrative distance\n"
6412 "Intra-area routes\n"
6413 "Distance for intra-area routes\n"
6414 "Inter-area routes\n"
6415 "Distance for inter-area routes\n")
6416{
paul68980082003-03-25 05:07:42 +00006417 struct ospf *ospf = vty->index;
6418
6419 ospf->distance_intra = atoi (argv[0]);
6420 ospf->distance_inter = atoi (argv[1]);
6421
paul718e3742002-12-13 20:15:29 +00006422 return CMD_SUCCESS;
6423}
6424
6425DEFUN (ospf_distance_ospf_intra_external,
6426 ospf_distance_ospf_intra_external_cmd,
6427 "distance ospf intra-area <1-255> external <1-255>",
6428 "Define an administrative distance\n"
6429 "OSPF Administrative distance\n"
6430 "Intra-area routes\n"
6431 "Distance for intra-area routes\n"
6432 "External routes\n"
6433 "Distance for external routes\n")
6434{
paul68980082003-03-25 05:07:42 +00006435 struct ospf *ospf = vty->index;
6436
6437 ospf->distance_intra = atoi (argv[0]);
6438 ospf->distance_external = atoi (argv[1]);
6439
paul718e3742002-12-13 20:15:29 +00006440 return CMD_SUCCESS;
6441}
6442
6443DEFUN (ospf_distance_ospf_intra_inter_external,
6444 ospf_distance_ospf_intra_inter_external_cmd,
6445 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6446 "Define an administrative distance\n"
6447 "OSPF Administrative distance\n"
6448 "Intra-area routes\n"
6449 "Distance for intra-area routes\n"
6450 "Inter-area routes\n"
6451 "Distance for inter-area routes\n"
6452 "External routes\n"
6453 "Distance for external routes\n")
6454{
paul68980082003-03-25 05:07:42 +00006455 struct ospf *ospf = vty->index;
6456
6457 ospf->distance_intra = atoi (argv[0]);
6458 ospf->distance_inter = atoi (argv[1]);
6459 ospf->distance_external = atoi (argv[2]);
6460
paul718e3742002-12-13 20:15:29 +00006461 return CMD_SUCCESS;
6462}
6463
6464DEFUN (ospf_distance_ospf_intra_external_inter,
6465 ospf_distance_ospf_intra_external_inter_cmd,
6466 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6467 "Define an administrative distance\n"
6468 "OSPF Administrative distance\n"
6469 "Intra-area routes\n"
6470 "Distance for intra-area routes\n"
6471 "External routes\n"
6472 "Distance for external routes\n"
6473 "Inter-area routes\n"
6474 "Distance for inter-area routes\n")
6475{
paul68980082003-03-25 05:07:42 +00006476 struct ospf *ospf = vty->index;
6477
6478 ospf->distance_intra = atoi (argv[0]);
6479 ospf->distance_external = atoi (argv[1]);
6480 ospf->distance_inter = atoi (argv[2]);
6481
paul718e3742002-12-13 20:15:29 +00006482 return CMD_SUCCESS;
6483}
6484
6485DEFUN (ospf_distance_ospf_inter,
6486 ospf_distance_ospf_inter_cmd,
6487 "distance ospf inter-area <1-255>",
6488 "Define an administrative distance\n"
6489 "OSPF Administrative distance\n"
6490 "Inter-area routes\n"
6491 "Distance for inter-area routes\n")
6492{
paul68980082003-03-25 05:07:42 +00006493 struct ospf *ospf = vty->index;
6494
6495 ospf->distance_inter = atoi (argv[0]);
6496
paul718e3742002-12-13 20:15:29 +00006497 return CMD_SUCCESS;
6498}
6499
6500DEFUN (ospf_distance_ospf_inter_intra,
6501 ospf_distance_ospf_inter_intra_cmd,
6502 "distance ospf inter-area <1-255> intra-area <1-255>",
6503 "Define an administrative distance\n"
6504 "OSPF Administrative distance\n"
6505 "Inter-area routes\n"
6506 "Distance for inter-area routes\n"
6507 "Intra-area routes\n"
6508 "Distance for intra-area routes\n")
6509{
paul68980082003-03-25 05:07:42 +00006510 struct ospf *ospf = vty->index;
6511
6512 ospf->distance_inter = atoi (argv[0]);
6513 ospf->distance_intra = atoi (argv[1]);
6514
paul718e3742002-12-13 20:15:29 +00006515 return CMD_SUCCESS;
6516}
6517
6518DEFUN (ospf_distance_ospf_inter_external,
6519 ospf_distance_ospf_inter_external_cmd,
6520 "distance ospf inter-area <1-255> external <1-255>",
6521 "Define an administrative distance\n"
6522 "OSPF Administrative distance\n"
6523 "Inter-area routes\n"
6524 "Distance for inter-area routes\n"
6525 "External routes\n"
6526 "Distance for external routes\n")
6527{
paul68980082003-03-25 05:07:42 +00006528 struct ospf *ospf = vty->index;
6529
6530 ospf->distance_inter = atoi (argv[0]);
6531 ospf->distance_external = atoi (argv[1]);
6532
paul718e3742002-12-13 20:15:29 +00006533 return CMD_SUCCESS;
6534}
6535
6536DEFUN (ospf_distance_ospf_inter_intra_external,
6537 ospf_distance_ospf_inter_intra_external_cmd,
6538 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6539 "Define an administrative distance\n"
6540 "OSPF Administrative distance\n"
6541 "Inter-area routes\n"
6542 "Distance for inter-area routes\n"
6543 "Intra-area routes\n"
6544 "Distance for intra-area routes\n"
6545 "External routes\n"
6546 "Distance for external routes\n")
6547{
paul68980082003-03-25 05:07:42 +00006548 struct ospf *ospf = vty->index;
6549
6550 ospf->distance_inter = atoi (argv[0]);
6551 ospf->distance_intra = atoi (argv[1]);
6552 ospf->distance_external = atoi (argv[2]);
6553
paul718e3742002-12-13 20:15:29 +00006554 return CMD_SUCCESS;
6555}
6556
6557DEFUN (ospf_distance_ospf_inter_external_intra,
6558 ospf_distance_ospf_inter_external_intra_cmd,
6559 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6560 "Define an administrative distance\n"
6561 "OSPF Administrative distance\n"
6562 "Inter-area routes\n"
6563 "Distance for inter-area routes\n"
6564 "External routes\n"
6565 "Distance for external routes\n"
6566 "Intra-area routes\n"
6567 "Distance for intra-area routes\n")
6568{
paul68980082003-03-25 05:07:42 +00006569 struct ospf *ospf = vty->index;
6570
6571 ospf->distance_inter = atoi (argv[0]);
6572 ospf->distance_external = atoi (argv[1]);
6573 ospf->distance_intra = atoi (argv[2]);
6574
paul718e3742002-12-13 20:15:29 +00006575 return CMD_SUCCESS;
6576}
6577
6578DEFUN (ospf_distance_ospf_external,
6579 ospf_distance_ospf_external_cmd,
6580 "distance ospf external <1-255>",
6581 "Define an administrative distance\n"
6582 "OSPF Administrative distance\n"
6583 "External routes\n"
6584 "Distance for external routes\n")
6585{
paul68980082003-03-25 05:07:42 +00006586 struct ospf *ospf = vty->index;
6587
6588 ospf->distance_external = atoi (argv[0]);
6589
paul718e3742002-12-13 20:15:29 +00006590 return CMD_SUCCESS;
6591}
6592
6593DEFUN (ospf_distance_ospf_external_intra,
6594 ospf_distance_ospf_external_intra_cmd,
6595 "distance ospf external <1-255> intra-area <1-255>",
6596 "Define an administrative distance\n"
6597 "OSPF Administrative distance\n"
6598 "External routes\n"
6599 "Distance for external routes\n"
6600 "Intra-area routes\n"
6601 "Distance for intra-area routes\n")
6602{
paul68980082003-03-25 05:07:42 +00006603 struct ospf *ospf = vty->index;
6604
6605 ospf->distance_external = atoi (argv[0]);
6606 ospf->distance_intra = atoi (argv[1]);
6607
paul718e3742002-12-13 20:15:29 +00006608 return CMD_SUCCESS;
6609}
6610
6611DEFUN (ospf_distance_ospf_external_inter,
6612 ospf_distance_ospf_external_inter_cmd,
6613 "distance ospf external <1-255> inter-area <1-255>",
6614 "Define an administrative distance\n"
6615 "OSPF Administrative distance\n"
6616 "External routes\n"
6617 "Distance for external routes\n"
6618 "Inter-area routes\n"
6619 "Distance for inter-area routes\n")
6620{
paul68980082003-03-25 05:07:42 +00006621 struct ospf *ospf = vty->index;
6622
6623 ospf->distance_external = atoi (argv[0]);
6624 ospf->distance_inter = atoi (argv[1]);
6625
paul718e3742002-12-13 20:15:29 +00006626 return CMD_SUCCESS;
6627}
6628
6629DEFUN (ospf_distance_ospf_external_intra_inter,
6630 ospf_distance_ospf_external_intra_inter_cmd,
6631 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6632 "Define an administrative distance\n"
6633 "OSPF Administrative distance\n"
6634 "External routes\n"
6635 "Distance for external routes\n"
6636 "Intra-area routes\n"
6637 "Distance for intra-area routes\n"
6638 "Inter-area routes\n"
6639 "Distance for inter-area routes\n")
6640{
paul68980082003-03-25 05:07:42 +00006641 struct ospf *ospf = vty->index;
6642
6643 ospf->distance_external = atoi (argv[0]);
6644 ospf->distance_intra = atoi (argv[1]);
6645 ospf->distance_inter = atoi (argv[2]);
6646
paul718e3742002-12-13 20:15:29 +00006647 return CMD_SUCCESS;
6648}
6649
6650DEFUN (ospf_distance_ospf_external_inter_intra,
6651 ospf_distance_ospf_external_inter_intra_cmd,
6652 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6653 "Define an administrative distance\n"
6654 "OSPF Administrative distance\n"
6655 "External routes\n"
6656 "Distance for external routes\n"
6657 "Inter-area routes\n"
6658 "Distance for inter-area routes\n"
6659 "Intra-area routes\n"
6660 "Distance for intra-area routes\n")
6661{
paul68980082003-03-25 05:07:42 +00006662 struct ospf *ospf = vty->index;
6663
6664 ospf->distance_external = atoi (argv[0]);
6665 ospf->distance_inter = atoi (argv[1]);
6666 ospf->distance_intra = atoi (argv[2]);
6667
paul718e3742002-12-13 20:15:29 +00006668 return CMD_SUCCESS;
6669}
6670
6671DEFUN (ospf_distance_source,
6672 ospf_distance_source_cmd,
6673 "distance <1-255> A.B.C.D/M",
6674 "Administrative distance\n"
6675 "Distance value\n"
6676 "IP source prefix\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], NULL);
paul68980082003-03-25 05:07:42 +00006681
paul718e3742002-12-13 20:15:29 +00006682 return CMD_SUCCESS;
6683}
6684
6685DEFUN (no_ospf_distance_source,
6686 no_ospf_distance_source_cmd,
6687 "no distance <1-255> A.B.C.D/M",
6688 NO_STR
6689 "Administrative distance\n"
6690 "Distance value\n"
6691 "IP source prefix\n")
6692{
paul020709f2003-04-04 02:44:16 +00006693 struct ospf *ospf = vty->index;
6694
6695 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6696
paul718e3742002-12-13 20:15:29 +00006697 return CMD_SUCCESS;
6698}
6699
6700DEFUN (ospf_distance_source_access_list,
6701 ospf_distance_source_access_list_cmd,
6702 "distance <1-255> A.B.C.D/M WORD",
6703 "Administrative distance\n"
6704 "Distance value\n"
6705 "IP source prefix\n"
6706 "Access list name\n")
6707{
paul020709f2003-04-04 02:44:16 +00006708 struct ospf *ospf = vty->index;
6709
6710 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6711
paul718e3742002-12-13 20:15:29 +00006712 return CMD_SUCCESS;
6713}
6714
6715DEFUN (no_ospf_distance_source_access_list,
6716 no_ospf_distance_source_access_list_cmd,
6717 "no distance <1-255> A.B.C.D/M WORD",
6718 NO_STR
6719 "Administrative distance\n"
6720 "Distance value\n"
6721 "IP source prefix\n"
6722 "Access list name\n")
6723{
paul020709f2003-04-04 02:44:16 +00006724 struct ospf *ospf = vty->index;
6725
6726 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6727
paul718e3742002-12-13 20:15:29 +00006728 return CMD_SUCCESS;
6729}
6730
vincentba682532005-09-29 13:52:57 +00006731DEFUN (ip_ospf_mtu_ignore,
6732 ip_ospf_mtu_ignore_addr_cmd,
6733 "ip ospf mtu-ignore A.B.C.D",
6734 "IP Information\n"
6735 "OSPF interface commands\n"
6736 "Disable mtu mismatch detection\n"
6737 "Address of interface")
6738{
6739 struct interface *ifp = vty->index;
6740 struct in_addr addr;
6741 int ret;
6742
6743 struct ospf_if_params *params;
6744 params = IF_DEF_PARAMS (ifp);
6745
6746 if (argc == 1)
6747 {
6748 ret = inet_aton(argv[0], &addr);
6749 if (!ret)
6750 {
6751 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6752 VTY_NEWLINE);
6753 return CMD_WARNING;
6754 }
6755 params = ospf_get_if_params (ifp, addr);
6756 ospf_if_update_params (ifp, addr);
6757 }
6758 params->mtu_ignore = 1;
6759 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6760 SET_IF_PARAM (params, mtu_ignore);
6761 else
6762 {
6763 UNSET_IF_PARAM (params, mtu_ignore);
6764 if (params != IF_DEF_PARAMS (ifp))
6765 {
6766 ospf_free_if_params (ifp, addr);
6767 ospf_if_update_params (ifp, addr);
6768 }
6769 }
6770 return CMD_SUCCESS;
6771}
6772
6773ALIAS (ip_ospf_mtu_ignore,
6774 ip_ospf_mtu_ignore_cmd,
6775 "ip ospf mtu-ignore",
6776 "IP Information\n"
6777 "OSPF interface commands\n"
6778 "Disable mtu mismatch detection\n")
6779
6780
6781DEFUN (no_ip_ospf_mtu_ignore,
6782 no_ip_ospf_mtu_ignore_addr_cmd,
6783 "no ip ospf mtu-ignore A.B.C.D",
6784 "IP Information\n"
6785 "OSPF interface commands\n"
6786 "Disable mtu mismatch detection\n"
6787 "Address of interface")
6788{
6789 struct interface *ifp = vty->index;
6790 struct in_addr addr;
6791 int ret;
6792
6793 struct ospf_if_params *params;
6794 params = IF_DEF_PARAMS (ifp);
6795
6796 if (argc == 1)
6797 {
6798 ret = inet_aton(argv[0], &addr);
6799 if (!ret)
6800 {
6801 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6802 VTY_NEWLINE);
6803 return CMD_WARNING;
6804 }
6805 params = ospf_get_if_params (ifp, addr);
6806 ospf_if_update_params (ifp, addr);
6807 }
6808 params->mtu_ignore = 0;
6809 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6810 SET_IF_PARAM (params, mtu_ignore);
6811 else
6812 {
6813 UNSET_IF_PARAM (params, mtu_ignore);
6814 if (params != IF_DEF_PARAMS (ifp))
6815 {
6816 ospf_free_if_params (ifp, addr);
6817 ospf_if_update_params (ifp, addr);
6818 }
6819 }
6820 return CMD_SUCCESS;
6821}
6822
6823ALIAS (no_ip_ospf_mtu_ignore,
6824 no_ip_ospf_mtu_ignore_cmd,
6825 "no ip ospf mtu-ignore",
6826 "IP Information\n"
6827 "OSPF interface commands\n"
6828 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00006829
6830DEFUN (ospf_max_metric_router_lsa_admin,
6831 ospf_max_metric_router_lsa_admin_cmd,
6832 "max-metric router-lsa administrative",
6833 "OSPF maximum / infinite-distance metric\n"
6834 "Advertise own Router-LSA with infinite distance (stub router)\n"
6835 "Administratively applied, for an indefinite period\n")
6836{
6837 struct listnode *ln;
6838 struct ospf_area *area;
6839 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006840
paul88d6cf32005-10-29 12:50:09 +00006841 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6842 {
6843 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6844
6845 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
6846 ospf_router_lsa_timer_add (area);
6847 }
6848 return CMD_SUCCESS;
6849}
6850
6851DEFUN (no_ospf_max_metric_router_lsa_admin,
6852 no_ospf_max_metric_router_lsa_admin_cmd,
6853 "no max-metric router-lsa administrative",
6854 NO_STR
6855 "OSPF maximum / infinite-distance metric\n"
6856 "Advertise own Router-LSA with infinite distance (stub router)\n"
6857 "Administratively applied, for an indefinite period\n")
6858{
6859 struct listnode *ln;
6860 struct ospf_area *area;
6861 struct ospf *ospf = vty->index;
6862
6863 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6864 {
6865 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6866
6867 /* Don't trample on the start-up stub timer */
6868 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6869 && !area->t_stub_router)
6870 {
6871 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6872 ospf_router_lsa_timer_add (area);
6873 }
6874 }
6875 return CMD_SUCCESS;
6876}
6877
6878DEFUN (ospf_max_metric_router_lsa_startup,
6879 ospf_max_metric_router_lsa_startup_cmd,
6880 "max-metric router-lsa on-startup <5-86400>",
6881 "OSPF maximum / infinite-distance metric\n"
6882 "Advertise own Router-LSA with infinite distance (stub router)\n"
6883 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6884 "Time (seconds) to advertise self as stub-router\n")
6885{
6886 unsigned int seconds;
6887 struct ospf *ospf = vty->index;
6888
6889 if (argc != 1)
6890 {
6891 vty_out (vty, "%% Must supply stub-router period");
6892 return CMD_WARNING;
6893 }
6894
6895 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6896
6897 ospf->stub_router_startup_time = seconds;
6898
6899 return CMD_SUCCESS;
6900}
6901
6902DEFUN (no_ospf_max_metric_router_lsa_startup,
6903 no_ospf_max_metric_router_lsa_startup_cmd,
6904 "no max-metric router-lsa on-startup",
6905 NO_STR
6906 "OSPF maximum / infinite-distance metric\n"
6907 "Advertise own Router-LSA with infinite distance (stub router)\n"
6908 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6909{
6910 struct listnode *ln;
6911 struct ospf_area *area;
6912 struct ospf *ospf = vty->index;
6913
6914 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6915
6916 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6917 {
6918 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6919 OSPF_TIMER_OFF (area->t_stub_router);
6920
6921 /* Don't trample on admin stub routed */
6922 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6923 {
6924 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6925 ospf_router_lsa_timer_add (area);
6926 }
6927 }
6928 return CMD_SUCCESS;
6929}
6930
6931DEFUN (ospf_max_metric_router_lsa_shutdown,
6932 ospf_max_metric_router_lsa_shutdown_cmd,
6933 "max-metric router-lsa on-shutdown <5-86400>",
6934 "OSPF maximum / infinite-distance metric\n"
6935 "Advertise own Router-LSA with infinite distance (stub router)\n"
6936 "Advertise stub-router prior to full shutdown of OSPF\n"
6937 "Time (seconds) to wait till full shutdown\n")
6938{
6939 unsigned int seconds;
6940 struct ospf *ospf = vty->index;
6941
6942 if (argc != 1)
6943 {
6944 vty_out (vty, "%% Must supply stub-router shutdown period");
6945 return CMD_WARNING;
6946 }
6947
6948 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6949
6950 ospf->stub_router_shutdown_time = seconds;
6951
6952 return CMD_SUCCESS;
6953}
6954
6955DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6956 no_ospf_max_metric_router_lsa_shutdown_cmd,
6957 "no max-metric router-lsa on-shutdown",
6958 NO_STR
6959 "OSPF maximum / infinite-distance metric\n"
6960 "Advertise own Router-LSA with infinite distance (stub router)\n"
6961 "Advertise stub-router prior to full shutdown of OSPF\n")
6962{
6963 struct ospf *ospf = vty->index;
6964
6965 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6966
6967 return CMD_SUCCESS;
6968}
6969
6970static void
6971config_write_stub_router (struct vty *vty, struct ospf *ospf)
6972{
6973 struct listnode *ln;
6974 struct ospf_area *area;
6975
6976 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6977 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6978 ospf->stub_router_startup_time, VTY_NEWLINE);
6979 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6980 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6981 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6982 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6983 {
6984 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6985 {
6986 vty_out (vty, " max-metric router-lsa administrative%s",
6987 VTY_NEWLINE);
6988 break;
6989 }
6990 }
6991 return;
6992}
6993
paul4dadc292005-05-06 21:37:42 +00006994static void
paul718e3742002-12-13 20:15:29 +00006995show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6996{
6997 struct route_node *rn;
6998 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006999 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007000 struct ospf_path *path;
7001
7002 vty_out (vty, "============ OSPF network routing table ============%s",
7003 VTY_NEWLINE);
7004
7005 for (rn = route_top (rt); rn; rn = route_next (rn))
7006 if ((or = rn->info) != NULL)
7007 {
7008 char buf1[19];
7009 snprintf (buf1, 19, "%s/%d",
7010 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7011
7012 switch (or->path_type)
7013 {
7014 case OSPF_PATH_INTER_AREA:
7015 if (or->type == OSPF_DESTINATION_NETWORK)
7016 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7017 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7018 else if (or->type == OSPF_DESTINATION_DISCARD)
7019 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7020 break;
7021 case OSPF_PATH_INTRA_AREA:
7022 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7023 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7024 break;
7025 default:
7026 break;
7027 }
7028
7029 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007030 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007031 {
hasso54bedb52005-08-17 13:31:47 +00007032 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00007033 {
7034 if (path->nexthop.s_addr == 0)
7035 vty_out (vty, "%24s directly attached to %s%s",
7036 "", path->oi->ifp->name, VTY_NEWLINE);
7037 else
7038 vty_out (vty, "%24s via %s, %s%s", "",
7039 inet_ntoa (path->nexthop), path->oi->ifp->name,
7040 VTY_NEWLINE);
7041 }
7042 }
paul718e3742002-12-13 20:15:29 +00007043 }
7044 vty_out (vty, "%s", VTY_NEWLINE);
7045}
7046
paul4dadc292005-05-06 21:37:42 +00007047static void
paul718e3742002-12-13 20:15:29 +00007048show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7049{
7050 struct route_node *rn;
7051 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007052 struct listnode *pnode;
7053 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007054 struct ospf_path *path;
7055
7056 vty_out (vty, "============ OSPF router routing table =============%s",
7057 VTY_NEWLINE);
7058 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7059 if (rn->info)
7060 {
7061 int flag = 0;
7062
7063 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7064
paul1eb8ef22005-04-07 07:30:20 +00007065 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7066 {
7067 if (flag++)
7068 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007069
paul1eb8ef22005-04-07 07:30:20 +00007070 /* Show path. */
7071 vty_out (vty, "%s [%d] area: %s",
7072 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7073 or->cost, inet_ntoa (or->u.std.area_id));
7074 /* Show flags. */
7075 vty_out (vty, "%s%s%s",
7076 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7077 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7078 VTY_NEWLINE);
7079
7080 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7081 {
hasso54bedb52005-08-17 13:31:47 +00007082 if (path->oi != NULL && ospf_if_exists(path->oi))
7083 {
7084 if (path->nexthop.s_addr == 0)
7085 vty_out (vty, "%24s directly attached to %s%s",
7086 "", path->oi->ifp->name, VTY_NEWLINE);
7087 else
7088 vty_out (vty, "%24s via %s, %s%s", "",
7089 inet_ntoa (path->nexthop),
7090 path->oi->ifp->name, VTY_NEWLINE);
7091 }
paul1eb8ef22005-04-07 07:30:20 +00007092 }
7093 }
paul718e3742002-12-13 20:15:29 +00007094 }
7095 vty_out (vty, "%s", VTY_NEWLINE);
7096}
7097
paul4dadc292005-05-06 21:37:42 +00007098static void
paul718e3742002-12-13 20:15:29 +00007099show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7100{
7101 struct route_node *rn;
7102 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007103 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007104 struct ospf_path *path;
7105
7106 vty_out (vty, "============ OSPF external routing table ===========%s",
7107 VTY_NEWLINE);
7108 for (rn = route_top (rt); rn; rn = route_next (rn))
7109 if ((er = rn->info) != NULL)
7110 {
7111 char buf1[19];
7112 snprintf (buf1, 19, "%s/%d",
7113 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7114
7115 switch (er->path_type)
7116 {
7117 case OSPF_PATH_TYPE1_EXTERNAL:
7118 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7119 er->cost, er->u.ext.tag, VTY_NEWLINE);
7120 break;
7121 case OSPF_PATH_TYPE2_EXTERNAL:
7122 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7123 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7124 break;
7125 }
7126
paul1eb8ef22005-04-07 07:30:20 +00007127 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007128 {
hasso54bedb52005-08-17 13:31:47 +00007129 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00007130 {
7131 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007132 vty_out (vty, "%24s directly attached to %s%s",
7133 "", path->oi->ifp->name, VTY_NEWLINE);
7134 else
7135 vty_out (vty, "%24s via %s, %s%s", "",
7136 inet_ntoa (path->nexthop), path->oi->ifp->name,
7137 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007138 }
7139 }
7140 }
7141 vty_out (vty, "%s", VTY_NEWLINE);
7142}
7143
paul718e3742002-12-13 20:15:29 +00007144DEFUN (show_ip_ospf_border_routers,
7145 show_ip_ospf_border_routers_cmd,
7146 "show ip ospf border-routers",
7147 SHOW_STR
7148 IP_STR
7149 "show all the ABR's and ASBR's\n"
7150 "for this area\n")
7151{
paul020709f2003-04-04 02:44:16 +00007152 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007153
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007154 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007155 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007156 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007157 return CMD_SUCCESS;
7158 }
7159
paul68980082003-03-25 05:07:42 +00007160 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007161 {
7162 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7163 return CMD_SUCCESS;
7164 }
7165
7166 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007167 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007168
7169 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007170 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007171
7172 return CMD_SUCCESS;
7173}
paul718e3742002-12-13 20:15:29 +00007174
7175DEFUN (show_ip_ospf_route,
7176 show_ip_ospf_route_cmd,
7177 "show ip ospf route",
7178 SHOW_STR
7179 IP_STR
7180 "OSPF information\n"
7181 "OSPF routing table\n")
7182{
paul020709f2003-04-04 02:44:16 +00007183 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007184
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007185 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007186 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007187 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007188 return CMD_SUCCESS;
7189 }
7190
paul68980082003-03-25 05:07:42 +00007191 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007192 {
7193 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7194 return CMD_SUCCESS;
7195 }
7196
7197 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007198 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007199
7200 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007201 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007202
7203 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007204 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007205
7206 return CMD_SUCCESS;
7207}
7208
7209
hassoeb1ce602004-10-08 08:17:22 +00007210const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007211{
7212 "unknown",
7213 "standard",
7214 "ibm",
7215 "cisco",
7216 "shortcut"
7217};
7218
hassoeb1ce602004-10-08 08:17:22 +00007219const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007220{
7221 "default",
7222 "enable",
7223 "disable"
7224};
7225
7226
paul4dadc292005-05-06 21:37:42 +00007227static void
paul718e3742002-12-13 20:15:29 +00007228area_id2str (char *buf, int length, struct ospf_area *area)
7229{
7230 memset (buf, 0, length);
7231
7232 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7233 strncpy (buf, inet_ntoa (area->area_id), length);
7234 else
7235 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7236}
7237
7238
hassoeb1ce602004-10-08 08:17:22 +00007239const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007240{
7241 "unknown", /* should never be used. */
7242 "point-to-point",
7243 "broadcast",
7244 "non-broadcast",
7245 "point-to-multipoint",
7246 "virtual-link", /* should never be used. */
7247 "loopback"
7248};
7249
7250/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007251static int
paul718e3742002-12-13 20:15:29 +00007252config_write_interface (struct vty *vty)
7253{
hasso52dc7ee2004-09-23 19:18:23 +00007254 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007255 struct interface *ifp;
7256 struct crypt_key *ck;
7257 int write = 0;
7258 struct route_node *rn = NULL;
7259 struct ospf_if_params *params;
7260
paul1eb8ef22005-04-07 07:30:20 +00007261 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007262 {
paul718e3742002-12-13 20:15:29 +00007263 if (memcmp (ifp->name, "VLINK", 5) == 0)
7264 continue;
7265
7266 vty_out (vty, "!%s", VTY_NEWLINE);
7267 vty_out (vty, "interface %s%s", ifp->name,
7268 VTY_NEWLINE);
7269 if (ifp->desc)
7270 vty_out (vty, " description %s%s", ifp->desc,
7271 VTY_NEWLINE);
7272
7273 write++;
7274
7275 params = IF_DEF_PARAMS (ifp);
7276
7277 do {
7278 /* Interface Network print. */
7279 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007280 params->type != OSPF_IFTYPE_LOOPBACK)
7281 {
ajsbc18d612004-12-15 15:07:19 +00007282 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007283 {
7284 vty_out (vty, " ip ospf network %s",
7285 ospf_int_type_str[params->type]);
7286 if (params != IF_DEF_PARAMS (ifp))
7287 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7288 vty_out (vty, "%s", VTY_NEWLINE);
7289 }
paul718e3742002-12-13 20:15:29 +00007290 }
7291
7292 /* OSPF interface authentication print */
7293 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7294 params->auth_type != OSPF_AUTH_NOTSET)
7295 {
hassoeb1ce602004-10-08 08:17:22 +00007296 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007297
7298 /* Translation tables are not that much help here due to syntax
7299 of the simple option */
7300 switch (params->auth_type)
7301 {
7302
7303 case OSPF_AUTH_NULL:
7304 auth_str = " null";
7305 break;
7306
7307 case OSPF_AUTH_SIMPLE:
7308 auth_str = "";
7309 break;
7310
7311 case OSPF_AUTH_CRYPTOGRAPHIC:
7312 auth_str = " message-digest";
7313 break;
7314
7315 default:
7316 auth_str = "";
7317 break;
7318 }
7319
7320 vty_out (vty, " ip ospf authentication%s", auth_str);
7321 if (params != IF_DEF_PARAMS (ifp))
7322 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7323 vty_out (vty, "%s", VTY_NEWLINE);
7324 }
7325
7326 /* Simple Authentication Password print. */
7327 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7328 params->auth_simple[0] != '\0')
7329 {
7330 vty_out (vty, " ip ospf authentication-key %s",
7331 params->auth_simple);
7332 if (params != IF_DEF_PARAMS (ifp))
7333 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7334 vty_out (vty, "%s", VTY_NEWLINE);
7335 }
7336
7337 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007338 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007339 {
paul718e3742002-12-13 20:15:29 +00007340 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7341 ck->key_id, ck->auth_key);
7342 if (params != IF_DEF_PARAMS (ifp))
7343 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7344 vty_out (vty, "%s", VTY_NEWLINE);
7345 }
7346
7347 /* Interface Output Cost print. */
7348 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7349 {
7350 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7351 if (params != IF_DEF_PARAMS (ifp))
7352 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7353 vty_out (vty, "%s", VTY_NEWLINE);
7354 }
7355
7356 /* Hello Interval print. */
7357 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7358 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7359 {
7360 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7361 if (params != IF_DEF_PARAMS (ifp))
7362 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7363 vty_out (vty, "%s", VTY_NEWLINE);
7364 }
7365
7366
7367 /* Router Dead Interval print. */
7368 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7369 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7370 {
paulf9ad9372005-10-21 00:45:17 +00007371 vty_out (vty, " ip ospf dead-interval ");
7372
7373 /* fast hello ? */
7374 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7375 vty_out (vty, "minimal hello-multiplier %d",
7376 params->fast_hello);
7377 else
7378 vty_out (vty, "%u", params->v_wait);
7379
paul718e3742002-12-13 20:15:29 +00007380 if (params != IF_DEF_PARAMS (ifp))
7381 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7382 vty_out (vty, "%s", VTY_NEWLINE);
7383 }
7384
7385 /* Router Priority print. */
7386 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7387 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7388 {
7389 vty_out (vty, " ip ospf priority %u", params->priority);
7390 if (params != IF_DEF_PARAMS (ifp))
7391 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7392 vty_out (vty, "%s", VTY_NEWLINE);
7393 }
7394
7395 /* Retransmit Interval print. */
7396 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7397 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7398 {
7399 vty_out (vty, " ip ospf retransmit-interval %u",
7400 params->retransmit_interval);
7401 if (params != IF_DEF_PARAMS (ifp))
7402 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7403 vty_out (vty, "%s", VTY_NEWLINE);
7404 }
7405
7406 /* Transmit Delay print. */
7407 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7408 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7409 {
7410 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7411 if (params != IF_DEF_PARAMS (ifp))
7412 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7413 vty_out (vty, "%s", VTY_NEWLINE);
7414 }
7415
vincentba682532005-09-29 13:52:57 +00007416 /* MTU ignore print. */
7417 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7418 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7419 {
7420 if (params->mtu_ignore == 0)
7421 vty_out (vty, " no ip ospf mtu-ignore");
7422 else
7423 vty_out (vty, " ip ospf mtu-ignore");
7424 if (params != IF_DEF_PARAMS (ifp))
7425 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7426 vty_out (vty, "%s", VTY_NEWLINE);
7427 }
7428
7429
paul718e3742002-12-13 20:15:29 +00007430 while (1)
7431 {
7432 if (rn == NULL)
7433 rn = route_top (IF_OIFS_PARAMS (ifp));
7434 else
7435 rn = route_next (rn);
7436
7437 if (rn == NULL)
7438 break;
7439 params = rn->info;
7440 if (params != NULL)
7441 break;
7442 }
7443 } while (rn);
7444
7445#ifdef HAVE_OPAQUE_LSA
7446 ospf_opaque_config_write_if (vty, ifp);
7447#endif /* HAVE_OPAQUE_LSA */
7448 }
7449
7450 return write;
7451}
7452
paul4dadc292005-05-06 21:37:42 +00007453static int
paul68980082003-03-25 05:07:42 +00007454config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007455{
7456 struct route_node *rn;
7457 u_char buf[INET_ADDRSTRLEN];
7458
7459 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007460 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007461 if (rn->info)
7462 {
7463 struct ospf_network *n = rn->info;
7464
7465 memset (buf, 0, INET_ADDRSTRLEN);
7466
7467 /* Create Area ID string by specified Area ID format. */
7468 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007469 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007470 else
hassoc9e52be2004-09-26 16:09:34 +00007471 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007472 (unsigned long int) ntohl (n->area_id.s_addr));
7473
7474 /* Network print. */
7475 vty_out (vty, " network %s/%d area %s%s",
7476 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7477 buf, VTY_NEWLINE);
7478 }
7479
7480 return 0;
7481}
7482
paul4dadc292005-05-06 21:37:42 +00007483static int
paul68980082003-03-25 05:07:42 +00007484config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007485{
hasso52dc7ee2004-09-23 19:18:23 +00007486 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007487 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007488 u_char buf[INET_ADDRSTRLEN];
7489
7490 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007491 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007492 {
paul718e3742002-12-13 20:15:29 +00007493 struct route_node *rn1;
7494
hassoc9e52be2004-09-26 16:09:34 +00007495 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007496
7497 if (area->auth_type != OSPF_AUTH_NULL)
7498 {
7499 if (area->auth_type == OSPF_AUTH_SIMPLE)
7500 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7501 else
7502 vty_out (vty, " area %s authentication message-digest%s",
7503 buf, VTY_NEWLINE);
7504 }
7505
7506 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7507 vty_out (vty, " area %s shortcut %s%s", buf,
7508 ospf_shortcut_mode_str[area->shortcut_configured],
7509 VTY_NEWLINE);
7510
7511 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007512 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007513 )
7514 {
paulb0a053b2003-06-22 09:04:47 +00007515 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007516 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007517 else if (area->external_routing == OSPF_AREA_NSSA)
7518 {
7519 vty_out (vty, " area %s nssa", buf);
7520 switch (area->NSSATranslatorRole)
7521 {
7522 case OSPF_NSSA_ROLE_NEVER:
7523 vty_out (vty, " translate-never");
7524 break;
7525 case OSPF_NSSA_ROLE_ALWAYS:
7526 vty_out (vty, " translate-always");
7527 break;
7528 case OSPF_NSSA_ROLE_CANDIDATE:
7529 default:
7530 vty_out (vty, " translate-candidate");
7531 }
7532 }
paul718e3742002-12-13 20:15:29 +00007533
7534 if (area->no_summary)
7535 vty_out (vty, " no-summary");
7536
7537 vty_out (vty, "%s", VTY_NEWLINE);
7538
7539 if (area->default_cost != 1)
7540 vty_out (vty, " area %s default-cost %d%s", buf,
7541 area->default_cost, VTY_NEWLINE);
7542 }
7543
7544 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7545 if (rn1->info)
7546 {
7547 struct ospf_area_range *range = rn1->info;
7548
7549 vty_out (vty, " area %s range %s/%d", buf,
7550 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7551
paul6c835672004-10-11 11:00:30 +00007552 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007553 vty_out (vty, " cost %d", range->cost_config);
7554
7555 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7556 vty_out (vty, " not-advertise");
7557
7558 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7559 vty_out (vty, " substitute %s/%d",
7560 inet_ntoa (range->subst_addr), range->subst_masklen);
7561
7562 vty_out (vty, "%s", VTY_NEWLINE);
7563 }
7564
7565 if (EXPORT_NAME (area))
7566 vty_out (vty, " area %s export-list %s%s", buf,
7567 EXPORT_NAME (area), VTY_NEWLINE);
7568
7569 if (IMPORT_NAME (area))
7570 vty_out (vty, " area %s import-list %s%s", buf,
7571 IMPORT_NAME (area), VTY_NEWLINE);
7572
7573 if (PREFIX_NAME_IN (area))
7574 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7575 PREFIX_NAME_IN (area), VTY_NEWLINE);
7576
7577 if (PREFIX_NAME_OUT (area))
7578 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7579 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7580 }
7581
7582 return 0;
7583}
7584
paul4dadc292005-05-06 21:37:42 +00007585static int
paul68980082003-03-25 05:07:42 +00007586config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007587{
7588 struct ospf_nbr_nbma *nbr_nbma;
7589 struct route_node *rn;
7590
7591 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007592 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007593 if ((nbr_nbma = rn->info))
7594 {
7595 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7596
7597 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7598 vty_out (vty, " priority %d", nbr_nbma->priority);
7599
7600 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7601 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7602
7603 vty_out (vty, "%s", VTY_NEWLINE);
7604 }
7605
7606 return 0;
7607}
7608
paul4dadc292005-05-06 21:37:42 +00007609static int
paul68980082003-03-25 05:07:42 +00007610config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007611{
hasso52dc7ee2004-09-23 19:18:23 +00007612 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007613 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007614 u_char buf[INET_ADDRSTRLEN];
7615
7616 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007617 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007618 {
hasso52dc7ee2004-09-23 19:18:23 +00007619 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007620 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007621 struct ospf_interface *oi;
7622
7623 if (vl_data != NULL)
7624 {
7625 memset (buf, 0, INET_ADDRSTRLEN);
7626
7627 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007628 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007629 else
hassoc9e52be2004-09-26 16:09:34 +00007630 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007631 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7632 oi = vl_data->vl_oi;
7633
7634 /* timers */
7635 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7636 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7637 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7638 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7639 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7640 buf,
7641 inet_ntoa (vl_data->vl_peer),
7642 OSPF_IF_PARAM (oi, v_hello),
7643 OSPF_IF_PARAM (oi, retransmit_interval),
7644 OSPF_IF_PARAM (oi, transmit_delay),
7645 OSPF_IF_PARAM (oi, v_wait),
7646 VTY_NEWLINE);
7647 else
7648 vty_out (vty, " area %s virtual-link %s%s", buf,
7649 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7650 /* Auth key */
7651 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7652 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7653 buf,
7654 inet_ntoa (vl_data->vl_peer),
7655 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7656 VTY_NEWLINE);
7657 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007658 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7659 n2, ck))
7660 vty_out (vty, " area %s virtual-link %s"
7661 " message-digest-key %d md5 %s%s",
7662 buf,
7663 inet_ntoa (vl_data->vl_peer),
7664 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007665
7666 }
7667 }
7668
7669 return 0;
7670}
7671
7672
paul4dadc292005-05-06 21:37:42 +00007673static int
paul68980082003-03-25 05:07:42 +00007674config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007675{
7676 int type;
7677
7678 /* redistribute print. */
7679 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7680 if (type != zclient->redist_default && zclient->redist[type])
7681 {
ajsf52d13c2005-10-01 17:38:06 +00007682 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007683 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007684 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007685
paul68980082003-03-25 05:07:42 +00007686 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007687 vty_out (vty, " metric-type 1");
7688
paul020709f2003-04-04 02:44:16 +00007689 if (ROUTEMAP_NAME (ospf, type))
7690 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007691
7692 vty_out (vty, "%s", VTY_NEWLINE);
7693 }
7694
7695 return 0;
7696}
7697
paul4dadc292005-05-06 21:37:42 +00007698static int
paul68980082003-03-25 05:07:42 +00007699config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007700{
paul68980082003-03-25 05:07:42 +00007701 if (ospf->default_metric != -1)
7702 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007703 VTY_NEWLINE);
7704 return 0;
7705}
7706
paul4dadc292005-05-06 21:37:42 +00007707static int
paul68980082003-03-25 05:07:42 +00007708config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007709{
7710 int type;
7711
paul68980082003-03-25 05:07:42 +00007712 if (ospf)
paul718e3742002-12-13 20:15:29 +00007713 {
7714 /* distribute-list print. */
7715 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007716 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007717 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007718 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007719 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007720
7721 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007722 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007723 {
paulc42c1772006-01-10 20:36:49 +00007724 vty_out (vty, " default-information originate");
7725 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7726 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007727
paul68980082003-03-25 05:07:42 +00007728 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007729 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007730 ospf->dmetric[DEFAULT_ROUTE].value);
7731 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007732 vty_out (vty, " metric-type 1");
7733
paul020709f2003-04-04 02:44:16 +00007734 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7735 vty_out (vty, " route-map %s",
7736 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007737
7738 vty_out (vty, "%s", VTY_NEWLINE);
7739 }
7740
7741 }
7742
7743 return 0;
7744}
7745
paul4dadc292005-05-06 21:37:42 +00007746static int
paul68980082003-03-25 05:07:42 +00007747config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007748{
7749 struct route_node *rn;
7750 struct ospf_distance *odistance;
7751
paul68980082003-03-25 05:07:42 +00007752 if (ospf->distance_all)
7753 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007754
paul68980082003-03-25 05:07:42 +00007755 if (ospf->distance_intra
7756 || ospf->distance_inter
7757 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007758 {
7759 vty_out (vty, " distance ospf");
7760
paul68980082003-03-25 05:07:42 +00007761 if (ospf->distance_intra)
7762 vty_out (vty, " intra-area %d", ospf->distance_intra);
7763 if (ospf->distance_inter)
7764 vty_out (vty, " inter-area %d", ospf->distance_inter);
7765 if (ospf->distance_external)
7766 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007767
7768 vty_out (vty, "%s", VTY_NEWLINE);
7769 }
7770
paul68980082003-03-25 05:07:42 +00007771 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007772 if ((odistance = rn->info) != NULL)
7773 {
7774 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7775 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7776 odistance->access_list ? odistance->access_list : "",
7777 VTY_NEWLINE);
7778 }
7779 return 0;
7780}
7781
7782/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007783static int
paul718e3742002-12-13 20:15:29 +00007784ospf_config_write (struct vty *vty)
7785{
paul020709f2003-04-04 02:44:16 +00007786 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007787 struct interface *ifp;
7788 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007789 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007790 int write = 0;
7791
paul020709f2003-04-04 02:44:16 +00007792 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007793 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007794 {
7795 /* `router ospf' print. */
7796 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7797
7798 write++;
7799
paul68980082003-03-25 05:07:42 +00007800 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007801 return write;
7802
7803 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007804 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007805 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007806 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007807
7808 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007809 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007810 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007811 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007812
7813 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007814 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007815 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7816
7817 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007818 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007819 {
7820 vty_out (vty, "! Important: ensure reference bandwidth "
7821 "is consistent across all routers%s", VTY_NEWLINE);
7822 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7823 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7824 }
paul718e3742002-12-13 20:15:29 +00007825
7826 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007827 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007828 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7829 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7830 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007831 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007832 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007833
7834 /* Max-metric router-lsa print */
7835 config_write_stub_router (vty, ospf);
7836
paul718e3742002-12-13 20:15:29 +00007837 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007838 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007839 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007840 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007841
7842 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007843 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007844
7845 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007846 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7847 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7848 vty_out (vty, " passive-interface %s%s",
7849 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007850
paul1eb8ef22005-04-07 07:30:20 +00007851 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7852 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7853 oi->params->passive_interface == OSPF_IF_PASSIVE)
7854 vty_out (vty, " passive-interface %s %s%s",
7855 oi->ifp->name,
7856 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007857
7858 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007859 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007860
7861 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007862 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007863
7864 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007865 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007866
7867 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007868 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007869
7870 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007871 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007872
7873 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007874 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007875
7876 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007877 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007878
7879#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007880 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007881#endif /* HAVE_OPAQUE_LSA */
7882 }
7883
7884 return write;
7885}
7886
7887void
paul4dadc292005-05-06 21:37:42 +00007888ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007889{
7890 /* "show ip ospf" commands. */
7891 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7892 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7893
7894 /* "show ip ospf database" commands. */
7895 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7896 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7897 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7898 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7899 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7900 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7901 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7902 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7903 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7904 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7905 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7906 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7907 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7908 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7909
7910 /* "show ip ospf interface" commands. */
7911 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7912 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7913
7914 /* "show ip ospf neighbor" commands. */
7915 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7916 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7917 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7918 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7919 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7920 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7921 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7922 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7923 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7924 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7925 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7926 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7927 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7928 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7929
7930 /* "show ip ospf route" commands. */
7931 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7932 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007933 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7934 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007935}
7936
7937
7938/* ospfd's interface node. */
7939struct cmd_node interface_node =
7940{
7941 INTERFACE_NODE,
7942 "%s(config-if)# ",
7943 1
7944};
7945
7946/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007947static void
7948ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007949{
7950 /* Install interface node. */
7951 install_node (&interface_node, config_write_interface);
7952
7953 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007954 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007955 install_default (INTERFACE_NODE);
7956
7957 /* "description" commands. */
7958 install_element (INTERFACE_NODE, &interface_desc_cmd);
7959 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7960
7961 /* "ip ospf authentication" commands. */
7962 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7963 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7964 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7965 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7966 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7967 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7968 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7969 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7970 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7971 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7972
7973 /* "ip ospf message-digest-key" commands. */
7974 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7975 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7976 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7977 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7978
7979 /* "ip ospf cost" commands. */
7980 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7981 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7982 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7983 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7984
vincentba682532005-09-29 13:52:57 +00007985 /* "ip ospf mtu-ignore" commands. */
7986 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7987 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7988 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7989 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7990
paul718e3742002-12-13 20:15:29 +00007991 /* "ip ospf dead-interval" commands. */
7992 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7993 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007994 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7995 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007996 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7997 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007998
paul718e3742002-12-13 20:15:29 +00007999 /* "ip ospf hello-interval" commands. */
8000 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8001 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8002 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8003 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8004
8005 /* "ip ospf network" commands. */
8006 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8007 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8008
8009 /* "ip ospf priority" commands. */
8010 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8011 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8012 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8013 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8014
8015 /* "ip ospf retransmit-interval" commands. */
8016 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8017 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8018 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8019 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8020
8021 /* "ip ospf transmit-delay" commands. */
8022 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8023 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8024 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8025 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8026
8027 /* These commands are compatibitliy for previous version. */
8028 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8029 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8030 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8031 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
8032 install_element (INTERFACE_NODE, &ospf_cost_cmd);
8033 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
8034 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8035 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8036 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8037 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8038 install_element (INTERFACE_NODE, &ospf_network_cmd);
8039 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8040 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8041 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8042 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8043 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8044 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8045 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8046}
8047
8048/* Zebra node structure. */
8049struct cmd_node zebra_node =
8050{
8051 ZEBRA_NODE,
8052 "%s(config-router)#",
8053};
8054
paul4dadc292005-05-06 21:37:42 +00008055static void
8056ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008057{
8058 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8059 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8060 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8061 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8062 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8063 install_element (OSPF_NODE,
8064 &ospf_redistribute_source_metric_type_routemap_cmd);
8065 install_element (OSPF_NODE,
8066 &ospf_redistribute_source_type_metric_routemap_cmd);
8067 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8068 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8069 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8070
8071 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8072
8073 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8074 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8075
8076 install_element (OSPF_NODE,
8077 &ospf_default_information_originate_metric_type_cmd);
8078 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8079 install_element (OSPF_NODE,
8080 &ospf_default_information_originate_type_metric_cmd);
8081 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8082 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8083 install_element (OSPF_NODE,
8084 &ospf_default_information_originate_always_metric_type_cmd);
8085 install_element (OSPF_NODE,
8086 &ospf_default_information_originate_always_metric_cmd);
8087 install_element (OSPF_NODE,
8088 &ospf_default_information_originate_always_cmd);
8089 install_element (OSPF_NODE,
8090 &ospf_default_information_originate_always_type_metric_cmd);
8091 install_element (OSPF_NODE,
8092 &ospf_default_information_originate_always_type_cmd);
8093
8094 install_element (OSPF_NODE,
8095 &ospf_default_information_originate_metric_type_routemap_cmd);
8096 install_element (OSPF_NODE,
8097 &ospf_default_information_originate_metric_routemap_cmd);
8098 install_element (OSPF_NODE,
8099 &ospf_default_information_originate_routemap_cmd);
8100 install_element (OSPF_NODE,
8101 &ospf_default_information_originate_type_metric_routemap_cmd);
8102 install_element (OSPF_NODE,
8103 &ospf_default_information_originate_type_routemap_cmd);
8104 install_element (OSPF_NODE,
8105 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8106 install_element (OSPF_NODE,
8107 &ospf_default_information_originate_always_metric_routemap_cmd);
8108 install_element (OSPF_NODE,
8109 &ospf_default_information_originate_always_routemap_cmd);
8110 install_element (OSPF_NODE,
8111 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8112 install_element (OSPF_NODE,
8113 &ospf_default_information_originate_always_type_routemap_cmd);
8114
8115 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8116
8117 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8118 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8119 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8120
8121 install_element (OSPF_NODE, &ospf_distance_cmd);
8122 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8123 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8124 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8125 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8126 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8127 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8128 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8129 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8130 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8131 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8132 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8133 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8134 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8135 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8136 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8137 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8138 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8139#if 0
8140 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8141 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8142 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8143 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8144#endif /* 0 */
8145}
8146
8147struct cmd_node ospf_node =
8148{
8149 OSPF_NODE,
8150 "%s(config-router)# ",
8151 1
8152};
8153
8154
8155/* Install OSPF related vty commands. */
8156void
paul4dadc292005-05-06 21:37:42 +00008157ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008158{
8159 /* Install ospf top node. */
8160 install_node (&ospf_node, ospf_config_write);
8161
8162 /* "router ospf" commands. */
8163 install_element (CONFIG_NODE, &router_ospf_cmd);
8164 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8165
8166 install_default (OSPF_NODE);
8167
8168 /* "ospf router-id" commands. */
8169 install_element (OSPF_NODE, &ospf_router_id_cmd);
8170 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008171 install_element (OSPF_NODE, &router_ospf_id_cmd);
8172 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008173
8174 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008175 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8176 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8177 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8178 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008179
8180 /* "ospf abr-type" commands. */
8181 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8182 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8183
8184 /* "ospf rfc1583-compatible" commands. */
8185 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8186 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8187 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8188 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8189
8190 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008191 install_element (OSPF_NODE, &ospf_network_area_cmd);
8192 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008193
8194 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008195 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8196 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8197 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008198
8199 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008200 install_element (OSPF_NODE, &ospf_area_range_cmd);
8201 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8202 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8203 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8204 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8205 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8206 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8207 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8208 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8209 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8210 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008211
8212 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008213 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8214 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008215
paula2c62832003-04-23 17:01:31 +00008216 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8217 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008218
paula2c62832003-04-23 17:01:31 +00008219 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8220 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008221
paula2c62832003-04-23 17:01:31 +00008222 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8223 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008224
paula2c62832003-04-23 17:01:31 +00008225 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8226 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008227
paula2c62832003-04-23 17:01:31 +00008228 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8229 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8230 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008231
paula2c62832003-04-23 17:01:31 +00008232 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8233 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008234
paula2c62832003-04-23 17:01:31 +00008235 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8236 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008237
paula2c62832003-04-23 17:01:31 +00008238 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8239 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8240 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008241
paula2c62832003-04-23 17:01:31 +00008242 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8243 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8244 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008245
8246 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008247 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8248 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8249 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8250 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008251
paul718e3742002-12-13 20:15:29 +00008252 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008253 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8254 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8255 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8256 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8257 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8258 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008259
paula2c62832003-04-23 17:01:31 +00008260 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8261 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008262
paula2c62832003-04-23 17:01:31 +00008263 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8264 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008265
paula2c62832003-04-23 17:01:31 +00008266 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8267 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008268
paula2c62832003-04-23 17:01:31 +00008269 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8270 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008271
paula2c62832003-04-23 17:01:31 +00008272 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8273 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008274
8275 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008276 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8277 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008278 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8279 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8280
paul88d6cf32005-10-29 12:50:09 +00008281 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008282 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8283 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8284 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008285
paul88d6cf32005-10-29 12:50:09 +00008286 /* max-metric commands */
8287 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8288 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8289 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8290 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8291 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8292 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8293
8294 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008295 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8296 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008297
8298 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008299 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8300 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8301 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8302 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8303 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8304 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8305 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8306 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008307
8308 /* Init interface related vty commands. */
8309 ospf_vty_if_init ();
8310
8311 /* Init zebra related vty commands. */
8312 ospf_vty_zebra_init ();
8313}