blob: 0d0befa7cecb7adad965c65fda6f6126302f9743 [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")
2116
paula2c62832003-04-23 17:01:31 +00002117DEFUN (ospf_timers_spf,
2118 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002119 "timers spf <0-4294967295> <0-4294967295>",
2120 "Adjust routing timers\n"
2121 "OSPF SPF timers\n"
2122 "Delay between receiving a change to SPF calculation\n"
2123 "Hold time between consecutive SPF calculations\n")
2124{
2125 struct ospf *ospf = vty->index;
2126 u_int32_t delay, hold;
2127
paul4dadc292005-05-06 21:37:42 +00002128 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2129 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
paul718e3742002-12-13 20:15:29 +00002130
2131 ospf_timers_spf_set (ospf, delay, hold);
2132
2133 return CMD_SUCCESS;
2134}
2135
paula2c62832003-04-23 17:01:31 +00002136DEFUN (no_ospf_timers_spf,
2137 no_ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002138 "no timers spf",
2139 NO_STR
2140 "Adjust routing timers\n"
2141 "OSPF SPF timers\n")
2142{
paul68980082003-03-25 05:07:42 +00002143 struct ospf *ospf = vty->index;
2144
2145 ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT;
2146 ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002147
2148 return CMD_SUCCESS;
2149}
2150
2151
paula2c62832003-04-23 17:01:31 +00002152DEFUN (ospf_neighbor,
2153 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002154 "neighbor A.B.C.D",
2155 NEIGHBOR_STR
2156 "Neighbor IP address\n")
2157{
2158 struct ospf *ospf = vty->index;
2159 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002160 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2161 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002162
2163 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2164
2165 if (argc > 1)
2166 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2167
2168 if (argc > 2)
2169 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2170
2171 ospf_nbr_nbma_set (ospf, nbr_addr);
2172 if (argc > 1)
2173 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2174 if (argc > 2)
2175 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2176
2177 return CMD_SUCCESS;
2178}
2179
paula2c62832003-04-23 17:01:31 +00002180ALIAS (ospf_neighbor,
2181 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002182 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2183 NEIGHBOR_STR
2184 "Neighbor IP address\n"
2185 "Neighbor Priority\n"
2186 "Priority\n"
2187 "Dead Neighbor Polling interval\n"
2188 "Seconds\n")
2189
paula2c62832003-04-23 17:01:31 +00002190ALIAS (ospf_neighbor,
2191 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002192 "neighbor A.B.C.D priority <0-255>",
2193 NEIGHBOR_STR
2194 "Neighbor IP address\n"
2195 "Neighbor Priority\n"
2196 "Seconds\n")
2197
paula2c62832003-04-23 17:01:31 +00002198DEFUN (ospf_neighbor_poll_interval,
2199 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002200 "neighbor A.B.C.D poll-interval <1-65535>",
2201 NEIGHBOR_STR
2202 "Neighbor IP address\n"
2203 "Dead Neighbor Polling interval\n"
2204 "Seconds\n")
2205{
2206 struct ospf *ospf = vty->index;
2207 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002208 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2209 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002210
2211 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2212
2213 if (argc > 1)
2214 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2215
2216 if (argc > 2)
2217 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2218
2219 ospf_nbr_nbma_set (ospf, nbr_addr);
2220 if (argc > 1)
2221 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2222 if (argc > 2)
2223 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2224
2225 return CMD_SUCCESS;
2226}
2227
paula2c62832003-04-23 17:01:31 +00002228ALIAS (ospf_neighbor_poll_interval,
2229 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002230 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2231 NEIGHBOR_STR
2232 "Neighbor address\n"
2233 "OSPF dead-router polling interval\n"
2234 "Seconds\n"
2235 "OSPF priority of non-broadcast neighbor\n"
2236 "Priority\n")
2237
paula2c62832003-04-23 17:01:31 +00002238DEFUN (no_ospf_neighbor,
2239 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002240 "no neighbor A.B.C.D",
2241 NO_STR
2242 NEIGHBOR_STR
2243 "Neighbor IP address\n")
2244{
2245 struct ospf *ospf = vty->index;
2246 struct in_addr nbr_addr;
2247 int ret;
2248
2249 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2250
2251 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2252
2253 return CMD_SUCCESS;
2254}
2255
paula2c62832003-04-23 17:01:31 +00002256ALIAS (no_ospf_neighbor,
2257 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002258 "no neighbor A.B.C.D priority <0-255>",
2259 NO_STR
2260 NEIGHBOR_STR
2261 "Neighbor IP address\n"
2262 "Neighbor Priority\n"
2263 "Priority\n")
2264
paula2c62832003-04-23 17:01:31 +00002265ALIAS (no_ospf_neighbor,
2266 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002267 "no neighbor A.B.C.D poll-interval <1-65535>",
2268 NO_STR
2269 NEIGHBOR_STR
2270 "Neighbor IP address\n"
2271 "Dead Neighbor Polling interval\n"
2272 "Seconds\n")
2273
paula2c62832003-04-23 17:01:31 +00002274ALIAS (no_ospf_neighbor,
2275 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002276 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2277 NO_STR
2278 NEIGHBOR_STR
2279 "Neighbor IP address\n"
2280 "Neighbor Priority\n"
2281 "Priority\n"
2282 "Dead Neighbor Polling interval\n"
2283 "Seconds\n")
2284
2285
paula2c62832003-04-23 17:01:31 +00002286DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002287 "refresh timer <10-1800>",
2288 "Adjust refresh parameters\n"
2289 "Set refresh timer\n"
2290 "Timer value in seconds\n")
2291{
2292 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002293 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002294
2295 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2296 interval = (interval / 10) * 10;
2297
2298 ospf_timers_refresh_set (ospf, interval);
2299
2300 return CMD_SUCCESS;
2301}
2302
paula2c62832003-04-23 17:01:31 +00002303DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002304 "no refresh timer <10-1800>",
2305 "Adjust refresh parameters\n"
2306 "Unset refresh timer\n"
2307 "Timer value in seconds\n")
2308{
2309 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002310 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002311
2312 if (argc == 1)
2313 {
2314 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2315
2316 if (ospf->lsa_refresh_interval != interval ||
2317 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2318 return CMD_SUCCESS;
2319 }
2320
2321 ospf_timers_refresh_unset (ospf);
2322
2323 return CMD_SUCCESS;
2324}
2325
paula2c62832003-04-23 17:01:31 +00002326ALIAS (no_ospf_refresh_timer,
2327 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002328 "no refresh timer",
2329 "Adjust refresh parameters\n"
2330 "Unset refresh timer\n")
2331
paula2c62832003-04-23 17:01:31 +00002332DEFUN (ospf_auto_cost_reference_bandwidth,
2333 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002334 "auto-cost reference-bandwidth <1-4294967>",
2335 "Calculate OSPF interface cost according to bandwidth\n"
2336 "Use reference bandwidth method to assign OSPF cost\n"
2337 "The reference bandwidth in terms of Mbits per second\n")
2338{
paul68980082003-03-25 05:07:42 +00002339 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002340 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002341 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002342 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002343
2344 refbw = strtol (argv[0], NULL, 10);
2345 if (refbw < 1 || refbw > 4294967)
2346 {
2347 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2348 return CMD_WARNING;
2349 }
2350
2351 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002352 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002353 return CMD_SUCCESS;
2354
paul68980082003-03-25 05:07:42 +00002355 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002356 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2357 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002358
2359 return CMD_SUCCESS;
2360}
2361
paula2c62832003-04-23 17:01:31 +00002362DEFUN (no_ospf_auto_cost_reference_bandwidth,
2363 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002364 "no auto-cost reference-bandwidth",
2365 NO_STR
2366 "Calculate OSPF interface cost according to bandwidth\n"
2367 "Use reference bandwidth method to assign OSPF cost\n")
2368{
paul68980082003-03-25 05:07:42 +00002369 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002370 struct listnode *node, *nnode;
2371 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002372
paul68980082003-03-25 05:07:42 +00002373 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002374 return CMD_SUCCESS;
2375
paul68980082003-03-25 05:07:42 +00002376 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002377 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2378 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2379
paul1eb8ef22005-04-07 07:30:20 +00002380 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2381 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002382
2383 return CMD_SUCCESS;
2384}
2385
hassoeb1ce602004-10-08 08:17:22 +00002386const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002387{
2388 "Unknown",
2389 "Standard (RFC2328)",
2390 "Alternative IBM",
2391 "Alternative Cisco",
2392 "Alternative Shortcut"
2393};
2394
hassoeb1ce602004-10-08 08:17:22 +00002395const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002396{
2397 "Default",
2398 "Enabled",
2399 "Disabled"
2400};
2401
2402
2403
paul4dadc292005-05-06 21:37:42 +00002404static void
paul718e3742002-12-13 20:15:29 +00002405show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2406{
2407 /* Show Area ID. */
2408 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2409
2410 /* Show Area type/mode. */
2411 if (OSPF_IS_AREA_BACKBONE (area))
2412 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2413 else
2414 {
2415 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002416 vty_out (vty, " (Stub%s%s)",
2417 area->no_summary ? ", no summary" : "",
2418 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002419
paulb0a053b2003-06-22 09:04:47 +00002420 else if (area->external_routing == OSPF_AREA_NSSA)
2421 vty_out (vty, " (NSSA%s%s)",
2422 area->no_summary ? ", no summary" : "",
2423 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002424
2425 vty_out (vty, "%s", VTY_NEWLINE);
2426 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002427 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002428 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002429 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002430 }
2431
2432 /* Show number of interfaces. */
2433 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2434 "Active: %d%s", listcount (area->oiflist),
2435 area->act_ints, VTY_NEWLINE);
2436
paul718e3742002-12-13 20:15:29 +00002437 if (area->external_routing == OSPF_AREA_NSSA)
2438 {
2439 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 +00002440 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002441 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2442 VTY_NEWLINE);
2443 else if (area->NSSATranslatorState)
2444 {
2445 vty_out (vty, " We are an ABR and ");
2446 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2447 vty_out (vty, "the NSSA Elected Translator. %s",
2448 VTY_NEWLINE);
2449 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2450 vty_out (vty, "always an NSSA Translator. %s",
2451 VTY_NEWLINE);
2452 }
paul718e3742002-12-13 20:15:29 +00002453 else
paulb0a053b2003-06-22 09:04:47 +00002454 {
2455 vty_out (vty, " We are an ABR, but ");
2456 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2457 vty_out (vty, "not the NSSA Elected Translator. %s",
2458 VTY_NEWLINE);
2459 else
hassoc6b87812004-12-22 13:09:59 +00002460 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002461 VTY_NEWLINE);
2462 }
paul718e3742002-12-13 20:15:29 +00002463 }
paul718e3742002-12-13 20:15:29 +00002464
2465 /* Show number of fully adjacent neighbors. */
2466 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002467 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002468
2469 /* Show authentication type. */
2470 vty_out (vty, " Area has ");
2471 if (area->auth_type == OSPF_AUTH_NULL)
2472 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2473 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2474 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2475 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2476 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2477
2478 if (!OSPF_IS_AREA_BACKBONE (area))
2479 vty_out (vty, " Number of full virtual adjacencies going through"
2480 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2481
2482 /* Show SPF calculation times. */
2483 vty_out (vty, " SPF algorithm executed %d times%s",
2484 area->spf_calculation, VTY_NEWLINE);
2485
2486 /* Show number of LSA. */
2487 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002488 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2489 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2490 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2491 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2492 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2493 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2494 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2495 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2496 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2497 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2498 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2499 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2500 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2501 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2502 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2503#ifdef HAVE_OPAQUE_LSA
2504 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2505 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2506 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2507 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2508 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2509 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2510#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002511 vty_out (vty, "%s", VTY_NEWLINE);
2512}
2513
2514DEFUN (show_ip_ospf,
2515 show_ip_ospf_cmd,
2516 "show ip ospf",
2517 SHOW_STR
2518 IP_STR
2519 "OSPF information\n")
2520{
paul1eb8ef22005-04-07 07:30:20 +00002521 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002522 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002523 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002524
2525 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002526 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002527 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002528 {
2529 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2530 return CMD_SUCCESS;
2531 }
2532
2533 /* Show Router ID. */
2534 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002535 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002536 VTY_NEWLINE);
2537
2538 /* Show capability. */
2539 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2540 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2541 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002542 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002543 "enabled" : "disabled", VTY_NEWLINE);
2544#ifdef HAVE_OPAQUE_LSA
2545 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002546 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002547 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002548 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002549 " (origination blocked)" : "",
2550 VTY_NEWLINE);
2551#endif /* HAVE_OPAQUE_LSA */
2552
2553 /* Show SPF timers. */
2554 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
paul68980082003-03-25 05:07:42 +00002555 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002556
2557 /* Show refresh parameters. */
2558 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002559 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002560
2561 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002562 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002563 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002564 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002565
paul68980082003-03-25 05:07:42 +00002566 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002567 vty_out (vty, " This router is an ASBR "
2568 "(injecting external routing information)%s", VTY_NEWLINE);
2569
2570 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002571 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2572 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2573 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2574#ifdef HAVE_OPAQUE_LSA
2575 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2576 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2577 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2578#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002579 /* Show number of areas attached. */
2580 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002581 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002582
2583 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002584 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2585 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002586
2587 return CMD_SUCCESS;
2588}
2589
2590
ajsfd651fa2005-03-29 16:08:16 +00002591static void
paul68980082003-03-25 05:07:42 +00002592show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2593 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002594{
ajsfd651fa2005-03-29 16:08:16 +00002595 int is_up;
paul718e3742002-12-13 20:15:29 +00002596 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002597 struct route_node *rn;
2598 char buf[9];
2599
paul718e3742002-12-13 20:15:29 +00002600 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002601 vty_out (vty, "%s is %s%s", ifp->name,
2602 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002603 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2604 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2605 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002606
2607 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002608 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002609 {
2610 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2611 return;
2612 }
ajsfd651fa2005-03-29 16:08:16 +00002613 else if (!is_up)
2614 {
2615 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2616 VTY_NEWLINE);
2617 return;
2618 }
2619
paul718e3742002-12-13 20:15:29 +00002620 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2621 {
2622 struct ospf_interface *oi = rn->info;
2623
2624 if (oi == NULL)
2625 continue;
2626
2627 /* Show OSPF interface information. */
2628 vty_out (vty, " Internet Address %s/%d,",
2629 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2630
hasso3fb9cd62004-10-19 19:44:43 +00002631 if (oi->connected->destination)
2632 vty_out (vty, " %s %s,",
2633 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2634 inet_ntoa (oi->connected->destination->u.prefix4));
2635
paul718e3742002-12-13 20:15:29 +00002636 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2637 VTY_NEWLINE);
2638
vincentba682532005-09-29 13:52:57 +00002639 vty_out (vty, " MTU mismatch detection:%s%s",
2640 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2641
paul718e3742002-12-13 20:15:29 +00002642 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002643 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002644 oi->output_cost, VTY_NEWLINE);
2645
2646 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2647 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2648 PRIORITY (oi), VTY_NEWLINE);
2649
2650 /* Show DR information. */
2651 if (DR (oi).s_addr == 0)
2652 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2653 else
2654 {
2655 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2656 if (nbr == NULL)
2657 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2658 else
2659 {
2660 vty_out (vty, " Designated Router (ID) %s,",
2661 inet_ntoa (nbr->router_id));
2662 vty_out (vty, " Interface Address %s%s",
2663 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2664 }
2665 }
2666
2667 /* Show BDR information. */
2668 if (BDR (oi).s_addr == 0)
2669 vty_out (vty, " No backup designated router on this network%s",
2670 VTY_NEWLINE);
2671 else
2672 {
2673 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2674 if (nbr == NULL)
2675 vty_out (vty, " No backup designated router on this network%s",
2676 VTY_NEWLINE);
2677 else
2678 {
2679 vty_out (vty, " Backup Designated Router (ID) %s,",
2680 inet_ntoa (nbr->router_id));
2681 vty_out (vty, " Interface Address %s%s",
2682 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2683 }
2684 }
ajsba6454e2005-02-08 15:37:30 +00002685
2686 vty_out (vty, " Multicast group memberships:");
2687 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2688 vty_out (vty, " OSPFAllRouters");
2689 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2690 vty_out (vty, " OSPFDesignatedRouters");
2691 if (!CHECK_FLAG(oi->multicast_memberships,
2692 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2693 vty_out (vty, " <None>");
2694 vty_out (vty, "%s", VTY_NEWLINE);
2695
paul718e3742002-12-13 20:15:29 +00002696 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002697 vty_out (vty, " Hello ");
2698 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2699 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2700 else
2701 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2702 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2703 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002704 OSPF_IF_PARAM (oi, v_wait),
2705 OSPF_IF_PARAM (oi, retransmit_interval),
2706 VTY_NEWLINE);
2707
2708 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002709 {
2710 int timer_slen = 9; /* length of "hh:mm:ss(nul)" */
2711
2712 /* for fast hello we also want to see the .XXXX ms part */
2713 if (OSPF_IF_PARAM (oi, fast_hello))
2714 timer_slen += 5;
2715
2716 vty_out (vty, " Hello due in %s%s",
2717 ospf_timer_dump (oi->t_hello, buf, timer_slen),
2718 VTY_NEWLINE);
2719 }
paul718e3742002-12-13 20:15:29 +00002720 else /* OSPF_IF_PASSIVE is set */
2721 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2722
2723 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002724 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002725 VTY_NEWLINE);
2726 }
2727}
2728
2729DEFUN (show_ip_ospf_interface,
2730 show_ip_ospf_interface_cmd,
2731 "show ip ospf interface [INTERFACE]",
2732 SHOW_STR
2733 IP_STR
2734 "OSPF information\n"
2735 "Interface information\n"
2736 "Interface name\n")
2737{
2738 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002739 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002740 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002741
paul020709f2003-04-04 02:44:16 +00002742 ospf = ospf_lookup ();
2743
paul718e3742002-12-13 20:15:29 +00002744 /* Show All Interfaces. */
2745 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002746 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2747 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002748 /* Interface name is specified. */
2749 else
2750 {
2751 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2752 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2753 else
paul68980082003-03-25 05:07:42 +00002754 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002755 }
2756
2757 return CMD_SUCCESS;
2758}
2759
paul4dadc292005-05-06 21:37:42 +00002760static void
paul718e3742002-12-13 20:15:29 +00002761show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2762{
2763 struct route_node *rn;
2764 struct ospf_neighbor *nbr;
2765 char msgbuf[16];
2766 char timebuf[9];
2767
2768 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2769 if ((nbr = rn->info))
2770 /* Do not show myself. */
2771 if (nbr != oi->nbr_self)
2772 /* Down state is not shown. */
2773 if (nbr->state != NSM_Down)
2774 {
2775 ospf_nbr_state_message (nbr, msgbuf, 16);
2776
2777 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2778 vty_out (vty, "%-15s %3d %-15s %8s ",
2779 "-", nbr->priority,
2780 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2781 else
2782 vty_out (vty, "%-15s %3d %-15s %8s ",
2783 inet_ntoa (nbr->router_id), nbr->priority,
2784 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2785 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2786 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2787 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2788 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2789 VTY_NEWLINE);
2790 }
2791}
2792
2793DEFUN (show_ip_ospf_neighbor,
2794 show_ip_ospf_neighbor_cmd,
2795 "show ip ospf neighbor",
2796 SHOW_STR
2797 IP_STR
2798 "OSPF information\n"
2799 "Neighbor list\n")
2800{
paul020709f2003-04-04 02:44:16 +00002801 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002802 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002803 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002804
paul020709f2003-04-04 02:44:16 +00002805 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002806 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002807 {
2808 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2809 return CMD_SUCCESS;
2810 }
2811
2812 /* Show All neighbors. */
2813 vty_out (vty, "%sNeighbor ID Pri State Dead "
2814 "Time Address Interface RXmtL "
2815 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2816
paul1eb8ef22005-04-07 07:30:20 +00002817 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
2818 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00002819
2820 return CMD_SUCCESS;
2821}
2822
2823DEFUN (show_ip_ospf_neighbor_all,
2824 show_ip_ospf_neighbor_all_cmd,
2825 "show ip ospf neighbor all",
2826 SHOW_STR
2827 IP_STR
2828 "OSPF information\n"
2829 "Neighbor list\n"
2830 "include down status neighbor\n")
2831{
paul68980082003-03-25 05:07:42 +00002832 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002833 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002834 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002835
paul68980082003-03-25 05:07:42 +00002836 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002837 {
2838 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2839 return CMD_SUCCESS;
2840 }
2841
2842 /* Show All neighbors. */
2843 vty_out (vty, "%sNeighbor ID Pri State Dead "
2844 "Time Address Interface RXmtL "
2845 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2846
paul1eb8ef22005-04-07 07:30:20 +00002847 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00002848 {
hasso52dc7ee2004-09-23 19:18:23 +00002849 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00002850 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00002851
2852 show_ip_ospf_neighbor_sub (vty, oi);
2853
2854 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00002855 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00002856 {
paul718e3742002-12-13 20:15:29 +00002857 if (nbr_nbma->nbr == NULL
2858 || nbr_nbma->nbr->state == NSM_Down)
2859 {
2860 vty_out (vty, "%-15s %3d %-15s %8s ",
2861 "-", nbr_nbma->priority, "Down", "-");
2862 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2863 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2864 0, 0, 0, VTY_NEWLINE);
2865 }
2866 }
2867 }
2868
2869 return CMD_SUCCESS;
2870}
2871
2872DEFUN (show_ip_ospf_neighbor_int,
2873 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00002874 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00002875 SHOW_STR
2876 IP_STR
2877 "OSPF information\n"
2878 "Neighbor list\n"
2879 "Interface name\n")
2880{
paul020709f2003-04-04 02:44:16 +00002881 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00002882 struct interface *ifp;
2883 struct route_node *rn;
2884
2885 ifp = if_lookup_by_name (argv[0]);
2886 if (!ifp)
paul718e3742002-12-13 20:15:29 +00002887 {
hassobb5b7552005-08-21 20:01:15 +00002888 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002889 return CMD_WARNING;
2890 }
2891
paul020709f2003-04-04 02:44:16 +00002892 ospf = ospf_lookup ();
2893 if (ospf == NULL)
2894 {
2895 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2896 return CMD_SUCCESS;
2897 }
2898
hassobb5b7552005-08-21 20:01:15 +00002899 vty_out (vty, "%sNeighbor ID Pri State Dead "
2900 "Time Address Interface RXmtL "
2901 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2902
2903 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00002904 {
hassobb5b7552005-08-21 20:01:15 +00002905 struct ospf_interface *oi = rn->info;
2906
2907 if (oi == NULL)
2908 continue;
2909
paul718e3742002-12-13 20:15:29 +00002910 show_ip_ospf_neighbor_sub (vty, oi);
2911 }
2912
2913 return CMD_SUCCESS;
2914}
2915
paul4dadc292005-05-06 21:37:42 +00002916static void
paul718e3742002-12-13 20:15:29 +00002917show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2918 struct ospf_nbr_nbma *nbr_nbma)
2919{
2920 char timebuf[9];
2921
2922 /* Show neighbor ID. */
2923 vty_out (vty, " Neighbor %s,", "-");
2924
2925 /* Show interface address. */
2926 vty_out (vty, " interface address %s%s",
2927 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2928 /* Show Area ID. */
2929 vty_out (vty, " In the area %s via interface %s%s",
2930 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2931 /* Show neighbor priority and state. */
2932 vty_out (vty, " Neighbor priority is %d, State is %s,",
2933 nbr_nbma->priority, "Down");
2934 /* Show state changes. */
2935 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2936
2937 /* Show PollInterval */
2938 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2939
2940 /* Show poll-interval timer. */
2941 vty_out (vty, " Poll timer due in %s%s",
2942 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2943
2944 /* Show poll-interval timer thread. */
2945 vty_out (vty, " Thread Poll Timer %s%s",
2946 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2947}
2948
paul4dadc292005-05-06 21:37:42 +00002949static void
paul718e3742002-12-13 20:15:29 +00002950show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2951 struct ospf_neighbor *nbr)
2952{
2953 char timebuf[9];
2954
2955 /* Show neighbor ID. */
2956 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2957 vty_out (vty, " Neighbor %s,", "-");
2958 else
2959 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2960
2961 /* Show interface address. */
2962 vty_out (vty, " interface address %s%s",
2963 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2964 /* Show Area ID. */
2965 vty_out (vty, " In the area %s via interface %s%s",
2966 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2967 /* Show neighbor priority and state. */
2968 vty_out (vty, " Neighbor priority is %d, State is %s,",
2969 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2970 /* Show state changes. */
2971 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2972
2973 /* Show Designated Rotuer ID. */
2974 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2975 /* Show Backup Designated Rotuer ID. */
2976 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2977 /* Show options. */
2978 vty_out (vty, " Options %d %s%s", nbr->options,
2979 ospf_options_dump (nbr->options), VTY_NEWLINE);
2980 /* Show Router Dead interval timer. */
2981 vty_out (vty, " Dead timer due in %s%s",
2982 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2983 /* Show Database Summary list. */
2984 vty_out (vty, " Database Summary List %d%s",
2985 ospf_db_summary_count (nbr), VTY_NEWLINE);
2986 /* Show Link State Request list. */
2987 vty_out (vty, " Link State Request List %ld%s",
2988 ospf_ls_request_count (nbr), VTY_NEWLINE);
2989 /* Show Link State Retransmission list. */
2990 vty_out (vty, " Link State Retransmission List %ld%s",
2991 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2992 /* Show inactivity timer thread. */
2993 vty_out (vty, " Thread Inactivity Timer %s%s",
2994 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2995 /* Show Database Description retransmission thread. */
2996 vty_out (vty, " Thread Database Description Retransmision %s%s",
2997 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2998 /* Show Link State Request Retransmission thread. */
2999 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3000 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3001 /* Show Link State Update Retransmission thread. */
3002 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3003 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3004}
3005
3006DEFUN (show_ip_ospf_neighbor_id,
3007 show_ip_ospf_neighbor_id_cmd,
3008 "show ip ospf neighbor A.B.C.D",
3009 SHOW_STR
3010 IP_STR
3011 "OSPF information\n"
3012 "Neighbor list\n"
3013 "Neighbor ID\n")
3014{
paul020709f2003-04-04 02:44:16 +00003015 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003016 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003017 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003018 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003019 struct in_addr router_id;
3020 int ret;
3021
3022 ret = inet_aton (argv[0], &router_id);
3023 if (!ret)
3024 {
3025 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3026 return CMD_WARNING;
3027 }
3028
paul020709f2003-04-04 02:44:16 +00003029 ospf = ospf_lookup ();
3030 if (ospf == NULL)
3031 {
3032 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3033 return CMD_SUCCESS;
3034 }
3035
paul1eb8ef22005-04-07 07:30:20 +00003036 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3037 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3038 {
3039 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3040 return CMD_SUCCESS;
3041 }
paul718e3742002-12-13 20:15:29 +00003042
3043 /* Nothing to show. */
3044 return CMD_SUCCESS;
3045}
3046
3047DEFUN (show_ip_ospf_neighbor_detail,
3048 show_ip_ospf_neighbor_detail_cmd,
3049 "show ip ospf neighbor detail",
3050 SHOW_STR
3051 IP_STR
3052 "OSPF information\n"
3053 "Neighbor list\n"
3054 "detail of all neighbors\n")
3055{
paul020709f2003-04-04 02:44:16 +00003056 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003057 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003058 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003059
paul020709f2003-04-04 02:44:16 +00003060 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003061 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003062 {
3063 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3064 return CMD_SUCCESS;
3065 }
paul718e3742002-12-13 20:15:29 +00003066
paul1eb8ef22005-04-07 07:30:20 +00003067 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003068 {
paul718e3742002-12-13 20:15:29 +00003069 struct route_node *rn;
3070 struct ospf_neighbor *nbr;
3071
3072 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3073 if ((nbr = rn->info))
3074 if (nbr != oi->nbr_self)
3075 if (nbr->state != NSM_Down)
3076 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3077 }
3078
3079 return CMD_SUCCESS;
3080}
3081
3082DEFUN (show_ip_ospf_neighbor_detail_all,
3083 show_ip_ospf_neighbor_detail_all_cmd,
3084 "show ip ospf neighbor detail all",
3085 SHOW_STR
3086 IP_STR
3087 "OSPF information\n"
3088 "Neighbor list\n"
3089 "detail of all neighbors\n"
3090 "include down status neighbor\n")
3091{
paul020709f2003-04-04 02:44:16 +00003092 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003093 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003094 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003095
paul020709f2003-04-04 02:44:16 +00003096 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003097 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003098 {
3099 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3100 return CMD_SUCCESS;
3101 }
paul718e3742002-12-13 20:15:29 +00003102
paul1eb8ef22005-04-07 07:30:20 +00003103 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003104 {
paul718e3742002-12-13 20:15:29 +00003105 struct route_node *rn;
3106 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003107 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003108
3109 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3110 if ((nbr = rn->info))
3111 if (nbr != oi->nbr_self)
3112 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3113 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3114
3115 if (oi->type == OSPF_IFTYPE_NBMA)
3116 {
hasso52dc7ee2004-09-23 19:18:23 +00003117 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003118
paul1eb8ef22005-04-07 07:30:20 +00003119 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3120 if (nbr_nbma->nbr == NULL
3121 || nbr_nbma->nbr->state == NSM_Down)
3122 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003123 }
3124 }
3125
3126 return CMD_SUCCESS;
3127}
3128
3129DEFUN (show_ip_ospf_neighbor_int_detail,
3130 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003131 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003132 SHOW_STR
3133 IP_STR
3134 "OSPF information\n"
3135 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003136 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003137 "detail of all neighbors")
3138{
paul020709f2003-04-04 02:44:16 +00003139 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003140 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003141 struct interface *ifp;
3142 struct route_node *rn, *nrn;
3143 struct ospf_neighbor *nbr;
3144
3145 ifp = if_lookup_by_name (argv[0]);
3146 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003147 {
hassobb5b7552005-08-21 20:01:15 +00003148 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003149 return CMD_WARNING;
3150 }
3151
paul020709f2003-04-04 02:44:16 +00003152 ospf = ospf_lookup ();
3153 if (ospf == NULL)
3154 {
3155 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3156 return CMD_SUCCESS;
3157 }
paul68980082003-03-25 05:07:42 +00003158
paul718e3742002-12-13 20:15:29 +00003159
hassobb5b7552005-08-21 20:01:15 +00003160 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3161 if ((oi = rn->info))
3162 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3163 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003164 if (nbr != oi->nbr_self)
3165 if (nbr->state != NSM_Down)
3166 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003167
3168 return CMD_SUCCESS;
3169}
3170
3171
3172/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003173static int
paul020709f2003-04-04 02:44:16 +00003174show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003175{
paul718e3742002-12-13 20:15:29 +00003176 struct router_lsa *rl;
3177 struct summary_lsa *sl;
3178 struct as_external_lsa *asel;
3179 struct prefix_ipv4 p;
3180
3181 if (lsa != NULL)
3182 /* If self option is set, check LSA self flag. */
3183 if (self == 0 || IS_LSA_SELF (lsa))
3184 {
3185 /* LSA common part show. */
3186 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3187 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3188 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3189 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3190 /* LSA specific part show. */
3191 switch (lsa->data->type)
3192 {
3193 case OSPF_ROUTER_LSA:
3194 rl = (struct router_lsa *) lsa->data;
3195 vty_out (vty, " %-d", ntohs (rl->links));
3196 break;
3197 case OSPF_SUMMARY_LSA:
3198 sl = (struct summary_lsa *) lsa->data;
3199
3200 p.family = AF_INET;
3201 p.prefix = sl->header.id;
3202 p.prefixlen = ip_masklen (sl->mask);
3203 apply_mask_ipv4 (&p);
3204
3205 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3206 break;
3207 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003208 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003209 asel = (struct as_external_lsa *) lsa->data;
3210
3211 p.family = AF_INET;
3212 p.prefix = asel->header.id;
3213 p.prefixlen = ip_masklen (asel->mask);
3214 apply_mask_ipv4 (&p);
3215
3216 vty_out (vty, " %s %s/%d [0x%lx]",
3217 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3218 inet_ntoa (p.prefix), p.prefixlen,
3219 (u_long)ntohl (asel->e[0].route_tag));
3220 break;
3221 case OSPF_NETWORK_LSA:
3222 case OSPF_ASBR_SUMMARY_LSA:
3223#ifdef HAVE_OPAQUE_LSA
3224 case OSPF_OPAQUE_LINK_LSA:
3225 case OSPF_OPAQUE_AREA_LSA:
3226 case OSPF_OPAQUE_AS_LSA:
3227#endif /* HAVE_OPAQUE_LSA */
3228 default:
3229 break;
3230 }
3231 vty_out (vty, VTY_NEWLINE);
3232 }
3233
3234 return 0;
3235}
3236
hassoeb1ce602004-10-08 08:17:22 +00003237const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003238{
3239 "unknown",
3240 "Router Link States",
3241 "Net Link States",
3242 "Summary Link States",
3243 "ASBR-Summary Link States",
3244 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003245 "Group Membership LSA",
3246 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003247#ifdef HAVE_OPAQUE_LSA
3248 "Type-8 LSA",
3249 "Link-Local Opaque-LSA",
3250 "Area-Local Opaque-LSA",
3251 "AS-external Opaque-LSA",
3252#endif /* HAVE_OPAQUE_LSA */
3253};
3254
3255#define SHOW_OSPF_COMMON_HEADER \
3256 "Link ID ADV Router Age Seq# CkSum"
3257
hassoeb1ce602004-10-08 08:17:22 +00003258const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003259{
3260 "",
3261 "Link ID ADV Router Age Seq# CkSum Link count",
3262 "Link ID ADV Router Age Seq# CkSum",
3263 "Link ID ADV Router Age Seq# CkSum Route",
3264 "Link ID ADV Router Age Seq# CkSum",
3265 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003266 " --- header for Group Member ----",
3267 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003268#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003269 " --- type-8 ---",
3270 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3271 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3272 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3273#endif /* HAVE_OPAQUE_LSA */
3274};
3275
hassoeb1ce602004-10-08 08:17:22 +00003276const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003277{
3278 "Self-originated",
3279 "Checked",
3280 "Received",
3281 "Approved",
3282 "Discard",
paul4957f492003-06-27 01:28:45 +00003283 "Translated",
paul4957f492003-06-27 01:28:45 +00003284};
3285
paul4dadc292005-05-06 21:37:42 +00003286static void
paul718e3742002-12-13 20:15:29 +00003287show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3288{
3289 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003290
paul718e3742002-12-13 20:15:29 +00003291 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003292 vty_out (vty, " Options: 0x%-2x : %s%s",
3293 lsa->data->options,
3294 ospf_options_dump(lsa->data->options),
3295 VTY_NEWLINE);
3296 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003297 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003298 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3299 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003300
3301 if (lsa->data->type == OSPF_ROUTER_LSA)
3302 {
3303 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3304
3305 if (rlsa->flags)
3306 vty_out (vty, " :%s%s%s%s",
3307 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3308 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3309 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3310 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3311
3312 vty_out (vty, "%s", VTY_NEWLINE);
3313 }
3314 vty_out (vty, " LS Type: %s%s",
3315 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3316 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3317 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3318 vty_out (vty, " Advertising Router: %s%s",
3319 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3320 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3321 VTY_NEWLINE);
3322 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3323 VTY_NEWLINE);
3324 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3325}
3326
hassoeb1ce602004-10-08 08:17:22 +00003327const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003328{
3329 "(null)",
3330 "another Router (point-to-point)",
3331 "a Transit Network",
3332 "Stub Network",
3333 "a Virtual Link",
3334};
3335
hassoeb1ce602004-10-08 08:17:22 +00003336const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003337{
3338 "(null)",
3339 "Neighboring Router ID",
3340 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003341 "Net",
paul718e3742002-12-13 20:15:29 +00003342 "Neighboring Router ID",
3343};
3344
hassoeb1ce602004-10-08 08:17:22 +00003345const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003346{
3347 "(null)",
3348 "Router Interface address",
3349 "Router Interface address",
3350 "Network Mask",
3351 "Router Interface address",
3352};
3353
3354/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003355static void
paul718e3742002-12-13 20:15:29 +00003356show_ip_ospf_database_router_links (struct vty *vty,
3357 struct router_lsa *rl)
3358{
3359 int len, i, type;
3360
3361 len = ntohs (rl->header.length) - 4;
3362 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3363 {
3364 type = rl->link[i].type;
3365
3366 vty_out (vty, " Link connected to: %s%s",
3367 link_type_desc[type], VTY_NEWLINE);
3368 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3369 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3370 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3371 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3372 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3373 vty_out (vty, " TOS 0 Metric: %d%s",
3374 ntohs (rl->link[i].metric), VTY_NEWLINE);
3375 vty_out (vty, "%s", VTY_NEWLINE);
3376 }
3377}
3378
3379/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003380static int
paul718e3742002-12-13 20:15:29 +00003381show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3382{
3383 if (lsa != NULL)
3384 {
3385 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3386
3387 show_ip_ospf_database_header (vty, lsa);
3388
3389 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3390 VTY_NEWLINE, VTY_NEWLINE);
3391
3392 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003393 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003394 }
3395
3396 return 0;
3397}
3398
3399/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003400static int
paul718e3742002-12-13 20:15:29 +00003401show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3402{
3403 int length, i;
3404
3405 if (lsa != NULL)
3406 {
3407 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3408
3409 show_ip_ospf_database_header (vty, lsa);
3410
3411 vty_out (vty, " Network Mask: /%d%s",
3412 ip_masklen (nl->mask), VTY_NEWLINE);
3413
3414 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3415
3416 for (i = 0; length > 0; i++, length -= 4)
3417 vty_out (vty, " Attached Router: %s%s",
3418 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3419
3420 vty_out (vty, "%s", VTY_NEWLINE);
3421 }
3422
3423 return 0;
3424}
3425
3426/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003427static int
paul718e3742002-12-13 20:15:29 +00003428show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3429{
3430 if (lsa != NULL)
3431 {
3432 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3433
3434 show_ip_ospf_database_header (vty, lsa);
3435
3436 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3437 VTY_NEWLINE);
3438 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3439 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003440 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003441 }
3442
3443 return 0;
3444}
3445
3446/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003447static int
paul718e3742002-12-13 20:15:29 +00003448show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3449{
3450 if (lsa != NULL)
3451 {
3452 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3453
3454 show_ip_ospf_database_header (vty, lsa);
3455
3456 vty_out (vty, " Network Mask: /%d%s",
3457 ip_masklen (sl->mask), VTY_NEWLINE);
3458 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3459 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003460 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003461 }
3462
3463 return 0;
3464}
3465
3466/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003467static int
paul718e3742002-12-13 20:15:29 +00003468show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3469{
3470 if (lsa != NULL)
3471 {
3472 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3473
3474 show_ip_ospf_database_header (vty, lsa);
3475
3476 vty_out (vty, " Network Mask: /%d%s",
3477 ip_masklen (al->mask), VTY_NEWLINE);
3478 vty_out (vty, " Metric Type: %s%s",
3479 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3480 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3481 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3482 vty_out (vty, " Metric: %d%s",
3483 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3484 vty_out (vty, " Forward Address: %s%s",
3485 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3486
3487 vty_out (vty, " External Route Tag: %lu%s%s",
3488 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3489 }
3490
3491 return 0;
3492}
3493
ajs2a42e282004-12-08 18:43:03 +00003494/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003495static int
paul718e3742002-12-13 20:15:29 +00003496show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3497{
3498 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3499
3500 /* show_ip_ospf_database_header (vty, lsa); */
3501
ajs2a42e282004-12-08 18:43:03 +00003502 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003503 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003504 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003505 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3506 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003507 zlog_debug( " TOS: 0%s", "\n");
3508 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003509 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003510 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003511 inet_ntoa (al->e[0].fwd_addr), "\n");
3512
ajs2a42e282004-12-08 18:43:03 +00003513 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003514 ntohl (al->e[0].route_tag), "\n", "\n");
3515
3516 return 0;
3517}
3518
3519/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003520static int
paul718e3742002-12-13 20:15:29 +00003521show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3522{
3523 if (lsa != NULL)
3524 {
3525 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3526
3527 show_ip_ospf_database_header (vty, lsa);
3528
3529 vty_out (vty, " Network Mask: /%d%s",
3530 ip_masklen (al->mask), VTY_NEWLINE);
3531 vty_out (vty, " Metric Type: %s%s",
3532 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3533 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3534 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3535 vty_out (vty, " Metric: %d%s",
3536 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3537 vty_out (vty, " NSSA: Forward Address: %s%s",
3538 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3539
3540 vty_out (vty, " External Route Tag: %u%s%s",
3541 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3542 }
3543
3544 return 0;
3545}
3546
paul4dadc292005-05-06 21:37:42 +00003547static int
paul718e3742002-12-13 20:15:29 +00003548show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3549{
3550 return 0;
3551}
3552
3553#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003554static int
paul718e3742002-12-13 20:15:29 +00003555show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3556{
3557 if (lsa != NULL)
3558 {
3559 show_ip_ospf_database_header (vty, lsa);
3560 show_opaque_info_detail (vty, lsa);
3561
3562 vty_out (vty, "%s", VTY_NEWLINE);
3563 }
3564 return 0;
3565}
3566#endif /* HAVE_OPAQUE_LSA */
3567
3568int (*show_function[])(struct vty *, struct ospf_lsa *) =
3569{
3570 NULL,
3571 show_router_lsa_detail,
3572 show_network_lsa_detail,
3573 show_summary_lsa_detail,
3574 show_summary_asbr_lsa_detail,
3575 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003576 show_func_dummy,
3577 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003578#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003579 NULL, /* type-8 */
3580 show_opaque_lsa_detail,
3581 show_opaque_lsa_detail,
3582 show_opaque_lsa_detail,
3583#endif /* HAVE_OPAQUE_LSA */
3584};
3585
paul4dadc292005-05-06 21:37:42 +00003586static void
paul718e3742002-12-13 20:15:29 +00003587show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3588 struct in_addr *adv_router)
3589{
3590 memset (lp, 0, sizeof (struct prefix_ls));
3591 lp->family = 0;
3592 if (id == NULL)
3593 lp->prefixlen = 0;
3594 else if (adv_router == NULL)
3595 {
3596 lp->prefixlen = 32;
3597 lp->id = *id;
3598 }
3599 else
3600 {
3601 lp->prefixlen = 64;
3602 lp->id = *id;
3603 lp->adv_router = *adv_router;
3604 }
3605}
3606
paul4dadc292005-05-06 21:37:42 +00003607static void
paul718e3742002-12-13 20:15:29 +00003608show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3609 struct in_addr *id, struct in_addr *adv_router)
3610{
3611 struct prefix_ls lp;
3612 struct route_node *rn, *start;
3613 struct ospf_lsa *lsa;
3614
3615 show_lsa_prefix_set (vty, &lp, id, adv_router);
3616 start = route_node_get (rt, (struct prefix *) &lp);
3617 if (start)
3618 {
3619 route_lock_node (start);
3620 for (rn = start; rn; rn = route_next_until (rn, start))
3621 if ((lsa = rn->info))
3622 {
paul718e3742002-12-13 20:15:29 +00003623 if (show_function[lsa->data->type] != NULL)
3624 show_function[lsa->data->type] (vty, lsa);
3625 }
3626 route_unlock_node (start);
3627 }
3628}
3629
3630/* Show detail LSA information
3631 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003632static void
paul020709f2003-04-04 02:44:16 +00003633show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003634 struct in_addr *id, struct in_addr *adv_router)
3635{
hasso52dc7ee2004-09-23 19:18:23 +00003636 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003637 struct ospf_area *area;
3638
paul718e3742002-12-13 20:15:29 +00003639 switch (type)
3640 {
3641 case OSPF_AS_EXTERNAL_LSA:
3642#ifdef HAVE_OPAQUE_LSA
3643 case OSPF_OPAQUE_AS_LSA:
3644#endif /* HAVE_OPAQUE_LSA */
3645 vty_out (vty, " %s %s%s",
3646 show_database_desc[type],
3647 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003648 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003649 break;
3650 default:
paul1eb8ef22005-04-07 07:30:20 +00003651 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003652 {
paul718e3742002-12-13 20:15:29 +00003653 vty_out (vty, "%s %s (Area %s)%s%s",
3654 VTY_NEWLINE, show_database_desc[type],
3655 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3656 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3657 }
3658 break;
3659 }
3660}
3661
paul4dadc292005-05-06 21:37:42 +00003662static void
paul718e3742002-12-13 20:15:29 +00003663show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3664 struct in_addr *adv_router)
3665{
3666 struct route_node *rn;
3667 struct ospf_lsa *lsa;
3668
3669 for (rn = route_top (rt); rn; rn = route_next (rn))
3670 if ((lsa = rn->info))
3671 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3672 {
paul718e3742002-12-13 20:15:29 +00003673 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3674 continue;
paul718e3742002-12-13 20:15:29 +00003675 if (show_function[lsa->data->type] != NULL)
3676 show_function[lsa->data->type] (vty, lsa);
3677 }
3678}
3679
3680/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003681static void
paul020709f2003-04-04 02:44:16 +00003682show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003683 struct in_addr *adv_router)
3684{
hasso52dc7ee2004-09-23 19:18:23 +00003685 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003686 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003687
3688 switch (type)
3689 {
3690 case OSPF_AS_EXTERNAL_LSA:
3691#ifdef HAVE_OPAQUE_LSA
3692 case OSPF_OPAQUE_AS_LSA:
3693#endif /* HAVE_OPAQUE_LSA */
3694 vty_out (vty, " %s %s%s",
3695 show_database_desc[type],
3696 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003697 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003698 adv_router);
3699 break;
3700 default:
paul1eb8ef22005-04-07 07:30:20 +00003701 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003702 {
paul718e3742002-12-13 20:15:29 +00003703 vty_out (vty, "%s %s (Area %s)%s%s",
3704 VTY_NEWLINE, show_database_desc[type],
3705 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3706 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3707 adv_router);
3708 }
3709 break;
3710 }
3711}
3712
paul4dadc292005-05-06 21:37:42 +00003713static void
paul020709f2003-04-04 02:44:16 +00003714show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003715{
paul020709f2003-04-04 02:44:16 +00003716 struct ospf_lsa *lsa;
3717 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003718 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003719 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003720 int type;
3721
paul1eb8ef22005-04-07 07:30:20 +00003722 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003723 {
paul718e3742002-12-13 20:15:29 +00003724 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3725 {
3726 switch (type)
3727 {
3728 case OSPF_AS_EXTERNAL_LSA:
3729#ifdef HAVE_OPAQUE_LSA
3730 case OSPF_OPAQUE_AS_LSA:
3731#endif /* HAVE_OPAQUE_LSA */
3732 continue;
3733 default:
3734 break;
3735 }
3736 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3737 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3738 {
3739 vty_out (vty, " %s (Area %s)%s%s",
3740 show_database_desc[type],
3741 ospf_area_desc_string (area),
3742 VTY_NEWLINE, VTY_NEWLINE);
3743 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3744
paul020709f2003-04-04 02:44:16 +00003745 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3746 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003747
3748 vty_out (vty, "%s", VTY_NEWLINE);
3749 }
3750 }
3751 }
3752
3753 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3754 {
3755 switch (type)
3756 {
3757 case OSPF_AS_EXTERNAL_LSA:
3758#ifdef HAVE_OPAQUE_LSA
3759 case OSPF_OPAQUE_AS_LSA:
3760#endif /* HAVE_OPAQUE_LSA */
3761 break;;
3762 default:
3763 continue;
3764 }
paul68980082003-03-25 05:07:42 +00003765 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3766 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003767 {
3768 vty_out (vty, " %s%s%s",
3769 show_database_desc[type],
3770 VTY_NEWLINE, VTY_NEWLINE);
3771 vty_out (vty, "%s%s", show_database_header[type],
3772 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003773
3774 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3775 show_lsa_summary (vty, lsa, self);
3776
paul718e3742002-12-13 20:15:29 +00003777 vty_out (vty, "%s", VTY_NEWLINE);
3778 }
3779 }
3780
3781 vty_out (vty, "%s", VTY_NEWLINE);
3782}
3783
paul4dadc292005-05-06 21:37:42 +00003784static void
paul020709f2003-04-04 02:44:16 +00003785show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003786{
hasso52dc7ee2004-09-23 19:18:23 +00003787 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003788 struct ospf_lsa *lsa;
3789
3790 vty_out (vty, "%s MaxAge Link States:%s%s",
3791 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3792
paul1eb8ef22005-04-07 07:30:20 +00003793 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3794 {
3795 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3796 vty_out (vty, "Link State ID: %s%s",
3797 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3798 vty_out (vty, "Advertising Router: %s%s",
3799 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3800 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3801 vty_out (vty, "%s", VTY_NEWLINE);
3802 }
paul718e3742002-12-13 20:15:29 +00003803}
3804
paul718e3742002-12-13 20:15:29 +00003805#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3806#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003807
3808#ifdef HAVE_OPAQUE_LSA
3809#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3810#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3811#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3812#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3813#else /* HAVE_OPAQUE_LSA */
3814#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3815#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3816#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3817#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3818#endif /* HAVE_OPAQUE_LSA */
3819
3820#define OSPF_LSA_TYPES_CMD_STR \
3821 "asbr-summary|external|network|router|summary" \
3822 OSPF_LSA_TYPE_NSSA_CMD_STR \
3823 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3824
3825#define OSPF_LSA_TYPES_DESC \
3826 "ASBR summary link states\n" \
3827 "External link states\n" \
3828 "Network link states\n" \
3829 "Router link states\n" \
3830 "Network summary link states\n" \
3831 OSPF_LSA_TYPE_NSSA_DESC \
3832 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3833 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3834 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3835
3836DEFUN (show_ip_ospf_database,
3837 show_ip_ospf_database_cmd,
3838 "show ip ospf database",
3839 SHOW_STR
3840 IP_STR
3841 "OSPF information\n"
3842 "Database summary\n")
3843{
paul020709f2003-04-04 02:44:16 +00003844 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003845 int type, ret;
3846 struct in_addr id, adv_router;
3847
paul020709f2003-04-04 02:44:16 +00003848 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003849 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003850 return CMD_SUCCESS;
3851
3852 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003853 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003854
3855 /* Show all LSA. */
3856 if (argc == 0)
3857 {
paul020709f2003-04-04 02:44:16 +00003858 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003859 return CMD_SUCCESS;
3860 }
3861
3862 /* Set database type to show. */
3863 if (strncmp (argv[0], "r", 1) == 0)
3864 type = OSPF_ROUTER_LSA;
3865 else if (strncmp (argv[0], "ne", 2) == 0)
3866 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003867 else if (strncmp (argv[0], "ns", 2) == 0)
3868 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003869 else if (strncmp (argv[0], "su", 2) == 0)
3870 type = OSPF_SUMMARY_LSA;
3871 else if (strncmp (argv[0], "a", 1) == 0)
3872 type = OSPF_ASBR_SUMMARY_LSA;
3873 else if (strncmp (argv[0], "e", 1) == 0)
3874 type = OSPF_AS_EXTERNAL_LSA;
3875 else if (strncmp (argv[0], "se", 2) == 0)
3876 {
paul020709f2003-04-04 02:44:16 +00003877 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003878 return CMD_SUCCESS;
3879 }
3880 else if (strncmp (argv[0], "m", 1) == 0)
3881 {
paul020709f2003-04-04 02:44:16 +00003882 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003883 return CMD_SUCCESS;
3884 }
3885#ifdef HAVE_OPAQUE_LSA
3886 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3887 type = OSPF_OPAQUE_LINK_LSA;
3888 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3889 type = OSPF_OPAQUE_AREA_LSA;
3890 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3891 type = OSPF_OPAQUE_AS_LSA;
3892#endif /* HAVE_OPAQUE_LSA */
3893 else
3894 return CMD_WARNING;
3895
3896 /* `show ip ospf database LSA'. */
3897 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003898 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003899 else if (argc >= 2)
3900 {
3901 ret = inet_aton (argv[1], &id);
3902 if (!ret)
3903 return CMD_WARNING;
3904
3905 /* `show ip ospf database LSA ID'. */
3906 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003907 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003908 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3909 else if (argc == 3)
3910 {
3911 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003912 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003913 else
3914 {
3915 ret = inet_aton (argv[2], &adv_router);
3916 if (!ret)
3917 return CMD_WARNING;
3918 }
paul020709f2003-04-04 02:44:16 +00003919 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003920 }
3921 }
3922
3923 return CMD_SUCCESS;
3924}
3925
3926ALIAS (show_ip_ospf_database,
3927 show_ip_ospf_database_type_cmd,
3928 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3929 SHOW_STR
3930 IP_STR
3931 "OSPF information\n"
3932 "Database summary\n"
3933 OSPF_LSA_TYPES_DESC
3934 "LSAs in MaxAge list\n"
3935 "Self-originated link states\n")
3936
3937ALIAS (show_ip_ospf_database,
3938 show_ip_ospf_database_type_id_cmd,
3939 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3940 SHOW_STR
3941 IP_STR
3942 "OSPF information\n"
3943 "Database summary\n"
3944 OSPF_LSA_TYPES_DESC
3945 "Link State ID (as an IP address)\n")
3946
3947ALIAS (show_ip_ospf_database,
3948 show_ip_ospf_database_type_id_adv_router_cmd,
3949 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3950 SHOW_STR
3951 IP_STR
3952 "OSPF information\n"
3953 "Database summary\n"
3954 OSPF_LSA_TYPES_DESC
3955 "Link State ID (as an IP address)\n"
3956 "Advertising Router link states\n"
3957 "Advertising Router (as an IP address)\n")
3958
3959ALIAS (show_ip_ospf_database,
3960 show_ip_ospf_database_type_id_self_cmd,
3961 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3962 SHOW_STR
3963 IP_STR
3964 "OSPF information\n"
3965 "Database summary\n"
3966 OSPF_LSA_TYPES_DESC
3967 "Link State ID (as an IP address)\n"
3968 "Self-originated link states\n"
3969 "\n")
3970
3971DEFUN (show_ip_ospf_database_type_adv_router,
3972 show_ip_ospf_database_type_adv_router_cmd,
3973 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3974 SHOW_STR
3975 IP_STR
3976 "OSPF information\n"
3977 "Database summary\n"
3978 OSPF_LSA_TYPES_DESC
3979 "Advertising Router link states\n"
3980 "Advertising Router (as an IP address)\n")
3981{
paul020709f2003-04-04 02:44:16 +00003982 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003983 int type, ret;
3984 struct in_addr adv_router;
3985
paul020709f2003-04-04 02:44:16 +00003986 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003987 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003988 return CMD_SUCCESS;
3989
3990 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003991 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003992
3993 if (argc != 2)
3994 return CMD_WARNING;
3995
3996 /* Set database type to show. */
3997 if (strncmp (argv[0], "r", 1) == 0)
3998 type = OSPF_ROUTER_LSA;
3999 else if (strncmp (argv[0], "ne", 2) == 0)
4000 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004001 else if (strncmp (argv[0], "ns", 2) == 0)
4002 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004003 else if (strncmp (argv[0], "s", 1) == 0)
4004 type = OSPF_SUMMARY_LSA;
4005 else if (strncmp (argv[0], "a", 1) == 0)
4006 type = OSPF_ASBR_SUMMARY_LSA;
4007 else if (strncmp (argv[0], "e", 1) == 0)
4008 type = OSPF_AS_EXTERNAL_LSA;
4009#ifdef HAVE_OPAQUE_LSA
4010 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4011 type = OSPF_OPAQUE_LINK_LSA;
4012 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4013 type = OSPF_OPAQUE_AREA_LSA;
4014 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4015 type = OSPF_OPAQUE_AS_LSA;
4016#endif /* HAVE_OPAQUE_LSA */
4017 else
4018 return CMD_WARNING;
4019
4020 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4021 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004022 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004023 else
4024 {
4025 ret = inet_aton (argv[1], &adv_router);
4026 if (!ret)
4027 return CMD_WARNING;
4028 }
4029
paul020709f2003-04-04 02:44:16 +00004030 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004031
4032 return CMD_SUCCESS;
4033}
4034
4035ALIAS (show_ip_ospf_database_type_adv_router,
4036 show_ip_ospf_database_type_self_cmd,
4037 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4038 SHOW_STR
4039 IP_STR
4040 "OSPF information\n"
4041 "Database summary\n"
4042 OSPF_LSA_TYPES_DESC
4043 "Self-originated link states\n")
4044
4045
4046DEFUN (ip_ospf_authentication_args,
4047 ip_ospf_authentication_args_addr_cmd,
4048 "ip ospf authentication (null|message-digest) A.B.C.D",
4049 "IP Information\n"
4050 "OSPF interface commands\n"
4051 "Enable authentication on this interface\n"
4052 "Use null authentication\n"
4053 "Use message-digest authentication\n"
4054 "Address of interface")
4055{
4056 struct interface *ifp;
4057 struct in_addr addr;
4058 int ret;
4059 struct ospf_if_params *params;
4060
4061 ifp = vty->index;
4062 params = IF_DEF_PARAMS (ifp);
4063
4064 if (argc == 2)
4065 {
4066 ret = inet_aton(argv[1], &addr);
4067 if (!ret)
4068 {
4069 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4070 VTY_NEWLINE);
4071 return CMD_WARNING;
4072 }
4073
4074 params = ospf_get_if_params (ifp, addr);
4075 ospf_if_update_params (ifp, addr);
4076 }
4077
4078 /* Handle null authentication */
4079 if ( argv[0][0] == 'n' )
4080 {
4081 SET_IF_PARAM (params, auth_type);
4082 params->auth_type = OSPF_AUTH_NULL;
4083 return CMD_SUCCESS;
4084 }
4085
4086 /* Handle message-digest authentication */
4087 if ( argv[0][0] == 'm' )
4088 {
4089 SET_IF_PARAM (params, auth_type);
4090 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4091 return CMD_SUCCESS;
4092 }
4093
4094 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4095 return CMD_WARNING;
4096}
4097
4098ALIAS (ip_ospf_authentication_args,
4099 ip_ospf_authentication_args_cmd,
4100 "ip ospf authentication (null|message-digest)",
4101 "IP Information\n"
4102 "OSPF interface commands\n"
4103 "Enable authentication on this interface\n"
4104 "Use null authentication\n"
4105 "Use message-digest authentication\n")
4106
4107DEFUN (ip_ospf_authentication,
4108 ip_ospf_authentication_addr_cmd,
4109 "ip ospf authentication A.B.C.D",
4110 "IP Information\n"
4111 "OSPF interface commands\n"
4112 "Enable authentication on this interface\n"
4113 "Address of interface")
4114{
4115 struct interface *ifp;
4116 struct in_addr addr;
4117 int ret;
4118 struct ospf_if_params *params;
4119
4120 ifp = vty->index;
4121 params = IF_DEF_PARAMS (ifp);
4122
4123 if (argc == 1)
4124 {
4125 ret = inet_aton(argv[1], &addr);
4126 if (!ret)
4127 {
4128 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4129 VTY_NEWLINE);
4130 return CMD_WARNING;
4131 }
4132
4133 params = ospf_get_if_params (ifp, addr);
4134 ospf_if_update_params (ifp, addr);
4135 }
4136
4137 SET_IF_PARAM (params, auth_type);
4138 params->auth_type = OSPF_AUTH_SIMPLE;
4139
4140 return CMD_SUCCESS;
4141}
4142
4143ALIAS (ip_ospf_authentication,
4144 ip_ospf_authentication_cmd,
4145 "ip ospf authentication",
4146 "IP Information\n"
4147 "OSPF interface commands\n"
4148 "Enable authentication on this interface\n")
4149
4150DEFUN (no_ip_ospf_authentication,
4151 no_ip_ospf_authentication_addr_cmd,
4152 "no ip ospf authentication A.B.C.D",
4153 NO_STR
4154 "IP Information\n"
4155 "OSPF interface commands\n"
4156 "Enable authentication on this interface\n"
4157 "Address of interface")
4158{
4159 struct interface *ifp;
4160 struct in_addr addr;
4161 int ret;
4162 struct ospf_if_params *params;
4163
4164 ifp = vty->index;
4165 params = IF_DEF_PARAMS (ifp);
4166
4167 if (argc == 1)
4168 {
4169 ret = inet_aton(argv[1], &addr);
4170 if (!ret)
4171 {
4172 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4173 VTY_NEWLINE);
4174 return CMD_WARNING;
4175 }
4176
4177 params = ospf_lookup_if_params (ifp, addr);
4178 if (params == NULL)
4179 return CMD_SUCCESS;
4180 }
4181
4182 params->auth_type = OSPF_AUTH_NOTSET;
4183 UNSET_IF_PARAM (params, auth_type);
4184
4185 if (params != IF_DEF_PARAMS (ifp))
4186 {
4187 ospf_free_if_params (ifp, addr);
4188 ospf_if_update_params (ifp, addr);
4189 }
4190
4191 return CMD_SUCCESS;
4192}
4193
4194ALIAS (no_ip_ospf_authentication,
4195 no_ip_ospf_authentication_cmd,
4196 "no ip ospf authentication",
4197 NO_STR
4198 "IP Information\n"
4199 "OSPF interface commands\n"
4200 "Enable authentication on this interface\n")
4201
4202DEFUN (ip_ospf_authentication_key,
4203 ip_ospf_authentication_key_addr_cmd,
4204 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4205 "IP Information\n"
4206 "OSPF interface commands\n"
4207 "Authentication password (key)\n"
4208 "The OSPF password (key)\n"
4209 "Address of interface")
4210{
4211 struct interface *ifp;
4212 struct in_addr addr;
4213 int ret;
4214 struct ospf_if_params *params;
4215
4216 ifp = vty->index;
4217 params = IF_DEF_PARAMS (ifp);
4218
4219 if (argc == 2)
4220 {
4221 ret = inet_aton(argv[1], &addr);
4222 if (!ret)
4223 {
4224 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4225 VTY_NEWLINE);
4226 return CMD_WARNING;
4227 }
4228
4229 params = ospf_get_if_params (ifp, addr);
4230 ospf_if_update_params (ifp, addr);
4231 }
4232
4233
4234 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004235 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004236 SET_IF_PARAM (params, auth_simple);
4237
4238 return CMD_SUCCESS;
4239}
4240
4241ALIAS (ip_ospf_authentication_key,
4242 ip_ospf_authentication_key_cmd,
4243 "ip ospf authentication-key AUTH_KEY",
4244 "IP Information\n"
4245 "OSPF interface commands\n"
4246 "Authentication password (key)\n"
4247 "The OSPF password (key)")
4248
4249ALIAS (ip_ospf_authentication_key,
4250 ospf_authentication_key_cmd,
4251 "ospf authentication-key AUTH_KEY",
4252 "OSPF interface commands\n"
4253 "Authentication password (key)\n"
4254 "The OSPF password (key)")
4255
4256DEFUN (no_ip_ospf_authentication_key,
4257 no_ip_ospf_authentication_key_addr_cmd,
4258 "no ip ospf authentication-key A.B.C.D",
4259 NO_STR
4260 "IP Information\n"
4261 "OSPF interface commands\n"
4262 "Authentication password (key)\n"
4263 "Address of interface")
4264{
4265 struct interface *ifp;
4266 struct in_addr addr;
4267 int ret;
4268 struct ospf_if_params *params;
4269
4270 ifp = vty->index;
4271 params = IF_DEF_PARAMS (ifp);
4272
4273 if (argc == 2)
4274 {
4275 ret = inet_aton(argv[1], &addr);
4276 if (!ret)
4277 {
4278 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4279 VTY_NEWLINE);
4280 return CMD_WARNING;
4281 }
4282
4283 params = ospf_lookup_if_params (ifp, addr);
4284 if (params == NULL)
4285 return CMD_SUCCESS;
4286 }
4287
4288 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4289 UNSET_IF_PARAM (params, auth_simple);
4290
4291 if (params != IF_DEF_PARAMS (ifp))
4292 {
4293 ospf_free_if_params (ifp, addr);
4294 ospf_if_update_params (ifp, addr);
4295 }
4296
4297 return CMD_SUCCESS;
4298}
4299
4300ALIAS (no_ip_ospf_authentication_key,
4301 no_ip_ospf_authentication_key_cmd,
4302 "no ip ospf authentication-key",
4303 NO_STR
4304 "IP Information\n"
4305 "OSPF interface commands\n"
4306 "Authentication password (key)\n")
4307
4308ALIAS (no_ip_ospf_authentication_key,
4309 no_ospf_authentication_key_cmd,
4310 "no ospf authentication-key",
4311 NO_STR
4312 "OSPF interface commands\n"
4313 "Authentication password (key)\n")
4314
4315DEFUN (ip_ospf_message_digest_key,
4316 ip_ospf_message_digest_key_addr_cmd,
4317 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4318 "IP Information\n"
4319 "OSPF interface commands\n"
4320 "Message digest authentication password (key)\n"
4321 "Key ID\n"
4322 "Use MD5 algorithm\n"
4323 "The OSPF password (key)"
4324 "Address of interface")
4325{
4326 struct interface *ifp;
4327 struct crypt_key *ck;
4328 u_char key_id;
4329 struct in_addr addr;
4330 int ret;
4331 struct ospf_if_params *params;
4332
4333 ifp = vty->index;
4334 params = IF_DEF_PARAMS (ifp);
4335
4336 if (argc == 3)
4337 {
4338 ret = inet_aton(argv[2], &addr);
4339 if (!ret)
4340 {
4341 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4342 VTY_NEWLINE);
4343 return CMD_WARNING;
4344 }
4345
4346 params = ospf_get_if_params (ifp, addr);
4347 ospf_if_update_params (ifp, addr);
4348 }
4349
4350 key_id = strtol (argv[0], NULL, 10);
4351 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4352 {
4353 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4354 return CMD_WARNING;
4355 }
4356
4357 ck = ospf_crypt_key_new ();
4358 ck->key_id = (u_char) key_id;
4359 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004360 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004361
4362 ospf_crypt_key_add (params->auth_crypt, ck);
4363 SET_IF_PARAM (params, auth_crypt);
4364
4365 return CMD_SUCCESS;
4366}
4367
4368ALIAS (ip_ospf_message_digest_key,
4369 ip_ospf_message_digest_key_cmd,
4370 "ip ospf message-digest-key <1-255> md5 KEY",
4371 "IP Information\n"
4372 "OSPF interface commands\n"
4373 "Message digest authentication password (key)\n"
4374 "Key ID\n"
4375 "Use MD5 algorithm\n"
4376 "The OSPF password (key)")
4377
4378ALIAS (ip_ospf_message_digest_key,
4379 ospf_message_digest_key_cmd,
4380 "ospf message-digest-key <1-255> md5 KEY",
4381 "OSPF interface commands\n"
4382 "Message digest authentication password (key)\n"
4383 "Key ID\n"
4384 "Use MD5 algorithm\n"
4385 "The OSPF password (key)")
4386
4387DEFUN (no_ip_ospf_message_digest_key,
4388 no_ip_ospf_message_digest_key_addr_cmd,
4389 "no ip ospf message-digest-key <1-255> A.B.C.D",
4390 NO_STR
4391 "IP Information\n"
4392 "OSPF interface commands\n"
4393 "Message digest authentication password (key)\n"
4394 "Key ID\n"
4395 "Address of interface")
4396{
4397 struct interface *ifp;
4398 struct crypt_key *ck;
4399 int key_id;
4400 struct in_addr addr;
4401 int ret;
4402 struct ospf_if_params *params;
4403
4404 ifp = vty->index;
4405 params = IF_DEF_PARAMS (ifp);
4406
4407 if (argc == 2)
4408 {
4409 ret = inet_aton(argv[1], &addr);
4410 if (!ret)
4411 {
4412 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4413 VTY_NEWLINE);
4414 return CMD_WARNING;
4415 }
4416
4417 params = ospf_lookup_if_params (ifp, addr);
4418 if (params == NULL)
4419 return CMD_SUCCESS;
4420 }
4421
4422 key_id = strtol (argv[0], NULL, 10);
4423 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4424 if (ck == NULL)
4425 {
4426 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4427 return CMD_WARNING;
4428 }
4429
4430 ospf_crypt_key_delete (params->auth_crypt, key_id);
4431
4432 if (params != IF_DEF_PARAMS (ifp))
4433 {
4434 ospf_free_if_params (ifp, addr);
4435 ospf_if_update_params (ifp, addr);
4436 }
4437
4438 return CMD_SUCCESS;
4439}
4440
4441ALIAS (no_ip_ospf_message_digest_key,
4442 no_ip_ospf_message_digest_key_cmd,
4443 "no ip ospf message-digest-key <1-255>",
4444 NO_STR
4445 "IP Information\n"
4446 "OSPF interface commands\n"
4447 "Message digest authentication password (key)\n"
4448 "Key ID\n")
4449
4450ALIAS (no_ip_ospf_message_digest_key,
4451 no_ospf_message_digest_key_cmd,
4452 "no ospf message-digest-key <1-255>",
4453 NO_STR
4454 "OSPF interface commands\n"
4455 "Message digest authentication password (key)\n"
4456 "Key ID\n")
4457
4458DEFUN (ip_ospf_cost,
4459 ip_ospf_cost_addr_cmd,
4460 "ip ospf cost <1-65535> A.B.C.D",
4461 "IP Information\n"
4462 "OSPF interface commands\n"
4463 "Interface cost\n"
4464 "Cost\n"
4465 "Address of interface")
4466{
4467 struct interface *ifp = vty->index;
4468 u_int32_t cost;
4469 struct in_addr addr;
4470 int ret;
4471 struct ospf_if_params *params;
4472
4473 params = IF_DEF_PARAMS (ifp);
4474
4475 cost = strtol (argv[0], NULL, 10);
4476
4477 /* cost range is <1-65535>. */
4478 if (cost < 1 || cost > 65535)
4479 {
4480 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4481 return CMD_WARNING;
4482 }
4483
4484 if (argc == 2)
4485 {
4486 ret = inet_aton(argv[1], &addr);
4487 if (!ret)
4488 {
4489 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4490 VTY_NEWLINE);
4491 return CMD_WARNING;
4492 }
4493
4494 params = ospf_get_if_params (ifp, addr);
4495 ospf_if_update_params (ifp, addr);
4496 }
4497
4498 SET_IF_PARAM (params, output_cost_cmd);
4499 params->output_cost_cmd = cost;
4500
4501 ospf_if_recalculate_output_cost (ifp);
4502
4503 return CMD_SUCCESS;
4504}
4505
4506ALIAS (ip_ospf_cost,
4507 ip_ospf_cost_cmd,
4508 "ip ospf cost <1-65535>",
4509 "IP Information\n"
4510 "OSPF interface commands\n"
4511 "Interface cost\n"
4512 "Cost")
4513
4514ALIAS (ip_ospf_cost,
4515 ospf_cost_cmd,
4516 "ospf cost <1-65535>",
4517 "OSPF interface commands\n"
4518 "Interface cost\n"
4519 "Cost")
4520
4521DEFUN (no_ip_ospf_cost,
4522 no_ip_ospf_cost_addr_cmd,
4523 "no ip ospf cost A.B.C.D",
4524 NO_STR
4525 "IP Information\n"
4526 "OSPF interface commands\n"
4527 "Interface cost\n"
4528 "Address of interface")
4529{
4530 struct interface *ifp = vty->index;
4531 struct in_addr addr;
4532 int ret;
4533 struct ospf_if_params *params;
4534
4535 ifp = vty->index;
4536 params = IF_DEF_PARAMS (ifp);
4537
4538 if (argc == 1)
4539 {
4540 ret = inet_aton(argv[0], &addr);
4541 if (!ret)
4542 {
4543 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4544 VTY_NEWLINE);
4545 return CMD_WARNING;
4546 }
4547
4548 params = ospf_lookup_if_params (ifp, addr);
4549 if (params == NULL)
4550 return CMD_SUCCESS;
4551 }
4552
4553 UNSET_IF_PARAM (params, output_cost_cmd);
4554
4555 if (params != IF_DEF_PARAMS (ifp))
4556 {
4557 ospf_free_if_params (ifp, addr);
4558 ospf_if_update_params (ifp, addr);
4559 }
4560
4561 ospf_if_recalculate_output_cost (ifp);
4562
4563 return CMD_SUCCESS;
4564}
4565
4566ALIAS (no_ip_ospf_cost,
4567 no_ip_ospf_cost_cmd,
4568 "no ip ospf cost",
4569 NO_STR
4570 "IP Information\n"
4571 "OSPF interface commands\n"
4572 "Interface cost\n")
4573
4574ALIAS (no_ip_ospf_cost,
4575 no_ospf_cost_cmd,
4576 "no ospf cost",
4577 NO_STR
4578 "OSPF interface commands\n"
4579 "Interface cost\n")
4580
paul4dadc292005-05-06 21:37:42 +00004581static void
paul718e3742002-12-13 20:15:29 +00004582ospf_nbr_timer_update (struct ospf_interface *oi)
4583{
4584 struct route_node *rn;
4585 struct ospf_neighbor *nbr;
4586
4587 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4588 if ((nbr = rn->info))
4589 {
4590 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4591 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4592 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4593 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4594 }
4595}
4596
paulf9ad9372005-10-21 00:45:17 +00004597static int
4598ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4599 const char *nbr_str,
4600 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004601{
4602 struct interface *ifp = vty->index;
4603 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004604 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004605 struct in_addr addr;
4606 int ret;
4607 struct ospf_if_params *params;
4608 struct ospf_interface *oi;
4609 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004610 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004611
paul020709f2003-04-04 02:44:16 +00004612 ospf = ospf_lookup ();
4613
paul718e3742002-12-13 20:15:29 +00004614 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004615
4616 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004617 {
paulf9ad9372005-10-21 00:45:17 +00004618 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004619 if (!ret)
4620 {
4621 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4622 VTY_NEWLINE);
4623 return CMD_WARNING;
4624 }
4625
4626 params = ospf_get_if_params (ifp, addr);
4627 ospf_if_update_params (ifp, addr);
4628 }
4629
paulf9ad9372005-10-21 00:45:17 +00004630 if (interval_str)
4631 {
4632 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4633 1, 65535);
4634
4635 /* reset fast_hello too, just to be sure */
4636 UNSET_IF_PARAM (params, fast_hello);
4637 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4638 }
4639 else if (fast_hello_str)
4640 {
4641 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4642 1, 10);
4643 /* 1s dead-interval with sub-second hellos desired */
4644 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4645 SET_IF_PARAM (params, fast_hello);
4646 params->fast_hello = hellomult;
4647 }
4648 else
4649 {
4650 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4651 VTY_NEWLINE);
4652 return CMD_WARNING;
4653 }
4654
paul718e3742002-12-13 20:15:29 +00004655 SET_IF_PARAM (params, v_wait);
4656 params->v_wait = seconds;
4657
4658 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00004659 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004660 {
paul68980082003-03-25 05:07:42 +00004661 if (ospf)
4662 {
4663 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4664 if (oi)
4665 ospf_nbr_timer_update (oi);
4666 }
paul718e3742002-12-13 20:15:29 +00004667 }
4668 else
4669 {
4670 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4671 if ((oi = rn->info))
4672 ospf_nbr_timer_update (oi);
4673 }
4674
4675 return CMD_SUCCESS;
4676}
4677
paulf9ad9372005-10-21 00:45:17 +00004678
4679DEFUN (ip_ospf_dead_interval,
4680 ip_ospf_dead_interval_addr_cmd,
4681 "ip ospf dead-interval <1-65535> A.B.C.D",
4682 "IP Information\n"
4683 "OSPF interface commands\n"
4684 "Interval after which a neighbor is declared dead\n"
4685 "Seconds\n"
4686 "Address of interface\n")
4687{
4688 if (argc == 2)
4689 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4690 else
4691 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4692}
4693
paul718e3742002-12-13 20:15:29 +00004694ALIAS (ip_ospf_dead_interval,
4695 ip_ospf_dead_interval_cmd,
4696 "ip ospf dead-interval <1-65535>",
4697 "IP Information\n"
4698 "OSPF interface commands\n"
4699 "Interval after which a neighbor is declared dead\n"
4700 "Seconds\n")
4701
4702ALIAS (ip_ospf_dead_interval,
4703 ospf_dead_interval_cmd,
4704 "ospf dead-interval <1-65535>",
4705 "OSPF interface commands\n"
4706 "Interval after which a neighbor is declared dead\n"
4707 "Seconds\n")
4708
paulf9ad9372005-10-21 00:45:17 +00004709DEFUN (ip_ospf_dead_interval_minimal,
4710 ip_ospf_dead_interval_minimal_addr_cmd,
4711 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4712 "IP Information\n"
4713 "OSPF interface commands\n"
4714 "Interval after which a neighbor is declared dead\n"
4715 "Minimal 1s dead-interval with fast sub-second hellos\n"
4716 "Hello multiplier factor\n"
4717 "Number of Hellos to send each second\n"
4718 "Address of interface\n")
4719{
4720 if (argc == 2)
4721 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4722 else
4723 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4724}
4725
4726ALIAS (ip_ospf_dead_interval_minimal,
4727 ip_ospf_dead_interval_minimal_cmd,
4728 "ip ospf dead-interval minimal hello-multiplier <1-10>",
4729 "IP Information\n"
4730 "OSPF interface commands\n"
4731 "Interval after which a neighbor is declared dead\n"
4732 "Minimal 1s dead-interval with fast sub-second hellos\n"
4733 "Hello multiplier factor\n"
4734 "Number of Hellos to send each second\n")
4735
paul718e3742002-12-13 20:15:29 +00004736DEFUN (no_ip_ospf_dead_interval,
4737 no_ip_ospf_dead_interval_addr_cmd,
4738 "no ip ospf dead-interval A.B.C.D",
4739 NO_STR
4740 "IP Information\n"
4741 "OSPF interface commands\n"
4742 "Interval after which a neighbor is declared dead\n"
4743 "Address of interface")
4744{
4745 struct interface *ifp = vty->index;
4746 struct in_addr addr;
4747 int ret;
4748 struct ospf_if_params *params;
4749 struct ospf_interface *oi;
4750 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004751 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004752
paul020709f2003-04-04 02:44:16 +00004753 ospf = ospf_lookup ();
4754
paul718e3742002-12-13 20:15:29 +00004755 ifp = vty->index;
4756 params = IF_DEF_PARAMS (ifp);
4757
4758 if (argc == 1)
4759 {
4760 ret = inet_aton(argv[0], &addr);
4761 if (!ret)
4762 {
4763 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4764 VTY_NEWLINE);
4765 return CMD_WARNING;
4766 }
4767
4768 params = ospf_lookup_if_params (ifp, addr);
4769 if (params == NULL)
4770 return CMD_SUCCESS;
4771 }
4772
4773 UNSET_IF_PARAM (params, v_wait);
4774 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00004775
4776 UNSET_IF_PARAM (params, fast_hello);
4777 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4778
paul718e3742002-12-13 20:15:29 +00004779 if (params != IF_DEF_PARAMS (ifp))
4780 {
4781 ospf_free_if_params (ifp, addr);
4782 ospf_if_update_params (ifp, addr);
4783 }
4784
4785 /* Update timer values in neighbor structure. */
4786 if (argc == 1)
4787 {
paul68980082003-03-25 05:07:42 +00004788 if (ospf)
4789 {
4790 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4791 if (oi)
4792 ospf_nbr_timer_update (oi);
4793 }
paul718e3742002-12-13 20:15:29 +00004794 }
4795 else
4796 {
4797 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4798 if ((oi = rn->info))
4799 ospf_nbr_timer_update (oi);
4800 }
4801
4802 return CMD_SUCCESS;
4803}
4804
4805ALIAS (no_ip_ospf_dead_interval,
4806 no_ip_ospf_dead_interval_cmd,
4807 "no ip ospf dead-interval",
4808 NO_STR
4809 "IP Information\n"
4810 "OSPF interface commands\n"
4811 "Interval after which a neighbor is declared dead\n")
4812
4813ALIAS (no_ip_ospf_dead_interval,
4814 no_ospf_dead_interval_cmd,
4815 "no ospf dead-interval",
4816 NO_STR
4817 "OSPF interface commands\n"
4818 "Interval after which a neighbor is declared dead\n")
4819
4820DEFUN (ip_ospf_hello_interval,
4821 ip_ospf_hello_interval_addr_cmd,
4822 "ip ospf hello-interval <1-65535> A.B.C.D",
4823 "IP Information\n"
4824 "OSPF interface commands\n"
4825 "Time between HELLO packets\n"
4826 "Seconds\n"
4827 "Address of interface")
4828{
4829 struct interface *ifp = vty->index;
4830 u_int32_t seconds;
4831 struct in_addr addr;
4832 int ret;
4833 struct ospf_if_params *params;
4834
4835 params = IF_DEF_PARAMS (ifp);
4836
4837 seconds = strtol (argv[0], NULL, 10);
4838
4839 /* HelloInterval range is <1-65535>. */
4840 if (seconds < 1 || seconds > 65535)
4841 {
4842 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4843 return CMD_WARNING;
4844 }
4845
4846 if (argc == 2)
4847 {
4848 ret = inet_aton(argv[1], &addr);
4849 if (!ret)
4850 {
4851 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4852 VTY_NEWLINE);
4853 return CMD_WARNING;
4854 }
4855
4856 params = ospf_get_if_params (ifp, addr);
4857 ospf_if_update_params (ifp, addr);
4858 }
4859
paulf9ad9372005-10-21 00:45:17 +00004860 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00004861 params->v_hello = seconds;
4862
4863 return CMD_SUCCESS;
4864}
4865
4866ALIAS (ip_ospf_hello_interval,
4867 ip_ospf_hello_interval_cmd,
4868 "ip ospf hello-interval <1-65535>",
4869 "IP Information\n"
4870 "OSPF interface commands\n"
4871 "Time between HELLO packets\n"
4872 "Seconds\n")
4873
4874ALIAS (ip_ospf_hello_interval,
4875 ospf_hello_interval_cmd,
4876 "ospf hello-interval <1-65535>",
4877 "OSPF interface commands\n"
4878 "Time between HELLO packets\n"
4879 "Seconds\n")
4880
4881DEFUN (no_ip_ospf_hello_interval,
4882 no_ip_ospf_hello_interval_addr_cmd,
4883 "no ip ospf hello-interval A.B.C.D",
4884 NO_STR
4885 "IP Information\n"
4886 "OSPF interface commands\n"
4887 "Time between HELLO packets\n"
4888 "Address of interface")
4889{
4890 struct interface *ifp = vty->index;
4891 struct in_addr addr;
4892 int ret;
4893 struct ospf_if_params *params;
4894
4895 ifp = vty->index;
4896 params = IF_DEF_PARAMS (ifp);
4897
4898 if (argc == 1)
4899 {
4900 ret = inet_aton(argv[0], &addr);
4901 if (!ret)
4902 {
4903 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4904 VTY_NEWLINE);
4905 return CMD_WARNING;
4906 }
4907
4908 params = ospf_lookup_if_params (ifp, addr);
4909 if (params == NULL)
4910 return CMD_SUCCESS;
4911 }
4912
4913 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00004914 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00004915
4916 if (params != IF_DEF_PARAMS (ifp))
4917 {
4918 ospf_free_if_params (ifp, addr);
4919 ospf_if_update_params (ifp, addr);
4920 }
4921
4922 return CMD_SUCCESS;
4923}
4924
4925ALIAS (no_ip_ospf_hello_interval,
4926 no_ip_ospf_hello_interval_cmd,
4927 "no ip ospf hello-interval",
4928 NO_STR
4929 "IP Information\n"
4930 "OSPF interface commands\n"
4931 "Time between HELLO packets\n")
4932
4933ALIAS (no_ip_ospf_hello_interval,
4934 no_ospf_hello_interval_cmd,
4935 "no ospf hello-interval",
4936 NO_STR
4937 "OSPF interface commands\n"
4938 "Time between HELLO packets\n")
4939
4940DEFUN (ip_ospf_network,
4941 ip_ospf_network_cmd,
4942 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4943 "IP Information\n"
4944 "OSPF interface commands\n"
4945 "Network type\n"
4946 "Specify OSPF broadcast multi-access network\n"
4947 "Specify OSPF NBMA network\n"
4948 "Specify OSPF point-to-multipoint network\n"
4949 "Specify OSPF point-to-point network\n")
4950{
4951 struct interface *ifp = vty->index;
4952 int old_type = IF_DEF_PARAMS (ifp)->type;
4953 struct route_node *rn;
4954
4955 if (strncmp (argv[0], "b", 1) == 0)
4956 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4957 else if (strncmp (argv[0], "n", 1) == 0)
4958 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4959 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4960 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4961 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4962 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4963
4964 if (IF_DEF_PARAMS (ifp)->type == old_type)
4965 return CMD_SUCCESS;
4966
4967 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4968
4969 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4970 {
4971 struct ospf_interface *oi = rn->info;
4972
4973 if (!oi)
4974 continue;
4975
4976 oi->type = IF_DEF_PARAMS (ifp)->type;
4977
4978 if (oi->state > ISM_Down)
4979 {
4980 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4981 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4982 }
4983 }
4984
4985 return CMD_SUCCESS;
4986}
4987
4988ALIAS (ip_ospf_network,
4989 ospf_network_cmd,
4990 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4991 "OSPF interface commands\n"
4992 "Network type\n"
4993 "Specify OSPF broadcast multi-access network\n"
4994 "Specify OSPF NBMA network\n"
4995 "Specify OSPF point-to-multipoint network\n"
4996 "Specify OSPF point-to-point network\n")
4997
4998DEFUN (no_ip_ospf_network,
4999 no_ip_ospf_network_cmd,
5000 "no ip ospf network",
5001 NO_STR
5002 "IP Information\n"
5003 "OSPF interface commands\n"
5004 "Network type\n")
5005{
5006 struct interface *ifp = vty->index;
5007 int old_type = IF_DEF_PARAMS (ifp)->type;
5008 struct route_node *rn;
5009
ajsbc18d612004-12-15 15:07:19 +00005010 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005011
5012 if (IF_DEF_PARAMS (ifp)->type == old_type)
5013 return CMD_SUCCESS;
5014
5015 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5016 {
5017 struct ospf_interface *oi = rn->info;
5018
5019 if (!oi)
5020 continue;
5021
5022 oi->type = IF_DEF_PARAMS (ifp)->type;
5023
5024 if (oi->state > ISM_Down)
5025 {
5026 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5027 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5028 }
5029 }
5030
5031 return CMD_SUCCESS;
5032}
5033
5034ALIAS (no_ip_ospf_network,
5035 no_ospf_network_cmd,
5036 "no ospf network",
5037 NO_STR
5038 "OSPF interface commands\n"
5039 "Network type\n")
5040
5041DEFUN (ip_ospf_priority,
5042 ip_ospf_priority_addr_cmd,
5043 "ip ospf priority <0-255> A.B.C.D",
5044 "IP Information\n"
5045 "OSPF interface commands\n"
5046 "Router priority\n"
5047 "Priority\n"
5048 "Address of interface")
5049{
5050 struct interface *ifp = vty->index;
5051 u_int32_t priority;
5052 struct route_node *rn;
5053 struct in_addr addr;
5054 int ret;
5055 struct ospf_if_params *params;
5056
5057 params = IF_DEF_PARAMS (ifp);
5058
5059 priority = strtol (argv[0], NULL, 10);
5060
5061 /* Router Priority range is <0-255>. */
5062 if (priority < 0 || priority > 255)
5063 {
5064 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5065 return CMD_WARNING;
5066 }
5067
5068 if (argc == 2)
5069 {
5070 ret = inet_aton(argv[1], &addr);
5071 if (!ret)
5072 {
5073 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5074 VTY_NEWLINE);
5075 return CMD_WARNING;
5076 }
5077
5078 params = ospf_get_if_params (ifp, addr);
5079 ospf_if_update_params (ifp, addr);
5080 }
5081
5082 SET_IF_PARAM (params, priority);
5083 params->priority = priority;
5084
5085 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5086 {
5087 struct ospf_interface *oi = rn->info;
5088
5089 if (!oi)
5090 continue;
5091
5092
5093 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5094 {
5095 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5096 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5097 }
5098 }
5099
5100 return CMD_SUCCESS;
5101}
5102
5103ALIAS (ip_ospf_priority,
5104 ip_ospf_priority_cmd,
5105 "ip ospf priority <0-255>",
5106 "IP Information\n"
5107 "OSPF interface commands\n"
5108 "Router priority\n"
5109 "Priority\n")
5110
5111ALIAS (ip_ospf_priority,
5112 ospf_priority_cmd,
5113 "ospf priority <0-255>",
5114 "OSPF interface commands\n"
5115 "Router priority\n"
5116 "Priority\n")
5117
5118DEFUN (no_ip_ospf_priority,
5119 no_ip_ospf_priority_addr_cmd,
5120 "no ip ospf priority A.B.C.D",
5121 NO_STR
5122 "IP Information\n"
5123 "OSPF interface commands\n"
5124 "Router priority\n"
5125 "Address of interface")
5126{
5127 struct interface *ifp = vty->index;
5128 struct route_node *rn;
5129 struct in_addr addr;
5130 int ret;
5131 struct ospf_if_params *params;
5132
5133 ifp = vty->index;
5134 params = IF_DEF_PARAMS (ifp);
5135
5136 if (argc == 1)
5137 {
5138 ret = inet_aton(argv[0], &addr);
5139 if (!ret)
5140 {
5141 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5142 VTY_NEWLINE);
5143 return CMD_WARNING;
5144 }
5145
5146 params = ospf_lookup_if_params (ifp, addr);
5147 if (params == NULL)
5148 return CMD_SUCCESS;
5149 }
5150
5151 UNSET_IF_PARAM (params, priority);
5152 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5153
5154 if (params != IF_DEF_PARAMS (ifp))
5155 {
5156 ospf_free_if_params (ifp, addr);
5157 ospf_if_update_params (ifp, addr);
5158 }
5159
5160 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5161 {
5162 struct ospf_interface *oi = rn->info;
5163
5164 if (!oi)
5165 continue;
5166
5167
5168 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5169 {
5170 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5171 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5172 }
5173 }
5174
5175 return CMD_SUCCESS;
5176}
5177
5178ALIAS (no_ip_ospf_priority,
5179 no_ip_ospf_priority_cmd,
5180 "no ip ospf priority",
5181 NO_STR
5182 "IP Information\n"
5183 "OSPF interface commands\n"
5184 "Router priority\n")
5185
5186ALIAS (no_ip_ospf_priority,
5187 no_ospf_priority_cmd,
5188 "no ospf priority",
5189 NO_STR
5190 "OSPF interface commands\n"
5191 "Router priority\n")
5192
5193DEFUN (ip_ospf_retransmit_interval,
5194 ip_ospf_retransmit_interval_addr_cmd,
5195 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5196 "IP Information\n"
5197 "OSPF interface commands\n"
5198 "Time between retransmitting lost link state advertisements\n"
5199 "Seconds\n"
5200 "Address of interface")
5201{
5202 struct interface *ifp = vty->index;
5203 u_int32_t seconds;
5204 struct in_addr addr;
5205 int ret;
5206 struct ospf_if_params *params;
5207
5208 params = IF_DEF_PARAMS (ifp);
5209 seconds = strtol (argv[0], NULL, 10);
5210
5211 /* Retransmit Interval range is <3-65535>. */
5212 if (seconds < 3 || seconds > 65535)
5213 {
5214 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5215 return CMD_WARNING;
5216 }
5217
5218
5219 if (argc == 2)
5220 {
5221 ret = inet_aton(argv[1], &addr);
5222 if (!ret)
5223 {
5224 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5225 VTY_NEWLINE);
5226 return CMD_WARNING;
5227 }
5228
5229 params = ospf_get_if_params (ifp, addr);
5230 ospf_if_update_params (ifp, addr);
5231 }
5232
5233 SET_IF_PARAM (params, retransmit_interval);
5234 params->retransmit_interval = seconds;
5235
5236 return CMD_SUCCESS;
5237}
5238
5239ALIAS (ip_ospf_retransmit_interval,
5240 ip_ospf_retransmit_interval_cmd,
5241 "ip ospf retransmit-interval <3-65535>",
5242 "IP Information\n"
5243 "OSPF interface commands\n"
5244 "Time between retransmitting lost link state advertisements\n"
5245 "Seconds\n")
5246
5247ALIAS (ip_ospf_retransmit_interval,
5248 ospf_retransmit_interval_cmd,
5249 "ospf retransmit-interval <3-65535>",
5250 "OSPF interface commands\n"
5251 "Time between retransmitting lost link state advertisements\n"
5252 "Seconds\n")
5253
5254DEFUN (no_ip_ospf_retransmit_interval,
5255 no_ip_ospf_retransmit_interval_addr_cmd,
5256 "no ip ospf retransmit-interval A.B.C.D",
5257 NO_STR
5258 "IP Information\n"
5259 "OSPF interface commands\n"
5260 "Time between retransmitting lost link state advertisements\n"
5261 "Address of interface")
5262{
5263 struct interface *ifp = vty->index;
5264 struct in_addr addr;
5265 int ret;
5266 struct ospf_if_params *params;
5267
5268 ifp = vty->index;
5269 params = IF_DEF_PARAMS (ifp);
5270
5271 if (argc == 1)
5272 {
5273 ret = inet_aton(argv[0], &addr);
5274 if (!ret)
5275 {
5276 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5277 VTY_NEWLINE);
5278 return CMD_WARNING;
5279 }
5280
5281 params = ospf_lookup_if_params (ifp, addr);
5282 if (params == NULL)
5283 return CMD_SUCCESS;
5284 }
5285
5286 UNSET_IF_PARAM (params, retransmit_interval);
5287 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5288
5289 if (params != IF_DEF_PARAMS (ifp))
5290 {
5291 ospf_free_if_params (ifp, addr);
5292 ospf_if_update_params (ifp, addr);
5293 }
5294
5295 return CMD_SUCCESS;
5296}
5297
5298ALIAS (no_ip_ospf_retransmit_interval,
5299 no_ip_ospf_retransmit_interval_cmd,
5300 "no ip ospf retransmit-interval",
5301 NO_STR
5302 "IP Information\n"
5303 "OSPF interface commands\n"
5304 "Time between retransmitting lost link state advertisements\n")
5305
5306ALIAS (no_ip_ospf_retransmit_interval,
5307 no_ospf_retransmit_interval_cmd,
5308 "no ospf retransmit-interval",
5309 NO_STR
5310 "OSPF interface commands\n"
5311 "Time between retransmitting lost link state advertisements\n")
5312
5313DEFUN (ip_ospf_transmit_delay,
5314 ip_ospf_transmit_delay_addr_cmd,
5315 "ip ospf transmit-delay <1-65535> A.B.C.D",
5316 "IP Information\n"
5317 "OSPF interface commands\n"
5318 "Link state transmit delay\n"
5319 "Seconds\n"
5320 "Address of interface")
5321{
5322 struct interface *ifp = vty->index;
5323 u_int32_t seconds;
5324 struct in_addr addr;
5325 int ret;
5326 struct ospf_if_params *params;
5327
5328 params = IF_DEF_PARAMS (ifp);
5329 seconds = strtol (argv[0], NULL, 10);
5330
5331 /* Transmit Delay range is <1-65535>. */
5332 if (seconds < 1 || seconds > 65535)
5333 {
5334 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5335 return CMD_WARNING;
5336 }
5337
5338 if (argc == 2)
5339 {
5340 ret = inet_aton(argv[1], &addr);
5341 if (!ret)
5342 {
5343 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5344 VTY_NEWLINE);
5345 return CMD_WARNING;
5346 }
5347
5348 params = ospf_get_if_params (ifp, addr);
5349 ospf_if_update_params (ifp, addr);
5350 }
5351
5352 SET_IF_PARAM (params, transmit_delay);
5353 params->transmit_delay = seconds;
5354
5355 return CMD_SUCCESS;
5356}
5357
5358ALIAS (ip_ospf_transmit_delay,
5359 ip_ospf_transmit_delay_cmd,
5360 "ip ospf transmit-delay <1-65535>",
5361 "IP Information\n"
5362 "OSPF interface commands\n"
5363 "Link state transmit delay\n"
5364 "Seconds\n")
5365
5366ALIAS (ip_ospf_transmit_delay,
5367 ospf_transmit_delay_cmd,
5368 "ospf transmit-delay <1-65535>",
5369 "OSPF interface commands\n"
5370 "Link state transmit delay\n"
5371 "Seconds\n")
5372
5373DEFUN (no_ip_ospf_transmit_delay,
5374 no_ip_ospf_transmit_delay_addr_cmd,
5375 "no ip ospf transmit-delay A.B.C.D",
5376 NO_STR
5377 "IP Information\n"
5378 "OSPF interface commands\n"
5379 "Link state transmit delay\n"
5380 "Address of interface")
5381{
5382 struct interface *ifp = vty->index;
5383 struct in_addr addr;
5384 int ret;
5385 struct ospf_if_params *params;
5386
5387 ifp = vty->index;
5388 params = IF_DEF_PARAMS (ifp);
5389
5390 if (argc == 1)
5391 {
5392 ret = inet_aton(argv[0], &addr);
5393 if (!ret)
5394 {
5395 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5396 VTY_NEWLINE);
5397 return CMD_WARNING;
5398 }
5399
5400 params = ospf_lookup_if_params (ifp, addr);
5401 if (params == NULL)
5402 return CMD_SUCCESS;
5403 }
5404
5405 UNSET_IF_PARAM (params, transmit_delay);
5406 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5407
5408 if (params != IF_DEF_PARAMS (ifp))
5409 {
5410 ospf_free_if_params (ifp, addr);
5411 ospf_if_update_params (ifp, addr);
5412 }
5413
5414 return CMD_SUCCESS;
5415}
5416
5417ALIAS (no_ip_ospf_transmit_delay,
5418 no_ip_ospf_transmit_delay_cmd,
5419 "no ip ospf transmit-delay",
5420 NO_STR
5421 "IP Information\n"
5422 "OSPF interface commands\n"
5423 "Link state transmit delay\n")
5424
5425ALIAS (no_ip_ospf_transmit_delay,
5426 no_ospf_transmit_delay_cmd,
5427 "no ospf transmit-delay",
5428 NO_STR
5429 "OSPF interface commands\n"
5430 "Link state transmit delay\n")
5431
5432
5433DEFUN (ospf_redistribute_source_metric_type,
5434 ospf_redistribute_source_metric_type_routemap_cmd,
5435 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5436 "Redistribute information from another routing protocol\n"
5437 "Kernel routes\n"
5438 "Connected\n"
5439 "Static routes\n"
5440 "Routing Information Protocol (RIP)\n"
5441 "Border Gateway Protocol (BGP)\n"
5442 "Metric for redistributed routes\n"
5443 "OSPF default metric\n"
5444 "OSPF exterior metric type for redistributed routes\n"
5445 "Set OSPF External Type 1 metrics\n"
5446 "Set OSPF External Type 2 metrics\n"
5447 "Route map reference\n"
5448 "Pointer to route-map entries\n")
5449{
paul020709f2003-04-04 02:44:16 +00005450 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005451 int source;
5452 int type = -1;
5453 int metric = -1;
5454
5455 /* Get distribute source. */
5456 if (!str2distribute_source (argv[0], &source))
5457 return CMD_WARNING;
5458
5459 /* Get metric value. */
5460 if (argc >= 2)
5461 if (!str2metric (argv[1], &metric))
5462 return CMD_WARNING;
5463
5464 /* Get metric type. */
5465 if (argc >= 3)
5466 if (!str2metric_type (argv[2], &type))
5467 return CMD_WARNING;
5468
5469 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005470 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005471 else
paul020709f2003-04-04 02:44:16 +00005472 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005473
paul020709f2003-04-04 02:44:16 +00005474 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005475}
5476
5477ALIAS (ospf_redistribute_source_metric_type,
5478 ospf_redistribute_source_metric_type_cmd,
5479 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5480 "Redistribute information from another routing protocol\n"
5481 "Kernel routes\n"
5482 "Connected\n"
5483 "Static routes\n"
5484 "Routing Information Protocol (RIP)\n"
5485 "Border Gateway Protocol (BGP)\n"
5486 "Metric for redistributed routes\n"
5487 "OSPF default metric\n"
5488 "OSPF exterior metric type for redistributed routes\n"
5489 "Set OSPF External Type 1 metrics\n"
5490 "Set OSPF External Type 2 metrics\n")
5491
5492ALIAS (ospf_redistribute_source_metric_type,
5493 ospf_redistribute_source_metric_cmd,
5494 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5495 "Redistribute information from another routing protocol\n"
5496 "Kernel routes\n"
5497 "Connected\n"
5498 "Static routes\n"
5499 "Routing Information Protocol (RIP)\n"
5500 "Border Gateway Protocol (BGP)\n"
5501 "Metric for redistributed routes\n"
5502 "OSPF default metric\n")
5503
5504DEFUN (ospf_redistribute_source_type_metric,
5505 ospf_redistribute_source_type_metric_routemap_cmd,
5506 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5507 "Redistribute information from another routing protocol\n"
5508 "Kernel routes\n"
5509 "Connected\n"
5510 "Static routes\n"
5511 "Routing Information Protocol (RIP)\n"
5512 "Border Gateway Protocol (BGP)\n"
5513 "OSPF exterior metric type for redistributed routes\n"
5514 "Set OSPF External Type 1 metrics\n"
5515 "Set OSPF External Type 2 metrics\n"
5516 "Metric for redistributed routes\n"
5517 "OSPF default metric\n"
5518 "Route map reference\n"
5519 "Pointer to route-map entries\n")
5520{
paul020709f2003-04-04 02:44:16 +00005521 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005522 int source;
5523 int type = -1;
5524 int metric = -1;
5525
5526 /* Get distribute source. */
5527 if (!str2distribute_source (argv[0], &source))
5528 return CMD_WARNING;
5529
5530 /* Get metric value. */
5531 if (argc >= 2)
5532 if (!str2metric_type (argv[1], &type))
5533 return CMD_WARNING;
5534
5535 /* Get metric type. */
5536 if (argc >= 3)
5537 if (!str2metric (argv[2], &metric))
5538 return CMD_WARNING;
5539
5540 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005541 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005542 else
paul020709f2003-04-04 02:44:16 +00005543 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005544
paul020709f2003-04-04 02:44:16 +00005545 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005546}
5547
5548ALIAS (ospf_redistribute_source_type_metric,
5549 ospf_redistribute_source_type_metric_cmd,
5550 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5551 "Redistribute information from another routing protocol\n"
5552 "Kernel routes\n"
5553 "Connected\n"
5554 "Static routes\n"
5555 "Routing Information Protocol (RIP)\n"
5556 "Border Gateway Protocol (BGP)\n"
5557 "OSPF exterior metric type for redistributed routes\n"
5558 "Set OSPF External Type 1 metrics\n"
5559 "Set OSPF External Type 2 metrics\n"
5560 "Metric for redistributed routes\n"
5561 "OSPF default metric\n")
5562
5563ALIAS (ospf_redistribute_source_type_metric,
5564 ospf_redistribute_source_type_cmd,
5565 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5566 "Redistribute information from another routing protocol\n"
5567 "Kernel routes\n"
5568 "Connected\n"
5569 "Static routes\n"
5570 "Routing Information Protocol (RIP)\n"
5571 "Border Gateway Protocol (BGP)\n"
5572 "OSPF exterior metric type for redistributed routes\n"
5573 "Set OSPF External Type 1 metrics\n"
5574 "Set OSPF External Type 2 metrics\n")
5575
5576ALIAS (ospf_redistribute_source_type_metric,
5577 ospf_redistribute_source_cmd,
5578 "redistribute (kernel|connected|static|rip|bgp)",
5579 "Redistribute information from another routing protocol\n"
5580 "Kernel routes\n"
5581 "Connected\n"
5582 "Static routes\n"
5583 "Routing Information Protocol (RIP)\n"
5584 "Border Gateway Protocol (BGP)\n")
5585
5586DEFUN (ospf_redistribute_source_metric_routemap,
5587 ospf_redistribute_source_metric_routemap_cmd,
5588 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5589 "Redistribute information from another routing protocol\n"
5590 "Kernel routes\n"
5591 "Connected\n"
5592 "Static routes\n"
5593 "Routing Information Protocol (RIP)\n"
5594 "Border Gateway Protocol (BGP)\n"
5595 "Metric for redistributed routes\n"
5596 "OSPF default metric\n"
5597 "Route map reference\n"
5598 "Pointer to route-map entries\n")
5599{
paul020709f2003-04-04 02:44:16 +00005600 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005601 int source;
5602 int metric = -1;
5603
5604 /* Get distribute source. */
5605 if (!str2distribute_source (argv[0], &source))
5606 return CMD_WARNING;
5607
5608 /* Get metric value. */
5609 if (argc >= 2)
5610 if (!str2metric (argv[1], &metric))
5611 return CMD_WARNING;
5612
5613 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005614 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005615 else
paul020709f2003-04-04 02:44:16 +00005616 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005617
paul020709f2003-04-04 02:44:16 +00005618 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005619}
5620
5621DEFUN (ospf_redistribute_source_type_routemap,
5622 ospf_redistribute_source_type_routemap_cmd,
5623 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5624 "Redistribute information from another routing protocol\n"
5625 "Kernel routes\n"
5626 "Connected\n"
5627 "Static routes\n"
5628 "Routing Information Protocol (RIP)\n"
5629 "Border Gateway Protocol (BGP)\n"
5630 "OSPF exterior metric type for redistributed routes\n"
5631 "Set OSPF External Type 1 metrics\n"
5632 "Set OSPF External Type 2 metrics\n"
5633 "Route map reference\n"
5634 "Pointer to route-map entries\n")
5635{
paul020709f2003-04-04 02:44:16 +00005636 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005637 int source;
5638 int type = -1;
5639
5640 /* Get distribute source. */
5641 if (!str2distribute_source (argv[0], &source))
5642 return CMD_WARNING;
5643
5644 /* Get metric value. */
5645 if (argc >= 2)
5646 if (!str2metric_type (argv[1], &type))
5647 return CMD_WARNING;
5648
5649 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005650 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005651 else
paul020709f2003-04-04 02:44:16 +00005652 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005653
paul020709f2003-04-04 02:44:16 +00005654 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005655}
5656
5657DEFUN (ospf_redistribute_source_routemap,
5658 ospf_redistribute_source_routemap_cmd,
5659 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
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 "Route map reference\n"
5667 "Pointer to route-map entries\n")
5668{
paul020709f2003-04-04 02:44:16 +00005669 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005670 int source;
5671
5672 /* Get distribute source. */
5673 if (!str2distribute_source (argv[0], &source))
5674 return CMD_WARNING;
5675
5676 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005677 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005678 else
paul020709f2003-04-04 02:44:16 +00005679 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005680
paul020709f2003-04-04 02:44:16 +00005681 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005682}
5683
5684DEFUN (no_ospf_redistribute_source,
5685 no_ospf_redistribute_source_cmd,
5686 "no redistribute (kernel|connected|static|rip|bgp)",
5687 NO_STR
5688 "Redistribute information from another routing protocol\n"
5689 "Kernel routes\n"
5690 "Connected\n"
5691 "Static routes\n"
5692 "Routing Information Protocol (RIP)\n"
5693 "Border Gateway Protocol (BGP)\n")
5694{
paul020709f2003-04-04 02:44:16 +00005695 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005696 int source;
5697
5698 if (!str2distribute_source (argv[0], &source))
5699 return CMD_WARNING;
5700
paul020709f2003-04-04 02:44:16 +00005701 ospf_routemap_unset (ospf, source);
5702 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005703}
5704
5705DEFUN (ospf_distribute_list_out,
5706 ospf_distribute_list_out_cmd,
5707 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5708 "Filter networks in routing updates\n"
5709 "Access-list name\n"
5710 OUT_STR
5711 "Kernel routes\n"
5712 "Connected\n"
5713 "Static routes\n"
5714 "Routing Information Protocol (RIP)\n"
5715 "Border Gateway Protocol (BGP)\n")
5716{
paul68980082003-03-25 05:07:42 +00005717 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005718 int source;
5719
5720 /* Get distribute source. */
5721 if (!str2distribute_source (argv[1], &source))
5722 return CMD_WARNING;
5723
paul68980082003-03-25 05:07:42 +00005724 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005725}
5726
5727DEFUN (no_ospf_distribute_list_out,
5728 no_ospf_distribute_list_out_cmd,
5729 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5730 NO_STR
5731 "Filter networks in routing updates\n"
5732 "Access-list name\n"
5733 OUT_STR
5734 "Kernel routes\n"
5735 "Connected\n"
5736 "Static routes\n"
5737 "Routing Information Protocol (RIP)\n"
5738 "Border Gateway Protocol (BGP)\n")
5739{
paul68980082003-03-25 05:07:42 +00005740 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005741 int source;
5742
5743 if (!str2distribute_source (argv[1], &source))
5744 return CMD_WARNING;
5745
paul68980082003-03-25 05:07:42 +00005746 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005747}
5748
5749/* Default information originate. */
5750DEFUN (ospf_default_information_originate_metric_type_routemap,
5751 ospf_default_information_originate_metric_type_routemap_cmd,
5752 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5753 "Control distribution of default information\n"
5754 "Distribute a default route\n"
5755 "OSPF default metric\n"
5756 "OSPF metric\n"
5757 "OSPF metric type for default routes\n"
5758 "Set OSPF External Type 1 metrics\n"
5759 "Set OSPF External Type 2 metrics\n"
5760 "Route map reference\n"
5761 "Pointer to route-map entries\n")
5762{
paul020709f2003-04-04 02:44:16 +00005763 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005764 int type = -1;
5765 int metric = -1;
5766
5767 /* Get metric value. */
5768 if (argc >= 1)
5769 if (!str2metric (argv[0], &metric))
5770 return CMD_WARNING;
5771
5772 /* Get metric type. */
5773 if (argc >= 2)
5774 if (!str2metric_type (argv[1], &type))
5775 return CMD_WARNING;
5776
5777 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005778 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005779 else
paul020709f2003-04-04 02:44:16 +00005780 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005781
paul020709f2003-04-04 02:44:16 +00005782 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5783 type, metric);
paul718e3742002-12-13 20:15:29 +00005784}
5785
5786ALIAS (ospf_default_information_originate_metric_type_routemap,
5787 ospf_default_information_originate_metric_type_cmd,
5788 "default-information originate metric <0-16777214> metric-type (1|2)",
5789 "Control distribution of default information\n"
5790 "Distribute a default route\n"
5791 "OSPF default metric\n"
5792 "OSPF metric\n"
5793 "OSPF metric type for default routes\n"
5794 "Set OSPF External Type 1 metrics\n"
5795 "Set OSPF External Type 2 metrics\n")
5796
5797ALIAS (ospf_default_information_originate_metric_type_routemap,
5798 ospf_default_information_originate_metric_cmd,
5799 "default-information originate metric <0-16777214>",
5800 "Control distribution of default information\n"
5801 "Distribute a default route\n"
5802 "OSPF default metric\n"
5803 "OSPF metric\n")
5804
5805ALIAS (ospf_default_information_originate_metric_type_routemap,
5806 ospf_default_information_originate_cmd,
5807 "default-information originate",
5808 "Control distribution of default information\n"
5809 "Distribute a default route\n")
5810
5811/* Default information originate. */
5812DEFUN (ospf_default_information_originate_metric_routemap,
5813 ospf_default_information_originate_metric_routemap_cmd,
5814 "default-information originate metric <0-16777214> route-map WORD",
5815 "Control distribution of default information\n"
5816 "Distribute a default route\n"
5817 "OSPF default metric\n"
5818 "OSPF metric\n"
5819 "Route map reference\n"
5820 "Pointer to route-map entries\n")
5821{
paul020709f2003-04-04 02:44:16 +00005822 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005823 int metric = -1;
5824
5825 /* Get metric value. */
5826 if (argc >= 1)
5827 if (!str2metric (argv[0], &metric))
5828 return CMD_WARNING;
5829
5830 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005831 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005832 else
paul020709f2003-04-04 02:44:16 +00005833 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005834
paul020709f2003-04-04 02:44:16 +00005835 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5836 -1, metric);
paul718e3742002-12-13 20:15:29 +00005837}
5838
5839/* Default information originate. */
5840DEFUN (ospf_default_information_originate_routemap,
5841 ospf_default_information_originate_routemap_cmd,
5842 "default-information originate route-map WORD",
5843 "Control distribution of default information\n"
5844 "Distribute a default route\n"
5845 "Route map reference\n"
5846 "Pointer to route-map entries\n")
5847{
paul020709f2003-04-04 02:44:16 +00005848 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005849
paul020709f2003-04-04 02:44:16 +00005850 if (argc == 1)
5851 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5852 else
5853 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5854
5855 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005856}
5857
5858DEFUN (ospf_default_information_originate_type_metric_routemap,
5859 ospf_default_information_originate_type_metric_routemap_cmd,
5860 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5861 "Control distribution of default information\n"
5862 "Distribute a default route\n"
5863 "OSPF metric type for default routes\n"
5864 "Set OSPF External Type 1 metrics\n"
5865 "Set OSPF External Type 2 metrics\n"
5866 "OSPF default metric\n"
5867 "OSPF metric\n"
5868 "Route map reference\n"
5869 "Pointer to route-map entries\n")
5870{
paul020709f2003-04-04 02:44:16 +00005871 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005872 int type = -1;
5873 int metric = -1;
5874
5875 /* Get metric type. */
5876 if (argc >= 1)
5877 if (!str2metric_type (argv[0], &type))
5878 return CMD_WARNING;
5879
5880 /* Get metric value. */
5881 if (argc >= 2)
5882 if (!str2metric (argv[1], &metric))
5883 return CMD_WARNING;
5884
5885 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005886 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005887 else
paul020709f2003-04-04 02:44:16 +00005888 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005889
paul020709f2003-04-04 02:44:16 +00005890 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5891 type, metric);
paul718e3742002-12-13 20:15:29 +00005892}
5893
5894ALIAS (ospf_default_information_originate_type_metric_routemap,
5895 ospf_default_information_originate_type_metric_cmd,
5896 "default-information originate metric-type (1|2) metric <0-16777214>",
5897 "Control distribution of default information\n"
5898 "Distribute a default route\n"
5899 "OSPF metric type for default routes\n"
5900 "Set OSPF External Type 1 metrics\n"
5901 "Set OSPF External Type 2 metrics\n"
5902 "OSPF default metric\n"
5903 "OSPF metric\n")
5904
5905ALIAS (ospf_default_information_originate_type_metric_routemap,
5906 ospf_default_information_originate_type_cmd,
5907 "default-information originate metric-type (1|2)",
5908 "Control distribution of default information\n"
5909 "Distribute a default route\n"
5910 "OSPF metric type for default routes\n"
5911 "Set OSPF External Type 1 metrics\n"
5912 "Set OSPF External Type 2 metrics\n")
5913
5914DEFUN (ospf_default_information_originate_type_routemap,
5915 ospf_default_information_originate_type_routemap_cmd,
5916 "default-information originate metric-type (1|2) route-map WORD",
5917 "Control distribution of default information\n"
5918 "Distribute a default route\n"
5919 "OSPF metric type for default routes\n"
5920 "Set OSPF External Type 1 metrics\n"
5921 "Set OSPF External Type 2 metrics\n"
5922 "Route map reference\n"
5923 "Pointer to route-map entries\n")
5924{
paul020709f2003-04-04 02:44:16 +00005925 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005926 int type = -1;
5927
5928 /* Get metric type. */
5929 if (argc >= 1)
5930 if (!str2metric_type (argv[0], &type))
5931 return CMD_WARNING;
5932
5933 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005934 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005935 else
paul020709f2003-04-04 02:44:16 +00005936 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005937
paul020709f2003-04-04 02:44:16 +00005938 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5939 type, -1);
paul718e3742002-12-13 20:15:29 +00005940}
5941
5942DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5943 ospf_default_information_originate_always_metric_type_routemap_cmd,
5944 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5945 "Control distribution of default information\n"
5946 "Distribute a default route\n"
5947 "Always advertise default route\n"
5948 "OSPF default metric\n"
5949 "OSPF metric\n"
5950 "OSPF metric type for default routes\n"
5951 "Set OSPF External Type 1 metrics\n"
5952 "Set OSPF External Type 2 metrics\n"
5953 "Route map reference\n"
5954 "Pointer to route-map entries\n")
5955{
paul020709f2003-04-04 02:44:16 +00005956 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005957 int type = -1;
5958 int metric = -1;
5959
5960 /* Get metric value. */
5961 if (argc >= 1)
5962 if (!str2metric (argv[0], &metric))
5963 return CMD_WARNING;
5964
5965 /* Get metric type. */
5966 if (argc >= 2)
5967 if (!str2metric_type (argv[1], &type))
5968 return CMD_WARNING;
5969
5970 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005971 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005972 else
paul020709f2003-04-04 02:44:16 +00005973 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005974
paul020709f2003-04-04 02:44:16 +00005975 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005976 type, metric);
5977}
5978
5979ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5980 ospf_default_information_originate_always_metric_type_cmd,
5981 "default-information originate always metric <0-16777214> metric-type (1|2)",
5982 "Control distribution of default information\n"
5983 "Distribute a default route\n"
5984 "Always advertise default route\n"
5985 "OSPF default metric\n"
5986 "OSPF metric\n"
5987 "OSPF metric type for default routes\n"
5988 "Set OSPF External Type 1 metrics\n"
5989 "Set OSPF External Type 2 metrics\n")
5990
5991ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5992 ospf_default_information_originate_always_metric_cmd,
5993 "default-information originate always metric <0-16777214>",
5994 "Control distribution of default information\n"
5995 "Distribute a default route\n"
5996 "Always advertise default route\n"
5997 "OSPF default metric\n"
5998 "OSPF metric\n"
5999 "OSPF metric type for default routes\n")
6000
6001ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6002 ospf_default_information_originate_always_cmd,
6003 "default-information originate always",
6004 "Control distribution of default information\n"
6005 "Distribute a default route\n"
6006 "Always advertise default route\n")
6007
6008DEFUN (ospf_default_information_originate_always_metric_routemap,
6009 ospf_default_information_originate_always_metric_routemap_cmd,
6010 "default-information originate always metric <0-16777214> route-map WORD",
6011 "Control distribution of default information\n"
6012 "Distribute a default route\n"
6013 "Always advertise default route\n"
6014 "OSPF default metric\n"
6015 "OSPF metric\n"
6016 "Route map reference\n"
6017 "Pointer to route-map entries\n")
6018{
paul020709f2003-04-04 02:44:16 +00006019 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006020 int metric = -1;
6021
6022 /* Get metric value. */
6023 if (argc >= 1)
6024 if (!str2metric (argv[0], &metric))
6025 return CMD_WARNING;
6026
6027 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006028 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006029 else
paul020709f2003-04-04 02:44:16 +00006030 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006031
paul020709f2003-04-04 02:44:16 +00006032 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6033 -1, metric);
paul718e3742002-12-13 20:15:29 +00006034}
6035
6036DEFUN (ospf_default_information_originate_always_routemap,
6037 ospf_default_information_originate_always_routemap_cmd,
6038 "default-information originate always route-map WORD",
6039 "Control distribution of default information\n"
6040 "Distribute a default route\n"
6041 "Always advertise default route\n"
6042 "Route map reference\n"
6043 "Pointer to route-map entries\n")
6044{
paul020709f2003-04-04 02:44:16 +00006045 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006046
paul020709f2003-04-04 02:44:16 +00006047 if (argc == 1)
6048 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6049 else
6050 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6051
6052 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006053}
6054
6055DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6056 ospf_default_information_originate_always_type_metric_routemap_cmd,
6057 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6058 "Control distribution of default information\n"
6059 "Distribute a default route\n"
6060 "Always advertise default route\n"
6061 "OSPF metric type for default routes\n"
6062 "Set OSPF External Type 1 metrics\n"
6063 "Set OSPF External Type 2 metrics\n"
6064 "OSPF default metric\n"
6065 "OSPF metric\n"
6066 "Route map reference\n"
6067 "Pointer to route-map entries\n")
6068{
paul020709f2003-04-04 02:44:16 +00006069 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006070 int type = -1;
6071 int metric = -1;
6072
6073 /* Get metric type. */
6074 if (argc >= 1)
6075 if (!str2metric_type (argv[0], &type))
6076 return CMD_WARNING;
6077
6078 /* Get metric value. */
6079 if (argc >= 2)
6080 if (!str2metric (argv[1], &metric))
6081 return CMD_WARNING;
6082
6083 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006084 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006085 else
paul020709f2003-04-04 02:44:16 +00006086 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006087
paul020709f2003-04-04 02:44:16 +00006088 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006089 type, metric);
6090}
6091
6092ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6093 ospf_default_information_originate_always_type_metric_cmd,
6094 "default-information originate always metric-type (1|2) metric <0-16777214>",
6095 "Control distribution of default information\n"
6096 "Distribute a default route\n"
6097 "Always advertise default route\n"
6098 "OSPF metric type for default routes\n"
6099 "Set OSPF External Type 1 metrics\n"
6100 "Set OSPF External Type 2 metrics\n"
6101 "OSPF default metric\n"
6102 "OSPF metric\n")
6103
6104ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6105 ospf_default_information_originate_always_type_cmd,
6106 "default-information originate always metric-type (1|2)",
6107 "Control distribution of default information\n"
6108 "Distribute a default route\n"
6109 "Always advertise default route\n"
6110 "OSPF metric type for default routes\n"
6111 "Set OSPF External Type 1 metrics\n"
6112 "Set OSPF External Type 2 metrics\n")
6113
6114DEFUN (ospf_default_information_originate_always_type_routemap,
6115 ospf_default_information_originate_always_type_routemap_cmd,
6116 "default-information originate always metric-type (1|2) route-map WORD",
6117 "Control distribution of default information\n"
6118 "Distribute a default route\n"
6119 "Always advertise default route\n"
6120 "OSPF metric type for default routes\n"
6121 "Set OSPF External Type 1 metrics\n"
6122 "Set OSPF External Type 2 metrics\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 int type = -1;
6128
6129 /* Get metric type. */
6130 if (argc >= 1)
6131 if (!str2metric_type (argv[0], &type))
6132 return CMD_WARNING;
6133
6134 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006135 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006136 else
paul020709f2003-04-04 02:44:16 +00006137 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006138
paul020709f2003-04-04 02:44:16 +00006139 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006140 type, -1);
6141}
6142
6143DEFUN (no_ospf_default_information_originate,
6144 no_ospf_default_information_originate_cmd,
6145 "no default-information originate",
6146 NO_STR
6147 "Control distribution of default information\n"
6148 "Distribute a default route\n")
6149{
paul68980082003-03-25 05:07:42 +00006150 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006151 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006152
6153 p.family = AF_INET;
6154 p.prefix.s_addr = 0;
6155 p.prefixlen = 0;
6156
ajs5339cfd2005-09-19 13:28:05 +00006157 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006158
6159 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6160 ospf_external_info_delete (DEFAULT_ROUTE, p);
6161 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6162 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6163 }
6164
paul020709f2003-04-04 02:44:16 +00006165 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6166 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006167}
6168
6169DEFUN (ospf_default_metric,
6170 ospf_default_metric_cmd,
6171 "default-metric <0-16777214>",
6172 "Set metric of redistributed routes\n"
6173 "Default metric\n")
6174{
paul68980082003-03-25 05:07:42 +00006175 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006176 int metric = -1;
6177
6178 if (!str2metric (argv[0], &metric))
6179 return CMD_WARNING;
6180
paul68980082003-03-25 05:07:42 +00006181 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006182
6183 return CMD_SUCCESS;
6184}
6185
6186DEFUN (no_ospf_default_metric,
6187 no_ospf_default_metric_cmd,
6188 "no default-metric",
6189 NO_STR
6190 "Set metric of redistributed routes\n")
6191{
paul68980082003-03-25 05:07:42 +00006192 struct ospf *ospf = vty->index;
6193
6194 ospf->default_metric = -1;
6195
paul718e3742002-12-13 20:15:29 +00006196 return CMD_SUCCESS;
6197}
6198
6199ALIAS (no_ospf_default_metric,
6200 no_ospf_default_metric_val_cmd,
6201 "no default-metric <0-16777214>",
6202 NO_STR
6203 "Set metric of redistributed routes\n"
6204 "Default metric\n")
6205
6206DEFUN (ospf_distance,
6207 ospf_distance_cmd,
6208 "distance <1-255>",
6209 "Define an administrative distance\n"
6210 "OSPF Administrative distance\n")
6211{
paul68980082003-03-25 05:07:42 +00006212 struct ospf *ospf = vty->index;
6213
6214 ospf->distance_all = atoi (argv[0]);
6215
paul718e3742002-12-13 20:15:29 +00006216 return CMD_SUCCESS;
6217}
6218
6219DEFUN (no_ospf_distance,
6220 no_ospf_distance_cmd,
6221 "no distance <1-255>",
6222 NO_STR
6223 "Define an administrative distance\n"
6224 "OSPF Administrative distance\n")
6225{
paul68980082003-03-25 05:07:42 +00006226 struct ospf *ospf = vty->index;
6227
6228 ospf->distance_all = 0;
6229
paul718e3742002-12-13 20:15:29 +00006230 return CMD_SUCCESS;
6231}
6232
6233DEFUN (no_ospf_distance_ospf,
6234 no_ospf_distance_ospf_cmd,
6235 "no distance ospf",
6236 NO_STR
6237 "Define an administrative distance\n"
6238 "OSPF Administrative distance\n"
6239 "OSPF Distance\n")
6240{
paul68980082003-03-25 05:07:42 +00006241 struct ospf *ospf = vty->index;
6242
6243 ospf->distance_intra = 0;
6244 ospf->distance_inter = 0;
6245 ospf->distance_external = 0;
6246
paul718e3742002-12-13 20:15:29 +00006247 return CMD_SUCCESS;
6248}
6249
6250DEFUN (ospf_distance_ospf_intra,
6251 ospf_distance_ospf_intra_cmd,
6252 "distance ospf intra-area <1-255>",
6253 "Define an administrative distance\n"
6254 "OSPF Administrative distance\n"
6255 "Intra-area routes\n"
6256 "Distance for intra-area routes\n")
6257{
paul68980082003-03-25 05:07:42 +00006258 struct ospf *ospf = vty->index;
6259
6260 ospf->distance_intra = atoi (argv[0]);
6261
paul718e3742002-12-13 20:15:29 +00006262 return CMD_SUCCESS;
6263}
6264
6265DEFUN (ospf_distance_ospf_intra_inter,
6266 ospf_distance_ospf_intra_inter_cmd,
6267 "distance ospf intra-area <1-255> inter-area <1-255>",
6268 "Define an administrative distance\n"
6269 "OSPF Administrative distance\n"
6270 "Intra-area routes\n"
6271 "Distance for intra-area routes\n"
6272 "Inter-area routes\n"
6273 "Distance for inter-area routes\n")
6274{
paul68980082003-03-25 05:07:42 +00006275 struct ospf *ospf = vty->index;
6276
6277 ospf->distance_intra = atoi (argv[0]);
6278 ospf->distance_inter = atoi (argv[1]);
6279
paul718e3742002-12-13 20:15:29 +00006280 return CMD_SUCCESS;
6281}
6282
6283DEFUN (ospf_distance_ospf_intra_external,
6284 ospf_distance_ospf_intra_external_cmd,
6285 "distance ospf intra-area <1-255> external <1-255>",
6286 "Define an administrative distance\n"
6287 "OSPF Administrative distance\n"
6288 "Intra-area routes\n"
6289 "Distance for intra-area routes\n"
6290 "External routes\n"
6291 "Distance for external routes\n")
6292{
paul68980082003-03-25 05:07:42 +00006293 struct ospf *ospf = vty->index;
6294
6295 ospf->distance_intra = atoi (argv[0]);
6296 ospf->distance_external = atoi (argv[1]);
6297
paul718e3742002-12-13 20:15:29 +00006298 return CMD_SUCCESS;
6299}
6300
6301DEFUN (ospf_distance_ospf_intra_inter_external,
6302 ospf_distance_ospf_intra_inter_external_cmd,
6303 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6304 "Define an administrative distance\n"
6305 "OSPF Administrative distance\n"
6306 "Intra-area routes\n"
6307 "Distance for intra-area routes\n"
6308 "Inter-area routes\n"
6309 "Distance for inter-area routes\n"
6310 "External routes\n"
6311 "Distance for external routes\n")
6312{
paul68980082003-03-25 05:07:42 +00006313 struct ospf *ospf = vty->index;
6314
6315 ospf->distance_intra = atoi (argv[0]);
6316 ospf->distance_inter = atoi (argv[1]);
6317 ospf->distance_external = atoi (argv[2]);
6318
paul718e3742002-12-13 20:15:29 +00006319 return CMD_SUCCESS;
6320}
6321
6322DEFUN (ospf_distance_ospf_intra_external_inter,
6323 ospf_distance_ospf_intra_external_inter_cmd,
6324 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6325 "Define an administrative distance\n"
6326 "OSPF Administrative distance\n"
6327 "Intra-area routes\n"
6328 "Distance for intra-area routes\n"
6329 "External routes\n"
6330 "Distance for external routes\n"
6331 "Inter-area routes\n"
6332 "Distance for inter-area routes\n")
6333{
paul68980082003-03-25 05:07:42 +00006334 struct ospf *ospf = vty->index;
6335
6336 ospf->distance_intra = atoi (argv[0]);
6337 ospf->distance_external = atoi (argv[1]);
6338 ospf->distance_inter = atoi (argv[2]);
6339
paul718e3742002-12-13 20:15:29 +00006340 return CMD_SUCCESS;
6341}
6342
6343DEFUN (ospf_distance_ospf_inter,
6344 ospf_distance_ospf_inter_cmd,
6345 "distance ospf inter-area <1-255>",
6346 "Define an administrative distance\n"
6347 "OSPF Administrative distance\n"
6348 "Inter-area routes\n"
6349 "Distance for inter-area routes\n")
6350{
paul68980082003-03-25 05:07:42 +00006351 struct ospf *ospf = vty->index;
6352
6353 ospf->distance_inter = atoi (argv[0]);
6354
paul718e3742002-12-13 20:15:29 +00006355 return CMD_SUCCESS;
6356}
6357
6358DEFUN (ospf_distance_ospf_inter_intra,
6359 ospf_distance_ospf_inter_intra_cmd,
6360 "distance ospf inter-area <1-255> intra-area <1-255>",
6361 "Define an administrative distance\n"
6362 "OSPF Administrative distance\n"
6363 "Inter-area routes\n"
6364 "Distance for inter-area routes\n"
6365 "Intra-area routes\n"
6366 "Distance for intra-area routes\n")
6367{
paul68980082003-03-25 05:07:42 +00006368 struct ospf *ospf = vty->index;
6369
6370 ospf->distance_inter = atoi (argv[0]);
6371 ospf->distance_intra = atoi (argv[1]);
6372
paul718e3742002-12-13 20:15:29 +00006373 return CMD_SUCCESS;
6374}
6375
6376DEFUN (ospf_distance_ospf_inter_external,
6377 ospf_distance_ospf_inter_external_cmd,
6378 "distance ospf inter-area <1-255> external <1-255>",
6379 "Define an administrative distance\n"
6380 "OSPF Administrative distance\n"
6381 "Inter-area routes\n"
6382 "Distance for inter-area routes\n"
6383 "External routes\n"
6384 "Distance for external routes\n")
6385{
paul68980082003-03-25 05:07:42 +00006386 struct ospf *ospf = vty->index;
6387
6388 ospf->distance_inter = atoi (argv[0]);
6389 ospf->distance_external = atoi (argv[1]);
6390
paul718e3742002-12-13 20:15:29 +00006391 return CMD_SUCCESS;
6392}
6393
6394DEFUN (ospf_distance_ospf_inter_intra_external,
6395 ospf_distance_ospf_inter_intra_external_cmd,
6396 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6397 "Define an administrative distance\n"
6398 "OSPF Administrative distance\n"
6399 "Inter-area routes\n"
6400 "Distance for inter-area routes\n"
6401 "Intra-area routes\n"
6402 "Distance for intra-area routes\n"
6403 "External routes\n"
6404 "Distance for external routes\n")
6405{
paul68980082003-03-25 05:07:42 +00006406 struct ospf *ospf = vty->index;
6407
6408 ospf->distance_inter = atoi (argv[0]);
6409 ospf->distance_intra = atoi (argv[1]);
6410 ospf->distance_external = atoi (argv[2]);
6411
paul718e3742002-12-13 20:15:29 +00006412 return CMD_SUCCESS;
6413}
6414
6415DEFUN (ospf_distance_ospf_inter_external_intra,
6416 ospf_distance_ospf_inter_external_intra_cmd,
6417 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6418 "Define an administrative distance\n"
6419 "OSPF Administrative distance\n"
6420 "Inter-area routes\n"
6421 "Distance for inter-area routes\n"
6422 "External routes\n"
6423 "Distance for external routes\n"
6424 "Intra-area routes\n"
6425 "Distance for intra-area routes\n")
6426{
paul68980082003-03-25 05:07:42 +00006427 struct ospf *ospf = vty->index;
6428
6429 ospf->distance_inter = atoi (argv[0]);
6430 ospf->distance_external = atoi (argv[1]);
6431 ospf->distance_intra = atoi (argv[2]);
6432
paul718e3742002-12-13 20:15:29 +00006433 return CMD_SUCCESS;
6434}
6435
6436DEFUN (ospf_distance_ospf_external,
6437 ospf_distance_ospf_external_cmd,
6438 "distance ospf external <1-255>",
6439 "Define an administrative distance\n"
6440 "OSPF Administrative distance\n"
6441 "External routes\n"
6442 "Distance for external routes\n")
6443{
paul68980082003-03-25 05:07:42 +00006444 struct ospf *ospf = vty->index;
6445
6446 ospf->distance_external = atoi (argv[0]);
6447
paul718e3742002-12-13 20:15:29 +00006448 return CMD_SUCCESS;
6449}
6450
6451DEFUN (ospf_distance_ospf_external_intra,
6452 ospf_distance_ospf_external_intra_cmd,
6453 "distance ospf external <1-255> intra-area <1-255>",
6454 "Define an administrative distance\n"
6455 "OSPF Administrative distance\n"
6456 "External routes\n"
6457 "Distance for external routes\n"
6458 "Intra-area routes\n"
6459 "Distance for intra-area routes\n")
6460{
paul68980082003-03-25 05:07:42 +00006461 struct ospf *ospf = vty->index;
6462
6463 ospf->distance_external = atoi (argv[0]);
6464 ospf->distance_intra = atoi (argv[1]);
6465
paul718e3742002-12-13 20:15:29 +00006466 return CMD_SUCCESS;
6467}
6468
6469DEFUN (ospf_distance_ospf_external_inter,
6470 ospf_distance_ospf_external_inter_cmd,
6471 "distance ospf external <1-255> inter-area <1-255>",
6472 "Define an administrative distance\n"
6473 "OSPF Administrative distance\n"
6474 "External routes\n"
6475 "Distance for external routes\n"
6476 "Inter-area routes\n"
6477 "Distance for inter-area routes\n")
6478{
paul68980082003-03-25 05:07:42 +00006479 struct ospf *ospf = vty->index;
6480
6481 ospf->distance_external = atoi (argv[0]);
6482 ospf->distance_inter = atoi (argv[1]);
6483
paul718e3742002-12-13 20:15:29 +00006484 return CMD_SUCCESS;
6485}
6486
6487DEFUN (ospf_distance_ospf_external_intra_inter,
6488 ospf_distance_ospf_external_intra_inter_cmd,
6489 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6490 "Define an administrative distance\n"
6491 "OSPF Administrative distance\n"
6492 "External routes\n"
6493 "Distance for external routes\n"
6494 "Intra-area routes\n"
6495 "Distance for intra-area routes\n"
6496 "Inter-area routes\n"
6497 "Distance for inter-area routes\n")
6498{
paul68980082003-03-25 05:07:42 +00006499 struct ospf *ospf = vty->index;
6500
6501 ospf->distance_external = atoi (argv[0]);
6502 ospf->distance_intra = atoi (argv[1]);
6503 ospf->distance_inter = atoi (argv[2]);
6504
paul718e3742002-12-13 20:15:29 +00006505 return CMD_SUCCESS;
6506}
6507
6508DEFUN (ospf_distance_ospf_external_inter_intra,
6509 ospf_distance_ospf_external_inter_intra_cmd,
6510 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6511 "Define an administrative distance\n"
6512 "OSPF Administrative distance\n"
6513 "External routes\n"
6514 "Distance for external routes\n"
6515 "Inter-area routes\n"
6516 "Distance for inter-area routes\n"
6517 "Intra-area routes\n"
6518 "Distance for intra-area routes\n")
6519{
paul68980082003-03-25 05:07:42 +00006520 struct ospf *ospf = vty->index;
6521
6522 ospf->distance_external = atoi (argv[0]);
6523 ospf->distance_inter = atoi (argv[1]);
6524 ospf->distance_intra = atoi (argv[2]);
6525
paul718e3742002-12-13 20:15:29 +00006526 return CMD_SUCCESS;
6527}
6528
6529DEFUN (ospf_distance_source,
6530 ospf_distance_source_cmd,
6531 "distance <1-255> A.B.C.D/M",
6532 "Administrative distance\n"
6533 "Distance value\n"
6534 "IP source prefix\n")
6535{
paul020709f2003-04-04 02:44:16 +00006536 struct ospf *ospf = vty->index;
6537
6538 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006539
paul718e3742002-12-13 20:15:29 +00006540 return CMD_SUCCESS;
6541}
6542
6543DEFUN (no_ospf_distance_source,
6544 no_ospf_distance_source_cmd,
6545 "no distance <1-255> A.B.C.D/M",
6546 NO_STR
6547 "Administrative distance\n"
6548 "Distance value\n"
6549 "IP source prefix\n")
6550{
paul020709f2003-04-04 02:44:16 +00006551 struct ospf *ospf = vty->index;
6552
6553 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6554
paul718e3742002-12-13 20:15:29 +00006555 return CMD_SUCCESS;
6556}
6557
6558DEFUN (ospf_distance_source_access_list,
6559 ospf_distance_source_access_list_cmd,
6560 "distance <1-255> A.B.C.D/M WORD",
6561 "Administrative distance\n"
6562 "Distance value\n"
6563 "IP source prefix\n"
6564 "Access list name\n")
6565{
paul020709f2003-04-04 02:44:16 +00006566 struct ospf *ospf = vty->index;
6567
6568 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6569
paul718e3742002-12-13 20:15:29 +00006570 return CMD_SUCCESS;
6571}
6572
6573DEFUN (no_ospf_distance_source_access_list,
6574 no_ospf_distance_source_access_list_cmd,
6575 "no distance <1-255> A.B.C.D/M WORD",
6576 NO_STR
6577 "Administrative distance\n"
6578 "Distance value\n"
6579 "IP source prefix\n"
6580 "Access list name\n")
6581{
paul020709f2003-04-04 02:44:16 +00006582 struct ospf *ospf = vty->index;
6583
6584 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6585
paul718e3742002-12-13 20:15:29 +00006586 return CMD_SUCCESS;
6587}
6588
vincentba682532005-09-29 13:52:57 +00006589DEFUN (ip_ospf_mtu_ignore,
6590 ip_ospf_mtu_ignore_addr_cmd,
6591 "ip ospf mtu-ignore A.B.C.D",
6592 "IP Information\n"
6593 "OSPF interface commands\n"
6594 "Disable mtu mismatch detection\n"
6595 "Address of interface")
6596{
6597 struct interface *ifp = vty->index;
6598 struct in_addr addr;
6599 int ret;
6600
6601 struct ospf_if_params *params;
6602 params = IF_DEF_PARAMS (ifp);
6603
6604 if (argc == 1)
6605 {
6606 ret = inet_aton(argv[0], &addr);
6607 if (!ret)
6608 {
6609 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6610 VTY_NEWLINE);
6611 return CMD_WARNING;
6612 }
6613 params = ospf_get_if_params (ifp, addr);
6614 ospf_if_update_params (ifp, addr);
6615 }
6616 params->mtu_ignore = 1;
6617 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6618 SET_IF_PARAM (params, mtu_ignore);
6619 else
6620 {
6621 UNSET_IF_PARAM (params, mtu_ignore);
6622 if (params != IF_DEF_PARAMS (ifp))
6623 {
6624 ospf_free_if_params (ifp, addr);
6625 ospf_if_update_params (ifp, addr);
6626 }
6627 }
6628 return CMD_SUCCESS;
6629}
6630
6631ALIAS (ip_ospf_mtu_ignore,
6632 ip_ospf_mtu_ignore_cmd,
6633 "ip ospf mtu-ignore",
6634 "IP Information\n"
6635 "OSPF interface commands\n"
6636 "Disable mtu mismatch detection\n")
6637
6638
6639DEFUN (no_ip_ospf_mtu_ignore,
6640 no_ip_ospf_mtu_ignore_addr_cmd,
6641 "no ip ospf mtu-ignore A.B.C.D",
6642 "IP Information\n"
6643 "OSPF interface commands\n"
6644 "Disable mtu mismatch detection\n"
6645 "Address of interface")
6646{
6647 struct interface *ifp = vty->index;
6648 struct in_addr addr;
6649 int ret;
6650
6651 struct ospf_if_params *params;
6652 params = IF_DEF_PARAMS (ifp);
6653
6654 if (argc == 1)
6655 {
6656 ret = inet_aton(argv[0], &addr);
6657 if (!ret)
6658 {
6659 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6660 VTY_NEWLINE);
6661 return CMD_WARNING;
6662 }
6663 params = ospf_get_if_params (ifp, addr);
6664 ospf_if_update_params (ifp, addr);
6665 }
6666 params->mtu_ignore = 0;
6667 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6668 SET_IF_PARAM (params, mtu_ignore);
6669 else
6670 {
6671 UNSET_IF_PARAM (params, mtu_ignore);
6672 if (params != IF_DEF_PARAMS (ifp))
6673 {
6674 ospf_free_if_params (ifp, addr);
6675 ospf_if_update_params (ifp, addr);
6676 }
6677 }
6678 return CMD_SUCCESS;
6679}
6680
6681ALIAS (no_ip_ospf_mtu_ignore,
6682 no_ip_ospf_mtu_ignore_cmd,
6683 "no ip ospf mtu-ignore",
6684 "IP Information\n"
6685 "OSPF interface commands\n"
6686 "Disable mtu mismatch detection\n")
6687
paul4dadc292005-05-06 21:37:42 +00006688static void
paul718e3742002-12-13 20:15:29 +00006689show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6690{
6691 struct route_node *rn;
6692 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006693 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006694 struct ospf_path *path;
6695
6696 vty_out (vty, "============ OSPF network routing table ============%s",
6697 VTY_NEWLINE);
6698
6699 for (rn = route_top (rt); rn; rn = route_next (rn))
6700 if ((or = rn->info) != NULL)
6701 {
6702 char buf1[19];
6703 snprintf (buf1, 19, "%s/%d",
6704 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6705
6706 switch (or->path_type)
6707 {
6708 case OSPF_PATH_INTER_AREA:
6709 if (or->type == OSPF_DESTINATION_NETWORK)
6710 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6711 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6712 else if (or->type == OSPF_DESTINATION_DISCARD)
6713 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6714 break;
6715 case OSPF_PATH_INTRA_AREA:
6716 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6717 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6718 break;
6719 default:
6720 break;
6721 }
6722
6723 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00006724 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00006725 {
hasso54bedb52005-08-17 13:31:47 +00006726 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00006727 {
6728 if (path->nexthop.s_addr == 0)
6729 vty_out (vty, "%24s directly attached to %s%s",
6730 "", path->oi->ifp->name, VTY_NEWLINE);
6731 else
6732 vty_out (vty, "%24s via %s, %s%s", "",
6733 inet_ntoa (path->nexthop), path->oi->ifp->name,
6734 VTY_NEWLINE);
6735 }
6736 }
paul718e3742002-12-13 20:15:29 +00006737 }
6738 vty_out (vty, "%s", VTY_NEWLINE);
6739}
6740
paul4dadc292005-05-06 21:37:42 +00006741static void
paul718e3742002-12-13 20:15:29 +00006742show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6743{
6744 struct route_node *rn;
6745 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006746 struct listnode *pnode;
6747 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006748 struct ospf_path *path;
6749
6750 vty_out (vty, "============ OSPF router routing table =============%s",
6751 VTY_NEWLINE);
6752 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6753 if (rn->info)
6754 {
6755 int flag = 0;
6756
6757 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6758
paul1eb8ef22005-04-07 07:30:20 +00006759 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
6760 {
6761 if (flag++)
6762 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006763
paul1eb8ef22005-04-07 07:30:20 +00006764 /* Show path. */
6765 vty_out (vty, "%s [%d] area: %s",
6766 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6767 or->cost, inet_ntoa (or->u.std.area_id));
6768 /* Show flags. */
6769 vty_out (vty, "%s%s%s",
6770 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6771 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6772 VTY_NEWLINE);
6773
6774 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
6775 {
hasso54bedb52005-08-17 13:31:47 +00006776 if (path->oi != NULL && ospf_if_exists(path->oi))
6777 {
6778 if (path->nexthop.s_addr == 0)
6779 vty_out (vty, "%24s directly attached to %s%s",
6780 "", path->oi->ifp->name, VTY_NEWLINE);
6781 else
6782 vty_out (vty, "%24s via %s, %s%s", "",
6783 inet_ntoa (path->nexthop),
6784 path->oi->ifp->name, VTY_NEWLINE);
6785 }
paul1eb8ef22005-04-07 07:30:20 +00006786 }
6787 }
paul718e3742002-12-13 20:15:29 +00006788 }
6789 vty_out (vty, "%s", VTY_NEWLINE);
6790}
6791
paul4dadc292005-05-06 21:37:42 +00006792static void
paul718e3742002-12-13 20:15:29 +00006793show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6794{
6795 struct route_node *rn;
6796 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00006797 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006798 struct ospf_path *path;
6799
6800 vty_out (vty, "============ OSPF external routing table ===========%s",
6801 VTY_NEWLINE);
6802 for (rn = route_top (rt); rn; rn = route_next (rn))
6803 if ((er = rn->info) != NULL)
6804 {
6805 char buf1[19];
6806 snprintf (buf1, 19, "%s/%d",
6807 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6808
6809 switch (er->path_type)
6810 {
6811 case OSPF_PATH_TYPE1_EXTERNAL:
6812 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6813 er->cost, er->u.ext.tag, VTY_NEWLINE);
6814 break;
6815 case OSPF_PATH_TYPE2_EXTERNAL:
6816 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6817 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6818 break;
6819 }
6820
paul1eb8ef22005-04-07 07:30:20 +00006821 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00006822 {
hasso54bedb52005-08-17 13:31:47 +00006823 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00006824 {
6825 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006826 vty_out (vty, "%24s directly attached to %s%s",
6827 "", path->oi->ifp->name, VTY_NEWLINE);
6828 else
6829 vty_out (vty, "%24s via %s, %s%s", "",
6830 inet_ntoa (path->nexthop), path->oi->ifp->name,
6831 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006832 }
6833 }
6834 }
6835 vty_out (vty, "%s", VTY_NEWLINE);
6836}
6837
paul718e3742002-12-13 20:15:29 +00006838DEFUN (show_ip_ospf_border_routers,
6839 show_ip_ospf_border_routers_cmd,
6840 "show ip ospf border-routers",
6841 SHOW_STR
6842 IP_STR
6843 "show all the ABR's and ASBR's\n"
6844 "for this area\n")
6845{
paul020709f2003-04-04 02:44:16 +00006846 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006847
paul020709f2003-04-04 02:44:16 +00006848 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006849 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006850 {
6851 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6852 return CMD_SUCCESS;
6853 }
6854
paul68980082003-03-25 05:07:42 +00006855 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006856 {
6857 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6858 return CMD_SUCCESS;
6859 }
6860
6861 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006862 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006863
6864 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006865 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006866
6867 return CMD_SUCCESS;
6868}
paul718e3742002-12-13 20:15:29 +00006869
6870DEFUN (show_ip_ospf_route,
6871 show_ip_ospf_route_cmd,
6872 "show ip ospf route",
6873 SHOW_STR
6874 IP_STR
6875 "OSPF information\n"
6876 "OSPF routing table\n")
6877{
paul020709f2003-04-04 02:44:16 +00006878 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006879
paul020709f2003-04-04 02:44:16 +00006880 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006881 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006882 {
6883 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6884 return CMD_SUCCESS;
6885 }
6886
paul68980082003-03-25 05:07:42 +00006887 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006888 {
6889 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6890 return CMD_SUCCESS;
6891 }
6892
6893 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006894 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006895
6896 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006897 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006898
6899 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006900 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006901
6902 return CMD_SUCCESS;
6903}
6904
6905
hassoeb1ce602004-10-08 08:17:22 +00006906const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006907{
6908 "unknown",
6909 "standard",
6910 "ibm",
6911 "cisco",
6912 "shortcut"
6913};
6914
hassoeb1ce602004-10-08 08:17:22 +00006915const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006916{
6917 "default",
6918 "enable",
6919 "disable"
6920};
6921
6922
paul4dadc292005-05-06 21:37:42 +00006923static void
paul718e3742002-12-13 20:15:29 +00006924area_id2str (char *buf, int length, struct ospf_area *area)
6925{
6926 memset (buf, 0, length);
6927
6928 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6929 strncpy (buf, inet_ntoa (area->area_id), length);
6930 else
6931 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6932}
6933
6934
hassoeb1ce602004-10-08 08:17:22 +00006935const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006936{
6937 "unknown", /* should never be used. */
6938 "point-to-point",
6939 "broadcast",
6940 "non-broadcast",
6941 "point-to-multipoint",
6942 "virtual-link", /* should never be used. */
6943 "loopback"
6944};
6945
6946/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00006947static int
paul718e3742002-12-13 20:15:29 +00006948config_write_interface (struct vty *vty)
6949{
hasso52dc7ee2004-09-23 19:18:23 +00006950 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006951 struct interface *ifp;
6952 struct crypt_key *ck;
6953 int write = 0;
6954 struct route_node *rn = NULL;
6955 struct ospf_if_params *params;
6956
paul1eb8ef22005-04-07 07:30:20 +00006957 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00006958 {
paul718e3742002-12-13 20:15:29 +00006959 if (memcmp (ifp->name, "VLINK", 5) == 0)
6960 continue;
6961
6962 vty_out (vty, "!%s", VTY_NEWLINE);
6963 vty_out (vty, "interface %s%s", ifp->name,
6964 VTY_NEWLINE);
6965 if (ifp->desc)
6966 vty_out (vty, " description %s%s", ifp->desc,
6967 VTY_NEWLINE);
6968
6969 write++;
6970
6971 params = IF_DEF_PARAMS (ifp);
6972
6973 do {
6974 /* Interface Network print. */
6975 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006976 params->type != OSPF_IFTYPE_LOOPBACK)
6977 {
ajsbc18d612004-12-15 15:07:19 +00006978 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006979 {
6980 vty_out (vty, " ip ospf network %s",
6981 ospf_int_type_str[params->type]);
6982 if (params != IF_DEF_PARAMS (ifp))
6983 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6984 vty_out (vty, "%s", VTY_NEWLINE);
6985 }
paul718e3742002-12-13 20:15:29 +00006986 }
6987
6988 /* OSPF interface authentication print */
6989 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6990 params->auth_type != OSPF_AUTH_NOTSET)
6991 {
hassoeb1ce602004-10-08 08:17:22 +00006992 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006993
6994 /* Translation tables are not that much help here due to syntax
6995 of the simple option */
6996 switch (params->auth_type)
6997 {
6998
6999 case OSPF_AUTH_NULL:
7000 auth_str = " null";
7001 break;
7002
7003 case OSPF_AUTH_SIMPLE:
7004 auth_str = "";
7005 break;
7006
7007 case OSPF_AUTH_CRYPTOGRAPHIC:
7008 auth_str = " message-digest";
7009 break;
7010
7011 default:
7012 auth_str = "";
7013 break;
7014 }
7015
7016 vty_out (vty, " ip ospf authentication%s", auth_str);
7017 if (params != IF_DEF_PARAMS (ifp))
7018 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7019 vty_out (vty, "%s", VTY_NEWLINE);
7020 }
7021
7022 /* Simple Authentication Password print. */
7023 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7024 params->auth_simple[0] != '\0')
7025 {
7026 vty_out (vty, " ip ospf authentication-key %s",
7027 params->auth_simple);
7028 if (params != IF_DEF_PARAMS (ifp))
7029 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7030 vty_out (vty, "%s", VTY_NEWLINE);
7031 }
7032
7033 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007034 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007035 {
paul718e3742002-12-13 20:15:29 +00007036 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7037 ck->key_id, ck->auth_key);
7038 if (params != IF_DEF_PARAMS (ifp))
7039 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7040 vty_out (vty, "%s", VTY_NEWLINE);
7041 }
7042
7043 /* Interface Output Cost print. */
7044 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7045 {
7046 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7047 if (params != IF_DEF_PARAMS (ifp))
7048 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7049 vty_out (vty, "%s", VTY_NEWLINE);
7050 }
7051
7052 /* Hello Interval print. */
7053 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7054 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7055 {
7056 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7057 if (params != IF_DEF_PARAMS (ifp))
7058 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7059 vty_out (vty, "%s", VTY_NEWLINE);
7060 }
7061
7062
7063 /* Router Dead Interval print. */
7064 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7065 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7066 {
paulf9ad9372005-10-21 00:45:17 +00007067 vty_out (vty, " ip ospf dead-interval ");
7068
7069 /* fast hello ? */
7070 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7071 vty_out (vty, "minimal hello-multiplier %d",
7072 params->fast_hello);
7073 else
7074 vty_out (vty, "%u", params->v_wait);
7075
paul718e3742002-12-13 20:15:29 +00007076 if (params != IF_DEF_PARAMS (ifp))
7077 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7078 vty_out (vty, "%s", VTY_NEWLINE);
7079 }
7080
7081 /* Router Priority print. */
7082 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7083 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7084 {
7085 vty_out (vty, " ip ospf priority %u", params->priority);
7086 if (params != IF_DEF_PARAMS (ifp))
7087 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7088 vty_out (vty, "%s", VTY_NEWLINE);
7089 }
7090
7091 /* Retransmit Interval print. */
7092 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7093 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7094 {
7095 vty_out (vty, " ip ospf retransmit-interval %u",
7096 params->retransmit_interval);
7097 if (params != IF_DEF_PARAMS (ifp))
7098 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7099 vty_out (vty, "%s", VTY_NEWLINE);
7100 }
7101
7102 /* Transmit Delay print. */
7103 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7104 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7105 {
7106 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7107 if (params != IF_DEF_PARAMS (ifp))
7108 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7109 vty_out (vty, "%s", VTY_NEWLINE);
7110 }
7111
vincentba682532005-09-29 13:52:57 +00007112 /* MTU ignore print. */
7113 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7114 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7115 {
7116 if (params->mtu_ignore == 0)
7117 vty_out (vty, " no ip ospf mtu-ignore");
7118 else
7119 vty_out (vty, " ip ospf mtu-ignore");
7120 if (params != IF_DEF_PARAMS (ifp))
7121 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7122 vty_out (vty, "%s", VTY_NEWLINE);
7123 }
7124
7125
paul718e3742002-12-13 20:15:29 +00007126 while (1)
7127 {
7128 if (rn == NULL)
7129 rn = route_top (IF_OIFS_PARAMS (ifp));
7130 else
7131 rn = route_next (rn);
7132
7133 if (rn == NULL)
7134 break;
7135 params = rn->info;
7136 if (params != NULL)
7137 break;
7138 }
7139 } while (rn);
7140
7141#ifdef HAVE_OPAQUE_LSA
7142 ospf_opaque_config_write_if (vty, ifp);
7143#endif /* HAVE_OPAQUE_LSA */
7144 }
7145
7146 return write;
7147}
7148
paul4dadc292005-05-06 21:37:42 +00007149static int
paul68980082003-03-25 05:07:42 +00007150config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007151{
7152 struct route_node *rn;
7153 u_char buf[INET_ADDRSTRLEN];
7154
7155 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007156 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007157 if (rn->info)
7158 {
7159 struct ospf_network *n = rn->info;
7160
7161 memset (buf, 0, INET_ADDRSTRLEN);
7162
7163 /* Create Area ID string by specified Area ID format. */
7164 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007165 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007166 else
hassoc9e52be2004-09-26 16:09:34 +00007167 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007168 (unsigned long int) ntohl (n->area_id.s_addr));
7169
7170 /* Network print. */
7171 vty_out (vty, " network %s/%d area %s%s",
7172 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7173 buf, VTY_NEWLINE);
7174 }
7175
7176 return 0;
7177}
7178
paul4dadc292005-05-06 21:37:42 +00007179static int
paul68980082003-03-25 05:07:42 +00007180config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007181{
hasso52dc7ee2004-09-23 19:18:23 +00007182 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007183 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007184 u_char buf[INET_ADDRSTRLEN];
7185
7186 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007187 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007188 {
paul718e3742002-12-13 20:15:29 +00007189 struct route_node *rn1;
7190
hassoc9e52be2004-09-26 16:09:34 +00007191 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007192
7193 if (area->auth_type != OSPF_AUTH_NULL)
7194 {
7195 if (area->auth_type == OSPF_AUTH_SIMPLE)
7196 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7197 else
7198 vty_out (vty, " area %s authentication message-digest%s",
7199 buf, VTY_NEWLINE);
7200 }
7201
7202 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7203 vty_out (vty, " area %s shortcut %s%s", buf,
7204 ospf_shortcut_mode_str[area->shortcut_configured],
7205 VTY_NEWLINE);
7206
7207 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007208 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007209 )
7210 {
paulb0a053b2003-06-22 09:04:47 +00007211 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007212 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007213 else if (area->external_routing == OSPF_AREA_NSSA)
7214 {
7215 vty_out (vty, " area %s nssa", buf);
7216 switch (area->NSSATranslatorRole)
7217 {
7218 case OSPF_NSSA_ROLE_NEVER:
7219 vty_out (vty, " translate-never");
7220 break;
7221 case OSPF_NSSA_ROLE_ALWAYS:
7222 vty_out (vty, " translate-always");
7223 break;
7224 case OSPF_NSSA_ROLE_CANDIDATE:
7225 default:
7226 vty_out (vty, " translate-candidate");
7227 }
7228 }
paul718e3742002-12-13 20:15:29 +00007229
7230 if (area->no_summary)
7231 vty_out (vty, " no-summary");
7232
7233 vty_out (vty, "%s", VTY_NEWLINE);
7234
7235 if (area->default_cost != 1)
7236 vty_out (vty, " area %s default-cost %d%s", buf,
7237 area->default_cost, VTY_NEWLINE);
7238 }
7239
7240 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7241 if (rn1->info)
7242 {
7243 struct ospf_area_range *range = rn1->info;
7244
7245 vty_out (vty, " area %s range %s/%d", buf,
7246 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7247
paul6c835672004-10-11 11:00:30 +00007248 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007249 vty_out (vty, " cost %d", range->cost_config);
7250
7251 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7252 vty_out (vty, " not-advertise");
7253
7254 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7255 vty_out (vty, " substitute %s/%d",
7256 inet_ntoa (range->subst_addr), range->subst_masklen);
7257
7258 vty_out (vty, "%s", VTY_NEWLINE);
7259 }
7260
7261 if (EXPORT_NAME (area))
7262 vty_out (vty, " area %s export-list %s%s", buf,
7263 EXPORT_NAME (area), VTY_NEWLINE);
7264
7265 if (IMPORT_NAME (area))
7266 vty_out (vty, " area %s import-list %s%s", buf,
7267 IMPORT_NAME (area), VTY_NEWLINE);
7268
7269 if (PREFIX_NAME_IN (area))
7270 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7271 PREFIX_NAME_IN (area), VTY_NEWLINE);
7272
7273 if (PREFIX_NAME_OUT (area))
7274 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7275 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7276 }
7277
7278 return 0;
7279}
7280
paul4dadc292005-05-06 21:37:42 +00007281static int
paul68980082003-03-25 05:07:42 +00007282config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007283{
7284 struct ospf_nbr_nbma *nbr_nbma;
7285 struct route_node *rn;
7286
7287 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007288 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007289 if ((nbr_nbma = rn->info))
7290 {
7291 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7292
7293 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7294 vty_out (vty, " priority %d", nbr_nbma->priority);
7295
7296 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7297 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7298
7299 vty_out (vty, "%s", VTY_NEWLINE);
7300 }
7301
7302 return 0;
7303}
7304
paul4dadc292005-05-06 21:37:42 +00007305static int
paul68980082003-03-25 05:07:42 +00007306config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007307{
hasso52dc7ee2004-09-23 19:18:23 +00007308 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007309 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007310 u_char buf[INET_ADDRSTRLEN];
7311
7312 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007313 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007314 {
hasso52dc7ee2004-09-23 19:18:23 +00007315 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007316 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007317 struct ospf_interface *oi;
7318
7319 if (vl_data != NULL)
7320 {
7321 memset (buf, 0, INET_ADDRSTRLEN);
7322
7323 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007324 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007325 else
hassoc9e52be2004-09-26 16:09:34 +00007326 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007327 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7328 oi = vl_data->vl_oi;
7329
7330 /* timers */
7331 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7332 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7333 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7334 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7335 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7336 buf,
7337 inet_ntoa (vl_data->vl_peer),
7338 OSPF_IF_PARAM (oi, v_hello),
7339 OSPF_IF_PARAM (oi, retransmit_interval),
7340 OSPF_IF_PARAM (oi, transmit_delay),
7341 OSPF_IF_PARAM (oi, v_wait),
7342 VTY_NEWLINE);
7343 else
7344 vty_out (vty, " area %s virtual-link %s%s", buf,
7345 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7346 /* Auth key */
7347 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7348 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7349 buf,
7350 inet_ntoa (vl_data->vl_peer),
7351 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7352 VTY_NEWLINE);
7353 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007354 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7355 n2, ck))
7356 vty_out (vty, " area %s virtual-link %s"
7357 " message-digest-key %d md5 %s%s",
7358 buf,
7359 inet_ntoa (vl_data->vl_peer),
7360 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007361
7362 }
7363 }
7364
7365 return 0;
7366}
7367
7368
paul4dadc292005-05-06 21:37:42 +00007369static int
paul68980082003-03-25 05:07:42 +00007370config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007371{
7372 int type;
7373
7374 /* redistribute print. */
7375 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7376 if (type != zclient->redist_default && zclient->redist[type])
7377 {
ajsf52d13c2005-10-01 17:38:06 +00007378 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007379 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007380 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007381
paul68980082003-03-25 05:07:42 +00007382 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007383 vty_out (vty, " metric-type 1");
7384
paul020709f2003-04-04 02:44:16 +00007385 if (ROUTEMAP_NAME (ospf, type))
7386 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007387
7388 vty_out (vty, "%s", VTY_NEWLINE);
7389 }
7390
7391 return 0;
7392}
7393
paul4dadc292005-05-06 21:37:42 +00007394static int
paul68980082003-03-25 05:07:42 +00007395config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007396{
paul68980082003-03-25 05:07:42 +00007397 if (ospf->default_metric != -1)
7398 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007399 VTY_NEWLINE);
7400 return 0;
7401}
7402
paul4dadc292005-05-06 21:37:42 +00007403static int
paul68980082003-03-25 05:07:42 +00007404config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007405{
7406 int type;
7407
paul68980082003-03-25 05:07:42 +00007408 if (ospf)
paul718e3742002-12-13 20:15:29 +00007409 {
7410 /* distribute-list print. */
7411 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007412 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007413 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007414 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007415 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007416
7417 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007418 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007419 {
paul68980082003-03-25 05:07:42 +00007420 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007421 vty_out (vty, " default-information originate");
7422 else
7423 vty_out (vty, " default-information originate always");
7424
paul68980082003-03-25 05:07:42 +00007425 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007426 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007427 ospf->dmetric[DEFAULT_ROUTE].value);
7428 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007429 vty_out (vty, " metric-type 1");
7430
paul020709f2003-04-04 02:44:16 +00007431 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7432 vty_out (vty, " route-map %s",
7433 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007434
7435 vty_out (vty, "%s", VTY_NEWLINE);
7436 }
7437
7438 }
7439
7440 return 0;
7441}
7442
paul4dadc292005-05-06 21:37:42 +00007443static int
paul68980082003-03-25 05:07:42 +00007444config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007445{
7446 struct route_node *rn;
7447 struct ospf_distance *odistance;
7448
paul68980082003-03-25 05:07:42 +00007449 if (ospf->distance_all)
7450 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007451
paul68980082003-03-25 05:07:42 +00007452 if (ospf->distance_intra
7453 || ospf->distance_inter
7454 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007455 {
7456 vty_out (vty, " distance ospf");
7457
paul68980082003-03-25 05:07:42 +00007458 if (ospf->distance_intra)
7459 vty_out (vty, " intra-area %d", ospf->distance_intra);
7460 if (ospf->distance_inter)
7461 vty_out (vty, " inter-area %d", ospf->distance_inter);
7462 if (ospf->distance_external)
7463 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007464
7465 vty_out (vty, "%s", VTY_NEWLINE);
7466 }
7467
paul68980082003-03-25 05:07:42 +00007468 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007469 if ((odistance = rn->info) != NULL)
7470 {
7471 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7472 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7473 odistance->access_list ? odistance->access_list : "",
7474 VTY_NEWLINE);
7475 }
7476 return 0;
7477}
7478
7479/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007480static int
paul718e3742002-12-13 20:15:29 +00007481ospf_config_write (struct vty *vty)
7482{
paul020709f2003-04-04 02:44:16 +00007483 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007484 struct interface *ifp;
7485 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007486 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007487 int write = 0;
7488
paul020709f2003-04-04 02:44:16 +00007489 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007490 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007491 {
7492 /* `router ospf' print. */
7493 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7494
7495 write++;
7496
paul68980082003-03-25 05:07:42 +00007497 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007498 return write;
7499
7500 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007501 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007502 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007503 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007504
7505 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007506 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007507 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007508 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007509
7510 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007511 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007512 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7513
7514 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007515 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007516 {
7517 vty_out (vty, "! Important: ensure reference bandwidth "
7518 "is consistent across all routers%s", VTY_NEWLINE);
7519 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7520 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7521 }
paul718e3742002-12-13 20:15:29 +00007522
7523 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007524 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7525 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007526 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007527 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007528
7529 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007530 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007531 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007532 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007533
7534 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007535 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007536
7537 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007538 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7539 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7540 vty_out (vty, " passive-interface %s%s",
7541 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007542
paul1eb8ef22005-04-07 07:30:20 +00007543 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7544 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7545 oi->params->passive_interface == OSPF_IF_PASSIVE)
7546 vty_out (vty, " passive-interface %s %s%s",
7547 oi->ifp->name,
7548 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007549
7550 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007551 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007552
7553 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007554 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007555
7556 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007557 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007558
7559 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007560 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007561
7562 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007563 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007564
7565 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007566 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007567
7568 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007569 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007570
7571#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007572 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007573#endif /* HAVE_OPAQUE_LSA */
7574 }
7575
7576 return write;
7577}
7578
7579void
paul4dadc292005-05-06 21:37:42 +00007580ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007581{
7582 /* "show ip ospf" commands. */
7583 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7584 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7585
7586 /* "show ip ospf database" commands. */
7587 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7588 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7589 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7590 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7591 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7592 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7593 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7594 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7595 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7596 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7597 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7598 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7599 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7600 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7601
7602 /* "show ip ospf interface" commands. */
7603 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7604 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7605
7606 /* "show ip ospf neighbor" commands. */
7607 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7608 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7609 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7610 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7611 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7612 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7613 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7614 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7615 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7616 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7617 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7618 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7619 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7620 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7621
7622 /* "show ip ospf route" commands. */
7623 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7624 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007625 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7626 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007627}
7628
7629
7630/* ospfd's interface node. */
7631struct cmd_node interface_node =
7632{
7633 INTERFACE_NODE,
7634 "%s(config-if)# ",
7635 1
7636};
7637
7638/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007639static void
7640ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007641{
7642 /* Install interface node. */
7643 install_node (&interface_node, config_write_interface);
7644
7645 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007646 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007647 install_default (INTERFACE_NODE);
7648
7649 /* "description" commands. */
7650 install_element (INTERFACE_NODE, &interface_desc_cmd);
7651 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7652
7653 /* "ip ospf authentication" commands. */
7654 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7655 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7656 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7657 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7658 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7659 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7660 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7661 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7662 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7663 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7664
7665 /* "ip ospf message-digest-key" commands. */
7666 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7667 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7668 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7669 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7670
7671 /* "ip ospf cost" commands. */
7672 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7673 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7674 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7675 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7676
vincentba682532005-09-29 13:52:57 +00007677 /* "ip ospf mtu-ignore" commands. */
7678 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7679 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7680 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7681 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7682
paul718e3742002-12-13 20:15:29 +00007683 /* "ip ospf dead-interval" commands. */
7684 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7685 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007686 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7687 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007688 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7689 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007690
paul718e3742002-12-13 20:15:29 +00007691 /* "ip ospf hello-interval" commands. */
7692 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7693 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7694 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7695 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7696
7697 /* "ip ospf network" commands. */
7698 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7699 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7700
7701 /* "ip ospf priority" commands. */
7702 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7703 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7704 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7705 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7706
7707 /* "ip ospf retransmit-interval" commands. */
7708 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7709 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7710 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7711 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7712
7713 /* "ip ospf transmit-delay" commands. */
7714 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7715 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7716 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7717 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7718
7719 /* These commands are compatibitliy for previous version. */
7720 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7721 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7722 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7723 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7724 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7725 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7726 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7727 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7728 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7729 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7730 install_element (INTERFACE_NODE, &ospf_network_cmd);
7731 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7732 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7733 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7734 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7735 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7736 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7737 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7738}
7739
7740/* Zebra node structure. */
7741struct cmd_node zebra_node =
7742{
7743 ZEBRA_NODE,
7744 "%s(config-router)#",
7745};
7746
paul4dadc292005-05-06 21:37:42 +00007747static void
7748ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00007749{
7750 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7751 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7752 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7753 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7754 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7755 install_element (OSPF_NODE,
7756 &ospf_redistribute_source_metric_type_routemap_cmd);
7757 install_element (OSPF_NODE,
7758 &ospf_redistribute_source_type_metric_routemap_cmd);
7759 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7760 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7761 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7762
7763 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7764
7765 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7766 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7767
7768 install_element (OSPF_NODE,
7769 &ospf_default_information_originate_metric_type_cmd);
7770 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7771 install_element (OSPF_NODE,
7772 &ospf_default_information_originate_type_metric_cmd);
7773 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7774 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7775 install_element (OSPF_NODE,
7776 &ospf_default_information_originate_always_metric_type_cmd);
7777 install_element (OSPF_NODE,
7778 &ospf_default_information_originate_always_metric_cmd);
7779 install_element (OSPF_NODE,
7780 &ospf_default_information_originate_always_cmd);
7781 install_element (OSPF_NODE,
7782 &ospf_default_information_originate_always_type_metric_cmd);
7783 install_element (OSPF_NODE,
7784 &ospf_default_information_originate_always_type_cmd);
7785
7786 install_element (OSPF_NODE,
7787 &ospf_default_information_originate_metric_type_routemap_cmd);
7788 install_element (OSPF_NODE,
7789 &ospf_default_information_originate_metric_routemap_cmd);
7790 install_element (OSPF_NODE,
7791 &ospf_default_information_originate_routemap_cmd);
7792 install_element (OSPF_NODE,
7793 &ospf_default_information_originate_type_metric_routemap_cmd);
7794 install_element (OSPF_NODE,
7795 &ospf_default_information_originate_type_routemap_cmd);
7796 install_element (OSPF_NODE,
7797 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7798 install_element (OSPF_NODE,
7799 &ospf_default_information_originate_always_metric_routemap_cmd);
7800 install_element (OSPF_NODE,
7801 &ospf_default_information_originate_always_routemap_cmd);
7802 install_element (OSPF_NODE,
7803 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7804 install_element (OSPF_NODE,
7805 &ospf_default_information_originate_always_type_routemap_cmd);
7806
7807 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7808
7809 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7810 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7811 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7812
7813 install_element (OSPF_NODE, &ospf_distance_cmd);
7814 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7815 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7816 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7817 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7818 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7819 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7820 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7821 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7822 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7823 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7824 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7825 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7826 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7827 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7828 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7829 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7830 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7831#if 0
7832 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7833 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7834 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7835 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7836#endif /* 0 */
7837}
7838
7839struct cmd_node ospf_node =
7840{
7841 OSPF_NODE,
7842 "%s(config-router)# ",
7843 1
7844};
7845
7846
7847/* Install OSPF related vty commands. */
7848void
paul4dadc292005-05-06 21:37:42 +00007849ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00007850{
7851 /* Install ospf top node. */
7852 install_node (&ospf_node, ospf_config_write);
7853
7854 /* "router ospf" commands. */
7855 install_element (CONFIG_NODE, &router_ospf_cmd);
7856 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7857
7858 install_default (OSPF_NODE);
7859
7860 /* "ospf router-id" commands. */
7861 install_element (OSPF_NODE, &ospf_router_id_cmd);
7862 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007863 install_element (OSPF_NODE, &router_ospf_id_cmd);
7864 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007865
7866 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007867 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7868 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7869 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7870 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007871
7872 /* "ospf abr-type" commands. */
7873 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7874 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7875
7876 /* "ospf rfc1583-compatible" commands. */
7877 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7878 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7879 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7880 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7881
7882 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007883 install_element (OSPF_NODE, &ospf_network_area_cmd);
7884 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007885
7886 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007887 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7888 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7889 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007890
7891 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007892 install_element (OSPF_NODE, &ospf_area_range_cmd);
7893 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7894 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7895 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7896 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7897 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7898 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7899 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7900 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7901 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7902 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007903
7904 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007905 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7906 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007907
paula2c62832003-04-23 17:01:31 +00007908 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7909 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007910
paula2c62832003-04-23 17:01:31 +00007911 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7912 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007913
paula2c62832003-04-23 17:01:31 +00007914 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7915 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007916
paula2c62832003-04-23 17:01:31 +00007917 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7918 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007919
paula2c62832003-04-23 17:01:31 +00007920 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7921 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7922 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007923
paula2c62832003-04-23 17:01:31 +00007924 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7925 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007926
paula2c62832003-04-23 17:01:31 +00007927 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7928 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007929
paula2c62832003-04-23 17:01:31 +00007930 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7931 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7932 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007933
paula2c62832003-04-23 17:01:31 +00007934 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7935 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7936 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007937
7938 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007939 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7940 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7941 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7942 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007943
paul718e3742002-12-13 20:15:29 +00007944 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007945 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7946 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7947 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7948 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7949 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7950 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007951
paula2c62832003-04-23 17:01:31 +00007952 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7953 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007954
paula2c62832003-04-23 17:01:31 +00007955 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7956 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007957
paula2c62832003-04-23 17:01:31 +00007958 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7959 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007960
paula2c62832003-04-23 17:01:31 +00007961 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7962 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007963
paula2c62832003-04-23 17:01:31 +00007964 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7965 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007966
paula2c62832003-04-23 17:01:31 +00007967 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7968 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007969
paula2c62832003-04-23 17:01:31 +00007970 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7971 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7972 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007973
paula2c62832003-04-23 17:01:31 +00007974 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7975 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007976
7977 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007978 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7979 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7980 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7981 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7982 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7983 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7984 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7985 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007986
7987 /* Init interface related vty commands. */
7988 ospf_vty_if_init ();
7989
7990 /* Init zebra related vty commands. */
7991 ospf_vty_zebra_init ();
7992}