blob: 44049d8c469f31da769c1db5b9144ede0345fd05 [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);
Paul Jakma90c33172006-07-11 17:57:25 +00003158 if (nbr->ts_last_change.tv_sec || nbr->ts_last_change.tv_usec)
3159 {
3160 struct timeval res = tv_sub (recent_time, nbr->ts_last_change);
3161 vty_out (vty, " Last state change %s ago, due to %s%s",
3162 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3163 (nbr->last_event_str ? nbr->last_event_str : "??"),
3164 VTY_NEWLINE);
3165 }
paul718e3742002-12-13 20:15:29 +00003166 /* Show Designated Rotuer ID. */
3167 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3168 /* Show Backup Designated Rotuer ID. */
3169 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3170 /* Show options. */
3171 vty_out (vty, " Options %d %s%s", nbr->options,
3172 ospf_options_dump (nbr->options), VTY_NEWLINE);
3173 /* Show Router Dead interval timer. */
3174 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003175 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3176 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003177 /* Show Database Summary list. */
3178 vty_out (vty, " Database Summary List %d%s",
3179 ospf_db_summary_count (nbr), VTY_NEWLINE);
3180 /* Show Link State Request list. */
3181 vty_out (vty, " Link State Request List %ld%s",
3182 ospf_ls_request_count (nbr), VTY_NEWLINE);
3183 /* Show Link State Retransmission list. */
3184 vty_out (vty, " Link State Retransmission List %ld%s",
3185 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3186 /* Show inactivity timer thread. */
3187 vty_out (vty, " Thread Inactivity Timer %s%s",
3188 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3189 /* Show Database Description retransmission thread. */
3190 vty_out (vty, " Thread Database Description Retransmision %s%s",
3191 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3192 /* Show Link State Request Retransmission thread. */
3193 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3194 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3195 /* Show Link State Update Retransmission thread. */
3196 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3197 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3198}
3199
3200DEFUN (show_ip_ospf_neighbor_id,
3201 show_ip_ospf_neighbor_id_cmd,
3202 "show ip ospf neighbor A.B.C.D",
3203 SHOW_STR
3204 IP_STR
3205 "OSPF information\n"
3206 "Neighbor list\n"
3207 "Neighbor ID\n")
3208{
paul020709f2003-04-04 02:44:16 +00003209 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003210 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003211 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003212 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003213 struct in_addr router_id;
3214 int ret;
3215
3216 ret = inet_aton (argv[0], &router_id);
3217 if (!ret)
3218 {
3219 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3220 return CMD_WARNING;
3221 }
3222
paul020709f2003-04-04 02:44:16 +00003223 ospf = ospf_lookup ();
3224 if (ospf == NULL)
3225 {
3226 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3227 return CMD_SUCCESS;
3228 }
3229
paul1eb8ef22005-04-07 07:30:20 +00003230 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3231 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003232 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003233
paul718e3742002-12-13 20:15:29 +00003234 return CMD_SUCCESS;
3235}
3236
3237DEFUN (show_ip_ospf_neighbor_detail,
3238 show_ip_ospf_neighbor_detail_cmd,
3239 "show ip ospf neighbor detail",
3240 SHOW_STR
3241 IP_STR
3242 "OSPF information\n"
3243 "Neighbor list\n"
3244 "detail of all neighbors\n")
3245{
paul020709f2003-04-04 02:44:16 +00003246 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003247 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003248 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003249
paul020709f2003-04-04 02:44:16 +00003250 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003251 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003252 {
3253 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3254 return CMD_SUCCESS;
3255 }
paul718e3742002-12-13 20:15:29 +00003256
paul1eb8ef22005-04-07 07:30:20 +00003257 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003258 {
paul718e3742002-12-13 20:15:29 +00003259 struct route_node *rn;
3260 struct ospf_neighbor *nbr;
3261
3262 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3263 if ((nbr = rn->info))
3264 if (nbr != oi->nbr_self)
3265 if (nbr->state != NSM_Down)
3266 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3267 }
3268
3269 return CMD_SUCCESS;
3270}
3271
3272DEFUN (show_ip_ospf_neighbor_detail_all,
3273 show_ip_ospf_neighbor_detail_all_cmd,
3274 "show ip ospf neighbor detail all",
3275 SHOW_STR
3276 IP_STR
3277 "OSPF information\n"
3278 "Neighbor list\n"
3279 "detail of all neighbors\n"
3280 "include down status neighbor\n")
3281{
paul020709f2003-04-04 02:44:16 +00003282 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003283 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003284 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003285
paul020709f2003-04-04 02:44:16 +00003286 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003287 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003288 {
3289 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3290 return CMD_SUCCESS;
3291 }
paul718e3742002-12-13 20:15:29 +00003292
paul1eb8ef22005-04-07 07:30:20 +00003293 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003294 {
paul718e3742002-12-13 20:15:29 +00003295 struct route_node *rn;
3296 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003297 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003298
3299 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3300 if ((nbr = rn->info))
3301 if (nbr != oi->nbr_self)
3302 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3303 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3304
3305 if (oi->type == OSPF_IFTYPE_NBMA)
3306 {
hasso52dc7ee2004-09-23 19:18:23 +00003307 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003308
paul1eb8ef22005-04-07 07:30:20 +00003309 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3310 if (nbr_nbma->nbr == NULL
3311 || nbr_nbma->nbr->state == NSM_Down)
3312 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003313 }
3314 }
3315
3316 return CMD_SUCCESS;
3317}
3318
3319DEFUN (show_ip_ospf_neighbor_int_detail,
3320 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003321 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003322 SHOW_STR
3323 IP_STR
3324 "OSPF information\n"
3325 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003326 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003327 "detail of all neighbors")
3328{
paul020709f2003-04-04 02:44:16 +00003329 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003330 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003331 struct interface *ifp;
3332 struct route_node *rn, *nrn;
3333 struct ospf_neighbor *nbr;
3334
3335 ifp = if_lookup_by_name (argv[0]);
3336 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003337 {
hassobb5b7552005-08-21 20:01:15 +00003338 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003339 return CMD_WARNING;
3340 }
3341
paul020709f2003-04-04 02:44:16 +00003342 ospf = ospf_lookup ();
3343 if (ospf == NULL)
3344 {
3345 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3346 return CMD_SUCCESS;
3347 }
paul68980082003-03-25 05:07:42 +00003348
paul718e3742002-12-13 20:15:29 +00003349
hassobb5b7552005-08-21 20:01:15 +00003350 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3351 if ((oi = rn->info))
3352 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3353 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003354 if (nbr != oi->nbr_self)
3355 if (nbr->state != NSM_Down)
3356 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003357
3358 return CMD_SUCCESS;
3359}
3360
3361
3362/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003363static int
paul020709f2003-04-04 02:44:16 +00003364show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003365{
paul718e3742002-12-13 20:15:29 +00003366 struct router_lsa *rl;
3367 struct summary_lsa *sl;
3368 struct as_external_lsa *asel;
3369 struct prefix_ipv4 p;
3370
3371 if (lsa != NULL)
3372 /* If self option is set, check LSA self flag. */
3373 if (self == 0 || IS_LSA_SELF (lsa))
3374 {
3375 /* LSA common part show. */
3376 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3377 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3378 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3379 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3380 /* LSA specific part show. */
3381 switch (lsa->data->type)
3382 {
3383 case OSPF_ROUTER_LSA:
3384 rl = (struct router_lsa *) lsa->data;
3385 vty_out (vty, " %-d", ntohs (rl->links));
3386 break;
3387 case OSPF_SUMMARY_LSA:
3388 sl = (struct summary_lsa *) lsa->data;
3389
3390 p.family = AF_INET;
3391 p.prefix = sl->header.id;
3392 p.prefixlen = ip_masklen (sl->mask);
3393 apply_mask_ipv4 (&p);
3394
3395 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3396 break;
3397 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003398 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003399 asel = (struct as_external_lsa *) lsa->data;
3400
3401 p.family = AF_INET;
3402 p.prefix = asel->header.id;
3403 p.prefixlen = ip_masklen (asel->mask);
3404 apply_mask_ipv4 (&p);
3405
3406 vty_out (vty, " %s %s/%d [0x%lx]",
3407 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3408 inet_ntoa (p.prefix), p.prefixlen,
3409 (u_long)ntohl (asel->e[0].route_tag));
3410 break;
3411 case OSPF_NETWORK_LSA:
3412 case OSPF_ASBR_SUMMARY_LSA:
3413#ifdef HAVE_OPAQUE_LSA
3414 case OSPF_OPAQUE_LINK_LSA:
3415 case OSPF_OPAQUE_AREA_LSA:
3416 case OSPF_OPAQUE_AS_LSA:
3417#endif /* HAVE_OPAQUE_LSA */
3418 default:
3419 break;
3420 }
3421 vty_out (vty, VTY_NEWLINE);
3422 }
3423
3424 return 0;
3425}
3426
hassoeb1ce602004-10-08 08:17:22 +00003427const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003428{
3429 "unknown",
3430 "Router Link States",
3431 "Net Link States",
3432 "Summary Link States",
3433 "ASBR-Summary Link States",
3434 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003435 "Group Membership LSA",
3436 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003437#ifdef HAVE_OPAQUE_LSA
3438 "Type-8 LSA",
3439 "Link-Local Opaque-LSA",
3440 "Area-Local Opaque-LSA",
3441 "AS-external Opaque-LSA",
3442#endif /* HAVE_OPAQUE_LSA */
3443};
3444
3445#define SHOW_OSPF_COMMON_HEADER \
3446 "Link ID ADV Router Age Seq# CkSum"
3447
hassoeb1ce602004-10-08 08:17:22 +00003448const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003449{
3450 "",
3451 "Link ID ADV Router Age Seq# CkSum Link count",
3452 "Link ID ADV Router Age Seq# CkSum",
3453 "Link ID ADV Router Age Seq# CkSum Route",
3454 "Link ID ADV Router Age Seq# CkSum",
3455 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003456 " --- header for Group Member ----",
3457 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003458#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003459 " --- type-8 ---",
3460 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3461 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3462 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3463#endif /* HAVE_OPAQUE_LSA */
3464};
3465
hassoeb1ce602004-10-08 08:17:22 +00003466const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003467{
3468 "Self-originated",
3469 "Checked",
3470 "Received",
3471 "Approved",
3472 "Discard",
paul4957f492003-06-27 01:28:45 +00003473 "Translated",
paul4957f492003-06-27 01:28:45 +00003474};
3475
paul4dadc292005-05-06 21:37:42 +00003476static void
paul718e3742002-12-13 20:15:29 +00003477show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3478{
3479 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003480
paul718e3742002-12-13 20:15:29 +00003481 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003482 vty_out (vty, " Options: 0x%-2x : %s%s",
3483 lsa->data->options,
3484 ospf_options_dump(lsa->data->options),
3485 VTY_NEWLINE);
3486 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003487 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003488 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3489 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003490
3491 if (lsa->data->type == OSPF_ROUTER_LSA)
3492 {
3493 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3494
3495 if (rlsa->flags)
3496 vty_out (vty, " :%s%s%s%s",
3497 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3498 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3499 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3500 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3501
3502 vty_out (vty, "%s", VTY_NEWLINE);
3503 }
3504 vty_out (vty, " LS Type: %s%s",
3505 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3506 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3507 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3508 vty_out (vty, " Advertising Router: %s%s",
3509 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3510 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3511 VTY_NEWLINE);
3512 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3513 VTY_NEWLINE);
3514 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3515}
3516
hassoeb1ce602004-10-08 08:17:22 +00003517const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003518{
3519 "(null)",
3520 "another Router (point-to-point)",
3521 "a Transit Network",
3522 "Stub Network",
3523 "a Virtual Link",
3524};
3525
hassoeb1ce602004-10-08 08:17:22 +00003526const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003527{
3528 "(null)",
3529 "Neighboring Router ID",
3530 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003531 "Net",
paul718e3742002-12-13 20:15:29 +00003532 "Neighboring Router ID",
3533};
3534
hassoeb1ce602004-10-08 08:17:22 +00003535const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003536{
3537 "(null)",
3538 "Router Interface address",
3539 "Router Interface address",
3540 "Network Mask",
3541 "Router Interface address",
3542};
3543
3544/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003545static void
paul718e3742002-12-13 20:15:29 +00003546show_ip_ospf_database_router_links (struct vty *vty,
3547 struct router_lsa *rl)
3548{
3549 int len, i, type;
3550
3551 len = ntohs (rl->header.length) - 4;
3552 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3553 {
3554 type = rl->link[i].type;
3555
3556 vty_out (vty, " Link connected to: %s%s",
3557 link_type_desc[type], VTY_NEWLINE);
3558 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3559 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3560 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3561 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3562 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3563 vty_out (vty, " TOS 0 Metric: %d%s",
3564 ntohs (rl->link[i].metric), VTY_NEWLINE);
3565 vty_out (vty, "%s", VTY_NEWLINE);
3566 }
3567}
3568
3569/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003570static int
paul718e3742002-12-13 20:15:29 +00003571show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3572{
3573 if (lsa != NULL)
3574 {
3575 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3576
3577 show_ip_ospf_database_header (vty, lsa);
3578
3579 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3580 VTY_NEWLINE, VTY_NEWLINE);
3581
3582 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003583 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003584 }
3585
3586 return 0;
3587}
3588
3589/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003590static int
paul718e3742002-12-13 20:15:29 +00003591show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3592{
3593 int length, i;
3594
3595 if (lsa != NULL)
3596 {
3597 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3598
3599 show_ip_ospf_database_header (vty, lsa);
3600
3601 vty_out (vty, " Network Mask: /%d%s",
3602 ip_masklen (nl->mask), VTY_NEWLINE);
3603
3604 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3605
3606 for (i = 0; length > 0; i++, length -= 4)
3607 vty_out (vty, " Attached Router: %s%s",
3608 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3609
3610 vty_out (vty, "%s", VTY_NEWLINE);
3611 }
3612
3613 return 0;
3614}
3615
3616/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003617static int
paul718e3742002-12-13 20:15:29 +00003618show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3619{
3620 if (lsa != NULL)
3621 {
3622 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3623
3624 show_ip_ospf_database_header (vty, lsa);
3625
3626 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3627 VTY_NEWLINE);
3628 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3629 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003630 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003631 }
3632
3633 return 0;
3634}
3635
3636/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003637static int
paul718e3742002-12-13 20:15:29 +00003638show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3639{
3640 if (lsa != NULL)
3641 {
3642 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3643
3644 show_ip_ospf_database_header (vty, lsa);
3645
3646 vty_out (vty, " Network Mask: /%d%s",
3647 ip_masklen (sl->mask), VTY_NEWLINE);
3648 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3649 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003650 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003651 }
3652
3653 return 0;
3654}
3655
3656/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003657static int
paul718e3742002-12-13 20:15:29 +00003658show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3659{
3660 if (lsa != NULL)
3661 {
3662 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3663
3664 show_ip_ospf_database_header (vty, lsa);
3665
3666 vty_out (vty, " Network Mask: /%d%s",
3667 ip_masklen (al->mask), VTY_NEWLINE);
3668 vty_out (vty, " Metric Type: %s%s",
3669 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3670 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3671 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3672 vty_out (vty, " Metric: %d%s",
3673 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3674 vty_out (vty, " Forward Address: %s%s",
3675 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3676
3677 vty_out (vty, " External Route Tag: %lu%s%s",
3678 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3679 }
3680
3681 return 0;
3682}
3683
ajs2a42e282004-12-08 18:43:03 +00003684/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003685static int
paul718e3742002-12-13 20:15:29 +00003686show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3687{
3688 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3689
3690 /* show_ip_ospf_database_header (vty, lsa); */
3691
ajs2a42e282004-12-08 18:43:03 +00003692 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003693 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003694 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003695 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3696 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003697 zlog_debug( " TOS: 0%s", "\n");
3698 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003699 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003700 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003701 inet_ntoa (al->e[0].fwd_addr), "\n");
3702
ajs2a42e282004-12-08 18:43:03 +00003703 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003704 ntohl (al->e[0].route_tag), "\n", "\n");
3705
3706 return 0;
3707}
3708
3709/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003710static int
paul718e3742002-12-13 20:15:29 +00003711show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3712{
3713 if (lsa != NULL)
3714 {
3715 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3716
3717 show_ip_ospf_database_header (vty, lsa);
3718
3719 vty_out (vty, " Network Mask: /%d%s",
3720 ip_masklen (al->mask), VTY_NEWLINE);
3721 vty_out (vty, " Metric Type: %s%s",
3722 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3723 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3724 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3725 vty_out (vty, " Metric: %d%s",
3726 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3727 vty_out (vty, " NSSA: Forward Address: %s%s",
3728 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3729
3730 vty_out (vty, " External Route Tag: %u%s%s",
3731 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3732 }
3733
3734 return 0;
3735}
3736
paul4dadc292005-05-06 21:37:42 +00003737static int
paul718e3742002-12-13 20:15:29 +00003738show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3739{
3740 return 0;
3741}
3742
3743#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003744static int
paul718e3742002-12-13 20:15:29 +00003745show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3746{
3747 if (lsa != NULL)
3748 {
3749 show_ip_ospf_database_header (vty, lsa);
3750 show_opaque_info_detail (vty, lsa);
3751
3752 vty_out (vty, "%s", VTY_NEWLINE);
3753 }
3754 return 0;
3755}
3756#endif /* HAVE_OPAQUE_LSA */
3757
3758int (*show_function[])(struct vty *, struct ospf_lsa *) =
3759{
3760 NULL,
3761 show_router_lsa_detail,
3762 show_network_lsa_detail,
3763 show_summary_lsa_detail,
3764 show_summary_asbr_lsa_detail,
3765 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003766 show_func_dummy,
3767 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003768#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003769 NULL, /* type-8 */
3770 show_opaque_lsa_detail,
3771 show_opaque_lsa_detail,
3772 show_opaque_lsa_detail,
3773#endif /* HAVE_OPAQUE_LSA */
3774};
3775
paul4dadc292005-05-06 21:37:42 +00003776static void
paul718e3742002-12-13 20:15:29 +00003777show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3778 struct in_addr *adv_router)
3779{
3780 memset (lp, 0, sizeof (struct prefix_ls));
3781 lp->family = 0;
3782 if (id == NULL)
3783 lp->prefixlen = 0;
3784 else if (adv_router == NULL)
3785 {
3786 lp->prefixlen = 32;
3787 lp->id = *id;
3788 }
3789 else
3790 {
3791 lp->prefixlen = 64;
3792 lp->id = *id;
3793 lp->adv_router = *adv_router;
3794 }
3795}
3796
paul4dadc292005-05-06 21:37:42 +00003797static void
paul718e3742002-12-13 20:15:29 +00003798show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3799 struct in_addr *id, struct in_addr *adv_router)
3800{
3801 struct prefix_ls lp;
3802 struct route_node *rn, *start;
3803 struct ospf_lsa *lsa;
3804
3805 show_lsa_prefix_set (vty, &lp, id, adv_router);
3806 start = route_node_get (rt, (struct prefix *) &lp);
3807 if (start)
3808 {
3809 route_lock_node (start);
3810 for (rn = start; rn; rn = route_next_until (rn, start))
3811 if ((lsa = rn->info))
3812 {
paul718e3742002-12-13 20:15:29 +00003813 if (show_function[lsa->data->type] != NULL)
3814 show_function[lsa->data->type] (vty, lsa);
3815 }
3816 route_unlock_node (start);
3817 }
3818}
3819
3820/* Show detail LSA information
3821 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003822static void
paul020709f2003-04-04 02:44:16 +00003823show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003824 struct in_addr *id, struct in_addr *adv_router)
3825{
hasso52dc7ee2004-09-23 19:18:23 +00003826 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003827 struct ospf_area *area;
3828
paul718e3742002-12-13 20:15:29 +00003829 switch (type)
3830 {
3831 case OSPF_AS_EXTERNAL_LSA:
3832#ifdef HAVE_OPAQUE_LSA
3833 case OSPF_OPAQUE_AS_LSA:
3834#endif /* HAVE_OPAQUE_LSA */
3835 vty_out (vty, " %s %s%s",
3836 show_database_desc[type],
3837 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003838 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003839 break;
3840 default:
paul1eb8ef22005-04-07 07:30:20 +00003841 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003842 {
paul718e3742002-12-13 20:15:29 +00003843 vty_out (vty, "%s %s (Area %s)%s%s",
3844 VTY_NEWLINE, show_database_desc[type],
3845 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3846 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3847 }
3848 break;
3849 }
3850}
3851
paul4dadc292005-05-06 21:37:42 +00003852static void
paul718e3742002-12-13 20:15:29 +00003853show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3854 struct in_addr *adv_router)
3855{
3856 struct route_node *rn;
3857 struct ospf_lsa *lsa;
3858
3859 for (rn = route_top (rt); rn; rn = route_next (rn))
3860 if ((lsa = rn->info))
3861 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3862 {
paul718e3742002-12-13 20:15:29 +00003863 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3864 continue;
paul718e3742002-12-13 20:15:29 +00003865 if (show_function[lsa->data->type] != NULL)
3866 show_function[lsa->data->type] (vty, lsa);
3867 }
3868}
3869
3870/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003871static void
paul020709f2003-04-04 02:44:16 +00003872show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003873 struct in_addr *adv_router)
3874{
hasso52dc7ee2004-09-23 19:18:23 +00003875 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003876 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003877
3878 switch (type)
3879 {
3880 case OSPF_AS_EXTERNAL_LSA:
3881#ifdef HAVE_OPAQUE_LSA
3882 case OSPF_OPAQUE_AS_LSA:
3883#endif /* HAVE_OPAQUE_LSA */
3884 vty_out (vty, " %s %s%s",
3885 show_database_desc[type],
3886 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003887 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003888 adv_router);
3889 break;
3890 default:
paul1eb8ef22005-04-07 07:30:20 +00003891 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003892 {
paul718e3742002-12-13 20:15:29 +00003893 vty_out (vty, "%s %s (Area %s)%s%s",
3894 VTY_NEWLINE, show_database_desc[type],
3895 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3896 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3897 adv_router);
3898 }
3899 break;
3900 }
3901}
3902
paul4dadc292005-05-06 21:37:42 +00003903static void
paul020709f2003-04-04 02:44:16 +00003904show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003905{
paul020709f2003-04-04 02:44:16 +00003906 struct ospf_lsa *lsa;
3907 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003908 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003909 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003910 int type;
3911
paul1eb8ef22005-04-07 07:30:20 +00003912 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003913 {
paul718e3742002-12-13 20:15:29 +00003914 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3915 {
3916 switch (type)
3917 {
3918 case OSPF_AS_EXTERNAL_LSA:
3919#ifdef HAVE_OPAQUE_LSA
3920 case OSPF_OPAQUE_AS_LSA:
3921#endif /* HAVE_OPAQUE_LSA */
3922 continue;
3923 default:
3924 break;
3925 }
3926 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3927 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3928 {
3929 vty_out (vty, " %s (Area %s)%s%s",
3930 show_database_desc[type],
3931 ospf_area_desc_string (area),
3932 VTY_NEWLINE, VTY_NEWLINE);
3933 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3934
paul020709f2003-04-04 02:44:16 +00003935 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3936 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003937
3938 vty_out (vty, "%s", VTY_NEWLINE);
3939 }
3940 }
3941 }
3942
3943 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3944 {
3945 switch (type)
3946 {
3947 case OSPF_AS_EXTERNAL_LSA:
3948#ifdef HAVE_OPAQUE_LSA
3949 case OSPF_OPAQUE_AS_LSA:
3950#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00003951 break;
paul718e3742002-12-13 20:15:29 +00003952 default:
3953 continue;
3954 }
paul68980082003-03-25 05:07:42 +00003955 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3956 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003957 {
3958 vty_out (vty, " %s%s%s",
3959 show_database_desc[type],
3960 VTY_NEWLINE, VTY_NEWLINE);
3961 vty_out (vty, "%s%s", show_database_header[type],
3962 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003963
3964 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3965 show_lsa_summary (vty, lsa, self);
3966
paul718e3742002-12-13 20:15:29 +00003967 vty_out (vty, "%s", VTY_NEWLINE);
3968 }
3969 }
3970
3971 vty_out (vty, "%s", VTY_NEWLINE);
3972}
3973
paul4dadc292005-05-06 21:37:42 +00003974static void
paul020709f2003-04-04 02:44:16 +00003975show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003976{
hasso52dc7ee2004-09-23 19:18:23 +00003977 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003978 struct ospf_lsa *lsa;
3979
3980 vty_out (vty, "%s MaxAge Link States:%s%s",
3981 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3982
paul1eb8ef22005-04-07 07:30:20 +00003983 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3984 {
3985 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3986 vty_out (vty, "Link State ID: %s%s",
3987 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3988 vty_out (vty, "Advertising Router: %s%s",
3989 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3990 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3991 vty_out (vty, "%s", VTY_NEWLINE);
3992 }
paul718e3742002-12-13 20:15:29 +00003993}
3994
paul718e3742002-12-13 20:15:29 +00003995#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3996#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003997
3998#ifdef HAVE_OPAQUE_LSA
3999#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4000#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4001#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4002#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4003#else /* HAVE_OPAQUE_LSA */
4004#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4005#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4006#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4007#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4008#endif /* HAVE_OPAQUE_LSA */
4009
4010#define OSPF_LSA_TYPES_CMD_STR \
4011 "asbr-summary|external|network|router|summary" \
4012 OSPF_LSA_TYPE_NSSA_CMD_STR \
4013 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4014
4015#define OSPF_LSA_TYPES_DESC \
4016 "ASBR summary link states\n" \
4017 "External link states\n" \
4018 "Network link states\n" \
4019 "Router link states\n" \
4020 "Network summary link states\n" \
4021 OSPF_LSA_TYPE_NSSA_DESC \
4022 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4023 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4024 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4025
4026DEFUN (show_ip_ospf_database,
4027 show_ip_ospf_database_cmd,
4028 "show ip ospf database",
4029 SHOW_STR
4030 IP_STR
4031 "OSPF information\n"
4032 "Database summary\n")
4033{
paul020709f2003-04-04 02:44:16 +00004034 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004035 int type, ret;
4036 struct in_addr id, adv_router;
4037
paul020709f2003-04-04 02:44:16 +00004038 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004039 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004040 {
4041 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4042 return CMD_SUCCESS;
4043 }
paul718e3742002-12-13 20:15:29 +00004044
4045 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004046 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004047
4048 /* Show all LSA. */
4049 if (argc == 0)
4050 {
paul020709f2003-04-04 02:44:16 +00004051 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004052 return CMD_SUCCESS;
4053 }
4054
4055 /* Set database type to show. */
4056 if (strncmp (argv[0], "r", 1) == 0)
4057 type = OSPF_ROUTER_LSA;
4058 else if (strncmp (argv[0], "ne", 2) == 0)
4059 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004060 else if (strncmp (argv[0], "ns", 2) == 0)
4061 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004062 else if (strncmp (argv[0], "su", 2) == 0)
4063 type = OSPF_SUMMARY_LSA;
4064 else if (strncmp (argv[0], "a", 1) == 0)
4065 type = OSPF_ASBR_SUMMARY_LSA;
4066 else if (strncmp (argv[0], "e", 1) == 0)
4067 type = OSPF_AS_EXTERNAL_LSA;
4068 else if (strncmp (argv[0], "se", 2) == 0)
4069 {
paul020709f2003-04-04 02:44:16 +00004070 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004071 return CMD_SUCCESS;
4072 }
4073 else if (strncmp (argv[0], "m", 1) == 0)
4074 {
paul020709f2003-04-04 02:44:16 +00004075 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004076 return CMD_SUCCESS;
4077 }
4078#ifdef HAVE_OPAQUE_LSA
4079 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4080 type = OSPF_OPAQUE_LINK_LSA;
4081 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4082 type = OSPF_OPAQUE_AREA_LSA;
4083 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4084 type = OSPF_OPAQUE_AS_LSA;
4085#endif /* HAVE_OPAQUE_LSA */
4086 else
4087 return CMD_WARNING;
4088
4089 /* `show ip ospf database LSA'. */
4090 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004091 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004092 else if (argc >= 2)
4093 {
4094 ret = inet_aton (argv[1], &id);
4095 if (!ret)
4096 return CMD_WARNING;
4097
4098 /* `show ip ospf database LSA ID'. */
4099 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004100 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004101 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4102 else if (argc == 3)
4103 {
4104 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004105 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004106 else
4107 {
4108 ret = inet_aton (argv[2], &adv_router);
4109 if (!ret)
4110 return CMD_WARNING;
4111 }
paul020709f2003-04-04 02:44:16 +00004112 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004113 }
4114 }
4115
4116 return CMD_SUCCESS;
4117}
4118
4119ALIAS (show_ip_ospf_database,
4120 show_ip_ospf_database_type_cmd,
4121 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4122 SHOW_STR
4123 IP_STR
4124 "OSPF information\n"
4125 "Database summary\n"
4126 OSPF_LSA_TYPES_DESC
4127 "LSAs in MaxAge list\n"
4128 "Self-originated link states\n")
4129
4130ALIAS (show_ip_ospf_database,
4131 show_ip_ospf_database_type_id_cmd,
4132 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4133 SHOW_STR
4134 IP_STR
4135 "OSPF information\n"
4136 "Database summary\n"
4137 OSPF_LSA_TYPES_DESC
4138 "Link State ID (as an IP address)\n")
4139
4140ALIAS (show_ip_ospf_database,
4141 show_ip_ospf_database_type_id_adv_router_cmd,
4142 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4143 SHOW_STR
4144 IP_STR
4145 "OSPF information\n"
4146 "Database summary\n"
4147 OSPF_LSA_TYPES_DESC
4148 "Link State ID (as an IP address)\n"
4149 "Advertising Router link states\n"
4150 "Advertising Router (as an IP address)\n")
4151
4152ALIAS (show_ip_ospf_database,
4153 show_ip_ospf_database_type_id_self_cmd,
4154 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4155 SHOW_STR
4156 IP_STR
4157 "OSPF information\n"
4158 "Database summary\n"
4159 OSPF_LSA_TYPES_DESC
4160 "Link State ID (as an IP address)\n"
4161 "Self-originated link states\n"
4162 "\n")
4163
4164DEFUN (show_ip_ospf_database_type_adv_router,
4165 show_ip_ospf_database_type_adv_router_cmd,
4166 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4167 SHOW_STR
4168 IP_STR
4169 "OSPF information\n"
4170 "Database summary\n"
4171 OSPF_LSA_TYPES_DESC
4172 "Advertising Router link states\n"
4173 "Advertising Router (as an IP address)\n")
4174{
paul020709f2003-04-04 02:44:16 +00004175 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004176 int type, ret;
4177 struct in_addr adv_router;
4178
paul020709f2003-04-04 02:44:16 +00004179 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004180 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004181 {
4182 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4183 return CMD_SUCCESS;
4184 }
paul718e3742002-12-13 20:15:29 +00004185
4186 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004187 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004188
4189 if (argc != 2)
4190 return CMD_WARNING;
4191
4192 /* Set database type to show. */
4193 if (strncmp (argv[0], "r", 1) == 0)
4194 type = OSPF_ROUTER_LSA;
4195 else if (strncmp (argv[0], "ne", 2) == 0)
4196 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004197 else if (strncmp (argv[0], "ns", 2) == 0)
4198 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004199 else if (strncmp (argv[0], "s", 1) == 0)
4200 type = OSPF_SUMMARY_LSA;
4201 else if (strncmp (argv[0], "a", 1) == 0)
4202 type = OSPF_ASBR_SUMMARY_LSA;
4203 else if (strncmp (argv[0], "e", 1) == 0)
4204 type = OSPF_AS_EXTERNAL_LSA;
4205#ifdef HAVE_OPAQUE_LSA
4206 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4207 type = OSPF_OPAQUE_LINK_LSA;
4208 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4209 type = OSPF_OPAQUE_AREA_LSA;
4210 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4211 type = OSPF_OPAQUE_AS_LSA;
4212#endif /* HAVE_OPAQUE_LSA */
4213 else
4214 return CMD_WARNING;
4215
4216 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4217 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004218 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004219 else
4220 {
4221 ret = inet_aton (argv[1], &adv_router);
4222 if (!ret)
4223 return CMD_WARNING;
4224 }
4225
paul020709f2003-04-04 02:44:16 +00004226 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004227
4228 return CMD_SUCCESS;
4229}
4230
4231ALIAS (show_ip_ospf_database_type_adv_router,
4232 show_ip_ospf_database_type_self_cmd,
4233 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4234 SHOW_STR
4235 IP_STR
4236 "OSPF information\n"
4237 "Database summary\n"
4238 OSPF_LSA_TYPES_DESC
4239 "Self-originated link states\n")
4240
4241
4242DEFUN (ip_ospf_authentication_args,
4243 ip_ospf_authentication_args_addr_cmd,
4244 "ip ospf authentication (null|message-digest) A.B.C.D",
4245 "IP Information\n"
4246 "OSPF interface commands\n"
4247 "Enable authentication on this interface\n"
4248 "Use null authentication\n"
4249 "Use message-digest authentication\n"
4250 "Address of interface")
4251{
4252 struct interface *ifp;
4253 struct in_addr addr;
4254 int ret;
4255 struct ospf_if_params *params;
4256
4257 ifp = vty->index;
4258 params = IF_DEF_PARAMS (ifp);
4259
4260 if (argc == 2)
4261 {
4262 ret = inet_aton(argv[1], &addr);
4263 if (!ret)
4264 {
4265 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4266 VTY_NEWLINE);
4267 return CMD_WARNING;
4268 }
4269
4270 params = ospf_get_if_params (ifp, addr);
4271 ospf_if_update_params (ifp, addr);
4272 }
4273
4274 /* Handle null authentication */
4275 if ( argv[0][0] == 'n' )
4276 {
4277 SET_IF_PARAM (params, auth_type);
4278 params->auth_type = OSPF_AUTH_NULL;
4279 return CMD_SUCCESS;
4280 }
4281
4282 /* Handle message-digest authentication */
4283 if ( argv[0][0] == 'm' )
4284 {
4285 SET_IF_PARAM (params, auth_type);
4286 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4287 return CMD_SUCCESS;
4288 }
4289
4290 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4291 return CMD_WARNING;
4292}
4293
4294ALIAS (ip_ospf_authentication_args,
4295 ip_ospf_authentication_args_cmd,
4296 "ip ospf authentication (null|message-digest)",
4297 "IP Information\n"
4298 "OSPF interface commands\n"
4299 "Enable authentication on this interface\n"
4300 "Use null authentication\n"
4301 "Use message-digest authentication\n")
4302
4303DEFUN (ip_ospf_authentication,
4304 ip_ospf_authentication_addr_cmd,
4305 "ip ospf authentication A.B.C.D",
4306 "IP Information\n"
4307 "OSPF interface commands\n"
4308 "Enable authentication on this interface\n"
4309 "Address of interface")
4310{
4311 struct interface *ifp;
4312 struct in_addr addr;
4313 int ret;
4314 struct ospf_if_params *params;
4315
4316 ifp = vty->index;
4317 params = IF_DEF_PARAMS (ifp);
4318
4319 if (argc == 1)
4320 {
4321 ret = inet_aton(argv[1], &addr);
4322 if (!ret)
4323 {
4324 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4325 VTY_NEWLINE);
4326 return CMD_WARNING;
4327 }
4328
4329 params = ospf_get_if_params (ifp, addr);
4330 ospf_if_update_params (ifp, addr);
4331 }
4332
4333 SET_IF_PARAM (params, auth_type);
4334 params->auth_type = OSPF_AUTH_SIMPLE;
4335
4336 return CMD_SUCCESS;
4337}
4338
4339ALIAS (ip_ospf_authentication,
4340 ip_ospf_authentication_cmd,
4341 "ip ospf authentication",
4342 "IP Information\n"
4343 "OSPF interface commands\n"
4344 "Enable authentication on this interface\n")
4345
4346DEFUN (no_ip_ospf_authentication,
4347 no_ip_ospf_authentication_addr_cmd,
4348 "no ip ospf authentication A.B.C.D",
4349 NO_STR
4350 "IP Information\n"
4351 "OSPF interface commands\n"
4352 "Enable authentication on this interface\n"
4353 "Address of interface")
4354{
4355 struct interface *ifp;
4356 struct in_addr addr;
4357 int ret;
4358 struct ospf_if_params *params;
4359
4360 ifp = vty->index;
4361 params = IF_DEF_PARAMS (ifp);
4362
4363 if (argc == 1)
4364 {
4365 ret = inet_aton(argv[1], &addr);
4366 if (!ret)
4367 {
4368 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4369 VTY_NEWLINE);
4370 return CMD_WARNING;
4371 }
4372
4373 params = ospf_lookup_if_params (ifp, addr);
4374 if (params == NULL)
4375 return CMD_SUCCESS;
4376 }
4377
4378 params->auth_type = OSPF_AUTH_NOTSET;
4379 UNSET_IF_PARAM (params, auth_type);
4380
4381 if (params != IF_DEF_PARAMS (ifp))
4382 {
4383 ospf_free_if_params (ifp, addr);
4384 ospf_if_update_params (ifp, addr);
4385 }
4386
4387 return CMD_SUCCESS;
4388}
4389
4390ALIAS (no_ip_ospf_authentication,
4391 no_ip_ospf_authentication_cmd,
4392 "no ip ospf authentication",
4393 NO_STR
4394 "IP Information\n"
4395 "OSPF interface commands\n"
4396 "Enable authentication on this interface\n")
4397
4398DEFUN (ip_ospf_authentication_key,
4399 ip_ospf_authentication_key_addr_cmd,
4400 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4401 "IP Information\n"
4402 "OSPF interface commands\n"
4403 "Authentication password (key)\n"
4404 "The OSPF password (key)\n"
4405 "Address of interface")
4406{
4407 struct interface *ifp;
4408 struct in_addr addr;
4409 int ret;
4410 struct ospf_if_params *params;
4411
4412 ifp = vty->index;
4413 params = IF_DEF_PARAMS (ifp);
4414
4415 if (argc == 2)
4416 {
4417 ret = inet_aton(argv[1], &addr);
4418 if (!ret)
4419 {
4420 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4421 VTY_NEWLINE);
4422 return CMD_WARNING;
4423 }
4424
4425 params = ospf_get_if_params (ifp, addr);
4426 ospf_if_update_params (ifp, addr);
4427 }
4428
4429
4430 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004431 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004432 SET_IF_PARAM (params, auth_simple);
4433
4434 return CMD_SUCCESS;
4435}
4436
4437ALIAS (ip_ospf_authentication_key,
4438 ip_ospf_authentication_key_cmd,
4439 "ip ospf authentication-key AUTH_KEY",
4440 "IP Information\n"
4441 "OSPF interface commands\n"
4442 "Authentication password (key)\n"
4443 "The OSPF password (key)")
4444
4445ALIAS (ip_ospf_authentication_key,
4446 ospf_authentication_key_cmd,
4447 "ospf authentication-key AUTH_KEY",
4448 "OSPF interface commands\n"
4449 "Authentication password (key)\n"
4450 "The OSPF password (key)")
4451
4452DEFUN (no_ip_ospf_authentication_key,
4453 no_ip_ospf_authentication_key_addr_cmd,
4454 "no ip ospf authentication-key A.B.C.D",
4455 NO_STR
4456 "IP Information\n"
4457 "OSPF interface commands\n"
4458 "Authentication password (key)\n"
4459 "Address of interface")
4460{
4461 struct interface *ifp;
4462 struct in_addr addr;
4463 int ret;
4464 struct ospf_if_params *params;
4465
4466 ifp = vty->index;
4467 params = IF_DEF_PARAMS (ifp);
4468
4469 if (argc == 2)
4470 {
4471 ret = inet_aton(argv[1], &addr);
4472 if (!ret)
4473 {
4474 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4475 VTY_NEWLINE);
4476 return CMD_WARNING;
4477 }
4478
4479 params = ospf_lookup_if_params (ifp, addr);
4480 if (params == NULL)
4481 return CMD_SUCCESS;
4482 }
4483
4484 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4485 UNSET_IF_PARAM (params, auth_simple);
4486
4487 if (params != IF_DEF_PARAMS (ifp))
4488 {
4489 ospf_free_if_params (ifp, addr);
4490 ospf_if_update_params (ifp, addr);
4491 }
4492
4493 return CMD_SUCCESS;
4494}
4495
4496ALIAS (no_ip_ospf_authentication_key,
4497 no_ip_ospf_authentication_key_cmd,
4498 "no ip ospf authentication-key",
4499 NO_STR
4500 "IP Information\n"
4501 "OSPF interface commands\n"
4502 "Authentication password (key)\n")
4503
4504ALIAS (no_ip_ospf_authentication_key,
4505 no_ospf_authentication_key_cmd,
4506 "no ospf authentication-key",
4507 NO_STR
4508 "OSPF interface commands\n"
4509 "Authentication password (key)\n")
4510
4511DEFUN (ip_ospf_message_digest_key,
4512 ip_ospf_message_digest_key_addr_cmd,
4513 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4514 "IP Information\n"
4515 "OSPF interface commands\n"
4516 "Message digest authentication password (key)\n"
4517 "Key ID\n"
4518 "Use MD5 algorithm\n"
4519 "The OSPF password (key)"
4520 "Address of interface")
4521{
4522 struct interface *ifp;
4523 struct crypt_key *ck;
4524 u_char key_id;
4525 struct in_addr addr;
4526 int ret;
4527 struct ospf_if_params *params;
4528
4529 ifp = vty->index;
4530 params = IF_DEF_PARAMS (ifp);
4531
4532 if (argc == 3)
4533 {
4534 ret = inet_aton(argv[2], &addr);
4535 if (!ret)
4536 {
4537 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4538 VTY_NEWLINE);
4539 return CMD_WARNING;
4540 }
4541
4542 params = ospf_get_if_params (ifp, addr);
4543 ospf_if_update_params (ifp, addr);
4544 }
4545
4546 key_id = strtol (argv[0], NULL, 10);
4547 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4548 {
4549 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4550 return CMD_WARNING;
4551 }
4552
4553 ck = ospf_crypt_key_new ();
4554 ck->key_id = (u_char) key_id;
4555 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004556 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004557
4558 ospf_crypt_key_add (params->auth_crypt, ck);
4559 SET_IF_PARAM (params, auth_crypt);
4560
4561 return CMD_SUCCESS;
4562}
4563
4564ALIAS (ip_ospf_message_digest_key,
4565 ip_ospf_message_digest_key_cmd,
4566 "ip ospf message-digest-key <1-255> md5 KEY",
4567 "IP Information\n"
4568 "OSPF interface commands\n"
4569 "Message digest authentication password (key)\n"
4570 "Key ID\n"
4571 "Use MD5 algorithm\n"
4572 "The OSPF password (key)")
4573
4574ALIAS (ip_ospf_message_digest_key,
4575 ospf_message_digest_key_cmd,
4576 "ospf message-digest-key <1-255> md5 KEY",
4577 "OSPF interface commands\n"
4578 "Message digest authentication password (key)\n"
4579 "Key ID\n"
4580 "Use MD5 algorithm\n"
4581 "The OSPF password (key)")
4582
4583DEFUN (no_ip_ospf_message_digest_key,
4584 no_ip_ospf_message_digest_key_addr_cmd,
4585 "no ip ospf message-digest-key <1-255> A.B.C.D",
4586 NO_STR
4587 "IP Information\n"
4588 "OSPF interface commands\n"
4589 "Message digest authentication password (key)\n"
4590 "Key ID\n"
4591 "Address of interface")
4592{
4593 struct interface *ifp;
4594 struct crypt_key *ck;
4595 int key_id;
4596 struct in_addr addr;
4597 int ret;
4598 struct ospf_if_params *params;
4599
4600 ifp = vty->index;
4601 params = IF_DEF_PARAMS (ifp);
4602
4603 if (argc == 2)
4604 {
4605 ret = inet_aton(argv[1], &addr);
4606 if (!ret)
4607 {
4608 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4609 VTY_NEWLINE);
4610 return CMD_WARNING;
4611 }
4612
4613 params = ospf_lookup_if_params (ifp, addr);
4614 if (params == NULL)
4615 return CMD_SUCCESS;
4616 }
4617
4618 key_id = strtol (argv[0], NULL, 10);
4619 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4620 if (ck == NULL)
4621 {
4622 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4623 return CMD_WARNING;
4624 }
4625
4626 ospf_crypt_key_delete (params->auth_crypt, key_id);
4627
4628 if (params != IF_DEF_PARAMS (ifp))
4629 {
4630 ospf_free_if_params (ifp, addr);
4631 ospf_if_update_params (ifp, addr);
4632 }
4633
4634 return CMD_SUCCESS;
4635}
4636
4637ALIAS (no_ip_ospf_message_digest_key,
4638 no_ip_ospf_message_digest_key_cmd,
4639 "no ip ospf message-digest-key <1-255>",
4640 NO_STR
4641 "IP Information\n"
4642 "OSPF interface commands\n"
4643 "Message digest authentication password (key)\n"
4644 "Key ID\n")
4645
4646ALIAS (no_ip_ospf_message_digest_key,
4647 no_ospf_message_digest_key_cmd,
4648 "no ospf message-digest-key <1-255>",
4649 NO_STR
4650 "OSPF interface commands\n"
4651 "Message digest authentication password (key)\n"
4652 "Key ID\n")
4653
4654DEFUN (ip_ospf_cost,
4655 ip_ospf_cost_addr_cmd,
4656 "ip ospf cost <1-65535> A.B.C.D",
4657 "IP Information\n"
4658 "OSPF interface commands\n"
4659 "Interface cost\n"
4660 "Cost\n"
4661 "Address of interface")
4662{
4663 struct interface *ifp = vty->index;
4664 u_int32_t cost;
4665 struct in_addr addr;
4666 int ret;
4667 struct ospf_if_params *params;
4668
4669 params = IF_DEF_PARAMS (ifp);
4670
4671 cost = strtol (argv[0], NULL, 10);
4672
4673 /* cost range is <1-65535>. */
4674 if (cost < 1 || cost > 65535)
4675 {
4676 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4677 return CMD_WARNING;
4678 }
4679
4680 if (argc == 2)
4681 {
4682 ret = inet_aton(argv[1], &addr);
4683 if (!ret)
4684 {
4685 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4686 VTY_NEWLINE);
4687 return CMD_WARNING;
4688 }
4689
4690 params = ospf_get_if_params (ifp, addr);
4691 ospf_if_update_params (ifp, addr);
4692 }
4693
4694 SET_IF_PARAM (params, output_cost_cmd);
4695 params->output_cost_cmd = cost;
4696
4697 ospf_if_recalculate_output_cost (ifp);
4698
4699 return CMD_SUCCESS;
4700}
4701
4702ALIAS (ip_ospf_cost,
4703 ip_ospf_cost_cmd,
4704 "ip ospf cost <1-65535>",
4705 "IP Information\n"
4706 "OSPF interface commands\n"
4707 "Interface cost\n"
4708 "Cost")
4709
4710ALIAS (ip_ospf_cost,
4711 ospf_cost_cmd,
4712 "ospf cost <1-65535>",
4713 "OSPF interface commands\n"
4714 "Interface cost\n"
4715 "Cost")
4716
4717DEFUN (no_ip_ospf_cost,
4718 no_ip_ospf_cost_addr_cmd,
4719 "no ip ospf cost A.B.C.D",
4720 NO_STR
4721 "IP Information\n"
4722 "OSPF interface commands\n"
4723 "Interface cost\n"
4724 "Address of interface")
4725{
4726 struct interface *ifp = vty->index;
4727 struct in_addr addr;
4728 int ret;
4729 struct ospf_if_params *params;
4730
4731 ifp = vty->index;
4732 params = IF_DEF_PARAMS (ifp);
4733
4734 if (argc == 1)
4735 {
4736 ret = inet_aton(argv[0], &addr);
4737 if (!ret)
4738 {
4739 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4740 VTY_NEWLINE);
4741 return CMD_WARNING;
4742 }
4743
4744 params = ospf_lookup_if_params (ifp, addr);
4745 if (params == NULL)
4746 return CMD_SUCCESS;
4747 }
4748
4749 UNSET_IF_PARAM (params, output_cost_cmd);
4750
4751 if (params != IF_DEF_PARAMS (ifp))
4752 {
4753 ospf_free_if_params (ifp, addr);
4754 ospf_if_update_params (ifp, addr);
4755 }
4756
4757 ospf_if_recalculate_output_cost (ifp);
4758
4759 return CMD_SUCCESS;
4760}
4761
4762ALIAS (no_ip_ospf_cost,
4763 no_ip_ospf_cost_cmd,
4764 "no ip ospf cost",
4765 NO_STR
4766 "IP Information\n"
4767 "OSPF interface commands\n"
4768 "Interface cost\n")
4769
4770ALIAS (no_ip_ospf_cost,
4771 no_ospf_cost_cmd,
4772 "no ospf cost",
4773 NO_STR
4774 "OSPF interface commands\n"
4775 "Interface cost\n")
4776
paul4dadc292005-05-06 21:37:42 +00004777static void
paul718e3742002-12-13 20:15:29 +00004778ospf_nbr_timer_update (struct ospf_interface *oi)
4779{
4780 struct route_node *rn;
4781 struct ospf_neighbor *nbr;
4782
4783 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4784 if ((nbr = rn->info))
4785 {
4786 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4787 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4788 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4789 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4790 }
4791}
4792
paulf9ad9372005-10-21 00:45:17 +00004793static int
4794ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4795 const char *nbr_str,
4796 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004797{
4798 struct interface *ifp = vty->index;
4799 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004800 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004801 struct in_addr addr;
4802 int ret;
4803 struct ospf_if_params *params;
4804 struct ospf_interface *oi;
4805 struct route_node *rn;
4806
4807 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004808
4809 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004810 {
paulf9ad9372005-10-21 00:45:17 +00004811 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004812 if (!ret)
4813 {
4814 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4815 VTY_NEWLINE);
4816 return CMD_WARNING;
4817 }
4818
4819 params = ospf_get_if_params (ifp, addr);
4820 ospf_if_update_params (ifp, addr);
4821 }
4822
paulf9ad9372005-10-21 00:45:17 +00004823 if (interval_str)
4824 {
4825 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4826 1, 65535);
4827
4828 /* reset fast_hello too, just to be sure */
4829 UNSET_IF_PARAM (params, fast_hello);
4830 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4831 }
4832 else if (fast_hello_str)
4833 {
4834 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4835 1, 10);
4836 /* 1s dead-interval with sub-second hellos desired */
4837 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4838 SET_IF_PARAM (params, fast_hello);
4839 params->fast_hello = hellomult;
4840 }
4841 else
4842 {
4843 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4844 VTY_NEWLINE);
4845 return CMD_WARNING;
4846 }
4847
paul718e3742002-12-13 20:15:29 +00004848 SET_IF_PARAM (params, v_wait);
4849 params->v_wait = seconds;
4850
4851 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00004852 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004853 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004854 struct ospf *ospf;
4855 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00004856 {
4857 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4858 if (oi)
4859 ospf_nbr_timer_update (oi);
4860 }
paul718e3742002-12-13 20:15:29 +00004861 }
4862 else
4863 {
4864 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4865 if ((oi = rn->info))
4866 ospf_nbr_timer_update (oi);
4867 }
4868
4869 return CMD_SUCCESS;
4870}
4871
paulf9ad9372005-10-21 00:45:17 +00004872
4873DEFUN (ip_ospf_dead_interval,
4874 ip_ospf_dead_interval_addr_cmd,
4875 "ip ospf dead-interval <1-65535> A.B.C.D",
4876 "IP Information\n"
4877 "OSPF interface commands\n"
4878 "Interval after which a neighbor is declared dead\n"
4879 "Seconds\n"
4880 "Address of interface\n")
4881{
4882 if (argc == 2)
4883 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4884 else
4885 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4886}
4887
paul718e3742002-12-13 20:15:29 +00004888ALIAS (ip_ospf_dead_interval,
4889 ip_ospf_dead_interval_cmd,
4890 "ip ospf dead-interval <1-65535>",
4891 "IP Information\n"
4892 "OSPF interface commands\n"
4893 "Interval after which a neighbor is declared dead\n"
4894 "Seconds\n")
4895
4896ALIAS (ip_ospf_dead_interval,
4897 ospf_dead_interval_cmd,
4898 "ospf dead-interval <1-65535>",
4899 "OSPF interface commands\n"
4900 "Interval after which a neighbor is declared dead\n"
4901 "Seconds\n")
4902
paulf9ad9372005-10-21 00:45:17 +00004903DEFUN (ip_ospf_dead_interval_minimal,
4904 ip_ospf_dead_interval_minimal_addr_cmd,
4905 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4906 "IP Information\n"
4907 "OSPF interface commands\n"
4908 "Interval after which a neighbor is declared dead\n"
4909 "Minimal 1s dead-interval with fast sub-second hellos\n"
4910 "Hello multiplier factor\n"
4911 "Number of Hellos to send each second\n"
4912 "Address of interface\n")
4913{
4914 if (argc == 2)
4915 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4916 else
4917 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4918}
4919
4920ALIAS (ip_ospf_dead_interval_minimal,
4921 ip_ospf_dead_interval_minimal_cmd,
4922 "ip ospf dead-interval minimal hello-multiplier <1-10>",
4923 "IP Information\n"
4924 "OSPF interface commands\n"
4925 "Interval after which a neighbor is declared dead\n"
4926 "Minimal 1s dead-interval with fast sub-second hellos\n"
4927 "Hello multiplier factor\n"
4928 "Number of Hellos to send each second\n")
4929
paul718e3742002-12-13 20:15:29 +00004930DEFUN (no_ip_ospf_dead_interval,
4931 no_ip_ospf_dead_interval_addr_cmd,
4932 "no ip ospf dead-interval A.B.C.D",
4933 NO_STR
4934 "IP Information\n"
4935 "OSPF interface commands\n"
4936 "Interval after which a neighbor is declared dead\n"
4937 "Address of interface")
4938{
4939 struct interface *ifp = vty->index;
4940 struct in_addr addr;
4941 int ret;
4942 struct ospf_if_params *params;
4943 struct ospf_interface *oi;
4944 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004945
paul718e3742002-12-13 20:15:29 +00004946 ifp = vty->index;
4947 params = IF_DEF_PARAMS (ifp);
4948
4949 if (argc == 1)
4950 {
4951 ret = inet_aton(argv[0], &addr);
4952 if (!ret)
4953 {
4954 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4955 VTY_NEWLINE);
4956 return CMD_WARNING;
4957 }
4958
4959 params = ospf_lookup_if_params (ifp, addr);
4960 if (params == NULL)
4961 return CMD_SUCCESS;
4962 }
4963
4964 UNSET_IF_PARAM (params, v_wait);
4965 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00004966
4967 UNSET_IF_PARAM (params, fast_hello);
4968 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4969
paul718e3742002-12-13 20:15:29 +00004970 if (params != IF_DEF_PARAMS (ifp))
4971 {
4972 ospf_free_if_params (ifp, addr);
4973 ospf_if_update_params (ifp, addr);
4974 }
4975
4976 /* Update timer values in neighbor structure. */
4977 if (argc == 1)
4978 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004979 struct ospf *ospf;
4980
4981 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00004982 {
4983 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4984 if (oi)
4985 ospf_nbr_timer_update (oi);
4986 }
paul718e3742002-12-13 20:15:29 +00004987 }
4988 else
4989 {
4990 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4991 if ((oi = rn->info))
4992 ospf_nbr_timer_update (oi);
4993 }
4994
4995 return CMD_SUCCESS;
4996}
4997
4998ALIAS (no_ip_ospf_dead_interval,
4999 no_ip_ospf_dead_interval_cmd,
5000 "no ip ospf dead-interval",
5001 NO_STR
5002 "IP Information\n"
5003 "OSPF interface commands\n"
5004 "Interval after which a neighbor is declared dead\n")
5005
5006ALIAS (no_ip_ospf_dead_interval,
5007 no_ospf_dead_interval_cmd,
5008 "no ospf dead-interval",
5009 NO_STR
5010 "OSPF interface commands\n"
5011 "Interval after which a neighbor is declared dead\n")
5012
5013DEFUN (ip_ospf_hello_interval,
5014 ip_ospf_hello_interval_addr_cmd,
5015 "ip ospf hello-interval <1-65535> A.B.C.D",
5016 "IP Information\n"
5017 "OSPF interface commands\n"
5018 "Time between HELLO packets\n"
5019 "Seconds\n"
5020 "Address of interface")
5021{
5022 struct interface *ifp = vty->index;
5023 u_int32_t seconds;
5024 struct in_addr addr;
5025 int ret;
5026 struct ospf_if_params *params;
5027
5028 params = IF_DEF_PARAMS (ifp);
5029
5030 seconds = strtol (argv[0], NULL, 10);
5031
5032 /* HelloInterval range is <1-65535>. */
5033 if (seconds < 1 || seconds > 65535)
5034 {
5035 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5036 return CMD_WARNING;
5037 }
5038
5039 if (argc == 2)
5040 {
5041 ret = inet_aton(argv[1], &addr);
5042 if (!ret)
5043 {
5044 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5045 VTY_NEWLINE);
5046 return CMD_WARNING;
5047 }
5048
5049 params = ospf_get_if_params (ifp, addr);
5050 ospf_if_update_params (ifp, addr);
5051 }
5052
paulf9ad9372005-10-21 00:45:17 +00005053 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005054 params->v_hello = seconds;
5055
5056 return CMD_SUCCESS;
5057}
5058
5059ALIAS (ip_ospf_hello_interval,
5060 ip_ospf_hello_interval_cmd,
5061 "ip ospf hello-interval <1-65535>",
5062 "IP Information\n"
5063 "OSPF interface commands\n"
5064 "Time between HELLO packets\n"
5065 "Seconds\n")
5066
5067ALIAS (ip_ospf_hello_interval,
5068 ospf_hello_interval_cmd,
5069 "ospf hello-interval <1-65535>",
5070 "OSPF interface commands\n"
5071 "Time between HELLO packets\n"
5072 "Seconds\n")
5073
5074DEFUN (no_ip_ospf_hello_interval,
5075 no_ip_ospf_hello_interval_addr_cmd,
5076 "no ip ospf hello-interval A.B.C.D",
5077 NO_STR
5078 "IP Information\n"
5079 "OSPF interface commands\n"
5080 "Time between HELLO packets\n"
5081 "Address of interface")
5082{
5083 struct interface *ifp = vty->index;
5084 struct in_addr addr;
5085 int ret;
5086 struct ospf_if_params *params;
5087
5088 ifp = vty->index;
5089 params = IF_DEF_PARAMS (ifp);
5090
5091 if (argc == 1)
5092 {
5093 ret = inet_aton(argv[0], &addr);
5094 if (!ret)
5095 {
5096 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5097 VTY_NEWLINE);
5098 return CMD_WARNING;
5099 }
5100
5101 params = ospf_lookup_if_params (ifp, addr);
5102 if (params == NULL)
5103 return CMD_SUCCESS;
5104 }
5105
5106 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005107 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005108
5109 if (params != IF_DEF_PARAMS (ifp))
5110 {
5111 ospf_free_if_params (ifp, addr);
5112 ospf_if_update_params (ifp, addr);
5113 }
5114
5115 return CMD_SUCCESS;
5116}
5117
5118ALIAS (no_ip_ospf_hello_interval,
5119 no_ip_ospf_hello_interval_cmd,
5120 "no ip ospf hello-interval",
5121 NO_STR
5122 "IP Information\n"
5123 "OSPF interface commands\n"
5124 "Time between HELLO packets\n")
5125
5126ALIAS (no_ip_ospf_hello_interval,
5127 no_ospf_hello_interval_cmd,
5128 "no ospf hello-interval",
5129 NO_STR
5130 "OSPF interface commands\n"
5131 "Time between HELLO packets\n")
5132
5133DEFUN (ip_ospf_network,
5134 ip_ospf_network_cmd,
5135 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5136 "IP Information\n"
5137 "OSPF interface commands\n"
5138 "Network type\n"
5139 "Specify OSPF broadcast multi-access network\n"
5140 "Specify OSPF NBMA network\n"
5141 "Specify OSPF point-to-multipoint network\n"
5142 "Specify OSPF point-to-point network\n")
5143{
5144 struct interface *ifp = vty->index;
5145 int old_type = IF_DEF_PARAMS (ifp)->type;
5146 struct route_node *rn;
5147
5148 if (strncmp (argv[0], "b", 1) == 0)
5149 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5150 else if (strncmp (argv[0], "n", 1) == 0)
5151 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5152 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5153 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5154 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5155 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5156
5157 if (IF_DEF_PARAMS (ifp)->type == old_type)
5158 return CMD_SUCCESS;
5159
5160 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5161
5162 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5163 {
5164 struct ospf_interface *oi = rn->info;
5165
5166 if (!oi)
5167 continue;
5168
5169 oi->type = IF_DEF_PARAMS (ifp)->type;
5170
5171 if (oi->state > ISM_Down)
5172 {
5173 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5174 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5175 }
5176 }
5177
5178 return CMD_SUCCESS;
5179}
5180
5181ALIAS (ip_ospf_network,
5182 ospf_network_cmd,
5183 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5184 "OSPF interface commands\n"
5185 "Network type\n"
5186 "Specify OSPF broadcast multi-access network\n"
5187 "Specify OSPF NBMA network\n"
5188 "Specify OSPF point-to-multipoint network\n"
5189 "Specify OSPF point-to-point network\n")
5190
5191DEFUN (no_ip_ospf_network,
5192 no_ip_ospf_network_cmd,
5193 "no ip ospf network",
5194 NO_STR
5195 "IP Information\n"
5196 "OSPF interface commands\n"
5197 "Network type\n")
5198{
5199 struct interface *ifp = vty->index;
5200 int old_type = IF_DEF_PARAMS (ifp)->type;
5201 struct route_node *rn;
5202
ajsbc18d612004-12-15 15:07:19 +00005203 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005204
5205 if (IF_DEF_PARAMS (ifp)->type == old_type)
5206 return CMD_SUCCESS;
5207
5208 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5209 {
5210 struct ospf_interface *oi = rn->info;
5211
5212 if (!oi)
5213 continue;
5214
5215 oi->type = IF_DEF_PARAMS (ifp)->type;
5216
5217 if (oi->state > ISM_Down)
5218 {
5219 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5220 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5221 }
5222 }
5223
5224 return CMD_SUCCESS;
5225}
5226
5227ALIAS (no_ip_ospf_network,
5228 no_ospf_network_cmd,
5229 "no ospf network",
5230 NO_STR
5231 "OSPF interface commands\n"
5232 "Network type\n")
5233
5234DEFUN (ip_ospf_priority,
5235 ip_ospf_priority_addr_cmd,
5236 "ip ospf priority <0-255> A.B.C.D",
5237 "IP Information\n"
5238 "OSPF interface commands\n"
5239 "Router priority\n"
5240 "Priority\n"
5241 "Address of interface")
5242{
5243 struct interface *ifp = vty->index;
5244 u_int32_t priority;
5245 struct route_node *rn;
5246 struct in_addr addr;
5247 int ret;
5248 struct ospf_if_params *params;
5249
5250 params = IF_DEF_PARAMS (ifp);
5251
5252 priority = strtol (argv[0], NULL, 10);
5253
5254 /* Router Priority range is <0-255>. */
5255 if (priority < 0 || priority > 255)
5256 {
5257 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5258 return CMD_WARNING;
5259 }
5260
5261 if (argc == 2)
5262 {
5263 ret = inet_aton(argv[1], &addr);
5264 if (!ret)
5265 {
5266 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5267 VTY_NEWLINE);
5268 return CMD_WARNING;
5269 }
5270
5271 params = ospf_get_if_params (ifp, addr);
5272 ospf_if_update_params (ifp, addr);
5273 }
5274
5275 SET_IF_PARAM (params, priority);
5276 params->priority = priority;
5277
5278 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5279 {
5280 struct ospf_interface *oi = rn->info;
5281
5282 if (!oi)
5283 continue;
5284
5285
5286 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5287 {
5288 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5289 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5290 }
5291 }
5292
5293 return CMD_SUCCESS;
5294}
5295
5296ALIAS (ip_ospf_priority,
5297 ip_ospf_priority_cmd,
5298 "ip ospf priority <0-255>",
5299 "IP Information\n"
5300 "OSPF interface commands\n"
5301 "Router priority\n"
5302 "Priority\n")
5303
5304ALIAS (ip_ospf_priority,
5305 ospf_priority_cmd,
5306 "ospf priority <0-255>",
5307 "OSPF interface commands\n"
5308 "Router priority\n"
5309 "Priority\n")
5310
5311DEFUN (no_ip_ospf_priority,
5312 no_ip_ospf_priority_addr_cmd,
5313 "no ip ospf priority A.B.C.D",
5314 NO_STR
5315 "IP Information\n"
5316 "OSPF interface commands\n"
5317 "Router priority\n"
5318 "Address of interface")
5319{
5320 struct interface *ifp = vty->index;
5321 struct route_node *rn;
5322 struct in_addr addr;
5323 int ret;
5324 struct ospf_if_params *params;
5325
5326 ifp = vty->index;
5327 params = IF_DEF_PARAMS (ifp);
5328
5329 if (argc == 1)
5330 {
5331 ret = inet_aton(argv[0], &addr);
5332 if (!ret)
5333 {
5334 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5335 VTY_NEWLINE);
5336 return CMD_WARNING;
5337 }
5338
5339 params = ospf_lookup_if_params (ifp, addr);
5340 if (params == NULL)
5341 return CMD_SUCCESS;
5342 }
5343
5344 UNSET_IF_PARAM (params, priority);
5345 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5346
5347 if (params != IF_DEF_PARAMS (ifp))
5348 {
5349 ospf_free_if_params (ifp, addr);
5350 ospf_if_update_params (ifp, addr);
5351 }
5352
5353 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5354 {
5355 struct ospf_interface *oi = rn->info;
5356
5357 if (!oi)
5358 continue;
5359
5360
5361 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5362 {
5363 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5364 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5365 }
5366 }
5367
5368 return CMD_SUCCESS;
5369}
5370
5371ALIAS (no_ip_ospf_priority,
5372 no_ip_ospf_priority_cmd,
5373 "no ip ospf priority",
5374 NO_STR
5375 "IP Information\n"
5376 "OSPF interface commands\n"
5377 "Router priority\n")
5378
5379ALIAS (no_ip_ospf_priority,
5380 no_ospf_priority_cmd,
5381 "no ospf priority",
5382 NO_STR
5383 "OSPF interface commands\n"
5384 "Router priority\n")
5385
5386DEFUN (ip_ospf_retransmit_interval,
5387 ip_ospf_retransmit_interval_addr_cmd,
5388 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5389 "IP Information\n"
5390 "OSPF interface commands\n"
5391 "Time between retransmitting lost link state advertisements\n"
5392 "Seconds\n"
5393 "Address of interface")
5394{
5395 struct interface *ifp = vty->index;
5396 u_int32_t seconds;
5397 struct in_addr addr;
5398 int ret;
5399 struct ospf_if_params *params;
5400
5401 params = IF_DEF_PARAMS (ifp);
5402 seconds = strtol (argv[0], NULL, 10);
5403
5404 /* Retransmit Interval range is <3-65535>. */
5405 if (seconds < 3 || seconds > 65535)
5406 {
5407 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5408 return CMD_WARNING;
5409 }
5410
5411
5412 if (argc == 2)
5413 {
5414 ret = inet_aton(argv[1], &addr);
5415 if (!ret)
5416 {
5417 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5418 VTY_NEWLINE);
5419 return CMD_WARNING;
5420 }
5421
5422 params = ospf_get_if_params (ifp, addr);
5423 ospf_if_update_params (ifp, addr);
5424 }
5425
5426 SET_IF_PARAM (params, retransmit_interval);
5427 params->retransmit_interval = seconds;
5428
5429 return CMD_SUCCESS;
5430}
5431
5432ALIAS (ip_ospf_retransmit_interval,
5433 ip_ospf_retransmit_interval_cmd,
5434 "ip ospf retransmit-interval <3-65535>",
5435 "IP Information\n"
5436 "OSPF interface commands\n"
5437 "Time between retransmitting lost link state advertisements\n"
5438 "Seconds\n")
5439
5440ALIAS (ip_ospf_retransmit_interval,
5441 ospf_retransmit_interval_cmd,
5442 "ospf retransmit-interval <3-65535>",
5443 "OSPF interface commands\n"
5444 "Time between retransmitting lost link state advertisements\n"
5445 "Seconds\n")
5446
5447DEFUN (no_ip_ospf_retransmit_interval,
5448 no_ip_ospf_retransmit_interval_addr_cmd,
5449 "no ip ospf retransmit-interval A.B.C.D",
5450 NO_STR
5451 "IP Information\n"
5452 "OSPF interface commands\n"
5453 "Time between retransmitting lost link state advertisements\n"
5454 "Address of interface")
5455{
5456 struct interface *ifp = vty->index;
5457 struct in_addr addr;
5458 int ret;
5459 struct ospf_if_params *params;
5460
5461 ifp = vty->index;
5462 params = IF_DEF_PARAMS (ifp);
5463
5464 if (argc == 1)
5465 {
5466 ret = inet_aton(argv[0], &addr);
5467 if (!ret)
5468 {
5469 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5470 VTY_NEWLINE);
5471 return CMD_WARNING;
5472 }
5473
5474 params = ospf_lookup_if_params (ifp, addr);
5475 if (params == NULL)
5476 return CMD_SUCCESS;
5477 }
5478
5479 UNSET_IF_PARAM (params, retransmit_interval);
5480 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5481
5482 if (params != IF_DEF_PARAMS (ifp))
5483 {
5484 ospf_free_if_params (ifp, addr);
5485 ospf_if_update_params (ifp, addr);
5486 }
5487
5488 return CMD_SUCCESS;
5489}
5490
5491ALIAS (no_ip_ospf_retransmit_interval,
5492 no_ip_ospf_retransmit_interval_cmd,
5493 "no ip ospf retransmit-interval",
5494 NO_STR
5495 "IP Information\n"
5496 "OSPF interface commands\n"
5497 "Time between retransmitting lost link state advertisements\n")
5498
5499ALIAS (no_ip_ospf_retransmit_interval,
5500 no_ospf_retransmit_interval_cmd,
5501 "no ospf retransmit-interval",
5502 NO_STR
5503 "OSPF interface commands\n"
5504 "Time between retransmitting lost link state advertisements\n")
5505
5506DEFUN (ip_ospf_transmit_delay,
5507 ip_ospf_transmit_delay_addr_cmd,
5508 "ip ospf transmit-delay <1-65535> A.B.C.D",
5509 "IP Information\n"
5510 "OSPF interface commands\n"
5511 "Link state transmit delay\n"
5512 "Seconds\n"
5513 "Address of interface")
5514{
5515 struct interface *ifp = vty->index;
5516 u_int32_t seconds;
5517 struct in_addr addr;
5518 int ret;
5519 struct ospf_if_params *params;
5520
5521 params = IF_DEF_PARAMS (ifp);
5522 seconds = strtol (argv[0], NULL, 10);
5523
5524 /* Transmit Delay range is <1-65535>. */
5525 if (seconds < 1 || seconds > 65535)
5526 {
5527 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5528 return CMD_WARNING;
5529 }
5530
5531 if (argc == 2)
5532 {
5533 ret = inet_aton(argv[1], &addr);
5534 if (!ret)
5535 {
5536 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5537 VTY_NEWLINE);
5538 return CMD_WARNING;
5539 }
5540
5541 params = ospf_get_if_params (ifp, addr);
5542 ospf_if_update_params (ifp, addr);
5543 }
5544
5545 SET_IF_PARAM (params, transmit_delay);
5546 params->transmit_delay = seconds;
5547
5548 return CMD_SUCCESS;
5549}
5550
5551ALIAS (ip_ospf_transmit_delay,
5552 ip_ospf_transmit_delay_cmd,
5553 "ip ospf transmit-delay <1-65535>",
5554 "IP Information\n"
5555 "OSPF interface commands\n"
5556 "Link state transmit delay\n"
5557 "Seconds\n")
5558
5559ALIAS (ip_ospf_transmit_delay,
5560 ospf_transmit_delay_cmd,
5561 "ospf transmit-delay <1-65535>",
5562 "OSPF interface commands\n"
5563 "Link state transmit delay\n"
5564 "Seconds\n")
5565
5566DEFUN (no_ip_ospf_transmit_delay,
5567 no_ip_ospf_transmit_delay_addr_cmd,
5568 "no ip ospf transmit-delay A.B.C.D",
5569 NO_STR
5570 "IP Information\n"
5571 "OSPF interface commands\n"
5572 "Link state transmit delay\n"
5573 "Address of interface")
5574{
5575 struct interface *ifp = vty->index;
5576 struct in_addr addr;
5577 int ret;
5578 struct ospf_if_params *params;
5579
5580 ifp = vty->index;
5581 params = IF_DEF_PARAMS (ifp);
5582
5583 if (argc == 1)
5584 {
5585 ret = inet_aton(argv[0], &addr);
5586 if (!ret)
5587 {
5588 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5589 VTY_NEWLINE);
5590 return CMD_WARNING;
5591 }
5592
5593 params = ospf_lookup_if_params (ifp, addr);
5594 if (params == NULL)
5595 return CMD_SUCCESS;
5596 }
5597
5598 UNSET_IF_PARAM (params, transmit_delay);
5599 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5600
5601 if (params != IF_DEF_PARAMS (ifp))
5602 {
5603 ospf_free_if_params (ifp, addr);
5604 ospf_if_update_params (ifp, addr);
5605 }
5606
5607 return CMD_SUCCESS;
5608}
5609
5610ALIAS (no_ip_ospf_transmit_delay,
5611 no_ip_ospf_transmit_delay_cmd,
5612 "no ip ospf transmit-delay",
5613 NO_STR
5614 "IP Information\n"
5615 "OSPF interface commands\n"
5616 "Link state transmit delay\n")
5617
5618ALIAS (no_ip_ospf_transmit_delay,
5619 no_ospf_transmit_delay_cmd,
5620 "no ospf transmit-delay",
5621 NO_STR
5622 "OSPF interface commands\n"
5623 "Link state transmit delay\n")
5624
5625
5626DEFUN (ospf_redistribute_source_metric_type,
5627 ospf_redistribute_source_metric_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005628 "redistribute " QUAGGA_REDIST_STR_OSPFD
5629 " metric <0-16777214> metric-type (1|2) route-map WORD",
5630 REDIST_STR
5631 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005632 "Metric for redistributed routes\n"
5633 "OSPF default metric\n"
5634 "OSPF exterior metric type for redistributed routes\n"
5635 "Set OSPF External Type 1 metrics\n"
5636 "Set OSPF External Type 2 metrics\n"
5637 "Route map reference\n"
5638 "Pointer to route-map entries\n")
5639{
paul020709f2003-04-04 02:44:16 +00005640 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005641 int source;
5642 int type = -1;
5643 int metric = -1;
5644
5645 /* Get distribute source. */
5646 if (!str2distribute_source (argv[0], &source))
5647 return CMD_WARNING;
5648
5649 /* Get metric value. */
5650 if (argc >= 2)
5651 if (!str2metric (argv[1], &metric))
5652 return CMD_WARNING;
5653
5654 /* Get metric type. */
5655 if (argc >= 3)
5656 if (!str2metric_type (argv[2], &type))
5657 return CMD_WARNING;
5658
5659 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005660 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005661 else
paul020709f2003-04-04 02:44:16 +00005662 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005663
paul020709f2003-04-04 02:44:16 +00005664 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005665}
5666
5667ALIAS (ospf_redistribute_source_metric_type,
5668 ospf_redistribute_source_metric_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005669 "redistribute " QUAGGA_REDIST_STR_OSPFD
5670 " metric <0-16777214> metric-type (1|2)",
5671 REDIST_STR
5672 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005673 "Metric for redistributed routes\n"
5674 "OSPF default metric\n"
5675 "OSPF exterior metric type for redistributed routes\n"
5676 "Set OSPF External Type 1 metrics\n"
5677 "Set OSPF External Type 2 metrics\n")
5678
5679ALIAS (ospf_redistribute_source_metric_type,
5680 ospf_redistribute_source_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005681 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5682 REDIST_STR
5683 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005684 "Metric for redistributed routes\n"
5685 "OSPF default metric\n")
5686
5687DEFUN (ospf_redistribute_source_type_metric,
5688 ospf_redistribute_source_type_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005689 "redistribute " QUAGGA_REDIST_STR_OSPFD
5690 " metric-type (1|2) metric <0-16777214> route-map WORD",
5691 REDIST_STR
5692 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005693 "OSPF exterior metric type for redistributed routes\n"
5694 "Set OSPF External Type 1 metrics\n"
5695 "Set OSPF External Type 2 metrics\n"
5696 "Metric for redistributed routes\n"
5697 "OSPF default metric\n"
5698 "Route map reference\n"
5699 "Pointer to route-map entries\n")
5700{
paul020709f2003-04-04 02:44:16 +00005701 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005702 int source;
5703 int type = -1;
5704 int metric = -1;
5705
5706 /* Get distribute source. */
5707 if (!str2distribute_source (argv[0], &source))
5708 return CMD_WARNING;
5709
5710 /* Get metric value. */
5711 if (argc >= 2)
5712 if (!str2metric_type (argv[1], &type))
5713 return CMD_WARNING;
5714
5715 /* Get metric type. */
5716 if (argc >= 3)
5717 if (!str2metric (argv[2], &metric))
5718 return CMD_WARNING;
5719
5720 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005721 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005722 else
paul020709f2003-04-04 02:44:16 +00005723 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005724
paul020709f2003-04-04 02:44:16 +00005725 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005726}
5727
5728ALIAS (ospf_redistribute_source_type_metric,
5729 ospf_redistribute_source_type_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005730 "redistribute " QUAGGA_REDIST_STR_OSPFD
5731 " metric-type (1|2) metric <0-16777214>",
5732 REDIST_STR
5733 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005734 "OSPF exterior metric type for redistributed routes\n"
5735 "Set OSPF External Type 1 metrics\n"
5736 "Set OSPF External Type 2 metrics\n"
5737 "Metric for redistributed routes\n"
5738 "OSPF default metric\n")
5739
5740ALIAS (ospf_redistribute_source_type_metric,
5741 ospf_redistribute_source_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005742 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5743 REDIST_STR
5744 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005745 "OSPF exterior metric type for redistributed routes\n"
5746 "Set OSPF External Type 1 metrics\n"
5747 "Set OSPF External Type 2 metrics\n")
5748
5749ALIAS (ospf_redistribute_source_type_metric,
5750 ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005751 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5752 REDIST_STR
5753 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005754
5755DEFUN (ospf_redistribute_source_metric_routemap,
5756 ospf_redistribute_source_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005757 "redistribute " QUAGGA_REDIST_STR_OSPFD
5758 " metric <0-16777214> route-map WORD",
5759 REDIST_STR
5760 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005761 "Metric for redistributed routes\n"
5762 "OSPF default metric\n"
5763 "Route map reference\n"
5764 "Pointer to route-map entries\n")
5765{
paul020709f2003-04-04 02:44:16 +00005766 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005767 int source;
5768 int metric = -1;
5769
5770 /* Get distribute source. */
5771 if (!str2distribute_source (argv[0], &source))
5772 return CMD_WARNING;
5773
5774 /* Get metric value. */
5775 if (argc >= 2)
5776 if (!str2metric (argv[1], &metric))
5777 return CMD_WARNING;
5778
5779 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005780 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005781 else
paul020709f2003-04-04 02:44:16 +00005782 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005783
paul020709f2003-04-04 02:44:16 +00005784 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005785}
5786
5787DEFUN (ospf_redistribute_source_type_routemap,
5788 ospf_redistribute_source_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005789 "redistribute " QUAGGA_REDIST_STR_OSPFD
5790 " metric-type (1|2) route-map WORD",
5791 REDIST_STR
5792 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005793 "OSPF exterior metric type for redistributed routes\n"
5794 "Set OSPF External Type 1 metrics\n"
5795 "Set OSPF External Type 2 metrics\n"
5796 "Route map reference\n"
5797 "Pointer to route-map entries\n")
5798{
paul020709f2003-04-04 02:44:16 +00005799 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005800 int source;
5801 int type = -1;
5802
5803 /* Get distribute source. */
5804 if (!str2distribute_source (argv[0], &source))
5805 return CMD_WARNING;
5806
5807 /* Get metric value. */
5808 if (argc >= 2)
5809 if (!str2metric_type (argv[1], &type))
5810 return CMD_WARNING;
5811
5812 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005813 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005814 else
paul020709f2003-04-04 02:44:16 +00005815 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005816
paul020709f2003-04-04 02:44:16 +00005817 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005818}
5819
5820DEFUN (ospf_redistribute_source_routemap,
5821 ospf_redistribute_source_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005822 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5823 REDIST_STR
5824 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005825 "Route map reference\n"
5826 "Pointer to route-map entries\n")
5827{
paul020709f2003-04-04 02:44:16 +00005828 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005829 int source;
5830
5831 /* Get distribute source. */
5832 if (!str2distribute_source (argv[0], &source))
5833 return CMD_WARNING;
5834
5835 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005836 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005837 else
paul020709f2003-04-04 02:44:16 +00005838 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005839
paul020709f2003-04-04 02:44:16 +00005840 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005841}
5842
5843DEFUN (no_ospf_redistribute_source,
5844 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005845 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005846 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005847 REDIST_STR
5848 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005849{
paul020709f2003-04-04 02:44:16 +00005850 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005851 int source;
5852
5853 if (!str2distribute_source (argv[0], &source))
5854 return CMD_WARNING;
5855
paul020709f2003-04-04 02:44:16 +00005856 ospf_routemap_unset (ospf, source);
5857 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005858}
5859
5860DEFUN (ospf_distribute_list_out,
5861 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005862 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005863 "Filter networks in routing updates\n"
5864 "Access-list name\n"
5865 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005866 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005867{
paul68980082003-03-25 05:07:42 +00005868 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005869 int source;
5870
5871 /* Get distribute source. */
5872 if (!str2distribute_source (argv[1], &source))
5873 return CMD_WARNING;
5874
paul68980082003-03-25 05:07:42 +00005875 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005876}
5877
5878DEFUN (no_ospf_distribute_list_out,
5879 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005880 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00005881 NO_STR
5882 "Filter networks in routing updates\n"
5883 "Access-list name\n"
5884 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00005885 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005886{
paul68980082003-03-25 05:07:42 +00005887 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005888 int source;
5889
5890 if (!str2distribute_source (argv[1], &source))
5891 return CMD_WARNING;
5892
paul68980082003-03-25 05:07:42 +00005893 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005894}
5895
5896/* Default information originate. */
5897DEFUN (ospf_default_information_originate_metric_type_routemap,
5898 ospf_default_information_originate_metric_type_routemap_cmd,
5899 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5900 "Control distribution of default information\n"
5901 "Distribute a default route\n"
5902 "OSPF default metric\n"
5903 "OSPF metric\n"
5904 "OSPF metric type for default routes\n"
5905 "Set OSPF External Type 1 metrics\n"
5906 "Set OSPF External Type 2 metrics\n"
5907 "Route map reference\n"
5908 "Pointer to route-map entries\n")
5909{
paul020709f2003-04-04 02:44:16 +00005910 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005911 int type = -1;
5912 int metric = -1;
5913
5914 /* Get metric value. */
5915 if (argc >= 1)
5916 if (!str2metric (argv[0], &metric))
5917 return CMD_WARNING;
5918
5919 /* Get metric type. */
5920 if (argc >= 2)
5921 if (!str2metric_type (argv[1], &type))
5922 return CMD_WARNING;
5923
5924 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005925 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005926 else
paul020709f2003-04-04 02:44:16 +00005927 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005928
paul020709f2003-04-04 02:44:16 +00005929 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5930 type, metric);
paul718e3742002-12-13 20:15:29 +00005931}
5932
5933ALIAS (ospf_default_information_originate_metric_type_routemap,
5934 ospf_default_information_originate_metric_type_cmd,
5935 "default-information originate metric <0-16777214> metric-type (1|2)",
5936 "Control distribution of default information\n"
5937 "Distribute a default route\n"
5938 "OSPF default metric\n"
5939 "OSPF metric\n"
5940 "OSPF metric type for default routes\n"
5941 "Set OSPF External Type 1 metrics\n"
5942 "Set OSPF External Type 2 metrics\n")
5943
5944ALIAS (ospf_default_information_originate_metric_type_routemap,
5945 ospf_default_information_originate_metric_cmd,
5946 "default-information originate metric <0-16777214>",
5947 "Control distribution of default information\n"
5948 "Distribute a default route\n"
5949 "OSPF default metric\n"
5950 "OSPF metric\n")
5951
5952ALIAS (ospf_default_information_originate_metric_type_routemap,
5953 ospf_default_information_originate_cmd,
5954 "default-information originate",
5955 "Control distribution of default information\n"
5956 "Distribute a default route\n")
5957
5958/* Default information originate. */
5959DEFUN (ospf_default_information_originate_metric_routemap,
5960 ospf_default_information_originate_metric_routemap_cmd,
5961 "default-information originate metric <0-16777214> route-map WORD",
5962 "Control distribution of default information\n"
5963 "Distribute a default route\n"
5964 "OSPF default metric\n"
5965 "OSPF metric\n"
5966 "Route map reference\n"
5967 "Pointer to route-map entries\n")
5968{
paul020709f2003-04-04 02:44:16 +00005969 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005970 int metric = -1;
5971
5972 /* Get metric value. */
5973 if (argc >= 1)
5974 if (!str2metric (argv[0], &metric))
5975 return CMD_WARNING;
5976
5977 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005978 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005979 else
paul020709f2003-04-04 02:44:16 +00005980 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005981
paul020709f2003-04-04 02:44:16 +00005982 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5983 -1, metric);
paul718e3742002-12-13 20:15:29 +00005984}
5985
5986/* Default information originate. */
5987DEFUN (ospf_default_information_originate_routemap,
5988 ospf_default_information_originate_routemap_cmd,
5989 "default-information originate route-map WORD",
5990 "Control distribution of default information\n"
5991 "Distribute a default route\n"
5992 "Route map reference\n"
5993 "Pointer to route-map entries\n")
5994{
paul020709f2003-04-04 02:44:16 +00005995 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005996
paul020709f2003-04-04 02:44:16 +00005997 if (argc == 1)
5998 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5999 else
6000 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6001
6002 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00006003}
6004
6005DEFUN (ospf_default_information_originate_type_metric_routemap,
6006 ospf_default_information_originate_type_metric_routemap_cmd,
6007 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6008 "Control distribution of default information\n"
6009 "Distribute a default route\n"
6010 "OSPF metric type for default routes\n"
6011 "Set OSPF External Type 1 metrics\n"
6012 "Set OSPF External Type 2 metrics\n"
6013 "OSPF default metric\n"
6014 "OSPF metric\n"
6015 "Route map reference\n"
6016 "Pointer to route-map entries\n")
6017{
paul020709f2003-04-04 02:44:16 +00006018 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006019 int type = -1;
6020 int metric = -1;
6021
6022 /* Get metric type. */
6023 if (argc >= 1)
6024 if (!str2metric_type (argv[0], &type))
6025 return CMD_WARNING;
6026
6027 /* Get metric value. */
6028 if (argc >= 2)
6029 if (!str2metric (argv[1], &metric))
6030 return CMD_WARNING;
6031
6032 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006033 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006034 else
paul020709f2003-04-04 02:44:16 +00006035 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006036
paul020709f2003-04-04 02:44:16 +00006037 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6038 type, metric);
paul718e3742002-12-13 20:15:29 +00006039}
6040
6041ALIAS (ospf_default_information_originate_type_metric_routemap,
6042 ospf_default_information_originate_type_metric_cmd,
6043 "default-information originate metric-type (1|2) metric <0-16777214>",
6044 "Control distribution of default information\n"
6045 "Distribute a default route\n"
6046 "OSPF metric type for default routes\n"
6047 "Set OSPF External Type 1 metrics\n"
6048 "Set OSPF External Type 2 metrics\n"
6049 "OSPF default metric\n"
6050 "OSPF metric\n")
6051
6052ALIAS (ospf_default_information_originate_type_metric_routemap,
6053 ospf_default_information_originate_type_cmd,
6054 "default-information originate metric-type (1|2)",
6055 "Control distribution of default information\n"
6056 "Distribute a default route\n"
6057 "OSPF metric type for default routes\n"
6058 "Set OSPF External Type 1 metrics\n"
6059 "Set OSPF External Type 2 metrics\n")
6060
6061DEFUN (ospf_default_information_originate_type_routemap,
6062 ospf_default_information_originate_type_routemap_cmd,
6063 "default-information originate metric-type (1|2) route-map WORD",
6064 "Control distribution of default information\n"
6065 "Distribute a default route\n"
6066 "OSPF metric type for default routes\n"
6067 "Set OSPF External Type 1 metrics\n"
6068 "Set OSPF External Type 2 metrics\n"
6069 "Route map reference\n"
6070 "Pointer to route-map entries\n")
6071{
paul020709f2003-04-04 02:44:16 +00006072 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006073 int type = -1;
6074
6075 /* Get metric type. */
6076 if (argc >= 1)
6077 if (!str2metric_type (argv[0], &type))
6078 return CMD_WARNING;
6079
6080 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006081 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006082 else
paul020709f2003-04-04 02:44:16 +00006083 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006084
paul020709f2003-04-04 02:44:16 +00006085 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6086 type, -1);
paul718e3742002-12-13 20:15:29 +00006087}
6088
6089DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6090 ospf_default_information_originate_always_metric_type_routemap_cmd,
6091 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6092 "Control distribution of default information\n"
6093 "Distribute a default route\n"
6094 "Always advertise default route\n"
6095 "OSPF default metric\n"
6096 "OSPF metric\n"
6097 "OSPF metric type for default routes\n"
6098 "Set OSPF External Type 1 metrics\n"
6099 "Set OSPF External Type 2 metrics\n"
6100 "Route map reference\n"
6101 "Pointer to route-map entries\n")
6102{
paul020709f2003-04-04 02:44:16 +00006103 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006104 int type = -1;
6105 int metric = -1;
6106
6107 /* Get metric value. */
6108 if (argc >= 1)
6109 if (!str2metric (argv[0], &metric))
6110 return CMD_WARNING;
6111
6112 /* Get metric type. */
6113 if (argc >= 2)
6114 if (!str2metric_type (argv[1], &type))
6115 return CMD_WARNING;
6116
6117 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006118 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006119 else
paul020709f2003-04-04 02:44:16 +00006120 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006121
paul020709f2003-04-04 02:44:16 +00006122 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006123 type, metric);
6124}
6125
6126ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6127 ospf_default_information_originate_always_metric_type_cmd,
6128 "default-information originate always metric <0-16777214> metric-type (1|2)",
6129 "Control distribution of default information\n"
6130 "Distribute a default route\n"
6131 "Always advertise default route\n"
6132 "OSPF default metric\n"
6133 "OSPF metric\n"
6134 "OSPF metric type for default routes\n"
6135 "Set OSPF External Type 1 metrics\n"
6136 "Set OSPF External Type 2 metrics\n")
6137
6138ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6139 ospf_default_information_originate_always_metric_cmd,
6140 "default-information originate always metric <0-16777214>",
6141 "Control distribution of default information\n"
6142 "Distribute a default route\n"
6143 "Always advertise default route\n"
6144 "OSPF default metric\n"
6145 "OSPF metric\n"
6146 "OSPF metric type for default routes\n")
6147
6148ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6149 ospf_default_information_originate_always_cmd,
6150 "default-information originate always",
6151 "Control distribution of default information\n"
6152 "Distribute a default route\n"
6153 "Always advertise default route\n")
6154
6155DEFUN (ospf_default_information_originate_always_metric_routemap,
6156 ospf_default_information_originate_always_metric_routemap_cmd,
6157 "default-information originate always metric <0-16777214> route-map WORD",
6158 "Control distribution of default information\n"
6159 "Distribute a default route\n"
6160 "Always advertise default route\n"
6161 "OSPF default metric\n"
6162 "OSPF metric\n"
6163 "Route map reference\n"
6164 "Pointer to route-map entries\n")
6165{
paul020709f2003-04-04 02:44:16 +00006166 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006167 int metric = -1;
6168
6169 /* Get metric value. */
6170 if (argc >= 1)
6171 if (!str2metric (argv[0], &metric))
6172 return CMD_WARNING;
6173
6174 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006175 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006176 else
paul020709f2003-04-04 02:44:16 +00006177 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006178
paul020709f2003-04-04 02:44:16 +00006179 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6180 -1, metric);
paul718e3742002-12-13 20:15:29 +00006181}
6182
6183DEFUN (ospf_default_information_originate_always_routemap,
6184 ospf_default_information_originate_always_routemap_cmd,
6185 "default-information originate always route-map WORD",
6186 "Control distribution of default information\n"
6187 "Distribute a default route\n"
6188 "Always advertise default route\n"
6189 "Route map reference\n"
6190 "Pointer to route-map entries\n")
6191{
paul020709f2003-04-04 02:44:16 +00006192 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006193
paul020709f2003-04-04 02:44:16 +00006194 if (argc == 1)
6195 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6196 else
6197 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6198
6199 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006200}
6201
6202DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6203 ospf_default_information_originate_always_type_metric_routemap_cmd,
6204 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6205 "Control distribution of default information\n"
6206 "Distribute a default route\n"
6207 "Always advertise default route\n"
6208 "OSPF metric type for default routes\n"
6209 "Set OSPF External Type 1 metrics\n"
6210 "Set OSPF External Type 2 metrics\n"
6211 "OSPF default metric\n"
6212 "OSPF metric\n"
6213 "Route map reference\n"
6214 "Pointer to route-map entries\n")
6215{
paul020709f2003-04-04 02:44:16 +00006216 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006217 int type = -1;
6218 int metric = -1;
6219
6220 /* Get metric type. */
6221 if (argc >= 1)
6222 if (!str2metric_type (argv[0], &type))
6223 return CMD_WARNING;
6224
6225 /* Get metric value. */
6226 if (argc >= 2)
6227 if (!str2metric (argv[1], &metric))
6228 return CMD_WARNING;
6229
6230 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006231 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006232 else
paul020709f2003-04-04 02:44:16 +00006233 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006234
paul020709f2003-04-04 02:44:16 +00006235 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006236 type, metric);
6237}
6238
6239ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6240 ospf_default_information_originate_always_type_metric_cmd,
6241 "default-information originate always metric-type (1|2) metric <0-16777214>",
6242 "Control distribution of default information\n"
6243 "Distribute a default route\n"
6244 "Always advertise default route\n"
6245 "OSPF metric type for default routes\n"
6246 "Set OSPF External Type 1 metrics\n"
6247 "Set OSPF External Type 2 metrics\n"
6248 "OSPF default metric\n"
6249 "OSPF metric\n")
6250
6251ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6252 ospf_default_information_originate_always_type_cmd,
6253 "default-information originate always metric-type (1|2)",
6254 "Control distribution of default information\n"
6255 "Distribute a default route\n"
6256 "Always advertise default route\n"
6257 "OSPF metric type for default routes\n"
6258 "Set OSPF External Type 1 metrics\n"
6259 "Set OSPF External Type 2 metrics\n")
6260
6261DEFUN (ospf_default_information_originate_always_type_routemap,
6262 ospf_default_information_originate_always_type_routemap_cmd,
6263 "default-information originate always metric-type (1|2) route-map WORD",
6264 "Control distribution of default information\n"
6265 "Distribute a default route\n"
6266 "Always advertise default route\n"
6267 "OSPF metric type for default routes\n"
6268 "Set OSPF External Type 1 metrics\n"
6269 "Set OSPF External Type 2 metrics\n"
6270 "Route map reference\n"
6271 "Pointer to route-map entries\n")
6272{
paul020709f2003-04-04 02:44:16 +00006273 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006274 int type = -1;
6275
6276 /* Get metric type. */
6277 if (argc >= 1)
6278 if (!str2metric_type (argv[0], &type))
6279 return CMD_WARNING;
6280
6281 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006282 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006283 else
paul020709f2003-04-04 02:44:16 +00006284 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006285
paul020709f2003-04-04 02:44:16 +00006286 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006287 type, -1);
6288}
6289
6290DEFUN (no_ospf_default_information_originate,
6291 no_ospf_default_information_originate_cmd,
6292 "no default-information originate",
6293 NO_STR
6294 "Control distribution of default information\n"
6295 "Distribute a default route\n")
6296{
paul68980082003-03-25 05:07:42 +00006297 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006298 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006299
6300 p.family = AF_INET;
6301 p.prefix.s_addr = 0;
6302 p.prefixlen = 0;
6303
ajs5339cfd2005-09-19 13:28:05 +00006304 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006305
6306 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6307 ospf_external_info_delete (DEFAULT_ROUTE, p);
6308 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6309 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6310 }
6311
paul020709f2003-04-04 02:44:16 +00006312 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6313 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006314}
6315
6316DEFUN (ospf_default_metric,
6317 ospf_default_metric_cmd,
6318 "default-metric <0-16777214>",
6319 "Set metric of redistributed routes\n"
6320 "Default metric\n")
6321{
paul68980082003-03-25 05:07:42 +00006322 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006323 int metric = -1;
6324
6325 if (!str2metric (argv[0], &metric))
6326 return CMD_WARNING;
6327
paul68980082003-03-25 05:07:42 +00006328 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006329
6330 return CMD_SUCCESS;
6331}
6332
6333DEFUN (no_ospf_default_metric,
6334 no_ospf_default_metric_cmd,
6335 "no default-metric",
6336 NO_STR
6337 "Set metric of redistributed routes\n")
6338{
paul68980082003-03-25 05:07:42 +00006339 struct ospf *ospf = vty->index;
6340
6341 ospf->default_metric = -1;
6342
paul718e3742002-12-13 20:15:29 +00006343 return CMD_SUCCESS;
6344}
6345
6346ALIAS (no_ospf_default_metric,
6347 no_ospf_default_metric_val_cmd,
6348 "no default-metric <0-16777214>",
6349 NO_STR
6350 "Set metric of redistributed routes\n"
6351 "Default metric\n")
6352
6353DEFUN (ospf_distance,
6354 ospf_distance_cmd,
6355 "distance <1-255>",
6356 "Define an administrative distance\n"
6357 "OSPF Administrative distance\n")
6358{
paul68980082003-03-25 05:07:42 +00006359 struct ospf *ospf = vty->index;
6360
6361 ospf->distance_all = atoi (argv[0]);
6362
paul718e3742002-12-13 20:15:29 +00006363 return CMD_SUCCESS;
6364}
6365
6366DEFUN (no_ospf_distance,
6367 no_ospf_distance_cmd,
6368 "no distance <1-255>",
6369 NO_STR
6370 "Define an administrative distance\n"
6371 "OSPF Administrative distance\n")
6372{
paul68980082003-03-25 05:07:42 +00006373 struct ospf *ospf = vty->index;
6374
6375 ospf->distance_all = 0;
6376
paul718e3742002-12-13 20:15:29 +00006377 return CMD_SUCCESS;
6378}
6379
6380DEFUN (no_ospf_distance_ospf,
6381 no_ospf_distance_ospf_cmd,
6382 "no distance ospf",
6383 NO_STR
6384 "Define an administrative distance\n"
6385 "OSPF Administrative distance\n"
6386 "OSPF Distance\n")
6387{
paul68980082003-03-25 05:07:42 +00006388 struct ospf *ospf = vty->index;
6389
6390 ospf->distance_intra = 0;
6391 ospf->distance_inter = 0;
6392 ospf->distance_external = 0;
6393
paul718e3742002-12-13 20:15:29 +00006394 return CMD_SUCCESS;
6395}
6396
6397DEFUN (ospf_distance_ospf_intra,
6398 ospf_distance_ospf_intra_cmd,
6399 "distance ospf intra-area <1-255>",
6400 "Define an administrative distance\n"
6401 "OSPF Administrative distance\n"
6402 "Intra-area routes\n"
6403 "Distance for intra-area routes\n")
6404{
paul68980082003-03-25 05:07:42 +00006405 struct ospf *ospf = vty->index;
6406
6407 ospf->distance_intra = atoi (argv[0]);
6408
paul718e3742002-12-13 20:15:29 +00006409 return CMD_SUCCESS;
6410}
6411
6412DEFUN (ospf_distance_ospf_intra_inter,
6413 ospf_distance_ospf_intra_inter_cmd,
6414 "distance ospf intra-area <1-255> inter-area <1-255>",
6415 "Define an administrative distance\n"
6416 "OSPF Administrative distance\n"
6417 "Intra-area routes\n"
6418 "Distance for intra-area routes\n"
6419 "Inter-area routes\n"
6420 "Distance for inter-area routes\n")
6421{
paul68980082003-03-25 05:07:42 +00006422 struct ospf *ospf = vty->index;
6423
6424 ospf->distance_intra = atoi (argv[0]);
6425 ospf->distance_inter = atoi (argv[1]);
6426
paul718e3742002-12-13 20:15:29 +00006427 return CMD_SUCCESS;
6428}
6429
6430DEFUN (ospf_distance_ospf_intra_external,
6431 ospf_distance_ospf_intra_external_cmd,
6432 "distance ospf intra-area <1-255> external <1-255>",
6433 "Define an administrative distance\n"
6434 "OSPF Administrative distance\n"
6435 "Intra-area routes\n"
6436 "Distance for intra-area routes\n"
6437 "External routes\n"
6438 "Distance for external routes\n")
6439{
paul68980082003-03-25 05:07:42 +00006440 struct ospf *ospf = vty->index;
6441
6442 ospf->distance_intra = atoi (argv[0]);
6443 ospf->distance_external = atoi (argv[1]);
6444
paul718e3742002-12-13 20:15:29 +00006445 return CMD_SUCCESS;
6446}
6447
6448DEFUN (ospf_distance_ospf_intra_inter_external,
6449 ospf_distance_ospf_intra_inter_external_cmd,
6450 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6451 "Define an administrative distance\n"
6452 "OSPF Administrative distance\n"
6453 "Intra-area routes\n"
6454 "Distance for intra-area routes\n"
6455 "Inter-area routes\n"
6456 "Distance for inter-area routes\n"
6457 "External routes\n"
6458 "Distance for external routes\n")
6459{
paul68980082003-03-25 05:07:42 +00006460 struct ospf *ospf = vty->index;
6461
6462 ospf->distance_intra = atoi (argv[0]);
6463 ospf->distance_inter = atoi (argv[1]);
6464 ospf->distance_external = atoi (argv[2]);
6465
paul718e3742002-12-13 20:15:29 +00006466 return CMD_SUCCESS;
6467}
6468
6469DEFUN (ospf_distance_ospf_intra_external_inter,
6470 ospf_distance_ospf_intra_external_inter_cmd,
6471 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6472 "Define an administrative distance\n"
6473 "OSPF Administrative distance\n"
6474 "Intra-area routes\n"
6475 "Distance for intra-area routes\n"
6476 "External routes\n"
6477 "Distance for external routes\n"
6478 "Inter-area routes\n"
6479 "Distance for inter-area routes\n")
6480{
paul68980082003-03-25 05:07:42 +00006481 struct ospf *ospf = vty->index;
6482
6483 ospf->distance_intra = atoi (argv[0]);
6484 ospf->distance_external = atoi (argv[1]);
6485 ospf->distance_inter = atoi (argv[2]);
6486
paul718e3742002-12-13 20:15:29 +00006487 return CMD_SUCCESS;
6488}
6489
6490DEFUN (ospf_distance_ospf_inter,
6491 ospf_distance_ospf_inter_cmd,
6492 "distance ospf inter-area <1-255>",
6493 "Define an administrative distance\n"
6494 "OSPF Administrative distance\n"
6495 "Inter-area routes\n"
6496 "Distance for inter-area routes\n")
6497{
paul68980082003-03-25 05:07:42 +00006498 struct ospf *ospf = vty->index;
6499
6500 ospf->distance_inter = atoi (argv[0]);
6501
paul718e3742002-12-13 20:15:29 +00006502 return CMD_SUCCESS;
6503}
6504
6505DEFUN (ospf_distance_ospf_inter_intra,
6506 ospf_distance_ospf_inter_intra_cmd,
6507 "distance ospf inter-area <1-255> intra-area <1-255>",
6508 "Define an administrative distance\n"
6509 "OSPF Administrative distance\n"
6510 "Inter-area routes\n"
6511 "Distance for inter-area routes\n"
6512 "Intra-area routes\n"
6513 "Distance for intra-area routes\n")
6514{
paul68980082003-03-25 05:07:42 +00006515 struct ospf *ospf = vty->index;
6516
6517 ospf->distance_inter = atoi (argv[0]);
6518 ospf->distance_intra = atoi (argv[1]);
6519
paul718e3742002-12-13 20:15:29 +00006520 return CMD_SUCCESS;
6521}
6522
6523DEFUN (ospf_distance_ospf_inter_external,
6524 ospf_distance_ospf_inter_external_cmd,
6525 "distance ospf inter-area <1-255> external <1-255>",
6526 "Define an administrative distance\n"
6527 "OSPF Administrative distance\n"
6528 "Inter-area routes\n"
6529 "Distance for inter-area routes\n"
6530 "External routes\n"
6531 "Distance for external routes\n")
6532{
paul68980082003-03-25 05:07:42 +00006533 struct ospf *ospf = vty->index;
6534
6535 ospf->distance_inter = atoi (argv[0]);
6536 ospf->distance_external = atoi (argv[1]);
6537
paul718e3742002-12-13 20:15:29 +00006538 return CMD_SUCCESS;
6539}
6540
6541DEFUN (ospf_distance_ospf_inter_intra_external,
6542 ospf_distance_ospf_inter_intra_external_cmd,
6543 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6544 "Define an administrative distance\n"
6545 "OSPF Administrative distance\n"
6546 "Inter-area routes\n"
6547 "Distance for inter-area routes\n"
6548 "Intra-area routes\n"
6549 "Distance for intra-area routes\n"
6550 "External routes\n"
6551 "Distance for external routes\n")
6552{
paul68980082003-03-25 05:07:42 +00006553 struct ospf *ospf = vty->index;
6554
6555 ospf->distance_inter = atoi (argv[0]);
6556 ospf->distance_intra = atoi (argv[1]);
6557 ospf->distance_external = atoi (argv[2]);
6558
paul718e3742002-12-13 20:15:29 +00006559 return CMD_SUCCESS;
6560}
6561
6562DEFUN (ospf_distance_ospf_inter_external_intra,
6563 ospf_distance_ospf_inter_external_intra_cmd,
6564 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6565 "Define an administrative distance\n"
6566 "OSPF Administrative distance\n"
6567 "Inter-area routes\n"
6568 "Distance for inter-area routes\n"
6569 "External routes\n"
6570 "Distance for external routes\n"
6571 "Intra-area routes\n"
6572 "Distance for intra-area routes\n")
6573{
paul68980082003-03-25 05:07:42 +00006574 struct ospf *ospf = vty->index;
6575
6576 ospf->distance_inter = atoi (argv[0]);
6577 ospf->distance_external = atoi (argv[1]);
6578 ospf->distance_intra = atoi (argv[2]);
6579
paul718e3742002-12-13 20:15:29 +00006580 return CMD_SUCCESS;
6581}
6582
6583DEFUN (ospf_distance_ospf_external,
6584 ospf_distance_ospf_external_cmd,
6585 "distance ospf external <1-255>",
6586 "Define an administrative distance\n"
6587 "OSPF Administrative distance\n"
6588 "External routes\n"
6589 "Distance for external routes\n")
6590{
paul68980082003-03-25 05:07:42 +00006591 struct ospf *ospf = vty->index;
6592
6593 ospf->distance_external = atoi (argv[0]);
6594
paul718e3742002-12-13 20:15:29 +00006595 return CMD_SUCCESS;
6596}
6597
6598DEFUN (ospf_distance_ospf_external_intra,
6599 ospf_distance_ospf_external_intra_cmd,
6600 "distance ospf external <1-255> intra-area <1-255>",
6601 "Define an administrative distance\n"
6602 "OSPF Administrative distance\n"
6603 "External routes\n"
6604 "Distance for external routes\n"
6605 "Intra-area routes\n"
6606 "Distance for intra-area routes\n")
6607{
paul68980082003-03-25 05:07:42 +00006608 struct ospf *ospf = vty->index;
6609
6610 ospf->distance_external = atoi (argv[0]);
6611 ospf->distance_intra = atoi (argv[1]);
6612
paul718e3742002-12-13 20:15:29 +00006613 return CMD_SUCCESS;
6614}
6615
6616DEFUN (ospf_distance_ospf_external_inter,
6617 ospf_distance_ospf_external_inter_cmd,
6618 "distance ospf external <1-255> inter-area <1-255>",
6619 "Define an administrative distance\n"
6620 "OSPF Administrative distance\n"
6621 "External routes\n"
6622 "Distance for external routes\n"
6623 "Inter-area routes\n"
6624 "Distance for inter-area routes\n")
6625{
paul68980082003-03-25 05:07:42 +00006626 struct ospf *ospf = vty->index;
6627
6628 ospf->distance_external = atoi (argv[0]);
6629 ospf->distance_inter = atoi (argv[1]);
6630
paul718e3742002-12-13 20:15:29 +00006631 return CMD_SUCCESS;
6632}
6633
6634DEFUN (ospf_distance_ospf_external_intra_inter,
6635 ospf_distance_ospf_external_intra_inter_cmd,
6636 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6637 "Define an administrative distance\n"
6638 "OSPF Administrative distance\n"
6639 "External routes\n"
6640 "Distance for external routes\n"
6641 "Intra-area routes\n"
6642 "Distance for intra-area routes\n"
6643 "Inter-area routes\n"
6644 "Distance for inter-area routes\n")
6645{
paul68980082003-03-25 05:07:42 +00006646 struct ospf *ospf = vty->index;
6647
6648 ospf->distance_external = atoi (argv[0]);
6649 ospf->distance_intra = atoi (argv[1]);
6650 ospf->distance_inter = atoi (argv[2]);
6651
paul718e3742002-12-13 20:15:29 +00006652 return CMD_SUCCESS;
6653}
6654
6655DEFUN (ospf_distance_ospf_external_inter_intra,
6656 ospf_distance_ospf_external_inter_intra_cmd,
6657 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6658 "Define an administrative distance\n"
6659 "OSPF Administrative distance\n"
6660 "External routes\n"
6661 "Distance for external routes\n"
6662 "Inter-area routes\n"
6663 "Distance for inter-area routes\n"
6664 "Intra-area routes\n"
6665 "Distance for intra-area routes\n")
6666{
paul68980082003-03-25 05:07:42 +00006667 struct ospf *ospf = vty->index;
6668
6669 ospf->distance_external = atoi (argv[0]);
6670 ospf->distance_inter = atoi (argv[1]);
6671 ospf->distance_intra = atoi (argv[2]);
6672
paul718e3742002-12-13 20:15:29 +00006673 return CMD_SUCCESS;
6674}
6675
6676DEFUN (ospf_distance_source,
6677 ospf_distance_source_cmd,
6678 "distance <1-255> A.B.C.D/M",
6679 "Administrative distance\n"
6680 "Distance value\n"
6681 "IP source prefix\n")
6682{
paul020709f2003-04-04 02:44:16 +00006683 struct ospf *ospf = vty->index;
6684
6685 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006686
paul718e3742002-12-13 20:15:29 +00006687 return CMD_SUCCESS;
6688}
6689
6690DEFUN (no_ospf_distance_source,
6691 no_ospf_distance_source_cmd,
6692 "no distance <1-255> A.B.C.D/M",
6693 NO_STR
6694 "Administrative distance\n"
6695 "Distance value\n"
6696 "IP source prefix\n")
6697{
paul020709f2003-04-04 02:44:16 +00006698 struct ospf *ospf = vty->index;
6699
6700 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6701
paul718e3742002-12-13 20:15:29 +00006702 return CMD_SUCCESS;
6703}
6704
6705DEFUN (ospf_distance_source_access_list,
6706 ospf_distance_source_access_list_cmd,
6707 "distance <1-255> A.B.C.D/M WORD",
6708 "Administrative distance\n"
6709 "Distance value\n"
6710 "IP source prefix\n"
6711 "Access list name\n")
6712{
paul020709f2003-04-04 02:44:16 +00006713 struct ospf *ospf = vty->index;
6714
6715 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6716
paul718e3742002-12-13 20:15:29 +00006717 return CMD_SUCCESS;
6718}
6719
6720DEFUN (no_ospf_distance_source_access_list,
6721 no_ospf_distance_source_access_list_cmd,
6722 "no distance <1-255> A.B.C.D/M WORD",
6723 NO_STR
6724 "Administrative distance\n"
6725 "Distance value\n"
6726 "IP source prefix\n"
6727 "Access list name\n")
6728{
paul020709f2003-04-04 02:44:16 +00006729 struct ospf *ospf = vty->index;
6730
6731 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6732
paul718e3742002-12-13 20:15:29 +00006733 return CMD_SUCCESS;
6734}
6735
vincentba682532005-09-29 13:52:57 +00006736DEFUN (ip_ospf_mtu_ignore,
6737 ip_ospf_mtu_ignore_addr_cmd,
6738 "ip ospf mtu-ignore A.B.C.D",
6739 "IP Information\n"
6740 "OSPF interface commands\n"
6741 "Disable mtu mismatch detection\n"
6742 "Address of interface")
6743{
6744 struct interface *ifp = vty->index;
6745 struct in_addr addr;
6746 int ret;
6747
6748 struct ospf_if_params *params;
6749 params = IF_DEF_PARAMS (ifp);
6750
6751 if (argc == 1)
6752 {
6753 ret = inet_aton(argv[0], &addr);
6754 if (!ret)
6755 {
6756 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6757 VTY_NEWLINE);
6758 return CMD_WARNING;
6759 }
6760 params = ospf_get_if_params (ifp, addr);
6761 ospf_if_update_params (ifp, addr);
6762 }
6763 params->mtu_ignore = 1;
6764 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6765 SET_IF_PARAM (params, mtu_ignore);
6766 else
6767 {
6768 UNSET_IF_PARAM (params, mtu_ignore);
6769 if (params != IF_DEF_PARAMS (ifp))
6770 {
6771 ospf_free_if_params (ifp, addr);
6772 ospf_if_update_params (ifp, addr);
6773 }
6774 }
6775 return CMD_SUCCESS;
6776}
6777
6778ALIAS (ip_ospf_mtu_ignore,
6779 ip_ospf_mtu_ignore_cmd,
6780 "ip ospf mtu-ignore",
6781 "IP Information\n"
6782 "OSPF interface commands\n"
6783 "Disable mtu mismatch detection\n")
6784
6785
6786DEFUN (no_ip_ospf_mtu_ignore,
6787 no_ip_ospf_mtu_ignore_addr_cmd,
6788 "no ip ospf mtu-ignore A.B.C.D",
6789 "IP Information\n"
6790 "OSPF interface commands\n"
6791 "Disable mtu mismatch detection\n"
6792 "Address of interface")
6793{
6794 struct interface *ifp = vty->index;
6795 struct in_addr addr;
6796 int ret;
6797
6798 struct ospf_if_params *params;
6799 params = IF_DEF_PARAMS (ifp);
6800
6801 if (argc == 1)
6802 {
6803 ret = inet_aton(argv[0], &addr);
6804 if (!ret)
6805 {
6806 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6807 VTY_NEWLINE);
6808 return CMD_WARNING;
6809 }
6810 params = ospf_get_if_params (ifp, addr);
6811 ospf_if_update_params (ifp, addr);
6812 }
6813 params->mtu_ignore = 0;
6814 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6815 SET_IF_PARAM (params, mtu_ignore);
6816 else
6817 {
6818 UNSET_IF_PARAM (params, mtu_ignore);
6819 if (params != IF_DEF_PARAMS (ifp))
6820 {
6821 ospf_free_if_params (ifp, addr);
6822 ospf_if_update_params (ifp, addr);
6823 }
6824 }
6825 return CMD_SUCCESS;
6826}
6827
6828ALIAS (no_ip_ospf_mtu_ignore,
6829 no_ip_ospf_mtu_ignore_cmd,
6830 "no ip ospf mtu-ignore",
6831 "IP Information\n"
6832 "OSPF interface commands\n"
6833 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00006834
6835DEFUN (ospf_max_metric_router_lsa_admin,
6836 ospf_max_metric_router_lsa_admin_cmd,
6837 "max-metric router-lsa administrative",
6838 "OSPF maximum / infinite-distance metric\n"
6839 "Advertise own Router-LSA with infinite distance (stub router)\n"
6840 "Administratively applied, for an indefinite period\n")
6841{
6842 struct listnode *ln;
6843 struct ospf_area *area;
6844 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006845
paul88d6cf32005-10-29 12:50:09 +00006846 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6847 {
6848 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6849
6850 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
6851 ospf_router_lsa_timer_add (area);
6852 }
6853 return CMD_SUCCESS;
6854}
6855
6856DEFUN (no_ospf_max_metric_router_lsa_admin,
6857 no_ospf_max_metric_router_lsa_admin_cmd,
6858 "no max-metric router-lsa administrative",
6859 NO_STR
6860 "OSPF maximum / infinite-distance metric\n"
6861 "Advertise own Router-LSA with infinite distance (stub router)\n"
6862 "Administratively applied, for an indefinite period\n")
6863{
6864 struct listnode *ln;
6865 struct ospf_area *area;
6866 struct ospf *ospf = vty->index;
6867
6868 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6869 {
6870 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6871
6872 /* Don't trample on the start-up stub timer */
6873 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6874 && !area->t_stub_router)
6875 {
6876 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6877 ospf_router_lsa_timer_add (area);
6878 }
6879 }
6880 return CMD_SUCCESS;
6881}
6882
6883DEFUN (ospf_max_metric_router_lsa_startup,
6884 ospf_max_metric_router_lsa_startup_cmd,
6885 "max-metric router-lsa on-startup <5-86400>",
6886 "OSPF maximum / infinite-distance metric\n"
6887 "Advertise own Router-LSA with infinite distance (stub router)\n"
6888 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6889 "Time (seconds) to advertise self as stub-router\n")
6890{
6891 unsigned int seconds;
6892 struct ospf *ospf = vty->index;
6893
6894 if (argc != 1)
6895 {
6896 vty_out (vty, "%% Must supply stub-router period");
6897 return CMD_WARNING;
6898 }
6899
6900 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6901
6902 ospf->stub_router_startup_time = seconds;
6903
6904 return CMD_SUCCESS;
6905}
6906
6907DEFUN (no_ospf_max_metric_router_lsa_startup,
6908 no_ospf_max_metric_router_lsa_startup_cmd,
6909 "no max-metric router-lsa on-startup",
6910 NO_STR
6911 "OSPF maximum / infinite-distance metric\n"
6912 "Advertise own Router-LSA with infinite distance (stub router)\n"
6913 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6914{
6915 struct listnode *ln;
6916 struct ospf_area *area;
6917 struct ospf *ospf = vty->index;
6918
6919 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6920
6921 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6922 {
6923 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6924 OSPF_TIMER_OFF (area->t_stub_router);
6925
6926 /* Don't trample on admin stub routed */
6927 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6928 {
6929 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6930 ospf_router_lsa_timer_add (area);
6931 }
6932 }
6933 return CMD_SUCCESS;
6934}
6935
6936DEFUN (ospf_max_metric_router_lsa_shutdown,
6937 ospf_max_metric_router_lsa_shutdown_cmd,
6938 "max-metric router-lsa on-shutdown <5-86400>",
6939 "OSPF maximum / infinite-distance metric\n"
6940 "Advertise own Router-LSA with infinite distance (stub router)\n"
6941 "Advertise stub-router prior to full shutdown of OSPF\n"
6942 "Time (seconds) to wait till full shutdown\n")
6943{
6944 unsigned int seconds;
6945 struct ospf *ospf = vty->index;
6946
6947 if (argc != 1)
6948 {
6949 vty_out (vty, "%% Must supply stub-router shutdown period");
6950 return CMD_WARNING;
6951 }
6952
6953 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6954
6955 ospf->stub_router_shutdown_time = seconds;
6956
6957 return CMD_SUCCESS;
6958}
6959
6960DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6961 no_ospf_max_metric_router_lsa_shutdown_cmd,
6962 "no max-metric router-lsa on-shutdown",
6963 NO_STR
6964 "OSPF maximum / infinite-distance metric\n"
6965 "Advertise own Router-LSA with infinite distance (stub router)\n"
6966 "Advertise stub-router prior to full shutdown of OSPF\n")
6967{
6968 struct ospf *ospf = vty->index;
6969
6970 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6971
6972 return CMD_SUCCESS;
6973}
6974
6975static void
6976config_write_stub_router (struct vty *vty, struct ospf *ospf)
6977{
6978 struct listnode *ln;
6979 struct ospf_area *area;
6980
6981 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6982 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6983 ospf->stub_router_startup_time, VTY_NEWLINE);
6984 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6985 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6986 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6987 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6988 {
6989 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6990 {
6991 vty_out (vty, " max-metric router-lsa administrative%s",
6992 VTY_NEWLINE);
6993 break;
6994 }
6995 }
6996 return;
6997}
6998
paul4dadc292005-05-06 21:37:42 +00006999static void
paul718e3742002-12-13 20:15:29 +00007000show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7001{
7002 struct route_node *rn;
7003 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007004 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007005 struct ospf_path *path;
7006
7007 vty_out (vty, "============ OSPF network routing table ============%s",
7008 VTY_NEWLINE);
7009
7010 for (rn = route_top (rt); rn; rn = route_next (rn))
7011 if ((or = rn->info) != NULL)
7012 {
7013 char buf1[19];
7014 snprintf (buf1, 19, "%s/%d",
7015 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7016
7017 switch (or->path_type)
7018 {
7019 case OSPF_PATH_INTER_AREA:
7020 if (or->type == OSPF_DESTINATION_NETWORK)
7021 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7022 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7023 else if (or->type == OSPF_DESTINATION_DISCARD)
7024 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7025 break;
7026 case OSPF_PATH_INTRA_AREA:
7027 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7028 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7029 break;
7030 default:
7031 break;
7032 }
7033
7034 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007035 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007036 {
hasso54bedb52005-08-17 13:31:47 +00007037 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00007038 {
7039 if (path->nexthop.s_addr == 0)
7040 vty_out (vty, "%24s directly attached to %s%s",
7041 "", path->oi->ifp->name, VTY_NEWLINE);
7042 else
7043 vty_out (vty, "%24s via %s, %s%s", "",
7044 inet_ntoa (path->nexthop), path->oi->ifp->name,
7045 VTY_NEWLINE);
7046 }
7047 }
paul718e3742002-12-13 20:15:29 +00007048 }
7049 vty_out (vty, "%s", VTY_NEWLINE);
7050}
7051
paul4dadc292005-05-06 21:37:42 +00007052static void
paul718e3742002-12-13 20:15:29 +00007053show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7054{
7055 struct route_node *rn;
7056 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007057 struct listnode *pnode;
7058 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007059 struct ospf_path *path;
7060
7061 vty_out (vty, "============ OSPF router routing table =============%s",
7062 VTY_NEWLINE);
7063 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7064 if (rn->info)
7065 {
7066 int flag = 0;
7067
7068 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7069
paul1eb8ef22005-04-07 07:30:20 +00007070 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7071 {
7072 if (flag++)
7073 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007074
paul1eb8ef22005-04-07 07:30:20 +00007075 /* Show path. */
7076 vty_out (vty, "%s [%d] area: %s",
7077 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7078 or->cost, inet_ntoa (or->u.std.area_id));
7079 /* Show flags. */
7080 vty_out (vty, "%s%s%s",
7081 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7082 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7083 VTY_NEWLINE);
7084
7085 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7086 {
hasso54bedb52005-08-17 13:31:47 +00007087 if (path->oi != NULL && ospf_if_exists(path->oi))
7088 {
7089 if (path->nexthop.s_addr == 0)
7090 vty_out (vty, "%24s directly attached to %s%s",
7091 "", path->oi->ifp->name, VTY_NEWLINE);
7092 else
7093 vty_out (vty, "%24s via %s, %s%s", "",
7094 inet_ntoa (path->nexthop),
7095 path->oi->ifp->name, VTY_NEWLINE);
7096 }
paul1eb8ef22005-04-07 07:30:20 +00007097 }
7098 }
paul718e3742002-12-13 20:15:29 +00007099 }
7100 vty_out (vty, "%s", VTY_NEWLINE);
7101}
7102
paul4dadc292005-05-06 21:37:42 +00007103static void
paul718e3742002-12-13 20:15:29 +00007104show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7105{
7106 struct route_node *rn;
7107 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007108 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007109 struct ospf_path *path;
7110
7111 vty_out (vty, "============ OSPF external routing table ===========%s",
7112 VTY_NEWLINE);
7113 for (rn = route_top (rt); rn; rn = route_next (rn))
7114 if ((er = rn->info) != NULL)
7115 {
7116 char buf1[19];
7117 snprintf (buf1, 19, "%s/%d",
7118 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7119
7120 switch (er->path_type)
7121 {
7122 case OSPF_PATH_TYPE1_EXTERNAL:
7123 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7124 er->cost, er->u.ext.tag, VTY_NEWLINE);
7125 break;
7126 case OSPF_PATH_TYPE2_EXTERNAL:
7127 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7128 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7129 break;
7130 }
7131
paul1eb8ef22005-04-07 07:30:20 +00007132 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007133 {
hasso54bedb52005-08-17 13:31:47 +00007134 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00007135 {
7136 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007137 vty_out (vty, "%24s directly attached to %s%s",
7138 "", path->oi->ifp->name, VTY_NEWLINE);
7139 else
7140 vty_out (vty, "%24s via %s, %s%s", "",
7141 inet_ntoa (path->nexthop), path->oi->ifp->name,
7142 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007143 }
7144 }
7145 }
7146 vty_out (vty, "%s", VTY_NEWLINE);
7147}
7148
paul718e3742002-12-13 20:15:29 +00007149DEFUN (show_ip_ospf_border_routers,
7150 show_ip_ospf_border_routers_cmd,
7151 "show ip ospf border-routers",
7152 SHOW_STR
7153 IP_STR
7154 "show all the ABR's and ASBR's\n"
7155 "for this area\n")
7156{
paul020709f2003-04-04 02:44:16 +00007157 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007158
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007159 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007160 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007161 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007162 return CMD_SUCCESS;
7163 }
7164
paul68980082003-03-25 05:07:42 +00007165 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007166 {
7167 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7168 return CMD_SUCCESS;
7169 }
7170
7171 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007172 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007173
7174 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007175 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007176
7177 return CMD_SUCCESS;
7178}
paul718e3742002-12-13 20:15:29 +00007179
7180DEFUN (show_ip_ospf_route,
7181 show_ip_ospf_route_cmd,
7182 "show ip ospf route",
7183 SHOW_STR
7184 IP_STR
7185 "OSPF information\n"
7186 "OSPF routing table\n")
7187{
paul020709f2003-04-04 02:44:16 +00007188 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007189
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007190 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007191 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007192 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007193 return CMD_SUCCESS;
7194 }
7195
paul68980082003-03-25 05:07:42 +00007196 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007197 {
7198 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7199 return CMD_SUCCESS;
7200 }
7201
7202 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007203 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007204
7205 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007206 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007207
7208 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007209 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007210
7211 return CMD_SUCCESS;
7212}
7213
7214
hassoeb1ce602004-10-08 08:17:22 +00007215const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007216{
7217 "unknown",
7218 "standard",
7219 "ibm",
7220 "cisco",
7221 "shortcut"
7222};
7223
hassoeb1ce602004-10-08 08:17:22 +00007224const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007225{
7226 "default",
7227 "enable",
7228 "disable"
7229};
7230
7231
paul4dadc292005-05-06 21:37:42 +00007232static void
paul718e3742002-12-13 20:15:29 +00007233area_id2str (char *buf, int length, struct ospf_area *area)
7234{
7235 memset (buf, 0, length);
7236
7237 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7238 strncpy (buf, inet_ntoa (area->area_id), length);
7239 else
7240 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7241}
7242
7243
hassoeb1ce602004-10-08 08:17:22 +00007244const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007245{
7246 "unknown", /* should never be used. */
7247 "point-to-point",
7248 "broadcast",
7249 "non-broadcast",
7250 "point-to-multipoint",
7251 "virtual-link", /* should never be used. */
7252 "loopback"
7253};
7254
7255/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007256static int
paul718e3742002-12-13 20:15:29 +00007257config_write_interface (struct vty *vty)
7258{
hasso52dc7ee2004-09-23 19:18:23 +00007259 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007260 struct interface *ifp;
7261 struct crypt_key *ck;
7262 int write = 0;
7263 struct route_node *rn = NULL;
7264 struct ospf_if_params *params;
7265
paul1eb8ef22005-04-07 07:30:20 +00007266 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007267 {
paul718e3742002-12-13 20:15:29 +00007268 if (memcmp (ifp->name, "VLINK", 5) == 0)
7269 continue;
7270
7271 vty_out (vty, "!%s", VTY_NEWLINE);
7272 vty_out (vty, "interface %s%s", ifp->name,
7273 VTY_NEWLINE);
7274 if (ifp->desc)
7275 vty_out (vty, " description %s%s", ifp->desc,
7276 VTY_NEWLINE);
7277
7278 write++;
7279
7280 params = IF_DEF_PARAMS (ifp);
7281
7282 do {
7283 /* Interface Network print. */
7284 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007285 params->type != OSPF_IFTYPE_LOOPBACK)
7286 {
ajsbc18d612004-12-15 15:07:19 +00007287 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007288 {
7289 vty_out (vty, " ip ospf network %s",
7290 ospf_int_type_str[params->type]);
7291 if (params != IF_DEF_PARAMS (ifp))
7292 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7293 vty_out (vty, "%s", VTY_NEWLINE);
7294 }
paul718e3742002-12-13 20:15:29 +00007295 }
7296
7297 /* OSPF interface authentication print */
7298 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7299 params->auth_type != OSPF_AUTH_NOTSET)
7300 {
hassoeb1ce602004-10-08 08:17:22 +00007301 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007302
7303 /* Translation tables are not that much help here due to syntax
7304 of the simple option */
7305 switch (params->auth_type)
7306 {
7307
7308 case OSPF_AUTH_NULL:
7309 auth_str = " null";
7310 break;
7311
7312 case OSPF_AUTH_SIMPLE:
7313 auth_str = "";
7314 break;
7315
7316 case OSPF_AUTH_CRYPTOGRAPHIC:
7317 auth_str = " message-digest";
7318 break;
7319
7320 default:
7321 auth_str = "";
7322 break;
7323 }
7324
7325 vty_out (vty, " ip ospf authentication%s", auth_str);
7326 if (params != IF_DEF_PARAMS (ifp))
7327 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7328 vty_out (vty, "%s", VTY_NEWLINE);
7329 }
7330
7331 /* Simple Authentication Password print. */
7332 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7333 params->auth_simple[0] != '\0')
7334 {
7335 vty_out (vty, " ip ospf authentication-key %s",
7336 params->auth_simple);
7337 if (params != IF_DEF_PARAMS (ifp))
7338 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7339 vty_out (vty, "%s", VTY_NEWLINE);
7340 }
7341
7342 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007343 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007344 {
paul718e3742002-12-13 20:15:29 +00007345 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7346 ck->key_id, ck->auth_key);
7347 if (params != IF_DEF_PARAMS (ifp))
7348 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7349 vty_out (vty, "%s", VTY_NEWLINE);
7350 }
7351
7352 /* Interface Output Cost print. */
7353 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7354 {
7355 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7356 if (params != IF_DEF_PARAMS (ifp))
7357 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7358 vty_out (vty, "%s", VTY_NEWLINE);
7359 }
7360
7361 /* Hello Interval print. */
7362 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7363 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7364 {
7365 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7366 if (params != IF_DEF_PARAMS (ifp))
7367 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7368 vty_out (vty, "%s", VTY_NEWLINE);
7369 }
7370
7371
7372 /* Router Dead Interval print. */
7373 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7374 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7375 {
paulf9ad9372005-10-21 00:45:17 +00007376 vty_out (vty, " ip ospf dead-interval ");
7377
7378 /* fast hello ? */
7379 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7380 vty_out (vty, "minimal hello-multiplier %d",
7381 params->fast_hello);
7382 else
7383 vty_out (vty, "%u", params->v_wait);
7384
paul718e3742002-12-13 20:15:29 +00007385 if (params != IF_DEF_PARAMS (ifp))
7386 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7387 vty_out (vty, "%s", VTY_NEWLINE);
7388 }
7389
7390 /* Router Priority print. */
7391 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7392 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7393 {
7394 vty_out (vty, " ip ospf priority %u", params->priority);
7395 if (params != IF_DEF_PARAMS (ifp))
7396 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7397 vty_out (vty, "%s", VTY_NEWLINE);
7398 }
7399
7400 /* Retransmit Interval print. */
7401 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7402 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7403 {
7404 vty_out (vty, " ip ospf retransmit-interval %u",
7405 params->retransmit_interval);
7406 if (params != IF_DEF_PARAMS (ifp))
7407 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7408 vty_out (vty, "%s", VTY_NEWLINE);
7409 }
7410
7411 /* Transmit Delay print. */
7412 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7413 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7414 {
7415 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7416 if (params != IF_DEF_PARAMS (ifp))
7417 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7418 vty_out (vty, "%s", VTY_NEWLINE);
7419 }
7420
vincentba682532005-09-29 13:52:57 +00007421 /* MTU ignore print. */
7422 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7423 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7424 {
7425 if (params->mtu_ignore == 0)
7426 vty_out (vty, " no ip ospf mtu-ignore");
7427 else
7428 vty_out (vty, " ip ospf mtu-ignore");
7429 if (params != IF_DEF_PARAMS (ifp))
7430 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7431 vty_out (vty, "%s", VTY_NEWLINE);
7432 }
7433
7434
paul718e3742002-12-13 20:15:29 +00007435 while (1)
7436 {
7437 if (rn == NULL)
7438 rn = route_top (IF_OIFS_PARAMS (ifp));
7439 else
7440 rn = route_next (rn);
7441
7442 if (rn == NULL)
7443 break;
7444 params = rn->info;
7445 if (params != NULL)
7446 break;
7447 }
7448 } while (rn);
7449
7450#ifdef HAVE_OPAQUE_LSA
7451 ospf_opaque_config_write_if (vty, ifp);
7452#endif /* HAVE_OPAQUE_LSA */
7453 }
7454
7455 return write;
7456}
7457
paul4dadc292005-05-06 21:37:42 +00007458static int
paul68980082003-03-25 05:07:42 +00007459config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007460{
7461 struct route_node *rn;
7462 u_char buf[INET_ADDRSTRLEN];
7463
7464 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007465 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007466 if (rn->info)
7467 {
7468 struct ospf_network *n = rn->info;
7469
7470 memset (buf, 0, INET_ADDRSTRLEN);
7471
7472 /* Create Area ID string by specified Area ID format. */
7473 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007474 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007475 else
hassoc9e52be2004-09-26 16:09:34 +00007476 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007477 (unsigned long int) ntohl (n->area_id.s_addr));
7478
7479 /* Network print. */
7480 vty_out (vty, " network %s/%d area %s%s",
7481 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7482 buf, VTY_NEWLINE);
7483 }
7484
7485 return 0;
7486}
7487
paul4dadc292005-05-06 21:37:42 +00007488static int
paul68980082003-03-25 05:07:42 +00007489config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007490{
hasso52dc7ee2004-09-23 19:18:23 +00007491 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007492 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007493 u_char buf[INET_ADDRSTRLEN];
7494
7495 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007496 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007497 {
paul718e3742002-12-13 20:15:29 +00007498 struct route_node *rn1;
7499
hassoc9e52be2004-09-26 16:09:34 +00007500 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007501
7502 if (area->auth_type != OSPF_AUTH_NULL)
7503 {
7504 if (area->auth_type == OSPF_AUTH_SIMPLE)
7505 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7506 else
7507 vty_out (vty, " area %s authentication message-digest%s",
7508 buf, VTY_NEWLINE);
7509 }
7510
7511 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7512 vty_out (vty, " area %s shortcut %s%s", buf,
7513 ospf_shortcut_mode_str[area->shortcut_configured],
7514 VTY_NEWLINE);
7515
7516 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007517 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007518 )
7519 {
paulb0a053b2003-06-22 09:04:47 +00007520 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007521 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007522 else if (area->external_routing == OSPF_AREA_NSSA)
7523 {
7524 vty_out (vty, " area %s nssa", buf);
7525 switch (area->NSSATranslatorRole)
7526 {
7527 case OSPF_NSSA_ROLE_NEVER:
7528 vty_out (vty, " translate-never");
7529 break;
7530 case OSPF_NSSA_ROLE_ALWAYS:
7531 vty_out (vty, " translate-always");
7532 break;
7533 case OSPF_NSSA_ROLE_CANDIDATE:
7534 default:
7535 vty_out (vty, " translate-candidate");
7536 }
7537 }
paul718e3742002-12-13 20:15:29 +00007538
7539 if (area->no_summary)
7540 vty_out (vty, " no-summary");
7541
7542 vty_out (vty, "%s", VTY_NEWLINE);
7543
7544 if (area->default_cost != 1)
7545 vty_out (vty, " area %s default-cost %d%s", buf,
7546 area->default_cost, VTY_NEWLINE);
7547 }
7548
7549 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7550 if (rn1->info)
7551 {
7552 struct ospf_area_range *range = rn1->info;
7553
7554 vty_out (vty, " area %s range %s/%d", buf,
7555 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7556
paul6c835672004-10-11 11:00:30 +00007557 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007558 vty_out (vty, " cost %d", range->cost_config);
7559
7560 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7561 vty_out (vty, " not-advertise");
7562
7563 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7564 vty_out (vty, " substitute %s/%d",
7565 inet_ntoa (range->subst_addr), range->subst_masklen);
7566
7567 vty_out (vty, "%s", VTY_NEWLINE);
7568 }
7569
7570 if (EXPORT_NAME (area))
7571 vty_out (vty, " area %s export-list %s%s", buf,
7572 EXPORT_NAME (area), VTY_NEWLINE);
7573
7574 if (IMPORT_NAME (area))
7575 vty_out (vty, " area %s import-list %s%s", buf,
7576 IMPORT_NAME (area), VTY_NEWLINE);
7577
7578 if (PREFIX_NAME_IN (area))
7579 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7580 PREFIX_NAME_IN (area), VTY_NEWLINE);
7581
7582 if (PREFIX_NAME_OUT (area))
7583 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7584 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7585 }
7586
7587 return 0;
7588}
7589
paul4dadc292005-05-06 21:37:42 +00007590static int
paul68980082003-03-25 05:07:42 +00007591config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007592{
7593 struct ospf_nbr_nbma *nbr_nbma;
7594 struct route_node *rn;
7595
7596 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007597 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007598 if ((nbr_nbma = rn->info))
7599 {
7600 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7601
7602 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7603 vty_out (vty, " priority %d", nbr_nbma->priority);
7604
7605 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7606 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7607
7608 vty_out (vty, "%s", VTY_NEWLINE);
7609 }
7610
7611 return 0;
7612}
7613
paul4dadc292005-05-06 21:37:42 +00007614static int
paul68980082003-03-25 05:07:42 +00007615config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007616{
hasso52dc7ee2004-09-23 19:18:23 +00007617 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007618 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007619 u_char buf[INET_ADDRSTRLEN];
7620
7621 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007622 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007623 {
hasso52dc7ee2004-09-23 19:18:23 +00007624 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007625 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007626 struct ospf_interface *oi;
7627
7628 if (vl_data != NULL)
7629 {
7630 memset (buf, 0, INET_ADDRSTRLEN);
7631
7632 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007633 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007634 else
hassoc9e52be2004-09-26 16:09:34 +00007635 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007636 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7637 oi = vl_data->vl_oi;
7638
7639 /* timers */
7640 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7641 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7642 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7643 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7644 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7645 buf,
7646 inet_ntoa (vl_data->vl_peer),
7647 OSPF_IF_PARAM (oi, v_hello),
7648 OSPF_IF_PARAM (oi, retransmit_interval),
7649 OSPF_IF_PARAM (oi, transmit_delay),
7650 OSPF_IF_PARAM (oi, v_wait),
7651 VTY_NEWLINE);
7652 else
7653 vty_out (vty, " area %s virtual-link %s%s", buf,
7654 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7655 /* Auth key */
7656 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7657 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7658 buf,
7659 inet_ntoa (vl_data->vl_peer),
7660 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7661 VTY_NEWLINE);
7662 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007663 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7664 n2, ck))
7665 vty_out (vty, " area %s virtual-link %s"
7666 " message-digest-key %d md5 %s%s",
7667 buf,
7668 inet_ntoa (vl_data->vl_peer),
7669 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007670
7671 }
7672 }
7673
7674 return 0;
7675}
7676
7677
paul4dadc292005-05-06 21:37:42 +00007678static int
paul68980082003-03-25 05:07:42 +00007679config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007680{
7681 int type;
7682
7683 /* redistribute print. */
7684 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7685 if (type != zclient->redist_default && zclient->redist[type])
7686 {
ajsf52d13c2005-10-01 17:38:06 +00007687 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007688 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007689 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007690
paul68980082003-03-25 05:07:42 +00007691 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007692 vty_out (vty, " metric-type 1");
7693
paul020709f2003-04-04 02:44:16 +00007694 if (ROUTEMAP_NAME (ospf, type))
7695 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007696
7697 vty_out (vty, "%s", VTY_NEWLINE);
7698 }
7699
7700 return 0;
7701}
7702
paul4dadc292005-05-06 21:37:42 +00007703static int
paul68980082003-03-25 05:07:42 +00007704config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007705{
paul68980082003-03-25 05:07:42 +00007706 if (ospf->default_metric != -1)
7707 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007708 VTY_NEWLINE);
7709 return 0;
7710}
7711
paul4dadc292005-05-06 21:37:42 +00007712static int
paul68980082003-03-25 05:07:42 +00007713config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007714{
7715 int type;
7716
paul68980082003-03-25 05:07:42 +00007717 if (ospf)
paul718e3742002-12-13 20:15:29 +00007718 {
7719 /* distribute-list print. */
7720 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007721 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007722 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007723 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007724 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007725
7726 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007727 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007728 {
paulc42c1772006-01-10 20:36:49 +00007729 vty_out (vty, " default-information originate");
7730 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7731 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007732
paul68980082003-03-25 05:07:42 +00007733 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007734 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007735 ospf->dmetric[DEFAULT_ROUTE].value);
7736 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007737 vty_out (vty, " metric-type 1");
7738
paul020709f2003-04-04 02:44:16 +00007739 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7740 vty_out (vty, " route-map %s",
7741 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007742
7743 vty_out (vty, "%s", VTY_NEWLINE);
7744 }
7745
7746 }
7747
7748 return 0;
7749}
7750
paul4dadc292005-05-06 21:37:42 +00007751static int
paul68980082003-03-25 05:07:42 +00007752config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007753{
7754 struct route_node *rn;
7755 struct ospf_distance *odistance;
7756
paul68980082003-03-25 05:07:42 +00007757 if (ospf->distance_all)
7758 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007759
paul68980082003-03-25 05:07:42 +00007760 if (ospf->distance_intra
7761 || ospf->distance_inter
7762 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007763 {
7764 vty_out (vty, " distance ospf");
7765
paul68980082003-03-25 05:07:42 +00007766 if (ospf->distance_intra)
7767 vty_out (vty, " intra-area %d", ospf->distance_intra);
7768 if (ospf->distance_inter)
7769 vty_out (vty, " inter-area %d", ospf->distance_inter);
7770 if (ospf->distance_external)
7771 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007772
7773 vty_out (vty, "%s", VTY_NEWLINE);
7774 }
7775
paul68980082003-03-25 05:07:42 +00007776 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007777 if ((odistance = rn->info) != NULL)
7778 {
7779 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7780 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7781 odistance->access_list ? odistance->access_list : "",
7782 VTY_NEWLINE);
7783 }
7784 return 0;
7785}
7786
7787/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007788static int
paul718e3742002-12-13 20:15:29 +00007789ospf_config_write (struct vty *vty)
7790{
paul020709f2003-04-04 02:44:16 +00007791 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007792 struct interface *ifp;
7793 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007794 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007795 int write = 0;
7796
paul020709f2003-04-04 02:44:16 +00007797 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007798 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007799 {
7800 /* `router ospf' print. */
7801 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7802
7803 write++;
7804
paul68980082003-03-25 05:07:42 +00007805 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007806 return write;
7807
7808 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007809 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007810 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007811 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007812
7813 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007814 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007815 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007816 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007817
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007818 /* log-adjacency-changes flag print. */
7819 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7820 {
7821 vty_out(vty, " log-adjacency-changes");
7822 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7823 vty_out(vty, " detail");
7824 vty_out(vty, "%s", VTY_NEWLINE);
7825 }
7826
paul718e3742002-12-13 20:15:29 +00007827 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007828 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007829 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7830
7831 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007832 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007833 {
7834 vty_out (vty, "! Important: ensure reference bandwidth "
7835 "is consistent across all routers%s", VTY_NEWLINE);
7836 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7837 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7838 }
paul718e3742002-12-13 20:15:29 +00007839
7840 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007841 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007842 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7843 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7844 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007845 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007846 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007847
7848 /* Max-metric router-lsa print */
7849 config_write_stub_router (vty, ospf);
7850
paul718e3742002-12-13 20:15:29 +00007851 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007852 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007853 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007854 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007855
7856 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007857 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007858
7859 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007860 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7861 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7862 vty_out (vty, " passive-interface %s%s",
7863 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007864
paul1eb8ef22005-04-07 07:30:20 +00007865 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7866 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7867 oi->params->passive_interface == OSPF_IF_PASSIVE)
7868 vty_out (vty, " passive-interface %s %s%s",
7869 oi->ifp->name,
7870 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007871
7872 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007873 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007874
7875 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007876 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007877
7878 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007879 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007880
7881 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007882 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007883
7884 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007885 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007886
7887 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007888 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007889
7890 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007891 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007892
7893#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007894 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007895#endif /* HAVE_OPAQUE_LSA */
7896 }
7897
7898 return write;
7899}
7900
7901void
paul4dadc292005-05-06 21:37:42 +00007902ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007903{
7904 /* "show ip ospf" commands. */
7905 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7906 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7907
7908 /* "show ip ospf database" commands. */
7909 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7910 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7911 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7912 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7913 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7914 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7915 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7916 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7917 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7918 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7919 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7920 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7921 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7922 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7923
7924 /* "show ip ospf interface" commands. */
7925 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7926 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7927
7928 /* "show ip ospf neighbor" commands. */
7929 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7930 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7931 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7932 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7933 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7934 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7935 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7936 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7937 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7938 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7939 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7940 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7941 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7942 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7943
7944 /* "show ip ospf route" commands. */
7945 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7946 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007947 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7948 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007949}
7950
7951
7952/* ospfd's interface node. */
7953struct cmd_node interface_node =
7954{
7955 INTERFACE_NODE,
7956 "%s(config-if)# ",
7957 1
7958};
7959
7960/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007961static void
7962ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007963{
7964 /* Install interface node. */
7965 install_node (&interface_node, config_write_interface);
7966
7967 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007968 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007969 install_default (INTERFACE_NODE);
7970
7971 /* "description" commands. */
7972 install_element (INTERFACE_NODE, &interface_desc_cmd);
7973 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7974
7975 /* "ip ospf authentication" commands. */
7976 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7977 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7978 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7979 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7980 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7981 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7982 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7983 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7984 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7985 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7986
7987 /* "ip ospf message-digest-key" commands. */
7988 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7989 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7990 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7991 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7992
7993 /* "ip ospf cost" commands. */
7994 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7995 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7996 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7997 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7998
vincentba682532005-09-29 13:52:57 +00007999 /* "ip ospf mtu-ignore" commands. */
8000 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8001 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8002 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8003 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8004
paul718e3742002-12-13 20:15:29 +00008005 /* "ip ospf dead-interval" commands. */
8006 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8007 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008008 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8009 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00008010 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8011 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008012
paul718e3742002-12-13 20:15:29 +00008013 /* "ip ospf hello-interval" commands. */
8014 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8015 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8016 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8017 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8018
8019 /* "ip ospf network" commands. */
8020 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8021 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8022
8023 /* "ip ospf priority" commands. */
8024 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8025 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8026 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8027 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8028
8029 /* "ip ospf retransmit-interval" commands. */
8030 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8031 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8032 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8033 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8034
8035 /* "ip ospf transmit-delay" commands. */
8036 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8037 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8038 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8039 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8040
8041 /* These commands are compatibitliy for previous version. */
8042 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8043 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8044 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8045 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
8046 install_element (INTERFACE_NODE, &ospf_cost_cmd);
8047 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
8048 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8049 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8050 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8051 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8052 install_element (INTERFACE_NODE, &ospf_network_cmd);
8053 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8054 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8055 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8056 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8057 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8058 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8059 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8060}
8061
8062/* Zebra node structure. */
8063struct cmd_node zebra_node =
8064{
8065 ZEBRA_NODE,
8066 "%s(config-router)#",
8067};
8068
paul4dadc292005-05-06 21:37:42 +00008069static void
8070ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008071{
8072 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8073 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8074 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8075 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8076 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8077 install_element (OSPF_NODE,
8078 &ospf_redistribute_source_metric_type_routemap_cmd);
8079 install_element (OSPF_NODE,
8080 &ospf_redistribute_source_type_metric_routemap_cmd);
8081 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8082 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8083 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8084
8085 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8086
8087 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8088 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8089
8090 install_element (OSPF_NODE,
8091 &ospf_default_information_originate_metric_type_cmd);
8092 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8093 install_element (OSPF_NODE,
8094 &ospf_default_information_originate_type_metric_cmd);
8095 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8096 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8097 install_element (OSPF_NODE,
8098 &ospf_default_information_originate_always_metric_type_cmd);
8099 install_element (OSPF_NODE,
8100 &ospf_default_information_originate_always_metric_cmd);
8101 install_element (OSPF_NODE,
8102 &ospf_default_information_originate_always_cmd);
8103 install_element (OSPF_NODE,
8104 &ospf_default_information_originate_always_type_metric_cmd);
8105 install_element (OSPF_NODE,
8106 &ospf_default_information_originate_always_type_cmd);
8107
8108 install_element (OSPF_NODE,
8109 &ospf_default_information_originate_metric_type_routemap_cmd);
8110 install_element (OSPF_NODE,
8111 &ospf_default_information_originate_metric_routemap_cmd);
8112 install_element (OSPF_NODE,
8113 &ospf_default_information_originate_routemap_cmd);
8114 install_element (OSPF_NODE,
8115 &ospf_default_information_originate_type_metric_routemap_cmd);
8116 install_element (OSPF_NODE,
8117 &ospf_default_information_originate_type_routemap_cmd);
8118 install_element (OSPF_NODE,
8119 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8120 install_element (OSPF_NODE,
8121 &ospf_default_information_originate_always_metric_routemap_cmd);
8122 install_element (OSPF_NODE,
8123 &ospf_default_information_originate_always_routemap_cmd);
8124 install_element (OSPF_NODE,
8125 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8126 install_element (OSPF_NODE,
8127 &ospf_default_information_originate_always_type_routemap_cmd);
8128
8129 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8130
8131 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8132 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8133 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8134
8135 install_element (OSPF_NODE, &ospf_distance_cmd);
8136 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8137 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8138 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8139 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8140 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8141 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8142 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8143 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8144 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8145 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8146 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8147 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8148 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8149 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8150 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8151 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8152 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8153#if 0
8154 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8155 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8156 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8157 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8158#endif /* 0 */
8159}
8160
8161struct cmd_node ospf_node =
8162{
8163 OSPF_NODE,
8164 "%s(config-router)# ",
8165 1
8166};
8167
8168
8169/* Install OSPF related vty commands. */
8170void
paul4dadc292005-05-06 21:37:42 +00008171ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008172{
8173 /* Install ospf top node. */
8174 install_node (&ospf_node, ospf_config_write);
8175
8176 /* "router ospf" commands. */
8177 install_element (CONFIG_NODE, &router_ospf_cmd);
8178 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8179
8180 install_default (OSPF_NODE);
8181
8182 /* "ospf router-id" commands. */
8183 install_element (OSPF_NODE, &ospf_router_id_cmd);
8184 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008185 install_element (OSPF_NODE, &router_ospf_id_cmd);
8186 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008187
8188 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008189 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8190 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8191 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8192 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008193
8194 /* "ospf abr-type" commands. */
8195 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8196 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8197
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008198 /* "ospf log-adjacency-changes" commands. */
8199 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8200 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8201 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8202 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8203
paul718e3742002-12-13 20:15:29 +00008204 /* "ospf rfc1583-compatible" commands. */
8205 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8206 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8207 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8208 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8209
8210 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008211 install_element (OSPF_NODE, &ospf_network_area_cmd);
8212 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008213
8214 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008215 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8216 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8217 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008218
8219 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008220 install_element (OSPF_NODE, &ospf_area_range_cmd);
8221 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8222 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8223 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8224 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8225 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8226 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8227 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8228 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8229 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8230 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008231
8232 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008233 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8234 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008235
paula2c62832003-04-23 17:01:31 +00008236 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8237 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008238
paula2c62832003-04-23 17:01:31 +00008239 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8240 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008241
paula2c62832003-04-23 17:01:31 +00008242 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8243 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008244
paula2c62832003-04-23 17:01:31 +00008245 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8246 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008247
paula2c62832003-04-23 17:01:31 +00008248 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8249 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8250 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008251
paula2c62832003-04-23 17:01:31 +00008252 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8253 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008254
paula2c62832003-04-23 17:01:31 +00008255 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8256 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008257
paula2c62832003-04-23 17:01:31 +00008258 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8259 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8260 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008261
paula2c62832003-04-23 17:01:31 +00008262 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8263 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8264 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008265
8266 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008267 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8268 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8269 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8270 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008271
paul718e3742002-12-13 20:15:29 +00008272 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008273 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8274 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8275 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8276 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8277 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8278 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008279
paula2c62832003-04-23 17:01:31 +00008280 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8281 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008282
paula2c62832003-04-23 17:01:31 +00008283 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8284 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008285
paula2c62832003-04-23 17:01:31 +00008286 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8287 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008288
paula2c62832003-04-23 17:01:31 +00008289 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8290 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008291
paula2c62832003-04-23 17:01:31 +00008292 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8293 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008294
8295 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008296 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8297 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008298 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8299 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8300
paul88d6cf32005-10-29 12:50:09 +00008301 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008302 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8303 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8304 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008305
paul88d6cf32005-10-29 12:50:09 +00008306 /* max-metric commands */
8307 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8308 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8309 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8310 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8311 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8312 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8313
8314 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008315 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8316 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008317
8318 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008319 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8320 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8321 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8322 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8323 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8324 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8325 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8326 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008327
8328 /* Init interface related vty commands. */
8329 ospf_vty_if_init ();
8330
8331 /* Init zebra related vty commands. */
8332 ospf_vty_zebra_init ();
8333}