blob: de021bc25ae0a07952e71a4b16c31369fc4970d4 [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;
paul718e3742002-12-13 20:15:29 +0000218
paul68980082003-03-25 05:07:42 +0000219 if (ospf->t_router_id_update == NULL)
paul020709f2003-04-04 02:44:16 +0000220 OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer,
221 OSPF_ROUTER_ID_UPDATE_DELAY);
paul718e3742002-12-13 20:15:29 +0000222
223 return CMD_SUCCESS;
224}
225
226ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000227 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000228 "router-id A.B.C.D",
229 "router-id for the OSPF process\n"
230 "OSPF router-id in IP address format\n")
231
232DEFUN (no_ospf_router_id,
233 no_ospf_router_id_cmd,
234 "no ospf router-id",
235 NO_STR
236 "OSPF specific commands\n"
237 "router-id for the OSPF process\n")
238{
paul68980082003-03-25 05:07:42 +0000239 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000240
paul68980082003-03-25 05:07:42 +0000241 ospf->router_id_static.s_addr = 0;
242
243 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000244
245 return CMD_SUCCESS;
246}
247
248ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000249 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000250 "no router-id",
251 NO_STR
252 "router-id for the OSPF process\n")
253
paula2c62832003-04-23 17:01:31 +0000254DEFUN (ospf_passive_interface,
255 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000256 "passive-interface IFNAME A.B.C.D",
257 "Suppress routing updates on an interface\n"
258 "Interface's name\n")
259{
260 struct interface *ifp;
261 struct in_addr addr;
262 int ret;
263 struct ospf_if_params *params;
ajsba6454e2005-02-08 15:37:30 +0000264 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000265
266 ifp = if_lookup_by_name (argv[0]);
267
268 if (ifp == NULL)
269 {
270 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
271 return CMD_WARNING;
272 }
273
274 params = IF_DEF_PARAMS (ifp);
275
276 if (argc == 2)
277 {
278 ret = inet_aton(argv[1], &addr);
279 if (!ret)
280 {
281 vty_out (vty, "Please specify interface address by A.B.C.D%s",
282 VTY_NEWLINE);
283 return CMD_WARNING;
284 }
285
286 params = ospf_get_if_params (ifp, addr);
287 ospf_if_update_params (ifp, addr);
288 }
289
290 SET_IF_PARAM (params, passive_interface);
291 params->passive_interface = OSPF_IF_PASSIVE;
ajsba6454e2005-02-08 15:37:30 +0000292
293 /* XXX We should call ospf_if_set_multicast on exactly those
294 * interfaces for which the passive property changed. It is too much
295 * work to determine this set, so we do this for every interface.
296 * This is safe and reasonable because ospf_if_set_multicast uses a
297 * record of joined groups to avoid systems calls if the desired
298 * memberships match the current memership.
299 */
300 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
301 {
302 struct ospf_interface *oi = rn->info;
303
304 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
305 ospf_if_set_multicast(oi);
306 }
307 /*
308 * XXX It is not clear what state transitions the interface needs to
309 * undergo when going from active to passive. Fixing this will
310 * require precise identification of interfaces having such a
311 * transition.
312 */
313
paul718e3742002-12-13 20:15:29 +0000314 return CMD_SUCCESS;
315}
316
paula2c62832003-04-23 17:01:31 +0000317ALIAS (ospf_passive_interface,
318 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000319 "passive-interface IFNAME",
320 "Suppress routing updates on an interface\n"
321 "Interface's name\n")
322
paula2c62832003-04-23 17:01:31 +0000323DEFUN (no_ospf_passive_interface,
324 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000325 "no passive-interface IFNAME A.B.C.D",
326 NO_STR
327 "Allow routing updates on an interface\n"
328 "Interface's name\n")
329{
330 struct interface *ifp;
331 struct in_addr addr;
332 struct ospf_if_params *params;
333 int ret;
ajsba6454e2005-02-08 15:37:30 +0000334 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000335
336 ifp = if_lookup_by_name (argv[0]);
337
338 if (ifp == NULL)
339 {
340 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
341 return CMD_WARNING;
342 }
343
344 params = IF_DEF_PARAMS (ifp);
345
346 if (argc == 2)
347 {
348 ret = inet_aton(argv[1], &addr);
349 if (!ret)
350 {
351 vty_out (vty, "Please specify interface address by A.B.C.D%s",
352 VTY_NEWLINE);
353 return CMD_WARNING;
354 }
355
356 params = ospf_lookup_if_params (ifp, addr);
357 if (params == NULL)
358 return CMD_SUCCESS;
359 }
360
361 UNSET_IF_PARAM (params, passive_interface);
362 params->passive_interface = OSPF_IF_ACTIVE;
363
364 if (params != IF_DEF_PARAMS (ifp))
365 {
366 ospf_free_if_params (ifp, addr);
367 ospf_if_update_params (ifp, addr);
368 }
ajsba6454e2005-02-08 15:37:30 +0000369
370 /* XXX We should call ospf_if_set_multicast on exactly those
371 * interfaces for which the passive property changed. It is too much
372 * work to determine this set, so we do this for every interface.
373 * This is safe and reasonable because ospf_if_set_multicast uses a
374 * record of joined groups to avoid systems calls if the desired
375 * memberships match the current memership.
376 */
377 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
378 {
379 struct ospf_interface *oi = rn->info;
380
381 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
382 ospf_if_set_multicast(oi);
383 }
384
paul718e3742002-12-13 20:15:29 +0000385 return CMD_SUCCESS;
386}
387
paula2c62832003-04-23 17:01:31 +0000388ALIAS (no_ospf_passive_interface,
389 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000390 "no passive-interface IFNAME",
391 NO_STR
392 "Allow routing updates on an interface\n"
393 "Interface's name\n")
394
paula2c62832003-04-23 17:01:31 +0000395DEFUN (ospf_network_area,
396 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000397 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
398 "Enable routing on an IP network\n"
399 "OSPF network prefix\n"
400 "Set the OSPF area ID\n"
401 "OSPF area ID in IP address format\n"
402 "OSPF area ID as a decimal value\n")
403{
404 struct ospf *ospf= vty->index;
405 struct prefix_ipv4 p;
406 struct in_addr area_id;
407 int ret, format;
408
409 /* Get network prefix and Area ID. */
410 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
411 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
412
413 ret = ospf_network_set (ospf, &p, area_id);
414 if (ret == 0)
415 {
416 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
417 return CMD_WARNING;
418 }
419
420 return CMD_SUCCESS;
421}
422
paula2c62832003-04-23 17:01:31 +0000423DEFUN (no_ospf_network_area,
424 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000425 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
426 NO_STR
427 "Enable routing on an IP network\n"
428 "OSPF network prefix\n"
429 "Set the OSPF area ID\n"
430 "OSPF area ID in IP address format\n"
431 "OSPF area ID as a decimal value\n")
432{
433 struct ospf *ospf = (struct ospf *) vty->index;
434 struct prefix_ipv4 p;
435 struct in_addr area_id;
436 int ret, format;
437
438 /* Get network prefix and Area ID. */
439 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
440 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
441
442 ret = ospf_network_unset (ospf, &p, area_id);
443 if (ret == 0)
444 {
445 vty_out (vty, "Can't find specified network area configuration.%s",
446 VTY_NEWLINE);
447 return CMD_WARNING;
448 }
449
450 return CMD_SUCCESS;
451}
452
453
paula2c62832003-04-23 17:01:31 +0000454DEFUN (ospf_area_range,
455 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000456 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
457 "OSPF area parameters\n"
458 "OSPF area ID in IP address format\n"
459 "OSPF area ID as a decimal value\n"
460 "Summarize routes matching address/mask (border routers only)\n"
461 "Area range prefix\n")
462{
463 struct ospf *ospf = vty->index;
464 struct prefix_ipv4 p;
465 struct in_addr area_id;
466 int format;
467 u_int32_t cost;
468
469 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
470 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
471
472 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
473 if (argc > 2)
474 {
paul4dadc292005-05-06 21:37:42 +0000475 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000476 ospf_area_range_cost_set (ospf, area_id, &p, cost);
477 }
478
479 return CMD_SUCCESS;
480}
481
paula2c62832003-04-23 17:01:31 +0000482ALIAS (ospf_area_range,
483 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000484 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
485 "OSPF area parameters\n"
486 "OSPF area ID in IP address format\n"
487 "OSPF area ID as a decimal value\n"
488 "OSPF area range for route advertise (default)\n"
489 "Area range prefix\n"
490 "Advertise this range (default)\n")
491
paula2c62832003-04-23 17:01:31 +0000492ALIAS (ospf_area_range,
493 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000494 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
495 "OSPF area parameters\n"
496 "OSPF area ID in IP address format\n"
497 "OSPF area ID as a decimal value\n"
498 "Summarize routes matching address/mask (border routers only)\n"
499 "Area range prefix\n"
500 "User specified metric for this range\n"
501 "Advertised metric for this range\n")
502
paula2c62832003-04-23 17:01:31 +0000503ALIAS (ospf_area_range,
504 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000505 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
506 "OSPF area parameters\n"
507 "OSPF area ID in IP address format\n"
508 "OSPF area ID as a decimal value\n"
509 "Summarize routes matching address/mask (border routers only)\n"
510 "Area range prefix\n"
511 "Advertise this range (default)\n"
512 "User specified metric for this range\n"
513 "Advertised metric for this range\n")
514
paula2c62832003-04-23 17:01:31 +0000515DEFUN (ospf_area_range_not_advertise,
516 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000517 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
518 "OSPF area parameters\n"
519 "OSPF area ID in IP address format\n"
520 "OSPF area ID as a decimal value\n"
521 "Summarize routes matching address/mask (border routers only)\n"
522 "Area range prefix\n"
523 "DoNotAdvertise this range\n")
524{
525 struct ospf *ospf = vty->index;
526 struct prefix_ipv4 p;
527 struct in_addr area_id;
528 int format;
529
530 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
531 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
532
533 ospf_area_range_set (ospf, area_id, &p, 0);
534
535 return CMD_SUCCESS;
536}
537
paula2c62832003-04-23 17:01:31 +0000538DEFUN (no_ospf_area_range,
539 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000540 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
541 NO_STR
542 "OSPF area parameters\n"
543 "OSPF area ID in IP address format\n"
544 "OSPF area ID as a decimal value\n"
545 "Summarize routes matching address/mask (border routers only)\n"
546 "Area range prefix\n")
547{
548 struct ospf *ospf = vty->index;
549 struct prefix_ipv4 p;
550 struct in_addr area_id;
551 int format;
552
553 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
554 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
555
556 ospf_area_range_unset (ospf, area_id, &p);
557
558 return CMD_SUCCESS;
559}
560
paula2c62832003-04-23 17:01:31 +0000561ALIAS (no_ospf_area_range,
562 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000563 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
564 NO_STR
565 "OSPF area parameters\n"
566 "OSPF area ID in IP address format\n"
567 "OSPF area ID as a decimal value\n"
568 "Summarize routes matching address/mask (border routers only)\n"
569 "Area range prefix\n"
570 "Advertise this range (default)\n"
571 "DoNotAdvertise this range\n")
572
paula2c62832003-04-23 17:01:31 +0000573ALIAS (no_ospf_area_range,
574 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000575 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
576 NO_STR
577 "OSPF area parameters\n"
578 "OSPF area ID in IP address format\n"
579 "OSPF area ID as a decimal value\n"
580 "Summarize routes matching address/mask (border routers only)\n"
581 "Area range prefix\n"
582 "User specified metric for this range\n"
583 "Advertised metric for this range\n")
584
paula2c62832003-04-23 17:01:31 +0000585ALIAS (no_ospf_area_range,
586 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000587 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
588 NO_STR
589 "OSPF area parameters\n"
590 "OSPF area ID in IP address format\n"
591 "OSPF area ID as a decimal value\n"
592 "Summarize routes matching address/mask (border routers only)\n"
593 "Area range prefix\n"
594 "Advertise this range (default)\n"
595 "User specified metric for this range\n"
596 "Advertised metric for this range\n")
597
paula2c62832003-04-23 17:01:31 +0000598DEFUN (ospf_area_range_substitute,
599 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000600 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
601 "OSPF area parameters\n"
602 "OSPF area ID in IP address format\n"
603 "OSPF area ID as a decimal value\n"
604 "Summarize routes matching address/mask (border routers only)\n"
605 "Area range prefix\n"
606 "Announce area range as another prefix\n"
607 "Network prefix to be announced instead of range\n")
608{
609 struct ospf *ospf = vty->index;
610 struct prefix_ipv4 p, s;
611 struct in_addr area_id;
612 int format;
613
614 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
615 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
616 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
617
618 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
619
620 return CMD_SUCCESS;
621}
622
paula2c62832003-04-23 17:01:31 +0000623DEFUN (no_ospf_area_range_substitute,
624 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000625 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
626 NO_STR
627 "OSPF area parameters\n"
628 "OSPF area ID in IP address format\n"
629 "OSPF area ID as a decimal value\n"
630 "Summarize routes matching address/mask (border routers only)\n"
631 "Area range prefix\n"
632 "Announce area range as another prefix\n"
633 "Network prefix to be announced instead of range\n")
634{
635 struct ospf *ospf = vty->index;
636 struct prefix_ipv4 p, s;
637 struct in_addr area_id;
638 int format;
639
640 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
641 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
642 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
643
644 ospf_area_range_substitute_unset (ospf, area_id, &p);
645
646 return CMD_SUCCESS;
647}
648
649
650/* Command Handler Logic in VLink stuff is delicate!!
651
652 ALTER AT YOUR OWN RISK!!!!
653
654 Various dummy values are used to represent 'NoChange' state for
655 VLink configuration NOT being changed by a VLink command, and
656 special syntax is used within the command strings so that the
657 typed in command verbs can be seen in the configuration command
658 bacckend handler. This is to drastically reduce the verbeage
659 required to coe up with a reasonably compatible Cisco VLink command
660
661 - Matthew Grant <grantma@anathoth.gen.nz>
662 Wed, 21 Feb 2001 15:13:52 +1300
663 */
664
665
666/* Configuration data for virtual links
667 */
668struct ospf_vl_config_data {
669 struct vty *vty; /* vty stuff */
670 struct in_addr area_id; /* area ID from command line */
671 int format; /* command line area ID format */
672 struct in_addr vl_peer; /* command line vl_peer */
673 int auth_type; /* Authehntication type, if given */
674 char *auth_key; /* simple password if present */
675 int crypto_key_id; /* Cryptographic key ID */
676 char *md5_key; /* MD5 authentication key */
677 int hello_interval; /* Obvious what these are... */
678 int retransmit_interval;
679 int transmit_delay;
680 int dead_interval;
681};
682
paul4dadc292005-05-06 21:37:42 +0000683static void
paul718e3742002-12-13 20:15:29 +0000684ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
685 struct vty *vty)
686{
687 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
688 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
689 vl_config->vty = vty;
690}
691
paul4dadc292005-05-06 21:37:42 +0000692static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000693ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000694{
695 struct ospf_area *area;
696 struct ospf_vl_data *vl_data;
697 struct vty *vty;
698 struct in_addr area_id;
699
700 vty = vl_config->vty;
701 area_id = vl_config->area_id;
702
703 if (area_id.s_addr == OSPF_AREA_BACKBONE)
704 {
705 vty_out (vty,
706 "Configuring VLs over the backbone is not allowed%s",
707 VTY_NEWLINE);
708 return NULL;
709 }
paul68980082003-03-25 05:07:42 +0000710 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000711
712 if (area->external_routing != OSPF_AREA_DEFAULT)
713 {
714 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
715 vty_out (vty, "Area %s is %s%s",
716 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000717 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000718 VTY_NEWLINE);
719 else
720 vty_out (vty, "Area %ld is %s%s",
721 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000722 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000723 VTY_NEWLINE);
724 return NULL;
725 }
726
727 if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)
728 {
729 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
730 if (vl_data->vl_oi == NULL)
731 {
paul68980082003-03-25 05:07:42 +0000732 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
733 ospf_vl_add (ospf, vl_data);
734 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000735 }
736 }
737 return vl_data;
738}
739
740
paul4dadc292005-05-06 21:37:42 +0000741static int
paul718e3742002-12-13 20:15:29 +0000742ospf_vl_set_security (struct ospf_vl_data *vl_data,
743 struct ospf_vl_config_data *vl_config)
744{
745 struct crypt_key *ck;
746 struct vty *vty;
747 struct interface *ifp = vl_data->vl_oi->ifp;
748
749 vty = vl_config->vty;
750
751 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
752 {
753 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
754 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
755 }
756
757 if (vl_config->auth_key)
758 {
759 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000760 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000761 OSPF_AUTH_SIMPLE_SIZE);
762 }
763 else if (vl_config->md5_key)
764 {
765 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
766 != NULL)
767 {
768 vty_out (vty, "OSPF: Key %d already exists%s",
769 vl_config->crypto_key_id, VTY_NEWLINE);
770 return CMD_WARNING;
771 }
772 ck = ospf_crypt_key_new ();
773 ck->key_id = vl_config->crypto_key_id;
774 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000775 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000776
777 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
778 }
779 else if (vl_config->crypto_key_id != 0)
780 {
781 /* Delete a key */
782
783 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
784 vl_config->crypto_key_id) == NULL)
785 {
786 vty_out (vty, "OSPF: Key %d does not exist%s",
787 vl_config->crypto_key_id, VTY_NEWLINE);
788 return CMD_WARNING;
789 }
790
791 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
792
793 }
794
795 return CMD_SUCCESS;
796}
797
paul4dadc292005-05-06 21:37:42 +0000798static int
paul718e3742002-12-13 20:15:29 +0000799ospf_vl_set_timers (struct ospf_vl_data *vl_data,
800 struct ospf_vl_config_data *vl_config)
801{
802 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
803 /* Virtual Link data initialised to defaults, so only set
804 if a value given */
805 if (vl_config->hello_interval)
806 {
807 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
808 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
809 }
810
811 if (vl_config->dead_interval)
812 {
813 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
814 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
815 }
816
817 if (vl_config->retransmit_interval)
818 {
819 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
820 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
821 }
822
823 if (vl_config->transmit_delay)
824 {
825 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
826 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
827 }
828
829 return CMD_SUCCESS;
830}
831
832
833
834/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000835static int
paul68980082003-03-25 05:07:42 +0000836ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000837{
838 struct ospf_vl_data *vl_data;
839 int ret;
840
paul68980082003-03-25 05:07:42 +0000841 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000842 if (!vl_data)
843 return CMD_WARNING;
844
845 /* Process this one first as it can have a fatal result, which can
846 only logically occur if the virtual link exists already
847 Thus a command error does not result in a change to the
848 running configuration such as unexpectedly altered timer
849 values etc.*/
850 ret = ospf_vl_set_security (vl_data, vl_config);
851 if (ret != CMD_SUCCESS)
852 return ret;
853
854 /* Set any time based parameters, these area already range checked */
855
856 ret = ospf_vl_set_timers (vl_data, vl_config);
857 if (ret != CMD_SUCCESS)
858 return ret;
859
860 return CMD_SUCCESS;
861
862}
863
864/* This stuff exists to make specifying all the alias commands A LOT simpler
865 */
866#define VLINK_HELPSTR_IPADDR \
867 "OSPF area parameters\n" \
868 "OSPF area ID in IP address format\n" \
869 "OSPF area ID as a decimal value\n" \
870 "Configure a virtual link\n" \
871 "Router ID of the remote ABR\n"
872
873#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
874 "Enable authentication on this virtual link\n" \
875 "dummy string \n"
876
877#define VLINK_HELPSTR_AUTHTYPE_ALL \
878 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
879 "Use null authentication\n" \
880 "Use message-digest authentication\n"
881
882#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
883 "Time between HELLO packets\n" \
884 "Time between retransmitting lost link state advertisements\n" \
885 "Link state transmit delay\n" \
886 "Interval after which a neighbor is declared dead\n"
887
888#define VLINK_HELPSTR_TIME_PARAM \
889 VLINK_HELPSTR_TIME_PARAM_NOSECS \
890 "Seconds\n"
891
892#define VLINK_HELPSTR_AUTH_SIMPLE \
893 "Authentication password (key)\n" \
894 "The OSPF password (key)"
895
896#define VLINK_HELPSTR_AUTH_MD5 \
897 "Message digest authentication password (key)\n" \
898 "dummy string \n" \
899 "Key ID\n" \
900 "Use MD5 algorithm\n" \
901 "The OSPF password (key)"
902
paula2c62832003-04-23 17:01:31 +0000903DEFUN (ospf_area_vlink,
904 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000905 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
906 VLINK_HELPSTR_IPADDR)
907{
paul68980082003-03-25 05:07:42 +0000908 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000909 struct ospf_vl_config_data vl_config;
910 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
911 char md5_key[OSPF_AUTH_MD5_SIZE+1];
912 int i;
913 int ret;
914
915 ospf_vl_config_data_init(&vl_config, vty);
916
917 /* Read off first 2 parameters and check them */
918 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
919 if (ret < 0)
920 {
921 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
922 return CMD_WARNING;
923 }
924
925 ret = inet_aton (argv[1], &vl_config.vl_peer);
926 if (! ret)
927 {
928 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
929 VTY_NEWLINE);
930 return CMD_WARNING;
931 }
932
933 if (argc <=2)
934 {
935 /* Thats all folks! - BUGS B. strikes again!!!*/
936
paul68980082003-03-25 05:07:42 +0000937 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000938 }
939
940 /* Deal with other parameters */
941 for (i=2; i < argc; i++)
942 {
943
944 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
945
946 switch (argv[i][0])
947 {
948
949 case 'a':
950 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
951 {
952 /* authentication-key - this option can occur anywhere on
953 command line. At start of command line
954 must check for authentication option. */
955 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
956 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
957 vl_config.auth_key = auth_key;
958 i++;
959 }
960 else if (strncmp (argv[i], "authentication", 14) == 0)
961 {
962 /* authentication - this option can only occur at start
963 of command line */
964 vl_config.auth_type = OSPF_AUTH_SIMPLE;
965 if ((i+1) < argc)
966 {
967 if (strncmp (argv[i+1], "n", 1) == 0)
968 {
969 /* "authentication null" */
970 vl_config.auth_type = OSPF_AUTH_NULL;
971 i++;
972 }
973 else if (strncmp (argv[i+1], "m", 1) == 0
974 && strcmp (argv[i+1], "message-digest-") != 0)
975 {
976 /* "authentication message-digest" */
977 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
978 i++;
979 }
980 }
981 }
982 break;
983
984 case 'm':
985 /* message-digest-key */
986 i++;
987 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
988 if (vl_config.crypto_key_id < 0)
989 return CMD_WARNING;
990 i++;
991 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
992 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
993 vl_config.md5_key = md5_key;
994 break;
995
996 case 'h':
997 /* Hello interval */
998 i++;
999 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1000 if (vl_config.hello_interval < 0)
1001 return CMD_WARNING;
1002 break;
1003
1004 case 'r':
1005 /* Retransmit Interval */
1006 i++;
1007 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1008 if (vl_config.retransmit_interval < 0)
1009 return CMD_WARNING;
1010 break;
1011
1012 case 't':
1013 /* Transmit Delay */
1014 i++;
1015 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1016 if (vl_config.transmit_delay < 0)
1017 return CMD_WARNING;
1018 break;
1019
1020 case 'd':
1021 /* Dead Interval */
1022 i++;
1023 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1024 if (vl_config.dead_interval < 0)
1025 return CMD_WARNING;
1026 break;
1027 }
1028 }
1029
1030
1031 /* Action configuration */
1032
paul68980082003-03-25 05:07:42 +00001033 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001034
1035}
1036
paula2c62832003-04-23 17:01:31 +00001037DEFUN (no_ospf_area_vlink,
1038 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001039 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1040 NO_STR
1041 VLINK_HELPSTR_IPADDR)
1042{
paul68980082003-03-25 05:07:42 +00001043 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001044 struct ospf_area *area;
1045 struct ospf_vl_config_data vl_config;
1046 struct ospf_vl_data *vl_data = NULL;
1047 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1048 int i;
1049 int ret, format;
1050
1051 ospf_vl_config_data_init(&vl_config, vty);
1052
1053 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1054 if (ret < 0)
1055 {
1056 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1057 return CMD_WARNING;
1058 }
1059
paul68980082003-03-25 05:07:42 +00001060 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001061 if (!area)
1062 {
1063 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1064 return CMD_WARNING;
1065 }
1066
1067 ret = inet_aton (argv[1], &vl_config.vl_peer);
1068 if (! ret)
1069 {
1070 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1071 VTY_NEWLINE);
1072 return CMD_WARNING;
1073 }
1074
1075 if (argc <=2)
1076 {
1077 /* Basic VLink no command */
1078 /* Thats all folks! - BUGS B. strikes again!!!*/
1079 if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001080 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001081
paul68980082003-03-25 05:07:42 +00001082 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001083
1084 return CMD_SUCCESS;
1085 }
1086
1087 /* If we are down here, we are reseting parameters */
1088
1089 /* Deal with other parameters */
1090 for (i=2; i < argc; i++)
1091 {
paul718e3742002-12-13 20:15:29 +00001092 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1093
1094 switch (argv[i][0])
1095 {
1096
1097 case 'a':
1098 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1099 {
1100 /* authentication-key - this option can occur anywhere on
1101 command line. At start of command line
1102 must check for authentication option. */
1103 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1104 vl_config.auth_key = auth_key;
1105 }
1106 else if (strncmp (argv[i], "authentication", 14) == 0)
1107 {
1108 /* authentication - this option can only occur at start
1109 of command line */
1110 vl_config.auth_type = OSPF_AUTH_NOTSET;
1111 }
1112 break;
1113
1114 case 'm':
1115 /* message-digest-key */
1116 /* Delete one key */
1117 i++;
1118 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1119 if (vl_config.crypto_key_id < 0)
1120 return CMD_WARNING;
1121 vl_config.md5_key = NULL;
1122 break;
1123
1124 case 'h':
1125 /* Hello interval */
1126 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1127 break;
1128
1129 case 'r':
1130 /* Retransmit Interval */
1131 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1132 break;
1133
1134 case 't':
1135 /* Transmit Delay */
1136 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1137 break;
1138
1139 case 'd':
1140 /* Dead Interval */
1141 i++;
1142 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1143 break;
1144 }
1145 }
1146
1147
1148 /* Action configuration */
1149
paul68980082003-03-25 05:07:42 +00001150 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001151}
1152
paula2c62832003-04-23 17:01:31 +00001153ALIAS (ospf_area_vlink,
1154 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001155 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1156 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1157 VLINK_HELPSTR_IPADDR
1158 VLINK_HELPSTR_TIME_PARAM)
1159
paula2c62832003-04-23 17:01:31 +00001160ALIAS (no_ospf_area_vlink,
1161 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001162 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1163 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1164 NO_STR
1165 VLINK_HELPSTR_IPADDR
1166 VLINK_HELPSTR_TIME_PARAM)
1167
paula2c62832003-04-23 17:01:31 +00001168ALIAS (ospf_area_vlink,
1169 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001170 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1171 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1172 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1173 VLINK_HELPSTR_IPADDR
1174 VLINK_HELPSTR_TIME_PARAM
1175 VLINK_HELPSTR_TIME_PARAM)
1176
paula2c62832003-04-23 17:01:31 +00001177ALIAS (no_ospf_area_vlink,
1178 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001179 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1180 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1181 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1182 NO_STR
1183 VLINK_HELPSTR_IPADDR
1184 VLINK_HELPSTR_TIME_PARAM
1185 VLINK_HELPSTR_TIME_PARAM)
1186
paula2c62832003-04-23 17:01:31 +00001187ALIAS (ospf_area_vlink,
1188 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001189 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1190 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1191 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1192 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1193 VLINK_HELPSTR_IPADDR
1194 VLINK_HELPSTR_TIME_PARAM
1195 VLINK_HELPSTR_TIME_PARAM
1196 VLINK_HELPSTR_TIME_PARAM)
1197
paula2c62832003-04-23 17:01:31 +00001198ALIAS (no_ospf_area_vlink,
1199 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001200 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1201 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1202 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1203 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1204 NO_STR
1205 VLINK_HELPSTR_IPADDR
1206 VLINK_HELPSTR_TIME_PARAM
1207 VLINK_HELPSTR_TIME_PARAM
1208 VLINK_HELPSTR_TIME_PARAM)
1209
paula2c62832003-04-23 17:01:31 +00001210ALIAS (ospf_area_vlink,
1211 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001212 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1213 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1214 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1215 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1216 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
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 (no_ospf_area_vlink,
1224 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001225 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1226 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1227 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1228 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1229 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1230 NO_STR
1231 VLINK_HELPSTR_IPADDR
1232 VLINK_HELPSTR_TIME_PARAM
1233 VLINK_HELPSTR_TIME_PARAM
1234 VLINK_HELPSTR_TIME_PARAM
1235 VLINK_HELPSTR_TIME_PARAM)
1236
paula2c62832003-04-23 17:01:31 +00001237ALIAS (ospf_area_vlink,
1238 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001239 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1240 "(authentication|) (message-digest|null)",
1241 VLINK_HELPSTR_IPADDR
1242 VLINK_HELPSTR_AUTHTYPE_ALL)
1243
paula2c62832003-04-23 17:01:31 +00001244ALIAS (ospf_area_vlink,
1245 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001246 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1247 "(authentication|)",
1248 VLINK_HELPSTR_IPADDR
1249 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1250
paula2c62832003-04-23 17:01:31 +00001251ALIAS (no_ospf_area_vlink,
1252 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001253 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1254 "(authentication|)",
1255 NO_STR
1256 VLINK_HELPSTR_IPADDR
1257 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1258
paula2c62832003-04-23 17:01:31 +00001259ALIAS (ospf_area_vlink,
1260 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001261 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1262 "(message-digest-key|) <1-255> md5 KEY",
1263 VLINK_HELPSTR_IPADDR
1264 VLINK_HELPSTR_AUTH_MD5)
1265
paula2c62832003-04-23 17:01:31 +00001266ALIAS (no_ospf_area_vlink,
1267 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001268 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1269 "(message-digest-key|) <1-255>",
1270 NO_STR
1271 VLINK_HELPSTR_IPADDR
1272 VLINK_HELPSTR_AUTH_MD5)
1273
paula2c62832003-04-23 17:01:31 +00001274ALIAS (ospf_area_vlink,
1275 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001276 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1277 "(authentication-key|) AUTH_KEY",
1278 VLINK_HELPSTR_IPADDR
1279 VLINK_HELPSTR_AUTH_SIMPLE)
1280
paula2c62832003-04-23 17:01:31 +00001281ALIAS (no_ospf_area_vlink,
1282 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001283 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1284 "(authentication-key|)",
1285 NO_STR
1286 VLINK_HELPSTR_IPADDR
1287 VLINK_HELPSTR_AUTH_SIMPLE)
1288
paula2c62832003-04-23 17:01:31 +00001289ALIAS (ospf_area_vlink,
1290 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001291 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1292 "(authentication|) (message-digest|null) "
1293 "(authentication-key|) AUTH_KEY",
1294 VLINK_HELPSTR_IPADDR
1295 VLINK_HELPSTR_AUTHTYPE_ALL
1296 VLINK_HELPSTR_AUTH_SIMPLE)
1297
paula2c62832003-04-23 17:01:31 +00001298ALIAS (ospf_area_vlink,
1299 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001300 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1301 "(authentication|) "
1302 "(authentication-key|) AUTH_KEY",
1303 VLINK_HELPSTR_IPADDR
1304 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1305 VLINK_HELPSTR_AUTH_SIMPLE)
1306
paula2c62832003-04-23 17:01:31 +00001307ALIAS (no_ospf_area_vlink,
1308 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001309 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1310 "(authentication|) "
1311 "(authentication-key|)",
1312 NO_STR
1313 VLINK_HELPSTR_IPADDR
1314 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1315 VLINK_HELPSTR_AUTH_SIMPLE)
1316
paula2c62832003-04-23 17:01:31 +00001317ALIAS (ospf_area_vlink,
1318 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001319 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1320 "(authentication|) (message-digest|null) "
1321 "(message-digest-key|) <1-255> md5 KEY",
1322 VLINK_HELPSTR_IPADDR
1323 VLINK_HELPSTR_AUTHTYPE_ALL
1324 VLINK_HELPSTR_AUTH_MD5)
1325
paula2c62832003-04-23 17:01:31 +00001326ALIAS (ospf_area_vlink,
1327 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001328 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1329 "(authentication|) "
1330 "(message-digest-key|) <1-255> md5 KEY",
1331 VLINK_HELPSTR_IPADDR
1332 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1333 VLINK_HELPSTR_AUTH_MD5)
1334
paula2c62832003-04-23 17:01:31 +00001335ALIAS (no_ospf_area_vlink,
1336 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001337 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1338 "(authentication|) "
1339 "(message-digest-key|)",
1340 NO_STR
1341 VLINK_HELPSTR_IPADDR
1342 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1343 VLINK_HELPSTR_AUTH_MD5)
1344
1345
paula2c62832003-04-23 17:01:31 +00001346DEFUN (ospf_area_shortcut,
1347 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001348 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1349 "OSPF area parameters\n"
1350 "OSPF area ID in IP address format\n"
1351 "OSPF area ID as a decimal value\n"
1352 "Configure the area's shortcutting mode\n"
1353 "Set default shortcutting behavior\n"
1354 "Enable shortcutting through the area\n"
1355 "Disable shortcutting through the area\n")
1356{
paul68980082003-03-25 05:07:42 +00001357 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001358 struct ospf_area *area;
1359 struct in_addr area_id;
1360 int mode;
1361 int format;
1362
1363 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1364
paul68980082003-03-25 05:07:42 +00001365 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001366
1367 if (strncmp (argv[1], "de", 2) == 0)
1368 mode = OSPF_SHORTCUT_DEFAULT;
1369 else if (strncmp (argv[1], "di", 2) == 0)
1370 mode = OSPF_SHORTCUT_DISABLE;
1371 else if (strncmp (argv[1], "e", 1) == 0)
1372 mode = OSPF_SHORTCUT_ENABLE;
1373 else
1374 return CMD_WARNING;
1375
paul68980082003-03-25 05:07:42 +00001376 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001377
paul68980082003-03-25 05:07:42 +00001378 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001379 vty_out (vty, "Shortcut area setting will take effect "
1380 "only when the router is configured as Shortcut ABR%s",
1381 VTY_NEWLINE);
1382
1383 return CMD_SUCCESS;
1384}
1385
paula2c62832003-04-23 17:01:31 +00001386DEFUN (no_ospf_area_shortcut,
1387 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001388 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1389 NO_STR
1390 "OSPF area parameters\n"
1391 "OSPF area ID in IP address format\n"
1392 "OSPF area ID as a decimal value\n"
1393 "Deconfigure the area's shortcutting mode\n"
1394 "Deconfigure enabled shortcutting through the area\n"
1395 "Deconfigure disabled shortcutting through the area\n")
1396{
paul68980082003-03-25 05:07:42 +00001397 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001398 struct ospf_area *area;
1399 struct in_addr area_id;
1400 int format;
1401
1402 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1403
paul68980082003-03-25 05:07:42 +00001404 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001405 if (!area)
1406 return CMD_SUCCESS;
1407
paul68980082003-03-25 05:07:42 +00001408 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001409
1410 return CMD_SUCCESS;
1411}
1412
1413
paula2c62832003-04-23 17:01:31 +00001414DEFUN (ospf_area_stub,
1415 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001416 "area (A.B.C.D|<0-4294967295>) stub",
1417 "OSPF area parameters\n"
1418 "OSPF area ID in IP address format\n"
1419 "OSPF area ID as a decimal value\n"
1420 "Configure OSPF area as stub\n")
1421{
1422 struct ospf *ospf = vty->index;
1423 struct in_addr area_id;
1424 int ret, format;
1425
1426 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1427
1428 ret = ospf_area_stub_set (ospf, area_id);
1429 if (ret == 0)
1430 {
1431 vty_out (vty, "First deconfigure all virtual link through this area%s",
1432 VTY_NEWLINE);
1433 return CMD_WARNING;
1434 }
1435
1436 ospf_area_no_summary_unset (ospf, area_id);
1437
1438 return CMD_SUCCESS;
1439}
1440
paula2c62832003-04-23 17:01:31 +00001441DEFUN (ospf_area_stub_no_summary,
1442 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001443 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1444 "OSPF stub parameters\n"
1445 "OSPF area ID in IP address format\n"
1446 "OSPF area ID as a decimal value\n"
1447 "Configure OSPF area as stub\n"
1448 "Do not inject inter-area routes into stub\n")
1449{
1450 struct ospf *ospf = vty->index;
1451 struct in_addr area_id;
1452 int ret, format;
1453
1454 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1455
1456 ret = ospf_area_stub_set (ospf, area_id);
1457 if (ret == 0)
1458 {
paulb0a053b2003-06-22 09:04:47 +00001459 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001460 VTY_NEWLINE);
1461 return CMD_WARNING;
1462 }
1463
1464 ospf_area_no_summary_set (ospf, area_id);
1465
1466 return CMD_SUCCESS;
1467}
1468
paula2c62832003-04-23 17:01:31 +00001469DEFUN (no_ospf_area_stub,
1470 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001471 "no area (A.B.C.D|<0-4294967295>) stub",
1472 NO_STR
1473 "OSPF area parameters\n"
1474 "OSPF area ID in IP address format\n"
1475 "OSPF area ID as a decimal value\n"
1476 "Configure OSPF area as stub\n")
1477{
1478 struct ospf *ospf = vty->index;
1479 struct in_addr area_id;
1480 int format;
1481
1482 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1483
1484 ospf_area_stub_unset (ospf, area_id);
1485 ospf_area_no_summary_unset (ospf, area_id);
1486
1487 return CMD_SUCCESS;
1488}
1489
paula2c62832003-04-23 17:01:31 +00001490DEFUN (no_ospf_area_stub_no_summary,
1491 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001492 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1493 NO_STR
1494 "OSPF area parameters\n"
1495 "OSPF area ID in IP address format\n"
1496 "OSPF area ID as a decimal value\n"
1497 "Configure OSPF area as stub\n"
1498 "Do not inject inter-area routes into area\n")
1499{
1500 struct ospf *ospf = vty->index;
1501 struct in_addr area_id;
1502 int format;
1503
1504 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1505 ospf_area_no_summary_unset (ospf, area_id);
1506
1507 return CMD_SUCCESS;
1508}
1509
paul4dadc292005-05-06 21:37:42 +00001510static int
paul6c835672004-10-11 11:00:30 +00001511ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1512 int nosum)
paul718e3742002-12-13 20:15:29 +00001513{
1514 struct ospf *ospf = vty->index;
1515 struct in_addr area_id;
1516 int ret, format;
1517
1518 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1519
1520 ret = ospf_area_nssa_set (ospf, area_id);
1521 if (ret == 0)
1522 {
1523 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1524 VTY_NEWLINE);
1525 return CMD_WARNING;
1526 }
1527
1528 if (argc > 1)
1529 {
1530 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001531 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001532 OSPF_NSSA_ROLE_CANDIDATE);
1533 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001534 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001535 OSPF_NSSA_ROLE_NEVER);
1536 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001537 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001538 OSPF_NSSA_ROLE_ALWAYS);
1539 }
paulb0a053b2003-06-22 09:04:47 +00001540 else
1541 {
1542 ospf_area_nssa_translator_role_set (ospf, area_id,
1543 OSPF_NSSA_ROLE_CANDIDATE);
1544 }
paul718e3742002-12-13 20:15:29 +00001545
paulb0a053b2003-06-22 09:04:47 +00001546 if (nosum)
paul718e3742002-12-13 20:15:29 +00001547 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001548 else
1549 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001550
paulb0a053b2003-06-22 09:04:47 +00001551 ospf_schedule_abr_task (ospf);
1552
paul718e3742002-12-13 20:15:29 +00001553 return CMD_SUCCESS;
1554}
1555
paulb0a053b2003-06-22 09:04:47 +00001556DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001557 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001558 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001559 "OSPF area parameters\n"
1560 "OSPF area ID in IP address format\n"
1561 "OSPF area ID as a decimal value\n"
1562 "Configure OSPF area as nssa\n"
1563 "Configure NSSA-ABR for translate election (default)\n"
1564 "Configure NSSA-ABR to never translate\n"
1565 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001566 "Do not inject inter-area routes into nssa\n")
1567{
1568 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1569}
paul718e3742002-12-13 20:15:29 +00001570
paulb0a053b2003-06-22 09:04:47 +00001571DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001572 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001573 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
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 "Configure NSSA-ABR for translate election (default)\n"
1579 "Configure NSSA-ABR to never translate\n"
1580 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001581{
1582 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1583}
1584
1585DEFUN (ospf_area_nssa,
1586 ospf_area_nssa_cmd,
1587 "area (A.B.C.D|<0-4294967295>) nssa",
1588 "OSPF area parameters\n"
1589 "OSPF area ID in IP address format\n"
1590 "OSPF area ID as a decimal value\n"
1591 "Configure OSPF area as nssa\n")
1592{
1593 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1594}
paul718e3742002-12-13 20:15:29 +00001595
paula2c62832003-04-23 17:01:31 +00001596DEFUN (ospf_area_nssa_no_summary,
1597 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001598 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1599 "OSPF area parameters\n"
1600 "OSPF area ID in IP address format\n"
1601 "OSPF area ID as a decimal value\n"
1602 "Configure OSPF area as nssa\n"
1603 "Do not inject inter-area routes into nssa\n")
1604{
paulb0a053b2003-06-22 09:04:47 +00001605 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001606}
1607
paula2c62832003-04-23 17:01:31 +00001608DEFUN (no_ospf_area_nssa,
1609 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001610 "no area (A.B.C.D|<0-4294967295>) nssa",
1611 NO_STR
1612 "OSPF area parameters\n"
1613 "OSPF area ID in IP address format\n"
1614 "OSPF area ID as a decimal value\n"
1615 "Configure OSPF area as nssa\n")
1616{
1617 struct ospf *ospf = vty->index;
1618 struct in_addr area_id;
1619 int format;
1620
1621 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1622
1623 ospf_area_nssa_unset (ospf, area_id);
1624 ospf_area_no_summary_unset (ospf, area_id);
1625
paulb0a053b2003-06-22 09:04:47 +00001626 ospf_schedule_abr_task (ospf);
1627
paul718e3742002-12-13 20:15:29 +00001628 return CMD_SUCCESS;
1629}
1630
paula2c62832003-04-23 17:01:31 +00001631DEFUN (no_ospf_area_nssa_no_summary,
1632 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001633 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1634 NO_STR
1635 "OSPF area parameters\n"
1636 "OSPF area ID in IP address format\n"
1637 "OSPF area ID as a decimal value\n"
1638 "Configure OSPF area as nssa\n"
1639 "Do not inject inter-area routes into nssa\n")
1640{
1641 struct ospf *ospf = vty->index;
1642 struct in_addr area_id;
1643 int format;
1644
1645 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1646 ospf_area_no_summary_unset (ospf, area_id);
1647
1648 return CMD_SUCCESS;
1649}
1650
paula2c62832003-04-23 17:01:31 +00001651DEFUN (ospf_area_default_cost,
1652 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001653 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1654 "OSPF area parameters\n"
1655 "OSPF area ID in IP address format\n"
1656 "OSPF area ID as a decimal value\n"
1657 "Set the summary-default cost of a NSSA or stub area\n"
1658 "Stub's advertised default summary cost\n")
1659{
paul68980082003-03-25 05:07:42 +00001660 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001661 struct ospf_area *area;
1662 struct in_addr area_id;
1663 u_int32_t cost;
1664 int format;
vincentba682532005-09-29 13:52:57 +00001665 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001666
1667 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1668 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1669
paul68980082003-03-25 05:07:42 +00001670 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001671
1672 if (area->external_routing == OSPF_AREA_DEFAULT)
1673 {
1674 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1675 return CMD_WARNING;
1676 }
1677
1678 area->default_cost = cost;
1679
vincentba682532005-09-29 13:52:57 +00001680 p.family = AF_INET;
1681 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1682 p.prefixlen = 0;
1683 if (IS_DEBUG_OSPF_EVENT)
1684 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1685 "announcing 0.0.0.0/0 to area %s",
1686 inet_ntoa (area->area_id));
1687 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1688
paul718e3742002-12-13 20:15:29 +00001689 return CMD_SUCCESS;
1690}
1691
paula2c62832003-04-23 17:01:31 +00001692DEFUN (no_ospf_area_default_cost,
1693 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001694 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1695 NO_STR
1696 "OSPF area parameters\n"
1697 "OSPF area ID in IP address format\n"
1698 "OSPF area ID as a decimal value\n"
1699 "Set the summary-default cost of a NSSA or stub area\n"
1700 "Stub's advertised default summary cost\n")
1701{
paul68980082003-03-25 05:07:42 +00001702 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001703 struct ospf_area *area;
1704 struct in_addr area_id;
1705 u_int32_t cost;
1706 int format;
vincentba682532005-09-29 13:52:57 +00001707 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001708
1709 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1710 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1711
paul68980082003-03-25 05:07:42 +00001712 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001713 if (area == NULL)
1714 return CMD_SUCCESS;
1715
1716 if (area->external_routing == OSPF_AREA_DEFAULT)
1717 {
1718 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1719 return CMD_WARNING;
1720 }
1721
1722 area->default_cost = 1;
1723
vincentba682532005-09-29 13:52:57 +00001724 p.family = AF_INET;
1725 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1726 p.prefixlen = 0;
1727 if (IS_DEBUG_OSPF_EVENT)
1728 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1729 "announcing 0.0.0.0/0 to area %s",
1730 inet_ntoa (area->area_id));
1731 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1732
1733
paul68980082003-03-25 05:07:42 +00001734 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001735
1736 return CMD_SUCCESS;
1737}
1738
paula2c62832003-04-23 17:01:31 +00001739DEFUN (ospf_area_export_list,
1740 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001741 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1742 "OSPF area parameters\n"
1743 "OSPF area ID in IP address format\n"
1744 "OSPF area ID as a decimal value\n"
1745 "Set the filter for networks announced to other areas\n"
1746 "Name of the access-list\n")
1747{
paul68980082003-03-25 05:07:42 +00001748 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001749 struct ospf_area *area;
1750 struct in_addr area_id;
1751 int format;
1752
hasso52930762004-04-19 18:26:53 +00001753 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1754
paul68980082003-03-25 05:07:42 +00001755 area = ospf_area_get (ospf, area_id, format);
1756 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001757
1758 return CMD_SUCCESS;
1759}
1760
paula2c62832003-04-23 17:01:31 +00001761DEFUN (no_ospf_area_export_list,
1762 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001763 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1764 NO_STR
1765 "OSPF area parameters\n"
1766 "OSPF area ID in IP address format\n"
1767 "OSPF area ID as a decimal value\n"
1768 "Unset the filter for networks announced to other areas\n"
1769 "Name of the access-list\n")
1770{
paul68980082003-03-25 05:07:42 +00001771 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001772 struct ospf_area *area;
1773 struct in_addr area_id;
1774 int format;
1775
hasso52930762004-04-19 18:26:53 +00001776 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1777
paul68980082003-03-25 05:07:42 +00001778 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001779 if (area == NULL)
1780 return CMD_SUCCESS;
1781
paul68980082003-03-25 05:07:42 +00001782 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001783
1784 return CMD_SUCCESS;
1785}
1786
1787
paula2c62832003-04-23 17:01:31 +00001788DEFUN (ospf_area_import_list,
1789 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001790 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1791 "OSPF area parameters\n"
1792 "OSPF area ID in IP address format\n"
1793 "OSPF area ID as a decimal value\n"
1794 "Set the filter for networks from other areas announced to the specified one\n"
1795 "Name of the access-list\n")
1796{
paul68980082003-03-25 05:07:42 +00001797 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001798 struct ospf_area *area;
1799 struct in_addr area_id;
1800 int format;
1801
hasso52930762004-04-19 18:26:53 +00001802 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1803
paul68980082003-03-25 05:07:42 +00001804 area = ospf_area_get (ospf, area_id, format);
1805 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001806
1807 return CMD_SUCCESS;
1808}
1809
paula2c62832003-04-23 17:01:31 +00001810DEFUN (no_ospf_area_import_list,
1811 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001812 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1813 NO_STR
1814 "OSPF area parameters\n"
1815 "OSPF area ID in IP address format\n"
1816 "OSPF area ID as a decimal value\n"
1817 "Unset the filter for networks announced to other areas\n"
1818 "Name of the access-list\n")
1819{
paul68980082003-03-25 05:07:42 +00001820 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001821 struct ospf_area *area;
1822 struct in_addr area_id;
1823 int format;
1824
hasso52930762004-04-19 18:26:53 +00001825 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1826
paul68980082003-03-25 05:07:42 +00001827 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001828 if (area == NULL)
1829 return CMD_SUCCESS;
1830
paul68980082003-03-25 05:07:42 +00001831 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001832
1833 return CMD_SUCCESS;
1834}
1835
paula2c62832003-04-23 17:01:31 +00001836DEFUN (ospf_area_filter_list,
1837 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001838 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1839 "OSPF area parameters\n"
1840 "OSPF area ID in IP address format\n"
1841 "OSPF area ID as a decimal value\n"
1842 "Filter networks between OSPF areas\n"
1843 "Filter prefixes between OSPF areas\n"
1844 "Name of an IP prefix-list\n"
1845 "Filter networks sent to this area\n"
1846 "Filter networks sent from this area\n")
1847{
paul68980082003-03-25 05:07:42 +00001848 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001849 struct ospf_area *area;
1850 struct in_addr area_id;
1851 struct prefix_list *plist;
1852 int format;
1853
1854 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1855
paul68980082003-03-25 05:07:42 +00001856 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001857 plist = prefix_list_lookup (AFI_IP, argv[1]);
1858 if (strncmp (argv[2], "in", 2) == 0)
1859 {
1860 PREFIX_LIST_IN (area) = plist;
1861 if (PREFIX_NAME_IN (area))
1862 free (PREFIX_NAME_IN (area));
1863
1864 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001865 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001866 }
1867 else
1868 {
1869 PREFIX_LIST_OUT (area) = plist;
1870 if (PREFIX_NAME_OUT (area))
1871 free (PREFIX_NAME_OUT (area));
1872
1873 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001874 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001875 }
1876
1877 return CMD_SUCCESS;
1878}
1879
paula2c62832003-04-23 17:01:31 +00001880DEFUN (no_ospf_area_filter_list,
1881 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001882 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1883 NO_STR
1884 "OSPF area parameters\n"
1885 "OSPF area ID in IP address format\n"
1886 "OSPF area ID as a decimal value\n"
1887 "Filter networks between OSPF areas\n"
1888 "Filter prefixes between OSPF areas\n"
1889 "Name of an IP prefix-list\n"
1890 "Filter networks sent to this area\n"
1891 "Filter networks sent from this area\n")
1892{
paul68980082003-03-25 05:07:42 +00001893 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001894 struct ospf_area *area;
1895 struct in_addr area_id;
1896 struct prefix_list *plist;
1897 int format;
1898
1899 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1900
paul68980082003-03-25 05:07:42 +00001901 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001902 plist = prefix_list_lookup (AFI_IP, argv[1]);
1903 if (strncmp (argv[2], "in", 2) == 0)
1904 {
1905 if (PREFIX_NAME_IN (area))
1906 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1907 return CMD_SUCCESS;
1908
1909 PREFIX_LIST_IN (area) = NULL;
1910 if (PREFIX_NAME_IN (area))
1911 free (PREFIX_NAME_IN (area));
1912
1913 PREFIX_NAME_IN (area) = NULL;
1914
paul68980082003-03-25 05:07:42 +00001915 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001916 }
1917 else
1918 {
1919 if (PREFIX_NAME_OUT (area))
1920 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1921 return CMD_SUCCESS;
1922
1923 PREFIX_LIST_OUT (area) = NULL;
1924 if (PREFIX_NAME_OUT (area))
1925 free (PREFIX_NAME_OUT (area));
1926
1927 PREFIX_NAME_OUT (area) = NULL;
1928
paul68980082003-03-25 05:07:42 +00001929 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001930 }
1931
1932 return CMD_SUCCESS;
1933}
1934
1935
paula2c62832003-04-23 17:01:31 +00001936DEFUN (ospf_area_authentication_message_digest,
1937 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001938 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1939 "OSPF area parameters\n"
1940 "Enable authentication\n"
1941 "Use message-digest authentication\n")
1942{
paul68980082003-03-25 05:07:42 +00001943 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001944 struct ospf_area *area;
1945 struct in_addr area_id;
1946 int format;
1947
1948 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1949
paul68980082003-03-25 05:07:42 +00001950 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001951 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1952
1953 return CMD_SUCCESS;
1954}
1955
paula2c62832003-04-23 17:01:31 +00001956DEFUN (ospf_area_authentication,
1957 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001958 "area (A.B.C.D|<0-4294967295>) authentication",
1959 "OSPF area parameters\n"
1960 "OSPF area ID in IP address format\n"
1961 "OSPF area ID as a decimal value\n"
1962 "Enable authentication\n")
1963{
paul68980082003-03-25 05:07:42 +00001964 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001965 struct ospf_area *area;
1966 struct in_addr area_id;
1967 int format;
1968
1969 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1970
paul68980082003-03-25 05:07:42 +00001971 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001972 area->auth_type = OSPF_AUTH_SIMPLE;
1973
1974 return CMD_SUCCESS;
1975}
1976
paula2c62832003-04-23 17:01:31 +00001977DEFUN (no_ospf_area_authentication,
1978 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001979 "no area (A.B.C.D|<0-4294967295>) authentication",
1980 NO_STR
1981 "OSPF area parameters\n"
1982 "OSPF area ID in IP address format\n"
1983 "OSPF area ID as a decimal value\n"
1984 "Enable authentication\n")
1985{
paul68980082003-03-25 05:07:42 +00001986 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001987 struct ospf_area *area;
1988 struct in_addr area_id;
1989 int format;
1990
1991 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1992
paul68980082003-03-25 05:07:42 +00001993 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001994 if (area == NULL)
1995 return CMD_SUCCESS;
1996
1997 area->auth_type = OSPF_AUTH_NULL;
1998
paul68980082003-03-25 05:07:42 +00001999 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002000
2001 return CMD_SUCCESS;
2002}
2003
2004
2005DEFUN (ospf_abr_type,
2006 ospf_abr_type_cmd,
2007 "ospf abr-type (cisco|ibm|shortcut|standard)",
2008 "OSPF specific commands\n"
2009 "Set OSPF ABR type\n"
2010 "Alternative ABR, cisco implementation\n"
2011 "Alternative ABR, IBM implementation\n"
2012 "Shortcut ABR\n"
2013 "Standard behavior (RFC2328)\n")
2014{
paul68980082003-03-25 05:07:42 +00002015 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002016 u_char abr_type = OSPF_ABR_UNKNOWN;
2017
2018 if (strncmp (argv[0], "c", 1) == 0)
2019 abr_type = OSPF_ABR_CISCO;
2020 else if (strncmp (argv[0], "i", 1) == 0)
2021 abr_type = OSPF_ABR_IBM;
2022 else if (strncmp (argv[0], "sh", 2) == 0)
2023 abr_type = OSPF_ABR_SHORTCUT;
2024 else if (strncmp (argv[0], "st", 2) == 0)
2025 abr_type = OSPF_ABR_STAND;
2026 else
2027 return CMD_WARNING;
2028
2029 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002030 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002031 {
paul68980082003-03-25 05:07:42 +00002032 ospf->abr_type = abr_type;
2033 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002034 }
2035
2036 return CMD_SUCCESS;
2037}
2038
2039DEFUN (no_ospf_abr_type,
2040 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002041 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002042 NO_STR
2043 "OSPF specific commands\n"
2044 "Set OSPF ABR type\n"
2045 "Alternative ABR, cisco implementation\n"
2046 "Alternative ABR, IBM implementation\n"
2047 "Shortcut ABR\n")
2048{
paul68980082003-03-25 05:07:42 +00002049 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002050 u_char abr_type = OSPF_ABR_UNKNOWN;
2051
2052 if (strncmp (argv[0], "c", 1) == 0)
2053 abr_type = OSPF_ABR_CISCO;
2054 else if (strncmp (argv[0], "i", 1) == 0)
2055 abr_type = OSPF_ABR_IBM;
2056 else if (strncmp (argv[0], "s", 1) == 0)
2057 abr_type = OSPF_ABR_SHORTCUT;
2058 else
2059 return CMD_WARNING;
2060
2061 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002062 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002063 {
pauld57834f2005-07-12 20:04:22 +00002064 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002065 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002066 }
2067
2068 return CMD_SUCCESS;
2069}
2070
2071DEFUN (ospf_compatible_rfc1583,
2072 ospf_compatible_rfc1583_cmd,
2073 "compatible rfc1583",
2074 "OSPF compatibility list\n"
2075 "compatible with RFC 1583\n")
2076{
2077 struct ospf *ospf = vty->index;
2078
2079 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2080 {
2081 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002082 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002083 }
2084 return CMD_SUCCESS;
2085}
2086
2087DEFUN (no_ospf_compatible_rfc1583,
2088 no_ospf_compatible_rfc1583_cmd,
2089 "no compatible rfc1583",
2090 NO_STR
2091 "OSPF compatibility list\n"
2092 "compatible with RFC 1583\n")
2093{
2094 struct ospf *ospf = vty->index;
2095
2096 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2097 {
2098 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002099 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002100 }
2101 return CMD_SUCCESS;
2102}
2103
2104ALIAS (ospf_compatible_rfc1583,
2105 ospf_rfc1583_flag_cmd,
2106 "ospf rfc1583compatibility",
2107 "OSPF specific commands\n"
2108 "Enable the RFC1583Compatibility flag\n")
2109
2110ALIAS (no_ospf_compatible_rfc1583,
2111 no_ospf_rfc1583_flag_cmd,
2112 "no ospf rfc1583compatibility",
2113 NO_STR
2114 "OSPF specific commands\n"
2115 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002116
2117static int
2118ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2119 unsigned int hold,
2120 unsigned int max)
2121{
2122 struct ospf *ospf = vty->index;
2123
2124 ospf->spf_delay = delay;
2125 ospf->spf_holdtime = hold;
2126 ospf->spf_max_holdtime = max;
2127
2128 return CMD_SUCCESS;
2129}
paul718e3742002-12-13 20:15:29 +00002130
pauld24f6e22005-10-21 09:23:12 +00002131DEFUN (ospf_timers_throttle_spf,
2132 ospf_timers_throttle_spf_cmd,
2133 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2134 "Adjust routing timers\n"
2135 "Throttling adaptive timer\n"
2136 "OSPF SPF timers\n"
2137 "Delay (msec) from first change received till SPF calculation\n"
2138 "Initial hold time (msec) between consecutive SPF calculations\n"
2139 "Maximum hold time (msec)\n")
2140{
2141 unsigned int delay, hold, max;
2142
2143 if (argc != 3)
2144 {
2145 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2146 return CMD_WARNING;
2147 }
2148
2149 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2150 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2151 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2152
2153 return ospf_timers_spf_set (vty, delay, hold, max);
2154}
2155
2156DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002157 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002158 "timers spf <0-4294967295> <0-4294967295>",
2159 "Adjust routing timers\n"
2160 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002161 "Delay (s) between receiving a change to SPF calculation\n"
2162 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002163{
pauld24f6e22005-10-21 09:23:12 +00002164 unsigned int delay, hold;
2165
2166 if (argc != 2)
2167 {
2168 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2169 return CMD_WARNING;
2170 }
2171
paul4dadc292005-05-06 21:37:42 +00002172 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2173 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002174
2175 /* truncate down the second values if they're greater than 600000ms */
2176 if (delay > (600000 / 1000))
2177 delay = 600000;
2178 else if (delay == 0)
2179 /* 0s delay was probably specified because of lack of ms resolution */
2180 delay = OSPF_SPF_DELAY_DEFAULT;
2181 if (hold > (600000 / 1000))
2182 hold = 600000;
2183
2184 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002185}
2186
pauld24f6e22005-10-21 09:23:12 +00002187DEFUN (no_ospf_timers_throttle_spf,
2188 no_ospf_timers_throttle_spf_cmd,
2189 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002190 NO_STR
2191 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002192 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002193 "OSPF SPF timers\n")
2194{
pauld24f6e22005-10-21 09:23:12 +00002195 return ospf_timers_spf_set (vty,
2196 OSPF_SPF_DELAY_DEFAULT,
2197 OSPF_SPF_HOLDTIME_DEFAULT,
2198 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002199}
2200
pauld24f6e22005-10-21 09:23:12 +00002201ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2202 no_ospf_timers_spf_cmd,
2203 "no timers spf",
2204 NO_STR
2205 "Adjust routing timers\n"
2206 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002207
paula2c62832003-04-23 17:01:31 +00002208DEFUN (ospf_neighbor,
2209 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002210 "neighbor A.B.C.D",
2211 NEIGHBOR_STR
2212 "Neighbor IP address\n")
2213{
2214 struct ospf *ospf = vty->index;
2215 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002216 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2217 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002218
2219 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2220
2221 if (argc > 1)
2222 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2223
2224 if (argc > 2)
2225 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2226
2227 ospf_nbr_nbma_set (ospf, nbr_addr);
2228 if (argc > 1)
2229 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2230 if (argc > 2)
2231 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2232
2233 return CMD_SUCCESS;
2234}
2235
paula2c62832003-04-23 17:01:31 +00002236ALIAS (ospf_neighbor,
2237 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002238 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2239 NEIGHBOR_STR
2240 "Neighbor IP address\n"
2241 "Neighbor Priority\n"
2242 "Priority\n"
2243 "Dead Neighbor Polling interval\n"
2244 "Seconds\n")
2245
paula2c62832003-04-23 17:01:31 +00002246ALIAS (ospf_neighbor,
2247 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002248 "neighbor A.B.C.D priority <0-255>",
2249 NEIGHBOR_STR
2250 "Neighbor IP address\n"
2251 "Neighbor Priority\n"
2252 "Seconds\n")
2253
paula2c62832003-04-23 17:01:31 +00002254DEFUN (ospf_neighbor_poll_interval,
2255 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002256 "neighbor A.B.C.D poll-interval <1-65535>",
2257 NEIGHBOR_STR
2258 "Neighbor IP address\n"
2259 "Dead Neighbor Polling interval\n"
2260 "Seconds\n")
2261{
2262 struct ospf *ospf = vty->index;
2263 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002264 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2265 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002266
2267 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2268
2269 if (argc > 1)
2270 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2271
2272 if (argc > 2)
2273 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2274
2275 ospf_nbr_nbma_set (ospf, nbr_addr);
2276 if (argc > 1)
2277 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2278 if (argc > 2)
2279 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2280
2281 return CMD_SUCCESS;
2282}
2283
paula2c62832003-04-23 17:01:31 +00002284ALIAS (ospf_neighbor_poll_interval,
2285 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002286 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2287 NEIGHBOR_STR
2288 "Neighbor address\n"
2289 "OSPF dead-router polling interval\n"
2290 "Seconds\n"
2291 "OSPF priority of non-broadcast neighbor\n"
2292 "Priority\n")
2293
paula2c62832003-04-23 17:01:31 +00002294DEFUN (no_ospf_neighbor,
2295 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002296 "no neighbor A.B.C.D",
2297 NO_STR
2298 NEIGHBOR_STR
2299 "Neighbor IP address\n")
2300{
2301 struct ospf *ospf = vty->index;
2302 struct in_addr nbr_addr;
2303 int ret;
2304
2305 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2306
2307 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2308
2309 return CMD_SUCCESS;
2310}
2311
paula2c62832003-04-23 17:01:31 +00002312ALIAS (no_ospf_neighbor,
2313 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002314 "no neighbor A.B.C.D priority <0-255>",
2315 NO_STR
2316 NEIGHBOR_STR
2317 "Neighbor IP address\n"
2318 "Neighbor Priority\n"
2319 "Priority\n")
2320
paula2c62832003-04-23 17:01:31 +00002321ALIAS (no_ospf_neighbor,
2322 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002323 "no neighbor A.B.C.D poll-interval <1-65535>",
2324 NO_STR
2325 NEIGHBOR_STR
2326 "Neighbor IP address\n"
2327 "Dead Neighbor Polling interval\n"
2328 "Seconds\n")
2329
paula2c62832003-04-23 17:01:31 +00002330ALIAS (no_ospf_neighbor,
2331 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002332 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2333 NO_STR
2334 NEIGHBOR_STR
2335 "Neighbor IP address\n"
2336 "Neighbor Priority\n"
2337 "Priority\n"
2338 "Dead Neighbor Polling interval\n"
2339 "Seconds\n")
2340
2341
paula2c62832003-04-23 17:01:31 +00002342DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002343 "refresh timer <10-1800>",
2344 "Adjust refresh parameters\n"
2345 "Set refresh timer\n"
2346 "Timer value in seconds\n")
2347{
2348 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002349 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002350
2351 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2352 interval = (interval / 10) * 10;
2353
2354 ospf_timers_refresh_set (ospf, interval);
2355
2356 return CMD_SUCCESS;
2357}
2358
paula2c62832003-04-23 17:01:31 +00002359DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002360 "no refresh timer <10-1800>",
2361 "Adjust refresh parameters\n"
2362 "Unset refresh timer\n"
2363 "Timer value in seconds\n")
2364{
2365 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002366 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002367
2368 if (argc == 1)
2369 {
2370 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2371
2372 if (ospf->lsa_refresh_interval != interval ||
2373 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2374 return CMD_SUCCESS;
2375 }
2376
2377 ospf_timers_refresh_unset (ospf);
2378
2379 return CMD_SUCCESS;
2380}
2381
paula2c62832003-04-23 17:01:31 +00002382ALIAS (no_ospf_refresh_timer,
2383 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002384 "no refresh timer",
2385 "Adjust refresh parameters\n"
2386 "Unset refresh timer\n")
2387
paula2c62832003-04-23 17:01:31 +00002388DEFUN (ospf_auto_cost_reference_bandwidth,
2389 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002390 "auto-cost reference-bandwidth <1-4294967>",
2391 "Calculate OSPF interface cost according to bandwidth\n"
2392 "Use reference bandwidth method to assign OSPF cost\n"
2393 "The reference bandwidth in terms of Mbits per second\n")
2394{
paul68980082003-03-25 05:07:42 +00002395 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002396 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002397 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002398 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002399
2400 refbw = strtol (argv[0], NULL, 10);
2401 if (refbw < 1 || refbw > 4294967)
2402 {
2403 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2404 return CMD_WARNING;
2405 }
2406
2407 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002408 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002409 return CMD_SUCCESS;
2410
paul68980082003-03-25 05:07:42 +00002411 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002412 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2413 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002414
2415 return CMD_SUCCESS;
2416}
2417
paula2c62832003-04-23 17:01:31 +00002418DEFUN (no_ospf_auto_cost_reference_bandwidth,
2419 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002420 "no auto-cost reference-bandwidth",
2421 NO_STR
2422 "Calculate OSPF interface cost according to bandwidth\n"
2423 "Use reference bandwidth method to assign OSPF cost\n")
2424{
paul68980082003-03-25 05:07:42 +00002425 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002426 struct listnode *node, *nnode;
2427 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002428
paul68980082003-03-25 05:07:42 +00002429 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002430 return CMD_SUCCESS;
2431
paul68980082003-03-25 05:07:42 +00002432 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002433 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2434 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2435
paul1eb8ef22005-04-07 07:30:20 +00002436 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2437 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002438
2439 return CMD_SUCCESS;
2440}
2441
hassoeb1ce602004-10-08 08:17:22 +00002442const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002443{
2444 "Unknown",
2445 "Standard (RFC2328)",
2446 "Alternative IBM",
2447 "Alternative Cisco",
2448 "Alternative Shortcut"
2449};
2450
hassoeb1ce602004-10-08 08:17:22 +00002451const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002452{
2453 "Default",
2454 "Enabled",
2455 "Disabled"
2456};
2457
2458
2459
paul4dadc292005-05-06 21:37:42 +00002460static void
paul718e3742002-12-13 20:15:29 +00002461show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2462{
2463 /* Show Area ID. */
2464 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2465
2466 /* Show Area type/mode. */
2467 if (OSPF_IS_AREA_BACKBONE (area))
2468 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2469 else
2470 {
2471 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002472 vty_out (vty, " (Stub%s%s)",
2473 area->no_summary ? ", no summary" : "",
2474 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002475
paulb0a053b2003-06-22 09:04:47 +00002476 else if (area->external_routing == OSPF_AREA_NSSA)
2477 vty_out (vty, " (NSSA%s%s)",
2478 area->no_summary ? ", no summary" : "",
2479 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002480
2481 vty_out (vty, "%s", VTY_NEWLINE);
2482 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002483 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002484 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002485 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002486 }
2487
2488 /* Show number of interfaces. */
2489 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2490 "Active: %d%s", listcount (area->oiflist),
2491 area->act_ints, VTY_NEWLINE);
2492
paul718e3742002-12-13 20:15:29 +00002493 if (area->external_routing == OSPF_AREA_NSSA)
2494 {
2495 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00002496 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002497 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2498 VTY_NEWLINE);
2499 else if (area->NSSATranslatorState)
2500 {
2501 vty_out (vty, " We are an ABR and ");
2502 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2503 vty_out (vty, "the NSSA Elected Translator. %s",
2504 VTY_NEWLINE);
2505 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2506 vty_out (vty, "always an NSSA Translator. %s",
2507 VTY_NEWLINE);
2508 }
paul718e3742002-12-13 20:15:29 +00002509 else
paulb0a053b2003-06-22 09:04:47 +00002510 {
2511 vty_out (vty, " We are an ABR, but ");
2512 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2513 vty_out (vty, "not the NSSA Elected Translator. %s",
2514 VTY_NEWLINE);
2515 else
hassoc6b87812004-12-22 13:09:59 +00002516 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002517 VTY_NEWLINE);
2518 }
paul718e3742002-12-13 20:15:29 +00002519 }
paul88d6cf32005-10-29 12:50:09 +00002520 /* Stub-router state for this area */
2521 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2522 {
ajs649654a2005-11-16 20:17:52 +00002523 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002524 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2525 VTY_NEWLINE);
2526 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2527 vty_out (vty, " Administratively activated (indefinitely)%s",
2528 VTY_NEWLINE);
2529 if (area->t_stub_router)
2530 vty_out (vty, " Active from startup, %s remaining%s",
2531 ospf_timer_dump (area->t_stub_router, timebuf,
2532 sizeof(timebuf)), VTY_NEWLINE);
2533 }
2534
paul718e3742002-12-13 20:15:29 +00002535 /* Show number of fully adjacent neighbors. */
2536 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002537 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002538
2539 /* Show authentication type. */
2540 vty_out (vty, " Area has ");
2541 if (area->auth_type == OSPF_AUTH_NULL)
2542 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2543 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2544 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2545 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2546 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2547
2548 if (!OSPF_IS_AREA_BACKBONE (area))
2549 vty_out (vty, " Number of full virtual adjacencies going through"
2550 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2551
2552 /* Show SPF calculation times. */
2553 vty_out (vty, " SPF algorithm executed %d times%s",
2554 area->spf_calculation, VTY_NEWLINE);
2555
2556 /* Show number of LSA. */
2557 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002558 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2559 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2560 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2561 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2562 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2563 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2564 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2565 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2566 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2567 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2568 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2569 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2570 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2571 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2572 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2573#ifdef HAVE_OPAQUE_LSA
2574 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2575 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2576 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2577 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2578 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2579 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2580#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002581 vty_out (vty, "%s", VTY_NEWLINE);
2582}
2583
2584DEFUN (show_ip_ospf,
2585 show_ip_ospf_cmd,
2586 "show ip ospf",
2587 SHOW_STR
2588 IP_STR
2589 "OSPF information\n")
2590{
paul1eb8ef22005-04-07 07:30:20 +00002591 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002592 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002593 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002594 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002595 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002596
2597 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002598 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002599 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002600 {
2601 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2602 return CMD_SUCCESS;
2603 }
2604
2605 /* Show Router ID. */
2606 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002607 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002608 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002609
2610 /* Graceful shutdown */
2611 if (ospf->t_graceful_shutdown)
2612 vty_out (vty, " Graceful shutdown in progress, %s remaining%s",
2613 ospf_timer_dump (ospf->t_graceful_shutdown,
2614 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002615 /* Show capability. */
2616 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2617 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2618 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002619 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002620 "enabled" : "disabled", VTY_NEWLINE);
2621#ifdef HAVE_OPAQUE_LSA
2622 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002623 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002624 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002625 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002626 " (origination blocked)" : "",
2627 VTY_NEWLINE);
2628#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002629
2630 /* Show stub-router configuration */
2631 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2632 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2633 {
2634 vty_out (vty, " Stub router advertisement is configured%s",
2635 VTY_NEWLINE);
2636 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2637 vty_out (vty, " Enabled for %us after start-up%s",
2638 ospf->stub_router_startup_time, VTY_NEWLINE);
2639 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2640 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2641 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2642 }
2643
paul718e3742002-12-13 20:15:29 +00002644 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002645 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2646 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2647 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2648 " Hold time multiplier is currently %d%s",
2649 ospf->spf_delay, VTY_NEWLINE,
2650 ospf->spf_holdtime, VTY_NEWLINE,
2651 ospf->spf_max_holdtime, VTY_NEWLINE,
2652 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002653 vty_out (vty, " SPF algorithm ");
2654 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2655 {
paulc8c15212005-11-04 12:31:39 +00002656 result = tv_sub (recent_time, ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002657 vty_out (vty, "last executed %s ago%s",
2658 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2659 VTY_NEWLINE);
2660 }
2661 else
2662 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002663 vty_out (vty, " SPF timer %s%s%s",
2664 (ospf->t_spf_calc ? "due in " : "is "),
2665 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2666 VTY_NEWLINE);
2667
paul718e3742002-12-13 20:15:29 +00002668 /* Show refresh parameters. */
2669 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002670 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002671
2672 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002673 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002674 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002675 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002676
paul68980082003-03-25 05:07:42 +00002677 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002678 vty_out (vty, " This router is an ASBR "
2679 "(injecting external routing information)%s", VTY_NEWLINE);
2680
2681 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002682 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2683 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2684 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2685#ifdef HAVE_OPAQUE_LSA
2686 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2687 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2688 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2689#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002690 /* Show number of areas attached. */
2691 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002692 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002693
2694 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002695 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2696 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002697
2698 return CMD_SUCCESS;
2699}
2700
2701
ajsfd651fa2005-03-29 16:08:16 +00002702static void
paul68980082003-03-25 05:07:42 +00002703show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2704 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002705{
ajsfd651fa2005-03-29 16:08:16 +00002706 int is_up;
paul718e3742002-12-13 20:15:29 +00002707 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002708 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002709
paul718e3742002-12-13 20:15:29 +00002710 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002711 vty_out (vty, "%s is %s%s", ifp->name,
2712 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002713 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2714 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2715 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002716
2717 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002718 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002719 {
2720 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2721 return;
2722 }
ajsfd651fa2005-03-29 16:08:16 +00002723 else if (!is_up)
2724 {
2725 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2726 VTY_NEWLINE);
2727 return;
2728 }
2729
paul718e3742002-12-13 20:15:29 +00002730 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2731 {
2732 struct ospf_interface *oi = rn->info;
2733
2734 if (oi == NULL)
2735 continue;
2736
2737 /* Show OSPF interface information. */
2738 vty_out (vty, " Internet Address %s/%d,",
2739 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2740
hasso3fb9cd62004-10-19 19:44:43 +00002741 if (oi->connected->destination)
2742 vty_out (vty, " %s %s,",
2743 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2744 inet_ntoa (oi->connected->destination->u.prefix4));
2745
paul718e3742002-12-13 20:15:29 +00002746 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2747 VTY_NEWLINE);
2748
vincentba682532005-09-29 13:52:57 +00002749 vty_out (vty, " MTU mismatch detection:%s%s",
2750 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2751
paul718e3742002-12-13 20:15:29 +00002752 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002753 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002754 oi->output_cost, VTY_NEWLINE);
2755
2756 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2757 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2758 PRIORITY (oi), VTY_NEWLINE);
2759
2760 /* Show DR information. */
2761 if (DR (oi).s_addr == 0)
2762 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2763 else
2764 {
2765 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2766 if (nbr == NULL)
2767 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2768 else
2769 {
2770 vty_out (vty, " Designated Router (ID) %s,",
2771 inet_ntoa (nbr->router_id));
2772 vty_out (vty, " Interface Address %s%s",
2773 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2774 }
2775 }
2776
2777 /* Show BDR information. */
2778 if (BDR (oi).s_addr == 0)
2779 vty_out (vty, " No backup designated router on this network%s",
2780 VTY_NEWLINE);
2781 else
2782 {
2783 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2784 if (nbr == NULL)
2785 vty_out (vty, " No backup designated router on this network%s",
2786 VTY_NEWLINE);
2787 else
2788 {
2789 vty_out (vty, " Backup Designated Router (ID) %s,",
2790 inet_ntoa (nbr->router_id));
2791 vty_out (vty, " Interface Address %s%s",
2792 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2793 }
2794 }
ajsba6454e2005-02-08 15:37:30 +00002795
2796 vty_out (vty, " Multicast group memberships:");
2797 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2798 vty_out (vty, " OSPFAllRouters");
2799 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2800 vty_out (vty, " OSPFDesignatedRouters");
2801 if (!CHECK_FLAG(oi->multicast_memberships,
2802 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2803 vty_out (vty, " <None>");
2804 vty_out (vty, "%s", VTY_NEWLINE);
2805
paul718e3742002-12-13 20:15:29 +00002806 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002807 vty_out (vty, " Hello ");
2808 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2809 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2810 else
2811 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2812 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2813 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002814 OSPF_IF_PARAM (oi, v_wait),
2815 OSPF_IF_PARAM (oi, retransmit_interval),
2816 VTY_NEWLINE);
2817
2818 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002819 {
ajs649654a2005-11-16 20:17:52 +00002820 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002821 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002822 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002823 VTY_NEWLINE);
2824 }
paul718e3742002-12-13 20:15:29 +00002825 else /* OSPF_IF_PASSIVE is set */
2826 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2827
2828 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002829 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002830 VTY_NEWLINE);
2831 }
2832}
2833
2834DEFUN (show_ip_ospf_interface,
2835 show_ip_ospf_interface_cmd,
2836 "show ip ospf interface [INTERFACE]",
2837 SHOW_STR
2838 IP_STR
2839 "OSPF information\n"
2840 "Interface information\n"
2841 "Interface name\n")
2842{
2843 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002844 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002845 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002846
paul020709f2003-04-04 02:44:16 +00002847 ospf = ospf_lookup ();
2848
paul718e3742002-12-13 20:15:29 +00002849 /* Show All Interfaces. */
2850 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002851 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2852 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002853 /* Interface name is specified. */
2854 else
2855 {
2856 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2857 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2858 else
paul68980082003-03-25 05:07:42 +00002859 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002860 }
2861
2862 return CMD_SUCCESS;
2863}
2864
paul4dadc292005-05-06 21:37:42 +00002865static void
pauld24f6e22005-10-21 09:23:12 +00002866show_ip_ospf_neighbour_header (struct vty *vty)
2867{
2868 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2869 VTY_NEWLINE,
2870 "Neighbor ID", "Pri", "State", "Dead Time",
2871 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
2872 VTY_NEWLINE);
2873}
2874
2875static void
paul718e3742002-12-13 20:15:29 +00002876show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2877{
2878 struct route_node *rn;
2879 struct ospf_neighbor *nbr;
2880 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00002881 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002882
2883 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2884 if ((nbr = rn->info))
2885 /* Do not show myself. */
2886 if (nbr != oi->nbr_self)
2887 /* Down state is not shown. */
2888 if (nbr->state != NSM_Down)
2889 {
2890 ospf_nbr_state_message (nbr, msgbuf, 16);
2891
2892 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00002893 vty_out (vty, "%-15s %3d %-15s ",
2894 "-", nbr->priority,
2895 msgbuf);
2896 else
2897 vty_out (vty, "%-15s %3d %-15s ",
2898 inet_ntoa (nbr->router_id), nbr->priority,
2899 msgbuf);
2900
2901 vty_out (vty, "%9s ",
2902 ospf_timer_dump (nbr->t_inactivity, timebuf,
2903 sizeof(timebuf)));
2904
paul718e3742002-12-13 20:15:29 +00002905 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00002906 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00002907 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2908 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2909 VTY_NEWLINE);
2910 }
2911}
2912
2913DEFUN (show_ip_ospf_neighbor,
2914 show_ip_ospf_neighbor_cmd,
2915 "show ip ospf neighbor",
2916 SHOW_STR
2917 IP_STR
2918 "OSPF information\n"
2919 "Neighbor list\n")
2920{
paul020709f2003-04-04 02:44:16 +00002921 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002922 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002923 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002924
paul020709f2003-04-04 02:44:16 +00002925 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002926 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002927 {
2928 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2929 return CMD_SUCCESS;
2930 }
2931
pauld24f6e22005-10-21 09:23:12 +00002932 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00002933
paul1eb8ef22005-04-07 07:30:20 +00002934 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
2935 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00002936
2937 return CMD_SUCCESS;
2938}
2939
2940DEFUN (show_ip_ospf_neighbor_all,
2941 show_ip_ospf_neighbor_all_cmd,
2942 "show ip ospf neighbor all",
2943 SHOW_STR
2944 IP_STR
2945 "OSPF information\n"
2946 "Neighbor list\n"
2947 "include down status neighbor\n")
2948{
paul68980082003-03-25 05:07:42 +00002949 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002950 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002951 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002952
paul68980082003-03-25 05:07:42 +00002953 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002954 {
2955 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2956 return CMD_SUCCESS;
2957 }
pauld24f6e22005-10-21 09:23:12 +00002958
2959 show_ip_ospf_neighbour_header (vty);
2960
paul1eb8ef22005-04-07 07:30:20 +00002961 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00002962 {
hasso52dc7ee2004-09-23 19:18:23 +00002963 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00002964 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00002965
2966 show_ip_ospf_neighbor_sub (vty, oi);
2967
2968 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00002969 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00002970 {
paul718e3742002-12-13 20:15:29 +00002971 if (nbr_nbma->nbr == NULL
2972 || nbr_nbma->nbr->state == NSM_Down)
2973 {
pauld24f6e22005-10-21 09:23:12 +00002974 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00002975 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00002976 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00002977 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2978 0, 0, 0, VTY_NEWLINE);
2979 }
2980 }
2981 }
2982
2983 return CMD_SUCCESS;
2984}
2985
2986DEFUN (show_ip_ospf_neighbor_int,
2987 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00002988 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00002989 SHOW_STR
2990 IP_STR
2991 "OSPF information\n"
2992 "Neighbor list\n"
2993 "Interface name\n")
2994{
paul020709f2003-04-04 02:44:16 +00002995 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00002996 struct interface *ifp;
2997 struct route_node *rn;
2998
2999 ifp = if_lookup_by_name (argv[0]);
3000 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003001 {
hassobb5b7552005-08-21 20:01:15 +00003002 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003003 return CMD_WARNING;
3004 }
3005
paul020709f2003-04-04 02:44:16 +00003006 ospf = ospf_lookup ();
3007 if (ospf == NULL)
3008 {
3009 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3010 return CMD_SUCCESS;
3011 }
pauld24f6e22005-10-21 09:23:12 +00003012
3013 show_ip_ospf_neighbour_header (vty);
3014
hassobb5b7552005-08-21 20:01:15 +00003015 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003016 {
hassobb5b7552005-08-21 20:01:15 +00003017 struct ospf_interface *oi = rn->info;
3018
3019 if (oi == NULL)
3020 continue;
3021
paul718e3742002-12-13 20:15:29 +00003022 show_ip_ospf_neighbor_sub (vty, oi);
3023 }
3024
3025 return CMD_SUCCESS;
3026}
3027
paul4dadc292005-05-06 21:37:42 +00003028static void
paul718e3742002-12-13 20:15:29 +00003029show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3030 struct ospf_nbr_nbma *nbr_nbma)
3031{
ajs649654a2005-11-16 20:17:52 +00003032 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003033
3034 /* Show neighbor ID. */
3035 vty_out (vty, " Neighbor %s,", "-");
3036
3037 /* Show interface address. */
3038 vty_out (vty, " interface address %s%s",
3039 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3040 /* Show Area ID. */
3041 vty_out (vty, " In the area %s via interface %s%s",
3042 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3043 /* Show neighbor priority and state. */
3044 vty_out (vty, " Neighbor priority is %d, State is %s,",
3045 nbr_nbma->priority, "Down");
3046 /* Show state changes. */
3047 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3048
3049 /* Show PollInterval */
3050 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3051
3052 /* Show poll-interval timer. */
3053 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003054 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3055 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003056
3057 /* Show poll-interval timer thread. */
3058 vty_out (vty, " Thread Poll Timer %s%s",
3059 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3060}
3061
paul4dadc292005-05-06 21:37:42 +00003062static void
paul718e3742002-12-13 20:15:29 +00003063show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3064 struct ospf_neighbor *nbr)
3065{
ajs649654a2005-11-16 20:17:52 +00003066 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003067
3068 /* Show neighbor ID. */
3069 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3070 vty_out (vty, " Neighbor %s,", "-");
3071 else
3072 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3073
3074 /* Show interface address. */
3075 vty_out (vty, " interface address %s%s",
3076 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3077 /* Show Area ID. */
3078 vty_out (vty, " In the area %s via interface %s%s",
3079 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3080 /* Show neighbor priority and state. */
3081 vty_out (vty, " Neighbor priority is %d, State is %s,",
3082 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3083 /* Show state changes. */
3084 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3085
3086 /* Show Designated Rotuer ID. */
3087 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3088 /* Show Backup Designated Rotuer ID. */
3089 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3090 /* Show options. */
3091 vty_out (vty, " Options %d %s%s", nbr->options,
3092 ospf_options_dump (nbr->options), VTY_NEWLINE);
3093 /* Show Router Dead interval timer. */
3094 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003095 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3096 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003097 /* Show Database Summary list. */
3098 vty_out (vty, " Database Summary List %d%s",
3099 ospf_db_summary_count (nbr), VTY_NEWLINE);
3100 /* Show Link State Request list. */
3101 vty_out (vty, " Link State Request List %ld%s",
3102 ospf_ls_request_count (nbr), VTY_NEWLINE);
3103 /* Show Link State Retransmission list. */
3104 vty_out (vty, " Link State Retransmission List %ld%s",
3105 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3106 /* Show inactivity timer thread. */
3107 vty_out (vty, " Thread Inactivity Timer %s%s",
3108 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3109 /* Show Database Description retransmission thread. */
3110 vty_out (vty, " Thread Database Description Retransmision %s%s",
3111 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3112 /* Show Link State Request Retransmission thread. */
3113 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3114 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3115 /* Show Link State Update Retransmission thread. */
3116 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3117 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3118}
3119
3120DEFUN (show_ip_ospf_neighbor_id,
3121 show_ip_ospf_neighbor_id_cmd,
3122 "show ip ospf neighbor A.B.C.D",
3123 SHOW_STR
3124 IP_STR
3125 "OSPF information\n"
3126 "Neighbor list\n"
3127 "Neighbor ID\n")
3128{
paul020709f2003-04-04 02:44:16 +00003129 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003130 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003131 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003132 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003133 struct in_addr router_id;
3134 int ret;
3135
3136 ret = inet_aton (argv[0], &router_id);
3137 if (!ret)
3138 {
3139 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3140 return CMD_WARNING;
3141 }
3142
paul020709f2003-04-04 02:44:16 +00003143 ospf = ospf_lookup ();
3144 if (ospf == NULL)
3145 {
3146 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3147 return CMD_SUCCESS;
3148 }
3149
paul1eb8ef22005-04-07 07:30:20 +00003150 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3151 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3152 {
3153 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3154 return CMD_SUCCESS;
3155 }
paul718e3742002-12-13 20:15:29 +00003156
3157 /* Nothing to show. */
3158 return CMD_SUCCESS;
3159}
3160
3161DEFUN (show_ip_ospf_neighbor_detail,
3162 show_ip_ospf_neighbor_detail_cmd,
3163 "show ip ospf neighbor detail",
3164 SHOW_STR
3165 IP_STR
3166 "OSPF information\n"
3167 "Neighbor list\n"
3168 "detail of all neighbors\n")
3169{
paul020709f2003-04-04 02:44:16 +00003170 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003171 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003172 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003173
paul020709f2003-04-04 02:44:16 +00003174 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003175 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003176 {
3177 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3178 return CMD_SUCCESS;
3179 }
paul718e3742002-12-13 20:15:29 +00003180
paul1eb8ef22005-04-07 07:30:20 +00003181 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003182 {
paul718e3742002-12-13 20:15:29 +00003183 struct route_node *rn;
3184 struct ospf_neighbor *nbr;
3185
3186 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3187 if ((nbr = rn->info))
3188 if (nbr != oi->nbr_self)
3189 if (nbr->state != NSM_Down)
3190 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3191 }
3192
3193 return CMD_SUCCESS;
3194}
3195
3196DEFUN (show_ip_ospf_neighbor_detail_all,
3197 show_ip_ospf_neighbor_detail_all_cmd,
3198 "show ip ospf neighbor detail all",
3199 SHOW_STR
3200 IP_STR
3201 "OSPF information\n"
3202 "Neighbor list\n"
3203 "detail of all neighbors\n"
3204 "include down status neighbor\n")
3205{
paul020709f2003-04-04 02:44:16 +00003206 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003207 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003208 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003209
paul020709f2003-04-04 02:44:16 +00003210 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003211 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003212 {
3213 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3214 return CMD_SUCCESS;
3215 }
paul718e3742002-12-13 20:15:29 +00003216
paul1eb8ef22005-04-07 07:30:20 +00003217 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003218 {
paul718e3742002-12-13 20:15:29 +00003219 struct route_node *rn;
3220 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003221 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003222
3223 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3224 if ((nbr = rn->info))
3225 if (nbr != oi->nbr_self)
3226 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3227 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3228
3229 if (oi->type == OSPF_IFTYPE_NBMA)
3230 {
hasso52dc7ee2004-09-23 19:18:23 +00003231 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003232
paul1eb8ef22005-04-07 07:30:20 +00003233 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3234 if (nbr_nbma->nbr == NULL
3235 || nbr_nbma->nbr->state == NSM_Down)
3236 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003237 }
3238 }
3239
3240 return CMD_SUCCESS;
3241}
3242
3243DEFUN (show_ip_ospf_neighbor_int_detail,
3244 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003245 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003246 SHOW_STR
3247 IP_STR
3248 "OSPF information\n"
3249 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003250 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003251 "detail of all neighbors")
3252{
paul020709f2003-04-04 02:44:16 +00003253 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003254 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003255 struct interface *ifp;
3256 struct route_node *rn, *nrn;
3257 struct ospf_neighbor *nbr;
3258
3259 ifp = if_lookup_by_name (argv[0]);
3260 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003261 {
hassobb5b7552005-08-21 20:01:15 +00003262 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003263 return CMD_WARNING;
3264 }
3265
paul020709f2003-04-04 02:44:16 +00003266 ospf = ospf_lookup ();
3267 if (ospf == NULL)
3268 {
3269 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3270 return CMD_SUCCESS;
3271 }
paul68980082003-03-25 05:07:42 +00003272
paul718e3742002-12-13 20:15:29 +00003273
hassobb5b7552005-08-21 20:01:15 +00003274 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3275 if ((oi = rn->info))
3276 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3277 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003278 if (nbr != oi->nbr_self)
3279 if (nbr->state != NSM_Down)
3280 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003281
3282 return CMD_SUCCESS;
3283}
3284
3285
3286/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003287static int
paul020709f2003-04-04 02:44:16 +00003288show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003289{
paul718e3742002-12-13 20:15:29 +00003290 struct router_lsa *rl;
3291 struct summary_lsa *sl;
3292 struct as_external_lsa *asel;
3293 struct prefix_ipv4 p;
3294
3295 if (lsa != NULL)
3296 /* If self option is set, check LSA self flag. */
3297 if (self == 0 || IS_LSA_SELF (lsa))
3298 {
3299 /* LSA common part show. */
3300 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3301 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3302 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3303 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3304 /* LSA specific part show. */
3305 switch (lsa->data->type)
3306 {
3307 case OSPF_ROUTER_LSA:
3308 rl = (struct router_lsa *) lsa->data;
3309 vty_out (vty, " %-d", ntohs (rl->links));
3310 break;
3311 case OSPF_SUMMARY_LSA:
3312 sl = (struct summary_lsa *) lsa->data;
3313
3314 p.family = AF_INET;
3315 p.prefix = sl->header.id;
3316 p.prefixlen = ip_masklen (sl->mask);
3317 apply_mask_ipv4 (&p);
3318
3319 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3320 break;
3321 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003322 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003323 asel = (struct as_external_lsa *) lsa->data;
3324
3325 p.family = AF_INET;
3326 p.prefix = asel->header.id;
3327 p.prefixlen = ip_masklen (asel->mask);
3328 apply_mask_ipv4 (&p);
3329
3330 vty_out (vty, " %s %s/%d [0x%lx]",
3331 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3332 inet_ntoa (p.prefix), p.prefixlen,
3333 (u_long)ntohl (asel->e[0].route_tag));
3334 break;
3335 case OSPF_NETWORK_LSA:
3336 case OSPF_ASBR_SUMMARY_LSA:
3337#ifdef HAVE_OPAQUE_LSA
3338 case OSPF_OPAQUE_LINK_LSA:
3339 case OSPF_OPAQUE_AREA_LSA:
3340 case OSPF_OPAQUE_AS_LSA:
3341#endif /* HAVE_OPAQUE_LSA */
3342 default:
3343 break;
3344 }
3345 vty_out (vty, VTY_NEWLINE);
3346 }
3347
3348 return 0;
3349}
3350
hassoeb1ce602004-10-08 08:17:22 +00003351const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003352{
3353 "unknown",
3354 "Router Link States",
3355 "Net Link States",
3356 "Summary Link States",
3357 "ASBR-Summary Link States",
3358 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003359 "Group Membership LSA",
3360 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003361#ifdef HAVE_OPAQUE_LSA
3362 "Type-8 LSA",
3363 "Link-Local Opaque-LSA",
3364 "Area-Local Opaque-LSA",
3365 "AS-external Opaque-LSA",
3366#endif /* HAVE_OPAQUE_LSA */
3367};
3368
3369#define SHOW_OSPF_COMMON_HEADER \
3370 "Link ID ADV Router Age Seq# CkSum"
3371
hassoeb1ce602004-10-08 08:17:22 +00003372const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003373{
3374 "",
3375 "Link ID ADV Router Age Seq# CkSum Link count",
3376 "Link ID ADV Router Age Seq# CkSum",
3377 "Link ID ADV Router Age Seq# CkSum Route",
3378 "Link ID ADV Router Age Seq# CkSum",
3379 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003380 " --- header for Group Member ----",
3381 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003382#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003383 " --- type-8 ---",
3384 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3385 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3386 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3387#endif /* HAVE_OPAQUE_LSA */
3388};
3389
hassoeb1ce602004-10-08 08:17:22 +00003390const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003391{
3392 "Self-originated",
3393 "Checked",
3394 "Received",
3395 "Approved",
3396 "Discard",
paul4957f492003-06-27 01:28:45 +00003397 "Translated",
paul4957f492003-06-27 01:28:45 +00003398};
3399
paul4dadc292005-05-06 21:37:42 +00003400static void
paul718e3742002-12-13 20:15:29 +00003401show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3402{
3403 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003404
paul718e3742002-12-13 20:15:29 +00003405 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003406 vty_out (vty, " Options: 0x%-2x : %s%s",
3407 lsa->data->options,
3408 ospf_options_dump(lsa->data->options),
3409 VTY_NEWLINE);
3410 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003411 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003412 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3413 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003414
3415 if (lsa->data->type == OSPF_ROUTER_LSA)
3416 {
3417 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3418
3419 if (rlsa->flags)
3420 vty_out (vty, " :%s%s%s%s",
3421 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3422 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3423 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3424 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3425
3426 vty_out (vty, "%s", VTY_NEWLINE);
3427 }
3428 vty_out (vty, " LS Type: %s%s",
3429 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3430 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3431 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3432 vty_out (vty, " Advertising Router: %s%s",
3433 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3434 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3435 VTY_NEWLINE);
3436 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3437 VTY_NEWLINE);
3438 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3439}
3440
hassoeb1ce602004-10-08 08:17:22 +00003441const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003442{
3443 "(null)",
3444 "another Router (point-to-point)",
3445 "a Transit Network",
3446 "Stub Network",
3447 "a Virtual Link",
3448};
3449
hassoeb1ce602004-10-08 08:17:22 +00003450const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003451{
3452 "(null)",
3453 "Neighboring Router ID",
3454 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003455 "Net",
paul718e3742002-12-13 20:15:29 +00003456 "Neighboring Router ID",
3457};
3458
hassoeb1ce602004-10-08 08:17:22 +00003459const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003460{
3461 "(null)",
3462 "Router Interface address",
3463 "Router Interface address",
3464 "Network Mask",
3465 "Router Interface address",
3466};
3467
3468/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003469static void
paul718e3742002-12-13 20:15:29 +00003470show_ip_ospf_database_router_links (struct vty *vty,
3471 struct router_lsa *rl)
3472{
3473 int len, i, type;
3474
3475 len = ntohs (rl->header.length) - 4;
3476 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3477 {
3478 type = rl->link[i].type;
3479
3480 vty_out (vty, " Link connected to: %s%s",
3481 link_type_desc[type], VTY_NEWLINE);
3482 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3483 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3484 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3485 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3486 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3487 vty_out (vty, " TOS 0 Metric: %d%s",
3488 ntohs (rl->link[i].metric), VTY_NEWLINE);
3489 vty_out (vty, "%s", VTY_NEWLINE);
3490 }
3491}
3492
3493/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003494static int
paul718e3742002-12-13 20:15:29 +00003495show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3496{
3497 if (lsa != NULL)
3498 {
3499 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3500
3501 show_ip_ospf_database_header (vty, lsa);
3502
3503 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3504 VTY_NEWLINE, VTY_NEWLINE);
3505
3506 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003507 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003508 }
3509
3510 return 0;
3511}
3512
3513/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003514static int
paul718e3742002-12-13 20:15:29 +00003515show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3516{
3517 int length, i;
3518
3519 if (lsa != NULL)
3520 {
3521 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3522
3523 show_ip_ospf_database_header (vty, lsa);
3524
3525 vty_out (vty, " Network Mask: /%d%s",
3526 ip_masklen (nl->mask), VTY_NEWLINE);
3527
3528 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3529
3530 for (i = 0; length > 0; i++, length -= 4)
3531 vty_out (vty, " Attached Router: %s%s",
3532 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3533
3534 vty_out (vty, "%s", VTY_NEWLINE);
3535 }
3536
3537 return 0;
3538}
3539
3540/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003541static int
paul718e3742002-12-13 20:15:29 +00003542show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3543{
3544 if (lsa != NULL)
3545 {
3546 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3547
3548 show_ip_ospf_database_header (vty, lsa);
3549
3550 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3551 VTY_NEWLINE);
3552 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3553 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003554 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003555 }
3556
3557 return 0;
3558}
3559
3560/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003561static int
paul718e3742002-12-13 20:15:29 +00003562show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3563{
3564 if (lsa != NULL)
3565 {
3566 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3567
3568 show_ip_ospf_database_header (vty, lsa);
3569
3570 vty_out (vty, " Network Mask: /%d%s",
3571 ip_masklen (sl->mask), VTY_NEWLINE);
3572 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3573 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003574 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003575 }
3576
3577 return 0;
3578}
3579
3580/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003581static int
paul718e3742002-12-13 20:15:29 +00003582show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3583{
3584 if (lsa != NULL)
3585 {
3586 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3587
3588 show_ip_ospf_database_header (vty, lsa);
3589
3590 vty_out (vty, " Network Mask: /%d%s",
3591 ip_masklen (al->mask), VTY_NEWLINE);
3592 vty_out (vty, " Metric Type: %s%s",
3593 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3594 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3595 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3596 vty_out (vty, " Metric: %d%s",
3597 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3598 vty_out (vty, " Forward Address: %s%s",
3599 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3600
3601 vty_out (vty, " External Route Tag: %lu%s%s",
3602 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3603 }
3604
3605 return 0;
3606}
3607
ajs2a42e282004-12-08 18:43:03 +00003608/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003609static int
paul718e3742002-12-13 20:15:29 +00003610show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3611{
3612 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3613
3614 /* show_ip_ospf_database_header (vty, lsa); */
3615
ajs2a42e282004-12-08 18:43:03 +00003616 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003617 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003618 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003619 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3620 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003621 zlog_debug( " TOS: 0%s", "\n");
3622 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003623 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003624 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003625 inet_ntoa (al->e[0].fwd_addr), "\n");
3626
ajs2a42e282004-12-08 18:43:03 +00003627 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003628 ntohl (al->e[0].route_tag), "\n", "\n");
3629
3630 return 0;
3631}
3632
3633/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003634static int
paul718e3742002-12-13 20:15:29 +00003635show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3636{
3637 if (lsa != NULL)
3638 {
3639 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3640
3641 show_ip_ospf_database_header (vty, lsa);
3642
3643 vty_out (vty, " Network Mask: /%d%s",
3644 ip_masklen (al->mask), VTY_NEWLINE);
3645 vty_out (vty, " Metric Type: %s%s",
3646 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3647 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3648 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3649 vty_out (vty, " Metric: %d%s",
3650 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3651 vty_out (vty, " NSSA: Forward Address: %s%s",
3652 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3653
3654 vty_out (vty, " External Route Tag: %u%s%s",
3655 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3656 }
3657
3658 return 0;
3659}
3660
paul4dadc292005-05-06 21:37:42 +00003661static int
paul718e3742002-12-13 20:15:29 +00003662show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3663{
3664 return 0;
3665}
3666
3667#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003668static int
paul718e3742002-12-13 20:15:29 +00003669show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3670{
3671 if (lsa != NULL)
3672 {
3673 show_ip_ospf_database_header (vty, lsa);
3674 show_opaque_info_detail (vty, lsa);
3675
3676 vty_out (vty, "%s", VTY_NEWLINE);
3677 }
3678 return 0;
3679}
3680#endif /* HAVE_OPAQUE_LSA */
3681
3682int (*show_function[])(struct vty *, struct ospf_lsa *) =
3683{
3684 NULL,
3685 show_router_lsa_detail,
3686 show_network_lsa_detail,
3687 show_summary_lsa_detail,
3688 show_summary_asbr_lsa_detail,
3689 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003690 show_func_dummy,
3691 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003692#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003693 NULL, /* type-8 */
3694 show_opaque_lsa_detail,
3695 show_opaque_lsa_detail,
3696 show_opaque_lsa_detail,
3697#endif /* HAVE_OPAQUE_LSA */
3698};
3699
paul4dadc292005-05-06 21:37:42 +00003700static void
paul718e3742002-12-13 20:15:29 +00003701show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3702 struct in_addr *adv_router)
3703{
3704 memset (lp, 0, sizeof (struct prefix_ls));
3705 lp->family = 0;
3706 if (id == NULL)
3707 lp->prefixlen = 0;
3708 else if (adv_router == NULL)
3709 {
3710 lp->prefixlen = 32;
3711 lp->id = *id;
3712 }
3713 else
3714 {
3715 lp->prefixlen = 64;
3716 lp->id = *id;
3717 lp->adv_router = *adv_router;
3718 }
3719}
3720
paul4dadc292005-05-06 21:37:42 +00003721static void
paul718e3742002-12-13 20:15:29 +00003722show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3723 struct in_addr *id, struct in_addr *adv_router)
3724{
3725 struct prefix_ls lp;
3726 struct route_node *rn, *start;
3727 struct ospf_lsa *lsa;
3728
3729 show_lsa_prefix_set (vty, &lp, id, adv_router);
3730 start = route_node_get (rt, (struct prefix *) &lp);
3731 if (start)
3732 {
3733 route_lock_node (start);
3734 for (rn = start; rn; rn = route_next_until (rn, start))
3735 if ((lsa = rn->info))
3736 {
paul718e3742002-12-13 20:15:29 +00003737 if (show_function[lsa->data->type] != NULL)
3738 show_function[lsa->data->type] (vty, lsa);
3739 }
3740 route_unlock_node (start);
3741 }
3742}
3743
3744/* Show detail LSA information
3745 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003746static void
paul020709f2003-04-04 02:44:16 +00003747show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003748 struct in_addr *id, struct in_addr *adv_router)
3749{
hasso52dc7ee2004-09-23 19:18:23 +00003750 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003751 struct ospf_area *area;
3752
paul718e3742002-12-13 20:15:29 +00003753 switch (type)
3754 {
3755 case OSPF_AS_EXTERNAL_LSA:
3756#ifdef HAVE_OPAQUE_LSA
3757 case OSPF_OPAQUE_AS_LSA:
3758#endif /* HAVE_OPAQUE_LSA */
3759 vty_out (vty, " %s %s%s",
3760 show_database_desc[type],
3761 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003762 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003763 break;
3764 default:
paul1eb8ef22005-04-07 07:30:20 +00003765 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003766 {
paul718e3742002-12-13 20:15:29 +00003767 vty_out (vty, "%s %s (Area %s)%s%s",
3768 VTY_NEWLINE, show_database_desc[type],
3769 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3770 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3771 }
3772 break;
3773 }
3774}
3775
paul4dadc292005-05-06 21:37:42 +00003776static void
paul718e3742002-12-13 20:15:29 +00003777show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3778 struct in_addr *adv_router)
3779{
3780 struct route_node *rn;
3781 struct ospf_lsa *lsa;
3782
3783 for (rn = route_top (rt); rn; rn = route_next (rn))
3784 if ((lsa = rn->info))
3785 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3786 {
paul718e3742002-12-13 20:15:29 +00003787 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3788 continue;
paul718e3742002-12-13 20:15:29 +00003789 if (show_function[lsa->data->type] != NULL)
3790 show_function[lsa->data->type] (vty, lsa);
3791 }
3792}
3793
3794/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003795static void
paul020709f2003-04-04 02:44:16 +00003796show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003797 struct in_addr *adv_router)
3798{
hasso52dc7ee2004-09-23 19:18:23 +00003799 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003800 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003801
3802 switch (type)
3803 {
3804 case OSPF_AS_EXTERNAL_LSA:
3805#ifdef HAVE_OPAQUE_LSA
3806 case OSPF_OPAQUE_AS_LSA:
3807#endif /* HAVE_OPAQUE_LSA */
3808 vty_out (vty, " %s %s%s",
3809 show_database_desc[type],
3810 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003811 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003812 adv_router);
3813 break;
3814 default:
paul1eb8ef22005-04-07 07:30:20 +00003815 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003816 {
paul718e3742002-12-13 20:15:29 +00003817 vty_out (vty, "%s %s (Area %s)%s%s",
3818 VTY_NEWLINE, show_database_desc[type],
3819 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3820 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3821 adv_router);
3822 }
3823 break;
3824 }
3825}
3826
paul4dadc292005-05-06 21:37:42 +00003827static void
paul020709f2003-04-04 02:44:16 +00003828show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003829{
paul020709f2003-04-04 02:44:16 +00003830 struct ospf_lsa *lsa;
3831 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003832 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003833 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003834 int type;
3835
paul1eb8ef22005-04-07 07:30:20 +00003836 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003837 {
paul718e3742002-12-13 20:15:29 +00003838 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3839 {
3840 switch (type)
3841 {
3842 case OSPF_AS_EXTERNAL_LSA:
3843#ifdef HAVE_OPAQUE_LSA
3844 case OSPF_OPAQUE_AS_LSA:
3845#endif /* HAVE_OPAQUE_LSA */
3846 continue;
3847 default:
3848 break;
3849 }
3850 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3851 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3852 {
3853 vty_out (vty, " %s (Area %s)%s%s",
3854 show_database_desc[type],
3855 ospf_area_desc_string (area),
3856 VTY_NEWLINE, VTY_NEWLINE);
3857 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3858
paul020709f2003-04-04 02:44:16 +00003859 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3860 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003861
3862 vty_out (vty, "%s", VTY_NEWLINE);
3863 }
3864 }
3865 }
3866
3867 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3868 {
3869 switch (type)
3870 {
3871 case OSPF_AS_EXTERNAL_LSA:
3872#ifdef HAVE_OPAQUE_LSA
3873 case OSPF_OPAQUE_AS_LSA:
3874#endif /* HAVE_OPAQUE_LSA */
3875 break;;
3876 default:
3877 continue;
3878 }
paul68980082003-03-25 05:07:42 +00003879 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3880 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003881 {
3882 vty_out (vty, " %s%s%s",
3883 show_database_desc[type],
3884 VTY_NEWLINE, VTY_NEWLINE);
3885 vty_out (vty, "%s%s", show_database_header[type],
3886 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003887
3888 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3889 show_lsa_summary (vty, lsa, self);
3890
paul718e3742002-12-13 20:15:29 +00003891 vty_out (vty, "%s", VTY_NEWLINE);
3892 }
3893 }
3894
3895 vty_out (vty, "%s", VTY_NEWLINE);
3896}
3897
paul4dadc292005-05-06 21:37:42 +00003898static void
paul020709f2003-04-04 02:44:16 +00003899show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003900{
hasso52dc7ee2004-09-23 19:18:23 +00003901 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003902 struct ospf_lsa *lsa;
3903
3904 vty_out (vty, "%s MaxAge Link States:%s%s",
3905 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3906
paul1eb8ef22005-04-07 07:30:20 +00003907 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3908 {
3909 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3910 vty_out (vty, "Link State ID: %s%s",
3911 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3912 vty_out (vty, "Advertising Router: %s%s",
3913 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3914 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3915 vty_out (vty, "%s", VTY_NEWLINE);
3916 }
paul718e3742002-12-13 20:15:29 +00003917}
3918
paul718e3742002-12-13 20:15:29 +00003919#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3920#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003921
3922#ifdef HAVE_OPAQUE_LSA
3923#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3924#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3925#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3926#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3927#else /* HAVE_OPAQUE_LSA */
3928#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3929#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3930#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3931#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3932#endif /* HAVE_OPAQUE_LSA */
3933
3934#define OSPF_LSA_TYPES_CMD_STR \
3935 "asbr-summary|external|network|router|summary" \
3936 OSPF_LSA_TYPE_NSSA_CMD_STR \
3937 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3938
3939#define OSPF_LSA_TYPES_DESC \
3940 "ASBR summary link states\n" \
3941 "External link states\n" \
3942 "Network link states\n" \
3943 "Router link states\n" \
3944 "Network summary link states\n" \
3945 OSPF_LSA_TYPE_NSSA_DESC \
3946 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3947 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3948 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3949
3950DEFUN (show_ip_ospf_database,
3951 show_ip_ospf_database_cmd,
3952 "show ip ospf database",
3953 SHOW_STR
3954 IP_STR
3955 "OSPF information\n"
3956 "Database summary\n")
3957{
paul020709f2003-04-04 02:44:16 +00003958 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003959 int type, ret;
3960 struct in_addr id, adv_router;
3961
paul020709f2003-04-04 02:44:16 +00003962 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003963 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003964 return CMD_SUCCESS;
3965
3966 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003967 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003968
3969 /* Show all LSA. */
3970 if (argc == 0)
3971 {
paul020709f2003-04-04 02:44:16 +00003972 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003973 return CMD_SUCCESS;
3974 }
3975
3976 /* Set database type to show. */
3977 if (strncmp (argv[0], "r", 1) == 0)
3978 type = OSPF_ROUTER_LSA;
3979 else if (strncmp (argv[0], "ne", 2) == 0)
3980 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003981 else if (strncmp (argv[0], "ns", 2) == 0)
3982 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003983 else if (strncmp (argv[0], "su", 2) == 0)
3984 type = OSPF_SUMMARY_LSA;
3985 else if (strncmp (argv[0], "a", 1) == 0)
3986 type = OSPF_ASBR_SUMMARY_LSA;
3987 else if (strncmp (argv[0], "e", 1) == 0)
3988 type = OSPF_AS_EXTERNAL_LSA;
3989 else if (strncmp (argv[0], "se", 2) == 0)
3990 {
paul020709f2003-04-04 02:44:16 +00003991 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003992 return CMD_SUCCESS;
3993 }
3994 else if (strncmp (argv[0], "m", 1) == 0)
3995 {
paul020709f2003-04-04 02:44:16 +00003996 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003997 return CMD_SUCCESS;
3998 }
3999#ifdef HAVE_OPAQUE_LSA
4000 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4001 type = OSPF_OPAQUE_LINK_LSA;
4002 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4003 type = OSPF_OPAQUE_AREA_LSA;
4004 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4005 type = OSPF_OPAQUE_AS_LSA;
4006#endif /* HAVE_OPAQUE_LSA */
4007 else
4008 return CMD_WARNING;
4009
4010 /* `show ip ospf database LSA'. */
4011 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004012 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004013 else if (argc >= 2)
4014 {
4015 ret = inet_aton (argv[1], &id);
4016 if (!ret)
4017 return CMD_WARNING;
4018
4019 /* `show ip ospf database LSA ID'. */
4020 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004021 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004022 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4023 else if (argc == 3)
4024 {
4025 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004026 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004027 else
4028 {
4029 ret = inet_aton (argv[2], &adv_router);
4030 if (!ret)
4031 return CMD_WARNING;
4032 }
paul020709f2003-04-04 02:44:16 +00004033 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004034 }
4035 }
4036
4037 return CMD_SUCCESS;
4038}
4039
4040ALIAS (show_ip_ospf_database,
4041 show_ip_ospf_database_type_cmd,
4042 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4043 SHOW_STR
4044 IP_STR
4045 "OSPF information\n"
4046 "Database summary\n"
4047 OSPF_LSA_TYPES_DESC
4048 "LSAs in MaxAge list\n"
4049 "Self-originated link states\n")
4050
4051ALIAS (show_ip_ospf_database,
4052 show_ip_ospf_database_type_id_cmd,
4053 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4054 SHOW_STR
4055 IP_STR
4056 "OSPF information\n"
4057 "Database summary\n"
4058 OSPF_LSA_TYPES_DESC
4059 "Link State ID (as an IP address)\n")
4060
4061ALIAS (show_ip_ospf_database,
4062 show_ip_ospf_database_type_id_adv_router_cmd,
4063 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4064 SHOW_STR
4065 IP_STR
4066 "OSPF information\n"
4067 "Database summary\n"
4068 OSPF_LSA_TYPES_DESC
4069 "Link State ID (as an IP address)\n"
4070 "Advertising Router link states\n"
4071 "Advertising Router (as an IP address)\n")
4072
4073ALIAS (show_ip_ospf_database,
4074 show_ip_ospf_database_type_id_self_cmd,
4075 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4076 SHOW_STR
4077 IP_STR
4078 "OSPF information\n"
4079 "Database summary\n"
4080 OSPF_LSA_TYPES_DESC
4081 "Link State ID (as an IP address)\n"
4082 "Self-originated link states\n"
4083 "\n")
4084
4085DEFUN (show_ip_ospf_database_type_adv_router,
4086 show_ip_ospf_database_type_adv_router_cmd,
4087 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4088 SHOW_STR
4089 IP_STR
4090 "OSPF information\n"
4091 "Database summary\n"
4092 OSPF_LSA_TYPES_DESC
4093 "Advertising Router link states\n"
4094 "Advertising Router (as an IP address)\n")
4095{
paul020709f2003-04-04 02:44:16 +00004096 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004097 int type, ret;
4098 struct in_addr adv_router;
4099
paul020709f2003-04-04 02:44:16 +00004100 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004101 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00004102 return CMD_SUCCESS;
4103
4104 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004105 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004106
4107 if (argc != 2)
4108 return CMD_WARNING;
4109
4110 /* Set database type to show. */
4111 if (strncmp (argv[0], "r", 1) == 0)
4112 type = OSPF_ROUTER_LSA;
4113 else if (strncmp (argv[0], "ne", 2) == 0)
4114 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004115 else if (strncmp (argv[0], "ns", 2) == 0)
4116 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004117 else if (strncmp (argv[0], "s", 1) == 0)
4118 type = OSPF_SUMMARY_LSA;
4119 else if (strncmp (argv[0], "a", 1) == 0)
4120 type = OSPF_ASBR_SUMMARY_LSA;
4121 else if (strncmp (argv[0], "e", 1) == 0)
4122 type = OSPF_AS_EXTERNAL_LSA;
4123#ifdef HAVE_OPAQUE_LSA
4124 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4125 type = OSPF_OPAQUE_LINK_LSA;
4126 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4127 type = OSPF_OPAQUE_AREA_LSA;
4128 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4129 type = OSPF_OPAQUE_AS_LSA;
4130#endif /* HAVE_OPAQUE_LSA */
4131 else
4132 return CMD_WARNING;
4133
4134 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4135 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004136 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004137 else
4138 {
4139 ret = inet_aton (argv[1], &adv_router);
4140 if (!ret)
4141 return CMD_WARNING;
4142 }
4143
paul020709f2003-04-04 02:44:16 +00004144 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004145
4146 return CMD_SUCCESS;
4147}
4148
4149ALIAS (show_ip_ospf_database_type_adv_router,
4150 show_ip_ospf_database_type_self_cmd,
4151 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4152 SHOW_STR
4153 IP_STR
4154 "OSPF information\n"
4155 "Database summary\n"
4156 OSPF_LSA_TYPES_DESC
4157 "Self-originated link states\n")
4158
4159
4160DEFUN (ip_ospf_authentication_args,
4161 ip_ospf_authentication_args_addr_cmd,
4162 "ip ospf authentication (null|message-digest) A.B.C.D",
4163 "IP Information\n"
4164 "OSPF interface commands\n"
4165 "Enable authentication on this interface\n"
4166 "Use null authentication\n"
4167 "Use message-digest authentication\n"
4168 "Address of interface")
4169{
4170 struct interface *ifp;
4171 struct in_addr addr;
4172 int ret;
4173 struct ospf_if_params *params;
4174
4175 ifp = vty->index;
4176 params = IF_DEF_PARAMS (ifp);
4177
4178 if (argc == 2)
4179 {
4180 ret = inet_aton(argv[1], &addr);
4181 if (!ret)
4182 {
4183 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4184 VTY_NEWLINE);
4185 return CMD_WARNING;
4186 }
4187
4188 params = ospf_get_if_params (ifp, addr);
4189 ospf_if_update_params (ifp, addr);
4190 }
4191
4192 /* Handle null authentication */
4193 if ( argv[0][0] == 'n' )
4194 {
4195 SET_IF_PARAM (params, auth_type);
4196 params->auth_type = OSPF_AUTH_NULL;
4197 return CMD_SUCCESS;
4198 }
4199
4200 /* Handle message-digest authentication */
4201 if ( argv[0][0] == 'm' )
4202 {
4203 SET_IF_PARAM (params, auth_type);
4204 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4205 return CMD_SUCCESS;
4206 }
4207
4208 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4209 return CMD_WARNING;
4210}
4211
4212ALIAS (ip_ospf_authentication_args,
4213 ip_ospf_authentication_args_cmd,
4214 "ip ospf authentication (null|message-digest)",
4215 "IP Information\n"
4216 "OSPF interface commands\n"
4217 "Enable authentication on this interface\n"
4218 "Use null authentication\n"
4219 "Use message-digest authentication\n")
4220
4221DEFUN (ip_ospf_authentication,
4222 ip_ospf_authentication_addr_cmd,
4223 "ip ospf authentication A.B.C.D",
4224 "IP Information\n"
4225 "OSPF interface commands\n"
4226 "Enable authentication on this interface\n"
4227 "Address of interface")
4228{
4229 struct interface *ifp;
4230 struct in_addr addr;
4231 int ret;
4232 struct ospf_if_params *params;
4233
4234 ifp = vty->index;
4235 params = IF_DEF_PARAMS (ifp);
4236
4237 if (argc == 1)
4238 {
4239 ret = inet_aton(argv[1], &addr);
4240 if (!ret)
4241 {
4242 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4243 VTY_NEWLINE);
4244 return CMD_WARNING;
4245 }
4246
4247 params = ospf_get_if_params (ifp, addr);
4248 ospf_if_update_params (ifp, addr);
4249 }
4250
4251 SET_IF_PARAM (params, auth_type);
4252 params->auth_type = OSPF_AUTH_SIMPLE;
4253
4254 return CMD_SUCCESS;
4255}
4256
4257ALIAS (ip_ospf_authentication,
4258 ip_ospf_authentication_cmd,
4259 "ip ospf authentication",
4260 "IP Information\n"
4261 "OSPF interface commands\n"
4262 "Enable authentication on this interface\n")
4263
4264DEFUN (no_ip_ospf_authentication,
4265 no_ip_ospf_authentication_addr_cmd,
4266 "no ip ospf authentication A.B.C.D",
4267 NO_STR
4268 "IP Information\n"
4269 "OSPF interface commands\n"
4270 "Enable authentication on this interface\n"
4271 "Address of interface")
4272{
4273 struct interface *ifp;
4274 struct in_addr addr;
4275 int ret;
4276 struct ospf_if_params *params;
4277
4278 ifp = vty->index;
4279 params = IF_DEF_PARAMS (ifp);
4280
4281 if (argc == 1)
4282 {
4283 ret = inet_aton(argv[1], &addr);
4284 if (!ret)
4285 {
4286 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4287 VTY_NEWLINE);
4288 return CMD_WARNING;
4289 }
4290
4291 params = ospf_lookup_if_params (ifp, addr);
4292 if (params == NULL)
4293 return CMD_SUCCESS;
4294 }
4295
4296 params->auth_type = OSPF_AUTH_NOTSET;
4297 UNSET_IF_PARAM (params, auth_type);
4298
4299 if (params != IF_DEF_PARAMS (ifp))
4300 {
4301 ospf_free_if_params (ifp, addr);
4302 ospf_if_update_params (ifp, addr);
4303 }
4304
4305 return CMD_SUCCESS;
4306}
4307
4308ALIAS (no_ip_ospf_authentication,
4309 no_ip_ospf_authentication_cmd,
4310 "no ip ospf authentication",
4311 NO_STR
4312 "IP Information\n"
4313 "OSPF interface commands\n"
4314 "Enable authentication on this interface\n")
4315
4316DEFUN (ip_ospf_authentication_key,
4317 ip_ospf_authentication_key_addr_cmd,
4318 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4319 "IP Information\n"
4320 "OSPF interface commands\n"
4321 "Authentication password (key)\n"
4322 "The OSPF password (key)\n"
4323 "Address of interface")
4324{
4325 struct interface *ifp;
4326 struct in_addr addr;
4327 int ret;
4328 struct ospf_if_params *params;
4329
4330 ifp = vty->index;
4331 params = IF_DEF_PARAMS (ifp);
4332
4333 if (argc == 2)
4334 {
4335 ret = inet_aton(argv[1], &addr);
4336 if (!ret)
4337 {
4338 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4339 VTY_NEWLINE);
4340 return CMD_WARNING;
4341 }
4342
4343 params = ospf_get_if_params (ifp, addr);
4344 ospf_if_update_params (ifp, addr);
4345 }
4346
4347
4348 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004349 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004350 SET_IF_PARAM (params, auth_simple);
4351
4352 return CMD_SUCCESS;
4353}
4354
4355ALIAS (ip_ospf_authentication_key,
4356 ip_ospf_authentication_key_cmd,
4357 "ip ospf authentication-key AUTH_KEY",
4358 "IP Information\n"
4359 "OSPF interface commands\n"
4360 "Authentication password (key)\n"
4361 "The OSPF password (key)")
4362
4363ALIAS (ip_ospf_authentication_key,
4364 ospf_authentication_key_cmd,
4365 "ospf authentication-key AUTH_KEY",
4366 "OSPF interface commands\n"
4367 "Authentication password (key)\n"
4368 "The OSPF password (key)")
4369
4370DEFUN (no_ip_ospf_authentication_key,
4371 no_ip_ospf_authentication_key_addr_cmd,
4372 "no ip ospf authentication-key A.B.C.D",
4373 NO_STR
4374 "IP Information\n"
4375 "OSPF interface commands\n"
4376 "Authentication password (key)\n"
4377 "Address of interface")
4378{
4379 struct interface *ifp;
4380 struct in_addr addr;
4381 int ret;
4382 struct ospf_if_params *params;
4383
4384 ifp = vty->index;
4385 params = IF_DEF_PARAMS (ifp);
4386
4387 if (argc == 2)
4388 {
4389 ret = inet_aton(argv[1], &addr);
4390 if (!ret)
4391 {
4392 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4393 VTY_NEWLINE);
4394 return CMD_WARNING;
4395 }
4396
4397 params = ospf_lookup_if_params (ifp, addr);
4398 if (params == NULL)
4399 return CMD_SUCCESS;
4400 }
4401
4402 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4403 UNSET_IF_PARAM (params, auth_simple);
4404
4405 if (params != IF_DEF_PARAMS (ifp))
4406 {
4407 ospf_free_if_params (ifp, addr);
4408 ospf_if_update_params (ifp, addr);
4409 }
4410
4411 return CMD_SUCCESS;
4412}
4413
4414ALIAS (no_ip_ospf_authentication_key,
4415 no_ip_ospf_authentication_key_cmd,
4416 "no ip ospf authentication-key",
4417 NO_STR
4418 "IP Information\n"
4419 "OSPF interface commands\n"
4420 "Authentication password (key)\n")
4421
4422ALIAS (no_ip_ospf_authentication_key,
4423 no_ospf_authentication_key_cmd,
4424 "no ospf authentication-key",
4425 NO_STR
4426 "OSPF interface commands\n"
4427 "Authentication password (key)\n")
4428
4429DEFUN (ip_ospf_message_digest_key,
4430 ip_ospf_message_digest_key_addr_cmd,
4431 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4432 "IP Information\n"
4433 "OSPF interface commands\n"
4434 "Message digest authentication password (key)\n"
4435 "Key ID\n"
4436 "Use MD5 algorithm\n"
4437 "The OSPF password (key)"
4438 "Address of interface")
4439{
4440 struct interface *ifp;
4441 struct crypt_key *ck;
4442 u_char key_id;
4443 struct in_addr addr;
4444 int ret;
4445 struct ospf_if_params *params;
4446
4447 ifp = vty->index;
4448 params = IF_DEF_PARAMS (ifp);
4449
4450 if (argc == 3)
4451 {
4452 ret = inet_aton(argv[2], &addr);
4453 if (!ret)
4454 {
4455 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4456 VTY_NEWLINE);
4457 return CMD_WARNING;
4458 }
4459
4460 params = ospf_get_if_params (ifp, addr);
4461 ospf_if_update_params (ifp, addr);
4462 }
4463
4464 key_id = strtol (argv[0], NULL, 10);
4465 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4466 {
4467 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4468 return CMD_WARNING;
4469 }
4470
4471 ck = ospf_crypt_key_new ();
4472 ck->key_id = (u_char) key_id;
4473 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004474 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004475
4476 ospf_crypt_key_add (params->auth_crypt, ck);
4477 SET_IF_PARAM (params, auth_crypt);
4478
4479 return CMD_SUCCESS;
4480}
4481
4482ALIAS (ip_ospf_message_digest_key,
4483 ip_ospf_message_digest_key_cmd,
4484 "ip ospf message-digest-key <1-255> md5 KEY",
4485 "IP Information\n"
4486 "OSPF interface commands\n"
4487 "Message digest authentication password (key)\n"
4488 "Key ID\n"
4489 "Use MD5 algorithm\n"
4490 "The OSPF password (key)")
4491
4492ALIAS (ip_ospf_message_digest_key,
4493 ospf_message_digest_key_cmd,
4494 "ospf message-digest-key <1-255> md5 KEY",
4495 "OSPF interface commands\n"
4496 "Message digest authentication password (key)\n"
4497 "Key ID\n"
4498 "Use MD5 algorithm\n"
4499 "The OSPF password (key)")
4500
4501DEFUN (no_ip_ospf_message_digest_key,
4502 no_ip_ospf_message_digest_key_addr_cmd,
4503 "no ip ospf message-digest-key <1-255> A.B.C.D",
4504 NO_STR
4505 "IP Information\n"
4506 "OSPF interface commands\n"
4507 "Message digest authentication password (key)\n"
4508 "Key ID\n"
4509 "Address of interface")
4510{
4511 struct interface *ifp;
4512 struct crypt_key *ck;
4513 int key_id;
4514 struct in_addr addr;
4515 int ret;
4516 struct ospf_if_params *params;
4517
4518 ifp = vty->index;
4519 params = IF_DEF_PARAMS (ifp);
4520
4521 if (argc == 2)
4522 {
4523 ret = inet_aton(argv[1], &addr);
4524 if (!ret)
4525 {
4526 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4527 VTY_NEWLINE);
4528 return CMD_WARNING;
4529 }
4530
4531 params = ospf_lookup_if_params (ifp, addr);
4532 if (params == NULL)
4533 return CMD_SUCCESS;
4534 }
4535
4536 key_id = strtol (argv[0], NULL, 10);
4537 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4538 if (ck == NULL)
4539 {
4540 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4541 return CMD_WARNING;
4542 }
4543
4544 ospf_crypt_key_delete (params->auth_crypt, key_id);
4545
4546 if (params != IF_DEF_PARAMS (ifp))
4547 {
4548 ospf_free_if_params (ifp, addr);
4549 ospf_if_update_params (ifp, addr);
4550 }
4551
4552 return CMD_SUCCESS;
4553}
4554
4555ALIAS (no_ip_ospf_message_digest_key,
4556 no_ip_ospf_message_digest_key_cmd,
4557 "no ip ospf message-digest-key <1-255>",
4558 NO_STR
4559 "IP Information\n"
4560 "OSPF interface commands\n"
4561 "Message digest authentication password (key)\n"
4562 "Key ID\n")
4563
4564ALIAS (no_ip_ospf_message_digest_key,
4565 no_ospf_message_digest_key_cmd,
4566 "no ospf message-digest-key <1-255>",
4567 NO_STR
4568 "OSPF interface commands\n"
4569 "Message digest authentication password (key)\n"
4570 "Key ID\n")
4571
4572DEFUN (ip_ospf_cost,
4573 ip_ospf_cost_addr_cmd,
4574 "ip ospf cost <1-65535> A.B.C.D",
4575 "IP Information\n"
4576 "OSPF interface commands\n"
4577 "Interface cost\n"
4578 "Cost\n"
4579 "Address of interface")
4580{
4581 struct interface *ifp = vty->index;
4582 u_int32_t cost;
4583 struct in_addr addr;
4584 int ret;
4585 struct ospf_if_params *params;
4586
4587 params = IF_DEF_PARAMS (ifp);
4588
4589 cost = strtol (argv[0], NULL, 10);
4590
4591 /* cost range is <1-65535>. */
4592 if (cost < 1 || cost > 65535)
4593 {
4594 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4595 return CMD_WARNING;
4596 }
4597
4598 if (argc == 2)
4599 {
4600 ret = inet_aton(argv[1], &addr);
4601 if (!ret)
4602 {
4603 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4604 VTY_NEWLINE);
4605 return CMD_WARNING;
4606 }
4607
4608 params = ospf_get_if_params (ifp, addr);
4609 ospf_if_update_params (ifp, addr);
4610 }
4611
4612 SET_IF_PARAM (params, output_cost_cmd);
4613 params->output_cost_cmd = cost;
4614
4615 ospf_if_recalculate_output_cost (ifp);
4616
4617 return CMD_SUCCESS;
4618}
4619
4620ALIAS (ip_ospf_cost,
4621 ip_ospf_cost_cmd,
4622 "ip ospf cost <1-65535>",
4623 "IP Information\n"
4624 "OSPF interface commands\n"
4625 "Interface cost\n"
4626 "Cost")
4627
4628ALIAS (ip_ospf_cost,
4629 ospf_cost_cmd,
4630 "ospf cost <1-65535>",
4631 "OSPF interface commands\n"
4632 "Interface cost\n"
4633 "Cost")
4634
4635DEFUN (no_ip_ospf_cost,
4636 no_ip_ospf_cost_addr_cmd,
4637 "no ip ospf cost A.B.C.D",
4638 NO_STR
4639 "IP Information\n"
4640 "OSPF interface commands\n"
4641 "Interface cost\n"
4642 "Address of interface")
4643{
4644 struct interface *ifp = vty->index;
4645 struct in_addr addr;
4646 int ret;
4647 struct ospf_if_params *params;
4648
4649 ifp = vty->index;
4650 params = IF_DEF_PARAMS (ifp);
4651
4652 if (argc == 1)
4653 {
4654 ret = inet_aton(argv[0], &addr);
4655 if (!ret)
4656 {
4657 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4658 VTY_NEWLINE);
4659 return CMD_WARNING;
4660 }
4661
4662 params = ospf_lookup_if_params (ifp, addr);
4663 if (params == NULL)
4664 return CMD_SUCCESS;
4665 }
4666
4667 UNSET_IF_PARAM (params, output_cost_cmd);
4668
4669 if (params != IF_DEF_PARAMS (ifp))
4670 {
4671 ospf_free_if_params (ifp, addr);
4672 ospf_if_update_params (ifp, addr);
4673 }
4674
4675 ospf_if_recalculate_output_cost (ifp);
4676
4677 return CMD_SUCCESS;
4678}
4679
4680ALIAS (no_ip_ospf_cost,
4681 no_ip_ospf_cost_cmd,
4682 "no ip ospf cost",
4683 NO_STR
4684 "IP Information\n"
4685 "OSPF interface commands\n"
4686 "Interface cost\n")
4687
4688ALIAS (no_ip_ospf_cost,
4689 no_ospf_cost_cmd,
4690 "no ospf cost",
4691 NO_STR
4692 "OSPF interface commands\n"
4693 "Interface cost\n")
4694
paul4dadc292005-05-06 21:37:42 +00004695static void
paul718e3742002-12-13 20:15:29 +00004696ospf_nbr_timer_update (struct ospf_interface *oi)
4697{
4698 struct route_node *rn;
4699 struct ospf_neighbor *nbr;
4700
4701 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4702 if ((nbr = rn->info))
4703 {
4704 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4705 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4706 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4707 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4708 }
4709}
4710
paulf9ad9372005-10-21 00:45:17 +00004711static int
4712ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4713 const char *nbr_str,
4714 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004715{
4716 struct interface *ifp = vty->index;
4717 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004718 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004719 struct in_addr addr;
4720 int ret;
4721 struct ospf_if_params *params;
4722 struct ospf_interface *oi;
4723 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004724 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004725
paul020709f2003-04-04 02:44:16 +00004726 ospf = ospf_lookup ();
4727
paul718e3742002-12-13 20:15:29 +00004728 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004729
4730 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004731 {
paulf9ad9372005-10-21 00:45:17 +00004732 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004733 if (!ret)
4734 {
4735 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4736 VTY_NEWLINE);
4737 return CMD_WARNING;
4738 }
4739
4740 params = ospf_get_if_params (ifp, addr);
4741 ospf_if_update_params (ifp, addr);
4742 }
4743
paulf9ad9372005-10-21 00:45:17 +00004744 if (interval_str)
4745 {
4746 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4747 1, 65535);
4748
4749 /* reset fast_hello too, just to be sure */
4750 UNSET_IF_PARAM (params, fast_hello);
4751 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4752 }
4753 else if (fast_hello_str)
4754 {
4755 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4756 1, 10);
4757 /* 1s dead-interval with sub-second hellos desired */
4758 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4759 SET_IF_PARAM (params, fast_hello);
4760 params->fast_hello = hellomult;
4761 }
4762 else
4763 {
4764 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4765 VTY_NEWLINE);
4766 return CMD_WARNING;
4767 }
4768
paul718e3742002-12-13 20:15:29 +00004769 SET_IF_PARAM (params, v_wait);
4770 params->v_wait = seconds;
4771
4772 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00004773 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004774 {
paul68980082003-03-25 05:07:42 +00004775 if (ospf)
4776 {
4777 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4778 if (oi)
4779 ospf_nbr_timer_update (oi);
4780 }
paul718e3742002-12-13 20:15:29 +00004781 }
4782 else
4783 {
4784 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4785 if ((oi = rn->info))
4786 ospf_nbr_timer_update (oi);
4787 }
4788
4789 return CMD_SUCCESS;
4790}
4791
paulf9ad9372005-10-21 00:45:17 +00004792
4793DEFUN (ip_ospf_dead_interval,
4794 ip_ospf_dead_interval_addr_cmd,
4795 "ip ospf dead-interval <1-65535> A.B.C.D",
4796 "IP Information\n"
4797 "OSPF interface commands\n"
4798 "Interval after which a neighbor is declared dead\n"
4799 "Seconds\n"
4800 "Address of interface\n")
4801{
4802 if (argc == 2)
4803 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4804 else
4805 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4806}
4807
paul718e3742002-12-13 20:15:29 +00004808ALIAS (ip_ospf_dead_interval,
4809 ip_ospf_dead_interval_cmd,
4810 "ip ospf dead-interval <1-65535>",
4811 "IP Information\n"
4812 "OSPF interface commands\n"
4813 "Interval after which a neighbor is declared dead\n"
4814 "Seconds\n")
4815
4816ALIAS (ip_ospf_dead_interval,
4817 ospf_dead_interval_cmd,
4818 "ospf dead-interval <1-65535>",
4819 "OSPF interface commands\n"
4820 "Interval after which a neighbor is declared dead\n"
4821 "Seconds\n")
4822
paulf9ad9372005-10-21 00:45:17 +00004823DEFUN (ip_ospf_dead_interval_minimal,
4824 ip_ospf_dead_interval_minimal_addr_cmd,
4825 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4826 "IP Information\n"
4827 "OSPF interface commands\n"
4828 "Interval after which a neighbor is declared dead\n"
4829 "Minimal 1s dead-interval with fast sub-second hellos\n"
4830 "Hello multiplier factor\n"
4831 "Number of Hellos to send each second\n"
4832 "Address of interface\n")
4833{
4834 if (argc == 2)
4835 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4836 else
4837 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4838}
4839
4840ALIAS (ip_ospf_dead_interval_minimal,
4841 ip_ospf_dead_interval_minimal_cmd,
4842 "ip ospf dead-interval minimal hello-multiplier <1-10>",
4843 "IP Information\n"
4844 "OSPF interface commands\n"
4845 "Interval after which a neighbor is declared dead\n"
4846 "Minimal 1s dead-interval with fast sub-second hellos\n"
4847 "Hello multiplier factor\n"
4848 "Number of Hellos to send each second\n")
4849
paul718e3742002-12-13 20:15:29 +00004850DEFUN (no_ip_ospf_dead_interval,
4851 no_ip_ospf_dead_interval_addr_cmd,
4852 "no ip ospf dead-interval A.B.C.D",
4853 NO_STR
4854 "IP Information\n"
4855 "OSPF interface commands\n"
4856 "Interval after which a neighbor is declared dead\n"
4857 "Address of interface")
4858{
4859 struct interface *ifp = vty->index;
4860 struct in_addr addr;
4861 int ret;
4862 struct ospf_if_params *params;
4863 struct ospf_interface *oi;
4864 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004865 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004866
paul020709f2003-04-04 02:44:16 +00004867 ospf = ospf_lookup ();
4868
paul718e3742002-12-13 20:15:29 +00004869 ifp = vty->index;
4870 params = IF_DEF_PARAMS (ifp);
4871
4872 if (argc == 1)
4873 {
4874 ret = inet_aton(argv[0], &addr);
4875 if (!ret)
4876 {
4877 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4878 VTY_NEWLINE);
4879 return CMD_WARNING;
4880 }
4881
4882 params = ospf_lookup_if_params (ifp, addr);
4883 if (params == NULL)
4884 return CMD_SUCCESS;
4885 }
4886
4887 UNSET_IF_PARAM (params, v_wait);
4888 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00004889
4890 UNSET_IF_PARAM (params, fast_hello);
4891 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4892
paul718e3742002-12-13 20:15:29 +00004893 if (params != IF_DEF_PARAMS (ifp))
4894 {
4895 ospf_free_if_params (ifp, addr);
4896 ospf_if_update_params (ifp, addr);
4897 }
4898
4899 /* Update timer values in neighbor structure. */
4900 if (argc == 1)
4901 {
paul68980082003-03-25 05:07:42 +00004902 if (ospf)
4903 {
4904 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4905 if (oi)
4906 ospf_nbr_timer_update (oi);
4907 }
paul718e3742002-12-13 20:15:29 +00004908 }
4909 else
4910 {
4911 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4912 if ((oi = rn->info))
4913 ospf_nbr_timer_update (oi);
4914 }
4915
4916 return CMD_SUCCESS;
4917}
4918
4919ALIAS (no_ip_ospf_dead_interval,
4920 no_ip_ospf_dead_interval_cmd,
4921 "no ip ospf dead-interval",
4922 NO_STR
4923 "IP Information\n"
4924 "OSPF interface commands\n"
4925 "Interval after which a neighbor is declared dead\n")
4926
4927ALIAS (no_ip_ospf_dead_interval,
4928 no_ospf_dead_interval_cmd,
4929 "no ospf dead-interval",
4930 NO_STR
4931 "OSPF interface commands\n"
4932 "Interval after which a neighbor is declared dead\n")
4933
4934DEFUN (ip_ospf_hello_interval,
4935 ip_ospf_hello_interval_addr_cmd,
4936 "ip ospf hello-interval <1-65535> A.B.C.D",
4937 "IP Information\n"
4938 "OSPF interface commands\n"
4939 "Time between HELLO packets\n"
4940 "Seconds\n"
4941 "Address of interface")
4942{
4943 struct interface *ifp = vty->index;
4944 u_int32_t seconds;
4945 struct in_addr addr;
4946 int ret;
4947 struct ospf_if_params *params;
4948
4949 params = IF_DEF_PARAMS (ifp);
4950
4951 seconds = strtol (argv[0], NULL, 10);
4952
4953 /* HelloInterval range is <1-65535>. */
4954 if (seconds < 1 || seconds > 65535)
4955 {
4956 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4957 return CMD_WARNING;
4958 }
4959
4960 if (argc == 2)
4961 {
4962 ret = inet_aton(argv[1], &addr);
4963 if (!ret)
4964 {
4965 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4966 VTY_NEWLINE);
4967 return CMD_WARNING;
4968 }
4969
4970 params = ospf_get_if_params (ifp, addr);
4971 ospf_if_update_params (ifp, addr);
4972 }
4973
paulf9ad9372005-10-21 00:45:17 +00004974 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00004975 params->v_hello = seconds;
4976
4977 return CMD_SUCCESS;
4978}
4979
4980ALIAS (ip_ospf_hello_interval,
4981 ip_ospf_hello_interval_cmd,
4982 "ip ospf hello-interval <1-65535>",
4983 "IP Information\n"
4984 "OSPF interface commands\n"
4985 "Time between HELLO packets\n"
4986 "Seconds\n")
4987
4988ALIAS (ip_ospf_hello_interval,
4989 ospf_hello_interval_cmd,
4990 "ospf hello-interval <1-65535>",
4991 "OSPF interface commands\n"
4992 "Time between HELLO packets\n"
4993 "Seconds\n")
4994
4995DEFUN (no_ip_ospf_hello_interval,
4996 no_ip_ospf_hello_interval_addr_cmd,
4997 "no ip ospf hello-interval A.B.C.D",
4998 NO_STR
4999 "IP Information\n"
5000 "OSPF interface commands\n"
5001 "Time between HELLO packets\n"
5002 "Address of interface")
5003{
5004 struct interface *ifp = vty->index;
5005 struct in_addr addr;
5006 int ret;
5007 struct ospf_if_params *params;
5008
5009 ifp = vty->index;
5010 params = IF_DEF_PARAMS (ifp);
5011
5012 if (argc == 1)
5013 {
5014 ret = inet_aton(argv[0], &addr);
5015 if (!ret)
5016 {
5017 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5018 VTY_NEWLINE);
5019 return CMD_WARNING;
5020 }
5021
5022 params = ospf_lookup_if_params (ifp, addr);
5023 if (params == NULL)
5024 return CMD_SUCCESS;
5025 }
5026
5027 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005028 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005029
5030 if (params != IF_DEF_PARAMS (ifp))
5031 {
5032 ospf_free_if_params (ifp, addr);
5033 ospf_if_update_params (ifp, addr);
5034 }
5035
5036 return CMD_SUCCESS;
5037}
5038
5039ALIAS (no_ip_ospf_hello_interval,
5040 no_ip_ospf_hello_interval_cmd,
5041 "no ip ospf hello-interval",
5042 NO_STR
5043 "IP Information\n"
5044 "OSPF interface commands\n"
5045 "Time between HELLO packets\n")
5046
5047ALIAS (no_ip_ospf_hello_interval,
5048 no_ospf_hello_interval_cmd,
5049 "no ospf hello-interval",
5050 NO_STR
5051 "OSPF interface commands\n"
5052 "Time between HELLO packets\n")
5053
5054DEFUN (ip_ospf_network,
5055 ip_ospf_network_cmd,
5056 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5057 "IP Information\n"
5058 "OSPF interface commands\n"
5059 "Network type\n"
5060 "Specify OSPF broadcast multi-access network\n"
5061 "Specify OSPF NBMA network\n"
5062 "Specify OSPF point-to-multipoint network\n"
5063 "Specify OSPF point-to-point network\n")
5064{
5065 struct interface *ifp = vty->index;
5066 int old_type = IF_DEF_PARAMS (ifp)->type;
5067 struct route_node *rn;
5068
5069 if (strncmp (argv[0], "b", 1) == 0)
5070 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5071 else if (strncmp (argv[0], "n", 1) == 0)
5072 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5073 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5074 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5075 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5076 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5077
5078 if (IF_DEF_PARAMS (ifp)->type == old_type)
5079 return CMD_SUCCESS;
5080
5081 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5082
5083 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5084 {
5085 struct ospf_interface *oi = rn->info;
5086
5087 if (!oi)
5088 continue;
5089
5090 oi->type = IF_DEF_PARAMS (ifp)->type;
5091
5092 if (oi->state > ISM_Down)
5093 {
5094 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5095 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5096 }
5097 }
5098
5099 return CMD_SUCCESS;
5100}
5101
5102ALIAS (ip_ospf_network,
5103 ospf_network_cmd,
5104 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5105 "OSPF interface commands\n"
5106 "Network type\n"
5107 "Specify OSPF broadcast multi-access network\n"
5108 "Specify OSPF NBMA network\n"
5109 "Specify OSPF point-to-multipoint network\n"
5110 "Specify OSPF point-to-point network\n")
5111
5112DEFUN (no_ip_ospf_network,
5113 no_ip_ospf_network_cmd,
5114 "no ip ospf network",
5115 NO_STR
5116 "IP Information\n"
5117 "OSPF interface commands\n"
5118 "Network type\n")
5119{
5120 struct interface *ifp = vty->index;
5121 int old_type = IF_DEF_PARAMS (ifp)->type;
5122 struct route_node *rn;
5123
ajsbc18d612004-12-15 15:07:19 +00005124 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005125
5126 if (IF_DEF_PARAMS (ifp)->type == old_type)
5127 return CMD_SUCCESS;
5128
5129 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5130 {
5131 struct ospf_interface *oi = rn->info;
5132
5133 if (!oi)
5134 continue;
5135
5136 oi->type = IF_DEF_PARAMS (ifp)->type;
5137
5138 if (oi->state > ISM_Down)
5139 {
5140 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5141 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5142 }
5143 }
5144
5145 return CMD_SUCCESS;
5146}
5147
5148ALIAS (no_ip_ospf_network,
5149 no_ospf_network_cmd,
5150 "no ospf network",
5151 NO_STR
5152 "OSPF interface commands\n"
5153 "Network type\n")
5154
5155DEFUN (ip_ospf_priority,
5156 ip_ospf_priority_addr_cmd,
5157 "ip ospf priority <0-255> A.B.C.D",
5158 "IP Information\n"
5159 "OSPF interface commands\n"
5160 "Router priority\n"
5161 "Priority\n"
5162 "Address of interface")
5163{
5164 struct interface *ifp = vty->index;
5165 u_int32_t priority;
5166 struct route_node *rn;
5167 struct in_addr addr;
5168 int ret;
5169 struct ospf_if_params *params;
5170
5171 params = IF_DEF_PARAMS (ifp);
5172
5173 priority = strtol (argv[0], NULL, 10);
5174
5175 /* Router Priority range is <0-255>. */
5176 if (priority < 0 || priority > 255)
5177 {
5178 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5179 return CMD_WARNING;
5180 }
5181
5182 if (argc == 2)
5183 {
5184 ret = inet_aton(argv[1], &addr);
5185 if (!ret)
5186 {
5187 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5188 VTY_NEWLINE);
5189 return CMD_WARNING;
5190 }
5191
5192 params = ospf_get_if_params (ifp, addr);
5193 ospf_if_update_params (ifp, addr);
5194 }
5195
5196 SET_IF_PARAM (params, priority);
5197 params->priority = priority;
5198
5199 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5200 {
5201 struct ospf_interface *oi = rn->info;
5202
5203 if (!oi)
5204 continue;
5205
5206
5207 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5208 {
5209 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5210 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5211 }
5212 }
5213
5214 return CMD_SUCCESS;
5215}
5216
5217ALIAS (ip_ospf_priority,
5218 ip_ospf_priority_cmd,
5219 "ip ospf priority <0-255>",
5220 "IP Information\n"
5221 "OSPF interface commands\n"
5222 "Router priority\n"
5223 "Priority\n")
5224
5225ALIAS (ip_ospf_priority,
5226 ospf_priority_cmd,
5227 "ospf priority <0-255>",
5228 "OSPF interface commands\n"
5229 "Router priority\n"
5230 "Priority\n")
5231
5232DEFUN (no_ip_ospf_priority,
5233 no_ip_ospf_priority_addr_cmd,
5234 "no ip ospf priority A.B.C.D",
5235 NO_STR
5236 "IP Information\n"
5237 "OSPF interface commands\n"
5238 "Router priority\n"
5239 "Address of interface")
5240{
5241 struct interface *ifp = vty->index;
5242 struct route_node *rn;
5243 struct in_addr addr;
5244 int ret;
5245 struct ospf_if_params *params;
5246
5247 ifp = vty->index;
5248 params = IF_DEF_PARAMS (ifp);
5249
5250 if (argc == 1)
5251 {
5252 ret = inet_aton(argv[0], &addr);
5253 if (!ret)
5254 {
5255 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5256 VTY_NEWLINE);
5257 return CMD_WARNING;
5258 }
5259
5260 params = ospf_lookup_if_params (ifp, addr);
5261 if (params == NULL)
5262 return CMD_SUCCESS;
5263 }
5264
5265 UNSET_IF_PARAM (params, priority);
5266 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5267
5268 if (params != IF_DEF_PARAMS (ifp))
5269 {
5270 ospf_free_if_params (ifp, addr);
5271 ospf_if_update_params (ifp, addr);
5272 }
5273
5274 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5275 {
5276 struct ospf_interface *oi = rn->info;
5277
5278 if (!oi)
5279 continue;
5280
5281
5282 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5283 {
5284 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5285 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5286 }
5287 }
5288
5289 return CMD_SUCCESS;
5290}
5291
5292ALIAS (no_ip_ospf_priority,
5293 no_ip_ospf_priority_cmd,
5294 "no ip ospf priority",
5295 NO_STR
5296 "IP Information\n"
5297 "OSPF interface commands\n"
5298 "Router priority\n")
5299
5300ALIAS (no_ip_ospf_priority,
5301 no_ospf_priority_cmd,
5302 "no ospf priority",
5303 NO_STR
5304 "OSPF interface commands\n"
5305 "Router priority\n")
5306
5307DEFUN (ip_ospf_retransmit_interval,
5308 ip_ospf_retransmit_interval_addr_cmd,
5309 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5310 "IP Information\n"
5311 "OSPF interface commands\n"
5312 "Time between retransmitting lost link state advertisements\n"
5313 "Seconds\n"
5314 "Address of interface")
5315{
5316 struct interface *ifp = vty->index;
5317 u_int32_t seconds;
5318 struct in_addr addr;
5319 int ret;
5320 struct ospf_if_params *params;
5321
5322 params = IF_DEF_PARAMS (ifp);
5323 seconds = strtol (argv[0], NULL, 10);
5324
5325 /* Retransmit Interval range is <3-65535>. */
5326 if (seconds < 3 || seconds > 65535)
5327 {
5328 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5329 return CMD_WARNING;
5330 }
5331
5332
5333 if (argc == 2)
5334 {
5335 ret = inet_aton(argv[1], &addr);
5336 if (!ret)
5337 {
5338 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5339 VTY_NEWLINE);
5340 return CMD_WARNING;
5341 }
5342
5343 params = ospf_get_if_params (ifp, addr);
5344 ospf_if_update_params (ifp, addr);
5345 }
5346
5347 SET_IF_PARAM (params, retransmit_interval);
5348 params->retransmit_interval = seconds;
5349
5350 return CMD_SUCCESS;
5351}
5352
5353ALIAS (ip_ospf_retransmit_interval,
5354 ip_ospf_retransmit_interval_cmd,
5355 "ip ospf retransmit-interval <3-65535>",
5356 "IP Information\n"
5357 "OSPF interface commands\n"
5358 "Time between retransmitting lost link state advertisements\n"
5359 "Seconds\n")
5360
5361ALIAS (ip_ospf_retransmit_interval,
5362 ospf_retransmit_interval_cmd,
5363 "ospf retransmit-interval <3-65535>",
5364 "OSPF interface commands\n"
5365 "Time between retransmitting lost link state advertisements\n"
5366 "Seconds\n")
5367
5368DEFUN (no_ip_ospf_retransmit_interval,
5369 no_ip_ospf_retransmit_interval_addr_cmd,
5370 "no ip ospf retransmit-interval A.B.C.D",
5371 NO_STR
5372 "IP Information\n"
5373 "OSPF interface commands\n"
5374 "Time between retransmitting lost link state advertisements\n"
5375 "Address of interface")
5376{
5377 struct interface *ifp = vty->index;
5378 struct in_addr addr;
5379 int ret;
5380 struct ospf_if_params *params;
5381
5382 ifp = vty->index;
5383 params = IF_DEF_PARAMS (ifp);
5384
5385 if (argc == 1)
5386 {
5387 ret = inet_aton(argv[0], &addr);
5388 if (!ret)
5389 {
5390 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5391 VTY_NEWLINE);
5392 return CMD_WARNING;
5393 }
5394
5395 params = ospf_lookup_if_params (ifp, addr);
5396 if (params == NULL)
5397 return CMD_SUCCESS;
5398 }
5399
5400 UNSET_IF_PARAM (params, retransmit_interval);
5401 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5402
5403 if (params != IF_DEF_PARAMS (ifp))
5404 {
5405 ospf_free_if_params (ifp, addr);
5406 ospf_if_update_params (ifp, addr);
5407 }
5408
5409 return CMD_SUCCESS;
5410}
5411
5412ALIAS (no_ip_ospf_retransmit_interval,
5413 no_ip_ospf_retransmit_interval_cmd,
5414 "no ip ospf retransmit-interval",
5415 NO_STR
5416 "IP Information\n"
5417 "OSPF interface commands\n"
5418 "Time between retransmitting lost link state advertisements\n")
5419
5420ALIAS (no_ip_ospf_retransmit_interval,
5421 no_ospf_retransmit_interval_cmd,
5422 "no ospf retransmit-interval",
5423 NO_STR
5424 "OSPF interface commands\n"
5425 "Time between retransmitting lost link state advertisements\n")
5426
5427DEFUN (ip_ospf_transmit_delay,
5428 ip_ospf_transmit_delay_addr_cmd,
5429 "ip ospf transmit-delay <1-65535> A.B.C.D",
5430 "IP Information\n"
5431 "OSPF interface commands\n"
5432 "Link state transmit delay\n"
5433 "Seconds\n"
5434 "Address of interface")
5435{
5436 struct interface *ifp = vty->index;
5437 u_int32_t seconds;
5438 struct in_addr addr;
5439 int ret;
5440 struct ospf_if_params *params;
5441
5442 params = IF_DEF_PARAMS (ifp);
5443 seconds = strtol (argv[0], NULL, 10);
5444
5445 /* Transmit Delay range is <1-65535>. */
5446 if (seconds < 1 || seconds > 65535)
5447 {
5448 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5449 return CMD_WARNING;
5450 }
5451
5452 if (argc == 2)
5453 {
5454 ret = inet_aton(argv[1], &addr);
5455 if (!ret)
5456 {
5457 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5458 VTY_NEWLINE);
5459 return CMD_WARNING;
5460 }
5461
5462 params = ospf_get_if_params (ifp, addr);
5463 ospf_if_update_params (ifp, addr);
5464 }
5465
5466 SET_IF_PARAM (params, transmit_delay);
5467 params->transmit_delay = seconds;
5468
5469 return CMD_SUCCESS;
5470}
5471
5472ALIAS (ip_ospf_transmit_delay,
5473 ip_ospf_transmit_delay_cmd,
5474 "ip ospf transmit-delay <1-65535>",
5475 "IP Information\n"
5476 "OSPF interface commands\n"
5477 "Link state transmit delay\n"
5478 "Seconds\n")
5479
5480ALIAS (ip_ospf_transmit_delay,
5481 ospf_transmit_delay_cmd,
5482 "ospf transmit-delay <1-65535>",
5483 "OSPF interface commands\n"
5484 "Link state transmit delay\n"
5485 "Seconds\n")
5486
5487DEFUN (no_ip_ospf_transmit_delay,
5488 no_ip_ospf_transmit_delay_addr_cmd,
5489 "no ip ospf transmit-delay A.B.C.D",
5490 NO_STR
5491 "IP Information\n"
5492 "OSPF interface commands\n"
5493 "Link state transmit delay\n"
5494 "Address of interface")
5495{
5496 struct interface *ifp = vty->index;
5497 struct in_addr addr;
5498 int ret;
5499 struct ospf_if_params *params;
5500
5501 ifp = vty->index;
5502 params = IF_DEF_PARAMS (ifp);
5503
5504 if (argc == 1)
5505 {
5506 ret = inet_aton(argv[0], &addr);
5507 if (!ret)
5508 {
5509 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5510 VTY_NEWLINE);
5511 return CMD_WARNING;
5512 }
5513
5514 params = ospf_lookup_if_params (ifp, addr);
5515 if (params == NULL)
5516 return CMD_SUCCESS;
5517 }
5518
5519 UNSET_IF_PARAM (params, transmit_delay);
5520 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5521
5522 if (params != IF_DEF_PARAMS (ifp))
5523 {
5524 ospf_free_if_params (ifp, addr);
5525 ospf_if_update_params (ifp, addr);
5526 }
5527
5528 return CMD_SUCCESS;
5529}
5530
5531ALIAS (no_ip_ospf_transmit_delay,
5532 no_ip_ospf_transmit_delay_cmd,
5533 "no ip ospf transmit-delay",
5534 NO_STR
5535 "IP Information\n"
5536 "OSPF interface commands\n"
5537 "Link state transmit delay\n")
5538
5539ALIAS (no_ip_ospf_transmit_delay,
5540 no_ospf_transmit_delay_cmd,
5541 "no ospf transmit-delay",
5542 NO_STR
5543 "OSPF interface commands\n"
5544 "Link state transmit delay\n")
5545
5546
5547DEFUN (ospf_redistribute_source_metric_type,
5548 ospf_redistribute_source_metric_type_routemap_cmd,
5549 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5550 "Redistribute information from another routing protocol\n"
5551 "Kernel routes\n"
5552 "Connected\n"
5553 "Static routes\n"
5554 "Routing Information Protocol (RIP)\n"
5555 "Border Gateway Protocol (BGP)\n"
5556 "Metric for redistributed routes\n"
5557 "OSPF default metric\n"
5558 "OSPF exterior metric type for redistributed routes\n"
5559 "Set OSPF External Type 1 metrics\n"
5560 "Set OSPF External Type 2 metrics\n"
5561 "Route map reference\n"
5562 "Pointer to route-map entries\n")
5563{
paul020709f2003-04-04 02:44:16 +00005564 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005565 int source;
5566 int type = -1;
5567 int metric = -1;
5568
5569 /* Get distribute source. */
5570 if (!str2distribute_source (argv[0], &source))
5571 return CMD_WARNING;
5572
5573 /* Get metric value. */
5574 if (argc >= 2)
5575 if (!str2metric (argv[1], &metric))
5576 return CMD_WARNING;
5577
5578 /* Get metric type. */
5579 if (argc >= 3)
5580 if (!str2metric_type (argv[2], &type))
5581 return CMD_WARNING;
5582
5583 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005584 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005585 else
paul020709f2003-04-04 02:44:16 +00005586 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005587
paul020709f2003-04-04 02:44:16 +00005588 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005589}
5590
5591ALIAS (ospf_redistribute_source_metric_type,
5592 ospf_redistribute_source_metric_type_cmd,
5593 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5594 "Redistribute information from another routing protocol\n"
5595 "Kernel routes\n"
5596 "Connected\n"
5597 "Static routes\n"
5598 "Routing Information Protocol (RIP)\n"
5599 "Border Gateway Protocol (BGP)\n"
5600 "Metric for redistributed routes\n"
5601 "OSPF default metric\n"
5602 "OSPF exterior metric type for redistributed routes\n"
5603 "Set OSPF External Type 1 metrics\n"
5604 "Set OSPF External Type 2 metrics\n")
5605
5606ALIAS (ospf_redistribute_source_metric_type,
5607 ospf_redistribute_source_metric_cmd,
5608 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5609 "Redistribute information from another routing protocol\n"
5610 "Kernel routes\n"
5611 "Connected\n"
5612 "Static routes\n"
5613 "Routing Information Protocol (RIP)\n"
5614 "Border Gateway Protocol (BGP)\n"
5615 "Metric for redistributed routes\n"
5616 "OSPF default metric\n")
5617
5618DEFUN (ospf_redistribute_source_type_metric,
5619 ospf_redistribute_source_type_metric_routemap_cmd,
5620 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5621 "Redistribute information from another routing protocol\n"
5622 "Kernel routes\n"
5623 "Connected\n"
5624 "Static routes\n"
5625 "Routing Information Protocol (RIP)\n"
5626 "Border Gateway Protocol (BGP)\n"
5627 "OSPF exterior metric type for redistributed routes\n"
5628 "Set OSPF External Type 1 metrics\n"
5629 "Set OSPF External Type 2 metrics\n"
5630 "Metric for redistributed routes\n"
5631 "OSPF default metric\n"
5632 "Route map reference\n"
5633 "Pointer to route-map entries\n")
5634{
paul020709f2003-04-04 02:44:16 +00005635 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005636 int source;
5637 int type = -1;
5638 int metric = -1;
5639
5640 /* Get distribute source. */
5641 if (!str2distribute_source (argv[0], &source))
5642 return CMD_WARNING;
5643
5644 /* Get metric value. */
5645 if (argc >= 2)
5646 if (!str2metric_type (argv[1], &type))
5647 return CMD_WARNING;
5648
5649 /* Get metric type. */
5650 if (argc >= 3)
5651 if (!str2metric (argv[2], &metric))
5652 return CMD_WARNING;
5653
5654 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005655 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005656 else
paul020709f2003-04-04 02:44:16 +00005657 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005658
paul020709f2003-04-04 02:44:16 +00005659 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005660}
5661
5662ALIAS (ospf_redistribute_source_type_metric,
5663 ospf_redistribute_source_type_metric_cmd,
5664 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5665 "Redistribute information from another routing protocol\n"
5666 "Kernel routes\n"
5667 "Connected\n"
5668 "Static routes\n"
5669 "Routing Information Protocol (RIP)\n"
5670 "Border Gateway Protocol (BGP)\n"
5671 "OSPF exterior metric type for redistributed routes\n"
5672 "Set OSPF External Type 1 metrics\n"
5673 "Set OSPF External Type 2 metrics\n"
5674 "Metric for redistributed routes\n"
5675 "OSPF default metric\n")
5676
5677ALIAS (ospf_redistribute_source_type_metric,
5678 ospf_redistribute_source_type_cmd,
5679 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5680 "Redistribute information from another routing protocol\n"
5681 "Kernel routes\n"
5682 "Connected\n"
5683 "Static routes\n"
5684 "Routing Information Protocol (RIP)\n"
5685 "Border Gateway Protocol (BGP)\n"
5686 "OSPF exterior metric type for redistributed routes\n"
5687 "Set OSPF External Type 1 metrics\n"
5688 "Set OSPF External Type 2 metrics\n")
5689
5690ALIAS (ospf_redistribute_source_type_metric,
5691 ospf_redistribute_source_cmd,
5692 "redistribute (kernel|connected|static|rip|bgp)",
5693 "Redistribute information from another routing protocol\n"
5694 "Kernel routes\n"
5695 "Connected\n"
5696 "Static routes\n"
5697 "Routing Information Protocol (RIP)\n"
5698 "Border Gateway Protocol (BGP)\n")
5699
5700DEFUN (ospf_redistribute_source_metric_routemap,
5701 ospf_redistribute_source_metric_routemap_cmd,
5702 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5703 "Redistribute information from another routing protocol\n"
5704 "Kernel routes\n"
5705 "Connected\n"
5706 "Static routes\n"
5707 "Routing Information Protocol (RIP)\n"
5708 "Border Gateway Protocol (BGP)\n"
5709 "Metric for redistributed routes\n"
5710 "OSPF default metric\n"
5711 "Route map reference\n"
5712 "Pointer to route-map entries\n")
5713{
paul020709f2003-04-04 02:44:16 +00005714 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005715 int source;
5716 int metric = -1;
5717
5718 /* Get distribute source. */
5719 if (!str2distribute_source (argv[0], &source))
5720 return CMD_WARNING;
5721
5722 /* Get metric value. */
5723 if (argc >= 2)
5724 if (!str2metric (argv[1], &metric))
5725 return CMD_WARNING;
5726
5727 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005728 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005729 else
paul020709f2003-04-04 02:44:16 +00005730 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005731
paul020709f2003-04-04 02:44:16 +00005732 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005733}
5734
5735DEFUN (ospf_redistribute_source_type_routemap,
5736 ospf_redistribute_source_type_routemap_cmd,
5737 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5738 "Redistribute information from another routing protocol\n"
5739 "Kernel routes\n"
5740 "Connected\n"
5741 "Static routes\n"
5742 "Routing Information Protocol (RIP)\n"
5743 "Border Gateway Protocol (BGP)\n"
5744 "OSPF exterior metric type for redistributed routes\n"
5745 "Set OSPF External Type 1 metrics\n"
5746 "Set OSPF External Type 2 metrics\n"
5747 "Route map reference\n"
5748 "Pointer to route-map entries\n")
5749{
paul020709f2003-04-04 02:44:16 +00005750 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005751 int source;
5752 int type = -1;
5753
5754 /* Get distribute source. */
5755 if (!str2distribute_source (argv[0], &source))
5756 return CMD_WARNING;
5757
5758 /* Get metric value. */
5759 if (argc >= 2)
5760 if (!str2metric_type (argv[1], &type))
5761 return CMD_WARNING;
5762
5763 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005764 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005765 else
paul020709f2003-04-04 02:44:16 +00005766 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005767
paul020709f2003-04-04 02:44:16 +00005768 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005769}
5770
5771DEFUN (ospf_redistribute_source_routemap,
5772 ospf_redistribute_source_routemap_cmd,
5773 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5774 "Redistribute information from another routing protocol\n"
5775 "Kernel routes\n"
5776 "Connected\n"
5777 "Static routes\n"
5778 "Routing Information Protocol (RIP)\n"
5779 "Border Gateway Protocol (BGP)\n"
5780 "Route map reference\n"
5781 "Pointer to route-map entries\n")
5782{
paul020709f2003-04-04 02:44:16 +00005783 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005784 int source;
5785
5786 /* Get distribute source. */
5787 if (!str2distribute_source (argv[0], &source))
5788 return CMD_WARNING;
5789
5790 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005791 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005792 else
paul020709f2003-04-04 02:44:16 +00005793 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005794
paul020709f2003-04-04 02:44:16 +00005795 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005796}
5797
5798DEFUN (no_ospf_redistribute_source,
5799 no_ospf_redistribute_source_cmd,
5800 "no redistribute (kernel|connected|static|rip|bgp)",
5801 NO_STR
5802 "Redistribute information from another routing protocol\n"
5803 "Kernel routes\n"
5804 "Connected\n"
5805 "Static routes\n"
5806 "Routing Information Protocol (RIP)\n"
5807 "Border Gateway Protocol (BGP)\n")
5808{
paul020709f2003-04-04 02:44:16 +00005809 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005810 int source;
5811
5812 if (!str2distribute_source (argv[0], &source))
5813 return CMD_WARNING;
5814
paul020709f2003-04-04 02:44:16 +00005815 ospf_routemap_unset (ospf, source);
5816 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005817}
5818
5819DEFUN (ospf_distribute_list_out,
5820 ospf_distribute_list_out_cmd,
5821 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5822 "Filter networks in routing updates\n"
5823 "Access-list name\n"
5824 OUT_STR
5825 "Kernel routes\n"
5826 "Connected\n"
5827 "Static routes\n"
5828 "Routing Information Protocol (RIP)\n"
5829 "Border Gateway Protocol (BGP)\n")
5830{
paul68980082003-03-25 05:07:42 +00005831 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005832 int source;
5833
5834 /* Get distribute source. */
5835 if (!str2distribute_source (argv[1], &source))
5836 return CMD_WARNING;
5837
paul68980082003-03-25 05:07:42 +00005838 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005839}
5840
5841DEFUN (no_ospf_distribute_list_out,
5842 no_ospf_distribute_list_out_cmd,
5843 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5844 NO_STR
5845 "Filter networks in routing updates\n"
5846 "Access-list name\n"
5847 OUT_STR
5848 "Kernel routes\n"
5849 "Connected\n"
5850 "Static routes\n"
5851 "Routing Information Protocol (RIP)\n"
5852 "Border Gateway Protocol (BGP)\n")
5853{
paul68980082003-03-25 05:07:42 +00005854 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005855 int source;
5856
5857 if (!str2distribute_source (argv[1], &source))
5858 return CMD_WARNING;
5859
paul68980082003-03-25 05:07:42 +00005860 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005861}
5862
5863/* Default information originate. */
5864DEFUN (ospf_default_information_originate_metric_type_routemap,
5865 ospf_default_information_originate_metric_type_routemap_cmd,
5866 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5867 "Control distribution of default information\n"
5868 "Distribute a default route\n"
5869 "OSPF default metric\n"
5870 "OSPF metric\n"
5871 "OSPF metric type for default routes\n"
5872 "Set OSPF External Type 1 metrics\n"
5873 "Set OSPF External Type 2 metrics\n"
5874 "Route map reference\n"
5875 "Pointer to route-map entries\n")
5876{
paul020709f2003-04-04 02:44:16 +00005877 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005878 int type = -1;
5879 int metric = -1;
5880
5881 /* Get metric value. */
5882 if (argc >= 1)
5883 if (!str2metric (argv[0], &metric))
5884 return CMD_WARNING;
5885
5886 /* Get metric type. */
5887 if (argc >= 2)
5888 if (!str2metric_type (argv[1], &type))
5889 return CMD_WARNING;
5890
5891 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005892 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005893 else
paul020709f2003-04-04 02:44:16 +00005894 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005895
paul020709f2003-04-04 02:44:16 +00005896 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5897 type, metric);
paul718e3742002-12-13 20:15:29 +00005898}
5899
5900ALIAS (ospf_default_information_originate_metric_type_routemap,
5901 ospf_default_information_originate_metric_type_cmd,
5902 "default-information originate metric <0-16777214> metric-type (1|2)",
5903 "Control distribution of default information\n"
5904 "Distribute a default route\n"
5905 "OSPF default metric\n"
5906 "OSPF metric\n"
5907 "OSPF metric type for default routes\n"
5908 "Set OSPF External Type 1 metrics\n"
5909 "Set OSPF External Type 2 metrics\n")
5910
5911ALIAS (ospf_default_information_originate_metric_type_routemap,
5912 ospf_default_information_originate_metric_cmd,
5913 "default-information originate metric <0-16777214>",
5914 "Control distribution of default information\n"
5915 "Distribute a default route\n"
5916 "OSPF default metric\n"
5917 "OSPF metric\n")
5918
5919ALIAS (ospf_default_information_originate_metric_type_routemap,
5920 ospf_default_information_originate_cmd,
5921 "default-information originate",
5922 "Control distribution of default information\n"
5923 "Distribute a default route\n")
5924
5925/* Default information originate. */
5926DEFUN (ospf_default_information_originate_metric_routemap,
5927 ospf_default_information_originate_metric_routemap_cmd,
5928 "default-information originate metric <0-16777214> route-map WORD",
5929 "Control distribution of default information\n"
5930 "Distribute a default route\n"
5931 "OSPF default metric\n"
5932 "OSPF metric\n"
5933 "Route map reference\n"
5934 "Pointer to route-map entries\n")
5935{
paul020709f2003-04-04 02:44:16 +00005936 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005937 int metric = -1;
5938
5939 /* Get metric value. */
5940 if (argc >= 1)
5941 if (!str2metric (argv[0], &metric))
5942 return CMD_WARNING;
5943
5944 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005945 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005946 else
paul020709f2003-04-04 02:44:16 +00005947 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005948
paul020709f2003-04-04 02:44:16 +00005949 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5950 -1, metric);
paul718e3742002-12-13 20:15:29 +00005951}
5952
5953/* Default information originate. */
5954DEFUN (ospf_default_information_originate_routemap,
5955 ospf_default_information_originate_routemap_cmd,
5956 "default-information originate route-map WORD",
5957 "Control distribution of default information\n"
5958 "Distribute a default route\n"
5959 "Route map reference\n"
5960 "Pointer to route-map entries\n")
5961{
paul020709f2003-04-04 02:44:16 +00005962 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005963
paul020709f2003-04-04 02:44:16 +00005964 if (argc == 1)
5965 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5966 else
5967 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5968
5969 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005970}
5971
5972DEFUN (ospf_default_information_originate_type_metric_routemap,
5973 ospf_default_information_originate_type_metric_routemap_cmd,
5974 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5975 "Control distribution of default information\n"
5976 "Distribute a default route\n"
5977 "OSPF metric type for default routes\n"
5978 "Set OSPF External Type 1 metrics\n"
5979 "Set OSPF External Type 2 metrics\n"
5980 "OSPF default metric\n"
5981 "OSPF metric\n"
5982 "Route map reference\n"
5983 "Pointer to route-map entries\n")
5984{
paul020709f2003-04-04 02:44:16 +00005985 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005986 int type = -1;
5987 int metric = -1;
5988
5989 /* Get metric type. */
5990 if (argc >= 1)
5991 if (!str2metric_type (argv[0], &type))
5992 return CMD_WARNING;
5993
5994 /* Get metric value. */
5995 if (argc >= 2)
5996 if (!str2metric (argv[1], &metric))
5997 return CMD_WARNING;
5998
5999 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006000 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006001 else
paul020709f2003-04-04 02:44:16 +00006002 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006003
paul020709f2003-04-04 02:44:16 +00006004 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6005 type, metric);
paul718e3742002-12-13 20:15:29 +00006006}
6007
6008ALIAS (ospf_default_information_originate_type_metric_routemap,
6009 ospf_default_information_originate_type_metric_cmd,
6010 "default-information originate metric-type (1|2) metric <0-16777214>",
6011 "Control distribution of default information\n"
6012 "Distribute a default route\n"
6013 "OSPF metric type for default routes\n"
6014 "Set OSPF External Type 1 metrics\n"
6015 "Set OSPF External Type 2 metrics\n"
6016 "OSPF default metric\n"
6017 "OSPF metric\n")
6018
6019ALIAS (ospf_default_information_originate_type_metric_routemap,
6020 ospf_default_information_originate_type_cmd,
6021 "default-information originate metric-type (1|2)",
6022 "Control distribution of default information\n"
6023 "Distribute a default route\n"
6024 "OSPF metric type for default routes\n"
6025 "Set OSPF External Type 1 metrics\n"
6026 "Set OSPF External Type 2 metrics\n")
6027
6028DEFUN (ospf_default_information_originate_type_routemap,
6029 ospf_default_information_originate_type_routemap_cmd,
6030 "default-information originate metric-type (1|2) route-map WORD",
6031 "Control distribution of default information\n"
6032 "Distribute a default route\n"
6033 "OSPF metric type for default routes\n"
6034 "Set OSPF External Type 1 metrics\n"
6035 "Set OSPF External Type 2 metrics\n"
6036 "Route map reference\n"
6037 "Pointer to route-map entries\n")
6038{
paul020709f2003-04-04 02:44:16 +00006039 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006040 int type = -1;
6041
6042 /* Get metric type. */
6043 if (argc >= 1)
6044 if (!str2metric_type (argv[0], &type))
6045 return CMD_WARNING;
6046
6047 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006048 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006049 else
paul020709f2003-04-04 02:44:16 +00006050 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006051
paul020709f2003-04-04 02:44:16 +00006052 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6053 type, -1);
paul718e3742002-12-13 20:15:29 +00006054}
6055
6056DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6057 ospf_default_information_originate_always_metric_type_routemap_cmd,
6058 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6059 "Control distribution of default information\n"
6060 "Distribute a default route\n"
6061 "Always advertise default route\n"
6062 "OSPF default metric\n"
6063 "OSPF metric\n"
6064 "OSPF metric type for default routes\n"
6065 "Set OSPF External Type 1 metrics\n"
6066 "Set OSPF External Type 2 metrics\n"
6067 "Route map reference\n"
6068 "Pointer to route-map entries\n")
6069{
paul020709f2003-04-04 02:44:16 +00006070 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006071 int type = -1;
6072 int metric = -1;
6073
6074 /* Get metric value. */
6075 if (argc >= 1)
6076 if (!str2metric (argv[0], &metric))
6077 return CMD_WARNING;
6078
6079 /* Get metric type. */
6080 if (argc >= 2)
6081 if (!str2metric_type (argv[1], &type))
6082 return CMD_WARNING;
6083
6084 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006085 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006086 else
paul020709f2003-04-04 02:44:16 +00006087 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006088
paul020709f2003-04-04 02:44:16 +00006089 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006090 type, metric);
6091}
6092
6093ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6094 ospf_default_information_originate_always_metric_type_cmd,
6095 "default-information originate always metric <0-16777214> metric-type (1|2)",
6096 "Control distribution of default information\n"
6097 "Distribute a default route\n"
6098 "Always advertise default route\n"
6099 "OSPF default metric\n"
6100 "OSPF metric\n"
6101 "OSPF metric type for default routes\n"
6102 "Set OSPF External Type 1 metrics\n"
6103 "Set OSPF External Type 2 metrics\n")
6104
6105ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6106 ospf_default_information_originate_always_metric_cmd,
6107 "default-information originate always metric <0-16777214>",
6108 "Control distribution of default information\n"
6109 "Distribute a default route\n"
6110 "Always advertise default route\n"
6111 "OSPF default metric\n"
6112 "OSPF metric\n"
6113 "OSPF metric type for default routes\n")
6114
6115ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6116 ospf_default_information_originate_always_cmd,
6117 "default-information originate always",
6118 "Control distribution of default information\n"
6119 "Distribute a default route\n"
6120 "Always advertise default route\n")
6121
6122DEFUN (ospf_default_information_originate_always_metric_routemap,
6123 ospf_default_information_originate_always_metric_routemap_cmd,
6124 "default-information originate always metric <0-16777214> route-map WORD",
6125 "Control distribution of default information\n"
6126 "Distribute a default route\n"
6127 "Always advertise default route\n"
6128 "OSPF default metric\n"
6129 "OSPF metric\n"
6130 "Route map reference\n"
6131 "Pointer to route-map entries\n")
6132{
paul020709f2003-04-04 02:44:16 +00006133 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006134 int metric = -1;
6135
6136 /* Get metric value. */
6137 if (argc >= 1)
6138 if (!str2metric (argv[0], &metric))
6139 return CMD_WARNING;
6140
6141 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006142 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006143 else
paul020709f2003-04-04 02:44:16 +00006144 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006145
paul020709f2003-04-04 02:44:16 +00006146 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6147 -1, metric);
paul718e3742002-12-13 20:15:29 +00006148}
6149
6150DEFUN (ospf_default_information_originate_always_routemap,
6151 ospf_default_information_originate_always_routemap_cmd,
6152 "default-information originate always route-map WORD",
6153 "Control distribution of default information\n"
6154 "Distribute a default route\n"
6155 "Always advertise default route\n"
6156 "Route map reference\n"
6157 "Pointer to route-map entries\n")
6158{
paul020709f2003-04-04 02:44:16 +00006159 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006160
paul020709f2003-04-04 02:44:16 +00006161 if (argc == 1)
6162 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6163 else
6164 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6165
6166 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006167}
6168
6169DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6170 ospf_default_information_originate_always_type_metric_routemap_cmd,
6171 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6172 "Control distribution of default information\n"
6173 "Distribute a default route\n"
6174 "Always advertise default route\n"
6175 "OSPF metric type for default routes\n"
6176 "Set OSPF External Type 1 metrics\n"
6177 "Set OSPF External Type 2 metrics\n"
6178 "OSPF default metric\n"
6179 "OSPF metric\n"
6180 "Route map reference\n"
6181 "Pointer to route-map entries\n")
6182{
paul020709f2003-04-04 02:44:16 +00006183 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006184 int type = -1;
6185 int metric = -1;
6186
6187 /* Get metric type. */
6188 if (argc >= 1)
6189 if (!str2metric_type (argv[0], &type))
6190 return CMD_WARNING;
6191
6192 /* Get metric value. */
6193 if (argc >= 2)
6194 if (!str2metric (argv[1], &metric))
6195 return CMD_WARNING;
6196
6197 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006198 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006199 else
paul020709f2003-04-04 02:44:16 +00006200 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006201
paul020709f2003-04-04 02:44:16 +00006202 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006203 type, metric);
6204}
6205
6206ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6207 ospf_default_information_originate_always_type_metric_cmd,
6208 "default-information originate always metric-type (1|2) metric <0-16777214>",
6209 "Control distribution of default information\n"
6210 "Distribute a default route\n"
6211 "Always advertise default route\n"
6212 "OSPF metric type for default routes\n"
6213 "Set OSPF External Type 1 metrics\n"
6214 "Set OSPF External Type 2 metrics\n"
6215 "OSPF default metric\n"
6216 "OSPF metric\n")
6217
6218ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6219 ospf_default_information_originate_always_type_cmd,
6220 "default-information originate always metric-type (1|2)",
6221 "Control distribution of default information\n"
6222 "Distribute a default route\n"
6223 "Always advertise default route\n"
6224 "OSPF metric type for default routes\n"
6225 "Set OSPF External Type 1 metrics\n"
6226 "Set OSPF External Type 2 metrics\n")
6227
6228DEFUN (ospf_default_information_originate_always_type_routemap,
6229 ospf_default_information_originate_always_type_routemap_cmd,
6230 "default-information originate always metric-type (1|2) route-map WORD",
6231 "Control distribution of default information\n"
6232 "Distribute a default route\n"
6233 "Always advertise default route\n"
6234 "OSPF metric type for default routes\n"
6235 "Set OSPF External Type 1 metrics\n"
6236 "Set OSPF External Type 2 metrics\n"
6237 "Route map reference\n"
6238 "Pointer to route-map entries\n")
6239{
paul020709f2003-04-04 02:44:16 +00006240 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006241 int type = -1;
6242
6243 /* Get metric type. */
6244 if (argc >= 1)
6245 if (!str2metric_type (argv[0], &type))
6246 return CMD_WARNING;
6247
6248 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006249 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006250 else
paul020709f2003-04-04 02:44:16 +00006251 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006252
paul020709f2003-04-04 02:44:16 +00006253 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006254 type, -1);
6255}
6256
6257DEFUN (no_ospf_default_information_originate,
6258 no_ospf_default_information_originate_cmd,
6259 "no default-information originate",
6260 NO_STR
6261 "Control distribution of default information\n"
6262 "Distribute a default route\n")
6263{
paul68980082003-03-25 05:07:42 +00006264 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006265 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006266
6267 p.family = AF_INET;
6268 p.prefix.s_addr = 0;
6269 p.prefixlen = 0;
6270
ajs5339cfd2005-09-19 13:28:05 +00006271 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006272
6273 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6274 ospf_external_info_delete (DEFAULT_ROUTE, p);
6275 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6276 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6277 }
6278
paul020709f2003-04-04 02:44:16 +00006279 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6280 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006281}
6282
6283DEFUN (ospf_default_metric,
6284 ospf_default_metric_cmd,
6285 "default-metric <0-16777214>",
6286 "Set metric of redistributed routes\n"
6287 "Default metric\n")
6288{
paul68980082003-03-25 05:07:42 +00006289 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006290 int metric = -1;
6291
6292 if (!str2metric (argv[0], &metric))
6293 return CMD_WARNING;
6294
paul68980082003-03-25 05:07:42 +00006295 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006296
6297 return CMD_SUCCESS;
6298}
6299
6300DEFUN (no_ospf_default_metric,
6301 no_ospf_default_metric_cmd,
6302 "no default-metric",
6303 NO_STR
6304 "Set metric of redistributed routes\n")
6305{
paul68980082003-03-25 05:07:42 +00006306 struct ospf *ospf = vty->index;
6307
6308 ospf->default_metric = -1;
6309
paul718e3742002-12-13 20:15:29 +00006310 return CMD_SUCCESS;
6311}
6312
6313ALIAS (no_ospf_default_metric,
6314 no_ospf_default_metric_val_cmd,
6315 "no default-metric <0-16777214>",
6316 NO_STR
6317 "Set metric of redistributed routes\n"
6318 "Default metric\n")
6319
6320DEFUN (ospf_distance,
6321 ospf_distance_cmd,
6322 "distance <1-255>",
6323 "Define an administrative distance\n"
6324 "OSPF Administrative distance\n")
6325{
paul68980082003-03-25 05:07:42 +00006326 struct ospf *ospf = vty->index;
6327
6328 ospf->distance_all = atoi (argv[0]);
6329
paul718e3742002-12-13 20:15:29 +00006330 return CMD_SUCCESS;
6331}
6332
6333DEFUN (no_ospf_distance,
6334 no_ospf_distance_cmd,
6335 "no distance <1-255>",
6336 NO_STR
6337 "Define an administrative distance\n"
6338 "OSPF Administrative distance\n")
6339{
paul68980082003-03-25 05:07:42 +00006340 struct ospf *ospf = vty->index;
6341
6342 ospf->distance_all = 0;
6343
paul718e3742002-12-13 20:15:29 +00006344 return CMD_SUCCESS;
6345}
6346
6347DEFUN (no_ospf_distance_ospf,
6348 no_ospf_distance_ospf_cmd,
6349 "no distance ospf",
6350 NO_STR
6351 "Define an administrative distance\n"
6352 "OSPF Administrative distance\n"
6353 "OSPF Distance\n")
6354{
paul68980082003-03-25 05:07:42 +00006355 struct ospf *ospf = vty->index;
6356
6357 ospf->distance_intra = 0;
6358 ospf->distance_inter = 0;
6359 ospf->distance_external = 0;
6360
paul718e3742002-12-13 20:15:29 +00006361 return CMD_SUCCESS;
6362}
6363
6364DEFUN (ospf_distance_ospf_intra,
6365 ospf_distance_ospf_intra_cmd,
6366 "distance ospf intra-area <1-255>",
6367 "Define an administrative distance\n"
6368 "OSPF Administrative distance\n"
6369 "Intra-area routes\n"
6370 "Distance for intra-area routes\n")
6371{
paul68980082003-03-25 05:07:42 +00006372 struct ospf *ospf = vty->index;
6373
6374 ospf->distance_intra = atoi (argv[0]);
6375
paul718e3742002-12-13 20:15:29 +00006376 return CMD_SUCCESS;
6377}
6378
6379DEFUN (ospf_distance_ospf_intra_inter,
6380 ospf_distance_ospf_intra_inter_cmd,
6381 "distance ospf intra-area <1-255> inter-area <1-255>",
6382 "Define an administrative distance\n"
6383 "OSPF Administrative distance\n"
6384 "Intra-area routes\n"
6385 "Distance for intra-area routes\n"
6386 "Inter-area routes\n"
6387 "Distance for inter-area routes\n")
6388{
paul68980082003-03-25 05:07:42 +00006389 struct ospf *ospf = vty->index;
6390
6391 ospf->distance_intra = atoi (argv[0]);
6392 ospf->distance_inter = atoi (argv[1]);
6393
paul718e3742002-12-13 20:15:29 +00006394 return CMD_SUCCESS;
6395}
6396
6397DEFUN (ospf_distance_ospf_intra_external,
6398 ospf_distance_ospf_intra_external_cmd,
6399 "distance ospf intra-area <1-255> external <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 "External routes\n"
6405 "Distance for external routes\n")
6406{
paul68980082003-03-25 05:07:42 +00006407 struct ospf *ospf = vty->index;
6408
6409 ospf->distance_intra = atoi (argv[0]);
6410 ospf->distance_external = atoi (argv[1]);
6411
paul718e3742002-12-13 20:15:29 +00006412 return CMD_SUCCESS;
6413}
6414
6415DEFUN (ospf_distance_ospf_intra_inter_external,
6416 ospf_distance_ospf_intra_inter_external_cmd,
6417 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6418 "Define an administrative distance\n"
6419 "OSPF Administrative distance\n"
6420 "Intra-area routes\n"
6421 "Distance for intra-area routes\n"
6422 "Inter-area routes\n"
6423 "Distance for inter-area routes\n"
6424 "External routes\n"
6425 "Distance for external routes\n")
6426{
paul68980082003-03-25 05:07:42 +00006427 struct ospf *ospf = vty->index;
6428
6429 ospf->distance_intra = atoi (argv[0]);
6430 ospf->distance_inter = atoi (argv[1]);
6431 ospf->distance_external = atoi (argv[2]);
6432
paul718e3742002-12-13 20:15:29 +00006433 return CMD_SUCCESS;
6434}
6435
6436DEFUN (ospf_distance_ospf_intra_external_inter,
6437 ospf_distance_ospf_intra_external_inter_cmd,
6438 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6439 "Define an administrative distance\n"
6440 "OSPF Administrative distance\n"
6441 "Intra-area routes\n"
6442 "Distance for intra-area routes\n"
6443 "External routes\n"
6444 "Distance for external routes\n"
6445 "Inter-area routes\n"
6446 "Distance for inter-area routes\n")
6447{
paul68980082003-03-25 05:07:42 +00006448 struct ospf *ospf = vty->index;
6449
6450 ospf->distance_intra = atoi (argv[0]);
6451 ospf->distance_external = atoi (argv[1]);
6452 ospf->distance_inter = atoi (argv[2]);
6453
paul718e3742002-12-13 20:15:29 +00006454 return CMD_SUCCESS;
6455}
6456
6457DEFUN (ospf_distance_ospf_inter,
6458 ospf_distance_ospf_inter_cmd,
6459 "distance ospf inter-area <1-255>",
6460 "Define an administrative distance\n"
6461 "OSPF Administrative distance\n"
6462 "Inter-area routes\n"
6463 "Distance for inter-area routes\n")
6464{
paul68980082003-03-25 05:07:42 +00006465 struct ospf *ospf = vty->index;
6466
6467 ospf->distance_inter = atoi (argv[0]);
6468
paul718e3742002-12-13 20:15:29 +00006469 return CMD_SUCCESS;
6470}
6471
6472DEFUN (ospf_distance_ospf_inter_intra,
6473 ospf_distance_ospf_inter_intra_cmd,
6474 "distance ospf inter-area <1-255> intra-area <1-255>",
6475 "Define an administrative distance\n"
6476 "OSPF Administrative distance\n"
6477 "Inter-area routes\n"
6478 "Distance for inter-area routes\n"
6479 "Intra-area routes\n"
6480 "Distance for intra-area routes\n")
6481{
paul68980082003-03-25 05:07:42 +00006482 struct ospf *ospf = vty->index;
6483
6484 ospf->distance_inter = atoi (argv[0]);
6485 ospf->distance_intra = atoi (argv[1]);
6486
paul718e3742002-12-13 20:15:29 +00006487 return CMD_SUCCESS;
6488}
6489
6490DEFUN (ospf_distance_ospf_inter_external,
6491 ospf_distance_ospf_inter_external_cmd,
6492 "distance ospf inter-area <1-255> external <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 "External routes\n"
6498 "Distance for external routes\n")
6499{
paul68980082003-03-25 05:07:42 +00006500 struct ospf *ospf = vty->index;
6501
6502 ospf->distance_inter = atoi (argv[0]);
6503 ospf->distance_external = atoi (argv[1]);
6504
paul718e3742002-12-13 20:15:29 +00006505 return CMD_SUCCESS;
6506}
6507
6508DEFUN (ospf_distance_ospf_inter_intra_external,
6509 ospf_distance_ospf_inter_intra_external_cmd,
6510 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6511 "Define an administrative distance\n"
6512 "OSPF Administrative distance\n"
6513 "Inter-area routes\n"
6514 "Distance for inter-area routes\n"
6515 "Intra-area routes\n"
6516 "Distance for intra-area routes\n"
6517 "External routes\n"
6518 "Distance for external routes\n")
6519{
paul68980082003-03-25 05:07:42 +00006520 struct ospf *ospf = vty->index;
6521
6522 ospf->distance_inter = atoi (argv[0]);
6523 ospf->distance_intra = atoi (argv[1]);
6524 ospf->distance_external = atoi (argv[2]);
6525
paul718e3742002-12-13 20:15:29 +00006526 return CMD_SUCCESS;
6527}
6528
6529DEFUN (ospf_distance_ospf_inter_external_intra,
6530 ospf_distance_ospf_inter_external_intra_cmd,
6531 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6532 "Define an administrative distance\n"
6533 "OSPF Administrative distance\n"
6534 "Inter-area routes\n"
6535 "Distance for inter-area routes\n"
6536 "External routes\n"
6537 "Distance for external routes\n"
6538 "Intra-area routes\n"
6539 "Distance for intra-area routes\n")
6540{
paul68980082003-03-25 05:07:42 +00006541 struct ospf *ospf = vty->index;
6542
6543 ospf->distance_inter = atoi (argv[0]);
6544 ospf->distance_external = atoi (argv[1]);
6545 ospf->distance_intra = atoi (argv[2]);
6546
paul718e3742002-12-13 20:15:29 +00006547 return CMD_SUCCESS;
6548}
6549
6550DEFUN (ospf_distance_ospf_external,
6551 ospf_distance_ospf_external_cmd,
6552 "distance ospf external <1-255>",
6553 "Define an administrative distance\n"
6554 "OSPF Administrative distance\n"
6555 "External routes\n"
6556 "Distance for external routes\n")
6557{
paul68980082003-03-25 05:07:42 +00006558 struct ospf *ospf = vty->index;
6559
6560 ospf->distance_external = atoi (argv[0]);
6561
paul718e3742002-12-13 20:15:29 +00006562 return CMD_SUCCESS;
6563}
6564
6565DEFUN (ospf_distance_ospf_external_intra,
6566 ospf_distance_ospf_external_intra_cmd,
6567 "distance ospf external <1-255> intra-area <1-255>",
6568 "Define an administrative distance\n"
6569 "OSPF Administrative distance\n"
6570 "External routes\n"
6571 "Distance for external routes\n"
6572 "Intra-area routes\n"
6573 "Distance for intra-area routes\n")
6574{
paul68980082003-03-25 05:07:42 +00006575 struct ospf *ospf = vty->index;
6576
6577 ospf->distance_external = atoi (argv[0]);
6578 ospf->distance_intra = atoi (argv[1]);
6579
paul718e3742002-12-13 20:15:29 +00006580 return CMD_SUCCESS;
6581}
6582
6583DEFUN (ospf_distance_ospf_external_inter,
6584 ospf_distance_ospf_external_inter_cmd,
6585 "distance ospf external <1-255> inter-area <1-255>",
6586 "Define an administrative distance\n"
6587 "OSPF Administrative distance\n"
6588 "External routes\n"
6589 "Distance for external routes\n"
6590 "Inter-area routes\n"
6591 "Distance for inter-area routes\n")
6592{
paul68980082003-03-25 05:07:42 +00006593 struct ospf *ospf = vty->index;
6594
6595 ospf->distance_external = atoi (argv[0]);
6596 ospf->distance_inter = atoi (argv[1]);
6597
paul718e3742002-12-13 20:15:29 +00006598 return CMD_SUCCESS;
6599}
6600
6601DEFUN (ospf_distance_ospf_external_intra_inter,
6602 ospf_distance_ospf_external_intra_inter_cmd,
6603 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6604 "Define an administrative distance\n"
6605 "OSPF Administrative distance\n"
6606 "External routes\n"
6607 "Distance for external routes\n"
6608 "Intra-area routes\n"
6609 "Distance for intra-area routes\n"
6610 "Inter-area routes\n"
6611 "Distance for inter-area routes\n")
6612{
paul68980082003-03-25 05:07:42 +00006613 struct ospf *ospf = vty->index;
6614
6615 ospf->distance_external = atoi (argv[0]);
6616 ospf->distance_intra = atoi (argv[1]);
6617 ospf->distance_inter = atoi (argv[2]);
6618
paul718e3742002-12-13 20:15:29 +00006619 return CMD_SUCCESS;
6620}
6621
6622DEFUN (ospf_distance_ospf_external_inter_intra,
6623 ospf_distance_ospf_external_inter_intra_cmd,
6624 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6625 "Define an administrative distance\n"
6626 "OSPF Administrative distance\n"
6627 "External routes\n"
6628 "Distance for external routes\n"
6629 "Inter-area routes\n"
6630 "Distance for inter-area routes\n"
6631 "Intra-area routes\n"
6632 "Distance for intra-area routes\n")
6633{
paul68980082003-03-25 05:07:42 +00006634 struct ospf *ospf = vty->index;
6635
6636 ospf->distance_external = atoi (argv[0]);
6637 ospf->distance_inter = atoi (argv[1]);
6638 ospf->distance_intra = atoi (argv[2]);
6639
paul718e3742002-12-13 20:15:29 +00006640 return CMD_SUCCESS;
6641}
6642
6643DEFUN (ospf_distance_source,
6644 ospf_distance_source_cmd,
6645 "distance <1-255> A.B.C.D/M",
6646 "Administrative distance\n"
6647 "Distance value\n"
6648 "IP source prefix\n")
6649{
paul020709f2003-04-04 02:44:16 +00006650 struct ospf *ospf = vty->index;
6651
6652 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006653
paul718e3742002-12-13 20:15:29 +00006654 return CMD_SUCCESS;
6655}
6656
6657DEFUN (no_ospf_distance_source,
6658 no_ospf_distance_source_cmd,
6659 "no distance <1-255> A.B.C.D/M",
6660 NO_STR
6661 "Administrative distance\n"
6662 "Distance value\n"
6663 "IP source prefix\n")
6664{
paul020709f2003-04-04 02:44:16 +00006665 struct ospf *ospf = vty->index;
6666
6667 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6668
paul718e3742002-12-13 20:15:29 +00006669 return CMD_SUCCESS;
6670}
6671
6672DEFUN (ospf_distance_source_access_list,
6673 ospf_distance_source_access_list_cmd,
6674 "distance <1-255> A.B.C.D/M WORD",
6675 "Administrative distance\n"
6676 "Distance value\n"
6677 "IP source prefix\n"
6678 "Access list name\n")
6679{
paul020709f2003-04-04 02:44:16 +00006680 struct ospf *ospf = vty->index;
6681
6682 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6683
paul718e3742002-12-13 20:15:29 +00006684 return CMD_SUCCESS;
6685}
6686
6687DEFUN (no_ospf_distance_source_access_list,
6688 no_ospf_distance_source_access_list_cmd,
6689 "no distance <1-255> A.B.C.D/M WORD",
6690 NO_STR
6691 "Administrative distance\n"
6692 "Distance value\n"
6693 "IP source prefix\n"
6694 "Access list name\n")
6695{
paul020709f2003-04-04 02:44:16 +00006696 struct ospf *ospf = vty->index;
6697
6698 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6699
paul718e3742002-12-13 20:15:29 +00006700 return CMD_SUCCESS;
6701}
6702
vincentba682532005-09-29 13:52:57 +00006703DEFUN (ip_ospf_mtu_ignore,
6704 ip_ospf_mtu_ignore_addr_cmd,
6705 "ip ospf mtu-ignore A.B.C.D",
6706 "IP Information\n"
6707 "OSPF interface commands\n"
6708 "Disable mtu mismatch detection\n"
6709 "Address of interface")
6710{
6711 struct interface *ifp = vty->index;
6712 struct in_addr addr;
6713 int ret;
6714
6715 struct ospf_if_params *params;
6716 params = IF_DEF_PARAMS (ifp);
6717
6718 if (argc == 1)
6719 {
6720 ret = inet_aton(argv[0], &addr);
6721 if (!ret)
6722 {
6723 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6724 VTY_NEWLINE);
6725 return CMD_WARNING;
6726 }
6727 params = ospf_get_if_params (ifp, addr);
6728 ospf_if_update_params (ifp, addr);
6729 }
6730 params->mtu_ignore = 1;
6731 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6732 SET_IF_PARAM (params, mtu_ignore);
6733 else
6734 {
6735 UNSET_IF_PARAM (params, mtu_ignore);
6736 if (params != IF_DEF_PARAMS (ifp))
6737 {
6738 ospf_free_if_params (ifp, addr);
6739 ospf_if_update_params (ifp, addr);
6740 }
6741 }
6742 return CMD_SUCCESS;
6743}
6744
6745ALIAS (ip_ospf_mtu_ignore,
6746 ip_ospf_mtu_ignore_cmd,
6747 "ip ospf mtu-ignore",
6748 "IP Information\n"
6749 "OSPF interface commands\n"
6750 "Disable mtu mismatch detection\n")
6751
6752
6753DEFUN (no_ip_ospf_mtu_ignore,
6754 no_ip_ospf_mtu_ignore_addr_cmd,
6755 "no ip ospf mtu-ignore A.B.C.D",
6756 "IP Information\n"
6757 "OSPF interface commands\n"
6758 "Disable mtu mismatch detection\n"
6759 "Address of interface")
6760{
6761 struct interface *ifp = vty->index;
6762 struct in_addr addr;
6763 int ret;
6764
6765 struct ospf_if_params *params;
6766 params = IF_DEF_PARAMS (ifp);
6767
6768 if (argc == 1)
6769 {
6770 ret = inet_aton(argv[0], &addr);
6771 if (!ret)
6772 {
6773 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6774 VTY_NEWLINE);
6775 return CMD_WARNING;
6776 }
6777 params = ospf_get_if_params (ifp, addr);
6778 ospf_if_update_params (ifp, addr);
6779 }
6780 params->mtu_ignore = 0;
6781 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6782 SET_IF_PARAM (params, mtu_ignore);
6783 else
6784 {
6785 UNSET_IF_PARAM (params, mtu_ignore);
6786 if (params != IF_DEF_PARAMS (ifp))
6787 {
6788 ospf_free_if_params (ifp, addr);
6789 ospf_if_update_params (ifp, addr);
6790 }
6791 }
6792 return CMD_SUCCESS;
6793}
6794
6795ALIAS (no_ip_ospf_mtu_ignore,
6796 no_ip_ospf_mtu_ignore_cmd,
6797 "no ip ospf mtu-ignore",
6798 "IP Information\n"
6799 "OSPF interface commands\n"
6800 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00006801
6802DEFUN (ospf_max_metric_router_lsa_admin,
6803 ospf_max_metric_router_lsa_admin_cmd,
6804 "max-metric router-lsa administrative",
6805 "OSPF maximum / infinite-distance metric\n"
6806 "Advertise own Router-LSA with infinite distance (stub router)\n"
6807 "Administratively applied, for an indefinite period\n")
6808{
6809 struct listnode *ln;
6810 struct ospf_area *area;
6811 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006812
paul88d6cf32005-10-29 12:50:09 +00006813 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6814 {
6815 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6816
6817 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
6818 ospf_router_lsa_timer_add (area);
6819 }
6820 return CMD_SUCCESS;
6821}
6822
6823DEFUN (no_ospf_max_metric_router_lsa_admin,
6824 no_ospf_max_metric_router_lsa_admin_cmd,
6825 "no max-metric router-lsa administrative",
6826 NO_STR
6827 "OSPF maximum / infinite-distance metric\n"
6828 "Advertise own Router-LSA with infinite distance (stub router)\n"
6829 "Administratively applied, for an indefinite period\n")
6830{
6831 struct listnode *ln;
6832 struct ospf_area *area;
6833 struct ospf *ospf = vty->index;
6834
6835 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6836 {
6837 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6838
6839 /* Don't trample on the start-up stub timer */
6840 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6841 && !area->t_stub_router)
6842 {
6843 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6844 ospf_router_lsa_timer_add (area);
6845 }
6846 }
6847 return CMD_SUCCESS;
6848}
6849
6850DEFUN (ospf_max_metric_router_lsa_startup,
6851 ospf_max_metric_router_lsa_startup_cmd,
6852 "max-metric router-lsa on-startup <5-86400>",
6853 "OSPF maximum / infinite-distance metric\n"
6854 "Advertise own Router-LSA with infinite distance (stub router)\n"
6855 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6856 "Time (seconds) to advertise self as stub-router\n")
6857{
6858 unsigned int seconds;
6859 struct ospf *ospf = vty->index;
6860
6861 if (argc != 1)
6862 {
6863 vty_out (vty, "%% Must supply stub-router period");
6864 return CMD_WARNING;
6865 }
6866
6867 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6868
6869 ospf->stub_router_startup_time = seconds;
6870
6871 return CMD_SUCCESS;
6872}
6873
6874DEFUN (no_ospf_max_metric_router_lsa_startup,
6875 no_ospf_max_metric_router_lsa_startup_cmd,
6876 "no max-metric router-lsa on-startup",
6877 NO_STR
6878 "OSPF maximum / infinite-distance metric\n"
6879 "Advertise own Router-LSA with infinite distance (stub router)\n"
6880 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6881{
6882 struct listnode *ln;
6883 struct ospf_area *area;
6884 struct ospf *ospf = vty->index;
6885
6886 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6887
6888 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6889 {
6890 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6891 OSPF_TIMER_OFF (area->t_stub_router);
6892
6893 /* Don't trample on admin stub routed */
6894 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6895 {
6896 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6897 ospf_router_lsa_timer_add (area);
6898 }
6899 }
6900 return CMD_SUCCESS;
6901}
6902
6903DEFUN (ospf_max_metric_router_lsa_shutdown,
6904 ospf_max_metric_router_lsa_shutdown_cmd,
6905 "max-metric router-lsa on-shutdown <5-86400>",
6906 "OSPF maximum / infinite-distance metric\n"
6907 "Advertise own Router-LSA with infinite distance (stub router)\n"
6908 "Advertise stub-router prior to full shutdown of OSPF\n"
6909 "Time (seconds) to wait till full shutdown\n")
6910{
6911 unsigned int seconds;
6912 struct ospf *ospf = vty->index;
6913
6914 if (argc != 1)
6915 {
6916 vty_out (vty, "%% Must supply stub-router shutdown period");
6917 return CMD_WARNING;
6918 }
6919
6920 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6921
6922 ospf->stub_router_shutdown_time = seconds;
6923
6924 return CMD_SUCCESS;
6925}
6926
6927DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6928 no_ospf_max_metric_router_lsa_shutdown_cmd,
6929 "no max-metric router-lsa on-shutdown",
6930 NO_STR
6931 "OSPF maximum / infinite-distance metric\n"
6932 "Advertise own Router-LSA with infinite distance (stub router)\n"
6933 "Advertise stub-router prior to full shutdown of OSPF\n")
6934{
6935 struct ospf *ospf = vty->index;
6936
6937 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6938
6939 return CMD_SUCCESS;
6940}
6941
6942static void
6943config_write_stub_router (struct vty *vty, struct ospf *ospf)
6944{
6945 struct listnode *ln;
6946 struct ospf_area *area;
6947
6948 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6949 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6950 ospf->stub_router_startup_time, VTY_NEWLINE);
6951 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6952 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6953 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6954 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6955 {
6956 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6957 {
6958 vty_out (vty, " max-metric router-lsa administrative%s",
6959 VTY_NEWLINE);
6960 break;
6961 }
6962 }
6963 return;
6964}
6965
paul4dadc292005-05-06 21:37:42 +00006966static void
paul718e3742002-12-13 20:15:29 +00006967show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6968{
6969 struct route_node *rn;
6970 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006971 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006972 struct ospf_path *path;
6973
6974 vty_out (vty, "============ OSPF network routing table ============%s",
6975 VTY_NEWLINE);
6976
6977 for (rn = route_top (rt); rn; rn = route_next (rn))
6978 if ((or = rn->info) != NULL)
6979 {
6980 char buf1[19];
6981 snprintf (buf1, 19, "%s/%d",
6982 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6983
6984 switch (or->path_type)
6985 {
6986 case OSPF_PATH_INTER_AREA:
6987 if (or->type == OSPF_DESTINATION_NETWORK)
6988 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6989 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6990 else if (or->type == OSPF_DESTINATION_DISCARD)
6991 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6992 break;
6993 case OSPF_PATH_INTRA_AREA:
6994 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6995 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6996 break;
6997 default:
6998 break;
6999 }
7000
7001 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007002 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007003 {
hasso54bedb52005-08-17 13:31:47 +00007004 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00007005 {
7006 if (path->nexthop.s_addr == 0)
7007 vty_out (vty, "%24s directly attached to %s%s",
7008 "", path->oi->ifp->name, VTY_NEWLINE);
7009 else
7010 vty_out (vty, "%24s via %s, %s%s", "",
7011 inet_ntoa (path->nexthop), path->oi->ifp->name,
7012 VTY_NEWLINE);
7013 }
7014 }
paul718e3742002-12-13 20:15:29 +00007015 }
7016 vty_out (vty, "%s", VTY_NEWLINE);
7017}
7018
paul4dadc292005-05-06 21:37:42 +00007019static void
paul718e3742002-12-13 20:15:29 +00007020show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7021{
7022 struct route_node *rn;
7023 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007024 struct listnode *pnode;
7025 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007026 struct ospf_path *path;
7027
7028 vty_out (vty, "============ OSPF router routing table =============%s",
7029 VTY_NEWLINE);
7030 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7031 if (rn->info)
7032 {
7033 int flag = 0;
7034
7035 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7036
paul1eb8ef22005-04-07 07:30:20 +00007037 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7038 {
7039 if (flag++)
7040 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007041
paul1eb8ef22005-04-07 07:30:20 +00007042 /* Show path. */
7043 vty_out (vty, "%s [%d] area: %s",
7044 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7045 or->cost, inet_ntoa (or->u.std.area_id));
7046 /* Show flags. */
7047 vty_out (vty, "%s%s%s",
7048 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7049 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7050 VTY_NEWLINE);
7051
7052 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7053 {
hasso54bedb52005-08-17 13:31:47 +00007054 if (path->oi != NULL && ospf_if_exists(path->oi))
7055 {
7056 if (path->nexthop.s_addr == 0)
7057 vty_out (vty, "%24s directly attached to %s%s",
7058 "", path->oi->ifp->name, VTY_NEWLINE);
7059 else
7060 vty_out (vty, "%24s via %s, %s%s", "",
7061 inet_ntoa (path->nexthop),
7062 path->oi->ifp->name, VTY_NEWLINE);
7063 }
paul1eb8ef22005-04-07 07:30:20 +00007064 }
7065 }
paul718e3742002-12-13 20:15:29 +00007066 }
7067 vty_out (vty, "%s", VTY_NEWLINE);
7068}
7069
paul4dadc292005-05-06 21:37:42 +00007070static void
paul718e3742002-12-13 20:15:29 +00007071show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7072{
7073 struct route_node *rn;
7074 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007075 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007076 struct ospf_path *path;
7077
7078 vty_out (vty, "============ OSPF external routing table ===========%s",
7079 VTY_NEWLINE);
7080 for (rn = route_top (rt); rn; rn = route_next (rn))
7081 if ((er = rn->info) != NULL)
7082 {
7083 char buf1[19];
7084 snprintf (buf1, 19, "%s/%d",
7085 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7086
7087 switch (er->path_type)
7088 {
7089 case OSPF_PATH_TYPE1_EXTERNAL:
7090 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7091 er->cost, er->u.ext.tag, VTY_NEWLINE);
7092 break;
7093 case OSPF_PATH_TYPE2_EXTERNAL:
7094 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7095 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7096 break;
7097 }
7098
paul1eb8ef22005-04-07 07:30:20 +00007099 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007100 {
hasso54bedb52005-08-17 13:31:47 +00007101 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00007102 {
7103 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007104 vty_out (vty, "%24s directly attached to %s%s",
7105 "", path->oi->ifp->name, VTY_NEWLINE);
7106 else
7107 vty_out (vty, "%24s via %s, %s%s", "",
7108 inet_ntoa (path->nexthop), path->oi->ifp->name,
7109 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007110 }
7111 }
7112 }
7113 vty_out (vty, "%s", VTY_NEWLINE);
7114}
7115
paul718e3742002-12-13 20:15:29 +00007116DEFUN (show_ip_ospf_border_routers,
7117 show_ip_ospf_border_routers_cmd,
7118 "show ip ospf border-routers",
7119 SHOW_STR
7120 IP_STR
7121 "show all the ABR's and ASBR's\n"
7122 "for this area\n")
7123{
paul020709f2003-04-04 02:44:16 +00007124 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007125
paul020709f2003-04-04 02:44:16 +00007126 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007127 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00007128 {
7129 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
7130 return CMD_SUCCESS;
7131 }
7132
paul68980082003-03-25 05:07:42 +00007133 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007134 {
7135 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7136 return CMD_SUCCESS;
7137 }
7138
7139 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007140 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007141
7142 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007143 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007144
7145 return CMD_SUCCESS;
7146}
paul718e3742002-12-13 20:15:29 +00007147
7148DEFUN (show_ip_ospf_route,
7149 show_ip_ospf_route_cmd,
7150 "show ip ospf route",
7151 SHOW_STR
7152 IP_STR
7153 "OSPF information\n"
7154 "OSPF routing table\n")
7155{
paul020709f2003-04-04 02:44:16 +00007156 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007157
paul020709f2003-04-04 02:44:16 +00007158 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007159 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00007160 {
7161 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
7162 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. */
paul68980082003-03-25 05:07:42 +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 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007178 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007179
7180 return CMD_SUCCESS;
7181}
7182
7183
hassoeb1ce602004-10-08 08:17:22 +00007184const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007185{
7186 "unknown",
7187 "standard",
7188 "ibm",
7189 "cisco",
7190 "shortcut"
7191};
7192
hassoeb1ce602004-10-08 08:17:22 +00007193const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007194{
7195 "default",
7196 "enable",
7197 "disable"
7198};
7199
7200
paul4dadc292005-05-06 21:37:42 +00007201static void
paul718e3742002-12-13 20:15:29 +00007202area_id2str (char *buf, int length, struct ospf_area *area)
7203{
7204 memset (buf, 0, length);
7205
7206 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7207 strncpy (buf, inet_ntoa (area->area_id), length);
7208 else
7209 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7210}
7211
7212
hassoeb1ce602004-10-08 08:17:22 +00007213const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007214{
7215 "unknown", /* should never be used. */
7216 "point-to-point",
7217 "broadcast",
7218 "non-broadcast",
7219 "point-to-multipoint",
7220 "virtual-link", /* should never be used. */
7221 "loopback"
7222};
7223
7224/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007225static int
paul718e3742002-12-13 20:15:29 +00007226config_write_interface (struct vty *vty)
7227{
hasso52dc7ee2004-09-23 19:18:23 +00007228 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007229 struct interface *ifp;
7230 struct crypt_key *ck;
7231 int write = 0;
7232 struct route_node *rn = NULL;
7233 struct ospf_if_params *params;
7234
paul1eb8ef22005-04-07 07:30:20 +00007235 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007236 {
paul718e3742002-12-13 20:15:29 +00007237 if (memcmp (ifp->name, "VLINK", 5) == 0)
7238 continue;
7239
7240 vty_out (vty, "!%s", VTY_NEWLINE);
7241 vty_out (vty, "interface %s%s", ifp->name,
7242 VTY_NEWLINE);
7243 if (ifp->desc)
7244 vty_out (vty, " description %s%s", ifp->desc,
7245 VTY_NEWLINE);
7246
7247 write++;
7248
7249 params = IF_DEF_PARAMS (ifp);
7250
7251 do {
7252 /* Interface Network print. */
7253 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007254 params->type != OSPF_IFTYPE_LOOPBACK)
7255 {
ajsbc18d612004-12-15 15:07:19 +00007256 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007257 {
7258 vty_out (vty, " ip ospf network %s",
7259 ospf_int_type_str[params->type]);
7260 if (params != IF_DEF_PARAMS (ifp))
7261 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7262 vty_out (vty, "%s", VTY_NEWLINE);
7263 }
paul718e3742002-12-13 20:15:29 +00007264 }
7265
7266 /* OSPF interface authentication print */
7267 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7268 params->auth_type != OSPF_AUTH_NOTSET)
7269 {
hassoeb1ce602004-10-08 08:17:22 +00007270 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007271
7272 /* Translation tables are not that much help here due to syntax
7273 of the simple option */
7274 switch (params->auth_type)
7275 {
7276
7277 case OSPF_AUTH_NULL:
7278 auth_str = " null";
7279 break;
7280
7281 case OSPF_AUTH_SIMPLE:
7282 auth_str = "";
7283 break;
7284
7285 case OSPF_AUTH_CRYPTOGRAPHIC:
7286 auth_str = " message-digest";
7287 break;
7288
7289 default:
7290 auth_str = "";
7291 break;
7292 }
7293
7294 vty_out (vty, " ip ospf authentication%s", auth_str);
7295 if (params != IF_DEF_PARAMS (ifp))
7296 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7297 vty_out (vty, "%s", VTY_NEWLINE);
7298 }
7299
7300 /* Simple Authentication Password print. */
7301 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7302 params->auth_simple[0] != '\0')
7303 {
7304 vty_out (vty, " ip ospf authentication-key %s",
7305 params->auth_simple);
7306 if (params != IF_DEF_PARAMS (ifp))
7307 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7308 vty_out (vty, "%s", VTY_NEWLINE);
7309 }
7310
7311 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007312 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007313 {
paul718e3742002-12-13 20:15:29 +00007314 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7315 ck->key_id, ck->auth_key);
7316 if (params != IF_DEF_PARAMS (ifp))
7317 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7318 vty_out (vty, "%s", VTY_NEWLINE);
7319 }
7320
7321 /* Interface Output Cost print. */
7322 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7323 {
7324 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7325 if (params != IF_DEF_PARAMS (ifp))
7326 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7327 vty_out (vty, "%s", VTY_NEWLINE);
7328 }
7329
7330 /* Hello Interval print. */
7331 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7332 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7333 {
7334 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7335 if (params != IF_DEF_PARAMS (ifp))
7336 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7337 vty_out (vty, "%s", VTY_NEWLINE);
7338 }
7339
7340
7341 /* Router Dead Interval print. */
7342 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7343 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7344 {
paulf9ad9372005-10-21 00:45:17 +00007345 vty_out (vty, " ip ospf dead-interval ");
7346
7347 /* fast hello ? */
7348 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7349 vty_out (vty, "minimal hello-multiplier %d",
7350 params->fast_hello);
7351 else
7352 vty_out (vty, "%u", params->v_wait);
7353
paul718e3742002-12-13 20:15:29 +00007354 if (params != IF_DEF_PARAMS (ifp))
7355 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7356 vty_out (vty, "%s", VTY_NEWLINE);
7357 }
7358
7359 /* Router Priority print. */
7360 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7361 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7362 {
7363 vty_out (vty, " ip ospf priority %u", params->priority);
7364 if (params != IF_DEF_PARAMS (ifp))
7365 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7366 vty_out (vty, "%s", VTY_NEWLINE);
7367 }
7368
7369 /* Retransmit Interval print. */
7370 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7371 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7372 {
7373 vty_out (vty, " ip ospf retransmit-interval %u",
7374 params->retransmit_interval);
7375 if (params != IF_DEF_PARAMS (ifp))
7376 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7377 vty_out (vty, "%s", VTY_NEWLINE);
7378 }
7379
7380 /* Transmit Delay print. */
7381 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7382 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7383 {
7384 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7385 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
vincentba682532005-09-29 13:52:57 +00007390 /* MTU ignore print. */
7391 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7392 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7393 {
7394 if (params->mtu_ignore == 0)
7395 vty_out (vty, " no ip ospf mtu-ignore");
7396 else
7397 vty_out (vty, " ip ospf mtu-ignore");
7398 if (params != IF_DEF_PARAMS (ifp))
7399 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7400 vty_out (vty, "%s", VTY_NEWLINE);
7401 }
7402
7403
paul718e3742002-12-13 20:15:29 +00007404 while (1)
7405 {
7406 if (rn == NULL)
7407 rn = route_top (IF_OIFS_PARAMS (ifp));
7408 else
7409 rn = route_next (rn);
7410
7411 if (rn == NULL)
7412 break;
7413 params = rn->info;
7414 if (params != NULL)
7415 break;
7416 }
7417 } while (rn);
7418
7419#ifdef HAVE_OPAQUE_LSA
7420 ospf_opaque_config_write_if (vty, ifp);
7421#endif /* HAVE_OPAQUE_LSA */
7422 }
7423
7424 return write;
7425}
7426
paul4dadc292005-05-06 21:37:42 +00007427static int
paul68980082003-03-25 05:07:42 +00007428config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007429{
7430 struct route_node *rn;
7431 u_char buf[INET_ADDRSTRLEN];
7432
7433 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007434 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007435 if (rn->info)
7436 {
7437 struct ospf_network *n = rn->info;
7438
7439 memset (buf, 0, INET_ADDRSTRLEN);
7440
7441 /* Create Area ID string by specified Area ID format. */
7442 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007443 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007444 else
hassoc9e52be2004-09-26 16:09:34 +00007445 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007446 (unsigned long int) ntohl (n->area_id.s_addr));
7447
7448 /* Network print. */
7449 vty_out (vty, " network %s/%d area %s%s",
7450 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7451 buf, VTY_NEWLINE);
7452 }
7453
7454 return 0;
7455}
7456
paul4dadc292005-05-06 21:37:42 +00007457static int
paul68980082003-03-25 05:07:42 +00007458config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007459{
hasso52dc7ee2004-09-23 19:18:23 +00007460 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007461 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007462 u_char buf[INET_ADDRSTRLEN];
7463
7464 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007465 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007466 {
paul718e3742002-12-13 20:15:29 +00007467 struct route_node *rn1;
7468
hassoc9e52be2004-09-26 16:09:34 +00007469 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007470
7471 if (area->auth_type != OSPF_AUTH_NULL)
7472 {
7473 if (area->auth_type == OSPF_AUTH_SIMPLE)
7474 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7475 else
7476 vty_out (vty, " area %s authentication message-digest%s",
7477 buf, VTY_NEWLINE);
7478 }
7479
7480 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7481 vty_out (vty, " area %s shortcut %s%s", buf,
7482 ospf_shortcut_mode_str[area->shortcut_configured],
7483 VTY_NEWLINE);
7484
7485 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007486 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007487 )
7488 {
paulb0a053b2003-06-22 09:04:47 +00007489 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007490 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007491 else if (area->external_routing == OSPF_AREA_NSSA)
7492 {
7493 vty_out (vty, " area %s nssa", buf);
7494 switch (area->NSSATranslatorRole)
7495 {
7496 case OSPF_NSSA_ROLE_NEVER:
7497 vty_out (vty, " translate-never");
7498 break;
7499 case OSPF_NSSA_ROLE_ALWAYS:
7500 vty_out (vty, " translate-always");
7501 break;
7502 case OSPF_NSSA_ROLE_CANDIDATE:
7503 default:
7504 vty_out (vty, " translate-candidate");
7505 }
7506 }
paul718e3742002-12-13 20:15:29 +00007507
7508 if (area->no_summary)
7509 vty_out (vty, " no-summary");
7510
7511 vty_out (vty, "%s", VTY_NEWLINE);
7512
7513 if (area->default_cost != 1)
7514 vty_out (vty, " area %s default-cost %d%s", buf,
7515 area->default_cost, VTY_NEWLINE);
7516 }
7517
7518 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7519 if (rn1->info)
7520 {
7521 struct ospf_area_range *range = rn1->info;
7522
7523 vty_out (vty, " area %s range %s/%d", buf,
7524 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7525
paul6c835672004-10-11 11:00:30 +00007526 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007527 vty_out (vty, " cost %d", range->cost_config);
7528
7529 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7530 vty_out (vty, " not-advertise");
7531
7532 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7533 vty_out (vty, " substitute %s/%d",
7534 inet_ntoa (range->subst_addr), range->subst_masklen);
7535
7536 vty_out (vty, "%s", VTY_NEWLINE);
7537 }
7538
7539 if (EXPORT_NAME (area))
7540 vty_out (vty, " area %s export-list %s%s", buf,
7541 EXPORT_NAME (area), VTY_NEWLINE);
7542
7543 if (IMPORT_NAME (area))
7544 vty_out (vty, " area %s import-list %s%s", buf,
7545 IMPORT_NAME (area), VTY_NEWLINE);
7546
7547 if (PREFIX_NAME_IN (area))
7548 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7549 PREFIX_NAME_IN (area), VTY_NEWLINE);
7550
7551 if (PREFIX_NAME_OUT (area))
7552 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7553 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7554 }
7555
7556 return 0;
7557}
7558
paul4dadc292005-05-06 21:37:42 +00007559static int
paul68980082003-03-25 05:07:42 +00007560config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007561{
7562 struct ospf_nbr_nbma *nbr_nbma;
7563 struct route_node *rn;
7564
7565 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007566 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007567 if ((nbr_nbma = rn->info))
7568 {
7569 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7570
7571 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7572 vty_out (vty, " priority %d", nbr_nbma->priority);
7573
7574 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7575 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7576
7577 vty_out (vty, "%s", VTY_NEWLINE);
7578 }
7579
7580 return 0;
7581}
7582
paul4dadc292005-05-06 21:37:42 +00007583static int
paul68980082003-03-25 05:07:42 +00007584config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007585{
hasso52dc7ee2004-09-23 19:18:23 +00007586 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007587 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007588 u_char buf[INET_ADDRSTRLEN];
7589
7590 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007591 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007592 {
hasso52dc7ee2004-09-23 19:18:23 +00007593 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007594 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007595 struct ospf_interface *oi;
7596
7597 if (vl_data != NULL)
7598 {
7599 memset (buf, 0, INET_ADDRSTRLEN);
7600
7601 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007602 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007603 else
hassoc9e52be2004-09-26 16:09:34 +00007604 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007605 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7606 oi = vl_data->vl_oi;
7607
7608 /* timers */
7609 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7610 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7611 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7612 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7613 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7614 buf,
7615 inet_ntoa (vl_data->vl_peer),
7616 OSPF_IF_PARAM (oi, v_hello),
7617 OSPF_IF_PARAM (oi, retransmit_interval),
7618 OSPF_IF_PARAM (oi, transmit_delay),
7619 OSPF_IF_PARAM (oi, v_wait),
7620 VTY_NEWLINE);
7621 else
7622 vty_out (vty, " area %s virtual-link %s%s", buf,
7623 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7624 /* Auth key */
7625 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7626 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7627 buf,
7628 inet_ntoa (vl_data->vl_peer),
7629 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7630 VTY_NEWLINE);
7631 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007632 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7633 n2, ck))
7634 vty_out (vty, " area %s virtual-link %s"
7635 " message-digest-key %d md5 %s%s",
7636 buf,
7637 inet_ntoa (vl_data->vl_peer),
7638 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007639
7640 }
7641 }
7642
7643 return 0;
7644}
7645
7646
paul4dadc292005-05-06 21:37:42 +00007647static int
paul68980082003-03-25 05:07:42 +00007648config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007649{
7650 int type;
7651
7652 /* redistribute print. */
7653 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7654 if (type != zclient->redist_default && zclient->redist[type])
7655 {
ajsf52d13c2005-10-01 17:38:06 +00007656 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007657 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007658 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007659
paul68980082003-03-25 05:07:42 +00007660 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007661 vty_out (vty, " metric-type 1");
7662
paul020709f2003-04-04 02:44:16 +00007663 if (ROUTEMAP_NAME (ospf, type))
7664 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007665
7666 vty_out (vty, "%s", VTY_NEWLINE);
7667 }
7668
7669 return 0;
7670}
7671
paul4dadc292005-05-06 21:37:42 +00007672static int
paul68980082003-03-25 05:07:42 +00007673config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007674{
paul68980082003-03-25 05:07:42 +00007675 if (ospf->default_metric != -1)
7676 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007677 VTY_NEWLINE);
7678 return 0;
7679}
7680
paul4dadc292005-05-06 21:37:42 +00007681static int
paul68980082003-03-25 05:07:42 +00007682config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007683{
7684 int type;
7685
paul68980082003-03-25 05:07:42 +00007686 if (ospf)
paul718e3742002-12-13 20:15:29 +00007687 {
7688 /* distribute-list print. */
7689 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007690 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007691 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007692 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007693 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007694
7695 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007696 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007697 {
paul68980082003-03-25 05:07:42 +00007698 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007699 vty_out (vty, " default-information originate");
7700 else
7701 vty_out (vty, " default-information originate always");
7702
paul68980082003-03-25 05:07:42 +00007703 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007704 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007705 ospf->dmetric[DEFAULT_ROUTE].value);
7706 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007707 vty_out (vty, " metric-type 1");
7708
paul020709f2003-04-04 02:44:16 +00007709 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7710 vty_out (vty, " route-map %s",
7711 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007712
7713 vty_out (vty, "%s", VTY_NEWLINE);
7714 }
7715
7716 }
7717
7718 return 0;
7719}
7720
paul4dadc292005-05-06 21:37:42 +00007721static int
paul68980082003-03-25 05:07:42 +00007722config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007723{
7724 struct route_node *rn;
7725 struct ospf_distance *odistance;
7726
paul68980082003-03-25 05:07:42 +00007727 if (ospf->distance_all)
7728 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007729
paul68980082003-03-25 05:07:42 +00007730 if (ospf->distance_intra
7731 || ospf->distance_inter
7732 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007733 {
7734 vty_out (vty, " distance ospf");
7735
paul68980082003-03-25 05:07:42 +00007736 if (ospf->distance_intra)
7737 vty_out (vty, " intra-area %d", ospf->distance_intra);
7738 if (ospf->distance_inter)
7739 vty_out (vty, " inter-area %d", ospf->distance_inter);
7740 if (ospf->distance_external)
7741 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007742
7743 vty_out (vty, "%s", VTY_NEWLINE);
7744 }
7745
paul68980082003-03-25 05:07:42 +00007746 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007747 if ((odistance = rn->info) != NULL)
7748 {
7749 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7750 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7751 odistance->access_list ? odistance->access_list : "",
7752 VTY_NEWLINE);
7753 }
7754 return 0;
7755}
7756
7757/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007758static int
paul718e3742002-12-13 20:15:29 +00007759ospf_config_write (struct vty *vty)
7760{
paul020709f2003-04-04 02:44:16 +00007761 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007762 struct interface *ifp;
7763 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007764 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007765 int write = 0;
7766
paul020709f2003-04-04 02:44:16 +00007767 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007768 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007769 {
7770 /* `router ospf' print. */
7771 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7772
7773 write++;
7774
paul68980082003-03-25 05:07:42 +00007775 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007776 return write;
7777
7778 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007779 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007780 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007781 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007782
7783 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007784 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007785 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007786 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007787
7788 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007789 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007790 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7791
7792 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007793 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007794 {
7795 vty_out (vty, "! Important: ensure reference bandwidth "
7796 "is consistent across all routers%s", VTY_NEWLINE);
7797 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7798 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7799 }
paul718e3742002-12-13 20:15:29 +00007800
7801 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007802 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007803 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7804 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7805 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007806 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007807 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007808
7809 /* Max-metric router-lsa print */
7810 config_write_stub_router (vty, ospf);
7811
paul718e3742002-12-13 20:15:29 +00007812 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007813 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007814 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007815 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007816
7817 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007818 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007819
7820 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007821 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7822 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7823 vty_out (vty, " passive-interface %s%s",
7824 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007825
paul1eb8ef22005-04-07 07:30:20 +00007826 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7827 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7828 oi->params->passive_interface == OSPF_IF_PASSIVE)
7829 vty_out (vty, " passive-interface %s %s%s",
7830 oi->ifp->name,
7831 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007832
7833 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007834 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007835
7836 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007837 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007838
7839 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007840 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007841
7842 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007843 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007844
7845 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007846 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007847
7848 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007849 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007850
7851 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007852 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007853
7854#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007855 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007856#endif /* HAVE_OPAQUE_LSA */
7857 }
7858
7859 return write;
7860}
7861
7862void
paul4dadc292005-05-06 21:37:42 +00007863ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007864{
7865 /* "show ip ospf" commands. */
7866 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7867 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7868
7869 /* "show ip ospf database" commands. */
7870 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7871 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7872 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7873 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7874 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7875 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7876 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7877 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7878 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7879 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7880 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7881 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7882 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7883 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7884
7885 /* "show ip ospf interface" commands. */
7886 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7887 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7888
7889 /* "show ip ospf neighbor" commands. */
7890 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7891 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7892 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7893 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7894 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7895 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7896 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7897 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7898 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7899 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7900 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7901 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7902 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7903 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7904
7905 /* "show ip ospf route" commands. */
7906 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7907 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007908 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7909 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007910}
7911
7912
7913/* ospfd's interface node. */
7914struct cmd_node interface_node =
7915{
7916 INTERFACE_NODE,
7917 "%s(config-if)# ",
7918 1
7919};
7920
7921/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007922static void
7923ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007924{
7925 /* Install interface node. */
7926 install_node (&interface_node, config_write_interface);
7927
7928 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007929 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007930 install_default (INTERFACE_NODE);
7931
7932 /* "description" commands. */
7933 install_element (INTERFACE_NODE, &interface_desc_cmd);
7934 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7935
7936 /* "ip ospf authentication" commands. */
7937 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7938 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7939 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7940 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7941 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7942 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7943 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7944 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7945 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7946 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7947
7948 /* "ip ospf message-digest-key" commands. */
7949 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7950 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7951 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7952 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7953
7954 /* "ip ospf cost" commands. */
7955 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7956 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7957 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7958 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7959
vincentba682532005-09-29 13:52:57 +00007960 /* "ip ospf mtu-ignore" commands. */
7961 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7962 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7963 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7964 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7965
paul718e3742002-12-13 20:15:29 +00007966 /* "ip ospf dead-interval" commands. */
7967 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7968 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007969 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7970 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007971 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7972 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007973
paul718e3742002-12-13 20:15:29 +00007974 /* "ip ospf hello-interval" commands. */
7975 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7976 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7977 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7978 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7979
7980 /* "ip ospf network" commands. */
7981 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7982 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7983
7984 /* "ip ospf priority" commands. */
7985 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7986 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7987 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7988 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7989
7990 /* "ip ospf retransmit-interval" commands. */
7991 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7992 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7993 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7994 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7995
7996 /* "ip ospf transmit-delay" commands. */
7997 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7998 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7999 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8000 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8001
8002 /* These commands are compatibitliy for previous version. */
8003 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8004 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8005 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8006 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
8007 install_element (INTERFACE_NODE, &ospf_cost_cmd);
8008 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
8009 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8010 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8011 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8012 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8013 install_element (INTERFACE_NODE, &ospf_network_cmd);
8014 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8015 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8016 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8017 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8018 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8019 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8020 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8021}
8022
8023/* Zebra node structure. */
8024struct cmd_node zebra_node =
8025{
8026 ZEBRA_NODE,
8027 "%s(config-router)#",
8028};
8029
paul4dadc292005-05-06 21:37:42 +00008030static void
8031ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008032{
8033 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8034 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8035 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8036 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8037 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8038 install_element (OSPF_NODE,
8039 &ospf_redistribute_source_metric_type_routemap_cmd);
8040 install_element (OSPF_NODE,
8041 &ospf_redistribute_source_type_metric_routemap_cmd);
8042 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8043 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8044 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8045
8046 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8047
8048 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8049 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8050
8051 install_element (OSPF_NODE,
8052 &ospf_default_information_originate_metric_type_cmd);
8053 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8054 install_element (OSPF_NODE,
8055 &ospf_default_information_originate_type_metric_cmd);
8056 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8057 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8058 install_element (OSPF_NODE,
8059 &ospf_default_information_originate_always_metric_type_cmd);
8060 install_element (OSPF_NODE,
8061 &ospf_default_information_originate_always_metric_cmd);
8062 install_element (OSPF_NODE,
8063 &ospf_default_information_originate_always_cmd);
8064 install_element (OSPF_NODE,
8065 &ospf_default_information_originate_always_type_metric_cmd);
8066 install_element (OSPF_NODE,
8067 &ospf_default_information_originate_always_type_cmd);
8068
8069 install_element (OSPF_NODE,
8070 &ospf_default_information_originate_metric_type_routemap_cmd);
8071 install_element (OSPF_NODE,
8072 &ospf_default_information_originate_metric_routemap_cmd);
8073 install_element (OSPF_NODE,
8074 &ospf_default_information_originate_routemap_cmd);
8075 install_element (OSPF_NODE,
8076 &ospf_default_information_originate_type_metric_routemap_cmd);
8077 install_element (OSPF_NODE,
8078 &ospf_default_information_originate_type_routemap_cmd);
8079 install_element (OSPF_NODE,
8080 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8081 install_element (OSPF_NODE,
8082 &ospf_default_information_originate_always_metric_routemap_cmd);
8083 install_element (OSPF_NODE,
8084 &ospf_default_information_originate_always_routemap_cmd);
8085 install_element (OSPF_NODE,
8086 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8087 install_element (OSPF_NODE,
8088 &ospf_default_information_originate_always_type_routemap_cmd);
8089
8090 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8091
8092 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8093 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8094 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8095
8096 install_element (OSPF_NODE, &ospf_distance_cmd);
8097 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8098 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8099 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8100 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8101 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8102 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8103 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8104 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8105 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8106 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8107 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8108 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8109 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8110 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8111 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8112 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8113 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8114#if 0
8115 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8116 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8117 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8118 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8119#endif /* 0 */
8120}
8121
8122struct cmd_node ospf_node =
8123{
8124 OSPF_NODE,
8125 "%s(config-router)# ",
8126 1
8127};
8128
8129
8130/* Install OSPF related vty commands. */
8131void
paul4dadc292005-05-06 21:37:42 +00008132ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008133{
8134 /* Install ospf top node. */
8135 install_node (&ospf_node, ospf_config_write);
8136
8137 /* "router ospf" commands. */
8138 install_element (CONFIG_NODE, &router_ospf_cmd);
8139 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8140
8141 install_default (OSPF_NODE);
8142
8143 /* "ospf router-id" commands. */
8144 install_element (OSPF_NODE, &ospf_router_id_cmd);
8145 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008146 install_element (OSPF_NODE, &router_ospf_id_cmd);
8147 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008148
8149 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008150 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8151 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8152 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8153 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008154
8155 /* "ospf abr-type" commands. */
8156 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8157 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8158
8159 /* "ospf rfc1583-compatible" commands. */
8160 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8161 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8162 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8163 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8164
8165 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008166 install_element (OSPF_NODE, &ospf_network_area_cmd);
8167 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008168
8169 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008170 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8171 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8172 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008173
8174 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008175 install_element (OSPF_NODE, &ospf_area_range_cmd);
8176 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8177 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8178 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8179 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8180 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8181 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8182 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8183 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8184 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8185 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008186
8187 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008188 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8189 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008190
paula2c62832003-04-23 17:01:31 +00008191 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8192 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008193
paula2c62832003-04-23 17:01:31 +00008194 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8195 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008196
paula2c62832003-04-23 17:01:31 +00008197 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8198 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008199
paula2c62832003-04-23 17:01:31 +00008200 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8201 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008202
paula2c62832003-04-23 17:01:31 +00008203 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8204 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8205 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008206
paula2c62832003-04-23 17:01:31 +00008207 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8208 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008209
paula2c62832003-04-23 17:01:31 +00008210 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8211 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008212
paula2c62832003-04-23 17:01:31 +00008213 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8214 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8215 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008216
paula2c62832003-04-23 17:01:31 +00008217 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8218 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8219 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008220
8221 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008222 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8223 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8224 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8225 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008226
paul718e3742002-12-13 20:15:29 +00008227 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008228 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8229 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8230 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8231 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8232 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8233 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008234
paula2c62832003-04-23 17:01:31 +00008235 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8236 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008237
paula2c62832003-04-23 17:01:31 +00008238 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8239 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008240
paula2c62832003-04-23 17:01:31 +00008241 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8242 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008243
paula2c62832003-04-23 17:01:31 +00008244 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8245 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008246
paula2c62832003-04-23 17:01:31 +00008247 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8248 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008249
8250 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008251 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8252 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008253 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8254 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8255
paul88d6cf32005-10-29 12:50:09 +00008256 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008257 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8258 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8259 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008260
paul88d6cf32005-10-29 12:50:09 +00008261 /* max-metric commands */
8262 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8263 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8264 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8265 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8266 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8267 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8268
8269 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008270 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8271 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008272
8273 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008274 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8275 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8276 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8277 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8278 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8279 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8280 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8281 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008282
8283 /* Init interface related vty commands. */
8284 ospf_vty_if_init ();
8285
8286 /* Init zebra related vty commands. */
8287 ospf_vty_zebra_init ();
8288}