blob: 59f5fb67ce91791c44feb0b9ee0395f0eb36a3a0 [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 +000096str2distribute_source (const char *str, int *source)
paul718e3742002-12-13 20:15:29 +000097{
98 /* Sanity check. */
99 if (str == NULL)
100 return 0;
101
102 if (strncmp (str, "k", 1) == 0)
103 *source = ZEBRA_ROUTE_KERNEL;
104 else if (strncmp (str, "c", 1) == 0)
105 *source = ZEBRA_ROUTE_CONNECT;
106 else if (strncmp (str, "s", 1) == 0)
107 *source = ZEBRA_ROUTE_STATIC;
108 else if (strncmp (str, "r", 1) == 0)
109 *source = ZEBRA_ROUTE_RIP;
110 else if (strncmp (str, "b", 1) == 0)
111 *source = ZEBRA_ROUTE_BGP;
112 else
113 return 0;
114
115 return 1;
116}
117
paul4dadc292005-05-06 21:37:42 +0000118static int
paul6c835672004-10-11 11:00:30 +0000119str2metric (const char *str, int *metric)
paul718e3742002-12-13 20:15:29 +0000120{
121 /* Sanity check. */
122 if (str == NULL)
123 return 0;
124
125 *metric = strtol (str, NULL, 10);
126 if (*metric < 0 && *metric > 16777214)
127 {
128 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
129 return 0;
130 }
131
132 return 1;
133}
134
paul4dadc292005-05-06 21:37:42 +0000135static int
paul6c835672004-10-11 11:00:30 +0000136str2metric_type (const char *str, int *metric_type)
paul718e3742002-12-13 20:15:29 +0000137{
138 /* Sanity check. */
139 if (str == NULL)
140 return 0;
141
142 if (strncmp (str, "1", 1) == 0)
143 *metric_type = EXTERNAL_METRIC_TYPE_1;
144 else if (strncmp (str, "2", 1) == 0)
145 *metric_type = EXTERNAL_METRIC_TYPE_2;
146 else
147 return 0;
148
149 return 1;
150}
151
152int
153ospf_oi_count (struct interface *ifp)
154{
155 struct route_node *rn;
156 int i = 0;
157
158 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
159 if (rn->info)
160 i++;
161
162 return i;
163}
164
165
166DEFUN (router_ospf,
167 router_ospf_cmd,
168 "router ospf",
169 "Enable a routing process\n"
170 "Start OSPF configuration\n")
171{
172 vty->node = OSPF_NODE;
173 vty->index = ospf_get ();
174
175 return CMD_SUCCESS;
176}
177
178DEFUN (no_router_ospf,
179 no_router_ospf_cmd,
180 "no router ospf",
181 NO_STR
182 "Enable a routing process\n"
183 "Start OSPF configuration\n")
184{
paul020709f2003-04-04 02:44:16 +0000185 struct ospf *ospf;
186
187 ospf = ospf_lookup ();
188 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000189 {
paul020709f2003-04-04 02:44:16 +0000190 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000191 return CMD_WARNING;
192 }
193
paul020709f2003-04-04 02:44:16 +0000194 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000195
196 return CMD_SUCCESS;
197}
198
199DEFUN (ospf_router_id,
200 ospf_router_id_cmd,
201 "ospf router-id A.B.C.D",
202 "OSPF specific commands\n"
203 "router-id for the OSPF process\n"
204 "OSPF router-id in IP address format\n")
205{
paul68980082003-03-25 05:07:42 +0000206 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000207 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000208 int ret;
paul718e3742002-12-13 20:15:29 +0000209
210 ret = inet_aton (argv[0], &router_id);
211 if (!ret)
212 {
213 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
214 return CMD_WARNING;
215 }
216
paul68980082003-03-25 05:07:42 +0000217 ospf->router_id_static = router_id;
paulb29800a2005-11-20 14:50:45 +0000218
219 ospf_router_id_update (ospf);
220
paul718e3742002-12-13 20:15:29 +0000221 return CMD_SUCCESS;
222}
223
224ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000225 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000226 "router-id A.B.C.D",
227 "router-id for the OSPF process\n"
228 "OSPF router-id in IP address format\n")
229
230DEFUN (no_ospf_router_id,
231 no_ospf_router_id_cmd,
232 "no ospf router-id",
233 NO_STR
234 "OSPF specific commands\n"
235 "router-id for the OSPF process\n")
236{
paul68980082003-03-25 05:07:42 +0000237 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000238
paul68980082003-03-25 05:07:42 +0000239 ospf->router_id_static.s_addr = 0;
240
241 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000242
243 return CMD_SUCCESS;
244}
245
246ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000247 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000248 "no router-id",
249 NO_STR
250 "router-id for the OSPF process\n")
251
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000252static void
Andrew J. Schorr43540882006-11-28 16:36:39 +0000253ospf_passive_interface_default (struct ospf *ospf, u_char newval)
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000254{
255 struct listnode *ln;
256 struct interface *ifp;
257 struct ospf_interface *oi;
258
Andrew J. Schorr43540882006-11-28 16:36:39 +0000259 ospf->passive_interface_default = newval;
260
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000261 for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp))
262 {
263 if (ifp &&
264 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
265 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface);
266 }
267 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi))
268 {
269 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
270 UNSET_IF_PARAM (oi->params, passive_interface);
Andrew J. Schorr43540882006-11-28 16:36:39 +0000271 /* update multicast memberships */
272 ospf_if_set_multicast(oi);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000273 }
274}
275
276static void
277ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
278 struct in_addr addr,
279 struct ospf_if_params *params, u_char value)
280{
281 u_char dflt;
282
283 params->passive_interface = value;
284 if (params != IF_DEF_PARAMS (ifp))
285 {
286 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
287 dflt = IF_DEF_PARAMS (ifp)->passive_interface;
288 else
289 dflt = ospf->passive_interface_default;
290
291 if (value != dflt)
292 SET_IF_PARAM (params, passive_interface);
293 else
294 UNSET_IF_PARAM (params, passive_interface);
295
296 ospf_free_if_params (ifp, addr);
297 ospf_if_update_params (ifp, addr);
298 }
299 else
300 {
301 if (value != ospf->passive_interface_default)
302 SET_IF_PARAM (params, passive_interface);
303 else
304 UNSET_IF_PARAM (params, passive_interface);
305 }
306}
307
paula2c62832003-04-23 17:01:31 +0000308DEFUN (ospf_passive_interface,
309 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000310 "passive-interface IFNAME A.B.C.D",
311 "Suppress routing updates on an interface\n"
312 "Interface's name\n")
313{
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000314 struct interface *ifp;
315 struct in_addr addr;
316 int ret;
317 struct ospf_if_params *params;
318 struct route_node *rn;
319 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000320
Andrew J. Schorr43540882006-11-28 16:36:39 +0000321 if (argc == 0)
322 {
323 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
324 return CMD_SUCCESS;
325 }
326
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000327 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000328
329 params = IF_DEF_PARAMS (ifp);
330
Andrew J. Schorr43540882006-11-28 16:36:39 +0000331 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000332 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000333 ret = inet_aton(argv[1], &addr);
334 if (!ret)
335 {
336 vty_out (vty, "Please specify interface address by A.B.C.D%s",
337 VTY_NEWLINE);
338 return CMD_WARNING;
339 }
paul718e3742002-12-13 20:15:29 +0000340
Andrew J. Schorr43540882006-11-28 16:36:39 +0000341 params = ospf_get_if_params (ifp, addr);
342 ospf_if_update_params (ifp, addr);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000343 }
Andrew J. Schorr43540882006-11-28 16:36:39 +0000344 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE);
345
ajsba6454e2005-02-08 15:37:30 +0000346 /* XXX We should call ospf_if_set_multicast on exactly those
347 * interfaces for which the passive property changed. It is too much
348 * work to determine this set, so we do this for every interface.
349 * This is safe and reasonable because ospf_if_set_multicast uses a
350 * record of joined groups to avoid systems calls if the desired
351 * memberships match the current memership.
352 */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000353
ajsba6454e2005-02-08 15:37:30 +0000354 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
355 {
356 struct ospf_interface *oi = rn->info;
357
358 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
Andrew J. Schorr43540882006-11-28 16:36:39 +0000359 ospf_if_set_multicast(oi);
ajsba6454e2005-02-08 15:37:30 +0000360 }
361 /*
362 * XXX It is not clear what state transitions the interface needs to
363 * undergo when going from active to passive. Fixing this will
364 * require precise identification of interfaces having such a
365 * transition.
366 */
367
paul718e3742002-12-13 20:15:29 +0000368 return CMD_SUCCESS;
369}
370
paula2c62832003-04-23 17:01:31 +0000371ALIAS (ospf_passive_interface,
372 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000373 "passive-interface IFNAME",
374 "Suppress routing updates on an interface\n"
375 "Interface's name\n")
376
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000377ALIAS (ospf_passive_interface,
378 ospf_passive_interface_default_cmd,
379 "passive-interface default",
380 "Suppress routing updates on an interface\n"
381 "Suppress routing updates on interfaces by default\n")
382
paula2c62832003-04-23 17:01:31 +0000383DEFUN (no_ospf_passive_interface,
384 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000385 "no passive-interface IFNAME A.B.C.D",
386 NO_STR
387 "Allow routing updates on an interface\n"
388 "Interface's name\n")
389{
390 struct interface *ifp;
391 struct in_addr addr;
392 struct ospf_if_params *params;
393 int ret;
ajsba6454e2005-02-08 15:37:30 +0000394 struct route_node *rn;
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000395 struct ospf *ospf = vty->index;
Andrew J. Schorr43540882006-11-28 16:36:39 +0000396
397 if (argc == 0)
398 {
399 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
400 return CMD_SUCCESS;
401 }
paul718e3742002-12-13 20:15:29 +0000402
Andrew J. Schorr6e72cb62006-06-18 00:45:48 +0000403 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000404
405 params = IF_DEF_PARAMS (ifp);
406
Andrew J. Schorr43540882006-11-28 16:36:39 +0000407 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000408 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000409 ret = inet_aton(argv[1], &addr);
410 if (!ret)
411 {
412 vty_out (vty, "Please specify interface address by A.B.C.D%s",
413 VTY_NEWLINE);
414 return CMD_WARNING;
415 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000416
Andrew J. Schorr43540882006-11-28 16:36:39 +0000417 params = ospf_lookup_if_params (ifp, addr);
418 if (params == NULL)
419 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000420 }
Andrew J. Schorr43540882006-11-28 16:36:39 +0000421 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE);
ajsba6454e2005-02-08 15:37:30 +0000422
423 /* XXX We should call ospf_if_set_multicast on exactly those
424 * interfaces for which the passive property changed. It is too much
425 * work to determine this set, so we do this for every interface.
426 * This is safe and reasonable because ospf_if_set_multicast uses a
427 * record of joined groups to avoid systems calls if the desired
428 * memberships match the current memership.
429 */
430 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
431 {
432 struct ospf_interface *oi = rn->info;
433
434 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
435 ospf_if_set_multicast(oi);
436 }
437
paul718e3742002-12-13 20:15:29 +0000438 return CMD_SUCCESS;
439}
440
paula2c62832003-04-23 17:01:31 +0000441ALIAS (no_ospf_passive_interface,
442 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000443 "no passive-interface IFNAME",
444 NO_STR
445 "Allow routing updates on an interface\n"
446 "Interface's name\n")
447
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000448ALIAS (no_ospf_passive_interface,
449 no_ospf_passive_interface_default_cmd,
450 "no passive-interface default",
451 NO_STR
452 "Allow routing updates on an interface\n"
453 "Allow routing updates on interfaces by default\n")
454
paula2c62832003-04-23 17:01:31 +0000455DEFUN (ospf_network_area,
456 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000457 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
458 "Enable routing on an IP network\n"
459 "OSPF network prefix\n"
460 "Set the OSPF area ID\n"
461 "OSPF area ID in IP address format\n"
462 "OSPF area ID as a decimal value\n")
463{
464 struct ospf *ospf= vty->index;
465 struct prefix_ipv4 p;
466 struct in_addr area_id;
467 int ret, format;
468
469 /* Get network prefix and Area ID. */
470 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
471 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
472
473 ret = ospf_network_set (ospf, &p, area_id);
474 if (ret == 0)
475 {
476 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
477 return CMD_WARNING;
478 }
479
480 return CMD_SUCCESS;
481}
482
paula2c62832003-04-23 17:01:31 +0000483DEFUN (no_ospf_network_area,
484 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000485 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
486 NO_STR
487 "Enable routing on an IP network\n"
488 "OSPF network prefix\n"
489 "Set the OSPF area ID\n"
490 "OSPF area ID in IP address format\n"
491 "OSPF area ID as a decimal value\n")
492{
493 struct ospf *ospf = (struct ospf *) vty->index;
494 struct prefix_ipv4 p;
495 struct in_addr area_id;
496 int ret, format;
497
498 /* Get network prefix and Area ID. */
499 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
500 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
501
502 ret = ospf_network_unset (ospf, &p, area_id);
503 if (ret == 0)
504 {
505 vty_out (vty, "Can't find specified network area configuration.%s",
506 VTY_NEWLINE);
507 return CMD_WARNING;
508 }
509
510 return CMD_SUCCESS;
511}
512
513
paula2c62832003-04-23 17:01:31 +0000514DEFUN (ospf_area_range,
515 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000516 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
517 "OSPF area parameters\n"
518 "OSPF area ID in IP address format\n"
519 "OSPF area ID as a decimal value\n"
520 "Summarize routes matching address/mask (border routers only)\n"
521 "Area range prefix\n")
522{
523 struct ospf *ospf = vty->index;
524 struct prefix_ipv4 p;
525 struct in_addr area_id;
526 int format;
527 u_int32_t cost;
528
529 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
530 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
531
532 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
533 if (argc > 2)
534 {
paul4dadc292005-05-06 21:37:42 +0000535 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000536 ospf_area_range_cost_set (ospf, area_id, &p, cost);
537 }
538
539 return CMD_SUCCESS;
540}
541
paula2c62832003-04-23 17:01:31 +0000542ALIAS (ospf_area_range,
543 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000544 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
545 "OSPF area parameters\n"
546 "OSPF area ID in IP address format\n"
547 "OSPF area ID as a decimal value\n"
548 "OSPF area range for route advertise (default)\n"
549 "Area range prefix\n"
550 "Advertise this range (default)\n")
551
paula2c62832003-04-23 17:01:31 +0000552ALIAS (ospf_area_range,
553 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000554 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
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 "User specified metric for this range\n"
561 "Advertised metric for this range\n")
562
paula2c62832003-04-23 17:01:31 +0000563ALIAS (ospf_area_range,
564 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000565 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
566 "OSPF area parameters\n"
567 "OSPF area ID in IP address format\n"
568 "OSPF area ID as a decimal value\n"
569 "Summarize routes matching address/mask (border routers only)\n"
570 "Area range prefix\n"
571 "Advertise this range (default)\n"
572 "User specified metric for this range\n"
573 "Advertised metric for this range\n")
574
paula2c62832003-04-23 17:01:31 +0000575DEFUN (ospf_area_range_not_advertise,
576 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000577 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
578 "OSPF area parameters\n"
579 "OSPF area ID in IP address format\n"
580 "OSPF area ID as a decimal value\n"
581 "Summarize routes matching address/mask (border routers only)\n"
582 "Area range prefix\n"
583 "DoNotAdvertise this range\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_set (ospf, area_id, &p, 0);
594
595 return CMD_SUCCESS;
596}
597
paula2c62832003-04-23 17:01:31 +0000598DEFUN (no_ospf_area_range,
599 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000600 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
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{
608 struct ospf *ospf = vty->index;
609 struct prefix_ipv4 p;
610 struct in_addr area_id;
611 int format;
612
613 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
614 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
615
616 ospf_area_range_unset (ospf, area_id, &p);
617
618 return CMD_SUCCESS;
619}
620
paula2c62832003-04-23 17:01:31 +0000621ALIAS (no_ospf_area_range,
622 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000623 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
624 NO_STR
625 "OSPF area parameters\n"
626 "OSPF area ID in IP address format\n"
627 "OSPF area ID as a decimal value\n"
628 "Summarize routes matching address/mask (border routers only)\n"
629 "Area range prefix\n"
630 "Advertise this range (default)\n"
631 "DoNotAdvertise this range\n")
632
paula2c62832003-04-23 17:01:31 +0000633ALIAS (no_ospf_area_range,
634 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000635 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
636 NO_STR
637 "OSPF area parameters\n"
638 "OSPF area ID in IP address format\n"
639 "OSPF area ID as a decimal value\n"
640 "Summarize routes matching address/mask (border routers only)\n"
641 "Area range prefix\n"
642 "User specified metric for this range\n"
643 "Advertised metric for this range\n")
644
paula2c62832003-04-23 17:01:31 +0000645ALIAS (no_ospf_area_range,
646 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000647 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
648 NO_STR
649 "OSPF area parameters\n"
650 "OSPF area ID in IP address format\n"
651 "OSPF area ID as a decimal value\n"
652 "Summarize routes matching address/mask (border routers only)\n"
653 "Area range prefix\n"
654 "Advertise this range (default)\n"
655 "User specified metric for this range\n"
656 "Advertised metric for this range\n")
657
paula2c62832003-04-23 17:01:31 +0000658DEFUN (ospf_area_range_substitute,
659 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000660 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
661 "OSPF area parameters\n"
662 "OSPF area ID in IP address format\n"
663 "OSPF area ID as a decimal value\n"
664 "Summarize routes matching address/mask (border routers only)\n"
665 "Area range prefix\n"
666 "Announce area range as another prefix\n"
667 "Network prefix to be announced instead of range\n")
668{
669 struct ospf *ospf = vty->index;
670 struct prefix_ipv4 p, s;
671 struct in_addr area_id;
672 int format;
673
674 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
675 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
676 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
677
678 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
679
680 return CMD_SUCCESS;
681}
682
paula2c62832003-04-23 17:01:31 +0000683DEFUN (no_ospf_area_range_substitute,
684 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000685 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
686 NO_STR
687 "OSPF area parameters\n"
688 "OSPF area ID in IP address format\n"
689 "OSPF area ID as a decimal value\n"
690 "Summarize routes matching address/mask (border routers only)\n"
691 "Area range prefix\n"
692 "Announce area range as another prefix\n"
693 "Network prefix to be announced instead of range\n")
694{
695 struct ospf *ospf = vty->index;
696 struct prefix_ipv4 p, s;
697 struct in_addr area_id;
698 int format;
699
700 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
701 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
702 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
703
704 ospf_area_range_substitute_unset (ospf, area_id, &p);
705
706 return CMD_SUCCESS;
707}
708
709
710/* Command Handler Logic in VLink stuff is delicate!!
711
712 ALTER AT YOUR OWN RISK!!!!
713
714 Various dummy values are used to represent 'NoChange' state for
715 VLink configuration NOT being changed by a VLink command, and
716 special syntax is used within the command strings so that the
717 typed in command verbs can be seen in the configuration command
718 bacckend handler. This is to drastically reduce the verbeage
719 required to coe up with a reasonably compatible Cisco VLink command
720
721 - Matthew Grant <grantma@anathoth.gen.nz>
722 Wed, 21 Feb 2001 15:13:52 +1300
723 */
724
725
726/* Configuration data for virtual links
727 */
728struct ospf_vl_config_data {
729 struct vty *vty; /* vty stuff */
730 struct in_addr area_id; /* area ID from command line */
731 int format; /* command line area ID format */
732 struct in_addr vl_peer; /* command line vl_peer */
733 int auth_type; /* Authehntication type, if given */
734 char *auth_key; /* simple password if present */
735 int crypto_key_id; /* Cryptographic key ID */
736 char *md5_key; /* MD5 authentication key */
737 int hello_interval; /* Obvious what these are... */
738 int retransmit_interval;
739 int transmit_delay;
740 int dead_interval;
741};
742
paul4dadc292005-05-06 21:37:42 +0000743static void
paul718e3742002-12-13 20:15:29 +0000744ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
745 struct vty *vty)
746{
747 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
748 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
749 vl_config->vty = vty;
750}
751
paul4dadc292005-05-06 21:37:42 +0000752static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000753ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000754{
755 struct ospf_area *area;
756 struct ospf_vl_data *vl_data;
757 struct vty *vty;
758 struct in_addr area_id;
759
760 vty = vl_config->vty;
761 area_id = vl_config->area_id;
762
763 if (area_id.s_addr == OSPF_AREA_BACKBONE)
764 {
765 vty_out (vty,
766 "Configuring VLs over the backbone is not allowed%s",
767 VTY_NEWLINE);
768 return NULL;
769 }
paul68980082003-03-25 05:07:42 +0000770 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000771
772 if (area->external_routing != OSPF_AREA_DEFAULT)
773 {
774 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
775 vty_out (vty, "Area %s is %s%s",
776 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000777 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000778 VTY_NEWLINE);
779 else
780 vty_out (vty, "Area %ld is %s%s",
781 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000782 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000783 VTY_NEWLINE);
784 return NULL;
785 }
786
Paul Jakma9c27ef92006-05-04 07:32:57 +0000787 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
paul718e3742002-12-13 20:15:29 +0000788 {
789 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
790 if (vl_data->vl_oi == NULL)
791 {
paul68980082003-03-25 05:07:42 +0000792 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
793 ospf_vl_add (ospf, vl_data);
794 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000795 }
796 }
797 return vl_data;
798}
799
800
paul4dadc292005-05-06 21:37:42 +0000801static int
paul718e3742002-12-13 20:15:29 +0000802ospf_vl_set_security (struct ospf_vl_data *vl_data,
803 struct ospf_vl_config_data *vl_config)
804{
805 struct crypt_key *ck;
806 struct vty *vty;
807 struct interface *ifp = vl_data->vl_oi->ifp;
808
809 vty = vl_config->vty;
810
811 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
812 {
813 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
814 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
815 }
816
817 if (vl_config->auth_key)
818 {
819 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000820 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000821 OSPF_AUTH_SIMPLE_SIZE);
822 }
823 else if (vl_config->md5_key)
824 {
825 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
826 != NULL)
827 {
828 vty_out (vty, "OSPF: Key %d already exists%s",
829 vl_config->crypto_key_id, VTY_NEWLINE);
830 return CMD_WARNING;
831 }
832 ck = ospf_crypt_key_new ();
833 ck->key_id = vl_config->crypto_key_id;
834 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000835 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000836
837 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
838 }
839 else if (vl_config->crypto_key_id != 0)
840 {
841 /* Delete a key */
842
843 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
844 vl_config->crypto_key_id) == NULL)
845 {
846 vty_out (vty, "OSPF: Key %d does not exist%s",
847 vl_config->crypto_key_id, VTY_NEWLINE);
848 return CMD_WARNING;
849 }
850
851 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
852
853 }
854
855 return CMD_SUCCESS;
856}
857
paul4dadc292005-05-06 21:37:42 +0000858static int
paul718e3742002-12-13 20:15:29 +0000859ospf_vl_set_timers (struct ospf_vl_data *vl_data,
860 struct ospf_vl_config_data *vl_config)
861{
862 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
863 /* Virtual Link data initialised to defaults, so only set
864 if a value given */
865 if (vl_config->hello_interval)
866 {
867 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
868 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
869 }
870
871 if (vl_config->dead_interval)
872 {
873 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
874 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
875 }
876
877 if (vl_config->retransmit_interval)
878 {
879 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
880 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
881 }
882
883 if (vl_config->transmit_delay)
884 {
885 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
886 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
887 }
888
889 return CMD_SUCCESS;
890}
891
892
893
894/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000895static int
paul68980082003-03-25 05:07:42 +0000896ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000897{
898 struct ospf_vl_data *vl_data;
899 int ret;
900
paul68980082003-03-25 05:07:42 +0000901 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000902 if (!vl_data)
903 return CMD_WARNING;
904
905 /* Process this one first as it can have a fatal result, which can
906 only logically occur if the virtual link exists already
907 Thus a command error does not result in a change to the
908 running configuration such as unexpectedly altered timer
909 values etc.*/
910 ret = ospf_vl_set_security (vl_data, vl_config);
911 if (ret != CMD_SUCCESS)
912 return ret;
913
914 /* Set any time based parameters, these area already range checked */
915
916 ret = ospf_vl_set_timers (vl_data, vl_config);
917 if (ret != CMD_SUCCESS)
918 return ret;
919
920 return CMD_SUCCESS;
921
922}
923
924/* This stuff exists to make specifying all the alias commands A LOT simpler
925 */
926#define VLINK_HELPSTR_IPADDR \
927 "OSPF area parameters\n" \
928 "OSPF area ID in IP address format\n" \
929 "OSPF area ID as a decimal value\n" \
930 "Configure a virtual link\n" \
931 "Router ID of the remote ABR\n"
932
933#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
934 "Enable authentication on this virtual link\n" \
935 "dummy string \n"
936
937#define VLINK_HELPSTR_AUTHTYPE_ALL \
938 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
939 "Use null authentication\n" \
940 "Use message-digest authentication\n"
941
942#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
943 "Time between HELLO packets\n" \
944 "Time between retransmitting lost link state advertisements\n" \
945 "Link state transmit delay\n" \
946 "Interval after which a neighbor is declared dead\n"
947
948#define VLINK_HELPSTR_TIME_PARAM \
949 VLINK_HELPSTR_TIME_PARAM_NOSECS \
950 "Seconds\n"
951
952#define VLINK_HELPSTR_AUTH_SIMPLE \
953 "Authentication password (key)\n" \
954 "The OSPF password (key)"
955
956#define VLINK_HELPSTR_AUTH_MD5 \
957 "Message digest authentication password (key)\n" \
958 "dummy string \n" \
959 "Key ID\n" \
960 "Use MD5 algorithm\n" \
961 "The OSPF password (key)"
962
paula2c62832003-04-23 17:01:31 +0000963DEFUN (ospf_area_vlink,
964 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000965 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
966 VLINK_HELPSTR_IPADDR)
967{
paul68980082003-03-25 05:07:42 +0000968 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000969 struct ospf_vl_config_data vl_config;
970 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
971 char md5_key[OSPF_AUTH_MD5_SIZE+1];
972 int i;
973 int ret;
974
975 ospf_vl_config_data_init(&vl_config, vty);
976
977 /* Read off first 2 parameters and check them */
978 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
979 if (ret < 0)
980 {
981 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
982 return CMD_WARNING;
983 }
984
985 ret = inet_aton (argv[1], &vl_config.vl_peer);
986 if (! ret)
987 {
988 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
989 VTY_NEWLINE);
990 return CMD_WARNING;
991 }
992
993 if (argc <=2)
994 {
995 /* Thats all folks! - BUGS B. strikes again!!!*/
996
paul68980082003-03-25 05:07:42 +0000997 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000998 }
999
1000 /* Deal with other parameters */
1001 for (i=2; i < argc; i++)
1002 {
1003
1004 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1005
1006 switch (argv[i][0])
1007 {
1008
1009 case 'a':
1010 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1011 {
1012 /* authentication-key - this option can occur anywhere on
1013 command line. At start of command line
1014 must check for authentication option. */
1015 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1016 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
1017 vl_config.auth_key = auth_key;
1018 i++;
1019 }
1020 else if (strncmp (argv[i], "authentication", 14) == 0)
1021 {
1022 /* authentication - this option can only occur at start
1023 of command line */
1024 vl_config.auth_type = OSPF_AUTH_SIMPLE;
1025 if ((i+1) < argc)
1026 {
1027 if (strncmp (argv[i+1], "n", 1) == 0)
1028 {
1029 /* "authentication null" */
1030 vl_config.auth_type = OSPF_AUTH_NULL;
1031 i++;
1032 }
1033 else if (strncmp (argv[i+1], "m", 1) == 0
1034 && strcmp (argv[i+1], "message-digest-") != 0)
1035 {
1036 /* "authentication message-digest" */
1037 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1038 i++;
1039 }
1040 }
1041 }
1042 break;
1043
1044 case 'm':
1045 /* message-digest-key */
1046 i++;
1047 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1048 if (vl_config.crypto_key_id < 0)
1049 return CMD_WARNING;
1050 i++;
1051 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
1052 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
1053 vl_config.md5_key = md5_key;
1054 break;
1055
1056 case 'h':
1057 /* Hello interval */
1058 i++;
1059 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1060 if (vl_config.hello_interval < 0)
1061 return CMD_WARNING;
1062 break;
1063
1064 case 'r':
1065 /* Retransmit Interval */
1066 i++;
1067 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1068 if (vl_config.retransmit_interval < 0)
1069 return CMD_WARNING;
1070 break;
1071
1072 case 't':
1073 /* Transmit Delay */
1074 i++;
1075 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1076 if (vl_config.transmit_delay < 0)
1077 return CMD_WARNING;
1078 break;
1079
1080 case 'd':
1081 /* Dead Interval */
1082 i++;
1083 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1084 if (vl_config.dead_interval < 0)
1085 return CMD_WARNING;
1086 break;
1087 }
1088 }
1089
1090
1091 /* Action configuration */
1092
paul68980082003-03-25 05:07:42 +00001093 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001094
1095}
1096
paula2c62832003-04-23 17:01:31 +00001097DEFUN (no_ospf_area_vlink,
1098 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001099 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1100 NO_STR
1101 VLINK_HELPSTR_IPADDR)
1102{
paul68980082003-03-25 05:07:42 +00001103 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001104 struct ospf_area *area;
1105 struct ospf_vl_config_data vl_config;
1106 struct ospf_vl_data *vl_data = NULL;
1107 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1108 int i;
1109 int ret, format;
1110
1111 ospf_vl_config_data_init(&vl_config, vty);
1112
1113 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1114 if (ret < 0)
1115 {
1116 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1117 return CMD_WARNING;
1118 }
1119
paul68980082003-03-25 05:07:42 +00001120 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001121 if (!area)
1122 {
1123 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1124 return CMD_WARNING;
1125 }
1126
1127 ret = inet_aton (argv[1], &vl_config.vl_peer);
1128 if (! ret)
1129 {
1130 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1131 VTY_NEWLINE);
1132 return CMD_WARNING;
1133 }
1134
1135 if (argc <=2)
1136 {
1137 /* Basic VLink no command */
1138 /* Thats all folks! - BUGS B. strikes again!!!*/
Paul Jakma9c27ef92006-05-04 07:32:57 +00001139 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001140 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001141
paul68980082003-03-25 05:07:42 +00001142 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001143
1144 return CMD_SUCCESS;
1145 }
1146
1147 /* If we are down here, we are reseting parameters */
1148
1149 /* Deal with other parameters */
1150 for (i=2; i < argc; i++)
1151 {
paul718e3742002-12-13 20:15:29 +00001152 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1153
1154 switch (argv[i][0])
1155 {
1156
1157 case 'a':
1158 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1159 {
1160 /* authentication-key - this option can occur anywhere on
1161 command line. At start of command line
1162 must check for authentication option. */
1163 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1164 vl_config.auth_key = auth_key;
1165 }
1166 else if (strncmp (argv[i], "authentication", 14) == 0)
1167 {
1168 /* authentication - this option can only occur at start
1169 of command line */
1170 vl_config.auth_type = OSPF_AUTH_NOTSET;
1171 }
1172 break;
1173
1174 case 'm':
1175 /* message-digest-key */
1176 /* Delete one key */
1177 i++;
1178 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1179 if (vl_config.crypto_key_id < 0)
1180 return CMD_WARNING;
1181 vl_config.md5_key = NULL;
1182 break;
1183
1184 case 'h':
1185 /* Hello interval */
1186 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1187 break;
1188
1189 case 'r':
1190 /* Retransmit Interval */
1191 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1192 break;
1193
1194 case 't':
1195 /* Transmit Delay */
1196 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1197 break;
1198
1199 case 'd':
1200 /* Dead Interval */
1201 i++;
1202 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1203 break;
1204 }
1205 }
1206
1207
1208 /* Action configuration */
1209
paul68980082003-03-25 05:07:42 +00001210 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001211}
1212
paula2c62832003-04-23 17:01:31 +00001213ALIAS (ospf_area_vlink,
1214 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001215 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1216 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1217 VLINK_HELPSTR_IPADDR
1218 VLINK_HELPSTR_TIME_PARAM)
1219
paula2c62832003-04-23 17:01:31 +00001220ALIAS (no_ospf_area_vlink,
1221 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001222 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1223 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1224 NO_STR
1225 VLINK_HELPSTR_IPADDR
1226 VLINK_HELPSTR_TIME_PARAM)
1227
paula2c62832003-04-23 17:01:31 +00001228ALIAS (ospf_area_vlink,
1229 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001230 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1231 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1232 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1233 VLINK_HELPSTR_IPADDR
1234 VLINK_HELPSTR_TIME_PARAM
1235 VLINK_HELPSTR_TIME_PARAM)
1236
paula2c62832003-04-23 17:01:31 +00001237ALIAS (no_ospf_area_vlink,
1238 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001239 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1240 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1241 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1242 NO_STR
1243 VLINK_HELPSTR_IPADDR
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_param3_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 VLINK_HELPSTR_IPADDR
1254 VLINK_HELPSTR_TIME_PARAM
1255 VLINK_HELPSTR_TIME_PARAM
1256 VLINK_HELPSTR_TIME_PARAM)
1257
paula2c62832003-04-23 17:01:31 +00001258ALIAS (no_ospf_area_vlink,
1259 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001260 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1261 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1262 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1263 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1264 NO_STR
1265 VLINK_HELPSTR_IPADDR
1266 VLINK_HELPSTR_TIME_PARAM
1267 VLINK_HELPSTR_TIME_PARAM
1268 VLINK_HELPSTR_TIME_PARAM)
1269
paula2c62832003-04-23 17:01:31 +00001270ALIAS (ospf_area_vlink,
1271 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001272 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1273 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1274 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1275 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1276 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1277 VLINK_HELPSTR_IPADDR
1278 VLINK_HELPSTR_TIME_PARAM
1279 VLINK_HELPSTR_TIME_PARAM
1280 VLINK_HELPSTR_TIME_PARAM
1281 VLINK_HELPSTR_TIME_PARAM)
1282
paula2c62832003-04-23 17:01:31 +00001283ALIAS (no_ospf_area_vlink,
1284 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001285 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1286 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1287 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1288 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1289 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1290 NO_STR
1291 VLINK_HELPSTR_IPADDR
1292 VLINK_HELPSTR_TIME_PARAM
1293 VLINK_HELPSTR_TIME_PARAM
1294 VLINK_HELPSTR_TIME_PARAM
1295 VLINK_HELPSTR_TIME_PARAM)
1296
paula2c62832003-04-23 17:01:31 +00001297ALIAS (ospf_area_vlink,
1298 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001299 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1300 "(authentication|) (message-digest|null)",
1301 VLINK_HELPSTR_IPADDR
1302 VLINK_HELPSTR_AUTHTYPE_ALL)
1303
paula2c62832003-04-23 17:01:31 +00001304ALIAS (ospf_area_vlink,
1305 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001306 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1307 "(authentication|)",
1308 VLINK_HELPSTR_IPADDR
1309 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1310
paula2c62832003-04-23 17:01:31 +00001311ALIAS (no_ospf_area_vlink,
1312 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001313 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1314 "(authentication|)",
1315 NO_STR
1316 VLINK_HELPSTR_IPADDR
1317 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1318
paula2c62832003-04-23 17:01:31 +00001319ALIAS (ospf_area_vlink,
1320 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001321 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1322 "(message-digest-key|) <1-255> md5 KEY",
1323 VLINK_HELPSTR_IPADDR
1324 VLINK_HELPSTR_AUTH_MD5)
1325
paula2c62832003-04-23 17:01:31 +00001326ALIAS (no_ospf_area_vlink,
1327 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001328 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1329 "(message-digest-key|) <1-255>",
1330 NO_STR
1331 VLINK_HELPSTR_IPADDR
1332 VLINK_HELPSTR_AUTH_MD5)
1333
paula2c62832003-04-23 17:01:31 +00001334ALIAS (ospf_area_vlink,
1335 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001336 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1337 "(authentication-key|) AUTH_KEY",
1338 VLINK_HELPSTR_IPADDR
1339 VLINK_HELPSTR_AUTH_SIMPLE)
1340
paula2c62832003-04-23 17:01:31 +00001341ALIAS (no_ospf_area_vlink,
1342 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001343 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1344 "(authentication-key|)",
1345 NO_STR
1346 VLINK_HELPSTR_IPADDR
1347 VLINK_HELPSTR_AUTH_SIMPLE)
1348
paula2c62832003-04-23 17:01:31 +00001349ALIAS (ospf_area_vlink,
1350 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001351 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1352 "(authentication|) (message-digest|null) "
1353 "(authentication-key|) AUTH_KEY",
1354 VLINK_HELPSTR_IPADDR
1355 VLINK_HELPSTR_AUTHTYPE_ALL
1356 VLINK_HELPSTR_AUTH_SIMPLE)
1357
paula2c62832003-04-23 17:01:31 +00001358ALIAS (ospf_area_vlink,
1359 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001360 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1361 "(authentication|) "
1362 "(authentication-key|) AUTH_KEY",
1363 VLINK_HELPSTR_IPADDR
1364 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1365 VLINK_HELPSTR_AUTH_SIMPLE)
1366
paula2c62832003-04-23 17:01:31 +00001367ALIAS (no_ospf_area_vlink,
1368 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001369 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1370 "(authentication|) "
1371 "(authentication-key|)",
1372 NO_STR
1373 VLINK_HELPSTR_IPADDR
1374 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1375 VLINK_HELPSTR_AUTH_SIMPLE)
1376
paula2c62832003-04-23 17:01:31 +00001377ALIAS (ospf_area_vlink,
1378 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001379 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1380 "(authentication|) (message-digest|null) "
1381 "(message-digest-key|) <1-255> md5 KEY",
1382 VLINK_HELPSTR_IPADDR
1383 VLINK_HELPSTR_AUTHTYPE_ALL
1384 VLINK_HELPSTR_AUTH_MD5)
1385
paula2c62832003-04-23 17:01:31 +00001386ALIAS (ospf_area_vlink,
1387 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001388 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1389 "(authentication|) "
1390 "(message-digest-key|) <1-255> md5 KEY",
1391 VLINK_HELPSTR_IPADDR
1392 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1393 VLINK_HELPSTR_AUTH_MD5)
1394
paula2c62832003-04-23 17:01:31 +00001395ALIAS (no_ospf_area_vlink,
1396 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001397 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1398 "(authentication|) "
1399 "(message-digest-key|)",
1400 NO_STR
1401 VLINK_HELPSTR_IPADDR
1402 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1403 VLINK_HELPSTR_AUTH_MD5)
1404
1405
paula2c62832003-04-23 17:01:31 +00001406DEFUN (ospf_area_shortcut,
1407 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001408 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1409 "OSPF area parameters\n"
1410 "OSPF area ID in IP address format\n"
1411 "OSPF area ID as a decimal value\n"
1412 "Configure the area's shortcutting mode\n"
1413 "Set default shortcutting behavior\n"
1414 "Enable shortcutting through the area\n"
1415 "Disable shortcutting through the area\n")
1416{
paul68980082003-03-25 05:07:42 +00001417 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001418 struct ospf_area *area;
1419 struct in_addr area_id;
1420 int mode;
1421 int format;
1422
1423 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1424
paul68980082003-03-25 05:07:42 +00001425 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001426
1427 if (strncmp (argv[1], "de", 2) == 0)
1428 mode = OSPF_SHORTCUT_DEFAULT;
1429 else if (strncmp (argv[1], "di", 2) == 0)
1430 mode = OSPF_SHORTCUT_DISABLE;
1431 else if (strncmp (argv[1], "e", 1) == 0)
1432 mode = OSPF_SHORTCUT_ENABLE;
1433 else
1434 return CMD_WARNING;
1435
paul68980082003-03-25 05:07:42 +00001436 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001437
paul68980082003-03-25 05:07:42 +00001438 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001439 vty_out (vty, "Shortcut area setting will take effect "
1440 "only when the router is configured as Shortcut ABR%s",
1441 VTY_NEWLINE);
1442
1443 return CMD_SUCCESS;
1444}
1445
paula2c62832003-04-23 17:01:31 +00001446DEFUN (no_ospf_area_shortcut,
1447 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001448 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1449 NO_STR
1450 "OSPF area parameters\n"
1451 "OSPF area ID in IP address format\n"
1452 "OSPF area ID as a decimal value\n"
1453 "Deconfigure the area's shortcutting mode\n"
1454 "Deconfigure enabled shortcutting through the area\n"
1455 "Deconfigure disabled shortcutting through the area\n")
1456{
paul68980082003-03-25 05:07:42 +00001457 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001458 struct ospf_area *area;
1459 struct in_addr area_id;
1460 int format;
1461
1462 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1463
paul68980082003-03-25 05:07:42 +00001464 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001465 if (!area)
1466 return CMD_SUCCESS;
1467
paul68980082003-03-25 05:07:42 +00001468 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001469
1470 return CMD_SUCCESS;
1471}
1472
1473
paula2c62832003-04-23 17:01:31 +00001474DEFUN (ospf_area_stub,
1475 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001476 "area (A.B.C.D|<0-4294967295>) stub",
1477 "OSPF area parameters\n"
1478 "OSPF area ID in IP address format\n"
1479 "OSPF area ID as a decimal value\n"
1480 "Configure OSPF area as stub\n")
1481{
1482 struct ospf *ospf = vty->index;
1483 struct in_addr area_id;
1484 int ret, format;
1485
1486 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1487
1488 ret = ospf_area_stub_set (ospf, area_id);
1489 if (ret == 0)
1490 {
1491 vty_out (vty, "First deconfigure all virtual link through this area%s",
1492 VTY_NEWLINE);
1493 return CMD_WARNING;
1494 }
1495
1496 ospf_area_no_summary_unset (ospf, area_id);
1497
1498 return CMD_SUCCESS;
1499}
1500
paula2c62832003-04-23 17:01:31 +00001501DEFUN (ospf_area_stub_no_summary,
1502 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001503 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1504 "OSPF stub parameters\n"
1505 "OSPF area ID in IP address format\n"
1506 "OSPF area ID as a decimal value\n"
1507 "Configure OSPF area as stub\n"
1508 "Do not inject inter-area routes into stub\n")
1509{
1510 struct ospf *ospf = vty->index;
1511 struct in_addr area_id;
1512 int ret, format;
1513
1514 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1515
1516 ret = ospf_area_stub_set (ospf, area_id);
1517 if (ret == 0)
1518 {
paulb0a053b2003-06-22 09:04:47 +00001519 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001520 VTY_NEWLINE);
1521 return CMD_WARNING;
1522 }
1523
1524 ospf_area_no_summary_set (ospf, area_id);
1525
1526 return CMD_SUCCESS;
1527}
1528
paula2c62832003-04-23 17:01:31 +00001529DEFUN (no_ospf_area_stub,
1530 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001531 "no area (A.B.C.D|<0-4294967295>) stub",
1532 NO_STR
1533 "OSPF area parameters\n"
1534 "OSPF area ID in IP address format\n"
1535 "OSPF area ID as a decimal value\n"
1536 "Configure OSPF area as stub\n")
1537{
1538 struct ospf *ospf = vty->index;
1539 struct in_addr area_id;
1540 int format;
1541
1542 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1543
1544 ospf_area_stub_unset (ospf, area_id);
1545 ospf_area_no_summary_unset (ospf, area_id);
1546
1547 return CMD_SUCCESS;
1548}
1549
paula2c62832003-04-23 17:01:31 +00001550DEFUN (no_ospf_area_stub_no_summary,
1551 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001552 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1553 NO_STR
1554 "OSPF area parameters\n"
1555 "OSPF area ID in IP address format\n"
1556 "OSPF area ID as a decimal value\n"
1557 "Configure OSPF area as stub\n"
1558 "Do not inject inter-area routes into area\n")
1559{
1560 struct ospf *ospf = vty->index;
1561 struct in_addr area_id;
1562 int format;
1563
1564 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1565 ospf_area_no_summary_unset (ospf, area_id);
1566
1567 return CMD_SUCCESS;
1568}
1569
paul4dadc292005-05-06 21:37:42 +00001570static int
paul6c835672004-10-11 11:00:30 +00001571ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1572 int nosum)
paul718e3742002-12-13 20:15:29 +00001573{
1574 struct ospf *ospf = vty->index;
1575 struct in_addr area_id;
1576 int ret, format;
1577
1578 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1579
1580 ret = ospf_area_nssa_set (ospf, area_id);
1581 if (ret == 0)
1582 {
1583 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1584 VTY_NEWLINE);
1585 return CMD_WARNING;
1586 }
1587
1588 if (argc > 1)
1589 {
1590 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001591 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001592 OSPF_NSSA_ROLE_CANDIDATE);
1593 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001594 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001595 OSPF_NSSA_ROLE_NEVER);
1596 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001597 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001598 OSPF_NSSA_ROLE_ALWAYS);
1599 }
paulb0a053b2003-06-22 09:04:47 +00001600 else
1601 {
1602 ospf_area_nssa_translator_role_set (ospf, area_id,
1603 OSPF_NSSA_ROLE_CANDIDATE);
1604 }
paul718e3742002-12-13 20:15:29 +00001605
paulb0a053b2003-06-22 09:04:47 +00001606 if (nosum)
paul718e3742002-12-13 20:15:29 +00001607 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001608 else
1609 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001610
paulb0a053b2003-06-22 09:04:47 +00001611 ospf_schedule_abr_task (ospf);
1612
paul718e3742002-12-13 20:15:29 +00001613 return CMD_SUCCESS;
1614}
1615
paulb0a053b2003-06-22 09:04:47 +00001616DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001617 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001618 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001619 "OSPF area parameters\n"
1620 "OSPF area ID in IP address format\n"
1621 "OSPF area ID as a decimal value\n"
1622 "Configure OSPF area as nssa\n"
1623 "Configure NSSA-ABR for translate election (default)\n"
1624 "Configure NSSA-ABR to never translate\n"
1625 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001626 "Do not inject inter-area routes into nssa\n")
1627{
1628 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1629}
paul718e3742002-12-13 20:15:29 +00001630
paulb0a053b2003-06-22 09:04:47 +00001631DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001632 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001633 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1634 "OSPF area parameters\n"
1635 "OSPF area ID in IP address format\n"
1636 "OSPF area ID as a decimal value\n"
1637 "Configure OSPF area as nssa\n"
1638 "Configure NSSA-ABR for translate election (default)\n"
1639 "Configure NSSA-ABR to never translate\n"
1640 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001641{
1642 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1643}
1644
1645DEFUN (ospf_area_nssa,
1646 ospf_area_nssa_cmd,
1647 "area (A.B.C.D|<0-4294967295>) nssa",
1648 "OSPF area parameters\n"
1649 "OSPF area ID in IP address format\n"
1650 "OSPF area ID as a decimal value\n"
1651 "Configure OSPF area as nssa\n")
1652{
1653 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1654}
paul718e3742002-12-13 20:15:29 +00001655
paula2c62832003-04-23 17:01:31 +00001656DEFUN (ospf_area_nssa_no_summary,
1657 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001658 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1659 "OSPF area parameters\n"
1660 "OSPF area ID in IP address format\n"
1661 "OSPF area ID as a decimal value\n"
1662 "Configure OSPF area as nssa\n"
1663 "Do not inject inter-area routes into nssa\n")
1664{
paulb0a053b2003-06-22 09:04:47 +00001665 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001666}
1667
paula2c62832003-04-23 17:01:31 +00001668DEFUN (no_ospf_area_nssa,
1669 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001670 "no area (A.B.C.D|<0-4294967295>) nssa",
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{
1677 struct ospf *ospf = vty->index;
1678 struct in_addr area_id;
1679 int format;
1680
1681 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1682
1683 ospf_area_nssa_unset (ospf, area_id);
1684 ospf_area_no_summary_unset (ospf, area_id);
1685
paulb0a053b2003-06-22 09:04:47 +00001686 ospf_schedule_abr_task (ospf);
1687
paul718e3742002-12-13 20:15:29 +00001688 return CMD_SUCCESS;
1689}
1690
paula2c62832003-04-23 17:01:31 +00001691DEFUN (no_ospf_area_nssa_no_summary,
1692 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001693 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1694 NO_STR
1695 "OSPF area parameters\n"
1696 "OSPF area ID in IP address format\n"
1697 "OSPF area ID as a decimal value\n"
1698 "Configure OSPF area as nssa\n"
1699 "Do not inject inter-area routes into nssa\n")
1700{
1701 struct ospf *ospf = vty->index;
1702 struct in_addr area_id;
1703 int format;
1704
1705 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1706 ospf_area_no_summary_unset (ospf, area_id);
1707
1708 return CMD_SUCCESS;
1709}
1710
paula2c62832003-04-23 17:01:31 +00001711DEFUN (ospf_area_default_cost,
1712 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001713 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1714 "OSPF area parameters\n"
1715 "OSPF area ID in IP address format\n"
1716 "OSPF area ID as a decimal value\n"
1717 "Set the summary-default cost of a NSSA or stub area\n"
1718 "Stub's advertised default summary cost\n")
1719{
paul68980082003-03-25 05:07:42 +00001720 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001721 struct ospf_area *area;
1722 struct in_addr area_id;
1723 u_int32_t cost;
1724 int format;
vincentba682532005-09-29 13:52:57 +00001725 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001726
1727 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1728 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1729
paul68980082003-03-25 05:07:42 +00001730 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001731
1732 if (area->external_routing == OSPF_AREA_DEFAULT)
1733 {
1734 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1735 return CMD_WARNING;
1736 }
1737
1738 area->default_cost = cost;
1739
vincentba682532005-09-29 13:52:57 +00001740 p.family = AF_INET;
1741 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1742 p.prefixlen = 0;
1743 if (IS_DEBUG_OSPF_EVENT)
1744 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1745 "announcing 0.0.0.0/0 to area %s",
1746 inet_ntoa (area->area_id));
1747 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1748
paul718e3742002-12-13 20:15:29 +00001749 return CMD_SUCCESS;
1750}
1751
paula2c62832003-04-23 17:01:31 +00001752DEFUN (no_ospf_area_default_cost,
1753 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001754 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1755 NO_STR
1756 "OSPF area parameters\n"
1757 "OSPF area ID in IP address format\n"
1758 "OSPF area ID as a decimal value\n"
1759 "Set the summary-default cost of a NSSA or stub area\n"
1760 "Stub's advertised default summary cost\n")
1761{
paul68980082003-03-25 05:07:42 +00001762 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001763 struct ospf_area *area;
1764 struct in_addr area_id;
1765 u_int32_t cost;
1766 int format;
vincentba682532005-09-29 13:52:57 +00001767 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001768
1769 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1770 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1771
paul68980082003-03-25 05:07:42 +00001772 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001773 if (area == NULL)
1774 return CMD_SUCCESS;
1775
1776 if (area->external_routing == OSPF_AREA_DEFAULT)
1777 {
1778 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1779 return CMD_WARNING;
1780 }
1781
1782 area->default_cost = 1;
1783
vincentba682532005-09-29 13:52:57 +00001784 p.family = AF_INET;
1785 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1786 p.prefixlen = 0;
1787 if (IS_DEBUG_OSPF_EVENT)
1788 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1789 "announcing 0.0.0.0/0 to area %s",
1790 inet_ntoa (area->area_id));
1791 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1792
1793
paul68980082003-03-25 05:07:42 +00001794 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001795
1796 return CMD_SUCCESS;
1797}
1798
paula2c62832003-04-23 17:01:31 +00001799DEFUN (ospf_area_export_list,
1800 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001801 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1802 "OSPF area parameters\n"
1803 "OSPF area ID in IP address format\n"
1804 "OSPF area ID as a decimal value\n"
1805 "Set 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_get (ospf, area_id, format);
1816 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001817
1818 return CMD_SUCCESS;
1819}
1820
paula2c62832003-04-23 17:01:31 +00001821DEFUN (no_ospf_area_export_list,
1822 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001823 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1824 NO_STR
1825 "OSPF area parameters\n"
1826 "OSPF area ID in IP address format\n"
1827 "OSPF area ID as a decimal value\n"
1828 "Unset the filter for networks announced to other areas\n"
1829 "Name of the access-list\n")
1830{
paul68980082003-03-25 05:07:42 +00001831 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001832 struct ospf_area *area;
1833 struct in_addr area_id;
1834 int format;
1835
hasso52930762004-04-19 18:26:53 +00001836 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1837
paul68980082003-03-25 05:07:42 +00001838 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001839 if (area == NULL)
1840 return CMD_SUCCESS;
1841
paul68980082003-03-25 05:07:42 +00001842 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001843
1844 return CMD_SUCCESS;
1845}
1846
1847
paula2c62832003-04-23 17:01:31 +00001848DEFUN (ospf_area_import_list,
1849 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001850 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1851 "OSPF area parameters\n"
1852 "OSPF area ID in IP address format\n"
1853 "OSPF area ID as a decimal value\n"
1854 "Set the filter for networks from other areas announced to the specified one\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_get (ospf, area_id, format);
1865 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001866
1867 return CMD_SUCCESS;
1868}
1869
paula2c62832003-04-23 17:01:31 +00001870DEFUN (no_ospf_area_import_list,
1871 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001872 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1873 NO_STR
1874 "OSPF area parameters\n"
1875 "OSPF area ID in IP address format\n"
1876 "OSPF area ID as a decimal value\n"
1877 "Unset the filter for networks announced to other areas\n"
1878 "Name of the access-list\n")
1879{
paul68980082003-03-25 05:07:42 +00001880 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001881 struct ospf_area *area;
1882 struct in_addr area_id;
1883 int format;
1884
hasso52930762004-04-19 18:26:53 +00001885 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1886
paul68980082003-03-25 05:07:42 +00001887 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001888 if (area == NULL)
1889 return CMD_SUCCESS;
1890
paul68980082003-03-25 05:07:42 +00001891 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001892
1893 return CMD_SUCCESS;
1894}
1895
paula2c62832003-04-23 17:01:31 +00001896DEFUN (ospf_area_filter_list,
1897 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001898 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1899 "OSPF area parameters\n"
1900 "OSPF area ID in IP address format\n"
1901 "OSPF area ID as a decimal value\n"
1902 "Filter networks between OSPF areas\n"
1903 "Filter prefixes between OSPF areas\n"
1904 "Name of an IP prefix-list\n"
1905 "Filter networks sent to this area\n"
1906 "Filter networks sent from this area\n")
1907{
paul68980082003-03-25 05:07:42 +00001908 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001909 struct ospf_area *area;
1910 struct in_addr area_id;
1911 struct prefix_list *plist;
1912 int format;
1913
1914 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1915
paul68980082003-03-25 05:07:42 +00001916 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001917 plist = prefix_list_lookup (AFI_IP, argv[1]);
1918 if (strncmp (argv[2], "in", 2) == 0)
1919 {
1920 PREFIX_LIST_IN (area) = plist;
1921 if (PREFIX_NAME_IN (area))
1922 free (PREFIX_NAME_IN (area));
1923
1924 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001925 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001926 }
1927 else
1928 {
1929 PREFIX_LIST_OUT (area) = plist;
1930 if (PREFIX_NAME_OUT (area))
1931 free (PREFIX_NAME_OUT (area));
1932
1933 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001934 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001935 }
1936
1937 return CMD_SUCCESS;
1938}
1939
paula2c62832003-04-23 17:01:31 +00001940DEFUN (no_ospf_area_filter_list,
1941 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001942 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1943 NO_STR
1944 "OSPF area parameters\n"
1945 "OSPF area ID in IP address format\n"
1946 "OSPF area ID as a decimal value\n"
1947 "Filter networks between OSPF areas\n"
1948 "Filter prefixes between OSPF areas\n"
1949 "Name of an IP prefix-list\n"
1950 "Filter networks sent to this area\n"
1951 "Filter networks sent from this area\n")
1952{
paul68980082003-03-25 05:07:42 +00001953 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001954 struct ospf_area *area;
1955 struct in_addr area_id;
1956 struct prefix_list *plist;
1957 int format;
1958
1959 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1960
Paul Jakma1a8ec2b2006-05-11 13:34:08 +00001961 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1962 return CMD_SUCCESS;
1963
paul718e3742002-12-13 20:15:29 +00001964 plist = prefix_list_lookup (AFI_IP, argv[1]);
1965 if (strncmp (argv[2], "in", 2) == 0)
1966 {
1967 if (PREFIX_NAME_IN (area))
1968 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1969 return CMD_SUCCESS;
1970
1971 PREFIX_LIST_IN (area) = NULL;
1972 if (PREFIX_NAME_IN (area))
1973 free (PREFIX_NAME_IN (area));
1974
1975 PREFIX_NAME_IN (area) = NULL;
1976
paul68980082003-03-25 05:07:42 +00001977 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001978 }
1979 else
1980 {
1981 if (PREFIX_NAME_OUT (area))
1982 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1983 return CMD_SUCCESS;
1984
1985 PREFIX_LIST_OUT (area) = NULL;
1986 if (PREFIX_NAME_OUT (area))
1987 free (PREFIX_NAME_OUT (area));
1988
1989 PREFIX_NAME_OUT (area) = NULL;
1990
paul68980082003-03-25 05:07:42 +00001991 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001992 }
1993
1994 return CMD_SUCCESS;
1995}
1996
1997
paula2c62832003-04-23 17:01:31 +00001998DEFUN (ospf_area_authentication_message_digest,
1999 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00002000 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
2001 "OSPF area parameters\n"
2002 "Enable authentication\n"
2003 "Use message-digest authentication\n")
2004{
paul68980082003-03-25 05:07:42 +00002005 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002006 struct ospf_area *area;
2007 struct in_addr area_id;
2008 int format;
2009
2010 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2011
paul68980082003-03-25 05:07:42 +00002012 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00002013 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
2014
2015 return CMD_SUCCESS;
2016}
2017
paula2c62832003-04-23 17:01:31 +00002018DEFUN (ospf_area_authentication,
2019 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002020 "area (A.B.C.D|<0-4294967295>) authentication",
2021 "OSPF area parameters\n"
2022 "OSPF area ID in IP address format\n"
2023 "OSPF area ID as a decimal value\n"
2024 "Enable authentication\n")
2025{
paul68980082003-03-25 05:07:42 +00002026 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002027 struct ospf_area *area;
2028 struct in_addr area_id;
2029 int format;
2030
2031 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2032
paul68980082003-03-25 05:07:42 +00002033 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00002034 area->auth_type = OSPF_AUTH_SIMPLE;
2035
2036 return CMD_SUCCESS;
2037}
2038
paula2c62832003-04-23 17:01:31 +00002039DEFUN (no_ospf_area_authentication,
2040 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002041 "no area (A.B.C.D|<0-4294967295>) authentication",
2042 NO_STR
2043 "OSPF area parameters\n"
2044 "OSPF area ID in IP address format\n"
2045 "OSPF area ID as a decimal value\n"
2046 "Enable authentication\n")
2047{
paul68980082003-03-25 05:07:42 +00002048 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002049 struct ospf_area *area;
2050 struct in_addr area_id;
2051 int format;
2052
2053 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2054
paul68980082003-03-25 05:07:42 +00002055 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002056 if (area == NULL)
2057 return CMD_SUCCESS;
2058
2059 area->auth_type = OSPF_AUTH_NULL;
2060
paul68980082003-03-25 05:07:42 +00002061 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002062
2063 return CMD_SUCCESS;
2064}
2065
2066
2067DEFUN (ospf_abr_type,
2068 ospf_abr_type_cmd,
2069 "ospf abr-type (cisco|ibm|shortcut|standard)",
2070 "OSPF specific commands\n"
2071 "Set OSPF ABR type\n"
2072 "Alternative ABR, cisco implementation\n"
2073 "Alternative ABR, IBM implementation\n"
2074 "Shortcut ABR\n"
2075 "Standard behavior (RFC2328)\n")
2076{
paul68980082003-03-25 05:07:42 +00002077 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002078 u_char abr_type = OSPF_ABR_UNKNOWN;
2079
2080 if (strncmp (argv[0], "c", 1) == 0)
2081 abr_type = OSPF_ABR_CISCO;
2082 else if (strncmp (argv[0], "i", 1) == 0)
2083 abr_type = OSPF_ABR_IBM;
2084 else if (strncmp (argv[0], "sh", 2) == 0)
2085 abr_type = OSPF_ABR_SHORTCUT;
2086 else if (strncmp (argv[0], "st", 2) == 0)
2087 abr_type = OSPF_ABR_STAND;
2088 else
2089 return CMD_WARNING;
2090
2091 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002092 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002093 {
paul68980082003-03-25 05:07:42 +00002094 ospf->abr_type = abr_type;
2095 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002096 }
2097
2098 return CMD_SUCCESS;
2099}
2100
2101DEFUN (no_ospf_abr_type,
2102 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002103 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002104 NO_STR
2105 "OSPF specific commands\n"
2106 "Set OSPF ABR type\n"
2107 "Alternative ABR, cisco implementation\n"
2108 "Alternative ABR, IBM implementation\n"
2109 "Shortcut ABR\n")
2110{
paul68980082003-03-25 05:07:42 +00002111 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002112 u_char abr_type = OSPF_ABR_UNKNOWN;
2113
2114 if (strncmp (argv[0], "c", 1) == 0)
2115 abr_type = OSPF_ABR_CISCO;
2116 else if (strncmp (argv[0], "i", 1) == 0)
2117 abr_type = OSPF_ABR_IBM;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002118 else if (strncmp (argv[0], "sh", 2) == 0)
paul718e3742002-12-13 20:15:29 +00002119 abr_type = OSPF_ABR_SHORTCUT;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002120 else if (strncmp (argv[0], "st", 2) == 0)
2121 abr_type = OSPF_ABR_STAND;
paul718e3742002-12-13 20:15:29 +00002122 else
2123 return CMD_WARNING;
2124
2125 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002126 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002127 {
pauld57834f2005-07-12 20:04:22 +00002128 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002129 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002130 }
2131
2132 return CMD_SUCCESS;
2133}
2134
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002135DEFUN (ospf_log_adjacency_changes,
2136 ospf_log_adjacency_changes_cmd,
2137 "log-adjacency-changes",
2138 "Log changes in adjacency state\n")
2139{
2140 struct ospf *ospf = vty->index;
2141
2142 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2143 return CMD_SUCCESS;
2144}
2145
2146DEFUN (ospf_log_adjacency_changes_detail,
2147 ospf_log_adjacency_changes_detail_cmd,
2148 "log-adjacency-changes detail",
2149 "Log changes in adjacency state\n"
2150 "Log all state changes\n")
2151{
2152 struct ospf *ospf = vty->index;
2153
2154 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2155 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2156 return CMD_SUCCESS;
2157}
2158
2159DEFUN (no_ospf_log_adjacency_changes,
2160 no_ospf_log_adjacency_changes_cmd,
2161 "no log-adjacency-changes",
2162 NO_STR
2163 "Log changes in adjacency state\n")
2164{
2165 struct ospf *ospf = vty->index;
2166
2167 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2168 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2169 return CMD_SUCCESS;
2170}
2171
2172DEFUN (no_ospf_log_adjacency_changes_detail,
2173 no_ospf_log_adjacency_changes_detail_cmd,
2174 "no log-adjacency-changes detail",
2175 NO_STR
2176 "Log changes in adjacency state\n"
2177 "Log all state changes\n")
2178{
2179 struct ospf *ospf = vty->index;
2180
2181 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2182 return CMD_SUCCESS;
2183}
2184
paul718e3742002-12-13 20:15:29 +00002185DEFUN (ospf_compatible_rfc1583,
2186 ospf_compatible_rfc1583_cmd,
2187 "compatible rfc1583",
2188 "OSPF compatibility list\n"
2189 "compatible with RFC 1583\n")
2190{
2191 struct ospf *ospf = vty->index;
2192
2193 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2194 {
2195 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002196 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002197 }
2198 return CMD_SUCCESS;
2199}
2200
2201DEFUN (no_ospf_compatible_rfc1583,
2202 no_ospf_compatible_rfc1583_cmd,
2203 "no compatible rfc1583",
2204 NO_STR
2205 "OSPF compatibility list\n"
2206 "compatible with RFC 1583\n")
2207{
2208 struct ospf *ospf = vty->index;
2209
2210 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2211 {
2212 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002213 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002214 }
2215 return CMD_SUCCESS;
2216}
2217
2218ALIAS (ospf_compatible_rfc1583,
2219 ospf_rfc1583_flag_cmd,
2220 "ospf rfc1583compatibility",
2221 "OSPF specific commands\n"
2222 "Enable the RFC1583Compatibility flag\n")
2223
2224ALIAS (no_ospf_compatible_rfc1583,
2225 no_ospf_rfc1583_flag_cmd,
2226 "no ospf rfc1583compatibility",
2227 NO_STR
2228 "OSPF specific commands\n"
2229 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002230
2231static int
2232ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2233 unsigned int hold,
2234 unsigned int max)
2235{
2236 struct ospf *ospf = vty->index;
2237
2238 ospf->spf_delay = delay;
2239 ospf->spf_holdtime = hold;
2240 ospf->spf_max_holdtime = max;
2241
2242 return CMD_SUCCESS;
2243}
paul718e3742002-12-13 20:15:29 +00002244
pauld24f6e22005-10-21 09:23:12 +00002245DEFUN (ospf_timers_throttle_spf,
2246 ospf_timers_throttle_spf_cmd,
2247 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2248 "Adjust routing timers\n"
2249 "Throttling adaptive timer\n"
2250 "OSPF SPF timers\n"
2251 "Delay (msec) from first change received till SPF calculation\n"
2252 "Initial hold time (msec) between consecutive SPF calculations\n"
2253 "Maximum hold time (msec)\n")
2254{
2255 unsigned int delay, hold, max;
2256
2257 if (argc != 3)
2258 {
2259 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2260 return CMD_WARNING;
2261 }
2262
2263 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2264 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2265 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2266
2267 return ospf_timers_spf_set (vty, delay, hold, max);
2268}
2269
2270DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002271 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002272 "timers spf <0-4294967295> <0-4294967295>",
2273 "Adjust routing timers\n"
2274 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002275 "Delay (s) between receiving a change to SPF calculation\n"
2276 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002277{
pauld24f6e22005-10-21 09:23:12 +00002278 unsigned int delay, hold;
2279
2280 if (argc != 2)
2281 {
2282 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2283 return CMD_WARNING;
2284 }
2285
paul4dadc292005-05-06 21:37:42 +00002286 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2287 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002288
2289 /* truncate down the second values if they're greater than 600000ms */
2290 if (delay > (600000 / 1000))
2291 delay = 600000;
2292 else if (delay == 0)
2293 /* 0s delay was probably specified because of lack of ms resolution */
2294 delay = OSPF_SPF_DELAY_DEFAULT;
2295 if (hold > (600000 / 1000))
2296 hold = 600000;
2297
2298 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002299}
2300
pauld24f6e22005-10-21 09:23:12 +00002301DEFUN (no_ospf_timers_throttle_spf,
2302 no_ospf_timers_throttle_spf_cmd,
2303 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002304 NO_STR
2305 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002306 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002307 "OSPF SPF timers\n")
2308{
pauld24f6e22005-10-21 09:23:12 +00002309 return ospf_timers_spf_set (vty,
2310 OSPF_SPF_DELAY_DEFAULT,
2311 OSPF_SPF_HOLDTIME_DEFAULT,
2312 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002313}
2314
pauld24f6e22005-10-21 09:23:12 +00002315ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2316 no_ospf_timers_spf_cmd,
2317 "no timers spf",
2318 NO_STR
2319 "Adjust routing timers\n"
2320 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002321
paula2c62832003-04-23 17:01:31 +00002322DEFUN (ospf_neighbor,
2323 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002324 "neighbor A.B.C.D",
2325 NEIGHBOR_STR
2326 "Neighbor IP address\n")
2327{
2328 struct ospf *ospf = vty->index;
2329 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002330 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2331 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002332
2333 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2334
2335 if (argc > 1)
2336 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2337
2338 if (argc > 2)
2339 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2340
2341 ospf_nbr_nbma_set (ospf, nbr_addr);
2342 if (argc > 1)
2343 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2344 if (argc > 2)
2345 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2346
2347 return CMD_SUCCESS;
2348}
2349
paula2c62832003-04-23 17:01:31 +00002350ALIAS (ospf_neighbor,
2351 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002352 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2353 NEIGHBOR_STR
2354 "Neighbor IP address\n"
2355 "Neighbor Priority\n"
2356 "Priority\n"
2357 "Dead Neighbor Polling interval\n"
2358 "Seconds\n")
2359
paula2c62832003-04-23 17:01:31 +00002360ALIAS (ospf_neighbor,
2361 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002362 "neighbor A.B.C.D priority <0-255>",
2363 NEIGHBOR_STR
2364 "Neighbor IP address\n"
2365 "Neighbor Priority\n"
2366 "Seconds\n")
2367
paula2c62832003-04-23 17:01:31 +00002368DEFUN (ospf_neighbor_poll_interval,
2369 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002370 "neighbor A.B.C.D poll-interval <1-65535>",
2371 NEIGHBOR_STR
2372 "Neighbor IP address\n"
2373 "Dead Neighbor Polling interval\n"
2374 "Seconds\n")
2375{
2376 struct ospf *ospf = vty->index;
2377 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002378 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2379 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002380
2381 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2382
2383 if (argc > 1)
2384 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2385
2386 if (argc > 2)
2387 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2388
2389 ospf_nbr_nbma_set (ospf, nbr_addr);
2390 if (argc > 1)
2391 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2392 if (argc > 2)
2393 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2394
2395 return CMD_SUCCESS;
2396}
2397
paula2c62832003-04-23 17:01:31 +00002398ALIAS (ospf_neighbor_poll_interval,
2399 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002400 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2401 NEIGHBOR_STR
2402 "Neighbor address\n"
2403 "OSPF dead-router polling interval\n"
2404 "Seconds\n"
2405 "OSPF priority of non-broadcast neighbor\n"
2406 "Priority\n")
2407
paula2c62832003-04-23 17:01:31 +00002408DEFUN (no_ospf_neighbor,
2409 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002410 "no neighbor A.B.C.D",
2411 NO_STR
2412 NEIGHBOR_STR
2413 "Neighbor IP address\n")
2414{
2415 struct ospf *ospf = vty->index;
2416 struct in_addr nbr_addr;
2417 int ret;
2418
2419 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2420
2421 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2422
2423 return CMD_SUCCESS;
2424}
2425
paula2c62832003-04-23 17:01:31 +00002426ALIAS (no_ospf_neighbor,
2427 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002428 "no neighbor A.B.C.D priority <0-255>",
2429 NO_STR
2430 NEIGHBOR_STR
2431 "Neighbor IP address\n"
2432 "Neighbor Priority\n"
2433 "Priority\n")
2434
paula2c62832003-04-23 17:01:31 +00002435ALIAS (no_ospf_neighbor,
2436 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002437 "no neighbor A.B.C.D poll-interval <1-65535>",
2438 NO_STR
2439 NEIGHBOR_STR
2440 "Neighbor IP address\n"
2441 "Dead Neighbor Polling interval\n"
2442 "Seconds\n")
2443
paula2c62832003-04-23 17:01:31 +00002444ALIAS (no_ospf_neighbor,
2445 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002446 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2447 NO_STR
2448 NEIGHBOR_STR
2449 "Neighbor IP address\n"
2450 "Neighbor Priority\n"
2451 "Priority\n"
2452 "Dead Neighbor Polling interval\n"
2453 "Seconds\n")
2454
2455
paula2c62832003-04-23 17:01:31 +00002456DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002457 "refresh timer <10-1800>",
2458 "Adjust refresh parameters\n"
2459 "Set refresh timer\n"
2460 "Timer value in seconds\n")
2461{
2462 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002463 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002464
2465 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2466 interval = (interval / 10) * 10;
2467
2468 ospf_timers_refresh_set (ospf, interval);
2469
2470 return CMD_SUCCESS;
2471}
2472
paula2c62832003-04-23 17:01:31 +00002473DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002474 "no refresh timer <10-1800>",
2475 "Adjust refresh parameters\n"
2476 "Unset refresh timer\n"
2477 "Timer value in seconds\n")
2478{
2479 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002480 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002481
2482 if (argc == 1)
2483 {
2484 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2485
2486 if (ospf->lsa_refresh_interval != interval ||
2487 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2488 return CMD_SUCCESS;
2489 }
2490
2491 ospf_timers_refresh_unset (ospf);
2492
2493 return CMD_SUCCESS;
2494}
2495
paula2c62832003-04-23 17:01:31 +00002496ALIAS (no_ospf_refresh_timer,
2497 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002498 "no refresh timer",
2499 "Adjust refresh parameters\n"
2500 "Unset refresh timer\n")
2501
paula2c62832003-04-23 17:01:31 +00002502DEFUN (ospf_auto_cost_reference_bandwidth,
2503 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002504 "auto-cost reference-bandwidth <1-4294967>",
2505 "Calculate OSPF interface cost according to bandwidth\n"
2506 "Use reference bandwidth method to assign OSPF cost\n"
2507 "The reference bandwidth in terms of Mbits per second\n")
2508{
paul68980082003-03-25 05:07:42 +00002509 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002510 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002511 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002512 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002513
2514 refbw = strtol (argv[0], NULL, 10);
2515 if (refbw < 1 || refbw > 4294967)
2516 {
2517 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2518 return CMD_WARNING;
2519 }
2520
2521 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002522 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002523 return CMD_SUCCESS;
2524
paul68980082003-03-25 05:07:42 +00002525 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002526 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2527 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002528
2529 return CMD_SUCCESS;
2530}
2531
paula2c62832003-04-23 17:01:31 +00002532DEFUN (no_ospf_auto_cost_reference_bandwidth,
2533 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002534 "no auto-cost reference-bandwidth",
2535 NO_STR
2536 "Calculate OSPF interface cost according to bandwidth\n"
2537 "Use reference bandwidth method to assign OSPF cost\n")
2538{
paul68980082003-03-25 05:07:42 +00002539 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002540 struct listnode *node, *nnode;
2541 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002542
paul68980082003-03-25 05:07:42 +00002543 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002544 return CMD_SUCCESS;
2545
paul68980082003-03-25 05:07:42 +00002546 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002547 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2548 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2549
paul1eb8ef22005-04-07 07:30:20 +00002550 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2551 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002552
2553 return CMD_SUCCESS;
2554}
2555
hassoeb1ce602004-10-08 08:17:22 +00002556const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002557{
2558 "Unknown",
2559 "Standard (RFC2328)",
2560 "Alternative IBM",
2561 "Alternative Cisco",
2562 "Alternative Shortcut"
2563};
2564
hassoeb1ce602004-10-08 08:17:22 +00002565const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002566{
2567 "Default",
2568 "Enabled",
2569 "Disabled"
2570};
2571
2572
2573
paul4dadc292005-05-06 21:37:42 +00002574static void
paul718e3742002-12-13 20:15:29 +00002575show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2576{
2577 /* Show Area ID. */
2578 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2579
2580 /* Show Area type/mode. */
2581 if (OSPF_IS_AREA_BACKBONE (area))
2582 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2583 else
2584 {
2585 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002586 vty_out (vty, " (Stub%s%s)",
2587 area->no_summary ? ", no summary" : "",
2588 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002589
paulb0a053b2003-06-22 09:04:47 +00002590 else if (area->external_routing == OSPF_AREA_NSSA)
2591 vty_out (vty, " (NSSA%s%s)",
2592 area->no_summary ? ", no summary" : "",
2593 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002594
2595 vty_out (vty, "%s", VTY_NEWLINE);
2596 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002597 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002598 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002599 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002600 }
2601
2602 /* Show number of interfaces. */
2603 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2604 "Active: %d%s", listcount (area->oiflist),
2605 area->act_ints, VTY_NEWLINE);
2606
paul718e3742002-12-13 20:15:29 +00002607 if (area->external_routing == OSPF_AREA_NSSA)
2608 {
2609 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 +00002610 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002611 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2612 VTY_NEWLINE);
2613 else if (area->NSSATranslatorState)
2614 {
2615 vty_out (vty, " We are an ABR and ");
2616 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2617 vty_out (vty, "the NSSA Elected Translator. %s",
2618 VTY_NEWLINE);
2619 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2620 vty_out (vty, "always an NSSA Translator. %s",
2621 VTY_NEWLINE);
2622 }
paul718e3742002-12-13 20:15:29 +00002623 else
paulb0a053b2003-06-22 09:04:47 +00002624 {
2625 vty_out (vty, " We are an ABR, but ");
2626 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2627 vty_out (vty, "not the NSSA Elected Translator. %s",
2628 VTY_NEWLINE);
2629 else
hassoc6b87812004-12-22 13:09:59 +00002630 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002631 VTY_NEWLINE);
2632 }
paul718e3742002-12-13 20:15:29 +00002633 }
paul88d6cf32005-10-29 12:50:09 +00002634 /* Stub-router state for this area */
2635 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2636 {
ajs649654a2005-11-16 20:17:52 +00002637 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002638 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2639 VTY_NEWLINE);
2640 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2641 vty_out (vty, " Administratively activated (indefinitely)%s",
2642 VTY_NEWLINE);
2643 if (area->t_stub_router)
2644 vty_out (vty, " Active from startup, %s remaining%s",
2645 ospf_timer_dump (area->t_stub_router, timebuf,
2646 sizeof(timebuf)), VTY_NEWLINE);
2647 }
2648
paul718e3742002-12-13 20:15:29 +00002649 /* Show number of fully adjacent neighbors. */
2650 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002651 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002652
2653 /* Show authentication type. */
2654 vty_out (vty, " Area has ");
2655 if (area->auth_type == OSPF_AUTH_NULL)
2656 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2657 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2658 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2659 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2660 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2661
2662 if (!OSPF_IS_AREA_BACKBONE (area))
2663 vty_out (vty, " Number of full virtual adjacencies going through"
2664 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2665
2666 /* Show SPF calculation times. */
2667 vty_out (vty, " SPF algorithm executed %d times%s",
2668 area->spf_calculation, VTY_NEWLINE);
2669
2670 /* Show number of LSA. */
2671 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002672 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2673 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2674 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2675 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2676 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2677 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2678 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2679 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2680 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2681 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2682 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2683 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2684 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2685 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2686 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2687#ifdef HAVE_OPAQUE_LSA
2688 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2689 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2690 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2691 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2692 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2693 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2694#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002695 vty_out (vty, "%s", VTY_NEWLINE);
2696}
2697
2698DEFUN (show_ip_ospf,
2699 show_ip_ospf_cmd,
2700 "show ip ospf",
2701 SHOW_STR
2702 IP_STR
2703 "OSPF information\n")
2704{
paul1eb8ef22005-04-07 07:30:20 +00002705 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002706 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002707 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002708 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002709 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002710
2711 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002712 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002713 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002714 {
2715 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2716 return CMD_SUCCESS;
2717 }
2718
2719 /* Show Router ID. */
2720 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002721 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002722 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002723
2724 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002725 if (ospf->t_deferred_shutdown)
2726 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2727 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002728 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002729 /* Show capability. */
2730 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2731 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2732 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002733 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002734 "enabled" : "disabled", VTY_NEWLINE);
2735#ifdef HAVE_OPAQUE_LSA
2736 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002737 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002738 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002739 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002740 " (origination blocked)" : "",
2741 VTY_NEWLINE);
2742#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002743
2744 /* Show stub-router configuration */
2745 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2746 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2747 {
2748 vty_out (vty, " Stub router advertisement is configured%s",
2749 VTY_NEWLINE);
2750 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2751 vty_out (vty, " Enabled for %us after start-up%s",
2752 ospf->stub_router_startup_time, VTY_NEWLINE);
2753 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2754 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2755 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2756 }
2757
paul718e3742002-12-13 20:15:29 +00002758 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002759 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2760 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2761 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2762 " Hold time multiplier is currently %d%s",
2763 ospf->spf_delay, VTY_NEWLINE,
2764 ospf->spf_holdtime, VTY_NEWLINE,
2765 ospf->spf_max_holdtime, VTY_NEWLINE,
2766 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002767 vty_out (vty, " SPF algorithm ");
2768 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2769 {
Paul Jakma2518efd2006-08-27 06:49:29 +00002770 result = tv_sub (recent_relative_time (), ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002771 vty_out (vty, "last executed %s ago%s",
2772 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2773 VTY_NEWLINE);
2774 }
2775 else
2776 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002777 vty_out (vty, " SPF timer %s%s%s",
2778 (ospf->t_spf_calc ? "due in " : "is "),
2779 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2780 VTY_NEWLINE);
2781
paul718e3742002-12-13 20:15:29 +00002782 /* Show refresh parameters. */
2783 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002784 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002785
2786 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002787 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002788 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002789 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002790
paul68980082003-03-25 05:07:42 +00002791 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002792 vty_out (vty, " This router is an ASBR "
2793 "(injecting external routing information)%s", VTY_NEWLINE);
2794
2795 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002796 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2797 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2798 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2799#ifdef HAVE_OPAQUE_LSA
2800 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2801 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2802 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2803#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002804 /* Show number of areas attached. */
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002805 vty_out (vty, " Number of areas attached to this router: %d%s",
2806 listcount (ospf->areas), VTY_NEWLINE);
2807
2808 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2809 {
2810 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2811 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2812 else
2813 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2814 }
2815
2816 vty_out (vty, "%s",VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002817
2818 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002819 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2820 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002821
2822 return CMD_SUCCESS;
2823}
2824
2825
ajsfd651fa2005-03-29 16:08:16 +00002826static void
paul68980082003-03-25 05:07:42 +00002827show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2828 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002829{
ajsfd651fa2005-03-29 16:08:16 +00002830 int is_up;
paul718e3742002-12-13 20:15:29 +00002831 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002832 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002833
paul718e3742002-12-13 20:15:29 +00002834 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002835 vty_out (vty, "%s is %s%s", ifp->name,
2836 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002837 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2838 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2839 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002840
2841 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002842 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002843 {
2844 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2845 return;
2846 }
ajsfd651fa2005-03-29 16:08:16 +00002847 else if (!is_up)
2848 {
2849 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2850 VTY_NEWLINE);
2851 return;
2852 }
2853
paul718e3742002-12-13 20:15:29 +00002854 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2855 {
2856 struct ospf_interface *oi = rn->info;
2857
2858 if (oi == NULL)
2859 continue;
2860
2861 /* Show OSPF interface information. */
2862 vty_out (vty, " Internet Address %s/%d,",
2863 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2864
Paul Jakma9c27ef92006-05-04 07:32:57 +00002865 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2866 {
2867 struct in_addr *dest;
2868 const char *dstr;
2869
Andrew J. Schorre4529632006-12-12 19:18:21 +00002870 if (CONNECTED_PEER(oi->connected)
2871 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
Paul Jakma9c27ef92006-05-04 07:32:57 +00002872 dstr = "Peer";
2873 else
2874 dstr = "Broadcast";
2875
2876 /* For Vlinks, showing the peer address is probably more
2877 * informative than the local interface that is being used
2878 */
2879 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2880 dest = &oi->vl_data->peer_addr;
2881 else
2882 dest = &oi->connected->destination->u.prefix4;
2883
2884 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2885 }
hasso3fb9cd62004-10-19 19:44:43 +00002886
paul718e3742002-12-13 20:15:29 +00002887 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2888 VTY_NEWLINE);
2889
vincentba682532005-09-29 13:52:57 +00002890 vty_out (vty, " MTU mismatch detection:%s%s",
2891 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2892
paul718e3742002-12-13 20:15:29 +00002893 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002894 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002895 oi->output_cost, VTY_NEWLINE);
2896
2897 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2898 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2899 PRIORITY (oi), VTY_NEWLINE);
2900
2901 /* Show DR information. */
2902 if (DR (oi).s_addr == 0)
2903 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2904 else
2905 {
2906 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2907 if (nbr == NULL)
2908 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2909 else
2910 {
2911 vty_out (vty, " Designated Router (ID) %s,",
2912 inet_ntoa (nbr->router_id));
2913 vty_out (vty, " Interface Address %s%s",
2914 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2915 }
2916 }
2917
2918 /* Show BDR information. */
2919 if (BDR (oi).s_addr == 0)
2920 vty_out (vty, " No backup designated router on this network%s",
2921 VTY_NEWLINE);
2922 else
2923 {
2924 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2925 if (nbr == NULL)
2926 vty_out (vty, " No backup designated router on this network%s",
2927 VTY_NEWLINE);
2928 else
2929 {
2930 vty_out (vty, " Backup Designated Router (ID) %s,",
2931 inet_ntoa (nbr->router_id));
2932 vty_out (vty, " Interface Address %s%s",
2933 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2934 }
2935 }
Paul Jakma7eb5b472009-10-13 16:13:13 +01002936
2937 /* Next network-LSA sequence number we'll use, if we're elected DR */
2938 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
2939 != OSPF_INITIAL_SEQUENCE_NUMBER)
2940 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
2941 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
2942
ajsba6454e2005-02-08 15:37:30 +00002943 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002944 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2945 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2946 {
2947 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2948 vty_out (vty, " OSPFAllRouters");
2949 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2950 vty_out (vty, " OSPFDesignatedRouters");
2951 }
2952 else
ajsba6454e2005-02-08 15:37:30 +00002953 vty_out (vty, " <None>");
2954 vty_out (vty, "%s", VTY_NEWLINE);
2955
paul718e3742002-12-13 20:15:29 +00002956 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002957 vty_out (vty, " Hello ");
2958 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2959 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2960 else
2961 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2962 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2963 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002964 OSPF_IF_PARAM (oi, v_wait),
2965 OSPF_IF_PARAM (oi, retransmit_interval),
2966 VTY_NEWLINE);
2967
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002968 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002969 {
ajs649654a2005-11-16 20:17:52 +00002970 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002971 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002972 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002973 VTY_NEWLINE);
2974 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002975 else /* passive-interface is set */
paul718e3742002-12-13 20:15:29 +00002976 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2977
2978 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002979 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002980 VTY_NEWLINE);
2981 }
2982}
2983
2984DEFUN (show_ip_ospf_interface,
2985 show_ip_ospf_interface_cmd,
2986 "show ip ospf interface [INTERFACE]",
2987 SHOW_STR
2988 IP_STR
2989 "OSPF information\n"
2990 "Interface information\n"
2991 "Interface name\n")
2992{
2993 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002994 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002995 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002996
paul020709f2003-04-04 02:44:16 +00002997 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002998 if (ospf == NULL)
2999 {
3000 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
3001 return CMD_SUCCESS;
3002 }
paul020709f2003-04-04 02:44:16 +00003003
paul718e3742002-12-13 20:15:29 +00003004 /* Show All Interfaces. */
3005 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00003006 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
3007 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00003008 /* Interface name is specified. */
3009 else
3010 {
3011 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
3012 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
3013 else
paul68980082003-03-25 05:07:42 +00003014 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00003015 }
3016
3017 return CMD_SUCCESS;
3018}
3019
paul4dadc292005-05-06 21:37:42 +00003020static void
pauld24f6e22005-10-21 09:23:12 +00003021show_ip_ospf_neighbour_header (struct vty *vty)
3022{
3023 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3024 VTY_NEWLINE,
3025 "Neighbor ID", "Pri", "State", "Dead Time",
3026 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3027 VTY_NEWLINE);
3028}
3029
3030static void
paul718e3742002-12-13 20:15:29 +00003031show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3032{
3033 struct route_node *rn;
3034 struct ospf_neighbor *nbr;
3035 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00003036 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003037
3038 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3039 if ((nbr = rn->info))
3040 /* Do not show myself. */
3041 if (nbr != oi->nbr_self)
3042 /* Down state is not shown. */
3043 if (nbr->state != NSM_Down)
3044 {
3045 ospf_nbr_state_message (nbr, msgbuf, 16);
3046
3047 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00003048 vty_out (vty, "%-15s %3d %-15s ",
3049 "-", nbr->priority,
3050 msgbuf);
3051 else
3052 vty_out (vty, "%-15s %3d %-15s ",
3053 inet_ntoa (nbr->router_id), nbr->priority,
3054 msgbuf);
3055
3056 vty_out (vty, "%9s ",
3057 ospf_timer_dump (nbr->t_inactivity, timebuf,
3058 sizeof(timebuf)));
3059
paul718e3742002-12-13 20:15:29 +00003060 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00003061 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00003062 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3063 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3064 VTY_NEWLINE);
3065 }
3066}
3067
3068DEFUN (show_ip_ospf_neighbor,
3069 show_ip_ospf_neighbor_cmd,
3070 "show ip ospf neighbor",
3071 SHOW_STR
3072 IP_STR
3073 "OSPF information\n"
3074 "Neighbor list\n")
3075{
paul020709f2003-04-04 02:44:16 +00003076 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003077 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003078 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003079
paul020709f2003-04-04 02:44:16 +00003080 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003081 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003082 {
3083 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3084 return CMD_SUCCESS;
3085 }
3086
pauld24f6e22005-10-21 09:23:12 +00003087 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003088
paul1eb8ef22005-04-07 07:30:20 +00003089 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3090 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003091
3092 return CMD_SUCCESS;
3093}
3094
3095DEFUN (show_ip_ospf_neighbor_all,
3096 show_ip_ospf_neighbor_all_cmd,
3097 "show ip ospf neighbor all",
3098 SHOW_STR
3099 IP_STR
3100 "OSPF information\n"
3101 "Neighbor list\n"
3102 "include down status neighbor\n")
3103{
Joakim Tjernlund35f89142008-07-01 16:54:07 +02003104 struct ospf *ospf = ospf_lookup ();
hasso52dc7ee2004-09-23 19:18:23 +00003105 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003106 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003107
paul68980082003-03-25 05:07:42 +00003108 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003109 {
3110 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3111 return CMD_SUCCESS;
3112 }
pauld24f6e22005-10-21 09:23:12 +00003113
3114 show_ip_ospf_neighbour_header (vty);
3115
paul1eb8ef22005-04-07 07:30:20 +00003116 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003117 {
hasso52dc7ee2004-09-23 19:18:23 +00003118 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003119 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003120
3121 show_ip_ospf_neighbor_sub (vty, oi);
3122
3123 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003124 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003125 {
paul718e3742002-12-13 20:15:29 +00003126 if (nbr_nbma->nbr == NULL
3127 || nbr_nbma->nbr->state == NSM_Down)
3128 {
pauld24f6e22005-10-21 09:23:12 +00003129 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003130 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003131 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003132 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3133 0, 0, 0, VTY_NEWLINE);
3134 }
3135 }
3136 }
3137
3138 return CMD_SUCCESS;
3139}
3140
3141DEFUN (show_ip_ospf_neighbor_int,
3142 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003143 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003144 SHOW_STR
3145 IP_STR
3146 "OSPF information\n"
3147 "Neighbor list\n"
3148 "Interface name\n")
3149{
paul020709f2003-04-04 02:44:16 +00003150 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003151 struct interface *ifp;
3152 struct route_node *rn;
3153
3154 ifp = if_lookup_by_name (argv[0]);
3155 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003156 {
hassobb5b7552005-08-21 20:01:15 +00003157 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003158 return CMD_WARNING;
3159 }
3160
paul020709f2003-04-04 02:44:16 +00003161 ospf = ospf_lookup ();
3162 if (ospf == NULL)
3163 {
3164 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3165 return CMD_SUCCESS;
3166 }
pauld24f6e22005-10-21 09:23:12 +00003167
3168 show_ip_ospf_neighbour_header (vty);
3169
hassobb5b7552005-08-21 20:01:15 +00003170 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003171 {
hassobb5b7552005-08-21 20:01:15 +00003172 struct ospf_interface *oi = rn->info;
3173
3174 if (oi == NULL)
3175 continue;
3176
paul718e3742002-12-13 20:15:29 +00003177 show_ip_ospf_neighbor_sub (vty, oi);
3178 }
3179
3180 return CMD_SUCCESS;
3181}
3182
paul4dadc292005-05-06 21:37:42 +00003183static void
paul718e3742002-12-13 20:15:29 +00003184show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3185 struct ospf_nbr_nbma *nbr_nbma)
3186{
ajs649654a2005-11-16 20:17:52 +00003187 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003188
3189 /* Show neighbor ID. */
3190 vty_out (vty, " Neighbor %s,", "-");
3191
3192 /* Show interface address. */
3193 vty_out (vty, " interface address %s%s",
3194 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3195 /* Show Area ID. */
3196 vty_out (vty, " In the area %s via interface %s%s",
3197 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3198 /* Show neighbor priority and state. */
3199 vty_out (vty, " Neighbor priority is %d, State is %s,",
3200 nbr_nbma->priority, "Down");
3201 /* Show state changes. */
3202 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3203
3204 /* Show PollInterval */
3205 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3206
3207 /* Show poll-interval timer. */
3208 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003209 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3210 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003211
3212 /* Show poll-interval timer thread. */
3213 vty_out (vty, " Thread Poll Timer %s%s",
3214 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3215}
3216
paul4dadc292005-05-06 21:37:42 +00003217static void
paul718e3742002-12-13 20:15:29 +00003218show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3219 struct ospf_neighbor *nbr)
3220{
ajs649654a2005-11-16 20:17:52 +00003221 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003222
3223 /* Show neighbor ID. */
3224 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3225 vty_out (vty, " Neighbor %s,", "-");
3226 else
3227 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3228
3229 /* Show interface address. */
3230 vty_out (vty, " interface address %s%s",
3231 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3232 /* Show Area ID. */
3233 vty_out (vty, " In the area %s via interface %s%s",
3234 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3235 /* Show neighbor priority and state. */
3236 vty_out (vty, " Neighbor priority is %d, State is %s,",
3237 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3238 /* Show state changes. */
3239 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
Paul Jakma3fed4162006-07-25 20:44:12 +00003240 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
Paul Jakma90c33172006-07-11 17:57:25 +00003241 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003242 struct timeval res
3243 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003244 vty_out (vty, " Most recent state change statistics:%s",
3245 VTY_NEWLINE);
3246 vty_out (vty, " Progressive change %s ago%s",
Paul Jakma90c33172006-07-11 17:57:25 +00003247 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
Paul Jakma3fed4162006-07-25 20:44:12 +00003248 VTY_NEWLINE);
3249 }
3250 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3251 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003252 struct timeval res
3253 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003254 vty_out (vty, " Regressive change %s ago, due to %s%s",
3255 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3256 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
Paul Jakma90c33172006-07-11 17:57:25 +00003257 VTY_NEWLINE);
3258 }
paul718e3742002-12-13 20:15:29 +00003259 /* Show Designated Rotuer ID. */
3260 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3261 /* Show Backup Designated Rotuer ID. */
3262 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3263 /* Show options. */
3264 vty_out (vty, " Options %d %s%s", nbr->options,
3265 ospf_options_dump (nbr->options), VTY_NEWLINE);
3266 /* Show Router Dead interval timer. */
3267 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003268 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3269 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003270 /* Show Database Summary list. */
3271 vty_out (vty, " Database Summary List %d%s",
3272 ospf_db_summary_count (nbr), VTY_NEWLINE);
3273 /* Show Link State Request list. */
3274 vty_out (vty, " Link State Request List %ld%s",
3275 ospf_ls_request_count (nbr), VTY_NEWLINE);
3276 /* Show Link State Retransmission list. */
3277 vty_out (vty, " Link State Retransmission List %ld%s",
3278 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3279 /* Show inactivity timer thread. */
3280 vty_out (vty, " Thread Inactivity Timer %s%s",
3281 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3282 /* Show Database Description retransmission thread. */
3283 vty_out (vty, " Thread Database Description Retransmision %s%s",
3284 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3285 /* Show Link State Request Retransmission thread. */
3286 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3287 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3288 /* Show Link State Update Retransmission thread. */
3289 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3290 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3291}
3292
3293DEFUN (show_ip_ospf_neighbor_id,
3294 show_ip_ospf_neighbor_id_cmd,
3295 "show ip ospf neighbor A.B.C.D",
3296 SHOW_STR
3297 IP_STR
3298 "OSPF information\n"
3299 "Neighbor list\n"
3300 "Neighbor ID\n")
3301{
paul020709f2003-04-04 02:44:16 +00003302 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003303 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003304 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003305 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003306 struct in_addr router_id;
3307 int ret;
3308
3309 ret = inet_aton (argv[0], &router_id);
3310 if (!ret)
3311 {
3312 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3313 return CMD_WARNING;
3314 }
3315
paul020709f2003-04-04 02:44:16 +00003316 ospf = ospf_lookup ();
3317 if (ospf == NULL)
3318 {
3319 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3320 return CMD_SUCCESS;
3321 }
3322
paul1eb8ef22005-04-07 07:30:20 +00003323 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3324 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003325 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003326
paul718e3742002-12-13 20:15:29 +00003327 return CMD_SUCCESS;
3328}
3329
3330DEFUN (show_ip_ospf_neighbor_detail,
3331 show_ip_ospf_neighbor_detail_cmd,
3332 "show ip ospf neighbor detail",
3333 SHOW_STR
3334 IP_STR
3335 "OSPF information\n"
3336 "Neighbor list\n"
3337 "detail of all neighbors\n")
3338{
paul020709f2003-04-04 02:44:16 +00003339 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003340 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003341 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003342
paul020709f2003-04-04 02:44:16 +00003343 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003344 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003345 {
3346 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3347 return CMD_SUCCESS;
3348 }
paul718e3742002-12-13 20:15:29 +00003349
paul1eb8ef22005-04-07 07:30:20 +00003350 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003351 {
paul718e3742002-12-13 20:15:29 +00003352 struct route_node *rn;
3353 struct ospf_neighbor *nbr;
3354
3355 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3356 if ((nbr = rn->info))
3357 if (nbr != oi->nbr_self)
3358 if (nbr->state != NSM_Down)
3359 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3360 }
3361
3362 return CMD_SUCCESS;
3363}
3364
3365DEFUN (show_ip_ospf_neighbor_detail_all,
3366 show_ip_ospf_neighbor_detail_all_cmd,
3367 "show ip ospf neighbor detail all",
3368 SHOW_STR
3369 IP_STR
3370 "OSPF information\n"
3371 "Neighbor list\n"
3372 "detail of all neighbors\n"
3373 "include down status neighbor\n")
3374{
paul020709f2003-04-04 02:44:16 +00003375 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003376 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003377 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003378
paul020709f2003-04-04 02:44:16 +00003379 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003380 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003381 {
3382 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3383 return CMD_SUCCESS;
3384 }
paul718e3742002-12-13 20:15:29 +00003385
paul1eb8ef22005-04-07 07:30:20 +00003386 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003387 {
paul718e3742002-12-13 20:15:29 +00003388 struct route_node *rn;
3389 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003390 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003391
3392 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3393 if ((nbr = rn->info))
3394 if (nbr != oi->nbr_self)
3395 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3396 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3397
3398 if (oi->type == OSPF_IFTYPE_NBMA)
3399 {
hasso52dc7ee2004-09-23 19:18:23 +00003400 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003401
paul1eb8ef22005-04-07 07:30:20 +00003402 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3403 if (nbr_nbma->nbr == NULL
3404 || nbr_nbma->nbr->state == NSM_Down)
3405 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003406 }
3407 }
3408
3409 return CMD_SUCCESS;
3410}
3411
3412DEFUN (show_ip_ospf_neighbor_int_detail,
3413 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003414 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003415 SHOW_STR
3416 IP_STR
3417 "OSPF information\n"
3418 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003419 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003420 "detail of all neighbors")
3421{
paul020709f2003-04-04 02:44:16 +00003422 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003423 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003424 struct interface *ifp;
3425 struct route_node *rn, *nrn;
3426 struct ospf_neighbor *nbr;
3427
3428 ifp = if_lookup_by_name (argv[0]);
3429 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003430 {
hassobb5b7552005-08-21 20:01:15 +00003431 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003432 return CMD_WARNING;
3433 }
3434
paul020709f2003-04-04 02:44:16 +00003435 ospf = ospf_lookup ();
3436 if (ospf == NULL)
3437 {
3438 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3439 return CMD_SUCCESS;
3440 }
paul68980082003-03-25 05:07:42 +00003441
paul718e3742002-12-13 20:15:29 +00003442
hassobb5b7552005-08-21 20:01:15 +00003443 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3444 if ((oi = rn->info))
3445 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3446 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003447 if (nbr != oi->nbr_self)
3448 if (nbr->state != NSM_Down)
3449 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003450
3451 return CMD_SUCCESS;
3452}
3453
3454
3455/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003456static int
paul020709f2003-04-04 02:44:16 +00003457show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003458{
paul718e3742002-12-13 20:15:29 +00003459 struct router_lsa *rl;
3460 struct summary_lsa *sl;
3461 struct as_external_lsa *asel;
3462 struct prefix_ipv4 p;
3463
3464 if (lsa != NULL)
3465 /* If self option is set, check LSA self flag. */
3466 if (self == 0 || IS_LSA_SELF (lsa))
3467 {
3468 /* LSA common part show. */
3469 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3470 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3471 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3472 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3473 /* LSA specific part show. */
3474 switch (lsa->data->type)
3475 {
3476 case OSPF_ROUTER_LSA:
3477 rl = (struct router_lsa *) lsa->data;
3478 vty_out (vty, " %-d", ntohs (rl->links));
3479 break;
3480 case OSPF_SUMMARY_LSA:
3481 sl = (struct summary_lsa *) lsa->data;
3482
3483 p.family = AF_INET;
3484 p.prefix = sl->header.id;
3485 p.prefixlen = ip_masklen (sl->mask);
3486 apply_mask_ipv4 (&p);
3487
3488 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3489 break;
3490 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003491 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003492 asel = (struct as_external_lsa *) lsa->data;
3493
3494 p.family = AF_INET;
3495 p.prefix = asel->header.id;
3496 p.prefixlen = ip_masklen (asel->mask);
3497 apply_mask_ipv4 (&p);
3498
3499 vty_out (vty, " %s %s/%d [0x%lx]",
3500 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3501 inet_ntoa (p.prefix), p.prefixlen,
3502 (u_long)ntohl (asel->e[0].route_tag));
3503 break;
3504 case OSPF_NETWORK_LSA:
3505 case OSPF_ASBR_SUMMARY_LSA:
3506#ifdef HAVE_OPAQUE_LSA
3507 case OSPF_OPAQUE_LINK_LSA:
3508 case OSPF_OPAQUE_AREA_LSA:
3509 case OSPF_OPAQUE_AS_LSA:
3510#endif /* HAVE_OPAQUE_LSA */
3511 default:
3512 break;
3513 }
3514 vty_out (vty, VTY_NEWLINE);
3515 }
3516
3517 return 0;
3518}
3519
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003520static const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003521{
3522 "unknown",
3523 "Router Link States",
3524 "Net Link States",
3525 "Summary Link States",
3526 "ASBR-Summary Link States",
3527 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003528 "Group Membership LSA",
3529 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003530#ifdef HAVE_OPAQUE_LSA
3531 "Type-8 LSA",
3532 "Link-Local Opaque-LSA",
3533 "Area-Local Opaque-LSA",
3534 "AS-external Opaque-LSA",
3535#endif /* HAVE_OPAQUE_LSA */
3536};
3537
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003538static const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003539{
3540 "",
3541 "Link ID ADV Router Age Seq# CkSum Link count",
3542 "Link ID ADV Router Age Seq# CkSum",
3543 "Link ID ADV Router Age Seq# CkSum Route",
3544 "Link ID ADV Router Age Seq# CkSum",
3545 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003546 " --- header for Group Member ----",
3547 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003548#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003549 " --- type-8 ---",
3550 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3551 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3552 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3553#endif /* HAVE_OPAQUE_LSA */
3554};
3555
paul4dadc292005-05-06 21:37:42 +00003556static void
paul718e3742002-12-13 20:15:29 +00003557show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3558{
3559 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003560
paul718e3742002-12-13 20:15:29 +00003561 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003562 vty_out (vty, " Options: 0x%-2x : %s%s",
3563 lsa->data->options,
3564 ospf_options_dump(lsa->data->options),
3565 VTY_NEWLINE);
3566 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003567 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003568 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3569 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003570
3571 if (lsa->data->type == OSPF_ROUTER_LSA)
3572 {
3573 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3574
3575 if (rlsa->flags)
3576 vty_out (vty, " :%s%s%s%s",
3577 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3578 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3579 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3580 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3581
3582 vty_out (vty, "%s", VTY_NEWLINE);
3583 }
3584 vty_out (vty, " LS Type: %s%s",
3585 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3586 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3587 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3588 vty_out (vty, " Advertising Router: %s%s",
3589 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3590 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3591 VTY_NEWLINE);
3592 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3593 VTY_NEWLINE);
3594 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3595}
3596
hassoeb1ce602004-10-08 08:17:22 +00003597const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003598{
3599 "(null)",
3600 "another Router (point-to-point)",
3601 "a Transit Network",
3602 "Stub Network",
3603 "a Virtual Link",
3604};
3605
hassoeb1ce602004-10-08 08:17:22 +00003606const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003607{
3608 "(null)",
3609 "Neighboring Router ID",
3610 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003611 "Net",
paul718e3742002-12-13 20:15:29 +00003612 "Neighboring Router ID",
3613};
3614
hassoeb1ce602004-10-08 08:17:22 +00003615const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003616{
3617 "(null)",
3618 "Router Interface address",
3619 "Router Interface address",
3620 "Network Mask",
3621 "Router Interface address",
3622};
3623
3624/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003625static void
paul718e3742002-12-13 20:15:29 +00003626show_ip_ospf_database_router_links (struct vty *vty,
3627 struct router_lsa *rl)
3628{
3629 int len, i, type;
3630
3631 len = ntohs (rl->header.length) - 4;
3632 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3633 {
3634 type = rl->link[i].type;
3635
3636 vty_out (vty, " Link connected to: %s%s",
3637 link_type_desc[type], VTY_NEWLINE);
3638 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3639 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3640 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3641 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3642 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3643 vty_out (vty, " TOS 0 Metric: %d%s",
3644 ntohs (rl->link[i].metric), VTY_NEWLINE);
3645 vty_out (vty, "%s", VTY_NEWLINE);
3646 }
3647}
3648
3649/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003650static int
paul718e3742002-12-13 20:15:29 +00003651show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3652{
3653 if (lsa != NULL)
3654 {
3655 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3656
3657 show_ip_ospf_database_header (vty, lsa);
3658
3659 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3660 VTY_NEWLINE, VTY_NEWLINE);
3661
3662 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003663 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003664 }
3665
3666 return 0;
3667}
3668
3669/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003670static int
paul718e3742002-12-13 20:15:29 +00003671show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3672{
3673 int length, i;
3674
3675 if (lsa != NULL)
3676 {
3677 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3678
3679 show_ip_ospf_database_header (vty, lsa);
3680
3681 vty_out (vty, " Network Mask: /%d%s",
3682 ip_masklen (nl->mask), VTY_NEWLINE);
3683
3684 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3685
3686 for (i = 0; length > 0; i++, length -= 4)
3687 vty_out (vty, " Attached Router: %s%s",
3688 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3689
3690 vty_out (vty, "%s", VTY_NEWLINE);
3691 }
3692
3693 return 0;
3694}
3695
3696/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003697static int
paul718e3742002-12-13 20:15:29 +00003698show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3699{
3700 if (lsa != NULL)
3701 {
3702 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3703
3704 show_ip_ospf_database_header (vty, lsa);
3705
3706 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3707 VTY_NEWLINE);
3708 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3709 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003710 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003711 }
3712
3713 return 0;
3714}
3715
3716/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003717static int
paul718e3742002-12-13 20:15:29 +00003718show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3719{
3720 if (lsa != NULL)
3721 {
3722 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3723
3724 show_ip_ospf_database_header (vty, lsa);
3725
3726 vty_out (vty, " Network Mask: /%d%s",
3727 ip_masklen (sl->mask), VTY_NEWLINE);
3728 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3729 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003730 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003731 }
3732
3733 return 0;
3734}
3735
3736/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003737static int
paul718e3742002-12-13 20:15:29 +00003738show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3739{
3740 if (lsa != NULL)
3741 {
3742 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3743
3744 show_ip_ospf_database_header (vty, lsa);
3745
3746 vty_out (vty, " Network Mask: /%d%s",
3747 ip_masklen (al->mask), VTY_NEWLINE);
3748 vty_out (vty, " Metric Type: %s%s",
3749 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3750 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3751 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3752 vty_out (vty, " Metric: %d%s",
3753 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3754 vty_out (vty, " Forward Address: %s%s",
3755 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3756
3757 vty_out (vty, " External Route Tag: %lu%s%s",
3758 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3759 }
3760
3761 return 0;
3762}
3763
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003764#if 0
paul4dadc292005-05-06 21:37:42 +00003765static int
paul718e3742002-12-13 20:15:29 +00003766show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3767{
3768 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3769
3770 /* show_ip_ospf_database_header (vty, lsa); */
3771
ajs2a42e282004-12-08 18:43:03 +00003772 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003773 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003774 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003775 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3776 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003777 zlog_debug( " TOS: 0%s", "\n");
3778 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003779 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003780 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003781 inet_ntoa (al->e[0].fwd_addr), "\n");
3782
ajs2a42e282004-12-08 18:43:03 +00003783 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003784 ntohl (al->e[0].route_tag), "\n", "\n");
3785
3786 return 0;
3787}
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003788#endif
paul718e3742002-12-13 20:15:29 +00003789
3790/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003791static int
paul718e3742002-12-13 20:15:29 +00003792show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3793{
3794 if (lsa != NULL)
3795 {
3796 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3797
3798 show_ip_ospf_database_header (vty, lsa);
3799
3800 vty_out (vty, " Network Mask: /%d%s",
3801 ip_masklen (al->mask), VTY_NEWLINE);
3802 vty_out (vty, " Metric Type: %s%s",
3803 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3804 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3805 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3806 vty_out (vty, " Metric: %d%s",
3807 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3808 vty_out (vty, " NSSA: Forward Address: %s%s",
3809 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3810
3811 vty_out (vty, " External Route Tag: %u%s%s",
3812 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3813 }
3814
3815 return 0;
3816}
3817
paul4dadc292005-05-06 21:37:42 +00003818static int
paul718e3742002-12-13 20:15:29 +00003819show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3820{
3821 return 0;
3822}
3823
3824#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003825static int
paul718e3742002-12-13 20:15:29 +00003826show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3827{
3828 if (lsa != NULL)
3829 {
3830 show_ip_ospf_database_header (vty, lsa);
3831 show_opaque_info_detail (vty, lsa);
3832
3833 vty_out (vty, "%s", VTY_NEWLINE);
3834 }
3835 return 0;
3836}
3837#endif /* HAVE_OPAQUE_LSA */
3838
3839int (*show_function[])(struct vty *, struct ospf_lsa *) =
3840{
3841 NULL,
3842 show_router_lsa_detail,
3843 show_network_lsa_detail,
3844 show_summary_lsa_detail,
3845 show_summary_asbr_lsa_detail,
3846 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003847 show_func_dummy,
3848 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003849#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003850 NULL, /* type-8 */
3851 show_opaque_lsa_detail,
3852 show_opaque_lsa_detail,
3853 show_opaque_lsa_detail,
3854#endif /* HAVE_OPAQUE_LSA */
3855};
3856
paul4dadc292005-05-06 21:37:42 +00003857static void
paul718e3742002-12-13 20:15:29 +00003858show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3859 struct in_addr *adv_router)
3860{
3861 memset (lp, 0, sizeof (struct prefix_ls));
3862 lp->family = 0;
3863 if (id == NULL)
3864 lp->prefixlen = 0;
3865 else if (adv_router == NULL)
3866 {
3867 lp->prefixlen = 32;
3868 lp->id = *id;
3869 }
3870 else
3871 {
3872 lp->prefixlen = 64;
3873 lp->id = *id;
3874 lp->adv_router = *adv_router;
3875 }
3876}
3877
paul4dadc292005-05-06 21:37:42 +00003878static void
paul718e3742002-12-13 20:15:29 +00003879show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3880 struct in_addr *id, struct in_addr *adv_router)
3881{
3882 struct prefix_ls lp;
3883 struct route_node *rn, *start;
3884 struct ospf_lsa *lsa;
3885
3886 show_lsa_prefix_set (vty, &lp, id, adv_router);
3887 start = route_node_get (rt, (struct prefix *) &lp);
3888 if (start)
3889 {
3890 route_lock_node (start);
3891 for (rn = start; rn; rn = route_next_until (rn, start))
3892 if ((lsa = rn->info))
3893 {
paul718e3742002-12-13 20:15:29 +00003894 if (show_function[lsa->data->type] != NULL)
3895 show_function[lsa->data->type] (vty, lsa);
3896 }
3897 route_unlock_node (start);
3898 }
3899}
3900
3901/* Show detail LSA information
3902 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003903static void
paul020709f2003-04-04 02:44:16 +00003904show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003905 struct in_addr *id, struct in_addr *adv_router)
3906{
hasso52dc7ee2004-09-23 19:18:23 +00003907 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003908 struct ospf_area *area;
3909
paul718e3742002-12-13 20:15:29 +00003910 switch (type)
3911 {
3912 case OSPF_AS_EXTERNAL_LSA:
3913#ifdef HAVE_OPAQUE_LSA
3914 case OSPF_OPAQUE_AS_LSA:
3915#endif /* HAVE_OPAQUE_LSA */
3916 vty_out (vty, " %s %s%s",
3917 show_database_desc[type],
3918 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003919 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003920 break;
3921 default:
paul1eb8ef22005-04-07 07:30:20 +00003922 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003923 {
paul718e3742002-12-13 20:15:29 +00003924 vty_out (vty, "%s %s (Area %s)%s%s",
3925 VTY_NEWLINE, show_database_desc[type],
3926 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3927 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3928 }
3929 break;
3930 }
3931}
3932
paul4dadc292005-05-06 21:37:42 +00003933static void
paul718e3742002-12-13 20:15:29 +00003934show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3935 struct in_addr *adv_router)
3936{
3937 struct route_node *rn;
3938 struct ospf_lsa *lsa;
3939
3940 for (rn = route_top (rt); rn; rn = route_next (rn))
3941 if ((lsa = rn->info))
3942 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3943 {
paul718e3742002-12-13 20:15:29 +00003944 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3945 continue;
paul718e3742002-12-13 20:15:29 +00003946 if (show_function[lsa->data->type] != NULL)
3947 show_function[lsa->data->type] (vty, lsa);
3948 }
3949}
3950
3951/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003952static void
paul020709f2003-04-04 02:44:16 +00003953show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003954 struct in_addr *adv_router)
3955{
hasso52dc7ee2004-09-23 19:18:23 +00003956 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003957 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003958
3959 switch (type)
3960 {
3961 case OSPF_AS_EXTERNAL_LSA:
3962#ifdef HAVE_OPAQUE_LSA
3963 case OSPF_OPAQUE_AS_LSA:
3964#endif /* HAVE_OPAQUE_LSA */
3965 vty_out (vty, " %s %s%s",
3966 show_database_desc[type],
3967 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003968 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003969 adv_router);
3970 break;
3971 default:
paul1eb8ef22005-04-07 07:30:20 +00003972 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003973 {
paul718e3742002-12-13 20:15:29 +00003974 vty_out (vty, "%s %s (Area %s)%s%s",
3975 VTY_NEWLINE, show_database_desc[type],
3976 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3977 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3978 adv_router);
3979 }
3980 break;
3981 }
3982}
3983
paul4dadc292005-05-06 21:37:42 +00003984static void
paul020709f2003-04-04 02:44:16 +00003985show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003986{
paul020709f2003-04-04 02:44:16 +00003987 struct ospf_lsa *lsa;
3988 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003989 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003990 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003991 int type;
3992
paul1eb8ef22005-04-07 07:30:20 +00003993 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003994 {
paul718e3742002-12-13 20:15:29 +00003995 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3996 {
3997 switch (type)
3998 {
3999 case OSPF_AS_EXTERNAL_LSA:
4000#ifdef HAVE_OPAQUE_LSA
4001 case OSPF_OPAQUE_AS_LSA:
4002#endif /* HAVE_OPAQUE_LSA */
4003 continue;
4004 default:
4005 break;
4006 }
4007 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
4008 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
4009 {
4010 vty_out (vty, " %s (Area %s)%s%s",
4011 show_database_desc[type],
4012 ospf_area_desc_string (area),
4013 VTY_NEWLINE, VTY_NEWLINE);
4014 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
4015
paul020709f2003-04-04 02:44:16 +00004016 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
4017 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00004018
4019 vty_out (vty, "%s", VTY_NEWLINE);
4020 }
4021 }
4022 }
4023
4024 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4025 {
4026 switch (type)
4027 {
4028 case OSPF_AS_EXTERNAL_LSA:
4029#ifdef HAVE_OPAQUE_LSA
4030 case OSPF_OPAQUE_AS_LSA:
4031#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00004032 break;
paul718e3742002-12-13 20:15:29 +00004033 default:
4034 continue;
4035 }
paul68980082003-03-25 05:07:42 +00004036 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4037 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00004038 {
4039 vty_out (vty, " %s%s%s",
4040 show_database_desc[type],
4041 VTY_NEWLINE, VTY_NEWLINE);
4042 vty_out (vty, "%s%s", show_database_header[type],
4043 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00004044
4045 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4046 show_lsa_summary (vty, lsa, self);
4047
paul718e3742002-12-13 20:15:29 +00004048 vty_out (vty, "%s", VTY_NEWLINE);
4049 }
4050 }
4051
4052 vty_out (vty, "%s", VTY_NEWLINE);
4053}
4054
paul4dadc292005-05-06 21:37:42 +00004055static void
paul020709f2003-04-04 02:44:16 +00004056show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00004057{
hasso52dc7ee2004-09-23 19:18:23 +00004058 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00004059 struct ospf_lsa *lsa;
4060
4061 vty_out (vty, "%s MaxAge Link States:%s%s",
4062 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4063
paul1eb8ef22005-04-07 07:30:20 +00004064 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
4065 {
4066 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4067 vty_out (vty, "Link State ID: %s%s",
4068 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4069 vty_out (vty, "Advertising Router: %s%s",
4070 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4071 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4072 vty_out (vty, "%s", VTY_NEWLINE);
4073 }
paul718e3742002-12-13 20:15:29 +00004074}
4075
paul718e3742002-12-13 20:15:29 +00004076#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4077#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00004078
4079#ifdef HAVE_OPAQUE_LSA
4080#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4081#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4082#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4083#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4084#else /* HAVE_OPAQUE_LSA */
4085#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4086#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4087#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4088#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4089#endif /* HAVE_OPAQUE_LSA */
4090
4091#define OSPF_LSA_TYPES_CMD_STR \
4092 "asbr-summary|external|network|router|summary" \
4093 OSPF_LSA_TYPE_NSSA_CMD_STR \
4094 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4095
4096#define OSPF_LSA_TYPES_DESC \
4097 "ASBR summary link states\n" \
4098 "External link states\n" \
4099 "Network link states\n" \
4100 "Router link states\n" \
4101 "Network summary link states\n" \
4102 OSPF_LSA_TYPE_NSSA_DESC \
4103 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4104 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4105 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4106
4107DEFUN (show_ip_ospf_database,
4108 show_ip_ospf_database_cmd,
4109 "show ip ospf database",
4110 SHOW_STR
4111 IP_STR
4112 "OSPF information\n"
4113 "Database summary\n")
4114{
paul020709f2003-04-04 02:44:16 +00004115 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004116 int type, ret;
4117 struct in_addr id, adv_router;
4118
paul020709f2003-04-04 02:44:16 +00004119 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004120 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004121 {
4122 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4123 return CMD_SUCCESS;
4124 }
paul718e3742002-12-13 20:15:29 +00004125
4126 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004127 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004128
4129 /* Show all LSA. */
4130 if (argc == 0)
4131 {
paul020709f2003-04-04 02:44:16 +00004132 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004133 return CMD_SUCCESS;
4134 }
4135
4136 /* Set database type to show. */
4137 if (strncmp (argv[0], "r", 1) == 0)
4138 type = OSPF_ROUTER_LSA;
4139 else if (strncmp (argv[0], "ne", 2) == 0)
4140 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004141 else if (strncmp (argv[0], "ns", 2) == 0)
4142 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004143 else if (strncmp (argv[0], "su", 2) == 0)
4144 type = OSPF_SUMMARY_LSA;
4145 else if (strncmp (argv[0], "a", 1) == 0)
4146 type = OSPF_ASBR_SUMMARY_LSA;
4147 else if (strncmp (argv[0], "e", 1) == 0)
4148 type = OSPF_AS_EXTERNAL_LSA;
4149 else if (strncmp (argv[0], "se", 2) == 0)
4150 {
paul020709f2003-04-04 02:44:16 +00004151 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004152 return CMD_SUCCESS;
4153 }
4154 else if (strncmp (argv[0], "m", 1) == 0)
4155 {
paul020709f2003-04-04 02:44:16 +00004156 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004157 return CMD_SUCCESS;
4158 }
4159#ifdef HAVE_OPAQUE_LSA
4160 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4161 type = OSPF_OPAQUE_LINK_LSA;
4162 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4163 type = OSPF_OPAQUE_AREA_LSA;
4164 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4165 type = OSPF_OPAQUE_AS_LSA;
4166#endif /* HAVE_OPAQUE_LSA */
4167 else
4168 return CMD_WARNING;
4169
4170 /* `show ip ospf database LSA'. */
4171 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004172 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004173 else if (argc >= 2)
4174 {
4175 ret = inet_aton (argv[1], &id);
4176 if (!ret)
4177 return CMD_WARNING;
4178
4179 /* `show ip ospf database LSA ID'. */
4180 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004181 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004182 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4183 else if (argc == 3)
4184 {
4185 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004186 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004187 else
4188 {
4189 ret = inet_aton (argv[2], &adv_router);
4190 if (!ret)
4191 return CMD_WARNING;
4192 }
paul020709f2003-04-04 02:44:16 +00004193 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004194 }
4195 }
4196
4197 return CMD_SUCCESS;
4198}
4199
4200ALIAS (show_ip_ospf_database,
4201 show_ip_ospf_database_type_cmd,
4202 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4203 SHOW_STR
4204 IP_STR
4205 "OSPF information\n"
4206 "Database summary\n"
4207 OSPF_LSA_TYPES_DESC
4208 "LSAs in MaxAge list\n"
4209 "Self-originated link states\n")
4210
4211ALIAS (show_ip_ospf_database,
4212 show_ip_ospf_database_type_id_cmd,
4213 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4214 SHOW_STR
4215 IP_STR
4216 "OSPF information\n"
4217 "Database summary\n"
4218 OSPF_LSA_TYPES_DESC
4219 "Link State ID (as an IP address)\n")
4220
4221ALIAS (show_ip_ospf_database,
4222 show_ip_ospf_database_type_id_adv_router_cmd,
4223 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4224 SHOW_STR
4225 IP_STR
4226 "OSPF information\n"
4227 "Database summary\n"
4228 OSPF_LSA_TYPES_DESC
4229 "Link State ID (as an IP address)\n"
4230 "Advertising Router link states\n"
4231 "Advertising Router (as an IP address)\n")
4232
4233ALIAS (show_ip_ospf_database,
4234 show_ip_ospf_database_type_id_self_cmd,
4235 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4236 SHOW_STR
4237 IP_STR
4238 "OSPF information\n"
4239 "Database summary\n"
4240 OSPF_LSA_TYPES_DESC
4241 "Link State ID (as an IP address)\n"
4242 "Self-originated link states\n"
4243 "\n")
4244
4245DEFUN (show_ip_ospf_database_type_adv_router,
4246 show_ip_ospf_database_type_adv_router_cmd,
4247 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4248 SHOW_STR
4249 IP_STR
4250 "OSPF information\n"
4251 "Database summary\n"
4252 OSPF_LSA_TYPES_DESC
4253 "Advertising Router link states\n"
4254 "Advertising Router (as an IP address)\n")
4255{
paul020709f2003-04-04 02:44:16 +00004256 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004257 int type, ret;
4258 struct in_addr adv_router;
4259
paul020709f2003-04-04 02:44:16 +00004260 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004261 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004262 {
4263 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4264 return CMD_SUCCESS;
4265 }
paul718e3742002-12-13 20:15:29 +00004266
4267 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004268 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004269
4270 if (argc != 2)
4271 return CMD_WARNING;
4272
4273 /* Set database type to show. */
4274 if (strncmp (argv[0], "r", 1) == 0)
4275 type = OSPF_ROUTER_LSA;
4276 else if (strncmp (argv[0], "ne", 2) == 0)
4277 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004278 else if (strncmp (argv[0], "ns", 2) == 0)
4279 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004280 else if (strncmp (argv[0], "s", 1) == 0)
4281 type = OSPF_SUMMARY_LSA;
4282 else if (strncmp (argv[0], "a", 1) == 0)
4283 type = OSPF_ASBR_SUMMARY_LSA;
4284 else if (strncmp (argv[0], "e", 1) == 0)
4285 type = OSPF_AS_EXTERNAL_LSA;
4286#ifdef HAVE_OPAQUE_LSA
4287 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4288 type = OSPF_OPAQUE_LINK_LSA;
4289 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4290 type = OSPF_OPAQUE_AREA_LSA;
4291 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4292 type = OSPF_OPAQUE_AS_LSA;
4293#endif /* HAVE_OPAQUE_LSA */
4294 else
4295 return CMD_WARNING;
4296
4297 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4298 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004299 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004300 else
4301 {
4302 ret = inet_aton (argv[1], &adv_router);
4303 if (!ret)
4304 return CMD_WARNING;
4305 }
4306
paul020709f2003-04-04 02:44:16 +00004307 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004308
4309 return CMD_SUCCESS;
4310}
4311
4312ALIAS (show_ip_ospf_database_type_adv_router,
4313 show_ip_ospf_database_type_self_cmd,
4314 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4315 SHOW_STR
4316 IP_STR
4317 "OSPF information\n"
4318 "Database summary\n"
4319 OSPF_LSA_TYPES_DESC
4320 "Self-originated link states\n")
4321
4322
4323DEFUN (ip_ospf_authentication_args,
4324 ip_ospf_authentication_args_addr_cmd,
4325 "ip ospf authentication (null|message-digest) A.B.C.D",
4326 "IP Information\n"
4327 "OSPF interface commands\n"
4328 "Enable authentication on this interface\n"
4329 "Use null authentication\n"
4330 "Use message-digest authentication\n"
4331 "Address of interface")
4332{
4333 struct interface *ifp;
4334 struct in_addr addr;
4335 int ret;
4336 struct ospf_if_params *params;
4337
4338 ifp = vty->index;
4339 params = IF_DEF_PARAMS (ifp);
4340
4341 if (argc == 2)
4342 {
4343 ret = inet_aton(argv[1], &addr);
4344 if (!ret)
4345 {
4346 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4347 VTY_NEWLINE);
4348 return CMD_WARNING;
4349 }
4350
4351 params = ospf_get_if_params (ifp, addr);
4352 ospf_if_update_params (ifp, addr);
4353 }
4354
4355 /* Handle null authentication */
4356 if ( argv[0][0] == 'n' )
4357 {
4358 SET_IF_PARAM (params, auth_type);
4359 params->auth_type = OSPF_AUTH_NULL;
4360 return CMD_SUCCESS;
4361 }
4362
4363 /* Handle message-digest authentication */
4364 if ( argv[0][0] == 'm' )
4365 {
4366 SET_IF_PARAM (params, auth_type);
4367 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4368 return CMD_SUCCESS;
4369 }
4370
4371 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4372 return CMD_WARNING;
4373}
4374
4375ALIAS (ip_ospf_authentication_args,
4376 ip_ospf_authentication_args_cmd,
4377 "ip ospf authentication (null|message-digest)",
4378 "IP Information\n"
4379 "OSPF interface commands\n"
4380 "Enable authentication on this interface\n"
4381 "Use null authentication\n"
4382 "Use message-digest authentication\n")
4383
4384DEFUN (ip_ospf_authentication,
4385 ip_ospf_authentication_addr_cmd,
4386 "ip ospf authentication A.B.C.D",
4387 "IP Information\n"
4388 "OSPF interface commands\n"
4389 "Enable authentication on this interface\n"
4390 "Address of interface")
4391{
4392 struct interface *ifp;
4393 struct in_addr addr;
4394 int ret;
4395 struct ospf_if_params *params;
4396
4397 ifp = vty->index;
4398 params = IF_DEF_PARAMS (ifp);
4399
4400 if (argc == 1)
4401 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004402 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004403 if (!ret)
4404 {
4405 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4406 VTY_NEWLINE);
4407 return CMD_WARNING;
4408 }
4409
4410 params = ospf_get_if_params (ifp, addr);
4411 ospf_if_update_params (ifp, addr);
4412 }
4413
4414 SET_IF_PARAM (params, auth_type);
4415 params->auth_type = OSPF_AUTH_SIMPLE;
4416
4417 return CMD_SUCCESS;
4418}
4419
4420ALIAS (ip_ospf_authentication,
4421 ip_ospf_authentication_cmd,
4422 "ip ospf authentication",
4423 "IP Information\n"
4424 "OSPF interface commands\n"
4425 "Enable authentication on this interface\n")
4426
4427DEFUN (no_ip_ospf_authentication,
4428 no_ip_ospf_authentication_addr_cmd,
4429 "no ip ospf authentication A.B.C.D",
4430 NO_STR
4431 "IP Information\n"
4432 "OSPF interface commands\n"
4433 "Enable authentication on this interface\n"
4434 "Address of interface")
4435{
4436 struct interface *ifp;
4437 struct in_addr addr;
4438 int ret;
4439 struct ospf_if_params *params;
4440
4441 ifp = vty->index;
4442 params = IF_DEF_PARAMS (ifp);
4443
4444 if (argc == 1)
4445 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004446 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004447 if (!ret)
4448 {
4449 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4450 VTY_NEWLINE);
4451 return CMD_WARNING;
4452 }
4453
4454 params = ospf_lookup_if_params (ifp, addr);
4455 if (params == NULL)
4456 return CMD_SUCCESS;
4457 }
4458
4459 params->auth_type = OSPF_AUTH_NOTSET;
4460 UNSET_IF_PARAM (params, auth_type);
4461
4462 if (params != IF_DEF_PARAMS (ifp))
4463 {
4464 ospf_free_if_params (ifp, addr);
4465 ospf_if_update_params (ifp, addr);
4466 }
4467
4468 return CMD_SUCCESS;
4469}
4470
4471ALIAS (no_ip_ospf_authentication,
4472 no_ip_ospf_authentication_cmd,
4473 "no ip ospf authentication",
4474 NO_STR
4475 "IP Information\n"
4476 "OSPF interface commands\n"
4477 "Enable authentication on this interface\n")
4478
4479DEFUN (ip_ospf_authentication_key,
4480 ip_ospf_authentication_key_addr_cmd,
4481 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4482 "IP Information\n"
4483 "OSPF interface commands\n"
4484 "Authentication password (key)\n"
4485 "The OSPF password (key)\n"
4486 "Address of interface")
4487{
4488 struct interface *ifp;
4489 struct in_addr addr;
4490 int ret;
4491 struct ospf_if_params *params;
4492
4493 ifp = vty->index;
4494 params = IF_DEF_PARAMS (ifp);
4495
4496 if (argc == 2)
4497 {
4498 ret = inet_aton(argv[1], &addr);
4499 if (!ret)
4500 {
4501 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4502 VTY_NEWLINE);
4503 return CMD_WARNING;
4504 }
4505
4506 params = ospf_get_if_params (ifp, addr);
4507 ospf_if_update_params (ifp, addr);
4508 }
4509
4510
4511 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004512 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004513 SET_IF_PARAM (params, auth_simple);
4514
4515 return CMD_SUCCESS;
4516}
4517
4518ALIAS (ip_ospf_authentication_key,
4519 ip_ospf_authentication_key_cmd,
4520 "ip ospf authentication-key AUTH_KEY",
4521 "IP Information\n"
4522 "OSPF interface commands\n"
4523 "Authentication password (key)\n"
4524 "The OSPF password (key)")
4525
4526ALIAS (ip_ospf_authentication_key,
4527 ospf_authentication_key_cmd,
4528 "ospf authentication-key AUTH_KEY",
4529 "OSPF interface commands\n"
4530 "Authentication password (key)\n"
4531 "The OSPF password (key)")
4532
4533DEFUN (no_ip_ospf_authentication_key,
4534 no_ip_ospf_authentication_key_addr_cmd,
4535 "no ip ospf authentication-key A.B.C.D",
4536 NO_STR
4537 "IP Information\n"
4538 "OSPF interface commands\n"
4539 "Authentication password (key)\n"
4540 "Address of interface")
4541{
4542 struct interface *ifp;
4543 struct in_addr addr;
4544 int ret;
4545 struct ospf_if_params *params;
4546
4547 ifp = vty->index;
4548 params = IF_DEF_PARAMS (ifp);
4549
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004550 if (argc == 1)
paul718e3742002-12-13 20:15:29 +00004551 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004552 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004553 if (!ret)
4554 {
4555 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4556 VTY_NEWLINE);
4557 return CMD_WARNING;
4558 }
4559
4560 params = ospf_lookup_if_params (ifp, addr);
4561 if (params == NULL)
4562 return CMD_SUCCESS;
4563 }
4564
4565 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4566 UNSET_IF_PARAM (params, auth_simple);
4567
4568 if (params != IF_DEF_PARAMS (ifp))
4569 {
4570 ospf_free_if_params (ifp, addr);
4571 ospf_if_update_params (ifp, addr);
4572 }
4573
4574 return CMD_SUCCESS;
4575}
4576
4577ALIAS (no_ip_ospf_authentication_key,
4578 no_ip_ospf_authentication_key_cmd,
4579 "no ip ospf authentication-key",
4580 NO_STR
4581 "IP Information\n"
4582 "OSPF interface commands\n"
4583 "Authentication password (key)\n")
4584
4585ALIAS (no_ip_ospf_authentication_key,
4586 no_ospf_authentication_key_cmd,
4587 "no ospf authentication-key",
4588 NO_STR
4589 "OSPF interface commands\n"
4590 "Authentication password (key)\n")
4591
4592DEFUN (ip_ospf_message_digest_key,
4593 ip_ospf_message_digest_key_addr_cmd,
4594 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4595 "IP Information\n"
4596 "OSPF interface commands\n"
4597 "Message digest authentication password (key)\n"
4598 "Key ID\n"
4599 "Use MD5 algorithm\n"
4600 "The OSPF password (key)"
4601 "Address of interface")
4602{
4603 struct interface *ifp;
4604 struct crypt_key *ck;
4605 u_char key_id;
4606 struct in_addr addr;
4607 int ret;
4608 struct ospf_if_params *params;
4609
4610 ifp = vty->index;
4611 params = IF_DEF_PARAMS (ifp);
4612
4613 if (argc == 3)
4614 {
4615 ret = inet_aton(argv[2], &addr);
4616 if (!ret)
4617 {
4618 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4619 VTY_NEWLINE);
4620 return CMD_WARNING;
4621 }
4622
4623 params = ospf_get_if_params (ifp, addr);
4624 ospf_if_update_params (ifp, addr);
4625 }
4626
4627 key_id = strtol (argv[0], NULL, 10);
4628 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4629 {
4630 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4631 return CMD_WARNING;
4632 }
4633
4634 ck = ospf_crypt_key_new ();
4635 ck->key_id = (u_char) key_id;
4636 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004637 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004638
4639 ospf_crypt_key_add (params->auth_crypt, ck);
4640 SET_IF_PARAM (params, auth_crypt);
4641
4642 return CMD_SUCCESS;
4643}
4644
4645ALIAS (ip_ospf_message_digest_key,
4646 ip_ospf_message_digest_key_cmd,
4647 "ip ospf message-digest-key <1-255> md5 KEY",
4648 "IP Information\n"
4649 "OSPF interface commands\n"
4650 "Message digest authentication password (key)\n"
4651 "Key ID\n"
4652 "Use MD5 algorithm\n"
4653 "The OSPF password (key)")
4654
4655ALIAS (ip_ospf_message_digest_key,
4656 ospf_message_digest_key_cmd,
4657 "ospf message-digest-key <1-255> md5 KEY",
4658 "OSPF interface commands\n"
4659 "Message digest authentication password (key)\n"
4660 "Key ID\n"
4661 "Use MD5 algorithm\n"
4662 "The OSPF password (key)")
4663
4664DEFUN (no_ip_ospf_message_digest_key,
4665 no_ip_ospf_message_digest_key_addr_cmd,
4666 "no ip ospf message-digest-key <1-255> A.B.C.D",
4667 NO_STR
4668 "IP Information\n"
4669 "OSPF interface commands\n"
4670 "Message digest authentication password (key)\n"
4671 "Key ID\n"
4672 "Address of interface")
4673{
4674 struct interface *ifp;
4675 struct crypt_key *ck;
4676 int key_id;
4677 struct in_addr addr;
4678 int ret;
4679 struct ospf_if_params *params;
4680
4681 ifp = vty->index;
4682 params = IF_DEF_PARAMS (ifp);
4683
4684 if (argc == 2)
4685 {
4686 ret = inet_aton(argv[1], &addr);
4687 if (!ret)
4688 {
4689 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4690 VTY_NEWLINE);
4691 return CMD_WARNING;
4692 }
4693
4694 params = ospf_lookup_if_params (ifp, addr);
4695 if (params == NULL)
4696 return CMD_SUCCESS;
4697 }
4698
4699 key_id = strtol (argv[0], NULL, 10);
4700 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4701 if (ck == NULL)
4702 {
4703 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4704 return CMD_WARNING;
4705 }
4706
4707 ospf_crypt_key_delete (params->auth_crypt, key_id);
4708
4709 if (params != IF_DEF_PARAMS (ifp))
4710 {
4711 ospf_free_if_params (ifp, addr);
4712 ospf_if_update_params (ifp, addr);
4713 }
4714
4715 return CMD_SUCCESS;
4716}
4717
4718ALIAS (no_ip_ospf_message_digest_key,
4719 no_ip_ospf_message_digest_key_cmd,
4720 "no ip ospf message-digest-key <1-255>",
4721 NO_STR
4722 "IP Information\n"
4723 "OSPF interface commands\n"
4724 "Message digest authentication password (key)\n"
4725 "Key ID\n")
4726
4727ALIAS (no_ip_ospf_message_digest_key,
4728 no_ospf_message_digest_key_cmd,
4729 "no ospf message-digest-key <1-255>",
4730 NO_STR
4731 "OSPF interface commands\n"
4732 "Message digest authentication password (key)\n"
4733 "Key ID\n")
4734
4735DEFUN (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004736 ip_ospf_cost_u32_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004737 "ip ospf cost <1-65535> A.B.C.D",
4738 "IP Information\n"
4739 "OSPF interface commands\n"
4740 "Interface cost\n"
4741 "Cost\n"
4742 "Address of interface")
4743{
4744 struct interface *ifp = vty->index;
4745 u_int32_t cost;
4746 struct in_addr addr;
4747 int ret;
4748 struct ospf_if_params *params;
4749
4750 params = IF_DEF_PARAMS (ifp);
4751
4752 cost = strtol (argv[0], NULL, 10);
4753
4754 /* cost range is <1-65535>. */
4755 if (cost < 1 || cost > 65535)
4756 {
4757 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4758 return CMD_WARNING;
4759 }
4760
4761 if (argc == 2)
4762 {
4763 ret = inet_aton(argv[1], &addr);
4764 if (!ret)
4765 {
4766 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4767 VTY_NEWLINE);
4768 return CMD_WARNING;
4769 }
4770
4771 params = ospf_get_if_params (ifp, addr);
4772 ospf_if_update_params (ifp, addr);
4773 }
4774
4775 SET_IF_PARAM (params, output_cost_cmd);
4776 params->output_cost_cmd = cost;
4777
4778 ospf_if_recalculate_output_cost (ifp);
4779
4780 return CMD_SUCCESS;
4781}
4782
4783ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004784 ip_ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004785 "ip ospf cost <1-65535>",
4786 "IP Information\n"
4787 "OSPF interface commands\n"
4788 "Interface cost\n"
4789 "Cost")
4790
4791ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004792 ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004793 "ospf cost <1-65535>",
4794 "OSPF interface commands\n"
4795 "Interface cost\n"
4796 "Cost")
4797
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004798ALIAS (ip_ospf_cost,
4799 ospf_cost_u32_inet4_cmd,
4800 "ospf cost <1-65535> A.B.C.D",
4801 "OSPF interface commands\n"
4802 "Interface cost\n"
4803 "Cost\n"
4804 "Address of interface")
4805
paul718e3742002-12-13 20:15:29 +00004806DEFUN (no_ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004807 no_ip_ospf_cost_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004808 "no ip ospf cost A.B.C.D",
4809 NO_STR
4810 "IP Information\n"
4811 "OSPF interface commands\n"
4812 "Interface cost\n"
4813 "Address of interface")
4814{
4815 struct interface *ifp = vty->index;
4816 struct in_addr addr;
4817 int ret;
4818 struct ospf_if_params *params;
4819
4820 ifp = vty->index;
4821 params = IF_DEF_PARAMS (ifp);
4822
4823 if (argc == 1)
4824 {
4825 ret = inet_aton(argv[0], &addr);
4826 if (!ret)
4827 {
4828 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4829 VTY_NEWLINE);
4830 return CMD_WARNING;
4831 }
4832
4833 params = ospf_lookup_if_params (ifp, addr);
4834 if (params == NULL)
4835 return CMD_SUCCESS;
4836 }
4837
4838 UNSET_IF_PARAM (params, output_cost_cmd);
4839
4840 if (params != IF_DEF_PARAMS (ifp))
4841 {
4842 ospf_free_if_params (ifp, addr);
4843 ospf_if_update_params (ifp, addr);
4844 }
4845
4846 ospf_if_recalculate_output_cost (ifp);
4847
4848 return CMD_SUCCESS;
4849}
4850
4851ALIAS (no_ip_ospf_cost,
4852 no_ip_ospf_cost_cmd,
4853 "no ip ospf cost",
4854 NO_STR
4855 "IP Information\n"
4856 "OSPF interface commands\n"
4857 "Interface cost\n")
4858
4859ALIAS (no_ip_ospf_cost,
4860 no_ospf_cost_cmd,
4861 "no ospf cost",
4862 NO_STR
4863 "OSPF interface commands\n"
4864 "Interface cost\n")
4865
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004866ALIAS (no_ip_ospf_cost,
4867 no_ospf_cost_inet4_cmd,
4868 "no ospf cost A.B.C.D",
4869 NO_STR
4870 "OSPF interface commands\n"
4871 "Interface cost\n"
4872 "Address of interface")
4873
Denis Ovsienko827341b2009-09-28 19:34:59 +04004874DEFUN (no_ip_ospf_cost2,
4875 no_ip_ospf_cost_u32_cmd,
4876 "no ip ospf cost <1-65535>",
4877 NO_STR
4878 "IP Information\n"
4879 "OSPF interface commands\n"
4880 "Interface cost\n"
4881 "Cost")
4882{
4883 struct interface *ifp = vty->index;
4884 struct in_addr addr;
4885 u_int32_t cost;
4886 int ret;
4887 struct ospf_if_params *params;
4888
4889 ifp = vty->index;
4890 params = IF_DEF_PARAMS (ifp);
4891
4892 /* According to the semantics we are mimicking "no ip ospf cost N" is
4893 * always treated as "no ip ospf cost" regardless of the actual value
4894 * of N already configured for the interface. Thus the first argument
4895 * is always checked to be a number, but is ignored after that.
4896 */
4897 cost = strtol (argv[0], NULL, 10);
4898 if (cost < 1 || cost > 65535)
4899 {
4900 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4901 return CMD_WARNING;
4902 }
4903
4904 if (argc == 2)
4905 {
4906 ret = inet_aton(argv[1], &addr);
4907 if (!ret)
4908 {
4909 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4910 VTY_NEWLINE);
4911 return CMD_WARNING;
4912 }
4913
4914 params = ospf_lookup_if_params (ifp, addr);
4915 if (params == NULL)
4916 return CMD_SUCCESS;
4917 }
4918
4919 UNSET_IF_PARAM (params, output_cost_cmd);
4920
4921 if (params != IF_DEF_PARAMS (ifp))
4922 {
4923 ospf_free_if_params (ifp, addr);
4924 ospf_if_update_params (ifp, addr);
4925 }
4926
4927 ospf_if_recalculate_output_cost (ifp);
4928
4929 return CMD_SUCCESS;
4930}
4931
4932ALIAS (no_ip_ospf_cost2,
4933 no_ospf_cost_u32_cmd,
4934 "no ospf cost <1-65535>",
4935 NO_STR
4936 "OSPF interface commands\n"
4937 "Interface cost\n"
4938 "Cost")
4939
4940ALIAS (no_ip_ospf_cost2,
4941 no_ip_ospf_cost_u32_inet4_cmd,
4942 "no ip ospf cost <1-65535> A.B.C.D",
4943 NO_STR
4944 "IP Information\n"
4945 "OSPF interface commands\n"
4946 "Interface cost\n"
4947 "Cost\n"
4948 "Address of interface")
4949
4950ALIAS (no_ip_ospf_cost2,
4951 no_ospf_cost_u32_inet4_cmd,
4952 "no ospf cost <1-65535> A.B.C.D",
4953 NO_STR
4954 "OSPF interface commands\n"
4955 "Interface cost\n"
4956 "Cost\n"
4957 "Address of interface")
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004958
paul4dadc292005-05-06 21:37:42 +00004959static void
paul718e3742002-12-13 20:15:29 +00004960ospf_nbr_timer_update (struct ospf_interface *oi)
4961{
4962 struct route_node *rn;
4963 struct ospf_neighbor *nbr;
4964
4965 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4966 if ((nbr = rn->info))
4967 {
4968 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4969 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4970 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4971 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4972 }
4973}
4974
paulf9ad9372005-10-21 00:45:17 +00004975static int
4976ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4977 const char *nbr_str,
4978 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004979{
4980 struct interface *ifp = vty->index;
4981 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004982 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004983 struct in_addr addr;
4984 int ret;
4985 struct ospf_if_params *params;
4986 struct ospf_interface *oi;
4987 struct route_node *rn;
4988
4989 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004990
4991 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004992 {
paulf9ad9372005-10-21 00:45:17 +00004993 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004994 if (!ret)
4995 {
4996 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4997 VTY_NEWLINE);
4998 return CMD_WARNING;
4999 }
5000
5001 params = ospf_get_if_params (ifp, addr);
5002 ospf_if_update_params (ifp, addr);
5003 }
5004
paulf9ad9372005-10-21 00:45:17 +00005005 if (interval_str)
5006 {
5007 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
5008 1, 65535);
5009
5010 /* reset fast_hello too, just to be sure */
5011 UNSET_IF_PARAM (params, fast_hello);
5012 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5013 }
5014 else if (fast_hello_str)
5015 {
5016 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
5017 1, 10);
5018 /* 1s dead-interval with sub-second hellos desired */
5019 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
5020 SET_IF_PARAM (params, fast_hello);
5021 params->fast_hello = hellomult;
5022 }
5023 else
5024 {
5025 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5026 VTY_NEWLINE);
5027 return CMD_WARNING;
5028 }
5029
paul718e3742002-12-13 20:15:29 +00005030 SET_IF_PARAM (params, v_wait);
5031 params->v_wait = seconds;
5032
5033 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00005034 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005035 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005036 struct ospf *ospf;
5037 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005038 {
5039 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5040 if (oi)
5041 ospf_nbr_timer_update (oi);
5042 }
paul718e3742002-12-13 20:15:29 +00005043 }
5044 else
5045 {
5046 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5047 if ((oi = rn->info))
5048 ospf_nbr_timer_update (oi);
5049 }
5050
5051 return CMD_SUCCESS;
5052}
5053
paulf9ad9372005-10-21 00:45:17 +00005054
5055DEFUN (ip_ospf_dead_interval,
5056 ip_ospf_dead_interval_addr_cmd,
5057 "ip ospf dead-interval <1-65535> A.B.C.D",
5058 "IP Information\n"
5059 "OSPF interface commands\n"
5060 "Interval after which a neighbor is declared dead\n"
5061 "Seconds\n"
5062 "Address of interface\n")
5063{
5064 if (argc == 2)
5065 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5066 else
5067 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5068}
5069
paul718e3742002-12-13 20:15:29 +00005070ALIAS (ip_ospf_dead_interval,
5071 ip_ospf_dead_interval_cmd,
5072 "ip ospf dead-interval <1-65535>",
5073 "IP Information\n"
5074 "OSPF interface commands\n"
5075 "Interval after which a neighbor is declared dead\n"
5076 "Seconds\n")
5077
5078ALIAS (ip_ospf_dead_interval,
5079 ospf_dead_interval_cmd,
5080 "ospf dead-interval <1-65535>",
5081 "OSPF interface commands\n"
5082 "Interval after which a neighbor is declared dead\n"
5083 "Seconds\n")
5084
paulf9ad9372005-10-21 00:45:17 +00005085DEFUN (ip_ospf_dead_interval_minimal,
5086 ip_ospf_dead_interval_minimal_addr_cmd,
5087 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5088 "IP Information\n"
5089 "OSPF interface commands\n"
5090 "Interval after which a neighbor is declared dead\n"
5091 "Minimal 1s dead-interval with fast sub-second hellos\n"
5092 "Hello multiplier factor\n"
5093 "Number of Hellos to send each second\n"
5094 "Address of interface\n")
5095{
5096 if (argc == 2)
5097 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5098 else
5099 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5100}
5101
5102ALIAS (ip_ospf_dead_interval_minimal,
5103 ip_ospf_dead_interval_minimal_cmd,
5104 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5105 "IP Information\n"
5106 "OSPF interface commands\n"
5107 "Interval after which a neighbor is declared dead\n"
5108 "Minimal 1s dead-interval with fast sub-second hellos\n"
5109 "Hello multiplier factor\n"
5110 "Number of Hellos to send each second\n")
5111
paul718e3742002-12-13 20:15:29 +00005112DEFUN (no_ip_ospf_dead_interval,
5113 no_ip_ospf_dead_interval_addr_cmd,
5114 "no ip ospf dead-interval A.B.C.D",
5115 NO_STR
5116 "IP Information\n"
5117 "OSPF interface commands\n"
5118 "Interval after which a neighbor is declared dead\n"
5119 "Address of interface")
5120{
5121 struct interface *ifp = vty->index;
5122 struct in_addr addr;
5123 int ret;
5124 struct ospf_if_params *params;
5125 struct ospf_interface *oi;
5126 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00005127
paul718e3742002-12-13 20:15:29 +00005128 ifp = vty->index;
5129 params = IF_DEF_PARAMS (ifp);
5130
5131 if (argc == 1)
5132 {
5133 ret = inet_aton(argv[0], &addr);
5134 if (!ret)
5135 {
5136 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5137 VTY_NEWLINE);
5138 return CMD_WARNING;
5139 }
5140
5141 params = ospf_lookup_if_params (ifp, addr);
5142 if (params == NULL)
5143 return CMD_SUCCESS;
5144 }
5145
5146 UNSET_IF_PARAM (params, v_wait);
5147 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00005148
5149 UNSET_IF_PARAM (params, fast_hello);
5150 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5151
paul718e3742002-12-13 20:15:29 +00005152 if (params != IF_DEF_PARAMS (ifp))
5153 {
5154 ospf_free_if_params (ifp, addr);
5155 ospf_if_update_params (ifp, addr);
5156 }
5157
5158 /* Update timer values in neighbor structure. */
5159 if (argc == 1)
5160 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005161 struct ospf *ospf;
5162
5163 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005164 {
5165 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5166 if (oi)
5167 ospf_nbr_timer_update (oi);
5168 }
paul718e3742002-12-13 20:15:29 +00005169 }
5170 else
5171 {
5172 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5173 if ((oi = rn->info))
5174 ospf_nbr_timer_update (oi);
5175 }
5176
5177 return CMD_SUCCESS;
5178}
5179
5180ALIAS (no_ip_ospf_dead_interval,
5181 no_ip_ospf_dead_interval_cmd,
5182 "no ip ospf dead-interval",
5183 NO_STR
5184 "IP Information\n"
5185 "OSPF interface commands\n"
5186 "Interval after which a neighbor is declared dead\n")
5187
5188ALIAS (no_ip_ospf_dead_interval,
5189 no_ospf_dead_interval_cmd,
5190 "no ospf dead-interval",
5191 NO_STR
5192 "OSPF interface commands\n"
5193 "Interval after which a neighbor is declared dead\n")
5194
5195DEFUN (ip_ospf_hello_interval,
5196 ip_ospf_hello_interval_addr_cmd,
5197 "ip ospf hello-interval <1-65535> A.B.C.D",
5198 "IP Information\n"
5199 "OSPF interface commands\n"
5200 "Time between HELLO packets\n"
5201 "Seconds\n"
5202 "Address of interface")
5203{
5204 struct interface *ifp = vty->index;
5205 u_int32_t seconds;
5206 struct in_addr addr;
5207 int ret;
5208 struct ospf_if_params *params;
5209
5210 params = IF_DEF_PARAMS (ifp);
5211
5212 seconds = strtol (argv[0], NULL, 10);
5213
5214 /* HelloInterval range is <1-65535>. */
5215 if (seconds < 1 || seconds > 65535)
5216 {
5217 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5218 return CMD_WARNING;
5219 }
5220
5221 if (argc == 2)
5222 {
5223 ret = inet_aton(argv[1], &addr);
5224 if (!ret)
5225 {
5226 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5227 VTY_NEWLINE);
5228 return CMD_WARNING;
5229 }
5230
5231 params = ospf_get_if_params (ifp, addr);
5232 ospf_if_update_params (ifp, addr);
5233 }
5234
paulf9ad9372005-10-21 00:45:17 +00005235 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005236 params->v_hello = seconds;
5237
5238 return CMD_SUCCESS;
5239}
5240
5241ALIAS (ip_ospf_hello_interval,
5242 ip_ospf_hello_interval_cmd,
5243 "ip ospf hello-interval <1-65535>",
5244 "IP Information\n"
5245 "OSPF interface commands\n"
5246 "Time between HELLO packets\n"
5247 "Seconds\n")
5248
5249ALIAS (ip_ospf_hello_interval,
5250 ospf_hello_interval_cmd,
5251 "ospf hello-interval <1-65535>",
5252 "OSPF interface commands\n"
5253 "Time between HELLO packets\n"
5254 "Seconds\n")
5255
5256DEFUN (no_ip_ospf_hello_interval,
5257 no_ip_ospf_hello_interval_addr_cmd,
5258 "no ip ospf hello-interval A.B.C.D",
5259 NO_STR
5260 "IP Information\n"
5261 "OSPF interface commands\n"
5262 "Time between HELLO packets\n"
5263 "Address of interface")
5264{
5265 struct interface *ifp = vty->index;
5266 struct in_addr addr;
5267 int ret;
5268 struct ospf_if_params *params;
5269
5270 ifp = vty->index;
5271 params = IF_DEF_PARAMS (ifp);
5272
5273 if (argc == 1)
5274 {
5275 ret = inet_aton(argv[0], &addr);
5276 if (!ret)
5277 {
5278 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5279 VTY_NEWLINE);
5280 return CMD_WARNING;
5281 }
5282
5283 params = ospf_lookup_if_params (ifp, addr);
5284 if (params == NULL)
5285 return CMD_SUCCESS;
5286 }
5287
5288 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005289 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005290
5291 if (params != IF_DEF_PARAMS (ifp))
5292 {
5293 ospf_free_if_params (ifp, addr);
5294 ospf_if_update_params (ifp, addr);
5295 }
5296
5297 return CMD_SUCCESS;
5298}
5299
5300ALIAS (no_ip_ospf_hello_interval,
5301 no_ip_ospf_hello_interval_cmd,
5302 "no ip ospf hello-interval",
5303 NO_STR
5304 "IP Information\n"
5305 "OSPF interface commands\n"
5306 "Time between HELLO packets\n")
5307
5308ALIAS (no_ip_ospf_hello_interval,
5309 no_ospf_hello_interval_cmd,
5310 "no ospf hello-interval",
5311 NO_STR
5312 "OSPF interface commands\n"
5313 "Time between HELLO packets\n")
5314
5315DEFUN (ip_ospf_network,
5316 ip_ospf_network_cmd,
5317 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5318 "IP Information\n"
5319 "OSPF interface commands\n"
5320 "Network type\n"
5321 "Specify OSPF broadcast multi-access network\n"
5322 "Specify OSPF NBMA network\n"
5323 "Specify OSPF point-to-multipoint network\n"
5324 "Specify OSPF point-to-point network\n")
5325{
5326 struct interface *ifp = vty->index;
5327 int old_type = IF_DEF_PARAMS (ifp)->type;
5328 struct route_node *rn;
5329
5330 if (strncmp (argv[0], "b", 1) == 0)
5331 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5332 else if (strncmp (argv[0], "n", 1) == 0)
5333 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5334 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5335 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5336 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5337 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5338
5339 if (IF_DEF_PARAMS (ifp)->type == old_type)
5340 return CMD_SUCCESS;
5341
5342 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5343
5344 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5345 {
5346 struct ospf_interface *oi = rn->info;
5347
5348 if (!oi)
5349 continue;
5350
5351 oi->type = IF_DEF_PARAMS (ifp)->type;
5352
5353 if (oi->state > ISM_Down)
5354 {
5355 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5356 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5357 }
5358 }
5359
5360 return CMD_SUCCESS;
5361}
5362
5363ALIAS (ip_ospf_network,
5364 ospf_network_cmd,
5365 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5366 "OSPF interface commands\n"
5367 "Network type\n"
5368 "Specify OSPF broadcast multi-access network\n"
5369 "Specify OSPF NBMA network\n"
5370 "Specify OSPF point-to-multipoint network\n"
5371 "Specify OSPF point-to-point network\n")
5372
5373DEFUN (no_ip_ospf_network,
5374 no_ip_ospf_network_cmd,
5375 "no ip ospf network",
5376 NO_STR
5377 "IP Information\n"
5378 "OSPF interface commands\n"
5379 "Network type\n")
5380{
5381 struct interface *ifp = vty->index;
5382 int old_type = IF_DEF_PARAMS (ifp)->type;
5383 struct route_node *rn;
5384
ajsbc18d612004-12-15 15:07:19 +00005385 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005386
5387 if (IF_DEF_PARAMS (ifp)->type == old_type)
5388 return CMD_SUCCESS;
5389
5390 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5391 {
5392 struct ospf_interface *oi = rn->info;
5393
5394 if (!oi)
5395 continue;
5396
5397 oi->type = IF_DEF_PARAMS (ifp)->type;
5398
5399 if (oi->state > ISM_Down)
5400 {
5401 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5402 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5403 }
5404 }
5405
5406 return CMD_SUCCESS;
5407}
5408
5409ALIAS (no_ip_ospf_network,
5410 no_ospf_network_cmd,
5411 "no ospf network",
5412 NO_STR
5413 "OSPF interface commands\n"
5414 "Network type\n")
5415
5416DEFUN (ip_ospf_priority,
5417 ip_ospf_priority_addr_cmd,
5418 "ip ospf priority <0-255> A.B.C.D",
5419 "IP Information\n"
5420 "OSPF interface commands\n"
5421 "Router priority\n"
5422 "Priority\n"
5423 "Address of interface")
5424{
5425 struct interface *ifp = vty->index;
5426 u_int32_t priority;
5427 struct route_node *rn;
5428 struct in_addr addr;
5429 int ret;
5430 struct ospf_if_params *params;
5431
5432 params = IF_DEF_PARAMS (ifp);
5433
5434 priority = strtol (argv[0], NULL, 10);
5435
5436 /* Router Priority range is <0-255>. */
5437 if (priority < 0 || priority > 255)
5438 {
5439 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5440 return CMD_WARNING;
5441 }
5442
5443 if (argc == 2)
5444 {
5445 ret = inet_aton(argv[1], &addr);
5446 if (!ret)
5447 {
5448 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5449 VTY_NEWLINE);
5450 return CMD_WARNING;
5451 }
5452
5453 params = ospf_get_if_params (ifp, addr);
5454 ospf_if_update_params (ifp, addr);
5455 }
5456
5457 SET_IF_PARAM (params, priority);
5458 params->priority = priority;
5459
5460 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5461 {
5462 struct ospf_interface *oi = rn->info;
5463
5464 if (!oi)
5465 continue;
5466
5467
5468 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5469 {
5470 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5471 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5472 }
5473 }
5474
5475 return CMD_SUCCESS;
5476}
5477
5478ALIAS (ip_ospf_priority,
5479 ip_ospf_priority_cmd,
5480 "ip ospf priority <0-255>",
5481 "IP Information\n"
5482 "OSPF interface commands\n"
5483 "Router priority\n"
5484 "Priority\n")
5485
5486ALIAS (ip_ospf_priority,
5487 ospf_priority_cmd,
5488 "ospf priority <0-255>",
5489 "OSPF interface commands\n"
5490 "Router priority\n"
5491 "Priority\n")
5492
5493DEFUN (no_ip_ospf_priority,
5494 no_ip_ospf_priority_addr_cmd,
5495 "no ip ospf priority A.B.C.D",
5496 NO_STR
5497 "IP Information\n"
5498 "OSPF interface commands\n"
5499 "Router priority\n"
5500 "Address of interface")
5501{
5502 struct interface *ifp = vty->index;
5503 struct route_node *rn;
5504 struct in_addr addr;
5505 int ret;
5506 struct ospf_if_params *params;
5507
5508 ifp = vty->index;
5509 params = IF_DEF_PARAMS (ifp);
5510
5511 if (argc == 1)
5512 {
5513 ret = inet_aton(argv[0], &addr);
5514 if (!ret)
5515 {
5516 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5517 VTY_NEWLINE);
5518 return CMD_WARNING;
5519 }
5520
5521 params = ospf_lookup_if_params (ifp, addr);
5522 if (params == NULL)
5523 return CMD_SUCCESS;
5524 }
5525
5526 UNSET_IF_PARAM (params, priority);
5527 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5528
5529 if (params != IF_DEF_PARAMS (ifp))
5530 {
5531 ospf_free_if_params (ifp, addr);
5532 ospf_if_update_params (ifp, addr);
5533 }
5534
5535 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5536 {
5537 struct ospf_interface *oi = rn->info;
5538
5539 if (!oi)
5540 continue;
5541
5542
5543 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5544 {
5545 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5546 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5547 }
5548 }
5549
5550 return CMD_SUCCESS;
5551}
5552
5553ALIAS (no_ip_ospf_priority,
5554 no_ip_ospf_priority_cmd,
5555 "no ip ospf priority",
5556 NO_STR
5557 "IP Information\n"
5558 "OSPF interface commands\n"
5559 "Router priority\n")
5560
5561ALIAS (no_ip_ospf_priority,
5562 no_ospf_priority_cmd,
5563 "no ospf priority",
5564 NO_STR
5565 "OSPF interface commands\n"
5566 "Router priority\n")
5567
5568DEFUN (ip_ospf_retransmit_interval,
5569 ip_ospf_retransmit_interval_addr_cmd,
5570 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5571 "IP Information\n"
5572 "OSPF interface commands\n"
5573 "Time between retransmitting lost link state advertisements\n"
5574 "Seconds\n"
5575 "Address of interface")
5576{
5577 struct interface *ifp = vty->index;
5578 u_int32_t seconds;
5579 struct in_addr addr;
5580 int ret;
5581 struct ospf_if_params *params;
5582
5583 params = IF_DEF_PARAMS (ifp);
5584 seconds = strtol (argv[0], NULL, 10);
5585
5586 /* Retransmit Interval range is <3-65535>. */
5587 if (seconds < 3 || seconds > 65535)
5588 {
5589 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5590 return CMD_WARNING;
5591 }
5592
5593
5594 if (argc == 2)
5595 {
5596 ret = inet_aton(argv[1], &addr);
5597 if (!ret)
5598 {
5599 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5600 VTY_NEWLINE);
5601 return CMD_WARNING;
5602 }
5603
5604 params = ospf_get_if_params (ifp, addr);
5605 ospf_if_update_params (ifp, addr);
5606 }
5607
5608 SET_IF_PARAM (params, retransmit_interval);
5609 params->retransmit_interval = seconds;
5610
5611 return CMD_SUCCESS;
5612}
5613
5614ALIAS (ip_ospf_retransmit_interval,
5615 ip_ospf_retransmit_interval_cmd,
5616 "ip ospf retransmit-interval <3-65535>",
5617 "IP Information\n"
5618 "OSPF interface commands\n"
5619 "Time between retransmitting lost link state advertisements\n"
5620 "Seconds\n")
5621
5622ALIAS (ip_ospf_retransmit_interval,
5623 ospf_retransmit_interval_cmd,
5624 "ospf retransmit-interval <3-65535>",
5625 "OSPF interface commands\n"
5626 "Time between retransmitting lost link state advertisements\n"
5627 "Seconds\n")
5628
5629DEFUN (no_ip_ospf_retransmit_interval,
5630 no_ip_ospf_retransmit_interval_addr_cmd,
5631 "no ip ospf retransmit-interval A.B.C.D",
5632 NO_STR
5633 "IP Information\n"
5634 "OSPF interface commands\n"
5635 "Time between retransmitting lost link state advertisements\n"
5636 "Address of interface")
5637{
5638 struct interface *ifp = vty->index;
5639 struct in_addr addr;
5640 int ret;
5641 struct ospf_if_params *params;
5642
5643 ifp = vty->index;
5644 params = IF_DEF_PARAMS (ifp);
5645
5646 if (argc == 1)
5647 {
5648 ret = inet_aton(argv[0], &addr);
5649 if (!ret)
5650 {
5651 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5652 VTY_NEWLINE);
5653 return CMD_WARNING;
5654 }
5655
5656 params = ospf_lookup_if_params (ifp, addr);
5657 if (params == NULL)
5658 return CMD_SUCCESS;
5659 }
5660
5661 UNSET_IF_PARAM (params, retransmit_interval);
5662 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5663
5664 if (params != IF_DEF_PARAMS (ifp))
5665 {
5666 ospf_free_if_params (ifp, addr);
5667 ospf_if_update_params (ifp, addr);
5668 }
5669
5670 return CMD_SUCCESS;
5671}
5672
5673ALIAS (no_ip_ospf_retransmit_interval,
5674 no_ip_ospf_retransmit_interval_cmd,
5675 "no ip ospf retransmit-interval",
5676 NO_STR
5677 "IP Information\n"
5678 "OSPF interface commands\n"
5679 "Time between retransmitting lost link state advertisements\n")
5680
5681ALIAS (no_ip_ospf_retransmit_interval,
5682 no_ospf_retransmit_interval_cmd,
5683 "no ospf retransmit-interval",
5684 NO_STR
5685 "OSPF interface commands\n"
5686 "Time between retransmitting lost link state advertisements\n")
5687
5688DEFUN (ip_ospf_transmit_delay,
5689 ip_ospf_transmit_delay_addr_cmd,
5690 "ip ospf transmit-delay <1-65535> A.B.C.D",
5691 "IP Information\n"
5692 "OSPF interface commands\n"
5693 "Link state transmit delay\n"
5694 "Seconds\n"
5695 "Address of interface")
5696{
5697 struct interface *ifp = vty->index;
5698 u_int32_t seconds;
5699 struct in_addr addr;
5700 int ret;
5701 struct ospf_if_params *params;
5702
5703 params = IF_DEF_PARAMS (ifp);
5704 seconds = strtol (argv[0], NULL, 10);
5705
5706 /* Transmit Delay range is <1-65535>. */
5707 if (seconds < 1 || seconds > 65535)
5708 {
5709 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5710 return CMD_WARNING;
5711 }
5712
5713 if (argc == 2)
5714 {
5715 ret = inet_aton(argv[1], &addr);
5716 if (!ret)
5717 {
5718 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5719 VTY_NEWLINE);
5720 return CMD_WARNING;
5721 }
5722
5723 params = ospf_get_if_params (ifp, addr);
5724 ospf_if_update_params (ifp, addr);
5725 }
5726
5727 SET_IF_PARAM (params, transmit_delay);
5728 params->transmit_delay = seconds;
5729
5730 return CMD_SUCCESS;
5731}
5732
5733ALIAS (ip_ospf_transmit_delay,
5734 ip_ospf_transmit_delay_cmd,
5735 "ip ospf transmit-delay <1-65535>",
5736 "IP Information\n"
5737 "OSPF interface commands\n"
5738 "Link state transmit delay\n"
5739 "Seconds\n")
5740
5741ALIAS (ip_ospf_transmit_delay,
5742 ospf_transmit_delay_cmd,
5743 "ospf transmit-delay <1-65535>",
5744 "OSPF interface commands\n"
5745 "Link state transmit delay\n"
5746 "Seconds\n")
5747
5748DEFUN (no_ip_ospf_transmit_delay,
5749 no_ip_ospf_transmit_delay_addr_cmd,
5750 "no ip ospf transmit-delay A.B.C.D",
5751 NO_STR
5752 "IP Information\n"
5753 "OSPF interface commands\n"
5754 "Link state transmit delay\n"
5755 "Address of interface")
5756{
5757 struct interface *ifp = vty->index;
5758 struct in_addr addr;
5759 int ret;
5760 struct ospf_if_params *params;
5761
5762 ifp = vty->index;
5763 params = IF_DEF_PARAMS (ifp);
5764
5765 if (argc == 1)
5766 {
5767 ret = inet_aton(argv[0], &addr);
5768 if (!ret)
5769 {
5770 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5771 VTY_NEWLINE);
5772 return CMD_WARNING;
5773 }
5774
5775 params = ospf_lookup_if_params (ifp, addr);
5776 if (params == NULL)
5777 return CMD_SUCCESS;
5778 }
5779
5780 UNSET_IF_PARAM (params, transmit_delay);
5781 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5782
5783 if (params != IF_DEF_PARAMS (ifp))
5784 {
5785 ospf_free_if_params (ifp, addr);
5786 ospf_if_update_params (ifp, addr);
5787 }
5788
5789 return CMD_SUCCESS;
5790}
5791
5792ALIAS (no_ip_ospf_transmit_delay,
5793 no_ip_ospf_transmit_delay_cmd,
5794 "no ip ospf transmit-delay",
5795 NO_STR
5796 "IP Information\n"
5797 "OSPF interface commands\n"
5798 "Link state transmit delay\n")
5799
5800ALIAS (no_ip_ospf_transmit_delay,
5801 no_ospf_transmit_delay_cmd,
5802 "no ospf transmit-delay",
5803 NO_STR
5804 "OSPF interface commands\n"
5805 "Link state transmit delay\n")
5806
5807
5808DEFUN (ospf_redistribute_source_metric_type,
5809 ospf_redistribute_source_metric_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005810 "redistribute " QUAGGA_REDIST_STR_OSPFD
5811 " metric <0-16777214> metric-type (1|2) route-map WORD",
5812 REDIST_STR
5813 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005814 "Metric for redistributed routes\n"
5815 "OSPF default metric\n"
5816 "OSPF exterior metric type for redistributed routes\n"
5817 "Set OSPF External Type 1 metrics\n"
5818 "Set OSPF External Type 2 metrics\n"
5819 "Route map reference\n"
5820 "Pointer to route-map entries\n")
5821{
paul020709f2003-04-04 02:44:16 +00005822 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005823 int source;
5824 int type = -1;
5825 int metric = -1;
5826
5827 /* Get distribute source. */
5828 if (!str2distribute_source (argv[0], &source))
5829 return CMD_WARNING;
5830
5831 /* Get metric value. */
5832 if (argc >= 2)
5833 if (!str2metric (argv[1], &metric))
5834 return CMD_WARNING;
5835
5836 /* Get metric type. */
5837 if (argc >= 3)
5838 if (!str2metric_type (argv[2], &type))
5839 return CMD_WARNING;
5840
5841 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005842 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005843 else
paul020709f2003-04-04 02:44:16 +00005844 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005845
paul020709f2003-04-04 02:44:16 +00005846 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005847}
5848
5849ALIAS (ospf_redistribute_source_metric_type,
5850 ospf_redistribute_source_metric_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005851 "redistribute " QUAGGA_REDIST_STR_OSPFD
5852 " metric <0-16777214> metric-type (1|2)",
5853 REDIST_STR
5854 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005855 "Metric for redistributed routes\n"
5856 "OSPF default metric\n"
5857 "OSPF exterior metric type for redistributed routes\n"
5858 "Set OSPF External Type 1 metrics\n"
5859 "Set OSPF External Type 2 metrics\n")
5860
5861ALIAS (ospf_redistribute_source_metric_type,
5862 ospf_redistribute_source_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005863 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5864 REDIST_STR
5865 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005866 "Metric for redistributed routes\n"
5867 "OSPF default metric\n")
5868
5869DEFUN (ospf_redistribute_source_type_metric,
5870 ospf_redistribute_source_type_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005871 "redistribute " QUAGGA_REDIST_STR_OSPFD
5872 " metric-type (1|2) metric <0-16777214> route-map WORD",
5873 REDIST_STR
5874 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005875 "OSPF exterior metric type for redistributed routes\n"
5876 "Set OSPF External Type 1 metrics\n"
5877 "Set OSPF External Type 2 metrics\n"
5878 "Metric for redistributed routes\n"
5879 "OSPF default metric\n"
5880 "Route map reference\n"
5881 "Pointer to route-map entries\n")
5882{
paul020709f2003-04-04 02:44:16 +00005883 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005884 int source;
5885 int type = -1;
5886 int metric = -1;
5887
5888 /* Get distribute source. */
5889 if (!str2distribute_source (argv[0], &source))
5890 return CMD_WARNING;
5891
5892 /* Get metric value. */
5893 if (argc >= 2)
5894 if (!str2metric_type (argv[1], &type))
5895 return CMD_WARNING;
5896
5897 /* Get metric type. */
5898 if (argc >= 3)
5899 if (!str2metric (argv[2], &metric))
5900 return CMD_WARNING;
5901
5902 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005903 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005904 else
paul020709f2003-04-04 02:44:16 +00005905 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005906
paul020709f2003-04-04 02:44:16 +00005907 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005908}
5909
5910ALIAS (ospf_redistribute_source_type_metric,
5911 ospf_redistribute_source_type_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005912 "redistribute " QUAGGA_REDIST_STR_OSPFD
5913 " metric-type (1|2) metric <0-16777214>",
5914 REDIST_STR
5915 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005916 "OSPF exterior metric type for redistributed routes\n"
5917 "Set OSPF External Type 1 metrics\n"
5918 "Set OSPF External Type 2 metrics\n"
5919 "Metric for redistributed routes\n"
5920 "OSPF default metric\n")
5921
5922ALIAS (ospf_redistribute_source_type_metric,
5923 ospf_redistribute_source_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005924 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5925 REDIST_STR
5926 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005927 "OSPF exterior metric type for redistributed routes\n"
5928 "Set OSPF External Type 1 metrics\n"
5929 "Set OSPF External Type 2 metrics\n")
5930
5931ALIAS (ospf_redistribute_source_type_metric,
5932 ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005933 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5934 REDIST_STR
5935 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005936
5937DEFUN (ospf_redistribute_source_metric_routemap,
5938 ospf_redistribute_source_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005939 "redistribute " QUAGGA_REDIST_STR_OSPFD
5940 " metric <0-16777214> route-map WORD",
5941 REDIST_STR
5942 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005943 "Metric for redistributed routes\n"
5944 "OSPF default metric\n"
5945 "Route map reference\n"
5946 "Pointer to route-map entries\n")
5947{
paul020709f2003-04-04 02:44:16 +00005948 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005949 int source;
5950 int metric = -1;
5951
5952 /* Get distribute source. */
5953 if (!str2distribute_source (argv[0], &source))
5954 return CMD_WARNING;
5955
5956 /* Get metric value. */
5957 if (argc >= 2)
5958 if (!str2metric (argv[1], &metric))
5959 return CMD_WARNING;
5960
5961 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005962 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005963 else
paul020709f2003-04-04 02:44:16 +00005964 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005965
paul020709f2003-04-04 02:44:16 +00005966 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005967}
5968
5969DEFUN (ospf_redistribute_source_type_routemap,
5970 ospf_redistribute_source_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005971 "redistribute " QUAGGA_REDIST_STR_OSPFD
5972 " metric-type (1|2) route-map WORD",
5973 REDIST_STR
5974 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005975 "OSPF exterior metric type for redistributed routes\n"
5976 "Set OSPF External Type 1 metrics\n"
5977 "Set OSPF External Type 2 metrics\n"
5978 "Route map reference\n"
5979 "Pointer to route-map entries\n")
5980{
paul020709f2003-04-04 02:44:16 +00005981 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005982 int source;
5983 int type = -1;
5984
5985 /* Get distribute source. */
5986 if (!str2distribute_source (argv[0], &source))
5987 return CMD_WARNING;
5988
5989 /* Get metric value. */
5990 if (argc >= 2)
5991 if (!str2metric_type (argv[1], &type))
5992 return CMD_WARNING;
5993
5994 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005995 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005996 else
paul020709f2003-04-04 02:44:16 +00005997 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005998
paul020709f2003-04-04 02:44:16 +00005999 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00006000}
6001
6002DEFUN (ospf_redistribute_source_routemap,
6003 ospf_redistribute_source_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006004 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
6005 REDIST_STR
6006 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00006007 "Route map reference\n"
6008 "Pointer to route-map entries\n")
6009{
paul020709f2003-04-04 02:44:16 +00006010 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006011 int source;
6012
6013 /* Get distribute source. */
6014 if (!str2distribute_source (argv[0], &source))
6015 return CMD_WARNING;
6016
6017 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006018 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00006019 else
paul020709f2003-04-04 02:44:16 +00006020 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006021
paul020709f2003-04-04 02:44:16 +00006022 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00006023}
6024
6025DEFUN (no_ospf_redistribute_source,
6026 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006027 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006028 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006029 REDIST_STR
6030 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006031{
paul020709f2003-04-04 02:44:16 +00006032 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006033 int source;
6034
6035 if (!str2distribute_source (argv[0], &source))
6036 return CMD_WARNING;
6037
paul020709f2003-04-04 02:44:16 +00006038 ospf_routemap_unset (ospf, source);
6039 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006040}
6041
6042DEFUN (ospf_distribute_list_out,
6043 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006044 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006045 "Filter networks in routing updates\n"
6046 "Access-list name\n"
6047 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006048 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006049{
paul68980082003-03-25 05:07:42 +00006050 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006051 int source;
6052
6053 /* Get distribute source. */
6054 if (!str2distribute_source (argv[1], &source))
6055 return CMD_WARNING;
6056
paul68980082003-03-25 05:07:42 +00006057 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006058}
6059
6060DEFUN (no_ospf_distribute_list_out,
6061 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006062 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006063 NO_STR
6064 "Filter networks in routing updates\n"
6065 "Access-list name\n"
6066 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006067 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006068{
paul68980082003-03-25 05:07:42 +00006069 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006070 int source;
6071
6072 if (!str2distribute_source (argv[1], &source))
6073 return CMD_WARNING;
6074
paul68980082003-03-25 05:07:42 +00006075 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006076}
6077
6078/* Default information originate. */
6079DEFUN (ospf_default_information_originate_metric_type_routemap,
6080 ospf_default_information_originate_metric_type_routemap_cmd,
6081 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
6082 "Control distribution of default information\n"
6083 "Distribute a default route\n"
6084 "OSPF default metric\n"
6085 "OSPF metric\n"
6086 "OSPF metric type for default routes\n"
6087 "Set OSPF External Type 1 metrics\n"
6088 "Set OSPF External Type 2 metrics\n"
6089 "Route map reference\n"
6090 "Pointer to route-map entries\n")
6091{
paul020709f2003-04-04 02:44:16 +00006092 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006093 int type = -1;
6094 int metric = -1;
6095
6096 /* Get metric value. */
6097 if (argc >= 1)
6098 if (!str2metric (argv[0], &metric))
6099 return CMD_WARNING;
6100
6101 /* Get metric type. */
6102 if (argc >= 2)
6103 if (!str2metric_type (argv[1], &type))
6104 return CMD_WARNING;
6105
6106 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006107 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006108 else
paul020709f2003-04-04 02:44:16 +00006109 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006110
paul020709f2003-04-04 02:44:16 +00006111 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6112 type, metric);
paul718e3742002-12-13 20:15:29 +00006113}
6114
6115ALIAS (ospf_default_information_originate_metric_type_routemap,
6116 ospf_default_information_originate_metric_type_cmd,
6117 "default-information originate metric <0-16777214> metric-type (1|2)",
6118 "Control distribution of default information\n"
6119 "Distribute a default route\n"
6120 "OSPF default metric\n"
6121 "OSPF metric\n"
6122 "OSPF metric type for default routes\n"
6123 "Set OSPF External Type 1 metrics\n"
6124 "Set OSPF External Type 2 metrics\n")
6125
6126ALIAS (ospf_default_information_originate_metric_type_routemap,
6127 ospf_default_information_originate_metric_cmd,
6128 "default-information originate metric <0-16777214>",
6129 "Control distribution of default information\n"
6130 "Distribute a default route\n"
6131 "OSPF default metric\n"
6132 "OSPF metric\n")
6133
6134ALIAS (ospf_default_information_originate_metric_type_routemap,
6135 ospf_default_information_originate_cmd,
6136 "default-information originate",
6137 "Control distribution of default information\n"
6138 "Distribute a default route\n")
6139
6140/* Default information originate. */
6141DEFUN (ospf_default_information_originate_metric_routemap,
6142 ospf_default_information_originate_metric_routemap_cmd,
6143 "default-information originate metric <0-16777214> route-map WORD",
6144 "Control distribution of default information\n"
6145 "Distribute a default route\n"
6146 "OSPF default metric\n"
6147 "OSPF metric\n"
6148 "Route map reference\n"
6149 "Pointer to route-map entries\n")
6150{
paul020709f2003-04-04 02:44:16 +00006151 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006152 int metric = -1;
6153
6154 /* Get metric value. */
6155 if (argc >= 1)
6156 if (!str2metric (argv[0], &metric))
6157 return CMD_WARNING;
6158
6159 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006160 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006161 else
paul020709f2003-04-04 02:44:16 +00006162 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006163
paul020709f2003-04-04 02:44:16 +00006164 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6165 -1, metric);
paul718e3742002-12-13 20:15:29 +00006166}
6167
6168/* Default information originate. */
6169DEFUN (ospf_default_information_originate_routemap,
6170 ospf_default_information_originate_routemap_cmd,
6171 "default-information originate route-map WORD",
6172 "Control distribution of default information\n"
6173 "Distribute a default route\n"
6174 "Route map reference\n"
6175 "Pointer to route-map entries\n")
6176{
paul020709f2003-04-04 02:44:16 +00006177 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006178
paul020709f2003-04-04 02:44:16 +00006179 if (argc == 1)
6180 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6181 else
6182 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6183
6184 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00006185}
6186
6187DEFUN (ospf_default_information_originate_type_metric_routemap,
6188 ospf_default_information_originate_type_metric_routemap_cmd,
6189 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6190 "Control distribution of default information\n"
6191 "Distribute a default route\n"
6192 "OSPF metric type for default routes\n"
6193 "Set OSPF External Type 1 metrics\n"
6194 "Set OSPF External Type 2 metrics\n"
6195 "OSPF default metric\n"
6196 "OSPF metric\n"
6197 "Route map reference\n"
6198 "Pointer to route-map entries\n")
6199{
paul020709f2003-04-04 02:44:16 +00006200 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006201 int type = -1;
6202 int metric = -1;
6203
6204 /* Get metric type. */
6205 if (argc >= 1)
6206 if (!str2metric_type (argv[0], &type))
6207 return CMD_WARNING;
6208
6209 /* Get metric value. */
6210 if (argc >= 2)
6211 if (!str2metric (argv[1], &metric))
6212 return CMD_WARNING;
6213
6214 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006215 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006216 else
paul020709f2003-04-04 02:44:16 +00006217 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006218
paul020709f2003-04-04 02:44:16 +00006219 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6220 type, metric);
paul718e3742002-12-13 20:15:29 +00006221}
6222
6223ALIAS (ospf_default_information_originate_type_metric_routemap,
6224 ospf_default_information_originate_type_metric_cmd,
6225 "default-information originate metric-type (1|2) metric <0-16777214>",
6226 "Control distribution of default information\n"
6227 "Distribute a default route\n"
6228 "OSPF metric type for default routes\n"
6229 "Set OSPF External Type 1 metrics\n"
6230 "Set OSPF External Type 2 metrics\n"
6231 "OSPF default metric\n"
6232 "OSPF metric\n")
6233
6234ALIAS (ospf_default_information_originate_type_metric_routemap,
6235 ospf_default_information_originate_type_cmd,
6236 "default-information originate metric-type (1|2)",
6237 "Control distribution of default information\n"
6238 "Distribute a default route\n"
6239 "OSPF metric type for default routes\n"
6240 "Set OSPF External Type 1 metrics\n"
6241 "Set OSPF External Type 2 metrics\n")
6242
6243DEFUN (ospf_default_information_originate_type_routemap,
6244 ospf_default_information_originate_type_routemap_cmd,
6245 "default-information originate metric-type (1|2) route-map WORD",
6246 "Control distribution of default information\n"
6247 "Distribute a default route\n"
6248 "OSPF metric type for default routes\n"
6249 "Set OSPF External Type 1 metrics\n"
6250 "Set OSPF External Type 2 metrics\n"
6251 "Route map reference\n"
6252 "Pointer to route-map entries\n")
6253{
paul020709f2003-04-04 02:44:16 +00006254 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006255 int type = -1;
6256
6257 /* Get metric type. */
6258 if (argc >= 1)
6259 if (!str2metric_type (argv[0], &type))
6260 return CMD_WARNING;
6261
6262 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006263 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006264 else
paul020709f2003-04-04 02:44:16 +00006265 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006266
paul020709f2003-04-04 02:44:16 +00006267 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6268 type, -1);
paul718e3742002-12-13 20:15:29 +00006269}
6270
6271DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6272 ospf_default_information_originate_always_metric_type_routemap_cmd,
6273 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6274 "Control distribution of default information\n"
6275 "Distribute a default route\n"
6276 "Always advertise default route\n"
6277 "OSPF default metric\n"
6278 "OSPF metric\n"
6279 "OSPF metric type for default routes\n"
6280 "Set OSPF External Type 1 metrics\n"
6281 "Set OSPF External Type 2 metrics\n"
6282 "Route map reference\n"
6283 "Pointer to route-map entries\n")
6284{
paul020709f2003-04-04 02:44:16 +00006285 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006286 int type = -1;
6287 int metric = -1;
6288
6289 /* Get metric value. */
6290 if (argc >= 1)
6291 if (!str2metric (argv[0], &metric))
6292 return CMD_WARNING;
6293
6294 /* Get metric type. */
6295 if (argc >= 2)
6296 if (!str2metric_type (argv[1], &type))
6297 return CMD_WARNING;
6298
6299 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006300 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006301 else
paul020709f2003-04-04 02:44:16 +00006302 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006303
paul020709f2003-04-04 02:44:16 +00006304 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006305 type, metric);
6306}
6307
6308ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6309 ospf_default_information_originate_always_metric_type_cmd,
6310 "default-information originate always metric <0-16777214> metric-type (1|2)",
6311 "Control distribution of default information\n"
6312 "Distribute a default route\n"
6313 "Always advertise default route\n"
6314 "OSPF default metric\n"
6315 "OSPF metric\n"
6316 "OSPF metric type for default routes\n"
6317 "Set OSPF External Type 1 metrics\n"
6318 "Set OSPF External Type 2 metrics\n")
6319
6320ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6321 ospf_default_information_originate_always_metric_cmd,
6322 "default-information originate always metric <0-16777214>",
6323 "Control distribution of default information\n"
6324 "Distribute a default route\n"
6325 "Always advertise default route\n"
6326 "OSPF default metric\n"
6327 "OSPF metric\n"
6328 "OSPF metric type for default routes\n")
6329
6330ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6331 ospf_default_information_originate_always_cmd,
6332 "default-information originate always",
6333 "Control distribution of default information\n"
6334 "Distribute a default route\n"
6335 "Always advertise default route\n")
6336
6337DEFUN (ospf_default_information_originate_always_metric_routemap,
6338 ospf_default_information_originate_always_metric_routemap_cmd,
6339 "default-information originate always metric <0-16777214> route-map WORD",
6340 "Control distribution of default information\n"
6341 "Distribute a default route\n"
6342 "Always advertise default route\n"
6343 "OSPF default metric\n"
6344 "OSPF metric\n"
6345 "Route map reference\n"
6346 "Pointer to route-map entries\n")
6347{
paul020709f2003-04-04 02:44:16 +00006348 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006349 int metric = -1;
6350
6351 /* Get metric value. */
6352 if (argc >= 1)
6353 if (!str2metric (argv[0], &metric))
6354 return CMD_WARNING;
6355
6356 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006357 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006358 else
paul020709f2003-04-04 02:44:16 +00006359 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006360
paul020709f2003-04-04 02:44:16 +00006361 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6362 -1, metric);
paul718e3742002-12-13 20:15:29 +00006363}
6364
6365DEFUN (ospf_default_information_originate_always_routemap,
6366 ospf_default_information_originate_always_routemap_cmd,
6367 "default-information originate always route-map WORD",
6368 "Control distribution of default information\n"
6369 "Distribute a default route\n"
6370 "Always advertise default route\n"
6371 "Route map reference\n"
6372 "Pointer to route-map entries\n")
6373{
paul020709f2003-04-04 02:44:16 +00006374 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006375
paul020709f2003-04-04 02:44:16 +00006376 if (argc == 1)
6377 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6378 else
6379 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6380
6381 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006382}
6383
6384DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6385 ospf_default_information_originate_always_type_metric_routemap_cmd,
6386 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6387 "Control distribution of default information\n"
6388 "Distribute a default route\n"
6389 "Always advertise default route\n"
6390 "OSPF metric type for default routes\n"
6391 "Set OSPF External Type 1 metrics\n"
6392 "Set OSPF External Type 2 metrics\n"
6393 "OSPF default metric\n"
6394 "OSPF metric\n"
6395 "Route map reference\n"
6396 "Pointer to route-map entries\n")
6397{
paul020709f2003-04-04 02:44:16 +00006398 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006399 int type = -1;
6400 int metric = -1;
6401
6402 /* Get metric type. */
6403 if (argc >= 1)
6404 if (!str2metric_type (argv[0], &type))
6405 return CMD_WARNING;
6406
6407 /* Get metric value. */
6408 if (argc >= 2)
6409 if (!str2metric (argv[1], &metric))
6410 return CMD_WARNING;
6411
6412 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006413 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006414 else
paul020709f2003-04-04 02:44:16 +00006415 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006416
paul020709f2003-04-04 02:44:16 +00006417 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006418 type, metric);
6419}
6420
6421ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6422 ospf_default_information_originate_always_type_metric_cmd,
6423 "default-information originate always metric-type (1|2) metric <0-16777214>",
6424 "Control distribution of default information\n"
6425 "Distribute a default route\n"
6426 "Always advertise default route\n"
6427 "OSPF metric type for default routes\n"
6428 "Set OSPF External Type 1 metrics\n"
6429 "Set OSPF External Type 2 metrics\n"
6430 "OSPF default metric\n"
6431 "OSPF metric\n")
6432
6433ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6434 ospf_default_information_originate_always_type_cmd,
6435 "default-information originate always metric-type (1|2)",
6436 "Control distribution of default information\n"
6437 "Distribute a default route\n"
6438 "Always advertise default route\n"
6439 "OSPF metric type for default routes\n"
6440 "Set OSPF External Type 1 metrics\n"
6441 "Set OSPF External Type 2 metrics\n")
6442
6443DEFUN (ospf_default_information_originate_always_type_routemap,
6444 ospf_default_information_originate_always_type_routemap_cmd,
6445 "default-information originate always metric-type (1|2) route-map WORD",
6446 "Control distribution of default information\n"
6447 "Distribute a default route\n"
6448 "Always advertise default route\n"
6449 "OSPF metric type for default routes\n"
6450 "Set OSPF External Type 1 metrics\n"
6451 "Set OSPF External Type 2 metrics\n"
6452 "Route map reference\n"
6453 "Pointer to route-map entries\n")
6454{
paul020709f2003-04-04 02:44:16 +00006455 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006456 int type = -1;
6457
6458 /* Get metric type. */
6459 if (argc >= 1)
6460 if (!str2metric_type (argv[0], &type))
6461 return CMD_WARNING;
6462
6463 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006464 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006465 else
paul020709f2003-04-04 02:44:16 +00006466 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006467
paul020709f2003-04-04 02:44:16 +00006468 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006469 type, -1);
6470}
6471
6472DEFUN (no_ospf_default_information_originate,
6473 no_ospf_default_information_originate_cmd,
6474 "no default-information originate",
6475 NO_STR
6476 "Control distribution of default information\n"
6477 "Distribute a default route\n")
6478{
paul68980082003-03-25 05:07:42 +00006479 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006480 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006481
6482 p.family = AF_INET;
6483 p.prefix.s_addr = 0;
6484 p.prefixlen = 0;
6485
ajs5339cfd2005-09-19 13:28:05 +00006486 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006487
6488 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6489 ospf_external_info_delete (DEFAULT_ROUTE, p);
6490 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6491 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6492 }
6493
paul020709f2003-04-04 02:44:16 +00006494 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6495 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006496}
6497
6498DEFUN (ospf_default_metric,
6499 ospf_default_metric_cmd,
6500 "default-metric <0-16777214>",
6501 "Set metric of redistributed routes\n"
6502 "Default metric\n")
6503{
paul68980082003-03-25 05:07:42 +00006504 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006505 int metric = -1;
6506
6507 if (!str2metric (argv[0], &metric))
6508 return CMD_WARNING;
6509
paul68980082003-03-25 05:07:42 +00006510 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006511
6512 return CMD_SUCCESS;
6513}
6514
6515DEFUN (no_ospf_default_metric,
6516 no_ospf_default_metric_cmd,
6517 "no default-metric",
6518 NO_STR
6519 "Set metric of redistributed routes\n")
6520{
paul68980082003-03-25 05:07:42 +00006521 struct ospf *ospf = vty->index;
6522
6523 ospf->default_metric = -1;
6524
paul718e3742002-12-13 20:15:29 +00006525 return CMD_SUCCESS;
6526}
6527
6528ALIAS (no_ospf_default_metric,
6529 no_ospf_default_metric_val_cmd,
6530 "no default-metric <0-16777214>",
6531 NO_STR
6532 "Set metric of redistributed routes\n"
6533 "Default metric\n")
6534
6535DEFUN (ospf_distance,
6536 ospf_distance_cmd,
6537 "distance <1-255>",
6538 "Define an administrative distance\n"
6539 "OSPF Administrative distance\n")
6540{
paul68980082003-03-25 05:07:42 +00006541 struct ospf *ospf = vty->index;
6542
6543 ospf->distance_all = atoi (argv[0]);
6544
paul718e3742002-12-13 20:15:29 +00006545 return CMD_SUCCESS;
6546}
6547
6548DEFUN (no_ospf_distance,
6549 no_ospf_distance_cmd,
6550 "no distance <1-255>",
6551 NO_STR
6552 "Define an administrative distance\n"
6553 "OSPF Administrative distance\n")
6554{
paul68980082003-03-25 05:07:42 +00006555 struct ospf *ospf = vty->index;
6556
6557 ospf->distance_all = 0;
6558
paul718e3742002-12-13 20:15:29 +00006559 return CMD_SUCCESS;
6560}
6561
6562DEFUN (no_ospf_distance_ospf,
6563 no_ospf_distance_ospf_cmd,
6564 "no distance ospf",
6565 NO_STR
6566 "Define an administrative distance\n"
6567 "OSPF Administrative distance\n"
6568 "OSPF Distance\n")
6569{
paul68980082003-03-25 05:07:42 +00006570 struct ospf *ospf = vty->index;
6571
6572 ospf->distance_intra = 0;
6573 ospf->distance_inter = 0;
6574 ospf->distance_external = 0;
6575
paul718e3742002-12-13 20:15:29 +00006576 return CMD_SUCCESS;
6577}
6578
6579DEFUN (ospf_distance_ospf_intra,
6580 ospf_distance_ospf_intra_cmd,
6581 "distance ospf intra-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{
paul68980082003-03-25 05:07:42 +00006587 struct ospf *ospf = vty->index;
6588
6589 ospf->distance_intra = atoi (argv[0]);
6590
paul718e3742002-12-13 20:15:29 +00006591 return CMD_SUCCESS;
6592}
6593
6594DEFUN (ospf_distance_ospf_intra_inter,
6595 ospf_distance_ospf_intra_inter_cmd,
6596 "distance ospf intra-area <1-255> inter-area <1-255>",
6597 "Define an administrative distance\n"
6598 "OSPF Administrative distance\n"
6599 "Intra-area routes\n"
6600 "Distance for intra-area routes\n"
6601 "Inter-area routes\n"
6602 "Distance for inter-area routes\n")
6603{
paul68980082003-03-25 05:07:42 +00006604 struct ospf *ospf = vty->index;
6605
6606 ospf->distance_intra = atoi (argv[0]);
6607 ospf->distance_inter = atoi (argv[1]);
6608
paul718e3742002-12-13 20:15:29 +00006609 return CMD_SUCCESS;
6610}
6611
6612DEFUN (ospf_distance_ospf_intra_external,
6613 ospf_distance_ospf_intra_external_cmd,
6614 "distance ospf intra-area <1-255> external <1-255>",
6615 "Define an administrative distance\n"
6616 "OSPF Administrative distance\n"
6617 "Intra-area routes\n"
6618 "Distance for intra-area routes\n"
6619 "External routes\n"
6620 "Distance for external routes\n")
6621{
paul68980082003-03-25 05:07:42 +00006622 struct ospf *ospf = vty->index;
6623
6624 ospf->distance_intra = atoi (argv[0]);
6625 ospf->distance_external = atoi (argv[1]);
6626
paul718e3742002-12-13 20:15:29 +00006627 return CMD_SUCCESS;
6628}
6629
6630DEFUN (ospf_distance_ospf_intra_inter_external,
6631 ospf_distance_ospf_intra_inter_external_cmd,
6632 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6633 "Define an administrative distance\n"
6634 "OSPF Administrative distance\n"
6635 "Intra-area routes\n"
6636 "Distance for intra-area routes\n"
6637 "Inter-area routes\n"
6638 "Distance for inter-area routes\n"
6639 "External routes\n"
6640 "Distance for external routes\n")
6641{
paul68980082003-03-25 05:07:42 +00006642 struct ospf *ospf = vty->index;
6643
6644 ospf->distance_intra = atoi (argv[0]);
6645 ospf->distance_inter = atoi (argv[1]);
6646 ospf->distance_external = atoi (argv[2]);
6647
paul718e3742002-12-13 20:15:29 +00006648 return CMD_SUCCESS;
6649}
6650
6651DEFUN (ospf_distance_ospf_intra_external_inter,
6652 ospf_distance_ospf_intra_external_inter_cmd,
6653 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6654 "Define an administrative distance\n"
6655 "OSPF Administrative distance\n"
6656 "Intra-area routes\n"
6657 "Distance for intra-area routes\n"
6658 "External routes\n"
6659 "Distance for external routes\n"
6660 "Inter-area routes\n"
6661 "Distance for inter-area routes\n")
6662{
paul68980082003-03-25 05:07:42 +00006663 struct ospf *ospf = vty->index;
6664
6665 ospf->distance_intra = atoi (argv[0]);
6666 ospf->distance_external = atoi (argv[1]);
6667 ospf->distance_inter = atoi (argv[2]);
6668
paul718e3742002-12-13 20:15:29 +00006669 return CMD_SUCCESS;
6670}
6671
6672DEFUN (ospf_distance_ospf_inter,
6673 ospf_distance_ospf_inter_cmd,
6674 "distance ospf inter-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{
paul68980082003-03-25 05:07:42 +00006680 struct ospf *ospf = vty->index;
6681
6682 ospf->distance_inter = atoi (argv[0]);
6683
paul718e3742002-12-13 20:15:29 +00006684 return CMD_SUCCESS;
6685}
6686
6687DEFUN (ospf_distance_ospf_inter_intra,
6688 ospf_distance_ospf_inter_intra_cmd,
6689 "distance ospf inter-area <1-255> intra-area <1-255>",
6690 "Define an administrative distance\n"
6691 "OSPF Administrative distance\n"
6692 "Inter-area routes\n"
6693 "Distance for inter-area routes\n"
6694 "Intra-area routes\n"
6695 "Distance for intra-area routes\n")
6696{
paul68980082003-03-25 05:07:42 +00006697 struct ospf *ospf = vty->index;
6698
6699 ospf->distance_inter = atoi (argv[0]);
6700 ospf->distance_intra = atoi (argv[1]);
6701
paul718e3742002-12-13 20:15:29 +00006702 return CMD_SUCCESS;
6703}
6704
6705DEFUN (ospf_distance_ospf_inter_external,
6706 ospf_distance_ospf_inter_external_cmd,
6707 "distance ospf inter-area <1-255> external <1-255>",
6708 "Define an administrative distance\n"
6709 "OSPF Administrative distance\n"
6710 "Inter-area routes\n"
6711 "Distance for inter-area routes\n"
6712 "External routes\n"
6713 "Distance for external routes\n")
6714{
paul68980082003-03-25 05:07:42 +00006715 struct ospf *ospf = vty->index;
6716
6717 ospf->distance_inter = atoi (argv[0]);
6718 ospf->distance_external = atoi (argv[1]);
6719
paul718e3742002-12-13 20:15:29 +00006720 return CMD_SUCCESS;
6721}
6722
6723DEFUN (ospf_distance_ospf_inter_intra_external,
6724 ospf_distance_ospf_inter_intra_external_cmd,
6725 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6726 "Define an administrative distance\n"
6727 "OSPF Administrative distance\n"
6728 "Inter-area routes\n"
6729 "Distance for inter-area routes\n"
6730 "Intra-area routes\n"
6731 "Distance for intra-area routes\n"
6732 "External routes\n"
6733 "Distance for external routes\n")
6734{
paul68980082003-03-25 05:07:42 +00006735 struct ospf *ospf = vty->index;
6736
6737 ospf->distance_inter = atoi (argv[0]);
6738 ospf->distance_intra = atoi (argv[1]);
6739 ospf->distance_external = atoi (argv[2]);
6740
paul718e3742002-12-13 20:15:29 +00006741 return CMD_SUCCESS;
6742}
6743
6744DEFUN (ospf_distance_ospf_inter_external_intra,
6745 ospf_distance_ospf_inter_external_intra_cmd,
6746 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6747 "Define an administrative distance\n"
6748 "OSPF Administrative distance\n"
6749 "Inter-area routes\n"
6750 "Distance for inter-area routes\n"
6751 "External routes\n"
6752 "Distance for external routes\n"
6753 "Intra-area routes\n"
6754 "Distance for intra-area routes\n")
6755{
paul68980082003-03-25 05:07:42 +00006756 struct ospf *ospf = vty->index;
6757
6758 ospf->distance_inter = atoi (argv[0]);
6759 ospf->distance_external = atoi (argv[1]);
6760 ospf->distance_intra = atoi (argv[2]);
6761
paul718e3742002-12-13 20:15:29 +00006762 return CMD_SUCCESS;
6763}
6764
6765DEFUN (ospf_distance_ospf_external,
6766 ospf_distance_ospf_external_cmd,
6767 "distance ospf external <1-255>",
6768 "Define an administrative distance\n"
6769 "OSPF Administrative distance\n"
6770 "External routes\n"
6771 "Distance for external routes\n")
6772{
paul68980082003-03-25 05:07:42 +00006773 struct ospf *ospf = vty->index;
6774
6775 ospf->distance_external = atoi (argv[0]);
6776
paul718e3742002-12-13 20:15:29 +00006777 return CMD_SUCCESS;
6778}
6779
6780DEFUN (ospf_distance_ospf_external_intra,
6781 ospf_distance_ospf_external_intra_cmd,
6782 "distance ospf external <1-255> intra-area <1-255>",
6783 "Define an administrative distance\n"
6784 "OSPF Administrative distance\n"
6785 "External routes\n"
6786 "Distance for external routes\n"
6787 "Intra-area routes\n"
6788 "Distance for intra-area routes\n")
6789{
paul68980082003-03-25 05:07:42 +00006790 struct ospf *ospf = vty->index;
6791
6792 ospf->distance_external = atoi (argv[0]);
6793 ospf->distance_intra = atoi (argv[1]);
6794
paul718e3742002-12-13 20:15:29 +00006795 return CMD_SUCCESS;
6796}
6797
6798DEFUN (ospf_distance_ospf_external_inter,
6799 ospf_distance_ospf_external_inter_cmd,
6800 "distance ospf external <1-255> inter-area <1-255>",
6801 "Define an administrative distance\n"
6802 "OSPF Administrative distance\n"
6803 "External routes\n"
6804 "Distance for external routes\n"
6805 "Inter-area routes\n"
6806 "Distance for inter-area routes\n")
6807{
paul68980082003-03-25 05:07:42 +00006808 struct ospf *ospf = vty->index;
6809
6810 ospf->distance_external = atoi (argv[0]);
6811 ospf->distance_inter = atoi (argv[1]);
6812
paul718e3742002-12-13 20:15:29 +00006813 return CMD_SUCCESS;
6814}
6815
6816DEFUN (ospf_distance_ospf_external_intra_inter,
6817 ospf_distance_ospf_external_intra_inter_cmd,
6818 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6819 "Define an administrative distance\n"
6820 "OSPF Administrative distance\n"
6821 "External routes\n"
6822 "Distance for external routes\n"
6823 "Intra-area routes\n"
6824 "Distance for intra-area routes\n"
6825 "Inter-area routes\n"
6826 "Distance for inter-area routes\n")
6827{
paul68980082003-03-25 05:07:42 +00006828 struct ospf *ospf = vty->index;
6829
6830 ospf->distance_external = atoi (argv[0]);
6831 ospf->distance_intra = atoi (argv[1]);
6832 ospf->distance_inter = atoi (argv[2]);
6833
paul718e3742002-12-13 20:15:29 +00006834 return CMD_SUCCESS;
6835}
6836
6837DEFUN (ospf_distance_ospf_external_inter_intra,
6838 ospf_distance_ospf_external_inter_intra_cmd,
6839 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6840 "Define an administrative distance\n"
6841 "OSPF Administrative distance\n"
6842 "External routes\n"
6843 "Distance for external routes\n"
6844 "Inter-area routes\n"
6845 "Distance for inter-area routes\n"
6846 "Intra-area routes\n"
6847 "Distance for intra-area routes\n")
6848{
paul68980082003-03-25 05:07:42 +00006849 struct ospf *ospf = vty->index;
6850
6851 ospf->distance_external = atoi (argv[0]);
6852 ospf->distance_inter = atoi (argv[1]);
6853 ospf->distance_intra = atoi (argv[2]);
6854
paul718e3742002-12-13 20:15:29 +00006855 return CMD_SUCCESS;
6856}
6857
6858DEFUN (ospf_distance_source,
6859 ospf_distance_source_cmd,
6860 "distance <1-255> A.B.C.D/M",
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_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006868
paul718e3742002-12-13 20:15:29 +00006869 return CMD_SUCCESS;
6870}
6871
6872DEFUN (no_ospf_distance_source,
6873 no_ospf_distance_source_cmd,
6874 "no distance <1-255> A.B.C.D/M",
6875 NO_STR
6876 "Administrative distance\n"
6877 "Distance value\n"
6878 "IP source prefix\n")
6879{
paul020709f2003-04-04 02:44:16 +00006880 struct ospf *ospf = vty->index;
6881
6882 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6883
paul718e3742002-12-13 20:15:29 +00006884 return CMD_SUCCESS;
6885}
6886
6887DEFUN (ospf_distance_source_access_list,
6888 ospf_distance_source_access_list_cmd,
6889 "distance <1-255> A.B.C.D/M WORD",
6890 "Administrative distance\n"
6891 "Distance value\n"
6892 "IP source prefix\n"
6893 "Access list name\n")
6894{
paul020709f2003-04-04 02:44:16 +00006895 struct ospf *ospf = vty->index;
6896
6897 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6898
paul718e3742002-12-13 20:15:29 +00006899 return CMD_SUCCESS;
6900}
6901
6902DEFUN (no_ospf_distance_source_access_list,
6903 no_ospf_distance_source_access_list_cmd,
6904 "no distance <1-255> A.B.C.D/M WORD",
6905 NO_STR
6906 "Administrative distance\n"
6907 "Distance value\n"
6908 "IP source prefix\n"
6909 "Access list name\n")
6910{
paul020709f2003-04-04 02:44:16 +00006911 struct ospf *ospf = vty->index;
6912
6913 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6914
paul718e3742002-12-13 20:15:29 +00006915 return CMD_SUCCESS;
6916}
6917
vincentba682532005-09-29 13:52:57 +00006918DEFUN (ip_ospf_mtu_ignore,
6919 ip_ospf_mtu_ignore_addr_cmd,
6920 "ip ospf mtu-ignore A.B.C.D",
6921 "IP Information\n"
6922 "OSPF interface commands\n"
6923 "Disable mtu mismatch detection\n"
6924 "Address of interface")
6925{
6926 struct interface *ifp = vty->index;
6927 struct in_addr addr;
6928 int ret;
6929
6930 struct ospf_if_params *params;
6931 params = IF_DEF_PARAMS (ifp);
6932
6933 if (argc == 1)
6934 {
6935 ret = inet_aton(argv[0], &addr);
6936 if (!ret)
6937 {
6938 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6939 VTY_NEWLINE);
6940 return CMD_WARNING;
6941 }
6942 params = ospf_get_if_params (ifp, addr);
6943 ospf_if_update_params (ifp, addr);
6944 }
6945 params->mtu_ignore = 1;
6946 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6947 SET_IF_PARAM (params, mtu_ignore);
6948 else
6949 {
6950 UNSET_IF_PARAM (params, mtu_ignore);
6951 if (params != IF_DEF_PARAMS (ifp))
6952 {
6953 ospf_free_if_params (ifp, addr);
6954 ospf_if_update_params (ifp, addr);
6955 }
6956 }
6957 return CMD_SUCCESS;
6958}
6959
6960ALIAS (ip_ospf_mtu_ignore,
6961 ip_ospf_mtu_ignore_cmd,
6962 "ip ospf mtu-ignore",
6963 "IP Information\n"
6964 "OSPF interface commands\n"
6965 "Disable mtu mismatch detection\n")
6966
6967
6968DEFUN (no_ip_ospf_mtu_ignore,
6969 no_ip_ospf_mtu_ignore_addr_cmd,
6970 "no ip ospf mtu-ignore A.B.C.D",
6971 "IP Information\n"
6972 "OSPF interface commands\n"
6973 "Disable mtu mismatch detection\n"
6974 "Address of interface")
6975{
6976 struct interface *ifp = vty->index;
6977 struct in_addr addr;
6978 int ret;
6979
6980 struct ospf_if_params *params;
6981 params = IF_DEF_PARAMS (ifp);
6982
6983 if (argc == 1)
6984 {
6985 ret = inet_aton(argv[0], &addr);
6986 if (!ret)
6987 {
6988 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6989 VTY_NEWLINE);
6990 return CMD_WARNING;
6991 }
6992 params = ospf_get_if_params (ifp, addr);
6993 ospf_if_update_params (ifp, addr);
6994 }
6995 params->mtu_ignore = 0;
6996 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6997 SET_IF_PARAM (params, mtu_ignore);
6998 else
6999 {
7000 UNSET_IF_PARAM (params, mtu_ignore);
7001 if (params != IF_DEF_PARAMS (ifp))
7002 {
7003 ospf_free_if_params (ifp, addr);
7004 ospf_if_update_params (ifp, addr);
7005 }
7006 }
7007 return CMD_SUCCESS;
7008}
7009
7010ALIAS (no_ip_ospf_mtu_ignore,
7011 no_ip_ospf_mtu_ignore_cmd,
7012 "no ip ospf mtu-ignore",
7013 "IP Information\n"
7014 "OSPF interface commands\n"
7015 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00007016
7017DEFUN (ospf_max_metric_router_lsa_admin,
7018 ospf_max_metric_router_lsa_admin_cmd,
7019 "max-metric router-lsa administrative",
7020 "OSPF maximum / infinite-distance metric\n"
7021 "Advertise own Router-LSA with infinite distance (stub router)\n"
7022 "Administratively applied, for an indefinite period\n")
7023{
7024 struct listnode *ln;
7025 struct ospf_area *area;
7026 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00007027
paul88d6cf32005-10-29 12:50:09 +00007028 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7029 {
7030 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7031
7032 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
Paul Jakmac363d382010-01-24 22:42:13 +00007033 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007034 }
7035 return CMD_SUCCESS;
7036}
7037
7038DEFUN (no_ospf_max_metric_router_lsa_admin,
7039 no_ospf_max_metric_router_lsa_admin_cmd,
7040 "no max-metric router-lsa administrative",
7041 NO_STR
7042 "OSPF maximum / infinite-distance metric\n"
7043 "Advertise own Router-LSA with infinite distance (stub router)\n"
7044 "Administratively applied, for an indefinite period\n")
7045{
7046 struct listnode *ln;
7047 struct ospf_area *area;
7048 struct ospf *ospf = vty->index;
7049
7050 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7051 {
7052 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7053
7054 /* Don't trample on the start-up stub timer */
7055 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
7056 && !area->t_stub_router)
7057 {
7058 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00007059 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007060 }
7061 }
7062 return CMD_SUCCESS;
7063}
7064
7065DEFUN (ospf_max_metric_router_lsa_startup,
7066 ospf_max_metric_router_lsa_startup_cmd,
7067 "max-metric router-lsa on-startup <5-86400>",
7068 "OSPF maximum / infinite-distance metric\n"
7069 "Advertise own Router-LSA with infinite distance (stub router)\n"
7070 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7071 "Time (seconds) to advertise self as stub-router\n")
7072{
7073 unsigned int seconds;
7074 struct ospf *ospf = vty->index;
7075
7076 if (argc != 1)
7077 {
7078 vty_out (vty, "%% Must supply stub-router period");
7079 return CMD_WARNING;
7080 }
7081
7082 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
7083
7084 ospf->stub_router_startup_time = seconds;
7085
7086 return CMD_SUCCESS;
7087}
7088
7089DEFUN (no_ospf_max_metric_router_lsa_startup,
7090 no_ospf_max_metric_router_lsa_startup_cmd,
7091 "no max-metric router-lsa on-startup",
7092 NO_STR
7093 "OSPF maximum / infinite-distance metric\n"
7094 "Advertise own Router-LSA with infinite distance (stub router)\n"
7095 "Automatically advertise stub Router-LSA on startup of OSPF\n")
7096{
7097 struct listnode *ln;
7098 struct ospf_area *area;
7099 struct ospf *ospf = vty->index;
7100
7101 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7102
7103 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7104 {
7105 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
7106 OSPF_TIMER_OFF (area->t_stub_router);
7107
7108 /* Don't trample on admin stub routed */
7109 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7110 {
7111 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00007112 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007113 }
7114 }
7115 return CMD_SUCCESS;
7116}
7117
7118DEFUN (ospf_max_metric_router_lsa_shutdown,
7119 ospf_max_metric_router_lsa_shutdown_cmd,
7120 "max-metric router-lsa on-shutdown <5-86400>",
7121 "OSPF maximum / infinite-distance metric\n"
7122 "Advertise own Router-LSA with infinite distance (stub router)\n"
7123 "Advertise stub-router prior to full shutdown of OSPF\n"
7124 "Time (seconds) to wait till full shutdown\n")
7125{
7126 unsigned int seconds;
7127 struct ospf *ospf = vty->index;
7128
7129 if (argc != 1)
7130 {
7131 vty_out (vty, "%% Must supply stub-router shutdown period");
7132 return CMD_WARNING;
7133 }
7134
7135 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
7136
7137 ospf->stub_router_shutdown_time = seconds;
7138
7139 return CMD_SUCCESS;
7140}
7141
7142DEFUN (no_ospf_max_metric_router_lsa_shutdown,
7143 no_ospf_max_metric_router_lsa_shutdown_cmd,
7144 "no max-metric router-lsa on-shutdown",
7145 NO_STR
7146 "OSPF maximum / infinite-distance metric\n"
7147 "Advertise own Router-LSA with infinite distance (stub router)\n"
7148 "Advertise stub-router prior to full shutdown of OSPF\n")
7149{
7150 struct ospf *ospf = vty->index;
7151
7152 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7153
7154 return CMD_SUCCESS;
7155}
7156
7157static void
7158config_write_stub_router (struct vty *vty, struct ospf *ospf)
7159{
7160 struct listnode *ln;
7161 struct ospf_area *area;
7162
7163 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7164 vty_out (vty, " max-metric router-lsa on-startup %u%s",
7165 ospf->stub_router_startup_time, VTY_NEWLINE);
7166 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7167 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
7168 ospf->stub_router_shutdown_time, VTY_NEWLINE);
7169 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7170 {
7171 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7172 {
7173 vty_out (vty, " max-metric router-lsa administrative%s",
7174 VTY_NEWLINE);
7175 break;
7176 }
7177 }
7178 return;
7179}
7180
paul4dadc292005-05-06 21:37:42 +00007181static void
paul718e3742002-12-13 20:15:29 +00007182show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7183{
7184 struct route_node *rn;
7185 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007186 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007187 struct ospf_path *path;
7188
7189 vty_out (vty, "============ OSPF network routing table ============%s",
7190 VTY_NEWLINE);
7191
7192 for (rn = route_top (rt); rn; rn = route_next (rn))
7193 if ((or = rn->info) != NULL)
7194 {
7195 char buf1[19];
7196 snprintf (buf1, 19, "%s/%d",
7197 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7198
7199 switch (or->path_type)
7200 {
7201 case OSPF_PATH_INTER_AREA:
7202 if (or->type == OSPF_DESTINATION_NETWORK)
7203 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7204 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7205 else if (or->type == OSPF_DESTINATION_DISCARD)
7206 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7207 break;
7208 case OSPF_PATH_INTRA_AREA:
7209 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7210 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7211 break;
7212 default:
7213 break;
7214 }
7215
7216 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007217 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007218 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007219 if (if_lookup_by_index(path->ifindex))
paul96735ee2003-08-10 02:51:22 +00007220 {
7221 if (path->nexthop.s_addr == 0)
7222 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007223 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007224 else
7225 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007226 inet_ntoa (path->nexthop),
7227 ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007228 }
7229 }
paul718e3742002-12-13 20:15:29 +00007230 }
7231 vty_out (vty, "%s", VTY_NEWLINE);
7232}
7233
paul4dadc292005-05-06 21:37:42 +00007234static void
paul718e3742002-12-13 20:15:29 +00007235show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7236{
7237 struct route_node *rn;
7238 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007239 struct listnode *pnode;
7240 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007241 struct ospf_path *path;
7242
7243 vty_out (vty, "============ OSPF router routing table =============%s",
7244 VTY_NEWLINE);
7245 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7246 if (rn->info)
7247 {
7248 int flag = 0;
7249
7250 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7251
paul1eb8ef22005-04-07 07:30:20 +00007252 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7253 {
7254 if (flag++)
7255 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007256
paul1eb8ef22005-04-07 07:30:20 +00007257 /* Show path. */
7258 vty_out (vty, "%s [%d] area: %s",
7259 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7260 or->cost, inet_ntoa (or->u.std.area_id));
7261 /* Show flags. */
7262 vty_out (vty, "%s%s%s",
7263 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7264 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7265 VTY_NEWLINE);
7266
7267 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7268 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007269 if (if_lookup_by_index(path->ifindex))
hasso54bedb52005-08-17 13:31:47 +00007270 {
7271 if (path->nexthop.s_addr == 0)
7272 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007273 "", ifindex2ifname (path->ifindex),
7274 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007275 else
7276 vty_out (vty, "%24s via %s, %s%s", "",
7277 inet_ntoa (path->nexthop),
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007278 ifindex2ifname (path->ifindex),
7279 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007280 }
paul1eb8ef22005-04-07 07:30:20 +00007281 }
7282 }
paul718e3742002-12-13 20:15:29 +00007283 }
7284 vty_out (vty, "%s", VTY_NEWLINE);
7285}
7286
paul4dadc292005-05-06 21:37:42 +00007287static void
paul718e3742002-12-13 20:15:29 +00007288show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7289{
7290 struct route_node *rn;
7291 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007292 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007293 struct ospf_path *path;
7294
7295 vty_out (vty, "============ OSPF external routing table ===========%s",
7296 VTY_NEWLINE);
7297 for (rn = route_top (rt); rn; rn = route_next (rn))
7298 if ((er = rn->info) != NULL)
7299 {
7300 char buf1[19];
7301 snprintf (buf1, 19, "%s/%d",
7302 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7303
7304 switch (er->path_type)
7305 {
7306 case OSPF_PATH_TYPE1_EXTERNAL:
7307 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7308 er->cost, er->u.ext.tag, VTY_NEWLINE);
7309 break;
7310 case OSPF_PATH_TYPE2_EXTERNAL:
7311 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7312 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7313 break;
7314 }
7315
paul1eb8ef22005-04-07 07:30:20 +00007316 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007317 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007318 if (if_lookup_by_index(path->ifindex))
paul718e3742002-12-13 20:15:29 +00007319 {
7320 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007321 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007322 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007323 else
7324 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007325 inet_ntoa (path->nexthop),
7326 ifindex2ifname (path->ifindex),
paul96735ee2003-08-10 02:51:22 +00007327 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007328 }
7329 }
7330 }
7331 vty_out (vty, "%s", VTY_NEWLINE);
7332}
7333
paul718e3742002-12-13 20:15:29 +00007334DEFUN (show_ip_ospf_border_routers,
7335 show_ip_ospf_border_routers_cmd,
7336 "show ip ospf border-routers",
7337 SHOW_STR
7338 IP_STR
7339 "show all the ABR's and ASBR's\n"
7340 "for this area\n")
7341{
paul020709f2003-04-04 02:44:16 +00007342 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007343
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007344 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007345 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007346 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007347 return CMD_SUCCESS;
7348 }
7349
paul68980082003-03-25 05:07:42 +00007350 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007351 {
7352 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7353 return CMD_SUCCESS;
7354 }
7355
7356 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007357 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007358
7359 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007360 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007361
7362 return CMD_SUCCESS;
7363}
paul718e3742002-12-13 20:15:29 +00007364
7365DEFUN (show_ip_ospf_route,
7366 show_ip_ospf_route_cmd,
7367 "show ip ospf route",
7368 SHOW_STR
7369 IP_STR
7370 "OSPF information\n"
7371 "OSPF routing table\n")
7372{
paul020709f2003-04-04 02:44:16 +00007373 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007374
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007375 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007376 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007377 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007378 return CMD_SUCCESS;
7379 }
7380
paul68980082003-03-25 05:07:42 +00007381 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007382 {
7383 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7384 return CMD_SUCCESS;
7385 }
7386
7387 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007388 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007389
7390 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007391 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007392
7393 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007394 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007395
7396 return CMD_SUCCESS;
7397}
7398
7399
hassoeb1ce602004-10-08 08:17:22 +00007400const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007401{
7402 "unknown",
7403 "standard",
7404 "ibm",
7405 "cisco",
7406 "shortcut"
7407};
7408
hassoeb1ce602004-10-08 08:17:22 +00007409const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007410{
7411 "default",
7412 "enable",
7413 "disable"
7414};
7415
7416
paul4dadc292005-05-06 21:37:42 +00007417static void
paul718e3742002-12-13 20:15:29 +00007418area_id2str (char *buf, int length, struct ospf_area *area)
7419{
7420 memset (buf, 0, length);
7421
7422 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7423 strncpy (buf, inet_ntoa (area->area_id), length);
7424 else
7425 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7426}
7427
7428
hassoeb1ce602004-10-08 08:17:22 +00007429const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007430{
7431 "unknown", /* should never be used. */
7432 "point-to-point",
7433 "broadcast",
7434 "non-broadcast",
7435 "point-to-multipoint",
7436 "virtual-link", /* should never be used. */
7437 "loopback"
7438};
7439
7440/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007441static int
paul718e3742002-12-13 20:15:29 +00007442config_write_interface (struct vty *vty)
7443{
hasso52dc7ee2004-09-23 19:18:23 +00007444 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007445 struct interface *ifp;
7446 struct crypt_key *ck;
7447 int write = 0;
7448 struct route_node *rn = NULL;
7449 struct ospf_if_params *params;
7450
paul1eb8ef22005-04-07 07:30:20 +00007451 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007452 {
paul718e3742002-12-13 20:15:29 +00007453 if (memcmp (ifp->name, "VLINK", 5) == 0)
7454 continue;
7455
7456 vty_out (vty, "!%s", VTY_NEWLINE);
7457 vty_out (vty, "interface %s%s", ifp->name,
7458 VTY_NEWLINE);
7459 if (ifp->desc)
7460 vty_out (vty, " description %s%s", ifp->desc,
7461 VTY_NEWLINE);
7462
7463 write++;
7464
7465 params = IF_DEF_PARAMS (ifp);
7466
7467 do {
7468 /* Interface Network print. */
7469 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007470 params->type != OSPF_IFTYPE_LOOPBACK)
7471 {
ajsbc18d612004-12-15 15:07:19 +00007472 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007473 {
7474 vty_out (vty, " ip ospf network %s",
7475 ospf_int_type_str[params->type]);
7476 if (params != IF_DEF_PARAMS (ifp))
7477 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7478 vty_out (vty, "%s", VTY_NEWLINE);
7479 }
paul718e3742002-12-13 20:15:29 +00007480 }
7481
7482 /* OSPF interface authentication print */
7483 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7484 params->auth_type != OSPF_AUTH_NOTSET)
7485 {
hassoeb1ce602004-10-08 08:17:22 +00007486 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007487
7488 /* Translation tables are not that much help here due to syntax
7489 of the simple option */
7490 switch (params->auth_type)
7491 {
7492
7493 case OSPF_AUTH_NULL:
7494 auth_str = " null";
7495 break;
7496
7497 case OSPF_AUTH_SIMPLE:
7498 auth_str = "";
7499 break;
7500
7501 case OSPF_AUTH_CRYPTOGRAPHIC:
7502 auth_str = " message-digest";
7503 break;
7504
7505 default:
7506 auth_str = "";
7507 break;
7508 }
7509
7510 vty_out (vty, " ip ospf authentication%s", auth_str);
7511 if (params != IF_DEF_PARAMS (ifp))
7512 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7513 vty_out (vty, "%s", VTY_NEWLINE);
7514 }
7515
7516 /* Simple Authentication Password print. */
7517 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7518 params->auth_simple[0] != '\0')
7519 {
7520 vty_out (vty, " ip ospf authentication-key %s",
7521 params->auth_simple);
7522 if (params != IF_DEF_PARAMS (ifp))
7523 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7524 vty_out (vty, "%s", VTY_NEWLINE);
7525 }
7526
7527 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007528 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007529 {
paul718e3742002-12-13 20:15:29 +00007530 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7531 ck->key_id, ck->auth_key);
7532 if (params != IF_DEF_PARAMS (ifp))
7533 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7534 vty_out (vty, "%s", VTY_NEWLINE);
7535 }
7536
7537 /* Interface Output Cost print. */
7538 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7539 {
7540 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7541 if (params != IF_DEF_PARAMS (ifp))
7542 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7543 vty_out (vty, "%s", VTY_NEWLINE);
7544 }
7545
7546 /* Hello Interval print. */
7547 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7548 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7549 {
7550 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7551 if (params != IF_DEF_PARAMS (ifp))
7552 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7553 vty_out (vty, "%s", VTY_NEWLINE);
7554 }
7555
7556
7557 /* Router Dead Interval print. */
7558 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7559 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7560 {
paulf9ad9372005-10-21 00:45:17 +00007561 vty_out (vty, " ip ospf dead-interval ");
7562
7563 /* fast hello ? */
7564 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7565 vty_out (vty, "minimal hello-multiplier %d",
7566 params->fast_hello);
7567 else
7568 vty_out (vty, "%u", params->v_wait);
7569
paul718e3742002-12-13 20:15:29 +00007570 if (params != IF_DEF_PARAMS (ifp))
7571 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7572 vty_out (vty, "%s", VTY_NEWLINE);
7573 }
7574
7575 /* Router Priority print. */
7576 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7577 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7578 {
7579 vty_out (vty, " ip ospf priority %u", params->priority);
7580 if (params != IF_DEF_PARAMS (ifp))
7581 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7582 vty_out (vty, "%s", VTY_NEWLINE);
7583 }
7584
7585 /* Retransmit Interval print. */
7586 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7587 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7588 {
7589 vty_out (vty, " ip ospf retransmit-interval %u",
7590 params->retransmit_interval);
7591 if (params != IF_DEF_PARAMS (ifp))
7592 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7593 vty_out (vty, "%s", VTY_NEWLINE);
7594 }
7595
7596 /* Transmit Delay print. */
7597 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7598 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7599 {
7600 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7601 if (params != IF_DEF_PARAMS (ifp))
7602 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7603 vty_out (vty, "%s", VTY_NEWLINE);
7604 }
7605
vincentba682532005-09-29 13:52:57 +00007606 /* MTU ignore print. */
7607 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7608 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7609 {
7610 if (params->mtu_ignore == 0)
7611 vty_out (vty, " no ip ospf mtu-ignore");
7612 else
7613 vty_out (vty, " ip ospf mtu-ignore");
7614 if (params != IF_DEF_PARAMS (ifp))
7615 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7616 vty_out (vty, "%s", VTY_NEWLINE);
7617 }
7618
7619
paul718e3742002-12-13 20:15:29 +00007620 while (1)
7621 {
7622 if (rn == NULL)
7623 rn = route_top (IF_OIFS_PARAMS (ifp));
7624 else
7625 rn = route_next (rn);
7626
7627 if (rn == NULL)
7628 break;
7629 params = rn->info;
7630 if (params != NULL)
7631 break;
7632 }
7633 } while (rn);
7634
7635#ifdef HAVE_OPAQUE_LSA
7636 ospf_opaque_config_write_if (vty, ifp);
7637#endif /* HAVE_OPAQUE_LSA */
7638 }
7639
7640 return write;
7641}
7642
paul4dadc292005-05-06 21:37:42 +00007643static int
paul68980082003-03-25 05:07:42 +00007644config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007645{
7646 struct route_node *rn;
7647 u_char buf[INET_ADDRSTRLEN];
7648
7649 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007650 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007651 if (rn->info)
7652 {
7653 struct ospf_network *n = rn->info;
7654
7655 memset (buf, 0, INET_ADDRSTRLEN);
7656
7657 /* Create Area ID string by specified Area ID format. */
7658 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007659 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007660 else
hassoc9e52be2004-09-26 16:09:34 +00007661 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007662 (unsigned long int) ntohl (n->area_id.s_addr));
7663
7664 /* Network print. */
7665 vty_out (vty, " network %s/%d area %s%s",
7666 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7667 buf, VTY_NEWLINE);
7668 }
7669
7670 return 0;
7671}
7672
paul4dadc292005-05-06 21:37:42 +00007673static int
paul68980082003-03-25 05:07:42 +00007674config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007675{
hasso52dc7ee2004-09-23 19:18:23 +00007676 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007677 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007678 u_char buf[INET_ADDRSTRLEN];
7679
7680 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007681 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007682 {
paul718e3742002-12-13 20:15:29 +00007683 struct route_node *rn1;
7684
hassoc9e52be2004-09-26 16:09:34 +00007685 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007686
7687 if (area->auth_type != OSPF_AUTH_NULL)
7688 {
7689 if (area->auth_type == OSPF_AUTH_SIMPLE)
7690 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7691 else
7692 vty_out (vty, " area %s authentication message-digest%s",
7693 buf, VTY_NEWLINE);
7694 }
7695
7696 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7697 vty_out (vty, " area %s shortcut %s%s", buf,
7698 ospf_shortcut_mode_str[area->shortcut_configured],
7699 VTY_NEWLINE);
7700
7701 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007702 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007703 )
7704 {
paulb0a053b2003-06-22 09:04:47 +00007705 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007706 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007707 else if (area->external_routing == OSPF_AREA_NSSA)
7708 {
7709 vty_out (vty, " area %s nssa", buf);
7710 switch (area->NSSATranslatorRole)
7711 {
7712 case OSPF_NSSA_ROLE_NEVER:
7713 vty_out (vty, " translate-never");
7714 break;
7715 case OSPF_NSSA_ROLE_ALWAYS:
7716 vty_out (vty, " translate-always");
7717 break;
7718 case OSPF_NSSA_ROLE_CANDIDATE:
7719 default:
7720 vty_out (vty, " translate-candidate");
7721 }
7722 }
paul718e3742002-12-13 20:15:29 +00007723
7724 if (area->no_summary)
7725 vty_out (vty, " no-summary");
7726
7727 vty_out (vty, "%s", VTY_NEWLINE);
7728
7729 if (area->default_cost != 1)
7730 vty_out (vty, " area %s default-cost %d%s", buf,
7731 area->default_cost, VTY_NEWLINE);
7732 }
7733
7734 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7735 if (rn1->info)
7736 {
7737 struct ospf_area_range *range = rn1->info;
7738
7739 vty_out (vty, " area %s range %s/%d", buf,
7740 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7741
paul6c835672004-10-11 11:00:30 +00007742 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007743 vty_out (vty, " cost %d", range->cost_config);
7744
7745 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7746 vty_out (vty, " not-advertise");
7747
7748 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7749 vty_out (vty, " substitute %s/%d",
7750 inet_ntoa (range->subst_addr), range->subst_masklen);
7751
7752 vty_out (vty, "%s", VTY_NEWLINE);
7753 }
7754
7755 if (EXPORT_NAME (area))
7756 vty_out (vty, " area %s export-list %s%s", buf,
7757 EXPORT_NAME (area), VTY_NEWLINE);
7758
7759 if (IMPORT_NAME (area))
7760 vty_out (vty, " area %s import-list %s%s", buf,
7761 IMPORT_NAME (area), VTY_NEWLINE);
7762
7763 if (PREFIX_NAME_IN (area))
7764 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7765 PREFIX_NAME_IN (area), VTY_NEWLINE);
7766
7767 if (PREFIX_NAME_OUT (area))
7768 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7769 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7770 }
7771
7772 return 0;
7773}
7774
paul4dadc292005-05-06 21:37:42 +00007775static int
paul68980082003-03-25 05:07:42 +00007776config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007777{
7778 struct ospf_nbr_nbma *nbr_nbma;
7779 struct route_node *rn;
7780
7781 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007782 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007783 if ((nbr_nbma = rn->info))
7784 {
7785 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7786
7787 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7788 vty_out (vty, " priority %d", nbr_nbma->priority);
7789
7790 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7791 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7792
7793 vty_out (vty, "%s", VTY_NEWLINE);
7794 }
7795
7796 return 0;
7797}
7798
paul4dadc292005-05-06 21:37:42 +00007799static int
paul68980082003-03-25 05:07:42 +00007800config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007801{
hasso52dc7ee2004-09-23 19:18:23 +00007802 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007803 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007804 u_char buf[INET_ADDRSTRLEN];
7805
7806 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007807 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007808 {
hasso52dc7ee2004-09-23 19:18:23 +00007809 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007810 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007811 struct ospf_interface *oi;
7812
7813 if (vl_data != NULL)
7814 {
7815 memset (buf, 0, INET_ADDRSTRLEN);
7816
7817 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007818 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007819 else
hassoc9e52be2004-09-26 16:09:34 +00007820 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007821 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7822 oi = vl_data->vl_oi;
7823
7824 /* timers */
7825 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7826 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7827 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7828 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7829 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7830 buf,
7831 inet_ntoa (vl_data->vl_peer),
7832 OSPF_IF_PARAM (oi, v_hello),
7833 OSPF_IF_PARAM (oi, retransmit_interval),
7834 OSPF_IF_PARAM (oi, transmit_delay),
7835 OSPF_IF_PARAM (oi, v_wait),
7836 VTY_NEWLINE);
7837 else
7838 vty_out (vty, " area %s virtual-link %s%s", buf,
7839 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7840 /* Auth key */
7841 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7842 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7843 buf,
7844 inet_ntoa (vl_data->vl_peer),
7845 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7846 VTY_NEWLINE);
7847 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007848 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7849 n2, ck))
7850 vty_out (vty, " area %s virtual-link %s"
7851 " message-digest-key %d md5 %s%s",
7852 buf,
7853 inet_ntoa (vl_data->vl_peer),
7854 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007855
7856 }
7857 }
7858
7859 return 0;
7860}
7861
7862
paul4dadc292005-05-06 21:37:42 +00007863static int
paul68980082003-03-25 05:07:42 +00007864config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007865{
7866 int type;
7867
7868 /* redistribute print. */
7869 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7870 if (type != zclient->redist_default && zclient->redist[type])
7871 {
ajsf52d13c2005-10-01 17:38:06 +00007872 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007873 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007874 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007875
paul68980082003-03-25 05:07:42 +00007876 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007877 vty_out (vty, " metric-type 1");
7878
paul020709f2003-04-04 02:44:16 +00007879 if (ROUTEMAP_NAME (ospf, type))
7880 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007881
7882 vty_out (vty, "%s", VTY_NEWLINE);
7883 }
7884
7885 return 0;
7886}
7887
paul4dadc292005-05-06 21:37:42 +00007888static int
paul68980082003-03-25 05:07:42 +00007889config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007890{
paul68980082003-03-25 05:07:42 +00007891 if (ospf->default_metric != -1)
7892 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007893 VTY_NEWLINE);
7894 return 0;
7895}
7896
paul4dadc292005-05-06 21:37:42 +00007897static int
paul68980082003-03-25 05:07:42 +00007898config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007899{
7900 int type;
7901
paul68980082003-03-25 05:07:42 +00007902 if (ospf)
paul718e3742002-12-13 20:15:29 +00007903 {
7904 /* distribute-list print. */
7905 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007906 if (DISTRIBUTE_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +00007907 vty_out (vty, " distribute-list %s out %s%s",
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007908 DISTRIBUTE_NAME (ospf, type),
ajsf52d13c2005-10-01 17:38:06 +00007909 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007910
7911 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007912 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007913 {
paulc42c1772006-01-10 20:36:49 +00007914 vty_out (vty, " default-information originate");
7915 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7916 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007917
paul68980082003-03-25 05:07:42 +00007918 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007919 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007920 ospf->dmetric[DEFAULT_ROUTE].value);
7921 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007922 vty_out (vty, " metric-type 1");
7923
paul020709f2003-04-04 02:44:16 +00007924 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7925 vty_out (vty, " route-map %s",
7926 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007927
7928 vty_out (vty, "%s", VTY_NEWLINE);
7929 }
7930
7931 }
7932
7933 return 0;
7934}
7935
paul4dadc292005-05-06 21:37:42 +00007936static int
paul68980082003-03-25 05:07:42 +00007937config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007938{
7939 struct route_node *rn;
7940 struct ospf_distance *odistance;
7941
paul68980082003-03-25 05:07:42 +00007942 if (ospf->distance_all)
7943 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007944
paul68980082003-03-25 05:07:42 +00007945 if (ospf->distance_intra
7946 || ospf->distance_inter
7947 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007948 {
7949 vty_out (vty, " distance ospf");
7950
paul68980082003-03-25 05:07:42 +00007951 if (ospf->distance_intra)
7952 vty_out (vty, " intra-area %d", ospf->distance_intra);
7953 if (ospf->distance_inter)
7954 vty_out (vty, " inter-area %d", ospf->distance_inter);
7955 if (ospf->distance_external)
7956 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007957
7958 vty_out (vty, "%s", VTY_NEWLINE);
7959 }
7960
paul68980082003-03-25 05:07:42 +00007961 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007962 if ((odistance = rn->info) != NULL)
7963 {
7964 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7965 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7966 odistance->access_list ? odistance->access_list : "",
7967 VTY_NEWLINE);
7968 }
7969 return 0;
7970}
7971
7972/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007973static int
paul718e3742002-12-13 20:15:29 +00007974ospf_config_write (struct vty *vty)
7975{
paul020709f2003-04-04 02:44:16 +00007976 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007977 struct interface *ifp;
7978 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007979 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007980 int write = 0;
7981
paul020709f2003-04-04 02:44:16 +00007982 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007983 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007984 {
7985 /* `router ospf' print. */
7986 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7987
7988 write++;
7989
paul68980082003-03-25 05:07:42 +00007990 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007991 return write;
7992
7993 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007994 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007995 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007996 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007997
7998 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007999 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00008000 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00008001 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008002
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008003 /* log-adjacency-changes flag print. */
8004 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
8005 {
8006 vty_out(vty, " log-adjacency-changes");
8007 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
8008 vty_out(vty, " detail");
8009 vty_out(vty, "%s", VTY_NEWLINE);
8010 }
8011
paul718e3742002-12-13 20:15:29 +00008012 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00008013 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00008014 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
8015
8016 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00008017 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00008018 {
8019 vty_out (vty, "! Important: ensure reference bandwidth "
8020 "is consistent across all routers%s", VTY_NEWLINE);
8021 vty_out (vty, " auto-cost reference-bandwidth %d%s",
8022 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
8023 }
paul718e3742002-12-13 20:15:29 +00008024
8025 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00008026 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00008027 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
8028 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
8029 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00008030 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00008031 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00008032
8033 /* Max-metric router-lsa print */
8034 config_write_stub_router (vty, ospf);
8035
paul718e3742002-12-13 20:15:29 +00008036 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00008037 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00008038 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00008039 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008040
8041 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00008042 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008043
8044 /* passive-interface print. */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008045 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
8046 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
8047
paul1eb8ef22005-04-07 07:30:20 +00008048 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008049 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
8050 && IF_DEF_PARAMS (ifp)->passive_interface !=
8051 ospf->passive_interface_default)
8052 {
8053 vty_out (vty, " %spassive-interface %s%s",
8054 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
8055 ifp->name, VTY_NEWLINE);
8056 }
paul1eb8ef22005-04-07 07:30:20 +00008057 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008058 {
8059 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
8060 continue;
8061 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
8062 passive_interface))
8063 {
8064 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
8065 continue;
8066 }
8067 else if (oi->params->passive_interface == ospf->passive_interface_default)
8068 continue;
8069
8070 vty_out (vty, " %spassive-interface %s %s%s",
8071 oi->params->passive_interface ? "" : "no ",
paul1eb8ef22005-04-07 07:30:20 +00008072 oi->ifp->name,
8073 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008074 }
paul718e3742002-12-13 20:15:29 +00008075
8076 /* Network area print. */
paul68980082003-03-25 05:07:42 +00008077 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008078
8079 /* Area config print. */
paul68980082003-03-25 05:07:42 +00008080 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008081
8082 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00008083 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008084
8085 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00008086 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008087
8088 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00008089 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008090
8091 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00008092 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008093
8094 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00008095 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008096
8097#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00008098 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008099#endif /* HAVE_OPAQUE_LSA */
8100 }
8101
8102 return write;
8103}
8104
8105void
paul4dadc292005-05-06 21:37:42 +00008106ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00008107{
8108 /* "show ip ospf" commands. */
8109 install_element (VIEW_NODE, &show_ip_ospf_cmd);
8110 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
8111
8112 /* "show ip ospf database" commands. */
8113 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
8114 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
8115 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8116 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8117 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
8118 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
8119 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
8120 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
8121 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
8122 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8123 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8124 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
8125 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
8126 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
8127
8128 /* "show ip ospf interface" commands. */
8129 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
8130 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
8131
8132 /* "show ip ospf neighbor" commands. */
8133 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8134 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
8135 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
8136 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8137 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
8138 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
8139 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
8140 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8141 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
8142 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
8143 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8144 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
8145 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
8146 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
8147
8148 /* "show ip ospf route" commands. */
8149 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
8150 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00008151 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
8152 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00008153}
8154
8155
8156/* ospfd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008157static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00008158{
8159 INTERFACE_NODE,
8160 "%s(config-if)# ",
8161 1
8162};
8163
8164/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00008165static void
8166ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00008167{
8168 /* Install interface node. */
8169 install_node (&interface_node, config_write_interface);
8170
8171 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00008172 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008173 install_default (INTERFACE_NODE);
8174
8175 /* "description" commands. */
8176 install_element (INTERFACE_NODE, &interface_desc_cmd);
8177 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
8178
8179 /* "ip ospf authentication" commands. */
8180 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
8181 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
8182 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
8183 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
8184 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
8185 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
8186 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
8187 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
8188 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
8189 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
8190
8191 /* "ip ospf message-digest-key" commands. */
8192 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
8193 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
8194 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8195 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8196
8197 /* "ip ospf cost" commands. */
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008198 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
8199 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008200 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
8201 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008202 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008203 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8204
vincentba682532005-09-29 13:52:57 +00008205 /* "ip ospf mtu-ignore" commands. */
8206 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8207 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8208 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8209 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8210
paul718e3742002-12-13 20:15:29 +00008211 /* "ip ospf dead-interval" commands. */
8212 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8213 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008214 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8215 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00008216 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8217 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008218
paul718e3742002-12-13 20:15:29 +00008219 /* "ip ospf hello-interval" commands. */
8220 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8221 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8222 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8223 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8224
8225 /* "ip ospf network" commands. */
8226 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8227 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8228
8229 /* "ip ospf priority" commands. */
8230 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8231 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8232 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8233 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8234
8235 /* "ip ospf retransmit-interval" commands. */
8236 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8237 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8238 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8239 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8240
8241 /* "ip ospf transmit-delay" commands. */
8242 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8243 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8244 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8245 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8246
8247 /* These commands are compatibitliy for previous version. */
8248 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8249 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8250 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8251 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008252 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
8253 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008254 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008255 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
8256 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008257 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008258 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8259 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8260 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8261 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8262 install_element (INTERFACE_NODE, &ospf_network_cmd);
8263 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8264 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8265 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8266 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8267 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8268 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8269 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8270}
8271
paul4dadc292005-05-06 21:37:42 +00008272static void
8273ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008274{
8275 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8276 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8277 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8278 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8279 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8280 install_element (OSPF_NODE,
8281 &ospf_redistribute_source_metric_type_routemap_cmd);
8282 install_element (OSPF_NODE,
8283 &ospf_redistribute_source_type_metric_routemap_cmd);
8284 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8285 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8286 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8287
8288 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8289
8290 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8291 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8292
8293 install_element (OSPF_NODE,
8294 &ospf_default_information_originate_metric_type_cmd);
8295 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8296 install_element (OSPF_NODE,
8297 &ospf_default_information_originate_type_metric_cmd);
8298 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8299 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8300 install_element (OSPF_NODE,
8301 &ospf_default_information_originate_always_metric_type_cmd);
8302 install_element (OSPF_NODE,
8303 &ospf_default_information_originate_always_metric_cmd);
8304 install_element (OSPF_NODE,
8305 &ospf_default_information_originate_always_cmd);
8306 install_element (OSPF_NODE,
8307 &ospf_default_information_originate_always_type_metric_cmd);
8308 install_element (OSPF_NODE,
8309 &ospf_default_information_originate_always_type_cmd);
8310
8311 install_element (OSPF_NODE,
8312 &ospf_default_information_originate_metric_type_routemap_cmd);
8313 install_element (OSPF_NODE,
8314 &ospf_default_information_originate_metric_routemap_cmd);
8315 install_element (OSPF_NODE,
8316 &ospf_default_information_originate_routemap_cmd);
8317 install_element (OSPF_NODE,
8318 &ospf_default_information_originate_type_metric_routemap_cmd);
8319 install_element (OSPF_NODE,
8320 &ospf_default_information_originate_type_routemap_cmd);
8321 install_element (OSPF_NODE,
8322 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8323 install_element (OSPF_NODE,
8324 &ospf_default_information_originate_always_metric_routemap_cmd);
8325 install_element (OSPF_NODE,
8326 &ospf_default_information_originate_always_routemap_cmd);
8327 install_element (OSPF_NODE,
8328 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8329 install_element (OSPF_NODE,
8330 &ospf_default_information_originate_always_type_routemap_cmd);
8331
8332 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8333
8334 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8335 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8336 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8337
8338 install_element (OSPF_NODE, &ospf_distance_cmd);
8339 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8340 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8341 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8342 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8343 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8344 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8345 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8346 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8347 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8348 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8349 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8350 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8351 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8352 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8353 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8354 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8355 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8356#if 0
8357 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8358 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8359 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8360 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8361#endif /* 0 */
8362}
8363
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008364static struct cmd_node ospf_node =
paul718e3742002-12-13 20:15:29 +00008365{
8366 OSPF_NODE,
8367 "%s(config-router)# ",
8368 1
8369};
8370
8371
8372/* Install OSPF related vty commands. */
8373void
paul4dadc292005-05-06 21:37:42 +00008374ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008375{
8376 /* Install ospf top node. */
8377 install_node (&ospf_node, ospf_config_write);
8378
8379 /* "router ospf" commands. */
8380 install_element (CONFIG_NODE, &router_ospf_cmd);
8381 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8382
8383 install_default (OSPF_NODE);
8384
8385 /* "ospf router-id" commands. */
8386 install_element (OSPF_NODE, &ospf_router_id_cmd);
8387 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008388 install_element (OSPF_NODE, &router_ospf_id_cmd);
8389 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008390
8391 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008392 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8393 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008394 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
paula2c62832003-04-23 17:01:31 +00008395 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8396 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008397 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
paul718e3742002-12-13 20:15:29 +00008398
8399 /* "ospf abr-type" commands. */
8400 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8401 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8402
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008403 /* "ospf log-adjacency-changes" commands. */
8404 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8405 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8406 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8407 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8408
paul718e3742002-12-13 20:15:29 +00008409 /* "ospf rfc1583-compatible" commands. */
8410 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8411 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8412 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8413 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8414
8415 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008416 install_element (OSPF_NODE, &ospf_network_area_cmd);
8417 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008418
8419 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008420 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8421 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8422 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008423
8424 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008425 install_element (OSPF_NODE, &ospf_area_range_cmd);
8426 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8427 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8428 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8429 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8430 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8431 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8432 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8433 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8434 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8435 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008436
8437 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008438 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8439 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008440
paula2c62832003-04-23 17:01:31 +00008441 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8442 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008443
paula2c62832003-04-23 17:01:31 +00008444 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8445 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008446
paula2c62832003-04-23 17:01:31 +00008447 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8448 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008449
paula2c62832003-04-23 17:01:31 +00008450 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8451 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008452
paula2c62832003-04-23 17:01:31 +00008453 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8454 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8455 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008456
paula2c62832003-04-23 17:01:31 +00008457 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8458 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008459
paula2c62832003-04-23 17:01:31 +00008460 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8461 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008462
paula2c62832003-04-23 17:01:31 +00008463 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8464 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8465 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008466
paula2c62832003-04-23 17:01:31 +00008467 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8468 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8469 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008470
8471 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008472 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8473 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8474 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8475 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008476
paul718e3742002-12-13 20:15:29 +00008477 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008478 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8479 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8480 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8481 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8482 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8483 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008484
paula2c62832003-04-23 17:01:31 +00008485 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8486 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008487
paula2c62832003-04-23 17:01:31 +00008488 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8489 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008490
paula2c62832003-04-23 17:01:31 +00008491 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8492 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008493
paula2c62832003-04-23 17:01:31 +00008494 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8495 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008496
paula2c62832003-04-23 17:01:31 +00008497 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8498 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008499
8500 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008501 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8502 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008503 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8504 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8505
paul88d6cf32005-10-29 12:50:09 +00008506 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008507 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8508 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8509 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008510
paul88d6cf32005-10-29 12:50:09 +00008511 /* max-metric commands */
8512 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8513 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8514 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8515 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8516 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8517 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8518
8519 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008520 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8521 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008522
8523 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008524 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8525 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8526 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8527 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8528 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8529 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8530 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8531 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008532
8533 /* Init interface related vty commands. */
8534 ospf_vty_if_init ();
8535
8536 /* Init zebra related vty commands. */
8537 ospf_vty_zebra_init ();
8538}