blob: e144c2996ab1e165e4d300147527b7ea17feb634 [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 }
ajsba6454e2005-02-08 15:37:30 +00002936
2937 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002938 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2939 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2940 {
2941 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2942 vty_out (vty, " OSPFAllRouters");
2943 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2944 vty_out (vty, " OSPFDesignatedRouters");
2945 }
2946 else
ajsba6454e2005-02-08 15:37:30 +00002947 vty_out (vty, " <None>");
2948 vty_out (vty, "%s", VTY_NEWLINE);
2949
paul718e3742002-12-13 20:15:29 +00002950 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002951 vty_out (vty, " Hello ");
2952 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2953 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2954 else
2955 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2956 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2957 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002958 OSPF_IF_PARAM (oi, v_wait),
2959 OSPF_IF_PARAM (oi, retransmit_interval),
2960 VTY_NEWLINE);
2961
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002962 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002963 {
ajs649654a2005-11-16 20:17:52 +00002964 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002965 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002966 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002967 VTY_NEWLINE);
2968 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002969 else /* passive-interface is set */
paul718e3742002-12-13 20:15:29 +00002970 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2971
2972 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002973 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002974 VTY_NEWLINE);
2975 }
2976}
2977
2978DEFUN (show_ip_ospf_interface,
2979 show_ip_ospf_interface_cmd,
2980 "show ip ospf interface [INTERFACE]",
2981 SHOW_STR
2982 IP_STR
2983 "OSPF information\n"
2984 "Interface information\n"
2985 "Interface name\n")
2986{
2987 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002988 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002989 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002990
paul020709f2003-04-04 02:44:16 +00002991 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002992 if (ospf == NULL)
2993 {
2994 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2995 return CMD_SUCCESS;
2996 }
paul020709f2003-04-04 02:44:16 +00002997
paul718e3742002-12-13 20:15:29 +00002998 /* Show All Interfaces. */
2999 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00003000 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
3001 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00003002 /* Interface name is specified. */
3003 else
3004 {
3005 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
3006 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
3007 else
paul68980082003-03-25 05:07:42 +00003008 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00003009 }
3010
3011 return CMD_SUCCESS;
3012}
3013
paul4dadc292005-05-06 21:37:42 +00003014static void
pauld24f6e22005-10-21 09:23:12 +00003015show_ip_ospf_neighbour_header (struct vty *vty)
3016{
3017 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3018 VTY_NEWLINE,
3019 "Neighbor ID", "Pri", "State", "Dead Time",
3020 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3021 VTY_NEWLINE);
3022}
3023
3024static void
paul718e3742002-12-13 20:15:29 +00003025show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3026{
3027 struct route_node *rn;
3028 struct ospf_neighbor *nbr;
3029 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00003030 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003031
3032 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3033 if ((nbr = rn->info))
3034 /* Do not show myself. */
3035 if (nbr != oi->nbr_self)
3036 /* Down state is not shown. */
3037 if (nbr->state != NSM_Down)
3038 {
3039 ospf_nbr_state_message (nbr, msgbuf, 16);
3040
3041 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00003042 vty_out (vty, "%-15s %3d %-15s ",
3043 "-", nbr->priority,
3044 msgbuf);
3045 else
3046 vty_out (vty, "%-15s %3d %-15s ",
3047 inet_ntoa (nbr->router_id), nbr->priority,
3048 msgbuf);
3049
3050 vty_out (vty, "%9s ",
3051 ospf_timer_dump (nbr->t_inactivity, timebuf,
3052 sizeof(timebuf)));
3053
paul718e3742002-12-13 20:15:29 +00003054 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00003055 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00003056 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3057 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3058 VTY_NEWLINE);
3059 }
3060}
3061
3062DEFUN (show_ip_ospf_neighbor,
3063 show_ip_ospf_neighbor_cmd,
3064 "show ip ospf neighbor",
3065 SHOW_STR
3066 IP_STR
3067 "OSPF information\n"
3068 "Neighbor list\n")
3069{
paul020709f2003-04-04 02:44:16 +00003070 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003071 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003072 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003073
paul020709f2003-04-04 02:44:16 +00003074 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003075 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003076 {
3077 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3078 return CMD_SUCCESS;
3079 }
3080
pauld24f6e22005-10-21 09:23:12 +00003081 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003082
paul1eb8ef22005-04-07 07:30:20 +00003083 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3084 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003085
3086 return CMD_SUCCESS;
3087}
3088
3089DEFUN (show_ip_ospf_neighbor_all,
3090 show_ip_ospf_neighbor_all_cmd,
3091 "show ip ospf neighbor all",
3092 SHOW_STR
3093 IP_STR
3094 "OSPF information\n"
3095 "Neighbor list\n"
3096 "include down status neighbor\n")
3097{
Joakim Tjernlund35f89142008-07-01 16:54:07 +02003098 struct ospf *ospf = ospf_lookup ();
hasso52dc7ee2004-09-23 19:18:23 +00003099 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003100 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003101
paul68980082003-03-25 05:07:42 +00003102 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003103 {
3104 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3105 return CMD_SUCCESS;
3106 }
pauld24f6e22005-10-21 09:23:12 +00003107
3108 show_ip_ospf_neighbour_header (vty);
3109
paul1eb8ef22005-04-07 07:30:20 +00003110 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003111 {
hasso52dc7ee2004-09-23 19:18:23 +00003112 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003113 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003114
3115 show_ip_ospf_neighbor_sub (vty, oi);
3116
3117 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003118 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003119 {
paul718e3742002-12-13 20:15:29 +00003120 if (nbr_nbma->nbr == NULL
3121 || nbr_nbma->nbr->state == NSM_Down)
3122 {
pauld24f6e22005-10-21 09:23:12 +00003123 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003124 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003125 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003126 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3127 0, 0, 0, VTY_NEWLINE);
3128 }
3129 }
3130 }
3131
3132 return CMD_SUCCESS;
3133}
3134
3135DEFUN (show_ip_ospf_neighbor_int,
3136 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003137 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003138 SHOW_STR
3139 IP_STR
3140 "OSPF information\n"
3141 "Neighbor list\n"
3142 "Interface name\n")
3143{
paul020709f2003-04-04 02:44:16 +00003144 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003145 struct interface *ifp;
3146 struct route_node *rn;
3147
3148 ifp = if_lookup_by_name (argv[0]);
3149 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003150 {
hassobb5b7552005-08-21 20:01:15 +00003151 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003152 return CMD_WARNING;
3153 }
3154
paul020709f2003-04-04 02:44:16 +00003155 ospf = ospf_lookup ();
3156 if (ospf == NULL)
3157 {
3158 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3159 return CMD_SUCCESS;
3160 }
pauld24f6e22005-10-21 09:23:12 +00003161
3162 show_ip_ospf_neighbour_header (vty);
3163
hassobb5b7552005-08-21 20:01:15 +00003164 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003165 {
hassobb5b7552005-08-21 20:01:15 +00003166 struct ospf_interface *oi = rn->info;
3167
3168 if (oi == NULL)
3169 continue;
3170
paul718e3742002-12-13 20:15:29 +00003171 show_ip_ospf_neighbor_sub (vty, oi);
3172 }
3173
3174 return CMD_SUCCESS;
3175}
3176
paul4dadc292005-05-06 21:37:42 +00003177static void
paul718e3742002-12-13 20:15:29 +00003178show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3179 struct ospf_nbr_nbma *nbr_nbma)
3180{
ajs649654a2005-11-16 20:17:52 +00003181 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003182
3183 /* Show neighbor ID. */
3184 vty_out (vty, " Neighbor %s,", "-");
3185
3186 /* Show interface address. */
3187 vty_out (vty, " interface address %s%s",
3188 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3189 /* Show Area ID. */
3190 vty_out (vty, " In the area %s via interface %s%s",
3191 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3192 /* Show neighbor priority and state. */
3193 vty_out (vty, " Neighbor priority is %d, State is %s,",
3194 nbr_nbma->priority, "Down");
3195 /* Show state changes. */
3196 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3197
3198 /* Show PollInterval */
3199 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3200
3201 /* Show poll-interval timer. */
3202 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003203 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3204 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003205
3206 /* Show poll-interval timer thread. */
3207 vty_out (vty, " Thread Poll Timer %s%s",
3208 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3209}
3210
paul4dadc292005-05-06 21:37:42 +00003211static void
paul718e3742002-12-13 20:15:29 +00003212show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3213 struct ospf_neighbor *nbr)
3214{
ajs649654a2005-11-16 20:17:52 +00003215 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003216
3217 /* Show neighbor ID. */
3218 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3219 vty_out (vty, " Neighbor %s,", "-");
3220 else
3221 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3222
3223 /* Show interface address. */
3224 vty_out (vty, " interface address %s%s",
3225 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3226 /* Show Area ID. */
3227 vty_out (vty, " In the area %s via interface %s%s",
3228 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3229 /* Show neighbor priority and state. */
3230 vty_out (vty, " Neighbor priority is %d, State is %s,",
3231 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3232 /* Show state changes. */
3233 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
Paul Jakma3fed4162006-07-25 20:44:12 +00003234 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
Paul Jakma90c33172006-07-11 17:57:25 +00003235 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003236 struct timeval res
3237 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003238 vty_out (vty, " Most recent state change statistics:%s",
3239 VTY_NEWLINE);
3240 vty_out (vty, " Progressive change %s ago%s",
Paul Jakma90c33172006-07-11 17:57:25 +00003241 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
Paul Jakma3fed4162006-07-25 20:44:12 +00003242 VTY_NEWLINE);
3243 }
3244 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3245 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003246 struct timeval res
3247 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003248 vty_out (vty, " Regressive change %s ago, due to %s%s",
3249 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3250 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
Paul Jakma90c33172006-07-11 17:57:25 +00003251 VTY_NEWLINE);
3252 }
paul718e3742002-12-13 20:15:29 +00003253 /* Show Designated Rotuer ID. */
3254 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3255 /* Show Backup Designated Rotuer ID. */
3256 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3257 /* Show options. */
3258 vty_out (vty, " Options %d %s%s", nbr->options,
3259 ospf_options_dump (nbr->options), VTY_NEWLINE);
3260 /* Show Router Dead interval timer. */
3261 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003262 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3263 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003264 /* Show Database Summary list. */
3265 vty_out (vty, " Database Summary List %d%s",
3266 ospf_db_summary_count (nbr), VTY_NEWLINE);
3267 /* Show Link State Request list. */
3268 vty_out (vty, " Link State Request List %ld%s",
3269 ospf_ls_request_count (nbr), VTY_NEWLINE);
3270 /* Show Link State Retransmission list. */
3271 vty_out (vty, " Link State Retransmission List %ld%s",
3272 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3273 /* Show inactivity timer thread. */
3274 vty_out (vty, " Thread Inactivity Timer %s%s",
3275 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3276 /* Show Database Description retransmission thread. */
3277 vty_out (vty, " Thread Database Description Retransmision %s%s",
3278 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3279 /* Show Link State Request Retransmission thread. */
3280 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3281 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3282 /* Show Link State Update Retransmission thread. */
3283 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3284 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3285}
3286
3287DEFUN (show_ip_ospf_neighbor_id,
3288 show_ip_ospf_neighbor_id_cmd,
3289 "show ip ospf neighbor A.B.C.D",
3290 SHOW_STR
3291 IP_STR
3292 "OSPF information\n"
3293 "Neighbor list\n"
3294 "Neighbor ID\n")
3295{
paul020709f2003-04-04 02:44:16 +00003296 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003297 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003298 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003299 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003300 struct in_addr router_id;
3301 int ret;
3302
3303 ret = inet_aton (argv[0], &router_id);
3304 if (!ret)
3305 {
3306 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3307 return CMD_WARNING;
3308 }
3309
paul020709f2003-04-04 02:44:16 +00003310 ospf = ospf_lookup ();
3311 if (ospf == NULL)
3312 {
3313 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3314 return CMD_SUCCESS;
3315 }
3316
paul1eb8ef22005-04-07 07:30:20 +00003317 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3318 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003319 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003320
paul718e3742002-12-13 20:15:29 +00003321 return CMD_SUCCESS;
3322}
3323
3324DEFUN (show_ip_ospf_neighbor_detail,
3325 show_ip_ospf_neighbor_detail_cmd,
3326 "show ip ospf neighbor detail",
3327 SHOW_STR
3328 IP_STR
3329 "OSPF information\n"
3330 "Neighbor list\n"
3331 "detail of all neighbors\n")
3332{
paul020709f2003-04-04 02:44:16 +00003333 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003334 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003335 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003336
paul020709f2003-04-04 02:44:16 +00003337 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003338 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003339 {
3340 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3341 return CMD_SUCCESS;
3342 }
paul718e3742002-12-13 20:15:29 +00003343
paul1eb8ef22005-04-07 07:30:20 +00003344 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003345 {
paul718e3742002-12-13 20:15:29 +00003346 struct route_node *rn;
3347 struct ospf_neighbor *nbr;
3348
3349 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3350 if ((nbr = rn->info))
3351 if (nbr != oi->nbr_self)
3352 if (nbr->state != NSM_Down)
3353 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3354 }
3355
3356 return CMD_SUCCESS;
3357}
3358
3359DEFUN (show_ip_ospf_neighbor_detail_all,
3360 show_ip_ospf_neighbor_detail_all_cmd,
3361 "show ip ospf neighbor detail all",
3362 SHOW_STR
3363 IP_STR
3364 "OSPF information\n"
3365 "Neighbor list\n"
3366 "detail of all neighbors\n"
3367 "include down status neighbor\n")
3368{
paul020709f2003-04-04 02:44:16 +00003369 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003370 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003371 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003372
paul020709f2003-04-04 02:44:16 +00003373 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003374 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003375 {
3376 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3377 return CMD_SUCCESS;
3378 }
paul718e3742002-12-13 20:15:29 +00003379
paul1eb8ef22005-04-07 07:30:20 +00003380 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003381 {
paul718e3742002-12-13 20:15:29 +00003382 struct route_node *rn;
3383 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003384 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003385
3386 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3387 if ((nbr = rn->info))
3388 if (nbr != oi->nbr_self)
3389 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3390 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3391
3392 if (oi->type == OSPF_IFTYPE_NBMA)
3393 {
hasso52dc7ee2004-09-23 19:18:23 +00003394 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003395
paul1eb8ef22005-04-07 07:30:20 +00003396 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3397 if (nbr_nbma->nbr == NULL
3398 || nbr_nbma->nbr->state == NSM_Down)
3399 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003400 }
3401 }
3402
3403 return CMD_SUCCESS;
3404}
3405
3406DEFUN (show_ip_ospf_neighbor_int_detail,
3407 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003408 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003409 SHOW_STR
3410 IP_STR
3411 "OSPF information\n"
3412 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003413 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003414 "detail of all neighbors")
3415{
paul020709f2003-04-04 02:44:16 +00003416 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003417 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003418 struct interface *ifp;
3419 struct route_node *rn, *nrn;
3420 struct ospf_neighbor *nbr;
3421
3422 ifp = if_lookup_by_name (argv[0]);
3423 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003424 {
hassobb5b7552005-08-21 20:01:15 +00003425 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003426 return CMD_WARNING;
3427 }
3428
paul020709f2003-04-04 02:44:16 +00003429 ospf = ospf_lookup ();
3430 if (ospf == NULL)
3431 {
3432 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3433 return CMD_SUCCESS;
3434 }
paul68980082003-03-25 05:07:42 +00003435
paul718e3742002-12-13 20:15:29 +00003436
hassobb5b7552005-08-21 20:01:15 +00003437 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3438 if ((oi = rn->info))
3439 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3440 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003441 if (nbr != oi->nbr_self)
3442 if (nbr->state != NSM_Down)
3443 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003444
3445 return CMD_SUCCESS;
3446}
3447
3448
3449/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003450static int
paul020709f2003-04-04 02:44:16 +00003451show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003452{
paul718e3742002-12-13 20:15:29 +00003453 struct router_lsa *rl;
3454 struct summary_lsa *sl;
3455 struct as_external_lsa *asel;
3456 struct prefix_ipv4 p;
3457
3458 if (lsa != NULL)
3459 /* If self option is set, check LSA self flag. */
3460 if (self == 0 || IS_LSA_SELF (lsa))
3461 {
3462 /* LSA common part show. */
3463 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3464 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3465 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3466 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3467 /* LSA specific part show. */
3468 switch (lsa->data->type)
3469 {
3470 case OSPF_ROUTER_LSA:
3471 rl = (struct router_lsa *) lsa->data;
3472 vty_out (vty, " %-d", ntohs (rl->links));
3473 break;
3474 case OSPF_SUMMARY_LSA:
3475 sl = (struct summary_lsa *) lsa->data;
3476
3477 p.family = AF_INET;
3478 p.prefix = sl->header.id;
3479 p.prefixlen = ip_masklen (sl->mask);
3480 apply_mask_ipv4 (&p);
3481
3482 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3483 break;
3484 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003485 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003486 asel = (struct as_external_lsa *) lsa->data;
3487
3488 p.family = AF_INET;
3489 p.prefix = asel->header.id;
3490 p.prefixlen = ip_masklen (asel->mask);
3491 apply_mask_ipv4 (&p);
3492
3493 vty_out (vty, " %s %s/%d [0x%lx]",
3494 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3495 inet_ntoa (p.prefix), p.prefixlen,
3496 (u_long)ntohl (asel->e[0].route_tag));
3497 break;
3498 case OSPF_NETWORK_LSA:
3499 case OSPF_ASBR_SUMMARY_LSA:
3500#ifdef HAVE_OPAQUE_LSA
3501 case OSPF_OPAQUE_LINK_LSA:
3502 case OSPF_OPAQUE_AREA_LSA:
3503 case OSPF_OPAQUE_AS_LSA:
3504#endif /* HAVE_OPAQUE_LSA */
3505 default:
3506 break;
3507 }
3508 vty_out (vty, VTY_NEWLINE);
3509 }
3510
3511 return 0;
3512}
3513
hassoeb1ce602004-10-08 08:17:22 +00003514const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003515{
3516 "unknown",
3517 "Router Link States",
3518 "Net Link States",
3519 "Summary Link States",
3520 "ASBR-Summary Link States",
3521 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003522 "Group Membership LSA",
3523 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003524#ifdef HAVE_OPAQUE_LSA
3525 "Type-8 LSA",
3526 "Link-Local Opaque-LSA",
3527 "Area-Local Opaque-LSA",
3528 "AS-external Opaque-LSA",
3529#endif /* HAVE_OPAQUE_LSA */
3530};
3531
3532#define SHOW_OSPF_COMMON_HEADER \
3533 "Link ID ADV Router Age Seq# CkSum"
3534
hassoeb1ce602004-10-08 08:17:22 +00003535const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003536{
3537 "",
3538 "Link ID ADV Router Age Seq# CkSum Link count",
3539 "Link ID ADV Router Age Seq# CkSum",
3540 "Link ID ADV Router Age Seq# CkSum Route",
3541 "Link ID ADV Router Age Seq# CkSum",
3542 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003543 " --- header for Group Member ----",
3544 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003545#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003546 " --- type-8 ---",
3547 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3548 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3549 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3550#endif /* HAVE_OPAQUE_LSA */
3551};
3552
hassoeb1ce602004-10-08 08:17:22 +00003553const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003554{
3555 "Self-originated",
3556 "Checked",
3557 "Received",
3558 "Approved",
3559 "Discard",
paul4957f492003-06-27 01:28:45 +00003560 "Translated",
paul4957f492003-06-27 01:28:45 +00003561};
3562
paul4dadc292005-05-06 21:37:42 +00003563static void
paul718e3742002-12-13 20:15:29 +00003564show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3565{
3566 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003567
paul718e3742002-12-13 20:15:29 +00003568 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003569 vty_out (vty, " Options: 0x%-2x : %s%s",
3570 lsa->data->options,
3571 ospf_options_dump(lsa->data->options),
3572 VTY_NEWLINE);
3573 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003574 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003575 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3576 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003577
3578 if (lsa->data->type == OSPF_ROUTER_LSA)
3579 {
3580 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3581
3582 if (rlsa->flags)
3583 vty_out (vty, " :%s%s%s%s",
3584 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3585 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3586 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3587 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3588
3589 vty_out (vty, "%s", VTY_NEWLINE);
3590 }
3591 vty_out (vty, " LS Type: %s%s",
3592 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3593 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3594 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3595 vty_out (vty, " Advertising Router: %s%s",
3596 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3597 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3598 VTY_NEWLINE);
3599 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3600 VTY_NEWLINE);
3601 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3602}
3603
hassoeb1ce602004-10-08 08:17:22 +00003604const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003605{
3606 "(null)",
3607 "another Router (point-to-point)",
3608 "a Transit Network",
3609 "Stub Network",
3610 "a Virtual Link",
3611};
3612
hassoeb1ce602004-10-08 08:17:22 +00003613const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003614{
3615 "(null)",
3616 "Neighboring Router ID",
3617 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003618 "Net",
paul718e3742002-12-13 20:15:29 +00003619 "Neighboring Router ID",
3620};
3621
hassoeb1ce602004-10-08 08:17:22 +00003622const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003623{
3624 "(null)",
3625 "Router Interface address",
3626 "Router Interface address",
3627 "Network Mask",
3628 "Router Interface address",
3629};
3630
3631/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003632static void
paul718e3742002-12-13 20:15:29 +00003633show_ip_ospf_database_router_links (struct vty *vty,
3634 struct router_lsa *rl)
3635{
3636 int len, i, type;
3637
3638 len = ntohs (rl->header.length) - 4;
3639 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3640 {
3641 type = rl->link[i].type;
3642
3643 vty_out (vty, " Link connected to: %s%s",
3644 link_type_desc[type], VTY_NEWLINE);
3645 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3646 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3647 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3648 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3649 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3650 vty_out (vty, " TOS 0 Metric: %d%s",
3651 ntohs (rl->link[i].metric), VTY_NEWLINE);
3652 vty_out (vty, "%s", VTY_NEWLINE);
3653 }
3654}
3655
3656/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003657static int
paul718e3742002-12-13 20:15:29 +00003658show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3659{
3660 if (lsa != NULL)
3661 {
3662 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3663
3664 show_ip_ospf_database_header (vty, lsa);
3665
3666 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3667 VTY_NEWLINE, VTY_NEWLINE);
3668
3669 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003670 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003671 }
3672
3673 return 0;
3674}
3675
3676/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003677static int
paul718e3742002-12-13 20:15:29 +00003678show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3679{
3680 int length, i;
3681
3682 if (lsa != NULL)
3683 {
3684 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3685
3686 show_ip_ospf_database_header (vty, lsa);
3687
3688 vty_out (vty, " Network Mask: /%d%s",
3689 ip_masklen (nl->mask), VTY_NEWLINE);
3690
3691 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3692
3693 for (i = 0; length > 0; i++, length -= 4)
3694 vty_out (vty, " Attached Router: %s%s",
3695 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3696
3697 vty_out (vty, "%s", VTY_NEWLINE);
3698 }
3699
3700 return 0;
3701}
3702
3703/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003704static int
paul718e3742002-12-13 20:15:29 +00003705show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3706{
3707 if (lsa != NULL)
3708 {
3709 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3710
3711 show_ip_ospf_database_header (vty, lsa);
3712
3713 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3714 VTY_NEWLINE);
3715 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3716 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003717 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003718 }
3719
3720 return 0;
3721}
3722
3723/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003724static int
paul718e3742002-12-13 20:15:29 +00003725show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3726{
3727 if (lsa != NULL)
3728 {
3729 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3730
3731 show_ip_ospf_database_header (vty, lsa);
3732
3733 vty_out (vty, " Network Mask: /%d%s",
3734 ip_masklen (sl->mask), VTY_NEWLINE);
3735 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3736 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003737 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003738 }
3739
3740 return 0;
3741}
3742
3743/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003744static int
paul718e3742002-12-13 20:15:29 +00003745show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3746{
3747 if (lsa != NULL)
3748 {
3749 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3750
3751 show_ip_ospf_database_header (vty, lsa);
3752
3753 vty_out (vty, " Network Mask: /%d%s",
3754 ip_masklen (al->mask), VTY_NEWLINE);
3755 vty_out (vty, " Metric Type: %s%s",
3756 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3757 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3758 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3759 vty_out (vty, " Metric: %d%s",
3760 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3761 vty_out (vty, " Forward Address: %s%s",
3762 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3763
3764 vty_out (vty, " External Route Tag: %lu%s%s",
3765 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3766 }
3767
3768 return 0;
3769}
3770
ajs2a42e282004-12-08 18:43:03 +00003771/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003772static int
paul718e3742002-12-13 20:15:29 +00003773show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3774{
3775 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3776
3777 /* show_ip_ospf_database_header (vty, lsa); */
3778
ajs2a42e282004-12-08 18:43:03 +00003779 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003780 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003781 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003782 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3783 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003784 zlog_debug( " TOS: 0%s", "\n");
3785 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003786 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003787 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003788 inet_ntoa (al->e[0].fwd_addr), "\n");
3789
ajs2a42e282004-12-08 18:43:03 +00003790 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003791 ntohl (al->e[0].route_tag), "\n", "\n");
3792
3793 return 0;
3794}
3795
3796/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003797static int
paul718e3742002-12-13 20:15:29 +00003798show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3799{
3800 if (lsa != NULL)
3801 {
3802 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3803
3804 show_ip_ospf_database_header (vty, lsa);
3805
3806 vty_out (vty, " Network Mask: /%d%s",
3807 ip_masklen (al->mask), VTY_NEWLINE);
3808 vty_out (vty, " Metric Type: %s%s",
3809 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3810 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3811 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3812 vty_out (vty, " Metric: %d%s",
3813 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3814 vty_out (vty, " NSSA: Forward Address: %s%s",
3815 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3816
3817 vty_out (vty, " External Route Tag: %u%s%s",
3818 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3819 }
3820
3821 return 0;
3822}
3823
paul4dadc292005-05-06 21:37:42 +00003824static int
paul718e3742002-12-13 20:15:29 +00003825show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3826{
3827 return 0;
3828}
3829
3830#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003831static int
paul718e3742002-12-13 20:15:29 +00003832show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3833{
3834 if (lsa != NULL)
3835 {
3836 show_ip_ospf_database_header (vty, lsa);
3837 show_opaque_info_detail (vty, lsa);
3838
3839 vty_out (vty, "%s", VTY_NEWLINE);
3840 }
3841 return 0;
3842}
3843#endif /* HAVE_OPAQUE_LSA */
3844
3845int (*show_function[])(struct vty *, struct ospf_lsa *) =
3846{
3847 NULL,
3848 show_router_lsa_detail,
3849 show_network_lsa_detail,
3850 show_summary_lsa_detail,
3851 show_summary_asbr_lsa_detail,
3852 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003853 show_func_dummy,
3854 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003855#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003856 NULL, /* type-8 */
3857 show_opaque_lsa_detail,
3858 show_opaque_lsa_detail,
3859 show_opaque_lsa_detail,
3860#endif /* HAVE_OPAQUE_LSA */
3861};
3862
paul4dadc292005-05-06 21:37:42 +00003863static void
paul718e3742002-12-13 20:15:29 +00003864show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3865 struct in_addr *adv_router)
3866{
3867 memset (lp, 0, sizeof (struct prefix_ls));
3868 lp->family = 0;
3869 if (id == NULL)
3870 lp->prefixlen = 0;
3871 else if (adv_router == NULL)
3872 {
3873 lp->prefixlen = 32;
3874 lp->id = *id;
3875 }
3876 else
3877 {
3878 lp->prefixlen = 64;
3879 lp->id = *id;
3880 lp->adv_router = *adv_router;
3881 }
3882}
3883
paul4dadc292005-05-06 21:37:42 +00003884static void
paul718e3742002-12-13 20:15:29 +00003885show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3886 struct in_addr *id, struct in_addr *adv_router)
3887{
3888 struct prefix_ls lp;
3889 struct route_node *rn, *start;
3890 struct ospf_lsa *lsa;
3891
3892 show_lsa_prefix_set (vty, &lp, id, adv_router);
3893 start = route_node_get (rt, (struct prefix *) &lp);
3894 if (start)
3895 {
3896 route_lock_node (start);
3897 for (rn = start; rn; rn = route_next_until (rn, start))
3898 if ((lsa = rn->info))
3899 {
paul718e3742002-12-13 20:15:29 +00003900 if (show_function[lsa->data->type] != NULL)
3901 show_function[lsa->data->type] (vty, lsa);
3902 }
3903 route_unlock_node (start);
3904 }
3905}
3906
3907/* Show detail LSA information
3908 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003909static void
paul020709f2003-04-04 02:44:16 +00003910show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003911 struct in_addr *id, struct in_addr *adv_router)
3912{
hasso52dc7ee2004-09-23 19:18:23 +00003913 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003914 struct ospf_area *area;
3915
paul718e3742002-12-13 20:15:29 +00003916 switch (type)
3917 {
3918 case OSPF_AS_EXTERNAL_LSA:
3919#ifdef HAVE_OPAQUE_LSA
3920 case OSPF_OPAQUE_AS_LSA:
3921#endif /* HAVE_OPAQUE_LSA */
3922 vty_out (vty, " %s %s%s",
3923 show_database_desc[type],
3924 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003925 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003926 break;
3927 default:
paul1eb8ef22005-04-07 07:30:20 +00003928 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003929 {
paul718e3742002-12-13 20:15:29 +00003930 vty_out (vty, "%s %s (Area %s)%s%s",
3931 VTY_NEWLINE, show_database_desc[type],
3932 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3933 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3934 }
3935 break;
3936 }
3937}
3938
paul4dadc292005-05-06 21:37:42 +00003939static void
paul718e3742002-12-13 20:15:29 +00003940show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3941 struct in_addr *adv_router)
3942{
3943 struct route_node *rn;
3944 struct ospf_lsa *lsa;
3945
3946 for (rn = route_top (rt); rn; rn = route_next (rn))
3947 if ((lsa = rn->info))
3948 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3949 {
paul718e3742002-12-13 20:15:29 +00003950 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3951 continue;
paul718e3742002-12-13 20:15:29 +00003952 if (show_function[lsa->data->type] != NULL)
3953 show_function[lsa->data->type] (vty, lsa);
3954 }
3955}
3956
3957/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003958static void
paul020709f2003-04-04 02:44:16 +00003959show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003960 struct in_addr *adv_router)
3961{
hasso52dc7ee2004-09-23 19:18:23 +00003962 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003963 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003964
3965 switch (type)
3966 {
3967 case OSPF_AS_EXTERNAL_LSA:
3968#ifdef HAVE_OPAQUE_LSA
3969 case OSPF_OPAQUE_AS_LSA:
3970#endif /* HAVE_OPAQUE_LSA */
3971 vty_out (vty, " %s %s%s",
3972 show_database_desc[type],
3973 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003974 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003975 adv_router);
3976 break;
3977 default:
paul1eb8ef22005-04-07 07:30:20 +00003978 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003979 {
paul718e3742002-12-13 20:15:29 +00003980 vty_out (vty, "%s %s (Area %s)%s%s",
3981 VTY_NEWLINE, show_database_desc[type],
3982 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3983 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3984 adv_router);
3985 }
3986 break;
3987 }
3988}
3989
paul4dadc292005-05-06 21:37:42 +00003990static void
paul020709f2003-04-04 02:44:16 +00003991show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003992{
paul020709f2003-04-04 02:44:16 +00003993 struct ospf_lsa *lsa;
3994 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003995 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003996 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003997 int type;
3998
paul1eb8ef22005-04-07 07:30:20 +00003999 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00004000 {
paul718e3742002-12-13 20:15:29 +00004001 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4002 {
4003 switch (type)
4004 {
4005 case OSPF_AS_EXTERNAL_LSA:
4006#ifdef HAVE_OPAQUE_LSA
4007 case OSPF_OPAQUE_AS_LSA:
4008#endif /* HAVE_OPAQUE_LSA */
4009 continue;
4010 default:
4011 break;
4012 }
4013 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
4014 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
4015 {
4016 vty_out (vty, " %s (Area %s)%s%s",
4017 show_database_desc[type],
4018 ospf_area_desc_string (area),
4019 VTY_NEWLINE, VTY_NEWLINE);
4020 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
4021
paul020709f2003-04-04 02:44:16 +00004022 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
4023 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00004024
4025 vty_out (vty, "%s", VTY_NEWLINE);
4026 }
4027 }
4028 }
4029
4030 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4031 {
4032 switch (type)
4033 {
4034 case OSPF_AS_EXTERNAL_LSA:
4035#ifdef HAVE_OPAQUE_LSA
4036 case OSPF_OPAQUE_AS_LSA:
4037#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00004038 break;
paul718e3742002-12-13 20:15:29 +00004039 default:
4040 continue;
4041 }
paul68980082003-03-25 05:07:42 +00004042 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4043 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00004044 {
4045 vty_out (vty, " %s%s%s",
4046 show_database_desc[type],
4047 VTY_NEWLINE, VTY_NEWLINE);
4048 vty_out (vty, "%s%s", show_database_header[type],
4049 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00004050
4051 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4052 show_lsa_summary (vty, lsa, self);
4053
paul718e3742002-12-13 20:15:29 +00004054 vty_out (vty, "%s", VTY_NEWLINE);
4055 }
4056 }
4057
4058 vty_out (vty, "%s", VTY_NEWLINE);
4059}
4060
paul4dadc292005-05-06 21:37:42 +00004061static void
paul020709f2003-04-04 02:44:16 +00004062show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00004063{
hasso52dc7ee2004-09-23 19:18:23 +00004064 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00004065 struct ospf_lsa *lsa;
4066
4067 vty_out (vty, "%s MaxAge Link States:%s%s",
4068 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4069
paul1eb8ef22005-04-07 07:30:20 +00004070 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
4071 {
4072 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4073 vty_out (vty, "Link State ID: %s%s",
4074 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4075 vty_out (vty, "Advertising Router: %s%s",
4076 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4077 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4078 vty_out (vty, "%s", VTY_NEWLINE);
4079 }
paul718e3742002-12-13 20:15:29 +00004080}
4081
paul718e3742002-12-13 20:15:29 +00004082#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4083#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00004084
4085#ifdef HAVE_OPAQUE_LSA
4086#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4087#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4088#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4089#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4090#else /* HAVE_OPAQUE_LSA */
4091#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4092#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4093#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4094#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4095#endif /* HAVE_OPAQUE_LSA */
4096
4097#define OSPF_LSA_TYPES_CMD_STR \
4098 "asbr-summary|external|network|router|summary" \
4099 OSPF_LSA_TYPE_NSSA_CMD_STR \
4100 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4101
4102#define OSPF_LSA_TYPES_DESC \
4103 "ASBR summary link states\n" \
4104 "External link states\n" \
4105 "Network link states\n" \
4106 "Router link states\n" \
4107 "Network summary link states\n" \
4108 OSPF_LSA_TYPE_NSSA_DESC \
4109 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4110 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4111 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4112
4113DEFUN (show_ip_ospf_database,
4114 show_ip_ospf_database_cmd,
4115 "show ip ospf database",
4116 SHOW_STR
4117 IP_STR
4118 "OSPF information\n"
4119 "Database summary\n")
4120{
paul020709f2003-04-04 02:44:16 +00004121 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004122 int type, ret;
4123 struct in_addr id, adv_router;
4124
paul020709f2003-04-04 02:44:16 +00004125 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004126 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004127 {
4128 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4129 return CMD_SUCCESS;
4130 }
paul718e3742002-12-13 20:15:29 +00004131
4132 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004133 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004134
4135 /* Show all LSA. */
4136 if (argc == 0)
4137 {
paul020709f2003-04-04 02:44:16 +00004138 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004139 return CMD_SUCCESS;
4140 }
4141
4142 /* Set database type to show. */
4143 if (strncmp (argv[0], "r", 1) == 0)
4144 type = OSPF_ROUTER_LSA;
4145 else if (strncmp (argv[0], "ne", 2) == 0)
4146 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004147 else if (strncmp (argv[0], "ns", 2) == 0)
4148 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004149 else if (strncmp (argv[0], "su", 2) == 0)
4150 type = OSPF_SUMMARY_LSA;
4151 else if (strncmp (argv[0], "a", 1) == 0)
4152 type = OSPF_ASBR_SUMMARY_LSA;
4153 else if (strncmp (argv[0], "e", 1) == 0)
4154 type = OSPF_AS_EXTERNAL_LSA;
4155 else if (strncmp (argv[0], "se", 2) == 0)
4156 {
paul020709f2003-04-04 02:44:16 +00004157 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004158 return CMD_SUCCESS;
4159 }
4160 else if (strncmp (argv[0], "m", 1) == 0)
4161 {
paul020709f2003-04-04 02:44:16 +00004162 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004163 return CMD_SUCCESS;
4164 }
4165#ifdef HAVE_OPAQUE_LSA
4166 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4167 type = OSPF_OPAQUE_LINK_LSA;
4168 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4169 type = OSPF_OPAQUE_AREA_LSA;
4170 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4171 type = OSPF_OPAQUE_AS_LSA;
4172#endif /* HAVE_OPAQUE_LSA */
4173 else
4174 return CMD_WARNING;
4175
4176 /* `show ip ospf database LSA'. */
4177 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004178 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004179 else if (argc >= 2)
4180 {
4181 ret = inet_aton (argv[1], &id);
4182 if (!ret)
4183 return CMD_WARNING;
4184
4185 /* `show ip ospf database LSA ID'. */
4186 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004187 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004188 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4189 else if (argc == 3)
4190 {
4191 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004192 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004193 else
4194 {
4195 ret = inet_aton (argv[2], &adv_router);
4196 if (!ret)
4197 return CMD_WARNING;
4198 }
paul020709f2003-04-04 02:44:16 +00004199 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004200 }
4201 }
4202
4203 return CMD_SUCCESS;
4204}
4205
4206ALIAS (show_ip_ospf_database,
4207 show_ip_ospf_database_type_cmd,
4208 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4209 SHOW_STR
4210 IP_STR
4211 "OSPF information\n"
4212 "Database summary\n"
4213 OSPF_LSA_TYPES_DESC
4214 "LSAs in MaxAge list\n"
4215 "Self-originated link states\n")
4216
4217ALIAS (show_ip_ospf_database,
4218 show_ip_ospf_database_type_id_cmd,
4219 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4220 SHOW_STR
4221 IP_STR
4222 "OSPF information\n"
4223 "Database summary\n"
4224 OSPF_LSA_TYPES_DESC
4225 "Link State ID (as an IP address)\n")
4226
4227ALIAS (show_ip_ospf_database,
4228 show_ip_ospf_database_type_id_adv_router_cmd,
4229 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4230 SHOW_STR
4231 IP_STR
4232 "OSPF information\n"
4233 "Database summary\n"
4234 OSPF_LSA_TYPES_DESC
4235 "Link State ID (as an IP address)\n"
4236 "Advertising Router link states\n"
4237 "Advertising Router (as an IP address)\n")
4238
4239ALIAS (show_ip_ospf_database,
4240 show_ip_ospf_database_type_id_self_cmd,
4241 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4242 SHOW_STR
4243 IP_STR
4244 "OSPF information\n"
4245 "Database summary\n"
4246 OSPF_LSA_TYPES_DESC
4247 "Link State ID (as an IP address)\n"
4248 "Self-originated link states\n"
4249 "\n")
4250
4251DEFUN (show_ip_ospf_database_type_adv_router,
4252 show_ip_ospf_database_type_adv_router_cmd,
4253 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4254 SHOW_STR
4255 IP_STR
4256 "OSPF information\n"
4257 "Database summary\n"
4258 OSPF_LSA_TYPES_DESC
4259 "Advertising Router link states\n"
4260 "Advertising Router (as an IP address)\n")
4261{
paul020709f2003-04-04 02:44:16 +00004262 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004263 int type, ret;
4264 struct in_addr adv_router;
4265
paul020709f2003-04-04 02:44:16 +00004266 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004267 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004268 {
4269 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4270 return CMD_SUCCESS;
4271 }
paul718e3742002-12-13 20:15:29 +00004272
4273 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004274 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004275
4276 if (argc != 2)
4277 return CMD_WARNING;
4278
4279 /* Set database type to show. */
4280 if (strncmp (argv[0], "r", 1) == 0)
4281 type = OSPF_ROUTER_LSA;
4282 else if (strncmp (argv[0], "ne", 2) == 0)
4283 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004284 else if (strncmp (argv[0], "ns", 2) == 0)
4285 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004286 else if (strncmp (argv[0], "s", 1) == 0)
4287 type = OSPF_SUMMARY_LSA;
4288 else if (strncmp (argv[0], "a", 1) == 0)
4289 type = OSPF_ASBR_SUMMARY_LSA;
4290 else if (strncmp (argv[0], "e", 1) == 0)
4291 type = OSPF_AS_EXTERNAL_LSA;
4292#ifdef HAVE_OPAQUE_LSA
4293 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4294 type = OSPF_OPAQUE_LINK_LSA;
4295 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4296 type = OSPF_OPAQUE_AREA_LSA;
4297 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4298 type = OSPF_OPAQUE_AS_LSA;
4299#endif /* HAVE_OPAQUE_LSA */
4300 else
4301 return CMD_WARNING;
4302
4303 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4304 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004305 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004306 else
4307 {
4308 ret = inet_aton (argv[1], &adv_router);
4309 if (!ret)
4310 return CMD_WARNING;
4311 }
4312
paul020709f2003-04-04 02:44:16 +00004313 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004314
4315 return CMD_SUCCESS;
4316}
4317
4318ALIAS (show_ip_ospf_database_type_adv_router,
4319 show_ip_ospf_database_type_self_cmd,
4320 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4321 SHOW_STR
4322 IP_STR
4323 "OSPF information\n"
4324 "Database summary\n"
4325 OSPF_LSA_TYPES_DESC
4326 "Self-originated link states\n")
4327
4328
4329DEFUN (ip_ospf_authentication_args,
4330 ip_ospf_authentication_args_addr_cmd,
4331 "ip ospf authentication (null|message-digest) A.B.C.D",
4332 "IP Information\n"
4333 "OSPF interface commands\n"
4334 "Enable authentication on this interface\n"
4335 "Use null authentication\n"
4336 "Use message-digest authentication\n"
4337 "Address of interface")
4338{
4339 struct interface *ifp;
4340 struct in_addr addr;
4341 int ret;
4342 struct ospf_if_params *params;
4343
4344 ifp = vty->index;
4345 params = IF_DEF_PARAMS (ifp);
4346
4347 if (argc == 2)
4348 {
4349 ret = inet_aton(argv[1], &addr);
4350 if (!ret)
4351 {
4352 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4353 VTY_NEWLINE);
4354 return CMD_WARNING;
4355 }
4356
4357 params = ospf_get_if_params (ifp, addr);
4358 ospf_if_update_params (ifp, addr);
4359 }
4360
4361 /* Handle null authentication */
4362 if ( argv[0][0] == 'n' )
4363 {
4364 SET_IF_PARAM (params, auth_type);
4365 params->auth_type = OSPF_AUTH_NULL;
4366 return CMD_SUCCESS;
4367 }
4368
4369 /* Handle message-digest authentication */
4370 if ( argv[0][0] == 'm' )
4371 {
4372 SET_IF_PARAM (params, auth_type);
4373 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4374 return CMD_SUCCESS;
4375 }
4376
4377 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4378 return CMD_WARNING;
4379}
4380
4381ALIAS (ip_ospf_authentication_args,
4382 ip_ospf_authentication_args_cmd,
4383 "ip ospf authentication (null|message-digest)",
4384 "IP Information\n"
4385 "OSPF interface commands\n"
4386 "Enable authentication on this interface\n"
4387 "Use null authentication\n"
4388 "Use message-digest authentication\n")
4389
4390DEFUN (ip_ospf_authentication,
4391 ip_ospf_authentication_addr_cmd,
4392 "ip ospf authentication A.B.C.D",
4393 "IP Information\n"
4394 "OSPF interface commands\n"
4395 "Enable authentication on this interface\n"
4396 "Address of interface")
4397{
4398 struct interface *ifp;
4399 struct in_addr addr;
4400 int ret;
4401 struct ospf_if_params *params;
4402
4403 ifp = vty->index;
4404 params = IF_DEF_PARAMS (ifp);
4405
4406 if (argc == 1)
4407 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004408 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004409 if (!ret)
4410 {
4411 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4412 VTY_NEWLINE);
4413 return CMD_WARNING;
4414 }
4415
4416 params = ospf_get_if_params (ifp, addr);
4417 ospf_if_update_params (ifp, addr);
4418 }
4419
4420 SET_IF_PARAM (params, auth_type);
4421 params->auth_type = OSPF_AUTH_SIMPLE;
4422
4423 return CMD_SUCCESS;
4424}
4425
4426ALIAS (ip_ospf_authentication,
4427 ip_ospf_authentication_cmd,
4428 "ip ospf authentication",
4429 "IP Information\n"
4430 "OSPF interface commands\n"
4431 "Enable authentication on this interface\n")
4432
4433DEFUN (no_ip_ospf_authentication,
4434 no_ip_ospf_authentication_addr_cmd,
4435 "no ip ospf authentication A.B.C.D",
4436 NO_STR
4437 "IP Information\n"
4438 "OSPF interface commands\n"
4439 "Enable authentication on this interface\n"
4440 "Address of interface")
4441{
4442 struct interface *ifp;
4443 struct in_addr addr;
4444 int ret;
4445 struct ospf_if_params *params;
4446
4447 ifp = vty->index;
4448 params = IF_DEF_PARAMS (ifp);
4449
4450 if (argc == 1)
4451 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004452 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004453 if (!ret)
4454 {
4455 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4456 VTY_NEWLINE);
4457 return CMD_WARNING;
4458 }
4459
4460 params = ospf_lookup_if_params (ifp, addr);
4461 if (params == NULL)
4462 return CMD_SUCCESS;
4463 }
4464
4465 params->auth_type = OSPF_AUTH_NOTSET;
4466 UNSET_IF_PARAM (params, auth_type);
4467
4468 if (params != IF_DEF_PARAMS (ifp))
4469 {
4470 ospf_free_if_params (ifp, addr);
4471 ospf_if_update_params (ifp, addr);
4472 }
4473
4474 return CMD_SUCCESS;
4475}
4476
4477ALIAS (no_ip_ospf_authentication,
4478 no_ip_ospf_authentication_cmd,
4479 "no ip ospf authentication",
4480 NO_STR
4481 "IP Information\n"
4482 "OSPF interface commands\n"
4483 "Enable authentication on this interface\n")
4484
4485DEFUN (ip_ospf_authentication_key,
4486 ip_ospf_authentication_key_addr_cmd,
4487 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4488 "IP Information\n"
4489 "OSPF interface commands\n"
4490 "Authentication password (key)\n"
4491 "The OSPF password (key)\n"
4492 "Address of interface")
4493{
4494 struct interface *ifp;
4495 struct in_addr addr;
4496 int ret;
4497 struct ospf_if_params *params;
4498
4499 ifp = vty->index;
4500 params = IF_DEF_PARAMS (ifp);
4501
4502 if (argc == 2)
4503 {
4504 ret = inet_aton(argv[1], &addr);
4505 if (!ret)
4506 {
4507 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4508 VTY_NEWLINE);
4509 return CMD_WARNING;
4510 }
4511
4512 params = ospf_get_if_params (ifp, addr);
4513 ospf_if_update_params (ifp, addr);
4514 }
4515
4516
4517 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004518 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004519 SET_IF_PARAM (params, auth_simple);
4520
4521 return CMD_SUCCESS;
4522}
4523
4524ALIAS (ip_ospf_authentication_key,
4525 ip_ospf_authentication_key_cmd,
4526 "ip ospf authentication-key AUTH_KEY",
4527 "IP Information\n"
4528 "OSPF interface commands\n"
4529 "Authentication password (key)\n"
4530 "The OSPF password (key)")
4531
4532ALIAS (ip_ospf_authentication_key,
4533 ospf_authentication_key_cmd,
4534 "ospf authentication-key AUTH_KEY",
4535 "OSPF interface commands\n"
4536 "Authentication password (key)\n"
4537 "The OSPF password (key)")
4538
4539DEFUN (no_ip_ospf_authentication_key,
4540 no_ip_ospf_authentication_key_addr_cmd,
4541 "no ip ospf authentication-key A.B.C.D",
4542 NO_STR
4543 "IP Information\n"
4544 "OSPF interface commands\n"
4545 "Authentication password (key)\n"
4546 "Address of interface")
4547{
4548 struct interface *ifp;
4549 struct in_addr addr;
4550 int ret;
4551 struct ospf_if_params *params;
4552
4553 ifp = vty->index;
4554 params = IF_DEF_PARAMS (ifp);
4555
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004556 if (argc == 1)
paul718e3742002-12-13 20:15:29 +00004557 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004558 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004559 if (!ret)
4560 {
4561 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4562 VTY_NEWLINE);
4563 return CMD_WARNING;
4564 }
4565
4566 params = ospf_lookup_if_params (ifp, addr);
4567 if (params == NULL)
4568 return CMD_SUCCESS;
4569 }
4570
4571 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4572 UNSET_IF_PARAM (params, auth_simple);
4573
4574 if (params != IF_DEF_PARAMS (ifp))
4575 {
4576 ospf_free_if_params (ifp, addr);
4577 ospf_if_update_params (ifp, addr);
4578 }
4579
4580 return CMD_SUCCESS;
4581}
4582
4583ALIAS (no_ip_ospf_authentication_key,
4584 no_ip_ospf_authentication_key_cmd,
4585 "no ip ospf authentication-key",
4586 NO_STR
4587 "IP Information\n"
4588 "OSPF interface commands\n"
4589 "Authentication password (key)\n")
4590
4591ALIAS (no_ip_ospf_authentication_key,
4592 no_ospf_authentication_key_cmd,
4593 "no ospf authentication-key",
4594 NO_STR
4595 "OSPF interface commands\n"
4596 "Authentication password (key)\n")
4597
4598DEFUN (ip_ospf_message_digest_key,
4599 ip_ospf_message_digest_key_addr_cmd,
4600 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4601 "IP Information\n"
4602 "OSPF interface commands\n"
4603 "Message digest authentication password (key)\n"
4604 "Key ID\n"
4605 "Use MD5 algorithm\n"
4606 "The OSPF password (key)"
4607 "Address of interface")
4608{
4609 struct interface *ifp;
4610 struct crypt_key *ck;
4611 u_char key_id;
4612 struct in_addr addr;
4613 int ret;
4614 struct ospf_if_params *params;
4615
4616 ifp = vty->index;
4617 params = IF_DEF_PARAMS (ifp);
4618
4619 if (argc == 3)
4620 {
4621 ret = inet_aton(argv[2], &addr);
4622 if (!ret)
4623 {
4624 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4625 VTY_NEWLINE);
4626 return CMD_WARNING;
4627 }
4628
4629 params = ospf_get_if_params (ifp, addr);
4630 ospf_if_update_params (ifp, addr);
4631 }
4632
4633 key_id = strtol (argv[0], NULL, 10);
4634 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4635 {
4636 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4637 return CMD_WARNING;
4638 }
4639
4640 ck = ospf_crypt_key_new ();
4641 ck->key_id = (u_char) key_id;
4642 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004643 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004644
4645 ospf_crypt_key_add (params->auth_crypt, ck);
4646 SET_IF_PARAM (params, auth_crypt);
4647
4648 return CMD_SUCCESS;
4649}
4650
4651ALIAS (ip_ospf_message_digest_key,
4652 ip_ospf_message_digest_key_cmd,
4653 "ip ospf message-digest-key <1-255> md5 KEY",
4654 "IP Information\n"
4655 "OSPF interface commands\n"
4656 "Message digest authentication password (key)\n"
4657 "Key ID\n"
4658 "Use MD5 algorithm\n"
4659 "The OSPF password (key)")
4660
4661ALIAS (ip_ospf_message_digest_key,
4662 ospf_message_digest_key_cmd,
4663 "ospf message-digest-key <1-255> md5 KEY",
4664 "OSPF interface commands\n"
4665 "Message digest authentication password (key)\n"
4666 "Key ID\n"
4667 "Use MD5 algorithm\n"
4668 "The OSPF password (key)")
4669
4670DEFUN (no_ip_ospf_message_digest_key,
4671 no_ip_ospf_message_digest_key_addr_cmd,
4672 "no ip ospf message-digest-key <1-255> A.B.C.D",
4673 NO_STR
4674 "IP Information\n"
4675 "OSPF interface commands\n"
4676 "Message digest authentication password (key)\n"
4677 "Key ID\n"
4678 "Address of interface")
4679{
4680 struct interface *ifp;
4681 struct crypt_key *ck;
4682 int key_id;
4683 struct in_addr addr;
4684 int ret;
4685 struct ospf_if_params *params;
4686
4687 ifp = vty->index;
4688 params = IF_DEF_PARAMS (ifp);
4689
4690 if (argc == 2)
4691 {
4692 ret = inet_aton(argv[1], &addr);
4693 if (!ret)
4694 {
4695 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4696 VTY_NEWLINE);
4697 return CMD_WARNING;
4698 }
4699
4700 params = ospf_lookup_if_params (ifp, addr);
4701 if (params == NULL)
4702 return CMD_SUCCESS;
4703 }
4704
4705 key_id = strtol (argv[0], NULL, 10);
4706 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4707 if (ck == NULL)
4708 {
4709 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4710 return CMD_WARNING;
4711 }
4712
4713 ospf_crypt_key_delete (params->auth_crypt, key_id);
4714
4715 if (params != IF_DEF_PARAMS (ifp))
4716 {
4717 ospf_free_if_params (ifp, addr);
4718 ospf_if_update_params (ifp, addr);
4719 }
4720
4721 return CMD_SUCCESS;
4722}
4723
4724ALIAS (no_ip_ospf_message_digest_key,
4725 no_ip_ospf_message_digest_key_cmd,
4726 "no ip ospf message-digest-key <1-255>",
4727 NO_STR
4728 "IP Information\n"
4729 "OSPF interface commands\n"
4730 "Message digest authentication password (key)\n"
4731 "Key ID\n")
4732
4733ALIAS (no_ip_ospf_message_digest_key,
4734 no_ospf_message_digest_key_cmd,
4735 "no ospf message-digest-key <1-255>",
4736 NO_STR
4737 "OSPF interface commands\n"
4738 "Message digest authentication password (key)\n"
4739 "Key ID\n")
4740
4741DEFUN (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004742 ip_ospf_cost_u32_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004743 "ip ospf cost <1-65535> A.B.C.D",
4744 "IP Information\n"
4745 "OSPF interface commands\n"
4746 "Interface cost\n"
4747 "Cost\n"
4748 "Address of interface")
4749{
4750 struct interface *ifp = vty->index;
4751 u_int32_t cost;
4752 struct in_addr addr;
4753 int ret;
4754 struct ospf_if_params *params;
4755
4756 params = IF_DEF_PARAMS (ifp);
4757
4758 cost = strtol (argv[0], NULL, 10);
4759
4760 /* cost range is <1-65535>. */
4761 if (cost < 1 || cost > 65535)
4762 {
4763 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4764 return CMD_WARNING;
4765 }
4766
4767 if (argc == 2)
4768 {
4769 ret = inet_aton(argv[1], &addr);
4770 if (!ret)
4771 {
4772 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4773 VTY_NEWLINE);
4774 return CMD_WARNING;
4775 }
4776
4777 params = ospf_get_if_params (ifp, addr);
4778 ospf_if_update_params (ifp, addr);
4779 }
4780
4781 SET_IF_PARAM (params, output_cost_cmd);
4782 params->output_cost_cmd = cost;
4783
4784 ospf_if_recalculate_output_cost (ifp);
4785
4786 return CMD_SUCCESS;
4787}
4788
4789ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004790 ip_ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004791 "ip ospf cost <1-65535>",
4792 "IP Information\n"
4793 "OSPF interface commands\n"
4794 "Interface cost\n"
4795 "Cost")
4796
4797ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004798 ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004799 "ospf cost <1-65535>",
4800 "OSPF interface commands\n"
4801 "Interface cost\n"
4802 "Cost")
4803
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004804ALIAS (ip_ospf_cost,
4805 ospf_cost_u32_inet4_cmd,
4806 "ospf cost <1-65535> A.B.C.D",
4807 "OSPF interface commands\n"
4808 "Interface cost\n"
4809 "Cost\n"
4810 "Address of interface")
4811
paul718e3742002-12-13 20:15:29 +00004812DEFUN (no_ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004813 no_ip_ospf_cost_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004814 "no ip ospf cost A.B.C.D",
4815 NO_STR
4816 "IP Information\n"
4817 "OSPF interface commands\n"
4818 "Interface cost\n"
4819 "Address of interface")
4820{
4821 struct interface *ifp = vty->index;
4822 struct in_addr addr;
4823 int ret;
4824 struct ospf_if_params *params;
4825
4826 ifp = vty->index;
4827 params = IF_DEF_PARAMS (ifp);
4828
4829 if (argc == 1)
4830 {
4831 ret = inet_aton(argv[0], &addr);
4832 if (!ret)
4833 {
4834 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4835 VTY_NEWLINE);
4836 return CMD_WARNING;
4837 }
4838
4839 params = ospf_lookup_if_params (ifp, addr);
4840 if (params == NULL)
4841 return CMD_SUCCESS;
4842 }
4843
4844 UNSET_IF_PARAM (params, output_cost_cmd);
4845
4846 if (params != IF_DEF_PARAMS (ifp))
4847 {
4848 ospf_free_if_params (ifp, addr);
4849 ospf_if_update_params (ifp, addr);
4850 }
4851
4852 ospf_if_recalculate_output_cost (ifp);
4853
4854 return CMD_SUCCESS;
4855}
4856
4857ALIAS (no_ip_ospf_cost,
4858 no_ip_ospf_cost_cmd,
4859 "no ip ospf cost",
4860 NO_STR
4861 "IP Information\n"
4862 "OSPF interface commands\n"
4863 "Interface cost\n")
4864
4865ALIAS (no_ip_ospf_cost,
4866 no_ospf_cost_cmd,
4867 "no ospf cost",
4868 NO_STR
4869 "OSPF interface commands\n"
4870 "Interface cost\n")
4871
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004872ALIAS (no_ip_ospf_cost,
4873 no_ospf_cost_inet4_cmd,
4874 "no ospf cost A.B.C.D",
4875 NO_STR
4876 "OSPF interface commands\n"
4877 "Interface cost\n"
4878 "Address of interface")
4879
Denis Ovsienko827341b2009-09-28 19:34:59 +04004880DEFUN (no_ip_ospf_cost2,
4881 no_ip_ospf_cost_u32_cmd,
4882 "no ip ospf cost <1-65535>",
4883 NO_STR
4884 "IP Information\n"
4885 "OSPF interface commands\n"
4886 "Interface cost\n"
4887 "Cost")
4888{
4889 struct interface *ifp = vty->index;
4890 struct in_addr addr;
4891 u_int32_t cost;
4892 int ret;
4893 struct ospf_if_params *params;
4894
4895 ifp = vty->index;
4896 params = IF_DEF_PARAMS (ifp);
4897
4898 /* According to the semantics we are mimicking "no ip ospf cost N" is
4899 * always treated as "no ip ospf cost" regardless of the actual value
4900 * of N already configured for the interface. Thus the first argument
4901 * is always checked to be a number, but is ignored after that.
4902 */
4903 cost = strtol (argv[0], NULL, 10);
4904 if (cost < 1 || cost > 65535)
4905 {
4906 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4907 return CMD_WARNING;
4908 }
4909
4910 if (argc == 2)
4911 {
4912 ret = inet_aton(argv[1], &addr);
4913 if (!ret)
4914 {
4915 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4916 VTY_NEWLINE);
4917 return CMD_WARNING;
4918 }
4919
4920 params = ospf_lookup_if_params (ifp, addr);
4921 if (params == NULL)
4922 return CMD_SUCCESS;
4923 }
4924
4925 UNSET_IF_PARAM (params, output_cost_cmd);
4926
4927 if (params != IF_DEF_PARAMS (ifp))
4928 {
4929 ospf_free_if_params (ifp, addr);
4930 ospf_if_update_params (ifp, addr);
4931 }
4932
4933 ospf_if_recalculate_output_cost (ifp);
4934
4935 return CMD_SUCCESS;
4936}
4937
4938ALIAS (no_ip_ospf_cost2,
4939 no_ospf_cost_u32_cmd,
4940 "no ospf cost <1-65535>",
4941 NO_STR
4942 "OSPF interface commands\n"
4943 "Interface cost\n"
4944 "Cost")
4945
4946ALIAS (no_ip_ospf_cost2,
4947 no_ip_ospf_cost_u32_inet4_cmd,
4948 "no ip ospf cost <1-65535> A.B.C.D",
4949 NO_STR
4950 "IP Information\n"
4951 "OSPF interface commands\n"
4952 "Interface cost\n"
4953 "Cost\n"
4954 "Address of interface")
4955
4956ALIAS (no_ip_ospf_cost2,
4957 no_ospf_cost_u32_inet4_cmd,
4958 "no ospf cost <1-65535> A.B.C.D",
4959 NO_STR
4960 "OSPF interface commands\n"
4961 "Interface cost\n"
4962 "Cost\n"
4963 "Address of interface")
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004964
paul4dadc292005-05-06 21:37:42 +00004965static void
paul718e3742002-12-13 20:15:29 +00004966ospf_nbr_timer_update (struct ospf_interface *oi)
4967{
4968 struct route_node *rn;
4969 struct ospf_neighbor *nbr;
4970
4971 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4972 if ((nbr = rn->info))
4973 {
4974 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4975 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4976 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4977 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4978 }
4979}
4980
paulf9ad9372005-10-21 00:45:17 +00004981static int
4982ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4983 const char *nbr_str,
4984 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004985{
4986 struct interface *ifp = vty->index;
4987 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004988 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004989 struct in_addr addr;
4990 int ret;
4991 struct ospf_if_params *params;
4992 struct ospf_interface *oi;
4993 struct route_node *rn;
4994
4995 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004996
4997 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004998 {
paulf9ad9372005-10-21 00:45:17 +00004999 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00005000 if (!ret)
5001 {
5002 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5003 VTY_NEWLINE);
5004 return CMD_WARNING;
5005 }
5006
5007 params = ospf_get_if_params (ifp, addr);
5008 ospf_if_update_params (ifp, addr);
5009 }
5010
paulf9ad9372005-10-21 00:45:17 +00005011 if (interval_str)
5012 {
5013 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
5014 1, 65535);
5015
5016 /* reset fast_hello too, just to be sure */
5017 UNSET_IF_PARAM (params, fast_hello);
5018 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5019 }
5020 else if (fast_hello_str)
5021 {
5022 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
5023 1, 10);
5024 /* 1s dead-interval with sub-second hellos desired */
5025 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
5026 SET_IF_PARAM (params, fast_hello);
5027 params->fast_hello = hellomult;
5028 }
5029 else
5030 {
5031 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5032 VTY_NEWLINE);
5033 return CMD_WARNING;
5034 }
5035
paul718e3742002-12-13 20:15:29 +00005036 SET_IF_PARAM (params, v_wait);
5037 params->v_wait = seconds;
5038
5039 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00005040 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005041 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005042 struct ospf *ospf;
5043 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005044 {
5045 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5046 if (oi)
5047 ospf_nbr_timer_update (oi);
5048 }
paul718e3742002-12-13 20:15:29 +00005049 }
5050 else
5051 {
5052 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5053 if ((oi = rn->info))
5054 ospf_nbr_timer_update (oi);
5055 }
5056
5057 return CMD_SUCCESS;
5058}
5059
paulf9ad9372005-10-21 00:45:17 +00005060
5061DEFUN (ip_ospf_dead_interval,
5062 ip_ospf_dead_interval_addr_cmd,
5063 "ip ospf dead-interval <1-65535> A.B.C.D",
5064 "IP Information\n"
5065 "OSPF interface commands\n"
5066 "Interval after which a neighbor is declared dead\n"
5067 "Seconds\n"
5068 "Address of interface\n")
5069{
5070 if (argc == 2)
5071 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5072 else
5073 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5074}
5075
paul718e3742002-12-13 20:15:29 +00005076ALIAS (ip_ospf_dead_interval,
5077 ip_ospf_dead_interval_cmd,
5078 "ip ospf dead-interval <1-65535>",
5079 "IP Information\n"
5080 "OSPF interface commands\n"
5081 "Interval after which a neighbor is declared dead\n"
5082 "Seconds\n")
5083
5084ALIAS (ip_ospf_dead_interval,
5085 ospf_dead_interval_cmd,
5086 "ospf dead-interval <1-65535>",
5087 "OSPF interface commands\n"
5088 "Interval after which a neighbor is declared dead\n"
5089 "Seconds\n")
5090
paulf9ad9372005-10-21 00:45:17 +00005091DEFUN (ip_ospf_dead_interval_minimal,
5092 ip_ospf_dead_interval_minimal_addr_cmd,
5093 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5094 "IP Information\n"
5095 "OSPF interface commands\n"
5096 "Interval after which a neighbor is declared dead\n"
5097 "Minimal 1s dead-interval with fast sub-second hellos\n"
5098 "Hello multiplier factor\n"
5099 "Number of Hellos to send each second\n"
5100 "Address of interface\n")
5101{
5102 if (argc == 2)
5103 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5104 else
5105 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5106}
5107
5108ALIAS (ip_ospf_dead_interval_minimal,
5109 ip_ospf_dead_interval_minimal_cmd,
5110 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5111 "IP Information\n"
5112 "OSPF interface commands\n"
5113 "Interval after which a neighbor is declared dead\n"
5114 "Minimal 1s dead-interval with fast sub-second hellos\n"
5115 "Hello multiplier factor\n"
5116 "Number of Hellos to send each second\n")
5117
paul718e3742002-12-13 20:15:29 +00005118DEFUN (no_ip_ospf_dead_interval,
5119 no_ip_ospf_dead_interval_addr_cmd,
5120 "no ip ospf dead-interval A.B.C.D",
5121 NO_STR
5122 "IP Information\n"
5123 "OSPF interface commands\n"
5124 "Interval after which a neighbor is declared dead\n"
5125 "Address of interface")
5126{
5127 struct interface *ifp = vty->index;
5128 struct in_addr addr;
5129 int ret;
5130 struct ospf_if_params *params;
5131 struct ospf_interface *oi;
5132 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00005133
paul718e3742002-12-13 20:15:29 +00005134 ifp = vty->index;
5135 params = IF_DEF_PARAMS (ifp);
5136
5137 if (argc == 1)
5138 {
5139 ret = inet_aton(argv[0], &addr);
5140 if (!ret)
5141 {
5142 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5143 VTY_NEWLINE);
5144 return CMD_WARNING;
5145 }
5146
5147 params = ospf_lookup_if_params (ifp, addr);
5148 if (params == NULL)
5149 return CMD_SUCCESS;
5150 }
5151
5152 UNSET_IF_PARAM (params, v_wait);
5153 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00005154
5155 UNSET_IF_PARAM (params, fast_hello);
5156 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5157
paul718e3742002-12-13 20:15:29 +00005158 if (params != IF_DEF_PARAMS (ifp))
5159 {
5160 ospf_free_if_params (ifp, addr);
5161 ospf_if_update_params (ifp, addr);
5162 }
5163
5164 /* Update timer values in neighbor structure. */
5165 if (argc == 1)
5166 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005167 struct ospf *ospf;
5168
5169 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005170 {
5171 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5172 if (oi)
5173 ospf_nbr_timer_update (oi);
5174 }
paul718e3742002-12-13 20:15:29 +00005175 }
5176 else
5177 {
5178 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5179 if ((oi = rn->info))
5180 ospf_nbr_timer_update (oi);
5181 }
5182
5183 return CMD_SUCCESS;
5184}
5185
5186ALIAS (no_ip_ospf_dead_interval,
5187 no_ip_ospf_dead_interval_cmd,
5188 "no ip ospf dead-interval",
5189 NO_STR
5190 "IP Information\n"
5191 "OSPF interface commands\n"
5192 "Interval after which a neighbor is declared dead\n")
5193
5194ALIAS (no_ip_ospf_dead_interval,
5195 no_ospf_dead_interval_cmd,
5196 "no ospf dead-interval",
5197 NO_STR
5198 "OSPF interface commands\n"
5199 "Interval after which a neighbor is declared dead\n")
5200
5201DEFUN (ip_ospf_hello_interval,
5202 ip_ospf_hello_interval_addr_cmd,
5203 "ip ospf hello-interval <1-65535> A.B.C.D",
5204 "IP Information\n"
5205 "OSPF interface commands\n"
5206 "Time between HELLO packets\n"
5207 "Seconds\n"
5208 "Address of interface")
5209{
5210 struct interface *ifp = vty->index;
5211 u_int32_t seconds;
5212 struct in_addr addr;
5213 int ret;
5214 struct ospf_if_params *params;
5215
5216 params = IF_DEF_PARAMS (ifp);
5217
5218 seconds = strtol (argv[0], NULL, 10);
5219
5220 /* HelloInterval range is <1-65535>. */
5221 if (seconds < 1 || seconds > 65535)
5222 {
5223 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5224 return CMD_WARNING;
5225 }
5226
5227 if (argc == 2)
5228 {
5229 ret = inet_aton(argv[1], &addr);
5230 if (!ret)
5231 {
5232 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5233 VTY_NEWLINE);
5234 return CMD_WARNING;
5235 }
5236
5237 params = ospf_get_if_params (ifp, addr);
5238 ospf_if_update_params (ifp, addr);
5239 }
5240
paulf9ad9372005-10-21 00:45:17 +00005241 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005242 params->v_hello = seconds;
5243
5244 return CMD_SUCCESS;
5245}
5246
5247ALIAS (ip_ospf_hello_interval,
5248 ip_ospf_hello_interval_cmd,
5249 "ip ospf hello-interval <1-65535>",
5250 "IP Information\n"
5251 "OSPF interface commands\n"
5252 "Time between HELLO packets\n"
5253 "Seconds\n")
5254
5255ALIAS (ip_ospf_hello_interval,
5256 ospf_hello_interval_cmd,
5257 "ospf hello-interval <1-65535>",
5258 "OSPF interface commands\n"
5259 "Time between HELLO packets\n"
5260 "Seconds\n")
5261
5262DEFUN (no_ip_ospf_hello_interval,
5263 no_ip_ospf_hello_interval_addr_cmd,
5264 "no ip ospf hello-interval A.B.C.D",
5265 NO_STR
5266 "IP Information\n"
5267 "OSPF interface commands\n"
5268 "Time between HELLO packets\n"
5269 "Address of interface")
5270{
5271 struct interface *ifp = vty->index;
5272 struct in_addr addr;
5273 int ret;
5274 struct ospf_if_params *params;
5275
5276 ifp = vty->index;
5277 params = IF_DEF_PARAMS (ifp);
5278
5279 if (argc == 1)
5280 {
5281 ret = inet_aton(argv[0], &addr);
5282 if (!ret)
5283 {
5284 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5285 VTY_NEWLINE);
5286 return CMD_WARNING;
5287 }
5288
5289 params = ospf_lookup_if_params (ifp, addr);
5290 if (params == NULL)
5291 return CMD_SUCCESS;
5292 }
5293
5294 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005295 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005296
5297 if (params != IF_DEF_PARAMS (ifp))
5298 {
5299 ospf_free_if_params (ifp, addr);
5300 ospf_if_update_params (ifp, addr);
5301 }
5302
5303 return CMD_SUCCESS;
5304}
5305
5306ALIAS (no_ip_ospf_hello_interval,
5307 no_ip_ospf_hello_interval_cmd,
5308 "no ip ospf hello-interval",
5309 NO_STR
5310 "IP Information\n"
5311 "OSPF interface commands\n"
5312 "Time between HELLO packets\n")
5313
5314ALIAS (no_ip_ospf_hello_interval,
5315 no_ospf_hello_interval_cmd,
5316 "no ospf hello-interval",
5317 NO_STR
5318 "OSPF interface commands\n"
5319 "Time between HELLO packets\n")
5320
5321DEFUN (ip_ospf_network,
5322 ip_ospf_network_cmd,
5323 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5324 "IP Information\n"
5325 "OSPF interface commands\n"
5326 "Network type\n"
5327 "Specify OSPF broadcast multi-access network\n"
5328 "Specify OSPF NBMA network\n"
5329 "Specify OSPF point-to-multipoint network\n"
5330 "Specify OSPF point-to-point network\n")
5331{
5332 struct interface *ifp = vty->index;
5333 int old_type = IF_DEF_PARAMS (ifp)->type;
5334 struct route_node *rn;
5335
5336 if (strncmp (argv[0], "b", 1) == 0)
5337 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5338 else if (strncmp (argv[0], "n", 1) == 0)
5339 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5340 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5341 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5342 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5343 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5344
5345 if (IF_DEF_PARAMS (ifp)->type == old_type)
5346 return CMD_SUCCESS;
5347
5348 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5349
5350 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5351 {
5352 struct ospf_interface *oi = rn->info;
5353
5354 if (!oi)
5355 continue;
5356
5357 oi->type = IF_DEF_PARAMS (ifp)->type;
5358
5359 if (oi->state > ISM_Down)
5360 {
5361 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5362 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5363 }
5364 }
5365
5366 return CMD_SUCCESS;
5367}
5368
5369ALIAS (ip_ospf_network,
5370 ospf_network_cmd,
5371 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5372 "OSPF interface commands\n"
5373 "Network type\n"
5374 "Specify OSPF broadcast multi-access network\n"
5375 "Specify OSPF NBMA network\n"
5376 "Specify OSPF point-to-multipoint network\n"
5377 "Specify OSPF point-to-point network\n")
5378
5379DEFUN (no_ip_ospf_network,
5380 no_ip_ospf_network_cmd,
5381 "no ip ospf network",
5382 NO_STR
5383 "IP Information\n"
5384 "OSPF interface commands\n"
5385 "Network type\n")
5386{
5387 struct interface *ifp = vty->index;
5388 int old_type = IF_DEF_PARAMS (ifp)->type;
5389 struct route_node *rn;
5390
ajsbc18d612004-12-15 15:07:19 +00005391 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005392
5393 if (IF_DEF_PARAMS (ifp)->type == old_type)
5394 return CMD_SUCCESS;
5395
5396 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5397 {
5398 struct ospf_interface *oi = rn->info;
5399
5400 if (!oi)
5401 continue;
5402
5403 oi->type = IF_DEF_PARAMS (ifp)->type;
5404
5405 if (oi->state > ISM_Down)
5406 {
5407 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5408 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5409 }
5410 }
5411
5412 return CMD_SUCCESS;
5413}
5414
5415ALIAS (no_ip_ospf_network,
5416 no_ospf_network_cmd,
5417 "no ospf network",
5418 NO_STR
5419 "OSPF interface commands\n"
5420 "Network type\n")
5421
5422DEFUN (ip_ospf_priority,
5423 ip_ospf_priority_addr_cmd,
5424 "ip ospf priority <0-255> A.B.C.D",
5425 "IP Information\n"
5426 "OSPF interface commands\n"
5427 "Router priority\n"
5428 "Priority\n"
5429 "Address of interface")
5430{
5431 struct interface *ifp = vty->index;
5432 u_int32_t priority;
5433 struct route_node *rn;
5434 struct in_addr addr;
5435 int ret;
5436 struct ospf_if_params *params;
5437
5438 params = IF_DEF_PARAMS (ifp);
5439
5440 priority = strtol (argv[0], NULL, 10);
5441
5442 /* Router Priority range is <0-255>. */
5443 if (priority < 0 || priority > 255)
5444 {
5445 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5446 return CMD_WARNING;
5447 }
5448
5449 if (argc == 2)
5450 {
5451 ret = inet_aton(argv[1], &addr);
5452 if (!ret)
5453 {
5454 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5455 VTY_NEWLINE);
5456 return CMD_WARNING;
5457 }
5458
5459 params = ospf_get_if_params (ifp, addr);
5460 ospf_if_update_params (ifp, addr);
5461 }
5462
5463 SET_IF_PARAM (params, priority);
5464 params->priority = priority;
5465
5466 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5467 {
5468 struct ospf_interface *oi = rn->info;
5469
5470 if (!oi)
5471 continue;
5472
5473
5474 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5475 {
5476 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5477 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5478 }
5479 }
5480
5481 return CMD_SUCCESS;
5482}
5483
5484ALIAS (ip_ospf_priority,
5485 ip_ospf_priority_cmd,
5486 "ip ospf priority <0-255>",
5487 "IP Information\n"
5488 "OSPF interface commands\n"
5489 "Router priority\n"
5490 "Priority\n")
5491
5492ALIAS (ip_ospf_priority,
5493 ospf_priority_cmd,
5494 "ospf priority <0-255>",
5495 "OSPF interface commands\n"
5496 "Router priority\n"
5497 "Priority\n")
5498
5499DEFUN (no_ip_ospf_priority,
5500 no_ip_ospf_priority_addr_cmd,
5501 "no ip ospf priority A.B.C.D",
5502 NO_STR
5503 "IP Information\n"
5504 "OSPF interface commands\n"
5505 "Router priority\n"
5506 "Address of interface")
5507{
5508 struct interface *ifp = vty->index;
5509 struct route_node *rn;
5510 struct in_addr addr;
5511 int ret;
5512 struct ospf_if_params *params;
5513
5514 ifp = vty->index;
5515 params = IF_DEF_PARAMS (ifp);
5516
5517 if (argc == 1)
5518 {
5519 ret = inet_aton(argv[0], &addr);
5520 if (!ret)
5521 {
5522 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5523 VTY_NEWLINE);
5524 return CMD_WARNING;
5525 }
5526
5527 params = ospf_lookup_if_params (ifp, addr);
5528 if (params == NULL)
5529 return CMD_SUCCESS;
5530 }
5531
5532 UNSET_IF_PARAM (params, priority);
5533 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5534
5535 if (params != IF_DEF_PARAMS (ifp))
5536 {
5537 ospf_free_if_params (ifp, addr);
5538 ospf_if_update_params (ifp, addr);
5539 }
5540
5541 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5542 {
5543 struct ospf_interface *oi = rn->info;
5544
5545 if (!oi)
5546 continue;
5547
5548
5549 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5550 {
5551 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5552 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5553 }
5554 }
5555
5556 return CMD_SUCCESS;
5557}
5558
5559ALIAS (no_ip_ospf_priority,
5560 no_ip_ospf_priority_cmd,
5561 "no ip ospf priority",
5562 NO_STR
5563 "IP Information\n"
5564 "OSPF interface commands\n"
5565 "Router priority\n")
5566
5567ALIAS (no_ip_ospf_priority,
5568 no_ospf_priority_cmd,
5569 "no ospf priority",
5570 NO_STR
5571 "OSPF interface commands\n"
5572 "Router priority\n")
5573
5574DEFUN (ip_ospf_retransmit_interval,
5575 ip_ospf_retransmit_interval_addr_cmd,
5576 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5577 "IP Information\n"
5578 "OSPF interface commands\n"
5579 "Time between retransmitting lost link state advertisements\n"
5580 "Seconds\n"
5581 "Address of interface")
5582{
5583 struct interface *ifp = vty->index;
5584 u_int32_t seconds;
5585 struct in_addr addr;
5586 int ret;
5587 struct ospf_if_params *params;
5588
5589 params = IF_DEF_PARAMS (ifp);
5590 seconds = strtol (argv[0], NULL, 10);
5591
5592 /* Retransmit Interval range is <3-65535>. */
5593 if (seconds < 3 || seconds > 65535)
5594 {
5595 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5596 return CMD_WARNING;
5597 }
5598
5599
5600 if (argc == 2)
5601 {
5602 ret = inet_aton(argv[1], &addr);
5603 if (!ret)
5604 {
5605 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5606 VTY_NEWLINE);
5607 return CMD_WARNING;
5608 }
5609
5610 params = ospf_get_if_params (ifp, addr);
5611 ospf_if_update_params (ifp, addr);
5612 }
5613
5614 SET_IF_PARAM (params, retransmit_interval);
5615 params->retransmit_interval = seconds;
5616
5617 return CMD_SUCCESS;
5618}
5619
5620ALIAS (ip_ospf_retransmit_interval,
5621 ip_ospf_retransmit_interval_cmd,
5622 "ip ospf retransmit-interval <3-65535>",
5623 "IP Information\n"
5624 "OSPF interface commands\n"
5625 "Time between retransmitting lost link state advertisements\n"
5626 "Seconds\n")
5627
5628ALIAS (ip_ospf_retransmit_interval,
5629 ospf_retransmit_interval_cmd,
5630 "ospf retransmit-interval <3-65535>",
5631 "OSPF interface commands\n"
5632 "Time between retransmitting lost link state advertisements\n"
5633 "Seconds\n")
5634
5635DEFUN (no_ip_ospf_retransmit_interval,
5636 no_ip_ospf_retransmit_interval_addr_cmd,
5637 "no ip ospf retransmit-interval A.B.C.D",
5638 NO_STR
5639 "IP Information\n"
5640 "OSPF interface commands\n"
5641 "Time between retransmitting lost link state advertisements\n"
5642 "Address of interface")
5643{
5644 struct interface *ifp = vty->index;
5645 struct in_addr addr;
5646 int ret;
5647 struct ospf_if_params *params;
5648
5649 ifp = vty->index;
5650 params = IF_DEF_PARAMS (ifp);
5651
5652 if (argc == 1)
5653 {
5654 ret = inet_aton(argv[0], &addr);
5655 if (!ret)
5656 {
5657 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5658 VTY_NEWLINE);
5659 return CMD_WARNING;
5660 }
5661
5662 params = ospf_lookup_if_params (ifp, addr);
5663 if (params == NULL)
5664 return CMD_SUCCESS;
5665 }
5666
5667 UNSET_IF_PARAM (params, retransmit_interval);
5668 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5669
5670 if (params != IF_DEF_PARAMS (ifp))
5671 {
5672 ospf_free_if_params (ifp, addr);
5673 ospf_if_update_params (ifp, addr);
5674 }
5675
5676 return CMD_SUCCESS;
5677}
5678
5679ALIAS (no_ip_ospf_retransmit_interval,
5680 no_ip_ospf_retransmit_interval_cmd,
5681 "no ip ospf retransmit-interval",
5682 NO_STR
5683 "IP Information\n"
5684 "OSPF interface commands\n"
5685 "Time between retransmitting lost link state advertisements\n")
5686
5687ALIAS (no_ip_ospf_retransmit_interval,
5688 no_ospf_retransmit_interval_cmd,
5689 "no ospf retransmit-interval",
5690 NO_STR
5691 "OSPF interface commands\n"
5692 "Time between retransmitting lost link state advertisements\n")
5693
5694DEFUN (ip_ospf_transmit_delay,
5695 ip_ospf_transmit_delay_addr_cmd,
5696 "ip ospf transmit-delay <1-65535> A.B.C.D",
5697 "IP Information\n"
5698 "OSPF interface commands\n"
5699 "Link state transmit delay\n"
5700 "Seconds\n"
5701 "Address of interface")
5702{
5703 struct interface *ifp = vty->index;
5704 u_int32_t seconds;
5705 struct in_addr addr;
5706 int ret;
5707 struct ospf_if_params *params;
5708
5709 params = IF_DEF_PARAMS (ifp);
5710 seconds = strtol (argv[0], NULL, 10);
5711
5712 /* Transmit Delay range is <1-65535>. */
5713 if (seconds < 1 || seconds > 65535)
5714 {
5715 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5716 return CMD_WARNING;
5717 }
5718
5719 if (argc == 2)
5720 {
5721 ret = inet_aton(argv[1], &addr);
5722 if (!ret)
5723 {
5724 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5725 VTY_NEWLINE);
5726 return CMD_WARNING;
5727 }
5728
5729 params = ospf_get_if_params (ifp, addr);
5730 ospf_if_update_params (ifp, addr);
5731 }
5732
5733 SET_IF_PARAM (params, transmit_delay);
5734 params->transmit_delay = seconds;
5735
5736 return CMD_SUCCESS;
5737}
5738
5739ALIAS (ip_ospf_transmit_delay,
5740 ip_ospf_transmit_delay_cmd,
5741 "ip ospf transmit-delay <1-65535>",
5742 "IP Information\n"
5743 "OSPF interface commands\n"
5744 "Link state transmit delay\n"
5745 "Seconds\n")
5746
5747ALIAS (ip_ospf_transmit_delay,
5748 ospf_transmit_delay_cmd,
5749 "ospf transmit-delay <1-65535>",
5750 "OSPF interface commands\n"
5751 "Link state transmit delay\n"
5752 "Seconds\n")
5753
5754DEFUN (no_ip_ospf_transmit_delay,
5755 no_ip_ospf_transmit_delay_addr_cmd,
5756 "no ip ospf transmit-delay A.B.C.D",
5757 NO_STR
5758 "IP Information\n"
5759 "OSPF interface commands\n"
5760 "Link state transmit delay\n"
5761 "Address of interface")
5762{
5763 struct interface *ifp = vty->index;
5764 struct in_addr addr;
5765 int ret;
5766 struct ospf_if_params *params;
5767
5768 ifp = vty->index;
5769 params = IF_DEF_PARAMS (ifp);
5770
5771 if (argc == 1)
5772 {
5773 ret = inet_aton(argv[0], &addr);
5774 if (!ret)
5775 {
5776 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5777 VTY_NEWLINE);
5778 return CMD_WARNING;
5779 }
5780
5781 params = ospf_lookup_if_params (ifp, addr);
5782 if (params == NULL)
5783 return CMD_SUCCESS;
5784 }
5785
5786 UNSET_IF_PARAM (params, transmit_delay);
5787 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5788
5789 if (params != IF_DEF_PARAMS (ifp))
5790 {
5791 ospf_free_if_params (ifp, addr);
5792 ospf_if_update_params (ifp, addr);
5793 }
5794
5795 return CMD_SUCCESS;
5796}
5797
5798ALIAS (no_ip_ospf_transmit_delay,
5799 no_ip_ospf_transmit_delay_cmd,
5800 "no ip ospf transmit-delay",
5801 NO_STR
5802 "IP Information\n"
5803 "OSPF interface commands\n"
5804 "Link state transmit delay\n")
5805
5806ALIAS (no_ip_ospf_transmit_delay,
5807 no_ospf_transmit_delay_cmd,
5808 "no ospf transmit-delay",
5809 NO_STR
5810 "OSPF interface commands\n"
5811 "Link state transmit delay\n")
5812
5813
5814DEFUN (ospf_redistribute_source_metric_type,
5815 ospf_redistribute_source_metric_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005816 "redistribute " QUAGGA_REDIST_STR_OSPFD
5817 " metric <0-16777214> metric-type (1|2) route-map WORD",
5818 REDIST_STR
5819 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005820 "Metric for redistributed routes\n"
5821 "OSPF default metric\n"
5822 "OSPF exterior metric type for redistributed routes\n"
5823 "Set OSPF External Type 1 metrics\n"
5824 "Set OSPF External Type 2 metrics\n"
5825 "Route map reference\n"
5826 "Pointer to route-map entries\n")
5827{
paul020709f2003-04-04 02:44:16 +00005828 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005829 int source;
5830 int type = -1;
5831 int metric = -1;
5832
5833 /* Get distribute source. */
5834 if (!str2distribute_source (argv[0], &source))
5835 return CMD_WARNING;
5836
5837 /* Get metric value. */
5838 if (argc >= 2)
5839 if (!str2metric (argv[1], &metric))
5840 return CMD_WARNING;
5841
5842 /* Get metric type. */
5843 if (argc >= 3)
5844 if (!str2metric_type (argv[2], &type))
5845 return CMD_WARNING;
5846
5847 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005848 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005849 else
paul020709f2003-04-04 02:44:16 +00005850 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005851
paul020709f2003-04-04 02:44:16 +00005852 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005853}
5854
5855ALIAS (ospf_redistribute_source_metric_type,
5856 ospf_redistribute_source_metric_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005857 "redistribute " QUAGGA_REDIST_STR_OSPFD
5858 " metric <0-16777214> metric-type (1|2)",
5859 REDIST_STR
5860 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005861 "Metric for redistributed routes\n"
5862 "OSPF default metric\n"
5863 "OSPF exterior metric type for redistributed routes\n"
5864 "Set OSPF External Type 1 metrics\n"
5865 "Set OSPF External Type 2 metrics\n")
5866
5867ALIAS (ospf_redistribute_source_metric_type,
5868 ospf_redistribute_source_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005869 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5870 REDIST_STR
5871 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005872 "Metric for redistributed routes\n"
5873 "OSPF default metric\n")
5874
5875DEFUN (ospf_redistribute_source_type_metric,
5876 ospf_redistribute_source_type_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005877 "redistribute " QUAGGA_REDIST_STR_OSPFD
5878 " metric-type (1|2) metric <0-16777214> route-map WORD",
5879 REDIST_STR
5880 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005881 "OSPF exterior metric type for redistributed routes\n"
5882 "Set OSPF External Type 1 metrics\n"
5883 "Set OSPF External Type 2 metrics\n"
5884 "Metric for redistributed routes\n"
5885 "OSPF default metric\n"
5886 "Route map reference\n"
5887 "Pointer to route-map entries\n")
5888{
paul020709f2003-04-04 02:44:16 +00005889 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005890 int source;
5891 int type = -1;
5892 int metric = -1;
5893
5894 /* Get distribute source. */
5895 if (!str2distribute_source (argv[0], &source))
5896 return CMD_WARNING;
5897
5898 /* Get metric value. */
5899 if (argc >= 2)
5900 if (!str2metric_type (argv[1], &type))
5901 return CMD_WARNING;
5902
5903 /* Get metric type. */
5904 if (argc >= 3)
5905 if (!str2metric (argv[2], &metric))
5906 return CMD_WARNING;
5907
5908 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005909 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005910 else
paul020709f2003-04-04 02:44:16 +00005911 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005912
paul020709f2003-04-04 02:44:16 +00005913 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005914}
5915
5916ALIAS (ospf_redistribute_source_type_metric,
5917 ospf_redistribute_source_type_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005918 "redistribute " QUAGGA_REDIST_STR_OSPFD
5919 " metric-type (1|2) metric <0-16777214>",
5920 REDIST_STR
5921 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005922 "OSPF exterior metric type for redistributed routes\n"
5923 "Set OSPF External Type 1 metrics\n"
5924 "Set OSPF External Type 2 metrics\n"
5925 "Metric for redistributed routes\n"
5926 "OSPF default metric\n")
5927
5928ALIAS (ospf_redistribute_source_type_metric,
5929 ospf_redistribute_source_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005930 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5931 REDIST_STR
5932 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005933 "OSPF exterior metric type for redistributed routes\n"
5934 "Set OSPF External Type 1 metrics\n"
5935 "Set OSPF External Type 2 metrics\n")
5936
5937ALIAS (ospf_redistribute_source_type_metric,
5938 ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005939 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5940 REDIST_STR
5941 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005942
5943DEFUN (ospf_redistribute_source_metric_routemap,
5944 ospf_redistribute_source_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005945 "redistribute " QUAGGA_REDIST_STR_OSPFD
5946 " metric <0-16777214> route-map WORD",
5947 REDIST_STR
5948 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005949 "Metric for redistributed routes\n"
5950 "OSPF default metric\n"
5951 "Route map reference\n"
5952 "Pointer to route-map entries\n")
5953{
paul020709f2003-04-04 02:44:16 +00005954 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005955 int source;
5956 int metric = -1;
5957
5958 /* Get distribute source. */
5959 if (!str2distribute_source (argv[0], &source))
5960 return CMD_WARNING;
5961
5962 /* Get metric value. */
5963 if (argc >= 2)
5964 if (!str2metric (argv[1], &metric))
5965 return CMD_WARNING;
5966
5967 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005968 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005969 else
paul020709f2003-04-04 02:44:16 +00005970 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005971
paul020709f2003-04-04 02:44:16 +00005972 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005973}
5974
5975DEFUN (ospf_redistribute_source_type_routemap,
5976 ospf_redistribute_source_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005977 "redistribute " QUAGGA_REDIST_STR_OSPFD
5978 " metric-type (1|2) route-map WORD",
5979 REDIST_STR
5980 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005981 "OSPF exterior metric type for redistributed routes\n"
5982 "Set OSPF External Type 1 metrics\n"
5983 "Set OSPF External Type 2 metrics\n"
5984 "Route map reference\n"
5985 "Pointer to route-map entries\n")
5986{
paul020709f2003-04-04 02:44:16 +00005987 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005988 int source;
5989 int type = -1;
5990
5991 /* Get distribute source. */
5992 if (!str2distribute_source (argv[0], &source))
5993 return CMD_WARNING;
5994
5995 /* Get metric value. */
5996 if (argc >= 2)
5997 if (!str2metric_type (argv[1], &type))
5998 return CMD_WARNING;
5999
6000 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006001 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00006002 else
paul020709f2003-04-04 02:44:16 +00006003 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006004
paul020709f2003-04-04 02:44:16 +00006005 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00006006}
6007
6008DEFUN (ospf_redistribute_source_routemap,
6009 ospf_redistribute_source_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006010 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
6011 REDIST_STR
6012 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00006013 "Route map reference\n"
6014 "Pointer to route-map entries\n")
6015{
paul020709f2003-04-04 02:44:16 +00006016 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006017 int source;
6018
6019 /* Get distribute source. */
6020 if (!str2distribute_source (argv[0], &source))
6021 return CMD_WARNING;
6022
6023 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006024 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00006025 else
paul020709f2003-04-04 02:44:16 +00006026 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006027
paul020709f2003-04-04 02:44:16 +00006028 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00006029}
6030
6031DEFUN (no_ospf_redistribute_source,
6032 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006033 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006034 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006035 REDIST_STR
6036 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006037{
paul020709f2003-04-04 02:44:16 +00006038 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006039 int source;
6040
6041 if (!str2distribute_source (argv[0], &source))
6042 return CMD_WARNING;
6043
paul020709f2003-04-04 02:44:16 +00006044 ospf_routemap_unset (ospf, source);
6045 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006046}
6047
6048DEFUN (ospf_distribute_list_out,
6049 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006050 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006051 "Filter networks in routing updates\n"
6052 "Access-list name\n"
6053 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006054 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006055{
paul68980082003-03-25 05:07:42 +00006056 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006057 int source;
6058
6059 /* Get distribute source. */
6060 if (!str2distribute_source (argv[1], &source))
6061 return CMD_WARNING;
6062
paul68980082003-03-25 05:07:42 +00006063 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006064}
6065
6066DEFUN (no_ospf_distribute_list_out,
6067 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006068 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006069 NO_STR
6070 "Filter networks in routing updates\n"
6071 "Access-list name\n"
6072 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006073 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006074{
paul68980082003-03-25 05:07:42 +00006075 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006076 int source;
6077
6078 if (!str2distribute_source (argv[1], &source))
6079 return CMD_WARNING;
6080
paul68980082003-03-25 05:07:42 +00006081 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006082}
6083
6084/* Default information originate. */
6085DEFUN (ospf_default_information_originate_metric_type_routemap,
6086 ospf_default_information_originate_metric_type_routemap_cmd,
6087 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
6088 "Control distribution of default information\n"
6089 "Distribute a default route\n"
6090 "OSPF default metric\n"
6091 "OSPF metric\n"
6092 "OSPF metric type for default routes\n"
6093 "Set OSPF External Type 1 metrics\n"
6094 "Set OSPF External Type 2 metrics\n"
6095 "Route map reference\n"
6096 "Pointer to route-map entries\n")
6097{
paul020709f2003-04-04 02:44:16 +00006098 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006099 int type = -1;
6100 int metric = -1;
6101
6102 /* Get metric value. */
6103 if (argc >= 1)
6104 if (!str2metric (argv[0], &metric))
6105 return CMD_WARNING;
6106
6107 /* Get metric type. */
6108 if (argc >= 2)
6109 if (!str2metric_type (argv[1], &type))
6110 return CMD_WARNING;
6111
6112 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006113 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006114 else
paul020709f2003-04-04 02:44:16 +00006115 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006116
paul020709f2003-04-04 02:44:16 +00006117 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6118 type, metric);
paul718e3742002-12-13 20:15:29 +00006119}
6120
6121ALIAS (ospf_default_information_originate_metric_type_routemap,
6122 ospf_default_information_originate_metric_type_cmd,
6123 "default-information originate metric <0-16777214> metric-type (1|2)",
6124 "Control distribution of default information\n"
6125 "Distribute a default route\n"
6126 "OSPF default metric\n"
6127 "OSPF metric\n"
6128 "OSPF metric type for default routes\n"
6129 "Set OSPF External Type 1 metrics\n"
6130 "Set OSPF External Type 2 metrics\n")
6131
6132ALIAS (ospf_default_information_originate_metric_type_routemap,
6133 ospf_default_information_originate_metric_cmd,
6134 "default-information originate metric <0-16777214>",
6135 "Control distribution of default information\n"
6136 "Distribute a default route\n"
6137 "OSPF default metric\n"
6138 "OSPF metric\n")
6139
6140ALIAS (ospf_default_information_originate_metric_type_routemap,
6141 ospf_default_information_originate_cmd,
6142 "default-information originate",
6143 "Control distribution of default information\n"
6144 "Distribute a default route\n")
6145
6146/* Default information originate. */
6147DEFUN (ospf_default_information_originate_metric_routemap,
6148 ospf_default_information_originate_metric_routemap_cmd,
6149 "default-information originate metric <0-16777214> route-map WORD",
6150 "Control distribution of default information\n"
6151 "Distribute a default route\n"
6152 "OSPF default metric\n"
6153 "OSPF metric\n"
6154 "Route map reference\n"
6155 "Pointer to route-map entries\n")
6156{
paul020709f2003-04-04 02:44:16 +00006157 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006158 int metric = -1;
6159
6160 /* Get metric value. */
6161 if (argc >= 1)
6162 if (!str2metric (argv[0], &metric))
6163 return CMD_WARNING;
6164
6165 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006166 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006167 else
paul020709f2003-04-04 02:44:16 +00006168 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006169
paul020709f2003-04-04 02:44:16 +00006170 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6171 -1, metric);
paul718e3742002-12-13 20:15:29 +00006172}
6173
6174/* Default information originate. */
6175DEFUN (ospf_default_information_originate_routemap,
6176 ospf_default_information_originate_routemap_cmd,
6177 "default-information originate route-map WORD",
6178 "Control distribution of default information\n"
6179 "Distribute a default route\n"
6180 "Route map reference\n"
6181 "Pointer to route-map entries\n")
6182{
paul020709f2003-04-04 02:44:16 +00006183 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006184
paul020709f2003-04-04 02:44:16 +00006185 if (argc == 1)
6186 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6187 else
6188 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6189
6190 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00006191}
6192
6193DEFUN (ospf_default_information_originate_type_metric_routemap,
6194 ospf_default_information_originate_type_metric_routemap_cmd,
6195 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6196 "Control distribution of default information\n"
6197 "Distribute a default route\n"
6198 "OSPF metric type for default routes\n"
6199 "Set OSPF External Type 1 metrics\n"
6200 "Set OSPF External Type 2 metrics\n"
6201 "OSPF default metric\n"
6202 "OSPF metric\n"
6203 "Route map reference\n"
6204 "Pointer to route-map entries\n")
6205{
paul020709f2003-04-04 02:44:16 +00006206 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006207 int type = -1;
6208 int metric = -1;
6209
6210 /* Get metric type. */
6211 if (argc >= 1)
6212 if (!str2metric_type (argv[0], &type))
6213 return CMD_WARNING;
6214
6215 /* Get metric value. */
6216 if (argc >= 2)
6217 if (!str2metric (argv[1], &metric))
6218 return CMD_WARNING;
6219
6220 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006221 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006222 else
paul020709f2003-04-04 02:44:16 +00006223 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006224
paul020709f2003-04-04 02:44:16 +00006225 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6226 type, metric);
paul718e3742002-12-13 20:15:29 +00006227}
6228
6229ALIAS (ospf_default_information_originate_type_metric_routemap,
6230 ospf_default_information_originate_type_metric_cmd,
6231 "default-information originate metric-type (1|2) metric <0-16777214>",
6232 "Control distribution of default information\n"
6233 "Distribute a default route\n"
6234 "OSPF metric type for default routes\n"
6235 "Set OSPF External Type 1 metrics\n"
6236 "Set OSPF External Type 2 metrics\n"
6237 "OSPF default metric\n"
6238 "OSPF metric\n")
6239
6240ALIAS (ospf_default_information_originate_type_metric_routemap,
6241 ospf_default_information_originate_type_cmd,
6242 "default-information originate metric-type (1|2)",
6243 "Control distribution of default information\n"
6244 "Distribute a default route\n"
6245 "OSPF metric type for default routes\n"
6246 "Set OSPF External Type 1 metrics\n"
6247 "Set OSPF External Type 2 metrics\n")
6248
6249DEFUN (ospf_default_information_originate_type_routemap,
6250 ospf_default_information_originate_type_routemap_cmd,
6251 "default-information originate metric-type (1|2) route-map WORD",
6252 "Control distribution of default information\n"
6253 "Distribute a default route\n"
6254 "OSPF metric type for default routes\n"
6255 "Set OSPF External Type 1 metrics\n"
6256 "Set OSPF External Type 2 metrics\n"
6257 "Route map reference\n"
6258 "Pointer to route-map entries\n")
6259{
paul020709f2003-04-04 02:44:16 +00006260 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006261 int type = -1;
6262
6263 /* Get metric type. */
6264 if (argc >= 1)
6265 if (!str2metric_type (argv[0], &type))
6266 return CMD_WARNING;
6267
6268 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006269 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006270 else
paul020709f2003-04-04 02:44:16 +00006271 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006272
paul020709f2003-04-04 02:44:16 +00006273 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6274 type, -1);
paul718e3742002-12-13 20:15:29 +00006275}
6276
6277DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6278 ospf_default_information_originate_always_metric_type_routemap_cmd,
6279 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6280 "Control distribution of default information\n"
6281 "Distribute a default route\n"
6282 "Always advertise default route\n"
6283 "OSPF default metric\n"
6284 "OSPF metric\n"
6285 "OSPF metric type for default routes\n"
6286 "Set OSPF External Type 1 metrics\n"
6287 "Set OSPF External Type 2 metrics\n"
6288 "Route map reference\n"
6289 "Pointer to route-map entries\n")
6290{
paul020709f2003-04-04 02:44:16 +00006291 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006292 int type = -1;
6293 int metric = -1;
6294
6295 /* Get metric value. */
6296 if (argc >= 1)
6297 if (!str2metric (argv[0], &metric))
6298 return CMD_WARNING;
6299
6300 /* Get metric type. */
6301 if (argc >= 2)
6302 if (!str2metric_type (argv[1], &type))
6303 return CMD_WARNING;
6304
6305 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006306 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006307 else
paul020709f2003-04-04 02:44:16 +00006308 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006309
paul020709f2003-04-04 02:44:16 +00006310 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006311 type, metric);
6312}
6313
6314ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6315 ospf_default_information_originate_always_metric_type_cmd,
6316 "default-information originate always metric <0-16777214> metric-type (1|2)",
6317 "Control distribution of default information\n"
6318 "Distribute a default route\n"
6319 "Always advertise default route\n"
6320 "OSPF default metric\n"
6321 "OSPF metric\n"
6322 "OSPF metric type for default routes\n"
6323 "Set OSPF External Type 1 metrics\n"
6324 "Set OSPF External Type 2 metrics\n")
6325
6326ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6327 ospf_default_information_originate_always_metric_cmd,
6328 "default-information originate always metric <0-16777214>",
6329 "Control distribution of default information\n"
6330 "Distribute a default route\n"
6331 "Always advertise default route\n"
6332 "OSPF default metric\n"
6333 "OSPF metric\n"
6334 "OSPF metric type for default routes\n")
6335
6336ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6337 ospf_default_information_originate_always_cmd,
6338 "default-information originate always",
6339 "Control distribution of default information\n"
6340 "Distribute a default route\n"
6341 "Always advertise default route\n")
6342
6343DEFUN (ospf_default_information_originate_always_metric_routemap,
6344 ospf_default_information_originate_always_metric_routemap_cmd,
6345 "default-information originate always metric <0-16777214> route-map WORD",
6346 "Control distribution of default information\n"
6347 "Distribute a default route\n"
6348 "Always advertise default route\n"
6349 "OSPF default metric\n"
6350 "OSPF metric\n"
6351 "Route map reference\n"
6352 "Pointer to route-map entries\n")
6353{
paul020709f2003-04-04 02:44:16 +00006354 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006355 int metric = -1;
6356
6357 /* Get metric value. */
6358 if (argc >= 1)
6359 if (!str2metric (argv[0], &metric))
6360 return CMD_WARNING;
6361
6362 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006363 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006364 else
paul020709f2003-04-04 02:44:16 +00006365 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006366
paul020709f2003-04-04 02:44:16 +00006367 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6368 -1, metric);
paul718e3742002-12-13 20:15:29 +00006369}
6370
6371DEFUN (ospf_default_information_originate_always_routemap,
6372 ospf_default_information_originate_always_routemap_cmd,
6373 "default-information originate always route-map WORD",
6374 "Control distribution of default information\n"
6375 "Distribute a default route\n"
6376 "Always advertise default route\n"
6377 "Route map reference\n"
6378 "Pointer to route-map entries\n")
6379{
paul020709f2003-04-04 02:44:16 +00006380 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006381
paul020709f2003-04-04 02:44:16 +00006382 if (argc == 1)
6383 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6384 else
6385 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6386
6387 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006388}
6389
6390DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6391 ospf_default_information_originate_always_type_metric_routemap_cmd,
6392 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6393 "Control distribution of default information\n"
6394 "Distribute a default route\n"
6395 "Always advertise default route\n"
6396 "OSPF metric type for default routes\n"
6397 "Set OSPF External Type 1 metrics\n"
6398 "Set OSPF External Type 2 metrics\n"
6399 "OSPF default metric\n"
6400 "OSPF metric\n"
6401 "Route map reference\n"
6402 "Pointer to route-map entries\n")
6403{
paul020709f2003-04-04 02:44:16 +00006404 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006405 int type = -1;
6406 int metric = -1;
6407
6408 /* Get metric type. */
6409 if (argc >= 1)
6410 if (!str2metric_type (argv[0], &type))
6411 return CMD_WARNING;
6412
6413 /* Get metric value. */
6414 if (argc >= 2)
6415 if (!str2metric (argv[1], &metric))
6416 return CMD_WARNING;
6417
6418 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006419 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006420 else
paul020709f2003-04-04 02:44:16 +00006421 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006422
paul020709f2003-04-04 02:44:16 +00006423 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006424 type, metric);
6425}
6426
6427ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6428 ospf_default_information_originate_always_type_metric_cmd,
6429 "default-information originate always metric-type (1|2) metric <0-16777214>",
6430 "Control distribution of default information\n"
6431 "Distribute a default route\n"
6432 "Always advertise default route\n"
6433 "OSPF metric type for default routes\n"
6434 "Set OSPF External Type 1 metrics\n"
6435 "Set OSPF External Type 2 metrics\n"
6436 "OSPF default metric\n"
6437 "OSPF metric\n")
6438
6439ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6440 ospf_default_information_originate_always_type_cmd,
6441 "default-information originate always metric-type (1|2)",
6442 "Control distribution of default information\n"
6443 "Distribute a default route\n"
6444 "Always advertise default route\n"
6445 "OSPF metric type for default routes\n"
6446 "Set OSPF External Type 1 metrics\n"
6447 "Set OSPF External Type 2 metrics\n")
6448
6449DEFUN (ospf_default_information_originate_always_type_routemap,
6450 ospf_default_information_originate_always_type_routemap_cmd,
6451 "default-information originate always metric-type (1|2) route-map WORD",
6452 "Control distribution of default information\n"
6453 "Distribute a default route\n"
6454 "Always advertise default route\n"
6455 "OSPF metric type for default routes\n"
6456 "Set OSPF External Type 1 metrics\n"
6457 "Set OSPF External Type 2 metrics\n"
6458 "Route map reference\n"
6459 "Pointer to route-map entries\n")
6460{
paul020709f2003-04-04 02:44:16 +00006461 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006462 int type = -1;
6463
6464 /* Get metric type. */
6465 if (argc >= 1)
6466 if (!str2metric_type (argv[0], &type))
6467 return CMD_WARNING;
6468
6469 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006470 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006471 else
paul020709f2003-04-04 02:44:16 +00006472 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006473
paul020709f2003-04-04 02:44:16 +00006474 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006475 type, -1);
6476}
6477
6478DEFUN (no_ospf_default_information_originate,
6479 no_ospf_default_information_originate_cmd,
6480 "no default-information originate",
6481 NO_STR
6482 "Control distribution of default information\n"
6483 "Distribute a default route\n")
6484{
paul68980082003-03-25 05:07:42 +00006485 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006486 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006487
6488 p.family = AF_INET;
6489 p.prefix.s_addr = 0;
6490 p.prefixlen = 0;
6491
ajs5339cfd2005-09-19 13:28:05 +00006492 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006493
6494 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6495 ospf_external_info_delete (DEFAULT_ROUTE, p);
6496 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6497 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6498 }
6499
paul020709f2003-04-04 02:44:16 +00006500 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6501 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006502}
6503
6504DEFUN (ospf_default_metric,
6505 ospf_default_metric_cmd,
6506 "default-metric <0-16777214>",
6507 "Set metric of redistributed routes\n"
6508 "Default metric\n")
6509{
paul68980082003-03-25 05:07:42 +00006510 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006511 int metric = -1;
6512
6513 if (!str2metric (argv[0], &metric))
6514 return CMD_WARNING;
6515
paul68980082003-03-25 05:07:42 +00006516 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006517
6518 return CMD_SUCCESS;
6519}
6520
6521DEFUN (no_ospf_default_metric,
6522 no_ospf_default_metric_cmd,
6523 "no default-metric",
6524 NO_STR
6525 "Set metric of redistributed routes\n")
6526{
paul68980082003-03-25 05:07:42 +00006527 struct ospf *ospf = vty->index;
6528
6529 ospf->default_metric = -1;
6530
paul718e3742002-12-13 20:15:29 +00006531 return CMD_SUCCESS;
6532}
6533
6534ALIAS (no_ospf_default_metric,
6535 no_ospf_default_metric_val_cmd,
6536 "no default-metric <0-16777214>",
6537 NO_STR
6538 "Set metric of redistributed routes\n"
6539 "Default metric\n")
6540
6541DEFUN (ospf_distance,
6542 ospf_distance_cmd,
6543 "distance <1-255>",
6544 "Define an administrative distance\n"
6545 "OSPF Administrative distance\n")
6546{
paul68980082003-03-25 05:07:42 +00006547 struct ospf *ospf = vty->index;
6548
6549 ospf->distance_all = atoi (argv[0]);
6550
paul718e3742002-12-13 20:15:29 +00006551 return CMD_SUCCESS;
6552}
6553
6554DEFUN (no_ospf_distance,
6555 no_ospf_distance_cmd,
6556 "no distance <1-255>",
6557 NO_STR
6558 "Define an administrative distance\n"
6559 "OSPF Administrative distance\n")
6560{
paul68980082003-03-25 05:07:42 +00006561 struct ospf *ospf = vty->index;
6562
6563 ospf->distance_all = 0;
6564
paul718e3742002-12-13 20:15:29 +00006565 return CMD_SUCCESS;
6566}
6567
6568DEFUN (no_ospf_distance_ospf,
6569 no_ospf_distance_ospf_cmd,
6570 "no distance ospf",
6571 NO_STR
6572 "Define an administrative distance\n"
6573 "OSPF Administrative distance\n"
6574 "OSPF Distance\n")
6575{
paul68980082003-03-25 05:07:42 +00006576 struct ospf *ospf = vty->index;
6577
6578 ospf->distance_intra = 0;
6579 ospf->distance_inter = 0;
6580 ospf->distance_external = 0;
6581
paul718e3742002-12-13 20:15:29 +00006582 return CMD_SUCCESS;
6583}
6584
6585DEFUN (ospf_distance_ospf_intra,
6586 ospf_distance_ospf_intra_cmd,
6587 "distance ospf intra-area <1-255>",
6588 "Define an administrative distance\n"
6589 "OSPF Administrative distance\n"
6590 "Intra-area routes\n"
6591 "Distance for intra-area routes\n")
6592{
paul68980082003-03-25 05:07:42 +00006593 struct ospf *ospf = vty->index;
6594
6595 ospf->distance_intra = atoi (argv[0]);
6596
paul718e3742002-12-13 20:15:29 +00006597 return CMD_SUCCESS;
6598}
6599
6600DEFUN (ospf_distance_ospf_intra_inter,
6601 ospf_distance_ospf_intra_inter_cmd,
6602 "distance ospf intra-area <1-255> inter-area <1-255>",
6603 "Define an administrative distance\n"
6604 "OSPF Administrative distance\n"
6605 "Intra-area routes\n"
6606 "Distance for intra-area routes\n"
6607 "Inter-area routes\n"
6608 "Distance for inter-area routes\n")
6609{
paul68980082003-03-25 05:07:42 +00006610 struct ospf *ospf = vty->index;
6611
6612 ospf->distance_intra = atoi (argv[0]);
6613 ospf->distance_inter = atoi (argv[1]);
6614
paul718e3742002-12-13 20:15:29 +00006615 return CMD_SUCCESS;
6616}
6617
6618DEFUN (ospf_distance_ospf_intra_external,
6619 ospf_distance_ospf_intra_external_cmd,
6620 "distance ospf intra-area <1-255> external <1-255>",
6621 "Define an administrative distance\n"
6622 "OSPF Administrative distance\n"
6623 "Intra-area routes\n"
6624 "Distance for intra-area routes\n"
6625 "External routes\n"
6626 "Distance for external routes\n")
6627{
paul68980082003-03-25 05:07:42 +00006628 struct ospf *ospf = vty->index;
6629
6630 ospf->distance_intra = atoi (argv[0]);
6631 ospf->distance_external = atoi (argv[1]);
6632
paul718e3742002-12-13 20:15:29 +00006633 return CMD_SUCCESS;
6634}
6635
6636DEFUN (ospf_distance_ospf_intra_inter_external,
6637 ospf_distance_ospf_intra_inter_external_cmd,
6638 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6639 "Define an administrative distance\n"
6640 "OSPF Administrative distance\n"
6641 "Intra-area routes\n"
6642 "Distance for intra-area routes\n"
6643 "Inter-area routes\n"
6644 "Distance for inter-area routes\n"
6645 "External routes\n"
6646 "Distance for external routes\n")
6647{
paul68980082003-03-25 05:07:42 +00006648 struct ospf *ospf = vty->index;
6649
6650 ospf->distance_intra = atoi (argv[0]);
6651 ospf->distance_inter = atoi (argv[1]);
6652 ospf->distance_external = atoi (argv[2]);
6653
paul718e3742002-12-13 20:15:29 +00006654 return CMD_SUCCESS;
6655}
6656
6657DEFUN (ospf_distance_ospf_intra_external_inter,
6658 ospf_distance_ospf_intra_external_inter_cmd,
6659 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6660 "Define an administrative distance\n"
6661 "OSPF Administrative distance\n"
6662 "Intra-area routes\n"
6663 "Distance for intra-area routes\n"
6664 "External routes\n"
6665 "Distance for external routes\n"
6666 "Inter-area routes\n"
6667 "Distance for inter-area routes\n")
6668{
paul68980082003-03-25 05:07:42 +00006669 struct ospf *ospf = vty->index;
6670
6671 ospf->distance_intra = atoi (argv[0]);
6672 ospf->distance_external = atoi (argv[1]);
6673 ospf->distance_inter = atoi (argv[2]);
6674
paul718e3742002-12-13 20:15:29 +00006675 return CMD_SUCCESS;
6676}
6677
6678DEFUN (ospf_distance_ospf_inter,
6679 ospf_distance_ospf_inter_cmd,
6680 "distance ospf inter-area <1-255>",
6681 "Define an administrative distance\n"
6682 "OSPF Administrative distance\n"
6683 "Inter-area routes\n"
6684 "Distance for inter-area routes\n")
6685{
paul68980082003-03-25 05:07:42 +00006686 struct ospf *ospf = vty->index;
6687
6688 ospf->distance_inter = atoi (argv[0]);
6689
paul718e3742002-12-13 20:15:29 +00006690 return CMD_SUCCESS;
6691}
6692
6693DEFUN (ospf_distance_ospf_inter_intra,
6694 ospf_distance_ospf_inter_intra_cmd,
6695 "distance ospf inter-area <1-255> intra-area <1-255>",
6696 "Define an administrative distance\n"
6697 "OSPF Administrative distance\n"
6698 "Inter-area routes\n"
6699 "Distance for inter-area routes\n"
6700 "Intra-area routes\n"
6701 "Distance for intra-area routes\n")
6702{
paul68980082003-03-25 05:07:42 +00006703 struct ospf *ospf = vty->index;
6704
6705 ospf->distance_inter = atoi (argv[0]);
6706 ospf->distance_intra = atoi (argv[1]);
6707
paul718e3742002-12-13 20:15:29 +00006708 return CMD_SUCCESS;
6709}
6710
6711DEFUN (ospf_distance_ospf_inter_external,
6712 ospf_distance_ospf_inter_external_cmd,
6713 "distance ospf inter-area <1-255> external <1-255>",
6714 "Define an administrative distance\n"
6715 "OSPF Administrative distance\n"
6716 "Inter-area routes\n"
6717 "Distance for inter-area routes\n"
6718 "External routes\n"
6719 "Distance for external routes\n")
6720{
paul68980082003-03-25 05:07:42 +00006721 struct ospf *ospf = vty->index;
6722
6723 ospf->distance_inter = atoi (argv[0]);
6724 ospf->distance_external = atoi (argv[1]);
6725
paul718e3742002-12-13 20:15:29 +00006726 return CMD_SUCCESS;
6727}
6728
6729DEFUN (ospf_distance_ospf_inter_intra_external,
6730 ospf_distance_ospf_inter_intra_external_cmd,
6731 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6732 "Define an administrative distance\n"
6733 "OSPF Administrative distance\n"
6734 "Inter-area routes\n"
6735 "Distance for inter-area routes\n"
6736 "Intra-area routes\n"
6737 "Distance for intra-area routes\n"
6738 "External routes\n"
6739 "Distance for external routes\n")
6740{
paul68980082003-03-25 05:07:42 +00006741 struct ospf *ospf = vty->index;
6742
6743 ospf->distance_inter = atoi (argv[0]);
6744 ospf->distance_intra = atoi (argv[1]);
6745 ospf->distance_external = atoi (argv[2]);
6746
paul718e3742002-12-13 20:15:29 +00006747 return CMD_SUCCESS;
6748}
6749
6750DEFUN (ospf_distance_ospf_inter_external_intra,
6751 ospf_distance_ospf_inter_external_intra_cmd,
6752 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6753 "Define an administrative distance\n"
6754 "OSPF Administrative distance\n"
6755 "Inter-area routes\n"
6756 "Distance for inter-area routes\n"
6757 "External routes\n"
6758 "Distance for external routes\n"
6759 "Intra-area routes\n"
6760 "Distance for intra-area routes\n")
6761{
paul68980082003-03-25 05:07:42 +00006762 struct ospf *ospf = vty->index;
6763
6764 ospf->distance_inter = atoi (argv[0]);
6765 ospf->distance_external = atoi (argv[1]);
6766 ospf->distance_intra = atoi (argv[2]);
6767
paul718e3742002-12-13 20:15:29 +00006768 return CMD_SUCCESS;
6769}
6770
6771DEFUN (ospf_distance_ospf_external,
6772 ospf_distance_ospf_external_cmd,
6773 "distance ospf external <1-255>",
6774 "Define an administrative distance\n"
6775 "OSPF Administrative distance\n"
6776 "External routes\n"
6777 "Distance for external routes\n")
6778{
paul68980082003-03-25 05:07:42 +00006779 struct ospf *ospf = vty->index;
6780
6781 ospf->distance_external = atoi (argv[0]);
6782
paul718e3742002-12-13 20:15:29 +00006783 return CMD_SUCCESS;
6784}
6785
6786DEFUN (ospf_distance_ospf_external_intra,
6787 ospf_distance_ospf_external_intra_cmd,
6788 "distance ospf external <1-255> intra-area <1-255>",
6789 "Define an administrative distance\n"
6790 "OSPF Administrative distance\n"
6791 "External routes\n"
6792 "Distance for external routes\n"
6793 "Intra-area routes\n"
6794 "Distance for intra-area routes\n")
6795{
paul68980082003-03-25 05:07:42 +00006796 struct ospf *ospf = vty->index;
6797
6798 ospf->distance_external = atoi (argv[0]);
6799 ospf->distance_intra = atoi (argv[1]);
6800
paul718e3742002-12-13 20:15:29 +00006801 return CMD_SUCCESS;
6802}
6803
6804DEFUN (ospf_distance_ospf_external_inter,
6805 ospf_distance_ospf_external_inter_cmd,
6806 "distance ospf external <1-255> inter-area <1-255>",
6807 "Define an administrative distance\n"
6808 "OSPF Administrative distance\n"
6809 "External routes\n"
6810 "Distance for external routes\n"
6811 "Inter-area routes\n"
6812 "Distance for inter-area routes\n")
6813{
paul68980082003-03-25 05:07:42 +00006814 struct ospf *ospf = vty->index;
6815
6816 ospf->distance_external = atoi (argv[0]);
6817 ospf->distance_inter = atoi (argv[1]);
6818
paul718e3742002-12-13 20:15:29 +00006819 return CMD_SUCCESS;
6820}
6821
6822DEFUN (ospf_distance_ospf_external_intra_inter,
6823 ospf_distance_ospf_external_intra_inter_cmd,
6824 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6825 "Define an administrative distance\n"
6826 "OSPF Administrative distance\n"
6827 "External routes\n"
6828 "Distance for external routes\n"
6829 "Intra-area routes\n"
6830 "Distance for intra-area routes\n"
6831 "Inter-area routes\n"
6832 "Distance for inter-area routes\n")
6833{
paul68980082003-03-25 05:07:42 +00006834 struct ospf *ospf = vty->index;
6835
6836 ospf->distance_external = atoi (argv[0]);
6837 ospf->distance_intra = atoi (argv[1]);
6838 ospf->distance_inter = atoi (argv[2]);
6839
paul718e3742002-12-13 20:15:29 +00006840 return CMD_SUCCESS;
6841}
6842
6843DEFUN (ospf_distance_ospf_external_inter_intra,
6844 ospf_distance_ospf_external_inter_intra_cmd,
6845 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6846 "Define an administrative distance\n"
6847 "OSPF Administrative distance\n"
6848 "External routes\n"
6849 "Distance for external routes\n"
6850 "Inter-area routes\n"
6851 "Distance for inter-area routes\n"
6852 "Intra-area routes\n"
6853 "Distance for intra-area routes\n")
6854{
paul68980082003-03-25 05:07:42 +00006855 struct ospf *ospf = vty->index;
6856
6857 ospf->distance_external = atoi (argv[0]);
6858 ospf->distance_inter = atoi (argv[1]);
6859 ospf->distance_intra = atoi (argv[2]);
6860
paul718e3742002-12-13 20:15:29 +00006861 return CMD_SUCCESS;
6862}
6863
6864DEFUN (ospf_distance_source,
6865 ospf_distance_source_cmd,
6866 "distance <1-255> A.B.C.D/M",
6867 "Administrative distance\n"
6868 "Distance value\n"
6869 "IP source prefix\n")
6870{
paul020709f2003-04-04 02:44:16 +00006871 struct ospf *ospf = vty->index;
6872
6873 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006874
paul718e3742002-12-13 20:15:29 +00006875 return CMD_SUCCESS;
6876}
6877
6878DEFUN (no_ospf_distance_source,
6879 no_ospf_distance_source_cmd,
6880 "no distance <1-255> A.B.C.D/M",
6881 NO_STR
6882 "Administrative distance\n"
6883 "Distance value\n"
6884 "IP source prefix\n")
6885{
paul020709f2003-04-04 02:44:16 +00006886 struct ospf *ospf = vty->index;
6887
6888 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6889
paul718e3742002-12-13 20:15:29 +00006890 return CMD_SUCCESS;
6891}
6892
6893DEFUN (ospf_distance_source_access_list,
6894 ospf_distance_source_access_list_cmd,
6895 "distance <1-255> A.B.C.D/M WORD",
6896 "Administrative distance\n"
6897 "Distance value\n"
6898 "IP source prefix\n"
6899 "Access list name\n")
6900{
paul020709f2003-04-04 02:44:16 +00006901 struct ospf *ospf = vty->index;
6902
6903 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6904
paul718e3742002-12-13 20:15:29 +00006905 return CMD_SUCCESS;
6906}
6907
6908DEFUN (no_ospf_distance_source_access_list,
6909 no_ospf_distance_source_access_list_cmd,
6910 "no distance <1-255> A.B.C.D/M WORD",
6911 NO_STR
6912 "Administrative distance\n"
6913 "Distance value\n"
6914 "IP source prefix\n"
6915 "Access list name\n")
6916{
paul020709f2003-04-04 02:44:16 +00006917 struct ospf *ospf = vty->index;
6918
6919 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6920
paul718e3742002-12-13 20:15:29 +00006921 return CMD_SUCCESS;
6922}
6923
vincentba682532005-09-29 13:52:57 +00006924DEFUN (ip_ospf_mtu_ignore,
6925 ip_ospf_mtu_ignore_addr_cmd,
6926 "ip ospf mtu-ignore A.B.C.D",
6927 "IP Information\n"
6928 "OSPF interface commands\n"
6929 "Disable mtu mismatch detection\n"
6930 "Address of interface")
6931{
6932 struct interface *ifp = vty->index;
6933 struct in_addr addr;
6934 int ret;
6935
6936 struct ospf_if_params *params;
6937 params = IF_DEF_PARAMS (ifp);
6938
6939 if (argc == 1)
6940 {
6941 ret = inet_aton(argv[0], &addr);
6942 if (!ret)
6943 {
6944 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6945 VTY_NEWLINE);
6946 return CMD_WARNING;
6947 }
6948 params = ospf_get_if_params (ifp, addr);
6949 ospf_if_update_params (ifp, addr);
6950 }
6951 params->mtu_ignore = 1;
6952 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6953 SET_IF_PARAM (params, mtu_ignore);
6954 else
6955 {
6956 UNSET_IF_PARAM (params, mtu_ignore);
6957 if (params != IF_DEF_PARAMS (ifp))
6958 {
6959 ospf_free_if_params (ifp, addr);
6960 ospf_if_update_params (ifp, addr);
6961 }
6962 }
6963 return CMD_SUCCESS;
6964}
6965
6966ALIAS (ip_ospf_mtu_ignore,
6967 ip_ospf_mtu_ignore_cmd,
6968 "ip ospf mtu-ignore",
6969 "IP Information\n"
6970 "OSPF interface commands\n"
6971 "Disable mtu mismatch detection\n")
6972
6973
6974DEFUN (no_ip_ospf_mtu_ignore,
6975 no_ip_ospf_mtu_ignore_addr_cmd,
6976 "no ip ospf mtu-ignore A.B.C.D",
6977 "IP Information\n"
6978 "OSPF interface commands\n"
6979 "Disable mtu mismatch detection\n"
6980 "Address of interface")
6981{
6982 struct interface *ifp = vty->index;
6983 struct in_addr addr;
6984 int ret;
6985
6986 struct ospf_if_params *params;
6987 params = IF_DEF_PARAMS (ifp);
6988
6989 if (argc == 1)
6990 {
6991 ret = inet_aton(argv[0], &addr);
6992 if (!ret)
6993 {
6994 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6995 VTY_NEWLINE);
6996 return CMD_WARNING;
6997 }
6998 params = ospf_get_if_params (ifp, addr);
6999 ospf_if_update_params (ifp, addr);
7000 }
7001 params->mtu_ignore = 0;
7002 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7003 SET_IF_PARAM (params, mtu_ignore);
7004 else
7005 {
7006 UNSET_IF_PARAM (params, mtu_ignore);
7007 if (params != IF_DEF_PARAMS (ifp))
7008 {
7009 ospf_free_if_params (ifp, addr);
7010 ospf_if_update_params (ifp, addr);
7011 }
7012 }
7013 return CMD_SUCCESS;
7014}
7015
7016ALIAS (no_ip_ospf_mtu_ignore,
7017 no_ip_ospf_mtu_ignore_cmd,
7018 "no ip ospf mtu-ignore",
7019 "IP Information\n"
7020 "OSPF interface commands\n"
7021 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00007022
7023DEFUN (ospf_max_metric_router_lsa_admin,
7024 ospf_max_metric_router_lsa_admin_cmd,
7025 "max-metric router-lsa administrative",
7026 "OSPF maximum / infinite-distance metric\n"
7027 "Advertise own Router-LSA with infinite distance (stub router)\n"
7028 "Administratively applied, for an indefinite period\n")
7029{
7030 struct listnode *ln;
7031 struct ospf_area *area;
7032 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00007033
paul88d6cf32005-10-29 12:50:09 +00007034 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7035 {
7036 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7037
7038 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
7039 ospf_router_lsa_timer_add (area);
7040 }
7041 return CMD_SUCCESS;
7042}
7043
7044DEFUN (no_ospf_max_metric_router_lsa_admin,
7045 no_ospf_max_metric_router_lsa_admin_cmd,
7046 "no max-metric router-lsa administrative",
7047 NO_STR
7048 "OSPF maximum / infinite-distance metric\n"
7049 "Advertise own Router-LSA with infinite distance (stub router)\n"
7050 "Administratively applied, for an indefinite period\n")
7051{
7052 struct listnode *ln;
7053 struct ospf_area *area;
7054 struct ospf *ospf = vty->index;
7055
7056 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7057 {
7058 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7059
7060 /* Don't trample on the start-up stub timer */
7061 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
7062 && !area->t_stub_router)
7063 {
7064 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
7065 ospf_router_lsa_timer_add (area);
7066 }
7067 }
7068 return CMD_SUCCESS;
7069}
7070
7071DEFUN (ospf_max_metric_router_lsa_startup,
7072 ospf_max_metric_router_lsa_startup_cmd,
7073 "max-metric router-lsa on-startup <5-86400>",
7074 "OSPF maximum / infinite-distance metric\n"
7075 "Advertise own Router-LSA with infinite distance (stub router)\n"
7076 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7077 "Time (seconds) to advertise self as stub-router\n")
7078{
7079 unsigned int seconds;
7080 struct ospf *ospf = vty->index;
7081
7082 if (argc != 1)
7083 {
7084 vty_out (vty, "%% Must supply stub-router period");
7085 return CMD_WARNING;
7086 }
7087
7088 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
7089
7090 ospf->stub_router_startup_time = seconds;
7091
7092 return CMD_SUCCESS;
7093}
7094
7095DEFUN (no_ospf_max_metric_router_lsa_startup,
7096 no_ospf_max_metric_router_lsa_startup_cmd,
7097 "no max-metric router-lsa on-startup",
7098 NO_STR
7099 "OSPF maximum / infinite-distance metric\n"
7100 "Advertise own Router-LSA with infinite distance (stub router)\n"
7101 "Automatically advertise stub Router-LSA on startup of OSPF\n")
7102{
7103 struct listnode *ln;
7104 struct ospf_area *area;
7105 struct ospf *ospf = vty->index;
7106
7107 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7108
7109 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7110 {
7111 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
7112 OSPF_TIMER_OFF (area->t_stub_router);
7113
7114 /* Don't trample on admin stub routed */
7115 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7116 {
7117 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
7118 ospf_router_lsa_timer_add (area);
7119 }
7120 }
7121 return CMD_SUCCESS;
7122}
7123
7124DEFUN (ospf_max_metric_router_lsa_shutdown,
7125 ospf_max_metric_router_lsa_shutdown_cmd,
7126 "max-metric router-lsa on-shutdown <5-86400>",
7127 "OSPF maximum / infinite-distance metric\n"
7128 "Advertise own Router-LSA with infinite distance (stub router)\n"
7129 "Advertise stub-router prior to full shutdown of OSPF\n"
7130 "Time (seconds) to wait till full shutdown\n")
7131{
7132 unsigned int seconds;
7133 struct ospf *ospf = vty->index;
7134
7135 if (argc != 1)
7136 {
7137 vty_out (vty, "%% Must supply stub-router shutdown period");
7138 return CMD_WARNING;
7139 }
7140
7141 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
7142
7143 ospf->stub_router_shutdown_time = seconds;
7144
7145 return CMD_SUCCESS;
7146}
7147
7148DEFUN (no_ospf_max_metric_router_lsa_shutdown,
7149 no_ospf_max_metric_router_lsa_shutdown_cmd,
7150 "no max-metric router-lsa on-shutdown",
7151 NO_STR
7152 "OSPF maximum / infinite-distance metric\n"
7153 "Advertise own Router-LSA with infinite distance (stub router)\n"
7154 "Advertise stub-router prior to full shutdown of OSPF\n")
7155{
7156 struct ospf *ospf = vty->index;
7157
7158 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7159
7160 return CMD_SUCCESS;
7161}
7162
7163static void
7164config_write_stub_router (struct vty *vty, struct ospf *ospf)
7165{
7166 struct listnode *ln;
7167 struct ospf_area *area;
7168
7169 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7170 vty_out (vty, " max-metric router-lsa on-startup %u%s",
7171 ospf->stub_router_startup_time, VTY_NEWLINE);
7172 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7173 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
7174 ospf->stub_router_shutdown_time, VTY_NEWLINE);
7175 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7176 {
7177 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7178 {
7179 vty_out (vty, " max-metric router-lsa administrative%s",
7180 VTY_NEWLINE);
7181 break;
7182 }
7183 }
7184 return;
7185}
7186
paul4dadc292005-05-06 21:37:42 +00007187static void
paul718e3742002-12-13 20:15:29 +00007188show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7189{
7190 struct route_node *rn;
7191 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007192 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007193 struct ospf_path *path;
7194
7195 vty_out (vty, "============ OSPF network routing table ============%s",
7196 VTY_NEWLINE);
7197
7198 for (rn = route_top (rt); rn; rn = route_next (rn))
7199 if ((or = rn->info) != NULL)
7200 {
7201 char buf1[19];
7202 snprintf (buf1, 19, "%s/%d",
7203 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7204
7205 switch (or->path_type)
7206 {
7207 case OSPF_PATH_INTER_AREA:
7208 if (or->type == OSPF_DESTINATION_NETWORK)
7209 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7210 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7211 else if (or->type == OSPF_DESTINATION_DISCARD)
7212 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7213 break;
7214 case OSPF_PATH_INTRA_AREA:
7215 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7216 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7217 break;
7218 default:
7219 break;
7220 }
7221
7222 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007223 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007224 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007225 if (if_lookup_by_index(path->ifindex))
paul96735ee2003-08-10 02:51:22 +00007226 {
7227 if (path->nexthop.s_addr == 0)
7228 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007229 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007230 else
7231 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007232 inet_ntoa (path->nexthop),
7233 ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007234 }
7235 }
paul718e3742002-12-13 20:15:29 +00007236 }
7237 vty_out (vty, "%s", VTY_NEWLINE);
7238}
7239
paul4dadc292005-05-06 21:37:42 +00007240static void
paul718e3742002-12-13 20:15:29 +00007241show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7242{
7243 struct route_node *rn;
7244 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007245 struct listnode *pnode;
7246 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007247 struct ospf_path *path;
7248
7249 vty_out (vty, "============ OSPF router routing table =============%s",
7250 VTY_NEWLINE);
7251 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7252 if (rn->info)
7253 {
7254 int flag = 0;
7255
7256 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7257
paul1eb8ef22005-04-07 07:30:20 +00007258 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7259 {
7260 if (flag++)
7261 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007262
paul1eb8ef22005-04-07 07:30:20 +00007263 /* Show path. */
7264 vty_out (vty, "%s [%d] area: %s",
7265 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7266 or->cost, inet_ntoa (or->u.std.area_id));
7267 /* Show flags. */
7268 vty_out (vty, "%s%s%s",
7269 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7270 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7271 VTY_NEWLINE);
7272
7273 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7274 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007275 if (if_lookup_by_index(path->ifindex))
hasso54bedb52005-08-17 13:31:47 +00007276 {
7277 if (path->nexthop.s_addr == 0)
7278 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007279 "", ifindex2ifname (path->ifindex),
7280 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007281 else
7282 vty_out (vty, "%24s via %s, %s%s", "",
7283 inet_ntoa (path->nexthop),
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007284 ifindex2ifname (path->ifindex),
7285 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007286 }
paul1eb8ef22005-04-07 07:30:20 +00007287 }
7288 }
paul718e3742002-12-13 20:15:29 +00007289 }
7290 vty_out (vty, "%s", VTY_NEWLINE);
7291}
7292
paul4dadc292005-05-06 21:37:42 +00007293static void
paul718e3742002-12-13 20:15:29 +00007294show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7295{
7296 struct route_node *rn;
7297 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007298 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007299 struct ospf_path *path;
7300
7301 vty_out (vty, "============ OSPF external routing table ===========%s",
7302 VTY_NEWLINE);
7303 for (rn = route_top (rt); rn; rn = route_next (rn))
7304 if ((er = rn->info) != NULL)
7305 {
7306 char buf1[19];
7307 snprintf (buf1, 19, "%s/%d",
7308 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7309
7310 switch (er->path_type)
7311 {
7312 case OSPF_PATH_TYPE1_EXTERNAL:
7313 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7314 er->cost, er->u.ext.tag, VTY_NEWLINE);
7315 break;
7316 case OSPF_PATH_TYPE2_EXTERNAL:
7317 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7318 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7319 break;
7320 }
7321
paul1eb8ef22005-04-07 07:30:20 +00007322 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007323 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007324 if (if_lookup_by_index(path->ifindex))
paul718e3742002-12-13 20:15:29 +00007325 {
7326 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007327 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007328 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007329 else
7330 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007331 inet_ntoa (path->nexthop),
7332 ifindex2ifname (path->ifindex),
paul96735ee2003-08-10 02:51:22 +00007333 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007334 }
7335 }
7336 }
7337 vty_out (vty, "%s", VTY_NEWLINE);
7338}
7339
paul718e3742002-12-13 20:15:29 +00007340DEFUN (show_ip_ospf_border_routers,
7341 show_ip_ospf_border_routers_cmd,
7342 "show ip ospf border-routers",
7343 SHOW_STR
7344 IP_STR
7345 "show all the ABR's and ASBR's\n"
7346 "for this area\n")
7347{
paul020709f2003-04-04 02:44:16 +00007348 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007349
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007350 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007351 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007352 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007353 return CMD_SUCCESS;
7354 }
7355
paul68980082003-03-25 05:07:42 +00007356 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007357 {
7358 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7359 return CMD_SUCCESS;
7360 }
7361
7362 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007363 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007364
7365 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007366 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007367
7368 return CMD_SUCCESS;
7369}
paul718e3742002-12-13 20:15:29 +00007370
7371DEFUN (show_ip_ospf_route,
7372 show_ip_ospf_route_cmd,
7373 "show ip ospf route",
7374 SHOW_STR
7375 IP_STR
7376 "OSPF information\n"
7377 "OSPF routing table\n")
7378{
paul020709f2003-04-04 02:44:16 +00007379 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007380
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007381 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007382 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007383 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007384 return CMD_SUCCESS;
7385 }
7386
paul68980082003-03-25 05:07:42 +00007387 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007388 {
7389 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7390 return CMD_SUCCESS;
7391 }
7392
7393 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007394 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007395
7396 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007397 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007398
7399 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007400 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007401
7402 return CMD_SUCCESS;
7403}
7404
7405
hassoeb1ce602004-10-08 08:17:22 +00007406const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007407{
7408 "unknown",
7409 "standard",
7410 "ibm",
7411 "cisco",
7412 "shortcut"
7413};
7414
hassoeb1ce602004-10-08 08:17:22 +00007415const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007416{
7417 "default",
7418 "enable",
7419 "disable"
7420};
7421
7422
paul4dadc292005-05-06 21:37:42 +00007423static void
paul718e3742002-12-13 20:15:29 +00007424area_id2str (char *buf, int length, struct ospf_area *area)
7425{
7426 memset (buf, 0, length);
7427
7428 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7429 strncpy (buf, inet_ntoa (area->area_id), length);
7430 else
7431 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7432}
7433
7434
hassoeb1ce602004-10-08 08:17:22 +00007435const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007436{
7437 "unknown", /* should never be used. */
7438 "point-to-point",
7439 "broadcast",
7440 "non-broadcast",
7441 "point-to-multipoint",
7442 "virtual-link", /* should never be used. */
7443 "loopback"
7444};
7445
7446/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007447static int
paul718e3742002-12-13 20:15:29 +00007448config_write_interface (struct vty *vty)
7449{
hasso52dc7ee2004-09-23 19:18:23 +00007450 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007451 struct interface *ifp;
7452 struct crypt_key *ck;
7453 int write = 0;
7454 struct route_node *rn = NULL;
7455 struct ospf_if_params *params;
7456
paul1eb8ef22005-04-07 07:30:20 +00007457 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007458 {
paul718e3742002-12-13 20:15:29 +00007459 if (memcmp (ifp->name, "VLINK", 5) == 0)
7460 continue;
7461
7462 vty_out (vty, "!%s", VTY_NEWLINE);
7463 vty_out (vty, "interface %s%s", ifp->name,
7464 VTY_NEWLINE);
7465 if (ifp->desc)
7466 vty_out (vty, " description %s%s", ifp->desc,
7467 VTY_NEWLINE);
7468
7469 write++;
7470
7471 params = IF_DEF_PARAMS (ifp);
7472
7473 do {
7474 /* Interface Network print. */
7475 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007476 params->type != OSPF_IFTYPE_LOOPBACK)
7477 {
ajsbc18d612004-12-15 15:07:19 +00007478 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007479 {
7480 vty_out (vty, " ip ospf network %s",
7481 ospf_int_type_str[params->type]);
7482 if (params != IF_DEF_PARAMS (ifp))
7483 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7484 vty_out (vty, "%s", VTY_NEWLINE);
7485 }
paul718e3742002-12-13 20:15:29 +00007486 }
7487
7488 /* OSPF interface authentication print */
7489 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7490 params->auth_type != OSPF_AUTH_NOTSET)
7491 {
hassoeb1ce602004-10-08 08:17:22 +00007492 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007493
7494 /* Translation tables are not that much help here due to syntax
7495 of the simple option */
7496 switch (params->auth_type)
7497 {
7498
7499 case OSPF_AUTH_NULL:
7500 auth_str = " null";
7501 break;
7502
7503 case OSPF_AUTH_SIMPLE:
7504 auth_str = "";
7505 break;
7506
7507 case OSPF_AUTH_CRYPTOGRAPHIC:
7508 auth_str = " message-digest";
7509 break;
7510
7511 default:
7512 auth_str = "";
7513 break;
7514 }
7515
7516 vty_out (vty, " ip ospf authentication%s", auth_str);
7517 if (params != IF_DEF_PARAMS (ifp))
7518 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7519 vty_out (vty, "%s", VTY_NEWLINE);
7520 }
7521
7522 /* Simple Authentication Password print. */
7523 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7524 params->auth_simple[0] != '\0')
7525 {
7526 vty_out (vty, " ip ospf authentication-key %s",
7527 params->auth_simple);
7528 if (params != IF_DEF_PARAMS (ifp))
7529 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7530 vty_out (vty, "%s", VTY_NEWLINE);
7531 }
7532
7533 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007534 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007535 {
paul718e3742002-12-13 20:15:29 +00007536 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7537 ck->key_id, ck->auth_key);
7538 if (params != IF_DEF_PARAMS (ifp))
7539 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7540 vty_out (vty, "%s", VTY_NEWLINE);
7541 }
7542
7543 /* Interface Output Cost print. */
7544 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7545 {
7546 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7547 if (params != IF_DEF_PARAMS (ifp))
7548 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7549 vty_out (vty, "%s", VTY_NEWLINE);
7550 }
7551
7552 /* Hello Interval print. */
7553 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7554 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7555 {
7556 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7557 if (params != IF_DEF_PARAMS (ifp))
7558 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7559 vty_out (vty, "%s", VTY_NEWLINE);
7560 }
7561
7562
7563 /* Router Dead Interval print. */
7564 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7565 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7566 {
paulf9ad9372005-10-21 00:45:17 +00007567 vty_out (vty, " ip ospf dead-interval ");
7568
7569 /* fast hello ? */
7570 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7571 vty_out (vty, "minimal hello-multiplier %d",
7572 params->fast_hello);
7573 else
7574 vty_out (vty, "%u", params->v_wait);
7575
paul718e3742002-12-13 20:15:29 +00007576 if (params != IF_DEF_PARAMS (ifp))
7577 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7578 vty_out (vty, "%s", VTY_NEWLINE);
7579 }
7580
7581 /* Router Priority print. */
7582 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7583 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7584 {
7585 vty_out (vty, " ip ospf priority %u", params->priority);
7586 if (params != IF_DEF_PARAMS (ifp))
7587 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7588 vty_out (vty, "%s", VTY_NEWLINE);
7589 }
7590
7591 /* Retransmit Interval print. */
7592 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7593 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7594 {
7595 vty_out (vty, " ip ospf retransmit-interval %u",
7596 params->retransmit_interval);
7597 if (params != IF_DEF_PARAMS (ifp))
7598 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7599 vty_out (vty, "%s", VTY_NEWLINE);
7600 }
7601
7602 /* Transmit Delay print. */
7603 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7604 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7605 {
7606 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7607 if (params != IF_DEF_PARAMS (ifp))
7608 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7609 vty_out (vty, "%s", VTY_NEWLINE);
7610 }
7611
vincentba682532005-09-29 13:52:57 +00007612 /* MTU ignore print. */
7613 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7614 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7615 {
7616 if (params->mtu_ignore == 0)
7617 vty_out (vty, " no ip ospf mtu-ignore");
7618 else
7619 vty_out (vty, " ip ospf mtu-ignore");
7620 if (params != IF_DEF_PARAMS (ifp))
7621 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7622 vty_out (vty, "%s", VTY_NEWLINE);
7623 }
7624
7625
paul718e3742002-12-13 20:15:29 +00007626 while (1)
7627 {
7628 if (rn == NULL)
7629 rn = route_top (IF_OIFS_PARAMS (ifp));
7630 else
7631 rn = route_next (rn);
7632
7633 if (rn == NULL)
7634 break;
7635 params = rn->info;
7636 if (params != NULL)
7637 break;
7638 }
7639 } while (rn);
7640
7641#ifdef HAVE_OPAQUE_LSA
7642 ospf_opaque_config_write_if (vty, ifp);
7643#endif /* HAVE_OPAQUE_LSA */
7644 }
7645
7646 return write;
7647}
7648
paul4dadc292005-05-06 21:37:42 +00007649static int
paul68980082003-03-25 05:07:42 +00007650config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007651{
7652 struct route_node *rn;
7653 u_char buf[INET_ADDRSTRLEN];
7654
7655 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007656 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007657 if (rn->info)
7658 {
7659 struct ospf_network *n = rn->info;
7660
7661 memset (buf, 0, INET_ADDRSTRLEN);
7662
7663 /* Create Area ID string by specified Area ID format. */
7664 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007665 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007666 else
hassoc9e52be2004-09-26 16:09:34 +00007667 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007668 (unsigned long int) ntohl (n->area_id.s_addr));
7669
7670 /* Network print. */
7671 vty_out (vty, " network %s/%d area %s%s",
7672 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7673 buf, VTY_NEWLINE);
7674 }
7675
7676 return 0;
7677}
7678
paul4dadc292005-05-06 21:37:42 +00007679static int
paul68980082003-03-25 05:07:42 +00007680config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007681{
hasso52dc7ee2004-09-23 19:18:23 +00007682 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007683 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007684 u_char buf[INET_ADDRSTRLEN];
7685
7686 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007687 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007688 {
paul718e3742002-12-13 20:15:29 +00007689 struct route_node *rn1;
7690
hassoc9e52be2004-09-26 16:09:34 +00007691 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007692
7693 if (area->auth_type != OSPF_AUTH_NULL)
7694 {
7695 if (area->auth_type == OSPF_AUTH_SIMPLE)
7696 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7697 else
7698 vty_out (vty, " area %s authentication message-digest%s",
7699 buf, VTY_NEWLINE);
7700 }
7701
7702 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7703 vty_out (vty, " area %s shortcut %s%s", buf,
7704 ospf_shortcut_mode_str[area->shortcut_configured],
7705 VTY_NEWLINE);
7706
7707 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007708 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007709 )
7710 {
paulb0a053b2003-06-22 09:04:47 +00007711 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007712 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007713 else if (area->external_routing == OSPF_AREA_NSSA)
7714 {
7715 vty_out (vty, " area %s nssa", buf);
7716 switch (area->NSSATranslatorRole)
7717 {
7718 case OSPF_NSSA_ROLE_NEVER:
7719 vty_out (vty, " translate-never");
7720 break;
7721 case OSPF_NSSA_ROLE_ALWAYS:
7722 vty_out (vty, " translate-always");
7723 break;
7724 case OSPF_NSSA_ROLE_CANDIDATE:
7725 default:
7726 vty_out (vty, " translate-candidate");
7727 }
7728 }
paul718e3742002-12-13 20:15:29 +00007729
7730 if (area->no_summary)
7731 vty_out (vty, " no-summary");
7732
7733 vty_out (vty, "%s", VTY_NEWLINE);
7734
7735 if (area->default_cost != 1)
7736 vty_out (vty, " area %s default-cost %d%s", buf,
7737 area->default_cost, VTY_NEWLINE);
7738 }
7739
7740 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7741 if (rn1->info)
7742 {
7743 struct ospf_area_range *range = rn1->info;
7744
7745 vty_out (vty, " area %s range %s/%d", buf,
7746 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7747
paul6c835672004-10-11 11:00:30 +00007748 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007749 vty_out (vty, " cost %d", range->cost_config);
7750
7751 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7752 vty_out (vty, " not-advertise");
7753
7754 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7755 vty_out (vty, " substitute %s/%d",
7756 inet_ntoa (range->subst_addr), range->subst_masklen);
7757
7758 vty_out (vty, "%s", VTY_NEWLINE);
7759 }
7760
7761 if (EXPORT_NAME (area))
7762 vty_out (vty, " area %s export-list %s%s", buf,
7763 EXPORT_NAME (area), VTY_NEWLINE);
7764
7765 if (IMPORT_NAME (area))
7766 vty_out (vty, " area %s import-list %s%s", buf,
7767 IMPORT_NAME (area), VTY_NEWLINE);
7768
7769 if (PREFIX_NAME_IN (area))
7770 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7771 PREFIX_NAME_IN (area), VTY_NEWLINE);
7772
7773 if (PREFIX_NAME_OUT (area))
7774 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7775 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7776 }
7777
7778 return 0;
7779}
7780
paul4dadc292005-05-06 21:37:42 +00007781static int
paul68980082003-03-25 05:07:42 +00007782config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007783{
7784 struct ospf_nbr_nbma *nbr_nbma;
7785 struct route_node *rn;
7786
7787 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007788 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007789 if ((nbr_nbma = rn->info))
7790 {
7791 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7792
7793 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7794 vty_out (vty, " priority %d", nbr_nbma->priority);
7795
7796 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7797 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7798
7799 vty_out (vty, "%s", VTY_NEWLINE);
7800 }
7801
7802 return 0;
7803}
7804
paul4dadc292005-05-06 21:37:42 +00007805static int
paul68980082003-03-25 05:07:42 +00007806config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007807{
hasso52dc7ee2004-09-23 19:18:23 +00007808 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007809 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007810 u_char buf[INET_ADDRSTRLEN];
7811
7812 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007813 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007814 {
hasso52dc7ee2004-09-23 19:18:23 +00007815 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007816 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007817 struct ospf_interface *oi;
7818
7819 if (vl_data != NULL)
7820 {
7821 memset (buf, 0, INET_ADDRSTRLEN);
7822
7823 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007824 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007825 else
hassoc9e52be2004-09-26 16:09:34 +00007826 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007827 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7828 oi = vl_data->vl_oi;
7829
7830 /* timers */
7831 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7832 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7833 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7834 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7835 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7836 buf,
7837 inet_ntoa (vl_data->vl_peer),
7838 OSPF_IF_PARAM (oi, v_hello),
7839 OSPF_IF_PARAM (oi, retransmit_interval),
7840 OSPF_IF_PARAM (oi, transmit_delay),
7841 OSPF_IF_PARAM (oi, v_wait),
7842 VTY_NEWLINE);
7843 else
7844 vty_out (vty, " area %s virtual-link %s%s", buf,
7845 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7846 /* Auth key */
7847 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7848 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7849 buf,
7850 inet_ntoa (vl_data->vl_peer),
7851 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7852 VTY_NEWLINE);
7853 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007854 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7855 n2, ck))
7856 vty_out (vty, " area %s virtual-link %s"
7857 " message-digest-key %d md5 %s%s",
7858 buf,
7859 inet_ntoa (vl_data->vl_peer),
7860 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007861
7862 }
7863 }
7864
7865 return 0;
7866}
7867
7868
paul4dadc292005-05-06 21:37:42 +00007869static int
paul68980082003-03-25 05:07:42 +00007870config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007871{
7872 int type;
7873
7874 /* redistribute print. */
7875 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7876 if (type != zclient->redist_default && zclient->redist[type])
7877 {
ajsf52d13c2005-10-01 17:38:06 +00007878 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007879 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007880 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007881
paul68980082003-03-25 05:07:42 +00007882 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007883 vty_out (vty, " metric-type 1");
7884
paul020709f2003-04-04 02:44:16 +00007885 if (ROUTEMAP_NAME (ospf, type))
7886 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007887
7888 vty_out (vty, "%s", VTY_NEWLINE);
7889 }
7890
7891 return 0;
7892}
7893
paul4dadc292005-05-06 21:37:42 +00007894static int
paul68980082003-03-25 05:07:42 +00007895config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007896{
paul68980082003-03-25 05:07:42 +00007897 if (ospf->default_metric != -1)
7898 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007899 VTY_NEWLINE);
7900 return 0;
7901}
7902
paul4dadc292005-05-06 21:37:42 +00007903static int
paul68980082003-03-25 05:07:42 +00007904config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007905{
7906 int type;
7907
paul68980082003-03-25 05:07:42 +00007908 if (ospf)
paul718e3742002-12-13 20:15:29 +00007909 {
7910 /* distribute-list print. */
7911 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007912 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007913 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007914 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007915 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007916
7917 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007918 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007919 {
paulc42c1772006-01-10 20:36:49 +00007920 vty_out (vty, " default-information originate");
7921 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7922 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007923
paul68980082003-03-25 05:07:42 +00007924 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007925 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007926 ospf->dmetric[DEFAULT_ROUTE].value);
7927 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007928 vty_out (vty, " metric-type 1");
7929
paul020709f2003-04-04 02:44:16 +00007930 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7931 vty_out (vty, " route-map %s",
7932 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007933
7934 vty_out (vty, "%s", VTY_NEWLINE);
7935 }
7936
7937 }
7938
7939 return 0;
7940}
7941
paul4dadc292005-05-06 21:37:42 +00007942static int
paul68980082003-03-25 05:07:42 +00007943config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007944{
7945 struct route_node *rn;
7946 struct ospf_distance *odistance;
7947
paul68980082003-03-25 05:07:42 +00007948 if (ospf->distance_all)
7949 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007950
paul68980082003-03-25 05:07:42 +00007951 if (ospf->distance_intra
7952 || ospf->distance_inter
7953 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007954 {
7955 vty_out (vty, " distance ospf");
7956
paul68980082003-03-25 05:07:42 +00007957 if (ospf->distance_intra)
7958 vty_out (vty, " intra-area %d", ospf->distance_intra);
7959 if (ospf->distance_inter)
7960 vty_out (vty, " inter-area %d", ospf->distance_inter);
7961 if (ospf->distance_external)
7962 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007963
7964 vty_out (vty, "%s", VTY_NEWLINE);
7965 }
7966
paul68980082003-03-25 05:07:42 +00007967 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007968 if ((odistance = rn->info) != NULL)
7969 {
7970 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7971 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7972 odistance->access_list ? odistance->access_list : "",
7973 VTY_NEWLINE);
7974 }
7975 return 0;
7976}
7977
7978/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007979static int
paul718e3742002-12-13 20:15:29 +00007980ospf_config_write (struct vty *vty)
7981{
paul020709f2003-04-04 02:44:16 +00007982 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007983 struct interface *ifp;
7984 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007985 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007986 int write = 0;
7987
paul020709f2003-04-04 02:44:16 +00007988 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007989 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007990 {
7991 /* `router ospf' print. */
7992 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7993
7994 write++;
7995
paul68980082003-03-25 05:07:42 +00007996 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007997 return write;
7998
7999 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00008000 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00008001 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00008002 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008003
8004 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00008005 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00008006 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00008007 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008008
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008009 /* log-adjacency-changes flag print. */
8010 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
8011 {
8012 vty_out(vty, " log-adjacency-changes");
8013 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
8014 vty_out(vty, " detail");
8015 vty_out(vty, "%s", VTY_NEWLINE);
8016 }
8017
paul718e3742002-12-13 20:15:29 +00008018 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00008019 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00008020 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
8021
8022 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00008023 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00008024 {
8025 vty_out (vty, "! Important: ensure reference bandwidth "
8026 "is consistent across all routers%s", VTY_NEWLINE);
8027 vty_out (vty, " auto-cost reference-bandwidth %d%s",
8028 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
8029 }
paul718e3742002-12-13 20:15:29 +00008030
8031 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00008032 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00008033 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
8034 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
8035 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00008036 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00008037 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00008038
8039 /* Max-metric router-lsa print */
8040 config_write_stub_router (vty, ospf);
8041
paul718e3742002-12-13 20:15:29 +00008042 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00008043 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00008044 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00008045 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008046
8047 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00008048 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008049
8050 /* passive-interface print. */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008051 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
8052 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
8053
paul1eb8ef22005-04-07 07:30:20 +00008054 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008055 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
8056 && IF_DEF_PARAMS (ifp)->passive_interface !=
8057 ospf->passive_interface_default)
8058 {
8059 vty_out (vty, " %spassive-interface %s%s",
8060 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
8061 ifp->name, VTY_NEWLINE);
8062 }
paul1eb8ef22005-04-07 07:30:20 +00008063 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008064 {
8065 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
8066 continue;
8067 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
8068 passive_interface))
8069 {
8070 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
8071 continue;
8072 }
8073 else if (oi->params->passive_interface == ospf->passive_interface_default)
8074 continue;
8075
8076 vty_out (vty, " %spassive-interface %s %s%s",
8077 oi->params->passive_interface ? "" : "no ",
paul1eb8ef22005-04-07 07:30:20 +00008078 oi->ifp->name,
8079 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008080 }
paul718e3742002-12-13 20:15:29 +00008081
8082 /* Network area print. */
paul68980082003-03-25 05:07:42 +00008083 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008084
8085 /* Area config print. */
paul68980082003-03-25 05:07:42 +00008086 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008087
8088 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00008089 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008090
8091 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00008092 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008093
8094 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00008095 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008096
8097 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00008098 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008099
8100 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00008101 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008102
8103#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00008104 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008105#endif /* HAVE_OPAQUE_LSA */
8106 }
8107
8108 return write;
8109}
8110
8111void
paul4dadc292005-05-06 21:37:42 +00008112ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00008113{
8114 /* "show ip ospf" commands. */
8115 install_element (VIEW_NODE, &show_ip_ospf_cmd);
8116 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
8117
8118 /* "show ip ospf database" commands. */
8119 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
8120 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
8121 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8122 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8123 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
8124 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
8125 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
8126 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
8127 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
8128 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8129 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8130 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
8131 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
8132 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
8133
8134 /* "show ip ospf interface" commands. */
8135 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
8136 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
8137
8138 /* "show ip ospf neighbor" commands. */
8139 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8140 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
8141 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
8142 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8143 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
8144 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
8145 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
8146 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8147 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
8148 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
8149 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8150 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
8151 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
8152 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
8153
8154 /* "show ip ospf route" commands. */
8155 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
8156 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00008157 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
8158 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00008159}
8160
8161
8162/* ospfd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008163static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00008164{
8165 INTERFACE_NODE,
8166 "%s(config-if)# ",
8167 1
8168};
8169
8170/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00008171static void
8172ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00008173{
8174 /* Install interface node. */
8175 install_node (&interface_node, config_write_interface);
8176
8177 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00008178 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008179 install_default (INTERFACE_NODE);
8180
8181 /* "description" commands. */
8182 install_element (INTERFACE_NODE, &interface_desc_cmd);
8183 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
8184
8185 /* "ip ospf authentication" commands. */
8186 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
8187 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
8188 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
8189 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
8190 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
8191 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
8192 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
8193 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
8194 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
8195 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
8196
8197 /* "ip ospf message-digest-key" commands. */
8198 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
8199 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
8200 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8201 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8202
8203 /* "ip ospf cost" commands. */
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008204 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
8205 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008206 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
8207 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008208 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008209 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8210
vincentba682532005-09-29 13:52:57 +00008211 /* "ip ospf mtu-ignore" commands. */
8212 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8213 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8214 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8215 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8216
paul718e3742002-12-13 20:15:29 +00008217 /* "ip ospf dead-interval" commands. */
8218 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8219 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008220 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8221 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00008222 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8223 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008224
paul718e3742002-12-13 20:15:29 +00008225 /* "ip ospf hello-interval" commands. */
8226 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8227 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8228 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8229 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8230
8231 /* "ip ospf network" commands. */
8232 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8233 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8234
8235 /* "ip ospf priority" commands. */
8236 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8237 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8238 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8239 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8240
8241 /* "ip ospf retransmit-interval" commands. */
8242 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8243 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8244 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8245 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8246
8247 /* "ip ospf transmit-delay" commands. */
8248 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8249 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8250 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8251 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8252
8253 /* These commands are compatibitliy for previous version. */
8254 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8255 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8256 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8257 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008258 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
8259 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008260 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008261 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
8262 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008263 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008264 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8265 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8266 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8267 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8268 install_element (INTERFACE_NODE, &ospf_network_cmd);
8269 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8270 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8271 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8272 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8273 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8274 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8275 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8276}
8277
paul4dadc292005-05-06 21:37:42 +00008278static void
8279ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008280{
8281 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8282 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8283 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8284 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8285 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8286 install_element (OSPF_NODE,
8287 &ospf_redistribute_source_metric_type_routemap_cmd);
8288 install_element (OSPF_NODE,
8289 &ospf_redistribute_source_type_metric_routemap_cmd);
8290 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8291 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8292 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8293
8294 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8295
8296 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8297 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8298
8299 install_element (OSPF_NODE,
8300 &ospf_default_information_originate_metric_type_cmd);
8301 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8302 install_element (OSPF_NODE,
8303 &ospf_default_information_originate_type_metric_cmd);
8304 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8305 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8306 install_element (OSPF_NODE,
8307 &ospf_default_information_originate_always_metric_type_cmd);
8308 install_element (OSPF_NODE,
8309 &ospf_default_information_originate_always_metric_cmd);
8310 install_element (OSPF_NODE,
8311 &ospf_default_information_originate_always_cmd);
8312 install_element (OSPF_NODE,
8313 &ospf_default_information_originate_always_type_metric_cmd);
8314 install_element (OSPF_NODE,
8315 &ospf_default_information_originate_always_type_cmd);
8316
8317 install_element (OSPF_NODE,
8318 &ospf_default_information_originate_metric_type_routemap_cmd);
8319 install_element (OSPF_NODE,
8320 &ospf_default_information_originate_metric_routemap_cmd);
8321 install_element (OSPF_NODE,
8322 &ospf_default_information_originate_routemap_cmd);
8323 install_element (OSPF_NODE,
8324 &ospf_default_information_originate_type_metric_routemap_cmd);
8325 install_element (OSPF_NODE,
8326 &ospf_default_information_originate_type_routemap_cmd);
8327 install_element (OSPF_NODE,
8328 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8329 install_element (OSPF_NODE,
8330 &ospf_default_information_originate_always_metric_routemap_cmd);
8331 install_element (OSPF_NODE,
8332 &ospf_default_information_originate_always_routemap_cmd);
8333 install_element (OSPF_NODE,
8334 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8335 install_element (OSPF_NODE,
8336 &ospf_default_information_originate_always_type_routemap_cmd);
8337
8338 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8339
8340 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8341 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8342 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8343
8344 install_element (OSPF_NODE, &ospf_distance_cmd);
8345 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8346 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8347 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8348 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8349 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8350 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8351 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8352 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8353 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8354 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8355 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8356 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8357 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8358 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8359 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8360 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8361 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8362#if 0
8363 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8364 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8365 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8366 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8367#endif /* 0 */
8368}
8369
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008370static struct cmd_node ospf_node =
paul718e3742002-12-13 20:15:29 +00008371{
8372 OSPF_NODE,
8373 "%s(config-router)# ",
8374 1
8375};
8376
8377
8378/* Install OSPF related vty commands. */
8379void
paul4dadc292005-05-06 21:37:42 +00008380ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008381{
8382 /* Install ospf top node. */
8383 install_node (&ospf_node, ospf_config_write);
8384
8385 /* "router ospf" commands. */
8386 install_element (CONFIG_NODE, &router_ospf_cmd);
8387 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8388
8389 install_default (OSPF_NODE);
8390
8391 /* "ospf router-id" commands. */
8392 install_element (OSPF_NODE, &ospf_router_id_cmd);
8393 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008394 install_element (OSPF_NODE, &router_ospf_id_cmd);
8395 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008396
8397 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008398 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8399 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008400 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
paula2c62832003-04-23 17:01:31 +00008401 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8402 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008403 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
paul718e3742002-12-13 20:15:29 +00008404
8405 /* "ospf abr-type" commands. */
8406 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8407 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8408
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008409 /* "ospf log-adjacency-changes" commands. */
8410 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8411 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8412 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8413 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8414
paul718e3742002-12-13 20:15:29 +00008415 /* "ospf rfc1583-compatible" commands. */
8416 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8417 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8418 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8419 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8420
8421 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008422 install_element (OSPF_NODE, &ospf_network_area_cmd);
8423 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008424
8425 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008426 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8427 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8428 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008429
8430 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008431 install_element (OSPF_NODE, &ospf_area_range_cmd);
8432 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8433 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8434 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8435 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8436 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8437 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8438 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8439 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8440 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8441 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008442
8443 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008444 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8445 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008446
paula2c62832003-04-23 17:01:31 +00008447 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8448 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008449
paula2c62832003-04-23 17:01:31 +00008450 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8451 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008452
paula2c62832003-04-23 17:01:31 +00008453 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8454 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008455
paula2c62832003-04-23 17:01:31 +00008456 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8457 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008458
paula2c62832003-04-23 17:01:31 +00008459 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8460 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8461 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008462
paula2c62832003-04-23 17:01:31 +00008463 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8464 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008465
paula2c62832003-04-23 17:01:31 +00008466 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8467 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008468
paula2c62832003-04-23 17:01:31 +00008469 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8470 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8471 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008472
paula2c62832003-04-23 17:01:31 +00008473 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8474 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8475 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008476
8477 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008478 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8479 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8480 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8481 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008482
paul718e3742002-12-13 20:15:29 +00008483 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008484 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8485 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8486 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8487 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8488 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8489 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008490
paula2c62832003-04-23 17:01:31 +00008491 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8492 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008493
paula2c62832003-04-23 17:01:31 +00008494 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8495 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008496
paula2c62832003-04-23 17:01:31 +00008497 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8498 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008499
paula2c62832003-04-23 17:01:31 +00008500 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8501 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008502
paula2c62832003-04-23 17:01:31 +00008503 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8504 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008505
8506 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008507 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8508 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008509 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8510 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8511
paul88d6cf32005-10-29 12:50:09 +00008512 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008513 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8514 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8515 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008516
paul88d6cf32005-10-29 12:50:09 +00008517 /* max-metric commands */
8518 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8519 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8520 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8521 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8522 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8523 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8524
8525 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008526 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8527 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008528
8529 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008530 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8531 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8532 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8533 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8534 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8535 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8536 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8537 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008538
8539 /* Init interface related vty commands. */
8540 ospf_vty_if_init ();
8541
8542 /* Init zebra related vty commands. */
8543 ospf_vty_zebra_init ();
8544}