blob: 0298af2298713808cd0310cb6160c167ff9445db [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
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002059DEFUN (ospf_log_adjacency_changes,
2060 ospf_log_adjacency_changes_cmd,
2061 "log-adjacency-changes",
2062 "Log changes in adjacency state\n")
2063{
2064 struct ospf *ospf = vty->index;
2065
2066 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2067 return CMD_SUCCESS;
2068}
2069
2070DEFUN (ospf_log_adjacency_changes_detail,
2071 ospf_log_adjacency_changes_detail_cmd,
2072 "log-adjacency-changes detail",
2073 "Log changes in adjacency state\n"
2074 "Log all state changes\n")
2075{
2076 struct ospf *ospf = vty->index;
2077
2078 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2079 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2080 return CMD_SUCCESS;
2081}
2082
2083DEFUN (no_ospf_log_adjacency_changes,
2084 no_ospf_log_adjacency_changes_cmd,
2085 "no log-adjacency-changes",
2086 NO_STR
2087 "Log changes in adjacency state\n")
2088{
2089 struct ospf *ospf = vty->index;
2090
2091 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2092 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2093 return CMD_SUCCESS;
2094}
2095
2096DEFUN (no_ospf_log_adjacency_changes_detail,
2097 no_ospf_log_adjacency_changes_detail_cmd,
2098 "no log-adjacency-changes detail",
2099 NO_STR
2100 "Log changes in adjacency state\n"
2101 "Log all state changes\n")
2102{
2103 struct ospf *ospf = vty->index;
2104
2105 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2106 return CMD_SUCCESS;
2107}
2108
paul718e3742002-12-13 20:15:29 +00002109DEFUN (ospf_compatible_rfc1583,
2110 ospf_compatible_rfc1583_cmd,
2111 "compatible rfc1583",
2112 "OSPF compatibility list\n"
2113 "compatible with RFC 1583\n")
2114{
2115 struct ospf *ospf = vty->index;
2116
2117 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2118 {
2119 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002120 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002121 }
2122 return CMD_SUCCESS;
2123}
2124
2125DEFUN (no_ospf_compatible_rfc1583,
2126 no_ospf_compatible_rfc1583_cmd,
2127 "no compatible rfc1583",
2128 NO_STR
2129 "OSPF compatibility list\n"
2130 "compatible with RFC 1583\n")
2131{
2132 struct ospf *ospf = vty->index;
2133
2134 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2135 {
2136 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002137 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002138 }
2139 return CMD_SUCCESS;
2140}
2141
2142ALIAS (ospf_compatible_rfc1583,
2143 ospf_rfc1583_flag_cmd,
2144 "ospf rfc1583compatibility",
2145 "OSPF specific commands\n"
2146 "Enable the RFC1583Compatibility flag\n")
2147
2148ALIAS (no_ospf_compatible_rfc1583,
2149 no_ospf_rfc1583_flag_cmd,
2150 "no ospf rfc1583compatibility",
2151 NO_STR
2152 "OSPF specific commands\n"
2153 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002154
2155static int
2156ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2157 unsigned int hold,
2158 unsigned int max)
2159{
2160 struct ospf *ospf = vty->index;
2161
2162 ospf->spf_delay = delay;
2163 ospf->spf_holdtime = hold;
2164 ospf->spf_max_holdtime = max;
2165
2166 return CMD_SUCCESS;
2167}
paul718e3742002-12-13 20:15:29 +00002168
pauld24f6e22005-10-21 09:23:12 +00002169DEFUN (ospf_timers_throttle_spf,
2170 ospf_timers_throttle_spf_cmd,
2171 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2172 "Adjust routing timers\n"
2173 "Throttling adaptive timer\n"
2174 "OSPF SPF timers\n"
2175 "Delay (msec) from first change received till SPF calculation\n"
2176 "Initial hold time (msec) between consecutive SPF calculations\n"
2177 "Maximum hold time (msec)\n")
2178{
2179 unsigned int delay, hold, max;
2180
2181 if (argc != 3)
2182 {
2183 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2184 return CMD_WARNING;
2185 }
2186
2187 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2188 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2189 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2190
2191 return ospf_timers_spf_set (vty, delay, hold, max);
2192}
2193
2194DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002195 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002196 "timers spf <0-4294967295> <0-4294967295>",
2197 "Adjust routing timers\n"
2198 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002199 "Delay (s) between receiving a change to SPF calculation\n"
2200 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002201{
pauld24f6e22005-10-21 09:23:12 +00002202 unsigned int delay, hold;
2203
2204 if (argc != 2)
2205 {
2206 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2207 return CMD_WARNING;
2208 }
2209
paul4dadc292005-05-06 21:37:42 +00002210 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2211 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002212
2213 /* truncate down the second values if they're greater than 600000ms */
2214 if (delay > (600000 / 1000))
2215 delay = 600000;
2216 else if (delay == 0)
2217 /* 0s delay was probably specified because of lack of ms resolution */
2218 delay = OSPF_SPF_DELAY_DEFAULT;
2219 if (hold > (600000 / 1000))
2220 hold = 600000;
2221
2222 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002223}
2224
pauld24f6e22005-10-21 09:23:12 +00002225DEFUN (no_ospf_timers_throttle_spf,
2226 no_ospf_timers_throttle_spf_cmd,
2227 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002228 NO_STR
2229 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002230 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002231 "OSPF SPF timers\n")
2232{
pauld24f6e22005-10-21 09:23:12 +00002233 return ospf_timers_spf_set (vty,
2234 OSPF_SPF_DELAY_DEFAULT,
2235 OSPF_SPF_HOLDTIME_DEFAULT,
2236 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002237}
2238
pauld24f6e22005-10-21 09:23:12 +00002239ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2240 no_ospf_timers_spf_cmd,
2241 "no timers spf",
2242 NO_STR
2243 "Adjust routing timers\n"
2244 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002245
paula2c62832003-04-23 17:01:31 +00002246DEFUN (ospf_neighbor,
2247 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002248 "neighbor A.B.C.D",
2249 NEIGHBOR_STR
2250 "Neighbor IP address\n")
2251{
2252 struct ospf *ospf = vty->index;
2253 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002254 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2255 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002256
2257 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2258
2259 if (argc > 1)
2260 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2261
2262 if (argc > 2)
2263 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2264
2265 ospf_nbr_nbma_set (ospf, nbr_addr);
2266 if (argc > 1)
2267 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2268 if (argc > 2)
2269 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2270
2271 return CMD_SUCCESS;
2272}
2273
paula2c62832003-04-23 17:01:31 +00002274ALIAS (ospf_neighbor,
2275 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002276 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2277 NEIGHBOR_STR
2278 "Neighbor IP address\n"
2279 "Neighbor Priority\n"
2280 "Priority\n"
2281 "Dead Neighbor Polling interval\n"
2282 "Seconds\n")
2283
paula2c62832003-04-23 17:01:31 +00002284ALIAS (ospf_neighbor,
2285 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002286 "neighbor A.B.C.D priority <0-255>",
2287 NEIGHBOR_STR
2288 "Neighbor IP address\n"
2289 "Neighbor Priority\n"
2290 "Seconds\n")
2291
paula2c62832003-04-23 17:01:31 +00002292DEFUN (ospf_neighbor_poll_interval,
2293 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002294 "neighbor A.B.C.D poll-interval <1-65535>",
2295 NEIGHBOR_STR
2296 "Neighbor IP address\n"
2297 "Dead Neighbor Polling interval\n"
2298 "Seconds\n")
2299{
2300 struct ospf *ospf = vty->index;
2301 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002302 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2303 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002304
2305 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2306
2307 if (argc > 1)
2308 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2309
2310 if (argc > 2)
2311 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2312
2313 ospf_nbr_nbma_set (ospf, nbr_addr);
2314 if (argc > 1)
2315 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2316 if (argc > 2)
2317 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2318
2319 return CMD_SUCCESS;
2320}
2321
paula2c62832003-04-23 17:01:31 +00002322ALIAS (ospf_neighbor_poll_interval,
2323 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002324 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2325 NEIGHBOR_STR
2326 "Neighbor address\n"
2327 "OSPF dead-router polling interval\n"
2328 "Seconds\n"
2329 "OSPF priority of non-broadcast neighbor\n"
2330 "Priority\n")
2331
paula2c62832003-04-23 17:01:31 +00002332DEFUN (no_ospf_neighbor,
2333 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002334 "no neighbor A.B.C.D",
2335 NO_STR
2336 NEIGHBOR_STR
2337 "Neighbor IP address\n")
2338{
2339 struct ospf *ospf = vty->index;
2340 struct in_addr nbr_addr;
2341 int ret;
2342
2343 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2344
2345 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2346
2347 return CMD_SUCCESS;
2348}
2349
paula2c62832003-04-23 17:01:31 +00002350ALIAS (no_ospf_neighbor,
2351 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002352 "no neighbor A.B.C.D priority <0-255>",
2353 NO_STR
2354 NEIGHBOR_STR
2355 "Neighbor IP address\n"
2356 "Neighbor Priority\n"
2357 "Priority\n")
2358
paula2c62832003-04-23 17:01:31 +00002359ALIAS (no_ospf_neighbor,
2360 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002361 "no neighbor A.B.C.D poll-interval <1-65535>",
2362 NO_STR
2363 NEIGHBOR_STR
2364 "Neighbor IP address\n"
2365 "Dead Neighbor Polling interval\n"
2366 "Seconds\n")
2367
paula2c62832003-04-23 17:01:31 +00002368ALIAS (no_ospf_neighbor,
2369 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002370 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2371 NO_STR
2372 NEIGHBOR_STR
2373 "Neighbor IP address\n"
2374 "Neighbor Priority\n"
2375 "Priority\n"
2376 "Dead Neighbor Polling interval\n"
2377 "Seconds\n")
2378
2379
paula2c62832003-04-23 17:01:31 +00002380DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002381 "refresh timer <10-1800>",
2382 "Adjust refresh parameters\n"
2383 "Set refresh timer\n"
2384 "Timer value in seconds\n")
2385{
2386 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002387 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002388
2389 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2390 interval = (interval / 10) * 10;
2391
2392 ospf_timers_refresh_set (ospf, interval);
2393
2394 return CMD_SUCCESS;
2395}
2396
paula2c62832003-04-23 17:01:31 +00002397DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002398 "no refresh timer <10-1800>",
2399 "Adjust refresh parameters\n"
2400 "Unset refresh timer\n"
2401 "Timer value in seconds\n")
2402{
2403 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002404 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002405
2406 if (argc == 1)
2407 {
2408 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2409
2410 if (ospf->lsa_refresh_interval != interval ||
2411 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2412 return CMD_SUCCESS;
2413 }
2414
2415 ospf_timers_refresh_unset (ospf);
2416
2417 return CMD_SUCCESS;
2418}
2419
paula2c62832003-04-23 17:01:31 +00002420ALIAS (no_ospf_refresh_timer,
2421 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002422 "no refresh timer",
2423 "Adjust refresh parameters\n"
2424 "Unset refresh timer\n")
2425
paula2c62832003-04-23 17:01:31 +00002426DEFUN (ospf_auto_cost_reference_bandwidth,
2427 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002428 "auto-cost reference-bandwidth <1-4294967>",
2429 "Calculate OSPF interface cost according to bandwidth\n"
2430 "Use reference bandwidth method to assign OSPF cost\n"
2431 "The reference bandwidth in terms of Mbits per second\n")
2432{
paul68980082003-03-25 05:07:42 +00002433 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002434 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002435 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002436 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002437
2438 refbw = strtol (argv[0], NULL, 10);
2439 if (refbw < 1 || refbw > 4294967)
2440 {
2441 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2442 return CMD_WARNING;
2443 }
2444
2445 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002446 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002447 return CMD_SUCCESS;
2448
paul68980082003-03-25 05:07:42 +00002449 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002450 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2451 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002452
2453 return CMD_SUCCESS;
2454}
2455
paula2c62832003-04-23 17:01:31 +00002456DEFUN (no_ospf_auto_cost_reference_bandwidth,
2457 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002458 "no auto-cost reference-bandwidth",
2459 NO_STR
2460 "Calculate OSPF interface cost according to bandwidth\n"
2461 "Use reference bandwidth method to assign OSPF cost\n")
2462{
paul68980082003-03-25 05:07:42 +00002463 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002464 struct listnode *node, *nnode;
2465 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002466
paul68980082003-03-25 05:07:42 +00002467 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002468 return CMD_SUCCESS;
2469
paul68980082003-03-25 05:07:42 +00002470 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002471 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2472 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2473
paul1eb8ef22005-04-07 07:30:20 +00002474 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2475 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002476
2477 return CMD_SUCCESS;
2478}
2479
hassoeb1ce602004-10-08 08:17:22 +00002480const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002481{
2482 "Unknown",
2483 "Standard (RFC2328)",
2484 "Alternative IBM",
2485 "Alternative Cisco",
2486 "Alternative Shortcut"
2487};
2488
hassoeb1ce602004-10-08 08:17:22 +00002489const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002490{
2491 "Default",
2492 "Enabled",
2493 "Disabled"
2494};
2495
2496
2497
paul4dadc292005-05-06 21:37:42 +00002498static void
paul718e3742002-12-13 20:15:29 +00002499show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2500{
2501 /* Show Area ID. */
2502 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2503
2504 /* Show Area type/mode. */
2505 if (OSPF_IS_AREA_BACKBONE (area))
2506 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2507 else
2508 {
2509 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002510 vty_out (vty, " (Stub%s%s)",
2511 area->no_summary ? ", no summary" : "",
2512 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002513
paulb0a053b2003-06-22 09:04:47 +00002514 else if (area->external_routing == OSPF_AREA_NSSA)
2515 vty_out (vty, " (NSSA%s%s)",
2516 area->no_summary ? ", no summary" : "",
2517 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002518
2519 vty_out (vty, "%s", VTY_NEWLINE);
2520 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002521 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002522 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002523 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002524 }
2525
2526 /* Show number of interfaces. */
2527 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2528 "Active: %d%s", listcount (area->oiflist),
2529 area->act_ints, VTY_NEWLINE);
2530
paul718e3742002-12-13 20:15:29 +00002531 if (area->external_routing == OSPF_AREA_NSSA)
2532 {
2533 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 +00002534 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002535 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2536 VTY_NEWLINE);
2537 else if (area->NSSATranslatorState)
2538 {
2539 vty_out (vty, " We are an ABR and ");
2540 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2541 vty_out (vty, "the NSSA Elected Translator. %s",
2542 VTY_NEWLINE);
2543 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2544 vty_out (vty, "always an NSSA Translator. %s",
2545 VTY_NEWLINE);
2546 }
paul718e3742002-12-13 20:15:29 +00002547 else
paulb0a053b2003-06-22 09:04:47 +00002548 {
2549 vty_out (vty, " We are an ABR, but ");
2550 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2551 vty_out (vty, "not the NSSA Elected Translator. %s",
2552 VTY_NEWLINE);
2553 else
hassoc6b87812004-12-22 13:09:59 +00002554 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002555 VTY_NEWLINE);
2556 }
paul718e3742002-12-13 20:15:29 +00002557 }
paul88d6cf32005-10-29 12:50:09 +00002558 /* Stub-router state for this area */
2559 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2560 {
ajs649654a2005-11-16 20:17:52 +00002561 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002562 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2563 VTY_NEWLINE);
2564 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2565 vty_out (vty, " Administratively activated (indefinitely)%s",
2566 VTY_NEWLINE);
2567 if (area->t_stub_router)
2568 vty_out (vty, " Active from startup, %s remaining%s",
2569 ospf_timer_dump (area->t_stub_router, timebuf,
2570 sizeof(timebuf)), VTY_NEWLINE);
2571 }
2572
paul718e3742002-12-13 20:15:29 +00002573 /* Show number of fully adjacent neighbors. */
2574 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002575 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002576
2577 /* Show authentication type. */
2578 vty_out (vty, " Area has ");
2579 if (area->auth_type == OSPF_AUTH_NULL)
2580 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2581 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2582 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2583 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2584 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2585
2586 if (!OSPF_IS_AREA_BACKBONE (area))
2587 vty_out (vty, " Number of full virtual adjacencies going through"
2588 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2589
2590 /* Show SPF calculation times. */
2591 vty_out (vty, " SPF algorithm executed %d times%s",
2592 area->spf_calculation, VTY_NEWLINE);
2593
2594 /* Show number of LSA. */
2595 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002596 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2597 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2598 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2599 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2600 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2601 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2602 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2603 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2604 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2605 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2606 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2607 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2608 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2609 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2610 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2611#ifdef HAVE_OPAQUE_LSA
2612 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2613 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2614 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2615 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2616 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2617 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2618#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002619 vty_out (vty, "%s", VTY_NEWLINE);
2620}
2621
2622DEFUN (show_ip_ospf,
2623 show_ip_ospf_cmd,
2624 "show ip ospf",
2625 SHOW_STR
2626 IP_STR
2627 "OSPF information\n")
2628{
paul1eb8ef22005-04-07 07:30:20 +00002629 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002630 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002631 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002632 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002633 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002634
2635 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002636 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002637 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002638 {
2639 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2640 return CMD_SUCCESS;
2641 }
2642
2643 /* Show Router ID. */
2644 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002645 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002646 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002647
2648 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002649 if (ospf->t_deferred_shutdown)
2650 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2651 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002652 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002653 /* Show capability. */
2654 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2655 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2656 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002657 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002658 "enabled" : "disabled", VTY_NEWLINE);
2659#ifdef HAVE_OPAQUE_LSA
2660 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002661 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002662 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002663 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002664 " (origination blocked)" : "",
2665 VTY_NEWLINE);
2666#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002667
2668 /* Show stub-router configuration */
2669 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2670 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2671 {
2672 vty_out (vty, " Stub router advertisement is configured%s",
2673 VTY_NEWLINE);
2674 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2675 vty_out (vty, " Enabled for %us after start-up%s",
2676 ospf->stub_router_startup_time, VTY_NEWLINE);
2677 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2678 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2679 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2680 }
2681
paul718e3742002-12-13 20:15:29 +00002682 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002683 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2684 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2685 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2686 " Hold time multiplier is currently %d%s",
2687 ospf->spf_delay, VTY_NEWLINE,
2688 ospf->spf_holdtime, VTY_NEWLINE,
2689 ospf->spf_max_holdtime, VTY_NEWLINE,
2690 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002691 vty_out (vty, " SPF algorithm ");
2692 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2693 {
paulc8c15212005-11-04 12:31:39 +00002694 result = tv_sub (recent_time, ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002695 vty_out (vty, "last executed %s ago%s",
2696 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2697 VTY_NEWLINE);
2698 }
2699 else
2700 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002701 vty_out (vty, " SPF timer %s%s%s",
2702 (ospf->t_spf_calc ? "due in " : "is "),
2703 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2704 VTY_NEWLINE);
2705
paul718e3742002-12-13 20:15:29 +00002706 /* Show refresh parameters. */
2707 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002708 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002709
2710 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002711 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002712 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002713 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002714
paul68980082003-03-25 05:07:42 +00002715 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002716 vty_out (vty, " This router is an ASBR "
2717 "(injecting external routing information)%s", VTY_NEWLINE);
2718
2719 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002720 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2721 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2722 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2723#ifdef HAVE_OPAQUE_LSA
2724 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2725 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2726 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2727#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002728 /* Show number of areas attached. */
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002729 vty_out (vty, " Number of areas attached to this router: %d%s",
2730 listcount (ospf->areas), VTY_NEWLINE);
2731
2732 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2733 {
2734 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2735 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2736 else
2737 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2738 }
2739
2740 vty_out (vty, "%s",VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002741
2742 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002743 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2744 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002745
2746 return CMD_SUCCESS;
2747}
2748
2749
ajsfd651fa2005-03-29 16:08:16 +00002750static void
paul68980082003-03-25 05:07:42 +00002751show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2752 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002753{
ajsfd651fa2005-03-29 16:08:16 +00002754 int is_up;
paul718e3742002-12-13 20:15:29 +00002755 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002756 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002757
paul718e3742002-12-13 20:15:29 +00002758 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002759 vty_out (vty, "%s is %s%s", ifp->name,
2760 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002761 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2762 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2763 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002764
2765 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002766 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002767 {
2768 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2769 return;
2770 }
ajsfd651fa2005-03-29 16:08:16 +00002771 else if (!is_up)
2772 {
2773 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2774 VTY_NEWLINE);
2775 return;
2776 }
2777
paul718e3742002-12-13 20:15:29 +00002778 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2779 {
2780 struct ospf_interface *oi = rn->info;
2781
2782 if (oi == NULL)
2783 continue;
2784
2785 /* Show OSPF interface information. */
2786 vty_out (vty, " Internet Address %s/%d,",
2787 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2788
Paul Jakma9c27ef92006-05-04 07:32:57 +00002789 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2790 {
2791 struct in_addr *dest;
2792 const char *dstr;
2793
2794 if ((ifp->flags & IFF_POINTOPOINT)
2795 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2796 dstr = "Peer";
2797 else
2798 dstr = "Broadcast";
2799
2800 /* For Vlinks, showing the peer address is probably more
2801 * informative than the local interface that is being used
2802 */
2803 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2804 dest = &oi->vl_data->peer_addr;
2805 else
2806 dest = &oi->connected->destination->u.prefix4;
2807
2808 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2809 }
hasso3fb9cd62004-10-19 19:44:43 +00002810
paul718e3742002-12-13 20:15:29 +00002811 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2812 VTY_NEWLINE);
2813
vincentba682532005-09-29 13:52:57 +00002814 vty_out (vty, " MTU mismatch detection:%s%s",
2815 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2816
paul718e3742002-12-13 20:15:29 +00002817 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002818 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002819 oi->output_cost, VTY_NEWLINE);
2820
2821 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2822 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2823 PRIORITY (oi), VTY_NEWLINE);
2824
2825 /* Show DR information. */
2826 if (DR (oi).s_addr == 0)
2827 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2828 else
2829 {
2830 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2831 if (nbr == NULL)
2832 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2833 else
2834 {
2835 vty_out (vty, " Designated Router (ID) %s,",
2836 inet_ntoa (nbr->router_id));
2837 vty_out (vty, " Interface Address %s%s",
2838 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2839 }
2840 }
2841
2842 /* Show BDR information. */
2843 if (BDR (oi).s_addr == 0)
2844 vty_out (vty, " No backup designated router on this network%s",
2845 VTY_NEWLINE);
2846 else
2847 {
2848 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2849 if (nbr == NULL)
2850 vty_out (vty, " No backup designated router on this network%s",
2851 VTY_NEWLINE);
2852 else
2853 {
2854 vty_out (vty, " Backup Designated Router (ID) %s,",
2855 inet_ntoa (nbr->router_id));
2856 vty_out (vty, " Interface Address %s%s",
2857 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2858 }
2859 }
ajsba6454e2005-02-08 15:37:30 +00002860
2861 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002862 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2863 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2864 {
2865 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2866 vty_out (vty, " OSPFAllRouters");
2867 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2868 vty_out (vty, " OSPFDesignatedRouters");
2869 }
2870 else
ajsba6454e2005-02-08 15:37:30 +00002871 vty_out (vty, " <None>");
2872 vty_out (vty, "%s", VTY_NEWLINE);
2873
paul718e3742002-12-13 20:15:29 +00002874 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002875 vty_out (vty, " Hello ");
2876 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2877 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2878 else
2879 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2880 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2881 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002882 OSPF_IF_PARAM (oi, v_wait),
2883 OSPF_IF_PARAM (oi, retransmit_interval),
2884 VTY_NEWLINE);
2885
2886 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002887 {
ajs649654a2005-11-16 20:17:52 +00002888 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002889 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002890 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002891 VTY_NEWLINE);
2892 }
paul718e3742002-12-13 20:15:29 +00002893 else /* OSPF_IF_PASSIVE is set */
2894 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2895
2896 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002897 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002898 VTY_NEWLINE);
2899 }
2900}
2901
2902DEFUN (show_ip_ospf_interface,
2903 show_ip_ospf_interface_cmd,
2904 "show ip ospf interface [INTERFACE]",
2905 SHOW_STR
2906 IP_STR
2907 "OSPF information\n"
2908 "Interface information\n"
2909 "Interface name\n")
2910{
2911 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002912 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002913 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002914
paul020709f2003-04-04 02:44:16 +00002915 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002916 if (ospf == NULL)
2917 {
2918 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2919 return CMD_SUCCESS;
2920 }
paul020709f2003-04-04 02:44:16 +00002921
paul718e3742002-12-13 20:15:29 +00002922 /* Show All Interfaces. */
2923 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002924 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2925 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002926 /* Interface name is specified. */
2927 else
2928 {
2929 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2930 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2931 else
paul68980082003-03-25 05:07:42 +00002932 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002933 }
2934
2935 return CMD_SUCCESS;
2936}
2937
paul4dadc292005-05-06 21:37:42 +00002938static void
pauld24f6e22005-10-21 09:23:12 +00002939show_ip_ospf_neighbour_header (struct vty *vty)
2940{
2941 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2942 VTY_NEWLINE,
2943 "Neighbor ID", "Pri", "State", "Dead Time",
2944 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
2945 VTY_NEWLINE);
2946}
2947
2948static void
paul718e3742002-12-13 20:15:29 +00002949show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2950{
2951 struct route_node *rn;
2952 struct ospf_neighbor *nbr;
2953 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00002954 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002955
2956 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2957 if ((nbr = rn->info))
2958 /* Do not show myself. */
2959 if (nbr != oi->nbr_self)
2960 /* Down state is not shown. */
2961 if (nbr->state != NSM_Down)
2962 {
2963 ospf_nbr_state_message (nbr, msgbuf, 16);
2964
2965 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00002966 vty_out (vty, "%-15s %3d %-15s ",
2967 "-", nbr->priority,
2968 msgbuf);
2969 else
2970 vty_out (vty, "%-15s %3d %-15s ",
2971 inet_ntoa (nbr->router_id), nbr->priority,
2972 msgbuf);
2973
2974 vty_out (vty, "%9s ",
2975 ospf_timer_dump (nbr->t_inactivity, timebuf,
2976 sizeof(timebuf)));
2977
paul718e3742002-12-13 20:15:29 +00002978 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00002979 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00002980 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2981 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2982 VTY_NEWLINE);
2983 }
2984}
2985
2986DEFUN (show_ip_ospf_neighbor,
2987 show_ip_ospf_neighbor_cmd,
2988 "show ip ospf neighbor",
2989 SHOW_STR
2990 IP_STR
2991 "OSPF information\n"
2992 "Neighbor list\n")
2993{
paul020709f2003-04-04 02:44:16 +00002994 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002995 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002996 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002997
paul020709f2003-04-04 02:44:16 +00002998 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002999 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003000 {
3001 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3002 return CMD_SUCCESS;
3003 }
3004
pauld24f6e22005-10-21 09:23:12 +00003005 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003006
paul1eb8ef22005-04-07 07:30:20 +00003007 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3008 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003009
3010 return CMD_SUCCESS;
3011}
3012
3013DEFUN (show_ip_ospf_neighbor_all,
3014 show_ip_ospf_neighbor_all_cmd,
3015 "show ip ospf neighbor all",
3016 SHOW_STR
3017 IP_STR
3018 "OSPF information\n"
3019 "Neighbor list\n"
3020 "include down status neighbor\n")
3021{
paul68980082003-03-25 05:07:42 +00003022 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00003023 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003024 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003025
paul68980082003-03-25 05:07:42 +00003026 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003027 {
3028 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3029 return CMD_SUCCESS;
3030 }
pauld24f6e22005-10-21 09:23:12 +00003031
3032 show_ip_ospf_neighbour_header (vty);
3033
paul1eb8ef22005-04-07 07:30:20 +00003034 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003035 {
hasso52dc7ee2004-09-23 19:18:23 +00003036 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003037 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003038
3039 show_ip_ospf_neighbor_sub (vty, oi);
3040
3041 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003042 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003043 {
paul718e3742002-12-13 20:15:29 +00003044 if (nbr_nbma->nbr == NULL
3045 || nbr_nbma->nbr->state == NSM_Down)
3046 {
pauld24f6e22005-10-21 09:23:12 +00003047 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003048 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003049 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003050 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3051 0, 0, 0, VTY_NEWLINE);
3052 }
3053 }
3054 }
3055
3056 return CMD_SUCCESS;
3057}
3058
3059DEFUN (show_ip_ospf_neighbor_int,
3060 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003061 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003062 SHOW_STR
3063 IP_STR
3064 "OSPF information\n"
3065 "Neighbor list\n"
3066 "Interface name\n")
3067{
paul020709f2003-04-04 02:44:16 +00003068 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003069 struct interface *ifp;
3070 struct route_node *rn;
3071
3072 ifp = if_lookup_by_name (argv[0]);
3073 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003074 {
hassobb5b7552005-08-21 20:01:15 +00003075 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003076 return CMD_WARNING;
3077 }
3078
paul020709f2003-04-04 02:44:16 +00003079 ospf = ospf_lookup ();
3080 if (ospf == NULL)
3081 {
3082 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3083 return CMD_SUCCESS;
3084 }
pauld24f6e22005-10-21 09:23:12 +00003085
3086 show_ip_ospf_neighbour_header (vty);
3087
hassobb5b7552005-08-21 20:01:15 +00003088 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003089 {
hassobb5b7552005-08-21 20:01:15 +00003090 struct ospf_interface *oi = rn->info;
3091
3092 if (oi == NULL)
3093 continue;
3094
paul718e3742002-12-13 20:15:29 +00003095 show_ip_ospf_neighbor_sub (vty, oi);
3096 }
3097
3098 return CMD_SUCCESS;
3099}
3100
paul4dadc292005-05-06 21:37:42 +00003101static void
paul718e3742002-12-13 20:15:29 +00003102show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3103 struct ospf_nbr_nbma *nbr_nbma)
3104{
ajs649654a2005-11-16 20:17:52 +00003105 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003106
3107 /* Show neighbor ID. */
3108 vty_out (vty, " Neighbor %s,", "-");
3109
3110 /* Show interface address. */
3111 vty_out (vty, " interface address %s%s",
3112 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3113 /* Show Area ID. */
3114 vty_out (vty, " In the area %s via interface %s%s",
3115 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3116 /* Show neighbor priority and state. */
3117 vty_out (vty, " Neighbor priority is %d, State is %s,",
3118 nbr_nbma->priority, "Down");
3119 /* Show state changes. */
3120 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3121
3122 /* Show PollInterval */
3123 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3124
3125 /* Show poll-interval timer. */
3126 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003127 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3128 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003129
3130 /* Show poll-interval timer thread. */
3131 vty_out (vty, " Thread Poll Timer %s%s",
3132 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3133}
3134
paul4dadc292005-05-06 21:37:42 +00003135static void
paul718e3742002-12-13 20:15:29 +00003136show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3137 struct ospf_neighbor *nbr)
3138{
ajs649654a2005-11-16 20:17:52 +00003139 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003140
3141 /* Show neighbor ID. */
3142 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3143 vty_out (vty, " Neighbor %s,", "-");
3144 else
3145 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3146
3147 /* Show interface address. */
3148 vty_out (vty, " interface address %s%s",
3149 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3150 /* Show Area ID. */
3151 vty_out (vty, " In the area %s via interface %s%s",
3152 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3153 /* Show neighbor priority and state. */
3154 vty_out (vty, " Neighbor priority is %d, State is %s,",
3155 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3156 /* Show state changes. */
3157 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3158
3159 /* Show Designated Rotuer ID. */
3160 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3161 /* Show Backup Designated Rotuer ID. */
3162 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3163 /* Show options. */
3164 vty_out (vty, " Options %d %s%s", nbr->options,
3165 ospf_options_dump (nbr->options), VTY_NEWLINE);
3166 /* Show Router Dead interval timer. */
3167 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003168 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3169 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003170 /* Show Database Summary list. */
3171 vty_out (vty, " Database Summary List %d%s",
3172 ospf_db_summary_count (nbr), VTY_NEWLINE);
3173 /* Show Link State Request list. */
3174 vty_out (vty, " Link State Request List %ld%s",
3175 ospf_ls_request_count (nbr), VTY_NEWLINE);
3176 /* Show Link State Retransmission list. */
3177 vty_out (vty, " Link State Retransmission List %ld%s",
3178 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3179 /* Show inactivity timer thread. */
3180 vty_out (vty, " Thread Inactivity Timer %s%s",
3181 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3182 /* Show Database Description retransmission thread. */
3183 vty_out (vty, " Thread Database Description Retransmision %s%s",
3184 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3185 /* Show Link State Request Retransmission thread. */
3186 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3187 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3188 /* Show Link State Update Retransmission thread. */
3189 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3190 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3191}
3192
3193DEFUN (show_ip_ospf_neighbor_id,
3194 show_ip_ospf_neighbor_id_cmd,
3195 "show ip ospf neighbor A.B.C.D",
3196 SHOW_STR
3197 IP_STR
3198 "OSPF information\n"
3199 "Neighbor list\n"
3200 "Neighbor ID\n")
3201{
paul020709f2003-04-04 02:44:16 +00003202 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003203 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003204 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003205 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003206 struct in_addr router_id;
3207 int ret;
3208
3209 ret = inet_aton (argv[0], &router_id);
3210 if (!ret)
3211 {
3212 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3213 return CMD_WARNING;
3214 }
3215
paul020709f2003-04-04 02:44:16 +00003216 ospf = ospf_lookup ();
3217 if (ospf == NULL)
3218 {
3219 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3220 return CMD_SUCCESS;
3221 }
3222
paul1eb8ef22005-04-07 07:30:20 +00003223 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3224 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3225 {
3226 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3227 return CMD_SUCCESS;
3228 }
paul718e3742002-12-13 20:15:29 +00003229
3230 /* Nothing to show. */
3231 return CMD_SUCCESS;
3232}
3233
3234DEFUN (show_ip_ospf_neighbor_detail,
3235 show_ip_ospf_neighbor_detail_cmd,
3236 "show ip ospf neighbor detail",
3237 SHOW_STR
3238 IP_STR
3239 "OSPF information\n"
3240 "Neighbor list\n"
3241 "detail of all neighbors\n")
3242{
paul020709f2003-04-04 02:44:16 +00003243 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003244 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003245 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003246
paul020709f2003-04-04 02:44:16 +00003247 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003248 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003249 {
3250 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3251 return CMD_SUCCESS;
3252 }
paul718e3742002-12-13 20:15:29 +00003253
paul1eb8ef22005-04-07 07:30:20 +00003254 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003255 {
paul718e3742002-12-13 20:15:29 +00003256 struct route_node *rn;
3257 struct ospf_neighbor *nbr;
3258
3259 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3260 if ((nbr = rn->info))
3261 if (nbr != oi->nbr_self)
3262 if (nbr->state != NSM_Down)
3263 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3264 }
3265
3266 return CMD_SUCCESS;
3267}
3268
3269DEFUN (show_ip_ospf_neighbor_detail_all,
3270 show_ip_ospf_neighbor_detail_all_cmd,
3271 "show ip ospf neighbor detail all",
3272 SHOW_STR
3273 IP_STR
3274 "OSPF information\n"
3275 "Neighbor list\n"
3276 "detail of all neighbors\n"
3277 "include down status neighbor\n")
3278{
paul020709f2003-04-04 02:44:16 +00003279 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003280 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003281 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003282
paul020709f2003-04-04 02:44:16 +00003283 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003284 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003285 {
3286 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3287 return CMD_SUCCESS;
3288 }
paul718e3742002-12-13 20:15:29 +00003289
paul1eb8ef22005-04-07 07:30:20 +00003290 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003291 {
paul718e3742002-12-13 20:15:29 +00003292 struct route_node *rn;
3293 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003294 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003295
3296 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3297 if ((nbr = rn->info))
3298 if (nbr != oi->nbr_self)
3299 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3300 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3301
3302 if (oi->type == OSPF_IFTYPE_NBMA)
3303 {
hasso52dc7ee2004-09-23 19:18:23 +00003304 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003305
paul1eb8ef22005-04-07 07:30:20 +00003306 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3307 if (nbr_nbma->nbr == NULL
3308 || nbr_nbma->nbr->state == NSM_Down)
3309 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003310 }
3311 }
3312
3313 return CMD_SUCCESS;
3314}
3315
3316DEFUN (show_ip_ospf_neighbor_int_detail,
3317 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003318 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003319 SHOW_STR
3320 IP_STR
3321 "OSPF information\n"
3322 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003323 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003324 "detail of all neighbors")
3325{
paul020709f2003-04-04 02:44:16 +00003326 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003327 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003328 struct interface *ifp;
3329 struct route_node *rn, *nrn;
3330 struct ospf_neighbor *nbr;
3331
3332 ifp = if_lookup_by_name (argv[0]);
3333 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003334 {
hassobb5b7552005-08-21 20:01:15 +00003335 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003336 return CMD_WARNING;
3337 }
3338
paul020709f2003-04-04 02:44:16 +00003339 ospf = ospf_lookup ();
3340 if (ospf == NULL)
3341 {
3342 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3343 return CMD_SUCCESS;
3344 }
paul68980082003-03-25 05:07:42 +00003345
paul718e3742002-12-13 20:15:29 +00003346
hassobb5b7552005-08-21 20:01:15 +00003347 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3348 if ((oi = rn->info))
3349 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3350 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003351 if (nbr != oi->nbr_self)
3352 if (nbr->state != NSM_Down)
3353 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003354
3355 return CMD_SUCCESS;
3356}
3357
3358
3359/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003360static int
paul020709f2003-04-04 02:44:16 +00003361show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003362{
paul718e3742002-12-13 20:15:29 +00003363 struct router_lsa *rl;
3364 struct summary_lsa *sl;
3365 struct as_external_lsa *asel;
3366 struct prefix_ipv4 p;
3367
3368 if (lsa != NULL)
3369 /* If self option is set, check LSA self flag. */
3370 if (self == 0 || IS_LSA_SELF (lsa))
3371 {
3372 /* LSA common part show. */
3373 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3374 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3375 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3376 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3377 /* LSA specific part show. */
3378 switch (lsa->data->type)
3379 {
3380 case OSPF_ROUTER_LSA:
3381 rl = (struct router_lsa *) lsa->data;
3382 vty_out (vty, " %-d", ntohs (rl->links));
3383 break;
3384 case OSPF_SUMMARY_LSA:
3385 sl = (struct summary_lsa *) lsa->data;
3386
3387 p.family = AF_INET;
3388 p.prefix = sl->header.id;
3389 p.prefixlen = ip_masklen (sl->mask);
3390 apply_mask_ipv4 (&p);
3391
3392 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3393 break;
3394 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003395 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003396 asel = (struct as_external_lsa *) lsa->data;
3397
3398 p.family = AF_INET;
3399 p.prefix = asel->header.id;
3400 p.prefixlen = ip_masklen (asel->mask);
3401 apply_mask_ipv4 (&p);
3402
3403 vty_out (vty, " %s %s/%d [0x%lx]",
3404 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3405 inet_ntoa (p.prefix), p.prefixlen,
3406 (u_long)ntohl (asel->e[0].route_tag));
3407 break;
3408 case OSPF_NETWORK_LSA:
3409 case OSPF_ASBR_SUMMARY_LSA:
3410#ifdef HAVE_OPAQUE_LSA
3411 case OSPF_OPAQUE_LINK_LSA:
3412 case OSPF_OPAQUE_AREA_LSA:
3413 case OSPF_OPAQUE_AS_LSA:
3414#endif /* HAVE_OPAQUE_LSA */
3415 default:
3416 break;
3417 }
3418 vty_out (vty, VTY_NEWLINE);
3419 }
3420
3421 return 0;
3422}
3423
hassoeb1ce602004-10-08 08:17:22 +00003424const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003425{
3426 "unknown",
3427 "Router Link States",
3428 "Net Link States",
3429 "Summary Link States",
3430 "ASBR-Summary Link States",
3431 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003432 "Group Membership LSA",
3433 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003434#ifdef HAVE_OPAQUE_LSA
3435 "Type-8 LSA",
3436 "Link-Local Opaque-LSA",
3437 "Area-Local Opaque-LSA",
3438 "AS-external Opaque-LSA",
3439#endif /* HAVE_OPAQUE_LSA */
3440};
3441
3442#define SHOW_OSPF_COMMON_HEADER \
3443 "Link ID ADV Router Age Seq# CkSum"
3444
hassoeb1ce602004-10-08 08:17:22 +00003445const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003446{
3447 "",
3448 "Link ID ADV Router Age Seq# CkSum Link count",
3449 "Link ID ADV Router Age Seq# CkSum",
3450 "Link ID ADV Router Age Seq# CkSum Route",
3451 "Link ID ADV Router Age Seq# CkSum",
3452 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003453 " --- header for Group Member ----",
3454 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003455#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003456 " --- type-8 ---",
3457 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3458 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3459 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3460#endif /* HAVE_OPAQUE_LSA */
3461};
3462
hassoeb1ce602004-10-08 08:17:22 +00003463const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003464{
3465 "Self-originated",
3466 "Checked",
3467 "Received",
3468 "Approved",
3469 "Discard",
paul4957f492003-06-27 01:28:45 +00003470 "Translated",
paul4957f492003-06-27 01:28:45 +00003471};
3472
paul4dadc292005-05-06 21:37:42 +00003473static void
paul718e3742002-12-13 20:15:29 +00003474show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3475{
3476 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003477
paul718e3742002-12-13 20:15:29 +00003478 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003479 vty_out (vty, " Options: 0x%-2x : %s%s",
3480 lsa->data->options,
3481 ospf_options_dump(lsa->data->options),
3482 VTY_NEWLINE);
3483 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003484 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003485 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3486 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003487
3488 if (lsa->data->type == OSPF_ROUTER_LSA)
3489 {
3490 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3491
3492 if (rlsa->flags)
3493 vty_out (vty, " :%s%s%s%s",
3494 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3495 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3496 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3497 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3498
3499 vty_out (vty, "%s", VTY_NEWLINE);
3500 }
3501 vty_out (vty, " LS Type: %s%s",
3502 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3503 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3504 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3505 vty_out (vty, " Advertising Router: %s%s",
3506 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3507 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3508 VTY_NEWLINE);
3509 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3510 VTY_NEWLINE);
3511 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3512}
3513
hassoeb1ce602004-10-08 08:17:22 +00003514const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003515{
3516 "(null)",
3517 "another Router (point-to-point)",
3518 "a Transit Network",
3519 "Stub Network",
3520 "a Virtual Link",
3521};
3522
hassoeb1ce602004-10-08 08:17:22 +00003523const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003524{
3525 "(null)",
3526 "Neighboring Router ID",
3527 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003528 "Net",
paul718e3742002-12-13 20:15:29 +00003529 "Neighboring Router ID",
3530};
3531
hassoeb1ce602004-10-08 08:17:22 +00003532const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003533{
3534 "(null)",
3535 "Router Interface address",
3536 "Router Interface address",
3537 "Network Mask",
3538 "Router Interface address",
3539};
3540
3541/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003542static void
paul718e3742002-12-13 20:15:29 +00003543show_ip_ospf_database_router_links (struct vty *vty,
3544 struct router_lsa *rl)
3545{
3546 int len, i, type;
3547
3548 len = ntohs (rl->header.length) - 4;
3549 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3550 {
3551 type = rl->link[i].type;
3552
3553 vty_out (vty, " Link connected to: %s%s",
3554 link_type_desc[type], VTY_NEWLINE);
3555 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3556 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3557 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3558 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3559 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3560 vty_out (vty, " TOS 0 Metric: %d%s",
3561 ntohs (rl->link[i].metric), VTY_NEWLINE);
3562 vty_out (vty, "%s", VTY_NEWLINE);
3563 }
3564}
3565
3566/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003567static int
paul718e3742002-12-13 20:15:29 +00003568show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3569{
3570 if (lsa != NULL)
3571 {
3572 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3573
3574 show_ip_ospf_database_header (vty, lsa);
3575
3576 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3577 VTY_NEWLINE, VTY_NEWLINE);
3578
3579 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003580 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003581 }
3582
3583 return 0;
3584}
3585
3586/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003587static int
paul718e3742002-12-13 20:15:29 +00003588show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3589{
3590 int length, i;
3591
3592 if (lsa != NULL)
3593 {
3594 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3595
3596 show_ip_ospf_database_header (vty, lsa);
3597
3598 vty_out (vty, " Network Mask: /%d%s",
3599 ip_masklen (nl->mask), VTY_NEWLINE);
3600
3601 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3602
3603 for (i = 0; length > 0; i++, length -= 4)
3604 vty_out (vty, " Attached Router: %s%s",
3605 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3606
3607 vty_out (vty, "%s", VTY_NEWLINE);
3608 }
3609
3610 return 0;
3611}
3612
3613/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003614static int
paul718e3742002-12-13 20:15:29 +00003615show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3616{
3617 if (lsa != NULL)
3618 {
3619 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3620
3621 show_ip_ospf_database_header (vty, lsa);
3622
3623 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3624 VTY_NEWLINE);
3625 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3626 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003627 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003628 }
3629
3630 return 0;
3631}
3632
3633/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003634static int
paul718e3742002-12-13 20:15:29 +00003635show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3636{
3637 if (lsa != NULL)
3638 {
3639 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3640
3641 show_ip_ospf_database_header (vty, lsa);
3642
3643 vty_out (vty, " Network Mask: /%d%s",
3644 ip_masklen (sl->mask), VTY_NEWLINE);
3645 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3646 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003647 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003648 }
3649
3650 return 0;
3651}
3652
3653/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003654static int
paul718e3742002-12-13 20:15:29 +00003655show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3656{
3657 if (lsa != NULL)
3658 {
3659 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3660
3661 show_ip_ospf_database_header (vty, lsa);
3662
3663 vty_out (vty, " Network Mask: /%d%s",
3664 ip_masklen (al->mask), VTY_NEWLINE);
3665 vty_out (vty, " Metric Type: %s%s",
3666 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3667 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3668 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3669 vty_out (vty, " Metric: %d%s",
3670 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3671 vty_out (vty, " Forward Address: %s%s",
3672 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3673
3674 vty_out (vty, " External Route Tag: %lu%s%s",
3675 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3676 }
3677
3678 return 0;
3679}
3680
ajs2a42e282004-12-08 18:43:03 +00003681/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003682static int
paul718e3742002-12-13 20:15:29 +00003683show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3684{
3685 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3686
3687 /* show_ip_ospf_database_header (vty, lsa); */
3688
ajs2a42e282004-12-08 18:43:03 +00003689 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003690 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003691 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003692 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3693 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003694 zlog_debug( " TOS: 0%s", "\n");
3695 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003696 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003697 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003698 inet_ntoa (al->e[0].fwd_addr), "\n");
3699
ajs2a42e282004-12-08 18:43:03 +00003700 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003701 ntohl (al->e[0].route_tag), "\n", "\n");
3702
3703 return 0;
3704}
3705
3706/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003707static int
paul718e3742002-12-13 20:15:29 +00003708show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3709{
3710 if (lsa != NULL)
3711 {
3712 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3713
3714 show_ip_ospf_database_header (vty, lsa);
3715
3716 vty_out (vty, " Network Mask: /%d%s",
3717 ip_masklen (al->mask), VTY_NEWLINE);
3718 vty_out (vty, " Metric Type: %s%s",
3719 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3720 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3721 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3722 vty_out (vty, " Metric: %d%s",
3723 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3724 vty_out (vty, " NSSA: Forward Address: %s%s",
3725 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3726
3727 vty_out (vty, " External Route Tag: %u%s%s",
3728 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3729 }
3730
3731 return 0;
3732}
3733
paul4dadc292005-05-06 21:37:42 +00003734static int
paul718e3742002-12-13 20:15:29 +00003735show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3736{
3737 return 0;
3738}
3739
3740#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003741static int
paul718e3742002-12-13 20:15:29 +00003742show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3743{
3744 if (lsa != NULL)
3745 {
3746 show_ip_ospf_database_header (vty, lsa);
3747 show_opaque_info_detail (vty, lsa);
3748
3749 vty_out (vty, "%s", VTY_NEWLINE);
3750 }
3751 return 0;
3752}
3753#endif /* HAVE_OPAQUE_LSA */
3754
3755int (*show_function[])(struct vty *, struct ospf_lsa *) =
3756{
3757 NULL,
3758 show_router_lsa_detail,
3759 show_network_lsa_detail,
3760 show_summary_lsa_detail,
3761 show_summary_asbr_lsa_detail,
3762 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003763 show_func_dummy,
3764 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003765#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003766 NULL, /* type-8 */
3767 show_opaque_lsa_detail,
3768 show_opaque_lsa_detail,
3769 show_opaque_lsa_detail,
3770#endif /* HAVE_OPAQUE_LSA */
3771};
3772
paul4dadc292005-05-06 21:37:42 +00003773static void
paul718e3742002-12-13 20:15:29 +00003774show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3775 struct in_addr *adv_router)
3776{
3777 memset (lp, 0, sizeof (struct prefix_ls));
3778 lp->family = 0;
3779 if (id == NULL)
3780 lp->prefixlen = 0;
3781 else if (adv_router == NULL)
3782 {
3783 lp->prefixlen = 32;
3784 lp->id = *id;
3785 }
3786 else
3787 {
3788 lp->prefixlen = 64;
3789 lp->id = *id;
3790 lp->adv_router = *adv_router;
3791 }
3792}
3793
paul4dadc292005-05-06 21:37:42 +00003794static void
paul718e3742002-12-13 20:15:29 +00003795show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3796 struct in_addr *id, struct in_addr *adv_router)
3797{
3798 struct prefix_ls lp;
3799 struct route_node *rn, *start;
3800 struct ospf_lsa *lsa;
3801
3802 show_lsa_prefix_set (vty, &lp, id, adv_router);
3803 start = route_node_get (rt, (struct prefix *) &lp);
3804 if (start)
3805 {
3806 route_lock_node (start);
3807 for (rn = start; rn; rn = route_next_until (rn, start))
3808 if ((lsa = rn->info))
3809 {
paul718e3742002-12-13 20:15:29 +00003810 if (show_function[lsa->data->type] != NULL)
3811 show_function[lsa->data->type] (vty, lsa);
3812 }
3813 route_unlock_node (start);
3814 }
3815}
3816
3817/* Show detail LSA information
3818 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003819static void
paul020709f2003-04-04 02:44:16 +00003820show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003821 struct in_addr *id, struct in_addr *adv_router)
3822{
hasso52dc7ee2004-09-23 19:18:23 +00003823 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003824 struct ospf_area *area;
3825
paul718e3742002-12-13 20:15:29 +00003826 switch (type)
3827 {
3828 case OSPF_AS_EXTERNAL_LSA:
3829#ifdef HAVE_OPAQUE_LSA
3830 case OSPF_OPAQUE_AS_LSA:
3831#endif /* HAVE_OPAQUE_LSA */
3832 vty_out (vty, " %s %s%s",
3833 show_database_desc[type],
3834 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003835 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003836 break;
3837 default:
paul1eb8ef22005-04-07 07:30:20 +00003838 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003839 {
paul718e3742002-12-13 20:15:29 +00003840 vty_out (vty, "%s %s (Area %s)%s%s",
3841 VTY_NEWLINE, show_database_desc[type],
3842 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3843 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3844 }
3845 break;
3846 }
3847}
3848
paul4dadc292005-05-06 21:37:42 +00003849static void
paul718e3742002-12-13 20:15:29 +00003850show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3851 struct in_addr *adv_router)
3852{
3853 struct route_node *rn;
3854 struct ospf_lsa *lsa;
3855
3856 for (rn = route_top (rt); rn; rn = route_next (rn))
3857 if ((lsa = rn->info))
3858 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3859 {
paul718e3742002-12-13 20:15:29 +00003860 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3861 continue;
paul718e3742002-12-13 20:15:29 +00003862 if (show_function[lsa->data->type] != NULL)
3863 show_function[lsa->data->type] (vty, lsa);
3864 }
3865}
3866
3867/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003868static void
paul020709f2003-04-04 02:44:16 +00003869show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003870 struct in_addr *adv_router)
3871{
hasso52dc7ee2004-09-23 19:18:23 +00003872 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003873 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003874
3875 switch (type)
3876 {
3877 case OSPF_AS_EXTERNAL_LSA:
3878#ifdef HAVE_OPAQUE_LSA
3879 case OSPF_OPAQUE_AS_LSA:
3880#endif /* HAVE_OPAQUE_LSA */
3881 vty_out (vty, " %s %s%s",
3882 show_database_desc[type],
3883 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003884 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003885 adv_router);
3886 break;
3887 default:
paul1eb8ef22005-04-07 07:30:20 +00003888 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003889 {
paul718e3742002-12-13 20:15:29 +00003890 vty_out (vty, "%s %s (Area %s)%s%s",
3891 VTY_NEWLINE, show_database_desc[type],
3892 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3893 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3894 adv_router);
3895 }
3896 break;
3897 }
3898}
3899
paul4dadc292005-05-06 21:37:42 +00003900static void
paul020709f2003-04-04 02:44:16 +00003901show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003902{
paul020709f2003-04-04 02:44:16 +00003903 struct ospf_lsa *lsa;
3904 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003905 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003906 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003907 int type;
3908
paul1eb8ef22005-04-07 07:30:20 +00003909 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003910 {
paul718e3742002-12-13 20:15:29 +00003911 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3912 {
3913 switch (type)
3914 {
3915 case OSPF_AS_EXTERNAL_LSA:
3916#ifdef HAVE_OPAQUE_LSA
3917 case OSPF_OPAQUE_AS_LSA:
3918#endif /* HAVE_OPAQUE_LSA */
3919 continue;
3920 default:
3921 break;
3922 }
3923 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3924 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3925 {
3926 vty_out (vty, " %s (Area %s)%s%s",
3927 show_database_desc[type],
3928 ospf_area_desc_string (area),
3929 VTY_NEWLINE, VTY_NEWLINE);
3930 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3931
paul020709f2003-04-04 02:44:16 +00003932 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3933 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003934
3935 vty_out (vty, "%s", VTY_NEWLINE);
3936 }
3937 }
3938 }
3939
3940 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3941 {
3942 switch (type)
3943 {
3944 case OSPF_AS_EXTERNAL_LSA:
3945#ifdef HAVE_OPAQUE_LSA
3946 case OSPF_OPAQUE_AS_LSA:
3947#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00003948 break;
paul718e3742002-12-13 20:15:29 +00003949 default:
3950 continue;
3951 }
paul68980082003-03-25 05:07:42 +00003952 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3953 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003954 {
3955 vty_out (vty, " %s%s%s",
3956 show_database_desc[type],
3957 VTY_NEWLINE, VTY_NEWLINE);
3958 vty_out (vty, "%s%s", show_database_header[type],
3959 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003960
3961 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3962 show_lsa_summary (vty, lsa, self);
3963
paul718e3742002-12-13 20:15:29 +00003964 vty_out (vty, "%s", VTY_NEWLINE);
3965 }
3966 }
3967
3968 vty_out (vty, "%s", VTY_NEWLINE);
3969}
3970
paul4dadc292005-05-06 21:37:42 +00003971static void
paul020709f2003-04-04 02:44:16 +00003972show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003973{
hasso52dc7ee2004-09-23 19:18:23 +00003974 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003975 struct ospf_lsa *lsa;
3976
3977 vty_out (vty, "%s MaxAge Link States:%s%s",
3978 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3979
paul1eb8ef22005-04-07 07:30:20 +00003980 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3981 {
3982 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3983 vty_out (vty, "Link State ID: %s%s",
3984 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3985 vty_out (vty, "Advertising Router: %s%s",
3986 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3987 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3988 vty_out (vty, "%s", VTY_NEWLINE);
3989 }
paul718e3742002-12-13 20:15:29 +00003990}
3991
paul718e3742002-12-13 20:15:29 +00003992#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3993#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003994
3995#ifdef HAVE_OPAQUE_LSA
3996#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3997#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3998#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3999#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4000#else /* HAVE_OPAQUE_LSA */
4001#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4002#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4003#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4004#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4005#endif /* HAVE_OPAQUE_LSA */
4006
4007#define OSPF_LSA_TYPES_CMD_STR \
4008 "asbr-summary|external|network|router|summary" \
4009 OSPF_LSA_TYPE_NSSA_CMD_STR \
4010 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4011
4012#define OSPF_LSA_TYPES_DESC \
4013 "ASBR summary link states\n" \
4014 "External link states\n" \
4015 "Network link states\n" \
4016 "Router link states\n" \
4017 "Network summary link states\n" \
4018 OSPF_LSA_TYPE_NSSA_DESC \
4019 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4020 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4021 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4022
4023DEFUN (show_ip_ospf_database,
4024 show_ip_ospf_database_cmd,
4025 "show ip ospf database",
4026 SHOW_STR
4027 IP_STR
4028 "OSPF information\n"
4029 "Database summary\n")
4030{
paul020709f2003-04-04 02:44:16 +00004031 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004032 int type, ret;
4033 struct in_addr id, adv_router;
4034
paul020709f2003-04-04 02:44:16 +00004035 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004036 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004037 {
4038 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4039 return CMD_SUCCESS;
4040 }
paul718e3742002-12-13 20:15:29 +00004041
4042 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004043 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004044
4045 /* Show all LSA. */
4046 if (argc == 0)
4047 {
paul020709f2003-04-04 02:44:16 +00004048 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004049 return CMD_SUCCESS;
4050 }
4051
4052 /* Set database type to show. */
4053 if (strncmp (argv[0], "r", 1) == 0)
4054 type = OSPF_ROUTER_LSA;
4055 else if (strncmp (argv[0], "ne", 2) == 0)
4056 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004057 else if (strncmp (argv[0], "ns", 2) == 0)
4058 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004059 else if (strncmp (argv[0], "su", 2) == 0)
4060 type = OSPF_SUMMARY_LSA;
4061 else if (strncmp (argv[0], "a", 1) == 0)
4062 type = OSPF_ASBR_SUMMARY_LSA;
4063 else if (strncmp (argv[0], "e", 1) == 0)
4064 type = OSPF_AS_EXTERNAL_LSA;
4065 else if (strncmp (argv[0], "se", 2) == 0)
4066 {
paul020709f2003-04-04 02:44:16 +00004067 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004068 return CMD_SUCCESS;
4069 }
4070 else if (strncmp (argv[0], "m", 1) == 0)
4071 {
paul020709f2003-04-04 02:44:16 +00004072 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004073 return CMD_SUCCESS;
4074 }
4075#ifdef HAVE_OPAQUE_LSA
4076 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4077 type = OSPF_OPAQUE_LINK_LSA;
4078 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4079 type = OSPF_OPAQUE_AREA_LSA;
4080 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4081 type = OSPF_OPAQUE_AS_LSA;
4082#endif /* HAVE_OPAQUE_LSA */
4083 else
4084 return CMD_WARNING;
4085
4086 /* `show ip ospf database LSA'. */
4087 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004088 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004089 else if (argc >= 2)
4090 {
4091 ret = inet_aton (argv[1], &id);
4092 if (!ret)
4093 return CMD_WARNING;
4094
4095 /* `show ip ospf database LSA ID'. */
4096 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004097 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004098 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4099 else if (argc == 3)
4100 {
4101 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004102 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004103 else
4104 {
4105 ret = inet_aton (argv[2], &adv_router);
4106 if (!ret)
4107 return CMD_WARNING;
4108 }
paul020709f2003-04-04 02:44:16 +00004109 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004110 }
4111 }
4112
4113 return CMD_SUCCESS;
4114}
4115
4116ALIAS (show_ip_ospf_database,
4117 show_ip_ospf_database_type_cmd,
4118 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4119 SHOW_STR
4120 IP_STR
4121 "OSPF information\n"
4122 "Database summary\n"
4123 OSPF_LSA_TYPES_DESC
4124 "LSAs in MaxAge list\n"
4125 "Self-originated link states\n")
4126
4127ALIAS (show_ip_ospf_database,
4128 show_ip_ospf_database_type_id_cmd,
4129 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4130 SHOW_STR
4131 IP_STR
4132 "OSPF information\n"
4133 "Database summary\n"
4134 OSPF_LSA_TYPES_DESC
4135 "Link State ID (as an IP address)\n")
4136
4137ALIAS (show_ip_ospf_database,
4138 show_ip_ospf_database_type_id_adv_router_cmd,
4139 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4140 SHOW_STR
4141 IP_STR
4142 "OSPF information\n"
4143 "Database summary\n"
4144 OSPF_LSA_TYPES_DESC
4145 "Link State ID (as an IP address)\n"
4146 "Advertising Router link states\n"
4147 "Advertising Router (as an IP address)\n")
4148
4149ALIAS (show_ip_ospf_database,
4150 show_ip_ospf_database_type_id_self_cmd,
4151 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4152 SHOW_STR
4153 IP_STR
4154 "OSPF information\n"
4155 "Database summary\n"
4156 OSPF_LSA_TYPES_DESC
4157 "Link State ID (as an IP address)\n"
4158 "Self-originated link states\n"
4159 "\n")
4160
4161DEFUN (show_ip_ospf_database_type_adv_router,
4162 show_ip_ospf_database_type_adv_router_cmd,
4163 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4164 SHOW_STR
4165 IP_STR
4166 "OSPF information\n"
4167 "Database summary\n"
4168 OSPF_LSA_TYPES_DESC
4169 "Advertising Router link states\n"
4170 "Advertising Router (as an IP address)\n")
4171{
paul020709f2003-04-04 02:44:16 +00004172 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004173 int type, ret;
4174 struct in_addr adv_router;
4175
paul020709f2003-04-04 02:44:16 +00004176 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004177 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004178 {
4179 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4180 return CMD_SUCCESS;
4181 }
paul718e3742002-12-13 20:15:29 +00004182
4183 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004184 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004185
4186 if (argc != 2)
4187 return CMD_WARNING;
4188
4189 /* Set database type to show. */
4190 if (strncmp (argv[0], "r", 1) == 0)
4191 type = OSPF_ROUTER_LSA;
4192 else if (strncmp (argv[0], "ne", 2) == 0)
4193 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004194 else if (strncmp (argv[0], "ns", 2) == 0)
4195 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004196 else if (strncmp (argv[0], "s", 1) == 0)
4197 type = OSPF_SUMMARY_LSA;
4198 else if (strncmp (argv[0], "a", 1) == 0)
4199 type = OSPF_ASBR_SUMMARY_LSA;
4200 else if (strncmp (argv[0], "e", 1) == 0)
4201 type = OSPF_AS_EXTERNAL_LSA;
4202#ifdef HAVE_OPAQUE_LSA
4203 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4204 type = OSPF_OPAQUE_LINK_LSA;
4205 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4206 type = OSPF_OPAQUE_AREA_LSA;
4207 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4208 type = OSPF_OPAQUE_AS_LSA;
4209#endif /* HAVE_OPAQUE_LSA */
4210 else
4211 return CMD_WARNING;
4212
4213 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4214 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004215 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004216 else
4217 {
4218 ret = inet_aton (argv[1], &adv_router);
4219 if (!ret)
4220 return CMD_WARNING;
4221 }
4222
paul020709f2003-04-04 02:44:16 +00004223 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004224
4225 return CMD_SUCCESS;
4226}
4227
4228ALIAS (show_ip_ospf_database_type_adv_router,
4229 show_ip_ospf_database_type_self_cmd,
4230 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4231 SHOW_STR
4232 IP_STR
4233 "OSPF information\n"
4234 "Database summary\n"
4235 OSPF_LSA_TYPES_DESC
4236 "Self-originated link states\n")
4237
4238
4239DEFUN (ip_ospf_authentication_args,
4240 ip_ospf_authentication_args_addr_cmd,
4241 "ip ospf authentication (null|message-digest) A.B.C.D",
4242 "IP Information\n"
4243 "OSPF interface commands\n"
4244 "Enable authentication on this interface\n"
4245 "Use null authentication\n"
4246 "Use message-digest authentication\n"
4247 "Address of interface")
4248{
4249 struct interface *ifp;
4250 struct in_addr addr;
4251 int ret;
4252 struct ospf_if_params *params;
4253
4254 ifp = vty->index;
4255 params = IF_DEF_PARAMS (ifp);
4256
4257 if (argc == 2)
4258 {
4259 ret = inet_aton(argv[1], &addr);
4260 if (!ret)
4261 {
4262 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4263 VTY_NEWLINE);
4264 return CMD_WARNING;
4265 }
4266
4267 params = ospf_get_if_params (ifp, addr);
4268 ospf_if_update_params (ifp, addr);
4269 }
4270
4271 /* Handle null authentication */
4272 if ( argv[0][0] == 'n' )
4273 {
4274 SET_IF_PARAM (params, auth_type);
4275 params->auth_type = OSPF_AUTH_NULL;
4276 return CMD_SUCCESS;
4277 }
4278
4279 /* Handle message-digest authentication */
4280 if ( argv[0][0] == 'm' )
4281 {
4282 SET_IF_PARAM (params, auth_type);
4283 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4284 return CMD_SUCCESS;
4285 }
4286
4287 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4288 return CMD_WARNING;
4289}
4290
4291ALIAS (ip_ospf_authentication_args,
4292 ip_ospf_authentication_args_cmd,
4293 "ip ospf authentication (null|message-digest)",
4294 "IP Information\n"
4295 "OSPF interface commands\n"
4296 "Enable authentication on this interface\n"
4297 "Use null authentication\n"
4298 "Use message-digest authentication\n")
4299
4300DEFUN (ip_ospf_authentication,
4301 ip_ospf_authentication_addr_cmd,
4302 "ip ospf authentication A.B.C.D",
4303 "IP Information\n"
4304 "OSPF interface commands\n"
4305 "Enable authentication on this interface\n"
4306 "Address of interface")
4307{
4308 struct interface *ifp;
4309 struct in_addr addr;
4310 int ret;
4311 struct ospf_if_params *params;
4312
4313 ifp = vty->index;
4314 params = IF_DEF_PARAMS (ifp);
4315
4316 if (argc == 1)
4317 {
4318 ret = inet_aton(argv[1], &addr);
4319 if (!ret)
4320 {
4321 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4322 VTY_NEWLINE);
4323 return CMD_WARNING;
4324 }
4325
4326 params = ospf_get_if_params (ifp, addr);
4327 ospf_if_update_params (ifp, addr);
4328 }
4329
4330 SET_IF_PARAM (params, auth_type);
4331 params->auth_type = OSPF_AUTH_SIMPLE;
4332
4333 return CMD_SUCCESS;
4334}
4335
4336ALIAS (ip_ospf_authentication,
4337 ip_ospf_authentication_cmd,
4338 "ip ospf authentication",
4339 "IP Information\n"
4340 "OSPF interface commands\n"
4341 "Enable authentication on this interface\n")
4342
4343DEFUN (no_ip_ospf_authentication,
4344 no_ip_ospf_authentication_addr_cmd,
4345 "no ip ospf authentication A.B.C.D",
4346 NO_STR
4347 "IP Information\n"
4348 "OSPF interface commands\n"
4349 "Enable authentication on this interface\n"
4350 "Address of interface")
4351{
4352 struct interface *ifp;
4353 struct in_addr addr;
4354 int ret;
4355 struct ospf_if_params *params;
4356
4357 ifp = vty->index;
4358 params = IF_DEF_PARAMS (ifp);
4359
4360 if (argc == 1)
4361 {
4362 ret = inet_aton(argv[1], &addr);
4363 if (!ret)
4364 {
4365 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4366 VTY_NEWLINE);
4367 return CMD_WARNING;
4368 }
4369
4370 params = ospf_lookup_if_params (ifp, addr);
4371 if (params == NULL)
4372 return CMD_SUCCESS;
4373 }
4374
4375 params->auth_type = OSPF_AUTH_NOTSET;
4376 UNSET_IF_PARAM (params, auth_type);
4377
4378 if (params != IF_DEF_PARAMS (ifp))
4379 {
4380 ospf_free_if_params (ifp, addr);
4381 ospf_if_update_params (ifp, addr);
4382 }
4383
4384 return CMD_SUCCESS;
4385}
4386
4387ALIAS (no_ip_ospf_authentication,
4388 no_ip_ospf_authentication_cmd,
4389 "no ip ospf authentication",
4390 NO_STR
4391 "IP Information\n"
4392 "OSPF interface commands\n"
4393 "Enable authentication on this interface\n")
4394
4395DEFUN (ip_ospf_authentication_key,
4396 ip_ospf_authentication_key_addr_cmd,
4397 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4398 "IP Information\n"
4399 "OSPF interface commands\n"
4400 "Authentication password (key)\n"
4401 "The OSPF password (key)\n"
4402 "Address of interface")
4403{
4404 struct interface *ifp;
4405 struct in_addr addr;
4406 int ret;
4407 struct ospf_if_params *params;
4408
4409 ifp = vty->index;
4410 params = IF_DEF_PARAMS (ifp);
4411
4412 if (argc == 2)
4413 {
4414 ret = inet_aton(argv[1], &addr);
4415 if (!ret)
4416 {
4417 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4418 VTY_NEWLINE);
4419 return CMD_WARNING;
4420 }
4421
4422 params = ospf_get_if_params (ifp, addr);
4423 ospf_if_update_params (ifp, addr);
4424 }
4425
4426
4427 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004428 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004429 SET_IF_PARAM (params, auth_simple);
4430
4431 return CMD_SUCCESS;
4432}
4433
4434ALIAS (ip_ospf_authentication_key,
4435 ip_ospf_authentication_key_cmd,
4436 "ip ospf authentication-key AUTH_KEY",
4437 "IP Information\n"
4438 "OSPF interface commands\n"
4439 "Authentication password (key)\n"
4440 "The OSPF password (key)")
4441
4442ALIAS (ip_ospf_authentication_key,
4443 ospf_authentication_key_cmd,
4444 "ospf authentication-key AUTH_KEY",
4445 "OSPF interface commands\n"
4446 "Authentication password (key)\n"
4447 "The OSPF password (key)")
4448
4449DEFUN (no_ip_ospf_authentication_key,
4450 no_ip_ospf_authentication_key_addr_cmd,
4451 "no ip ospf authentication-key A.B.C.D",
4452 NO_STR
4453 "IP Information\n"
4454 "OSPF interface commands\n"
4455 "Authentication password (key)\n"
4456 "Address of interface")
4457{
4458 struct interface *ifp;
4459 struct in_addr addr;
4460 int ret;
4461 struct ospf_if_params *params;
4462
4463 ifp = vty->index;
4464 params = IF_DEF_PARAMS (ifp);
4465
4466 if (argc == 2)
4467 {
4468 ret = inet_aton(argv[1], &addr);
4469 if (!ret)
4470 {
4471 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4472 VTY_NEWLINE);
4473 return CMD_WARNING;
4474 }
4475
4476 params = ospf_lookup_if_params (ifp, addr);
4477 if (params == NULL)
4478 return CMD_SUCCESS;
4479 }
4480
4481 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4482 UNSET_IF_PARAM (params, auth_simple);
4483
4484 if (params != IF_DEF_PARAMS (ifp))
4485 {
4486 ospf_free_if_params (ifp, addr);
4487 ospf_if_update_params (ifp, addr);
4488 }
4489
4490 return CMD_SUCCESS;
4491}
4492
4493ALIAS (no_ip_ospf_authentication_key,
4494 no_ip_ospf_authentication_key_cmd,
4495 "no ip ospf authentication-key",
4496 NO_STR
4497 "IP Information\n"
4498 "OSPF interface commands\n"
4499 "Authentication password (key)\n")
4500
4501ALIAS (no_ip_ospf_authentication_key,
4502 no_ospf_authentication_key_cmd,
4503 "no ospf authentication-key",
4504 NO_STR
4505 "OSPF interface commands\n"
4506 "Authentication password (key)\n")
4507
4508DEFUN (ip_ospf_message_digest_key,
4509 ip_ospf_message_digest_key_addr_cmd,
4510 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4511 "IP Information\n"
4512 "OSPF interface commands\n"
4513 "Message digest authentication password (key)\n"
4514 "Key ID\n"
4515 "Use MD5 algorithm\n"
4516 "The OSPF password (key)"
4517 "Address of interface")
4518{
4519 struct interface *ifp;
4520 struct crypt_key *ck;
4521 u_char key_id;
4522 struct in_addr addr;
4523 int ret;
4524 struct ospf_if_params *params;
4525
4526 ifp = vty->index;
4527 params = IF_DEF_PARAMS (ifp);
4528
4529 if (argc == 3)
4530 {
4531 ret = inet_aton(argv[2], &addr);
4532 if (!ret)
4533 {
4534 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4535 VTY_NEWLINE);
4536 return CMD_WARNING;
4537 }
4538
4539 params = ospf_get_if_params (ifp, addr);
4540 ospf_if_update_params (ifp, addr);
4541 }
4542
4543 key_id = strtol (argv[0], NULL, 10);
4544 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4545 {
4546 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4547 return CMD_WARNING;
4548 }
4549
4550 ck = ospf_crypt_key_new ();
4551 ck->key_id = (u_char) key_id;
4552 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004553 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004554
4555 ospf_crypt_key_add (params->auth_crypt, ck);
4556 SET_IF_PARAM (params, auth_crypt);
4557
4558 return CMD_SUCCESS;
4559}
4560
4561ALIAS (ip_ospf_message_digest_key,
4562 ip_ospf_message_digest_key_cmd,
4563 "ip ospf message-digest-key <1-255> md5 KEY",
4564 "IP Information\n"
4565 "OSPF interface commands\n"
4566 "Message digest authentication password (key)\n"
4567 "Key ID\n"
4568 "Use MD5 algorithm\n"
4569 "The OSPF password (key)")
4570
4571ALIAS (ip_ospf_message_digest_key,
4572 ospf_message_digest_key_cmd,
4573 "ospf message-digest-key <1-255> md5 KEY",
4574 "OSPF interface commands\n"
4575 "Message digest authentication password (key)\n"
4576 "Key ID\n"
4577 "Use MD5 algorithm\n"
4578 "The OSPF password (key)")
4579
4580DEFUN (no_ip_ospf_message_digest_key,
4581 no_ip_ospf_message_digest_key_addr_cmd,
4582 "no ip ospf message-digest-key <1-255> A.B.C.D",
4583 NO_STR
4584 "IP Information\n"
4585 "OSPF interface commands\n"
4586 "Message digest authentication password (key)\n"
4587 "Key ID\n"
4588 "Address of interface")
4589{
4590 struct interface *ifp;
4591 struct crypt_key *ck;
4592 int key_id;
4593 struct in_addr addr;
4594 int ret;
4595 struct ospf_if_params *params;
4596
4597 ifp = vty->index;
4598 params = IF_DEF_PARAMS (ifp);
4599
4600 if (argc == 2)
4601 {
4602 ret = inet_aton(argv[1], &addr);
4603 if (!ret)
4604 {
4605 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4606 VTY_NEWLINE);
4607 return CMD_WARNING;
4608 }
4609
4610 params = ospf_lookup_if_params (ifp, addr);
4611 if (params == NULL)
4612 return CMD_SUCCESS;
4613 }
4614
4615 key_id = strtol (argv[0], NULL, 10);
4616 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4617 if (ck == NULL)
4618 {
4619 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4620 return CMD_WARNING;
4621 }
4622
4623 ospf_crypt_key_delete (params->auth_crypt, key_id);
4624
4625 if (params != IF_DEF_PARAMS (ifp))
4626 {
4627 ospf_free_if_params (ifp, addr);
4628 ospf_if_update_params (ifp, addr);
4629 }
4630
4631 return CMD_SUCCESS;
4632}
4633
4634ALIAS (no_ip_ospf_message_digest_key,
4635 no_ip_ospf_message_digest_key_cmd,
4636 "no ip ospf message-digest-key <1-255>",
4637 NO_STR
4638 "IP Information\n"
4639 "OSPF interface commands\n"
4640 "Message digest authentication password (key)\n"
4641 "Key ID\n")
4642
4643ALIAS (no_ip_ospf_message_digest_key,
4644 no_ospf_message_digest_key_cmd,
4645 "no ospf message-digest-key <1-255>",
4646 NO_STR
4647 "OSPF interface commands\n"
4648 "Message digest authentication password (key)\n"
4649 "Key ID\n")
4650
4651DEFUN (ip_ospf_cost,
4652 ip_ospf_cost_addr_cmd,
4653 "ip ospf cost <1-65535> A.B.C.D",
4654 "IP Information\n"
4655 "OSPF interface commands\n"
4656 "Interface cost\n"
4657 "Cost\n"
4658 "Address of interface")
4659{
4660 struct interface *ifp = vty->index;
4661 u_int32_t cost;
4662 struct in_addr addr;
4663 int ret;
4664 struct ospf_if_params *params;
4665
4666 params = IF_DEF_PARAMS (ifp);
4667
4668 cost = strtol (argv[0], NULL, 10);
4669
4670 /* cost range is <1-65535>. */
4671 if (cost < 1 || cost > 65535)
4672 {
4673 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4674 return CMD_WARNING;
4675 }
4676
4677 if (argc == 2)
4678 {
4679 ret = inet_aton(argv[1], &addr);
4680 if (!ret)
4681 {
4682 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4683 VTY_NEWLINE);
4684 return CMD_WARNING;
4685 }
4686
4687 params = ospf_get_if_params (ifp, addr);
4688 ospf_if_update_params (ifp, addr);
4689 }
4690
4691 SET_IF_PARAM (params, output_cost_cmd);
4692 params->output_cost_cmd = cost;
4693
4694 ospf_if_recalculate_output_cost (ifp);
4695
4696 return CMD_SUCCESS;
4697}
4698
4699ALIAS (ip_ospf_cost,
4700 ip_ospf_cost_cmd,
4701 "ip ospf cost <1-65535>",
4702 "IP Information\n"
4703 "OSPF interface commands\n"
4704 "Interface cost\n"
4705 "Cost")
4706
4707ALIAS (ip_ospf_cost,
4708 ospf_cost_cmd,
4709 "ospf cost <1-65535>",
4710 "OSPF interface commands\n"
4711 "Interface cost\n"
4712 "Cost")
4713
4714DEFUN (no_ip_ospf_cost,
4715 no_ip_ospf_cost_addr_cmd,
4716 "no ip ospf cost A.B.C.D",
4717 NO_STR
4718 "IP Information\n"
4719 "OSPF interface commands\n"
4720 "Interface cost\n"
4721 "Address of interface")
4722{
4723 struct interface *ifp = vty->index;
4724 struct in_addr addr;
4725 int ret;
4726 struct ospf_if_params *params;
4727
4728 ifp = vty->index;
4729 params = IF_DEF_PARAMS (ifp);
4730
4731 if (argc == 1)
4732 {
4733 ret = inet_aton(argv[0], &addr);
4734 if (!ret)
4735 {
4736 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4737 VTY_NEWLINE);
4738 return CMD_WARNING;
4739 }
4740
4741 params = ospf_lookup_if_params (ifp, addr);
4742 if (params == NULL)
4743 return CMD_SUCCESS;
4744 }
4745
4746 UNSET_IF_PARAM (params, output_cost_cmd);
4747
4748 if (params != IF_DEF_PARAMS (ifp))
4749 {
4750 ospf_free_if_params (ifp, addr);
4751 ospf_if_update_params (ifp, addr);
4752 }
4753
4754 ospf_if_recalculate_output_cost (ifp);
4755
4756 return CMD_SUCCESS;
4757}
4758
4759ALIAS (no_ip_ospf_cost,
4760 no_ip_ospf_cost_cmd,
4761 "no ip ospf cost",
4762 NO_STR
4763 "IP Information\n"
4764 "OSPF interface commands\n"
4765 "Interface cost\n")
4766
4767ALIAS (no_ip_ospf_cost,
4768 no_ospf_cost_cmd,
4769 "no ospf cost",
4770 NO_STR
4771 "OSPF interface commands\n"
4772 "Interface cost\n")
4773
paul4dadc292005-05-06 21:37:42 +00004774static void
paul718e3742002-12-13 20:15:29 +00004775ospf_nbr_timer_update (struct ospf_interface *oi)
4776{
4777 struct route_node *rn;
4778 struct ospf_neighbor *nbr;
4779
4780 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4781 if ((nbr = rn->info))
4782 {
4783 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4784 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4785 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4786 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4787 }
4788}
4789
paulf9ad9372005-10-21 00:45:17 +00004790static int
4791ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4792 const char *nbr_str,
4793 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004794{
4795 struct interface *ifp = vty->index;
4796 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004797 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004798 struct in_addr addr;
4799 int ret;
4800 struct ospf_if_params *params;
4801 struct ospf_interface *oi;
4802 struct route_node *rn;
4803
4804 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004805
4806 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004807 {
paulf9ad9372005-10-21 00:45:17 +00004808 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004809 if (!ret)
4810 {
4811 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4812 VTY_NEWLINE);
4813 return CMD_WARNING;
4814 }
4815
4816 params = ospf_get_if_params (ifp, addr);
4817 ospf_if_update_params (ifp, addr);
4818 }
4819
paulf9ad9372005-10-21 00:45:17 +00004820 if (interval_str)
4821 {
4822 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4823 1, 65535);
4824
4825 /* reset fast_hello too, just to be sure */
4826 UNSET_IF_PARAM (params, fast_hello);
4827 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4828 }
4829 else if (fast_hello_str)
4830 {
4831 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4832 1, 10);
4833 /* 1s dead-interval with sub-second hellos desired */
4834 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4835 SET_IF_PARAM (params, fast_hello);
4836 params->fast_hello = hellomult;
4837 }
4838 else
4839 {
4840 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4841 VTY_NEWLINE);
4842 return CMD_WARNING;
4843 }
4844
paul718e3742002-12-13 20:15:29 +00004845 SET_IF_PARAM (params, v_wait);
4846 params->v_wait = seconds;
4847
4848 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00004849 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004850 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004851 struct ospf *ospf;
4852 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00004853 {
4854 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4855 if (oi)
4856 ospf_nbr_timer_update (oi);
4857 }
paul718e3742002-12-13 20:15:29 +00004858 }
4859 else
4860 {
4861 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4862 if ((oi = rn->info))
4863 ospf_nbr_timer_update (oi);
4864 }
4865
4866 return CMD_SUCCESS;
4867}
4868
paulf9ad9372005-10-21 00:45:17 +00004869
4870DEFUN (ip_ospf_dead_interval,
4871 ip_ospf_dead_interval_addr_cmd,
4872 "ip ospf dead-interval <1-65535> A.B.C.D",
4873 "IP Information\n"
4874 "OSPF interface commands\n"
4875 "Interval after which a neighbor is declared dead\n"
4876 "Seconds\n"
4877 "Address of interface\n")
4878{
4879 if (argc == 2)
4880 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4881 else
4882 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4883}
4884
paul718e3742002-12-13 20:15:29 +00004885ALIAS (ip_ospf_dead_interval,
4886 ip_ospf_dead_interval_cmd,
4887 "ip ospf dead-interval <1-65535>",
4888 "IP Information\n"
4889 "OSPF interface commands\n"
4890 "Interval after which a neighbor is declared dead\n"
4891 "Seconds\n")
4892
4893ALIAS (ip_ospf_dead_interval,
4894 ospf_dead_interval_cmd,
4895 "ospf dead-interval <1-65535>",
4896 "OSPF interface commands\n"
4897 "Interval after which a neighbor is declared dead\n"
4898 "Seconds\n")
4899
paulf9ad9372005-10-21 00:45:17 +00004900DEFUN (ip_ospf_dead_interval_minimal,
4901 ip_ospf_dead_interval_minimal_addr_cmd,
4902 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4903 "IP Information\n"
4904 "OSPF interface commands\n"
4905 "Interval after which a neighbor is declared dead\n"
4906 "Minimal 1s dead-interval with fast sub-second hellos\n"
4907 "Hello multiplier factor\n"
4908 "Number of Hellos to send each second\n"
4909 "Address of interface\n")
4910{
4911 if (argc == 2)
4912 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4913 else
4914 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4915}
4916
4917ALIAS (ip_ospf_dead_interval_minimal,
4918 ip_ospf_dead_interval_minimal_cmd,
4919 "ip ospf dead-interval minimal hello-multiplier <1-10>",
4920 "IP Information\n"
4921 "OSPF interface commands\n"
4922 "Interval after which a neighbor is declared dead\n"
4923 "Minimal 1s dead-interval with fast sub-second hellos\n"
4924 "Hello multiplier factor\n"
4925 "Number of Hellos to send each second\n")
4926
paul718e3742002-12-13 20:15:29 +00004927DEFUN (no_ip_ospf_dead_interval,
4928 no_ip_ospf_dead_interval_addr_cmd,
4929 "no ip ospf dead-interval A.B.C.D",
4930 NO_STR
4931 "IP Information\n"
4932 "OSPF interface commands\n"
4933 "Interval after which a neighbor is declared dead\n"
4934 "Address of interface")
4935{
4936 struct interface *ifp = vty->index;
4937 struct in_addr addr;
4938 int ret;
4939 struct ospf_if_params *params;
4940 struct ospf_interface *oi;
4941 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004942
paul718e3742002-12-13 20:15:29 +00004943 ifp = vty->index;
4944 params = IF_DEF_PARAMS (ifp);
4945
4946 if (argc == 1)
4947 {
4948 ret = inet_aton(argv[0], &addr);
4949 if (!ret)
4950 {
4951 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4952 VTY_NEWLINE);
4953 return CMD_WARNING;
4954 }
4955
4956 params = ospf_lookup_if_params (ifp, addr);
4957 if (params == NULL)
4958 return CMD_SUCCESS;
4959 }
4960
4961 UNSET_IF_PARAM (params, v_wait);
4962 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00004963
4964 UNSET_IF_PARAM (params, fast_hello);
4965 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4966
paul718e3742002-12-13 20:15:29 +00004967 if (params != IF_DEF_PARAMS (ifp))
4968 {
4969 ospf_free_if_params (ifp, addr);
4970 ospf_if_update_params (ifp, addr);
4971 }
4972
4973 /* Update timer values in neighbor structure. */
4974 if (argc == 1)
4975 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004976 struct ospf *ospf;
4977
4978 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00004979 {
4980 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4981 if (oi)
4982 ospf_nbr_timer_update (oi);
4983 }
paul718e3742002-12-13 20:15:29 +00004984 }
4985 else
4986 {
4987 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4988 if ((oi = rn->info))
4989 ospf_nbr_timer_update (oi);
4990 }
4991
4992 return CMD_SUCCESS;
4993}
4994
4995ALIAS (no_ip_ospf_dead_interval,
4996 no_ip_ospf_dead_interval_cmd,
4997 "no ip ospf dead-interval",
4998 NO_STR
4999 "IP Information\n"
5000 "OSPF interface commands\n"
5001 "Interval after which a neighbor is declared dead\n")
5002
5003ALIAS (no_ip_ospf_dead_interval,
5004 no_ospf_dead_interval_cmd,
5005 "no ospf dead-interval",
5006 NO_STR
5007 "OSPF interface commands\n"
5008 "Interval after which a neighbor is declared dead\n")
5009
5010DEFUN (ip_ospf_hello_interval,
5011 ip_ospf_hello_interval_addr_cmd,
5012 "ip ospf hello-interval <1-65535> A.B.C.D",
5013 "IP Information\n"
5014 "OSPF interface commands\n"
5015 "Time between HELLO packets\n"
5016 "Seconds\n"
5017 "Address of interface")
5018{
5019 struct interface *ifp = vty->index;
5020 u_int32_t seconds;
5021 struct in_addr addr;
5022 int ret;
5023 struct ospf_if_params *params;
5024
5025 params = IF_DEF_PARAMS (ifp);
5026
5027 seconds = strtol (argv[0], NULL, 10);
5028
5029 /* HelloInterval range is <1-65535>. */
5030 if (seconds < 1 || seconds > 65535)
5031 {
5032 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5033 return CMD_WARNING;
5034 }
5035
5036 if (argc == 2)
5037 {
5038 ret = inet_aton(argv[1], &addr);
5039 if (!ret)
5040 {
5041 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5042 VTY_NEWLINE);
5043 return CMD_WARNING;
5044 }
5045
5046 params = ospf_get_if_params (ifp, addr);
5047 ospf_if_update_params (ifp, addr);
5048 }
5049
paulf9ad9372005-10-21 00:45:17 +00005050 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005051 params->v_hello = seconds;
5052
5053 return CMD_SUCCESS;
5054}
5055
5056ALIAS (ip_ospf_hello_interval,
5057 ip_ospf_hello_interval_cmd,
5058 "ip ospf hello-interval <1-65535>",
5059 "IP Information\n"
5060 "OSPF interface commands\n"
5061 "Time between HELLO packets\n"
5062 "Seconds\n")
5063
5064ALIAS (ip_ospf_hello_interval,
5065 ospf_hello_interval_cmd,
5066 "ospf hello-interval <1-65535>",
5067 "OSPF interface commands\n"
5068 "Time between HELLO packets\n"
5069 "Seconds\n")
5070
5071DEFUN (no_ip_ospf_hello_interval,
5072 no_ip_ospf_hello_interval_addr_cmd,
5073 "no ip ospf hello-interval A.B.C.D",
5074 NO_STR
5075 "IP Information\n"
5076 "OSPF interface commands\n"
5077 "Time between HELLO packets\n"
5078 "Address of interface")
5079{
5080 struct interface *ifp = vty->index;
5081 struct in_addr addr;
5082 int ret;
5083 struct ospf_if_params *params;
5084
5085 ifp = vty->index;
5086 params = IF_DEF_PARAMS (ifp);
5087
5088 if (argc == 1)
5089 {
5090 ret = inet_aton(argv[0], &addr);
5091 if (!ret)
5092 {
5093 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5094 VTY_NEWLINE);
5095 return CMD_WARNING;
5096 }
5097
5098 params = ospf_lookup_if_params (ifp, addr);
5099 if (params == NULL)
5100 return CMD_SUCCESS;
5101 }
5102
5103 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005104 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005105
5106 if (params != IF_DEF_PARAMS (ifp))
5107 {
5108 ospf_free_if_params (ifp, addr);
5109 ospf_if_update_params (ifp, addr);
5110 }
5111
5112 return CMD_SUCCESS;
5113}
5114
5115ALIAS (no_ip_ospf_hello_interval,
5116 no_ip_ospf_hello_interval_cmd,
5117 "no ip ospf hello-interval",
5118 NO_STR
5119 "IP Information\n"
5120 "OSPF interface commands\n"
5121 "Time between HELLO packets\n")
5122
5123ALIAS (no_ip_ospf_hello_interval,
5124 no_ospf_hello_interval_cmd,
5125 "no ospf hello-interval",
5126 NO_STR
5127 "OSPF interface commands\n"
5128 "Time between HELLO packets\n")
5129
5130DEFUN (ip_ospf_network,
5131 ip_ospf_network_cmd,
5132 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5133 "IP Information\n"
5134 "OSPF interface commands\n"
5135 "Network type\n"
5136 "Specify OSPF broadcast multi-access network\n"
5137 "Specify OSPF NBMA network\n"
5138 "Specify OSPF point-to-multipoint network\n"
5139 "Specify OSPF point-to-point network\n")
5140{
5141 struct interface *ifp = vty->index;
5142 int old_type = IF_DEF_PARAMS (ifp)->type;
5143 struct route_node *rn;
5144
5145 if (strncmp (argv[0], "b", 1) == 0)
5146 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5147 else if (strncmp (argv[0], "n", 1) == 0)
5148 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5149 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5150 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5151 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5152 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5153
5154 if (IF_DEF_PARAMS (ifp)->type == old_type)
5155 return CMD_SUCCESS;
5156
5157 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5158
5159 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5160 {
5161 struct ospf_interface *oi = rn->info;
5162
5163 if (!oi)
5164 continue;
5165
5166 oi->type = IF_DEF_PARAMS (ifp)->type;
5167
5168 if (oi->state > ISM_Down)
5169 {
5170 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5171 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5172 }
5173 }
5174
5175 return CMD_SUCCESS;
5176}
5177
5178ALIAS (ip_ospf_network,
5179 ospf_network_cmd,
5180 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5181 "OSPF interface commands\n"
5182 "Network type\n"
5183 "Specify OSPF broadcast multi-access network\n"
5184 "Specify OSPF NBMA network\n"
5185 "Specify OSPF point-to-multipoint network\n"
5186 "Specify OSPF point-to-point network\n")
5187
5188DEFUN (no_ip_ospf_network,
5189 no_ip_ospf_network_cmd,
5190 "no ip ospf network",
5191 NO_STR
5192 "IP Information\n"
5193 "OSPF interface commands\n"
5194 "Network type\n")
5195{
5196 struct interface *ifp = vty->index;
5197 int old_type = IF_DEF_PARAMS (ifp)->type;
5198 struct route_node *rn;
5199
ajsbc18d612004-12-15 15:07:19 +00005200 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005201
5202 if (IF_DEF_PARAMS (ifp)->type == old_type)
5203 return CMD_SUCCESS;
5204
5205 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5206 {
5207 struct ospf_interface *oi = rn->info;
5208
5209 if (!oi)
5210 continue;
5211
5212 oi->type = IF_DEF_PARAMS (ifp)->type;
5213
5214 if (oi->state > ISM_Down)
5215 {
5216 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5217 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5218 }
5219 }
5220
5221 return CMD_SUCCESS;
5222}
5223
5224ALIAS (no_ip_ospf_network,
5225 no_ospf_network_cmd,
5226 "no ospf network",
5227 NO_STR
5228 "OSPF interface commands\n"
5229 "Network type\n")
5230
5231DEFUN (ip_ospf_priority,
5232 ip_ospf_priority_addr_cmd,
5233 "ip ospf priority <0-255> A.B.C.D",
5234 "IP Information\n"
5235 "OSPF interface commands\n"
5236 "Router priority\n"
5237 "Priority\n"
5238 "Address of interface")
5239{
5240 struct interface *ifp = vty->index;
5241 u_int32_t priority;
5242 struct route_node *rn;
5243 struct in_addr addr;
5244 int ret;
5245 struct ospf_if_params *params;
5246
5247 params = IF_DEF_PARAMS (ifp);
5248
5249 priority = strtol (argv[0], NULL, 10);
5250
5251 /* Router Priority range is <0-255>. */
5252 if (priority < 0 || priority > 255)
5253 {
5254 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5255 return CMD_WARNING;
5256 }
5257
5258 if (argc == 2)
5259 {
5260 ret = inet_aton(argv[1], &addr);
5261 if (!ret)
5262 {
5263 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5264 VTY_NEWLINE);
5265 return CMD_WARNING;
5266 }
5267
5268 params = ospf_get_if_params (ifp, addr);
5269 ospf_if_update_params (ifp, addr);
5270 }
5271
5272 SET_IF_PARAM (params, priority);
5273 params->priority = priority;
5274
5275 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5276 {
5277 struct ospf_interface *oi = rn->info;
5278
5279 if (!oi)
5280 continue;
5281
5282
5283 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5284 {
5285 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5286 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5287 }
5288 }
5289
5290 return CMD_SUCCESS;
5291}
5292
5293ALIAS (ip_ospf_priority,
5294 ip_ospf_priority_cmd,
5295 "ip ospf priority <0-255>",
5296 "IP Information\n"
5297 "OSPF interface commands\n"
5298 "Router priority\n"
5299 "Priority\n")
5300
5301ALIAS (ip_ospf_priority,
5302 ospf_priority_cmd,
5303 "ospf priority <0-255>",
5304 "OSPF interface commands\n"
5305 "Router priority\n"
5306 "Priority\n")
5307
5308DEFUN (no_ip_ospf_priority,
5309 no_ip_ospf_priority_addr_cmd,
5310 "no ip ospf priority A.B.C.D",
5311 NO_STR
5312 "IP Information\n"
5313 "OSPF interface commands\n"
5314 "Router priority\n"
5315 "Address of interface")
5316{
5317 struct interface *ifp = vty->index;
5318 struct route_node *rn;
5319 struct in_addr addr;
5320 int ret;
5321 struct ospf_if_params *params;
5322
5323 ifp = vty->index;
5324 params = IF_DEF_PARAMS (ifp);
5325
5326 if (argc == 1)
5327 {
5328 ret = inet_aton(argv[0], &addr);
5329 if (!ret)
5330 {
5331 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5332 VTY_NEWLINE);
5333 return CMD_WARNING;
5334 }
5335
5336 params = ospf_lookup_if_params (ifp, addr);
5337 if (params == NULL)
5338 return CMD_SUCCESS;
5339 }
5340
5341 UNSET_IF_PARAM (params, priority);
5342 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5343
5344 if (params != IF_DEF_PARAMS (ifp))
5345 {
5346 ospf_free_if_params (ifp, addr);
5347 ospf_if_update_params (ifp, addr);
5348 }
5349
5350 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5351 {
5352 struct ospf_interface *oi = rn->info;
5353
5354 if (!oi)
5355 continue;
5356
5357
5358 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5359 {
5360 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5361 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5362 }
5363 }
5364
5365 return CMD_SUCCESS;
5366}
5367
5368ALIAS (no_ip_ospf_priority,
5369 no_ip_ospf_priority_cmd,
5370 "no ip ospf priority",
5371 NO_STR
5372 "IP Information\n"
5373 "OSPF interface commands\n"
5374 "Router priority\n")
5375
5376ALIAS (no_ip_ospf_priority,
5377 no_ospf_priority_cmd,
5378 "no ospf priority",
5379 NO_STR
5380 "OSPF interface commands\n"
5381 "Router priority\n")
5382
5383DEFUN (ip_ospf_retransmit_interval,
5384 ip_ospf_retransmit_interval_addr_cmd,
5385 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5386 "IP Information\n"
5387 "OSPF interface commands\n"
5388 "Time between retransmitting lost link state advertisements\n"
5389 "Seconds\n"
5390 "Address of interface")
5391{
5392 struct interface *ifp = vty->index;
5393 u_int32_t seconds;
5394 struct in_addr addr;
5395 int ret;
5396 struct ospf_if_params *params;
5397
5398 params = IF_DEF_PARAMS (ifp);
5399 seconds = strtol (argv[0], NULL, 10);
5400
5401 /* Retransmit Interval range is <3-65535>. */
5402 if (seconds < 3 || seconds > 65535)
5403 {
5404 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5405 return CMD_WARNING;
5406 }
5407
5408
5409 if (argc == 2)
5410 {
5411 ret = inet_aton(argv[1], &addr);
5412 if (!ret)
5413 {
5414 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5415 VTY_NEWLINE);
5416 return CMD_WARNING;
5417 }
5418
5419 params = ospf_get_if_params (ifp, addr);
5420 ospf_if_update_params (ifp, addr);
5421 }
5422
5423 SET_IF_PARAM (params, retransmit_interval);
5424 params->retransmit_interval = seconds;
5425
5426 return CMD_SUCCESS;
5427}
5428
5429ALIAS (ip_ospf_retransmit_interval,
5430 ip_ospf_retransmit_interval_cmd,
5431 "ip ospf retransmit-interval <3-65535>",
5432 "IP Information\n"
5433 "OSPF interface commands\n"
5434 "Time between retransmitting lost link state advertisements\n"
5435 "Seconds\n")
5436
5437ALIAS (ip_ospf_retransmit_interval,
5438 ospf_retransmit_interval_cmd,
5439 "ospf retransmit-interval <3-65535>",
5440 "OSPF interface commands\n"
5441 "Time between retransmitting lost link state advertisements\n"
5442 "Seconds\n")
5443
5444DEFUN (no_ip_ospf_retransmit_interval,
5445 no_ip_ospf_retransmit_interval_addr_cmd,
5446 "no ip ospf retransmit-interval A.B.C.D",
5447 NO_STR
5448 "IP Information\n"
5449 "OSPF interface commands\n"
5450 "Time between retransmitting lost link state advertisements\n"
5451 "Address of interface")
5452{
5453 struct interface *ifp = vty->index;
5454 struct in_addr addr;
5455 int ret;
5456 struct ospf_if_params *params;
5457
5458 ifp = vty->index;
5459 params = IF_DEF_PARAMS (ifp);
5460
5461 if (argc == 1)
5462 {
5463 ret = inet_aton(argv[0], &addr);
5464 if (!ret)
5465 {
5466 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5467 VTY_NEWLINE);
5468 return CMD_WARNING;
5469 }
5470
5471 params = ospf_lookup_if_params (ifp, addr);
5472 if (params == NULL)
5473 return CMD_SUCCESS;
5474 }
5475
5476 UNSET_IF_PARAM (params, retransmit_interval);
5477 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5478
5479 if (params != IF_DEF_PARAMS (ifp))
5480 {
5481 ospf_free_if_params (ifp, addr);
5482 ospf_if_update_params (ifp, addr);
5483 }
5484
5485 return CMD_SUCCESS;
5486}
5487
5488ALIAS (no_ip_ospf_retransmit_interval,
5489 no_ip_ospf_retransmit_interval_cmd,
5490 "no ip ospf retransmit-interval",
5491 NO_STR
5492 "IP Information\n"
5493 "OSPF interface commands\n"
5494 "Time between retransmitting lost link state advertisements\n")
5495
5496ALIAS (no_ip_ospf_retransmit_interval,
5497 no_ospf_retransmit_interval_cmd,
5498 "no ospf retransmit-interval",
5499 NO_STR
5500 "OSPF interface commands\n"
5501 "Time between retransmitting lost link state advertisements\n")
5502
5503DEFUN (ip_ospf_transmit_delay,
5504 ip_ospf_transmit_delay_addr_cmd,
5505 "ip ospf transmit-delay <1-65535> A.B.C.D",
5506 "IP Information\n"
5507 "OSPF interface commands\n"
5508 "Link state transmit delay\n"
5509 "Seconds\n"
5510 "Address of interface")
5511{
5512 struct interface *ifp = vty->index;
5513 u_int32_t seconds;
5514 struct in_addr addr;
5515 int ret;
5516 struct ospf_if_params *params;
5517
5518 params = IF_DEF_PARAMS (ifp);
5519 seconds = strtol (argv[0], NULL, 10);
5520
5521 /* Transmit Delay range is <1-65535>. */
5522 if (seconds < 1 || seconds > 65535)
5523 {
5524 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5525 return CMD_WARNING;
5526 }
5527
5528 if (argc == 2)
5529 {
5530 ret = inet_aton(argv[1], &addr);
5531 if (!ret)
5532 {
5533 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5534 VTY_NEWLINE);
5535 return CMD_WARNING;
5536 }
5537
5538 params = ospf_get_if_params (ifp, addr);
5539 ospf_if_update_params (ifp, addr);
5540 }
5541
5542 SET_IF_PARAM (params, transmit_delay);
5543 params->transmit_delay = seconds;
5544
5545 return CMD_SUCCESS;
5546}
5547
5548ALIAS (ip_ospf_transmit_delay,
5549 ip_ospf_transmit_delay_cmd,
5550 "ip ospf transmit-delay <1-65535>",
5551 "IP Information\n"
5552 "OSPF interface commands\n"
5553 "Link state transmit delay\n"
5554 "Seconds\n")
5555
5556ALIAS (ip_ospf_transmit_delay,
5557 ospf_transmit_delay_cmd,
5558 "ospf transmit-delay <1-65535>",
5559 "OSPF interface commands\n"
5560 "Link state transmit delay\n"
5561 "Seconds\n")
5562
5563DEFUN (no_ip_ospf_transmit_delay,
5564 no_ip_ospf_transmit_delay_addr_cmd,
5565 "no ip ospf transmit-delay A.B.C.D",
5566 NO_STR
5567 "IP Information\n"
5568 "OSPF interface commands\n"
5569 "Link state transmit delay\n"
5570 "Address of interface")
5571{
5572 struct interface *ifp = vty->index;
5573 struct in_addr addr;
5574 int ret;
5575 struct ospf_if_params *params;
5576
5577 ifp = vty->index;
5578 params = IF_DEF_PARAMS (ifp);
5579
5580 if (argc == 1)
5581 {
5582 ret = inet_aton(argv[0], &addr);
5583 if (!ret)
5584 {
5585 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5586 VTY_NEWLINE);
5587 return CMD_WARNING;
5588 }
5589
5590 params = ospf_lookup_if_params (ifp, addr);
5591 if (params == NULL)
5592 return CMD_SUCCESS;
5593 }
5594
5595 UNSET_IF_PARAM (params, transmit_delay);
5596 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5597
5598 if (params != IF_DEF_PARAMS (ifp))
5599 {
5600 ospf_free_if_params (ifp, addr);
5601 ospf_if_update_params (ifp, addr);
5602 }
5603
5604 return CMD_SUCCESS;
5605}
5606
5607ALIAS (no_ip_ospf_transmit_delay,
5608 no_ip_ospf_transmit_delay_cmd,
5609 "no ip ospf transmit-delay",
5610 NO_STR
5611 "IP Information\n"
5612 "OSPF interface commands\n"
5613 "Link state transmit delay\n")
5614
5615ALIAS (no_ip_ospf_transmit_delay,
5616 no_ospf_transmit_delay_cmd,
5617 "no ospf transmit-delay",
5618 NO_STR
5619 "OSPF interface commands\n"
5620 "Link state transmit delay\n")
5621
5622
5623DEFUN (ospf_redistribute_source_metric_type,
5624 ospf_redistribute_source_metric_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005625 "redistribute " QUAGGA_REDIST_STR_OSPFD
5626 " metric <0-16777214> metric-type (1|2) route-map WORD",
5627 REDIST_STR
5628 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005629 "Metric for redistributed routes\n"
5630 "OSPF default metric\n"
5631 "OSPF exterior metric type for redistributed routes\n"
5632 "Set OSPF External Type 1 metrics\n"
5633 "Set OSPF External Type 2 metrics\n"
5634 "Route map reference\n"
5635 "Pointer to route-map entries\n")
5636{
paul020709f2003-04-04 02:44:16 +00005637 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005638 int source;
5639 int type = -1;
5640 int metric = -1;
5641
5642 /* Get distribute source. */
5643 if (!str2distribute_source (argv[0], &source))
5644 return CMD_WARNING;
5645
5646 /* Get metric value. */
5647 if (argc >= 2)
5648 if (!str2metric (argv[1], &metric))
5649 return CMD_WARNING;
5650
5651 /* Get metric type. */
5652 if (argc >= 3)
5653 if (!str2metric_type (argv[2], &type))
5654 return CMD_WARNING;
5655
5656 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005657 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005658 else
paul020709f2003-04-04 02:44:16 +00005659 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005660
paul020709f2003-04-04 02:44:16 +00005661 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005662}
5663
5664ALIAS (ospf_redistribute_source_metric_type,
5665 ospf_redistribute_source_metric_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005666 "redistribute " QUAGGA_REDIST_STR_OSPFD
5667 " metric <0-16777214> metric-type (1|2)",
5668 REDIST_STR
5669 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005670 "Metric for redistributed routes\n"
5671 "OSPF default metric\n"
5672 "OSPF exterior metric type for redistributed routes\n"
5673 "Set OSPF External Type 1 metrics\n"
5674 "Set OSPF External Type 2 metrics\n")
5675
5676ALIAS (ospf_redistribute_source_metric_type,
5677 ospf_redistribute_source_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005678 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5679 REDIST_STR
5680 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005681 "Metric for redistributed routes\n"
5682 "OSPF default metric\n")
5683
5684DEFUN (ospf_redistribute_source_type_metric,
5685 ospf_redistribute_source_type_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005686 "redistribute " QUAGGA_REDIST_STR_OSPFD
5687 " metric-type (1|2) metric <0-16777214> route-map WORD",
5688 REDIST_STR
5689 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005690 "OSPF exterior metric type for redistributed routes\n"
5691 "Set OSPF External Type 1 metrics\n"
5692 "Set OSPF External Type 2 metrics\n"
5693 "Metric for redistributed routes\n"
5694 "OSPF default metric\n"
5695 "Route map reference\n"
5696 "Pointer to route-map entries\n")
5697{
paul020709f2003-04-04 02:44:16 +00005698 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005699 int source;
5700 int type = -1;
5701 int metric = -1;
5702
5703 /* Get distribute source. */
5704 if (!str2distribute_source (argv[0], &source))
5705 return CMD_WARNING;
5706
5707 /* Get metric value. */
5708 if (argc >= 2)
5709 if (!str2metric_type (argv[1], &type))
5710 return CMD_WARNING;
5711
5712 /* Get metric type. */
5713 if (argc >= 3)
5714 if (!str2metric (argv[2], &metric))
5715 return CMD_WARNING;
5716
5717 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005718 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005719 else
paul020709f2003-04-04 02:44:16 +00005720 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005721
paul020709f2003-04-04 02:44:16 +00005722 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005723}
5724
5725ALIAS (ospf_redistribute_source_type_metric,
5726 ospf_redistribute_source_type_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005727 "redistribute " QUAGGA_REDIST_STR_OSPFD
5728 " metric-type (1|2) metric <0-16777214>",
5729 REDIST_STR
5730 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005731 "OSPF exterior metric type for redistributed routes\n"
5732 "Set OSPF External Type 1 metrics\n"
5733 "Set OSPF External Type 2 metrics\n"
5734 "Metric for redistributed routes\n"
5735 "OSPF default metric\n")
5736
5737ALIAS (ospf_redistribute_source_type_metric,
5738 ospf_redistribute_source_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005739 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5740 REDIST_STR
5741 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005742 "OSPF exterior metric type for redistributed routes\n"
5743 "Set OSPF External Type 1 metrics\n"
5744 "Set OSPF External Type 2 metrics\n")
5745
5746ALIAS (ospf_redistribute_source_type_metric,
5747 ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005748 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5749 REDIST_STR
5750 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005751
5752DEFUN (ospf_redistribute_source_metric_routemap,
5753 ospf_redistribute_source_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005754 "redistribute " QUAGGA_REDIST_STR_OSPFD
5755 " metric <0-16777214> route-map WORD",
5756 REDIST_STR
5757 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005758 "Metric for redistributed routes\n"
5759 "OSPF default metric\n"
5760 "Route map reference\n"
5761 "Pointer to route-map entries\n")
5762{
paul020709f2003-04-04 02:44:16 +00005763 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005764 int source;
5765 int metric = -1;
5766
5767 /* Get distribute source. */
5768 if (!str2distribute_source (argv[0], &source))
5769 return CMD_WARNING;
5770
5771 /* Get metric value. */
5772 if (argc >= 2)
5773 if (!str2metric (argv[1], &metric))
5774 return CMD_WARNING;
5775
5776 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005777 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005778 else
paul020709f2003-04-04 02:44:16 +00005779 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005780
paul020709f2003-04-04 02:44:16 +00005781 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005782}
5783
5784DEFUN (ospf_redistribute_source_type_routemap,
5785 ospf_redistribute_source_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005786 "redistribute " QUAGGA_REDIST_STR_OSPFD
5787 " metric-type (1|2) route-map WORD",
5788 REDIST_STR
5789 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005790 "OSPF exterior metric type for redistributed routes\n"
5791 "Set OSPF External Type 1 metrics\n"
5792 "Set OSPF External Type 2 metrics\n"
5793 "Route map reference\n"
5794 "Pointer to route-map entries\n")
5795{
paul020709f2003-04-04 02:44:16 +00005796 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005797 int source;
5798 int type = -1;
5799
5800 /* Get distribute source. */
5801 if (!str2distribute_source (argv[0], &source))
5802 return CMD_WARNING;
5803
5804 /* Get metric value. */
5805 if (argc >= 2)
5806 if (!str2metric_type (argv[1], &type))
5807 return CMD_WARNING;
5808
5809 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005810 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005811 else
paul020709f2003-04-04 02:44:16 +00005812 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005813
paul020709f2003-04-04 02:44:16 +00005814 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005815}
5816
5817DEFUN (ospf_redistribute_source_routemap,
5818 ospf_redistribute_source_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005819 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5820 REDIST_STR
5821 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005822 "Route map reference\n"
5823 "Pointer to route-map entries\n")
5824{
paul020709f2003-04-04 02:44:16 +00005825 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005826 int source;
5827
5828 /* Get distribute source. */
5829 if (!str2distribute_source (argv[0], &source))
5830 return CMD_WARNING;
5831
5832 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005833 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005834 else
paul020709f2003-04-04 02:44:16 +00005835 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005836
paul020709f2003-04-04 02:44:16 +00005837 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005838}
5839
5840DEFUN (no_ospf_redistribute_source,
5841 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005842 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005843 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005844 REDIST_STR
5845 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005846{
paul020709f2003-04-04 02:44:16 +00005847 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005848 int source;
5849
5850 if (!str2distribute_source (argv[0], &source))
5851 return CMD_WARNING;
5852
paul020709f2003-04-04 02:44:16 +00005853 ospf_routemap_unset (ospf, source);
5854 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005855}
5856
5857DEFUN (ospf_distribute_list_out,
5858 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005859 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005860 "Filter networks in routing updates\n"
5861 "Access-list name\n"
5862 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005863 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005864{
paul68980082003-03-25 05:07:42 +00005865 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005866 int source;
5867
5868 /* Get distribute source. */
5869 if (!str2distribute_source (argv[1], &source))
5870 return CMD_WARNING;
5871
paul68980082003-03-25 05:07:42 +00005872 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005873}
5874
5875DEFUN (no_ospf_distribute_list_out,
5876 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005877 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005878 NO_STR
5879 "Filter networks in routing updates\n"
5880 "Access-list name\n"
5881 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005882 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005883{
paul68980082003-03-25 05:07:42 +00005884 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005885 int source;
5886
5887 if (!str2distribute_source (argv[1], &source))
5888 return CMD_WARNING;
5889
paul68980082003-03-25 05:07:42 +00005890 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005891}
5892
5893/* Default information originate. */
5894DEFUN (ospf_default_information_originate_metric_type_routemap,
5895 ospf_default_information_originate_metric_type_routemap_cmd,
5896 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5897 "Control distribution of default information\n"
5898 "Distribute a default route\n"
5899 "OSPF default metric\n"
5900 "OSPF metric\n"
5901 "OSPF metric type for default routes\n"
5902 "Set OSPF External Type 1 metrics\n"
5903 "Set OSPF External Type 2 metrics\n"
5904 "Route map reference\n"
5905 "Pointer to route-map entries\n")
5906{
paul020709f2003-04-04 02:44:16 +00005907 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005908 int type = -1;
5909 int metric = -1;
5910
5911 /* Get metric value. */
5912 if (argc >= 1)
5913 if (!str2metric (argv[0], &metric))
5914 return CMD_WARNING;
5915
5916 /* Get metric type. */
5917 if (argc >= 2)
5918 if (!str2metric_type (argv[1], &type))
5919 return CMD_WARNING;
5920
5921 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005922 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005923 else
paul020709f2003-04-04 02:44:16 +00005924 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005925
paul020709f2003-04-04 02:44:16 +00005926 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5927 type, metric);
paul718e3742002-12-13 20:15:29 +00005928}
5929
5930ALIAS (ospf_default_information_originate_metric_type_routemap,
5931 ospf_default_information_originate_metric_type_cmd,
5932 "default-information originate metric <0-16777214> metric-type (1|2)",
5933 "Control distribution of default information\n"
5934 "Distribute a default route\n"
5935 "OSPF default metric\n"
5936 "OSPF metric\n"
5937 "OSPF metric type for default routes\n"
5938 "Set OSPF External Type 1 metrics\n"
5939 "Set OSPF External Type 2 metrics\n")
5940
5941ALIAS (ospf_default_information_originate_metric_type_routemap,
5942 ospf_default_information_originate_metric_cmd,
5943 "default-information originate metric <0-16777214>",
5944 "Control distribution of default information\n"
5945 "Distribute a default route\n"
5946 "OSPF default metric\n"
5947 "OSPF metric\n")
5948
5949ALIAS (ospf_default_information_originate_metric_type_routemap,
5950 ospf_default_information_originate_cmd,
5951 "default-information originate",
5952 "Control distribution of default information\n"
5953 "Distribute a default route\n")
5954
5955/* Default information originate. */
5956DEFUN (ospf_default_information_originate_metric_routemap,
5957 ospf_default_information_originate_metric_routemap_cmd,
5958 "default-information originate metric <0-16777214> route-map WORD",
5959 "Control distribution of default information\n"
5960 "Distribute a default route\n"
5961 "OSPF default metric\n"
5962 "OSPF metric\n"
5963 "Route map reference\n"
5964 "Pointer to route-map entries\n")
5965{
paul020709f2003-04-04 02:44:16 +00005966 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005967 int metric = -1;
5968
5969 /* Get metric value. */
5970 if (argc >= 1)
5971 if (!str2metric (argv[0], &metric))
5972 return CMD_WARNING;
5973
5974 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005975 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005976 else
paul020709f2003-04-04 02:44:16 +00005977 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005978
paul020709f2003-04-04 02:44:16 +00005979 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5980 -1, metric);
paul718e3742002-12-13 20:15:29 +00005981}
5982
5983/* Default information originate. */
5984DEFUN (ospf_default_information_originate_routemap,
5985 ospf_default_information_originate_routemap_cmd,
5986 "default-information originate route-map WORD",
5987 "Control distribution of default information\n"
5988 "Distribute a default route\n"
5989 "Route map reference\n"
5990 "Pointer to route-map entries\n")
5991{
paul020709f2003-04-04 02:44:16 +00005992 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005993
paul020709f2003-04-04 02:44:16 +00005994 if (argc == 1)
5995 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5996 else
5997 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5998
5999 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00006000}
6001
6002DEFUN (ospf_default_information_originate_type_metric_routemap,
6003 ospf_default_information_originate_type_metric_routemap_cmd,
6004 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6005 "Control distribution of default information\n"
6006 "Distribute a default route\n"
6007 "OSPF metric type for default routes\n"
6008 "Set OSPF External Type 1 metrics\n"
6009 "Set OSPF External Type 2 metrics\n"
6010 "OSPF default metric\n"
6011 "OSPF metric\n"
6012 "Route map reference\n"
6013 "Pointer to route-map entries\n")
6014{
paul020709f2003-04-04 02:44:16 +00006015 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006016 int type = -1;
6017 int metric = -1;
6018
6019 /* Get metric type. */
6020 if (argc >= 1)
6021 if (!str2metric_type (argv[0], &type))
6022 return CMD_WARNING;
6023
6024 /* Get metric value. */
6025 if (argc >= 2)
6026 if (!str2metric (argv[1], &metric))
6027 return CMD_WARNING;
6028
6029 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006030 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006031 else
paul020709f2003-04-04 02:44:16 +00006032 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006033
paul020709f2003-04-04 02:44:16 +00006034 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6035 type, metric);
paul718e3742002-12-13 20:15:29 +00006036}
6037
6038ALIAS (ospf_default_information_originate_type_metric_routemap,
6039 ospf_default_information_originate_type_metric_cmd,
6040 "default-information originate metric-type (1|2) metric <0-16777214>",
6041 "Control distribution of default information\n"
6042 "Distribute a default route\n"
6043 "OSPF metric type for default routes\n"
6044 "Set OSPF External Type 1 metrics\n"
6045 "Set OSPF External Type 2 metrics\n"
6046 "OSPF default metric\n"
6047 "OSPF metric\n")
6048
6049ALIAS (ospf_default_information_originate_type_metric_routemap,
6050 ospf_default_information_originate_type_cmd,
6051 "default-information originate metric-type (1|2)",
6052 "Control distribution of default information\n"
6053 "Distribute a default route\n"
6054 "OSPF metric type for default routes\n"
6055 "Set OSPF External Type 1 metrics\n"
6056 "Set OSPF External Type 2 metrics\n")
6057
6058DEFUN (ospf_default_information_originate_type_routemap,
6059 ospf_default_information_originate_type_routemap_cmd,
6060 "default-information originate metric-type (1|2) route-map WORD",
6061 "Control distribution of default information\n"
6062 "Distribute a default route\n"
6063 "OSPF metric type for default routes\n"
6064 "Set OSPF External Type 1 metrics\n"
6065 "Set OSPF External Type 2 metrics\n"
6066 "Route map reference\n"
6067 "Pointer to route-map entries\n")
6068{
paul020709f2003-04-04 02:44:16 +00006069 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006070 int type = -1;
6071
6072 /* Get metric type. */
6073 if (argc >= 1)
6074 if (!str2metric_type (argv[0], &type))
6075 return CMD_WARNING;
6076
6077 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006078 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006079 else
paul020709f2003-04-04 02:44:16 +00006080 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006081
paul020709f2003-04-04 02:44:16 +00006082 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6083 type, -1);
paul718e3742002-12-13 20:15:29 +00006084}
6085
6086DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6087 ospf_default_information_originate_always_metric_type_routemap_cmd,
6088 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6089 "Control distribution of default information\n"
6090 "Distribute a default route\n"
6091 "Always advertise default route\n"
6092 "OSPF default metric\n"
6093 "OSPF metric\n"
6094 "OSPF metric type for default routes\n"
6095 "Set OSPF External Type 1 metrics\n"
6096 "Set OSPF External Type 2 metrics\n"
6097 "Route map reference\n"
6098 "Pointer to route-map entries\n")
6099{
paul020709f2003-04-04 02:44:16 +00006100 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006101 int type = -1;
6102 int metric = -1;
6103
6104 /* Get metric value. */
6105 if (argc >= 1)
6106 if (!str2metric (argv[0], &metric))
6107 return CMD_WARNING;
6108
6109 /* Get metric type. */
6110 if (argc >= 2)
6111 if (!str2metric_type (argv[1], &type))
6112 return CMD_WARNING;
6113
6114 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006115 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006116 else
paul020709f2003-04-04 02:44:16 +00006117 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006118
paul020709f2003-04-04 02:44:16 +00006119 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006120 type, metric);
6121}
6122
6123ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6124 ospf_default_information_originate_always_metric_type_cmd,
6125 "default-information originate always metric <0-16777214> metric-type (1|2)",
6126 "Control distribution of default information\n"
6127 "Distribute a default route\n"
6128 "Always advertise default route\n"
6129 "OSPF default metric\n"
6130 "OSPF metric\n"
6131 "OSPF metric type for default routes\n"
6132 "Set OSPF External Type 1 metrics\n"
6133 "Set OSPF External Type 2 metrics\n")
6134
6135ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6136 ospf_default_information_originate_always_metric_cmd,
6137 "default-information originate always metric <0-16777214>",
6138 "Control distribution of default information\n"
6139 "Distribute a default route\n"
6140 "Always advertise default route\n"
6141 "OSPF default metric\n"
6142 "OSPF metric\n"
6143 "OSPF metric type for default routes\n")
6144
6145ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6146 ospf_default_information_originate_always_cmd,
6147 "default-information originate always",
6148 "Control distribution of default information\n"
6149 "Distribute a default route\n"
6150 "Always advertise default route\n")
6151
6152DEFUN (ospf_default_information_originate_always_metric_routemap,
6153 ospf_default_information_originate_always_metric_routemap_cmd,
6154 "default-information originate always metric <0-16777214> route-map WORD",
6155 "Control distribution of default information\n"
6156 "Distribute a default route\n"
6157 "Always advertise default route\n"
6158 "OSPF default metric\n"
6159 "OSPF metric\n"
6160 "Route map reference\n"
6161 "Pointer to route-map entries\n")
6162{
paul020709f2003-04-04 02:44:16 +00006163 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006164 int metric = -1;
6165
6166 /* Get metric value. */
6167 if (argc >= 1)
6168 if (!str2metric (argv[0], &metric))
6169 return CMD_WARNING;
6170
6171 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006172 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006173 else
paul020709f2003-04-04 02:44:16 +00006174 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006175
paul020709f2003-04-04 02:44:16 +00006176 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6177 -1, metric);
paul718e3742002-12-13 20:15:29 +00006178}
6179
6180DEFUN (ospf_default_information_originate_always_routemap,
6181 ospf_default_information_originate_always_routemap_cmd,
6182 "default-information originate always route-map WORD",
6183 "Control distribution of default information\n"
6184 "Distribute a default route\n"
6185 "Always advertise default route\n"
6186 "Route map reference\n"
6187 "Pointer to route-map entries\n")
6188{
paul020709f2003-04-04 02:44:16 +00006189 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006190
paul020709f2003-04-04 02:44:16 +00006191 if (argc == 1)
6192 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6193 else
6194 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6195
6196 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006197}
6198
6199DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6200 ospf_default_information_originate_always_type_metric_routemap_cmd,
6201 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6202 "Control distribution of default information\n"
6203 "Distribute a default route\n"
6204 "Always advertise default route\n"
6205 "OSPF metric type for default routes\n"
6206 "Set OSPF External Type 1 metrics\n"
6207 "Set OSPF External Type 2 metrics\n"
6208 "OSPF default metric\n"
6209 "OSPF metric\n"
6210 "Route map reference\n"
6211 "Pointer to route-map entries\n")
6212{
paul020709f2003-04-04 02:44:16 +00006213 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006214 int type = -1;
6215 int metric = -1;
6216
6217 /* Get metric type. */
6218 if (argc >= 1)
6219 if (!str2metric_type (argv[0], &type))
6220 return CMD_WARNING;
6221
6222 /* Get metric value. */
6223 if (argc >= 2)
6224 if (!str2metric (argv[1], &metric))
6225 return CMD_WARNING;
6226
6227 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006228 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006229 else
paul020709f2003-04-04 02:44:16 +00006230 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006231
paul020709f2003-04-04 02:44:16 +00006232 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006233 type, metric);
6234}
6235
6236ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6237 ospf_default_information_originate_always_type_metric_cmd,
6238 "default-information originate always metric-type (1|2) metric <0-16777214>",
6239 "Control distribution of default information\n"
6240 "Distribute a default route\n"
6241 "Always advertise default route\n"
6242 "OSPF metric type for default routes\n"
6243 "Set OSPF External Type 1 metrics\n"
6244 "Set OSPF External Type 2 metrics\n"
6245 "OSPF default metric\n"
6246 "OSPF metric\n")
6247
6248ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6249 ospf_default_information_originate_always_type_cmd,
6250 "default-information originate always metric-type (1|2)",
6251 "Control distribution of default information\n"
6252 "Distribute a default route\n"
6253 "Always advertise default route\n"
6254 "OSPF metric type for default routes\n"
6255 "Set OSPF External Type 1 metrics\n"
6256 "Set OSPF External Type 2 metrics\n")
6257
6258DEFUN (ospf_default_information_originate_always_type_routemap,
6259 ospf_default_information_originate_always_type_routemap_cmd,
6260 "default-information originate always metric-type (1|2) route-map WORD",
6261 "Control distribution of default information\n"
6262 "Distribute a default route\n"
6263 "Always advertise default route\n"
6264 "OSPF metric type for default routes\n"
6265 "Set OSPF External Type 1 metrics\n"
6266 "Set OSPF External Type 2 metrics\n"
6267 "Route map reference\n"
6268 "Pointer to route-map entries\n")
6269{
paul020709f2003-04-04 02:44:16 +00006270 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006271 int type = -1;
6272
6273 /* Get metric type. */
6274 if (argc >= 1)
6275 if (!str2metric_type (argv[0], &type))
6276 return CMD_WARNING;
6277
6278 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006279 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006280 else
paul020709f2003-04-04 02:44:16 +00006281 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006282
paul020709f2003-04-04 02:44:16 +00006283 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006284 type, -1);
6285}
6286
6287DEFUN (no_ospf_default_information_originate,
6288 no_ospf_default_information_originate_cmd,
6289 "no default-information originate",
6290 NO_STR
6291 "Control distribution of default information\n"
6292 "Distribute a default route\n")
6293{
paul68980082003-03-25 05:07:42 +00006294 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006295 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006296
6297 p.family = AF_INET;
6298 p.prefix.s_addr = 0;
6299 p.prefixlen = 0;
6300
ajs5339cfd2005-09-19 13:28:05 +00006301 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006302
6303 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6304 ospf_external_info_delete (DEFAULT_ROUTE, p);
6305 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6306 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6307 }
6308
paul020709f2003-04-04 02:44:16 +00006309 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6310 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006311}
6312
6313DEFUN (ospf_default_metric,
6314 ospf_default_metric_cmd,
6315 "default-metric <0-16777214>",
6316 "Set metric of redistributed routes\n"
6317 "Default metric\n")
6318{
paul68980082003-03-25 05:07:42 +00006319 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006320 int metric = -1;
6321
6322 if (!str2metric (argv[0], &metric))
6323 return CMD_WARNING;
6324
paul68980082003-03-25 05:07:42 +00006325 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006326
6327 return CMD_SUCCESS;
6328}
6329
6330DEFUN (no_ospf_default_metric,
6331 no_ospf_default_metric_cmd,
6332 "no default-metric",
6333 NO_STR
6334 "Set metric of redistributed routes\n")
6335{
paul68980082003-03-25 05:07:42 +00006336 struct ospf *ospf = vty->index;
6337
6338 ospf->default_metric = -1;
6339
paul718e3742002-12-13 20:15:29 +00006340 return CMD_SUCCESS;
6341}
6342
6343ALIAS (no_ospf_default_metric,
6344 no_ospf_default_metric_val_cmd,
6345 "no default-metric <0-16777214>",
6346 NO_STR
6347 "Set metric of redistributed routes\n"
6348 "Default metric\n")
6349
6350DEFUN (ospf_distance,
6351 ospf_distance_cmd,
6352 "distance <1-255>",
6353 "Define an administrative distance\n"
6354 "OSPF Administrative distance\n")
6355{
paul68980082003-03-25 05:07:42 +00006356 struct ospf *ospf = vty->index;
6357
6358 ospf->distance_all = atoi (argv[0]);
6359
paul718e3742002-12-13 20:15:29 +00006360 return CMD_SUCCESS;
6361}
6362
6363DEFUN (no_ospf_distance,
6364 no_ospf_distance_cmd,
6365 "no distance <1-255>",
6366 NO_STR
6367 "Define an administrative distance\n"
6368 "OSPF Administrative distance\n")
6369{
paul68980082003-03-25 05:07:42 +00006370 struct ospf *ospf = vty->index;
6371
6372 ospf->distance_all = 0;
6373
paul718e3742002-12-13 20:15:29 +00006374 return CMD_SUCCESS;
6375}
6376
6377DEFUN (no_ospf_distance_ospf,
6378 no_ospf_distance_ospf_cmd,
6379 "no distance ospf",
6380 NO_STR
6381 "Define an administrative distance\n"
6382 "OSPF Administrative distance\n"
6383 "OSPF Distance\n")
6384{
paul68980082003-03-25 05:07:42 +00006385 struct ospf *ospf = vty->index;
6386
6387 ospf->distance_intra = 0;
6388 ospf->distance_inter = 0;
6389 ospf->distance_external = 0;
6390
paul718e3742002-12-13 20:15:29 +00006391 return CMD_SUCCESS;
6392}
6393
6394DEFUN (ospf_distance_ospf_intra,
6395 ospf_distance_ospf_intra_cmd,
6396 "distance ospf intra-area <1-255>",
6397 "Define an administrative distance\n"
6398 "OSPF Administrative distance\n"
6399 "Intra-area routes\n"
6400 "Distance for intra-area routes\n")
6401{
paul68980082003-03-25 05:07:42 +00006402 struct ospf *ospf = vty->index;
6403
6404 ospf->distance_intra = atoi (argv[0]);
6405
paul718e3742002-12-13 20:15:29 +00006406 return CMD_SUCCESS;
6407}
6408
6409DEFUN (ospf_distance_ospf_intra_inter,
6410 ospf_distance_ospf_intra_inter_cmd,
6411 "distance ospf intra-area <1-255> inter-area <1-255>",
6412 "Define an administrative distance\n"
6413 "OSPF Administrative distance\n"
6414 "Intra-area routes\n"
6415 "Distance for intra-area routes\n"
6416 "Inter-area routes\n"
6417 "Distance for inter-area routes\n")
6418{
paul68980082003-03-25 05:07:42 +00006419 struct ospf *ospf = vty->index;
6420
6421 ospf->distance_intra = atoi (argv[0]);
6422 ospf->distance_inter = atoi (argv[1]);
6423
paul718e3742002-12-13 20:15:29 +00006424 return CMD_SUCCESS;
6425}
6426
6427DEFUN (ospf_distance_ospf_intra_external,
6428 ospf_distance_ospf_intra_external_cmd,
6429 "distance ospf intra-area <1-255> external <1-255>",
6430 "Define an administrative distance\n"
6431 "OSPF Administrative distance\n"
6432 "Intra-area routes\n"
6433 "Distance for intra-area routes\n"
6434 "External routes\n"
6435 "Distance for external routes\n")
6436{
paul68980082003-03-25 05:07:42 +00006437 struct ospf *ospf = vty->index;
6438
6439 ospf->distance_intra = atoi (argv[0]);
6440 ospf->distance_external = atoi (argv[1]);
6441
paul718e3742002-12-13 20:15:29 +00006442 return CMD_SUCCESS;
6443}
6444
6445DEFUN (ospf_distance_ospf_intra_inter_external,
6446 ospf_distance_ospf_intra_inter_external_cmd,
6447 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6448 "Define an administrative distance\n"
6449 "OSPF Administrative distance\n"
6450 "Intra-area routes\n"
6451 "Distance for intra-area routes\n"
6452 "Inter-area routes\n"
6453 "Distance for inter-area routes\n"
6454 "External routes\n"
6455 "Distance for external routes\n")
6456{
paul68980082003-03-25 05:07:42 +00006457 struct ospf *ospf = vty->index;
6458
6459 ospf->distance_intra = atoi (argv[0]);
6460 ospf->distance_inter = atoi (argv[1]);
6461 ospf->distance_external = atoi (argv[2]);
6462
paul718e3742002-12-13 20:15:29 +00006463 return CMD_SUCCESS;
6464}
6465
6466DEFUN (ospf_distance_ospf_intra_external_inter,
6467 ospf_distance_ospf_intra_external_inter_cmd,
6468 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6469 "Define an administrative distance\n"
6470 "OSPF Administrative distance\n"
6471 "Intra-area routes\n"
6472 "Distance for intra-area routes\n"
6473 "External routes\n"
6474 "Distance for external routes\n"
6475 "Inter-area routes\n"
6476 "Distance for inter-area routes\n")
6477{
paul68980082003-03-25 05:07:42 +00006478 struct ospf *ospf = vty->index;
6479
6480 ospf->distance_intra = atoi (argv[0]);
6481 ospf->distance_external = atoi (argv[1]);
6482 ospf->distance_inter = atoi (argv[2]);
6483
paul718e3742002-12-13 20:15:29 +00006484 return CMD_SUCCESS;
6485}
6486
6487DEFUN (ospf_distance_ospf_inter,
6488 ospf_distance_ospf_inter_cmd,
6489 "distance ospf inter-area <1-255>",
6490 "Define an administrative distance\n"
6491 "OSPF Administrative distance\n"
6492 "Inter-area routes\n"
6493 "Distance for inter-area routes\n")
6494{
paul68980082003-03-25 05:07:42 +00006495 struct ospf *ospf = vty->index;
6496
6497 ospf->distance_inter = atoi (argv[0]);
6498
paul718e3742002-12-13 20:15:29 +00006499 return CMD_SUCCESS;
6500}
6501
6502DEFUN (ospf_distance_ospf_inter_intra,
6503 ospf_distance_ospf_inter_intra_cmd,
6504 "distance ospf inter-area <1-255> intra-area <1-255>",
6505 "Define an administrative distance\n"
6506 "OSPF Administrative distance\n"
6507 "Inter-area routes\n"
6508 "Distance for inter-area routes\n"
6509 "Intra-area routes\n"
6510 "Distance for intra-area routes\n")
6511{
paul68980082003-03-25 05:07:42 +00006512 struct ospf *ospf = vty->index;
6513
6514 ospf->distance_inter = atoi (argv[0]);
6515 ospf->distance_intra = atoi (argv[1]);
6516
paul718e3742002-12-13 20:15:29 +00006517 return CMD_SUCCESS;
6518}
6519
6520DEFUN (ospf_distance_ospf_inter_external,
6521 ospf_distance_ospf_inter_external_cmd,
6522 "distance ospf inter-area <1-255> external <1-255>",
6523 "Define an administrative distance\n"
6524 "OSPF Administrative distance\n"
6525 "Inter-area routes\n"
6526 "Distance for inter-area routes\n"
6527 "External routes\n"
6528 "Distance for external routes\n")
6529{
paul68980082003-03-25 05:07:42 +00006530 struct ospf *ospf = vty->index;
6531
6532 ospf->distance_inter = atoi (argv[0]);
6533 ospf->distance_external = atoi (argv[1]);
6534
paul718e3742002-12-13 20:15:29 +00006535 return CMD_SUCCESS;
6536}
6537
6538DEFUN (ospf_distance_ospf_inter_intra_external,
6539 ospf_distance_ospf_inter_intra_external_cmd,
6540 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6541 "Define an administrative distance\n"
6542 "OSPF Administrative distance\n"
6543 "Inter-area routes\n"
6544 "Distance for inter-area routes\n"
6545 "Intra-area routes\n"
6546 "Distance for intra-area routes\n"
6547 "External routes\n"
6548 "Distance for external routes\n")
6549{
paul68980082003-03-25 05:07:42 +00006550 struct ospf *ospf = vty->index;
6551
6552 ospf->distance_inter = atoi (argv[0]);
6553 ospf->distance_intra = atoi (argv[1]);
6554 ospf->distance_external = atoi (argv[2]);
6555
paul718e3742002-12-13 20:15:29 +00006556 return CMD_SUCCESS;
6557}
6558
6559DEFUN (ospf_distance_ospf_inter_external_intra,
6560 ospf_distance_ospf_inter_external_intra_cmd,
6561 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6562 "Define an administrative distance\n"
6563 "OSPF Administrative distance\n"
6564 "Inter-area routes\n"
6565 "Distance for inter-area routes\n"
6566 "External routes\n"
6567 "Distance for external routes\n"
6568 "Intra-area routes\n"
6569 "Distance for intra-area routes\n")
6570{
paul68980082003-03-25 05:07:42 +00006571 struct ospf *ospf = vty->index;
6572
6573 ospf->distance_inter = atoi (argv[0]);
6574 ospf->distance_external = atoi (argv[1]);
6575 ospf->distance_intra = atoi (argv[2]);
6576
paul718e3742002-12-13 20:15:29 +00006577 return CMD_SUCCESS;
6578}
6579
6580DEFUN (ospf_distance_ospf_external,
6581 ospf_distance_ospf_external_cmd,
6582 "distance ospf external <1-255>",
6583 "Define an administrative distance\n"
6584 "OSPF Administrative distance\n"
6585 "External routes\n"
6586 "Distance for external routes\n")
6587{
paul68980082003-03-25 05:07:42 +00006588 struct ospf *ospf = vty->index;
6589
6590 ospf->distance_external = atoi (argv[0]);
6591
paul718e3742002-12-13 20:15:29 +00006592 return CMD_SUCCESS;
6593}
6594
6595DEFUN (ospf_distance_ospf_external_intra,
6596 ospf_distance_ospf_external_intra_cmd,
6597 "distance ospf external <1-255> intra-area <1-255>",
6598 "Define an administrative distance\n"
6599 "OSPF Administrative distance\n"
6600 "External routes\n"
6601 "Distance for external routes\n"
6602 "Intra-area routes\n"
6603 "Distance for intra-area routes\n")
6604{
paul68980082003-03-25 05:07:42 +00006605 struct ospf *ospf = vty->index;
6606
6607 ospf->distance_external = atoi (argv[0]);
6608 ospf->distance_intra = atoi (argv[1]);
6609
paul718e3742002-12-13 20:15:29 +00006610 return CMD_SUCCESS;
6611}
6612
6613DEFUN (ospf_distance_ospf_external_inter,
6614 ospf_distance_ospf_external_inter_cmd,
6615 "distance ospf external <1-255> inter-area <1-255>",
6616 "Define an administrative distance\n"
6617 "OSPF Administrative distance\n"
6618 "External routes\n"
6619 "Distance for external routes\n"
6620 "Inter-area routes\n"
6621 "Distance for inter-area routes\n")
6622{
paul68980082003-03-25 05:07:42 +00006623 struct ospf *ospf = vty->index;
6624
6625 ospf->distance_external = atoi (argv[0]);
6626 ospf->distance_inter = atoi (argv[1]);
6627
paul718e3742002-12-13 20:15:29 +00006628 return CMD_SUCCESS;
6629}
6630
6631DEFUN (ospf_distance_ospf_external_intra_inter,
6632 ospf_distance_ospf_external_intra_inter_cmd,
6633 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6634 "Define an administrative distance\n"
6635 "OSPF Administrative distance\n"
6636 "External routes\n"
6637 "Distance for external routes\n"
6638 "Intra-area routes\n"
6639 "Distance for intra-area routes\n"
6640 "Inter-area routes\n"
6641 "Distance for inter-area routes\n")
6642{
paul68980082003-03-25 05:07:42 +00006643 struct ospf *ospf = vty->index;
6644
6645 ospf->distance_external = atoi (argv[0]);
6646 ospf->distance_intra = atoi (argv[1]);
6647 ospf->distance_inter = atoi (argv[2]);
6648
paul718e3742002-12-13 20:15:29 +00006649 return CMD_SUCCESS;
6650}
6651
6652DEFUN (ospf_distance_ospf_external_inter_intra,
6653 ospf_distance_ospf_external_inter_intra_cmd,
6654 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6655 "Define an administrative distance\n"
6656 "OSPF Administrative distance\n"
6657 "External routes\n"
6658 "Distance for external routes\n"
6659 "Inter-area routes\n"
6660 "Distance for inter-area routes\n"
6661 "Intra-area routes\n"
6662 "Distance for intra-area routes\n")
6663{
paul68980082003-03-25 05:07:42 +00006664 struct ospf *ospf = vty->index;
6665
6666 ospf->distance_external = atoi (argv[0]);
6667 ospf->distance_inter = atoi (argv[1]);
6668 ospf->distance_intra = atoi (argv[2]);
6669
paul718e3742002-12-13 20:15:29 +00006670 return CMD_SUCCESS;
6671}
6672
6673DEFUN (ospf_distance_source,
6674 ospf_distance_source_cmd,
6675 "distance <1-255> A.B.C.D/M",
6676 "Administrative distance\n"
6677 "Distance value\n"
6678 "IP source prefix\n")
6679{
paul020709f2003-04-04 02:44:16 +00006680 struct ospf *ospf = vty->index;
6681
6682 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006683
paul718e3742002-12-13 20:15:29 +00006684 return CMD_SUCCESS;
6685}
6686
6687DEFUN (no_ospf_distance_source,
6688 no_ospf_distance_source_cmd,
6689 "no distance <1-255> A.B.C.D/M",
6690 NO_STR
6691 "Administrative distance\n"
6692 "Distance value\n"
6693 "IP source prefix\n")
6694{
paul020709f2003-04-04 02:44:16 +00006695 struct ospf *ospf = vty->index;
6696
6697 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6698
paul718e3742002-12-13 20:15:29 +00006699 return CMD_SUCCESS;
6700}
6701
6702DEFUN (ospf_distance_source_access_list,
6703 ospf_distance_source_access_list_cmd,
6704 "distance <1-255> A.B.C.D/M WORD",
6705 "Administrative distance\n"
6706 "Distance value\n"
6707 "IP source prefix\n"
6708 "Access list name\n")
6709{
paul020709f2003-04-04 02:44:16 +00006710 struct ospf *ospf = vty->index;
6711
6712 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6713
paul718e3742002-12-13 20:15:29 +00006714 return CMD_SUCCESS;
6715}
6716
6717DEFUN (no_ospf_distance_source_access_list,
6718 no_ospf_distance_source_access_list_cmd,
6719 "no distance <1-255> A.B.C.D/M WORD",
6720 NO_STR
6721 "Administrative distance\n"
6722 "Distance value\n"
6723 "IP source prefix\n"
6724 "Access list name\n")
6725{
paul020709f2003-04-04 02:44:16 +00006726 struct ospf *ospf = vty->index;
6727
6728 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6729
paul718e3742002-12-13 20:15:29 +00006730 return CMD_SUCCESS;
6731}
6732
vincentba682532005-09-29 13:52:57 +00006733DEFUN (ip_ospf_mtu_ignore,
6734 ip_ospf_mtu_ignore_addr_cmd,
6735 "ip ospf mtu-ignore A.B.C.D",
6736 "IP Information\n"
6737 "OSPF interface commands\n"
6738 "Disable mtu mismatch detection\n"
6739 "Address of interface")
6740{
6741 struct interface *ifp = vty->index;
6742 struct in_addr addr;
6743 int ret;
6744
6745 struct ospf_if_params *params;
6746 params = IF_DEF_PARAMS (ifp);
6747
6748 if (argc == 1)
6749 {
6750 ret = inet_aton(argv[0], &addr);
6751 if (!ret)
6752 {
6753 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6754 VTY_NEWLINE);
6755 return CMD_WARNING;
6756 }
6757 params = ospf_get_if_params (ifp, addr);
6758 ospf_if_update_params (ifp, addr);
6759 }
6760 params->mtu_ignore = 1;
6761 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6762 SET_IF_PARAM (params, mtu_ignore);
6763 else
6764 {
6765 UNSET_IF_PARAM (params, mtu_ignore);
6766 if (params != IF_DEF_PARAMS (ifp))
6767 {
6768 ospf_free_if_params (ifp, addr);
6769 ospf_if_update_params (ifp, addr);
6770 }
6771 }
6772 return CMD_SUCCESS;
6773}
6774
6775ALIAS (ip_ospf_mtu_ignore,
6776 ip_ospf_mtu_ignore_cmd,
6777 "ip ospf mtu-ignore",
6778 "IP Information\n"
6779 "OSPF interface commands\n"
6780 "Disable mtu mismatch detection\n")
6781
6782
6783DEFUN (no_ip_ospf_mtu_ignore,
6784 no_ip_ospf_mtu_ignore_addr_cmd,
6785 "no ip ospf mtu-ignore A.B.C.D",
6786 "IP Information\n"
6787 "OSPF interface commands\n"
6788 "Disable mtu mismatch detection\n"
6789 "Address of interface")
6790{
6791 struct interface *ifp = vty->index;
6792 struct in_addr addr;
6793 int ret;
6794
6795 struct ospf_if_params *params;
6796 params = IF_DEF_PARAMS (ifp);
6797
6798 if (argc == 1)
6799 {
6800 ret = inet_aton(argv[0], &addr);
6801 if (!ret)
6802 {
6803 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6804 VTY_NEWLINE);
6805 return CMD_WARNING;
6806 }
6807 params = ospf_get_if_params (ifp, addr);
6808 ospf_if_update_params (ifp, addr);
6809 }
6810 params->mtu_ignore = 0;
6811 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6812 SET_IF_PARAM (params, mtu_ignore);
6813 else
6814 {
6815 UNSET_IF_PARAM (params, mtu_ignore);
6816 if (params != IF_DEF_PARAMS (ifp))
6817 {
6818 ospf_free_if_params (ifp, addr);
6819 ospf_if_update_params (ifp, addr);
6820 }
6821 }
6822 return CMD_SUCCESS;
6823}
6824
6825ALIAS (no_ip_ospf_mtu_ignore,
6826 no_ip_ospf_mtu_ignore_cmd,
6827 "no ip ospf mtu-ignore",
6828 "IP Information\n"
6829 "OSPF interface commands\n"
6830 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00006831
6832DEFUN (ospf_max_metric_router_lsa_admin,
6833 ospf_max_metric_router_lsa_admin_cmd,
6834 "max-metric router-lsa administrative",
6835 "OSPF maximum / infinite-distance metric\n"
6836 "Advertise own Router-LSA with infinite distance (stub router)\n"
6837 "Administratively applied, for an indefinite period\n")
6838{
6839 struct listnode *ln;
6840 struct ospf_area *area;
6841 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006842
paul88d6cf32005-10-29 12:50:09 +00006843 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6844 {
6845 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6846
6847 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
6848 ospf_router_lsa_timer_add (area);
6849 }
6850 return CMD_SUCCESS;
6851}
6852
6853DEFUN (no_ospf_max_metric_router_lsa_admin,
6854 no_ospf_max_metric_router_lsa_admin_cmd,
6855 "no max-metric router-lsa administrative",
6856 NO_STR
6857 "OSPF maximum / infinite-distance metric\n"
6858 "Advertise own Router-LSA with infinite distance (stub router)\n"
6859 "Administratively applied, for an indefinite period\n")
6860{
6861 struct listnode *ln;
6862 struct ospf_area *area;
6863 struct ospf *ospf = vty->index;
6864
6865 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6866 {
6867 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6868
6869 /* Don't trample on the start-up stub timer */
6870 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6871 && !area->t_stub_router)
6872 {
6873 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6874 ospf_router_lsa_timer_add (area);
6875 }
6876 }
6877 return CMD_SUCCESS;
6878}
6879
6880DEFUN (ospf_max_metric_router_lsa_startup,
6881 ospf_max_metric_router_lsa_startup_cmd,
6882 "max-metric router-lsa on-startup <5-86400>",
6883 "OSPF maximum / infinite-distance metric\n"
6884 "Advertise own Router-LSA with infinite distance (stub router)\n"
6885 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6886 "Time (seconds) to advertise self as stub-router\n")
6887{
6888 unsigned int seconds;
6889 struct ospf *ospf = vty->index;
6890
6891 if (argc != 1)
6892 {
6893 vty_out (vty, "%% Must supply stub-router period");
6894 return CMD_WARNING;
6895 }
6896
6897 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6898
6899 ospf->stub_router_startup_time = seconds;
6900
6901 return CMD_SUCCESS;
6902}
6903
6904DEFUN (no_ospf_max_metric_router_lsa_startup,
6905 no_ospf_max_metric_router_lsa_startup_cmd,
6906 "no max-metric router-lsa on-startup",
6907 NO_STR
6908 "OSPF maximum / infinite-distance metric\n"
6909 "Advertise own Router-LSA with infinite distance (stub router)\n"
6910 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6911{
6912 struct listnode *ln;
6913 struct ospf_area *area;
6914 struct ospf *ospf = vty->index;
6915
6916 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6917
6918 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6919 {
6920 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6921 OSPF_TIMER_OFF (area->t_stub_router);
6922
6923 /* Don't trample on admin stub routed */
6924 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6925 {
6926 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6927 ospf_router_lsa_timer_add (area);
6928 }
6929 }
6930 return CMD_SUCCESS;
6931}
6932
6933DEFUN (ospf_max_metric_router_lsa_shutdown,
6934 ospf_max_metric_router_lsa_shutdown_cmd,
6935 "max-metric router-lsa on-shutdown <5-86400>",
6936 "OSPF maximum / infinite-distance metric\n"
6937 "Advertise own Router-LSA with infinite distance (stub router)\n"
6938 "Advertise stub-router prior to full shutdown of OSPF\n"
6939 "Time (seconds) to wait till full shutdown\n")
6940{
6941 unsigned int seconds;
6942 struct ospf *ospf = vty->index;
6943
6944 if (argc != 1)
6945 {
6946 vty_out (vty, "%% Must supply stub-router shutdown period");
6947 return CMD_WARNING;
6948 }
6949
6950 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6951
6952 ospf->stub_router_shutdown_time = seconds;
6953
6954 return CMD_SUCCESS;
6955}
6956
6957DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6958 no_ospf_max_metric_router_lsa_shutdown_cmd,
6959 "no max-metric router-lsa on-shutdown",
6960 NO_STR
6961 "OSPF maximum / infinite-distance metric\n"
6962 "Advertise own Router-LSA with infinite distance (stub router)\n"
6963 "Advertise stub-router prior to full shutdown of OSPF\n")
6964{
6965 struct ospf *ospf = vty->index;
6966
6967 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6968
6969 return CMD_SUCCESS;
6970}
6971
6972static void
6973config_write_stub_router (struct vty *vty, struct ospf *ospf)
6974{
6975 struct listnode *ln;
6976 struct ospf_area *area;
6977
6978 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6979 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6980 ospf->stub_router_startup_time, VTY_NEWLINE);
6981 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6982 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6983 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6984 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6985 {
6986 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6987 {
6988 vty_out (vty, " max-metric router-lsa administrative%s",
6989 VTY_NEWLINE);
6990 break;
6991 }
6992 }
6993 return;
6994}
6995
paul4dadc292005-05-06 21:37:42 +00006996static void
paul718e3742002-12-13 20:15:29 +00006997show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6998{
6999 struct route_node *rn;
7000 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007001 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007002 struct ospf_path *path;
7003
7004 vty_out (vty, "============ OSPF network routing table ============%s",
7005 VTY_NEWLINE);
7006
7007 for (rn = route_top (rt); rn; rn = route_next (rn))
7008 if ((or = rn->info) != NULL)
7009 {
7010 char buf1[19];
7011 snprintf (buf1, 19, "%s/%d",
7012 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7013
7014 switch (or->path_type)
7015 {
7016 case OSPF_PATH_INTER_AREA:
7017 if (or->type == OSPF_DESTINATION_NETWORK)
7018 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7019 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7020 else if (or->type == OSPF_DESTINATION_DISCARD)
7021 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7022 break;
7023 case OSPF_PATH_INTRA_AREA:
7024 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7025 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7026 break;
7027 default:
7028 break;
7029 }
7030
7031 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007032 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007033 {
hasso54bedb52005-08-17 13:31:47 +00007034 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00007035 {
7036 if (path->nexthop.s_addr == 0)
7037 vty_out (vty, "%24s directly attached to %s%s",
7038 "", path->oi->ifp->name, VTY_NEWLINE);
7039 else
7040 vty_out (vty, "%24s via %s, %s%s", "",
7041 inet_ntoa (path->nexthop), path->oi->ifp->name,
7042 VTY_NEWLINE);
7043 }
7044 }
paul718e3742002-12-13 20:15:29 +00007045 }
7046 vty_out (vty, "%s", VTY_NEWLINE);
7047}
7048
paul4dadc292005-05-06 21:37:42 +00007049static void
paul718e3742002-12-13 20:15:29 +00007050show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7051{
7052 struct route_node *rn;
7053 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007054 struct listnode *pnode;
7055 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007056 struct ospf_path *path;
7057
7058 vty_out (vty, "============ OSPF router routing table =============%s",
7059 VTY_NEWLINE);
7060 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7061 if (rn->info)
7062 {
7063 int flag = 0;
7064
7065 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7066
paul1eb8ef22005-04-07 07:30:20 +00007067 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7068 {
7069 if (flag++)
7070 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007071
paul1eb8ef22005-04-07 07:30:20 +00007072 /* Show path. */
7073 vty_out (vty, "%s [%d] area: %s",
7074 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7075 or->cost, inet_ntoa (or->u.std.area_id));
7076 /* Show flags. */
7077 vty_out (vty, "%s%s%s",
7078 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7079 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7080 VTY_NEWLINE);
7081
7082 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7083 {
hasso54bedb52005-08-17 13:31:47 +00007084 if (path->oi != NULL && ospf_if_exists(path->oi))
7085 {
7086 if (path->nexthop.s_addr == 0)
7087 vty_out (vty, "%24s directly attached to %s%s",
7088 "", path->oi->ifp->name, VTY_NEWLINE);
7089 else
7090 vty_out (vty, "%24s via %s, %s%s", "",
7091 inet_ntoa (path->nexthop),
7092 path->oi->ifp->name, VTY_NEWLINE);
7093 }
paul1eb8ef22005-04-07 07:30:20 +00007094 }
7095 }
paul718e3742002-12-13 20:15:29 +00007096 }
7097 vty_out (vty, "%s", VTY_NEWLINE);
7098}
7099
paul4dadc292005-05-06 21:37:42 +00007100static void
paul718e3742002-12-13 20:15:29 +00007101show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7102{
7103 struct route_node *rn;
7104 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007105 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007106 struct ospf_path *path;
7107
7108 vty_out (vty, "============ OSPF external routing table ===========%s",
7109 VTY_NEWLINE);
7110 for (rn = route_top (rt); rn; rn = route_next (rn))
7111 if ((er = rn->info) != NULL)
7112 {
7113 char buf1[19];
7114 snprintf (buf1, 19, "%s/%d",
7115 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7116
7117 switch (er->path_type)
7118 {
7119 case OSPF_PATH_TYPE1_EXTERNAL:
7120 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7121 er->cost, er->u.ext.tag, VTY_NEWLINE);
7122 break;
7123 case OSPF_PATH_TYPE2_EXTERNAL:
7124 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7125 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7126 break;
7127 }
7128
paul1eb8ef22005-04-07 07:30:20 +00007129 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007130 {
hasso54bedb52005-08-17 13:31:47 +00007131 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00007132 {
7133 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007134 vty_out (vty, "%24s directly attached to %s%s",
7135 "", path->oi->ifp->name, VTY_NEWLINE);
7136 else
7137 vty_out (vty, "%24s via %s, %s%s", "",
7138 inet_ntoa (path->nexthop), path->oi->ifp->name,
7139 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007140 }
7141 }
7142 }
7143 vty_out (vty, "%s", VTY_NEWLINE);
7144}
7145
paul718e3742002-12-13 20:15:29 +00007146DEFUN (show_ip_ospf_border_routers,
7147 show_ip_ospf_border_routers_cmd,
7148 "show ip ospf border-routers",
7149 SHOW_STR
7150 IP_STR
7151 "show all the ABR's and ASBR's\n"
7152 "for this area\n")
7153{
paul020709f2003-04-04 02:44:16 +00007154 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007155
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007156 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007157 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007158 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007159 return CMD_SUCCESS;
7160 }
7161
paul68980082003-03-25 05:07:42 +00007162 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007163 {
7164 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7165 return CMD_SUCCESS;
7166 }
7167
7168 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007169 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007170
7171 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007172 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007173
7174 return CMD_SUCCESS;
7175}
paul718e3742002-12-13 20:15:29 +00007176
7177DEFUN (show_ip_ospf_route,
7178 show_ip_ospf_route_cmd,
7179 "show ip ospf route",
7180 SHOW_STR
7181 IP_STR
7182 "OSPF information\n"
7183 "OSPF routing table\n")
7184{
paul020709f2003-04-04 02:44:16 +00007185 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007186
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007187 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007188 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007189 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007190 return CMD_SUCCESS;
7191 }
7192
paul68980082003-03-25 05:07:42 +00007193 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007194 {
7195 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7196 return CMD_SUCCESS;
7197 }
7198
7199 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007200 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007201
7202 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007203 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007204
7205 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007206 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007207
7208 return CMD_SUCCESS;
7209}
7210
7211
hassoeb1ce602004-10-08 08:17:22 +00007212const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007213{
7214 "unknown",
7215 "standard",
7216 "ibm",
7217 "cisco",
7218 "shortcut"
7219};
7220
hassoeb1ce602004-10-08 08:17:22 +00007221const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007222{
7223 "default",
7224 "enable",
7225 "disable"
7226};
7227
7228
paul4dadc292005-05-06 21:37:42 +00007229static void
paul718e3742002-12-13 20:15:29 +00007230area_id2str (char *buf, int length, struct ospf_area *area)
7231{
7232 memset (buf, 0, length);
7233
7234 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7235 strncpy (buf, inet_ntoa (area->area_id), length);
7236 else
7237 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7238}
7239
7240
hassoeb1ce602004-10-08 08:17:22 +00007241const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007242{
7243 "unknown", /* should never be used. */
7244 "point-to-point",
7245 "broadcast",
7246 "non-broadcast",
7247 "point-to-multipoint",
7248 "virtual-link", /* should never be used. */
7249 "loopback"
7250};
7251
7252/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007253static int
paul718e3742002-12-13 20:15:29 +00007254config_write_interface (struct vty *vty)
7255{
hasso52dc7ee2004-09-23 19:18:23 +00007256 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007257 struct interface *ifp;
7258 struct crypt_key *ck;
7259 int write = 0;
7260 struct route_node *rn = NULL;
7261 struct ospf_if_params *params;
7262
paul1eb8ef22005-04-07 07:30:20 +00007263 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007264 {
paul718e3742002-12-13 20:15:29 +00007265 if (memcmp (ifp->name, "VLINK", 5) == 0)
7266 continue;
7267
7268 vty_out (vty, "!%s", VTY_NEWLINE);
7269 vty_out (vty, "interface %s%s", ifp->name,
7270 VTY_NEWLINE);
7271 if (ifp->desc)
7272 vty_out (vty, " description %s%s", ifp->desc,
7273 VTY_NEWLINE);
7274
7275 write++;
7276
7277 params = IF_DEF_PARAMS (ifp);
7278
7279 do {
7280 /* Interface Network print. */
7281 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007282 params->type != OSPF_IFTYPE_LOOPBACK)
7283 {
ajsbc18d612004-12-15 15:07:19 +00007284 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007285 {
7286 vty_out (vty, " ip ospf network %s",
7287 ospf_int_type_str[params->type]);
7288 if (params != IF_DEF_PARAMS (ifp))
7289 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7290 vty_out (vty, "%s", VTY_NEWLINE);
7291 }
paul718e3742002-12-13 20:15:29 +00007292 }
7293
7294 /* OSPF interface authentication print */
7295 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7296 params->auth_type != OSPF_AUTH_NOTSET)
7297 {
hassoeb1ce602004-10-08 08:17:22 +00007298 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007299
7300 /* Translation tables are not that much help here due to syntax
7301 of the simple option */
7302 switch (params->auth_type)
7303 {
7304
7305 case OSPF_AUTH_NULL:
7306 auth_str = " null";
7307 break;
7308
7309 case OSPF_AUTH_SIMPLE:
7310 auth_str = "";
7311 break;
7312
7313 case OSPF_AUTH_CRYPTOGRAPHIC:
7314 auth_str = " message-digest";
7315 break;
7316
7317 default:
7318 auth_str = "";
7319 break;
7320 }
7321
7322 vty_out (vty, " ip ospf authentication%s", auth_str);
7323 if (params != IF_DEF_PARAMS (ifp))
7324 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7325 vty_out (vty, "%s", VTY_NEWLINE);
7326 }
7327
7328 /* Simple Authentication Password print. */
7329 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7330 params->auth_simple[0] != '\0')
7331 {
7332 vty_out (vty, " ip ospf authentication-key %s",
7333 params->auth_simple);
7334 if (params != IF_DEF_PARAMS (ifp))
7335 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7336 vty_out (vty, "%s", VTY_NEWLINE);
7337 }
7338
7339 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007340 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007341 {
paul718e3742002-12-13 20:15:29 +00007342 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7343 ck->key_id, ck->auth_key);
7344 if (params != IF_DEF_PARAMS (ifp))
7345 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7346 vty_out (vty, "%s", VTY_NEWLINE);
7347 }
7348
7349 /* Interface Output Cost print. */
7350 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7351 {
7352 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
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
7358 /* Hello Interval print. */
7359 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7360 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7361 {
7362 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7363 if (params != IF_DEF_PARAMS (ifp))
7364 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7365 vty_out (vty, "%s", VTY_NEWLINE);
7366 }
7367
7368
7369 /* Router Dead Interval print. */
7370 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7371 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7372 {
paulf9ad9372005-10-21 00:45:17 +00007373 vty_out (vty, " ip ospf dead-interval ");
7374
7375 /* fast hello ? */
7376 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7377 vty_out (vty, "minimal hello-multiplier %d",
7378 params->fast_hello);
7379 else
7380 vty_out (vty, "%u", params->v_wait);
7381
paul718e3742002-12-13 20:15:29 +00007382 if (params != IF_DEF_PARAMS (ifp))
7383 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7384 vty_out (vty, "%s", VTY_NEWLINE);
7385 }
7386
7387 /* Router Priority print. */
7388 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7389 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7390 {
7391 vty_out (vty, " ip ospf priority %u", params->priority);
7392 if (params != IF_DEF_PARAMS (ifp))
7393 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7394 vty_out (vty, "%s", VTY_NEWLINE);
7395 }
7396
7397 /* Retransmit Interval print. */
7398 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7399 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7400 {
7401 vty_out (vty, " ip ospf retransmit-interval %u",
7402 params->retransmit_interval);
7403 if (params != IF_DEF_PARAMS (ifp))
7404 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7405 vty_out (vty, "%s", VTY_NEWLINE);
7406 }
7407
7408 /* Transmit Delay print. */
7409 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7410 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7411 {
7412 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7413 if (params != IF_DEF_PARAMS (ifp))
7414 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7415 vty_out (vty, "%s", VTY_NEWLINE);
7416 }
7417
vincentba682532005-09-29 13:52:57 +00007418 /* MTU ignore print. */
7419 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7420 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7421 {
7422 if (params->mtu_ignore == 0)
7423 vty_out (vty, " no ip ospf mtu-ignore");
7424 else
7425 vty_out (vty, " ip ospf mtu-ignore");
7426 if (params != IF_DEF_PARAMS (ifp))
7427 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7428 vty_out (vty, "%s", VTY_NEWLINE);
7429 }
7430
7431
paul718e3742002-12-13 20:15:29 +00007432 while (1)
7433 {
7434 if (rn == NULL)
7435 rn = route_top (IF_OIFS_PARAMS (ifp));
7436 else
7437 rn = route_next (rn);
7438
7439 if (rn == NULL)
7440 break;
7441 params = rn->info;
7442 if (params != NULL)
7443 break;
7444 }
7445 } while (rn);
7446
7447#ifdef HAVE_OPAQUE_LSA
7448 ospf_opaque_config_write_if (vty, ifp);
7449#endif /* HAVE_OPAQUE_LSA */
7450 }
7451
7452 return write;
7453}
7454
paul4dadc292005-05-06 21:37:42 +00007455static int
paul68980082003-03-25 05:07:42 +00007456config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007457{
7458 struct route_node *rn;
7459 u_char buf[INET_ADDRSTRLEN];
7460
7461 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007462 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007463 if (rn->info)
7464 {
7465 struct ospf_network *n = rn->info;
7466
7467 memset (buf, 0, INET_ADDRSTRLEN);
7468
7469 /* Create Area ID string by specified Area ID format. */
7470 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007471 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007472 else
hassoc9e52be2004-09-26 16:09:34 +00007473 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007474 (unsigned long int) ntohl (n->area_id.s_addr));
7475
7476 /* Network print. */
7477 vty_out (vty, " network %s/%d area %s%s",
7478 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7479 buf, VTY_NEWLINE);
7480 }
7481
7482 return 0;
7483}
7484
paul4dadc292005-05-06 21:37:42 +00007485static int
paul68980082003-03-25 05:07:42 +00007486config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007487{
hasso52dc7ee2004-09-23 19:18:23 +00007488 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007489 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007490 u_char buf[INET_ADDRSTRLEN];
7491
7492 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007493 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007494 {
paul718e3742002-12-13 20:15:29 +00007495 struct route_node *rn1;
7496
hassoc9e52be2004-09-26 16:09:34 +00007497 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007498
7499 if (area->auth_type != OSPF_AUTH_NULL)
7500 {
7501 if (area->auth_type == OSPF_AUTH_SIMPLE)
7502 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7503 else
7504 vty_out (vty, " area %s authentication message-digest%s",
7505 buf, VTY_NEWLINE);
7506 }
7507
7508 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7509 vty_out (vty, " area %s shortcut %s%s", buf,
7510 ospf_shortcut_mode_str[area->shortcut_configured],
7511 VTY_NEWLINE);
7512
7513 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007514 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007515 )
7516 {
paulb0a053b2003-06-22 09:04:47 +00007517 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007518 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007519 else if (area->external_routing == OSPF_AREA_NSSA)
7520 {
7521 vty_out (vty, " area %s nssa", buf);
7522 switch (area->NSSATranslatorRole)
7523 {
7524 case OSPF_NSSA_ROLE_NEVER:
7525 vty_out (vty, " translate-never");
7526 break;
7527 case OSPF_NSSA_ROLE_ALWAYS:
7528 vty_out (vty, " translate-always");
7529 break;
7530 case OSPF_NSSA_ROLE_CANDIDATE:
7531 default:
7532 vty_out (vty, " translate-candidate");
7533 }
7534 }
paul718e3742002-12-13 20:15:29 +00007535
7536 if (area->no_summary)
7537 vty_out (vty, " no-summary");
7538
7539 vty_out (vty, "%s", VTY_NEWLINE);
7540
7541 if (area->default_cost != 1)
7542 vty_out (vty, " area %s default-cost %d%s", buf,
7543 area->default_cost, VTY_NEWLINE);
7544 }
7545
7546 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7547 if (rn1->info)
7548 {
7549 struct ospf_area_range *range = rn1->info;
7550
7551 vty_out (vty, " area %s range %s/%d", buf,
7552 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7553
paul6c835672004-10-11 11:00:30 +00007554 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007555 vty_out (vty, " cost %d", range->cost_config);
7556
7557 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7558 vty_out (vty, " not-advertise");
7559
7560 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7561 vty_out (vty, " substitute %s/%d",
7562 inet_ntoa (range->subst_addr), range->subst_masklen);
7563
7564 vty_out (vty, "%s", VTY_NEWLINE);
7565 }
7566
7567 if (EXPORT_NAME (area))
7568 vty_out (vty, " area %s export-list %s%s", buf,
7569 EXPORT_NAME (area), VTY_NEWLINE);
7570
7571 if (IMPORT_NAME (area))
7572 vty_out (vty, " area %s import-list %s%s", buf,
7573 IMPORT_NAME (area), VTY_NEWLINE);
7574
7575 if (PREFIX_NAME_IN (area))
7576 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7577 PREFIX_NAME_IN (area), VTY_NEWLINE);
7578
7579 if (PREFIX_NAME_OUT (area))
7580 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7581 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7582 }
7583
7584 return 0;
7585}
7586
paul4dadc292005-05-06 21:37:42 +00007587static int
paul68980082003-03-25 05:07:42 +00007588config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007589{
7590 struct ospf_nbr_nbma *nbr_nbma;
7591 struct route_node *rn;
7592
7593 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007594 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007595 if ((nbr_nbma = rn->info))
7596 {
7597 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7598
7599 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7600 vty_out (vty, " priority %d", nbr_nbma->priority);
7601
7602 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7603 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7604
7605 vty_out (vty, "%s", VTY_NEWLINE);
7606 }
7607
7608 return 0;
7609}
7610
paul4dadc292005-05-06 21:37:42 +00007611static int
paul68980082003-03-25 05:07:42 +00007612config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007613{
hasso52dc7ee2004-09-23 19:18:23 +00007614 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007615 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007616 u_char buf[INET_ADDRSTRLEN];
7617
7618 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007619 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007620 {
hasso52dc7ee2004-09-23 19:18:23 +00007621 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007622 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007623 struct ospf_interface *oi;
7624
7625 if (vl_data != NULL)
7626 {
7627 memset (buf, 0, INET_ADDRSTRLEN);
7628
7629 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007630 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007631 else
hassoc9e52be2004-09-26 16:09:34 +00007632 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007633 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7634 oi = vl_data->vl_oi;
7635
7636 /* timers */
7637 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7638 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7639 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7640 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7641 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7642 buf,
7643 inet_ntoa (vl_data->vl_peer),
7644 OSPF_IF_PARAM (oi, v_hello),
7645 OSPF_IF_PARAM (oi, retransmit_interval),
7646 OSPF_IF_PARAM (oi, transmit_delay),
7647 OSPF_IF_PARAM (oi, v_wait),
7648 VTY_NEWLINE);
7649 else
7650 vty_out (vty, " area %s virtual-link %s%s", buf,
7651 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7652 /* Auth key */
7653 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7654 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7655 buf,
7656 inet_ntoa (vl_data->vl_peer),
7657 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7658 VTY_NEWLINE);
7659 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007660 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7661 n2, ck))
7662 vty_out (vty, " area %s virtual-link %s"
7663 " message-digest-key %d md5 %s%s",
7664 buf,
7665 inet_ntoa (vl_data->vl_peer),
7666 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007667
7668 }
7669 }
7670
7671 return 0;
7672}
7673
7674
paul4dadc292005-05-06 21:37:42 +00007675static int
paul68980082003-03-25 05:07:42 +00007676config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007677{
7678 int type;
7679
7680 /* redistribute print. */
7681 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7682 if (type != zclient->redist_default && zclient->redist[type])
7683 {
ajsf52d13c2005-10-01 17:38:06 +00007684 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007685 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007686 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007687
paul68980082003-03-25 05:07:42 +00007688 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007689 vty_out (vty, " metric-type 1");
7690
paul020709f2003-04-04 02:44:16 +00007691 if (ROUTEMAP_NAME (ospf, type))
7692 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007693
7694 vty_out (vty, "%s", VTY_NEWLINE);
7695 }
7696
7697 return 0;
7698}
7699
paul4dadc292005-05-06 21:37:42 +00007700static int
paul68980082003-03-25 05:07:42 +00007701config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007702{
paul68980082003-03-25 05:07:42 +00007703 if (ospf->default_metric != -1)
7704 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007705 VTY_NEWLINE);
7706 return 0;
7707}
7708
paul4dadc292005-05-06 21:37:42 +00007709static int
paul68980082003-03-25 05:07:42 +00007710config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007711{
7712 int type;
7713
paul68980082003-03-25 05:07:42 +00007714 if (ospf)
paul718e3742002-12-13 20:15:29 +00007715 {
7716 /* distribute-list print. */
7717 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007718 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007719 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007720 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007721 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007722
7723 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007724 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007725 {
paulc42c1772006-01-10 20:36:49 +00007726 vty_out (vty, " default-information originate");
7727 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7728 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007729
paul68980082003-03-25 05:07:42 +00007730 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007731 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007732 ospf->dmetric[DEFAULT_ROUTE].value);
7733 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007734 vty_out (vty, " metric-type 1");
7735
paul020709f2003-04-04 02:44:16 +00007736 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7737 vty_out (vty, " route-map %s",
7738 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007739
7740 vty_out (vty, "%s", VTY_NEWLINE);
7741 }
7742
7743 }
7744
7745 return 0;
7746}
7747
paul4dadc292005-05-06 21:37:42 +00007748static int
paul68980082003-03-25 05:07:42 +00007749config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007750{
7751 struct route_node *rn;
7752 struct ospf_distance *odistance;
7753
paul68980082003-03-25 05:07:42 +00007754 if (ospf->distance_all)
7755 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007756
paul68980082003-03-25 05:07:42 +00007757 if (ospf->distance_intra
7758 || ospf->distance_inter
7759 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007760 {
7761 vty_out (vty, " distance ospf");
7762
paul68980082003-03-25 05:07:42 +00007763 if (ospf->distance_intra)
7764 vty_out (vty, " intra-area %d", ospf->distance_intra);
7765 if (ospf->distance_inter)
7766 vty_out (vty, " inter-area %d", ospf->distance_inter);
7767 if (ospf->distance_external)
7768 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007769
7770 vty_out (vty, "%s", VTY_NEWLINE);
7771 }
7772
paul68980082003-03-25 05:07:42 +00007773 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007774 if ((odistance = rn->info) != NULL)
7775 {
7776 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7777 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7778 odistance->access_list ? odistance->access_list : "",
7779 VTY_NEWLINE);
7780 }
7781 return 0;
7782}
7783
7784/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007785static int
paul718e3742002-12-13 20:15:29 +00007786ospf_config_write (struct vty *vty)
7787{
paul020709f2003-04-04 02:44:16 +00007788 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007789 struct interface *ifp;
7790 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007791 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007792 int write = 0;
7793
paul020709f2003-04-04 02:44:16 +00007794 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007795 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007796 {
7797 /* `router ospf' print. */
7798 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7799
7800 write++;
7801
paul68980082003-03-25 05:07:42 +00007802 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007803 return write;
7804
7805 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007806 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007807 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007808 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007809
7810 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007811 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007812 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007813 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007814
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007815 /* log-adjacency-changes flag print. */
7816 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7817 {
7818 vty_out(vty, " log-adjacency-changes");
7819 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7820 vty_out(vty, " detail");
7821 vty_out(vty, "%s", VTY_NEWLINE);
7822 }
7823
paul718e3742002-12-13 20:15:29 +00007824 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007825 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007826 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7827
7828 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007829 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007830 {
7831 vty_out (vty, "! Important: ensure reference bandwidth "
7832 "is consistent across all routers%s", VTY_NEWLINE);
7833 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7834 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7835 }
paul718e3742002-12-13 20:15:29 +00007836
7837 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007838 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007839 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7840 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7841 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007842 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007843 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007844
7845 /* Max-metric router-lsa print */
7846 config_write_stub_router (vty, ospf);
7847
paul718e3742002-12-13 20:15:29 +00007848 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007849 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007850 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007851 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007852
7853 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007854 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007855
7856 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007857 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7858 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7859 vty_out (vty, " passive-interface %s%s",
7860 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007861
paul1eb8ef22005-04-07 07:30:20 +00007862 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7863 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7864 oi->params->passive_interface == OSPF_IF_PASSIVE)
7865 vty_out (vty, " passive-interface %s %s%s",
7866 oi->ifp->name,
7867 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007868
7869 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007870 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007871
7872 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007873 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007874
7875 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007876 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007877
7878 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007879 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007880
7881 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007882 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007883
7884 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007885 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007886
7887 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007888 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007889
7890#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007891 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007892#endif /* HAVE_OPAQUE_LSA */
7893 }
7894
7895 return write;
7896}
7897
7898void
paul4dadc292005-05-06 21:37:42 +00007899ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007900{
7901 /* "show ip ospf" commands. */
7902 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7903 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7904
7905 /* "show ip ospf database" commands. */
7906 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7907 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7908 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7909 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7910 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7911 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7912 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7913 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7914 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7915 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7916 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7917 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7918 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7919 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7920
7921 /* "show ip ospf interface" commands. */
7922 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7923 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7924
7925 /* "show ip ospf neighbor" commands. */
7926 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7927 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7928 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7929 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7930 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7931 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7932 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7933 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7934 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7935 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7936 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7937 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7938 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7939 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7940
7941 /* "show ip ospf route" commands. */
7942 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7943 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007944 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7945 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007946}
7947
7948
7949/* ospfd's interface node. */
7950struct cmd_node interface_node =
7951{
7952 INTERFACE_NODE,
7953 "%s(config-if)# ",
7954 1
7955};
7956
7957/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007958static void
7959ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007960{
7961 /* Install interface node. */
7962 install_node (&interface_node, config_write_interface);
7963
7964 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007965 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007966 install_default (INTERFACE_NODE);
7967
7968 /* "description" commands. */
7969 install_element (INTERFACE_NODE, &interface_desc_cmd);
7970 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7971
7972 /* "ip ospf authentication" commands. */
7973 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7974 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7975 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7976 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7977 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7978 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7979 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7980 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7981 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7982 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7983
7984 /* "ip ospf message-digest-key" commands. */
7985 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7986 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7987 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7988 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7989
7990 /* "ip ospf cost" commands. */
7991 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7992 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7993 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7994 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7995
vincentba682532005-09-29 13:52:57 +00007996 /* "ip ospf mtu-ignore" commands. */
7997 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7998 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7999 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8000 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8001
paul718e3742002-12-13 20:15:29 +00008002 /* "ip ospf dead-interval" commands. */
8003 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8004 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008005 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8006 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00008007 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8008 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008009
paul718e3742002-12-13 20:15:29 +00008010 /* "ip ospf hello-interval" commands. */
8011 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8012 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8013 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8014 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8015
8016 /* "ip ospf network" commands. */
8017 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8018 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8019
8020 /* "ip ospf priority" commands. */
8021 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8022 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8023 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8024 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8025
8026 /* "ip ospf retransmit-interval" commands. */
8027 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8028 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8029 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8030 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8031
8032 /* "ip ospf transmit-delay" commands. */
8033 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8034 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8035 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8036 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8037
8038 /* These commands are compatibitliy for previous version. */
8039 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8040 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8041 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8042 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
8043 install_element (INTERFACE_NODE, &ospf_cost_cmd);
8044 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
8045 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8046 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8047 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8048 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8049 install_element (INTERFACE_NODE, &ospf_network_cmd);
8050 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8051 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8052 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8053 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8054 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8055 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8056 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8057}
8058
8059/* Zebra node structure. */
8060struct cmd_node zebra_node =
8061{
8062 ZEBRA_NODE,
8063 "%s(config-router)#",
8064};
8065
paul4dadc292005-05-06 21:37:42 +00008066static void
8067ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008068{
8069 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8070 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8071 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8072 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8073 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8074 install_element (OSPF_NODE,
8075 &ospf_redistribute_source_metric_type_routemap_cmd);
8076 install_element (OSPF_NODE,
8077 &ospf_redistribute_source_type_metric_routemap_cmd);
8078 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8079 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8080 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8081
8082 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8083
8084 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8085 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8086
8087 install_element (OSPF_NODE,
8088 &ospf_default_information_originate_metric_type_cmd);
8089 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8090 install_element (OSPF_NODE,
8091 &ospf_default_information_originate_type_metric_cmd);
8092 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8093 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8094 install_element (OSPF_NODE,
8095 &ospf_default_information_originate_always_metric_type_cmd);
8096 install_element (OSPF_NODE,
8097 &ospf_default_information_originate_always_metric_cmd);
8098 install_element (OSPF_NODE,
8099 &ospf_default_information_originate_always_cmd);
8100 install_element (OSPF_NODE,
8101 &ospf_default_information_originate_always_type_metric_cmd);
8102 install_element (OSPF_NODE,
8103 &ospf_default_information_originate_always_type_cmd);
8104
8105 install_element (OSPF_NODE,
8106 &ospf_default_information_originate_metric_type_routemap_cmd);
8107 install_element (OSPF_NODE,
8108 &ospf_default_information_originate_metric_routemap_cmd);
8109 install_element (OSPF_NODE,
8110 &ospf_default_information_originate_routemap_cmd);
8111 install_element (OSPF_NODE,
8112 &ospf_default_information_originate_type_metric_routemap_cmd);
8113 install_element (OSPF_NODE,
8114 &ospf_default_information_originate_type_routemap_cmd);
8115 install_element (OSPF_NODE,
8116 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8117 install_element (OSPF_NODE,
8118 &ospf_default_information_originate_always_metric_routemap_cmd);
8119 install_element (OSPF_NODE,
8120 &ospf_default_information_originate_always_routemap_cmd);
8121 install_element (OSPF_NODE,
8122 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8123 install_element (OSPF_NODE,
8124 &ospf_default_information_originate_always_type_routemap_cmd);
8125
8126 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8127
8128 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8129 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8130 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8131
8132 install_element (OSPF_NODE, &ospf_distance_cmd);
8133 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8134 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8135 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8136 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8137 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8138 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8139 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8140 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8141 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8142 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8143 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8144 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8145 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8146 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8147 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8148 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8149 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8150#if 0
8151 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8152 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8153 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8154 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8155#endif /* 0 */
8156}
8157
8158struct cmd_node ospf_node =
8159{
8160 OSPF_NODE,
8161 "%s(config-router)# ",
8162 1
8163};
8164
8165
8166/* Install OSPF related vty commands. */
8167void
paul4dadc292005-05-06 21:37:42 +00008168ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008169{
8170 /* Install ospf top node. */
8171 install_node (&ospf_node, ospf_config_write);
8172
8173 /* "router ospf" commands. */
8174 install_element (CONFIG_NODE, &router_ospf_cmd);
8175 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8176
8177 install_default (OSPF_NODE);
8178
8179 /* "ospf router-id" commands. */
8180 install_element (OSPF_NODE, &ospf_router_id_cmd);
8181 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008182 install_element (OSPF_NODE, &router_ospf_id_cmd);
8183 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008184
8185 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008186 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8187 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8188 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8189 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008190
8191 /* "ospf abr-type" commands. */
8192 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8193 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8194
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008195 /* "ospf log-adjacency-changes" commands. */
8196 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8197 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8198 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8199 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8200
paul718e3742002-12-13 20:15:29 +00008201 /* "ospf rfc1583-compatible" commands. */
8202 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8203 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8204 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8205 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8206
8207 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008208 install_element (OSPF_NODE, &ospf_network_area_cmd);
8209 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008210
8211 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008212 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8213 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8214 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008215
8216 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008217 install_element (OSPF_NODE, &ospf_area_range_cmd);
8218 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8219 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8220 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8221 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8222 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8223 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8224 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8225 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8226 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8227 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008228
8229 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008230 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8231 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008232
paula2c62832003-04-23 17:01:31 +00008233 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8234 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008235
paula2c62832003-04-23 17:01:31 +00008236 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8237 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008238
paula2c62832003-04-23 17:01:31 +00008239 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8240 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008241
paula2c62832003-04-23 17:01:31 +00008242 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8243 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008244
paula2c62832003-04-23 17:01:31 +00008245 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8246 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8247 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008248
paula2c62832003-04-23 17:01:31 +00008249 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8250 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008251
paula2c62832003-04-23 17:01:31 +00008252 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8253 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008254
paula2c62832003-04-23 17:01:31 +00008255 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8256 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8257 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008258
paula2c62832003-04-23 17:01:31 +00008259 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8260 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8261 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008262
8263 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008264 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8265 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8266 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8267 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008268
paul718e3742002-12-13 20:15:29 +00008269 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008270 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8271 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8272 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8273 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8274 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8275 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008276
paula2c62832003-04-23 17:01:31 +00008277 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8278 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008279
paula2c62832003-04-23 17:01:31 +00008280 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8281 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008282
paula2c62832003-04-23 17:01:31 +00008283 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8284 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008285
paula2c62832003-04-23 17:01:31 +00008286 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8287 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008288
paula2c62832003-04-23 17:01:31 +00008289 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8290 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008291
8292 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008293 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8294 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008295 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8296 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8297
paul88d6cf32005-10-29 12:50:09 +00008298 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008299 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8300 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8301 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008302
paul88d6cf32005-10-29 12:50:09 +00008303 /* max-metric commands */
8304 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8305 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8306 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8307 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8308 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8309 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8310
8311 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008312 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8313 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008314
8315 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008316 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8317 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8318 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8319 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8320 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8321 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8322 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8323 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008324
8325 /* Init interface related vty commands. */
8326 ospf_vty_if_init ();
8327
8328 /* Init zebra related vty commands. */
8329 ospf_vty_zebra_init ();
8330}