blob: f68adb2d1dc49b6cc03fafe8af4f4f5fa348621d [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 {
Ulrich Weber830526a2011-12-21 02:24:11 +040083 if (*str == '-')
84 return -1;
85 errno = 0;
paul718e3742002-12-13 20:15:29 +000086 ret = strtoul (str, &endptr, 10);
Ulrich Weber830526a2011-12-21 02:24:11 +040087 if (*endptr != '\0' || errno || ret > UINT32_MAX)
paul718e3742002-12-13 20:15:29 +000088 return -1;
89
90 area_id->s_addr = htonl (ret);
91 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
92 }
93
94 return 0;
95}
96
97
paul4dadc292005-05-06 21:37:42 +000098static int
paul6c835672004-10-11 11:00:30 +000099str2metric (const char *str, int *metric)
paul718e3742002-12-13 20:15:29 +0000100{
101 /* Sanity check. */
102 if (str == NULL)
103 return 0;
104
105 *metric = strtol (str, NULL, 10);
106 if (*metric < 0 && *metric > 16777214)
107 {
108 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
109 return 0;
110 }
111
112 return 1;
113}
114
paul4dadc292005-05-06 21:37:42 +0000115static int
paul6c835672004-10-11 11:00:30 +0000116str2metric_type (const char *str, int *metric_type)
paul718e3742002-12-13 20:15:29 +0000117{
118 /* Sanity check. */
119 if (str == NULL)
120 return 0;
121
122 if (strncmp (str, "1", 1) == 0)
123 *metric_type = EXTERNAL_METRIC_TYPE_1;
124 else if (strncmp (str, "2", 1) == 0)
125 *metric_type = EXTERNAL_METRIC_TYPE_2;
126 else
127 return 0;
128
129 return 1;
130}
131
132int
133ospf_oi_count (struct interface *ifp)
134{
135 struct route_node *rn;
136 int i = 0;
137
138 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
139 if (rn->info)
140 i++;
141
142 return i;
143}
144
145
146DEFUN (router_ospf,
147 router_ospf_cmd,
148 "router ospf",
149 "Enable a routing process\n"
150 "Start OSPF configuration\n")
151{
152 vty->node = OSPF_NODE;
153 vty->index = ospf_get ();
154
155 return CMD_SUCCESS;
156}
157
158DEFUN (no_router_ospf,
159 no_router_ospf_cmd,
160 "no router ospf",
161 NO_STR
162 "Enable a routing process\n"
163 "Start OSPF configuration\n")
164{
paul020709f2003-04-04 02:44:16 +0000165 struct ospf *ospf;
166
167 ospf = ospf_lookup ();
168 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000169 {
paul020709f2003-04-04 02:44:16 +0000170 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000171 return CMD_WARNING;
172 }
173
paul020709f2003-04-04 02:44:16 +0000174 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000175
176 return CMD_SUCCESS;
177}
178
179DEFUN (ospf_router_id,
180 ospf_router_id_cmd,
181 "ospf router-id A.B.C.D",
182 "OSPF specific commands\n"
183 "router-id for the OSPF process\n"
184 "OSPF router-id in IP address format\n")
185{
paul68980082003-03-25 05:07:42 +0000186 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000187 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000188 int ret;
paul718e3742002-12-13 20:15:29 +0000189
190 ret = inet_aton (argv[0], &router_id);
191 if (!ret)
192 {
193 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
194 return CMD_WARNING;
195 }
196
paul68980082003-03-25 05:07:42 +0000197 ospf->router_id_static = router_id;
paulb29800a2005-11-20 14:50:45 +0000198
199 ospf_router_id_update (ospf);
200
paul718e3742002-12-13 20:15:29 +0000201 return CMD_SUCCESS;
202}
203
204ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000205 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000206 "router-id A.B.C.D",
207 "router-id for the OSPF process\n"
208 "OSPF router-id in IP address format\n")
209
210DEFUN (no_ospf_router_id,
211 no_ospf_router_id_cmd,
212 "no ospf router-id",
213 NO_STR
214 "OSPF specific commands\n"
215 "router-id for the OSPF process\n")
216{
paul68980082003-03-25 05:07:42 +0000217 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000218
paul68980082003-03-25 05:07:42 +0000219 ospf->router_id_static.s_addr = 0;
220
221 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000222
223 return CMD_SUCCESS;
224}
225
226ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000227 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000228 "no router-id",
229 NO_STR
230 "router-id for the OSPF process\n")
231
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000232static void
Andrew J. Schorr43540882006-11-28 16:36:39 +0000233ospf_passive_interface_default (struct ospf *ospf, u_char newval)
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000234{
235 struct listnode *ln;
236 struct interface *ifp;
237 struct ospf_interface *oi;
238
Andrew J. Schorr43540882006-11-28 16:36:39 +0000239 ospf->passive_interface_default = newval;
240
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000241 for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp))
242 {
243 if (ifp &&
244 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
245 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface);
246 }
247 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi))
248 {
249 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
250 UNSET_IF_PARAM (oi->params, passive_interface);
Andrew J. Schorr43540882006-11-28 16:36:39 +0000251 /* update multicast memberships */
252 ospf_if_set_multicast(oi);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000253 }
254}
255
256static void
257ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
258 struct in_addr addr,
259 struct ospf_if_params *params, u_char value)
260{
261 u_char dflt;
262
263 params->passive_interface = value;
264 if (params != IF_DEF_PARAMS (ifp))
265 {
266 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
267 dflt = IF_DEF_PARAMS (ifp)->passive_interface;
268 else
269 dflt = ospf->passive_interface_default;
270
271 if (value != dflt)
272 SET_IF_PARAM (params, passive_interface);
273 else
274 UNSET_IF_PARAM (params, passive_interface);
275
276 ospf_free_if_params (ifp, addr);
277 ospf_if_update_params (ifp, addr);
278 }
279 else
280 {
281 if (value != ospf->passive_interface_default)
282 SET_IF_PARAM (params, passive_interface);
283 else
284 UNSET_IF_PARAM (params, passive_interface);
285 }
286}
287
paula2c62832003-04-23 17:01:31 +0000288DEFUN (ospf_passive_interface,
289 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000290 "passive-interface IFNAME A.B.C.D",
291 "Suppress routing updates on an interface\n"
292 "Interface's name\n")
293{
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000294 struct interface *ifp;
295 struct in_addr addr;
296 int ret;
297 struct ospf_if_params *params;
298 struct route_node *rn;
299 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000300
Andrew J. Schorr43540882006-11-28 16:36:39 +0000301 if (argc == 0)
302 {
303 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
304 return CMD_SUCCESS;
305 }
306
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000307 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000308
309 params = IF_DEF_PARAMS (ifp);
310
Andrew J. Schorr43540882006-11-28 16:36:39 +0000311 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000312 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000313 ret = inet_aton(argv[1], &addr);
314 if (!ret)
315 {
316 vty_out (vty, "Please specify interface address by A.B.C.D%s",
317 VTY_NEWLINE);
318 return CMD_WARNING;
319 }
paul718e3742002-12-13 20:15:29 +0000320
Andrew J. Schorr43540882006-11-28 16:36:39 +0000321 params = ospf_get_if_params (ifp, addr);
322 ospf_if_update_params (ifp, addr);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000323 }
Andrew J. Schorr43540882006-11-28 16:36:39 +0000324 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE);
325
ajsba6454e2005-02-08 15:37:30 +0000326 /* XXX We should call ospf_if_set_multicast on exactly those
327 * interfaces for which the passive property changed. It is too much
328 * work to determine this set, so we do this for every interface.
329 * This is safe and reasonable because ospf_if_set_multicast uses a
330 * record of joined groups to avoid systems calls if the desired
331 * memberships match the current memership.
332 */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000333
ajsba6454e2005-02-08 15:37:30 +0000334 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
335 {
336 struct ospf_interface *oi = rn->info;
337
338 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
Andrew J. Schorr43540882006-11-28 16:36:39 +0000339 ospf_if_set_multicast(oi);
ajsba6454e2005-02-08 15:37:30 +0000340 }
341 /*
342 * XXX It is not clear what state transitions the interface needs to
343 * undergo when going from active to passive. Fixing this will
344 * require precise identification of interfaces having such a
345 * transition.
346 */
347
paul718e3742002-12-13 20:15:29 +0000348 return CMD_SUCCESS;
349}
350
paula2c62832003-04-23 17:01:31 +0000351ALIAS (ospf_passive_interface,
352 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000353 "passive-interface IFNAME",
354 "Suppress routing updates on an interface\n"
355 "Interface's name\n")
356
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000357ALIAS (ospf_passive_interface,
358 ospf_passive_interface_default_cmd,
359 "passive-interface default",
360 "Suppress routing updates on an interface\n"
361 "Suppress routing updates on interfaces by default\n")
362
paula2c62832003-04-23 17:01:31 +0000363DEFUN (no_ospf_passive_interface,
364 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000365 "no passive-interface IFNAME A.B.C.D",
366 NO_STR
367 "Allow routing updates on an interface\n"
368 "Interface's name\n")
369{
370 struct interface *ifp;
371 struct in_addr addr;
372 struct ospf_if_params *params;
373 int ret;
ajsba6454e2005-02-08 15:37:30 +0000374 struct route_node *rn;
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000375 struct ospf *ospf = vty->index;
Andrew J. Schorr43540882006-11-28 16:36:39 +0000376
377 if (argc == 0)
378 {
379 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
380 return CMD_SUCCESS;
381 }
paul718e3742002-12-13 20:15:29 +0000382
Andrew J. Schorr6e72cb62006-06-18 00:45:48 +0000383 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000384
385 params = IF_DEF_PARAMS (ifp);
386
Andrew J. Schorr43540882006-11-28 16:36:39 +0000387 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000388 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000389 ret = inet_aton(argv[1], &addr);
390 if (!ret)
391 {
392 vty_out (vty, "Please specify interface address by A.B.C.D%s",
393 VTY_NEWLINE);
394 return CMD_WARNING;
395 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000396
Andrew J. Schorr43540882006-11-28 16:36:39 +0000397 params = ospf_lookup_if_params (ifp, addr);
398 if (params == NULL)
399 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000400 }
Andrew J. Schorr43540882006-11-28 16:36:39 +0000401 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE);
ajsba6454e2005-02-08 15:37:30 +0000402
403 /* XXX We should call ospf_if_set_multicast on exactly those
404 * interfaces for which the passive property changed. It is too much
405 * work to determine this set, so we do this for every interface.
406 * This is safe and reasonable because ospf_if_set_multicast uses a
407 * record of joined groups to avoid systems calls if the desired
408 * memberships match the current memership.
409 */
410 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
411 {
412 struct ospf_interface *oi = rn->info;
413
414 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
415 ospf_if_set_multicast(oi);
416 }
417
paul718e3742002-12-13 20:15:29 +0000418 return CMD_SUCCESS;
419}
420
paula2c62832003-04-23 17:01:31 +0000421ALIAS (no_ospf_passive_interface,
422 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000423 "no passive-interface IFNAME",
424 NO_STR
425 "Allow routing updates on an interface\n"
426 "Interface's name\n")
427
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000428ALIAS (no_ospf_passive_interface,
429 no_ospf_passive_interface_default_cmd,
430 "no passive-interface default",
431 NO_STR
432 "Allow routing updates on an interface\n"
433 "Allow routing updates on interfaces by default\n")
434
paula2c62832003-04-23 17:01:31 +0000435DEFUN (ospf_network_area,
436 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000437 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
438 "Enable routing on an IP network\n"
439 "OSPF network prefix\n"
440 "Set the OSPF area ID\n"
441 "OSPF area ID in IP address format\n"
442 "OSPF area ID as a decimal value\n")
443{
444 struct ospf *ospf= vty->index;
445 struct prefix_ipv4 p;
446 struct in_addr area_id;
447 int ret, format;
448
449 /* Get network prefix and Area ID. */
450 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
451 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
452
453 ret = ospf_network_set (ospf, &p, area_id);
454 if (ret == 0)
455 {
456 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
457 return CMD_WARNING;
458 }
459
460 return CMD_SUCCESS;
461}
462
paula2c62832003-04-23 17:01:31 +0000463DEFUN (no_ospf_network_area,
464 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000465 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
466 NO_STR
467 "Enable routing on an IP network\n"
468 "OSPF network prefix\n"
469 "Set the OSPF area ID\n"
470 "OSPF area ID in IP address format\n"
471 "OSPF area ID as a decimal value\n")
472{
473 struct ospf *ospf = (struct ospf *) vty->index;
474 struct prefix_ipv4 p;
475 struct in_addr area_id;
476 int ret, format;
477
478 /* Get network prefix and Area ID. */
479 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
480 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
481
482 ret = ospf_network_unset (ospf, &p, area_id);
483 if (ret == 0)
484 {
485 vty_out (vty, "Can't find specified network area configuration.%s",
486 VTY_NEWLINE);
487 return CMD_WARNING;
488 }
489
490 return CMD_SUCCESS;
491}
492
493
paula2c62832003-04-23 17:01:31 +0000494DEFUN (ospf_area_range,
495 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000496 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
497 "OSPF area parameters\n"
498 "OSPF area ID in IP address format\n"
499 "OSPF area ID as a decimal value\n"
500 "Summarize routes matching address/mask (border routers only)\n"
501 "Area range prefix\n")
502{
503 struct ospf *ospf = vty->index;
504 struct prefix_ipv4 p;
505 struct in_addr area_id;
506 int format;
507 u_int32_t cost;
508
509 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
510 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
511
512 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
513 if (argc > 2)
514 {
paul4dadc292005-05-06 21:37:42 +0000515 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000516 ospf_area_range_cost_set (ospf, area_id, &p, cost);
517 }
518
519 return CMD_SUCCESS;
520}
521
paula2c62832003-04-23 17:01:31 +0000522ALIAS (ospf_area_range,
523 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000524 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
525 "OSPF area parameters\n"
526 "OSPF area ID in IP address format\n"
527 "OSPF area ID as a decimal value\n"
528 "OSPF area range for route advertise (default)\n"
529 "Area range prefix\n"
530 "Advertise this range (default)\n")
531
paula2c62832003-04-23 17:01:31 +0000532ALIAS (ospf_area_range,
533 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000534 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
535 "OSPF area parameters\n"
536 "OSPF area ID in IP address format\n"
537 "OSPF area ID as a decimal value\n"
538 "Summarize routes matching address/mask (border routers only)\n"
539 "Area range prefix\n"
540 "User specified metric for this range\n"
541 "Advertised metric for this range\n")
542
paula2c62832003-04-23 17:01:31 +0000543ALIAS (ospf_area_range,
544 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000545 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
546 "OSPF area parameters\n"
547 "OSPF area ID in IP address format\n"
548 "OSPF area ID as a decimal value\n"
549 "Summarize routes matching address/mask (border routers only)\n"
550 "Area range prefix\n"
551 "Advertise this range (default)\n"
552 "User specified metric for this range\n"
553 "Advertised metric for this range\n")
554
paula2c62832003-04-23 17:01:31 +0000555DEFUN (ospf_area_range_not_advertise,
556 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000557 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
558 "OSPF area parameters\n"
559 "OSPF area ID in IP address format\n"
560 "OSPF area ID as a decimal value\n"
561 "Summarize routes matching address/mask (border routers only)\n"
562 "Area range prefix\n"
563 "DoNotAdvertise this range\n")
564{
565 struct ospf *ospf = vty->index;
566 struct prefix_ipv4 p;
567 struct in_addr area_id;
568 int format;
569
570 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
571 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
572
573 ospf_area_range_set (ospf, area_id, &p, 0);
574
575 return CMD_SUCCESS;
576}
577
paula2c62832003-04-23 17:01:31 +0000578DEFUN (no_ospf_area_range,
579 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000580 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
581 NO_STR
582 "OSPF area parameters\n"
583 "OSPF area ID in IP address format\n"
584 "OSPF area ID as a decimal value\n"
585 "Summarize routes matching address/mask (border routers only)\n"
586 "Area range prefix\n")
587{
588 struct ospf *ospf = vty->index;
589 struct prefix_ipv4 p;
590 struct in_addr area_id;
591 int format;
592
593 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
594 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
595
596 ospf_area_range_unset (ospf, area_id, &p);
597
598 return CMD_SUCCESS;
599}
600
paula2c62832003-04-23 17:01:31 +0000601ALIAS (no_ospf_area_range,
602 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000603 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
604 NO_STR
605 "OSPF area parameters\n"
606 "OSPF area ID in IP address format\n"
607 "OSPF area ID as a decimal value\n"
608 "Summarize routes matching address/mask (border routers only)\n"
609 "Area range prefix\n"
610 "Advertise this range (default)\n"
611 "DoNotAdvertise this range\n")
612
paula2c62832003-04-23 17:01:31 +0000613ALIAS (no_ospf_area_range,
614 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000615 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
616 NO_STR
617 "OSPF area parameters\n"
618 "OSPF area ID in IP address format\n"
619 "OSPF area ID as a decimal value\n"
620 "Summarize routes matching address/mask (border routers only)\n"
621 "Area range prefix\n"
622 "User specified metric for this range\n"
623 "Advertised metric for this range\n")
624
paula2c62832003-04-23 17:01:31 +0000625ALIAS (no_ospf_area_range,
626 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000627 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
628 NO_STR
629 "OSPF area parameters\n"
630 "OSPF area ID in IP address format\n"
631 "OSPF area ID as a decimal value\n"
632 "Summarize routes matching address/mask (border routers only)\n"
633 "Area range prefix\n"
634 "Advertise this range (default)\n"
635 "User specified metric for this range\n"
636 "Advertised metric for this range\n")
637
paula2c62832003-04-23 17:01:31 +0000638DEFUN (ospf_area_range_substitute,
639 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000640 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
641 "OSPF area parameters\n"
642 "OSPF area ID in IP address format\n"
643 "OSPF area ID as a decimal value\n"
644 "Summarize routes matching address/mask (border routers only)\n"
645 "Area range prefix\n"
646 "Announce area range as another prefix\n"
647 "Network prefix to be announced instead of range\n")
648{
649 struct ospf *ospf = vty->index;
650 struct prefix_ipv4 p, s;
651 struct in_addr area_id;
652 int format;
653
654 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
655 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
656 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
657
658 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
659
660 return CMD_SUCCESS;
661}
662
paula2c62832003-04-23 17:01:31 +0000663DEFUN (no_ospf_area_range_substitute,
664 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000665 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
666 NO_STR
667 "OSPF area parameters\n"
668 "OSPF area ID in IP address format\n"
669 "OSPF area ID as a decimal value\n"
670 "Summarize routes matching address/mask (border routers only)\n"
671 "Area range prefix\n"
672 "Announce area range as another prefix\n"
673 "Network prefix to be announced instead of range\n")
674{
675 struct ospf *ospf = vty->index;
676 struct prefix_ipv4 p, s;
677 struct in_addr area_id;
678 int format;
679
680 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
681 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
682 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
683
684 ospf_area_range_substitute_unset (ospf, area_id, &p);
685
686 return CMD_SUCCESS;
687}
688
689
690/* Command Handler Logic in VLink stuff is delicate!!
691
692 ALTER AT YOUR OWN RISK!!!!
693
694 Various dummy values are used to represent 'NoChange' state for
695 VLink configuration NOT being changed by a VLink command, and
696 special syntax is used within the command strings so that the
697 typed in command verbs can be seen in the configuration command
698 bacckend handler. This is to drastically reduce the verbeage
699 required to coe up with a reasonably compatible Cisco VLink command
700
701 - Matthew Grant <grantma@anathoth.gen.nz>
702 Wed, 21 Feb 2001 15:13:52 +1300
703 */
704
705
706/* Configuration data for virtual links
707 */
708struct ospf_vl_config_data {
709 struct vty *vty; /* vty stuff */
710 struct in_addr area_id; /* area ID from command line */
711 int format; /* command line area ID format */
712 struct in_addr vl_peer; /* command line vl_peer */
713 int auth_type; /* Authehntication type, if given */
714 char *auth_key; /* simple password if present */
715 int crypto_key_id; /* Cryptographic key ID */
716 char *md5_key; /* MD5 authentication key */
717 int hello_interval; /* Obvious what these are... */
718 int retransmit_interval;
719 int transmit_delay;
720 int dead_interval;
721};
722
paul4dadc292005-05-06 21:37:42 +0000723static void
paul718e3742002-12-13 20:15:29 +0000724ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
725 struct vty *vty)
726{
727 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
728 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
729 vl_config->vty = vty;
730}
731
paul4dadc292005-05-06 21:37:42 +0000732static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000733ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000734{
735 struct ospf_area *area;
736 struct ospf_vl_data *vl_data;
737 struct vty *vty;
738 struct in_addr area_id;
739
740 vty = vl_config->vty;
741 area_id = vl_config->area_id;
742
743 if (area_id.s_addr == OSPF_AREA_BACKBONE)
744 {
745 vty_out (vty,
746 "Configuring VLs over the backbone is not allowed%s",
747 VTY_NEWLINE);
748 return NULL;
749 }
paul68980082003-03-25 05:07:42 +0000750 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000751
752 if (area->external_routing != OSPF_AREA_DEFAULT)
753 {
754 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
755 vty_out (vty, "Area %s is %s%s",
756 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000757 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000758 VTY_NEWLINE);
759 else
760 vty_out (vty, "Area %ld is %s%s",
761 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000762 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000763 VTY_NEWLINE);
764 return NULL;
765 }
766
Paul Jakma9c27ef92006-05-04 07:32:57 +0000767 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
paul718e3742002-12-13 20:15:29 +0000768 {
769 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
770 if (vl_data->vl_oi == NULL)
771 {
paul68980082003-03-25 05:07:42 +0000772 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
773 ospf_vl_add (ospf, vl_data);
774 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000775 }
776 }
777 return vl_data;
778}
779
780
paul4dadc292005-05-06 21:37:42 +0000781static int
paul718e3742002-12-13 20:15:29 +0000782ospf_vl_set_security (struct ospf_vl_data *vl_data,
783 struct ospf_vl_config_data *vl_config)
784{
785 struct crypt_key *ck;
786 struct vty *vty;
787 struct interface *ifp = vl_data->vl_oi->ifp;
788
789 vty = vl_config->vty;
790
791 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
792 {
793 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
794 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
795 }
796
797 if (vl_config->auth_key)
798 {
799 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000800 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000801 OSPF_AUTH_SIMPLE_SIZE);
802 }
803 else if (vl_config->md5_key)
804 {
805 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
806 != NULL)
807 {
808 vty_out (vty, "OSPF: Key %d already exists%s",
809 vl_config->crypto_key_id, VTY_NEWLINE);
810 return CMD_WARNING;
811 }
812 ck = ospf_crypt_key_new ();
813 ck->key_id = vl_config->crypto_key_id;
814 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000815 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000816
817 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
818 }
819 else if (vl_config->crypto_key_id != 0)
820 {
821 /* Delete a key */
822
823 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
824 vl_config->crypto_key_id) == NULL)
825 {
826 vty_out (vty, "OSPF: Key %d does not exist%s",
827 vl_config->crypto_key_id, VTY_NEWLINE);
828 return CMD_WARNING;
829 }
830
831 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
832
833 }
834
835 return CMD_SUCCESS;
836}
837
paul4dadc292005-05-06 21:37:42 +0000838static int
paul718e3742002-12-13 20:15:29 +0000839ospf_vl_set_timers (struct ospf_vl_data *vl_data,
840 struct ospf_vl_config_data *vl_config)
841{
842 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
843 /* Virtual Link data initialised to defaults, so only set
844 if a value given */
845 if (vl_config->hello_interval)
846 {
847 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
848 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
849 }
850
851 if (vl_config->dead_interval)
852 {
853 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
854 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
855 }
856
857 if (vl_config->retransmit_interval)
858 {
859 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
860 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
861 }
862
863 if (vl_config->transmit_delay)
864 {
865 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
866 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
867 }
868
869 return CMD_SUCCESS;
870}
871
872
873
874/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000875static int
paul68980082003-03-25 05:07:42 +0000876ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000877{
878 struct ospf_vl_data *vl_data;
879 int ret;
880
paul68980082003-03-25 05:07:42 +0000881 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000882 if (!vl_data)
883 return CMD_WARNING;
884
885 /* Process this one first as it can have a fatal result, which can
886 only logically occur if the virtual link exists already
887 Thus a command error does not result in a change to the
888 running configuration such as unexpectedly altered timer
889 values etc.*/
890 ret = ospf_vl_set_security (vl_data, vl_config);
891 if (ret != CMD_SUCCESS)
892 return ret;
893
894 /* Set any time based parameters, these area already range checked */
895
896 ret = ospf_vl_set_timers (vl_data, vl_config);
897 if (ret != CMD_SUCCESS)
898 return ret;
899
900 return CMD_SUCCESS;
901
902}
903
904/* This stuff exists to make specifying all the alias commands A LOT simpler
905 */
906#define VLINK_HELPSTR_IPADDR \
907 "OSPF area parameters\n" \
908 "OSPF area ID in IP address format\n" \
909 "OSPF area ID as a decimal value\n" \
910 "Configure a virtual link\n" \
911 "Router ID of the remote ABR\n"
912
913#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
914 "Enable authentication on this virtual link\n" \
915 "dummy string \n"
916
917#define VLINK_HELPSTR_AUTHTYPE_ALL \
918 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
919 "Use null authentication\n" \
920 "Use message-digest authentication\n"
921
922#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
923 "Time between HELLO packets\n" \
924 "Time between retransmitting lost link state advertisements\n" \
925 "Link state transmit delay\n" \
926 "Interval after which a neighbor is declared dead\n"
927
928#define VLINK_HELPSTR_TIME_PARAM \
929 VLINK_HELPSTR_TIME_PARAM_NOSECS \
930 "Seconds\n"
931
932#define VLINK_HELPSTR_AUTH_SIMPLE \
933 "Authentication password (key)\n" \
934 "The OSPF password (key)"
935
936#define VLINK_HELPSTR_AUTH_MD5 \
937 "Message digest authentication password (key)\n" \
938 "dummy string \n" \
939 "Key ID\n" \
940 "Use MD5 algorithm\n" \
941 "The OSPF password (key)"
942
paula2c62832003-04-23 17:01:31 +0000943DEFUN (ospf_area_vlink,
944 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000945 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
946 VLINK_HELPSTR_IPADDR)
947{
paul68980082003-03-25 05:07:42 +0000948 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000949 struct ospf_vl_config_data vl_config;
950 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
951 char md5_key[OSPF_AUTH_MD5_SIZE+1];
952 int i;
953 int ret;
954
955 ospf_vl_config_data_init(&vl_config, vty);
956
957 /* Read off first 2 parameters and check them */
958 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
959 if (ret < 0)
960 {
961 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
962 return CMD_WARNING;
963 }
964
965 ret = inet_aton (argv[1], &vl_config.vl_peer);
966 if (! ret)
967 {
968 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
969 VTY_NEWLINE);
970 return CMD_WARNING;
971 }
972
973 if (argc <=2)
974 {
975 /* Thats all folks! - BUGS B. strikes again!!!*/
976
paul68980082003-03-25 05:07:42 +0000977 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000978 }
979
980 /* Deal with other parameters */
981 for (i=2; i < argc; i++)
982 {
983
984 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
985
986 switch (argv[i][0])
987 {
988
989 case 'a':
990 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
991 {
992 /* authentication-key - this option can occur anywhere on
993 command line. At start of command line
994 must check for authentication option. */
995 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
996 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
997 vl_config.auth_key = auth_key;
998 i++;
999 }
1000 else if (strncmp (argv[i], "authentication", 14) == 0)
1001 {
1002 /* authentication - this option can only occur at start
1003 of command line */
1004 vl_config.auth_type = OSPF_AUTH_SIMPLE;
1005 if ((i+1) < argc)
1006 {
1007 if (strncmp (argv[i+1], "n", 1) == 0)
1008 {
1009 /* "authentication null" */
1010 vl_config.auth_type = OSPF_AUTH_NULL;
1011 i++;
1012 }
1013 else if (strncmp (argv[i+1], "m", 1) == 0
1014 && strcmp (argv[i+1], "message-digest-") != 0)
1015 {
1016 /* "authentication message-digest" */
1017 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1018 i++;
1019 }
1020 }
1021 }
1022 break;
1023
1024 case 'm':
1025 /* message-digest-key */
1026 i++;
1027 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1028 if (vl_config.crypto_key_id < 0)
1029 return CMD_WARNING;
1030 i++;
1031 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
1032 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
1033 vl_config.md5_key = md5_key;
1034 break;
1035
1036 case 'h':
1037 /* Hello interval */
1038 i++;
1039 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1040 if (vl_config.hello_interval < 0)
1041 return CMD_WARNING;
1042 break;
1043
1044 case 'r':
1045 /* Retransmit Interval */
1046 i++;
1047 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1048 if (vl_config.retransmit_interval < 0)
1049 return CMD_WARNING;
1050 break;
1051
1052 case 't':
1053 /* Transmit Delay */
1054 i++;
1055 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1056 if (vl_config.transmit_delay < 0)
1057 return CMD_WARNING;
1058 break;
1059
1060 case 'd':
1061 /* Dead Interval */
1062 i++;
1063 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1064 if (vl_config.dead_interval < 0)
1065 return CMD_WARNING;
1066 break;
1067 }
1068 }
1069
1070
1071 /* Action configuration */
1072
paul68980082003-03-25 05:07:42 +00001073 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001074
1075}
1076
paula2c62832003-04-23 17:01:31 +00001077DEFUN (no_ospf_area_vlink,
1078 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001079 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1080 NO_STR
1081 VLINK_HELPSTR_IPADDR)
1082{
paul68980082003-03-25 05:07:42 +00001083 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001084 struct ospf_area *area;
1085 struct ospf_vl_config_data vl_config;
1086 struct ospf_vl_data *vl_data = NULL;
1087 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1088 int i;
1089 int ret, format;
1090
1091 ospf_vl_config_data_init(&vl_config, vty);
1092
1093 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1094 if (ret < 0)
1095 {
1096 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1097 return CMD_WARNING;
1098 }
1099
paul68980082003-03-25 05:07:42 +00001100 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001101 if (!area)
1102 {
1103 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1104 return CMD_WARNING;
1105 }
1106
1107 ret = inet_aton (argv[1], &vl_config.vl_peer);
1108 if (! ret)
1109 {
1110 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1111 VTY_NEWLINE);
1112 return CMD_WARNING;
1113 }
1114
1115 if (argc <=2)
1116 {
1117 /* Basic VLink no command */
1118 /* Thats all folks! - BUGS B. strikes again!!!*/
Paul Jakma9c27ef92006-05-04 07:32:57 +00001119 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001120 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001121
paul68980082003-03-25 05:07:42 +00001122 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001123
1124 return CMD_SUCCESS;
1125 }
1126
1127 /* If we are down here, we are reseting parameters */
1128
1129 /* Deal with other parameters */
1130 for (i=2; i < argc; i++)
1131 {
paul718e3742002-12-13 20:15:29 +00001132 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1133
1134 switch (argv[i][0])
1135 {
1136
1137 case 'a':
1138 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1139 {
1140 /* authentication-key - this option can occur anywhere on
1141 command line. At start of command line
1142 must check for authentication option. */
1143 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1144 vl_config.auth_key = auth_key;
1145 }
1146 else if (strncmp (argv[i], "authentication", 14) == 0)
1147 {
1148 /* authentication - this option can only occur at start
1149 of command line */
1150 vl_config.auth_type = OSPF_AUTH_NOTSET;
1151 }
1152 break;
1153
1154 case 'm':
1155 /* message-digest-key */
1156 /* Delete one key */
1157 i++;
1158 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1159 if (vl_config.crypto_key_id < 0)
1160 return CMD_WARNING;
1161 vl_config.md5_key = NULL;
1162 break;
1163
1164 case 'h':
1165 /* Hello interval */
1166 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1167 break;
1168
1169 case 'r':
1170 /* Retransmit Interval */
1171 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1172 break;
1173
1174 case 't':
1175 /* Transmit Delay */
1176 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1177 break;
1178
1179 case 'd':
1180 /* Dead Interval */
1181 i++;
1182 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1183 break;
1184 }
1185 }
1186
1187
1188 /* Action configuration */
1189
paul68980082003-03-25 05:07:42 +00001190 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001191}
1192
paula2c62832003-04-23 17:01:31 +00001193ALIAS (ospf_area_vlink,
1194 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001195 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1196 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1197 VLINK_HELPSTR_IPADDR
1198 VLINK_HELPSTR_TIME_PARAM)
1199
paula2c62832003-04-23 17:01:31 +00001200ALIAS (no_ospf_area_vlink,
1201 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001202 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1203 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1204 NO_STR
1205 VLINK_HELPSTR_IPADDR
1206 VLINK_HELPSTR_TIME_PARAM)
1207
paula2c62832003-04-23 17:01:31 +00001208ALIAS (ospf_area_vlink,
1209 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001210 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1211 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1212 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1213 VLINK_HELPSTR_IPADDR
1214 VLINK_HELPSTR_TIME_PARAM
1215 VLINK_HELPSTR_TIME_PARAM)
1216
paula2c62832003-04-23 17:01:31 +00001217ALIAS (no_ospf_area_vlink,
1218 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001219 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1220 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1221 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1222 NO_STR
1223 VLINK_HELPSTR_IPADDR
1224 VLINK_HELPSTR_TIME_PARAM
1225 VLINK_HELPSTR_TIME_PARAM)
1226
paula2c62832003-04-23 17:01:31 +00001227ALIAS (ospf_area_vlink,
1228 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001229 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1230 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
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 VLINK_HELPSTR_TIME_PARAM)
1237
paula2c62832003-04-23 17:01:31 +00001238ALIAS (no_ospf_area_vlink,
1239 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001240 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1241 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1242 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1243 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1244 NO_STR
1245 VLINK_HELPSTR_IPADDR
1246 VLINK_HELPSTR_TIME_PARAM
1247 VLINK_HELPSTR_TIME_PARAM
1248 VLINK_HELPSTR_TIME_PARAM)
1249
paula2c62832003-04-23 17:01:31 +00001250ALIAS (ospf_area_vlink,
1251 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001252 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1253 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1254 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1255 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1256 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_TIME_PARAM
1259 VLINK_HELPSTR_TIME_PARAM
1260 VLINK_HELPSTR_TIME_PARAM
1261 VLINK_HELPSTR_TIME_PARAM)
1262
paula2c62832003-04-23 17:01:31 +00001263ALIAS (no_ospf_area_vlink,
1264 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001265 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1266 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1267 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1268 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1269 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1270 NO_STR
1271 VLINK_HELPSTR_IPADDR
1272 VLINK_HELPSTR_TIME_PARAM
1273 VLINK_HELPSTR_TIME_PARAM
1274 VLINK_HELPSTR_TIME_PARAM
1275 VLINK_HELPSTR_TIME_PARAM)
1276
paula2c62832003-04-23 17:01:31 +00001277ALIAS (ospf_area_vlink,
1278 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001279 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1280 "(authentication|) (message-digest|null)",
1281 VLINK_HELPSTR_IPADDR
1282 VLINK_HELPSTR_AUTHTYPE_ALL)
1283
paula2c62832003-04-23 17:01:31 +00001284ALIAS (ospf_area_vlink,
1285 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001286 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1287 "(authentication|)",
1288 VLINK_HELPSTR_IPADDR
1289 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1290
paula2c62832003-04-23 17:01:31 +00001291ALIAS (no_ospf_area_vlink,
1292 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001293 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1294 "(authentication|)",
1295 NO_STR
1296 VLINK_HELPSTR_IPADDR
1297 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1298
paula2c62832003-04-23 17:01:31 +00001299ALIAS (ospf_area_vlink,
1300 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001301 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1302 "(message-digest-key|) <1-255> md5 KEY",
1303 VLINK_HELPSTR_IPADDR
1304 VLINK_HELPSTR_AUTH_MD5)
1305
paula2c62832003-04-23 17:01:31 +00001306ALIAS (no_ospf_area_vlink,
1307 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001308 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1309 "(message-digest-key|) <1-255>",
1310 NO_STR
1311 VLINK_HELPSTR_IPADDR
1312 VLINK_HELPSTR_AUTH_MD5)
1313
paula2c62832003-04-23 17:01:31 +00001314ALIAS (ospf_area_vlink,
1315 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001316 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1317 "(authentication-key|) AUTH_KEY",
1318 VLINK_HELPSTR_IPADDR
1319 VLINK_HELPSTR_AUTH_SIMPLE)
1320
paula2c62832003-04-23 17:01:31 +00001321ALIAS (no_ospf_area_vlink,
1322 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001323 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1324 "(authentication-key|)",
1325 NO_STR
1326 VLINK_HELPSTR_IPADDR
1327 VLINK_HELPSTR_AUTH_SIMPLE)
1328
paula2c62832003-04-23 17:01:31 +00001329ALIAS (ospf_area_vlink,
1330 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001331 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1332 "(authentication|) (message-digest|null) "
1333 "(authentication-key|) AUTH_KEY",
1334 VLINK_HELPSTR_IPADDR
1335 VLINK_HELPSTR_AUTHTYPE_ALL
1336 VLINK_HELPSTR_AUTH_SIMPLE)
1337
paula2c62832003-04-23 17:01:31 +00001338ALIAS (ospf_area_vlink,
1339 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001340 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1341 "(authentication|) "
1342 "(authentication-key|) AUTH_KEY",
1343 VLINK_HELPSTR_IPADDR
1344 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1345 VLINK_HELPSTR_AUTH_SIMPLE)
1346
paula2c62832003-04-23 17:01:31 +00001347ALIAS (no_ospf_area_vlink,
1348 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001349 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1350 "(authentication|) "
1351 "(authentication-key|)",
1352 NO_STR
1353 VLINK_HELPSTR_IPADDR
1354 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1355 VLINK_HELPSTR_AUTH_SIMPLE)
1356
paula2c62832003-04-23 17:01:31 +00001357ALIAS (ospf_area_vlink,
1358 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001359 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1360 "(authentication|) (message-digest|null) "
1361 "(message-digest-key|) <1-255> md5 KEY",
1362 VLINK_HELPSTR_IPADDR
1363 VLINK_HELPSTR_AUTHTYPE_ALL
1364 VLINK_HELPSTR_AUTH_MD5)
1365
paula2c62832003-04-23 17:01:31 +00001366ALIAS (ospf_area_vlink,
1367 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001368 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1369 "(authentication|) "
1370 "(message-digest-key|) <1-255> md5 KEY",
1371 VLINK_HELPSTR_IPADDR
1372 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1373 VLINK_HELPSTR_AUTH_MD5)
1374
paula2c62832003-04-23 17:01:31 +00001375ALIAS (no_ospf_area_vlink,
1376 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001377 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1378 "(authentication|) "
1379 "(message-digest-key|)",
1380 NO_STR
1381 VLINK_HELPSTR_IPADDR
1382 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1383 VLINK_HELPSTR_AUTH_MD5)
1384
1385
paula2c62832003-04-23 17:01:31 +00001386DEFUN (ospf_area_shortcut,
1387 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001388 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1389 "OSPF area parameters\n"
1390 "OSPF area ID in IP address format\n"
1391 "OSPF area ID as a decimal value\n"
1392 "Configure the area's shortcutting mode\n"
1393 "Set default shortcutting behavior\n"
1394 "Enable shortcutting through the area\n"
1395 "Disable shortcutting through the area\n")
1396{
paul68980082003-03-25 05:07:42 +00001397 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001398 struct ospf_area *area;
1399 struct in_addr area_id;
1400 int mode;
1401 int format;
1402
1403 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1404
paul68980082003-03-25 05:07:42 +00001405 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001406
1407 if (strncmp (argv[1], "de", 2) == 0)
1408 mode = OSPF_SHORTCUT_DEFAULT;
1409 else if (strncmp (argv[1], "di", 2) == 0)
1410 mode = OSPF_SHORTCUT_DISABLE;
1411 else if (strncmp (argv[1], "e", 1) == 0)
1412 mode = OSPF_SHORTCUT_ENABLE;
1413 else
1414 return CMD_WARNING;
1415
paul68980082003-03-25 05:07:42 +00001416 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001417
paul68980082003-03-25 05:07:42 +00001418 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001419 vty_out (vty, "Shortcut area setting will take effect "
1420 "only when the router is configured as Shortcut ABR%s",
1421 VTY_NEWLINE);
1422
1423 return CMD_SUCCESS;
1424}
1425
paula2c62832003-04-23 17:01:31 +00001426DEFUN (no_ospf_area_shortcut,
1427 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001428 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1429 NO_STR
1430 "OSPF area parameters\n"
1431 "OSPF area ID in IP address format\n"
1432 "OSPF area ID as a decimal value\n"
1433 "Deconfigure the area's shortcutting mode\n"
1434 "Deconfigure enabled shortcutting through the area\n"
1435 "Deconfigure disabled shortcutting through the area\n")
1436{
paul68980082003-03-25 05:07:42 +00001437 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001438 struct ospf_area *area;
1439 struct in_addr area_id;
1440 int format;
1441
1442 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1443
paul68980082003-03-25 05:07:42 +00001444 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001445 if (!area)
1446 return CMD_SUCCESS;
1447
paul68980082003-03-25 05:07:42 +00001448 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001449
1450 return CMD_SUCCESS;
1451}
1452
1453
paula2c62832003-04-23 17:01:31 +00001454DEFUN (ospf_area_stub,
1455 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001456 "area (A.B.C.D|<0-4294967295>) stub",
1457 "OSPF area parameters\n"
1458 "OSPF area ID in IP address format\n"
1459 "OSPF area ID as a decimal value\n"
1460 "Configure OSPF area as stub\n")
1461{
1462 struct ospf *ospf = vty->index;
1463 struct in_addr area_id;
1464 int ret, format;
1465
1466 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1467
1468 ret = ospf_area_stub_set (ospf, area_id);
1469 if (ret == 0)
1470 {
1471 vty_out (vty, "First deconfigure all virtual link through this area%s",
1472 VTY_NEWLINE);
1473 return CMD_WARNING;
1474 }
1475
1476 ospf_area_no_summary_unset (ospf, area_id);
1477
1478 return CMD_SUCCESS;
1479}
1480
paula2c62832003-04-23 17:01:31 +00001481DEFUN (ospf_area_stub_no_summary,
1482 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001483 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1484 "OSPF stub parameters\n"
1485 "OSPF area ID in IP address format\n"
1486 "OSPF area ID as a decimal value\n"
1487 "Configure OSPF area as stub\n"
1488 "Do not inject inter-area routes into stub\n")
1489{
1490 struct ospf *ospf = vty->index;
1491 struct in_addr area_id;
1492 int ret, format;
1493
1494 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1495
1496 ret = ospf_area_stub_set (ospf, area_id);
1497 if (ret == 0)
1498 {
paulb0a053b2003-06-22 09:04:47 +00001499 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001500 VTY_NEWLINE);
1501 return CMD_WARNING;
1502 }
1503
1504 ospf_area_no_summary_set (ospf, area_id);
1505
1506 return CMD_SUCCESS;
1507}
1508
paula2c62832003-04-23 17:01:31 +00001509DEFUN (no_ospf_area_stub,
1510 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001511 "no area (A.B.C.D|<0-4294967295>) stub",
1512 NO_STR
1513 "OSPF area parameters\n"
1514 "OSPF area ID in IP address format\n"
1515 "OSPF area ID as a decimal value\n"
1516 "Configure OSPF area as stub\n")
1517{
1518 struct ospf *ospf = vty->index;
1519 struct in_addr area_id;
1520 int format;
1521
1522 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1523
1524 ospf_area_stub_unset (ospf, area_id);
1525 ospf_area_no_summary_unset (ospf, area_id);
1526
1527 return CMD_SUCCESS;
1528}
1529
paula2c62832003-04-23 17:01:31 +00001530DEFUN (no_ospf_area_stub_no_summary,
1531 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001532 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1533 NO_STR
1534 "OSPF area parameters\n"
1535 "OSPF area ID in IP address format\n"
1536 "OSPF area ID as a decimal value\n"
1537 "Configure OSPF area as stub\n"
1538 "Do not inject inter-area routes into area\n")
1539{
1540 struct ospf *ospf = vty->index;
1541 struct in_addr area_id;
1542 int format;
1543
1544 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1545 ospf_area_no_summary_unset (ospf, area_id);
1546
1547 return CMD_SUCCESS;
1548}
1549
paul4dadc292005-05-06 21:37:42 +00001550static int
paul6c835672004-10-11 11:00:30 +00001551ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1552 int nosum)
paul718e3742002-12-13 20:15:29 +00001553{
1554 struct ospf *ospf = vty->index;
1555 struct in_addr area_id;
1556 int ret, format;
1557
1558 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1559
1560 ret = ospf_area_nssa_set (ospf, area_id);
1561 if (ret == 0)
1562 {
1563 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1564 VTY_NEWLINE);
1565 return CMD_WARNING;
1566 }
1567
1568 if (argc > 1)
1569 {
1570 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001571 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001572 OSPF_NSSA_ROLE_CANDIDATE);
1573 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001574 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001575 OSPF_NSSA_ROLE_NEVER);
1576 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001577 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001578 OSPF_NSSA_ROLE_ALWAYS);
1579 }
paulb0a053b2003-06-22 09:04:47 +00001580 else
1581 {
1582 ospf_area_nssa_translator_role_set (ospf, area_id,
1583 OSPF_NSSA_ROLE_CANDIDATE);
1584 }
paul718e3742002-12-13 20:15:29 +00001585
paulb0a053b2003-06-22 09:04:47 +00001586 if (nosum)
paul718e3742002-12-13 20:15:29 +00001587 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001588 else
1589 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001590
paulb0a053b2003-06-22 09:04:47 +00001591 ospf_schedule_abr_task (ospf);
1592
paul718e3742002-12-13 20:15:29 +00001593 return CMD_SUCCESS;
1594}
1595
paulb0a053b2003-06-22 09:04:47 +00001596DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001597 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001598 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001599 "OSPF area parameters\n"
1600 "OSPF area ID in IP address format\n"
1601 "OSPF area ID as a decimal value\n"
1602 "Configure OSPF area as nssa\n"
1603 "Configure NSSA-ABR for translate election (default)\n"
1604 "Configure NSSA-ABR to never translate\n"
1605 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001606 "Do not inject inter-area routes into nssa\n")
1607{
1608 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1609}
paul718e3742002-12-13 20:15:29 +00001610
paulb0a053b2003-06-22 09:04:47 +00001611DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001612 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001613 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1614 "OSPF area parameters\n"
1615 "OSPF area ID in IP address format\n"
1616 "OSPF area ID as a decimal value\n"
1617 "Configure OSPF area as nssa\n"
1618 "Configure NSSA-ABR for translate election (default)\n"
1619 "Configure NSSA-ABR to never translate\n"
1620 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001621{
1622 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1623}
1624
1625DEFUN (ospf_area_nssa,
1626 ospf_area_nssa_cmd,
1627 "area (A.B.C.D|<0-4294967295>) nssa",
1628 "OSPF area parameters\n"
1629 "OSPF area ID in IP address format\n"
1630 "OSPF area ID as a decimal value\n"
1631 "Configure OSPF area as nssa\n")
1632{
1633 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1634}
paul718e3742002-12-13 20:15:29 +00001635
paula2c62832003-04-23 17:01:31 +00001636DEFUN (ospf_area_nssa_no_summary,
1637 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001638 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1639 "OSPF area parameters\n"
1640 "OSPF area ID in IP address format\n"
1641 "OSPF area ID as a decimal value\n"
1642 "Configure OSPF area as nssa\n"
1643 "Do not inject inter-area routes into nssa\n")
1644{
paulb0a053b2003-06-22 09:04:47 +00001645 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001646}
1647
paula2c62832003-04-23 17:01:31 +00001648DEFUN (no_ospf_area_nssa,
1649 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001650 "no area (A.B.C.D|<0-4294967295>) nssa",
1651 NO_STR
1652 "OSPF area parameters\n"
1653 "OSPF area ID in IP address format\n"
1654 "OSPF area ID as a decimal value\n"
1655 "Configure OSPF area as nssa\n")
1656{
1657 struct ospf *ospf = vty->index;
1658 struct in_addr area_id;
1659 int format;
1660
1661 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1662
1663 ospf_area_nssa_unset (ospf, area_id);
1664 ospf_area_no_summary_unset (ospf, area_id);
1665
paulb0a053b2003-06-22 09:04:47 +00001666 ospf_schedule_abr_task (ospf);
1667
paul718e3742002-12-13 20:15:29 +00001668 return CMD_SUCCESS;
1669}
1670
paula2c62832003-04-23 17:01:31 +00001671DEFUN (no_ospf_area_nssa_no_summary,
1672 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001673 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1674 NO_STR
1675 "OSPF area parameters\n"
1676 "OSPF area ID in IP address format\n"
1677 "OSPF area ID as a decimal value\n"
1678 "Configure OSPF area as nssa\n"
1679 "Do not inject inter-area routes into nssa\n")
1680{
1681 struct ospf *ospf = vty->index;
1682 struct in_addr area_id;
1683 int format;
1684
1685 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1686 ospf_area_no_summary_unset (ospf, area_id);
1687
1688 return CMD_SUCCESS;
1689}
1690
paula2c62832003-04-23 17:01:31 +00001691DEFUN (ospf_area_default_cost,
1692 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001693 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1694 "OSPF area parameters\n"
1695 "OSPF area ID in IP address format\n"
1696 "OSPF area ID as a decimal value\n"
1697 "Set the summary-default cost of a NSSA or stub area\n"
1698 "Stub's advertised default summary cost\n")
1699{
paul68980082003-03-25 05:07:42 +00001700 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001701 struct ospf_area *area;
1702 struct in_addr area_id;
1703 u_int32_t cost;
1704 int format;
vincentba682532005-09-29 13:52:57 +00001705 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001706
1707 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1708 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1709
paul68980082003-03-25 05:07:42 +00001710 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001711
1712 if (area->external_routing == OSPF_AREA_DEFAULT)
1713 {
1714 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1715 return CMD_WARNING;
1716 }
1717
1718 area->default_cost = cost;
1719
vincentba682532005-09-29 13:52:57 +00001720 p.family = AF_INET;
1721 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1722 p.prefixlen = 0;
1723 if (IS_DEBUG_OSPF_EVENT)
1724 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1725 "announcing 0.0.0.0/0 to area %s",
1726 inet_ntoa (area->area_id));
1727 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1728
paul718e3742002-12-13 20:15:29 +00001729 return CMD_SUCCESS;
1730}
1731
paula2c62832003-04-23 17:01:31 +00001732DEFUN (no_ospf_area_default_cost,
1733 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001734 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1735 NO_STR
1736 "OSPF area parameters\n"
1737 "OSPF area ID in IP address format\n"
1738 "OSPF area ID as a decimal value\n"
1739 "Set the summary-default cost of a NSSA or stub area\n"
1740 "Stub's advertised default summary cost\n")
1741{
paul68980082003-03-25 05:07:42 +00001742 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001743 struct ospf_area *area;
1744 struct in_addr area_id;
1745 u_int32_t cost;
1746 int format;
vincentba682532005-09-29 13:52:57 +00001747 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001748
1749 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1750 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1751
paul68980082003-03-25 05:07:42 +00001752 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001753 if (area == NULL)
1754 return CMD_SUCCESS;
1755
1756 if (area->external_routing == OSPF_AREA_DEFAULT)
1757 {
1758 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1759 return CMD_WARNING;
1760 }
1761
1762 area->default_cost = 1;
1763
vincentba682532005-09-29 13:52:57 +00001764 p.family = AF_INET;
1765 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1766 p.prefixlen = 0;
1767 if (IS_DEBUG_OSPF_EVENT)
1768 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1769 "announcing 0.0.0.0/0 to area %s",
1770 inet_ntoa (area->area_id));
1771 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1772
1773
paul68980082003-03-25 05:07:42 +00001774 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001775
1776 return CMD_SUCCESS;
1777}
1778
paula2c62832003-04-23 17:01:31 +00001779DEFUN (ospf_area_export_list,
1780 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001781 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1782 "OSPF area parameters\n"
1783 "OSPF area ID in IP address format\n"
1784 "OSPF area ID as a decimal value\n"
1785 "Set the filter for networks announced to other areas\n"
1786 "Name of the access-list\n")
1787{
paul68980082003-03-25 05:07:42 +00001788 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001789 struct ospf_area *area;
1790 struct in_addr area_id;
1791 int format;
1792
hasso52930762004-04-19 18:26:53 +00001793 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1794
paul68980082003-03-25 05:07:42 +00001795 area = ospf_area_get (ospf, area_id, format);
1796 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001797
1798 return CMD_SUCCESS;
1799}
1800
paula2c62832003-04-23 17:01:31 +00001801DEFUN (no_ospf_area_export_list,
1802 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001803 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1804 NO_STR
1805 "OSPF area parameters\n"
1806 "OSPF area ID in IP address format\n"
1807 "OSPF area ID as a decimal value\n"
1808 "Unset the filter for networks announced to other areas\n"
1809 "Name of the access-list\n")
1810{
paul68980082003-03-25 05:07:42 +00001811 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001812 struct ospf_area *area;
1813 struct in_addr area_id;
1814 int format;
1815
hasso52930762004-04-19 18:26:53 +00001816 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1817
paul68980082003-03-25 05:07:42 +00001818 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001819 if (area == NULL)
1820 return CMD_SUCCESS;
1821
paul68980082003-03-25 05:07:42 +00001822 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001823
1824 return CMD_SUCCESS;
1825}
1826
1827
paula2c62832003-04-23 17:01:31 +00001828DEFUN (ospf_area_import_list,
1829 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001830 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1831 "OSPF area parameters\n"
1832 "OSPF area ID in IP address format\n"
1833 "OSPF area ID as a decimal value\n"
1834 "Set the filter for networks from other areas announced to the specified one\n"
1835 "Name of the access-list\n")
1836{
paul68980082003-03-25 05:07:42 +00001837 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001838 struct ospf_area *area;
1839 struct in_addr area_id;
1840 int format;
1841
hasso52930762004-04-19 18:26:53 +00001842 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1843
paul68980082003-03-25 05:07:42 +00001844 area = ospf_area_get (ospf, area_id, format);
1845 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001846
1847 return CMD_SUCCESS;
1848}
1849
paula2c62832003-04-23 17:01:31 +00001850DEFUN (no_ospf_area_import_list,
1851 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001852 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1853 NO_STR
1854 "OSPF area parameters\n"
1855 "OSPF area ID in IP address format\n"
1856 "OSPF area ID as a decimal value\n"
1857 "Unset the filter for networks announced to other areas\n"
1858 "Name of the access-list\n")
1859{
paul68980082003-03-25 05:07:42 +00001860 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001861 struct ospf_area *area;
1862 struct in_addr area_id;
1863 int format;
1864
hasso52930762004-04-19 18:26:53 +00001865 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1866
paul68980082003-03-25 05:07:42 +00001867 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001868 if (area == NULL)
1869 return CMD_SUCCESS;
1870
paul68980082003-03-25 05:07:42 +00001871 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001872
1873 return CMD_SUCCESS;
1874}
1875
paula2c62832003-04-23 17:01:31 +00001876DEFUN (ospf_area_filter_list,
1877 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001878 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1879 "OSPF area parameters\n"
1880 "OSPF area ID in IP address format\n"
1881 "OSPF area ID as a decimal value\n"
1882 "Filter networks between OSPF areas\n"
1883 "Filter prefixes between OSPF areas\n"
1884 "Name of an IP prefix-list\n"
1885 "Filter networks sent to this area\n"
1886 "Filter networks sent from this area\n")
1887{
paul68980082003-03-25 05:07:42 +00001888 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001889 struct ospf_area *area;
1890 struct in_addr area_id;
1891 struct prefix_list *plist;
1892 int format;
1893
1894 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1895
paul68980082003-03-25 05:07:42 +00001896 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001897 plist = prefix_list_lookup (AFI_IP, argv[1]);
1898 if (strncmp (argv[2], "in", 2) == 0)
1899 {
1900 PREFIX_LIST_IN (area) = plist;
1901 if (PREFIX_NAME_IN (area))
1902 free (PREFIX_NAME_IN (area));
1903
1904 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001905 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001906 }
1907 else
1908 {
1909 PREFIX_LIST_OUT (area) = plist;
1910 if (PREFIX_NAME_OUT (area))
1911 free (PREFIX_NAME_OUT (area));
1912
1913 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001914 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001915 }
1916
1917 return CMD_SUCCESS;
1918}
1919
paula2c62832003-04-23 17:01:31 +00001920DEFUN (no_ospf_area_filter_list,
1921 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001922 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1923 NO_STR
1924 "OSPF area parameters\n"
1925 "OSPF area ID in IP address format\n"
1926 "OSPF area ID as a decimal value\n"
1927 "Filter networks between OSPF areas\n"
1928 "Filter prefixes between OSPF areas\n"
1929 "Name of an IP prefix-list\n"
1930 "Filter networks sent to this area\n"
1931 "Filter networks sent from this area\n")
1932{
paul68980082003-03-25 05:07:42 +00001933 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001934 struct ospf_area *area;
1935 struct in_addr area_id;
1936 struct prefix_list *plist;
1937 int format;
1938
1939 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1940
Paul Jakma1a8ec2b2006-05-11 13:34:08 +00001941 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1942 return CMD_SUCCESS;
1943
paul718e3742002-12-13 20:15:29 +00001944 plist = prefix_list_lookup (AFI_IP, argv[1]);
1945 if (strncmp (argv[2], "in", 2) == 0)
1946 {
1947 if (PREFIX_NAME_IN (area))
1948 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1949 return CMD_SUCCESS;
1950
1951 PREFIX_LIST_IN (area) = NULL;
1952 if (PREFIX_NAME_IN (area))
1953 free (PREFIX_NAME_IN (area));
1954
1955 PREFIX_NAME_IN (area) = NULL;
1956
paul68980082003-03-25 05:07:42 +00001957 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001958 }
1959 else
1960 {
1961 if (PREFIX_NAME_OUT (area))
1962 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1963 return CMD_SUCCESS;
1964
1965 PREFIX_LIST_OUT (area) = NULL;
1966 if (PREFIX_NAME_OUT (area))
1967 free (PREFIX_NAME_OUT (area));
1968
1969 PREFIX_NAME_OUT (area) = NULL;
1970
paul68980082003-03-25 05:07:42 +00001971 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001972 }
1973
1974 return CMD_SUCCESS;
1975}
1976
1977
paula2c62832003-04-23 17:01:31 +00001978DEFUN (ospf_area_authentication_message_digest,
1979 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001980 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1981 "OSPF area parameters\n"
1982 "Enable authentication\n"
1983 "Use message-digest authentication\n")
1984{
paul68980082003-03-25 05:07:42 +00001985 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001986 struct ospf_area *area;
1987 struct in_addr area_id;
1988 int format;
1989
1990 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1991
paul68980082003-03-25 05:07:42 +00001992 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001993 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1994
1995 return CMD_SUCCESS;
1996}
1997
paula2c62832003-04-23 17:01:31 +00001998DEFUN (ospf_area_authentication,
1999 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002000 "area (A.B.C.D|<0-4294967295>) authentication",
2001 "OSPF area parameters\n"
2002 "OSPF area ID in IP address format\n"
2003 "OSPF area ID as a decimal value\n"
2004 "Enable authentication\n")
2005{
paul68980082003-03-25 05:07:42 +00002006 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002007 struct ospf_area *area;
2008 struct in_addr area_id;
2009 int format;
2010
2011 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2012
paul68980082003-03-25 05:07:42 +00002013 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00002014 area->auth_type = OSPF_AUTH_SIMPLE;
2015
2016 return CMD_SUCCESS;
2017}
2018
paula2c62832003-04-23 17:01:31 +00002019DEFUN (no_ospf_area_authentication,
2020 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002021 "no area (A.B.C.D|<0-4294967295>) authentication",
2022 NO_STR
2023 "OSPF area parameters\n"
2024 "OSPF area ID in IP address format\n"
2025 "OSPF area ID as a decimal value\n"
2026 "Enable authentication\n")
2027{
paul68980082003-03-25 05:07:42 +00002028 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002029 struct ospf_area *area;
2030 struct in_addr area_id;
2031 int format;
2032
2033 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2034
paul68980082003-03-25 05:07:42 +00002035 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002036 if (area == NULL)
2037 return CMD_SUCCESS;
2038
2039 area->auth_type = OSPF_AUTH_NULL;
2040
paul68980082003-03-25 05:07:42 +00002041 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002042
2043 return CMD_SUCCESS;
2044}
2045
2046
2047DEFUN (ospf_abr_type,
2048 ospf_abr_type_cmd,
2049 "ospf abr-type (cisco|ibm|shortcut|standard)",
2050 "OSPF specific commands\n"
2051 "Set OSPF ABR type\n"
2052 "Alternative ABR, cisco implementation\n"
2053 "Alternative ABR, IBM implementation\n"
2054 "Shortcut ABR\n"
2055 "Standard behavior (RFC2328)\n")
2056{
paul68980082003-03-25 05:07:42 +00002057 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002058 u_char abr_type = OSPF_ABR_UNKNOWN;
2059
2060 if (strncmp (argv[0], "c", 1) == 0)
2061 abr_type = OSPF_ABR_CISCO;
2062 else if (strncmp (argv[0], "i", 1) == 0)
2063 abr_type = OSPF_ABR_IBM;
2064 else if (strncmp (argv[0], "sh", 2) == 0)
2065 abr_type = OSPF_ABR_SHORTCUT;
2066 else if (strncmp (argv[0], "st", 2) == 0)
2067 abr_type = OSPF_ABR_STAND;
2068 else
2069 return CMD_WARNING;
2070
2071 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002072 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002073 {
paul68980082003-03-25 05:07:42 +00002074 ospf->abr_type = abr_type;
2075 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002076 }
2077
2078 return CMD_SUCCESS;
2079}
2080
2081DEFUN (no_ospf_abr_type,
2082 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002083 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002084 NO_STR
2085 "OSPF specific commands\n"
2086 "Set OSPF ABR type\n"
2087 "Alternative ABR, cisco implementation\n"
2088 "Alternative ABR, IBM implementation\n"
2089 "Shortcut ABR\n")
2090{
paul68980082003-03-25 05:07:42 +00002091 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002092 u_char abr_type = OSPF_ABR_UNKNOWN;
2093
2094 if (strncmp (argv[0], "c", 1) == 0)
2095 abr_type = OSPF_ABR_CISCO;
2096 else if (strncmp (argv[0], "i", 1) == 0)
2097 abr_type = OSPF_ABR_IBM;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002098 else if (strncmp (argv[0], "sh", 2) == 0)
paul718e3742002-12-13 20:15:29 +00002099 abr_type = OSPF_ABR_SHORTCUT;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002100 else if (strncmp (argv[0], "st", 2) == 0)
2101 abr_type = OSPF_ABR_STAND;
paul718e3742002-12-13 20:15:29 +00002102 else
2103 return CMD_WARNING;
2104
2105 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002106 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002107 {
pauld57834f2005-07-12 20:04:22 +00002108 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002109 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002110 }
2111
2112 return CMD_SUCCESS;
2113}
2114
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002115DEFUN (ospf_log_adjacency_changes,
2116 ospf_log_adjacency_changes_cmd,
2117 "log-adjacency-changes",
2118 "Log changes in adjacency state\n")
2119{
2120 struct ospf *ospf = vty->index;
2121
2122 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2123 return CMD_SUCCESS;
2124}
2125
2126DEFUN (ospf_log_adjacency_changes_detail,
2127 ospf_log_adjacency_changes_detail_cmd,
2128 "log-adjacency-changes detail",
2129 "Log changes in adjacency state\n"
2130 "Log all state changes\n")
2131{
2132 struct ospf *ospf = vty->index;
2133
2134 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2135 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2136 return CMD_SUCCESS;
2137}
2138
2139DEFUN (no_ospf_log_adjacency_changes,
2140 no_ospf_log_adjacency_changes_cmd,
2141 "no log-adjacency-changes",
2142 NO_STR
2143 "Log changes in adjacency state\n")
2144{
2145 struct ospf *ospf = vty->index;
2146
2147 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2148 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2149 return CMD_SUCCESS;
2150}
2151
2152DEFUN (no_ospf_log_adjacency_changes_detail,
2153 no_ospf_log_adjacency_changes_detail_cmd,
2154 "no log-adjacency-changes detail",
2155 NO_STR
2156 "Log changes in adjacency state\n"
2157 "Log all state changes\n")
2158{
2159 struct ospf *ospf = vty->index;
2160
2161 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2162 return CMD_SUCCESS;
2163}
2164
paul718e3742002-12-13 20:15:29 +00002165DEFUN (ospf_compatible_rfc1583,
2166 ospf_compatible_rfc1583_cmd,
2167 "compatible rfc1583",
2168 "OSPF compatibility list\n"
2169 "compatible with RFC 1583\n")
2170{
2171 struct ospf *ospf = vty->index;
2172
2173 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2174 {
2175 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002176 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002177 }
2178 return CMD_SUCCESS;
2179}
2180
2181DEFUN (no_ospf_compatible_rfc1583,
2182 no_ospf_compatible_rfc1583_cmd,
2183 "no compatible rfc1583",
2184 NO_STR
2185 "OSPF compatibility list\n"
2186 "compatible with RFC 1583\n")
2187{
2188 struct ospf *ospf = vty->index;
2189
2190 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2191 {
2192 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002193 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002194 }
2195 return CMD_SUCCESS;
2196}
2197
2198ALIAS (ospf_compatible_rfc1583,
2199 ospf_rfc1583_flag_cmd,
2200 "ospf rfc1583compatibility",
2201 "OSPF specific commands\n"
2202 "Enable the RFC1583Compatibility flag\n")
2203
2204ALIAS (no_ospf_compatible_rfc1583,
2205 no_ospf_rfc1583_flag_cmd,
2206 "no ospf rfc1583compatibility",
2207 NO_STR
2208 "OSPF specific commands\n"
2209 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002210
2211static int
2212ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2213 unsigned int hold,
2214 unsigned int max)
2215{
2216 struct ospf *ospf = vty->index;
2217
2218 ospf->spf_delay = delay;
2219 ospf->spf_holdtime = hold;
2220 ospf->spf_max_holdtime = max;
2221
2222 return CMD_SUCCESS;
2223}
paul718e3742002-12-13 20:15:29 +00002224
pauld24f6e22005-10-21 09:23:12 +00002225DEFUN (ospf_timers_throttle_spf,
2226 ospf_timers_throttle_spf_cmd,
2227 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2228 "Adjust routing timers\n"
2229 "Throttling adaptive timer\n"
2230 "OSPF SPF timers\n"
2231 "Delay (msec) from first change received till SPF calculation\n"
2232 "Initial hold time (msec) between consecutive SPF calculations\n"
2233 "Maximum hold time (msec)\n")
2234{
2235 unsigned int delay, hold, max;
2236
2237 if (argc != 3)
2238 {
2239 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2240 return CMD_WARNING;
2241 }
2242
2243 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2244 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2245 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2246
2247 return ospf_timers_spf_set (vty, delay, hold, max);
2248}
2249
2250DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002251 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002252 "timers spf <0-4294967295> <0-4294967295>",
2253 "Adjust routing timers\n"
2254 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002255 "Delay (s) between receiving a change to SPF calculation\n"
2256 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002257{
pauld24f6e22005-10-21 09:23:12 +00002258 unsigned int delay, hold;
2259
2260 if (argc != 2)
2261 {
2262 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2263 return CMD_WARNING;
2264 }
2265
paul4dadc292005-05-06 21:37:42 +00002266 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2267 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002268
2269 /* truncate down the second values if they're greater than 600000ms */
2270 if (delay > (600000 / 1000))
2271 delay = 600000;
2272 else if (delay == 0)
2273 /* 0s delay was probably specified because of lack of ms resolution */
2274 delay = OSPF_SPF_DELAY_DEFAULT;
2275 if (hold > (600000 / 1000))
2276 hold = 600000;
2277
2278 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002279}
2280
pauld24f6e22005-10-21 09:23:12 +00002281DEFUN (no_ospf_timers_throttle_spf,
2282 no_ospf_timers_throttle_spf_cmd,
2283 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002284 NO_STR
2285 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002286 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002287 "OSPF SPF timers\n")
2288{
pauld24f6e22005-10-21 09:23:12 +00002289 return ospf_timers_spf_set (vty,
2290 OSPF_SPF_DELAY_DEFAULT,
2291 OSPF_SPF_HOLDTIME_DEFAULT,
2292 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002293}
2294
pauld24f6e22005-10-21 09:23:12 +00002295ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2296 no_ospf_timers_spf_cmd,
2297 "no timers spf",
2298 NO_STR
2299 "Adjust routing timers\n"
2300 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002301
paula2c62832003-04-23 17:01:31 +00002302DEFUN (ospf_neighbor,
2303 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002304 "neighbor A.B.C.D",
2305 NEIGHBOR_STR
2306 "Neighbor IP address\n")
2307{
2308 struct ospf *ospf = vty->index;
2309 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002310 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2311 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002312
2313 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2314
2315 if (argc > 1)
2316 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2317
2318 if (argc > 2)
2319 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2320
2321 ospf_nbr_nbma_set (ospf, nbr_addr);
2322 if (argc > 1)
2323 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2324 if (argc > 2)
2325 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2326
2327 return CMD_SUCCESS;
2328}
2329
paula2c62832003-04-23 17:01:31 +00002330ALIAS (ospf_neighbor,
2331 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002332 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2333 NEIGHBOR_STR
2334 "Neighbor IP address\n"
2335 "Neighbor Priority\n"
2336 "Priority\n"
2337 "Dead Neighbor Polling interval\n"
2338 "Seconds\n")
2339
paula2c62832003-04-23 17:01:31 +00002340ALIAS (ospf_neighbor,
2341 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002342 "neighbor A.B.C.D priority <0-255>",
2343 NEIGHBOR_STR
2344 "Neighbor IP address\n"
2345 "Neighbor Priority\n"
2346 "Seconds\n")
2347
paula2c62832003-04-23 17:01:31 +00002348DEFUN (ospf_neighbor_poll_interval,
2349 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002350 "neighbor A.B.C.D poll-interval <1-65535>",
2351 NEIGHBOR_STR
2352 "Neighbor IP address\n"
2353 "Dead Neighbor Polling interval\n"
2354 "Seconds\n")
2355{
2356 struct ospf *ospf = vty->index;
2357 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002358 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2359 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002360
2361 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2362
2363 if (argc > 1)
2364 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2365
2366 if (argc > 2)
2367 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2368
2369 ospf_nbr_nbma_set (ospf, nbr_addr);
2370 if (argc > 1)
2371 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2372 if (argc > 2)
2373 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2374
2375 return CMD_SUCCESS;
2376}
2377
paula2c62832003-04-23 17:01:31 +00002378ALIAS (ospf_neighbor_poll_interval,
2379 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002380 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2381 NEIGHBOR_STR
2382 "Neighbor address\n"
2383 "OSPF dead-router polling interval\n"
2384 "Seconds\n"
2385 "OSPF priority of non-broadcast neighbor\n"
2386 "Priority\n")
2387
paula2c62832003-04-23 17:01:31 +00002388DEFUN (no_ospf_neighbor,
2389 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002390 "no neighbor A.B.C.D",
2391 NO_STR
2392 NEIGHBOR_STR
2393 "Neighbor IP address\n")
2394{
2395 struct ospf *ospf = vty->index;
2396 struct in_addr nbr_addr;
2397 int ret;
2398
2399 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2400
2401 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2402
2403 return CMD_SUCCESS;
2404}
2405
paula2c62832003-04-23 17:01:31 +00002406ALIAS (no_ospf_neighbor,
2407 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002408 "no neighbor A.B.C.D priority <0-255>",
2409 NO_STR
2410 NEIGHBOR_STR
2411 "Neighbor IP address\n"
2412 "Neighbor Priority\n"
2413 "Priority\n")
2414
paula2c62832003-04-23 17:01:31 +00002415ALIAS (no_ospf_neighbor,
2416 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002417 "no neighbor A.B.C.D poll-interval <1-65535>",
2418 NO_STR
2419 NEIGHBOR_STR
2420 "Neighbor IP address\n"
2421 "Dead Neighbor Polling interval\n"
2422 "Seconds\n")
2423
paula2c62832003-04-23 17:01:31 +00002424ALIAS (no_ospf_neighbor,
2425 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002426 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2427 NO_STR
2428 NEIGHBOR_STR
2429 "Neighbor IP address\n"
2430 "Neighbor Priority\n"
2431 "Priority\n"
2432 "Dead Neighbor Polling interval\n"
2433 "Seconds\n")
2434
2435
paula2c62832003-04-23 17:01:31 +00002436DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002437 "refresh timer <10-1800>",
2438 "Adjust refresh parameters\n"
2439 "Set refresh timer\n"
2440 "Timer value in seconds\n")
2441{
2442 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002443 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002444
2445 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2446 interval = (interval / 10) * 10;
2447
2448 ospf_timers_refresh_set (ospf, interval);
2449
2450 return CMD_SUCCESS;
2451}
2452
paula2c62832003-04-23 17:01:31 +00002453DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002454 "no refresh timer <10-1800>",
2455 "Adjust refresh parameters\n"
2456 "Unset refresh timer\n"
2457 "Timer value in seconds\n")
2458{
2459 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002460 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002461
2462 if (argc == 1)
2463 {
2464 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2465
2466 if (ospf->lsa_refresh_interval != interval ||
2467 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2468 return CMD_SUCCESS;
2469 }
2470
2471 ospf_timers_refresh_unset (ospf);
2472
2473 return CMD_SUCCESS;
2474}
2475
paula2c62832003-04-23 17:01:31 +00002476ALIAS (no_ospf_refresh_timer,
2477 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002478 "no refresh timer",
2479 "Adjust refresh parameters\n"
2480 "Unset refresh timer\n")
2481
paula2c62832003-04-23 17:01:31 +00002482DEFUN (ospf_auto_cost_reference_bandwidth,
2483 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002484 "auto-cost reference-bandwidth <1-4294967>",
2485 "Calculate OSPF interface cost according to bandwidth\n"
2486 "Use reference bandwidth method to assign OSPF cost\n"
2487 "The reference bandwidth in terms of Mbits per second\n")
2488{
paul68980082003-03-25 05:07:42 +00002489 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002490 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002491 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002492 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002493
2494 refbw = strtol (argv[0], NULL, 10);
2495 if (refbw < 1 || refbw > 4294967)
2496 {
2497 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2498 return CMD_WARNING;
2499 }
2500
2501 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002502 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002503 return CMD_SUCCESS;
2504
paul68980082003-03-25 05:07:42 +00002505 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002506 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2507 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002508
2509 return CMD_SUCCESS;
2510}
2511
paula2c62832003-04-23 17:01:31 +00002512DEFUN (no_ospf_auto_cost_reference_bandwidth,
2513 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002514 "no auto-cost reference-bandwidth",
2515 NO_STR
2516 "Calculate OSPF interface cost according to bandwidth\n"
2517 "Use reference bandwidth method to assign OSPF cost\n")
2518{
paul68980082003-03-25 05:07:42 +00002519 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002520 struct listnode *node, *nnode;
2521 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002522
paul68980082003-03-25 05:07:42 +00002523 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002524 return CMD_SUCCESS;
2525
paul68980082003-03-25 05:07:42 +00002526 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002527 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2528 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2529
paul1eb8ef22005-04-07 07:30:20 +00002530 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2531 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002532
2533 return CMD_SUCCESS;
2534}
2535
hassoeb1ce602004-10-08 08:17:22 +00002536const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002537{
2538 "Unknown",
2539 "Standard (RFC2328)",
2540 "Alternative IBM",
2541 "Alternative Cisco",
2542 "Alternative Shortcut"
2543};
2544
hassoeb1ce602004-10-08 08:17:22 +00002545const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002546{
2547 "Default",
2548 "Enabled",
2549 "Disabled"
2550};
2551
2552
2553
paul4dadc292005-05-06 21:37:42 +00002554static void
paul718e3742002-12-13 20:15:29 +00002555show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2556{
2557 /* Show Area ID. */
2558 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2559
2560 /* Show Area type/mode. */
2561 if (OSPF_IS_AREA_BACKBONE (area))
2562 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2563 else
2564 {
2565 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002566 vty_out (vty, " (Stub%s%s)",
2567 area->no_summary ? ", no summary" : "",
2568 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002569
paulb0a053b2003-06-22 09:04:47 +00002570 else if (area->external_routing == OSPF_AREA_NSSA)
2571 vty_out (vty, " (NSSA%s%s)",
2572 area->no_summary ? ", no summary" : "",
2573 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002574
2575 vty_out (vty, "%s", VTY_NEWLINE);
2576 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002577 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002578 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002579 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002580 }
2581
2582 /* Show number of interfaces. */
2583 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2584 "Active: %d%s", listcount (area->oiflist),
2585 area->act_ints, VTY_NEWLINE);
2586
paul718e3742002-12-13 20:15:29 +00002587 if (area->external_routing == OSPF_AREA_NSSA)
2588 {
2589 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 +00002590 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002591 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2592 VTY_NEWLINE);
2593 else if (area->NSSATranslatorState)
2594 {
2595 vty_out (vty, " We are an ABR and ");
2596 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2597 vty_out (vty, "the NSSA Elected Translator. %s",
2598 VTY_NEWLINE);
2599 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2600 vty_out (vty, "always an NSSA Translator. %s",
2601 VTY_NEWLINE);
2602 }
paul718e3742002-12-13 20:15:29 +00002603 else
paulb0a053b2003-06-22 09:04:47 +00002604 {
2605 vty_out (vty, " We are an ABR, but ");
2606 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2607 vty_out (vty, "not the NSSA Elected Translator. %s",
2608 VTY_NEWLINE);
2609 else
hassoc6b87812004-12-22 13:09:59 +00002610 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002611 VTY_NEWLINE);
2612 }
paul718e3742002-12-13 20:15:29 +00002613 }
paul88d6cf32005-10-29 12:50:09 +00002614 /* Stub-router state for this area */
2615 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2616 {
ajs649654a2005-11-16 20:17:52 +00002617 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002618 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2619 VTY_NEWLINE);
2620 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2621 vty_out (vty, " Administratively activated (indefinitely)%s",
2622 VTY_NEWLINE);
2623 if (area->t_stub_router)
2624 vty_out (vty, " Active from startup, %s remaining%s",
2625 ospf_timer_dump (area->t_stub_router, timebuf,
2626 sizeof(timebuf)), VTY_NEWLINE);
2627 }
2628
paul718e3742002-12-13 20:15:29 +00002629 /* Show number of fully adjacent neighbors. */
2630 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002631 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002632
2633 /* Show authentication type. */
2634 vty_out (vty, " Area has ");
2635 if (area->auth_type == OSPF_AUTH_NULL)
2636 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2637 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2638 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2639 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2640 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2641
2642 if (!OSPF_IS_AREA_BACKBONE (area))
2643 vty_out (vty, " Number of full virtual adjacencies going through"
2644 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2645
2646 /* Show SPF calculation times. */
2647 vty_out (vty, " SPF algorithm executed %d times%s",
2648 area->spf_calculation, VTY_NEWLINE);
2649
2650 /* Show number of LSA. */
2651 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002652 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2653 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2654 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2655 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2656 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2657 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2658 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2659 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2660 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2661 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2662 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2663 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2664 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2665 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2666 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2667#ifdef HAVE_OPAQUE_LSA
2668 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2669 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2670 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2671 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2672 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2673 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2674#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002675 vty_out (vty, "%s", VTY_NEWLINE);
2676}
2677
2678DEFUN (show_ip_ospf,
2679 show_ip_ospf_cmd,
2680 "show ip ospf",
2681 SHOW_STR
2682 IP_STR
2683 "OSPF information\n")
2684{
paul1eb8ef22005-04-07 07:30:20 +00002685 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002686 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002687 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002688 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002689 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002690
2691 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002692 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002693 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002694 {
2695 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2696 return CMD_SUCCESS;
2697 }
2698
2699 /* Show Router ID. */
2700 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002701 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002702 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002703
2704 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002705 if (ospf->t_deferred_shutdown)
2706 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2707 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002708 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002709 /* Show capability. */
2710 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2711 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2712 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002713 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002714 "enabled" : "disabled", VTY_NEWLINE);
2715#ifdef HAVE_OPAQUE_LSA
2716 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002717 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002718 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002719 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002720 " (origination blocked)" : "",
2721 VTY_NEWLINE);
2722#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002723
2724 /* Show stub-router configuration */
2725 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2726 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2727 {
2728 vty_out (vty, " Stub router advertisement is configured%s",
2729 VTY_NEWLINE);
2730 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2731 vty_out (vty, " Enabled for %us after start-up%s",
2732 ospf->stub_router_startup_time, VTY_NEWLINE);
2733 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2734 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2735 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2736 }
2737
paul718e3742002-12-13 20:15:29 +00002738 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002739 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2740 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2741 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2742 " Hold time multiplier is currently %d%s",
2743 ospf->spf_delay, VTY_NEWLINE,
2744 ospf->spf_holdtime, VTY_NEWLINE,
2745 ospf->spf_max_holdtime, VTY_NEWLINE,
2746 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002747 vty_out (vty, " SPF algorithm ");
2748 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2749 {
Paul Jakma2518efd2006-08-27 06:49:29 +00002750 result = tv_sub (recent_relative_time (), ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002751 vty_out (vty, "last executed %s ago%s",
2752 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2753 VTY_NEWLINE);
2754 }
2755 else
2756 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002757 vty_out (vty, " SPF timer %s%s%s",
2758 (ospf->t_spf_calc ? "due in " : "is "),
2759 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2760 VTY_NEWLINE);
2761
paul718e3742002-12-13 20:15:29 +00002762 /* Show refresh parameters. */
2763 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002764 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002765
2766 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002767 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002768 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002769 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002770
paul68980082003-03-25 05:07:42 +00002771 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002772 vty_out (vty, " This router is an ASBR "
2773 "(injecting external routing information)%s", VTY_NEWLINE);
2774
2775 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002776 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2777 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2778 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2779#ifdef HAVE_OPAQUE_LSA
2780 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2781 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2782 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2783#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002784 /* Show number of areas attached. */
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002785 vty_out (vty, " Number of areas attached to this router: %d%s",
2786 listcount (ospf->areas), VTY_NEWLINE);
2787
2788 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2789 {
2790 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2791 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2792 else
2793 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2794 }
2795
2796 vty_out (vty, "%s",VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002797
2798 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002799 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2800 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002801
2802 return CMD_SUCCESS;
2803}
2804
2805
ajsfd651fa2005-03-29 16:08:16 +00002806static void
paul68980082003-03-25 05:07:42 +00002807show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2808 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002809{
ajsfd651fa2005-03-29 16:08:16 +00002810 int is_up;
paul718e3742002-12-13 20:15:29 +00002811 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002812 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002813
paul718e3742002-12-13 20:15:29 +00002814 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002815 vty_out (vty, "%s is %s%s", ifp->name,
2816 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002817 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2818 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2819 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002820
2821 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002822 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002823 {
2824 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2825 return;
2826 }
ajsfd651fa2005-03-29 16:08:16 +00002827 else if (!is_up)
2828 {
2829 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2830 VTY_NEWLINE);
2831 return;
2832 }
2833
paul718e3742002-12-13 20:15:29 +00002834 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2835 {
2836 struct ospf_interface *oi = rn->info;
2837
2838 if (oi == NULL)
2839 continue;
2840
2841 /* Show OSPF interface information. */
2842 vty_out (vty, " Internet Address %s/%d,",
2843 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2844
Paul Jakma9c27ef92006-05-04 07:32:57 +00002845 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2846 {
2847 struct in_addr *dest;
2848 const char *dstr;
2849
Andrew J. Schorre4529632006-12-12 19:18:21 +00002850 if (CONNECTED_PEER(oi->connected)
2851 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
Paul Jakma9c27ef92006-05-04 07:32:57 +00002852 dstr = "Peer";
2853 else
2854 dstr = "Broadcast";
2855
2856 /* For Vlinks, showing the peer address is probably more
2857 * informative than the local interface that is being used
2858 */
2859 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2860 dest = &oi->vl_data->peer_addr;
2861 else
2862 dest = &oi->connected->destination->u.prefix4;
2863
2864 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2865 }
hasso3fb9cd62004-10-19 19:44:43 +00002866
paul718e3742002-12-13 20:15:29 +00002867 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2868 VTY_NEWLINE);
2869
vincentba682532005-09-29 13:52:57 +00002870 vty_out (vty, " MTU mismatch detection:%s%s",
2871 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2872
paul718e3742002-12-13 20:15:29 +00002873 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002874 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002875 oi->output_cost, VTY_NEWLINE);
2876
2877 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2878 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2879 PRIORITY (oi), VTY_NEWLINE);
2880
2881 /* Show DR information. */
2882 if (DR (oi).s_addr == 0)
2883 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2884 else
2885 {
2886 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2887 if (nbr == NULL)
2888 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2889 else
2890 {
2891 vty_out (vty, " Designated Router (ID) %s,",
2892 inet_ntoa (nbr->router_id));
2893 vty_out (vty, " Interface Address %s%s",
2894 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2895 }
2896 }
2897
2898 /* Show BDR information. */
2899 if (BDR (oi).s_addr == 0)
2900 vty_out (vty, " No backup designated router on this network%s",
2901 VTY_NEWLINE);
2902 else
2903 {
2904 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2905 if (nbr == NULL)
2906 vty_out (vty, " No backup designated router on this network%s",
2907 VTY_NEWLINE);
2908 else
2909 {
2910 vty_out (vty, " Backup Designated Router (ID) %s,",
2911 inet_ntoa (nbr->router_id));
2912 vty_out (vty, " Interface Address %s%s",
2913 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2914 }
2915 }
ajsba6454e2005-02-08 15:37:30 +00002916
2917 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002918 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2919 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2920 {
2921 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2922 vty_out (vty, " OSPFAllRouters");
2923 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2924 vty_out (vty, " OSPFDesignatedRouters");
2925 }
2926 else
ajsba6454e2005-02-08 15:37:30 +00002927 vty_out (vty, " <None>");
2928 vty_out (vty, "%s", VTY_NEWLINE);
2929
paul718e3742002-12-13 20:15:29 +00002930 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002931 vty_out (vty, " Hello ");
2932 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2933 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2934 else
2935 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2936 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2937 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002938 OSPF_IF_PARAM (oi, v_wait),
2939 OSPF_IF_PARAM (oi, retransmit_interval),
2940 VTY_NEWLINE);
2941
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002942 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002943 {
ajs649654a2005-11-16 20:17:52 +00002944 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002945 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002946 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002947 VTY_NEWLINE);
2948 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002949 else /* passive-interface is set */
paul718e3742002-12-13 20:15:29 +00002950 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2951
2952 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002953 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002954 VTY_NEWLINE);
2955 }
2956}
2957
2958DEFUN (show_ip_ospf_interface,
2959 show_ip_ospf_interface_cmd,
2960 "show ip ospf interface [INTERFACE]",
2961 SHOW_STR
2962 IP_STR
2963 "OSPF information\n"
2964 "Interface information\n"
2965 "Interface name\n")
2966{
2967 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002968 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002969 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002970
paul020709f2003-04-04 02:44:16 +00002971 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002972 if (ospf == NULL)
2973 {
2974 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2975 return CMD_SUCCESS;
2976 }
paul020709f2003-04-04 02:44:16 +00002977
paul718e3742002-12-13 20:15:29 +00002978 /* Show All Interfaces. */
2979 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002980 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2981 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002982 /* Interface name is specified. */
2983 else
2984 {
2985 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2986 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2987 else
paul68980082003-03-25 05:07:42 +00002988 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002989 }
2990
2991 return CMD_SUCCESS;
2992}
2993
paul4dadc292005-05-06 21:37:42 +00002994static void
pauld24f6e22005-10-21 09:23:12 +00002995show_ip_ospf_neighbour_header (struct vty *vty)
2996{
2997 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2998 VTY_NEWLINE,
2999 "Neighbor ID", "Pri", "State", "Dead Time",
3000 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3001 VTY_NEWLINE);
3002}
3003
3004static void
paul718e3742002-12-13 20:15:29 +00003005show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3006{
3007 struct route_node *rn;
3008 struct ospf_neighbor *nbr;
3009 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00003010 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003011
3012 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3013 if ((nbr = rn->info))
3014 /* Do not show myself. */
3015 if (nbr != oi->nbr_self)
3016 /* Down state is not shown. */
3017 if (nbr->state != NSM_Down)
3018 {
3019 ospf_nbr_state_message (nbr, msgbuf, 16);
3020
3021 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00003022 vty_out (vty, "%-15s %3d %-15s ",
3023 "-", nbr->priority,
3024 msgbuf);
3025 else
3026 vty_out (vty, "%-15s %3d %-15s ",
3027 inet_ntoa (nbr->router_id), nbr->priority,
3028 msgbuf);
3029
3030 vty_out (vty, "%9s ",
3031 ospf_timer_dump (nbr->t_inactivity, timebuf,
3032 sizeof(timebuf)));
3033
paul718e3742002-12-13 20:15:29 +00003034 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00003035 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00003036 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3037 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3038 VTY_NEWLINE);
3039 }
3040}
3041
3042DEFUN (show_ip_ospf_neighbor,
3043 show_ip_ospf_neighbor_cmd,
3044 "show ip ospf neighbor",
3045 SHOW_STR
3046 IP_STR
3047 "OSPF information\n"
3048 "Neighbor list\n")
3049{
paul020709f2003-04-04 02:44:16 +00003050 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003051 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003052 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003053
paul020709f2003-04-04 02:44:16 +00003054 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003055 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003056 {
3057 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3058 return CMD_SUCCESS;
3059 }
3060
pauld24f6e22005-10-21 09:23:12 +00003061 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003062
paul1eb8ef22005-04-07 07:30:20 +00003063 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3064 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003065
3066 return CMD_SUCCESS;
3067}
3068
3069DEFUN (show_ip_ospf_neighbor_all,
3070 show_ip_ospf_neighbor_all_cmd,
3071 "show ip ospf neighbor all",
3072 SHOW_STR
3073 IP_STR
3074 "OSPF information\n"
3075 "Neighbor list\n"
3076 "include down status neighbor\n")
3077{
Joakim Tjernlund35f89142008-07-01 16:54:07 +02003078 struct ospf *ospf = ospf_lookup ();
hasso52dc7ee2004-09-23 19:18:23 +00003079 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003080 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003081
paul68980082003-03-25 05:07:42 +00003082 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003083 {
3084 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3085 return CMD_SUCCESS;
3086 }
pauld24f6e22005-10-21 09:23:12 +00003087
3088 show_ip_ospf_neighbour_header (vty);
3089
paul1eb8ef22005-04-07 07:30:20 +00003090 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003091 {
hasso52dc7ee2004-09-23 19:18:23 +00003092 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003093 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003094
3095 show_ip_ospf_neighbor_sub (vty, oi);
3096
3097 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003098 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003099 {
paul718e3742002-12-13 20:15:29 +00003100 if (nbr_nbma->nbr == NULL
3101 || nbr_nbma->nbr->state == NSM_Down)
3102 {
pauld24f6e22005-10-21 09:23:12 +00003103 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003104 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003105 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003106 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3107 0, 0, 0, VTY_NEWLINE);
3108 }
3109 }
3110 }
3111
3112 return CMD_SUCCESS;
3113}
3114
3115DEFUN (show_ip_ospf_neighbor_int,
3116 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003117 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003118 SHOW_STR
3119 IP_STR
3120 "OSPF information\n"
3121 "Neighbor list\n"
3122 "Interface name\n")
3123{
paul020709f2003-04-04 02:44:16 +00003124 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003125 struct interface *ifp;
3126 struct route_node *rn;
3127
3128 ifp = if_lookup_by_name (argv[0]);
3129 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003130 {
hassobb5b7552005-08-21 20:01:15 +00003131 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003132 return CMD_WARNING;
3133 }
3134
paul020709f2003-04-04 02:44:16 +00003135 ospf = ospf_lookup ();
3136 if (ospf == NULL)
3137 {
3138 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3139 return CMD_SUCCESS;
3140 }
pauld24f6e22005-10-21 09:23:12 +00003141
3142 show_ip_ospf_neighbour_header (vty);
3143
hassobb5b7552005-08-21 20:01:15 +00003144 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003145 {
hassobb5b7552005-08-21 20:01:15 +00003146 struct ospf_interface *oi = rn->info;
3147
3148 if (oi == NULL)
3149 continue;
3150
paul718e3742002-12-13 20:15:29 +00003151 show_ip_ospf_neighbor_sub (vty, oi);
3152 }
3153
3154 return CMD_SUCCESS;
3155}
3156
paul4dadc292005-05-06 21:37:42 +00003157static void
paul718e3742002-12-13 20:15:29 +00003158show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3159 struct ospf_nbr_nbma *nbr_nbma)
3160{
ajs649654a2005-11-16 20:17:52 +00003161 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003162
3163 /* Show neighbor ID. */
3164 vty_out (vty, " Neighbor %s,", "-");
3165
3166 /* Show interface address. */
3167 vty_out (vty, " interface address %s%s",
3168 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3169 /* Show Area ID. */
3170 vty_out (vty, " In the area %s via interface %s%s",
3171 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3172 /* Show neighbor priority and state. */
3173 vty_out (vty, " Neighbor priority is %d, State is %s,",
3174 nbr_nbma->priority, "Down");
3175 /* Show state changes. */
3176 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3177
3178 /* Show PollInterval */
3179 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3180
3181 /* Show poll-interval timer. */
3182 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003183 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3184 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003185
3186 /* Show poll-interval timer thread. */
3187 vty_out (vty, " Thread Poll Timer %s%s",
3188 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3189}
3190
paul4dadc292005-05-06 21:37:42 +00003191static void
paul718e3742002-12-13 20:15:29 +00003192show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3193 struct ospf_neighbor *nbr)
3194{
ajs649654a2005-11-16 20:17:52 +00003195 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003196
3197 /* Show neighbor ID. */
3198 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3199 vty_out (vty, " Neighbor %s,", "-");
3200 else
3201 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3202
3203 /* Show interface address. */
3204 vty_out (vty, " interface address %s%s",
3205 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3206 /* Show Area ID. */
3207 vty_out (vty, " In the area %s via interface %s%s",
3208 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3209 /* Show neighbor priority and state. */
3210 vty_out (vty, " Neighbor priority is %d, State is %s,",
3211 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3212 /* Show state changes. */
3213 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
Paul Jakma3fed4162006-07-25 20:44:12 +00003214 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
Paul Jakma90c33172006-07-11 17:57:25 +00003215 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003216 struct timeval res
3217 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003218 vty_out (vty, " Most recent state change statistics:%s",
3219 VTY_NEWLINE);
3220 vty_out (vty, " Progressive change %s ago%s",
Paul Jakma90c33172006-07-11 17:57:25 +00003221 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
Paul Jakma3fed4162006-07-25 20:44:12 +00003222 VTY_NEWLINE);
3223 }
3224 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3225 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003226 struct timeval res
3227 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003228 vty_out (vty, " Regressive change %s ago, due to %s%s",
3229 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3230 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
Paul Jakma90c33172006-07-11 17:57:25 +00003231 VTY_NEWLINE);
3232 }
paul718e3742002-12-13 20:15:29 +00003233 /* Show Designated Rotuer ID. */
3234 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3235 /* Show Backup Designated Rotuer ID. */
3236 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3237 /* Show options. */
3238 vty_out (vty, " Options %d %s%s", nbr->options,
3239 ospf_options_dump (nbr->options), VTY_NEWLINE);
3240 /* Show Router Dead interval timer. */
3241 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003242 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3243 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003244 /* Show Database Summary list. */
3245 vty_out (vty, " Database Summary List %d%s",
3246 ospf_db_summary_count (nbr), VTY_NEWLINE);
3247 /* Show Link State Request list. */
3248 vty_out (vty, " Link State Request List %ld%s",
3249 ospf_ls_request_count (nbr), VTY_NEWLINE);
3250 /* Show Link State Retransmission list. */
3251 vty_out (vty, " Link State Retransmission List %ld%s",
3252 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3253 /* Show inactivity timer thread. */
3254 vty_out (vty, " Thread Inactivity Timer %s%s",
3255 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3256 /* Show Database Description retransmission thread. */
3257 vty_out (vty, " Thread Database Description Retransmision %s%s",
3258 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3259 /* Show Link State Request Retransmission thread. */
3260 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3261 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3262 /* Show Link State Update Retransmission thread. */
3263 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3264 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3265}
3266
3267DEFUN (show_ip_ospf_neighbor_id,
3268 show_ip_ospf_neighbor_id_cmd,
3269 "show ip ospf neighbor A.B.C.D",
3270 SHOW_STR
3271 IP_STR
3272 "OSPF information\n"
3273 "Neighbor list\n"
3274 "Neighbor ID\n")
3275{
paul020709f2003-04-04 02:44:16 +00003276 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003277 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003278 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003279 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003280 struct in_addr router_id;
3281 int ret;
3282
3283 ret = inet_aton (argv[0], &router_id);
3284 if (!ret)
3285 {
3286 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3287 return CMD_WARNING;
3288 }
3289
paul020709f2003-04-04 02:44:16 +00003290 ospf = ospf_lookup ();
3291 if (ospf == NULL)
3292 {
3293 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3294 return CMD_SUCCESS;
3295 }
3296
paul1eb8ef22005-04-07 07:30:20 +00003297 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3298 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003299 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003300
paul718e3742002-12-13 20:15:29 +00003301 return CMD_SUCCESS;
3302}
3303
3304DEFUN (show_ip_ospf_neighbor_detail,
3305 show_ip_ospf_neighbor_detail_cmd,
3306 "show ip ospf neighbor detail",
3307 SHOW_STR
3308 IP_STR
3309 "OSPF information\n"
3310 "Neighbor list\n"
3311 "detail of all neighbors\n")
3312{
paul020709f2003-04-04 02:44:16 +00003313 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003314 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003315 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003316
paul020709f2003-04-04 02:44:16 +00003317 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003318 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003319 {
3320 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3321 return CMD_SUCCESS;
3322 }
paul718e3742002-12-13 20:15:29 +00003323
paul1eb8ef22005-04-07 07:30:20 +00003324 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003325 {
paul718e3742002-12-13 20:15:29 +00003326 struct route_node *rn;
3327 struct ospf_neighbor *nbr;
3328
3329 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3330 if ((nbr = rn->info))
3331 if (nbr != oi->nbr_self)
3332 if (nbr->state != NSM_Down)
3333 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3334 }
3335
3336 return CMD_SUCCESS;
3337}
3338
3339DEFUN (show_ip_ospf_neighbor_detail_all,
3340 show_ip_ospf_neighbor_detail_all_cmd,
3341 "show ip ospf neighbor detail all",
3342 SHOW_STR
3343 IP_STR
3344 "OSPF information\n"
3345 "Neighbor list\n"
3346 "detail of all neighbors\n"
3347 "include down status neighbor\n")
3348{
paul020709f2003-04-04 02:44:16 +00003349 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003350 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003351 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003352
paul020709f2003-04-04 02:44:16 +00003353 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003354 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003355 {
3356 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3357 return CMD_SUCCESS;
3358 }
paul718e3742002-12-13 20:15:29 +00003359
paul1eb8ef22005-04-07 07:30:20 +00003360 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003361 {
paul718e3742002-12-13 20:15:29 +00003362 struct route_node *rn;
3363 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003364 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003365
3366 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3367 if ((nbr = rn->info))
3368 if (nbr != oi->nbr_self)
3369 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3370 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3371
3372 if (oi->type == OSPF_IFTYPE_NBMA)
3373 {
hasso52dc7ee2004-09-23 19:18:23 +00003374 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003375
paul1eb8ef22005-04-07 07:30:20 +00003376 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3377 if (nbr_nbma->nbr == NULL
3378 || nbr_nbma->nbr->state == NSM_Down)
3379 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003380 }
3381 }
3382
3383 return CMD_SUCCESS;
3384}
3385
3386DEFUN (show_ip_ospf_neighbor_int_detail,
3387 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003388 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003389 SHOW_STR
3390 IP_STR
3391 "OSPF information\n"
3392 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003393 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003394 "detail of all neighbors")
3395{
paul020709f2003-04-04 02:44:16 +00003396 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003397 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003398 struct interface *ifp;
3399 struct route_node *rn, *nrn;
3400 struct ospf_neighbor *nbr;
3401
3402 ifp = if_lookup_by_name (argv[0]);
3403 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003404 {
hassobb5b7552005-08-21 20:01:15 +00003405 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003406 return CMD_WARNING;
3407 }
3408
paul020709f2003-04-04 02:44:16 +00003409 ospf = ospf_lookup ();
3410 if (ospf == NULL)
3411 {
3412 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3413 return CMD_SUCCESS;
3414 }
paul68980082003-03-25 05:07:42 +00003415
paul718e3742002-12-13 20:15:29 +00003416
hassobb5b7552005-08-21 20:01:15 +00003417 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3418 if ((oi = rn->info))
3419 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3420 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003421 if (nbr != oi->nbr_self)
3422 if (nbr->state != NSM_Down)
3423 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003424
3425 return CMD_SUCCESS;
3426}
3427
3428
3429/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003430static int
paul020709f2003-04-04 02:44:16 +00003431show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003432{
paul718e3742002-12-13 20:15:29 +00003433 struct router_lsa *rl;
3434 struct summary_lsa *sl;
3435 struct as_external_lsa *asel;
3436 struct prefix_ipv4 p;
3437
3438 if (lsa != NULL)
3439 /* If self option is set, check LSA self flag. */
3440 if (self == 0 || IS_LSA_SELF (lsa))
3441 {
3442 /* LSA common part show. */
3443 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3444 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3445 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3446 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3447 /* LSA specific part show. */
3448 switch (lsa->data->type)
3449 {
3450 case OSPF_ROUTER_LSA:
3451 rl = (struct router_lsa *) lsa->data;
3452 vty_out (vty, " %-d", ntohs (rl->links));
3453 break;
3454 case OSPF_SUMMARY_LSA:
3455 sl = (struct summary_lsa *) lsa->data;
3456
3457 p.family = AF_INET;
3458 p.prefix = sl->header.id;
3459 p.prefixlen = ip_masklen (sl->mask);
3460 apply_mask_ipv4 (&p);
3461
3462 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3463 break;
3464 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003465 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003466 asel = (struct as_external_lsa *) lsa->data;
3467
3468 p.family = AF_INET;
3469 p.prefix = asel->header.id;
3470 p.prefixlen = ip_masklen (asel->mask);
3471 apply_mask_ipv4 (&p);
3472
3473 vty_out (vty, " %s %s/%d [0x%lx]",
3474 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3475 inet_ntoa (p.prefix), p.prefixlen,
3476 (u_long)ntohl (asel->e[0].route_tag));
3477 break;
3478 case OSPF_NETWORK_LSA:
3479 case OSPF_ASBR_SUMMARY_LSA:
3480#ifdef HAVE_OPAQUE_LSA
3481 case OSPF_OPAQUE_LINK_LSA:
3482 case OSPF_OPAQUE_AREA_LSA:
3483 case OSPF_OPAQUE_AS_LSA:
3484#endif /* HAVE_OPAQUE_LSA */
3485 default:
3486 break;
3487 }
3488 vty_out (vty, VTY_NEWLINE);
3489 }
3490
3491 return 0;
3492}
3493
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003494static const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003495{
3496 "unknown",
3497 "Router Link States",
3498 "Net Link States",
3499 "Summary Link States",
3500 "ASBR-Summary Link States",
3501 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003502 "Group Membership LSA",
3503 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003504#ifdef HAVE_OPAQUE_LSA
3505 "Type-8 LSA",
3506 "Link-Local Opaque-LSA",
3507 "Area-Local Opaque-LSA",
3508 "AS-external Opaque-LSA",
3509#endif /* HAVE_OPAQUE_LSA */
3510};
3511
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003512static const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003513{
3514 "",
3515 "Link ID ADV Router Age Seq# CkSum Link count",
3516 "Link ID ADV Router Age Seq# CkSum",
3517 "Link ID ADV Router Age Seq# CkSum Route",
3518 "Link ID ADV Router Age Seq# CkSum",
3519 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003520 " --- header for Group Member ----",
3521 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003522#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003523 " --- type-8 ---",
3524 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3525 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3526 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3527#endif /* HAVE_OPAQUE_LSA */
3528};
3529
paul4dadc292005-05-06 21:37:42 +00003530static void
paul718e3742002-12-13 20:15:29 +00003531show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3532{
3533 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003534
paul718e3742002-12-13 20:15:29 +00003535 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003536 vty_out (vty, " Options: 0x%-2x : %s%s",
3537 lsa->data->options,
3538 ospf_options_dump(lsa->data->options),
3539 VTY_NEWLINE);
3540 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003541 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003542 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3543 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003544
3545 if (lsa->data->type == OSPF_ROUTER_LSA)
3546 {
3547 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3548
3549 if (rlsa->flags)
3550 vty_out (vty, " :%s%s%s%s",
3551 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3552 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3553 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3554 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3555
3556 vty_out (vty, "%s", VTY_NEWLINE);
3557 }
3558 vty_out (vty, " LS Type: %s%s",
3559 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3560 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3561 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3562 vty_out (vty, " Advertising Router: %s%s",
3563 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3564 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3565 VTY_NEWLINE);
3566 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3567 VTY_NEWLINE);
3568 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3569}
3570
hassoeb1ce602004-10-08 08:17:22 +00003571const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003572{
3573 "(null)",
3574 "another Router (point-to-point)",
3575 "a Transit Network",
3576 "Stub Network",
3577 "a Virtual Link",
3578};
3579
hassoeb1ce602004-10-08 08:17:22 +00003580const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003581{
3582 "(null)",
3583 "Neighboring Router ID",
3584 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003585 "Net",
paul718e3742002-12-13 20:15:29 +00003586 "Neighboring Router ID",
3587};
3588
hassoeb1ce602004-10-08 08:17:22 +00003589const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003590{
3591 "(null)",
3592 "Router Interface address",
3593 "Router Interface address",
3594 "Network Mask",
3595 "Router Interface address",
3596};
3597
3598/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003599static void
paul718e3742002-12-13 20:15:29 +00003600show_ip_ospf_database_router_links (struct vty *vty,
3601 struct router_lsa *rl)
3602{
3603 int len, i, type;
3604
3605 len = ntohs (rl->header.length) - 4;
3606 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3607 {
3608 type = rl->link[i].type;
3609
3610 vty_out (vty, " Link connected to: %s%s",
3611 link_type_desc[type], VTY_NEWLINE);
3612 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3613 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3614 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3615 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3616 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3617 vty_out (vty, " TOS 0 Metric: %d%s",
3618 ntohs (rl->link[i].metric), VTY_NEWLINE);
3619 vty_out (vty, "%s", VTY_NEWLINE);
3620 }
3621}
3622
3623/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003624static int
paul718e3742002-12-13 20:15:29 +00003625show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3626{
3627 if (lsa != NULL)
3628 {
3629 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3630
3631 show_ip_ospf_database_header (vty, lsa);
3632
3633 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3634 VTY_NEWLINE, VTY_NEWLINE);
3635
3636 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003637 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003638 }
3639
3640 return 0;
3641}
3642
3643/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003644static int
paul718e3742002-12-13 20:15:29 +00003645show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3646{
3647 int length, i;
3648
3649 if (lsa != NULL)
3650 {
3651 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3652
3653 show_ip_ospf_database_header (vty, lsa);
3654
3655 vty_out (vty, " Network Mask: /%d%s",
3656 ip_masklen (nl->mask), VTY_NEWLINE);
3657
3658 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3659
3660 for (i = 0; length > 0; i++, length -= 4)
3661 vty_out (vty, " Attached Router: %s%s",
3662 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3663
3664 vty_out (vty, "%s", VTY_NEWLINE);
3665 }
3666
3667 return 0;
3668}
3669
3670/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003671static int
paul718e3742002-12-13 20:15:29 +00003672show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3673{
3674 if (lsa != NULL)
3675 {
3676 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3677
3678 show_ip_ospf_database_header (vty, lsa);
3679
3680 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3681 VTY_NEWLINE);
3682 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3683 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003684 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003685 }
3686
3687 return 0;
3688}
3689
3690/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003691static int
paul718e3742002-12-13 20:15:29 +00003692show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3693{
3694 if (lsa != NULL)
3695 {
3696 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3697
3698 show_ip_ospf_database_header (vty, lsa);
3699
3700 vty_out (vty, " Network Mask: /%d%s",
3701 ip_masklen (sl->mask), VTY_NEWLINE);
3702 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3703 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003704 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003705 }
3706
3707 return 0;
3708}
3709
3710/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003711static int
paul718e3742002-12-13 20:15:29 +00003712show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3713{
3714 if (lsa != NULL)
3715 {
3716 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3717
3718 show_ip_ospf_database_header (vty, lsa);
3719
3720 vty_out (vty, " Network Mask: /%d%s",
3721 ip_masklen (al->mask), VTY_NEWLINE);
3722 vty_out (vty, " Metric Type: %s%s",
3723 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3724 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3725 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3726 vty_out (vty, " Metric: %d%s",
3727 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3728 vty_out (vty, " Forward Address: %s%s",
3729 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3730
3731 vty_out (vty, " External Route Tag: %lu%s%s",
3732 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3733 }
3734
3735 return 0;
3736}
3737
Stephen Hemmingera80e20d2011-12-06 23:54:17 +04003738#if 0
paul4dadc292005-05-06 21:37:42 +00003739static int
paul718e3742002-12-13 20:15:29 +00003740show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3741{
3742 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3743
3744 /* show_ip_ospf_database_header (vty, lsa); */
3745
ajs2a42e282004-12-08 18:43:03 +00003746 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003747 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003748 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003749 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3750 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003751 zlog_debug( " TOS: 0%s", "\n");
3752 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003753 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003754 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003755 inet_ntoa (al->e[0].fwd_addr), "\n");
3756
ajs2a42e282004-12-08 18:43:03 +00003757 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003758 ntohl (al->e[0].route_tag), "\n", "\n");
3759
3760 return 0;
3761}
Stephen Hemmingera80e20d2011-12-06 23:54:17 +04003762#endif
paul718e3742002-12-13 20:15:29 +00003763
3764/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003765static int
paul718e3742002-12-13 20:15:29 +00003766show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3767{
3768 if (lsa != NULL)
3769 {
3770 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3771
3772 show_ip_ospf_database_header (vty, lsa);
3773
3774 vty_out (vty, " Network Mask: /%d%s",
3775 ip_masklen (al->mask), VTY_NEWLINE);
3776 vty_out (vty, " Metric Type: %s%s",
3777 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3778 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3779 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3780 vty_out (vty, " Metric: %d%s",
3781 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3782 vty_out (vty, " NSSA: Forward Address: %s%s",
3783 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3784
3785 vty_out (vty, " External Route Tag: %u%s%s",
3786 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3787 }
3788
3789 return 0;
3790}
3791
paul4dadc292005-05-06 21:37:42 +00003792static int
paul718e3742002-12-13 20:15:29 +00003793show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3794{
3795 return 0;
3796}
3797
3798#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003799static int
paul718e3742002-12-13 20:15:29 +00003800show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3801{
3802 if (lsa != NULL)
3803 {
3804 show_ip_ospf_database_header (vty, lsa);
3805 show_opaque_info_detail (vty, lsa);
3806
3807 vty_out (vty, "%s", VTY_NEWLINE);
3808 }
3809 return 0;
3810}
3811#endif /* HAVE_OPAQUE_LSA */
3812
3813int (*show_function[])(struct vty *, struct ospf_lsa *) =
3814{
3815 NULL,
3816 show_router_lsa_detail,
3817 show_network_lsa_detail,
3818 show_summary_lsa_detail,
3819 show_summary_asbr_lsa_detail,
3820 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003821 show_func_dummy,
3822 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003823#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003824 NULL, /* type-8 */
3825 show_opaque_lsa_detail,
3826 show_opaque_lsa_detail,
3827 show_opaque_lsa_detail,
3828#endif /* HAVE_OPAQUE_LSA */
3829};
3830
paul4dadc292005-05-06 21:37:42 +00003831static void
paul718e3742002-12-13 20:15:29 +00003832show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3833 struct in_addr *adv_router)
3834{
3835 memset (lp, 0, sizeof (struct prefix_ls));
3836 lp->family = 0;
3837 if (id == NULL)
3838 lp->prefixlen = 0;
3839 else if (adv_router == NULL)
3840 {
3841 lp->prefixlen = 32;
3842 lp->id = *id;
3843 }
3844 else
3845 {
3846 lp->prefixlen = 64;
3847 lp->id = *id;
3848 lp->adv_router = *adv_router;
3849 }
3850}
3851
paul4dadc292005-05-06 21:37:42 +00003852static void
paul718e3742002-12-13 20:15:29 +00003853show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3854 struct in_addr *id, struct in_addr *adv_router)
3855{
3856 struct prefix_ls lp;
3857 struct route_node *rn, *start;
3858 struct ospf_lsa *lsa;
3859
3860 show_lsa_prefix_set (vty, &lp, id, adv_router);
3861 start = route_node_get (rt, (struct prefix *) &lp);
3862 if (start)
3863 {
3864 route_lock_node (start);
3865 for (rn = start; rn; rn = route_next_until (rn, start))
3866 if ((lsa = rn->info))
3867 {
paul718e3742002-12-13 20:15:29 +00003868 if (show_function[lsa->data->type] != NULL)
3869 show_function[lsa->data->type] (vty, lsa);
3870 }
3871 route_unlock_node (start);
3872 }
3873}
3874
3875/* Show detail LSA information
3876 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003877static void
paul020709f2003-04-04 02:44:16 +00003878show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003879 struct in_addr *id, struct in_addr *adv_router)
3880{
hasso52dc7ee2004-09-23 19:18:23 +00003881 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003882 struct ospf_area *area;
3883
paul718e3742002-12-13 20:15:29 +00003884 switch (type)
3885 {
3886 case OSPF_AS_EXTERNAL_LSA:
3887#ifdef HAVE_OPAQUE_LSA
3888 case OSPF_OPAQUE_AS_LSA:
3889#endif /* HAVE_OPAQUE_LSA */
3890 vty_out (vty, " %s %s%s",
3891 show_database_desc[type],
3892 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003893 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003894 break;
3895 default:
paul1eb8ef22005-04-07 07:30:20 +00003896 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003897 {
paul718e3742002-12-13 20:15:29 +00003898 vty_out (vty, "%s %s (Area %s)%s%s",
3899 VTY_NEWLINE, show_database_desc[type],
3900 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3901 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3902 }
3903 break;
3904 }
3905}
3906
paul4dadc292005-05-06 21:37:42 +00003907static void
paul718e3742002-12-13 20:15:29 +00003908show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3909 struct in_addr *adv_router)
3910{
3911 struct route_node *rn;
3912 struct ospf_lsa *lsa;
3913
3914 for (rn = route_top (rt); rn; rn = route_next (rn))
3915 if ((lsa = rn->info))
3916 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3917 {
paul718e3742002-12-13 20:15:29 +00003918 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3919 continue;
paul718e3742002-12-13 20:15:29 +00003920 if (show_function[lsa->data->type] != NULL)
3921 show_function[lsa->data->type] (vty, lsa);
3922 }
3923}
3924
3925/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003926static void
paul020709f2003-04-04 02:44:16 +00003927show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003928 struct in_addr *adv_router)
3929{
hasso52dc7ee2004-09-23 19:18:23 +00003930 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003931 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003932
3933 switch (type)
3934 {
3935 case OSPF_AS_EXTERNAL_LSA:
3936#ifdef HAVE_OPAQUE_LSA
3937 case OSPF_OPAQUE_AS_LSA:
3938#endif /* HAVE_OPAQUE_LSA */
3939 vty_out (vty, " %s %s%s",
3940 show_database_desc[type],
3941 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003942 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003943 adv_router);
3944 break;
3945 default:
paul1eb8ef22005-04-07 07:30:20 +00003946 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003947 {
paul718e3742002-12-13 20:15:29 +00003948 vty_out (vty, "%s %s (Area %s)%s%s",
3949 VTY_NEWLINE, show_database_desc[type],
3950 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3951 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3952 adv_router);
3953 }
3954 break;
3955 }
3956}
3957
paul4dadc292005-05-06 21:37:42 +00003958static void
paul020709f2003-04-04 02:44:16 +00003959show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003960{
paul020709f2003-04-04 02:44:16 +00003961 struct ospf_lsa *lsa;
3962 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003963 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003964 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003965 int type;
3966
paul1eb8ef22005-04-07 07:30:20 +00003967 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003968 {
paul718e3742002-12-13 20:15:29 +00003969 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3970 {
3971 switch (type)
3972 {
3973 case OSPF_AS_EXTERNAL_LSA:
3974#ifdef HAVE_OPAQUE_LSA
3975 case OSPF_OPAQUE_AS_LSA:
3976#endif /* HAVE_OPAQUE_LSA */
3977 continue;
3978 default:
3979 break;
3980 }
3981 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3982 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3983 {
3984 vty_out (vty, " %s (Area %s)%s%s",
3985 show_database_desc[type],
3986 ospf_area_desc_string (area),
3987 VTY_NEWLINE, VTY_NEWLINE);
3988 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3989
paul020709f2003-04-04 02:44:16 +00003990 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3991 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003992
3993 vty_out (vty, "%s", VTY_NEWLINE);
3994 }
3995 }
3996 }
3997
3998 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3999 {
4000 switch (type)
4001 {
4002 case OSPF_AS_EXTERNAL_LSA:
4003#ifdef HAVE_OPAQUE_LSA
4004 case OSPF_OPAQUE_AS_LSA:
4005#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00004006 break;
paul718e3742002-12-13 20:15:29 +00004007 default:
4008 continue;
4009 }
paul68980082003-03-25 05:07:42 +00004010 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4011 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00004012 {
4013 vty_out (vty, " %s%s%s",
4014 show_database_desc[type],
4015 VTY_NEWLINE, VTY_NEWLINE);
4016 vty_out (vty, "%s%s", show_database_header[type],
4017 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00004018
4019 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4020 show_lsa_summary (vty, lsa, self);
4021
paul718e3742002-12-13 20:15:29 +00004022 vty_out (vty, "%s", VTY_NEWLINE);
4023 }
4024 }
4025
4026 vty_out (vty, "%s", VTY_NEWLINE);
4027}
4028
paul4dadc292005-05-06 21:37:42 +00004029static void
paul020709f2003-04-04 02:44:16 +00004030show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00004031{
hasso52dc7ee2004-09-23 19:18:23 +00004032 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00004033 struct ospf_lsa *lsa;
4034
4035 vty_out (vty, "%s MaxAge Link States:%s%s",
4036 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4037
paul1eb8ef22005-04-07 07:30:20 +00004038 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
4039 {
4040 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4041 vty_out (vty, "Link State ID: %s%s",
4042 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4043 vty_out (vty, "Advertising Router: %s%s",
4044 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4045 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4046 vty_out (vty, "%s", VTY_NEWLINE);
4047 }
paul718e3742002-12-13 20:15:29 +00004048}
4049
paul718e3742002-12-13 20:15:29 +00004050#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4051#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00004052
4053#ifdef HAVE_OPAQUE_LSA
4054#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4055#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4056#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4057#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4058#else /* HAVE_OPAQUE_LSA */
4059#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4060#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4061#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4062#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4063#endif /* HAVE_OPAQUE_LSA */
4064
4065#define OSPF_LSA_TYPES_CMD_STR \
4066 "asbr-summary|external|network|router|summary" \
4067 OSPF_LSA_TYPE_NSSA_CMD_STR \
4068 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4069
4070#define OSPF_LSA_TYPES_DESC \
4071 "ASBR summary link states\n" \
4072 "External link states\n" \
4073 "Network link states\n" \
4074 "Router link states\n" \
4075 "Network summary link states\n" \
4076 OSPF_LSA_TYPE_NSSA_DESC \
4077 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4078 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4079 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4080
4081DEFUN (show_ip_ospf_database,
4082 show_ip_ospf_database_cmd,
4083 "show ip ospf database",
4084 SHOW_STR
4085 IP_STR
4086 "OSPF information\n"
4087 "Database summary\n")
4088{
paul020709f2003-04-04 02:44:16 +00004089 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004090 int type, ret;
4091 struct in_addr id, adv_router;
4092
paul020709f2003-04-04 02:44:16 +00004093 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004094 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004095 {
4096 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4097 return CMD_SUCCESS;
4098 }
paul718e3742002-12-13 20:15:29 +00004099
4100 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004101 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004102
4103 /* Show all LSA. */
4104 if (argc == 0)
4105 {
paul020709f2003-04-04 02:44:16 +00004106 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004107 return CMD_SUCCESS;
4108 }
4109
4110 /* Set database type to show. */
4111 if (strncmp (argv[0], "r", 1) == 0)
4112 type = OSPF_ROUTER_LSA;
4113 else if (strncmp (argv[0], "ne", 2) == 0)
4114 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004115 else if (strncmp (argv[0], "ns", 2) == 0)
4116 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004117 else if (strncmp (argv[0], "su", 2) == 0)
4118 type = OSPF_SUMMARY_LSA;
4119 else if (strncmp (argv[0], "a", 1) == 0)
4120 type = OSPF_ASBR_SUMMARY_LSA;
4121 else if (strncmp (argv[0], "e", 1) == 0)
4122 type = OSPF_AS_EXTERNAL_LSA;
4123 else if (strncmp (argv[0], "se", 2) == 0)
4124 {
paul020709f2003-04-04 02:44:16 +00004125 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004126 return CMD_SUCCESS;
4127 }
4128 else if (strncmp (argv[0], "m", 1) == 0)
4129 {
paul020709f2003-04-04 02:44:16 +00004130 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004131 return CMD_SUCCESS;
4132 }
4133#ifdef HAVE_OPAQUE_LSA
4134 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4135 type = OSPF_OPAQUE_LINK_LSA;
4136 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4137 type = OSPF_OPAQUE_AREA_LSA;
4138 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4139 type = OSPF_OPAQUE_AS_LSA;
4140#endif /* HAVE_OPAQUE_LSA */
4141 else
4142 return CMD_WARNING;
4143
4144 /* `show ip ospf database LSA'. */
4145 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004146 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004147 else if (argc >= 2)
4148 {
4149 ret = inet_aton (argv[1], &id);
4150 if (!ret)
4151 return CMD_WARNING;
4152
4153 /* `show ip ospf database LSA ID'. */
4154 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004155 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004156 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4157 else if (argc == 3)
4158 {
4159 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004160 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004161 else
4162 {
4163 ret = inet_aton (argv[2], &adv_router);
4164 if (!ret)
4165 return CMD_WARNING;
4166 }
paul020709f2003-04-04 02:44:16 +00004167 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004168 }
4169 }
4170
4171 return CMD_SUCCESS;
4172}
4173
4174ALIAS (show_ip_ospf_database,
4175 show_ip_ospf_database_type_cmd,
4176 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4177 SHOW_STR
4178 IP_STR
4179 "OSPF information\n"
4180 "Database summary\n"
4181 OSPF_LSA_TYPES_DESC
4182 "LSAs in MaxAge list\n"
4183 "Self-originated link states\n")
4184
4185ALIAS (show_ip_ospf_database,
4186 show_ip_ospf_database_type_id_cmd,
4187 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4188 SHOW_STR
4189 IP_STR
4190 "OSPF information\n"
4191 "Database summary\n"
4192 OSPF_LSA_TYPES_DESC
4193 "Link State ID (as an IP address)\n")
4194
4195ALIAS (show_ip_ospf_database,
4196 show_ip_ospf_database_type_id_adv_router_cmd,
4197 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4198 SHOW_STR
4199 IP_STR
4200 "OSPF information\n"
4201 "Database summary\n"
4202 OSPF_LSA_TYPES_DESC
4203 "Link State ID (as an IP address)\n"
4204 "Advertising Router link states\n"
4205 "Advertising Router (as an IP address)\n")
4206
4207ALIAS (show_ip_ospf_database,
4208 show_ip_ospf_database_type_id_self_cmd,
4209 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4210 SHOW_STR
4211 IP_STR
4212 "OSPF information\n"
4213 "Database summary\n"
4214 OSPF_LSA_TYPES_DESC
4215 "Link State ID (as an IP address)\n"
4216 "Self-originated link states\n"
4217 "\n")
4218
4219DEFUN (show_ip_ospf_database_type_adv_router,
4220 show_ip_ospf_database_type_adv_router_cmd,
4221 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4222 SHOW_STR
4223 IP_STR
4224 "OSPF information\n"
4225 "Database summary\n"
4226 OSPF_LSA_TYPES_DESC
4227 "Advertising Router link states\n"
4228 "Advertising Router (as an IP address)\n")
4229{
paul020709f2003-04-04 02:44:16 +00004230 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004231 int type, ret;
4232 struct in_addr adv_router;
4233
paul020709f2003-04-04 02:44:16 +00004234 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004235 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004236 {
4237 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4238 return CMD_SUCCESS;
4239 }
paul718e3742002-12-13 20:15:29 +00004240
4241 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004242 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004243
4244 if (argc != 2)
4245 return CMD_WARNING;
4246
4247 /* Set database type to show. */
4248 if (strncmp (argv[0], "r", 1) == 0)
4249 type = OSPF_ROUTER_LSA;
4250 else if (strncmp (argv[0], "ne", 2) == 0)
4251 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004252 else if (strncmp (argv[0], "ns", 2) == 0)
4253 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004254 else if (strncmp (argv[0], "s", 1) == 0)
4255 type = OSPF_SUMMARY_LSA;
4256 else if (strncmp (argv[0], "a", 1) == 0)
4257 type = OSPF_ASBR_SUMMARY_LSA;
4258 else if (strncmp (argv[0], "e", 1) == 0)
4259 type = OSPF_AS_EXTERNAL_LSA;
4260#ifdef HAVE_OPAQUE_LSA
4261 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4262 type = OSPF_OPAQUE_LINK_LSA;
4263 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4264 type = OSPF_OPAQUE_AREA_LSA;
4265 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4266 type = OSPF_OPAQUE_AS_LSA;
4267#endif /* HAVE_OPAQUE_LSA */
4268 else
4269 return CMD_WARNING;
4270
4271 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4272 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004273 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004274 else
4275 {
4276 ret = inet_aton (argv[1], &adv_router);
4277 if (!ret)
4278 return CMD_WARNING;
4279 }
4280
paul020709f2003-04-04 02:44:16 +00004281 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004282
4283 return CMD_SUCCESS;
4284}
4285
4286ALIAS (show_ip_ospf_database_type_adv_router,
4287 show_ip_ospf_database_type_self_cmd,
4288 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4289 SHOW_STR
4290 IP_STR
4291 "OSPF information\n"
4292 "Database summary\n"
4293 OSPF_LSA_TYPES_DESC
4294 "Self-originated link states\n")
4295
4296
4297DEFUN (ip_ospf_authentication_args,
4298 ip_ospf_authentication_args_addr_cmd,
4299 "ip ospf authentication (null|message-digest) A.B.C.D",
4300 "IP Information\n"
4301 "OSPF interface commands\n"
4302 "Enable authentication on this interface\n"
4303 "Use null authentication\n"
4304 "Use message-digest authentication\n"
4305 "Address of interface")
4306{
4307 struct interface *ifp;
4308 struct in_addr addr;
4309 int ret;
4310 struct ospf_if_params *params;
4311
4312 ifp = vty->index;
4313 params = IF_DEF_PARAMS (ifp);
4314
4315 if (argc == 2)
4316 {
4317 ret = inet_aton(argv[1], &addr);
4318 if (!ret)
4319 {
4320 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4321 VTY_NEWLINE);
4322 return CMD_WARNING;
4323 }
4324
4325 params = ospf_get_if_params (ifp, addr);
4326 ospf_if_update_params (ifp, addr);
4327 }
4328
4329 /* Handle null authentication */
4330 if ( argv[0][0] == 'n' )
4331 {
4332 SET_IF_PARAM (params, auth_type);
4333 params->auth_type = OSPF_AUTH_NULL;
4334 return CMD_SUCCESS;
4335 }
4336
4337 /* Handle message-digest authentication */
4338 if ( argv[0][0] == 'm' )
4339 {
4340 SET_IF_PARAM (params, auth_type);
4341 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4342 return CMD_SUCCESS;
4343 }
4344
4345 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4346 return CMD_WARNING;
4347}
4348
4349ALIAS (ip_ospf_authentication_args,
4350 ip_ospf_authentication_args_cmd,
4351 "ip ospf authentication (null|message-digest)",
4352 "IP Information\n"
4353 "OSPF interface commands\n"
4354 "Enable authentication on this interface\n"
4355 "Use null authentication\n"
4356 "Use message-digest authentication\n")
4357
4358DEFUN (ip_ospf_authentication,
4359 ip_ospf_authentication_addr_cmd,
4360 "ip ospf authentication A.B.C.D",
4361 "IP Information\n"
4362 "OSPF interface commands\n"
4363 "Enable authentication on this interface\n"
4364 "Address of interface")
4365{
4366 struct interface *ifp;
4367 struct in_addr addr;
4368 int ret;
4369 struct ospf_if_params *params;
4370
4371 ifp = vty->index;
4372 params = IF_DEF_PARAMS (ifp);
4373
4374 if (argc == 1)
4375 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004376 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004377 if (!ret)
4378 {
4379 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4380 VTY_NEWLINE);
4381 return CMD_WARNING;
4382 }
4383
4384 params = ospf_get_if_params (ifp, addr);
4385 ospf_if_update_params (ifp, addr);
4386 }
4387
4388 SET_IF_PARAM (params, auth_type);
4389 params->auth_type = OSPF_AUTH_SIMPLE;
4390
4391 return CMD_SUCCESS;
4392}
4393
4394ALIAS (ip_ospf_authentication,
4395 ip_ospf_authentication_cmd,
4396 "ip ospf authentication",
4397 "IP Information\n"
4398 "OSPF interface commands\n"
4399 "Enable authentication on this interface\n")
4400
4401DEFUN (no_ip_ospf_authentication,
4402 no_ip_ospf_authentication_addr_cmd,
4403 "no ip ospf authentication A.B.C.D",
4404 NO_STR
4405 "IP Information\n"
4406 "OSPF interface commands\n"
4407 "Enable authentication on this interface\n"
4408 "Address of interface")
4409{
4410 struct interface *ifp;
4411 struct in_addr addr;
4412 int ret;
4413 struct ospf_if_params *params;
4414
4415 ifp = vty->index;
4416 params = IF_DEF_PARAMS (ifp);
4417
4418 if (argc == 1)
4419 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004420 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004421 if (!ret)
4422 {
4423 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4424 VTY_NEWLINE);
4425 return CMD_WARNING;
4426 }
4427
4428 params = ospf_lookup_if_params (ifp, addr);
4429 if (params == NULL)
4430 return CMD_SUCCESS;
4431 }
4432
4433 params->auth_type = OSPF_AUTH_NOTSET;
4434 UNSET_IF_PARAM (params, auth_type);
4435
4436 if (params != IF_DEF_PARAMS (ifp))
4437 {
4438 ospf_free_if_params (ifp, addr);
4439 ospf_if_update_params (ifp, addr);
4440 }
4441
4442 return CMD_SUCCESS;
4443}
4444
4445ALIAS (no_ip_ospf_authentication,
4446 no_ip_ospf_authentication_cmd,
4447 "no ip ospf authentication",
4448 NO_STR
4449 "IP Information\n"
4450 "OSPF interface commands\n"
4451 "Enable authentication on this interface\n")
4452
4453DEFUN (ip_ospf_authentication_key,
4454 ip_ospf_authentication_key_addr_cmd,
4455 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4456 "IP Information\n"
4457 "OSPF interface commands\n"
4458 "Authentication password (key)\n"
4459 "The OSPF password (key)\n"
4460 "Address of interface")
4461{
4462 struct interface *ifp;
4463 struct in_addr addr;
4464 int ret;
4465 struct ospf_if_params *params;
4466
4467 ifp = vty->index;
4468 params = IF_DEF_PARAMS (ifp);
4469
4470 if (argc == 2)
4471 {
4472 ret = inet_aton(argv[1], &addr);
4473 if (!ret)
4474 {
4475 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4476 VTY_NEWLINE);
4477 return CMD_WARNING;
4478 }
4479
4480 params = ospf_get_if_params (ifp, addr);
4481 ospf_if_update_params (ifp, addr);
4482 }
4483
4484
4485 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004486 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004487 SET_IF_PARAM (params, auth_simple);
4488
4489 return CMD_SUCCESS;
4490}
4491
4492ALIAS (ip_ospf_authentication_key,
4493 ip_ospf_authentication_key_cmd,
4494 "ip ospf authentication-key AUTH_KEY",
4495 "IP Information\n"
4496 "OSPF interface commands\n"
4497 "Authentication password (key)\n"
4498 "The OSPF password (key)")
4499
4500ALIAS (ip_ospf_authentication_key,
4501 ospf_authentication_key_cmd,
4502 "ospf authentication-key AUTH_KEY",
4503 "OSPF interface commands\n"
4504 "Authentication password (key)\n"
4505 "The OSPF password (key)")
4506
4507DEFUN (no_ip_ospf_authentication_key,
4508 no_ip_ospf_authentication_key_addr_cmd,
4509 "no ip ospf authentication-key A.B.C.D",
4510 NO_STR
4511 "IP Information\n"
4512 "OSPF interface commands\n"
4513 "Authentication password (key)\n"
4514 "Address of interface")
4515{
4516 struct interface *ifp;
4517 struct in_addr addr;
4518 int ret;
4519 struct ospf_if_params *params;
4520
4521 ifp = vty->index;
4522 params = IF_DEF_PARAMS (ifp);
4523
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004524 if (argc == 1)
paul718e3742002-12-13 20:15:29 +00004525 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004526 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004527 if (!ret)
4528 {
4529 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4530 VTY_NEWLINE);
4531 return CMD_WARNING;
4532 }
4533
4534 params = ospf_lookup_if_params (ifp, addr);
4535 if (params == NULL)
4536 return CMD_SUCCESS;
4537 }
4538
4539 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4540 UNSET_IF_PARAM (params, auth_simple);
4541
4542 if (params != IF_DEF_PARAMS (ifp))
4543 {
4544 ospf_free_if_params (ifp, addr);
4545 ospf_if_update_params (ifp, addr);
4546 }
4547
4548 return CMD_SUCCESS;
4549}
4550
4551ALIAS (no_ip_ospf_authentication_key,
4552 no_ip_ospf_authentication_key_cmd,
4553 "no ip ospf authentication-key",
4554 NO_STR
4555 "IP Information\n"
4556 "OSPF interface commands\n"
4557 "Authentication password (key)\n")
4558
4559ALIAS (no_ip_ospf_authentication_key,
4560 no_ospf_authentication_key_cmd,
4561 "no ospf authentication-key",
4562 NO_STR
4563 "OSPF interface commands\n"
4564 "Authentication password (key)\n")
4565
4566DEFUN (ip_ospf_message_digest_key,
4567 ip_ospf_message_digest_key_addr_cmd,
4568 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4569 "IP Information\n"
4570 "OSPF interface commands\n"
4571 "Message digest authentication password (key)\n"
4572 "Key ID\n"
4573 "Use MD5 algorithm\n"
4574 "The OSPF password (key)"
4575 "Address of interface")
4576{
4577 struct interface *ifp;
4578 struct crypt_key *ck;
4579 u_char key_id;
4580 struct in_addr addr;
4581 int ret;
4582 struct ospf_if_params *params;
4583
4584 ifp = vty->index;
4585 params = IF_DEF_PARAMS (ifp);
4586
4587 if (argc == 3)
4588 {
4589 ret = inet_aton(argv[2], &addr);
4590 if (!ret)
4591 {
4592 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4593 VTY_NEWLINE);
4594 return CMD_WARNING;
4595 }
4596
4597 params = ospf_get_if_params (ifp, addr);
4598 ospf_if_update_params (ifp, addr);
4599 }
4600
4601 key_id = strtol (argv[0], NULL, 10);
4602 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4603 {
4604 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4605 return CMD_WARNING;
4606 }
4607
4608 ck = ospf_crypt_key_new ();
4609 ck->key_id = (u_char) key_id;
4610 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004611 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004612
4613 ospf_crypt_key_add (params->auth_crypt, ck);
4614 SET_IF_PARAM (params, auth_crypt);
4615
4616 return CMD_SUCCESS;
4617}
4618
4619ALIAS (ip_ospf_message_digest_key,
4620 ip_ospf_message_digest_key_cmd,
4621 "ip ospf message-digest-key <1-255> md5 KEY",
4622 "IP Information\n"
4623 "OSPF interface commands\n"
4624 "Message digest authentication password (key)\n"
4625 "Key ID\n"
4626 "Use MD5 algorithm\n"
4627 "The OSPF password (key)")
4628
4629ALIAS (ip_ospf_message_digest_key,
4630 ospf_message_digest_key_cmd,
4631 "ospf message-digest-key <1-255> md5 KEY",
4632 "OSPF interface commands\n"
4633 "Message digest authentication password (key)\n"
4634 "Key ID\n"
4635 "Use MD5 algorithm\n"
4636 "The OSPF password (key)")
4637
4638DEFUN (no_ip_ospf_message_digest_key,
4639 no_ip_ospf_message_digest_key_addr_cmd,
4640 "no ip ospf message-digest-key <1-255> A.B.C.D",
4641 NO_STR
4642 "IP Information\n"
4643 "OSPF interface commands\n"
4644 "Message digest authentication password (key)\n"
4645 "Key ID\n"
4646 "Address of interface")
4647{
4648 struct interface *ifp;
4649 struct crypt_key *ck;
4650 int key_id;
4651 struct in_addr addr;
4652 int ret;
4653 struct ospf_if_params *params;
4654
4655 ifp = vty->index;
4656 params = IF_DEF_PARAMS (ifp);
4657
4658 if (argc == 2)
4659 {
4660 ret = inet_aton(argv[1], &addr);
4661 if (!ret)
4662 {
4663 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4664 VTY_NEWLINE);
4665 return CMD_WARNING;
4666 }
4667
4668 params = ospf_lookup_if_params (ifp, addr);
4669 if (params == NULL)
4670 return CMD_SUCCESS;
4671 }
4672
4673 key_id = strtol (argv[0], NULL, 10);
4674 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4675 if (ck == NULL)
4676 {
4677 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4678 return CMD_WARNING;
4679 }
4680
4681 ospf_crypt_key_delete (params->auth_crypt, key_id);
4682
4683 if (params != IF_DEF_PARAMS (ifp))
4684 {
4685 ospf_free_if_params (ifp, addr);
4686 ospf_if_update_params (ifp, addr);
4687 }
4688
4689 return CMD_SUCCESS;
4690}
4691
4692ALIAS (no_ip_ospf_message_digest_key,
4693 no_ip_ospf_message_digest_key_cmd,
4694 "no ip ospf message-digest-key <1-255>",
4695 NO_STR
4696 "IP Information\n"
4697 "OSPF interface commands\n"
4698 "Message digest authentication password (key)\n"
4699 "Key ID\n")
4700
4701ALIAS (no_ip_ospf_message_digest_key,
4702 no_ospf_message_digest_key_cmd,
4703 "no ospf message-digest-key <1-255>",
4704 NO_STR
4705 "OSPF interface commands\n"
4706 "Message digest authentication password (key)\n"
4707 "Key ID\n")
4708
4709DEFUN (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004710 ip_ospf_cost_u32_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004711 "ip ospf cost <1-65535> A.B.C.D",
4712 "IP Information\n"
4713 "OSPF interface commands\n"
4714 "Interface cost\n"
4715 "Cost\n"
4716 "Address of interface")
4717{
4718 struct interface *ifp = vty->index;
4719 u_int32_t cost;
4720 struct in_addr addr;
4721 int ret;
4722 struct ospf_if_params *params;
4723
4724 params = IF_DEF_PARAMS (ifp);
4725
4726 cost = strtol (argv[0], NULL, 10);
4727
4728 /* cost range is <1-65535>. */
4729 if (cost < 1 || cost > 65535)
4730 {
4731 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4732 return CMD_WARNING;
4733 }
4734
4735 if (argc == 2)
4736 {
4737 ret = inet_aton(argv[1], &addr);
4738 if (!ret)
4739 {
4740 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4741 VTY_NEWLINE);
4742 return CMD_WARNING;
4743 }
4744
4745 params = ospf_get_if_params (ifp, addr);
4746 ospf_if_update_params (ifp, addr);
4747 }
4748
4749 SET_IF_PARAM (params, output_cost_cmd);
4750 params->output_cost_cmd = cost;
4751
4752 ospf_if_recalculate_output_cost (ifp);
4753
4754 return CMD_SUCCESS;
4755}
4756
4757ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004758 ip_ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004759 "ip ospf cost <1-65535>",
4760 "IP Information\n"
4761 "OSPF interface commands\n"
4762 "Interface cost\n"
4763 "Cost")
4764
4765ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004766 ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004767 "ospf cost <1-65535>",
4768 "OSPF interface commands\n"
4769 "Interface cost\n"
4770 "Cost")
4771
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004772ALIAS (ip_ospf_cost,
4773 ospf_cost_u32_inet4_cmd,
4774 "ospf cost <1-65535> A.B.C.D",
4775 "OSPF interface commands\n"
4776 "Interface cost\n"
4777 "Cost\n"
4778 "Address of interface")
4779
paul718e3742002-12-13 20:15:29 +00004780DEFUN (no_ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004781 no_ip_ospf_cost_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004782 "no ip ospf cost A.B.C.D",
4783 NO_STR
4784 "IP Information\n"
4785 "OSPF interface commands\n"
4786 "Interface cost\n"
4787 "Address of interface")
4788{
4789 struct interface *ifp = vty->index;
4790 struct in_addr addr;
4791 int ret;
4792 struct ospf_if_params *params;
4793
4794 ifp = vty->index;
4795 params = IF_DEF_PARAMS (ifp);
4796
4797 if (argc == 1)
4798 {
4799 ret = inet_aton(argv[0], &addr);
4800 if (!ret)
4801 {
4802 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4803 VTY_NEWLINE);
4804 return CMD_WARNING;
4805 }
4806
4807 params = ospf_lookup_if_params (ifp, addr);
4808 if (params == NULL)
4809 return CMD_SUCCESS;
4810 }
4811
4812 UNSET_IF_PARAM (params, output_cost_cmd);
4813
4814 if (params != IF_DEF_PARAMS (ifp))
4815 {
4816 ospf_free_if_params (ifp, addr);
4817 ospf_if_update_params (ifp, addr);
4818 }
4819
4820 ospf_if_recalculate_output_cost (ifp);
4821
4822 return CMD_SUCCESS;
4823}
4824
4825ALIAS (no_ip_ospf_cost,
4826 no_ip_ospf_cost_cmd,
4827 "no ip ospf cost",
4828 NO_STR
4829 "IP Information\n"
4830 "OSPF interface commands\n"
4831 "Interface cost\n")
4832
4833ALIAS (no_ip_ospf_cost,
4834 no_ospf_cost_cmd,
4835 "no ospf cost",
4836 NO_STR
4837 "OSPF interface commands\n"
4838 "Interface cost\n")
4839
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004840ALIAS (no_ip_ospf_cost,
4841 no_ospf_cost_inet4_cmd,
4842 "no ospf cost A.B.C.D",
4843 NO_STR
4844 "OSPF interface commands\n"
4845 "Interface cost\n"
4846 "Address of interface")
4847
Denis Ovsienko827341b2009-09-28 19:34:59 +04004848DEFUN (no_ip_ospf_cost2,
4849 no_ip_ospf_cost_u32_cmd,
4850 "no ip ospf cost <1-65535>",
4851 NO_STR
4852 "IP Information\n"
4853 "OSPF interface commands\n"
4854 "Interface cost\n"
4855 "Cost")
4856{
4857 struct interface *ifp = vty->index;
4858 struct in_addr addr;
4859 u_int32_t cost;
4860 int ret;
4861 struct ospf_if_params *params;
4862
4863 ifp = vty->index;
4864 params = IF_DEF_PARAMS (ifp);
4865
4866 /* According to the semantics we are mimicking "no ip ospf cost N" is
4867 * always treated as "no ip ospf cost" regardless of the actual value
4868 * of N already configured for the interface. Thus the first argument
4869 * is always checked to be a number, but is ignored after that.
4870 */
4871 cost = strtol (argv[0], NULL, 10);
4872 if (cost < 1 || cost > 65535)
4873 {
4874 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4875 return CMD_WARNING;
4876 }
4877
4878 if (argc == 2)
4879 {
4880 ret = inet_aton(argv[1], &addr);
4881 if (!ret)
4882 {
4883 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4884 VTY_NEWLINE);
4885 return CMD_WARNING;
4886 }
4887
4888 params = ospf_lookup_if_params (ifp, addr);
4889 if (params == NULL)
4890 return CMD_SUCCESS;
4891 }
4892
4893 UNSET_IF_PARAM (params, output_cost_cmd);
4894
4895 if (params != IF_DEF_PARAMS (ifp))
4896 {
4897 ospf_free_if_params (ifp, addr);
4898 ospf_if_update_params (ifp, addr);
4899 }
4900
4901 ospf_if_recalculate_output_cost (ifp);
4902
4903 return CMD_SUCCESS;
4904}
4905
4906ALIAS (no_ip_ospf_cost2,
4907 no_ospf_cost_u32_cmd,
4908 "no ospf cost <1-65535>",
4909 NO_STR
4910 "OSPF interface commands\n"
4911 "Interface cost\n"
4912 "Cost")
4913
4914ALIAS (no_ip_ospf_cost2,
4915 no_ip_ospf_cost_u32_inet4_cmd,
4916 "no ip ospf cost <1-65535> A.B.C.D",
4917 NO_STR
4918 "IP Information\n"
4919 "OSPF interface commands\n"
4920 "Interface cost\n"
4921 "Cost\n"
4922 "Address of interface")
4923
4924ALIAS (no_ip_ospf_cost2,
4925 no_ospf_cost_u32_inet4_cmd,
4926 "no ospf cost <1-65535> A.B.C.D",
4927 NO_STR
4928 "OSPF interface commands\n"
4929 "Interface cost\n"
4930 "Cost\n"
4931 "Address of interface")
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004932
paul4dadc292005-05-06 21:37:42 +00004933static void
paul718e3742002-12-13 20:15:29 +00004934ospf_nbr_timer_update (struct ospf_interface *oi)
4935{
4936 struct route_node *rn;
4937 struct ospf_neighbor *nbr;
4938
4939 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4940 if ((nbr = rn->info))
4941 {
4942 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4943 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4944 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4945 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4946 }
4947}
4948
paulf9ad9372005-10-21 00:45:17 +00004949static int
4950ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4951 const char *nbr_str,
4952 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004953{
4954 struct interface *ifp = vty->index;
4955 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004956 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004957 struct in_addr addr;
4958 int ret;
4959 struct ospf_if_params *params;
4960 struct ospf_interface *oi;
4961 struct route_node *rn;
4962
4963 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004964
4965 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004966 {
paulf9ad9372005-10-21 00:45:17 +00004967 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004968 if (!ret)
4969 {
4970 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4971 VTY_NEWLINE);
4972 return CMD_WARNING;
4973 }
4974
4975 params = ospf_get_if_params (ifp, addr);
4976 ospf_if_update_params (ifp, addr);
4977 }
4978
paulf9ad9372005-10-21 00:45:17 +00004979 if (interval_str)
4980 {
4981 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4982 1, 65535);
4983
4984 /* reset fast_hello too, just to be sure */
4985 UNSET_IF_PARAM (params, fast_hello);
4986 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4987 }
4988 else if (fast_hello_str)
4989 {
4990 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4991 1, 10);
4992 /* 1s dead-interval with sub-second hellos desired */
4993 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4994 SET_IF_PARAM (params, fast_hello);
4995 params->fast_hello = hellomult;
4996 }
4997 else
4998 {
4999 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5000 VTY_NEWLINE);
5001 return CMD_WARNING;
5002 }
5003
paul718e3742002-12-13 20:15:29 +00005004 SET_IF_PARAM (params, v_wait);
5005 params->v_wait = seconds;
5006
5007 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00005008 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005009 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005010 struct ospf *ospf;
5011 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005012 {
5013 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5014 if (oi)
5015 ospf_nbr_timer_update (oi);
5016 }
paul718e3742002-12-13 20:15:29 +00005017 }
5018 else
5019 {
5020 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5021 if ((oi = rn->info))
5022 ospf_nbr_timer_update (oi);
5023 }
5024
5025 return CMD_SUCCESS;
5026}
5027
paulf9ad9372005-10-21 00:45:17 +00005028
5029DEFUN (ip_ospf_dead_interval,
5030 ip_ospf_dead_interval_addr_cmd,
5031 "ip ospf dead-interval <1-65535> A.B.C.D",
5032 "IP Information\n"
5033 "OSPF interface commands\n"
5034 "Interval after which a neighbor is declared dead\n"
5035 "Seconds\n"
5036 "Address of interface\n")
5037{
5038 if (argc == 2)
5039 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5040 else
5041 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5042}
5043
paul718e3742002-12-13 20:15:29 +00005044ALIAS (ip_ospf_dead_interval,
5045 ip_ospf_dead_interval_cmd,
5046 "ip ospf dead-interval <1-65535>",
5047 "IP Information\n"
5048 "OSPF interface commands\n"
5049 "Interval after which a neighbor is declared dead\n"
5050 "Seconds\n")
5051
5052ALIAS (ip_ospf_dead_interval,
5053 ospf_dead_interval_cmd,
5054 "ospf dead-interval <1-65535>",
5055 "OSPF interface commands\n"
5056 "Interval after which a neighbor is declared dead\n"
5057 "Seconds\n")
5058
paulf9ad9372005-10-21 00:45:17 +00005059DEFUN (ip_ospf_dead_interval_minimal,
5060 ip_ospf_dead_interval_minimal_addr_cmd,
5061 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5062 "IP Information\n"
5063 "OSPF interface commands\n"
5064 "Interval after which a neighbor is declared dead\n"
5065 "Minimal 1s dead-interval with fast sub-second hellos\n"
5066 "Hello multiplier factor\n"
5067 "Number of Hellos to send each second\n"
5068 "Address of interface\n")
5069{
5070 if (argc == 2)
5071 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5072 else
5073 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5074}
5075
5076ALIAS (ip_ospf_dead_interval_minimal,
5077 ip_ospf_dead_interval_minimal_cmd,
5078 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5079 "IP Information\n"
5080 "OSPF interface commands\n"
5081 "Interval after which a neighbor is declared dead\n"
5082 "Minimal 1s dead-interval with fast sub-second hellos\n"
5083 "Hello multiplier factor\n"
5084 "Number of Hellos to send each second\n")
5085
paul718e3742002-12-13 20:15:29 +00005086DEFUN (no_ip_ospf_dead_interval,
5087 no_ip_ospf_dead_interval_addr_cmd,
5088 "no ip ospf dead-interval A.B.C.D",
5089 NO_STR
5090 "IP Information\n"
5091 "OSPF interface commands\n"
5092 "Interval after which a neighbor is declared dead\n"
5093 "Address of interface")
5094{
5095 struct interface *ifp = vty->index;
5096 struct in_addr addr;
5097 int ret;
5098 struct ospf_if_params *params;
5099 struct ospf_interface *oi;
5100 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00005101
paul718e3742002-12-13 20:15:29 +00005102 ifp = vty->index;
5103 params = IF_DEF_PARAMS (ifp);
5104
5105 if (argc == 1)
5106 {
5107 ret = inet_aton(argv[0], &addr);
5108 if (!ret)
5109 {
5110 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5111 VTY_NEWLINE);
5112 return CMD_WARNING;
5113 }
5114
5115 params = ospf_lookup_if_params (ifp, addr);
5116 if (params == NULL)
5117 return CMD_SUCCESS;
5118 }
5119
5120 UNSET_IF_PARAM (params, v_wait);
5121 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00005122
5123 UNSET_IF_PARAM (params, fast_hello);
5124 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5125
paul718e3742002-12-13 20:15:29 +00005126 if (params != IF_DEF_PARAMS (ifp))
5127 {
5128 ospf_free_if_params (ifp, addr);
5129 ospf_if_update_params (ifp, addr);
5130 }
5131
5132 /* Update timer values in neighbor structure. */
5133 if (argc == 1)
5134 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005135 struct ospf *ospf;
5136
5137 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005138 {
5139 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5140 if (oi)
5141 ospf_nbr_timer_update (oi);
5142 }
paul718e3742002-12-13 20:15:29 +00005143 }
5144 else
5145 {
5146 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5147 if ((oi = rn->info))
5148 ospf_nbr_timer_update (oi);
5149 }
5150
5151 return CMD_SUCCESS;
5152}
5153
5154ALIAS (no_ip_ospf_dead_interval,
5155 no_ip_ospf_dead_interval_cmd,
5156 "no ip ospf dead-interval",
5157 NO_STR
5158 "IP Information\n"
5159 "OSPF interface commands\n"
5160 "Interval after which a neighbor is declared dead\n")
5161
5162ALIAS (no_ip_ospf_dead_interval,
5163 no_ospf_dead_interval_cmd,
5164 "no ospf dead-interval",
5165 NO_STR
5166 "OSPF interface commands\n"
5167 "Interval after which a neighbor is declared dead\n")
5168
5169DEFUN (ip_ospf_hello_interval,
5170 ip_ospf_hello_interval_addr_cmd,
5171 "ip ospf hello-interval <1-65535> A.B.C.D",
5172 "IP Information\n"
5173 "OSPF interface commands\n"
5174 "Time between HELLO packets\n"
5175 "Seconds\n"
5176 "Address of interface")
5177{
5178 struct interface *ifp = vty->index;
5179 u_int32_t seconds;
5180 struct in_addr addr;
5181 int ret;
5182 struct ospf_if_params *params;
5183
5184 params = IF_DEF_PARAMS (ifp);
5185
5186 seconds = strtol (argv[0], NULL, 10);
5187
5188 /* HelloInterval range is <1-65535>. */
5189 if (seconds < 1 || seconds > 65535)
5190 {
5191 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5192 return CMD_WARNING;
5193 }
5194
5195 if (argc == 2)
5196 {
5197 ret = inet_aton(argv[1], &addr);
5198 if (!ret)
5199 {
5200 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5201 VTY_NEWLINE);
5202 return CMD_WARNING;
5203 }
5204
5205 params = ospf_get_if_params (ifp, addr);
5206 ospf_if_update_params (ifp, addr);
5207 }
5208
paulf9ad9372005-10-21 00:45:17 +00005209 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005210 params->v_hello = seconds;
5211
5212 return CMD_SUCCESS;
5213}
5214
5215ALIAS (ip_ospf_hello_interval,
5216 ip_ospf_hello_interval_cmd,
5217 "ip ospf hello-interval <1-65535>",
5218 "IP Information\n"
5219 "OSPF interface commands\n"
5220 "Time between HELLO packets\n"
5221 "Seconds\n")
5222
5223ALIAS (ip_ospf_hello_interval,
5224 ospf_hello_interval_cmd,
5225 "ospf hello-interval <1-65535>",
5226 "OSPF interface commands\n"
5227 "Time between HELLO packets\n"
5228 "Seconds\n")
5229
5230DEFUN (no_ip_ospf_hello_interval,
5231 no_ip_ospf_hello_interval_addr_cmd,
5232 "no ip ospf hello-interval A.B.C.D",
5233 NO_STR
5234 "IP Information\n"
5235 "OSPF interface commands\n"
5236 "Time between HELLO packets\n"
5237 "Address of interface")
5238{
5239 struct interface *ifp = vty->index;
5240 struct in_addr addr;
5241 int ret;
5242 struct ospf_if_params *params;
5243
5244 ifp = vty->index;
5245 params = IF_DEF_PARAMS (ifp);
5246
5247 if (argc == 1)
5248 {
5249 ret = inet_aton(argv[0], &addr);
5250 if (!ret)
5251 {
5252 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5253 VTY_NEWLINE);
5254 return CMD_WARNING;
5255 }
5256
5257 params = ospf_lookup_if_params (ifp, addr);
5258 if (params == NULL)
5259 return CMD_SUCCESS;
5260 }
5261
5262 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005263 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005264
5265 if (params != IF_DEF_PARAMS (ifp))
5266 {
5267 ospf_free_if_params (ifp, addr);
5268 ospf_if_update_params (ifp, addr);
5269 }
5270
5271 return CMD_SUCCESS;
5272}
5273
5274ALIAS (no_ip_ospf_hello_interval,
5275 no_ip_ospf_hello_interval_cmd,
5276 "no ip ospf hello-interval",
5277 NO_STR
5278 "IP Information\n"
5279 "OSPF interface commands\n"
5280 "Time between HELLO packets\n")
5281
5282ALIAS (no_ip_ospf_hello_interval,
5283 no_ospf_hello_interval_cmd,
5284 "no ospf hello-interval",
5285 NO_STR
5286 "OSPF interface commands\n"
5287 "Time between HELLO packets\n")
5288
5289DEFUN (ip_ospf_network,
5290 ip_ospf_network_cmd,
5291 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5292 "IP Information\n"
5293 "OSPF interface commands\n"
5294 "Network type\n"
5295 "Specify OSPF broadcast multi-access network\n"
5296 "Specify OSPF NBMA network\n"
5297 "Specify OSPF point-to-multipoint network\n"
5298 "Specify OSPF point-to-point network\n")
5299{
5300 struct interface *ifp = vty->index;
5301 int old_type = IF_DEF_PARAMS (ifp)->type;
5302 struct route_node *rn;
5303
5304 if (strncmp (argv[0], "b", 1) == 0)
5305 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5306 else if (strncmp (argv[0], "n", 1) == 0)
5307 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5308 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5309 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5310 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5311 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5312
5313 if (IF_DEF_PARAMS (ifp)->type == old_type)
5314 return CMD_SUCCESS;
5315
5316 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5317
5318 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5319 {
5320 struct ospf_interface *oi = rn->info;
5321
5322 if (!oi)
5323 continue;
5324
5325 oi->type = IF_DEF_PARAMS (ifp)->type;
5326
5327 if (oi->state > ISM_Down)
5328 {
5329 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5330 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5331 }
5332 }
5333
5334 return CMD_SUCCESS;
5335}
5336
5337ALIAS (ip_ospf_network,
5338 ospf_network_cmd,
5339 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5340 "OSPF interface commands\n"
5341 "Network type\n"
5342 "Specify OSPF broadcast multi-access network\n"
5343 "Specify OSPF NBMA network\n"
5344 "Specify OSPF point-to-multipoint network\n"
5345 "Specify OSPF point-to-point network\n")
5346
5347DEFUN (no_ip_ospf_network,
5348 no_ip_ospf_network_cmd,
5349 "no ip ospf network",
5350 NO_STR
5351 "IP Information\n"
5352 "OSPF interface commands\n"
5353 "Network type\n")
5354{
5355 struct interface *ifp = vty->index;
5356 int old_type = IF_DEF_PARAMS (ifp)->type;
5357 struct route_node *rn;
5358
ajsbc18d612004-12-15 15:07:19 +00005359 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005360
5361 if (IF_DEF_PARAMS (ifp)->type == old_type)
5362 return CMD_SUCCESS;
5363
5364 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5365 {
5366 struct ospf_interface *oi = rn->info;
5367
5368 if (!oi)
5369 continue;
5370
5371 oi->type = IF_DEF_PARAMS (ifp)->type;
5372
5373 if (oi->state > ISM_Down)
5374 {
5375 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5376 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5377 }
5378 }
5379
5380 return CMD_SUCCESS;
5381}
5382
5383ALIAS (no_ip_ospf_network,
5384 no_ospf_network_cmd,
5385 "no ospf network",
5386 NO_STR
5387 "OSPF interface commands\n"
5388 "Network type\n")
5389
5390DEFUN (ip_ospf_priority,
5391 ip_ospf_priority_addr_cmd,
5392 "ip ospf priority <0-255> A.B.C.D",
5393 "IP Information\n"
5394 "OSPF interface commands\n"
5395 "Router priority\n"
5396 "Priority\n"
5397 "Address of interface")
5398{
5399 struct interface *ifp = vty->index;
5400 u_int32_t priority;
5401 struct route_node *rn;
5402 struct in_addr addr;
5403 int ret;
5404 struct ospf_if_params *params;
5405
5406 params = IF_DEF_PARAMS (ifp);
5407
5408 priority = strtol (argv[0], NULL, 10);
5409
5410 /* Router Priority range is <0-255>. */
5411 if (priority < 0 || priority > 255)
5412 {
5413 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5414 return CMD_WARNING;
5415 }
5416
5417 if (argc == 2)
5418 {
5419 ret = inet_aton(argv[1], &addr);
5420 if (!ret)
5421 {
5422 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5423 VTY_NEWLINE);
5424 return CMD_WARNING;
5425 }
5426
5427 params = ospf_get_if_params (ifp, addr);
5428 ospf_if_update_params (ifp, addr);
5429 }
5430
5431 SET_IF_PARAM (params, priority);
5432 params->priority = priority;
5433
5434 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5435 {
5436 struct ospf_interface *oi = rn->info;
5437
5438 if (!oi)
5439 continue;
5440
5441
5442 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5443 {
5444 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5445 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5446 }
5447 }
5448
5449 return CMD_SUCCESS;
5450}
5451
5452ALIAS (ip_ospf_priority,
5453 ip_ospf_priority_cmd,
5454 "ip ospf priority <0-255>",
5455 "IP Information\n"
5456 "OSPF interface commands\n"
5457 "Router priority\n"
5458 "Priority\n")
5459
5460ALIAS (ip_ospf_priority,
5461 ospf_priority_cmd,
5462 "ospf priority <0-255>",
5463 "OSPF interface commands\n"
5464 "Router priority\n"
5465 "Priority\n")
5466
5467DEFUN (no_ip_ospf_priority,
5468 no_ip_ospf_priority_addr_cmd,
5469 "no ip ospf priority A.B.C.D",
5470 NO_STR
5471 "IP Information\n"
5472 "OSPF interface commands\n"
5473 "Router priority\n"
5474 "Address of interface")
5475{
5476 struct interface *ifp = vty->index;
5477 struct route_node *rn;
5478 struct in_addr addr;
5479 int ret;
5480 struct ospf_if_params *params;
5481
5482 ifp = vty->index;
5483 params = IF_DEF_PARAMS (ifp);
5484
5485 if (argc == 1)
5486 {
5487 ret = inet_aton(argv[0], &addr);
5488 if (!ret)
5489 {
5490 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5491 VTY_NEWLINE);
5492 return CMD_WARNING;
5493 }
5494
5495 params = ospf_lookup_if_params (ifp, addr);
5496 if (params == NULL)
5497 return CMD_SUCCESS;
5498 }
5499
5500 UNSET_IF_PARAM (params, priority);
5501 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5502
5503 if (params != IF_DEF_PARAMS (ifp))
5504 {
5505 ospf_free_if_params (ifp, addr);
5506 ospf_if_update_params (ifp, addr);
5507 }
5508
5509 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5510 {
5511 struct ospf_interface *oi = rn->info;
5512
5513 if (!oi)
5514 continue;
5515
5516
5517 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5518 {
5519 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5520 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5521 }
5522 }
5523
5524 return CMD_SUCCESS;
5525}
5526
5527ALIAS (no_ip_ospf_priority,
5528 no_ip_ospf_priority_cmd,
5529 "no ip ospf priority",
5530 NO_STR
5531 "IP Information\n"
5532 "OSPF interface commands\n"
5533 "Router priority\n")
5534
5535ALIAS (no_ip_ospf_priority,
5536 no_ospf_priority_cmd,
5537 "no ospf priority",
5538 NO_STR
5539 "OSPF interface commands\n"
5540 "Router priority\n")
5541
5542DEFUN (ip_ospf_retransmit_interval,
5543 ip_ospf_retransmit_interval_addr_cmd,
5544 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5545 "IP Information\n"
5546 "OSPF interface commands\n"
5547 "Time between retransmitting lost link state advertisements\n"
5548 "Seconds\n"
5549 "Address of interface")
5550{
5551 struct interface *ifp = vty->index;
5552 u_int32_t seconds;
5553 struct in_addr addr;
5554 int ret;
5555 struct ospf_if_params *params;
5556
5557 params = IF_DEF_PARAMS (ifp);
5558 seconds = strtol (argv[0], NULL, 10);
5559
5560 /* Retransmit Interval range is <3-65535>. */
5561 if (seconds < 3 || seconds > 65535)
5562 {
5563 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5564 return CMD_WARNING;
5565 }
5566
5567
5568 if (argc == 2)
5569 {
5570 ret = inet_aton(argv[1], &addr);
5571 if (!ret)
5572 {
5573 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5574 VTY_NEWLINE);
5575 return CMD_WARNING;
5576 }
5577
5578 params = ospf_get_if_params (ifp, addr);
5579 ospf_if_update_params (ifp, addr);
5580 }
5581
5582 SET_IF_PARAM (params, retransmit_interval);
5583 params->retransmit_interval = seconds;
5584
5585 return CMD_SUCCESS;
5586}
5587
5588ALIAS (ip_ospf_retransmit_interval,
5589 ip_ospf_retransmit_interval_cmd,
5590 "ip ospf retransmit-interval <3-65535>",
5591 "IP Information\n"
5592 "OSPF interface commands\n"
5593 "Time between retransmitting lost link state advertisements\n"
5594 "Seconds\n")
5595
5596ALIAS (ip_ospf_retransmit_interval,
5597 ospf_retransmit_interval_cmd,
5598 "ospf retransmit-interval <3-65535>",
5599 "OSPF interface commands\n"
5600 "Time between retransmitting lost link state advertisements\n"
5601 "Seconds\n")
5602
5603DEFUN (no_ip_ospf_retransmit_interval,
5604 no_ip_ospf_retransmit_interval_addr_cmd,
5605 "no ip ospf retransmit-interval A.B.C.D",
5606 NO_STR
5607 "IP Information\n"
5608 "OSPF interface commands\n"
5609 "Time between retransmitting lost link state advertisements\n"
5610 "Address of interface")
5611{
5612 struct interface *ifp = vty->index;
5613 struct in_addr addr;
5614 int ret;
5615 struct ospf_if_params *params;
5616
5617 ifp = vty->index;
5618 params = IF_DEF_PARAMS (ifp);
5619
5620 if (argc == 1)
5621 {
5622 ret = inet_aton(argv[0], &addr);
5623 if (!ret)
5624 {
5625 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5626 VTY_NEWLINE);
5627 return CMD_WARNING;
5628 }
5629
5630 params = ospf_lookup_if_params (ifp, addr);
5631 if (params == NULL)
5632 return CMD_SUCCESS;
5633 }
5634
5635 UNSET_IF_PARAM (params, retransmit_interval);
5636 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5637
5638 if (params != IF_DEF_PARAMS (ifp))
5639 {
5640 ospf_free_if_params (ifp, addr);
5641 ospf_if_update_params (ifp, addr);
5642 }
5643
5644 return CMD_SUCCESS;
5645}
5646
5647ALIAS (no_ip_ospf_retransmit_interval,
5648 no_ip_ospf_retransmit_interval_cmd,
5649 "no ip ospf retransmit-interval",
5650 NO_STR
5651 "IP Information\n"
5652 "OSPF interface commands\n"
5653 "Time between retransmitting lost link state advertisements\n")
5654
5655ALIAS (no_ip_ospf_retransmit_interval,
5656 no_ospf_retransmit_interval_cmd,
5657 "no ospf retransmit-interval",
5658 NO_STR
5659 "OSPF interface commands\n"
5660 "Time between retransmitting lost link state advertisements\n")
5661
5662DEFUN (ip_ospf_transmit_delay,
5663 ip_ospf_transmit_delay_addr_cmd,
5664 "ip ospf transmit-delay <1-65535> A.B.C.D",
5665 "IP Information\n"
5666 "OSPF interface commands\n"
5667 "Link state transmit delay\n"
5668 "Seconds\n"
5669 "Address of interface")
5670{
5671 struct interface *ifp = vty->index;
5672 u_int32_t seconds;
5673 struct in_addr addr;
5674 int ret;
5675 struct ospf_if_params *params;
5676
5677 params = IF_DEF_PARAMS (ifp);
5678 seconds = strtol (argv[0], NULL, 10);
5679
5680 /* Transmit Delay range is <1-65535>. */
5681 if (seconds < 1 || seconds > 65535)
5682 {
5683 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5684 return CMD_WARNING;
5685 }
5686
5687 if (argc == 2)
5688 {
5689 ret = inet_aton(argv[1], &addr);
5690 if (!ret)
5691 {
5692 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5693 VTY_NEWLINE);
5694 return CMD_WARNING;
5695 }
5696
5697 params = ospf_get_if_params (ifp, addr);
5698 ospf_if_update_params (ifp, addr);
5699 }
5700
5701 SET_IF_PARAM (params, transmit_delay);
5702 params->transmit_delay = seconds;
5703
5704 return CMD_SUCCESS;
5705}
5706
5707ALIAS (ip_ospf_transmit_delay,
5708 ip_ospf_transmit_delay_cmd,
5709 "ip ospf transmit-delay <1-65535>",
5710 "IP Information\n"
5711 "OSPF interface commands\n"
5712 "Link state transmit delay\n"
5713 "Seconds\n")
5714
5715ALIAS (ip_ospf_transmit_delay,
5716 ospf_transmit_delay_cmd,
5717 "ospf transmit-delay <1-65535>",
5718 "OSPF interface commands\n"
5719 "Link state transmit delay\n"
5720 "Seconds\n")
5721
5722DEFUN (no_ip_ospf_transmit_delay,
5723 no_ip_ospf_transmit_delay_addr_cmd,
5724 "no ip ospf transmit-delay A.B.C.D",
5725 NO_STR
5726 "IP Information\n"
5727 "OSPF interface commands\n"
5728 "Link state transmit delay\n"
5729 "Address of interface")
5730{
5731 struct interface *ifp = vty->index;
5732 struct in_addr addr;
5733 int ret;
5734 struct ospf_if_params *params;
5735
5736 ifp = vty->index;
5737 params = IF_DEF_PARAMS (ifp);
5738
5739 if (argc == 1)
5740 {
5741 ret = inet_aton(argv[0], &addr);
5742 if (!ret)
5743 {
5744 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5745 VTY_NEWLINE);
5746 return CMD_WARNING;
5747 }
5748
5749 params = ospf_lookup_if_params (ifp, addr);
5750 if (params == NULL)
5751 return CMD_SUCCESS;
5752 }
5753
5754 UNSET_IF_PARAM (params, transmit_delay);
5755 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5756
5757 if (params != IF_DEF_PARAMS (ifp))
5758 {
5759 ospf_free_if_params (ifp, addr);
5760 ospf_if_update_params (ifp, addr);
5761 }
5762
5763 return CMD_SUCCESS;
5764}
5765
5766ALIAS (no_ip_ospf_transmit_delay,
5767 no_ip_ospf_transmit_delay_cmd,
5768 "no ip ospf transmit-delay",
5769 NO_STR
5770 "IP Information\n"
5771 "OSPF interface commands\n"
5772 "Link state transmit delay\n")
5773
5774ALIAS (no_ip_ospf_transmit_delay,
5775 no_ospf_transmit_delay_cmd,
5776 "no ospf transmit-delay",
5777 NO_STR
5778 "OSPF interface commands\n"
5779 "Link state transmit delay\n")
5780
5781
5782DEFUN (ospf_redistribute_source_metric_type,
5783 ospf_redistribute_source_metric_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005784 "redistribute " QUAGGA_REDIST_STR_OSPFD
5785 " metric <0-16777214> metric-type (1|2) route-map WORD",
5786 REDIST_STR
5787 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005788 "Metric for redistributed routes\n"
5789 "OSPF default metric\n"
5790 "OSPF exterior metric type for redistributed routes\n"
5791 "Set OSPF External Type 1 metrics\n"
5792 "Set OSPF External Type 2 metrics\n"
5793 "Route map reference\n"
5794 "Pointer to route-map entries\n")
5795{
paul020709f2003-04-04 02:44:16 +00005796 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005797 int source;
5798 int type = -1;
5799 int metric = -1;
5800
5801 /* Get distribute source. */
David Lamparterdaca2cf2009-09-16 01:52:42 +02005802 source = proto_redistnum(AFI_IP, argv[0]);
5803 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005804 return CMD_WARNING;
5805
5806 /* Get metric value. */
5807 if (argc >= 2)
5808 if (!str2metric (argv[1], &metric))
5809 return CMD_WARNING;
5810
5811 /* Get metric type. */
5812 if (argc >= 3)
5813 if (!str2metric_type (argv[2], &type))
5814 return CMD_WARNING;
5815
5816 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005817 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005818 else
paul020709f2003-04-04 02:44:16 +00005819 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005820
paul020709f2003-04-04 02:44:16 +00005821 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005822}
5823
5824ALIAS (ospf_redistribute_source_metric_type,
5825 ospf_redistribute_source_metric_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005826 "redistribute " QUAGGA_REDIST_STR_OSPFD
5827 " metric <0-16777214> metric-type (1|2)",
5828 REDIST_STR
5829 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005830 "Metric for redistributed routes\n"
5831 "OSPF default metric\n"
5832 "OSPF exterior metric type for redistributed routes\n"
5833 "Set OSPF External Type 1 metrics\n"
5834 "Set OSPF External Type 2 metrics\n")
5835
5836ALIAS (ospf_redistribute_source_metric_type,
5837 ospf_redistribute_source_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005838 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5839 REDIST_STR
5840 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005841 "Metric for redistributed routes\n"
5842 "OSPF default metric\n")
5843
5844DEFUN (ospf_redistribute_source_type_metric,
5845 ospf_redistribute_source_type_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005846 "redistribute " QUAGGA_REDIST_STR_OSPFD
5847 " metric-type (1|2) metric <0-16777214> route-map WORD",
5848 REDIST_STR
5849 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005850 "OSPF exterior metric type for redistributed routes\n"
5851 "Set OSPF External Type 1 metrics\n"
5852 "Set OSPF External Type 2 metrics\n"
5853 "Metric for redistributed routes\n"
5854 "OSPF default metric\n"
5855 "Route map reference\n"
5856 "Pointer to route-map entries\n")
5857{
paul020709f2003-04-04 02:44:16 +00005858 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005859 int source;
5860 int type = -1;
5861 int metric = -1;
5862
5863 /* Get distribute source. */
David Lamparterdaca2cf2009-09-16 01:52:42 +02005864 source = proto_redistnum(AFI_IP, argv[0]);
5865 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005866 return CMD_WARNING;
5867
5868 /* Get metric value. */
5869 if (argc >= 2)
5870 if (!str2metric_type (argv[1], &type))
5871 return CMD_WARNING;
5872
5873 /* Get metric type. */
5874 if (argc >= 3)
5875 if (!str2metric (argv[2], &metric))
5876 return CMD_WARNING;
5877
5878 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005879 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005880 else
paul020709f2003-04-04 02:44:16 +00005881 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005882
paul020709f2003-04-04 02:44:16 +00005883 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005884}
5885
5886ALIAS (ospf_redistribute_source_type_metric,
5887 ospf_redistribute_source_type_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005888 "redistribute " QUAGGA_REDIST_STR_OSPFD
5889 " metric-type (1|2) metric <0-16777214>",
5890 REDIST_STR
5891 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005892 "OSPF exterior metric type for redistributed routes\n"
5893 "Set OSPF External Type 1 metrics\n"
5894 "Set OSPF External Type 2 metrics\n"
5895 "Metric for redistributed routes\n"
5896 "OSPF default metric\n")
5897
5898ALIAS (ospf_redistribute_source_type_metric,
5899 ospf_redistribute_source_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005900 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5901 REDIST_STR
5902 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005903 "OSPF exterior metric type for redistributed routes\n"
5904 "Set OSPF External Type 1 metrics\n"
5905 "Set OSPF External Type 2 metrics\n")
5906
5907ALIAS (ospf_redistribute_source_type_metric,
5908 ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005909 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5910 REDIST_STR
5911 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005912
5913DEFUN (ospf_redistribute_source_metric_routemap,
5914 ospf_redistribute_source_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005915 "redistribute " QUAGGA_REDIST_STR_OSPFD
5916 " metric <0-16777214> route-map WORD",
5917 REDIST_STR
5918 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005919 "Metric for redistributed routes\n"
5920 "OSPF default metric\n"
5921 "Route map reference\n"
5922 "Pointer to route-map entries\n")
5923{
paul020709f2003-04-04 02:44:16 +00005924 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005925 int source;
5926 int metric = -1;
5927
5928 /* Get distribute source. */
David Lamparterdaca2cf2009-09-16 01:52:42 +02005929 source = proto_redistnum(AFI_IP, argv[0]);
5930 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005931 return CMD_WARNING;
5932
5933 /* Get metric value. */
5934 if (argc >= 2)
5935 if (!str2metric (argv[1], &metric))
5936 return CMD_WARNING;
5937
5938 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005939 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005940 else
paul020709f2003-04-04 02:44:16 +00005941 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005942
paul020709f2003-04-04 02:44:16 +00005943 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005944}
5945
5946DEFUN (ospf_redistribute_source_type_routemap,
5947 ospf_redistribute_source_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005948 "redistribute " QUAGGA_REDIST_STR_OSPFD
5949 " metric-type (1|2) route-map WORD",
5950 REDIST_STR
5951 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005952 "OSPF exterior metric type for redistributed routes\n"
5953 "Set OSPF External Type 1 metrics\n"
5954 "Set OSPF External Type 2 metrics\n"
5955 "Route map reference\n"
5956 "Pointer to route-map entries\n")
5957{
paul020709f2003-04-04 02:44:16 +00005958 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005959 int source;
5960 int type = -1;
5961
5962 /* Get distribute source. */
David Lamparterdaca2cf2009-09-16 01:52:42 +02005963 source = proto_redistnum(AFI_IP, argv[0]);
5964 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005965 return CMD_WARNING;
5966
5967 /* Get metric value. */
5968 if (argc >= 2)
5969 if (!str2metric_type (argv[1], &type))
5970 return CMD_WARNING;
5971
5972 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005973 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005974 else
paul020709f2003-04-04 02:44:16 +00005975 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005976
paul020709f2003-04-04 02:44:16 +00005977 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005978}
5979
5980DEFUN (ospf_redistribute_source_routemap,
5981 ospf_redistribute_source_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005982 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5983 REDIST_STR
5984 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005985 "Route map reference\n"
5986 "Pointer to route-map entries\n")
5987{
paul020709f2003-04-04 02:44:16 +00005988 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005989 int source;
5990
5991 /* Get distribute source. */
David Lamparterdaca2cf2009-09-16 01:52:42 +02005992 source = proto_redistnum(AFI_IP, argv[0]);
5993 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005994 return CMD_WARNING;
5995
5996 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005997 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005998 else
paul020709f2003-04-04 02:44:16 +00005999 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006000
paul020709f2003-04-04 02:44:16 +00006001 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00006002}
6003
6004DEFUN (no_ospf_redistribute_source,
6005 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006006 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006007 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006008 REDIST_STR
6009 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006010{
paul020709f2003-04-04 02:44:16 +00006011 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006012 int source;
6013
David Lamparterdaca2cf2009-09-16 01:52:42 +02006014 source = proto_redistnum(AFI_IP, argv[0]);
6015 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006016 return CMD_WARNING;
6017
paul020709f2003-04-04 02:44:16 +00006018 ospf_routemap_unset (ospf, source);
6019 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006020}
6021
6022DEFUN (ospf_distribute_list_out,
6023 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006024 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006025 "Filter networks in routing updates\n"
6026 "Access-list name\n"
6027 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006028 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006029{
paul68980082003-03-25 05:07:42 +00006030 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006031 int source;
6032
6033 /* Get distribute source. */
David Lamparterdaca2cf2009-09-16 01:52:42 +02006034 source = proto_redistnum(AFI_IP, argv[0]);
6035 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006036 return CMD_WARNING;
6037
paul68980082003-03-25 05:07:42 +00006038 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006039}
6040
6041DEFUN (no_ospf_distribute_list_out,
6042 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006043 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006044 NO_STR
6045 "Filter networks in routing updates\n"
6046 "Access-list name\n"
6047 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006048 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006049{
paul68980082003-03-25 05:07:42 +00006050 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006051 int source;
6052
David Lamparterdaca2cf2009-09-16 01:52:42 +02006053 source = proto_redistnum(AFI_IP, argv[0]);
6054 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006055 return CMD_WARNING;
6056
paul68980082003-03-25 05:07:42 +00006057 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006058}
6059
6060/* Default information originate. */
6061DEFUN (ospf_default_information_originate_metric_type_routemap,
6062 ospf_default_information_originate_metric_type_routemap_cmd,
6063 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
6064 "Control distribution of default information\n"
6065 "Distribute a default route\n"
6066 "OSPF default metric\n"
6067 "OSPF metric\n"
6068 "OSPF metric type for default routes\n"
6069 "Set OSPF External Type 1 metrics\n"
6070 "Set OSPF External Type 2 metrics\n"
6071 "Route map reference\n"
6072 "Pointer to route-map entries\n")
6073{
paul020709f2003-04-04 02:44:16 +00006074 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006075 int type = -1;
6076 int metric = -1;
6077
6078 /* Get metric value. */
6079 if (argc >= 1)
6080 if (!str2metric (argv[0], &metric))
6081 return CMD_WARNING;
6082
6083 /* Get metric type. */
6084 if (argc >= 2)
6085 if (!str2metric_type (argv[1], &type))
6086 return CMD_WARNING;
6087
6088 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006089 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006090 else
paul020709f2003-04-04 02:44:16 +00006091 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006092
paul020709f2003-04-04 02:44:16 +00006093 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6094 type, metric);
paul718e3742002-12-13 20:15:29 +00006095}
6096
6097ALIAS (ospf_default_information_originate_metric_type_routemap,
6098 ospf_default_information_originate_metric_type_cmd,
6099 "default-information originate metric <0-16777214> metric-type (1|2)",
6100 "Control distribution of default information\n"
6101 "Distribute a default route\n"
6102 "OSPF default metric\n"
6103 "OSPF metric\n"
6104 "OSPF metric type for default routes\n"
6105 "Set OSPF External Type 1 metrics\n"
6106 "Set OSPF External Type 2 metrics\n")
6107
6108ALIAS (ospf_default_information_originate_metric_type_routemap,
6109 ospf_default_information_originate_metric_cmd,
6110 "default-information originate metric <0-16777214>",
6111 "Control distribution of default information\n"
6112 "Distribute a default route\n"
6113 "OSPF default metric\n"
6114 "OSPF metric\n")
6115
6116ALIAS (ospf_default_information_originate_metric_type_routemap,
6117 ospf_default_information_originate_cmd,
6118 "default-information originate",
6119 "Control distribution of default information\n"
6120 "Distribute a default route\n")
6121
6122/* Default information originate. */
6123DEFUN (ospf_default_information_originate_metric_routemap,
6124 ospf_default_information_originate_metric_routemap_cmd,
6125 "default-information originate metric <0-16777214> route-map WORD",
6126 "Control distribution of default information\n"
6127 "Distribute a default route\n"
6128 "OSPF default metric\n"
6129 "OSPF metric\n"
6130 "Route map reference\n"
6131 "Pointer to route-map entries\n")
6132{
paul020709f2003-04-04 02:44:16 +00006133 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006134 int metric = -1;
6135
6136 /* Get metric value. */
6137 if (argc >= 1)
6138 if (!str2metric (argv[0], &metric))
6139 return CMD_WARNING;
6140
6141 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006142 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006143 else
paul020709f2003-04-04 02:44:16 +00006144 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006145
paul020709f2003-04-04 02:44:16 +00006146 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6147 -1, metric);
paul718e3742002-12-13 20:15:29 +00006148}
6149
6150/* Default information originate. */
6151DEFUN (ospf_default_information_originate_routemap,
6152 ospf_default_information_originate_routemap_cmd,
6153 "default-information originate route-map WORD",
6154 "Control distribution of default information\n"
6155 "Distribute a default route\n"
6156 "Route map reference\n"
6157 "Pointer to route-map entries\n")
6158{
paul020709f2003-04-04 02:44:16 +00006159 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006160
paul020709f2003-04-04 02:44:16 +00006161 if (argc == 1)
6162 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6163 else
6164 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6165
6166 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00006167}
6168
6169DEFUN (ospf_default_information_originate_type_metric_routemap,
6170 ospf_default_information_originate_type_metric_routemap_cmd,
6171 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6172 "Control distribution of default information\n"
6173 "Distribute a default route\n"
6174 "OSPF metric type for default routes\n"
6175 "Set OSPF External Type 1 metrics\n"
6176 "Set OSPF External Type 2 metrics\n"
6177 "OSPF default metric\n"
6178 "OSPF metric\n"
6179 "Route map reference\n"
6180 "Pointer to route-map entries\n")
6181{
paul020709f2003-04-04 02:44:16 +00006182 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006183 int type = -1;
6184 int metric = -1;
6185
6186 /* Get metric type. */
6187 if (argc >= 1)
6188 if (!str2metric_type (argv[0], &type))
6189 return CMD_WARNING;
6190
6191 /* Get metric value. */
6192 if (argc >= 2)
6193 if (!str2metric (argv[1], &metric))
6194 return CMD_WARNING;
6195
6196 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006197 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006198 else
paul020709f2003-04-04 02:44:16 +00006199 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006200
paul020709f2003-04-04 02:44:16 +00006201 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6202 type, metric);
paul718e3742002-12-13 20:15:29 +00006203}
6204
6205ALIAS (ospf_default_information_originate_type_metric_routemap,
6206 ospf_default_information_originate_type_metric_cmd,
6207 "default-information originate metric-type (1|2) metric <0-16777214>",
6208 "Control distribution of default information\n"
6209 "Distribute a default route\n"
6210 "OSPF metric type for default routes\n"
6211 "Set OSPF External Type 1 metrics\n"
6212 "Set OSPF External Type 2 metrics\n"
6213 "OSPF default metric\n"
6214 "OSPF metric\n")
6215
6216ALIAS (ospf_default_information_originate_type_metric_routemap,
6217 ospf_default_information_originate_type_cmd,
6218 "default-information originate metric-type (1|2)",
6219 "Control distribution of default information\n"
6220 "Distribute a default route\n"
6221 "OSPF metric type for default routes\n"
6222 "Set OSPF External Type 1 metrics\n"
6223 "Set OSPF External Type 2 metrics\n")
6224
6225DEFUN (ospf_default_information_originate_type_routemap,
6226 ospf_default_information_originate_type_routemap_cmd,
6227 "default-information originate metric-type (1|2) route-map WORD",
6228 "Control distribution of default information\n"
6229 "Distribute a default route\n"
6230 "OSPF metric type for default routes\n"
6231 "Set OSPF External Type 1 metrics\n"
6232 "Set OSPF External Type 2 metrics\n"
6233 "Route map reference\n"
6234 "Pointer to route-map entries\n")
6235{
paul020709f2003-04-04 02:44:16 +00006236 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006237 int type = -1;
6238
6239 /* Get metric type. */
6240 if (argc >= 1)
6241 if (!str2metric_type (argv[0], &type))
6242 return CMD_WARNING;
6243
6244 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006245 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006246 else
paul020709f2003-04-04 02:44:16 +00006247 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006248
paul020709f2003-04-04 02:44:16 +00006249 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6250 type, -1);
paul718e3742002-12-13 20:15:29 +00006251}
6252
6253DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6254 ospf_default_information_originate_always_metric_type_routemap_cmd,
6255 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6256 "Control distribution of default information\n"
6257 "Distribute a default route\n"
6258 "Always advertise default route\n"
6259 "OSPF default metric\n"
6260 "OSPF metric\n"
6261 "OSPF metric type for default routes\n"
6262 "Set OSPF External Type 1 metrics\n"
6263 "Set OSPF External Type 2 metrics\n"
6264 "Route map reference\n"
6265 "Pointer to route-map entries\n")
6266{
paul020709f2003-04-04 02:44:16 +00006267 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006268 int type = -1;
6269 int metric = -1;
6270
6271 /* Get metric value. */
6272 if (argc >= 1)
6273 if (!str2metric (argv[0], &metric))
6274 return CMD_WARNING;
6275
6276 /* Get metric type. */
6277 if (argc >= 2)
6278 if (!str2metric_type (argv[1], &type))
6279 return CMD_WARNING;
6280
6281 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006282 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006283 else
paul020709f2003-04-04 02:44:16 +00006284 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006285
paul020709f2003-04-04 02:44:16 +00006286 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006287 type, metric);
6288}
6289
6290ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6291 ospf_default_information_originate_always_metric_type_cmd,
6292 "default-information originate always metric <0-16777214> metric-type (1|2)",
6293 "Control distribution of default information\n"
6294 "Distribute a default route\n"
6295 "Always advertise default route\n"
6296 "OSPF default metric\n"
6297 "OSPF metric\n"
6298 "OSPF metric type for default routes\n"
6299 "Set OSPF External Type 1 metrics\n"
6300 "Set OSPF External Type 2 metrics\n")
6301
6302ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6303 ospf_default_information_originate_always_metric_cmd,
6304 "default-information originate always metric <0-16777214>",
6305 "Control distribution of default information\n"
6306 "Distribute a default route\n"
6307 "Always advertise default route\n"
6308 "OSPF default metric\n"
6309 "OSPF metric\n"
6310 "OSPF metric type for default routes\n")
6311
6312ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6313 ospf_default_information_originate_always_cmd,
6314 "default-information originate always",
6315 "Control distribution of default information\n"
6316 "Distribute a default route\n"
6317 "Always advertise default route\n")
6318
6319DEFUN (ospf_default_information_originate_always_metric_routemap,
6320 ospf_default_information_originate_always_metric_routemap_cmd,
6321 "default-information originate always metric <0-16777214> route-map WORD",
6322 "Control distribution of default information\n"
6323 "Distribute a default route\n"
6324 "Always advertise default route\n"
6325 "OSPF default metric\n"
6326 "OSPF metric\n"
6327 "Route map reference\n"
6328 "Pointer to route-map entries\n")
6329{
paul020709f2003-04-04 02:44:16 +00006330 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006331 int metric = -1;
6332
6333 /* Get metric value. */
6334 if (argc >= 1)
6335 if (!str2metric (argv[0], &metric))
6336 return CMD_WARNING;
6337
6338 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006339 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006340 else
paul020709f2003-04-04 02:44:16 +00006341 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006342
paul020709f2003-04-04 02:44:16 +00006343 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6344 -1, metric);
paul718e3742002-12-13 20:15:29 +00006345}
6346
6347DEFUN (ospf_default_information_originate_always_routemap,
6348 ospf_default_information_originate_always_routemap_cmd,
6349 "default-information originate always route-map WORD",
6350 "Control distribution of default information\n"
6351 "Distribute a default route\n"
6352 "Always advertise default route\n"
6353 "Route map reference\n"
6354 "Pointer to route-map entries\n")
6355{
paul020709f2003-04-04 02:44:16 +00006356 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006357
paul020709f2003-04-04 02:44:16 +00006358 if (argc == 1)
6359 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6360 else
6361 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6362
6363 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006364}
6365
6366DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6367 ospf_default_information_originate_always_type_metric_routemap_cmd,
6368 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6369 "Control distribution of default information\n"
6370 "Distribute a default route\n"
6371 "Always advertise default route\n"
6372 "OSPF metric type for default routes\n"
6373 "Set OSPF External Type 1 metrics\n"
6374 "Set OSPF External Type 2 metrics\n"
6375 "OSPF default metric\n"
6376 "OSPF metric\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 int type = -1;
6382 int metric = -1;
6383
6384 /* Get metric type. */
6385 if (argc >= 1)
6386 if (!str2metric_type (argv[0], &type))
6387 return CMD_WARNING;
6388
6389 /* Get metric value. */
6390 if (argc >= 2)
6391 if (!str2metric (argv[1], &metric))
6392 return CMD_WARNING;
6393
6394 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006395 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006396 else
paul020709f2003-04-04 02:44:16 +00006397 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006398
paul020709f2003-04-04 02:44:16 +00006399 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006400 type, metric);
6401}
6402
6403ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6404 ospf_default_information_originate_always_type_metric_cmd,
6405 "default-information originate always metric-type (1|2) metric <0-16777214>",
6406 "Control distribution of default information\n"
6407 "Distribute a default route\n"
6408 "Always advertise default route\n"
6409 "OSPF metric type for default routes\n"
6410 "Set OSPF External Type 1 metrics\n"
6411 "Set OSPF External Type 2 metrics\n"
6412 "OSPF default metric\n"
6413 "OSPF metric\n")
6414
6415ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6416 ospf_default_information_originate_always_type_cmd,
6417 "default-information originate always metric-type (1|2)",
6418 "Control distribution of default information\n"
6419 "Distribute a default route\n"
6420 "Always advertise default route\n"
6421 "OSPF metric type for default routes\n"
6422 "Set OSPF External Type 1 metrics\n"
6423 "Set OSPF External Type 2 metrics\n")
6424
6425DEFUN (ospf_default_information_originate_always_type_routemap,
6426 ospf_default_information_originate_always_type_routemap_cmd,
6427 "default-information originate always metric-type (1|2) route-map WORD",
6428 "Control distribution of default information\n"
6429 "Distribute a default route\n"
6430 "Always advertise default route\n"
6431 "OSPF metric type for default routes\n"
6432 "Set OSPF External Type 1 metrics\n"
6433 "Set OSPF External Type 2 metrics\n"
6434 "Route map reference\n"
6435 "Pointer to route-map entries\n")
6436{
paul020709f2003-04-04 02:44:16 +00006437 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006438 int type = -1;
6439
6440 /* Get metric type. */
6441 if (argc >= 1)
6442 if (!str2metric_type (argv[0], &type))
6443 return CMD_WARNING;
6444
6445 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006446 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006447 else
paul020709f2003-04-04 02:44:16 +00006448 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006449
paul020709f2003-04-04 02:44:16 +00006450 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006451 type, -1);
6452}
6453
6454DEFUN (no_ospf_default_information_originate,
6455 no_ospf_default_information_originate_cmd,
6456 "no default-information originate",
6457 NO_STR
6458 "Control distribution of default information\n"
6459 "Distribute a default route\n")
6460{
paul68980082003-03-25 05:07:42 +00006461 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006462 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006463
6464 p.family = AF_INET;
6465 p.prefix.s_addr = 0;
6466 p.prefixlen = 0;
6467
ajs5339cfd2005-09-19 13:28:05 +00006468 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006469
6470 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6471 ospf_external_info_delete (DEFAULT_ROUTE, p);
6472 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6473 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6474 }
6475
paul020709f2003-04-04 02:44:16 +00006476 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6477 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006478}
6479
6480DEFUN (ospf_default_metric,
6481 ospf_default_metric_cmd,
6482 "default-metric <0-16777214>",
6483 "Set metric of redistributed routes\n"
6484 "Default metric\n")
6485{
paul68980082003-03-25 05:07:42 +00006486 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006487 int metric = -1;
6488
6489 if (!str2metric (argv[0], &metric))
6490 return CMD_WARNING;
6491
paul68980082003-03-25 05:07:42 +00006492 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006493
6494 return CMD_SUCCESS;
6495}
6496
6497DEFUN (no_ospf_default_metric,
6498 no_ospf_default_metric_cmd,
6499 "no default-metric",
6500 NO_STR
6501 "Set metric of redistributed routes\n")
6502{
paul68980082003-03-25 05:07:42 +00006503 struct ospf *ospf = vty->index;
6504
6505 ospf->default_metric = -1;
6506
paul718e3742002-12-13 20:15:29 +00006507 return CMD_SUCCESS;
6508}
6509
6510ALIAS (no_ospf_default_metric,
6511 no_ospf_default_metric_val_cmd,
6512 "no default-metric <0-16777214>",
6513 NO_STR
6514 "Set metric of redistributed routes\n"
6515 "Default metric\n")
6516
6517DEFUN (ospf_distance,
6518 ospf_distance_cmd,
6519 "distance <1-255>",
6520 "Define an administrative distance\n"
6521 "OSPF Administrative distance\n")
6522{
paul68980082003-03-25 05:07:42 +00006523 struct ospf *ospf = vty->index;
6524
6525 ospf->distance_all = atoi (argv[0]);
6526
paul718e3742002-12-13 20:15:29 +00006527 return CMD_SUCCESS;
6528}
6529
6530DEFUN (no_ospf_distance,
6531 no_ospf_distance_cmd,
6532 "no distance <1-255>",
6533 NO_STR
6534 "Define an administrative distance\n"
6535 "OSPF Administrative distance\n")
6536{
paul68980082003-03-25 05:07:42 +00006537 struct ospf *ospf = vty->index;
6538
6539 ospf->distance_all = 0;
6540
paul718e3742002-12-13 20:15:29 +00006541 return CMD_SUCCESS;
6542}
6543
6544DEFUN (no_ospf_distance_ospf,
6545 no_ospf_distance_ospf_cmd,
6546 "no distance ospf",
6547 NO_STR
6548 "Define an administrative distance\n"
6549 "OSPF Administrative distance\n"
6550 "OSPF Distance\n")
6551{
paul68980082003-03-25 05:07:42 +00006552 struct ospf *ospf = vty->index;
6553
6554 ospf->distance_intra = 0;
6555 ospf->distance_inter = 0;
6556 ospf->distance_external = 0;
6557
paul718e3742002-12-13 20:15:29 +00006558 return CMD_SUCCESS;
6559}
6560
6561DEFUN (ospf_distance_ospf_intra,
6562 ospf_distance_ospf_intra_cmd,
6563 "distance ospf intra-area <1-255>",
6564 "Define an administrative distance\n"
6565 "OSPF Administrative distance\n"
6566 "Intra-area routes\n"
6567 "Distance for intra-area routes\n")
6568{
paul68980082003-03-25 05:07:42 +00006569 struct ospf *ospf = vty->index;
6570
6571 ospf->distance_intra = atoi (argv[0]);
6572
paul718e3742002-12-13 20:15:29 +00006573 return CMD_SUCCESS;
6574}
6575
6576DEFUN (ospf_distance_ospf_intra_inter,
6577 ospf_distance_ospf_intra_inter_cmd,
6578 "distance ospf intra-area <1-255> inter-area <1-255>",
6579 "Define an administrative distance\n"
6580 "OSPF Administrative distance\n"
6581 "Intra-area routes\n"
6582 "Distance for intra-area routes\n"
6583 "Inter-area routes\n"
6584 "Distance for inter-area routes\n")
6585{
paul68980082003-03-25 05:07:42 +00006586 struct ospf *ospf = vty->index;
6587
6588 ospf->distance_intra = atoi (argv[0]);
6589 ospf->distance_inter = atoi (argv[1]);
6590
paul718e3742002-12-13 20:15:29 +00006591 return CMD_SUCCESS;
6592}
6593
6594DEFUN (ospf_distance_ospf_intra_external,
6595 ospf_distance_ospf_intra_external_cmd,
6596 "distance ospf intra-area <1-255> external <1-255>",
6597 "Define an administrative distance\n"
6598 "OSPF Administrative distance\n"
6599 "Intra-area routes\n"
6600 "Distance for intra-area routes\n"
6601 "External routes\n"
6602 "Distance for external routes\n")
6603{
paul68980082003-03-25 05:07:42 +00006604 struct ospf *ospf = vty->index;
6605
6606 ospf->distance_intra = atoi (argv[0]);
6607 ospf->distance_external = atoi (argv[1]);
6608
paul718e3742002-12-13 20:15:29 +00006609 return CMD_SUCCESS;
6610}
6611
6612DEFUN (ospf_distance_ospf_intra_inter_external,
6613 ospf_distance_ospf_intra_inter_external_cmd,
6614 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6615 "Define an administrative distance\n"
6616 "OSPF Administrative distance\n"
6617 "Intra-area routes\n"
6618 "Distance for intra-area routes\n"
6619 "Inter-area routes\n"
6620 "Distance for inter-area routes\n"
6621 "External routes\n"
6622 "Distance for external routes\n")
6623{
paul68980082003-03-25 05:07:42 +00006624 struct ospf *ospf = vty->index;
6625
6626 ospf->distance_intra = atoi (argv[0]);
6627 ospf->distance_inter = atoi (argv[1]);
6628 ospf->distance_external = atoi (argv[2]);
6629
paul718e3742002-12-13 20:15:29 +00006630 return CMD_SUCCESS;
6631}
6632
6633DEFUN (ospf_distance_ospf_intra_external_inter,
6634 ospf_distance_ospf_intra_external_inter_cmd,
6635 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6636 "Define an administrative distance\n"
6637 "OSPF Administrative distance\n"
6638 "Intra-area routes\n"
6639 "Distance for intra-area routes\n"
6640 "External routes\n"
6641 "Distance for external routes\n"
6642 "Inter-area routes\n"
6643 "Distance for inter-area routes\n")
6644{
paul68980082003-03-25 05:07:42 +00006645 struct ospf *ospf = vty->index;
6646
6647 ospf->distance_intra = atoi (argv[0]);
6648 ospf->distance_external = atoi (argv[1]);
6649 ospf->distance_inter = atoi (argv[2]);
6650
paul718e3742002-12-13 20:15:29 +00006651 return CMD_SUCCESS;
6652}
6653
6654DEFUN (ospf_distance_ospf_inter,
6655 ospf_distance_ospf_inter_cmd,
6656 "distance ospf inter-area <1-255>",
6657 "Define an administrative distance\n"
6658 "OSPF Administrative distance\n"
6659 "Inter-area routes\n"
6660 "Distance for inter-area routes\n")
6661{
paul68980082003-03-25 05:07:42 +00006662 struct ospf *ospf = vty->index;
6663
6664 ospf->distance_inter = atoi (argv[0]);
6665
paul718e3742002-12-13 20:15:29 +00006666 return CMD_SUCCESS;
6667}
6668
6669DEFUN (ospf_distance_ospf_inter_intra,
6670 ospf_distance_ospf_inter_intra_cmd,
6671 "distance ospf inter-area <1-255> intra-area <1-255>",
6672 "Define an administrative distance\n"
6673 "OSPF Administrative distance\n"
6674 "Inter-area routes\n"
6675 "Distance for inter-area routes\n"
6676 "Intra-area routes\n"
6677 "Distance for intra-area routes\n")
6678{
paul68980082003-03-25 05:07:42 +00006679 struct ospf *ospf = vty->index;
6680
6681 ospf->distance_inter = atoi (argv[0]);
6682 ospf->distance_intra = atoi (argv[1]);
6683
paul718e3742002-12-13 20:15:29 +00006684 return CMD_SUCCESS;
6685}
6686
6687DEFUN (ospf_distance_ospf_inter_external,
6688 ospf_distance_ospf_inter_external_cmd,
6689 "distance ospf inter-area <1-255> external <1-255>",
6690 "Define an administrative distance\n"
6691 "OSPF Administrative distance\n"
6692 "Inter-area routes\n"
6693 "Distance for inter-area routes\n"
6694 "External routes\n"
6695 "Distance for external routes\n")
6696{
paul68980082003-03-25 05:07:42 +00006697 struct ospf *ospf = vty->index;
6698
6699 ospf->distance_inter = atoi (argv[0]);
6700 ospf->distance_external = atoi (argv[1]);
6701
paul718e3742002-12-13 20:15:29 +00006702 return CMD_SUCCESS;
6703}
6704
6705DEFUN (ospf_distance_ospf_inter_intra_external,
6706 ospf_distance_ospf_inter_intra_external_cmd,
6707 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6708 "Define an administrative distance\n"
6709 "OSPF Administrative distance\n"
6710 "Inter-area routes\n"
6711 "Distance for inter-area routes\n"
6712 "Intra-area routes\n"
6713 "Distance for intra-area routes\n"
6714 "External routes\n"
6715 "Distance for external routes\n")
6716{
paul68980082003-03-25 05:07:42 +00006717 struct ospf *ospf = vty->index;
6718
6719 ospf->distance_inter = atoi (argv[0]);
6720 ospf->distance_intra = atoi (argv[1]);
6721 ospf->distance_external = atoi (argv[2]);
6722
paul718e3742002-12-13 20:15:29 +00006723 return CMD_SUCCESS;
6724}
6725
6726DEFUN (ospf_distance_ospf_inter_external_intra,
6727 ospf_distance_ospf_inter_external_intra_cmd,
6728 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6729 "Define an administrative distance\n"
6730 "OSPF Administrative distance\n"
6731 "Inter-area routes\n"
6732 "Distance for inter-area routes\n"
6733 "External routes\n"
6734 "Distance for external routes\n"
6735 "Intra-area routes\n"
6736 "Distance for intra-area routes\n")
6737{
paul68980082003-03-25 05:07:42 +00006738 struct ospf *ospf = vty->index;
6739
6740 ospf->distance_inter = atoi (argv[0]);
6741 ospf->distance_external = atoi (argv[1]);
6742 ospf->distance_intra = atoi (argv[2]);
6743
paul718e3742002-12-13 20:15:29 +00006744 return CMD_SUCCESS;
6745}
6746
6747DEFUN (ospf_distance_ospf_external,
6748 ospf_distance_ospf_external_cmd,
6749 "distance ospf external <1-255>",
6750 "Define an administrative distance\n"
6751 "OSPF Administrative distance\n"
6752 "External routes\n"
6753 "Distance for external routes\n")
6754{
paul68980082003-03-25 05:07:42 +00006755 struct ospf *ospf = vty->index;
6756
6757 ospf->distance_external = atoi (argv[0]);
6758
paul718e3742002-12-13 20:15:29 +00006759 return CMD_SUCCESS;
6760}
6761
6762DEFUN (ospf_distance_ospf_external_intra,
6763 ospf_distance_ospf_external_intra_cmd,
6764 "distance ospf external <1-255> intra-area <1-255>",
6765 "Define an administrative distance\n"
6766 "OSPF Administrative distance\n"
6767 "External routes\n"
6768 "Distance for external routes\n"
6769 "Intra-area routes\n"
6770 "Distance for intra-area routes\n")
6771{
paul68980082003-03-25 05:07:42 +00006772 struct ospf *ospf = vty->index;
6773
6774 ospf->distance_external = atoi (argv[0]);
6775 ospf->distance_intra = atoi (argv[1]);
6776
paul718e3742002-12-13 20:15:29 +00006777 return CMD_SUCCESS;
6778}
6779
6780DEFUN (ospf_distance_ospf_external_inter,
6781 ospf_distance_ospf_external_inter_cmd,
6782 "distance ospf external <1-255> inter-area <1-255>",
6783 "Define an administrative distance\n"
6784 "OSPF Administrative distance\n"
6785 "External routes\n"
6786 "Distance for external routes\n"
6787 "Inter-area routes\n"
6788 "Distance for inter-area routes\n")
6789{
paul68980082003-03-25 05:07:42 +00006790 struct ospf *ospf = vty->index;
6791
6792 ospf->distance_external = atoi (argv[0]);
6793 ospf->distance_inter = atoi (argv[1]);
6794
paul718e3742002-12-13 20:15:29 +00006795 return CMD_SUCCESS;
6796}
6797
6798DEFUN (ospf_distance_ospf_external_intra_inter,
6799 ospf_distance_ospf_external_intra_inter_cmd,
6800 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6801 "Define an administrative distance\n"
6802 "OSPF Administrative distance\n"
6803 "External routes\n"
6804 "Distance for external routes\n"
6805 "Intra-area routes\n"
6806 "Distance for intra-area routes\n"
6807 "Inter-area routes\n"
6808 "Distance for inter-area routes\n")
6809{
paul68980082003-03-25 05:07:42 +00006810 struct ospf *ospf = vty->index;
6811
6812 ospf->distance_external = atoi (argv[0]);
6813 ospf->distance_intra = atoi (argv[1]);
6814 ospf->distance_inter = atoi (argv[2]);
6815
paul718e3742002-12-13 20:15:29 +00006816 return CMD_SUCCESS;
6817}
6818
6819DEFUN (ospf_distance_ospf_external_inter_intra,
6820 ospf_distance_ospf_external_inter_intra_cmd,
6821 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6822 "Define an administrative distance\n"
6823 "OSPF Administrative distance\n"
6824 "External routes\n"
6825 "Distance for external routes\n"
6826 "Inter-area routes\n"
6827 "Distance for inter-area routes\n"
6828 "Intra-area routes\n"
6829 "Distance for intra-area routes\n")
6830{
paul68980082003-03-25 05:07:42 +00006831 struct ospf *ospf = vty->index;
6832
6833 ospf->distance_external = atoi (argv[0]);
6834 ospf->distance_inter = atoi (argv[1]);
6835 ospf->distance_intra = atoi (argv[2]);
6836
paul718e3742002-12-13 20:15:29 +00006837 return CMD_SUCCESS;
6838}
6839
6840DEFUN (ospf_distance_source,
6841 ospf_distance_source_cmd,
6842 "distance <1-255> A.B.C.D/M",
6843 "Administrative distance\n"
6844 "Distance value\n"
6845 "IP source prefix\n")
6846{
paul020709f2003-04-04 02:44:16 +00006847 struct ospf *ospf = vty->index;
6848
6849 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006850
paul718e3742002-12-13 20:15:29 +00006851 return CMD_SUCCESS;
6852}
6853
6854DEFUN (no_ospf_distance_source,
6855 no_ospf_distance_source_cmd,
6856 "no distance <1-255> A.B.C.D/M",
6857 NO_STR
6858 "Administrative distance\n"
6859 "Distance value\n"
6860 "IP source prefix\n")
6861{
paul020709f2003-04-04 02:44:16 +00006862 struct ospf *ospf = vty->index;
6863
6864 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6865
paul718e3742002-12-13 20:15:29 +00006866 return CMD_SUCCESS;
6867}
6868
6869DEFUN (ospf_distance_source_access_list,
6870 ospf_distance_source_access_list_cmd,
6871 "distance <1-255> A.B.C.D/M WORD",
6872 "Administrative distance\n"
6873 "Distance value\n"
6874 "IP source prefix\n"
6875 "Access list name\n")
6876{
paul020709f2003-04-04 02:44:16 +00006877 struct ospf *ospf = vty->index;
6878
6879 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6880
paul718e3742002-12-13 20:15:29 +00006881 return CMD_SUCCESS;
6882}
6883
6884DEFUN (no_ospf_distance_source_access_list,
6885 no_ospf_distance_source_access_list_cmd,
6886 "no distance <1-255> A.B.C.D/M WORD",
6887 NO_STR
6888 "Administrative distance\n"
6889 "Distance value\n"
6890 "IP source prefix\n"
6891 "Access list name\n")
6892{
paul020709f2003-04-04 02:44:16 +00006893 struct ospf *ospf = vty->index;
6894
6895 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6896
paul718e3742002-12-13 20:15:29 +00006897 return CMD_SUCCESS;
6898}
6899
vincentba682532005-09-29 13:52:57 +00006900DEFUN (ip_ospf_mtu_ignore,
6901 ip_ospf_mtu_ignore_addr_cmd,
6902 "ip ospf mtu-ignore A.B.C.D",
6903 "IP Information\n"
6904 "OSPF interface commands\n"
6905 "Disable mtu mismatch detection\n"
6906 "Address of interface")
6907{
6908 struct interface *ifp = vty->index;
6909 struct in_addr addr;
6910 int ret;
6911
6912 struct ospf_if_params *params;
6913 params = IF_DEF_PARAMS (ifp);
6914
6915 if (argc == 1)
6916 {
6917 ret = inet_aton(argv[0], &addr);
6918 if (!ret)
6919 {
6920 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6921 VTY_NEWLINE);
6922 return CMD_WARNING;
6923 }
6924 params = ospf_get_if_params (ifp, addr);
6925 ospf_if_update_params (ifp, addr);
6926 }
6927 params->mtu_ignore = 1;
6928 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6929 SET_IF_PARAM (params, mtu_ignore);
6930 else
6931 {
6932 UNSET_IF_PARAM (params, mtu_ignore);
6933 if (params != IF_DEF_PARAMS (ifp))
6934 {
6935 ospf_free_if_params (ifp, addr);
6936 ospf_if_update_params (ifp, addr);
6937 }
6938 }
6939 return CMD_SUCCESS;
6940}
6941
6942ALIAS (ip_ospf_mtu_ignore,
6943 ip_ospf_mtu_ignore_cmd,
6944 "ip ospf mtu-ignore",
6945 "IP Information\n"
6946 "OSPF interface commands\n"
6947 "Disable mtu mismatch detection\n")
6948
6949
6950DEFUN (no_ip_ospf_mtu_ignore,
6951 no_ip_ospf_mtu_ignore_addr_cmd,
6952 "no ip ospf mtu-ignore A.B.C.D",
6953 "IP Information\n"
6954 "OSPF interface commands\n"
6955 "Disable mtu mismatch detection\n"
6956 "Address of interface")
6957{
6958 struct interface *ifp = vty->index;
6959 struct in_addr addr;
6960 int ret;
6961
6962 struct ospf_if_params *params;
6963 params = IF_DEF_PARAMS (ifp);
6964
6965 if (argc == 1)
6966 {
6967 ret = inet_aton(argv[0], &addr);
6968 if (!ret)
6969 {
6970 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6971 VTY_NEWLINE);
6972 return CMD_WARNING;
6973 }
6974 params = ospf_get_if_params (ifp, addr);
6975 ospf_if_update_params (ifp, addr);
6976 }
6977 params->mtu_ignore = 0;
6978 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6979 SET_IF_PARAM (params, mtu_ignore);
6980 else
6981 {
6982 UNSET_IF_PARAM (params, mtu_ignore);
6983 if (params != IF_DEF_PARAMS (ifp))
6984 {
6985 ospf_free_if_params (ifp, addr);
6986 ospf_if_update_params (ifp, addr);
6987 }
6988 }
6989 return CMD_SUCCESS;
6990}
6991
6992ALIAS (no_ip_ospf_mtu_ignore,
6993 no_ip_ospf_mtu_ignore_cmd,
6994 "no ip ospf mtu-ignore",
6995 "IP Information\n"
6996 "OSPF interface commands\n"
6997 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00006998
6999DEFUN (ospf_max_metric_router_lsa_admin,
7000 ospf_max_metric_router_lsa_admin_cmd,
7001 "max-metric router-lsa administrative",
7002 "OSPF maximum / infinite-distance metric\n"
7003 "Advertise own Router-LSA with infinite distance (stub router)\n"
7004 "Administratively applied, for an indefinite period\n")
7005{
7006 struct listnode *ln;
7007 struct ospf_area *area;
7008 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00007009
paul88d6cf32005-10-29 12:50:09 +00007010 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7011 {
7012 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7013
7014 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
7015 ospf_router_lsa_timer_add (area);
7016 }
7017 return CMD_SUCCESS;
7018}
7019
7020DEFUN (no_ospf_max_metric_router_lsa_admin,
7021 no_ospf_max_metric_router_lsa_admin_cmd,
7022 "no max-metric router-lsa administrative",
7023 NO_STR
7024 "OSPF maximum / infinite-distance metric\n"
7025 "Advertise own Router-LSA with infinite distance (stub router)\n"
7026 "Administratively applied, for an indefinite period\n")
7027{
7028 struct listnode *ln;
7029 struct ospf_area *area;
7030 struct ospf *ospf = vty->index;
7031
7032 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7033 {
7034 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7035
7036 /* Don't trample on the start-up stub timer */
7037 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
7038 && !area->t_stub_router)
7039 {
7040 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
7041 ospf_router_lsa_timer_add (area);
7042 }
7043 }
7044 return CMD_SUCCESS;
7045}
7046
7047DEFUN (ospf_max_metric_router_lsa_startup,
7048 ospf_max_metric_router_lsa_startup_cmd,
7049 "max-metric router-lsa on-startup <5-86400>",
7050 "OSPF maximum / infinite-distance metric\n"
7051 "Advertise own Router-LSA with infinite distance (stub router)\n"
7052 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7053 "Time (seconds) to advertise self as stub-router\n")
7054{
7055 unsigned int seconds;
7056 struct ospf *ospf = vty->index;
7057
7058 if (argc != 1)
7059 {
7060 vty_out (vty, "%% Must supply stub-router period");
7061 return CMD_WARNING;
7062 }
7063
7064 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
7065
7066 ospf->stub_router_startup_time = seconds;
7067
7068 return CMD_SUCCESS;
7069}
7070
7071DEFUN (no_ospf_max_metric_router_lsa_startup,
7072 no_ospf_max_metric_router_lsa_startup_cmd,
7073 "no max-metric router-lsa on-startup",
7074 NO_STR
7075 "OSPF maximum / infinite-distance metric\n"
7076 "Advertise own Router-LSA with infinite distance (stub router)\n"
7077 "Automatically advertise stub Router-LSA on startup of OSPF\n")
7078{
7079 struct listnode *ln;
7080 struct ospf_area *area;
7081 struct ospf *ospf = vty->index;
7082
7083 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7084
7085 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7086 {
7087 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
7088 OSPF_TIMER_OFF (area->t_stub_router);
7089
7090 /* Don't trample on admin stub routed */
7091 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7092 {
7093 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
7094 ospf_router_lsa_timer_add (area);
7095 }
7096 }
7097 return CMD_SUCCESS;
7098}
7099
7100DEFUN (ospf_max_metric_router_lsa_shutdown,
7101 ospf_max_metric_router_lsa_shutdown_cmd,
7102 "max-metric router-lsa on-shutdown <5-86400>",
7103 "OSPF maximum / infinite-distance metric\n"
7104 "Advertise own Router-LSA with infinite distance (stub router)\n"
7105 "Advertise stub-router prior to full shutdown of OSPF\n"
7106 "Time (seconds) to wait till full shutdown\n")
7107{
7108 unsigned int seconds;
7109 struct ospf *ospf = vty->index;
7110
7111 if (argc != 1)
7112 {
7113 vty_out (vty, "%% Must supply stub-router shutdown period");
7114 return CMD_WARNING;
7115 }
7116
7117 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
7118
7119 ospf->stub_router_shutdown_time = seconds;
7120
7121 return CMD_SUCCESS;
7122}
7123
7124DEFUN (no_ospf_max_metric_router_lsa_shutdown,
7125 no_ospf_max_metric_router_lsa_shutdown_cmd,
7126 "no max-metric router-lsa on-shutdown",
7127 NO_STR
7128 "OSPF maximum / infinite-distance metric\n"
7129 "Advertise own Router-LSA with infinite distance (stub router)\n"
7130 "Advertise stub-router prior to full shutdown of OSPF\n")
7131{
7132 struct ospf *ospf = vty->index;
7133
7134 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7135
7136 return CMD_SUCCESS;
7137}
7138
7139static void
7140config_write_stub_router (struct vty *vty, struct ospf *ospf)
7141{
7142 struct listnode *ln;
7143 struct ospf_area *area;
7144
7145 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7146 vty_out (vty, " max-metric router-lsa on-startup %u%s",
7147 ospf->stub_router_startup_time, VTY_NEWLINE);
7148 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7149 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
7150 ospf->stub_router_shutdown_time, VTY_NEWLINE);
7151 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7152 {
7153 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7154 {
7155 vty_out (vty, " max-metric router-lsa administrative%s",
7156 VTY_NEWLINE);
7157 break;
7158 }
7159 }
7160 return;
7161}
7162
paul4dadc292005-05-06 21:37:42 +00007163static void
paul718e3742002-12-13 20:15:29 +00007164show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7165{
7166 struct route_node *rn;
7167 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007168 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007169 struct ospf_path *path;
7170
7171 vty_out (vty, "============ OSPF network routing table ============%s",
7172 VTY_NEWLINE);
7173
7174 for (rn = route_top (rt); rn; rn = route_next (rn))
7175 if ((or = rn->info) != NULL)
7176 {
7177 char buf1[19];
7178 snprintf (buf1, 19, "%s/%d",
7179 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7180
7181 switch (or->path_type)
7182 {
7183 case OSPF_PATH_INTER_AREA:
7184 if (or->type == OSPF_DESTINATION_NETWORK)
7185 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7186 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7187 else if (or->type == OSPF_DESTINATION_DISCARD)
7188 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7189 break;
7190 case OSPF_PATH_INTRA_AREA:
7191 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7192 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7193 break;
7194 default:
7195 break;
7196 }
7197
7198 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007199 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007200 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007201 if (if_lookup_by_index(path->ifindex))
paul96735ee2003-08-10 02:51:22 +00007202 {
7203 if (path->nexthop.s_addr == 0)
7204 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007205 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007206 else
7207 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007208 inet_ntoa (path->nexthop),
7209 ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007210 }
7211 }
paul718e3742002-12-13 20:15:29 +00007212 }
7213 vty_out (vty, "%s", VTY_NEWLINE);
7214}
7215
paul4dadc292005-05-06 21:37:42 +00007216static void
paul718e3742002-12-13 20:15:29 +00007217show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7218{
7219 struct route_node *rn;
7220 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007221 struct listnode *pnode;
7222 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007223 struct ospf_path *path;
7224
7225 vty_out (vty, "============ OSPF router routing table =============%s",
7226 VTY_NEWLINE);
7227 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7228 if (rn->info)
7229 {
7230 int flag = 0;
7231
7232 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7233
paul1eb8ef22005-04-07 07:30:20 +00007234 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7235 {
7236 if (flag++)
7237 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007238
paul1eb8ef22005-04-07 07:30:20 +00007239 /* Show path. */
7240 vty_out (vty, "%s [%d] area: %s",
7241 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7242 or->cost, inet_ntoa (or->u.std.area_id));
7243 /* Show flags. */
7244 vty_out (vty, "%s%s%s",
7245 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7246 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7247 VTY_NEWLINE);
7248
7249 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7250 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007251 if (if_lookup_by_index(path->ifindex))
hasso54bedb52005-08-17 13:31:47 +00007252 {
7253 if (path->nexthop.s_addr == 0)
7254 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007255 "", ifindex2ifname (path->ifindex),
7256 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007257 else
7258 vty_out (vty, "%24s via %s, %s%s", "",
7259 inet_ntoa (path->nexthop),
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007260 ifindex2ifname (path->ifindex),
7261 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007262 }
paul1eb8ef22005-04-07 07:30:20 +00007263 }
7264 }
paul718e3742002-12-13 20:15:29 +00007265 }
7266 vty_out (vty, "%s", VTY_NEWLINE);
7267}
7268
paul4dadc292005-05-06 21:37:42 +00007269static void
paul718e3742002-12-13 20:15:29 +00007270show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7271{
7272 struct route_node *rn;
7273 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007274 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007275 struct ospf_path *path;
7276
7277 vty_out (vty, "============ OSPF external routing table ===========%s",
7278 VTY_NEWLINE);
7279 for (rn = route_top (rt); rn; rn = route_next (rn))
7280 if ((er = rn->info) != NULL)
7281 {
7282 char buf1[19];
7283 snprintf (buf1, 19, "%s/%d",
7284 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7285
7286 switch (er->path_type)
7287 {
7288 case OSPF_PATH_TYPE1_EXTERNAL:
7289 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7290 er->cost, er->u.ext.tag, VTY_NEWLINE);
7291 break;
7292 case OSPF_PATH_TYPE2_EXTERNAL:
7293 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7294 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7295 break;
7296 }
7297
paul1eb8ef22005-04-07 07:30:20 +00007298 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007299 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007300 if (if_lookup_by_index(path->ifindex))
paul718e3742002-12-13 20:15:29 +00007301 {
7302 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007303 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007304 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007305 else
7306 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007307 inet_ntoa (path->nexthop),
7308 ifindex2ifname (path->ifindex),
paul96735ee2003-08-10 02:51:22 +00007309 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007310 }
7311 }
7312 }
7313 vty_out (vty, "%s", VTY_NEWLINE);
7314}
7315
paul718e3742002-12-13 20:15:29 +00007316DEFUN (show_ip_ospf_border_routers,
7317 show_ip_ospf_border_routers_cmd,
7318 "show ip ospf border-routers",
7319 SHOW_STR
7320 IP_STR
7321 "show all the ABR's and ASBR's\n"
7322 "for this area\n")
7323{
paul020709f2003-04-04 02:44:16 +00007324 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007325
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007326 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007327 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007328 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007329 return CMD_SUCCESS;
7330 }
7331
paul68980082003-03-25 05:07:42 +00007332 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007333 {
7334 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7335 return CMD_SUCCESS;
7336 }
7337
7338 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007339 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007340
7341 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007342 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007343
7344 return CMD_SUCCESS;
7345}
paul718e3742002-12-13 20:15:29 +00007346
7347DEFUN (show_ip_ospf_route,
7348 show_ip_ospf_route_cmd,
7349 "show ip ospf route",
7350 SHOW_STR
7351 IP_STR
7352 "OSPF information\n"
7353 "OSPF routing table\n")
7354{
paul020709f2003-04-04 02:44:16 +00007355 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007356
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007357 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007358 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007359 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007360 return CMD_SUCCESS;
7361 }
7362
paul68980082003-03-25 05:07:42 +00007363 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007364 {
7365 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7366 return CMD_SUCCESS;
7367 }
7368
7369 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007370 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007371
7372 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007373 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007374
7375 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007376 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007377
7378 return CMD_SUCCESS;
7379}
7380
7381
hassoeb1ce602004-10-08 08:17:22 +00007382const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007383{
7384 "unknown",
7385 "standard",
7386 "ibm",
7387 "cisco",
7388 "shortcut"
7389};
7390
hassoeb1ce602004-10-08 08:17:22 +00007391const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007392{
7393 "default",
7394 "enable",
7395 "disable"
7396};
7397
7398
paul4dadc292005-05-06 21:37:42 +00007399static void
paul718e3742002-12-13 20:15:29 +00007400area_id2str (char *buf, int length, struct ospf_area *area)
7401{
7402 memset (buf, 0, length);
7403
7404 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7405 strncpy (buf, inet_ntoa (area->area_id), length);
7406 else
7407 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7408}
7409
7410
hassoeb1ce602004-10-08 08:17:22 +00007411const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007412{
7413 "unknown", /* should never be used. */
7414 "point-to-point",
7415 "broadcast",
7416 "non-broadcast",
7417 "point-to-multipoint",
7418 "virtual-link", /* should never be used. */
7419 "loopback"
7420};
7421
7422/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007423static int
paul718e3742002-12-13 20:15:29 +00007424config_write_interface (struct vty *vty)
7425{
hasso52dc7ee2004-09-23 19:18:23 +00007426 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007427 struct interface *ifp;
7428 struct crypt_key *ck;
7429 int write = 0;
7430 struct route_node *rn = NULL;
7431 struct ospf_if_params *params;
7432
paul1eb8ef22005-04-07 07:30:20 +00007433 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007434 {
paul718e3742002-12-13 20:15:29 +00007435 if (memcmp (ifp->name, "VLINK", 5) == 0)
7436 continue;
7437
7438 vty_out (vty, "!%s", VTY_NEWLINE);
7439 vty_out (vty, "interface %s%s", ifp->name,
7440 VTY_NEWLINE);
7441 if (ifp->desc)
7442 vty_out (vty, " description %s%s", ifp->desc,
7443 VTY_NEWLINE);
7444
7445 write++;
7446
7447 params = IF_DEF_PARAMS (ifp);
7448
7449 do {
7450 /* Interface Network print. */
7451 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007452 params->type != OSPF_IFTYPE_LOOPBACK)
7453 {
ajsbc18d612004-12-15 15:07:19 +00007454 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007455 {
7456 vty_out (vty, " ip ospf network %s",
7457 ospf_int_type_str[params->type]);
7458 if (params != IF_DEF_PARAMS (ifp))
7459 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7460 vty_out (vty, "%s", VTY_NEWLINE);
7461 }
paul718e3742002-12-13 20:15:29 +00007462 }
7463
7464 /* OSPF interface authentication print */
7465 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7466 params->auth_type != OSPF_AUTH_NOTSET)
7467 {
hassoeb1ce602004-10-08 08:17:22 +00007468 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007469
7470 /* Translation tables are not that much help here due to syntax
7471 of the simple option */
7472 switch (params->auth_type)
7473 {
7474
7475 case OSPF_AUTH_NULL:
7476 auth_str = " null";
7477 break;
7478
7479 case OSPF_AUTH_SIMPLE:
7480 auth_str = "";
7481 break;
7482
7483 case OSPF_AUTH_CRYPTOGRAPHIC:
7484 auth_str = " message-digest";
7485 break;
7486
7487 default:
7488 auth_str = "";
7489 break;
7490 }
7491
7492 vty_out (vty, " ip ospf authentication%s", auth_str);
7493 if (params != IF_DEF_PARAMS (ifp))
7494 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7495 vty_out (vty, "%s", VTY_NEWLINE);
7496 }
7497
7498 /* Simple Authentication Password print. */
7499 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7500 params->auth_simple[0] != '\0')
7501 {
7502 vty_out (vty, " ip ospf authentication-key %s",
7503 params->auth_simple);
7504 if (params != IF_DEF_PARAMS (ifp))
7505 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7506 vty_out (vty, "%s", VTY_NEWLINE);
7507 }
7508
7509 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007510 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007511 {
paul718e3742002-12-13 20:15:29 +00007512 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7513 ck->key_id, ck->auth_key);
7514 if (params != IF_DEF_PARAMS (ifp))
7515 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7516 vty_out (vty, "%s", VTY_NEWLINE);
7517 }
7518
7519 /* Interface Output Cost print. */
7520 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7521 {
7522 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7523 if (params != IF_DEF_PARAMS (ifp))
7524 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7525 vty_out (vty, "%s", VTY_NEWLINE);
7526 }
7527
7528 /* Hello Interval print. */
7529 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7530 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7531 {
7532 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7533 if (params != IF_DEF_PARAMS (ifp))
7534 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7535 vty_out (vty, "%s", VTY_NEWLINE);
7536 }
7537
7538
7539 /* Router Dead Interval print. */
7540 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7541 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7542 {
paulf9ad9372005-10-21 00:45:17 +00007543 vty_out (vty, " ip ospf dead-interval ");
7544
7545 /* fast hello ? */
7546 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7547 vty_out (vty, "minimal hello-multiplier %d",
7548 params->fast_hello);
7549 else
7550 vty_out (vty, "%u", params->v_wait);
7551
paul718e3742002-12-13 20:15:29 +00007552 if (params != IF_DEF_PARAMS (ifp))
7553 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7554 vty_out (vty, "%s", VTY_NEWLINE);
7555 }
7556
7557 /* Router Priority print. */
7558 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7559 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7560 {
7561 vty_out (vty, " ip ospf priority %u", params->priority);
7562 if (params != IF_DEF_PARAMS (ifp))
7563 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7564 vty_out (vty, "%s", VTY_NEWLINE);
7565 }
7566
7567 /* Retransmit Interval print. */
7568 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7569 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7570 {
7571 vty_out (vty, " ip ospf retransmit-interval %u",
7572 params->retransmit_interval);
7573 if (params != IF_DEF_PARAMS (ifp))
7574 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7575 vty_out (vty, "%s", VTY_NEWLINE);
7576 }
7577
7578 /* Transmit Delay print. */
7579 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7580 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7581 {
7582 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7583 if (params != IF_DEF_PARAMS (ifp))
7584 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7585 vty_out (vty, "%s", VTY_NEWLINE);
7586 }
7587
vincentba682532005-09-29 13:52:57 +00007588 /* MTU ignore print. */
7589 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7590 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7591 {
7592 if (params->mtu_ignore == 0)
7593 vty_out (vty, " no ip ospf mtu-ignore");
7594 else
7595 vty_out (vty, " ip ospf mtu-ignore");
7596 if (params != IF_DEF_PARAMS (ifp))
7597 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7598 vty_out (vty, "%s", VTY_NEWLINE);
7599 }
7600
7601
paul718e3742002-12-13 20:15:29 +00007602 while (1)
7603 {
7604 if (rn == NULL)
7605 rn = route_top (IF_OIFS_PARAMS (ifp));
7606 else
7607 rn = route_next (rn);
7608
7609 if (rn == NULL)
7610 break;
7611 params = rn->info;
7612 if (params != NULL)
7613 break;
7614 }
7615 } while (rn);
7616
7617#ifdef HAVE_OPAQUE_LSA
7618 ospf_opaque_config_write_if (vty, ifp);
7619#endif /* HAVE_OPAQUE_LSA */
7620 }
7621
7622 return write;
7623}
7624
paul4dadc292005-05-06 21:37:42 +00007625static int
paul68980082003-03-25 05:07:42 +00007626config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007627{
7628 struct route_node *rn;
7629 u_char buf[INET_ADDRSTRLEN];
7630
7631 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007632 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007633 if (rn->info)
7634 {
7635 struct ospf_network *n = rn->info;
7636
7637 memset (buf, 0, INET_ADDRSTRLEN);
7638
7639 /* Create Area ID string by specified Area ID format. */
7640 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007641 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007642 else
hassoc9e52be2004-09-26 16:09:34 +00007643 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007644 (unsigned long int) ntohl (n->area_id.s_addr));
7645
7646 /* Network print. */
7647 vty_out (vty, " network %s/%d area %s%s",
7648 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7649 buf, VTY_NEWLINE);
7650 }
7651
7652 return 0;
7653}
7654
paul4dadc292005-05-06 21:37:42 +00007655static int
paul68980082003-03-25 05:07:42 +00007656config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007657{
hasso52dc7ee2004-09-23 19:18:23 +00007658 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007659 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007660 u_char buf[INET_ADDRSTRLEN];
7661
7662 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007663 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007664 {
paul718e3742002-12-13 20:15:29 +00007665 struct route_node *rn1;
7666
hassoc9e52be2004-09-26 16:09:34 +00007667 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007668
7669 if (area->auth_type != OSPF_AUTH_NULL)
7670 {
7671 if (area->auth_type == OSPF_AUTH_SIMPLE)
7672 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7673 else
7674 vty_out (vty, " area %s authentication message-digest%s",
7675 buf, VTY_NEWLINE);
7676 }
7677
7678 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7679 vty_out (vty, " area %s shortcut %s%s", buf,
7680 ospf_shortcut_mode_str[area->shortcut_configured],
7681 VTY_NEWLINE);
7682
7683 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007684 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007685 )
7686 {
paulb0a053b2003-06-22 09:04:47 +00007687 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007688 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007689 else if (area->external_routing == OSPF_AREA_NSSA)
7690 {
7691 vty_out (vty, " area %s nssa", buf);
7692 switch (area->NSSATranslatorRole)
7693 {
7694 case OSPF_NSSA_ROLE_NEVER:
7695 vty_out (vty, " translate-never");
7696 break;
7697 case OSPF_NSSA_ROLE_ALWAYS:
7698 vty_out (vty, " translate-always");
7699 break;
7700 case OSPF_NSSA_ROLE_CANDIDATE:
7701 default:
7702 vty_out (vty, " translate-candidate");
7703 }
7704 }
paul718e3742002-12-13 20:15:29 +00007705
7706 if (area->no_summary)
7707 vty_out (vty, " no-summary");
7708
7709 vty_out (vty, "%s", VTY_NEWLINE);
7710
7711 if (area->default_cost != 1)
7712 vty_out (vty, " area %s default-cost %d%s", buf,
7713 area->default_cost, VTY_NEWLINE);
7714 }
7715
7716 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7717 if (rn1->info)
7718 {
7719 struct ospf_area_range *range = rn1->info;
7720
7721 vty_out (vty, " area %s range %s/%d", buf,
7722 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7723
paul6c835672004-10-11 11:00:30 +00007724 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007725 vty_out (vty, " cost %d", range->cost_config);
7726
7727 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7728 vty_out (vty, " not-advertise");
7729
7730 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7731 vty_out (vty, " substitute %s/%d",
7732 inet_ntoa (range->subst_addr), range->subst_masklen);
7733
7734 vty_out (vty, "%s", VTY_NEWLINE);
7735 }
7736
7737 if (EXPORT_NAME (area))
7738 vty_out (vty, " area %s export-list %s%s", buf,
7739 EXPORT_NAME (area), VTY_NEWLINE);
7740
7741 if (IMPORT_NAME (area))
7742 vty_out (vty, " area %s import-list %s%s", buf,
7743 IMPORT_NAME (area), VTY_NEWLINE);
7744
7745 if (PREFIX_NAME_IN (area))
7746 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7747 PREFIX_NAME_IN (area), VTY_NEWLINE);
7748
7749 if (PREFIX_NAME_OUT (area))
7750 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7751 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7752 }
7753
7754 return 0;
7755}
7756
paul4dadc292005-05-06 21:37:42 +00007757static int
paul68980082003-03-25 05:07:42 +00007758config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007759{
7760 struct ospf_nbr_nbma *nbr_nbma;
7761 struct route_node *rn;
7762
7763 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007764 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007765 if ((nbr_nbma = rn->info))
7766 {
7767 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7768
7769 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7770 vty_out (vty, " priority %d", nbr_nbma->priority);
7771
7772 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7773 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7774
7775 vty_out (vty, "%s", 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_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007783{
hasso52dc7ee2004-09-23 19:18:23 +00007784 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007785 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007786 u_char buf[INET_ADDRSTRLEN];
7787
7788 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007789 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007790 {
hasso52dc7ee2004-09-23 19:18:23 +00007791 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007792 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007793 struct ospf_interface *oi;
7794
7795 if (vl_data != NULL)
7796 {
7797 memset (buf, 0, INET_ADDRSTRLEN);
7798
7799 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007800 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007801 else
hassoc9e52be2004-09-26 16:09:34 +00007802 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007803 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7804 oi = vl_data->vl_oi;
7805
7806 /* timers */
7807 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7808 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7809 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7810 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7811 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7812 buf,
7813 inet_ntoa (vl_data->vl_peer),
7814 OSPF_IF_PARAM (oi, v_hello),
7815 OSPF_IF_PARAM (oi, retransmit_interval),
7816 OSPF_IF_PARAM (oi, transmit_delay),
7817 OSPF_IF_PARAM (oi, v_wait),
7818 VTY_NEWLINE);
7819 else
7820 vty_out (vty, " area %s virtual-link %s%s", buf,
7821 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7822 /* Auth key */
7823 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7824 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7825 buf,
7826 inet_ntoa (vl_data->vl_peer),
7827 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7828 VTY_NEWLINE);
7829 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007830 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7831 n2, ck))
7832 vty_out (vty, " area %s virtual-link %s"
7833 " message-digest-key %d md5 %s%s",
7834 buf,
7835 inet_ntoa (vl_data->vl_peer),
7836 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007837
7838 }
7839 }
7840
7841 return 0;
7842}
7843
7844
paul4dadc292005-05-06 21:37:42 +00007845static int
paul68980082003-03-25 05:07:42 +00007846config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007847{
7848 int type;
7849
7850 /* redistribute print. */
7851 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7852 if (type != zclient->redist_default && zclient->redist[type])
7853 {
ajsf52d13c2005-10-01 17:38:06 +00007854 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007855 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007856 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007857
paul68980082003-03-25 05:07:42 +00007858 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007859 vty_out (vty, " metric-type 1");
7860
paul020709f2003-04-04 02:44:16 +00007861 if (ROUTEMAP_NAME (ospf, type))
7862 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007863
7864 vty_out (vty, "%s", VTY_NEWLINE);
7865 }
7866
7867 return 0;
7868}
7869
paul4dadc292005-05-06 21:37:42 +00007870static int
paul68980082003-03-25 05:07:42 +00007871config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007872{
paul68980082003-03-25 05:07:42 +00007873 if (ospf->default_metric != -1)
7874 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007875 VTY_NEWLINE);
7876 return 0;
7877}
7878
paul4dadc292005-05-06 21:37:42 +00007879static int
paul68980082003-03-25 05:07:42 +00007880config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007881{
7882 int type;
7883
paul68980082003-03-25 05:07:42 +00007884 if (ospf)
paul718e3742002-12-13 20:15:29 +00007885 {
7886 /* distribute-list print. */
7887 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Denis Ovsienko4f151e52011-09-10 16:40:23 +04007888 if (DISTRIBUTE_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +00007889 vty_out (vty, " distribute-list %s out %s%s",
Denis Ovsienko4f151e52011-09-10 16:40:23 +04007890 DISTRIBUTE_NAME (ospf, type),
ajsf52d13c2005-10-01 17:38:06 +00007891 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007892
7893 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007894 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007895 {
paulc42c1772006-01-10 20:36:49 +00007896 vty_out (vty, " default-information originate");
7897 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7898 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007899
paul68980082003-03-25 05:07:42 +00007900 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007901 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007902 ospf->dmetric[DEFAULT_ROUTE].value);
7903 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007904 vty_out (vty, " metric-type 1");
7905
paul020709f2003-04-04 02:44:16 +00007906 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7907 vty_out (vty, " route-map %s",
7908 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007909
7910 vty_out (vty, "%s", VTY_NEWLINE);
7911 }
7912
7913 }
7914
7915 return 0;
7916}
7917
paul4dadc292005-05-06 21:37:42 +00007918static int
paul68980082003-03-25 05:07:42 +00007919config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007920{
7921 struct route_node *rn;
7922 struct ospf_distance *odistance;
7923
paul68980082003-03-25 05:07:42 +00007924 if (ospf->distance_all)
7925 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007926
paul68980082003-03-25 05:07:42 +00007927 if (ospf->distance_intra
7928 || ospf->distance_inter
7929 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007930 {
7931 vty_out (vty, " distance ospf");
7932
paul68980082003-03-25 05:07:42 +00007933 if (ospf->distance_intra)
7934 vty_out (vty, " intra-area %d", ospf->distance_intra);
7935 if (ospf->distance_inter)
7936 vty_out (vty, " inter-area %d", ospf->distance_inter);
7937 if (ospf->distance_external)
7938 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007939
7940 vty_out (vty, "%s", VTY_NEWLINE);
7941 }
7942
paul68980082003-03-25 05:07:42 +00007943 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007944 if ((odistance = rn->info) != NULL)
7945 {
7946 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7947 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7948 odistance->access_list ? odistance->access_list : "",
7949 VTY_NEWLINE);
7950 }
7951 return 0;
7952}
7953
7954/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007955static int
paul718e3742002-12-13 20:15:29 +00007956ospf_config_write (struct vty *vty)
7957{
paul020709f2003-04-04 02:44:16 +00007958 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007959 struct interface *ifp;
7960 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007961 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007962 int write = 0;
7963
paul020709f2003-04-04 02:44:16 +00007964 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007965 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007966 {
7967 /* `router ospf' print. */
7968 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7969
7970 write++;
7971
paul68980082003-03-25 05:07:42 +00007972 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007973 return write;
7974
7975 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007976 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007977 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007978 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007979
7980 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007981 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007982 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007983 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007984
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007985 /* log-adjacency-changes flag print. */
7986 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7987 {
7988 vty_out(vty, " log-adjacency-changes");
7989 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7990 vty_out(vty, " detail");
7991 vty_out(vty, "%s", VTY_NEWLINE);
7992 }
7993
paul718e3742002-12-13 20:15:29 +00007994 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007995 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007996 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7997
7998 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007999 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00008000 {
8001 vty_out (vty, "! Important: ensure reference bandwidth "
8002 "is consistent across all routers%s", VTY_NEWLINE);
8003 vty_out (vty, " auto-cost reference-bandwidth %d%s",
8004 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
8005 }
paul718e3742002-12-13 20:15:29 +00008006
8007 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00008008 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00008009 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
8010 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
8011 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00008012 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00008013 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00008014
8015 /* Max-metric router-lsa print */
8016 config_write_stub_router (vty, ospf);
8017
paul718e3742002-12-13 20:15:29 +00008018 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00008019 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00008020 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00008021 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008022
8023 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00008024 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008025
8026 /* passive-interface print. */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008027 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
8028 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
8029
paul1eb8ef22005-04-07 07:30:20 +00008030 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008031 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
8032 && IF_DEF_PARAMS (ifp)->passive_interface !=
8033 ospf->passive_interface_default)
8034 {
8035 vty_out (vty, " %spassive-interface %s%s",
8036 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
8037 ifp->name, VTY_NEWLINE);
8038 }
paul1eb8ef22005-04-07 07:30:20 +00008039 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008040 {
8041 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
8042 continue;
8043 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
8044 passive_interface))
8045 {
8046 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
8047 continue;
8048 }
8049 else if (oi->params->passive_interface == ospf->passive_interface_default)
8050 continue;
8051
8052 vty_out (vty, " %spassive-interface %s %s%s",
8053 oi->params->passive_interface ? "" : "no ",
paul1eb8ef22005-04-07 07:30:20 +00008054 oi->ifp->name,
8055 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008056 }
paul718e3742002-12-13 20:15:29 +00008057
8058 /* Network area print. */
paul68980082003-03-25 05:07:42 +00008059 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008060
8061 /* Area config print. */
paul68980082003-03-25 05:07:42 +00008062 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008063
8064 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00008065 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008066
8067 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00008068 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008069
8070 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00008071 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008072
8073 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00008074 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008075
8076 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00008077 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008078
8079#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00008080 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008081#endif /* HAVE_OPAQUE_LSA */
8082 }
8083
8084 return write;
8085}
8086
8087void
paul4dadc292005-05-06 21:37:42 +00008088ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00008089{
8090 /* "show ip ospf" commands. */
8091 install_element (VIEW_NODE, &show_ip_ospf_cmd);
8092 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
8093
8094 /* "show ip ospf database" commands. */
8095 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
8096 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
8097 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8098 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8099 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
8100 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
8101 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
8102 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
8103 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
8104 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8105 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8106 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
8107 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
8108 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
8109
8110 /* "show ip ospf interface" commands. */
8111 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
8112 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
8113
8114 /* "show ip ospf neighbor" commands. */
8115 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8116 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
8117 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
8118 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8119 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
8120 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
8121 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
8122 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8123 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
8124 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
8125 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8126 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
8127 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
8128 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
8129
8130 /* "show ip ospf route" commands. */
8131 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
8132 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00008133 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
8134 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00008135}
8136
8137
8138/* ospfd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008139static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00008140{
8141 INTERFACE_NODE,
8142 "%s(config-if)# ",
8143 1
8144};
8145
8146/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00008147static void
8148ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00008149{
8150 /* Install interface node. */
8151 install_node (&interface_node, config_write_interface);
8152
8153 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00008154 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008155 install_default (INTERFACE_NODE);
8156
8157 /* "description" commands. */
8158 install_element (INTERFACE_NODE, &interface_desc_cmd);
8159 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
8160
8161 /* "ip ospf authentication" commands. */
8162 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
8163 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
8164 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
8165 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
8166 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
8167 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
8168 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
8169 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
8170 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
8171 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
8172
8173 /* "ip ospf message-digest-key" commands. */
8174 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
8175 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
8176 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8177 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8178
8179 /* "ip ospf cost" commands. */
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008180 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
8181 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008182 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
8183 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008184 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008185 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8186
vincentba682532005-09-29 13:52:57 +00008187 /* "ip ospf mtu-ignore" commands. */
8188 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8189 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8190 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8191 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8192
paul718e3742002-12-13 20:15:29 +00008193 /* "ip ospf dead-interval" commands. */
8194 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8195 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008196 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8197 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00008198 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8199 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008200
paul718e3742002-12-13 20:15:29 +00008201 /* "ip ospf hello-interval" commands. */
8202 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8203 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8204 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8205 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8206
8207 /* "ip ospf network" commands. */
8208 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8209 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8210
8211 /* "ip ospf priority" commands. */
8212 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8213 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8214 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8215 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8216
8217 /* "ip ospf retransmit-interval" commands. */
8218 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8219 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8220 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8221 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8222
8223 /* "ip ospf transmit-delay" commands. */
8224 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8225 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8226 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8227 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8228
8229 /* These commands are compatibitliy for previous version. */
8230 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8231 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8232 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8233 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008234 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
8235 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008236 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008237 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
8238 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008239 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008240 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8241 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8242 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8243 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8244 install_element (INTERFACE_NODE, &ospf_network_cmd);
8245 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8246 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8247 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8248 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8249 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8250 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8251 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8252}
8253
paul4dadc292005-05-06 21:37:42 +00008254static void
8255ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008256{
8257 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8258 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8259 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8260 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8261 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8262 install_element (OSPF_NODE,
8263 &ospf_redistribute_source_metric_type_routemap_cmd);
8264 install_element (OSPF_NODE,
8265 &ospf_redistribute_source_type_metric_routemap_cmd);
8266 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8267 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8268 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8269
8270 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8271
8272 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8273 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8274
8275 install_element (OSPF_NODE,
8276 &ospf_default_information_originate_metric_type_cmd);
8277 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8278 install_element (OSPF_NODE,
8279 &ospf_default_information_originate_type_metric_cmd);
8280 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8281 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8282 install_element (OSPF_NODE,
8283 &ospf_default_information_originate_always_metric_type_cmd);
8284 install_element (OSPF_NODE,
8285 &ospf_default_information_originate_always_metric_cmd);
8286 install_element (OSPF_NODE,
8287 &ospf_default_information_originate_always_cmd);
8288 install_element (OSPF_NODE,
8289 &ospf_default_information_originate_always_type_metric_cmd);
8290 install_element (OSPF_NODE,
8291 &ospf_default_information_originate_always_type_cmd);
8292
8293 install_element (OSPF_NODE,
8294 &ospf_default_information_originate_metric_type_routemap_cmd);
8295 install_element (OSPF_NODE,
8296 &ospf_default_information_originate_metric_routemap_cmd);
8297 install_element (OSPF_NODE,
8298 &ospf_default_information_originate_routemap_cmd);
8299 install_element (OSPF_NODE,
8300 &ospf_default_information_originate_type_metric_routemap_cmd);
8301 install_element (OSPF_NODE,
8302 &ospf_default_information_originate_type_routemap_cmd);
8303 install_element (OSPF_NODE,
8304 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8305 install_element (OSPF_NODE,
8306 &ospf_default_information_originate_always_metric_routemap_cmd);
8307 install_element (OSPF_NODE,
8308 &ospf_default_information_originate_always_routemap_cmd);
8309 install_element (OSPF_NODE,
8310 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8311 install_element (OSPF_NODE,
8312 &ospf_default_information_originate_always_type_routemap_cmd);
8313
8314 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8315
8316 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8317 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8318 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8319
8320 install_element (OSPF_NODE, &ospf_distance_cmd);
8321 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8322 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8323 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8324 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8325 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8326 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8327 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8328 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8329 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8330 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8331 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8332 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8333 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8334 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8335 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8336 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8337 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8338#if 0
8339 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8340 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8341 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8342 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8343#endif /* 0 */
8344}
8345
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008346static struct cmd_node ospf_node =
paul718e3742002-12-13 20:15:29 +00008347{
8348 OSPF_NODE,
8349 "%s(config-router)# ",
8350 1
8351};
8352
8353
8354/* Install OSPF related vty commands. */
8355void
paul4dadc292005-05-06 21:37:42 +00008356ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008357{
8358 /* Install ospf top node. */
8359 install_node (&ospf_node, ospf_config_write);
8360
8361 /* "router ospf" commands. */
8362 install_element (CONFIG_NODE, &router_ospf_cmd);
8363 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8364
8365 install_default (OSPF_NODE);
8366
8367 /* "ospf router-id" commands. */
8368 install_element (OSPF_NODE, &ospf_router_id_cmd);
8369 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008370 install_element (OSPF_NODE, &router_ospf_id_cmd);
8371 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008372
8373 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008374 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8375 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008376 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
paula2c62832003-04-23 17:01:31 +00008377 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8378 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008379 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
paul718e3742002-12-13 20:15:29 +00008380
8381 /* "ospf abr-type" commands. */
8382 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8383 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8384
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008385 /* "ospf log-adjacency-changes" commands. */
8386 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8387 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8388 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8389 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8390
paul718e3742002-12-13 20:15:29 +00008391 /* "ospf rfc1583-compatible" commands. */
8392 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8393 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8394 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8395 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8396
8397 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008398 install_element (OSPF_NODE, &ospf_network_area_cmd);
8399 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008400
8401 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008402 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8403 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8404 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008405
8406 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008407 install_element (OSPF_NODE, &ospf_area_range_cmd);
8408 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8409 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8410 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8411 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8412 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8413 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8414 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8415 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8416 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8417 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008418
8419 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008420 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8421 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008422
paula2c62832003-04-23 17:01:31 +00008423 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8424 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008425
paula2c62832003-04-23 17:01:31 +00008426 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8427 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008428
paula2c62832003-04-23 17:01:31 +00008429 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8430 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008431
paula2c62832003-04-23 17:01:31 +00008432 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8433 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008434
paula2c62832003-04-23 17:01:31 +00008435 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8436 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8437 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008438
paula2c62832003-04-23 17:01:31 +00008439 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8440 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008441
paula2c62832003-04-23 17:01:31 +00008442 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8443 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008444
paula2c62832003-04-23 17:01:31 +00008445 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8446 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8447 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008448
paula2c62832003-04-23 17:01:31 +00008449 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8450 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8451 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008452
8453 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008454 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8455 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8456 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8457 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008458
paul718e3742002-12-13 20:15:29 +00008459 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008460 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8461 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8462 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8463 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8464 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8465 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008466
paula2c62832003-04-23 17:01:31 +00008467 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8468 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008469
paula2c62832003-04-23 17:01:31 +00008470 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8471 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008472
paula2c62832003-04-23 17:01:31 +00008473 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8474 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008475
paula2c62832003-04-23 17:01:31 +00008476 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8477 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008478
paula2c62832003-04-23 17:01:31 +00008479 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8480 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008481
8482 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008483 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8484 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008485 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8486 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8487
paul88d6cf32005-10-29 12:50:09 +00008488 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008489 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8490 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8491 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008492
paul88d6cf32005-10-29 12:50:09 +00008493 /* max-metric commands */
8494 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8495 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8496 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8497 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8498 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8499 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8500
8501 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008502 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8503 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008504
8505 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008506 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8507 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8508 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8509 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8510 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8511 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8512 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8513 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008514
8515 /* Init interface related vty commands. */
8516 ospf_vty_if_init ();
8517
8518 /* Init zebra related vty commands. */
8519 ospf_vty_zebra_init ();
8520}