blob: e28a89c514fa57318f9fc664e34ce81f8cacc0bd [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 {
2523 char timebuf[9];
2524 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;
2595 char timebuf[13]; /* XX:XX:XX.XXX(nul) */
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;
2709 char buf[9];
2710
paul718e3742002-12-13 20:15:29 +00002711 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002712 vty_out (vty, "%s is %s%s", ifp->name,
2713 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002714 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2715 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2716 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002717
2718 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002719 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002720 {
2721 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2722 return;
2723 }
ajsfd651fa2005-03-29 16:08:16 +00002724 else if (!is_up)
2725 {
2726 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2727 VTY_NEWLINE);
2728 return;
2729 }
2730
paul718e3742002-12-13 20:15:29 +00002731 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2732 {
2733 struct ospf_interface *oi = rn->info;
2734
2735 if (oi == NULL)
2736 continue;
2737
2738 /* Show OSPF interface information. */
2739 vty_out (vty, " Internet Address %s/%d,",
2740 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2741
hasso3fb9cd62004-10-19 19:44:43 +00002742 if (oi->connected->destination)
2743 vty_out (vty, " %s %s,",
2744 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2745 inet_ntoa (oi->connected->destination->u.prefix4));
2746
paul718e3742002-12-13 20:15:29 +00002747 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2748 VTY_NEWLINE);
2749
vincentba682532005-09-29 13:52:57 +00002750 vty_out (vty, " MTU mismatch detection:%s%s",
2751 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2752
paul718e3742002-12-13 20:15:29 +00002753 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002754 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002755 oi->output_cost, VTY_NEWLINE);
2756
2757 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2758 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2759 PRIORITY (oi), VTY_NEWLINE);
2760
2761 /* Show DR information. */
2762 if (DR (oi).s_addr == 0)
2763 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2764 else
2765 {
2766 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2767 if (nbr == NULL)
2768 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2769 else
2770 {
2771 vty_out (vty, " Designated Router (ID) %s,",
2772 inet_ntoa (nbr->router_id));
2773 vty_out (vty, " Interface Address %s%s",
2774 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2775 }
2776 }
2777
2778 /* Show BDR information. */
2779 if (BDR (oi).s_addr == 0)
2780 vty_out (vty, " No backup designated router on this network%s",
2781 VTY_NEWLINE);
2782 else
2783 {
2784 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2785 if (nbr == NULL)
2786 vty_out (vty, " No backup designated router on this network%s",
2787 VTY_NEWLINE);
2788 else
2789 {
2790 vty_out (vty, " Backup Designated Router (ID) %s,",
2791 inet_ntoa (nbr->router_id));
2792 vty_out (vty, " Interface Address %s%s",
2793 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2794 }
2795 }
ajsba6454e2005-02-08 15:37:30 +00002796
2797 vty_out (vty, " Multicast group memberships:");
2798 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2799 vty_out (vty, " OSPFAllRouters");
2800 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2801 vty_out (vty, " OSPFDesignatedRouters");
2802 if (!CHECK_FLAG(oi->multicast_memberships,
2803 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2804 vty_out (vty, " <None>");
2805 vty_out (vty, "%s", VTY_NEWLINE);
2806
paul718e3742002-12-13 20:15:29 +00002807 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002808 vty_out (vty, " Hello ");
2809 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2810 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2811 else
2812 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2813 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2814 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002815 OSPF_IF_PARAM (oi, v_wait),
2816 OSPF_IF_PARAM (oi, retransmit_interval),
2817 VTY_NEWLINE);
2818
2819 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002820 {
2821 int timer_slen = 9; /* length of "hh:mm:ss(nul)" */
2822
2823 /* for fast hello we also want to see the .XXXX ms part */
2824 if (OSPF_IF_PARAM (oi, fast_hello))
2825 timer_slen += 5;
2826
2827 vty_out (vty, " Hello due in %s%s",
2828 ospf_timer_dump (oi->t_hello, buf, timer_slen),
2829 VTY_NEWLINE);
2830 }
paul718e3742002-12-13 20:15:29 +00002831 else /* OSPF_IF_PASSIVE is set */
2832 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2833
2834 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002835 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002836 VTY_NEWLINE);
2837 }
2838}
2839
2840DEFUN (show_ip_ospf_interface,
2841 show_ip_ospf_interface_cmd,
2842 "show ip ospf interface [INTERFACE]",
2843 SHOW_STR
2844 IP_STR
2845 "OSPF information\n"
2846 "Interface information\n"
2847 "Interface name\n")
2848{
2849 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002850 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002851 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002852
paul020709f2003-04-04 02:44:16 +00002853 ospf = ospf_lookup ();
2854
paul718e3742002-12-13 20:15:29 +00002855 /* Show All Interfaces. */
2856 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002857 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2858 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002859 /* Interface name is specified. */
2860 else
2861 {
2862 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2863 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2864 else
paul68980082003-03-25 05:07:42 +00002865 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002866 }
2867
2868 return CMD_SUCCESS;
2869}
2870
paul4dadc292005-05-06 21:37:42 +00002871static void
pauld24f6e22005-10-21 09:23:12 +00002872show_ip_ospf_neighbour_header (struct vty *vty)
2873{
2874 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2875 VTY_NEWLINE,
2876 "Neighbor ID", "Pri", "State", "Dead Time",
2877 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
2878 VTY_NEWLINE);
2879}
2880
2881static void
paul718e3742002-12-13 20:15:29 +00002882show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2883{
2884 struct route_node *rn;
2885 struct ospf_neighbor *nbr;
2886 char msgbuf[16];
pauld24f6e22005-10-21 09:23:12 +00002887 char timebuf[14];
paul718e3742002-12-13 20:15:29 +00002888
2889 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2890 if ((nbr = rn->info))
2891 /* Do not show myself. */
2892 if (nbr != oi->nbr_self)
2893 /* Down state is not shown. */
2894 if (nbr->state != NSM_Down)
2895 {
2896 ospf_nbr_state_message (nbr, msgbuf, 16);
2897
2898 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00002899 vty_out (vty, "%-15s %3d %-15s ",
2900 "-", nbr->priority,
2901 msgbuf);
2902 else
2903 vty_out (vty, "%-15s %3d %-15s ",
2904 inet_ntoa (nbr->router_id), nbr->priority,
2905 msgbuf);
2906
2907 vty_out (vty, "%9s ",
2908 ospf_timer_dump (nbr->t_inactivity, timebuf,
2909 sizeof(timebuf)));
2910
paul718e3742002-12-13 20:15:29 +00002911 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00002912 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00002913 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2914 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2915 VTY_NEWLINE);
2916 }
2917}
2918
2919DEFUN (show_ip_ospf_neighbor,
2920 show_ip_ospf_neighbor_cmd,
2921 "show ip ospf neighbor",
2922 SHOW_STR
2923 IP_STR
2924 "OSPF information\n"
2925 "Neighbor list\n")
2926{
paul020709f2003-04-04 02:44:16 +00002927 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002928 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002929 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002930
paul020709f2003-04-04 02:44:16 +00002931 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002932 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002933 {
2934 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2935 return CMD_SUCCESS;
2936 }
2937
pauld24f6e22005-10-21 09:23:12 +00002938 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00002939
paul1eb8ef22005-04-07 07:30:20 +00002940 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
2941 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00002942
2943 return CMD_SUCCESS;
2944}
2945
2946DEFUN (show_ip_ospf_neighbor_all,
2947 show_ip_ospf_neighbor_all_cmd,
2948 "show ip ospf neighbor all",
2949 SHOW_STR
2950 IP_STR
2951 "OSPF information\n"
2952 "Neighbor list\n"
2953 "include down status neighbor\n")
2954{
paul68980082003-03-25 05:07:42 +00002955 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002956 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002957 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002958
paul68980082003-03-25 05:07:42 +00002959 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002960 {
2961 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2962 return CMD_SUCCESS;
2963 }
pauld24f6e22005-10-21 09:23:12 +00002964
2965 show_ip_ospf_neighbour_header (vty);
2966
paul1eb8ef22005-04-07 07:30:20 +00002967 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00002968 {
hasso52dc7ee2004-09-23 19:18:23 +00002969 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00002970 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00002971
2972 show_ip_ospf_neighbor_sub (vty, oi);
2973
2974 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00002975 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00002976 {
paul718e3742002-12-13 20:15:29 +00002977 if (nbr_nbma->nbr == NULL
2978 || nbr_nbma->nbr->state == NSM_Down)
2979 {
pauld24f6e22005-10-21 09:23:12 +00002980 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00002981 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00002982 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00002983 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2984 0, 0, 0, VTY_NEWLINE);
2985 }
2986 }
2987 }
2988
2989 return CMD_SUCCESS;
2990}
2991
2992DEFUN (show_ip_ospf_neighbor_int,
2993 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00002994 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00002995 SHOW_STR
2996 IP_STR
2997 "OSPF information\n"
2998 "Neighbor list\n"
2999 "Interface name\n")
3000{
paul020709f2003-04-04 02:44:16 +00003001 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003002 struct interface *ifp;
3003 struct route_node *rn;
3004
3005 ifp = if_lookup_by_name (argv[0]);
3006 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003007 {
hassobb5b7552005-08-21 20:01:15 +00003008 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003009 return CMD_WARNING;
3010 }
3011
paul020709f2003-04-04 02:44:16 +00003012 ospf = ospf_lookup ();
3013 if (ospf == NULL)
3014 {
3015 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3016 return CMD_SUCCESS;
3017 }
pauld24f6e22005-10-21 09:23:12 +00003018
3019 show_ip_ospf_neighbour_header (vty);
3020
hassobb5b7552005-08-21 20:01:15 +00003021 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003022 {
hassobb5b7552005-08-21 20:01:15 +00003023 struct ospf_interface *oi = rn->info;
3024
3025 if (oi == NULL)
3026 continue;
3027
paul718e3742002-12-13 20:15:29 +00003028 show_ip_ospf_neighbor_sub (vty, oi);
3029 }
3030
3031 return CMD_SUCCESS;
3032}
3033
paul4dadc292005-05-06 21:37:42 +00003034static void
paul718e3742002-12-13 20:15:29 +00003035show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3036 struct ospf_nbr_nbma *nbr_nbma)
3037{
3038 char timebuf[9];
3039
3040 /* Show neighbor ID. */
3041 vty_out (vty, " Neighbor %s,", "-");
3042
3043 /* Show interface address. */
3044 vty_out (vty, " interface address %s%s",
3045 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3046 /* Show Area ID. */
3047 vty_out (vty, " In the area %s via interface %s%s",
3048 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3049 /* Show neighbor priority and state. */
3050 vty_out (vty, " Neighbor priority is %d, State is %s,",
3051 nbr_nbma->priority, "Down");
3052 /* Show state changes. */
3053 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3054
3055 /* Show PollInterval */
3056 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3057
3058 /* Show poll-interval timer. */
3059 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003060 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3061 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003062
3063 /* Show poll-interval timer thread. */
3064 vty_out (vty, " Thread Poll Timer %s%s",
3065 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3066}
3067
paul4dadc292005-05-06 21:37:42 +00003068static void
paul718e3742002-12-13 20:15:29 +00003069show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3070 struct ospf_neighbor *nbr)
3071{
3072 char timebuf[9];
3073
3074 /* Show neighbor ID. */
3075 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3076 vty_out (vty, " Neighbor %s,", "-");
3077 else
3078 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3079
3080 /* Show interface address. */
3081 vty_out (vty, " interface address %s%s",
3082 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3083 /* Show Area ID. */
3084 vty_out (vty, " In the area %s via interface %s%s",
3085 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3086 /* Show neighbor priority and state. */
3087 vty_out (vty, " Neighbor priority is %d, State is %s,",
3088 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3089 /* Show state changes. */
3090 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3091
3092 /* Show Designated Rotuer ID. */
3093 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3094 /* Show Backup Designated Rotuer ID. */
3095 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3096 /* Show options. */
3097 vty_out (vty, " Options %d %s%s", nbr->options,
3098 ospf_options_dump (nbr->options), VTY_NEWLINE);
3099 /* Show Router Dead interval timer. */
3100 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003101 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3102 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003103 /* Show Database Summary list. */
3104 vty_out (vty, " Database Summary List %d%s",
3105 ospf_db_summary_count (nbr), VTY_NEWLINE);
3106 /* Show Link State Request list. */
3107 vty_out (vty, " Link State Request List %ld%s",
3108 ospf_ls_request_count (nbr), VTY_NEWLINE);
3109 /* Show Link State Retransmission list. */
3110 vty_out (vty, " Link State Retransmission List %ld%s",
3111 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3112 /* Show inactivity timer thread. */
3113 vty_out (vty, " Thread Inactivity Timer %s%s",
3114 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3115 /* Show Database Description retransmission thread. */
3116 vty_out (vty, " Thread Database Description Retransmision %s%s",
3117 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3118 /* Show Link State Request Retransmission thread. */
3119 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3120 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3121 /* Show Link State Update Retransmission thread. */
3122 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3123 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3124}
3125
3126DEFUN (show_ip_ospf_neighbor_id,
3127 show_ip_ospf_neighbor_id_cmd,
3128 "show ip ospf neighbor A.B.C.D",
3129 SHOW_STR
3130 IP_STR
3131 "OSPF information\n"
3132 "Neighbor list\n"
3133 "Neighbor ID\n")
3134{
paul020709f2003-04-04 02:44:16 +00003135 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003136 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003137 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003138 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003139 struct in_addr router_id;
3140 int ret;
3141
3142 ret = inet_aton (argv[0], &router_id);
3143 if (!ret)
3144 {
3145 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3146 return CMD_WARNING;
3147 }
3148
paul020709f2003-04-04 02:44:16 +00003149 ospf = ospf_lookup ();
3150 if (ospf == NULL)
3151 {
3152 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3153 return CMD_SUCCESS;
3154 }
3155
paul1eb8ef22005-04-07 07:30:20 +00003156 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3157 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3158 {
3159 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3160 return CMD_SUCCESS;
3161 }
paul718e3742002-12-13 20:15:29 +00003162
3163 /* Nothing to show. */
3164 return CMD_SUCCESS;
3165}
3166
3167DEFUN (show_ip_ospf_neighbor_detail,
3168 show_ip_ospf_neighbor_detail_cmd,
3169 "show ip ospf neighbor detail",
3170 SHOW_STR
3171 IP_STR
3172 "OSPF information\n"
3173 "Neighbor list\n"
3174 "detail of all neighbors\n")
3175{
paul020709f2003-04-04 02:44:16 +00003176 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003177 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003178 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003179
paul020709f2003-04-04 02:44:16 +00003180 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003181 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003182 {
3183 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3184 return CMD_SUCCESS;
3185 }
paul718e3742002-12-13 20:15:29 +00003186
paul1eb8ef22005-04-07 07:30:20 +00003187 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003188 {
paul718e3742002-12-13 20:15:29 +00003189 struct route_node *rn;
3190 struct ospf_neighbor *nbr;
3191
3192 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3193 if ((nbr = rn->info))
3194 if (nbr != oi->nbr_self)
3195 if (nbr->state != NSM_Down)
3196 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3197 }
3198
3199 return CMD_SUCCESS;
3200}
3201
3202DEFUN (show_ip_ospf_neighbor_detail_all,
3203 show_ip_ospf_neighbor_detail_all_cmd,
3204 "show ip ospf neighbor detail all",
3205 SHOW_STR
3206 IP_STR
3207 "OSPF information\n"
3208 "Neighbor list\n"
3209 "detail of all neighbors\n"
3210 "include down status neighbor\n")
3211{
paul020709f2003-04-04 02:44:16 +00003212 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003213 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003214 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003215
paul020709f2003-04-04 02:44:16 +00003216 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003217 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003218 {
3219 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3220 return CMD_SUCCESS;
3221 }
paul718e3742002-12-13 20:15:29 +00003222
paul1eb8ef22005-04-07 07:30:20 +00003223 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003224 {
paul718e3742002-12-13 20:15:29 +00003225 struct route_node *rn;
3226 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003227 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003228
3229 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3230 if ((nbr = rn->info))
3231 if (nbr != oi->nbr_self)
3232 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3233 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3234
3235 if (oi->type == OSPF_IFTYPE_NBMA)
3236 {
hasso52dc7ee2004-09-23 19:18:23 +00003237 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003238
paul1eb8ef22005-04-07 07:30:20 +00003239 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3240 if (nbr_nbma->nbr == NULL
3241 || nbr_nbma->nbr->state == NSM_Down)
3242 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003243 }
3244 }
3245
3246 return CMD_SUCCESS;
3247}
3248
3249DEFUN (show_ip_ospf_neighbor_int_detail,
3250 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003251 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003252 SHOW_STR
3253 IP_STR
3254 "OSPF information\n"
3255 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003256 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003257 "detail of all neighbors")
3258{
paul020709f2003-04-04 02:44:16 +00003259 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003260 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003261 struct interface *ifp;
3262 struct route_node *rn, *nrn;
3263 struct ospf_neighbor *nbr;
3264
3265 ifp = if_lookup_by_name (argv[0]);
3266 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003267 {
hassobb5b7552005-08-21 20:01:15 +00003268 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003269 return CMD_WARNING;
3270 }
3271
paul020709f2003-04-04 02:44:16 +00003272 ospf = ospf_lookup ();
3273 if (ospf == NULL)
3274 {
3275 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3276 return CMD_SUCCESS;
3277 }
paul68980082003-03-25 05:07:42 +00003278
paul718e3742002-12-13 20:15:29 +00003279
hassobb5b7552005-08-21 20:01:15 +00003280 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3281 if ((oi = rn->info))
3282 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3283 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003284 if (nbr != oi->nbr_self)
3285 if (nbr->state != NSM_Down)
3286 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003287
3288 return CMD_SUCCESS;
3289}
3290
3291
3292/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003293static int
paul020709f2003-04-04 02:44:16 +00003294show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003295{
paul718e3742002-12-13 20:15:29 +00003296 struct router_lsa *rl;
3297 struct summary_lsa *sl;
3298 struct as_external_lsa *asel;
3299 struct prefix_ipv4 p;
3300
3301 if (lsa != NULL)
3302 /* If self option is set, check LSA self flag. */
3303 if (self == 0 || IS_LSA_SELF (lsa))
3304 {
3305 /* LSA common part show. */
3306 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3307 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3308 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3309 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3310 /* LSA specific part show. */
3311 switch (lsa->data->type)
3312 {
3313 case OSPF_ROUTER_LSA:
3314 rl = (struct router_lsa *) lsa->data;
3315 vty_out (vty, " %-d", ntohs (rl->links));
3316 break;
3317 case OSPF_SUMMARY_LSA:
3318 sl = (struct summary_lsa *) lsa->data;
3319
3320 p.family = AF_INET;
3321 p.prefix = sl->header.id;
3322 p.prefixlen = ip_masklen (sl->mask);
3323 apply_mask_ipv4 (&p);
3324
3325 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3326 break;
3327 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003328 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003329 asel = (struct as_external_lsa *) lsa->data;
3330
3331 p.family = AF_INET;
3332 p.prefix = asel->header.id;
3333 p.prefixlen = ip_masklen (asel->mask);
3334 apply_mask_ipv4 (&p);
3335
3336 vty_out (vty, " %s %s/%d [0x%lx]",
3337 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3338 inet_ntoa (p.prefix), p.prefixlen,
3339 (u_long)ntohl (asel->e[0].route_tag));
3340 break;
3341 case OSPF_NETWORK_LSA:
3342 case OSPF_ASBR_SUMMARY_LSA:
3343#ifdef HAVE_OPAQUE_LSA
3344 case OSPF_OPAQUE_LINK_LSA:
3345 case OSPF_OPAQUE_AREA_LSA:
3346 case OSPF_OPAQUE_AS_LSA:
3347#endif /* HAVE_OPAQUE_LSA */
3348 default:
3349 break;
3350 }
3351 vty_out (vty, VTY_NEWLINE);
3352 }
3353
3354 return 0;
3355}
3356
hassoeb1ce602004-10-08 08:17:22 +00003357const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003358{
3359 "unknown",
3360 "Router Link States",
3361 "Net Link States",
3362 "Summary Link States",
3363 "ASBR-Summary Link States",
3364 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003365 "Group Membership LSA",
3366 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003367#ifdef HAVE_OPAQUE_LSA
3368 "Type-8 LSA",
3369 "Link-Local Opaque-LSA",
3370 "Area-Local Opaque-LSA",
3371 "AS-external Opaque-LSA",
3372#endif /* HAVE_OPAQUE_LSA */
3373};
3374
3375#define SHOW_OSPF_COMMON_HEADER \
3376 "Link ID ADV Router Age Seq# CkSum"
3377
hassoeb1ce602004-10-08 08:17:22 +00003378const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003379{
3380 "",
3381 "Link ID ADV Router Age Seq# CkSum Link count",
3382 "Link ID ADV Router Age Seq# CkSum",
3383 "Link ID ADV Router Age Seq# CkSum Route",
3384 "Link ID ADV Router Age Seq# CkSum",
3385 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003386 " --- header for Group Member ----",
3387 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003388#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003389 " --- type-8 ---",
3390 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3391 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3392 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3393#endif /* HAVE_OPAQUE_LSA */
3394};
3395
hassoeb1ce602004-10-08 08:17:22 +00003396const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003397{
3398 "Self-originated",
3399 "Checked",
3400 "Received",
3401 "Approved",
3402 "Discard",
paul4957f492003-06-27 01:28:45 +00003403 "Translated",
paul4957f492003-06-27 01:28:45 +00003404};
3405
paul4dadc292005-05-06 21:37:42 +00003406static void
paul718e3742002-12-13 20:15:29 +00003407show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3408{
3409 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003410
paul718e3742002-12-13 20:15:29 +00003411 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003412 vty_out (vty, " Options: 0x%-2x : %s%s",
3413 lsa->data->options,
3414 ospf_options_dump(lsa->data->options),
3415 VTY_NEWLINE);
3416 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003417 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003418 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3419 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003420
3421 if (lsa->data->type == OSPF_ROUTER_LSA)
3422 {
3423 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3424
3425 if (rlsa->flags)
3426 vty_out (vty, " :%s%s%s%s",
3427 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3428 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3429 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3430 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3431
3432 vty_out (vty, "%s", VTY_NEWLINE);
3433 }
3434 vty_out (vty, " LS Type: %s%s",
3435 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3436 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3437 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3438 vty_out (vty, " Advertising Router: %s%s",
3439 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3440 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3441 VTY_NEWLINE);
3442 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3443 VTY_NEWLINE);
3444 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3445}
3446
hassoeb1ce602004-10-08 08:17:22 +00003447const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003448{
3449 "(null)",
3450 "another Router (point-to-point)",
3451 "a Transit Network",
3452 "Stub Network",
3453 "a Virtual Link",
3454};
3455
hassoeb1ce602004-10-08 08:17:22 +00003456const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003457{
3458 "(null)",
3459 "Neighboring Router ID",
3460 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003461 "Net",
paul718e3742002-12-13 20:15:29 +00003462 "Neighboring Router ID",
3463};
3464
hassoeb1ce602004-10-08 08:17:22 +00003465const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003466{
3467 "(null)",
3468 "Router Interface address",
3469 "Router Interface address",
3470 "Network Mask",
3471 "Router Interface address",
3472};
3473
3474/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003475static void
paul718e3742002-12-13 20:15:29 +00003476show_ip_ospf_database_router_links (struct vty *vty,
3477 struct router_lsa *rl)
3478{
3479 int len, i, type;
3480
3481 len = ntohs (rl->header.length) - 4;
3482 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3483 {
3484 type = rl->link[i].type;
3485
3486 vty_out (vty, " Link connected to: %s%s",
3487 link_type_desc[type], VTY_NEWLINE);
3488 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3489 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3490 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3491 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3492 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3493 vty_out (vty, " TOS 0 Metric: %d%s",
3494 ntohs (rl->link[i].metric), VTY_NEWLINE);
3495 vty_out (vty, "%s", VTY_NEWLINE);
3496 }
3497}
3498
3499/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003500static int
paul718e3742002-12-13 20:15:29 +00003501show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3502{
3503 if (lsa != NULL)
3504 {
3505 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3506
3507 show_ip_ospf_database_header (vty, lsa);
3508
3509 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3510 VTY_NEWLINE, VTY_NEWLINE);
3511
3512 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003513 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003514 }
3515
3516 return 0;
3517}
3518
3519/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003520static int
paul718e3742002-12-13 20:15:29 +00003521show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3522{
3523 int length, i;
3524
3525 if (lsa != NULL)
3526 {
3527 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3528
3529 show_ip_ospf_database_header (vty, lsa);
3530
3531 vty_out (vty, " Network Mask: /%d%s",
3532 ip_masklen (nl->mask), VTY_NEWLINE);
3533
3534 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3535
3536 for (i = 0; length > 0; i++, length -= 4)
3537 vty_out (vty, " Attached Router: %s%s",
3538 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3539
3540 vty_out (vty, "%s", VTY_NEWLINE);
3541 }
3542
3543 return 0;
3544}
3545
3546/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003547static int
paul718e3742002-12-13 20:15:29 +00003548show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3549{
3550 if (lsa != NULL)
3551 {
3552 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3553
3554 show_ip_ospf_database_header (vty, lsa);
3555
3556 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3557 VTY_NEWLINE);
3558 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3559 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003560 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003561 }
3562
3563 return 0;
3564}
3565
3566/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003567static int
paul718e3742002-12-13 20:15:29 +00003568show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3569{
3570 if (lsa != NULL)
3571 {
3572 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3573
3574 show_ip_ospf_database_header (vty, lsa);
3575
3576 vty_out (vty, " Network Mask: /%d%s",
3577 ip_masklen (sl->mask), VTY_NEWLINE);
3578 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3579 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003580 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003581 }
3582
3583 return 0;
3584}
3585
3586/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003587static int
paul718e3742002-12-13 20:15:29 +00003588show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3589{
3590 if (lsa != NULL)
3591 {
3592 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3593
3594 show_ip_ospf_database_header (vty, lsa);
3595
3596 vty_out (vty, " Network Mask: /%d%s",
3597 ip_masklen (al->mask), VTY_NEWLINE);
3598 vty_out (vty, " Metric Type: %s%s",
3599 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3600 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3601 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3602 vty_out (vty, " Metric: %d%s",
3603 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3604 vty_out (vty, " Forward Address: %s%s",
3605 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3606
3607 vty_out (vty, " External Route Tag: %lu%s%s",
3608 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3609 }
3610
3611 return 0;
3612}
3613
ajs2a42e282004-12-08 18:43:03 +00003614/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003615static int
paul718e3742002-12-13 20:15:29 +00003616show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3617{
3618 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3619
3620 /* show_ip_ospf_database_header (vty, lsa); */
3621
ajs2a42e282004-12-08 18:43:03 +00003622 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003623 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003624 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003625 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3626 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003627 zlog_debug( " TOS: 0%s", "\n");
3628 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003629 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003630 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003631 inet_ntoa (al->e[0].fwd_addr), "\n");
3632
ajs2a42e282004-12-08 18:43:03 +00003633 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003634 ntohl (al->e[0].route_tag), "\n", "\n");
3635
3636 return 0;
3637}
3638
3639/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003640static int
paul718e3742002-12-13 20:15:29 +00003641show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3642{
3643 if (lsa != NULL)
3644 {
3645 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3646
3647 show_ip_ospf_database_header (vty, lsa);
3648
3649 vty_out (vty, " Network Mask: /%d%s",
3650 ip_masklen (al->mask), VTY_NEWLINE);
3651 vty_out (vty, " Metric Type: %s%s",
3652 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3653 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3654 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3655 vty_out (vty, " Metric: %d%s",
3656 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3657 vty_out (vty, " NSSA: Forward Address: %s%s",
3658 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3659
3660 vty_out (vty, " External Route Tag: %u%s%s",
3661 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3662 }
3663
3664 return 0;
3665}
3666
paul4dadc292005-05-06 21:37:42 +00003667static int
paul718e3742002-12-13 20:15:29 +00003668show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3669{
3670 return 0;
3671}
3672
3673#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003674static int
paul718e3742002-12-13 20:15:29 +00003675show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3676{
3677 if (lsa != NULL)
3678 {
3679 show_ip_ospf_database_header (vty, lsa);
3680 show_opaque_info_detail (vty, lsa);
3681
3682 vty_out (vty, "%s", VTY_NEWLINE);
3683 }
3684 return 0;
3685}
3686#endif /* HAVE_OPAQUE_LSA */
3687
3688int (*show_function[])(struct vty *, struct ospf_lsa *) =
3689{
3690 NULL,
3691 show_router_lsa_detail,
3692 show_network_lsa_detail,
3693 show_summary_lsa_detail,
3694 show_summary_asbr_lsa_detail,
3695 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003696 show_func_dummy,
3697 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003698#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003699 NULL, /* type-8 */
3700 show_opaque_lsa_detail,
3701 show_opaque_lsa_detail,
3702 show_opaque_lsa_detail,
3703#endif /* HAVE_OPAQUE_LSA */
3704};
3705
paul4dadc292005-05-06 21:37:42 +00003706static void
paul718e3742002-12-13 20:15:29 +00003707show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3708 struct in_addr *adv_router)
3709{
3710 memset (lp, 0, sizeof (struct prefix_ls));
3711 lp->family = 0;
3712 if (id == NULL)
3713 lp->prefixlen = 0;
3714 else if (adv_router == NULL)
3715 {
3716 lp->prefixlen = 32;
3717 lp->id = *id;
3718 }
3719 else
3720 {
3721 lp->prefixlen = 64;
3722 lp->id = *id;
3723 lp->adv_router = *adv_router;
3724 }
3725}
3726
paul4dadc292005-05-06 21:37:42 +00003727static void
paul718e3742002-12-13 20:15:29 +00003728show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3729 struct in_addr *id, struct in_addr *adv_router)
3730{
3731 struct prefix_ls lp;
3732 struct route_node *rn, *start;
3733 struct ospf_lsa *lsa;
3734
3735 show_lsa_prefix_set (vty, &lp, id, adv_router);
3736 start = route_node_get (rt, (struct prefix *) &lp);
3737 if (start)
3738 {
3739 route_lock_node (start);
3740 for (rn = start; rn; rn = route_next_until (rn, start))
3741 if ((lsa = rn->info))
3742 {
paul718e3742002-12-13 20:15:29 +00003743 if (show_function[lsa->data->type] != NULL)
3744 show_function[lsa->data->type] (vty, lsa);
3745 }
3746 route_unlock_node (start);
3747 }
3748}
3749
3750/* Show detail LSA information
3751 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003752static void
paul020709f2003-04-04 02:44:16 +00003753show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003754 struct in_addr *id, struct in_addr *adv_router)
3755{
hasso52dc7ee2004-09-23 19:18:23 +00003756 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003757 struct ospf_area *area;
3758
paul718e3742002-12-13 20:15:29 +00003759 switch (type)
3760 {
3761 case OSPF_AS_EXTERNAL_LSA:
3762#ifdef HAVE_OPAQUE_LSA
3763 case OSPF_OPAQUE_AS_LSA:
3764#endif /* HAVE_OPAQUE_LSA */
3765 vty_out (vty, " %s %s%s",
3766 show_database_desc[type],
3767 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003768 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003769 break;
3770 default:
paul1eb8ef22005-04-07 07:30:20 +00003771 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003772 {
paul718e3742002-12-13 20:15:29 +00003773 vty_out (vty, "%s %s (Area %s)%s%s",
3774 VTY_NEWLINE, show_database_desc[type],
3775 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3776 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3777 }
3778 break;
3779 }
3780}
3781
paul4dadc292005-05-06 21:37:42 +00003782static void
paul718e3742002-12-13 20:15:29 +00003783show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3784 struct in_addr *adv_router)
3785{
3786 struct route_node *rn;
3787 struct ospf_lsa *lsa;
3788
3789 for (rn = route_top (rt); rn; rn = route_next (rn))
3790 if ((lsa = rn->info))
3791 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3792 {
paul718e3742002-12-13 20:15:29 +00003793 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3794 continue;
paul718e3742002-12-13 20:15:29 +00003795 if (show_function[lsa->data->type] != NULL)
3796 show_function[lsa->data->type] (vty, lsa);
3797 }
3798}
3799
3800/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003801static void
paul020709f2003-04-04 02:44:16 +00003802show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003803 struct in_addr *adv_router)
3804{
hasso52dc7ee2004-09-23 19:18:23 +00003805 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003806 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003807
3808 switch (type)
3809 {
3810 case OSPF_AS_EXTERNAL_LSA:
3811#ifdef HAVE_OPAQUE_LSA
3812 case OSPF_OPAQUE_AS_LSA:
3813#endif /* HAVE_OPAQUE_LSA */
3814 vty_out (vty, " %s %s%s",
3815 show_database_desc[type],
3816 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003817 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003818 adv_router);
3819 break;
3820 default:
paul1eb8ef22005-04-07 07:30:20 +00003821 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003822 {
paul718e3742002-12-13 20:15:29 +00003823 vty_out (vty, "%s %s (Area %s)%s%s",
3824 VTY_NEWLINE, show_database_desc[type],
3825 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3826 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3827 adv_router);
3828 }
3829 break;
3830 }
3831}
3832
paul4dadc292005-05-06 21:37:42 +00003833static void
paul020709f2003-04-04 02:44:16 +00003834show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003835{
paul020709f2003-04-04 02:44:16 +00003836 struct ospf_lsa *lsa;
3837 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003838 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003839 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003840 int type;
3841
paul1eb8ef22005-04-07 07:30:20 +00003842 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003843 {
paul718e3742002-12-13 20:15:29 +00003844 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3845 {
3846 switch (type)
3847 {
3848 case OSPF_AS_EXTERNAL_LSA:
3849#ifdef HAVE_OPAQUE_LSA
3850 case OSPF_OPAQUE_AS_LSA:
3851#endif /* HAVE_OPAQUE_LSA */
3852 continue;
3853 default:
3854 break;
3855 }
3856 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3857 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3858 {
3859 vty_out (vty, " %s (Area %s)%s%s",
3860 show_database_desc[type],
3861 ospf_area_desc_string (area),
3862 VTY_NEWLINE, VTY_NEWLINE);
3863 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3864
paul020709f2003-04-04 02:44:16 +00003865 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3866 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003867
3868 vty_out (vty, "%s", VTY_NEWLINE);
3869 }
3870 }
3871 }
3872
3873 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3874 {
3875 switch (type)
3876 {
3877 case OSPF_AS_EXTERNAL_LSA:
3878#ifdef HAVE_OPAQUE_LSA
3879 case OSPF_OPAQUE_AS_LSA:
3880#endif /* HAVE_OPAQUE_LSA */
3881 break;;
3882 default:
3883 continue;
3884 }
paul68980082003-03-25 05:07:42 +00003885 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3886 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003887 {
3888 vty_out (vty, " %s%s%s",
3889 show_database_desc[type],
3890 VTY_NEWLINE, VTY_NEWLINE);
3891 vty_out (vty, "%s%s", show_database_header[type],
3892 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003893
3894 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3895 show_lsa_summary (vty, lsa, self);
3896
paul718e3742002-12-13 20:15:29 +00003897 vty_out (vty, "%s", VTY_NEWLINE);
3898 }
3899 }
3900
3901 vty_out (vty, "%s", VTY_NEWLINE);
3902}
3903
paul4dadc292005-05-06 21:37:42 +00003904static void
paul020709f2003-04-04 02:44:16 +00003905show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003906{
hasso52dc7ee2004-09-23 19:18:23 +00003907 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003908 struct ospf_lsa *lsa;
3909
3910 vty_out (vty, "%s MaxAge Link States:%s%s",
3911 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3912
paul1eb8ef22005-04-07 07:30:20 +00003913 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3914 {
3915 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3916 vty_out (vty, "Link State ID: %s%s",
3917 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3918 vty_out (vty, "Advertising Router: %s%s",
3919 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3920 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3921 vty_out (vty, "%s", VTY_NEWLINE);
3922 }
paul718e3742002-12-13 20:15:29 +00003923}
3924
paul718e3742002-12-13 20:15:29 +00003925#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3926#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003927
3928#ifdef HAVE_OPAQUE_LSA
3929#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3930#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3931#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3932#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3933#else /* HAVE_OPAQUE_LSA */
3934#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3935#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3936#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3937#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3938#endif /* HAVE_OPAQUE_LSA */
3939
3940#define OSPF_LSA_TYPES_CMD_STR \
3941 "asbr-summary|external|network|router|summary" \
3942 OSPF_LSA_TYPE_NSSA_CMD_STR \
3943 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3944
3945#define OSPF_LSA_TYPES_DESC \
3946 "ASBR summary link states\n" \
3947 "External link states\n" \
3948 "Network link states\n" \
3949 "Router link states\n" \
3950 "Network summary link states\n" \
3951 OSPF_LSA_TYPE_NSSA_DESC \
3952 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3953 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3954 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3955
3956DEFUN (show_ip_ospf_database,
3957 show_ip_ospf_database_cmd,
3958 "show ip ospf database",
3959 SHOW_STR
3960 IP_STR
3961 "OSPF information\n"
3962 "Database summary\n")
3963{
paul020709f2003-04-04 02:44:16 +00003964 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003965 int type, ret;
3966 struct in_addr id, adv_router;
3967
paul020709f2003-04-04 02:44:16 +00003968 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003969 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003970 return CMD_SUCCESS;
3971
3972 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003973 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003974
3975 /* Show all LSA. */
3976 if (argc == 0)
3977 {
paul020709f2003-04-04 02:44:16 +00003978 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003979 return CMD_SUCCESS;
3980 }
3981
3982 /* Set database type to show. */
3983 if (strncmp (argv[0], "r", 1) == 0)
3984 type = OSPF_ROUTER_LSA;
3985 else if (strncmp (argv[0], "ne", 2) == 0)
3986 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003987 else if (strncmp (argv[0], "ns", 2) == 0)
3988 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003989 else if (strncmp (argv[0], "su", 2) == 0)
3990 type = OSPF_SUMMARY_LSA;
3991 else if (strncmp (argv[0], "a", 1) == 0)
3992 type = OSPF_ASBR_SUMMARY_LSA;
3993 else if (strncmp (argv[0], "e", 1) == 0)
3994 type = OSPF_AS_EXTERNAL_LSA;
3995 else if (strncmp (argv[0], "se", 2) == 0)
3996 {
paul020709f2003-04-04 02:44:16 +00003997 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003998 return CMD_SUCCESS;
3999 }
4000 else if (strncmp (argv[0], "m", 1) == 0)
4001 {
paul020709f2003-04-04 02:44:16 +00004002 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004003 return CMD_SUCCESS;
4004 }
4005#ifdef HAVE_OPAQUE_LSA
4006 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4007 type = OSPF_OPAQUE_LINK_LSA;
4008 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4009 type = OSPF_OPAQUE_AREA_LSA;
4010 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4011 type = OSPF_OPAQUE_AS_LSA;
4012#endif /* HAVE_OPAQUE_LSA */
4013 else
4014 return CMD_WARNING;
4015
4016 /* `show ip ospf database LSA'. */
4017 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004018 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004019 else if (argc >= 2)
4020 {
4021 ret = inet_aton (argv[1], &id);
4022 if (!ret)
4023 return CMD_WARNING;
4024
4025 /* `show ip ospf database LSA ID'. */
4026 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004027 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004028 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4029 else if (argc == 3)
4030 {
4031 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004032 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004033 else
4034 {
4035 ret = inet_aton (argv[2], &adv_router);
4036 if (!ret)
4037 return CMD_WARNING;
4038 }
paul020709f2003-04-04 02:44:16 +00004039 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004040 }
4041 }
4042
4043 return CMD_SUCCESS;
4044}
4045
4046ALIAS (show_ip_ospf_database,
4047 show_ip_ospf_database_type_cmd,
4048 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4049 SHOW_STR
4050 IP_STR
4051 "OSPF information\n"
4052 "Database summary\n"
4053 OSPF_LSA_TYPES_DESC
4054 "LSAs in MaxAge list\n"
4055 "Self-originated link states\n")
4056
4057ALIAS (show_ip_ospf_database,
4058 show_ip_ospf_database_type_id_cmd,
4059 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4060 SHOW_STR
4061 IP_STR
4062 "OSPF information\n"
4063 "Database summary\n"
4064 OSPF_LSA_TYPES_DESC
4065 "Link State ID (as an IP address)\n")
4066
4067ALIAS (show_ip_ospf_database,
4068 show_ip_ospf_database_type_id_adv_router_cmd,
4069 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4070 SHOW_STR
4071 IP_STR
4072 "OSPF information\n"
4073 "Database summary\n"
4074 OSPF_LSA_TYPES_DESC
4075 "Link State ID (as an IP address)\n"
4076 "Advertising Router link states\n"
4077 "Advertising Router (as an IP address)\n")
4078
4079ALIAS (show_ip_ospf_database,
4080 show_ip_ospf_database_type_id_self_cmd,
4081 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4082 SHOW_STR
4083 IP_STR
4084 "OSPF information\n"
4085 "Database summary\n"
4086 OSPF_LSA_TYPES_DESC
4087 "Link State ID (as an IP address)\n"
4088 "Self-originated link states\n"
4089 "\n")
4090
4091DEFUN (show_ip_ospf_database_type_adv_router,
4092 show_ip_ospf_database_type_adv_router_cmd,
4093 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4094 SHOW_STR
4095 IP_STR
4096 "OSPF information\n"
4097 "Database summary\n"
4098 OSPF_LSA_TYPES_DESC
4099 "Advertising Router link states\n"
4100 "Advertising Router (as an IP address)\n")
4101{
paul020709f2003-04-04 02:44:16 +00004102 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004103 int type, ret;
4104 struct in_addr adv_router;
4105
paul020709f2003-04-04 02:44:16 +00004106 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004107 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00004108 return CMD_SUCCESS;
4109
4110 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004111 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004112
4113 if (argc != 2)
4114 return CMD_WARNING;
4115
4116 /* Set database type to show. */
4117 if (strncmp (argv[0], "r", 1) == 0)
4118 type = OSPF_ROUTER_LSA;
4119 else if (strncmp (argv[0], "ne", 2) == 0)
4120 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004121 else if (strncmp (argv[0], "ns", 2) == 0)
4122 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004123 else if (strncmp (argv[0], "s", 1) == 0)
4124 type = OSPF_SUMMARY_LSA;
4125 else if (strncmp (argv[0], "a", 1) == 0)
4126 type = OSPF_ASBR_SUMMARY_LSA;
4127 else if (strncmp (argv[0], "e", 1) == 0)
4128 type = OSPF_AS_EXTERNAL_LSA;
4129#ifdef HAVE_OPAQUE_LSA
4130 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4131 type = OSPF_OPAQUE_LINK_LSA;
4132 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4133 type = OSPF_OPAQUE_AREA_LSA;
4134 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4135 type = OSPF_OPAQUE_AS_LSA;
4136#endif /* HAVE_OPAQUE_LSA */
4137 else
4138 return CMD_WARNING;
4139
4140 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4141 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004142 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004143 else
4144 {
4145 ret = inet_aton (argv[1], &adv_router);
4146 if (!ret)
4147 return CMD_WARNING;
4148 }
4149
paul020709f2003-04-04 02:44:16 +00004150 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004151
4152 return CMD_SUCCESS;
4153}
4154
4155ALIAS (show_ip_ospf_database_type_adv_router,
4156 show_ip_ospf_database_type_self_cmd,
4157 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4158 SHOW_STR
4159 IP_STR
4160 "OSPF information\n"
4161 "Database summary\n"
4162 OSPF_LSA_TYPES_DESC
4163 "Self-originated link states\n")
4164
4165
4166DEFUN (ip_ospf_authentication_args,
4167 ip_ospf_authentication_args_addr_cmd,
4168 "ip ospf authentication (null|message-digest) A.B.C.D",
4169 "IP Information\n"
4170 "OSPF interface commands\n"
4171 "Enable authentication on this interface\n"
4172 "Use null authentication\n"
4173 "Use message-digest authentication\n"
4174 "Address of interface")
4175{
4176 struct interface *ifp;
4177 struct in_addr addr;
4178 int ret;
4179 struct ospf_if_params *params;
4180
4181 ifp = vty->index;
4182 params = IF_DEF_PARAMS (ifp);
4183
4184 if (argc == 2)
4185 {
4186 ret = inet_aton(argv[1], &addr);
4187 if (!ret)
4188 {
4189 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4190 VTY_NEWLINE);
4191 return CMD_WARNING;
4192 }
4193
4194 params = ospf_get_if_params (ifp, addr);
4195 ospf_if_update_params (ifp, addr);
4196 }
4197
4198 /* Handle null authentication */
4199 if ( argv[0][0] == 'n' )
4200 {
4201 SET_IF_PARAM (params, auth_type);
4202 params->auth_type = OSPF_AUTH_NULL;
4203 return CMD_SUCCESS;
4204 }
4205
4206 /* Handle message-digest authentication */
4207 if ( argv[0][0] == 'm' )
4208 {
4209 SET_IF_PARAM (params, auth_type);
4210 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4211 return CMD_SUCCESS;
4212 }
4213
4214 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4215 return CMD_WARNING;
4216}
4217
4218ALIAS (ip_ospf_authentication_args,
4219 ip_ospf_authentication_args_cmd,
4220 "ip ospf authentication (null|message-digest)",
4221 "IP Information\n"
4222 "OSPF interface commands\n"
4223 "Enable authentication on this interface\n"
4224 "Use null authentication\n"
4225 "Use message-digest authentication\n")
4226
4227DEFUN (ip_ospf_authentication,
4228 ip_ospf_authentication_addr_cmd,
4229 "ip ospf authentication A.B.C.D",
4230 "IP Information\n"
4231 "OSPF interface commands\n"
4232 "Enable authentication on this interface\n"
4233 "Address of interface")
4234{
4235 struct interface *ifp;
4236 struct in_addr addr;
4237 int ret;
4238 struct ospf_if_params *params;
4239
4240 ifp = vty->index;
4241 params = IF_DEF_PARAMS (ifp);
4242
4243 if (argc == 1)
4244 {
4245 ret = inet_aton(argv[1], &addr);
4246 if (!ret)
4247 {
4248 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4249 VTY_NEWLINE);
4250 return CMD_WARNING;
4251 }
4252
4253 params = ospf_get_if_params (ifp, addr);
4254 ospf_if_update_params (ifp, addr);
4255 }
4256
4257 SET_IF_PARAM (params, auth_type);
4258 params->auth_type = OSPF_AUTH_SIMPLE;
4259
4260 return CMD_SUCCESS;
4261}
4262
4263ALIAS (ip_ospf_authentication,
4264 ip_ospf_authentication_cmd,
4265 "ip ospf authentication",
4266 "IP Information\n"
4267 "OSPF interface commands\n"
4268 "Enable authentication on this interface\n")
4269
4270DEFUN (no_ip_ospf_authentication,
4271 no_ip_ospf_authentication_addr_cmd,
4272 "no ip ospf authentication A.B.C.D",
4273 NO_STR
4274 "IP Information\n"
4275 "OSPF interface commands\n"
4276 "Enable authentication on this interface\n"
4277 "Address of interface")
4278{
4279 struct interface *ifp;
4280 struct in_addr addr;
4281 int ret;
4282 struct ospf_if_params *params;
4283
4284 ifp = vty->index;
4285 params = IF_DEF_PARAMS (ifp);
4286
4287 if (argc == 1)
4288 {
4289 ret = inet_aton(argv[1], &addr);
4290 if (!ret)
4291 {
4292 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4293 VTY_NEWLINE);
4294 return CMD_WARNING;
4295 }
4296
4297 params = ospf_lookup_if_params (ifp, addr);
4298 if (params == NULL)
4299 return CMD_SUCCESS;
4300 }
4301
4302 params->auth_type = OSPF_AUTH_NOTSET;
4303 UNSET_IF_PARAM (params, auth_type);
4304
4305 if (params != IF_DEF_PARAMS (ifp))
4306 {
4307 ospf_free_if_params (ifp, addr);
4308 ospf_if_update_params (ifp, addr);
4309 }
4310
4311 return CMD_SUCCESS;
4312}
4313
4314ALIAS (no_ip_ospf_authentication,
4315 no_ip_ospf_authentication_cmd,
4316 "no ip ospf authentication",
4317 NO_STR
4318 "IP Information\n"
4319 "OSPF interface commands\n"
4320 "Enable authentication on this interface\n")
4321
4322DEFUN (ip_ospf_authentication_key,
4323 ip_ospf_authentication_key_addr_cmd,
4324 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4325 "IP Information\n"
4326 "OSPF interface commands\n"
4327 "Authentication password (key)\n"
4328 "The OSPF password (key)\n"
4329 "Address of interface")
4330{
4331 struct interface *ifp;
4332 struct in_addr addr;
4333 int ret;
4334 struct ospf_if_params *params;
4335
4336 ifp = vty->index;
4337 params = IF_DEF_PARAMS (ifp);
4338
4339 if (argc == 2)
4340 {
4341 ret = inet_aton(argv[1], &addr);
4342 if (!ret)
4343 {
4344 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4345 VTY_NEWLINE);
4346 return CMD_WARNING;
4347 }
4348
4349 params = ospf_get_if_params (ifp, addr);
4350 ospf_if_update_params (ifp, addr);
4351 }
4352
4353
4354 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004355 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004356 SET_IF_PARAM (params, auth_simple);
4357
4358 return CMD_SUCCESS;
4359}
4360
4361ALIAS (ip_ospf_authentication_key,
4362 ip_ospf_authentication_key_cmd,
4363 "ip ospf authentication-key AUTH_KEY",
4364 "IP Information\n"
4365 "OSPF interface commands\n"
4366 "Authentication password (key)\n"
4367 "The OSPF password (key)")
4368
4369ALIAS (ip_ospf_authentication_key,
4370 ospf_authentication_key_cmd,
4371 "ospf authentication-key AUTH_KEY",
4372 "OSPF interface commands\n"
4373 "Authentication password (key)\n"
4374 "The OSPF password (key)")
4375
4376DEFUN (no_ip_ospf_authentication_key,
4377 no_ip_ospf_authentication_key_addr_cmd,
4378 "no ip ospf authentication-key A.B.C.D",
4379 NO_STR
4380 "IP Information\n"
4381 "OSPF interface commands\n"
4382 "Authentication password (key)\n"
4383 "Address of interface")
4384{
4385 struct interface *ifp;
4386 struct in_addr addr;
4387 int ret;
4388 struct ospf_if_params *params;
4389
4390 ifp = vty->index;
4391 params = IF_DEF_PARAMS (ifp);
4392
4393 if (argc == 2)
4394 {
4395 ret = inet_aton(argv[1], &addr);
4396 if (!ret)
4397 {
4398 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4399 VTY_NEWLINE);
4400 return CMD_WARNING;
4401 }
4402
4403 params = ospf_lookup_if_params (ifp, addr);
4404 if (params == NULL)
4405 return CMD_SUCCESS;
4406 }
4407
4408 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4409 UNSET_IF_PARAM (params, auth_simple);
4410
4411 if (params != IF_DEF_PARAMS (ifp))
4412 {
4413 ospf_free_if_params (ifp, addr);
4414 ospf_if_update_params (ifp, addr);
4415 }
4416
4417 return CMD_SUCCESS;
4418}
4419
4420ALIAS (no_ip_ospf_authentication_key,
4421 no_ip_ospf_authentication_key_cmd,
4422 "no ip ospf authentication-key",
4423 NO_STR
4424 "IP Information\n"
4425 "OSPF interface commands\n"
4426 "Authentication password (key)\n")
4427
4428ALIAS (no_ip_ospf_authentication_key,
4429 no_ospf_authentication_key_cmd,
4430 "no ospf authentication-key",
4431 NO_STR
4432 "OSPF interface commands\n"
4433 "Authentication password (key)\n")
4434
4435DEFUN (ip_ospf_message_digest_key,
4436 ip_ospf_message_digest_key_addr_cmd,
4437 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4438 "IP Information\n"
4439 "OSPF interface commands\n"
4440 "Message digest authentication password (key)\n"
4441 "Key ID\n"
4442 "Use MD5 algorithm\n"
4443 "The OSPF password (key)"
4444 "Address of interface")
4445{
4446 struct interface *ifp;
4447 struct crypt_key *ck;
4448 u_char key_id;
4449 struct in_addr addr;
4450 int ret;
4451 struct ospf_if_params *params;
4452
4453 ifp = vty->index;
4454 params = IF_DEF_PARAMS (ifp);
4455
4456 if (argc == 3)
4457 {
4458 ret = inet_aton(argv[2], &addr);
4459 if (!ret)
4460 {
4461 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4462 VTY_NEWLINE);
4463 return CMD_WARNING;
4464 }
4465
4466 params = ospf_get_if_params (ifp, addr);
4467 ospf_if_update_params (ifp, addr);
4468 }
4469
4470 key_id = strtol (argv[0], NULL, 10);
4471 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4472 {
4473 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4474 return CMD_WARNING;
4475 }
4476
4477 ck = ospf_crypt_key_new ();
4478 ck->key_id = (u_char) key_id;
4479 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004480 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004481
4482 ospf_crypt_key_add (params->auth_crypt, ck);
4483 SET_IF_PARAM (params, auth_crypt);
4484
4485 return CMD_SUCCESS;
4486}
4487
4488ALIAS (ip_ospf_message_digest_key,
4489 ip_ospf_message_digest_key_cmd,
4490 "ip ospf message-digest-key <1-255> md5 KEY",
4491 "IP Information\n"
4492 "OSPF interface commands\n"
4493 "Message digest authentication password (key)\n"
4494 "Key ID\n"
4495 "Use MD5 algorithm\n"
4496 "The OSPF password (key)")
4497
4498ALIAS (ip_ospf_message_digest_key,
4499 ospf_message_digest_key_cmd,
4500 "ospf message-digest-key <1-255> md5 KEY",
4501 "OSPF interface commands\n"
4502 "Message digest authentication password (key)\n"
4503 "Key ID\n"
4504 "Use MD5 algorithm\n"
4505 "The OSPF password (key)")
4506
4507DEFUN (no_ip_ospf_message_digest_key,
4508 no_ip_ospf_message_digest_key_addr_cmd,
4509 "no ip ospf message-digest-key <1-255> A.B.C.D",
4510 NO_STR
4511 "IP Information\n"
4512 "OSPF interface commands\n"
4513 "Message digest authentication password (key)\n"
4514 "Key ID\n"
4515 "Address of interface")
4516{
4517 struct interface *ifp;
4518 struct crypt_key *ck;
4519 int key_id;
4520 struct in_addr addr;
4521 int ret;
4522 struct ospf_if_params *params;
4523
4524 ifp = vty->index;
4525 params = IF_DEF_PARAMS (ifp);
4526
4527 if (argc == 2)
4528 {
4529 ret = inet_aton(argv[1], &addr);
4530 if (!ret)
4531 {
4532 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4533 VTY_NEWLINE);
4534 return CMD_WARNING;
4535 }
4536
4537 params = ospf_lookup_if_params (ifp, addr);
4538 if (params == NULL)
4539 return CMD_SUCCESS;
4540 }
4541
4542 key_id = strtol (argv[0], NULL, 10);
4543 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4544 if (ck == NULL)
4545 {
4546 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4547 return CMD_WARNING;
4548 }
4549
4550 ospf_crypt_key_delete (params->auth_crypt, key_id);
4551
4552 if (params != IF_DEF_PARAMS (ifp))
4553 {
4554 ospf_free_if_params (ifp, addr);
4555 ospf_if_update_params (ifp, addr);
4556 }
4557
4558 return CMD_SUCCESS;
4559}
4560
4561ALIAS (no_ip_ospf_message_digest_key,
4562 no_ip_ospf_message_digest_key_cmd,
4563 "no ip ospf message-digest-key <1-255>",
4564 NO_STR
4565 "IP Information\n"
4566 "OSPF interface commands\n"
4567 "Message digest authentication password (key)\n"
4568 "Key ID\n")
4569
4570ALIAS (no_ip_ospf_message_digest_key,
4571 no_ospf_message_digest_key_cmd,
4572 "no ospf message-digest-key <1-255>",
4573 NO_STR
4574 "OSPF interface commands\n"
4575 "Message digest authentication password (key)\n"
4576 "Key ID\n")
4577
4578DEFUN (ip_ospf_cost,
4579 ip_ospf_cost_addr_cmd,
4580 "ip ospf cost <1-65535> A.B.C.D",
4581 "IP Information\n"
4582 "OSPF interface commands\n"
4583 "Interface cost\n"
4584 "Cost\n"
4585 "Address of interface")
4586{
4587 struct interface *ifp = vty->index;
4588 u_int32_t cost;
4589 struct in_addr addr;
4590 int ret;
4591 struct ospf_if_params *params;
4592
4593 params = IF_DEF_PARAMS (ifp);
4594
4595 cost = strtol (argv[0], NULL, 10);
4596
4597 /* cost range is <1-65535>. */
4598 if (cost < 1 || cost > 65535)
4599 {
4600 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4601 return CMD_WARNING;
4602 }
4603
4604 if (argc == 2)
4605 {
4606 ret = inet_aton(argv[1], &addr);
4607 if (!ret)
4608 {
4609 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4610 VTY_NEWLINE);
4611 return CMD_WARNING;
4612 }
4613
4614 params = ospf_get_if_params (ifp, addr);
4615 ospf_if_update_params (ifp, addr);
4616 }
4617
4618 SET_IF_PARAM (params, output_cost_cmd);
4619 params->output_cost_cmd = cost;
4620
4621 ospf_if_recalculate_output_cost (ifp);
4622
4623 return CMD_SUCCESS;
4624}
4625
4626ALIAS (ip_ospf_cost,
4627 ip_ospf_cost_cmd,
4628 "ip ospf cost <1-65535>",
4629 "IP Information\n"
4630 "OSPF interface commands\n"
4631 "Interface cost\n"
4632 "Cost")
4633
4634ALIAS (ip_ospf_cost,
4635 ospf_cost_cmd,
4636 "ospf cost <1-65535>",
4637 "OSPF interface commands\n"
4638 "Interface cost\n"
4639 "Cost")
4640
4641DEFUN (no_ip_ospf_cost,
4642 no_ip_ospf_cost_addr_cmd,
4643 "no ip ospf cost A.B.C.D",
4644 NO_STR
4645 "IP Information\n"
4646 "OSPF interface commands\n"
4647 "Interface cost\n"
4648 "Address of interface")
4649{
4650 struct interface *ifp = vty->index;
4651 struct in_addr addr;
4652 int ret;
4653 struct ospf_if_params *params;
4654
4655 ifp = vty->index;
4656 params = IF_DEF_PARAMS (ifp);
4657
4658 if (argc == 1)
4659 {
4660 ret = inet_aton(argv[0], &addr);
4661 if (!ret)
4662 {
4663 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4664 VTY_NEWLINE);
4665 return CMD_WARNING;
4666 }
4667
4668 params = ospf_lookup_if_params (ifp, addr);
4669 if (params == NULL)
4670 return CMD_SUCCESS;
4671 }
4672
4673 UNSET_IF_PARAM (params, output_cost_cmd);
4674
4675 if (params != IF_DEF_PARAMS (ifp))
4676 {
4677 ospf_free_if_params (ifp, addr);
4678 ospf_if_update_params (ifp, addr);
4679 }
4680
4681 ospf_if_recalculate_output_cost (ifp);
4682
4683 return CMD_SUCCESS;
4684}
4685
4686ALIAS (no_ip_ospf_cost,
4687 no_ip_ospf_cost_cmd,
4688 "no ip ospf cost",
4689 NO_STR
4690 "IP Information\n"
4691 "OSPF interface commands\n"
4692 "Interface cost\n")
4693
4694ALIAS (no_ip_ospf_cost,
4695 no_ospf_cost_cmd,
4696 "no ospf cost",
4697 NO_STR
4698 "OSPF interface commands\n"
4699 "Interface cost\n")
4700
paul4dadc292005-05-06 21:37:42 +00004701static void
paul718e3742002-12-13 20:15:29 +00004702ospf_nbr_timer_update (struct ospf_interface *oi)
4703{
4704 struct route_node *rn;
4705 struct ospf_neighbor *nbr;
4706
4707 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4708 if ((nbr = rn->info))
4709 {
4710 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4711 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4712 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4713 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4714 }
4715}
4716
paulf9ad9372005-10-21 00:45:17 +00004717static int
4718ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4719 const char *nbr_str,
4720 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004721{
4722 struct interface *ifp = vty->index;
4723 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004724 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004725 struct in_addr addr;
4726 int ret;
4727 struct ospf_if_params *params;
4728 struct ospf_interface *oi;
4729 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004730 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004731
paul020709f2003-04-04 02:44:16 +00004732 ospf = ospf_lookup ();
4733
paul718e3742002-12-13 20:15:29 +00004734 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004735
4736 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004737 {
paulf9ad9372005-10-21 00:45:17 +00004738 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004739 if (!ret)
4740 {
4741 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4742 VTY_NEWLINE);
4743 return CMD_WARNING;
4744 }
4745
4746 params = ospf_get_if_params (ifp, addr);
4747 ospf_if_update_params (ifp, addr);
4748 }
4749
paulf9ad9372005-10-21 00:45:17 +00004750 if (interval_str)
4751 {
4752 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4753 1, 65535);
4754
4755 /* reset fast_hello too, just to be sure */
4756 UNSET_IF_PARAM (params, fast_hello);
4757 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4758 }
4759 else if (fast_hello_str)
4760 {
4761 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4762 1, 10);
4763 /* 1s dead-interval with sub-second hellos desired */
4764 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4765 SET_IF_PARAM (params, fast_hello);
4766 params->fast_hello = hellomult;
4767 }
4768 else
4769 {
4770 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4771 VTY_NEWLINE);
4772 return CMD_WARNING;
4773 }
4774
paul718e3742002-12-13 20:15:29 +00004775 SET_IF_PARAM (params, v_wait);
4776 params->v_wait = seconds;
4777
4778 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00004779 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004780 {
paul68980082003-03-25 05:07:42 +00004781 if (ospf)
4782 {
4783 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4784 if (oi)
4785 ospf_nbr_timer_update (oi);
4786 }
paul718e3742002-12-13 20:15:29 +00004787 }
4788 else
4789 {
4790 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4791 if ((oi = rn->info))
4792 ospf_nbr_timer_update (oi);
4793 }
4794
4795 return CMD_SUCCESS;
4796}
4797
paulf9ad9372005-10-21 00:45:17 +00004798
4799DEFUN (ip_ospf_dead_interval,
4800 ip_ospf_dead_interval_addr_cmd,
4801 "ip ospf dead-interval <1-65535> A.B.C.D",
4802 "IP Information\n"
4803 "OSPF interface commands\n"
4804 "Interval after which a neighbor is declared dead\n"
4805 "Seconds\n"
4806 "Address of interface\n")
4807{
4808 if (argc == 2)
4809 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4810 else
4811 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4812}
4813
paul718e3742002-12-13 20:15:29 +00004814ALIAS (ip_ospf_dead_interval,
4815 ip_ospf_dead_interval_cmd,
4816 "ip ospf dead-interval <1-65535>",
4817 "IP Information\n"
4818 "OSPF interface commands\n"
4819 "Interval after which a neighbor is declared dead\n"
4820 "Seconds\n")
4821
4822ALIAS (ip_ospf_dead_interval,
4823 ospf_dead_interval_cmd,
4824 "ospf dead-interval <1-65535>",
4825 "OSPF interface commands\n"
4826 "Interval after which a neighbor is declared dead\n"
4827 "Seconds\n")
4828
paulf9ad9372005-10-21 00:45:17 +00004829DEFUN (ip_ospf_dead_interval_minimal,
4830 ip_ospf_dead_interval_minimal_addr_cmd,
4831 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4832 "IP Information\n"
4833 "OSPF interface commands\n"
4834 "Interval after which a neighbor is declared dead\n"
4835 "Minimal 1s dead-interval with fast sub-second hellos\n"
4836 "Hello multiplier factor\n"
4837 "Number of Hellos to send each second\n"
4838 "Address of interface\n")
4839{
4840 if (argc == 2)
4841 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4842 else
4843 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4844}
4845
4846ALIAS (ip_ospf_dead_interval_minimal,
4847 ip_ospf_dead_interval_minimal_cmd,
4848 "ip ospf dead-interval minimal hello-multiplier <1-10>",
4849 "IP Information\n"
4850 "OSPF interface commands\n"
4851 "Interval after which a neighbor is declared dead\n"
4852 "Minimal 1s dead-interval with fast sub-second hellos\n"
4853 "Hello multiplier factor\n"
4854 "Number of Hellos to send each second\n")
4855
paul718e3742002-12-13 20:15:29 +00004856DEFUN (no_ip_ospf_dead_interval,
4857 no_ip_ospf_dead_interval_addr_cmd,
4858 "no ip ospf dead-interval A.B.C.D",
4859 NO_STR
4860 "IP Information\n"
4861 "OSPF interface commands\n"
4862 "Interval after which a neighbor is declared dead\n"
4863 "Address of interface")
4864{
4865 struct interface *ifp = vty->index;
4866 struct in_addr addr;
4867 int ret;
4868 struct ospf_if_params *params;
4869 struct ospf_interface *oi;
4870 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004871 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004872
paul020709f2003-04-04 02:44:16 +00004873 ospf = ospf_lookup ();
4874
paul718e3742002-12-13 20:15:29 +00004875 ifp = vty->index;
4876 params = IF_DEF_PARAMS (ifp);
4877
4878 if (argc == 1)
4879 {
4880 ret = inet_aton(argv[0], &addr);
4881 if (!ret)
4882 {
4883 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4884 VTY_NEWLINE);
4885 return CMD_WARNING;
4886 }
4887
4888 params = ospf_lookup_if_params (ifp, addr);
4889 if (params == NULL)
4890 return CMD_SUCCESS;
4891 }
4892
4893 UNSET_IF_PARAM (params, v_wait);
4894 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00004895
4896 UNSET_IF_PARAM (params, fast_hello);
4897 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4898
paul718e3742002-12-13 20:15:29 +00004899 if (params != IF_DEF_PARAMS (ifp))
4900 {
4901 ospf_free_if_params (ifp, addr);
4902 ospf_if_update_params (ifp, addr);
4903 }
4904
4905 /* Update timer values in neighbor structure. */
4906 if (argc == 1)
4907 {
paul68980082003-03-25 05:07:42 +00004908 if (ospf)
4909 {
4910 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4911 if (oi)
4912 ospf_nbr_timer_update (oi);
4913 }
paul718e3742002-12-13 20:15:29 +00004914 }
4915 else
4916 {
4917 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4918 if ((oi = rn->info))
4919 ospf_nbr_timer_update (oi);
4920 }
4921
4922 return CMD_SUCCESS;
4923}
4924
4925ALIAS (no_ip_ospf_dead_interval,
4926 no_ip_ospf_dead_interval_cmd,
4927 "no ip ospf dead-interval",
4928 NO_STR
4929 "IP Information\n"
4930 "OSPF interface commands\n"
4931 "Interval after which a neighbor is declared dead\n")
4932
4933ALIAS (no_ip_ospf_dead_interval,
4934 no_ospf_dead_interval_cmd,
4935 "no ospf dead-interval",
4936 NO_STR
4937 "OSPF interface commands\n"
4938 "Interval after which a neighbor is declared dead\n")
4939
4940DEFUN (ip_ospf_hello_interval,
4941 ip_ospf_hello_interval_addr_cmd,
4942 "ip ospf hello-interval <1-65535> A.B.C.D",
4943 "IP Information\n"
4944 "OSPF interface commands\n"
4945 "Time between HELLO packets\n"
4946 "Seconds\n"
4947 "Address of interface")
4948{
4949 struct interface *ifp = vty->index;
4950 u_int32_t seconds;
4951 struct in_addr addr;
4952 int ret;
4953 struct ospf_if_params *params;
4954
4955 params = IF_DEF_PARAMS (ifp);
4956
4957 seconds = strtol (argv[0], NULL, 10);
4958
4959 /* HelloInterval range is <1-65535>. */
4960 if (seconds < 1 || seconds > 65535)
4961 {
4962 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4963 return CMD_WARNING;
4964 }
4965
4966 if (argc == 2)
4967 {
4968 ret = inet_aton(argv[1], &addr);
4969 if (!ret)
4970 {
4971 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4972 VTY_NEWLINE);
4973 return CMD_WARNING;
4974 }
4975
4976 params = ospf_get_if_params (ifp, addr);
4977 ospf_if_update_params (ifp, addr);
4978 }
4979
paulf9ad9372005-10-21 00:45:17 +00004980 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00004981 params->v_hello = seconds;
4982
4983 return CMD_SUCCESS;
4984}
4985
4986ALIAS (ip_ospf_hello_interval,
4987 ip_ospf_hello_interval_cmd,
4988 "ip ospf hello-interval <1-65535>",
4989 "IP Information\n"
4990 "OSPF interface commands\n"
4991 "Time between HELLO packets\n"
4992 "Seconds\n")
4993
4994ALIAS (ip_ospf_hello_interval,
4995 ospf_hello_interval_cmd,
4996 "ospf hello-interval <1-65535>",
4997 "OSPF interface commands\n"
4998 "Time between HELLO packets\n"
4999 "Seconds\n")
5000
5001DEFUN (no_ip_ospf_hello_interval,
5002 no_ip_ospf_hello_interval_addr_cmd,
5003 "no ip ospf hello-interval A.B.C.D",
5004 NO_STR
5005 "IP Information\n"
5006 "OSPF interface commands\n"
5007 "Time between HELLO packets\n"
5008 "Address of interface")
5009{
5010 struct interface *ifp = vty->index;
5011 struct in_addr addr;
5012 int ret;
5013 struct ospf_if_params *params;
5014
5015 ifp = vty->index;
5016 params = IF_DEF_PARAMS (ifp);
5017
5018 if (argc == 1)
5019 {
5020 ret = inet_aton(argv[0], &addr);
5021 if (!ret)
5022 {
5023 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5024 VTY_NEWLINE);
5025 return CMD_WARNING;
5026 }
5027
5028 params = ospf_lookup_if_params (ifp, addr);
5029 if (params == NULL)
5030 return CMD_SUCCESS;
5031 }
5032
5033 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005034 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005035
5036 if (params != IF_DEF_PARAMS (ifp))
5037 {
5038 ospf_free_if_params (ifp, addr);
5039 ospf_if_update_params (ifp, addr);
5040 }
5041
5042 return CMD_SUCCESS;
5043}
5044
5045ALIAS (no_ip_ospf_hello_interval,
5046 no_ip_ospf_hello_interval_cmd,
5047 "no ip ospf hello-interval",
5048 NO_STR
5049 "IP Information\n"
5050 "OSPF interface commands\n"
5051 "Time between HELLO packets\n")
5052
5053ALIAS (no_ip_ospf_hello_interval,
5054 no_ospf_hello_interval_cmd,
5055 "no ospf hello-interval",
5056 NO_STR
5057 "OSPF interface commands\n"
5058 "Time between HELLO packets\n")
5059
5060DEFUN (ip_ospf_network,
5061 ip_ospf_network_cmd,
5062 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5063 "IP Information\n"
5064 "OSPF interface commands\n"
5065 "Network type\n"
5066 "Specify OSPF broadcast multi-access network\n"
5067 "Specify OSPF NBMA network\n"
5068 "Specify OSPF point-to-multipoint network\n"
5069 "Specify OSPF point-to-point network\n")
5070{
5071 struct interface *ifp = vty->index;
5072 int old_type = IF_DEF_PARAMS (ifp)->type;
5073 struct route_node *rn;
5074
5075 if (strncmp (argv[0], "b", 1) == 0)
5076 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5077 else if (strncmp (argv[0], "n", 1) == 0)
5078 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5079 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5080 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5081 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5082 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5083
5084 if (IF_DEF_PARAMS (ifp)->type == old_type)
5085 return CMD_SUCCESS;
5086
5087 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5088
5089 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5090 {
5091 struct ospf_interface *oi = rn->info;
5092
5093 if (!oi)
5094 continue;
5095
5096 oi->type = IF_DEF_PARAMS (ifp)->type;
5097
5098 if (oi->state > ISM_Down)
5099 {
5100 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5101 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5102 }
5103 }
5104
5105 return CMD_SUCCESS;
5106}
5107
5108ALIAS (ip_ospf_network,
5109 ospf_network_cmd,
5110 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5111 "OSPF interface commands\n"
5112 "Network type\n"
5113 "Specify OSPF broadcast multi-access network\n"
5114 "Specify OSPF NBMA network\n"
5115 "Specify OSPF point-to-multipoint network\n"
5116 "Specify OSPF point-to-point network\n")
5117
5118DEFUN (no_ip_ospf_network,
5119 no_ip_ospf_network_cmd,
5120 "no ip ospf network",
5121 NO_STR
5122 "IP Information\n"
5123 "OSPF interface commands\n"
5124 "Network type\n")
5125{
5126 struct interface *ifp = vty->index;
5127 int old_type = IF_DEF_PARAMS (ifp)->type;
5128 struct route_node *rn;
5129
ajsbc18d612004-12-15 15:07:19 +00005130 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005131
5132 if (IF_DEF_PARAMS (ifp)->type == old_type)
5133 return CMD_SUCCESS;
5134
5135 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5136 {
5137 struct ospf_interface *oi = rn->info;
5138
5139 if (!oi)
5140 continue;
5141
5142 oi->type = IF_DEF_PARAMS (ifp)->type;
5143
5144 if (oi->state > ISM_Down)
5145 {
5146 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5147 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5148 }
5149 }
5150
5151 return CMD_SUCCESS;
5152}
5153
5154ALIAS (no_ip_ospf_network,
5155 no_ospf_network_cmd,
5156 "no ospf network",
5157 NO_STR
5158 "OSPF interface commands\n"
5159 "Network type\n")
5160
5161DEFUN (ip_ospf_priority,
5162 ip_ospf_priority_addr_cmd,
5163 "ip ospf priority <0-255> A.B.C.D",
5164 "IP Information\n"
5165 "OSPF interface commands\n"
5166 "Router priority\n"
5167 "Priority\n"
5168 "Address of interface")
5169{
5170 struct interface *ifp = vty->index;
5171 u_int32_t priority;
5172 struct route_node *rn;
5173 struct in_addr addr;
5174 int ret;
5175 struct ospf_if_params *params;
5176
5177 params = IF_DEF_PARAMS (ifp);
5178
5179 priority = strtol (argv[0], NULL, 10);
5180
5181 /* Router Priority range is <0-255>. */
5182 if (priority < 0 || priority > 255)
5183 {
5184 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5185 return CMD_WARNING;
5186 }
5187
5188 if (argc == 2)
5189 {
5190 ret = inet_aton(argv[1], &addr);
5191 if (!ret)
5192 {
5193 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5194 VTY_NEWLINE);
5195 return CMD_WARNING;
5196 }
5197
5198 params = ospf_get_if_params (ifp, addr);
5199 ospf_if_update_params (ifp, addr);
5200 }
5201
5202 SET_IF_PARAM (params, priority);
5203 params->priority = priority;
5204
5205 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5206 {
5207 struct ospf_interface *oi = rn->info;
5208
5209 if (!oi)
5210 continue;
5211
5212
5213 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5214 {
5215 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5216 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5217 }
5218 }
5219
5220 return CMD_SUCCESS;
5221}
5222
5223ALIAS (ip_ospf_priority,
5224 ip_ospf_priority_cmd,
5225 "ip ospf priority <0-255>",
5226 "IP Information\n"
5227 "OSPF interface commands\n"
5228 "Router priority\n"
5229 "Priority\n")
5230
5231ALIAS (ip_ospf_priority,
5232 ospf_priority_cmd,
5233 "ospf priority <0-255>",
5234 "OSPF interface commands\n"
5235 "Router priority\n"
5236 "Priority\n")
5237
5238DEFUN (no_ip_ospf_priority,
5239 no_ip_ospf_priority_addr_cmd,
5240 "no ip ospf priority A.B.C.D",
5241 NO_STR
5242 "IP Information\n"
5243 "OSPF interface commands\n"
5244 "Router priority\n"
5245 "Address of interface")
5246{
5247 struct interface *ifp = vty->index;
5248 struct route_node *rn;
5249 struct in_addr addr;
5250 int ret;
5251 struct ospf_if_params *params;
5252
5253 ifp = vty->index;
5254 params = IF_DEF_PARAMS (ifp);
5255
5256 if (argc == 1)
5257 {
5258 ret = inet_aton(argv[0], &addr);
5259 if (!ret)
5260 {
5261 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5262 VTY_NEWLINE);
5263 return CMD_WARNING;
5264 }
5265
5266 params = ospf_lookup_if_params (ifp, addr);
5267 if (params == NULL)
5268 return CMD_SUCCESS;
5269 }
5270
5271 UNSET_IF_PARAM (params, priority);
5272 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5273
5274 if (params != IF_DEF_PARAMS (ifp))
5275 {
5276 ospf_free_if_params (ifp, addr);
5277 ospf_if_update_params (ifp, addr);
5278 }
5279
5280 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5281 {
5282 struct ospf_interface *oi = rn->info;
5283
5284 if (!oi)
5285 continue;
5286
5287
5288 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5289 {
5290 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5291 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5292 }
5293 }
5294
5295 return CMD_SUCCESS;
5296}
5297
5298ALIAS (no_ip_ospf_priority,
5299 no_ip_ospf_priority_cmd,
5300 "no ip ospf priority",
5301 NO_STR
5302 "IP Information\n"
5303 "OSPF interface commands\n"
5304 "Router priority\n")
5305
5306ALIAS (no_ip_ospf_priority,
5307 no_ospf_priority_cmd,
5308 "no ospf priority",
5309 NO_STR
5310 "OSPF interface commands\n"
5311 "Router priority\n")
5312
5313DEFUN (ip_ospf_retransmit_interval,
5314 ip_ospf_retransmit_interval_addr_cmd,
5315 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5316 "IP Information\n"
5317 "OSPF interface commands\n"
5318 "Time between retransmitting lost link state advertisements\n"
5319 "Seconds\n"
5320 "Address of interface")
5321{
5322 struct interface *ifp = vty->index;
5323 u_int32_t seconds;
5324 struct in_addr addr;
5325 int ret;
5326 struct ospf_if_params *params;
5327
5328 params = IF_DEF_PARAMS (ifp);
5329 seconds = strtol (argv[0], NULL, 10);
5330
5331 /* Retransmit Interval range is <3-65535>. */
5332 if (seconds < 3 || seconds > 65535)
5333 {
5334 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5335 return CMD_WARNING;
5336 }
5337
5338
5339 if (argc == 2)
5340 {
5341 ret = inet_aton(argv[1], &addr);
5342 if (!ret)
5343 {
5344 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5345 VTY_NEWLINE);
5346 return CMD_WARNING;
5347 }
5348
5349 params = ospf_get_if_params (ifp, addr);
5350 ospf_if_update_params (ifp, addr);
5351 }
5352
5353 SET_IF_PARAM (params, retransmit_interval);
5354 params->retransmit_interval = seconds;
5355
5356 return CMD_SUCCESS;
5357}
5358
5359ALIAS (ip_ospf_retransmit_interval,
5360 ip_ospf_retransmit_interval_cmd,
5361 "ip ospf retransmit-interval <3-65535>",
5362 "IP Information\n"
5363 "OSPF interface commands\n"
5364 "Time between retransmitting lost link state advertisements\n"
5365 "Seconds\n")
5366
5367ALIAS (ip_ospf_retransmit_interval,
5368 ospf_retransmit_interval_cmd,
5369 "ospf retransmit-interval <3-65535>",
5370 "OSPF interface commands\n"
5371 "Time between retransmitting lost link state advertisements\n"
5372 "Seconds\n")
5373
5374DEFUN (no_ip_ospf_retransmit_interval,
5375 no_ip_ospf_retransmit_interval_addr_cmd,
5376 "no ip ospf retransmit-interval A.B.C.D",
5377 NO_STR
5378 "IP Information\n"
5379 "OSPF interface commands\n"
5380 "Time between retransmitting lost link state advertisements\n"
5381 "Address of interface")
5382{
5383 struct interface *ifp = vty->index;
5384 struct in_addr addr;
5385 int ret;
5386 struct ospf_if_params *params;
5387
5388 ifp = vty->index;
5389 params = IF_DEF_PARAMS (ifp);
5390
5391 if (argc == 1)
5392 {
5393 ret = inet_aton(argv[0], &addr);
5394 if (!ret)
5395 {
5396 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5397 VTY_NEWLINE);
5398 return CMD_WARNING;
5399 }
5400
5401 params = ospf_lookup_if_params (ifp, addr);
5402 if (params == NULL)
5403 return CMD_SUCCESS;
5404 }
5405
5406 UNSET_IF_PARAM (params, retransmit_interval);
5407 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5408
5409 if (params != IF_DEF_PARAMS (ifp))
5410 {
5411 ospf_free_if_params (ifp, addr);
5412 ospf_if_update_params (ifp, addr);
5413 }
5414
5415 return CMD_SUCCESS;
5416}
5417
5418ALIAS (no_ip_ospf_retransmit_interval,
5419 no_ip_ospf_retransmit_interval_cmd,
5420 "no ip ospf retransmit-interval",
5421 NO_STR
5422 "IP Information\n"
5423 "OSPF interface commands\n"
5424 "Time between retransmitting lost link state advertisements\n")
5425
5426ALIAS (no_ip_ospf_retransmit_interval,
5427 no_ospf_retransmit_interval_cmd,
5428 "no ospf retransmit-interval",
5429 NO_STR
5430 "OSPF interface commands\n"
5431 "Time between retransmitting lost link state advertisements\n")
5432
5433DEFUN (ip_ospf_transmit_delay,
5434 ip_ospf_transmit_delay_addr_cmd,
5435 "ip ospf transmit-delay <1-65535> A.B.C.D",
5436 "IP Information\n"
5437 "OSPF interface commands\n"
5438 "Link state transmit delay\n"
5439 "Seconds\n"
5440 "Address of interface")
5441{
5442 struct interface *ifp = vty->index;
5443 u_int32_t seconds;
5444 struct in_addr addr;
5445 int ret;
5446 struct ospf_if_params *params;
5447
5448 params = IF_DEF_PARAMS (ifp);
5449 seconds = strtol (argv[0], NULL, 10);
5450
5451 /* Transmit Delay range is <1-65535>. */
5452 if (seconds < 1 || seconds > 65535)
5453 {
5454 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5455 return CMD_WARNING;
5456 }
5457
5458 if (argc == 2)
5459 {
5460 ret = inet_aton(argv[1], &addr);
5461 if (!ret)
5462 {
5463 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5464 VTY_NEWLINE);
5465 return CMD_WARNING;
5466 }
5467
5468 params = ospf_get_if_params (ifp, addr);
5469 ospf_if_update_params (ifp, addr);
5470 }
5471
5472 SET_IF_PARAM (params, transmit_delay);
5473 params->transmit_delay = seconds;
5474
5475 return CMD_SUCCESS;
5476}
5477
5478ALIAS (ip_ospf_transmit_delay,
5479 ip_ospf_transmit_delay_cmd,
5480 "ip ospf transmit-delay <1-65535>",
5481 "IP Information\n"
5482 "OSPF interface commands\n"
5483 "Link state transmit delay\n"
5484 "Seconds\n")
5485
5486ALIAS (ip_ospf_transmit_delay,
5487 ospf_transmit_delay_cmd,
5488 "ospf transmit-delay <1-65535>",
5489 "OSPF interface commands\n"
5490 "Link state transmit delay\n"
5491 "Seconds\n")
5492
5493DEFUN (no_ip_ospf_transmit_delay,
5494 no_ip_ospf_transmit_delay_addr_cmd,
5495 "no ip ospf transmit-delay A.B.C.D",
5496 NO_STR
5497 "IP Information\n"
5498 "OSPF interface commands\n"
5499 "Link state transmit delay\n"
5500 "Address of interface")
5501{
5502 struct interface *ifp = vty->index;
5503 struct in_addr addr;
5504 int ret;
5505 struct ospf_if_params *params;
5506
5507 ifp = vty->index;
5508 params = IF_DEF_PARAMS (ifp);
5509
5510 if (argc == 1)
5511 {
5512 ret = inet_aton(argv[0], &addr);
5513 if (!ret)
5514 {
5515 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5516 VTY_NEWLINE);
5517 return CMD_WARNING;
5518 }
5519
5520 params = ospf_lookup_if_params (ifp, addr);
5521 if (params == NULL)
5522 return CMD_SUCCESS;
5523 }
5524
5525 UNSET_IF_PARAM (params, transmit_delay);
5526 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5527
5528 if (params != IF_DEF_PARAMS (ifp))
5529 {
5530 ospf_free_if_params (ifp, addr);
5531 ospf_if_update_params (ifp, addr);
5532 }
5533
5534 return CMD_SUCCESS;
5535}
5536
5537ALIAS (no_ip_ospf_transmit_delay,
5538 no_ip_ospf_transmit_delay_cmd,
5539 "no ip ospf transmit-delay",
5540 NO_STR
5541 "IP Information\n"
5542 "OSPF interface commands\n"
5543 "Link state transmit delay\n")
5544
5545ALIAS (no_ip_ospf_transmit_delay,
5546 no_ospf_transmit_delay_cmd,
5547 "no ospf transmit-delay",
5548 NO_STR
5549 "OSPF interface commands\n"
5550 "Link state transmit delay\n")
5551
5552
5553DEFUN (ospf_redistribute_source_metric_type,
5554 ospf_redistribute_source_metric_type_routemap_cmd,
5555 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5556 "Redistribute information from another routing protocol\n"
5557 "Kernel routes\n"
5558 "Connected\n"
5559 "Static routes\n"
5560 "Routing Information Protocol (RIP)\n"
5561 "Border Gateway Protocol (BGP)\n"
5562 "Metric for redistributed routes\n"
5563 "OSPF default metric\n"
5564 "OSPF exterior metric type for redistributed routes\n"
5565 "Set OSPF External Type 1 metrics\n"
5566 "Set OSPF External Type 2 metrics\n"
5567 "Route map reference\n"
5568 "Pointer to route-map entries\n")
5569{
paul020709f2003-04-04 02:44:16 +00005570 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005571 int source;
5572 int type = -1;
5573 int metric = -1;
5574
5575 /* Get distribute source. */
5576 if (!str2distribute_source (argv[0], &source))
5577 return CMD_WARNING;
5578
5579 /* Get metric value. */
5580 if (argc >= 2)
5581 if (!str2metric (argv[1], &metric))
5582 return CMD_WARNING;
5583
5584 /* Get metric type. */
5585 if (argc >= 3)
5586 if (!str2metric_type (argv[2], &type))
5587 return CMD_WARNING;
5588
5589 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005590 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005591 else
paul020709f2003-04-04 02:44:16 +00005592 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005593
paul020709f2003-04-04 02:44:16 +00005594 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005595}
5596
5597ALIAS (ospf_redistribute_source_metric_type,
5598 ospf_redistribute_source_metric_type_cmd,
5599 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5600 "Redistribute information from another routing protocol\n"
5601 "Kernel routes\n"
5602 "Connected\n"
5603 "Static routes\n"
5604 "Routing Information Protocol (RIP)\n"
5605 "Border Gateway Protocol (BGP)\n"
5606 "Metric for redistributed routes\n"
5607 "OSPF default metric\n"
5608 "OSPF exterior metric type for redistributed routes\n"
5609 "Set OSPF External Type 1 metrics\n"
5610 "Set OSPF External Type 2 metrics\n")
5611
5612ALIAS (ospf_redistribute_source_metric_type,
5613 ospf_redistribute_source_metric_cmd,
5614 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5615 "Redistribute information from another routing protocol\n"
5616 "Kernel routes\n"
5617 "Connected\n"
5618 "Static routes\n"
5619 "Routing Information Protocol (RIP)\n"
5620 "Border Gateway Protocol (BGP)\n"
5621 "Metric for redistributed routes\n"
5622 "OSPF default metric\n")
5623
5624DEFUN (ospf_redistribute_source_type_metric,
5625 ospf_redistribute_source_type_metric_routemap_cmd,
5626 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5627 "Redistribute information from another routing protocol\n"
5628 "Kernel routes\n"
5629 "Connected\n"
5630 "Static routes\n"
5631 "Routing Information Protocol (RIP)\n"
5632 "Border Gateway Protocol (BGP)\n"
5633 "OSPF exterior metric type for redistributed routes\n"
5634 "Set OSPF External Type 1 metrics\n"
5635 "Set OSPF External Type 2 metrics\n"
5636 "Metric for redistributed routes\n"
5637 "OSPF default metric\n"
5638 "Route map reference\n"
5639 "Pointer to route-map entries\n")
5640{
paul020709f2003-04-04 02:44:16 +00005641 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005642 int source;
5643 int type = -1;
5644 int metric = -1;
5645
5646 /* Get distribute source. */
5647 if (!str2distribute_source (argv[0], &source))
5648 return CMD_WARNING;
5649
5650 /* Get metric value. */
5651 if (argc >= 2)
5652 if (!str2metric_type (argv[1], &type))
5653 return CMD_WARNING;
5654
5655 /* Get metric type. */
5656 if (argc >= 3)
5657 if (!str2metric (argv[2], &metric))
5658 return CMD_WARNING;
5659
5660 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005661 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005662 else
paul020709f2003-04-04 02:44:16 +00005663 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005664
paul020709f2003-04-04 02:44:16 +00005665 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005666}
5667
5668ALIAS (ospf_redistribute_source_type_metric,
5669 ospf_redistribute_source_type_metric_cmd,
5670 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5671 "Redistribute information from another routing protocol\n"
5672 "Kernel routes\n"
5673 "Connected\n"
5674 "Static routes\n"
5675 "Routing Information Protocol (RIP)\n"
5676 "Border Gateway Protocol (BGP)\n"
5677 "OSPF exterior metric type for redistributed routes\n"
5678 "Set OSPF External Type 1 metrics\n"
5679 "Set OSPF External Type 2 metrics\n"
5680 "Metric for redistributed routes\n"
5681 "OSPF default metric\n")
5682
5683ALIAS (ospf_redistribute_source_type_metric,
5684 ospf_redistribute_source_type_cmd,
5685 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5686 "Redistribute information from another routing protocol\n"
5687 "Kernel routes\n"
5688 "Connected\n"
5689 "Static routes\n"
5690 "Routing Information Protocol (RIP)\n"
5691 "Border Gateway Protocol (BGP)\n"
5692 "OSPF exterior metric type for redistributed routes\n"
5693 "Set OSPF External Type 1 metrics\n"
5694 "Set OSPF External Type 2 metrics\n")
5695
5696ALIAS (ospf_redistribute_source_type_metric,
5697 ospf_redistribute_source_cmd,
5698 "redistribute (kernel|connected|static|rip|bgp)",
5699 "Redistribute information from another routing protocol\n"
5700 "Kernel routes\n"
5701 "Connected\n"
5702 "Static routes\n"
5703 "Routing Information Protocol (RIP)\n"
5704 "Border Gateway Protocol (BGP)\n")
5705
5706DEFUN (ospf_redistribute_source_metric_routemap,
5707 ospf_redistribute_source_metric_routemap_cmd,
5708 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5709 "Redistribute information from another routing protocol\n"
5710 "Kernel routes\n"
5711 "Connected\n"
5712 "Static routes\n"
5713 "Routing Information Protocol (RIP)\n"
5714 "Border Gateway Protocol (BGP)\n"
5715 "Metric for redistributed routes\n"
5716 "OSPF default metric\n"
5717 "Route map reference\n"
5718 "Pointer to route-map entries\n")
5719{
paul020709f2003-04-04 02:44:16 +00005720 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005721 int source;
5722 int metric = -1;
5723
5724 /* Get distribute source. */
5725 if (!str2distribute_source (argv[0], &source))
5726 return CMD_WARNING;
5727
5728 /* Get metric value. */
5729 if (argc >= 2)
5730 if (!str2metric (argv[1], &metric))
5731 return CMD_WARNING;
5732
5733 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005734 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005735 else
paul020709f2003-04-04 02:44:16 +00005736 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005737
paul020709f2003-04-04 02:44:16 +00005738 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005739}
5740
5741DEFUN (ospf_redistribute_source_type_routemap,
5742 ospf_redistribute_source_type_routemap_cmd,
5743 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5744 "Redistribute information from another routing protocol\n"
5745 "Kernel routes\n"
5746 "Connected\n"
5747 "Static routes\n"
5748 "Routing Information Protocol (RIP)\n"
5749 "Border Gateway Protocol (BGP)\n"
5750 "OSPF exterior metric type for redistributed routes\n"
5751 "Set OSPF External Type 1 metrics\n"
5752 "Set OSPF External Type 2 metrics\n"
5753 "Route map reference\n"
5754 "Pointer to route-map entries\n")
5755{
paul020709f2003-04-04 02:44:16 +00005756 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005757 int source;
5758 int type = -1;
5759
5760 /* Get distribute source. */
5761 if (!str2distribute_source (argv[0], &source))
5762 return CMD_WARNING;
5763
5764 /* Get metric value. */
5765 if (argc >= 2)
5766 if (!str2metric_type (argv[1], &type))
5767 return CMD_WARNING;
5768
5769 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005770 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005771 else
paul020709f2003-04-04 02:44:16 +00005772 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005773
paul020709f2003-04-04 02:44:16 +00005774 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005775}
5776
5777DEFUN (ospf_redistribute_source_routemap,
5778 ospf_redistribute_source_routemap_cmd,
5779 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5780 "Redistribute information from another routing protocol\n"
5781 "Kernel routes\n"
5782 "Connected\n"
5783 "Static routes\n"
5784 "Routing Information Protocol (RIP)\n"
5785 "Border Gateway Protocol (BGP)\n"
5786 "Route map reference\n"
5787 "Pointer to route-map entries\n")
5788{
paul020709f2003-04-04 02:44:16 +00005789 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005790 int source;
5791
5792 /* Get distribute source. */
5793 if (!str2distribute_source (argv[0], &source))
5794 return CMD_WARNING;
5795
5796 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005797 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005798 else
paul020709f2003-04-04 02:44:16 +00005799 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005800
paul020709f2003-04-04 02:44:16 +00005801 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005802}
5803
5804DEFUN (no_ospf_redistribute_source,
5805 no_ospf_redistribute_source_cmd,
5806 "no redistribute (kernel|connected|static|rip|bgp)",
5807 NO_STR
5808 "Redistribute information from another routing protocol\n"
5809 "Kernel routes\n"
5810 "Connected\n"
5811 "Static routes\n"
5812 "Routing Information Protocol (RIP)\n"
5813 "Border Gateway Protocol (BGP)\n")
5814{
paul020709f2003-04-04 02:44:16 +00005815 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005816 int source;
5817
5818 if (!str2distribute_source (argv[0], &source))
5819 return CMD_WARNING;
5820
paul020709f2003-04-04 02:44:16 +00005821 ospf_routemap_unset (ospf, source);
5822 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005823}
5824
5825DEFUN (ospf_distribute_list_out,
5826 ospf_distribute_list_out_cmd,
5827 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5828 "Filter networks in routing updates\n"
5829 "Access-list name\n"
5830 OUT_STR
5831 "Kernel routes\n"
5832 "Connected\n"
5833 "Static routes\n"
5834 "Routing Information Protocol (RIP)\n"
5835 "Border Gateway Protocol (BGP)\n")
5836{
paul68980082003-03-25 05:07:42 +00005837 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005838 int source;
5839
5840 /* Get distribute source. */
5841 if (!str2distribute_source (argv[1], &source))
5842 return CMD_WARNING;
5843
paul68980082003-03-25 05:07:42 +00005844 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005845}
5846
5847DEFUN (no_ospf_distribute_list_out,
5848 no_ospf_distribute_list_out_cmd,
5849 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5850 NO_STR
5851 "Filter networks in routing updates\n"
5852 "Access-list name\n"
5853 OUT_STR
5854 "Kernel routes\n"
5855 "Connected\n"
5856 "Static routes\n"
5857 "Routing Information Protocol (RIP)\n"
5858 "Border Gateway Protocol (BGP)\n")
5859{
paul68980082003-03-25 05:07:42 +00005860 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005861 int source;
5862
5863 if (!str2distribute_source (argv[1], &source))
5864 return CMD_WARNING;
5865
paul68980082003-03-25 05:07:42 +00005866 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005867}
5868
5869/* Default information originate. */
5870DEFUN (ospf_default_information_originate_metric_type_routemap,
5871 ospf_default_information_originate_metric_type_routemap_cmd,
5872 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5873 "Control distribution of default information\n"
5874 "Distribute a default route\n"
5875 "OSPF default metric\n"
5876 "OSPF metric\n"
5877 "OSPF metric type for default routes\n"
5878 "Set OSPF External Type 1 metrics\n"
5879 "Set OSPF External Type 2 metrics\n"
5880 "Route map reference\n"
5881 "Pointer to route-map entries\n")
5882{
paul020709f2003-04-04 02:44:16 +00005883 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005884 int type = -1;
5885 int metric = -1;
5886
5887 /* Get metric value. */
5888 if (argc >= 1)
5889 if (!str2metric (argv[0], &metric))
5890 return CMD_WARNING;
5891
5892 /* Get metric type. */
5893 if (argc >= 2)
5894 if (!str2metric_type (argv[1], &type))
5895 return CMD_WARNING;
5896
5897 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005898 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005899 else
paul020709f2003-04-04 02:44:16 +00005900 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005901
paul020709f2003-04-04 02:44:16 +00005902 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5903 type, metric);
paul718e3742002-12-13 20:15:29 +00005904}
5905
5906ALIAS (ospf_default_information_originate_metric_type_routemap,
5907 ospf_default_information_originate_metric_type_cmd,
5908 "default-information originate metric <0-16777214> metric-type (1|2)",
5909 "Control distribution of default information\n"
5910 "Distribute a default route\n"
5911 "OSPF default metric\n"
5912 "OSPF metric\n"
5913 "OSPF metric type for default routes\n"
5914 "Set OSPF External Type 1 metrics\n"
5915 "Set OSPF External Type 2 metrics\n")
5916
5917ALIAS (ospf_default_information_originate_metric_type_routemap,
5918 ospf_default_information_originate_metric_cmd,
5919 "default-information originate metric <0-16777214>",
5920 "Control distribution of default information\n"
5921 "Distribute a default route\n"
5922 "OSPF default metric\n"
5923 "OSPF metric\n")
5924
5925ALIAS (ospf_default_information_originate_metric_type_routemap,
5926 ospf_default_information_originate_cmd,
5927 "default-information originate",
5928 "Control distribution of default information\n"
5929 "Distribute a default route\n")
5930
5931/* Default information originate. */
5932DEFUN (ospf_default_information_originate_metric_routemap,
5933 ospf_default_information_originate_metric_routemap_cmd,
5934 "default-information originate metric <0-16777214> route-map WORD",
5935 "Control distribution of default information\n"
5936 "Distribute a default route\n"
5937 "OSPF default metric\n"
5938 "OSPF metric\n"
5939 "Route map reference\n"
5940 "Pointer to route-map entries\n")
5941{
paul020709f2003-04-04 02:44:16 +00005942 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005943 int metric = -1;
5944
5945 /* Get metric value. */
5946 if (argc >= 1)
5947 if (!str2metric (argv[0], &metric))
5948 return CMD_WARNING;
5949
5950 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005951 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005952 else
paul020709f2003-04-04 02:44:16 +00005953 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005954
paul020709f2003-04-04 02:44:16 +00005955 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5956 -1, metric);
paul718e3742002-12-13 20:15:29 +00005957}
5958
5959/* Default information originate. */
5960DEFUN (ospf_default_information_originate_routemap,
5961 ospf_default_information_originate_routemap_cmd,
5962 "default-information originate route-map WORD",
5963 "Control distribution of default information\n"
5964 "Distribute a default route\n"
5965 "Route map reference\n"
5966 "Pointer to route-map entries\n")
5967{
paul020709f2003-04-04 02:44:16 +00005968 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005969
paul020709f2003-04-04 02:44:16 +00005970 if (argc == 1)
5971 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5972 else
5973 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5974
5975 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005976}
5977
5978DEFUN (ospf_default_information_originate_type_metric_routemap,
5979 ospf_default_information_originate_type_metric_routemap_cmd,
5980 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5981 "Control distribution of default information\n"
5982 "Distribute a default route\n"
5983 "OSPF metric type for default routes\n"
5984 "Set OSPF External Type 1 metrics\n"
5985 "Set OSPF External Type 2 metrics\n"
5986 "OSPF default metric\n"
5987 "OSPF metric\n"
5988 "Route map reference\n"
5989 "Pointer to route-map entries\n")
5990{
paul020709f2003-04-04 02:44:16 +00005991 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005992 int type = -1;
5993 int metric = -1;
5994
5995 /* Get metric type. */
5996 if (argc >= 1)
5997 if (!str2metric_type (argv[0], &type))
5998 return CMD_WARNING;
5999
6000 /* Get metric value. */
6001 if (argc >= 2)
6002 if (!str2metric (argv[1], &metric))
6003 return CMD_WARNING;
6004
6005 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006006 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006007 else
paul020709f2003-04-04 02:44:16 +00006008 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006009
paul020709f2003-04-04 02:44:16 +00006010 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6011 type, metric);
paul718e3742002-12-13 20:15:29 +00006012}
6013
6014ALIAS (ospf_default_information_originate_type_metric_routemap,
6015 ospf_default_information_originate_type_metric_cmd,
6016 "default-information originate metric-type (1|2) metric <0-16777214>",
6017 "Control distribution of default information\n"
6018 "Distribute a default route\n"
6019 "OSPF metric type for default routes\n"
6020 "Set OSPF External Type 1 metrics\n"
6021 "Set OSPF External Type 2 metrics\n"
6022 "OSPF default metric\n"
6023 "OSPF metric\n")
6024
6025ALIAS (ospf_default_information_originate_type_metric_routemap,
6026 ospf_default_information_originate_type_cmd,
6027 "default-information originate metric-type (1|2)",
6028 "Control distribution of default information\n"
6029 "Distribute a default route\n"
6030 "OSPF metric type for default routes\n"
6031 "Set OSPF External Type 1 metrics\n"
6032 "Set OSPF External Type 2 metrics\n")
6033
6034DEFUN (ospf_default_information_originate_type_routemap,
6035 ospf_default_information_originate_type_routemap_cmd,
6036 "default-information originate metric-type (1|2) route-map WORD",
6037 "Control distribution of default information\n"
6038 "Distribute a default route\n"
6039 "OSPF metric type for default routes\n"
6040 "Set OSPF External Type 1 metrics\n"
6041 "Set OSPF External Type 2 metrics\n"
6042 "Route map reference\n"
6043 "Pointer to route-map entries\n")
6044{
paul020709f2003-04-04 02:44:16 +00006045 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006046 int type = -1;
6047
6048 /* Get metric type. */
6049 if (argc >= 1)
6050 if (!str2metric_type (argv[0], &type))
6051 return CMD_WARNING;
6052
6053 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006054 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006055 else
paul020709f2003-04-04 02:44:16 +00006056 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006057
paul020709f2003-04-04 02:44:16 +00006058 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6059 type, -1);
paul718e3742002-12-13 20:15:29 +00006060}
6061
6062DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6063 ospf_default_information_originate_always_metric_type_routemap_cmd,
6064 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6065 "Control distribution of default information\n"
6066 "Distribute a default route\n"
6067 "Always advertise default route\n"
6068 "OSPF default metric\n"
6069 "OSPF metric\n"
6070 "OSPF metric type for default routes\n"
6071 "Set OSPF External Type 1 metrics\n"
6072 "Set OSPF External Type 2 metrics\n"
6073 "Route map reference\n"
6074 "Pointer to route-map entries\n")
6075{
paul020709f2003-04-04 02:44:16 +00006076 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006077 int type = -1;
6078 int metric = -1;
6079
6080 /* Get metric value. */
6081 if (argc >= 1)
6082 if (!str2metric (argv[0], &metric))
6083 return CMD_WARNING;
6084
6085 /* Get metric type. */
6086 if (argc >= 2)
6087 if (!str2metric_type (argv[1], &type))
6088 return CMD_WARNING;
6089
6090 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006091 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006092 else
paul020709f2003-04-04 02:44:16 +00006093 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006094
paul020709f2003-04-04 02:44:16 +00006095 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006096 type, metric);
6097}
6098
6099ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6100 ospf_default_information_originate_always_metric_type_cmd,
6101 "default-information originate always metric <0-16777214> metric-type (1|2)",
6102 "Control distribution of default information\n"
6103 "Distribute a default route\n"
6104 "Always advertise default route\n"
6105 "OSPF default metric\n"
6106 "OSPF metric\n"
6107 "OSPF metric type for default routes\n"
6108 "Set OSPF External Type 1 metrics\n"
6109 "Set OSPF External Type 2 metrics\n")
6110
6111ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6112 ospf_default_information_originate_always_metric_cmd,
6113 "default-information originate always metric <0-16777214>",
6114 "Control distribution of default information\n"
6115 "Distribute a default route\n"
6116 "Always advertise default route\n"
6117 "OSPF default metric\n"
6118 "OSPF metric\n"
6119 "OSPF metric type for default routes\n")
6120
6121ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6122 ospf_default_information_originate_always_cmd,
6123 "default-information originate always",
6124 "Control distribution of default information\n"
6125 "Distribute a default route\n"
6126 "Always advertise default route\n")
6127
6128DEFUN (ospf_default_information_originate_always_metric_routemap,
6129 ospf_default_information_originate_always_metric_routemap_cmd,
6130 "default-information originate always metric <0-16777214> route-map WORD",
6131 "Control distribution of default information\n"
6132 "Distribute a default route\n"
6133 "Always advertise default route\n"
6134 "OSPF default metric\n"
6135 "OSPF metric\n"
6136 "Route map reference\n"
6137 "Pointer to route-map entries\n")
6138{
paul020709f2003-04-04 02:44:16 +00006139 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006140 int metric = -1;
6141
6142 /* Get metric value. */
6143 if (argc >= 1)
6144 if (!str2metric (argv[0], &metric))
6145 return CMD_WARNING;
6146
6147 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006148 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006149 else
paul020709f2003-04-04 02:44:16 +00006150 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006151
paul020709f2003-04-04 02:44:16 +00006152 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6153 -1, metric);
paul718e3742002-12-13 20:15:29 +00006154}
6155
6156DEFUN (ospf_default_information_originate_always_routemap,
6157 ospf_default_information_originate_always_routemap_cmd,
6158 "default-information originate always route-map WORD",
6159 "Control distribution of default information\n"
6160 "Distribute a default route\n"
6161 "Always advertise default route\n"
6162 "Route map reference\n"
6163 "Pointer to route-map entries\n")
6164{
paul020709f2003-04-04 02:44:16 +00006165 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006166
paul020709f2003-04-04 02:44:16 +00006167 if (argc == 1)
6168 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6169 else
6170 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6171
6172 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006173}
6174
6175DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6176 ospf_default_information_originate_always_type_metric_routemap_cmd,
6177 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6178 "Control distribution of default information\n"
6179 "Distribute a default route\n"
6180 "Always advertise default route\n"
6181 "OSPF metric type for default routes\n"
6182 "Set OSPF External Type 1 metrics\n"
6183 "Set OSPF External Type 2 metrics\n"
6184 "OSPF default metric\n"
6185 "OSPF metric\n"
6186 "Route map reference\n"
6187 "Pointer to route-map entries\n")
6188{
paul020709f2003-04-04 02:44:16 +00006189 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006190 int type = -1;
6191 int metric = -1;
6192
6193 /* Get metric type. */
6194 if (argc >= 1)
6195 if (!str2metric_type (argv[0], &type))
6196 return CMD_WARNING;
6197
6198 /* Get metric value. */
6199 if (argc >= 2)
6200 if (!str2metric (argv[1], &metric))
6201 return CMD_WARNING;
6202
6203 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006204 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006205 else
paul020709f2003-04-04 02:44:16 +00006206 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006207
paul020709f2003-04-04 02:44:16 +00006208 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006209 type, metric);
6210}
6211
6212ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6213 ospf_default_information_originate_always_type_metric_cmd,
6214 "default-information originate always metric-type (1|2) metric <0-16777214>",
6215 "Control distribution of default information\n"
6216 "Distribute a default route\n"
6217 "Always advertise default route\n"
6218 "OSPF metric type for default routes\n"
6219 "Set OSPF External Type 1 metrics\n"
6220 "Set OSPF External Type 2 metrics\n"
6221 "OSPF default metric\n"
6222 "OSPF metric\n")
6223
6224ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6225 ospf_default_information_originate_always_type_cmd,
6226 "default-information originate always metric-type (1|2)",
6227 "Control distribution of default information\n"
6228 "Distribute a default route\n"
6229 "Always advertise default route\n"
6230 "OSPF metric type for default routes\n"
6231 "Set OSPF External Type 1 metrics\n"
6232 "Set OSPF External Type 2 metrics\n")
6233
6234DEFUN (ospf_default_information_originate_always_type_routemap,
6235 ospf_default_information_originate_always_type_routemap_cmd,
6236 "default-information originate always metric-type (1|2) route-map WORD",
6237 "Control distribution of default information\n"
6238 "Distribute a default route\n"
6239 "Always advertise default route\n"
6240 "OSPF metric type for default routes\n"
6241 "Set OSPF External Type 1 metrics\n"
6242 "Set OSPF External Type 2 metrics\n"
6243 "Route map reference\n"
6244 "Pointer to route-map entries\n")
6245{
paul020709f2003-04-04 02:44:16 +00006246 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006247 int type = -1;
6248
6249 /* Get metric type. */
6250 if (argc >= 1)
6251 if (!str2metric_type (argv[0], &type))
6252 return CMD_WARNING;
6253
6254 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006255 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006256 else
paul020709f2003-04-04 02:44:16 +00006257 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006258
paul020709f2003-04-04 02:44:16 +00006259 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006260 type, -1);
6261}
6262
6263DEFUN (no_ospf_default_information_originate,
6264 no_ospf_default_information_originate_cmd,
6265 "no default-information originate",
6266 NO_STR
6267 "Control distribution of default information\n"
6268 "Distribute a default route\n")
6269{
paul68980082003-03-25 05:07:42 +00006270 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006271 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006272
6273 p.family = AF_INET;
6274 p.prefix.s_addr = 0;
6275 p.prefixlen = 0;
6276
ajs5339cfd2005-09-19 13:28:05 +00006277 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006278
6279 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6280 ospf_external_info_delete (DEFAULT_ROUTE, p);
6281 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6282 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6283 }
6284
paul020709f2003-04-04 02:44:16 +00006285 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6286 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006287}
6288
6289DEFUN (ospf_default_metric,
6290 ospf_default_metric_cmd,
6291 "default-metric <0-16777214>",
6292 "Set metric of redistributed routes\n"
6293 "Default metric\n")
6294{
paul68980082003-03-25 05:07:42 +00006295 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006296 int metric = -1;
6297
6298 if (!str2metric (argv[0], &metric))
6299 return CMD_WARNING;
6300
paul68980082003-03-25 05:07:42 +00006301 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006302
6303 return CMD_SUCCESS;
6304}
6305
6306DEFUN (no_ospf_default_metric,
6307 no_ospf_default_metric_cmd,
6308 "no default-metric",
6309 NO_STR
6310 "Set metric of redistributed routes\n")
6311{
paul68980082003-03-25 05:07:42 +00006312 struct ospf *ospf = vty->index;
6313
6314 ospf->default_metric = -1;
6315
paul718e3742002-12-13 20:15:29 +00006316 return CMD_SUCCESS;
6317}
6318
6319ALIAS (no_ospf_default_metric,
6320 no_ospf_default_metric_val_cmd,
6321 "no default-metric <0-16777214>",
6322 NO_STR
6323 "Set metric of redistributed routes\n"
6324 "Default metric\n")
6325
6326DEFUN (ospf_distance,
6327 ospf_distance_cmd,
6328 "distance <1-255>",
6329 "Define an administrative distance\n"
6330 "OSPF Administrative distance\n")
6331{
paul68980082003-03-25 05:07:42 +00006332 struct ospf *ospf = vty->index;
6333
6334 ospf->distance_all = atoi (argv[0]);
6335
paul718e3742002-12-13 20:15:29 +00006336 return CMD_SUCCESS;
6337}
6338
6339DEFUN (no_ospf_distance,
6340 no_ospf_distance_cmd,
6341 "no distance <1-255>",
6342 NO_STR
6343 "Define an administrative distance\n"
6344 "OSPF Administrative distance\n")
6345{
paul68980082003-03-25 05:07:42 +00006346 struct ospf *ospf = vty->index;
6347
6348 ospf->distance_all = 0;
6349
paul718e3742002-12-13 20:15:29 +00006350 return CMD_SUCCESS;
6351}
6352
6353DEFUN (no_ospf_distance_ospf,
6354 no_ospf_distance_ospf_cmd,
6355 "no distance ospf",
6356 NO_STR
6357 "Define an administrative distance\n"
6358 "OSPF Administrative distance\n"
6359 "OSPF Distance\n")
6360{
paul68980082003-03-25 05:07:42 +00006361 struct ospf *ospf = vty->index;
6362
6363 ospf->distance_intra = 0;
6364 ospf->distance_inter = 0;
6365 ospf->distance_external = 0;
6366
paul718e3742002-12-13 20:15:29 +00006367 return CMD_SUCCESS;
6368}
6369
6370DEFUN (ospf_distance_ospf_intra,
6371 ospf_distance_ospf_intra_cmd,
6372 "distance ospf intra-area <1-255>",
6373 "Define an administrative distance\n"
6374 "OSPF Administrative distance\n"
6375 "Intra-area routes\n"
6376 "Distance for intra-area routes\n")
6377{
paul68980082003-03-25 05:07:42 +00006378 struct ospf *ospf = vty->index;
6379
6380 ospf->distance_intra = atoi (argv[0]);
6381
paul718e3742002-12-13 20:15:29 +00006382 return CMD_SUCCESS;
6383}
6384
6385DEFUN (ospf_distance_ospf_intra_inter,
6386 ospf_distance_ospf_intra_inter_cmd,
6387 "distance ospf intra-area <1-255> inter-area <1-255>",
6388 "Define an administrative distance\n"
6389 "OSPF Administrative distance\n"
6390 "Intra-area routes\n"
6391 "Distance for intra-area routes\n"
6392 "Inter-area routes\n"
6393 "Distance for inter-area routes\n")
6394{
paul68980082003-03-25 05:07:42 +00006395 struct ospf *ospf = vty->index;
6396
6397 ospf->distance_intra = atoi (argv[0]);
6398 ospf->distance_inter = atoi (argv[1]);
6399
paul718e3742002-12-13 20:15:29 +00006400 return CMD_SUCCESS;
6401}
6402
6403DEFUN (ospf_distance_ospf_intra_external,
6404 ospf_distance_ospf_intra_external_cmd,
6405 "distance ospf intra-area <1-255> external <1-255>",
6406 "Define an administrative distance\n"
6407 "OSPF Administrative distance\n"
6408 "Intra-area routes\n"
6409 "Distance for intra-area routes\n"
6410 "External routes\n"
6411 "Distance for external routes\n")
6412{
paul68980082003-03-25 05:07:42 +00006413 struct ospf *ospf = vty->index;
6414
6415 ospf->distance_intra = atoi (argv[0]);
6416 ospf->distance_external = atoi (argv[1]);
6417
paul718e3742002-12-13 20:15:29 +00006418 return CMD_SUCCESS;
6419}
6420
6421DEFUN (ospf_distance_ospf_intra_inter_external,
6422 ospf_distance_ospf_intra_inter_external_cmd,
6423 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6424 "Define an administrative distance\n"
6425 "OSPF Administrative distance\n"
6426 "Intra-area routes\n"
6427 "Distance for intra-area routes\n"
6428 "Inter-area routes\n"
6429 "Distance for inter-area routes\n"
6430 "External routes\n"
6431 "Distance for external routes\n")
6432{
paul68980082003-03-25 05:07:42 +00006433 struct ospf *ospf = vty->index;
6434
6435 ospf->distance_intra = atoi (argv[0]);
6436 ospf->distance_inter = atoi (argv[1]);
6437 ospf->distance_external = atoi (argv[2]);
6438
paul718e3742002-12-13 20:15:29 +00006439 return CMD_SUCCESS;
6440}
6441
6442DEFUN (ospf_distance_ospf_intra_external_inter,
6443 ospf_distance_ospf_intra_external_inter_cmd,
6444 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6445 "Define an administrative distance\n"
6446 "OSPF Administrative distance\n"
6447 "Intra-area routes\n"
6448 "Distance for intra-area routes\n"
6449 "External routes\n"
6450 "Distance for external routes\n"
6451 "Inter-area routes\n"
6452 "Distance for inter-area routes\n")
6453{
paul68980082003-03-25 05:07:42 +00006454 struct ospf *ospf = vty->index;
6455
6456 ospf->distance_intra = atoi (argv[0]);
6457 ospf->distance_external = atoi (argv[1]);
6458 ospf->distance_inter = atoi (argv[2]);
6459
paul718e3742002-12-13 20:15:29 +00006460 return CMD_SUCCESS;
6461}
6462
6463DEFUN (ospf_distance_ospf_inter,
6464 ospf_distance_ospf_inter_cmd,
6465 "distance ospf inter-area <1-255>",
6466 "Define an administrative distance\n"
6467 "OSPF Administrative distance\n"
6468 "Inter-area routes\n"
6469 "Distance for inter-area routes\n")
6470{
paul68980082003-03-25 05:07:42 +00006471 struct ospf *ospf = vty->index;
6472
6473 ospf->distance_inter = atoi (argv[0]);
6474
paul718e3742002-12-13 20:15:29 +00006475 return CMD_SUCCESS;
6476}
6477
6478DEFUN (ospf_distance_ospf_inter_intra,
6479 ospf_distance_ospf_inter_intra_cmd,
6480 "distance ospf inter-area <1-255> intra-area <1-255>",
6481 "Define an administrative distance\n"
6482 "OSPF Administrative distance\n"
6483 "Inter-area routes\n"
6484 "Distance for inter-area routes\n"
6485 "Intra-area routes\n"
6486 "Distance for intra-area routes\n")
6487{
paul68980082003-03-25 05:07:42 +00006488 struct ospf *ospf = vty->index;
6489
6490 ospf->distance_inter = atoi (argv[0]);
6491 ospf->distance_intra = atoi (argv[1]);
6492
paul718e3742002-12-13 20:15:29 +00006493 return CMD_SUCCESS;
6494}
6495
6496DEFUN (ospf_distance_ospf_inter_external,
6497 ospf_distance_ospf_inter_external_cmd,
6498 "distance ospf inter-area <1-255> external <1-255>",
6499 "Define an administrative distance\n"
6500 "OSPF Administrative distance\n"
6501 "Inter-area routes\n"
6502 "Distance for inter-area routes\n"
6503 "External routes\n"
6504 "Distance for external routes\n")
6505{
paul68980082003-03-25 05:07:42 +00006506 struct ospf *ospf = vty->index;
6507
6508 ospf->distance_inter = atoi (argv[0]);
6509 ospf->distance_external = atoi (argv[1]);
6510
paul718e3742002-12-13 20:15:29 +00006511 return CMD_SUCCESS;
6512}
6513
6514DEFUN (ospf_distance_ospf_inter_intra_external,
6515 ospf_distance_ospf_inter_intra_external_cmd,
6516 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6517 "Define an administrative distance\n"
6518 "OSPF Administrative distance\n"
6519 "Inter-area routes\n"
6520 "Distance for inter-area routes\n"
6521 "Intra-area routes\n"
6522 "Distance for intra-area routes\n"
6523 "External routes\n"
6524 "Distance for external routes\n")
6525{
paul68980082003-03-25 05:07:42 +00006526 struct ospf *ospf = vty->index;
6527
6528 ospf->distance_inter = atoi (argv[0]);
6529 ospf->distance_intra = atoi (argv[1]);
6530 ospf->distance_external = atoi (argv[2]);
6531
paul718e3742002-12-13 20:15:29 +00006532 return CMD_SUCCESS;
6533}
6534
6535DEFUN (ospf_distance_ospf_inter_external_intra,
6536 ospf_distance_ospf_inter_external_intra_cmd,
6537 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6538 "Define an administrative distance\n"
6539 "OSPF Administrative distance\n"
6540 "Inter-area routes\n"
6541 "Distance for inter-area routes\n"
6542 "External routes\n"
6543 "Distance for external routes\n"
6544 "Intra-area routes\n"
6545 "Distance for intra-area routes\n")
6546{
paul68980082003-03-25 05:07:42 +00006547 struct ospf *ospf = vty->index;
6548
6549 ospf->distance_inter = atoi (argv[0]);
6550 ospf->distance_external = atoi (argv[1]);
6551 ospf->distance_intra = atoi (argv[2]);
6552
paul718e3742002-12-13 20:15:29 +00006553 return CMD_SUCCESS;
6554}
6555
6556DEFUN (ospf_distance_ospf_external,
6557 ospf_distance_ospf_external_cmd,
6558 "distance ospf external <1-255>",
6559 "Define an administrative distance\n"
6560 "OSPF Administrative distance\n"
6561 "External routes\n"
6562 "Distance for external routes\n")
6563{
paul68980082003-03-25 05:07:42 +00006564 struct ospf *ospf = vty->index;
6565
6566 ospf->distance_external = atoi (argv[0]);
6567
paul718e3742002-12-13 20:15:29 +00006568 return CMD_SUCCESS;
6569}
6570
6571DEFUN (ospf_distance_ospf_external_intra,
6572 ospf_distance_ospf_external_intra_cmd,
6573 "distance ospf external <1-255> intra-area <1-255>",
6574 "Define an administrative distance\n"
6575 "OSPF Administrative distance\n"
6576 "External routes\n"
6577 "Distance for external routes\n"
6578 "Intra-area routes\n"
6579 "Distance for intra-area routes\n")
6580{
paul68980082003-03-25 05:07:42 +00006581 struct ospf *ospf = vty->index;
6582
6583 ospf->distance_external = atoi (argv[0]);
6584 ospf->distance_intra = atoi (argv[1]);
6585
paul718e3742002-12-13 20:15:29 +00006586 return CMD_SUCCESS;
6587}
6588
6589DEFUN (ospf_distance_ospf_external_inter,
6590 ospf_distance_ospf_external_inter_cmd,
6591 "distance ospf external <1-255> inter-area <1-255>",
6592 "Define an administrative distance\n"
6593 "OSPF Administrative distance\n"
6594 "External routes\n"
6595 "Distance for external routes\n"
6596 "Inter-area routes\n"
6597 "Distance for inter-area routes\n")
6598{
paul68980082003-03-25 05:07:42 +00006599 struct ospf *ospf = vty->index;
6600
6601 ospf->distance_external = atoi (argv[0]);
6602 ospf->distance_inter = atoi (argv[1]);
6603
paul718e3742002-12-13 20:15:29 +00006604 return CMD_SUCCESS;
6605}
6606
6607DEFUN (ospf_distance_ospf_external_intra_inter,
6608 ospf_distance_ospf_external_intra_inter_cmd,
6609 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6610 "Define an administrative distance\n"
6611 "OSPF Administrative distance\n"
6612 "External routes\n"
6613 "Distance for external routes\n"
6614 "Intra-area routes\n"
6615 "Distance for intra-area routes\n"
6616 "Inter-area routes\n"
6617 "Distance for inter-area routes\n")
6618{
paul68980082003-03-25 05:07:42 +00006619 struct ospf *ospf = vty->index;
6620
6621 ospf->distance_external = atoi (argv[0]);
6622 ospf->distance_intra = atoi (argv[1]);
6623 ospf->distance_inter = atoi (argv[2]);
6624
paul718e3742002-12-13 20:15:29 +00006625 return CMD_SUCCESS;
6626}
6627
6628DEFUN (ospf_distance_ospf_external_inter_intra,
6629 ospf_distance_ospf_external_inter_intra_cmd,
6630 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6631 "Define an administrative distance\n"
6632 "OSPF Administrative distance\n"
6633 "External routes\n"
6634 "Distance for external routes\n"
6635 "Inter-area routes\n"
6636 "Distance for inter-area routes\n"
6637 "Intra-area routes\n"
6638 "Distance for intra-area routes\n")
6639{
paul68980082003-03-25 05:07:42 +00006640 struct ospf *ospf = vty->index;
6641
6642 ospf->distance_external = atoi (argv[0]);
6643 ospf->distance_inter = atoi (argv[1]);
6644 ospf->distance_intra = atoi (argv[2]);
6645
paul718e3742002-12-13 20:15:29 +00006646 return CMD_SUCCESS;
6647}
6648
6649DEFUN (ospf_distance_source,
6650 ospf_distance_source_cmd,
6651 "distance <1-255> A.B.C.D/M",
6652 "Administrative distance\n"
6653 "Distance value\n"
6654 "IP source prefix\n")
6655{
paul020709f2003-04-04 02:44:16 +00006656 struct ospf *ospf = vty->index;
6657
6658 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006659
paul718e3742002-12-13 20:15:29 +00006660 return CMD_SUCCESS;
6661}
6662
6663DEFUN (no_ospf_distance_source,
6664 no_ospf_distance_source_cmd,
6665 "no distance <1-255> A.B.C.D/M",
6666 NO_STR
6667 "Administrative distance\n"
6668 "Distance value\n"
6669 "IP source prefix\n")
6670{
paul020709f2003-04-04 02:44:16 +00006671 struct ospf *ospf = vty->index;
6672
6673 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6674
paul718e3742002-12-13 20:15:29 +00006675 return CMD_SUCCESS;
6676}
6677
6678DEFUN (ospf_distance_source_access_list,
6679 ospf_distance_source_access_list_cmd,
6680 "distance <1-255> A.B.C.D/M WORD",
6681 "Administrative distance\n"
6682 "Distance value\n"
6683 "IP source prefix\n"
6684 "Access list name\n")
6685{
paul020709f2003-04-04 02:44:16 +00006686 struct ospf *ospf = vty->index;
6687
6688 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6689
paul718e3742002-12-13 20:15:29 +00006690 return CMD_SUCCESS;
6691}
6692
6693DEFUN (no_ospf_distance_source_access_list,
6694 no_ospf_distance_source_access_list_cmd,
6695 "no distance <1-255> A.B.C.D/M WORD",
6696 NO_STR
6697 "Administrative distance\n"
6698 "Distance value\n"
6699 "IP source prefix\n"
6700 "Access list name\n")
6701{
paul020709f2003-04-04 02:44:16 +00006702 struct ospf *ospf = vty->index;
6703
6704 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6705
paul718e3742002-12-13 20:15:29 +00006706 return CMD_SUCCESS;
6707}
6708
vincentba682532005-09-29 13:52:57 +00006709DEFUN (ip_ospf_mtu_ignore,
6710 ip_ospf_mtu_ignore_addr_cmd,
6711 "ip ospf mtu-ignore A.B.C.D",
6712 "IP Information\n"
6713 "OSPF interface commands\n"
6714 "Disable mtu mismatch detection\n"
6715 "Address of interface")
6716{
6717 struct interface *ifp = vty->index;
6718 struct in_addr addr;
6719 int ret;
6720
6721 struct ospf_if_params *params;
6722 params = IF_DEF_PARAMS (ifp);
6723
6724 if (argc == 1)
6725 {
6726 ret = inet_aton(argv[0], &addr);
6727 if (!ret)
6728 {
6729 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6730 VTY_NEWLINE);
6731 return CMD_WARNING;
6732 }
6733 params = ospf_get_if_params (ifp, addr);
6734 ospf_if_update_params (ifp, addr);
6735 }
6736 params->mtu_ignore = 1;
6737 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6738 SET_IF_PARAM (params, mtu_ignore);
6739 else
6740 {
6741 UNSET_IF_PARAM (params, mtu_ignore);
6742 if (params != IF_DEF_PARAMS (ifp))
6743 {
6744 ospf_free_if_params (ifp, addr);
6745 ospf_if_update_params (ifp, addr);
6746 }
6747 }
6748 return CMD_SUCCESS;
6749}
6750
6751ALIAS (ip_ospf_mtu_ignore,
6752 ip_ospf_mtu_ignore_cmd,
6753 "ip ospf mtu-ignore",
6754 "IP Information\n"
6755 "OSPF interface commands\n"
6756 "Disable mtu mismatch detection\n")
6757
6758
6759DEFUN (no_ip_ospf_mtu_ignore,
6760 no_ip_ospf_mtu_ignore_addr_cmd,
6761 "no ip ospf mtu-ignore A.B.C.D",
6762 "IP Information\n"
6763 "OSPF interface commands\n"
6764 "Disable mtu mismatch detection\n"
6765 "Address of interface")
6766{
6767 struct interface *ifp = vty->index;
6768 struct in_addr addr;
6769 int ret;
6770
6771 struct ospf_if_params *params;
6772 params = IF_DEF_PARAMS (ifp);
6773
6774 if (argc == 1)
6775 {
6776 ret = inet_aton(argv[0], &addr);
6777 if (!ret)
6778 {
6779 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6780 VTY_NEWLINE);
6781 return CMD_WARNING;
6782 }
6783 params = ospf_get_if_params (ifp, addr);
6784 ospf_if_update_params (ifp, addr);
6785 }
6786 params->mtu_ignore = 0;
6787 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6788 SET_IF_PARAM (params, mtu_ignore);
6789 else
6790 {
6791 UNSET_IF_PARAM (params, mtu_ignore);
6792 if (params != IF_DEF_PARAMS (ifp))
6793 {
6794 ospf_free_if_params (ifp, addr);
6795 ospf_if_update_params (ifp, addr);
6796 }
6797 }
6798 return CMD_SUCCESS;
6799}
6800
6801ALIAS (no_ip_ospf_mtu_ignore,
6802 no_ip_ospf_mtu_ignore_cmd,
6803 "no ip ospf mtu-ignore",
6804 "IP Information\n"
6805 "OSPF interface commands\n"
6806 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00006807
6808DEFUN (ospf_max_metric_router_lsa_admin,
6809 ospf_max_metric_router_lsa_admin_cmd,
6810 "max-metric router-lsa administrative",
6811 "OSPF maximum / infinite-distance metric\n"
6812 "Advertise own Router-LSA with infinite distance (stub router)\n"
6813 "Administratively applied, for an indefinite period\n")
6814{
6815 struct listnode *ln;
6816 struct ospf_area *area;
6817 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006818
paul88d6cf32005-10-29 12:50:09 +00006819 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6820 {
6821 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6822
6823 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
6824 ospf_router_lsa_timer_add (area);
6825 }
6826 return CMD_SUCCESS;
6827}
6828
6829DEFUN (no_ospf_max_metric_router_lsa_admin,
6830 no_ospf_max_metric_router_lsa_admin_cmd,
6831 "no max-metric router-lsa administrative",
6832 NO_STR
6833 "OSPF maximum / infinite-distance metric\n"
6834 "Advertise own Router-LSA with infinite distance (stub router)\n"
6835 "Administratively applied, for an indefinite period\n")
6836{
6837 struct listnode *ln;
6838 struct ospf_area *area;
6839 struct ospf *ospf = vty->index;
6840
6841 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6842 {
6843 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6844
6845 /* Don't trample on the start-up stub timer */
6846 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6847 && !area->t_stub_router)
6848 {
6849 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6850 ospf_router_lsa_timer_add (area);
6851 }
6852 }
6853 return CMD_SUCCESS;
6854}
6855
6856DEFUN (ospf_max_metric_router_lsa_startup,
6857 ospf_max_metric_router_lsa_startup_cmd,
6858 "max-metric router-lsa on-startup <5-86400>",
6859 "OSPF maximum / infinite-distance metric\n"
6860 "Advertise own Router-LSA with infinite distance (stub router)\n"
6861 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6862 "Time (seconds) to advertise self as stub-router\n")
6863{
6864 unsigned int seconds;
6865 struct ospf *ospf = vty->index;
6866
6867 if (argc != 1)
6868 {
6869 vty_out (vty, "%% Must supply stub-router period");
6870 return CMD_WARNING;
6871 }
6872
6873 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6874
6875 ospf->stub_router_startup_time = seconds;
6876
6877 return CMD_SUCCESS;
6878}
6879
6880DEFUN (no_ospf_max_metric_router_lsa_startup,
6881 no_ospf_max_metric_router_lsa_startup_cmd,
6882 "no max-metric router-lsa on-startup",
6883 NO_STR
6884 "OSPF maximum / infinite-distance metric\n"
6885 "Advertise own Router-LSA with infinite distance (stub router)\n"
6886 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6887{
6888 struct listnode *ln;
6889 struct ospf_area *area;
6890 struct ospf *ospf = vty->index;
6891
6892 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6893
6894 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6895 {
6896 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6897 OSPF_TIMER_OFF (area->t_stub_router);
6898
6899 /* Don't trample on admin stub routed */
6900 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6901 {
6902 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
6903 ospf_router_lsa_timer_add (area);
6904 }
6905 }
6906 return CMD_SUCCESS;
6907}
6908
6909DEFUN (ospf_max_metric_router_lsa_shutdown,
6910 ospf_max_metric_router_lsa_shutdown_cmd,
6911 "max-metric router-lsa on-shutdown <5-86400>",
6912 "OSPF maximum / infinite-distance metric\n"
6913 "Advertise own Router-LSA with infinite distance (stub router)\n"
6914 "Advertise stub-router prior to full shutdown of OSPF\n"
6915 "Time (seconds) to wait till full shutdown\n")
6916{
6917 unsigned int seconds;
6918 struct ospf *ospf = vty->index;
6919
6920 if (argc != 1)
6921 {
6922 vty_out (vty, "%% Must supply stub-router shutdown period");
6923 return CMD_WARNING;
6924 }
6925
6926 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6927
6928 ospf->stub_router_shutdown_time = seconds;
6929
6930 return CMD_SUCCESS;
6931}
6932
6933DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6934 no_ospf_max_metric_router_lsa_shutdown_cmd,
6935 "no max-metric router-lsa on-shutdown",
6936 NO_STR
6937 "OSPF maximum / infinite-distance metric\n"
6938 "Advertise own Router-LSA with infinite distance (stub router)\n"
6939 "Advertise stub-router prior to full shutdown of OSPF\n")
6940{
6941 struct ospf *ospf = vty->index;
6942
6943 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6944
6945 return CMD_SUCCESS;
6946}
6947
6948static void
6949config_write_stub_router (struct vty *vty, struct ospf *ospf)
6950{
6951 struct listnode *ln;
6952 struct ospf_area *area;
6953
6954 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6955 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6956 ospf->stub_router_startup_time, VTY_NEWLINE);
6957 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6958 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6959 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6960 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6961 {
6962 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6963 {
6964 vty_out (vty, " max-metric router-lsa administrative%s",
6965 VTY_NEWLINE);
6966 break;
6967 }
6968 }
6969 return;
6970}
6971
paul4dadc292005-05-06 21:37:42 +00006972static void
paul718e3742002-12-13 20:15:29 +00006973show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6974{
6975 struct route_node *rn;
6976 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006977 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006978 struct ospf_path *path;
6979
6980 vty_out (vty, "============ OSPF network routing table ============%s",
6981 VTY_NEWLINE);
6982
6983 for (rn = route_top (rt); rn; rn = route_next (rn))
6984 if ((or = rn->info) != NULL)
6985 {
6986 char buf1[19];
6987 snprintf (buf1, 19, "%s/%d",
6988 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6989
6990 switch (or->path_type)
6991 {
6992 case OSPF_PATH_INTER_AREA:
6993 if (or->type == OSPF_DESTINATION_NETWORK)
6994 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6995 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6996 else if (or->type == OSPF_DESTINATION_DISCARD)
6997 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6998 break;
6999 case OSPF_PATH_INTRA_AREA:
7000 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7001 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7002 break;
7003 default:
7004 break;
7005 }
7006
7007 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007008 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007009 {
hasso54bedb52005-08-17 13:31:47 +00007010 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00007011 {
7012 if (path->nexthop.s_addr == 0)
7013 vty_out (vty, "%24s directly attached to %s%s",
7014 "", path->oi->ifp->name, VTY_NEWLINE);
7015 else
7016 vty_out (vty, "%24s via %s, %s%s", "",
7017 inet_ntoa (path->nexthop), path->oi->ifp->name,
7018 VTY_NEWLINE);
7019 }
7020 }
paul718e3742002-12-13 20:15:29 +00007021 }
7022 vty_out (vty, "%s", VTY_NEWLINE);
7023}
7024
paul4dadc292005-05-06 21:37:42 +00007025static void
paul718e3742002-12-13 20:15:29 +00007026show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7027{
7028 struct route_node *rn;
7029 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007030 struct listnode *pnode;
7031 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007032 struct ospf_path *path;
7033
7034 vty_out (vty, "============ OSPF router routing table =============%s",
7035 VTY_NEWLINE);
7036 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7037 if (rn->info)
7038 {
7039 int flag = 0;
7040
7041 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7042
paul1eb8ef22005-04-07 07:30:20 +00007043 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7044 {
7045 if (flag++)
7046 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007047
paul1eb8ef22005-04-07 07:30:20 +00007048 /* Show path. */
7049 vty_out (vty, "%s [%d] area: %s",
7050 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7051 or->cost, inet_ntoa (or->u.std.area_id));
7052 /* Show flags. */
7053 vty_out (vty, "%s%s%s",
7054 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7055 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7056 VTY_NEWLINE);
7057
7058 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7059 {
hasso54bedb52005-08-17 13:31:47 +00007060 if (path->oi != NULL && ospf_if_exists(path->oi))
7061 {
7062 if (path->nexthop.s_addr == 0)
7063 vty_out (vty, "%24s directly attached to %s%s",
7064 "", path->oi->ifp->name, VTY_NEWLINE);
7065 else
7066 vty_out (vty, "%24s via %s, %s%s", "",
7067 inet_ntoa (path->nexthop),
7068 path->oi->ifp->name, VTY_NEWLINE);
7069 }
paul1eb8ef22005-04-07 07:30:20 +00007070 }
7071 }
paul718e3742002-12-13 20:15:29 +00007072 }
7073 vty_out (vty, "%s", VTY_NEWLINE);
7074}
7075
paul4dadc292005-05-06 21:37:42 +00007076static void
paul718e3742002-12-13 20:15:29 +00007077show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7078{
7079 struct route_node *rn;
7080 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007081 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007082 struct ospf_path *path;
7083
7084 vty_out (vty, "============ OSPF external routing table ===========%s",
7085 VTY_NEWLINE);
7086 for (rn = route_top (rt); rn; rn = route_next (rn))
7087 if ((er = rn->info) != NULL)
7088 {
7089 char buf1[19];
7090 snprintf (buf1, 19, "%s/%d",
7091 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7092
7093 switch (er->path_type)
7094 {
7095 case OSPF_PATH_TYPE1_EXTERNAL:
7096 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7097 er->cost, er->u.ext.tag, VTY_NEWLINE);
7098 break;
7099 case OSPF_PATH_TYPE2_EXTERNAL:
7100 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7101 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7102 break;
7103 }
7104
paul1eb8ef22005-04-07 07:30:20 +00007105 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007106 {
hasso54bedb52005-08-17 13:31:47 +00007107 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00007108 {
7109 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007110 vty_out (vty, "%24s directly attached to %s%s",
7111 "", path->oi->ifp->name, VTY_NEWLINE);
7112 else
7113 vty_out (vty, "%24s via %s, %s%s", "",
7114 inet_ntoa (path->nexthop), path->oi->ifp->name,
7115 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007116 }
7117 }
7118 }
7119 vty_out (vty, "%s", VTY_NEWLINE);
7120}
7121
paul718e3742002-12-13 20:15:29 +00007122DEFUN (show_ip_ospf_border_routers,
7123 show_ip_ospf_border_routers_cmd,
7124 "show ip ospf border-routers",
7125 SHOW_STR
7126 IP_STR
7127 "show all the ABR's and ASBR's\n"
7128 "for this area\n")
7129{
paul020709f2003-04-04 02:44:16 +00007130 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007131
paul020709f2003-04-04 02:44:16 +00007132 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007133 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00007134 {
7135 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
7136 return CMD_SUCCESS;
7137 }
7138
paul68980082003-03-25 05:07:42 +00007139 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007140 {
7141 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7142 return CMD_SUCCESS;
7143 }
7144
7145 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007146 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007147
7148 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007149 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007150
7151 return CMD_SUCCESS;
7152}
paul718e3742002-12-13 20:15:29 +00007153
7154DEFUN (show_ip_ospf_route,
7155 show_ip_ospf_route_cmd,
7156 "show ip ospf route",
7157 SHOW_STR
7158 IP_STR
7159 "OSPF information\n"
7160 "OSPF routing table\n")
7161{
paul020709f2003-04-04 02:44:16 +00007162 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007163
paul020709f2003-04-04 02:44:16 +00007164 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007165 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00007166 {
7167 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
7168 return CMD_SUCCESS;
7169 }
7170
paul68980082003-03-25 05:07:42 +00007171 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007172 {
7173 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7174 return CMD_SUCCESS;
7175 }
7176
7177 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007178 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007179
7180 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007181 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007182
7183 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007184 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007185
7186 return CMD_SUCCESS;
7187}
7188
7189
hassoeb1ce602004-10-08 08:17:22 +00007190const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007191{
7192 "unknown",
7193 "standard",
7194 "ibm",
7195 "cisco",
7196 "shortcut"
7197};
7198
hassoeb1ce602004-10-08 08:17:22 +00007199const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007200{
7201 "default",
7202 "enable",
7203 "disable"
7204};
7205
7206
paul4dadc292005-05-06 21:37:42 +00007207static void
paul718e3742002-12-13 20:15:29 +00007208area_id2str (char *buf, int length, struct ospf_area *area)
7209{
7210 memset (buf, 0, length);
7211
7212 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7213 strncpy (buf, inet_ntoa (area->area_id), length);
7214 else
7215 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7216}
7217
7218
hassoeb1ce602004-10-08 08:17:22 +00007219const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007220{
7221 "unknown", /* should never be used. */
7222 "point-to-point",
7223 "broadcast",
7224 "non-broadcast",
7225 "point-to-multipoint",
7226 "virtual-link", /* should never be used. */
7227 "loopback"
7228};
7229
7230/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007231static int
paul718e3742002-12-13 20:15:29 +00007232config_write_interface (struct vty *vty)
7233{
hasso52dc7ee2004-09-23 19:18:23 +00007234 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007235 struct interface *ifp;
7236 struct crypt_key *ck;
7237 int write = 0;
7238 struct route_node *rn = NULL;
7239 struct ospf_if_params *params;
7240
paul1eb8ef22005-04-07 07:30:20 +00007241 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007242 {
paul718e3742002-12-13 20:15:29 +00007243 if (memcmp (ifp->name, "VLINK", 5) == 0)
7244 continue;
7245
7246 vty_out (vty, "!%s", VTY_NEWLINE);
7247 vty_out (vty, "interface %s%s", ifp->name,
7248 VTY_NEWLINE);
7249 if (ifp->desc)
7250 vty_out (vty, " description %s%s", ifp->desc,
7251 VTY_NEWLINE);
7252
7253 write++;
7254
7255 params = IF_DEF_PARAMS (ifp);
7256
7257 do {
7258 /* Interface Network print. */
7259 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007260 params->type != OSPF_IFTYPE_LOOPBACK)
7261 {
ajsbc18d612004-12-15 15:07:19 +00007262 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007263 {
7264 vty_out (vty, " ip ospf network %s",
7265 ospf_int_type_str[params->type]);
7266 if (params != IF_DEF_PARAMS (ifp))
7267 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7268 vty_out (vty, "%s", VTY_NEWLINE);
7269 }
paul718e3742002-12-13 20:15:29 +00007270 }
7271
7272 /* OSPF interface authentication print */
7273 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7274 params->auth_type != OSPF_AUTH_NOTSET)
7275 {
hassoeb1ce602004-10-08 08:17:22 +00007276 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007277
7278 /* Translation tables are not that much help here due to syntax
7279 of the simple option */
7280 switch (params->auth_type)
7281 {
7282
7283 case OSPF_AUTH_NULL:
7284 auth_str = " null";
7285 break;
7286
7287 case OSPF_AUTH_SIMPLE:
7288 auth_str = "";
7289 break;
7290
7291 case OSPF_AUTH_CRYPTOGRAPHIC:
7292 auth_str = " message-digest";
7293 break;
7294
7295 default:
7296 auth_str = "";
7297 break;
7298 }
7299
7300 vty_out (vty, " ip ospf authentication%s", auth_str);
7301 if (params != IF_DEF_PARAMS (ifp))
7302 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7303 vty_out (vty, "%s", VTY_NEWLINE);
7304 }
7305
7306 /* Simple Authentication Password print. */
7307 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7308 params->auth_simple[0] != '\0')
7309 {
7310 vty_out (vty, " ip ospf authentication-key %s",
7311 params->auth_simple);
7312 if (params != IF_DEF_PARAMS (ifp))
7313 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7314 vty_out (vty, "%s", VTY_NEWLINE);
7315 }
7316
7317 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007318 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007319 {
paul718e3742002-12-13 20:15:29 +00007320 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7321 ck->key_id, ck->auth_key);
7322 if (params != IF_DEF_PARAMS (ifp))
7323 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7324 vty_out (vty, "%s", VTY_NEWLINE);
7325 }
7326
7327 /* Interface Output Cost print. */
7328 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7329 {
7330 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7331 if (params != IF_DEF_PARAMS (ifp))
7332 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7333 vty_out (vty, "%s", VTY_NEWLINE);
7334 }
7335
7336 /* Hello Interval print. */
7337 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7338 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7339 {
7340 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7341 if (params != IF_DEF_PARAMS (ifp))
7342 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7343 vty_out (vty, "%s", VTY_NEWLINE);
7344 }
7345
7346
7347 /* Router Dead Interval print. */
7348 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7349 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7350 {
paulf9ad9372005-10-21 00:45:17 +00007351 vty_out (vty, " ip ospf dead-interval ");
7352
7353 /* fast hello ? */
7354 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7355 vty_out (vty, "minimal hello-multiplier %d",
7356 params->fast_hello);
7357 else
7358 vty_out (vty, "%u", params->v_wait);
7359
paul718e3742002-12-13 20:15:29 +00007360 if (params != IF_DEF_PARAMS (ifp))
7361 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7362 vty_out (vty, "%s", VTY_NEWLINE);
7363 }
7364
7365 /* Router Priority print. */
7366 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7367 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7368 {
7369 vty_out (vty, " ip ospf priority %u", params->priority);
7370 if (params != IF_DEF_PARAMS (ifp))
7371 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7372 vty_out (vty, "%s", VTY_NEWLINE);
7373 }
7374
7375 /* Retransmit Interval print. */
7376 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7377 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7378 {
7379 vty_out (vty, " ip ospf retransmit-interval %u",
7380 params->retransmit_interval);
7381 if (params != IF_DEF_PARAMS (ifp))
7382 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7383 vty_out (vty, "%s", VTY_NEWLINE);
7384 }
7385
7386 /* Transmit Delay print. */
7387 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7388 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7389 {
7390 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7391 if (params != IF_DEF_PARAMS (ifp))
7392 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7393 vty_out (vty, "%s", VTY_NEWLINE);
7394 }
7395
vincentba682532005-09-29 13:52:57 +00007396 /* MTU ignore print. */
7397 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7398 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7399 {
7400 if (params->mtu_ignore == 0)
7401 vty_out (vty, " no ip ospf mtu-ignore");
7402 else
7403 vty_out (vty, " ip ospf mtu-ignore");
7404 if (params != IF_DEF_PARAMS (ifp))
7405 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7406 vty_out (vty, "%s", VTY_NEWLINE);
7407 }
7408
7409
paul718e3742002-12-13 20:15:29 +00007410 while (1)
7411 {
7412 if (rn == NULL)
7413 rn = route_top (IF_OIFS_PARAMS (ifp));
7414 else
7415 rn = route_next (rn);
7416
7417 if (rn == NULL)
7418 break;
7419 params = rn->info;
7420 if (params != NULL)
7421 break;
7422 }
7423 } while (rn);
7424
7425#ifdef HAVE_OPAQUE_LSA
7426 ospf_opaque_config_write_if (vty, ifp);
7427#endif /* HAVE_OPAQUE_LSA */
7428 }
7429
7430 return write;
7431}
7432
paul4dadc292005-05-06 21:37:42 +00007433static int
paul68980082003-03-25 05:07:42 +00007434config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007435{
7436 struct route_node *rn;
7437 u_char buf[INET_ADDRSTRLEN];
7438
7439 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007440 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007441 if (rn->info)
7442 {
7443 struct ospf_network *n = rn->info;
7444
7445 memset (buf, 0, INET_ADDRSTRLEN);
7446
7447 /* Create Area ID string by specified Area ID format. */
7448 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007449 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007450 else
hassoc9e52be2004-09-26 16:09:34 +00007451 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007452 (unsigned long int) ntohl (n->area_id.s_addr));
7453
7454 /* Network print. */
7455 vty_out (vty, " network %s/%d area %s%s",
7456 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7457 buf, VTY_NEWLINE);
7458 }
7459
7460 return 0;
7461}
7462
paul4dadc292005-05-06 21:37:42 +00007463static int
paul68980082003-03-25 05:07:42 +00007464config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007465{
hasso52dc7ee2004-09-23 19:18:23 +00007466 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007467 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007468 u_char buf[INET_ADDRSTRLEN];
7469
7470 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007471 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007472 {
paul718e3742002-12-13 20:15:29 +00007473 struct route_node *rn1;
7474
hassoc9e52be2004-09-26 16:09:34 +00007475 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007476
7477 if (area->auth_type != OSPF_AUTH_NULL)
7478 {
7479 if (area->auth_type == OSPF_AUTH_SIMPLE)
7480 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7481 else
7482 vty_out (vty, " area %s authentication message-digest%s",
7483 buf, VTY_NEWLINE);
7484 }
7485
7486 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7487 vty_out (vty, " area %s shortcut %s%s", buf,
7488 ospf_shortcut_mode_str[area->shortcut_configured],
7489 VTY_NEWLINE);
7490
7491 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007492 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007493 )
7494 {
paulb0a053b2003-06-22 09:04:47 +00007495 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007496 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007497 else if (area->external_routing == OSPF_AREA_NSSA)
7498 {
7499 vty_out (vty, " area %s nssa", buf);
7500 switch (area->NSSATranslatorRole)
7501 {
7502 case OSPF_NSSA_ROLE_NEVER:
7503 vty_out (vty, " translate-never");
7504 break;
7505 case OSPF_NSSA_ROLE_ALWAYS:
7506 vty_out (vty, " translate-always");
7507 break;
7508 case OSPF_NSSA_ROLE_CANDIDATE:
7509 default:
7510 vty_out (vty, " translate-candidate");
7511 }
7512 }
paul718e3742002-12-13 20:15:29 +00007513
7514 if (area->no_summary)
7515 vty_out (vty, " no-summary");
7516
7517 vty_out (vty, "%s", VTY_NEWLINE);
7518
7519 if (area->default_cost != 1)
7520 vty_out (vty, " area %s default-cost %d%s", buf,
7521 area->default_cost, VTY_NEWLINE);
7522 }
7523
7524 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7525 if (rn1->info)
7526 {
7527 struct ospf_area_range *range = rn1->info;
7528
7529 vty_out (vty, " area %s range %s/%d", buf,
7530 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7531
paul6c835672004-10-11 11:00:30 +00007532 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007533 vty_out (vty, " cost %d", range->cost_config);
7534
7535 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7536 vty_out (vty, " not-advertise");
7537
7538 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7539 vty_out (vty, " substitute %s/%d",
7540 inet_ntoa (range->subst_addr), range->subst_masklen);
7541
7542 vty_out (vty, "%s", VTY_NEWLINE);
7543 }
7544
7545 if (EXPORT_NAME (area))
7546 vty_out (vty, " area %s export-list %s%s", buf,
7547 EXPORT_NAME (area), VTY_NEWLINE);
7548
7549 if (IMPORT_NAME (area))
7550 vty_out (vty, " area %s import-list %s%s", buf,
7551 IMPORT_NAME (area), VTY_NEWLINE);
7552
7553 if (PREFIX_NAME_IN (area))
7554 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7555 PREFIX_NAME_IN (area), VTY_NEWLINE);
7556
7557 if (PREFIX_NAME_OUT (area))
7558 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7559 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7560 }
7561
7562 return 0;
7563}
7564
paul4dadc292005-05-06 21:37:42 +00007565static int
paul68980082003-03-25 05:07:42 +00007566config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007567{
7568 struct ospf_nbr_nbma *nbr_nbma;
7569 struct route_node *rn;
7570
7571 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007572 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007573 if ((nbr_nbma = rn->info))
7574 {
7575 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7576
7577 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7578 vty_out (vty, " priority %d", nbr_nbma->priority);
7579
7580 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7581 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7582
7583 vty_out (vty, "%s", VTY_NEWLINE);
7584 }
7585
7586 return 0;
7587}
7588
paul4dadc292005-05-06 21:37:42 +00007589static int
paul68980082003-03-25 05:07:42 +00007590config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007591{
hasso52dc7ee2004-09-23 19:18:23 +00007592 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007593 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007594 u_char buf[INET_ADDRSTRLEN];
7595
7596 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007597 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007598 {
hasso52dc7ee2004-09-23 19:18:23 +00007599 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007600 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007601 struct ospf_interface *oi;
7602
7603 if (vl_data != NULL)
7604 {
7605 memset (buf, 0, INET_ADDRSTRLEN);
7606
7607 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007608 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007609 else
hassoc9e52be2004-09-26 16:09:34 +00007610 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007611 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7612 oi = vl_data->vl_oi;
7613
7614 /* timers */
7615 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7616 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7617 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7618 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7619 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7620 buf,
7621 inet_ntoa (vl_data->vl_peer),
7622 OSPF_IF_PARAM (oi, v_hello),
7623 OSPF_IF_PARAM (oi, retransmit_interval),
7624 OSPF_IF_PARAM (oi, transmit_delay),
7625 OSPF_IF_PARAM (oi, v_wait),
7626 VTY_NEWLINE);
7627 else
7628 vty_out (vty, " area %s virtual-link %s%s", buf,
7629 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7630 /* Auth key */
7631 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7632 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7633 buf,
7634 inet_ntoa (vl_data->vl_peer),
7635 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7636 VTY_NEWLINE);
7637 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007638 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7639 n2, ck))
7640 vty_out (vty, " area %s virtual-link %s"
7641 " message-digest-key %d md5 %s%s",
7642 buf,
7643 inet_ntoa (vl_data->vl_peer),
7644 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007645
7646 }
7647 }
7648
7649 return 0;
7650}
7651
7652
paul4dadc292005-05-06 21:37:42 +00007653static int
paul68980082003-03-25 05:07:42 +00007654config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007655{
7656 int type;
7657
7658 /* redistribute print. */
7659 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7660 if (type != zclient->redist_default && zclient->redist[type])
7661 {
ajsf52d13c2005-10-01 17:38:06 +00007662 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007663 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007664 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007665
paul68980082003-03-25 05:07:42 +00007666 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007667 vty_out (vty, " metric-type 1");
7668
paul020709f2003-04-04 02:44:16 +00007669 if (ROUTEMAP_NAME (ospf, type))
7670 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007671
7672 vty_out (vty, "%s", VTY_NEWLINE);
7673 }
7674
7675 return 0;
7676}
7677
paul4dadc292005-05-06 21:37:42 +00007678static int
paul68980082003-03-25 05:07:42 +00007679config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007680{
paul68980082003-03-25 05:07:42 +00007681 if (ospf->default_metric != -1)
7682 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007683 VTY_NEWLINE);
7684 return 0;
7685}
7686
paul4dadc292005-05-06 21:37:42 +00007687static int
paul68980082003-03-25 05:07:42 +00007688config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007689{
7690 int type;
7691
paul68980082003-03-25 05:07:42 +00007692 if (ospf)
paul718e3742002-12-13 20:15:29 +00007693 {
7694 /* distribute-list print. */
7695 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007696 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007697 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007698 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007699 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007700
7701 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007702 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007703 {
paul68980082003-03-25 05:07:42 +00007704 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007705 vty_out (vty, " default-information originate");
7706 else
7707 vty_out (vty, " default-information originate always");
7708
paul68980082003-03-25 05:07:42 +00007709 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007710 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007711 ospf->dmetric[DEFAULT_ROUTE].value);
7712 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007713 vty_out (vty, " metric-type 1");
7714
paul020709f2003-04-04 02:44:16 +00007715 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7716 vty_out (vty, " route-map %s",
7717 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007718
7719 vty_out (vty, "%s", VTY_NEWLINE);
7720 }
7721
7722 }
7723
7724 return 0;
7725}
7726
paul4dadc292005-05-06 21:37:42 +00007727static int
paul68980082003-03-25 05:07:42 +00007728config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007729{
7730 struct route_node *rn;
7731 struct ospf_distance *odistance;
7732
paul68980082003-03-25 05:07:42 +00007733 if (ospf->distance_all)
7734 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007735
paul68980082003-03-25 05:07:42 +00007736 if (ospf->distance_intra
7737 || ospf->distance_inter
7738 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007739 {
7740 vty_out (vty, " distance ospf");
7741
paul68980082003-03-25 05:07:42 +00007742 if (ospf->distance_intra)
7743 vty_out (vty, " intra-area %d", ospf->distance_intra);
7744 if (ospf->distance_inter)
7745 vty_out (vty, " inter-area %d", ospf->distance_inter);
7746 if (ospf->distance_external)
7747 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007748
7749 vty_out (vty, "%s", VTY_NEWLINE);
7750 }
7751
paul68980082003-03-25 05:07:42 +00007752 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007753 if ((odistance = rn->info) != NULL)
7754 {
7755 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7756 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7757 odistance->access_list ? odistance->access_list : "",
7758 VTY_NEWLINE);
7759 }
7760 return 0;
7761}
7762
7763/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007764static int
paul718e3742002-12-13 20:15:29 +00007765ospf_config_write (struct vty *vty)
7766{
paul020709f2003-04-04 02:44:16 +00007767 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007768 struct interface *ifp;
7769 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007770 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007771 int write = 0;
7772
paul020709f2003-04-04 02:44:16 +00007773 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007774 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007775 {
7776 /* `router ospf' print. */
7777 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7778
7779 write++;
7780
paul68980082003-03-25 05:07:42 +00007781 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007782 return write;
7783
7784 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007785 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007786 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007787 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007788
7789 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007790 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007791 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007792 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007793
7794 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007795 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007796 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7797
7798 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007799 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007800 {
7801 vty_out (vty, "! Important: ensure reference bandwidth "
7802 "is consistent across all routers%s", VTY_NEWLINE);
7803 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7804 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7805 }
paul718e3742002-12-13 20:15:29 +00007806
7807 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007808 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007809 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7810 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7811 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007812 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007813 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007814
7815 /* Max-metric router-lsa print */
7816 config_write_stub_router (vty, ospf);
7817
paul718e3742002-12-13 20:15:29 +00007818 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007819 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007820 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007821 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007822
7823 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007824 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007825
7826 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007827 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7828 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7829 vty_out (vty, " passive-interface %s%s",
7830 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007831
paul1eb8ef22005-04-07 07:30:20 +00007832 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7833 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7834 oi->params->passive_interface == OSPF_IF_PASSIVE)
7835 vty_out (vty, " passive-interface %s %s%s",
7836 oi->ifp->name,
7837 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007838
7839 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007840 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007841
7842 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007843 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007844
7845 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007846 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007847
7848 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007849 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007850
7851 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007852 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007853
7854 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007855 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007856
7857 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007858 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007859
7860#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007861 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007862#endif /* HAVE_OPAQUE_LSA */
7863 }
7864
7865 return write;
7866}
7867
7868void
paul4dadc292005-05-06 21:37:42 +00007869ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007870{
7871 /* "show ip ospf" commands. */
7872 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7873 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7874
7875 /* "show ip ospf database" commands. */
7876 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7877 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7878 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7879 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7880 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7881 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7882 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7883 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7884 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7885 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7886 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7887 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7888 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7889 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7890
7891 /* "show ip ospf interface" commands. */
7892 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7893 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7894
7895 /* "show ip ospf neighbor" commands. */
7896 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7897 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7898 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7899 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7900 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7901 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7902 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7903 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7904 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7905 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7906 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7907 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7908 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7909 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7910
7911 /* "show ip ospf route" commands. */
7912 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7913 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007914 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7915 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007916}
7917
7918
7919/* ospfd's interface node. */
7920struct cmd_node interface_node =
7921{
7922 INTERFACE_NODE,
7923 "%s(config-if)# ",
7924 1
7925};
7926
7927/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007928static void
7929ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007930{
7931 /* Install interface node. */
7932 install_node (&interface_node, config_write_interface);
7933
7934 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007935 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007936 install_default (INTERFACE_NODE);
7937
7938 /* "description" commands. */
7939 install_element (INTERFACE_NODE, &interface_desc_cmd);
7940 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7941
7942 /* "ip ospf authentication" commands. */
7943 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7944 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7945 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7946 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7947 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7948 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7949 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7950 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7951 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7952 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7953
7954 /* "ip ospf message-digest-key" commands. */
7955 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7956 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7957 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7958 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7959
7960 /* "ip ospf cost" commands. */
7961 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7962 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7963 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7964 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7965
vincentba682532005-09-29 13:52:57 +00007966 /* "ip ospf mtu-ignore" commands. */
7967 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7968 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7969 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7970 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7971
paul718e3742002-12-13 20:15:29 +00007972 /* "ip ospf dead-interval" commands. */
7973 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7974 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007975 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7976 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007977 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7978 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007979
paul718e3742002-12-13 20:15:29 +00007980 /* "ip ospf hello-interval" commands. */
7981 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7982 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7983 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7984 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7985
7986 /* "ip ospf network" commands. */
7987 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7988 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7989
7990 /* "ip ospf priority" commands. */
7991 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7992 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7993 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7994 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7995
7996 /* "ip ospf retransmit-interval" commands. */
7997 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7998 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7999 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8000 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8001
8002 /* "ip ospf transmit-delay" commands. */
8003 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8004 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8005 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8006 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8007
8008 /* These commands are compatibitliy for previous version. */
8009 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8010 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8011 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8012 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
8013 install_element (INTERFACE_NODE, &ospf_cost_cmd);
8014 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
8015 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8016 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8017 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8018 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8019 install_element (INTERFACE_NODE, &ospf_network_cmd);
8020 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8021 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8022 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8023 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8024 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8025 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8026 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8027}
8028
8029/* Zebra node structure. */
8030struct cmd_node zebra_node =
8031{
8032 ZEBRA_NODE,
8033 "%s(config-router)#",
8034};
8035
paul4dadc292005-05-06 21:37:42 +00008036static void
8037ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008038{
8039 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8040 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8041 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8042 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8043 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8044 install_element (OSPF_NODE,
8045 &ospf_redistribute_source_metric_type_routemap_cmd);
8046 install_element (OSPF_NODE,
8047 &ospf_redistribute_source_type_metric_routemap_cmd);
8048 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8049 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8050 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8051
8052 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8053
8054 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8055 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8056
8057 install_element (OSPF_NODE,
8058 &ospf_default_information_originate_metric_type_cmd);
8059 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8060 install_element (OSPF_NODE,
8061 &ospf_default_information_originate_type_metric_cmd);
8062 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8063 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8064 install_element (OSPF_NODE,
8065 &ospf_default_information_originate_always_metric_type_cmd);
8066 install_element (OSPF_NODE,
8067 &ospf_default_information_originate_always_metric_cmd);
8068 install_element (OSPF_NODE,
8069 &ospf_default_information_originate_always_cmd);
8070 install_element (OSPF_NODE,
8071 &ospf_default_information_originate_always_type_metric_cmd);
8072 install_element (OSPF_NODE,
8073 &ospf_default_information_originate_always_type_cmd);
8074
8075 install_element (OSPF_NODE,
8076 &ospf_default_information_originate_metric_type_routemap_cmd);
8077 install_element (OSPF_NODE,
8078 &ospf_default_information_originate_metric_routemap_cmd);
8079 install_element (OSPF_NODE,
8080 &ospf_default_information_originate_routemap_cmd);
8081 install_element (OSPF_NODE,
8082 &ospf_default_information_originate_type_metric_routemap_cmd);
8083 install_element (OSPF_NODE,
8084 &ospf_default_information_originate_type_routemap_cmd);
8085 install_element (OSPF_NODE,
8086 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8087 install_element (OSPF_NODE,
8088 &ospf_default_information_originate_always_metric_routemap_cmd);
8089 install_element (OSPF_NODE,
8090 &ospf_default_information_originate_always_routemap_cmd);
8091 install_element (OSPF_NODE,
8092 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8093 install_element (OSPF_NODE,
8094 &ospf_default_information_originate_always_type_routemap_cmd);
8095
8096 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8097
8098 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8099 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8100 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8101
8102 install_element (OSPF_NODE, &ospf_distance_cmd);
8103 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8104 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8105 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8106 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8107 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8108 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8109 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8110 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8111 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8112 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8113 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8114 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8115 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8116 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8117 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8118 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8119 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8120#if 0
8121 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8122 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8123 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8124 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8125#endif /* 0 */
8126}
8127
8128struct cmd_node ospf_node =
8129{
8130 OSPF_NODE,
8131 "%s(config-router)# ",
8132 1
8133};
8134
8135
8136/* Install OSPF related vty commands. */
8137void
paul4dadc292005-05-06 21:37:42 +00008138ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008139{
8140 /* Install ospf top node. */
8141 install_node (&ospf_node, ospf_config_write);
8142
8143 /* "router ospf" commands. */
8144 install_element (CONFIG_NODE, &router_ospf_cmd);
8145 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8146
8147 install_default (OSPF_NODE);
8148
8149 /* "ospf router-id" commands. */
8150 install_element (OSPF_NODE, &ospf_router_id_cmd);
8151 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008152 install_element (OSPF_NODE, &router_ospf_id_cmd);
8153 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008154
8155 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008156 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8157 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
8158 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8159 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008160
8161 /* "ospf abr-type" commands. */
8162 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8163 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8164
8165 /* "ospf rfc1583-compatible" commands. */
8166 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8167 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8168 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8169 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8170
8171 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008172 install_element (OSPF_NODE, &ospf_network_area_cmd);
8173 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008174
8175 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008176 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8177 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8178 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008179
8180 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008181 install_element (OSPF_NODE, &ospf_area_range_cmd);
8182 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8183 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8184 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8185 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8186 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8187 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8188 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8189 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8190 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8191 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008192
8193 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008194 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8195 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008196
paula2c62832003-04-23 17:01:31 +00008197 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8198 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008199
paula2c62832003-04-23 17:01:31 +00008200 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8201 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008202
paula2c62832003-04-23 17:01:31 +00008203 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8204 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008205
paula2c62832003-04-23 17:01:31 +00008206 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8207 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008208
paula2c62832003-04-23 17:01:31 +00008209 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8210 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8211 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008212
paula2c62832003-04-23 17:01:31 +00008213 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8214 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008215
paula2c62832003-04-23 17:01:31 +00008216 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8217 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008218
paula2c62832003-04-23 17:01:31 +00008219 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8220 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8221 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008222
paula2c62832003-04-23 17:01:31 +00008223 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8224 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8225 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008226
8227 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008228 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8229 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8230 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8231 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008232
paul718e3742002-12-13 20:15:29 +00008233 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008234 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8235 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8236 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8237 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8238 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8239 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008240
paula2c62832003-04-23 17:01:31 +00008241 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8242 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008243
paula2c62832003-04-23 17:01:31 +00008244 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8245 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008246
paula2c62832003-04-23 17:01:31 +00008247 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8248 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008249
paula2c62832003-04-23 17:01:31 +00008250 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8251 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008252
paula2c62832003-04-23 17:01:31 +00008253 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8254 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008255
8256 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008257 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8258 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008259 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8260 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8261
paul88d6cf32005-10-29 12:50:09 +00008262 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008263 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8264 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8265 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008266
paul88d6cf32005-10-29 12:50:09 +00008267 /* max-metric commands */
8268 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8269 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8270 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8271 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8272 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8273 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8274
8275 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008276 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8277 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008278
8279 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008280 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8281 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8282 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8283 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8284 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8285 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8286 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8287 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008288
8289 /* Init interface related vty commands. */
8290 ospf_vty_if_init ();
8291
8292 /* Init zebra related vty commands. */
8293 ospf_vty_zebra_init ();
8294}