blob: 20dc940ad94d67408bfcce6f396f7e866ff00f11 [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
Andrew J. Schorr6e72cb62006-06-18 00:45:48 +0000264 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000265
266 params = IF_DEF_PARAMS (ifp);
267
268 if (argc == 2)
269 {
270 ret = inet_aton(argv[1], &addr);
271 if (!ret)
272 {
273 vty_out (vty, "Please specify interface address by A.B.C.D%s",
274 VTY_NEWLINE);
275 return CMD_WARNING;
276 }
277
278 params = ospf_get_if_params (ifp, addr);
279 ospf_if_update_params (ifp, addr);
280 }
281
282 SET_IF_PARAM (params, passive_interface);
283 params->passive_interface = OSPF_IF_PASSIVE;
ajsba6454e2005-02-08 15:37:30 +0000284
285 /* XXX We should call ospf_if_set_multicast on exactly those
286 * interfaces for which the passive property changed. It is too much
287 * work to determine this set, so we do this for every interface.
288 * This is safe and reasonable because ospf_if_set_multicast uses a
289 * record of joined groups to avoid systems calls if the desired
290 * memberships match the current memership.
291 */
292 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
293 {
294 struct ospf_interface *oi = rn->info;
295
296 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
297 ospf_if_set_multicast(oi);
298 }
299 /*
300 * XXX It is not clear what state transitions the interface needs to
301 * undergo when going from active to passive. Fixing this will
302 * require precise identification of interfaces having such a
303 * transition.
304 */
305
paul718e3742002-12-13 20:15:29 +0000306 return CMD_SUCCESS;
307}
308
paula2c62832003-04-23 17:01:31 +0000309ALIAS (ospf_passive_interface,
310 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000311 "passive-interface IFNAME",
312 "Suppress routing updates on an interface\n"
313 "Interface's name\n")
314
paula2c62832003-04-23 17:01:31 +0000315DEFUN (no_ospf_passive_interface,
316 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000317 "no passive-interface IFNAME A.B.C.D",
318 NO_STR
319 "Allow routing updates on an interface\n"
320 "Interface's name\n")
321{
322 struct interface *ifp;
323 struct in_addr addr;
324 struct ospf_if_params *params;
325 int ret;
ajsba6454e2005-02-08 15:37:30 +0000326 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000327
Andrew J. Schorr6e72cb62006-06-18 00:45:48 +0000328 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000329
330 params = IF_DEF_PARAMS (ifp);
331
332 if (argc == 2)
333 {
334 ret = inet_aton(argv[1], &addr);
335 if (!ret)
336 {
337 vty_out (vty, "Please specify interface address by A.B.C.D%s",
338 VTY_NEWLINE);
339 return CMD_WARNING;
340 }
341
342 params = ospf_lookup_if_params (ifp, addr);
343 if (params == NULL)
344 return CMD_SUCCESS;
345 }
346
347 UNSET_IF_PARAM (params, passive_interface);
348 params->passive_interface = OSPF_IF_ACTIVE;
349
350 if (params != IF_DEF_PARAMS (ifp))
351 {
352 ospf_free_if_params (ifp, addr);
353 ospf_if_update_params (ifp, addr);
354 }
ajsba6454e2005-02-08 15:37:30 +0000355
356 /* XXX We should call ospf_if_set_multicast on exactly those
357 * interfaces for which the passive property changed. It is too much
358 * work to determine this set, so we do this for every interface.
359 * This is safe and reasonable because ospf_if_set_multicast uses a
360 * record of joined groups to avoid systems calls if the desired
361 * memberships match the current memership.
362 */
363 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
364 {
365 struct ospf_interface *oi = rn->info;
366
367 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
368 ospf_if_set_multicast(oi);
369 }
370
paul718e3742002-12-13 20:15:29 +0000371 return CMD_SUCCESS;
372}
373
paula2c62832003-04-23 17:01:31 +0000374ALIAS (no_ospf_passive_interface,
375 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000376 "no passive-interface IFNAME",
377 NO_STR
378 "Allow routing updates on an interface\n"
379 "Interface's name\n")
380
paula2c62832003-04-23 17:01:31 +0000381DEFUN (ospf_network_area,
382 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000383 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
384 "Enable routing on an IP network\n"
385 "OSPF network prefix\n"
386 "Set the OSPF area ID\n"
387 "OSPF area ID in IP address format\n"
388 "OSPF area ID as a decimal value\n")
389{
390 struct ospf *ospf= vty->index;
391 struct prefix_ipv4 p;
392 struct in_addr area_id;
393 int ret, format;
394
395 /* Get network prefix and Area ID. */
396 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
397 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
398
399 ret = ospf_network_set (ospf, &p, area_id);
400 if (ret == 0)
401 {
402 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
403 return CMD_WARNING;
404 }
405
406 return CMD_SUCCESS;
407}
408
paula2c62832003-04-23 17:01:31 +0000409DEFUN (no_ospf_network_area,
410 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000411 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
412 NO_STR
413 "Enable routing on an IP network\n"
414 "OSPF network prefix\n"
415 "Set the OSPF area ID\n"
416 "OSPF area ID in IP address format\n"
417 "OSPF area ID as a decimal value\n")
418{
419 struct ospf *ospf = (struct ospf *) vty->index;
420 struct prefix_ipv4 p;
421 struct in_addr area_id;
422 int ret, format;
423
424 /* Get network prefix and Area ID. */
425 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
426 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
427
428 ret = ospf_network_unset (ospf, &p, area_id);
429 if (ret == 0)
430 {
431 vty_out (vty, "Can't find specified network area configuration.%s",
432 VTY_NEWLINE);
433 return CMD_WARNING;
434 }
435
436 return CMD_SUCCESS;
437}
438
439
paula2c62832003-04-23 17:01:31 +0000440DEFUN (ospf_area_range,
441 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000442 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
443 "OSPF area parameters\n"
444 "OSPF area ID in IP address format\n"
445 "OSPF area ID as a decimal value\n"
446 "Summarize routes matching address/mask (border routers only)\n"
447 "Area range prefix\n")
448{
449 struct ospf *ospf = vty->index;
450 struct prefix_ipv4 p;
451 struct in_addr area_id;
452 int format;
453 u_int32_t cost;
454
455 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
456 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
457
458 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
459 if (argc > 2)
460 {
paul4dadc292005-05-06 21:37:42 +0000461 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000462 ospf_area_range_cost_set (ospf, area_id, &p, cost);
463 }
464
465 return CMD_SUCCESS;
466}
467
paula2c62832003-04-23 17:01:31 +0000468ALIAS (ospf_area_range,
469 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000470 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
471 "OSPF area parameters\n"
472 "OSPF area ID in IP address format\n"
473 "OSPF area ID as a decimal value\n"
474 "OSPF area range for route advertise (default)\n"
475 "Area range prefix\n"
476 "Advertise this range (default)\n")
477
paula2c62832003-04-23 17:01:31 +0000478ALIAS (ospf_area_range,
479 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000480 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
481 "OSPF area parameters\n"
482 "OSPF area ID in IP address format\n"
483 "OSPF area ID as a decimal value\n"
484 "Summarize routes matching address/mask (border routers only)\n"
485 "Area range prefix\n"
486 "User specified metric for this range\n"
487 "Advertised metric for this range\n")
488
paula2c62832003-04-23 17:01:31 +0000489ALIAS (ospf_area_range,
490 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000491 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
492 "OSPF area parameters\n"
493 "OSPF area ID in IP address format\n"
494 "OSPF area ID as a decimal value\n"
495 "Summarize routes matching address/mask (border routers only)\n"
496 "Area range prefix\n"
497 "Advertise this range (default)\n"
498 "User specified metric for this range\n"
499 "Advertised metric for this range\n")
500
paula2c62832003-04-23 17:01:31 +0000501DEFUN (ospf_area_range_not_advertise,
502 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000503 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
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 "DoNotAdvertise this range\n")
510{
511 struct ospf *ospf = vty->index;
512 struct prefix_ipv4 p;
513 struct in_addr area_id;
514 int format;
515
516 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
517 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
518
519 ospf_area_range_set (ospf, area_id, &p, 0);
520
521 return CMD_SUCCESS;
522}
523
paula2c62832003-04-23 17:01:31 +0000524DEFUN (no_ospf_area_range,
525 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000526 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
527 NO_STR
528 "OSPF area parameters\n"
529 "OSPF area ID in IP address format\n"
530 "OSPF area ID as a decimal value\n"
531 "Summarize routes matching address/mask (border routers only)\n"
532 "Area range prefix\n")
533{
534 struct ospf *ospf = vty->index;
535 struct prefix_ipv4 p;
536 struct in_addr area_id;
537 int format;
538
539 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
540 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
541
542 ospf_area_range_unset (ospf, area_id, &p);
543
544 return CMD_SUCCESS;
545}
546
paula2c62832003-04-23 17:01:31 +0000547ALIAS (no_ospf_area_range,
548 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000549 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
550 NO_STR
551 "OSPF area parameters\n"
552 "OSPF area ID in IP address format\n"
553 "OSPF area ID as a decimal value\n"
554 "Summarize routes matching address/mask (border routers only)\n"
555 "Area range prefix\n"
556 "Advertise this range (default)\n"
557 "DoNotAdvertise this range\n")
558
paula2c62832003-04-23 17:01:31 +0000559ALIAS (no_ospf_area_range,
560 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000561 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
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 "User specified metric for this range\n"
569 "Advertised metric for this range\n")
570
paula2c62832003-04-23 17:01:31 +0000571ALIAS (no_ospf_area_range,
572 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000573 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise 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 "Advertise this range (default)\n"
581 "User specified metric for this range\n"
582 "Advertised metric for this range\n")
583
paula2c62832003-04-23 17:01:31 +0000584DEFUN (ospf_area_range_substitute,
585 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000586 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
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 "Announce area range as another prefix\n"
593 "Network prefix to be announced instead of range\n")
594{
595 struct ospf *ospf = vty->index;
596 struct prefix_ipv4 p, s;
597 struct in_addr area_id;
598 int format;
599
600 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
601 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
602 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
603
604 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
605
606 return CMD_SUCCESS;
607}
608
paula2c62832003-04-23 17:01:31 +0000609DEFUN (no_ospf_area_range_substitute,
610 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000611 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
612 NO_STR
613 "OSPF area parameters\n"
614 "OSPF area ID in IP address format\n"
615 "OSPF area ID as a decimal value\n"
616 "Summarize routes matching address/mask (border routers only)\n"
617 "Area range prefix\n"
618 "Announce area range as another prefix\n"
619 "Network prefix to be announced instead of range\n")
620{
621 struct ospf *ospf = vty->index;
622 struct prefix_ipv4 p, s;
623 struct in_addr area_id;
624 int format;
625
626 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
627 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
628 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
629
630 ospf_area_range_substitute_unset (ospf, area_id, &p);
631
632 return CMD_SUCCESS;
633}
634
635
636/* Command Handler Logic in VLink stuff is delicate!!
637
638 ALTER AT YOUR OWN RISK!!!!
639
640 Various dummy values are used to represent 'NoChange' state for
641 VLink configuration NOT being changed by a VLink command, and
642 special syntax is used within the command strings so that the
643 typed in command verbs can be seen in the configuration command
644 bacckend handler. This is to drastically reduce the verbeage
645 required to coe up with a reasonably compatible Cisco VLink command
646
647 - Matthew Grant <grantma@anathoth.gen.nz>
648 Wed, 21 Feb 2001 15:13:52 +1300
649 */
650
651
652/* Configuration data for virtual links
653 */
654struct ospf_vl_config_data {
655 struct vty *vty; /* vty stuff */
656 struct in_addr area_id; /* area ID from command line */
657 int format; /* command line area ID format */
658 struct in_addr vl_peer; /* command line vl_peer */
659 int auth_type; /* Authehntication type, if given */
660 char *auth_key; /* simple password if present */
661 int crypto_key_id; /* Cryptographic key ID */
662 char *md5_key; /* MD5 authentication key */
663 int hello_interval; /* Obvious what these are... */
664 int retransmit_interval;
665 int transmit_delay;
666 int dead_interval;
667};
668
paul4dadc292005-05-06 21:37:42 +0000669static void
paul718e3742002-12-13 20:15:29 +0000670ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
671 struct vty *vty)
672{
673 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
674 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
675 vl_config->vty = vty;
676}
677
paul4dadc292005-05-06 21:37:42 +0000678static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000679ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000680{
681 struct ospf_area *area;
682 struct ospf_vl_data *vl_data;
683 struct vty *vty;
684 struct in_addr area_id;
685
686 vty = vl_config->vty;
687 area_id = vl_config->area_id;
688
689 if (area_id.s_addr == OSPF_AREA_BACKBONE)
690 {
691 vty_out (vty,
692 "Configuring VLs over the backbone is not allowed%s",
693 VTY_NEWLINE);
694 return NULL;
695 }
paul68980082003-03-25 05:07:42 +0000696 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000697
698 if (area->external_routing != OSPF_AREA_DEFAULT)
699 {
700 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
701 vty_out (vty, "Area %s is %s%s",
702 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000703 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000704 VTY_NEWLINE);
705 else
706 vty_out (vty, "Area %ld is %s%s",
707 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000708 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000709 VTY_NEWLINE);
710 return NULL;
711 }
712
Paul Jakma9c27ef92006-05-04 07:32:57 +0000713 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
paul718e3742002-12-13 20:15:29 +0000714 {
715 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
716 if (vl_data->vl_oi == NULL)
717 {
paul68980082003-03-25 05:07:42 +0000718 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
719 ospf_vl_add (ospf, vl_data);
720 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000721 }
722 }
723 return vl_data;
724}
725
726
paul4dadc292005-05-06 21:37:42 +0000727static int
paul718e3742002-12-13 20:15:29 +0000728ospf_vl_set_security (struct ospf_vl_data *vl_data,
729 struct ospf_vl_config_data *vl_config)
730{
731 struct crypt_key *ck;
732 struct vty *vty;
733 struct interface *ifp = vl_data->vl_oi->ifp;
734
735 vty = vl_config->vty;
736
737 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
738 {
739 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
740 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
741 }
742
743 if (vl_config->auth_key)
744 {
745 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000746 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000747 OSPF_AUTH_SIMPLE_SIZE);
748 }
749 else if (vl_config->md5_key)
750 {
751 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
752 != NULL)
753 {
754 vty_out (vty, "OSPF: Key %d already exists%s",
755 vl_config->crypto_key_id, VTY_NEWLINE);
756 return CMD_WARNING;
757 }
758 ck = ospf_crypt_key_new ();
759 ck->key_id = vl_config->crypto_key_id;
760 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000761 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000762
763 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
764 }
765 else if (vl_config->crypto_key_id != 0)
766 {
767 /* Delete a key */
768
769 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
770 vl_config->crypto_key_id) == NULL)
771 {
772 vty_out (vty, "OSPF: Key %d does not exist%s",
773 vl_config->crypto_key_id, VTY_NEWLINE);
774 return CMD_WARNING;
775 }
776
777 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
778
779 }
780
781 return CMD_SUCCESS;
782}
783
paul4dadc292005-05-06 21:37:42 +0000784static int
paul718e3742002-12-13 20:15:29 +0000785ospf_vl_set_timers (struct ospf_vl_data *vl_data,
786 struct ospf_vl_config_data *vl_config)
787{
788 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
789 /* Virtual Link data initialised to defaults, so only set
790 if a value given */
791 if (vl_config->hello_interval)
792 {
793 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
794 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
795 }
796
797 if (vl_config->dead_interval)
798 {
799 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
800 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
801 }
802
803 if (vl_config->retransmit_interval)
804 {
805 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
806 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
807 }
808
809 if (vl_config->transmit_delay)
810 {
811 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
812 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
813 }
814
815 return CMD_SUCCESS;
816}
817
818
819
820/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000821static int
paul68980082003-03-25 05:07:42 +0000822ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000823{
824 struct ospf_vl_data *vl_data;
825 int ret;
826
paul68980082003-03-25 05:07:42 +0000827 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000828 if (!vl_data)
829 return CMD_WARNING;
830
831 /* Process this one first as it can have a fatal result, which can
832 only logically occur if the virtual link exists already
833 Thus a command error does not result in a change to the
834 running configuration such as unexpectedly altered timer
835 values etc.*/
836 ret = ospf_vl_set_security (vl_data, vl_config);
837 if (ret != CMD_SUCCESS)
838 return ret;
839
840 /* Set any time based parameters, these area already range checked */
841
842 ret = ospf_vl_set_timers (vl_data, vl_config);
843 if (ret != CMD_SUCCESS)
844 return ret;
845
846 return CMD_SUCCESS;
847
848}
849
850/* This stuff exists to make specifying all the alias commands A LOT simpler
851 */
852#define VLINK_HELPSTR_IPADDR \
853 "OSPF area parameters\n" \
854 "OSPF area ID in IP address format\n" \
855 "OSPF area ID as a decimal value\n" \
856 "Configure a virtual link\n" \
857 "Router ID of the remote ABR\n"
858
859#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
860 "Enable authentication on this virtual link\n" \
861 "dummy string \n"
862
863#define VLINK_HELPSTR_AUTHTYPE_ALL \
864 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
865 "Use null authentication\n" \
866 "Use message-digest authentication\n"
867
868#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
869 "Time between HELLO packets\n" \
870 "Time between retransmitting lost link state advertisements\n" \
871 "Link state transmit delay\n" \
872 "Interval after which a neighbor is declared dead\n"
873
874#define VLINK_HELPSTR_TIME_PARAM \
875 VLINK_HELPSTR_TIME_PARAM_NOSECS \
876 "Seconds\n"
877
878#define VLINK_HELPSTR_AUTH_SIMPLE \
879 "Authentication password (key)\n" \
880 "The OSPF password (key)"
881
882#define VLINK_HELPSTR_AUTH_MD5 \
883 "Message digest authentication password (key)\n" \
884 "dummy string \n" \
885 "Key ID\n" \
886 "Use MD5 algorithm\n" \
887 "The OSPF password (key)"
888
paula2c62832003-04-23 17:01:31 +0000889DEFUN (ospf_area_vlink,
890 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000891 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
892 VLINK_HELPSTR_IPADDR)
893{
paul68980082003-03-25 05:07:42 +0000894 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000895 struct ospf_vl_config_data vl_config;
896 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
897 char md5_key[OSPF_AUTH_MD5_SIZE+1];
898 int i;
899 int ret;
900
901 ospf_vl_config_data_init(&vl_config, vty);
902
903 /* Read off first 2 parameters and check them */
904 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
905 if (ret < 0)
906 {
907 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
908 return CMD_WARNING;
909 }
910
911 ret = inet_aton (argv[1], &vl_config.vl_peer);
912 if (! ret)
913 {
914 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
915 VTY_NEWLINE);
916 return CMD_WARNING;
917 }
918
919 if (argc <=2)
920 {
921 /* Thats all folks! - BUGS B. strikes again!!!*/
922
paul68980082003-03-25 05:07:42 +0000923 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000924 }
925
926 /* Deal with other parameters */
927 for (i=2; i < argc; i++)
928 {
929
930 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
931
932 switch (argv[i][0])
933 {
934
935 case 'a':
936 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
937 {
938 /* authentication-key - this option can occur anywhere on
939 command line. At start of command line
940 must check for authentication option. */
941 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
942 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
943 vl_config.auth_key = auth_key;
944 i++;
945 }
946 else if (strncmp (argv[i], "authentication", 14) == 0)
947 {
948 /* authentication - this option can only occur at start
949 of command line */
950 vl_config.auth_type = OSPF_AUTH_SIMPLE;
951 if ((i+1) < argc)
952 {
953 if (strncmp (argv[i+1], "n", 1) == 0)
954 {
955 /* "authentication null" */
956 vl_config.auth_type = OSPF_AUTH_NULL;
957 i++;
958 }
959 else if (strncmp (argv[i+1], "m", 1) == 0
960 && strcmp (argv[i+1], "message-digest-") != 0)
961 {
962 /* "authentication message-digest" */
963 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
964 i++;
965 }
966 }
967 }
968 break;
969
970 case 'm':
971 /* message-digest-key */
972 i++;
973 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
974 if (vl_config.crypto_key_id < 0)
975 return CMD_WARNING;
976 i++;
977 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
978 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
979 vl_config.md5_key = md5_key;
980 break;
981
982 case 'h':
983 /* Hello interval */
984 i++;
985 vl_config.hello_interval = strtol (argv[i], NULL, 10);
986 if (vl_config.hello_interval < 0)
987 return CMD_WARNING;
988 break;
989
990 case 'r':
991 /* Retransmit Interval */
992 i++;
993 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
994 if (vl_config.retransmit_interval < 0)
995 return CMD_WARNING;
996 break;
997
998 case 't':
999 /* Transmit Delay */
1000 i++;
1001 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1002 if (vl_config.transmit_delay < 0)
1003 return CMD_WARNING;
1004 break;
1005
1006 case 'd':
1007 /* Dead Interval */
1008 i++;
1009 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1010 if (vl_config.dead_interval < 0)
1011 return CMD_WARNING;
1012 break;
1013 }
1014 }
1015
1016
1017 /* Action configuration */
1018
paul68980082003-03-25 05:07:42 +00001019 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001020
1021}
1022
paula2c62832003-04-23 17:01:31 +00001023DEFUN (no_ospf_area_vlink,
1024 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001025 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1026 NO_STR
1027 VLINK_HELPSTR_IPADDR)
1028{
paul68980082003-03-25 05:07:42 +00001029 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001030 struct ospf_area *area;
1031 struct ospf_vl_config_data vl_config;
1032 struct ospf_vl_data *vl_data = NULL;
1033 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1034 int i;
1035 int ret, format;
1036
1037 ospf_vl_config_data_init(&vl_config, vty);
1038
1039 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1040 if (ret < 0)
1041 {
1042 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1043 return CMD_WARNING;
1044 }
1045
paul68980082003-03-25 05:07:42 +00001046 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001047 if (!area)
1048 {
1049 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1050 return CMD_WARNING;
1051 }
1052
1053 ret = inet_aton (argv[1], &vl_config.vl_peer);
1054 if (! ret)
1055 {
1056 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1057 VTY_NEWLINE);
1058 return CMD_WARNING;
1059 }
1060
1061 if (argc <=2)
1062 {
1063 /* Basic VLink no command */
1064 /* Thats all folks! - BUGS B. strikes again!!!*/
Paul Jakma9c27ef92006-05-04 07:32:57 +00001065 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001066 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001067
paul68980082003-03-25 05:07:42 +00001068 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001069
1070 return CMD_SUCCESS;
1071 }
1072
1073 /* If we are down here, we are reseting parameters */
1074
1075 /* Deal with other parameters */
1076 for (i=2; i < argc; i++)
1077 {
paul718e3742002-12-13 20:15:29 +00001078 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1079
1080 switch (argv[i][0])
1081 {
1082
1083 case 'a':
1084 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1085 {
1086 /* authentication-key - this option can occur anywhere on
1087 command line. At start of command line
1088 must check for authentication option. */
1089 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1090 vl_config.auth_key = auth_key;
1091 }
1092 else if (strncmp (argv[i], "authentication", 14) == 0)
1093 {
1094 /* authentication - this option can only occur at start
1095 of command line */
1096 vl_config.auth_type = OSPF_AUTH_NOTSET;
1097 }
1098 break;
1099
1100 case 'm':
1101 /* message-digest-key */
1102 /* Delete one key */
1103 i++;
1104 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1105 if (vl_config.crypto_key_id < 0)
1106 return CMD_WARNING;
1107 vl_config.md5_key = NULL;
1108 break;
1109
1110 case 'h':
1111 /* Hello interval */
1112 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1113 break;
1114
1115 case 'r':
1116 /* Retransmit Interval */
1117 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1118 break;
1119
1120 case 't':
1121 /* Transmit Delay */
1122 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1123 break;
1124
1125 case 'd':
1126 /* Dead Interval */
1127 i++;
1128 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1129 break;
1130 }
1131 }
1132
1133
1134 /* Action configuration */
1135
paul68980082003-03-25 05:07:42 +00001136 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001137}
1138
paula2c62832003-04-23 17:01:31 +00001139ALIAS (ospf_area_vlink,
1140 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001141 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1142 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1143 VLINK_HELPSTR_IPADDR
1144 VLINK_HELPSTR_TIME_PARAM)
1145
paula2c62832003-04-23 17:01:31 +00001146ALIAS (no_ospf_area_vlink,
1147 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001148 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1149 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1150 NO_STR
1151 VLINK_HELPSTR_IPADDR
1152 VLINK_HELPSTR_TIME_PARAM)
1153
paula2c62832003-04-23 17:01:31 +00001154ALIAS (ospf_area_vlink,
1155 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001156 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1157 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1158 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1159 VLINK_HELPSTR_IPADDR
1160 VLINK_HELPSTR_TIME_PARAM
1161 VLINK_HELPSTR_TIME_PARAM)
1162
paula2c62832003-04-23 17:01:31 +00001163ALIAS (no_ospf_area_vlink,
1164 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001165 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1166 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1167 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1168 NO_STR
1169 VLINK_HELPSTR_IPADDR
1170 VLINK_HELPSTR_TIME_PARAM
1171 VLINK_HELPSTR_TIME_PARAM)
1172
paula2c62832003-04-23 17:01:31 +00001173ALIAS (ospf_area_vlink,
1174 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001175 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1176 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1177 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1178 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1179 VLINK_HELPSTR_IPADDR
1180 VLINK_HELPSTR_TIME_PARAM
1181 VLINK_HELPSTR_TIME_PARAM
1182 VLINK_HELPSTR_TIME_PARAM)
1183
paula2c62832003-04-23 17:01:31 +00001184ALIAS (no_ospf_area_vlink,
1185 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001186 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1187 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1188 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1189 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1190 NO_STR
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 (ospf_area_vlink,
1197 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001198 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1199 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1200 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1201 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1202 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1203 VLINK_HELPSTR_IPADDR
1204 VLINK_HELPSTR_TIME_PARAM
1205 VLINK_HELPSTR_TIME_PARAM
1206 VLINK_HELPSTR_TIME_PARAM
1207 VLINK_HELPSTR_TIME_PARAM)
1208
paula2c62832003-04-23 17:01:31 +00001209ALIAS (no_ospf_area_vlink,
1210 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001211 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1212 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1213 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1214 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1215 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1216 NO_STR
1217 VLINK_HELPSTR_IPADDR
1218 VLINK_HELPSTR_TIME_PARAM
1219 VLINK_HELPSTR_TIME_PARAM
1220 VLINK_HELPSTR_TIME_PARAM
1221 VLINK_HELPSTR_TIME_PARAM)
1222
paula2c62832003-04-23 17:01:31 +00001223ALIAS (ospf_area_vlink,
1224 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001225 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1226 "(authentication|) (message-digest|null)",
1227 VLINK_HELPSTR_IPADDR
1228 VLINK_HELPSTR_AUTHTYPE_ALL)
1229
paula2c62832003-04-23 17:01:31 +00001230ALIAS (ospf_area_vlink,
1231 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001232 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1233 "(authentication|)",
1234 VLINK_HELPSTR_IPADDR
1235 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1236
paula2c62832003-04-23 17:01:31 +00001237ALIAS (no_ospf_area_vlink,
1238 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001239 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1240 "(authentication|)",
1241 NO_STR
1242 VLINK_HELPSTR_IPADDR
1243 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1244
paula2c62832003-04-23 17:01:31 +00001245ALIAS (ospf_area_vlink,
1246 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001247 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1248 "(message-digest-key|) <1-255> md5 KEY",
1249 VLINK_HELPSTR_IPADDR
1250 VLINK_HELPSTR_AUTH_MD5)
1251
paula2c62832003-04-23 17:01:31 +00001252ALIAS (no_ospf_area_vlink,
1253 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001254 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1255 "(message-digest-key|) <1-255>",
1256 NO_STR
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_AUTH_MD5)
1259
paula2c62832003-04-23 17:01:31 +00001260ALIAS (ospf_area_vlink,
1261 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001262 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1263 "(authentication-key|) AUTH_KEY",
1264 VLINK_HELPSTR_IPADDR
1265 VLINK_HELPSTR_AUTH_SIMPLE)
1266
paula2c62832003-04-23 17:01:31 +00001267ALIAS (no_ospf_area_vlink,
1268 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001269 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1270 "(authentication-key|)",
1271 NO_STR
1272 VLINK_HELPSTR_IPADDR
1273 VLINK_HELPSTR_AUTH_SIMPLE)
1274
paula2c62832003-04-23 17:01:31 +00001275ALIAS (ospf_area_vlink,
1276 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001277 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1278 "(authentication|) (message-digest|null) "
1279 "(authentication-key|) AUTH_KEY",
1280 VLINK_HELPSTR_IPADDR
1281 VLINK_HELPSTR_AUTHTYPE_ALL
1282 VLINK_HELPSTR_AUTH_SIMPLE)
1283
paula2c62832003-04-23 17:01:31 +00001284ALIAS (ospf_area_vlink,
1285 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001286 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1287 "(authentication|) "
1288 "(authentication-key|) AUTH_KEY",
1289 VLINK_HELPSTR_IPADDR
1290 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1291 VLINK_HELPSTR_AUTH_SIMPLE)
1292
paula2c62832003-04-23 17:01:31 +00001293ALIAS (no_ospf_area_vlink,
1294 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001295 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1296 "(authentication|) "
1297 "(authentication-key|)",
1298 NO_STR
1299 VLINK_HELPSTR_IPADDR
1300 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1301 VLINK_HELPSTR_AUTH_SIMPLE)
1302
paula2c62832003-04-23 17:01:31 +00001303ALIAS (ospf_area_vlink,
1304 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001305 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1306 "(authentication|) (message-digest|null) "
1307 "(message-digest-key|) <1-255> md5 KEY",
1308 VLINK_HELPSTR_IPADDR
1309 VLINK_HELPSTR_AUTHTYPE_ALL
1310 VLINK_HELPSTR_AUTH_MD5)
1311
paula2c62832003-04-23 17:01:31 +00001312ALIAS (ospf_area_vlink,
1313 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001314 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1315 "(authentication|) "
1316 "(message-digest-key|) <1-255> md5 KEY",
1317 VLINK_HELPSTR_IPADDR
1318 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1319 VLINK_HELPSTR_AUTH_MD5)
1320
paula2c62832003-04-23 17:01:31 +00001321ALIAS (no_ospf_area_vlink,
1322 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001323 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1324 "(authentication|) "
1325 "(message-digest-key|)",
1326 NO_STR
1327 VLINK_HELPSTR_IPADDR
1328 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1329 VLINK_HELPSTR_AUTH_MD5)
1330
1331
paula2c62832003-04-23 17:01:31 +00001332DEFUN (ospf_area_shortcut,
1333 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001334 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1335 "OSPF area parameters\n"
1336 "OSPF area ID in IP address format\n"
1337 "OSPF area ID as a decimal value\n"
1338 "Configure the area's shortcutting mode\n"
1339 "Set default shortcutting behavior\n"
1340 "Enable shortcutting through the area\n"
1341 "Disable shortcutting through the area\n")
1342{
paul68980082003-03-25 05:07:42 +00001343 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001344 struct ospf_area *area;
1345 struct in_addr area_id;
1346 int mode;
1347 int format;
1348
1349 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1350
paul68980082003-03-25 05:07:42 +00001351 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001352
1353 if (strncmp (argv[1], "de", 2) == 0)
1354 mode = OSPF_SHORTCUT_DEFAULT;
1355 else if (strncmp (argv[1], "di", 2) == 0)
1356 mode = OSPF_SHORTCUT_DISABLE;
1357 else if (strncmp (argv[1], "e", 1) == 0)
1358 mode = OSPF_SHORTCUT_ENABLE;
1359 else
1360 return CMD_WARNING;
1361
paul68980082003-03-25 05:07:42 +00001362 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001363
paul68980082003-03-25 05:07:42 +00001364 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001365 vty_out (vty, "Shortcut area setting will take effect "
1366 "only when the router is configured as Shortcut ABR%s",
1367 VTY_NEWLINE);
1368
1369 return CMD_SUCCESS;
1370}
1371
paula2c62832003-04-23 17:01:31 +00001372DEFUN (no_ospf_area_shortcut,
1373 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001374 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1375 NO_STR
1376 "OSPF area parameters\n"
1377 "OSPF area ID in IP address format\n"
1378 "OSPF area ID as a decimal value\n"
1379 "Deconfigure the area's shortcutting mode\n"
1380 "Deconfigure enabled shortcutting through the area\n"
1381 "Deconfigure disabled shortcutting through the area\n")
1382{
paul68980082003-03-25 05:07:42 +00001383 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001384 struct ospf_area *area;
1385 struct in_addr area_id;
1386 int format;
1387
1388 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1389
paul68980082003-03-25 05:07:42 +00001390 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001391 if (!area)
1392 return CMD_SUCCESS;
1393
paul68980082003-03-25 05:07:42 +00001394 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001395
1396 return CMD_SUCCESS;
1397}
1398
1399
paula2c62832003-04-23 17:01:31 +00001400DEFUN (ospf_area_stub,
1401 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001402 "area (A.B.C.D|<0-4294967295>) stub",
1403 "OSPF area parameters\n"
1404 "OSPF area ID in IP address format\n"
1405 "OSPF area ID as a decimal value\n"
1406 "Configure OSPF area as stub\n")
1407{
1408 struct ospf *ospf = vty->index;
1409 struct in_addr area_id;
1410 int ret, format;
1411
1412 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1413
1414 ret = ospf_area_stub_set (ospf, area_id);
1415 if (ret == 0)
1416 {
1417 vty_out (vty, "First deconfigure all virtual link through this area%s",
1418 VTY_NEWLINE);
1419 return CMD_WARNING;
1420 }
1421
1422 ospf_area_no_summary_unset (ospf, area_id);
1423
1424 return CMD_SUCCESS;
1425}
1426
paula2c62832003-04-23 17:01:31 +00001427DEFUN (ospf_area_stub_no_summary,
1428 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001429 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1430 "OSPF stub parameters\n"
1431 "OSPF area ID in IP address format\n"
1432 "OSPF area ID as a decimal value\n"
1433 "Configure OSPF area as stub\n"
1434 "Do not inject inter-area routes into stub\n")
1435{
1436 struct ospf *ospf = vty->index;
1437 struct in_addr area_id;
1438 int ret, format;
1439
1440 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1441
1442 ret = ospf_area_stub_set (ospf, area_id);
1443 if (ret == 0)
1444 {
paulb0a053b2003-06-22 09:04:47 +00001445 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001446 VTY_NEWLINE);
1447 return CMD_WARNING;
1448 }
1449
1450 ospf_area_no_summary_set (ospf, area_id);
1451
1452 return CMD_SUCCESS;
1453}
1454
paula2c62832003-04-23 17:01:31 +00001455DEFUN (no_ospf_area_stub,
1456 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001457 "no area (A.B.C.D|<0-4294967295>) stub",
1458 NO_STR
1459 "OSPF area parameters\n"
1460 "OSPF area ID in IP address format\n"
1461 "OSPF area ID as a decimal value\n"
1462 "Configure OSPF area as stub\n")
1463{
1464 struct ospf *ospf = vty->index;
1465 struct in_addr area_id;
1466 int format;
1467
1468 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1469
1470 ospf_area_stub_unset (ospf, area_id);
1471 ospf_area_no_summary_unset (ospf, area_id);
1472
1473 return CMD_SUCCESS;
1474}
1475
paula2c62832003-04-23 17:01:31 +00001476DEFUN (no_ospf_area_stub_no_summary,
1477 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001478 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1479 NO_STR
1480 "OSPF area parameters\n"
1481 "OSPF area ID in IP address format\n"
1482 "OSPF area ID as a decimal value\n"
1483 "Configure OSPF area as stub\n"
1484 "Do not inject inter-area routes into area\n")
1485{
1486 struct ospf *ospf = vty->index;
1487 struct in_addr area_id;
1488 int format;
1489
1490 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1491 ospf_area_no_summary_unset (ospf, area_id);
1492
1493 return CMD_SUCCESS;
1494}
1495
paul4dadc292005-05-06 21:37:42 +00001496static int
paul6c835672004-10-11 11:00:30 +00001497ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1498 int nosum)
paul718e3742002-12-13 20:15:29 +00001499{
1500 struct ospf *ospf = vty->index;
1501 struct in_addr area_id;
1502 int ret, format;
1503
1504 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1505
1506 ret = ospf_area_nssa_set (ospf, area_id);
1507 if (ret == 0)
1508 {
1509 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1510 VTY_NEWLINE);
1511 return CMD_WARNING;
1512 }
1513
1514 if (argc > 1)
1515 {
1516 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001517 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001518 OSPF_NSSA_ROLE_CANDIDATE);
1519 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001520 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001521 OSPF_NSSA_ROLE_NEVER);
1522 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001523 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001524 OSPF_NSSA_ROLE_ALWAYS);
1525 }
paulb0a053b2003-06-22 09:04:47 +00001526 else
1527 {
1528 ospf_area_nssa_translator_role_set (ospf, area_id,
1529 OSPF_NSSA_ROLE_CANDIDATE);
1530 }
paul718e3742002-12-13 20:15:29 +00001531
paulb0a053b2003-06-22 09:04:47 +00001532 if (nosum)
paul718e3742002-12-13 20:15:29 +00001533 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001534 else
1535 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001536
paulb0a053b2003-06-22 09:04:47 +00001537 ospf_schedule_abr_task (ospf);
1538
paul718e3742002-12-13 20:15:29 +00001539 return CMD_SUCCESS;
1540}
1541
paulb0a053b2003-06-22 09:04:47 +00001542DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001543 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001544 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001545 "OSPF area parameters\n"
1546 "OSPF area ID in IP address format\n"
1547 "OSPF area ID as a decimal value\n"
1548 "Configure OSPF area as nssa\n"
1549 "Configure NSSA-ABR for translate election (default)\n"
1550 "Configure NSSA-ABR to never translate\n"
1551 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001552 "Do not inject inter-area routes into nssa\n")
1553{
1554 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1555}
paul718e3742002-12-13 20:15:29 +00001556
paulb0a053b2003-06-22 09:04:47 +00001557DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001558 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001559 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1560 "OSPF area parameters\n"
1561 "OSPF area ID in IP address format\n"
1562 "OSPF area ID as a decimal value\n"
1563 "Configure OSPF area as nssa\n"
1564 "Configure NSSA-ABR for translate election (default)\n"
1565 "Configure NSSA-ABR to never translate\n"
1566 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001567{
1568 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1569}
1570
1571DEFUN (ospf_area_nssa,
1572 ospf_area_nssa_cmd,
1573 "area (A.B.C.D|<0-4294967295>) nssa",
1574 "OSPF area parameters\n"
1575 "OSPF area ID in IP address format\n"
1576 "OSPF area ID as a decimal value\n"
1577 "Configure OSPF area as nssa\n")
1578{
1579 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1580}
paul718e3742002-12-13 20:15:29 +00001581
paula2c62832003-04-23 17:01:31 +00001582DEFUN (ospf_area_nssa_no_summary,
1583 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001584 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1585 "OSPF area parameters\n"
1586 "OSPF area ID in IP address format\n"
1587 "OSPF area ID as a decimal value\n"
1588 "Configure OSPF area as nssa\n"
1589 "Do not inject inter-area routes into nssa\n")
1590{
paulb0a053b2003-06-22 09:04:47 +00001591 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001592}
1593
paula2c62832003-04-23 17:01:31 +00001594DEFUN (no_ospf_area_nssa,
1595 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001596 "no area (A.B.C.D|<0-4294967295>) nssa",
1597 NO_STR
1598 "OSPF area parameters\n"
1599 "OSPF area ID in IP address format\n"
1600 "OSPF area ID as a decimal value\n"
1601 "Configure OSPF area as nssa\n")
1602{
1603 struct ospf *ospf = vty->index;
1604 struct in_addr area_id;
1605 int format;
1606
1607 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1608
1609 ospf_area_nssa_unset (ospf, area_id);
1610 ospf_area_no_summary_unset (ospf, area_id);
1611
paulb0a053b2003-06-22 09:04:47 +00001612 ospf_schedule_abr_task (ospf);
1613
paul718e3742002-12-13 20:15:29 +00001614 return CMD_SUCCESS;
1615}
1616
paula2c62832003-04-23 17:01:31 +00001617DEFUN (no_ospf_area_nssa_no_summary,
1618 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001619 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1620 NO_STR
1621 "OSPF area parameters\n"
1622 "OSPF area ID in IP address format\n"
1623 "OSPF area ID as a decimal value\n"
1624 "Configure OSPF area as nssa\n"
1625 "Do not inject inter-area routes into nssa\n")
1626{
1627 struct ospf *ospf = vty->index;
1628 struct in_addr area_id;
1629 int format;
1630
1631 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1632 ospf_area_no_summary_unset (ospf, area_id);
1633
1634 return CMD_SUCCESS;
1635}
1636
paula2c62832003-04-23 17:01:31 +00001637DEFUN (ospf_area_default_cost,
1638 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001639 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1640 "OSPF area parameters\n"
1641 "OSPF area ID in IP address format\n"
1642 "OSPF area ID as a decimal value\n"
1643 "Set the summary-default cost of a NSSA or stub area\n"
1644 "Stub's advertised default summary cost\n")
1645{
paul68980082003-03-25 05:07:42 +00001646 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001647 struct ospf_area *area;
1648 struct in_addr area_id;
1649 u_int32_t cost;
1650 int format;
vincentba682532005-09-29 13:52:57 +00001651 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001652
1653 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1654 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1655
paul68980082003-03-25 05:07:42 +00001656 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001657
1658 if (area->external_routing == OSPF_AREA_DEFAULT)
1659 {
1660 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1661 return CMD_WARNING;
1662 }
1663
1664 area->default_cost = cost;
1665
vincentba682532005-09-29 13:52:57 +00001666 p.family = AF_INET;
1667 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1668 p.prefixlen = 0;
1669 if (IS_DEBUG_OSPF_EVENT)
1670 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1671 "announcing 0.0.0.0/0 to area %s",
1672 inet_ntoa (area->area_id));
1673 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1674
paul718e3742002-12-13 20:15:29 +00001675 return CMD_SUCCESS;
1676}
1677
paula2c62832003-04-23 17:01:31 +00001678DEFUN (no_ospf_area_default_cost,
1679 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001680 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1681 NO_STR
1682 "OSPF area parameters\n"
1683 "OSPF area ID in IP address format\n"
1684 "OSPF area ID as a decimal value\n"
1685 "Set the summary-default cost of a NSSA or stub area\n"
1686 "Stub's advertised default summary cost\n")
1687{
paul68980082003-03-25 05:07:42 +00001688 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001689 struct ospf_area *area;
1690 struct in_addr area_id;
1691 u_int32_t cost;
1692 int format;
vincentba682532005-09-29 13:52:57 +00001693 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001694
1695 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1696 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1697
paul68980082003-03-25 05:07:42 +00001698 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001699 if (area == NULL)
1700 return CMD_SUCCESS;
1701
1702 if (area->external_routing == OSPF_AREA_DEFAULT)
1703 {
1704 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1705 return CMD_WARNING;
1706 }
1707
1708 area->default_cost = 1;
1709
vincentba682532005-09-29 13:52:57 +00001710 p.family = AF_INET;
1711 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1712 p.prefixlen = 0;
1713 if (IS_DEBUG_OSPF_EVENT)
1714 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1715 "announcing 0.0.0.0/0 to area %s",
1716 inet_ntoa (area->area_id));
1717 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1718
1719
paul68980082003-03-25 05:07:42 +00001720 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001721
1722 return CMD_SUCCESS;
1723}
1724
paula2c62832003-04-23 17:01:31 +00001725DEFUN (ospf_area_export_list,
1726 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001727 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1728 "OSPF area parameters\n"
1729 "OSPF area ID in IP address format\n"
1730 "OSPF area ID as a decimal value\n"
1731 "Set the filter for networks announced to other areas\n"
1732 "Name of the access-list\n")
1733{
paul68980082003-03-25 05:07:42 +00001734 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001735 struct ospf_area *area;
1736 struct in_addr area_id;
1737 int format;
1738
hasso52930762004-04-19 18:26:53 +00001739 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1740
paul68980082003-03-25 05:07:42 +00001741 area = ospf_area_get (ospf, area_id, format);
1742 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001743
1744 return CMD_SUCCESS;
1745}
1746
paula2c62832003-04-23 17:01:31 +00001747DEFUN (no_ospf_area_export_list,
1748 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001749 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1750 NO_STR
1751 "OSPF area parameters\n"
1752 "OSPF area ID in IP address format\n"
1753 "OSPF area ID as a decimal value\n"
1754 "Unset the filter for networks announced to other areas\n"
1755 "Name of the access-list\n")
1756{
paul68980082003-03-25 05:07:42 +00001757 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001758 struct ospf_area *area;
1759 struct in_addr area_id;
1760 int format;
1761
hasso52930762004-04-19 18:26:53 +00001762 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1763
paul68980082003-03-25 05:07:42 +00001764 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001765 if (area == NULL)
1766 return CMD_SUCCESS;
1767
paul68980082003-03-25 05:07:42 +00001768 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001769
1770 return CMD_SUCCESS;
1771}
1772
1773
paula2c62832003-04-23 17:01:31 +00001774DEFUN (ospf_area_import_list,
1775 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001776 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1777 "OSPF area parameters\n"
1778 "OSPF area ID in IP address format\n"
1779 "OSPF area ID as a decimal value\n"
1780 "Set the filter for networks from other areas announced to the specified one\n"
1781 "Name of the access-list\n")
1782{
paul68980082003-03-25 05:07:42 +00001783 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001784 struct ospf_area *area;
1785 struct in_addr area_id;
1786 int format;
1787
hasso52930762004-04-19 18:26:53 +00001788 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1789
paul68980082003-03-25 05:07:42 +00001790 area = ospf_area_get (ospf, area_id, format);
1791 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001792
1793 return CMD_SUCCESS;
1794}
1795
paula2c62832003-04-23 17:01:31 +00001796DEFUN (no_ospf_area_import_list,
1797 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001798 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1799 NO_STR
1800 "OSPF area parameters\n"
1801 "OSPF area ID in IP address format\n"
1802 "OSPF area ID as a decimal value\n"
1803 "Unset the filter for networks announced to other areas\n"
1804 "Name of the access-list\n")
1805{
paul68980082003-03-25 05:07:42 +00001806 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001807 struct ospf_area *area;
1808 struct in_addr area_id;
1809 int format;
1810
hasso52930762004-04-19 18:26:53 +00001811 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1812
paul68980082003-03-25 05:07:42 +00001813 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001814 if (area == NULL)
1815 return CMD_SUCCESS;
1816
paul68980082003-03-25 05:07:42 +00001817 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001818
1819 return CMD_SUCCESS;
1820}
1821
paula2c62832003-04-23 17:01:31 +00001822DEFUN (ospf_area_filter_list,
1823 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001824 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1825 "OSPF area parameters\n"
1826 "OSPF area ID in IP address format\n"
1827 "OSPF area ID as a decimal value\n"
1828 "Filter networks between OSPF areas\n"
1829 "Filter prefixes between OSPF areas\n"
1830 "Name of an IP prefix-list\n"
1831 "Filter networks sent to this area\n"
1832 "Filter networks sent from this area\n")
1833{
paul68980082003-03-25 05:07:42 +00001834 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001835 struct ospf_area *area;
1836 struct in_addr area_id;
1837 struct prefix_list *plist;
1838 int format;
1839
1840 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1841
paul68980082003-03-25 05:07:42 +00001842 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001843 plist = prefix_list_lookup (AFI_IP, argv[1]);
1844 if (strncmp (argv[2], "in", 2) == 0)
1845 {
1846 PREFIX_LIST_IN (area) = plist;
1847 if (PREFIX_NAME_IN (area))
1848 free (PREFIX_NAME_IN (area));
1849
1850 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001851 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001852 }
1853 else
1854 {
1855 PREFIX_LIST_OUT (area) = plist;
1856 if (PREFIX_NAME_OUT (area))
1857 free (PREFIX_NAME_OUT (area));
1858
1859 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001860 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001861 }
1862
1863 return CMD_SUCCESS;
1864}
1865
paula2c62832003-04-23 17:01:31 +00001866DEFUN (no_ospf_area_filter_list,
1867 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001868 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1869 NO_STR
1870 "OSPF area parameters\n"
1871 "OSPF area ID in IP address format\n"
1872 "OSPF area ID as a decimal value\n"
1873 "Filter networks between OSPF areas\n"
1874 "Filter prefixes between OSPF areas\n"
1875 "Name of an IP prefix-list\n"
1876 "Filter networks sent to this area\n"
1877 "Filter networks sent from this area\n")
1878{
paul68980082003-03-25 05:07:42 +00001879 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001880 struct ospf_area *area;
1881 struct in_addr area_id;
1882 struct prefix_list *plist;
1883 int format;
1884
1885 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1886
Paul Jakma1a8ec2b2006-05-11 13:34:08 +00001887 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1888 return CMD_SUCCESS;
1889
paul718e3742002-12-13 20:15:29 +00001890 plist = prefix_list_lookup (AFI_IP, argv[1]);
1891 if (strncmp (argv[2], "in", 2) == 0)
1892 {
1893 if (PREFIX_NAME_IN (area))
1894 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1895 return CMD_SUCCESS;
1896
1897 PREFIX_LIST_IN (area) = NULL;
1898 if (PREFIX_NAME_IN (area))
1899 free (PREFIX_NAME_IN (area));
1900
1901 PREFIX_NAME_IN (area) = NULL;
1902
paul68980082003-03-25 05:07:42 +00001903 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001904 }
1905 else
1906 {
1907 if (PREFIX_NAME_OUT (area))
1908 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1909 return CMD_SUCCESS;
1910
1911 PREFIX_LIST_OUT (area) = NULL;
1912 if (PREFIX_NAME_OUT (area))
1913 free (PREFIX_NAME_OUT (area));
1914
1915 PREFIX_NAME_OUT (area) = NULL;
1916
paul68980082003-03-25 05:07:42 +00001917 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001918 }
1919
1920 return CMD_SUCCESS;
1921}
1922
1923
paula2c62832003-04-23 17:01:31 +00001924DEFUN (ospf_area_authentication_message_digest,
1925 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001926 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1927 "OSPF area parameters\n"
1928 "Enable authentication\n"
1929 "Use message-digest authentication\n")
1930{
paul68980082003-03-25 05:07:42 +00001931 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001932 struct ospf_area *area;
1933 struct in_addr area_id;
1934 int format;
1935
1936 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1937
paul68980082003-03-25 05:07:42 +00001938 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001939 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1940
1941 return CMD_SUCCESS;
1942}
1943
paula2c62832003-04-23 17:01:31 +00001944DEFUN (ospf_area_authentication,
1945 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001946 "area (A.B.C.D|<0-4294967295>) authentication",
1947 "OSPF area parameters\n"
1948 "OSPF area ID in IP address format\n"
1949 "OSPF area ID as a decimal value\n"
1950 "Enable authentication\n")
1951{
paul68980082003-03-25 05:07:42 +00001952 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001953 struct ospf_area *area;
1954 struct in_addr area_id;
1955 int format;
1956
1957 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1958
paul68980082003-03-25 05:07:42 +00001959 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001960 area->auth_type = OSPF_AUTH_SIMPLE;
1961
1962 return CMD_SUCCESS;
1963}
1964
paula2c62832003-04-23 17:01:31 +00001965DEFUN (no_ospf_area_authentication,
1966 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001967 "no area (A.B.C.D|<0-4294967295>) authentication",
1968 NO_STR
1969 "OSPF area parameters\n"
1970 "OSPF area ID in IP address format\n"
1971 "OSPF area ID as a decimal value\n"
1972 "Enable authentication\n")
1973{
paul68980082003-03-25 05:07:42 +00001974 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001975 struct ospf_area *area;
1976 struct in_addr area_id;
1977 int format;
1978
1979 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1980
paul68980082003-03-25 05:07:42 +00001981 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001982 if (area == NULL)
1983 return CMD_SUCCESS;
1984
1985 area->auth_type = OSPF_AUTH_NULL;
1986
paul68980082003-03-25 05:07:42 +00001987 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001988
1989 return CMD_SUCCESS;
1990}
1991
1992
1993DEFUN (ospf_abr_type,
1994 ospf_abr_type_cmd,
1995 "ospf abr-type (cisco|ibm|shortcut|standard)",
1996 "OSPF specific commands\n"
1997 "Set OSPF ABR type\n"
1998 "Alternative ABR, cisco implementation\n"
1999 "Alternative ABR, IBM implementation\n"
2000 "Shortcut ABR\n"
2001 "Standard behavior (RFC2328)\n")
2002{
paul68980082003-03-25 05:07:42 +00002003 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002004 u_char abr_type = OSPF_ABR_UNKNOWN;
2005
2006 if (strncmp (argv[0], "c", 1) == 0)
2007 abr_type = OSPF_ABR_CISCO;
2008 else if (strncmp (argv[0], "i", 1) == 0)
2009 abr_type = OSPF_ABR_IBM;
2010 else if (strncmp (argv[0], "sh", 2) == 0)
2011 abr_type = OSPF_ABR_SHORTCUT;
2012 else if (strncmp (argv[0], "st", 2) == 0)
2013 abr_type = OSPF_ABR_STAND;
2014 else
2015 return CMD_WARNING;
2016
2017 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002018 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002019 {
paul68980082003-03-25 05:07:42 +00002020 ospf->abr_type = abr_type;
2021 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002022 }
2023
2024 return CMD_SUCCESS;
2025}
2026
2027DEFUN (no_ospf_abr_type,
2028 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002029 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002030 NO_STR
2031 "OSPF specific commands\n"
2032 "Set OSPF ABR type\n"
2033 "Alternative ABR, cisco implementation\n"
2034 "Alternative ABR, IBM implementation\n"
2035 "Shortcut ABR\n")
2036{
paul68980082003-03-25 05:07:42 +00002037 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002038 u_char abr_type = OSPF_ABR_UNKNOWN;
2039
2040 if (strncmp (argv[0], "c", 1) == 0)
2041 abr_type = OSPF_ABR_CISCO;
2042 else if (strncmp (argv[0], "i", 1) == 0)
2043 abr_type = OSPF_ABR_IBM;
2044 else if (strncmp (argv[0], "s", 1) == 0)
2045 abr_type = OSPF_ABR_SHORTCUT;
2046 else
2047 return CMD_WARNING;
2048
2049 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002050 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002051 {
pauld57834f2005-07-12 20:04:22 +00002052 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002053 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002054 }
2055
2056 return CMD_SUCCESS;
2057}
2058
2059DEFUN (ospf_compatible_rfc1583,
2060 ospf_compatible_rfc1583_cmd,
2061 "compatible rfc1583",
2062 "OSPF compatibility list\n"
2063 "compatible with RFC 1583\n")
2064{
2065 struct ospf *ospf = vty->index;
2066
2067 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2068 {
2069 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002070 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002071 }
2072 return CMD_SUCCESS;
2073}
2074
2075DEFUN (no_ospf_compatible_rfc1583,
2076 no_ospf_compatible_rfc1583_cmd,
2077 "no compatible rfc1583",
2078 NO_STR
2079 "OSPF compatibility list\n"
2080 "compatible with RFC 1583\n")
2081{
2082 struct ospf *ospf = vty->index;
2083
2084 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2085 {
2086 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002087 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002088 }
2089 return CMD_SUCCESS;
2090}
2091
2092ALIAS (ospf_compatible_rfc1583,
2093 ospf_rfc1583_flag_cmd,
2094 "ospf rfc1583compatibility",
2095 "OSPF specific commands\n"
2096 "Enable the RFC1583Compatibility flag\n")
2097
2098ALIAS (no_ospf_compatible_rfc1583,
2099 no_ospf_rfc1583_flag_cmd,
2100 "no ospf rfc1583compatibility",
2101 NO_STR
2102 "OSPF specific commands\n"
2103 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002104
2105static int
2106ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2107 unsigned int hold,
2108 unsigned int max)
2109{
2110 struct ospf *ospf = vty->index;
2111
2112 ospf->spf_delay = delay;
2113 ospf->spf_holdtime = hold;
2114 ospf->spf_max_holdtime = max;
2115
2116 return CMD_SUCCESS;
2117}
paul718e3742002-12-13 20:15:29 +00002118
pauld24f6e22005-10-21 09:23:12 +00002119DEFUN (ospf_timers_throttle_spf,
2120 ospf_timers_throttle_spf_cmd,
2121 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2122 "Adjust routing timers\n"
2123 "Throttling adaptive timer\n"
2124 "OSPF SPF timers\n"
2125 "Delay (msec) from first change received till SPF calculation\n"
2126 "Initial hold time (msec) between consecutive SPF calculations\n"
2127 "Maximum hold time (msec)\n")
2128{
2129 unsigned int delay, hold, max;
2130
2131 if (argc != 3)
2132 {
2133 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2134 return CMD_WARNING;
2135 }
2136
2137 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2138 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2139 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2140
2141 return ospf_timers_spf_set (vty, delay, hold, max);
2142}
2143
2144DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002145 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002146 "timers spf <0-4294967295> <0-4294967295>",
2147 "Adjust routing timers\n"
2148 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002149 "Delay (s) between receiving a change to SPF calculation\n"
2150 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002151{
pauld24f6e22005-10-21 09:23:12 +00002152 unsigned int delay, hold;
2153
2154 if (argc != 2)
2155 {
2156 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2157 return CMD_WARNING;
2158 }
2159
paul4dadc292005-05-06 21:37:42 +00002160 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2161 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002162
2163 /* truncate down the second values if they're greater than 600000ms */
2164 if (delay > (600000 / 1000))
2165 delay = 600000;
2166 else if (delay == 0)
2167 /* 0s delay was probably specified because of lack of ms resolution */
2168 delay = OSPF_SPF_DELAY_DEFAULT;
2169 if (hold > (600000 / 1000))
2170 hold = 600000;
2171
2172 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002173}
2174
pauld24f6e22005-10-21 09:23:12 +00002175DEFUN (no_ospf_timers_throttle_spf,
2176 no_ospf_timers_throttle_spf_cmd,
2177 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002178 NO_STR
2179 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002180 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002181 "OSPF SPF timers\n")
2182{
pauld24f6e22005-10-21 09:23:12 +00002183 return ospf_timers_spf_set (vty,
2184 OSPF_SPF_DELAY_DEFAULT,
2185 OSPF_SPF_HOLDTIME_DEFAULT,
2186 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002187}
2188
pauld24f6e22005-10-21 09:23:12 +00002189ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2190 no_ospf_timers_spf_cmd,
2191 "no timers spf",
2192 NO_STR
2193 "Adjust routing timers\n"
2194 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002195
paula2c62832003-04-23 17:01:31 +00002196DEFUN (ospf_neighbor,
2197 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002198 "neighbor A.B.C.D",
2199 NEIGHBOR_STR
2200 "Neighbor IP address\n")
2201{
2202 struct ospf *ospf = vty->index;
2203 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002204 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2205 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002206
2207 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2208
2209 if (argc > 1)
2210 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2211
2212 if (argc > 2)
2213 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2214
2215 ospf_nbr_nbma_set (ospf, nbr_addr);
2216 if (argc > 1)
2217 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2218 if (argc > 2)
2219 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2220
2221 return CMD_SUCCESS;
2222}
2223
paula2c62832003-04-23 17:01:31 +00002224ALIAS (ospf_neighbor,
2225 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002226 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2227 NEIGHBOR_STR
2228 "Neighbor IP address\n"
2229 "Neighbor Priority\n"
2230 "Priority\n"
2231 "Dead Neighbor Polling interval\n"
2232 "Seconds\n")
2233
paula2c62832003-04-23 17:01:31 +00002234ALIAS (ospf_neighbor,
2235 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002236 "neighbor A.B.C.D priority <0-255>",
2237 NEIGHBOR_STR
2238 "Neighbor IP address\n"
2239 "Neighbor Priority\n"
2240 "Seconds\n")
2241
paula2c62832003-04-23 17:01:31 +00002242DEFUN (ospf_neighbor_poll_interval,
2243 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002244 "neighbor A.B.C.D poll-interval <1-65535>",
2245 NEIGHBOR_STR
2246 "Neighbor IP address\n"
2247 "Dead Neighbor Polling interval\n"
2248 "Seconds\n")
2249{
2250 struct ospf *ospf = vty->index;
2251 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002252 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2253 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002254
2255 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2256
2257 if (argc > 1)
2258 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2259
2260 if (argc > 2)
2261 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2262
2263 ospf_nbr_nbma_set (ospf, nbr_addr);
2264 if (argc > 1)
2265 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2266 if (argc > 2)
2267 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2268
2269 return CMD_SUCCESS;
2270}
2271
paula2c62832003-04-23 17:01:31 +00002272ALIAS (ospf_neighbor_poll_interval,
2273 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002274 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2275 NEIGHBOR_STR
2276 "Neighbor address\n"
2277 "OSPF dead-router polling interval\n"
2278 "Seconds\n"
2279 "OSPF priority of non-broadcast neighbor\n"
2280 "Priority\n")
2281
paula2c62832003-04-23 17:01:31 +00002282DEFUN (no_ospf_neighbor,
2283 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002284 "no neighbor A.B.C.D",
2285 NO_STR
2286 NEIGHBOR_STR
2287 "Neighbor IP address\n")
2288{
2289 struct ospf *ospf = vty->index;
2290 struct in_addr nbr_addr;
2291 int ret;
2292
2293 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2294
2295 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2296
2297 return CMD_SUCCESS;
2298}
2299
paula2c62832003-04-23 17:01:31 +00002300ALIAS (no_ospf_neighbor,
2301 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002302 "no neighbor A.B.C.D priority <0-255>",
2303 NO_STR
2304 NEIGHBOR_STR
2305 "Neighbor IP address\n"
2306 "Neighbor Priority\n"
2307 "Priority\n")
2308
paula2c62832003-04-23 17:01:31 +00002309ALIAS (no_ospf_neighbor,
2310 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002311 "no neighbor A.B.C.D poll-interval <1-65535>",
2312 NO_STR
2313 NEIGHBOR_STR
2314 "Neighbor IP address\n"
2315 "Dead Neighbor Polling interval\n"
2316 "Seconds\n")
2317
paula2c62832003-04-23 17:01:31 +00002318ALIAS (no_ospf_neighbor,
2319 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002320 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2321 NO_STR
2322 NEIGHBOR_STR
2323 "Neighbor IP address\n"
2324 "Neighbor Priority\n"
2325 "Priority\n"
2326 "Dead Neighbor Polling interval\n"
2327 "Seconds\n")
2328
2329
paula2c62832003-04-23 17:01:31 +00002330DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002331 "refresh timer <10-1800>",
2332 "Adjust refresh parameters\n"
2333 "Set refresh timer\n"
2334 "Timer value in seconds\n")
2335{
2336 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002337 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002338
2339 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2340 interval = (interval / 10) * 10;
2341
2342 ospf_timers_refresh_set (ospf, interval);
2343
2344 return CMD_SUCCESS;
2345}
2346
paula2c62832003-04-23 17:01:31 +00002347DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002348 "no refresh timer <10-1800>",
2349 "Adjust refresh parameters\n"
2350 "Unset refresh timer\n"
2351 "Timer value in seconds\n")
2352{
2353 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002354 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002355
2356 if (argc == 1)
2357 {
2358 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2359
2360 if (ospf->lsa_refresh_interval != interval ||
2361 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2362 return CMD_SUCCESS;
2363 }
2364
2365 ospf_timers_refresh_unset (ospf);
2366
2367 return CMD_SUCCESS;
2368}
2369
paula2c62832003-04-23 17:01:31 +00002370ALIAS (no_ospf_refresh_timer,
2371 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002372 "no refresh timer",
2373 "Adjust refresh parameters\n"
2374 "Unset refresh timer\n")
2375
paula2c62832003-04-23 17:01:31 +00002376DEFUN (ospf_auto_cost_reference_bandwidth,
2377 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002378 "auto-cost reference-bandwidth <1-4294967>",
2379 "Calculate OSPF interface cost according to bandwidth\n"
2380 "Use reference bandwidth method to assign OSPF cost\n"
2381 "The reference bandwidth in terms of Mbits per second\n")
2382{
paul68980082003-03-25 05:07:42 +00002383 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002384 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002385 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002386 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002387
2388 refbw = strtol (argv[0], NULL, 10);
2389 if (refbw < 1 || refbw > 4294967)
2390 {
2391 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2392 return CMD_WARNING;
2393 }
2394
2395 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002396 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002397 return CMD_SUCCESS;
2398
paul68980082003-03-25 05:07:42 +00002399 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002400 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2401 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002402
2403 return CMD_SUCCESS;
2404}
2405
paula2c62832003-04-23 17:01:31 +00002406DEFUN (no_ospf_auto_cost_reference_bandwidth,
2407 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002408 "no auto-cost reference-bandwidth",
2409 NO_STR
2410 "Calculate OSPF interface cost according to bandwidth\n"
2411 "Use reference bandwidth method to assign OSPF cost\n")
2412{
paul68980082003-03-25 05:07:42 +00002413 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002414 struct listnode *node, *nnode;
2415 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002416
paul68980082003-03-25 05:07:42 +00002417 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002418 return CMD_SUCCESS;
2419
paul68980082003-03-25 05:07:42 +00002420 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002421 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2422 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2423
paul1eb8ef22005-04-07 07:30:20 +00002424 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2425 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002426
2427 return CMD_SUCCESS;
2428}
2429
hassoeb1ce602004-10-08 08:17:22 +00002430const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002431{
2432 "Unknown",
2433 "Standard (RFC2328)",
2434 "Alternative IBM",
2435 "Alternative Cisco",
2436 "Alternative Shortcut"
2437};
2438
hassoeb1ce602004-10-08 08:17:22 +00002439const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002440{
2441 "Default",
2442 "Enabled",
2443 "Disabled"
2444};
2445
2446
2447
paul4dadc292005-05-06 21:37:42 +00002448static void
paul718e3742002-12-13 20:15:29 +00002449show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2450{
2451 /* Show Area ID. */
2452 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2453
2454 /* Show Area type/mode. */
2455 if (OSPF_IS_AREA_BACKBONE (area))
2456 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2457 else
2458 {
2459 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002460 vty_out (vty, " (Stub%s%s)",
2461 area->no_summary ? ", no summary" : "",
2462 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002463
paulb0a053b2003-06-22 09:04:47 +00002464 else if (area->external_routing == OSPF_AREA_NSSA)
2465 vty_out (vty, " (NSSA%s%s)",
2466 area->no_summary ? ", no summary" : "",
2467 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002468
2469 vty_out (vty, "%s", VTY_NEWLINE);
2470 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002471 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002472 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002473 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002474 }
2475
2476 /* Show number of interfaces. */
2477 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2478 "Active: %d%s", listcount (area->oiflist),
2479 area->act_ints, VTY_NEWLINE);
2480
paul718e3742002-12-13 20:15:29 +00002481 if (area->external_routing == OSPF_AREA_NSSA)
2482 {
2483 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 +00002484 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002485 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2486 VTY_NEWLINE);
2487 else if (area->NSSATranslatorState)
2488 {
2489 vty_out (vty, " We are an ABR and ");
2490 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2491 vty_out (vty, "the NSSA Elected Translator. %s",
2492 VTY_NEWLINE);
2493 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2494 vty_out (vty, "always an NSSA Translator. %s",
2495 VTY_NEWLINE);
2496 }
paul718e3742002-12-13 20:15:29 +00002497 else
paulb0a053b2003-06-22 09:04:47 +00002498 {
2499 vty_out (vty, " We are an ABR, but ");
2500 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2501 vty_out (vty, "not the NSSA Elected Translator. %s",
2502 VTY_NEWLINE);
2503 else
hassoc6b87812004-12-22 13:09:59 +00002504 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002505 VTY_NEWLINE);
2506 }
paul718e3742002-12-13 20:15:29 +00002507 }
paul88d6cf32005-10-29 12:50:09 +00002508 /* Stub-router state for this area */
2509 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2510 {
ajs649654a2005-11-16 20:17:52 +00002511 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002512 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2513 VTY_NEWLINE);
2514 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2515 vty_out (vty, " Administratively activated (indefinitely)%s",
2516 VTY_NEWLINE);
2517 if (area->t_stub_router)
2518 vty_out (vty, " Active from startup, %s remaining%s",
2519 ospf_timer_dump (area->t_stub_router, timebuf,
2520 sizeof(timebuf)), VTY_NEWLINE);
2521 }
2522
paul718e3742002-12-13 20:15:29 +00002523 /* Show number of fully adjacent neighbors. */
2524 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002525 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002526
2527 /* Show authentication type. */
2528 vty_out (vty, " Area has ");
2529 if (area->auth_type == OSPF_AUTH_NULL)
2530 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2531 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2532 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2533 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2534 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2535
2536 if (!OSPF_IS_AREA_BACKBONE (area))
2537 vty_out (vty, " Number of full virtual adjacencies going through"
2538 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2539
2540 /* Show SPF calculation times. */
2541 vty_out (vty, " SPF algorithm executed %d times%s",
2542 area->spf_calculation, VTY_NEWLINE);
2543
2544 /* Show number of LSA. */
2545 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002546 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2547 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2548 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2549 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2550 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2551 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2552 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2553 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2554 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2555 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2556 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2557 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2558 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2559 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2560 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2561#ifdef HAVE_OPAQUE_LSA
2562 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2563 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2564 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2565 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2566 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2567 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2568#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002569 vty_out (vty, "%s", VTY_NEWLINE);
2570}
2571
2572DEFUN (show_ip_ospf,
2573 show_ip_ospf_cmd,
2574 "show ip ospf",
2575 SHOW_STR
2576 IP_STR
2577 "OSPF information\n")
2578{
paul1eb8ef22005-04-07 07:30:20 +00002579 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002580 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002581 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002582 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002583 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002584
2585 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002586 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002587 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002588 {
2589 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2590 return CMD_SUCCESS;
2591 }
2592
2593 /* Show Router ID. */
2594 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002595 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002596 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002597
2598 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002599 if (ospf->t_deferred_shutdown)
2600 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2601 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002602 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002603 /* Show capability. */
2604 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2605 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2606 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002607 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002608 "enabled" : "disabled", VTY_NEWLINE);
2609#ifdef HAVE_OPAQUE_LSA
2610 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002611 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002612 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002613 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002614 " (origination blocked)" : "",
2615 VTY_NEWLINE);
2616#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002617
2618 /* Show stub-router configuration */
2619 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2620 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2621 {
2622 vty_out (vty, " Stub router advertisement is configured%s",
2623 VTY_NEWLINE);
2624 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2625 vty_out (vty, " Enabled for %us after start-up%s",
2626 ospf->stub_router_startup_time, VTY_NEWLINE);
2627 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2628 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2629 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2630 }
2631
paul718e3742002-12-13 20:15:29 +00002632 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002633 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2634 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2635 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2636 " Hold time multiplier is currently %d%s",
2637 ospf->spf_delay, VTY_NEWLINE,
2638 ospf->spf_holdtime, VTY_NEWLINE,
2639 ospf->spf_max_holdtime, VTY_NEWLINE,
2640 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002641 vty_out (vty, " SPF algorithm ");
2642 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2643 {
paulc8c15212005-11-04 12:31:39 +00002644 result = tv_sub (recent_time, ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002645 vty_out (vty, "last executed %s ago%s",
2646 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2647 VTY_NEWLINE);
2648 }
2649 else
2650 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002651 vty_out (vty, " SPF timer %s%s%s",
2652 (ospf->t_spf_calc ? "due in " : "is "),
2653 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2654 VTY_NEWLINE);
2655
paul718e3742002-12-13 20:15:29 +00002656 /* Show refresh parameters. */
2657 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002658 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002659
2660 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002661 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002662 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002663 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002664
paul68980082003-03-25 05:07:42 +00002665 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002666 vty_out (vty, " This router is an ASBR "
2667 "(injecting external routing information)%s", VTY_NEWLINE);
2668
2669 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002670 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2671 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2672 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2673#ifdef HAVE_OPAQUE_LSA
2674 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2675 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2676 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2677#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002678 /* Show number of areas attached. */
2679 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002680 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002681
2682 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002683 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2684 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002685
2686 return CMD_SUCCESS;
2687}
2688
2689
ajsfd651fa2005-03-29 16:08:16 +00002690static void
paul68980082003-03-25 05:07:42 +00002691show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2692 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002693{
ajsfd651fa2005-03-29 16:08:16 +00002694 int is_up;
paul718e3742002-12-13 20:15:29 +00002695 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002696 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002697
paul718e3742002-12-13 20:15:29 +00002698 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002699 vty_out (vty, "%s is %s%s", ifp->name,
2700 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002701 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2702 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2703 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002704
2705 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002706 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002707 {
2708 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2709 return;
2710 }
ajsfd651fa2005-03-29 16:08:16 +00002711 else if (!is_up)
2712 {
2713 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2714 VTY_NEWLINE);
2715 return;
2716 }
2717
paul718e3742002-12-13 20:15:29 +00002718 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2719 {
2720 struct ospf_interface *oi = rn->info;
2721
2722 if (oi == NULL)
2723 continue;
2724
2725 /* Show OSPF interface information. */
2726 vty_out (vty, " Internet Address %s/%d,",
2727 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2728
Paul Jakma9c27ef92006-05-04 07:32:57 +00002729 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2730 {
2731 struct in_addr *dest;
2732 const char *dstr;
2733
2734 if ((ifp->flags & IFF_POINTOPOINT)
2735 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2736 dstr = "Peer";
2737 else
2738 dstr = "Broadcast";
2739
2740 /* For Vlinks, showing the peer address is probably more
2741 * informative than the local interface that is being used
2742 */
2743 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2744 dest = &oi->vl_data->peer_addr;
2745 else
2746 dest = &oi->connected->destination->u.prefix4;
2747
2748 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2749 }
hasso3fb9cd62004-10-19 19:44:43 +00002750
paul718e3742002-12-13 20:15:29 +00002751 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2752 VTY_NEWLINE);
2753
vincentba682532005-09-29 13:52:57 +00002754 vty_out (vty, " MTU mismatch detection:%s%s",
2755 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2756
paul718e3742002-12-13 20:15:29 +00002757 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002758 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002759 oi->output_cost, VTY_NEWLINE);
2760
2761 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2762 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2763 PRIORITY (oi), VTY_NEWLINE);
2764
2765 /* Show DR information. */
2766 if (DR (oi).s_addr == 0)
2767 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2768 else
2769 {
2770 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2771 if (nbr == NULL)
2772 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2773 else
2774 {
2775 vty_out (vty, " Designated Router (ID) %s,",
2776 inet_ntoa (nbr->router_id));
2777 vty_out (vty, " Interface Address %s%s",
2778 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2779 }
2780 }
2781
2782 /* Show BDR information. */
2783 if (BDR (oi).s_addr == 0)
2784 vty_out (vty, " No backup designated router on this network%s",
2785 VTY_NEWLINE);
2786 else
2787 {
2788 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2789 if (nbr == NULL)
2790 vty_out (vty, " No backup designated router on this network%s",
2791 VTY_NEWLINE);
2792 else
2793 {
2794 vty_out (vty, " Backup Designated Router (ID) %s,",
2795 inet_ntoa (nbr->router_id));
2796 vty_out (vty, " Interface Address %s%s",
2797 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2798 }
2799 }
ajsba6454e2005-02-08 15:37:30 +00002800
2801 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002802 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2803 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2804 {
2805 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2806 vty_out (vty, " OSPFAllRouters");
2807 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2808 vty_out (vty, " OSPFDesignatedRouters");
2809 }
2810 else
ajsba6454e2005-02-08 15:37:30 +00002811 vty_out (vty, " <None>");
2812 vty_out (vty, "%s", VTY_NEWLINE);
2813
paul718e3742002-12-13 20:15:29 +00002814 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002815 vty_out (vty, " Hello ");
2816 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2817 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2818 else
2819 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2820 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2821 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002822 OSPF_IF_PARAM (oi, v_wait),
2823 OSPF_IF_PARAM (oi, retransmit_interval),
2824 VTY_NEWLINE);
2825
2826 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002827 {
ajs649654a2005-11-16 20:17:52 +00002828 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002829 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002830 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002831 VTY_NEWLINE);
2832 }
paul718e3742002-12-13 20:15:29 +00002833 else /* OSPF_IF_PASSIVE is set */
2834 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2835
2836 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002837 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002838 VTY_NEWLINE);
2839 }
2840}
2841
2842DEFUN (show_ip_ospf_interface,
2843 show_ip_ospf_interface_cmd,
2844 "show ip ospf interface [INTERFACE]",
2845 SHOW_STR
2846 IP_STR
2847 "OSPF information\n"
2848 "Interface information\n"
2849 "Interface name\n")
2850{
2851 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002852 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002853 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002854
paul020709f2003-04-04 02:44:16 +00002855 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002856 if (ospf == NULL)
2857 {
2858 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2859 return CMD_SUCCESS;
2860 }
paul020709f2003-04-04 02:44:16 +00002861
paul718e3742002-12-13 20:15:29 +00002862 /* Show All Interfaces. */
2863 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002864 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2865 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002866 /* Interface name is specified. */
2867 else
2868 {
2869 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2870 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2871 else
paul68980082003-03-25 05:07:42 +00002872 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002873 }
2874
2875 return CMD_SUCCESS;
2876}
2877
paul4dadc292005-05-06 21:37:42 +00002878static void
pauld24f6e22005-10-21 09:23:12 +00002879show_ip_ospf_neighbour_header (struct vty *vty)
2880{
2881 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2882 VTY_NEWLINE,
2883 "Neighbor ID", "Pri", "State", "Dead Time",
2884 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
2885 VTY_NEWLINE);
2886}
2887
2888static void
paul718e3742002-12-13 20:15:29 +00002889show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2890{
2891 struct route_node *rn;
2892 struct ospf_neighbor *nbr;
2893 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00002894 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002895
2896 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2897 if ((nbr = rn->info))
2898 /* Do not show myself. */
2899 if (nbr != oi->nbr_self)
2900 /* Down state is not shown. */
2901 if (nbr->state != NSM_Down)
2902 {
2903 ospf_nbr_state_message (nbr, msgbuf, 16);
2904
2905 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00002906 vty_out (vty, "%-15s %3d %-15s ",
2907 "-", nbr->priority,
2908 msgbuf);
2909 else
2910 vty_out (vty, "%-15s %3d %-15s ",
2911 inet_ntoa (nbr->router_id), nbr->priority,
2912 msgbuf);
2913
2914 vty_out (vty, "%9s ",
2915 ospf_timer_dump (nbr->t_inactivity, timebuf,
2916 sizeof(timebuf)));
2917
paul718e3742002-12-13 20:15:29 +00002918 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00002919 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00002920 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2921 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2922 VTY_NEWLINE);
2923 }
2924}
2925
2926DEFUN (show_ip_ospf_neighbor,
2927 show_ip_ospf_neighbor_cmd,
2928 "show ip ospf neighbor",
2929 SHOW_STR
2930 IP_STR
2931 "OSPF information\n"
2932 "Neighbor list\n")
2933{
paul020709f2003-04-04 02:44:16 +00002934 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002935 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002936 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002937
paul020709f2003-04-04 02:44:16 +00002938 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002939 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002940 {
2941 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2942 return CMD_SUCCESS;
2943 }
2944
pauld24f6e22005-10-21 09:23:12 +00002945 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00002946
paul1eb8ef22005-04-07 07:30:20 +00002947 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
2948 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00002949
2950 return CMD_SUCCESS;
2951}
2952
2953DEFUN (show_ip_ospf_neighbor_all,
2954 show_ip_ospf_neighbor_all_cmd,
2955 "show ip ospf neighbor all",
2956 SHOW_STR
2957 IP_STR
2958 "OSPF information\n"
2959 "Neighbor list\n"
2960 "include down status neighbor\n")
2961{
paul68980082003-03-25 05:07:42 +00002962 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002963 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002964 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002965
paul68980082003-03-25 05:07:42 +00002966 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002967 {
2968 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2969 return CMD_SUCCESS;
2970 }
pauld24f6e22005-10-21 09:23:12 +00002971
2972 show_ip_ospf_neighbour_header (vty);
2973
paul1eb8ef22005-04-07 07:30:20 +00002974 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00002975 {
hasso52dc7ee2004-09-23 19:18:23 +00002976 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00002977 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00002978
2979 show_ip_ospf_neighbor_sub (vty, oi);
2980
2981 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00002982 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00002983 {
paul718e3742002-12-13 20:15:29 +00002984 if (nbr_nbma->nbr == NULL
2985 || nbr_nbma->nbr->state == NSM_Down)
2986 {
pauld24f6e22005-10-21 09:23:12 +00002987 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00002988 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00002989 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00002990 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2991 0, 0, 0, VTY_NEWLINE);
2992 }
2993 }
2994 }
2995
2996 return CMD_SUCCESS;
2997}
2998
2999DEFUN (show_ip_ospf_neighbor_int,
3000 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003001 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003002 SHOW_STR
3003 IP_STR
3004 "OSPF information\n"
3005 "Neighbor list\n"
3006 "Interface name\n")
3007{
paul020709f2003-04-04 02:44:16 +00003008 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003009 struct interface *ifp;
3010 struct route_node *rn;
3011
3012 ifp = if_lookup_by_name (argv[0]);
3013 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003014 {
hassobb5b7552005-08-21 20:01:15 +00003015 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003016 return CMD_WARNING;
3017 }
3018
paul020709f2003-04-04 02:44:16 +00003019 ospf = ospf_lookup ();
3020 if (ospf == NULL)
3021 {
3022 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3023 return CMD_SUCCESS;
3024 }
pauld24f6e22005-10-21 09:23:12 +00003025
3026 show_ip_ospf_neighbour_header (vty);
3027
hassobb5b7552005-08-21 20:01:15 +00003028 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003029 {
hassobb5b7552005-08-21 20:01:15 +00003030 struct ospf_interface *oi = rn->info;
3031
3032 if (oi == NULL)
3033 continue;
3034
paul718e3742002-12-13 20:15:29 +00003035 show_ip_ospf_neighbor_sub (vty, oi);
3036 }
3037
3038 return CMD_SUCCESS;
3039}
3040
paul4dadc292005-05-06 21:37:42 +00003041static void
paul718e3742002-12-13 20:15:29 +00003042show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3043 struct ospf_nbr_nbma *nbr_nbma)
3044{
ajs649654a2005-11-16 20:17:52 +00003045 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003046
3047 /* Show neighbor ID. */
3048 vty_out (vty, " Neighbor %s,", "-");
3049
3050 /* Show interface address. */
3051 vty_out (vty, " interface address %s%s",
3052 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3053 /* Show Area ID. */
3054 vty_out (vty, " In the area %s via interface %s%s",
3055 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3056 /* Show neighbor priority and state. */
3057 vty_out (vty, " Neighbor priority is %d, State is %s,",
3058 nbr_nbma->priority, "Down");
3059 /* Show state changes. */
3060 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3061
3062 /* Show PollInterval */
3063 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3064
3065 /* Show poll-interval timer. */
3066 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003067 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3068 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003069
3070 /* Show poll-interval timer thread. */
3071 vty_out (vty, " Thread Poll Timer %s%s",
3072 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3073}
3074
paul4dadc292005-05-06 21:37:42 +00003075static void
paul718e3742002-12-13 20:15:29 +00003076show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3077 struct ospf_neighbor *nbr)
3078{
ajs649654a2005-11-16 20:17:52 +00003079 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003080
3081 /* Show neighbor ID. */
3082 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3083 vty_out (vty, " Neighbor %s,", "-");
3084 else
3085 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3086
3087 /* Show interface address. */
3088 vty_out (vty, " interface address %s%s",
3089 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3090 /* Show Area ID. */
3091 vty_out (vty, " In the area %s via interface %s%s",
3092 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3093 /* Show neighbor priority and state. */
3094 vty_out (vty, " Neighbor priority is %d, State is %s,",
3095 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3096 /* Show state changes. */
3097 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3098
3099 /* Show Designated Rotuer ID. */
3100 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3101 /* Show Backup Designated Rotuer ID. */
3102 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3103 /* Show options. */
3104 vty_out (vty, " Options %d %s%s", nbr->options,
3105 ospf_options_dump (nbr->options), VTY_NEWLINE);
3106 /* Show Router Dead interval timer. */
3107 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003108 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3109 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003110 /* Show Database Summary list. */
3111 vty_out (vty, " Database Summary List %d%s",
3112 ospf_db_summary_count (nbr), VTY_NEWLINE);
3113 /* Show Link State Request list. */
3114 vty_out (vty, " Link State Request List %ld%s",
3115 ospf_ls_request_count (nbr), VTY_NEWLINE);
3116 /* Show Link State Retransmission list. */
3117 vty_out (vty, " Link State Retransmission List %ld%s",
3118 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3119 /* Show inactivity timer thread. */
3120 vty_out (vty, " Thread Inactivity Timer %s%s",
3121 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3122 /* Show Database Description retransmission thread. */
3123 vty_out (vty, " Thread Database Description Retransmision %s%s",
3124 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3125 /* Show Link State Request Retransmission thread. */
3126 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3127 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3128 /* Show Link State Update Retransmission thread. */
3129 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3130 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3131}
3132
3133DEFUN (show_ip_ospf_neighbor_id,
3134 show_ip_ospf_neighbor_id_cmd,
3135 "show ip ospf neighbor A.B.C.D",
3136 SHOW_STR
3137 IP_STR
3138 "OSPF information\n"
3139 "Neighbor list\n"
3140 "Neighbor ID\n")
3141{
paul020709f2003-04-04 02:44:16 +00003142 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003143 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003144 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003145 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003146 struct in_addr router_id;
3147 int ret;
3148
3149 ret = inet_aton (argv[0], &router_id);
3150 if (!ret)
3151 {
3152 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3153 return CMD_WARNING;
3154 }
3155
paul020709f2003-04-04 02:44:16 +00003156 ospf = ospf_lookup ();
3157 if (ospf == NULL)
3158 {
3159 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3160 return CMD_SUCCESS;
3161 }
3162
paul1eb8ef22005-04-07 07:30:20 +00003163 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3164 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3165 {
3166 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3167 return CMD_SUCCESS;
3168 }
paul718e3742002-12-13 20:15:29 +00003169
3170 /* Nothing to show. */
3171 return CMD_SUCCESS;
3172}
3173
3174DEFUN (show_ip_ospf_neighbor_detail,
3175 show_ip_ospf_neighbor_detail_cmd,
3176 "show ip ospf neighbor detail",
3177 SHOW_STR
3178 IP_STR
3179 "OSPF information\n"
3180 "Neighbor list\n"
3181 "detail of all neighbors\n")
3182{
paul020709f2003-04-04 02:44:16 +00003183 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003184 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003185 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003186
paul020709f2003-04-04 02:44:16 +00003187 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003188 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003189 {
3190 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3191 return CMD_SUCCESS;
3192 }
paul718e3742002-12-13 20:15:29 +00003193
paul1eb8ef22005-04-07 07:30:20 +00003194 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003195 {
paul718e3742002-12-13 20:15:29 +00003196 struct route_node *rn;
3197 struct ospf_neighbor *nbr;
3198
3199 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3200 if ((nbr = rn->info))
3201 if (nbr != oi->nbr_self)
3202 if (nbr->state != NSM_Down)
3203 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3204 }
3205
3206 return CMD_SUCCESS;
3207}
3208
3209DEFUN (show_ip_ospf_neighbor_detail_all,
3210 show_ip_ospf_neighbor_detail_all_cmd,
3211 "show ip ospf neighbor detail all",
3212 SHOW_STR
3213 IP_STR
3214 "OSPF information\n"
3215 "Neighbor list\n"
3216 "detail of all neighbors\n"
3217 "include down status neighbor\n")
3218{
paul020709f2003-04-04 02:44:16 +00003219 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003220 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003221 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003222
paul020709f2003-04-04 02:44:16 +00003223 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003224 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003225 {
3226 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3227 return CMD_SUCCESS;
3228 }
paul718e3742002-12-13 20:15:29 +00003229
paul1eb8ef22005-04-07 07:30:20 +00003230 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003231 {
paul718e3742002-12-13 20:15:29 +00003232 struct route_node *rn;
3233 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003234 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003235
3236 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3237 if ((nbr = rn->info))
3238 if (nbr != oi->nbr_self)
3239 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3240 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3241
3242 if (oi->type == OSPF_IFTYPE_NBMA)
3243 {
hasso52dc7ee2004-09-23 19:18:23 +00003244 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003245
paul1eb8ef22005-04-07 07:30:20 +00003246 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3247 if (nbr_nbma->nbr == NULL
3248 || nbr_nbma->nbr->state == NSM_Down)
3249 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003250 }
3251 }
3252
3253 return CMD_SUCCESS;
3254}
3255
3256DEFUN (show_ip_ospf_neighbor_int_detail,
3257 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003258 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003259 SHOW_STR
3260 IP_STR
3261 "OSPF information\n"
3262 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003263 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003264 "detail of all neighbors")
3265{
paul020709f2003-04-04 02:44:16 +00003266 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003267 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003268 struct interface *ifp;
3269 struct route_node *rn, *nrn;
3270 struct ospf_neighbor *nbr;
3271
3272 ifp = if_lookup_by_name (argv[0]);
3273 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003274 {
hassobb5b7552005-08-21 20:01:15 +00003275 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003276 return CMD_WARNING;
3277 }
3278
paul020709f2003-04-04 02:44:16 +00003279 ospf = ospf_lookup ();
3280 if (ospf == NULL)
3281 {
3282 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3283 return CMD_SUCCESS;
3284 }
paul68980082003-03-25 05:07:42 +00003285
paul718e3742002-12-13 20:15:29 +00003286
hassobb5b7552005-08-21 20:01:15 +00003287 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3288 if ((oi = rn->info))
3289 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3290 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003291 if (nbr != oi->nbr_self)
3292 if (nbr->state != NSM_Down)
3293 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003294
3295 return CMD_SUCCESS;
3296}
3297
3298
3299/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003300static int
paul020709f2003-04-04 02:44:16 +00003301show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003302{
paul718e3742002-12-13 20:15:29 +00003303 struct router_lsa *rl;
3304 struct summary_lsa *sl;
3305 struct as_external_lsa *asel;
3306 struct prefix_ipv4 p;
3307
3308 if (lsa != NULL)
3309 /* If self option is set, check LSA self flag. */
3310 if (self == 0 || IS_LSA_SELF (lsa))
3311 {
3312 /* LSA common part show. */
3313 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3314 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3315 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3316 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3317 /* LSA specific part show. */
3318 switch (lsa->data->type)
3319 {
3320 case OSPF_ROUTER_LSA:
3321 rl = (struct router_lsa *) lsa->data;
3322 vty_out (vty, " %-d", ntohs (rl->links));
3323 break;
3324 case OSPF_SUMMARY_LSA:
3325 sl = (struct summary_lsa *) lsa->data;
3326
3327 p.family = AF_INET;
3328 p.prefix = sl->header.id;
3329 p.prefixlen = ip_masklen (sl->mask);
3330 apply_mask_ipv4 (&p);
3331
3332 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3333 break;
3334 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003335 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003336 asel = (struct as_external_lsa *) lsa->data;
3337
3338 p.family = AF_INET;
3339 p.prefix = asel->header.id;
3340 p.prefixlen = ip_masklen (asel->mask);
3341 apply_mask_ipv4 (&p);
3342
3343 vty_out (vty, " %s %s/%d [0x%lx]",
3344 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3345 inet_ntoa (p.prefix), p.prefixlen,
3346 (u_long)ntohl (asel->e[0].route_tag));
3347 break;
3348 case OSPF_NETWORK_LSA:
3349 case OSPF_ASBR_SUMMARY_LSA:
3350#ifdef HAVE_OPAQUE_LSA
3351 case OSPF_OPAQUE_LINK_LSA:
3352 case OSPF_OPAQUE_AREA_LSA:
3353 case OSPF_OPAQUE_AS_LSA:
3354#endif /* HAVE_OPAQUE_LSA */
3355 default:
3356 break;
3357 }
3358 vty_out (vty, VTY_NEWLINE);
3359 }
3360
3361 return 0;
3362}
3363
hassoeb1ce602004-10-08 08:17:22 +00003364const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003365{
3366 "unknown",
3367 "Router Link States",
3368 "Net Link States",
3369 "Summary Link States",
3370 "ASBR-Summary Link States",
3371 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003372 "Group Membership LSA",
3373 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003374#ifdef HAVE_OPAQUE_LSA
3375 "Type-8 LSA",
3376 "Link-Local Opaque-LSA",
3377 "Area-Local Opaque-LSA",
3378 "AS-external Opaque-LSA",
3379#endif /* HAVE_OPAQUE_LSA */
3380};
3381
3382#define SHOW_OSPF_COMMON_HEADER \
3383 "Link ID ADV Router Age Seq# CkSum"
3384
hassoeb1ce602004-10-08 08:17:22 +00003385const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003386{
3387 "",
3388 "Link ID ADV Router Age Seq# CkSum Link count",
3389 "Link ID ADV Router Age Seq# CkSum",
3390 "Link ID ADV Router Age Seq# CkSum Route",
3391 "Link ID ADV Router Age Seq# CkSum",
3392 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003393 " --- header for Group Member ----",
3394 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003395#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003396 " --- type-8 ---",
3397 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3398 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3399 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3400#endif /* HAVE_OPAQUE_LSA */
3401};
3402
hassoeb1ce602004-10-08 08:17:22 +00003403const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003404{
3405 "Self-originated",
3406 "Checked",
3407 "Received",
3408 "Approved",
3409 "Discard",
paul4957f492003-06-27 01:28:45 +00003410 "Translated",
paul4957f492003-06-27 01:28:45 +00003411};
3412
paul4dadc292005-05-06 21:37:42 +00003413static void
paul718e3742002-12-13 20:15:29 +00003414show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3415{
3416 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003417
paul718e3742002-12-13 20:15:29 +00003418 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003419 vty_out (vty, " Options: 0x%-2x : %s%s",
3420 lsa->data->options,
3421 ospf_options_dump(lsa->data->options),
3422 VTY_NEWLINE);
3423 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003424 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003425 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3426 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003427
3428 if (lsa->data->type == OSPF_ROUTER_LSA)
3429 {
3430 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3431
3432 if (rlsa->flags)
3433 vty_out (vty, " :%s%s%s%s",
3434 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3435 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3436 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3437 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3438
3439 vty_out (vty, "%s", VTY_NEWLINE);
3440 }
3441 vty_out (vty, " LS Type: %s%s",
3442 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3443 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3444 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3445 vty_out (vty, " Advertising Router: %s%s",
3446 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3447 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3448 VTY_NEWLINE);
3449 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3450 VTY_NEWLINE);
3451 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3452}
3453
hassoeb1ce602004-10-08 08:17:22 +00003454const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003455{
3456 "(null)",
3457 "another Router (point-to-point)",
3458 "a Transit Network",
3459 "Stub Network",
3460 "a Virtual Link",
3461};
3462
hassoeb1ce602004-10-08 08:17:22 +00003463const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003464{
3465 "(null)",
3466 "Neighboring Router ID",
3467 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003468 "Net",
paul718e3742002-12-13 20:15:29 +00003469 "Neighboring Router ID",
3470};
3471
hassoeb1ce602004-10-08 08:17:22 +00003472const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003473{
3474 "(null)",
3475 "Router Interface address",
3476 "Router Interface address",
3477 "Network Mask",
3478 "Router Interface address",
3479};
3480
3481/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003482static void
paul718e3742002-12-13 20:15:29 +00003483show_ip_ospf_database_router_links (struct vty *vty,
3484 struct router_lsa *rl)
3485{
3486 int len, i, type;
3487
3488 len = ntohs (rl->header.length) - 4;
3489 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3490 {
3491 type = rl->link[i].type;
3492
3493 vty_out (vty, " Link connected to: %s%s",
3494 link_type_desc[type], VTY_NEWLINE);
3495 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3496 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3497 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3498 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3499 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3500 vty_out (vty, " TOS 0 Metric: %d%s",
3501 ntohs (rl->link[i].metric), VTY_NEWLINE);
3502 vty_out (vty, "%s", VTY_NEWLINE);
3503 }
3504}
3505
3506/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003507static int
paul718e3742002-12-13 20:15:29 +00003508show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3509{
3510 if (lsa != NULL)
3511 {
3512 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3513
3514 show_ip_ospf_database_header (vty, lsa);
3515
3516 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3517 VTY_NEWLINE, VTY_NEWLINE);
3518
3519 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003520 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003521 }
3522
3523 return 0;
3524}
3525
3526/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003527static int
paul718e3742002-12-13 20:15:29 +00003528show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3529{
3530 int length, i;
3531
3532 if (lsa != NULL)
3533 {
3534 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3535
3536 show_ip_ospf_database_header (vty, lsa);
3537
3538 vty_out (vty, " Network Mask: /%d%s",
3539 ip_masklen (nl->mask), VTY_NEWLINE);
3540
3541 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3542
3543 for (i = 0; length > 0; i++, length -= 4)
3544 vty_out (vty, " Attached Router: %s%s",
3545 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3546
3547 vty_out (vty, "%s", VTY_NEWLINE);
3548 }
3549
3550 return 0;
3551}
3552
3553/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003554static int
paul718e3742002-12-13 20:15:29 +00003555show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3556{
3557 if (lsa != NULL)
3558 {
3559 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3560
3561 show_ip_ospf_database_header (vty, lsa);
3562
3563 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3564 VTY_NEWLINE);
3565 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3566 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003567 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003568 }
3569
3570 return 0;
3571}
3572
3573/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003574static int
paul718e3742002-12-13 20:15:29 +00003575show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3576{
3577 if (lsa != NULL)
3578 {
3579 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3580
3581 show_ip_ospf_database_header (vty, lsa);
3582
3583 vty_out (vty, " Network Mask: /%d%s",
3584 ip_masklen (sl->mask), VTY_NEWLINE);
3585 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3586 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003587 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003588 }
3589
3590 return 0;
3591}
3592
3593/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003594static int
paul718e3742002-12-13 20:15:29 +00003595show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3596{
3597 if (lsa != NULL)
3598 {
3599 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3600
3601 show_ip_ospf_database_header (vty, lsa);
3602
3603 vty_out (vty, " Network Mask: /%d%s",
3604 ip_masklen (al->mask), VTY_NEWLINE);
3605 vty_out (vty, " Metric Type: %s%s",
3606 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3607 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3608 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3609 vty_out (vty, " Metric: %d%s",
3610 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3611 vty_out (vty, " Forward Address: %s%s",
3612 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3613
3614 vty_out (vty, " External Route Tag: %lu%s%s",
3615 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3616 }
3617
3618 return 0;
3619}
3620
ajs2a42e282004-12-08 18:43:03 +00003621/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003622static int
paul718e3742002-12-13 20:15:29 +00003623show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3624{
3625 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3626
3627 /* show_ip_ospf_database_header (vty, lsa); */
3628
ajs2a42e282004-12-08 18:43:03 +00003629 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003630 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003631 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003632 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3633 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003634 zlog_debug( " TOS: 0%s", "\n");
3635 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003636 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003637 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003638 inet_ntoa (al->e[0].fwd_addr), "\n");
3639
ajs2a42e282004-12-08 18:43:03 +00003640 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003641 ntohl (al->e[0].route_tag), "\n", "\n");
3642
3643 return 0;
3644}
3645
3646/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003647static int
paul718e3742002-12-13 20:15:29 +00003648show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3649{
3650 if (lsa != NULL)
3651 {
3652 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3653
3654 show_ip_ospf_database_header (vty, lsa);
3655
3656 vty_out (vty, " Network Mask: /%d%s",
3657 ip_masklen (al->mask), VTY_NEWLINE);
3658 vty_out (vty, " Metric Type: %s%s",
3659 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3660 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3661 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3662 vty_out (vty, " Metric: %d%s",
3663 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3664 vty_out (vty, " NSSA: Forward Address: %s%s",
3665 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3666
3667 vty_out (vty, " External Route Tag: %u%s%s",
3668 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3669 }
3670
3671 return 0;
3672}
3673
paul4dadc292005-05-06 21:37:42 +00003674static int
paul718e3742002-12-13 20:15:29 +00003675show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3676{
3677 return 0;
3678}
3679
3680#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003681static int
paul718e3742002-12-13 20:15:29 +00003682show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3683{
3684 if (lsa != NULL)
3685 {
3686 show_ip_ospf_database_header (vty, lsa);
3687 show_opaque_info_detail (vty, lsa);
3688
3689 vty_out (vty, "%s", VTY_NEWLINE);
3690 }
3691 return 0;
3692}
3693#endif /* HAVE_OPAQUE_LSA */
3694
3695int (*show_function[])(struct vty *, struct ospf_lsa *) =
3696{
3697 NULL,
3698 show_router_lsa_detail,
3699 show_network_lsa_detail,
3700 show_summary_lsa_detail,
3701 show_summary_asbr_lsa_detail,
3702 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003703 show_func_dummy,
3704 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003705#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003706 NULL, /* type-8 */
3707 show_opaque_lsa_detail,
3708 show_opaque_lsa_detail,
3709 show_opaque_lsa_detail,
3710#endif /* HAVE_OPAQUE_LSA */
3711};
3712
paul4dadc292005-05-06 21:37:42 +00003713static void
paul718e3742002-12-13 20:15:29 +00003714show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3715 struct in_addr *adv_router)
3716{
3717 memset (lp, 0, sizeof (struct prefix_ls));
3718 lp->family = 0;
3719 if (id == NULL)
3720 lp->prefixlen = 0;
3721 else if (adv_router == NULL)
3722 {
3723 lp->prefixlen = 32;
3724 lp->id = *id;
3725 }
3726 else
3727 {
3728 lp->prefixlen = 64;
3729 lp->id = *id;
3730 lp->adv_router = *adv_router;
3731 }
3732}
3733
paul4dadc292005-05-06 21:37:42 +00003734static void
paul718e3742002-12-13 20:15:29 +00003735show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3736 struct in_addr *id, struct in_addr *adv_router)
3737{
3738 struct prefix_ls lp;
3739 struct route_node *rn, *start;
3740 struct ospf_lsa *lsa;
3741
3742 show_lsa_prefix_set (vty, &lp, id, adv_router);
3743 start = route_node_get (rt, (struct prefix *) &lp);
3744 if (start)
3745 {
3746 route_lock_node (start);
3747 for (rn = start; rn; rn = route_next_until (rn, start))
3748 if ((lsa = rn->info))
3749 {
paul718e3742002-12-13 20:15:29 +00003750 if (show_function[lsa->data->type] != NULL)
3751 show_function[lsa->data->type] (vty, lsa);
3752 }
3753 route_unlock_node (start);
3754 }
3755}
3756
3757/* Show detail LSA information
3758 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003759static void
paul020709f2003-04-04 02:44:16 +00003760show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003761 struct in_addr *id, struct in_addr *adv_router)
3762{
hasso52dc7ee2004-09-23 19:18:23 +00003763 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003764 struct ospf_area *area;
3765
paul718e3742002-12-13 20:15:29 +00003766 switch (type)
3767 {
3768 case OSPF_AS_EXTERNAL_LSA:
3769#ifdef HAVE_OPAQUE_LSA
3770 case OSPF_OPAQUE_AS_LSA:
3771#endif /* HAVE_OPAQUE_LSA */
3772 vty_out (vty, " %s %s%s",
3773 show_database_desc[type],
3774 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003775 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003776 break;
3777 default:
paul1eb8ef22005-04-07 07:30:20 +00003778 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003779 {
paul718e3742002-12-13 20:15:29 +00003780 vty_out (vty, "%s %s (Area %s)%s%s",
3781 VTY_NEWLINE, show_database_desc[type],
3782 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3783 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3784 }
3785 break;
3786 }
3787}
3788
paul4dadc292005-05-06 21:37:42 +00003789static void
paul718e3742002-12-13 20:15:29 +00003790show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3791 struct in_addr *adv_router)
3792{
3793 struct route_node *rn;
3794 struct ospf_lsa *lsa;
3795
3796 for (rn = route_top (rt); rn; rn = route_next (rn))
3797 if ((lsa = rn->info))
3798 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3799 {
paul718e3742002-12-13 20:15:29 +00003800 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3801 continue;
paul718e3742002-12-13 20:15:29 +00003802 if (show_function[lsa->data->type] != NULL)
3803 show_function[lsa->data->type] (vty, lsa);
3804 }
3805}
3806
3807/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003808static void
paul020709f2003-04-04 02:44:16 +00003809show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003810 struct in_addr *adv_router)
3811{
hasso52dc7ee2004-09-23 19:18:23 +00003812 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003813 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003814
3815 switch (type)
3816 {
3817 case OSPF_AS_EXTERNAL_LSA:
3818#ifdef HAVE_OPAQUE_LSA
3819 case OSPF_OPAQUE_AS_LSA:
3820#endif /* HAVE_OPAQUE_LSA */
3821 vty_out (vty, " %s %s%s",
3822 show_database_desc[type],
3823 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003824 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003825 adv_router);
3826 break;
3827 default:
paul1eb8ef22005-04-07 07:30:20 +00003828 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003829 {
paul718e3742002-12-13 20:15:29 +00003830 vty_out (vty, "%s %s (Area %s)%s%s",
3831 VTY_NEWLINE, show_database_desc[type],
3832 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3833 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3834 adv_router);
3835 }
3836 break;
3837 }
3838}
3839
paul4dadc292005-05-06 21:37:42 +00003840static void
paul020709f2003-04-04 02:44:16 +00003841show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003842{
paul020709f2003-04-04 02:44:16 +00003843 struct ospf_lsa *lsa;
3844 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003845 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003846 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003847 int type;
3848
paul1eb8ef22005-04-07 07:30:20 +00003849 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003850 {
paul718e3742002-12-13 20:15:29 +00003851 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3852 {
3853 switch (type)
3854 {
3855 case OSPF_AS_EXTERNAL_LSA:
3856#ifdef HAVE_OPAQUE_LSA
3857 case OSPF_OPAQUE_AS_LSA:
3858#endif /* HAVE_OPAQUE_LSA */
3859 continue;
3860 default:
3861 break;
3862 }
3863 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3864 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3865 {
3866 vty_out (vty, " %s (Area %s)%s%s",
3867 show_database_desc[type],
3868 ospf_area_desc_string (area),
3869 VTY_NEWLINE, VTY_NEWLINE);
3870 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3871
paul020709f2003-04-04 02:44:16 +00003872 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3873 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003874
3875 vty_out (vty, "%s", VTY_NEWLINE);
3876 }
3877 }
3878 }
3879
3880 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3881 {
3882 switch (type)
3883 {
3884 case OSPF_AS_EXTERNAL_LSA:
3885#ifdef HAVE_OPAQUE_LSA
3886 case OSPF_OPAQUE_AS_LSA:
3887#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00003888 break;
paul718e3742002-12-13 20:15:29 +00003889 default:
3890 continue;
3891 }
paul68980082003-03-25 05:07:42 +00003892 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3893 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003894 {
3895 vty_out (vty, " %s%s%s",
3896 show_database_desc[type],
3897 VTY_NEWLINE, VTY_NEWLINE);
3898 vty_out (vty, "%s%s", show_database_header[type],
3899 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003900
3901 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3902 show_lsa_summary (vty, lsa, self);
3903
paul718e3742002-12-13 20:15:29 +00003904 vty_out (vty, "%s", VTY_NEWLINE);
3905 }
3906 }
3907
3908 vty_out (vty, "%s", VTY_NEWLINE);
3909}
3910
paul4dadc292005-05-06 21:37:42 +00003911static void
paul020709f2003-04-04 02:44:16 +00003912show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003913{
hasso52dc7ee2004-09-23 19:18:23 +00003914 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003915 struct ospf_lsa *lsa;
3916
3917 vty_out (vty, "%s MaxAge Link States:%s%s",
3918 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3919
paul1eb8ef22005-04-07 07:30:20 +00003920 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3921 {
3922 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3923 vty_out (vty, "Link State ID: %s%s",
3924 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3925 vty_out (vty, "Advertising Router: %s%s",
3926 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3927 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3928 vty_out (vty, "%s", VTY_NEWLINE);
3929 }
paul718e3742002-12-13 20:15:29 +00003930}
3931
paul718e3742002-12-13 20:15:29 +00003932#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3933#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003934
3935#ifdef HAVE_OPAQUE_LSA
3936#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3937#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3938#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3939#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3940#else /* HAVE_OPAQUE_LSA */
3941#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3942#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3943#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3944#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3945#endif /* HAVE_OPAQUE_LSA */
3946
3947#define OSPF_LSA_TYPES_CMD_STR \
3948 "asbr-summary|external|network|router|summary" \
3949 OSPF_LSA_TYPE_NSSA_CMD_STR \
3950 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3951
3952#define OSPF_LSA_TYPES_DESC \
3953 "ASBR summary link states\n" \
3954 "External link states\n" \
3955 "Network link states\n" \
3956 "Router link states\n" \
3957 "Network summary link states\n" \
3958 OSPF_LSA_TYPE_NSSA_DESC \
3959 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3960 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3961 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3962
3963DEFUN (show_ip_ospf_database,
3964 show_ip_ospf_database_cmd,
3965 "show ip ospf database",
3966 SHOW_STR
3967 IP_STR
3968 "OSPF information\n"
3969 "Database summary\n")
3970{
paul020709f2003-04-04 02:44:16 +00003971 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003972 int type, ret;
3973 struct in_addr id, adv_router;
3974
paul020709f2003-04-04 02:44:16 +00003975 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003976 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00003977 {
3978 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3979 return CMD_SUCCESS;
3980 }
paul718e3742002-12-13 20:15:29 +00003981
3982 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003983 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003984
3985 /* Show all LSA. */
3986 if (argc == 0)
3987 {
paul020709f2003-04-04 02:44:16 +00003988 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003989 return CMD_SUCCESS;
3990 }
3991
3992 /* Set database type to show. */
3993 if (strncmp (argv[0], "r", 1) == 0)
3994 type = OSPF_ROUTER_LSA;
3995 else if (strncmp (argv[0], "ne", 2) == 0)
3996 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003997 else if (strncmp (argv[0], "ns", 2) == 0)
3998 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003999 else if (strncmp (argv[0], "su", 2) == 0)
4000 type = OSPF_SUMMARY_LSA;
4001 else if (strncmp (argv[0], "a", 1) == 0)
4002 type = OSPF_ASBR_SUMMARY_LSA;
4003 else if (strncmp (argv[0], "e", 1) == 0)
4004 type = OSPF_AS_EXTERNAL_LSA;
4005 else if (strncmp (argv[0], "se", 2) == 0)
4006 {
paul020709f2003-04-04 02:44:16 +00004007 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004008 return CMD_SUCCESS;
4009 }
4010 else if (strncmp (argv[0], "m", 1) == 0)
4011 {
paul020709f2003-04-04 02:44:16 +00004012 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004013 return CMD_SUCCESS;
4014 }
4015#ifdef HAVE_OPAQUE_LSA
4016 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4017 type = OSPF_OPAQUE_LINK_LSA;
4018 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4019 type = OSPF_OPAQUE_AREA_LSA;
4020 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4021 type = OSPF_OPAQUE_AS_LSA;
4022#endif /* HAVE_OPAQUE_LSA */
4023 else
4024 return CMD_WARNING;
4025
4026 /* `show ip ospf database LSA'. */
4027 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004028 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004029 else if (argc >= 2)
4030 {
4031 ret = inet_aton (argv[1], &id);
4032 if (!ret)
4033 return CMD_WARNING;
4034
4035 /* `show ip ospf database LSA ID'. */
4036 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004037 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004038 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4039 else if (argc == 3)
4040 {
4041 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004042 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004043 else
4044 {
4045 ret = inet_aton (argv[2], &adv_router);
4046 if (!ret)
4047 return CMD_WARNING;
4048 }
paul020709f2003-04-04 02:44:16 +00004049 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004050 }
4051 }
4052
4053 return CMD_SUCCESS;
4054}
4055
4056ALIAS (show_ip_ospf_database,
4057 show_ip_ospf_database_type_cmd,
4058 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4059 SHOW_STR
4060 IP_STR
4061 "OSPF information\n"
4062 "Database summary\n"
4063 OSPF_LSA_TYPES_DESC
4064 "LSAs in MaxAge list\n"
4065 "Self-originated link states\n")
4066
4067ALIAS (show_ip_ospf_database,
4068 show_ip_ospf_database_type_id_cmd,
4069 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4070 SHOW_STR
4071 IP_STR
4072 "OSPF information\n"
4073 "Database summary\n"
4074 OSPF_LSA_TYPES_DESC
4075 "Link State ID (as an IP address)\n")
4076
4077ALIAS (show_ip_ospf_database,
4078 show_ip_ospf_database_type_id_adv_router_cmd,
4079 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4080 SHOW_STR
4081 IP_STR
4082 "OSPF information\n"
4083 "Database summary\n"
4084 OSPF_LSA_TYPES_DESC
4085 "Link State ID (as an IP address)\n"
4086 "Advertising Router link states\n"
4087 "Advertising Router (as an IP address)\n")
4088
4089ALIAS (show_ip_ospf_database,
4090 show_ip_ospf_database_type_id_self_cmd,
4091 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
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 "Self-originated link states\n"
4099 "\n")
4100
4101DEFUN (show_ip_ospf_database_type_adv_router,
4102 show_ip_ospf_database_type_adv_router_cmd,
4103 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4104 SHOW_STR
4105 IP_STR
4106 "OSPF information\n"
4107 "Database summary\n"
4108 OSPF_LSA_TYPES_DESC
4109 "Advertising Router link states\n"
4110 "Advertising Router (as an IP address)\n")
4111{
paul020709f2003-04-04 02:44:16 +00004112 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004113 int type, ret;
4114 struct in_addr adv_router;
4115
paul020709f2003-04-04 02:44:16 +00004116 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004117 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004118 {
4119 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4120 return CMD_SUCCESS;
4121 }
paul718e3742002-12-13 20:15:29 +00004122
4123 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004124 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004125
4126 if (argc != 2)
4127 return CMD_WARNING;
4128
4129 /* Set database type to show. */
4130 if (strncmp (argv[0], "r", 1) == 0)
4131 type = OSPF_ROUTER_LSA;
4132 else if (strncmp (argv[0], "ne", 2) == 0)
4133 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004134 else if (strncmp (argv[0], "ns", 2) == 0)
4135 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004136 else if (strncmp (argv[0], "s", 1) == 0)
4137 type = OSPF_SUMMARY_LSA;
4138 else if (strncmp (argv[0], "a", 1) == 0)
4139 type = OSPF_ASBR_SUMMARY_LSA;
4140 else if (strncmp (argv[0], "e", 1) == 0)
4141 type = OSPF_AS_EXTERNAL_LSA;
4142#ifdef HAVE_OPAQUE_LSA
4143 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4144 type = OSPF_OPAQUE_LINK_LSA;
4145 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4146 type = OSPF_OPAQUE_AREA_LSA;
4147 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4148 type = OSPF_OPAQUE_AS_LSA;
4149#endif /* HAVE_OPAQUE_LSA */
4150 else
4151 return CMD_WARNING;
4152
4153 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4154 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004155 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004156 else
4157 {
4158 ret = inet_aton (argv[1], &adv_router);
4159 if (!ret)
4160 return CMD_WARNING;
4161 }
4162
paul020709f2003-04-04 02:44:16 +00004163 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004164
4165 return CMD_SUCCESS;
4166}
4167
4168ALIAS (show_ip_ospf_database_type_adv_router,
4169 show_ip_ospf_database_type_self_cmd,
4170 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4171 SHOW_STR
4172 IP_STR
4173 "OSPF information\n"
4174 "Database summary\n"
4175 OSPF_LSA_TYPES_DESC
4176 "Self-originated link states\n")
4177
4178
4179DEFUN (ip_ospf_authentication_args,
4180 ip_ospf_authentication_args_addr_cmd,
4181 "ip ospf authentication (null|message-digest) A.B.C.D",
4182 "IP Information\n"
4183 "OSPF interface commands\n"
4184 "Enable authentication on this interface\n"
4185 "Use null authentication\n"
4186 "Use message-digest authentication\n"
4187 "Address of interface")
4188{
4189 struct interface *ifp;
4190 struct in_addr addr;
4191 int ret;
4192 struct ospf_if_params *params;
4193
4194 ifp = vty->index;
4195 params = IF_DEF_PARAMS (ifp);
4196
4197 if (argc == 2)
4198 {
4199 ret = inet_aton(argv[1], &addr);
4200 if (!ret)
4201 {
4202 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4203 VTY_NEWLINE);
4204 return CMD_WARNING;
4205 }
4206
4207 params = ospf_get_if_params (ifp, addr);
4208 ospf_if_update_params (ifp, addr);
4209 }
4210
4211 /* Handle null authentication */
4212 if ( argv[0][0] == 'n' )
4213 {
4214 SET_IF_PARAM (params, auth_type);
4215 params->auth_type = OSPF_AUTH_NULL;
4216 return CMD_SUCCESS;
4217 }
4218
4219 /* Handle message-digest authentication */
4220 if ( argv[0][0] == 'm' )
4221 {
4222 SET_IF_PARAM (params, auth_type);
4223 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4224 return CMD_SUCCESS;
4225 }
4226
4227 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4228 return CMD_WARNING;
4229}
4230
4231ALIAS (ip_ospf_authentication_args,
4232 ip_ospf_authentication_args_cmd,
4233 "ip ospf authentication (null|message-digest)",
4234 "IP Information\n"
4235 "OSPF interface commands\n"
4236 "Enable authentication on this interface\n"
4237 "Use null authentication\n"
4238 "Use message-digest authentication\n")
4239
4240DEFUN (ip_ospf_authentication,
4241 ip_ospf_authentication_addr_cmd,
4242 "ip ospf authentication A.B.C.D",
4243 "IP Information\n"
4244 "OSPF interface commands\n"
4245 "Enable authentication on this interface\n"
4246 "Address of interface")
4247{
4248 struct interface *ifp;
4249 struct in_addr addr;
4250 int ret;
4251 struct ospf_if_params *params;
4252
4253 ifp = vty->index;
4254 params = IF_DEF_PARAMS (ifp);
4255
4256 if (argc == 1)
4257 {
4258 ret = inet_aton(argv[1], &addr);
4259 if (!ret)
4260 {
4261 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4262 VTY_NEWLINE);
4263 return CMD_WARNING;
4264 }
4265
4266 params = ospf_get_if_params (ifp, addr);
4267 ospf_if_update_params (ifp, addr);
4268 }
4269
4270 SET_IF_PARAM (params, auth_type);
4271 params->auth_type = OSPF_AUTH_SIMPLE;
4272
4273 return CMD_SUCCESS;
4274}
4275
4276ALIAS (ip_ospf_authentication,
4277 ip_ospf_authentication_cmd,
4278 "ip ospf authentication",
4279 "IP Information\n"
4280 "OSPF interface commands\n"
4281 "Enable authentication on this interface\n")
4282
4283DEFUN (no_ip_ospf_authentication,
4284 no_ip_ospf_authentication_addr_cmd,
4285 "no ip ospf authentication A.B.C.D",
4286 NO_STR
4287 "IP Information\n"
4288 "OSPF interface commands\n"
4289 "Enable authentication on this interface\n"
4290 "Address of interface")
4291{
4292 struct interface *ifp;
4293 struct in_addr addr;
4294 int ret;
4295 struct ospf_if_params *params;
4296
4297 ifp = vty->index;
4298 params = IF_DEF_PARAMS (ifp);
4299
4300 if (argc == 1)
4301 {
4302 ret = inet_aton(argv[1], &addr);
4303 if (!ret)
4304 {
4305 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4306 VTY_NEWLINE);
4307 return CMD_WARNING;
4308 }
4309
4310 params = ospf_lookup_if_params (ifp, addr);
4311 if (params == NULL)
4312 return CMD_SUCCESS;
4313 }
4314
4315 params->auth_type = OSPF_AUTH_NOTSET;
4316 UNSET_IF_PARAM (params, auth_type);
4317
4318 if (params != IF_DEF_PARAMS (ifp))
4319 {
4320 ospf_free_if_params (ifp, addr);
4321 ospf_if_update_params (ifp, addr);
4322 }
4323
4324 return CMD_SUCCESS;
4325}
4326
4327ALIAS (no_ip_ospf_authentication,
4328 no_ip_ospf_authentication_cmd,
4329 "no ip ospf authentication",
4330 NO_STR
4331 "IP Information\n"
4332 "OSPF interface commands\n"
4333 "Enable authentication on this interface\n")
4334
4335DEFUN (ip_ospf_authentication_key,
4336 ip_ospf_authentication_key_addr_cmd,
4337 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4338 "IP Information\n"
4339 "OSPF interface commands\n"
4340 "Authentication password (key)\n"
4341 "The OSPF password (key)\n"
4342 "Address of interface")
4343{
4344 struct interface *ifp;
4345 struct in_addr addr;
4346 int ret;
4347 struct ospf_if_params *params;
4348
4349 ifp = vty->index;
4350 params = IF_DEF_PARAMS (ifp);
4351
4352 if (argc == 2)
4353 {
4354 ret = inet_aton(argv[1], &addr);
4355 if (!ret)
4356 {
4357 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4358 VTY_NEWLINE);
4359 return CMD_WARNING;
4360 }
4361
4362 params = ospf_get_if_params (ifp, addr);
4363 ospf_if_update_params (ifp, addr);
4364 }
4365
4366
4367 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004368 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004369 SET_IF_PARAM (params, auth_simple);
4370
4371 return CMD_SUCCESS;
4372}
4373
4374ALIAS (ip_ospf_authentication_key,
4375 ip_ospf_authentication_key_cmd,
4376 "ip ospf authentication-key AUTH_KEY",
4377 "IP Information\n"
4378 "OSPF interface commands\n"
4379 "Authentication password (key)\n"
4380 "The OSPF password (key)")
4381
4382ALIAS (ip_ospf_authentication_key,
4383 ospf_authentication_key_cmd,
4384 "ospf authentication-key AUTH_KEY",
4385 "OSPF interface commands\n"
4386 "Authentication password (key)\n"
4387 "The OSPF password (key)")
4388
4389DEFUN (no_ip_ospf_authentication_key,
4390 no_ip_ospf_authentication_key_addr_cmd,
4391 "no ip ospf authentication-key A.B.C.D",
4392 NO_STR
4393 "IP Information\n"
4394 "OSPF interface commands\n"
4395 "Authentication password (key)\n"
4396 "Address of interface")
4397{
4398 struct interface *ifp;
4399 struct in_addr addr;
4400 int ret;
4401 struct ospf_if_params *params;
4402
4403 ifp = vty->index;
4404 params = IF_DEF_PARAMS (ifp);
4405
4406 if (argc == 2)
4407 {
4408 ret = inet_aton(argv[1], &addr);
4409 if (!ret)
4410 {
4411 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4412 VTY_NEWLINE);
4413 return CMD_WARNING;
4414 }
4415
4416 params = ospf_lookup_if_params (ifp, addr);
4417 if (params == NULL)
4418 return CMD_SUCCESS;
4419 }
4420
4421 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4422 UNSET_IF_PARAM (params, auth_simple);
4423
4424 if (params != IF_DEF_PARAMS (ifp))
4425 {
4426 ospf_free_if_params (ifp, addr);
4427 ospf_if_update_params (ifp, addr);
4428 }
4429
4430 return CMD_SUCCESS;
4431}
4432
4433ALIAS (no_ip_ospf_authentication_key,
4434 no_ip_ospf_authentication_key_cmd,
4435 "no ip ospf authentication-key",
4436 NO_STR
4437 "IP Information\n"
4438 "OSPF interface commands\n"
4439 "Authentication password (key)\n")
4440
4441ALIAS (no_ip_ospf_authentication_key,
4442 no_ospf_authentication_key_cmd,
4443 "no ospf authentication-key",
4444 NO_STR
4445 "OSPF interface commands\n"
4446 "Authentication password (key)\n")
4447
4448DEFUN (ip_ospf_message_digest_key,
4449 ip_ospf_message_digest_key_addr_cmd,
4450 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4451 "IP Information\n"
4452 "OSPF interface commands\n"
4453 "Message digest authentication password (key)\n"
4454 "Key ID\n"
4455 "Use MD5 algorithm\n"
4456 "The OSPF password (key)"
4457 "Address of interface")
4458{
4459 struct interface *ifp;
4460 struct crypt_key *ck;
4461 u_char key_id;
4462 struct in_addr addr;
4463 int ret;
4464 struct ospf_if_params *params;
4465
4466 ifp = vty->index;
4467 params = IF_DEF_PARAMS (ifp);
4468
4469 if (argc == 3)
4470 {
4471 ret = inet_aton(argv[2], &addr);
4472 if (!ret)
4473 {
4474 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4475 VTY_NEWLINE);
4476 return CMD_WARNING;
4477 }
4478
4479 params = ospf_get_if_params (ifp, addr);
4480 ospf_if_update_params (ifp, addr);
4481 }
4482
4483 key_id = strtol (argv[0], NULL, 10);
4484 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4485 {
4486 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4487 return CMD_WARNING;
4488 }
4489
4490 ck = ospf_crypt_key_new ();
4491 ck->key_id = (u_char) key_id;
4492 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004493 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004494
4495 ospf_crypt_key_add (params->auth_crypt, ck);
4496 SET_IF_PARAM (params, auth_crypt);
4497
4498 return CMD_SUCCESS;
4499}
4500
4501ALIAS (ip_ospf_message_digest_key,
4502 ip_ospf_message_digest_key_cmd,
4503 "ip ospf message-digest-key <1-255> md5 KEY",
4504 "IP Information\n"
4505 "OSPF interface commands\n"
4506 "Message digest authentication password (key)\n"
4507 "Key ID\n"
4508 "Use MD5 algorithm\n"
4509 "The OSPF password (key)")
4510
4511ALIAS (ip_ospf_message_digest_key,
4512 ospf_message_digest_key_cmd,
4513 "ospf message-digest-key <1-255> md5 KEY",
4514 "OSPF interface commands\n"
4515 "Message digest authentication password (key)\n"
4516 "Key ID\n"
4517 "Use MD5 algorithm\n"
4518 "The OSPF password (key)")
4519
4520DEFUN (no_ip_ospf_message_digest_key,
4521 no_ip_ospf_message_digest_key_addr_cmd,
4522 "no ip ospf message-digest-key <1-255> A.B.C.D",
4523 NO_STR
4524 "IP Information\n"
4525 "OSPF interface commands\n"
4526 "Message digest authentication password (key)\n"
4527 "Key ID\n"
4528 "Address of interface")
4529{
4530 struct interface *ifp;
4531 struct crypt_key *ck;
4532 int key_id;
4533 struct in_addr addr;
4534 int ret;
4535 struct ospf_if_params *params;
4536
4537 ifp = vty->index;
4538 params = IF_DEF_PARAMS (ifp);
4539
4540 if (argc == 2)
4541 {
4542 ret = inet_aton(argv[1], &addr);
4543 if (!ret)
4544 {
4545 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4546 VTY_NEWLINE);
4547 return CMD_WARNING;
4548 }
4549
4550 params = ospf_lookup_if_params (ifp, addr);
4551 if (params == NULL)
4552 return CMD_SUCCESS;
4553 }
4554
4555 key_id = strtol (argv[0], NULL, 10);
4556 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4557 if (ck == NULL)
4558 {
4559 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4560 return CMD_WARNING;
4561 }
4562
4563 ospf_crypt_key_delete (params->auth_crypt, key_id);
4564
4565 if (params != IF_DEF_PARAMS (ifp))
4566 {
4567 ospf_free_if_params (ifp, addr);
4568 ospf_if_update_params (ifp, addr);
4569 }
4570
4571 return CMD_SUCCESS;
4572}
4573
4574ALIAS (no_ip_ospf_message_digest_key,
4575 no_ip_ospf_message_digest_key_cmd,
4576 "no ip ospf message-digest-key <1-255>",
4577 NO_STR
4578 "IP Information\n"
4579 "OSPF interface commands\n"
4580 "Message digest authentication password (key)\n"
4581 "Key ID\n")
4582
4583ALIAS (no_ip_ospf_message_digest_key,
4584 no_ospf_message_digest_key_cmd,
4585 "no ospf message-digest-key <1-255>",
4586 NO_STR
4587 "OSPF interface commands\n"
4588 "Message digest authentication password (key)\n"
4589 "Key ID\n")
4590
4591DEFUN (ip_ospf_cost,
4592 ip_ospf_cost_addr_cmd,
4593 "ip ospf cost <1-65535> A.B.C.D",
4594 "IP Information\n"
4595 "OSPF interface commands\n"
4596 "Interface cost\n"
4597 "Cost\n"
4598 "Address of interface")
4599{
4600 struct interface *ifp = vty->index;
4601 u_int32_t cost;
4602 struct in_addr addr;
4603 int ret;
4604 struct ospf_if_params *params;
4605
4606 params = IF_DEF_PARAMS (ifp);
4607
4608 cost = strtol (argv[0], NULL, 10);
4609
4610 /* cost range is <1-65535>. */
4611 if (cost < 1 || cost > 65535)
4612 {
4613 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4614 return CMD_WARNING;
4615 }
4616
4617 if (argc == 2)
4618 {
4619 ret = inet_aton(argv[1], &addr);
4620 if (!ret)
4621 {
4622 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4623 VTY_NEWLINE);
4624 return CMD_WARNING;
4625 }
4626
4627 params = ospf_get_if_params (ifp, addr);
4628 ospf_if_update_params (ifp, addr);
4629 }
4630
4631 SET_IF_PARAM (params, output_cost_cmd);
4632 params->output_cost_cmd = cost;
4633
4634 ospf_if_recalculate_output_cost (ifp);
4635
4636 return CMD_SUCCESS;
4637}
4638
4639ALIAS (ip_ospf_cost,
4640 ip_ospf_cost_cmd,
4641 "ip ospf cost <1-65535>",
4642 "IP Information\n"
4643 "OSPF interface commands\n"
4644 "Interface cost\n"
4645 "Cost")
4646
4647ALIAS (ip_ospf_cost,
4648 ospf_cost_cmd,
4649 "ospf cost <1-65535>",
4650 "OSPF interface commands\n"
4651 "Interface cost\n"
4652 "Cost")
4653
4654DEFUN (no_ip_ospf_cost,
4655 no_ip_ospf_cost_addr_cmd,
4656 "no ip ospf cost A.B.C.D",
4657 NO_STR
4658 "IP Information\n"
4659 "OSPF interface commands\n"
4660 "Interface cost\n"
4661 "Address of interface")
4662{
4663 struct interface *ifp = vty->index;
4664 struct in_addr addr;
4665 int ret;
4666 struct ospf_if_params *params;
4667
4668 ifp = vty->index;
4669 params = IF_DEF_PARAMS (ifp);
4670
4671 if (argc == 1)
4672 {
4673 ret = inet_aton(argv[0], &addr);
4674 if (!ret)
4675 {
4676 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4677 VTY_NEWLINE);
4678 return CMD_WARNING;
4679 }
4680
4681 params = ospf_lookup_if_params (ifp, addr);
4682 if (params == NULL)
4683 return CMD_SUCCESS;
4684 }
4685
4686 UNSET_IF_PARAM (params, output_cost_cmd);
4687
4688 if (params != IF_DEF_PARAMS (ifp))
4689 {
4690 ospf_free_if_params (ifp, addr);
4691 ospf_if_update_params (ifp, addr);
4692 }
4693
4694 ospf_if_recalculate_output_cost (ifp);
4695
4696 return CMD_SUCCESS;
4697}
4698
4699ALIAS (no_ip_ospf_cost,
4700 no_ip_ospf_cost_cmd,
4701 "no ip ospf cost",
4702 NO_STR
4703 "IP Information\n"
4704 "OSPF interface commands\n"
4705 "Interface cost\n")
4706
4707ALIAS (no_ip_ospf_cost,
4708 no_ospf_cost_cmd,
4709 "no ospf cost",
4710 NO_STR
4711 "OSPF interface commands\n"
4712 "Interface cost\n")
4713
paul4dadc292005-05-06 21:37:42 +00004714static void
paul718e3742002-12-13 20:15:29 +00004715ospf_nbr_timer_update (struct ospf_interface *oi)
4716{
4717 struct route_node *rn;
4718 struct ospf_neighbor *nbr;
4719
4720 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4721 if ((nbr = rn->info))
4722 {
4723 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4724 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4725 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4726 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4727 }
4728}
4729
paulf9ad9372005-10-21 00:45:17 +00004730static int
4731ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4732 const char *nbr_str,
4733 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004734{
4735 struct interface *ifp = vty->index;
4736 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004737 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004738 struct in_addr addr;
4739 int ret;
4740 struct ospf_if_params *params;
4741 struct ospf_interface *oi;
4742 struct route_node *rn;
4743
4744 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004745
4746 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004747 {
paulf9ad9372005-10-21 00:45:17 +00004748 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004749 if (!ret)
4750 {
4751 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4752 VTY_NEWLINE);
4753 return CMD_WARNING;
4754 }
4755
4756 params = ospf_get_if_params (ifp, addr);
4757 ospf_if_update_params (ifp, addr);
4758 }
4759
paulf9ad9372005-10-21 00:45:17 +00004760 if (interval_str)
4761 {
4762 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4763 1, 65535);
4764
4765 /* reset fast_hello too, just to be sure */
4766 UNSET_IF_PARAM (params, fast_hello);
4767 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4768 }
4769 else if (fast_hello_str)
4770 {
4771 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4772 1, 10);
4773 /* 1s dead-interval with sub-second hellos desired */
4774 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4775 SET_IF_PARAM (params, fast_hello);
4776 params->fast_hello = hellomult;
4777 }
4778 else
4779 {
4780 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4781 VTY_NEWLINE);
4782 return CMD_WARNING;
4783 }
4784
paul718e3742002-12-13 20:15:29 +00004785 SET_IF_PARAM (params, v_wait);
4786 params->v_wait = seconds;
4787
4788 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00004789 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004790 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004791 struct ospf *ospf;
4792 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00004793 {
4794 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4795 if (oi)
4796 ospf_nbr_timer_update (oi);
4797 }
paul718e3742002-12-13 20:15:29 +00004798 }
4799 else
4800 {
4801 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4802 if ((oi = rn->info))
4803 ospf_nbr_timer_update (oi);
4804 }
4805
4806 return CMD_SUCCESS;
4807}
4808
paulf9ad9372005-10-21 00:45:17 +00004809
4810DEFUN (ip_ospf_dead_interval,
4811 ip_ospf_dead_interval_addr_cmd,
4812 "ip ospf dead-interval <1-65535> A.B.C.D",
4813 "IP Information\n"
4814 "OSPF interface commands\n"
4815 "Interval after which a neighbor is declared dead\n"
4816 "Seconds\n"
4817 "Address of interface\n")
4818{
4819 if (argc == 2)
4820 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4821 else
4822 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4823}
4824
paul718e3742002-12-13 20:15:29 +00004825ALIAS (ip_ospf_dead_interval,
4826 ip_ospf_dead_interval_cmd,
4827 "ip ospf dead-interval <1-65535>",
4828 "IP Information\n"
4829 "OSPF interface commands\n"
4830 "Interval after which a neighbor is declared dead\n"
4831 "Seconds\n")
4832
4833ALIAS (ip_ospf_dead_interval,
4834 ospf_dead_interval_cmd,
4835 "ospf dead-interval <1-65535>",
4836 "OSPF interface commands\n"
4837 "Interval after which a neighbor is declared dead\n"
4838 "Seconds\n")
4839
paulf9ad9372005-10-21 00:45:17 +00004840DEFUN (ip_ospf_dead_interval_minimal,
4841 ip_ospf_dead_interval_minimal_addr_cmd,
4842 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4843 "IP Information\n"
4844 "OSPF interface commands\n"
4845 "Interval after which a neighbor is declared dead\n"
4846 "Minimal 1s dead-interval with fast sub-second hellos\n"
4847 "Hello multiplier factor\n"
4848 "Number of Hellos to send each second\n"
4849 "Address of interface\n")
4850{
4851 if (argc == 2)
4852 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4853 else
4854 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4855}
4856
4857ALIAS (ip_ospf_dead_interval_minimal,
4858 ip_ospf_dead_interval_minimal_cmd,
4859 "ip ospf dead-interval minimal hello-multiplier <1-10>",
4860 "IP Information\n"
4861 "OSPF interface commands\n"
4862 "Interval after which a neighbor is declared dead\n"
4863 "Minimal 1s dead-interval with fast sub-second hellos\n"
4864 "Hello multiplier factor\n"
4865 "Number of Hellos to send each second\n")
4866
paul718e3742002-12-13 20:15:29 +00004867DEFUN (no_ip_ospf_dead_interval,
4868 no_ip_ospf_dead_interval_addr_cmd,
4869 "no ip ospf dead-interval A.B.C.D",
4870 NO_STR
4871 "IP Information\n"
4872 "OSPF interface commands\n"
4873 "Interval after which a neighbor is declared dead\n"
4874 "Address of interface")
4875{
4876 struct interface *ifp = vty->index;
4877 struct in_addr addr;
4878 int ret;
4879 struct ospf_if_params *params;
4880 struct ospf_interface *oi;
4881 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004882
paul718e3742002-12-13 20:15:29 +00004883 ifp = vty->index;
4884 params = IF_DEF_PARAMS (ifp);
4885
4886 if (argc == 1)
4887 {
4888 ret = inet_aton(argv[0], &addr);
4889 if (!ret)
4890 {
4891 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4892 VTY_NEWLINE);
4893 return CMD_WARNING;
4894 }
4895
4896 params = ospf_lookup_if_params (ifp, addr);
4897 if (params == NULL)
4898 return CMD_SUCCESS;
4899 }
4900
4901 UNSET_IF_PARAM (params, v_wait);
4902 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00004903
4904 UNSET_IF_PARAM (params, fast_hello);
4905 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4906
paul718e3742002-12-13 20:15:29 +00004907 if (params != IF_DEF_PARAMS (ifp))
4908 {
4909 ospf_free_if_params (ifp, addr);
4910 ospf_if_update_params (ifp, addr);
4911 }
4912
4913 /* Update timer values in neighbor structure. */
4914 if (argc == 1)
4915 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004916 struct ospf *ospf;
4917
4918 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00004919 {
4920 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4921 if (oi)
4922 ospf_nbr_timer_update (oi);
4923 }
paul718e3742002-12-13 20:15:29 +00004924 }
4925 else
4926 {
4927 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4928 if ((oi = rn->info))
4929 ospf_nbr_timer_update (oi);
4930 }
4931
4932 return CMD_SUCCESS;
4933}
4934
4935ALIAS (no_ip_ospf_dead_interval,
4936 no_ip_ospf_dead_interval_cmd,
4937 "no ip ospf dead-interval",
4938 NO_STR
4939 "IP Information\n"
4940 "OSPF interface commands\n"
4941 "Interval after which a neighbor is declared dead\n")
4942
4943ALIAS (no_ip_ospf_dead_interval,
4944 no_ospf_dead_interval_cmd,
4945 "no ospf dead-interval",
4946 NO_STR
4947 "OSPF interface commands\n"
4948 "Interval after which a neighbor is declared dead\n")
4949
4950DEFUN (ip_ospf_hello_interval,
4951 ip_ospf_hello_interval_addr_cmd,
4952 "ip ospf hello-interval <1-65535> A.B.C.D",
4953 "IP Information\n"
4954 "OSPF interface commands\n"
4955 "Time between HELLO packets\n"
4956 "Seconds\n"
4957 "Address of interface")
4958{
4959 struct interface *ifp = vty->index;
4960 u_int32_t seconds;
4961 struct in_addr addr;
4962 int ret;
4963 struct ospf_if_params *params;
4964
4965 params = IF_DEF_PARAMS (ifp);
4966
4967 seconds = strtol (argv[0], NULL, 10);
4968
4969 /* HelloInterval range is <1-65535>. */
4970 if (seconds < 1 || seconds > 65535)
4971 {
4972 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4973 return CMD_WARNING;
4974 }
4975
4976 if (argc == 2)
4977 {
4978 ret = inet_aton(argv[1], &addr);
4979 if (!ret)
4980 {
4981 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4982 VTY_NEWLINE);
4983 return CMD_WARNING;
4984 }
4985
4986 params = ospf_get_if_params (ifp, addr);
4987 ospf_if_update_params (ifp, addr);
4988 }
4989
paulf9ad9372005-10-21 00:45:17 +00004990 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00004991 params->v_hello = seconds;
4992
4993 return CMD_SUCCESS;
4994}
4995
4996ALIAS (ip_ospf_hello_interval,
4997 ip_ospf_hello_interval_cmd,
4998 "ip ospf hello-interval <1-65535>",
4999 "IP Information\n"
5000 "OSPF interface commands\n"
5001 "Time between HELLO packets\n"
5002 "Seconds\n")
5003
5004ALIAS (ip_ospf_hello_interval,
5005 ospf_hello_interval_cmd,
5006 "ospf hello-interval <1-65535>",
5007 "OSPF interface commands\n"
5008 "Time between HELLO packets\n"
5009 "Seconds\n")
5010
5011DEFUN (no_ip_ospf_hello_interval,
5012 no_ip_ospf_hello_interval_addr_cmd,
5013 "no ip ospf hello-interval A.B.C.D",
5014 NO_STR
5015 "IP Information\n"
5016 "OSPF interface commands\n"
5017 "Time between HELLO packets\n"
5018 "Address of interface")
5019{
5020 struct interface *ifp = vty->index;
5021 struct in_addr addr;
5022 int ret;
5023 struct ospf_if_params *params;
5024
5025 ifp = vty->index;
5026 params = IF_DEF_PARAMS (ifp);
5027
5028 if (argc == 1)
5029 {
5030 ret = inet_aton(argv[0], &addr);
5031 if (!ret)
5032 {
5033 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5034 VTY_NEWLINE);
5035 return CMD_WARNING;
5036 }
5037
5038 params = ospf_lookup_if_params (ifp, addr);
5039 if (params == NULL)
5040 return CMD_SUCCESS;
5041 }
5042
5043 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005044 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005045
5046 if (params != IF_DEF_PARAMS (ifp))
5047 {
5048 ospf_free_if_params (ifp, addr);
5049 ospf_if_update_params (ifp, addr);
5050 }
5051
5052 return CMD_SUCCESS;
5053}
5054
5055ALIAS (no_ip_ospf_hello_interval,
5056 no_ip_ospf_hello_interval_cmd,
5057 "no ip ospf hello-interval",
5058 NO_STR
5059 "IP Information\n"
5060 "OSPF interface commands\n"
5061 "Time between HELLO packets\n")
5062
5063ALIAS (no_ip_ospf_hello_interval,
5064 no_ospf_hello_interval_cmd,
5065 "no ospf hello-interval",
5066 NO_STR
5067 "OSPF interface commands\n"
5068 "Time between HELLO packets\n")
5069
5070DEFUN (ip_ospf_network,
5071 ip_ospf_network_cmd,
5072 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5073 "IP Information\n"
5074 "OSPF interface commands\n"
5075 "Network type\n"
5076 "Specify OSPF broadcast multi-access network\n"
5077 "Specify OSPF NBMA network\n"
5078 "Specify OSPF point-to-multipoint network\n"
5079 "Specify OSPF point-to-point network\n")
5080{
5081 struct interface *ifp = vty->index;
5082 int old_type = IF_DEF_PARAMS (ifp)->type;
5083 struct route_node *rn;
5084
5085 if (strncmp (argv[0], "b", 1) == 0)
5086 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5087 else if (strncmp (argv[0], "n", 1) == 0)
5088 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5089 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5090 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5091 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5092 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5093
5094 if (IF_DEF_PARAMS (ifp)->type == old_type)
5095 return CMD_SUCCESS;
5096
5097 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5098
5099 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5100 {
5101 struct ospf_interface *oi = rn->info;
5102
5103 if (!oi)
5104 continue;
5105
5106 oi->type = IF_DEF_PARAMS (ifp)->type;
5107
5108 if (oi->state > ISM_Down)
5109 {
5110 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5111 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5112 }
5113 }
5114
5115 return CMD_SUCCESS;
5116}
5117
5118ALIAS (ip_ospf_network,
5119 ospf_network_cmd,
5120 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5121 "OSPF interface commands\n"
5122 "Network type\n"
5123 "Specify OSPF broadcast multi-access network\n"
5124 "Specify OSPF NBMA network\n"
5125 "Specify OSPF point-to-multipoint network\n"
5126 "Specify OSPF point-to-point network\n")
5127
5128DEFUN (no_ip_ospf_network,
5129 no_ip_ospf_network_cmd,
5130 "no ip ospf network",
5131 NO_STR
5132 "IP Information\n"
5133 "OSPF interface commands\n"
5134 "Network type\n")
5135{
5136 struct interface *ifp = vty->index;
5137 int old_type = IF_DEF_PARAMS (ifp)->type;
5138 struct route_node *rn;
5139
ajsbc18d612004-12-15 15:07:19 +00005140 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005141
5142 if (IF_DEF_PARAMS (ifp)->type == old_type)
5143 return CMD_SUCCESS;
5144
5145 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5146 {
5147 struct ospf_interface *oi = rn->info;
5148
5149 if (!oi)
5150 continue;
5151
5152 oi->type = IF_DEF_PARAMS (ifp)->type;
5153
5154 if (oi->state > ISM_Down)
5155 {
5156 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5157 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5158 }
5159 }
5160
5161 return CMD_SUCCESS;
5162}
5163
5164ALIAS (no_ip_ospf_network,
5165 no_ospf_network_cmd,
5166 "no ospf network",
5167 NO_STR
5168 "OSPF interface commands\n"
5169 "Network type\n")
5170
5171DEFUN (ip_ospf_priority,
5172 ip_ospf_priority_addr_cmd,
5173 "ip ospf priority <0-255> A.B.C.D",
5174 "IP Information\n"
5175 "OSPF interface commands\n"
5176 "Router priority\n"
5177 "Priority\n"
5178 "Address of interface")
5179{
5180 struct interface *ifp = vty->index;
5181 u_int32_t priority;
5182 struct route_node *rn;
5183 struct in_addr addr;
5184 int ret;
5185 struct ospf_if_params *params;
5186
5187 params = IF_DEF_PARAMS (ifp);
5188
5189 priority = strtol (argv[0], NULL, 10);
5190
5191 /* Router Priority range is <0-255>. */
5192 if (priority < 0 || priority > 255)
5193 {
5194 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5195 return CMD_WARNING;
5196 }
5197
5198 if (argc == 2)
5199 {
5200 ret = inet_aton(argv[1], &addr);
5201 if (!ret)
5202 {
5203 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5204 VTY_NEWLINE);
5205 return CMD_WARNING;
5206 }
5207
5208 params = ospf_get_if_params (ifp, addr);
5209 ospf_if_update_params (ifp, addr);
5210 }
5211
5212 SET_IF_PARAM (params, priority);
5213 params->priority = priority;
5214
5215 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5216 {
5217 struct ospf_interface *oi = rn->info;
5218
5219 if (!oi)
5220 continue;
5221
5222
5223 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5224 {
5225 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5226 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5227 }
5228 }
5229
5230 return CMD_SUCCESS;
5231}
5232
5233ALIAS (ip_ospf_priority,
5234 ip_ospf_priority_cmd,
5235 "ip ospf priority <0-255>",
5236 "IP Information\n"
5237 "OSPF interface commands\n"
5238 "Router priority\n"
5239 "Priority\n")
5240
5241ALIAS (ip_ospf_priority,
5242 ospf_priority_cmd,
5243 "ospf priority <0-255>",
5244 "OSPF interface commands\n"
5245 "Router priority\n"
5246 "Priority\n")
5247
5248DEFUN (no_ip_ospf_priority,
5249 no_ip_ospf_priority_addr_cmd,
5250 "no ip ospf priority A.B.C.D",
5251 NO_STR
5252 "IP Information\n"
5253 "OSPF interface commands\n"
5254 "Router priority\n"
5255 "Address of interface")
5256{
5257 struct interface *ifp = vty->index;
5258 struct route_node *rn;
5259 struct in_addr addr;
5260 int ret;
5261 struct ospf_if_params *params;
5262
5263 ifp = vty->index;
5264 params = IF_DEF_PARAMS (ifp);
5265
5266 if (argc == 1)
5267 {
5268 ret = inet_aton(argv[0], &addr);
5269 if (!ret)
5270 {
5271 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5272 VTY_NEWLINE);
5273 return CMD_WARNING;
5274 }
5275
5276 params = ospf_lookup_if_params (ifp, addr);
5277 if (params == NULL)
5278 return CMD_SUCCESS;
5279 }
5280
5281 UNSET_IF_PARAM (params, priority);
5282 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5283
5284 if (params != IF_DEF_PARAMS (ifp))
5285 {
5286 ospf_free_if_params (ifp, addr);
5287 ospf_if_update_params (ifp, addr);
5288 }
5289
5290 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5291 {
5292 struct ospf_interface *oi = rn->info;
5293
5294 if (!oi)
5295 continue;
5296
5297
5298 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5299 {
5300 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5301 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5302 }
5303 }
5304
5305 return CMD_SUCCESS;
5306}
5307
5308ALIAS (no_ip_ospf_priority,
5309 no_ip_ospf_priority_cmd,
5310 "no ip ospf priority",
5311 NO_STR
5312 "IP Information\n"
5313 "OSPF interface commands\n"
5314 "Router priority\n")
5315
5316ALIAS (no_ip_ospf_priority,
5317 no_ospf_priority_cmd,
5318 "no ospf priority",
5319 NO_STR
5320 "OSPF interface commands\n"
5321 "Router priority\n")
5322
5323DEFUN (ip_ospf_retransmit_interval,
5324 ip_ospf_retransmit_interval_addr_cmd,
5325 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5326 "IP Information\n"
5327 "OSPF interface commands\n"
5328 "Time between retransmitting lost link state advertisements\n"
5329 "Seconds\n"
5330 "Address of interface")
5331{
5332 struct interface *ifp = vty->index;
5333 u_int32_t seconds;
5334 struct in_addr addr;
5335 int ret;
5336 struct ospf_if_params *params;
5337
5338 params = IF_DEF_PARAMS (ifp);
5339 seconds = strtol (argv[0], NULL, 10);
5340
5341 /* Retransmit Interval range is <3-65535>. */
5342 if (seconds < 3 || seconds > 65535)
5343 {
5344 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5345 return CMD_WARNING;
5346 }
5347
5348
5349 if (argc == 2)
5350 {
5351 ret = inet_aton(argv[1], &addr);
5352 if (!ret)
5353 {
5354 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5355 VTY_NEWLINE);
5356 return CMD_WARNING;
5357 }
5358
5359 params = ospf_get_if_params (ifp, addr);
5360 ospf_if_update_params (ifp, addr);
5361 }
5362
5363 SET_IF_PARAM (params, retransmit_interval);
5364 params->retransmit_interval = seconds;
5365
5366 return CMD_SUCCESS;
5367}
5368
5369ALIAS (ip_ospf_retransmit_interval,
5370 ip_ospf_retransmit_interval_cmd,
5371 "ip ospf retransmit-interval <3-65535>",
5372 "IP Information\n"
5373 "OSPF interface commands\n"
5374 "Time between retransmitting lost link state advertisements\n"
5375 "Seconds\n")
5376
5377ALIAS (ip_ospf_retransmit_interval,
5378 ospf_retransmit_interval_cmd,
5379 "ospf retransmit-interval <3-65535>",
5380 "OSPF interface commands\n"
5381 "Time between retransmitting lost link state advertisements\n"
5382 "Seconds\n")
5383
5384DEFUN (no_ip_ospf_retransmit_interval,
5385 no_ip_ospf_retransmit_interval_addr_cmd,
5386 "no ip ospf retransmit-interval A.B.C.D",
5387 NO_STR
5388 "IP Information\n"
5389 "OSPF interface commands\n"
5390 "Time between retransmitting lost link state advertisements\n"
5391 "Address of interface")
5392{
5393 struct interface *ifp = vty->index;
5394 struct in_addr addr;
5395 int ret;
5396 struct ospf_if_params *params;
5397
5398 ifp = vty->index;
5399 params = IF_DEF_PARAMS (ifp);
5400
5401 if (argc == 1)
5402 {
5403 ret = inet_aton(argv[0], &addr);
5404 if (!ret)
5405 {
5406 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5407 VTY_NEWLINE);
5408 return CMD_WARNING;
5409 }
5410
5411 params = ospf_lookup_if_params (ifp, addr);
5412 if (params == NULL)
5413 return CMD_SUCCESS;
5414 }
5415
5416 UNSET_IF_PARAM (params, retransmit_interval);
5417 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5418
5419 if (params != IF_DEF_PARAMS (ifp))
5420 {
5421 ospf_free_if_params (ifp, addr);
5422 ospf_if_update_params (ifp, addr);
5423 }
5424
5425 return CMD_SUCCESS;
5426}
5427
5428ALIAS (no_ip_ospf_retransmit_interval,
5429 no_ip_ospf_retransmit_interval_cmd,
5430 "no ip ospf retransmit-interval",
5431 NO_STR
5432 "IP Information\n"
5433 "OSPF interface commands\n"
5434 "Time between retransmitting lost link state advertisements\n")
5435
5436ALIAS (no_ip_ospf_retransmit_interval,
5437 no_ospf_retransmit_interval_cmd,
5438 "no ospf retransmit-interval",
5439 NO_STR
5440 "OSPF interface commands\n"
5441 "Time between retransmitting lost link state advertisements\n")
5442
5443DEFUN (ip_ospf_transmit_delay,
5444 ip_ospf_transmit_delay_addr_cmd,
5445 "ip ospf transmit-delay <1-65535> A.B.C.D",
5446 "IP Information\n"
5447 "OSPF interface commands\n"
5448 "Link state transmit delay\n"
5449 "Seconds\n"
5450 "Address of interface")
5451{
5452 struct interface *ifp = vty->index;
5453 u_int32_t seconds;
5454 struct in_addr addr;
5455 int ret;
5456 struct ospf_if_params *params;
5457
5458 params = IF_DEF_PARAMS (ifp);
5459 seconds = strtol (argv[0], NULL, 10);
5460
5461 /* Transmit Delay range is <1-65535>. */
5462 if (seconds < 1 || seconds > 65535)
5463 {
5464 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5465 return CMD_WARNING;
5466 }
5467
5468 if (argc == 2)
5469 {
5470 ret = inet_aton(argv[1], &addr);
5471 if (!ret)
5472 {
5473 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5474 VTY_NEWLINE);
5475 return CMD_WARNING;
5476 }
5477
5478 params = ospf_get_if_params (ifp, addr);
5479 ospf_if_update_params (ifp, addr);
5480 }
5481
5482 SET_IF_PARAM (params, transmit_delay);
5483 params->transmit_delay = seconds;
5484
5485 return CMD_SUCCESS;
5486}
5487
5488ALIAS (ip_ospf_transmit_delay,
5489 ip_ospf_transmit_delay_cmd,
5490 "ip ospf transmit-delay <1-65535>",
5491 "IP Information\n"
5492 "OSPF interface commands\n"
5493 "Link state transmit delay\n"
5494 "Seconds\n")
5495
5496ALIAS (ip_ospf_transmit_delay,
5497 ospf_transmit_delay_cmd,
5498 "ospf transmit-delay <1-65535>",
5499 "OSPF interface commands\n"
5500 "Link state transmit delay\n"
5501 "Seconds\n")
5502
5503DEFUN (no_ip_ospf_transmit_delay,
5504 no_ip_ospf_transmit_delay_addr_cmd,
5505 "no ip ospf transmit-delay A.B.C.D",
5506 NO_STR
5507 "IP Information\n"
5508 "OSPF interface commands\n"
5509 "Link state transmit delay\n"
5510 "Address of interface")
5511{
5512 struct interface *ifp = vty->index;
5513 struct in_addr addr;
5514 int ret;
5515 struct ospf_if_params *params;
5516
5517 ifp = vty->index;
5518 params = IF_DEF_PARAMS (ifp);
5519
5520 if (argc == 1)
5521 {
5522 ret = inet_aton(argv[0], &addr);
5523 if (!ret)
5524 {
5525 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5526 VTY_NEWLINE);
5527 return CMD_WARNING;
5528 }
5529
5530 params = ospf_lookup_if_params (ifp, addr);
5531 if (params == NULL)
5532 return CMD_SUCCESS;
5533 }
5534
5535 UNSET_IF_PARAM (params, transmit_delay);
5536 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5537
5538 if (params != IF_DEF_PARAMS (ifp))
5539 {
5540 ospf_free_if_params (ifp, addr);
5541 ospf_if_update_params (ifp, addr);
5542 }
5543
5544 return CMD_SUCCESS;
5545}
5546
5547ALIAS (no_ip_ospf_transmit_delay,
5548 no_ip_ospf_transmit_delay_cmd,
5549 "no ip ospf transmit-delay",
5550 NO_STR
5551 "IP Information\n"
5552 "OSPF interface commands\n"
5553 "Link state transmit delay\n")
5554
5555ALIAS (no_ip_ospf_transmit_delay,
5556 no_ospf_transmit_delay_cmd,
5557 "no ospf transmit-delay",
5558 NO_STR
5559 "OSPF interface commands\n"
5560 "Link state transmit delay\n")
5561
5562
5563DEFUN (ospf_redistribute_source_metric_type,
5564 ospf_redistribute_source_metric_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005565 "redistribute " QUAGGA_REDIST_STR_OSPFD
5566 " metric <0-16777214> metric-type (1|2) route-map WORD",
5567 REDIST_STR
5568 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005569 "Metric for redistributed routes\n"
5570 "OSPF default metric\n"
5571 "OSPF exterior metric type for redistributed routes\n"
5572 "Set OSPF External Type 1 metrics\n"
5573 "Set OSPF External Type 2 metrics\n"
5574 "Route map reference\n"
5575 "Pointer to route-map entries\n")
5576{
paul020709f2003-04-04 02:44:16 +00005577 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005578 int source;
5579 int type = -1;
5580 int metric = -1;
5581
5582 /* Get distribute source. */
5583 if (!str2distribute_source (argv[0], &source))
5584 return CMD_WARNING;
5585
5586 /* Get metric value. */
5587 if (argc >= 2)
5588 if (!str2metric (argv[1], &metric))
5589 return CMD_WARNING;
5590
5591 /* Get metric type. */
5592 if (argc >= 3)
5593 if (!str2metric_type (argv[2], &type))
5594 return CMD_WARNING;
5595
5596 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005597 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005598 else
paul020709f2003-04-04 02:44:16 +00005599 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005600
paul020709f2003-04-04 02:44:16 +00005601 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005602}
5603
5604ALIAS (ospf_redistribute_source_metric_type,
5605 ospf_redistribute_source_metric_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005606 "redistribute " QUAGGA_REDIST_STR_OSPFD
5607 " metric <0-16777214> metric-type (1|2)",
5608 REDIST_STR
5609 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005610 "Metric for redistributed routes\n"
5611 "OSPF default metric\n"
5612 "OSPF exterior metric type for redistributed routes\n"
5613 "Set OSPF External Type 1 metrics\n"
5614 "Set OSPF External Type 2 metrics\n")
5615
5616ALIAS (ospf_redistribute_source_metric_type,
5617 ospf_redistribute_source_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005618 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5619 REDIST_STR
5620 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005621 "Metric for redistributed routes\n"
5622 "OSPF default metric\n")
5623
5624DEFUN (ospf_redistribute_source_type_metric,
5625 ospf_redistribute_source_type_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005626 "redistribute " QUAGGA_REDIST_STR_OSPFD
5627 " metric-type (1|2) metric <0-16777214> route-map WORD",
5628 REDIST_STR
5629 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005630 "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 "Metric for redistributed routes\n"
5634 "OSPF default metric\n"
5635 "Route map reference\n"
5636 "Pointer to route-map entries\n")
5637{
paul020709f2003-04-04 02:44:16 +00005638 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005639 int source;
5640 int type = -1;
5641 int metric = -1;
5642
5643 /* Get distribute source. */
5644 if (!str2distribute_source (argv[0], &source))
5645 return CMD_WARNING;
5646
5647 /* Get metric value. */
5648 if (argc >= 2)
5649 if (!str2metric_type (argv[1], &type))
5650 return CMD_WARNING;
5651
5652 /* Get metric type. */
5653 if (argc >= 3)
5654 if (!str2metric (argv[2], &metric))
5655 return CMD_WARNING;
5656
5657 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005658 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005659 else
paul020709f2003-04-04 02:44:16 +00005660 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005661
paul020709f2003-04-04 02:44:16 +00005662 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005663}
5664
5665ALIAS (ospf_redistribute_source_type_metric,
5666 ospf_redistribute_source_type_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005667 "redistribute " QUAGGA_REDIST_STR_OSPFD
5668 " metric-type (1|2) metric <0-16777214>",
5669 REDIST_STR
5670 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005671 "OSPF exterior metric type for redistributed routes\n"
5672 "Set OSPF External Type 1 metrics\n"
5673 "Set OSPF External Type 2 metrics\n"
5674 "Metric for redistributed routes\n"
5675 "OSPF default metric\n")
5676
5677ALIAS (ospf_redistribute_source_type_metric,
5678 ospf_redistribute_source_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005679 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5680 REDIST_STR
5681 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005682 "OSPF exterior metric type for redistributed routes\n"
5683 "Set OSPF External Type 1 metrics\n"
5684 "Set OSPF External Type 2 metrics\n")
5685
5686ALIAS (ospf_redistribute_source_type_metric,
5687 ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005688 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5689 REDIST_STR
5690 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005691
5692DEFUN (ospf_redistribute_source_metric_routemap,
5693 ospf_redistribute_source_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005694 "redistribute " QUAGGA_REDIST_STR_OSPFD
5695 " metric <0-16777214> route-map WORD",
5696 REDIST_STR
5697 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005698 "Metric for redistributed routes\n"
5699 "OSPF default metric\n"
5700 "Route map reference\n"
5701 "Pointer to route-map entries\n")
5702{
paul020709f2003-04-04 02:44:16 +00005703 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005704 int source;
5705 int metric = -1;
5706
5707 /* Get distribute source. */
5708 if (!str2distribute_source (argv[0], &source))
5709 return CMD_WARNING;
5710
5711 /* Get metric value. */
5712 if (argc >= 2)
5713 if (!str2metric (argv[1], &metric))
5714 return CMD_WARNING;
5715
5716 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005717 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005718 else
paul020709f2003-04-04 02:44:16 +00005719 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005720
paul020709f2003-04-04 02:44:16 +00005721 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005722}
5723
5724DEFUN (ospf_redistribute_source_type_routemap,
5725 ospf_redistribute_source_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005726 "redistribute " QUAGGA_REDIST_STR_OSPFD
5727 " metric-type (1|2) route-map WORD",
5728 REDIST_STR
5729 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005730 "OSPF exterior metric type for redistributed routes\n"
5731 "Set OSPF External Type 1 metrics\n"
5732 "Set OSPF External Type 2 metrics\n"
5733 "Route map reference\n"
5734 "Pointer to route-map entries\n")
5735{
paul020709f2003-04-04 02:44:16 +00005736 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005737 int source;
5738 int type = -1;
5739
5740 /* Get distribute source. */
5741 if (!str2distribute_source (argv[0], &source))
5742 return CMD_WARNING;
5743
5744 /* Get metric value. */
5745 if (argc >= 2)
5746 if (!str2metric_type (argv[1], &type))
5747 return CMD_WARNING;
5748
5749 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005750 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005751 else
paul020709f2003-04-04 02:44:16 +00005752 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005753
paul020709f2003-04-04 02:44:16 +00005754 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005755}
5756
5757DEFUN (ospf_redistribute_source_routemap,
5758 ospf_redistribute_source_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005759 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5760 REDIST_STR
5761 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005762 "Route map reference\n"
5763 "Pointer to route-map entries\n")
5764{
paul020709f2003-04-04 02:44:16 +00005765 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005766 int source;
5767
5768 /* Get distribute source. */
5769 if (!str2distribute_source (argv[0], &source))
5770 return CMD_WARNING;
5771
5772 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005773 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005774 else
paul020709f2003-04-04 02:44:16 +00005775 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005776
paul020709f2003-04-04 02:44:16 +00005777 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005778}
5779
5780DEFUN (no_ospf_redistribute_source,
5781 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005782 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005783 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005784 REDIST_STR
5785 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005786{
paul020709f2003-04-04 02:44:16 +00005787 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005788 int source;
5789
5790 if (!str2distribute_source (argv[0], &source))
5791 return CMD_WARNING;
5792
paul020709f2003-04-04 02:44:16 +00005793 ospf_routemap_unset (ospf, source);
5794 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005795}
5796
5797DEFUN (ospf_distribute_list_out,
5798 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005799 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005800 "Filter networks in routing updates\n"
5801 "Access-list name\n"
5802 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005803 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005804{
paul68980082003-03-25 05:07:42 +00005805 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005806 int source;
5807
5808 /* Get distribute source. */
5809 if (!str2distribute_source (argv[1], &source))
5810 return CMD_WARNING;
5811
paul68980082003-03-25 05:07:42 +00005812 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005813}
5814
5815DEFUN (no_ospf_distribute_list_out,
5816 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005817 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005818 NO_STR
5819 "Filter networks in routing updates\n"
5820 "Access-list name\n"
5821 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005822 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005823{
paul68980082003-03-25 05:07:42 +00005824 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005825 int source;
5826
5827 if (!str2distribute_source (argv[1], &source))
5828 return CMD_WARNING;
5829
paul68980082003-03-25 05:07:42 +00005830 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005831}
5832
5833/* Default information originate. */
5834DEFUN (ospf_default_information_originate_metric_type_routemap,
5835 ospf_default_information_originate_metric_type_routemap_cmd,
5836 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5837 "Control distribution of default information\n"
5838 "Distribute a default route\n"
5839 "OSPF default metric\n"
5840 "OSPF metric\n"
5841 "OSPF metric type for default routes\n"
5842 "Set OSPF External Type 1 metrics\n"
5843 "Set OSPF External Type 2 metrics\n"
5844 "Route map reference\n"
5845 "Pointer to route-map entries\n")
5846{
paul020709f2003-04-04 02:44:16 +00005847 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005848 int type = -1;
5849 int metric = -1;
5850
5851 /* Get metric value. */
5852 if (argc >= 1)
5853 if (!str2metric (argv[0], &metric))
5854 return CMD_WARNING;
5855
5856 /* Get metric type. */
5857 if (argc >= 2)
5858 if (!str2metric_type (argv[1], &type))
5859 return CMD_WARNING;
5860
5861 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005862 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005863 else
paul020709f2003-04-04 02:44:16 +00005864 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005865
paul020709f2003-04-04 02:44:16 +00005866 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5867 type, metric);
paul718e3742002-12-13 20:15:29 +00005868}
5869
5870ALIAS (ospf_default_information_originate_metric_type_routemap,
5871 ospf_default_information_originate_metric_type_cmd,
5872 "default-information originate metric <0-16777214> metric-type (1|2)",
5873 "Control distribution of default information\n"
5874 "Distribute a default route\n"
5875 "OSPF default metric\n"
5876 "OSPF metric\n"
5877 "OSPF metric type for default routes\n"
5878 "Set OSPF External Type 1 metrics\n"
5879 "Set OSPF External Type 2 metrics\n")
5880
5881ALIAS (ospf_default_information_originate_metric_type_routemap,
5882 ospf_default_information_originate_metric_cmd,
5883 "default-information originate metric <0-16777214>",
5884 "Control distribution of default information\n"
5885 "Distribute a default route\n"
5886 "OSPF default metric\n"
5887 "OSPF metric\n")
5888
5889ALIAS (ospf_default_information_originate_metric_type_routemap,
5890 ospf_default_information_originate_cmd,
5891 "default-information originate",
5892 "Control distribution of default information\n"
5893 "Distribute a default route\n")
5894
5895/* Default information originate. */
5896DEFUN (ospf_default_information_originate_metric_routemap,
5897 ospf_default_information_originate_metric_routemap_cmd,
5898 "default-information originate metric <0-16777214> route-map WORD",
5899 "Control distribution of default information\n"
5900 "Distribute a default route\n"
5901 "OSPF default metric\n"
5902 "OSPF metric\n"
5903 "Route map reference\n"
5904 "Pointer to route-map entries\n")
5905{
paul020709f2003-04-04 02:44:16 +00005906 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005907 int metric = -1;
5908
5909 /* Get metric value. */
5910 if (argc >= 1)
5911 if (!str2metric (argv[0], &metric))
5912 return CMD_WARNING;
5913
5914 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005915 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005916 else
paul020709f2003-04-04 02:44:16 +00005917 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005918
paul020709f2003-04-04 02:44:16 +00005919 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5920 -1, metric);
paul718e3742002-12-13 20:15:29 +00005921}
5922
5923/* Default information originate. */
5924DEFUN (ospf_default_information_originate_routemap,
5925 ospf_default_information_originate_routemap_cmd,
5926 "default-information originate route-map WORD",
5927 "Control distribution of default information\n"
5928 "Distribute a default route\n"
5929 "Route map reference\n"
5930 "Pointer to route-map entries\n")
5931{
paul020709f2003-04-04 02:44:16 +00005932 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005933
paul020709f2003-04-04 02:44:16 +00005934 if (argc == 1)
5935 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5936 else
5937 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5938
5939 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005940}
5941
5942DEFUN (ospf_default_information_originate_type_metric_routemap,
5943 ospf_default_information_originate_type_metric_routemap_cmd,
5944 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5945 "Control distribution of default information\n"
5946 "Distribute a default route\n"
5947 "OSPF metric type for default routes\n"
5948 "Set OSPF External Type 1 metrics\n"
5949 "Set OSPF External Type 2 metrics\n"
5950 "OSPF default metric\n"
5951 "OSPF metric\n"
5952 "Route map reference\n"
5953 "Pointer to route-map entries\n")
5954{
paul020709f2003-04-04 02:44:16 +00005955 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005956 int type = -1;
5957 int metric = -1;
5958
5959 /* Get metric type. */
5960 if (argc >= 1)
5961 if (!str2metric_type (argv[0], &type))
5962 return CMD_WARNING;
5963
5964 /* Get metric value. */
5965 if (argc >= 2)
5966 if (!str2metric (argv[1], &metric))
5967 return CMD_WARNING;
5968
5969 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005970 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005971 else
paul020709f2003-04-04 02:44:16 +00005972 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005973
paul020709f2003-04-04 02:44:16 +00005974 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5975 type, metric);
paul718e3742002-12-13 20:15:29 +00005976}
5977
5978ALIAS (ospf_default_information_originate_type_metric_routemap,
5979 ospf_default_information_originate_type_metric_cmd,
5980 "default-information originate metric-type (1|2) metric <0-16777214>",
5981 "Control distribution of default information\n"
5982 "Distribute a default route\n"
5983 "OSPF metric type for default routes\n"
5984 "Set OSPF External Type 1 metrics\n"
5985 "Set OSPF External Type 2 metrics\n"
5986 "OSPF default metric\n"
5987 "OSPF metric\n")
5988
5989ALIAS (ospf_default_information_originate_type_metric_routemap,
5990 ospf_default_information_originate_type_cmd,
5991 "default-information originate metric-type (1|2)",
5992 "Control distribution of default information\n"
5993 "Distribute a default route\n"
5994 "OSPF metric type for default routes\n"
5995 "Set OSPF External Type 1 metrics\n"
5996 "Set OSPF External Type 2 metrics\n")
5997
5998DEFUN (ospf_default_information_originate_type_routemap,
5999 ospf_default_information_originate_type_routemap_cmd,
6000 "default-information originate metric-type (1|2) route-map WORD",
6001 "Control distribution of default information\n"
6002 "Distribute a default route\n"
6003 "OSPF metric type for default routes\n"
6004 "Set OSPF External Type 1 metrics\n"
6005 "Set OSPF External Type 2 metrics\n"
6006 "Route map reference\n"
6007 "Pointer to route-map entries\n")
6008{
paul020709f2003-04-04 02:44:16 +00006009 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006010 int type = -1;
6011
6012 /* Get metric type. */
6013 if (argc >= 1)
6014 if (!str2metric_type (argv[0], &type))
6015 return CMD_WARNING;
6016
6017 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006018 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006019 else
paul020709f2003-04-04 02:44:16 +00006020 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006021
paul020709f2003-04-04 02:44:16 +00006022 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6023 type, -1);
paul718e3742002-12-13 20:15:29 +00006024}
6025
6026DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6027 ospf_default_information_originate_always_metric_type_routemap_cmd,
6028 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6029 "Control distribution of default information\n"
6030 "Distribute a default route\n"
6031 "Always advertise default route\n"
6032 "OSPF default metric\n"
6033 "OSPF metric\n"
6034 "OSPF metric type for default routes\n"
6035 "Set OSPF External Type 1 metrics\n"
6036 "Set OSPF External Type 2 metrics\n"
6037 "Route map reference\n"
6038 "Pointer to route-map entries\n")
6039{
paul020709f2003-04-04 02:44:16 +00006040 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006041 int type = -1;
6042 int metric = -1;
6043
6044 /* Get metric value. */
6045 if (argc >= 1)
6046 if (!str2metric (argv[0], &metric))
6047 return CMD_WARNING;
6048
6049 /* Get metric type. */
6050 if (argc >= 2)
6051 if (!str2metric_type (argv[1], &type))
6052 return CMD_WARNING;
6053
6054 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006055 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006056 else
paul020709f2003-04-04 02:44:16 +00006057 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006058
paul020709f2003-04-04 02:44:16 +00006059 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006060 type, metric);
6061}
6062
6063ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6064 ospf_default_information_originate_always_metric_type_cmd,
6065 "default-information originate always metric <0-16777214> metric-type (1|2)",
6066 "Control distribution of default information\n"
6067 "Distribute a default route\n"
6068 "Always advertise default route\n"
6069 "OSPF default metric\n"
6070 "OSPF metric\n"
6071 "OSPF metric type for default routes\n"
6072 "Set OSPF External Type 1 metrics\n"
6073 "Set OSPF External Type 2 metrics\n")
6074
6075ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6076 ospf_default_information_originate_always_metric_cmd,
6077 "default-information originate always metric <0-16777214>",
6078 "Control distribution of default information\n"
6079 "Distribute a default route\n"
6080 "Always advertise default route\n"
6081 "OSPF default metric\n"
6082 "OSPF metric\n"
6083 "OSPF metric type for default routes\n")
6084
6085ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6086 ospf_default_information_originate_always_cmd,
6087 "default-information originate always",
6088 "Control distribution of default information\n"
6089 "Distribute a default route\n"
6090 "Always advertise default route\n")
6091
6092DEFUN (ospf_default_information_originate_always_metric_routemap,
6093 ospf_default_information_originate_always_metric_routemap_cmd,
6094 "default-information originate always metric <0-16777214> route-map WORD",
6095 "Control distribution of default information\n"
6096 "Distribute a default route\n"
6097 "Always advertise default route\n"
6098 "OSPF default metric\n"
6099 "OSPF metric\n"
6100 "Route map reference\n"
6101 "Pointer to route-map entries\n")
6102{
paul020709f2003-04-04 02:44:16 +00006103 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006104 int metric = -1;
6105
6106 /* Get metric value. */
6107 if (argc >= 1)
6108 if (!str2metric (argv[0], &metric))
6109 return CMD_WARNING;
6110
6111 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006112 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006113 else
paul020709f2003-04-04 02:44:16 +00006114 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006115
paul020709f2003-04-04 02:44:16 +00006116 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6117 -1, metric);
paul718e3742002-12-13 20:15:29 +00006118}
6119
6120DEFUN (ospf_default_information_originate_always_routemap,
6121 ospf_default_information_originate_always_routemap_cmd,
6122 "default-information originate always route-map WORD",
6123 "Control distribution of default information\n"
6124 "Distribute a default route\n"
6125 "Always advertise default route\n"
6126 "Route map reference\n"
6127 "Pointer to route-map entries\n")
6128{
paul020709f2003-04-04 02:44:16 +00006129 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006130
paul020709f2003-04-04 02:44:16 +00006131 if (argc == 1)
6132 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6133 else
6134 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6135
6136 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006137}
6138
6139DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6140 ospf_default_information_originate_always_type_metric_routemap_cmd,
6141 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6142 "Control distribution of default information\n"
6143 "Distribute a default route\n"
6144 "Always advertise default route\n"
6145 "OSPF metric type for default routes\n"
6146 "Set OSPF External Type 1 metrics\n"
6147 "Set OSPF External Type 2 metrics\n"
6148 "OSPF default metric\n"
6149 "OSPF metric\n"
6150 "Route map reference\n"
6151 "Pointer to route-map entries\n")
6152{
paul020709f2003-04-04 02:44:16 +00006153 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006154 int type = -1;
6155 int metric = -1;
6156
6157 /* Get metric type. */
6158 if (argc >= 1)
6159 if (!str2metric_type (argv[0], &type))
6160 return CMD_WARNING;
6161
6162 /* Get metric value. */
6163 if (argc >= 2)
6164 if (!str2metric (argv[1], &metric))
6165 return CMD_WARNING;
6166
6167 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006168 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006169 else
paul020709f2003-04-04 02:44:16 +00006170 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006171
paul020709f2003-04-04 02:44:16 +00006172 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006173 type, metric);
6174}
6175
6176ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6177 ospf_default_information_originate_always_type_metric_cmd,
6178 "default-information originate always metric-type (1|2) metric <0-16777214>",
6179 "Control distribution of default information\n"
6180 "Distribute a default route\n"
6181 "Always advertise default route\n"
6182 "OSPF metric type for default routes\n"
6183 "Set OSPF External Type 1 metrics\n"
6184 "Set OSPF External Type 2 metrics\n"
6185 "OSPF default metric\n"
6186 "OSPF metric\n")
6187
6188ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6189 ospf_default_information_originate_always_type_cmd,
6190 "default-information originate always metric-type (1|2)",
6191 "Control distribution of default information\n"
6192 "Distribute a default route\n"
6193 "Always advertise default route\n"
6194 "OSPF metric type for default routes\n"
6195 "Set OSPF External Type 1 metrics\n"
6196 "Set OSPF External Type 2 metrics\n")
6197
6198DEFUN (ospf_default_information_originate_always_type_routemap,
6199 ospf_default_information_originate_always_type_routemap_cmd,
6200 "default-information originate always metric-type (1|2) route-map WORD",
6201 "Control distribution of default information\n"
6202 "Distribute a default route\n"
6203 "Always advertise default route\n"
6204 "OSPF metric type for default routes\n"
6205 "Set OSPF External Type 1 metrics\n"
6206 "Set OSPF External Type 2 metrics\n"
6207 "Route map reference\n"
6208 "Pointer to route-map entries\n")
6209{
paul020709f2003-04-04 02:44:16 +00006210 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006211 int type = -1;
6212
6213 /* Get metric type. */
6214 if (argc >= 1)
6215 if (!str2metric_type (argv[0], &type))
6216 return CMD_WARNING;
6217
6218 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006219 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006220 else
paul020709f2003-04-04 02:44:16 +00006221 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006222
paul020709f2003-04-04 02:44:16 +00006223 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006224 type, -1);
6225}
6226
6227DEFUN (no_ospf_default_information_originate,
6228 no_ospf_default_information_originate_cmd,
6229 "no default-information originate",
6230 NO_STR
6231 "Control distribution of default information\n"
6232 "Distribute a default route\n")
6233{
paul68980082003-03-25 05:07:42 +00006234 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006235 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006236
6237 p.family = AF_INET;
6238 p.prefix.s_addr = 0;
6239 p.prefixlen = 0;
6240
ajs5339cfd2005-09-19 13:28:05 +00006241 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006242
6243 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6244 ospf_external_info_delete (DEFAULT_ROUTE, p);
6245 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6246 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6247 }
6248
paul020709f2003-04-04 02:44:16 +00006249 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6250 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006251}
6252
6253DEFUN (ospf_default_metric,
6254 ospf_default_metric_cmd,
6255 "default-metric <0-16777214>",
6256 "Set metric of redistributed routes\n"
6257 "Default metric\n")
6258{
paul68980082003-03-25 05:07:42 +00006259 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006260 int metric = -1;
6261
6262 if (!str2metric (argv[0], &metric))
6263 return CMD_WARNING;
6264
paul68980082003-03-25 05:07:42 +00006265 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006266
6267 return CMD_SUCCESS;
6268}
6269
6270DEFUN (no_ospf_default_metric,
6271 no_ospf_default_metric_cmd,
6272 "no default-metric",
6273 NO_STR
6274 "Set metric of redistributed routes\n")
6275{
paul68980082003-03-25 05:07:42 +00006276 struct ospf *ospf = vty->index;
6277
6278 ospf->default_metric = -1;
6279
paul718e3742002-12-13 20:15:29 +00006280 return CMD_SUCCESS;
6281}
6282
6283ALIAS (no_ospf_default_metric,
6284 no_ospf_default_metric_val_cmd,
6285 "no default-metric <0-16777214>",
6286 NO_STR
6287 "Set metric of redistributed routes\n"
6288 "Default metric\n")
6289
6290DEFUN (ospf_distance,
6291 ospf_distance_cmd,
6292 "distance <1-255>",
6293 "Define an administrative distance\n"
6294 "OSPF Administrative distance\n")
6295{
paul68980082003-03-25 05:07:42 +00006296 struct ospf *ospf = vty->index;
6297
6298 ospf->distance_all = atoi (argv[0]);
6299
paul718e3742002-12-13 20:15:29 +00006300 return CMD_SUCCESS;
6301}
6302
6303DEFUN (no_ospf_distance,
6304 no_ospf_distance_cmd,
6305 "no distance <1-255>",
6306 NO_STR
6307 "Define an administrative distance\n"
6308 "OSPF Administrative distance\n")
6309{
paul68980082003-03-25 05:07:42 +00006310 struct ospf *ospf = vty->index;
6311
6312 ospf->distance_all = 0;
6313
paul718e3742002-12-13 20:15:29 +00006314 return CMD_SUCCESS;
6315}
6316
6317DEFUN (no_ospf_distance_ospf,
6318 no_ospf_distance_ospf_cmd,
6319 "no distance ospf",
6320 NO_STR
6321 "Define an administrative distance\n"
6322 "OSPF Administrative distance\n"
6323 "OSPF Distance\n")
6324{
paul68980082003-03-25 05:07:42 +00006325 struct ospf *ospf = vty->index;
6326
6327 ospf->distance_intra = 0;
6328 ospf->distance_inter = 0;
6329 ospf->distance_external = 0;
6330
paul718e3742002-12-13 20:15:29 +00006331 return CMD_SUCCESS;
6332}
6333
6334DEFUN (ospf_distance_ospf_intra,
6335 ospf_distance_ospf_intra_cmd,
6336 "distance ospf intra-area <1-255>",
6337 "Define an administrative distance\n"
6338 "OSPF Administrative distance\n"
6339 "Intra-area routes\n"
6340 "Distance for intra-area routes\n")
6341{
paul68980082003-03-25 05:07:42 +00006342 struct ospf *ospf = vty->index;
6343
6344 ospf->distance_intra = atoi (argv[0]);
6345
paul718e3742002-12-13 20:15:29 +00006346 return CMD_SUCCESS;
6347}
6348
6349DEFUN (ospf_distance_ospf_intra_inter,
6350 ospf_distance_ospf_intra_inter_cmd,
6351 "distance ospf intra-area <1-255> inter-area <1-255>",
6352 "Define an administrative distance\n"
6353 "OSPF Administrative distance\n"
6354 "Intra-area routes\n"
6355 "Distance for intra-area routes\n"
6356 "Inter-area routes\n"
6357 "Distance for inter-area routes\n")
6358{
paul68980082003-03-25 05:07:42 +00006359 struct ospf *ospf = vty->index;
6360
6361 ospf->distance_intra = atoi (argv[0]);
6362 ospf->distance_inter = atoi (argv[1]);
6363
paul718e3742002-12-13 20:15:29 +00006364 return CMD_SUCCESS;
6365}
6366
6367DEFUN (ospf_distance_ospf_intra_external,
6368 ospf_distance_ospf_intra_external_cmd,
6369 "distance ospf intra-area <1-255> external <1-255>",
6370 "Define an administrative distance\n"
6371 "OSPF Administrative distance\n"
6372 "Intra-area routes\n"
6373 "Distance for intra-area routes\n"
6374 "External routes\n"
6375 "Distance for external routes\n")
6376{
paul68980082003-03-25 05:07:42 +00006377 struct ospf *ospf = vty->index;
6378
6379 ospf->distance_intra = atoi (argv[0]);
6380 ospf->distance_external = atoi (argv[1]);
6381
paul718e3742002-12-13 20:15:29 +00006382 return CMD_SUCCESS;
6383}
6384
6385DEFUN (ospf_distance_ospf_intra_inter_external,
6386 ospf_distance_ospf_intra_inter_external_cmd,
6387 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6388 "Define an administrative distance\n"
6389 "OSPF Administrative distance\n"
6390 "Intra-area routes\n"
6391 "Distance for intra-area routes\n"
6392 "Inter-area routes\n"
6393 "Distance for inter-area routes\n"
6394 "External routes\n"
6395 "Distance for external routes\n")
6396{
paul68980082003-03-25 05:07:42 +00006397 struct ospf *ospf = vty->index;
6398
6399 ospf->distance_intra = atoi (argv[0]);
6400 ospf->distance_inter = atoi (argv[1]);
6401 ospf->distance_external = atoi (argv[2]);
6402
paul718e3742002-12-13 20:15:29 +00006403 return CMD_SUCCESS;
6404}
6405
6406DEFUN (ospf_distance_ospf_intra_external_inter,
6407 ospf_distance_ospf_intra_external_inter_cmd,
6408 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6409 "Define an administrative distance\n"
6410 "OSPF Administrative distance\n"
6411 "Intra-area routes\n"
6412 "Distance for intra-area routes\n"
6413 "External routes\n"
6414 "Distance for external routes\n"
6415 "Inter-area routes\n"
6416 "Distance for inter-area routes\n")
6417{
paul68980082003-03-25 05:07:42 +00006418 struct ospf *ospf = vty->index;
6419
6420 ospf->distance_intra = atoi (argv[0]);
6421 ospf->distance_external = atoi (argv[1]);
6422 ospf->distance_inter = atoi (argv[2]);
6423
paul718e3742002-12-13 20:15:29 +00006424 return CMD_SUCCESS;
6425}
6426
6427DEFUN (ospf_distance_ospf_inter,
6428 ospf_distance_ospf_inter_cmd,
6429 "distance ospf inter-area <1-255>",
6430 "Define an administrative distance\n"
6431 "OSPF Administrative distance\n"
6432 "Inter-area routes\n"
6433 "Distance for inter-area routes\n")
6434{
paul68980082003-03-25 05:07:42 +00006435 struct ospf *ospf = vty->index;
6436
6437 ospf->distance_inter = atoi (argv[0]);
6438
paul718e3742002-12-13 20:15:29 +00006439 return CMD_SUCCESS;
6440}
6441
6442DEFUN (ospf_distance_ospf_inter_intra,
6443 ospf_distance_ospf_inter_intra_cmd,
6444 "distance ospf inter-area <1-255> intra-area <1-255>",
6445 "Define an administrative distance\n"
6446 "OSPF Administrative distance\n"
6447 "Inter-area routes\n"
6448 "Distance for inter-area routes\n"
6449 "Intra-area routes\n"
6450 "Distance for intra-area routes\n")
6451{
paul68980082003-03-25 05:07:42 +00006452 struct ospf *ospf = vty->index;
6453
6454 ospf->distance_inter = atoi (argv[0]);
6455 ospf->distance_intra = atoi (argv[1]);
6456
paul718e3742002-12-13 20:15:29 +00006457 return CMD_SUCCESS;
6458}
6459
6460DEFUN (ospf_distance_ospf_inter_external,
6461 ospf_distance_ospf_inter_external_cmd,
6462 "distance ospf inter-area <1-255> external <1-255>",
6463 "Define an administrative distance\n"
6464 "OSPF Administrative distance\n"
6465 "Inter-area routes\n"
6466 "Distance for inter-area routes\n"
6467 "External routes\n"
6468 "Distance for external routes\n")
6469{
paul68980082003-03-25 05:07:42 +00006470 struct ospf *ospf = vty->index;
6471
6472 ospf->distance_inter = atoi (argv[0]);
6473 ospf->distance_external = atoi (argv[1]);
6474
paul718e3742002-12-13 20:15:29 +00006475 return CMD_SUCCESS;
6476}
6477
6478DEFUN (ospf_distance_ospf_inter_intra_external,
6479 ospf_distance_ospf_inter_intra_external_cmd,
6480 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6481 "Define an administrative distance\n"
6482 "OSPF Administrative distance\n"
6483 "Inter-area routes\n"
6484 "Distance for inter-area routes\n"
6485 "Intra-area routes\n"
6486 "Distance for intra-area routes\n"
6487 "External routes\n"
6488 "Distance for external routes\n")
6489{
paul68980082003-03-25 05:07:42 +00006490 struct ospf *ospf = vty->index;
6491
6492 ospf->distance_inter = atoi (argv[0]);
6493 ospf->distance_intra = atoi (argv[1]);
6494 ospf->distance_external = atoi (argv[2]);
6495
paul718e3742002-12-13 20:15:29 +00006496 return CMD_SUCCESS;
6497}
6498
6499DEFUN (ospf_distance_ospf_inter_external_intra,
6500 ospf_distance_ospf_inter_external_intra_cmd,
6501 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6502 "Define an administrative distance\n"
6503 "OSPF Administrative distance\n"
6504 "Inter-area routes\n"
6505 "Distance for inter-area routes\n"
6506 "External routes\n"
6507 "Distance for external routes\n"
6508 "Intra-area routes\n"
6509 "Distance for intra-area routes\n")
6510{
paul68980082003-03-25 05:07:42 +00006511 struct ospf *ospf = vty->index;
6512
6513 ospf->distance_inter = atoi (argv[0]);
6514 ospf->distance_external = atoi (argv[1]);
6515 ospf->distance_intra = atoi (argv[2]);
6516
paul718e3742002-12-13 20:15:29 +00006517 return CMD_SUCCESS;
6518}
6519
6520DEFUN (ospf_distance_ospf_external,
6521 ospf_distance_ospf_external_cmd,
6522 "distance ospf external <1-255>",
6523 "Define an administrative distance\n"
6524 "OSPF Administrative distance\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_external = atoi (argv[0]);
6531
paul718e3742002-12-13 20:15:29 +00006532 return CMD_SUCCESS;
6533}
6534
6535DEFUN (ospf_distance_ospf_external_intra,
6536 ospf_distance_ospf_external_intra_cmd,
6537 "distance ospf external <1-255> intra-area <1-255>",
6538 "Define an administrative distance\n"
6539 "OSPF Administrative distance\n"
6540 "External routes\n"
6541 "Distance for external routes\n"
6542 "Intra-area routes\n"
6543 "Distance for intra-area routes\n")
6544{
paul68980082003-03-25 05:07:42 +00006545 struct ospf *ospf = vty->index;
6546
6547 ospf->distance_external = atoi (argv[0]);
6548 ospf->distance_intra = atoi (argv[1]);
6549
paul718e3742002-12-13 20:15:29 +00006550 return CMD_SUCCESS;
6551}
6552
6553DEFUN (ospf_distance_ospf_external_inter,
6554 ospf_distance_ospf_external_inter_cmd,
6555 "distance ospf external <1-255> inter-area <1-255>",
6556 "Define an administrative distance\n"
6557 "OSPF Administrative distance\n"
6558 "External routes\n"
6559 "Distance for external routes\n"
6560 "Inter-area routes\n"
6561 "Distance for inter-area routes\n")
6562{
paul68980082003-03-25 05:07:42 +00006563 struct ospf *ospf = vty->index;
6564
6565 ospf->distance_external = atoi (argv[0]);
6566 ospf->distance_inter = atoi (argv[1]);
6567
paul718e3742002-12-13 20:15:29 +00006568 return CMD_SUCCESS;
6569}
6570
6571DEFUN (ospf_distance_ospf_external_intra_inter,
6572 ospf_distance_ospf_external_intra_inter_cmd,
6573 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6574 "Define an administrative distance\n"
6575 "OSPF Administrative distance\n"
6576 "External routes\n"
6577 "Distance for external routes\n"
6578 "Intra-area routes\n"
6579 "Distance for intra-area routes\n"
6580 "Inter-area routes\n"
6581 "Distance for inter-area routes\n")
6582{
paul68980082003-03-25 05:07:42 +00006583 struct ospf *ospf = vty->index;
6584
6585 ospf->distance_external = atoi (argv[0]);
6586 ospf->distance_intra = atoi (argv[1]);
6587 ospf->distance_inter = atoi (argv[2]);
6588
paul718e3742002-12-13 20:15:29 +00006589 return CMD_SUCCESS;
6590}
6591
6592DEFUN (ospf_distance_ospf_external_inter_intra,
6593 ospf_distance_ospf_external_inter_intra_cmd,
6594 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6595 "Define an administrative distance\n"
6596 "OSPF Administrative distance\n"
6597 "External routes\n"
6598 "Distance for external routes\n"
6599 "Inter-area routes\n"
6600 "Distance for inter-area routes\n"
6601 "Intra-area routes\n"
6602 "Distance for intra-area routes\n")
6603{
paul68980082003-03-25 05:07:42 +00006604 struct ospf *ospf = vty->index;
6605
6606 ospf->distance_external = atoi (argv[0]);
6607 ospf->distance_inter = atoi (argv[1]);
6608 ospf->distance_intra = atoi (argv[2]);
6609
paul718e3742002-12-13 20:15:29 +00006610 return CMD_SUCCESS;
6611}
6612
6613DEFUN (ospf_distance_source,
6614 ospf_distance_source_cmd,
6615 "distance <1-255> A.B.C.D/M",
6616 "Administrative distance\n"
6617 "Distance value\n"
6618 "IP source prefix\n")
6619{
paul020709f2003-04-04 02:44:16 +00006620 struct ospf *ospf = vty->index;
6621
6622 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006623
paul718e3742002-12-13 20:15:29 +00006624 return CMD_SUCCESS;
6625}
6626
6627DEFUN (no_ospf_distance_source,
6628 no_ospf_distance_source_cmd,
6629 "no distance <1-255> A.B.C.D/M",
6630 NO_STR
6631 "Administrative distance\n"
6632 "Distance value\n"
6633 "IP source prefix\n")
6634{
paul020709f2003-04-04 02:44:16 +00006635 struct ospf *ospf = vty->index;
6636
6637 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6638
paul718e3742002-12-13 20:15:29 +00006639 return CMD_SUCCESS;
6640}
6641
6642DEFUN (ospf_distance_source_access_list,
6643 ospf_distance_source_access_list_cmd,
6644 "distance <1-255> A.B.C.D/M WORD",
6645 "Administrative distance\n"
6646 "Distance value\n"
6647 "IP source prefix\n"
6648 "Access list name\n")
6649{
paul020709f2003-04-04 02:44:16 +00006650 struct ospf *ospf = vty->index;
6651
6652 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6653
paul718e3742002-12-13 20:15:29 +00006654 return CMD_SUCCESS;
6655}
6656
6657DEFUN (no_ospf_distance_source_access_list,
6658 no_ospf_distance_source_access_list_cmd,
6659 "no distance <1-255> A.B.C.D/M WORD",
6660 NO_STR
6661 "Administrative distance\n"
6662 "Distance value\n"
6663 "IP source prefix\n"
6664 "Access list name\n")
6665{
paul020709f2003-04-04 02:44:16 +00006666 struct ospf *ospf = vty->index;
6667
6668 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6669
paul718e3742002-12-13 20:15:29 +00006670 return CMD_SUCCESS;
6671}
6672
vincentba682532005-09-29 13:52:57 +00006673DEFUN (ip_ospf_mtu_ignore,
6674 ip_ospf_mtu_ignore_addr_cmd,
6675 "ip ospf mtu-ignore A.B.C.D",
6676 "IP Information\n"
6677 "OSPF interface commands\n"
6678 "Disable mtu mismatch detection\n"
6679 "Address of interface")
6680{
6681 struct interface *ifp = vty->index;
6682 struct in_addr addr;
6683 int ret;
6684
6685 struct ospf_if_params *params;
6686 params = IF_DEF_PARAMS (ifp);
6687
6688 if (argc == 1)
6689 {
6690 ret = inet_aton(argv[0], &addr);
6691 if (!ret)
6692 {
6693 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6694 VTY_NEWLINE);
6695 return CMD_WARNING;
6696 }
6697 params = ospf_get_if_params (ifp, addr);
6698 ospf_if_update_params (ifp, addr);
6699 }
6700 params->mtu_ignore = 1;
6701 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6702 SET_IF_PARAM (params, mtu_ignore);
6703 else
6704 {
6705 UNSET_IF_PARAM (params, mtu_ignore);
6706 if (params != IF_DEF_PARAMS (ifp))
6707 {
6708 ospf_free_if_params (ifp, addr);
6709 ospf_if_update_params (ifp, addr);
6710 }
6711 }
6712 return CMD_SUCCESS;
6713}
6714
6715ALIAS (ip_ospf_mtu_ignore,
6716 ip_ospf_mtu_ignore_cmd,
6717 "ip ospf mtu-ignore",
6718 "IP Information\n"
6719 "OSPF interface commands\n"
6720 "Disable mtu mismatch detection\n")
6721
6722
6723DEFUN (no_ip_ospf_mtu_ignore,
6724 no_ip_ospf_mtu_ignore_addr_cmd,
6725 "no ip ospf mtu-ignore A.B.C.D",
6726 "IP Information\n"
6727 "OSPF interface commands\n"
6728 "Disable mtu mismatch detection\n"
6729 "Address of interface")
6730{
6731 struct interface *ifp = vty->index;
6732 struct in_addr addr;
6733 int ret;
6734
6735 struct ospf_if_params *params;
6736 params = IF_DEF_PARAMS (ifp);
6737
6738 if (argc == 1)
6739 {
6740 ret = inet_aton(argv[0], &addr);
6741 if (!ret)
6742 {
6743 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6744 VTY_NEWLINE);
6745 return CMD_WARNING;
6746 }
6747 params = ospf_get_if_params (ifp, addr);
6748 ospf_if_update_params (ifp, addr);
6749 }
6750 params->mtu_ignore = 0;
6751 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6752 SET_IF_PARAM (params, mtu_ignore);
6753 else
6754 {
6755 UNSET_IF_PARAM (params, mtu_ignore);
6756 if (params != IF_DEF_PARAMS (ifp))
6757 {
6758 ospf_free_if_params (ifp, addr);
6759 ospf_if_update_params (ifp, addr);
6760 }
6761 }
6762 return CMD_SUCCESS;
6763}
6764
6765ALIAS (no_ip_ospf_mtu_ignore,
6766 no_ip_ospf_mtu_ignore_cmd,
6767 "no ip ospf mtu-ignore",
6768 "IP Information\n"
6769 "OSPF interface commands\n"
6770 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00006771
6772DEFUN (ospf_max_metric_router_lsa_admin,
6773 ospf_max_metric_router_lsa_admin_cmd,
6774 "max-metric router-lsa administrative",
6775 "OSPF maximum / infinite-distance metric\n"
6776 "Advertise own Router-LSA with infinite distance (stub router)\n"
6777 "Administratively applied, for an indefinite period\n")
6778{
6779 struct listnode *ln;
6780 struct ospf_area *area;
6781 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006782
paul88d6cf32005-10-29 12:50:09 +00006783 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6784 {
6785 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6786
6787 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
6788 ospf_router_lsa_timer_add (area);
6789 }
6790 return CMD_SUCCESS;
6791}
6792
6793DEFUN (no_ospf_max_metric_router_lsa_admin,
6794 no_ospf_max_metric_router_lsa_admin_cmd,
6795 "no max-metric router-lsa administrative",
6796 NO_STR
6797 "OSPF maximum / infinite-distance metric\n"
6798 "Advertise own Router-LSA with infinite distance (stub router)\n"
6799 "Administratively applied, for an indefinite period\n")
6800{
6801 struct listnode *ln;
6802 struct ospf_area *area;
6803 struct ospf *ospf = vty->index;
6804
6805 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6806 {
6807 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6808
6809 /* Don't trample on the start-up stub timer */
6810 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6811 && !area->t_stub_router)
6812 {
6813 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6814 ospf_router_lsa_timer_add (area);
6815 }
6816 }
6817 return CMD_SUCCESS;
6818}
6819
6820DEFUN (ospf_max_metric_router_lsa_startup,
6821 ospf_max_metric_router_lsa_startup_cmd,
6822 "max-metric router-lsa on-startup <5-86400>",
6823 "OSPF maximum / infinite-distance metric\n"
6824 "Advertise own Router-LSA with infinite distance (stub router)\n"
6825 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6826 "Time (seconds) to advertise self as stub-router\n")
6827{
6828 unsigned int seconds;
6829 struct ospf *ospf = vty->index;
6830
6831 if (argc != 1)
6832 {
6833 vty_out (vty, "%% Must supply stub-router period");
6834 return CMD_WARNING;
6835 }
6836
6837 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6838
6839 ospf->stub_router_startup_time = seconds;
6840
6841 return CMD_SUCCESS;
6842}
6843
6844DEFUN (no_ospf_max_metric_router_lsa_startup,
6845 no_ospf_max_metric_router_lsa_startup_cmd,
6846 "no max-metric router-lsa on-startup",
6847 NO_STR
6848 "OSPF maximum / infinite-distance metric\n"
6849 "Advertise own Router-LSA with infinite distance (stub router)\n"
6850 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6851{
6852 struct listnode *ln;
6853 struct ospf_area *area;
6854 struct ospf *ospf = vty->index;
6855
6856 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6857
6858 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6859 {
6860 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6861 OSPF_TIMER_OFF (area->t_stub_router);
6862
6863 /* Don't trample on admin stub routed */
6864 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6865 {
6866 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6867 ospf_router_lsa_timer_add (area);
6868 }
6869 }
6870 return CMD_SUCCESS;
6871}
6872
6873DEFUN (ospf_max_metric_router_lsa_shutdown,
6874 ospf_max_metric_router_lsa_shutdown_cmd,
6875 "max-metric router-lsa on-shutdown <5-86400>",
6876 "OSPF maximum / infinite-distance metric\n"
6877 "Advertise own Router-LSA with infinite distance (stub router)\n"
6878 "Advertise stub-router prior to full shutdown of OSPF\n"
6879 "Time (seconds) to wait till full shutdown\n")
6880{
6881 unsigned int seconds;
6882 struct ospf *ospf = vty->index;
6883
6884 if (argc != 1)
6885 {
6886 vty_out (vty, "%% Must supply stub-router shutdown period");
6887 return CMD_WARNING;
6888 }
6889
6890 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6891
6892 ospf->stub_router_shutdown_time = seconds;
6893
6894 return CMD_SUCCESS;
6895}
6896
6897DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6898 no_ospf_max_metric_router_lsa_shutdown_cmd,
6899 "no max-metric router-lsa on-shutdown",
6900 NO_STR
6901 "OSPF maximum / infinite-distance metric\n"
6902 "Advertise own Router-LSA with infinite distance (stub router)\n"
6903 "Advertise stub-router prior to full shutdown of OSPF\n")
6904{
6905 struct ospf *ospf = vty->index;
6906
6907 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6908
6909 return CMD_SUCCESS;
6910}
6911
6912static void
6913config_write_stub_router (struct vty *vty, struct ospf *ospf)
6914{
6915 struct listnode *ln;
6916 struct ospf_area *area;
6917
6918 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6919 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6920 ospf->stub_router_startup_time, VTY_NEWLINE);
6921 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6922 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6923 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6924 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6925 {
6926 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6927 {
6928 vty_out (vty, " max-metric router-lsa administrative%s",
6929 VTY_NEWLINE);
6930 break;
6931 }
6932 }
6933 return;
6934}
6935
paul4dadc292005-05-06 21:37:42 +00006936static void
paul718e3742002-12-13 20:15:29 +00006937show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6938{
6939 struct route_node *rn;
6940 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006941 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006942 struct ospf_path *path;
6943
6944 vty_out (vty, "============ OSPF network routing table ============%s",
6945 VTY_NEWLINE);
6946
6947 for (rn = route_top (rt); rn; rn = route_next (rn))
6948 if ((or = rn->info) != NULL)
6949 {
6950 char buf1[19];
6951 snprintf (buf1, 19, "%s/%d",
6952 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6953
6954 switch (or->path_type)
6955 {
6956 case OSPF_PATH_INTER_AREA:
6957 if (or->type == OSPF_DESTINATION_NETWORK)
6958 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6959 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6960 else if (or->type == OSPF_DESTINATION_DISCARD)
6961 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6962 break;
6963 case OSPF_PATH_INTRA_AREA:
6964 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6965 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6966 break;
6967 default:
6968 break;
6969 }
6970
6971 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00006972 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00006973 {
hasso54bedb52005-08-17 13:31:47 +00006974 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00006975 {
6976 if (path->nexthop.s_addr == 0)
6977 vty_out (vty, "%24s directly attached to %s%s",
6978 "", path->oi->ifp->name, VTY_NEWLINE);
6979 else
6980 vty_out (vty, "%24s via %s, %s%s", "",
6981 inet_ntoa (path->nexthop), path->oi->ifp->name,
6982 VTY_NEWLINE);
6983 }
6984 }
paul718e3742002-12-13 20:15:29 +00006985 }
6986 vty_out (vty, "%s", VTY_NEWLINE);
6987}
6988
paul4dadc292005-05-06 21:37:42 +00006989static void
paul718e3742002-12-13 20:15:29 +00006990show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6991{
6992 struct route_node *rn;
6993 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006994 struct listnode *pnode;
6995 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006996 struct ospf_path *path;
6997
6998 vty_out (vty, "============ OSPF router routing table =============%s",
6999 VTY_NEWLINE);
7000 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7001 if (rn->info)
7002 {
7003 int flag = 0;
7004
7005 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7006
paul1eb8ef22005-04-07 07:30:20 +00007007 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7008 {
7009 if (flag++)
7010 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007011
paul1eb8ef22005-04-07 07:30:20 +00007012 /* Show path. */
7013 vty_out (vty, "%s [%d] area: %s",
7014 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7015 or->cost, inet_ntoa (or->u.std.area_id));
7016 /* Show flags. */
7017 vty_out (vty, "%s%s%s",
7018 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7019 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7020 VTY_NEWLINE);
7021
7022 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7023 {
hasso54bedb52005-08-17 13:31:47 +00007024 if (path->oi != NULL && ospf_if_exists(path->oi))
7025 {
7026 if (path->nexthop.s_addr == 0)
7027 vty_out (vty, "%24s directly attached to %s%s",
7028 "", path->oi->ifp->name, VTY_NEWLINE);
7029 else
7030 vty_out (vty, "%24s via %s, %s%s", "",
7031 inet_ntoa (path->nexthop),
7032 path->oi->ifp->name, VTY_NEWLINE);
7033 }
paul1eb8ef22005-04-07 07:30:20 +00007034 }
7035 }
paul718e3742002-12-13 20:15:29 +00007036 }
7037 vty_out (vty, "%s", VTY_NEWLINE);
7038}
7039
paul4dadc292005-05-06 21:37:42 +00007040static void
paul718e3742002-12-13 20:15:29 +00007041show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7042{
7043 struct route_node *rn;
7044 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007045 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007046 struct ospf_path *path;
7047
7048 vty_out (vty, "============ OSPF external routing table ===========%s",
7049 VTY_NEWLINE);
7050 for (rn = route_top (rt); rn; rn = route_next (rn))
7051 if ((er = rn->info) != NULL)
7052 {
7053 char buf1[19];
7054 snprintf (buf1, 19, "%s/%d",
7055 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7056
7057 switch (er->path_type)
7058 {
7059 case OSPF_PATH_TYPE1_EXTERNAL:
7060 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7061 er->cost, er->u.ext.tag, VTY_NEWLINE);
7062 break;
7063 case OSPF_PATH_TYPE2_EXTERNAL:
7064 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7065 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7066 break;
7067 }
7068
paul1eb8ef22005-04-07 07:30:20 +00007069 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007070 {
hasso54bedb52005-08-17 13:31:47 +00007071 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00007072 {
7073 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007074 vty_out (vty, "%24s directly attached to %s%s",
7075 "", path->oi->ifp->name, VTY_NEWLINE);
7076 else
7077 vty_out (vty, "%24s via %s, %s%s", "",
7078 inet_ntoa (path->nexthop), path->oi->ifp->name,
7079 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007080 }
7081 }
7082 }
7083 vty_out (vty, "%s", VTY_NEWLINE);
7084}
7085
paul718e3742002-12-13 20:15:29 +00007086DEFUN (show_ip_ospf_border_routers,
7087 show_ip_ospf_border_routers_cmd,
7088 "show ip ospf border-routers",
7089 SHOW_STR
7090 IP_STR
7091 "show all the ABR's and ASBR's\n"
7092 "for this area\n")
7093{
paul020709f2003-04-04 02:44:16 +00007094 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007095
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007096 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007097 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007098 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007099 return CMD_SUCCESS;
7100 }
7101
paul68980082003-03-25 05:07:42 +00007102 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007103 {
7104 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7105 return CMD_SUCCESS;
7106 }
7107
7108 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007109 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007110
7111 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007112 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007113
7114 return CMD_SUCCESS;
7115}
paul718e3742002-12-13 20:15:29 +00007116
7117DEFUN (show_ip_ospf_route,
7118 show_ip_ospf_route_cmd,
7119 "show ip ospf route",
7120 SHOW_STR
7121 IP_STR
7122 "OSPF information\n"
7123 "OSPF routing table\n")
7124{
paul020709f2003-04-04 02:44:16 +00007125 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007126
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007127 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007128 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007129 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007130 return CMD_SUCCESS;
7131 }
7132
paul68980082003-03-25 05:07:42 +00007133 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007134 {
7135 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7136 return CMD_SUCCESS;
7137 }
7138
7139 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007140 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007141
7142 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007143 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007144
7145 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007146 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007147
7148 return CMD_SUCCESS;
7149}
7150
7151
hassoeb1ce602004-10-08 08:17:22 +00007152const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007153{
7154 "unknown",
7155 "standard",
7156 "ibm",
7157 "cisco",
7158 "shortcut"
7159};
7160
hassoeb1ce602004-10-08 08:17:22 +00007161const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007162{
7163 "default",
7164 "enable",
7165 "disable"
7166};
7167
7168
paul4dadc292005-05-06 21:37:42 +00007169static void
paul718e3742002-12-13 20:15:29 +00007170area_id2str (char *buf, int length, struct ospf_area *area)
7171{
7172 memset (buf, 0, length);
7173
7174 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7175 strncpy (buf, inet_ntoa (area->area_id), length);
7176 else
7177 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7178}
7179
7180
hassoeb1ce602004-10-08 08:17:22 +00007181const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007182{
7183 "unknown", /* should never be used. */
7184 "point-to-point",
7185 "broadcast",
7186 "non-broadcast",
7187 "point-to-multipoint",
7188 "virtual-link", /* should never be used. */
7189 "loopback"
7190};
7191
7192/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007193static int
paul718e3742002-12-13 20:15:29 +00007194config_write_interface (struct vty *vty)
7195{
hasso52dc7ee2004-09-23 19:18:23 +00007196 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007197 struct interface *ifp;
7198 struct crypt_key *ck;
7199 int write = 0;
7200 struct route_node *rn = NULL;
7201 struct ospf_if_params *params;
7202
paul1eb8ef22005-04-07 07:30:20 +00007203 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007204 {
paul718e3742002-12-13 20:15:29 +00007205 if (memcmp (ifp->name, "VLINK", 5) == 0)
7206 continue;
7207
7208 vty_out (vty, "!%s", VTY_NEWLINE);
7209 vty_out (vty, "interface %s%s", ifp->name,
7210 VTY_NEWLINE);
7211 if (ifp->desc)
7212 vty_out (vty, " description %s%s", ifp->desc,
7213 VTY_NEWLINE);
7214
7215 write++;
7216
7217 params = IF_DEF_PARAMS (ifp);
7218
7219 do {
7220 /* Interface Network print. */
7221 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007222 params->type != OSPF_IFTYPE_LOOPBACK)
7223 {
ajsbc18d612004-12-15 15:07:19 +00007224 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007225 {
7226 vty_out (vty, " ip ospf network %s",
7227 ospf_int_type_str[params->type]);
7228 if (params != IF_DEF_PARAMS (ifp))
7229 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7230 vty_out (vty, "%s", VTY_NEWLINE);
7231 }
paul718e3742002-12-13 20:15:29 +00007232 }
7233
7234 /* OSPF interface authentication print */
7235 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7236 params->auth_type != OSPF_AUTH_NOTSET)
7237 {
hassoeb1ce602004-10-08 08:17:22 +00007238 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007239
7240 /* Translation tables are not that much help here due to syntax
7241 of the simple option */
7242 switch (params->auth_type)
7243 {
7244
7245 case OSPF_AUTH_NULL:
7246 auth_str = " null";
7247 break;
7248
7249 case OSPF_AUTH_SIMPLE:
7250 auth_str = "";
7251 break;
7252
7253 case OSPF_AUTH_CRYPTOGRAPHIC:
7254 auth_str = " message-digest";
7255 break;
7256
7257 default:
7258 auth_str = "";
7259 break;
7260 }
7261
7262 vty_out (vty, " ip ospf authentication%s", auth_str);
7263 if (params != IF_DEF_PARAMS (ifp))
7264 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7265 vty_out (vty, "%s", VTY_NEWLINE);
7266 }
7267
7268 /* Simple Authentication Password print. */
7269 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7270 params->auth_simple[0] != '\0')
7271 {
7272 vty_out (vty, " ip ospf authentication-key %s",
7273 params->auth_simple);
7274 if (params != IF_DEF_PARAMS (ifp))
7275 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7276 vty_out (vty, "%s", VTY_NEWLINE);
7277 }
7278
7279 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007280 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007281 {
paul718e3742002-12-13 20:15:29 +00007282 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7283 ck->key_id, ck->auth_key);
7284 if (params != IF_DEF_PARAMS (ifp))
7285 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7286 vty_out (vty, "%s", VTY_NEWLINE);
7287 }
7288
7289 /* Interface Output Cost print. */
7290 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7291 {
7292 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7293 if (params != IF_DEF_PARAMS (ifp))
7294 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7295 vty_out (vty, "%s", VTY_NEWLINE);
7296 }
7297
7298 /* Hello Interval print. */
7299 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7300 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7301 {
7302 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7303 if (params != IF_DEF_PARAMS (ifp))
7304 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7305 vty_out (vty, "%s", VTY_NEWLINE);
7306 }
7307
7308
7309 /* Router Dead Interval print. */
7310 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7311 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7312 {
paulf9ad9372005-10-21 00:45:17 +00007313 vty_out (vty, " ip ospf dead-interval ");
7314
7315 /* fast hello ? */
7316 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7317 vty_out (vty, "minimal hello-multiplier %d",
7318 params->fast_hello);
7319 else
7320 vty_out (vty, "%u", params->v_wait);
7321
paul718e3742002-12-13 20:15:29 +00007322 if (params != IF_DEF_PARAMS (ifp))
7323 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7324 vty_out (vty, "%s", VTY_NEWLINE);
7325 }
7326
7327 /* Router Priority print. */
7328 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7329 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7330 {
7331 vty_out (vty, " ip ospf priority %u", params->priority);
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 /* Retransmit Interval print. */
7338 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7339 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7340 {
7341 vty_out (vty, " ip ospf retransmit-interval %u",
7342 params->retransmit_interval);
7343 if (params != IF_DEF_PARAMS (ifp))
7344 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7345 vty_out (vty, "%s", VTY_NEWLINE);
7346 }
7347
7348 /* Transmit Delay print. */
7349 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7350 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7351 {
7352 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7353 if (params != IF_DEF_PARAMS (ifp))
7354 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7355 vty_out (vty, "%s", VTY_NEWLINE);
7356 }
7357
vincentba682532005-09-29 13:52:57 +00007358 /* MTU ignore print. */
7359 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7360 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7361 {
7362 if (params->mtu_ignore == 0)
7363 vty_out (vty, " no ip ospf mtu-ignore");
7364 else
7365 vty_out (vty, " ip ospf mtu-ignore");
7366 if (params != IF_DEF_PARAMS (ifp))
7367 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7368 vty_out (vty, "%s", VTY_NEWLINE);
7369 }
7370
7371
paul718e3742002-12-13 20:15:29 +00007372 while (1)
7373 {
7374 if (rn == NULL)
7375 rn = route_top (IF_OIFS_PARAMS (ifp));
7376 else
7377 rn = route_next (rn);
7378
7379 if (rn == NULL)
7380 break;
7381 params = rn->info;
7382 if (params != NULL)
7383 break;
7384 }
7385 } while (rn);
7386
7387#ifdef HAVE_OPAQUE_LSA
7388 ospf_opaque_config_write_if (vty, ifp);
7389#endif /* HAVE_OPAQUE_LSA */
7390 }
7391
7392 return write;
7393}
7394
paul4dadc292005-05-06 21:37:42 +00007395static int
paul68980082003-03-25 05:07:42 +00007396config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007397{
7398 struct route_node *rn;
7399 u_char buf[INET_ADDRSTRLEN];
7400
7401 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007402 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007403 if (rn->info)
7404 {
7405 struct ospf_network *n = rn->info;
7406
7407 memset (buf, 0, INET_ADDRSTRLEN);
7408
7409 /* Create Area ID string by specified Area ID format. */
7410 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007411 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007412 else
hassoc9e52be2004-09-26 16:09:34 +00007413 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007414 (unsigned long int) ntohl (n->area_id.s_addr));
7415
7416 /* Network print. */
7417 vty_out (vty, " network %s/%d area %s%s",
7418 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7419 buf, VTY_NEWLINE);
7420 }
7421
7422 return 0;
7423}
7424
paul4dadc292005-05-06 21:37:42 +00007425static int
paul68980082003-03-25 05:07:42 +00007426config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007427{
hasso52dc7ee2004-09-23 19:18:23 +00007428 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007429 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007430 u_char buf[INET_ADDRSTRLEN];
7431
7432 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007433 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007434 {
paul718e3742002-12-13 20:15:29 +00007435 struct route_node *rn1;
7436
hassoc9e52be2004-09-26 16:09:34 +00007437 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007438
7439 if (area->auth_type != OSPF_AUTH_NULL)
7440 {
7441 if (area->auth_type == OSPF_AUTH_SIMPLE)
7442 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7443 else
7444 vty_out (vty, " area %s authentication message-digest%s",
7445 buf, VTY_NEWLINE);
7446 }
7447
7448 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7449 vty_out (vty, " area %s shortcut %s%s", buf,
7450 ospf_shortcut_mode_str[area->shortcut_configured],
7451 VTY_NEWLINE);
7452
7453 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007454 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007455 )
7456 {
paulb0a053b2003-06-22 09:04:47 +00007457 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007458 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007459 else if (area->external_routing == OSPF_AREA_NSSA)
7460 {
7461 vty_out (vty, " area %s nssa", buf);
7462 switch (area->NSSATranslatorRole)
7463 {
7464 case OSPF_NSSA_ROLE_NEVER:
7465 vty_out (vty, " translate-never");
7466 break;
7467 case OSPF_NSSA_ROLE_ALWAYS:
7468 vty_out (vty, " translate-always");
7469 break;
7470 case OSPF_NSSA_ROLE_CANDIDATE:
7471 default:
7472 vty_out (vty, " translate-candidate");
7473 }
7474 }
paul718e3742002-12-13 20:15:29 +00007475
7476 if (area->no_summary)
7477 vty_out (vty, " no-summary");
7478
7479 vty_out (vty, "%s", VTY_NEWLINE);
7480
7481 if (area->default_cost != 1)
7482 vty_out (vty, " area %s default-cost %d%s", buf,
7483 area->default_cost, VTY_NEWLINE);
7484 }
7485
7486 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7487 if (rn1->info)
7488 {
7489 struct ospf_area_range *range = rn1->info;
7490
7491 vty_out (vty, " area %s range %s/%d", buf,
7492 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7493
paul6c835672004-10-11 11:00:30 +00007494 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007495 vty_out (vty, " cost %d", range->cost_config);
7496
7497 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7498 vty_out (vty, " not-advertise");
7499
7500 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7501 vty_out (vty, " substitute %s/%d",
7502 inet_ntoa (range->subst_addr), range->subst_masklen);
7503
7504 vty_out (vty, "%s", VTY_NEWLINE);
7505 }
7506
7507 if (EXPORT_NAME (area))
7508 vty_out (vty, " area %s export-list %s%s", buf,
7509 EXPORT_NAME (area), VTY_NEWLINE);
7510
7511 if (IMPORT_NAME (area))
7512 vty_out (vty, " area %s import-list %s%s", buf,
7513 IMPORT_NAME (area), VTY_NEWLINE);
7514
7515 if (PREFIX_NAME_IN (area))
7516 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7517 PREFIX_NAME_IN (area), VTY_NEWLINE);
7518
7519 if (PREFIX_NAME_OUT (area))
7520 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7521 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7522 }
7523
7524 return 0;
7525}
7526
paul4dadc292005-05-06 21:37:42 +00007527static int
paul68980082003-03-25 05:07:42 +00007528config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007529{
7530 struct ospf_nbr_nbma *nbr_nbma;
7531 struct route_node *rn;
7532
7533 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007534 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007535 if ((nbr_nbma = rn->info))
7536 {
7537 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7538
7539 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7540 vty_out (vty, " priority %d", nbr_nbma->priority);
7541
7542 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7543 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7544
7545 vty_out (vty, "%s", VTY_NEWLINE);
7546 }
7547
7548 return 0;
7549}
7550
paul4dadc292005-05-06 21:37:42 +00007551static int
paul68980082003-03-25 05:07:42 +00007552config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007553{
hasso52dc7ee2004-09-23 19:18:23 +00007554 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007555 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007556 u_char buf[INET_ADDRSTRLEN];
7557
7558 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007559 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007560 {
hasso52dc7ee2004-09-23 19:18:23 +00007561 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007562 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007563 struct ospf_interface *oi;
7564
7565 if (vl_data != NULL)
7566 {
7567 memset (buf, 0, INET_ADDRSTRLEN);
7568
7569 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007570 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007571 else
hassoc9e52be2004-09-26 16:09:34 +00007572 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007573 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7574 oi = vl_data->vl_oi;
7575
7576 /* timers */
7577 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7578 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7579 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7580 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7581 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7582 buf,
7583 inet_ntoa (vl_data->vl_peer),
7584 OSPF_IF_PARAM (oi, v_hello),
7585 OSPF_IF_PARAM (oi, retransmit_interval),
7586 OSPF_IF_PARAM (oi, transmit_delay),
7587 OSPF_IF_PARAM (oi, v_wait),
7588 VTY_NEWLINE);
7589 else
7590 vty_out (vty, " area %s virtual-link %s%s", buf,
7591 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7592 /* Auth key */
7593 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7594 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7595 buf,
7596 inet_ntoa (vl_data->vl_peer),
7597 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7598 VTY_NEWLINE);
7599 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007600 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7601 n2, ck))
7602 vty_out (vty, " area %s virtual-link %s"
7603 " message-digest-key %d md5 %s%s",
7604 buf,
7605 inet_ntoa (vl_data->vl_peer),
7606 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007607
7608 }
7609 }
7610
7611 return 0;
7612}
7613
7614
paul4dadc292005-05-06 21:37:42 +00007615static int
paul68980082003-03-25 05:07:42 +00007616config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007617{
7618 int type;
7619
7620 /* redistribute print. */
7621 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7622 if (type != zclient->redist_default && zclient->redist[type])
7623 {
ajsf52d13c2005-10-01 17:38:06 +00007624 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007625 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007626 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007627
paul68980082003-03-25 05:07:42 +00007628 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007629 vty_out (vty, " metric-type 1");
7630
paul020709f2003-04-04 02:44:16 +00007631 if (ROUTEMAP_NAME (ospf, type))
7632 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007633
7634 vty_out (vty, "%s", VTY_NEWLINE);
7635 }
7636
7637 return 0;
7638}
7639
paul4dadc292005-05-06 21:37:42 +00007640static int
paul68980082003-03-25 05:07:42 +00007641config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007642{
paul68980082003-03-25 05:07:42 +00007643 if (ospf->default_metric != -1)
7644 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007645 VTY_NEWLINE);
7646 return 0;
7647}
7648
paul4dadc292005-05-06 21:37:42 +00007649static int
paul68980082003-03-25 05:07:42 +00007650config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007651{
7652 int type;
7653
paul68980082003-03-25 05:07:42 +00007654 if (ospf)
paul718e3742002-12-13 20:15:29 +00007655 {
7656 /* distribute-list print. */
7657 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007658 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007659 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007660 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007661 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007662
7663 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007664 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007665 {
paulc42c1772006-01-10 20:36:49 +00007666 vty_out (vty, " default-information originate");
7667 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7668 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007669
paul68980082003-03-25 05:07:42 +00007670 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007671 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007672 ospf->dmetric[DEFAULT_ROUTE].value);
7673 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007674 vty_out (vty, " metric-type 1");
7675
paul020709f2003-04-04 02:44:16 +00007676 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7677 vty_out (vty, " route-map %s",
7678 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007679
7680 vty_out (vty, "%s", VTY_NEWLINE);
7681 }
7682
7683 }
7684
7685 return 0;
7686}
7687
paul4dadc292005-05-06 21:37:42 +00007688static int
paul68980082003-03-25 05:07:42 +00007689config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007690{
7691 struct route_node *rn;
7692 struct ospf_distance *odistance;
7693
paul68980082003-03-25 05:07:42 +00007694 if (ospf->distance_all)
7695 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007696
paul68980082003-03-25 05:07:42 +00007697 if (ospf->distance_intra
7698 || ospf->distance_inter
7699 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007700 {
7701 vty_out (vty, " distance ospf");
7702
paul68980082003-03-25 05:07:42 +00007703 if (ospf->distance_intra)
7704 vty_out (vty, " intra-area %d", ospf->distance_intra);
7705 if (ospf->distance_inter)
7706 vty_out (vty, " inter-area %d", ospf->distance_inter);
7707 if (ospf->distance_external)
7708 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007709
7710 vty_out (vty, "%s", VTY_NEWLINE);
7711 }
7712
paul68980082003-03-25 05:07:42 +00007713 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007714 if ((odistance = rn->info) != NULL)
7715 {
7716 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7717 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7718 odistance->access_list ? odistance->access_list : "",
7719 VTY_NEWLINE);
7720 }
7721 return 0;
7722}
7723
7724/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007725static int
paul718e3742002-12-13 20:15:29 +00007726ospf_config_write (struct vty *vty)
7727{
paul020709f2003-04-04 02:44:16 +00007728 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007729 struct interface *ifp;
7730 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007731 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007732 int write = 0;
7733
paul020709f2003-04-04 02:44:16 +00007734 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007735 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007736 {
7737 /* `router ospf' print. */
7738 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7739
7740 write++;
7741
paul68980082003-03-25 05:07:42 +00007742 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007743 return write;
7744
7745 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007746 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007747 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007748 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007749
7750 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007751 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007752 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007753 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007754
7755 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007756 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007757 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7758
7759 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007760 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007761 {
7762 vty_out (vty, "! Important: ensure reference bandwidth "
7763 "is consistent across all routers%s", VTY_NEWLINE);
7764 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7765 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7766 }
paul718e3742002-12-13 20:15:29 +00007767
7768 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007769 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007770 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7771 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7772 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007773 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007774 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007775
7776 /* Max-metric router-lsa print */
7777 config_write_stub_router (vty, ospf);
7778
paul718e3742002-12-13 20:15:29 +00007779 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007780 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007781 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007782 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007783
7784 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007785 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007786
7787 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007788 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7789 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7790 vty_out (vty, " passive-interface %s%s",
7791 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007792
paul1eb8ef22005-04-07 07:30:20 +00007793 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7794 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7795 oi->params->passive_interface == OSPF_IF_PASSIVE)
7796 vty_out (vty, " passive-interface %s %s%s",
7797 oi->ifp->name,
7798 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007799
7800 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007801 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007802
7803 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007804 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007805
7806 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007807 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007808
7809 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007810 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007811
7812 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007813 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007814
7815 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007816 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007817
7818 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007819 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007820
7821#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007822 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007823#endif /* HAVE_OPAQUE_LSA */
7824 }
7825
7826 return write;
7827}
7828
7829void
paul4dadc292005-05-06 21:37:42 +00007830ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007831{
7832 /* "show ip ospf" commands. */
7833 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7834 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7835
7836 /* "show ip ospf database" commands. */
7837 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7838 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7839 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7840 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7841 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7842 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7843 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7844 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7845 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7846 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7847 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7848 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7849 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7850 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7851
7852 /* "show ip ospf interface" commands. */
7853 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7854 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7855
7856 /* "show ip ospf neighbor" commands. */
7857 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7858 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7859 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7860 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7861 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7862 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7863 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7864 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7865 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7866 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7867 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7868 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7869 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7870 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7871
7872 /* "show ip ospf route" commands. */
7873 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7874 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007875 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7876 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007877}
7878
7879
7880/* ospfd's interface node. */
7881struct cmd_node interface_node =
7882{
7883 INTERFACE_NODE,
7884 "%s(config-if)# ",
7885 1
7886};
7887
7888/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007889static void
7890ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007891{
7892 /* Install interface node. */
7893 install_node (&interface_node, config_write_interface);
7894
7895 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007896 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007897 install_default (INTERFACE_NODE);
7898
7899 /* "description" commands. */
7900 install_element (INTERFACE_NODE, &interface_desc_cmd);
7901 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7902
7903 /* "ip ospf authentication" commands. */
7904 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7905 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7906 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7907 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7908 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7909 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7910 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7911 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7912 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7913 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7914
7915 /* "ip ospf message-digest-key" commands. */
7916 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7917 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7918 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7919 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7920
7921 /* "ip ospf cost" commands. */
7922 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7923 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7924 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7925 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7926
vincentba682532005-09-29 13:52:57 +00007927 /* "ip ospf mtu-ignore" commands. */
7928 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7929 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7930 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7931 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7932
paul718e3742002-12-13 20:15:29 +00007933 /* "ip ospf dead-interval" commands. */
7934 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7935 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007936 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7937 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007938 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7939 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007940
paul718e3742002-12-13 20:15:29 +00007941 /* "ip ospf hello-interval" commands. */
7942 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7943 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7944 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7945 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7946
7947 /* "ip ospf network" commands. */
7948 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7949 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7950
7951 /* "ip ospf priority" commands. */
7952 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7953 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7954 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7955 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7956
7957 /* "ip ospf retransmit-interval" commands. */
7958 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7959 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7960 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7961 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7962
7963 /* "ip ospf transmit-delay" commands. */
7964 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7965 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7966 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7967 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7968
7969 /* These commands are compatibitliy for previous version. */
7970 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7971 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7972 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7973 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7974 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7975 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7976 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7977 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7978 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7979 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7980 install_element (INTERFACE_NODE, &ospf_network_cmd);
7981 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7982 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7983 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7984 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7985 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7986 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7987 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7988}
7989
7990/* Zebra node structure. */
7991struct cmd_node zebra_node =
7992{
7993 ZEBRA_NODE,
7994 "%s(config-router)#",
7995};
7996
paul4dadc292005-05-06 21:37:42 +00007997static void
7998ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00007999{
8000 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8001 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8002 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8003 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8004 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8005 install_element (OSPF_NODE,
8006 &ospf_redistribute_source_metric_type_routemap_cmd);
8007 install_element (OSPF_NODE,
8008 &ospf_redistribute_source_type_metric_routemap_cmd);
8009 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8010 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8011 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8012
8013 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8014
8015 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8016 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8017
8018 install_element (OSPF_NODE,
8019 &ospf_default_information_originate_metric_type_cmd);
8020 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8021 install_element (OSPF_NODE,
8022 &ospf_default_information_originate_type_metric_cmd);
8023 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8024 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8025 install_element (OSPF_NODE,
8026 &ospf_default_information_originate_always_metric_type_cmd);
8027 install_element (OSPF_NODE,
8028 &ospf_default_information_originate_always_metric_cmd);
8029 install_element (OSPF_NODE,
8030 &ospf_default_information_originate_always_cmd);
8031 install_element (OSPF_NODE,
8032 &ospf_default_information_originate_always_type_metric_cmd);
8033 install_element (OSPF_NODE,
8034 &ospf_default_information_originate_always_type_cmd);
8035
8036 install_element (OSPF_NODE,
8037 &ospf_default_information_originate_metric_type_routemap_cmd);
8038 install_element (OSPF_NODE,
8039 &ospf_default_information_originate_metric_routemap_cmd);
8040 install_element (OSPF_NODE,
8041 &ospf_default_information_originate_routemap_cmd);
8042 install_element (OSPF_NODE,
8043 &ospf_default_information_originate_type_metric_routemap_cmd);
8044 install_element (OSPF_NODE,
8045 &ospf_default_information_originate_type_routemap_cmd);
8046 install_element (OSPF_NODE,
8047 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8048 install_element (OSPF_NODE,
8049 &ospf_default_information_originate_always_metric_routemap_cmd);
8050 install_element (OSPF_NODE,
8051 &ospf_default_information_originate_always_routemap_cmd);
8052 install_element (OSPF_NODE,
8053 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8054 install_element (OSPF_NODE,
8055 &ospf_default_information_originate_always_type_routemap_cmd);
8056
8057 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8058
8059 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8060 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8061 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8062
8063 install_element (OSPF_NODE, &ospf_distance_cmd);
8064 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8065 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8066 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8067 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8068 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8069 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8070 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8071 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8072 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8073 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8074 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8075 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8076 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8077 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8078 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8079 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8080 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8081#if 0
8082 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8083 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8084 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8085 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8086#endif /* 0 */
8087}
8088
8089struct cmd_node ospf_node =
8090{
8091 OSPF_NODE,
8092 "%s(config-router)# ",
8093 1
8094};
8095
8096
8097/* Install OSPF related vty commands. */
8098void
paul4dadc292005-05-06 21:37:42 +00008099ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008100{
8101 /* Install ospf top node. */
8102 install_node (&ospf_node, ospf_config_write);
8103
8104 /* "router ospf" commands. */
8105 install_element (CONFIG_NODE, &router_ospf_cmd);
8106 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8107
8108 install_default (OSPF_NODE);
8109
8110 /* "ospf router-id" commands. */
8111 install_element (OSPF_NODE, &ospf_router_id_cmd);
8112 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008113 install_element (OSPF_NODE, &router_ospf_id_cmd);
8114 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008115
8116 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008117 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8118 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8119 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8120 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008121
8122 /* "ospf abr-type" commands. */
8123 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8124 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8125
8126 /* "ospf rfc1583-compatible" commands. */
8127 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8128 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8129 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8130 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8131
8132 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008133 install_element (OSPF_NODE, &ospf_network_area_cmd);
8134 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008135
8136 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008137 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8138 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8139 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008140
8141 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008142 install_element (OSPF_NODE, &ospf_area_range_cmd);
8143 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8144 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8145 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8146 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8147 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8148 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8149 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8150 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8151 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8152 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008153
8154 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008155 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8156 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008157
paula2c62832003-04-23 17:01:31 +00008158 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8159 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008160
paula2c62832003-04-23 17:01:31 +00008161 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8162 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008163
paula2c62832003-04-23 17:01:31 +00008164 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8165 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008166
paula2c62832003-04-23 17:01:31 +00008167 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8168 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008169
paula2c62832003-04-23 17:01:31 +00008170 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8171 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8172 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008173
paula2c62832003-04-23 17:01:31 +00008174 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8175 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008176
paula2c62832003-04-23 17:01:31 +00008177 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8178 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008179
paula2c62832003-04-23 17:01:31 +00008180 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8181 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8182 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008183
paula2c62832003-04-23 17:01:31 +00008184 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8185 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8186 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008187
8188 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008189 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8190 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8191 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8192 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008193
paul718e3742002-12-13 20:15:29 +00008194 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008195 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8196 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8197 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8198 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8199 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8200 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008201
paula2c62832003-04-23 17:01:31 +00008202 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8203 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008204
paula2c62832003-04-23 17:01:31 +00008205 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8206 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008207
paula2c62832003-04-23 17:01:31 +00008208 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8209 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008210
paula2c62832003-04-23 17:01:31 +00008211 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8212 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008213
paula2c62832003-04-23 17:01:31 +00008214 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8215 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008216
8217 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008218 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8219 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008220 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8221 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8222
paul88d6cf32005-10-29 12:50:09 +00008223 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008224 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8225 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8226 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008227
paul88d6cf32005-10-29 12:50:09 +00008228 /* max-metric commands */
8229 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8230 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8231 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8232 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8233 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8234 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8235
8236 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008237 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8238 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008239
8240 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008241 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8242 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8243 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8244 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8245 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8246 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8247 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8248 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008249
8250 /* Init interface related vty commands. */
8251 ospf_vty_if_init ();
8252
8253 /* Init zebra related vty commands. */
8254 ospf_vty_zebra_init ();
8255}