blob: a880714153b9e362cd4ebb9043e67a2489ccd0e2 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* OSPF VTY interface.
vincentba682532005-09-29 13:52:57 +00002 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
paul718e3742002-12-13 20:15:29 +00003 * Copyright (C) 2000 Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23#include <zebra.h>
24
25#include "memory.h"
26#include "thread.h"
27#include "prefix.h"
28#include "table.h"
29#include "vty.h"
30#include "command.h"
31#include "plist.h"
32#include "log.h"
33#include "zclient.h"
34
35#include "ospfd/ospfd.h"
36#include "ospfd/ospf_asbr.h"
37#include "ospfd/ospf_lsa.h"
38#include "ospfd/ospf_lsdb.h"
39#include "ospfd/ospf_ism.h"
40#include "ospfd/ospf_interface.h"
41#include "ospfd/ospf_nsm.h"
42#include "ospfd/ospf_neighbor.h"
43#include "ospfd/ospf_flood.h"
44#include "ospfd/ospf_abr.h"
45#include "ospfd/ospf_spf.h"
46#include "ospfd/ospf_route.h"
47#include "ospfd/ospf_zebra.h"
48/*#include "ospfd/ospf_routemap.h" */
49#include "ospfd/ospf_vty.h"
50#include "ospfd/ospf_dump.h"
51
52
Paul Jakma30a22312008-08-15 14:05:22 +010053static const char *ospf_network_type_str[] =
paul718e3742002-12-13 20:15:29 +000054{
55 "Null",
56 "POINTOPOINT",
57 "BROADCAST",
58 "NBMA",
59 "POINTOMULTIPOINT",
60 "VIRTUALLINK",
61 "LOOPBACK"
62};
63
64
65/* Utility functions. */
paul4dadc292005-05-06 21:37:42 +000066static int
paul6c835672004-10-11 11:00:30 +000067ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
paul718e3742002-12-13 20:15:29 +000068{
69 char *endptr = NULL;
70 unsigned long ret;
71
72 /* match "A.B.C.D". */
73 if (strchr (str, '.') != NULL)
74 {
75 ret = inet_aton (str, area_id);
76 if (!ret)
77 return -1;
78 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
79 }
80 /* match "<0-4294967295>". */
81 else
82 {
Ulrich Weber664711c2011-12-21 02:24:11 +040083 if (*str == '-')
84 return -1;
85 errno = 0;
paul718e3742002-12-13 20:15:29 +000086 ret = strtoul (str, &endptr, 10);
Ulrich Weber664711c2011-12-21 02:24:11 +040087 if (*endptr != '\0' || errno || ret > UINT32_MAX)
paul718e3742002-12-13 20:15:29 +000088 return -1;
89
90 area_id->s_addr = htonl (ret);
91 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
92 }
93
94 return 0;
95}
96
97
paul4dadc292005-05-06 21:37:42 +000098static int
paul6c835672004-10-11 11:00:30 +000099str2metric (const char *str, int *metric)
paul718e3742002-12-13 20:15:29 +0000100{
101 /* Sanity check. */
102 if (str == NULL)
103 return 0;
104
105 *metric = strtol (str, NULL, 10);
106 if (*metric < 0 && *metric > 16777214)
107 {
108 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
109 return 0;
110 }
111
112 return 1;
113}
114
paul4dadc292005-05-06 21:37:42 +0000115static int
paul6c835672004-10-11 11:00:30 +0000116str2metric_type (const char *str, int *metric_type)
paul718e3742002-12-13 20:15:29 +0000117{
118 /* Sanity check. */
119 if (str == NULL)
120 return 0;
121
122 if (strncmp (str, "1", 1) == 0)
123 *metric_type = EXTERNAL_METRIC_TYPE_1;
124 else if (strncmp (str, "2", 1) == 0)
125 *metric_type = EXTERNAL_METRIC_TYPE_2;
126 else
127 return 0;
128
129 return 1;
130}
131
132int
133ospf_oi_count (struct interface *ifp)
134{
135 struct route_node *rn;
136 int i = 0;
137
138 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
139 if (rn->info)
140 i++;
141
142 return i;
143}
144
145
146DEFUN (router_ospf,
147 router_ospf_cmd,
148 "router ospf",
149 "Enable a routing process\n"
150 "Start OSPF configuration\n")
151{
152 vty->node = OSPF_NODE;
153 vty->index = ospf_get ();
154
155 return CMD_SUCCESS;
156}
157
158DEFUN (no_router_ospf,
159 no_router_ospf_cmd,
160 "no router ospf",
161 NO_STR
162 "Enable a routing process\n"
163 "Start OSPF configuration\n")
164{
paul020709f2003-04-04 02:44:16 +0000165 struct ospf *ospf;
166
167 ospf = ospf_lookup ();
168 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000169 {
paul020709f2003-04-04 02:44:16 +0000170 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000171 return CMD_WARNING;
172 }
173
paul020709f2003-04-04 02:44:16 +0000174 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000175
176 return CMD_SUCCESS;
177}
178
179DEFUN (ospf_router_id,
180 ospf_router_id_cmd,
181 "ospf router-id A.B.C.D",
182 "OSPF specific commands\n"
183 "router-id for the OSPF process\n"
184 "OSPF router-id in IP address format\n")
185{
paul68980082003-03-25 05:07:42 +0000186 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000187 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000188 int ret;
paul718e3742002-12-13 20:15:29 +0000189
190 ret = inet_aton (argv[0], &router_id);
191 if (!ret)
192 {
193 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
194 return CMD_WARNING;
195 }
196
paul68980082003-03-25 05:07:42 +0000197 ospf->router_id_static = router_id;
paulb29800a2005-11-20 14:50:45 +0000198
199 ospf_router_id_update (ospf);
200
paul718e3742002-12-13 20:15:29 +0000201 return CMD_SUCCESS;
202}
203
204ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000205 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000206 "router-id A.B.C.D",
207 "router-id for the OSPF process\n"
208 "OSPF router-id in IP address format\n")
209
210DEFUN (no_ospf_router_id,
211 no_ospf_router_id_cmd,
212 "no ospf router-id",
213 NO_STR
214 "OSPF specific commands\n"
215 "router-id for the OSPF process\n")
216{
paul68980082003-03-25 05:07:42 +0000217 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000218
paul68980082003-03-25 05:07:42 +0000219 ospf->router_id_static.s_addr = 0;
220
221 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000222
223 return CMD_SUCCESS;
224}
225
226ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000227 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000228 "no router-id",
229 NO_STR
230 "router-id for the OSPF process\n")
231
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000232static void
Andrew J. Schorr43540882006-11-28 16:36:39 +0000233ospf_passive_interface_default (struct ospf *ospf, u_char newval)
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000234{
235 struct listnode *ln;
236 struct interface *ifp;
237 struct ospf_interface *oi;
238
Andrew J. Schorr43540882006-11-28 16:36:39 +0000239 ospf->passive_interface_default = newval;
240
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000241 for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp))
242 {
243 if (ifp &&
244 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
245 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface);
246 }
247 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi))
248 {
249 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
250 UNSET_IF_PARAM (oi->params, passive_interface);
Andrew J. Schorr43540882006-11-28 16:36:39 +0000251 /* update multicast memberships */
252 ospf_if_set_multicast(oi);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000253 }
254}
255
256static void
257ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
258 struct in_addr addr,
259 struct ospf_if_params *params, u_char value)
260{
261 u_char dflt;
262
263 params->passive_interface = value;
264 if (params != IF_DEF_PARAMS (ifp))
265 {
266 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
267 dflt = IF_DEF_PARAMS (ifp)->passive_interface;
268 else
269 dflt = ospf->passive_interface_default;
270
271 if (value != dflt)
272 SET_IF_PARAM (params, passive_interface);
273 else
274 UNSET_IF_PARAM (params, passive_interface);
275
276 ospf_free_if_params (ifp, addr);
277 ospf_if_update_params (ifp, addr);
278 }
279 else
280 {
281 if (value != ospf->passive_interface_default)
282 SET_IF_PARAM (params, passive_interface);
283 else
284 UNSET_IF_PARAM (params, passive_interface);
285 }
286}
287
paula2c62832003-04-23 17:01:31 +0000288DEFUN (ospf_passive_interface,
289 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000290 "passive-interface IFNAME A.B.C.D",
291 "Suppress routing updates on an interface\n"
292 "Interface's name\n")
293{
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000294 struct interface *ifp;
295 struct in_addr addr;
296 int ret;
297 struct ospf_if_params *params;
298 struct route_node *rn;
299 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000300
Andrew J. Schorr43540882006-11-28 16:36:39 +0000301 if (argc == 0)
302 {
303 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
304 return CMD_SUCCESS;
305 }
306
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000307 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000308
309 params = IF_DEF_PARAMS (ifp);
310
Andrew J. Schorr43540882006-11-28 16:36:39 +0000311 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000312 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000313 ret = inet_aton(argv[1], &addr);
314 if (!ret)
315 {
316 vty_out (vty, "Please specify interface address by A.B.C.D%s",
317 VTY_NEWLINE);
318 return CMD_WARNING;
319 }
paul718e3742002-12-13 20:15:29 +0000320
Andrew J. Schorr43540882006-11-28 16:36:39 +0000321 params = ospf_get_if_params (ifp, addr);
322 ospf_if_update_params (ifp, addr);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000323 }
Andrew J. Schorr43540882006-11-28 16:36:39 +0000324 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE);
325
ajsba6454e2005-02-08 15:37:30 +0000326 /* XXX We should call ospf_if_set_multicast on exactly those
327 * interfaces for which the passive property changed. It is too much
328 * work to determine this set, so we do this for every interface.
329 * This is safe and reasonable because ospf_if_set_multicast uses a
330 * record of joined groups to avoid systems calls if the desired
331 * memberships match the current memership.
332 */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000333
ajsba6454e2005-02-08 15:37:30 +0000334 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
335 {
336 struct ospf_interface *oi = rn->info;
337
338 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
Andrew J. Schorr43540882006-11-28 16:36:39 +0000339 ospf_if_set_multicast(oi);
ajsba6454e2005-02-08 15:37:30 +0000340 }
341 /*
342 * XXX It is not clear what state transitions the interface needs to
343 * undergo when going from active to passive. Fixing this will
344 * require precise identification of interfaces having such a
345 * transition.
346 */
347
paul718e3742002-12-13 20:15:29 +0000348 return CMD_SUCCESS;
349}
350
paula2c62832003-04-23 17:01:31 +0000351ALIAS (ospf_passive_interface,
352 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000353 "passive-interface IFNAME",
354 "Suppress routing updates on an interface\n"
355 "Interface's name\n")
356
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000357ALIAS (ospf_passive_interface,
358 ospf_passive_interface_default_cmd,
359 "passive-interface default",
360 "Suppress routing updates on an interface\n"
361 "Suppress routing updates on interfaces by default\n")
362
paula2c62832003-04-23 17:01:31 +0000363DEFUN (no_ospf_passive_interface,
364 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000365 "no passive-interface IFNAME A.B.C.D",
366 NO_STR
367 "Allow routing updates on an interface\n"
368 "Interface's name\n")
369{
370 struct interface *ifp;
371 struct in_addr addr;
372 struct ospf_if_params *params;
373 int ret;
ajsba6454e2005-02-08 15:37:30 +0000374 struct route_node *rn;
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000375 struct ospf *ospf = vty->index;
Andrew J. Schorr43540882006-11-28 16:36:39 +0000376
377 if (argc == 0)
378 {
379 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
380 return CMD_SUCCESS;
381 }
paul718e3742002-12-13 20:15:29 +0000382
Andrew J. Schorr6e72cb62006-06-18 00:45:48 +0000383 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000384
385 params = IF_DEF_PARAMS (ifp);
386
Andrew J. Schorr43540882006-11-28 16:36:39 +0000387 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000388 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000389 ret = inet_aton(argv[1], &addr);
390 if (!ret)
391 {
392 vty_out (vty, "Please specify interface address by A.B.C.D%s",
393 VTY_NEWLINE);
394 return CMD_WARNING;
395 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000396
Andrew J. Schorr43540882006-11-28 16:36:39 +0000397 params = ospf_lookup_if_params (ifp, addr);
398 if (params == NULL)
399 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000400 }
Andrew J. Schorr43540882006-11-28 16:36:39 +0000401 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE);
ajsba6454e2005-02-08 15:37:30 +0000402
403 /* XXX We should call ospf_if_set_multicast on exactly those
404 * interfaces for which the passive property changed. It is too much
405 * work to determine this set, so we do this for every interface.
406 * This is safe and reasonable because ospf_if_set_multicast uses a
407 * record of joined groups to avoid systems calls if the desired
408 * memberships match the current memership.
409 */
410 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
411 {
412 struct ospf_interface *oi = rn->info;
413
414 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
415 ospf_if_set_multicast(oi);
416 }
417
paul718e3742002-12-13 20:15:29 +0000418 return CMD_SUCCESS;
419}
420
paula2c62832003-04-23 17:01:31 +0000421ALIAS (no_ospf_passive_interface,
422 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000423 "no passive-interface IFNAME",
424 NO_STR
425 "Allow routing updates on an interface\n"
426 "Interface's name\n")
427
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000428ALIAS (no_ospf_passive_interface,
429 no_ospf_passive_interface_default_cmd,
430 "no passive-interface default",
431 NO_STR
432 "Allow routing updates on an interface\n"
433 "Allow routing updates on interfaces by default\n")
434
paula2c62832003-04-23 17:01:31 +0000435DEFUN (ospf_network_area,
436 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000437 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
438 "Enable routing on an IP network\n"
439 "OSPF network prefix\n"
440 "Set the OSPF area ID\n"
441 "OSPF area ID in IP address format\n"
442 "OSPF area ID as a decimal value\n")
443{
444 struct ospf *ospf= vty->index;
445 struct prefix_ipv4 p;
446 struct in_addr area_id;
447 int ret, format;
448
449 /* Get network prefix and Area ID. */
450 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
451 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
452
453 ret = ospf_network_set (ospf, &p, area_id);
454 if (ret == 0)
455 {
456 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
457 return CMD_WARNING;
458 }
459
460 return CMD_SUCCESS;
461}
462
paula2c62832003-04-23 17:01:31 +0000463DEFUN (no_ospf_network_area,
464 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000465 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
466 NO_STR
467 "Enable routing on an IP network\n"
468 "OSPF network prefix\n"
469 "Set the OSPF area ID\n"
470 "OSPF area ID in IP address format\n"
471 "OSPF area ID as a decimal value\n")
472{
473 struct ospf *ospf = (struct ospf *) vty->index;
474 struct prefix_ipv4 p;
475 struct in_addr area_id;
476 int ret, format;
477
478 /* Get network prefix and Area ID. */
479 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
480 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
481
482 ret = ospf_network_unset (ospf, &p, area_id);
483 if (ret == 0)
484 {
485 vty_out (vty, "Can't find specified network area configuration.%s",
486 VTY_NEWLINE);
487 return CMD_WARNING;
488 }
489
490 return CMD_SUCCESS;
491}
492
493
paula2c62832003-04-23 17:01:31 +0000494DEFUN (ospf_area_range,
495 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000496 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
497 "OSPF area parameters\n"
498 "OSPF area ID in IP address format\n"
499 "OSPF area ID as a decimal value\n"
500 "Summarize routes matching address/mask (border routers only)\n"
501 "Area range prefix\n")
502{
503 struct ospf *ospf = vty->index;
504 struct prefix_ipv4 p;
505 struct in_addr area_id;
506 int format;
507 u_int32_t cost;
508
509 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
510 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
511
512 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
513 if (argc > 2)
514 {
paul4dadc292005-05-06 21:37:42 +0000515 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000516 ospf_area_range_cost_set (ospf, area_id, &p, cost);
517 }
518
519 return CMD_SUCCESS;
520}
521
paula2c62832003-04-23 17:01:31 +0000522ALIAS (ospf_area_range,
523 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000524 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
525 "OSPF area parameters\n"
526 "OSPF area ID in IP address format\n"
527 "OSPF area ID as a decimal value\n"
528 "OSPF area range for route advertise (default)\n"
529 "Area range prefix\n"
530 "Advertise this range (default)\n")
531
paula2c62832003-04-23 17:01:31 +0000532ALIAS (ospf_area_range,
533 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000534 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
535 "OSPF area parameters\n"
536 "OSPF area ID in IP address format\n"
537 "OSPF area ID as a decimal value\n"
538 "Summarize routes matching address/mask (border routers only)\n"
539 "Area range prefix\n"
540 "User specified metric for this range\n"
541 "Advertised metric for this range\n")
542
paula2c62832003-04-23 17:01:31 +0000543ALIAS (ospf_area_range,
544 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000545 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
546 "OSPF area parameters\n"
547 "OSPF area ID in IP address format\n"
548 "OSPF area ID as a decimal value\n"
549 "Summarize routes matching address/mask (border routers only)\n"
550 "Area range prefix\n"
551 "Advertise this range (default)\n"
552 "User specified metric for this range\n"
553 "Advertised metric for this range\n")
554
paula2c62832003-04-23 17:01:31 +0000555DEFUN (ospf_area_range_not_advertise,
556 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000557 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
558 "OSPF area parameters\n"
559 "OSPF area ID in IP address format\n"
560 "OSPF area ID as a decimal value\n"
561 "Summarize routes matching address/mask (border routers only)\n"
562 "Area range prefix\n"
563 "DoNotAdvertise this range\n")
564{
565 struct ospf *ospf = vty->index;
566 struct prefix_ipv4 p;
567 struct in_addr area_id;
568 int format;
569
570 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
571 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
572
573 ospf_area_range_set (ospf, area_id, &p, 0);
574
575 return CMD_SUCCESS;
576}
577
paula2c62832003-04-23 17:01:31 +0000578DEFUN (no_ospf_area_range,
579 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000580 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
581 NO_STR
582 "OSPF area parameters\n"
583 "OSPF area ID in IP address format\n"
584 "OSPF area ID as a decimal value\n"
585 "Summarize routes matching address/mask (border routers only)\n"
586 "Area range prefix\n")
587{
588 struct ospf *ospf = vty->index;
589 struct prefix_ipv4 p;
590 struct in_addr area_id;
591 int format;
592
593 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
594 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
595
596 ospf_area_range_unset (ospf, area_id, &p);
597
598 return CMD_SUCCESS;
599}
600
paula2c62832003-04-23 17:01:31 +0000601ALIAS (no_ospf_area_range,
602 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000603 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
604 NO_STR
605 "OSPF area parameters\n"
606 "OSPF area ID in IP address format\n"
607 "OSPF area ID as a decimal value\n"
608 "Summarize routes matching address/mask (border routers only)\n"
609 "Area range prefix\n"
610 "Advertise this range (default)\n"
611 "DoNotAdvertise this range\n")
612
paula2c62832003-04-23 17:01:31 +0000613ALIAS (no_ospf_area_range,
614 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000615 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
616 NO_STR
617 "OSPF area parameters\n"
618 "OSPF area ID in IP address format\n"
619 "OSPF area ID as a decimal value\n"
620 "Summarize routes matching address/mask (border routers only)\n"
621 "Area range prefix\n"
622 "User specified metric for this range\n"
623 "Advertised metric for this range\n")
624
paula2c62832003-04-23 17:01:31 +0000625ALIAS (no_ospf_area_range,
626 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000627 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
628 NO_STR
629 "OSPF area parameters\n"
630 "OSPF area ID in IP address format\n"
631 "OSPF area ID as a decimal value\n"
632 "Summarize routes matching address/mask (border routers only)\n"
633 "Area range prefix\n"
634 "Advertise this range (default)\n"
635 "User specified metric for this range\n"
636 "Advertised metric for this range\n")
637
paula2c62832003-04-23 17:01:31 +0000638DEFUN (ospf_area_range_substitute,
639 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000640 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
641 "OSPF area parameters\n"
642 "OSPF area ID in IP address format\n"
643 "OSPF area ID as a decimal value\n"
644 "Summarize routes matching address/mask (border routers only)\n"
645 "Area range prefix\n"
646 "Announce area range as another prefix\n"
647 "Network prefix to be announced instead of range\n")
648{
649 struct ospf *ospf = vty->index;
650 struct prefix_ipv4 p, s;
651 struct in_addr area_id;
652 int format;
653
654 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
655 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
656 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
657
658 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
659
660 return CMD_SUCCESS;
661}
662
paula2c62832003-04-23 17:01:31 +0000663DEFUN (no_ospf_area_range_substitute,
664 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000665 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
666 NO_STR
667 "OSPF area parameters\n"
668 "OSPF area ID in IP address format\n"
669 "OSPF area ID as a decimal value\n"
670 "Summarize routes matching address/mask (border routers only)\n"
671 "Area range prefix\n"
672 "Announce area range as another prefix\n"
673 "Network prefix to be announced instead of range\n")
674{
675 struct ospf *ospf = vty->index;
676 struct prefix_ipv4 p, s;
677 struct in_addr area_id;
678 int format;
679
680 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
681 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
682 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
683
684 ospf_area_range_substitute_unset (ospf, area_id, &p);
685
686 return CMD_SUCCESS;
687}
688
689
690/* Command Handler Logic in VLink stuff is delicate!!
691
692 ALTER AT YOUR OWN RISK!!!!
693
694 Various dummy values are used to represent 'NoChange' state for
695 VLink configuration NOT being changed by a VLink command, and
696 special syntax is used within the command strings so that the
697 typed in command verbs can be seen in the configuration command
698 bacckend handler. This is to drastically reduce the verbeage
699 required to coe up with a reasonably compatible Cisco VLink command
700
701 - Matthew Grant <grantma@anathoth.gen.nz>
702 Wed, 21 Feb 2001 15:13:52 +1300
703 */
704
705
706/* Configuration data for virtual links
707 */
708struct ospf_vl_config_data {
709 struct vty *vty; /* vty stuff */
710 struct in_addr area_id; /* area ID from command line */
711 int format; /* command line area ID format */
712 struct in_addr vl_peer; /* command line vl_peer */
713 int auth_type; /* Authehntication type, if given */
714 char *auth_key; /* simple password if present */
715 int crypto_key_id; /* Cryptographic key ID */
716 char *md5_key; /* MD5 authentication key */
717 int hello_interval; /* Obvious what these are... */
718 int retransmit_interval;
719 int transmit_delay;
720 int dead_interval;
721};
722
paul4dadc292005-05-06 21:37:42 +0000723static void
paul718e3742002-12-13 20:15:29 +0000724ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
725 struct vty *vty)
726{
727 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
728 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
729 vl_config->vty = vty;
730}
731
paul4dadc292005-05-06 21:37:42 +0000732static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000733ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000734{
735 struct ospf_area *area;
736 struct ospf_vl_data *vl_data;
737 struct vty *vty;
738 struct in_addr area_id;
739
740 vty = vl_config->vty;
741 area_id = vl_config->area_id;
742
743 if (area_id.s_addr == OSPF_AREA_BACKBONE)
744 {
745 vty_out (vty,
746 "Configuring VLs over the backbone is not allowed%s",
747 VTY_NEWLINE);
748 return NULL;
749 }
paul68980082003-03-25 05:07:42 +0000750 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000751
752 if (area->external_routing != OSPF_AREA_DEFAULT)
753 {
754 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
755 vty_out (vty, "Area %s is %s%s",
756 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000757 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000758 VTY_NEWLINE);
759 else
760 vty_out (vty, "Area %ld is %s%s",
761 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000762 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000763 VTY_NEWLINE);
764 return NULL;
765 }
766
Paul Jakma9c27ef92006-05-04 07:32:57 +0000767 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
paul718e3742002-12-13 20:15:29 +0000768 {
769 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
770 if (vl_data->vl_oi == NULL)
771 {
paul68980082003-03-25 05:07:42 +0000772 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
773 ospf_vl_add (ospf, vl_data);
774 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000775 }
776 }
777 return vl_data;
778}
779
780
paul4dadc292005-05-06 21:37:42 +0000781static int
paul718e3742002-12-13 20:15:29 +0000782ospf_vl_set_security (struct ospf_vl_data *vl_data,
783 struct ospf_vl_config_data *vl_config)
784{
785 struct crypt_key *ck;
786 struct vty *vty;
787 struct interface *ifp = vl_data->vl_oi->ifp;
788
789 vty = vl_config->vty;
790
791 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
792 {
793 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
794 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
795 }
796
797 if (vl_config->auth_key)
798 {
799 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000800 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000801 OSPF_AUTH_SIMPLE_SIZE);
802 }
803 else if (vl_config->md5_key)
804 {
805 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
806 != NULL)
807 {
808 vty_out (vty, "OSPF: Key %d already exists%s",
809 vl_config->crypto_key_id, VTY_NEWLINE);
810 return CMD_WARNING;
811 }
812 ck = ospf_crypt_key_new ();
813 ck->key_id = vl_config->crypto_key_id;
814 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000815 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000816
817 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
818 }
819 else if (vl_config->crypto_key_id != 0)
820 {
821 /* Delete a key */
822
823 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
824 vl_config->crypto_key_id) == NULL)
825 {
826 vty_out (vty, "OSPF: Key %d does not exist%s",
827 vl_config->crypto_key_id, VTY_NEWLINE);
828 return CMD_WARNING;
829 }
830
831 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
832
833 }
834
835 return CMD_SUCCESS;
836}
837
paul4dadc292005-05-06 21:37:42 +0000838static int
paul718e3742002-12-13 20:15:29 +0000839ospf_vl_set_timers (struct ospf_vl_data *vl_data,
840 struct ospf_vl_config_data *vl_config)
841{
842 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
843 /* Virtual Link data initialised to defaults, so only set
844 if a value given */
845 if (vl_config->hello_interval)
846 {
847 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
848 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
849 }
850
851 if (vl_config->dead_interval)
852 {
853 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
854 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
855 }
856
857 if (vl_config->retransmit_interval)
858 {
859 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
860 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
861 }
862
863 if (vl_config->transmit_delay)
864 {
865 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
866 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
867 }
868
869 return CMD_SUCCESS;
870}
871
872
873
874/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000875static int
paul68980082003-03-25 05:07:42 +0000876ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000877{
878 struct ospf_vl_data *vl_data;
879 int ret;
880
paul68980082003-03-25 05:07:42 +0000881 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000882 if (!vl_data)
883 return CMD_WARNING;
884
885 /* Process this one first as it can have a fatal result, which can
886 only logically occur if the virtual link exists already
887 Thus a command error does not result in a change to the
888 running configuration such as unexpectedly altered timer
889 values etc.*/
890 ret = ospf_vl_set_security (vl_data, vl_config);
891 if (ret != CMD_SUCCESS)
892 return ret;
893
894 /* Set any time based parameters, these area already range checked */
895
896 ret = ospf_vl_set_timers (vl_data, vl_config);
897 if (ret != CMD_SUCCESS)
898 return ret;
899
900 return CMD_SUCCESS;
901
902}
903
904/* This stuff exists to make specifying all the alias commands A LOT simpler
905 */
906#define VLINK_HELPSTR_IPADDR \
907 "OSPF area parameters\n" \
908 "OSPF area ID in IP address format\n" \
909 "OSPF area ID as a decimal value\n" \
910 "Configure a virtual link\n" \
911 "Router ID of the remote ABR\n"
912
913#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
914 "Enable authentication on this virtual link\n" \
915 "dummy string \n"
916
917#define VLINK_HELPSTR_AUTHTYPE_ALL \
918 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
919 "Use null authentication\n" \
920 "Use message-digest authentication\n"
921
922#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
923 "Time between HELLO packets\n" \
924 "Time between retransmitting lost link state advertisements\n" \
925 "Link state transmit delay\n" \
926 "Interval after which a neighbor is declared dead\n"
927
928#define VLINK_HELPSTR_TIME_PARAM \
929 VLINK_HELPSTR_TIME_PARAM_NOSECS \
930 "Seconds\n"
931
932#define VLINK_HELPSTR_AUTH_SIMPLE \
933 "Authentication password (key)\n" \
934 "The OSPF password (key)"
935
936#define VLINK_HELPSTR_AUTH_MD5 \
937 "Message digest authentication password (key)\n" \
938 "dummy string \n" \
939 "Key ID\n" \
940 "Use MD5 algorithm\n" \
941 "The OSPF password (key)"
942
paula2c62832003-04-23 17:01:31 +0000943DEFUN (ospf_area_vlink,
944 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000945 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
946 VLINK_HELPSTR_IPADDR)
947{
paul68980082003-03-25 05:07:42 +0000948 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000949 struct ospf_vl_config_data vl_config;
950 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
951 char md5_key[OSPF_AUTH_MD5_SIZE+1];
952 int i;
953 int ret;
954
955 ospf_vl_config_data_init(&vl_config, vty);
956
957 /* Read off first 2 parameters and check them */
958 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
959 if (ret < 0)
960 {
961 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
962 return CMD_WARNING;
963 }
964
965 ret = inet_aton (argv[1], &vl_config.vl_peer);
966 if (! ret)
967 {
968 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
969 VTY_NEWLINE);
970 return CMD_WARNING;
971 }
972
973 if (argc <=2)
974 {
975 /* Thats all folks! - BUGS B. strikes again!!!*/
976
paul68980082003-03-25 05:07:42 +0000977 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000978 }
979
980 /* Deal with other parameters */
981 for (i=2; i < argc; i++)
982 {
983
984 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
985
986 switch (argv[i][0])
987 {
988
989 case 'a':
990 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
991 {
992 /* authentication-key - this option can occur anywhere on
993 command line. At start of command line
994 must check for authentication option. */
995 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
996 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
997 vl_config.auth_key = auth_key;
998 i++;
999 }
1000 else if (strncmp (argv[i], "authentication", 14) == 0)
1001 {
1002 /* authentication - this option can only occur at start
1003 of command line */
1004 vl_config.auth_type = OSPF_AUTH_SIMPLE;
1005 if ((i+1) < argc)
1006 {
1007 if (strncmp (argv[i+1], "n", 1) == 0)
1008 {
1009 /* "authentication null" */
1010 vl_config.auth_type = OSPF_AUTH_NULL;
1011 i++;
1012 }
1013 else if (strncmp (argv[i+1], "m", 1) == 0
1014 && strcmp (argv[i+1], "message-digest-") != 0)
1015 {
1016 /* "authentication message-digest" */
1017 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1018 i++;
1019 }
1020 }
1021 }
1022 break;
1023
1024 case 'm':
1025 /* message-digest-key */
1026 i++;
1027 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1028 if (vl_config.crypto_key_id < 0)
1029 return CMD_WARNING;
1030 i++;
1031 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
1032 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
1033 vl_config.md5_key = md5_key;
1034 break;
1035
1036 case 'h':
1037 /* Hello interval */
1038 i++;
1039 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1040 if (vl_config.hello_interval < 0)
1041 return CMD_WARNING;
1042 break;
1043
1044 case 'r':
1045 /* Retransmit Interval */
1046 i++;
1047 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1048 if (vl_config.retransmit_interval < 0)
1049 return CMD_WARNING;
1050 break;
1051
1052 case 't':
1053 /* Transmit Delay */
1054 i++;
1055 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1056 if (vl_config.transmit_delay < 0)
1057 return CMD_WARNING;
1058 break;
1059
1060 case 'd':
1061 /* Dead Interval */
1062 i++;
1063 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1064 if (vl_config.dead_interval < 0)
1065 return CMD_WARNING;
1066 break;
1067 }
1068 }
1069
1070
1071 /* Action configuration */
1072
paul68980082003-03-25 05:07:42 +00001073 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001074
1075}
1076
paula2c62832003-04-23 17:01:31 +00001077DEFUN (no_ospf_area_vlink,
1078 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001079 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1080 NO_STR
1081 VLINK_HELPSTR_IPADDR)
1082{
paul68980082003-03-25 05:07:42 +00001083 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001084 struct ospf_area *area;
1085 struct ospf_vl_config_data vl_config;
1086 struct ospf_vl_data *vl_data = NULL;
1087 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1088 int i;
1089 int ret, format;
1090
1091 ospf_vl_config_data_init(&vl_config, vty);
1092
1093 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1094 if (ret < 0)
1095 {
1096 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1097 return CMD_WARNING;
1098 }
1099
paul68980082003-03-25 05:07:42 +00001100 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001101 if (!area)
1102 {
1103 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1104 return CMD_WARNING;
1105 }
1106
1107 ret = inet_aton (argv[1], &vl_config.vl_peer);
1108 if (! ret)
1109 {
1110 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1111 VTY_NEWLINE);
1112 return CMD_WARNING;
1113 }
1114
1115 if (argc <=2)
1116 {
1117 /* Basic VLink no command */
1118 /* Thats all folks! - BUGS B. strikes again!!!*/
Paul Jakma9c27ef92006-05-04 07:32:57 +00001119 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001120 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001121
paul68980082003-03-25 05:07:42 +00001122 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001123
1124 return CMD_SUCCESS;
1125 }
1126
1127 /* If we are down here, we are reseting parameters */
1128
1129 /* Deal with other parameters */
1130 for (i=2; i < argc; i++)
1131 {
paul718e3742002-12-13 20:15:29 +00001132 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1133
1134 switch (argv[i][0])
1135 {
1136
1137 case 'a':
1138 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1139 {
1140 /* authentication-key - this option can occur anywhere on
1141 command line. At start of command line
1142 must check for authentication option. */
1143 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1144 vl_config.auth_key = auth_key;
1145 }
1146 else if (strncmp (argv[i], "authentication", 14) == 0)
1147 {
1148 /* authentication - this option can only occur at start
1149 of command line */
1150 vl_config.auth_type = OSPF_AUTH_NOTSET;
1151 }
1152 break;
1153
1154 case 'm':
1155 /* message-digest-key */
1156 /* Delete one key */
1157 i++;
1158 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1159 if (vl_config.crypto_key_id < 0)
1160 return CMD_WARNING;
1161 vl_config.md5_key = NULL;
1162 break;
1163
1164 case 'h':
1165 /* Hello interval */
1166 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1167 break;
1168
1169 case 'r':
1170 /* Retransmit Interval */
1171 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1172 break;
1173
1174 case 't':
1175 /* Transmit Delay */
1176 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1177 break;
1178
1179 case 'd':
1180 /* Dead Interval */
1181 i++;
1182 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1183 break;
1184 }
1185 }
1186
1187
1188 /* Action configuration */
1189
paul68980082003-03-25 05:07:42 +00001190 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001191}
1192
paula2c62832003-04-23 17:01:31 +00001193ALIAS (ospf_area_vlink,
1194 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001195 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1196 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1197 VLINK_HELPSTR_IPADDR
1198 VLINK_HELPSTR_TIME_PARAM)
1199
paula2c62832003-04-23 17:01:31 +00001200ALIAS (no_ospf_area_vlink,
1201 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001202 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1203 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1204 NO_STR
1205 VLINK_HELPSTR_IPADDR
1206 VLINK_HELPSTR_TIME_PARAM)
1207
paula2c62832003-04-23 17:01:31 +00001208ALIAS (ospf_area_vlink,
1209 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001210 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1211 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1212 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1213 VLINK_HELPSTR_IPADDR
1214 VLINK_HELPSTR_TIME_PARAM
1215 VLINK_HELPSTR_TIME_PARAM)
1216
paula2c62832003-04-23 17:01:31 +00001217ALIAS (no_ospf_area_vlink,
1218 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001219 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1220 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1221 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1222 NO_STR
1223 VLINK_HELPSTR_IPADDR
1224 VLINK_HELPSTR_TIME_PARAM
1225 VLINK_HELPSTR_TIME_PARAM)
1226
paula2c62832003-04-23 17:01:31 +00001227ALIAS (ospf_area_vlink,
1228 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001229 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1230 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1231 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1232 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1233 VLINK_HELPSTR_IPADDR
1234 VLINK_HELPSTR_TIME_PARAM
1235 VLINK_HELPSTR_TIME_PARAM
1236 VLINK_HELPSTR_TIME_PARAM)
1237
paula2c62832003-04-23 17:01:31 +00001238ALIAS (no_ospf_area_vlink,
1239 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001240 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1241 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1242 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1243 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1244 NO_STR
1245 VLINK_HELPSTR_IPADDR
1246 VLINK_HELPSTR_TIME_PARAM
1247 VLINK_HELPSTR_TIME_PARAM
1248 VLINK_HELPSTR_TIME_PARAM)
1249
paula2c62832003-04-23 17:01:31 +00001250ALIAS (ospf_area_vlink,
1251 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001252 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1253 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1254 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1255 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1256 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_TIME_PARAM
1259 VLINK_HELPSTR_TIME_PARAM
1260 VLINK_HELPSTR_TIME_PARAM
1261 VLINK_HELPSTR_TIME_PARAM)
1262
paula2c62832003-04-23 17:01:31 +00001263ALIAS (no_ospf_area_vlink,
1264 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001265 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1266 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1267 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1268 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1269 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1270 NO_STR
1271 VLINK_HELPSTR_IPADDR
1272 VLINK_HELPSTR_TIME_PARAM
1273 VLINK_HELPSTR_TIME_PARAM
1274 VLINK_HELPSTR_TIME_PARAM
1275 VLINK_HELPSTR_TIME_PARAM)
1276
paula2c62832003-04-23 17:01:31 +00001277ALIAS (ospf_area_vlink,
1278 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001279 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1280 "(authentication|) (message-digest|null)",
1281 VLINK_HELPSTR_IPADDR
1282 VLINK_HELPSTR_AUTHTYPE_ALL)
1283
paula2c62832003-04-23 17:01:31 +00001284ALIAS (ospf_area_vlink,
1285 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001286 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1287 "(authentication|)",
1288 VLINK_HELPSTR_IPADDR
1289 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1290
paula2c62832003-04-23 17:01:31 +00001291ALIAS (no_ospf_area_vlink,
1292 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001293 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1294 "(authentication|)",
1295 NO_STR
1296 VLINK_HELPSTR_IPADDR
1297 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1298
paula2c62832003-04-23 17:01:31 +00001299ALIAS (ospf_area_vlink,
1300 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001301 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1302 "(message-digest-key|) <1-255> md5 KEY",
1303 VLINK_HELPSTR_IPADDR
1304 VLINK_HELPSTR_AUTH_MD5)
1305
paula2c62832003-04-23 17:01:31 +00001306ALIAS (no_ospf_area_vlink,
1307 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001308 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1309 "(message-digest-key|) <1-255>",
1310 NO_STR
1311 VLINK_HELPSTR_IPADDR
1312 VLINK_HELPSTR_AUTH_MD5)
1313
paula2c62832003-04-23 17:01:31 +00001314ALIAS (ospf_area_vlink,
1315 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001316 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1317 "(authentication-key|) AUTH_KEY",
1318 VLINK_HELPSTR_IPADDR
1319 VLINK_HELPSTR_AUTH_SIMPLE)
1320
paula2c62832003-04-23 17:01:31 +00001321ALIAS (no_ospf_area_vlink,
1322 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001323 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1324 "(authentication-key|)",
1325 NO_STR
1326 VLINK_HELPSTR_IPADDR
1327 VLINK_HELPSTR_AUTH_SIMPLE)
1328
paula2c62832003-04-23 17:01:31 +00001329ALIAS (ospf_area_vlink,
1330 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001331 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1332 "(authentication|) (message-digest|null) "
1333 "(authentication-key|) AUTH_KEY",
1334 VLINK_HELPSTR_IPADDR
1335 VLINK_HELPSTR_AUTHTYPE_ALL
1336 VLINK_HELPSTR_AUTH_SIMPLE)
1337
paula2c62832003-04-23 17:01:31 +00001338ALIAS (ospf_area_vlink,
1339 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001340 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1341 "(authentication|) "
1342 "(authentication-key|) AUTH_KEY",
1343 VLINK_HELPSTR_IPADDR
1344 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1345 VLINK_HELPSTR_AUTH_SIMPLE)
1346
paula2c62832003-04-23 17:01:31 +00001347ALIAS (no_ospf_area_vlink,
1348 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001349 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1350 "(authentication|) "
1351 "(authentication-key|)",
1352 NO_STR
1353 VLINK_HELPSTR_IPADDR
1354 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1355 VLINK_HELPSTR_AUTH_SIMPLE)
1356
paula2c62832003-04-23 17:01:31 +00001357ALIAS (ospf_area_vlink,
1358 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001359 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1360 "(authentication|) (message-digest|null) "
1361 "(message-digest-key|) <1-255> md5 KEY",
1362 VLINK_HELPSTR_IPADDR
1363 VLINK_HELPSTR_AUTHTYPE_ALL
1364 VLINK_HELPSTR_AUTH_MD5)
1365
paula2c62832003-04-23 17:01:31 +00001366ALIAS (ospf_area_vlink,
1367 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001368 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1369 "(authentication|) "
1370 "(message-digest-key|) <1-255> md5 KEY",
1371 VLINK_HELPSTR_IPADDR
1372 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1373 VLINK_HELPSTR_AUTH_MD5)
1374
paula2c62832003-04-23 17:01:31 +00001375ALIAS (no_ospf_area_vlink,
1376 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001377 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1378 "(authentication|) "
1379 "(message-digest-key|)",
1380 NO_STR
1381 VLINK_HELPSTR_IPADDR
1382 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1383 VLINK_HELPSTR_AUTH_MD5)
1384
1385
paula2c62832003-04-23 17:01:31 +00001386DEFUN (ospf_area_shortcut,
1387 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001388 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1389 "OSPF area parameters\n"
1390 "OSPF area ID in IP address format\n"
1391 "OSPF area ID as a decimal value\n"
1392 "Configure the area's shortcutting mode\n"
1393 "Set default shortcutting behavior\n"
1394 "Enable shortcutting through the area\n"
1395 "Disable shortcutting through the area\n")
1396{
paul68980082003-03-25 05:07:42 +00001397 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001398 struct ospf_area *area;
1399 struct in_addr area_id;
1400 int mode;
1401 int format;
1402
1403 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1404
paul68980082003-03-25 05:07:42 +00001405 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001406
1407 if (strncmp (argv[1], "de", 2) == 0)
1408 mode = OSPF_SHORTCUT_DEFAULT;
1409 else if (strncmp (argv[1], "di", 2) == 0)
1410 mode = OSPF_SHORTCUT_DISABLE;
1411 else if (strncmp (argv[1], "e", 1) == 0)
1412 mode = OSPF_SHORTCUT_ENABLE;
1413 else
1414 return CMD_WARNING;
1415
paul68980082003-03-25 05:07:42 +00001416 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001417
paul68980082003-03-25 05:07:42 +00001418 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001419 vty_out (vty, "Shortcut area setting will take effect "
1420 "only when the router is configured as Shortcut ABR%s",
1421 VTY_NEWLINE);
1422
1423 return CMD_SUCCESS;
1424}
1425
paula2c62832003-04-23 17:01:31 +00001426DEFUN (no_ospf_area_shortcut,
1427 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001428 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1429 NO_STR
1430 "OSPF area parameters\n"
1431 "OSPF area ID in IP address format\n"
1432 "OSPF area ID as a decimal value\n"
1433 "Deconfigure the area's shortcutting mode\n"
1434 "Deconfigure enabled shortcutting through the area\n"
1435 "Deconfigure disabled shortcutting through the area\n")
1436{
paul68980082003-03-25 05:07:42 +00001437 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001438 struct ospf_area *area;
1439 struct in_addr area_id;
1440 int format;
1441
1442 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1443
paul68980082003-03-25 05:07:42 +00001444 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001445 if (!area)
1446 return CMD_SUCCESS;
1447
paul68980082003-03-25 05:07:42 +00001448 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001449
1450 return CMD_SUCCESS;
1451}
1452
1453
paula2c62832003-04-23 17:01:31 +00001454DEFUN (ospf_area_stub,
1455 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001456 "area (A.B.C.D|<0-4294967295>) stub",
1457 "OSPF area parameters\n"
1458 "OSPF area ID in IP address format\n"
1459 "OSPF area ID as a decimal value\n"
1460 "Configure OSPF area as stub\n")
1461{
1462 struct ospf *ospf = vty->index;
1463 struct in_addr area_id;
1464 int ret, format;
1465
1466 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1467
1468 ret = ospf_area_stub_set (ospf, area_id);
1469 if (ret == 0)
1470 {
1471 vty_out (vty, "First deconfigure all virtual link through this area%s",
1472 VTY_NEWLINE);
1473 return CMD_WARNING;
1474 }
1475
1476 ospf_area_no_summary_unset (ospf, area_id);
1477
1478 return CMD_SUCCESS;
1479}
1480
paula2c62832003-04-23 17:01:31 +00001481DEFUN (ospf_area_stub_no_summary,
1482 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001483 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1484 "OSPF stub parameters\n"
1485 "OSPF area ID in IP address format\n"
1486 "OSPF area ID as a decimal value\n"
1487 "Configure OSPF area as stub\n"
1488 "Do not inject inter-area routes into stub\n")
1489{
1490 struct ospf *ospf = vty->index;
1491 struct in_addr area_id;
1492 int ret, format;
1493
1494 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1495
1496 ret = ospf_area_stub_set (ospf, area_id);
1497 if (ret == 0)
1498 {
paulb0a053b2003-06-22 09:04:47 +00001499 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001500 VTY_NEWLINE);
1501 return CMD_WARNING;
1502 }
1503
1504 ospf_area_no_summary_set (ospf, area_id);
1505
1506 return CMD_SUCCESS;
1507}
1508
paula2c62832003-04-23 17:01:31 +00001509DEFUN (no_ospf_area_stub,
1510 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001511 "no area (A.B.C.D|<0-4294967295>) stub",
1512 NO_STR
1513 "OSPF area parameters\n"
1514 "OSPF area ID in IP address format\n"
1515 "OSPF area ID as a decimal value\n"
1516 "Configure OSPF area as stub\n")
1517{
1518 struct ospf *ospf = vty->index;
1519 struct in_addr area_id;
1520 int format;
1521
1522 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1523
1524 ospf_area_stub_unset (ospf, area_id);
1525 ospf_area_no_summary_unset (ospf, area_id);
1526
1527 return CMD_SUCCESS;
1528}
1529
paula2c62832003-04-23 17:01:31 +00001530DEFUN (no_ospf_area_stub_no_summary,
1531 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001532 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1533 NO_STR
1534 "OSPF area parameters\n"
1535 "OSPF area ID in IP address format\n"
1536 "OSPF area ID as a decimal value\n"
1537 "Configure OSPF area as stub\n"
1538 "Do not inject inter-area routes into area\n")
1539{
1540 struct ospf *ospf = vty->index;
1541 struct in_addr area_id;
1542 int format;
1543
1544 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1545 ospf_area_no_summary_unset (ospf, area_id);
1546
1547 return CMD_SUCCESS;
1548}
1549
paul4dadc292005-05-06 21:37:42 +00001550static int
paul6c835672004-10-11 11:00:30 +00001551ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1552 int nosum)
paul718e3742002-12-13 20:15:29 +00001553{
1554 struct ospf *ospf = vty->index;
1555 struct in_addr area_id;
1556 int ret, format;
1557
1558 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1559
1560 ret = ospf_area_nssa_set (ospf, area_id);
1561 if (ret == 0)
1562 {
1563 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1564 VTY_NEWLINE);
1565 return CMD_WARNING;
1566 }
1567
1568 if (argc > 1)
1569 {
1570 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001571 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001572 OSPF_NSSA_ROLE_CANDIDATE);
1573 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001574 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001575 OSPF_NSSA_ROLE_NEVER);
1576 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001577 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001578 OSPF_NSSA_ROLE_ALWAYS);
1579 }
paulb0a053b2003-06-22 09:04:47 +00001580 else
1581 {
1582 ospf_area_nssa_translator_role_set (ospf, area_id,
1583 OSPF_NSSA_ROLE_CANDIDATE);
1584 }
paul718e3742002-12-13 20:15:29 +00001585
paulb0a053b2003-06-22 09:04:47 +00001586 if (nosum)
paul718e3742002-12-13 20:15:29 +00001587 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001588 else
1589 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001590
paulb0a053b2003-06-22 09:04:47 +00001591 ospf_schedule_abr_task (ospf);
1592
paul718e3742002-12-13 20:15:29 +00001593 return CMD_SUCCESS;
1594}
1595
paulb0a053b2003-06-22 09:04:47 +00001596DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001597 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001598 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001599 "OSPF area parameters\n"
1600 "OSPF area ID in IP address format\n"
1601 "OSPF area ID as a decimal value\n"
1602 "Configure OSPF area as nssa\n"
1603 "Configure NSSA-ABR for translate election (default)\n"
1604 "Configure NSSA-ABR to never translate\n"
1605 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001606 "Do not inject inter-area routes into nssa\n")
1607{
1608 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1609}
paul718e3742002-12-13 20:15:29 +00001610
paulb0a053b2003-06-22 09:04:47 +00001611DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001612 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001613 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1614 "OSPF area parameters\n"
1615 "OSPF area ID in IP address format\n"
1616 "OSPF area ID as a decimal value\n"
1617 "Configure OSPF area as nssa\n"
1618 "Configure NSSA-ABR for translate election (default)\n"
1619 "Configure NSSA-ABR to never translate\n"
1620 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001621{
1622 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1623}
1624
1625DEFUN (ospf_area_nssa,
1626 ospf_area_nssa_cmd,
1627 "area (A.B.C.D|<0-4294967295>) nssa",
1628 "OSPF area parameters\n"
1629 "OSPF area ID in IP address format\n"
1630 "OSPF area ID as a decimal value\n"
1631 "Configure OSPF area as nssa\n")
1632{
1633 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1634}
paul718e3742002-12-13 20:15:29 +00001635
paula2c62832003-04-23 17:01:31 +00001636DEFUN (ospf_area_nssa_no_summary,
1637 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001638 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1639 "OSPF area parameters\n"
1640 "OSPF area ID in IP address format\n"
1641 "OSPF area ID as a decimal value\n"
1642 "Configure OSPF area as nssa\n"
1643 "Do not inject inter-area routes into nssa\n")
1644{
paulb0a053b2003-06-22 09:04:47 +00001645 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001646}
1647
paula2c62832003-04-23 17:01:31 +00001648DEFUN (no_ospf_area_nssa,
1649 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001650 "no area (A.B.C.D|<0-4294967295>) nssa",
1651 NO_STR
1652 "OSPF area parameters\n"
1653 "OSPF area ID in IP address format\n"
1654 "OSPF area ID as a decimal value\n"
1655 "Configure OSPF area as nssa\n")
1656{
1657 struct ospf *ospf = vty->index;
1658 struct in_addr area_id;
1659 int format;
1660
1661 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1662
1663 ospf_area_nssa_unset (ospf, area_id);
1664 ospf_area_no_summary_unset (ospf, area_id);
1665
paulb0a053b2003-06-22 09:04:47 +00001666 ospf_schedule_abr_task (ospf);
1667
paul718e3742002-12-13 20:15:29 +00001668 return CMD_SUCCESS;
1669}
1670
paula2c62832003-04-23 17:01:31 +00001671DEFUN (no_ospf_area_nssa_no_summary,
1672 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001673 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1674 NO_STR
1675 "OSPF area parameters\n"
1676 "OSPF area ID in IP address format\n"
1677 "OSPF area ID as a decimal value\n"
1678 "Configure OSPF area as nssa\n"
1679 "Do not inject inter-area routes into nssa\n")
1680{
1681 struct ospf *ospf = vty->index;
1682 struct in_addr area_id;
1683 int format;
1684
1685 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1686 ospf_area_no_summary_unset (ospf, area_id);
1687
1688 return CMD_SUCCESS;
1689}
1690
paula2c62832003-04-23 17:01:31 +00001691DEFUN (ospf_area_default_cost,
1692 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001693 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1694 "OSPF area parameters\n"
1695 "OSPF area ID in IP address format\n"
1696 "OSPF area ID as a decimal value\n"
1697 "Set the summary-default cost of a NSSA or stub area\n"
1698 "Stub's advertised default summary cost\n")
1699{
paul68980082003-03-25 05:07:42 +00001700 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001701 struct ospf_area *area;
1702 struct in_addr area_id;
1703 u_int32_t cost;
1704 int format;
vincentba682532005-09-29 13:52:57 +00001705 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001706
1707 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1708 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1709
paul68980082003-03-25 05:07:42 +00001710 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001711
1712 if (area->external_routing == OSPF_AREA_DEFAULT)
1713 {
1714 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1715 return CMD_WARNING;
1716 }
1717
1718 area->default_cost = cost;
1719
vincentba682532005-09-29 13:52:57 +00001720 p.family = AF_INET;
1721 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1722 p.prefixlen = 0;
1723 if (IS_DEBUG_OSPF_EVENT)
1724 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1725 "announcing 0.0.0.0/0 to area %s",
1726 inet_ntoa (area->area_id));
1727 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1728
paul718e3742002-12-13 20:15:29 +00001729 return CMD_SUCCESS;
1730}
1731
paula2c62832003-04-23 17:01:31 +00001732DEFUN (no_ospf_area_default_cost,
1733 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001734 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1735 NO_STR
1736 "OSPF area parameters\n"
1737 "OSPF area ID in IP address format\n"
1738 "OSPF area ID as a decimal value\n"
1739 "Set the summary-default cost of a NSSA or stub area\n"
1740 "Stub's advertised default summary cost\n")
1741{
paul68980082003-03-25 05:07:42 +00001742 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001743 struct ospf_area *area;
1744 struct in_addr area_id;
1745 u_int32_t cost;
1746 int format;
vincentba682532005-09-29 13:52:57 +00001747 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001748
1749 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1750 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1751
paul68980082003-03-25 05:07:42 +00001752 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001753 if (area == NULL)
1754 return CMD_SUCCESS;
1755
1756 if (area->external_routing == OSPF_AREA_DEFAULT)
1757 {
1758 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1759 return CMD_WARNING;
1760 }
1761
1762 area->default_cost = 1;
1763
vincentba682532005-09-29 13:52:57 +00001764 p.family = AF_INET;
1765 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1766 p.prefixlen = 0;
1767 if (IS_DEBUG_OSPF_EVENT)
1768 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1769 "announcing 0.0.0.0/0 to area %s",
1770 inet_ntoa (area->area_id));
1771 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1772
1773
paul68980082003-03-25 05:07:42 +00001774 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001775
1776 return CMD_SUCCESS;
1777}
1778
paula2c62832003-04-23 17:01:31 +00001779DEFUN (ospf_area_export_list,
1780 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001781 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1782 "OSPF area parameters\n"
1783 "OSPF area ID in IP address format\n"
1784 "OSPF area ID as a decimal value\n"
1785 "Set the filter for networks announced to other areas\n"
1786 "Name of the access-list\n")
1787{
paul68980082003-03-25 05:07:42 +00001788 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001789 struct ospf_area *area;
1790 struct in_addr area_id;
1791 int format;
1792
hasso52930762004-04-19 18:26:53 +00001793 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1794
paul68980082003-03-25 05:07:42 +00001795 area = ospf_area_get (ospf, area_id, format);
1796 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001797
1798 return CMD_SUCCESS;
1799}
1800
paula2c62832003-04-23 17:01:31 +00001801DEFUN (no_ospf_area_export_list,
1802 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001803 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1804 NO_STR
1805 "OSPF area parameters\n"
1806 "OSPF area ID in IP address format\n"
1807 "OSPF area ID as a decimal value\n"
1808 "Unset the filter for networks announced to other areas\n"
1809 "Name of the access-list\n")
1810{
paul68980082003-03-25 05:07:42 +00001811 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001812 struct ospf_area *area;
1813 struct in_addr area_id;
1814 int format;
1815
hasso52930762004-04-19 18:26:53 +00001816 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1817
paul68980082003-03-25 05:07:42 +00001818 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001819 if (area == NULL)
1820 return CMD_SUCCESS;
1821
paul68980082003-03-25 05:07:42 +00001822 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001823
1824 return CMD_SUCCESS;
1825}
1826
1827
paula2c62832003-04-23 17:01:31 +00001828DEFUN (ospf_area_import_list,
1829 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001830 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1831 "OSPF area parameters\n"
1832 "OSPF area ID in IP address format\n"
1833 "OSPF area ID as a decimal value\n"
1834 "Set the filter for networks from other areas announced to the specified one\n"
1835 "Name of the access-list\n")
1836{
paul68980082003-03-25 05:07:42 +00001837 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001838 struct ospf_area *area;
1839 struct in_addr area_id;
1840 int format;
1841
hasso52930762004-04-19 18:26:53 +00001842 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1843
paul68980082003-03-25 05:07:42 +00001844 area = ospf_area_get (ospf, area_id, format);
1845 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001846
1847 return CMD_SUCCESS;
1848}
1849
paula2c62832003-04-23 17:01:31 +00001850DEFUN (no_ospf_area_import_list,
1851 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001852 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1853 NO_STR
1854 "OSPF area parameters\n"
1855 "OSPF area ID in IP address format\n"
1856 "OSPF area ID as a decimal value\n"
1857 "Unset the filter for networks announced to other areas\n"
1858 "Name of the access-list\n")
1859{
paul68980082003-03-25 05:07:42 +00001860 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001861 struct ospf_area *area;
1862 struct in_addr area_id;
1863 int format;
1864
hasso52930762004-04-19 18:26:53 +00001865 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1866
paul68980082003-03-25 05:07:42 +00001867 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001868 if (area == NULL)
1869 return CMD_SUCCESS;
1870
paul68980082003-03-25 05:07:42 +00001871 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001872
1873 return CMD_SUCCESS;
1874}
1875
paula2c62832003-04-23 17:01:31 +00001876DEFUN (ospf_area_filter_list,
1877 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001878 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1879 "OSPF area parameters\n"
1880 "OSPF area ID in IP address format\n"
1881 "OSPF area ID as a decimal value\n"
1882 "Filter networks between OSPF areas\n"
1883 "Filter prefixes between OSPF areas\n"
1884 "Name of an IP prefix-list\n"
1885 "Filter networks sent to this area\n"
1886 "Filter networks sent from this area\n")
1887{
paul68980082003-03-25 05:07:42 +00001888 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001889 struct ospf_area *area;
1890 struct in_addr area_id;
1891 struct prefix_list *plist;
1892 int format;
1893
1894 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1895
paul68980082003-03-25 05:07:42 +00001896 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001897 plist = prefix_list_lookup (AFI_IP, argv[1]);
1898 if (strncmp (argv[2], "in", 2) == 0)
1899 {
1900 PREFIX_LIST_IN (area) = plist;
1901 if (PREFIX_NAME_IN (area))
1902 free (PREFIX_NAME_IN (area));
1903
1904 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001905 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001906 }
1907 else
1908 {
1909 PREFIX_LIST_OUT (area) = plist;
1910 if (PREFIX_NAME_OUT (area))
1911 free (PREFIX_NAME_OUT (area));
1912
1913 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001914 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001915 }
1916
1917 return CMD_SUCCESS;
1918}
1919
paula2c62832003-04-23 17:01:31 +00001920DEFUN (no_ospf_area_filter_list,
1921 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001922 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1923 NO_STR
1924 "OSPF area parameters\n"
1925 "OSPF area ID in IP address format\n"
1926 "OSPF area ID as a decimal value\n"
1927 "Filter networks between OSPF areas\n"
1928 "Filter prefixes between OSPF areas\n"
1929 "Name of an IP prefix-list\n"
1930 "Filter networks sent to this area\n"
1931 "Filter networks sent from this area\n")
1932{
paul68980082003-03-25 05:07:42 +00001933 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001934 struct ospf_area *area;
1935 struct in_addr area_id;
1936 struct prefix_list *plist;
1937 int format;
1938
1939 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1940
Paul Jakma1a8ec2b2006-05-11 13:34:08 +00001941 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1942 return CMD_SUCCESS;
1943
paul718e3742002-12-13 20:15:29 +00001944 plist = prefix_list_lookup (AFI_IP, argv[1]);
1945 if (strncmp (argv[2], "in", 2) == 0)
1946 {
1947 if (PREFIX_NAME_IN (area))
1948 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1949 return CMD_SUCCESS;
1950
1951 PREFIX_LIST_IN (area) = NULL;
1952 if (PREFIX_NAME_IN (area))
1953 free (PREFIX_NAME_IN (area));
1954
1955 PREFIX_NAME_IN (area) = NULL;
1956
paul68980082003-03-25 05:07:42 +00001957 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001958 }
1959 else
1960 {
1961 if (PREFIX_NAME_OUT (area))
1962 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1963 return CMD_SUCCESS;
1964
1965 PREFIX_LIST_OUT (area) = NULL;
1966 if (PREFIX_NAME_OUT (area))
1967 free (PREFIX_NAME_OUT (area));
1968
1969 PREFIX_NAME_OUT (area) = NULL;
1970
paul68980082003-03-25 05:07:42 +00001971 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001972 }
1973
1974 return CMD_SUCCESS;
1975}
1976
1977
paula2c62832003-04-23 17:01:31 +00001978DEFUN (ospf_area_authentication_message_digest,
1979 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001980 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1981 "OSPF area parameters\n"
1982 "Enable authentication\n"
1983 "Use message-digest authentication\n")
1984{
paul68980082003-03-25 05:07:42 +00001985 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001986 struct ospf_area *area;
1987 struct in_addr area_id;
1988 int format;
1989
1990 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1991
paul68980082003-03-25 05:07:42 +00001992 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001993 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1994
1995 return CMD_SUCCESS;
1996}
1997
paula2c62832003-04-23 17:01:31 +00001998DEFUN (ospf_area_authentication,
1999 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002000 "area (A.B.C.D|<0-4294967295>) authentication",
2001 "OSPF area parameters\n"
2002 "OSPF area ID in IP address format\n"
2003 "OSPF area ID as a decimal value\n"
2004 "Enable authentication\n")
2005{
paul68980082003-03-25 05:07:42 +00002006 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002007 struct ospf_area *area;
2008 struct in_addr area_id;
2009 int format;
2010
2011 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2012
paul68980082003-03-25 05:07:42 +00002013 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00002014 area->auth_type = OSPF_AUTH_SIMPLE;
2015
2016 return CMD_SUCCESS;
2017}
2018
paula2c62832003-04-23 17:01:31 +00002019DEFUN (no_ospf_area_authentication,
2020 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002021 "no area (A.B.C.D|<0-4294967295>) authentication",
2022 NO_STR
2023 "OSPF area parameters\n"
2024 "OSPF area ID in IP address format\n"
2025 "OSPF area ID as a decimal value\n"
2026 "Enable authentication\n")
2027{
paul68980082003-03-25 05:07:42 +00002028 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002029 struct ospf_area *area;
2030 struct in_addr area_id;
2031 int format;
2032
2033 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2034
paul68980082003-03-25 05:07:42 +00002035 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002036 if (area == NULL)
2037 return CMD_SUCCESS;
2038
2039 area->auth_type = OSPF_AUTH_NULL;
2040
paul68980082003-03-25 05:07:42 +00002041 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002042
2043 return CMD_SUCCESS;
2044}
2045
2046
2047DEFUN (ospf_abr_type,
2048 ospf_abr_type_cmd,
2049 "ospf abr-type (cisco|ibm|shortcut|standard)",
2050 "OSPF specific commands\n"
2051 "Set OSPF ABR type\n"
2052 "Alternative ABR, cisco implementation\n"
2053 "Alternative ABR, IBM implementation\n"
2054 "Shortcut ABR\n"
2055 "Standard behavior (RFC2328)\n")
2056{
paul68980082003-03-25 05:07:42 +00002057 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002058 u_char abr_type = OSPF_ABR_UNKNOWN;
2059
2060 if (strncmp (argv[0], "c", 1) == 0)
2061 abr_type = OSPF_ABR_CISCO;
2062 else if (strncmp (argv[0], "i", 1) == 0)
2063 abr_type = OSPF_ABR_IBM;
2064 else if (strncmp (argv[0], "sh", 2) == 0)
2065 abr_type = OSPF_ABR_SHORTCUT;
2066 else if (strncmp (argv[0], "st", 2) == 0)
2067 abr_type = OSPF_ABR_STAND;
2068 else
2069 return CMD_WARNING;
2070
2071 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002072 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002073 {
paul68980082003-03-25 05:07:42 +00002074 ospf->abr_type = abr_type;
2075 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002076 }
2077
2078 return CMD_SUCCESS;
2079}
2080
2081DEFUN (no_ospf_abr_type,
2082 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002083 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002084 NO_STR
2085 "OSPF specific commands\n"
2086 "Set OSPF ABR type\n"
2087 "Alternative ABR, cisco implementation\n"
2088 "Alternative ABR, IBM implementation\n"
2089 "Shortcut ABR\n")
2090{
paul68980082003-03-25 05:07:42 +00002091 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002092 u_char abr_type = OSPF_ABR_UNKNOWN;
2093
2094 if (strncmp (argv[0], "c", 1) == 0)
2095 abr_type = OSPF_ABR_CISCO;
2096 else if (strncmp (argv[0], "i", 1) == 0)
2097 abr_type = OSPF_ABR_IBM;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002098 else if (strncmp (argv[0], "sh", 2) == 0)
paul718e3742002-12-13 20:15:29 +00002099 abr_type = OSPF_ABR_SHORTCUT;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002100 else if (strncmp (argv[0], "st", 2) == 0)
2101 abr_type = OSPF_ABR_STAND;
paul718e3742002-12-13 20:15:29 +00002102 else
2103 return CMD_WARNING;
2104
2105 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002106 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002107 {
pauld57834f2005-07-12 20:04:22 +00002108 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002109 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002110 }
2111
2112 return CMD_SUCCESS;
2113}
2114
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002115DEFUN (ospf_log_adjacency_changes,
2116 ospf_log_adjacency_changes_cmd,
2117 "log-adjacency-changes",
2118 "Log changes in adjacency state\n")
2119{
2120 struct ospf *ospf = vty->index;
2121
2122 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2123 return CMD_SUCCESS;
2124}
2125
2126DEFUN (ospf_log_adjacency_changes_detail,
2127 ospf_log_adjacency_changes_detail_cmd,
2128 "log-adjacency-changes detail",
2129 "Log changes in adjacency state\n"
2130 "Log all state changes\n")
2131{
2132 struct ospf *ospf = vty->index;
2133
2134 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2135 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2136 return CMD_SUCCESS;
2137}
2138
2139DEFUN (no_ospf_log_adjacency_changes,
2140 no_ospf_log_adjacency_changes_cmd,
2141 "no log-adjacency-changes",
2142 NO_STR
2143 "Log changes in adjacency state\n")
2144{
2145 struct ospf *ospf = vty->index;
2146
2147 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2148 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2149 return CMD_SUCCESS;
2150}
2151
2152DEFUN (no_ospf_log_adjacency_changes_detail,
2153 no_ospf_log_adjacency_changes_detail_cmd,
2154 "no log-adjacency-changes detail",
2155 NO_STR
2156 "Log changes in adjacency state\n"
2157 "Log all state changes\n")
2158{
2159 struct ospf *ospf = vty->index;
2160
2161 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2162 return CMD_SUCCESS;
2163}
2164
paul718e3742002-12-13 20:15:29 +00002165DEFUN (ospf_compatible_rfc1583,
2166 ospf_compatible_rfc1583_cmd,
2167 "compatible rfc1583",
2168 "OSPF compatibility list\n"
2169 "compatible with RFC 1583\n")
2170{
2171 struct ospf *ospf = vty->index;
2172
2173 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2174 {
2175 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002176 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002177 }
2178 return CMD_SUCCESS;
2179}
2180
2181DEFUN (no_ospf_compatible_rfc1583,
2182 no_ospf_compatible_rfc1583_cmd,
2183 "no compatible rfc1583",
2184 NO_STR
2185 "OSPF compatibility list\n"
2186 "compatible with RFC 1583\n")
2187{
2188 struct ospf *ospf = vty->index;
2189
2190 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2191 {
2192 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002193 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002194 }
2195 return CMD_SUCCESS;
2196}
2197
2198ALIAS (ospf_compatible_rfc1583,
2199 ospf_rfc1583_flag_cmd,
2200 "ospf rfc1583compatibility",
2201 "OSPF specific commands\n"
2202 "Enable the RFC1583Compatibility flag\n")
2203
2204ALIAS (no_ospf_compatible_rfc1583,
2205 no_ospf_rfc1583_flag_cmd,
2206 "no ospf rfc1583compatibility",
2207 NO_STR
2208 "OSPF specific commands\n"
2209 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002210
2211static int
2212ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2213 unsigned int hold,
2214 unsigned int max)
2215{
2216 struct ospf *ospf = vty->index;
2217
2218 ospf->spf_delay = delay;
2219 ospf->spf_holdtime = hold;
2220 ospf->spf_max_holdtime = max;
2221
2222 return CMD_SUCCESS;
2223}
paul718e3742002-12-13 20:15:29 +00002224
pauld24f6e22005-10-21 09:23:12 +00002225DEFUN (ospf_timers_throttle_spf,
2226 ospf_timers_throttle_spf_cmd,
2227 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2228 "Adjust routing timers\n"
2229 "Throttling adaptive timer\n"
2230 "OSPF SPF timers\n"
2231 "Delay (msec) from first change received till SPF calculation\n"
2232 "Initial hold time (msec) between consecutive SPF calculations\n"
2233 "Maximum hold time (msec)\n")
2234{
2235 unsigned int delay, hold, max;
2236
2237 if (argc != 3)
2238 {
2239 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2240 return CMD_WARNING;
2241 }
2242
2243 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2244 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2245 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2246
2247 return ospf_timers_spf_set (vty, delay, hold, max);
2248}
2249
2250DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002251 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002252 "timers spf <0-4294967295> <0-4294967295>",
2253 "Adjust routing timers\n"
2254 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002255 "Delay (s) between receiving a change to SPF calculation\n"
2256 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002257{
pauld24f6e22005-10-21 09:23:12 +00002258 unsigned int delay, hold;
2259
2260 if (argc != 2)
2261 {
2262 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2263 return CMD_WARNING;
2264 }
2265
paul4dadc292005-05-06 21:37:42 +00002266 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2267 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002268
2269 /* truncate down the second values if they're greater than 600000ms */
2270 if (delay > (600000 / 1000))
2271 delay = 600000;
2272 else if (delay == 0)
2273 /* 0s delay was probably specified because of lack of ms resolution */
2274 delay = OSPF_SPF_DELAY_DEFAULT;
2275 if (hold > (600000 / 1000))
2276 hold = 600000;
2277
2278 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002279}
2280
pauld24f6e22005-10-21 09:23:12 +00002281DEFUN (no_ospf_timers_throttle_spf,
2282 no_ospf_timers_throttle_spf_cmd,
2283 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002284 NO_STR
2285 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002286 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002287 "OSPF SPF timers\n")
2288{
pauld24f6e22005-10-21 09:23:12 +00002289 return ospf_timers_spf_set (vty,
2290 OSPF_SPF_DELAY_DEFAULT,
2291 OSPF_SPF_HOLDTIME_DEFAULT,
2292 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002293}
2294
pauld24f6e22005-10-21 09:23:12 +00002295ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2296 no_ospf_timers_spf_cmd,
2297 "no timers spf",
2298 NO_STR
2299 "Adjust routing timers\n"
2300 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002301
paula2c62832003-04-23 17:01:31 +00002302DEFUN (ospf_neighbor,
2303 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002304 "neighbor A.B.C.D",
2305 NEIGHBOR_STR
2306 "Neighbor IP address\n")
2307{
2308 struct ospf *ospf = vty->index;
2309 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002310 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2311 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002312
2313 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2314
2315 if (argc > 1)
2316 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2317
2318 if (argc > 2)
2319 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2320
2321 ospf_nbr_nbma_set (ospf, nbr_addr);
2322 if (argc > 1)
2323 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2324 if (argc > 2)
2325 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2326
2327 return CMD_SUCCESS;
2328}
2329
paula2c62832003-04-23 17:01:31 +00002330ALIAS (ospf_neighbor,
2331 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002332 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2333 NEIGHBOR_STR
2334 "Neighbor IP address\n"
2335 "Neighbor Priority\n"
2336 "Priority\n"
2337 "Dead Neighbor Polling interval\n"
2338 "Seconds\n")
2339
paula2c62832003-04-23 17:01:31 +00002340ALIAS (ospf_neighbor,
2341 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002342 "neighbor A.B.C.D priority <0-255>",
2343 NEIGHBOR_STR
2344 "Neighbor IP address\n"
2345 "Neighbor Priority\n"
2346 "Seconds\n")
2347
paula2c62832003-04-23 17:01:31 +00002348DEFUN (ospf_neighbor_poll_interval,
2349 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002350 "neighbor A.B.C.D poll-interval <1-65535>",
2351 NEIGHBOR_STR
2352 "Neighbor IP address\n"
2353 "Dead Neighbor Polling interval\n"
2354 "Seconds\n")
2355{
2356 struct ospf *ospf = vty->index;
2357 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002358 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2359 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002360
2361 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2362
2363 if (argc > 1)
2364 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2365
2366 if (argc > 2)
2367 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2368
2369 ospf_nbr_nbma_set (ospf, nbr_addr);
2370 if (argc > 1)
2371 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2372 if (argc > 2)
2373 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2374
2375 return CMD_SUCCESS;
2376}
2377
paula2c62832003-04-23 17:01:31 +00002378ALIAS (ospf_neighbor_poll_interval,
2379 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002380 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2381 NEIGHBOR_STR
2382 "Neighbor address\n"
2383 "OSPF dead-router polling interval\n"
2384 "Seconds\n"
2385 "OSPF priority of non-broadcast neighbor\n"
2386 "Priority\n")
2387
paula2c62832003-04-23 17:01:31 +00002388DEFUN (no_ospf_neighbor,
2389 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002390 "no neighbor A.B.C.D",
2391 NO_STR
2392 NEIGHBOR_STR
2393 "Neighbor IP address\n")
2394{
2395 struct ospf *ospf = vty->index;
2396 struct in_addr nbr_addr;
2397 int ret;
2398
2399 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2400
2401 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2402
2403 return CMD_SUCCESS;
2404}
2405
paula2c62832003-04-23 17:01:31 +00002406ALIAS (no_ospf_neighbor,
2407 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002408 "no neighbor A.B.C.D priority <0-255>",
2409 NO_STR
2410 NEIGHBOR_STR
2411 "Neighbor IP address\n"
2412 "Neighbor Priority\n"
2413 "Priority\n")
2414
paula2c62832003-04-23 17:01:31 +00002415ALIAS (no_ospf_neighbor,
2416 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002417 "no neighbor A.B.C.D poll-interval <1-65535>",
2418 NO_STR
2419 NEIGHBOR_STR
2420 "Neighbor IP address\n"
2421 "Dead Neighbor Polling interval\n"
2422 "Seconds\n")
2423
paula2c62832003-04-23 17:01:31 +00002424ALIAS (no_ospf_neighbor,
2425 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002426 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2427 NO_STR
2428 NEIGHBOR_STR
2429 "Neighbor IP address\n"
2430 "Neighbor Priority\n"
2431 "Priority\n"
2432 "Dead Neighbor Polling interval\n"
2433 "Seconds\n")
2434
2435
paula2c62832003-04-23 17:01:31 +00002436DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002437 "refresh timer <10-1800>",
2438 "Adjust refresh parameters\n"
2439 "Set refresh timer\n"
2440 "Timer value in seconds\n")
2441{
2442 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002443 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002444
2445 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2446 interval = (interval / 10) * 10;
2447
2448 ospf_timers_refresh_set (ospf, interval);
2449
2450 return CMD_SUCCESS;
2451}
2452
paula2c62832003-04-23 17:01:31 +00002453DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002454 "no refresh timer <10-1800>",
2455 "Adjust refresh parameters\n"
2456 "Unset refresh timer\n"
2457 "Timer value in seconds\n")
2458{
2459 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002460 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002461
2462 if (argc == 1)
2463 {
2464 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2465
2466 if (ospf->lsa_refresh_interval != interval ||
2467 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2468 return CMD_SUCCESS;
2469 }
2470
2471 ospf_timers_refresh_unset (ospf);
2472
2473 return CMD_SUCCESS;
2474}
2475
paula2c62832003-04-23 17:01:31 +00002476ALIAS (no_ospf_refresh_timer,
2477 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002478 "no refresh timer",
2479 "Adjust refresh parameters\n"
2480 "Unset refresh timer\n")
2481
paula2c62832003-04-23 17:01:31 +00002482DEFUN (ospf_auto_cost_reference_bandwidth,
2483 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002484 "auto-cost reference-bandwidth <1-4294967>",
2485 "Calculate OSPF interface cost according to bandwidth\n"
2486 "Use reference bandwidth method to assign OSPF cost\n"
2487 "The reference bandwidth in terms of Mbits per second\n")
2488{
paul68980082003-03-25 05:07:42 +00002489 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002490 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002491 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002492 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002493
2494 refbw = strtol (argv[0], NULL, 10);
2495 if (refbw < 1 || refbw > 4294967)
2496 {
2497 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2498 return CMD_WARNING;
2499 }
2500
2501 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002502 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002503 return CMD_SUCCESS;
2504
paul68980082003-03-25 05:07:42 +00002505 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002506 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2507 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002508
2509 return CMD_SUCCESS;
2510}
2511
paula2c62832003-04-23 17:01:31 +00002512DEFUN (no_ospf_auto_cost_reference_bandwidth,
2513 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002514 "no auto-cost reference-bandwidth",
2515 NO_STR
2516 "Calculate OSPF interface cost according to bandwidth\n"
2517 "Use reference bandwidth method to assign OSPF cost\n")
2518{
paul68980082003-03-25 05:07:42 +00002519 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002520 struct listnode *node, *nnode;
2521 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002522
paul68980082003-03-25 05:07:42 +00002523 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002524 return CMD_SUCCESS;
2525
paul68980082003-03-25 05:07:42 +00002526 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002527 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2528 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2529
paul1eb8ef22005-04-07 07:30:20 +00002530 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2531 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002532
2533 return CMD_SUCCESS;
2534}
2535
hassoeb1ce602004-10-08 08:17:22 +00002536const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002537{
2538 "Unknown",
2539 "Standard (RFC2328)",
2540 "Alternative IBM",
2541 "Alternative Cisco",
2542 "Alternative Shortcut"
2543};
2544
hassoeb1ce602004-10-08 08:17:22 +00002545const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002546{
2547 "Default",
2548 "Enabled",
2549 "Disabled"
2550};
2551
2552
2553
paul4dadc292005-05-06 21:37:42 +00002554static void
paul718e3742002-12-13 20:15:29 +00002555show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2556{
2557 /* Show Area ID. */
2558 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2559
2560 /* Show Area type/mode. */
2561 if (OSPF_IS_AREA_BACKBONE (area))
2562 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2563 else
2564 {
2565 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002566 vty_out (vty, " (Stub%s%s)",
2567 area->no_summary ? ", no summary" : "",
2568 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002569
paulb0a053b2003-06-22 09:04:47 +00002570 else if (area->external_routing == OSPF_AREA_NSSA)
2571 vty_out (vty, " (NSSA%s%s)",
2572 area->no_summary ? ", no summary" : "",
2573 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002574
2575 vty_out (vty, "%s", VTY_NEWLINE);
2576 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002577 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002578 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002579 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002580 }
2581
2582 /* Show number of interfaces. */
2583 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2584 "Active: %d%s", listcount (area->oiflist),
2585 area->act_ints, VTY_NEWLINE);
2586
paul718e3742002-12-13 20:15:29 +00002587 if (area->external_routing == OSPF_AREA_NSSA)
2588 {
2589 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00002590 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002591 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2592 VTY_NEWLINE);
2593 else if (area->NSSATranslatorState)
2594 {
2595 vty_out (vty, " We are an ABR and ");
2596 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2597 vty_out (vty, "the NSSA Elected Translator. %s",
2598 VTY_NEWLINE);
2599 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2600 vty_out (vty, "always an NSSA Translator. %s",
2601 VTY_NEWLINE);
2602 }
paul718e3742002-12-13 20:15:29 +00002603 else
paulb0a053b2003-06-22 09:04:47 +00002604 {
2605 vty_out (vty, " We are an ABR, but ");
2606 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2607 vty_out (vty, "not the NSSA Elected Translator. %s",
2608 VTY_NEWLINE);
2609 else
hassoc6b87812004-12-22 13:09:59 +00002610 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002611 VTY_NEWLINE);
2612 }
paul718e3742002-12-13 20:15:29 +00002613 }
paul88d6cf32005-10-29 12:50:09 +00002614 /* Stub-router state for this area */
2615 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2616 {
ajs649654a2005-11-16 20:17:52 +00002617 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002618 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2619 VTY_NEWLINE);
2620 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2621 vty_out (vty, " Administratively activated (indefinitely)%s",
2622 VTY_NEWLINE);
2623 if (area->t_stub_router)
2624 vty_out (vty, " Active from startup, %s remaining%s",
2625 ospf_timer_dump (area->t_stub_router, timebuf,
2626 sizeof(timebuf)), VTY_NEWLINE);
2627 }
2628
paul718e3742002-12-13 20:15:29 +00002629 /* Show number of fully adjacent neighbors. */
2630 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002631 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002632
2633 /* Show authentication type. */
2634 vty_out (vty, " Area has ");
2635 if (area->auth_type == OSPF_AUTH_NULL)
2636 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2637 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2638 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2639 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2640 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2641
2642 if (!OSPF_IS_AREA_BACKBONE (area))
2643 vty_out (vty, " Number of full virtual adjacencies going through"
2644 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2645
2646 /* Show SPF calculation times. */
2647 vty_out (vty, " SPF algorithm executed %d times%s",
2648 area->spf_calculation, VTY_NEWLINE);
2649
2650 /* Show number of LSA. */
2651 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002652 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2653 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2654 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2655 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2656 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2657 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2658 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2659 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2660 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2661 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2662 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2663 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2664 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2665 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2666 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2667#ifdef HAVE_OPAQUE_LSA
2668 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2669 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2670 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2671 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2672 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2673 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2674#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002675 vty_out (vty, "%s", VTY_NEWLINE);
2676}
2677
2678DEFUN (show_ip_ospf,
2679 show_ip_ospf_cmd,
2680 "show ip ospf",
2681 SHOW_STR
2682 IP_STR
2683 "OSPF information\n")
2684{
paul1eb8ef22005-04-07 07:30:20 +00002685 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002686 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002687 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002688 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002689 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002690
2691 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002692 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002693 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002694 {
2695 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2696 return CMD_SUCCESS;
2697 }
2698
2699 /* Show Router ID. */
2700 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002701 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002702 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002703
2704 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002705 if (ospf->t_deferred_shutdown)
2706 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2707 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002708 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002709 /* Show capability. */
2710 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2711 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2712 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002713 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002714 "enabled" : "disabled", VTY_NEWLINE);
2715#ifdef HAVE_OPAQUE_LSA
2716 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002717 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002718 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002719 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002720 " (origination blocked)" : "",
2721 VTY_NEWLINE);
2722#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002723
2724 /* Show stub-router configuration */
2725 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2726 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2727 {
2728 vty_out (vty, " Stub router advertisement is configured%s",
2729 VTY_NEWLINE);
2730 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2731 vty_out (vty, " Enabled for %us after start-up%s",
2732 ospf->stub_router_startup_time, VTY_NEWLINE);
2733 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2734 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2735 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2736 }
2737
paul718e3742002-12-13 20:15:29 +00002738 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002739 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2740 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2741 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2742 " Hold time multiplier is currently %d%s",
2743 ospf->spf_delay, VTY_NEWLINE,
2744 ospf->spf_holdtime, VTY_NEWLINE,
2745 ospf->spf_max_holdtime, VTY_NEWLINE,
2746 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002747 vty_out (vty, " SPF algorithm ");
2748 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2749 {
Paul Jakma2518efd2006-08-27 06:49:29 +00002750 result = tv_sub (recent_relative_time (), ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002751 vty_out (vty, "last executed %s ago%s",
2752 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2753 VTY_NEWLINE);
2754 }
2755 else
2756 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002757 vty_out (vty, " SPF timer %s%s%s",
2758 (ospf->t_spf_calc ? "due in " : "is "),
2759 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2760 VTY_NEWLINE);
2761
paul718e3742002-12-13 20:15:29 +00002762 /* Show refresh parameters. */
2763 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002764 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002765
2766 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002767 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002768 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002769 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002770
paul68980082003-03-25 05:07:42 +00002771 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002772 vty_out (vty, " This router is an ASBR "
2773 "(injecting external routing information)%s", VTY_NEWLINE);
2774
2775 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002776 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2777 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2778 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2779#ifdef HAVE_OPAQUE_LSA
2780 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2781 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2782 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2783#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002784 /* Show number of areas attached. */
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002785 vty_out (vty, " Number of areas attached to this router: %d%s",
2786 listcount (ospf->areas), VTY_NEWLINE);
2787
2788 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2789 {
2790 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2791 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2792 else
2793 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2794 }
2795
2796 vty_out (vty, "%s",VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002797
2798 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002799 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2800 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002801
2802 return CMD_SUCCESS;
2803}
2804
2805
ajsfd651fa2005-03-29 16:08:16 +00002806static void
paul68980082003-03-25 05:07:42 +00002807show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2808 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002809{
ajsfd651fa2005-03-29 16:08:16 +00002810 int is_up;
paul718e3742002-12-13 20:15:29 +00002811 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002812 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002813
paul718e3742002-12-13 20:15:29 +00002814 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002815 vty_out (vty, "%s is %s%s", ifp->name,
2816 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002817 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2818 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2819 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002820
2821 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002822 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002823 {
2824 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2825 return;
2826 }
ajsfd651fa2005-03-29 16:08:16 +00002827 else if (!is_up)
2828 {
2829 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2830 VTY_NEWLINE);
2831 return;
2832 }
2833
paul718e3742002-12-13 20:15:29 +00002834 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2835 {
2836 struct ospf_interface *oi = rn->info;
2837
2838 if (oi == NULL)
2839 continue;
2840
2841 /* Show OSPF interface information. */
2842 vty_out (vty, " Internet Address %s/%d,",
2843 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2844
Paul Jakma9c27ef92006-05-04 07:32:57 +00002845 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2846 {
2847 struct in_addr *dest;
2848 const char *dstr;
2849
Andrew J. Schorre4529632006-12-12 19:18:21 +00002850 if (CONNECTED_PEER(oi->connected)
2851 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
Paul Jakma9c27ef92006-05-04 07:32:57 +00002852 dstr = "Peer";
2853 else
2854 dstr = "Broadcast";
2855
2856 /* For Vlinks, showing the peer address is probably more
2857 * informative than the local interface that is being used
2858 */
2859 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2860 dest = &oi->vl_data->peer_addr;
2861 else
2862 dest = &oi->connected->destination->u.prefix4;
2863
2864 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2865 }
hasso3fb9cd62004-10-19 19:44:43 +00002866
paul718e3742002-12-13 20:15:29 +00002867 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2868 VTY_NEWLINE);
2869
vincentba682532005-09-29 13:52:57 +00002870 vty_out (vty, " MTU mismatch detection:%s%s",
2871 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2872
paul718e3742002-12-13 20:15:29 +00002873 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002874 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002875 oi->output_cost, VTY_NEWLINE);
2876
2877 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2878 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2879 PRIORITY (oi), VTY_NEWLINE);
2880
2881 /* Show DR information. */
2882 if (DR (oi).s_addr == 0)
2883 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2884 else
2885 {
2886 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2887 if (nbr == NULL)
2888 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2889 else
2890 {
2891 vty_out (vty, " Designated Router (ID) %s,",
2892 inet_ntoa (nbr->router_id));
2893 vty_out (vty, " Interface Address %s%s",
2894 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2895 }
2896 }
2897
2898 /* Show BDR information. */
2899 if (BDR (oi).s_addr == 0)
2900 vty_out (vty, " No backup designated router on this network%s",
2901 VTY_NEWLINE);
2902 else
2903 {
2904 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2905 if (nbr == NULL)
2906 vty_out (vty, " No backup designated router on this network%s",
2907 VTY_NEWLINE);
2908 else
2909 {
2910 vty_out (vty, " Backup Designated Router (ID) %s,",
2911 inet_ntoa (nbr->router_id));
2912 vty_out (vty, " Interface Address %s%s",
2913 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2914 }
2915 }
Paul Jakma7eb5b472009-10-13 16:13:13 +01002916
2917 /* Next network-LSA sequence number we'll use, if we're elected DR */
2918 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
2919 != OSPF_INITIAL_SEQUENCE_NUMBER)
2920 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
2921 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
2922
ajsba6454e2005-02-08 15:37:30 +00002923 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00002924 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2925 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2926 {
2927 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2928 vty_out (vty, " OSPFAllRouters");
2929 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2930 vty_out (vty, " OSPFDesignatedRouters");
2931 }
2932 else
ajsba6454e2005-02-08 15:37:30 +00002933 vty_out (vty, " <None>");
2934 vty_out (vty, "%s", VTY_NEWLINE);
2935
paul718e3742002-12-13 20:15:29 +00002936 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002937 vty_out (vty, " Hello ");
2938 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2939 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2940 else
2941 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2942 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2943 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002944 OSPF_IF_PARAM (oi, v_wait),
2945 OSPF_IF_PARAM (oi, retransmit_interval),
2946 VTY_NEWLINE);
2947
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002948 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002949 {
ajs649654a2005-11-16 20:17:52 +00002950 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00002951 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00002952 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00002953 VTY_NEWLINE);
2954 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00002955 else /* passive-interface is set */
paul718e3742002-12-13 20:15:29 +00002956 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2957
2958 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002959 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002960 VTY_NEWLINE);
2961 }
2962}
2963
2964DEFUN (show_ip_ospf_interface,
2965 show_ip_ospf_interface_cmd,
2966 "show ip ospf interface [INTERFACE]",
2967 SHOW_STR
2968 IP_STR
2969 "OSPF information\n"
2970 "Interface information\n"
2971 "Interface name\n")
2972{
2973 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002974 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002975 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002976
paul020709f2003-04-04 02:44:16 +00002977 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00002978 if (ospf == NULL)
2979 {
2980 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2981 return CMD_SUCCESS;
2982 }
paul020709f2003-04-04 02:44:16 +00002983
paul718e3742002-12-13 20:15:29 +00002984 /* Show All Interfaces. */
2985 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002986 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2987 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002988 /* Interface name is specified. */
2989 else
2990 {
2991 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2992 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2993 else
paul68980082003-03-25 05:07:42 +00002994 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002995 }
2996
2997 return CMD_SUCCESS;
2998}
2999
paul4dadc292005-05-06 21:37:42 +00003000static void
pauld24f6e22005-10-21 09:23:12 +00003001show_ip_ospf_neighbour_header (struct vty *vty)
3002{
3003 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3004 VTY_NEWLINE,
3005 "Neighbor ID", "Pri", "State", "Dead Time",
3006 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3007 VTY_NEWLINE);
3008}
3009
3010static void
paul718e3742002-12-13 20:15:29 +00003011show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3012{
3013 struct route_node *rn;
3014 struct ospf_neighbor *nbr;
3015 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00003016 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003017
3018 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3019 if ((nbr = rn->info))
3020 /* Do not show myself. */
3021 if (nbr != oi->nbr_self)
3022 /* Down state is not shown. */
3023 if (nbr->state != NSM_Down)
3024 {
3025 ospf_nbr_state_message (nbr, msgbuf, 16);
3026
3027 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00003028 vty_out (vty, "%-15s %3d %-15s ",
3029 "-", nbr->priority,
3030 msgbuf);
3031 else
3032 vty_out (vty, "%-15s %3d %-15s ",
3033 inet_ntoa (nbr->router_id), nbr->priority,
3034 msgbuf);
3035
3036 vty_out (vty, "%9s ",
3037 ospf_timer_dump (nbr->t_inactivity, timebuf,
3038 sizeof(timebuf)));
3039
paul718e3742002-12-13 20:15:29 +00003040 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00003041 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00003042 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3043 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3044 VTY_NEWLINE);
3045 }
3046}
3047
3048DEFUN (show_ip_ospf_neighbor,
3049 show_ip_ospf_neighbor_cmd,
3050 "show ip ospf neighbor",
3051 SHOW_STR
3052 IP_STR
3053 "OSPF information\n"
3054 "Neighbor list\n")
3055{
paul020709f2003-04-04 02:44:16 +00003056 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003057 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003058 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003059
paul020709f2003-04-04 02:44:16 +00003060 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003061 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003062 {
3063 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3064 return CMD_SUCCESS;
3065 }
3066
pauld24f6e22005-10-21 09:23:12 +00003067 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003068
paul1eb8ef22005-04-07 07:30:20 +00003069 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3070 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003071
3072 return CMD_SUCCESS;
3073}
3074
3075DEFUN (show_ip_ospf_neighbor_all,
3076 show_ip_ospf_neighbor_all_cmd,
3077 "show ip ospf neighbor all",
3078 SHOW_STR
3079 IP_STR
3080 "OSPF information\n"
3081 "Neighbor list\n"
3082 "include down status neighbor\n")
3083{
Joakim Tjernlund35f89142008-07-01 16:54:07 +02003084 struct ospf *ospf = ospf_lookup ();
hasso52dc7ee2004-09-23 19:18:23 +00003085 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003086 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003087
paul68980082003-03-25 05:07:42 +00003088 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003089 {
3090 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3091 return CMD_SUCCESS;
3092 }
pauld24f6e22005-10-21 09:23:12 +00003093
3094 show_ip_ospf_neighbour_header (vty);
3095
paul1eb8ef22005-04-07 07:30:20 +00003096 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003097 {
hasso52dc7ee2004-09-23 19:18:23 +00003098 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003099 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003100
3101 show_ip_ospf_neighbor_sub (vty, oi);
3102
3103 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003104 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003105 {
paul718e3742002-12-13 20:15:29 +00003106 if (nbr_nbma->nbr == NULL
3107 || nbr_nbma->nbr->state == NSM_Down)
3108 {
pauld24f6e22005-10-21 09:23:12 +00003109 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003110 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003111 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003112 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3113 0, 0, 0, VTY_NEWLINE);
3114 }
3115 }
3116 }
3117
3118 return CMD_SUCCESS;
3119}
3120
3121DEFUN (show_ip_ospf_neighbor_int,
3122 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003123 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003124 SHOW_STR
3125 IP_STR
3126 "OSPF information\n"
3127 "Neighbor list\n"
3128 "Interface name\n")
3129{
paul020709f2003-04-04 02:44:16 +00003130 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003131 struct interface *ifp;
3132 struct route_node *rn;
3133
3134 ifp = if_lookup_by_name (argv[0]);
3135 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003136 {
hassobb5b7552005-08-21 20:01:15 +00003137 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003138 return CMD_WARNING;
3139 }
3140
paul020709f2003-04-04 02:44:16 +00003141 ospf = ospf_lookup ();
3142 if (ospf == NULL)
3143 {
3144 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3145 return CMD_SUCCESS;
3146 }
pauld24f6e22005-10-21 09:23:12 +00003147
3148 show_ip_ospf_neighbour_header (vty);
3149
hassobb5b7552005-08-21 20:01:15 +00003150 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003151 {
hassobb5b7552005-08-21 20:01:15 +00003152 struct ospf_interface *oi = rn->info;
3153
3154 if (oi == NULL)
3155 continue;
3156
paul718e3742002-12-13 20:15:29 +00003157 show_ip_ospf_neighbor_sub (vty, oi);
3158 }
3159
3160 return CMD_SUCCESS;
3161}
3162
paul4dadc292005-05-06 21:37:42 +00003163static void
paul718e3742002-12-13 20:15:29 +00003164show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3165 struct ospf_nbr_nbma *nbr_nbma)
3166{
ajs649654a2005-11-16 20:17:52 +00003167 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003168
3169 /* Show neighbor ID. */
3170 vty_out (vty, " Neighbor %s,", "-");
3171
3172 /* Show interface address. */
3173 vty_out (vty, " interface address %s%s",
3174 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3175 /* Show Area ID. */
3176 vty_out (vty, " In the area %s via interface %s%s",
3177 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3178 /* Show neighbor priority and state. */
3179 vty_out (vty, " Neighbor priority is %d, State is %s,",
3180 nbr_nbma->priority, "Down");
3181 /* Show state changes. */
3182 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3183
3184 /* Show PollInterval */
3185 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3186
3187 /* Show poll-interval timer. */
3188 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003189 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3190 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003191
3192 /* Show poll-interval timer thread. */
3193 vty_out (vty, " Thread Poll Timer %s%s",
3194 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3195}
3196
paul4dadc292005-05-06 21:37:42 +00003197static void
paul718e3742002-12-13 20:15:29 +00003198show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3199 struct ospf_neighbor *nbr)
3200{
ajs649654a2005-11-16 20:17:52 +00003201 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003202
3203 /* Show neighbor ID. */
3204 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3205 vty_out (vty, " Neighbor %s,", "-");
3206 else
3207 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3208
3209 /* Show interface address. */
3210 vty_out (vty, " interface address %s%s",
3211 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3212 /* Show Area ID. */
3213 vty_out (vty, " In the area %s via interface %s%s",
3214 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3215 /* Show neighbor priority and state. */
3216 vty_out (vty, " Neighbor priority is %d, State is %s,",
3217 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3218 /* Show state changes. */
3219 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
Paul Jakma3fed4162006-07-25 20:44:12 +00003220 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
Paul Jakma90c33172006-07-11 17:57:25 +00003221 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003222 struct timeval res
3223 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003224 vty_out (vty, " Most recent state change statistics:%s",
3225 VTY_NEWLINE);
3226 vty_out (vty, " Progressive change %s ago%s",
Paul Jakma90c33172006-07-11 17:57:25 +00003227 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
Paul Jakma3fed4162006-07-25 20:44:12 +00003228 VTY_NEWLINE);
3229 }
3230 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3231 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003232 struct timeval res
3233 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003234 vty_out (vty, " Regressive change %s ago, due to %s%s",
3235 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3236 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
Paul Jakma90c33172006-07-11 17:57:25 +00003237 VTY_NEWLINE);
3238 }
paul718e3742002-12-13 20:15:29 +00003239 /* Show Designated Rotuer ID. */
3240 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3241 /* Show Backup Designated Rotuer ID. */
3242 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3243 /* Show options. */
3244 vty_out (vty, " Options %d %s%s", nbr->options,
3245 ospf_options_dump (nbr->options), VTY_NEWLINE);
3246 /* Show Router Dead interval timer. */
3247 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003248 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3249 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003250 /* Show Database Summary list. */
3251 vty_out (vty, " Database Summary List %d%s",
3252 ospf_db_summary_count (nbr), VTY_NEWLINE);
3253 /* Show Link State Request list. */
3254 vty_out (vty, " Link State Request List %ld%s",
3255 ospf_ls_request_count (nbr), VTY_NEWLINE);
3256 /* Show Link State Retransmission list. */
3257 vty_out (vty, " Link State Retransmission List %ld%s",
3258 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3259 /* Show inactivity timer thread. */
3260 vty_out (vty, " Thread Inactivity Timer %s%s",
3261 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3262 /* Show Database Description retransmission thread. */
3263 vty_out (vty, " Thread Database Description Retransmision %s%s",
3264 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3265 /* Show Link State Request Retransmission thread. */
3266 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3267 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3268 /* Show Link State Update Retransmission thread. */
3269 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3270 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3271}
3272
3273DEFUN (show_ip_ospf_neighbor_id,
3274 show_ip_ospf_neighbor_id_cmd,
3275 "show ip ospf neighbor A.B.C.D",
3276 SHOW_STR
3277 IP_STR
3278 "OSPF information\n"
3279 "Neighbor list\n"
3280 "Neighbor ID\n")
3281{
paul020709f2003-04-04 02:44:16 +00003282 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003283 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003284 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003285 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003286 struct in_addr router_id;
3287 int ret;
3288
3289 ret = inet_aton (argv[0], &router_id);
3290 if (!ret)
3291 {
3292 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3293 return CMD_WARNING;
3294 }
3295
paul020709f2003-04-04 02:44:16 +00003296 ospf = ospf_lookup ();
3297 if (ospf == NULL)
3298 {
3299 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3300 return CMD_SUCCESS;
3301 }
3302
paul1eb8ef22005-04-07 07:30:20 +00003303 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3304 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003305 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003306
paul718e3742002-12-13 20:15:29 +00003307 return CMD_SUCCESS;
3308}
3309
3310DEFUN (show_ip_ospf_neighbor_detail,
3311 show_ip_ospf_neighbor_detail_cmd,
3312 "show ip ospf neighbor detail",
3313 SHOW_STR
3314 IP_STR
3315 "OSPF information\n"
3316 "Neighbor list\n"
3317 "detail of all neighbors\n")
3318{
paul020709f2003-04-04 02:44:16 +00003319 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003320 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003321 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003322
paul020709f2003-04-04 02:44:16 +00003323 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003324 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003325 {
3326 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3327 return CMD_SUCCESS;
3328 }
paul718e3742002-12-13 20:15:29 +00003329
paul1eb8ef22005-04-07 07:30:20 +00003330 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003331 {
paul718e3742002-12-13 20:15:29 +00003332 struct route_node *rn;
3333 struct ospf_neighbor *nbr;
3334
3335 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3336 if ((nbr = rn->info))
3337 if (nbr != oi->nbr_self)
3338 if (nbr->state != NSM_Down)
3339 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3340 }
3341
3342 return CMD_SUCCESS;
3343}
3344
3345DEFUN (show_ip_ospf_neighbor_detail_all,
3346 show_ip_ospf_neighbor_detail_all_cmd,
3347 "show ip ospf neighbor detail all",
3348 SHOW_STR
3349 IP_STR
3350 "OSPF information\n"
3351 "Neighbor list\n"
3352 "detail of all neighbors\n"
3353 "include down status neighbor\n")
3354{
paul020709f2003-04-04 02:44:16 +00003355 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003356 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003357 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003358
paul020709f2003-04-04 02:44:16 +00003359 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003360 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003361 {
3362 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3363 return CMD_SUCCESS;
3364 }
paul718e3742002-12-13 20:15:29 +00003365
paul1eb8ef22005-04-07 07:30:20 +00003366 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003367 {
paul718e3742002-12-13 20:15:29 +00003368 struct route_node *rn;
3369 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003370 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003371
3372 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3373 if ((nbr = rn->info))
3374 if (nbr != oi->nbr_self)
3375 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3376 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3377
3378 if (oi->type == OSPF_IFTYPE_NBMA)
3379 {
hasso52dc7ee2004-09-23 19:18:23 +00003380 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003381
paul1eb8ef22005-04-07 07:30:20 +00003382 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3383 if (nbr_nbma->nbr == NULL
3384 || nbr_nbma->nbr->state == NSM_Down)
3385 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003386 }
3387 }
3388
3389 return CMD_SUCCESS;
3390}
3391
3392DEFUN (show_ip_ospf_neighbor_int_detail,
3393 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003394 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003395 SHOW_STR
3396 IP_STR
3397 "OSPF information\n"
3398 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003399 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003400 "detail of all neighbors")
3401{
paul020709f2003-04-04 02:44:16 +00003402 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003403 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003404 struct interface *ifp;
3405 struct route_node *rn, *nrn;
3406 struct ospf_neighbor *nbr;
3407
3408 ifp = if_lookup_by_name (argv[0]);
3409 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003410 {
hassobb5b7552005-08-21 20:01:15 +00003411 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003412 return CMD_WARNING;
3413 }
3414
paul020709f2003-04-04 02:44:16 +00003415 ospf = ospf_lookup ();
3416 if (ospf == NULL)
3417 {
3418 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3419 return CMD_SUCCESS;
3420 }
paul68980082003-03-25 05:07:42 +00003421
paul718e3742002-12-13 20:15:29 +00003422
hassobb5b7552005-08-21 20:01:15 +00003423 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3424 if ((oi = rn->info))
3425 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3426 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003427 if (nbr != oi->nbr_self)
3428 if (nbr->state != NSM_Down)
3429 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003430
3431 return CMD_SUCCESS;
3432}
3433
3434
3435/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003436static int
paul020709f2003-04-04 02:44:16 +00003437show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003438{
paul718e3742002-12-13 20:15:29 +00003439 struct router_lsa *rl;
3440 struct summary_lsa *sl;
3441 struct as_external_lsa *asel;
3442 struct prefix_ipv4 p;
3443
3444 if (lsa != NULL)
3445 /* If self option is set, check LSA self flag. */
3446 if (self == 0 || IS_LSA_SELF (lsa))
3447 {
3448 /* LSA common part show. */
3449 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3450 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3451 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3452 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3453 /* LSA specific part show. */
3454 switch (lsa->data->type)
3455 {
3456 case OSPF_ROUTER_LSA:
3457 rl = (struct router_lsa *) lsa->data;
3458 vty_out (vty, " %-d", ntohs (rl->links));
3459 break;
3460 case OSPF_SUMMARY_LSA:
3461 sl = (struct summary_lsa *) lsa->data;
3462
3463 p.family = AF_INET;
3464 p.prefix = sl->header.id;
3465 p.prefixlen = ip_masklen (sl->mask);
3466 apply_mask_ipv4 (&p);
3467
3468 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3469 break;
3470 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003471 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003472 asel = (struct as_external_lsa *) lsa->data;
3473
3474 p.family = AF_INET;
3475 p.prefix = asel->header.id;
3476 p.prefixlen = ip_masklen (asel->mask);
3477 apply_mask_ipv4 (&p);
3478
3479 vty_out (vty, " %s %s/%d [0x%lx]",
3480 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3481 inet_ntoa (p.prefix), p.prefixlen,
3482 (u_long)ntohl (asel->e[0].route_tag));
3483 break;
3484 case OSPF_NETWORK_LSA:
3485 case OSPF_ASBR_SUMMARY_LSA:
3486#ifdef HAVE_OPAQUE_LSA
3487 case OSPF_OPAQUE_LINK_LSA:
3488 case OSPF_OPAQUE_AREA_LSA:
3489 case OSPF_OPAQUE_AS_LSA:
3490#endif /* HAVE_OPAQUE_LSA */
3491 default:
3492 break;
3493 }
3494 vty_out (vty, VTY_NEWLINE);
3495 }
3496
3497 return 0;
3498}
3499
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003500static const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003501{
3502 "unknown",
3503 "Router Link States",
3504 "Net Link States",
3505 "Summary Link States",
3506 "ASBR-Summary Link States",
3507 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003508 "Group Membership LSA",
3509 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003510#ifdef HAVE_OPAQUE_LSA
3511 "Type-8 LSA",
3512 "Link-Local Opaque-LSA",
3513 "Area-Local Opaque-LSA",
3514 "AS-external Opaque-LSA",
3515#endif /* HAVE_OPAQUE_LSA */
3516};
3517
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003518static const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003519{
3520 "",
3521 "Link ID ADV Router Age Seq# CkSum Link count",
3522 "Link ID ADV Router Age Seq# CkSum",
3523 "Link ID ADV Router Age Seq# CkSum Route",
3524 "Link ID ADV Router Age Seq# CkSum",
3525 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003526 " --- header for Group Member ----",
3527 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003528#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003529 " --- type-8 ---",
3530 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3531 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3532 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3533#endif /* HAVE_OPAQUE_LSA */
3534};
3535
paul4dadc292005-05-06 21:37:42 +00003536static void
paul718e3742002-12-13 20:15:29 +00003537show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3538{
3539 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003540
paul718e3742002-12-13 20:15:29 +00003541 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003542 vty_out (vty, " Options: 0x%-2x : %s%s",
3543 lsa->data->options,
3544 ospf_options_dump(lsa->data->options),
3545 VTY_NEWLINE);
3546 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003547 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003548 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3549 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003550
3551 if (lsa->data->type == OSPF_ROUTER_LSA)
3552 {
3553 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3554
3555 if (rlsa->flags)
3556 vty_out (vty, " :%s%s%s%s",
3557 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3558 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3559 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3560 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3561
3562 vty_out (vty, "%s", VTY_NEWLINE);
3563 }
3564 vty_out (vty, " LS Type: %s%s",
3565 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3566 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3567 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3568 vty_out (vty, " Advertising Router: %s%s",
3569 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3570 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3571 VTY_NEWLINE);
3572 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3573 VTY_NEWLINE);
3574 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3575}
3576
hassoeb1ce602004-10-08 08:17:22 +00003577const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003578{
3579 "(null)",
3580 "another Router (point-to-point)",
3581 "a Transit Network",
3582 "Stub Network",
3583 "a Virtual Link",
3584};
3585
hassoeb1ce602004-10-08 08:17:22 +00003586const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003587{
3588 "(null)",
3589 "Neighboring Router ID",
3590 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003591 "Net",
paul718e3742002-12-13 20:15:29 +00003592 "Neighboring Router ID",
3593};
3594
hassoeb1ce602004-10-08 08:17:22 +00003595const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003596{
3597 "(null)",
3598 "Router Interface address",
3599 "Router Interface address",
3600 "Network Mask",
3601 "Router Interface address",
3602};
3603
3604/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003605static void
paul718e3742002-12-13 20:15:29 +00003606show_ip_ospf_database_router_links (struct vty *vty,
3607 struct router_lsa *rl)
3608{
3609 int len, i, type;
3610
3611 len = ntohs (rl->header.length) - 4;
3612 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3613 {
3614 type = rl->link[i].type;
3615
3616 vty_out (vty, " Link connected to: %s%s",
3617 link_type_desc[type], VTY_NEWLINE);
3618 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3619 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3620 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3621 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3622 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3623 vty_out (vty, " TOS 0 Metric: %d%s",
3624 ntohs (rl->link[i].metric), VTY_NEWLINE);
3625 vty_out (vty, "%s", VTY_NEWLINE);
3626 }
3627}
3628
3629/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003630static int
paul718e3742002-12-13 20:15:29 +00003631show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3632{
3633 if (lsa != NULL)
3634 {
3635 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3636
3637 show_ip_ospf_database_header (vty, lsa);
3638
3639 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3640 VTY_NEWLINE, VTY_NEWLINE);
3641
3642 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003643 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003644 }
3645
3646 return 0;
3647}
3648
3649/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003650static int
paul718e3742002-12-13 20:15:29 +00003651show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3652{
3653 int length, i;
3654
3655 if (lsa != NULL)
3656 {
3657 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3658
3659 show_ip_ospf_database_header (vty, lsa);
3660
3661 vty_out (vty, " Network Mask: /%d%s",
3662 ip_masklen (nl->mask), VTY_NEWLINE);
3663
3664 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3665
3666 for (i = 0; length > 0; i++, length -= 4)
3667 vty_out (vty, " Attached Router: %s%s",
3668 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3669
3670 vty_out (vty, "%s", VTY_NEWLINE);
3671 }
3672
3673 return 0;
3674}
3675
3676/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003677static int
paul718e3742002-12-13 20:15:29 +00003678show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3679{
3680 if (lsa != NULL)
3681 {
3682 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3683
3684 show_ip_ospf_database_header (vty, lsa);
3685
3686 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3687 VTY_NEWLINE);
3688 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3689 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003690 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003691 }
3692
3693 return 0;
3694}
3695
3696/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003697static int
paul718e3742002-12-13 20:15:29 +00003698show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3699{
3700 if (lsa != NULL)
3701 {
3702 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3703
3704 show_ip_ospf_database_header (vty, lsa);
3705
3706 vty_out (vty, " Network Mask: /%d%s",
3707 ip_masklen (sl->mask), VTY_NEWLINE);
3708 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3709 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003710 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003711 }
3712
3713 return 0;
3714}
3715
3716/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003717static int
paul718e3742002-12-13 20:15:29 +00003718show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3719{
3720 if (lsa != NULL)
3721 {
3722 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3723
3724 show_ip_ospf_database_header (vty, lsa);
3725
3726 vty_out (vty, " Network Mask: /%d%s",
3727 ip_masklen (al->mask), VTY_NEWLINE);
3728 vty_out (vty, " Metric Type: %s%s",
3729 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3730 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3731 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3732 vty_out (vty, " Metric: %d%s",
3733 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3734 vty_out (vty, " Forward Address: %s%s",
3735 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3736
3737 vty_out (vty, " External Route Tag: %lu%s%s",
3738 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3739 }
3740
3741 return 0;
3742}
3743
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003744#if 0
paul4dadc292005-05-06 21:37:42 +00003745static int
paul718e3742002-12-13 20:15:29 +00003746show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3747{
3748 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3749
3750 /* show_ip_ospf_database_header (vty, lsa); */
3751
ajs2a42e282004-12-08 18:43:03 +00003752 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003753 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003754 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003755 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3756 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003757 zlog_debug( " TOS: 0%s", "\n");
3758 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003759 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003760 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003761 inet_ntoa (al->e[0].fwd_addr), "\n");
3762
ajs2a42e282004-12-08 18:43:03 +00003763 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003764 ntohl (al->e[0].route_tag), "\n", "\n");
3765
3766 return 0;
3767}
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003768#endif
paul718e3742002-12-13 20:15:29 +00003769
3770/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003771static int
paul718e3742002-12-13 20:15:29 +00003772show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3773{
3774 if (lsa != NULL)
3775 {
3776 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3777
3778 show_ip_ospf_database_header (vty, lsa);
3779
3780 vty_out (vty, " Network Mask: /%d%s",
3781 ip_masklen (al->mask), VTY_NEWLINE);
3782 vty_out (vty, " Metric Type: %s%s",
3783 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3784 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3785 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3786 vty_out (vty, " Metric: %d%s",
3787 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3788 vty_out (vty, " NSSA: Forward Address: %s%s",
3789 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3790
3791 vty_out (vty, " External Route Tag: %u%s%s",
3792 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3793 }
3794
3795 return 0;
3796}
3797
paul4dadc292005-05-06 21:37:42 +00003798static int
paul718e3742002-12-13 20:15:29 +00003799show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3800{
3801 return 0;
3802}
3803
3804#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003805static int
paul718e3742002-12-13 20:15:29 +00003806show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3807{
3808 if (lsa != NULL)
3809 {
3810 show_ip_ospf_database_header (vty, lsa);
3811 show_opaque_info_detail (vty, lsa);
3812
3813 vty_out (vty, "%s", VTY_NEWLINE);
3814 }
3815 return 0;
3816}
3817#endif /* HAVE_OPAQUE_LSA */
3818
3819int (*show_function[])(struct vty *, struct ospf_lsa *) =
3820{
3821 NULL,
3822 show_router_lsa_detail,
3823 show_network_lsa_detail,
3824 show_summary_lsa_detail,
3825 show_summary_asbr_lsa_detail,
3826 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003827 show_func_dummy,
3828 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003829#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003830 NULL, /* type-8 */
3831 show_opaque_lsa_detail,
3832 show_opaque_lsa_detail,
3833 show_opaque_lsa_detail,
3834#endif /* HAVE_OPAQUE_LSA */
3835};
3836
paul4dadc292005-05-06 21:37:42 +00003837static void
paul718e3742002-12-13 20:15:29 +00003838show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3839 struct in_addr *adv_router)
3840{
3841 memset (lp, 0, sizeof (struct prefix_ls));
3842 lp->family = 0;
3843 if (id == NULL)
3844 lp->prefixlen = 0;
3845 else if (adv_router == NULL)
3846 {
3847 lp->prefixlen = 32;
3848 lp->id = *id;
3849 }
3850 else
3851 {
3852 lp->prefixlen = 64;
3853 lp->id = *id;
3854 lp->adv_router = *adv_router;
3855 }
3856}
3857
paul4dadc292005-05-06 21:37:42 +00003858static void
paul718e3742002-12-13 20:15:29 +00003859show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3860 struct in_addr *id, struct in_addr *adv_router)
3861{
3862 struct prefix_ls lp;
3863 struct route_node *rn, *start;
3864 struct ospf_lsa *lsa;
3865
3866 show_lsa_prefix_set (vty, &lp, id, adv_router);
3867 start = route_node_get (rt, (struct prefix *) &lp);
3868 if (start)
3869 {
3870 route_lock_node (start);
3871 for (rn = start; rn; rn = route_next_until (rn, start))
3872 if ((lsa = rn->info))
3873 {
paul718e3742002-12-13 20:15:29 +00003874 if (show_function[lsa->data->type] != NULL)
3875 show_function[lsa->data->type] (vty, lsa);
3876 }
3877 route_unlock_node (start);
3878 }
3879}
3880
3881/* Show detail LSA information
3882 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003883static void
paul020709f2003-04-04 02:44:16 +00003884show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003885 struct in_addr *id, struct in_addr *adv_router)
3886{
hasso52dc7ee2004-09-23 19:18:23 +00003887 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003888 struct ospf_area *area;
3889
paul718e3742002-12-13 20:15:29 +00003890 switch (type)
3891 {
3892 case OSPF_AS_EXTERNAL_LSA:
3893#ifdef HAVE_OPAQUE_LSA
3894 case OSPF_OPAQUE_AS_LSA:
3895#endif /* HAVE_OPAQUE_LSA */
3896 vty_out (vty, " %s %s%s",
3897 show_database_desc[type],
3898 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003899 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003900 break;
3901 default:
paul1eb8ef22005-04-07 07:30:20 +00003902 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003903 {
paul718e3742002-12-13 20:15:29 +00003904 vty_out (vty, "%s %s (Area %s)%s%s",
3905 VTY_NEWLINE, show_database_desc[type],
3906 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3907 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3908 }
3909 break;
3910 }
3911}
3912
paul4dadc292005-05-06 21:37:42 +00003913static void
paul718e3742002-12-13 20:15:29 +00003914show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3915 struct in_addr *adv_router)
3916{
3917 struct route_node *rn;
3918 struct ospf_lsa *lsa;
3919
3920 for (rn = route_top (rt); rn; rn = route_next (rn))
3921 if ((lsa = rn->info))
3922 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3923 {
paul718e3742002-12-13 20:15:29 +00003924 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3925 continue;
paul718e3742002-12-13 20:15:29 +00003926 if (show_function[lsa->data->type] != NULL)
3927 show_function[lsa->data->type] (vty, lsa);
3928 }
3929}
3930
3931/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003932static void
paul020709f2003-04-04 02:44:16 +00003933show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003934 struct in_addr *adv_router)
3935{
hasso52dc7ee2004-09-23 19:18:23 +00003936 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003937 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003938
3939 switch (type)
3940 {
3941 case OSPF_AS_EXTERNAL_LSA:
3942#ifdef HAVE_OPAQUE_LSA
3943 case OSPF_OPAQUE_AS_LSA:
3944#endif /* HAVE_OPAQUE_LSA */
3945 vty_out (vty, " %s %s%s",
3946 show_database_desc[type],
3947 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003948 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003949 adv_router);
3950 break;
3951 default:
paul1eb8ef22005-04-07 07:30:20 +00003952 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003953 {
paul718e3742002-12-13 20:15:29 +00003954 vty_out (vty, "%s %s (Area %s)%s%s",
3955 VTY_NEWLINE, show_database_desc[type],
3956 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3957 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3958 adv_router);
3959 }
3960 break;
3961 }
3962}
3963
paul4dadc292005-05-06 21:37:42 +00003964static void
paul020709f2003-04-04 02:44:16 +00003965show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003966{
paul020709f2003-04-04 02:44:16 +00003967 struct ospf_lsa *lsa;
3968 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003969 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003970 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003971 int type;
3972
paul1eb8ef22005-04-07 07:30:20 +00003973 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003974 {
paul718e3742002-12-13 20:15:29 +00003975 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3976 {
3977 switch (type)
3978 {
3979 case OSPF_AS_EXTERNAL_LSA:
3980#ifdef HAVE_OPAQUE_LSA
3981 case OSPF_OPAQUE_AS_LSA:
3982#endif /* HAVE_OPAQUE_LSA */
3983 continue;
3984 default:
3985 break;
3986 }
3987 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3988 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3989 {
3990 vty_out (vty, " %s (Area %s)%s%s",
3991 show_database_desc[type],
3992 ospf_area_desc_string (area),
3993 VTY_NEWLINE, VTY_NEWLINE);
3994 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3995
paul020709f2003-04-04 02:44:16 +00003996 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3997 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003998
3999 vty_out (vty, "%s", VTY_NEWLINE);
4000 }
4001 }
4002 }
4003
4004 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4005 {
4006 switch (type)
4007 {
4008 case OSPF_AS_EXTERNAL_LSA:
4009#ifdef HAVE_OPAQUE_LSA
4010 case OSPF_OPAQUE_AS_LSA:
4011#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00004012 break;
paul718e3742002-12-13 20:15:29 +00004013 default:
4014 continue;
4015 }
paul68980082003-03-25 05:07:42 +00004016 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4017 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00004018 {
4019 vty_out (vty, " %s%s%s",
4020 show_database_desc[type],
4021 VTY_NEWLINE, VTY_NEWLINE);
4022 vty_out (vty, "%s%s", show_database_header[type],
4023 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00004024
4025 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4026 show_lsa_summary (vty, lsa, self);
4027
paul718e3742002-12-13 20:15:29 +00004028 vty_out (vty, "%s", VTY_NEWLINE);
4029 }
4030 }
4031
4032 vty_out (vty, "%s", VTY_NEWLINE);
4033}
4034
paul4dadc292005-05-06 21:37:42 +00004035static void
paul020709f2003-04-04 02:44:16 +00004036show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00004037{
hasso52dc7ee2004-09-23 19:18:23 +00004038 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00004039 struct ospf_lsa *lsa;
4040
4041 vty_out (vty, "%s MaxAge Link States:%s%s",
4042 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4043
paul1eb8ef22005-04-07 07:30:20 +00004044 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
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 }
paul718e3742002-12-13 20:15:29 +00004054}
4055
paul718e3742002-12-13 20:15:29 +00004056#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4057#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00004058
4059#ifdef HAVE_OPAQUE_LSA
4060#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4061#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4062#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4063#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4064#else /* HAVE_OPAQUE_LSA */
4065#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4066#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4067#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4068#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4069#endif /* HAVE_OPAQUE_LSA */
4070
4071#define OSPF_LSA_TYPES_CMD_STR \
4072 "asbr-summary|external|network|router|summary" \
4073 OSPF_LSA_TYPE_NSSA_CMD_STR \
4074 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4075
4076#define OSPF_LSA_TYPES_DESC \
4077 "ASBR summary link states\n" \
4078 "External link states\n" \
4079 "Network link states\n" \
4080 "Router link states\n" \
4081 "Network summary link states\n" \
4082 OSPF_LSA_TYPE_NSSA_DESC \
4083 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4084 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4085 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4086
4087DEFUN (show_ip_ospf_database,
4088 show_ip_ospf_database_cmd,
4089 "show ip ospf database",
4090 SHOW_STR
4091 IP_STR
4092 "OSPF information\n"
4093 "Database summary\n")
4094{
paul020709f2003-04-04 02:44:16 +00004095 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004096 int type, ret;
4097 struct in_addr id, adv_router;
4098
paul020709f2003-04-04 02:44:16 +00004099 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004100 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004101 {
4102 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4103 return CMD_SUCCESS;
4104 }
paul718e3742002-12-13 20:15:29 +00004105
4106 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004107 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004108
4109 /* Show all LSA. */
4110 if (argc == 0)
4111 {
paul020709f2003-04-04 02:44:16 +00004112 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004113 return CMD_SUCCESS;
4114 }
4115
4116 /* Set database type to show. */
4117 if (strncmp (argv[0], "r", 1) == 0)
4118 type = OSPF_ROUTER_LSA;
4119 else if (strncmp (argv[0], "ne", 2) == 0)
4120 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004121 else if (strncmp (argv[0], "ns", 2) == 0)
4122 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004123 else if (strncmp (argv[0], "su", 2) == 0)
4124 type = OSPF_SUMMARY_LSA;
4125 else if (strncmp (argv[0], "a", 1) == 0)
4126 type = OSPF_ASBR_SUMMARY_LSA;
4127 else if (strncmp (argv[0], "e", 1) == 0)
4128 type = OSPF_AS_EXTERNAL_LSA;
4129 else if (strncmp (argv[0], "se", 2) == 0)
4130 {
paul020709f2003-04-04 02:44:16 +00004131 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004132 return CMD_SUCCESS;
4133 }
4134 else if (strncmp (argv[0], "m", 1) == 0)
4135 {
paul020709f2003-04-04 02:44:16 +00004136 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004137 return CMD_SUCCESS;
4138 }
4139#ifdef HAVE_OPAQUE_LSA
4140 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4141 type = OSPF_OPAQUE_LINK_LSA;
4142 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4143 type = OSPF_OPAQUE_AREA_LSA;
4144 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4145 type = OSPF_OPAQUE_AS_LSA;
4146#endif /* HAVE_OPAQUE_LSA */
4147 else
4148 return CMD_WARNING;
4149
4150 /* `show ip ospf database LSA'. */
4151 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004152 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004153 else if (argc >= 2)
4154 {
4155 ret = inet_aton (argv[1], &id);
4156 if (!ret)
4157 return CMD_WARNING;
4158
4159 /* `show ip ospf database LSA ID'. */
4160 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004161 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004162 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4163 else if (argc == 3)
4164 {
4165 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004166 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004167 else
4168 {
4169 ret = inet_aton (argv[2], &adv_router);
4170 if (!ret)
4171 return CMD_WARNING;
4172 }
paul020709f2003-04-04 02:44:16 +00004173 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004174 }
4175 }
4176
4177 return CMD_SUCCESS;
4178}
4179
4180ALIAS (show_ip_ospf_database,
4181 show_ip_ospf_database_type_cmd,
4182 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4183 SHOW_STR
4184 IP_STR
4185 "OSPF information\n"
4186 "Database summary\n"
4187 OSPF_LSA_TYPES_DESC
4188 "LSAs in MaxAge list\n"
4189 "Self-originated link states\n")
4190
4191ALIAS (show_ip_ospf_database,
4192 show_ip_ospf_database_type_id_cmd,
4193 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4194 SHOW_STR
4195 IP_STR
4196 "OSPF information\n"
4197 "Database summary\n"
4198 OSPF_LSA_TYPES_DESC
4199 "Link State ID (as an IP address)\n")
4200
4201ALIAS (show_ip_ospf_database,
4202 show_ip_ospf_database_type_id_adv_router_cmd,
4203 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4204 SHOW_STR
4205 IP_STR
4206 "OSPF information\n"
4207 "Database summary\n"
4208 OSPF_LSA_TYPES_DESC
4209 "Link State ID (as an IP address)\n"
4210 "Advertising Router link states\n"
4211 "Advertising Router (as an IP address)\n")
4212
4213ALIAS (show_ip_ospf_database,
4214 show_ip_ospf_database_type_id_self_cmd,
4215 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4216 SHOW_STR
4217 IP_STR
4218 "OSPF information\n"
4219 "Database summary\n"
4220 OSPF_LSA_TYPES_DESC
4221 "Link State ID (as an IP address)\n"
4222 "Self-originated link states\n"
4223 "\n")
4224
4225DEFUN (show_ip_ospf_database_type_adv_router,
4226 show_ip_ospf_database_type_adv_router_cmd,
4227 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4228 SHOW_STR
4229 IP_STR
4230 "OSPF information\n"
4231 "Database summary\n"
4232 OSPF_LSA_TYPES_DESC
4233 "Advertising Router link states\n"
4234 "Advertising Router (as an IP address)\n")
4235{
paul020709f2003-04-04 02:44:16 +00004236 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004237 int type, ret;
4238 struct in_addr adv_router;
4239
paul020709f2003-04-04 02:44:16 +00004240 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004241 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004242 {
4243 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4244 return CMD_SUCCESS;
4245 }
paul718e3742002-12-13 20:15:29 +00004246
4247 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004248 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004249
4250 if (argc != 2)
4251 return CMD_WARNING;
4252
4253 /* Set database type to show. */
4254 if (strncmp (argv[0], "r", 1) == 0)
4255 type = OSPF_ROUTER_LSA;
4256 else if (strncmp (argv[0], "ne", 2) == 0)
4257 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004258 else if (strncmp (argv[0], "ns", 2) == 0)
4259 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004260 else if (strncmp (argv[0], "s", 1) == 0)
4261 type = OSPF_SUMMARY_LSA;
4262 else if (strncmp (argv[0], "a", 1) == 0)
4263 type = OSPF_ASBR_SUMMARY_LSA;
4264 else if (strncmp (argv[0], "e", 1) == 0)
4265 type = OSPF_AS_EXTERNAL_LSA;
4266#ifdef HAVE_OPAQUE_LSA
4267 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4268 type = OSPF_OPAQUE_LINK_LSA;
4269 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4270 type = OSPF_OPAQUE_AREA_LSA;
4271 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4272 type = OSPF_OPAQUE_AS_LSA;
4273#endif /* HAVE_OPAQUE_LSA */
4274 else
4275 return CMD_WARNING;
4276
4277 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4278 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004279 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004280 else
4281 {
4282 ret = inet_aton (argv[1], &adv_router);
4283 if (!ret)
4284 return CMD_WARNING;
4285 }
4286
paul020709f2003-04-04 02:44:16 +00004287 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004288
4289 return CMD_SUCCESS;
4290}
4291
4292ALIAS (show_ip_ospf_database_type_adv_router,
4293 show_ip_ospf_database_type_self_cmd,
4294 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4295 SHOW_STR
4296 IP_STR
4297 "OSPF information\n"
4298 "Database summary\n"
4299 OSPF_LSA_TYPES_DESC
4300 "Self-originated link states\n")
4301
4302
4303DEFUN (ip_ospf_authentication_args,
4304 ip_ospf_authentication_args_addr_cmd,
4305 "ip ospf authentication (null|message-digest) A.B.C.D",
4306 "IP Information\n"
4307 "OSPF interface commands\n"
4308 "Enable authentication on this interface\n"
4309 "Use null authentication\n"
4310 "Use message-digest authentication\n"
4311 "Address of interface")
4312{
4313 struct interface *ifp;
4314 struct in_addr addr;
4315 int ret;
4316 struct ospf_if_params *params;
4317
4318 ifp = vty->index;
4319 params = IF_DEF_PARAMS (ifp);
4320
4321 if (argc == 2)
4322 {
4323 ret = inet_aton(argv[1], &addr);
4324 if (!ret)
4325 {
4326 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4327 VTY_NEWLINE);
4328 return CMD_WARNING;
4329 }
4330
4331 params = ospf_get_if_params (ifp, addr);
4332 ospf_if_update_params (ifp, addr);
4333 }
4334
4335 /* Handle null authentication */
4336 if ( argv[0][0] == 'n' )
4337 {
4338 SET_IF_PARAM (params, auth_type);
4339 params->auth_type = OSPF_AUTH_NULL;
4340 return CMD_SUCCESS;
4341 }
4342
4343 /* Handle message-digest authentication */
4344 if ( argv[0][0] == 'm' )
4345 {
4346 SET_IF_PARAM (params, auth_type);
4347 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4348 return CMD_SUCCESS;
4349 }
4350
4351 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4352 return CMD_WARNING;
4353}
4354
4355ALIAS (ip_ospf_authentication_args,
4356 ip_ospf_authentication_args_cmd,
4357 "ip ospf authentication (null|message-digest)",
4358 "IP Information\n"
4359 "OSPF interface commands\n"
4360 "Enable authentication on this interface\n"
4361 "Use null authentication\n"
4362 "Use message-digest authentication\n")
4363
4364DEFUN (ip_ospf_authentication,
4365 ip_ospf_authentication_addr_cmd,
4366 "ip ospf authentication A.B.C.D",
4367 "IP Information\n"
4368 "OSPF interface commands\n"
4369 "Enable authentication on this interface\n"
4370 "Address of interface")
4371{
4372 struct interface *ifp;
4373 struct in_addr addr;
4374 int ret;
4375 struct ospf_if_params *params;
4376
4377 ifp = vty->index;
4378 params = IF_DEF_PARAMS (ifp);
4379
4380 if (argc == 1)
4381 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004382 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004383 if (!ret)
4384 {
4385 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4386 VTY_NEWLINE);
4387 return CMD_WARNING;
4388 }
4389
4390 params = ospf_get_if_params (ifp, addr);
4391 ospf_if_update_params (ifp, addr);
4392 }
4393
4394 SET_IF_PARAM (params, auth_type);
4395 params->auth_type = OSPF_AUTH_SIMPLE;
4396
4397 return CMD_SUCCESS;
4398}
4399
4400ALIAS (ip_ospf_authentication,
4401 ip_ospf_authentication_cmd,
4402 "ip ospf authentication",
4403 "IP Information\n"
4404 "OSPF interface commands\n"
4405 "Enable authentication on this interface\n")
4406
4407DEFUN (no_ip_ospf_authentication,
4408 no_ip_ospf_authentication_addr_cmd,
4409 "no ip ospf authentication A.B.C.D",
4410 NO_STR
4411 "IP Information\n"
4412 "OSPF interface commands\n"
4413 "Enable authentication on this interface\n"
4414 "Address of interface")
4415{
4416 struct interface *ifp;
4417 struct in_addr addr;
4418 int ret;
4419 struct ospf_if_params *params;
4420
4421 ifp = vty->index;
4422 params = IF_DEF_PARAMS (ifp);
4423
4424 if (argc == 1)
4425 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004426 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004427 if (!ret)
4428 {
4429 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4430 VTY_NEWLINE);
4431 return CMD_WARNING;
4432 }
4433
4434 params = ospf_lookup_if_params (ifp, addr);
4435 if (params == NULL)
4436 return CMD_SUCCESS;
4437 }
4438
4439 params->auth_type = OSPF_AUTH_NOTSET;
4440 UNSET_IF_PARAM (params, auth_type);
4441
4442 if (params != IF_DEF_PARAMS (ifp))
4443 {
4444 ospf_free_if_params (ifp, addr);
4445 ospf_if_update_params (ifp, addr);
4446 }
4447
4448 return CMD_SUCCESS;
4449}
4450
4451ALIAS (no_ip_ospf_authentication,
4452 no_ip_ospf_authentication_cmd,
4453 "no ip ospf authentication",
4454 NO_STR
4455 "IP Information\n"
4456 "OSPF interface commands\n"
4457 "Enable authentication on this interface\n")
4458
4459DEFUN (ip_ospf_authentication_key,
4460 ip_ospf_authentication_key_addr_cmd,
4461 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4462 "IP Information\n"
4463 "OSPF interface commands\n"
4464 "Authentication password (key)\n"
4465 "The OSPF password (key)\n"
4466 "Address of interface")
4467{
4468 struct interface *ifp;
4469 struct in_addr addr;
4470 int ret;
4471 struct ospf_if_params *params;
4472
4473 ifp = vty->index;
4474 params = IF_DEF_PARAMS (ifp);
4475
4476 if (argc == 2)
4477 {
4478 ret = inet_aton(argv[1], &addr);
4479 if (!ret)
4480 {
4481 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4482 VTY_NEWLINE);
4483 return CMD_WARNING;
4484 }
4485
4486 params = ospf_get_if_params (ifp, addr);
4487 ospf_if_update_params (ifp, addr);
4488 }
4489
4490
4491 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004492 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004493 SET_IF_PARAM (params, auth_simple);
4494
4495 return CMD_SUCCESS;
4496}
4497
4498ALIAS (ip_ospf_authentication_key,
4499 ip_ospf_authentication_key_cmd,
4500 "ip ospf authentication-key AUTH_KEY",
4501 "IP Information\n"
4502 "OSPF interface commands\n"
4503 "Authentication password (key)\n"
4504 "The OSPF password (key)")
4505
4506ALIAS (ip_ospf_authentication_key,
4507 ospf_authentication_key_cmd,
4508 "ospf authentication-key AUTH_KEY",
4509 "OSPF interface commands\n"
4510 "Authentication password (key)\n"
4511 "The OSPF password (key)")
4512
4513DEFUN (no_ip_ospf_authentication_key,
4514 no_ip_ospf_authentication_key_addr_cmd,
4515 "no ip ospf authentication-key A.B.C.D",
4516 NO_STR
4517 "IP Information\n"
4518 "OSPF interface commands\n"
4519 "Authentication password (key)\n"
4520 "Address of interface")
4521{
4522 struct interface *ifp;
4523 struct in_addr addr;
4524 int ret;
4525 struct ospf_if_params *params;
4526
4527 ifp = vty->index;
4528 params = IF_DEF_PARAMS (ifp);
4529
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004530 if (argc == 1)
paul718e3742002-12-13 20:15:29 +00004531 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004532 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004533 if (!ret)
4534 {
4535 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4536 VTY_NEWLINE);
4537 return CMD_WARNING;
4538 }
4539
4540 params = ospf_lookup_if_params (ifp, addr);
4541 if (params == NULL)
4542 return CMD_SUCCESS;
4543 }
4544
4545 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4546 UNSET_IF_PARAM (params, auth_simple);
4547
4548 if (params != IF_DEF_PARAMS (ifp))
4549 {
4550 ospf_free_if_params (ifp, addr);
4551 ospf_if_update_params (ifp, addr);
4552 }
4553
4554 return CMD_SUCCESS;
4555}
4556
4557ALIAS (no_ip_ospf_authentication_key,
4558 no_ip_ospf_authentication_key_cmd,
4559 "no ip ospf authentication-key",
4560 NO_STR
4561 "IP Information\n"
4562 "OSPF interface commands\n"
4563 "Authentication password (key)\n")
4564
4565ALIAS (no_ip_ospf_authentication_key,
4566 no_ospf_authentication_key_cmd,
4567 "no ospf authentication-key",
4568 NO_STR
4569 "OSPF interface commands\n"
4570 "Authentication password (key)\n")
4571
4572DEFUN (ip_ospf_message_digest_key,
4573 ip_ospf_message_digest_key_addr_cmd,
4574 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4575 "IP Information\n"
4576 "OSPF interface commands\n"
4577 "Message digest authentication password (key)\n"
4578 "Key ID\n"
4579 "Use MD5 algorithm\n"
4580 "The OSPF password (key)"
4581 "Address of interface")
4582{
4583 struct interface *ifp;
4584 struct crypt_key *ck;
4585 u_char key_id;
4586 struct in_addr addr;
4587 int ret;
4588 struct ospf_if_params *params;
4589
4590 ifp = vty->index;
4591 params = IF_DEF_PARAMS (ifp);
4592
4593 if (argc == 3)
4594 {
4595 ret = inet_aton(argv[2], &addr);
4596 if (!ret)
4597 {
4598 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4599 VTY_NEWLINE);
4600 return CMD_WARNING;
4601 }
4602
4603 params = ospf_get_if_params (ifp, addr);
4604 ospf_if_update_params (ifp, addr);
4605 }
4606
4607 key_id = strtol (argv[0], NULL, 10);
4608 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4609 {
4610 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4611 return CMD_WARNING;
4612 }
4613
4614 ck = ospf_crypt_key_new ();
4615 ck->key_id = (u_char) key_id;
4616 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004617 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004618
4619 ospf_crypt_key_add (params->auth_crypt, ck);
4620 SET_IF_PARAM (params, auth_crypt);
4621
4622 return CMD_SUCCESS;
4623}
4624
4625ALIAS (ip_ospf_message_digest_key,
4626 ip_ospf_message_digest_key_cmd,
4627 "ip ospf message-digest-key <1-255> md5 KEY",
4628 "IP Information\n"
4629 "OSPF interface commands\n"
4630 "Message digest authentication password (key)\n"
4631 "Key ID\n"
4632 "Use MD5 algorithm\n"
4633 "The OSPF password (key)")
4634
4635ALIAS (ip_ospf_message_digest_key,
4636 ospf_message_digest_key_cmd,
4637 "ospf message-digest-key <1-255> md5 KEY",
4638 "OSPF interface commands\n"
4639 "Message digest authentication password (key)\n"
4640 "Key ID\n"
4641 "Use MD5 algorithm\n"
4642 "The OSPF password (key)")
4643
4644DEFUN (no_ip_ospf_message_digest_key,
4645 no_ip_ospf_message_digest_key_addr_cmd,
4646 "no ip ospf message-digest-key <1-255> A.B.C.D",
4647 NO_STR
4648 "IP Information\n"
4649 "OSPF interface commands\n"
4650 "Message digest authentication password (key)\n"
4651 "Key ID\n"
4652 "Address of interface")
4653{
4654 struct interface *ifp;
4655 struct crypt_key *ck;
4656 int key_id;
4657 struct in_addr addr;
4658 int ret;
4659 struct ospf_if_params *params;
4660
4661 ifp = vty->index;
4662 params = IF_DEF_PARAMS (ifp);
4663
4664 if (argc == 2)
4665 {
4666 ret = inet_aton(argv[1], &addr);
4667 if (!ret)
4668 {
4669 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4670 VTY_NEWLINE);
4671 return CMD_WARNING;
4672 }
4673
4674 params = ospf_lookup_if_params (ifp, addr);
4675 if (params == NULL)
4676 return CMD_SUCCESS;
4677 }
4678
4679 key_id = strtol (argv[0], NULL, 10);
4680 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4681 if (ck == NULL)
4682 {
4683 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4684 return CMD_WARNING;
4685 }
4686
4687 ospf_crypt_key_delete (params->auth_crypt, key_id);
4688
4689 if (params != IF_DEF_PARAMS (ifp))
4690 {
4691 ospf_free_if_params (ifp, addr);
4692 ospf_if_update_params (ifp, addr);
4693 }
4694
4695 return CMD_SUCCESS;
4696}
4697
4698ALIAS (no_ip_ospf_message_digest_key,
4699 no_ip_ospf_message_digest_key_cmd,
4700 "no ip ospf message-digest-key <1-255>",
4701 NO_STR
4702 "IP Information\n"
4703 "OSPF interface commands\n"
4704 "Message digest authentication password (key)\n"
4705 "Key ID\n")
4706
4707ALIAS (no_ip_ospf_message_digest_key,
4708 no_ospf_message_digest_key_cmd,
4709 "no ospf message-digest-key <1-255>",
4710 NO_STR
4711 "OSPF interface commands\n"
4712 "Message digest authentication password (key)\n"
4713 "Key ID\n")
4714
4715DEFUN (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004716 ip_ospf_cost_u32_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004717 "ip ospf cost <1-65535> A.B.C.D",
4718 "IP Information\n"
4719 "OSPF interface commands\n"
4720 "Interface cost\n"
4721 "Cost\n"
4722 "Address of interface")
4723{
4724 struct interface *ifp = vty->index;
4725 u_int32_t cost;
4726 struct in_addr addr;
4727 int ret;
4728 struct ospf_if_params *params;
4729
4730 params = IF_DEF_PARAMS (ifp);
4731
4732 cost = strtol (argv[0], NULL, 10);
4733
4734 /* cost range is <1-65535>. */
4735 if (cost < 1 || cost > 65535)
4736 {
4737 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4738 return CMD_WARNING;
4739 }
4740
4741 if (argc == 2)
4742 {
4743 ret = inet_aton(argv[1], &addr);
4744 if (!ret)
4745 {
4746 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4747 VTY_NEWLINE);
4748 return CMD_WARNING;
4749 }
4750
4751 params = ospf_get_if_params (ifp, addr);
4752 ospf_if_update_params (ifp, addr);
4753 }
4754
4755 SET_IF_PARAM (params, output_cost_cmd);
4756 params->output_cost_cmd = cost;
4757
4758 ospf_if_recalculate_output_cost (ifp);
4759
4760 return CMD_SUCCESS;
4761}
4762
4763ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004764 ip_ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004765 "ip ospf cost <1-65535>",
4766 "IP Information\n"
4767 "OSPF interface commands\n"
4768 "Interface cost\n"
4769 "Cost")
4770
4771ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004772 ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004773 "ospf cost <1-65535>",
4774 "OSPF interface commands\n"
4775 "Interface cost\n"
4776 "Cost")
4777
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004778ALIAS (ip_ospf_cost,
4779 ospf_cost_u32_inet4_cmd,
4780 "ospf cost <1-65535> A.B.C.D",
4781 "OSPF interface commands\n"
4782 "Interface cost\n"
4783 "Cost\n"
4784 "Address of interface")
4785
paul718e3742002-12-13 20:15:29 +00004786DEFUN (no_ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004787 no_ip_ospf_cost_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004788 "no ip ospf cost A.B.C.D",
4789 NO_STR
4790 "IP Information\n"
4791 "OSPF interface commands\n"
4792 "Interface cost\n"
4793 "Address of interface")
4794{
4795 struct interface *ifp = vty->index;
4796 struct in_addr addr;
4797 int ret;
4798 struct ospf_if_params *params;
4799
4800 ifp = vty->index;
4801 params = IF_DEF_PARAMS (ifp);
4802
4803 if (argc == 1)
4804 {
4805 ret = inet_aton(argv[0], &addr);
4806 if (!ret)
4807 {
4808 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4809 VTY_NEWLINE);
4810 return CMD_WARNING;
4811 }
4812
4813 params = ospf_lookup_if_params (ifp, addr);
4814 if (params == NULL)
4815 return CMD_SUCCESS;
4816 }
4817
4818 UNSET_IF_PARAM (params, output_cost_cmd);
4819
4820 if (params != IF_DEF_PARAMS (ifp))
4821 {
4822 ospf_free_if_params (ifp, addr);
4823 ospf_if_update_params (ifp, addr);
4824 }
4825
4826 ospf_if_recalculate_output_cost (ifp);
4827
4828 return CMD_SUCCESS;
4829}
4830
4831ALIAS (no_ip_ospf_cost,
4832 no_ip_ospf_cost_cmd,
4833 "no ip ospf cost",
4834 NO_STR
4835 "IP Information\n"
4836 "OSPF interface commands\n"
4837 "Interface cost\n")
4838
4839ALIAS (no_ip_ospf_cost,
4840 no_ospf_cost_cmd,
4841 "no ospf cost",
4842 NO_STR
4843 "OSPF interface commands\n"
4844 "Interface cost\n")
4845
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004846ALIAS (no_ip_ospf_cost,
4847 no_ospf_cost_inet4_cmd,
4848 "no ospf cost A.B.C.D",
4849 NO_STR
4850 "OSPF interface commands\n"
4851 "Interface cost\n"
4852 "Address of interface")
4853
Denis Ovsienko827341b2009-09-28 19:34:59 +04004854DEFUN (no_ip_ospf_cost2,
4855 no_ip_ospf_cost_u32_cmd,
4856 "no ip ospf cost <1-65535>",
4857 NO_STR
4858 "IP Information\n"
4859 "OSPF interface commands\n"
4860 "Interface cost\n"
4861 "Cost")
4862{
4863 struct interface *ifp = vty->index;
4864 struct in_addr addr;
4865 u_int32_t cost;
4866 int ret;
4867 struct ospf_if_params *params;
4868
4869 ifp = vty->index;
4870 params = IF_DEF_PARAMS (ifp);
4871
4872 /* According to the semantics we are mimicking "no ip ospf cost N" is
4873 * always treated as "no ip ospf cost" regardless of the actual value
4874 * of N already configured for the interface. Thus the first argument
4875 * is always checked to be a number, but is ignored after that.
4876 */
4877 cost = strtol (argv[0], NULL, 10);
4878 if (cost < 1 || cost > 65535)
4879 {
4880 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4881 return CMD_WARNING;
4882 }
4883
4884 if (argc == 2)
4885 {
4886 ret = inet_aton(argv[1], &addr);
4887 if (!ret)
4888 {
4889 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4890 VTY_NEWLINE);
4891 return CMD_WARNING;
4892 }
4893
4894 params = ospf_lookup_if_params (ifp, addr);
4895 if (params == NULL)
4896 return CMD_SUCCESS;
4897 }
4898
4899 UNSET_IF_PARAM (params, output_cost_cmd);
4900
4901 if (params != IF_DEF_PARAMS (ifp))
4902 {
4903 ospf_free_if_params (ifp, addr);
4904 ospf_if_update_params (ifp, addr);
4905 }
4906
4907 ospf_if_recalculate_output_cost (ifp);
4908
4909 return CMD_SUCCESS;
4910}
4911
4912ALIAS (no_ip_ospf_cost2,
4913 no_ospf_cost_u32_cmd,
4914 "no ospf cost <1-65535>",
4915 NO_STR
4916 "OSPF interface commands\n"
4917 "Interface cost\n"
4918 "Cost")
4919
4920ALIAS (no_ip_ospf_cost2,
4921 no_ip_ospf_cost_u32_inet4_cmd,
4922 "no ip ospf cost <1-65535> A.B.C.D",
4923 NO_STR
4924 "IP Information\n"
4925 "OSPF interface commands\n"
4926 "Interface cost\n"
4927 "Cost\n"
4928 "Address of interface")
4929
4930ALIAS (no_ip_ospf_cost2,
4931 no_ospf_cost_u32_inet4_cmd,
4932 "no ospf cost <1-65535> A.B.C.D",
4933 NO_STR
4934 "OSPF interface commands\n"
4935 "Interface cost\n"
4936 "Cost\n"
4937 "Address of interface")
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004938
paul4dadc292005-05-06 21:37:42 +00004939static void
paul718e3742002-12-13 20:15:29 +00004940ospf_nbr_timer_update (struct ospf_interface *oi)
4941{
4942 struct route_node *rn;
4943 struct ospf_neighbor *nbr;
4944
4945 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4946 if ((nbr = rn->info))
4947 {
4948 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4949 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4950 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4951 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4952 }
4953}
4954
paulf9ad9372005-10-21 00:45:17 +00004955static int
4956ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4957 const char *nbr_str,
4958 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004959{
4960 struct interface *ifp = vty->index;
4961 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004962 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004963 struct in_addr addr;
4964 int ret;
4965 struct ospf_if_params *params;
4966 struct ospf_interface *oi;
4967 struct route_node *rn;
4968
4969 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004970
4971 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004972 {
paulf9ad9372005-10-21 00:45:17 +00004973 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004974 if (!ret)
4975 {
4976 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4977 VTY_NEWLINE);
4978 return CMD_WARNING;
4979 }
4980
4981 params = ospf_get_if_params (ifp, addr);
4982 ospf_if_update_params (ifp, addr);
4983 }
4984
paulf9ad9372005-10-21 00:45:17 +00004985 if (interval_str)
4986 {
4987 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4988 1, 65535);
4989
4990 /* reset fast_hello too, just to be sure */
4991 UNSET_IF_PARAM (params, fast_hello);
4992 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4993 }
4994 else if (fast_hello_str)
4995 {
4996 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4997 1, 10);
4998 /* 1s dead-interval with sub-second hellos desired */
4999 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
5000 SET_IF_PARAM (params, fast_hello);
5001 params->fast_hello = hellomult;
5002 }
5003 else
5004 {
5005 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5006 VTY_NEWLINE);
5007 return CMD_WARNING;
5008 }
5009
paul718e3742002-12-13 20:15:29 +00005010 SET_IF_PARAM (params, v_wait);
5011 params->v_wait = seconds;
5012
5013 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00005014 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005015 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005016 struct ospf *ospf;
5017 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005018 {
5019 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5020 if (oi)
5021 ospf_nbr_timer_update (oi);
5022 }
paul718e3742002-12-13 20:15:29 +00005023 }
5024 else
5025 {
5026 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5027 if ((oi = rn->info))
5028 ospf_nbr_timer_update (oi);
5029 }
5030
5031 return CMD_SUCCESS;
5032}
5033
paulf9ad9372005-10-21 00:45:17 +00005034
5035DEFUN (ip_ospf_dead_interval,
5036 ip_ospf_dead_interval_addr_cmd,
5037 "ip ospf dead-interval <1-65535> A.B.C.D",
5038 "IP Information\n"
5039 "OSPF interface commands\n"
5040 "Interval after which a neighbor is declared dead\n"
5041 "Seconds\n"
5042 "Address of interface\n")
5043{
5044 if (argc == 2)
5045 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5046 else
5047 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5048}
5049
paul718e3742002-12-13 20:15:29 +00005050ALIAS (ip_ospf_dead_interval,
5051 ip_ospf_dead_interval_cmd,
5052 "ip ospf dead-interval <1-65535>",
5053 "IP Information\n"
5054 "OSPF interface commands\n"
5055 "Interval after which a neighbor is declared dead\n"
5056 "Seconds\n")
5057
5058ALIAS (ip_ospf_dead_interval,
5059 ospf_dead_interval_cmd,
5060 "ospf dead-interval <1-65535>",
5061 "OSPF interface commands\n"
5062 "Interval after which a neighbor is declared dead\n"
5063 "Seconds\n")
5064
paulf9ad9372005-10-21 00:45:17 +00005065DEFUN (ip_ospf_dead_interval_minimal,
5066 ip_ospf_dead_interval_minimal_addr_cmd,
5067 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5068 "IP Information\n"
5069 "OSPF interface commands\n"
5070 "Interval after which a neighbor is declared dead\n"
5071 "Minimal 1s dead-interval with fast sub-second hellos\n"
5072 "Hello multiplier factor\n"
5073 "Number of Hellos to send each second\n"
5074 "Address of interface\n")
5075{
5076 if (argc == 2)
5077 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5078 else
5079 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5080}
5081
5082ALIAS (ip_ospf_dead_interval_minimal,
5083 ip_ospf_dead_interval_minimal_cmd,
5084 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5085 "IP Information\n"
5086 "OSPF interface commands\n"
5087 "Interval after which a neighbor is declared dead\n"
5088 "Minimal 1s dead-interval with fast sub-second hellos\n"
5089 "Hello multiplier factor\n"
5090 "Number of Hellos to send each second\n")
5091
paul718e3742002-12-13 20:15:29 +00005092DEFUN (no_ip_ospf_dead_interval,
5093 no_ip_ospf_dead_interval_addr_cmd,
5094 "no ip ospf dead-interval A.B.C.D",
5095 NO_STR
5096 "IP Information\n"
5097 "OSPF interface commands\n"
5098 "Interval after which a neighbor is declared dead\n"
5099 "Address of interface")
5100{
5101 struct interface *ifp = vty->index;
5102 struct in_addr addr;
5103 int ret;
5104 struct ospf_if_params *params;
5105 struct ospf_interface *oi;
5106 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00005107
paul718e3742002-12-13 20:15:29 +00005108 ifp = vty->index;
5109 params = IF_DEF_PARAMS (ifp);
5110
5111 if (argc == 1)
5112 {
5113 ret = inet_aton(argv[0], &addr);
5114 if (!ret)
5115 {
5116 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5117 VTY_NEWLINE);
5118 return CMD_WARNING;
5119 }
5120
5121 params = ospf_lookup_if_params (ifp, addr);
5122 if (params == NULL)
5123 return CMD_SUCCESS;
5124 }
5125
5126 UNSET_IF_PARAM (params, v_wait);
5127 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00005128
5129 UNSET_IF_PARAM (params, fast_hello);
5130 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5131
paul718e3742002-12-13 20:15:29 +00005132 if (params != IF_DEF_PARAMS (ifp))
5133 {
5134 ospf_free_if_params (ifp, addr);
5135 ospf_if_update_params (ifp, addr);
5136 }
5137
5138 /* Update timer values in neighbor structure. */
5139 if (argc == 1)
5140 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005141 struct ospf *ospf;
5142
5143 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005144 {
5145 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5146 if (oi)
5147 ospf_nbr_timer_update (oi);
5148 }
paul718e3742002-12-13 20:15:29 +00005149 }
5150 else
5151 {
5152 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5153 if ((oi = rn->info))
5154 ospf_nbr_timer_update (oi);
5155 }
5156
5157 return CMD_SUCCESS;
5158}
5159
5160ALIAS (no_ip_ospf_dead_interval,
5161 no_ip_ospf_dead_interval_cmd,
5162 "no ip ospf dead-interval",
5163 NO_STR
5164 "IP Information\n"
5165 "OSPF interface commands\n"
5166 "Interval after which a neighbor is declared dead\n")
5167
5168ALIAS (no_ip_ospf_dead_interval,
5169 no_ospf_dead_interval_cmd,
5170 "no ospf dead-interval",
5171 NO_STR
5172 "OSPF interface commands\n"
5173 "Interval after which a neighbor is declared dead\n")
5174
5175DEFUN (ip_ospf_hello_interval,
5176 ip_ospf_hello_interval_addr_cmd,
5177 "ip ospf hello-interval <1-65535> A.B.C.D",
5178 "IP Information\n"
5179 "OSPF interface commands\n"
5180 "Time between HELLO packets\n"
5181 "Seconds\n"
5182 "Address of interface")
5183{
5184 struct interface *ifp = vty->index;
5185 u_int32_t seconds;
5186 struct in_addr addr;
5187 int ret;
5188 struct ospf_if_params *params;
5189
5190 params = IF_DEF_PARAMS (ifp);
5191
5192 seconds = strtol (argv[0], NULL, 10);
5193
5194 /* HelloInterval range is <1-65535>. */
5195 if (seconds < 1 || seconds > 65535)
5196 {
5197 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5198 return CMD_WARNING;
5199 }
5200
5201 if (argc == 2)
5202 {
5203 ret = inet_aton(argv[1], &addr);
5204 if (!ret)
5205 {
5206 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5207 VTY_NEWLINE);
5208 return CMD_WARNING;
5209 }
5210
5211 params = ospf_get_if_params (ifp, addr);
5212 ospf_if_update_params (ifp, addr);
5213 }
5214
paulf9ad9372005-10-21 00:45:17 +00005215 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005216 params->v_hello = seconds;
5217
5218 return CMD_SUCCESS;
5219}
5220
5221ALIAS (ip_ospf_hello_interval,
5222 ip_ospf_hello_interval_cmd,
5223 "ip ospf hello-interval <1-65535>",
5224 "IP Information\n"
5225 "OSPF interface commands\n"
5226 "Time between HELLO packets\n"
5227 "Seconds\n")
5228
5229ALIAS (ip_ospf_hello_interval,
5230 ospf_hello_interval_cmd,
5231 "ospf hello-interval <1-65535>",
5232 "OSPF interface commands\n"
5233 "Time between HELLO packets\n"
5234 "Seconds\n")
5235
5236DEFUN (no_ip_ospf_hello_interval,
5237 no_ip_ospf_hello_interval_addr_cmd,
5238 "no ip ospf hello-interval A.B.C.D",
5239 NO_STR
5240 "IP Information\n"
5241 "OSPF interface commands\n"
5242 "Time between HELLO packets\n"
5243 "Address of interface")
5244{
5245 struct interface *ifp = vty->index;
5246 struct in_addr addr;
5247 int ret;
5248 struct ospf_if_params *params;
5249
5250 ifp = vty->index;
5251 params = IF_DEF_PARAMS (ifp);
5252
5253 if (argc == 1)
5254 {
5255 ret = inet_aton(argv[0], &addr);
5256 if (!ret)
5257 {
5258 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5259 VTY_NEWLINE);
5260 return CMD_WARNING;
5261 }
5262
5263 params = ospf_lookup_if_params (ifp, addr);
5264 if (params == NULL)
5265 return CMD_SUCCESS;
5266 }
5267
5268 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005269 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005270
5271 if (params != IF_DEF_PARAMS (ifp))
5272 {
5273 ospf_free_if_params (ifp, addr);
5274 ospf_if_update_params (ifp, addr);
5275 }
5276
5277 return CMD_SUCCESS;
5278}
5279
5280ALIAS (no_ip_ospf_hello_interval,
5281 no_ip_ospf_hello_interval_cmd,
5282 "no ip ospf hello-interval",
5283 NO_STR
5284 "IP Information\n"
5285 "OSPF interface commands\n"
5286 "Time between HELLO packets\n")
5287
5288ALIAS (no_ip_ospf_hello_interval,
5289 no_ospf_hello_interval_cmd,
5290 "no ospf hello-interval",
5291 NO_STR
5292 "OSPF interface commands\n"
5293 "Time between HELLO packets\n")
5294
5295DEFUN (ip_ospf_network,
5296 ip_ospf_network_cmd,
5297 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5298 "IP Information\n"
5299 "OSPF interface commands\n"
5300 "Network type\n"
5301 "Specify OSPF broadcast multi-access network\n"
5302 "Specify OSPF NBMA network\n"
5303 "Specify OSPF point-to-multipoint network\n"
5304 "Specify OSPF point-to-point network\n")
5305{
5306 struct interface *ifp = vty->index;
5307 int old_type = IF_DEF_PARAMS (ifp)->type;
5308 struct route_node *rn;
5309
5310 if (strncmp (argv[0], "b", 1) == 0)
5311 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5312 else if (strncmp (argv[0], "n", 1) == 0)
5313 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5314 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5315 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5316 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5317 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5318
5319 if (IF_DEF_PARAMS (ifp)->type == old_type)
5320 return CMD_SUCCESS;
5321
5322 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5323
5324 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5325 {
5326 struct ospf_interface *oi = rn->info;
5327
5328 if (!oi)
5329 continue;
5330
5331 oi->type = IF_DEF_PARAMS (ifp)->type;
5332
5333 if (oi->state > ISM_Down)
5334 {
5335 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5336 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5337 }
5338 }
5339
5340 return CMD_SUCCESS;
5341}
5342
5343ALIAS (ip_ospf_network,
5344 ospf_network_cmd,
5345 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5346 "OSPF interface commands\n"
5347 "Network type\n"
5348 "Specify OSPF broadcast multi-access network\n"
5349 "Specify OSPF NBMA network\n"
5350 "Specify OSPF point-to-multipoint network\n"
5351 "Specify OSPF point-to-point network\n")
5352
5353DEFUN (no_ip_ospf_network,
5354 no_ip_ospf_network_cmd,
5355 "no ip ospf network",
5356 NO_STR
5357 "IP Information\n"
5358 "OSPF interface commands\n"
5359 "Network type\n")
5360{
5361 struct interface *ifp = vty->index;
5362 int old_type = IF_DEF_PARAMS (ifp)->type;
5363 struct route_node *rn;
5364
ajsbc18d612004-12-15 15:07:19 +00005365 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005366
5367 if (IF_DEF_PARAMS (ifp)->type == old_type)
5368 return CMD_SUCCESS;
5369
5370 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5371 {
5372 struct ospf_interface *oi = rn->info;
5373
5374 if (!oi)
5375 continue;
5376
5377 oi->type = IF_DEF_PARAMS (ifp)->type;
5378
5379 if (oi->state > ISM_Down)
5380 {
5381 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5382 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5383 }
5384 }
5385
5386 return CMD_SUCCESS;
5387}
5388
5389ALIAS (no_ip_ospf_network,
5390 no_ospf_network_cmd,
5391 "no ospf network",
5392 NO_STR
5393 "OSPF interface commands\n"
5394 "Network type\n")
5395
5396DEFUN (ip_ospf_priority,
5397 ip_ospf_priority_addr_cmd,
5398 "ip ospf priority <0-255> A.B.C.D",
5399 "IP Information\n"
5400 "OSPF interface commands\n"
5401 "Router priority\n"
5402 "Priority\n"
5403 "Address of interface")
5404{
5405 struct interface *ifp = vty->index;
5406 u_int32_t priority;
5407 struct route_node *rn;
5408 struct in_addr addr;
5409 int ret;
5410 struct ospf_if_params *params;
5411
5412 params = IF_DEF_PARAMS (ifp);
5413
5414 priority = strtol (argv[0], NULL, 10);
5415
5416 /* Router Priority range is <0-255>. */
5417 if (priority < 0 || priority > 255)
5418 {
5419 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5420 return CMD_WARNING;
5421 }
5422
5423 if (argc == 2)
5424 {
5425 ret = inet_aton(argv[1], &addr);
5426 if (!ret)
5427 {
5428 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5429 VTY_NEWLINE);
5430 return CMD_WARNING;
5431 }
5432
5433 params = ospf_get_if_params (ifp, addr);
5434 ospf_if_update_params (ifp, addr);
5435 }
5436
5437 SET_IF_PARAM (params, priority);
5438 params->priority = priority;
5439
5440 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5441 {
5442 struct ospf_interface *oi = rn->info;
5443
5444 if (!oi)
5445 continue;
5446
5447
5448 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5449 {
5450 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5451 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5452 }
5453 }
5454
5455 return CMD_SUCCESS;
5456}
5457
5458ALIAS (ip_ospf_priority,
5459 ip_ospf_priority_cmd,
5460 "ip ospf priority <0-255>",
5461 "IP Information\n"
5462 "OSPF interface commands\n"
5463 "Router priority\n"
5464 "Priority\n")
5465
5466ALIAS (ip_ospf_priority,
5467 ospf_priority_cmd,
5468 "ospf priority <0-255>",
5469 "OSPF interface commands\n"
5470 "Router priority\n"
5471 "Priority\n")
5472
5473DEFUN (no_ip_ospf_priority,
5474 no_ip_ospf_priority_addr_cmd,
5475 "no ip ospf priority A.B.C.D",
5476 NO_STR
5477 "IP Information\n"
5478 "OSPF interface commands\n"
5479 "Router priority\n"
5480 "Address of interface")
5481{
5482 struct interface *ifp = vty->index;
5483 struct route_node *rn;
5484 struct in_addr addr;
5485 int ret;
5486 struct ospf_if_params *params;
5487
5488 ifp = vty->index;
5489 params = IF_DEF_PARAMS (ifp);
5490
5491 if (argc == 1)
5492 {
5493 ret = inet_aton(argv[0], &addr);
5494 if (!ret)
5495 {
5496 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5497 VTY_NEWLINE);
5498 return CMD_WARNING;
5499 }
5500
5501 params = ospf_lookup_if_params (ifp, addr);
5502 if (params == NULL)
5503 return CMD_SUCCESS;
5504 }
5505
5506 UNSET_IF_PARAM (params, priority);
5507 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5508
5509 if (params != IF_DEF_PARAMS (ifp))
5510 {
5511 ospf_free_if_params (ifp, addr);
5512 ospf_if_update_params (ifp, addr);
5513 }
5514
5515 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5516 {
5517 struct ospf_interface *oi = rn->info;
5518
5519 if (!oi)
5520 continue;
5521
5522
5523 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5524 {
5525 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5526 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5527 }
5528 }
5529
5530 return CMD_SUCCESS;
5531}
5532
5533ALIAS (no_ip_ospf_priority,
5534 no_ip_ospf_priority_cmd,
5535 "no ip ospf priority",
5536 NO_STR
5537 "IP Information\n"
5538 "OSPF interface commands\n"
5539 "Router priority\n")
5540
5541ALIAS (no_ip_ospf_priority,
5542 no_ospf_priority_cmd,
5543 "no ospf priority",
5544 NO_STR
5545 "OSPF interface commands\n"
5546 "Router priority\n")
5547
5548DEFUN (ip_ospf_retransmit_interval,
5549 ip_ospf_retransmit_interval_addr_cmd,
5550 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5551 "IP Information\n"
5552 "OSPF interface commands\n"
5553 "Time between retransmitting lost link state advertisements\n"
5554 "Seconds\n"
5555 "Address of interface")
5556{
5557 struct interface *ifp = vty->index;
5558 u_int32_t seconds;
5559 struct in_addr addr;
5560 int ret;
5561 struct ospf_if_params *params;
5562
5563 params = IF_DEF_PARAMS (ifp);
5564 seconds = strtol (argv[0], NULL, 10);
5565
5566 /* Retransmit Interval range is <3-65535>. */
5567 if (seconds < 3 || seconds > 65535)
5568 {
5569 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5570 return CMD_WARNING;
5571 }
5572
5573
5574 if (argc == 2)
5575 {
5576 ret = inet_aton(argv[1], &addr);
5577 if (!ret)
5578 {
5579 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5580 VTY_NEWLINE);
5581 return CMD_WARNING;
5582 }
5583
5584 params = ospf_get_if_params (ifp, addr);
5585 ospf_if_update_params (ifp, addr);
5586 }
5587
5588 SET_IF_PARAM (params, retransmit_interval);
5589 params->retransmit_interval = seconds;
5590
5591 return CMD_SUCCESS;
5592}
5593
5594ALIAS (ip_ospf_retransmit_interval,
5595 ip_ospf_retransmit_interval_cmd,
5596 "ip ospf retransmit-interval <3-65535>",
5597 "IP Information\n"
5598 "OSPF interface commands\n"
5599 "Time between retransmitting lost link state advertisements\n"
5600 "Seconds\n")
5601
5602ALIAS (ip_ospf_retransmit_interval,
5603 ospf_retransmit_interval_cmd,
5604 "ospf retransmit-interval <3-65535>",
5605 "OSPF interface commands\n"
5606 "Time between retransmitting lost link state advertisements\n"
5607 "Seconds\n")
5608
5609DEFUN (no_ip_ospf_retransmit_interval,
5610 no_ip_ospf_retransmit_interval_addr_cmd,
5611 "no ip ospf retransmit-interval A.B.C.D",
5612 NO_STR
5613 "IP Information\n"
5614 "OSPF interface commands\n"
5615 "Time between retransmitting lost link state advertisements\n"
5616 "Address of interface")
5617{
5618 struct interface *ifp = vty->index;
5619 struct in_addr addr;
5620 int ret;
5621 struct ospf_if_params *params;
5622
5623 ifp = vty->index;
5624 params = IF_DEF_PARAMS (ifp);
5625
5626 if (argc == 1)
5627 {
5628 ret = inet_aton(argv[0], &addr);
5629 if (!ret)
5630 {
5631 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5632 VTY_NEWLINE);
5633 return CMD_WARNING;
5634 }
5635
5636 params = ospf_lookup_if_params (ifp, addr);
5637 if (params == NULL)
5638 return CMD_SUCCESS;
5639 }
5640
5641 UNSET_IF_PARAM (params, retransmit_interval);
5642 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5643
5644 if (params != IF_DEF_PARAMS (ifp))
5645 {
5646 ospf_free_if_params (ifp, addr);
5647 ospf_if_update_params (ifp, addr);
5648 }
5649
5650 return CMD_SUCCESS;
5651}
5652
5653ALIAS (no_ip_ospf_retransmit_interval,
5654 no_ip_ospf_retransmit_interval_cmd,
5655 "no ip ospf retransmit-interval",
5656 NO_STR
5657 "IP Information\n"
5658 "OSPF interface commands\n"
5659 "Time between retransmitting lost link state advertisements\n")
5660
5661ALIAS (no_ip_ospf_retransmit_interval,
5662 no_ospf_retransmit_interval_cmd,
5663 "no ospf retransmit-interval",
5664 NO_STR
5665 "OSPF interface commands\n"
5666 "Time between retransmitting lost link state advertisements\n")
5667
5668DEFUN (ip_ospf_transmit_delay,
5669 ip_ospf_transmit_delay_addr_cmd,
5670 "ip ospf transmit-delay <1-65535> A.B.C.D",
5671 "IP Information\n"
5672 "OSPF interface commands\n"
5673 "Link state transmit delay\n"
5674 "Seconds\n"
5675 "Address of interface")
5676{
5677 struct interface *ifp = vty->index;
5678 u_int32_t seconds;
5679 struct in_addr addr;
5680 int ret;
5681 struct ospf_if_params *params;
5682
5683 params = IF_DEF_PARAMS (ifp);
5684 seconds = strtol (argv[0], NULL, 10);
5685
5686 /* Transmit Delay range is <1-65535>. */
5687 if (seconds < 1 || seconds > 65535)
5688 {
5689 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5690 return CMD_WARNING;
5691 }
5692
5693 if (argc == 2)
5694 {
5695 ret = inet_aton(argv[1], &addr);
5696 if (!ret)
5697 {
5698 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5699 VTY_NEWLINE);
5700 return CMD_WARNING;
5701 }
5702
5703 params = ospf_get_if_params (ifp, addr);
5704 ospf_if_update_params (ifp, addr);
5705 }
5706
5707 SET_IF_PARAM (params, transmit_delay);
5708 params->transmit_delay = seconds;
5709
5710 return CMD_SUCCESS;
5711}
5712
5713ALIAS (ip_ospf_transmit_delay,
5714 ip_ospf_transmit_delay_cmd,
5715 "ip ospf transmit-delay <1-65535>",
5716 "IP Information\n"
5717 "OSPF interface commands\n"
5718 "Link state transmit delay\n"
5719 "Seconds\n")
5720
5721ALIAS (ip_ospf_transmit_delay,
5722 ospf_transmit_delay_cmd,
5723 "ospf transmit-delay <1-65535>",
5724 "OSPF interface commands\n"
5725 "Link state transmit delay\n"
5726 "Seconds\n")
5727
5728DEFUN (no_ip_ospf_transmit_delay,
5729 no_ip_ospf_transmit_delay_addr_cmd,
5730 "no ip ospf transmit-delay A.B.C.D",
5731 NO_STR
5732 "IP Information\n"
5733 "OSPF interface commands\n"
5734 "Link state transmit delay\n"
5735 "Address of interface")
5736{
5737 struct interface *ifp = vty->index;
5738 struct in_addr addr;
5739 int ret;
5740 struct ospf_if_params *params;
5741
5742 ifp = vty->index;
5743 params = IF_DEF_PARAMS (ifp);
5744
5745 if (argc == 1)
5746 {
5747 ret = inet_aton(argv[0], &addr);
5748 if (!ret)
5749 {
5750 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5751 VTY_NEWLINE);
5752 return CMD_WARNING;
5753 }
5754
5755 params = ospf_lookup_if_params (ifp, addr);
5756 if (params == NULL)
5757 return CMD_SUCCESS;
5758 }
5759
5760 UNSET_IF_PARAM (params, transmit_delay);
5761 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5762
5763 if (params != IF_DEF_PARAMS (ifp))
5764 {
5765 ospf_free_if_params (ifp, addr);
5766 ospf_if_update_params (ifp, addr);
5767 }
5768
5769 return CMD_SUCCESS;
5770}
5771
5772ALIAS (no_ip_ospf_transmit_delay,
5773 no_ip_ospf_transmit_delay_cmd,
5774 "no ip ospf transmit-delay",
5775 NO_STR
5776 "IP Information\n"
5777 "OSPF interface commands\n"
5778 "Link state transmit delay\n")
5779
5780ALIAS (no_ip_ospf_transmit_delay,
5781 no_ospf_transmit_delay_cmd,
5782 "no ospf transmit-delay",
5783 NO_STR
5784 "OSPF interface commands\n"
5785 "Link state transmit delay\n")
5786
5787
5788DEFUN (ospf_redistribute_source_metric_type,
5789 ospf_redistribute_source_metric_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005790 "redistribute " QUAGGA_REDIST_STR_OSPFD
5791 " metric <0-16777214> metric-type (1|2) route-map WORD",
5792 REDIST_STR
5793 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005794 "Metric for redistributed routes\n"
5795 "OSPF default metric\n"
5796 "OSPF exterior metric type for redistributed routes\n"
5797 "Set OSPF External Type 1 metrics\n"
5798 "Set OSPF External Type 2 metrics\n"
5799 "Route map reference\n"
5800 "Pointer to route-map entries\n")
5801{
paul020709f2003-04-04 02:44:16 +00005802 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005803 int source;
5804 int type = -1;
5805 int metric = -1;
5806
5807 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005808 source = proto_redistnum(AFI_IP, argv[0]);
5809 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005810 return CMD_WARNING;
5811
5812 /* Get metric value. */
5813 if (argc >= 2)
5814 if (!str2metric (argv[1], &metric))
5815 return CMD_WARNING;
5816
5817 /* Get metric type. */
5818 if (argc >= 3)
5819 if (!str2metric_type (argv[2], &type))
5820 return CMD_WARNING;
5821
5822 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005823 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005824 else
paul020709f2003-04-04 02:44:16 +00005825 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005826
paul020709f2003-04-04 02:44:16 +00005827 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005828}
5829
5830ALIAS (ospf_redistribute_source_metric_type,
5831 ospf_redistribute_source_metric_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005832 "redistribute " QUAGGA_REDIST_STR_OSPFD
5833 " metric <0-16777214> metric-type (1|2)",
5834 REDIST_STR
5835 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005836 "Metric for redistributed routes\n"
5837 "OSPF default metric\n"
5838 "OSPF exterior metric type for redistributed routes\n"
5839 "Set OSPF External Type 1 metrics\n"
5840 "Set OSPF External Type 2 metrics\n")
5841
5842ALIAS (ospf_redistribute_source_metric_type,
5843 ospf_redistribute_source_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005844 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5845 REDIST_STR
5846 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005847 "Metric for redistributed routes\n"
5848 "OSPF default metric\n")
5849
5850DEFUN (ospf_redistribute_source_type_metric,
5851 ospf_redistribute_source_type_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005852 "redistribute " QUAGGA_REDIST_STR_OSPFD
5853 " metric-type (1|2) metric <0-16777214> route-map WORD",
5854 REDIST_STR
5855 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005856 "OSPF exterior metric type for redistributed routes\n"
5857 "Set OSPF External Type 1 metrics\n"
5858 "Set OSPF External Type 2 metrics\n"
5859 "Metric for redistributed routes\n"
5860 "OSPF default metric\n"
5861 "Route map reference\n"
5862 "Pointer to route-map entries\n")
5863{
paul020709f2003-04-04 02:44:16 +00005864 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005865 int source;
5866 int type = -1;
5867 int metric = -1;
5868
5869 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005870 source = proto_redistnum(AFI_IP, argv[0]);
5871 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005872 return CMD_WARNING;
5873
5874 /* Get metric value. */
5875 if (argc >= 2)
5876 if (!str2metric_type (argv[1], &type))
5877 return CMD_WARNING;
5878
5879 /* Get metric type. */
5880 if (argc >= 3)
5881 if (!str2metric (argv[2], &metric))
5882 return CMD_WARNING;
5883
5884 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005885 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005886 else
paul020709f2003-04-04 02:44:16 +00005887 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005888
paul020709f2003-04-04 02:44:16 +00005889 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005890}
5891
5892ALIAS (ospf_redistribute_source_type_metric,
5893 ospf_redistribute_source_type_metric_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005894 "redistribute " QUAGGA_REDIST_STR_OSPFD
5895 " metric-type (1|2) metric <0-16777214>",
5896 REDIST_STR
5897 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005898 "OSPF exterior metric type for redistributed routes\n"
5899 "Set OSPF External Type 1 metrics\n"
5900 "Set OSPF External Type 2 metrics\n"
5901 "Metric for redistributed routes\n"
5902 "OSPF default metric\n")
5903
5904ALIAS (ospf_redistribute_source_type_metric,
5905 ospf_redistribute_source_type_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005906 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5907 REDIST_STR
5908 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005909 "OSPF exterior metric type for redistributed routes\n"
5910 "Set OSPF External Type 1 metrics\n"
5911 "Set OSPF External Type 2 metrics\n")
5912
5913ALIAS (ospf_redistribute_source_type_metric,
5914 ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005915 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5916 REDIST_STR
5917 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00005918
5919DEFUN (ospf_redistribute_source_metric_routemap,
5920 ospf_redistribute_source_metric_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005921 "redistribute " QUAGGA_REDIST_STR_OSPFD
5922 " metric <0-16777214> route-map WORD",
5923 REDIST_STR
5924 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005925 "Metric for redistributed routes\n"
5926 "OSPF default metric\n"
5927 "Route map reference\n"
5928 "Pointer to route-map entries\n")
5929{
paul020709f2003-04-04 02:44:16 +00005930 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005931 int source;
5932 int metric = -1;
5933
5934 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005935 source = proto_redistnum(AFI_IP, argv[0]);
5936 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005937 return CMD_WARNING;
5938
5939 /* Get metric value. */
5940 if (argc >= 2)
5941 if (!str2metric (argv[1], &metric))
5942 return CMD_WARNING;
5943
5944 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005945 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005946 else
paul020709f2003-04-04 02:44:16 +00005947 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005948
paul020709f2003-04-04 02:44:16 +00005949 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005950}
5951
5952DEFUN (ospf_redistribute_source_type_routemap,
5953 ospf_redistribute_source_type_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005954 "redistribute " QUAGGA_REDIST_STR_OSPFD
5955 " metric-type (1|2) route-map WORD",
5956 REDIST_STR
5957 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005958 "OSPF exterior metric type for redistributed routes\n"
5959 "Set OSPF External Type 1 metrics\n"
5960 "Set OSPF External Type 2 metrics\n"
5961 "Route map reference\n"
5962 "Pointer to route-map entries\n")
5963{
paul020709f2003-04-04 02:44:16 +00005964 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005965 int source;
5966 int type = -1;
5967
5968 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005969 source = proto_redistnum(AFI_IP, argv[0]);
5970 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00005971 return CMD_WARNING;
5972
5973 /* Get metric value. */
5974 if (argc >= 2)
5975 if (!str2metric_type (argv[1], &type))
5976 return CMD_WARNING;
5977
5978 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005979 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005980 else
paul020709f2003-04-04 02:44:16 +00005981 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005982
paul020709f2003-04-04 02:44:16 +00005983 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005984}
5985
5986DEFUN (ospf_redistribute_source_routemap,
5987 ospf_redistribute_source_routemap_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00005988 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5989 REDIST_STR
5990 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005991 "Route map reference\n"
5992 "Pointer to route-map entries\n")
5993{
paul020709f2003-04-04 02:44:16 +00005994 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005995 int source;
5996
5997 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02005998 source = proto_redistnum(AFI_IP, argv[0]);
5999 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006000 return CMD_WARNING;
6001
6002 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006003 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00006004 else
paul020709f2003-04-04 02:44:16 +00006005 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006006
paul020709f2003-04-04 02:44:16 +00006007 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00006008}
6009
6010DEFUN (no_ospf_redistribute_source,
6011 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006012 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006013 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006014 REDIST_STR
6015 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006016{
paul020709f2003-04-04 02:44:16 +00006017 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006018 int source;
6019
David Lampartere0ca5fd2009-09-16 01:52:42 +02006020 source = proto_redistnum(AFI_IP, argv[0]);
6021 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006022 return CMD_WARNING;
6023
paul020709f2003-04-04 02:44:16 +00006024 ospf_routemap_unset (ospf, source);
6025 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006026}
6027
6028DEFUN (ospf_distribute_list_out,
6029 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006030 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006031 "Filter networks in routing updates\n"
6032 "Access-list name\n"
6033 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006034 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006035{
paul68980082003-03-25 05:07:42 +00006036 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006037 int source;
6038
6039 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02006040 source = proto_redistnum(AFI_IP, argv[0]);
6041 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006042 return CMD_WARNING;
6043
paul68980082003-03-25 05:07:42 +00006044 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006045}
6046
6047DEFUN (no_ospf_distribute_list_out,
6048 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006049 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006050 NO_STR
6051 "Filter networks in routing updates\n"
6052 "Access-list name\n"
6053 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006054 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006055{
paul68980082003-03-25 05:07:42 +00006056 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006057 int source;
6058
David Lampartere0ca5fd2009-09-16 01:52:42 +02006059 source = proto_redistnum(AFI_IP, argv[0]);
6060 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006061 return CMD_WARNING;
6062
paul68980082003-03-25 05:07:42 +00006063 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006064}
6065
6066/* Default information originate. */
6067DEFUN (ospf_default_information_originate_metric_type_routemap,
6068 ospf_default_information_originate_metric_type_routemap_cmd,
6069 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
6070 "Control distribution of default information\n"
6071 "Distribute a default route\n"
6072 "OSPF default metric\n"
6073 "OSPF metric\n"
6074 "OSPF metric type for default routes\n"
6075 "Set OSPF External Type 1 metrics\n"
6076 "Set OSPF External Type 2 metrics\n"
6077 "Route map reference\n"
6078 "Pointer to route-map entries\n")
6079{
paul020709f2003-04-04 02:44:16 +00006080 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006081 int type = -1;
6082 int metric = -1;
6083
6084 /* Get metric value. */
6085 if (argc >= 1)
6086 if (!str2metric (argv[0], &metric))
6087 return CMD_WARNING;
6088
6089 /* Get metric type. */
6090 if (argc >= 2)
6091 if (!str2metric_type (argv[1], &type))
6092 return CMD_WARNING;
6093
6094 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006095 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006096 else
paul020709f2003-04-04 02:44:16 +00006097 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006098
paul020709f2003-04-04 02:44:16 +00006099 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6100 type, metric);
paul718e3742002-12-13 20:15:29 +00006101}
6102
6103ALIAS (ospf_default_information_originate_metric_type_routemap,
6104 ospf_default_information_originate_metric_type_cmd,
6105 "default-information originate metric <0-16777214> metric-type (1|2)",
6106 "Control distribution of default information\n"
6107 "Distribute a default route\n"
6108 "OSPF default metric\n"
6109 "OSPF metric\n"
6110 "OSPF metric type for default routes\n"
6111 "Set OSPF External Type 1 metrics\n"
6112 "Set OSPF External Type 2 metrics\n")
6113
6114ALIAS (ospf_default_information_originate_metric_type_routemap,
6115 ospf_default_information_originate_metric_cmd,
6116 "default-information originate metric <0-16777214>",
6117 "Control distribution of default information\n"
6118 "Distribute a default route\n"
6119 "OSPF default metric\n"
6120 "OSPF metric\n")
6121
6122ALIAS (ospf_default_information_originate_metric_type_routemap,
6123 ospf_default_information_originate_cmd,
6124 "default-information originate",
6125 "Control distribution of default information\n"
6126 "Distribute a default route\n")
6127
6128/* Default information originate. */
6129DEFUN (ospf_default_information_originate_metric_routemap,
6130 ospf_default_information_originate_metric_routemap_cmd,
6131 "default-information originate metric <0-16777214> route-map WORD",
6132 "Control distribution of default information\n"
6133 "Distribute a default route\n"
6134 "OSPF default metric\n"
6135 "OSPF metric\n"
6136 "Route map reference\n"
6137 "Pointer to route-map entries\n")
6138{
paul020709f2003-04-04 02:44:16 +00006139 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006140 int metric = -1;
6141
6142 /* Get metric value. */
6143 if (argc >= 1)
6144 if (!str2metric (argv[0], &metric))
6145 return CMD_WARNING;
6146
6147 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006148 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006149 else
paul020709f2003-04-04 02:44:16 +00006150 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006151
paul020709f2003-04-04 02:44:16 +00006152 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6153 -1, metric);
paul718e3742002-12-13 20:15:29 +00006154}
6155
6156/* Default information originate. */
6157DEFUN (ospf_default_information_originate_routemap,
6158 ospf_default_information_originate_routemap_cmd,
6159 "default-information originate route-map WORD",
6160 "Control distribution of default information\n"
6161 "Distribute a default route\n"
6162 "Route map reference\n"
6163 "Pointer to route-map entries\n")
6164{
paul020709f2003-04-04 02:44:16 +00006165 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006166
paul020709f2003-04-04 02:44:16 +00006167 if (argc == 1)
6168 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6169 else
6170 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6171
6172 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00006173}
6174
6175DEFUN (ospf_default_information_originate_type_metric_routemap,
6176 ospf_default_information_originate_type_metric_routemap_cmd,
6177 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6178 "Control distribution of default information\n"
6179 "Distribute a default route\n"
6180 "OSPF metric type for default routes\n"
6181 "Set OSPF External Type 1 metrics\n"
6182 "Set OSPF External Type 2 metrics\n"
6183 "OSPF default metric\n"
6184 "OSPF metric\n"
6185 "Route map reference\n"
6186 "Pointer to route-map entries\n")
6187{
paul020709f2003-04-04 02:44:16 +00006188 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006189 int type = -1;
6190 int metric = -1;
6191
6192 /* Get metric type. */
6193 if (argc >= 1)
6194 if (!str2metric_type (argv[0], &type))
6195 return CMD_WARNING;
6196
6197 /* Get metric value. */
6198 if (argc >= 2)
6199 if (!str2metric (argv[1], &metric))
6200 return CMD_WARNING;
6201
6202 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006203 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006204 else
paul020709f2003-04-04 02:44:16 +00006205 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006206
paul020709f2003-04-04 02:44:16 +00006207 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6208 type, metric);
paul718e3742002-12-13 20:15:29 +00006209}
6210
6211ALIAS (ospf_default_information_originate_type_metric_routemap,
6212 ospf_default_information_originate_type_metric_cmd,
6213 "default-information originate metric-type (1|2) metric <0-16777214>",
6214 "Control distribution of default information\n"
6215 "Distribute a default route\n"
6216 "OSPF metric type for default routes\n"
6217 "Set OSPF External Type 1 metrics\n"
6218 "Set OSPF External Type 2 metrics\n"
6219 "OSPF default metric\n"
6220 "OSPF metric\n")
6221
6222ALIAS (ospf_default_information_originate_type_metric_routemap,
6223 ospf_default_information_originate_type_cmd,
6224 "default-information originate metric-type (1|2)",
6225 "Control distribution of default information\n"
6226 "Distribute a default route\n"
6227 "OSPF metric type for default routes\n"
6228 "Set OSPF External Type 1 metrics\n"
6229 "Set OSPF External Type 2 metrics\n")
6230
6231DEFUN (ospf_default_information_originate_type_routemap,
6232 ospf_default_information_originate_type_routemap_cmd,
6233 "default-information originate metric-type (1|2) route-map WORD",
6234 "Control distribution of default information\n"
6235 "Distribute a default route\n"
6236 "OSPF metric type for default routes\n"
6237 "Set OSPF External Type 1 metrics\n"
6238 "Set OSPF External Type 2 metrics\n"
6239 "Route map reference\n"
6240 "Pointer to route-map entries\n")
6241{
paul020709f2003-04-04 02:44:16 +00006242 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006243 int type = -1;
6244
6245 /* Get metric type. */
6246 if (argc >= 1)
6247 if (!str2metric_type (argv[0], &type))
6248 return CMD_WARNING;
6249
6250 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006251 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006252 else
paul020709f2003-04-04 02:44:16 +00006253 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006254
paul020709f2003-04-04 02:44:16 +00006255 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6256 type, -1);
paul718e3742002-12-13 20:15:29 +00006257}
6258
6259DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6260 ospf_default_information_originate_always_metric_type_routemap_cmd,
6261 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6262 "Control distribution of default information\n"
6263 "Distribute a default route\n"
6264 "Always advertise default route\n"
6265 "OSPF default metric\n"
6266 "OSPF metric\n"
6267 "OSPF metric type for default routes\n"
6268 "Set OSPF External Type 1 metrics\n"
6269 "Set OSPF External Type 2 metrics\n"
6270 "Route map reference\n"
6271 "Pointer to route-map entries\n")
6272{
paul020709f2003-04-04 02:44:16 +00006273 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006274 int type = -1;
6275 int metric = -1;
6276
6277 /* Get metric value. */
6278 if (argc >= 1)
6279 if (!str2metric (argv[0], &metric))
6280 return CMD_WARNING;
6281
6282 /* Get metric type. */
6283 if (argc >= 2)
6284 if (!str2metric_type (argv[1], &type))
6285 return CMD_WARNING;
6286
6287 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006288 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006289 else
paul020709f2003-04-04 02:44:16 +00006290 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006291
paul020709f2003-04-04 02:44:16 +00006292 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006293 type, metric);
6294}
6295
6296ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6297 ospf_default_information_originate_always_metric_type_cmd,
6298 "default-information originate always metric <0-16777214> metric-type (1|2)",
6299 "Control distribution of default information\n"
6300 "Distribute a default route\n"
6301 "Always advertise default route\n"
6302 "OSPF default metric\n"
6303 "OSPF metric\n"
6304 "OSPF metric type for default routes\n"
6305 "Set OSPF External Type 1 metrics\n"
6306 "Set OSPF External Type 2 metrics\n")
6307
6308ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6309 ospf_default_information_originate_always_metric_cmd,
6310 "default-information originate always metric <0-16777214>",
6311 "Control distribution of default information\n"
6312 "Distribute a default route\n"
6313 "Always advertise default route\n"
6314 "OSPF default metric\n"
6315 "OSPF metric\n"
6316 "OSPF metric type for default routes\n")
6317
6318ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6319 ospf_default_information_originate_always_cmd,
6320 "default-information originate always",
6321 "Control distribution of default information\n"
6322 "Distribute a default route\n"
6323 "Always advertise default route\n")
6324
6325DEFUN (ospf_default_information_originate_always_metric_routemap,
6326 ospf_default_information_originate_always_metric_routemap_cmd,
6327 "default-information originate always metric <0-16777214> route-map WORD",
6328 "Control distribution of default information\n"
6329 "Distribute a default route\n"
6330 "Always advertise default route\n"
6331 "OSPF default metric\n"
6332 "OSPF metric\n"
6333 "Route map reference\n"
6334 "Pointer to route-map entries\n")
6335{
paul020709f2003-04-04 02:44:16 +00006336 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006337 int metric = -1;
6338
6339 /* Get metric value. */
6340 if (argc >= 1)
6341 if (!str2metric (argv[0], &metric))
6342 return CMD_WARNING;
6343
6344 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006345 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006346 else
paul020709f2003-04-04 02:44:16 +00006347 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006348
paul020709f2003-04-04 02:44:16 +00006349 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6350 -1, metric);
paul718e3742002-12-13 20:15:29 +00006351}
6352
6353DEFUN (ospf_default_information_originate_always_routemap,
6354 ospf_default_information_originate_always_routemap_cmd,
6355 "default-information originate always route-map WORD",
6356 "Control distribution of default information\n"
6357 "Distribute a default route\n"
6358 "Always advertise default route\n"
6359 "Route map reference\n"
6360 "Pointer to route-map entries\n")
6361{
paul020709f2003-04-04 02:44:16 +00006362 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006363
paul020709f2003-04-04 02:44:16 +00006364 if (argc == 1)
6365 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6366 else
6367 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6368
6369 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006370}
6371
6372DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6373 ospf_default_information_originate_always_type_metric_routemap_cmd,
6374 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6375 "Control distribution of default information\n"
6376 "Distribute a default route\n"
6377 "Always advertise default route\n"
6378 "OSPF metric type for default routes\n"
6379 "Set OSPF External Type 1 metrics\n"
6380 "Set OSPF External Type 2 metrics\n"
6381 "OSPF default metric\n"
6382 "OSPF metric\n"
6383 "Route map reference\n"
6384 "Pointer to route-map entries\n")
6385{
paul020709f2003-04-04 02:44:16 +00006386 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006387 int type = -1;
6388 int metric = -1;
6389
6390 /* Get metric type. */
6391 if (argc >= 1)
6392 if (!str2metric_type (argv[0], &type))
6393 return CMD_WARNING;
6394
6395 /* Get metric value. */
6396 if (argc >= 2)
6397 if (!str2metric (argv[1], &metric))
6398 return CMD_WARNING;
6399
6400 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006401 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006402 else
paul020709f2003-04-04 02:44:16 +00006403 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006404
paul020709f2003-04-04 02:44:16 +00006405 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006406 type, metric);
6407}
6408
6409ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6410 ospf_default_information_originate_always_type_metric_cmd,
6411 "default-information originate always metric-type (1|2) metric <0-16777214>",
6412 "Control distribution of default information\n"
6413 "Distribute a default route\n"
6414 "Always advertise default route\n"
6415 "OSPF metric type for default routes\n"
6416 "Set OSPF External Type 1 metrics\n"
6417 "Set OSPF External Type 2 metrics\n"
6418 "OSPF default metric\n"
6419 "OSPF metric\n")
6420
6421ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6422 ospf_default_information_originate_always_type_cmd,
6423 "default-information originate always metric-type (1|2)",
6424 "Control distribution of default information\n"
6425 "Distribute a default route\n"
6426 "Always advertise default route\n"
6427 "OSPF metric type for default routes\n"
6428 "Set OSPF External Type 1 metrics\n"
6429 "Set OSPF External Type 2 metrics\n")
6430
6431DEFUN (ospf_default_information_originate_always_type_routemap,
6432 ospf_default_information_originate_always_type_routemap_cmd,
6433 "default-information originate always metric-type (1|2) route-map WORD",
6434 "Control distribution of default information\n"
6435 "Distribute a default route\n"
6436 "Always advertise default route\n"
6437 "OSPF metric type for default routes\n"
6438 "Set OSPF External Type 1 metrics\n"
6439 "Set OSPF External Type 2 metrics\n"
6440 "Route map reference\n"
6441 "Pointer to route-map entries\n")
6442{
paul020709f2003-04-04 02:44:16 +00006443 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006444 int type = -1;
6445
6446 /* Get metric type. */
6447 if (argc >= 1)
6448 if (!str2metric_type (argv[0], &type))
6449 return CMD_WARNING;
6450
6451 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006452 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006453 else
paul020709f2003-04-04 02:44:16 +00006454 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006455
paul020709f2003-04-04 02:44:16 +00006456 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006457 type, -1);
6458}
6459
6460DEFUN (no_ospf_default_information_originate,
6461 no_ospf_default_information_originate_cmd,
6462 "no default-information originate",
6463 NO_STR
6464 "Control distribution of default information\n"
6465 "Distribute a default route\n")
6466{
paul68980082003-03-25 05:07:42 +00006467 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006468 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006469
6470 p.family = AF_INET;
6471 p.prefix.s_addr = 0;
6472 p.prefixlen = 0;
6473
ajs5339cfd2005-09-19 13:28:05 +00006474 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006475
6476 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6477 ospf_external_info_delete (DEFAULT_ROUTE, p);
6478 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6479 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6480 }
6481
paul020709f2003-04-04 02:44:16 +00006482 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6483 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006484}
6485
6486DEFUN (ospf_default_metric,
6487 ospf_default_metric_cmd,
6488 "default-metric <0-16777214>",
6489 "Set metric of redistributed routes\n"
6490 "Default metric\n")
6491{
paul68980082003-03-25 05:07:42 +00006492 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006493 int metric = -1;
6494
6495 if (!str2metric (argv[0], &metric))
6496 return CMD_WARNING;
6497
paul68980082003-03-25 05:07:42 +00006498 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006499
6500 return CMD_SUCCESS;
6501}
6502
6503DEFUN (no_ospf_default_metric,
6504 no_ospf_default_metric_cmd,
6505 "no default-metric",
6506 NO_STR
6507 "Set metric of redistributed routes\n")
6508{
paul68980082003-03-25 05:07:42 +00006509 struct ospf *ospf = vty->index;
6510
6511 ospf->default_metric = -1;
6512
paul718e3742002-12-13 20:15:29 +00006513 return CMD_SUCCESS;
6514}
6515
6516ALIAS (no_ospf_default_metric,
6517 no_ospf_default_metric_val_cmd,
6518 "no default-metric <0-16777214>",
6519 NO_STR
6520 "Set metric of redistributed routes\n"
6521 "Default metric\n")
6522
6523DEFUN (ospf_distance,
6524 ospf_distance_cmd,
6525 "distance <1-255>",
6526 "Define an administrative distance\n"
6527 "OSPF Administrative distance\n")
6528{
paul68980082003-03-25 05:07:42 +00006529 struct ospf *ospf = vty->index;
6530
6531 ospf->distance_all = atoi (argv[0]);
6532
paul718e3742002-12-13 20:15:29 +00006533 return CMD_SUCCESS;
6534}
6535
6536DEFUN (no_ospf_distance,
6537 no_ospf_distance_cmd,
6538 "no distance <1-255>",
6539 NO_STR
6540 "Define an administrative distance\n"
6541 "OSPF Administrative distance\n")
6542{
paul68980082003-03-25 05:07:42 +00006543 struct ospf *ospf = vty->index;
6544
6545 ospf->distance_all = 0;
6546
paul718e3742002-12-13 20:15:29 +00006547 return CMD_SUCCESS;
6548}
6549
6550DEFUN (no_ospf_distance_ospf,
6551 no_ospf_distance_ospf_cmd,
6552 "no distance ospf",
6553 NO_STR
6554 "Define an administrative distance\n"
6555 "OSPF Administrative distance\n"
6556 "OSPF Distance\n")
6557{
paul68980082003-03-25 05:07:42 +00006558 struct ospf *ospf = vty->index;
6559
6560 ospf->distance_intra = 0;
6561 ospf->distance_inter = 0;
6562 ospf->distance_external = 0;
6563
paul718e3742002-12-13 20:15:29 +00006564 return CMD_SUCCESS;
6565}
6566
6567DEFUN (ospf_distance_ospf_intra,
6568 ospf_distance_ospf_intra_cmd,
6569 "distance ospf intra-area <1-255>",
6570 "Define an administrative distance\n"
6571 "OSPF Administrative distance\n"
6572 "Intra-area routes\n"
6573 "Distance for intra-area routes\n")
6574{
paul68980082003-03-25 05:07:42 +00006575 struct ospf *ospf = vty->index;
6576
6577 ospf->distance_intra = atoi (argv[0]);
6578
paul718e3742002-12-13 20:15:29 +00006579 return CMD_SUCCESS;
6580}
6581
6582DEFUN (ospf_distance_ospf_intra_inter,
6583 ospf_distance_ospf_intra_inter_cmd,
6584 "distance ospf intra-area <1-255> inter-area <1-255>",
6585 "Define an administrative distance\n"
6586 "OSPF Administrative distance\n"
6587 "Intra-area routes\n"
6588 "Distance for intra-area routes\n"
6589 "Inter-area routes\n"
6590 "Distance for inter-area routes\n")
6591{
paul68980082003-03-25 05:07:42 +00006592 struct ospf *ospf = vty->index;
6593
6594 ospf->distance_intra = atoi (argv[0]);
6595 ospf->distance_inter = atoi (argv[1]);
6596
paul718e3742002-12-13 20:15:29 +00006597 return CMD_SUCCESS;
6598}
6599
6600DEFUN (ospf_distance_ospf_intra_external,
6601 ospf_distance_ospf_intra_external_cmd,
6602 "distance ospf intra-area <1-255> external <1-255>",
6603 "Define an administrative distance\n"
6604 "OSPF Administrative distance\n"
6605 "Intra-area routes\n"
6606 "Distance for intra-area routes\n"
6607 "External routes\n"
6608 "Distance for external routes\n")
6609{
paul68980082003-03-25 05:07:42 +00006610 struct ospf *ospf = vty->index;
6611
6612 ospf->distance_intra = atoi (argv[0]);
6613 ospf->distance_external = atoi (argv[1]);
6614
paul718e3742002-12-13 20:15:29 +00006615 return CMD_SUCCESS;
6616}
6617
6618DEFUN (ospf_distance_ospf_intra_inter_external,
6619 ospf_distance_ospf_intra_inter_external_cmd,
6620 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6621 "Define an administrative distance\n"
6622 "OSPF Administrative distance\n"
6623 "Intra-area routes\n"
6624 "Distance for intra-area routes\n"
6625 "Inter-area routes\n"
6626 "Distance for inter-area routes\n"
6627 "External routes\n"
6628 "Distance for external routes\n")
6629{
paul68980082003-03-25 05:07:42 +00006630 struct ospf *ospf = vty->index;
6631
6632 ospf->distance_intra = atoi (argv[0]);
6633 ospf->distance_inter = atoi (argv[1]);
6634 ospf->distance_external = atoi (argv[2]);
6635
paul718e3742002-12-13 20:15:29 +00006636 return CMD_SUCCESS;
6637}
6638
6639DEFUN (ospf_distance_ospf_intra_external_inter,
6640 ospf_distance_ospf_intra_external_inter_cmd,
6641 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6642 "Define an administrative distance\n"
6643 "OSPF Administrative distance\n"
6644 "Intra-area routes\n"
6645 "Distance for intra-area routes\n"
6646 "External routes\n"
6647 "Distance for external routes\n"
6648 "Inter-area routes\n"
6649 "Distance for inter-area routes\n")
6650{
paul68980082003-03-25 05:07:42 +00006651 struct ospf *ospf = vty->index;
6652
6653 ospf->distance_intra = atoi (argv[0]);
6654 ospf->distance_external = atoi (argv[1]);
6655 ospf->distance_inter = atoi (argv[2]);
6656
paul718e3742002-12-13 20:15:29 +00006657 return CMD_SUCCESS;
6658}
6659
6660DEFUN (ospf_distance_ospf_inter,
6661 ospf_distance_ospf_inter_cmd,
6662 "distance ospf inter-area <1-255>",
6663 "Define an administrative distance\n"
6664 "OSPF Administrative distance\n"
6665 "Inter-area routes\n"
6666 "Distance for inter-area routes\n")
6667{
paul68980082003-03-25 05:07:42 +00006668 struct ospf *ospf = vty->index;
6669
6670 ospf->distance_inter = atoi (argv[0]);
6671
paul718e3742002-12-13 20:15:29 +00006672 return CMD_SUCCESS;
6673}
6674
6675DEFUN (ospf_distance_ospf_inter_intra,
6676 ospf_distance_ospf_inter_intra_cmd,
6677 "distance ospf inter-area <1-255> intra-area <1-255>",
6678 "Define an administrative distance\n"
6679 "OSPF Administrative distance\n"
6680 "Inter-area routes\n"
6681 "Distance for inter-area routes\n"
6682 "Intra-area routes\n"
6683 "Distance for intra-area routes\n")
6684{
paul68980082003-03-25 05:07:42 +00006685 struct ospf *ospf = vty->index;
6686
6687 ospf->distance_inter = atoi (argv[0]);
6688 ospf->distance_intra = atoi (argv[1]);
6689
paul718e3742002-12-13 20:15:29 +00006690 return CMD_SUCCESS;
6691}
6692
6693DEFUN (ospf_distance_ospf_inter_external,
6694 ospf_distance_ospf_inter_external_cmd,
6695 "distance ospf inter-area <1-255> external <1-255>",
6696 "Define an administrative distance\n"
6697 "OSPF Administrative distance\n"
6698 "Inter-area routes\n"
6699 "Distance for inter-area routes\n"
6700 "External routes\n"
6701 "Distance for external routes\n")
6702{
paul68980082003-03-25 05:07:42 +00006703 struct ospf *ospf = vty->index;
6704
6705 ospf->distance_inter = atoi (argv[0]);
6706 ospf->distance_external = atoi (argv[1]);
6707
paul718e3742002-12-13 20:15:29 +00006708 return CMD_SUCCESS;
6709}
6710
6711DEFUN (ospf_distance_ospf_inter_intra_external,
6712 ospf_distance_ospf_inter_intra_external_cmd,
6713 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6714 "Define an administrative distance\n"
6715 "OSPF Administrative distance\n"
6716 "Inter-area routes\n"
6717 "Distance for inter-area routes\n"
6718 "Intra-area routes\n"
6719 "Distance for intra-area routes\n"
6720 "External routes\n"
6721 "Distance for external routes\n")
6722{
paul68980082003-03-25 05:07:42 +00006723 struct ospf *ospf = vty->index;
6724
6725 ospf->distance_inter = atoi (argv[0]);
6726 ospf->distance_intra = atoi (argv[1]);
6727 ospf->distance_external = atoi (argv[2]);
6728
paul718e3742002-12-13 20:15:29 +00006729 return CMD_SUCCESS;
6730}
6731
6732DEFUN (ospf_distance_ospf_inter_external_intra,
6733 ospf_distance_ospf_inter_external_intra_cmd,
6734 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6735 "Define an administrative distance\n"
6736 "OSPF Administrative distance\n"
6737 "Inter-area routes\n"
6738 "Distance for inter-area routes\n"
6739 "External routes\n"
6740 "Distance for external routes\n"
6741 "Intra-area routes\n"
6742 "Distance for intra-area routes\n")
6743{
paul68980082003-03-25 05:07:42 +00006744 struct ospf *ospf = vty->index;
6745
6746 ospf->distance_inter = atoi (argv[0]);
6747 ospf->distance_external = atoi (argv[1]);
6748 ospf->distance_intra = atoi (argv[2]);
6749
paul718e3742002-12-13 20:15:29 +00006750 return CMD_SUCCESS;
6751}
6752
6753DEFUN (ospf_distance_ospf_external,
6754 ospf_distance_ospf_external_cmd,
6755 "distance ospf external <1-255>",
6756 "Define an administrative distance\n"
6757 "OSPF Administrative distance\n"
6758 "External routes\n"
6759 "Distance for external routes\n")
6760{
paul68980082003-03-25 05:07:42 +00006761 struct ospf *ospf = vty->index;
6762
6763 ospf->distance_external = atoi (argv[0]);
6764
paul718e3742002-12-13 20:15:29 +00006765 return CMD_SUCCESS;
6766}
6767
6768DEFUN (ospf_distance_ospf_external_intra,
6769 ospf_distance_ospf_external_intra_cmd,
6770 "distance ospf external <1-255> intra-area <1-255>",
6771 "Define an administrative distance\n"
6772 "OSPF Administrative distance\n"
6773 "External routes\n"
6774 "Distance for external routes\n"
6775 "Intra-area routes\n"
6776 "Distance for intra-area routes\n")
6777{
paul68980082003-03-25 05:07:42 +00006778 struct ospf *ospf = vty->index;
6779
6780 ospf->distance_external = atoi (argv[0]);
6781 ospf->distance_intra = atoi (argv[1]);
6782
paul718e3742002-12-13 20:15:29 +00006783 return CMD_SUCCESS;
6784}
6785
6786DEFUN (ospf_distance_ospf_external_inter,
6787 ospf_distance_ospf_external_inter_cmd,
6788 "distance ospf external <1-255> inter-area <1-255>",
6789 "Define an administrative distance\n"
6790 "OSPF Administrative distance\n"
6791 "External routes\n"
6792 "Distance for external routes\n"
6793 "Inter-area routes\n"
6794 "Distance for inter-area routes\n")
6795{
paul68980082003-03-25 05:07:42 +00006796 struct ospf *ospf = vty->index;
6797
6798 ospf->distance_external = atoi (argv[0]);
6799 ospf->distance_inter = atoi (argv[1]);
6800
paul718e3742002-12-13 20:15:29 +00006801 return CMD_SUCCESS;
6802}
6803
6804DEFUN (ospf_distance_ospf_external_intra_inter,
6805 ospf_distance_ospf_external_intra_inter_cmd,
6806 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6807 "Define an administrative distance\n"
6808 "OSPF Administrative distance\n"
6809 "External routes\n"
6810 "Distance for external routes\n"
6811 "Intra-area routes\n"
6812 "Distance for intra-area routes\n"
6813 "Inter-area routes\n"
6814 "Distance for inter-area routes\n")
6815{
paul68980082003-03-25 05:07:42 +00006816 struct ospf *ospf = vty->index;
6817
6818 ospf->distance_external = atoi (argv[0]);
6819 ospf->distance_intra = atoi (argv[1]);
6820 ospf->distance_inter = atoi (argv[2]);
6821
paul718e3742002-12-13 20:15:29 +00006822 return CMD_SUCCESS;
6823}
6824
6825DEFUN (ospf_distance_ospf_external_inter_intra,
6826 ospf_distance_ospf_external_inter_intra_cmd,
6827 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6828 "Define an administrative distance\n"
6829 "OSPF Administrative distance\n"
6830 "External routes\n"
6831 "Distance for external routes\n"
6832 "Inter-area routes\n"
6833 "Distance for inter-area routes\n"
6834 "Intra-area routes\n"
6835 "Distance for intra-area routes\n")
6836{
paul68980082003-03-25 05:07:42 +00006837 struct ospf *ospf = vty->index;
6838
6839 ospf->distance_external = atoi (argv[0]);
6840 ospf->distance_inter = atoi (argv[1]);
6841 ospf->distance_intra = atoi (argv[2]);
6842
paul718e3742002-12-13 20:15:29 +00006843 return CMD_SUCCESS;
6844}
6845
6846DEFUN (ospf_distance_source,
6847 ospf_distance_source_cmd,
6848 "distance <1-255> A.B.C.D/M",
6849 "Administrative distance\n"
6850 "Distance value\n"
6851 "IP source prefix\n")
6852{
paul020709f2003-04-04 02:44:16 +00006853 struct ospf *ospf = vty->index;
6854
6855 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006856
paul718e3742002-12-13 20:15:29 +00006857 return CMD_SUCCESS;
6858}
6859
6860DEFUN (no_ospf_distance_source,
6861 no_ospf_distance_source_cmd,
6862 "no distance <1-255> A.B.C.D/M",
6863 NO_STR
6864 "Administrative distance\n"
6865 "Distance value\n"
6866 "IP source prefix\n")
6867{
paul020709f2003-04-04 02:44:16 +00006868 struct ospf *ospf = vty->index;
6869
6870 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6871
paul718e3742002-12-13 20:15:29 +00006872 return CMD_SUCCESS;
6873}
6874
6875DEFUN (ospf_distance_source_access_list,
6876 ospf_distance_source_access_list_cmd,
6877 "distance <1-255> A.B.C.D/M WORD",
6878 "Administrative distance\n"
6879 "Distance value\n"
6880 "IP source prefix\n"
6881 "Access list name\n")
6882{
paul020709f2003-04-04 02:44:16 +00006883 struct ospf *ospf = vty->index;
6884
6885 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6886
paul718e3742002-12-13 20:15:29 +00006887 return CMD_SUCCESS;
6888}
6889
6890DEFUN (no_ospf_distance_source_access_list,
6891 no_ospf_distance_source_access_list_cmd,
6892 "no distance <1-255> A.B.C.D/M WORD",
6893 NO_STR
6894 "Administrative distance\n"
6895 "Distance value\n"
6896 "IP source prefix\n"
6897 "Access list name\n")
6898{
paul020709f2003-04-04 02:44:16 +00006899 struct ospf *ospf = vty->index;
6900
6901 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6902
paul718e3742002-12-13 20:15:29 +00006903 return CMD_SUCCESS;
6904}
6905
vincentba682532005-09-29 13:52:57 +00006906DEFUN (ip_ospf_mtu_ignore,
6907 ip_ospf_mtu_ignore_addr_cmd,
6908 "ip ospf mtu-ignore A.B.C.D",
6909 "IP Information\n"
6910 "OSPF interface commands\n"
6911 "Disable mtu mismatch detection\n"
6912 "Address of interface")
6913{
6914 struct interface *ifp = vty->index;
6915 struct in_addr addr;
6916 int ret;
6917
6918 struct ospf_if_params *params;
6919 params = IF_DEF_PARAMS (ifp);
6920
6921 if (argc == 1)
6922 {
6923 ret = inet_aton(argv[0], &addr);
6924 if (!ret)
6925 {
6926 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6927 VTY_NEWLINE);
6928 return CMD_WARNING;
6929 }
6930 params = ospf_get_if_params (ifp, addr);
6931 ospf_if_update_params (ifp, addr);
6932 }
6933 params->mtu_ignore = 1;
6934 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6935 SET_IF_PARAM (params, mtu_ignore);
6936 else
6937 {
6938 UNSET_IF_PARAM (params, mtu_ignore);
6939 if (params != IF_DEF_PARAMS (ifp))
6940 {
6941 ospf_free_if_params (ifp, addr);
6942 ospf_if_update_params (ifp, addr);
6943 }
6944 }
6945 return CMD_SUCCESS;
6946}
6947
6948ALIAS (ip_ospf_mtu_ignore,
6949 ip_ospf_mtu_ignore_cmd,
6950 "ip ospf mtu-ignore",
6951 "IP Information\n"
6952 "OSPF interface commands\n"
6953 "Disable mtu mismatch detection\n")
6954
6955
6956DEFUN (no_ip_ospf_mtu_ignore,
6957 no_ip_ospf_mtu_ignore_addr_cmd,
6958 "no ip ospf mtu-ignore A.B.C.D",
6959 "IP Information\n"
6960 "OSPF interface commands\n"
6961 "Disable mtu mismatch detection\n"
6962 "Address of interface")
6963{
6964 struct interface *ifp = vty->index;
6965 struct in_addr addr;
6966 int ret;
6967
6968 struct ospf_if_params *params;
6969 params = IF_DEF_PARAMS (ifp);
6970
6971 if (argc == 1)
6972 {
6973 ret = inet_aton(argv[0], &addr);
6974 if (!ret)
6975 {
6976 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6977 VTY_NEWLINE);
6978 return CMD_WARNING;
6979 }
6980 params = ospf_get_if_params (ifp, addr);
6981 ospf_if_update_params (ifp, addr);
6982 }
6983 params->mtu_ignore = 0;
6984 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6985 SET_IF_PARAM (params, mtu_ignore);
6986 else
6987 {
6988 UNSET_IF_PARAM (params, mtu_ignore);
6989 if (params != IF_DEF_PARAMS (ifp))
6990 {
6991 ospf_free_if_params (ifp, addr);
6992 ospf_if_update_params (ifp, addr);
6993 }
6994 }
6995 return CMD_SUCCESS;
6996}
6997
6998ALIAS (no_ip_ospf_mtu_ignore,
6999 no_ip_ospf_mtu_ignore_cmd,
7000 "no ip ospf mtu-ignore",
7001 "IP Information\n"
7002 "OSPF interface commands\n"
7003 "Disable mtu mismatch detection\n")
paul88d6cf32005-10-29 12:50:09 +00007004
7005DEFUN (ospf_max_metric_router_lsa_admin,
7006 ospf_max_metric_router_lsa_admin_cmd,
7007 "max-metric router-lsa administrative",
7008 "OSPF maximum / infinite-distance metric\n"
7009 "Advertise own Router-LSA with infinite distance (stub router)\n"
7010 "Administratively applied, for an indefinite period\n")
7011{
7012 struct listnode *ln;
7013 struct ospf_area *area;
7014 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00007015
paul88d6cf32005-10-29 12:50:09 +00007016 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7017 {
7018 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7019
7020 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
Paul Jakmac363d382010-01-24 22:42:13 +00007021 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007022 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08007023
7024 /* Allows for areas configured later to get the property */
7025 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
7026
paul88d6cf32005-10-29 12:50:09 +00007027 return CMD_SUCCESS;
7028}
7029
7030DEFUN (no_ospf_max_metric_router_lsa_admin,
7031 no_ospf_max_metric_router_lsa_admin_cmd,
7032 "no max-metric router-lsa administrative",
7033 NO_STR
7034 "OSPF maximum / infinite-distance metric\n"
7035 "Advertise own Router-LSA with infinite distance (stub router)\n"
7036 "Administratively applied, for an indefinite period\n")
7037{
7038 struct listnode *ln;
7039 struct ospf_area *area;
7040 struct ospf *ospf = vty->index;
7041
7042 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7043 {
7044 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7045
7046 /* Don't trample on the start-up stub timer */
7047 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
7048 && !area->t_stub_router)
7049 {
7050 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00007051 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007052 }
7053 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08007054 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
paul88d6cf32005-10-29 12:50:09 +00007055 return CMD_SUCCESS;
7056}
7057
7058DEFUN (ospf_max_metric_router_lsa_startup,
7059 ospf_max_metric_router_lsa_startup_cmd,
7060 "max-metric router-lsa on-startup <5-86400>",
7061 "OSPF maximum / infinite-distance metric\n"
7062 "Advertise own Router-LSA with infinite distance (stub router)\n"
7063 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7064 "Time (seconds) to advertise self as stub-router\n")
7065{
7066 unsigned int seconds;
7067 struct ospf *ospf = vty->index;
7068
7069 if (argc != 1)
7070 {
7071 vty_out (vty, "%% Must supply stub-router period");
7072 return CMD_WARNING;
7073 }
7074
7075 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
7076
7077 ospf->stub_router_startup_time = seconds;
7078
7079 return CMD_SUCCESS;
7080}
7081
7082DEFUN (no_ospf_max_metric_router_lsa_startup,
7083 no_ospf_max_metric_router_lsa_startup_cmd,
7084 "no max-metric router-lsa on-startup",
7085 NO_STR
7086 "OSPF maximum / infinite-distance metric\n"
7087 "Advertise own Router-LSA with infinite distance (stub router)\n"
7088 "Automatically advertise stub Router-LSA on startup of OSPF\n")
7089{
7090 struct listnode *ln;
7091 struct ospf_area *area;
7092 struct ospf *ospf = vty->index;
7093
7094 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7095
7096 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7097 {
7098 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
7099 OSPF_TIMER_OFF (area->t_stub_router);
7100
7101 /* Don't trample on admin stub routed */
7102 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7103 {
7104 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00007105 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00007106 }
7107 }
7108 return CMD_SUCCESS;
7109}
7110
7111DEFUN (ospf_max_metric_router_lsa_shutdown,
7112 ospf_max_metric_router_lsa_shutdown_cmd,
7113 "max-metric router-lsa on-shutdown <5-86400>",
7114 "OSPF maximum / infinite-distance metric\n"
7115 "Advertise own Router-LSA with infinite distance (stub router)\n"
7116 "Advertise stub-router prior to full shutdown of OSPF\n"
7117 "Time (seconds) to wait till full shutdown\n")
7118{
7119 unsigned int seconds;
7120 struct ospf *ospf = vty->index;
7121
7122 if (argc != 1)
7123 {
7124 vty_out (vty, "%% Must supply stub-router shutdown period");
7125 return CMD_WARNING;
7126 }
7127
7128 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
7129
7130 ospf->stub_router_shutdown_time = seconds;
7131
7132 return CMD_SUCCESS;
7133}
7134
7135DEFUN (no_ospf_max_metric_router_lsa_shutdown,
7136 no_ospf_max_metric_router_lsa_shutdown_cmd,
7137 "no max-metric router-lsa on-shutdown",
7138 NO_STR
7139 "OSPF maximum / infinite-distance metric\n"
7140 "Advertise own Router-LSA with infinite distance (stub router)\n"
7141 "Advertise stub-router prior to full shutdown of OSPF\n")
7142{
7143 struct ospf *ospf = vty->index;
7144
7145 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7146
7147 return CMD_SUCCESS;
7148}
7149
7150static void
7151config_write_stub_router (struct vty *vty, struct ospf *ospf)
7152{
7153 struct listnode *ln;
7154 struct ospf_area *area;
7155
7156 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7157 vty_out (vty, " max-metric router-lsa on-startup %u%s",
7158 ospf->stub_router_startup_time, VTY_NEWLINE);
7159 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7160 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
7161 ospf->stub_router_shutdown_time, VTY_NEWLINE);
7162 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7163 {
7164 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7165 {
7166 vty_out (vty, " max-metric router-lsa administrative%s",
7167 VTY_NEWLINE);
7168 break;
7169 }
7170 }
7171 return;
7172}
7173
paul4dadc292005-05-06 21:37:42 +00007174static void
paul718e3742002-12-13 20:15:29 +00007175show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7176{
7177 struct route_node *rn;
7178 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007179 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007180 struct ospf_path *path;
7181
7182 vty_out (vty, "============ OSPF network routing table ============%s",
7183 VTY_NEWLINE);
7184
7185 for (rn = route_top (rt); rn; rn = route_next (rn))
7186 if ((or = rn->info) != NULL)
7187 {
7188 char buf1[19];
7189 snprintf (buf1, 19, "%s/%d",
7190 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7191
7192 switch (or->path_type)
7193 {
7194 case OSPF_PATH_INTER_AREA:
7195 if (or->type == OSPF_DESTINATION_NETWORK)
7196 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7197 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7198 else if (or->type == OSPF_DESTINATION_DISCARD)
7199 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7200 break;
7201 case OSPF_PATH_INTRA_AREA:
7202 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7203 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7204 break;
7205 default:
7206 break;
7207 }
7208
7209 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00007210 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00007211 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007212 if (if_lookup_by_index(path->ifindex))
paul96735ee2003-08-10 02:51:22 +00007213 {
7214 if (path->nexthop.s_addr == 0)
7215 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007216 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007217 else
7218 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007219 inet_ntoa (path->nexthop),
7220 ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007221 }
7222 }
paul718e3742002-12-13 20:15:29 +00007223 }
7224 vty_out (vty, "%s", VTY_NEWLINE);
7225}
7226
paul4dadc292005-05-06 21:37:42 +00007227static void
paul718e3742002-12-13 20:15:29 +00007228show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7229{
7230 struct route_node *rn;
7231 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00007232 struct listnode *pnode;
7233 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007234 struct ospf_path *path;
7235
7236 vty_out (vty, "============ OSPF router routing table =============%s",
7237 VTY_NEWLINE);
7238 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7239 if (rn->info)
7240 {
7241 int flag = 0;
7242
7243 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7244
paul1eb8ef22005-04-07 07:30:20 +00007245 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7246 {
7247 if (flag++)
7248 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00007249
paul1eb8ef22005-04-07 07:30:20 +00007250 /* Show path. */
7251 vty_out (vty, "%s [%d] area: %s",
7252 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7253 or->cost, inet_ntoa (or->u.std.area_id));
7254 /* Show flags. */
7255 vty_out (vty, "%s%s%s",
7256 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7257 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7258 VTY_NEWLINE);
7259
7260 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7261 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007262 if (if_lookup_by_index(path->ifindex))
hasso54bedb52005-08-17 13:31:47 +00007263 {
7264 if (path->nexthop.s_addr == 0)
7265 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007266 "", ifindex2ifname (path->ifindex),
7267 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007268 else
7269 vty_out (vty, "%24s via %s, %s%s", "",
7270 inet_ntoa (path->nexthop),
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007271 ifindex2ifname (path->ifindex),
7272 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00007273 }
paul1eb8ef22005-04-07 07:30:20 +00007274 }
7275 }
paul718e3742002-12-13 20:15:29 +00007276 }
7277 vty_out (vty, "%s", VTY_NEWLINE);
7278}
7279
paul4dadc292005-05-06 21:37:42 +00007280static void
paul718e3742002-12-13 20:15:29 +00007281show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7282{
7283 struct route_node *rn;
7284 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00007285 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00007286 struct ospf_path *path;
7287
7288 vty_out (vty, "============ OSPF external routing table ===========%s",
7289 VTY_NEWLINE);
7290 for (rn = route_top (rt); rn; rn = route_next (rn))
7291 if ((er = rn->info) != NULL)
7292 {
7293 char buf1[19];
7294 snprintf (buf1, 19, "%s/%d",
7295 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7296
7297 switch (er->path_type)
7298 {
7299 case OSPF_PATH_TYPE1_EXTERNAL:
7300 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7301 er->cost, er->u.ext.tag, VTY_NEWLINE);
7302 break;
7303 case OSPF_PATH_TYPE2_EXTERNAL:
7304 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7305 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7306 break;
7307 }
7308
paul1eb8ef22005-04-07 07:30:20 +00007309 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00007310 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007311 if (if_lookup_by_index(path->ifindex))
paul718e3742002-12-13 20:15:29 +00007312 {
7313 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00007314 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007315 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00007316 else
7317 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02007318 inet_ntoa (path->nexthop),
7319 ifindex2ifname (path->ifindex),
paul96735ee2003-08-10 02:51:22 +00007320 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007321 }
7322 }
7323 }
7324 vty_out (vty, "%s", VTY_NEWLINE);
7325}
7326
paul718e3742002-12-13 20:15:29 +00007327DEFUN (show_ip_ospf_border_routers,
7328 show_ip_ospf_border_routers_cmd,
7329 "show ip ospf border-routers",
7330 SHOW_STR
7331 IP_STR
7332 "show all the ABR's and ASBR's\n"
7333 "for this area\n")
7334{
paul020709f2003-04-04 02:44:16 +00007335 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007336
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007337 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007338 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007339 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007340 return CMD_SUCCESS;
7341 }
7342
paul68980082003-03-25 05:07:42 +00007343 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007344 {
7345 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7346 return CMD_SUCCESS;
7347 }
7348
7349 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00007350 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00007351
7352 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007353 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007354
7355 return CMD_SUCCESS;
7356}
paul718e3742002-12-13 20:15:29 +00007357
7358DEFUN (show_ip_ospf_route,
7359 show_ip_ospf_route_cmd,
7360 "show ip ospf route",
7361 SHOW_STR
7362 IP_STR
7363 "OSPF information\n"
7364 "OSPF routing table\n")
7365{
paul020709f2003-04-04 02:44:16 +00007366 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00007367
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007368 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00007369 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00007370 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007371 return CMD_SUCCESS;
7372 }
7373
paul68980082003-03-25 05:07:42 +00007374 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00007375 {
7376 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7377 return CMD_SUCCESS;
7378 }
7379
7380 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00007381 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00007382
7383 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00007384 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00007385
7386 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00007387 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00007388
7389 return CMD_SUCCESS;
7390}
7391
7392
hassoeb1ce602004-10-08 08:17:22 +00007393const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00007394{
7395 "unknown",
7396 "standard",
7397 "ibm",
7398 "cisco",
7399 "shortcut"
7400};
7401
hassoeb1ce602004-10-08 08:17:22 +00007402const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007403{
7404 "default",
7405 "enable",
7406 "disable"
7407};
7408
7409
paul4dadc292005-05-06 21:37:42 +00007410static void
paul718e3742002-12-13 20:15:29 +00007411area_id2str (char *buf, int length, struct ospf_area *area)
7412{
7413 memset (buf, 0, length);
7414
7415 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7416 strncpy (buf, inet_ntoa (area->area_id), length);
7417 else
7418 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7419}
7420
7421
hassoeb1ce602004-10-08 08:17:22 +00007422const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007423{
7424 "unknown", /* should never be used. */
7425 "point-to-point",
7426 "broadcast",
7427 "non-broadcast",
7428 "point-to-multipoint",
7429 "virtual-link", /* should never be used. */
7430 "loopback"
7431};
7432
7433/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007434static int
paul718e3742002-12-13 20:15:29 +00007435config_write_interface (struct vty *vty)
7436{
hasso52dc7ee2004-09-23 19:18:23 +00007437 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007438 struct interface *ifp;
7439 struct crypt_key *ck;
7440 int write = 0;
7441 struct route_node *rn = NULL;
7442 struct ospf_if_params *params;
7443
paul1eb8ef22005-04-07 07:30:20 +00007444 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007445 {
paul718e3742002-12-13 20:15:29 +00007446 if (memcmp (ifp->name, "VLINK", 5) == 0)
7447 continue;
7448
7449 vty_out (vty, "!%s", VTY_NEWLINE);
7450 vty_out (vty, "interface %s%s", ifp->name,
7451 VTY_NEWLINE);
7452 if (ifp->desc)
7453 vty_out (vty, " description %s%s", ifp->desc,
7454 VTY_NEWLINE);
7455
7456 write++;
7457
7458 params = IF_DEF_PARAMS (ifp);
7459
7460 do {
7461 /* Interface Network print. */
7462 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007463 params->type != OSPF_IFTYPE_LOOPBACK)
7464 {
ajsbc18d612004-12-15 15:07:19 +00007465 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007466 {
7467 vty_out (vty, " ip ospf network %s",
7468 ospf_int_type_str[params->type]);
7469 if (params != IF_DEF_PARAMS (ifp))
7470 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7471 vty_out (vty, "%s", VTY_NEWLINE);
7472 }
paul718e3742002-12-13 20:15:29 +00007473 }
7474
7475 /* OSPF interface authentication print */
7476 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7477 params->auth_type != OSPF_AUTH_NOTSET)
7478 {
hassoeb1ce602004-10-08 08:17:22 +00007479 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007480
7481 /* Translation tables are not that much help here due to syntax
7482 of the simple option */
7483 switch (params->auth_type)
7484 {
7485
7486 case OSPF_AUTH_NULL:
7487 auth_str = " null";
7488 break;
7489
7490 case OSPF_AUTH_SIMPLE:
7491 auth_str = "";
7492 break;
7493
7494 case OSPF_AUTH_CRYPTOGRAPHIC:
7495 auth_str = " message-digest";
7496 break;
7497
7498 default:
7499 auth_str = "";
7500 break;
7501 }
7502
7503 vty_out (vty, " ip ospf authentication%s", auth_str);
7504 if (params != IF_DEF_PARAMS (ifp))
7505 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7506 vty_out (vty, "%s", VTY_NEWLINE);
7507 }
7508
7509 /* Simple Authentication Password print. */
7510 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7511 params->auth_simple[0] != '\0')
7512 {
7513 vty_out (vty, " ip ospf authentication-key %s",
7514 params->auth_simple);
7515 if (params != IF_DEF_PARAMS (ifp))
7516 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7517 vty_out (vty, "%s", VTY_NEWLINE);
7518 }
7519
7520 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007521 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007522 {
paul718e3742002-12-13 20:15:29 +00007523 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7524 ck->key_id, ck->auth_key);
7525 if (params != IF_DEF_PARAMS (ifp))
7526 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7527 vty_out (vty, "%s", VTY_NEWLINE);
7528 }
7529
7530 /* Interface Output Cost print. */
7531 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7532 {
7533 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7534 if (params != IF_DEF_PARAMS (ifp))
7535 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7536 vty_out (vty, "%s", VTY_NEWLINE);
7537 }
7538
7539 /* Hello Interval print. */
7540 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7541 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7542 {
7543 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7544 if (params != IF_DEF_PARAMS (ifp))
7545 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7546 vty_out (vty, "%s", VTY_NEWLINE);
7547 }
7548
7549
7550 /* Router Dead Interval print. */
7551 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7552 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7553 {
paulf9ad9372005-10-21 00:45:17 +00007554 vty_out (vty, " ip ospf dead-interval ");
7555
7556 /* fast hello ? */
7557 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7558 vty_out (vty, "minimal hello-multiplier %d",
7559 params->fast_hello);
7560 else
7561 vty_out (vty, "%u", params->v_wait);
7562
paul718e3742002-12-13 20:15:29 +00007563 if (params != IF_DEF_PARAMS (ifp))
7564 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7565 vty_out (vty, "%s", VTY_NEWLINE);
7566 }
7567
7568 /* Router Priority print. */
7569 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7570 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7571 {
7572 vty_out (vty, " ip ospf priority %u", params->priority);
7573 if (params != IF_DEF_PARAMS (ifp))
7574 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7575 vty_out (vty, "%s", VTY_NEWLINE);
7576 }
7577
7578 /* Retransmit Interval print. */
7579 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7580 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7581 {
7582 vty_out (vty, " ip ospf retransmit-interval %u",
7583 params->retransmit_interval);
7584 if (params != IF_DEF_PARAMS (ifp))
7585 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7586 vty_out (vty, "%s", VTY_NEWLINE);
7587 }
7588
7589 /* Transmit Delay print. */
7590 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7591 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7592 {
7593 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7594 if (params != IF_DEF_PARAMS (ifp))
7595 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7596 vty_out (vty, "%s", VTY_NEWLINE);
7597 }
7598
vincentba682532005-09-29 13:52:57 +00007599 /* MTU ignore print. */
7600 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7601 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7602 {
7603 if (params->mtu_ignore == 0)
7604 vty_out (vty, " no ip ospf mtu-ignore");
7605 else
7606 vty_out (vty, " ip ospf mtu-ignore");
7607 if (params != IF_DEF_PARAMS (ifp))
7608 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7609 vty_out (vty, "%s", VTY_NEWLINE);
7610 }
7611
7612
paul718e3742002-12-13 20:15:29 +00007613 while (1)
7614 {
7615 if (rn == NULL)
7616 rn = route_top (IF_OIFS_PARAMS (ifp));
7617 else
7618 rn = route_next (rn);
7619
7620 if (rn == NULL)
7621 break;
7622 params = rn->info;
7623 if (params != NULL)
7624 break;
7625 }
7626 } while (rn);
7627
7628#ifdef HAVE_OPAQUE_LSA
7629 ospf_opaque_config_write_if (vty, ifp);
7630#endif /* HAVE_OPAQUE_LSA */
7631 }
7632
7633 return write;
7634}
7635
paul4dadc292005-05-06 21:37:42 +00007636static int
paul68980082003-03-25 05:07:42 +00007637config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007638{
7639 struct route_node *rn;
7640 u_char buf[INET_ADDRSTRLEN];
7641
7642 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007643 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007644 if (rn->info)
7645 {
7646 struct ospf_network *n = rn->info;
7647
7648 memset (buf, 0, INET_ADDRSTRLEN);
7649
7650 /* Create Area ID string by specified Area ID format. */
7651 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007652 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007653 else
hassoc9e52be2004-09-26 16:09:34 +00007654 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007655 (unsigned long int) ntohl (n->area_id.s_addr));
7656
7657 /* Network print. */
7658 vty_out (vty, " network %s/%d area %s%s",
7659 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7660 buf, VTY_NEWLINE);
7661 }
7662
7663 return 0;
7664}
7665
paul4dadc292005-05-06 21:37:42 +00007666static int
paul68980082003-03-25 05:07:42 +00007667config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007668{
hasso52dc7ee2004-09-23 19:18:23 +00007669 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007670 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007671 u_char buf[INET_ADDRSTRLEN];
7672
7673 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007674 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007675 {
paul718e3742002-12-13 20:15:29 +00007676 struct route_node *rn1;
7677
hassoc9e52be2004-09-26 16:09:34 +00007678 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007679
7680 if (area->auth_type != OSPF_AUTH_NULL)
7681 {
7682 if (area->auth_type == OSPF_AUTH_SIMPLE)
7683 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7684 else
7685 vty_out (vty, " area %s authentication message-digest%s",
7686 buf, VTY_NEWLINE);
7687 }
7688
7689 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7690 vty_out (vty, " area %s shortcut %s%s", buf,
7691 ospf_shortcut_mode_str[area->shortcut_configured],
7692 VTY_NEWLINE);
7693
7694 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007695 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007696 )
7697 {
paulb0a053b2003-06-22 09:04:47 +00007698 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007699 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007700 else if (area->external_routing == OSPF_AREA_NSSA)
7701 {
7702 vty_out (vty, " area %s nssa", buf);
7703 switch (area->NSSATranslatorRole)
7704 {
7705 case OSPF_NSSA_ROLE_NEVER:
7706 vty_out (vty, " translate-never");
7707 break;
7708 case OSPF_NSSA_ROLE_ALWAYS:
7709 vty_out (vty, " translate-always");
7710 break;
7711 case OSPF_NSSA_ROLE_CANDIDATE:
7712 default:
7713 vty_out (vty, " translate-candidate");
7714 }
7715 }
paul718e3742002-12-13 20:15:29 +00007716
7717 if (area->no_summary)
7718 vty_out (vty, " no-summary");
7719
7720 vty_out (vty, "%s", VTY_NEWLINE);
7721
7722 if (area->default_cost != 1)
7723 vty_out (vty, " area %s default-cost %d%s", buf,
7724 area->default_cost, VTY_NEWLINE);
7725 }
7726
7727 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7728 if (rn1->info)
7729 {
7730 struct ospf_area_range *range = rn1->info;
7731
7732 vty_out (vty, " area %s range %s/%d", buf,
7733 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7734
paul6c835672004-10-11 11:00:30 +00007735 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007736 vty_out (vty, " cost %d", range->cost_config);
7737
7738 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7739 vty_out (vty, " not-advertise");
7740
7741 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7742 vty_out (vty, " substitute %s/%d",
7743 inet_ntoa (range->subst_addr), range->subst_masklen);
7744
7745 vty_out (vty, "%s", VTY_NEWLINE);
7746 }
7747
7748 if (EXPORT_NAME (area))
7749 vty_out (vty, " area %s export-list %s%s", buf,
7750 EXPORT_NAME (area), VTY_NEWLINE);
7751
7752 if (IMPORT_NAME (area))
7753 vty_out (vty, " area %s import-list %s%s", buf,
7754 IMPORT_NAME (area), VTY_NEWLINE);
7755
7756 if (PREFIX_NAME_IN (area))
7757 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7758 PREFIX_NAME_IN (area), VTY_NEWLINE);
7759
7760 if (PREFIX_NAME_OUT (area))
7761 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7762 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7763 }
7764
7765 return 0;
7766}
7767
paul4dadc292005-05-06 21:37:42 +00007768static int
paul68980082003-03-25 05:07:42 +00007769config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007770{
7771 struct ospf_nbr_nbma *nbr_nbma;
7772 struct route_node *rn;
7773
7774 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007775 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007776 if ((nbr_nbma = rn->info))
7777 {
7778 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7779
7780 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7781 vty_out (vty, " priority %d", nbr_nbma->priority);
7782
7783 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7784 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7785
7786 vty_out (vty, "%s", VTY_NEWLINE);
7787 }
7788
7789 return 0;
7790}
7791
paul4dadc292005-05-06 21:37:42 +00007792static int
paul68980082003-03-25 05:07:42 +00007793config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007794{
hasso52dc7ee2004-09-23 19:18:23 +00007795 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007796 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007797 u_char buf[INET_ADDRSTRLEN];
7798
7799 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007800 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007801 {
hasso52dc7ee2004-09-23 19:18:23 +00007802 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007803 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007804 struct ospf_interface *oi;
7805
7806 if (vl_data != NULL)
7807 {
7808 memset (buf, 0, INET_ADDRSTRLEN);
7809
7810 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007811 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007812 else
hassoc9e52be2004-09-26 16:09:34 +00007813 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007814 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7815 oi = vl_data->vl_oi;
7816
7817 /* timers */
7818 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7819 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7820 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7821 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7822 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7823 buf,
7824 inet_ntoa (vl_data->vl_peer),
7825 OSPF_IF_PARAM (oi, v_hello),
7826 OSPF_IF_PARAM (oi, retransmit_interval),
7827 OSPF_IF_PARAM (oi, transmit_delay),
7828 OSPF_IF_PARAM (oi, v_wait),
7829 VTY_NEWLINE);
7830 else
7831 vty_out (vty, " area %s virtual-link %s%s", buf,
7832 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7833 /* Auth key */
7834 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7835 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7836 buf,
7837 inet_ntoa (vl_data->vl_peer),
7838 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7839 VTY_NEWLINE);
7840 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007841 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7842 n2, ck))
7843 vty_out (vty, " area %s virtual-link %s"
7844 " message-digest-key %d md5 %s%s",
7845 buf,
7846 inet_ntoa (vl_data->vl_peer),
7847 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007848
7849 }
7850 }
7851
7852 return 0;
7853}
7854
7855
paul4dadc292005-05-06 21:37:42 +00007856static int
paul68980082003-03-25 05:07:42 +00007857config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007858{
7859 int type;
7860
7861 /* redistribute print. */
7862 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7863 if (type != zclient->redist_default && zclient->redist[type])
7864 {
ajsf52d13c2005-10-01 17:38:06 +00007865 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007866 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007867 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007868
paul68980082003-03-25 05:07:42 +00007869 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007870 vty_out (vty, " metric-type 1");
7871
paul020709f2003-04-04 02:44:16 +00007872 if (ROUTEMAP_NAME (ospf, type))
7873 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007874
7875 vty_out (vty, "%s", VTY_NEWLINE);
7876 }
7877
7878 return 0;
7879}
7880
paul4dadc292005-05-06 21:37:42 +00007881static int
paul68980082003-03-25 05:07:42 +00007882config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007883{
paul68980082003-03-25 05:07:42 +00007884 if (ospf->default_metric != -1)
7885 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007886 VTY_NEWLINE);
7887 return 0;
7888}
7889
paul4dadc292005-05-06 21:37:42 +00007890static int
paul68980082003-03-25 05:07:42 +00007891config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007892{
7893 int type;
7894
paul68980082003-03-25 05:07:42 +00007895 if (ospf)
paul718e3742002-12-13 20:15:29 +00007896 {
7897 /* distribute-list print. */
7898 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007899 if (DISTRIBUTE_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +00007900 vty_out (vty, " distribute-list %s out %s%s",
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007901 DISTRIBUTE_NAME (ospf, type),
ajsf52d13c2005-10-01 17:38:06 +00007902 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007903
7904 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007905 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007906 {
paulc42c1772006-01-10 20:36:49 +00007907 vty_out (vty, " default-information originate");
7908 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7909 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007910
paul68980082003-03-25 05:07:42 +00007911 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007912 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007913 ospf->dmetric[DEFAULT_ROUTE].value);
7914 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007915 vty_out (vty, " metric-type 1");
7916
paul020709f2003-04-04 02:44:16 +00007917 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7918 vty_out (vty, " route-map %s",
7919 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007920
7921 vty_out (vty, "%s", VTY_NEWLINE);
7922 }
7923
7924 }
7925
7926 return 0;
7927}
7928
paul4dadc292005-05-06 21:37:42 +00007929static int
paul68980082003-03-25 05:07:42 +00007930config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007931{
7932 struct route_node *rn;
7933 struct ospf_distance *odistance;
7934
paul68980082003-03-25 05:07:42 +00007935 if (ospf->distance_all)
7936 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007937
paul68980082003-03-25 05:07:42 +00007938 if (ospf->distance_intra
7939 || ospf->distance_inter
7940 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007941 {
7942 vty_out (vty, " distance ospf");
7943
paul68980082003-03-25 05:07:42 +00007944 if (ospf->distance_intra)
7945 vty_out (vty, " intra-area %d", ospf->distance_intra);
7946 if (ospf->distance_inter)
7947 vty_out (vty, " inter-area %d", ospf->distance_inter);
7948 if (ospf->distance_external)
7949 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007950
7951 vty_out (vty, "%s", VTY_NEWLINE);
7952 }
7953
paul68980082003-03-25 05:07:42 +00007954 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007955 if ((odistance = rn->info) != NULL)
7956 {
7957 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7958 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7959 odistance->access_list ? odistance->access_list : "",
7960 VTY_NEWLINE);
7961 }
7962 return 0;
7963}
7964
7965/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007966static int
paul718e3742002-12-13 20:15:29 +00007967ospf_config_write (struct vty *vty)
7968{
paul020709f2003-04-04 02:44:16 +00007969 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007970 struct interface *ifp;
7971 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007972 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007973 int write = 0;
7974
paul020709f2003-04-04 02:44:16 +00007975 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007976 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007977 {
7978 /* `router ospf' print. */
7979 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7980
7981 write++;
7982
paul68980082003-03-25 05:07:42 +00007983 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007984 return write;
7985
7986 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007987 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007988 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007989 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007990
7991 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007992 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007993 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007994 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007995
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007996 /* log-adjacency-changes flag print. */
7997 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7998 {
7999 vty_out(vty, " log-adjacency-changes");
8000 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
8001 vty_out(vty, " detail");
8002 vty_out(vty, "%s", VTY_NEWLINE);
8003 }
8004
paul718e3742002-12-13 20:15:29 +00008005 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00008006 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00008007 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
8008
8009 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00008010 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00008011 {
8012 vty_out (vty, "! Important: ensure reference bandwidth "
8013 "is consistent across all routers%s", VTY_NEWLINE);
8014 vty_out (vty, " auto-cost reference-bandwidth %d%s",
8015 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
8016 }
paul718e3742002-12-13 20:15:29 +00008017
8018 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00008019 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00008020 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
8021 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
8022 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00008023 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00008024 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00008025
8026 /* Max-metric router-lsa print */
8027 config_write_stub_router (vty, ospf);
8028
paul718e3742002-12-13 20:15:29 +00008029 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00008030 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00008031 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00008032 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008033
8034 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00008035 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008036
8037 /* passive-interface print. */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008038 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
8039 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
8040
paul1eb8ef22005-04-07 07:30:20 +00008041 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008042 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
8043 && IF_DEF_PARAMS (ifp)->passive_interface !=
8044 ospf->passive_interface_default)
8045 {
8046 vty_out (vty, " %spassive-interface %s%s",
8047 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
8048 ifp->name, VTY_NEWLINE);
8049 }
paul1eb8ef22005-04-07 07:30:20 +00008050 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008051 {
8052 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
8053 continue;
8054 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
8055 passive_interface))
8056 {
8057 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
8058 continue;
8059 }
8060 else if (oi->params->passive_interface == ospf->passive_interface_default)
8061 continue;
8062
8063 vty_out (vty, " %spassive-interface %s %s%s",
8064 oi->params->passive_interface ? "" : "no ",
paul1eb8ef22005-04-07 07:30:20 +00008065 oi->ifp->name,
8066 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008067 }
paul718e3742002-12-13 20:15:29 +00008068
8069 /* Network area print. */
paul68980082003-03-25 05:07:42 +00008070 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008071
8072 /* Area config print. */
paul68980082003-03-25 05:07:42 +00008073 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008074
8075 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00008076 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008077
8078 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00008079 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008080
8081 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00008082 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008083
8084 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00008085 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008086
8087 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00008088 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008089
8090#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00008091 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00008092#endif /* HAVE_OPAQUE_LSA */
8093 }
8094
8095 return write;
8096}
8097
8098void
paul4dadc292005-05-06 21:37:42 +00008099ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00008100{
8101 /* "show ip ospf" commands. */
8102 install_element (VIEW_NODE, &show_ip_ospf_cmd);
8103 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
8104
8105 /* "show ip ospf database" commands. */
8106 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
8107 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
8108 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8109 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8110 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
8111 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
8112 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
8113 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
8114 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
8115 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8116 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8117 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
8118 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
8119 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
8120
8121 /* "show ip ospf interface" commands. */
8122 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
8123 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
8124
8125 /* "show ip ospf neighbor" commands. */
8126 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8127 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
8128 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
8129 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8130 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
8131 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
8132 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
8133 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8134 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
8135 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
8136 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8137 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
8138 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
8139 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
8140
8141 /* "show ip ospf route" commands. */
8142 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
8143 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00008144 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
8145 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00008146}
8147
8148
8149/* ospfd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008150static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00008151{
8152 INTERFACE_NODE,
8153 "%s(config-if)# ",
8154 1
8155};
8156
8157/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00008158static void
8159ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00008160{
8161 /* Install interface node. */
8162 install_node (&interface_node, config_write_interface);
8163
8164 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00008165 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00008166 install_default (INTERFACE_NODE);
8167
8168 /* "description" commands. */
8169 install_element (INTERFACE_NODE, &interface_desc_cmd);
8170 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
8171
8172 /* "ip ospf authentication" commands. */
8173 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
8174 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
8175 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
8176 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
8177 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
8178 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
8179 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
8180 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
8181 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
8182 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
8183
8184 /* "ip ospf message-digest-key" commands. */
8185 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
8186 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
8187 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8188 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8189
8190 /* "ip ospf cost" commands. */
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008191 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
8192 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008193 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
8194 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008195 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008196 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8197
vincentba682532005-09-29 13:52:57 +00008198 /* "ip ospf mtu-ignore" commands. */
8199 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8200 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8201 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8202 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8203
paul718e3742002-12-13 20:15:29 +00008204 /* "ip ospf dead-interval" commands. */
8205 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8206 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008207 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8208 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00008209 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8210 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00008211
paul718e3742002-12-13 20:15:29 +00008212 /* "ip ospf hello-interval" commands. */
8213 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8214 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8215 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8216 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8217
8218 /* "ip ospf network" commands. */
8219 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8220 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8221
8222 /* "ip ospf priority" commands. */
8223 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8224 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8225 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8226 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8227
8228 /* "ip ospf retransmit-interval" commands. */
8229 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8230 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8231 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8232 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8233
8234 /* "ip ospf transmit-delay" commands. */
8235 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8236 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8237 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8238 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8239
8240 /* These commands are compatibitliy for previous version. */
8241 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8242 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8243 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8244 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008245 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
8246 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008247 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04008248 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
8249 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04008250 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00008251 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8252 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8253 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8254 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8255 install_element (INTERFACE_NODE, &ospf_network_cmd);
8256 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8257 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8258 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8259 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8260 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8261 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8262 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8263}
8264
paul4dadc292005-05-06 21:37:42 +00008265static void
8266ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00008267{
8268 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8269 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8270 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8271 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8272 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8273 install_element (OSPF_NODE,
8274 &ospf_redistribute_source_metric_type_routemap_cmd);
8275 install_element (OSPF_NODE,
8276 &ospf_redistribute_source_type_metric_routemap_cmd);
8277 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8278 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8279 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8280
8281 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8282
8283 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8284 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8285
8286 install_element (OSPF_NODE,
8287 &ospf_default_information_originate_metric_type_cmd);
8288 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8289 install_element (OSPF_NODE,
8290 &ospf_default_information_originate_type_metric_cmd);
8291 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8292 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8293 install_element (OSPF_NODE,
8294 &ospf_default_information_originate_always_metric_type_cmd);
8295 install_element (OSPF_NODE,
8296 &ospf_default_information_originate_always_metric_cmd);
8297 install_element (OSPF_NODE,
8298 &ospf_default_information_originate_always_cmd);
8299 install_element (OSPF_NODE,
8300 &ospf_default_information_originate_always_type_metric_cmd);
8301 install_element (OSPF_NODE,
8302 &ospf_default_information_originate_always_type_cmd);
8303
8304 install_element (OSPF_NODE,
8305 &ospf_default_information_originate_metric_type_routemap_cmd);
8306 install_element (OSPF_NODE,
8307 &ospf_default_information_originate_metric_routemap_cmd);
8308 install_element (OSPF_NODE,
8309 &ospf_default_information_originate_routemap_cmd);
8310 install_element (OSPF_NODE,
8311 &ospf_default_information_originate_type_metric_routemap_cmd);
8312 install_element (OSPF_NODE,
8313 &ospf_default_information_originate_type_routemap_cmd);
8314 install_element (OSPF_NODE,
8315 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8316 install_element (OSPF_NODE,
8317 &ospf_default_information_originate_always_metric_routemap_cmd);
8318 install_element (OSPF_NODE,
8319 &ospf_default_information_originate_always_routemap_cmd);
8320 install_element (OSPF_NODE,
8321 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8322 install_element (OSPF_NODE,
8323 &ospf_default_information_originate_always_type_routemap_cmd);
8324
8325 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8326
8327 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8328 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8329 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8330
8331 install_element (OSPF_NODE, &ospf_distance_cmd);
8332 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8333 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8334 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8335 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8336 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8337 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8338 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8339 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8340 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8341 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8342 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8343 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8344 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8345 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8346 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8347 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8348 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8349#if 0
8350 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8351 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8352 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8353 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8354#endif /* 0 */
8355}
8356
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08008357static struct cmd_node ospf_node =
paul718e3742002-12-13 20:15:29 +00008358{
8359 OSPF_NODE,
8360 "%s(config-router)# ",
8361 1
8362};
8363
8364
8365/* Install OSPF related vty commands. */
8366void
paul4dadc292005-05-06 21:37:42 +00008367ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00008368{
8369 /* Install ospf top node. */
8370 install_node (&ospf_node, ospf_config_write);
8371
8372 /* "router ospf" commands. */
8373 install_element (CONFIG_NODE, &router_ospf_cmd);
8374 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8375
8376 install_default (OSPF_NODE);
8377
8378 /* "ospf router-id" commands. */
8379 install_element (OSPF_NODE, &ospf_router_id_cmd);
8380 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00008381 install_element (OSPF_NODE, &router_ospf_id_cmd);
8382 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00008383
8384 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00008385 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8386 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008387 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
paula2c62832003-04-23 17:01:31 +00008388 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8389 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00008390 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
paul718e3742002-12-13 20:15:29 +00008391
8392 /* "ospf abr-type" commands. */
8393 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8394 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8395
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00008396 /* "ospf log-adjacency-changes" commands. */
8397 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8398 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8399 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8400 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8401
paul718e3742002-12-13 20:15:29 +00008402 /* "ospf rfc1583-compatible" commands. */
8403 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8404 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8405 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8406 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8407
8408 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00008409 install_element (OSPF_NODE, &ospf_network_area_cmd);
8410 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00008411
8412 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00008413 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8414 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8415 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00008416
8417 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00008418 install_element (OSPF_NODE, &ospf_area_range_cmd);
8419 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8420 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8421 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8422 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8423 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8424 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8425 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8426 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8427 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8428 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00008429
8430 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00008431 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8432 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00008433
paula2c62832003-04-23 17:01:31 +00008434 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8435 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00008436
paula2c62832003-04-23 17:01:31 +00008437 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8438 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008439
paula2c62832003-04-23 17:01:31 +00008440 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8441 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008442
paula2c62832003-04-23 17:01:31 +00008443 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8444 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008445
paula2c62832003-04-23 17:01:31 +00008446 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8447 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8448 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008449
paula2c62832003-04-23 17:01:31 +00008450 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8451 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008452
paula2c62832003-04-23 17:01:31 +00008453 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8454 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008455
paula2c62832003-04-23 17:01:31 +00008456 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8457 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8458 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008459
paula2c62832003-04-23 17:01:31 +00008460 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8461 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8462 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008463
8464 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008465 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8466 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8467 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8468 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008469
paul718e3742002-12-13 20:15:29 +00008470 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008471 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8472 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8473 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8474 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8475 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8476 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008477
paula2c62832003-04-23 17:01:31 +00008478 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8479 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008480
paula2c62832003-04-23 17:01:31 +00008481 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8482 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008483
paula2c62832003-04-23 17:01:31 +00008484 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8485 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008486
paula2c62832003-04-23 17:01:31 +00008487 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8488 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008489
paula2c62832003-04-23 17:01:31 +00008490 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8491 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00008492
8493 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00008494 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8495 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008496 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8497 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8498
paul88d6cf32005-10-29 12:50:09 +00008499 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00008500 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8501 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8502 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008503
paul88d6cf32005-10-29 12:50:09 +00008504 /* max-metric commands */
8505 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8506 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8507 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8508 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8509 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8510 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8511
8512 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00008513 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8514 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008515
8516 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008517 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8518 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8519 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8520 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8521 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8522 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8523 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8524 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008525
8526 /* Init interface related vty commands. */
8527 ospf_vty_if_init ();
8528
8529 /* Init zebra related vty commands. */
8530 ospf_vty_zebra_init ();
8531}