blob: c928e8190453ffaf778b41f1c65a23c540eb2b47 [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
Paul Jakma30a22312008-08-15 14:05:22 +010053static const 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 +000096str2metric (const char *str, int *metric)
paul718e3742002-12-13 20:15:29 +000097{
98 /* Sanity check. */
99 if (str == NULL)
100 return 0;
101
102 *metric = strtol (str, NULL, 10);
103 if (*metric < 0 && *metric > 16777214)
104 {
105 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
106 return 0;
107 }
108
109 return 1;
110}
111
paul4dadc292005-05-06 21:37:42 +0000112static int
paul6c835672004-10-11 11:00:30 +0000113str2metric_type (const char *str, int *metric_type)
paul718e3742002-12-13 20:15:29 +0000114{
115 /* Sanity check. */
116 if (str == NULL)
117 return 0;
118
119 if (strncmp (str, "1", 1) == 0)
120 *metric_type = EXTERNAL_METRIC_TYPE_1;
121 else if (strncmp (str, "2", 1) == 0)
122 *metric_type = EXTERNAL_METRIC_TYPE_2;
123 else
124 return 0;
125
126 return 1;
127}
128
129int
130ospf_oi_count (struct interface *ifp)
131{
132 struct route_node *rn;
133 int i = 0;
134
135 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
136 if (rn->info)
137 i++;
138
139 return i;
140}
141
142
143DEFUN (router_ospf,
144 router_ospf_cmd,
145 "router ospf",
146 "Enable a routing process\n"
147 "Start OSPF configuration\n")
148{
149 vty->node = OSPF_NODE;
150 vty->index = ospf_get ();
151
152 return CMD_SUCCESS;
153}
154
155DEFUN (no_router_ospf,
156 no_router_ospf_cmd,
157 "no router ospf",
158 NO_STR
159 "Enable a routing process\n"
160 "Start OSPF configuration\n")
161{
paul020709f2003-04-04 02:44:16 +0000162 struct ospf *ospf;
163
164 ospf = ospf_lookup ();
165 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000166 {
paul020709f2003-04-04 02:44:16 +0000167 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000168 return CMD_WARNING;
169 }
170
paul020709f2003-04-04 02:44:16 +0000171 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000172
173 return CMD_SUCCESS;
174}
175
176DEFUN (ospf_router_id,
177 ospf_router_id_cmd,
178 "ospf router-id A.B.C.D",
179 "OSPF specific commands\n"
180 "router-id for the OSPF process\n"
181 "OSPF router-id in IP address format\n")
182{
paul68980082003-03-25 05:07:42 +0000183 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000184 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000185 int ret;
paul718e3742002-12-13 20:15:29 +0000186
187 ret = inet_aton (argv[0], &router_id);
188 if (!ret)
189 {
190 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
191 return CMD_WARNING;
192 }
193
paul68980082003-03-25 05:07:42 +0000194 ospf->router_id_static = router_id;
paulb29800a2005-11-20 14:50:45 +0000195
196 ospf_router_id_update (ospf);
197
paul718e3742002-12-13 20:15:29 +0000198 return CMD_SUCCESS;
199}
200
201ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000202 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000203 "router-id A.B.C.D",
204 "router-id for the OSPF process\n"
205 "OSPF router-id in IP address format\n")
206
207DEFUN (no_ospf_router_id,
208 no_ospf_router_id_cmd,
209 "no ospf router-id",
210 NO_STR
211 "OSPF specific commands\n"
212 "router-id for the OSPF process\n")
213{
paul68980082003-03-25 05:07:42 +0000214 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000215
paul68980082003-03-25 05:07:42 +0000216 ospf->router_id_static.s_addr = 0;
217
218 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000219
220 return CMD_SUCCESS;
221}
222
223ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000224 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000225 "no router-id",
226 NO_STR
227 "router-id for the OSPF process\n")
228
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000229static void
Andrew J. Schorr43540882006-11-28 16:36:39 +0000230ospf_passive_interface_default (struct ospf *ospf, u_char newval)
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000231{
232 struct listnode *ln;
233 struct interface *ifp;
234 struct ospf_interface *oi;
235
Andrew J. Schorr43540882006-11-28 16:36:39 +0000236 ospf->passive_interface_default = newval;
237
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000238 for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp))
239 {
240 if (ifp &&
241 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
242 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface);
243 }
244 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi))
245 {
246 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
247 UNSET_IF_PARAM (oi->params, passive_interface);
Andrew J. Schorr43540882006-11-28 16:36:39 +0000248 /* update multicast memberships */
249 ospf_if_set_multicast(oi);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000250 }
251}
252
253static void
254ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
255 struct in_addr addr,
256 struct ospf_if_params *params, u_char value)
257{
258 u_char dflt;
259
260 params->passive_interface = value;
261 if (params != IF_DEF_PARAMS (ifp))
262 {
263 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
264 dflt = IF_DEF_PARAMS (ifp)->passive_interface;
265 else
266 dflt = ospf->passive_interface_default;
267
268 if (value != dflt)
269 SET_IF_PARAM (params, passive_interface);
270 else
271 UNSET_IF_PARAM (params, passive_interface);
272
273 ospf_free_if_params (ifp, addr);
274 ospf_if_update_params (ifp, addr);
275 }
276 else
277 {
278 if (value != ospf->passive_interface_default)
279 SET_IF_PARAM (params, passive_interface);
280 else
281 UNSET_IF_PARAM (params, passive_interface);
282 }
283}
284
paula2c62832003-04-23 17:01:31 +0000285DEFUN (ospf_passive_interface,
286 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000287 "passive-interface IFNAME A.B.C.D",
288 "Suppress routing updates on an interface\n"
289 "Interface's name\n")
290{
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000291 struct interface *ifp;
292 struct in_addr addr;
293 int ret;
294 struct ospf_if_params *params;
295 struct route_node *rn;
296 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000297
Andrew J. Schorr43540882006-11-28 16:36:39 +0000298 if (argc == 0)
299 {
300 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
301 return CMD_SUCCESS;
302 }
303
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000304 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000305
306 params = IF_DEF_PARAMS (ifp);
307
Andrew J. Schorr43540882006-11-28 16:36:39 +0000308 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000309 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000310 ret = inet_aton(argv[1], &addr);
311 if (!ret)
312 {
313 vty_out (vty, "Please specify interface address by A.B.C.D%s",
314 VTY_NEWLINE);
315 return CMD_WARNING;
316 }
paul718e3742002-12-13 20:15:29 +0000317
Andrew J. Schorr43540882006-11-28 16:36:39 +0000318 params = ospf_get_if_params (ifp, addr);
319 ospf_if_update_params (ifp, addr);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000320 }
Andrew J. Schorr43540882006-11-28 16:36:39 +0000321 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE);
322
ajsba6454e2005-02-08 15:37:30 +0000323 /* XXX We should call ospf_if_set_multicast on exactly those
324 * interfaces for which the passive property changed. It is too much
325 * work to determine this set, so we do this for every interface.
326 * This is safe and reasonable because ospf_if_set_multicast uses a
327 * record of joined groups to avoid systems calls if the desired
328 * memberships match the current memership.
329 */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000330
ajsba6454e2005-02-08 15:37:30 +0000331 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
332 {
333 struct ospf_interface *oi = rn->info;
334
335 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
Andrew J. Schorr43540882006-11-28 16:36:39 +0000336 ospf_if_set_multicast(oi);
ajsba6454e2005-02-08 15:37:30 +0000337 }
338 /*
339 * XXX It is not clear what state transitions the interface needs to
340 * undergo when going from active to passive. Fixing this will
341 * require precise identification of interfaces having such a
342 * transition.
343 */
344
paul718e3742002-12-13 20:15:29 +0000345 return CMD_SUCCESS;
346}
347
paula2c62832003-04-23 17:01:31 +0000348ALIAS (ospf_passive_interface,
349 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000350 "passive-interface IFNAME",
351 "Suppress routing updates on an interface\n"
352 "Interface's name\n")
353
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000354ALIAS (ospf_passive_interface,
355 ospf_passive_interface_default_cmd,
356 "passive-interface default",
357 "Suppress routing updates on an interface\n"
358 "Suppress routing updates on interfaces by default\n")
359
paula2c62832003-04-23 17:01:31 +0000360DEFUN (no_ospf_passive_interface,
361 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000362 "no passive-interface IFNAME A.B.C.D",
363 NO_STR
364 "Allow routing updates on an interface\n"
365 "Interface's name\n")
366{
367 struct interface *ifp;
368 struct in_addr addr;
369 struct ospf_if_params *params;
370 int ret;
ajsba6454e2005-02-08 15:37:30 +0000371 struct route_node *rn;
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000372 struct ospf *ospf = vty->index;
Andrew J. Schorr43540882006-11-28 16:36:39 +0000373
374 if (argc == 0)
375 {
376 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
377 return CMD_SUCCESS;
378 }
paul718e3742002-12-13 20:15:29 +0000379
Andrew J. Schorr6e72cb62006-06-18 00:45:48 +0000380 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000381
382 params = IF_DEF_PARAMS (ifp);
383
Andrew J. Schorr43540882006-11-28 16:36:39 +0000384 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000385 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000386 ret = inet_aton(argv[1], &addr);
387 if (!ret)
388 {
389 vty_out (vty, "Please specify interface address by A.B.C.D%s",
390 VTY_NEWLINE);
391 return CMD_WARNING;
392 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000393
Andrew J. Schorr43540882006-11-28 16:36:39 +0000394 params = ospf_lookup_if_params (ifp, addr);
395 if (params == NULL)
396 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000397 }
Andrew J. Schorr43540882006-11-28 16:36:39 +0000398 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE);
ajsba6454e2005-02-08 15:37:30 +0000399
400 /* XXX We should call ospf_if_set_multicast on exactly those
401 * interfaces for which the passive property changed. It is too much
402 * work to determine this set, so we do this for every interface.
403 * This is safe and reasonable because ospf_if_set_multicast uses a
404 * record of joined groups to avoid systems calls if the desired
405 * memberships match the current memership.
406 */
407 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
408 {
409 struct ospf_interface *oi = rn->info;
410
411 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
412 ospf_if_set_multicast(oi);
413 }
414
paul718e3742002-12-13 20:15:29 +0000415 return CMD_SUCCESS;
416}
417
paula2c62832003-04-23 17:01:31 +0000418ALIAS (no_ospf_passive_interface,
419 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000420 "no passive-interface IFNAME",
421 NO_STR
422 "Allow routing updates on an interface\n"
423 "Interface's name\n")
424
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000425ALIAS (no_ospf_passive_interface,
426 no_ospf_passive_interface_default_cmd,
427 "no passive-interface default",
428 NO_STR
429 "Allow routing updates on an interface\n"
430 "Allow routing updates on interfaces by default\n")
431
paula2c62832003-04-23 17:01:31 +0000432DEFUN (ospf_network_area,
433 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000434 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
435 "Enable routing on an IP network\n"
436 "OSPF network prefix\n"
437 "Set the OSPF area ID\n"
438 "OSPF area ID in IP address format\n"
439 "OSPF area ID as a decimal value\n")
440{
441 struct ospf *ospf= vty->index;
442 struct prefix_ipv4 p;
443 struct in_addr area_id;
444 int ret, format;
445
446 /* Get network prefix and Area ID. */
447 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
448 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
449
450 ret = ospf_network_set (ospf, &p, area_id);
451 if (ret == 0)
452 {
453 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
454 return CMD_WARNING;
455 }
456
457 return CMD_SUCCESS;
458}
459
paula2c62832003-04-23 17:01:31 +0000460DEFUN (no_ospf_network_area,
461 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000462 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
463 NO_STR
464 "Enable routing on an IP network\n"
465 "OSPF network prefix\n"
466 "Set the OSPF area ID\n"
467 "OSPF area ID in IP address format\n"
468 "OSPF area ID as a decimal value\n")
469{
470 struct ospf *ospf = (struct ospf *) vty->index;
471 struct prefix_ipv4 p;
472 struct in_addr area_id;
473 int ret, format;
474
475 /* Get network prefix and Area ID. */
476 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
477 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
478
479 ret = ospf_network_unset (ospf, &p, area_id);
480 if (ret == 0)
481 {
482 vty_out (vty, "Can't find specified network area configuration.%s",
483 VTY_NEWLINE);
484 return CMD_WARNING;
485 }
486
487 return CMD_SUCCESS;
488}
489
490
paula2c62832003-04-23 17:01:31 +0000491DEFUN (ospf_area_range,
492 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000493 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
494 "OSPF area parameters\n"
495 "OSPF area ID in IP address format\n"
496 "OSPF area ID as a decimal value\n"
497 "Summarize routes matching address/mask (border routers only)\n"
498 "Area range prefix\n")
499{
500 struct ospf *ospf = vty->index;
501 struct prefix_ipv4 p;
502 struct in_addr area_id;
503 int format;
504 u_int32_t cost;
505
506 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
507 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
508
509 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
510 if (argc > 2)
511 {
paul4dadc292005-05-06 21:37:42 +0000512 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000513 ospf_area_range_cost_set (ospf, area_id, &p, cost);
514 }
515
516 return CMD_SUCCESS;
517}
518
paula2c62832003-04-23 17:01:31 +0000519ALIAS (ospf_area_range,
520 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000521 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
522 "OSPF area parameters\n"
523 "OSPF area ID in IP address format\n"
524 "OSPF area ID as a decimal value\n"
525 "OSPF area range for route advertise (default)\n"
526 "Area range prefix\n"
527 "Advertise this range (default)\n")
528
paula2c62832003-04-23 17:01:31 +0000529ALIAS (ospf_area_range,
530 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000531 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
532 "OSPF area parameters\n"
533 "OSPF area ID in IP address format\n"
534 "OSPF area ID as a decimal value\n"
535 "Summarize routes matching address/mask (border routers only)\n"
536 "Area range prefix\n"
537 "User specified metric for this range\n"
538 "Advertised metric for this range\n")
539
paula2c62832003-04-23 17:01:31 +0000540ALIAS (ospf_area_range,
541 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000542 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
543 "OSPF area parameters\n"
544 "OSPF area ID in IP address format\n"
545 "OSPF area ID as a decimal value\n"
546 "Summarize routes matching address/mask (border routers only)\n"
547 "Area range prefix\n"
548 "Advertise this range (default)\n"
549 "User specified metric for this range\n"
550 "Advertised metric for this range\n")
551
paula2c62832003-04-23 17:01:31 +0000552DEFUN (ospf_area_range_not_advertise,
553 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000554 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
555 "OSPF area parameters\n"
556 "OSPF area ID in IP address format\n"
557 "OSPF area ID as a decimal value\n"
558 "Summarize routes matching address/mask (border routers only)\n"
559 "Area range prefix\n"
560 "DoNotAdvertise this range\n")
561{
562 struct ospf *ospf = vty->index;
563 struct prefix_ipv4 p;
564 struct in_addr area_id;
565 int format;
566
567 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
568 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
569
570 ospf_area_range_set (ospf, area_id, &p, 0);
571
572 return CMD_SUCCESS;
573}
574
paula2c62832003-04-23 17:01:31 +0000575DEFUN (no_ospf_area_range,
576 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000577 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
578 NO_STR
579 "OSPF area parameters\n"
580 "OSPF area ID in IP address format\n"
581 "OSPF area ID as a decimal value\n"
582 "Summarize routes matching address/mask (border routers only)\n"
583 "Area range prefix\n")
584{
585 struct ospf *ospf = vty->index;
586 struct prefix_ipv4 p;
587 struct in_addr area_id;
588 int format;
589
590 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
591 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
592
593 ospf_area_range_unset (ospf, area_id, &p);
594
595 return CMD_SUCCESS;
596}
597
paula2c62832003-04-23 17:01:31 +0000598ALIAS (no_ospf_area_range,
599 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000600 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
601 NO_STR
602 "OSPF area parameters\n"
603 "OSPF area ID in IP address format\n"
604 "OSPF area ID as a decimal value\n"
605 "Summarize routes matching address/mask (border routers only)\n"
606 "Area range prefix\n"
607 "Advertise this range (default)\n"
608 "DoNotAdvertise this range\n")
609
paula2c62832003-04-23 17:01:31 +0000610ALIAS (no_ospf_area_range,
611 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000612 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
613 NO_STR
614 "OSPF area parameters\n"
615 "OSPF area ID in IP address format\n"
616 "OSPF area ID as a decimal value\n"
617 "Summarize routes matching address/mask (border routers only)\n"
618 "Area range prefix\n"
619 "User specified metric for this range\n"
620 "Advertised metric for this range\n")
621
paula2c62832003-04-23 17:01:31 +0000622ALIAS (no_ospf_area_range,
623 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000624 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
625 NO_STR
626 "OSPF area parameters\n"
627 "OSPF area ID in IP address format\n"
628 "OSPF area ID as a decimal value\n"
629 "Summarize routes matching address/mask (border routers only)\n"
630 "Area range prefix\n"
631 "Advertise this range (default)\n"
632 "User specified metric for this range\n"
633 "Advertised metric for this range\n")
634
paula2c62832003-04-23 17:01:31 +0000635DEFUN (ospf_area_range_substitute,
636 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000637 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
638 "OSPF area parameters\n"
639 "OSPF area ID in IP address format\n"
640 "OSPF area ID as a decimal value\n"
641 "Summarize routes matching address/mask (border routers only)\n"
642 "Area range prefix\n"
643 "Announce area range as another prefix\n"
644 "Network prefix to be announced instead of range\n")
645{
646 struct ospf *ospf = vty->index;
647 struct prefix_ipv4 p, s;
648 struct in_addr area_id;
649 int format;
650
651 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
652 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
653 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
654
655 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
656
657 return CMD_SUCCESS;
658}
659
paula2c62832003-04-23 17:01:31 +0000660DEFUN (no_ospf_area_range_substitute,
661 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000662 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
663 NO_STR
664 "OSPF area parameters\n"
665 "OSPF area ID in IP address format\n"
666 "OSPF area ID as a decimal value\n"
667 "Summarize routes matching address/mask (border routers only)\n"
668 "Area range prefix\n"
669 "Announce area range as another prefix\n"
670 "Network prefix to be announced instead of range\n")
671{
672 struct ospf *ospf = vty->index;
673 struct prefix_ipv4 p, s;
674 struct in_addr area_id;
675 int format;
676
677 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
678 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
679 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
680
681 ospf_area_range_substitute_unset (ospf, area_id, &p);
682
683 return CMD_SUCCESS;
684}
685
686
687/* Command Handler Logic in VLink stuff is delicate!!
688
689 ALTER AT YOUR OWN RISK!!!!
690
691 Various dummy values are used to represent 'NoChange' state for
692 VLink configuration NOT being changed by a VLink command, and
693 special syntax is used within the command strings so that the
694 typed in command verbs can be seen in the configuration command
695 bacckend handler. This is to drastically reduce the verbeage
696 required to coe up with a reasonably compatible Cisco VLink command
697
698 - Matthew Grant <grantma@anathoth.gen.nz>
699 Wed, 21 Feb 2001 15:13:52 +1300
700 */
701
702
703/* Configuration data for virtual links
704 */
705struct ospf_vl_config_data {
706 struct vty *vty; /* vty stuff */
707 struct in_addr area_id; /* area ID from command line */
708 int format; /* command line area ID format */
709 struct in_addr vl_peer; /* command line vl_peer */
710 int auth_type; /* Authehntication type, if given */
711 char *auth_key; /* simple password if present */
712 int crypto_key_id; /* Cryptographic key ID */
713 char *md5_key; /* MD5 authentication key */
714 int hello_interval; /* Obvious what these are... */
715 int retransmit_interval;
716 int transmit_delay;
717 int dead_interval;
718};
719
paul4dadc292005-05-06 21:37:42 +0000720static void
paul718e3742002-12-13 20:15:29 +0000721ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
722 struct vty *vty)
723{
724 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
725 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
726 vl_config->vty = vty;
727}
728
paul4dadc292005-05-06 21:37:42 +0000729static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000730ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000731{
732 struct ospf_area *area;
733 struct ospf_vl_data *vl_data;
734 struct vty *vty;
735 struct in_addr area_id;
736
737 vty = vl_config->vty;
738 area_id = vl_config->area_id;
739
740 if (area_id.s_addr == OSPF_AREA_BACKBONE)
741 {
742 vty_out (vty,
743 "Configuring VLs over the backbone is not allowed%s",
744 VTY_NEWLINE);
745 return NULL;
746 }
paul68980082003-03-25 05:07:42 +0000747 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000748
749 if (area->external_routing != OSPF_AREA_DEFAULT)
750 {
751 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
752 vty_out (vty, "Area %s is %s%s",
753 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000754 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000755 VTY_NEWLINE);
756 else
757 vty_out (vty, "Area %ld is %s%s",
758 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000759 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000760 VTY_NEWLINE);
761 return NULL;
762 }
763
Paul Jakma9c27ef92006-05-04 07:32:57 +0000764 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
paul718e3742002-12-13 20:15:29 +0000765 {
766 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
767 if (vl_data->vl_oi == NULL)
768 {
paul68980082003-03-25 05:07:42 +0000769 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
770 ospf_vl_add (ospf, vl_data);
771 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000772 }
773 }
774 return vl_data;
775}
776
777
paul4dadc292005-05-06 21:37:42 +0000778static int
paul718e3742002-12-13 20:15:29 +0000779ospf_vl_set_security (struct ospf_vl_data *vl_data,
780 struct ospf_vl_config_data *vl_config)
781{
782 struct crypt_key *ck;
783 struct vty *vty;
784 struct interface *ifp = vl_data->vl_oi->ifp;
785
786 vty = vl_config->vty;
787
788 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
789 {
790 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
791 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
792 }
793
794 if (vl_config->auth_key)
795 {
796 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000797 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000798 OSPF_AUTH_SIMPLE_SIZE);
799 }
800 else if (vl_config->md5_key)
801 {
802 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
803 != NULL)
804 {
805 vty_out (vty, "OSPF: Key %d already exists%s",
806 vl_config->crypto_key_id, VTY_NEWLINE);
807 return CMD_WARNING;
808 }
809 ck = ospf_crypt_key_new ();
810 ck->key_id = vl_config->crypto_key_id;
811 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000812 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000813
814 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
815 }
816 else if (vl_config->crypto_key_id != 0)
817 {
818 /* Delete a key */
819
820 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
821 vl_config->crypto_key_id) == NULL)
822 {
823 vty_out (vty, "OSPF: Key %d does not exist%s",
824 vl_config->crypto_key_id, VTY_NEWLINE);
825 return CMD_WARNING;
826 }
827
828 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
829
830 }
831
832 return CMD_SUCCESS;
833}
834
paul4dadc292005-05-06 21:37:42 +0000835static int
paul718e3742002-12-13 20:15:29 +0000836ospf_vl_set_timers (struct ospf_vl_data *vl_data,
837 struct ospf_vl_config_data *vl_config)
838{
839 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
840 /* Virtual Link data initialised to defaults, so only set
841 if a value given */
842 if (vl_config->hello_interval)
843 {
844 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
845 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
846 }
847
848 if (vl_config->dead_interval)
849 {
850 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
851 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
852 }
853
854 if (vl_config->retransmit_interval)
855 {
856 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
857 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
858 }
859
860 if (vl_config->transmit_delay)
861 {
862 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
863 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
864 }
865
866 return CMD_SUCCESS;
867}
868
869
870
871/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000872static int
paul68980082003-03-25 05:07:42 +0000873ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000874{
875 struct ospf_vl_data *vl_data;
876 int ret;
877
paul68980082003-03-25 05:07:42 +0000878 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000879 if (!vl_data)
880 return CMD_WARNING;
881
882 /* Process this one first as it can have a fatal result, which can
883 only logically occur if the virtual link exists already
884 Thus a command error does not result in a change to the
885 running configuration such as unexpectedly altered timer
886 values etc.*/
887 ret = ospf_vl_set_security (vl_data, vl_config);
888 if (ret != CMD_SUCCESS)
889 return ret;
890
891 /* Set any time based parameters, these area already range checked */
892
893 ret = ospf_vl_set_timers (vl_data, vl_config);
894 if (ret != CMD_SUCCESS)
895 return ret;
896
897 return CMD_SUCCESS;
898
899}
900
901/* This stuff exists to make specifying all the alias commands A LOT simpler
902 */
903#define VLINK_HELPSTR_IPADDR \
904 "OSPF area parameters\n" \
905 "OSPF area ID in IP address format\n" \
906 "OSPF area ID as a decimal value\n" \
907 "Configure a virtual link\n" \
908 "Router ID of the remote ABR\n"
909
910#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
911 "Enable authentication on this virtual link\n" \
912 "dummy string \n"
913
914#define VLINK_HELPSTR_AUTHTYPE_ALL \
915 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
916 "Use null authentication\n" \
917 "Use message-digest authentication\n"
918
919#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
920 "Time between HELLO packets\n" \
921 "Time between retransmitting lost link state advertisements\n" \
922 "Link state transmit delay\n" \
923 "Interval after which a neighbor is declared dead\n"
924
925#define VLINK_HELPSTR_TIME_PARAM \
926 VLINK_HELPSTR_TIME_PARAM_NOSECS \
927 "Seconds\n"
928
929#define VLINK_HELPSTR_AUTH_SIMPLE \
930 "Authentication password (key)\n" \
931 "The OSPF password (key)"
932
933#define VLINK_HELPSTR_AUTH_MD5 \
934 "Message digest authentication password (key)\n" \
935 "dummy string \n" \
936 "Key ID\n" \
937 "Use MD5 algorithm\n" \
938 "The OSPF password (key)"
939
paula2c62832003-04-23 17:01:31 +0000940DEFUN (ospf_area_vlink,
941 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000942 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
943 VLINK_HELPSTR_IPADDR)
944{
paul68980082003-03-25 05:07:42 +0000945 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000946 struct ospf_vl_config_data vl_config;
947 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
948 char md5_key[OSPF_AUTH_MD5_SIZE+1];
949 int i;
950 int ret;
951
952 ospf_vl_config_data_init(&vl_config, vty);
953
954 /* Read off first 2 parameters and check them */
955 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
956 if (ret < 0)
957 {
958 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
959 return CMD_WARNING;
960 }
961
962 ret = inet_aton (argv[1], &vl_config.vl_peer);
963 if (! ret)
964 {
965 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
966 VTY_NEWLINE);
967 return CMD_WARNING;
968 }
969
970 if (argc <=2)
971 {
972 /* Thats all folks! - BUGS B. strikes again!!!*/
973
paul68980082003-03-25 05:07:42 +0000974 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000975 }
976
977 /* Deal with other parameters */
978 for (i=2; i < argc; i++)
979 {
980
981 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
982
983 switch (argv[i][0])
984 {
985
986 case 'a':
987 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
988 {
989 /* authentication-key - this option can occur anywhere on
990 command line. At start of command line
991 must check for authentication option. */
992 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
993 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
994 vl_config.auth_key = auth_key;
995 i++;
996 }
997 else if (strncmp (argv[i], "authentication", 14) == 0)
998 {
999 /* authentication - this option can only occur at start
1000 of command line */
1001 vl_config.auth_type = OSPF_AUTH_SIMPLE;
1002 if ((i+1) < argc)
1003 {
1004 if (strncmp (argv[i+1], "n", 1) == 0)
1005 {
1006 /* "authentication null" */
1007 vl_config.auth_type = OSPF_AUTH_NULL;
1008 i++;
1009 }
1010 else if (strncmp (argv[i+1], "m", 1) == 0
1011 && strcmp (argv[i+1], "message-digest-") != 0)
1012 {
1013 /* "authentication message-digest" */
1014 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1015 i++;
1016 }
1017 }
1018 }
1019 break;
1020
1021 case 'm':
1022 /* message-digest-key */
1023 i++;
1024 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1025 if (vl_config.crypto_key_id < 0)
1026 return CMD_WARNING;
1027 i++;
1028 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
1029 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
1030 vl_config.md5_key = md5_key;
1031 break;
1032
1033 case 'h':
1034 /* Hello interval */
1035 i++;
1036 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1037 if (vl_config.hello_interval < 0)
1038 return CMD_WARNING;
1039 break;
1040
1041 case 'r':
1042 /* Retransmit Interval */
1043 i++;
1044 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1045 if (vl_config.retransmit_interval < 0)
1046 return CMD_WARNING;
1047 break;
1048
1049 case 't':
1050 /* Transmit Delay */
1051 i++;
1052 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1053 if (vl_config.transmit_delay < 0)
1054 return CMD_WARNING;
1055 break;
1056
1057 case 'd':
1058 /* Dead Interval */
1059 i++;
1060 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1061 if (vl_config.dead_interval < 0)
1062 return CMD_WARNING;
1063 break;
1064 }
1065 }
1066
1067
1068 /* Action configuration */
1069
paul68980082003-03-25 05:07:42 +00001070 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001071
1072}
1073
paula2c62832003-04-23 17:01:31 +00001074DEFUN (no_ospf_area_vlink,
1075 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001076 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1077 NO_STR
1078 VLINK_HELPSTR_IPADDR)
1079{
paul68980082003-03-25 05:07:42 +00001080 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001081 struct ospf_area *area;
1082 struct ospf_vl_config_data vl_config;
1083 struct ospf_vl_data *vl_data = NULL;
1084 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1085 int i;
1086 int ret, format;
1087
1088 ospf_vl_config_data_init(&vl_config, vty);
1089
1090 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1091 if (ret < 0)
1092 {
1093 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1094 return CMD_WARNING;
1095 }
1096
paul68980082003-03-25 05:07:42 +00001097 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001098 if (!area)
1099 {
1100 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1101 return CMD_WARNING;
1102 }
1103
1104 ret = inet_aton (argv[1], &vl_config.vl_peer);
1105 if (! ret)
1106 {
1107 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1108 VTY_NEWLINE);
1109 return CMD_WARNING;
1110 }
1111
1112 if (argc <=2)
1113 {
1114 /* Basic VLink no command */
1115 /* Thats all folks! - BUGS B. strikes again!!!*/
Paul Jakma9c27ef92006-05-04 07:32:57 +00001116 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001117 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001118
paul68980082003-03-25 05:07:42 +00001119 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001120
1121 return CMD_SUCCESS;
1122 }
1123
1124 /* If we are down here, we are reseting parameters */
1125
1126 /* Deal with other parameters */
1127 for (i=2; i < argc; i++)
1128 {
paul718e3742002-12-13 20:15:29 +00001129 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1130
1131 switch (argv[i][0])
1132 {
1133
1134 case 'a':
1135 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1136 {
1137 /* authentication-key - this option can occur anywhere on
1138 command line. At start of command line
1139 must check for authentication option. */
1140 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1141 vl_config.auth_key = auth_key;
1142 }
1143 else if (strncmp (argv[i], "authentication", 14) == 0)
1144 {
1145 /* authentication - this option can only occur at start
1146 of command line */
1147 vl_config.auth_type = OSPF_AUTH_NOTSET;
1148 }
1149 break;
1150
1151 case 'm':
1152 /* message-digest-key */
1153 /* Delete one key */
1154 i++;
1155 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1156 if (vl_config.crypto_key_id < 0)
1157 return CMD_WARNING;
1158 vl_config.md5_key = NULL;
1159 break;
1160
1161 case 'h':
1162 /* Hello interval */
1163 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1164 break;
1165
1166 case 'r':
1167 /* Retransmit Interval */
1168 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1169 break;
1170
1171 case 't':
1172 /* Transmit Delay */
1173 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1174 break;
1175
1176 case 'd':
1177 /* Dead Interval */
1178 i++;
1179 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1180 break;
1181 }
1182 }
1183
1184
1185 /* Action configuration */
1186
paul68980082003-03-25 05:07:42 +00001187 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001188}
1189
paula2c62832003-04-23 17:01:31 +00001190ALIAS (ospf_area_vlink,
1191 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001192 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1193 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1194 VLINK_HELPSTR_IPADDR
1195 VLINK_HELPSTR_TIME_PARAM)
1196
paula2c62832003-04-23 17:01:31 +00001197ALIAS (no_ospf_area_vlink,
1198 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001199 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1200 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1201 NO_STR
1202 VLINK_HELPSTR_IPADDR
1203 VLINK_HELPSTR_TIME_PARAM)
1204
paula2c62832003-04-23 17:01:31 +00001205ALIAS (ospf_area_vlink,
1206 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001207 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1208 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1209 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1210 VLINK_HELPSTR_IPADDR
1211 VLINK_HELPSTR_TIME_PARAM
1212 VLINK_HELPSTR_TIME_PARAM)
1213
paula2c62832003-04-23 17:01:31 +00001214ALIAS (no_ospf_area_vlink,
1215 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001216 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1217 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1218 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1219 NO_STR
1220 VLINK_HELPSTR_IPADDR
1221 VLINK_HELPSTR_TIME_PARAM
1222 VLINK_HELPSTR_TIME_PARAM)
1223
paula2c62832003-04-23 17:01:31 +00001224ALIAS (ospf_area_vlink,
1225 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001226 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1227 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1228 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1229 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1230 VLINK_HELPSTR_IPADDR
1231 VLINK_HELPSTR_TIME_PARAM
1232 VLINK_HELPSTR_TIME_PARAM
1233 VLINK_HELPSTR_TIME_PARAM)
1234
paula2c62832003-04-23 17:01:31 +00001235ALIAS (no_ospf_area_vlink,
1236 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001237 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1238 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1239 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1240 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1241 NO_STR
1242 VLINK_HELPSTR_IPADDR
1243 VLINK_HELPSTR_TIME_PARAM
1244 VLINK_HELPSTR_TIME_PARAM
1245 VLINK_HELPSTR_TIME_PARAM)
1246
paula2c62832003-04-23 17:01:31 +00001247ALIAS (ospf_area_vlink,
1248 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001249 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1250 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1251 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1252 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1253 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1254 VLINK_HELPSTR_IPADDR
1255 VLINK_HELPSTR_TIME_PARAM
1256 VLINK_HELPSTR_TIME_PARAM
1257 VLINK_HELPSTR_TIME_PARAM
1258 VLINK_HELPSTR_TIME_PARAM)
1259
paula2c62832003-04-23 17:01:31 +00001260ALIAS (no_ospf_area_vlink,
1261 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001262 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1263 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1264 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1265 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1266 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1267 NO_STR
1268 VLINK_HELPSTR_IPADDR
1269 VLINK_HELPSTR_TIME_PARAM
1270 VLINK_HELPSTR_TIME_PARAM
1271 VLINK_HELPSTR_TIME_PARAM
1272 VLINK_HELPSTR_TIME_PARAM)
1273
paula2c62832003-04-23 17:01:31 +00001274ALIAS (ospf_area_vlink,
1275 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001276 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1277 "(authentication|) (message-digest|null)",
1278 VLINK_HELPSTR_IPADDR
1279 VLINK_HELPSTR_AUTHTYPE_ALL)
1280
paula2c62832003-04-23 17:01:31 +00001281ALIAS (ospf_area_vlink,
1282 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001283 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1284 "(authentication|)",
1285 VLINK_HELPSTR_IPADDR
1286 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1287
paula2c62832003-04-23 17:01:31 +00001288ALIAS (no_ospf_area_vlink,
1289 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001290 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1291 "(authentication|)",
1292 NO_STR
1293 VLINK_HELPSTR_IPADDR
1294 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1295
paula2c62832003-04-23 17:01:31 +00001296ALIAS (ospf_area_vlink,
1297 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001298 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1299 "(message-digest-key|) <1-255> md5 KEY",
1300 VLINK_HELPSTR_IPADDR
1301 VLINK_HELPSTR_AUTH_MD5)
1302
paula2c62832003-04-23 17:01:31 +00001303ALIAS (no_ospf_area_vlink,
1304 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001305 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1306 "(message-digest-key|) <1-255>",
1307 NO_STR
1308 VLINK_HELPSTR_IPADDR
1309 VLINK_HELPSTR_AUTH_MD5)
1310
paula2c62832003-04-23 17:01:31 +00001311ALIAS (ospf_area_vlink,
1312 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001313 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1314 "(authentication-key|) AUTH_KEY",
1315 VLINK_HELPSTR_IPADDR
1316 VLINK_HELPSTR_AUTH_SIMPLE)
1317
paula2c62832003-04-23 17:01:31 +00001318ALIAS (no_ospf_area_vlink,
1319 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001320 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1321 "(authentication-key|)",
1322 NO_STR
1323 VLINK_HELPSTR_IPADDR
1324 VLINK_HELPSTR_AUTH_SIMPLE)
1325
paula2c62832003-04-23 17:01:31 +00001326ALIAS (ospf_area_vlink,
1327 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001328 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1329 "(authentication|) (message-digest|null) "
1330 "(authentication-key|) AUTH_KEY",
1331 VLINK_HELPSTR_IPADDR
1332 VLINK_HELPSTR_AUTHTYPE_ALL
1333 VLINK_HELPSTR_AUTH_SIMPLE)
1334
paula2c62832003-04-23 17:01:31 +00001335ALIAS (ospf_area_vlink,
1336 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001337 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1338 "(authentication|) "
1339 "(authentication-key|) AUTH_KEY",
1340 VLINK_HELPSTR_IPADDR
1341 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1342 VLINK_HELPSTR_AUTH_SIMPLE)
1343
paula2c62832003-04-23 17:01:31 +00001344ALIAS (no_ospf_area_vlink,
1345 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001346 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1347 "(authentication|) "
1348 "(authentication-key|)",
1349 NO_STR
1350 VLINK_HELPSTR_IPADDR
1351 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1352 VLINK_HELPSTR_AUTH_SIMPLE)
1353
paula2c62832003-04-23 17:01:31 +00001354ALIAS (ospf_area_vlink,
1355 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001356 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1357 "(authentication|) (message-digest|null) "
1358 "(message-digest-key|) <1-255> md5 KEY",
1359 VLINK_HELPSTR_IPADDR
1360 VLINK_HELPSTR_AUTHTYPE_ALL
1361 VLINK_HELPSTR_AUTH_MD5)
1362
paula2c62832003-04-23 17:01:31 +00001363ALIAS (ospf_area_vlink,
1364 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001365 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1366 "(authentication|) "
1367 "(message-digest-key|) <1-255> md5 KEY",
1368 VLINK_HELPSTR_IPADDR
1369 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1370 VLINK_HELPSTR_AUTH_MD5)
1371
paula2c62832003-04-23 17:01:31 +00001372ALIAS (no_ospf_area_vlink,
1373 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001374 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1375 "(authentication|) "
1376 "(message-digest-key|)",
1377 NO_STR
1378 VLINK_HELPSTR_IPADDR
1379 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1380 VLINK_HELPSTR_AUTH_MD5)
1381
1382
paula2c62832003-04-23 17:01:31 +00001383DEFUN (ospf_area_shortcut,
1384 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001385 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1386 "OSPF area parameters\n"
1387 "OSPF area ID in IP address format\n"
1388 "OSPF area ID as a decimal value\n"
1389 "Configure the area's shortcutting mode\n"
1390 "Set default shortcutting behavior\n"
1391 "Enable shortcutting through the area\n"
1392 "Disable shortcutting through the area\n")
1393{
paul68980082003-03-25 05:07:42 +00001394 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001395 struct ospf_area *area;
1396 struct in_addr area_id;
1397 int mode;
1398 int format;
1399
1400 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1401
paul68980082003-03-25 05:07:42 +00001402 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001403
1404 if (strncmp (argv[1], "de", 2) == 0)
1405 mode = OSPF_SHORTCUT_DEFAULT;
1406 else if (strncmp (argv[1], "di", 2) == 0)
1407 mode = OSPF_SHORTCUT_DISABLE;
1408 else if (strncmp (argv[1], "e", 1) == 0)
1409 mode = OSPF_SHORTCUT_ENABLE;
1410 else
1411 return CMD_WARNING;
1412
paul68980082003-03-25 05:07:42 +00001413 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001414
paul68980082003-03-25 05:07:42 +00001415 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001416 vty_out (vty, "Shortcut area setting will take effect "
1417 "only when the router is configured as Shortcut ABR%s",
1418 VTY_NEWLINE);
1419
1420 return CMD_SUCCESS;
1421}
1422
paula2c62832003-04-23 17:01:31 +00001423DEFUN (no_ospf_area_shortcut,
1424 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001425 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1426 NO_STR
1427 "OSPF area parameters\n"
1428 "OSPF area ID in IP address format\n"
1429 "OSPF area ID as a decimal value\n"
1430 "Deconfigure the area's shortcutting mode\n"
1431 "Deconfigure enabled shortcutting through the area\n"
1432 "Deconfigure disabled shortcutting through the area\n")
1433{
paul68980082003-03-25 05:07:42 +00001434 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001435 struct ospf_area *area;
1436 struct in_addr area_id;
1437 int format;
1438
1439 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1440
paul68980082003-03-25 05:07:42 +00001441 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001442 if (!area)
1443 return CMD_SUCCESS;
1444
paul68980082003-03-25 05:07:42 +00001445 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001446
1447 return CMD_SUCCESS;
1448}
1449
1450
paula2c62832003-04-23 17:01:31 +00001451DEFUN (ospf_area_stub,
1452 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001453 "area (A.B.C.D|<0-4294967295>) stub",
1454 "OSPF area parameters\n"
1455 "OSPF area ID in IP address format\n"
1456 "OSPF area ID as a decimal value\n"
1457 "Configure OSPF area as stub\n")
1458{
1459 struct ospf *ospf = vty->index;
1460 struct in_addr area_id;
1461 int ret, format;
1462
1463 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1464
1465 ret = ospf_area_stub_set (ospf, area_id);
1466 if (ret == 0)
1467 {
1468 vty_out (vty, "First deconfigure all virtual link through this area%s",
1469 VTY_NEWLINE);
1470 return CMD_WARNING;
1471 }
1472
1473 ospf_area_no_summary_unset (ospf, area_id);
1474
1475 return CMD_SUCCESS;
1476}
1477
paula2c62832003-04-23 17:01:31 +00001478DEFUN (ospf_area_stub_no_summary,
1479 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001480 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1481 "OSPF stub parameters\n"
1482 "OSPF area ID in IP address format\n"
1483 "OSPF area ID as a decimal value\n"
1484 "Configure OSPF area as stub\n"
1485 "Do not inject inter-area routes into stub\n")
1486{
1487 struct ospf *ospf = vty->index;
1488 struct in_addr area_id;
1489 int ret, format;
1490
1491 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1492
1493 ret = ospf_area_stub_set (ospf, area_id);
1494 if (ret == 0)
1495 {
paulb0a053b2003-06-22 09:04:47 +00001496 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001497 VTY_NEWLINE);
1498 return CMD_WARNING;
1499 }
1500
1501 ospf_area_no_summary_set (ospf, area_id);
1502
1503 return CMD_SUCCESS;
1504}
1505
paula2c62832003-04-23 17:01:31 +00001506DEFUN (no_ospf_area_stub,
1507 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001508 "no area (A.B.C.D|<0-4294967295>) stub",
1509 NO_STR
1510 "OSPF area parameters\n"
1511 "OSPF area ID in IP address format\n"
1512 "OSPF area ID as a decimal value\n"
1513 "Configure OSPF area as stub\n")
1514{
1515 struct ospf *ospf = vty->index;
1516 struct in_addr area_id;
1517 int format;
1518
1519 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1520
1521 ospf_area_stub_unset (ospf, area_id);
1522 ospf_area_no_summary_unset (ospf, area_id);
1523
1524 return CMD_SUCCESS;
1525}
1526
paula2c62832003-04-23 17:01:31 +00001527DEFUN (no_ospf_area_stub_no_summary,
1528 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001529 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1530 NO_STR
1531 "OSPF area parameters\n"
1532 "OSPF area ID in IP address format\n"
1533 "OSPF area ID as a decimal value\n"
1534 "Configure OSPF area as stub\n"
1535 "Do not inject inter-area routes into area\n")
1536{
1537 struct ospf *ospf = vty->index;
1538 struct in_addr area_id;
1539 int format;
1540
1541 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1542 ospf_area_no_summary_unset (ospf, area_id);
1543
1544 return CMD_SUCCESS;
1545}
1546
paul4dadc292005-05-06 21:37:42 +00001547static int
paul6c835672004-10-11 11:00:30 +00001548ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1549 int nosum)
paul718e3742002-12-13 20:15:29 +00001550{
1551 struct ospf *ospf = vty->index;
1552 struct in_addr area_id;
1553 int ret, format;
1554
1555 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1556
1557 ret = ospf_area_nssa_set (ospf, area_id);
1558 if (ret == 0)
1559 {
1560 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1561 VTY_NEWLINE);
1562 return CMD_WARNING;
1563 }
1564
1565 if (argc > 1)
1566 {
1567 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001568 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001569 OSPF_NSSA_ROLE_CANDIDATE);
1570 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001571 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001572 OSPF_NSSA_ROLE_NEVER);
1573 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001574 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001575 OSPF_NSSA_ROLE_ALWAYS);
1576 }
paulb0a053b2003-06-22 09:04:47 +00001577 else
1578 {
1579 ospf_area_nssa_translator_role_set (ospf, area_id,
1580 OSPF_NSSA_ROLE_CANDIDATE);
1581 }
paul718e3742002-12-13 20:15:29 +00001582
paulb0a053b2003-06-22 09:04:47 +00001583 if (nosum)
paul718e3742002-12-13 20:15:29 +00001584 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001585 else
1586 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001587
paulb0a053b2003-06-22 09:04:47 +00001588 ospf_schedule_abr_task (ospf);
1589
paul718e3742002-12-13 20:15:29 +00001590 return CMD_SUCCESS;
1591}
1592
paulb0a053b2003-06-22 09:04:47 +00001593DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001594 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001595 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001596 "OSPF area parameters\n"
1597 "OSPF area ID in IP address format\n"
1598 "OSPF area ID as a decimal value\n"
1599 "Configure OSPF area as nssa\n"
1600 "Configure NSSA-ABR for translate election (default)\n"
1601 "Configure NSSA-ABR to never translate\n"
1602 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001603 "Do not inject inter-area routes into nssa\n")
1604{
1605 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1606}
paul718e3742002-12-13 20:15:29 +00001607
paulb0a053b2003-06-22 09:04:47 +00001608DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001609 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001610 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1611 "OSPF area parameters\n"
1612 "OSPF area ID in IP address format\n"
1613 "OSPF area ID as a decimal value\n"
1614 "Configure OSPF area as nssa\n"
1615 "Configure NSSA-ABR for translate election (default)\n"
1616 "Configure NSSA-ABR to never translate\n"
1617 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001618{
1619 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1620}
1621
1622DEFUN (ospf_area_nssa,
1623 ospf_area_nssa_cmd,
1624 "area (A.B.C.D|<0-4294967295>) nssa",
1625 "OSPF area parameters\n"
1626 "OSPF area ID in IP address format\n"
1627 "OSPF area ID as a decimal value\n"
1628 "Configure OSPF area as nssa\n")
1629{
1630 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1631}
paul718e3742002-12-13 20:15:29 +00001632
paula2c62832003-04-23 17:01:31 +00001633DEFUN (ospf_area_nssa_no_summary,
1634 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001635 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1636 "OSPF area parameters\n"
1637 "OSPF area ID in IP address format\n"
1638 "OSPF area ID as a decimal value\n"
1639 "Configure OSPF area as nssa\n"
1640 "Do not inject inter-area routes into nssa\n")
1641{
paulb0a053b2003-06-22 09:04:47 +00001642 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001643}
1644
paula2c62832003-04-23 17:01:31 +00001645DEFUN (no_ospf_area_nssa,
1646 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001647 "no area (A.B.C.D|<0-4294967295>) nssa",
1648 NO_STR
1649 "OSPF area parameters\n"
1650 "OSPF area ID in IP address format\n"
1651 "OSPF area ID as a decimal value\n"
1652 "Configure OSPF area as nssa\n")
1653{
1654 struct ospf *ospf = vty->index;
1655 struct in_addr area_id;
1656 int format;
1657
1658 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1659
1660 ospf_area_nssa_unset (ospf, area_id);
1661 ospf_area_no_summary_unset (ospf, area_id);
1662
paulb0a053b2003-06-22 09:04:47 +00001663 ospf_schedule_abr_task (ospf);
1664
paul718e3742002-12-13 20:15:29 +00001665 return CMD_SUCCESS;
1666}
1667
paula2c62832003-04-23 17:01:31 +00001668DEFUN (no_ospf_area_nssa_no_summary,
1669 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001670 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1671 NO_STR
1672 "OSPF area parameters\n"
1673 "OSPF area ID in IP address format\n"
1674 "OSPF area ID as a decimal value\n"
1675 "Configure OSPF area as nssa\n"
1676 "Do not inject inter-area routes into nssa\n")
1677{
1678 struct ospf *ospf = vty->index;
1679 struct in_addr area_id;
1680 int format;
1681
1682 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1683 ospf_area_no_summary_unset (ospf, area_id);
1684
1685 return CMD_SUCCESS;
1686}
1687
paula2c62832003-04-23 17:01:31 +00001688DEFUN (ospf_area_default_cost,
1689 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001690 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1691 "OSPF area parameters\n"
1692 "OSPF area ID in IP address format\n"
1693 "OSPF area ID as a decimal value\n"
1694 "Set the summary-default cost of a NSSA or stub area\n"
1695 "Stub's advertised default summary cost\n")
1696{
paul68980082003-03-25 05:07:42 +00001697 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001698 struct ospf_area *area;
1699 struct in_addr area_id;
1700 u_int32_t cost;
1701 int format;
vincentba682532005-09-29 13:52:57 +00001702 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001703
1704 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1705 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1706
paul68980082003-03-25 05:07:42 +00001707 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001708
1709 if (area->external_routing == OSPF_AREA_DEFAULT)
1710 {
1711 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1712 return CMD_WARNING;
1713 }
1714
1715 area->default_cost = cost;
1716
vincentba682532005-09-29 13:52:57 +00001717 p.family = AF_INET;
1718 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1719 p.prefixlen = 0;
1720 if (IS_DEBUG_OSPF_EVENT)
1721 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1722 "announcing 0.0.0.0/0 to area %s",
1723 inet_ntoa (area->area_id));
1724 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1725
paul718e3742002-12-13 20:15:29 +00001726 return CMD_SUCCESS;
1727}
1728
paula2c62832003-04-23 17:01:31 +00001729DEFUN (no_ospf_area_default_cost,
1730 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001731 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1732 NO_STR
1733 "OSPF area parameters\n"
1734 "OSPF area ID in IP address format\n"
1735 "OSPF area ID as a decimal value\n"
1736 "Set the summary-default cost of a NSSA or stub area\n"
1737 "Stub's advertised default summary cost\n")
1738{
paul68980082003-03-25 05:07:42 +00001739 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001740 struct ospf_area *area;
1741 struct in_addr area_id;
1742 u_int32_t cost;
1743 int format;
vincentba682532005-09-29 13:52:57 +00001744 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001745
1746 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1747 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1748
paul68980082003-03-25 05:07:42 +00001749 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001750 if (area == NULL)
1751 return CMD_SUCCESS;
1752
1753 if (area->external_routing == OSPF_AREA_DEFAULT)
1754 {
1755 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1756 return CMD_WARNING;
1757 }
1758
1759 area->default_cost = 1;
1760
vincentba682532005-09-29 13:52:57 +00001761 p.family = AF_INET;
1762 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1763 p.prefixlen = 0;
1764 if (IS_DEBUG_OSPF_EVENT)
1765 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1766 "announcing 0.0.0.0/0 to area %s",
1767 inet_ntoa (area->area_id));
1768 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1769
1770
paul68980082003-03-25 05:07:42 +00001771 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001772
1773 return CMD_SUCCESS;
1774}
1775
paula2c62832003-04-23 17:01:31 +00001776DEFUN (ospf_area_export_list,
1777 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001778 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1779 "OSPF area parameters\n"
1780 "OSPF area ID in IP address format\n"
1781 "OSPF area ID as a decimal value\n"
1782 "Set the filter for networks announced to other areas\n"
1783 "Name of the access-list\n")
1784{
paul68980082003-03-25 05:07:42 +00001785 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001786 struct ospf_area *area;
1787 struct in_addr area_id;
1788 int format;
1789
hasso52930762004-04-19 18:26:53 +00001790 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1791
paul68980082003-03-25 05:07:42 +00001792 area = ospf_area_get (ospf, area_id, format);
1793 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001794
1795 return CMD_SUCCESS;
1796}
1797
paula2c62832003-04-23 17:01:31 +00001798DEFUN (no_ospf_area_export_list,
1799 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001800 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1801 NO_STR
1802 "OSPF area parameters\n"
1803 "OSPF area ID in IP address format\n"
1804 "OSPF area ID as a decimal value\n"
1805 "Unset the filter for networks announced to other areas\n"
1806 "Name of the access-list\n")
1807{
paul68980082003-03-25 05:07:42 +00001808 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001809 struct ospf_area *area;
1810 struct in_addr area_id;
1811 int format;
1812
hasso52930762004-04-19 18:26:53 +00001813 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1814
paul68980082003-03-25 05:07:42 +00001815 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001816 if (area == NULL)
1817 return CMD_SUCCESS;
1818
paul68980082003-03-25 05:07:42 +00001819 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001820
1821 return CMD_SUCCESS;
1822}
1823
1824
paula2c62832003-04-23 17:01:31 +00001825DEFUN (ospf_area_import_list,
1826 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001827 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1828 "OSPF area parameters\n"
1829 "OSPF area ID in IP address format\n"
1830 "OSPF area ID as a decimal value\n"
1831 "Set the filter for networks from other areas announced to the specified one\n"
1832 "Name of the access-list\n")
1833{
paul68980082003-03-25 05:07:42 +00001834 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001835 struct ospf_area *area;
1836 struct in_addr area_id;
1837 int format;
1838
hasso52930762004-04-19 18:26:53 +00001839 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1840
paul68980082003-03-25 05:07:42 +00001841 area = ospf_area_get (ospf, area_id, format);
1842 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001843
1844 return CMD_SUCCESS;
1845}
1846
paula2c62832003-04-23 17:01:31 +00001847DEFUN (no_ospf_area_import_list,
1848 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001849 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1850 NO_STR
1851 "OSPF area parameters\n"
1852 "OSPF area ID in IP address format\n"
1853 "OSPF area ID as a decimal value\n"
1854 "Unset the filter for networks announced to other areas\n"
1855 "Name of the access-list\n")
1856{
paul68980082003-03-25 05:07:42 +00001857 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001858 struct ospf_area *area;
1859 struct in_addr area_id;
1860 int format;
1861
hasso52930762004-04-19 18:26:53 +00001862 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1863
paul68980082003-03-25 05:07:42 +00001864 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001865 if (area == NULL)
1866 return CMD_SUCCESS;
1867
paul68980082003-03-25 05:07:42 +00001868 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001869
1870 return CMD_SUCCESS;
1871}
1872
paula2c62832003-04-23 17:01:31 +00001873DEFUN (ospf_area_filter_list,
1874 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001875 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1876 "OSPF area parameters\n"
1877 "OSPF area ID in IP address format\n"
1878 "OSPF area ID as a decimal value\n"
1879 "Filter networks between OSPF areas\n"
1880 "Filter prefixes between OSPF areas\n"
1881 "Name of an IP prefix-list\n"
1882 "Filter networks sent to this area\n"
1883 "Filter networks sent from this area\n")
1884{
paul68980082003-03-25 05:07:42 +00001885 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001886 struct ospf_area *area;
1887 struct in_addr area_id;
1888 struct prefix_list *plist;
1889 int format;
1890
1891 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1892
paul68980082003-03-25 05:07:42 +00001893 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001894 plist = prefix_list_lookup (AFI_IP, argv[1]);
1895 if (strncmp (argv[2], "in", 2) == 0)
1896 {
1897 PREFIX_LIST_IN (area) = plist;
1898 if (PREFIX_NAME_IN (area))
1899 free (PREFIX_NAME_IN (area));
1900
1901 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001902 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001903 }
1904 else
1905 {
1906 PREFIX_LIST_OUT (area) = plist;
1907 if (PREFIX_NAME_OUT (area))
1908 free (PREFIX_NAME_OUT (area));
1909
1910 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001911 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001912 }
1913
1914 return CMD_SUCCESS;
1915}
1916
paula2c62832003-04-23 17:01:31 +00001917DEFUN (no_ospf_area_filter_list,
1918 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001919 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1920 NO_STR
1921 "OSPF area parameters\n"
1922 "OSPF area ID in IP address format\n"
1923 "OSPF area ID as a decimal value\n"
1924 "Filter networks between OSPF areas\n"
1925 "Filter prefixes between OSPF areas\n"
1926 "Name of an IP prefix-list\n"
1927 "Filter networks sent to this area\n"
1928 "Filter networks sent from this area\n")
1929{
paul68980082003-03-25 05:07:42 +00001930 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001931 struct ospf_area *area;
1932 struct in_addr area_id;
1933 struct prefix_list *plist;
1934 int format;
1935
1936 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1937
Paul Jakma1a8ec2b2006-05-11 13:34:08 +00001938 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1939 return CMD_SUCCESS;
1940
paul718e3742002-12-13 20:15:29 +00001941 plist = prefix_list_lookup (AFI_IP, argv[1]);
1942 if (strncmp (argv[2], "in", 2) == 0)
1943 {
1944 if (PREFIX_NAME_IN (area))
1945 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1946 return CMD_SUCCESS;
1947
1948 PREFIX_LIST_IN (area) = NULL;
1949 if (PREFIX_NAME_IN (area))
1950 free (PREFIX_NAME_IN (area));
1951
1952 PREFIX_NAME_IN (area) = NULL;
1953
paul68980082003-03-25 05:07:42 +00001954 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001955 }
1956 else
1957 {
1958 if (PREFIX_NAME_OUT (area))
1959 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1960 return CMD_SUCCESS;
1961
1962 PREFIX_LIST_OUT (area) = NULL;
1963 if (PREFIX_NAME_OUT (area))
1964 free (PREFIX_NAME_OUT (area));
1965
1966 PREFIX_NAME_OUT (area) = NULL;
1967
paul68980082003-03-25 05:07:42 +00001968 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001969 }
1970
1971 return CMD_SUCCESS;
1972}
1973
1974
paula2c62832003-04-23 17:01:31 +00001975DEFUN (ospf_area_authentication_message_digest,
1976 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001977 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1978 "OSPF area parameters\n"
1979 "Enable authentication\n"
1980 "Use message-digest authentication\n")
1981{
paul68980082003-03-25 05:07:42 +00001982 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001983 struct ospf_area *area;
1984 struct in_addr area_id;
1985 int format;
1986
1987 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1988
paul68980082003-03-25 05:07:42 +00001989 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001990 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1991
1992 return CMD_SUCCESS;
1993}
1994
paula2c62832003-04-23 17:01:31 +00001995DEFUN (ospf_area_authentication,
1996 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001997 "area (A.B.C.D|<0-4294967295>) authentication",
1998 "OSPF area parameters\n"
1999 "OSPF area ID in IP address format\n"
2000 "OSPF area ID as a decimal value\n"
2001 "Enable authentication\n")
2002{
paul68980082003-03-25 05:07:42 +00002003 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002004 struct ospf_area *area;
2005 struct in_addr area_id;
2006 int format;
2007
2008 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2009
paul68980082003-03-25 05:07:42 +00002010 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00002011 area->auth_type = OSPF_AUTH_SIMPLE;
2012
2013 return CMD_SUCCESS;
2014}
2015
paula2c62832003-04-23 17:01:31 +00002016DEFUN (no_ospf_area_authentication,
2017 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002018 "no area (A.B.C.D|<0-4294967295>) authentication",
2019 NO_STR
2020 "OSPF area parameters\n"
2021 "OSPF area ID in IP address format\n"
2022 "OSPF area ID as a decimal value\n"
2023 "Enable authentication\n")
2024{
paul68980082003-03-25 05:07:42 +00002025 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002026 struct ospf_area *area;
2027 struct in_addr area_id;
2028 int format;
2029
2030 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2031
paul68980082003-03-25 05:07:42 +00002032 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002033 if (area == NULL)
2034 return CMD_SUCCESS;
2035
2036 area->auth_type = OSPF_AUTH_NULL;
2037
paul68980082003-03-25 05:07:42 +00002038 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002039
2040 return CMD_SUCCESS;
2041}
2042
2043
2044DEFUN (ospf_abr_type,
2045 ospf_abr_type_cmd,
2046 "ospf abr-type (cisco|ibm|shortcut|standard)",
2047 "OSPF specific commands\n"
2048 "Set OSPF ABR type\n"
2049 "Alternative ABR, cisco implementation\n"
2050 "Alternative ABR, IBM implementation\n"
2051 "Shortcut ABR\n"
2052 "Standard behavior (RFC2328)\n")
2053{
paul68980082003-03-25 05:07:42 +00002054 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002055 u_char abr_type = OSPF_ABR_UNKNOWN;
2056
2057 if (strncmp (argv[0], "c", 1) == 0)
2058 abr_type = OSPF_ABR_CISCO;
2059 else if (strncmp (argv[0], "i", 1) == 0)
2060 abr_type = OSPF_ABR_IBM;
2061 else if (strncmp (argv[0], "sh", 2) == 0)
2062 abr_type = OSPF_ABR_SHORTCUT;
2063 else if (strncmp (argv[0], "st", 2) == 0)
2064 abr_type = OSPF_ABR_STAND;
2065 else
2066 return CMD_WARNING;
2067
2068 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002069 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002070 {
paul68980082003-03-25 05:07:42 +00002071 ospf->abr_type = abr_type;
2072 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002073 }
2074
2075 return CMD_SUCCESS;
2076}
2077
2078DEFUN (no_ospf_abr_type,
2079 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002080 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002081 NO_STR
2082 "OSPF specific commands\n"
2083 "Set OSPF ABR type\n"
2084 "Alternative ABR, cisco implementation\n"
2085 "Alternative ABR, IBM implementation\n"
2086 "Shortcut ABR\n")
2087{
paul68980082003-03-25 05:07:42 +00002088 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002089 u_char abr_type = OSPF_ABR_UNKNOWN;
2090
2091 if (strncmp (argv[0], "c", 1) == 0)
2092 abr_type = OSPF_ABR_CISCO;
2093 else if (strncmp (argv[0], "i", 1) == 0)
2094 abr_type = OSPF_ABR_IBM;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002095 else if (strncmp (argv[0], "sh", 2) == 0)
paul718e3742002-12-13 20:15:29 +00002096 abr_type = OSPF_ABR_SHORTCUT;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002097 else if (strncmp (argv[0], "st", 2) == 0)
2098 abr_type = OSPF_ABR_STAND;
paul718e3742002-12-13 20:15:29 +00002099 else
2100 return CMD_WARNING;
2101
2102 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002103 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002104 {
pauld57834f2005-07-12 20:04:22 +00002105 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002106 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002107 }
2108
2109 return CMD_SUCCESS;
2110}
2111
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002112DEFUN (ospf_log_adjacency_changes,
2113 ospf_log_adjacency_changes_cmd,
2114 "log-adjacency-changes",
2115 "Log changes in adjacency state\n")
2116{
2117 struct ospf *ospf = vty->index;
2118
2119 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2120 return CMD_SUCCESS;
2121}
2122
2123DEFUN (ospf_log_adjacency_changes_detail,
2124 ospf_log_adjacency_changes_detail_cmd,
2125 "log-adjacency-changes detail",
2126 "Log changes in adjacency state\n"
2127 "Log all state changes\n")
2128{
2129 struct ospf *ospf = vty->index;
2130
2131 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2132 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2133 return CMD_SUCCESS;
2134}
2135
2136DEFUN (no_ospf_log_adjacency_changes,
2137 no_ospf_log_adjacency_changes_cmd,
2138 "no log-adjacency-changes",
2139 NO_STR
2140 "Log changes in adjacency state\n")
2141{
2142 struct ospf *ospf = vty->index;
2143
2144 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2145 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2146 return CMD_SUCCESS;
2147}
2148
2149DEFUN (no_ospf_log_adjacency_changes_detail,
2150 no_ospf_log_adjacency_changes_detail_cmd,
2151 "no log-adjacency-changes detail",
2152 NO_STR
2153 "Log changes in adjacency state\n"
2154 "Log all state changes\n")
2155{
2156 struct ospf *ospf = vty->index;
2157
2158 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2159 return CMD_SUCCESS;
2160}
2161
paul718e3742002-12-13 20:15:29 +00002162DEFUN (ospf_compatible_rfc1583,
2163 ospf_compatible_rfc1583_cmd,
2164 "compatible rfc1583",
2165 "OSPF compatibility list\n"
2166 "compatible with RFC 1583\n")
2167{
2168 struct ospf *ospf = vty->index;
2169
2170 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2171 {
2172 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002173 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002174 }
2175 return CMD_SUCCESS;
2176}
2177
2178DEFUN (no_ospf_compatible_rfc1583,
2179 no_ospf_compatible_rfc1583_cmd,
2180 "no compatible rfc1583",
2181 NO_STR
2182 "OSPF compatibility list\n"
2183 "compatible with RFC 1583\n")
2184{
2185 struct ospf *ospf = vty->index;
2186
2187 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2188 {
2189 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002190 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002191 }
2192 return CMD_SUCCESS;
2193}
2194
2195ALIAS (ospf_compatible_rfc1583,
2196 ospf_rfc1583_flag_cmd,
2197 "ospf rfc1583compatibility",
2198 "OSPF specific commands\n"
2199 "Enable the RFC1583Compatibility flag\n")
2200
2201ALIAS (no_ospf_compatible_rfc1583,
2202 no_ospf_rfc1583_flag_cmd,
2203 "no ospf rfc1583compatibility",
2204 NO_STR
2205 "OSPF specific commands\n"
2206 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002207
2208static int
2209ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2210 unsigned int hold,
2211 unsigned int max)
2212{
2213 struct ospf *ospf = vty->index;
2214
2215 ospf->spf_delay = delay;
2216 ospf->spf_holdtime = hold;
2217 ospf->spf_max_holdtime = max;
2218
2219 return CMD_SUCCESS;
2220}
paul718e3742002-12-13 20:15:29 +00002221
pauld24f6e22005-10-21 09:23:12 +00002222DEFUN (ospf_timers_throttle_spf,
2223 ospf_timers_throttle_spf_cmd,
2224 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2225 "Adjust routing timers\n"
2226 "Throttling adaptive timer\n"
2227 "OSPF SPF timers\n"
2228 "Delay (msec) from first change received till SPF calculation\n"
2229 "Initial hold time (msec) between consecutive SPF calculations\n"
2230 "Maximum hold time (msec)\n")
2231{
2232 unsigned int delay, hold, max;
2233
2234 if (argc != 3)
2235 {
2236 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2237 return CMD_WARNING;
2238 }
2239
2240 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2241 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2242 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2243
2244 return ospf_timers_spf_set (vty, delay, hold, max);
2245}
2246
2247DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002248 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002249 "timers spf <0-4294967295> <0-4294967295>",
2250 "Adjust routing timers\n"
2251 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002252 "Delay (s) between receiving a change to SPF calculation\n"
2253 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002254{
pauld24f6e22005-10-21 09:23:12 +00002255 unsigned int delay, hold;
2256
2257 if (argc != 2)
2258 {
2259 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2260 return CMD_WARNING;
2261 }
2262
paul4dadc292005-05-06 21:37:42 +00002263 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2264 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002265
2266 /* truncate down the second values if they're greater than 600000ms */
2267 if (delay > (600000 / 1000))
2268 delay = 600000;
2269 else if (delay == 0)
2270 /* 0s delay was probably specified because of lack of ms resolution */
2271 delay = OSPF_SPF_DELAY_DEFAULT;
2272 if (hold > (600000 / 1000))
2273 hold = 600000;
2274
2275 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002276}
2277
pauld24f6e22005-10-21 09:23:12 +00002278DEFUN (no_ospf_timers_throttle_spf,
2279 no_ospf_timers_throttle_spf_cmd,
2280 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002281 NO_STR
2282 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002283 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002284 "OSPF SPF timers\n")
2285{
pauld24f6e22005-10-21 09:23:12 +00002286 return ospf_timers_spf_set (vty,
2287 OSPF_SPF_DELAY_DEFAULT,
2288 OSPF_SPF_HOLDTIME_DEFAULT,
2289 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002290}
2291
pauld24f6e22005-10-21 09:23:12 +00002292ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2293 no_ospf_timers_spf_cmd,
2294 "no timers spf",
2295 NO_STR
2296 "Adjust routing timers\n"
2297 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002298
paula2c62832003-04-23 17:01:31 +00002299DEFUN (ospf_neighbor,
2300 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002301 "neighbor A.B.C.D",
2302 NEIGHBOR_STR
2303 "Neighbor IP address\n")
2304{
2305 struct ospf *ospf = vty->index;
2306 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002307 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2308 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002309
2310 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2311
2312 if (argc > 1)
2313 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2314
2315 if (argc > 2)
2316 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2317
2318 ospf_nbr_nbma_set (ospf, nbr_addr);
2319 if (argc > 1)
2320 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2321 if (argc > 2)
2322 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2323
2324 return CMD_SUCCESS;
2325}
2326
paula2c62832003-04-23 17:01:31 +00002327ALIAS (ospf_neighbor,
2328 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002329 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2330 NEIGHBOR_STR
2331 "Neighbor IP address\n"
2332 "Neighbor Priority\n"
2333 "Priority\n"
2334 "Dead Neighbor Polling interval\n"
2335 "Seconds\n")
2336
paula2c62832003-04-23 17:01:31 +00002337ALIAS (ospf_neighbor,
2338 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002339 "neighbor A.B.C.D priority <0-255>",
2340 NEIGHBOR_STR
2341 "Neighbor IP address\n"
2342 "Neighbor Priority\n"
2343 "Seconds\n")
2344
paula2c62832003-04-23 17:01:31 +00002345DEFUN (ospf_neighbor_poll_interval,
2346 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002347 "neighbor A.B.C.D poll-interval <1-65535>",
2348 NEIGHBOR_STR
2349 "Neighbor IP address\n"
2350 "Dead Neighbor Polling interval\n"
2351 "Seconds\n")
2352{
2353 struct ospf *ospf = vty->index;
2354 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002355 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2356 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002357
2358 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2359
2360 if (argc > 1)
2361 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2362
2363 if (argc > 2)
2364 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2365
2366 ospf_nbr_nbma_set (ospf, nbr_addr);
2367 if (argc > 1)
2368 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2369 if (argc > 2)
2370 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2371
2372 return CMD_SUCCESS;
2373}
2374
paula2c62832003-04-23 17:01:31 +00002375ALIAS (ospf_neighbor_poll_interval,
2376 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002377 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2378 NEIGHBOR_STR
2379 "Neighbor address\n"
2380 "OSPF dead-router polling interval\n"
2381 "Seconds\n"
2382 "OSPF priority of non-broadcast neighbor\n"
2383 "Priority\n")
2384
paula2c62832003-04-23 17:01:31 +00002385DEFUN (no_ospf_neighbor,
2386 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002387 "no neighbor A.B.C.D",
2388 NO_STR
2389 NEIGHBOR_STR
2390 "Neighbor IP address\n")
2391{
2392 struct ospf *ospf = vty->index;
2393 struct in_addr nbr_addr;
2394 int ret;
2395
2396 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2397
2398 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2399
2400 return CMD_SUCCESS;
2401}
2402
paula2c62832003-04-23 17:01:31 +00002403ALIAS (no_ospf_neighbor,
2404 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002405 "no neighbor A.B.C.D priority <0-255>",
2406 NO_STR
2407 NEIGHBOR_STR
2408 "Neighbor IP address\n"
2409 "Neighbor Priority\n"
2410 "Priority\n")
2411
paula2c62832003-04-23 17:01:31 +00002412ALIAS (no_ospf_neighbor,
2413 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002414 "no neighbor A.B.C.D poll-interval <1-65535>",
2415 NO_STR
2416 NEIGHBOR_STR
2417 "Neighbor IP address\n"
2418 "Dead Neighbor Polling interval\n"
2419 "Seconds\n")
2420
paula2c62832003-04-23 17:01:31 +00002421ALIAS (no_ospf_neighbor,
2422 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002423 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2424 NO_STR
2425 NEIGHBOR_STR
2426 "Neighbor IP address\n"
2427 "Neighbor Priority\n"
2428 "Priority\n"
2429 "Dead Neighbor Polling interval\n"
2430 "Seconds\n")
2431
2432
paula2c62832003-04-23 17:01:31 +00002433DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002434 "refresh timer <10-1800>",
2435 "Adjust refresh parameters\n"
2436 "Set refresh timer\n"
2437 "Timer value in seconds\n")
2438{
2439 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002440 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002441
2442 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2443 interval = (interval / 10) * 10;
2444
2445 ospf_timers_refresh_set (ospf, interval);
2446
2447 return CMD_SUCCESS;
2448}
2449
paula2c62832003-04-23 17:01:31 +00002450DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002451 "no refresh timer <10-1800>",
2452 "Adjust refresh parameters\n"
2453 "Unset refresh timer\n"
2454 "Timer value in seconds\n")
2455{
2456 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002457 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002458
2459 if (argc == 1)
2460 {
2461 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2462
2463 if (ospf->lsa_refresh_interval != interval ||
2464 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2465 return CMD_SUCCESS;
2466 }
2467
2468 ospf_timers_refresh_unset (ospf);
2469
2470 return CMD_SUCCESS;
2471}
2472
paula2c62832003-04-23 17:01:31 +00002473ALIAS (no_ospf_refresh_timer,
2474 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002475 "no refresh timer",
2476 "Adjust refresh parameters\n"
2477 "Unset refresh timer\n")
2478
paula2c62832003-04-23 17:01:31 +00002479DEFUN (ospf_auto_cost_reference_bandwidth,
2480 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002481 "auto-cost reference-bandwidth <1-4294967>",
2482 "Calculate OSPF interface cost according to bandwidth\n"
2483 "Use reference bandwidth method to assign OSPF cost\n"
2484 "The reference bandwidth in terms of Mbits per second\n")
2485{
paul68980082003-03-25 05:07:42 +00002486 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002487 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002488 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002489 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002490
2491 refbw = strtol (argv[0], NULL, 10);
2492 if (refbw < 1 || refbw > 4294967)
2493 {
2494 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2495 return CMD_WARNING;
2496 }
2497
2498 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002499 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002500 return CMD_SUCCESS;
2501
paul68980082003-03-25 05:07:42 +00002502 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002503 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2504 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002505
2506 return CMD_SUCCESS;
2507}
2508
paula2c62832003-04-23 17:01:31 +00002509DEFUN (no_ospf_auto_cost_reference_bandwidth,
2510 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002511 "no auto-cost reference-bandwidth",
2512 NO_STR
2513 "Calculate OSPF interface cost according to bandwidth\n"
2514 "Use reference bandwidth method to assign OSPF cost\n")
2515{
paul68980082003-03-25 05:07:42 +00002516 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002517 struct listnode *node, *nnode;
2518 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002519
paul68980082003-03-25 05:07:42 +00002520 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002521 return CMD_SUCCESS;
2522
paul68980082003-03-25 05:07:42 +00002523 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002524 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2525 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2526
paul1eb8ef22005-04-07 07:30:20 +00002527 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2528 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002529
2530 return CMD_SUCCESS;
2531}
2532
hassoeb1ce602004-10-08 08:17:22 +00002533const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002534{
2535 "Unknown",
2536 "Standard (RFC2328)",
2537 "Alternative IBM",
2538 "Alternative Cisco",
2539 "Alternative Shortcut"
2540};
2541
hassoeb1ce602004-10-08 08:17:22 +00002542const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002543{
2544 "Default",
2545 "Enabled",
2546 "Disabled"
2547};
2548
2549
2550
paul4dadc292005-05-06 21:37:42 +00002551static void
paul718e3742002-12-13 20:15:29 +00002552show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2553{
2554 /* Show Area ID. */
2555 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2556
2557 /* Show Area type/mode. */
2558 if (OSPF_IS_AREA_BACKBONE (area))
2559 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2560 else
2561 {
2562 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002563 vty_out (vty, " (Stub%s%s)",
2564 area->no_summary ? ", no summary" : "",
2565 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002566
paulb0a053b2003-06-22 09:04:47 +00002567 else if (area->external_routing == OSPF_AREA_NSSA)
2568 vty_out (vty, " (NSSA%s%s)",
2569 area->no_summary ? ", no summary" : "",
2570 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002571
2572 vty_out (vty, "%s", VTY_NEWLINE);
2573 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002574 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002575 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002576 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002577 }
2578
2579 /* Show number of interfaces. */
2580 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2581 "Active: %d%s", listcount (area->oiflist),
2582 area->act_ints, VTY_NEWLINE);
2583
paul718e3742002-12-13 20:15:29 +00002584 if (area->external_routing == OSPF_AREA_NSSA)
2585 {
2586 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 +00002587 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002588 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2589 VTY_NEWLINE);
2590 else if (area->NSSATranslatorState)
2591 {
2592 vty_out (vty, " We are an ABR and ");
2593 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2594 vty_out (vty, "the NSSA Elected Translator. %s",
2595 VTY_NEWLINE);
2596 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2597 vty_out (vty, "always an NSSA Translator. %s",
2598 VTY_NEWLINE);
2599 }
paul718e3742002-12-13 20:15:29 +00002600 else
paulb0a053b2003-06-22 09:04:47 +00002601 {
2602 vty_out (vty, " We are an ABR, but ");
2603 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2604 vty_out (vty, "not the NSSA Elected Translator. %s",
2605 VTY_NEWLINE);
2606 else
hassoc6b87812004-12-22 13:09:59 +00002607 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002608 VTY_NEWLINE);
2609 }
paul718e3742002-12-13 20:15:29 +00002610 }
paul88d6cf32005-10-29 12:50:09 +00002611 /* Stub-router state for this area */
2612 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2613 {
ajs649654a2005-11-16 20:17:52 +00002614 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002615 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2616 VTY_NEWLINE);
2617 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2618 vty_out (vty, " Administratively activated (indefinitely)%s",
2619 VTY_NEWLINE);
2620 if (area->t_stub_router)
2621 vty_out (vty, " Active from startup, %s remaining%s",
2622 ospf_timer_dump (area->t_stub_router, timebuf,
2623 sizeof(timebuf)), VTY_NEWLINE);
2624 }
2625
paul718e3742002-12-13 20:15:29 +00002626 /* Show number of fully adjacent neighbors. */
2627 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002628 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002629
2630 /* Show authentication type. */
2631 vty_out (vty, " Area has ");
2632 if (area->auth_type == OSPF_AUTH_NULL)
2633 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2634 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2635 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2636 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2637 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2638
2639 if (!OSPF_IS_AREA_BACKBONE (area))
2640 vty_out (vty, " Number of full virtual adjacencies going through"
2641 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2642
2643 /* Show SPF calculation times. */
2644 vty_out (vty, " SPF algorithm executed %d times%s",
2645 area->spf_calculation, VTY_NEWLINE);
2646
2647 /* Show number of LSA. */
2648 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002649 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2650 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2651 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2652 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2653 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2654 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2655 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2656 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2657 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2658 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2659 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2660 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2661 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2662 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2663 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2664#ifdef HAVE_OPAQUE_LSA
2665 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2666 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2667 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2668 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2669 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2670 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2671#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002672 vty_out (vty, "%s", VTY_NEWLINE);
2673}
2674
2675DEFUN (show_ip_ospf,
2676 show_ip_ospf_cmd,
2677 "show ip ospf",
2678 SHOW_STR
2679 IP_STR
2680 "OSPF information\n")
2681{
paul1eb8ef22005-04-07 07:30:20 +00002682 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002683 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002684 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002685 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002686 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002687
2688 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002689 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002690 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002691 {
2692 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2693 return CMD_SUCCESS;
2694 }
2695
2696 /* Show Router ID. */
2697 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002698 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002699 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002700
2701 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002702 if (ospf->t_deferred_shutdown)
2703 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2704 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002705 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002706 /* Show capability. */
2707 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2708 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2709 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002710 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002711 "enabled" : "disabled", VTY_NEWLINE);
2712#ifdef HAVE_OPAQUE_LSA
2713 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002714 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002715 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002716 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002717 " (origination blocked)" : "",
2718 VTY_NEWLINE);
2719#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002720
2721 /* Show stub-router configuration */
2722 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2723 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2724 {
2725 vty_out (vty, " Stub router advertisement is configured%s",
2726 VTY_NEWLINE);
2727 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2728 vty_out (vty, " Enabled for %us after start-up%s",
2729 ospf->stub_router_startup_time, VTY_NEWLINE);
2730 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2731 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2732 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2733 }
2734
paul718e3742002-12-13 20:15:29 +00002735 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002736 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2737 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2738 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2739 " Hold time multiplier is currently %d%s",
2740 ospf->spf_delay, VTY_NEWLINE,
2741 ospf->spf_holdtime, VTY_NEWLINE,
2742 ospf->spf_max_holdtime, VTY_NEWLINE,
2743 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002744 vty_out (vty, " SPF algorithm ");
2745 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2746 {
Paul Jakma2518efd2006-08-27 06:49:29 +00002747 result = tv_sub (recent_relative_time (), ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002748 vty_out (vty, "last executed %s ago%s",
2749 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2750 VTY_NEWLINE);
2751 }
2752 else
2753 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002754 vty_out (vty, " SPF timer %s%s%s",
2755 (ospf->t_spf_calc ? "due in " : "is "),
2756 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2757 VTY_NEWLINE);
2758
paul718e3742002-12-13 20:15:29 +00002759 /* Show refresh parameters. */
2760 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002761 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002762
2763 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002764 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002765 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002766 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002767
paul68980082003-03-25 05:07:42 +00002768 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002769 vty_out (vty, " This router is an ASBR "
2770 "(injecting external routing information)%s", VTY_NEWLINE);
2771
2772 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002773 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2774 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2775 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2776#ifdef HAVE_OPAQUE_LSA
2777 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2778 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2779 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2780#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002781 /* Show number of areas attached. */
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002782 vty_out (vty, " Number of areas attached to this router: %d%s",
2783 listcount (ospf->areas), VTY_NEWLINE);
2784
2785 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2786 {
2787 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2788 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2789 else
2790 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2791 }
2792
2793 vty_out (vty, "%s",VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002794
2795 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002796 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2797 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002798
2799 return CMD_SUCCESS;
2800}
2801
2802
ajsfd651fa2005-03-29 16:08:16 +00002803static void
paul68980082003-03-25 05:07:42 +00002804show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2805 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002806{
ajsfd651fa2005-03-29 16:08:16 +00002807 int is_up;
paul718e3742002-12-13 20:15:29 +00002808 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002809 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002810
paul718e3742002-12-13 20:15:29 +00002811 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002812 vty_out (vty, "%s is %s%s", ifp->name,
2813 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002814 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2815 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2816 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002817
2818 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002819 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002820 {
2821 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2822 return;
2823 }
ajsfd651fa2005-03-29 16:08:16 +00002824 else if (!is_up)
2825 {
2826 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2827 VTY_NEWLINE);
2828 return;
2829 }
2830
paul718e3742002-12-13 20:15:29 +00002831 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2832 {
2833 struct ospf_interface *oi = rn->info;
2834
2835 if (oi == NULL)
2836 continue;
2837
2838 /* Show OSPF interface information. */
2839 vty_out (vty, " Internet Address %s/%d,",
2840 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2841
Paul Jakma9c27ef92006-05-04 07:32:57 +00002842 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2843 {
2844 struct in_addr *dest;
2845 const char *dstr;
2846
Andrew J. Schorre4529632006-12-12 19:18:21 +00002847 if (CONNECTED_PEER(oi->connected)
2848 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
Paul Jakma9c27ef92006-05-04 07:32:57 +00002849 dstr = "Peer";
2850 else
2851 dstr = "Broadcast";
2852
2853 /* For Vlinks, showing the peer address is probably more
2854 * informative than the local interface that is being used
2855 */
2856 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2857 dest = &oi->vl_data->peer_addr;
2858 else
2859 dest = &oi->connected->destination->u.prefix4;
2860
2861 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2862 }
hasso3fb9cd62004-10-19 19:44:43 +00002863
paul718e3742002-12-13 20:15:29 +00002864 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2865 VTY_NEWLINE);
2866
vincentba682532005-09-29 13:52:57 +00002867 vty_out (vty, " MTU mismatch detection:%s%s",
2868 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2869
paul718e3742002-12-13 20:15:29 +00002870 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002871 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002872 oi->output_cost, VTY_NEWLINE);
2873
2874 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2875 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2876 PRIORITY (oi), VTY_NEWLINE);
2877
2878 /* Show DR information. */
2879 if (DR (oi).s_addr == 0)
2880 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2881 else
2882 {
2883 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2884 if (nbr == NULL)
2885 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2886 else
2887 {
2888 vty_out (vty, " Designated Router (ID) %s,",
2889 inet_ntoa (nbr->router_id));
2890 vty_out (vty, " Interface Address %s%s",
2891 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2892 }
2893 }
2894
2895 /* Show BDR information. */
2896 if (BDR (oi).s_addr == 0)
2897 vty_out (vty, " No backup designated router on this network%s",
2898 VTY_NEWLINE);
2899 else
2900 {
2901 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2902 if (nbr == NULL)
2903 vty_out (vty, " No backup designated router on this network%s",
2904 VTY_NEWLINE);
2905 else
2906 {
2907 vty_out (vty, " Backup Designated Router (ID) %s,",
2908 inet_ntoa (nbr->router_id));
2909 vty_out (vty, " Interface Address %s%s",
2910 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2911 }
2912 }
Paul Jakma7eb5b472009-10-13 16:13:13 +01002913
2914 /* Next network-LSA sequence number we'll use, if we're elected DR */
2915 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
2916 != OSPF_INITIAL_SEQUENCE_NUMBER)
2917 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
2918 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
2919
ajsba6454e2005-02-08 15:37:30 +00002920 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002921 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2922 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2923 {
2924 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2925 vty_out (vty, " OSPFAllRouters");
2926 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2927 vty_out (vty, " OSPFDesignatedRouters");
2928 }
2929 else
ajsba6454e2005-02-08 15:37:30 +00002930 vty_out (vty, " <None>");
2931 vty_out (vty, "%s", VTY_NEWLINE);
2932
paul718e3742002-12-13 20:15:29 +00002933 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002934 vty_out (vty, " Hello ");
2935 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2936 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2937 else
2938 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2939 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2940 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002941 OSPF_IF_PARAM (oi, v_wait),
2942 OSPF_IF_PARAM (oi, retransmit_interval),
2943 VTY_NEWLINE);
2944
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002945 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002946 {
ajs649654a2005-11-16 20:17:52 +00002947 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002948 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002949 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002950 VTY_NEWLINE);
2951 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002952 else /* passive-interface is set */
paul718e3742002-12-13 20:15:29 +00002953 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2954
2955 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002956 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002957 VTY_NEWLINE);
2958 }
2959}
2960
2961DEFUN (show_ip_ospf_interface,
2962 show_ip_ospf_interface_cmd,
2963 "show ip ospf interface [INTERFACE]",
2964 SHOW_STR
2965 IP_STR
2966 "OSPF information\n"
2967 "Interface information\n"
2968 "Interface name\n")
2969{
2970 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002971 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002972 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002973
paul020709f2003-04-04 02:44:16 +00002974 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002975 if (ospf == NULL)
2976 {
2977 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2978 return CMD_SUCCESS;
2979 }
paul020709f2003-04-04 02:44:16 +00002980
paul718e3742002-12-13 20:15:29 +00002981 /* Show All Interfaces. */
2982 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002983 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2984 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002985 /* Interface name is specified. */
2986 else
2987 {
2988 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2989 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2990 else
paul68980082003-03-25 05:07:42 +00002991 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002992 }
2993
2994 return CMD_SUCCESS;
2995}
2996
paul4dadc292005-05-06 21:37:42 +00002997static void
pauld24f6e22005-10-21 09:23:12 +00002998show_ip_ospf_neighbour_header (struct vty *vty)
2999{
3000 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3001 VTY_NEWLINE,
3002 "Neighbor ID", "Pri", "State", "Dead Time",
3003 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3004 VTY_NEWLINE);
3005}
3006
3007static void
paul718e3742002-12-13 20:15:29 +00003008show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3009{
3010 struct route_node *rn;
3011 struct ospf_neighbor *nbr;
3012 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00003013 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003014
3015 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3016 if ((nbr = rn->info))
3017 /* Do not show myself. */
3018 if (nbr != oi->nbr_self)
3019 /* Down state is not shown. */
3020 if (nbr->state != NSM_Down)
3021 {
3022 ospf_nbr_state_message (nbr, msgbuf, 16);
3023
3024 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00003025 vty_out (vty, "%-15s %3d %-15s ",
3026 "-", nbr->priority,
3027 msgbuf);
3028 else
3029 vty_out (vty, "%-15s %3d %-15s ",
3030 inet_ntoa (nbr->router_id), nbr->priority,
3031 msgbuf);
3032
3033 vty_out (vty, "%9s ",
3034 ospf_timer_dump (nbr->t_inactivity, timebuf,
3035 sizeof(timebuf)));
3036
paul718e3742002-12-13 20:15:29 +00003037 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00003038 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00003039 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3040 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3041 VTY_NEWLINE);
3042 }
3043}
3044
3045DEFUN (show_ip_ospf_neighbor,
3046 show_ip_ospf_neighbor_cmd,
3047 "show ip ospf neighbor",
3048 SHOW_STR
3049 IP_STR
3050 "OSPF information\n"
3051 "Neighbor list\n")
3052{
paul020709f2003-04-04 02:44:16 +00003053 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003054 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003055 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003056
paul020709f2003-04-04 02:44:16 +00003057 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003058 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003059 {
3060 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3061 return CMD_SUCCESS;
3062 }
3063
pauld24f6e22005-10-21 09:23:12 +00003064 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003065
paul1eb8ef22005-04-07 07:30:20 +00003066 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3067 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003068
3069 return CMD_SUCCESS;
3070}
3071
3072DEFUN (show_ip_ospf_neighbor_all,
3073 show_ip_ospf_neighbor_all_cmd,
3074 "show ip ospf neighbor all",
3075 SHOW_STR
3076 IP_STR
3077 "OSPF information\n"
3078 "Neighbor list\n"
3079 "include down status neighbor\n")
3080{
Joakim Tjernlund35f89142008-07-01 16:54:07 +02003081 struct ospf *ospf = ospf_lookup ();
hasso52dc7ee2004-09-23 19:18:23 +00003082 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003083 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003084
paul68980082003-03-25 05:07:42 +00003085 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003086 {
3087 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3088 return CMD_SUCCESS;
3089 }
pauld24f6e22005-10-21 09:23:12 +00003090
3091 show_ip_ospf_neighbour_header (vty);
3092
paul1eb8ef22005-04-07 07:30:20 +00003093 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003094 {
hasso52dc7ee2004-09-23 19:18:23 +00003095 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003096 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003097
3098 show_ip_ospf_neighbor_sub (vty, oi);
3099
3100 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003101 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003102 {
paul718e3742002-12-13 20:15:29 +00003103 if (nbr_nbma->nbr == NULL
3104 || nbr_nbma->nbr->state == NSM_Down)
3105 {
pauld24f6e22005-10-21 09:23:12 +00003106 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003107 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003108 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003109 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3110 0, 0, 0, VTY_NEWLINE);
3111 }
3112 }
3113 }
3114
3115 return CMD_SUCCESS;
3116}
3117
3118DEFUN (show_ip_ospf_neighbor_int,
3119 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003120 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003121 SHOW_STR
3122 IP_STR
3123 "OSPF information\n"
3124 "Neighbor list\n"
3125 "Interface name\n")
3126{
paul020709f2003-04-04 02:44:16 +00003127 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003128 struct interface *ifp;
3129 struct route_node *rn;
3130
3131 ifp = if_lookup_by_name (argv[0]);
3132 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003133 {
hassobb5b7552005-08-21 20:01:15 +00003134 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003135 return CMD_WARNING;
3136 }
3137
paul020709f2003-04-04 02:44:16 +00003138 ospf = ospf_lookup ();
3139 if (ospf == NULL)
3140 {
3141 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3142 return CMD_SUCCESS;
3143 }
pauld24f6e22005-10-21 09:23:12 +00003144
3145 show_ip_ospf_neighbour_header (vty);
3146
hassobb5b7552005-08-21 20:01:15 +00003147 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003148 {
hassobb5b7552005-08-21 20:01:15 +00003149 struct ospf_interface *oi = rn->info;
3150
3151 if (oi == NULL)
3152 continue;
3153
paul718e3742002-12-13 20:15:29 +00003154 show_ip_ospf_neighbor_sub (vty, oi);
3155 }
3156
3157 return CMD_SUCCESS;
3158}
3159
paul4dadc292005-05-06 21:37:42 +00003160static void
paul718e3742002-12-13 20:15:29 +00003161show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3162 struct ospf_nbr_nbma *nbr_nbma)
3163{
ajs649654a2005-11-16 20:17:52 +00003164 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003165
3166 /* Show neighbor ID. */
3167 vty_out (vty, " Neighbor %s,", "-");
3168
3169 /* Show interface address. */
3170 vty_out (vty, " interface address %s%s",
3171 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3172 /* Show Area ID. */
3173 vty_out (vty, " In the area %s via interface %s%s",
3174 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3175 /* Show neighbor priority and state. */
3176 vty_out (vty, " Neighbor priority is %d, State is %s,",
3177 nbr_nbma->priority, "Down");
3178 /* Show state changes. */
3179 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3180
3181 /* Show PollInterval */
3182 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3183
3184 /* Show poll-interval timer. */
3185 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003186 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3187 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003188
3189 /* Show poll-interval timer thread. */
3190 vty_out (vty, " Thread Poll Timer %s%s",
3191 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3192}
3193
paul4dadc292005-05-06 21:37:42 +00003194static void
paul718e3742002-12-13 20:15:29 +00003195show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3196 struct ospf_neighbor *nbr)
3197{
ajs649654a2005-11-16 20:17:52 +00003198 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003199
3200 /* Show neighbor ID. */
3201 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3202 vty_out (vty, " Neighbor %s,", "-");
3203 else
3204 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3205
3206 /* Show interface address. */
3207 vty_out (vty, " interface address %s%s",
3208 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3209 /* Show Area ID. */
3210 vty_out (vty, " In the area %s via interface %s%s",
3211 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3212 /* Show neighbor priority and state. */
3213 vty_out (vty, " Neighbor priority is %d, State is %s,",
3214 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3215 /* Show state changes. */
3216 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
Paul Jakma3fed4162006-07-25 20:44:12 +00003217 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
Paul Jakma90c33172006-07-11 17:57:25 +00003218 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003219 struct timeval res
3220 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003221 vty_out (vty, " Most recent state change statistics:%s",
3222 VTY_NEWLINE);
3223 vty_out (vty, " Progressive change %s ago%s",
Paul Jakma90c33172006-07-11 17:57:25 +00003224 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
Paul Jakma3fed4162006-07-25 20:44:12 +00003225 VTY_NEWLINE);
3226 }
3227 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3228 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003229 struct timeval res
3230 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003231 vty_out (vty, " Regressive change %s ago, due to %s%s",
3232 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3233 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
Paul Jakma90c33172006-07-11 17:57:25 +00003234 VTY_NEWLINE);
3235 }
paul718e3742002-12-13 20:15:29 +00003236 /* Show Designated Rotuer ID. */
3237 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3238 /* Show Backup Designated Rotuer ID. */
3239 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3240 /* Show options. */
3241 vty_out (vty, " Options %d %s%s", nbr->options,
3242 ospf_options_dump (nbr->options), VTY_NEWLINE);
3243 /* Show Router Dead interval timer. */
3244 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003245 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3246 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003247 /* Show Database Summary list. */
3248 vty_out (vty, " Database Summary List %d%s",
3249 ospf_db_summary_count (nbr), VTY_NEWLINE);
3250 /* Show Link State Request list. */
3251 vty_out (vty, " Link State Request List %ld%s",
3252 ospf_ls_request_count (nbr), VTY_NEWLINE);
3253 /* Show Link State Retransmission list. */
3254 vty_out (vty, " Link State Retransmission List %ld%s",
3255 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3256 /* Show inactivity timer thread. */
3257 vty_out (vty, " Thread Inactivity Timer %s%s",
3258 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3259 /* Show Database Description retransmission thread. */
3260 vty_out (vty, " Thread Database Description Retransmision %s%s",
3261 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3262 /* Show Link State Request Retransmission thread. */
3263 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3264 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3265 /* Show Link State Update Retransmission thread. */
3266 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3267 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3268}
3269
3270DEFUN (show_ip_ospf_neighbor_id,
3271 show_ip_ospf_neighbor_id_cmd,
3272 "show ip ospf neighbor A.B.C.D",
3273 SHOW_STR
3274 IP_STR
3275 "OSPF information\n"
3276 "Neighbor list\n"
3277 "Neighbor ID\n")
3278{
paul020709f2003-04-04 02:44:16 +00003279 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003280 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003281 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003282 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003283 struct in_addr router_id;
3284 int ret;
3285
3286 ret = inet_aton (argv[0], &router_id);
3287 if (!ret)
3288 {
3289 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3290 return CMD_WARNING;
3291 }
3292
paul020709f2003-04-04 02:44:16 +00003293 ospf = ospf_lookup ();
3294 if (ospf == NULL)
3295 {
3296 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3297 return CMD_SUCCESS;
3298 }
3299
paul1eb8ef22005-04-07 07:30:20 +00003300 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3301 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003302 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003303
paul718e3742002-12-13 20:15:29 +00003304 return CMD_SUCCESS;
3305}
3306
3307DEFUN (show_ip_ospf_neighbor_detail,
3308 show_ip_ospf_neighbor_detail_cmd,
3309 "show ip ospf neighbor detail",
3310 SHOW_STR
3311 IP_STR
3312 "OSPF information\n"
3313 "Neighbor list\n"
3314 "detail of all neighbors\n")
3315{
paul020709f2003-04-04 02:44:16 +00003316 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003317 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003318 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003319
paul020709f2003-04-04 02:44:16 +00003320 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003321 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003322 {
3323 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3324 return CMD_SUCCESS;
3325 }
paul718e3742002-12-13 20:15:29 +00003326
paul1eb8ef22005-04-07 07:30:20 +00003327 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003328 {
paul718e3742002-12-13 20:15:29 +00003329 struct route_node *rn;
3330 struct ospf_neighbor *nbr;
3331
3332 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3333 if ((nbr = rn->info))
3334 if (nbr != oi->nbr_self)
3335 if (nbr->state != NSM_Down)
3336 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3337 }
3338
3339 return CMD_SUCCESS;
3340}
3341
3342DEFUN (show_ip_ospf_neighbor_detail_all,
3343 show_ip_ospf_neighbor_detail_all_cmd,
3344 "show ip ospf neighbor detail all",
3345 SHOW_STR
3346 IP_STR
3347 "OSPF information\n"
3348 "Neighbor list\n"
3349 "detail of all neighbors\n"
3350 "include down status neighbor\n")
3351{
paul020709f2003-04-04 02:44:16 +00003352 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003353 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003354 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003355
paul020709f2003-04-04 02:44:16 +00003356 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003357 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003358 {
3359 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3360 return CMD_SUCCESS;
3361 }
paul718e3742002-12-13 20:15:29 +00003362
paul1eb8ef22005-04-07 07:30:20 +00003363 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003364 {
paul718e3742002-12-13 20:15:29 +00003365 struct route_node *rn;
3366 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003367 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003368
3369 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3370 if ((nbr = rn->info))
3371 if (nbr != oi->nbr_self)
3372 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3373 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3374
3375 if (oi->type == OSPF_IFTYPE_NBMA)
3376 {
hasso52dc7ee2004-09-23 19:18:23 +00003377 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003378
paul1eb8ef22005-04-07 07:30:20 +00003379 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3380 if (nbr_nbma->nbr == NULL
3381 || nbr_nbma->nbr->state == NSM_Down)
3382 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003383 }
3384 }
3385
3386 return CMD_SUCCESS;
3387}
3388
3389DEFUN (show_ip_ospf_neighbor_int_detail,
3390 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003391 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003392 SHOW_STR
3393 IP_STR
3394 "OSPF information\n"
3395 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003396 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003397 "detail of all neighbors")
3398{
paul020709f2003-04-04 02:44:16 +00003399 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003400 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003401 struct interface *ifp;
3402 struct route_node *rn, *nrn;
3403 struct ospf_neighbor *nbr;
3404
3405 ifp = if_lookup_by_name (argv[0]);
3406 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003407 {
hassobb5b7552005-08-21 20:01:15 +00003408 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003409 return CMD_WARNING;
3410 }
3411
paul020709f2003-04-04 02:44:16 +00003412 ospf = ospf_lookup ();
3413 if (ospf == NULL)
3414 {
3415 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3416 return CMD_SUCCESS;
3417 }
paul68980082003-03-25 05:07:42 +00003418
paul718e3742002-12-13 20:15:29 +00003419
hassobb5b7552005-08-21 20:01:15 +00003420 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3421 if ((oi = rn->info))
3422 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3423 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003424 if (nbr != oi->nbr_self)
3425 if (nbr->state != NSM_Down)
3426 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003427
3428 return CMD_SUCCESS;
3429}
3430
3431
3432/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003433static int
paul020709f2003-04-04 02:44:16 +00003434show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003435{
paul718e3742002-12-13 20:15:29 +00003436 struct router_lsa *rl;
3437 struct summary_lsa *sl;
3438 struct as_external_lsa *asel;
3439 struct prefix_ipv4 p;
3440
3441 if (lsa != NULL)
3442 /* If self option is set, check LSA self flag. */
3443 if (self == 0 || IS_LSA_SELF (lsa))
3444 {
3445 /* LSA common part show. */
3446 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3447 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3448 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3449 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3450 /* LSA specific part show. */
3451 switch (lsa->data->type)
3452 {
3453 case OSPF_ROUTER_LSA:
3454 rl = (struct router_lsa *) lsa->data;
3455 vty_out (vty, " %-d", ntohs (rl->links));
3456 break;
3457 case OSPF_SUMMARY_LSA:
3458 sl = (struct summary_lsa *) lsa->data;
3459
3460 p.family = AF_INET;
3461 p.prefix = sl->header.id;
3462 p.prefixlen = ip_masklen (sl->mask);
3463 apply_mask_ipv4 (&p);
3464
3465 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3466 break;
3467 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003468 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003469 asel = (struct as_external_lsa *) lsa->data;
3470
3471 p.family = AF_INET;
3472 p.prefix = asel->header.id;
3473 p.prefixlen = ip_masklen (asel->mask);
3474 apply_mask_ipv4 (&p);
3475
3476 vty_out (vty, " %s %s/%d [0x%lx]",
3477 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3478 inet_ntoa (p.prefix), p.prefixlen,
3479 (u_long)ntohl (asel->e[0].route_tag));
3480 break;
3481 case OSPF_NETWORK_LSA:
3482 case OSPF_ASBR_SUMMARY_LSA:
3483#ifdef HAVE_OPAQUE_LSA
3484 case OSPF_OPAQUE_LINK_LSA:
3485 case OSPF_OPAQUE_AREA_LSA:
3486 case OSPF_OPAQUE_AS_LSA:
3487#endif /* HAVE_OPAQUE_LSA */
3488 default:
3489 break;
3490 }
3491 vty_out (vty, VTY_NEWLINE);
3492 }
3493
3494 return 0;
3495}
3496
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003497static const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003498{
3499 "unknown",
3500 "Router Link States",
3501 "Net Link States",
3502 "Summary Link States",
3503 "ASBR-Summary Link States",
3504 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003505 "Group Membership LSA",
3506 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003507#ifdef HAVE_OPAQUE_LSA
3508 "Type-8 LSA",
3509 "Link-Local Opaque-LSA",
3510 "Area-Local Opaque-LSA",
3511 "AS-external Opaque-LSA",
3512#endif /* HAVE_OPAQUE_LSA */
3513};
3514
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003515static const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003516{
3517 "",
3518 "Link ID ADV Router Age Seq# CkSum Link count",
3519 "Link ID ADV Router Age Seq# CkSum",
3520 "Link ID ADV Router Age Seq# CkSum Route",
3521 "Link ID ADV Router Age Seq# CkSum",
3522 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003523 " --- header for Group Member ----",
3524 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003525#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003526 " --- type-8 ---",
3527 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3528 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3529 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3530#endif /* HAVE_OPAQUE_LSA */
3531};
3532
paul4dadc292005-05-06 21:37:42 +00003533static void
paul718e3742002-12-13 20:15:29 +00003534show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3535{
3536 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003537
paul718e3742002-12-13 20:15:29 +00003538 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003539 vty_out (vty, " Options: 0x%-2x : %s%s",
3540 lsa->data->options,
3541 ospf_options_dump(lsa->data->options),
3542 VTY_NEWLINE);
3543 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003544 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003545 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3546 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003547
3548 if (lsa->data->type == OSPF_ROUTER_LSA)
3549 {
3550 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3551
3552 if (rlsa->flags)
3553 vty_out (vty, " :%s%s%s%s",
3554 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3555 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3556 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3557 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3558
3559 vty_out (vty, "%s", VTY_NEWLINE);
3560 }
3561 vty_out (vty, " LS Type: %s%s",
3562 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3563 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3564 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3565 vty_out (vty, " Advertising Router: %s%s",
3566 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3567 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3568 VTY_NEWLINE);
3569 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3570 VTY_NEWLINE);
3571 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3572}
3573
hassoeb1ce602004-10-08 08:17:22 +00003574const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003575{
3576 "(null)",
3577 "another Router (point-to-point)",
3578 "a Transit Network",
3579 "Stub Network",
3580 "a Virtual Link",
3581};
3582
hassoeb1ce602004-10-08 08:17:22 +00003583const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003584{
3585 "(null)",
3586 "Neighboring Router ID",
3587 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003588 "Net",
paul718e3742002-12-13 20:15:29 +00003589 "Neighboring Router ID",
3590};
3591
hassoeb1ce602004-10-08 08:17:22 +00003592const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003593{
3594 "(null)",
3595 "Router Interface address",
3596 "Router Interface address",
3597 "Network Mask",
3598 "Router Interface address",
3599};
3600
3601/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003602static void
paul718e3742002-12-13 20:15:29 +00003603show_ip_ospf_database_router_links (struct vty *vty,
3604 struct router_lsa *rl)
3605{
3606 int len, i, type;
3607
3608 len = ntohs (rl->header.length) - 4;
3609 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3610 {
3611 type = rl->link[i].type;
3612
3613 vty_out (vty, " Link connected to: %s%s",
3614 link_type_desc[type], VTY_NEWLINE);
3615 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3616 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3617 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3618 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3619 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3620 vty_out (vty, " TOS 0 Metric: %d%s",
3621 ntohs (rl->link[i].metric), VTY_NEWLINE);
3622 vty_out (vty, "%s", VTY_NEWLINE);
3623 }
3624}
3625
3626/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003627static int
paul718e3742002-12-13 20:15:29 +00003628show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3629{
3630 if (lsa != NULL)
3631 {
3632 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3633
3634 show_ip_ospf_database_header (vty, lsa);
3635
3636 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3637 VTY_NEWLINE, VTY_NEWLINE);
3638
3639 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003640 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003641 }
3642
3643 return 0;
3644}
3645
3646/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003647static int
paul718e3742002-12-13 20:15:29 +00003648show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3649{
3650 int length, i;
3651
3652 if (lsa != NULL)
3653 {
3654 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3655
3656 show_ip_ospf_database_header (vty, lsa);
3657
3658 vty_out (vty, " Network Mask: /%d%s",
3659 ip_masklen (nl->mask), VTY_NEWLINE);
3660
3661 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3662
3663 for (i = 0; length > 0; i++, length -= 4)
3664 vty_out (vty, " Attached Router: %s%s",
3665 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3666
3667 vty_out (vty, "%s", VTY_NEWLINE);
3668 }
3669
3670 return 0;
3671}
3672
3673/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003674static int
paul718e3742002-12-13 20:15:29 +00003675show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3676{
3677 if (lsa != NULL)
3678 {
3679 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3680
3681 show_ip_ospf_database_header (vty, lsa);
3682
3683 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3684 VTY_NEWLINE);
3685 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3686 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003687 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003688 }
3689
3690 return 0;
3691}
3692
3693/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003694static int
paul718e3742002-12-13 20:15:29 +00003695show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3696{
3697 if (lsa != NULL)
3698 {
3699 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3700
3701 show_ip_ospf_database_header (vty, lsa);
3702
3703 vty_out (vty, " Network Mask: /%d%s",
3704 ip_masklen (sl->mask), VTY_NEWLINE);
3705 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3706 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003707 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003708 }
3709
3710 return 0;
3711}
3712
3713/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003714static int
paul718e3742002-12-13 20:15:29 +00003715show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3716{
3717 if (lsa != NULL)
3718 {
3719 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3720
3721 show_ip_ospf_database_header (vty, lsa);
3722
3723 vty_out (vty, " Network Mask: /%d%s",
3724 ip_masklen (al->mask), VTY_NEWLINE);
3725 vty_out (vty, " Metric Type: %s%s",
3726 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3727 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3728 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3729 vty_out (vty, " Metric: %d%s",
3730 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3731 vty_out (vty, " Forward Address: %s%s",
3732 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3733
3734 vty_out (vty, " External Route Tag: %lu%s%s",
3735 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3736 }
3737
3738 return 0;
3739}
3740
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003741#if 0
paul4dadc292005-05-06 21:37:42 +00003742static int
paul718e3742002-12-13 20:15:29 +00003743show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3744{
3745 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3746
3747 /* show_ip_ospf_database_header (vty, lsa); */
3748
ajs2a42e282004-12-08 18:43:03 +00003749 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003750 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003751 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003752 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3753 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003754 zlog_debug( " TOS: 0%s", "\n");
3755 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003756 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003757 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003758 inet_ntoa (al->e[0].fwd_addr), "\n");
3759
ajs2a42e282004-12-08 18:43:03 +00003760 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003761 ntohl (al->e[0].route_tag), "\n", "\n");
3762
3763 return 0;
3764}
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003765#endif
paul718e3742002-12-13 20:15:29 +00003766
3767/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003768static int
paul718e3742002-12-13 20:15:29 +00003769show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3770{
3771 if (lsa != NULL)
3772 {
3773 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3774
3775 show_ip_ospf_database_header (vty, lsa);
3776
3777 vty_out (vty, " Network Mask: /%d%s",
3778 ip_masklen (al->mask), VTY_NEWLINE);
3779 vty_out (vty, " Metric Type: %s%s",
3780 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3781 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3782 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3783 vty_out (vty, " Metric: %d%s",
3784 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3785 vty_out (vty, " NSSA: Forward Address: %s%s",
3786 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3787
3788 vty_out (vty, " External Route Tag: %u%s%s",
3789 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3790 }
3791
3792 return 0;
3793}
3794
paul4dadc292005-05-06 21:37:42 +00003795static int
paul718e3742002-12-13 20:15:29 +00003796show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3797{
3798 return 0;
3799}
3800
3801#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003802static int
paul718e3742002-12-13 20:15:29 +00003803show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3804{
3805 if (lsa != NULL)
3806 {
3807 show_ip_ospf_database_header (vty, lsa);
3808 show_opaque_info_detail (vty, lsa);
3809
3810 vty_out (vty, "%s", VTY_NEWLINE);
3811 }
3812 return 0;
3813}
3814#endif /* HAVE_OPAQUE_LSA */
3815
3816int (*show_function[])(struct vty *, struct ospf_lsa *) =
3817{
3818 NULL,
3819 show_router_lsa_detail,
3820 show_network_lsa_detail,
3821 show_summary_lsa_detail,
3822 show_summary_asbr_lsa_detail,
3823 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003824 show_func_dummy,
3825 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003826#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003827 NULL, /* type-8 */
3828 show_opaque_lsa_detail,
3829 show_opaque_lsa_detail,
3830 show_opaque_lsa_detail,
3831#endif /* HAVE_OPAQUE_LSA */
3832};
3833
paul4dadc292005-05-06 21:37:42 +00003834static void
paul718e3742002-12-13 20:15:29 +00003835show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3836 struct in_addr *adv_router)
3837{
3838 memset (lp, 0, sizeof (struct prefix_ls));
3839 lp->family = 0;
3840 if (id == NULL)
3841 lp->prefixlen = 0;
3842 else if (adv_router == NULL)
3843 {
3844 lp->prefixlen = 32;
3845 lp->id = *id;
3846 }
3847 else
3848 {
3849 lp->prefixlen = 64;
3850 lp->id = *id;
3851 lp->adv_router = *adv_router;
3852 }
3853}
3854
paul4dadc292005-05-06 21:37:42 +00003855static void
paul718e3742002-12-13 20:15:29 +00003856show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3857 struct in_addr *id, struct in_addr *adv_router)
3858{
3859 struct prefix_ls lp;
3860 struct route_node *rn, *start;
3861 struct ospf_lsa *lsa;
3862
3863 show_lsa_prefix_set (vty, &lp, id, adv_router);
3864 start = route_node_get (rt, (struct prefix *) &lp);
3865 if (start)
3866 {
3867 route_lock_node (start);
3868 for (rn = start; rn; rn = route_next_until (rn, start))
3869 if ((lsa = rn->info))
3870 {
paul718e3742002-12-13 20:15:29 +00003871 if (show_function[lsa->data->type] != NULL)
3872 show_function[lsa->data->type] (vty, lsa);
3873 }
3874 route_unlock_node (start);
3875 }
3876}
3877
3878/* Show detail LSA information
3879 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003880static void
paul020709f2003-04-04 02:44:16 +00003881show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003882 struct in_addr *id, struct in_addr *adv_router)
3883{
hasso52dc7ee2004-09-23 19:18:23 +00003884 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003885 struct ospf_area *area;
3886
paul718e3742002-12-13 20:15:29 +00003887 switch (type)
3888 {
3889 case OSPF_AS_EXTERNAL_LSA:
3890#ifdef HAVE_OPAQUE_LSA
3891 case OSPF_OPAQUE_AS_LSA:
3892#endif /* HAVE_OPAQUE_LSA */
3893 vty_out (vty, " %s %s%s",
3894 show_database_desc[type],
3895 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003896 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003897 break;
3898 default:
paul1eb8ef22005-04-07 07:30:20 +00003899 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003900 {
paul718e3742002-12-13 20:15:29 +00003901 vty_out (vty, "%s %s (Area %s)%s%s",
3902 VTY_NEWLINE, show_database_desc[type],
3903 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3904 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3905 }
3906 break;
3907 }
3908}
3909
paul4dadc292005-05-06 21:37:42 +00003910static void
paul718e3742002-12-13 20:15:29 +00003911show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3912 struct in_addr *adv_router)
3913{
3914 struct route_node *rn;
3915 struct ospf_lsa *lsa;
3916
3917 for (rn = route_top (rt); rn; rn = route_next (rn))
3918 if ((lsa = rn->info))
3919 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3920 {
paul718e3742002-12-13 20:15:29 +00003921 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3922 continue;
paul718e3742002-12-13 20:15:29 +00003923 if (show_function[lsa->data->type] != NULL)
3924 show_function[lsa->data->type] (vty, lsa);
3925 }
3926}
3927
3928/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003929static void
paul020709f2003-04-04 02:44:16 +00003930show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003931 struct in_addr *adv_router)
3932{
hasso52dc7ee2004-09-23 19:18:23 +00003933 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003934 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003935
3936 switch (type)
3937 {
3938 case OSPF_AS_EXTERNAL_LSA:
3939#ifdef HAVE_OPAQUE_LSA
3940 case OSPF_OPAQUE_AS_LSA:
3941#endif /* HAVE_OPAQUE_LSA */
3942 vty_out (vty, " %s %s%s",
3943 show_database_desc[type],
3944 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003945 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003946 adv_router);
3947 break;
3948 default:
paul1eb8ef22005-04-07 07:30:20 +00003949 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003950 {
paul718e3742002-12-13 20:15:29 +00003951 vty_out (vty, "%s %s (Area %s)%s%s",
3952 VTY_NEWLINE, show_database_desc[type],
3953 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3954 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3955 adv_router);
3956 }
3957 break;
3958 }
3959}
3960
paul4dadc292005-05-06 21:37:42 +00003961static void
paul020709f2003-04-04 02:44:16 +00003962show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003963{
paul020709f2003-04-04 02:44:16 +00003964 struct ospf_lsa *lsa;
3965 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003966 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003967 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003968 int type;
3969
paul1eb8ef22005-04-07 07:30:20 +00003970 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003971 {
paul718e3742002-12-13 20:15:29 +00003972 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3973 {
3974 switch (type)
3975 {
3976 case OSPF_AS_EXTERNAL_LSA:
3977#ifdef HAVE_OPAQUE_LSA
3978 case OSPF_OPAQUE_AS_LSA:
3979#endif /* HAVE_OPAQUE_LSA */
3980 continue;
3981 default:
3982 break;
3983 }
3984 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3985 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3986 {
3987 vty_out (vty, " %s (Area %s)%s%s",
3988 show_database_desc[type],
3989 ospf_area_desc_string (area),
3990 VTY_NEWLINE, VTY_NEWLINE);
3991 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3992
paul020709f2003-04-04 02:44:16 +00003993 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3994 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003995
3996 vty_out (vty, "%s", VTY_NEWLINE);
3997 }
3998 }
3999 }
4000
4001 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4002 {
4003 switch (type)
4004 {
4005 case OSPF_AS_EXTERNAL_LSA:
4006#ifdef HAVE_OPAQUE_LSA
4007 case OSPF_OPAQUE_AS_LSA:
4008#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00004009 break;
paul718e3742002-12-13 20:15:29 +00004010 default:
4011 continue;
4012 }
paul68980082003-03-25 05:07:42 +00004013 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4014 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00004015 {
4016 vty_out (vty, " %s%s%s",
4017 show_database_desc[type],
4018 VTY_NEWLINE, VTY_NEWLINE);
4019 vty_out (vty, "%s%s", show_database_header[type],
4020 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00004021
4022 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4023 show_lsa_summary (vty, lsa, self);
4024
paul718e3742002-12-13 20:15:29 +00004025 vty_out (vty, "%s", VTY_NEWLINE);
4026 }
4027 }
4028
4029 vty_out (vty, "%s", VTY_NEWLINE);
4030}
4031
paul4dadc292005-05-06 21:37:42 +00004032static void
paul020709f2003-04-04 02:44:16 +00004033show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00004034{
hasso52dc7ee2004-09-23 19:18:23 +00004035 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00004036 struct ospf_lsa *lsa;
4037
4038 vty_out (vty, "%s MaxAge Link States:%s%s",
4039 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4040
paul1eb8ef22005-04-07 07:30:20 +00004041 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
4042 {
4043 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4044 vty_out (vty, "Link State ID: %s%s",
4045 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4046 vty_out (vty, "Advertising Router: %s%s",
4047 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4048 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4049 vty_out (vty, "%s", VTY_NEWLINE);
4050 }
paul718e3742002-12-13 20:15:29 +00004051}
4052
paul718e3742002-12-13 20:15:29 +00004053#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4054#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00004055
4056#ifdef HAVE_OPAQUE_LSA
4057#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4058#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4059#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4060#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4061#else /* HAVE_OPAQUE_LSA */
4062#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4063#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4064#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4065#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4066#endif /* HAVE_OPAQUE_LSA */
4067
4068#define OSPF_LSA_TYPES_CMD_STR \
4069 "asbr-summary|external|network|router|summary" \
4070 OSPF_LSA_TYPE_NSSA_CMD_STR \
4071 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4072
4073#define OSPF_LSA_TYPES_DESC \
4074 "ASBR summary link states\n" \
4075 "External link states\n" \
4076 "Network link states\n" \
4077 "Router link states\n" \
4078 "Network summary link states\n" \
4079 OSPF_LSA_TYPE_NSSA_DESC \
4080 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4081 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4082 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4083
4084DEFUN (show_ip_ospf_database,
4085 show_ip_ospf_database_cmd,
4086 "show ip ospf database",
4087 SHOW_STR
4088 IP_STR
4089 "OSPF information\n"
4090 "Database summary\n")
4091{
paul020709f2003-04-04 02:44:16 +00004092 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004093 int type, ret;
4094 struct in_addr id, adv_router;
4095
paul020709f2003-04-04 02:44:16 +00004096 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004097 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004098 {
4099 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4100 return CMD_SUCCESS;
4101 }
paul718e3742002-12-13 20:15:29 +00004102
4103 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004104 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004105
4106 /* Show all LSA. */
4107 if (argc == 0)
4108 {
paul020709f2003-04-04 02:44:16 +00004109 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004110 return CMD_SUCCESS;
4111 }
4112
4113 /* Set database type to show. */
4114 if (strncmp (argv[0], "r", 1) == 0)
4115 type = OSPF_ROUTER_LSA;
4116 else if (strncmp (argv[0], "ne", 2) == 0)
4117 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004118 else if (strncmp (argv[0], "ns", 2) == 0)
4119 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004120 else if (strncmp (argv[0], "su", 2) == 0)
4121 type = OSPF_SUMMARY_LSA;
4122 else if (strncmp (argv[0], "a", 1) == 0)
4123 type = OSPF_ASBR_SUMMARY_LSA;
4124 else if (strncmp (argv[0], "e", 1) == 0)
4125 type = OSPF_AS_EXTERNAL_LSA;
4126 else if (strncmp (argv[0], "se", 2) == 0)
4127 {
paul020709f2003-04-04 02:44:16 +00004128 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004129 return CMD_SUCCESS;
4130 }
4131 else if (strncmp (argv[0], "m", 1) == 0)
4132 {
paul020709f2003-04-04 02:44:16 +00004133 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004134 return CMD_SUCCESS;
4135 }
4136#ifdef HAVE_OPAQUE_LSA
4137 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4138 type = OSPF_OPAQUE_LINK_LSA;
4139 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4140 type = OSPF_OPAQUE_AREA_LSA;
4141 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4142 type = OSPF_OPAQUE_AS_LSA;
4143#endif /* HAVE_OPAQUE_LSA */
4144 else
4145 return CMD_WARNING;
4146
4147 /* `show ip ospf database LSA'. */
4148 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004149 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004150 else if (argc >= 2)
4151 {
4152 ret = inet_aton (argv[1], &id);
4153 if (!ret)
4154 return CMD_WARNING;
4155
4156 /* `show ip ospf database LSA ID'. */
4157 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004158 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004159 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4160 else if (argc == 3)
4161 {
4162 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004163 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004164 else
4165 {
4166 ret = inet_aton (argv[2], &adv_router);
4167 if (!ret)
4168 return CMD_WARNING;
4169 }
paul020709f2003-04-04 02:44:16 +00004170 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004171 }
4172 }
4173
4174 return CMD_SUCCESS;
4175}
4176
4177ALIAS (show_ip_ospf_database,
4178 show_ip_ospf_database_type_cmd,
4179 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4180 SHOW_STR
4181 IP_STR
4182 "OSPF information\n"
4183 "Database summary\n"
4184 OSPF_LSA_TYPES_DESC
4185 "LSAs in MaxAge list\n"
4186 "Self-originated link states\n")
4187
4188ALIAS (show_ip_ospf_database,
4189 show_ip_ospf_database_type_id_cmd,
4190 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4191 SHOW_STR
4192 IP_STR
4193 "OSPF information\n"
4194 "Database summary\n"
4195 OSPF_LSA_TYPES_DESC
4196 "Link State ID (as an IP address)\n")
4197
4198ALIAS (show_ip_ospf_database,
4199 show_ip_ospf_database_type_id_adv_router_cmd,
4200 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4201 SHOW_STR
4202 IP_STR
4203 "OSPF information\n"
4204 "Database summary\n"
4205 OSPF_LSA_TYPES_DESC
4206 "Link State ID (as an IP address)\n"
4207 "Advertising Router link states\n"
4208 "Advertising Router (as an IP address)\n")
4209
4210ALIAS (show_ip_ospf_database,
4211 show_ip_ospf_database_type_id_self_cmd,
4212 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4213 SHOW_STR
4214 IP_STR
4215 "OSPF information\n"
4216 "Database summary\n"
4217 OSPF_LSA_TYPES_DESC
4218 "Link State ID (as an IP address)\n"
4219 "Self-originated link states\n"
4220 "\n")
4221
4222DEFUN (show_ip_ospf_database_type_adv_router,
4223 show_ip_ospf_database_type_adv_router_cmd,
4224 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4225 SHOW_STR
4226 IP_STR
4227 "OSPF information\n"
4228 "Database summary\n"
4229 OSPF_LSA_TYPES_DESC
4230 "Advertising Router link states\n"
4231 "Advertising Router (as an IP address)\n")
4232{
paul020709f2003-04-04 02:44:16 +00004233 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004234 int type, ret;
4235 struct in_addr adv_router;
4236
paul020709f2003-04-04 02:44:16 +00004237 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004238 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004239 {
4240 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4241 return CMD_SUCCESS;
4242 }
paul718e3742002-12-13 20:15:29 +00004243
4244 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004245 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004246
4247 if (argc != 2)
4248 return CMD_WARNING;
4249
4250 /* Set database type to show. */
4251 if (strncmp (argv[0], "r", 1) == 0)
4252 type = OSPF_ROUTER_LSA;
4253 else if (strncmp (argv[0], "ne", 2) == 0)
4254 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004255 else if (strncmp (argv[0], "ns", 2) == 0)
4256 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004257 else if (strncmp (argv[0], "s", 1) == 0)
4258 type = OSPF_SUMMARY_LSA;
4259 else if (strncmp (argv[0], "a", 1) == 0)
4260 type = OSPF_ASBR_SUMMARY_LSA;
4261 else if (strncmp (argv[0], "e", 1) == 0)
4262 type = OSPF_AS_EXTERNAL_LSA;
4263#ifdef HAVE_OPAQUE_LSA
4264 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4265 type = OSPF_OPAQUE_LINK_LSA;
4266 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4267 type = OSPF_OPAQUE_AREA_LSA;
4268 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4269 type = OSPF_OPAQUE_AS_LSA;
4270#endif /* HAVE_OPAQUE_LSA */
4271 else
4272 return CMD_WARNING;
4273
4274 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4275 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004276 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004277 else
4278 {
4279 ret = inet_aton (argv[1], &adv_router);
4280 if (!ret)
4281 return CMD_WARNING;
4282 }
4283
paul020709f2003-04-04 02:44:16 +00004284 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004285
4286 return CMD_SUCCESS;
4287}
4288
4289ALIAS (show_ip_ospf_database_type_adv_router,
4290 show_ip_ospf_database_type_self_cmd,
4291 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4292 SHOW_STR
4293 IP_STR
4294 "OSPF information\n"
4295 "Database summary\n"
4296 OSPF_LSA_TYPES_DESC
4297 "Self-originated link states\n")
4298
4299
4300DEFUN (ip_ospf_authentication_args,
4301 ip_ospf_authentication_args_addr_cmd,
4302 "ip ospf authentication (null|message-digest) A.B.C.D",
4303 "IP Information\n"
4304 "OSPF interface commands\n"
4305 "Enable authentication on this interface\n"
4306 "Use null authentication\n"
4307 "Use message-digest authentication\n"
4308 "Address of interface")
4309{
4310 struct interface *ifp;
4311 struct in_addr addr;
4312 int ret;
4313 struct ospf_if_params *params;
4314
4315 ifp = vty->index;
4316 params = IF_DEF_PARAMS (ifp);
4317
4318 if (argc == 2)
4319 {
4320 ret = inet_aton(argv[1], &addr);
4321 if (!ret)
4322 {
4323 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4324 VTY_NEWLINE);
4325 return CMD_WARNING;
4326 }
4327
4328 params = ospf_get_if_params (ifp, addr);
4329 ospf_if_update_params (ifp, addr);
4330 }
4331
4332 /* Handle null authentication */
4333 if ( argv[0][0] == 'n' )
4334 {
4335 SET_IF_PARAM (params, auth_type);
4336 params->auth_type = OSPF_AUTH_NULL;
4337 return CMD_SUCCESS;
4338 }
4339
4340 /* Handle message-digest authentication */
4341 if ( argv[0][0] == 'm' )
4342 {
4343 SET_IF_PARAM (params, auth_type);
4344 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4345 return CMD_SUCCESS;
4346 }
4347
4348 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4349 return CMD_WARNING;
4350}
4351
4352ALIAS (ip_ospf_authentication_args,
4353 ip_ospf_authentication_args_cmd,
4354 "ip ospf authentication (null|message-digest)",
4355 "IP Information\n"
4356 "OSPF interface commands\n"
4357 "Enable authentication on this interface\n"
4358 "Use null authentication\n"
4359 "Use message-digest authentication\n")
4360
4361DEFUN (ip_ospf_authentication,
4362 ip_ospf_authentication_addr_cmd,
4363 "ip ospf authentication A.B.C.D",
4364 "IP Information\n"
4365 "OSPF interface commands\n"
4366 "Enable authentication on this interface\n"
4367 "Address of interface")
4368{
4369 struct interface *ifp;
4370 struct in_addr addr;
4371 int ret;
4372 struct ospf_if_params *params;
4373
4374 ifp = vty->index;
4375 params = IF_DEF_PARAMS (ifp);
4376
4377 if (argc == 1)
4378 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004379 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004380 if (!ret)
4381 {
4382 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4383 VTY_NEWLINE);
4384 return CMD_WARNING;
4385 }
4386
4387 params = ospf_get_if_params (ifp, addr);
4388 ospf_if_update_params (ifp, addr);
4389 }
4390
4391 SET_IF_PARAM (params, auth_type);
4392 params->auth_type = OSPF_AUTH_SIMPLE;
4393
4394 return CMD_SUCCESS;
4395}
4396
4397ALIAS (ip_ospf_authentication,
4398 ip_ospf_authentication_cmd,
4399 "ip ospf authentication",
4400 "IP Information\n"
4401 "OSPF interface commands\n"
4402 "Enable authentication on this interface\n")
4403
4404DEFUN (no_ip_ospf_authentication,
4405 no_ip_ospf_authentication_addr_cmd,
4406 "no ip ospf authentication A.B.C.D",
4407 NO_STR
4408 "IP Information\n"
4409 "OSPF interface commands\n"
4410 "Enable authentication on this interface\n"
4411 "Address of interface")
4412{
4413 struct interface *ifp;
4414 struct in_addr addr;
4415 int ret;
4416 struct ospf_if_params *params;
4417
4418 ifp = vty->index;
4419 params = IF_DEF_PARAMS (ifp);
4420
4421 if (argc == 1)
4422 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004423 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004424 if (!ret)
4425 {
4426 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4427 VTY_NEWLINE);
4428 return CMD_WARNING;
4429 }
4430
4431 params = ospf_lookup_if_params (ifp, addr);
4432 if (params == NULL)
4433 return CMD_SUCCESS;
4434 }
4435
4436 params->auth_type = OSPF_AUTH_NOTSET;
4437 UNSET_IF_PARAM (params, auth_type);
4438
4439 if (params != IF_DEF_PARAMS (ifp))
4440 {
4441 ospf_free_if_params (ifp, addr);
4442 ospf_if_update_params (ifp, addr);
4443 }
4444
4445 return CMD_SUCCESS;
4446}
4447
4448ALIAS (no_ip_ospf_authentication,
4449 no_ip_ospf_authentication_cmd,
4450 "no ip ospf authentication",
4451 NO_STR
4452 "IP Information\n"
4453 "OSPF interface commands\n"
4454 "Enable authentication on this interface\n")
4455
4456DEFUN (ip_ospf_authentication_key,
4457 ip_ospf_authentication_key_addr_cmd,
4458 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4459 "IP Information\n"
4460 "OSPF interface commands\n"
4461 "Authentication password (key)\n"
4462 "The OSPF password (key)\n"
4463 "Address of interface")
4464{
4465 struct interface *ifp;
4466 struct in_addr addr;
4467 int ret;
4468 struct ospf_if_params *params;
4469
4470 ifp = vty->index;
4471 params = IF_DEF_PARAMS (ifp);
4472
4473 if (argc == 2)
4474 {
4475 ret = inet_aton(argv[1], &addr);
4476 if (!ret)
4477 {
4478 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4479 VTY_NEWLINE);
4480 return CMD_WARNING;
4481 }
4482
4483 params = ospf_get_if_params (ifp, addr);
4484 ospf_if_update_params (ifp, addr);
4485 }
4486
4487
4488 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004489 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004490 SET_IF_PARAM (params, auth_simple);
4491
4492 return CMD_SUCCESS;
4493}
4494
4495ALIAS (ip_ospf_authentication_key,
4496 ip_ospf_authentication_key_cmd,
4497 "ip ospf authentication-key AUTH_KEY",
4498 "IP Information\n"
4499 "OSPF interface commands\n"
4500 "Authentication password (key)\n"
4501 "The OSPF password (key)")
4502
4503ALIAS (ip_ospf_authentication_key,
4504 ospf_authentication_key_cmd,
4505 "ospf authentication-key AUTH_KEY",
4506 "OSPF interface commands\n"
4507 "Authentication password (key)\n"
4508 "The OSPF password (key)")
4509
4510DEFUN (no_ip_ospf_authentication_key,
4511 no_ip_ospf_authentication_key_addr_cmd,
4512 "no ip ospf authentication-key A.B.C.D",
4513 NO_STR
4514 "IP Information\n"
4515 "OSPF interface commands\n"
4516 "Authentication password (key)\n"
4517 "Address of interface")
4518{
4519 struct interface *ifp;
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
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004527 if (argc == 1)
paul718e3742002-12-13 20:15:29 +00004528 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004529 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004530 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 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4543 UNSET_IF_PARAM (params, auth_simple);
4544
4545 if (params != IF_DEF_PARAMS (ifp))
4546 {
4547 ospf_free_if_params (ifp, addr);
4548 ospf_if_update_params (ifp, addr);
4549 }
4550
4551 return CMD_SUCCESS;
4552}
4553
4554ALIAS (no_ip_ospf_authentication_key,
4555 no_ip_ospf_authentication_key_cmd,
4556 "no ip ospf authentication-key",
4557 NO_STR
4558 "IP Information\n"
4559 "OSPF interface commands\n"
4560 "Authentication password (key)\n")
4561
4562ALIAS (no_ip_ospf_authentication_key,
4563 no_ospf_authentication_key_cmd,
4564 "no ospf authentication-key",
4565 NO_STR
4566 "OSPF interface commands\n"
4567 "Authentication password (key)\n")
4568
4569DEFUN (ip_ospf_message_digest_key,
4570 ip_ospf_message_digest_key_addr_cmd,
4571 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4572 "IP Information\n"
4573 "OSPF interface commands\n"
4574 "Message digest authentication password (key)\n"
4575 "Key ID\n"
4576 "Use MD5 algorithm\n"
4577 "The OSPF password (key)"
4578 "Address of interface")
4579{
4580 struct interface *ifp;
4581 struct crypt_key *ck;
4582 u_char key_id;
4583 struct in_addr addr;
4584 int ret;
4585 struct ospf_if_params *params;
4586
4587 ifp = vty->index;
4588 params = IF_DEF_PARAMS (ifp);
4589
4590 if (argc == 3)
4591 {
4592 ret = inet_aton(argv[2], &addr);
4593 if (!ret)
4594 {
4595 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4596 VTY_NEWLINE);
4597 return CMD_WARNING;
4598 }
4599
4600 params = ospf_get_if_params (ifp, addr);
4601 ospf_if_update_params (ifp, addr);
4602 }
4603
4604 key_id = strtol (argv[0], NULL, 10);
4605 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4606 {
4607 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4608 return CMD_WARNING;
4609 }
4610
4611 ck = ospf_crypt_key_new ();
4612 ck->key_id = (u_char) key_id;
4613 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004614 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004615
4616 ospf_crypt_key_add (params->auth_crypt, ck);
4617 SET_IF_PARAM (params, auth_crypt);
4618
4619 return CMD_SUCCESS;
4620}
4621
4622ALIAS (ip_ospf_message_digest_key,
4623 ip_ospf_message_digest_key_cmd,
4624 "ip ospf message-digest-key <1-255> md5 KEY",
4625 "IP Information\n"
4626 "OSPF interface commands\n"
4627 "Message digest authentication password (key)\n"
4628 "Key ID\n"
4629 "Use MD5 algorithm\n"
4630 "The OSPF password (key)")
4631
4632ALIAS (ip_ospf_message_digest_key,
4633 ospf_message_digest_key_cmd,
4634 "ospf message-digest-key <1-255> md5 KEY",
4635 "OSPF interface commands\n"
4636 "Message digest authentication password (key)\n"
4637 "Key ID\n"
4638 "Use MD5 algorithm\n"
4639 "The OSPF password (key)")
4640
4641DEFUN (no_ip_ospf_message_digest_key,
4642 no_ip_ospf_message_digest_key_addr_cmd,
4643 "no ip ospf message-digest-key <1-255> A.B.C.D",
4644 NO_STR
4645 "IP Information\n"
4646 "OSPF interface commands\n"
4647 "Message digest authentication password (key)\n"
4648 "Key ID\n"
4649 "Address of interface")
4650{
4651 struct interface *ifp;
4652 struct crypt_key *ck;
4653 int key_id;
4654 struct in_addr addr;
4655 int ret;
4656 struct ospf_if_params *params;
4657
4658 ifp = vty->index;
4659 params = IF_DEF_PARAMS (ifp);
4660
4661 if (argc == 2)
4662 {
4663 ret = inet_aton(argv[1], &addr);
4664 if (!ret)
4665 {
4666 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4667 VTY_NEWLINE);
4668 return CMD_WARNING;
4669 }
4670
4671 params = ospf_lookup_if_params (ifp, addr);
4672 if (params == NULL)
4673 return CMD_SUCCESS;
4674 }
4675
4676 key_id = strtol (argv[0], NULL, 10);
4677 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4678 if (ck == NULL)
4679 {
4680 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4681 return CMD_WARNING;
4682 }
4683
4684 ospf_crypt_key_delete (params->auth_crypt, key_id);
4685
4686 if (params != IF_DEF_PARAMS (ifp))
4687 {
4688 ospf_free_if_params (ifp, addr);
4689 ospf_if_update_params (ifp, addr);
4690 }
4691
4692 return CMD_SUCCESS;
4693}
4694
4695ALIAS (no_ip_ospf_message_digest_key,
4696 no_ip_ospf_message_digest_key_cmd,
4697 "no ip ospf message-digest-key <1-255>",
4698 NO_STR
4699 "IP Information\n"
4700 "OSPF interface commands\n"
4701 "Message digest authentication password (key)\n"
4702 "Key ID\n")
4703
4704ALIAS (no_ip_ospf_message_digest_key,
4705 no_ospf_message_digest_key_cmd,
4706 "no ospf message-digest-key <1-255>",
4707 NO_STR
4708 "OSPF interface commands\n"
4709 "Message digest authentication password (key)\n"
4710 "Key ID\n")
4711
4712DEFUN (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004713 ip_ospf_cost_u32_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004714 "ip ospf cost <1-65535> A.B.C.D",
4715 "IP Information\n"
4716 "OSPF interface commands\n"
4717 "Interface cost\n"
4718 "Cost\n"
4719 "Address of interface")
4720{
4721 struct interface *ifp = vty->index;
4722 u_int32_t cost;
4723 struct in_addr addr;
4724 int ret;
4725 struct ospf_if_params *params;
4726
4727 params = IF_DEF_PARAMS (ifp);
4728
4729 cost = strtol (argv[0], NULL, 10);
4730
4731 /* cost range is <1-65535>. */
4732 if (cost < 1 || cost > 65535)
4733 {
4734 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4735 return CMD_WARNING;
4736 }
4737
4738 if (argc == 2)
4739 {
4740 ret = inet_aton(argv[1], &addr);
4741 if (!ret)
4742 {
4743 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4744 VTY_NEWLINE);
4745 return CMD_WARNING;
4746 }
4747
4748 params = ospf_get_if_params (ifp, addr);
4749 ospf_if_update_params (ifp, addr);
4750 }
4751
4752 SET_IF_PARAM (params, output_cost_cmd);
4753 params->output_cost_cmd = cost;
4754
4755 ospf_if_recalculate_output_cost (ifp);
4756
4757 return CMD_SUCCESS;
4758}
4759
4760ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004761 ip_ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004762 "ip ospf cost <1-65535>",
4763 "IP Information\n"
4764 "OSPF interface commands\n"
4765 "Interface cost\n"
4766 "Cost")
4767
4768ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004769 ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004770 "ospf cost <1-65535>",
4771 "OSPF interface commands\n"
4772 "Interface cost\n"
4773 "Cost")
4774
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004775ALIAS (ip_ospf_cost,
4776 ospf_cost_u32_inet4_cmd,
4777 "ospf cost <1-65535> A.B.C.D",
4778 "OSPF interface commands\n"
4779 "Interface cost\n"
4780 "Cost\n"
4781 "Address of interface")
4782
paul718e3742002-12-13 20:15:29 +00004783DEFUN (no_ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004784 no_ip_ospf_cost_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004785 "no ip ospf cost A.B.C.D",
4786 NO_STR
4787 "IP Information\n"
4788 "OSPF interface commands\n"
4789 "Interface cost\n"
4790 "Address of interface")
4791{
4792 struct interface *ifp = vty->index;
4793 struct in_addr addr;
4794 int ret;
4795 struct ospf_if_params *params;
4796
4797 ifp = vty->index;
4798 params = IF_DEF_PARAMS (ifp);
4799
4800 if (argc == 1)
4801 {
4802 ret = inet_aton(argv[0], &addr);
4803 if (!ret)
4804 {
4805 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4806 VTY_NEWLINE);
4807 return CMD_WARNING;
4808 }
4809
4810 params = ospf_lookup_if_params (ifp, addr);
4811 if (params == NULL)
4812 return CMD_SUCCESS;
4813 }
4814
4815 UNSET_IF_PARAM (params, output_cost_cmd);
4816
4817 if (params != IF_DEF_PARAMS (ifp))
4818 {
4819 ospf_free_if_params (ifp, addr);
4820 ospf_if_update_params (ifp, addr);
4821 }
4822
4823 ospf_if_recalculate_output_cost (ifp);
4824
4825 return CMD_SUCCESS;
4826}
4827
4828ALIAS (no_ip_ospf_cost,
4829 no_ip_ospf_cost_cmd,
4830 "no ip ospf cost",
4831 NO_STR
4832 "IP Information\n"
4833 "OSPF interface commands\n"
4834 "Interface cost\n")
4835
4836ALIAS (no_ip_ospf_cost,
4837 no_ospf_cost_cmd,
4838 "no ospf cost",
4839 NO_STR
4840 "OSPF interface commands\n"
4841 "Interface cost\n")
4842
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004843ALIAS (no_ip_ospf_cost,
4844 no_ospf_cost_inet4_cmd,
4845 "no ospf cost A.B.C.D",
4846 NO_STR
4847 "OSPF interface commands\n"
4848 "Interface cost\n"
4849 "Address of interface")
4850
Denis Ovsienko827341b2009-09-28 19:34:59 +04004851DEFUN (no_ip_ospf_cost2,
4852 no_ip_ospf_cost_u32_cmd,
4853 "no ip ospf cost <1-65535>",
4854 NO_STR
4855 "IP Information\n"
4856 "OSPF interface commands\n"
4857 "Interface cost\n"
4858 "Cost")
4859{
4860 struct interface *ifp = vty->index;
4861 struct in_addr addr;
4862 u_int32_t cost;
4863 int ret;
4864 struct ospf_if_params *params;
4865
4866 ifp = vty->index;
4867 params = IF_DEF_PARAMS (ifp);
4868
4869 /* According to the semantics we are mimicking "no ip ospf cost N" is
4870 * always treated as "no ip ospf cost" regardless of the actual value
4871 * of N already configured for the interface. Thus the first argument
4872 * is always checked to be a number, but is ignored after that.
4873 */
4874 cost = strtol (argv[0], NULL, 10);
4875 if (cost < 1 || cost > 65535)
4876 {
4877 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4878 return CMD_WARNING;
4879 }
4880
4881 if (argc == 2)
4882 {
4883 ret = inet_aton(argv[1], &addr);
4884 if (!ret)
4885 {
4886 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4887 VTY_NEWLINE);
4888 return CMD_WARNING;
4889 }
4890
4891 params = ospf_lookup_if_params (ifp, addr);
4892 if (params == NULL)
4893 return CMD_SUCCESS;
4894 }
4895
4896 UNSET_IF_PARAM (params, output_cost_cmd);
4897
4898 if (params != IF_DEF_PARAMS (ifp))
4899 {
4900 ospf_free_if_params (ifp, addr);
4901 ospf_if_update_params (ifp, addr);
4902 }
4903
4904 ospf_if_recalculate_output_cost (ifp);
4905
4906 return CMD_SUCCESS;
4907}
4908
4909ALIAS (no_ip_ospf_cost2,
4910 no_ospf_cost_u32_cmd,
4911 "no ospf cost <1-65535>",
4912 NO_STR
4913 "OSPF interface commands\n"
4914 "Interface cost\n"
4915 "Cost")
4916
4917ALIAS (no_ip_ospf_cost2,
4918 no_ip_ospf_cost_u32_inet4_cmd,
4919 "no ip ospf cost <1-65535> A.B.C.D",
4920 NO_STR
4921 "IP Information\n"
4922 "OSPF interface commands\n"
4923 "Interface cost\n"
4924 "Cost\n"
4925 "Address of interface")
4926
4927ALIAS (no_ip_ospf_cost2,
4928 no_ospf_cost_u32_inet4_cmd,
4929 "no ospf cost <1-65535> A.B.C.D",
4930 NO_STR
4931 "OSPF interface commands\n"
4932 "Interface cost\n"
4933 "Cost\n"
4934 "Address of interface")
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004935
paul4dadc292005-05-06 21:37:42 +00004936static void
paul718e3742002-12-13 20:15:29 +00004937ospf_nbr_timer_update (struct ospf_interface *oi)
4938{
4939 struct route_node *rn;
4940 struct ospf_neighbor *nbr;
4941
4942 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4943 if ((nbr = rn->info))
4944 {
4945 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4946 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4947 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4948 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4949 }
4950}
4951
paulf9ad9372005-10-21 00:45:17 +00004952static int
4953ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4954 const char *nbr_str,
4955 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004956{
4957 struct interface *ifp = vty->index;
4958 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004959 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004960 struct in_addr addr;
4961 int ret;
4962 struct ospf_if_params *params;
4963 struct ospf_interface *oi;
4964 struct route_node *rn;
4965
4966 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004967
4968 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004969 {
paulf9ad9372005-10-21 00:45:17 +00004970 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004971 if (!ret)
4972 {
4973 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4974 VTY_NEWLINE);
4975 return CMD_WARNING;
4976 }
4977
4978 params = ospf_get_if_params (ifp, addr);
4979 ospf_if_update_params (ifp, addr);
4980 }
4981
paulf9ad9372005-10-21 00:45:17 +00004982 if (interval_str)
4983 {
4984 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4985 1, 65535);
4986
4987 /* reset fast_hello too, just to be sure */
4988 UNSET_IF_PARAM (params, fast_hello);
4989 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4990 }
4991 else if (fast_hello_str)
4992 {
4993 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4994 1, 10);
4995 /* 1s dead-interval with sub-second hellos desired */
4996 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4997 SET_IF_PARAM (params, fast_hello);
4998 params->fast_hello = hellomult;
4999 }
5000 else
5001 {
5002 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5003 VTY_NEWLINE);
5004 return CMD_WARNING;
5005 }
5006
paul718e3742002-12-13 20:15:29 +00005007 SET_IF_PARAM (params, v_wait);
5008 params->v_wait = seconds;
5009
5010 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00005011 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005012 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005013 struct ospf *ospf;
5014 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005015 {
5016 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5017 if (oi)
5018 ospf_nbr_timer_update (oi);
5019 }
paul718e3742002-12-13 20:15:29 +00005020 }
5021 else
5022 {
5023 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5024 if ((oi = rn->info))
5025 ospf_nbr_timer_update (oi);
5026 }
5027
5028 return CMD_SUCCESS;
5029}
5030
paulf9ad9372005-10-21 00:45:17 +00005031
5032DEFUN (ip_ospf_dead_interval,
5033 ip_ospf_dead_interval_addr_cmd,
5034 "ip ospf dead-interval <1-65535> A.B.C.D",
5035 "IP Information\n"
5036 "OSPF interface commands\n"
5037 "Interval after which a neighbor is declared dead\n"
5038 "Seconds\n"
5039 "Address of interface\n")
5040{
5041 if (argc == 2)
5042 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5043 else
5044 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5045}
5046
paul718e3742002-12-13 20:15:29 +00005047ALIAS (ip_ospf_dead_interval,
5048 ip_ospf_dead_interval_cmd,
5049 "ip ospf dead-interval <1-65535>",
5050 "IP Information\n"
5051 "OSPF interface commands\n"
5052 "Interval after which a neighbor is declared dead\n"
5053 "Seconds\n")
5054
5055ALIAS (ip_ospf_dead_interval,
5056 ospf_dead_interval_cmd,
5057 "ospf dead-interval <1-65535>",
5058 "OSPF interface commands\n"
5059 "Interval after which a neighbor is declared dead\n"
5060 "Seconds\n")
5061
paulf9ad9372005-10-21 00:45:17 +00005062DEFUN (ip_ospf_dead_interval_minimal,
5063 ip_ospf_dead_interval_minimal_addr_cmd,
5064 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5065 "IP Information\n"
5066 "OSPF interface commands\n"
5067 "Interval after which a neighbor is declared dead\n"
5068 "Minimal 1s dead-interval with fast sub-second hellos\n"
5069 "Hello multiplier factor\n"
5070 "Number of Hellos to send each second\n"
5071 "Address of interface\n")
5072{
5073 if (argc == 2)
5074 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5075 else
5076 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5077}
5078
5079ALIAS (ip_ospf_dead_interval_minimal,
5080 ip_ospf_dead_interval_minimal_cmd,
5081 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5082 "IP Information\n"
5083 "OSPF interface commands\n"
5084 "Interval after which a neighbor is declared dead\n"
5085 "Minimal 1s dead-interval with fast sub-second hellos\n"
5086 "Hello multiplier factor\n"
5087 "Number of Hellos to send each second\n")
5088
paul718e3742002-12-13 20:15:29 +00005089DEFUN (no_ip_ospf_dead_interval,
5090 no_ip_ospf_dead_interval_addr_cmd,
5091 "no ip ospf dead-interval A.B.C.D",
5092 NO_STR
5093 "IP Information\n"
5094 "OSPF interface commands\n"
5095 "Interval after which a neighbor is declared dead\n"
5096 "Address of interface")
5097{
5098 struct interface *ifp = vty->index;
5099 struct in_addr addr;
5100 int ret;
5101 struct ospf_if_params *params;
5102 struct ospf_interface *oi;
5103 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00005104
paul718e3742002-12-13 20:15:29 +00005105 ifp = vty->index;
5106 params = IF_DEF_PARAMS (ifp);
5107
5108 if (argc == 1)
5109 {
5110 ret = inet_aton(argv[0], &addr);
5111 if (!ret)
5112 {
5113 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5114 VTY_NEWLINE);
5115 return CMD_WARNING;
5116 }
5117
5118 params = ospf_lookup_if_params (ifp, addr);
5119 if (params == NULL)
5120 return CMD_SUCCESS;
5121 }
5122
5123 UNSET_IF_PARAM (params, v_wait);
5124 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00005125
5126 UNSET_IF_PARAM (params, fast_hello);
5127 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5128
paul718e3742002-12-13 20:15:29 +00005129 if (params != IF_DEF_PARAMS (ifp))
5130 {
5131 ospf_free_if_params (ifp, addr);
5132 ospf_if_update_params (ifp, addr);
5133 }
5134
5135 /* Update timer values in neighbor structure. */
5136 if (argc == 1)
5137 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005138 struct ospf *ospf;
5139
5140 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005141 {
5142 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5143 if (oi)
5144 ospf_nbr_timer_update (oi);
5145 }
paul718e3742002-12-13 20:15:29 +00005146 }
5147 else
5148 {
5149 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5150 if ((oi = rn->info))
5151 ospf_nbr_timer_update (oi);
5152 }
5153
5154 return CMD_SUCCESS;
5155}
5156
5157ALIAS (no_ip_ospf_dead_interval,
5158 no_ip_ospf_dead_interval_cmd,
5159 "no ip ospf dead-interval",
5160 NO_STR
5161 "IP Information\n"
5162 "OSPF interface commands\n"
5163 "Interval after which a neighbor is declared dead\n")
5164
5165ALIAS (no_ip_ospf_dead_interval,
5166 no_ospf_dead_interval_cmd,
5167 "no ospf dead-interval",
5168 NO_STR
5169 "OSPF interface commands\n"
5170 "Interval after which a neighbor is declared dead\n")
5171
5172DEFUN (ip_ospf_hello_interval,
5173 ip_ospf_hello_interval_addr_cmd,
5174 "ip ospf hello-interval <1-65535> A.B.C.D",
5175 "IP Information\n"
5176 "OSPF interface commands\n"
5177 "Time between HELLO packets\n"
5178 "Seconds\n"
5179 "Address of interface")
5180{
5181 struct interface *ifp = vty->index;
5182 u_int32_t seconds;
5183 struct in_addr addr;
5184 int ret;
5185 struct ospf_if_params *params;
5186
5187 params = IF_DEF_PARAMS (ifp);
5188
5189 seconds = strtol (argv[0], NULL, 10);
5190
5191 /* HelloInterval range is <1-65535>. */
5192 if (seconds < 1 || seconds > 65535)
5193 {
5194 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5195 return CMD_WARNING;
5196 }
5197
5198 if (argc == 2)
5199 {
5200 ret = inet_aton(argv[1], &addr);
5201 if (!ret)
5202 {
5203 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5204 VTY_NEWLINE);
5205 return CMD_WARNING;
5206 }
5207
5208 params = ospf_get_if_params (ifp, addr);
5209 ospf_if_update_params (ifp, addr);
5210 }
5211
paulf9ad9372005-10-21 00:45:17 +00005212 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005213 params->v_hello = seconds;
5214
5215 return CMD_SUCCESS;
5216}
5217
5218ALIAS (ip_ospf_hello_interval,
5219 ip_ospf_hello_interval_cmd,
5220 "ip ospf hello-interval <1-65535>",
5221 "IP Information\n"
5222 "OSPF interface commands\n"
5223 "Time between HELLO packets\n"
5224 "Seconds\n")
5225
5226ALIAS (ip_ospf_hello_interval,
5227 ospf_hello_interval_cmd,
5228 "ospf hello-interval <1-65535>",
5229 "OSPF interface commands\n"
5230 "Time between HELLO packets\n"
5231 "Seconds\n")
5232
5233DEFUN (no_ip_ospf_hello_interval,
5234 no_ip_ospf_hello_interval_addr_cmd,
5235 "no ip ospf hello-interval A.B.C.D",
5236 NO_STR
5237 "IP Information\n"
5238 "OSPF interface commands\n"
5239 "Time between HELLO packets\n"
5240 "Address of interface")
5241{
5242 struct interface *ifp = vty->index;
5243 struct in_addr addr;
5244 int ret;
5245 struct ospf_if_params *params;
5246
5247 ifp = vty->index;
5248 params = IF_DEF_PARAMS (ifp);
5249
5250 if (argc == 1)
5251 {
5252 ret = inet_aton(argv[0], &addr);
5253 if (!ret)
5254 {
5255 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5256 VTY_NEWLINE);
5257 return CMD_WARNING;
5258 }
5259
5260 params = ospf_lookup_if_params (ifp, addr);
5261 if (params == NULL)
5262 return CMD_SUCCESS;
5263 }
5264
5265 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005266 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005267
5268 if (params != IF_DEF_PARAMS (ifp))
5269 {
5270 ospf_free_if_params (ifp, addr);
5271 ospf_if_update_params (ifp, addr);
5272 }
5273
5274 return CMD_SUCCESS;
5275}
5276
5277ALIAS (no_ip_ospf_hello_interval,
5278 no_ip_ospf_hello_interval_cmd,
5279 "no ip ospf hello-interval",
5280 NO_STR
5281 "IP Information\n"
5282 "OSPF interface commands\n"
5283 "Time between HELLO packets\n")
5284
5285ALIAS (no_ip_ospf_hello_interval,
5286 no_ospf_hello_interval_cmd,
5287 "no ospf hello-interval",
5288 NO_STR
5289 "OSPF interface commands\n"
5290 "Time between HELLO packets\n")
5291
5292DEFUN (ip_ospf_network,
5293 ip_ospf_network_cmd,
5294 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5295 "IP Information\n"
5296 "OSPF interface commands\n"
5297 "Network type\n"
5298 "Specify OSPF broadcast multi-access network\n"
5299 "Specify OSPF NBMA network\n"
5300 "Specify OSPF point-to-multipoint network\n"
5301 "Specify OSPF point-to-point network\n")
5302{
5303 struct interface *ifp = vty->index;
5304 int old_type = IF_DEF_PARAMS (ifp)->type;
5305 struct route_node *rn;
5306
5307 if (strncmp (argv[0], "b", 1) == 0)
5308 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5309 else if (strncmp (argv[0], "n", 1) == 0)
5310 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5311 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5312 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5313 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5314 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5315
5316 if (IF_DEF_PARAMS (ifp)->type == old_type)
5317 return CMD_SUCCESS;
5318
5319 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5320
5321 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5322 {
5323 struct ospf_interface *oi = rn->info;
5324
5325 if (!oi)
5326 continue;
5327
5328 oi->type = IF_DEF_PARAMS (ifp)->type;
5329
5330 if (oi->state > ISM_Down)
5331 {
5332 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5333 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5334 }
5335 }
5336
5337 return CMD_SUCCESS;
5338}
5339
5340ALIAS (ip_ospf_network,
5341 ospf_network_cmd,
5342 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5343 "OSPF interface commands\n"
5344 "Network type\n"
5345 "Specify OSPF broadcast multi-access network\n"
5346 "Specify OSPF NBMA network\n"
5347 "Specify OSPF point-to-multipoint network\n"
5348 "Specify OSPF point-to-point network\n")
5349
5350DEFUN (no_ip_ospf_network,
5351 no_ip_ospf_network_cmd,
5352 "no ip ospf network",
5353 NO_STR
5354 "IP Information\n"
5355 "OSPF interface commands\n"
5356 "Network type\n")
5357{
5358 struct interface *ifp = vty->index;
5359 int old_type = IF_DEF_PARAMS (ifp)->type;
5360 struct route_node *rn;
5361
ajsbc18d612004-12-15 15:07:19 +00005362 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005363
5364 if (IF_DEF_PARAMS (ifp)->type == old_type)
5365 return CMD_SUCCESS;
5366
5367 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5368 {
5369 struct ospf_interface *oi = rn->info;
5370
5371 if (!oi)
5372 continue;
5373
5374 oi->type = IF_DEF_PARAMS (ifp)->type;
5375
5376 if (oi->state > ISM_Down)
5377 {
5378 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5379 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5380 }
5381 }
5382
5383 return CMD_SUCCESS;
5384}
5385
5386ALIAS (no_ip_ospf_network,
5387 no_ospf_network_cmd,
5388 "no ospf network",
5389 NO_STR
5390 "OSPF interface commands\n"
5391 "Network type\n")
5392
5393DEFUN (ip_ospf_priority,
5394 ip_ospf_priority_addr_cmd,
5395 "ip ospf priority <0-255> A.B.C.D",
5396 "IP Information\n"
5397 "OSPF interface commands\n"
5398 "Router priority\n"
5399 "Priority\n"
5400 "Address of interface")
5401{
5402 struct interface *ifp = vty->index;
5403 u_int32_t priority;
5404 struct route_node *rn;
5405 struct in_addr addr;
5406 int ret;
5407 struct ospf_if_params *params;
5408
5409 params = IF_DEF_PARAMS (ifp);
5410
5411 priority = strtol (argv[0], NULL, 10);
5412
5413 /* Router Priority range is <0-255>. */
5414 if (priority < 0 || priority > 255)
5415 {
5416 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5417 return CMD_WARNING;
5418 }
5419
5420 if (argc == 2)
5421 {
5422 ret = inet_aton(argv[1], &addr);
5423 if (!ret)
5424 {
5425 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5426 VTY_NEWLINE);
5427 return CMD_WARNING;
5428 }
5429
5430 params = ospf_get_if_params (ifp, addr);
5431 ospf_if_update_params (ifp, addr);
5432 }
5433
5434 SET_IF_PARAM (params, priority);
5435 params->priority = priority;
5436
5437 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5438 {
5439 struct ospf_interface *oi = rn->info;
5440
5441 if (!oi)
5442 continue;
5443
5444
5445 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5446 {
5447 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5448 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5449 }
5450 }
5451
5452 return CMD_SUCCESS;
5453}
5454
5455ALIAS (ip_ospf_priority,
5456 ip_ospf_priority_cmd,
5457 "ip ospf priority <0-255>",
5458 "IP Information\n"
5459 "OSPF interface commands\n"
5460 "Router priority\n"
5461 "Priority\n")
5462
5463ALIAS (ip_ospf_priority,
5464 ospf_priority_cmd,
5465 "ospf priority <0-255>",
5466 "OSPF interface commands\n"
5467 "Router priority\n"
5468 "Priority\n")
5469
5470DEFUN (no_ip_ospf_priority,
5471 no_ip_ospf_priority_addr_cmd,
5472 "no ip ospf priority A.B.C.D",
5473 NO_STR
5474 "IP Information\n"
5475 "OSPF interface commands\n"
5476 "Router priority\n"
5477 "Address of interface")
5478{
5479 struct interface *ifp = vty->index;
5480 struct route_node *rn;
5481 struct in_addr addr;
5482 int ret;
5483 struct ospf_if_params *params;
5484
5485 ifp = vty->index;
5486 params = IF_DEF_PARAMS (ifp);
5487
5488 if (argc == 1)
5489 {
5490 ret = inet_aton(argv[0], &addr);
5491 if (!ret)
5492 {
5493 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5494 VTY_NEWLINE);
5495 return CMD_WARNING;
5496 }
5497
5498 params = ospf_lookup_if_params (ifp, addr);
5499 if (params == NULL)
5500 return CMD_SUCCESS;
5501 }
5502
5503 UNSET_IF_PARAM (params, priority);
5504 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5505
5506 if (params != IF_DEF_PARAMS (ifp))
5507 {
5508 ospf_free_if_params (ifp, addr);
5509 ospf_if_update_params (ifp, addr);
5510 }
5511
5512 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5513 {
5514 struct ospf_interface *oi = rn->info;
5515
5516 if (!oi)
5517 continue;
5518
5519
5520 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5521 {
5522 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5523 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5524 }
5525 }
5526
5527 return CMD_SUCCESS;
5528}
5529
5530ALIAS (no_ip_ospf_priority,
5531 no_ip_ospf_priority_cmd,
5532 "no ip ospf priority",
5533 NO_STR
5534 "IP Information\n"
5535 "OSPF interface commands\n"
5536 "Router priority\n")
5537
5538ALIAS (no_ip_ospf_priority,
5539 no_ospf_priority_cmd,
5540 "no ospf priority",
5541 NO_STR
5542 "OSPF interface commands\n"
5543 "Router priority\n")
5544
5545DEFUN (ip_ospf_retransmit_interval,
5546 ip_ospf_retransmit_interval_addr_cmd,
5547 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5548 "IP Information\n"
5549 "OSPF interface commands\n"
5550 "Time between retransmitting lost link state advertisements\n"
5551 "Seconds\n"
5552 "Address of interface")
5553{
5554 struct interface *ifp = vty->index;
5555 u_int32_t seconds;
5556 struct in_addr addr;
5557 int ret;
5558 struct ospf_if_params *params;
5559
5560 params = IF_DEF_PARAMS (ifp);
5561 seconds = strtol (argv[0], NULL, 10);
5562
5563 /* Retransmit Interval range is <3-65535>. */
5564 if (seconds < 3 || seconds > 65535)
5565 {
5566 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5567 return CMD_WARNING;
5568 }
5569
5570
5571 if (argc == 2)
5572 {
5573 ret = inet_aton(argv[1], &addr);
5574 if (!ret)
5575 {
5576 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5577 VTY_NEWLINE);
5578 return CMD_WARNING;
5579 }
5580
5581 params = ospf_get_if_params (ifp, addr);
5582 ospf_if_update_params (ifp, addr);
5583 }
5584
5585 SET_IF_PARAM (params, retransmit_interval);
5586 params->retransmit_interval = seconds;
5587
5588 return CMD_SUCCESS;
5589}
5590
5591ALIAS (ip_ospf_retransmit_interval,
5592 ip_ospf_retransmit_interval_cmd,
5593 "ip ospf retransmit-interval <3-65535>",
5594 "IP Information\n"
5595 "OSPF interface commands\n"
5596 "Time between retransmitting lost link state advertisements\n"
5597 "Seconds\n")
5598
5599ALIAS (ip_ospf_retransmit_interval,
5600 ospf_retransmit_interval_cmd,
5601 "ospf retransmit-interval <3-65535>",
5602 "OSPF interface commands\n"
5603 "Time between retransmitting lost link state advertisements\n"
5604 "Seconds\n")
5605
5606DEFUN (no_ip_ospf_retransmit_interval,
5607 no_ip_ospf_retransmit_interval_addr_cmd,
5608 "no ip ospf retransmit-interval A.B.C.D",
5609 NO_STR
5610 "IP Information\n"
5611 "OSPF interface commands\n"
5612 "Time between retransmitting lost link state advertisements\n"
5613 "Address of interface")
5614{
5615 struct interface *ifp = vty->index;
5616 struct in_addr addr;
5617 int ret;
5618 struct ospf_if_params *params;
5619
5620 ifp = vty->index;
5621 params = IF_DEF_PARAMS (ifp);
5622
5623 if (argc == 1)
5624 {
5625 ret = inet_aton(argv[0], &addr);
5626 if (!ret)
5627 {
5628 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5629 VTY_NEWLINE);
5630 return CMD_WARNING;
5631 }
5632
5633 params = ospf_lookup_if_params (ifp, addr);
5634 if (params == NULL)
5635 return CMD_SUCCESS;
5636 }
5637
5638 UNSET_IF_PARAM (params, retransmit_interval);
5639 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5640
5641 if (params != IF_DEF_PARAMS (ifp))
5642 {
5643 ospf_free_if_params (ifp, addr);
5644 ospf_if_update_params (ifp, addr);
5645 }
5646
5647 return CMD_SUCCESS;
5648}
5649
5650ALIAS (no_ip_ospf_retransmit_interval,
5651 no_ip_ospf_retransmit_interval_cmd,
5652 "no ip ospf retransmit-interval",
5653 NO_STR
5654 "IP Information\n"
5655 "OSPF interface commands\n"
5656 "Time between retransmitting lost link state advertisements\n")
5657
5658ALIAS (no_ip_ospf_retransmit_interval,
5659 no_ospf_retransmit_interval_cmd,
5660 "no ospf retransmit-interval",
5661 NO_STR
5662 "OSPF interface commands\n"
5663 "Time between retransmitting lost link state advertisements\n")
5664
5665DEFUN (ip_ospf_transmit_delay,
5666 ip_ospf_transmit_delay_addr_cmd,
5667 "ip ospf transmit-delay <1-65535> A.B.C.D",
5668 "IP Information\n"
5669 "OSPF interface commands\n"
5670 "Link state transmit delay\n"
5671 "Seconds\n"
5672 "Address of interface")
5673{
5674 struct interface *ifp = vty->index;
5675 u_int32_t seconds;
5676 struct in_addr addr;
5677 int ret;
5678 struct ospf_if_params *params;
5679
5680 params = IF_DEF_PARAMS (ifp);
5681 seconds = strtol (argv[0], NULL, 10);
5682
5683 /* Transmit Delay range is <1-65535>. */
5684 if (seconds < 1 || seconds > 65535)
5685 {
5686 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5687 return CMD_WARNING;
5688 }
5689
5690 if (argc == 2)
5691 {
5692 ret = inet_aton(argv[1], &addr);
5693 if (!ret)
5694 {
5695 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5696 VTY_NEWLINE);
5697 return CMD_WARNING;
5698 }
5699
5700 params = ospf_get_if_params (ifp, addr);
5701 ospf_if_update_params (ifp, addr);
5702 }
5703
5704 SET_IF_PARAM (params, transmit_delay);
5705 params->transmit_delay = seconds;
5706
5707 return CMD_SUCCESS;
5708}
5709
5710ALIAS (ip_ospf_transmit_delay,
5711 ip_ospf_transmit_delay_cmd,
5712 "ip ospf transmit-delay <1-65535>",
5713 "IP Information\n"
5714 "OSPF interface commands\n"
5715 "Link state transmit delay\n"
5716 "Seconds\n")
5717
5718ALIAS (ip_ospf_transmit_delay,
5719 ospf_transmit_delay_cmd,
5720 "ospf transmit-delay <1-65535>",
5721 "OSPF interface commands\n"
5722 "Link state transmit delay\n"
5723 "Seconds\n")
5724
5725DEFUN (no_ip_ospf_transmit_delay,
5726 no_ip_ospf_transmit_delay_addr_cmd,
5727 "no ip ospf transmit-delay A.B.C.D",
5728 NO_STR
5729 "IP Information\n"
5730 "OSPF interface commands\n"
5731 "Link state transmit delay\n"
5732 "Address of interface")
5733{
5734 struct interface *ifp = vty->index;
5735 struct in_addr addr;
5736 int ret;
5737 struct ospf_if_params *params;
5738
5739 ifp = vty->index;
5740 params = IF_DEF_PARAMS (ifp);
5741
5742 if (argc == 1)
5743 {
5744 ret = inet_aton(argv[0], &addr);
5745 if (!ret)
5746 {
5747 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5748 VTY_NEWLINE);
5749 return CMD_WARNING;
5750 }
5751
5752 params = ospf_lookup_if_params (ifp, addr);
5753 if (params == NULL)
5754 return CMD_SUCCESS;
5755 }
5756
5757 UNSET_IF_PARAM (params, transmit_delay);
5758 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5759
5760 if (params != IF_DEF_PARAMS (ifp))
5761 {
5762 ospf_free_if_params (ifp, addr);
5763 ospf_if_update_params (ifp, addr);
5764 }
5765
5766 return CMD_SUCCESS;
5767}
5768
5769ALIAS (no_ip_ospf_transmit_delay,
5770 no_ip_ospf_transmit_delay_cmd,
5771 "no ip ospf transmit-delay",
5772 NO_STR
5773 "IP Information\n"
5774 "OSPF interface commands\n"
5775 "Link state transmit delay\n")
5776
5777ALIAS (no_ip_ospf_transmit_delay,
5778 no_ospf_transmit_delay_cmd,
5779 "no ospf transmit-delay",
5780 NO_STR
5781 "OSPF interface commands\n"
5782 "Link state transmit delay\n")
5783
5784
5785DEFUN (ospf_redistribute_source_metric_type,
5786 ospf_redistribute_source_metric_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005787 "redistribute " QUAGGA_REDIST_STR_OSPFD
5788 " metric <0-16777214> metric-type (1|2) route-map WORD",
5789 REDIST_STR
5790 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005791 "Metric for redistributed routes\n"
5792 "OSPF default metric\n"
5793 "OSPF exterior metric type for redistributed routes\n"
5794 "Set OSPF External Type 1 metrics\n"
5795 "Set OSPF External Type 2 metrics\n"
5796 "Route map reference\n"
5797 "Pointer to route-map entries\n")
5798{
paul020709f2003-04-04 02:44:16 +00005799 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005800 int source;
5801 int type = -1;
5802 int metric = -1;
5803
5804 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005805 source = proto_redistnum(AFI_IP, argv[0]);
5806 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005807 return CMD_WARNING;
5808
5809 /* Get metric value. */
5810 if (argc >= 2)
5811 if (!str2metric (argv[1], &metric))
5812 return CMD_WARNING;
5813
5814 /* Get metric type. */
5815 if (argc >= 3)
5816 if (!str2metric_type (argv[2], &type))
5817 return CMD_WARNING;
5818
5819 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005820 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005821 else
paul020709f2003-04-04 02:44:16 +00005822 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005823
paul020709f2003-04-04 02:44:16 +00005824 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005825}
5826
5827ALIAS (ospf_redistribute_source_metric_type,
5828 ospf_redistribute_source_metric_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005829 "redistribute " QUAGGA_REDIST_STR_OSPFD
5830 " metric <0-16777214> metric-type (1|2)",
5831 REDIST_STR
5832 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005833 "Metric for redistributed routes\n"
5834 "OSPF default metric\n"
5835 "OSPF exterior metric type for redistributed routes\n"
5836 "Set OSPF External Type 1 metrics\n"
5837 "Set OSPF External Type 2 metrics\n")
5838
5839ALIAS (ospf_redistribute_source_metric_type,
5840 ospf_redistribute_source_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005841 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5842 REDIST_STR
5843 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005844 "Metric for redistributed routes\n"
5845 "OSPF default metric\n")
5846
5847DEFUN (ospf_redistribute_source_type_metric,
5848 ospf_redistribute_source_type_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005849 "redistribute " QUAGGA_REDIST_STR_OSPFD
5850 " metric-type (1|2) metric <0-16777214> route-map WORD",
5851 REDIST_STR
5852 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005853 "OSPF exterior metric type for redistributed routes\n"
5854 "Set OSPF External Type 1 metrics\n"
5855 "Set OSPF External Type 2 metrics\n"
5856 "Metric for redistributed routes\n"
5857 "OSPF default metric\n"
5858 "Route map reference\n"
5859 "Pointer to route-map entries\n")
5860{
paul020709f2003-04-04 02:44:16 +00005861 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005862 int source;
5863 int type = -1;
5864 int metric = -1;
5865
5866 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005867 source = proto_redistnum(AFI_IP, argv[0]);
5868 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005869 return CMD_WARNING;
5870
5871 /* Get metric value. */
5872 if (argc >= 2)
5873 if (!str2metric_type (argv[1], &type))
5874 return CMD_WARNING;
5875
5876 /* Get metric type. */
5877 if (argc >= 3)
5878 if (!str2metric (argv[2], &metric))
5879 return CMD_WARNING;
5880
5881 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005882 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005883 else
paul020709f2003-04-04 02:44:16 +00005884 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005885
paul020709f2003-04-04 02:44:16 +00005886 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005887}
5888
5889ALIAS (ospf_redistribute_source_type_metric,
5890 ospf_redistribute_source_type_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005891 "redistribute " QUAGGA_REDIST_STR_OSPFD
5892 " metric-type (1|2) metric <0-16777214>",
5893 REDIST_STR
5894 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005895 "OSPF exterior metric type for redistributed routes\n"
5896 "Set OSPF External Type 1 metrics\n"
5897 "Set OSPF External Type 2 metrics\n"
5898 "Metric for redistributed routes\n"
5899 "OSPF default metric\n")
5900
5901ALIAS (ospf_redistribute_source_type_metric,
5902 ospf_redistribute_source_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005903 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5904 REDIST_STR
5905 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005906 "OSPF exterior metric type for redistributed routes\n"
5907 "Set OSPF External Type 1 metrics\n"
5908 "Set OSPF External Type 2 metrics\n")
5909
5910ALIAS (ospf_redistribute_source_type_metric,
5911 ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005912 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5913 REDIST_STR
5914 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005915
5916DEFUN (ospf_redistribute_source_metric_routemap,
5917 ospf_redistribute_source_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005918 "redistribute " QUAGGA_REDIST_STR_OSPFD
5919 " metric <0-16777214> route-map WORD",
5920 REDIST_STR
5921 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005922 "Metric for redistributed routes\n"
5923 "OSPF default metric\n"
5924 "Route map reference\n"
5925 "Pointer to route-map entries\n")
5926{
paul020709f2003-04-04 02:44:16 +00005927 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005928 int source;
5929 int metric = -1;
5930
5931 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005932 source = proto_redistnum(AFI_IP, argv[0]);
5933 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005934 return CMD_WARNING;
5935
5936 /* Get metric value. */
5937 if (argc >= 2)
5938 if (!str2metric (argv[1], &metric))
5939 return CMD_WARNING;
5940
5941 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005942 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005943 else
paul020709f2003-04-04 02:44:16 +00005944 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005945
paul020709f2003-04-04 02:44:16 +00005946 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005947}
5948
5949DEFUN (ospf_redistribute_source_type_routemap,
5950 ospf_redistribute_source_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005951 "redistribute " QUAGGA_REDIST_STR_OSPFD
5952 " metric-type (1|2) route-map WORD",
5953 REDIST_STR
5954 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005955 "OSPF exterior metric type for redistributed routes\n"
5956 "Set OSPF External Type 1 metrics\n"
5957 "Set OSPF External Type 2 metrics\n"
5958 "Route map reference\n"
5959 "Pointer to route-map entries\n")
5960{
paul020709f2003-04-04 02:44:16 +00005961 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005962 int source;
5963 int type = -1;
5964
5965 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005966 source = proto_redistnum(AFI_IP, argv[0]);
5967 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005968 return CMD_WARNING;
5969
5970 /* Get metric value. */
5971 if (argc >= 2)
5972 if (!str2metric_type (argv[1], &type))
5973 return CMD_WARNING;
5974
5975 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005976 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005977 else
paul020709f2003-04-04 02:44:16 +00005978 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005979
paul020709f2003-04-04 02:44:16 +00005980 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005981}
5982
5983DEFUN (ospf_redistribute_source_routemap,
5984 ospf_redistribute_source_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005985 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5986 REDIST_STR
5987 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005988 "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 source;
5993
5994 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005995 source = proto_redistnum(AFI_IP, argv[0]);
5996 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005997 return CMD_WARNING;
5998
5999 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006000 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00006001 else
paul020709f2003-04-04 02:44:16 +00006002 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006003
paul020709f2003-04-04 02:44:16 +00006004 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00006005}
6006
6007DEFUN (no_ospf_redistribute_source,
6008 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006009 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006010 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006011 REDIST_STR
6012 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006013{
paul020709f2003-04-04 02:44:16 +00006014 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006015 int source;
6016
David Lampartere0ca5fd2009-09-16 01:52:42 +02006017 source = proto_redistnum(AFI_IP, argv[0]);
6018 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006019 return CMD_WARNING;
6020
paul020709f2003-04-04 02:44:16 +00006021 ospf_routemap_unset (ospf, source);
6022 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006023}
6024
6025DEFUN (ospf_distribute_list_out,
6026 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006027 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006028 "Filter networks in routing updates\n"
6029 "Access-list name\n"
6030 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006031 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006032{
paul68980082003-03-25 05:07:42 +00006033 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006034 int source;
6035
6036 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02006037 source = proto_redistnum(AFI_IP, argv[0]);
6038 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006039 return CMD_WARNING;
6040
paul68980082003-03-25 05:07:42 +00006041 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006042}
6043
6044DEFUN (no_ospf_distribute_list_out,
6045 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006046 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006047 NO_STR
6048 "Filter networks in routing updates\n"
6049 "Access-list name\n"
6050 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006051 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006052{
paul68980082003-03-25 05:07:42 +00006053 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006054 int source;
6055
David Lampartere0ca5fd2009-09-16 01:52:42 +02006056 source = proto_redistnum(AFI_IP, argv[0]);
6057 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006058 return CMD_WARNING;
6059
paul68980082003-03-25 05:07:42 +00006060 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006061}
6062
6063/* Default information originate. */
6064DEFUN (ospf_default_information_originate_metric_type_routemap,
6065 ospf_default_information_originate_metric_type_routemap_cmd,
6066 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
6067 "Control distribution of default information\n"
6068 "Distribute a default route\n"
6069 "OSPF default metric\n"
6070 "OSPF metric\n"
6071 "OSPF metric type for default routes\n"
6072 "Set OSPF External Type 1 metrics\n"
6073 "Set OSPF External Type 2 metrics\n"
6074 "Route map reference\n"
6075 "Pointer to route-map entries\n")
6076{
paul020709f2003-04-04 02:44:16 +00006077 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006078 int type = -1;
6079 int metric = -1;
6080
6081 /* Get metric value. */
6082 if (argc >= 1)
6083 if (!str2metric (argv[0], &metric))
6084 return CMD_WARNING;
6085
6086 /* Get metric type. */
6087 if (argc >= 2)
6088 if (!str2metric_type (argv[1], &type))
6089 return CMD_WARNING;
6090
6091 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006092 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006093 else
paul020709f2003-04-04 02:44:16 +00006094 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006095
paul020709f2003-04-04 02:44:16 +00006096 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6097 type, metric);
paul718e3742002-12-13 20:15:29 +00006098}
6099
6100ALIAS (ospf_default_information_originate_metric_type_routemap,
6101 ospf_default_information_originate_metric_type_cmd,
6102 "default-information originate metric <0-16777214> metric-type (1|2)",
6103 "Control distribution of default information\n"
6104 "Distribute a 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_metric_type_routemap,
6112 ospf_default_information_originate_metric_cmd,
6113 "default-information originate metric <0-16777214>",
6114 "Control distribution of default information\n"
6115 "Distribute a default route\n"
6116 "OSPF default metric\n"
6117 "OSPF metric\n")
6118
6119ALIAS (ospf_default_information_originate_metric_type_routemap,
6120 ospf_default_information_originate_cmd,
6121 "default-information originate",
6122 "Control distribution of default information\n"
6123 "Distribute a default route\n")
6124
6125/* Default information originate. */
6126DEFUN (ospf_default_information_originate_metric_routemap,
6127 ospf_default_information_originate_metric_routemap_cmd,
6128 "default-information originate metric <0-16777214> route-map WORD",
6129 "Control distribution of default information\n"
6130 "Distribute a default route\n"
6131 "OSPF default metric\n"
6132 "OSPF metric\n"
6133 "Route map reference\n"
6134 "Pointer to route-map entries\n")
6135{
paul020709f2003-04-04 02:44:16 +00006136 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006137 int metric = -1;
6138
6139 /* Get metric value. */
6140 if (argc >= 1)
6141 if (!str2metric (argv[0], &metric))
6142 return CMD_WARNING;
6143
6144 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006145 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006146 else
paul020709f2003-04-04 02:44:16 +00006147 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006148
paul020709f2003-04-04 02:44:16 +00006149 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6150 -1, metric);
paul718e3742002-12-13 20:15:29 +00006151}
6152
6153/* Default information originate. */
6154DEFUN (ospf_default_information_originate_routemap,
6155 ospf_default_information_originate_routemap_cmd,
6156 "default-information originate route-map WORD",
6157 "Control distribution of default information\n"
6158 "Distribute a default route\n"
6159 "Route map reference\n"
6160 "Pointer to route-map entries\n")
6161{
paul020709f2003-04-04 02:44:16 +00006162 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006163
paul020709f2003-04-04 02:44:16 +00006164 if (argc == 1)
6165 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6166 else
6167 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6168
6169 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00006170}
6171
6172DEFUN (ospf_default_information_originate_type_metric_routemap,
6173 ospf_default_information_originate_type_metric_routemap_cmd,
6174 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6175 "Control distribution of default information\n"
6176 "Distribute a default route\n"
6177 "OSPF metric type for default routes\n"
6178 "Set OSPF External Type 1 metrics\n"
6179 "Set OSPF External Type 2 metrics\n"
6180 "OSPF default metric\n"
6181 "OSPF metric\n"
6182 "Route map reference\n"
6183 "Pointer to route-map entries\n")
6184{
paul020709f2003-04-04 02:44:16 +00006185 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006186 int type = -1;
6187 int metric = -1;
6188
6189 /* Get metric type. */
6190 if (argc >= 1)
6191 if (!str2metric_type (argv[0], &type))
6192 return CMD_WARNING;
6193
6194 /* Get metric value. */
6195 if (argc >= 2)
6196 if (!str2metric (argv[1], &metric))
6197 return CMD_WARNING;
6198
6199 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006200 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006201 else
paul020709f2003-04-04 02:44:16 +00006202 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006203
paul020709f2003-04-04 02:44:16 +00006204 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6205 type, metric);
paul718e3742002-12-13 20:15:29 +00006206}
6207
6208ALIAS (ospf_default_information_originate_type_metric_routemap,
6209 ospf_default_information_originate_type_metric_cmd,
6210 "default-information originate metric-type (1|2) metric <0-16777214>",
6211 "Control distribution of default information\n"
6212 "Distribute a default route\n"
6213 "OSPF metric type for default routes\n"
6214 "Set OSPF External Type 1 metrics\n"
6215 "Set OSPF External Type 2 metrics\n"
6216 "OSPF default metric\n"
6217 "OSPF metric\n")
6218
6219ALIAS (ospf_default_information_originate_type_metric_routemap,
6220 ospf_default_information_originate_type_cmd,
6221 "default-information originate metric-type (1|2)",
6222 "Control distribution of default information\n"
6223 "Distribute a default route\n"
6224 "OSPF metric type for default routes\n"
6225 "Set OSPF External Type 1 metrics\n"
6226 "Set OSPF External Type 2 metrics\n")
6227
6228DEFUN (ospf_default_information_originate_type_routemap,
6229 ospf_default_information_originate_type_routemap_cmd,
6230 "default-information originate metric-type (1|2) route-map WORD",
6231 "Control distribution of default information\n"
6232 "Distribute a default route\n"
6233 "OSPF metric type for default routes\n"
6234 "Set OSPF External Type 1 metrics\n"
6235 "Set OSPF External Type 2 metrics\n"
6236 "Route map reference\n"
6237 "Pointer to route-map entries\n")
6238{
paul020709f2003-04-04 02:44:16 +00006239 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006240 int type = -1;
6241
6242 /* Get metric type. */
6243 if (argc >= 1)
6244 if (!str2metric_type (argv[0], &type))
6245 return CMD_WARNING;
6246
6247 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006248 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006249 else
paul020709f2003-04-04 02:44:16 +00006250 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006251
paul020709f2003-04-04 02:44:16 +00006252 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6253 type, -1);
paul718e3742002-12-13 20:15:29 +00006254}
6255
6256DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6257 ospf_default_information_originate_always_metric_type_routemap_cmd,
6258 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6259 "Control distribution of default information\n"
6260 "Distribute a default route\n"
6261 "Always advertise default route\n"
6262 "OSPF default metric\n"
6263 "OSPF metric\n"
6264 "OSPF metric type for default routes\n"
6265 "Set OSPF External Type 1 metrics\n"
6266 "Set OSPF External Type 2 metrics\n"
6267 "Route map reference\n"
6268 "Pointer to route-map entries\n")
6269{
paul020709f2003-04-04 02:44:16 +00006270 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006271 int type = -1;
6272 int metric = -1;
6273
6274 /* Get metric value. */
6275 if (argc >= 1)
6276 if (!str2metric (argv[0], &metric))
6277 return CMD_WARNING;
6278
6279 /* Get metric type. */
6280 if (argc >= 2)
6281 if (!str2metric_type (argv[1], &type))
6282 return CMD_WARNING;
6283
6284 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006285 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006286 else
paul020709f2003-04-04 02:44:16 +00006287 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006288
paul020709f2003-04-04 02:44:16 +00006289 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006290 type, metric);
6291}
6292
6293ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6294 ospf_default_information_originate_always_metric_type_cmd,
6295 "default-information originate always metric <0-16777214> metric-type (1|2)",
6296 "Control distribution of default information\n"
6297 "Distribute a default route\n"
6298 "Always advertise default route\n"
6299 "OSPF default metric\n"
6300 "OSPF metric\n"
6301 "OSPF metric type for default routes\n"
6302 "Set OSPF External Type 1 metrics\n"
6303 "Set OSPF External Type 2 metrics\n")
6304
6305ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6306 ospf_default_information_originate_always_metric_cmd,
6307 "default-information originate always metric <0-16777214>",
6308 "Control distribution of default information\n"
6309 "Distribute a default route\n"
6310 "Always advertise default route\n"
6311 "OSPF default metric\n"
6312 "OSPF metric\n"
6313 "OSPF metric type for default routes\n")
6314
6315ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6316 ospf_default_information_originate_always_cmd,
6317 "default-information originate always",
6318 "Control distribution of default information\n"
6319 "Distribute a default route\n"
6320 "Always advertise default route\n")
6321
6322DEFUN (ospf_default_information_originate_always_metric_routemap,
6323 ospf_default_information_originate_always_metric_routemap_cmd,
6324 "default-information originate always metric <0-16777214> route-map WORD",
6325 "Control distribution of default information\n"
6326 "Distribute a default route\n"
6327 "Always advertise default route\n"
6328 "OSPF default metric\n"
6329 "OSPF metric\n"
6330 "Route map reference\n"
6331 "Pointer to route-map entries\n")
6332{
paul020709f2003-04-04 02:44:16 +00006333 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006334 int metric = -1;
6335
6336 /* Get metric value. */
6337 if (argc >= 1)
6338 if (!str2metric (argv[0], &metric))
6339 return CMD_WARNING;
6340
6341 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006342 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006343 else
paul020709f2003-04-04 02:44:16 +00006344 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006345
paul020709f2003-04-04 02:44:16 +00006346 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6347 -1, metric);
paul718e3742002-12-13 20:15:29 +00006348}
6349
6350DEFUN (ospf_default_information_originate_always_routemap,
6351 ospf_default_information_originate_always_routemap_cmd,
6352 "default-information originate always route-map WORD",
6353 "Control distribution of default information\n"
6354 "Distribute a default route\n"
6355 "Always advertise default route\n"
6356 "Route map reference\n"
6357 "Pointer to route-map entries\n")
6358{
paul020709f2003-04-04 02:44:16 +00006359 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006360
paul020709f2003-04-04 02:44:16 +00006361 if (argc == 1)
6362 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6363 else
6364 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6365
6366 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006367}
6368
6369DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6370 ospf_default_information_originate_always_type_metric_routemap_cmd,
6371 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6372 "Control distribution of default information\n"
6373 "Distribute a default route\n"
6374 "Always advertise default route\n"
6375 "OSPF metric type for default routes\n"
6376 "Set OSPF External Type 1 metrics\n"
6377 "Set OSPF External Type 2 metrics\n"
6378 "OSPF default metric\n"
6379 "OSPF metric\n"
6380 "Route map reference\n"
6381 "Pointer to route-map entries\n")
6382{
paul020709f2003-04-04 02:44:16 +00006383 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006384 int type = -1;
6385 int metric = -1;
6386
6387 /* Get metric type. */
6388 if (argc >= 1)
6389 if (!str2metric_type (argv[0], &type))
6390 return CMD_WARNING;
6391
6392 /* Get metric value. */
6393 if (argc >= 2)
6394 if (!str2metric (argv[1], &metric))
6395 return CMD_WARNING;
6396
6397 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006398 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006399 else
paul020709f2003-04-04 02:44:16 +00006400 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006401
paul020709f2003-04-04 02:44:16 +00006402 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006403 type, metric);
6404}
6405
6406ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6407 ospf_default_information_originate_always_type_metric_cmd,
6408 "default-information originate always metric-type (1|2) metric <0-16777214>",
6409 "Control distribution of default information\n"
6410 "Distribute a default route\n"
6411 "Always advertise default route\n"
6412 "OSPF metric type for default routes\n"
6413 "Set OSPF External Type 1 metrics\n"
6414 "Set OSPF External Type 2 metrics\n"
6415 "OSPF default metric\n"
6416 "OSPF metric\n")
6417
6418ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6419 ospf_default_information_originate_always_type_cmd,
6420 "default-information originate always metric-type (1|2)",
6421 "Control distribution of default information\n"
6422 "Distribute a default route\n"
6423 "Always advertise default route\n"
6424 "OSPF metric type for default routes\n"
6425 "Set OSPF External Type 1 metrics\n"
6426 "Set OSPF External Type 2 metrics\n")
6427
6428DEFUN (ospf_default_information_originate_always_type_routemap,
6429 ospf_default_information_originate_always_type_routemap_cmd,
6430 "default-information originate always metric-type (1|2) route-map WORD",
6431 "Control distribution of default information\n"
6432 "Distribute a default route\n"
6433 "Always advertise default route\n"
6434 "OSPF metric type for default routes\n"
6435 "Set OSPF External Type 1 metrics\n"
6436 "Set OSPF External Type 2 metrics\n"
6437 "Route map reference\n"
6438 "Pointer to route-map entries\n")
6439{
paul020709f2003-04-04 02:44:16 +00006440 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006441 int type = -1;
6442
6443 /* Get metric type. */
6444 if (argc >= 1)
6445 if (!str2metric_type (argv[0], &type))
6446 return CMD_WARNING;
6447
6448 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006449 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006450 else
paul020709f2003-04-04 02:44:16 +00006451 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006452
paul020709f2003-04-04 02:44:16 +00006453 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006454 type, -1);
6455}
6456
6457DEFUN (no_ospf_default_information_originate,
6458 no_ospf_default_information_originate_cmd,
6459 "no default-information originate",
6460 NO_STR
6461 "Control distribution of default information\n"
6462 "Distribute a default route\n")
6463{
paul68980082003-03-25 05:07:42 +00006464 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006465 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006466
6467 p.family = AF_INET;
6468 p.prefix.s_addr = 0;
6469 p.prefixlen = 0;
6470
ajs5339cfd2005-09-19 13:28:05 +00006471 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006472
6473 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6474 ospf_external_info_delete (DEFAULT_ROUTE, p);
6475 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6476 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6477 }
6478
paul020709f2003-04-04 02:44:16 +00006479 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6480 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006481}
6482
6483DEFUN (ospf_default_metric,
6484 ospf_default_metric_cmd,
6485 "default-metric <0-16777214>",
6486 "Set metric of redistributed routes\n"
6487 "Default metric\n")
6488{
paul68980082003-03-25 05:07:42 +00006489 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006490 int metric = -1;
6491
6492 if (!str2metric (argv[0], &metric))
6493 return CMD_WARNING;
6494
paul68980082003-03-25 05:07:42 +00006495 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006496
6497 return CMD_SUCCESS;
6498}
6499
6500DEFUN (no_ospf_default_metric,
6501 no_ospf_default_metric_cmd,
6502 "no default-metric",
6503 NO_STR
6504 "Set metric of redistributed routes\n")
6505{
paul68980082003-03-25 05:07:42 +00006506 struct ospf *ospf = vty->index;
6507
6508 ospf->default_metric = -1;
6509
paul718e3742002-12-13 20:15:29 +00006510 return CMD_SUCCESS;
6511}
6512
6513ALIAS (no_ospf_default_metric,
6514 no_ospf_default_metric_val_cmd,
6515 "no default-metric <0-16777214>",
6516 NO_STR
6517 "Set metric of redistributed routes\n"
6518 "Default metric\n")
6519
6520DEFUN (ospf_distance,
6521 ospf_distance_cmd,
6522 "distance <1-255>",
6523 "Define an administrative distance\n"
6524 "OSPF Administrative distance\n")
6525{
paul68980082003-03-25 05:07:42 +00006526 struct ospf *ospf = vty->index;
6527
6528 ospf->distance_all = atoi (argv[0]);
6529
paul718e3742002-12-13 20:15:29 +00006530 return CMD_SUCCESS;
6531}
6532
6533DEFUN (no_ospf_distance,
6534 no_ospf_distance_cmd,
6535 "no distance <1-255>",
6536 NO_STR
6537 "Define an administrative distance\n"
6538 "OSPF Administrative distance\n")
6539{
paul68980082003-03-25 05:07:42 +00006540 struct ospf *ospf = vty->index;
6541
6542 ospf->distance_all = 0;
6543
paul718e3742002-12-13 20:15:29 +00006544 return CMD_SUCCESS;
6545}
6546
6547DEFUN (no_ospf_distance_ospf,
6548 no_ospf_distance_ospf_cmd,
6549 "no distance ospf",
6550 NO_STR
6551 "Define an administrative distance\n"
6552 "OSPF Administrative distance\n"
6553 "OSPF Distance\n")
6554{
paul68980082003-03-25 05:07:42 +00006555 struct ospf *ospf = vty->index;
6556
6557 ospf->distance_intra = 0;
6558 ospf->distance_inter = 0;
6559 ospf->distance_external = 0;
6560
paul718e3742002-12-13 20:15:29 +00006561 return CMD_SUCCESS;
6562}
6563
6564DEFUN (ospf_distance_ospf_intra,
6565 ospf_distance_ospf_intra_cmd,
6566 "distance ospf intra-area <1-255>",
6567 "Define an administrative distance\n"
6568 "OSPF Administrative distance\n"
6569 "Intra-area routes\n"
6570 "Distance for intra-area routes\n")
6571{
paul68980082003-03-25 05:07:42 +00006572 struct ospf *ospf = vty->index;
6573
6574 ospf->distance_intra = atoi (argv[0]);
6575
paul718e3742002-12-13 20:15:29 +00006576 return CMD_SUCCESS;
6577}
6578
6579DEFUN (ospf_distance_ospf_intra_inter,
6580 ospf_distance_ospf_intra_inter_cmd,
6581 "distance ospf intra-area <1-255> inter-area <1-255>",
6582 "Define an administrative distance\n"
6583 "OSPF Administrative distance\n"
6584 "Intra-area routes\n"
6585 "Distance for intra-area routes\n"
6586 "Inter-area routes\n"
6587 "Distance for inter-area routes\n")
6588{
paul68980082003-03-25 05:07:42 +00006589 struct ospf *ospf = vty->index;
6590
6591 ospf->distance_intra = atoi (argv[0]);
6592 ospf->distance_inter = atoi (argv[1]);
6593
paul718e3742002-12-13 20:15:29 +00006594 return CMD_SUCCESS;
6595}
6596
6597DEFUN (ospf_distance_ospf_intra_external,
6598 ospf_distance_ospf_intra_external_cmd,
6599 "distance ospf intra-area <1-255> external <1-255>",
6600 "Define an administrative distance\n"
6601 "OSPF Administrative distance\n"
6602 "Intra-area routes\n"
6603 "Distance for intra-area routes\n"
6604 "External routes\n"
6605 "Distance for external routes\n")
6606{
paul68980082003-03-25 05:07:42 +00006607 struct ospf *ospf = vty->index;
6608
6609 ospf->distance_intra = atoi (argv[0]);
6610 ospf->distance_external = atoi (argv[1]);
6611
paul718e3742002-12-13 20:15:29 +00006612 return CMD_SUCCESS;
6613}
6614
6615DEFUN (ospf_distance_ospf_intra_inter_external,
6616 ospf_distance_ospf_intra_inter_external_cmd,
6617 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6618 "Define an administrative distance\n"
6619 "OSPF Administrative distance\n"
6620 "Intra-area routes\n"
6621 "Distance for intra-area routes\n"
6622 "Inter-area routes\n"
6623 "Distance for inter-area routes\n"
6624 "External routes\n"
6625 "Distance for external routes\n")
6626{
paul68980082003-03-25 05:07:42 +00006627 struct ospf *ospf = vty->index;
6628
6629 ospf->distance_intra = atoi (argv[0]);
6630 ospf->distance_inter = atoi (argv[1]);
6631 ospf->distance_external = atoi (argv[2]);
6632
paul718e3742002-12-13 20:15:29 +00006633 return CMD_SUCCESS;
6634}
6635
6636DEFUN (ospf_distance_ospf_intra_external_inter,
6637 ospf_distance_ospf_intra_external_inter_cmd,
6638 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6639 "Define an administrative distance\n"
6640 "OSPF Administrative distance\n"
6641 "Intra-area routes\n"
6642 "Distance for intra-area routes\n"
6643 "External routes\n"
6644 "Distance for external routes\n"
6645 "Inter-area routes\n"
6646 "Distance for inter-area routes\n")
6647{
paul68980082003-03-25 05:07:42 +00006648 struct ospf *ospf = vty->index;
6649
6650 ospf->distance_intra = atoi (argv[0]);
6651 ospf->distance_external = atoi (argv[1]);
6652 ospf->distance_inter = atoi (argv[2]);
6653
paul718e3742002-12-13 20:15:29 +00006654 return CMD_SUCCESS;
6655}
6656
6657DEFUN (ospf_distance_ospf_inter,
6658 ospf_distance_ospf_inter_cmd,
6659 "distance ospf inter-area <1-255>",
6660 "Define an administrative distance\n"
6661 "OSPF Administrative distance\n"
6662 "Inter-area routes\n"
6663 "Distance for inter-area routes\n")
6664{
paul68980082003-03-25 05:07:42 +00006665 struct ospf *ospf = vty->index;
6666
6667 ospf->distance_inter = atoi (argv[0]);
6668
paul718e3742002-12-13 20:15:29 +00006669 return CMD_SUCCESS;
6670}
6671
6672DEFUN (ospf_distance_ospf_inter_intra,
6673 ospf_distance_ospf_inter_intra_cmd,
6674 "distance ospf inter-area <1-255> intra-area <1-255>",
6675 "Define an administrative distance\n"
6676 "OSPF Administrative distance\n"
6677 "Inter-area routes\n"
6678 "Distance for inter-area routes\n"
6679 "Intra-area routes\n"
6680 "Distance for intra-area routes\n")
6681{
paul68980082003-03-25 05:07:42 +00006682 struct ospf *ospf = vty->index;
6683
6684 ospf->distance_inter = atoi (argv[0]);
6685 ospf->distance_intra = atoi (argv[1]);
6686
paul718e3742002-12-13 20:15:29 +00006687 return CMD_SUCCESS;
6688}
6689
6690DEFUN (ospf_distance_ospf_inter_external,
6691 ospf_distance_ospf_inter_external_cmd,
6692 "distance ospf inter-area <1-255> external <1-255>",
6693 "Define an administrative distance\n"
6694 "OSPF Administrative distance\n"
6695 "Inter-area routes\n"
6696 "Distance for inter-area routes\n"
6697 "External routes\n"
6698 "Distance for external routes\n")
6699{
paul68980082003-03-25 05:07:42 +00006700 struct ospf *ospf = vty->index;
6701
6702 ospf->distance_inter = atoi (argv[0]);
6703 ospf->distance_external = atoi (argv[1]);
6704
paul718e3742002-12-13 20:15:29 +00006705 return CMD_SUCCESS;
6706}
6707
6708DEFUN (ospf_distance_ospf_inter_intra_external,
6709 ospf_distance_ospf_inter_intra_external_cmd,
6710 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6711 "Define an administrative distance\n"
6712 "OSPF Administrative distance\n"
6713 "Inter-area routes\n"
6714 "Distance for inter-area routes\n"
6715 "Intra-area routes\n"
6716 "Distance for intra-area routes\n"
6717 "External routes\n"
6718 "Distance for external routes\n")
6719{
paul68980082003-03-25 05:07:42 +00006720 struct ospf *ospf = vty->index;
6721
6722 ospf->distance_inter = atoi (argv[0]);
6723 ospf->distance_intra = atoi (argv[1]);
6724 ospf->distance_external = atoi (argv[2]);
6725
paul718e3742002-12-13 20:15:29 +00006726 return CMD_SUCCESS;
6727}
6728
6729DEFUN (ospf_distance_ospf_inter_external_intra,
6730 ospf_distance_ospf_inter_external_intra_cmd,
6731 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6732 "Define an administrative distance\n"
6733 "OSPF Administrative distance\n"
6734 "Inter-area routes\n"
6735 "Distance for inter-area routes\n"
6736 "External routes\n"
6737 "Distance for external routes\n"
6738 "Intra-area routes\n"
6739 "Distance for intra-area routes\n")
6740{
paul68980082003-03-25 05:07:42 +00006741 struct ospf *ospf = vty->index;
6742
6743 ospf->distance_inter = atoi (argv[0]);
6744 ospf->distance_external = atoi (argv[1]);
6745 ospf->distance_intra = atoi (argv[2]);
6746
paul718e3742002-12-13 20:15:29 +00006747 return CMD_SUCCESS;
6748}
6749
6750DEFUN (ospf_distance_ospf_external,
6751 ospf_distance_ospf_external_cmd,
6752 "distance ospf external <1-255>",
6753 "Define an administrative distance\n"
6754 "OSPF Administrative distance\n"
6755 "External routes\n"
6756 "Distance for external routes\n")
6757{
paul68980082003-03-25 05:07:42 +00006758 struct ospf *ospf = vty->index;
6759
6760 ospf->distance_external = atoi (argv[0]);
6761
paul718e3742002-12-13 20:15:29 +00006762 return CMD_SUCCESS;
6763}
6764
6765DEFUN (ospf_distance_ospf_external_intra,
6766 ospf_distance_ospf_external_intra_cmd,
6767 "distance ospf external <1-255> intra-area <1-255>",
6768 "Define an administrative distance\n"
6769 "OSPF Administrative distance\n"
6770 "External routes\n"
6771 "Distance for external routes\n"
6772 "Intra-area routes\n"
6773 "Distance for intra-area routes\n")
6774{
paul68980082003-03-25 05:07:42 +00006775 struct ospf *ospf = vty->index;
6776
6777 ospf->distance_external = atoi (argv[0]);
6778 ospf->distance_intra = atoi (argv[1]);
6779
paul718e3742002-12-13 20:15:29 +00006780 return CMD_SUCCESS;
6781}
6782
6783DEFUN (ospf_distance_ospf_external_inter,
6784 ospf_distance_ospf_external_inter_cmd,
6785 "distance ospf external <1-255> inter-area <1-255>",
6786 "Define an administrative distance\n"
6787 "OSPF Administrative distance\n"
6788 "External routes\n"
6789 "Distance for external routes\n"
6790 "Inter-area routes\n"
6791 "Distance for inter-area routes\n")
6792{
paul68980082003-03-25 05:07:42 +00006793 struct ospf *ospf = vty->index;
6794
6795 ospf->distance_external = atoi (argv[0]);
6796 ospf->distance_inter = atoi (argv[1]);
6797
paul718e3742002-12-13 20:15:29 +00006798 return CMD_SUCCESS;
6799}
6800
6801DEFUN (ospf_distance_ospf_external_intra_inter,
6802 ospf_distance_ospf_external_intra_inter_cmd,
6803 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6804 "Define an administrative distance\n"
6805 "OSPF Administrative distance\n"
6806 "External routes\n"
6807 "Distance for external routes\n"
6808 "Intra-area routes\n"
6809 "Distance for intra-area routes\n"
6810 "Inter-area routes\n"
6811 "Distance for inter-area routes\n")
6812{
paul68980082003-03-25 05:07:42 +00006813 struct ospf *ospf = vty->index;
6814
6815 ospf->distance_external = atoi (argv[0]);
6816 ospf->distance_intra = atoi (argv[1]);
6817 ospf->distance_inter = atoi (argv[2]);
6818
paul718e3742002-12-13 20:15:29 +00006819 return CMD_SUCCESS;
6820}
6821
6822DEFUN (ospf_distance_ospf_external_inter_intra,
6823 ospf_distance_ospf_external_inter_intra_cmd,
6824 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6825 "Define an administrative distance\n"
6826 "OSPF Administrative distance\n"
6827 "External routes\n"
6828 "Distance for external routes\n"
6829 "Inter-area routes\n"
6830 "Distance for inter-area routes\n"
6831 "Intra-area routes\n"
6832 "Distance for intra-area routes\n")
6833{
paul68980082003-03-25 05:07:42 +00006834 struct ospf *ospf = vty->index;
6835
6836 ospf->distance_external = atoi (argv[0]);
6837 ospf->distance_inter = atoi (argv[1]);
6838 ospf->distance_intra = atoi (argv[2]);
6839
paul718e3742002-12-13 20:15:29 +00006840 return CMD_SUCCESS;
6841}
6842
6843DEFUN (ospf_distance_source,
6844 ospf_distance_source_cmd,
6845 "distance <1-255> A.B.C.D/M",
6846 "Administrative distance\n"
6847 "Distance value\n"
6848 "IP source prefix\n")
6849{
paul020709f2003-04-04 02:44:16 +00006850 struct ospf *ospf = vty->index;
6851
6852 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006853
paul718e3742002-12-13 20:15:29 +00006854 return CMD_SUCCESS;
6855}
6856
6857DEFUN (no_ospf_distance_source,
6858 no_ospf_distance_source_cmd,
6859 "no distance <1-255> A.B.C.D/M",
6860 NO_STR
6861 "Administrative distance\n"
6862 "Distance value\n"
6863 "IP source prefix\n")
6864{
paul020709f2003-04-04 02:44:16 +00006865 struct ospf *ospf = vty->index;
6866
6867 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6868
paul718e3742002-12-13 20:15:29 +00006869 return CMD_SUCCESS;
6870}
6871
6872DEFUN (ospf_distance_source_access_list,
6873 ospf_distance_source_access_list_cmd,
6874 "distance <1-255> A.B.C.D/M WORD",
6875 "Administrative distance\n"
6876 "Distance value\n"
6877 "IP source prefix\n"
6878 "Access list name\n")
6879{
paul020709f2003-04-04 02:44:16 +00006880 struct ospf *ospf = vty->index;
6881
6882 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6883
paul718e3742002-12-13 20:15:29 +00006884 return CMD_SUCCESS;
6885}
6886
6887DEFUN (no_ospf_distance_source_access_list,
6888 no_ospf_distance_source_access_list_cmd,
6889 "no distance <1-255> A.B.C.D/M WORD",
6890 NO_STR
6891 "Administrative distance\n"
6892 "Distance value\n"
6893 "IP source prefix\n"
6894 "Access list name\n")
6895{
paul020709f2003-04-04 02:44:16 +00006896 struct ospf *ospf = vty->index;
6897
6898 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6899
paul718e3742002-12-13 20:15:29 +00006900 return CMD_SUCCESS;
6901}
6902
vincentba682532005-09-29 13:52:57 +00006903DEFUN (ip_ospf_mtu_ignore,
6904 ip_ospf_mtu_ignore_addr_cmd,
6905 "ip ospf mtu-ignore A.B.C.D",
6906 "IP Information\n"
6907 "OSPF interface commands\n"
6908 "Disable mtu mismatch detection\n"
6909 "Address of interface")
6910{
6911 struct interface *ifp = vty->index;
6912 struct in_addr addr;
6913 int ret;
6914
6915 struct ospf_if_params *params;
6916 params = IF_DEF_PARAMS (ifp);
6917
6918 if (argc == 1)
6919 {
6920 ret = inet_aton(argv[0], &addr);
6921 if (!ret)
6922 {
6923 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6924 VTY_NEWLINE);
6925 return CMD_WARNING;
6926 }
6927 params = ospf_get_if_params (ifp, addr);
6928 ospf_if_update_params (ifp, addr);
6929 }
6930 params->mtu_ignore = 1;
6931 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6932 SET_IF_PARAM (params, mtu_ignore);
6933 else
6934 {
6935 UNSET_IF_PARAM (params, mtu_ignore);
6936 if (params != IF_DEF_PARAMS (ifp))
6937 {
6938 ospf_free_if_params (ifp, addr);
6939 ospf_if_update_params (ifp, addr);
6940 }
6941 }
6942 return CMD_SUCCESS;
6943}
6944
6945ALIAS (ip_ospf_mtu_ignore,
6946 ip_ospf_mtu_ignore_cmd,
6947 "ip ospf mtu-ignore",
6948 "IP Information\n"
6949 "OSPF interface commands\n"
6950 "Disable mtu mismatch detection\n")
6951
6952
6953DEFUN (no_ip_ospf_mtu_ignore,
6954 no_ip_ospf_mtu_ignore_addr_cmd,
6955 "no ip ospf mtu-ignore A.B.C.D",
6956 "IP Information\n"
6957 "OSPF interface commands\n"
6958 "Disable mtu mismatch detection\n"
6959 "Address of interface")
6960{
6961 struct interface *ifp = vty->index;
6962 struct in_addr addr;
6963 int ret;
6964
6965 struct ospf_if_params *params;
6966 params = IF_DEF_PARAMS (ifp);
6967
6968 if (argc == 1)
6969 {
6970 ret = inet_aton(argv[0], &addr);
6971 if (!ret)
6972 {
6973 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6974 VTY_NEWLINE);
6975 return CMD_WARNING;
6976 }
6977 params = ospf_get_if_params (ifp, addr);
6978 ospf_if_update_params (ifp, addr);
6979 }
6980 params->mtu_ignore = 0;
6981 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6982 SET_IF_PARAM (params, mtu_ignore);
6983 else
6984 {
6985 UNSET_IF_PARAM (params, mtu_ignore);
6986 if (params != IF_DEF_PARAMS (ifp))
6987 {
6988 ospf_free_if_params (ifp, addr);
6989 ospf_if_update_params (ifp, addr);
6990 }
6991 }
6992 return CMD_SUCCESS;
6993}
6994
6995ALIAS (no_ip_ospf_mtu_ignore,
6996 no_ip_ospf_mtu_ignore_cmd,
6997 "no ip ospf mtu-ignore",
6998 "IP Information\n"
6999 "OSPF interface commands\n"
7000 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00007001
7002DEFUN (ospf_max_metric_router_lsa_admin,
7003 ospf_max_metric_router_lsa_admin_cmd,
7004 "max-metric router-lsa administrative",
7005 "OSPF maximum / infinite-distance metric\n"
7006 "Advertise own Router-LSA with infinite distance (stub router)\n"
7007 "Administratively applied, for an indefinite period\n")
7008{
7009 struct listnode *ln;
7010 struct ospf_area *area;
7011 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00007012
paul88d6cf32005-10-29 12:50:09 +00007013 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7014 {
7015 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7016
7017 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
Paul Jakmac363d382010-01-24 22:42:13 +00007018 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007019 }
7020 return CMD_SUCCESS;
7021}
7022
7023DEFUN (no_ospf_max_metric_router_lsa_admin,
7024 no_ospf_max_metric_router_lsa_admin_cmd,
7025 "no max-metric router-lsa administrative",
7026 NO_STR
7027 "OSPF maximum / infinite-distance metric\n"
7028 "Advertise own Router-LSA with infinite distance (stub router)\n"
7029 "Administratively applied, for an indefinite period\n")
7030{
7031 struct listnode *ln;
7032 struct ospf_area *area;
7033 struct ospf *ospf = vty->index;
7034
7035 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7036 {
7037 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7038
7039 /* Don't trample on the start-up stub timer */
7040 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
7041 && !area->t_stub_router)
7042 {
7043 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00007044 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007045 }
7046 }
7047 return CMD_SUCCESS;
7048}
7049
7050DEFUN (ospf_max_metric_router_lsa_startup,
7051 ospf_max_metric_router_lsa_startup_cmd,
7052 "max-metric router-lsa on-startup <5-86400>",
7053 "OSPF maximum / infinite-distance metric\n"
7054 "Advertise own Router-LSA with infinite distance (stub router)\n"
7055 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7056 "Time (seconds) to advertise self as stub-router\n")
7057{
7058 unsigned int seconds;
7059 struct ospf *ospf = vty->index;
7060
7061 if (argc != 1)
7062 {
7063 vty_out (vty, "%% Must supply stub-router period");
7064 return CMD_WARNING;
7065 }
7066
7067 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
7068
7069 ospf->stub_router_startup_time = seconds;
7070
7071 return CMD_SUCCESS;
7072}
7073
7074DEFUN (no_ospf_max_metric_router_lsa_startup,
7075 no_ospf_max_metric_router_lsa_startup_cmd,
7076 "no max-metric router-lsa on-startup",
7077 NO_STR
7078 "OSPF maximum / infinite-distance metric\n"
7079 "Advertise own Router-LSA with infinite distance (stub router)\n"
7080 "Automatically advertise stub Router-LSA on startup of OSPF\n")
7081{
7082 struct listnode *ln;
7083 struct ospf_area *area;
7084 struct ospf *ospf = vty->index;
7085
7086 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7087
7088 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7089 {
7090 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
7091 OSPF_TIMER_OFF (area->t_stub_router);
7092
7093 /* Don't trample on admin stub routed */
7094 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7095 {
7096 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00007097 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007098 }
7099 }
7100 return CMD_SUCCESS;
7101}
7102
7103DEFUN (ospf_max_metric_router_lsa_shutdown,
7104 ospf_max_metric_router_lsa_shutdown_cmd,
7105 "max-metric router-lsa on-shutdown <5-86400>",
7106 "OSPF maximum / infinite-distance metric\n"
7107 "Advertise own Router-LSA with infinite distance (stub router)\n"
7108 "Advertise stub-router prior to full shutdown of OSPF\n"
7109 "Time (seconds) to wait till full shutdown\n")
7110{
7111 unsigned int seconds;
7112 struct ospf *ospf = vty->index;
7113
7114 if (argc != 1)
7115 {
7116 vty_out (vty, "%% Must supply stub-router shutdown period");
7117 return CMD_WARNING;
7118 }
7119
7120 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
7121
7122 ospf->stub_router_shutdown_time = seconds;
7123
7124 return CMD_SUCCESS;
7125}
7126
7127DEFUN (no_ospf_max_metric_router_lsa_shutdown,
7128 no_ospf_max_metric_router_lsa_shutdown_cmd,
7129 "no max-metric router-lsa on-shutdown",
7130 NO_STR
7131 "OSPF maximum / infinite-distance metric\n"
7132 "Advertise own Router-LSA with infinite distance (stub router)\n"
7133 "Advertise stub-router prior to full shutdown of OSPF\n")
7134{
7135 struct ospf *ospf = vty->index;
7136
7137 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7138
7139 return CMD_SUCCESS;
7140}
7141
7142static void
7143config_write_stub_router (struct vty *vty, struct ospf *ospf)
7144{
7145 struct listnode *ln;
7146 struct ospf_area *area;
7147
7148 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7149 vty_out (vty, " max-metric router-lsa on-startup %u%s",
7150 ospf->stub_router_startup_time, VTY_NEWLINE);
7151 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7152 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
7153 ospf->stub_router_shutdown_time, VTY_NEWLINE);
7154 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7155 {
7156 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7157 {
7158 vty_out (vty, " max-metric router-lsa administrative%s",
7159 VTY_NEWLINE);
7160 break;
7161 }
7162 }
7163 return;
7164}
7165
paul4dadc292005-05-06 21:37:42 +00007166static void
paul718e3742002-12-13 20:15:29 +00007167show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7168{
7169 struct route_node *rn;
7170 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007171 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007172 struct ospf_path *path;
7173
7174 vty_out (vty, "============ OSPF network routing table ============%s",
7175 VTY_NEWLINE);
7176
7177 for (rn = route_top (rt); rn; rn = route_next (rn))
7178 if ((or = rn->info) != NULL)
7179 {
7180 char buf1[19];
7181 snprintf (buf1, 19, "%s/%d",
7182 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7183
7184 switch (or->path_type)
7185 {
7186 case OSPF_PATH_INTER_AREA:
7187 if (or->type == OSPF_DESTINATION_NETWORK)
7188 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7189 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7190 else if (or->type == OSPF_DESTINATION_DISCARD)
7191 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7192 break;
7193 case OSPF_PATH_INTRA_AREA:
7194 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7195 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7196 break;
7197 default:
7198 break;
7199 }
7200
7201 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007202 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007203 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007204 if (if_lookup_by_index(path->ifindex))
paul96735ee2003-08-10 02:51:22 +00007205 {
7206 if (path->nexthop.s_addr == 0)
7207 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007208 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007209 else
7210 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007211 inet_ntoa (path->nexthop),
7212 ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007213 }
7214 }
paul718e3742002-12-13 20:15:29 +00007215 }
7216 vty_out (vty, "%s", VTY_NEWLINE);
7217}
7218
paul4dadc292005-05-06 21:37:42 +00007219static void
paul718e3742002-12-13 20:15:29 +00007220show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7221{
7222 struct route_node *rn;
7223 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007224 struct listnode *pnode;
7225 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007226 struct ospf_path *path;
7227
7228 vty_out (vty, "============ OSPF router routing table =============%s",
7229 VTY_NEWLINE);
7230 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7231 if (rn->info)
7232 {
7233 int flag = 0;
7234
7235 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7236
paul1eb8ef22005-04-07 07:30:20 +00007237 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7238 {
7239 if (flag++)
7240 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007241
paul1eb8ef22005-04-07 07:30:20 +00007242 /* Show path. */
7243 vty_out (vty, "%s [%d] area: %s",
7244 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7245 or->cost, inet_ntoa (or->u.std.area_id));
7246 /* Show flags. */
7247 vty_out (vty, "%s%s%s",
7248 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7249 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7250 VTY_NEWLINE);
7251
7252 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7253 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007254 if (if_lookup_by_index(path->ifindex))
hasso54bedb52005-08-17 13:31:47 +00007255 {
7256 if (path->nexthop.s_addr == 0)
7257 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007258 "", ifindex2ifname (path->ifindex),
7259 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007260 else
7261 vty_out (vty, "%24s via %s, %s%s", "",
7262 inet_ntoa (path->nexthop),
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007263 ifindex2ifname (path->ifindex),
7264 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007265 }
paul1eb8ef22005-04-07 07:30:20 +00007266 }
7267 }
paul718e3742002-12-13 20:15:29 +00007268 }
7269 vty_out (vty, "%s", VTY_NEWLINE);
7270}
7271
paul4dadc292005-05-06 21:37:42 +00007272static void
paul718e3742002-12-13 20:15:29 +00007273show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7274{
7275 struct route_node *rn;
7276 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007277 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007278 struct ospf_path *path;
7279
7280 vty_out (vty, "============ OSPF external routing table ===========%s",
7281 VTY_NEWLINE);
7282 for (rn = route_top (rt); rn; rn = route_next (rn))
7283 if ((er = rn->info) != NULL)
7284 {
7285 char buf1[19];
7286 snprintf (buf1, 19, "%s/%d",
7287 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7288
7289 switch (er->path_type)
7290 {
7291 case OSPF_PATH_TYPE1_EXTERNAL:
7292 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7293 er->cost, er->u.ext.tag, VTY_NEWLINE);
7294 break;
7295 case OSPF_PATH_TYPE2_EXTERNAL:
7296 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7297 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7298 break;
7299 }
7300
paul1eb8ef22005-04-07 07:30:20 +00007301 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007302 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007303 if (if_lookup_by_index(path->ifindex))
paul718e3742002-12-13 20:15:29 +00007304 {
7305 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007306 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007307 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007308 else
7309 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007310 inet_ntoa (path->nexthop),
7311 ifindex2ifname (path->ifindex),
paul96735ee2003-08-10 02:51:22 +00007312 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007313 }
7314 }
7315 }
7316 vty_out (vty, "%s", VTY_NEWLINE);
7317}
7318
paul718e3742002-12-13 20:15:29 +00007319DEFUN (show_ip_ospf_border_routers,
7320 show_ip_ospf_border_routers_cmd,
7321 "show ip ospf border-routers",
7322 SHOW_STR
7323 IP_STR
7324 "show all the ABR's and ASBR's\n"
7325 "for this area\n")
7326{
paul020709f2003-04-04 02:44:16 +00007327 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007328
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007329 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007330 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007331 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007332 return CMD_SUCCESS;
7333 }
7334
paul68980082003-03-25 05:07:42 +00007335 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007336 {
7337 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7338 return CMD_SUCCESS;
7339 }
7340
7341 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007342 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007343
7344 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007345 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007346
7347 return CMD_SUCCESS;
7348}
paul718e3742002-12-13 20:15:29 +00007349
7350DEFUN (show_ip_ospf_route,
7351 show_ip_ospf_route_cmd,
7352 "show ip ospf route",
7353 SHOW_STR
7354 IP_STR
7355 "OSPF information\n"
7356 "OSPF routing table\n")
7357{
paul020709f2003-04-04 02:44:16 +00007358 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007359
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007360 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007361 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007362 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007363 return CMD_SUCCESS;
7364 }
7365
paul68980082003-03-25 05:07:42 +00007366 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007367 {
7368 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7369 return CMD_SUCCESS;
7370 }
7371
7372 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007373 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007374
7375 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007376 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007377
7378 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007379 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007380
7381 return CMD_SUCCESS;
7382}
7383
7384
hassoeb1ce602004-10-08 08:17:22 +00007385const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007386{
7387 "unknown",
7388 "standard",
7389 "ibm",
7390 "cisco",
7391 "shortcut"
7392};
7393
hassoeb1ce602004-10-08 08:17:22 +00007394const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007395{
7396 "default",
7397 "enable",
7398 "disable"
7399};
7400
7401
paul4dadc292005-05-06 21:37:42 +00007402static void
paul718e3742002-12-13 20:15:29 +00007403area_id2str (char *buf, int length, struct ospf_area *area)
7404{
7405 memset (buf, 0, length);
7406
7407 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7408 strncpy (buf, inet_ntoa (area->area_id), length);
7409 else
7410 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7411}
7412
7413
hassoeb1ce602004-10-08 08:17:22 +00007414const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007415{
7416 "unknown", /* should never be used. */
7417 "point-to-point",
7418 "broadcast",
7419 "non-broadcast",
7420 "point-to-multipoint",
7421 "virtual-link", /* should never be used. */
7422 "loopback"
7423};
7424
7425/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007426static int
paul718e3742002-12-13 20:15:29 +00007427config_write_interface (struct vty *vty)
7428{
hasso52dc7ee2004-09-23 19:18:23 +00007429 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007430 struct interface *ifp;
7431 struct crypt_key *ck;
7432 int write = 0;
7433 struct route_node *rn = NULL;
7434 struct ospf_if_params *params;
7435
paul1eb8ef22005-04-07 07:30:20 +00007436 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007437 {
paul718e3742002-12-13 20:15:29 +00007438 if (memcmp (ifp->name, "VLINK", 5) == 0)
7439 continue;
7440
7441 vty_out (vty, "!%s", VTY_NEWLINE);
7442 vty_out (vty, "interface %s%s", ifp->name,
7443 VTY_NEWLINE);
7444 if (ifp->desc)
7445 vty_out (vty, " description %s%s", ifp->desc,
7446 VTY_NEWLINE);
7447
7448 write++;
7449
7450 params = IF_DEF_PARAMS (ifp);
7451
7452 do {
7453 /* Interface Network print. */
7454 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007455 params->type != OSPF_IFTYPE_LOOPBACK)
7456 {
ajsbc18d612004-12-15 15:07:19 +00007457 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007458 {
7459 vty_out (vty, " ip ospf network %s",
7460 ospf_int_type_str[params->type]);
7461 if (params != IF_DEF_PARAMS (ifp))
7462 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7463 vty_out (vty, "%s", VTY_NEWLINE);
7464 }
paul718e3742002-12-13 20:15:29 +00007465 }
7466
7467 /* OSPF interface authentication print */
7468 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7469 params->auth_type != OSPF_AUTH_NOTSET)
7470 {
hassoeb1ce602004-10-08 08:17:22 +00007471 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007472
7473 /* Translation tables are not that much help here due to syntax
7474 of the simple option */
7475 switch (params->auth_type)
7476 {
7477
7478 case OSPF_AUTH_NULL:
7479 auth_str = " null";
7480 break;
7481
7482 case OSPF_AUTH_SIMPLE:
7483 auth_str = "";
7484 break;
7485
7486 case OSPF_AUTH_CRYPTOGRAPHIC:
7487 auth_str = " message-digest";
7488 break;
7489
7490 default:
7491 auth_str = "";
7492 break;
7493 }
7494
7495 vty_out (vty, " ip ospf authentication%s", auth_str);
7496 if (params != IF_DEF_PARAMS (ifp))
7497 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7498 vty_out (vty, "%s", VTY_NEWLINE);
7499 }
7500
7501 /* Simple Authentication Password print. */
7502 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7503 params->auth_simple[0] != '\0')
7504 {
7505 vty_out (vty, " ip ospf authentication-key %s",
7506 params->auth_simple);
7507 if (params != IF_DEF_PARAMS (ifp))
7508 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7509 vty_out (vty, "%s", VTY_NEWLINE);
7510 }
7511
7512 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007513 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007514 {
paul718e3742002-12-13 20:15:29 +00007515 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7516 ck->key_id, ck->auth_key);
7517 if (params != IF_DEF_PARAMS (ifp))
7518 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7519 vty_out (vty, "%s", VTY_NEWLINE);
7520 }
7521
7522 /* Interface Output Cost print. */
7523 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7524 {
7525 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7526 if (params != IF_DEF_PARAMS (ifp))
7527 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7528 vty_out (vty, "%s", VTY_NEWLINE);
7529 }
7530
7531 /* Hello Interval print. */
7532 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7533 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7534 {
7535 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7536 if (params != IF_DEF_PARAMS (ifp))
7537 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7538 vty_out (vty, "%s", VTY_NEWLINE);
7539 }
7540
7541
7542 /* Router Dead Interval print. */
7543 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7544 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7545 {
paulf9ad9372005-10-21 00:45:17 +00007546 vty_out (vty, " ip ospf dead-interval ");
7547
7548 /* fast hello ? */
7549 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7550 vty_out (vty, "minimal hello-multiplier %d",
7551 params->fast_hello);
7552 else
7553 vty_out (vty, "%u", params->v_wait);
7554
paul718e3742002-12-13 20:15:29 +00007555 if (params != IF_DEF_PARAMS (ifp))
7556 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7557 vty_out (vty, "%s", VTY_NEWLINE);
7558 }
7559
7560 /* Router Priority print. */
7561 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7562 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7563 {
7564 vty_out (vty, " ip ospf priority %u", params->priority);
7565 if (params != IF_DEF_PARAMS (ifp))
7566 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7567 vty_out (vty, "%s", VTY_NEWLINE);
7568 }
7569
7570 /* Retransmit Interval print. */
7571 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7572 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7573 {
7574 vty_out (vty, " ip ospf retransmit-interval %u",
7575 params->retransmit_interval);
7576 if (params != IF_DEF_PARAMS (ifp))
7577 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7578 vty_out (vty, "%s", VTY_NEWLINE);
7579 }
7580
7581 /* Transmit Delay print. */
7582 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7583 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7584 {
7585 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7586 if (params != IF_DEF_PARAMS (ifp))
7587 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7588 vty_out (vty, "%s", VTY_NEWLINE);
7589 }
7590
vincentba682532005-09-29 13:52:57 +00007591 /* MTU ignore print. */
7592 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7593 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7594 {
7595 if (params->mtu_ignore == 0)
7596 vty_out (vty, " no ip ospf mtu-ignore");
7597 else
7598 vty_out (vty, " ip ospf mtu-ignore");
7599 if (params != IF_DEF_PARAMS (ifp))
7600 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7601 vty_out (vty, "%s", VTY_NEWLINE);
7602 }
7603
7604
paul718e3742002-12-13 20:15:29 +00007605 while (1)
7606 {
7607 if (rn == NULL)
7608 rn = route_top (IF_OIFS_PARAMS (ifp));
7609 else
7610 rn = route_next (rn);
7611
7612 if (rn == NULL)
7613 break;
7614 params = rn->info;
7615 if (params != NULL)
7616 break;
7617 }
7618 } while (rn);
7619
7620#ifdef HAVE_OPAQUE_LSA
7621 ospf_opaque_config_write_if (vty, ifp);
7622#endif /* HAVE_OPAQUE_LSA */
7623 }
7624
7625 return write;
7626}
7627
paul4dadc292005-05-06 21:37:42 +00007628static int
paul68980082003-03-25 05:07:42 +00007629config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007630{
7631 struct route_node *rn;
7632 u_char buf[INET_ADDRSTRLEN];
7633
7634 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007635 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007636 if (rn->info)
7637 {
7638 struct ospf_network *n = rn->info;
7639
7640 memset (buf, 0, INET_ADDRSTRLEN);
7641
7642 /* Create Area ID string by specified Area ID format. */
7643 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007644 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007645 else
hassoc9e52be2004-09-26 16:09:34 +00007646 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007647 (unsigned long int) ntohl (n->area_id.s_addr));
7648
7649 /* Network print. */
7650 vty_out (vty, " network %s/%d area %s%s",
7651 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7652 buf, VTY_NEWLINE);
7653 }
7654
7655 return 0;
7656}
7657
paul4dadc292005-05-06 21:37:42 +00007658static int
paul68980082003-03-25 05:07:42 +00007659config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007660{
hasso52dc7ee2004-09-23 19:18:23 +00007661 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007662 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007663 u_char buf[INET_ADDRSTRLEN];
7664
7665 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007666 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007667 {
paul718e3742002-12-13 20:15:29 +00007668 struct route_node *rn1;
7669
hassoc9e52be2004-09-26 16:09:34 +00007670 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007671
7672 if (area->auth_type != OSPF_AUTH_NULL)
7673 {
7674 if (area->auth_type == OSPF_AUTH_SIMPLE)
7675 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7676 else
7677 vty_out (vty, " area %s authentication message-digest%s",
7678 buf, VTY_NEWLINE);
7679 }
7680
7681 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7682 vty_out (vty, " area %s shortcut %s%s", buf,
7683 ospf_shortcut_mode_str[area->shortcut_configured],
7684 VTY_NEWLINE);
7685
7686 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007687 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007688 )
7689 {
paulb0a053b2003-06-22 09:04:47 +00007690 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007691 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007692 else if (area->external_routing == OSPF_AREA_NSSA)
7693 {
7694 vty_out (vty, " area %s nssa", buf);
7695 switch (area->NSSATranslatorRole)
7696 {
7697 case OSPF_NSSA_ROLE_NEVER:
7698 vty_out (vty, " translate-never");
7699 break;
7700 case OSPF_NSSA_ROLE_ALWAYS:
7701 vty_out (vty, " translate-always");
7702 break;
7703 case OSPF_NSSA_ROLE_CANDIDATE:
7704 default:
7705 vty_out (vty, " translate-candidate");
7706 }
7707 }
paul718e3742002-12-13 20:15:29 +00007708
7709 if (area->no_summary)
7710 vty_out (vty, " no-summary");
7711
7712 vty_out (vty, "%s", VTY_NEWLINE);
7713
7714 if (area->default_cost != 1)
7715 vty_out (vty, " area %s default-cost %d%s", buf,
7716 area->default_cost, VTY_NEWLINE);
7717 }
7718
7719 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7720 if (rn1->info)
7721 {
7722 struct ospf_area_range *range = rn1->info;
7723
7724 vty_out (vty, " area %s range %s/%d", buf,
7725 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7726
paul6c835672004-10-11 11:00:30 +00007727 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007728 vty_out (vty, " cost %d", range->cost_config);
7729
7730 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7731 vty_out (vty, " not-advertise");
7732
7733 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7734 vty_out (vty, " substitute %s/%d",
7735 inet_ntoa (range->subst_addr), range->subst_masklen);
7736
7737 vty_out (vty, "%s", VTY_NEWLINE);
7738 }
7739
7740 if (EXPORT_NAME (area))
7741 vty_out (vty, " area %s export-list %s%s", buf,
7742 EXPORT_NAME (area), VTY_NEWLINE);
7743
7744 if (IMPORT_NAME (area))
7745 vty_out (vty, " area %s import-list %s%s", buf,
7746 IMPORT_NAME (area), VTY_NEWLINE);
7747
7748 if (PREFIX_NAME_IN (area))
7749 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7750 PREFIX_NAME_IN (area), VTY_NEWLINE);
7751
7752 if (PREFIX_NAME_OUT (area))
7753 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7754 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7755 }
7756
7757 return 0;
7758}
7759
paul4dadc292005-05-06 21:37:42 +00007760static int
paul68980082003-03-25 05:07:42 +00007761config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007762{
7763 struct ospf_nbr_nbma *nbr_nbma;
7764 struct route_node *rn;
7765
7766 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007767 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007768 if ((nbr_nbma = rn->info))
7769 {
7770 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7771
7772 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7773 vty_out (vty, " priority %d", nbr_nbma->priority);
7774
7775 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7776 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7777
7778 vty_out (vty, "%s", VTY_NEWLINE);
7779 }
7780
7781 return 0;
7782}
7783
paul4dadc292005-05-06 21:37:42 +00007784static int
paul68980082003-03-25 05:07:42 +00007785config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007786{
hasso52dc7ee2004-09-23 19:18:23 +00007787 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007788 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007789 u_char buf[INET_ADDRSTRLEN];
7790
7791 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007792 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007793 {
hasso52dc7ee2004-09-23 19:18:23 +00007794 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007795 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007796 struct ospf_interface *oi;
7797
7798 if (vl_data != NULL)
7799 {
7800 memset (buf, 0, INET_ADDRSTRLEN);
7801
7802 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007803 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007804 else
hassoc9e52be2004-09-26 16:09:34 +00007805 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007806 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7807 oi = vl_data->vl_oi;
7808
7809 /* timers */
7810 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7811 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7812 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7813 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7814 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7815 buf,
7816 inet_ntoa (vl_data->vl_peer),
7817 OSPF_IF_PARAM (oi, v_hello),
7818 OSPF_IF_PARAM (oi, retransmit_interval),
7819 OSPF_IF_PARAM (oi, transmit_delay),
7820 OSPF_IF_PARAM (oi, v_wait),
7821 VTY_NEWLINE);
7822 else
7823 vty_out (vty, " area %s virtual-link %s%s", buf,
7824 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7825 /* Auth key */
7826 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7827 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7828 buf,
7829 inet_ntoa (vl_data->vl_peer),
7830 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7831 VTY_NEWLINE);
7832 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007833 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7834 n2, ck))
7835 vty_out (vty, " area %s virtual-link %s"
7836 " message-digest-key %d md5 %s%s",
7837 buf,
7838 inet_ntoa (vl_data->vl_peer),
7839 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007840
7841 }
7842 }
7843
7844 return 0;
7845}
7846
7847
paul4dadc292005-05-06 21:37:42 +00007848static int
paul68980082003-03-25 05:07:42 +00007849config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007850{
7851 int type;
7852
7853 /* redistribute print. */
7854 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7855 if (type != zclient->redist_default && zclient->redist[type])
7856 {
ajsf52d13c2005-10-01 17:38:06 +00007857 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007858 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007859 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007860
paul68980082003-03-25 05:07:42 +00007861 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007862 vty_out (vty, " metric-type 1");
7863
paul020709f2003-04-04 02:44:16 +00007864 if (ROUTEMAP_NAME (ospf, type))
7865 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007866
7867 vty_out (vty, "%s", VTY_NEWLINE);
7868 }
7869
7870 return 0;
7871}
7872
paul4dadc292005-05-06 21:37:42 +00007873static int
paul68980082003-03-25 05:07:42 +00007874config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007875{
paul68980082003-03-25 05:07:42 +00007876 if (ospf->default_metric != -1)
7877 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007878 VTY_NEWLINE);
7879 return 0;
7880}
7881
paul4dadc292005-05-06 21:37:42 +00007882static int
paul68980082003-03-25 05:07:42 +00007883config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007884{
7885 int type;
7886
paul68980082003-03-25 05:07:42 +00007887 if (ospf)
paul718e3742002-12-13 20:15:29 +00007888 {
7889 /* distribute-list print. */
7890 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007891 if (DISTRIBUTE_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +00007892 vty_out (vty, " distribute-list %s out %s%s",
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007893 DISTRIBUTE_NAME (ospf, type),
ajsf52d13c2005-10-01 17:38:06 +00007894 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007895
7896 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007897 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007898 {
paulc42c1772006-01-10 20:36:49 +00007899 vty_out (vty, " default-information originate");
7900 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7901 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007902
paul68980082003-03-25 05:07:42 +00007903 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007904 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007905 ospf->dmetric[DEFAULT_ROUTE].value);
7906 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007907 vty_out (vty, " metric-type 1");
7908
paul020709f2003-04-04 02:44:16 +00007909 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7910 vty_out (vty, " route-map %s",
7911 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007912
7913 vty_out (vty, "%s", VTY_NEWLINE);
7914 }
7915
7916 }
7917
7918 return 0;
7919}
7920
paul4dadc292005-05-06 21:37:42 +00007921static int
paul68980082003-03-25 05:07:42 +00007922config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007923{
7924 struct route_node *rn;
7925 struct ospf_distance *odistance;
7926
paul68980082003-03-25 05:07:42 +00007927 if (ospf->distance_all)
7928 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007929
paul68980082003-03-25 05:07:42 +00007930 if (ospf->distance_intra
7931 || ospf->distance_inter
7932 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007933 {
7934 vty_out (vty, " distance ospf");
7935
paul68980082003-03-25 05:07:42 +00007936 if (ospf->distance_intra)
7937 vty_out (vty, " intra-area %d", ospf->distance_intra);
7938 if (ospf->distance_inter)
7939 vty_out (vty, " inter-area %d", ospf->distance_inter);
7940 if (ospf->distance_external)
7941 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007942
7943 vty_out (vty, "%s", VTY_NEWLINE);
7944 }
7945
paul68980082003-03-25 05:07:42 +00007946 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007947 if ((odistance = rn->info) != NULL)
7948 {
7949 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7950 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7951 odistance->access_list ? odistance->access_list : "",
7952 VTY_NEWLINE);
7953 }
7954 return 0;
7955}
7956
7957/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007958static int
paul718e3742002-12-13 20:15:29 +00007959ospf_config_write (struct vty *vty)
7960{
paul020709f2003-04-04 02:44:16 +00007961 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007962 struct interface *ifp;
7963 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007964 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007965 int write = 0;
7966
paul020709f2003-04-04 02:44:16 +00007967 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007968 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007969 {
7970 /* `router ospf' print. */
7971 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7972
7973 write++;
7974
paul68980082003-03-25 05:07:42 +00007975 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007976 return write;
7977
7978 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007979 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007980 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007981 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007982
7983 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007984 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007985 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007986 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007987
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007988 /* log-adjacency-changes flag print. */
7989 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7990 {
7991 vty_out(vty, " log-adjacency-changes");
7992 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7993 vty_out(vty, " detail");
7994 vty_out(vty, "%s", VTY_NEWLINE);
7995 }
7996
paul718e3742002-12-13 20:15:29 +00007997 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007998 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007999 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
8000
8001 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00008002 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00008003 {
8004 vty_out (vty, "! Important: ensure reference bandwidth "
8005 "is consistent across all routers%s", VTY_NEWLINE);
8006 vty_out (vty, " auto-cost reference-bandwidth %d%s",
8007 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
8008 }
paul718e3742002-12-13 20:15:29 +00008009
8010 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00008011 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00008012 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
8013 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
8014 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00008015 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00008016 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00008017
8018 /* Max-metric router-lsa print */
8019 config_write_stub_router (vty, ospf);
8020
paul718e3742002-12-13 20:15:29 +00008021 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00008022 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00008023 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00008024 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008025
8026 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00008027 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008028
8029 /* passive-interface print. */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008030 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
8031 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
8032
paul1eb8ef22005-04-07 07:30:20 +00008033 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008034 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
8035 && IF_DEF_PARAMS (ifp)->passive_interface !=
8036 ospf->passive_interface_default)
8037 {
8038 vty_out (vty, " %spassive-interface %s%s",
8039 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
8040 ifp->name, VTY_NEWLINE);
8041 }
paul1eb8ef22005-04-07 07:30:20 +00008042 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008043 {
8044 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
8045 continue;
8046 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
8047 passive_interface))
8048 {
8049 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
8050 continue;
8051 }
8052 else if (oi->params->passive_interface == ospf->passive_interface_default)
8053 continue;
8054
8055 vty_out (vty, " %spassive-interface %s %s%s",
8056 oi->params->passive_interface ? "" : "no ",
paul1eb8ef22005-04-07 07:30:20 +00008057 oi->ifp->name,
8058 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008059 }
paul718e3742002-12-13 20:15:29 +00008060
8061 /* Network area print. */
paul68980082003-03-25 05:07:42 +00008062 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008063
8064 /* Area config print. */
paul68980082003-03-25 05:07:42 +00008065 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008066
8067 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00008068 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008069
8070 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00008071 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008072
8073 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00008074 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008075
8076 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00008077 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008078
8079 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00008080 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008081
8082#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00008083 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008084#endif /* HAVE_OPAQUE_LSA */
8085 }
8086
8087 return write;
8088}
8089
8090void
paul4dadc292005-05-06 21:37:42 +00008091ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00008092{
8093 /* "show ip ospf" commands. */
8094 install_element (VIEW_NODE, &show_ip_ospf_cmd);
8095 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
8096
8097 /* "show ip ospf database" commands. */
8098 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
8099 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
8100 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8101 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8102 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
8103 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
8104 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
8105 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
8106 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
8107 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8108 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8109 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
8110 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
8111 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
8112
8113 /* "show ip ospf interface" commands. */
8114 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
8115 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
8116
8117 /* "show ip ospf neighbor" commands. */
8118 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8119 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
8120 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
8121 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8122 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
8123 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
8124 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
8125 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8126 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
8127 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
8128 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8129 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
8130 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
8131 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
8132
8133 /* "show ip ospf route" commands. */
8134 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
8135 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00008136 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
8137 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00008138}
8139
8140
8141/* ospfd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008142static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00008143{
8144 INTERFACE_NODE,
8145 "%s(config-if)# ",
8146 1
8147};
8148
8149/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00008150static void
8151ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00008152{
8153 /* Install interface node. */
8154 install_node (&interface_node, config_write_interface);
8155
8156 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00008157 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008158 install_default (INTERFACE_NODE);
8159
8160 /* "description" commands. */
8161 install_element (INTERFACE_NODE, &interface_desc_cmd);
8162 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
8163
8164 /* "ip ospf authentication" commands. */
8165 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
8166 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
8167 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
8168 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
8169 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
8170 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
8171 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
8172 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
8173 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
8174 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
8175
8176 /* "ip ospf message-digest-key" commands. */
8177 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
8178 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
8179 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8180 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8181
8182 /* "ip ospf cost" commands. */
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008183 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
8184 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008185 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
8186 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008187 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008188 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8189
vincentba682532005-09-29 13:52:57 +00008190 /* "ip ospf mtu-ignore" commands. */
8191 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8192 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8193 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8194 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8195
paul718e3742002-12-13 20:15:29 +00008196 /* "ip ospf dead-interval" commands. */
8197 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8198 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008199 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8200 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00008201 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8202 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008203
paul718e3742002-12-13 20:15:29 +00008204 /* "ip ospf hello-interval" commands. */
8205 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8206 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8207 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8208 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8209
8210 /* "ip ospf network" commands. */
8211 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8212 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8213
8214 /* "ip ospf priority" commands. */
8215 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8216 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8217 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8218 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8219
8220 /* "ip ospf retransmit-interval" commands. */
8221 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8222 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8223 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8224 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8225
8226 /* "ip ospf transmit-delay" commands. */
8227 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8228 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8229 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8230 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8231
8232 /* These commands are compatibitliy for previous version. */
8233 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8234 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8235 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8236 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008237 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
8238 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008239 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008240 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
8241 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008242 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008243 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8244 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8245 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8246 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8247 install_element (INTERFACE_NODE, &ospf_network_cmd);
8248 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8249 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8250 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8251 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8252 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8253 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8254 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8255}
8256
paul4dadc292005-05-06 21:37:42 +00008257static void
8258ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008259{
8260 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8261 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8262 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8263 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8264 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8265 install_element (OSPF_NODE,
8266 &ospf_redistribute_source_metric_type_routemap_cmd);
8267 install_element (OSPF_NODE,
8268 &ospf_redistribute_source_type_metric_routemap_cmd);
8269 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8270 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8271 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8272
8273 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8274
8275 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8276 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8277
8278 install_element (OSPF_NODE,
8279 &ospf_default_information_originate_metric_type_cmd);
8280 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8281 install_element (OSPF_NODE,
8282 &ospf_default_information_originate_type_metric_cmd);
8283 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8284 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8285 install_element (OSPF_NODE,
8286 &ospf_default_information_originate_always_metric_type_cmd);
8287 install_element (OSPF_NODE,
8288 &ospf_default_information_originate_always_metric_cmd);
8289 install_element (OSPF_NODE,
8290 &ospf_default_information_originate_always_cmd);
8291 install_element (OSPF_NODE,
8292 &ospf_default_information_originate_always_type_metric_cmd);
8293 install_element (OSPF_NODE,
8294 &ospf_default_information_originate_always_type_cmd);
8295
8296 install_element (OSPF_NODE,
8297 &ospf_default_information_originate_metric_type_routemap_cmd);
8298 install_element (OSPF_NODE,
8299 &ospf_default_information_originate_metric_routemap_cmd);
8300 install_element (OSPF_NODE,
8301 &ospf_default_information_originate_routemap_cmd);
8302 install_element (OSPF_NODE,
8303 &ospf_default_information_originate_type_metric_routemap_cmd);
8304 install_element (OSPF_NODE,
8305 &ospf_default_information_originate_type_routemap_cmd);
8306 install_element (OSPF_NODE,
8307 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8308 install_element (OSPF_NODE,
8309 &ospf_default_information_originate_always_metric_routemap_cmd);
8310 install_element (OSPF_NODE,
8311 &ospf_default_information_originate_always_routemap_cmd);
8312 install_element (OSPF_NODE,
8313 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8314 install_element (OSPF_NODE,
8315 &ospf_default_information_originate_always_type_routemap_cmd);
8316
8317 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8318
8319 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8320 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8321 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8322
8323 install_element (OSPF_NODE, &ospf_distance_cmd);
8324 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8325 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8326 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8327 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8328 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8329 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8330 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8331 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8332 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8333 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8334 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8335 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8336 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8337 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8338 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8339 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8340 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8341#if 0
8342 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8343 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8344 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8345 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8346#endif /* 0 */
8347}
8348
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008349static struct cmd_node ospf_node =
paul718e3742002-12-13 20:15:29 +00008350{
8351 OSPF_NODE,
8352 "%s(config-router)# ",
8353 1
8354};
8355
8356
8357/* Install OSPF related vty commands. */
8358void
paul4dadc292005-05-06 21:37:42 +00008359ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008360{
8361 /* Install ospf top node. */
8362 install_node (&ospf_node, ospf_config_write);
8363
8364 /* "router ospf" commands. */
8365 install_element (CONFIG_NODE, &router_ospf_cmd);
8366 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8367
8368 install_default (OSPF_NODE);
8369
8370 /* "ospf router-id" commands. */
8371 install_element (OSPF_NODE, &ospf_router_id_cmd);
8372 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008373 install_element (OSPF_NODE, &router_ospf_id_cmd);
8374 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008375
8376 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008377 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8378 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008379 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
paula2c62832003-04-23 17:01:31 +00008380 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8381 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008382 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
paul718e3742002-12-13 20:15:29 +00008383
8384 /* "ospf abr-type" commands. */
8385 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8386 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8387
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008388 /* "ospf log-adjacency-changes" commands. */
8389 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8390 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8391 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8392 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8393
paul718e3742002-12-13 20:15:29 +00008394 /* "ospf rfc1583-compatible" commands. */
8395 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8396 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8397 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8398 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8399
8400 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008401 install_element (OSPF_NODE, &ospf_network_area_cmd);
8402 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008403
8404 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008405 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8406 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8407 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008408
8409 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008410 install_element (OSPF_NODE, &ospf_area_range_cmd);
8411 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8412 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8413 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8414 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8415 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8416 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8417 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8418 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8419 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8420 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008421
8422 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008423 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8424 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008425
paula2c62832003-04-23 17:01:31 +00008426 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8427 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008428
paula2c62832003-04-23 17:01:31 +00008429 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8430 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008431
paula2c62832003-04-23 17:01:31 +00008432 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8433 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008434
paula2c62832003-04-23 17:01:31 +00008435 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8436 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008437
paula2c62832003-04-23 17:01:31 +00008438 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8439 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8440 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008441
paula2c62832003-04-23 17:01:31 +00008442 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8443 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008444
paula2c62832003-04-23 17:01:31 +00008445 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8446 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008447
paula2c62832003-04-23 17:01:31 +00008448 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8449 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8450 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008451
paula2c62832003-04-23 17:01:31 +00008452 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8453 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8454 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008455
8456 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008457 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8458 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8459 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8460 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008461
paul718e3742002-12-13 20:15:29 +00008462 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008463 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8464 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8465 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8466 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8467 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8468 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008469
paula2c62832003-04-23 17:01:31 +00008470 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8471 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008472
paula2c62832003-04-23 17:01:31 +00008473 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8474 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008475
paula2c62832003-04-23 17:01:31 +00008476 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8477 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008478
paula2c62832003-04-23 17:01:31 +00008479 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8480 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008481
paula2c62832003-04-23 17:01:31 +00008482 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8483 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008484
8485 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008486 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8487 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008488 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8489 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8490
paul88d6cf32005-10-29 12:50:09 +00008491 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008492 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8493 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8494 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008495
paul88d6cf32005-10-29 12:50:09 +00008496 /* max-metric commands */
8497 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8498 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8499 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8500 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8501 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8502 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8503
8504 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008505 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8506 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008507
8508 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008509 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8510 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8511 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8512 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8513 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8514 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8515 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8516 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008517
8518 /* Init interface related vty commands. */
8519 ospf_vty_if_init ();
8520
8521 /* Init zebra related vty commands. */
8522 ospf_vty_zebra_init ();
8523}