blob: 2ba8188c758b59d9932a1fd6fa59a065f2d3a740 [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;
paul718e3742002-12-13 20:15:29 +00001745 int format;
vincentba682532005-09-29 13:52:57 +00001746 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001747
1748 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
Andrew Certain0798cee2012-12-04 13:43:42 -08001749 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
paul718e3742002-12-13 20:15:29 +00001750
paul68980082003-03-25 05:07:42 +00001751 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001752 if (area == NULL)
1753 return CMD_SUCCESS;
1754
1755 if (area->external_routing == OSPF_AREA_DEFAULT)
1756 {
1757 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1758 return CMD_WARNING;
1759 }
1760
1761 area->default_cost = 1;
1762
vincentba682532005-09-29 13:52:57 +00001763 p.family = AF_INET;
1764 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1765 p.prefixlen = 0;
1766 if (IS_DEBUG_OSPF_EVENT)
1767 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1768 "announcing 0.0.0.0/0 to area %s",
1769 inet_ntoa (area->area_id));
1770 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1771
1772
paul68980082003-03-25 05:07:42 +00001773 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001774
1775 return CMD_SUCCESS;
1776}
1777
paula2c62832003-04-23 17:01:31 +00001778DEFUN (ospf_area_export_list,
1779 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001780 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1781 "OSPF area parameters\n"
1782 "OSPF area ID in IP address format\n"
1783 "OSPF area ID as a decimal value\n"
1784 "Set the filter for networks announced to other areas\n"
1785 "Name of the access-list\n")
1786{
paul68980082003-03-25 05:07:42 +00001787 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001788 struct ospf_area *area;
1789 struct in_addr area_id;
1790 int format;
1791
hasso52930762004-04-19 18:26:53 +00001792 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1793
paul68980082003-03-25 05:07:42 +00001794 area = ospf_area_get (ospf, area_id, format);
1795 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001796
1797 return CMD_SUCCESS;
1798}
1799
paula2c62832003-04-23 17:01:31 +00001800DEFUN (no_ospf_area_export_list,
1801 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001802 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1803 NO_STR
1804 "OSPF area parameters\n"
1805 "OSPF area ID in IP address format\n"
1806 "OSPF area ID as a decimal value\n"
1807 "Unset the filter for networks announced to other areas\n"
1808 "Name of the access-list\n")
1809{
paul68980082003-03-25 05:07:42 +00001810 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001811 struct ospf_area *area;
1812 struct in_addr area_id;
1813 int format;
1814
hasso52930762004-04-19 18:26:53 +00001815 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1816
paul68980082003-03-25 05:07:42 +00001817 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001818 if (area == NULL)
1819 return CMD_SUCCESS;
1820
paul68980082003-03-25 05:07:42 +00001821 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001822
1823 return CMD_SUCCESS;
1824}
1825
1826
paula2c62832003-04-23 17:01:31 +00001827DEFUN (ospf_area_import_list,
1828 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001829 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1830 "OSPF area parameters\n"
1831 "OSPF area ID in IP address format\n"
1832 "OSPF area ID as a decimal value\n"
1833 "Set the filter for networks from other areas announced to the specified one\n"
1834 "Name of the access-list\n")
1835{
paul68980082003-03-25 05:07:42 +00001836 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001837 struct ospf_area *area;
1838 struct in_addr area_id;
1839 int format;
1840
hasso52930762004-04-19 18:26:53 +00001841 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1842
paul68980082003-03-25 05:07:42 +00001843 area = ospf_area_get (ospf, area_id, format);
1844 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001845
1846 return CMD_SUCCESS;
1847}
1848
paula2c62832003-04-23 17:01:31 +00001849DEFUN (no_ospf_area_import_list,
1850 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001851 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1852 NO_STR
1853 "OSPF area parameters\n"
1854 "OSPF area ID in IP address format\n"
1855 "OSPF area ID as a decimal value\n"
1856 "Unset the filter for networks announced to other areas\n"
1857 "Name of the access-list\n")
1858{
paul68980082003-03-25 05:07:42 +00001859 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001860 struct ospf_area *area;
1861 struct in_addr area_id;
1862 int format;
1863
hasso52930762004-04-19 18:26:53 +00001864 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1865
paul68980082003-03-25 05:07:42 +00001866 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001867 if (area == NULL)
1868 return CMD_SUCCESS;
1869
paul68980082003-03-25 05:07:42 +00001870 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001871
1872 return CMD_SUCCESS;
1873}
1874
paula2c62832003-04-23 17:01:31 +00001875DEFUN (ospf_area_filter_list,
1876 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001877 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1878 "OSPF area parameters\n"
1879 "OSPF area ID in IP address format\n"
1880 "OSPF area ID as a decimal value\n"
1881 "Filter networks between OSPF areas\n"
1882 "Filter prefixes between OSPF areas\n"
1883 "Name of an IP prefix-list\n"
1884 "Filter networks sent to this area\n"
1885 "Filter networks sent from this area\n")
1886{
paul68980082003-03-25 05:07:42 +00001887 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001888 struct ospf_area *area;
1889 struct in_addr area_id;
1890 struct prefix_list *plist;
1891 int format;
1892
1893 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1894
paul68980082003-03-25 05:07:42 +00001895 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001896 plist = prefix_list_lookup (AFI_IP, argv[1]);
1897 if (strncmp (argv[2], "in", 2) == 0)
1898 {
1899 PREFIX_LIST_IN (area) = plist;
1900 if (PREFIX_NAME_IN (area))
1901 free (PREFIX_NAME_IN (area));
1902
1903 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001904 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001905 }
1906 else
1907 {
1908 PREFIX_LIST_OUT (area) = plist;
1909 if (PREFIX_NAME_OUT (area))
1910 free (PREFIX_NAME_OUT (area));
1911
1912 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001913 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001914 }
1915
1916 return CMD_SUCCESS;
1917}
1918
paula2c62832003-04-23 17:01:31 +00001919DEFUN (no_ospf_area_filter_list,
1920 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001921 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1922 NO_STR
1923 "OSPF area parameters\n"
1924 "OSPF area ID in IP address format\n"
1925 "OSPF area ID as a decimal value\n"
1926 "Filter networks between OSPF areas\n"
1927 "Filter prefixes between OSPF areas\n"
1928 "Name of an IP prefix-list\n"
1929 "Filter networks sent to this area\n"
1930 "Filter networks sent from this area\n")
1931{
paul68980082003-03-25 05:07:42 +00001932 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001933 struct ospf_area *area;
1934 struct in_addr area_id;
paul718e3742002-12-13 20:15:29 +00001935 int format;
1936
1937 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1938
Paul Jakma1a8ec2b2006-05-11 13:34:08 +00001939 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1940 return CMD_SUCCESS;
1941
paul718e3742002-12-13 20:15:29 +00001942 if (strncmp (argv[2], "in", 2) == 0)
1943 {
1944 if (PREFIX_NAME_IN (area))
1945 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1946 return CMD_SUCCESS;
1947
1948 PREFIX_LIST_IN (area) = NULL;
1949 if (PREFIX_NAME_IN (area))
1950 free (PREFIX_NAME_IN (area));
1951
1952 PREFIX_NAME_IN (area) = NULL;
1953
paul68980082003-03-25 05:07:42 +00001954 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001955 }
1956 else
1957 {
1958 if (PREFIX_NAME_OUT (area))
1959 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1960 return CMD_SUCCESS;
1961
1962 PREFIX_LIST_OUT (area) = NULL;
1963 if (PREFIX_NAME_OUT (area))
1964 free (PREFIX_NAME_OUT (area));
1965
1966 PREFIX_NAME_OUT (area) = NULL;
1967
paul68980082003-03-25 05:07:42 +00001968 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001969 }
1970
1971 return CMD_SUCCESS;
1972}
1973
1974
paula2c62832003-04-23 17:01:31 +00001975DEFUN (ospf_area_authentication_message_digest,
1976 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001977 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1978 "OSPF area parameters\n"
1979 "Enable authentication\n"
1980 "Use message-digest authentication\n")
1981{
paul68980082003-03-25 05:07:42 +00001982 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001983 struct ospf_area *area;
1984 struct in_addr area_id;
1985 int format;
1986
1987 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1988
paul68980082003-03-25 05:07:42 +00001989 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001990 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1991
1992 return CMD_SUCCESS;
1993}
1994
paula2c62832003-04-23 17:01:31 +00001995DEFUN (ospf_area_authentication,
1996 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001997 "area (A.B.C.D|<0-4294967295>) authentication",
1998 "OSPF area parameters\n"
1999 "OSPF area ID in IP address format\n"
2000 "OSPF area ID as a decimal value\n"
2001 "Enable authentication\n")
2002{
paul68980082003-03-25 05:07:42 +00002003 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002004 struct ospf_area *area;
2005 struct in_addr area_id;
2006 int format;
2007
2008 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2009
paul68980082003-03-25 05:07:42 +00002010 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00002011 area->auth_type = OSPF_AUTH_SIMPLE;
2012
2013 return CMD_SUCCESS;
2014}
2015
paula2c62832003-04-23 17:01:31 +00002016DEFUN (no_ospf_area_authentication,
2017 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002018 "no area (A.B.C.D|<0-4294967295>) authentication",
2019 NO_STR
2020 "OSPF area parameters\n"
2021 "OSPF area ID in IP address format\n"
2022 "OSPF area ID as a decimal value\n"
2023 "Enable authentication\n")
2024{
paul68980082003-03-25 05:07:42 +00002025 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002026 struct ospf_area *area;
2027 struct in_addr area_id;
2028 int format;
2029
2030 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2031
paul68980082003-03-25 05:07:42 +00002032 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002033 if (area == NULL)
2034 return CMD_SUCCESS;
2035
2036 area->auth_type = OSPF_AUTH_NULL;
2037
paul68980082003-03-25 05:07:42 +00002038 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002039
2040 return CMD_SUCCESS;
2041}
2042
2043
2044DEFUN (ospf_abr_type,
2045 ospf_abr_type_cmd,
2046 "ospf abr-type (cisco|ibm|shortcut|standard)",
2047 "OSPF specific commands\n"
2048 "Set OSPF ABR type\n"
2049 "Alternative ABR, cisco implementation\n"
2050 "Alternative ABR, IBM implementation\n"
2051 "Shortcut ABR\n"
2052 "Standard behavior (RFC2328)\n")
2053{
paul68980082003-03-25 05:07:42 +00002054 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002055 u_char abr_type = OSPF_ABR_UNKNOWN;
2056
2057 if (strncmp (argv[0], "c", 1) == 0)
2058 abr_type = OSPF_ABR_CISCO;
2059 else if (strncmp (argv[0], "i", 1) == 0)
2060 abr_type = OSPF_ABR_IBM;
2061 else if (strncmp (argv[0], "sh", 2) == 0)
2062 abr_type = OSPF_ABR_SHORTCUT;
2063 else if (strncmp (argv[0], "st", 2) == 0)
2064 abr_type = OSPF_ABR_STAND;
2065 else
2066 return CMD_WARNING;
2067
2068 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002069 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002070 {
paul68980082003-03-25 05:07:42 +00002071 ospf->abr_type = abr_type;
2072 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002073 }
2074
2075 return CMD_SUCCESS;
2076}
2077
2078DEFUN (no_ospf_abr_type,
2079 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002080 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002081 NO_STR
2082 "OSPF specific commands\n"
2083 "Set OSPF ABR type\n"
2084 "Alternative ABR, cisco implementation\n"
2085 "Alternative ABR, IBM implementation\n"
2086 "Shortcut ABR\n")
2087{
paul68980082003-03-25 05:07:42 +00002088 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002089 u_char abr_type = OSPF_ABR_UNKNOWN;
2090
2091 if (strncmp (argv[0], "c", 1) == 0)
2092 abr_type = OSPF_ABR_CISCO;
2093 else if (strncmp (argv[0], "i", 1) == 0)
2094 abr_type = OSPF_ABR_IBM;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002095 else if (strncmp (argv[0], "sh", 2) == 0)
paul718e3742002-12-13 20:15:29 +00002096 abr_type = OSPF_ABR_SHORTCUT;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002097 else if (strncmp (argv[0], "st", 2) == 0)
2098 abr_type = OSPF_ABR_STAND;
paul718e3742002-12-13 20:15:29 +00002099 else
2100 return CMD_WARNING;
2101
2102 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002103 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002104 {
pauld57834f2005-07-12 20:04:22 +00002105 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002106 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002107 }
2108
2109 return CMD_SUCCESS;
2110}
2111
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002112DEFUN (ospf_log_adjacency_changes,
2113 ospf_log_adjacency_changes_cmd,
2114 "log-adjacency-changes",
2115 "Log changes in adjacency state\n")
2116{
2117 struct ospf *ospf = vty->index;
2118
2119 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2120 return CMD_SUCCESS;
2121}
2122
2123DEFUN (ospf_log_adjacency_changes_detail,
2124 ospf_log_adjacency_changes_detail_cmd,
2125 "log-adjacency-changes detail",
2126 "Log changes in adjacency state\n"
2127 "Log all state changes\n")
2128{
2129 struct ospf *ospf = vty->index;
2130
2131 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2132 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2133 return CMD_SUCCESS;
2134}
2135
2136DEFUN (no_ospf_log_adjacency_changes,
2137 no_ospf_log_adjacency_changes_cmd,
2138 "no log-adjacency-changes",
2139 NO_STR
2140 "Log changes in adjacency state\n")
2141{
2142 struct ospf *ospf = vty->index;
2143
2144 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2145 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2146 return CMD_SUCCESS;
2147}
2148
2149DEFUN (no_ospf_log_adjacency_changes_detail,
2150 no_ospf_log_adjacency_changes_detail_cmd,
2151 "no log-adjacency-changes detail",
2152 NO_STR
2153 "Log changes in adjacency state\n"
2154 "Log all state changes\n")
2155{
2156 struct ospf *ospf = vty->index;
2157
2158 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2159 return CMD_SUCCESS;
2160}
2161
paul718e3742002-12-13 20:15:29 +00002162DEFUN (ospf_compatible_rfc1583,
2163 ospf_compatible_rfc1583_cmd,
2164 "compatible rfc1583",
2165 "OSPF compatibility list\n"
2166 "compatible with RFC 1583\n")
2167{
2168 struct ospf *ospf = vty->index;
2169
2170 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2171 {
2172 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002173 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002174 }
2175 return CMD_SUCCESS;
2176}
2177
2178DEFUN (no_ospf_compatible_rfc1583,
2179 no_ospf_compatible_rfc1583_cmd,
2180 "no compatible rfc1583",
2181 NO_STR
2182 "OSPF compatibility list\n"
2183 "compatible with RFC 1583\n")
2184{
2185 struct ospf *ospf = vty->index;
2186
2187 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2188 {
2189 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002190 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002191 }
2192 return CMD_SUCCESS;
2193}
2194
2195ALIAS (ospf_compatible_rfc1583,
2196 ospf_rfc1583_flag_cmd,
2197 "ospf rfc1583compatibility",
2198 "OSPF specific commands\n"
2199 "Enable the RFC1583Compatibility flag\n")
2200
2201ALIAS (no_ospf_compatible_rfc1583,
2202 no_ospf_rfc1583_flag_cmd,
2203 "no ospf rfc1583compatibility",
2204 NO_STR
2205 "OSPF specific commands\n"
2206 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002207
2208static int
2209ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2210 unsigned int hold,
2211 unsigned int max)
2212{
2213 struct ospf *ospf = vty->index;
2214
2215 ospf->spf_delay = delay;
2216 ospf->spf_holdtime = hold;
2217 ospf->spf_max_holdtime = max;
2218
2219 return CMD_SUCCESS;
2220}
paul718e3742002-12-13 20:15:29 +00002221
pauld24f6e22005-10-21 09:23:12 +00002222DEFUN (ospf_timers_throttle_spf,
2223 ospf_timers_throttle_spf_cmd,
2224 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2225 "Adjust routing timers\n"
2226 "Throttling adaptive timer\n"
2227 "OSPF SPF timers\n"
2228 "Delay (msec) from first change received till SPF calculation\n"
2229 "Initial hold time (msec) between consecutive SPF calculations\n"
2230 "Maximum hold time (msec)\n")
2231{
2232 unsigned int delay, hold, max;
2233
2234 if (argc != 3)
2235 {
2236 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2237 return CMD_WARNING;
2238 }
2239
2240 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2241 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2242 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2243
2244 return ospf_timers_spf_set (vty, delay, hold, max);
2245}
2246
2247DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002248 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002249 "timers spf <0-4294967295> <0-4294967295>",
2250 "Adjust routing timers\n"
2251 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002252 "Delay (s) between receiving a change to SPF calculation\n"
2253 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002254{
pauld24f6e22005-10-21 09:23:12 +00002255 unsigned int delay, hold;
2256
2257 if (argc != 2)
2258 {
2259 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2260 return CMD_WARNING;
2261 }
2262
paul4dadc292005-05-06 21:37:42 +00002263 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2264 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002265
2266 /* truncate down the second values if they're greater than 600000ms */
2267 if (delay > (600000 / 1000))
2268 delay = 600000;
2269 else if (delay == 0)
2270 /* 0s delay was probably specified because of lack of ms resolution */
2271 delay = OSPF_SPF_DELAY_DEFAULT;
2272 if (hold > (600000 / 1000))
2273 hold = 600000;
2274
2275 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002276}
2277
pauld24f6e22005-10-21 09:23:12 +00002278DEFUN (no_ospf_timers_throttle_spf,
2279 no_ospf_timers_throttle_spf_cmd,
2280 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002281 NO_STR
2282 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002283 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002284 "OSPF SPF timers\n")
2285{
pauld24f6e22005-10-21 09:23:12 +00002286 return ospf_timers_spf_set (vty,
2287 OSPF_SPF_DELAY_DEFAULT,
2288 OSPF_SPF_HOLDTIME_DEFAULT,
2289 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002290}
2291
pauld24f6e22005-10-21 09:23:12 +00002292ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2293 no_ospf_timers_spf_cmd,
2294 "no timers spf",
2295 NO_STR
2296 "Adjust routing timers\n"
2297 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002298
paula2c62832003-04-23 17:01:31 +00002299DEFUN (ospf_neighbor,
2300 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002301 "neighbor A.B.C.D",
2302 NEIGHBOR_STR
2303 "Neighbor IP address\n")
2304{
2305 struct ospf *ospf = vty->index;
2306 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002307 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2308 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002309
2310 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2311
2312 if (argc > 1)
2313 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2314
2315 if (argc > 2)
2316 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2317
2318 ospf_nbr_nbma_set (ospf, nbr_addr);
2319 if (argc > 1)
2320 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2321 if (argc > 2)
Andrew Certain1a61ad12012-12-04 12:50:23 -08002322 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
paul718e3742002-12-13 20:15:29 +00002323
2324 return CMD_SUCCESS;
2325}
2326
paula2c62832003-04-23 17:01:31 +00002327ALIAS (ospf_neighbor,
2328 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002329 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2330 NEIGHBOR_STR
2331 "Neighbor IP address\n"
2332 "Neighbor Priority\n"
2333 "Priority\n"
2334 "Dead Neighbor Polling interval\n"
2335 "Seconds\n")
2336
paula2c62832003-04-23 17:01:31 +00002337ALIAS (ospf_neighbor,
2338 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002339 "neighbor A.B.C.D priority <0-255>",
2340 NEIGHBOR_STR
2341 "Neighbor IP address\n"
2342 "Neighbor Priority\n"
2343 "Seconds\n")
2344
paula2c62832003-04-23 17:01:31 +00002345DEFUN (ospf_neighbor_poll_interval,
2346 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002347 "neighbor A.B.C.D poll-interval <1-65535>",
2348 NEIGHBOR_STR
2349 "Neighbor IP address\n"
2350 "Dead Neighbor Polling interval\n"
2351 "Seconds\n")
2352{
2353 struct ospf *ospf = vty->index;
2354 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002355 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2356 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002357
2358 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2359
2360 if (argc > 1)
2361 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2362
2363 if (argc > 2)
2364 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2365
2366 ospf_nbr_nbma_set (ospf, nbr_addr);
2367 if (argc > 1)
2368 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2369 if (argc > 2)
2370 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2371
2372 return CMD_SUCCESS;
2373}
2374
paula2c62832003-04-23 17:01:31 +00002375ALIAS (ospf_neighbor_poll_interval,
2376 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002377 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2378 NEIGHBOR_STR
2379 "Neighbor address\n"
2380 "OSPF dead-router polling interval\n"
2381 "Seconds\n"
2382 "OSPF priority of non-broadcast neighbor\n"
2383 "Priority\n")
2384
paula2c62832003-04-23 17:01:31 +00002385DEFUN (no_ospf_neighbor,
2386 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002387 "no neighbor A.B.C.D",
2388 NO_STR
2389 NEIGHBOR_STR
2390 "Neighbor IP address\n")
2391{
2392 struct ospf *ospf = vty->index;
2393 struct in_addr nbr_addr;
paul718e3742002-12-13 20:15:29 +00002394
2395 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2396
Andrew Certain0798cee2012-12-04 13:43:42 -08002397 (void)ospf_nbr_nbma_unset (ospf, nbr_addr);
paul718e3742002-12-13 20:15:29 +00002398
2399 return CMD_SUCCESS;
2400}
2401
paula2c62832003-04-23 17:01:31 +00002402ALIAS (no_ospf_neighbor,
2403 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002404 "no neighbor A.B.C.D priority <0-255>",
2405 NO_STR
2406 NEIGHBOR_STR
2407 "Neighbor IP address\n"
2408 "Neighbor Priority\n"
2409 "Priority\n")
2410
paula2c62832003-04-23 17:01:31 +00002411ALIAS (no_ospf_neighbor,
2412 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002413 "no neighbor A.B.C.D poll-interval <1-65535>",
2414 NO_STR
2415 NEIGHBOR_STR
2416 "Neighbor IP address\n"
2417 "Dead Neighbor Polling interval\n"
2418 "Seconds\n")
2419
paula2c62832003-04-23 17:01:31 +00002420ALIAS (no_ospf_neighbor,
2421 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002422 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2423 NO_STR
2424 NEIGHBOR_STR
2425 "Neighbor IP address\n"
2426 "Neighbor Priority\n"
2427 "Priority\n"
2428 "Dead Neighbor Polling interval\n"
2429 "Seconds\n")
2430
2431
paula2c62832003-04-23 17:01:31 +00002432DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002433 "refresh timer <10-1800>",
2434 "Adjust refresh parameters\n"
2435 "Set refresh timer\n"
2436 "Timer value in seconds\n")
2437{
2438 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002439 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002440
2441 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2442 interval = (interval / 10) * 10;
2443
2444 ospf_timers_refresh_set (ospf, interval);
2445
2446 return CMD_SUCCESS;
2447}
2448
paula2c62832003-04-23 17:01:31 +00002449DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002450 "no refresh timer <10-1800>",
2451 "Adjust refresh parameters\n"
2452 "Unset refresh timer\n"
2453 "Timer value in seconds\n")
2454{
2455 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002456 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002457
2458 if (argc == 1)
2459 {
2460 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2461
2462 if (ospf->lsa_refresh_interval != interval ||
2463 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2464 return CMD_SUCCESS;
2465 }
2466
2467 ospf_timers_refresh_unset (ospf);
2468
2469 return CMD_SUCCESS;
2470}
2471
paula2c62832003-04-23 17:01:31 +00002472ALIAS (no_ospf_refresh_timer,
2473 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002474 "no refresh timer",
2475 "Adjust refresh parameters\n"
2476 "Unset refresh timer\n")
2477
paula2c62832003-04-23 17:01:31 +00002478DEFUN (ospf_auto_cost_reference_bandwidth,
2479 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002480 "auto-cost reference-bandwidth <1-4294967>",
2481 "Calculate OSPF interface cost according to bandwidth\n"
2482 "Use reference bandwidth method to assign OSPF cost\n"
2483 "The reference bandwidth in terms of Mbits per second\n")
2484{
paul68980082003-03-25 05:07:42 +00002485 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002486 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002487 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002488 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002489
2490 refbw = strtol (argv[0], NULL, 10);
2491 if (refbw < 1 || refbw > 4294967)
2492 {
2493 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2494 return CMD_WARNING;
2495 }
2496
2497 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002498 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002499 return CMD_SUCCESS;
2500
paul68980082003-03-25 05:07:42 +00002501 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002502 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2503 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002504
2505 return CMD_SUCCESS;
2506}
2507
paula2c62832003-04-23 17:01:31 +00002508DEFUN (no_ospf_auto_cost_reference_bandwidth,
2509 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002510 "no auto-cost reference-bandwidth",
2511 NO_STR
2512 "Calculate OSPF interface cost according to bandwidth\n"
2513 "Use reference bandwidth method to assign OSPF cost\n")
2514{
paul68980082003-03-25 05:07:42 +00002515 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002516 struct listnode *node, *nnode;
2517 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002518
paul68980082003-03-25 05:07:42 +00002519 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002520 return CMD_SUCCESS;
2521
paul68980082003-03-25 05:07:42 +00002522 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002523 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2524 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2525
paul1eb8ef22005-04-07 07:30:20 +00002526 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2527 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002528
2529 return CMD_SUCCESS;
2530}
2531
hassoeb1ce602004-10-08 08:17:22 +00002532const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002533{
2534 "Unknown",
2535 "Standard (RFC2328)",
2536 "Alternative IBM",
2537 "Alternative Cisco",
2538 "Alternative Shortcut"
2539};
2540
hassoeb1ce602004-10-08 08:17:22 +00002541const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002542{
2543 "Default",
2544 "Enabled",
2545 "Disabled"
2546};
2547
2548
2549
paul4dadc292005-05-06 21:37:42 +00002550static void
paul718e3742002-12-13 20:15:29 +00002551show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2552{
2553 /* Show Area ID. */
2554 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2555
2556 /* Show Area type/mode. */
2557 if (OSPF_IS_AREA_BACKBONE (area))
2558 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2559 else
2560 {
2561 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002562 vty_out (vty, " (Stub%s%s)",
2563 area->no_summary ? ", no summary" : "",
2564 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002565
paulb0a053b2003-06-22 09:04:47 +00002566 else if (area->external_routing == OSPF_AREA_NSSA)
2567 vty_out (vty, " (NSSA%s%s)",
2568 area->no_summary ? ", no summary" : "",
2569 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002570
2571 vty_out (vty, "%s", VTY_NEWLINE);
2572 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002573 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002574 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002575 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002576 }
2577
2578 /* Show number of interfaces. */
2579 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2580 "Active: %d%s", listcount (area->oiflist),
2581 area->act_ints, VTY_NEWLINE);
2582
paul718e3742002-12-13 20:15:29 +00002583 if (area->external_routing == OSPF_AREA_NSSA)
2584 {
2585 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 +00002586 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002587 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2588 VTY_NEWLINE);
2589 else if (area->NSSATranslatorState)
2590 {
2591 vty_out (vty, " We are an ABR and ");
2592 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2593 vty_out (vty, "the NSSA Elected Translator. %s",
2594 VTY_NEWLINE);
2595 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2596 vty_out (vty, "always an NSSA Translator. %s",
2597 VTY_NEWLINE);
2598 }
paul718e3742002-12-13 20:15:29 +00002599 else
paulb0a053b2003-06-22 09:04:47 +00002600 {
2601 vty_out (vty, " We are an ABR, but ");
2602 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2603 vty_out (vty, "not the NSSA Elected Translator. %s",
2604 VTY_NEWLINE);
2605 else
hassoc6b87812004-12-22 13:09:59 +00002606 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002607 VTY_NEWLINE);
2608 }
paul718e3742002-12-13 20:15:29 +00002609 }
paul88d6cf32005-10-29 12:50:09 +00002610 /* Stub-router state for this area */
2611 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2612 {
ajs649654a2005-11-16 20:17:52 +00002613 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002614 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2615 VTY_NEWLINE);
2616 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2617 vty_out (vty, " Administratively activated (indefinitely)%s",
2618 VTY_NEWLINE);
2619 if (area->t_stub_router)
2620 vty_out (vty, " Active from startup, %s remaining%s",
2621 ospf_timer_dump (area->t_stub_router, timebuf,
2622 sizeof(timebuf)), VTY_NEWLINE);
2623 }
2624
paul718e3742002-12-13 20:15:29 +00002625 /* Show number of fully adjacent neighbors. */
2626 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002627 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002628
2629 /* Show authentication type. */
2630 vty_out (vty, " Area has ");
2631 if (area->auth_type == OSPF_AUTH_NULL)
2632 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2633 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2634 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2635 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2636 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2637
2638 if (!OSPF_IS_AREA_BACKBONE (area))
2639 vty_out (vty, " Number of full virtual adjacencies going through"
2640 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2641
2642 /* Show SPF calculation times. */
2643 vty_out (vty, " SPF algorithm executed %d times%s",
2644 area->spf_calculation, VTY_NEWLINE);
2645
2646 /* Show number of LSA. */
2647 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002648 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2649 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2650 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2651 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2652 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2653 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2654 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2655 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2656 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2657 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2658 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2659 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2660 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2661 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2662 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2663#ifdef HAVE_OPAQUE_LSA
2664 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2665 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2666 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2667 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2668 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2669 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2670#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002671 vty_out (vty, "%s", VTY_NEWLINE);
2672}
2673
2674DEFUN (show_ip_ospf,
2675 show_ip_ospf_cmd,
2676 "show ip ospf",
2677 SHOW_STR
2678 IP_STR
2679 "OSPF information\n")
2680{
paul1eb8ef22005-04-07 07:30:20 +00002681 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002682 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002683 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002684 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002685 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002686
2687 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002688 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002689 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002690 {
2691 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2692 return CMD_SUCCESS;
2693 }
2694
2695 /* Show Router ID. */
2696 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002697 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002698 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002699
2700 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002701 if (ospf->t_deferred_shutdown)
2702 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2703 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002704 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002705 /* Show capability. */
2706 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2707 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2708 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002709 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002710 "enabled" : "disabled", VTY_NEWLINE);
2711#ifdef HAVE_OPAQUE_LSA
2712 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002713 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002714 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002715 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002716 " (origination blocked)" : "",
2717 VTY_NEWLINE);
2718#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002719
2720 /* Show stub-router configuration */
2721 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2722 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2723 {
2724 vty_out (vty, " Stub router advertisement is configured%s",
2725 VTY_NEWLINE);
2726 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2727 vty_out (vty, " Enabled for %us after start-up%s",
2728 ospf->stub_router_startup_time, VTY_NEWLINE);
2729 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2730 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2731 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2732 }
2733
paul718e3742002-12-13 20:15:29 +00002734 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002735 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2736 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2737 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2738 " Hold time multiplier is currently %d%s",
2739 ospf->spf_delay, VTY_NEWLINE,
2740 ospf->spf_holdtime, VTY_NEWLINE,
2741 ospf->spf_max_holdtime, VTY_NEWLINE,
2742 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002743 vty_out (vty, " SPF algorithm ");
2744 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2745 {
Paul Jakma2518efd2006-08-27 06:49:29 +00002746 result = tv_sub (recent_relative_time (), ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002747 vty_out (vty, "last executed %s ago%s",
2748 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2749 VTY_NEWLINE);
2750 }
2751 else
2752 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002753 vty_out (vty, " SPF timer %s%s%s",
2754 (ospf->t_spf_calc ? "due in " : "is "),
2755 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2756 VTY_NEWLINE);
2757
paul718e3742002-12-13 20:15:29 +00002758 /* Show refresh parameters. */
2759 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002760 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002761
2762 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002763 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002764 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002765 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002766
paul68980082003-03-25 05:07:42 +00002767 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002768 vty_out (vty, " This router is an ASBR "
2769 "(injecting external routing information)%s", VTY_NEWLINE);
2770
2771 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002772 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2773 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2774 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2775#ifdef HAVE_OPAQUE_LSA
2776 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2777 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2778 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2779#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002780 /* Show number of areas attached. */
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002781 vty_out (vty, " Number of areas attached to this router: %d%s",
2782 listcount (ospf->areas), VTY_NEWLINE);
2783
2784 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2785 {
2786 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2787 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2788 else
2789 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2790 }
2791
2792 vty_out (vty, "%s",VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002793
2794 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002795 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2796 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002797
2798 return CMD_SUCCESS;
2799}
2800
2801
ajsfd651fa2005-03-29 16:08:16 +00002802static void
paul68980082003-03-25 05:07:42 +00002803show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2804 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002805{
ajsfd651fa2005-03-29 16:08:16 +00002806 int is_up;
paul718e3742002-12-13 20:15:29 +00002807 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002808 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002809
paul718e3742002-12-13 20:15:29 +00002810 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002811 vty_out (vty, "%s is %s%s", ifp->name,
2812 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002813 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2814 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2815 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002816
2817 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002818 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002819 {
2820 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2821 return;
2822 }
ajsfd651fa2005-03-29 16:08:16 +00002823 else if (!is_up)
2824 {
2825 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2826 VTY_NEWLINE);
2827 return;
2828 }
2829
paul718e3742002-12-13 20:15:29 +00002830 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2831 {
2832 struct ospf_interface *oi = rn->info;
2833
2834 if (oi == NULL)
2835 continue;
2836
2837 /* Show OSPF interface information. */
2838 vty_out (vty, " Internet Address %s/%d,",
2839 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2840
Paul Jakma9c27ef92006-05-04 07:32:57 +00002841 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2842 {
2843 struct in_addr *dest;
2844 const char *dstr;
2845
Andrew J. Schorre4529632006-12-12 19:18:21 +00002846 if (CONNECTED_PEER(oi->connected)
2847 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
Paul Jakma9c27ef92006-05-04 07:32:57 +00002848 dstr = "Peer";
2849 else
2850 dstr = "Broadcast";
2851
2852 /* For Vlinks, showing the peer address is probably more
2853 * informative than the local interface that is being used
2854 */
2855 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2856 dest = &oi->vl_data->peer_addr;
2857 else
2858 dest = &oi->connected->destination->u.prefix4;
2859
2860 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2861 }
hasso3fb9cd62004-10-19 19:44:43 +00002862
paul718e3742002-12-13 20:15:29 +00002863 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2864 VTY_NEWLINE);
2865
vincentba682532005-09-29 13:52:57 +00002866 vty_out (vty, " MTU mismatch detection:%s%s",
2867 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2868
paul718e3742002-12-13 20:15:29 +00002869 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002870 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002871 oi->output_cost, VTY_NEWLINE);
2872
2873 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2874 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2875 PRIORITY (oi), VTY_NEWLINE);
2876
2877 /* Show DR information. */
2878 if (DR (oi).s_addr == 0)
2879 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2880 else
2881 {
2882 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2883 if (nbr == NULL)
2884 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2885 else
2886 {
2887 vty_out (vty, " Designated Router (ID) %s,",
2888 inet_ntoa (nbr->router_id));
2889 vty_out (vty, " Interface Address %s%s",
2890 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2891 }
2892 }
2893
2894 /* Show BDR information. */
2895 if (BDR (oi).s_addr == 0)
2896 vty_out (vty, " No backup designated router on this network%s",
2897 VTY_NEWLINE);
2898 else
2899 {
2900 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2901 if (nbr == NULL)
2902 vty_out (vty, " No backup designated router on this network%s",
2903 VTY_NEWLINE);
2904 else
2905 {
2906 vty_out (vty, " Backup Designated Router (ID) %s,",
2907 inet_ntoa (nbr->router_id));
2908 vty_out (vty, " Interface Address %s%s",
2909 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2910 }
2911 }
Paul Jakma7eb5b472009-10-13 16:13:13 +01002912
2913 /* Next network-LSA sequence number we'll use, if we're elected DR */
2914 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
2915 != OSPF_INITIAL_SEQUENCE_NUMBER)
2916 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
2917 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
2918
ajsba6454e2005-02-08 15:37:30 +00002919 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002920 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2921 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2922 {
2923 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2924 vty_out (vty, " OSPFAllRouters");
2925 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2926 vty_out (vty, " OSPFDesignatedRouters");
2927 }
2928 else
ajsba6454e2005-02-08 15:37:30 +00002929 vty_out (vty, " <None>");
2930 vty_out (vty, "%s", VTY_NEWLINE);
2931
paul718e3742002-12-13 20:15:29 +00002932 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002933 vty_out (vty, " Hello ");
2934 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2935 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2936 else
2937 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2938 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2939 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002940 OSPF_IF_PARAM (oi, v_wait),
2941 OSPF_IF_PARAM (oi, retransmit_interval),
2942 VTY_NEWLINE);
2943
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002944 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002945 {
ajs649654a2005-11-16 20:17:52 +00002946 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002947 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002948 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002949 VTY_NEWLINE);
2950 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002951 else /* passive-interface is set */
paul718e3742002-12-13 20:15:29 +00002952 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2953
2954 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002955 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002956 VTY_NEWLINE);
2957 }
2958}
2959
2960DEFUN (show_ip_ospf_interface,
2961 show_ip_ospf_interface_cmd,
2962 "show ip ospf interface [INTERFACE]",
2963 SHOW_STR
2964 IP_STR
2965 "OSPF information\n"
2966 "Interface information\n"
2967 "Interface name\n")
2968{
2969 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002970 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002971 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002972
paul020709f2003-04-04 02:44:16 +00002973 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002974 if (ospf == NULL)
2975 {
2976 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2977 return CMD_SUCCESS;
2978 }
paul020709f2003-04-04 02:44:16 +00002979
paul718e3742002-12-13 20:15:29 +00002980 /* Show All Interfaces. */
2981 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002982 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2983 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002984 /* Interface name is specified. */
2985 else
2986 {
2987 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2988 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2989 else
paul68980082003-03-25 05:07:42 +00002990 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002991 }
2992
2993 return CMD_SUCCESS;
2994}
2995
paul4dadc292005-05-06 21:37:42 +00002996static void
pauld24f6e22005-10-21 09:23:12 +00002997show_ip_ospf_neighbour_header (struct vty *vty)
2998{
2999 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3000 VTY_NEWLINE,
3001 "Neighbor ID", "Pri", "State", "Dead Time",
3002 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3003 VTY_NEWLINE);
3004}
3005
3006static void
paul718e3742002-12-13 20:15:29 +00003007show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3008{
3009 struct route_node *rn;
3010 struct ospf_neighbor *nbr;
3011 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00003012 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003013
3014 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3015 if ((nbr = rn->info))
3016 /* Do not show myself. */
3017 if (nbr != oi->nbr_self)
3018 /* Down state is not shown. */
3019 if (nbr->state != NSM_Down)
3020 {
3021 ospf_nbr_state_message (nbr, msgbuf, 16);
3022
3023 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00003024 vty_out (vty, "%-15s %3d %-15s ",
3025 "-", nbr->priority,
3026 msgbuf);
3027 else
3028 vty_out (vty, "%-15s %3d %-15s ",
3029 inet_ntoa (nbr->router_id), nbr->priority,
3030 msgbuf);
3031
3032 vty_out (vty, "%9s ",
3033 ospf_timer_dump (nbr->t_inactivity, timebuf,
3034 sizeof(timebuf)));
3035
paul718e3742002-12-13 20:15:29 +00003036 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00003037 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00003038 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3039 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3040 VTY_NEWLINE);
3041 }
3042}
3043
3044DEFUN (show_ip_ospf_neighbor,
3045 show_ip_ospf_neighbor_cmd,
3046 "show ip ospf neighbor",
3047 SHOW_STR
3048 IP_STR
3049 "OSPF information\n"
3050 "Neighbor list\n")
3051{
paul020709f2003-04-04 02:44:16 +00003052 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003053 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003054 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003055
paul020709f2003-04-04 02:44:16 +00003056 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003057 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003058 {
3059 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3060 return CMD_SUCCESS;
3061 }
3062
pauld24f6e22005-10-21 09:23:12 +00003063 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003064
paul1eb8ef22005-04-07 07:30:20 +00003065 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3066 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003067
3068 return CMD_SUCCESS;
3069}
3070
3071DEFUN (show_ip_ospf_neighbor_all,
3072 show_ip_ospf_neighbor_all_cmd,
3073 "show ip ospf neighbor all",
3074 SHOW_STR
3075 IP_STR
3076 "OSPF information\n"
3077 "Neighbor list\n"
3078 "include down status neighbor\n")
3079{
Joakim Tjernlund35f89142008-07-01 16:54:07 +02003080 struct ospf *ospf = ospf_lookup ();
hasso52dc7ee2004-09-23 19:18:23 +00003081 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003082 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003083
paul68980082003-03-25 05:07:42 +00003084 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003085 {
3086 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3087 return CMD_SUCCESS;
3088 }
pauld24f6e22005-10-21 09:23:12 +00003089
3090 show_ip_ospf_neighbour_header (vty);
3091
paul1eb8ef22005-04-07 07:30:20 +00003092 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003093 {
hasso52dc7ee2004-09-23 19:18:23 +00003094 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003095 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003096
3097 show_ip_ospf_neighbor_sub (vty, oi);
3098
3099 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003100 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003101 {
paul718e3742002-12-13 20:15:29 +00003102 if (nbr_nbma->nbr == NULL
3103 || nbr_nbma->nbr->state == NSM_Down)
3104 {
pauld24f6e22005-10-21 09:23:12 +00003105 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003106 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003107 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003108 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3109 0, 0, 0, VTY_NEWLINE);
3110 }
3111 }
3112 }
3113
3114 return CMD_SUCCESS;
3115}
3116
3117DEFUN (show_ip_ospf_neighbor_int,
3118 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003119 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003120 SHOW_STR
3121 IP_STR
3122 "OSPF information\n"
3123 "Neighbor list\n"
3124 "Interface name\n")
3125{
paul020709f2003-04-04 02:44:16 +00003126 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003127 struct interface *ifp;
3128 struct route_node *rn;
3129
3130 ifp = if_lookup_by_name (argv[0]);
3131 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003132 {
hassobb5b7552005-08-21 20:01:15 +00003133 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003134 return CMD_WARNING;
3135 }
3136
paul020709f2003-04-04 02:44:16 +00003137 ospf = ospf_lookup ();
3138 if (ospf == NULL)
3139 {
3140 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3141 return CMD_SUCCESS;
3142 }
pauld24f6e22005-10-21 09:23:12 +00003143
3144 show_ip_ospf_neighbour_header (vty);
3145
hassobb5b7552005-08-21 20:01:15 +00003146 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003147 {
hassobb5b7552005-08-21 20:01:15 +00003148 struct ospf_interface *oi = rn->info;
3149
3150 if (oi == NULL)
3151 continue;
3152
paul718e3742002-12-13 20:15:29 +00003153 show_ip_ospf_neighbor_sub (vty, oi);
3154 }
3155
3156 return CMD_SUCCESS;
3157}
3158
paul4dadc292005-05-06 21:37:42 +00003159static void
paul718e3742002-12-13 20:15:29 +00003160show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3161 struct ospf_nbr_nbma *nbr_nbma)
3162{
ajs649654a2005-11-16 20:17:52 +00003163 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003164
3165 /* Show neighbor ID. */
3166 vty_out (vty, " Neighbor %s,", "-");
3167
3168 /* Show interface address. */
3169 vty_out (vty, " interface address %s%s",
3170 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3171 /* Show Area ID. */
3172 vty_out (vty, " In the area %s via interface %s%s",
3173 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3174 /* Show neighbor priority and state. */
3175 vty_out (vty, " Neighbor priority is %d, State is %s,",
3176 nbr_nbma->priority, "Down");
3177 /* Show state changes. */
3178 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3179
3180 /* Show PollInterval */
3181 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3182
3183 /* Show poll-interval timer. */
3184 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003185 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3186 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003187
3188 /* Show poll-interval timer thread. */
3189 vty_out (vty, " Thread Poll Timer %s%s",
3190 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3191}
3192
paul4dadc292005-05-06 21:37:42 +00003193static void
paul718e3742002-12-13 20:15:29 +00003194show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3195 struct ospf_neighbor *nbr)
3196{
ajs649654a2005-11-16 20:17:52 +00003197 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003198
3199 /* Show neighbor ID. */
3200 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3201 vty_out (vty, " Neighbor %s,", "-");
3202 else
3203 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3204
3205 /* Show interface address. */
3206 vty_out (vty, " interface address %s%s",
3207 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3208 /* Show Area ID. */
3209 vty_out (vty, " In the area %s via interface %s%s",
3210 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3211 /* Show neighbor priority and state. */
3212 vty_out (vty, " Neighbor priority is %d, State is %s,",
3213 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3214 /* Show state changes. */
3215 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
Paul Jakma3fed4162006-07-25 20:44:12 +00003216 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
Paul Jakma90c33172006-07-11 17:57:25 +00003217 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003218 struct timeval res
3219 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003220 vty_out (vty, " Most recent state change statistics:%s",
3221 VTY_NEWLINE);
3222 vty_out (vty, " Progressive change %s ago%s",
Paul Jakma90c33172006-07-11 17:57:25 +00003223 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
Paul Jakma3fed4162006-07-25 20:44:12 +00003224 VTY_NEWLINE);
3225 }
3226 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3227 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003228 struct timeval res
3229 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003230 vty_out (vty, " Regressive change %s ago, due to %s%s",
3231 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3232 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
Paul Jakma90c33172006-07-11 17:57:25 +00003233 VTY_NEWLINE);
3234 }
paul718e3742002-12-13 20:15:29 +00003235 /* Show Designated Rotuer ID. */
3236 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3237 /* Show Backup Designated Rotuer ID. */
3238 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3239 /* Show options. */
3240 vty_out (vty, " Options %d %s%s", nbr->options,
3241 ospf_options_dump (nbr->options), VTY_NEWLINE);
3242 /* Show Router Dead interval timer. */
3243 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003244 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3245 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003246 /* Show Database Summary list. */
3247 vty_out (vty, " Database Summary List %d%s",
3248 ospf_db_summary_count (nbr), VTY_NEWLINE);
3249 /* Show Link State Request list. */
3250 vty_out (vty, " Link State Request List %ld%s",
3251 ospf_ls_request_count (nbr), VTY_NEWLINE);
3252 /* Show Link State Retransmission list. */
3253 vty_out (vty, " Link State Retransmission List %ld%s",
3254 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3255 /* Show inactivity timer thread. */
3256 vty_out (vty, " Thread Inactivity Timer %s%s",
3257 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3258 /* Show Database Description retransmission thread. */
3259 vty_out (vty, " Thread Database Description Retransmision %s%s",
3260 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3261 /* Show Link State Request Retransmission thread. */
3262 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3263 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3264 /* Show Link State Update Retransmission thread. */
3265 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3266 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3267}
3268
3269DEFUN (show_ip_ospf_neighbor_id,
3270 show_ip_ospf_neighbor_id_cmd,
3271 "show ip ospf neighbor A.B.C.D",
3272 SHOW_STR
3273 IP_STR
3274 "OSPF information\n"
3275 "Neighbor list\n"
3276 "Neighbor ID\n")
3277{
paul020709f2003-04-04 02:44:16 +00003278 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003279 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003280 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003281 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003282 struct in_addr router_id;
3283 int ret;
3284
3285 ret = inet_aton (argv[0], &router_id);
3286 if (!ret)
3287 {
3288 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3289 return CMD_WARNING;
3290 }
3291
paul020709f2003-04-04 02:44:16 +00003292 ospf = ospf_lookup ();
3293 if (ospf == NULL)
3294 {
3295 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3296 return CMD_SUCCESS;
3297 }
3298
paul1eb8ef22005-04-07 07:30:20 +00003299 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3300 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003301 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003302
paul718e3742002-12-13 20:15:29 +00003303 return CMD_SUCCESS;
3304}
3305
3306DEFUN (show_ip_ospf_neighbor_detail,
3307 show_ip_ospf_neighbor_detail_cmd,
3308 "show ip ospf neighbor detail",
3309 SHOW_STR
3310 IP_STR
3311 "OSPF information\n"
3312 "Neighbor list\n"
3313 "detail of all neighbors\n")
3314{
paul020709f2003-04-04 02:44:16 +00003315 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003316 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003317 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003318
paul020709f2003-04-04 02:44:16 +00003319 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003320 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003321 {
3322 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3323 return CMD_SUCCESS;
3324 }
paul718e3742002-12-13 20:15:29 +00003325
paul1eb8ef22005-04-07 07:30:20 +00003326 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003327 {
paul718e3742002-12-13 20:15:29 +00003328 struct route_node *rn;
3329 struct ospf_neighbor *nbr;
3330
3331 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3332 if ((nbr = rn->info))
3333 if (nbr != oi->nbr_self)
3334 if (nbr->state != NSM_Down)
3335 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3336 }
3337
3338 return CMD_SUCCESS;
3339}
3340
3341DEFUN (show_ip_ospf_neighbor_detail_all,
3342 show_ip_ospf_neighbor_detail_all_cmd,
3343 "show ip ospf neighbor detail all",
3344 SHOW_STR
3345 IP_STR
3346 "OSPF information\n"
3347 "Neighbor list\n"
3348 "detail of all neighbors\n"
3349 "include down status neighbor\n")
3350{
paul020709f2003-04-04 02:44:16 +00003351 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003352 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003353 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003354
paul020709f2003-04-04 02:44:16 +00003355 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003356 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003357 {
3358 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3359 return CMD_SUCCESS;
3360 }
paul718e3742002-12-13 20:15:29 +00003361
paul1eb8ef22005-04-07 07:30:20 +00003362 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003363 {
paul718e3742002-12-13 20:15:29 +00003364 struct route_node *rn;
3365 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003366 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003367
3368 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3369 if ((nbr = rn->info))
3370 if (nbr != oi->nbr_self)
3371 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3372 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3373
3374 if (oi->type == OSPF_IFTYPE_NBMA)
3375 {
hasso52dc7ee2004-09-23 19:18:23 +00003376 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003377
paul1eb8ef22005-04-07 07:30:20 +00003378 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3379 if (nbr_nbma->nbr == NULL
3380 || nbr_nbma->nbr->state == NSM_Down)
3381 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003382 }
3383 }
3384
3385 return CMD_SUCCESS;
3386}
3387
3388DEFUN (show_ip_ospf_neighbor_int_detail,
3389 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003390 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003391 SHOW_STR
3392 IP_STR
3393 "OSPF information\n"
3394 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003395 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003396 "detail of all neighbors")
3397{
paul020709f2003-04-04 02:44:16 +00003398 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003399 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003400 struct interface *ifp;
3401 struct route_node *rn, *nrn;
3402 struct ospf_neighbor *nbr;
3403
3404 ifp = if_lookup_by_name (argv[0]);
3405 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003406 {
hassobb5b7552005-08-21 20:01:15 +00003407 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003408 return CMD_WARNING;
3409 }
3410
paul020709f2003-04-04 02:44:16 +00003411 ospf = ospf_lookup ();
3412 if (ospf == NULL)
3413 {
3414 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3415 return CMD_SUCCESS;
3416 }
paul68980082003-03-25 05:07:42 +00003417
paul718e3742002-12-13 20:15:29 +00003418
hassobb5b7552005-08-21 20:01:15 +00003419 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3420 if ((oi = rn->info))
3421 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3422 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003423 if (nbr != oi->nbr_self)
3424 if (nbr->state != NSM_Down)
3425 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003426
3427 return CMD_SUCCESS;
3428}
3429
3430
3431/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003432static int
paul020709f2003-04-04 02:44:16 +00003433show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003434{
paul718e3742002-12-13 20:15:29 +00003435 struct router_lsa *rl;
3436 struct summary_lsa *sl;
3437 struct as_external_lsa *asel;
3438 struct prefix_ipv4 p;
3439
3440 if (lsa != NULL)
3441 /* If self option is set, check LSA self flag. */
3442 if (self == 0 || IS_LSA_SELF (lsa))
3443 {
3444 /* LSA common part show. */
3445 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3446 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3447 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3448 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3449 /* LSA specific part show. */
3450 switch (lsa->data->type)
3451 {
3452 case OSPF_ROUTER_LSA:
3453 rl = (struct router_lsa *) lsa->data;
3454 vty_out (vty, " %-d", ntohs (rl->links));
3455 break;
3456 case OSPF_SUMMARY_LSA:
3457 sl = (struct summary_lsa *) lsa->data;
3458
3459 p.family = AF_INET;
3460 p.prefix = sl->header.id;
3461 p.prefixlen = ip_masklen (sl->mask);
3462 apply_mask_ipv4 (&p);
3463
3464 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3465 break;
3466 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003467 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003468 asel = (struct as_external_lsa *) lsa->data;
3469
3470 p.family = AF_INET;
3471 p.prefix = asel->header.id;
3472 p.prefixlen = ip_masklen (asel->mask);
3473 apply_mask_ipv4 (&p);
3474
3475 vty_out (vty, " %s %s/%d [0x%lx]",
3476 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3477 inet_ntoa (p.prefix), p.prefixlen,
3478 (u_long)ntohl (asel->e[0].route_tag));
3479 break;
3480 case OSPF_NETWORK_LSA:
3481 case OSPF_ASBR_SUMMARY_LSA:
3482#ifdef HAVE_OPAQUE_LSA
3483 case OSPF_OPAQUE_LINK_LSA:
3484 case OSPF_OPAQUE_AREA_LSA:
3485 case OSPF_OPAQUE_AS_LSA:
3486#endif /* HAVE_OPAQUE_LSA */
3487 default:
3488 break;
3489 }
3490 vty_out (vty, VTY_NEWLINE);
3491 }
3492
3493 return 0;
3494}
3495
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003496static const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003497{
3498 "unknown",
3499 "Router Link States",
3500 "Net Link States",
3501 "Summary Link States",
3502 "ASBR-Summary Link States",
3503 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003504 "Group Membership LSA",
3505 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003506#ifdef HAVE_OPAQUE_LSA
3507 "Type-8 LSA",
3508 "Link-Local Opaque-LSA",
3509 "Area-Local Opaque-LSA",
3510 "AS-external Opaque-LSA",
3511#endif /* HAVE_OPAQUE_LSA */
3512};
3513
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003514static const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003515{
3516 "",
3517 "Link ID ADV Router Age Seq# CkSum Link count",
3518 "Link ID ADV Router Age Seq# CkSum",
3519 "Link ID ADV Router Age Seq# CkSum Route",
3520 "Link ID ADV Router Age Seq# CkSum",
3521 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003522 " --- header for Group Member ----",
3523 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003524#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003525 " --- type-8 ---",
3526 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3527 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3528 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3529#endif /* HAVE_OPAQUE_LSA */
3530};
3531
paul4dadc292005-05-06 21:37:42 +00003532static void
paul718e3742002-12-13 20:15:29 +00003533show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3534{
3535 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003536
paul718e3742002-12-13 20:15:29 +00003537 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003538 vty_out (vty, " Options: 0x%-2x : %s%s",
3539 lsa->data->options,
3540 ospf_options_dump(lsa->data->options),
3541 VTY_NEWLINE);
3542 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003543 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003544 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3545 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003546
3547 if (lsa->data->type == OSPF_ROUTER_LSA)
3548 {
3549 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3550
3551 if (rlsa->flags)
3552 vty_out (vty, " :%s%s%s%s",
3553 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3554 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3555 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3556 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3557
3558 vty_out (vty, "%s", VTY_NEWLINE);
3559 }
3560 vty_out (vty, " LS Type: %s%s",
3561 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3562 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3563 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3564 vty_out (vty, " Advertising Router: %s%s",
3565 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3566 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3567 VTY_NEWLINE);
3568 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3569 VTY_NEWLINE);
3570 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3571}
3572
hassoeb1ce602004-10-08 08:17:22 +00003573const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003574{
3575 "(null)",
3576 "another Router (point-to-point)",
3577 "a Transit Network",
3578 "Stub Network",
3579 "a Virtual Link",
3580};
3581
hassoeb1ce602004-10-08 08:17:22 +00003582const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003583{
3584 "(null)",
3585 "Neighboring Router ID",
3586 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003587 "Net",
paul718e3742002-12-13 20:15:29 +00003588 "Neighboring Router ID",
3589};
3590
hassoeb1ce602004-10-08 08:17:22 +00003591const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003592{
3593 "(null)",
3594 "Router Interface address",
3595 "Router Interface address",
3596 "Network Mask",
3597 "Router Interface address",
3598};
3599
3600/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003601static void
paul718e3742002-12-13 20:15:29 +00003602show_ip_ospf_database_router_links (struct vty *vty,
3603 struct router_lsa *rl)
3604{
3605 int len, i, type;
3606
3607 len = ntohs (rl->header.length) - 4;
3608 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3609 {
3610 type = rl->link[i].type;
3611
3612 vty_out (vty, " Link connected to: %s%s",
3613 link_type_desc[type], VTY_NEWLINE);
3614 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3615 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3616 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3617 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3618 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3619 vty_out (vty, " TOS 0 Metric: %d%s",
3620 ntohs (rl->link[i].metric), VTY_NEWLINE);
3621 vty_out (vty, "%s", VTY_NEWLINE);
3622 }
3623}
3624
3625/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003626static int
paul718e3742002-12-13 20:15:29 +00003627show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3628{
3629 if (lsa != NULL)
3630 {
3631 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3632
3633 show_ip_ospf_database_header (vty, lsa);
3634
3635 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3636 VTY_NEWLINE, VTY_NEWLINE);
3637
3638 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003639 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003640 }
3641
3642 return 0;
3643}
3644
3645/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003646static int
paul718e3742002-12-13 20:15:29 +00003647show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3648{
3649 int length, i;
3650
3651 if (lsa != NULL)
3652 {
3653 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3654
3655 show_ip_ospf_database_header (vty, lsa);
3656
3657 vty_out (vty, " Network Mask: /%d%s",
3658 ip_masklen (nl->mask), VTY_NEWLINE);
3659
3660 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3661
3662 for (i = 0; length > 0; i++, length -= 4)
3663 vty_out (vty, " Attached Router: %s%s",
3664 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3665
3666 vty_out (vty, "%s", VTY_NEWLINE);
3667 }
3668
3669 return 0;
3670}
3671
3672/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003673static int
paul718e3742002-12-13 20:15:29 +00003674show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3675{
3676 if (lsa != NULL)
3677 {
3678 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3679
3680 show_ip_ospf_database_header (vty, lsa);
3681
3682 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3683 VTY_NEWLINE);
3684 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3685 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003686 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003687 }
3688
3689 return 0;
3690}
3691
3692/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003693static int
paul718e3742002-12-13 20:15:29 +00003694show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3695{
3696 if (lsa != NULL)
3697 {
3698 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3699
3700 show_ip_ospf_database_header (vty, lsa);
3701
3702 vty_out (vty, " Network Mask: /%d%s",
3703 ip_masklen (sl->mask), VTY_NEWLINE);
3704 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3705 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003706 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003707 }
3708
3709 return 0;
3710}
3711
3712/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003713static int
paul718e3742002-12-13 20:15:29 +00003714show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3715{
3716 if (lsa != NULL)
3717 {
3718 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3719
3720 show_ip_ospf_database_header (vty, lsa);
3721
3722 vty_out (vty, " Network Mask: /%d%s",
3723 ip_masklen (al->mask), VTY_NEWLINE);
3724 vty_out (vty, " Metric Type: %s%s",
3725 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3726 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3727 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3728 vty_out (vty, " Metric: %d%s",
3729 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3730 vty_out (vty, " Forward Address: %s%s",
3731 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3732
3733 vty_out (vty, " External Route Tag: %lu%s%s",
3734 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3735 }
3736
3737 return 0;
3738}
3739
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003740#if 0
paul4dadc292005-05-06 21:37:42 +00003741static int
paul718e3742002-12-13 20:15:29 +00003742show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3743{
3744 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3745
3746 /* show_ip_ospf_database_header (vty, lsa); */
3747
ajs2a42e282004-12-08 18:43:03 +00003748 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003749 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003750 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003751 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3752 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003753 zlog_debug( " TOS: 0%s", "\n");
3754 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003755 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003756 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003757 inet_ntoa (al->e[0].fwd_addr), "\n");
3758
ajs2a42e282004-12-08 18:43:03 +00003759 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003760 ntohl (al->e[0].route_tag), "\n", "\n");
3761
3762 return 0;
3763}
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003764#endif
paul718e3742002-12-13 20:15:29 +00003765
3766/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003767static int
paul718e3742002-12-13 20:15:29 +00003768show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3769{
3770 if (lsa != NULL)
3771 {
3772 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3773
3774 show_ip_ospf_database_header (vty, lsa);
3775
3776 vty_out (vty, " Network Mask: /%d%s",
3777 ip_masklen (al->mask), VTY_NEWLINE);
3778 vty_out (vty, " Metric Type: %s%s",
3779 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3780 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3781 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3782 vty_out (vty, " Metric: %d%s",
3783 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3784 vty_out (vty, " NSSA: Forward Address: %s%s",
3785 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3786
3787 vty_out (vty, " External Route Tag: %u%s%s",
3788 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3789 }
3790
3791 return 0;
3792}
3793
paul4dadc292005-05-06 21:37:42 +00003794static int
paul718e3742002-12-13 20:15:29 +00003795show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3796{
3797 return 0;
3798}
3799
3800#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003801static int
paul718e3742002-12-13 20:15:29 +00003802show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3803{
3804 if (lsa != NULL)
3805 {
3806 show_ip_ospf_database_header (vty, lsa);
3807 show_opaque_info_detail (vty, lsa);
3808
3809 vty_out (vty, "%s", VTY_NEWLINE);
3810 }
3811 return 0;
3812}
3813#endif /* HAVE_OPAQUE_LSA */
3814
3815int (*show_function[])(struct vty *, struct ospf_lsa *) =
3816{
3817 NULL,
3818 show_router_lsa_detail,
3819 show_network_lsa_detail,
3820 show_summary_lsa_detail,
3821 show_summary_asbr_lsa_detail,
3822 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003823 show_func_dummy,
3824 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003825#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003826 NULL, /* type-8 */
3827 show_opaque_lsa_detail,
3828 show_opaque_lsa_detail,
3829 show_opaque_lsa_detail,
3830#endif /* HAVE_OPAQUE_LSA */
3831};
3832
paul4dadc292005-05-06 21:37:42 +00003833static void
paul718e3742002-12-13 20:15:29 +00003834show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3835 struct in_addr *adv_router)
3836{
3837 memset (lp, 0, sizeof (struct prefix_ls));
3838 lp->family = 0;
3839 if (id == NULL)
3840 lp->prefixlen = 0;
3841 else if (adv_router == NULL)
3842 {
3843 lp->prefixlen = 32;
3844 lp->id = *id;
3845 }
3846 else
3847 {
3848 lp->prefixlen = 64;
3849 lp->id = *id;
3850 lp->adv_router = *adv_router;
3851 }
3852}
3853
paul4dadc292005-05-06 21:37:42 +00003854static void
paul718e3742002-12-13 20:15:29 +00003855show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3856 struct in_addr *id, struct in_addr *adv_router)
3857{
3858 struct prefix_ls lp;
3859 struct route_node *rn, *start;
3860 struct ospf_lsa *lsa;
3861
3862 show_lsa_prefix_set (vty, &lp, id, adv_router);
3863 start = route_node_get (rt, (struct prefix *) &lp);
3864 if (start)
3865 {
3866 route_lock_node (start);
3867 for (rn = start; rn; rn = route_next_until (rn, start))
3868 if ((lsa = rn->info))
3869 {
paul718e3742002-12-13 20:15:29 +00003870 if (show_function[lsa->data->type] != NULL)
3871 show_function[lsa->data->type] (vty, lsa);
3872 }
3873 route_unlock_node (start);
3874 }
3875}
3876
3877/* Show detail LSA information
3878 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003879static void
paul020709f2003-04-04 02:44:16 +00003880show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003881 struct in_addr *id, struct in_addr *adv_router)
3882{
hasso52dc7ee2004-09-23 19:18:23 +00003883 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003884 struct ospf_area *area;
3885
paul718e3742002-12-13 20:15:29 +00003886 switch (type)
3887 {
3888 case OSPF_AS_EXTERNAL_LSA:
3889#ifdef HAVE_OPAQUE_LSA
3890 case OSPF_OPAQUE_AS_LSA:
3891#endif /* HAVE_OPAQUE_LSA */
3892 vty_out (vty, " %s %s%s",
3893 show_database_desc[type],
3894 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003895 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003896 break;
3897 default:
paul1eb8ef22005-04-07 07:30:20 +00003898 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003899 {
paul718e3742002-12-13 20:15:29 +00003900 vty_out (vty, "%s %s (Area %s)%s%s",
3901 VTY_NEWLINE, show_database_desc[type],
3902 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3903 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3904 }
3905 break;
3906 }
3907}
3908
paul4dadc292005-05-06 21:37:42 +00003909static void
paul718e3742002-12-13 20:15:29 +00003910show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3911 struct in_addr *adv_router)
3912{
3913 struct route_node *rn;
3914 struct ospf_lsa *lsa;
3915
3916 for (rn = route_top (rt); rn; rn = route_next (rn))
3917 if ((lsa = rn->info))
3918 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3919 {
paul718e3742002-12-13 20:15:29 +00003920 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3921 continue;
paul718e3742002-12-13 20:15:29 +00003922 if (show_function[lsa->data->type] != NULL)
3923 show_function[lsa->data->type] (vty, lsa);
3924 }
3925}
3926
3927/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003928static void
paul020709f2003-04-04 02:44:16 +00003929show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003930 struct in_addr *adv_router)
3931{
hasso52dc7ee2004-09-23 19:18:23 +00003932 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003933 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003934
3935 switch (type)
3936 {
3937 case OSPF_AS_EXTERNAL_LSA:
3938#ifdef HAVE_OPAQUE_LSA
3939 case OSPF_OPAQUE_AS_LSA:
3940#endif /* HAVE_OPAQUE_LSA */
3941 vty_out (vty, " %s %s%s",
3942 show_database_desc[type],
3943 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003944 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003945 adv_router);
3946 break;
3947 default:
paul1eb8ef22005-04-07 07:30:20 +00003948 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003949 {
paul718e3742002-12-13 20:15:29 +00003950 vty_out (vty, "%s %s (Area %s)%s%s",
3951 VTY_NEWLINE, show_database_desc[type],
3952 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3953 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3954 adv_router);
3955 }
3956 break;
3957 }
3958}
3959
paul4dadc292005-05-06 21:37:42 +00003960static void
paul020709f2003-04-04 02:44:16 +00003961show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003962{
paul020709f2003-04-04 02:44:16 +00003963 struct ospf_lsa *lsa;
3964 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003965 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003966 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003967 int type;
3968
paul1eb8ef22005-04-07 07:30:20 +00003969 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003970 {
paul718e3742002-12-13 20:15:29 +00003971 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3972 {
3973 switch (type)
3974 {
3975 case OSPF_AS_EXTERNAL_LSA:
3976#ifdef HAVE_OPAQUE_LSA
3977 case OSPF_OPAQUE_AS_LSA:
3978#endif /* HAVE_OPAQUE_LSA */
3979 continue;
3980 default:
3981 break;
3982 }
3983 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3984 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3985 {
3986 vty_out (vty, " %s (Area %s)%s%s",
3987 show_database_desc[type],
3988 ospf_area_desc_string (area),
3989 VTY_NEWLINE, VTY_NEWLINE);
3990 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3991
paul020709f2003-04-04 02:44:16 +00003992 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3993 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003994
3995 vty_out (vty, "%s", VTY_NEWLINE);
3996 }
3997 }
3998 }
3999
4000 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4001 {
4002 switch (type)
4003 {
4004 case OSPF_AS_EXTERNAL_LSA:
4005#ifdef HAVE_OPAQUE_LSA
4006 case OSPF_OPAQUE_AS_LSA:
4007#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00004008 break;
paul718e3742002-12-13 20:15:29 +00004009 default:
4010 continue;
4011 }
paul68980082003-03-25 05:07:42 +00004012 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4013 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00004014 {
4015 vty_out (vty, " %s%s%s",
4016 show_database_desc[type],
4017 VTY_NEWLINE, VTY_NEWLINE);
4018 vty_out (vty, "%s%s", show_database_header[type],
4019 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00004020
4021 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4022 show_lsa_summary (vty, lsa, self);
4023
paul718e3742002-12-13 20:15:29 +00004024 vty_out (vty, "%s", VTY_NEWLINE);
4025 }
4026 }
4027
4028 vty_out (vty, "%s", VTY_NEWLINE);
4029}
4030
paul4dadc292005-05-06 21:37:42 +00004031static void
paul020709f2003-04-04 02:44:16 +00004032show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00004033{
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004034 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00004035 struct ospf_lsa *lsa;
4036
4037 vty_out (vty, "%s MaxAge Link States:%s%s",
4038 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4039
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004040 for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
paul1eb8ef22005-04-07 07:30:20 +00004041 {
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004042 struct ospf_lsa *lsa;
4043
4044 if ((lsa = rn->info) != NULL)
4045 {
4046 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4047 vty_out (vty, "Link State ID: %s%s",
4048 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4049 vty_out (vty, "Advertising Router: %s%s",
4050 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4051 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4052 vty_out (vty, "%s", VTY_NEWLINE);
4053 }
paul1eb8ef22005-04-07 07:30:20 +00004054 }
paul718e3742002-12-13 20:15:29 +00004055}
4056
paul718e3742002-12-13 20:15:29 +00004057#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4058#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00004059
4060#ifdef HAVE_OPAQUE_LSA
4061#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4062#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4063#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4064#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4065#else /* HAVE_OPAQUE_LSA */
4066#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4067#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4068#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4069#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4070#endif /* HAVE_OPAQUE_LSA */
4071
4072#define OSPF_LSA_TYPES_CMD_STR \
4073 "asbr-summary|external|network|router|summary" \
4074 OSPF_LSA_TYPE_NSSA_CMD_STR \
4075 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4076
4077#define OSPF_LSA_TYPES_DESC \
4078 "ASBR summary link states\n" \
4079 "External link states\n" \
4080 "Network link states\n" \
4081 "Router link states\n" \
4082 "Network summary link states\n" \
4083 OSPF_LSA_TYPE_NSSA_DESC \
4084 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4085 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4086 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4087
4088DEFUN (show_ip_ospf_database,
4089 show_ip_ospf_database_cmd,
4090 "show ip ospf database",
4091 SHOW_STR
4092 IP_STR
4093 "OSPF information\n"
4094 "Database summary\n")
4095{
paul020709f2003-04-04 02:44:16 +00004096 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004097 int type, ret;
4098 struct in_addr id, adv_router;
4099
paul020709f2003-04-04 02:44:16 +00004100 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004101 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004102 {
4103 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4104 return CMD_SUCCESS;
4105 }
paul718e3742002-12-13 20:15:29 +00004106
4107 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004108 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004109
4110 /* Show all LSA. */
4111 if (argc == 0)
4112 {
paul020709f2003-04-04 02:44:16 +00004113 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004114 return CMD_SUCCESS;
4115 }
4116
4117 /* Set database type to show. */
4118 if (strncmp (argv[0], "r", 1) == 0)
4119 type = OSPF_ROUTER_LSA;
4120 else if (strncmp (argv[0], "ne", 2) == 0)
4121 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004122 else if (strncmp (argv[0], "ns", 2) == 0)
4123 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004124 else if (strncmp (argv[0], "su", 2) == 0)
4125 type = OSPF_SUMMARY_LSA;
4126 else if (strncmp (argv[0], "a", 1) == 0)
4127 type = OSPF_ASBR_SUMMARY_LSA;
4128 else if (strncmp (argv[0], "e", 1) == 0)
4129 type = OSPF_AS_EXTERNAL_LSA;
4130 else if (strncmp (argv[0], "se", 2) == 0)
4131 {
paul020709f2003-04-04 02:44:16 +00004132 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004133 return CMD_SUCCESS;
4134 }
4135 else if (strncmp (argv[0], "m", 1) == 0)
4136 {
paul020709f2003-04-04 02:44:16 +00004137 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004138 return CMD_SUCCESS;
4139 }
4140#ifdef HAVE_OPAQUE_LSA
4141 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4142 type = OSPF_OPAQUE_LINK_LSA;
4143 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4144 type = OSPF_OPAQUE_AREA_LSA;
4145 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4146 type = OSPF_OPAQUE_AS_LSA;
4147#endif /* HAVE_OPAQUE_LSA */
4148 else
4149 return CMD_WARNING;
4150
4151 /* `show ip ospf database LSA'. */
4152 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004153 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004154 else if (argc >= 2)
4155 {
4156 ret = inet_aton (argv[1], &id);
4157 if (!ret)
4158 return CMD_WARNING;
4159
4160 /* `show ip ospf database LSA ID'. */
4161 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004162 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004163 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4164 else if (argc == 3)
4165 {
4166 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004167 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004168 else
4169 {
4170 ret = inet_aton (argv[2], &adv_router);
4171 if (!ret)
4172 return CMD_WARNING;
4173 }
paul020709f2003-04-04 02:44:16 +00004174 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004175 }
4176 }
4177
4178 return CMD_SUCCESS;
4179}
4180
4181ALIAS (show_ip_ospf_database,
4182 show_ip_ospf_database_type_cmd,
4183 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4184 SHOW_STR
4185 IP_STR
4186 "OSPF information\n"
4187 "Database summary\n"
4188 OSPF_LSA_TYPES_DESC
4189 "LSAs in MaxAge list\n"
4190 "Self-originated link states\n")
4191
4192ALIAS (show_ip_ospf_database,
4193 show_ip_ospf_database_type_id_cmd,
4194 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4195 SHOW_STR
4196 IP_STR
4197 "OSPF information\n"
4198 "Database summary\n"
4199 OSPF_LSA_TYPES_DESC
4200 "Link State ID (as an IP address)\n")
4201
4202ALIAS (show_ip_ospf_database,
4203 show_ip_ospf_database_type_id_adv_router_cmd,
4204 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4205 SHOW_STR
4206 IP_STR
4207 "OSPF information\n"
4208 "Database summary\n"
4209 OSPF_LSA_TYPES_DESC
4210 "Link State ID (as an IP address)\n"
4211 "Advertising Router link states\n"
4212 "Advertising Router (as an IP address)\n")
4213
4214ALIAS (show_ip_ospf_database,
4215 show_ip_ospf_database_type_id_self_cmd,
4216 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4217 SHOW_STR
4218 IP_STR
4219 "OSPF information\n"
4220 "Database summary\n"
4221 OSPF_LSA_TYPES_DESC
4222 "Link State ID (as an IP address)\n"
4223 "Self-originated link states\n"
4224 "\n")
4225
4226DEFUN (show_ip_ospf_database_type_adv_router,
4227 show_ip_ospf_database_type_adv_router_cmd,
4228 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4229 SHOW_STR
4230 IP_STR
4231 "OSPF information\n"
4232 "Database summary\n"
4233 OSPF_LSA_TYPES_DESC
4234 "Advertising Router link states\n"
4235 "Advertising Router (as an IP address)\n")
4236{
paul020709f2003-04-04 02:44:16 +00004237 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004238 int type, ret;
4239 struct in_addr adv_router;
4240
paul020709f2003-04-04 02:44:16 +00004241 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004242 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004243 {
4244 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4245 return CMD_SUCCESS;
4246 }
paul718e3742002-12-13 20:15:29 +00004247
4248 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004249 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004250
4251 if (argc != 2)
4252 return CMD_WARNING;
4253
4254 /* Set database type to show. */
4255 if (strncmp (argv[0], "r", 1) == 0)
4256 type = OSPF_ROUTER_LSA;
4257 else if (strncmp (argv[0], "ne", 2) == 0)
4258 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004259 else if (strncmp (argv[0], "ns", 2) == 0)
4260 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004261 else if (strncmp (argv[0], "s", 1) == 0)
4262 type = OSPF_SUMMARY_LSA;
4263 else if (strncmp (argv[0], "a", 1) == 0)
4264 type = OSPF_ASBR_SUMMARY_LSA;
4265 else if (strncmp (argv[0], "e", 1) == 0)
4266 type = OSPF_AS_EXTERNAL_LSA;
4267#ifdef HAVE_OPAQUE_LSA
4268 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4269 type = OSPF_OPAQUE_LINK_LSA;
4270 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4271 type = OSPF_OPAQUE_AREA_LSA;
4272 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4273 type = OSPF_OPAQUE_AS_LSA;
4274#endif /* HAVE_OPAQUE_LSA */
4275 else
4276 return CMD_WARNING;
4277
4278 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4279 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004280 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004281 else
4282 {
4283 ret = inet_aton (argv[1], &adv_router);
4284 if (!ret)
4285 return CMD_WARNING;
4286 }
4287
paul020709f2003-04-04 02:44:16 +00004288 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004289
4290 return CMD_SUCCESS;
4291}
4292
4293ALIAS (show_ip_ospf_database_type_adv_router,
4294 show_ip_ospf_database_type_self_cmd,
4295 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4296 SHOW_STR
4297 IP_STR
4298 "OSPF information\n"
4299 "Database summary\n"
4300 OSPF_LSA_TYPES_DESC
4301 "Self-originated link states\n")
4302
4303
4304DEFUN (ip_ospf_authentication_args,
4305 ip_ospf_authentication_args_addr_cmd,
4306 "ip ospf authentication (null|message-digest) A.B.C.D",
4307 "IP Information\n"
4308 "OSPF interface commands\n"
4309 "Enable authentication on this interface\n"
4310 "Use null authentication\n"
4311 "Use message-digest authentication\n"
4312 "Address of interface")
4313{
4314 struct interface *ifp;
4315 struct in_addr addr;
4316 int ret;
4317 struct ospf_if_params *params;
4318
4319 ifp = vty->index;
4320 params = IF_DEF_PARAMS (ifp);
4321
4322 if (argc == 2)
4323 {
4324 ret = inet_aton(argv[1], &addr);
4325 if (!ret)
4326 {
4327 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4328 VTY_NEWLINE);
4329 return CMD_WARNING;
4330 }
4331
4332 params = ospf_get_if_params (ifp, addr);
4333 ospf_if_update_params (ifp, addr);
4334 }
4335
4336 /* Handle null authentication */
4337 if ( argv[0][0] == 'n' )
4338 {
4339 SET_IF_PARAM (params, auth_type);
4340 params->auth_type = OSPF_AUTH_NULL;
4341 return CMD_SUCCESS;
4342 }
4343
4344 /* Handle message-digest authentication */
4345 if ( argv[0][0] == 'm' )
4346 {
4347 SET_IF_PARAM (params, auth_type);
4348 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4349 return CMD_SUCCESS;
4350 }
4351
4352 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4353 return CMD_WARNING;
4354}
4355
4356ALIAS (ip_ospf_authentication_args,
4357 ip_ospf_authentication_args_cmd,
4358 "ip ospf authentication (null|message-digest)",
4359 "IP Information\n"
4360 "OSPF interface commands\n"
4361 "Enable authentication on this interface\n"
4362 "Use null authentication\n"
4363 "Use message-digest authentication\n")
4364
4365DEFUN (ip_ospf_authentication,
4366 ip_ospf_authentication_addr_cmd,
4367 "ip ospf authentication A.B.C.D",
4368 "IP Information\n"
4369 "OSPF interface commands\n"
4370 "Enable authentication on this interface\n"
4371 "Address of interface")
4372{
4373 struct interface *ifp;
4374 struct in_addr addr;
4375 int ret;
4376 struct ospf_if_params *params;
4377
4378 ifp = vty->index;
4379 params = IF_DEF_PARAMS (ifp);
4380
4381 if (argc == 1)
4382 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004383 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004384 if (!ret)
4385 {
4386 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4387 VTY_NEWLINE);
4388 return CMD_WARNING;
4389 }
4390
4391 params = ospf_get_if_params (ifp, addr);
4392 ospf_if_update_params (ifp, addr);
4393 }
4394
4395 SET_IF_PARAM (params, auth_type);
4396 params->auth_type = OSPF_AUTH_SIMPLE;
4397
4398 return CMD_SUCCESS;
4399}
4400
4401ALIAS (ip_ospf_authentication,
4402 ip_ospf_authentication_cmd,
4403 "ip ospf authentication",
4404 "IP Information\n"
4405 "OSPF interface commands\n"
4406 "Enable authentication on this interface\n")
4407
4408DEFUN (no_ip_ospf_authentication,
4409 no_ip_ospf_authentication_addr_cmd,
4410 "no ip ospf authentication A.B.C.D",
4411 NO_STR
4412 "IP Information\n"
4413 "OSPF interface commands\n"
4414 "Enable authentication on this interface\n"
4415 "Address of interface")
4416{
4417 struct interface *ifp;
4418 struct in_addr addr;
4419 int ret;
4420 struct ospf_if_params *params;
4421
4422 ifp = vty->index;
4423 params = IF_DEF_PARAMS (ifp);
4424
4425 if (argc == 1)
4426 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004427 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004428 if (!ret)
4429 {
4430 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4431 VTY_NEWLINE);
4432 return CMD_WARNING;
4433 }
4434
4435 params = ospf_lookup_if_params (ifp, addr);
4436 if (params == NULL)
4437 return CMD_SUCCESS;
4438 }
4439
4440 params->auth_type = OSPF_AUTH_NOTSET;
4441 UNSET_IF_PARAM (params, auth_type);
4442
4443 if (params != IF_DEF_PARAMS (ifp))
4444 {
4445 ospf_free_if_params (ifp, addr);
4446 ospf_if_update_params (ifp, addr);
4447 }
4448
4449 return CMD_SUCCESS;
4450}
4451
4452ALIAS (no_ip_ospf_authentication,
4453 no_ip_ospf_authentication_cmd,
4454 "no ip ospf authentication",
4455 NO_STR
4456 "IP Information\n"
4457 "OSPF interface commands\n"
4458 "Enable authentication on this interface\n")
4459
4460DEFUN (ip_ospf_authentication_key,
4461 ip_ospf_authentication_key_addr_cmd,
4462 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4463 "IP Information\n"
4464 "OSPF interface commands\n"
4465 "Authentication password (key)\n"
4466 "The OSPF password (key)\n"
4467 "Address of interface")
4468{
4469 struct interface *ifp;
4470 struct in_addr addr;
4471 int ret;
4472 struct ospf_if_params *params;
4473
4474 ifp = vty->index;
4475 params = IF_DEF_PARAMS (ifp);
4476
4477 if (argc == 2)
4478 {
4479 ret = inet_aton(argv[1], &addr);
4480 if (!ret)
4481 {
4482 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4483 VTY_NEWLINE);
4484 return CMD_WARNING;
4485 }
4486
4487 params = ospf_get_if_params (ifp, addr);
4488 ospf_if_update_params (ifp, addr);
4489 }
4490
4491
4492 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004493 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004494 SET_IF_PARAM (params, auth_simple);
4495
4496 return CMD_SUCCESS;
4497}
4498
4499ALIAS (ip_ospf_authentication_key,
4500 ip_ospf_authentication_key_cmd,
4501 "ip ospf authentication-key AUTH_KEY",
4502 "IP Information\n"
4503 "OSPF interface commands\n"
4504 "Authentication password (key)\n"
4505 "The OSPF password (key)")
4506
4507ALIAS (ip_ospf_authentication_key,
4508 ospf_authentication_key_cmd,
4509 "ospf authentication-key AUTH_KEY",
4510 "OSPF interface commands\n"
4511 "Authentication password (key)\n"
4512 "The OSPF password (key)")
4513
4514DEFUN (no_ip_ospf_authentication_key,
4515 no_ip_ospf_authentication_key_addr_cmd,
4516 "no ip ospf authentication-key A.B.C.D",
4517 NO_STR
4518 "IP Information\n"
4519 "OSPF interface commands\n"
4520 "Authentication password (key)\n"
4521 "Address of interface")
4522{
4523 struct interface *ifp;
4524 struct in_addr addr;
4525 int ret;
4526 struct ospf_if_params *params;
4527
4528 ifp = vty->index;
4529 params = IF_DEF_PARAMS (ifp);
4530
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004531 if (argc == 1)
paul718e3742002-12-13 20:15:29 +00004532 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004533 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004534 if (!ret)
4535 {
4536 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4537 VTY_NEWLINE);
4538 return CMD_WARNING;
4539 }
4540
4541 params = ospf_lookup_if_params (ifp, addr);
4542 if (params == NULL)
4543 return CMD_SUCCESS;
4544 }
4545
4546 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4547 UNSET_IF_PARAM (params, auth_simple);
4548
4549 if (params != IF_DEF_PARAMS (ifp))
4550 {
4551 ospf_free_if_params (ifp, addr);
4552 ospf_if_update_params (ifp, addr);
4553 }
4554
4555 return CMD_SUCCESS;
4556}
4557
4558ALIAS (no_ip_ospf_authentication_key,
4559 no_ip_ospf_authentication_key_cmd,
4560 "no ip ospf authentication-key",
4561 NO_STR
4562 "IP Information\n"
4563 "OSPF interface commands\n"
4564 "Authentication password (key)\n")
4565
4566ALIAS (no_ip_ospf_authentication_key,
4567 no_ospf_authentication_key_cmd,
4568 "no ospf authentication-key",
4569 NO_STR
4570 "OSPF interface commands\n"
4571 "Authentication password (key)\n")
4572
4573DEFUN (ip_ospf_message_digest_key,
4574 ip_ospf_message_digest_key_addr_cmd,
4575 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4576 "IP Information\n"
4577 "OSPF interface commands\n"
4578 "Message digest authentication password (key)\n"
4579 "Key ID\n"
4580 "Use MD5 algorithm\n"
4581 "The OSPF password (key)"
4582 "Address of interface")
4583{
4584 struct interface *ifp;
4585 struct crypt_key *ck;
4586 u_char key_id;
4587 struct in_addr addr;
4588 int ret;
4589 struct ospf_if_params *params;
4590
4591 ifp = vty->index;
4592 params = IF_DEF_PARAMS (ifp);
4593
4594 if (argc == 3)
4595 {
4596 ret = inet_aton(argv[2], &addr);
4597 if (!ret)
4598 {
4599 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4600 VTY_NEWLINE);
4601 return CMD_WARNING;
4602 }
4603
4604 params = ospf_get_if_params (ifp, addr);
4605 ospf_if_update_params (ifp, addr);
4606 }
4607
4608 key_id = strtol (argv[0], NULL, 10);
4609 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4610 {
4611 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4612 return CMD_WARNING;
4613 }
4614
4615 ck = ospf_crypt_key_new ();
4616 ck->key_id = (u_char) key_id;
4617 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004618 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004619
4620 ospf_crypt_key_add (params->auth_crypt, ck);
4621 SET_IF_PARAM (params, auth_crypt);
4622
4623 return CMD_SUCCESS;
4624}
4625
4626ALIAS (ip_ospf_message_digest_key,
4627 ip_ospf_message_digest_key_cmd,
4628 "ip ospf message-digest-key <1-255> md5 KEY",
4629 "IP Information\n"
4630 "OSPF interface commands\n"
4631 "Message digest authentication password (key)\n"
4632 "Key ID\n"
4633 "Use MD5 algorithm\n"
4634 "The OSPF password (key)")
4635
4636ALIAS (ip_ospf_message_digest_key,
4637 ospf_message_digest_key_cmd,
4638 "ospf message-digest-key <1-255> md5 KEY",
4639 "OSPF interface commands\n"
4640 "Message digest authentication password (key)\n"
4641 "Key ID\n"
4642 "Use MD5 algorithm\n"
4643 "The OSPF password (key)")
4644
4645DEFUN (no_ip_ospf_message_digest_key,
4646 no_ip_ospf_message_digest_key_addr_cmd,
4647 "no ip ospf message-digest-key <1-255> A.B.C.D",
4648 NO_STR
4649 "IP Information\n"
4650 "OSPF interface commands\n"
4651 "Message digest authentication password (key)\n"
4652 "Key ID\n"
4653 "Address of interface")
4654{
4655 struct interface *ifp;
4656 struct crypt_key *ck;
4657 int key_id;
4658 struct in_addr addr;
4659 int ret;
4660 struct ospf_if_params *params;
4661
4662 ifp = vty->index;
4663 params = IF_DEF_PARAMS (ifp);
4664
4665 if (argc == 2)
4666 {
4667 ret = inet_aton(argv[1], &addr);
4668 if (!ret)
4669 {
4670 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4671 VTY_NEWLINE);
4672 return CMD_WARNING;
4673 }
4674
4675 params = ospf_lookup_if_params (ifp, addr);
4676 if (params == NULL)
4677 return CMD_SUCCESS;
4678 }
4679
4680 key_id = strtol (argv[0], NULL, 10);
4681 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4682 if (ck == NULL)
4683 {
4684 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4685 return CMD_WARNING;
4686 }
4687
4688 ospf_crypt_key_delete (params->auth_crypt, key_id);
4689
4690 if (params != IF_DEF_PARAMS (ifp))
4691 {
4692 ospf_free_if_params (ifp, addr);
4693 ospf_if_update_params (ifp, addr);
4694 }
4695
4696 return CMD_SUCCESS;
4697}
4698
4699ALIAS (no_ip_ospf_message_digest_key,
4700 no_ip_ospf_message_digest_key_cmd,
4701 "no ip ospf message-digest-key <1-255>",
4702 NO_STR
4703 "IP Information\n"
4704 "OSPF interface commands\n"
4705 "Message digest authentication password (key)\n"
4706 "Key ID\n")
4707
4708ALIAS (no_ip_ospf_message_digest_key,
4709 no_ospf_message_digest_key_cmd,
4710 "no ospf message-digest-key <1-255>",
4711 NO_STR
4712 "OSPF interface commands\n"
4713 "Message digest authentication password (key)\n"
4714 "Key ID\n")
4715
4716DEFUN (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004717 ip_ospf_cost_u32_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004718 "ip ospf cost <1-65535> A.B.C.D",
4719 "IP Information\n"
4720 "OSPF interface commands\n"
4721 "Interface cost\n"
4722 "Cost\n"
4723 "Address of interface")
4724{
4725 struct interface *ifp = vty->index;
4726 u_int32_t cost;
4727 struct in_addr addr;
4728 int ret;
4729 struct ospf_if_params *params;
4730
4731 params = IF_DEF_PARAMS (ifp);
4732
4733 cost = strtol (argv[0], NULL, 10);
4734
4735 /* cost range is <1-65535>. */
4736 if (cost < 1 || cost > 65535)
4737 {
4738 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4739 return CMD_WARNING;
4740 }
4741
4742 if (argc == 2)
4743 {
4744 ret = inet_aton(argv[1], &addr);
4745 if (!ret)
4746 {
4747 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4748 VTY_NEWLINE);
4749 return CMD_WARNING;
4750 }
4751
4752 params = ospf_get_if_params (ifp, addr);
4753 ospf_if_update_params (ifp, addr);
4754 }
4755
4756 SET_IF_PARAM (params, output_cost_cmd);
4757 params->output_cost_cmd = cost;
4758
4759 ospf_if_recalculate_output_cost (ifp);
4760
4761 return CMD_SUCCESS;
4762}
4763
4764ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004765 ip_ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004766 "ip ospf cost <1-65535>",
4767 "IP Information\n"
4768 "OSPF interface commands\n"
4769 "Interface cost\n"
4770 "Cost")
4771
4772ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004773 ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004774 "ospf cost <1-65535>",
4775 "OSPF interface commands\n"
4776 "Interface cost\n"
4777 "Cost")
4778
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004779ALIAS (ip_ospf_cost,
4780 ospf_cost_u32_inet4_cmd,
4781 "ospf cost <1-65535> A.B.C.D",
4782 "OSPF interface commands\n"
4783 "Interface cost\n"
4784 "Cost\n"
4785 "Address of interface")
4786
paul718e3742002-12-13 20:15:29 +00004787DEFUN (no_ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004788 no_ip_ospf_cost_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004789 "no ip ospf cost A.B.C.D",
4790 NO_STR
4791 "IP Information\n"
4792 "OSPF interface commands\n"
4793 "Interface cost\n"
4794 "Address of interface")
4795{
4796 struct interface *ifp = vty->index;
4797 struct in_addr addr;
4798 int ret;
4799 struct ospf_if_params *params;
4800
4801 ifp = vty->index;
4802 params = IF_DEF_PARAMS (ifp);
4803
4804 if (argc == 1)
4805 {
4806 ret = inet_aton(argv[0], &addr);
4807 if (!ret)
4808 {
4809 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4810 VTY_NEWLINE);
4811 return CMD_WARNING;
4812 }
4813
4814 params = ospf_lookup_if_params (ifp, addr);
4815 if (params == NULL)
4816 return CMD_SUCCESS;
4817 }
4818
4819 UNSET_IF_PARAM (params, output_cost_cmd);
4820
4821 if (params != IF_DEF_PARAMS (ifp))
4822 {
4823 ospf_free_if_params (ifp, addr);
4824 ospf_if_update_params (ifp, addr);
4825 }
4826
4827 ospf_if_recalculate_output_cost (ifp);
4828
4829 return CMD_SUCCESS;
4830}
4831
4832ALIAS (no_ip_ospf_cost,
4833 no_ip_ospf_cost_cmd,
4834 "no ip ospf cost",
4835 NO_STR
4836 "IP Information\n"
4837 "OSPF interface commands\n"
4838 "Interface cost\n")
4839
4840ALIAS (no_ip_ospf_cost,
4841 no_ospf_cost_cmd,
4842 "no ospf cost",
4843 NO_STR
4844 "OSPF interface commands\n"
4845 "Interface cost\n")
4846
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004847ALIAS (no_ip_ospf_cost,
4848 no_ospf_cost_inet4_cmd,
4849 "no ospf cost A.B.C.D",
4850 NO_STR
4851 "OSPF interface commands\n"
4852 "Interface cost\n"
4853 "Address of interface")
4854
Denis Ovsienko827341b2009-09-28 19:34:59 +04004855DEFUN (no_ip_ospf_cost2,
4856 no_ip_ospf_cost_u32_cmd,
4857 "no ip ospf cost <1-65535>",
4858 NO_STR
4859 "IP Information\n"
4860 "OSPF interface commands\n"
4861 "Interface cost\n"
4862 "Cost")
4863{
4864 struct interface *ifp = vty->index;
4865 struct in_addr addr;
4866 u_int32_t cost;
4867 int ret;
4868 struct ospf_if_params *params;
4869
4870 ifp = vty->index;
4871 params = IF_DEF_PARAMS (ifp);
4872
4873 /* According to the semantics we are mimicking "no ip ospf cost N" is
4874 * always treated as "no ip ospf cost" regardless of the actual value
4875 * of N already configured for the interface. Thus the first argument
4876 * is always checked to be a number, but is ignored after that.
4877 */
4878 cost = strtol (argv[0], NULL, 10);
4879 if (cost < 1 || cost > 65535)
4880 {
4881 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4882 return CMD_WARNING;
4883 }
4884
4885 if (argc == 2)
4886 {
4887 ret = inet_aton(argv[1], &addr);
4888 if (!ret)
4889 {
4890 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4891 VTY_NEWLINE);
4892 return CMD_WARNING;
4893 }
4894
4895 params = ospf_lookup_if_params (ifp, addr);
4896 if (params == NULL)
4897 return CMD_SUCCESS;
4898 }
4899
4900 UNSET_IF_PARAM (params, output_cost_cmd);
4901
4902 if (params != IF_DEF_PARAMS (ifp))
4903 {
4904 ospf_free_if_params (ifp, addr);
4905 ospf_if_update_params (ifp, addr);
4906 }
4907
4908 ospf_if_recalculate_output_cost (ifp);
4909
4910 return CMD_SUCCESS;
4911}
4912
4913ALIAS (no_ip_ospf_cost2,
4914 no_ospf_cost_u32_cmd,
4915 "no ospf cost <1-65535>",
4916 NO_STR
4917 "OSPF interface commands\n"
4918 "Interface cost\n"
4919 "Cost")
4920
4921ALIAS (no_ip_ospf_cost2,
4922 no_ip_ospf_cost_u32_inet4_cmd,
4923 "no ip ospf cost <1-65535> A.B.C.D",
4924 NO_STR
4925 "IP Information\n"
4926 "OSPF interface commands\n"
4927 "Interface cost\n"
4928 "Cost\n"
4929 "Address of interface")
4930
4931ALIAS (no_ip_ospf_cost2,
4932 no_ospf_cost_u32_inet4_cmd,
4933 "no ospf cost <1-65535> A.B.C.D",
4934 NO_STR
4935 "OSPF interface commands\n"
4936 "Interface cost\n"
4937 "Cost\n"
4938 "Address of interface")
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004939
paul4dadc292005-05-06 21:37:42 +00004940static void
paul718e3742002-12-13 20:15:29 +00004941ospf_nbr_timer_update (struct ospf_interface *oi)
4942{
4943 struct route_node *rn;
4944 struct ospf_neighbor *nbr;
4945
4946 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4947 if ((nbr = rn->info))
4948 {
4949 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4950 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4951 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4952 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4953 }
4954}
4955
paulf9ad9372005-10-21 00:45:17 +00004956static int
4957ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4958 const char *nbr_str,
4959 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004960{
4961 struct interface *ifp = vty->index;
4962 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004963 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004964 struct in_addr addr;
4965 int ret;
4966 struct ospf_if_params *params;
4967 struct ospf_interface *oi;
4968 struct route_node *rn;
4969
4970 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004971
4972 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004973 {
paulf9ad9372005-10-21 00:45:17 +00004974 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004975 if (!ret)
4976 {
4977 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4978 VTY_NEWLINE);
4979 return CMD_WARNING;
4980 }
4981
4982 params = ospf_get_if_params (ifp, addr);
4983 ospf_if_update_params (ifp, addr);
4984 }
4985
paulf9ad9372005-10-21 00:45:17 +00004986 if (interval_str)
4987 {
4988 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4989 1, 65535);
4990
4991 /* reset fast_hello too, just to be sure */
4992 UNSET_IF_PARAM (params, fast_hello);
4993 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4994 }
4995 else if (fast_hello_str)
4996 {
4997 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4998 1, 10);
4999 /* 1s dead-interval with sub-second hellos desired */
5000 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
5001 SET_IF_PARAM (params, fast_hello);
5002 params->fast_hello = hellomult;
5003 }
5004 else
5005 {
5006 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5007 VTY_NEWLINE);
5008 return CMD_WARNING;
5009 }
5010
paul718e3742002-12-13 20:15:29 +00005011 SET_IF_PARAM (params, v_wait);
5012 params->v_wait = seconds;
5013
5014 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00005015 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005016 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005017 struct ospf *ospf;
5018 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005019 {
5020 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5021 if (oi)
5022 ospf_nbr_timer_update (oi);
5023 }
paul718e3742002-12-13 20:15:29 +00005024 }
5025 else
5026 {
5027 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5028 if ((oi = rn->info))
5029 ospf_nbr_timer_update (oi);
5030 }
5031
5032 return CMD_SUCCESS;
5033}
5034
paulf9ad9372005-10-21 00:45:17 +00005035
5036DEFUN (ip_ospf_dead_interval,
5037 ip_ospf_dead_interval_addr_cmd,
5038 "ip ospf dead-interval <1-65535> A.B.C.D",
5039 "IP Information\n"
5040 "OSPF interface commands\n"
5041 "Interval after which a neighbor is declared dead\n"
5042 "Seconds\n"
5043 "Address of interface\n")
5044{
5045 if (argc == 2)
5046 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5047 else
5048 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5049}
5050
paul718e3742002-12-13 20:15:29 +00005051ALIAS (ip_ospf_dead_interval,
5052 ip_ospf_dead_interval_cmd,
5053 "ip ospf dead-interval <1-65535>",
5054 "IP Information\n"
5055 "OSPF interface commands\n"
5056 "Interval after which a neighbor is declared dead\n"
5057 "Seconds\n")
5058
5059ALIAS (ip_ospf_dead_interval,
5060 ospf_dead_interval_cmd,
5061 "ospf dead-interval <1-65535>",
5062 "OSPF interface commands\n"
5063 "Interval after which a neighbor is declared dead\n"
5064 "Seconds\n")
5065
paulf9ad9372005-10-21 00:45:17 +00005066DEFUN (ip_ospf_dead_interval_minimal,
5067 ip_ospf_dead_interval_minimal_addr_cmd,
5068 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5069 "IP Information\n"
5070 "OSPF interface commands\n"
5071 "Interval after which a neighbor is declared dead\n"
5072 "Minimal 1s dead-interval with fast sub-second hellos\n"
5073 "Hello multiplier factor\n"
5074 "Number of Hellos to send each second\n"
5075 "Address of interface\n")
5076{
5077 if (argc == 2)
5078 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5079 else
5080 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5081}
5082
5083ALIAS (ip_ospf_dead_interval_minimal,
5084 ip_ospf_dead_interval_minimal_cmd,
5085 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5086 "IP Information\n"
5087 "OSPF interface commands\n"
5088 "Interval after which a neighbor is declared dead\n"
5089 "Minimal 1s dead-interval with fast sub-second hellos\n"
5090 "Hello multiplier factor\n"
5091 "Number of Hellos to send each second\n")
5092
paul718e3742002-12-13 20:15:29 +00005093DEFUN (no_ip_ospf_dead_interval,
5094 no_ip_ospf_dead_interval_addr_cmd,
5095 "no ip ospf dead-interval A.B.C.D",
5096 NO_STR
5097 "IP Information\n"
5098 "OSPF interface commands\n"
5099 "Interval after which a neighbor is declared dead\n"
5100 "Address of interface")
5101{
5102 struct interface *ifp = vty->index;
5103 struct in_addr addr;
5104 int ret;
5105 struct ospf_if_params *params;
5106 struct ospf_interface *oi;
5107 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00005108
paul718e3742002-12-13 20:15:29 +00005109 ifp = vty->index;
5110 params = IF_DEF_PARAMS (ifp);
5111
5112 if (argc == 1)
5113 {
5114 ret = inet_aton(argv[0], &addr);
5115 if (!ret)
5116 {
5117 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5118 VTY_NEWLINE);
5119 return CMD_WARNING;
5120 }
5121
5122 params = ospf_lookup_if_params (ifp, addr);
5123 if (params == NULL)
5124 return CMD_SUCCESS;
5125 }
5126
5127 UNSET_IF_PARAM (params, v_wait);
5128 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00005129
5130 UNSET_IF_PARAM (params, fast_hello);
5131 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5132
paul718e3742002-12-13 20:15:29 +00005133 if (params != IF_DEF_PARAMS (ifp))
5134 {
5135 ospf_free_if_params (ifp, addr);
5136 ospf_if_update_params (ifp, addr);
5137 }
5138
5139 /* Update timer values in neighbor structure. */
5140 if (argc == 1)
5141 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005142 struct ospf *ospf;
5143
5144 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005145 {
5146 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5147 if (oi)
5148 ospf_nbr_timer_update (oi);
5149 }
paul718e3742002-12-13 20:15:29 +00005150 }
5151 else
5152 {
5153 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5154 if ((oi = rn->info))
5155 ospf_nbr_timer_update (oi);
5156 }
5157
5158 return CMD_SUCCESS;
5159}
5160
5161ALIAS (no_ip_ospf_dead_interval,
5162 no_ip_ospf_dead_interval_cmd,
5163 "no ip ospf dead-interval",
5164 NO_STR
5165 "IP Information\n"
5166 "OSPF interface commands\n"
5167 "Interval after which a neighbor is declared dead\n")
5168
5169ALIAS (no_ip_ospf_dead_interval,
5170 no_ospf_dead_interval_cmd,
5171 "no ospf dead-interval",
5172 NO_STR
5173 "OSPF interface commands\n"
5174 "Interval after which a neighbor is declared dead\n")
5175
5176DEFUN (ip_ospf_hello_interval,
5177 ip_ospf_hello_interval_addr_cmd,
5178 "ip ospf hello-interval <1-65535> A.B.C.D",
5179 "IP Information\n"
5180 "OSPF interface commands\n"
5181 "Time between HELLO packets\n"
5182 "Seconds\n"
5183 "Address of interface")
5184{
5185 struct interface *ifp = vty->index;
5186 u_int32_t seconds;
5187 struct in_addr addr;
5188 int ret;
5189 struct ospf_if_params *params;
5190
5191 params = IF_DEF_PARAMS (ifp);
5192
5193 seconds = strtol (argv[0], NULL, 10);
5194
5195 /* HelloInterval range is <1-65535>. */
5196 if (seconds < 1 || seconds > 65535)
5197 {
5198 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5199 return CMD_WARNING;
5200 }
5201
5202 if (argc == 2)
5203 {
5204 ret = inet_aton(argv[1], &addr);
5205 if (!ret)
5206 {
5207 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5208 VTY_NEWLINE);
5209 return CMD_WARNING;
5210 }
5211
5212 params = ospf_get_if_params (ifp, addr);
5213 ospf_if_update_params (ifp, addr);
5214 }
5215
paulf9ad9372005-10-21 00:45:17 +00005216 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005217 params->v_hello = seconds;
5218
5219 return CMD_SUCCESS;
5220}
5221
5222ALIAS (ip_ospf_hello_interval,
5223 ip_ospf_hello_interval_cmd,
5224 "ip ospf hello-interval <1-65535>",
5225 "IP Information\n"
5226 "OSPF interface commands\n"
5227 "Time between HELLO packets\n"
5228 "Seconds\n")
5229
5230ALIAS (ip_ospf_hello_interval,
5231 ospf_hello_interval_cmd,
5232 "ospf hello-interval <1-65535>",
5233 "OSPF interface commands\n"
5234 "Time between HELLO packets\n"
5235 "Seconds\n")
5236
5237DEFUN (no_ip_ospf_hello_interval,
5238 no_ip_ospf_hello_interval_addr_cmd,
5239 "no ip ospf hello-interval A.B.C.D",
5240 NO_STR
5241 "IP Information\n"
5242 "OSPF interface commands\n"
5243 "Time between HELLO packets\n"
5244 "Address of interface")
5245{
5246 struct interface *ifp = vty->index;
5247 struct in_addr addr;
5248 int ret;
5249 struct ospf_if_params *params;
5250
5251 ifp = vty->index;
5252 params = IF_DEF_PARAMS (ifp);
5253
5254 if (argc == 1)
5255 {
5256 ret = inet_aton(argv[0], &addr);
5257 if (!ret)
5258 {
5259 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5260 VTY_NEWLINE);
5261 return CMD_WARNING;
5262 }
5263
5264 params = ospf_lookup_if_params (ifp, addr);
5265 if (params == NULL)
5266 return CMD_SUCCESS;
5267 }
5268
5269 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005270 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005271
5272 if (params != IF_DEF_PARAMS (ifp))
5273 {
5274 ospf_free_if_params (ifp, addr);
5275 ospf_if_update_params (ifp, addr);
5276 }
5277
5278 return CMD_SUCCESS;
5279}
5280
5281ALIAS (no_ip_ospf_hello_interval,
5282 no_ip_ospf_hello_interval_cmd,
5283 "no ip ospf hello-interval",
5284 NO_STR
5285 "IP Information\n"
5286 "OSPF interface commands\n"
5287 "Time between HELLO packets\n")
5288
5289ALIAS (no_ip_ospf_hello_interval,
5290 no_ospf_hello_interval_cmd,
5291 "no ospf hello-interval",
5292 NO_STR
5293 "OSPF interface commands\n"
5294 "Time between HELLO packets\n")
5295
5296DEFUN (ip_ospf_network,
5297 ip_ospf_network_cmd,
5298 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5299 "IP Information\n"
5300 "OSPF interface commands\n"
5301 "Network type\n"
5302 "Specify OSPF broadcast multi-access network\n"
5303 "Specify OSPF NBMA network\n"
5304 "Specify OSPF point-to-multipoint network\n"
5305 "Specify OSPF point-to-point network\n")
5306{
5307 struct interface *ifp = vty->index;
5308 int old_type = IF_DEF_PARAMS (ifp)->type;
5309 struct route_node *rn;
5310
5311 if (strncmp (argv[0], "b", 1) == 0)
5312 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5313 else if (strncmp (argv[0], "n", 1) == 0)
5314 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5315 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5316 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5317 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5318 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5319
5320 if (IF_DEF_PARAMS (ifp)->type == old_type)
5321 return CMD_SUCCESS;
5322
5323 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5324
5325 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5326 {
5327 struct ospf_interface *oi = rn->info;
5328
5329 if (!oi)
5330 continue;
5331
5332 oi->type = IF_DEF_PARAMS (ifp)->type;
5333
5334 if (oi->state > ISM_Down)
5335 {
5336 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5337 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5338 }
5339 }
5340
5341 return CMD_SUCCESS;
5342}
5343
5344ALIAS (ip_ospf_network,
5345 ospf_network_cmd,
5346 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5347 "OSPF interface commands\n"
5348 "Network type\n"
5349 "Specify OSPF broadcast multi-access network\n"
5350 "Specify OSPF NBMA network\n"
5351 "Specify OSPF point-to-multipoint network\n"
5352 "Specify OSPF point-to-point network\n")
5353
5354DEFUN (no_ip_ospf_network,
5355 no_ip_ospf_network_cmd,
5356 "no ip ospf network",
5357 NO_STR
5358 "IP Information\n"
5359 "OSPF interface commands\n"
5360 "Network type\n")
5361{
5362 struct interface *ifp = vty->index;
5363 int old_type = IF_DEF_PARAMS (ifp)->type;
5364 struct route_node *rn;
5365
ajsbc18d612004-12-15 15:07:19 +00005366 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005367
5368 if (IF_DEF_PARAMS (ifp)->type == old_type)
5369 return CMD_SUCCESS;
5370
5371 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5372 {
5373 struct ospf_interface *oi = rn->info;
5374
5375 if (!oi)
5376 continue;
5377
5378 oi->type = IF_DEF_PARAMS (ifp)->type;
5379
5380 if (oi->state > ISM_Down)
5381 {
5382 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5383 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5384 }
5385 }
5386
5387 return CMD_SUCCESS;
5388}
5389
5390ALIAS (no_ip_ospf_network,
5391 no_ospf_network_cmd,
5392 "no ospf network",
5393 NO_STR
5394 "OSPF interface commands\n"
5395 "Network type\n")
5396
5397DEFUN (ip_ospf_priority,
5398 ip_ospf_priority_addr_cmd,
5399 "ip ospf priority <0-255> A.B.C.D",
5400 "IP Information\n"
5401 "OSPF interface commands\n"
5402 "Router priority\n"
5403 "Priority\n"
5404 "Address of interface")
5405{
5406 struct interface *ifp = vty->index;
Andrew Certain0798cee2012-12-04 13:43:42 -08005407 long priority;
paul718e3742002-12-13 20:15:29 +00005408 struct route_node *rn;
5409 struct in_addr addr;
5410 int ret;
5411 struct ospf_if_params *params;
5412
5413 params = IF_DEF_PARAMS (ifp);
5414
5415 priority = strtol (argv[0], NULL, 10);
5416
5417 /* Router Priority range is <0-255>. */
5418 if (priority < 0 || priority > 255)
5419 {
5420 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5421 return CMD_WARNING;
5422 }
5423
5424 if (argc == 2)
5425 {
5426 ret = inet_aton(argv[1], &addr);
5427 if (!ret)
5428 {
5429 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5430 VTY_NEWLINE);
5431 return CMD_WARNING;
5432 }
5433
5434 params = ospf_get_if_params (ifp, addr);
5435 ospf_if_update_params (ifp, addr);
5436 }
5437
5438 SET_IF_PARAM (params, priority);
5439 params->priority = priority;
5440
5441 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5442 {
5443 struct ospf_interface *oi = rn->info;
5444
5445 if (!oi)
5446 continue;
5447
5448
5449 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5450 {
5451 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5452 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5453 }
5454 }
5455
5456 return CMD_SUCCESS;
5457}
5458
5459ALIAS (ip_ospf_priority,
5460 ip_ospf_priority_cmd,
5461 "ip ospf priority <0-255>",
5462 "IP Information\n"
5463 "OSPF interface commands\n"
5464 "Router priority\n"
5465 "Priority\n")
5466
5467ALIAS (ip_ospf_priority,
5468 ospf_priority_cmd,
5469 "ospf priority <0-255>",
5470 "OSPF interface commands\n"
5471 "Router priority\n"
5472 "Priority\n")
5473
5474DEFUN (no_ip_ospf_priority,
5475 no_ip_ospf_priority_addr_cmd,
5476 "no ip ospf priority A.B.C.D",
5477 NO_STR
5478 "IP Information\n"
5479 "OSPF interface commands\n"
5480 "Router priority\n"
5481 "Address of interface")
5482{
5483 struct interface *ifp = vty->index;
5484 struct route_node *rn;
5485 struct in_addr addr;
5486 int ret;
5487 struct ospf_if_params *params;
5488
5489 ifp = vty->index;
5490 params = IF_DEF_PARAMS (ifp);
5491
5492 if (argc == 1)
5493 {
5494 ret = inet_aton(argv[0], &addr);
5495 if (!ret)
5496 {
5497 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5498 VTY_NEWLINE);
5499 return CMD_WARNING;
5500 }
5501
5502 params = ospf_lookup_if_params (ifp, addr);
5503 if (params == NULL)
5504 return CMD_SUCCESS;
5505 }
5506
5507 UNSET_IF_PARAM (params, priority);
5508 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5509
5510 if (params != IF_DEF_PARAMS (ifp))
5511 {
5512 ospf_free_if_params (ifp, addr);
5513 ospf_if_update_params (ifp, addr);
5514 }
5515
5516 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5517 {
5518 struct ospf_interface *oi = rn->info;
5519
5520 if (!oi)
5521 continue;
5522
5523
5524 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5525 {
5526 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5527 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5528 }
5529 }
5530
5531 return CMD_SUCCESS;
5532}
5533
5534ALIAS (no_ip_ospf_priority,
5535 no_ip_ospf_priority_cmd,
5536 "no ip ospf priority",
5537 NO_STR
5538 "IP Information\n"
5539 "OSPF interface commands\n"
5540 "Router priority\n")
5541
5542ALIAS (no_ip_ospf_priority,
5543 no_ospf_priority_cmd,
5544 "no ospf priority",
5545 NO_STR
5546 "OSPF interface commands\n"
5547 "Router priority\n")
5548
5549DEFUN (ip_ospf_retransmit_interval,
5550 ip_ospf_retransmit_interval_addr_cmd,
5551 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5552 "IP Information\n"
5553 "OSPF interface commands\n"
5554 "Time between retransmitting lost link state advertisements\n"
5555 "Seconds\n"
5556 "Address of interface")
5557{
5558 struct interface *ifp = vty->index;
5559 u_int32_t seconds;
5560 struct in_addr addr;
5561 int ret;
5562 struct ospf_if_params *params;
5563
5564 params = IF_DEF_PARAMS (ifp);
5565 seconds = strtol (argv[0], NULL, 10);
5566
5567 /* Retransmit Interval range is <3-65535>. */
5568 if (seconds < 3 || seconds > 65535)
5569 {
5570 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5571 return CMD_WARNING;
5572 }
5573
5574
5575 if (argc == 2)
5576 {
5577 ret = inet_aton(argv[1], &addr);
5578 if (!ret)
5579 {
5580 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5581 VTY_NEWLINE);
5582 return CMD_WARNING;
5583 }
5584
5585 params = ospf_get_if_params (ifp, addr);
5586 ospf_if_update_params (ifp, addr);
5587 }
5588
5589 SET_IF_PARAM (params, retransmit_interval);
5590 params->retransmit_interval = seconds;
5591
5592 return CMD_SUCCESS;
5593}
5594
5595ALIAS (ip_ospf_retransmit_interval,
5596 ip_ospf_retransmit_interval_cmd,
5597 "ip ospf retransmit-interval <3-65535>",
5598 "IP Information\n"
5599 "OSPF interface commands\n"
5600 "Time between retransmitting lost link state advertisements\n"
5601 "Seconds\n")
5602
5603ALIAS (ip_ospf_retransmit_interval,
5604 ospf_retransmit_interval_cmd,
5605 "ospf retransmit-interval <3-65535>",
5606 "OSPF interface commands\n"
5607 "Time between retransmitting lost link state advertisements\n"
5608 "Seconds\n")
5609
5610DEFUN (no_ip_ospf_retransmit_interval,
5611 no_ip_ospf_retransmit_interval_addr_cmd,
5612 "no ip ospf retransmit-interval A.B.C.D",
5613 NO_STR
5614 "IP Information\n"
5615 "OSPF interface commands\n"
5616 "Time between retransmitting lost link state advertisements\n"
5617 "Address of interface")
5618{
5619 struct interface *ifp = vty->index;
5620 struct in_addr addr;
5621 int ret;
5622 struct ospf_if_params *params;
5623
5624 ifp = vty->index;
5625 params = IF_DEF_PARAMS (ifp);
5626
5627 if (argc == 1)
5628 {
5629 ret = inet_aton(argv[0], &addr);
5630 if (!ret)
5631 {
5632 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5633 VTY_NEWLINE);
5634 return CMD_WARNING;
5635 }
5636
5637 params = ospf_lookup_if_params (ifp, addr);
5638 if (params == NULL)
5639 return CMD_SUCCESS;
5640 }
5641
5642 UNSET_IF_PARAM (params, retransmit_interval);
5643 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5644
5645 if (params != IF_DEF_PARAMS (ifp))
5646 {
5647 ospf_free_if_params (ifp, addr);
5648 ospf_if_update_params (ifp, addr);
5649 }
5650
5651 return CMD_SUCCESS;
5652}
5653
5654ALIAS (no_ip_ospf_retransmit_interval,
5655 no_ip_ospf_retransmit_interval_cmd,
5656 "no ip ospf retransmit-interval",
5657 NO_STR
5658 "IP Information\n"
5659 "OSPF interface commands\n"
5660 "Time between retransmitting lost link state advertisements\n")
5661
5662ALIAS (no_ip_ospf_retransmit_interval,
5663 no_ospf_retransmit_interval_cmd,
5664 "no ospf retransmit-interval",
5665 NO_STR
5666 "OSPF interface commands\n"
5667 "Time between retransmitting lost link state advertisements\n")
5668
5669DEFUN (ip_ospf_transmit_delay,
5670 ip_ospf_transmit_delay_addr_cmd,
5671 "ip ospf transmit-delay <1-65535> A.B.C.D",
5672 "IP Information\n"
5673 "OSPF interface commands\n"
5674 "Link state transmit delay\n"
5675 "Seconds\n"
5676 "Address of interface")
5677{
5678 struct interface *ifp = vty->index;
5679 u_int32_t seconds;
5680 struct in_addr addr;
5681 int ret;
5682 struct ospf_if_params *params;
5683
5684 params = IF_DEF_PARAMS (ifp);
5685 seconds = strtol (argv[0], NULL, 10);
5686
5687 /* Transmit Delay range is <1-65535>. */
5688 if (seconds < 1 || seconds > 65535)
5689 {
5690 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5691 return CMD_WARNING;
5692 }
5693
5694 if (argc == 2)
5695 {
5696 ret = inet_aton(argv[1], &addr);
5697 if (!ret)
5698 {
5699 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5700 VTY_NEWLINE);
5701 return CMD_WARNING;
5702 }
5703
5704 params = ospf_get_if_params (ifp, addr);
5705 ospf_if_update_params (ifp, addr);
5706 }
5707
5708 SET_IF_PARAM (params, transmit_delay);
5709 params->transmit_delay = seconds;
5710
5711 return CMD_SUCCESS;
5712}
5713
5714ALIAS (ip_ospf_transmit_delay,
5715 ip_ospf_transmit_delay_cmd,
5716 "ip ospf transmit-delay <1-65535>",
5717 "IP Information\n"
5718 "OSPF interface commands\n"
5719 "Link state transmit delay\n"
5720 "Seconds\n")
5721
5722ALIAS (ip_ospf_transmit_delay,
5723 ospf_transmit_delay_cmd,
5724 "ospf transmit-delay <1-65535>",
5725 "OSPF interface commands\n"
5726 "Link state transmit delay\n"
5727 "Seconds\n")
5728
5729DEFUN (no_ip_ospf_transmit_delay,
5730 no_ip_ospf_transmit_delay_addr_cmd,
5731 "no ip ospf transmit-delay A.B.C.D",
5732 NO_STR
5733 "IP Information\n"
5734 "OSPF interface commands\n"
5735 "Link state transmit delay\n"
5736 "Address of interface")
5737{
5738 struct interface *ifp = vty->index;
5739 struct in_addr addr;
5740 int ret;
5741 struct ospf_if_params *params;
5742
5743 ifp = vty->index;
5744 params = IF_DEF_PARAMS (ifp);
5745
5746 if (argc == 1)
5747 {
5748 ret = inet_aton(argv[0], &addr);
5749 if (!ret)
5750 {
5751 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5752 VTY_NEWLINE);
5753 return CMD_WARNING;
5754 }
5755
5756 params = ospf_lookup_if_params (ifp, addr);
5757 if (params == NULL)
5758 return CMD_SUCCESS;
5759 }
5760
5761 UNSET_IF_PARAM (params, transmit_delay);
5762 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5763
5764 if (params != IF_DEF_PARAMS (ifp))
5765 {
5766 ospf_free_if_params (ifp, addr);
5767 ospf_if_update_params (ifp, addr);
5768 }
5769
5770 return CMD_SUCCESS;
5771}
5772
5773ALIAS (no_ip_ospf_transmit_delay,
5774 no_ip_ospf_transmit_delay_cmd,
5775 "no ip ospf transmit-delay",
5776 NO_STR
5777 "IP Information\n"
5778 "OSPF interface commands\n"
5779 "Link state transmit delay\n")
5780
5781ALIAS (no_ip_ospf_transmit_delay,
5782 no_ospf_transmit_delay_cmd,
5783 "no ospf transmit-delay",
5784 NO_STR
5785 "OSPF interface commands\n"
5786 "Link state transmit delay\n")
5787
5788
5789DEFUN (ospf_redistribute_source_metric_type,
5790 ospf_redistribute_source_metric_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005791 "redistribute " QUAGGA_REDIST_STR_OSPFD
5792 " metric <0-16777214> metric-type (1|2) route-map WORD",
5793 REDIST_STR
5794 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005795 "Metric for redistributed routes\n"
5796 "OSPF default metric\n"
5797 "OSPF exterior metric type for redistributed routes\n"
5798 "Set OSPF External Type 1 metrics\n"
5799 "Set OSPF External Type 2 metrics\n"
5800 "Route map reference\n"
5801 "Pointer to route-map entries\n")
5802{
paul020709f2003-04-04 02:44:16 +00005803 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005804 int source;
5805 int type = -1;
5806 int metric = -1;
5807
5808 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005809 source = proto_redistnum(AFI_IP, argv[0]);
5810 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005811 return CMD_WARNING;
5812
5813 /* Get metric value. */
5814 if (argc >= 2)
5815 if (!str2metric (argv[1], &metric))
5816 return CMD_WARNING;
5817
5818 /* Get metric type. */
5819 if (argc >= 3)
5820 if (!str2metric_type (argv[2], &type))
5821 return CMD_WARNING;
5822
5823 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005824 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005825 else
paul020709f2003-04-04 02:44:16 +00005826 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005827
paul020709f2003-04-04 02:44:16 +00005828 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005829}
5830
5831ALIAS (ospf_redistribute_source_metric_type,
5832 ospf_redistribute_source_metric_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005833 "redistribute " QUAGGA_REDIST_STR_OSPFD
5834 " metric <0-16777214> metric-type (1|2)",
5835 REDIST_STR
5836 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005837 "Metric for redistributed routes\n"
5838 "OSPF default metric\n"
5839 "OSPF exterior metric type for redistributed routes\n"
5840 "Set OSPF External Type 1 metrics\n"
5841 "Set OSPF External Type 2 metrics\n")
5842
5843ALIAS (ospf_redistribute_source_metric_type,
5844 ospf_redistribute_source_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005845 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5846 REDIST_STR
5847 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005848 "Metric for redistributed routes\n"
5849 "OSPF default metric\n")
5850
5851DEFUN (ospf_redistribute_source_type_metric,
5852 ospf_redistribute_source_type_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005853 "redistribute " QUAGGA_REDIST_STR_OSPFD
5854 " metric-type (1|2) metric <0-16777214> route-map WORD",
5855 REDIST_STR
5856 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005857 "OSPF exterior metric type for redistributed routes\n"
5858 "Set OSPF External Type 1 metrics\n"
5859 "Set OSPF External Type 2 metrics\n"
5860 "Metric for redistributed routes\n"
5861 "OSPF default metric\n"
5862 "Route map reference\n"
5863 "Pointer to route-map entries\n")
5864{
paul020709f2003-04-04 02:44:16 +00005865 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005866 int source;
5867 int type = -1;
5868 int metric = -1;
5869
5870 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005871 source = proto_redistnum(AFI_IP, argv[0]);
5872 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005873 return CMD_WARNING;
5874
5875 /* Get metric value. */
5876 if (argc >= 2)
5877 if (!str2metric_type (argv[1], &type))
5878 return CMD_WARNING;
5879
5880 /* Get metric type. */
5881 if (argc >= 3)
5882 if (!str2metric (argv[2], &metric))
5883 return CMD_WARNING;
5884
5885 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005886 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005887 else
paul020709f2003-04-04 02:44:16 +00005888 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005889
paul020709f2003-04-04 02:44:16 +00005890 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005891}
5892
5893ALIAS (ospf_redistribute_source_type_metric,
5894 ospf_redistribute_source_type_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005895 "redistribute " QUAGGA_REDIST_STR_OSPFD
5896 " metric-type (1|2) metric <0-16777214>",
5897 REDIST_STR
5898 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005899 "OSPF exterior metric type for redistributed routes\n"
5900 "Set OSPF External Type 1 metrics\n"
5901 "Set OSPF External Type 2 metrics\n"
5902 "Metric for redistributed routes\n"
5903 "OSPF default metric\n")
5904
5905ALIAS (ospf_redistribute_source_type_metric,
5906 ospf_redistribute_source_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005907 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5908 REDIST_STR
5909 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005910 "OSPF exterior metric type for redistributed routes\n"
5911 "Set OSPF External Type 1 metrics\n"
5912 "Set OSPF External Type 2 metrics\n")
5913
5914ALIAS (ospf_redistribute_source_type_metric,
5915 ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005916 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5917 REDIST_STR
5918 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005919
5920DEFUN (ospf_redistribute_source_metric_routemap,
5921 ospf_redistribute_source_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005922 "redistribute " QUAGGA_REDIST_STR_OSPFD
5923 " metric <0-16777214> route-map WORD",
5924 REDIST_STR
5925 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005926 "Metric for redistributed routes\n"
5927 "OSPF default metric\n"
5928 "Route map reference\n"
5929 "Pointer to route-map entries\n")
5930{
paul020709f2003-04-04 02:44:16 +00005931 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005932 int source;
5933 int metric = -1;
5934
5935 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005936 source = proto_redistnum(AFI_IP, argv[0]);
5937 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005938 return CMD_WARNING;
5939
5940 /* Get metric value. */
5941 if (argc >= 2)
5942 if (!str2metric (argv[1], &metric))
5943 return CMD_WARNING;
5944
5945 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005946 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005947 else
paul020709f2003-04-04 02:44:16 +00005948 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005949
paul020709f2003-04-04 02:44:16 +00005950 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005951}
5952
5953DEFUN (ospf_redistribute_source_type_routemap,
5954 ospf_redistribute_source_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005955 "redistribute " QUAGGA_REDIST_STR_OSPFD
5956 " metric-type (1|2) route-map WORD",
5957 REDIST_STR
5958 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005959 "OSPF exterior metric type for redistributed routes\n"
5960 "Set OSPF External Type 1 metrics\n"
5961 "Set OSPF External Type 2 metrics\n"
5962 "Route map reference\n"
5963 "Pointer to route-map entries\n")
5964{
paul020709f2003-04-04 02:44:16 +00005965 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005966 int source;
5967 int type = -1;
5968
5969 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005970 source = proto_redistnum(AFI_IP, argv[0]);
5971 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005972 return CMD_WARNING;
5973
5974 /* Get metric value. */
5975 if (argc >= 2)
5976 if (!str2metric_type (argv[1], &type))
5977 return CMD_WARNING;
5978
5979 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005980 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005981 else
paul020709f2003-04-04 02:44:16 +00005982 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005983
paul020709f2003-04-04 02:44:16 +00005984 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005985}
5986
5987DEFUN (ospf_redistribute_source_routemap,
5988 ospf_redistribute_source_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005989 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5990 REDIST_STR
5991 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005992 "Route map reference\n"
5993 "Pointer to route-map entries\n")
5994{
paul020709f2003-04-04 02:44:16 +00005995 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005996 int source;
5997
5998 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005999 source = proto_redistnum(AFI_IP, argv[0]);
6000 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006001 return CMD_WARNING;
6002
6003 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006004 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00006005 else
paul020709f2003-04-04 02:44:16 +00006006 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006007
paul020709f2003-04-04 02:44:16 +00006008 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00006009}
6010
6011DEFUN (no_ospf_redistribute_source,
6012 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006013 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006014 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006015 REDIST_STR
6016 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006017{
paul020709f2003-04-04 02:44:16 +00006018 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006019 int source;
6020
David Lampartere0ca5fd2009-09-16 01:52:42 +02006021 source = proto_redistnum(AFI_IP, argv[0]);
6022 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006023 return CMD_WARNING;
6024
paul020709f2003-04-04 02:44:16 +00006025 ospf_routemap_unset (ospf, source);
6026 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006027}
6028
6029DEFUN (ospf_distribute_list_out,
6030 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006031 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006032 "Filter networks in routing updates\n"
6033 "Access-list name\n"
6034 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006035 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006036{
paul68980082003-03-25 05:07:42 +00006037 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006038 int source;
6039
6040 /* Get distribute source. */
Christian Frankebda3c322012-12-04 11:31:16 -08006041 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02006042 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006043 return CMD_WARNING;
6044
paul68980082003-03-25 05:07:42 +00006045 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006046}
6047
6048DEFUN (no_ospf_distribute_list_out,
6049 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006050 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006051 NO_STR
6052 "Filter networks in routing updates\n"
6053 "Access-list name\n"
6054 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006055 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006056{
paul68980082003-03-25 05:07:42 +00006057 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006058 int source;
6059
Christian Frankebda3c322012-12-04 11:31:16 -08006060 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02006061 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006062 return CMD_WARNING;
6063
paul68980082003-03-25 05:07:42 +00006064 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006065}
6066
6067/* Default information originate. */
6068DEFUN (ospf_default_information_originate_metric_type_routemap,
6069 ospf_default_information_originate_metric_type_routemap_cmd,
6070 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
6071 "Control distribution of default information\n"
6072 "Distribute a default route\n"
6073 "OSPF default metric\n"
6074 "OSPF metric\n"
6075 "OSPF metric type for default routes\n"
6076 "Set OSPF External Type 1 metrics\n"
6077 "Set OSPF External Type 2 metrics\n"
6078 "Route map reference\n"
6079 "Pointer to route-map entries\n")
6080{
paul020709f2003-04-04 02:44:16 +00006081 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006082 int type = -1;
6083 int metric = -1;
6084
6085 /* Get metric value. */
6086 if (argc >= 1)
6087 if (!str2metric (argv[0], &metric))
6088 return CMD_WARNING;
6089
6090 /* Get metric type. */
6091 if (argc >= 2)
6092 if (!str2metric_type (argv[1], &type))
6093 return CMD_WARNING;
6094
6095 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006096 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006097 else
paul020709f2003-04-04 02:44:16 +00006098 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006099
paul020709f2003-04-04 02:44:16 +00006100 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6101 type, metric);
paul718e3742002-12-13 20:15:29 +00006102}
6103
6104ALIAS (ospf_default_information_originate_metric_type_routemap,
6105 ospf_default_information_originate_metric_type_cmd,
6106 "default-information originate metric <0-16777214> metric-type (1|2)",
6107 "Control distribution of default information\n"
6108 "Distribute a default route\n"
6109 "OSPF default metric\n"
6110 "OSPF metric\n"
6111 "OSPF metric type for default routes\n"
6112 "Set OSPF External Type 1 metrics\n"
6113 "Set OSPF External Type 2 metrics\n")
6114
6115ALIAS (ospf_default_information_originate_metric_type_routemap,
6116 ospf_default_information_originate_metric_cmd,
6117 "default-information originate metric <0-16777214>",
6118 "Control distribution of default information\n"
6119 "Distribute a default route\n"
6120 "OSPF default metric\n"
6121 "OSPF metric\n")
6122
6123ALIAS (ospf_default_information_originate_metric_type_routemap,
6124 ospf_default_information_originate_cmd,
6125 "default-information originate",
6126 "Control distribution of default information\n"
6127 "Distribute a default route\n")
6128
6129/* Default information originate. */
6130DEFUN (ospf_default_information_originate_metric_routemap,
6131 ospf_default_information_originate_metric_routemap_cmd,
6132 "default-information originate metric <0-16777214> route-map WORD",
6133 "Control distribution of default information\n"
6134 "Distribute a default route\n"
6135 "OSPF default metric\n"
6136 "OSPF metric\n"
6137 "Route map reference\n"
6138 "Pointer to route-map entries\n")
6139{
paul020709f2003-04-04 02:44:16 +00006140 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006141 int metric = -1;
6142
6143 /* Get metric value. */
6144 if (argc >= 1)
6145 if (!str2metric (argv[0], &metric))
6146 return CMD_WARNING;
6147
6148 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006149 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006150 else
paul020709f2003-04-04 02:44:16 +00006151 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006152
paul020709f2003-04-04 02:44:16 +00006153 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6154 -1, metric);
paul718e3742002-12-13 20:15:29 +00006155}
6156
6157/* Default information originate. */
6158DEFUN (ospf_default_information_originate_routemap,
6159 ospf_default_information_originate_routemap_cmd,
6160 "default-information originate route-map WORD",
6161 "Control distribution of default information\n"
6162 "Distribute a default route\n"
6163 "Route map reference\n"
6164 "Pointer to route-map entries\n")
6165{
paul020709f2003-04-04 02:44:16 +00006166 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006167
paul020709f2003-04-04 02:44:16 +00006168 if (argc == 1)
6169 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6170 else
6171 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6172
6173 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00006174}
6175
6176DEFUN (ospf_default_information_originate_type_metric_routemap,
6177 ospf_default_information_originate_type_metric_routemap_cmd,
6178 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6179 "Control distribution of default information\n"
6180 "Distribute a default route\n"
6181 "OSPF metric type for default routes\n"
6182 "Set OSPF External Type 1 metrics\n"
6183 "Set OSPF External Type 2 metrics\n"
6184 "OSPF default metric\n"
6185 "OSPF metric\n"
6186 "Route map reference\n"
6187 "Pointer to route-map entries\n")
6188{
paul020709f2003-04-04 02:44:16 +00006189 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006190 int type = -1;
6191 int metric = -1;
6192
6193 /* Get metric type. */
6194 if (argc >= 1)
6195 if (!str2metric_type (argv[0], &type))
6196 return CMD_WARNING;
6197
6198 /* Get metric value. */
6199 if (argc >= 2)
6200 if (!str2metric (argv[1], &metric))
6201 return CMD_WARNING;
6202
6203 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006204 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006205 else
paul020709f2003-04-04 02:44:16 +00006206 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006207
paul020709f2003-04-04 02:44:16 +00006208 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6209 type, metric);
paul718e3742002-12-13 20:15:29 +00006210}
6211
6212ALIAS (ospf_default_information_originate_type_metric_routemap,
6213 ospf_default_information_originate_type_metric_cmd,
6214 "default-information originate metric-type (1|2) metric <0-16777214>",
6215 "Control distribution of default information\n"
6216 "Distribute a default route\n"
6217 "OSPF metric type for default routes\n"
6218 "Set OSPF External Type 1 metrics\n"
6219 "Set OSPF External Type 2 metrics\n"
6220 "OSPF default metric\n"
6221 "OSPF metric\n")
6222
6223ALIAS (ospf_default_information_originate_type_metric_routemap,
6224 ospf_default_information_originate_type_cmd,
6225 "default-information originate metric-type (1|2)",
6226 "Control distribution of default information\n"
6227 "Distribute a default route\n"
6228 "OSPF metric type for default routes\n"
6229 "Set OSPF External Type 1 metrics\n"
6230 "Set OSPF External Type 2 metrics\n")
6231
6232DEFUN (ospf_default_information_originate_type_routemap,
6233 ospf_default_information_originate_type_routemap_cmd,
6234 "default-information originate metric-type (1|2) route-map WORD",
6235 "Control distribution of default information\n"
6236 "Distribute a default route\n"
6237 "OSPF metric type for default routes\n"
6238 "Set OSPF External Type 1 metrics\n"
6239 "Set OSPF External Type 2 metrics\n"
6240 "Route map reference\n"
6241 "Pointer to route-map entries\n")
6242{
paul020709f2003-04-04 02:44:16 +00006243 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006244 int type = -1;
6245
6246 /* Get metric type. */
6247 if (argc >= 1)
6248 if (!str2metric_type (argv[0], &type))
6249 return CMD_WARNING;
6250
6251 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006252 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006253 else
paul020709f2003-04-04 02:44:16 +00006254 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006255
paul020709f2003-04-04 02:44:16 +00006256 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6257 type, -1);
paul718e3742002-12-13 20:15:29 +00006258}
6259
6260DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6261 ospf_default_information_originate_always_metric_type_routemap_cmd,
6262 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6263 "Control distribution of default information\n"
6264 "Distribute a default route\n"
6265 "Always advertise default route\n"
6266 "OSPF default metric\n"
6267 "OSPF metric\n"
6268 "OSPF metric type for default routes\n"
6269 "Set OSPF External Type 1 metrics\n"
6270 "Set OSPF External Type 2 metrics\n"
6271 "Route map reference\n"
6272 "Pointer to route-map entries\n")
6273{
paul020709f2003-04-04 02:44:16 +00006274 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006275 int type = -1;
6276 int metric = -1;
6277
6278 /* Get metric value. */
6279 if (argc >= 1)
6280 if (!str2metric (argv[0], &metric))
6281 return CMD_WARNING;
6282
6283 /* Get metric type. */
6284 if (argc >= 2)
6285 if (!str2metric_type (argv[1], &type))
6286 return CMD_WARNING;
6287
6288 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006289 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006290 else
paul020709f2003-04-04 02:44:16 +00006291 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006292
paul020709f2003-04-04 02:44:16 +00006293 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006294 type, metric);
6295}
6296
6297ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6298 ospf_default_information_originate_always_metric_type_cmd,
6299 "default-information originate always metric <0-16777214> metric-type (1|2)",
6300 "Control distribution of default information\n"
6301 "Distribute a default route\n"
6302 "Always advertise default route\n"
6303 "OSPF default metric\n"
6304 "OSPF metric\n"
6305 "OSPF metric type for default routes\n"
6306 "Set OSPF External Type 1 metrics\n"
6307 "Set OSPF External Type 2 metrics\n")
6308
6309ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6310 ospf_default_information_originate_always_metric_cmd,
6311 "default-information originate always metric <0-16777214>",
6312 "Control distribution of default information\n"
6313 "Distribute a default route\n"
6314 "Always advertise default route\n"
6315 "OSPF default metric\n"
6316 "OSPF metric\n"
6317 "OSPF metric type for default routes\n")
6318
6319ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6320 ospf_default_information_originate_always_cmd,
6321 "default-information originate always",
6322 "Control distribution of default information\n"
6323 "Distribute a default route\n"
6324 "Always advertise default route\n")
6325
6326DEFUN (ospf_default_information_originate_always_metric_routemap,
6327 ospf_default_information_originate_always_metric_routemap_cmd,
6328 "default-information originate always metric <0-16777214> route-map WORD",
6329 "Control distribution of default information\n"
6330 "Distribute a default route\n"
6331 "Always advertise default route\n"
6332 "OSPF default metric\n"
6333 "OSPF metric\n"
6334 "Route map reference\n"
6335 "Pointer to route-map entries\n")
6336{
paul020709f2003-04-04 02:44:16 +00006337 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006338 int metric = -1;
6339
6340 /* Get metric value. */
6341 if (argc >= 1)
6342 if (!str2metric (argv[0], &metric))
6343 return CMD_WARNING;
6344
6345 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006346 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006347 else
paul020709f2003-04-04 02:44:16 +00006348 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006349
paul020709f2003-04-04 02:44:16 +00006350 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6351 -1, metric);
paul718e3742002-12-13 20:15:29 +00006352}
6353
6354DEFUN (ospf_default_information_originate_always_routemap,
6355 ospf_default_information_originate_always_routemap_cmd,
6356 "default-information originate always route-map WORD",
6357 "Control distribution of default information\n"
6358 "Distribute a default route\n"
6359 "Always advertise default route\n"
6360 "Route map reference\n"
6361 "Pointer to route-map entries\n")
6362{
paul020709f2003-04-04 02:44:16 +00006363 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006364
paul020709f2003-04-04 02:44:16 +00006365 if (argc == 1)
6366 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6367 else
6368 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6369
6370 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006371}
6372
6373DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6374 ospf_default_information_originate_always_type_metric_routemap_cmd,
6375 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6376 "Control distribution of default information\n"
6377 "Distribute a default route\n"
6378 "Always advertise default route\n"
6379 "OSPF metric type for default routes\n"
6380 "Set OSPF External Type 1 metrics\n"
6381 "Set OSPF External Type 2 metrics\n"
6382 "OSPF default metric\n"
6383 "OSPF metric\n"
6384 "Route map reference\n"
6385 "Pointer to route-map entries\n")
6386{
paul020709f2003-04-04 02:44:16 +00006387 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006388 int type = -1;
6389 int metric = -1;
6390
6391 /* Get metric type. */
6392 if (argc >= 1)
6393 if (!str2metric_type (argv[0], &type))
6394 return CMD_WARNING;
6395
6396 /* Get metric value. */
6397 if (argc >= 2)
6398 if (!str2metric (argv[1], &metric))
6399 return CMD_WARNING;
6400
6401 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006402 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006403 else
paul020709f2003-04-04 02:44:16 +00006404 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006405
paul020709f2003-04-04 02:44:16 +00006406 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006407 type, metric);
6408}
6409
6410ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6411 ospf_default_information_originate_always_type_metric_cmd,
6412 "default-information originate always metric-type (1|2) metric <0-16777214>",
6413 "Control distribution of default information\n"
6414 "Distribute a default route\n"
6415 "Always advertise default route\n"
6416 "OSPF metric type for default routes\n"
6417 "Set OSPF External Type 1 metrics\n"
6418 "Set OSPF External Type 2 metrics\n"
6419 "OSPF default metric\n"
6420 "OSPF metric\n")
6421
6422ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6423 ospf_default_information_originate_always_type_cmd,
6424 "default-information originate always metric-type (1|2)",
6425 "Control distribution of default information\n"
6426 "Distribute a default route\n"
6427 "Always advertise default route\n"
6428 "OSPF metric type for default routes\n"
6429 "Set OSPF External Type 1 metrics\n"
6430 "Set OSPF External Type 2 metrics\n")
6431
6432DEFUN (ospf_default_information_originate_always_type_routemap,
6433 ospf_default_information_originate_always_type_routemap_cmd,
6434 "default-information originate always metric-type (1|2) route-map WORD",
6435 "Control distribution of default information\n"
6436 "Distribute a default route\n"
6437 "Always advertise default route\n"
6438 "OSPF metric type for default routes\n"
6439 "Set OSPF External Type 1 metrics\n"
6440 "Set OSPF External Type 2 metrics\n"
6441 "Route map reference\n"
6442 "Pointer to route-map entries\n")
6443{
paul020709f2003-04-04 02:44:16 +00006444 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006445 int type = -1;
6446
6447 /* Get metric type. */
6448 if (argc >= 1)
6449 if (!str2metric_type (argv[0], &type))
6450 return CMD_WARNING;
6451
6452 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006453 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006454 else
paul020709f2003-04-04 02:44:16 +00006455 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006456
paul020709f2003-04-04 02:44:16 +00006457 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006458 type, -1);
6459}
6460
6461DEFUN (no_ospf_default_information_originate,
6462 no_ospf_default_information_originate_cmd,
6463 "no default-information originate",
6464 NO_STR
6465 "Control distribution of default information\n"
6466 "Distribute a default route\n")
6467{
paul68980082003-03-25 05:07:42 +00006468 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006469 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006470
6471 p.family = AF_INET;
6472 p.prefix.s_addr = 0;
6473 p.prefixlen = 0;
6474
ajs5339cfd2005-09-19 13:28:05 +00006475 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006476
6477 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6478 ospf_external_info_delete (DEFAULT_ROUTE, p);
6479 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6480 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6481 }
6482
paul020709f2003-04-04 02:44:16 +00006483 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6484 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006485}
6486
6487DEFUN (ospf_default_metric,
6488 ospf_default_metric_cmd,
6489 "default-metric <0-16777214>",
6490 "Set metric of redistributed routes\n"
6491 "Default metric\n")
6492{
paul68980082003-03-25 05:07:42 +00006493 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006494 int metric = -1;
6495
6496 if (!str2metric (argv[0], &metric))
6497 return CMD_WARNING;
6498
paul68980082003-03-25 05:07:42 +00006499 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006500
6501 return CMD_SUCCESS;
6502}
6503
6504DEFUN (no_ospf_default_metric,
6505 no_ospf_default_metric_cmd,
6506 "no default-metric",
6507 NO_STR
6508 "Set metric of redistributed routes\n")
6509{
paul68980082003-03-25 05:07:42 +00006510 struct ospf *ospf = vty->index;
6511
6512 ospf->default_metric = -1;
6513
paul718e3742002-12-13 20:15:29 +00006514 return CMD_SUCCESS;
6515}
6516
6517ALIAS (no_ospf_default_metric,
6518 no_ospf_default_metric_val_cmd,
6519 "no default-metric <0-16777214>",
6520 NO_STR
6521 "Set metric of redistributed routes\n"
6522 "Default metric\n")
6523
6524DEFUN (ospf_distance,
6525 ospf_distance_cmd,
6526 "distance <1-255>",
6527 "Define an administrative distance\n"
6528 "OSPF Administrative distance\n")
6529{
paul68980082003-03-25 05:07:42 +00006530 struct ospf *ospf = vty->index;
6531
6532 ospf->distance_all = atoi (argv[0]);
6533
paul718e3742002-12-13 20:15:29 +00006534 return CMD_SUCCESS;
6535}
6536
6537DEFUN (no_ospf_distance,
6538 no_ospf_distance_cmd,
6539 "no distance <1-255>",
6540 NO_STR
6541 "Define an administrative distance\n"
6542 "OSPF Administrative distance\n")
6543{
paul68980082003-03-25 05:07:42 +00006544 struct ospf *ospf = vty->index;
6545
6546 ospf->distance_all = 0;
6547
paul718e3742002-12-13 20:15:29 +00006548 return CMD_SUCCESS;
6549}
6550
6551DEFUN (no_ospf_distance_ospf,
6552 no_ospf_distance_ospf_cmd,
6553 "no distance ospf",
6554 NO_STR
6555 "Define an administrative distance\n"
6556 "OSPF Administrative distance\n"
6557 "OSPF Distance\n")
6558{
paul68980082003-03-25 05:07:42 +00006559 struct ospf *ospf = vty->index;
6560
6561 ospf->distance_intra = 0;
6562 ospf->distance_inter = 0;
6563 ospf->distance_external = 0;
6564
paul718e3742002-12-13 20:15:29 +00006565 return CMD_SUCCESS;
6566}
6567
6568DEFUN (ospf_distance_ospf_intra,
6569 ospf_distance_ospf_intra_cmd,
6570 "distance ospf intra-area <1-255>",
6571 "Define an administrative distance\n"
6572 "OSPF Administrative distance\n"
6573 "Intra-area routes\n"
6574 "Distance for intra-area routes\n")
6575{
paul68980082003-03-25 05:07:42 +00006576 struct ospf *ospf = vty->index;
6577
6578 ospf->distance_intra = atoi (argv[0]);
6579
paul718e3742002-12-13 20:15:29 +00006580 return CMD_SUCCESS;
6581}
6582
6583DEFUN (ospf_distance_ospf_intra_inter,
6584 ospf_distance_ospf_intra_inter_cmd,
6585 "distance ospf intra-area <1-255> inter-area <1-255>",
6586 "Define an administrative distance\n"
6587 "OSPF Administrative distance\n"
6588 "Intra-area routes\n"
6589 "Distance for intra-area routes\n"
6590 "Inter-area routes\n"
6591 "Distance for inter-area routes\n")
6592{
paul68980082003-03-25 05:07:42 +00006593 struct ospf *ospf = vty->index;
6594
6595 ospf->distance_intra = atoi (argv[0]);
6596 ospf->distance_inter = atoi (argv[1]);
6597
paul718e3742002-12-13 20:15:29 +00006598 return CMD_SUCCESS;
6599}
6600
6601DEFUN (ospf_distance_ospf_intra_external,
6602 ospf_distance_ospf_intra_external_cmd,
6603 "distance ospf intra-area <1-255> external <1-255>",
6604 "Define an administrative distance\n"
6605 "OSPF Administrative distance\n"
6606 "Intra-area routes\n"
6607 "Distance for intra-area routes\n"
6608 "External routes\n"
6609 "Distance for external routes\n")
6610{
paul68980082003-03-25 05:07:42 +00006611 struct ospf *ospf = vty->index;
6612
6613 ospf->distance_intra = atoi (argv[0]);
6614 ospf->distance_external = atoi (argv[1]);
6615
paul718e3742002-12-13 20:15:29 +00006616 return CMD_SUCCESS;
6617}
6618
6619DEFUN (ospf_distance_ospf_intra_inter_external,
6620 ospf_distance_ospf_intra_inter_external_cmd,
6621 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6622 "Define an administrative distance\n"
6623 "OSPF Administrative distance\n"
6624 "Intra-area routes\n"
6625 "Distance for intra-area routes\n"
6626 "Inter-area routes\n"
6627 "Distance for inter-area routes\n"
6628 "External routes\n"
6629 "Distance for external routes\n")
6630{
paul68980082003-03-25 05:07:42 +00006631 struct ospf *ospf = vty->index;
6632
6633 ospf->distance_intra = atoi (argv[0]);
6634 ospf->distance_inter = atoi (argv[1]);
6635 ospf->distance_external = atoi (argv[2]);
6636
paul718e3742002-12-13 20:15:29 +00006637 return CMD_SUCCESS;
6638}
6639
6640DEFUN (ospf_distance_ospf_intra_external_inter,
6641 ospf_distance_ospf_intra_external_inter_cmd,
6642 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6643 "Define an administrative distance\n"
6644 "OSPF Administrative distance\n"
6645 "Intra-area routes\n"
6646 "Distance for intra-area routes\n"
6647 "External routes\n"
6648 "Distance for external routes\n"
6649 "Inter-area routes\n"
6650 "Distance for inter-area routes\n")
6651{
paul68980082003-03-25 05:07:42 +00006652 struct ospf *ospf = vty->index;
6653
6654 ospf->distance_intra = atoi (argv[0]);
6655 ospf->distance_external = atoi (argv[1]);
6656 ospf->distance_inter = atoi (argv[2]);
6657
paul718e3742002-12-13 20:15:29 +00006658 return CMD_SUCCESS;
6659}
6660
6661DEFUN (ospf_distance_ospf_inter,
6662 ospf_distance_ospf_inter_cmd,
6663 "distance ospf inter-area <1-255>",
6664 "Define an administrative distance\n"
6665 "OSPF Administrative distance\n"
6666 "Inter-area routes\n"
6667 "Distance for inter-area routes\n")
6668{
paul68980082003-03-25 05:07:42 +00006669 struct ospf *ospf = vty->index;
6670
6671 ospf->distance_inter = atoi (argv[0]);
6672
paul718e3742002-12-13 20:15:29 +00006673 return CMD_SUCCESS;
6674}
6675
6676DEFUN (ospf_distance_ospf_inter_intra,
6677 ospf_distance_ospf_inter_intra_cmd,
6678 "distance ospf inter-area <1-255> intra-area <1-255>",
6679 "Define an administrative distance\n"
6680 "OSPF Administrative distance\n"
6681 "Inter-area routes\n"
6682 "Distance for inter-area routes\n"
6683 "Intra-area routes\n"
6684 "Distance for intra-area routes\n")
6685{
paul68980082003-03-25 05:07:42 +00006686 struct ospf *ospf = vty->index;
6687
6688 ospf->distance_inter = atoi (argv[0]);
6689 ospf->distance_intra = atoi (argv[1]);
6690
paul718e3742002-12-13 20:15:29 +00006691 return CMD_SUCCESS;
6692}
6693
6694DEFUN (ospf_distance_ospf_inter_external,
6695 ospf_distance_ospf_inter_external_cmd,
6696 "distance ospf inter-area <1-255> external <1-255>",
6697 "Define an administrative distance\n"
6698 "OSPF Administrative distance\n"
6699 "Inter-area routes\n"
6700 "Distance for inter-area routes\n"
6701 "External routes\n"
6702 "Distance for external routes\n")
6703{
paul68980082003-03-25 05:07:42 +00006704 struct ospf *ospf = vty->index;
6705
6706 ospf->distance_inter = atoi (argv[0]);
6707 ospf->distance_external = atoi (argv[1]);
6708
paul718e3742002-12-13 20:15:29 +00006709 return CMD_SUCCESS;
6710}
6711
6712DEFUN (ospf_distance_ospf_inter_intra_external,
6713 ospf_distance_ospf_inter_intra_external_cmd,
6714 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6715 "Define an administrative distance\n"
6716 "OSPF Administrative distance\n"
6717 "Inter-area routes\n"
6718 "Distance for inter-area routes\n"
6719 "Intra-area routes\n"
6720 "Distance for intra-area routes\n"
6721 "External routes\n"
6722 "Distance for external routes\n")
6723{
paul68980082003-03-25 05:07:42 +00006724 struct ospf *ospf = vty->index;
6725
6726 ospf->distance_inter = atoi (argv[0]);
6727 ospf->distance_intra = atoi (argv[1]);
6728 ospf->distance_external = atoi (argv[2]);
6729
paul718e3742002-12-13 20:15:29 +00006730 return CMD_SUCCESS;
6731}
6732
6733DEFUN (ospf_distance_ospf_inter_external_intra,
6734 ospf_distance_ospf_inter_external_intra_cmd,
6735 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6736 "Define an administrative distance\n"
6737 "OSPF Administrative distance\n"
6738 "Inter-area routes\n"
6739 "Distance for inter-area routes\n"
6740 "External routes\n"
6741 "Distance for external routes\n"
6742 "Intra-area routes\n"
6743 "Distance for intra-area routes\n")
6744{
paul68980082003-03-25 05:07:42 +00006745 struct ospf *ospf = vty->index;
6746
6747 ospf->distance_inter = atoi (argv[0]);
6748 ospf->distance_external = atoi (argv[1]);
6749 ospf->distance_intra = atoi (argv[2]);
6750
paul718e3742002-12-13 20:15:29 +00006751 return CMD_SUCCESS;
6752}
6753
6754DEFUN (ospf_distance_ospf_external,
6755 ospf_distance_ospf_external_cmd,
6756 "distance ospf external <1-255>",
6757 "Define an administrative distance\n"
6758 "OSPF Administrative distance\n"
6759 "External routes\n"
6760 "Distance for external routes\n")
6761{
paul68980082003-03-25 05:07:42 +00006762 struct ospf *ospf = vty->index;
6763
6764 ospf->distance_external = atoi (argv[0]);
6765
paul718e3742002-12-13 20:15:29 +00006766 return CMD_SUCCESS;
6767}
6768
6769DEFUN (ospf_distance_ospf_external_intra,
6770 ospf_distance_ospf_external_intra_cmd,
6771 "distance ospf external <1-255> intra-area <1-255>",
6772 "Define an administrative distance\n"
6773 "OSPF Administrative distance\n"
6774 "External routes\n"
6775 "Distance for external routes\n"
6776 "Intra-area routes\n"
6777 "Distance for intra-area routes\n")
6778{
paul68980082003-03-25 05:07:42 +00006779 struct ospf *ospf = vty->index;
6780
6781 ospf->distance_external = atoi (argv[0]);
6782 ospf->distance_intra = atoi (argv[1]);
6783
paul718e3742002-12-13 20:15:29 +00006784 return CMD_SUCCESS;
6785}
6786
6787DEFUN (ospf_distance_ospf_external_inter,
6788 ospf_distance_ospf_external_inter_cmd,
6789 "distance ospf external <1-255> inter-area <1-255>",
6790 "Define an administrative distance\n"
6791 "OSPF Administrative distance\n"
6792 "External routes\n"
6793 "Distance for external routes\n"
6794 "Inter-area routes\n"
6795 "Distance for inter-area routes\n")
6796{
paul68980082003-03-25 05:07:42 +00006797 struct ospf *ospf = vty->index;
6798
6799 ospf->distance_external = atoi (argv[0]);
6800 ospf->distance_inter = atoi (argv[1]);
6801
paul718e3742002-12-13 20:15:29 +00006802 return CMD_SUCCESS;
6803}
6804
6805DEFUN (ospf_distance_ospf_external_intra_inter,
6806 ospf_distance_ospf_external_intra_inter_cmd,
6807 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6808 "Define an administrative distance\n"
6809 "OSPF Administrative distance\n"
6810 "External routes\n"
6811 "Distance for external routes\n"
6812 "Intra-area routes\n"
6813 "Distance for intra-area routes\n"
6814 "Inter-area routes\n"
6815 "Distance for inter-area routes\n")
6816{
paul68980082003-03-25 05:07:42 +00006817 struct ospf *ospf = vty->index;
6818
6819 ospf->distance_external = atoi (argv[0]);
6820 ospf->distance_intra = atoi (argv[1]);
6821 ospf->distance_inter = atoi (argv[2]);
6822
paul718e3742002-12-13 20:15:29 +00006823 return CMD_SUCCESS;
6824}
6825
6826DEFUN (ospf_distance_ospf_external_inter_intra,
6827 ospf_distance_ospf_external_inter_intra_cmd,
6828 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6829 "Define an administrative distance\n"
6830 "OSPF Administrative distance\n"
6831 "External routes\n"
6832 "Distance for external routes\n"
6833 "Inter-area routes\n"
6834 "Distance for inter-area routes\n"
6835 "Intra-area routes\n"
6836 "Distance for intra-area routes\n")
6837{
paul68980082003-03-25 05:07:42 +00006838 struct ospf *ospf = vty->index;
6839
6840 ospf->distance_external = atoi (argv[0]);
6841 ospf->distance_inter = atoi (argv[1]);
6842 ospf->distance_intra = atoi (argv[2]);
6843
paul718e3742002-12-13 20:15:29 +00006844 return CMD_SUCCESS;
6845}
6846
6847DEFUN (ospf_distance_source,
6848 ospf_distance_source_cmd,
6849 "distance <1-255> A.B.C.D/M",
6850 "Administrative distance\n"
6851 "Distance value\n"
6852 "IP source prefix\n")
6853{
paul020709f2003-04-04 02:44:16 +00006854 struct ospf *ospf = vty->index;
6855
6856 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006857
paul718e3742002-12-13 20:15:29 +00006858 return CMD_SUCCESS;
6859}
6860
6861DEFUN (no_ospf_distance_source,
6862 no_ospf_distance_source_cmd,
6863 "no distance <1-255> A.B.C.D/M",
6864 NO_STR
6865 "Administrative distance\n"
6866 "Distance value\n"
6867 "IP source prefix\n")
6868{
paul020709f2003-04-04 02:44:16 +00006869 struct ospf *ospf = vty->index;
6870
6871 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6872
paul718e3742002-12-13 20:15:29 +00006873 return CMD_SUCCESS;
6874}
6875
6876DEFUN (ospf_distance_source_access_list,
6877 ospf_distance_source_access_list_cmd,
6878 "distance <1-255> A.B.C.D/M WORD",
6879 "Administrative distance\n"
6880 "Distance value\n"
6881 "IP source prefix\n"
6882 "Access list name\n")
6883{
paul020709f2003-04-04 02:44:16 +00006884 struct ospf *ospf = vty->index;
6885
6886 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6887
paul718e3742002-12-13 20:15:29 +00006888 return CMD_SUCCESS;
6889}
6890
6891DEFUN (no_ospf_distance_source_access_list,
6892 no_ospf_distance_source_access_list_cmd,
6893 "no distance <1-255> A.B.C.D/M WORD",
6894 NO_STR
6895 "Administrative distance\n"
6896 "Distance value\n"
6897 "IP source prefix\n"
6898 "Access list name\n")
6899{
paul020709f2003-04-04 02:44:16 +00006900 struct ospf *ospf = vty->index;
6901
6902 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6903
paul718e3742002-12-13 20:15:29 +00006904 return CMD_SUCCESS;
6905}
6906
vincentba682532005-09-29 13:52:57 +00006907DEFUN (ip_ospf_mtu_ignore,
6908 ip_ospf_mtu_ignore_addr_cmd,
6909 "ip ospf mtu-ignore A.B.C.D",
6910 "IP Information\n"
6911 "OSPF interface commands\n"
6912 "Disable mtu mismatch detection\n"
6913 "Address of interface")
6914{
6915 struct interface *ifp = vty->index;
6916 struct in_addr addr;
6917 int ret;
6918
6919 struct ospf_if_params *params;
6920 params = IF_DEF_PARAMS (ifp);
6921
6922 if (argc == 1)
6923 {
6924 ret = inet_aton(argv[0], &addr);
6925 if (!ret)
6926 {
6927 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6928 VTY_NEWLINE);
6929 return CMD_WARNING;
6930 }
6931 params = ospf_get_if_params (ifp, addr);
6932 ospf_if_update_params (ifp, addr);
6933 }
6934 params->mtu_ignore = 1;
6935 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6936 SET_IF_PARAM (params, mtu_ignore);
6937 else
6938 {
6939 UNSET_IF_PARAM (params, mtu_ignore);
6940 if (params != IF_DEF_PARAMS (ifp))
6941 {
6942 ospf_free_if_params (ifp, addr);
6943 ospf_if_update_params (ifp, addr);
6944 }
6945 }
6946 return CMD_SUCCESS;
6947}
6948
6949ALIAS (ip_ospf_mtu_ignore,
6950 ip_ospf_mtu_ignore_cmd,
6951 "ip ospf mtu-ignore",
6952 "IP Information\n"
6953 "OSPF interface commands\n"
6954 "Disable mtu mismatch detection\n")
6955
6956
6957DEFUN (no_ip_ospf_mtu_ignore,
6958 no_ip_ospf_mtu_ignore_addr_cmd,
6959 "no ip ospf mtu-ignore A.B.C.D",
6960 "IP Information\n"
6961 "OSPF interface commands\n"
6962 "Disable mtu mismatch detection\n"
6963 "Address of interface")
6964{
6965 struct interface *ifp = vty->index;
6966 struct in_addr addr;
6967 int ret;
6968
6969 struct ospf_if_params *params;
6970 params = IF_DEF_PARAMS (ifp);
6971
6972 if (argc == 1)
6973 {
6974 ret = inet_aton(argv[0], &addr);
6975 if (!ret)
6976 {
6977 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6978 VTY_NEWLINE);
6979 return CMD_WARNING;
6980 }
6981 params = ospf_get_if_params (ifp, addr);
6982 ospf_if_update_params (ifp, addr);
6983 }
6984 params->mtu_ignore = 0;
6985 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6986 SET_IF_PARAM (params, mtu_ignore);
6987 else
6988 {
6989 UNSET_IF_PARAM (params, mtu_ignore);
6990 if (params != IF_DEF_PARAMS (ifp))
6991 {
6992 ospf_free_if_params (ifp, addr);
6993 ospf_if_update_params (ifp, addr);
6994 }
6995 }
6996 return CMD_SUCCESS;
6997}
6998
6999ALIAS (no_ip_ospf_mtu_ignore,
7000 no_ip_ospf_mtu_ignore_cmd,
7001 "no ip ospf mtu-ignore",
7002 "IP Information\n"
7003 "OSPF interface commands\n"
7004 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00007005
7006DEFUN (ospf_max_metric_router_lsa_admin,
7007 ospf_max_metric_router_lsa_admin_cmd,
7008 "max-metric router-lsa administrative",
7009 "OSPF maximum / infinite-distance metric\n"
7010 "Advertise own Router-LSA with infinite distance (stub router)\n"
7011 "Administratively applied, for an indefinite period\n")
7012{
7013 struct listnode *ln;
7014 struct ospf_area *area;
7015 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00007016
paul88d6cf32005-10-29 12:50:09 +00007017 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7018 {
7019 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7020
7021 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
Paul Jakmac363d382010-01-24 22:42:13 +00007022 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007023 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08007024
7025 /* Allows for areas configured later to get the property */
7026 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
7027
paul88d6cf32005-10-29 12:50:09 +00007028 return CMD_SUCCESS;
7029}
7030
7031DEFUN (no_ospf_max_metric_router_lsa_admin,
7032 no_ospf_max_metric_router_lsa_admin_cmd,
7033 "no max-metric router-lsa administrative",
7034 NO_STR
7035 "OSPF maximum / infinite-distance metric\n"
7036 "Advertise own Router-LSA with infinite distance (stub router)\n"
7037 "Administratively applied, for an indefinite period\n")
7038{
7039 struct listnode *ln;
7040 struct ospf_area *area;
7041 struct ospf *ospf = vty->index;
7042
7043 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7044 {
7045 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7046
7047 /* Don't trample on the start-up stub timer */
7048 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
7049 && !area->t_stub_router)
7050 {
7051 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00007052 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007053 }
7054 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08007055 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
paul88d6cf32005-10-29 12:50:09 +00007056 return CMD_SUCCESS;
7057}
7058
7059DEFUN (ospf_max_metric_router_lsa_startup,
7060 ospf_max_metric_router_lsa_startup_cmd,
7061 "max-metric router-lsa on-startup <5-86400>",
7062 "OSPF maximum / infinite-distance metric\n"
7063 "Advertise own Router-LSA with infinite distance (stub router)\n"
7064 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7065 "Time (seconds) to advertise self as stub-router\n")
7066{
7067 unsigned int seconds;
7068 struct ospf *ospf = vty->index;
7069
7070 if (argc != 1)
7071 {
7072 vty_out (vty, "%% Must supply stub-router period");
7073 return CMD_WARNING;
7074 }
7075
7076 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
7077
7078 ospf->stub_router_startup_time = seconds;
7079
7080 return CMD_SUCCESS;
7081}
7082
7083DEFUN (no_ospf_max_metric_router_lsa_startup,
7084 no_ospf_max_metric_router_lsa_startup_cmd,
7085 "no max-metric router-lsa on-startup",
7086 NO_STR
7087 "OSPF maximum / infinite-distance metric\n"
7088 "Advertise own Router-LSA with infinite distance (stub router)\n"
7089 "Automatically advertise stub Router-LSA on startup of OSPF\n")
7090{
7091 struct listnode *ln;
7092 struct ospf_area *area;
7093 struct ospf *ospf = vty->index;
7094
7095 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7096
7097 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7098 {
7099 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
7100 OSPF_TIMER_OFF (area->t_stub_router);
7101
7102 /* Don't trample on admin stub routed */
7103 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7104 {
7105 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00007106 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007107 }
7108 }
7109 return CMD_SUCCESS;
7110}
7111
7112DEFUN (ospf_max_metric_router_lsa_shutdown,
7113 ospf_max_metric_router_lsa_shutdown_cmd,
7114 "max-metric router-lsa on-shutdown <5-86400>",
7115 "OSPF maximum / infinite-distance metric\n"
7116 "Advertise own Router-LSA with infinite distance (stub router)\n"
7117 "Advertise stub-router prior to full shutdown of OSPF\n"
7118 "Time (seconds) to wait till full shutdown\n")
7119{
7120 unsigned int seconds;
7121 struct ospf *ospf = vty->index;
7122
7123 if (argc != 1)
7124 {
7125 vty_out (vty, "%% Must supply stub-router shutdown period");
7126 return CMD_WARNING;
7127 }
7128
7129 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
7130
7131 ospf->stub_router_shutdown_time = seconds;
7132
7133 return CMD_SUCCESS;
7134}
7135
7136DEFUN (no_ospf_max_metric_router_lsa_shutdown,
7137 no_ospf_max_metric_router_lsa_shutdown_cmd,
7138 "no max-metric router-lsa on-shutdown",
7139 NO_STR
7140 "OSPF maximum / infinite-distance metric\n"
7141 "Advertise own Router-LSA with infinite distance (stub router)\n"
7142 "Advertise stub-router prior to full shutdown of OSPF\n")
7143{
7144 struct ospf *ospf = vty->index;
7145
7146 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7147
7148 return CMD_SUCCESS;
7149}
7150
7151static void
7152config_write_stub_router (struct vty *vty, struct ospf *ospf)
7153{
7154 struct listnode *ln;
7155 struct ospf_area *area;
7156
7157 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7158 vty_out (vty, " max-metric router-lsa on-startup %u%s",
7159 ospf->stub_router_startup_time, VTY_NEWLINE);
7160 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7161 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
7162 ospf->stub_router_shutdown_time, VTY_NEWLINE);
7163 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7164 {
7165 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7166 {
7167 vty_out (vty, " max-metric router-lsa administrative%s",
7168 VTY_NEWLINE);
7169 break;
7170 }
7171 }
7172 return;
7173}
7174
paul4dadc292005-05-06 21:37:42 +00007175static void
paul718e3742002-12-13 20:15:29 +00007176show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7177{
7178 struct route_node *rn;
7179 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007180 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007181 struct ospf_path *path;
7182
7183 vty_out (vty, "============ OSPF network routing table ============%s",
7184 VTY_NEWLINE);
7185
7186 for (rn = route_top (rt); rn; rn = route_next (rn))
7187 if ((or = rn->info) != NULL)
7188 {
7189 char buf1[19];
7190 snprintf (buf1, 19, "%s/%d",
7191 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7192
7193 switch (or->path_type)
7194 {
7195 case OSPF_PATH_INTER_AREA:
7196 if (or->type == OSPF_DESTINATION_NETWORK)
7197 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7198 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7199 else if (or->type == OSPF_DESTINATION_DISCARD)
7200 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7201 break;
7202 case OSPF_PATH_INTRA_AREA:
7203 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7204 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7205 break;
7206 default:
7207 break;
7208 }
7209
7210 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007211 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007212 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007213 if (if_lookup_by_index(path->ifindex))
paul96735ee2003-08-10 02:51:22 +00007214 {
7215 if (path->nexthop.s_addr == 0)
7216 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007217 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007218 else
7219 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007220 inet_ntoa (path->nexthop),
7221 ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007222 }
7223 }
paul718e3742002-12-13 20:15:29 +00007224 }
7225 vty_out (vty, "%s", VTY_NEWLINE);
7226}
7227
paul4dadc292005-05-06 21:37:42 +00007228static void
paul718e3742002-12-13 20:15:29 +00007229show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7230{
7231 struct route_node *rn;
7232 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007233 struct listnode *pnode;
7234 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007235 struct ospf_path *path;
7236
7237 vty_out (vty, "============ OSPF router routing table =============%s",
7238 VTY_NEWLINE);
7239 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7240 if (rn->info)
7241 {
7242 int flag = 0;
7243
7244 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7245
paul1eb8ef22005-04-07 07:30:20 +00007246 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7247 {
7248 if (flag++)
7249 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007250
paul1eb8ef22005-04-07 07:30:20 +00007251 /* Show path. */
7252 vty_out (vty, "%s [%d] area: %s",
7253 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7254 or->cost, inet_ntoa (or->u.std.area_id));
7255 /* Show flags. */
7256 vty_out (vty, "%s%s%s",
7257 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7258 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7259 VTY_NEWLINE);
7260
7261 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7262 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007263 if (if_lookup_by_index(path->ifindex))
hasso54bedb52005-08-17 13:31:47 +00007264 {
7265 if (path->nexthop.s_addr == 0)
7266 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007267 "", ifindex2ifname (path->ifindex),
7268 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007269 else
7270 vty_out (vty, "%24s via %s, %s%s", "",
7271 inet_ntoa (path->nexthop),
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007272 ifindex2ifname (path->ifindex),
7273 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007274 }
paul1eb8ef22005-04-07 07:30:20 +00007275 }
7276 }
paul718e3742002-12-13 20:15:29 +00007277 }
7278 vty_out (vty, "%s", VTY_NEWLINE);
7279}
7280
paul4dadc292005-05-06 21:37:42 +00007281static void
paul718e3742002-12-13 20:15:29 +00007282show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7283{
7284 struct route_node *rn;
7285 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007286 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007287 struct ospf_path *path;
7288
7289 vty_out (vty, "============ OSPF external routing table ===========%s",
7290 VTY_NEWLINE);
7291 for (rn = route_top (rt); rn; rn = route_next (rn))
7292 if ((er = rn->info) != NULL)
7293 {
7294 char buf1[19];
7295 snprintf (buf1, 19, "%s/%d",
7296 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7297
7298 switch (er->path_type)
7299 {
7300 case OSPF_PATH_TYPE1_EXTERNAL:
7301 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7302 er->cost, er->u.ext.tag, VTY_NEWLINE);
7303 break;
7304 case OSPF_PATH_TYPE2_EXTERNAL:
7305 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7306 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7307 break;
7308 }
7309
paul1eb8ef22005-04-07 07:30:20 +00007310 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007311 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007312 if (if_lookup_by_index(path->ifindex))
paul718e3742002-12-13 20:15:29 +00007313 {
7314 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007315 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007316 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007317 else
7318 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007319 inet_ntoa (path->nexthop),
7320 ifindex2ifname (path->ifindex),
paul96735ee2003-08-10 02:51:22 +00007321 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007322 }
7323 }
7324 }
7325 vty_out (vty, "%s", VTY_NEWLINE);
7326}
7327
paul718e3742002-12-13 20:15:29 +00007328DEFUN (show_ip_ospf_border_routers,
7329 show_ip_ospf_border_routers_cmd,
7330 "show ip ospf border-routers",
7331 SHOW_STR
7332 IP_STR
7333 "show all the ABR's and ASBR's\n"
7334 "for this area\n")
7335{
paul020709f2003-04-04 02:44:16 +00007336 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007337
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007338 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007339 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007340 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007341 return CMD_SUCCESS;
7342 }
7343
paul68980082003-03-25 05:07:42 +00007344 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007345 {
7346 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7347 return CMD_SUCCESS;
7348 }
7349
7350 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007351 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007352
7353 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007354 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007355
7356 return CMD_SUCCESS;
7357}
paul718e3742002-12-13 20:15:29 +00007358
7359DEFUN (show_ip_ospf_route,
7360 show_ip_ospf_route_cmd,
7361 "show ip ospf route",
7362 SHOW_STR
7363 IP_STR
7364 "OSPF information\n"
7365 "OSPF routing table\n")
7366{
paul020709f2003-04-04 02:44:16 +00007367 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007368
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007369 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007370 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007371 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007372 return CMD_SUCCESS;
7373 }
7374
paul68980082003-03-25 05:07:42 +00007375 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007376 {
7377 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7378 return CMD_SUCCESS;
7379 }
7380
7381 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007382 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007383
7384 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007385 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007386
7387 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007388 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007389
7390 return CMD_SUCCESS;
7391}
7392
7393
hassoeb1ce602004-10-08 08:17:22 +00007394const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007395{
7396 "unknown",
7397 "standard",
7398 "ibm",
7399 "cisco",
7400 "shortcut"
7401};
7402
hassoeb1ce602004-10-08 08:17:22 +00007403const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007404{
7405 "default",
7406 "enable",
7407 "disable"
7408};
7409
7410
paul4dadc292005-05-06 21:37:42 +00007411static void
paul718e3742002-12-13 20:15:29 +00007412area_id2str (char *buf, int length, struct ospf_area *area)
7413{
7414 memset (buf, 0, length);
7415
7416 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7417 strncpy (buf, inet_ntoa (area->area_id), length);
7418 else
7419 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7420}
7421
7422
hassoeb1ce602004-10-08 08:17:22 +00007423const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007424{
7425 "unknown", /* should never be used. */
7426 "point-to-point",
7427 "broadcast",
7428 "non-broadcast",
7429 "point-to-multipoint",
7430 "virtual-link", /* should never be used. */
7431 "loopback"
7432};
7433
7434/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007435static int
paul718e3742002-12-13 20:15:29 +00007436config_write_interface (struct vty *vty)
7437{
hasso52dc7ee2004-09-23 19:18:23 +00007438 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007439 struct interface *ifp;
7440 struct crypt_key *ck;
7441 int write = 0;
7442 struct route_node *rn = NULL;
7443 struct ospf_if_params *params;
7444
paul1eb8ef22005-04-07 07:30:20 +00007445 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007446 {
paul718e3742002-12-13 20:15:29 +00007447 if (memcmp (ifp->name, "VLINK", 5) == 0)
7448 continue;
7449
7450 vty_out (vty, "!%s", VTY_NEWLINE);
7451 vty_out (vty, "interface %s%s", ifp->name,
7452 VTY_NEWLINE);
7453 if (ifp->desc)
7454 vty_out (vty, " description %s%s", ifp->desc,
7455 VTY_NEWLINE);
7456
7457 write++;
7458
7459 params = IF_DEF_PARAMS (ifp);
7460
7461 do {
7462 /* Interface Network print. */
7463 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007464 params->type != OSPF_IFTYPE_LOOPBACK)
7465 {
ajsbc18d612004-12-15 15:07:19 +00007466 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007467 {
7468 vty_out (vty, " ip ospf network %s",
7469 ospf_int_type_str[params->type]);
7470 if (params != IF_DEF_PARAMS (ifp))
7471 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7472 vty_out (vty, "%s", VTY_NEWLINE);
7473 }
paul718e3742002-12-13 20:15:29 +00007474 }
7475
7476 /* OSPF interface authentication print */
7477 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7478 params->auth_type != OSPF_AUTH_NOTSET)
7479 {
hassoeb1ce602004-10-08 08:17:22 +00007480 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007481
7482 /* Translation tables are not that much help here due to syntax
7483 of the simple option */
7484 switch (params->auth_type)
7485 {
7486
7487 case OSPF_AUTH_NULL:
7488 auth_str = " null";
7489 break;
7490
7491 case OSPF_AUTH_SIMPLE:
7492 auth_str = "";
7493 break;
7494
7495 case OSPF_AUTH_CRYPTOGRAPHIC:
7496 auth_str = " message-digest";
7497 break;
7498
7499 default:
7500 auth_str = "";
7501 break;
7502 }
7503
7504 vty_out (vty, " ip ospf authentication%s", auth_str);
7505 if (params != IF_DEF_PARAMS (ifp))
7506 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7507 vty_out (vty, "%s", VTY_NEWLINE);
7508 }
7509
7510 /* Simple Authentication Password print. */
7511 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7512 params->auth_simple[0] != '\0')
7513 {
7514 vty_out (vty, " ip ospf authentication-key %s",
7515 params->auth_simple);
7516 if (params != IF_DEF_PARAMS (ifp))
7517 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7518 vty_out (vty, "%s", VTY_NEWLINE);
7519 }
7520
7521 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007522 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007523 {
paul718e3742002-12-13 20:15:29 +00007524 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7525 ck->key_id, ck->auth_key);
7526 if (params != IF_DEF_PARAMS (ifp))
7527 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7528 vty_out (vty, "%s", VTY_NEWLINE);
7529 }
7530
7531 /* Interface Output Cost print. */
7532 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7533 {
7534 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7535 if (params != IF_DEF_PARAMS (ifp))
7536 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7537 vty_out (vty, "%s", VTY_NEWLINE);
7538 }
7539
7540 /* Hello Interval print. */
7541 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7542 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7543 {
7544 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7545 if (params != IF_DEF_PARAMS (ifp))
7546 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7547 vty_out (vty, "%s", VTY_NEWLINE);
7548 }
7549
7550
7551 /* Router Dead Interval print. */
7552 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7553 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7554 {
paulf9ad9372005-10-21 00:45:17 +00007555 vty_out (vty, " ip ospf dead-interval ");
7556
7557 /* fast hello ? */
7558 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7559 vty_out (vty, "minimal hello-multiplier %d",
7560 params->fast_hello);
7561 else
7562 vty_out (vty, "%u", params->v_wait);
7563
paul718e3742002-12-13 20:15:29 +00007564 if (params != IF_DEF_PARAMS (ifp))
7565 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7566 vty_out (vty, "%s", VTY_NEWLINE);
7567 }
7568
7569 /* Router Priority print. */
7570 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7571 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7572 {
7573 vty_out (vty, " ip ospf priority %u", params->priority);
7574 if (params != IF_DEF_PARAMS (ifp))
7575 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7576 vty_out (vty, "%s", VTY_NEWLINE);
7577 }
7578
7579 /* Retransmit Interval print. */
7580 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7581 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7582 {
7583 vty_out (vty, " ip ospf retransmit-interval %u",
7584 params->retransmit_interval);
7585 if (params != IF_DEF_PARAMS (ifp))
7586 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7587 vty_out (vty, "%s", VTY_NEWLINE);
7588 }
7589
7590 /* Transmit Delay print. */
7591 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7592 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7593 {
7594 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7595 if (params != IF_DEF_PARAMS (ifp))
7596 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7597 vty_out (vty, "%s", VTY_NEWLINE);
7598 }
7599
vincentba682532005-09-29 13:52:57 +00007600 /* MTU ignore print. */
7601 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7602 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7603 {
7604 if (params->mtu_ignore == 0)
7605 vty_out (vty, " no ip ospf mtu-ignore");
7606 else
7607 vty_out (vty, " ip ospf mtu-ignore");
7608 if (params != IF_DEF_PARAMS (ifp))
7609 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7610 vty_out (vty, "%s", VTY_NEWLINE);
7611 }
7612
7613
paul718e3742002-12-13 20:15:29 +00007614 while (1)
7615 {
7616 if (rn == NULL)
7617 rn = route_top (IF_OIFS_PARAMS (ifp));
7618 else
7619 rn = route_next (rn);
7620
7621 if (rn == NULL)
7622 break;
7623 params = rn->info;
7624 if (params != NULL)
7625 break;
7626 }
7627 } while (rn);
7628
7629#ifdef HAVE_OPAQUE_LSA
7630 ospf_opaque_config_write_if (vty, ifp);
7631#endif /* HAVE_OPAQUE_LSA */
7632 }
7633
7634 return write;
7635}
7636
paul4dadc292005-05-06 21:37:42 +00007637static int
paul68980082003-03-25 05:07:42 +00007638config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007639{
7640 struct route_node *rn;
7641 u_char buf[INET_ADDRSTRLEN];
7642
7643 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007644 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007645 if (rn->info)
7646 {
7647 struct ospf_network *n = rn->info;
7648
7649 memset (buf, 0, INET_ADDRSTRLEN);
7650
7651 /* Create Area ID string by specified Area ID format. */
7652 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007653 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007654 else
hassoc9e52be2004-09-26 16:09:34 +00007655 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007656 (unsigned long int) ntohl (n->area_id.s_addr));
7657
7658 /* Network print. */
7659 vty_out (vty, " network %s/%d area %s%s",
7660 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7661 buf, VTY_NEWLINE);
7662 }
7663
7664 return 0;
7665}
7666
paul4dadc292005-05-06 21:37:42 +00007667static int
paul68980082003-03-25 05:07:42 +00007668config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007669{
hasso52dc7ee2004-09-23 19:18:23 +00007670 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007671 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007672 u_char buf[INET_ADDRSTRLEN];
7673
7674 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007675 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007676 {
paul718e3742002-12-13 20:15:29 +00007677 struct route_node *rn1;
7678
hassoc9e52be2004-09-26 16:09:34 +00007679 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007680
7681 if (area->auth_type != OSPF_AUTH_NULL)
7682 {
7683 if (area->auth_type == OSPF_AUTH_SIMPLE)
7684 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7685 else
7686 vty_out (vty, " area %s authentication message-digest%s",
7687 buf, VTY_NEWLINE);
7688 }
7689
7690 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7691 vty_out (vty, " area %s shortcut %s%s", buf,
7692 ospf_shortcut_mode_str[area->shortcut_configured],
7693 VTY_NEWLINE);
7694
7695 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007696 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007697 )
7698 {
paulb0a053b2003-06-22 09:04:47 +00007699 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007700 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007701 else if (area->external_routing == OSPF_AREA_NSSA)
7702 {
7703 vty_out (vty, " area %s nssa", buf);
7704 switch (area->NSSATranslatorRole)
7705 {
7706 case OSPF_NSSA_ROLE_NEVER:
7707 vty_out (vty, " translate-never");
7708 break;
7709 case OSPF_NSSA_ROLE_ALWAYS:
7710 vty_out (vty, " translate-always");
7711 break;
7712 case OSPF_NSSA_ROLE_CANDIDATE:
7713 default:
7714 vty_out (vty, " translate-candidate");
7715 }
7716 }
paul718e3742002-12-13 20:15:29 +00007717
7718 if (area->no_summary)
7719 vty_out (vty, " no-summary");
7720
7721 vty_out (vty, "%s", VTY_NEWLINE);
7722
7723 if (area->default_cost != 1)
7724 vty_out (vty, " area %s default-cost %d%s", buf,
7725 area->default_cost, VTY_NEWLINE);
7726 }
7727
7728 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7729 if (rn1->info)
7730 {
7731 struct ospf_area_range *range = rn1->info;
7732
7733 vty_out (vty, " area %s range %s/%d", buf,
7734 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7735
paul6c835672004-10-11 11:00:30 +00007736 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007737 vty_out (vty, " cost %d", range->cost_config);
7738
7739 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7740 vty_out (vty, " not-advertise");
7741
7742 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7743 vty_out (vty, " substitute %s/%d",
7744 inet_ntoa (range->subst_addr), range->subst_masklen);
7745
7746 vty_out (vty, "%s", VTY_NEWLINE);
7747 }
7748
7749 if (EXPORT_NAME (area))
7750 vty_out (vty, " area %s export-list %s%s", buf,
7751 EXPORT_NAME (area), VTY_NEWLINE);
7752
7753 if (IMPORT_NAME (area))
7754 vty_out (vty, " area %s import-list %s%s", buf,
7755 IMPORT_NAME (area), VTY_NEWLINE);
7756
7757 if (PREFIX_NAME_IN (area))
7758 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7759 PREFIX_NAME_IN (area), VTY_NEWLINE);
7760
7761 if (PREFIX_NAME_OUT (area))
7762 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7763 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7764 }
7765
7766 return 0;
7767}
7768
paul4dadc292005-05-06 21:37:42 +00007769static int
paul68980082003-03-25 05:07:42 +00007770config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007771{
7772 struct ospf_nbr_nbma *nbr_nbma;
7773 struct route_node *rn;
7774
7775 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007776 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007777 if ((nbr_nbma = rn->info))
7778 {
7779 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7780
7781 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7782 vty_out (vty, " priority %d", nbr_nbma->priority);
7783
7784 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7785 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7786
7787 vty_out (vty, "%s", VTY_NEWLINE);
7788 }
7789
7790 return 0;
7791}
7792
paul4dadc292005-05-06 21:37:42 +00007793static int
paul68980082003-03-25 05:07:42 +00007794config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007795{
hasso52dc7ee2004-09-23 19:18:23 +00007796 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007797 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007798 u_char buf[INET_ADDRSTRLEN];
7799
7800 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007801 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007802 {
hasso52dc7ee2004-09-23 19:18:23 +00007803 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007804 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007805 struct ospf_interface *oi;
7806
7807 if (vl_data != NULL)
7808 {
7809 memset (buf, 0, INET_ADDRSTRLEN);
7810
7811 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007812 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007813 else
hassoc9e52be2004-09-26 16:09:34 +00007814 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007815 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7816 oi = vl_data->vl_oi;
7817
7818 /* timers */
7819 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7820 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7821 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7822 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7823 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7824 buf,
7825 inet_ntoa (vl_data->vl_peer),
7826 OSPF_IF_PARAM (oi, v_hello),
7827 OSPF_IF_PARAM (oi, retransmit_interval),
7828 OSPF_IF_PARAM (oi, transmit_delay),
7829 OSPF_IF_PARAM (oi, v_wait),
7830 VTY_NEWLINE);
7831 else
7832 vty_out (vty, " area %s virtual-link %s%s", buf,
7833 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7834 /* Auth key */
7835 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7836 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7837 buf,
7838 inet_ntoa (vl_data->vl_peer),
7839 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7840 VTY_NEWLINE);
7841 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007842 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7843 n2, ck))
7844 vty_out (vty, " area %s virtual-link %s"
7845 " message-digest-key %d md5 %s%s",
7846 buf,
7847 inet_ntoa (vl_data->vl_peer),
7848 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007849
7850 }
7851 }
7852
7853 return 0;
7854}
7855
7856
paul4dadc292005-05-06 21:37:42 +00007857static int
paul68980082003-03-25 05:07:42 +00007858config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007859{
7860 int type;
7861
7862 /* redistribute print. */
7863 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7864 if (type != zclient->redist_default && zclient->redist[type])
7865 {
ajsf52d13c2005-10-01 17:38:06 +00007866 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007867 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007868 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007869
paul68980082003-03-25 05:07:42 +00007870 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007871 vty_out (vty, " metric-type 1");
7872
paul020709f2003-04-04 02:44:16 +00007873 if (ROUTEMAP_NAME (ospf, type))
7874 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007875
7876 vty_out (vty, "%s", VTY_NEWLINE);
7877 }
7878
7879 return 0;
7880}
7881
paul4dadc292005-05-06 21:37:42 +00007882static int
paul68980082003-03-25 05:07:42 +00007883config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007884{
paul68980082003-03-25 05:07:42 +00007885 if (ospf->default_metric != -1)
7886 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007887 VTY_NEWLINE);
7888 return 0;
7889}
7890
paul4dadc292005-05-06 21:37:42 +00007891static int
paul68980082003-03-25 05:07:42 +00007892config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007893{
7894 int type;
7895
paul68980082003-03-25 05:07:42 +00007896 if (ospf)
paul718e3742002-12-13 20:15:29 +00007897 {
7898 /* distribute-list print. */
7899 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007900 if (DISTRIBUTE_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +00007901 vty_out (vty, " distribute-list %s out %s%s",
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007902 DISTRIBUTE_NAME (ospf, type),
ajsf52d13c2005-10-01 17:38:06 +00007903 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007904
7905 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007906 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007907 {
paulc42c1772006-01-10 20:36:49 +00007908 vty_out (vty, " default-information originate");
7909 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7910 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007911
paul68980082003-03-25 05:07:42 +00007912 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007913 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007914 ospf->dmetric[DEFAULT_ROUTE].value);
7915 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007916 vty_out (vty, " metric-type 1");
7917
paul020709f2003-04-04 02:44:16 +00007918 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7919 vty_out (vty, " route-map %s",
7920 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007921
7922 vty_out (vty, "%s", VTY_NEWLINE);
7923 }
7924
7925 }
7926
7927 return 0;
7928}
7929
paul4dadc292005-05-06 21:37:42 +00007930static int
paul68980082003-03-25 05:07:42 +00007931config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007932{
7933 struct route_node *rn;
7934 struct ospf_distance *odistance;
7935
paul68980082003-03-25 05:07:42 +00007936 if (ospf->distance_all)
7937 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007938
paul68980082003-03-25 05:07:42 +00007939 if (ospf->distance_intra
7940 || ospf->distance_inter
7941 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007942 {
7943 vty_out (vty, " distance ospf");
7944
paul68980082003-03-25 05:07:42 +00007945 if (ospf->distance_intra)
7946 vty_out (vty, " intra-area %d", ospf->distance_intra);
7947 if (ospf->distance_inter)
7948 vty_out (vty, " inter-area %d", ospf->distance_inter);
7949 if (ospf->distance_external)
7950 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007951
7952 vty_out (vty, "%s", VTY_NEWLINE);
7953 }
7954
paul68980082003-03-25 05:07:42 +00007955 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007956 if ((odistance = rn->info) != NULL)
7957 {
7958 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7959 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7960 odistance->access_list ? odistance->access_list : "",
7961 VTY_NEWLINE);
7962 }
7963 return 0;
7964}
7965
7966/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007967static int
paul718e3742002-12-13 20:15:29 +00007968ospf_config_write (struct vty *vty)
7969{
paul020709f2003-04-04 02:44:16 +00007970 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007971 struct interface *ifp;
7972 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007973 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007974 int write = 0;
7975
paul020709f2003-04-04 02:44:16 +00007976 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007977 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007978 {
7979 /* `router ospf' print. */
7980 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7981
7982 write++;
7983
paul68980082003-03-25 05:07:42 +00007984 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007985 return write;
7986
7987 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007988 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007989 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007990 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007991
7992 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007993 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007994 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007995 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007996
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007997 /* log-adjacency-changes flag print. */
7998 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7999 {
8000 vty_out(vty, " log-adjacency-changes");
8001 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
8002 vty_out(vty, " detail");
8003 vty_out(vty, "%s", VTY_NEWLINE);
8004 }
8005
paul718e3742002-12-13 20:15:29 +00008006 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00008007 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00008008 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
8009
8010 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00008011 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00008012 {
8013 vty_out (vty, "! Important: ensure reference bandwidth "
8014 "is consistent across all routers%s", VTY_NEWLINE);
8015 vty_out (vty, " auto-cost reference-bandwidth %d%s",
8016 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
8017 }
paul718e3742002-12-13 20:15:29 +00008018
8019 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00008020 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00008021 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
8022 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
8023 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00008024 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00008025 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00008026
8027 /* Max-metric router-lsa print */
8028 config_write_stub_router (vty, ospf);
8029
paul718e3742002-12-13 20:15:29 +00008030 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00008031 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00008032 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00008033 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008034
8035 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00008036 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008037
8038 /* passive-interface print. */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008039 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
8040 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
8041
paul1eb8ef22005-04-07 07:30:20 +00008042 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008043 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
8044 && IF_DEF_PARAMS (ifp)->passive_interface !=
8045 ospf->passive_interface_default)
8046 {
8047 vty_out (vty, " %spassive-interface %s%s",
8048 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
8049 ifp->name, VTY_NEWLINE);
8050 }
paul1eb8ef22005-04-07 07:30:20 +00008051 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008052 {
8053 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
8054 continue;
8055 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
8056 passive_interface))
8057 {
8058 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
8059 continue;
8060 }
8061 else if (oi->params->passive_interface == ospf->passive_interface_default)
8062 continue;
8063
8064 vty_out (vty, " %spassive-interface %s %s%s",
8065 oi->params->passive_interface ? "" : "no ",
paul1eb8ef22005-04-07 07:30:20 +00008066 oi->ifp->name,
8067 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008068 }
paul718e3742002-12-13 20:15:29 +00008069
8070 /* Network area print. */
paul68980082003-03-25 05:07:42 +00008071 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008072
8073 /* Area config print. */
paul68980082003-03-25 05:07:42 +00008074 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008075
8076 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00008077 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008078
8079 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00008080 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008081
8082 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00008083 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008084
8085 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00008086 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008087
8088 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00008089 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008090
8091#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00008092 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008093#endif /* HAVE_OPAQUE_LSA */
8094 }
8095
8096 return write;
8097}
8098
8099void
paul4dadc292005-05-06 21:37:42 +00008100ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00008101{
8102 /* "show ip ospf" commands. */
8103 install_element (VIEW_NODE, &show_ip_ospf_cmd);
8104 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
8105
8106 /* "show ip ospf database" commands. */
8107 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
8108 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
8109 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8110 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8111 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
8112 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
8113 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
8114 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
8115 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
8116 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8117 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8118 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
8119 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
8120 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
8121
8122 /* "show ip ospf interface" commands. */
8123 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
8124 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
8125
8126 /* "show ip ospf neighbor" commands. */
8127 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8128 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
8129 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
8130 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8131 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
8132 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
8133 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
8134 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8135 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
8136 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
8137 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8138 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
8139 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
8140 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
8141
8142 /* "show ip ospf route" commands. */
8143 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
8144 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00008145 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
8146 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00008147}
8148
8149
8150/* ospfd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008151static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00008152{
8153 INTERFACE_NODE,
8154 "%s(config-if)# ",
8155 1
8156};
8157
8158/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00008159static void
8160ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00008161{
8162 /* Install interface node. */
8163 install_node (&interface_node, config_write_interface);
8164
8165 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00008166 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008167 install_default (INTERFACE_NODE);
8168
8169 /* "description" commands. */
8170 install_element (INTERFACE_NODE, &interface_desc_cmd);
8171 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
8172
8173 /* "ip ospf authentication" commands. */
8174 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
8175 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
8176 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
8177 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
8178 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
8179 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
8180 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
8181 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
8182 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
8183 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
8184
8185 /* "ip ospf message-digest-key" commands. */
8186 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
8187 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
8188 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8189 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8190
8191 /* "ip ospf cost" commands. */
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008192 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
8193 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008194 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
8195 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008196 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008197 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8198
vincentba682532005-09-29 13:52:57 +00008199 /* "ip ospf mtu-ignore" commands. */
8200 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8201 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8202 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8203 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8204
paul718e3742002-12-13 20:15:29 +00008205 /* "ip ospf dead-interval" commands. */
8206 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8207 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008208 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8209 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00008210 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8211 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008212
paul718e3742002-12-13 20:15:29 +00008213 /* "ip ospf hello-interval" commands. */
8214 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8215 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8216 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8217 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8218
8219 /* "ip ospf network" commands. */
8220 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8221 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8222
8223 /* "ip ospf priority" commands. */
8224 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8225 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8226 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8227 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8228
8229 /* "ip ospf retransmit-interval" commands. */
8230 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8231 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8232 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8233 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8234
8235 /* "ip ospf transmit-delay" commands. */
8236 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8237 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8238 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8239 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8240
8241 /* These commands are compatibitliy for previous version. */
8242 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8243 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8244 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8245 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008246 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
8247 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008248 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008249 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
8250 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008251 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008252 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8253 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8254 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8255 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8256 install_element (INTERFACE_NODE, &ospf_network_cmd);
8257 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8258 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8259 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8260 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8261 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8262 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8263 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8264}
8265
paul4dadc292005-05-06 21:37:42 +00008266static void
8267ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008268{
8269 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8270 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8271 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8272 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8273 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8274 install_element (OSPF_NODE,
8275 &ospf_redistribute_source_metric_type_routemap_cmd);
8276 install_element (OSPF_NODE,
8277 &ospf_redistribute_source_type_metric_routemap_cmd);
8278 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8279 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8280 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8281
8282 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8283
8284 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8285 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8286
8287 install_element (OSPF_NODE,
8288 &ospf_default_information_originate_metric_type_cmd);
8289 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8290 install_element (OSPF_NODE,
8291 &ospf_default_information_originate_type_metric_cmd);
8292 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8293 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8294 install_element (OSPF_NODE,
8295 &ospf_default_information_originate_always_metric_type_cmd);
8296 install_element (OSPF_NODE,
8297 &ospf_default_information_originate_always_metric_cmd);
8298 install_element (OSPF_NODE,
8299 &ospf_default_information_originate_always_cmd);
8300 install_element (OSPF_NODE,
8301 &ospf_default_information_originate_always_type_metric_cmd);
8302 install_element (OSPF_NODE,
8303 &ospf_default_information_originate_always_type_cmd);
8304
8305 install_element (OSPF_NODE,
8306 &ospf_default_information_originate_metric_type_routemap_cmd);
8307 install_element (OSPF_NODE,
8308 &ospf_default_information_originate_metric_routemap_cmd);
8309 install_element (OSPF_NODE,
8310 &ospf_default_information_originate_routemap_cmd);
8311 install_element (OSPF_NODE,
8312 &ospf_default_information_originate_type_metric_routemap_cmd);
8313 install_element (OSPF_NODE,
8314 &ospf_default_information_originate_type_routemap_cmd);
8315 install_element (OSPF_NODE,
8316 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8317 install_element (OSPF_NODE,
8318 &ospf_default_information_originate_always_metric_routemap_cmd);
8319 install_element (OSPF_NODE,
8320 &ospf_default_information_originate_always_routemap_cmd);
8321 install_element (OSPF_NODE,
8322 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8323 install_element (OSPF_NODE,
8324 &ospf_default_information_originate_always_type_routemap_cmd);
8325
8326 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8327
8328 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8329 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8330 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8331
8332 install_element (OSPF_NODE, &ospf_distance_cmd);
8333 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8334 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8335 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8336 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8337 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8338 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8339 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8340 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8341 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8342 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8343 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8344 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8345 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8346 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8347 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8348 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8349 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8350#if 0
8351 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8352 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8353 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8354 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8355#endif /* 0 */
8356}
8357
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008358static struct cmd_node ospf_node =
paul718e3742002-12-13 20:15:29 +00008359{
8360 OSPF_NODE,
8361 "%s(config-router)# ",
8362 1
8363};
8364
8365
8366/* Install OSPF related vty commands. */
8367void
paul4dadc292005-05-06 21:37:42 +00008368ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008369{
8370 /* Install ospf top node. */
8371 install_node (&ospf_node, ospf_config_write);
8372
8373 /* "router ospf" commands. */
8374 install_element (CONFIG_NODE, &router_ospf_cmd);
8375 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8376
8377 install_default (OSPF_NODE);
8378
8379 /* "ospf router-id" commands. */
8380 install_element (OSPF_NODE, &ospf_router_id_cmd);
8381 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008382 install_element (OSPF_NODE, &router_ospf_id_cmd);
8383 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008384
8385 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008386 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8387 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008388 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
paula2c62832003-04-23 17:01:31 +00008389 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8390 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008391 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
paul718e3742002-12-13 20:15:29 +00008392
8393 /* "ospf abr-type" commands. */
8394 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8395 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8396
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008397 /* "ospf log-adjacency-changes" commands. */
8398 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8399 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8400 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8401 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8402
paul718e3742002-12-13 20:15:29 +00008403 /* "ospf rfc1583-compatible" commands. */
8404 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8405 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8406 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8407 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8408
8409 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008410 install_element (OSPF_NODE, &ospf_network_area_cmd);
8411 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008412
8413 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008414 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8415 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8416 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008417
8418 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008419 install_element (OSPF_NODE, &ospf_area_range_cmd);
8420 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8421 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8422 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8423 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8424 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8425 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8426 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8427 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8428 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8429 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008430
8431 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008432 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8433 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008434
paula2c62832003-04-23 17:01:31 +00008435 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8436 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008437
paula2c62832003-04-23 17:01:31 +00008438 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8439 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008440
paula2c62832003-04-23 17:01:31 +00008441 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8442 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008443
paula2c62832003-04-23 17:01:31 +00008444 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8445 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008446
paula2c62832003-04-23 17:01:31 +00008447 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8448 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8449 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008450
paula2c62832003-04-23 17:01:31 +00008451 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8452 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008453
paula2c62832003-04-23 17:01:31 +00008454 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8455 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008456
paula2c62832003-04-23 17:01:31 +00008457 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8458 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8459 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_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_md5_cmd);
8462 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8463 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008464
8465 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008466 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8467 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8468 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8469 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008470
paul718e3742002-12-13 20:15:29 +00008471 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008472 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8473 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8474 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8475 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8476 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8477 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008478
paula2c62832003-04-23 17:01:31 +00008479 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8480 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008481
paula2c62832003-04-23 17:01:31 +00008482 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8483 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008484
paula2c62832003-04-23 17:01:31 +00008485 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8486 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008487
paula2c62832003-04-23 17:01:31 +00008488 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8489 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008490
paula2c62832003-04-23 17:01:31 +00008491 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8492 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008493
8494 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008495 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8496 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008497 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8498 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8499
paul88d6cf32005-10-29 12:50:09 +00008500 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008501 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8502 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8503 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008504
paul88d6cf32005-10-29 12:50:09 +00008505 /* max-metric commands */
8506 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8507 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8508 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8509 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8510 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8511 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8512
8513 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008514 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8515 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008516
8517 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008518 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8519 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8520 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8521 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8522 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8523 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8524 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8525 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008526
8527 /* Init interface related vty commands. */
8528 ospf_vty_if_init ();
8529
8530 /* Init zebra related vty commands. */
8531 ospf_vty_zebra_init ();
8532}