blob: 2115b987f25426085a06cde9d86cba67fc6484ea [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
hassoeb1ce602004-10-08 08:17:22 +000053const static char *ospf_network_type_str[] =
paul718e3742002-12-13 20:15:29 +000054{
55 "Null",
56 "POINTOPOINT",
57 "BROADCAST",
58 "NBMA",
59 "POINTOMULTIPOINT",
60 "VIRTUALLINK",
61 "LOOPBACK"
62};
63
64
65/* Utility functions. */
paul4dadc292005-05-06 21:37:42 +000066static int
paul6c835672004-10-11 11:00:30 +000067ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
paul718e3742002-12-13 20:15:29 +000068{
69 char *endptr = NULL;
70 unsigned long ret;
71
72 /* match "A.B.C.D". */
73 if (strchr (str, '.') != NULL)
74 {
75 ret = inet_aton (str, area_id);
76 if (!ret)
77 return -1;
78 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
79 }
80 /* match "<0-4294967295>". */
81 else
82 {
83 ret = strtoul (str, &endptr, 10);
84 if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE))
85 return -1;
86
87 area_id->s_addr = htonl (ret);
88 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
89 }
90
91 return 0;
92}
93
94
paul4dadc292005-05-06 21:37:42 +000095static int
paul6c835672004-10-11 11:00:30 +000096str2distribute_source (const char *str, int *source)
paul718e3742002-12-13 20:15:29 +000097{
98 /* Sanity check. */
99 if (str == NULL)
100 return 0;
101
102 if (strncmp (str, "k", 1) == 0)
103 *source = ZEBRA_ROUTE_KERNEL;
104 else if (strncmp (str, "c", 1) == 0)
105 *source = ZEBRA_ROUTE_CONNECT;
106 else if (strncmp (str, "s", 1) == 0)
107 *source = ZEBRA_ROUTE_STATIC;
108 else if (strncmp (str, "r", 1) == 0)
109 *source = ZEBRA_ROUTE_RIP;
110 else if (strncmp (str, "b", 1) == 0)
111 *source = ZEBRA_ROUTE_BGP;
112 else
113 return 0;
114
115 return 1;
116}
117
paul4dadc292005-05-06 21:37:42 +0000118static int
paul6c835672004-10-11 11:00:30 +0000119str2metric (const char *str, int *metric)
paul718e3742002-12-13 20:15:29 +0000120{
121 /* Sanity check. */
122 if (str == NULL)
123 return 0;
124
125 *metric = strtol (str, NULL, 10);
126 if (*metric < 0 && *metric > 16777214)
127 {
128 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
129 return 0;
130 }
131
132 return 1;
133}
134
paul4dadc292005-05-06 21:37:42 +0000135static int
paul6c835672004-10-11 11:00:30 +0000136str2metric_type (const char *str, int *metric_type)
paul718e3742002-12-13 20:15:29 +0000137{
138 /* Sanity check. */
139 if (str == NULL)
140 return 0;
141
142 if (strncmp (str, "1", 1) == 0)
143 *metric_type = EXTERNAL_METRIC_TYPE_1;
144 else if (strncmp (str, "2", 1) == 0)
145 *metric_type = EXTERNAL_METRIC_TYPE_2;
146 else
147 return 0;
148
149 return 1;
150}
151
152int
153ospf_oi_count (struct interface *ifp)
154{
155 struct route_node *rn;
156 int i = 0;
157
158 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
159 if (rn->info)
160 i++;
161
162 return i;
163}
164
165
166DEFUN (router_ospf,
167 router_ospf_cmd,
168 "router ospf",
169 "Enable a routing process\n"
170 "Start OSPF configuration\n")
171{
172 vty->node = OSPF_NODE;
173 vty->index = ospf_get ();
174
175 return CMD_SUCCESS;
176}
177
178DEFUN (no_router_ospf,
179 no_router_ospf_cmd,
180 "no router ospf",
181 NO_STR
182 "Enable a routing process\n"
183 "Start OSPF configuration\n")
184{
paul020709f2003-04-04 02:44:16 +0000185 struct ospf *ospf;
186
187 ospf = ospf_lookup ();
188 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000189 {
paul020709f2003-04-04 02:44:16 +0000190 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000191 return CMD_WARNING;
192 }
193
paul020709f2003-04-04 02:44:16 +0000194 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000195
196 return CMD_SUCCESS;
197}
198
199DEFUN (ospf_router_id,
200 ospf_router_id_cmd,
201 "ospf router-id A.B.C.D",
202 "OSPF specific commands\n"
203 "router-id for the OSPF process\n"
204 "OSPF router-id in IP address format\n")
205{
paul68980082003-03-25 05:07:42 +0000206 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000207 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000208 int ret;
paul718e3742002-12-13 20:15:29 +0000209
210 ret = inet_aton (argv[0], &router_id);
211 if (!ret)
212 {
213 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
214 return CMD_WARNING;
215 }
216
paul68980082003-03-25 05:07:42 +0000217 ospf->router_id_static = router_id;
paul718e3742002-12-13 20:15:29 +0000218
paul68980082003-03-25 05:07:42 +0000219 if (ospf->t_router_id_update == NULL)
paul020709f2003-04-04 02:44:16 +0000220 OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer,
221 OSPF_ROUTER_ID_UPDATE_DELAY);
paul718e3742002-12-13 20:15:29 +0000222
223 return CMD_SUCCESS;
224}
225
226ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000227 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000228 "router-id A.B.C.D",
229 "router-id for the OSPF process\n"
230 "OSPF router-id in IP address format\n")
231
232DEFUN (no_ospf_router_id,
233 no_ospf_router_id_cmd,
234 "no ospf router-id",
235 NO_STR
236 "OSPF specific commands\n"
237 "router-id for the OSPF process\n")
238{
paul68980082003-03-25 05:07:42 +0000239 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000240
paul68980082003-03-25 05:07:42 +0000241 ospf->router_id_static.s_addr = 0;
242
243 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000244
245 return CMD_SUCCESS;
246}
247
248ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000249 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000250 "no router-id",
251 NO_STR
252 "router-id for the OSPF process\n")
253
paula2c62832003-04-23 17:01:31 +0000254DEFUN (ospf_passive_interface,
255 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000256 "passive-interface IFNAME A.B.C.D",
257 "Suppress routing updates on an interface\n"
258 "Interface's name\n")
259{
260 struct interface *ifp;
261 struct in_addr addr;
262 int ret;
263 struct ospf_if_params *params;
ajsba6454e2005-02-08 15:37:30 +0000264 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000265
266 ifp = if_lookup_by_name (argv[0]);
267
268 if (ifp == NULL)
269 {
270 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
271 return CMD_WARNING;
272 }
273
274 params = IF_DEF_PARAMS (ifp);
275
276 if (argc == 2)
277 {
278 ret = inet_aton(argv[1], &addr);
279 if (!ret)
280 {
281 vty_out (vty, "Please specify interface address by A.B.C.D%s",
282 VTY_NEWLINE);
283 return CMD_WARNING;
284 }
285
286 params = ospf_get_if_params (ifp, addr);
287 ospf_if_update_params (ifp, addr);
288 }
289
290 SET_IF_PARAM (params, passive_interface);
291 params->passive_interface = OSPF_IF_PASSIVE;
ajsba6454e2005-02-08 15:37:30 +0000292
293 /* XXX We should call ospf_if_set_multicast on exactly those
294 * interfaces for which the passive property changed. It is too much
295 * work to determine this set, so we do this for every interface.
296 * This is safe and reasonable because ospf_if_set_multicast uses a
297 * record of joined groups to avoid systems calls if the desired
298 * memberships match the current memership.
299 */
300 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
301 {
302 struct ospf_interface *oi = rn->info;
303
304 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
305 ospf_if_set_multicast(oi);
306 }
307 /*
308 * XXX It is not clear what state transitions the interface needs to
309 * undergo when going from active to passive. Fixing this will
310 * require precise identification of interfaces having such a
311 * transition.
312 */
313
paul718e3742002-12-13 20:15:29 +0000314 return CMD_SUCCESS;
315}
316
paula2c62832003-04-23 17:01:31 +0000317ALIAS (ospf_passive_interface,
318 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000319 "passive-interface IFNAME",
320 "Suppress routing updates on an interface\n"
321 "Interface's name\n")
322
paula2c62832003-04-23 17:01:31 +0000323DEFUN (no_ospf_passive_interface,
324 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000325 "no passive-interface IFNAME A.B.C.D",
326 NO_STR
327 "Allow routing updates on an interface\n"
328 "Interface's name\n")
329{
330 struct interface *ifp;
331 struct in_addr addr;
332 struct ospf_if_params *params;
333 int ret;
ajsba6454e2005-02-08 15:37:30 +0000334 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000335
336 ifp = if_lookup_by_name (argv[0]);
337
338 if (ifp == NULL)
339 {
340 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
341 return CMD_WARNING;
342 }
343
344 params = IF_DEF_PARAMS (ifp);
345
346 if (argc == 2)
347 {
348 ret = inet_aton(argv[1], &addr);
349 if (!ret)
350 {
351 vty_out (vty, "Please specify interface address by A.B.C.D%s",
352 VTY_NEWLINE);
353 return CMD_WARNING;
354 }
355
356 params = ospf_lookup_if_params (ifp, addr);
357 if (params == NULL)
358 return CMD_SUCCESS;
359 }
360
361 UNSET_IF_PARAM (params, passive_interface);
362 params->passive_interface = OSPF_IF_ACTIVE;
363
364 if (params != IF_DEF_PARAMS (ifp))
365 {
366 ospf_free_if_params (ifp, addr);
367 ospf_if_update_params (ifp, addr);
368 }
ajsba6454e2005-02-08 15:37:30 +0000369
370 /* XXX We should call ospf_if_set_multicast on exactly those
371 * interfaces for which the passive property changed. It is too much
372 * work to determine this set, so we do this for every interface.
373 * This is safe and reasonable because ospf_if_set_multicast uses a
374 * record of joined groups to avoid systems calls if the desired
375 * memberships match the current memership.
376 */
377 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
378 {
379 struct ospf_interface *oi = rn->info;
380
381 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
382 ospf_if_set_multicast(oi);
383 }
384
paul718e3742002-12-13 20:15:29 +0000385 return CMD_SUCCESS;
386}
387
paula2c62832003-04-23 17:01:31 +0000388ALIAS (no_ospf_passive_interface,
389 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000390 "no passive-interface IFNAME",
391 NO_STR
392 "Allow routing updates on an interface\n"
393 "Interface's name\n")
394
paula2c62832003-04-23 17:01:31 +0000395DEFUN (ospf_network_area,
396 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000397 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
398 "Enable routing on an IP network\n"
399 "OSPF network prefix\n"
400 "Set the OSPF area ID\n"
401 "OSPF area ID in IP address format\n"
402 "OSPF area ID as a decimal value\n")
403{
404 struct ospf *ospf= vty->index;
405 struct prefix_ipv4 p;
406 struct in_addr area_id;
407 int ret, format;
408
409 /* Get network prefix and Area ID. */
410 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
411 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
412
413 ret = ospf_network_set (ospf, &p, area_id);
414 if (ret == 0)
415 {
416 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
417 return CMD_WARNING;
418 }
419
420 return CMD_SUCCESS;
421}
422
paula2c62832003-04-23 17:01:31 +0000423DEFUN (no_ospf_network_area,
424 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000425 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
426 NO_STR
427 "Enable routing on an IP network\n"
428 "OSPF network prefix\n"
429 "Set the OSPF area ID\n"
430 "OSPF area ID in IP address format\n"
431 "OSPF area ID as a decimal value\n")
432{
433 struct ospf *ospf = (struct ospf *) vty->index;
434 struct prefix_ipv4 p;
435 struct in_addr area_id;
436 int ret, format;
437
438 /* Get network prefix and Area ID. */
439 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
440 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
441
442 ret = ospf_network_unset (ospf, &p, area_id);
443 if (ret == 0)
444 {
445 vty_out (vty, "Can't find specified network area configuration.%s",
446 VTY_NEWLINE);
447 return CMD_WARNING;
448 }
449
450 return CMD_SUCCESS;
451}
452
453
paula2c62832003-04-23 17:01:31 +0000454DEFUN (ospf_area_range,
455 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000456 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
457 "OSPF area parameters\n"
458 "OSPF area ID in IP address format\n"
459 "OSPF area ID as a decimal value\n"
460 "Summarize routes matching address/mask (border routers only)\n"
461 "Area range prefix\n")
462{
463 struct ospf *ospf = vty->index;
464 struct prefix_ipv4 p;
465 struct in_addr area_id;
466 int format;
467 u_int32_t cost;
468
469 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
470 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
471
472 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
473 if (argc > 2)
474 {
paul4dadc292005-05-06 21:37:42 +0000475 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000476 ospf_area_range_cost_set (ospf, area_id, &p, cost);
477 }
478
479 return CMD_SUCCESS;
480}
481
paula2c62832003-04-23 17:01:31 +0000482ALIAS (ospf_area_range,
483 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000484 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
485 "OSPF area parameters\n"
486 "OSPF area ID in IP address format\n"
487 "OSPF area ID as a decimal value\n"
488 "OSPF area range for route advertise (default)\n"
489 "Area range prefix\n"
490 "Advertise this range (default)\n")
491
paula2c62832003-04-23 17:01:31 +0000492ALIAS (ospf_area_range,
493 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000494 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
495 "OSPF area parameters\n"
496 "OSPF area ID in IP address format\n"
497 "OSPF area ID as a decimal value\n"
498 "Summarize routes matching address/mask (border routers only)\n"
499 "Area range prefix\n"
500 "User specified metric for this range\n"
501 "Advertised metric for this range\n")
502
paula2c62832003-04-23 17:01:31 +0000503ALIAS (ospf_area_range,
504 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000505 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
506 "OSPF area parameters\n"
507 "OSPF area ID in IP address format\n"
508 "OSPF area ID as a decimal value\n"
509 "Summarize routes matching address/mask (border routers only)\n"
510 "Area range prefix\n"
511 "Advertise this range (default)\n"
512 "User specified metric for this range\n"
513 "Advertised metric for this range\n")
514
paula2c62832003-04-23 17:01:31 +0000515DEFUN (ospf_area_range_not_advertise,
516 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000517 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
518 "OSPF area parameters\n"
519 "OSPF area ID in IP address format\n"
520 "OSPF area ID as a decimal value\n"
521 "Summarize routes matching address/mask (border routers only)\n"
522 "Area range prefix\n"
523 "DoNotAdvertise this range\n")
524{
525 struct ospf *ospf = vty->index;
526 struct prefix_ipv4 p;
527 struct in_addr area_id;
528 int format;
529
530 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
531 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
532
533 ospf_area_range_set (ospf, area_id, &p, 0);
534
535 return CMD_SUCCESS;
536}
537
paula2c62832003-04-23 17:01:31 +0000538DEFUN (no_ospf_area_range,
539 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000540 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
541 NO_STR
542 "OSPF area parameters\n"
543 "OSPF area ID in IP address format\n"
544 "OSPF area ID as a decimal value\n"
545 "Summarize routes matching address/mask (border routers only)\n"
546 "Area range prefix\n")
547{
548 struct ospf *ospf = vty->index;
549 struct prefix_ipv4 p;
550 struct in_addr area_id;
551 int format;
552
553 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
554 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
555
556 ospf_area_range_unset (ospf, area_id, &p);
557
558 return CMD_SUCCESS;
559}
560
paula2c62832003-04-23 17:01:31 +0000561ALIAS (no_ospf_area_range,
562 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000563 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
564 NO_STR
565 "OSPF area parameters\n"
566 "OSPF area ID in IP address format\n"
567 "OSPF area ID as a decimal value\n"
568 "Summarize routes matching address/mask (border routers only)\n"
569 "Area range prefix\n"
570 "Advertise this range (default)\n"
571 "DoNotAdvertise this range\n")
572
paula2c62832003-04-23 17:01:31 +0000573ALIAS (no_ospf_area_range,
574 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000575 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
576 NO_STR
577 "OSPF area parameters\n"
578 "OSPF area ID in IP address format\n"
579 "OSPF area ID as a decimal value\n"
580 "Summarize routes matching address/mask (border routers only)\n"
581 "Area range prefix\n"
582 "User specified metric for this range\n"
583 "Advertised metric for this range\n")
584
paula2c62832003-04-23 17:01:31 +0000585ALIAS (no_ospf_area_range,
586 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000587 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
588 NO_STR
589 "OSPF area parameters\n"
590 "OSPF area ID in IP address format\n"
591 "OSPF area ID as a decimal value\n"
592 "Summarize routes matching address/mask (border routers only)\n"
593 "Area range prefix\n"
594 "Advertise this range (default)\n"
595 "User specified metric for this range\n"
596 "Advertised metric for this range\n")
597
paula2c62832003-04-23 17:01:31 +0000598DEFUN (ospf_area_range_substitute,
599 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000600 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
601 "OSPF area parameters\n"
602 "OSPF area ID in IP address format\n"
603 "OSPF area ID as a decimal value\n"
604 "Summarize routes matching address/mask (border routers only)\n"
605 "Area range prefix\n"
606 "Announce area range as another prefix\n"
607 "Network prefix to be announced instead of range\n")
608{
609 struct ospf *ospf = vty->index;
610 struct prefix_ipv4 p, s;
611 struct in_addr area_id;
612 int format;
613
614 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
615 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
616 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
617
618 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
619
620 return CMD_SUCCESS;
621}
622
paula2c62832003-04-23 17:01:31 +0000623DEFUN (no_ospf_area_range_substitute,
624 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000625 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
626 NO_STR
627 "OSPF area parameters\n"
628 "OSPF area ID in IP address format\n"
629 "OSPF area ID as a decimal value\n"
630 "Summarize routes matching address/mask (border routers only)\n"
631 "Area range prefix\n"
632 "Announce area range as another prefix\n"
633 "Network prefix to be announced instead of range\n")
634{
635 struct ospf *ospf = vty->index;
636 struct prefix_ipv4 p, s;
637 struct in_addr area_id;
638 int format;
639
640 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
641 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
642 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
643
644 ospf_area_range_substitute_unset (ospf, area_id, &p);
645
646 return CMD_SUCCESS;
647}
648
649
650/* Command Handler Logic in VLink stuff is delicate!!
651
652 ALTER AT YOUR OWN RISK!!!!
653
654 Various dummy values are used to represent 'NoChange' state for
655 VLink configuration NOT being changed by a VLink command, and
656 special syntax is used within the command strings so that the
657 typed in command verbs can be seen in the configuration command
658 bacckend handler. This is to drastically reduce the verbeage
659 required to coe up with a reasonably compatible Cisco VLink command
660
661 - Matthew Grant <grantma@anathoth.gen.nz>
662 Wed, 21 Feb 2001 15:13:52 +1300
663 */
664
665
666/* Configuration data for virtual links
667 */
668struct ospf_vl_config_data {
669 struct vty *vty; /* vty stuff */
670 struct in_addr area_id; /* area ID from command line */
671 int format; /* command line area ID format */
672 struct in_addr vl_peer; /* command line vl_peer */
673 int auth_type; /* Authehntication type, if given */
674 char *auth_key; /* simple password if present */
675 int crypto_key_id; /* Cryptographic key ID */
676 char *md5_key; /* MD5 authentication key */
677 int hello_interval; /* Obvious what these are... */
678 int retransmit_interval;
679 int transmit_delay;
680 int dead_interval;
681};
682
paul4dadc292005-05-06 21:37:42 +0000683static void
paul718e3742002-12-13 20:15:29 +0000684ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
685 struct vty *vty)
686{
687 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
688 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
689 vl_config->vty = vty;
690}
691
paul4dadc292005-05-06 21:37:42 +0000692static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000693ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000694{
695 struct ospf_area *area;
696 struct ospf_vl_data *vl_data;
697 struct vty *vty;
698 struct in_addr area_id;
699
700 vty = vl_config->vty;
701 area_id = vl_config->area_id;
702
703 if (area_id.s_addr == OSPF_AREA_BACKBONE)
704 {
705 vty_out (vty,
706 "Configuring VLs over the backbone is not allowed%s",
707 VTY_NEWLINE);
708 return NULL;
709 }
paul68980082003-03-25 05:07:42 +0000710 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000711
712 if (area->external_routing != OSPF_AREA_DEFAULT)
713 {
714 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
715 vty_out (vty, "Area %s is %s%s",
716 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000717 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000718 VTY_NEWLINE);
719 else
720 vty_out (vty, "Area %ld is %s%s",
721 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000722 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000723 VTY_NEWLINE);
724 return NULL;
725 }
726
727 if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)
728 {
729 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
730 if (vl_data->vl_oi == NULL)
731 {
paul68980082003-03-25 05:07:42 +0000732 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
733 ospf_vl_add (ospf, vl_data);
734 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000735 }
736 }
737 return vl_data;
738}
739
740
paul4dadc292005-05-06 21:37:42 +0000741static int
paul718e3742002-12-13 20:15:29 +0000742ospf_vl_set_security (struct ospf_vl_data *vl_data,
743 struct ospf_vl_config_data *vl_config)
744{
745 struct crypt_key *ck;
746 struct vty *vty;
747 struct interface *ifp = vl_data->vl_oi->ifp;
748
749 vty = vl_config->vty;
750
751 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
752 {
753 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
754 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
755 }
756
757 if (vl_config->auth_key)
758 {
759 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000760 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000761 OSPF_AUTH_SIMPLE_SIZE);
762 }
763 else if (vl_config->md5_key)
764 {
765 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
766 != NULL)
767 {
768 vty_out (vty, "OSPF: Key %d already exists%s",
769 vl_config->crypto_key_id, VTY_NEWLINE);
770 return CMD_WARNING;
771 }
772 ck = ospf_crypt_key_new ();
773 ck->key_id = vl_config->crypto_key_id;
774 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000775 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000776
777 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
778 }
779 else if (vl_config->crypto_key_id != 0)
780 {
781 /* Delete a key */
782
783 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
784 vl_config->crypto_key_id) == NULL)
785 {
786 vty_out (vty, "OSPF: Key %d does not exist%s",
787 vl_config->crypto_key_id, VTY_NEWLINE);
788 return CMD_WARNING;
789 }
790
791 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
792
793 }
794
795 return CMD_SUCCESS;
796}
797
paul4dadc292005-05-06 21:37:42 +0000798static int
paul718e3742002-12-13 20:15:29 +0000799ospf_vl_set_timers (struct ospf_vl_data *vl_data,
800 struct ospf_vl_config_data *vl_config)
801{
802 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
803 /* Virtual Link data initialised to defaults, so only set
804 if a value given */
805 if (vl_config->hello_interval)
806 {
807 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
808 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
809 }
810
811 if (vl_config->dead_interval)
812 {
813 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
814 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
815 }
816
817 if (vl_config->retransmit_interval)
818 {
819 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
820 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
821 }
822
823 if (vl_config->transmit_delay)
824 {
825 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
826 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
827 }
828
829 return CMD_SUCCESS;
830}
831
832
833
834/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000835static int
paul68980082003-03-25 05:07:42 +0000836ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000837{
838 struct ospf_vl_data *vl_data;
839 int ret;
840
paul68980082003-03-25 05:07:42 +0000841 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000842 if (!vl_data)
843 return CMD_WARNING;
844
845 /* Process this one first as it can have a fatal result, which can
846 only logically occur if the virtual link exists already
847 Thus a command error does not result in a change to the
848 running configuration such as unexpectedly altered timer
849 values etc.*/
850 ret = ospf_vl_set_security (vl_data, vl_config);
851 if (ret != CMD_SUCCESS)
852 return ret;
853
854 /* Set any time based parameters, these area already range checked */
855
856 ret = ospf_vl_set_timers (vl_data, vl_config);
857 if (ret != CMD_SUCCESS)
858 return ret;
859
860 return CMD_SUCCESS;
861
862}
863
864/* This stuff exists to make specifying all the alias commands A LOT simpler
865 */
866#define VLINK_HELPSTR_IPADDR \
867 "OSPF area parameters\n" \
868 "OSPF area ID in IP address format\n" \
869 "OSPF area ID as a decimal value\n" \
870 "Configure a virtual link\n" \
871 "Router ID of the remote ABR\n"
872
873#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
874 "Enable authentication on this virtual link\n" \
875 "dummy string \n"
876
877#define VLINK_HELPSTR_AUTHTYPE_ALL \
878 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
879 "Use null authentication\n" \
880 "Use message-digest authentication\n"
881
882#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
883 "Time between HELLO packets\n" \
884 "Time between retransmitting lost link state advertisements\n" \
885 "Link state transmit delay\n" \
886 "Interval after which a neighbor is declared dead\n"
887
888#define VLINK_HELPSTR_TIME_PARAM \
889 VLINK_HELPSTR_TIME_PARAM_NOSECS \
890 "Seconds\n"
891
892#define VLINK_HELPSTR_AUTH_SIMPLE \
893 "Authentication password (key)\n" \
894 "The OSPF password (key)"
895
896#define VLINK_HELPSTR_AUTH_MD5 \
897 "Message digest authentication password (key)\n" \
898 "dummy string \n" \
899 "Key ID\n" \
900 "Use MD5 algorithm\n" \
901 "The OSPF password (key)"
902
paula2c62832003-04-23 17:01:31 +0000903DEFUN (ospf_area_vlink,
904 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000905 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
906 VLINK_HELPSTR_IPADDR)
907{
paul68980082003-03-25 05:07:42 +0000908 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000909 struct ospf_vl_config_data vl_config;
910 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
911 char md5_key[OSPF_AUTH_MD5_SIZE+1];
912 int i;
913 int ret;
914
915 ospf_vl_config_data_init(&vl_config, vty);
916
917 /* Read off first 2 parameters and check them */
918 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
919 if (ret < 0)
920 {
921 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
922 return CMD_WARNING;
923 }
924
925 ret = inet_aton (argv[1], &vl_config.vl_peer);
926 if (! ret)
927 {
928 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
929 VTY_NEWLINE);
930 return CMD_WARNING;
931 }
932
933 if (argc <=2)
934 {
935 /* Thats all folks! - BUGS B. strikes again!!!*/
936
paul68980082003-03-25 05:07:42 +0000937 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000938 }
939
940 /* Deal with other parameters */
941 for (i=2; i < argc; i++)
942 {
943
944 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
945
946 switch (argv[i][0])
947 {
948
949 case 'a':
950 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
951 {
952 /* authentication-key - this option can occur anywhere on
953 command line. At start of command line
954 must check for authentication option. */
955 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
956 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
957 vl_config.auth_key = auth_key;
958 i++;
959 }
960 else if (strncmp (argv[i], "authentication", 14) == 0)
961 {
962 /* authentication - this option can only occur at start
963 of command line */
964 vl_config.auth_type = OSPF_AUTH_SIMPLE;
965 if ((i+1) < argc)
966 {
967 if (strncmp (argv[i+1], "n", 1) == 0)
968 {
969 /* "authentication null" */
970 vl_config.auth_type = OSPF_AUTH_NULL;
971 i++;
972 }
973 else if (strncmp (argv[i+1], "m", 1) == 0
974 && strcmp (argv[i+1], "message-digest-") != 0)
975 {
976 /* "authentication message-digest" */
977 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
978 i++;
979 }
980 }
981 }
982 break;
983
984 case 'm':
985 /* message-digest-key */
986 i++;
987 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
988 if (vl_config.crypto_key_id < 0)
989 return CMD_WARNING;
990 i++;
991 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
992 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
993 vl_config.md5_key = md5_key;
994 break;
995
996 case 'h':
997 /* Hello interval */
998 i++;
999 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1000 if (vl_config.hello_interval < 0)
1001 return CMD_WARNING;
1002 break;
1003
1004 case 'r':
1005 /* Retransmit Interval */
1006 i++;
1007 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1008 if (vl_config.retransmit_interval < 0)
1009 return CMD_WARNING;
1010 break;
1011
1012 case 't':
1013 /* Transmit Delay */
1014 i++;
1015 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1016 if (vl_config.transmit_delay < 0)
1017 return CMD_WARNING;
1018 break;
1019
1020 case 'd':
1021 /* Dead Interval */
1022 i++;
1023 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1024 if (vl_config.dead_interval < 0)
1025 return CMD_WARNING;
1026 break;
1027 }
1028 }
1029
1030
1031 /* Action configuration */
1032
paul68980082003-03-25 05:07:42 +00001033 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001034
1035}
1036
paula2c62832003-04-23 17:01:31 +00001037DEFUN (no_ospf_area_vlink,
1038 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001039 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1040 NO_STR
1041 VLINK_HELPSTR_IPADDR)
1042{
paul68980082003-03-25 05:07:42 +00001043 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001044 struct ospf_area *area;
1045 struct ospf_vl_config_data vl_config;
1046 struct ospf_vl_data *vl_data = NULL;
1047 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1048 int i;
1049 int ret, format;
1050
1051 ospf_vl_config_data_init(&vl_config, vty);
1052
1053 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1054 if (ret < 0)
1055 {
1056 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1057 return CMD_WARNING;
1058 }
1059
paul68980082003-03-25 05:07:42 +00001060 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001061 if (!area)
1062 {
1063 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1064 return CMD_WARNING;
1065 }
1066
1067 ret = inet_aton (argv[1], &vl_config.vl_peer);
1068 if (! ret)
1069 {
1070 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1071 VTY_NEWLINE);
1072 return CMD_WARNING;
1073 }
1074
1075 if (argc <=2)
1076 {
1077 /* Basic VLink no command */
1078 /* Thats all folks! - BUGS B. strikes again!!!*/
1079 if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001080 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001081
paul68980082003-03-25 05:07:42 +00001082 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001083
1084 return CMD_SUCCESS;
1085 }
1086
1087 /* If we are down here, we are reseting parameters */
1088
1089 /* Deal with other parameters */
1090 for (i=2; i < argc; i++)
1091 {
paul718e3742002-12-13 20:15:29 +00001092 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1093
1094 switch (argv[i][0])
1095 {
1096
1097 case 'a':
1098 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1099 {
1100 /* authentication-key - this option can occur anywhere on
1101 command line. At start of command line
1102 must check for authentication option. */
1103 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1104 vl_config.auth_key = auth_key;
1105 }
1106 else if (strncmp (argv[i], "authentication", 14) == 0)
1107 {
1108 /* authentication - this option can only occur at start
1109 of command line */
1110 vl_config.auth_type = OSPF_AUTH_NOTSET;
1111 }
1112 break;
1113
1114 case 'm':
1115 /* message-digest-key */
1116 /* Delete one key */
1117 i++;
1118 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1119 if (vl_config.crypto_key_id < 0)
1120 return CMD_WARNING;
1121 vl_config.md5_key = NULL;
1122 break;
1123
1124 case 'h':
1125 /* Hello interval */
1126 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1127 break;
1128
1129 case 'r':
1130 /* Retransmit Interval */
1131 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1132 break;
1133
1134 case 't':
1135 /* Transmit Delay */
1136 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1137 break;
1138
1139 case 'd':
1140 /* Dead Interval */
1141 i++;
1142 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1143 break;
1144 }
1145 }
1146
1147
1148 /* Action configuration */
1149
paul68980082003-03-25 05:07:42 +00001150 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001151}
1152
paula2c62832003-04-23 17:01:31 +00001153ALIAS (ospf_area_vlink,
1154 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001155 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1156 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1157 VLINK_HELPSTR_IPADDR
1158 VLINK_HELPSTR_TIME_PARAM)
1159
paula2c62832003-04-23 17:01:31 +00001160ALIAS (no_ospf_area_vlink,
1161 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001162 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1163 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1164 NO_STR
1165 VLINK_HELPSTR_IPADDR
1166 VLINK_HELPSTR_TIME_PARAM)
1167
paula2c62832003-04-23 17:01:31 +00001168ALIAS (ospf_area_vlink,
1169 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001170 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1171 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1172 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1173 VLINK_HELPSTR_IPADDR
1174 VLINK_HELPSTR_TIME_PARAM
1175 VLINK_HELPSTR_TIME_PARAM)
1176
paula2c62832003-04-23 17:01:31 +00001177ALIAS (no_ospf_area_vlink,
1178 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001179 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1180 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1181 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1182 NO_STR
1183 VLINK_HELPSTR_IPADDR
1184 VLINK_HELPSTR_TIME_PARAM
1185 VLINK_HELPSTR_TIME_PARAM)
1186
paula2c62832003-04-23 17:01:31 +00001187ALIAS (ospf_area_vlink,
1188 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001189 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1190 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1191 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1192 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1193 VLINK_HELPSTR_IPADDR
1194 VLINK_HELPSTR_TIME_PARAM
1195 VLINK_HELPSTR_TIME_PARAM
1196 VLINK_HELPSTR_TIME_PARAM)
1197
paula2c62832003-04-23 17:01:31 +00001198ALIAS (no_ospf_area_vlink,
1199 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001200 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1201 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1202 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1203 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1204 NO_STR
1205 VLINK_HELPSTR_IPADDR
1206 VLINK_HELPSTR_TIME_PARAM
1207 VLINK_HELPSTR_TIME_PARAM
1208 VLINK_HELPSTR_TIME_PARAM)
1209
paula2c62832003-04-23 17:01:31 +00001210ALIAS (ospf_area_vlink,
1211 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001212 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1213 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1214 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1215 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1216 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1217 VLINK_HELPSTR_IPADDR
1218 VLINK_HELPSTR_TIME_PARAM
1219 VLINK_HELPSTR_TIME_PARAM
1220 VLINK_HELPSTR_TIME_PARAM
1221 VLINK_HELPSTR_TIME_PARAM)
1222
paula2c62832003-04-23 17:01:31 +00001223ALIAS (no_ospf_area_vlink,
1224 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001225 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1226 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1227 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1228 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1229 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1230 NO_STR
1231 VLINK_HELPSTR_IPADDR
1232 VLINK_HELPSTR_TIME_PARAM
1233 VLINK_HELPSTR_TIME_PARAM
1234 VLINK_HELPSTR_TIME_PARAM
1235 VLINK_HELPSTR_TIME_PARAM)
1236
paula2c62832003-04-23 17:01:31 +00001237ALIAS (ospf_area_vlink,
1238 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001239 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1240 "(authentication|) (message-digest|null)",
1241 VLINK_HELPSTR_IPADDR
1242 VLINK_HELPSTR_AUTHTYPE_ALL)
1243
paula2c62832003-04-23 17:01:31 +00001244ALIAS (ospf_area_vlink,
1245 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001246 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1247 "(authentication|)",
1248 VLINK_HELPSTR_IPADDR
1249 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1250
paula2c62832003-04-23 17:01:31 +00001251ALIAS (no_ospf_area_vlink,
1252 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001253 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1254 "(authentication|)",
1255 NO_STR
1256 VLINK_HELPSTR_IPADDR
1257 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1258
paula2c62832003-04-23 17:01:31 +00001259ALIAS (ospf_area_vlink,
1260 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001261 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1262 "(message-digest-key|) <1-255> md5 KEY",
1263 VLINK_HELPSTR_IPADDR
1264 VLINK_HELPSTR_AUTH_MD5)
1265
paula2c62832003-04-23 17:01:31 +00001266ALIAS (no_ospf_area_vlink,
1267 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001268 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1269 "(message-digest-key|) <1-255>",
1270 NO_STR
1271 VLINK_HELPSTR_IPADDR
1272 VLINK_HELPSTR_AUTH_MD5)
1273
paula2c62832003-04-23 17:01:31 +00001274ALIAS (ospf_area_vlink,
1275 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001276 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1277 "(authentication-key|) AUTH_KEY",
1278 VLINK_HELPSTR_IPADDR
1279 VLINK_HELPSTR_AUTH_SIMPLE)
1280
paula2c62832003-04-23 17:01:31 +00001281ALIAS (no_ospf_area_vlink,
1282 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001283 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1284 "(authentication-key|)",
1285 NO_STR
1286 VLINK_HELPSTR_IPADDR
1287 VLINK_HELPSTR_AUTH_SIMPLE)
1288
paula2c62832003-04-23 17:01:31 +00001289ALIAS (ospf_area_vlink,
1290 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001291 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1292 "(authentication|) (message-digest|null) "
1293 "(authentication-key|) AUTH_KEY",
1294 VLINK_HELPSTR_IPADDR
1295 VLINK_HELPSTR_AUTHTYPE_ALL
1296 VLINK_HELPSTR_AUTH_SIMPLE)
1297
paula2c62832003-04-23 17:01:31 +00001298ALIAS (ospf_area_vlink,
1299 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001300 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1301 "(authentication|) "
1302 "(authentication-key|) AUTH_KEY",
1303 VLINK_HELPSTR_IPADDR
1304 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1305 VLINK_HELPSTR_AUTH_SIMPLE)
1306
paula2c62832003-04-23 17:01:31 +00001307ALIAS (no_ospf_area_vlink,
1308 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001309 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1310 "(authentication|) "
1311 "(authentication-key|)",
1312 NO_STR
1313 VLINK_HELPSTR_IPADDR
1314 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1315 VLINK_HELPSTR_AUTH_SIMPLE)
1316
paula2c62832003-04-23 17:01:31 +00001317ALIAS (ospf_area_vlink,
1318 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001319 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1320 "(authentication|) (message-digest|null) "
1321 "(message-digest-key|) <1-255> md5 KEY",
1322 VLINK_HELPSTR_IPADDR
1323 VLINK_HELPSTR_AUTHTYPE_ALL
1324 VLINK_HELPSTR_AUTH_MD5)
1325
paula2c62832003-04-23 17:01:31 +00001326ALIAS (ospf_area_vlink,
1327 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001328 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1329 "(authentication|) "
1330 "(message-digest-key|) <1-255> md5 KEY",
1331 VLINK_HELPSTR_IPADDR
1332 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1333 VLINK_HELPSTR_AUTH_MD5)
1334
paula2c62832003-04-23 17:01:31 +00001335ALIAS (no_ospf_area_vlink,
1336 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001337 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1338 "(authentication|) "
1339 "(message-digest-key|)",
1340 NO_STR
1341 VLINK_HELPSTR_IPADDR
1342 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1343 VLINK_HELPSTR_AUTH_MD5)
1344
1345
paula2c62832003-04-23 17:01:31 +00001346DEFUN (ospf_area_shortcut,
1347 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001348 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1349 "OSPF area parameters\n"
1350 "OSPF area ID in IP address format\n"
1351 "OSPF area ID as a decimal value\n"
1352 "Configure the area's shortcutting mode\n"
1353 "Set default shortcutting behavior\n"
1354 "Enable shortcutting through the area\n"
1355 "Disable shortcutting through the area\n")
1356{
paul68980082003-03-25 05:07:42 +00001357 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001358 struct ospf_area *area;
1359 struct in_addr area_id;
1360 int mode;
1361 int format;
1362
1363 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1364
paul68980082003-03-25 05:07:42 +00001365 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001366
1367 if (strncmp (argv[1], "de", 2) == 0)
1368 mode = OSPF_SHORTCUT_DEFAULT;
1369 else if (strncmp (argv[1], "di", 2) == 0)
1370 mode = OSPF_SHORTCUT_DISABLE;
1371 else if (strncmp (argv[1], "e", 1) == 0)
1372 mode = OSPF_SHORTCUT_ENABLE;
1373 else
1374 return CMD_WARNING;
1375
paul68980082003-03-25 05:07:42 +00001376 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001377
paul68980082003-03-25 05:07:42 +00001378 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001379 vty_out (vty, "Shortcut area setting will take effect "
1380 "only when the router is configured as Shortcut ABR%s",
1381 VTY_NEWLINE);
1382
1383 return CMD_SUCCESS;
1384}
1385
paula2c62832003-04-23 17:01:31 +00001386DEFUN (no_ospf_area_shortcut,
1387 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001388 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1389 NO_STR
1390 "OSPF area parameters\n"
1391 "OSPF area ID in IP address format\n"
1392 "OSPF area ID as a decimal value\n"
1393 "Deconfigure the area's shortcutting mode\n"
1394 "Deconfigure enabled shortcutting through the area\n"
1395 "Deconfigure disabled 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 format;
1401
1402 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1403
paul68980082003-03-25 05:07:42 +00001404 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001405 if (!area)
1406 return CMD_SUCCESS;
1407
paul68980082003-03-25 05:07:42 +00001408 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001409
1410 return CMD_SUCCESS;
1411}
1412
1413
paula2c62832003-04-23 17:01:31 +00001414DEFUN (ospf_area_stub,
1415 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001416 "area (A.B.C.D|<0-4294967295>) stub",
1417 "OSPF area parameters\n"
1418 "OSPF area ID in IP address format\n"
1419 "OSPF area ID as a decimal value\n"
1420 "Configure OSPF area as stub\n")
1421{
1422 struct ospf *ospf = vty->index;
1423 struct in_addr area_id;
1424 int ret, format;
1425
1426 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1427
1428 ret = ospf_area_stub_set (ospf, area_id);
1429 if (ret == 0)
1430 {
1431 vty_out (vty, "First deconfigure all virtual link through this area%s",
1432 VTY_NEWLINE);
1433 return CMD_WARNING;
1434 }
1435
1436 ospf_area_no_summary_unset (ospf, area_id);
1437
1438 return CMD_SUCCESS;
1439}
1440
paula2c62832003-04-23 17:01:31 +00001441DEFUN (ospf_area_stub_no_summary,
1442 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001443 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1444 "OSPF stub parameters\n"
1445 "OSPF area ID in IP address format\n"
1446 "OSPF area ID as a decimal value\n"
1447 "Configure OSPF area as stub\n"
1448 "Do not inject inter-area routes into stub\n")
1449{
1450 struct ospf *ospf = vty->index;
1451 struct in_addr area_id;
1452 int ret, format;
1453
1454 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1455
1456 ret = ospf_area_stub_set (ospf, area_id);
1457 if (ret == 0)
1458 {
paulb0a053b2003-06-22 09:04:47 +00001459 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001460 VTY_NEWLINE);
1461 return CMD_WARNING;
1462 }
1463
1464 ospf_area_no_summary_set (ospf, area_id);
1465
1466 return CMD_SUCCESS;
1467}
1468
paula2c62832003-04-23 17:01:31 +00001469DEFUN (no_ospf_area_stub,
1470 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001471 "no area (A.B.C.D|<0-4294967295>) stub",
1472 NO_STR
1473 "OSPF area parameters\n"
1474 "OSPF area ID in IP address format\n"
1475 "OSPF area ID as a decimal value\n"
1476 "Configure OSPF area as stub\n")
1477{
1478 struct ospf *ospf = vty->index;
1479 struct in_addr area_id;
1480 int format;
1481
1482 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1483
1484 ospf_area_stub_unset (ospf, area_id);
1485 ospf_area_no_summary_unset (ospf, area_id);
1486
1487 return CMD_SUCCESS;
1488}
1489
paula2c62832003-04-23 17:01:31 +00001490DEFUN (no_ospf_area_stub_no_summary,
1491 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001492 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1493 NO_STR
1494 "OSPF area parameters\n"
1495 "OSPF area ID in IP address format\n"
1496 "OSPF area ID as a decimal value\n"
1497 "Configure OSPF area as stub\n"
1498 "Do not inject inter-area routes into area\n")
1499{
1500 struct ospf *ospf = vty->index;
1501 struct in_addr area_id;
1502 int format;
1503
1504 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1505 ospf_area_no_summary_unset (ospf, area_id);
1506
1507 return CMD_SUCCESS;
1508}
1509
paul4dadc292005-05-06 21:37:42 +00001510static int
paul6c835672004-10-11 11:00:30 +00001511ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1512 int nosum)
paul718e3742002-12-13 20:15:29 +00001513{
1514 struct ospf *ospf = vty->index;
1515 struct in_addr area_id;
1516 int ret, format;
1517
1518 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1519
1520 ret = ospf_area_nssa_set (ospf, area_id);
1521 if (ret == 0)
1522 {
1523 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1524 VTY_NEWLINE);
1525 return CMD_WARNING;
1526 }
1527
1528 if (argc > 1)
1529 {
1530 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001531 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001532 OSPF_NSSA_ROLE_CANDIDATE);
1533 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001534 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001535 OSPF_NSSA_ROLE_NEVER);
1536 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001537 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001538 OSPF_NSSA_ROLE_ALWAYS);
1539 }
paulb0a053b2003-06-22 09:04:47 +00001540 else
1541 {
1542 ospf_area_nssa_translator_role_set (ospf, area_id,
1543 OSPF_NSSA_ROLE_CANDIDATE);
1544 }
paul718e3742002-12-13 20:15:29 +00001545
paulb0a053b2003-06-22 09:04:47 +00001546 if (nosum)
paul718e3742002-12-13 20:15:29 +00001547 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001548 else
1549 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001550
paulb0a053b2003-06-22 09:04:47 +00001551 ospf_schedule_abr_task (ospf);
1552
paul718e3742002-12-13 20:15:29 +00001553 return CMD_SUCCESS;
1554}
1555
paulb0a053b2003-06-22 09:04:47 +00001556DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001557 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001558 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001559 "OSPF area parameters\n"
1560 "OSPF area ID in IP address format\n"
1561 "OSPF area ID as a decimal value\n"
1562 "Configure OSPF area as nssa\n"
1563 "Configure NSSA-ABR for translate election (default)\n"
1564 "Configure NSSA-ABR to never translate\n"
1565 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001566 "Do not inject inter-area routes into nssa\n")
1567{
1568 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1569}
paul718e3742002-12-13 20:15:29 +00001570
paulb0a053b2003-06-22 09:04:47 +00001571DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001572 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001573 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1574 "OSPF area parameters\n"
1575 "OSPF area ID in IP address format\n"
1576 "OSPF area ID as a decimal value\n"
1577 "Configure OSPF area as nssa\n"
1578 "Configure NSSA-ABR for translate election (default)\n"
1579 "Configure NSSA-ABR to never translate\n"
1580 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001581{
1582 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1583}
1584
1585DEFUN (ospf_area_nssa,
1586 ospf_area_nssa_cmd,
1587 "area (A.B.C.D|<0-4294967295>) nssa",
1588 "OSPF area parameters\n"
1589 "OSPF area ID in IP address format\n"
1590 "OSPF area ID as a decimal value\n"
1591 "Configure OSPF area as nssa\n")
1592{
1593 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1594}
paul718e3742002-12-13 20:15:29 +00001595
paula2c62832003-04-23 17:01:31 +00001596DEFUN (ospf_area_nssa_no_summary,
1597 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001598 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1599 "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 "Do not inject inter-area routes into nssa\n")
1604{
paulb0a053b2003-06-22 09:04:47 +00001605 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001606}
1607
paula2c62832003-04-23 17:01:31 +00001608DEFUN (no_ospf_area_nssa,
1609 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001610 "no area (A.B.C.D|<0-4294967295>) nssa",
1611 NO_STR
1612 "OSPF area parameters\n"
1613 "OSPF area ID in IP address format\n"
1614 "OSPF area ID as a decimal value\n"
1615 "Configure OSPF area as nssa\n")
1616{
1617 struct ospf *ospf = vty->index;
1618 struct in_addr area_id;
1619 int format;
1620
1621 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1622
1623 ospf_area_nssa_unset (ospf, area_id);
1624 ospf_area_no_summary_unset (ospf, area_id);
1625
paulb0a053b2003-06-22 09:04:47 +00001626 ospf_schedule_abr_task (ospf);
1627
paul718e3742002-12-13 20:15:29 +00001628 return CMD_SUCCESS;
1629}
1630
paula2c62832003-04-23 17:01:31 +00001631DEFUN (no_ospf_area_nssa_no_summary,
1632 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001633 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1634 NO_STR
1635 "OSPF area parameters\n"
1636 "OSPF area ID in IP address format\n"
1637 "OSPF area ID as a decimal value\n"
1638 "Configure OSPF area as nssa\n"
1639 "Do not inject inter-area routes into nssa\n")
1640{
1641 struct ospf *ospf = vty->index;
1642 struct in_addr area_id;
1643 int format;
1644
1645 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1646 ospf_area_no_summary_unset (ospf, area_id);
1647
1648 return CMD_SUCCESS;
1649}
1650
paula2c62832003-04-23 17:01:31 +00001651DEFUN (ospf_area_default_cost,
1652 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001653 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1654 "OSPF area parameters\n"
1655 "OSPF area ID in IP address format\n"
1656 "OSPF area ID as a decimal value\n"
1657 "Set the summary-default cost of a NSSA or stub area\n"
1658 "Stub's advertised default summary cost\n")
1659{
paul68980082003-03-25 05:07:42 +00001660 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001661 struct ospf_area *area;
1662 struct in_addr area_id;
1663 u_int32_t cost;
1664 int format;
vincentba682532005-09-29 13:52:57 +00001665 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001666
1667 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1668 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1669
paul68980082003-03-25 05:07:42 +00001670 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001671
1672 if (area->external_routing == OSPF_AREA_DEFAULT)
1673 {
1674 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1675 return CMD_WARNING;
1676 }
1677
1678 area->default_cost = cost;
1679
vincentba682532005-09-29 13:52:57 +00001680 p.family = AF_INET;
1681 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1682 p.prefixlen = 0;
1683 if (IS_DEBUG_OSPF_EVENT)
1684 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1685 "announcing 0.0.0.0/0 to area %s",
1686 inet_ntoa (area->area_id));
1687 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1688
paul718e3742002-12-13 20:15:29 +00001689 return CMD_SUCCESS;
1690}
1691
paula2c62832003-04-23 17:01:31 +00001692DEFUN (no_ospf_area_default_cost,
1693 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001694 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1695 NO_STR
1696 "OSPF area parameters\n"
1697 "OSPF area ID in IP address format\n"
1698 "OSPF area ID as a decimal value\n"
1699 "Set the summary-default cost of a NSSA or stub area\n"
1700 "Stub's advertised default summary cost\n")
1701{
paul68980082003-03-25 05:07:42 +00001702 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001703 struct ospf_area *area;
1704 struct in_addr area_id;
1705 u_int32_t cost;
1706 int format;
vincentba682532005-09-29 13:52:57 +00001707 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001708
1709 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1710 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1711
paul68980082003-03-25 05:07:42 +00001712 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001713 if (area == NULL)
1714 return CMD_SUCCESS;
1715
1716 if (area->external_routing == OSPF_AREA_DEFAULT)
1717 {
1718 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1719 return CMD_WARNING;
1720 }
1721
1722 area->default_cost = 1;
1723
vincentba682532005-09-29 13:52:57 +00001724 p.family = AF_INET;
1725 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1726 p.prefixlen = 0;
1727 if (IS_DEBUG_OSPF_EVENT)
1728 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1729 "announcing 0.0.0.0/0 to area %s",
1730 inet_ntoa (area->area_id));
1731 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1732
1733
paul68980082003-03-25 05:07:42 +00001734 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001735
1736 return CMD_SUCCESS;
1737}
1738
paula2c62832003-04-23 17:01:31 +00001739DEFUN (ospf_area_export_list,
1740 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001741 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1742 "OSPF area parameters\n"
1743 "OSPF area ID in IP address format\n"
1744 "OSPF area ID as a decimal value\n"
1745 "Set the filter for networks announced to other areas\n"
1746 "Name of the access-list\n")
1747{
paul68980082003-03-25 05:07:42 +00001748 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001749 struct ospf_area *area;
1750 struct in_addr area_id;
1751 int format;
1752
hasso52930762004-04-19 18:26:53 +00001753 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1754
paul68980082003-03-25 05:07:42 +00001755 area = ospf_area_get (ospf, area_id, format);
1756 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001757
1758 return CMD_SUCCESS;
1759}
1760
paula2c62832003-04-23 17:01:31 +00001761DEFUN (no_ospf_area_export_list,
1762 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001763 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1764 NO_STR
1765 "OSPF area parameters\n"
1766 "OSPF area ID in IP address format\n"
1767 "OSPF area ID as a decimal value\n"
1768 "Unset the filter for networks announced to other areas\n"
1769 "Name of the access-list\n")
1770{
paul68980082003-03-25 05:07:42 +00001771 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001772 struct ospf_area *area;
1773 struct in_addr area_id;
1774 int format;
1775
hasso52930762004-04-19 18:26:53 +00001776 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1777
paul68980082003-03-25 05:07:42 +00001778 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001779 if (area == NULL)
1780 return CMD_SUCCESS;
1781
paul68980082003-03-25 05:07:42 +00001782 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001783
1784 return CMD_SUCCESS;
1785}
1786
1787
paula2c62832003-04-23 17:01:31 +00001788DEFUN (ospf_area_import_list,
1789 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001790 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1791 "OSPF area parameters\n"
1792 "OSPF area ID in IP address format\n"
1793 "OSPF area ID as a decimal value\n"
1794 "Set the filter for networks from other areas announced to the specified one\n"
1795 "Name of the access-list\n")
1796{
paul68980082003-03-25 05:07:42 +00001797 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001798 struct ospf_area *area;
1799 struct in_addr area_id;
1800 int format;
1801
hasso52930762004-04-19 18:26:53 +00001802 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1803
paul68980082003-03-25 05:07:42 +00001804 area = ospf_area_get (ospf, area_id, format);
1805 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001806
1807 return CMD_SUCCESS;
1808}
1809
paula2c62832003-04-23 17:01:31 +00001810DEFUN (no_ospf_area_import_list,
1811 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001812 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1813 NO_STR
1814 "OSPF area parameters\n"
1815 "OSPF area ID in IP address format\n"
1816 "OSPF area ID as a decimal value\n"
1817 "Unset the filter for networks announced to other areas\n"
1818 "Name of the access-list\n")
1819{
paul68980082003-03-25 05:07:42 +00001820 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001821 struct ospf_area *area;
1822 struct in_addr area_id;
1823 int format;
1824
hasso52930762004-04-19 18:26:53 +00001825 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1826
paul68980082003-03-25 05:07:42 +00001827 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001828 if (area == NULL)
1829 return CMD_SUCCESS;
1830
paul68980082003-03-25 05:07:42 +00001831 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001832
1833 return CMD_SUCCESS;
1834}
1835
paula2c62832003-04-23 17:01:31 +00001836DEFUN (ospf_area_filter_list,
1837 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001838 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1839 "OSPF area parameters\n"
1840 "OSPF area ID in IP address format\n"
1841 "OSPF area ID as a decimal value\n"
1842 "Filter networks between OSPF areas\n"
1843 "Filter prefixes between OSPF areas\n"
1844 "Name of an IP prefix-list\n"
1845 "Filter networks sent to this area\n"
1846 "Filter networks sent from this area\n")
1847{
paul68980082003-03-25 05:07:42 +00001848 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001849 struct ospf_area *area;
1850 struct in_addr area_id;
1851 struct prefix_list *plist;
1852 int format;
1853
1854 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1855
paul68980082003-03-25 05:07:42 +00001856 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001857 plist = prefix_list_lookup (AFI_IP, argv[1]);
1858 if (strncmp (argv[2], "in", 2) == 0)
1859 {
1860 PREFIX_LIST_IN (area) = plist;
1861 if (PREFIX_NAME_IN (area))
1862 free (PREFIX_NAME_IN (area));
1863
1864 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001865 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001866 }
1867 else
1868 {
1869 PREFIX_LIST_OUT (area) = plist;
1870 if (PREFIX_NAME_OUT (area))
1871 free (PREFIX_NAME_OUT (area));
1872
1873 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001874 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001875 }
1876
1877 return CMD_SUCCESS;
1878}
1879
paula2c62832003-04-23 17:01:31 +00001880DEFUN (no_ospf_area_filter_list,
1881 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001882 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1883 NO_STR
1884 "OSPF area parameters\n"
1885 "OSPF area ID in IP address format\n"
1886 "OSPF area ID as a decimal value\n"
1887 "Filter networks between OSPF areas\n"
1888 "Filter prefixes between OSPF areas\n"
1889 "Name of an IP prefix-list\n"
1890 "Filter networks sent to this area\n"
1891 "Filter networks sent from this area\n")
1892{
paul68980082003-03-25 05:07:42 +00001893 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001894 struct ospf_area *area;
1895 struct in_addr area_id;
1896 struct prefix_list *plist;
1897 int format;
1898
1899 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1900
paul68980082003-03-25 05:07:42 +00001901 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001902 plist = prefix_list_lookup (AFI_IP, argv[1]);
1903 if (strncmp (argv[2], "in", 2) == 0)
1904 {
1905 if (PREFIX_NAME_IN (area))
1906 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1907 return CMD_SUCCESS;
1908
1909 PREFIX_LIST_IN (area) = NULL;
1910 if (PREFIX_NAME_IN (area))
1911 free (PREFIX_NAME_IN (area));
1912
1913 PREFIX_NAME_IN (area) = NULL;
1914
paul68980082003-03-25 05:07:42 +00001915 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001916 }
1917 else
1918 {
1919 if (PREFIX_NAME_OUT (area))
1920 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1921 return CMD_SUCCESS;
1922
1923 PREFIX_LIST_OUT (area) = NULL;
1924 if (PREFIX_NAME_OUT (area))
1925 free (PREFIX_NAME_OUT (area));
1926
1927 PREFIX_NAME_OUT (area) = NULL;
1928
paul68980082003-03-25 05:07:42 +00001929 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001930 }
1931
1932 return CMD_SUCCESS;
1933}
1934
1935
paula2c62832003-04-23 17:01:31 +00001936DEFUN (ospf_area_authentication_message_digest,
1937 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001938 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1939 "OSPF area parameters\n"
1940 "Enable authentication\n"
1941 "Use message-digest authentication\n")
1942{
paul68980082003-03-25 05:07:42 +00001943 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001944 struct ospf_area *area;
1945 struct in_addr area_id;
1946 int format;
1947
1948 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1949
paul68980082003-03-25 05:07:42 +00001950 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001951 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1952
1953 return CMD_SUCCESS;
1954}
1955
paula2c62832003-04-23 17:01:31 +00001956DEFUN (ospf_area_authentication,
1957 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001958 "area (A.B.C.D|<0-4294967295>) authentication",
1959 "OSPF area parameters\n"
1960 "OSPF area ID in IP address format\n"
1961 "OSPF area ID as a decimal value\n"
1962 "Enable authentication\n")
1963{
paul68980082003-03-25 05:07:42 +00001964 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001965 struct ospf_area *area;
1966 struct in_addr area_id;
1967 int format;
1968
1969 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1970
paul68980082003-03-25 05:07:42 +00001971 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001972 area->auth_type = OSPF_AUTH_SIMPLE;
1973
1974 return CMD_SUCCESS;
1975}
1976
paula2c62832003-04-23 17:01:31 +00001977DEFUN (no_ospf_area_authentication,
1978 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001979 "no area (A.B.C.D|<0-4294967295>) authentication",
1980 NO_STR
1981 "OSPF area parameters\n"
1982 "OSPF area ID in IP address format\n"
1983 "OSPF area ID as a decimal value\n"
1984 "Enable authentication\n")
1985{
paul68980082003-03-25 05:07:42 +00001986 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001987 struct ospf_area *area;
1988 struct in_addr area_id;
1989 int format;
1990
1991 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1992
paul68980082003-03-25 05:07:42 +00001993 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001994 if (area == NULL)
1995 return CMD_SUCCESS;
1996
1997 area->auth_type = OSPF_AUTH_NULL;
1998
paul68980082003-03-25 05:07:42 +00001999 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002000
2001 return CMD_SUCCESS;
2002}
2003
2004
2005DEFUN (ospf_abr_type,
2006 ospf_abr_type_cmd,
2007 "ospf abr-type (cisco|ibm|shortcut|standard)",
2008 "OSPF specific commands\n"
2009 "Set OSPF ABR type\n"
2010 "Alternative ABR, cisco implementation\n"
2011 "Alternative ABR, IBM implementation\n"
2012 "Shortcut ABR\n"
2013 "Standard behavior (RFC2328)\n")
2014{
paul68980082003-03-25 05:07:42 +00002015 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002016 u_char abr_type = OSPF_ABR_UNKNOWN;
2017
2018 if (strncmp (argv[0], "c", 1) == 0)
2019 abr_type = OSPF_ABR_CISCO;
2020 else if (strncmp (argv[0], "i", 1) == 0)
2021 abr_type = OSPF_ABR_IBM;
2022 else if (strncmp (argv[0], "sh", 2) == 0)
2023 abr_type = OSPF_ABR_SHORTCUT;
2024 else if (strncmp (argv[0], "st", 2) == 0)
2025 abr_type = OSPF_ABR_STAND;
2026 else
2027 return CMD_WARNING;
2028
2029 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002030 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002031 {
paul68980082003-03-25 05:07:42 +00002032 ospf->abr_type = abr_type;
2033 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002034 }
2035
2036 return CMD_SUCCESS;
2037}
2038
2039DEFUN (no_ospf_abr_type,
2040 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002041 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002042 NO_STR
2043 "OSPF specific commands\n"
2044 "Set OSPF ABR type\n"
2045 "Alternative ABR, cisco implementation\n"
2046 "Alternative ABR, IBM implementation\n"
2047 "Shortcut ABR\n")
2048{
paul68980082003-03-25 05:07:42 +00002049 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002050 u_char abr_type = OSPF_ABR_UNKNOWN;
2051
2052 if (strncmp (argv[0], "c", 1) == 0)
2053 abr_type = OSPF_ABR_CISCO;
2054 else if (strncmp (argv[0], "i", 1) == 0)
2055 abr_type = OSPF_ABR_IBM;
2056 else if (strncmp (argv[0], "s", 1) == 0)
2057 abr_type = OSPF_ABR_SHORTCUT;
2058 else
2059 return CMD_WARNING;
2060
2061 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002062 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002063 {
pauld57834f2005-07-12 20:04:22 +00002064 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002065 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002066 }
2067
2068 return CMD_SUCCESS;
2069}
2070
2071DEFUN (ospf_compatible_rfc1583,
2072 ospf_compatible_rfc1583_cmd,
2073 "compatible rfc1583",
2074 "OSPF compatibility list\n"
2075 "compatible with RFC 1583\n")
2076{
2077 struct ospf *ospf = vty->index;
2078
2079 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2080 {
2081 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002082 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002083 }
2084 return CMD_SUCCESS;
2085}
2086
2087DEFUN (no_ospf_compatible_rfc1583,
2088 no_ospf_compatible_rfc1583_cmd,
2089 "no compatible rfc1583",
2090 NO_STR
2091 "OSPF compatibility list\n"
2092 "compatible with RFC 1583\n")
2093{
2094 struct ospf *ospf = vty->index;
2095
2096 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2097 {
2098 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002099 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002100 }
2101 return CMD_SUCCESS;
2102}
2103
2104ALIAS (ospf_compatible_rfc1583,
2105 ospf_rfc1583_flag_cmd,
2106 "ospf rfc1583compatibility",
2107 "OSPF specific commands\n"
2108 "Enable the RFC1583Compatibility flag\n")
2109
2110ALIAS (no_ospf_compatible_rfc1583,
2111 no_ospf_rfc1583_flag_cmd,
2112 "no ospf rfc1583compatibility",
2113 NO_STR
2114 "OSPF specific commands\n"
2115 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002116
2117static int
2118ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2119 unsigned int hold,
2120 unsigned int max)
2121{
2122 struct ospf *ospf = vty->index;
2123
2124 ospf->spf_delay = delay;
2125 ospf->spf_holdtime = hold;
2126 ospf->spf_max_holdtime = max;
2127
2128 return CMD_SUCCESS;
2129}
paul718e3742002-12-13 20:15:29 +00002130
pauld24f6e22005-10-21 09:23:12 +00002131DEFUN (ospf_timers_throttle_spf,
2132 ospf_timers_throttle_spf_cmd,
2133 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2134 "Adjust routing timers\n"
2135 "Throttling adaptive timer\n"
2136 "OSPF SPF timers\n"
2137 "Delay (msec) from first change received till SPF calculation\n"
2138 "Initial hold time (msec) between consecutive SPF calculations\n"
2139 "Maximum hold time (msec)\n")
2140{
2141 unsigned int delay, hold, max;
2142
2143 if (argc != 3)
2144 {
2145 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2146 return CMD_WARNING;
2147 }
2148
2149 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2150 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2151 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2152
2153 return ospf_timers_spf_set (vty, delay, hold, max);
2154}
2155
2156DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002157 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002158 "timers spf <0-4294967295> <0-4294967295>",
2159 "Adjust routing timers\n"
2160 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002161 "Delay (s) between receiving a change to SPF calculation\n"
2162 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002163{
pauld24f6e22005-10-21 09:23:12 +00002164 unsigned int delay, hold;
2165
2166 if (argc != 2)
2167 {
2168 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2169 return CMD_WARNING;
2170 }
2171
paul4dadc292005-05-06 21:37:42 +00002172 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2173 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002174
2175 /* truncate down the second values if they're greater than 600000ms */
2176 if (delay > (600000 / 1000))
2177 delay = 600000;
2178 else if (delay == 0)
2179 /* 0s delay was probably specified because of lack of ms resolution */
2180 delay = OSPF_SPF_DELAY_DEFAULT;
2181 if (hold > (600000 / 1000))
2182 hold = 600000;
2183
2184 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002185}
2186
pauld24f6e22005-10-21 09:23:12 +00002187DEFUN (no_ospf_timers_throttle_spf,
2188 no_ospf_timers_throttle_spf_cmd,
2189 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002190 NO_STR
2191 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002192 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002193 "OSPF SPF timers\n")
2194{
pauld24f6e22005-10-21 09:23:12 +00002195 return ospf_timers_spf_set (vty,
2196 OSPF_SPF_DELAY_DEFAULT,
2197 OSPF_SPF_HOLDTIME_DEFAULT,
2198 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002199}
2200
pauld24f6e22005-10-21 09:23:12 +00002201ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2202 no_ospf_timers_spf_cmd,
2203 "no timers spf",
2204 NO_STR
2205 "Adjust routing timers\n"
2206 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002207
paula2c62832003-04-23 17:01:31 +00002208DEFUN (ospf_neighbor,
2209 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002210 "neighbor A.B.C.D",
2211 NEIGHBOR_STR
2212 "Neighbor IP address\n")
2213{
2214 struct ospf *ospf = vty->index;
2215 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002216 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2217 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002218
2219 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2220
2221 if (argc > 1)
2222 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2223
2224 if (argc > 2)
2225 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2226
2227 ospf_nbr_nbma_set (ospf, nbr_addr);
2228 if (argc > 1)
2229 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2230 if (argc > 2)
2231 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2232
2233 return CMD_SUCCESS;
2234}
2235
paula2c62832003-04-23 17:01:31 +00002236ALIAS (ospf_neighbor,
2237 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002238 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2239 NEIGHBOR_STR
2240 "Neighbor IP address\n"
2241 "Neighbor Priority\n"
2242 "Priority\n"
2243 "Dead Neighbor Polling interval\n"
2244 "Seconds\n")
2245
paula2c62832003-04-23 17:01:31 +00002246ALIAS (ospf_neighbor,
2247 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002248 "neighbor A.B.C.D priority <0-255>",
2249 NEIGHBOR_STR
2250 "Neighbor IP address\n"
2251 "Neighbor Priority\n"
2252 "Seconds\n")
2253
paula2c62832003-04-23 17:01:31 +00002254DEFUN (ospf_neighbor_poll_interval,
2255 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002256 "neighbor A.B.C.D poll-interval <1-65535>",
2257 NEIGHBOR_STR
2258 "Neighbor IP address\n"
2259 "Dead Neighbor Polling interval\n"
2260 "Seconds\n")
2261{
2262 struct ospf *ospf = vty->index;
2263 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002264 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2265 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002266
2267 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2268
2269 if (argc > 1)
2270 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2271
2272 if (argc > 2)
2273 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2274
2275 ospf_nbr_nbma_set (ospf, nbr_addr);
2276 if (argc > 1)
2277 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2278 if (argc > 2)
2279 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2280
2281 return CMD_SUCCESS;
2282}
2283
paula2c62832003-04-23 17:01:31 +00002284ALIAS (ospf_neighbor_poll_interval,
2285 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002286 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2287 NEIGHBOR_STR
2288 "Neighbor address\n"
2289 "OSPF dead-router polling interval\n"
2290 "Seconds\n"
2291 "OSPF priority of non-broadcast neighbor\n"
2292 "Priority\n")
2293
paula2c62832003-04-23 17:01:31 +00002294DEFUN (no_ospf_neighbor,
2295 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002296 "no neighbor A.B.C.D",
2297 NO_STR
2298 NEIGHBOR_STR
2299 "Neighbor IP address\n")
2300{
2301 struct ospf *ospf = vty->index;
2302 struct in_addr nbr_addr;
2303 int ret;
2304
2305 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2306
2307 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2308
2309 return CMD_SUCCESS;
2310}
2311
paula2c62832003-04-23 17:01:31 +00002312ALIAS (no_ospf_neighbor,
2313 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002314 "no neighbor A.B.C.D priority <0-255>",
2315 NO_STR
2316 NEIGHBOR_STR
2317 "Neighbor IP address\n"
2318 "Neighbor Priority\n"
2319 "Priority\n")
2320
paula2c62832003-04-23 17:01:31 +00002321ALIAS (no_ospf_neighbor,
2322 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002323 "no neighbor A.B.C.D poll-interval <1-65535>",
2324 NO_STR
2325 NEIGHBOR_STR
2326 "Neighbor IP address\n"
2327 "Dead Neighbor Polling interval\n"
2328 "Seconds\n")
2329
paula2c62832003-04-23 17:01:31 +00002330ALIAS (no_ospf_neighbor,
2331 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002332 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2333 NO_STR
2334 NEIGHBOR_STR
2335 "Neighbor IP address\n"
2336 "Neighbor Priority\n"
2337 "Priority\n"
2338 "Dead Neighbor Polling interval\n"
2339 "Seconds\n")
2340
2341
paula2c62832003-04-23 17:01:31 +00002342DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002343 "refresh timer <10-1800>",
2344 "Adjust refresh parameters\n"
2345 "Set refresh timer\n"
2346 "Timer value in seconds\n")
2347{
2348 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002349 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002350
2351 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2352 interval = (interval / 10) * 10;
2353
2354 ospf_timers_refresh_set (ospf, interval);
2355
2356 return CMD_SUCCESS;
2357}
2358
paula2c62832003-04-23 17:01:31 +00002359DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002360 "no refresh timer <10-1800>",
2361 "Adjust refresh parameters\n"
2362 "Unset refresh timer\n"
2363 "Timer value in seconds\n")
2364{
2365 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002366 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002367
2368 if (argc == 1)
2369 {
2370 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2371
2372 if (ospf->lsa_refresh_interval != interval ||
2373 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2374 return CMD_SUCCESS;
2375 }
2376
2377 ospf_timers_refresh_unset (ospf);
2378
2379 return CMD_SUCCESS;
2380}
2381
paula2c62832003-04-23 17:01:31 +00002382ALIAS (no_ospf_refresh_timer,
2383 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002384 "no refresh timer",
2385 "Adjust refresh parameters\n"
2386 "Unset refresh timer\n")
2387
paula2c62832003-04-23 17:01:31 +00002388DEFUN (ospf_auto_cost_reference_bandwidth,
2389 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002390 "auto-cost reference-bandwidth <1-4294967>",
2391 "Calculate OSPF interface cost according to bandwidth\n"
2392 "Use reference bandwidth method to assign OSPF cost\n"
2393 "The reference bandwidth in terms of Mbits per second\n")
2394{
paul68980082003-03-25 05:07:42 +00002395 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002396 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002397 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002398 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002399
2400 refbw = strtol (argv[0], NULL, 10);
2401 if (refbw < 1 || refbw > 4294967)
2402 {
2403 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2404 return CMD_WARNING;
2405 }
2406
2407 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002408 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002409 return CMD_SUCCESS;
2410
paul68980082003-03-25 05:07:42 +00002411 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002412 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2413 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002414
2415 return CMD_SUCCESS;
2416}
2417
paula2c62832003-04-23 17:01:31 +00002418DEFUN (no_ospf_auto_cost_reference_bandwidth,
2419 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002420 "no auto-cost reference-bandwidth",
2421 NO_STR
2422 "Calculate OSPF interface cost according to bandwidth\n"
2423 "Use reference bandwidth method to assign OSPF cost\n")
2424{
paul68980082003-03-25 05:07:42 +00002425 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002426 struct listnode *node, *nnode;
2427 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002428
paul68980082003-03-25 05:07:42 +00002429 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002430 return CMD_SUCCESS;
2431
paul68980082003-03-25 05:07:42 +00002432 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002433 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2434 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2435
paul1eb8ef22005-04-07 07:30:20 +00002436 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2437 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002438
2439 return CMD_SUCCESS;
2440}
2441
hassoeb1ce602004-10-08 08:17:22 +00002442const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002443{
2444 "Unknown",
2445 "Standard (RFC2328)",
2446 "Alternative IBM",
2447 "Alternative Cisco",
2448 "Alternative Shortcut"
2449};
2450
hassoeb1ce602004-10-08 08:17:22 +00002451const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002452{
2453 "Default",
2454 "Enabled",
2455 "Disabled"
2456};
2457
2458
2459
paul4dadc292005-05-06 21:37:42 +00002460static void
paul718e3742002-12-13 20:15:29 +00002461show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2462{
2463 /* Show Area ID. */
2464 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2465
2466 /* Show Area type/mode. */
2467 if (OSPF_IS_AREA_BACKBONE (area))
2468 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2469 else
2470 {
2471 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002472 vty_out (vty, " (Stub%s%s)",
2473 area->no_summary ? ", no summary" : "",
2474 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002475
paulb0a053b2003-06-22 09:04:47 +00002476 else if (area->external_routing == OSPF_AREA_NSSA)
2477 vty_out (vty, " (NSSA%s%s)",
2478 area->no_summary ? ", no summary" : "",
2479 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002480
2481 vty_out (vty, "%s", VTY_NEWLINE);
2482 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002483 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002484 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002485 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002486 }
2487
2488 /* Show number of interfaces. */
2489 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2490 "Active: %d%s", listcount (area->oiflist),
2491 area->act_ints, VTY_NEWLINE);
2492
paul718e3742002-12-13 20:15:29 +00002493 if (area->external_routing == OSPF_AREA_NSSA)
2494 {
2495 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 +00002496 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002497 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2498 VTY_NEWLINE);
2499 else if (area->NSSATranslatorState)
2500 {
2501 vty_out (vty, " We are an ABR and ");
2502 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2503 vty_out (vty, "the NSSA Elected Translator. %s",
2504 VTY_NEWLINE);
2505 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2506 vty_out (vty, "always an NSSA Translator. %s",
2507 VTY_NEWLINE);
2508 }
paul718e3742002-12-13 20:15:29 +00002509 else
paulb0a053b2003-06-22 09:04:47 +00002510 {
2511 vty_out (vty, " We are an ABR, but ");
2512 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2513 vty_out (vty, "not the NSSA Elected Translator. %s",
2514 VTY_NEWLINE);
2515 else
hassoc6b87812004-12-22 13:09:59 +00002516 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002517 VTY_NEWLINE);
2518 }
paul718e3742002-12-13 20:15:29 +00002519 }
paul718e3742002-12-13 20:15:29 +00002520
2521 /* Show number of fully adjacent neighbors. */
2522 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002523 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002524
2525 /* Show authentication type. */
2526 vty_out (vty, " Area has ");
2527 if (area->auth_type == OSPF_AUTH_NULL)
2528 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2529 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2530 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2531 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2532 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2533
2534 if (!OSPF_IS_AREA_BACKBONE (area))
2535 vty_out (vty, " Number of full virtual adjacencies going through"
2536 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2537
2538 /* Show SPF calculation times. */
2539 vty_out (vty, " SPF algorithm executed %d times%s",
2540 area->spf_calculation, VTY_NEWLINE);
2541
2542 /* Show number of LSA. */
2543 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002544 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2545 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2546 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2547 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2548 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2549 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2550 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2551 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2552 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2553 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2554 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2555 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2556 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2557 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2558 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2559#ifdef HAVE_OPAQUE_LSA
2560 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2561 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2562 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2563 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2564 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2565 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2566#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002567 vty_out (vty, "%s", VTY_NEWLINE);
2568}
2569
2570DEFUN (show_ip_ospf,
2571 show_ip_ospf_cmd,
2572 "show ip ospf",
2573 SHOW_STR
2574 IP_STR
2575 "OSPF information\n")
2576{
paul1eb8ef22005-04-07 07:30:20 +00002577 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002578 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002579 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002580 struct timeval result;
2581 char timebuf[13]; /* XX:XX:XX.XXX(nul) */
paul718e3742002-12-13 20:15:29 +00002582
2583 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002584 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002585 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002586 {
2587 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2588 return CMD_SUCCESS;
2589 }
2590
2591 /* Show Router ID. */
2592 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002593 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002594 VTY_NEWLINE);
2595
2596 /* Show capability. */
2597 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2598 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2599 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002600 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002601 "enabled" : "disabled", VTY_NEWLINE);
2602#ifdef HAVE_OPAQUE_LSA
2603 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002604 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002605 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002606 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002607 " (origination blocked)" : "",
2608 VTY_NEWLINE);
2609#endif /* HAVE_OPAQUE_LSA */
2610
2611 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002612 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2613 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2614 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2615 " Hold time multiplier is currently %d%s",
2616 ospf->spf_delay, VTY_NEWLINE,
2617 ospf->spf_holdtime, VTY_NEWLINE,
2618 ospf->spf_max_holdtime, VTY_NEWLINE,
2619 ospf->spf_hold_multiplier, VTY_NEWLINE);
2620 timersub (&recent_time, &ospf->ts_spf, &result);
2621 vty_out (vty, " SPF algorithm last executed %s ago%s",
2622 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2623 VTY_NEWLINE);
2624 vty_out (vty, " SPF timer %s%s%s",
2625 (ospf->t_spf_calc ? "due in " : "is "),
2626 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2627 VTY_NEWLINE);
2628
paul718e3742002-12-13 20:15:29 +00002629 /* Show refresh parameters. */
2630 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002631 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002632
2633 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002634 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002635 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002636 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002637
paul68980082003-03-25 05:07:42 +00002638 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002639 vty_out (vty, " This router is an ASBR "
2640 "(injecting external routing information)%s", VTY_NEWLINE);
2641
2642 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002643 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2644 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2645 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2646#ifdef HAVE_OPAQUE_LSA
2647 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2648 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2649 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2650#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002651 /* Show number of areas attached. */
2652 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002653 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002654
2655 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002656 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2657 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002658
2659 return CMD_SUCCESS;
2660}
2661
2662
ajsfd651fa2005-03-29 16:08:16 +00002663static void
paul68980082003-03-25 05:07:42 +00002664show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2665 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002666{
ajsfd651fa2005-03-29 16:08:16 +00002667 int is_up;
paul718e3742002-12-13 20:15:29 +00002668 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002669 struct route_node *rn;
2670 char buf[9];
2671
paul718e3742002-12-13 20:15:29 +00002672 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002673 vty_out (vty, "%s is %s%s", ifp->name,
2674 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002675 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2676 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2677 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002678
2679 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002680 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002681 {
2682 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2683 return;
2684 }
ajsfd651fa2005-03-29 16:08:16 +00002685 else if (!is_up)
2686 {
2687 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2688 VTY_NEWLINE);
2689 return;
2690 }
2691
paul718e3742002-12-13 20:15:29 +00002692 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2693 {
2694 struct ospf_interface *oi = rn->info;
2695
2696 if (oi == NULL)
2697 continue;
2698
2699 /* Show OSPF interface information. */
2700 vty_out (vty, " Internet Address %s/%d,",
2701 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2702
hasso3fb9cd62004-10-19 19:44:43 +00002703 if (oi->connected->destination)
2704 vty_out (vty, " %s %s,",
2705 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2706 inet_ntoa (oi->connected->destination->u.prefix4));
2707
paul718e3742002-12-13 20:15:29 +00002708 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2709 VTY_NEWLINE);
2710
vincentba682532005-09-29 13:52:57 +00002711 vty_out (vty, " MTU mismatch detection:%s%s",
2712 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2713
paul718e3742002-12-13 20:15:29 +00002714 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002715 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002716 oi->output_cost, VTY_NEWLINE);
2717
2718 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2719 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2720 PRIORITY (oi), VTY_NEWLINE);
2721
2722 /* Show DR information. */
2723 if (DR (oi).s_addr == 0)
2724 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2725 else
2726 {
2727 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2728 if (nbr == NULL)
2729 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2730 else
2731 {
2732 vty_out (vty, " Designated Router (ID) %s,",
2733 inet_ntoa (nbr->router_id));
2734 vty_out (vty, " Interface Address %s%s",
2735 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2736 }
2737 }
2738
2739 /* Show BDR information. */
2740 if (BDR (oi).s_addr == 0)
2741 vty_out (vty, " No backup designated router on this network%s",
2742 VTY_NEWLINE);
2743 else
2744 {
2745 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2746 if (nbr == NULL)
2747 vty_out (vty, " No backup designated router on this network%s",
2748 VTY_NEWLINE);
2749 else
2750 {
2751 vty_out (vty, " Backup Designated Router (ID) %s,",
2752 inet_ntoa (nbr->router_id));
2753 vty_out (vty, " Interface Address %s%s",
2754 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2755 }
2756 }
ajsba6454e2005-02-08 15:37:30 +00002757
2758 vty_out (vty, " Multicast group memberships:");
2759 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2760 vty_out (vty, " OSPFAllRouters");
2761 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2762 vty_out (vty, " OSPFDesignatedRouters");
2763 if (!CHECK_FLAG(oi->multicast_memberships,
2764 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2765 vty_out (vty, " <None>");
2766 vty_out (vty, "%s", VTY_NEWLINE);
2767
paul718e3742002-12-13 20:15:29 +00002768 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002769 vty_out (vty, " Hello ");
2770 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2771 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2772 else
2773 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2774 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2775 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002776 OSPF_IF_PARAM (oi, v_wait),
2777 OSPF_IF_PARAM (oi, retransmit_interval),
2778 VTY_NEWLINE);
2779
2780 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002781 {
2782 int timer_slen = 9; /* length of "hh:mm:ss(nul)" */
2783
2784 /* for fast hello we also want to see the .XXXX ms part */
2785 if (OSPF_IF_PARAM (oi, fast_hello))
2786 timer_slen += 5;
2787
2788 vty_out (vty, " Hello due in %s%s",
2789 ospf_timer_dump (oi->t_hello, buf, timer_slen),
2790 VTY_NEWLINE);
2791 }
paul718e3742002-12-13 20:15:29 +00002792 else /* OSPF_IF_PASSIVE is set */
2793 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2794
2795 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002796 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002797 VTY_NEWLINE);
2798 }
2799}
2800
2801DEFUN (show_ip_ospf_interface,
2802 show_ip_ospf_interface_cmd,
2803 "show ip ospf interface [INTERFACE]",
2804 SHOW_STR
2805 IP_STR
2806 "OSPF information\n"
2807 "Interface information\n"
2808 "Interface name\n")
2809{
2810 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002811 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002812 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002813
paul020709f2003-04-04 02:44:16 +00002814 ospf = ospf_lookup ();
2815
paul718e3742002-12-13 20:15:29 +00002816 /* Show All Interfaces. */
2817 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002818 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2819 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002820 /* Interface name is specified. */
2821 else
2822 {
2823 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2824 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2825 else
paul68980082003-03-25 05:07:42 +00002826 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002827 }
2828
2829 return CMD_SUCCESS;
2830}
2831
paul4dadc292005-05-06 21:37:42 +00002832static void
pauld24f6e22005-10-21 09:23:12 +00002833show_ip_ospf_neighbour_header (struct vty *vty)
2834{
2835 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2836 VTY_NEWLINE,
2837 "Neighbor ID", "Pri", "State", "Dead Time",
2838 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
2839 VTY_NEWLINE);
2840}
2841
2842static void
paul718e3742002-12-13 20:15:29 +00002843show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2844{
2845 struct route_node *rn;
2846 struct ospf_neighbor *nbr;
2847 char msgbuf[16];
pauld24f6e22005-10-21 09:23:12 +00002848 char timebuf[14];
paul718e3742002-12-13 20:15:29 +00002849
2850 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2851 if ((nbr = rn->info))
2852 /* Do not show myself. */
2853 if (nbr != oi->nbr_self)
2854 /* Down state is not shown. */
2855 if (nbr->state != NSM_Down)
2856 {
2857 ospf_nbr_state_message (nbr, msgbuf, 16);
2858
2859 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00002860 vty_out (vty, "%-15s %3d %-15s ",
2861 "-", nbr->priority,
2862 msgbuf);
2863 else
2864 vty_out (vty, "%-15s %3d %-15s ",
2865 inet_ntoa (nbr->router_id), nbr->priority,
2866 msgbuf);
2867
2868 vty_out (vty, "%9s ",
2869 ospf_timer_dump (nbr->t_inactivity, timebuf,
2870 sizeof(timebuf)));
2871
paul718e3742002-12-13 20:15:29 +00002872 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00002873 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00002874 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2875 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2876 VTY_NEWLINE);
2877 }
2878}
2879
2880DEFUN (show_ip_ospf_neighbor,
2881 show_ip_ospf_neighbor_cmd,
2882 "show ip ospf neighbor",
2883 SHOW_STR
2884 IP_STR
2885 "OSPF information\n"
2886 "Neighbor list\n")
2887{
paul020709f2003-04-04 02:44:16 +00002888 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002889 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002890 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002891
paul020709f2003-04-04 02:44:16 +00002892 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002893 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002894 {
2895 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2896 return CMD_SUCCESS;
2897 }
2898
pauld24f6e22005-10-21 09:23:12 +00002899 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00002900
paul1eb8ef22005-04-07 07:30:20 +00002901 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
2902 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00002903
2904 return CMD_SUCCESS;
2905}
2906
2907DEFUN (show_ip_ospf_neighbor_all,
2908 show_ip_ospf_neighbor_all_cmd,
2909 "show ip ospf neighbor all",
2910 SHOW_STR
2911 IP_STR
2912 "OSPF information\n"
2913 "Neighbor list\n"
2914 "include down status neighbor\n")
2915{
paul68980082003-03-25 05:07:42 +00002916 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002917 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002918 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002919
paul68980082003-03-25 05:07:42 +00002920 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002921 {
2922 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2923 return CMD_SUCCESS;
2924 }
pauld24f6e22005-10-21 09:23:12 +00002925
2926 show_ip_ospf_neighbour_header (vty);
2927
paul1eb8ef22005-04-07 07:30:20 +00002928 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00002929 {
hasso52dc7ee2004-09-23 19:18:23 +00002930 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00002931 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00002932
2933 show_ip_ospf_neighbor_sub (vty, oi);
2934
2935 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00002936 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00002937 {
paul718e3742002-12-13 20:15:29 +00002938 if (nbr_nbma->nbr == NULL
2939 || nbr_nbma->nbr->state == NSM_Down)
2940 {
pauld24f6e22005-10-21 09:23:12 +00002941 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00002942 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00002943 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00002944 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2945 0, 0, 0, VTY_NEWLINE);
2946 }
2947 }
2948 }
2949
2950 return CMD_SUCCESS;
2951}
2952
2953DEFUN (show_ip_ospf_neighbor_int,
2954 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00002955 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00002956 SHOW_STR
2957 IP_STR
2958 "OSPF information\n"
2959 "Neighbor list\n"
2960 "Interface name\n")
2961{
paul020709f2003-04-04 02:44:16 +00002962 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00002963 struct interface *ifp;
2964 struct route_node *rn;
2965
2966 ifp = if_lookup_by_name (argv[0]);
2967 if (!ifp)
paul718e3742002-12-13 20:15:29 +00002968 {
hassobb5b7552005-08-21 20:01:15 +00002969 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002970 return CMD_WARNING;
2971 }
2972
paul020709f2003-04-04 02:44:16 +00002973 ospf = ospf_lookup ();
2974 if (ospf == NULL)
2975 {
2976 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2977 return CMD_SUCCESS;
2978 }
pauld24f6e22005-10-21 09:23:12 +00002979
2980 show_ip_ospf_neighbour_header (vty);
2981
hassobb5b7552005-08-21 20:01:15 +00002982 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00002983 {
hassobb5b7552005-08-21 20:01:15 +00002984 struct ospf_interface *oi = rn->info;
2985
2986 if (oi == NULL)
2987 continue;
2988
paul718e3742002-12-13 20:15:29 +00002989 show_ip_ospf_neighbor_sub (vty, oi);
2990 }
2991
2992 return CMD_SUCCESS;
2993}
2994
paul4dadc292005-05-06 21:37:42 +00002995static void
paul718e3742002-12-13 20:15:29 +00002996show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2997 struct ospf_nbr_nbma *nbr_nbma)
2998{
2999 char timebuf[9];
3000
3001 /* Show neighbor ID. */
3002 vty_out (vty, " Neighbor %s,", "-");
3003
3004 /* Show interface address. */
3005 vty_out (vty, " interface address %s%s",
3006 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3007 /* Show Area ID. */
3008 vty_out (vty, " In the area %s via interface %s%s",
3009 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3010 /* Show neighbor priority and state. */
3011 vty_out (vty, " Neighbor priority is %d, State is %s,",
3012 nbr_nbma->priority, "Down");
3013 /* Show state changes. */
3014 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3015
3016 /* Show PollInterval */
3017 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3018
3019 /* Show poll-interval timer. */
3020 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003021 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3022 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003023
3024 /* Show poll-interval timer thread. */
3025 vty_out (vty, " Thread Poll Timer %s%s",
3026 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3027}
3028
paul4dadc292005-05-06 21:37:42 +00003029static void
paul718e3742002-12-13 20:15:29 +00003030show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3031 struct ospf_neighbor *nbr)
3032{
3033 char timebuf[9];
3034
3035 /* Show neighbor ID. */
3036 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3037 vty_out (vty, " Neighbor %s,", "-");
3038 else
3039 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3040
3041 /* Show interface address. */
3042 vty_out (vty, " interface address %s%s",
3043 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3044 /* Show Area ID. */
3045 vty_out (vty, " In the area %s via interface %s%s",
3046 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3047 /* Show neighbor priority and state. */
3048 vty_out (vty, " Neighbor priority is %d, State is %s,",
3049 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3050 /* Show state changes. */
3051 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3052
3053 /* Show Designated Rotuer ID. */
3054 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3055 /* Show Backup Designated Rotuer ID. */
3056 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3057 /* Show options. */
3058 vty_out (vty, " Options %d %s%s", nbr->options,
3059 ospf_options_dump (nbr->options), VTY_NEWLINE);
3060 /* Show Router Dead interval timer. */
3061 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003062 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3063 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003064 /* Show Database Summary list. */
3065 vty_out (vty, " Database Summary List %d%s",
3066 ospf_db_summary_count (nbr), VTY_NEWLINE);
3067 /* Show Link State Request list. */
3068 vty_out (vty, " Link State Request List %ld%s",
3069 ospf_ls_request_count (nbr), VTY_NEWLINE);
3070 /* Show Link State Retransmission list. */
3071 vty_out (vty, " Link State Retransmission List %ld%s",
3072 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3073 /* Show inactivity timer thread. */
3074 vty_out (vty, " Thread Inactivity Timer %s%s",
3075 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3076 /* Show Database Description retransmission thread. */
3077 vty_out (vty, " Thread Database Description Retransmision %s%s",
3078 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3079 /* Show Link State Request Retransmission thread. */
3080 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3081 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3082 /* Show Link State Update Retransmission thread. */
3083 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3084 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3085}
3086
3087DEFUN (show_ip_ospf_neighbor_id,
3088 show_ip_ospf_neighbor_id_cmd,
3089 "show ip ospf neighbor A.B.C.D",
3090 SHOW_STR
3091 IP_STR
3092 "OSPF information\n"
3093 "Neighbor list\n"
3094 "Neighbor ID\n")
3095{
paul020709f2003-04-04 02:44:16 +00003096 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003097 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003098 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003099 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003100 struct in_addr router_id;
3101 int ret;
3102
3103 ret = inet_aton (argv[0], &router_id);
3104 if (!ret)
3105 {
3106 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3107 return CMD_WARNING;
3108 }
3109
paul020709f2003-04-04 02:44:16 +00003110 ospf = ospf_lookup ();
3111 if (ospf == NULL)
3112 {
3113 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3114 return CMD_SUCCESS;
3115 }
3116
paul1eb8ef22005-04-07 07:30:20 +00003117 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3118 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3119 {
3120 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3121 return CMD_SUCCESS;
3122 }
paul718e3742002-12-13 20:15:29 +00003123
3124 /* Nothing to show. */
3125 return CMD_SUCCESS;
3126}
3127
3128DEFUN (show_ip_ospf_neighbor_detail,
3129 show_ip_ospf_neighbor_detail_cmd,
3130 "show ip ospf neighbor detail",
3131 SHOW_STR
3132 IP_STR
3133 "OSPF information\n"
3134 "Neighbor list\n"
3135 "detail of all neighbors\n")
3136{
paul020709f2003-04-04 02:44:16 +00003137 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003138 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003139 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003140
paul020709f2003-04-04 02:44:16 +00003141 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003142 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003143 {
3144 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3145 return CMD_SUCCESS;
3146 }
paul718e3742002-12-13 20:15:29 +00003147
paul1eb8ef22005-04-07 07:30:20 +00003148 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003149 {
paul718e3742002-12-13 20:15:29 +00003150 struct route_node *rn;
3151 struct ospf_neighbor *nbr;
3152
3153 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3154 if ((nbr = rn->info))
3155 if (nbr != oi->nbr_self)
3156 if (nbr->state != NSM_Down)
3157 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3158 }
3159
3160 return CMD_SUCCESS;
3161}
3162
3163DEFUN (show_ip_ospf_neighbor_detail_all,
3164 show_ip_ospf_neighbor_detail_all_cmd,
3165 "show ip ospf neighbor detail all",
3166 SHOW_STR
3167 IP_STR
3168 "OSPF information\n"
3169 "Neighbor list\n"
3170 "detail of all neighbors\n"
3171 "include down status neighbor\n")
3172{
paul020709f2003-04-04 02:44:16 +00003173 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003174 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003175 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003176
paul020709f2003-04-04 02:44:16 +00003177 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003178 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003179 {
3180 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3181 return CMD_SUCCESS;
3182 }
paul718e3742002-12-13 20:15:29 +00003183
paul1eb8ef22005-04-07 07:30:20 +00003184 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003185 {
paul718e3742002-12-13 20:15:29 +00003186 struct route_node *rn;
3187 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003188 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003189
3190 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3191 if ((nbr = rn->info))
3192 if (nbr != oi->nbr_self)
3193 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3194 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3195
3196 if (oi->type == OSPF_IFTYPE_NBMA)
3197 {
hasso52dc7ee2004-09-23 19:18:23 +00003198 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003199
paul1eb8ef22005-04-07 07:30:20 +00003200 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3201 if (nbr_nbma->nbr == NULL
3202 || nbr_nbma->nbr->state == NSM_Down)
3203 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003204 }
3205 }
3206
3207 return CMD_SUCCESS;
3208}
3209
3210DEFUN (show_ip_ospf_neighbor_int_detail,
3211 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003212 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003213 SHOW_STR
3214 IP_STR
3215 "OSPF information\n"
3216 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003217 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003218 "detail of all neighbors")
3219{
paul020709f2003-04-04 02:44:16 +00003220 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003221 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003222 struct interface *ifp;
3223 struct route_node *rn, *nrn;
3224 struct ospf_neighbor *nbr;
3225
3226 ifp = if_lookup_by_name (argv[0]);
3227 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003228 {
hassobb5b7552005-08-21 20:01:15 +00003229 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003230 return CMD_WARNING;
3231 }
3232
paul020709f2003-04-04 02:44:16 +00003233 ospf = ospf_lookup ();
3234 if (ospf == NULL)
3235 {
3236 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3237 return CMD_SUCCESS;
3238 }
paul68980082003-03-25 05:07:42 +00003239
paul718e3742002-12-13 20:15:29 +00003240
hassobb5b7552005-08-21 20:01:15 +00003241 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3242 if ((oi = rn->info))
3243 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3244 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003245 if (nbr != oi->nbr_self)
3246 if (nbr->state != NSM_Down)
3247 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003248
3249 return CMD_SUCCESS;
3250}
3251
3252
3253/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003254static int
paul020709f2003-04-04 02:44:16 +00003255show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003256{
paul718e3742002-12-13 20:15:29 +00003257 struct router_lsa *rl;
3258 struct summary_lsa *sl;
3259 struct as_external_lsa *asel;
3260 struct prefix_ipv4 p;
3261
3262 if (lsa != NULL)
3263 /* If self option is set, check LSA self flag. */
3264 if (self == 0 || IS_LSA_SELF (lsa))
3265 {
3266 /* LSA common part show. */
3267 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3268 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3269 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3270 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3271 /* LSA specific part show. */
3272 switch (lsa->data->type)
3273 {
3274 case OSPF_ROUTER_LSA:
3275 rl = (struct router_lsa *) lsa->data;
3276 vty_out (vty, " %-d", ntohs (rl->links));
3277 break;
3278 case OSPF_SUMMARY_LSA:
3279 sl = (struct summary_lsa *) lsa->data;
3280
3281 p.family = AF_INET;
3282 p.prefix = sl->header.id;
3283 p.prefixlen = ip_masklen (sl->mask);
3284 apply_mask_ipv4 (&p);
3285
3286 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3287 break;
3288 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003289 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003290 asel = (struct as_external_lsa *) lsa->data;
3291
3292 p.family = AF_INET;
3293 p.prefix = asel->header.id;
3294 p.prefixlen = ip_masklen (asel->mask);
3295 apply_mask_ipv4 (&p);
3296
3297 vty_out (vty, " %s %s/%d [0x%lx]",
3298 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3299 inet_ntoa (p.prefix), p.prefixlen,
3300 (u_long)ntohl (asel->e[0].route_tag));
3301 break;
3302 case OSPF_NETWORK_LSA:
3303 case OSPF_ASBR_SUMMARY_LSA:
3304#ifdef HAVE_OPAQUE_LSA
3305 case OSPF_OPAQUE_LINK_LSA:
3306 case OSPF_OPAQUE_AREA_LSA:
3307 case OSPF_OPAQUE_AS_LSA:
3308#endif /* HAVE_OPAQUE_LSA */
3309 default:
3310 break;
3311 }
3312 vty_out (vty, VTY_NEWLINE);
3313 }
3314
3315 return 0;
3316}
3317
hassoeb1ce602004-10-08 08:17:22 +00003318const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003319{
3320 "unknown",
3321 "Router Link States",
3322 "Net Link States",
3323 "Summary Link States",
3324 "ASBR-Summary Link States",
3325 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003326 "Group Membership LSA",
3327 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003328#ifdef HAVE_OPAQUE_LSA
3329 "Type-8 LSA",
3330 "Link-Local Opaque-LSA",
3331 "Area-Local Opaque-LSA",
3332 "AS-external Opaque-LSA",
3333#endif /* HAVE_OPAQUE_LSA */
3334};
3335
3336#define SHOW_OSPF_COMMON_HEADER \
3337 "Link ID ADV Router Age Seq# CkSum"
3338
hassoeb1ce602004-10-08 08:17:22 +00003339const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003340{
3341 "",
3342 "Link ID ADV Router Age Seq# CkSum Link count",
3343 "Link ID ADV Router Age Seq# CkSum",
3344 "Link ID ADV Router Age Seq# CkSum Route",
3345 "Link ID ADV Router Age Seq# CkSum",
3346 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003347 " --- header for Group Member ----",
3348 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003349#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003350 " --- type-8 ---",
3351 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3352 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3353 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3354#endif /* HAVE_OPAQUE_LSA */
3355};
3356
hassoeb1ce602004-10-08 08:17:22 +00003357const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003358{
3359 "Self-originated",
3360 "Checked",
3361 "Received",
3362 "Approved",
3363 "Discard",
paul4957f492003-06-27 01:28:45 +00003364 "Translated",
paul4957f492003-06-27 01:28:45 +00003365};
3366
paul4dadc292005-05-06 21:37:42 +00003367static void
paul718e3742002-12-13 20:15:29 +00003368show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3369{
3370 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003371
paul718e3742002-12-13 20:15:29 +00003372 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003373 vty_out (vty, " Options: 0x%-2x : %s%s",
3374 lsa->data->options,
3375 ospf_options_dump(lsa->data->options),
3376 VTY_NEWLINE);
3377 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003378 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003379 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3380 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003381
3382 if (lsa->data->type == OSPF_ROUTER_LSA)
3383 {
3384 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3385
3386 if (rlsa->flags)
3387 vty_out (vty, " :%s%s%s%s",
3388 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3389 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3390 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3391 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3392
3393 vty_out (vty, "%s", VTY_NEWLINE);
3394 }
3395 vty_out (vty, " LS Type: %s%s",
3396 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3397 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3398 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3399 vty_out (vty, " Advertising Router: %s%s",
3400 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3401 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3402 VTY_NEWLINE);
3403 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3404 VTY_NEWLINE);
3405 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3406}
3407
hassoeb1ce602004-10-08 08:17:22 +00003408const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003409{
3410 "(null)",
3411 "another Router (point-to-point)",
3412 "a Transit Network",
3413 "Stub Network",
3414 "a Virtual Link",
3415};
3416
hassoeb1ce602004-10-08 08:17:22 +00003417const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003418{
3419 "(null)",
3420 "Neighboring Router ID",
3421 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003422 "Net",
paul718e3742002-12-13 20:15:29 +00003423 "Neighboring Router ID",
3424};
3425
hassoeb1ce602004-10-08 08:17:22 +00003426const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003427{
3428 "(null)",
3429 "Router Interface address",
3430 "Router Interface address",
3431 "Network Mask",
3432 "Router Interface address",
3433};
3434
3435/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003436static void
paul718e3742002-12-13 20:15:29 +00003437show_ip_ospf_database_router_links (struct vty *vty,
3438 struct router_lsa *rl)
3439{
3440 int len, i, type;
3441
3442 len = ntohs (rl->header.length) - 4;
3443 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3444 {
3445 type = rl->link[i].type;
3446
3447 vty_out (vty, " Link connected to: %s%s",
3448 link_type_desc[type], VTY_NEWLINE);
3449 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3450 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3451 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3452 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3453 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3454 vty_out (vty, " TOS 0 Metric: %d%s",
3455 ntohs (rl->link[i].metric), VTY_NEWLINE);
3456 vty_out (vty, "%s", VTY_NEWLINE);
3457 }
3458}
3459
3460/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003461static int
paul718e3742002-12-13 20:15:29 +00003462show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3463{
3464 if (lsa != NULL)
3465 {
3466 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3467
3468 show_ip_ospf_database_header (vty, lsa);
3469
3470 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3471 VTY_NEWLINE, VTY_NEWLINE);
3472
3473 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003474 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003475 }
3476
3477 return 0;
3478}
3479
3480/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003481static int
paul718e3742002-12-13 20:15:29 +00003482show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3483{
3484 int length, i;
3485
3486 if (lsa != NULL)
3487 {
3488 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3489
3490 show_ip_ospf_database_header (vty, lsa);
3491
3492 vty_out (vty, " Network Mask: /%d%s",
3493 ip_masklen (nl->mask), VTY_NEWLINE);
3494
3495 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3496
3497 for (i = 0; length > 0; i++, length -= 4)
3498 vty_out (vty, " Attached Router: %s%s",
3499 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3500
3501 vty_out (vty, "%s", VTY_NEWLINE);
3502 }
3503
3504 return 0;
3505}
3506
3507/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003508static int
paul718e3742002-12-13 20:15:29 +00003509show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3510{
3511 if (lsa != NULL)
3512 {
3513 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3514
3515 show_ip_ospf_database_header (vty, lsa);
3516
3517 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3518 VTY_NEWLINE);
3519 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3520 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003521 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003522 }
3523
3524 return 0;
3525}
3526
3527/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003528static int
paul718e3742002-12-13 20:15:29 +00003529show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3530{
3531 if (lsa != NULL)
3532 {
3533 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3534
3535 show_ip_ospf_database_header (vty, lsa);
3536
3537 vty_out (vty, " Network Mask: /%d%s",
3538 ip_masklen (sl->mask), VTY_NEWLINE);
3539 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3540 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003541 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003542 }
3543
3544 return 0;
3545}
3546
3547/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003548static int
paul718e3742002-12-13 20:15:29 +00003549show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3550{
3551 if (lsa != NULL)
3552 {
3553 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3554
3555 show_ip_ospf_database_header (vty, lsa);
3556
3557 vty_out (vty, " Network Mask: /%d%s",
3558 ip_masklen (al->mask), VTY_NEWLINE);
3559 vty_out (vty, " Metric Type: %s%s",
3560 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3561 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3562 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3563 vty_out (vty, " Metric: %d%s",
3564 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3565 vty_out (vty, " Forward Address: %s%s",
3566 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3567
3568 vty_out (vty, " External Route Tag: %lu%s%s",
3569 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3570 }
3571
3572 return 0;
3573}
3574
ajs2a42e282004-12-08 18:43:03 +00003575/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003576static int
paul718e3742002-12-13 20:15:29 +00003577show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3578{
3579 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3580
3581 /* show_ip_ospf_database_header (vty, lsa); */
3582
ajs2a42e282004-12-08 18:43:03 +00003583 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003584 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003585 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003586 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3587 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003588 zlog_debug( " TOS: 0%s", "\n");
3589 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003590 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003591 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003592 inet_ntoa (al->e[0].fwd_addr), "\n");
3593
ajs2a42e282004-12-08 18:43:03 +00003594 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003595 ntohl (al->e[0].route_tag), "\n", "\n");
3596
3597 return 0;
3598}
3599
3600/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003601static int
paul718e3742002-12-13 20:15:29 +00003602show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3603{
3604 if (lsa != NULL)
3605 {
3606 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3607
3608 show_ip_ospf_database_header (vty, lsa);
3609
3610 vty_out (vty, " Network Mask: /%d%s",
3611 ip_masklen (al->mask), VTY_NEWLINE);
3612 vty_out (vty, " Metric Type: %s%s",
3613 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3614 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3615 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3616 vty_out (vty, " Metric: %d%s",
3617 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3618 vty_out (vty, " NSSA: Forward Address: %s%s",
3619 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3620
3621 vty_out (vty, " External Route Tag: %u%s%s",
3622 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3623 }
3624
3625 return 0;
3626}
3627
paul4dadc292005-05-06 21:37:42 +00003628static int
paul718e3742002-12-13 20:15:29 +00003629show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3630{
3631 return 0;
3632}
3633
3634#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003635static int
paul718e3742002-12-13 20:15:29 +00003636show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3637{
3638 if (lsa != NULL)
3639 {
3640 show_ip_ospf_database_header (vty, lsa);
3641 show_opaque_info_detail (vty, lsa);
3642
3643 vty_out (vty, "%s", VTY_NEWLINE);
3644 }
3645 return 0;
3646}
3647#endif /* HAVE_OPAQUE_LSA */
3648
3649int (*show_function[])(struct vty *, struct ospf_lsa *) =
3650{
3651 NULL,
3652 show_router_lsa_detail,
3653 show_network_lsa_detail,
3654 show_summary_lsa_detail,
3655 show_summary_asbr_lsa_detail,
3656 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003657 show_func_dummy,
3658 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003659#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003660 NULL, /* type-8 */
3661 show_opaque_lsa_detail,
3662 show_opaque_lsa_detail,
3663 show_opaque_lsa_detail,
3664#endif /* HAVE_OPAQUE_LSA */
3665};
3666
paul4dadc292005-05-06 21:37:42 +00003667static void
paul718e3742002-12-13 20:15:29 +00003668show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3669 struct in_addr *adv_router)
3670{
3671 memset (lp, 0, sizeof (struct prefix_ls));
3672 lp->family = 0;
3673 if (id == NULL)
3674 lp->prefixlen = 0;
3675 else if (adv_router == NULL)
3676 {
3677 lp->prefixlen = 32;
3678 lp->id = *id;
3679 }
3680 else
3681 {
3682 lp->prefixlen = 64;
3683 lp->id = *id;
3684 lp->adv_router = *adv_router;
3685 }
3686}
3687
paul4dadc292005-05-06 21:37:42 +00003688static void
paul718e3742002-12-13 20:15:29 +00003689show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3690 struct in_addr *id, struct in_addr *adv_router)
3691{
3692 struct prefix_ls lp;
3693 struct route_node *rn, *start;
3694 struct ospf_lsa *lsa;
3695
3696 show_lsa_prefix_set (vty, &lp, id, adv_router);
3697 start = route_node_get (rt, (struct prefix *) &lp);
3698 if (start)
3699 {
3700 route_lock_node (start);
3701 for (rn = start; rn; rn = route_next_until (rn, start))
3702 if ((lsa = rn->info))
3703 {
paul718e3742002-12-13 20:15:29 +00003704 if (show_function[lsa->data->type] != NULL)
3705 show_function[lsa->data->type] (vty, lsa);
3706 }
3707 route_unlock_node (start);
3708 }
3709}
3710
3711/* Show detail LSA information
3712 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003713static void
paul020709f2003-04-04 02:44:16 +00003714show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003715 struct in_addr *id, struct in_addr *adv_router)
3716{
hasso52dc7ee2004-09-23 19:18:23 +00003717 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003718 struct ospf_area *area;
3719
paul718e3742002-12-13 20:15:29 +00003720 switch (type)
3721 {
3722 case OSPF_AS_EXTERNAL_LSA:
3723#ifdef HAVE_OPAQUE_LSA
3724 case OSPF_OPAQUE_AS_LSA:
3725#endif /* HAVE_OPAQUE_LSA */
3726 vty_out (vty, " %s %s%s",
3727 show_database_desc[type],
3728 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003729 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003730 break;
3731 default:
paul1eb8ef22005-04-07 07:30:20 +00003732 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003733 {
paul718e3742002-12-13 20:15:29 +00003734 vty_out (vty, "%s %s (Area %s)%s%s",
3735 VTY_NEWLINE, show_database_desc[type],
3736 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3737 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3738 }
3739 break;
3740 }
3741}
3742
paul4dadc292005-05-06 21:37:42 +00003743static void
paul718e3742002-12-13 20:15:29 +00003744show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3745 struct in_addr *adv_router)
3746{
3747 struct route_node *rn;
3748 struct ospf_lsa *lsa;
3749
3750 for (rn = route_top (rt); rn; rn = route_next (rn))
3751 if ((lsa = rn->info))
3752 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3753 {
paul718e3742002-12-13 20:15:29 +00003754 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3755 continue;
paul718e3742002-12-13 20:15:29 +00003756 if (show_function[lsa->data->type] != NULL)
3757 show_function[lsa->data->type] (vty, lsa);
3758 }
3759}
3760
3761/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003762static void
paul020709f2003-04-04 02:44:16 +00003763show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003764 struct in_addr *adv_router)
3765{
hasso52dc7ee2004-09-23 19:18:23 +00003766 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003767 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003768
3769 switch (type)
3770 {
3771 case OSPF_AS_EXTERNAL_LSA:
3772#ifdef HAVE_OPAQUE_LSA
3773 case OSPF_OPAQUE_AS_LSA:
3774#endif /* HAVE_OPAQUE_LSA */
3775 vty_out (vty, " %s %s%s",
3776 show_database_desc[type],
3777 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003778 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003779 adv_router);
3780 break;
3781 default:
paul1eb8ef22005-04-07 07:30:20 +00003782 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003783 {
paul718e3742002-12-13 20:15:29 +00003784 vty_out (vty, "%s %s (Area %s)%s%s",
3785 VTY_NEWLINE, show_database_desc[type],
3786 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3787 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3788 adv_router);
3789 }
3790 break;
3791 }
3792}
3793
paul4dadc292005-05-06 21:37:42 +00003794static void
paul020709f2003-04-04 02:44:16 +00003795show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003796{
paul020709f2003-04-04 02:44:16 +00003797 struct ospf_lsa *lsa;
3798 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003799 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003800 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003801 int type;
3802
paul1eb8ef22005-04-07 07:30:20 +00003803 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003804 {
paul718e3742002-12-13 20:15:29 +00003805 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3806 {
3807 switch (type)
3808 {
3809 case OSPF_AS_EXTERNAL_LSA:
3810#ifdef HAVE_OPAQUE_LSA
3811 case OSPF_OPAQUE_AS_LSA:
3812#endif /* HAVE_OPAQUE_LSA */
3813 continue;
3814 default:
3815 break;
3816 }
3817 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3818 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3819 {
3820 vty_out (vty, " %s (Area %s)%s%s",
3821 show_database_desc[type],
3822 ospf_area_desc_string (area),
3823 VTY_NEWLINE, VTY_NEWLINE);
3824 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3825
paul020709f2003-04-04 02:44:16 +00003826 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3827 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003828
3829 vty_out (vty, "%s", VTY_NEWLINE);
3830 }
3831 }
3832 }
3833
3834 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3835 {
3836 switch (type)
3837 {
3838 case OSPF_AS_EXTERNAL_LSA:
3839#ifdef HAVE_OPAQUE_LSA
3840 case OSPF_OPAQUE_AS_LSA:
3841#endif /* HAVE_OPAQUE_LSA */
3842 break;;
3843 default:
3844 continue;
3845 }
paul68980082003-03-25 05:07:42 +00003846 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3847 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003848 {
3849 vty_out (vty, " %s%s%s",
3850 show_database_desc[type],
3851 VTY_NEWLINE, VTY_NEWLINE);
3852 vty_out (vty, "%s%s", show_database_header[type],
3853 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003854
3855 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3856 show_lsa_summary (vty, lsa, self);
3857
paul718e3742002-12-13 20:15:29 +00003858 vty_out (vty, "%s", VTY_NEWLINE);
3859 }
3860 }
3861
3862 vty_out (vty, "%s", VTY_NEWLINE);
3863}
3864
paul4dadc292005-05-06 21:37:42 +00003865static void
paul020709f2003-04-04 02:44:16 +00003866show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003867{
hasso52dc7ee2004-09-23 19:18:23 +00003868 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003869 struct ospf_lsa *lsa;
3870
3871 vty_out (vty, "%s MaxAge Link States:%s%s",
3872 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3873
paul1eb8ef22005-04-07 07:30:20 +00003874 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3875 {
3876 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3877 vty_out (vty, "Link State ID: %s%s",
3878 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3879 vty_out (vty, "Advertising Router: %s%s",
3880 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3881 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3882 vty_out (vty, "%s", VTY_NEWLINE);
3883 }
paul718e3742002-12-13 20:15:29 +00003884}
3885
paul718e3742002-12-13 20:15:29 +00003886#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3887#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003888
3889#ifdef HAVE_OPAQUE_LSA
3890#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3891#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3892#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3893#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3894#else /* HAVE_OPAQUE_LSA */
3895#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3896#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3897#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3898#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3899#endif /* HAVE_OPAQUE_LSA */
3900
3901#define OSPF_LSA_TYPES_CMD_STR \
3902 "asbr-summary|external|network|router|summary" \
3903 OSPF_LSA_TYPE_NSSA_CMD_STR \
3904 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3905
3906#define OSPF_LSA_TYPES_DESC \
3907 "ASBR summary link states\n" \
3908 "External link states\n" \
3909 "Network link states\n" \
3910 "Router link states\n" \
3911 "Network summary link states\n" \
3912 OSPF_LSA_TYPE_NSSA_DESC \
3913 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3914 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3915 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3916
3917DEFUN (show_ip_ospf_database,
3918 show_ip_ospf_database_cmd,
3919 "show ip ospf database",
3920 SHOW_STR
3921 IP_STR
3922 "OSPF information\n"
3923 "Database summary\n")
3924{
paul020709f2003-04-04 02:44:16 +00003925 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003926 int type, ret;
3927 struct in_addr id, adv_router;
3928
paul020709f2003-04-04 02:44:16 +00003929 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003930 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003931 return CMD_SUCCESS;
3932
3933 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003934 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003935
3936 /* Show all LSA. */
3937 if (argc == 0)
3938 {
paul020709f2003-04-04 02:44:16 +00003939 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003940 return CMD_SUCCESS;
3941 }
3942
3943 /* Set database type to show. */
3944 if (strncmp (argv[0], "r", 1) == 0)
3945 type = OSPF_ROUTER_LSA;
3946 else if (strncmp (argv[0], "ne", 2) == 0)
3947 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003948 else if (strncmp (argv[0], "ns", 2) == 0)
3949 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003950 else if (strncmp (argv[0], "su", 2) == 0)
3951 type = OSPF_SUMMARY_LSA;
3952 else if (strncmp (argv[0], "a", 1) == 0)
3953 type = OSPF_ASBR_SUMMARY_LSA;
3954 else if (strncmp (argv[0], "e", 1) == 0)
3955 type = OSPF_AS_EXTERNAL_LSA;
3956 else if (strncmp (argv[0], "se", 2) == 0)
3957 {
paul020709f2003-04-04 02:44:16 +00003958 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003959 return CMD_SUCCESS;
3960 }
3961 else if (strncmp (argv[0], "m", 1) == 0)
3962 {
paul020709f2003-04-04 02:44:16 +00003963 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003964 return CMD_SUCCESS;
3965 }
3966#ifdef HAVE_OPAQUE_LSA
3967 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3968 type = OSPF_OPAQUE_LINK_LSA;
3969 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3970 type = OSPF_OPAQUE_AREA_LSA;
3971 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3972 type = OSPF_OPAQUE_AS_LSA;
3973#endif /* HAVE_OPAQUE_LSA */
3974 else
3975 return CMD_WARNING;
3976
3977 /* `show ip ospf database LSA'. */
3978 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003979 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003980 else if (argc >= 2)
3981 {
3982 ret = inet_aton (argv[1], &id);
3983 if (!ret)
3984 return CMD_WARNING;
3985
3986 /* `show ip ospf database LSA ID'. */
3987 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003988 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003989 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3990 else if (argc == 3)
3991 {
3992 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003993 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003994 else
3995 {
3996 ret = inet_aton (argv[2], &adv_router);
3997 if (!ret)
3998 return CMD_WARNING;
3999 }
paul020709f2003-04-04 02:44:16 +00004000 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004001 }
4002 }
4003
4004 return CMD_SUCCESS;
4005}
4006
4007ALIAS (show_ip_ospf_database,
4008 show_ip_ospf_database_type_cmd,
4009 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4010 SHOW_STR
4011 IP_STR
4012 "OSPF information\n"
4013 "Database summary\n"
4014 OSPF_LSA_TYPES_DESC
4015 "LSAs in MaxAge list\n"
4016 "Self-originated link states\n")
4017
4018ALIAS (show_ip_ospf_database,
4019 show_ip_ospf_database_type_id_cmd,
4020 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4021 SHOW_STR
4022 IP_STR
4023 "OSPF information\n"
4024 "Database summary\n"
4025 OSPF_LSA_TYPES_DESC
4026 "Link State ID (as an IP address)\n")
4027
4028ALIAS (show_ip_ospf_database,
4029 show_ip_ospf_database_type_id_adv_router_cmd,
4030 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4031 SHOW_STR
4032 IP_STR
4033 "OSPF information\n"
4034 "Database summary\n"
4035 OSPF_LSA_TYPES_DESC
4036 "Link State ID (as an IP address)\n"
4037 "Advertising Router link states\n"
4038 "Advertising Router (as an IP address)\n")
4039
4040ALIAS (show_ip_ospf_database,
4041 show_ip_ospf_database_type_id_self_cmd,
4042 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4043 SHOW_STR
4044 IP_STR
4045 "OSPF information\n"
4046 "Database summary\n"
4047 OSPF_LSA_TYPES_DESC
4048 "Link State ID (as an IP address)\n"
4049 "Self-originated link states\n"
4050 "\n")
4051
4052DEFUN (show_ip_ospf_database_type_adv_router,
4053 show_ip_ospf_database_type_adv_router_cmd,
4054 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4055 SHOW_STR
4056 IP_STR
4057 "OSPF information\n"
4058 "Database summary\n"
4059 OSPF_LSA_TYPES_DESC
4060 "Advertising Router link states\n"
4061 "Advertising Router (as an IP address)\n")
4062{
paul020709f2003-04-04 02:44:16 +00004063 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004064 int type, ret;
4065 struct in_addr adv_router;
4066
paul020709f2003-04-04 02:44:16 +00004067 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004068 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00004069 return CMD_SUCCESS;
4070
4071 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004072 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004073
4074 if (argc != 2)
4075 return CMD_WARNING;
4076
4077 /* Set database type to show. */
4078 if (strncmp (argv[0], "r", 1) == 0)
4079 type = OSPF_ROUTER_LSA;
4080 else if (strncmp (argv[0], "ne", 2) == 0)
4081 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004082 else if (strncmp (argv[0], "ns", 2) == 0)
4083 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004084 else if (strncmp (argv[0], "s", 1) == 0)
4085 type = OSPF_SUMMARY_LSA;
4086 else if (strncmp (argv[0], "a", 1) == 0)
4087 type = OSPF_ASBR_SUMMARY_LSA;
4088 else if (strncmp (argv[0], "e", 1) == 0)
4089 type = OSPF_AS_EXTERNAL_LSA;
4090#ifdef HAVE_OPAQUE_LSA
4091 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4092 type = OSPF_OPAQUE_LINK_LSA;
4093 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4094 type = OSPF_OPAQUE_AREA_LSA;
4095 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4096 type = OSPF_OPAQUE_AS_LSA;
4097#endif /* HAVE_OPAQUE_LSA */
4098 else
4099 return CMD_WARNING;
4100
4101 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4102 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004103 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004104 else
4105 {
4106 ret = inet_aton (argv[1], &adv_router);
4107 if (!ret)
4108 return CMD_WARNING;
4109 }
4110
paul020709f2003-04-04 02:44:16 +00004111 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004112
4113 return CMD_SUCCESS;
4114}
4115
4116ALIAS (show_ip_ospf_database_type_adv_router,
4117 show_ip_ospf_database_type_self_cmd,
4118 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4119 SHOW_STR
4120 IP_STR
4121 "OSPF information\n"
4122 "Database summary\n"
4123 OSPF_LSA_TYPES_DESC
4124 "Self-originated link states\n")
4125
4126
4127DEFUN (ip_ospf_authentication_args,
4128 ip_ospf_authentication_args_addr_cmd,
4129 "ip ospf authentication (null|message-digest) A.B.C.D",
4130 "IP Information\n"
4131 "OSPF interface commands\n"
4132 "Enable authentication on this interface\n"
4133 "Use null authentication\n"
4134 "Use message-digest authentication\n"
4135 "Address of interface")
4136{
4137 struct interface *ifp;
4138 struct in_addr addr;
4139 int ret;
4140 struct ospf_if_params *params;
4141
4142 ifp = vty->index;
4143 params = IF_DEF_PARAMS (ifp);
4144
4145 if (argc == 2)
4146 {
4147 ret = inet_aton(argv[1], &addr);
4148 if (!ret)
4149 {
4150 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4151 VTY_NEWLINE);
4152 return CMD_WARNING;
4153 }
4154
4155 params = ospf_get_if_params (ifp, addr);
4156 ospf_if_update_params (ifp, addr);
4157 }
4158
4159 /* Handle null authentication */
4160 if ( argv[0][0] == 'n' )
4161 {
4162 SET_IF_PARAM (params, auth_type);
4163 params->auth_type = OSPF_AUTH_NULL;
4164 return CMD_SUCCESS;
4165 }
4166
4167 /* Handle message-digest authentication */
4168 if ( argv[0][0] == 'm' )
4169 {
4170 SET_IF_PARAM (params, auth_type);
4171 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4172 return CMD_SUCCESS;
4173 }
4174
4175 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4176 return CMD_WARNING;
4177}
4178
4179ALIAS (ip_ospf_authentication_args,
4180 ip_ospf_authentication_args_cmd,
4181 "ip ospf authentication (null|message-digest)",
4182 "IP Information\n"
4183 "OSPF interface commands\n"
4184 "Enable authentication on this interface\n"
4185 "Use null authentication\n"
4186 "Use message-digest authentication\n")
4187
4188DEFUN (ip_ospf_authentication,
4189 ip_ospf_authentication_addr_cmd,
4190 "ip ospf authentication A.B.C.D",
4191 "IP Information\n"
4192 "OSPF interface commands\n"
4193 "Enable authentication on this interface\n"
4194 "Address of interface")
4195{
4196 struct interface *ifp;
4197 struct in_addr addr;
4198 int ret;
4199 struct ospf_if_params *params;
4200
4201 ifp = vty->index;
4202 params = IF_DEF_PARAMS (ifp);
4203
4204 if (argc == 1)
4205 {
4206 ret = inet_aton(argv[1], &addr);
4207 if (!ret)
4208 {
4209 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4210 VTY_NEWLINE);
4211 return CMD_WARNING;
4212 }
4213
4214 params = ospf_get_if_params (ifp, addr);
4215 ospf_if_update_params (ifp, addr);
4216 }
4217
4218 SET_IF_PARAM (params, auth_type);
4219 params->auth_type = OSPF_AUTH_SIMPLE;
4220
4221 return CMD_SUCCESS;
4222}
4223
4224ALIAS (ip_ospf_authentication,
4225 ip_ospf_authentication_cmd,
4226 "ip ospf authentication",
4227 "IP Information\n"
4228 "OSPF interface commands\n"
4229 "Enable authentication on this interface\n")
4230
4231DEFUN (no_ip_ospf_authentication,
4232 no_ip_ospf_authentication_addr_cmd,
4233 "no ip ospf authentication A.B.C.D",
4234 NO_STR
4235 "IP Information\n"
4236 "OSPF interface commands\n"
4237 "Enable authentication on this interface\n"
4238 "Address of interface")
4239{
4240 struct interface *ifp;
4241 struct in_addr addr;
4242 int ret;
4243 struct ospf_if_params *params;
4244
4245 ifp = vty->index;
4246 params = IF_DEF_PARAMS (ifp);
4247
4248 if (argc == 1)
4249 {
4250 ret = inet_aton(argv[1], &addr);
4251 if (!ret)
4252 {
4253 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4254 VTY_NEWLINE);
4255 return CMD_WARNING;
4256 }
4257
4258 params = ospf_lookup_if_params (ifp, addr);
4259 if (params == NULL)
4260 return CMD_SUCCESS;
4261 }
4262
4263 params->auth_type = OSPF_AUTH_NOTSET;
4264 UNSET_IF_PARAM (params, auth_type);
4265
4266 if (params != IF_DEF_PARAMS (ifp))
4267 {
4268 ospf_free_if_params (ifp, addr);
4269 ospf_if_update_params (ifp, addr);
4270 }
4271
4272 return CMD_SUCCESS;
4273}
4274
4275ALIAS (no_ip_ospf_authentication,
4276 no_ip_ospf_authentication_cmd,
4277 "no ip ospf authentication",
4278 NO_STR
4279 "IP Information\n"
4280 "OSPF interface commands\n"
4281 "Enable authentication on this interface\n")
4282
4283DEFUN (ip_ospf_authentication_key,
4284 ip_ospf_authentication_key_addr_cmd,
4285 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4286 "IP Information\n"
4287 "OSPF interface commands\n"
4288 "Authentication password (key)\n"
4289 "The OSPF password (key)\n"
4290 "Address of interface")
4291{
4292 struct interface *ifp;
4293 struct in_addr addr;
4294 int ret;
4295 struct ospf_if_params *params;
4296
4297 ifp = vty->index;
4298 params = IF_DEF_PARAMS (ifp);
4299
4300 if (argc == 2)
4301 {
4302 ret = inet_aton(argv[1], &addr);
4303 if (!ret)
4304 {
4305 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4306 VTY_NEWLINE);
4307 return CMD_WARNING;
4308 }
4309
4310 params = ospf_get_if_params (ifp, addr);
4311 ospf_if_update_params (ifp, addr);
4312 }
4313
4314
4315 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004316 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004317 SET_IF_PARAM (params, auth_simple);
4318
4319 return CMD_SUCCESS;
4320}
4321
4322ALIAS (ip_ospf_authentication_key,
4323 ip_ospf_authentication_key_cmd,
4324 "ip ospf authentication-key AUTH_KEY",
4325 "IP Information\n"
4326 "OSPF interface commands\n"
4327 "Authentication password (key)\n"
4328 "The OSPF password (key)")
4329
4330ALIAS (ip_ospf_authentication_key,
4331 ospf_authentication_key_cmd,
4332 "ospf authentication-key AUTH_KEY",
4333 "OSPF interface commands\n"
4334 "Authentication password (key)\n"
4335 "The OSPF password (key)")
4336
4337DEFUN (no_ip_ospf_authentication_key,
4338 no_ip_ospf_authentication_key_addr_cmd,
4339 "no ip ospf authentication-key A.B.C.D",
4340 NO_STR
4341 "IP Information\n"
4342 "OSPF interface commands\n"
4343 "Authentication password (key)\n"
4344 "Address of interface")
4345{
4346 struct interface *ifp;
4347 struct in_addr addr;
4348 int ret;
4349 struct ospf_if_params *params;
4350
4351 ifp = vty->index;
4352 params = IF_DEF_PARAMS (ifp);
4353
4354 if (argc == 2)
4355 {
4356 ret = inet_aton(argv[1], &addr);
4357 if (!ret)
4358 {
4359 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4360 VTY_NEWLINE);
4361 return CMD_WARNING;
4362 }
4363
4364 params = ospf_lookup_if_params (ifp, addr);
4365 if (params == NULL)
4366 return CMD_SUCCESS;
4367 }
4368
4369 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4370 UNSET_IF_PARAM (params, auth_simple);
4371
4372 if (params != IF_DEF_PARAMS (ifp))
4373 {
4374 ospf_free_if_params (ifp, addr);
4375 ospf_if_update_params (ifp, addr);
4376 }
4377
4378 return CMD_SUCCESS;
4379}
4380
4381ALIAS (no_ip_ospf_authentication_key,
4382 no_ip_ospf_authentication_key_cmd,
4383 "no ip ospf authentication-key",
4384 NO_STR
4385 "IP Information\n"
4386 "OSPF interface commands\n"
4387 "Authentication password (key)\n")
4388
4389ALIAS (no_ip_ospf_authentication_key,
4390 no_ospf_authentication_key_cmd,
4391 "no ospf authentication-key",
4392 NO_STR
4393 "OSPF interface commands\n"
4394 "Authentication password (key)\n")
4395
4396DEFUN (ip_ospf_message_digest_key,
4397 ip_ospf_message_digest_key_addr_cmd,
4398 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4399 "IP Information\n"
4400 "OSPF interface commands\n"
4401 "Message digest authentication password (key)\n"
4402 "Key ID\n"
4403 "Use MD5 algorithm\n"
4404 "The OSPF password (key)"
4405 "Address of interface")
4406{
4407 struct interface *ifp;
4408 struct crypt_key *ck;
4409 u_char key_id;
4410 struct in_addr addr;
4411 int ret;
4412 struct ospf_if_params *params;
4413
4414 ifp = vty->index;
4415 params = IF_DEF_PARAMS (ifp);
4416
4417 if (argc == 3)
4418 {
4419 ret = inet_aton(argv[2], &addr);
4420 if (!ret)
4421 {
4422 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4423 VTY_NEWLINE);
4424 return CMD_WARNING;
4425 }
4426
4427 params = ospf_get_if_params (ifp, addr);
4428 ospf_if_update_params (ifp, addr);
4429 }
4430
4431 key_id = strtol (argv[0], NULL, 10);
4432 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4433 {
4434 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4435 return CMD_WARNING;
4436 }
4437
4438 ck = ospf_crypt_key_new ();
4439 ck->key_id = (u_char) key_id;
4440 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004441 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004442
4443 ospf_crypt_key_add (params->auth_crypt, ck);
4444 SET_IF_PARAM (params, auth_crypt);
4445
4446 return CMD_SUCCESS;
4447}
4448
4449ALIAS (ip_ospf_message_digest_key,
4450 ip_ospf_message_digest_key_cmd,
4451 "ip ospf message-digest-key <1-255> md5 KEY",
4452 "IP Information\n"
4453 "OSPF interface commands\n"
4454 "Message digest authentication password (key)\n"
4455 "Key ID\n"
4456 "Use MD5 algorithm\n"
4457 "The OSPF password (key)")
4458
4459ALIAS (ip_ospf_message_digest_key,
4460 ospf_message_digest_key_cmd,
4461 "ospf message-digest-key <1-255> md5 KEY",
4462 "OSPF interface commands\n"
4463 "Message digest authentication password (key)\n"
4464 "Key ID\n"
4465 "Use MD5 algorithm\n"
4466 "The OSPF password (key)")
4467
4468DEFUN (no_ip_ospf_message_digest_key,
4469 no_ip_ospf_message_digest_key_addr_cmd,
4470 "no ip ospf message-digest-key <1-255> A.B.C.D",
4471 NO_STR
4472 "IP Information\n"
4473 "OSPF interface commands\n"
4474 "Message digest authentication password (key)\n"
4475 "Key ID\n"
4476 "Address of interface")
4477{
4478 struct interface *ifp;
4479 struct crypt_key *ck;
4480 int key_id;
4481 struct in_addr addr;
4482 int ret;
4483 struct ospf_if_params *params;
4484
4485 ifp = vty->index;
4486 params = IF_DEF_PARAMS (ifp);
4487
4488 if (argc == 2)
4489 {
4490 ret = inet_aton(argv[1], &addr);
4491 if (!ret)
4492 {
4493 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4494 VTY_NEWLINE);
4495 return CMD_WARNING;
4496 }
4497
4498 params = ospf_lookup_if_params (ifp, addr);
4499 if (params == NULL)
4500 return CMD_SUCCESS;
4501 }
4502
4503 key_id = strtol (argv[0], NULL, 10);
4504 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4505 if (ck == NULL)
4506 {
4507 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4508 return CMD_WARNING;
4509 }
4510
4511 ospf_crypt_key_delete (params->auth_crypt, key_id);
4512
4513 if (params != IF_DEF_PARAMS (ifp))
4514 {
4515 ospf_free_if_params (ifp, addr);
4516 ospf_if_update_params (ifp, addr);
4517 }
4518
4519 return CMD_SUCCESS;
4520}
4521
4522ALIAS (no_ip_ospf_message_digest_key,
4523 no_ip_ospf_message_digest_key_cmd,
4524 "no ip ospf message-digest-key <1-255>",
4525 NO_STR
4526 "IP Information\n"
4527 "OSPF interface commands\n"
4528 "Message digest authentication password (key)\n"
4529 "Key ID\n")
4530
4531ALIAS (no_ip_ospf_message_digest_key,
4532 no_ospf_message_digest_key_cmd,
4533 "no ospf message-digest-key <1-255>",
4534 NO_STR
4535 "OSPF interface commands\n"
4536 "Message digest authentication password (key)\n"
4537 "Key ID\n")
4538
4539DEFUN (ip_ospf_cost,
4540 ip_ospf_cost_addr_cmd,
4541 "ip ospf cost <1-65535> A.B.C.D",
4542 "IP Information\n"
4543 "OSPF interface commands\n"
4544 "Interface cost\n"
4545 "Cost\n"
4546 "Address of interface")
4547{
4548 struct interface *ifp = vty->index;
4549 u_int32_t cost;
4550 struct in_addr addr;
4551 int ret;
4552 struct ospf_if_params *params;
4553
4554 params = IF_DEF_PARAMS (ifp);
4555
4556 cost = strtol (argv[0], NULL, 10);
4557
4558 /* cost range is <1-65535>. */
4559 if (cost < 1 || cost > 65535)
4560 {
4561 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4562 return CMD_WARNING;
4563 }
4564
4565 if (argc == 2)
4566 {
4567 ret = inet_aton(argv[1], &addr);
4568 if (!ret)
4569 {
4570 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4571 VTY_NEWLINE);
4572 return CMD_WARNING;
4573 }
4574
4575 params = ospf_get_if_params (ifp, addr);
4576 ospf_if_update_params (ifp, addr);
4577 }
4578
4579 SET_IF_PARAM (params, output_cost_cmd);
4580 params->output_cost_cmd = cost;
4581
4582 ospf_if_recalculate_output_cost (ifp);
4583
4584 return CMD_SUCCESS;
4585}
4586
4587ALIAS (ip_ospf_cost,
4588 ip_ospf_cost_cmd,
4589 "ip ospf cost <1-65535>",
4590 "IP Information\n"
4591 "OSPF interface commands\n"
4592 "Interface cost\n"
4593 "Cost")
4594
4595ALIAS (ip_ospf_cost,
4596 ospf_cost_cmd,
4597 "ospf cost <1-65535>",
4598 "OSPF interface commands\n"
4599 "Interface cost\n"
4600 "Cost")
4601
4602DEFUN (no_ip_ospf_cost,
4603 no_ip_ospf_cost_addr_cmd,
4604 "no ip ospf cost A.B.C.D",
4605 NO_STR
4606 "IP Information\n"
4607 "OSPF interface commands\n"
4608 "Interface cost\n"
4609 "Address of interface")
4610{
4611 struct interface *ifp = vty->index;
4612 struct in_addr addr;
4613 int ret;
4614 struct ospf_if_params *params;
4615
4616 ifp = vty->index;
4617 params = IF_DEF_PARAMS (ifp);
4618
4619 if (argc == 1)
4620 {
4621 ret = inet_aton(argv[0], &addr);
4622 if (!ret)
4623 {
4624 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4625 VTY_NEWLINE);
4626 return CMD_WARNING;
4627 }
4628
4629 params = ospf_lookup_if_params (ifp, addr);
4630 if (params == NULL)
4631 return CMD_SUCCESS;
4632 }
4633
4634 UNSET_IF_PARAM (params, output_cost_cmd);
4635
4636 if (params != IF_DEF_PARAMS (ifp))
4637 {
4638 ospf_free_if_params (ifp, addr);
4639 ospf_if_update_params (ifp, addr);
4640 }
4641
4642 ospf_if_recalculate_output_cost (ifp);
4643
4644 return CMD_SUCCESS;
4645}
4646
4647ALIAS (no_ip_ospf_cost,
4648 no_ip_ospf_cost_cmd,
4649 "no ip ospf cost",
4650 NO_STR
4651 "IP Information\n"
4652 "OSPF interface commands\n"
4653 "Interface cost\n")
4654
4655ALIAS (no_ip_ospf_cost,
4656 no_ospf_cost_cmd,
4657 "no ospf cost",
4658 NO_STR
4659 "OSPF interface commands\n"
4660 "Interface cost\n")
4661
paul4dadc292005-05-06 21:37:42 +00004662static void
paul718e3742002-12-13 20:15:29 +00004663ospf_nbr_timer_update (struct ospf_interface *oi)
4664{
4665 struct route_node *rn;
4666 struct ospf_neighbor *nbr;
4667
4668 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4669 if ((nbr = rn->info))
4670 {
4671 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4672 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4673 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4674 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4675 }
4676}
4677
paulf9ad9372005-10-21 00:45:17 +00004678static int
4679ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4680 const char *nbr_str,
4681 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004682{
4683 struct interface *ifp = vty->index;
4684 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004685 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004686 struct in_addr addr;
4687 int ret;
4688 struct ospf_if_params *params;
4689 struct ospf_interface *oi;
4690 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004691 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004692
paul020709f2003-04-04 02:44:16 +00004693 ospf = ospf_lookup ();
4694
paul718e3742002-12-13 20:15:29 +00004695 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004696
4697 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004698 {
paulf9ad9372005-10-21 00:45:17 +00004699 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004700 if (!ret)
4701 {
4702 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4703 VTY_NEWLINE);
4704 return CMD_WARNING;
4705 }
4706
4707 params = ospf_get_if_params (ifp, addr);
4708 ospf_if_update_params (ifp, addr);
4709 }
4710
paulf9ad9372005-10-21 00:45:17 +00004711 if (interval_str)
4712 {
4713 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4714 1, 65535);
4715
4716 /* reset fast_hello too, just to be sure */
4717 UNSET_IF_PARAM (params, fast_hello);
4718 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4719 }
4720 else if (fast_hello_str)
4721 {
4722 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4723 1, 10);
4724 /* 1s dead-interval with sub-second hellos desired */
4725 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4726 SET_IF_PARAM (params, fast_hello);
4727 params->fast_hello = hellomult;
4728 }
4729 else
4730 {
4731 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4732 VTY_NEWLINE);
4733 return CMD_WARNING;
4734 }
4735
paul718e3742002-12-13 20:15:29 +00004736 SET_IF_PARAM (params, v_wait);
4737 params->v_wait = seconds;
4738
4739 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00004740 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004741 {
paul68980082003-03-25 05:07:42 +00004742 if (ospf)
4743 {
4744 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4745 if (oi)
4746 ospf_nbr_timer_update (oi);
4747 }
paul718e3742002-12-13 20:15:29 +00004748 }
4749 else
4750 {
4751 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4752 if ((oi = rn->info))
4753 ospf_nbr_timer_update (oi);
4754 }
4755
4756 return CMD_SUCCESS;
4757}
4758
paulf9ad9372005-10-21 00:45:17 +00004759
4760DEFUN (ip_ospf_dead_interval,
4761 ip_ospf_dead_interval_addr_cmd,
4762 "ip ospf dead-interval <1-65535> A.B.C.D",
4763 "IP Information\n"
4764 "OSPF interface commands\n"
4765 "Interval after which a neighbor is declared dead\n"
4766 "Seconds\n"
4767 "Address of interface\n")
4768{
4769 if (argc == 2)
4770 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4771 else
4772 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4773}
4774
paul718e3742002-12-13 20:15:29 +00004775ALIAS (ip_ospf_dead_interval,
4776 ip_ospf_dead_interval_cmd,
4777 "ip ospf dead-interval <1-65535>",
4778 "IP Information\n"
4779 "OSPF interface commands\n"
4780 "Interval after which a neighbor is declared dead\n"
4781 "Seconds\n")
4782
4783ALIAS (ip_ospf_dead_interval,
4784 ospf_dead_interval_cmd,
4785 "ospf dead-interval <1-65535>",
4786 "OSPF interface commands\n"
4787 "Interval after which a neighbor is declared dead\n"
4788 "Seconds\n")
4789
paulf9ad9372005-10-21 00:45:17 +00004790DEFUN (ip_ospf_dead_interval_minimal,
4791 ip_ospf_dead_interval_minimal_addr_cmd,
4792 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4793 "IP Information\n"
4794 "OSPF interface commands\n"
4795 "Interval after which a neighbor is declared dead\n"
4796 "Minimal 1s dead-interval with fast sub-second hellos\n"
4797 "Hello multiplier factor\n"
4798 "Number of Hellos to send each second\n"
4799 "Address of interface\n")
4800{
4801 if (argc == 2)
4802 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4803 else
4804 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4805}
4806
4807ALIAS (ip_ospf_dead_interval_minimal,
4808 ip_ospf_dead_interval_minimal_cmd,
4809 "ip ospf dead-interval minimal hello-multiplier <1-10>",
4810 "IP Information\n"
4811 "OSPF interface commands\n"
4812 "Interval after which a neighbor is declared dead\n"
4813 "Minimal 1s dead-interval with fast sub-second hellos\n"
4814 "Hello multiplier factor\n"
4815 "Number of Hellos to send each second\n")
4816
paul718e3742002-12-13 20:15:29 +00004817DEFUN (no_ip_ospf_dead_interval,
4818 no_ip_ospf_dead_interval_addr_cmd,
4819 "no ip ospf dead-interval A.B.C.D",
4820 NO_STR
4821 "IP Information\n"
4822 "OSPF interface commands\n"
4823 "Interval after which a neighbor is declared dead\n"
4824 "Address of interface")
4825{
4826 struct interface *ifp = vty->index;
4827 struct in_addr addr;
4828 int ret;
4829 struct ospf_if_params *params;
4830 struct ospf_interface *oi;
4831 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004832 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004833
paul020709f2003-04-04 02:44:16 +00004834 ospf = ospf_lookup ();
4835
paul718e3742002-12-13 20:15:29 +00004836 ifp = vty->index;
4837 params = IF_DEF_PARAMS (ifp);
4838
4839 if (argc == 1)
4840 {
4841 ret = inet_aton(argv[0], &addr);
4842 if (!ret)
4843 {
4844 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4845 VTY_NEWLINE);
4846 return CMD_WARNING;
4847 }
4848
4849 params = ospf_lookup_if_params (ifp, addr);
4850 if (params == NULL)
4851 return CMD_SUCCESS;
4852 }
4853
4854 UNSET_IF_PARAM (params, v_wait);
4855 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00004856
4857 UNSET_IF_PARAM (params, fast_hello);
4858 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4859
paul718e3742002-12-13 20:15:29 +00004860 if (params != IF_DEF_PARAMS (ifp))
4861 {
4862 ospf_free_if_params (ifp, addr);
4863 ospf_if_update_params (ifp, addr);
4864 }
4865
4866 /* Update timer values in neighbor structure. */
4867 if (argc == 1)
4868 {
paul68980082003-03-25 05:07:42 +00004869 if (ospf)
4870 {
4871 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4872 if (oi)
4873 ospf_nbr_timer_update (oi);
4874 }
paul718e3742002-12-13 20:15:29 +00004875 }
4876 else
4877 {
4878 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4879 if ((oi = rn->info))
4880 ospf_nbr_timer_update (oi);
4881 }
4882
4883 return CMD_SUCCESS;
4884}
4885
4886ALIAS (no_ip_ospf_dead_interval,
4887 no_ip_ospf_dead_interval_cmd,
4888 "no ip ospf dead-interval",
4889 NO_STR
4890 "IP Information\n"
4891 "OSPF interface commands\n"
4892 "Interval after which a neighbor is declared dead\n")
4893
4894ALIAS (no_ip_ospf_dead_interval,
4895 no_ospf_dead_interval_cmd,
4896 "no ospf dead-interval",
4897 NO_STR
4898 "OSPF interface commands\n"
4899 "Interval after which a neighbor is declared dead\n")
4900
4901DEFUN (ip_ospf_hello_interval,
4902 ip_ospf_hello_interval_addr_cmd,
4903 "ip ospf hello-interval <1-65535> A.B.C.D",
4904 "IP Information\n"
4905 "OSPF interface commands\n"
4906 "Time between HELLO packets\n"
4907 "Seconds\n"
4908 "Address of interface")
4909{
4910 struct interface *ifp = vty->index;
4911 u_int32_t seconds;
4912 struct in_addr addr;
4913 int ret;
4914 struct ospf_if_params *params;
4915
4916 params = IF_DEF_PARAMS (ifp);
4917
4918 seconds = strtol (argv[0], NULL, 10);
4919
4920 /* HelloInterval range is <1-65535>. */
4921 if (seconds < 1 || seconds > 65535)
4922 {
4923 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4924 return CMD_WARNING;
4925 }
4926
4927 if (argc == 2)
4928 {
4929 ret = inet_aton(argv[1], &addr);
4930 if (!ret)
4931 {
4932 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4933 VTY_NEWLINE);
4934 return CMD_WARNING;
4935 }
4936
4937 params = ospf_get_if_params (ifp, addr);
4938 ospf_if_update_params (ifp, addr);
4939 }
4940
paulf9ad9372005-10-21 00:45:17 +00004941 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00004942 params->v_hello = seconds;
4943
4944 return CMD_SUCCESS;
4945}
4946
4947ALIAS (ip_ospf_hello_interval,
4948 ip_ospf_hello_interval_cmd,
4949 "ip ospf hello-interval <1-65535>",
4950 "IP Information\n"
4951 "OSPF interface commands\n"
4952 "Time between HELLO packets\n"
4953 "Seconds\n")
4954
4955ALIAS (ip_ospf_hello_interval,
4956 ospf_hello_interval_cmd,
4957 "ospf hello-interval <1-65535>",
4958 "OSPF interface commands\n"
4959 "Time between HELLO packets\n"
4960 "Seconds\n")
4961
4962DEFUN (no_ip_ospf_hello_interval,
4963 no_ip_ospf_hello_interval_addr_cmd,
4964 "no ip ospf hello-interval A.B.C.D",
4965 NO_STR
4966 "IP Information\n"
4967 "OSPF interface commands\n"
4968 "Time between HELLO packets\n"
4969 "Address of interface")
4970{
4971 struct interface *ifp = vty->index;
4972 struct in_addr addr;
4973 int ret;
4974 struct ospf_if_params *params;
4975
4976 ifp = vty->index;
4977 params = IF_DEF_PARAMS (ifp);
4978
4979 if (argc == 1)
4980 {
4981 ret = inet_aton(argv[0], &addr);
4982 if (!ret)
4983 {
4984 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4985 VTY_NEWLINE);
4986 return CMD_WARNING;
4987 }
4988
4989 params = ospf_lookup_if_params (ifp, addr);
4990 if (params == NULL)
4991 return CMD_SUCCESS;
4992 }
4993
4994 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00004995 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00004996
4997 if (params != IF_DEF_PARAMS (ifp))
4998 {
4999 ospf_free_if_params (ifp, addr);
5000 ospf_if_update_params (ifp, addr);
5001 }
5002
5003 return CMD_SUCCESS;
5004}
5005
5006ALIAS (no_ip_ospf_hello_interval,
5007 no_ip_ospf_hello_interval_cmd,
5008 "no ip ospf hello-interval",
5009 NO_STR
5010 "IP Information\n"
5011 "OSPF interface commands\n"
5012 "Time between HELLO packets\n")
5013
5014ALIAS (no_ip_ospf_hello_interval,
5015 no_ospf_hello_interval_cmd,
5016 "no ospf hello-interval",
5017 NO_STR
5018 "OSPF interface commands\n"
5019 "Time between HELLO packets\n")
5020
5021DEFUN (ip_ospf_network,
5022 ip_ospf_network_cmd,
5023 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5024 "IP Information\n"
5025 "OSPF interface commands\n"
5026 "Network type\n"
5027 "Specify OSPF broadcast multi-access network\n"
5028 "Specify OSPF NBMA network\n"
5029 "Specify OSPF point-to-multipoint network\n"
5030 "Specify OSPF point-to-point network\n")
5031{
5032 struct interface *ifp = vty->index;
5033 int old_type = IF_DEF_PARAMS (ifp)->type;
5034 struct route_node *rn;
5035
5036 if (strncmp (argv[0], "b", 1) == 0)
5037 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5038 else if (strncmp (argv[0], "n", 1) == 0)
5039 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5040 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5041 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5042 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5043 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5044
5045 if (IF_DEF_PARAMS (ifp)->type == old_type)
5046 return CMD_SUCCESS;
5047
5048 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5049
5050 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5051 {
5052 struct ospf_interface *oi = rn->info;
5053
5054 if (!oi)
5055 continue;
5056
5057 oi->type = IF_DEF_PARAMS (ifp)->type;
5058
5059 if (oi->state > ISM_Down)
5060 {
5061 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5062 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5063 }
5064 }
5065
5066 return CMD_SUCCESS;
5067}
5068
5069ALIAS (ip_ospf_network,
5070 ospf_network_cmd,
5071 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5072 "OSPF interface commands\n"
5073 "Network type\n"
5074 "Specify OSPF broadcast multi-access network\n"
5075 "Specify OSPF NBMA network\n"
5076 "Specify OSPF point-to-multipoint network\n"
5077 "Specify OSPF point-to-point network\n")
5078
5079DEFUN (no_ip_ospf_network,
5080 no_ip_ospf_network_cmd,
5081 "no ip ospf network",
5082 NO_STR
5083 "IP Information\n"
5084 "OSPF interface commands\n"
5085 "Network type\n")
5086{
5087 struct interface *ifp = vty->index;
5088 int old_type = IF_DEF_PARAMS (ifp)->type;
5089 struct route_node *rn;
5090
ajsbc18d612004-12-15 15:07:19 +00005091 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005092
5093 if (IF_DEF_PARAMS (ifp)->type == old_type)
5094 return CMD_SUCCESS;
5095
5096 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5097 {
5098 struct ospf_interface *oi = rn->info;
5099
5100 if (!oi)
5101 continue;
5102
5103 oi->type = IF_DEF_PARAMS (ifp)->type;
5104
5105 if (oi->state > ISM_Down)
5106 {
5107 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5108 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5109 }
5110 }
5111
5112 return CMD_SUCCESS;
5113}
5114
5115ALIAS (no_ip_ospf_network,
5116 no_ospf_network_cmd,
5117 "no ospf network",
5118 NO_STR
5119 "OSPF interface commands\n"
5120 "Network type\n")
5121
5122DEFUN (ip_ospf_priority,
5123 ip_ospf_priority_addr_cmd,
5124 "ip ospf priority <0-255> A.B.C.D",
5125 "IP Information\n"
5126 "OSPF interface commands\n"
5127 "Router priority\n"
5128 "Priority\n"
5129 "Address of interface")
5130{
5131 struct interface *ifp = vty->index;
5132 u_int32_t priority;
5133 struct route_node *rn;
5134 struct in_addr addr;
5135 int ret;
5136 struct ospf_if_params *params;
5137
5138 params = IF_DEF_PARAMS (ifp);
5139
5140 priority = strtol (argv[0], NULL, 10);
5141
5142 /* Router Priority range is <0-255>. */
5143 if (priority < 0 || priority > 255)
5144 {
5145 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5146 return CMD_WARNING;
5147 }
5148
5149 if (argc == 2)
5150 {
5151 ret = inet_aton(argv[1], &addr);
5152 if (!ret)
5153 {
5154 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5155 VTY_NEWLINE);
5156 return CMD_WARNING;
5157 }
5158
5159 params = ospf_get_if_params (ifp, addr);
5160 ospf_if_update_params (ifp, addr);
5161 }
5162
5163 SET_IF_PARAM (params, priority);
5164 params->priority = priority;
5165
5166 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5167 {
5168 struct ospf_interface *oi = rn->info;
5169
5170 if (!oi)
5171 continue;
5172
5173
5174 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5175 {
5176 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5177 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5178 }
5179 }
5180
5181 return CMD_SUCCESS;
5182}
5183
5184ALIAS (ip_ospf_priority,
5185 ip_ospf_priority_cmd,
5186 "ip ospf priority <0-255>",
5187 "IP Information\n"
5188 "OSPF interface commands\n"
5189 "Router priority\n"
5190 "Priority\n")
5191
5192ALIAS (ip_ospf_priority,
5193 ospf_priority_cmd,
5194 "ospf priority <0-255>",
5195 "OSPF interface commands\n"
5196 "Router priority\n"
5197 "Priority\n")
5198
5199DEFUN (no_ip_ospf_priority,
5200 no_ip_ospf_priority_addr_cmd,
5201 "no ip ospf priority A.B.C.D",
5202 NO_STR
5203 "IP Information\n"
5204 "OSPF interface commands\n"
5205 "Router priority\n"
5206 "Address of interface")
5207{
5208 struct interface *ifp = vty->index;
5209 struct route_node *rn;
5210 struct in_addr addr;
5211 int ret;
5212 struct ospf_if_params *params;
5213
5214 ifp = vty->index;
5215 params = IF_DEF_PARAMS (ifp);
5216
5217 if (argc == 1)
5218 {
5219 ret = inet_aton(argv[0], &addr);
5220 if (!ret)
5221 {
5222 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5223 VTY_NEWLINE);
5224 return CMD_WARNING;
5225 }
5226
5227 params = ospf_lookup_if_params (ifp, addr);
5228 if (params == NULL)
5229 return CMD_SUCCESS;
5230 }
5231
5232 UNSET_IF_PARAM (params, priority);
5233 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5234
5235 if (params != IF_DEF_PARAMS (ifp))
5236 {
5237 ospf_free_if_params (ifp, addr);
5238 ospf_if_update_params (ifp, addr);
5239 }
5240
5241 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5242 {
5243 struct ospf_interface *oi = rn->info;
5244
5245 if (!oi)
5246 continue;
5247
5248
5249 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5250 {
5251 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5252 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5253 }
5254 }
5255
5256 return CMD_SUCCESS;
5257}
5258
5259ALIAS (no_ip_ospf_priority,
5260 no_ip_ospf_priority_cmd,
5261 "no ip ospf priority",
5262 NO_STR
5263 "IP Information\n"
5264 "OSPF interface commands\n"
5265 "Router priority\n")
5266
5267ALIAS (no_ip_ospf_priority,
5268 no_ospf_priority_cmd,
5269 "no ospf priority",
5270 NO_STR
5271 "OSPF interface commands\n"
5272 "Router priority\n")
5273
5274DEFUN (ip_ospf_retransmit_interval,
5275 ip_ospf_retransmit_interval_addr_cmd,
5276 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5277 "IP Information\n"
5278 "OSPF interface commands\n"
5279 "Time between retransmitting lost link state advertisements\n"
5280 "Seconds\n"
5281 "Address of interface")
5282{
5283 struct interface *ifp = vty->index;
5284 u_int32_t seconds;
5285 struct in_addr addr;
5286 int ret;
5287 struct ospf_if_params *params;
5288
5289 params = IF_DEF_PARAMS (ifp);
5290 seconds = strtol (argv[0], NULL, 10);
5291
5292 /* Retransmit Interval range is <3-65535>. */
5293 if (seconds < 3 || seconds > 65535)
5294 {
5295 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5296 return CMD_WARNING;
5297 }
5298
5299
5300 if (argc == 2)
5301 {
5302 ret = inet_aton(argv[1], &addr);
5303 if (!ret)
5304 {
5305 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5306 VTY_NEWLINE);
5307 return CMD_WARNING;
5308 }
5309
5310 params = ospf_get_if_params (ifp, addr);
5311 ospf_if_update_params (ifp, addr);
5312 }
5313
5314 SET_IF_PARAM (params, retransmit_interval);
5315 params->retransmit_interval = seconds;
5316
5317 return CMD_SUCCESS;
5318}
5319
5320ALIAS (ip_ospf_retransmit_interval,
5321 ip_ospf_retransmit_interval_cmd,
5322 "ip ospf retransmit-interval <3-65535>",
5323 "IP Information\n"
5324 "OSPF interface commands\n"
5325 "Time between retransmitting lost link state advertisements\n"
5326 "Seconds\n")
5327
5328ALIAS (ip_ospf_retransmit_interval,
5329 ospf_retransmit_interval_cmd,
5330 "ospf retransmit-interval <3-65535>",
5331 "OSPF interface commands\n"
5332 "Time between retransmitting lost link state advertisements\n"
5333 "Seconds\n")
5334
5335DEFUN (no_ip_ospf_retransmit_interval,
5336 no_ip_ospf_retransmit_interval_addr_cmd,
5337 "no ip ospf retransmit-interval A.B.C.D",
5338 NO_STR
5339 "IP Information\n"
5340 "OSPF interface commands\n"
5341 "Time between retransmitting lost link state advertisements\n"
5342 "Address of interface")
5343{
5344 struct interface *ifp = vty->index;
5345 struct in_addr addr;
5346 int ret;
5347 struct ospf_if_params *params;
5348
5349 ifp = vty->index;
5350 params = IF_DEF_PARAMS (ifp);
5351
5352 if (argc == 1)
5353 {
5354 ret = inet_aton(argv[0], &addr);
5355 if (!ret)
5356 {
5357 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5358 VTY_NEWLINE);
5359 return CMD_WARNING;
5360 }
5361
5362 params = ospf_lookup_if_params (ifp, addr);
5363 if (params == NULL)
5364 return CMD_SUCCESS;
5365 }
5366
5367 UNSET_IF_PARAM (params, retransmit_interval);
5368 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5369
5370 if (params != IF_DEF_PARAMS (ifp))
5371 {
5372 ospf_free_if_params (ifp, addr);
5373 ospf_if_update_params (ifp, addr);
5374 }
5375
5376 return CMD_SUCCESS;
5377}
5378
5379ALIAS (no_ip_ospf_retransmit_interval,
5380 no_ip_ospf_retransmit_interval_cmd,
5381 "no ip ospf retransmit-interval",
5382 NO_STR
5383 "IP Information\n"
5384 "OSPF interface commands\n"
5385 "Time between retransmitting lost link state advertisements\n")
5386
5387ALIAS (no_ip_ospf_retransmit_interval,
5388 no_ospf_retransmit_interval_cmd,
5389 "no ospf retransmit-interval",
5390 NO_STR
5391 "OSPF interface commands\n"
5392 "Time between retransmitting lost link state advertisements\n")
5393
5394DEFUN (ip_ospf_transmit_delay,
5395 ip_ospf_transmit_delay_addr_cmd,
5396 "ip ospf transmit-delay <1-65535> A.B.C.D",
5397 "IP Information\n"
5398 "OSPF interface commands\n"
5399 "Link state transmit delay\n"
5400 "Seconds\n"
5401 "Address of interface")
5402{
5403 struct interface *ifp = vty->index;
5404 u_int32_t seconds;
5405 struct in_addr addr;
5406 int ret;
5407 struct ospf_if_params *params;
5408
5409 params = IF_DEF_PARAMS (ifp);
5410 seconds = strtol (argv[0], NULL, 10);
5411
5412 /* Transmit Delay range is <1-65535>. */
5413 if (seconds < 1 || seconds > 65535)
5414 {
5415 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5416 return CMD_WARNING;
5417 }
5418
5419 if (argc == 2)
5420 {
5421 ret = inet_aton(argv[1], &addr);
5422 if (!ret)
5423 {
5424 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5425 VTY_NEWLINE);
5426 return CMD_WARNING;
5427 }
5428
5429 params = ospf_get_if_params (ifp, addr);
5430 ospf_if_update_params (ifp, addr);
5431 }
5432
5433 SET_IF_PARAM (params, transmit_delay);
5434 params->transmit_delay = seconds;
5435
5436 return CMD_SUCCESS;
5437}
5438
5439ALIAS (ip_ospf_transmit_delay,
5440 ip_ospf_transmit_delay_cmd,
5441 "ip ospf transmit-delay <1-65535>",
5442 "IP Information\n"
5443 "OSPF interface commands\n"
5444 "Link state transmit delay\n"
5445 "Seconds\n")
5446
5447ALIAS (ip_ospf_transmit_delay,
5448 ospf_transmit_delay_cmd,
5449 "ospf transmit-delay <1-65535>",
5450 "OSPF interface commands\n"
5451 "Link state transmit delay\n"
5452 "Seconds\n")
5453
5454DEFUN (no_ip_ospf_transmit_delay,
5455 no_ip_ospf_transmit_delay_addr_cmd,
5456 "no ip ospf transmit-delay A.B.C.D",
5457 NO_STR
5458 "IP Information\n"
5459 "OSPF interface commands\n"
5460 "Link state transmit delay\n"
5461 "Address of interface")
5462{
5463 struct interface *ifp = vty->index;
5464 struct in_addr addr;
5465 int ret;
5466 struct ospf_if_params *params;
5467
5468 ifp = vty->index;
5469 params = IF_DEF_PARAMS (ifp);
5470
5471 if (argc == 1)
5472 {
5473 ret = inet_aton(argv[0], &addr);
5474 if (!ret)
5475 {
5476 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5477 VTY_NEWLINE);
5478 return CMD_WARNING;
5479 }
5480
5481 params = ospf_lookup_if_params (ifp, addr);
5482 if (params == NULL)
5483 return CMD_SUCCESS;
5484 }
5485
5486 UNSET_IF_PARAM (params, transmit_delay);
5487 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5488
5489 if (params != IF_DEF_PARAMS (ifp))
5490 {
5491 ospf_free_if_params (ifp, addr);
5492 ospf_if_update_params (ifp, addr);
5493 }
5494
5495 return CMD_SUCCESS;
5496}
5497
5498ALIAS (no_ip_ospf_transmit_delay,
5499 no_ip_ospf_transmit_delay_cmd,
5500 "no ip ospf transmit-delay",
5501 NO_STR
5502 "IP Information\n"
5503 "OSPF interface commands\n"
5504 "Link state transmit delay\n")
5505
5506ALIAS (no_ip_ospf_transmit_delay,
5507 no_ospf_transmit_delay_cmd,
5508 "no ospf transmit-delay",
5509 NO_STR
5510 "OSPF interface commands\n"
5511 "Link state transmit delay\n")
5512
5513
5514DEFUN (ospf_redistribute_source_metric_type,
5515 ospf_redistribute_source_metric_type_routemap_cmd,
5516 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5517 "Redistribute information from another routing protocol\n"
5518 "Kernel routes\n"
5519 "Connected\n"
5520 "Static routes\n"
5521 "Routing Information Protocol (RIP)\n"
5522 "Border Gateway Protocol (BGP)\n"
5523 "Metric for redistributed routes\n"
5524 "OSPF default metric\n"
5525 "OSPF exterior metric type for redistributed routes\n"
5526 "Set OSPF External Type 1 metrics\n"
5527 "Set OSPF External Type 2 metrics\n"
5528 "Route map reference\n"
5529 "Pointer to route-map entries\n")
5530{
paul020709f2003-04-04 02:44:16 +00005531 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005532 int source;
5533 int type = -1;
5534 int metric = -1;
5535
5536 /* Get distribute source. */
5537 if (!str2distribute_source (argv[0], &source))
5538 return CMD_WARNING;
5539
5540 /* Get metric value. */
5541 if (argc >= 2)
5542 if (!str2metric (argv[1], &metric))
5543 return CMD_WARNING;
5544
5545 /* Get metric type. */
5546 if (argc >= 3)
5547 if (!str2metric_type (argv[2], &type))
5548 return CMD_WARNING;
5549
5550 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005551 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005552 else
paul020709f2003-04-04 02:44:16 +00005553 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005554
paul020709f2003-04-04 02:44:16 +00005555 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005556}
5557
5558ALIAS (ospf_redistribute_source_metric_type,
5559 ospf_redistribute_source_metric_type_cmd,
5560 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5561 "Redistribute information from another routing protocol\n"
5562 "Kernel routes\n"
5563 "Connected\n"
5564 "Static routes\n"
5565 "Routing Information Protocol (RIP)\n"
5566 "Border Gateway Protocol (BGP)\n"
5567 "Metric for redistributed routes\n"
5568 "OSPF default metric\n"
5569 "OSPF exterior metric type for redistributed routes\n"
5570 "Set OSPF External Type 1 metrics\n"
5571 "Set OSPF External Type 2 metrics\n")
5572
5573ALIAS (ospf_redistribute_source_metric_type,
5574 ospf_redistribute_source_metric_cmd,
5575 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5576 "Redistribute information from another routing protocol\n"
5577 "Kernel routes\n"
5578 "Connected\n"
5579 "Static routes\n"
5580 "Routing Information Protocol (RIP)\n"
5581 "Border Gateway Protocol (BGP)\n"
5582 "Metric for redistributed routes\n"
5583 "OSPF default metric\n")
5584
5585DEFUN (ospf_redistribute_source_type_metric,
5586 ospf_redistribute_source_type_metric_routemap_cmd,
5587 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5588 "Redistribute information from another routing protocol\n"
5589 "Kernel routes\n"
5590 "Connected\n"
5591 "Static routes\n"
5592 "Routing Information Protocol (RIP)\n"
5593 "Border Gateway Protocol (BGP)\n"
5594 "OSPF exterior metric type for redistributed routes\n"
5595 "Set OSPF External Type 1 metrics\n"
5596 "Set OSPF External Type 2 metrics\n"
5597 "Metric for redistributed routes\n"
5598 "OSPF default metric\n"
5599 "Route map reference\n"
5600 "Pointer to route-map entries\n")
5601{
paul020709f2003-04-04 02:44:16 +00005602 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005603 int source;
5604 int type = -1;
5605 int metric = -1;
5606
5607 /* Get distribute source. */
5608 if (!str2distribute_source (argv[0], &source))
5609 return CMD_WARNING;
5610
5611 /* Get metric value. */
5612 if (argc >= 2)
5613 if (!str2metric_type (argv[1], &type))
5614 return CMD_WARNING;
5615
5616 /* Get metric type. */
5617 if (argc >= 3)
5618 if (!str2metric (argv[2], &metric))
5619 return CMD_WARNING;
5620
5621 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005622 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005623 else
paul020709f2003-04-04 02:44:16 +00005624 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005625
paul020709f2003-04-04 02:44:16 +00005626 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005627}
5628
5629ALIAS (ospf_redistribute_source_type_metric,
5630 ospf_redistribute_source_type_metric_cmd,
5631 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5632 "Redistribute information from another routing protocol\n"
5633 "Kernel routes\n"
5634 "Connected\n"
5635 "Static routes\n"
5636 "Routing Information Protocol (RIP)\n"
5637 "Border Gateway Protocol (BGP)\n"
5638 "OSPF exterior metric type for redistributed routes\n"
5639 "Set OSPF External Type 1 metrics\n"
5640 "Set OSPF External Type 2 metrics\n"
5641 "Metric for redistributed routes\n"
5642 "OSPF default metric\n")
5643
5644ALIAS (ospf_redistribute_source_type_metric,
5645 ospf_redistribute_source_type_cmd,
5646 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5647 "Redistribute information from another routing protocol\n"
5648 "Kernel routes\n"
5649 "Connected\n"
5650 "Static routes\n"
5651 "Routing Information Protocol (RIP)\n"
5652 "Border Gateway Protocol (BGP)\n"
5653 "OSPF exterior metric type for redistributed routes\n"
5654 "Set OSPF External Type 1 metrics\n"
5655 "Set OSPF External Type 2 metrics\n")
5656
5657ALIAS (ospf_redistribute_source_type_metric,
5658 ospf_redistribute_source_cmd,
5659 "redistribute (kernel|connected|static|rip|bgp)",
5660 "Redistribute information from another routing protocol\n"
5661 "Kernel routes\n"
5662 "Connected\n"
5663 "Static routes\n"
5664 "Routing Information Protocol (RIP)\n"
5665 "Border Gateway Protocol (BGP)\n")
5666
5667DEFUN (ospf_redistribute_source_metric_routemap,
5668 ospf_redistribute_source_metric_routemap_cmd,
5669 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5670 "Redistribute information from another routing protocol\n"
5671 "Kernel routes\n"
5672 "Connected\n"
5673 "Static routes\n"
5674 "Routing Information Protocol (RIP)\n"
5675 "Border Gateway Protocol (BGP)\n"
5676 "Metric for redistributed routes\n"
5677 "OSPF default metric\n"
5678 "Route map reference\n"
5679 "Pointer to route-map entries\n")
5680{
paul020709f2003-04-04 02:44:16 +00005681 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005682 int source;
5683 int metric = -1;
5684
5685 /* Get distribute source. */
5686 if (!str2distribute_source (argv[0], &source))
5687 return CMD_WARNING;
5688
5689 /* Get metric value. */
5690 if (argc >= 2)
5691 if (!str2metric (argv[1], &metric))
5692 return CMD_WARNING;
5693
5694 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005695 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005696 else
paul020709f2003-04-04 02:44:16 +00005697 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005698
paul020709f2003-04-04 02:44:16 +00005699 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005700}
5701
5702DEFUN (ospf_redistribute_source_type_routemap,
5703 ospf_redistribute_source_type_routemap_cmd,
5704 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5705 "Redistribute information from another routing protocol\n"
5706 "Kernel routes\n"
5707 "Connected\n"
5708 "Static routes\n"
5709 "Routing Information Protocol (RIP)\n"
5710 "Border Gateway Protocol (BGP)\n"
5711 "OSPF exterior metric type for redistributed routes\n"
5712 "Set OSPF External Type 1 metrics\n"
5713 "Set OSPF External Type 2 metrics\n"
5714 "Route map reference\n"
5715 "Pointer to route-map entries\n")
5716{
paul020709f2003-04-04 02:44:16 +00005717 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005718 int source;
5719 int type = -1;
5720
5721 /* Get distribute source. */
5722 if (!str2distribute_source (argv[0], &source))
5723 return CMD_WARNING;
5724
5725 /* Get metric value. */
5726 if (argc >= 2)
5727 if (!str2metric_type (argv[1], &type))
5728 return CMD_WARNING;
5729
5730 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005731 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005732 else
paul020709f2003-04-04 02:44:16 +00005733 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005734
paul020709f2003-04-04 02:44:16 +00005735 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005736}
5737
5738DEFUN (ospf_redistribute_source_routemap,
5739 ospf_redistribute_source_routemap_cmd,
5740 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5741 "Redistribute information from another routing protocol\n"
5742 "Kernel routes\n"
5743 "Connected\n"
5744 "Static routes\n"
5745 "Routing Information Protocol (RIP)\n"
5746 "Border Gateway Protocol (BGP)\n"
5747 "Route map reference\n"
5748 "Pointer to route-map entries\n")
5749{
paul020709f2003-04-04 02:44:16 +00005750 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005751 int source;
5752
5753 /* Get distribute source. */
5754 if (!str2distribute_source (argv[0], &source))
5755 return CMD_WARNING;
5756
5757 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005758 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005759 else
paul020709f2003-04-04 02:44:16 +00005760 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005761
paul020709f2003-04-04 02:44:16 +00005762 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005763}
5764
5765DEFUN (no_ospf_redistribute_source,
5766 no_ospf_redistribute_source_cmd,
5767 "no redistribute (kernel|connected|static|rip|bgp)",
5768 NO_STR
5769 "Redistribute information from another routing protocol\n"
5770 "Kernel routes\n"
5771 "Connected\n"
5772 "Static routes\n"
5773 "Routing Information Protocol (RIP)\n"
5774 "Border Gateway Protocol (BGP)\n")
5775{
paul020709f2003-04-04 02:44:16 +00005776 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005777 int source;
5778
5779 if (!str2distribute_source (argv[0], &source))
5780 return CMD_WARNING;
5781
paul020709f2003-04-04 02:44:16 +00005782 ospf_routemap_unset (ospf, source);
5783 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005784}
5785
5786DEFUN (ospf_distribute_list_out,
5787 ospf_distribute_list_out_cmd,
5788 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5789 "Filter networks in routing updates\n"
5790 "Access-list name\n"
5791 OUT_STR
5792 "Kernel routes\n"
5793 "Connected\n"
5794 "Static routes\n"
5795 "Routing Information Protocol (RIP)\n"
5796 "Border Gateway Protocol (BGP)\n")
5797{
paul68980082003-03-25 05:07:42 +00005798 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005799 int source;
5800
5801 /* Get distribute source. */
5802 if (!str2distribute_source (argv[1], &source))
5803 return CMD_WARNING;
5804
paul68980082003-03-25 05:07:42 +00005805 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005806}
5807
5808DEFUN (no_ospf_distribute_list_out,
5809 no_ospf_distribute_list_out_cmd,
5810 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5811 NO_STR
5812 "Filter networks in routing updates\n"
5813 "Access-list name\n"
5814 OUT_STR
5815 "Kernel routes\n"
5816 "Connected\n"
5817 "Static routes\n"
5818 "Routing Information Protocol (RIP)\n"
5819 "Border Gateway Protocol (BGP)\n")
5820{
paul68980082003-03-25 05:07:42 +00005821 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005822 int source;
5823
5824 if (!str2distribute_source (argv[1], &source))
5825 return CMD_WARNING;
5826
paul68980082003-03-25 05:07:42 +00005827 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005828}
5829
5830/* Default information originate. */
5831DEFUN (ospf_default_information_originate_metric_type_routemap,
5832 ospf_default_information_originate_metric_type_routemap_cmd,
5833 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5834 "Control distribution of default information\n"
5835 "Distribute a default route\n"
5836 "OSPF default metric\n"
5837 "OSPF metric\n"
5838 "OSPF metric type for default routes\n"
5839 "Set OSPF External Type 1 metrics\n"
5840 "Set OSPF External Type 2 metrics\n"
5841 "Route map reference\n"
5842 "Pointer to route-map entries\n")
5843{
paul020709f2003-04-04 02:44:16 +00005844 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005845 int type = -1;
5846 int metric = -1;
5847
5848 /* Get metric value. */
5849 if (argc >= 1)
5850 if (!str2metric (argv[0], &metric))
5851 return CMD_WARNING;
5852
5853 /* Get metric type. */
5854 if (argc >= 2)
5855 if (!str2metric_type (argv[1], &type))
5856 return CMD_WARNING;
5857
5858 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005859 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005860 else
paul020709f2003-04-04 02:44:16 +00005861 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005862
paul020709f2003-04-04 02:44:16 +00005863 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5864 type, metric);
paul718e3742002-12-13 20:15:29 +00005865}
5866
5867ALIAS (ospf_default_information_originate_metric_type_routemap,
5868 ospf_default_information_originate_metric_type_cmd,
5869 "default-information originate metric <0-16777214> metric-type (1|2)",
5870 "Control distribution of default information\n"
5871 "Distribute a default route\n"
5872 "OSPF default metric\n"
5873 "OSPF metric\n"
5874 "OSPF metric type for default routes\n"
5875 "Set OSPF External Type 1 metrics\n"
5876 "Set OSPF External Type 2 metrics\n")
5877
5878ALIAS (ospf_default_information_originate_metric_type_routemap,
5879 ospf_default_information_originate_metric_cmd,
5880 "default-information originate metric <0-16777214>",
5881 "Control distribution of default information\n"
5882 "Distribute a default route\n"
5883 "OSPF default metric\n"
5884 "OSPF metric\n")
5885
5886ALIAS (ospf_default_information_originate_metric_type_routemap,
5887 ospf_default_information_originate_cmd,
5888 "default-information originate",
5889 "Control distribution of default information\n"
5890 "Distribute a default route\n")
5891
5892/* Default information originate. */
5893DEFUN (ospf_default_information_originate_metric_routemap,
5894 ospf_default_information_originate_metric_routemap_cmd,
5895 "default-information originate metric <0-16777214> route-map WORD",
5896 "Control distribution of default information\n"
5897 "Distribute a default route\n"
5898 "OSPF default metric\n"
5899 "OSPF metric\n"
5900 "Route map reference\n"
5901 "Pointer to route-map entries\n")
5902{
paul020709f2003-04-04 02:44:16 +00005903 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005904 int metric = -1;
5905
5906 /* Get metric value. */
5907 if (argc >= 1)
5908 if (!str2metric (argv[0], &metric))
5909 return CMD_WARNING;
5910
5911 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005912 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005913 else
paul020709f2003-04-04 02:44:16 +00005914 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005915
paul020709f2003-04-04 02:44:16 +00005916 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5917 -1, metric);
paul718e3742002-12-13 20:15:29 +00005918}
5919
5920/* Default information originate. */
5921DEFUN (ospf_default_information_originate_routemap,
5922 ospf_default_information_originate_routemap_cmd,
5923 "default-information originate route-map WORD",
5924 "Control distribution of default information\n"
5925 "Distribute a default route\n"
5926 "Route map reference\n"
5927 "Pointer to route-map entries\n")
5928{
paul020709f2003-04-04 02:44:16 +00005929 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005930
paul020709f2003-04-04 02:44:16 +00005931 if (argc == 1)
5932 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5933 else
5934 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5935
5936 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005937}
5938
5939DEFUN (ospf_default_information_originate_type_metric_routemap,
5940 ospf_default_information_originate_type_metric_routemap_cmd,
5941 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5942 "Control distribution of default information\n"
5943 "Distribute a default route\n"
5944 "OSPF metric type for default routes\n"
5945 "Set OSPF External Type 1 metrics\n"
5946 "Set OSPF External Type 2 metrics\n"
5947 "OSPF default metric\n"
5948 "OSPF metric\n"
5949 "Route map reference\n"
5950 "Pointer to route-map entries\n")
5951{
paul020709f2003-04-04 02:44:16 +00005952 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005953 int type = -1;
5954 int metric = -1;
5955
5956 /* Get metric type. */
5957 if (argc >= 1)
5958 if (!str2metric_type (argv[0], &type))
5959 return CMD_WARNING;
5960
5961 /* Get metric value. */
5962 if (argc >= 2)
5963 if (!str2metric (argv[1], &metric))
5964 return CMD_WARNING;
5965
5966 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005967 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005968 else
paul020709f2003-04-04 02:44:16 +00005969 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005970
paul020709f2003-04-04 02:44:16 +00005971 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5972 type, metric);
paul718e3742002-12-13 20:15:29 +00005973}
5974
5975ALIAS (ospf_default_information_originate_type_metric_routemap,
5976 ospf_default_information_originate_type_metric_cmd,
5977 "default-information originate metric-type (1|2) metric <0-16777214>",
5978 "Control distribution of default information\n"
5979 "Distribute a default route\n"
5980 "OSPF metric type for default routes\n"
5981 "Set OSPF External Type 1 metrics\n"
5982 "Set OSPF External Type 2 metrics\n"
5983 "OSPF default metric\n"
5984 "OSPF metric\n")
5985
5986ALIAS (ospf_default_information_originate_type_metric_routemap,
5987 ospf_default_information_originate_type_cmd,
5988 "default-information originate metric-type (1|2)",
5989 "Control distribution of default information\n"
5990 "Distribute a default route\n"
5991 "OSPF metric type for default routes\n"
5992 "Set OSPF External Type 1 metrics\n"
5993 "Set OSPF External Type 2 metrics\n")
5994
5995DEFUN (ospf_default_information_originate_type_routemap,
5996 ospf_default_information_originate_type_routemap_cmd,
5997 "default-information originate metric-type (1|2) route-map WORD",
5998 "Control distribution of default information\n"
5999 "Distribute a default route\n"
6000 "OSPF metric type for default routes\n"
6001 "Set OSPF External Type 1 metrics\n"
6002 "Set OSPF External Type 2 metrics\n"
6003 "Route map reference\n"
6004 "Pointer to route-map entries\n")
6005{
paul020709f2003-04-04 02:44:16 +00006006 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006007 int type = -1;
6008
6009 /* Get metric type. */
6010 if (argc >= 1)
6011 if (!str2metric_type (argv[0], &type))
6012 return CMD_WARNING;
6013
6014 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006015 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006016 else
paul020709f2003-04-04 02:44:16 +00006017 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006018
paul020709f2003-04-04 02:44:16 +00006019 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6020 type, -1);
paul718e3742002-12-13 20:15:29 +00006021}
6022
6023DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6024 ospf_default_information_originate_always_metric_type_routemap_cmd,
6025 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6026 "Control distribution of default information\n"
6027 "Distribute a default route\n"
6028 "Always advertise default route\n"
6029 "OSPF default metric\n"
6030 "OSPF metric\n"
6031 "OSPF metric type for default routes\n"
6032 "Set OSPF External Type 1 metrics\n"
6033 "Set OSPF External Type 2 metrics\n"
6034 "Route map reference\n"
6035 "Pointer to route-map entries\n")
6036{
paul020709f2003-04-04 02:44:16 +00006037 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006038 int type = -1;
6039 int metric = -1;
6040
6041 /* Get metric value. */
6042 if (argc >= 1)
6043 if (!str2metric (argv[0], &metric))
6044 return CMD_WARNING;
6045
6046 /* Get metric type. */
6047 if (argc >= 2)
6048 if (!str2metric_type (argv[1], &type))
6049 return CMD_WARNING;
6050
6051 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006052 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006053 else
paul020709f2003-04-04 02:44:16 +00006054 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006055
paul020709f2003-04-04 02:44:16 +00006056 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006057 type, metric);
6058}
6059
6060ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6061 ospf_default_information_originate_always_metric_type_cmd,
6062 "default-information originate always metric <0-16777214> metric-type (1|2)",
6063 "Control distribution of default information\n"
6064 "Distribute a default route\n"
6065 "Always advertise default route\n"
6066 "OSPF default metric\n"
6067 "OSPF metric\n"
6068 "OSPF metric type for default routes\n"
6069 "Set OSPF External Type 1 metrics\n"
6070 "Set OSPF External Type 2 metrics\n")
6071
6072ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6073 ospf_default_information_originate_always_metric_cmd,
6074 "default-information originate always metric <0-16777214>",
6075 "Control distribution of default information\n"
6076 "Distribute a default route\n"
6077 "Always advertise default route\n"
6078 "OSPF default metric\n"
6079 "OSPF metric\n"
6080 "OSPF metric type for default routes\n")
6081
6082ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6083 ospf_default_information_originate_always_cmd,
6084 "default-information originate always",
6085 "Control distribution of default information\n"
6086 "Distribute a default route\n"
6087 "Always advertise default route\n")
6088
6089DEFUN (ospf_default_information_originate_always_metric_routemap,
6090 ospf_default_information_originate_always_metric_routemap_cmd,
6091 "default-information originate always metric <0-16777214> route-map WORD",
6092 "Control distribution of default information\n"
6093 "Distribute a default route\n"
6094 "Always advertise default route\n"
6095 "OSPF default metric\n"
6096 "OSPF metric\n"
6097 "Route map reference\n"
6098 "Pointer to route-map entries\n")
6099{
paul020709f2003-04-04 02:44:16 +00006100 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006101 int metric = -1;
6102
6103 /* Get metric value. */
6104 if (argc >= 1)
6105 if (!str2metric (argv[0], &metric))
6106 return CMD_WARNING;
6107
6108 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006109 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006110 else
paul020709f2003-04-04 02:44:16 +00006111 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006112
paul020709f2003-04-04 02:44:16 +00006113 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6114 -1, metric);
paul718e3742002-12-13 20:15:29 +00006115}
6116
6117DEFUN (ospf_default_information_originate_always_routemap,
6118 ospf_default_information_originate_always_routemap_cmd,
6119 "default-information originate always route-map WORD",
6120 "Control distribution of default information\n"
6121 "Distribute a default route\n"
6122 "Always advertise default route\n"
6123 "Route map reference\n"
6124 "Pointer to route-map entries\n")
6125{
paul020709f2003-04-04 02:44:16 +00006126 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006127
paul020709f2003-04-04 02:44:16 +00006128 if (argc == 1)
6129 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6130 else
6131 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6132
6133 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006134}
6135
6136DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6137 ospf_default_information_originate_always_type_metric_routemap_cmd,
6138 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6139 "Control distribution of default information\n"
6140 "Distribute a default route\n"
6141 "Always advertise default route\n"
6142 "OSPF metric type for default routes\n"
6143 "Set OSPF External Type 1 metrics\n"
6144 "Set OSPF External Type 2 metrics\n"
6145 "OSPF default metric\n"
6146 "OSPF metric\n"
6147 "Route map reference\n"
6148 "Pointer to route-map entries\n")
6149{
paul020709f2003-04-04 02:44:16 +00006150 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006151 int type = -1;
6152 int metric = -1;
6153
6154 /* Get metric type. */
6155 if (argc >= 1)
6156 if (!str2metric_type (argv[0], &type))
6157 return CMD_WARNING;
6158
6159 /* Get metric value. */
6160 if (argc >= 2)
6161 if (!str2metric (argv[1], &metric))
6162 return CMD_WARNING;
6163
6164 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006165 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006166 else
paul020709f2003-04-04 02:44:16 +00006167 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006168
paul020709f2003-04-04 02:44:16 +00006169 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006170 type, metric);
6171}
6172
6173ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6174 ospf_default_information_originate_always_type_metric_cmd,
6175 "default-information originate always metric-type (1|2) metric <0-16777214>",
6176 "Control distribution of default information\n"
6177 "Distribute a default route\n"
6178 "Always advertise default route\n"
6179 "OSPF metric type for default routes\n"
6180 "Set OSPF External Type 1 metrics\n"
6181 "Set OSPF External Type 2 metrics\n"
6182 "OSPF default metric\n"
6183 "OSPF metric\n")
6184
6185ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6186 ospf_default_information_originate_always_type_cmd,
6187 "default-information originate always metric-type (1|2)",
6188 "Control distribution of default information\n"
6189 "Distribute a default route\n"
6190 "Always advertise default route\n"
6191 "OSPF metric type for default routes\n"
6192 "Set OSPF External Type 1 metrics\n"
6193 "Set OSPF External Type 2 metrics\n")
6194
6195DEFUN (ospf_default_information_originate_always_type_routemap,
6196 ospf_default_information_originate_always_type_routemap_cmd,
6197 "default-information originate always metric-type (1|2) route-map WORD",
6198 "Control distribution of default information\n"
6199 "Distribute a default route\n"
6200 "Always advertise default route\n"
6201 "OSPF metric type for default routes\n"
6202 "Set OSPF External Type 1 metrics\n"
6203 "Set OSPF External Type 2 metrics\n"
6204 "Route map reference\n"
6205 "Pointer to route-map entries\n")
6206{
paul020709f2003-04-04 02:44:16 +00006207 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006208 int type = -1;
6209
6210 /* Get metric type. */
6211 if (argc >= 1)
6212 if (!str2metric_type (argv[0], &type))
6213 return CMD_WARNING;
6214
6215 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006216 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006217 else
paul020709f2003-04-04 02:44:16 +00006218 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006219
paul020709f2003-04-04 02:44:16 +00006220 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006221 type, -1);
6222}
6223
6224DEFUN (no_ospf_default_information_originate,
6225 no_ospf_default_information_originate_cmd,
6226 "no default-information originate",
6227 NO_STR
6228 "Control distribution of default information\n"
6229 "Distribute a default route\n")
6230{
paul68980082003-03-25 05:07:42 +00006231 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006232 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006233
6234 p.family = AF_INET;
6235 p.prefix.s_addr = 0;
6236 p.prefixlen = 0;
6237
ajs5339cfd2005-09-19 13:28:05 +00006238 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006239
6240 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6241 ospf_external_info_delete (DEFAULT_ROUTE, p);
6242 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6243 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6244 }
6245
paul020709f2003-04-04 02:44:16 +00006246 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6247 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006248}
6249
6250DEFUN (ospf_default_metric,
6251 ospf_default_metric_cmd,
6252 "default-metric <0-16777214>",
6253 "Set metric of redistributed routes\n"
6254 "Default metric\n")
6255{
paul68980082003-03-25 05:07:42 +00006256 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006257 int metric = -1;
6258
6259 if (!str2metric (argv[0], &metric))
6260 return CMD_WARNING;
6261
paul68980082003-03-25 05:07:42 +00006262 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006263
6264 return CMD_SUCCESS;
6265}
6266
6267DEFUN (no_ospf_default_metric,
6268 no_ospf_default_metric_cmd,
6269 "no default-metric",
6270 NO_STR
6271 "Set metric of redistributed routes\n")
6272{
paul68980082003-03-25 05:07:42 +00006273 struct ospf *ospf = vty->index;
6274
6275 ospf->default_metric = -1;
6276
paul718e3742002-12-13 20:15:29 +00006277 return CMD_SUCCESS;
6278}
6279
6280ALIAS (no_ospf_default_metric,
6281 no_ospf_default_metric_val_cmd,
6282 "no default-metric <0-16777214>",
6283 NO_STR
6284 "Set metric of redistributed routes\n"
6285 "Default metric\n")
6286
6287DEFUN (ospf_distance,
6288 ospf_distance_cmd,
6289 "distance <1-255>",
6290 "Define an administrative distance\n"
6291 "OSPF Administrative distance\n")
6292{
paul68980082003-03-25 05:07:42 +00006293 struct ospf *ospf = vty->index;
6294
6295 ospf->distance_all = atoi (argv[0]);
6296
paul718e3742002-12-13 20:15:29 +00006297 return CMD_SUCCESS;
6298}
6299
6300DEFUN (no_ospf_distance,
6301 no_ospf_distance_cmd,
6302 "no distance <1-255>",
6303 NO_STR
6304 "Define an administrative distance\n"
6305 "OSPF Administrative distance\n")
6306{
paul68980082003-03-25 05:07:42 +00006307 struct ospf *ospf = vty->index;
6308
6309 ospf->distance_all = 0;
6310
paul718e3742002-12-13 20:15:29 +00006311 return CMD_SUCCESS;
6312}
6313
6314DEFUN (no_ospf_distance_ospf,
6315 no_ospf_distance_ospf_cmd,
6316 "no distance ospf",
6317 NO_STR
6318 "Define an administrative distance\n"
6319 "OSPF Administrative distance\n"
6320 "OSPF Distance\n")
6321{
paul68980082003-03-25 05:07:42 +00006322 struct ospf *ospf = vty->index;
6323
6324 ospf->distance_intra = 0;
6325 ospf->distance_inter = 0;
6326 ospf->distance_external = 0;
6327
paul718e3742002-12-13 20:15:29 +00006328 return CMD_SUCCESS;
6329}
6330
6331DEFUN (ospf_distance_ospf_intra,
6332 ospf_distance_ospf_intra_cmd,
6333 "distance ospf intra-area <1-255>",
6334 "Define an administrative distance\n"
6335 "OSPF Administrative distance\n"
6336 "Intra-area routes\n"
6337 "Distance for intra-area routes\n")
6338{
paul68980082003-03-25 05:07:42 +00006339 struct ospf *ospf = vty->index;
6340
6341 ospf->distance_intra = atoi (argv[0]);
6342
paul718e3742002-12-13 20:15:29 +00006343 return CMD_SUCCESS;
6344}
6345
6346DEFUN (ospf_distance_ospf_intra_inter,
6347 ospf_distance_ospf_intra_inter_cmd,
6348 "distance ospf intra-area <1-255> inter-area <1-255>",
6349 "Define an administrative distance\n"
6350 "OSPF Administrative distance\n"
6351 "Intra-area routes\n"
6352 "Distance for intra-area routes\n"
6353 "Inter-area routes\n"
6354 "Distance for inter-area routes\n")
6355{
paul68980082003-03-25 05:07:42 +00006356 struct ospf *ospf = vty->index;
6357
6358 ospf->distance_intra = atoi (argv[0]);
6359 ospf->distance_inter = atoi (argv[1]);
6360
paul718e3742002-12-13 20:15:29 +00006361 return CMD_SUCCESS;
6362}
6363
6364DEFUN (ospf_distance_ospf_intra_external,
6365 ospf_distance_ospf_intra_external_cmd,
6366 "distance ospf intra-area <1-255> external <1-255>",
6367 "Define an administrative distance\n"
6368 "OSPF Administrative distance\n"
6369 "Intra-area routes\n"
6370 "Distance for intra-area routes\n"
6371 "External routes\n"
6372 "Distance for external routes\n")
6373{
paul68980082003-03-25 05:07:42 +00006374 struct ospf *ospf = vty->index;
6375
6376 ospf->distance_intra = atoi (argv[0]);
6377 ospf->distance_external = atoi (argv[1]);
6378
paul718e3742002-12-13 20:15:29 +00006379 return CMD_SUCCESS;
6380}
6381
6382DEFUN (ospf_distance_ospf_intra_inter_external,
6383 ospf_distance_ospf_intra_inter_external_cmd,
6384 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6385 "Define an administrative distance\n"
6386 "OSPF Administrative distance\n"
6387 "Intra-area routes\n"
6388 "Distance for intra-area routes\n"
6389 "Inter-area routes\n"
6390 "Distance for inter-area routes\n"
6391 "External routes\n"
6392 "Distance for external routes\n")
6393{
paul68980082003-03-25 05:07:42 +00006394 struct ospf *ospf = vty->index;
6395
6396 ospf->distance_intra = atoi (argv[0]);
6397 ospf->distance_inter = atoi (argv[1]);
6398 ospf->distance_external = atoi (argv[2]);
6399
paul718e3742002-12-13 20:15:29 +00006400 return CMD_SUCCESS;
6401}
6402
6403DEFUN (ospf_distance_ospf_intra_external_inter,
6404 ospf_distance_ospf_intra_external_inter_cmd,
6405 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6406 "Define an administrative distance\n"
6407 "OSPF Administrative distance\n"
6408 "Intra-area routes\n"
6409 "Distance for intra-area routes\n"
6410 "External routes\n"
6411 "Distance for external routes\n"
6412 "Inter-area routes\n"
6413 "Distance for inter-area routes\n")
6414{
paul68980082003-03-25 05:07:42 +00006415 struct ospf *ospf = vty->index;
6416
6417 ospf->distance_intra = atoi (argv[0]);
6418 ospf->distance_external = atoi (argv[1]);
6419 ospf->distance_inter = atoi (argv[2]);
6420
paul718e3742002-12-13 20:15:29 +00006421 return CMD_SUCCESS;
6422}
6423
6424DEFUN (ospf_distance_ospf_inter,
6425 ospf_distance_ospf_inter_cmd,
6426 "distance ospf inter-area <1-255>",
6427 "Define an administrative distance\n"
6428 "OSPF Administrative distance\n"
6429 "Inter-area routes\n"
6430 "Distance for inter-area routes\n")
6431{
paul68980082003-03-25 05:07:42 +00006432 struct ospf *ospf = vty->index;
6433
6434 ospf->distance_inter = atoi (argv[0]);
6435
paul718e3742002-12-13 20:15:29 +00006436 return CMD_SUCCESS;
6437}
6438
6439DEFUN (ospf_distance_ospf_inter_intra,
6440 ospf_distance_ospf_inter_intra_cmd,
6441 "distance ospf inter-area <1-255> intra-area <1-255>",
6442 "Define an administrative distance\n"
6443 "OSPF Administrative distance\n"
6444 "Inter-area routes\n"
6445 "Distance for inter-area routes\n"
6446 "Intra-area routes\n"
6447 "Distance for intra-area routes\n")
6448{
paul68980082003-03-25 05:07:42 +00006449 struct ospf *ospf = vty->index;
6450
6451 ospf->distance_inter = atoi (argv[0]);
6452 ospf->distance_intra = atoi (argv[1]);
6453
paul718e3742002-12-13 20:15:29 +00006454 return CMD_SUCCESS;
6455}
6456
6457DEFUN (ospf_distance_ospf_inter_external,
6458 ospf_distance_ospf_inter_external_cmd,
6459 "distance ospf inter-area <1-255> external <1-255>",
6460 "Define an administrative distance\n"
6461 "OSPF Administrative distance\n"
6462 "Inter-area routes\n"
6463 "Distance for inter-area routes\n"
6464 "External routes\n"
6465 "Distance for external routes\n")
6466{
paul68980082003-03-25 05:07:42 +00006467 struct ospf *ospf = vty->index;
6468
6469 ospf->distance_inter = atoi (argv[0]);
6470 ospf->distance_external = atoi (argv[1]);
6471
paul718e3742002-12-13 20:15:29 +00006472 return CMD_SUCCESS;
6473}
6474
6475DEFUN (ospf_distance_ospf_inter_intra_external,
6476 ospf_distance_ospf_inter_intra_external_cmd,
6477 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6478 "Define an administrative distance\n"
6479 "OSPF Administrative distance\n"
6480 "Inter-area routes\n"
6481 "Distance for inter-area routes\n"
6482 "Intra-area routes\n"
6483 "Distance for intra-area routes\n"
6484 "External routes\n"
6485 "Distance for external routes\n")
6486{
paul68980082003-03-25 05:07:42 +00006487 struct ospf *ospf = vty->index;
6488
6489 ospf->distance_inter = atoi (argv[0]);
6490 ospf->distance_intra = atoi (argv[1]);
6491 ospf->distance_external = atoi (argv[2]);
6492
paul718e3742002-12-13 20:15:29 +00006493 return CMD_SUCCESS;
6494}
6495
6496DEFUN (ospf_distance_ospf_inter_external_intra,
6497 ospf_distance_ospf_inter_external_intra_cmd,
6498 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6499 "Define an administrative distance\n"
6500 "OSPF Administrative distance\n"
6501 "Inter-area routes\n"
6502 "Distance for inter-area routes\n"
6503 "External routes\n"
6504 "Distance for external routes\n"
6505 "Intra-area routes\n"
6506 "Distance for intra-area routes\n")
6507{
paul68980082003-03-25 05:07:42 +00006508 struct ospf *ospf = vty->index;
6509
6510 ospf->distance_inter = atoi (argv[0]);
6511 ospf->distance_external = atoi (argv[1]);
6512 ospf->distance_intra = atoi (argv[2]);
6513
paul718e3742002-12-13 20:15:29 +00006514 return CMD_SUCCESS;
6515}
6516
6517DEFUN (ospf_distance_ospf_external,
6518 ospf_distance_ospf_external_cmd,
6519 "distance ospf external <1-255>",
6520 "Define an administrative distance\n"
6521 "OSPF Administrative distance\n"
6522 "External routes\n"
6523 "Distance for external routes\n")
6524{
paul68980082003-03-25 05:07:42 +00006525 struct ospf *ospf = vty->index;
6526
6527 ospf->distance_external = atoi (argv[0]);
6528
paul718e3742002-12-13 20:15:29 +00006529 return CMD_SUCCESS;
6530}
6531
6532DEFUN (ospf_distance_ospf_external_intra,
6533 ospf_distance_ospf_external_intra_cmd,
6534 "distance ospf external <1-255> intra-area <1-255>",
6535 "Define an administrative distance\n"
6536 "OSPF Administrative distance\n"
6537 "External routes\n"
6538 "Distance for external routes\n"
6539 "Intra-area routes\n"
6540 "Distance for intra-area routes\n")
6541{
paul68980082003-03-25 05:07:42 +00006542 struct ospf *ospf = vty->index;
6543
6544 ospf->distance_external = atoi (argv[0]);
6545 ospf->distance_intra = atoi (argv[1]);
6546
paul718e3742002-12-13 20:15:29 +00006547 return CMD_SUCCESS;
6548}
6549
6550DEFUN (ospf_distance_ospf_external_inter,
6551 ospf_distance_ospf_external_inter_cmd,
6552 "distance ospf external <1-255> inter-area <1-255>",
6553 "Define an administrative distance\n"
6554 "OSPF Administrative distance\n"
6555 "External routes\n"
6556 "Distance for external routes\n"
6557 "Inter-area routes\n"
6558 "Distance for inter-area routes\n")
6559{
paul68980082003-03-25 05:07:42 +00006560 struct ospf *ospf = vty->index;
6561
6562 ospf->distance_external = atoi (argv[0]);
6563 ospf->distance_inter = atoi (argv[1]);
6564
paul718e3742002-12-13 20:15:29 +00006565 return CMD_SUCCESS;
6566}
6567
6568DEFUN (ospf_distance_ospf_external_intra_inter,
6569 ospf_distance_ospf_external_intra_inter_cmd,
6570 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6571 "Define an administrative distance\n"
6572 "OSPF Administrative distance\n"
6573 "External routes\n"
6574 "Distance for external routes\n"
6575 "Intra-area routes\n"
6576 "Distance for intra-area routes\n"
6577 "Inter-area routes\n"
6578 "Distance for inter-area routes\n")
6579{
paul68980082003-03-25 05:07:42 +00006580 struct ospf *ospf = vty->index;
6581
6582 ospf->distance_external = atoi (argv[0]);
6583 ospf->distance_intra = atoi (argv[1]);
6584 ospf->distance_inter = atoi (argv[2]);
6585
paul718e3742002-12-13 20:15:29 +00006586 return CMD_SUCCESS;
6587}
6588
6589DEFUN (ospf_distance_ospf_external_inter_intra,
6590 ospf_distance_ospf_external_inter_intra_cmd,
6591 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6592 "Define an administrative distance\n"
6593 "OSPF Administrative distance\n"
6594 "External routes\n"
6595 "Distance for external routes\n"
6596 "Inter-area routes\n"
6597 "Distance for inter-area routes\n"
6598 "Intra-area routes\n"
6599 "Distance for intra-area routes\n")
6600{
paul68980082003-03-25 05:07:42 +00006601 struct ospf *ospf = vty->index;
6602
6603 ospf->distance_external = atoi (argv[0]);
6604 ospf->distance_inter = atoi (argv[1]);
6605 ospf->distance_intra = atoi (argv[2]);
6606
paul718e3742002-12-13 20:15:29 +00006607 return CMD_SUCCESS;
6608}
6609
6610DEFUN (ospf_distance_source,
6611 ospf_distance_source_cmd,
6612 "distance <1-255> A.B.C.D/M",
6613 "Administrative distance\n"
6614 "Distance value\n"
6615 "IP source prefix\n")
6616{
paul020709f2003-04-04 02:44:16 +00006617 struct ospf *ospf = vty->index;
6618
6619 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006620
paul718e3742002-12-13 20:15:29 +00006621 return CMD_SUCCESS;
6622}
6623
6624DEFUN (no_ospf_distance_source,
6625 no_ospf_distance_source_cmd,
6626 "no distance <1-255> A.B.C.D/M",
6627 NO_STR
6628 "Administrative distance\n"
6629 "Distance value\n"
6630 "IP source prefix\n")
6631{
paul020709f2003-04-04 02:44:16 +00006632 struct ospf *ospf = vty->index;
6633
6634 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6635
paul718e3742002-12-13 20:15:29 +00006636 return CMD_SUCCESS;
6637}
6638
6639DEFUN (ospf_distance_source_access_list,
6640 ospf_distance_source_access_list_cmd,
6641 "distance <1-255> A.B.C.D/M WORD",
6642 "Administrative distance\n"
6643 "Distance value\n"
6644 "IP source prefix\n"
6645 "Access list name\n")
6646{
paul020709f2003-04-04 02:44:16 +00006647 struct ospf *ospf = vty->index;
6648
6649 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6650
paul718e3742002-12-13 20:15:29 +00006651 return CMD_SUCCESS;
6652}
6653
6654DEFUN (no_ospf_distance_source_access_list,
6655 no_ospf_distance_source_access_list_cmd,
6656 "no distance <1-255> A.B.C.D/M WORD",
6657 NO_STR
6658 "Administrative distance\n"
6659 "Distance value\n"
6660 "IP source prefix\n"
6661 "Access list name\n")
6662{
paul020709f2003-04-04 02:44:16 +00006663 struct ospf *ospf = vty->index;
6664
6665 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6666
paul718e3742002-12-13 20:15:29 +00006667 return CMD_SUCCESS;
6668}
6669
vincentba682532005-09-29 13:52:57 +00006670DEFUN (ip_ospf_mtu_ignore,
6671 ip_ospf_mtu_ignore_addr_cmd,
6672 "ip ospf mtu-ignore A.B.C.D",
6673 "IP Information\n"
6674 "OSPF interface commands\n"
6675 "Disable mtu mismatch detection\n"
6676 "Address of interface")
6677{
6678 struct interface *ifp = vty->index;
6679 struct in_addr addr;
6680 int ret;
6681
6682 struct ospf_if_params *params;
6683 params = IF_DEF_PARAMS (ifp);
6684
6685 if (argc == 1)
6686 {
6687 ret = inet_aton(argv[0], &addr);
6688 if (!ret)
6689 {
6690 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6691 VTY_NEWLINE);
6692 return CMD_WARNING;
6693 }
6694 params = ospf_get_if_params (ifp, addr);
6695 ospf_if_update_params (ifp, addr);
6696 }
6697 params->mtu_ignore = 1;
6698 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6699 SET_IF_PARAM (params, mtu_ignore);
6700 else
6701 {
6702 UNSET_IF_PARAM (params, mtu_ignore);
6703 if (params != IF_DEF_PARAMS (ifp))
6704 {
6705 ospf_free_if_params (ifp, addr);
6706 ospf_if_update_params (ifp, addr);
6707 }
6708 }
6709 return CMD_SUCCESS;
6710}
6711
6712ALIAS (ip_ospf_mtu_ignore,
6713 ip_ospf_mtu_ignore_cmd,
6714 "ip ospf mtu-ignore",
6715 "IP Information\n"
6716 "OSPF interface commands\n"
6717 "Disable mtu mismatch detection\n")
6718
6719
6720DEFUN (no_ip_ospf_mtu_ignore,
6721 no_ip_ospf_mtu_ignore_addr_cmd,
6722 "no ip ospf mtu-ignore A.B.C.D",
6723 "IP Information\n"
6724 "OSPF interface commands\n"
6725 "Disable mtu mismatch detection\n"
6726 "Address of interface")
6727{
6728 struct interface *ifp = vty->index;
6729 struct in_addr addr;
6730 int ret;
6731
6732 struct ospf_if_params *params;
6733 params = IF_DEF_PARAMS (ifp);
6734
6735 if (argc == 1)
6736 {
6737 ret = inet_aton(argv[0], &addr);
6738 if (!ret)
6739 {
6740 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6741 VTY_NEWLINE);
6742 return CMD_WARNING;
6743 }
6744 params = ospf_get_if_params (ifp, addr);
6745 ospf_if_update_params (ifp, addr);
6746 }
6747 params->mtu_ignore = 0;
6748 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6749 SET_IF_PARAM (params, mtu_ignore);
6750 else
6751 {
6752 UNSET_IF_PARAM (params, mtu_ignore);
6753 if (params != IF_DEF_PARAMS (ifp))
6754 {
6755 ospf_free_if_params (ifp, addr);
6756 ospf_if_update_params (ifp, addr);
6757 }
6758 }
6759 return CMD_SUCCESS;
6760}
6761
6762ALIAS (no_ip_ospf_mtu_ignore,
6763 no_ip_ospf_mtu_ignore_cmd,
6764 "no ip ospf mtu-ignore",
6765 "IP Information\n"
6766 "OSPF interface commands\n"
6767 "Disable mtu mismatch detection\n")
6768
paul4dadc292005-05-06 21:37:42 +00006769static void
paul718e3742002-12-13 20:15:29 +00006770show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6771{
6772 struct route_node *rn;
6773 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006774 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006775 struct ospf_path *path;
6776
6777 vty_out (vty, "============ OSPF network routing table ============%s",
6778 VTY_NEWLINE);
6779
6780 for (rn = route_top (rt); rn; rn = route_next (rn))
6781 if ((or = rn->info) != NULL)
6782 {
6783 char buf1[19];
6784 snprintf (buf1, 19, "%s/%d",
6785 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6786
6787 switch (or->path_type)
6788 {
6789 case OSPF_PATH_INTER_AREA:
6790 if (or->type == OSPF_DESTINATION_NETWORK)
6791 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6792 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6793 else if (or->type == OSPF_DESTINATION_DISCARD)
6794 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6795 break;
6796 case OSPF_PATH_INTRA_AREA:
6797 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6798 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6799 break;
6800 default:
6801 break;
6802 }
6803
6804 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00006805 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00006806 {
hasso54bedb52005-08-17 13:31:47 +00006807 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00006808 {
6809 if (path->nexthop.s_addr == 0)
6810 vty_out (vty, "%24s directly attached to %s%s",
6811 "", path->oi->ifp->name, VTY_NEWLINE);
6812 else
6813 vty_out (vty, "%24s via %s, %s%s", "",
6814 inet_ntoa (path->nexthop), path->oi->ifp->name,
6815 VTY_NEWLINE);
6816 }
6817 }
paul718e3742002-12-13 20:15:29 +00006818 }
6819 vty_out (vty, "%s", VTY_NEWLINE);
6820}
6821
paul4dadc292005-05-06 21:37:42 +00006822static void
paul718e3742002-12-13 20:15:29 +00006823show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6824{
6825 struct route_node *rn;
6826 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006827 struct listnode *pnode;
6828 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006829 struct ospf_path *path;
6830
6831 vty_out (vty, "============ OSPF router routing table =============%s",
6832 VTY_NEWLINE);
6833 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6834 if (rn->info)
6835 {
6836 int flag = 0;
6837
6838 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6839
paul1eb8ef22005-04-07 07:30:20 +00006840 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
6841 {
6842 if (flag++)
6843 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006844
paul1eb8ef22005-04-07 07:30:20 +00006845 /* Show path. */
6846 vty_out (vty, "%s [%d] area: %s",
6847 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6848 or->cost, inet_ntoa (or->u.std.area_id));
6849 /* Show flags. */
6850 vty_out (vty, "%s%s%s",
6851 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6852 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6853 VTY_NEWLINE);
6854
6855 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
6856 {
hasso54bedb52005-08-17 13:31:47 +00006857 if (path->oi != NULL && ospf_if_exists(path->oi))
6858 {
6859 if (path->nexthop.s_addr == 0)
6860 vty_out (vty, "%24s directly attached to %s%s",
6861 "", path->oi->ifp->name, VTY_NEWLINE);
6862 else
6863 vty_out (vty, "%24s via %s, %s%s", "",
6864 inet_ntoa (path->nexthop),
6865 path->oi->ifp->name, VTY_NEWLINE);
6866 }
paul1eb8ef22005-04-07 07:30:20 +00006867 }
6868 }
paul718e3742002-12-13 20:15:29 +00006869 }
6870 vty_out (vty, "%s", VTY_NEWLINE);
6871}
6872
paul4dadc292005-05-06 21:37:42 +00006873static void
paul718e3742002-12-13 20:15:29 +00006874show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6875{
6876 struct route_node *rn;
6877 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00006878 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006879 struct ospf_path *path;
6880
6881 vty_out (vty, "============ OSPF external routing table ===========%s",
6882 VTY_NEWLINE);
6883 for (rn = route_top (rt); rn; rn = route_next (rn))
6884 if ((er = rn->info) != NULL)
6885 {
6886 char buf1[19];
6887 snprintf (buf1, 19, "%s/%d",
6888 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6889
6890 switch (er->path_type)
6891 {
6892 case OSPF_PATH_TYPE1_EXTERNAL:
6893 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6894 er->cost, er->u.ext.tag, VTY_NEWLINE);
6895 break;
6896 case OSPF_PATH_TYPE2_EXTERNAL:
6897 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6898 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6899 break;
6900 }
6901
paul1eb8ef22005-04-07 07:30:20 +00006902 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00006903 {
hasso54bedb52005-08-17 13:31:47 +00006904 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00006905 {
6906 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006907 vty_out (vty, "%24s directly attached to %s%s",
6908 "", path->oi->ifp->name, VTY_NEWLINE);
6909 else
6910 vty_out (vty, "%24s via %s, %s%s", "",
6911 inet_ntoa (path->nexthop), path->oi->ifp->name,
6912 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006913 }
6914 }
6915 }
6916 vty_out (vty, "%s", VTY_NEWLINE);
6917}
6918
paul718e3742002-12-13 20:15:29 +00006919DEFUN (show_ip_ospf_border_routers,
6920 show_ip_ospf_border_routers_cmd,
6921 "show ip ospf border-routers",
6922 SHOW_STR
6923 IP_STR
6924 "show all the ABR's and ASBR's\n"
6925 "for this area\n")
6926{
paul020709f2003-04-04 02:44:16 +00006927 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006928
paul020709f2003-04-04 02:44:16 +00006929 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006930 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006931 {
6932 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6933 return CMD_SUCCESS;
6934 }
6935
paul68980082003-03-25 05:07:42 +00006936 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006937 {
6938 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6939 return CMD_SUCCESS;
6940 }
6941
6942 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006943 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006944
6945 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006946 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006947
6948 return CMD_SUCCESS;
6949}
paul718e3742002-12-13 20:15:29 +00006950
6951DEFUN (show_ip_ospf_route,
6952 show_ip_ospf_route_cmd,
6953 "show ip ospf route",
6954 SHOW_STR
6955 IP_STR
6956 "OSPF information\n"
6957 "OSPF routing table\n")
6958{
paul020709f2003-04-04 02:44:16 +00006959 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006960
paul020709f2003-04-04 02:44:16 +00006961 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006962 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006963 {
6964 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6965 return CMD_SUCCESS;
6966 }
6967
paul68980082003-03-25 05:07:42 +00006968 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006969 {
6970 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6971 return CMD_SUCCESS;
6972 }
6973
6974 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006975 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006976
6977 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006978 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006979
6980 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006981 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006982
6983 return CMD_SUCCESS;
6984}
6985
6986
hassoeb1ce602004-10-08 08:17:22 +00006987const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006988{
6989 "unknown",
6990 "standard",
6991 "ibm",
6992 "cisco",
6993 "shortcut"
6994};
6995
hassoeb1ce602004-10-08 08:17:22 +00006996const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006997{
6998 "default",
6999 "enable",
7000 "disable"
7001};
7002
7003
paul4dadc292005-05-06 21:37:42 +00007004static void
paul718e3742002-12-13 20:15:29 +00007005area_id2str (char *buf, int length, struct ospf_area *area)
7006{
7007 memset (buf, 0, length);
7008
7009 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7010 strncpy (buf, inet_ntoa (area->area_id), length);
7011 else
7012 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7013}
7014
7015
hassoeb1ce602004-10-08 08:17:22 +00007016const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007017{
7018 "unknown", /* should never be used. */
7019 "point-to-point",
7020 "broadcast",
7021 "non-broadcast",
7022 "point-to-multipoint",
7023 "virtual-link", /* should never be used. */
7024 "loopback"
7025};
7026
7027/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007028static int
paul718e3742002-12-13 20:15:29 +00007029config_write_interface (struct vty *vty)
7030{
hasso52dc7ee2004-09-23 19:18:23 +00007031 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007032 struct interface *ifp;
7033 struct crypt_key *ck;
7034 int write = 0;
7035 struct route_node *rn = NULL;
7036 struct ospf_if_params *params;
7037
paul1eb8ef22005-04-07 07:30:20 +00007038 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007039 {
paul718e3742002-12-13 20:15:29 +00007040 if (memcmp (ifp->name, "VLINK", 5) == 0)
7041 continue;
7042
7043 vty_out (vty, "!%s", VTY_NEWLINE);
7044 vty_out (vty, "interface %s%s", ifp->name,
7045 VTY_NEWLINE);
7046 if (ifp->desc)
7047 vty_out (vty, " description %s%s", ifp->desc,
7048 VTY_NEWLINE);
7049
7050 write++;
7051
7052 params = IF_DEF_PARAMS (ifp);
7053
7054 do {
7055 /* Interface Network print. */
7056 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007057 params->type != OSPF_IFTYPE_LOOPBACK)
7058 {
ajsbc18d612004-12-15 15:07:19 +00007059 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007060 {
7061 vty_out (vty, " ip ospf network %s",
7062 ospf_int_type_str[params->type]);
7063 if (params != IF_DEF_PARAMS (ifp))
7064 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7065 vty_out (vty, "%s", VTY_NEWLINE);
7066 }
paul718e3742002-12-13 20:15:29 +00007067 }
7068
7069 /* OSPF interface authentication print */
7070 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7071 params->auth_type != OSPF_AUTH_NOTSET)
7072 {
hassoeb1ce602004-10-08 08:17:22 +00007073 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007074
7075 /* Translation tables are not that much help here due to syntax
7076 of the simple option */
7077 switch (params->auth_type)
7078 {
7079
7080 case OSPF_AUTH_NULL:
7081 auth_str = " null";
7082 break;
7083
7084 case OSPF_AUTH_SIMPLE:
7085 auth_str = "";
7086 break;
7087
7088 case OSPF_AUTH_CRYPTOGRAPHIC:
7089 auth_str = " message-digest";
7090 break;
7091
7092 default:
7093 auth_str = "";
7094 break;
7095 }
7096
7097 vty_out (vty, " ip ospf authentication%s", auth_str);
7098 if (params != IF_DEF_PARAMS (ifp))
7099 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7100 vty_out (vty, "%s", VTY_NEWLINE);
7101 }
7102
7103 /* Simple Authentication Password print. */
7104 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7105 params->auth_simple[0] != '\0')
7106 {
7107 vty_out (vty, " ip ospf authentication-key %s",
7108 params->auth_simple);
7109 if (params != IF_DEF_PARAMS (ifp))
7110 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7111 vty_out (vty, "%s", VTY_NEWLINE);
7112 }
7113
7114 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007115 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007116 {
paul718e3742002-12-13 20:15:29 +00007117 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7118 ck->key_id, ck->auth_key);
7119 if (params != IF_DEF_PARAMS (ifp))
7120 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7121 vty_out (vty, "%s", VTY_NEWLINE);
7122 }
7123
7124 /* Interface Output Cost print. */
7125 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7126 {
7127 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7128 if (params != IF_DEF_PARAMS (ifp))
7129 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7130 vty_out (vty, "%s", VTY_NEWLINE);
7131 }
7132
7133 /* Hello Interval print. */
7134 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7135 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7136 {
7137 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7138 if (params != IF_DEF_PARAMS (ifp))
7139 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7140 vty_out (vty, "%s", VTY_NEWLINE);
7141 }
7142
7143
7144 /* Router Dead Interval print. */
7145 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7146 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7147 {
paulf9ad9372005-10-21 00:45:17 +00007148 vty_out (vty, " ip ospf dead-interval ");
7149
7150 /* fast hello ? */
7151 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7152 vty_out (vty, "minimal hello-multiplier %d",
7153 params->fast_hello);
7154 else
7155 vty_out (vty, "%u", params->v_wait);
7156
paul718e3742002-12-13 20:15:29 +00007157 if (params != IF_DEF_PARAMS (ifp))
7158 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7159 vty_out (vty, "%s", VTY_NEWLINE);
7160 }
7161
7162 /* Router Priority print. */
7163 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7164 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7165 {
7166 vty_out (vty, " ip ospf priority %u", params->priority);
7167 if (params != IF_DEF_PARAMS (ifp))
7168 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7169 vty_out (vty, "%s", VTY_NEWLINE);
7170 }
7171
7172 /* Retransmit Interval print. */
7173 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7174 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7175 {
7176 vty_out (vty, " ip ospf retransmit-interval %u",
7177 params->retransmit_interval);
7178 if (params != IF_DEF_PARAMS (ifp))
7179 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7180 vty_out (vty, "%s", VTY_NEWLINE);
7181 }
7182
7183 /* Transmit Delay print. */
7184 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7185 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7186 {
7187 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7188 if (params != IF_DEF_PARAMS (ifp))
7189 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7190 vty_out (vty, "%s", VTY_NEWLINE);
7191 }
7192
vincentba682532005-09-29 13:52:57 +00007193 /* MTU ignore print. */
7194 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7195 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7196 {
7197 if (params->mtu_ignore == 0)
7198 vty_out (vty, " no ip ospf mtu-ignore");
7199 else
7200 vty_out (vty, " ip ospf mtu-ignore");
7201 if (params != IF_DEF_PARAMS (ifp))
7202 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7203 vty_out (vty, "%s", VTY_NEWLINE);
7204 }
7205
7206
paul718e3742002-12-13 20:15:29 +00007207 while (1)
7208 {
7209 if (rn == NULL)
7210 rn = route_top (IF_OIFS_PARAMS (ifp));
7211 else
7212 rn = route_next (rn);
7213
7214 if (rn == NULL)
7215 break;
7216 params = rn->info;
7217 if (params != NULL)
7218 break;
7219 }
7220 } while (rn);
7221
7222#ifdef HAVE_OPAQUE_LSA
7223 ospf_opaque_config_write_if (vty, ifp);
7224#endif /* HAVE_OPAQUE_LSA */
7225 }
7226
7227 return write;
7228}
7229
paul4dadc292005-05-06 21:37:42 +00007230static int
paul68980082003-03-25 05:07:42 +00007231config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007232{
7233 struct route_node *rn;
7234 u_char buf[INET_ADDRSTRLEN];
7235
7236 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007237 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007238 if (rn->info)
7239 {
7240 struct ospf_network *n = rn->info;
7241
7242 memset (buf, 0, INET_ADDRSTRLEN);
7243
7244 /* Create Area ID string by specified Area ID format. */
7245 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007246 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007247 else
hassoc9e52be2004-09-26 16:09:34 +00007248 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007249 (unsigned long int) ntohl (n->area_id.s_addr));
7250
7251 /* Network print. */
7252 vty_out (vty, " network %s/%d area %s%s",
7253 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7254 buf, VTY_NEWLINE);
7255 }
7256
7257 return 0;
7258}
7259
paul4dadc292005-05-06 21:37:42 +00007260static int
paul68980082003-03-25 05:07:42 +00007261config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007262{
hasso52dc7ee2004-09-23 19:18:23 +00007263 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007264 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007265 u_char buf[INET_ADDRSTRLEN];
7266
7267 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007268 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007269 {
paul718e3742002-12-13 20:15:29 +00007270 struct route_node *rn1;
7271
hassoc9e52be2004-09-26 16:09:34 +00007272 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007273
7274 if (area->auth_type != OSPF_AUTH_NULL)
7275 {
7276 if (area->auth_type == OSPF_AUTH_SIMPLE)
7277 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7278 else
7279 vty_out (vty, " area %s authentication message-digest%s",
7280 buf, VTY_NEWLINE);
7281 }
7282
7283 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7284 vty_out (vty, " area %s shortcut %s%s", buf,
7285 ospf_shortcut_mode_str[area->shortcut_configured],
7286 VTY_NEWLINE);
7287
7288 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007289 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007290 )
7291 {
paulb0a053b2003-06-22 09:04:47 +00007292 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007293 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007294 else if (area->external_routing == OSPF_AREA_NSSA)
7295 {
7296 vty_out (vty, " area %s nssa", buf);
7297 switch (area->NSSATranslatorRole)
7298 {
7299 case OSPF_NSSA_ROLE_NEVER:
7300 vty_out (vty, " translate-never");
7301 break;
7302 case OSPF_NSSA_ROLE_ALWAYS:
7303 vty_out (vty, " translate-always");
7304 break;
7305 case OSPF_NSSA_ROLE_CANDIDATE:
7306 default:
7307 vty_out (vty, " translate-candidate");
7308 }
7309 }
paul718e3742002-12-13 20:15:29 +00007310
7311 if (area->no_summary)
7312 vty_out (vty, " no-summary");
7313
7314 vty_out (vty, "%s", VTY_NEWLINE);
7315
7316 if (area->default_cost != 1)
7317 vty_out (vty, " area %s default-cost %d%s", buf,
7318 area->default_cost, VTY_NEWLINE);
7319 }
7320
7321 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7322 if (rn1->info)
7323 {
7324 struct ospf_area_range *range = rn1->info;
7325
7326 vty_out (vty, " area %s range %s/%d", buf,
7327 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7328
paul6c835672004-10-11 11:00:30 +00007329 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007330 vty_out (vty, " cost %d", range->cost_config);
7331
7332 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7333 vty_out (vty, " not-advertise");
7334
7335 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7336 vty_out (vty, " substitute %s/%d",
7337 inet_ntoa (range->subst_addr), range->subst_masklen);
7338
7339 vty_out (vty, "%s", VTY_NEWLINE);
7340 }
7341
7342 if (EXPORT_NAME (area))
7343 vty_out (vty, " area %s export-list %s%s", buf,
7344 EXPORT_NAME (area), VTY_NEWLINE);
7345
7346 if (IMPORT_NAME (area))
7347 vty_out (vty, " area %s import-list %s%s", buf,
7348 IMPORT_NAME (area), VTY_NEWLINE);
7349
7350 if (PREFIX_NAME_IN (area))
7351 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7352 PREFIX_NAME_IN (area), VTY_NEWLINE);
7353
7354 if (PREFIX_NAME_OUT (area))
7355 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7356 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7357 }
7358
7359 return 0;
7360}
7361
paul4dadc292005-05-06 21:37:42 +00007362static int
paul68980082003-03-25 05:07:42 +00007363config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007364{
7365 struct ospf_nbr_nbma *nbr_nbma;
7366 struct route_node *rn;
7367
7368 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007369 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007370 if ((nbr_nbma = rn->info))
7371 {
7372 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7373
7374 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7375 vty_out (vty, " priority %d", nbr_nbma->priority);
7376
7377 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7378 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7379
7380 vty_out (vty, "%s", VTY_NEWLINE);
7381 }
7382
7383 return 0;
7384}
7385
paul4dadc292005-05-06 21:37:42 +00007386static int
paul68980082003-03-25 05:07:42 +00007387config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007388{
hasso52dc7ee2004-09-23 19:18:23 +00007389 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007390 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007391 u_char buf[INET_ADDRSTRLEN];
7392
7393 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007394 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007395 {
hasso52dc7ee2004-09-23 19:18:23 +00007396 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007397 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007398 struct ospf_interface *oi;
7399
7400 if (vl_data != NULL)
7401 {
7402 memset (buf, 0, INET_ADDRSTRLEN);
7403
7404 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007405 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007406 else
hassoc9e52be2004-09-26 16:09:34 +00007407 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007408 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7409 oi = vl_data->vl_oi;
7410
7411 /* timers */
7412 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7413 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7414 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7415 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7416 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7417 buf,
7418 inet_ntoa (vl_data->vl_peer),
7419 OSPF_IF_PARAM (oi, v_hello),
7420 OSPF_IF_PARAM (oi, retransmit_interval),
7421 OSPF_IF_PARAM (oi, transmit_delay),
7422 OSPF_IF_PARAM (oi, v_wait),
7423 VTY_NEWLINE);
7424 else
7425 vty_out (vty, " area %s virtual-link %s%s", buf,
7426 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7427 /* Auth key */
7428 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7429 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7430 buf,
7431 inet_ntoa (vl_data->vl_peer),
7432 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7433 VTY_NEWLINE);
7434 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007435 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7436 n2, ck))
7437 vty_out (vty, " area %s virtual-link %s"
7438 " message-digest-key %d md5 %s%s",
7439 buf,
7440 inet_ntoa (vl_data->vl_peer),
7441 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007442
7443 }
7444 }
7445
7446 return 0;
7447}
7448
7449
paul4dadc292005-05-06 21:37:42 +00007450static int
paul68980082003-03-25 05:07:42 +00007451config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007452{
7453 int type;
7454
7455 /* redistribute print. */
7456 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7457 if (type != zclient->redist_default && zclient->redist[type])
7458 {
ajsf52d13c2005-10-01 17:38:06 +00007459 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007460 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007461 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007462
paul68980082003-03-25 05:07:42 +00007463 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007464 vty_out (vty, " metric-type 1");
7465
paul020709f2003-04-04 02:44:16 +00007466 if (ROUTEMAP_NAME (ospf, type))
7467 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007468
7469 vty_out (vty, "%s", VTY_NEWLINE);
7470 }
7471
7472 return 0;
7473}
7474
paul4dadc292005-05-06 21:37:42 +00007475static int
paul68980082003-03-25 05:07:42 +00007476config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007477{
paul68980082003-03-25 05:07:42 +00007478 if (ospf->default_metric != -1)
7479 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007480 VTY_NEWLINE);
7481 return 0;
7482}
7483
paul4dadc292005-05-06 21:37:42 +00007484static int
paul68980082003-03-25 05:07:42 +00007485config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007486{
7487 int type;
7488
paul68980082003-03-25 05:07:42 +00007489 if (ospf)
paul718e3742002-12-13 20:15:29 +00007490 {
7491 /* distribute-list print. */
7492 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007493 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007494 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007495 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007496 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007497
7498 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007499 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007500 {
paul68980082003-03-25 05:07:42 +00007501 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007502 vty_out (vty, " default-information originate");
7503 else
7504 vty_out (vty, " default-information originate always");
7505
paul68980082003-03-25 05:07:42 +00007506 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007507 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007508 ospf->dmetric[DEFAULT_ROUTE].value);
7509 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007510 vty_out (vty, " metric-type 1");
7511
paul020709f2003-04-04 02:44:16 +00007512 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7513 vty_out (vty, " route-map %s",
7514 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007515
7516 vty_out (vty, "%s", VTY_NEWLINE);
7517 }
7518
7519 }
7520
7521 return 0;
7522}
7523
paul4dadc292005-05-06 21:37:42 +00007524static int
paul68980082003-03-25 05:07:42 +00007525config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007526{
7527 struct route_node *rn;
7528 struct ospf_distance *odistance;
7529
paul68980082003-03-25 05:07:42 +00007530 if (ospf->distance_all)
7531 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007532
paul68980082003-03-25 05:07:42 +00007533 if (ospf->distance_intra
7534 || ospf->distance_inter
7535 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007536 {
7537 vty_out (vty, " distance ospf");
7538
paul68980082003-03-25 05:07:42 +00007539 if (ospf->distance_intra)
7540 vty_out (vty, " intra-area %d", ospf->distance_intra);
7541 if (ospf->distance_inter)
7542 vty_out (vty, " inter-area %d", ospf->distance_inter);
7543 if (ospf->distance_external)
7544 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007545
7546 vty_out (vty, "%s", VTY_NEWLINE);
7547 }
7548
paul68980082003-03-25 05:07:42 +00007549 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007550 if ((odistance = rn->info) != NULL)
7551 {
7552 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7553 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7554 odistance->access_list ? odistance->access_list : "",
7555 VTY_NEWLINE);
7556 }
7557 return 0;
7558}
7559
7560/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007561static int
paul718e3742002-12-13 20:15:29 +00007562ospf_config_write (struct vty *vty)
7563{
paul020709f2003-04-04 02:44:16 +00007564 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007565 struct interface *ifp;
7566 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007567 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007568 int write = 0;
7569
paul020709f2003-04-04 02:44:16 +00007570 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007571 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007572 {
7573 /* `router ospf' print. */
7574 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7575
7576 write++;
7577
paul68980082003-03-25 05:07:42 +00007578 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007579 return write;
7580
7581 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007582 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007583 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007584 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007585
7586 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007587 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007588 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007589 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007590
7591 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007592 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007593 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7594
7595 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007596 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007597 {
7598 vty_out (vty, "! Important: ensure reference bandwidth "
7599 "is consistent across all routers%s", VTY_NEWLINE);
7600 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7601 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7602 }
paul718e3742002-12-13 20:15:29 +00007603
7604 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007605 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007606 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7607 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7608 vty_out (vty, " timers throttle spf %d %d %d%s",
7609 ospf->spf_delay, ospf->spf_holdtime,
7610 ospf->spf_max_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007611
7612 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007613 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007614 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007615 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007616
7617 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007618 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007619
7620 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007621 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7622 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7623 vty_out (vty, " passive-interface %s%s",
7624 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007625
paul1eb8ef22005-04-07 07:30:20 +00007626 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7627 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7628 oi->params->passive_interface == OSPF_IF_PASSIVE)
7629 vty_out (vty, " passive-interface %s %s%s",
7630 oi->ifp->name,
7631 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007632
7633 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007634 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007635
7636 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007637 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007638
7639 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007640 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007641
7642 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007643 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007644
7645 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007646 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007647
7648 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007649 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007650
7651 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007652 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007653
7654#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007655 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007656#endif /* HAVE_OPAQUE_LSA */
7657 }
7658
7659 return write;
7660}
7661
7662void
paul4dadc292005-05-06 21:37:42 +00007663ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007664{
7665 /* "show ip ospf" commands. */
7666 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7667 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7668
7669 /* "show ip ospf database" commands. */
7670 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7671 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7672 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7673 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7674 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7675 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7676 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7677 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7678 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7679 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7680 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7681 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7682 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7683 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7684
7685 /* "show ip ospf interface" commands. */
7686 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7687 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7688
7689 /* "show ip ospf neighbor" commands. */
7690 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7691 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7692 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7693 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7694 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7695 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7696 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7697 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7698 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7699 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7700 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7701 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7702 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7703 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7704
7705 /* "show ip ospf route" commands. */
7706 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7707 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007708 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7709 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007710}
7711
7712
7713/* ospfd's interface node. */
7714struct cmd_node interface_node =
7715{
7716 INTERFACE_NODE,
7717 "%s(config-if)# ",
7718 1
7719};
7720
7721/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007722static void
7723ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007724{
7725 /* Install interface node. */
7726 install_node (&interface_node, config_write_interface);
7727
7728 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007729 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007730 install_default (INTERFACE_NODE);
7731
7732 /* "description" commands. */
7733 install_element (INTERFACE_NODE, &interface_desc_cmd);
7734 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7735
7736 /* "ip ospf authentication" commands. */
7737 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7738 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7739 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7740 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7741 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7742 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7743 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7744 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7745 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7746 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7747
7748 /* "ip ospf message-digest-key" commands. */
7749 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7750 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7751 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7752 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7753
7754 /* "ip ospf cost" commands. */
7755 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7756 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7757 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7758 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7759
vincentba682532005-09-29 13:52:57 +00007760 /* "ip ospf mtu-ignore" commands. */
7761 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7762 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7763 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7764 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7765
paul718e3742002-12-13 20:15:29 +00007766 /* "ip ospf dead-interval" commands. */
7767 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7768 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007769 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7770 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007771 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7772 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007773
paul718e3742002-12-13 20:15:29 +00007774 /* "ip ospf hello-interval" commands. */
7775 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7776 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7777 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7778 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7779
7780 /* "ip ospf network" commands. */
7781 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7782 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7783
7784 /* "ip ospf priority" commands. */
7785 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7786 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7787 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7788 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7789
7790 /* "ip ospf retransmit-interval" commands. */
7791 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7792 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7793 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7794 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7795
7796 /* "ip ospf transmit-delay" commands. */
7797 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7798 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7799 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7800 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7801
7802 /* These commands are compatibitliy for previous version. */
7803 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7804 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7805 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7806 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7807 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7808 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7809 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7810 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7811 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7812 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7813 install_element (INTERFACE_NODE, &ospf_network_cmd);
7814 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7815 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7816 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7817 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7818 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7819 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7820 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7821}
7822
7823/* Zebra node structure. */
7824struct cmd_node zebra_node =
7825{
7826 ZEBRA_NODE,
7827 "%s(config-router)#",
7828};
7829
paul4dadc292005-05-06 21:37:42 +00007830static void
7831ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00007832{
7833 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7834 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7835 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7836 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7837 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7838 install_element (OSPF_NODE,
7839 &ospf_redistribute_source_metric_type_routemap_cmd);
7840 install_element (OSPF_NODE,
7841 &ospf_redistribute_source_type_metric_routemap_cmd);
7842 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7843 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7844 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7845
7846 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7847
7848 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7849 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7850
7851 install_element (OSPF_NODE,
7852 &ospf_default_information_originate_metric_type_cmd);
7853 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7854 install_element (OSPF_NODE,
7855 &ospf_default_information_originate_type_metric_cmd);
7856 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7857 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7858 install_element (OSPF_NODE,
7859 &ospf_default_information_originate_always_metric_type_cmd);
7860 install_element (OSPF_NODE,
7861 &ospf_default_information_originate_always_metric_cmd);
7862 install_element (OSPF_NODE,
7863 &ospf_default_information_originate_always_cmd);
7864 install_element (OSPF_NODE,
7865 &ospf_default_information_originate_always_type_metric_cmd);
7866 install_element (OSPF_NODE,
7867 &ospf_default_information_originate_always_type_cmd);
7868
7869 install_element (OSPF_NODE,
7870 &ospf_default_information_originate_metric_type_routemap_cmd);
7871 install_element (OSPF_NODE,
7872 &ospf_default_information_originate_metric_routemap_cmd);
7873 install_element (OSPF_NODE,
7874 &ospf_default_information_originate_routemap_cmd);
7875 install_element (OSPF_NODE,
7876 &ospf_default_information_originate_type_metric_routemap_cmd);
7877 install_element (OSPF_NODE,
7878 &ospf_default_information_originate_type_routemap_cmd);
7879 install_element (OSPF_NODE,
7880 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7881 install_element (OSPF_NODE,
7882 &ospf_default_information_originate_always_metric_routemap_cmd);
7883 install_element (OSPF_NODE,
7884 &ospf_default_information_originate_always_routemap_cmd);
7885 install_element (OSPF_NODE,
7886 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7887 install_element (OSPF_NODE,
7888 &ospf_default_information_originate_always_type_routemap_cmd);
7889
7890 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7891
7892 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7893 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7894 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7895
7896 install_element (OSPF_NODE, &ospf_distance_cmd);
7897 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7898 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7899 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7900 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7901 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7902 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7903 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7904 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7905 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7906 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7907 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7908 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7909 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7910 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7911 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7912 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7913 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7914#if 0
7915 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7916 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7917 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7918 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7919#endif /* 0 */
7920}
7921
7922struct cmd_node ospf_node =
7923{
7924 OSPF_NODE,
7925 "%s(config-router)# ",
7926 1
7927};
7928
7929
7930/* Install OSPF related vty commands. */
7931void
paul4dadc292005-05-06 21:37:42 +00007932ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00007933{
7934 /* Install ospf top node. */
7935 install_node (&ospf_node, ospf_config_write);
7936
7937 /* "router ospf" commands. */
7938 install_element (CONFIG_NODE, &router_ospf_cmd);
7939 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7940
7941 install_default (OSPF_NODE);
7942
7943 /* "ospf router-id" commands. */
7944 install_element (OSPF_NODE, &ospf_router_id_cmd);
7945 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007946 install_element (OSPF_NODE, &router_ospf_id_cmd);
7947 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007948
7949 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007950 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7951 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7952 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7953 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007954
7955 /* "ospf abr-type" commands. */
7956 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7957 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7958
7959 /* "ospf rfc1583-compatible" commands. */
7960 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7961 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7962 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7963 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7964
7965 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007966 install_element (OSPF_NODE, &ospf_network_area_cmd);
7967 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007968
7969 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007970 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7971 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7972 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007973
7974 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007975 install_element (OSPF_NODE, &ospf_area_range_cmd);
7976 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7977 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7978 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7979 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7980 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7981 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7982 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7983 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7984 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7985 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007986
7987 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007988 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7989 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007990
paula2c62832003-04-23 17:01:31 +00007991 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7992 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007993
paula2c62832003-04-23 17:01:31 +00007994 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7995 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007996
paula2c62832003-04-23 17:01:31 +00007997 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7998 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007999
paula2c62832003-04-23 17:01:31 +00008000 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8001 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008002
paula2c62832003-04-23 17:01:31 +00008003 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8004 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8005 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008006
paula2c62832003-04-23 17:01:31 +00008007 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8008 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008009
paula2c62832003-04-23 17:01:31 +00008010 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8011 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008012
paula2c62832003-04-23 17:01:31 +00008013 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8014 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8015 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008016
paula2c62832003-04-23 17:01:31 +00008017 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8018 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8019 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008020
8021 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008022 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8023 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8024 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8025 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008026
paul718e3742002-12-13 20:15:29 +00008027 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008028 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8029 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8030 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8031 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8032 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8033 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008034
paula2c62832003-04-23 17:01:31 +00008035 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8036 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008037
paula2c62832003-04-23 17:01:31 +00008038 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8039 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008040
paula2c62832003-04-23 17:01:31 +00008041 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8042 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008043
paula2c62832003-04-23 17:01:31 +00008044 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8045 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008046
paula2c62832003-04-23 17:01:31 +00008047 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8048 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00008049
paula2c62832003-04-23 17:01:31 +00008050 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8051 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008052 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8053 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8054
paula2c62832003-04-23 17:01:31 +00008055 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8056 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8057 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008058
paula2c62832003-04-23 17:01:31 +00008059 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8060 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008061
8062 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008063 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8064 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8065 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8066 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8067 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8068 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8069 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8070 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008071
8072 /* Init interface related vty commands. */
8073 ospf_vty_if_init ();
8074
8075 /* Init zebra related vty commands. */
8076 ospf_vty_zebra_init ();
8077}