blob: 45ddc5c4083fa5c67bea33c66ca315be855f1371 [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 Weber664711c2011-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 Weber664711c2011-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)
Andrew Certain1a61ad12012-12-04 12:50:23 -08002325 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
paul718e3742002-12-13 20:15:29 +00002326
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 }
Paul Jakma7eb5b472009-10-13 16:13:13 +01002916
2917 /* Next network-LSA sequence number we'll use, if we're elected DR */
2918 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
2919 != OSPF_INITIAL_SEQUENCE_NUMBER)
2920 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
2921 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
2922
ajsba6454e2005-02-08 15:37:30 +00002923 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002924 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2925 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2926 {
2927 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2928 vty_out (vty, " OSPFAllRouters");
2929 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2930 vty_out (vty, " OSPFDesignatedRouters");
2931 }
2932 else
ajsba6454e2005-02-08 15:37:30 +00002933 vty_out (vty, " <None>");
2934 vty_out (vty, "%s", VTY_NEWLINE);
2935
paul718e3742002-12-13 20:15:29 +00002936 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002937 vty_out (vty, " Hello ");
2938 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2939 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2940 else
2941 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2942 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2943 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002944 OSPF_IF_PARAM (oi, v_wait),
2945 OSPF_IF_PARAM (oi, retransmit_interval),
2946 VTY_NEWLINE);
2947
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002948 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002949 {
ajs649654a2005-11-16 20:17:52 +00002950 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002951 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002952 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002953 VTY_NEWLINE);
2954 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002955 else /* passive-interface is set */
paul718e3742002-12-13 20:15:29 +00002956 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2957
2958 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002959 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002960 VTY_NEWLINE);
2961 }
2962}
2963
2964DEFUN (show_ip_ospf_interface,
2965 show_ip_ospf_interface_cmd,
2966 "show ip ospf interface [INTERFACE]",
2967 SHOW_STR
2968 IP_STR
2969 "OSPF information\n"
2970 "Interface information\n"
2971 "Interface name\n")
2972{
2973 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002974 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002975 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002976
paul020709f2003-04-04 02:44:16 +00002977 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002978 if (ospf == NULL)
2979 {
2980 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2981 return CMD_SUCCESS;
2982 }
paul020709f2003-04-04 02:44:16 +00002983
paul718e3742002-12-13 20:15:29 +00002984 /* Show All Interfaces. */
2985 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002986 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2987 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002988 /* Interface name is specified. */
2989 else
2990 {
2991 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2992 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2993 else
paul68980082003-03-25 05:07:42 +00002994 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002995 }
2996
2997 return CMD_SUCCESS;
2998}
2999
paul4dadc292005-05-06 21:37:42 +00003000static void
pauld24f6e22005-10-21 09:23:12 +00003001show_ip_ospf_neighbour_header (struct vty *vty)
3002{
3003 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3004 VTY_NEWLINE,
3005 "Neighbor ID", "Pri", "State", "Dead Time",
3006 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3007 VTY_NEWLINE);
3008}
3009
3010static void
paul718e3742002-12-13 20:15:29 +00003011show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3012{
3013 struct route_node *rn;
3014 struct ospf_neighbor *nbr;
3015 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00003016 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003017
3018 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3019 if ((nbr = rn->info))
3020 /* Do not show myself. */
3021 if (nbr != oi->nbr_self)
3022 /* Down state is not shown. */
3023 if (nbr->state != NSM_Down)
3024 {
3025 ospf_nbr_state_message (nbr, msgbuf, 16);
3026
3027 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00003028 vty_out (vty, "%-15s %3d %-15s ",
3029 "-", nbr->priority,
3030 msgbuf);
3031 else
3032 vty_out (vty, "%-15s %3d %-15s ",
3033 inet_ntoa (nbr->router_id), nbr->priority,
3034 msgbuf);
3035
3036 vty_out (vty, "%9s ",
3037 ospf_timer_dump (nbr->t_inactivity, timebuf,
3038 sizeof(timebuf)));
3039
paul718e3742002-12-13 20:15:29 +00003040 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00003041 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00003042 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3043 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3044 VTY_NEWLINE);
3045 }
3046}
3047
3048DEFUN (show_ip_ospf_neighbor,
3049 show_ip_ospf_neighbor_cmd,
3050 "show ip ospf neighbor",
3051 SHOW_STR
3052 IP_STR
3053 "OSPF information\n"
3054 "Neighbor list\n")
3055{
paul020709f2003-04-04 02:44:16 +00003056 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003057 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003058 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003059
paul020709f2003-04-04 02:44:16 +00003060 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003061 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003062 {
3063 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3064 return CMD_SUCCESS;
3065 }
3066
pauld24f6e22005-10-21 09:23:12 +00003067 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003068
paul1eb8ef22005-04-07 07:30:20 +00003069 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3070 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003071
3072 return CMD_SUCCESS;
3073}
3074
3075DEFUN (show_ip_ospf_neighbor_all,
3076 show_ip_ospf_neighbor_all_cmd,
3077 "show ip ospf neighbor all",
3078 SHOW_STR
3079 IP_STR
3080 "OSPF information\n"
3081 "Neighbor list\n"
3082 "include down status neighbor\n")
3083{
Joakim Tjernlund35f89142008-07-01 16:54:07 +02003084 struct ospf *ospf = ospf_lookup ();
hasso52dc7ee2004-09-23 19:18:23 +00003085 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003086 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003087
paul68980082003-03-25 05:07:42 +00003088 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003089 {
3090 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3091 return CMD_SUCCESS;
3092 }
pauld24f6e22005-10-21 09:23:12 +00003093
3094 show_ip_ospf_neighbour_header (vty);
3095
paul1eb8ef22005-04-07 07:30:20 +00003096 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003097 {
hasso52dc7ee2004-09-23 19:18:23 +00003098 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003099 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003100
3101 show_ip_ospf_neighbor_sub (vty, oi);
3102
3103 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003104 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003105 {
paul718e3742002-12-13 20:15:29 +00003106 if (nbr_nbma->nbr == NULL
3107 || nbr_nbma->nbr->state == NSM_Down)
3108 {
pauld24f6e22005-10-21 09:23:12 +00003109 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003110 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003111 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003112 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3113 0, 0, 0, VTY_NEWLINE);
3114 }
3115 }
3116 }
3117
3118 return CMD_SUCCESS;
3119}
3120
3121DEFUN (show_ip_ospf_neighbor_int,
3122 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003123 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003124 SHOW_STR
3125 IP_STR
3126 "OSPF information\n"
3127 "Neighbor list\n"
3128 "Interface name\n")
3129{
paul020709f2003-04-04 02:44:16 +00003130 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003131 struct interface *ifp;
3132 struct route_node *rn;
3133
3134 ifp = if_lookup_by_name (argv[0]);
3135 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003136 {
hassobb5b7552005-08-21 20:01:15 +00003137 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003138 return CMD_WARNING;
3139 }
3140
paul020709f2003-04-04 02:44:16 +00003141 ospf = ospf_lookup ();
3142 if (ospf == NULL)
3143 {
3144 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3145 return CMD_SUCCESS;
3146 }
pauld24f6e22005-10-21 09:23:12 +00003147
3148 show_ip_ospf_neighbour_header (vty);
3149
hassobb5b7552005-08-21 20:01:15 +00003150 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003151 {
hassobb5b7552005-08-21 20:01:15 +00003152 struct ospf_interface *oi = rn->info;
3153
3154 if (oi == NULL)
3155 continue;
3156
paul718e3742002-12-13 20:15:29 +00003157 show_ip_ospf_neighbor_sub (vty, oi);
3158 }
3159
3160 return CMD_SUCCESS;
3161}
3162
paul4dadc292005-05-06 21:37:42 +00003163static void
paul718e3742002-12-13 20:15:29 +00003164show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3165 struct ospf_nbr_nbma *nbr_nbma)
3166{
ajs649654a2005-11-16 20:17:52 +00003167 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003168
3169 /* Show neighbor ID. */
3170 vty_out (vty, " Neighbor %s,", "-");
3171
3172 /* Show interface address. */
3173 vty_out (vty, " interface address %s%s",
3174 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3175 /* Show Area ID. */
3176 vty_out (vty, " In the area %s via interface %s%s",
3177 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3178 /* Show neighbor priority and state. */
3179 vty_out (vty, " Neighbor priority is %d, State is %s,",
3180 nbr_nbma->priority, "Down");
3181 /* Show state changes. */
3182 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3183
3184 /* Show PollInterval */
3185 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3186
3187 /* Show poll-interval timer. */
3188 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003189 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3190 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003191
3192 /* Show poll-interval timer thread. */
3193 vty_out (vty, " Thread Poll Timer %s%s",
3194 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3195}
3196
paul4dadc292005-05-06 21:37:42 +00003197static void
paul718e3742002-12-13 20:15:29 +00003198show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3199 struct ospf_neighbor *nbr)
3200{
ajs649654a2005-11-16 20:17:52 +00003201 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003202
3203 /* Show neighbor ID. */
3204 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3205 vty_out (vty, " Neighbor %s,", "-");
3206 else
3207 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3208
3209 /* Show interface address. */
3210 vty_out (vty, " interface address %s%s",
3211 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3212 /* Show Area ID. */
3213 vty_out (vty, " In the area %s via interface %s%s",
3214 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3215 /* Show neighbor priority and state. */
3216 vty_out (vty, " Neighbor priority is %d, State is %s,",
3217 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3218 /* Show state changes. */
3219 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
Paul Jakma3fed4162006-07-25 20:44:12 +00003220 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
Paul Jakma90c33172006-07-11 17:57:25 +00003221 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003222 struct timeval res
3223 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003224 vty_out (vty, " Most recent state change statistics:%s",
3225 VTY_NEWLINE);
3226 vty_out (vty, " Progressive change %s ago%s",
Paul Jakma90c33172006-07-11 17:57:25 +00003227 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
Paul Jakma3fed4162006-07-25 20:44:12 +00003228 VTY_NEWLINE);
3229 }
3230 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3231 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003232 struct timeval res
3233 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003234 vty_out (vty, " Regressive change %s ago, due to %s%s",
3235 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3236 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
Paul Jakma90c33172006-07-11 17:57:25 +00003237 VTY_NEWLINE);
3238 }
paul718e3742002-12-13 20:15:29 +00003239 /* Show Designated Rotuer ID. */
3240 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3241 /* Show Backup Designated Rotuer ID. */
3242 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3243 /* Show options. */
3244 vty_out (vty, " Options %d %s%s", nbr->options,
3245 ospf_options_dump (nbr->options), VTY_NEWLINE);
3246 /* Show Router Dead interval timer. */
3247 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003248 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3249 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003250 /* Show Database Summary list. */
3251 vty_out (vty, " Database Summary List %d%s",
3252 ospf_db_summary_count (nbr), VTY_NEWLINE);
3253 /* Show Link State Request list. */
3254 vty_out (vty, " Link State Request List %ld%s",
3255 ospf_ls_request_count (nbr), VTY_NEWLINE);
3256 /* Show Link State Retransmission list. */
3257 vty_out (vty, " Link State Retransmission List %ld%s",
3258 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3259 /* Show inactivity timer thread. */
3260 vty_out (vty, " Thread Inactivity Timer %s%s",
3261 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3262 /* Show Database Description retransmission thread. */
3263 vty_out (vty, " Thread Database Description Retransmision %s%s",
3264 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3265 /* Show Link State Request Retransmission thread. */
3266 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3267 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3268 /* Show Link State Update Retransmission thread. */
3269 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3270 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3271}
3272
3273DEFUN (show_ip_ospf_neighbor_id,
3274 show_ip_ospf_neighbor_id_cmd,
3275 "show ip ospf neighbor A.B.C.D",
3276 SHOW_STR
3277 IP_STR
3278 "OSPF information\n"
3279 "Neighbor list\n"
3280 "Neighbor ID\n")
3281{
paul020709f2003-04-04 02:44:16 +00003282 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003283 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003284 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003285 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003286 struct in_addr router_id;
3287 int ret;
3288
3289 ret = inet_aton (argv[0], &router_id);
3290 if (!ret)
3291 {
3292 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3293 return CMD_WARNING;
3294 }
3295
paul020709f2003-04-04 02:44:16 +00003296 ospf = ospf_lookup ();
3297 if (ospf == NULL)
3298 {
3299 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3300 return CMD_SUCCESS;
3301 }
3302
paul1eb8ef22005-04-07 07:30:20 +00003303 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3304 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003305 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003306
paul718e3742002-12-13 20:15:29 +00003307 return CMD_SUCCESS;
3308}
3309
3310DEFUN (show_ip_ospf_neighbor_detail,
3311 show_ip_ospf_neighbor_detail_cmd,
3312 "show ip ospf neighbor detail",
3313 SHOW_STR
3314 IP_STR
3315 "OSPF information\n"
3316 "Neighbor list\n"
3317 "detail of all neighbors\n")
3318{
paul020709f2003-04-04 02:44:16 +00003319 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003320 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003321 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003322
paul020709f2003-04-04 02:44:16 +00003323 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003324 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003325 {
3326 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3327 return CMD_SUCCESS;
3328 }
paul718e3742002-12-13 20:15:29 +00003329
paul1eb8ef22005-04-07 07:30:20 +00003330 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003331 {
paul718e3742002-12-13 20:15:29 +00003332 struct route_node *rn;
3333 struct ospf_neighbor *nbr;
3334
3335 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3336 if ((nbr = rn->info))
3337 if (nbr != oi->nbr_self)
3338 if (nbr->state != NSM_Down)
3339 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3340 }
3341
3342 return CMD_SUCCESS;
3343}
3344
3345DEFUN (show_ip_ospf_neighbor_detail_all,
3346 show_ip_ospf_neighbor_detail_all_cmd,
3347 "show ip ospf neighbor detail all",
3348 SHOW_STR
3349 IP_STR
3350 "OSPF information\n"
3351 "Neighbor list\n"
3352 "detail of all neighbors\n"
3353 "include down status neighbor\n")
3354{
paul020709f2003-04-04 02:44:16 +00003355 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003356 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003357 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003358
paul020709f2003-04-04 02:44:16 +00003359 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003360 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003361 {
3362 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3363 return CMD_SUCCESS;
3364 }
paul718e3742002-12-13 20:15:29 +00003365
paul1eb8ef22005-04-07 07:30:20 +00003366 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003367 {
paul718e3742002-12-13 20:15:29 +00003368 struct route_node *rn;
3369 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003370 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003371
3372 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3373 if ((nbr = rn->info))
3374 if (nbr != oi->nbr_self)
3375 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3376 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3377
3378 if (oi->type == OSPF_IFTYPE_NBMA)
3379 {
hasso52dc7ee2004-09-23 19:18:23 +00003380 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003381
paul1eb8ef22005-04-07 07:30:20 +00003382 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3383 if (nbr_nbma->nbr == NULL
3384 || nbr_nbma->nbr->state == NSM_Down)
3385 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003386 }
3387 }
3388
3389 return CMD_SUCCESS;
3390}
3391
3392DEFUN (show_ip_ospf_neighbor_int_detail,
3393 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003394 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003395 SHOW_STR
3396 IP_STR
3397 "OSPF information\n"
3398 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003399 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003400 "detail of all neighbors")
3401{
paul020709f2003-04-04 02:44:16 +00003402 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003403 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003404 struct interface *ifp;
3405 struct route_node *rn, *nrn;
3406 struct ospf_neighbor *nbr;
3407
3408 ifp = if_lookup_by_name (argv[0]);
3409 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003410 {
hassobb5b7552005-08-21 20:01:15 +00003411 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003412 return CMD_WARNING;
3413 }
3414
paul020709f2003-04-04 02:44:16 +00003415 ospf = ospf_lookup ();
3416 if (ospf == NULL)
3417 {
3418 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3419 return CMD_SUCCESS;
3420 }
paul68980082003-03-25 05:07:42 +00003421
paul718e3742002-12-13 20:15:29 +00003422
hassobb5b7552005-08-21 20:01:15 +00003423 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3424 if ((oi = rn->info))
3425 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3426 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003427 if (nbr != oi->nbr_self)
3428 if (nbr->state != NSM_Down)
3429 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003430
3431 return CMD_SUCCESS;
3432}
3433
3434
3435/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003436static int
paul020709f2003-04-04 02:44:16 +00003437show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003438{
paul718e3742002-12-13 20:15:29 +00003439 struct router_lsa *rl;
3440 struct summary_lsa *sl;
3441 struct as_external_lsa *asel;
3442 struct prefix_ipv4 p;
3443
3444 if (lsa != NULL)
3445 /* If self option is set, check LSA self flag. */
3446 if (self == 0 || IS_LSA_SELF (lsa))
3447 {
3448 /* LSA common part show. */
3449 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3450 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3451 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3452 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3453 /* LSA specific part show. */
3454 switch (lsa->data->type)
3455 {
3456 case OSPF_ROUTER_LSA:
3457 rl = (struct router_lsa *) lsa->data;
3458 vty_out (vty, " %-d", ntohs (rl->links));
3459 break;
3460 case OSPF_SUMMARY_LSA:
3461 sl = (struct summary_lsa *) lsa->data;
3462
3463 p.family = AF_INET;
3464 p.prefix = sl->header.id;
3465 p.prefixlen = ip_masklen (sl->mask);
3466 apply_mask_ipv4 (&p);
3467
3468 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3469 break;
3470 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003471 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003472 asel = (struct as_external_lsa *) lsa->data;
3473
3474 p.family = AF_INET;
3475 p.prefix = asel->header.id;
3476 p.prefixlen = ip_masklen (asel->mask);
3477 apply_mask_ipv4 (&p);
3478
3479 vty_out (vty, " %s %s/%d [0x%lx]",
3480 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3481 inet_ntoa (p.prefix), p.prefixlen,
3482 (u_long)ntohl (asel->e[0].route_tag));
3483 break;
3484 case OSPF_NETWORK_LSA:
3485 case OSPF_ASBR_SUMMARY_LSA:
3486#ifdef HAVE_OPAQUE_LSA
3487 case OSPF_OPAQUE_LINK_LSA:
3488 case OSPF_OPAQUE_AREA_LSA:
3489 case OSPF_OPAQUE_AS_LSA:
3490#endif /* HAVE_OPAQUE_LSA */
3491 default:
3492 break;
3493 }
3494 vty_out (vty, VTY_NEWLINE);
3495 }
3496
3497 return 0;
3498}
3499
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003500static const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003501{
3502 "unknown",
3503 "Router Link States",
3504 "Net Link States",
3505 "Summary Link States",
3506 "ASBR-Summary Link States",
3507 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003508 "Group Membership LSA",
3509 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003510#ifdef HAVE_OPAQUE_LSA
3511 "Type-8 LSA",
3512 "Link-Local Opaque-LSA",
3513 "Area-Local Opaque-LSA",
3514 "AS-external Opaque-LSA",
3515#endif /* HAVE_OPAQUE_LSA */
3516};
3517
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003518static const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003519{
3520 "",
3521 "Link ID ADV Router Age Seq# CkSum Link count",
3522 "Link ID ADV Router Age Seq# CkSum",
3523 "Link ID ADV Router Age Seq# CkSum Route",
3524 "Link ID ADV Router Age Seq# CkSum",
3525 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003526 " --- header for Group Member ----",
3527 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003528#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003529 " --- type-8 ---",
3530 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3531 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3532 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3533#endif /* HAVE_OPAQUE_LSA */
3534};
3535
paul4dadc292005-05-06 21:37:42 +00003536static void
paul718e3742002-12-13 20:15:29 +00003537show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3538{
3539 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003540
paul718e3742002-12-13 20:15:29 +00003541 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003542 vty_out (vty, " Options: 0x%-2x : %s%s",
3543 lsa->data->options,
3544 ospf_options_dump(lsa->data->options),
3545 VTY_NEWLINE);
3546 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003547 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003548 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3549 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003550
3551 if (lsa->data->type == OSPF_ROUTER_LSA)
3552 {
3553 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3554
3555 if (rlsa->flags)
3556 vty_out (vty, " :%s%s%s%s",
3557 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3558 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3559 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3560 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3561
3562 vty_out (vty, "%s", VTY_NEWLINE);
3563 }
3564 vty_out (vty, " LS Type: %s%s",
3565 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3566 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3567 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3568 vty_out (vty, " Advertising Router: %s%s",
3569 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3570 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3571 VTY_NEWLINE);
3572 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3573 VTY_NEWLINE);
3574 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3575}
3576
hassoeb1ce602004-10-08 08:17:22 +00003577const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003578{
3579 "(null)",
3580 "another Router (point-to-point)",
3581 "a Transit Network",
3582 "Stub Network",
3583 "a Virtual Link",
3584};
3585
hassoeb1ce602004-10-08 08:17:22 +00003586const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003587{
3588 "(null)",
3589 "Neighboring Router ID",
3590 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003591 "Net",
paul718e3742002-12-13 20:15:29 +00003592 "Neighboring Router ID",
3593};
3594
hassoeb1ce602004-10-08 08:17:22 +00003595const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003596{
3597 "(null)",
3598 "Router Interface address",
3599 "Router Interface address",
3600 "Network Mask",
3601 "Router Interface address",
3602};
3603
3604/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003605static void
paul718e3742002-12-13 20:15:29 +00003606show_ip_ospf_database_router_links (struct vty *vty,
3607 struct router_lsa *rl)
3608{
3609 int len, i, type;
3610
3611 len = ntohs (rl->header.length) - 4;
3612 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3613 {
3614 type = rl->link[i].type;
3615
3616 vty_out (vty, " Link connected to: %s%s",
3617 link_type_desc[type], VTY_NEWLINE);
3618 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3619 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3620 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3621 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3622 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3623 vty_out (vty, " TOS 0 Metric: %d%s",
3624 ntohs (rl->link[i].metric), VTY_NEWLINE);
3625 vty_out (vty, "%s", VTY_NEWLINE);
3626 }
3627}
3628
3629/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003630static int
paul718e3742002-12-13 20:15:29 +00003631show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3632{
3633 if (lsa != NULL)
3634 {
3635 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3636
3637 show_ip_ospf_database_header (vty, lsa);
3638
3639 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3640 VTY_NEWLINE, VTY_NEWLINE);
3641
3642 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003643 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003644 }
3645
3646 return 0;
3647}
3648
3649/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003650static int
paul718e3742002-12-13 20:15:29 +00003651show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3652{
3653 int length, i;
3654
3655 if (lsa != NULL)
3656 {
3657 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3658
3659 show_ip_ospf_database_header (vty, lsa);
3660
3661 vty_out (vty, " Network Mask: /%d%s",
3662 ip_masklen (nl->mask), VTY_NEWLINE);
3663
3664 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3665
3666 for (i = 0; length > 0; i++, length -= 4)
3667 vty_out (vty, " Attached Router: %s%s",
3668 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3669
3670 vty_out (vty, "%s", VTY_NEWLINE);
3671 }
3672
3673 return 0;
3674}
3675
3676/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003677static int
paul718e3742002-12-13 20:15:29 +00003678show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3679{
3680 if (lsa != NULL)
3681 {
3682 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3683
3684 show_ip_ospf_database_header (vty, lsa);
3685
3686 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3687 VTY_NEWLINE);
3688 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3689 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003690 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003691 }
3692
3693 return 0;
3694}
3695
3696/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003697static int
paul718e3742002-12-13 20:15:29 +00003698show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3699{
3700 if (lsa != NULL)
3701 {
3702 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3703
3704 show_ip_ospf_database_header (vty, lsa);
3705
3706 vty_out (vty, " Network Mask: /%d%s",
3707 ip_masklen (sl->mask), VTY_NEWLINE);
3708 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3709 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003710 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003711 }
3712
3713 return 0;
3714}
3715
3716/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003717static int
paul718e3742002-12-13 20:15:29 +00003718show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3719{
3720 if (lsa != NULL)
3721 {
3722 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3723
3724 show_ip_ospf_database_header (vty, lsa);
3725
3726 vty_out (vty, " Network Mask: /%d%s",
3727 ip_masklen (al->mask), VTY_NEWLINE);
3728 vty_out (vty, " Metric Type: %s%s",
3729 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3730 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3731 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3732 vty_out (vty, " Metric: %d%s",
3733 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3734 vty_out (vty, " Forward Address: %s%s",
3735 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3736
3737 vty_out (vty, " External Route Tag: %lu%s%s",
3738 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3739 }
3740
3741 return 0;
3742}
3743
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003744#if 0
paul4dadc292005-05-06 21:37:42 +00003745static int
paul718e3742002-12-13 20:15:29 +00003746show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3747{
3748 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3749
3750 /* show_ip_ospf_database_header (vty, lsa); */
3751
ajs2a42e282004-12-08 18:43:03 +00003752 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003753 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003754 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003755 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3756 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003757 zlog_debug( " TOS: 0%s", "\n");
3758 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003759 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003760 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003761 inet_ntoa (al->e[0].fwd_addr), "\n");
3762
ajs2a42e282004-12-08 18:43:03 +00003763 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003764 ntohl (al->e[0].route_tag), "\n", "\n");
3765
3766 return 0;
3767}
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003768#endif
paul718e3742002-12-13 20:15:29 +00003769
3770/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003771static int
paul718e3742002-12-13 20:15:29 +00003772show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3773{
3774 if (lsa != NULL)
3775 {
3776 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3777
3778 show_ip_ospf_database_header (vty, lsa);
3779
3780 vty_out (vty, " Network Mask: /%d%s",
3781 ip_masklen (al->mask), VTY_NEWLINE);
3782 vty_out (vty, " Metric Type: %s%s",
3783 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3784 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3785 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3786 vty_out (vty, " Metric: %d%s",
3787 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3788 vty_out (vty, " NSSA: Forward Address: %s%s",
3789 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3790
3791 vty_out (vty, " External Route Tag: %u%s%s",
3792 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3793 }
3794
3795 return 0;
3796}
3797
paul4dadc292005-05-06 21:37:42 +00003798static int
paul718e3742002-12-13 20:15:29 +00003799show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3800{
3801 return 0;
3802}
3803
3804#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003805static int
paul718e3742002-12-13 20:15:29 +00003806show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3807{
3808 if (lsa != NULL)
3809 {
3810 show_ip_ospf_database_header (vty, lsa);
3811 show_opaque_info_detail (vty, lsa);
3812
3813 vty_out (vty, "%s", VTY_NEWLINE);
3814 }
3815 return 0;
3816}
3817#endif /* HAVE_OPAQUE_LSA */
3818
3819int (*show_function[])(struct vty *, struct ospf_lsa *) =
3820{
3821 NULL,
3822 show_router_lsa_detail,
3823 show_network_lsa_detail,
3824 show_summary_lsa_detail,
3825 show_summary_asbr_lsa_detail,
3826 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003827 show_func_dummy,
3828 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003829#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003830 NULL, /* type-8 */
3831 show_opaque_lsa_detail,
3832 show_opaque_lsa_detail,
3833 show_opaque_lsa_detail,
3834#endif /* HAVE_OPAQUE_LSA */
3835};
3836
paul4dadc292005-05-06 21:37:42 +00003837static void
paul718e3742002-12-13 20:15:29 +00003838show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3839 struct in_addr *adv_router)
3840{
3841 memset (lp, 0, sizeof (struct prefix_ls));
3842 lp->family = 0;
3843 if (id == NULL)
3844 lp->prefixlen = 0;
3845 else if (adv_router == NULL)
3846 {
3847 lp->prefixlen = 32;
3848 lp->id = *id;
3849 }
3850 else
3851 {
3852 lp->prefixlen = 64;
3853 lp->id = *id;
3854 lp->adv_router = *adv_router;
3855 }
3856}
3857
paul4dadc292005-05-06 21:37:42 +00003858static void
paul718e3742002-12-13 20:15:29 +00003859show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3860 struct in_addr *id, struct in_addr *adv_router)
3861{
3862 struct prefix_ls lp;
3863 struct route_node *rn, *start;
3864 struct ospf_lsa *lsa;
3865
3866 show_lsa_prefix_set (vty, &lp, id, adv_router);
3867 start = route_node_get (rt, (struct prefix *) &lp);
3868 if (start)
3869 {
3870 route_lock_node (start);
3871 for (rn = start; rn; rn = route_next_until (rn, start))
3872 if ((lsa = rn->info))
3873 {
paul718e3742002-12-13 20:15:29 +00003874 if (show_function[lsa->data->type] != NULL)
3875 show_function[lsa->data->type] (vty, lsa);
3876 }
3877 route_unlock_node (start);
3878 }
3879}
3880
3881/* Show detail LSA information
3882 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003883static void
paul020709f2003-04-04 02:44:16 +00003884show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003885 struct in_addr *id, struct in_addr *adv_router)
3886{
hasso52dc7ee2004-09-23 19:18:23 +00003887 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003888 struct ospf_area *area;
3889
paul718e3742002-12-13 20:15:29 +00003890 switch (type)
3891 {
3892 case OSPF_AS_EXTERNAL_LSA:
3893#ifdef HAVE_OPAQUE_LSA
3894 case OSPF_OPAQUE_AS_LSA:
3895#endif /* HAVE_OPAQUE_LSA */
3896 vty_out (vty, " %s %s%s",
3897 show_database_desc[type],
3898 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003899 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003900 break;
3901 default:
paul1eb8ef22005-04-07 07:30:20 +00003902 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003903 {
paul718e3742002-12-13 20:15:29 +00003904 vty_out (vty, "%s %s (Area %s)%s%s",
3905 VTY_NEWLINE, show_database_desc[type],
3906 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3907 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3908 }
3909 break;
3910 }
3911}
3912
paul4dadc292005-05-06 21:37:42 +00003913static void
paul718e3742002-12-13 20:15:29 +00003914show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3915 struct in_addr *adv_router)
3916{
3917 struct route_node *rn;
3918 struct ospf_lsa *lsa;
3919
3920 for (rn = route_top (rt); rn; rn = route_next (rn))
3921 if ((lsa = rn->info))
3922 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3923 {
paul718e3742002-12-13 20:15:29 +00003924 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3925 continue;
paul718e3742002-12-13 20:15:29 +00003926 if (show_function[lsa->data->type] != NULL)
3927 show_function[lsa->data->type] (vty, lsa);
3928 }
3929}
3930
3931/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003932static void
paul020709f2003-04-04 02:44:16 +00003933show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003934 struct in_addr *adv_router)
3935{
hasso52dc7ee2004-09-23 19:18:23 +00003936 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003937 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003938
3939 switch (type)
3940 {
3941 case OSPF_AS_EXTERNAL_LSA:
3942#ifdef HAVE_OPAQUE_LSA
3943 case OSPF_OPAQUE_AS_LSA:
3944#endif /* HAVE_OPAQUE_LSA */
3945 vty_out (vty, " %s %s%s",
3946 show_database_desc[type],
3947 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003948 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003949 adv_router);
3950 break;
3951 default:
paul1eb8ef22005-04-07 07:30:20 +00003952 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003953 {
paul718e3742002-12-13 20:15:29 +00003954 vty_out (vty, "%s %s (Area %s)%s%s",
3955 VTY_NEWLINE, show_database_desc[type],
3956 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3957 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3958 adv_router);
3959 }
3960 break;
3961 }
3962}
3963
paul4dadc292005-05-06 21:37:42 +00003964static void
paul020709f2003-04-04 02:44:16 +00003965show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003966{
paul020709f2003-04-04 02:44:16 +00003967 struct ospf_lsa *lsa;
3968 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003969 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003970 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003971 int type;
3972
paul1eb8ef22005-04-07 07:30:20 +00003973 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003974 {
paul718e3742002-12-13 20:15:29 +00003975 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3976 {
3977 switch (type)
3978 {
3979 case OSPF_AS_EXTERNAL_LSA:
3980#ifdef HAVE_OPAQUE_LSA
3981 case OSPF_OPAQUE_AS_LSA:
3982#endif /* HAVE_OPAQUE_LSA */
3983 continue;
3984 default:
3985 break;
3986 }
3987 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3988 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3989 {
3990 vty_out (vty, " %s (Area %s)%s%s",
3991 show_database_desc[type],
3992 ospf_area_desc_string (area),
3993 VTY_NEWLINE, VTY_NEWLINE);
3994 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3995
paul020709f2003-04-04 02:44:16 +00003996 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3997 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003998
3999 vty_out (vty, "%s", VTY_NEWLINE);
4000 }
4001 }
4002 }
4003
4004 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4005 {
4006 switch (type)
4007 {
4008 case OSPF_AS_EXTERNAL_LSA:
4009#ifdef HAVE_OPAQUE_LSA
4010 case OSPF_OPAQUE_AS_LSA:
4011#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00004012 break;
paul718e3742002-12-13 20:15:29 +00004013 default:
4014 continue;
4015 }
paul68980082003-03-25 05:07:42 +00004016 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4017 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00004018 {
4019 vty_out (vty, " %s%s%s",
4020 show_database_desc[type],
4021 VTY_NEWLINE, VTY_NEWLINE);
4022 vty_out (vty, "%s%s", show_database_header[type],
4023 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00004024
4025 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4026 show_lsa_summary (vty, lsa, self);
4027
paul718e3742002-12-13 20:15:29 +00004028 vty_out (vty, "%s", VTY_NEWLINE);
4029 }
4030 }
4031
4032 vty_out (vty, "%s", VTY_NEWLINE);
4033}
4034
paul4dadc292005-05-06 21:37:42 +00004035static void
paul020709f2003-04-04 02:44:16 +00004036show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00004037{
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004038 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00004039 struct ospf_lsa *lsa;
4040
4041 vty_out (vty, "%s MaxAge Link States:%s%s",
4042 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4043
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004044 for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
paul1eb8ef22005-04-07 07:30:20 +00004045 {
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004046 struct ospf_lsa *lsa;
4047
4048 if ((lsa = rn->info) != NULL)
4049 {
4050 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4051 vty_out (vty, "Link State ID: %s%s",
4052 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4053 vty_out (vty, "Advertising Router: %s%s",
4054 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4055 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4056 vty_out (vty, "%s", VTY_NEWLINE);
4057 }
paul1eb8ef22005-04-07 07:30:20 +00004058 }
paul718e3742002-12-13 20:15:29 +00004059}
4060
paul718e3742002-12-13 20:15:29 +00004061#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4062#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00004063
4064#ifdef HAVE_OPAQUE_LSA
4065#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4066#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4067#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4068#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4069#else /* HAVE_OPAQUE_LSA */
4070#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4071#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4072#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4073#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4074#endif /* HAVE_OPAQUE_LSA */
4075
4076#define OSPF_LSA_TYPES_CMD_STR \
4077 "asbr-summary|external|network|router|summary" \
4078 OSPF_LSA_TYPE_NSSA_CMD_STR \
4079 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4080
4081#define OSPF_LSA_TYPES_DESC \
4082 "ASBR summary link states\n" \
4083 "External link states\n" \
4084 "Network link states\n" \
4085 "Router link states\n" \
4086 "Network summary link states\n" \
4087 OSPF_LSA_TYPE_NSSA_DESC \
4088 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4089 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4090 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4091
4092DEFUN (show_ip_ospf_database,
4093 show_ip_ospf_database_cmd,
4094 "show ip ospf database",
4095 SHOW_STR
4096 IP_STR
4097 "OSPF information\n"
4098 "Database summary\n")
4099{
paul020709f2003-04-04 02:44:16 +00004100 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004101 int type, ret;
4102 struct in_addr id, adv_router;
4103
paul020709f2003-04-04 02:44:16 +00004104 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004105 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004106 {
4107 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4108 return CMD_SUCCESS;
4109 }
paul718e3742002-12-13 20:15:29 +00004110
4111 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004112 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004113
4114 /* Show all LSA. */
4115 if (argc == 0)
4116 {
paul020709f2003-04-04 02:44:16 +00004117 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004118 return CMD_SUCCESS;
4119 }
4120
4121 /* Set database type to show. */
4122 if (strncmp (argv[0], "r", 1) == 0)
4123 type = OSPF_ROUTER_LSA;
4124 else if (strncmp (argv[0], "ne", 2) == 0)
4125 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004126 else if (strncmp (argv[0], "ns", 2) == 0)
4127 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004128 else if (strncmp (argv[0], "su", 2) == 0)
4129 type = OSPF_SUMMARY_LSA;
4130 else if (strncmp (argv[0], "a", 1) == 0)
4131 type = OSPF_ASBR_SUMMARY_LSA;
4132 else if (strncmp (argv[0], "e", 1) == 0)
4133 type = OSPF_AS_EXTERNAL_LSA;
4134 else if (strncmp (argv[0], "se", 2) == 0)
4135 {
paul020709f2003-04-04 02:44:16 +00004136 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004137 return CMD_SUCCESS;
4138 }
4139 else if (strncmp (argv[0], "m", 1) == 0)
4140 {
paul020709f2003-04-04 02:44:16 +00004141 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004142 return CMD_SUCCESS;
4143 }
4144#ifdef HAVE_OPAQUE_LSA
4145 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4146 type = OSPF_OPAQUE_LINK_LSA;
4147 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4148 type = OSPF_OPAQUE_AREA_LSA;
4149 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4150 type = OSPF_OPAQUE_AS_LSA;
4151#endif /* HAVE_OPAQUE_LSA */
4152 else
4153 return CMD_WARNING;
4154
4155 /* `show ip ospf database LSA'. */
4156 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004157 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004158 else if (argc >= 2)
4159 {
4160 ret = inet_aton (argv[1], &id);
4161 if (!ret)
4162 return CMD_WARNING;
4163
4164 /* `show ip ospf database LSA ID'. */
4165 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004166 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004167 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4168 else if (argc == 3)
4169 {
4170 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004171 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004172 else
4173 {
4174 ret = inet_aton (argv[2], &adv_router);
4175 if (!ret)
4176 return CMD_WARNING;
4177 }
paul020709f2003-04-04 02:44:16 +00004178 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004179 }
4180 }
4181
4182 return CMD_SUCCESS;
4183}
4184
4185ALIAS (show_ip_ospf_database,
4186 show_ip_ospf_database_type_cmd,
4187 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4188 SHOW_STR
4189 IP_STR
4190 "OSPF information\n"
4191 "Database summary\n"
4192 OSPF_LSA_TYPES_DESC
4193 "LSAs in MaxAge list\n"
4194 "Self-originated link states\n")
4195
4196ALIAS (show_ip_ospf_database,
4197 show_ip_ospf_database_type_id_cmd,
4198 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4199 SHOW_STR
4200 IP_STR
4201 "OSPF information\n"
4202 "Database summary\n"
4203 OSPF_LSA_TYPES_DESC
4204 "Link State ID (as an IP address)\n")
4205
4206ALIAS (show_ip_ospf_database,
4207 show_ip_ospf_database_type_id_adv_router_cmd,
4208 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4209 SHOW_STR
4210 IP_STR
4211 "OSPF information\n"
4212 "Database summary\n"
4213 OSPF_LSA_TYPES_DESC
4214 "Link State ID (as an IP address)\n"
4215 "Advertising Router link states\n"
4216 "Advertising Router (as an IP address)\n")
4217
4218ALIAS (show_ip_ospf_database,
4219 show_ip_ospf_database_type_id_self_cmd,
4220 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4221 SHOW_STR
4222 IP_STR
4223 "OSPF information\n"
4224 "Database summary\n"
4225 OSPF_LSA_TYPES_DESC
4226 "Link State ID (as an IP address)\n"
4227 "Self-originated link states\n"
4228 "\n")
4229
4230DEFUN (show_ip_ospf_database_type_adv_router,
4231 show_ip_ospf_database_type_adv_router_cmd,
4232 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4233 SHOW_STR
4234 IP_STR
4235 "OSPF information\n"
4236 "Database summary\n"
4237 OSPF_LSA_TYPES_DESC
4238 "Advertising Router link states\n"
4239 "Advertising Router (as an IP address)\n")
4240{
paul020709f2003-04-04 02:44:16 +00004241 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004242 int type, ret;
4243 struct in_addr adv_router;
4244
paul020709f2003-04-04 02:44:16 +00004245 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004246 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004247 {
4248 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4249 return CMD_SUCCESS;
4250 }
paul718e3742002-12-13 20:15:29 +00004251
4252 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004253 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004254
4255 if (argc != 2)
4256 return CMD_WARNING;
4257
4258 /* Set database type to show. */
4259 if (strncmp (argv[0], "r", 1) == 0)
4260 type = OSPF_ROUTER_LSA;
4261 else if (strncmp (argv[0], "ne", 2) == 0)
4262 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004263 else if (strncmp (argv[0], "ns", 2) == 0)
4264 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004265 else if (strncmp (argv[0], "s", 1) == 0)
4266 type = OSPF_SUMMARY_LSA;
4267 else if (strncmp (argv[0], "a", 1) == 0)
4268 type = OSPF_ASBR_SUMMARY_LSA;
4269 else if (strncmp (argv[0], "e", 1) == 0)
4270 type = OSPF_AS_EXTERNAL_LSA;
4271#ifdef HAVE_OPAQUE_LSA
4272 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4273 type = OSPF_OPAQUE_LINK_LSA;
4274 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4275 type = OSPF_OPAQUE_AREA_LSA;
4276 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4277 type = OSPF_OPAQUE_AS_LSA;
4278#endif /* HAVE_OPAQUE_LSA */
4279 else
4280 return CMD_WARNING;
4281
4282 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4283 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004284 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004285 else
4286 {
4287 ret = inet_aton (argv[1], &adv_router);
4288 if (!ret)
4289 return CMD_WARNING;
4290 }
4291
paul020709f2003-04-04 02:44:16 +00004292 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004293
4294 return CMD_SUCCESS;
4295}
4296
4297ALIAS (show_ip_ospf_database_type_adv_router,
4298 show_ip_ospf_database_type_self_cmd,
4299 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4300 SHOW_STR
4301 IP_STR
4302 "OSPF information\n"
4303 "Database summary\n"
4304 OSPF_LSA_TYPES_DESC
4305 "Self-originated link states\n")
4306
4307
4308DEFUN (ip_ospf_authentication_args,
4309 ip_ospf_authentication_args_addr_cmd,
4310 "ip ospf authentication (null|message-digest) A.B.C.D",
4311 "IP Information\n"
4312 "OSPF interface commands\n"
4313 "Enable authentication on this interface\n"
4314 "Use null authentication\n"
4315 "Use message-digest authentication\n"
4316 "Address of interface")
4317{
4318 struct interface *ifp;
4319 struct in_addr addr;
4320 int ret;
4321 struct ospf_if_params *params;
4322
4323 ifp = vty->index;
4324 params = IF_DEF_PARAMS (ifp);
4325
4326 if (argc == 2)
4327 {
4328 ret = inet_aton(argv[1], &addr);
4329 if (!ret)
4330 {
4331 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4332 VTY_NEWLINE);
4333 return CMD_WARNING;
4334 }
4335
4336 params = ospf_get_if_params (ifp, addr);
4337 ospf_if_update_params (ifp, addr);
4338 }
4339
4340 /* Handle null authentication */
4341 if ( argv[0][0] == 'n' )
4342 {
4343 SET_IF_PARAM (params, auth_type);
4344 params->auth_type = OSPF_AUTH_NULL;
4345 return CMD_SUCCESS;
4346 }
4347
4348 /* Handle message-digest authentication */
4349 if ( argv[0][0] == 'm' )
4350 {
4351 SET_IF_PARAM (params, auth_type);
4352 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4353 return CMD_SUCCESS;
4354 }
4355
4356 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4357 return CMD_WARNING;
4358}
4359
4360ALIAS (ip_ospf_authentication_args,
4361 ip_ospf_authentication_args_cmd,
4362 "ip ospf authentication (null|message-digest)",
4363 "IP Information\n"
4364 "OSPF interface commands\n"
4365 "Enable authentication on this interface\n"
4366 "Use null authentication\n"
4367 "Use message-digest authentication\n")
4368
4369DEFUN (ip_ospf_authentication,
4370 ip_ospf_authentication_addr_cmd,
4371 "ip ospf authentication A.B.C.D",
4372 "IP Information\n"
4373 "OSPF interface commands\n"
4374 "Enable authentication on this interface\n"
4375 "Address of interface")
4376{
4377 struct interface *ifp;
4378 struct in_addr addr;
4379 int ret;
4380 struct ospf_if_params *params;
4381
4382 ifp = vty->index;
4383 params = IF_DEF_PARAMS (ifp);
4384
4385 if (argc == 1)
4386 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004387 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004388 if (!ret)
4389 {
4390 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4391 VTY_NEWLINE);
4392 return CMD_WARNING;
4393 }
4394
4395 params = ospf_get_if_params (ifp, addr);
4396 ospf_if_update_params (ifp, addr);
4397 }
4398
4399 SET_IF_PARAM (params, auth_type);
4400 params->auth_type = OSPF_AUTH_SIMPLE;
4401
4402 return CMD_SUCCESS;
4403}
4404
4405ALIAS (ip_ospf_authentication,
4406 ip_ospf_authentication_cmd,
4407 "ip ospf authentication",
4408 "IP Information\n"
4409 "OSPF interface commands\n"
4410 "Enable authentication on this interface\n")
4411
4412DEFUN (no_ip_ospf_authentication,
4413 no_ip_ospf_authentication_addr_cmd,
4414 "no ip ospf authentication A.B.C.D",
4415 NO_STR
4416 "IP Information\n"
4417 "OSPF interface commands\n"
4418 "Enable authentication on this interface\n"
4419 "Address of interface")
4420{
4421 struct interface *ifp;
4422 struct in_addr addr;
4423 int ret;
4424 struct ospf_if_params *params;
4425
4426 ifp = vty->index;
4427 params = IF_DEF_PARAMS (ifp);
4428
4429 if (argc == 1)
4430 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004431 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004432 if (!ret)
4433 {
4434 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4435 VTY_NEWLINE);
4436 return CMD_WARNING;
4437 }
4438
4439 params = ospf_lookup_if_params (ifp, addr);
4440 if (params == NULL)
4441 return CMD_SUCCESS;
4442 }
4443
4444 params->auth_type = OSPF_AUTH_NOTSET;
4445 UNSET_IF_PARAM (params, auth_type);
4446
4447 if (params != IF_DEF_PARAMS (ifp))
4448 {
4449 ospf_free_if_params (ifp, addr);
4450 ospf_if_update_params (ifp, addr);
4451 }
4452
4453 return CMD_SUCCESS;
4454}
4455
4456ALIAS (no_ip_ospf_authentication,
4457 no_ip_ospf_authentication_cmd,
4458 "no ip ospf authentication",
4459 NO_STR
4460 "IP Information\n"
4461 "OSPF interface commands\n"
4462 "Enable authentication on this interface\n")
4463
4464DEFUN (ip_ospf_authentication_key,
4465 ip_ospf_authentication_key_addr_cmd,
4466 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4467 "IP Information\n"
4468 "OSPF interface commands\n"
4469 "Authentication password (key)\n"
4470 "The OSPF password (key)\n"
4471 "Address of interface")
4472{
4473 struct interface *ifp;
4474 struct in_addr addr;
4475 int ret;
4476 struct ospf_if_params *params;
4477
4478 ifp = vty->index;
4479 params = IF_DEF_PARAMS (ifp);
4480
4481 if (argc == 2)
4482 {
4483 ret = inet_aton(argv[1], &addr);
4484 if (!ret)
4485 {
4486 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4487 VTY_NEWLINE);
4488 return CMD_WARNING;
4489 }
4490
4491 params = ospf_get_if_params (ifp, addr);
4492 ospf_if_update_params (ifp, addr);
4493 }
4494
4495
4496 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004497 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004498 SET_IF_PARAM (params, auth_simple);
4499
4500 return CMD_SUCCESS;
4501}
4502
4503ALIAS (ip_ospf_authentication_key,
4504 ip_ospf_authentication_key_cmd,
4505 "ip ospf authentication-key AUTH_KEY",
4506 "IP Information\n"
4507 "OSPF interface commands\n"
4508 "Authentication password (key)\n"
4509 "The OSPF password (key)")
4510
4511ALIAS (ip_ospf_authentication_key,
4512 ospf_authentication_key_cmd,
4513 "ospf authentication-key AUTH_KEY",
4514 "OSPF interface commands\n"
4515 "Authentication password (key)\n"
4516 "The OSPF password (key)")
4517
4518DEFUN (no_ip_ospf_authentication_key,
4519 no_ip_ospf_authentication_key_addr_cmd,
4520 "no ip ospf authentication-key A.B.C.D",
4521 NO_STR
4522 "IP Information\n"
4523 "OSPF interface commands\n"
4524 "Authentication password (key)\n"
4525 "Address of interface")
4526{
4527 struct interface *ifp;
4528 struct in_addr addr;
4529 int ret;
4530 struct ospf_if_params *params;
4531
4532 ifp = vty->index;
4533 params = IF_DEF_PARAMS (ifp);
4534
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004535 if (argc == 1)
paul718e3742002-12-13 20:15:29 +00004536 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004537 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004538 if (!ret)
4539 {
4540 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4541 VTY_NEWLINE);
4542 return CMD_WARNING;
4543 }
4544
4545 params = ospf_lookup_if_params (ifp, addr);
4546 if (params == NULL)
4547 return CMD_SUCCESS;
4548 }
4549
4550 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4551 UNSET_IF_PARAM (params, auth_simple);
4552
4553 if (params != IF_DEF_PARAMS (ifp))
4554 {
4555 ospf_free_if_params (ifp, addr);
4556 ospf_if_update_params (ifp, addr);
4557 }
4558
4559 return CMD_SUCCESS;
4560}
4561
4562ALIAS (no_ip_ospf_authentication_key,
4563 no_ip_ospf_authentication_key_cmd,
4564 "no ip ospf authentication-key",
4565 NO_STR
4566 "IP Information\n"
4567 "OSPF interface commands\n"
4568 "Authentication password (key)\n")
4569
4570ALIAS (no_ip_ospf_authentication_key,
4571 no_ospf_authentication_key_cmd,
4572 "no ospf authentication-key",
4573 NO_STR
4574 "OSPF interface commands\n"
4575 "Authentication password (key)\n")
4576
4577DEFUN (ip_ospf_message_digest_key,
4578 ip_ospf_message_digest_key_addr_cmd,
4579 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4580 "IP Information\n"
4581 "OSPF interface commands\n"
4582 "Message digest authentication password (key)\n"
4583 "Key ID\n"
4584 "Use MD5 algorithm\n"
4585 "The OSPF password (key)"
4586 "Address of interface")
4587{
4588 struct interface *ifp;
4589 struct crypt_key *ck;
4590 u_char key_id;
4591 struct in_addr addr;
4592 int ret;
4593 struct ospf_if_params *params;
4594
4595 ifp = vty->index;
4596 params = IF_DEF_PARAMS (ifp);
4597
4598 if (argc == 3)
4599 {
4600 ret = inet_aton(argv[2], &addr);
4601 if (!ret)
4602 {
4603 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4604 VTY_NEWLINE);
4605 return CMD_WARNING;
4606 }
4607
4608 params = ospf_get_if_params (ifp, addr);
4609 ospf_if_update_params (ifp, addr);
4610 }
4611
4612 key_id = strtol (argv[0], NULL, 10);
4613 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4614 {
4615 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4616 return CMD_WARNING;
4617 }
4618
4619 ck = ospf_crypt_key_new ();
4620 ck->key_id = (u_char) key_id;
4621 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004622 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004623
4624 ospf_crypt_key_add (params->auth_crypt, ck);
4625 SET_IF_PARAM (params, auth_crypt);
4626
4627 return CMD_SUCCESS;
4628}
4629
4630ALIAS (ip_ospf_message_digest_key,
4631 ip_ospf_message_digest_key_cmd,
4632 "ip ospf message-digest-key <1-255> md5 KEY",
4633 "IP Information\n"
4634 "OSPF interface commands\n"
4635 "Message digest authentication password (key)\n"
4636 "Key ID\n"
4637 "Use MD5 algorithm\n"
4638 "The OSPF password (key)")
4639
4640ALIAS (ip_ospf_message_digest_key,
4641 ospf_message_digest_key_cmd,
4642 "ospf message-digest-key <1-255> md5 KEY",
4643 "OSPF interface commands\n"
4644 "Message digest authentication password (key)\n"
4645 "Key ID\n"
4646 "Use MD5 algorithm\n"
4647 "The OSPF password (key)")
4648
4649DEFUN (no_ip_ospf_message_digest_key,
4650 no_ip_ospf_message_digest_key_addr_cmd,
4651 "no ip ospf message-digest-key <1-255> A.B.C.D",
4652 NO_STR
4653 "IP Information\n"
4654 "OSPF interface commands\n"
4655 "Message digest authentication password (key)\n"
4656 "Key ID\n"
4657 "Address of interface")
4658{
4659 struct interface *ifp;
4660 struct crypt_key *ck;
4661 int key_id;
4662 struct in_addr addr;
4663 int ret;
4664 struct ospf_if_params *params;
4665
4666 ifp = vty->index;
4667 params = IF_DEF_PARAMS (ifp);
4668
4669 if (argc == 2)
4670 {
4671 ret = inet_aton(argv[1], &addr);
4672 if (!ret)
4673 {
4674 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4675 VTY_NEWLINE);
4676 return CMD_WARNING;
4677 }
4678
4679 params = ospf_lookup_if_params (ifp, addr);
4680 if (params == NULL)
4681 return CMD_SUCCESS;
4682 }
4683
4684 key_id = strtol (argv[0], NULL, 10);
4685 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4686 if (ck == NULL)
4687 {
4688 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4689 return CMD_WARNING;
4690 }
4691
4692 ospf_crypt_key_delete (params->auth_crypt, key_id);
4693
4694 if (params != IF_DEF_PARAMS (ifp))
4695 {
4696 ospf_free_if_params (ifp, addr);
4697 ospf_if_update_params (ifp, addr);
4698 }
4699
4700 return CMD_SUCCESS;
4701}
4702
4703ALIAS (no_ip_ospf_message_digest_key,
4704 no_ip_ospf_message_digest_key_cmd,
4705 "no ip ospf message-digest-key <1-255>",
4706 NO_STR
4707 "IP Information\n"
4708 "OSPF interface commands\n"
4709 "Message digest authentication password (key)\n"
4710 "Key ID\n")
4711
4712ALIAS (no_ip_ospf_message_digest_key,
4713 no_ospf_message_digest_key_cmd,
4714 "no ospf message-digest-key <1-255>",
4715 NO_STR
4716 "OSPF interface commands\n"
4717 "Message digest authentication password (key)\n"
4718 "Key ID\n")
4719
4720DEFUN (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004721 ip_ospf_cost_u32_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004722 "ip ospf cost <1-65535> A.B.C.D",
4723 "IP Information\n"
4724 "OSPF interface commands\n"
4725 "Interface cost\n"
4726 "Cost\n"
4727 "Address of interface")
4728{
4729 struct interface *ifp = vty->index;
4730 u_int32_t cost;
4731 struct in_addr addr;
4732 int ret;
4733 struct ospf_if_params *params;
4734
4735 params = IF_DEF_PARAMS (ifp);
4736
4737 cost = strtol (argv[0], NULL, 10);
4738
4739 /* cost range is <1-65535>. */
4740 if (cost < 1 || cost > 65535)
4741 {
4742 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4743 return CMD_WARNING;
4744 }
4745
4746 if (argc == 2)
4747 {
4748 ret = inet_aton(argv[1], &addr);
4749 if (!ret)
4750 {
4751 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4752 VTY_NEWLINE);
4753 return CMD_WARNING;
4754 }
4755
4756 params = ospf_get_if_params (ifp, addr);
4757 ospf_if_update_params (ifp, addr);
4758 }
4759
4760 SET_IF_PARAM (params, output_cost_cmd);
4761 params->output_cost_cmd = cost;
4762
4763 ospf_if_recalculate_output_cost (ifp);
4764
4765 return CMD_SUCCESS;
4766}
4767
4768ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004769 ip_ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004770 "ip ospf cost <1-65535>",
4771 "IP Information\n"
4772 "OSPF interface commands\n"
4773 "Interface cost\n"
4774 "Cost")
4775
4776ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004777 ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004778 "ospf cost <1-65535>",
4779 "OSPF interface commands\n"
4780 "Interface cost\n"
4781 "Cost")
4782
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004783ALIAS (ip_ospf_cost,
4784 ospf_cost_u32_inet4_cmd,
4785 "ospf cost <1-65535> A.B.C.D",
4786 "OSPF interface commands\n"
4787 "Interface cost\n"
4788 "Cost\n"
4789 "Address of interface")
4790
paul718e3742002-12-13 20:15:29 +00004791DEFUN (no_ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004792 no_ip_ospf_cost_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004793 "no ip ospf cost A.B.C.D",
4794 NO_STR
4795 "IP Information\n"
4796 "OSPF interface commands\n"
4797 "Interface cost\n"
4798 "Address of interface")
4799{
4800 struct interface *ifp = vty->index;
4801 struct in_addr addr;
4802 int ret;
4803 struct ospf_if_params *params;
4804
4805 ifp = vty->index;
4806 params = IF_DEF_PARAMS (ifp);
4807
4808 if (argc == 1)
4809 {
4810 ret = inet_aton(argv[0], &addr);
4811 if (!ret)
4812 {
4813 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4814 VTY_NEWLINE);
4815 return CMD_WARNING;
4816 }
4817
4818 params = ospf_lookup_if_params (ifp, addr);
4819 if (params == NULL)
4820 return CMD_SUCCESS;
4821 }
4822
4823 UNSET_IF_PARAM (params, output_cost_cmd);
4824
4825 if (params != IF_DEF_PARAMS (ifp))
4826 {
4827 ospf_free_if_params (ifp, addr);
4828 ospf_if_update_params (ifp, addr);
4829 }
4830
4831 ospf_if_recalculate_output_cost (ifp);
4832
4833 return CMD_SUCCESS;
4834}
4835
4836ALIAS (no_ip_ospf_cost,
4837 no_ip_ospf_cost_cmd,
4838 "no ip ospf cost",
4839 NO_STR
4840 "IP Information\n"
4841 "OSPF interface commands\n"
4842 "Interface cost\n")
4843
4844ALIAS (no_ip_ospf_cost,
4845 no_ospf_cost_cmd,
4846 "no ospf cost",
4847 NO_STR
4848 "OSPF interface commands\n"
4849 "Interface cost\n")
4850
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004851ALIAS (no_ip_ospf_cost,
4852 no_ospf_cost_inet4_cmd,
4853 "no ospf cost A.B.C.D",
4854 NO_STR
4855 "OSPF interface commands\n"
4856 "Interface cost\n"
4857 "Address of interface")
4858
Denis Ovsienko827341b2009-09-28 19:34:59 +04004859DEFUN (no_ip_ospf_cost2,
4860 no_ip_ospf_cost_u32_cmd,
4861 "no ip ospf cost <1-65535>",
4862 NO_STR
4863 "IP Information\n"
4864 "OSPF interface commands\n"
4865 "Interface cost\n"
4866 "Cost")
4867{
4868 struct interface *ifp = vty->index;
4869 struct in_addr addr;
4870 u_int32_t cost;
4871 int ret;
4872 struct ospf_if_params *params;
4873
4874 ifp = vty->index;
4875 params = IF_DEF_PARAMS (ifp);
4876
4877 /* According to the semantics we are mimicking "no ip ospf cost N" is
4878 * always treated as "no ip ospf cost" regardless of the actual value
4879 * of N already configured for the interface. Thus the first argument
4880 * is always checked to be a number, but is ignored after that.
4881 */
4882 cost = strtol (argv[0], NULL, 10);
4883 if (cost < 1 || cost > 65535)
4884 {
4885 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4886 return CMD_WARNING;
4887 }
4888
4889 if (argc == 2)
4890 {
4891 ret = inet_aton(argv[1], &addr);
4892 if (!ret)
4893 {
4894 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4895 VTY_NEWLINE);
4896 return CMD_WARNING;
4897 }
4898
4899 params = ospf_lookup_if_params (ifp, addr);
4900 if (params == NULL)
4901 return CMD_SUCCESS;
4902 }
4903
4904 UNSET_IF_PARAM (params, output_cost_cmd);
4905
4906 if (params != IF_DEF_PARAMS (ifp))
4907 {
4908 ospf_free_if_params (ifp, addr);
4909 ospf_if_update_params (ifp, addr);
4910 }
4911
4912 ospf_if_recalculate_output_cost (ifp);
4913
4914 return CMD_SUCCESS;
4915}
4916
4917ALIAS (no_ip_ospf_cost2,
4918 no_ospf_cost_u32_cmd,
4919 "no ospf cost <1-65535>",
4920 NO_STR
4921 "OSPF interface commands\n"
4922 "Interface cost\n"
4923 "Cost")
4924
4925ALIAS (no_ip_ospf_cost2,
4926 no_ip_ospf_cost_u32_inet4_cmd,
4927 "no ip ospf cost <1-65535> A.B.C.D",
4928 NO_STR
4929 "IP Information\n"
4930 "OSPF interface commands\n"
4931 "Interface cost\n"
4932 "Cost\n"
4933 "Address of interface")
4934
4935ALIAS (no_ip_ospf_cost2,
4936 no_ospf_cost_u32_inet4_cmd,
4937 "no ospf cost <1-65535> A.B.C.D",
4938 NO_STR
4939 "OSPF interface commands\n"
4940 "Interface cost\n"
4941 "Cost\n"
4942 "Address of interface")
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004943
paul4dadc292005-05-06 21:37:42 +00004944static void
paul718e3742002-12-13 20:15:29 +00004945ospf_nbr_timer_update (struct ospf_interface *oi)
4946{
4947 struct route_node *rn;
4948 struct ospf_neighbor *nbr;
4949
4950 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4951 if ((nbr = rn->info))
4952 {
4953 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4954 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4955 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4956 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4957 }
4958}
4959
paulf9ad9372005-10-21 00:45:17 +00004960static int
4961ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4962 const char *nbr_str,
4963 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004964{
4965 struct interface *ifp = vty->index;
4966 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004967 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004968 struct in_addr addr;
4969 int ret;
4970 struct ospf_if_params *params;
4971 struct ospf_interface *oi;
4972 struct route_node *rn;
4973
4974 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004975
4976 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004977 {
paulf9ad9372005-10-21 00:45:17 +00004978 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004979 if (!ret)
4980 {
4981 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4982 VTY_NEWLINE);
4983 return CMD_WARNING;
4984 }
4985
4986 params = ospf_get_if_params (ifp, addr);
4987 ospf_if_update_params (ifp, addr);
4988 }
4989
paulf9ad9372005-10-21 00:45:17 +00004990 if (interval_str)
4991 {
4992 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4993 1, 65535);
4994
4995 /* reset fast_hello too, just to be sure */
4996 UNSET_IF_PARAM (params, fast_hello);
4997 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4998 }
4999 else if (fast_hello_str)
5000 {
5001 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
5002 1, 10);
5003 /* 1s dead-interval with sub-second hellos desired */
5004 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
5005 SET_IF_PARAM (params, fast_hello);
5006 params->fast_hello = hellomult;
5007 }
5008 else
5009 {
5010 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5011 VTY_NEWLINE);
5012 return CMD_WARNING;
5013 }
5014
paul718e3742002-12-13 20:15:29 +00005015 SET_IF_PARAM (params, v_wait);
5016 params->v_wait = seconds;
5017
5018 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00005019 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005020 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005021 struct ospf *ospf;
5022 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005023 {
5024 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5025 if (oi)
5026 ospf_nbr_timer_update (oi);
5027 }
paul718e3742002-12-13 20:15:29 +00005028 }
5029 else
5030 {
5031 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5032 if ((oi = rn->info))
5033 ospf_nbr_timer_update (oi);
5034 }
5035
5036 return CMD_SUCCESS;
5037}
5038
paulf9ad9372005-10-21 00:45:17 +00005039
5040DEFUN (ip_ospf_dead_interval,
5041 ip_ospf_dead_interval_addr_cmd,
5042 "ip ospf dead-interval <1-65535> A.B.C.D",
5043 "IP Information\n"
5044 "OSPF interface commands\n"
5045 "Interval after which a neighbor is declared dead\n"
5046 "Seconds\n"
5047 "Address of interface\n")
5048{
5049 if (argc == 2)
5050 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5051 else
5052 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5053}
5054
paul718e3742002-12-13 20:15:29 +00005055ALIAS (ip_ospf_dead_interval,
5056 ip_ospf_dead_interval_cmd,
5057 "ip ospf dead-interval <1-65535>",
5058 "IP Information\n"
5059 "OSPF interface commands\n"
5060 "Interval after which a neighbor is declared dead\n"
5061 "Seconds\n")
5062
5063ALIAS (ip_ospf_dead_interval,
5064 ospf_dead_interval_cmd,
5065 "ospf dead-interval <1-65535>",
5066 "OSPF interface commands\n"
5067 "Interval after which a neighbor is declared dead\n"
5068 "Seconds\n")
5069
paulf9ad9372005-10-21 00:45:17 +00005070DEFUN (ip_ospf_dead_interval_minimal,
5071 ip_ospf_dead_interval_minimal_addr_cmd,
5072 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5073 "IP Information\n"
5074 "OSPF interface commands\n"
5075 "Interval after which a neighbor is declared dead\n"
5076 "Minimal 1s dead-interval with fast sub-second hellos\n"
5077 "Hello multiplier factor\n"
5078 "Number of Hellos to send each second\n"
5079 "Address of interface\n")
5080{
5081 if (argc == 2)
5082 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5083 else
5084 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5085}
5086
5087ALIAS (ip_ospf_dead_interval_minimal,
5088 ip_ospf_dead_interval_minimal_cmd,
5089 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5090 "IP Information\n"
5091 "OSPF interface commands\n"
5092 "Interval after which a neighbor is declared dead\n"
5093 "Minimal 1s dead-interval with fast sub-second hellos\n"
5094 "Hello multiplier factor\n"
5095 "Number of Hellos to send each second\n")
5096
paul718e3742002-12-13 20:15:29 +00005097DEFUN (no_ip_ospf_dead_interval,
5098 no_ip_ospf_dead_interval_addr_cmd,
5099 "no ip ospf dead-interval A.B.C.D",
5100 NO_STR
5101 "IP Information\n"
5102 "OSPF interface commands\n"
5103 "Interval after which a neighbor is declared dead\n"
5104 "Address of interface")
5105{
5106 struct interface *ifp = vty->index;
5107 struct in_addr addr;
5108 int ret;
5109 struct ospf_if_params *params;
5110 struct ospf_interface *oi;
5111 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00005112
paul718e3742002-12-13 20:15:29 +00005113 ifp = vty->index;
5114 params = IF_DEF_PARAMS (ifp);
5115
5116 if (argc == 1)
5117 {
5118 ret = inet_aton(argv[0], &addr);
5119 if (!ret)
5120 {
5121 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5122 VTY_NEWLINE);
5123 return CMD_WARNING;
5124 }
5125
5126 params = ospf_lookup_if_params (ifp, addr);
5127 if (params == NULL)
5128 return CMD_SUCCESS;
5129 }
5130
5131 UNSET_IF_PARAM (params, v_wait);
5132 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00005133
5134 UNSET_IF_PARAM (params, fast_hello);
5135 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5136
paul718e3742002-12-13 20:15:29 +00005137 if (params != IF_DEF_PARAMS (ifp))
5138 {
5139 ospf_free_if_params (ifp, addr);
5140 ospf_if_update_params (ifp, addr);
5141 }
5142
5143 /* Update timer values in neighbor structure. */
5144 if (argc == 1)
5145 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005146 struct ospf *ospf;
5147
5148 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005149 {
5150 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5151 if (oi)
5152 ospf_nbr_timer_update (oi);
5153 }
paul718e3742002-12-13 20:15:29 +00005154 }
5155 else
5156 {
5157 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5158 if ((oi = rn->info))
5159 ospf_nbr_timer_update (oi);
5160 }
5161
5162 return CMD_SUCCESS;
5163}
5164
5165ALIAS (no_ip_ospf_dead_interval,
5166 no_ip_ospf_dead_interval_cmd,
5167 "no ip ospf dead-interval",
5168 NO_STR
5169 "IP Information\n"
5170 "OSPF interface commands\n"
5171 "Interval after which a neighbor is declared dead\n")
5172
5173ALIAS (no_ip_ospf_dead_interval,
5174 no_ospf_dead_interval_cmd,
5175 "no ospf dead-interval",
5176 NO_STR
5177 "OSPF interface commands\n"
5178 "Interval after which a neighbor is declared dead\n")
5179
5180DEFUN (ip_ospf_hello_interval,
5181 ip_ospf_hello_interval_addr_cmd,
5182 "ip ospf hello-interval <1-65535> A.B.C.D",
5183 "IP Information\n"
5184 "OSPF interface commands\n"
5185 "Time between HELLO packets\n"
5186 "Seconds\n"
5187 "Address of interface")
5188{
5189 struct interface *ifp = vty->index;
5190 u_int32_t seconds;
5191 struct in_addr addr;
5192 int ret;
5193 struct ospf_if_params *params;
5194
5195 params = IF_DEF_PARAMS (ifp);
5196
5197 seconds = strtol (argv[0], NULL, 10);
5198
5199 /* HelloInterval range is <1-65535>. */
5200 if (seconds < 1 || seconds > 65535)
5201 {
5202 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5203 return CMD_WARNING;
5204 }
5205
5206 if (argc == 2)
5207 {
5208 ret = inet_aton(argv[1], &addr);
5209 if (!ret)
5210 {
5211 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5212 VTY_NEWLINE);
5213 return CMD_WARNING;
5214 }
5215
5216 params = ospf_get_if_params (ifp, addr);
5217 ospf_if_update_params (ifp, addr);
5218 }
5219
paulf9ad9372005-10-21 00:45:17 +00005220 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005221 params->v_hello = seconds;
5222
5223 return CMD_SUCCESS;
5224}
5225
5226ALIAS (ip_ospf_hello_interval,
5227 ip_ospf_hello_interval_cmd,
5228 "ip ospf hello-interval <1-65535>",
5229 "IP Information\n"
5230 "OSPF interface commands\n"
5231 "Time between HELLO packets\n"
5232 "Seconds\n")
5233
5234ALIAS (ip_ospf_hello_interval,
5235 ospf_hello_interval_cmd,
5236 "ospf hello-interval <1-65535>",
5237 "OSPF interface commands\n"
5238 "Time between HELLO packets\n"
5239 "Seconds\n")
5240
5241DEFUN (no_ip_ospf_hello_interval,
5242 no_ip_ospf_hello_interval_addr_cmd,
5243 "no ip ospf hello-interval A.B.C.D",
5244 NO_STR
5245 "IP Information\n"
5246 "OSPF interface commands\n"
5247 "Time between HELLO packets\n"
5248 "Address of interface")
5249{
5250 struct interface *ifp = vty->index;
5251 struct in_addr addr;
5252 int ret;
5253 struct ospf_if_params *params;
5254
5255 ifp = vty->index;
5256 params = IF_DEF_PARAMS (ifp);
5257
5258 if (argc == 1)
5259 {
5260 ret = inet_aton(argv[0], &addr);
5261 if (!ret)
5262 {
5263 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5264 VTY_NEWLINE);
5265 return CMD_WARNING;
5266 }
5267
5268 params = ospf_lookup_if_params (ifp, addr);
5269 if (params == NULL)
5270 return CMD_SUCCESS;
5271 }
5272
5273 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005274 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005275
5276 if (params != IF_DEF_PARAMS (ifp))
5277 {
5278 ospf_free_if_params (ifp, addr);
5279 ospf_if_update_params (ifp, addr);
5280 }
5281
5282 return CMD_SUCCESS;
5283}
5284
5285ALIAS (no_ip_ospf_hello_interval,
5286 no_ip_ospf_hello_interval_cmd,
5287 "no ip ospf hello-interval",
5288 NO_STR
5289 "IP Information\n"
5290 "OSPF interface commands\n"
5291 "Time between HELLO packets\n")
5292
5293ALIAS (no_ip_ospf_hello_interval,
5294 no_ospf_hello_interval_cmd,
5295 "no ospf hello-interval",
5296 NO_STR
5297 "OSPF interface commands\n"
5298 "Time between HELLO packets\n")
5299
5300DEFUN (ip_ospf_network,
5301 ip_ospf_network_cmd,
5302 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5303 "IP Information\n"
5304 "OSPF interface commands\n"
5305 "Network type\n"
5306 "Specify OSPF broadcast multi-access network\n"
5307 "Specify OSPF NBMA network\n"
5308 "Specify OSPF point-to-multipoint network\n"
5309 "Specify OSPF point-to-point network\n")
5310{
5311 struct interface *ifp = vty->index;
5312 int old_type = IF_DEF_PARAMS (ifp)->type;
5313 struct route_node *rn;
5314
5315 if (strncmp (argv[0], "b", 1) == 0)
5316 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5317 else if (strncmp (argv[0], "n", 1) == 0)
5318 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5319 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5320 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5321 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5322 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5323
5324 if (IF_DEF_PARAMS (ifp)->type == old_type)
5325 return CMD_SUCCESS;
5326
5327 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5328
5329 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5330 {
5331 struct ospf_interface *oi = rn->info;
5332
5333 if (!oi)
5334 continue;
5335
5336 oi->type = IF_DEF_PARAMS (ifp)->type;
5337
5338 if (oi->state > ISM_Down)
5339 {
5340 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5341 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5342 }
5343 }
5344
5345 return CMD_SUCCESS;
5346}
5347
5348ALIAS (ip_ospf_network,
5349 ospf_network_cmd,
5350 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5351 "OSPF interface commands\n"
5352 "Network type\n"
5353 "Specify OSPF broadcast multi-access network\n"
5354 "Specify OSPF NBMA network\n"
5355 "Specify OSPF point-to-multipoint network\n"
5356 "Specify OSPF point-to-point network\n")
5357
5358DEFUN (no_ip_ospf_network,
5359 no_ip_ospf_network_cmd,
5360 "no ip ospf network",
5361 NO_STR
5362 "IP Information\n"
5363 "OSPF interface commands\n"
5364 "Network type\n")
5365{
5366 struct interface *ifp = vty->index;
5367 int old_type = IF_DEF_PARAMS (ifp)->type;
5368 struct route_node *rn;
5369
ajsbc18d612004-12-15 15:07:19 +00005370 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005371
5372 if (IF_DEF_PARAMS (ifp)->type == old_type)
5373 return CMD_SUCCESS;
5374
5375 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5376 {
5377 struct ospf_interface *oi = rn->info;
5378
5379 if (!oi)
5380 continue;
5381
5382 oi->type = IF_DEF_PARAMS (ifp)->type;
5383
5384 if (oi->state > ISM_Down)
5385 {
5386 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5387 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5388 }
5389 }
5390
5391 return CMD_SUCCESS;
5392}
5393
5394ALIAS (no_ip_ospf_network,
5395 no_ospf_network_cmd,
5396 "no ospf network",
5397 NO_STR
5398 "OSPF interface commands\n"
5399 "Network type\n")
5400
5401DEFUN (ip_ospf_priority,
5402 ip_ospf_priority_addr_cmd,
5403 "ip ospf priority <0-255> A.B.C.D",
5404 "IP Information\n"
5405 "OSPF interface commands\n"
5406 "Router priority\n"
5407 "Priority\n"
5408 "Address of interface")
5409{
5410 struct interface *ifp = vty->index;
5411 u_int32_t priority;
5412 struct route_node *rn;
5413 struct in_addr addr;
5414 int ret;
5415 struct ospf_if_params *params;
5416
5417 params = IF_DEF_PARAMS (ifp);
5418
5419 priority = strtol (argv[0], NULL, 10);
5420
5421 /* Router Priority range is <0-255>. */
5422 if (priority < 0 || priority > 255)
5423 {
5424 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5425 return CMD_WARNING;
5426 }
5427
5428 if (argc == 2)
5429 {
5430 ret = inet_aton(argv[1], &addr);
5431 if (!ret)
5432 {
5433 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5434 VTY_NEWLINE);
5435 return CMD_WARNING;
5436 }
5437
5438 params = ospf_get_if_params (ifp, addr);
5439 ospf_if_update_params (ifp, addr);
5440 }
5441
5442 SET_IF_PARAM (params, priority);
5443 params->priority = priority;
5444
5445 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5446 {
5447 struct ospf_interface *oi = rn->info;
5448
5449 if (!oi)
5450 continue;
5451
5452
5453 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5454 {
5455 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5456 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5457 }
5458 }
5459
5460 return CMD_SUCCESS;
5461}
5462
5463ALIAS (ip_ospf_priority,
5464 ip_ospf_priority_cmd,
5465 "ip ospf priority <0-255>",
5466 "IP Information\n"
5467 "OSPF interface commands\n"
5468 "Router priority\n"
5469 "Priority\n")
5470
5471ALIAS (ip_ospf_priority,
5472 ospf_priority_cmd,
5473 "ospf priority <0-255>",
5474 "OSPF interface commands\n"
5475 "Router priority\n"
5476 "Priority\n")
5477
5478DEFUN (no_ip_ospf_priority,
5479 no_ip_ospf_priority_addr_cmd,
5480 "no ip ospf priority A.B.C.D",
5481 NO_STR
5482 "IP Information\n"
5483 "OSPF interface commands\n"
5484 "Router priority\n"
5485 "Address of interface")
5486{
5487 struct interface *ifp = vty->index;
5488 struct route_node *rn;
5489 struct in_addr addr;
5490 int ret;
5491 struct ospf_if_params *params;
5492
5493 ifp = vty->index;
5494 params = IF_DEF_PARAMS (ifp);
5495
5496 if (argc == 1)
5497 {
5498 ret = inet_aton(argv[0], &addr);
5499 if (!ret)
5500 {
5501 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5502 VTY_NEWLINE);
5503 return CMD_WARNING;
5504 }
5505
5506 params = ospf_lookup_if_params (ifp, addr);
5507 if (params == NULL)
5508 return CMD_SUCCESS;
5509 }
5510
5511 UNSET_IF_PARAM (params, priority);
5512 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5513
5514 if (params != IF_DEF_PARAMS (ifp))
5515 {
5516 ospf_free_if_params (ifp, addr);
5517 ospf_if_update_params (ifp, addr);
5518 }
5519
5520 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5521 {
5522 struct ospf_interface *oi = rn->info;
5523
5524 if (!oi)
5525 continue;
5526
5527
5528 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5529 {
5530 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5531 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5532 }
5533 }
5534
5535 return CMD_SUCCESS;
5536}
5537
5538ALIAS (no_ip_ospf_priority,
5539 no_ip_ospf_priority_cmd,
5540 "no ip ospf priority",
5541 NO_STR
5542 "IP Information\n"
5543 "OSPF interface commands\n"
5544 "Router priority\n")
5545
5546ALIAS (no_ip_ospf_priority,
5547 no_ospf_priority_cmd,
5548 "no ospf priority",
5549 NO_STR
5550 "OSPF interface commands\n"
5551 "Router priority\n")
5552
5553DEFUN (ip_ospf_retransmit_interval,
5554 ip_ospf_retransmit_interval_addr_cmd,
5555 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5556 "IP Information\n"
5557 "OSPF interface commands\n"
5558 "Time between retransmitting lost link state advertisements\n"
5559 "Seconds\n"
5560 "Address of interface")
5561{
5562 struct interface *ifp = vty->index;
5563 u_int32_t seconds;
5564 struct in_addr addr;
5565 int ret;
5566 struct ospf_if_params *params;
5567
5568 params = IF_DEF_PARAMS (ifp);
5569 seconds = strtol (argv[0], NULL, 10);
5570
5571 /* Retransmit Interval range is <3-65535>. */
5572 if (seconds < 3 || seconds > 65535)
5573 {
5574 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5575 return CMD_WARNING;
5576 }
5577
5578
5579 if (argc == 2)
5580 {
5581 ret = inet_aton(argv[1], &addr);
5582 if (!ret)
5583 {
5584 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5585 VTY_NEWLINE);
5586 return CMD_WARNING;
5587 }
5588
5589 params = ospf_get_if_params (ifp, addr);
5590 ospf_if_update_params (ifp, addr);
5591 }
5592
5593 SET_IF_PARAM (params, retransmit_interval);
5594 params->retransmit_interval = seconds;
5595
5596 return CMD_SUCCESS;
5597}
5598
5599ALIAS (ip_ospf_retransmit_interval,
5600 ip_ospf_retransmit_interval_cmd,
5601 "ip ospf retransmit-interval <3-65535>",
5602 "IP Information\n"
5603 "OSPF interface commands\n"
5604 "Time between retransmitting lost link state advertisements\n"
5605 "Seconds\n")
5606
5607ALIAS (ip_ospf_retransmit_interval,
5608 ospf_retransmit_interval_cmd,
5609 "ospf retransmit-interval <3-65535>",
5610 "OSPF interface commands\n"
5611 "Time between retransmitting lost link state advertisements\n"
5612 "Seconds\n")
5613
5614DEFUN (no_ip_ospf_retransmit_interval,
5615 no_ip_ospf_retransmit_interval_addr_cmd,
5616 "no ip ospf retransmit-interval A.B.C.D",
5617 NO_STR
5618 "IP Information\n"
5619 "OSPF interface commands\n"
5620 "Time between retransmitting lost link state advertisements\n"
5621 "Address of interface")
5622{
5623 struct interface *ifp = vty->index;
5624 struct in_addr addr;
5625 int ret;
5626 struct ospf_if_params *params;
5627
5628 ifp = vty->index;
5629 params = IF_DEF_PARAMS (ifp);
5630
5631 if (argc == 1)
5632 {
5633 ret = inet_aton(argv[0], &addr);
5634 if (!ret)
5635 {
5636 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5637 VTY_NEWLINE);
5638 return CMD_WARNING;
5639 }
5640
5641 params = ospf_lookup_if_params (ifp, addr);
5642 if (params == NULL)
5643 return CMD_SUCCESS;
5644 }
5645
5646 UNSET_IF_PARAM (params, retransmit_interval);
5647 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5648
5649 if (params != IF_DEF_PARAMS (ifp))
5650 {
5651 ospf_free_if_params (ifp, addr);
5652 ospf_if_update_params (ifp, addr);
5653 }
5654
5655 return CMD_SUCCESS;
5656}
5657
5658ALIAS (no_ip_ospf_retransmit_interval,
5659 no_ip_ospf_retransmit_interval_cmd,
5660 "no ip ospf retransmit-interval",
5661 NO_STR
5662 "IP Information\n"
5663 "OSPF interface commands\n"
5664 "Time between retransmitting lost link state advertisements\n")
5665
5666ALIAS (no_ip_ospf_retransmit_interval,
5667 no_ospf_retransmit_interval_cmd,
5668 "no ospf retransmit-interval",
5669 NO_STR
5670 "OSPF interface commands\n"
5671 "Time between retransmitting lost link state advertisements\n")
5672
5673DEFUN (ip_ospf_transmit_delay,
5674 ip_ospf_transmit_delay_addr_cmd,
5675 "ip ospf transmit-delay <1-65535> A.B.C.D",
5676 "IP Information\n"
5677 "OSPF interface commands\n"
5678 "Link state transmit delay\n"
5679 "Seconds\n"
5680 "Address of interface")
5681{
5682 struct interface *ifp = vty->index;
5683 u_int32_t seconds;
5684 struct in_addr addr;
5685 int ret;
5686 struct ospf_if_params *params;
5687
5688 params = IF_DEF_PARAMS (ifp);
5689 seconds = strtol (argv[0], NULL, 10);
5690
5691 /* Transmit Delay range is <1-65535>. */
5692 if (seconds < 1 || seconds > 65535)
5693 {
5694 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5695 return CMD_WARNING;
5696 }
5697
5698 if (argc == 2)
5699 {
5700 ret = inet_aton(argv[1], &addr);
5701 if (!ret)
5702 {
5703 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5704 VTY_NEWLINE);
5705 return CMD_WARNING;
5706 }
5707
5708 params = ospf_get_if_params (ifp, addr);
5709 ospf_if_update_params (ifp, addr);
5710 }
5711
5712 SET_IF_PARAM (params, transmit_delay);
5713 params->transmit_delay = seconds;
5714
5715 return CMD_SUCCESS;
5716}
5717
5718ALIAS (ip_ospf_transmit_delay,
5719 ip_ospf_transmit_delay_cmd,
5720 "ip ospf transmit-delay <1-65535>",
5721 "IP Information\n"
5722 "OSPF interface commands\n"
5723 "Link state transmit delay\n"
5724 "Seconds\n")
5725
5726ALIAS (ip_ospf_transmit_delay,
5727 ospf_transmit_delay_cmd,
5728 "ospf transmit-delay <1-65535>",
5729 "OSPF interface commands\n"
5730 "Link state transmit delay\n"
5731 "Seconds\n")
5732
5733DEFUN (no_ip_ospf_transmit_delay,
5734 no_ip_ospf_transmit_delay_addr_cmd,
5735 "no ip ospf transmit-delay A.B.C.D",
5736 NO_STR
5737 "IP Information\n"
5738 "OSPF interface commands\n"
5739 "Link state transmit delay\n"
5740 "Address of interface")
5741{
5742 struct interface *ifp = vty->index;
5743 struct in_addr addr;
5744 int ret;
5745 struct ospf_if_params *params;
5746
5747 ifp = vty->index;
5748 params = IF_DEF_PARAMS (ifp);
5749
5750 if (argc == 1)
5751 {
5752 ret = inet_aton(argv[0], &addr);
5753 if (!ret)
5754 {
5755 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5756 VTY_NEWLINE);
5757 return CMD_WARNING;
5758 }
5759
5760 params = ospf_lookup_if_params (ifp, addr);
5761 if (params == NULL)
5762 return CMD_SUCCESS;
5763 }
5764
5765 UNSET_IF_PARAM (params, transmit_delay);
5766 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5767
5768 if (params != IF_DEF_PARAMS (ifp))
5769 {
5770 ospf_free_if_params (ifp, addr);
5771 ospf_if_update_params (ifp, addr);
5772 }
5773
5774 return CMD_SUCCESS;
5775}
5776
5777ALIAS (no_ip_ospf_transmit_delay,
5778 no_ip_ospf_transmit_delay_cmd,
5779 "no ip ospf transmit-delay",
5780 NO_STR
5781 "IP Information\n"
5782 "OSPF interface commands\n"
5783 "Link state transmit delay\n")
5784
5785ALIAS (no_ip_ospf_transmit_delay,
5786 no_ospf_transmit_delay_cmd,
5787 "no ospf transmit-delay",
5788 NO_STR
5789 "OSPF interface commands\n"
5790 "Link state transmit delay\n")
5791
5792
5793DEFUN (ospf_redistribute_source_metric_type,
5794 ospf_redistribute_source_metric_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005795 "redistribute " QUAGGA_REDIST_STR_OSPFD
5796 " metric <0-16777214> metric-type (1|2) route-map WORD",
5797 REDIST_STR
5798 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005799 "Metric for redistributed routes\n"
5800 "OSPF default metric\n"
5801 "OSPF exterior metric type for redistributed routes\n"
5802 "Set OSPF External Type 1 metrics\n"
5803 "Set OSPF External Type 2 metrics\n"
5804 "Route map reference\n"
5805 "Pointer to route-map entries\n")
5806{
paul020709f2003-04-04 02:44:16 +00005807 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005808 int source;
5809 int type = -1;
5810 int metric = -1;
5811
5812 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005813 source = proto_redistnum(AFI_IP, argv[0]);
5814 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005815 return CMD_WARNING;
5816
5817 /* Get metric value. */
5818 if (argc >= 2)
5819 if (!str2metric (argv[1], &metric))
5820 return CMD_WARNING;
5821
5822 /* Get metric type. */
5823 if (argc >= 3)
5824 if (!str2metric_type (argv[2], &type))
5825 return CMD_WARNING;
5826
5827 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005828 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005829 else
paul020709f2003-04-04 02:44:16 +00005830 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005831
paul020709f2003-04-04 02:44:16 +00005832 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005833}
5834
5835ALIAS (ospf_redistribute_source_metric_type,
5836 ospf_redistribute_source_metric_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005837 "redistribute " QUAGGA_REDIST_STR_OSPFD
5838 " metric <0-16777214> metric-type (1|2)",
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 "OSPF exterior metric type for redistributed routes\n"
5844 "Set OSPF External Type 1 metrics\n"
5845 "Set OSPF External Type 2 metrics\n")
5846
5847ALIAS (ospf_redistribute_source_metric_type,
5848 ospf_redistribute_source_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005849 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5850 REDIST_STR
5851 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005852 "Metric for redistributed routes\n"
5853 "OSPF default metric\n")
5854
5855DEFUN (ospf_redistribute_source_type_metric,
5856 ospf_redistribute_source_type_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005857 "redistribute " QUAGGA_REDIST_STR_OSPFD
5858 " metric-type (1|2) metric <0-16777214> route-map WORD",
5859 REDIST_STR
5860 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005861 "OSPF exterior metric type for redistributed routes\n"
5862 "Set OSPF External Type 1 metrics\n"
5863 "Set OSPF External Type 2 metrics\n"
5864 "Metric for redistributed routes\n"
5865 "OSPF default metric\n"
5866 "Route map reference\n"
5867 "Pointer to route-map entries\n")
5868{
paul020709f2003-04-04 02:44:16 +00005869 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005870 int source;
5871 int type = -1;
5872 int metric = -1;
5873
5874 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005875 source = proto_redistnum(AFI_IP, argv[0]);
5876 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005877 return CMD_WARNING;
5878
5879 /* Get metric value. */
5880 if (argc >= 2)
5881 if (!str2metric_type (argv[1], &type))
5882 return CMD_WARNING;
5883
5884 /* Get metric type. */
5885 if (argc >= 3)
5886 if (!str2metric (argv[2], &metric))
5887 return CMD_WARNING;
5888
5889 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005890 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005891 else
paul020709f2003-04-04 02:44:16 +00005892 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005893
paul020709f2003-04-04 02:44:16 +00005894 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005895}
5896
5897ALIAS (ospf_redistribute_source_type_metric,
5898 ospf_redistribute_source_type_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005899 "redistribute " QUAGGA_REDIST_STR_OSPFD
5900 " metric-type (1|2) metric <0-16777214>",
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 "Metric for redistributed routes\n"
5907 "OSPF default metric\n")
5908
5909ALIAS (ospf_redistribute_source_type_metric,
5910 ospf_redistribute_source_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005911 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5912 REDIST_STR
5913 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005914 "OSPF exterior metric type for redistributed routes\n"
5915 "Set OSPF External Type 1 metrics\n"
5916 "Set OSPF External Type 2 metrics\n")
5917
5918ALIAS (ospf_redistribute_source_type_metric,
5919 ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005920 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5921 REDIST_STR
5922 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005923
5924DEFUN (ospf_redistribute_source_metric_routemap,
5925 ospf_redistribute_source_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005926 "redistribute " QUAGGA_REDIST_STR_OSPFD
5927 " metric <0-16777214> route-map WORD",
5928 REDIST_STR
5929 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005930 "Metric for redistributed routes\n"
5931 "OSPF default metric\n"
5932 "Route map reference\n"
5933 "Pointer to route-map entries\n")
5934{
paul020709f2003-04-04 02:44:16 +00005935 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005936 int source;
5937 int metric = -1;
5938
5939 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005940 source = proto_redistnum(AFI_IP, argv[0]);
5941 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005942 return CMD_WARNING;
5943
5944 /* Get metric value. */
5945 if (argc >= 2)
5946 if (!str2metric (argv[1], &metric))
5947 return CMD_WARNING;
5948
5949 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005950 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005951 else
paul020709f2003-04-04 02:44:16 +00005952 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005953
paul020709f2003-04-04 02:44:16 +00005954 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005955}
5956
5957DEFUN (ospf_redistribute_source_type_routemap,
5958 ospf_redistribute_source_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005959 "redistribute " QUAGGA_REDIST_STR_OSPFD
5960 " metric-type (1|2) route-map WORD",
5961 REDIST_STR
5962 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005963 "OSPF exterior metric type for redistributed routes\n"
5964 "Set OSPF External Type 1 metrics\n"
5965 "Set OSPF External Type 2 metrics\n"
5966 "Route map reference\n"
5967 "Pointer to route-map entries\n")
5968{
paul020709f2003-04-04 02:44:16 +00005969 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005970 int source;
5971 int type = -1;
5972
5973 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005974 source = proto_redistnum(AFI_IP, argv[0]);
5975 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005976 return CMD_WARNING;
5977
5978 /* Get metric value. */
5979 if (argc >= 2)
5980 if (!str2metric_type (argv[1], &type))
5981 return CMD_WARNING;
5982
5983 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005984 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005985 else
paul020709f2003-04-04 02:44:16 +00005986 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005987
paul020709f2003-04-04 02:44:16 +00005988 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005989}
5990
5991DEFUN (ospf_redistribute_source_routemap,
5992 ospf_redistribute_source_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005993 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5994 REDIST_STR
5995 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005996 "Route map reference\n"
5997 "Pointer to route-map entries\n")
5998{
paul020709f2003-04-04 02:44:16 +00005999 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006000 int source;
6001
6002 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02006003 source = proto_redistnum(AFI_IP, argv[0]);
6004 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006005 return CMD_WARNING;
6006
6007 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006008 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00006009 else
paul020709f2003-04-04 02:44:16 +00006010 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006011
paul020709f2003-04-04 02:44:16 +00006012 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00006013}
6014
6015DEFUN (no_ospf_redistribute_source,
6016 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006017 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006018 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006019 REDIST_STR
6020 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006021{
paul020709f2003-04-04 02:44:16 +00006022 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006023 int source;
6024
David Lampartere0ca5fd2009-09-16 01:52:42 +02006025 source = proto_redistnum(AFI_IP, argv[0]);
6026 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006027 return CMD_WARNING;
6028
paul020709f2003-04-04 02:44:16 +00006029 ospf_routemap_unset (ospf, source);
6030 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006031}
6032
6033DEFUN (ospf_distribute_list_out,
6034 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006035 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006036 "Filter networks in routing updates\n"
6037 "Access-list name\n"
6038 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006039 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006040{
paul68980082003-03-25 05:07:42 +00006041 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006042 int source;
6043
6044 /* Get distribute source. */
Christian Frankebda3c322012-12-04 11:31:16 -08006045 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02006046 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006047 return CMD_WARNING;
6048
paul68980082003-03-25 05:07:42 +00006049 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006050}
6051
6052DEFUN (no_ospf_distribute_list_out,
6053 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006054 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006055 NO_STR
6056 "Filter networks in routing updates\n"
6057 "Access-list name\n"
6058 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006059 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006060{
paul68980082003-03-25 05:07:42 +00006061 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006062 int source;
6063
Christian Frankebda3c322012-12-04 11:31:16 -08006064 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02006065 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006066 return CMD_WARNING;
6067
paul68980082003-03-25 05:07:42 +00006068 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006069}
6070
6071/* Default information originate. */
6072DEFUN (ospf_default_information_originate_metric_type_routemap,
6073 ospf_default_information_originate_metric_type_routemap_cmd,
6074 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
6075 "Control distribution of default information\n"
6076 "Distribute a default route\n"
6077 "OSPF default metric\n"
6078 "OSPF metric\n"
6079 "OSPF metric type for default routes\n"
6080 "Set OSPF External Type 1 metrics\n"
6081 "Set OSPF External Type 2 metrics\n"
6082 "Route map reference\n"
6083 "Pointer to route-map entries\n")
6084{
paul020709f2003-04-04 02:44:16 +00006085 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006086 int type = -1;
6087 int metric = -1;
6088
6089 /* Get metric value. */
6090 if (argc >= 1)
6091 if (!str2metric (argv[0], &metric))
6092 return CMD_WARNING;
6093
6094 /* Get metric type. */
6095 if (argc >= 2)
6096 if (!str2metric_type (argv[1], &type))
6097 return CMD_WARNING;
6098
6099 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006100 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006101 else
paul020709f2003-04-04 02:44:16 +00006102 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006103
paul020709f2003-04-04 02:44:16 +00006104 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6105 type, metric);
paul718e3742002-12-13 20:15:29 +00006106}
6107
6108ALIAS (ospf_default_information_originate_metric_type_routemap,
6109 ospf_default_information_originate_metric_type_cmd,
6110 "default-information originate metric <0-16777214> metric-type (1|2)",
6111 "Control distribution of default information\n"
6112 "Distribute a default route\n"
6113 "OSPF default metric\n"
6114 "OSPF metric\n"
6115 "OSPF metric type for default routes\n"
6116 "Set OSPF External Type 1 metrics\n"
6117 "Set OSPF External Type 2 metrics\n")
6118
6119ALIAS (ospf_default_information_originate_metric_type_routemap,
6120 ospf_default_information_originate_metric_cmd,
6121 "default-information originate metric <0-16777214>",
6122 "Control distribution of default information\n"
6123 "Distribute a default route\n"
6124 "OSPF default metric\n"
6125 "OSPF metric\n")
6126
6127ALIAS (ospf_default_information_originate_metric_type_routemap,
6128 ospf_default_information_originate_cmd,
6129 "default-information originate",
6130 "Control distribution of default information\n"
6131 "Distribute a default route\n")
6132
6133/* Default information originate. */
6134DEFUN (ospf_default_information_originate_metric_routemap,
6135 ospf_default_information_originate_metric_routemap_cmd,
6136 "default-information originate metric <0-16777214> route-map WORD",
6137 "Control distribution of default information\n"
6138 "Distribute a default route\n"
6139 "OSPF default metric\n"
6140 "OSPF metric\n"
6141 "Route map reference\n"
6142 "Pointer to route-map entries\n")
6143{
paul020709f2003-04-04 02:44:16 +00006144 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006145 int metric = -1;
6146
6147 /* Get metric value. */
6148 if (argc >= 1)
6149 if (!str2metric (argv[0], &metric))
6150 return CMD_WARNING;
6151
6152 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006153 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006154 else
paul020709f2003-04-04 02:44:16 +00006155 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006156
paul020709f2003-04-04 02:44:16 +00006157 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6158 -1, metric);
paul718e3742002-12-13 20:15:29 +00006159}
6160
6161/* Default information originate. */
6162DEFUN (ospf_default_information_originate_routemap,
6163 ospf_default_information_originate_routemap_cmd,
6164 "default-information originate route-map WORD",
6165 "Control distribution of default information\n"
6166 "Distribute a default route\n"
6167 "Route map reference\n"
6168 "Pointer to route-map entries\n")
6169{
paul020709f2003-04-04 02:44:16 +00006170 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006171
paul020709f2003-04-04 02:44:16 +00006172 if (argc == 1)
6173 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6174 else
6175 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6176
6177 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00006178}
6179
6180DEFUN (ospf_default_information_originate_type_metric_routemap,
6181 ospf_default_information_originate_type_metric_routemap_cmd,
6182 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6183 "Control distribution of default information\n"
6184 "Distribute a default route\n"
6185 "OSPF metric type for default routes\n"
6186 "Set OSPF External Type 1 metrics\n"
6187 "Set OSPF External Type 2 metrics\n"
6188 "OSPF default metric\n"
6189 "OSPF metric\n"
6190 "Route map reference\n"
6191 "Pointer to route-map entries\n")
6192{
paul020709f2003-04-04 02:44:16 +00006193 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006194 int type = -1;
6195 int metric = -1;
6196
6197 /* Get metric type. */
6198 if (argc >= 1)
6199 if (!str2metric_type (argv[0], &type))
6200 return CMD_WARNING;
6201
6202 /* Get metric value. */
6203 if (argc >= 2)
6204 if (!str2metric (argv[1], &metric))
6205 return CMD_WARNING;
6206
6207 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006208 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006209 else
paul020709f2003-04-04 02:44:16 +00006210 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006211
paul020709f2003-04-04 02:44:16 +00006212 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6213 type, metric);
paul718e3742002-12-13 20:15:29 +00006214}
6215
6216ALIAS (ospf_default_information_originate_type_metric_routemap,
6217 ospf_default_information_originate_type_metric_cmd,
6218 "default-information originate metric-type (1|2) metric <0-16777214>",
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 "OSPF default metric\n"
6225 "OSPF metric\n")
6226
6227ALIAS (ospf_default_information_originate_type_metric_routemap,
6228 ospf_default_information_originate_type_cmd,
6229 "default-information originate metric-type (1|2)",
6230 "Control distribution of default information\n"
6231 "Distribute a default route\n"
6232 "OSPF metric type for default routes\n"
6233 "Set OSPF External Type 1 metrics\n"
6234 "Set OSPF External Type 2 metrics\n")
6235
6236DEFUN (ospf_default_information_originate_type_routemap,
6237 ospf_default_information_originate_type_routemap_cmd,
6238 "default-information originate metric-type (1|2) route-map WORD",
6239 "Control distribution of default information\n"
6240 "Distribute a default route\n"
6241 "OSPF metric type for default routes\n"
6242 "Set OSPF External Type 1 metrics\n"
6243 "Set OSPF External Type 2 metrics\n"
6244 "Route map reference\n"
6245 "Pointer to route-map entries\n")
6246{
paul020709f2003-04-04 02:44:16 +00006247 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006248 int type = -1;
6249
6250 /* Get metric type. */
6251 if (argc >= 1)
6252 if (!str2metric_type (argv[0], &type))
6253 return CMD_WARNING;
6254
6255 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006256 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006257 else
paul020709f2003-04-04 02:44:16 +00006258 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006259
paul020709f2003-04-04 02:44:16 +00006260 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6261 type, -1);
paul718e3742002-12-13 20:15:29 +00006262}
6263
6264DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6265 ospf_default_information_originate_always_metric_type_routemap_cmd,
6266 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6267 "Control distribution of default information\n"
6268 "Distribute a default route\n"
6269 "Always advertise default route\n"
6270 "OSPF default metric\n"
6271 "OSPF metric\n"
6272 "OSPF metric type for default routes\n"
6273 "Set OSPF External Type 1 metrics\n"
6274 "Set OSPF External Type 2 metrics\n"
6275 "Route map reference\n"
6276 "Pointer to route-map entries\n")
6277{
paul020709f2003-04-04 02:44:16 +00006278 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006279 int type = -1;
6280 int metric = -1;
6281
6282 /* Get metric value. */
6283 if (argc >= 1)
6284 if (!str2metric (argv[0], &metric))
6285 return CMD_WARNING;
6286
6287 /* Get metric type. */
6288 if (argc >= 2)
6289 if (!str2metric_type (argv[1], &type))
6290 return CMD_WARNING;
6291
6292 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006293 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006294 else
paul020709f2003-04-04 02:44:16 +00006295 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006296
paul020709f2003-04-04 02:44:16 +00006297 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006298 type, metric);
6299}
6300
6301ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6302 ospf_default_information_originate_always_metric_type_cmd,
6303 "default-information originate always metric <0-16777214> metric-type (1|2)",
6304 "Control distribution of default information\n"
6305 "Distribute a default route\n"
6306 "Always advertise default route\n"
6307 "OSPF default metric\n"
6308 "OSPF metric\n"
6309 "OSPF metric type for default routes\n"
6310 "Set OSPF External Type 1 metrics\n"
6311 "Set OSPF External Type 2 metrics\n")
6312
6313ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6314 ospf_default_information_originate_always_metric_cmd,
6315 "default-information originate always metric <0-16777214>",
6316 "Control distribution of default information\n"
6317 "Distribute a default route\n"
6318 "Always advertise default route\n"
6319 "OSPF default metric\n"
6320 "OSPF metric\n"
6321 "OSPF metric type for default routes\n")
6322
6323ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6324 ospf_default_information_originate_always_cmd,
6325 "default-information originate always",
6326 "Control distribution of default information\n"
6327 "Distribute a default route\n"
6328 "Always advertise default route\n")
6329
6330DEFUN (ospf_default_information_originate_always_metric_routemap,
6331 ospf_default_information_originate_always_metric_routemap_cmd,
6332 "default-information originate always metric <0-16777214> route-map WORD",
6333 "Control distribution of default information\n"
6334 "Distribute a default route\n"
6335 "Always advertise default route\n"
6336 "OSPF default metric\n"
6337 "OSPF metric\n"
6338 "Route map reference\n"
6339 "Pointer to route-map entries\n")
6340{
paul020709f2003-04-04 02:44:16 +00006341 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006342 int metric = -1;
6343
6344 /* Get metric value. */
6345 if (argc >= 1)
6346 if (!str2metric (argv[0], &metric))
6347 return CMD_WARNING;
6348
6349 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006350 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006351 else
paul020709f2003-04-04 02:44:16 +00006352 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006353
paul020709f2003-04-04 02:44:16 +00006354 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6355 -1, metric);
paul718e3742002-12-13 20:15:29 +00006356}
6357
6358DEFUN (ospf_default_information_originate_always_routemap,
6359 ospf_default_information_originate_always_routemap_cmd,
6360 "default-information originate always route-map WORD",
6361 "Control distribution of default information\n"
6362 "Distribute a default route\n"
6363 "Always advertise default route\n"
6364 "Route map reference\n"
6365 "Pointer to route-map entries\n")
6366{
paul020709f2003-04-04 02:44:16 +00006367 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006368
paul020709f2003-04-04 02:44:16 +00006369 if (argc == 1)
6370 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6371 else
6372 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6373
6374 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006375}
6376
6377DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6378 ospf_default_information_originate_always_type_metric_routemap_cmd,
6379 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6380 "Control distribution of default information\n"
6381 "Distribute a default route\n"
6382 "Always advertise default route\n"
6383 "OSPF metric type for default routes\n"
6384 "Set OSPF External Type 1 metrics\n"
6385 "Set OSPF External Type 2 metrics\n"
6386 "OSPF default metric\n"
6387 "OSPF metric\n"
6388 "Route map reference\n"
6389 "Pointer to route-map entries\n")
6390{
paul020709f2003-04-04 02:44:16 +00006391 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006392 int type = -1;
6393 int metric = -1;
6394
6395 /* Get metric type. */
6396 if (argc >= 1)
6397 if (!str2metric_type (argv[0], &type))
6398 return CMD_WARNING;
6399
6400 /* Get metric value. */
6401 if (argc >= 2)
6402 if (!str2metric (argv[1], &metric))
6403 return CMD_WARNING;
6404
6405 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006406 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006407 else
paul020709f2003-04-04 02:44:16 +00006408 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006409
paul020709f2003-04-04 02:44:16 +00006410 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006411 type, metric);
6412}
6413
6414ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6415 ospf_default_information_originate_always_type_metric_cmd,
6416 "default-information originate always metric-type (1|2) metric <0-16777214>",
6417 "Control distribution of default information\n"
6418 "Distribute a default route\n"
6419 "Always advertise default route\n"
6420 "OSPF metric type for default routes\n"
6421 "Set OSPF External Type 1 metrics\n"
6422 "Set OSPF External Type 2 metrics\n"
6423 "OSPF default metric\n"
6424 "OSPF metric\n")
6425
6426ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6427 ospf_default_information_originate_always_type_cmd,
6428 "default-information originate always metric-type (1|2)",
6429 "Control distribution of default information\n"
6430 "Distribute a default route\n"
6431 "Always advertise default route\n"
6432 "OSPF metric type for default routes\n"
6433 "Set OSPF External Type 1 metrics\n"
6434 "Set OSPF External Type 2 metrics\n")
6435
6436DEFUN (ospf_default_information_originate_always_type_routemap,
6437 ospf_default_information_originate_always_type_routemap_cmd,
6438 "default-information originate always metric-type (1|2) route-map WORD",
6439 "Control distribution of default information\n"
6440 "Distribute a default route\n"
6441 "Always advertise default route\n"
6442 "OSPF metric type for default routes\n"
6443 "Set OSPF External Type 1 metrics\n"
6444 "Set OSPF External Type 2 metrics\n"
6445 "Route map reference\n"
6446 "Pointer to route-map entries\n")
6447{
paul020709f2003-04-04 02:44:16 +00006448 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006449 int type = -1;
6450
6451 /* Get metric type. */
6452 if (argc >= 1)
6453 if (!str2metric_type (argv[0], &type))
6454 return CMD_WARNING;
6455
6456 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006457 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006458 else
paul020709f2003-04-04 02:44:16 +00006459 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006460
paul020709f2003-04-04 02:44:16 +00006461 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006462 type, -1);
6463}
6464
6465DEFUN (no_ospf_default_information_originate,
6466 no_ospf_default_information_originate_cmd,
6467 "no default-information originate",
6468 NO_STR
6469 "Control distribution of default information\n"
6470 "Distribute a default route\n")
6471{
paul68980082003-03-25 05:07:42 +00006472 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006473 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006474
6475 p.family = AF_INET;
6476 p.prefix.s_addr = 0;
6477 p.prefixlen = 0;
6478
ajs5339cfd2005-09-19 13:28:05 +00006479 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006480
6481 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6482 ospf_external_info_delete (DEFAULT_ROUTE, p);
6483 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6484 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6485 }
6486
paul020709f2003-04-04 02:44:16 +00006487 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6488 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006489}
6490
6491DEFUN (ospf_default_metric,
6492 ospf_default_metric_cmd,
6493 "default-metric <0-16777214>",
6494 "Set metric of redistributed routes\n"
6495 "Default metric\n")
6496{
paul68980082003-03-25 05:07:42 +00006497 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006498 int metric = -1;
6499
6500 if (!str2metric (argv[0], &metric))
6501 return CMD_WARNING;
6502
paul68980082003-03-25 05:07:42 +00006503 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006504
6505 return CMD_SUCCESS;
6506}
6507
6508DEFUN (no_ospf_default_metric,
6509 no_ospf_default_metric_cmd,
6510 "no default-metric",
6511 NO_STR
6512 "Set metric of redistributed routes\n")
6513{
paul68980082003-03-25 05:07:42 +00006514 struct ospf *ospf = vty->index;
6515
6516 ospf->default_metric = -1;
6517
paul718e3742002-12-13 20:15:29 +00006518 return CMD_SUCCESS;
6519}
6520
6521ALIAS (no_ospf_default_metric,
6522 no_ospf_default_metric_val_cmd,
6523 "no default-metric <0-16777214>",
6524 NO_STR
6525 "Set metric of redistributed routes\n"
6526 "Default metric\n")
6527
6528DEFUN (ospf_distance,
6529 ospf_distance_cmd,
6530 "distance <1-255>",
6531 "Define an administrative distance\n"
6532 "OSPF Administrative distance\n")
6533{
paul68980082003-03-25 05:07:42 +00006534 struct ospf *ospf = vty->index;
6535
6536 ospf->distance_all = atoi (argv[0]);
6537
paul718e3742002-12-13 20:15:29 +00006538 return CMD_SUCCESS;
6539}
6540
6541DEFUN (no_ospf_distance,
6542 no_ospf_distance_cmd,
6543 "no distance <1-255>",
6544 NO_STR
6545 "Define an administrative distance\n"
6546 "OSPF Administrative distance\n")
6547{
paul68980082003-03-25 05:07:42 +00006548 struct ospf *ospf = vty->index;
6549
6550 ospf->distance_all = 0;
6551
paul718e3742002-12-13 20:15:29 +00006552 return CMD_SUCCESS;
6553}
6554
6555DEFUN (no_ospf_distance_ospf,
6556 no_ospf_distance_ospf_cmd,
6557 "no distance ospf",
6558 NO_STR
6559 "Define an administrative distance\n"
6560 "OSPF Administrative distance\n"
6561 "OSPF Distance\n")
6562{
paul68980082003-03-25 05:07:42 +00006563 struct ospf *ospf = vty->index;
6564
6565 ospf->distance_intra = 0;
6566 ospf->distance_inter = 0;
6567 ospf->distance_external = 0;
6568
paul718e3742002-12-13 20:15:29 +00006569 return CMD_SUCCESS;
6570}
6571
6572DEFUN (ospf_distance_ospf_intra,
6573 ospf_distance_ospf_intra_cmd,
6574 "distance ospf intra-area <1-255>",
6575 "Define an administrative distance\n"
6576 "OSPF Administrative distance\n"
6577 "Intra-area routes\n"
6578 "Distance for intra-area routes\n")
6579{
paul68980082003-03-25 05:07:42 +00006580 struct ospf *ospf = vty->index;
6581
6582 ospf->distance_intra = atoi (argv[0]);
6583
paul718e3742002-12-13 20:15:29 +00006584 return CMD_SUCCESS;
6585}
6586
6587DEFUN (ospf_distance_ospf_intra_inter,
6588 ospf_distance_ospf_intra_inter_cmd,
6589 "distance ospf intra-area <1-255> inter-area <1-255>",
6590 "Define an administrative distance\n"
6591 "OSPF Administrative distance\n"
6592 "Intra-area routes\n"
6593 "Distance for intra-area routes\n"
6594 "Inter-area routes\n"
6595 "Distance for inter-area routes\n")
6596{
paul68980082003-03-25 05:07:42 +00006597 struct ospf *ospf = vty->index;
6598
6599 ospf->distance_intra = atoi (argv[0]);
6600 ospf->distance_inter = atoi (argv[1]);
6601
paul718e3742002-12-13 20:15:29 +00006602 return CMD_SUCCESS;
6603}
6604
6605DEFUN (ospf_distance_ospf_intra_external,
6606 ospf_distance_ospf_intra_external_cmd,
6607 "distance ospf intra-area <1-255> external <1-255>",
6608 "Define an administrative distance\n"
6609 "OSPF Administrative distance\n"
6610 "Intra-area routes\n"
6611 "Distance for intra-area routes\n"
6612 "External routes\n"
6613 "Distance for external routes\n")
6614{
paul68980082003-03-25 05:07:42 +00006615 struct ospf *ospf = vty->index;
6616
6617 ospf->distance_intra = atoi (argv[0]);
6618 ospf->distance_external = atoi (argv[1]);
6619
paul718e3742002-12-13 20:15:29 +00006620 return CMD_SUCCESS;
6621}
6622
6623DEFUN (ospf_distance_ospf_intra_inter_external,
6624 ospf_distance_ospf_intra_inter_external_cmd,
6625 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6626 "Define an administrative distance\n"
6627 "OSPF Administrative distance\n"
6628 "Intra-area routes\n"
6629 "Distance for intra-area routes\n"
6630 "Inter-area routes\n"
6631 "Distance for inter-area routes\n"
6632 "External routes\n"
6633 "Distance for external routes\n")
6634{
paul68980082003-03-25 05:07:42 +00006635 struct ospf *ospf = vty->index;
6636
6637 ospf->distance_intra = atoi (argv[0]);
6638 ospf->distance_inter = atoi (argv[1]);
6639 ospf->distance_external = atoi (argv[2]);
6640
paul718e3742002-12-13 20:15:29 +00006641 return CMD_SUCCESS;
6642}
6643
6644DEFUN (ospf_distance_ospf_intra_external_inter,
6645 ospf_distance_ospf_intra_external_inter_cmd,
6646 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6647 "Define an administrative distance\n"
6648 "OSPF Administrative distance\n"
6649 "Intra-area routes\n"
6650 "Distance for intra-area routes\n"
6651 "External routes\n"
6652 "Distance for external routes\n"
6653 "Inter-area routes\n"
6654 "Distance for inter-area routes\n")
6655{
paul68980082003-03-25 05:07:42 +00006656 struct ospf *ospf = vty->index;
6657
6658 ospf->distance_intra = atoi (argv[0]);
6659 ospf->distance_external = atoi (argv[1]);
6660 ospf->distance_inter = atoi (argv[2]);
6661
paul718e3742002-12-13 20:15:29 +00006662 return CMD_SUCCESS;
6663}
6664
6665DEFUN (ospf_distance_ospf_inter,
6666 ospf_distance_ospf_inter_cmd,
6667 "distance ospf inter-area <1-255>",
6668 "Define an administrative distance\n"
6669 "OSPF Administrative distance\n"
6670 "Inter-area routes\n"
6671 "Distance for inter-area routes\n")
6672{
paul68980082003-03-25 05:07:42 +00006673 struct ospf *ospf = vty->index;
6674
6675 ospf->distance_inter = atoi (argv[0]);
6676
paul718e3742002-12-13 20:15:29 +00006677 return CMD_SUCCESS;
6678}
6679
6680DEFUN (ospf_distance_ospf_inter_intra,
6681 ospf_distance_ospf_inter_intra_cmd,
6682 "distance ospf inter-area <1-255> intra-area <1-255>",
6683 "Define an administrative distance\n"
6684 "OSPF Administrative distance\n"
6685 "Inter-area routes\n"
6686 "Distance for inter-area routes\n"
6687 "Intra-area routes\n"
6688 "Distance for intra-area routes\n")
6689{
paul68980082003-03-25 05:07:42 +00006690 struct ospf *ospf = vty->index;
6691
6692 ospf->distance_inter = atoi (argv[0]);
6693 ospf->distance_intra = atoi (argv[1]);
6694
paul718e3742002-12-13 20:15:29 +00006695 return CMD_SUCCESS;
6696}
6697
6698DEFUN (ospf_distance_ospf_inter_external,
6699 ospf_distance_ospf_inter_external_cmd,
6700 "distance ospf inter-area <1-255> external <1-255>",
6701 "Define an administrative distance\n"
6702 "OSPF Administrative distance\n"
6703 "Inter-area routes\n"
6704 "Distance for inter-area routes\n"
6705 "External routes\n"
6706 "Distance for external routes\n")
6707{
paul68980082003-03-25 05:07:42 +00006708 struct ospf *ospf = vty->index;
6709
6710 ospf->distance_inter = atoi (argv[0]);
6711 ospf->distance_external = atoi (argv[1]);
6712
paul718e3742002-12-13 20:15:29 +00006713 return CMD_SUCCESS;
6714}
6715
6716DEFUN (ospf_distance_ospf_inter_intra_external,
6717 ospf_distance_ospf_inter_intra_external_cmd,
6718 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6719 "Define an administrative distance\n"
6720 "OSPF Administrative distance\n"
6721 "Inter-area routes\n"
6722 "Distance for inter-area routes\n"
6723 "Intra-area routes\n"
6724 "Distance for intra-area routes\n"
6725 "External routes\n"
6726 "Distance for external routes\n")
6727{
paul68980082003-03-25 05:07:42 +00006728 struct ospf *ospf = vty->index;
6729
6730 ospf->distance_inter = atoi (argv[0]);
6731 ospf->distance_intra = atoi (argv[1]);
6732 ospf->distance_external = atoi (argv[2]);
6733
paul718e3742002-12-13 20:15:29 +00006734 return CMD_SUCCESS;
6735}
6736
6737DEFUN (ospf_distance_ospf_inter_external_intra,
6738 ospf_distance_ospf_inter_external_intra_cmd,
6739 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6740 "Define an administrative distance\n"
6741 "OSPF Administrative distance\n"
6742 "Inter-area routes\n"
6743 "Distance for inter-area routes\n"
6744 "External routes\n"
6745 "Distance for external routes\n"
6746 "Intra-area routes\n"
6747 "Distance for intra-area routes\n")
6748{
paul68980082003-03-25 05:07:42 +00006749 struct ospf *ospf = vty->index;
6750
6751 ospf->distance_inter = atoi (argv[0]);
6752 ospf->distance_external = atoi (argv[1]);
6753 ospf->distance_intra = atoi (argv[2]);
6754
paul718e3742002-12-13 20:15:29 +00006755 return CMD_SUCCESS;
6756}
6757
6758DEFUN (ospf_distance_ospf_external,
6759 ospf_distance_ospf_external_cmd,
6760 "distance ospf external <1-255>",
6761 "Define an administrative distance\n"
6762 "OSPF Administrative distance\n"
6763 "External routes\n"
6764 "Distance for external routes\n")
6765{
paul68980082003-03-25 05:07:42 +00006766 struct ospf *ospf = vty->index;
6767
6768 ospf->distance_external = atoi (argv[0]);
6769
paul718e3742002-12-13 20:15:29 +00006770 return CMD_SUCCESS;
6771}
6772
6773DEFUN (ospf_distance_ospf_external_intra,
6774 ospf_distance_ospf_external_intra_cmd,
6775 "distance ospf external <1-255> intra-area <1-255>",
6776 "Define an administrative distance\n"
6777 "OSPF Administrative distance\n"
6778 "External routes\n"
6779 "Distance for external routes\n"
6780 "Intra-area routes\n"
6781 "Distance for intra-area routes\n")
6782{
paul68980082003-03-25 05:07:42 +00006783 struct ospf *ospf = vty->index;
6784
6785 ospf->distance_external = atoi (argv[0]);
6786 ospf->distance_intra = atoi (argv[1]);
6787
paul718e3742002-12-13 20:15:29 +00006788 return CMD_SUCCESS;
6789}
6790
6791DEFUN (ospf_distance_ospf_external_inter,
6792 ospf_distance_ospf_external_inter_cmd,
6793 "distance ospf external <1-255> inter-area <1-255>",
6794 "Define an administrative distance\n"
6795 "OSPF Administrative distance\n"
6796 "External routes\n"
6797 "Distance for external routes\n"
6798 "Inter-area routes\n"
6799 "Distance for inter-area routes\n")
6800{
paul68980082003-03-25 05:07:42 +00006801 struct ospf *ospf = vty->index;
6802
6803 ospf->distance_external = atoi (argv[0]);
6804 ospf->distance_inter = atoi (argv[1]);
6805
paul718e3742002-12-13 20:15:29 +00006806 return CMD_SUCCESS;
6807}
6808
6809DEFUN (ospf_distance_ospf_external_intra_inter,
6810 ospf_distance_ospf_external_intra_inter_cmd,
6811 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6812 "Define an administrative distance\n"
6813 "OSPF Administrative distance\n"
6814 "External routes\n"
6815 "Distance for external routes\n"
6816 "Intra-area routes\n"
6817 "Distance for intra-area routes\n"
6818 "Inter-area routes\n"
6819 "Distance for inter-area routes\n")
6820{
paul68980082003-03-25 05:07:42 +00006821 struct ospf *ospf = vty->index;
6822
6823 ospf->distance_external = atoi (argv[0]);
6824 ospf->distance_intra = atoi (argv[1]);
6825 ospf->distance_inter = atoi (argv[2]);
6826
paul718e3742002-12-13 20:15:29 +00006827 return CMD_SUCCESS;
6828}
6829
6830DEFUN (ospf_distance_ospf_external_inter_intra,
6831 ospf_distance_ospf_external_inter_intra_cmd,
6832 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6833 "Define an administrative distance\n"
6834 "OSPF Administrative distance\n"
6835 "External routes\n"
6836 "Distance for external routes\n"
6837 "Inter-area routes\n"
6838 "Distance for inter-area routes\n"
6839 "Intra-area routes\n"
6840 "Distance for intra-area routes\n")
6841{
paul68980082003-03-25 05:07:42 +00006842 struct ospf *ospf = vty->index;
6843
6844 ospf->distance_external = atoi (argv[0]);
6845 ospf->distance_inter = atoi (argv[1]);
6846 ospf->distance_intra = atoi (argv[2]);
6847
paul718e3742002-12-13 20:15:29 +00006848 return CMD_SUCCESS;
6849}
6850
6851DEFUN (ospf_distance_source,
6852 ospf_distance_source_cmd,
6853 "distance <1-255> A.B.C.D/M",
6854 "Administrative distance\n"
6855 "Distance value\n"
6856 "IP source prefix\n")
6857{
paul020709f2003-04-04 02:44:16 +00006858 struct ospf *ospf = vty->index;
6859
6860 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006861
paul718e3742002-12-13 20:15:29 +00006862 return CMD_SUCCESS;
6863}
6864
6865DEFUN (no_ospf_distance_source,
6866 no_ospf_distance_source_cmd,
6867 "no distance <1-255> A.B.C.D/M",
6868 NO_STR
6869 "Administrative distance\n"
6870 "Distance value\n"
6871 "IP source prefix\n")
6872{
paul020709f2003-04-04 02:44:16 +00006873 struct ospf *ospf = vty->index;
6874
6875 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6876
paul718e3742002-12-13 20:15:29 +00006877 return CMD_SUCCESS;
6878}
6879
6880DEFUN (ospf_distance_source_access_list,
6881 ospf_distance_source_access_list_cmd,
6882 "distance <1-255> A.B.C.D/M WORD",
6883 "Administrative distance\n"
6884 "Distance value\n"
6885 "IP source prefix\n"
6886 "Access list name\n")
6887{
paul020709f2003-04-04 02:44:16 +00006888 struct ospf *ospf = vty->index;
6889
6890 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6891
paul718e3742002-12-13 20:15:29 +00006892 return CMD_SUCCESS;
6893}
6894
6895DEFUN (no_ospf_distance_source_access_list,
6896 no_ospf_distance_source_access_list_cmd,
6897 "no distance <1-255> A.B.C.D/M WORD",
6898 NO_STR
6899 "Administrative distance\n"
6900 "Distance value\n"
6901 "IP source prefix\n"
6902 "Access list name\n")
6903{
paul020709f2003-04-04 02:44:16 +00006904 struct ospf *ospf = vty->index;
6905
6906 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6907
paul718e3742002-12-13 20:15:29 +00006908 return CMD_SUCCESS;
6909}
6910
vincentba682532005-09-29 13:52:57 +00006911DEFUN (ip_ospf_mtu_ignore,
6912 ip_ospf_mtu_ignore_addr_cmd,
6913 "ip ospf mtu-ignore A.B.C.D",
6914 "IP Information\n"
6915 "OSPF interface commands\n"
6916 "Disable mtu mismatch detection\n"
6917 "Address of interface")
6918{
6919 struct interface *ifp = vty->index;
6920 struct in_addr addr;
6921 int ret;
6922
6923 struct ospf_if_params *params;
6924 params = IF_DEF_PARAMS (ifp);
6925
6926 if (argc == 1)
6927 {
6928 ret = inet_aton(argv[0], &addr);
6929 if (!ret)
6930 {
6931 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6932 VTY_NEWLINE);
6933 return CMD_WARNING;
6934 }
6935 params = ospf_get_if_params (ifp, addr);
6936 ospf_if_update_params (ifp, addr);
6937 }
6938 params->mtu_ignore = 1;
6939 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6940 SET_IF_PARAM (params, mtu_ignore);
6941 else
6942 {
6943 UNSET_IF_PARAM (params, mtu_ignore);
6944 if (params != IF_DEF_PARAMS (ifp))
6945 {
6946 ospf_free_if_params (ifp, addr);
6947 ospf_if_update_params (ifp, addr);
6948 }
6949 }
6950 return CMD_SUCCESS;
6951}
6952
6953ALIAS (ip_ospf_mtu_ignore,
6954 ip_ospf_mtu_ignore_cmd,
6955 "ip ospf mtu-ignore",
6956 "IP Information\n"
6957 "OSPF interface commands\n"
6958 "Disable mtu mismatch detection\n")
6959
6960
6961DEFUN (no_ip_ospf_mtu_ignore,
6962 no_ip_ospf_mtu_ignore_addr_cmd,
6963 "no ip ospf mtu-ignore A.B.C.D",
6964 "IP Information\n"
6965 "OSPF interface commands\n"
6966 "Disable mtu mismatch detection\n"
6967 "Address of interface")
6968{
6969 struct interface *ifp = vty->index;
6970 struct in_addr addr;
6971 int ret;
6972
6973 struct ospf_if_params *params;
6974 params = IF_DEF_PARAMS (ifp);
6975
6976 if (argc == 1)
6977 {
6978 ret = inet_aton(argv[0], &addr);
6979 if (!ret)
6980 {
6981 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6982 VTY_NEWLINE);
6983 return CMD_WARNING;
6984 }
6985 params = ospf_get_if_params (ifp, addr);
6986 ospf_if_update_params (ifp, addr);
6987 }
6988 params->mtu_ignore = 0;
6989 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6990 SET_IF_PARAM (params, mtu_ignore);
6991 else
6992 {
6993 UNSET_IF_PARAM (params, mtu_ignore);
6994 if (params != IF_DEF_PARAMS (ifp))
6995 {
6996 ospf_free_if_params (ifp, addr);
6997 ospf_if_update_params (ifp, addr);
6998 }
6999 }
7000 return CMD_SUCCESS;
7001}
7002
7003ALIAS (no_ip_ospf_mtu_ignore,
7004 no_ip_ospf_mtu_ignore_cmd,
7005 "no ip ospf mtu-ignore",
7006 "IP Information\n"
7007 "OSPF interface commands\n"
7008 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00007009
7010DEFUN (ospf_max_metric_router_lsa_admin,
7011 ospf_max_metric_router_lsa_admin_cmd,
7012 "max-metric router-lsa administrative",
7013 "OSPF maximum / infinite-distance metric\n"
7014 "Advertise own Router-LSA with infinite distance (stub router)\n"
7015 "Administratively applied, for an indefinite period\n")
7016{
7017 struct listnode *ln;
7018 struct ospf_area *area;
7019 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00007020
paul88d6cf32005-10-29 12:50:09 +00007021 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7022 {
7023 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7024
7025 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
Paul Jakmac363d382010-01-24 22:42:13 +00007026 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007027 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08007028
7029 /* Allows for areas configured later to get the property */
7030 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
7031
paul88d6cf32005-10-29 12:50:09 +00007032 return CMD_SUCCESS;
7033}
7034
7035DEFUN (no_ospf_max_metric_router_lsa_admin,
7036 no_ospf_max_metric_router_lsa_admin_cmd,
7037 "no max-metric router-lsa administrative",
7038 NO_STR
7039 "OSPF maximum / infinite-distance metric\n"
7040 "Advertise own Router-LSA with infinite distance (stub router)\n"
7041 "Administratively applied, for an indefinite period\n")
7042{
7043 struct listnode *ln;
7044 struct ospf_area *area;
7045 struct ospf *ospf = vty->index;
7046
7047 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7048 {
7049 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7050
7051 /* Don't trample on the start-up stub timer */
7052 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
7053 && !area->t_stub_router)
7054 {
7055 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00007056 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007057 }
7058 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08007059 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
paul88d6cf32005-10-29 12:50:09 +00007060 return CMD_SUCCESS;
7061}
7062
7063DEFUN (ospf_max_metric_router_lsa_startup,
7064 ospf_max_metric_router_lsa_startup_cmd,
7065 "max-metric router-lsa on-startup <5-86400>",
7066 "OSPF maximum / infinite-distance metric\n"
7067 "Advertise own Router-LSA with infinite distance (stub router)\n"
7068 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7069 "Time (seconds) to advertise self as stub-router\n")
7070{
7071 unsigned int seconds;
7072 struct ospf *ospf = vty->index;
7073
7074 if (argc != 1)
7075 {
7076 vty_out (vty, "%% Must supply stub-router period");
7077 return CMD_WARNING;
7078 }
7079
7080 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
7081
7082 ospf->stub_router_startup_time = seconds;
7083
7084 return CMD_SUCCESS;
7085}
7086
7087DEFUN (no_ospf_max_metric_router_lsa_startup,
7088 no_ospf_max_metric_router_lsa_startup_cmd,
7089 "no max-metric router-lsa on-startup",
7090 NO_STR
7091 "OSPF maximum / infinite-distance metric\n"
7092 "Advertise own Router-LSA with infinite distance (stub router)\n"
7093 "Automatically advertise stub Router-LSA on startup of OSPF\n")
7094{
7095 struct listnode *ln;
7096 struct ospf_area *area;
7097 struct ospf *ospf = vty->index;
7098
7099 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7100
7101 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7102 {
7103 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
7104 OSPF_TIMER_OFF (area->t_stub_router);
7105
7106 /* Don't trample on admin stub routed */
7107 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7108 {
7109 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00007110 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007111 }
7112 }
7113 return CMD_SUCCESS;
7114}
7115
7116DEFUN (ospf_max_metric_router_lsa_shutdown,
7117 ospf_max_metric_router_lsa_shutdown_cmd,
7118 "max-metric router-lsa on-shutdown <5-86400>",
7119 "OSPF maximum / infinite-distance metric\n"
7120 "Advertise own Router-LSA with infinite distance (stub router)\n"
7121 "Advertise stub-router prior to full shutdown of OSPF\n"
7122 "Time (seconds) to wait till full shutdown\n")
7123{
7124 unsigned int seconds;
7125 struct ospf *ospf = vty->index;
7126
7127 if (argc != 1)
7128 {
7129 vty_out (vty, "%% Must supply stub-router shutdown period");
7130 return CMD_WARNING;
7131 }
7132
7133 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
7134
7135 ospf->stub_router_shutdown_time = seconds;
7136
7137 return CMD_SUCCESS;
7138}
7139
7140DEFUN (no_ospf_max_metric_router_lsa_shutdown,
7141 no_ospf_max_metric_router_lsa_shutdown_cmd,
7142 "no max-metric router-lsa on-shutdown",
7143 NO_STR
7144 "OSPF maximum / infinite-distance metric\n"
7145 "Advertise own Router-LSA with infinite distance (stub router)\n"
7146 "Advertise stub-router prior to full shutdown of OSPF\n")
7147{
7148 struct ospf *ospf = vty->index;
7149
7150 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7151
7152 return CMD_SUCCESS;
7153}
7154
7155static void
7156config_write_stub_router (struct vty *vty, struct ospf *ospf)
7157{
7158 struct listnode *ln;
7159 struct ospf_area *area;
7160
7161 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7162 vty_out (vty, " max-metric router-lsa on-startup %u%s",
7163 ospf->stub_router_startup_time, VTY_NEWLINE);
7164 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7165 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
7166 ospf->stub_router_shutdown_time, VTY_NEWLINE);
7167 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7168 {
7169 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7170 {
7171 vty_out (vty, " max-metric router-lsa administrative%s",
7172 VTY_NEWLINE);
7173 break;
7174 }
7175 }
7176 return;
7177}
7178
paul4dadc292005-05-06 21:37:42 +00007179static void
paul718e3742002-12-13 20:15:29 +00007180show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7181{
7182 struct route_node *rn;
7183 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007184 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007185 struct ospf_path *path;
7186
7187 vty_out (vty, "============ OSPF network routing table ============%s",
7188 VTY_NEWLINE);
7189
7190 for (rn = route_top (rt); rn; rn = route_next (rn))
7191 if ((or = rn->info) != NULL)
7192 {
7193 char buf1[19];
7194 snprintf (buf1, 19, "%s/%d",
7195 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7196
7197 switch (or->path_type)
7198 {
7199 case OSPF_PATH_INTER_AREA:
7200 if (or->type == OSPF_DESTINATION_NETWORK)
7201 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7202 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7203 else if (or->type == OSPF_DESTINATION_DISCARD)
7204 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7205 break;
7206 case OSPF_PATH_INTRA_AREA:
7207 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7208 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7209 break;
7210 default:
7211 break;
7212 }
7213
7214 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007215 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007216 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007217 if (if_lookup_by_index(path->ifindex))
paul96735ee2003-08-10 02:51:22 +00007218 {
7219 if (path->nexthop.s_addr == 0)
7220 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007221 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007222 else
7223 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007224 inet_ntoa (path->nexthop),
7225 ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007226 }
7227 }
paul718e3742002-12-13 20:15:29 +00007228 }
7229 vty_out (vty, "%s", VTY_NEWLINE);
7230}
7231
paul4dadc292005-05-06 21:37:42 +00007232static void
paul718e3742002-12-13 20:15:29 +00007233show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7234{
7235 struct route_node *rn;
7236 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007237 struct listnode *pnode;
7238 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007239 struct ospf_path *path;
7240
7241 vty_out (vty, "============ OSPF router routing table =============%s",
7242 VTY_NEWLINE);
7243 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7244 if (rn->info)
7245 {
7246 int flag = 0;
7247
7248 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7249
paul1eb8ef22005-04-07 07:30:20 +00007250 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7251 {
7252 if (flag++)
7253 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007254
paul1eb8ef22005-04-07 07:30:20 +00007255 /* Show path. */
7256 vty_out (vty, "%s [%d] area: %s",
7257 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7258 or->cost, inet_ntoa (or->u.std.area_id));
7259 /* Show flags. */
7260 vty_out (vty, "%s%s%s",
7261 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7262 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7263 VTY_NEWLINE);
7264
7265 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7266 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007267 if (if_lookup_by_index(path->ifindex))
hasso54bedb52005-08-17 13:31:47 +00007268 {
7269 if (path->nexthop.s_addr == 0)
7270 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007271 "", ifindex2ifname (path->ifindex),
7272 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007273 else
7274 vty_out (vty, "%24s via %s, %s%s", "",
7275 inet_ntoa (path->nexthop),
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007276 ifindex2ifname (path->ifindex),
7277 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007278 }
paul1eb8ef22005-04-07 07:30:20 +00007279 }
7280 }
paul718e3742002-12-13 20:15:29 +00007281 }
7282 vty_out (vty, "%s", VTY_NEWLINE);
7283}
7284
paul4dadc292005-05-06 21:37:42 +00007285static void
paul718e3742002-12-13 20:15:29 +00007286show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7287{
7288 struct route_node *rn;
7289 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007290 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007291 struct ospf_path *path;
7292
7293 vty_out (vty, "============ OSPF external routing table ===========%s",
7294 VTY_NEWLINE);
7295 for (rn = route_top (rt); rn; rn = route_next (rn))
7296 if ((er = rn->info) != NULL)
7297 {
7298 char buf1[19];
7299 snprintf (buf1, 19, "%s/%d",
7300 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7301
7302 switch (er->path_type)
7303 {
7304 case OSPF_PATH_TYPE1_EXTERNAL:
7305 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7306 er->cost, er->u.ext.tag, VTY_NEWLINE);
7307 break;
7308 case OSPF_PATH_TYPE2_EXTERNAL:
7309 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7310 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7311 break;
7312 }
7313
paul1eb8ef22005-04-07 07:30:20 +00007314 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007315 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007316 if (if_lookup_by_index(path->ifindex))
paul718e3742002-12-13 20:15:29 +00007317 {
7318 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007319 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007320 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007321 else
7322 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007323 inet_ntoa (path->nexthop),
7324 ifindex2ifname (path->ifindex),
paul96735ee2003-08-10 02:51:22 +00007325 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007326 }
7327 }
7328 }
7329 vty_out (vty, "%s", VTY_NEWLINE);
7330}
7331
paul718e3742002-12-13 20:15:29 +00007332DEFUN (show_ip_ospf_border_routers,
7333 show_ip_ospf_border_routers_cmd,
7334 "show ip ospf border-routers",
7335 SHOW_STR
7336 IP_STR
7337 "show all the ABR's and ASBR's\n"
7338 "for this area\n")
7339{
paul020709f2003-04-04 02:44:16 +00007340 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007341
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007342 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007343 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007344 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007345 return CMD_SUCCESS;
7346 }
7347
paul68980082003-03-25 05:07:42 +00007348 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007349 {
7350 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7351 return CMD_SUCCESS;
7352 }
7353
7354 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007355 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007356
7357 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007358 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007359
7360 return CMD_SUCCESS;
7361}
paul718e3742002-12-13 20:15:29 +00007362
7363DEFUN (show_ip_ospf_route,
7364 show_ip_ospf_route_cmd,
7365 "show ip ospf route",
7366 SHOW_STR
7367 IP_STR
7368 "OSPF information\n"
7369 "OSPF routing table\n")
7370{
paul020709f2003-04-04 02:44:16 +00007371 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007372
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007373 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007374 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007375 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007376 return CMD_SUCCESS;
7377 }
7378
paul68980082003-03-25 05:07:42 +00007379 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007380 {
7381 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7382 return CMD_SUCCESS;
7383 }
7384
7385 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007386 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007387
7388 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007389 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007390
7391 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007392 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007393
7394 return CMD_SUCCESS;
7395}
7396
7397
hassoeb1ce602004-10-08 08:17:22 +00007398const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007399{
7400 "unknown",
7401 "standard",
7402 "ibm",
7403 "cisco",
7404 "shortcut"
7405};
7406
hassoeb1ce602004-10-08 08:17:22 +00007407const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007408{
7409 "default",
7410 "enable",
7411 "disable"
7412};
7413
7414
paul4dadc292005-05-06 21:37:42 +00007415static void
paul718e3742002-12-13 20:15:29 +00007416area_id2str (char *buf, int length, struct ospf_area *area)
7417{
7418 memset (buf, 0, length);
7419
7420 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7421 strncpy (buf, inet_ntoa (area->area_id), length);
7422 else
7423 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7424}
7425
7426
hassoeb1ce602004-10-08 08:17:22 +00007427const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007428{
7429 "unknown", /* should never be used. */
7430 "point-to-point",
7431 "broadcast",
7432 "non-broadcast",
7433 "point-to-multipoint",
7434 "virtual-link", /* should never be used. */
7435 "loopback"
7436};
7437
7438/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007439static int
paul718e3742002-12-13 20:15:29 +00007440config_write_interface (struct vty *vty)
7441{
hasso52dc7ee2004-09-23 19:18:23 +00007442 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007443 struct interface *ifp;
7444 struct crypt_key *ck;
7445 int write = 0;
7446 struct route_node *rn = NULL;
7447 struct ospf_if_params *params;
7448
paul1eb8ef22005-04-07 07:30:20 +00007449 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007450 {
paul718e3742002-12-13 20:15:29 +00007451 if (memcmp (ifp->name, "VLINK", 5) == 0)
7452 continue;
7453
7454 vty_out (vty, "!%s", VTY_NEWLINE);
7455 vty_out (vty, "interface %s%s", ifp->name,
7456 VTY_NEWLINE);
7457 if (ifp->desc)
7458 vty_out (vty, " description %s%s", ifp->desc,
7459 VTY_NEWLINE);
7460
7461 write++;
7462
7463 params = IF_DEF_PARAMS (ifp);
7464
7465 do {
7466 /* Interface Network print. */
7467 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007468 params->type != OSPF_IFTYPE_LOOPBACK)
7469 {
ajsbc18d612004-12-15 15:07:19 +00007470 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007471 {
7472 vty_out (vty, " ip ospf network %s",
7473 ospf_int_type_str[params->type]);
7474 if (params != IF_DEF_PARAMS (ifp))
7475 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7476 vty_out (vty, "%s", VTY_NEWLINE);
7477 }
paul718e3742002-12-13 20:15:29 +00007478 }
7479
7480 /* OSPF interface authentication print */
7481 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7482 params->auth_type != OSPF_AUTH_NOTSET)
7483 {
hassoeb1ce602004-10-08 08:17:22 +00007484 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007485
7486 /* Translation tables are not that much help here due to syntax
7487 of the simple option */
7488 switch (params->auth_type)
7489 {
7490
7491 case OSPF_AUTH_NULL:
7492 auth_str = " null";
7493 break;
7494
7495 case OSPF_AUTH_SIMPLE:
7496 auth_str = "";
7497 break;
7498
7499 case OSPF_AUTH_CRYPTOGRAPHIC:
7500 auth_str = " message-digest";
7501 break;
7502
7503 default:
7504 auth_str = "";
7505 break;
7506 }
7507
7508 vty_out (vty, " ip ospf authentication%s", auth_str);
7509 if (params != IF_DEF_PARAMS (ifp))
7510 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7511 vty_out (vty, "%s", VTY_NEWLINE);
7512 }
7513
7514 /* Simple Authentication Password print. */
7515 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7516 params->auth_simple[0] != '\0')
7517 {
7518 vty_out (vty, " ip ospf authentication-key %s",
7519 params->auth_simple);
7520 if (params != IF_DEF_PARAMS (ifp))
7521 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7522 vty_out (vty, "%s", VTY_NEWLINE);
7523 }
7524
7525 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007526 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007527 {
paul718e3742002-12-13 20:15:29 +00007528 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7529 ck->key_id, ck->auth_key);
7530 if (params != IF_DEF_PARAMS (ifp))
7531 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7532 vty_out (vty, "%s", VTY_NEWLINE);
7533 }
7534
7535 /* Interface Output Cost print. */
7536 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7537 {
7538 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7539 if (params != IF_DEF_PARAMS (ifp))
7540 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7541 vty_out (vty, "%s", VTY_NEWLINE);
7542 }
7543
7544 /* Hello Interval print. */
7545 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7546 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7547 {
7548 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7549 if (params != IF_DEF_PARAMS (ifp))
7550 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7551 vty_out (vty, "%s", VTY_NEWLINE);
7552 }
7553
7554
7555 /* Router Dead Interval print. */
7556 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7557 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7558 {
paulf9ad9372005-10-21 00:45:17 +00007559 vty_out (vty, " ip ospf dead-interval ");
7560
7561 /* fast hello ? */
7562 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7563 vty_out (vty, "minimal hello-multiplier %d",
7564 params->fast_hello);
7565 else
7566 vty_out (vty, "%u", params->v_wait);
7567
paul718e3742002-12-13 20:15:29 +00007568 if (params != IF_DEF_PARAMS (ifp))
7569 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7570 vty_out (vty, "%s", VTY_NEWLINE);
7571 }
7572
7573 /* Router Priority print. */
7574 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7575 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7576 {
7577 vty_out (vty, " ip ospf priority %u", params->priority);
7578 if (params != IF_DEF_PARAMS (ifp))
7579 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7580 vty_out (vty, "%s", VTY_NEWLINE);
7581 }
7582
7583 /* Retransmit Interval print. */
7584 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7585 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7586 {
7587 vty_out (vty, " ip ospf retransmit-interval %u",
7588 params->retransmit_interval);
7589 if (params != IF_DEF_PARAMS (ifp))
7590 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7591 vty_out (vty, "%s", VTY_NEWLINE);
7592 }
7593
7594 /* Transmit Delay print. */
7595 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7596 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7597 {
7598 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7599 if (params != IF_DEF_PARAMS (ifp))
7600 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7601 vty_out (vty, "%s", VTY_NEWLINE);
7602 }
7603
vincentba682532005-09-29 13:52:57 +00007604 /* MTU ignore print. */
7605 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7606 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7607 {
7608 if (params->mtu_ignore == 0)
7609 vty_out (vty, " no ip ospf mtu-ignore");
7610 else
7611 vty_out (vty, " ip ospf mtu-ignore");
7612 if (params != IF_DEF_PARAMS (ifp))
7613 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7614 vty_out (vty, "%s", VTY_NEWLINE);
7615 }
7616
7617
paul718e3742002-12-13 20:15:29 +00007618 while (1)
7619 {
7620 if (rn == NULL)
7621 rn = route_top (IF_OIFS_PARAMS (ifp));
7622 else
7623 rn = route_next (rn);
7624
7625 if (rn == NULL)
7626 break;
7627 params = rn->info;
7628 if (params != NULL)
7629 break;
7630 }
7631 } while (rn);
7632
7633#ifdef HAVE_OPAQUE_LSA
7634 ospf_opaque_config_write_if (vty, ifp);
7635#endif /* HAVE_OPAQUE_LSA */
7636 }
7637
7638 return write;
7639}
7640
paul4dadc292005-05-06 21:37:42 +00007641static int
paul68980082003-03-25 05:07:42 +00007642config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007643{
7644 struct route_node *rn;
7645 u_char buf[INET_ADDRSTRLEN];
7646
7647 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007648 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007649 if (rn->info)
7650 {
7651 struct ospf_network *n = rn->info;
7652
7653 memset (buf, 0, INET_ADDRSTRLEN);
7654
7655 /* Create Area ID string by specified Area ID format. */
7656 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007657 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007658 else
hassoc9e52be2004-09-26 16:09:34 +00007659 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007660 (unsigned long int) ntohl (n->area_id.s_addr));
7661
7662 /* Network print. */
7663 vty_out (vty, " network %s/%d area %s%s",
7664 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7665 buf, VTY_NEWLINE);
7666 }
7667
7668 return 0;
7669}
7670
paul4dadc292005-05-06 21:37:42 +00007671static int
paul68980082003-03-25 05:07:42 +00007672config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007673{
hasso52dc7ee2004-09-23 19:18:23 +00007674 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007675 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007676 u_char buf[INET_ADDRSTRLEN];
7677
7678 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007679 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007680 {
paul718e3742002-12-13 20:15:29 +00007681 struct route_node *rn1;
7682
hassoc9e52be2004-09-26 16:09:34 +00007683 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007684
7685 if (area->auth_type != OSPF_AUTH_NULL)
7686 {
7687 if (area->auth_type == OSPF_AUTH_SIMPLE)
7688 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7689 else
7690 vty_out (vty, " area %s authentication message-digest%s",
7691 buf, VTY_NEWLINE);
7692 }
7693
7694 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7695 vty_out (vty, " area %s shortcut %s%s", buf,
7696 ospf_shortcut_mode_str[area->shortcut_configured],
7697 VTY_NEWLINE);
7698
7699 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007700 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007701 )
7702 {
paulb0a053b2003-06-22 09:04:47 +00007703 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007704 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007705 else if (area->external_routing == OSPF_AREA_NSSA)
7706 {
7707 vty_out (vty, " area %s nssa", buf);
7708 switch (area->NSSATranslatorRole)
7709 {
7710 case OSPF_NSSA_ROLE_NEVER:
7711 vty_out (vty, " translate-never");
7712 break;
7713 case OSPF_NSSA_ROLE_ALWAYS:
7714 vty_out (vty, " translate-always");
7715 break;
7716 case OSPF_NSSA_ROLE_CANDIDATE:
7717 default:
7718 vty_out (vty, " translate-candidate");
7719 }
7720 }
paul718e3742002-12-13 20:15:29 +00007721
7722 if (area->no_summary)
7723 vty_out (vty, " no-summary");
7724
7725 vty_out (vty, "%s", VTY_NEWLINE);
7726
7727 if (area->default_cost != 1)
7728 vty_out (vty, " area %s default-cost %d%s", buf,
7729 area->default_cost, VTY_NEWLINE);
7730 }
7731
7732 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7733 if (rn1->info)
7734 {
7735 struct ospf_area_range *range = rn1->info;
7736
7737 vty_out (vty, " area %s range %s/%d", buf,
7738 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7739
paul6c835672004-10-11 11:00:30 +00007740 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007741 vty_out (vty, " cost %d", range->cost_config);
7742
7743 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7744 vty_out (vty, " not-advertise");
7745
7746 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7747 vty_out (vty, " substitute %s/%d",
7748 inet_ntoa (range->subst_addr), range->subst_masklen);
7749
7750 vty_out (vty, "%s", VTY_NEWLINE);
7751 }
7752
7753 if (EXPORT_NAME (area))
7754 vty_out (vty, " area %s export-list %s%s", buf,
7755 EXPORT_NAME (area), VTY_NEWLINE);
7756
7757 if (IMPORT_NAME (area))
7758 vty_out (vty, " area %s import-list %s%s", buf,
7759 IMPORT_NAME (area), VTY_NEWLINE);
7760
7761 if (PREFIX_NAME_IN (area))
7762 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7763 PREFIX_NAME_IN (area), VTY_NEWLINE);
7764
7765 if (PREFIX_NAME_OUT (area))
7766 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7767 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7768 }
7769
7770 return 0;
7771}
7772
paul4dadc292005-05-06 21:37:42 +00007773static int
paul68980082003-03-25 05:07:42 +00007774config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007775{
7776 struct ospf_nbr_nbma *nbr_nbma;
7777 struct route_node *rn;
7778
7779 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007780 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007781 if ((nbr_nbma = rn->info))
7782 {
7783 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7784
7785 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7786 vty_out (vty, " priority %d", nbr_nbma->priority);
7787
7788 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7789 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7790
7791 vty_out (vty, "%s", VTY_NEWLINE);
7792 }
7793
7794 return 0;
7795}
7796
paul4dadc292005-05-06 21:37:42 +00007797static int
paul68980082003-03-25 05:07:42 +00007798config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007799{
hasso52dc7ee2004-09-23 19:18:23 +00007800 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007801 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007802 u_char buf[INET_ADDRSTRLEN];
7803
7804 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007805 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007806 {
hasso52dc7ee2004-09-23 19:18:23 +00007807 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007808 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007809 struct ospf_interface *oi;
7810
7811 if (vl_data != NULL)
7812 {
7813 memset (buf, 0, INET_ADDRSTRLEN);
7814
7815 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007816 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007817 else
hassoc9e52be2004-09-26 16:09:34 +00007818 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007819 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7820 oi = vl_data->vl_oi;
7821
7822 /* timers */
7823 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7824 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7825 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7826 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7827 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7828 buf,
7829 inet_ntoa (vl_data->vl_peer),
7830 OSPF_IF_PARAM (oi, v_hello),
7831 OSPF_IF_PARAM (oi, retransmit_interval),
7832 OSPF_IF_PARAM (oi, transmit_delay),
7833 OSPF_IF_PARAM (oi, v_wait),
7834 VTY_NEWLINE);
7835 else
7836 vty_out (vty, " area %s virtual-link %s%s", buf,
7837 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7838 /* Auth key */
7839 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7840 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7841 buf,
7842 inet_ntoa (vl_data->vl_peer),
7843 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7844 VTY_NEWLINE);
7845 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007846 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7847 n2, ck))
7848 vty_out (vty, " area %s virtual-link %s"
7849 " message-digest-key %d md5 %s%s",
7850 buf,
7851 inet_ntoa (vl_data->vl_peer),
7852 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007853
7854 }
7855 }
7856
7857 return 0;
7858}
7859
7860
paul4dadc292005-05-06 21:37:42 +00007861static int
paul68980082003-03-25 05:07:42 +00007862config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007863{
7864 int type;
7865
7866 /* redistribute print. */
7867 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7868 if (type != zclient->redist_default && zclient->redist[type])
7869 {
ajsf52d13c2005-10-01 17:38:06 +00007870 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007871 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007872 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007873
paul68980082003-03-25 05:07:42 +00007874 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007875 vty_out (vty, " metric-type 1");
7876
paul020709f2003-04-04 02:44:16 +00007877 if (ROUTEMAP_NAME (ospf, type))
7878 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007879
7880 vty_out (vty, "%s", VTY_NEWLINE);
7881 }
7882
7883 return 0;
7884}
7885
paul4dadc292005-05-06 21:37:42 +00007886static int
paul68980082003-03-25 05:07:42 +00007887config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007888{
paul68980082003-03-25 05:07:42 +00007889 if (ospf->default_metric != -1)
7890 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007891 VTY_NEWLINE);
7892 return 0;
7893}
7894
paul4dadc292005-05-06 21:37:42 +00007895static int
paul68980082003-03-25 05:07:42 +00007896config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007897{
7898 int type;
7899
paul68980082003-03-25 05:07:42 +00007900 if (ospf)
paul718e3742002-12-13 20:15:29 +00007901 {
7902 /* distribute-list print. */
7903 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007904 if (DISTRIBUTE_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +00007905 vty_out (vty, " distribute-list %s out %s%s",
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007906 DISTRIBUTE_NAME (ospf, type),
ajsf52d13c2005-10-01 17:38:06 +00007907 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007908
7909 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007910 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007911 {
paulc42c1772006-01-10 20:36:49 +00007912 vty_out (vty, " default-information originate");
7913 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7914 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007915
paul68980082003-03-25 05:07:42 +00007916 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007917 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007918 ospf->dmetric[DEFAULT_ROUTE].value);
7919 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007920 vty_out (vty, " metric-type 1");
7921
paul020709f2003-04-04 02:44:16 +00007922 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7923 vty_out (vty, " route-map %s",
7924 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007925
7926 vty_out (vty, "%s", VTY_NEWLINE);
7927 }
7928
7929 }
7930
7931 return 0;
7932}
7933
paul4dadc292005-05-06 21:37:42 +00007934static int
paul68980082003-03-25 05:07:42 +00007935config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007936{
7937 struct route_node *rn;
7938 struct ospf_distance *odistance;
7939
paul68980082003-03-25 05:07:42 +00007940 if (ospf->distance_all)
7941 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007942
paul68980082003-03-25 05:07:42 +00007943 if (ospf->distance_intra
7944 || ospf->distance_inter
7945 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007946 {
7947 vty_out (vty, " distance ospf");
7948
paul68980082003-03-25 05:07:42 +00007949 if (ospf->distance_intra)
7950 vty_out (vty, " intra-area %d", ospf->distance_intra);
7951 if (ospf->distance_inter)
7952 vty_out (vty, " inter-area %d", ospf->distance_inter);
7953 if (ospf->distance_external)
7954 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007955
7956 vty_out (vty, "%s", VTY_NEWLINE);
7957 }
7958
paul68980082003-03-25 05:07:42 +00007959 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007960 if ((odistance = rn->info) != NULL)
7961 {
7962 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7963 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7964 odistance->access_list ? odistance->access_list : "",
7965 VTY_NEWLINE);
7966 }
7967 return 0;
7968}
7969
7970/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007971static int
paul718e3742002-12-13 20:15:29 +00007972ospf_config_write (struct vty *vty)
7973{
paul020709f2003-04-04 02:44:16 +00007974 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007975 struct interface *ifp;
7976 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007977 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007978 int write = 0;
7979
paul020709f2003-04-04 02:44:16 +00007980 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007981 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007982 {
7983 /* `router ospf' print. */
7984 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7985
7986 write++;
7987
paul68980082003-03-25 05:07:42 +00007988 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007989 return write;
7990
7991 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007992 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007993 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007994 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007995
7996 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007997 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007998 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007999 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008000
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008001 /* log-adjacency-changes flag print. */
8002 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
8003 {
8004 vty_out(vty, " log-adjacency-changes");
8005 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
8006 vty_out(vty, " detail");
8007 vty_out(vty, "%s", VTY_NEWLINE);
8008 }
8009
paul718e3742002-12-13 20:15:29 +00008010 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00008011 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00008012 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
8013
8014 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00008015 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00008016 {
8017 vty_out (vty, "! Important: ensure reference bandwidth "
8018 "is consistent across all routers%s", VTY_NEWLINE);
8019 vty_out (vty, " auto-cost reference-bandwidth %d%s",
8020 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
8021 }
paul718e3742002-12-13 20:15:29 +00008022
8023 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00008024 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00008025 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
8026 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
8027 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00008028 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00008029 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00008030
8031 /* Max-metric router-lsa print */
8032 config_write_stub_router (vty, ospf);
8033
paul718e3742002-12-13 20:15:29 +00008034 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00008035 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00008036 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00008037 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008038
8039 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00008040 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008041
8042 /* passive-interface print. */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008043 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
8044 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
8045
paul1eb8ef22005-04-07 07:30:20 +00008046 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008047 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
8048 && IF_DEF_PARAMS (ifp)->passive_interface !=
8049 ospf->passive_interface_default)
8050 {
8051 vty_out (vty, " %spassive-interface %s%s",
8052 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
8053 ifp->name, VTY_NEWLINE);
8054 }
paul1eb8ef22005-04-07 07:30:20 +00008055 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008056 {
8057 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
8058 continue;
8059 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
8060 passive_interface))
8061 {
8062 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
8063 continue;
8064 }
8065 else if (oi->params->passive_interface == ospf->passive_interface_default)
8066 continue;
8067
8068 vty_out (vty, " %spassive-interface %s %s%s",
8069 oi->params->passive_interface ? "" : "no ",
paul1eb8ef22005-04-07 07:30:20 +00008070 oi->ifp->name,
8071 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008072 }
paul718e3742002-12-13 20:15:29 +00008073
8074 /* Network area print. */
paul68980082003-03-25 05:07:42 +00008075 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008076
8077 /* Area config print. */
paul68980082003-03-25 05:07:42 +00008078 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008079
8080 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00008081 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008082
8083 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00008084 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008085
8086 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00008087 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008088
8089 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00008090 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008091
8092 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00008093 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008094
8095#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00008096 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008097#endif /* HAVE_OPAQUE_LSA */
8098 }
8099
8100 return write;
8101}
8102
8103void
paul4dadc292005-05-06 21:37:42 +00008104ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00008105{
8106 /* "show ip ospf" commands. */
8107 install_element (VIEW_NODE, &show_ip_ospf_cmd);
8108 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
8109
8110 /* "show ip ospf database" commands. */
8111 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
8112 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
8113 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8114 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8115 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
8116 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
8117 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
8118 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
8119 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
8120 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8121 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8122 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
8123 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
8124 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
8125
8126 /* "show ip ospf interface" commands. */
8127 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
8128 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
8129
8130 /* "show ip ospf neighbor" commands. */
8131 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8132 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
8133 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
8134 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8135 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
8136 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
8137 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
8138 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8139 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
8140 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
8141 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8142 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
8143 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
8144 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
8145
8146 /* "show ip ospf route" commands. */
8147 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
8148 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00008149 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
8150 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00008151}
8152
8153
8154/* ospfd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008155static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00008156{
8157 INTERFACE_NODE,
8158 "%s(config-if)# ",
8159 1
8160};
8161
8162/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00008163static void
8164ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00008165{
8166 /* Install interface node. */
8167 install_node (&interface_node, config_write_interface);
8168
8169 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00008170 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008171 install_default (INTERFACE_NODE);
8172
8173 /* "description" commands. */
8174 install_element (INTERFACE_NODE, &interface_desc_cmd);
8175 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
8176
8177 /* "ip ospf authentication" commands. */
8178 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
8179 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
8180 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
8181 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
8182 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
8183 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
8184 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
8185 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
8186 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
8187 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
8188
8189 /* "ip ospf message-digest-key" commands. */
8190 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
8191 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
8192 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8193 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8194
8195 /* "ip ospf cost" commands. */
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008196 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
8197 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008198 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
8199 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008200 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008201 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8202
vincentba682532005-09-29 13:52:57 +00008203 /* "ip ospf mtu-ignore" commands. */
8204 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8205 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8206 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8207 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8208
paul718e3742002-12-13 20:15:29 +00008209 /* "ip ospf dead-interval" commands. */
8210 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8211 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008212 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8213 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00008214 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8215 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008216
paul718e3742002-12-13 20:15:29 +00008217 /* "ip ospf hello-interval" commands. */
8218 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8219 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8220 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8221 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8222
8223 /* "ip ospf network" commands. */
8224 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8225 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8226
8227 /* "ip ospf priority" commands. */
8228 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8229 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8230 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8231 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8232
8233 /* "ip ospf retransmit-interval" commands. */
8234 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8235 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8236 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8237 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8238
8239 /* "ip ospf transmit-delay" commands. */
8240 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8241 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8242 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8243 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8244
8245 /* These commands are compatibitliy for previous version. */
8246 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8247 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8248 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8249 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008250 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
8251 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008252 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008253 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
8254 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008255 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008256 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8257 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8258 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8259 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8260 install_element (INTERFACE_NODE, &ospf_network_cmd);
8261 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8262 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8263 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8264 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8265 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8266 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8267 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8268}
8269
paul4dadc292005-05-06 21:37:42 +00008270static void
8271ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008272{
8273 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8274 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8275 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8276 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8277 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8278 install_element (OSPF_NODE,
8279 &ospf_redistribute_source_metric_type_routemap_cmd);
8280 install_element (OSPF_NODE,
8281 &ospf_redistribute_source_type_metric_routemap_cmd);
8282 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8283 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8284 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8285
8286 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8287
8288 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8289 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8290
8291 install_element (OSPF_NODE,
8292 &ospf_default_information_originate_metric_type_cmd);
8293 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8294 install_element (OSPF_NODE,
8295 &ospf_default_information_originate_type_metric_cmd);
8296 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8297 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8298 install_element (OSPF_NODE,
8299 &ospf_default_information_originate_always_metric_type_cmd);
8300 install_element (OSPF_NODE,
8301 &ospf_default_information_originate_always_metric_cmd);
8302 install_element (OSPF_NODE,
8303 &ospf_default_information_originate_always_cmd);
8304 install_element (OSPF_NODE,
8305 &ospf_default_information_originate_always_type_metric_cmd);
8306 install_element (OSPF_NODE,
8307 &ospf_default_information_originate_always_type_cmd);
8308
8309 install_element (OSPF_NODE,
8310 &ospf_default_information_originate_metric_type_routemap_cmd);
8311 install_element (OSPF_NODE,
8312 &ospf_default_information_originate_metric_routemap_cmd);
8313 install_element (OSPF_NODE,
8314 &ospf_default_information_originate_routemap_cmd);
8315 install_element (OSPF_NODE,
8316 &ospf_default_information_originate_type_metric_routemap_cmd);
8317 install_element (OSPF_NODE,
8318 &ospf_default_information_originate_type_routemap_cmd);
8319 install_element (OSPF_NODE,
8320 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8321 install_element (OSPF_NODE,
8322 &ospf_default_information_originate_always_metric_routemap_cmd);
8323 install_element (OSPF_NODE,
8324 &ospf_default_information_originate_always_routemap_cmd);
8325 install_element (OSPF_NODE,
8326 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8327 install_element (OSPF_NODE,
8328 &ospf_default_information_originate_always_type_routemap_cmd);
8329
8330 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8331
8332 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8333 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8334 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8335
8336 install_element (OSPF_NODE, &ospf_distance_cmd);
8337 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8338 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8339 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8340 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8341 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8342 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8343 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8344 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8345 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8346 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8347 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8348 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8349 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8350 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8351 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8352 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8353 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8354#if 0
8355 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8356 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8357 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8358 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8359#endif /* 0 */
8360}
8361
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008362static struct cmd_node ospf_node =
paul718e3742002-12-13 20:15:29 +00008363{
8364 OSPF_NODE,
8365 "%s(config-router)# ",
8366 1
8367};
8368
8369
8370/* Install OSPF related vty commands. */
8371void
paul4dadc292005-05-06 21:37:42 +00008372ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008373{
8374 /* Install ospf top node. */
8375 install_node (&ospf_node, ospf_config_write);
8376
8377 /* "router ospf" commands. */
8378 install_element (CONFIG_NODE, &router_ospf_cmd);
8379 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8380
8381 install_default (OSPF_NODE);
8382
8383 /* "ospf router-id" commands. */
8384 install_element (OSPF_NODE, &ospf_router_id_cmd);
8385 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008386 install_element (OSPF_NODE, &router_ospf_id_cmd);
8387 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008388
8389 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008390 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8391 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008392 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
paula2c62832003-04-23 17:01:31 +00008393 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8394 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008395 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
paul718e3742002-12-13 20:15:29 +00008396
8397 /* "ospf abr-type" commands. */
8398 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8399 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8400
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008401 /* "ospf log-adjacency-changes" commands. */
8402 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8403 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8404 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8405 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8406
paul718e3742002-12-13 20:15:29 +00008407 /* "ospf rfc1583-compatible" commands. */
8408 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8409 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8410 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8411 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8412
8413 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008414 install_element (OSPF_NODE, &ospf_network_area_cmd);
8415 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008416
8417 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008418 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8419 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8420 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008421
8422 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008423 install_element (OSPF_NODE, &ospf_area_range_cmd);
8424 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8425 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8426 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8427 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8428 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8429 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8430 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8431 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8432 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8433 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008434
8435 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008436 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8437 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008438
paula2c62832003-04-23 17:01:31 +00008439 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8440 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008441
paula2c62832003-04-23 17:01:31 +00008442 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8443 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008444
paula2c62832003-04-23 17:01:31 +00008445 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8446 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008447
paula2c62832003-04-23 17:01:31 +00008448 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8449 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008450
paula2c62832003-04-23 17:01:31 +00008451 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8452 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8453 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008454
paula2c62832003-04-23 17:01:31 +00008455 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8456 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008457
paula2c62832003-04-23 17:01:31 +00008458 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8459 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008460
paula2c62832003-04-23 17:01:31 +00008461 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8462 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8463 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008464
paula2c62832003-04-23 17:01:31 +00008465 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8466 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8467 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008468
8469 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008470 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8471 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8472 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8473 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008474
paul718e3742002-12-13 20:15:29 +00008475 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008476 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8477 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8478 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8479 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8480 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8481 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008482
paula2c62832003-04-23 17:01:31 +00008483 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8484 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008485
paula2c62832003-04-23 17:01:31 +00008486 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8487 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008488
paula2c62832003-04-23 17:01:31 +00008489 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8490 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008491
paula2c62832003-04-23 17:01:31 +00008492 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8493 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008494
paula2c62832003-04-23 17:01:31 +00008495 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8496 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008497
8498 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008499 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8500 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008501 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8502 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8503
paul88d6cf32005-10-29 12:50:09 +00008504 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008505 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8506 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8507 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008508
paul88d6cf32005-10-29 12:50:09 +00008509 /* max-metric commands */
8510 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8511 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8512 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8513 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8514 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8515 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8516
8517 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008518 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8519 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008520
8521 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008522 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8523 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8524 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8525 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8526 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8527 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8528 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8529 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008530
8531 /* Init interface related vty commands. */
8532 ospf_vty_if_init ();
8533
8534 /* Init zebra related vty commands. */
8535 ospf_vty_zebra_init ();
8536}