blob: 1a2afacc7629b7dc56ab37b8badbf651fc82c443 [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;
paul718e3742002-12-13 20:15:29 +00002356 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2357 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2358
paul1eb8ef22005-04-07 07:30:20 +00002359 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2360 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002361
2362 return CMD_SUCCESS;
2363}
2364
paula2c62832003-04-23 17:01:31 +00002365DEFUN (no_ospf_auto_cost_reference_bandwidth,
2366 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002367 "no auto-cost reference-bandwidth",
2368 NO_STR
2369 "Calculate OSPF interface cost according to bandwidth\n"
2370 "Use reference bandwidth method to assign OSPF cost\n")
2371{
paul68980082003-03-25 05:07:42 +00002372 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002373 struct listnode *node, *nnode;
2374 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002375
paul68980082003-03-25 05:07:42 +00002376 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002377 return CMD_SUCCESS;
2378
paul68980082003-03-25 05:07:42 +00002379 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002380 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2381 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2382
paul1eb8ef22005-04-07 07:30:20 +00002383 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2384 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002385
2386 return CMD_SUCCESS;
2387}
2388
hassoeb1ce602004-10-08 08:17:22 +00002389const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002390{
2391 "Unknown",
2392 "Standard (RFC2328)",
2393 "Alternative IBM",
2394 "Alternative Cisco",
2395 "Alternative Shortcut"
2396};
2397
hassoeb1ce602004-10-08 08:17:22 +00002398const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002399{
2400 "Default",
2401 "Enabled",
2402 "Disabled"
2403};
2404
2405
2406
paul4dadc292005-05-06 21:37:42 +00002407static void
paul718e3742002-12-13 20:15:29 +00002408show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2409{
2410 /* Show Area ID. */
2411 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2412
2413 /* Show Area type/mode. */
2414 if (OSPF_IS_AREA_BACKBONE (area))
2415 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2416 else
2417 {
2418 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002419 vty_out (vty, " (Stub%s%s)",
2420 area->no_summary ? ", no summary" : "",
2421 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002422
paulb0a053b2003-06-22 09:04:47 +00002423 else if (area->external_routing == OSPF_AREA_NSSA)
2424 vty_out (vty, " (NSSA%s%s)",
2425 area->no_summary ? ", no summary" : "",
2426 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002427
2428 vty_out (vty, "%s", VTY_NEWLINE);
2429 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002430 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002431 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002432 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002433 }
2434
2435 /* Show number of interfaces. */
2436 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2437 "Active: %d%s", listcount (area->oiflist),
2438 area->act_ints, VTY_NEWLINE);
2439
paul718e3742002-12-13 20:15:29 +00002440 if (area->external_routing == OSPF_AREA_NSSA)
2441 {
2442 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 +00002443 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002444 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2445 VTY_NEWLINE);
2446 else if (area->NSSATranslatorState)
2447 {
2448 vty_out (vty, " We are an ABR and ");
2449 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2450 vty_out (vty, "the NSSA Elected Translator. %s",
2451 VTY_NEWLINE);
2452 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2453 vty_out (vty, "always an NSSA Translator. %s",
2454 VTY_NEWLINE);
2455 }
paul718e3742002-12-13 20:15:29 +00002456 else
paulb0a053b2003-06-22 09:04:47 +00002457 {
2458 vty_out (vty, " We are an ABR, but ");
2459 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2460 vty_out (vty, "not the NSSA Elected Translator. %s",
2461 VTY_NEWLINE);
2462 else
hassoc6b87812004-12-22 13:09:59 +00002463 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002464 VTY_NEWLINE);
2465 }
paul718e3742002-12-13 20:15:29 +00002466 }
paul718e3742002-12-13 20:15:29 +00002467
2468 /* Show number of fully adjacent neighbors. */
2469 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002470 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002471
2472 /* Show authentication type. */
2473 vty_out (vty, " Area has ");
2474 if (area->auth_type == OSPF_AUTH_NULL)
2475 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2476 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2477 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2478 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2479 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2480
2481 if (!OSPF_IS_AREA_BACKBONE (area))
2482 vty_out (vty, " Number of full virtual adjacencies going through"
2483 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2484
2485 /* Show SPF calculation times. */
2486 vty_out (vty, " SPF algorithm executed %d times%s",
2487 area->spf_calculation, VTY_NEWLINE);
2488
2489 /* Show number of LSA. */
2490 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002491 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2492 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2493 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2494 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2495 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2496 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2497 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2498 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2499 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2500 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2501 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2502 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2503 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2504 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2505 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2506#ifdef HAVE_OPAQUE_LSA
2507 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2508 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2509 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2510 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2511 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2512 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2513#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002514 vty_out (vty, "%s", VTY_NEWLINE);
2515}
2516
2517DEFUN (show_ip_ospf,
2518 show_ip_ospf_cmd,
2519 "show ip ospf",
2520 SHOW_STR
2521 IP_STR
2522 "OSPF information\n")
2523{
paul1eb8ef22005-04-07 07:30:20 +00002524 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002525 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002526 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002527
2528 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002529 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002530 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002531 {
2532 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2533 return CMD_SUCCESS;
2534 }
2535
2536 /* Show Router ID. */
2537 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002538 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002539 VTY_NEWLINE);
2540
2541 /* Show capability. */
2542 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2543 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2544 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002545 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002546 "enabled" : "disabled", VTY_NEWLINE);
2547#ifdef HAVE_OPAQUE_LSA
2548 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002549 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002550 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002551 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002552 " (origination blocked)" : "",
2553 VTY_NEWLINE);
2554#endif /* HAVE_OPAQUE_LSA */
2555
2556 /* Show SPF timers. */
2557 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
paul68980082003-03-25 05:07:42 +00002558 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002559
2560 /* Show refresh parameters. */
2561 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002562 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002563
2564 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002565 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002566 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002567 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002568
paul68980082003-03-25 05:07:42 +00002569 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002570 vty_out (vty, " This router is an ASBR "
2571 "(injecting external routing information)%s", VTY_NEWLINE);
2572
2573 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002574 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2575 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2576 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2577#ifdef HAVE_OPAQUE_LSA
2578 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2579 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2580 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2581#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002582 /* Show number of areas attached. */
2583 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002584 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002585
2586 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002587 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2588 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002589
2590 return CMD_SUCCESS;
2591}
2592
2593
ajsfd651fa2005-03-29 16:08:16 +00002594static void
paul68980082003-03-25 05:07:42 +00002595show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2596 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002597{
ajsfd651fa2005-03-29 16:08:16 +00002598 int is_up;
paul718e3742002-12-13 20:15:29 +00002599 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002600 struct route_node *rn;
2601 char buf[9];
2602
paul718e3742002-12-13 20:15:29 +00002603 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002604 vty_out (vty, "%s is %s%s", ifp->name,
2605 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002606 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2607 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2608 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002609
2610 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002611 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002612 {
2613 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2614 return;
2615 }
ajsfd651fa2005-03-29 16:08:16 +00002616 else if (!is_up)
2617 {
2618 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2619 VTY_NEWLINE);
2620 return;
2621 }
2622
paul718e3742002-12-13 20:15:29 +00002623 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2624 {
2625 struct ospf_interface *oi = rn->info;
2626
2627 if (oi == NULL)
2628 continue;
2629
2630 /* Show OSPF interface information. */
2631 vty_out (vty, " Internet Address %s/%d,",
2632 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2633
hasso3fb9cd62004-10-19 19:44:43 +00002634 if (oi->connected->destination)
2635 vty_out (vty, " %s %s,",
2636 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2637 inet_ntoa (oi->connected->destination->u.prefix4));
2638
paul718e3742002-12-13 20:15:29 +00002639 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2640 VTY_NEWLINE);
2641
vincentba682532005-09-29 13:52:57 +00002642 vty_out (vty, " MTU mismatch detection:%s%s",
2643 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2644
paul718e3742002-12-13 20:15:29 +00002645 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002646 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002647 oi->output_cost, VTY_NEWLINE);
2648
2649 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2650 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2651 PRIORITY (oi), VTY_NEWLINE);
2652
2653 /* Show DR information. */
2654 if (DR (oi).s_addr == 0)
2655 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2656 else
2657 {
2658 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2659 if (nbr == NULL)
2660 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2661 else
2662 {
2663 vty_out (vty, " Designated Router (ID) %s,",
2664 inet_ntoa (nbr->router_id));
2665 vty_out (vty, " Interface Address %s%s",
2666 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2667 }
2668 }
2669
2670 /* Show BDR information. */
2671 if (BDR (oi).s_addr == 0)
2672 vty_out (vty, " No backup designated router on this network%s",
2673 VTY_NEWLINE);
2674 else
2675 {
2676 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2677 if (nbr == NULL)
2678 vty_out (vty, " No backup designated router on this network%s",
2679 VTY_NEWLINE);
2680 else
2681 {
2682 vty_out (vty, " Backup Designated Router (ID) %s,",
2683 inet_ntoa (nbr->router_id));
2684 vty_out (vty, " Interface Address %s%s",
2685 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2686 }
2687 }
ajsba6454e2005-02-08 15:37:30 +00002688
2689 vty_out (vty, " Multicast group memberships:");
2690 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2691 vty_out (vty, " OSPFAllRouters");
2692 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2693 vty_out (vty, " OSPFDesignatedRouters");
2694 if (!CHECK_FLAG(oi->multicast_memberships,
2695 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2696 vty_out (vty, " <None>");
2697 vty_out (vty, "%s", VTY_NEWLINE);
2698
paul718e3742002-12-13 20:15:29 +00002699 vty_out (vty, " Timer intervals configured,");
2700 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2701 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2702 OSPF_IF_PARAM (oi, v_wait),
2703 OSPF_IF_PARAM (oi, retransmit_interval),
2704 VTY_NEWLINE);
2705
2706 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2707 vty_out (vty, " Hello due in %s%s",
2708 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2709 else /* OSPF_IF_PASSIVE is set */
2710 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2711
2712 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002713 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002714 VTY_NEWLINE);
2715 }
2716}
2717
2718DEFUN (show_ip_ospf_interface,
2719 show_ip_ospf_interface_cmd,
2720 "show ip ospf interface [INTERFACE]",
2721 SHOW_STR
2722 IP_STR
2723 "OSPF information\n"
2724 "Interface information\n"
2725 "Interface name\n")
2726{
2727 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002728 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002729 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002730
paul020709f2003-04-04 02:44:16 +00002731 ospf = ospf_lookup ();
2732
paul718e3742002-12-13 20:15:29 +00002733 /* Show All Interfaces. */
2734 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002735 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2736 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002737 /* Interface name is specified. */
2738 else
2739 {
2740 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2741 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2742 else
paul68980082003-03-25 05:07:42 +00002743 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002744 }
2745
2746 return CMD_SUCCESS;
2747}
2748
paul4dadc292005-05-06 21:37:42 +00002749static void
paul718e3742002-12-13 20:15:29 +00002750show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2751{
2752 struct route_node *rn;
2753 struct ospf_neighbor *nbr;
2754 char msgbuf[16];
2755 char timebuf[9];
2756
2757 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2758 if ((nbr = rn->info))
2759 /* Do not show myself. */
2760 if (nbr != oi->nbr_self)
2761 /* Down state is not shown. */
2762 if (nbr->state != NSM_Down)
2763 {
2764 ospf_nbr_state_message (nbr, msgbuf, 16);
2765
2766 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2767 vty_out (vty, "%-15s %3d %-15s %8s ",
2768 "-", nbr->priority,
2769 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2770 else
2771 vty_out (vty, "%-15s %3d %-15s %8s ",
2772 inet_ntoa (nbr->router_id), nbr->priority,
2773 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2774 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2775 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2776 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2777 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2778 VTY_NEWLINE);
2779 }
2780}
2781
2782DEFUN (show_ip_ospf_neighbor,
2783 show_ip_ospf_neighbor_cmd,
2784 "show ip ospf neighbor",
2785 SHOW_STR
2786 IP_STR
2787 "OSPF information\n"
2788 "Neighbor list\n")
2789{
paul020709f2003-04-04 02:44:16 +00002790 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002791 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002792 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002793
paul020709f2003-04-04 02:44:16 +00002794 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002795 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002796 {
2797 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2798 return CMD_SUCCESS;
2799 }
2800
2801 /* Show All neighbors. */
2802 vty_out (vty, "%sNeighbor ID Pri State Dead "
2803 "Time Address Interface RXmtL "
2804 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2805
paul1eb8ef22005-04-07 07:30:20 +00002806 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
2807 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00002808
2809 return CMD_SUCCESS;
2810}
2811
2812DEFUN (show_ip_ospf_neighbor_all,
2813 show_ip_ospf_neighbor_all_cmd,
2814 "show ip ospf neighbor all",
2815 SHOW_STR
2816 IP_STR
2817 "OSPF information\n"
2818 "Neighbor list\n"
2819 "include down status neighbor\n")
2820{
paul68980082003-03-25 05:07:42 +00002821 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002822 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002823 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002824
paul68980082003-03-25 05:07:42 +00002825 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002826 {
2827 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2828 return CMD_SUCCESS;
2829 }
2830
2831 /* Show All neighbors. */
2832 vty_out (vty, "%sNeighbor ID Pri State Dead "
2833 "Time Address Interface RXmtL "
2834 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2835
paul1eb8ef22005-04-07 07:30:20 +00002836 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00002837 {
hasso52dc7ee2004-09-23 19:18:23 +00002838 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00002839 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00002840
2841 show_ip_ospf_neighbor_sub (vty, oi);
2842
2843 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00002844 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00002845 {
paul718e3742002-12-13 20:15:29 +00002846 if (nbr_nbma->nbr == NULL
2847 || nbr_nbma->nbr->state == NSM_Down)
2848 {
2849 vty_out (vty, "%-15s %3d %-15s %8s ",
2850 "-", nbr_nbma->priority, "Down", "-");
2851 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2852 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2853 0, 0, 0, VTY_NEWLINE);
2854 }
2855 }
2856 }
2857
2858 return CMD_SUCCESS;
2859}
2860
2861DEFUN (show_ip_ospf_neighbor_int,
2862 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00002863 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00002864 SHOW_STR
2865 IP_STR
2866 "OSPF information\n"
2867 "Neighbor list\n"
2868 "Interface name\n")
2869{
paul020709f2003-04-04 02:44:16 +00002870 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00002871 struct interface *ifp;
2872 struct route_node *rn;
2873
2874 ifp = if_lookup_by_name (argv[0]);
2875 if (!ifp)
paul718e3742002-12-13 20:15:29 +00002876 {
hassobb5b7552005-08-21 20:01:15 +00002877 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002878 return CMD_WARNING;
2879 }
2880
paul020709f2003-04-04 02:44:16 +00002881 ospf = ospf_lookup ();
2882 if (ospf == NULL)
2883 {
2884 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2885 return CMD_SUCCESS;
2886 }
2887
hassobb5b7552005-08-21 20:01:15 +00002888 vty_out (vty, "%sNeighbor ID Pri State Dead "
2889 "Time Address Interface RXmtL "
2890 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2891
2892 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00002893 {
hassobb5b7552005-08-21 20:01:15 +00002894 struct ospf_interface *oi = rn->info;
2895
2896 if (oi == NULL)
2897 continue;
2898
paul718e3742002-12-13 20:15:29 +00002899 show_ip_ospf_neighbor_sub (vty, oi);
2900 }
2901
2902 return CMD_SUCCESS;
2903}
2904
paul4dadc292005-05-06 21:37:42 +00002905static void
paul718e3742002-12-13 20:15:29 +00002906show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2907 struct ospf_nbr_nbma *nbr_nbma)
2908{
2909 char timebuf[9];
2910
2911 /* Show neighbor ID. */
2912 vty_out (vty, " Neighbor %s,", "-");
2913
2914 /* Show interface address. */
2915 vty_out (vty, " interface address %s%s",
2916 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2917 /* Show Area ID. */
2918 vty_out (vty, " In the area %s via interface %s%s",
2919 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2920 /* Show neighbor priority and state. */
2921 vty_out (vty, " Neighbor priority is %d, State is %s,",
2922 nbr_nbma->priority, "Down");
2923 /* Show state changes. */
2924 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2925
2926 /* Show PollInterval */
2927 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2928
2929 /* Show poll-interval timer. */
2930 vty_out (vty, " Poll timer due in %s%s",
2931 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2932
2933 /* Show poll-interval timer thread. */
2934 vty_out (vty, " Thread Poll Timer %s%s",
2935 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2936}
2937
paul4dadc292005-05-06 21:37:42 +00002938static void
paul718e3742002-12-13 20:15:29 +00002939show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2940 struct ospf_neighbor *nbr)
2941{
2942 char timebuf[9];
2943
2944 /* Show neighbor ID. */
2945 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2946 vty_out (vty, " Neighbor %s,", "-");
2947 else
2948 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2949
2950 /* Show interface address. */
2951 vty_out (vty, " interface address %s%s",
2952 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2953 /* Show Area ID. */
2954 vty_out (vty, " In the area %s via interface %s%s",
2955 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2956 /* Show neighbor priority and state. */
2957 vty_out (vty, " Neighbor priority is %d, State is %s,",
2958 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2959 /* Show state changes. */
2960 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2961
2962 /* Show Designated Rotuer ID. */
2963 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2964 /* Show Backup Designated Rotuer ID. */
2965 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2966 /* Show options. */
2967 vty_out (vty, " Options %d %s%s", nbr->options,
2968 ospf_options_dump (nbr->options), VTY_NEWLINE);
2969 /* Show Router Dead interval timer. */
2970 vty_out (vty, " Dead timer due in %s%s",
2971 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2972 /* Show Database Summary list. */
2973 vty_out (vty, " Database Summary List %d%s",
2974 ospf_db_summary_count (nbr), VTY_NEWLINE);
2975 /* Show Link State Request list. */
2976 vty_out (vty, " Link State Request List %ld%s",
2977 ospf_ls_request_count (nbr), VTY_NEWLINE);
2978 /* Show Link State Retransmission list. */
2979 vty_out (vty, " Link State Retransmission List %ld%s",
2980 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2981 /* Show inactivity timer thread. */
2982 vty_out (vty, " Thread Inactivity Timer %s%s",
2983 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2984 /* Show Database Description retransmission thread. */
2985 vty_out (vty, " Thread Database Description Retransmision %s%s",
2986 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2987 /* Show Link State Request Retransmission thread. */
2988 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2989 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2990 /* Show Link State Update Retransmission thread. */
2991 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2992 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2993}
2994
2995DEFUN (show_ip_ospf_neighbor_id,
2996 show_ip_ospf_neighbor_id_cmd,
2997 "show ip ospf neighbor A.B.C.D",
2998 SHOW_STR
2999 IP_STR
3000 "OSPF information\n"
3001 "Neighbor list\n"
3002 "Neighbor ID\n")
3003{
paul020709f2003-04-04 02:44:16 +00003004 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003005 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003006 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003007 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003008 struct in_addr router_id;
3009 int ret;
3010
3011 ret = inet_aton (argv[0], &router_id);
3012 if (!ret)
3013 {
3014 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3015 return CMD_WARNING;
3016 }
3017
paul020709f2003-04-04 02:44:16 +00003018 ospf = ospf_lookup ();
3019 if (ospf == NULL)
3020 {
3021 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3022 return CMD_SUCCESS;
3023 }
3024
paul1eb8ef22005-04-07 07:30:20 +00003025 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3026 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3027 {
3028 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3029 return CMD_SUCCESS;
3030 }
paul718e3742002-12-13 20:15:29 +00003031
3032 /* Nothing to show. */
3033 return CMD_SUCCESS;
3034}
3035
3036DEFUN (show_ip_ospf_neighbor_detail,
3037 show_ip_ospf_neighbor_detail_cmd,
3038 "show ip ospf neighbor detail",
3039 SHOW_STR
3040 IP_STR
3041 "OSPF information\n"
3042 "Neighbor list\n"
3043 "detail of all neighbors\n")
3044{
paul020709f2003-04-04 02:44:16 +00003045 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003046 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003047 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003048
paul020709f2003-04-04 02:44:16 +00003049 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003050 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003051 {
3052 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3053 return CMD_SUCCESS;
3054 }
paul718e3742002-12-13 20:15:29 +00003055
paul1eb8ef22005-04-07 07:30:20 +00003056 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003057 {
paul718e3742002-12-13 20:15:29 +00003058 struct route_node *rn;
3059 struct ospf_neighbor *nbr;
3060
3061 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3062 if ((nbr = rn->info))
3063 if (nbr != oi->nbr_self)
3064 if (nbr->state != NSM_Down)
3065 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3066 }
3067
3068 return CMD_SUCCESS;
3069}
3070
3071DEFUN (show_ip_ospf_neighbor_detail_all,
3072 show_ip_ospf_neighbor_detail_all_cmd,
3073 "show ip ospf neighbor detail all",
3074 SHOW_STR
3075 IP_STR
3076 "OSPF information\n"
3077 "Neighbor list\n"
3078 "detail of all neighbors\n"
3079 "include down status neighbor\n")
3080{
paul020709f2003-04-04 02:44:16 +00003081 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003082 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003083 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003084
paul020709f2003-04-04 02:44:16 +00003085 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003086 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003087 {
3088 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3089 return CMD_SUCCESS;
3090 }
paul718e3742002-12-13 20:15:29 +00003091
paul1eb8ef22005-04-07 07:30:20 +00003092 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003093 {
paul718e3742002-12-13 20:15:29 +00003094 struct route_node *rn;
3095 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003096 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003097
3098 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3099 if ((nbr = rn->info))
3100 if (nbr != oi->nbr_self)
3101 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3102 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3103
3104 if (oi->type == OSPF_IFTYPE_NBMA)
3105 {
hasso52dc7ee2004-09-23 19:18:23 +00003106 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003107
paul1eb8ef22005-04-07 07:30:20 +00003108 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3109 if (nbr_nbma->nbr == NULL
3110 || nbr_nbma->nbr->state == NSM_Down)
3111 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003112 }
3113 }
3114
3115 return CMD_SUCCESS;
3116}
3117
3118DEFUN (show_ip_ospf_neighbor_int_detail,
3119 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003120 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003121 SHOW_STR
3122 IP_STR
3123 "OSPF information\n"
3124 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003125 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003126 "detail of all neighbors")
3127{
paul020709f2003-04-04 02:44:16 +00003128 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003129 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003130 struct interface *ifp;
3131 struct route_node *rn, *nrn;
3132 struct ospf_neighbor *nbr;
3133
3134 ifp = if_lookup_by_name (argv[0]);
3135 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003136 {
hassobb5b7552005-08-21 20:01:15 +00003137 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003138 return CMD_WARNING;
3139 }
3140
paul020709f2003-04-04 02:44:16 +00003141 ospf = ospf_lookup ();
3142 if (ospf == NULL)
3143 {
3144 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3145 return CMD_SUCCESS;
3146 }
paul68980082003-03-25 05:07:42 +00003147
paul718e3742002-12-13 20:15:29 +00003148
hassobb5b7552005-08-21 20:01:15 +00003149 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3150 if ((oi = rn->info))
3151 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3152 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003153 if (nbr != oi->nbr_self)
3154 if (nbr->state != NSM_Down)
3155 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003156
3157 return CMD_SUCCESS;
3158}
3159
3160
3161/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003162static int
paul020709f2003-04-04 02:44:16 +00003163show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003164{
paul718e3742002-12-13 20:15:29 +00003165 struct router_lsa *rl;
3166 struct summary_lsa *sl;
3167 struct as_external_lsa *asel;
3168 struct prefix_ipv4 p;
3169
3170 if (lsa != NULL)
3171 /* If self option is set, check LSA self flag. */
3172 if (self == 0 || IS_LSA_SELF (lsa))
3173 {
3174 /* LSA common part show. */
3175 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3176 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3177 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3178 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3179 /* LSA specific part show. */
3180 switch (lsa->data->type)
3181 {
3182 case OSPF_ROUTER_LSA:
3183 rl = (struct router_lsa *) lsa->data;
3184 vty_out (vty, " %-d", ntohs (rl->links));
3185 break;
3186 case OSPF_SUMMARY_LSA:
3187 sl = (struct summary_lsa *) lsa->data;
3188
3189 p.family = AF_INET;
3190 p.prefix = sl->header.id;
3191 p.prefixlen = ip_masklen (sl->mask);
3192 apply_mask_ipv4 (&p);
3193
3194 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3195 break;
3196 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003197 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003198 asel = (struct as_external_lsa *) lsa->data;
3199
3200 p.family = AF_INET;
3201 p.prefix = asel->header.id;
3202 p.prefixlen = ip_masklen (asel->mask);
3203 apply_mask_ipv4 (&p);
3204
3205 vty_out (vty, " %s %s/%d [0x%lx]",
3206 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3207 inet_ntoa (p.prefix), p.prefixlen,
3208 (u_long)ntohl (asel->e[0].route_tag));
3209 break;
3210 case OSPF_NETWORK_LSA:
3211 case OSPF_ASBR_SUMMARY_LSA:
3212#ifdef HAVE_OPAQUE_LSA
3213 case OSPF_OPAQUE_LINK_LSA:
3214 case OSPF_OPAQUE_AREA_LSA:
3215 case OSPF_OPAQUE_AS_LSA:
3216#endif /* HAVE_OPAQUE_LSA */
3217 default:
3218 break;
3219 }
3220 vty_out (vty, VTY_NEWLINE);
3221 }
3222
3223 return 0;
3224}
3225
hassoeb1ce602004-10-08 08:17:22 +00003226const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003227{
3228 "unknown",
3229 "Router Link States",
3230 "Net Link States",
3231 "Summary Link States",
3232 "ASBR-Summary Link States",
3233 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003234 "Group Membership LSA",
3235 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003236#ifdef HAVE_OPAQUE_LSA
3237 "Type-8 LSA",
3238 "Link-Local Opaque-LSA",
3239 "Area-Local Opaque-LSA",
3240 "AS-external Opaque-LSA",
3241#endif /* HAVE_OPAQUE_LSA */
3242};
3243
3244#define SHOW_OSPF_COMMON_HEADER \
3245 "Link ID ADV Router Age Seq# CkSum"
3246
hassoeb1ce602004-10-08 08:17:22 +00003247const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003248{
3249 "",
3250 "Link ID ADV Router Age Seq# CkSum Link count",
3251 "Link ID ADV Router Age Seq# CkSum",
3252 "Link ID ADV Router Age Seq# CkSum Route",
3253 "Link ID ADV Router Age Seq# CkSum",
3254 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003255 " --- header for Group Member ----",
3256 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003257#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003258 " --- type-8 ---",
3259 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3260 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3261 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3262#endif /* HAVE_OPAQUE_LSA */
3263};
3264
hassoeb1ce602004-10-08 08:17:22 +00003265const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003266{
3267 "Self-originated",
3268 "Checked",
3269 "Received",
3270 "Approved",
3271 "Discard",
paul4957f492003-06-27 01:28:45 +00003272 "Translated",
paul4957f492003-06-27 01:28:45 +00003273};
3274
paul4dadc292005-05-06 21:37:42 +00003275static void
paul718e3742002-12-13 20:15:29 +00003276show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3277{
3278 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003279
paul718e3742002-12-13 20:15:29 +00003280 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003281 vty_out (vty, " Options: 0x%-2x : %s%s",
3282 lsa->data->options,
3283 ospf_options_dump(lsa->data->options),
3284 VTY_NEWLINE);
3285 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003286 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003287 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3288 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003289
3290 if (lsa->data->type == OSPF_ROUTER_LSA)
3291 {
3292 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3293
3294 if (rlsa->flags)
3295 vty_out (vty, " :%s%s%s%s",
3296 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3297 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3298 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3299 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3300
3301 vty_out (vty, "%s", VTY_NEWLINE);
3302 }
3303 vty_out (vty, " LS Type: %s%s",
3304 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3305 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3306 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3307 vty_out (vty, " Advertising Router: %s%s",
3308 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3309 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3310 VTY_NEWLINE);
3311 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3312 VTY_NEWLINE);
3313 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3314}
3315
hassoeb1ce602004-10-08 08:17:22 +00003316const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003317{
3318 "(null)",
3319 "another Router (point-to-point)",
3320 "a Transit Network",
3321 "Stub Network",
3322 "a Virtual Link",
3323};
3324
hassoeb1ce602004-10-08 08:17:22 +00003325const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003326{
3327 "(null)",
3328 "Neighboring Router ID",
3329 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003330 "Net",
paul718e3742002-12-13 20:15:29 +00003331 "Neighboring Router ID",
3332};
3333
hassoeb1ce602004-10-08 08:17:22 +00003334const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003335{
3336 "(null)",
3337 "Router Interface address",
3338 "Router Interface address",
3339 "Network Mask",
3340 "Router Interface address",
3341};
3342
3343/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003344static void
paul718e3742002-12-13 20:15:29 +00003345show_ip_ospf_database_router_links (struct vty *vty,
3346 struct router_lsa *rl)
3347{
3348 int len, i, type;
3349
3350 len = ntohs (rl->header.length) - 4;
3351 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3352 {
3353 type = rl->link[i].type;
3354
3355 vty_out (vty, " Link connected to: %s%s",
3356 link_type_desc[type], VTY_NEWLINE);
3357 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3358 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3359 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3360 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3361 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3362 vty_out (vty, " TOS 0 Metric: %d%s",
3363 ntohs (rl->link[i].metric), VTY_NEWLINE);
3364 vty_out (vty, "%s", VTY_NEWLINE);
3365 }
3366}
3367
3368/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003369static int
paul718e3742002-12-13 20:15:29 +00003370show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3371{
3372 if (lsa != NULL)
3373 {
3374 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3375
3376 show_ip_ospf_database_header (vty, lsa);
3377
3378 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3379 VTY_NEWLINE, VTY_NEWLINE);
3380
3381 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003382 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003383 }
3384
3385 return 0;
3386}
3387
3388/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003389static int
paul718e3742002-12-13 20:15:29 +00003390show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3391{
3392 int length, i;
3393
3394 if (lsa != NULL)
3395 {
3396 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3397
3398 show_ip_ospf_database_header (vty, lsa);
3399
3400 vty_out (vty, " Network Mask: /%d%s",
3401 ip_masklen (nl->mask), VTY_NEWLINE);
3402
3403 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3404
3405 for (i = 0; length > 0; i++, length -= 4)
3406 vty_out (vty, " Attached Router: %s%s",
3407 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3408
3409 vty_out (vty, "%s", VTY_NEWLINE);
3410 }
3411
3412 return 0;
3413}
3414
3415/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003416static int
paul718e3742002-12-13 20:15:29 +00003417show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3418{
3419 if (lsa != NULL)
3420 {
3421 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3422
3423 show_ip_ospf_database_header (vty, lsa);
3424
3425 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3426 VTY_NEWLINE);
3427 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3428 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003429 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003430 }
3431
3432 return 0;
3433}
3434
3435/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003436static int
paul718e3742002-12-13 20:15:29 +00003437show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3438{
3439 if (lsa != NULL)
3440 {
3441 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3442
3443 show_ip_ospf_database_header (vty, lsa);
3444
3445 vty_out (vty, " Network Mask: /%d%s",
3446 ip_masklen (sl->mask), VTY_NEWLINE);
3447 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3448 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003449 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003450 }
3451
3452 return 0;
3453}
3454
3455/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003456static int
paul718e3742002-12-13 20:15:29 +00003457show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3458{
3459 if (lsa != NULL)
3460 {
3461 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3462
3463 show_ip_ospf_database_header (vty, lsa);
3464
3465 vty_out (vty, " Network Mask: /%d%s",
3466 ip_masklen (al->mask), VTY_NEWLINE);
3467 vty_out (vty, " Metric Type: %s%s",
3468 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3469 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3470 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3471 vty_out (vty, " Metric: %d%s",
3472 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3473 vty_out (vty, " Forward Address: %s%s",
3474 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3475
3476 vty_out (vty, " External Route Tag: %lu%s%s",
3477 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3478 }
3479
3480 return 0;
3481}
3482
ajs2a42e282004-12-08 18:43:03 +00003483/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003484static int
paul718e3742002-12-13 20:15:29 +00003485show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3486{
3487 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3488
3489 /* show_ip_ospf_database_header (vty, lsa); */
3490
ajs2a42e282004-12-08 18:43:03 +00003491 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003492 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003493 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003494 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3495 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003496 zlog_debug( " TOS: 0%s", "\n");
3497 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003498 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003499 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003500 inet_ntoa (al->e[0].fwd_addr), "\n");
3501
ajs2a42e282004-12-08 18:43:03 +00003502 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003503 ntohl (al->e[0].route_tag), "\n", "\n");
3504
3505 return 0;
3506}
3507
3508/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003509static int
paul718e3742002-12-13 20:15:29 +00003510show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3511{
3512 if (lsa != NULL)
3513 {
3514 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3515
3516 show_ip_ospf_database_header (vty, lsa);
3517
3518 vty_out (vty, " Network Mask: /%d%s",
3519 ip_masklen (al->mask), VTY_NEWLINE);
3520 vty_out (vty, " Metric Type: %s%s",
3521 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3522 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3523 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3524 vty_out (vty, " Metric: %d%s",
3525 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3526 vty_out (vty, " NSSA: Forward Address: %s%s",
3527 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3528
3529 vty_out (vty, " External Route Tag: %u%s%s",
3530 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3531 }
3532
3533 return 0;
3534}
3535
paul4dadc292005-05-06 21:37:42 +00003536static int
paul718e3742002-12-13 20:15:29 +00003537show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3538{
3539 return 0;
3540}
3541
3542#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003543static int
paul718e3742002-12-13 20:15:29 +00003544show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3545{
3546 if (lsa != NULL)
3547 {
3548 show_ip_ospf_database_header (vty, lsa);
3549 show_opaque_info_detail (vty, lsa);
3550
3551 vty_out (vty, "%s", VTY_NEWLINE);
3552 }
3553 return 0;
3554}
3555#endif /* HAVE_OPAQUE_LSA */
3556
3557int (*show_function[])(struct vty *, struct ospf_lsa *) =
3558{
3559 NULL,
3560 show_router_lsa_detail,
3561 show_network_lsa_detail,
3562 show_summary_lsa_detail,
3563 show_summary_asbr_lsa_detail,
3564 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003565 show_func_dummy,
3566 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003567#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003568 NULL, /* type-8 */
3569 show_opaque_lsa_detail,
3570 show_opaque_lsa_detail,
3571 show_opaque_lsa_detail,
3572#endif /* HAVE_OPAQUE_LSA */
3573};
3574
paul4dadc292005-05-06 21:37:42 +00003575static void
paul718e3742002-12-13 20:15:29 +00003576show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3577 struct in_addr *adv_router)
3578{
3579 memset (lp, 0, sizeof (struct prefix_ls));
3580 lp->family = 0;
3581 if (id == NULL)
3582 lp->prefixlen = 0;
3583 else if (adv_router == NULL)
3584 {
3585 lp->prefixlen = 32;
3586 lp->id = *id;
3587 }
3588 else
3589 {
3590 lp->prefixlen = 64;
3591 lp->id = *id;
3592 lp->adv_router = *adv_router;
3593 }
3594}
3595
paul4dadc292005-05-06 21:37:42 +00003596static void
paul718e3742002-12-13 20:15:29 +00003597show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3598 struct in_addr *id, struct in_addr *adv_router)
3599{
3600 struct prefix_ls lp;
3601 struct route_node *rn, *start;
3602 struct ospf_lsa *lsa;
3603
3604 show_lsa_prefix_set (vty, &lp, id, adv_router);
3605 start = route_node_get (rt, (struct prefix *) &lp);
3606 if (start)
3607 {
3608 route_lock_node (start);
3609 for (rn = start; rn; rn = route_next_until (rn, start))
3610 if ((lsa = rn->info))
3611 {
paul718e3742002-12-13 20:15:29 +00003612 if (show_function[lsa->data->type] != NULL)
3613 show_function[lsa->data->type] (vty, lsa);
3614 }
3615 route_unlock_node (start);
3616 }
3617}
3618
3619/* Show detail LSA information
3620 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003621static void
paul020709f2003-04-04 02:44:16 +00003622show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003623 struct in_addr *id, struct in_addr *adv_router)
3624{
hasso52dc7ee2004-09-23 19:18:23 +00003625 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003626 struct ospf_area *area;
3627
paul718e3742002-12-13 20:15:29 +00003628 switch (type)
3629 {
3630 case OSPF_AS_EXTERNAL_LSA:
3631#ifdef HAVE_OPAQUE_LSA
3632 case OSPF_OPAQUE_AS_LSA:
3633#endif /* HAVE_OPAQUE_LSA */
3634 vty_out (vty, " %s %s%s",
3635 show_database_desc[type],
3636 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003637 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003638 break;
3639 default:
paul1eb8ef22005-04-07 07:30:20 +00003640 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003641 {
paul718e3742002-12-13 20:15:29 +00003642 vty_out (vty, "%s %s (Area %s)%s%s",
3643 VTY_NEWLINE, show_database_desc[type],
3644 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3645 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3646 }
3647 break;
3648 }
3649}
3650
paul4dadc292005-05-06 21:37:42 +00003651static void
paul718e3742002-12-13 20:15:29 +00003652show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3653 struct in_addr *adv_router)
3654{
3655 struct route_node *rn;
3656 struct ospf_lsa *lsa;
3657
3658 for (rn = route_top (rt); rn; rn = route_next (rn))
3659 if ((lsa = rn->info))
3660 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3661 {
paul718e3742002-12-13 20:15:29 +00003662 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3663 continue;
paul718e3742002-12-13 20:15:29 +00003664 if (show_function[lsa->data->type] != NULL)
3665 show_function[lsa->data->type] (vty, lsa);
3666 }
3667}
3668
3669/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003670static void
paul020709f2003-04-04 02:44:16 +00003671show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003672 struct in_addr *adv_router)
3673{
hasso52dc7ee2004-09-23 19:18:23 +00003674 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003675 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003676
3677 switch (type)
3678 {
3679 case OSPF_AS_EXTERNAL_LSA:
3680#ifdef HAVE_OPAQUE_LSA
3681 case OSPF_OPAQUE_AS_LSA:
3682#endif /* HAVE_OPAQUE_LSA */
3683 vty_out (vty, " %s %s%s",
3684 show_database_desc[type],
3685 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003686 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003687 adv_router);
3688 break;
3689 default:
paul1eb8ef22005-04-07 07:30:20 +00003690 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003691 {
paul718e3742002-12-13 20:15:29 +00003692 vty_out (vty, "%s %s (Area %s)%s%s",
3693 VTY_NEWLINE, show_database_desc[type],
3694 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3695 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3696 adv_router);
3697 }
3698 break;
3699 }
3700}
3701
paul4dadc292005-05-06 21:37:42 +00003702static void
paul020709f2003-04-04 02:44:16 +00003703show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003704{
paul020709f2003-04-04 02:44:16 +00003705 struct ospf_lsa *lsa;
3706 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003707 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003708 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003709 int type;
3710
paul1eb8ef22005-04-07 07:30:20 +00003711 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003712 {
paul718e3742002-12-13 20:15:29 +00003713 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3714 {
3715 switch (type)
3716 {
3717 case OSPF_AS_EXTERNAL_LSA:
3718#ifdef HAVE_OPAQUE_LSA
3719 case OSPF_OPAQUE_AS_LSA:
3720#endif /* HAVE_OPAQUE_LSA */
3721 continue;
3722 default:
3723 break;
3724 }
3725 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3726 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3727 {
3728 vty_out (vty, " %s (Area %s)%s%s",
3729 show_database_desc[type],
3730 ospf_area_desc_string (area),
3731 VTY_NEWLINE, VTY_NEWLINE);
3732 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3733
paul020709f2003-04-04 02:44:16 +00003734 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3735 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003736
3737 vty_out (vty, "%s", VTY_NEWLINE);
3738 }
3739 }
3740 }
3741
3742 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3743 {
3744 switch (type)
3745 {
3746 case OSPF_AS_EXTERNAL_LSA:
3747#ifdef HAVE_OPAQUE_LSA
3748 case OSPF_OPAQUE_AS_LSA:
3749#endif /* HAVE_OPAQUE_LSA */
3750 break;;
3751 default:
3752 continue;
3753 }
paul68980082003-03-25 05:07:42 +00003754 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3755 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003756 {
3757 vty_out (vty, " %s%s%s",
3758 show_database_desc[type],
3759 VTY_NEWLINE, VTY_NEWLINE);
3760 vty_out (vty, "%s%s", show_database_header[type],
3761 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003762
3763 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3764 show_lsa_summary (vty, lsa, self);
3765
paul718e3742002-12-13 20:15:29 +00003766 vty_out (vty, "%s", VTY_NEWLINE);
3767 }
3768 }
3769
3770 vty_out (vty, "%s", VTY_NEWLINE);
3771}
3772
paul4dadc292005-05-06 21:37:42 +00003773static void
paul020709f2003-04-04 02:44:16 +00003774show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003775{
hasso52dc7ee2004-09-23 19:18:23 +00003776 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003777 struct ospf_lsa *lsa;
3778
3779 vty_out (vty, "%s MaxAge Link States:%s%s",
3780 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3781
paul1eb8ef22005-04-07 07:30:20 +00003782 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3783 {
3784 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3785 vty_out (vty, "Link State ID: %s%s",
3786 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3787 vty_out (vty, "Advertising Router: %s%s",
3788 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3789 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3790 vty_out (vty, "%s", VTY_NEWLINE);
3791 }
paul718e3742002-12-13 20:15:29 +00003792}
3793
paul718e3742002-12-13 20:15:29 +00003794#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3795#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003796
3797#ifdef HAVE_OPAQUE_LSA
3798#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3799#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3800#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3801#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3802#else /* HAVE_OPAQUE_LSA */
3803#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3804#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3805#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3806#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3807#endif /* HAVE_OPAQUE_LSA */
3808
3809#define OSPF_LSA_TYPES_CMD_STR \
3810 "asbr-summary|external|network|router|summary" \
3811 OSPF_LSA_TYPE_NSSA_CMD_STR \
3812 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3813
3814#define OSPF_LSA_TYPES_DESC \
3815 "ASBR summary link states\n" \
3816 "External link states\n" \
3817 "Network link states\n" \
3818 "Router link states\n" \
3819 "Network summary link states\n" \
3820 OSPF_LSA_TYPE_NSSA_DESC \
3821 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3822 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3823 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3824
3825DEFUN (show_ip_ospf_database,
3826 show_ip_ospf_database_cmd,
3827 "show ip ospf database",
3828 SHOW_STR
3829 IP_STR
3830 "OSPF information\n"
3831 "Database summary\n")
3832{
paul020709f2003-04-04 02:44:16 +00003833 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003834 int type, ret;
3835 struct in_addr id, adv_router;
3836
paul020709f2003-04-04 02:44:16 +00003837 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003838 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003839 return CMD_SUCCESS;
3840
3841 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003842 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003843
3844 /* Show all LSA. */
3845 if (argc == 0)
3846 {
paul020709f2003-04-04 02:44:16 +00003847 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003848 return CMD_SUCCESS;
3849 }
3850
3851 /* Set database type to show. */
3852 if (strncmp (argv[0], "r", 1) == 0)
3853 type = OSPF_ROUTER_LSA;
3854 else if (strncmp (argv[0], "ne", 2) == 0)
3855 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003856 else if (strncmp (argv[0], "ns", 2) == 0)
3857 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003858 else if (strncmp (argv[0], "su", 2) == 0)
3859 type = OSPF_SUMMARY_LSA;
3860 else if (strncmp (argv[0], "a", 1) == 0)
3861 type = OSPF_ASBR_SUMMARY_LSA;
3862 else if (strncmp (argv[0], "e", 1) == 0)
3863 type = OSPF_AS_EXTERNAL_LSA;
3864 else if (strncmp (argv[0], "se", 2) == 0)
3865 {
paul020709f2003-04-04 02:44:16 +00003866 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003867 return CMD_SUCCESS;
3868 }
3869 else if (strncmp (argv[0], "m", 1) == 0)
3870 {
paul020709f2003-04-04 02:44:16 +00003871 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003872 return CMD_SUCCESS;
3873 }
3874#ifdef HAVE_OPAQUE_LSA
3875 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3876 type = OSPF_OPAQUE_LINK_LSA;
3877 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3878 type = OSPF_OPAQUE_AREA_LSA;
3879 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3880 type = OSPF_OPAQUE_AS_LSA;
3881#endif /* HAVE_OPAQUE_LSA */
3882 else
3883 return CMD_WARNING;
3884
3885 /* `show ip ospf database LSA'. */
3886 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003887 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003888 else if (argc >= 2)
3889 {
3890 ret = inet_aton (argv[1], &id);
3891 if (!ret)
3892 return CMD_WARNING;
3893
3894 /* `show ip ospf database LSA ID'. */
3895 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003896 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003897 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3898 else if (argc == 3)
3899 {
3900 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003901 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003902 else
3903 {
3904 ret = inet_aton (argv[2], &adv_router);
3905 if (!ret)
3906 return CMD_WARNING;
3907 }
paul020709f2003-04-04 02:44:16 +00003908 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003909 }
3910 }
3911
3912 return CMD_SUCCESS;
3913}
3914
3915ALIAS (show_ip_ospf_database,
3916 show_ip_ospf_database_type_cmd,
3917 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3918 SHOW_STR
3919 IP_STR
3920 "OSPF information\n"
3921 "Database summary\n"
3922 OSPF_LSA_TYPES_DESC
3923 "LSAs in MaxAge list\n"
3924 "Self-originated link states\n")
3925
3926ALIAS (show_ip_ospf_database,
3927 show_ip_ospf_database_type_id_cmd,
3928 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3929 SHOW_STR
3930 IP_STR
3931 "OSPF information\n"
3932 "Database summary\n"
3933 OSPF_LSA_TYPES_DESC
3934 "Link State ID (as an IP address)\n")
3935
3936ALIAS (show_ip_ospf_database,
3937 show_ip_ospf_database_type_id_adv_router_cmd,
3938 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3939 SHOW_STR
3940 IP_STR
3941 "OSPF information\n"
3942 "Database summary\n"
3943 OSPF_LSA_TYPES_DESC
3944 "Link State ID (as an IP address)\n"
3945 "Advertising Router link states\n"
3946 "Advertising Router (as an IP address)\n")
3947
3948ALIAS (show_ip_ospf_database,
3949 show_ip_ospf_database_type_id_self_cmd,
3950 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3951 SHOW_STR
3952 IP_STR
3953 "OSPF information\n"
3954 "Database summary\n"
3955 OSPF_LSA_TYPES_DESC
3956 "Link State ID (as an IP address)\n"
3957 "Self-originated link states\n"
3958 "\n")
3959
3960DEFUN (show_ip_ospf_database_type_adv_router,
3961 show_ip_ospf_database_type_adv_router_cmd,
3962 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3963 SHOW_STR
3964 IP_STR
3965 "OSPF information\n"
3966 "Database summary\n"
3967 OSPF_LSA_TYPES_DESC
3968 "Advertising Router link states\n"
3969 "Advertising Router (as an IP address)\n")
3970{
paul020709f2003-04-04 02:44:16 +00003971 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003972 int type, ret;
3973 struct in_addr adv_router;
3974
paul020709f2003-04-04 02:44:16 +00003975 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003976 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003977 return CMD_SUCCESS;
3978
3979 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003980 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003981
3982 if (argc != 2)
3983 return CMD_WARNING;
3984
3985 /* Set database type to show. */
3986 if (strncmp (argv[0], "r", 1) == 0)
3987 type = OSPF_ROUTER_LSA;
3988 else if (strncmp (argv[0], "ne", 2) == 0)
3989 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003990 else if (strncmp (argv[0], "ns", 2) == 0)
3991 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003992 else if (strncmp (argv[0], "s", 1) == 0)
3993 type = OSPF_SUMMARY_LSA;
3994 else if (strncmp (argv[0], "a", 1) == 0)
3995 type = OSPF_ASBR_SUMMARY_LSA;
3996 else if (strncmp (argv[0], "e", 1) == 0)
3997 type = OSPF_AS_EXTERNAL_LSA;
3998#ifdef HAVE_OPAQUE_LSA
3999 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4000 type = OSPF_OPAQUE_LINK_LSA;
4001 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4002 type = OSPF_OPAQUE_AREA_LSA;
4003 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4004 type = OSPF_OPAQUE_AS_LSA;
4005#endif /* HAVE_OPAQUE_LSA */
4006 else
4007 return CMD_WARNING;
4008
4009 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4010 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004011 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004012 else
4013 {
4014 ret = inet_aton (argv[1], &adv_router);
4015 if (!ret)
4016 return CMD_WARNING;
4017 }
4018
paul020709f2003-04-04 02:44:16 +00004019 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004020
4021 return CMD_SUCCESS;
4022}
4023
4024ALIAS (show_ip_ospf_database_type_adv_router,
4025 show_ip_ospf_database_type_self_cmd,
4026 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4027 SHOW_STR
4028 IP_STR
4029 "OSPF information\n"
4030 "Database summary\n"
4031 OSPF_LSA_TYPES_DESC
4032 "Self-originated link states\n")
4033
4034
4035DEFUN (ip_ospf_authentication_args,
4036 ip_ospf_authentication_args_addr_cmd,
4037 "ip ospf authentication (null|message-digest) A.B.C.D",
4038 "IP Information\n"
4039 "OSPF interface commands\n"
4040 "Enable authentication on this interface\n"
4041 "Use null authentication\n"
4042 "Use message-digest authentication\n"
4043 "Address of interface")
4044{
4045 struct interface *ifp;
4046 struct in_addr addr;
4047 int ret;
4048 struct ospf_if_params *params;
4049
4050 ifp = vty->index;
4051 params = IF_DEF_PARAMS (ifp);
4052
4053 if (argc == 2)
4054 {
4055 ret = inet_aton(argv[1], &addr);
4056 if (!ret)
4057 {
4058 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4059 VTY_NEWLINE);
4060 return CMD_WARNING;
4061 }
4062
4063 params = ospf_get_if_params (ifp, addr);
4064 ospf_if_update_params (ifp, addr);
4065 }
4066
4067 /* Handle null authentication */
4068 if ( argv[0][0] == 'n' )
4069 {
4070 SET_IF_PARAM (params, auth_type);
4071 params->auth_type = OSPF_AUTH_NULL;
4072 return CMD_SUCCESS;
4073 }
4074
4075 /* Handle message-digest authentication */
4076 if ( argv[0][0] == 'm' )
4077 {
4078 SET_IF_PARAM (params, auth_type);
4079 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4080 return CMD_SUCCESS;
4081 }
4082
4083 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4084 return CMD_WARNING;
4085}
4086
4087ALIAS (ip_ospf_authentication_args,
4088 ip_ospf_authentication_args_cmd,
4089 "ip ospf authentication (null|message-digest)",
4090 "IP Information\n"
4091 "OSPF interface commands\n"
4092 "Enable authentication on this interface\n"
4093 "Use null authentication\n"
4094 "Use message-digest authentication\n")
4095
4096DEFUN (ip_ospf_authentication,
4097 ip_ospf_authentication_addr_cmd,
4098 "ip ospf authentication A.B.C.D",
4099 "IP Information\n"
4100 "OSPF interface commands\n"
4101 "Enable authentication on this interface\n"
4102 "Address of interface")
4103{
4104 struct interface *ifp;
4105 struct in_addr addr;
4106 int ret;
4107 struct ospf_if_params *params;
4108
4109 ifp = vty->index;
4110 params = IF_DEF_PARAMS (ifp);
4111
4112 if (argc == 1)
4113 {
4114 ret = inet_aton(argv[1], &addr);
4115 if (!ret)
4116 {
4117 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4118 VTY_NEWLINE);
4119 return CMD_WARNING;
4120 }
4121
4122 params = ospf_get_if_params (ifp, addr);
4123 ospf_if_update_params (ifp, addr);
4124 }
4125
4126 SET_IF_PARAM (params, auth_type);
4127 params->auth_type = OSPF_AUTH_SIMPLE;
4128
4129 return CMD_SUCCESS;
4130}
4131
4132ALIAS (ip_ospf_authentication,
4133 ip_ospf_authentication_cmd,
4134 "ip ospf authentication",
4135 "IP Information\n"
4136 "OSPF interface commands\n"
4137 "Enable authentication on this interface\n")
4138
4139DEFUN (no_ip_ospf_authentication,
4140 no_ip_ospf_authentication_addr_cmd,
4141 "no ip ospf authentication A.B.C.D",
4142 NO_STR
4143 "IP Information\n"
4144 "OSPF interface commands\n"
4145 "Enable authentication on this interface\n"
4146 "Address of interface")
4147{
4148 struct interface *ifp;
4149 struct in_addr addr;
4150 int ret;
4151 struct ospf_if_params *params;
4152
4153 ifp = vty->index;
4154 params = IF_DEF_PARAMS (ifp);
4155
4156 if (argc == 1)
4157 {
4158 ret = inet_aton(argv[1], &addr);
4159 if (!ret)
4160 {
4161 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4162 VTY_NEWLINE);
4163 return CMD_WARNING;
4164 }
4165
4166 params = ospf_lookup_if_params (ifp, addr);
4167 if (params == NULL)
4168 return CMD_SUCCESS;
4169 }
4170
4171 params->auth_type = OSPF_AUTH_NOTSET;
4172 UNSET_IF_PARAM (params, auth_type);
4173
4174 if (params != IF_DEF_PARAMS (ifp))
4175 {
4176 ospf_free_if_params (ifp, addr);
4177 ospf_if_update_params (ifp, addr);
4178 }
4179
4180 return CMD_SUCCESS;
4181}
4182
4183ALIAS (no_ip_ospf_authentication,
4184 no_ip_ospf_authentication_cmd,
4185 "no ip ospf authentication",
4186 NO_STR
4187 "IP Information\n"
4188 "OSPF interface commands\n"
4189 "Enable authentication on this interface\n")
4190
4191DEFUN (ip_ospf_authentication_key,
4192 ip_ospf_authentication_key_addr_cmd,
4193 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4194 "IP Information\n"
4195 "OSPF interface commands\n"
4196 "Authentication password (key)\n"
4197 "The OSPF password (key)\n"
4198 "Address of interface")
4199{
4200 struct interface *ifp;
4201 struct in_addr addr;
4202 int ret;
4203 struct ospf_if_params *params;
4204
4205 ifp = vty->index;
4206 params = IF_DEF_PARAMS (ifp);
4207
4208 if (argc == 2)
4209 {
4210 ret = inet_aton(argv[1], &addr);
4211 if (!ret)
4212 {
4213 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4214 VTY_NEWLINE);
4215 return CMD_WARNING;
4216 }
4217
4218 params = ospf_get_if_params (ifp, addr);
4219 ospf_if_update_params (ifp, addr);
4220 }
4221
4222
4223 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004224 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004225 SET_IF_PARAM (params, auth_simple);
4226
4227 return CMD_SUCCESS;
4228}
4229
4230ALIAS (ip_ospf_authentication_key,
4231 ip_ospf_authentication_key_cmd,
4232 "ip ospf authentication-key AUTH_KEY",
4233 "IP Information\n"
4234 "OSPF interface commands\n"
4235 "Authentication password (key)\n"
4236 "The OSPF password (key)")
4237
4238ALIAS (ip_ospf_authentication_key,
4239 ospf_authentication_key_cmd,
4240 "ospf authentication-key AUTH_KEY",
4241 "OSPF interface commands\n"
4242 "Authentication password (key)\n"
4243 "The OSPF password (key)")
4244
4245DEFUN (no_ip_ospf_authentication_key,
4246 no_ip_ospf_authentication_key_addr_cmd,
4247 "no ip ospf authentication-key A.B.C.D",
4248 NO_STR
4249 "IP Information\n"
4250 "OSPF interface commands\n"
4251 "Authentication password (key)\n"
4252 "Address of interface")
4253{
4254 struct interface *ifp;
4255 struct in_addr addr;
4256 int ret;
4257 struct ospf_if_params *params;
4258
4259 ifp = vty->index;
4260 params = IF_DEF_PARAMS (ifp);
4261
4262 if (argc == 2)
4263 {
4264 ret = inet_aton(argv[1], &addr);
4265 if (!ret)
4266 {
4267 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4268 VTY_NEWLINE);
4269 return CMD_WARNING;
4270 }
4271
4272 params = ospf_lookup_if_params (ifp, addr);
4273 if (params == NULL)
4274 return CMD_SUCCESS;
4275 }
4276
4277 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4278 UNSET_IF_PARAM (params, auth_simple);
4279
4280 if (params != IF_DEF_PARAMS (ifp))
4281 {
4282 ospf_free_if_params (ifp, addr);
4283 ospf_if_update_params (ifp, addr);
4284 }
4285
4286 return CMD_SUCCESS;
4287}
4288
4289ALIAS (no_ip_ospf_authentication_key,
4290 no_ip_ospf_authentication_key_cmd,
4291 "no ip ospf authentication-key",
4292 NO_STR
4293 "IP Information\n"
4294 "OSPF interface commands\n"
4295 "Authentication password (key)\n")
4296
4297ALIAS (no_ip_ospf_authentication_key,
4298 no_ospf_authentication_key_cmd,
4299 "no ospf authentication-key",
4300 NO_STR
4301 "OSPF interface commands\n"
4302 "Authentication password (key)\n")
4303
4304DEFUN (ip_ospf_message_digest_key,
4305 ip_ospf_message_digest_key_addr_cmd,
4306 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4307 "IP Information\n"
4308 "OSPF interface commands\n"
4309 "Message digest authentication password (key)\n"
4310 "Key ID\n"
4311 "Use MD5 algorithm\n"
4312 "The OSPF password (key)"
4313 "Address of interface")
4314{
4315 struct interface *ifp;
4316 struct crypt_key *ck;
4317 u_char key_id;
4318 struct in_addr addr;
4319 int ret;
4320 struct ospf_if_params *params;
4321
4322 ifp = vty->index;
4323 params = IF_DEF_PARAMS (ifp);
4324
4325 if (argc == 3)
4326 {
4327 ret = inet_aton(argv[2], &addr);
4328 if (!ret)
4329 {
4330 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4331 VTY_NEWLINE);
4332 return CMD_WARNING;
4333 }
4334
4335 params = ospf_get_if_params (ifp, addr);
4336 ospf_if_update_params (ifp, addr);
4337 }
4338
4339 key_id = strtol (argv[0], NULL, 10);
4340 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4341 {
4342 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4343 return CMD_WARNING;
4344 }
4345
4346 ck = ospf_crypt_key_new ();
4347 ck->key_id = (u_char) key_id;
4348 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004349 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004350
4351 ospf_crypt_key_add (params->auth_crypt, ck);
4352 SET_IF_PARAM (params, auth_crypt);
4353
4354 return CMD_SUCCESS;
4355}
4356
4357ALIAS (ip_ospf_message_digest_key,
4358 ip_ospf_message_digest_key_cmd,
4359 "ip ospf message-digest-key <1-255> md5 KEY",
4360 "IP Information\n"
4361 "OSPF interface commands\n"
4362 "Message digest authentication password (key)\n"
4363 "Key ID\n"
4364 "Use MD5 algorithm\n"
4365 "The OSPF password (key)")
4366
4367ALIAS (ip_ospf_message_digest_key,
4368 ospf_message_digest_key_cmd,
4369 "ospf message-digest-key <1-255> md5 KEY",
4370 "OSPF interface commands\n"
4371 "Message digest authentication password (key)\n"
4372 "Key ID\n"
4373 "Use MD5 algorithm\n"
4374 "The OSPF password (key)")
4375
4376DEFUN (no_ip_ospf_message_digest_key,
4377 no_ip_ospf_message_digest_key_addr_cmd,
4378 "no ip ospf message-digest-key <1-255> A.B.C.D",
4379 NO_STR
4380 "IP Information\n"
4381 "OSPF interface commands\n"
4382 "Message digest authentication password (key)\n"
4383 "Key ID\n"
4384 "Address of interface")
4385{
4386 struct interface *ifp;
4387 struct crypt_key *ck;
4388 int key_id;
4389 struct in_addr addr;
4390 int ret;
4391 struct ospf_if_params *params;
4392
4393 ifp = vty->index;
4394 params = IF_DEF_PARAMS (ifp);
4395
4396 if (argc == 2)
4397 {
4398 ret = inet_aton(argv[1], &addr);
4399 if (!ret)
4400 {
4401 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4402 VTY_NEWLINE);
4403 return CMD_WARNING;
4404 }
4405
4406 params = ospf_lookup_if_params (ifp, addr);
4407 if (params == NULL)
4408 return CMD_SUCCESS;
4409 }
4410
4411 key_id = strtol (argv[0], NULL, 10);
4412 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4413 if (ck == NULL)
4414 {
4415 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4416 return CMD_WARNING;
4417 }
4418
4419 ospf_crypt_key_delete (params->auth_crypt, key_id);
4420
4421 if (params != IF_DEF_PARAMS (ifp))
4422 {
4423 ospf_free_if_params (ifp, addr);
4424 ospf_if_update_params (ifp, addr);
4425 }
4426
4427 return CMD_SUCCESS;
4428}
4429
4430ALIAS (no_ip_ospf_message_digest_key,
4431 no_ip_ospf_message_digest_key_cmd,
4432 "no ip ospf message-digest-key <1-255>",
4433 NO_STR
4434 "IP Information\n"
4435 "OSPF interface commands\n"
4436 "Message digest authentication password (key)\n"
4437 "Key ID\n")
4438
4439ALIAS (no_ip_ospf_message_digest_key,
4440 no_ospf_message_digest_key_cmd,
4441 "no ospf message-digest-key <1-255>",
4442 NO_STR
4443 "OSPF interface commands\n"
4444 "Message digest authentication password (key)\n"
4445 "Key ID\n")
4446
4447DEFUN (ip_ospf_cost,
4448 ip_ospf_cost_addr_cmd,
4449 "ip ospf cost <1-65535> A.B.C.D",
4450 "IP Information\n"
4451 "OSPF interface commands\n"
4452 "Interface cost\n"
4453 "Cost\n"
4454 "Address of interface")
4455{
4456 struct interface *ifp = vty->index;
4457 u_int32_t cost;
4458 struct in_addr addr;
4459 int ret;
4460 struct ospf_if_params *params;
4461
4462 params = IF_DEF_PARAMS (ifp);
4463
4464 cost = strtol (argv[0], NULL, 10);
4465
4466 /* cost range is <1-65535>. */
4467 if (cost < 1 || cost > 65535)
4468 {
4469 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4470 return CMD_WARNING;
4471 }
4472
4473 if (argc == 2)
4474 {
4475 ret = inet_aton(argv[1], &addr);
4476 if (!ret)
4477 {
4478 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4479 VTY_NEWLINE);
4480 return CMD_WARNING;
4481 }
4482
4483 params = ospf_get_if_params (ifp, addr);
4484 ospf_if_update_params (ifp, addr);
4485 }
4486
4487 SET_IF_PARAM (params, output_cost_cmd);
4488 params->output_cost_cmd = cost;
4489
4490 ospf_if_recalculate_output_cost (ifp);
4491
4492 return CMD_SUCCESS;
4493}
4494
4495ALIAS (ip_ospf_cost,
4496 ip_ospf_cost_cmd,
4497 "ip ospf cost <1-65535>",
4498 "IP Information\n"
4499 "OSPF interface commands\n"
4500 "Interface cost\n"
4501 "Cost")
4502
4503ALIAS (ip_ospf_cost,
4504 ospf_cost_cmd,
4505 "ospf cost <1-65535>",
4506 "OSPF interface commands\n"
4507 "Interface cost\n"
4508 "Cost")
4509
4510DEFUN (no_ip_ospf_cost,
4511 no_ip_ospf_cost_addr_cmd,
4512 "no ip ospf cost A.B.C.D",
4513 NO_STR
4514 "IP Information\n"
4515 "OSPF interface commands\n"
4516 "Interface cost\n"
4517 "Address of interface")
4518{
4519 struct interface *ifp = vty->index;
4520 struct in_addr addr;
4521 int ret;
4522 struct ospf_if_params *params;
4523
4524 ifp = vty->index;
4525 params = IF_DEF_PARAMS (ifp);
4526
4527 if (argc == 1)
4528 {
4529 ret = inet_aton(argv[0], &addr);
4530 if (!ret)
4531 {
4532 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4533 VTY_NEWLINE);
4534 return CMD_WARNING;
4535 }
4536
4537 params = ospf_lookup_if_params (ifp, addr);
4538 if (params == NULL)
4539 return CMD_SUCCESS;
4540 }
4541
4542 UNSET_IF_PARAM (params, output_cost_cmd);
4543
4544 if (params != IF_DEF_PARAMS (ifp))
4545 {
4546 ospf_free_if_params (ifp, addr);
4547 ospf_if_update_params (ifp, addr);
4548 }
4549
4550 ospf_if_recalculate_output_cost (ifp);
4551
4552 return CMD_SUCCESS;
4553}
4554
4555ALIAS (no_ip_ospf_cost,
4556 no_ip_ospf_cost_cmd,
4557 "no ip ospf cost",
4558 NO_STR
4559 "IP Information\n"
4560 "OSPF interface commands\n"
4561 "Interface cost\n")
4562
4563ALIAS (no_ip_ospf_cost,
4564 no_ospf_cost_cmd,
4565 "no ospf cost",
4566 NO_STR
4567 "OSPF interface commands\n"
4568 "Interface cost\n")
4569
paul4dadc292005-05-06 21:37:42 +00004570static void
paul718e3742002-12-13 20:15:29 +00004571ospf_nbr_timer_update (struct ospf_interface *oi)
4572{
4573 struct route_node *rn;
4574 struct ospf_neighbor *nbr;
4575
4576 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4577 if ((nbr = rn->info))
4578 {
4579 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4580 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4581 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4582 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4583 }
4584}
4585
4586DEFUN (ip_ospf_dead_interval,
4587 ip_ospf_dead_interval_addr_cmd,
4588 "ip ospf dead-interval <1-65535> A.B.C.D",
4589 "IP Information\n"
4590 "OSPF interface commands\n"
4591 "Interval after which a neighbor is declared dead\n"
4592 "Seconds\n"
4593 "Address of interface")
4594{
4595 struct interface *ifp = vty->index;
4596 u_int32_t seconds;
4597 struct in_addr addr;
4598 int ret;
4599 struct ospf_if_params *params;
4600 struct ospf_interface *oi;
4601 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004602 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004603
paul020709f2003-04-04 02:44:16 +00004604 ospf = ospf_lookup ();
4605
paul718e3742002-12-13 20:15:29 +00004606 params = IF_DEF_PARAMS (ifp);
4607
4608 seconds = strtol (argv[0], NULL, 10);
4609
4610 /* dead_interval range is <1-65535>. */
4611 if (seconds < 1 || seconds > 65535)
4612 {
4613 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4614 return CMD_WARNING;
4615 }
4616
4617 if (argc == 2)
4618 {
4619 ret = inet_aton(argv[1], &addr);
4620 if (!ret)
4621 {
4622 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4623 VTY_NEWLINE);
4624 return CMD_WARNING;
4625 }
4626
4627 params = ospf_get_if_params (ifp, addr);
4628 ospf_if_update_params (ifp, addr);
4629 }
4630
4631 SET_IF_PARAM (params, v_wait);
4632 params->v_wait = seconds;
4633
4634 /* Update timer values in neighbor structure. */
4635 if (argc == 2)
4636 {
paul68980082003-03-25 05:07:42 +00004637 if (ospf)
4638 {
4639 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4640 if (oi)
4641 ospf_nbr_timer_update (oi);
4642 }
paul718e3742002-12-13 20:15:29 +00004643 }
4644 else
4645 {
4646 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4647 if ((oi = rn->info))
4648 ospf_nbr_timer_update (oi);
4649 }
4650
4651 return CMD_SUCCESS;
4652}
4653
4654ALIAS (ip_ospf_dead_interval,
4655 ip_ospf_dead_interval_cmd,
4656 "ip ospf dead-interval <1-65535>",
4657 "IP Information\n"
4658 "OSPF interface commands\n"
4659 "Interval after which a neighbor is declared dead\n"
4660 "Seconds\n")
4661
4662ALIAS (ip_ospf_dead_interval,
4663 ospf_dead_interval_cmd,
4664 "ospf dead-interval <1-65535>",
4665 "OSPF interface commands\n"
4666 "Interval after which a neighbor is declared dead\n"
4667 "Seconds\n")
4668
4669DEFUN (no_ip_ospf_dead_interval,
4670 no_ip_ospf_dead_interval_addr_cmd,
4671 "no ip ospf dead-interval A.B.C.D",
4672 NO_STR
4673 "IP Information\n"
4674 "OSPF interface commands\n"
4675 "Interval after which a neighbor is declared dead\n"
4676 "Address of interface")
4677{
4678 struct interface *ifp = vty->index;
4679 struct in_addr addr;
4680 int ret;
4681 struct ospf_if_params *params;
4682 struct ospf_interface *oi;
4683 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004684 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004685
paul020709f2003-04-04 02:44:16 +00004686 ospf = ospf_lookup ();
4687
paul718e3742002-12-13 20:15:29 +00004688 ifp = vty->index;
4689 params = IF_DEF_PARAMS (ifp);
4690
4691 if (argc == 1)
4692 {
4693 ret = inet_aton(argv[0], &addr);
4694 if (!ret)
4695 {
4696 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4697 VTY_NEWLINE);
4698 return CMD_WARNING;
4699 }
4700
4701 params = ospf_lookup_if_params (ifp, addr);
4702 if (params == NULL)
4703 return CMD_SUCCESS;
4704 }
4705
4706 UNSET_IF_PARAM (params, v_wait);
4707 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4708
4709 if (params != IF_DEF_PARAMS (ifp))
4710 {
4711 ospf_free_if_params (ifp, addr);
4712 ospf_if_update_params (ifp, addr);
4713 }
4714
4715 /* Update timer values in neighbor structure. */
4716 if (argc == 1)
4717 {
paul68980082003-03-25 05:07:42 +00004718 if (ospf)
4719 {
4720 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4721 if (oi)
4722 ospf_nbr_timer_update (oi);
4723 }
paul718e3742002-12-13 20:15:29 +00004724 }
4725 else
4726 {
4727 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4728 if ((oi = rn->info))
4729 ospf_nbr_timer_update (oi);
4730 }
4731
4732 return CMD_SUCCESS;
4733}
4734
4735ALIAS (no_ip_ospf_dead_interval,
4736 no_ip_ospf_dead_interval_cmd,
4737 "no ip ospf dead-interval",
4738 NO_STR
4739 "IP Information\n"
4740 "OSPF interface commands\n"
4741 "Interval after which a neighbor is declared dead\n")
4742
4743ALIAS (no_ip_ospf_dead_interval,
4744 no_ospf_dead_interval_cmd,
4745 "no ospf dead-interval",
4746 NO_STR
4747 "OSPF interface commands\n"
4748 "Interval after which a neighbor is declared dead\n")
4749
4750DEFUN (ip_ospf_hello_interval,
4751 ip_ospf_hello_interval_addr_cmd,
4752 "ip ospf hello-interval <1-65535> A.B.C.D",
4753 "IP Information\n"
4754 "OSPF interface commands\n"
4755 "Time between HELLO packets\n"
4756 "Seconds\n"
4757 "Address of interface")
4758{
4759 struct interface *ifp = vty->index;
4760 u_int32_t seconds;
4761 struct in_addr addr;
4762 int ret;
4763 struct ospf_if_params *params;
4764
4765 params = IF_DEF_PARAMS (ifp);
4766
4767 seconds = strtol (argv[0], NULL, 10);
4768
4769 /* HelloInterval range is <1-65535>. */
4770 if (seconds < 1 || seconds > 65535)
4771 {
4772 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4773 return CMD_WARNING;
4774 }
4775
4776 if (argc == 2)
4777 {
4778 ret = inet_aton(argv[1], &addr);
4779 if (!ret)
4780 {
4781 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4782 VTY_NEWLINE);
4783 return CMD_WARNING;
4784 }
4785
4786 params = ospf_get_if_params (ifp, addr);
4787 ospf_if_update_params (ifp, addr);
4788 }
4789
4790 SET_IF_PARAM (params, v_hello);
4791 params->v_hello = seconds;
4792
4793 return CMD_SUCCESS;
4794}
4795
4796ALIAS (ip_ospf_hello_interval,
4797 ip_ospf_hello_interval_cmd,
4798 "ip ospf hello-interval <1-65535>",
4799 "IP Information\n"
4800 "OSPF interface commands\n"
4801 "Time between HELLO packets\n"
4802 "Seconds\n")
4803
4804ALIAS (ip_ospf_hello_interval,
4805 ospf_hello_interval_cmd,
4806 "ospf hello-interval <1-65535>",
4807 "OSPF interface commands\n"
4808 "Time between HELLO packets\n"
4809 "Seconds\n")
4810
4811DEFUN (no_ip_ospf_hello_interval,
4812 no_ip_ospf_hello_interval_addr_cmd,
4813 "no ip ospf hello-interval A.B.C.D",
4814 NO_STR
4815 "IP Information\n"
4816 "OSPF interface commands\n"
4817 "Time between HELLO packets\n"
4818 "Address of interface")
4819{
4820 struct interface *ifp = vty->index;
4821 struct in_addr addr;
4822 int ret;
4823 struct ospf_if_params *params;
4824
4825 ifp = vty->index;
4826 params = IF_DEF_PARAMS (ifp);
4827
4828 if (argc == 1)
4829 {
4830 ret = inet_aton(argv[0], &addr);
4831 if (!ret)
4832 {
4833 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4834 VTY_NEWLINE);
4835 return CMD_WARNING;
4836 }
4837
4838 params = ospf_lookup_if_params (ifp, addr);
4839 if (params == NULL)
4840 return CMD_SUCCESS;
4841 }
4842
4843 UNSET_IF_PARAM (params, v_hello);
4844 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4845
4846 if (params != IF_DEF_PARAMS (ifp))
4847 {
4848 ospf_free_if_params (ifp, addr);
4849 ospf_if_update_params (ifp, addr);
4850 }
4851
4852 return CMD_SUCCESS;
4853}
4854
4855ALIAS (no_ip_ospf_hello_interval,
4856 no_ip_ospf_hello_interval_cmd,
4857 "no ip ospf hello-interval",
4858 NO_STR
4859 "IP Information\n"
4860 "OSPF interface commands\n"
4861 "Time between HELLO packets\n")
4862
4863ALIAS (no_ip_ospf_hello_interval,
4864 no_ospf_hello_interval_cmd,
4865 "no ospf hello-interval",
4866 NO_STR
4867 "OSPF interface commands\n"
4868 "Time between HELLO packets\n")
4869
4870DEFUN (ip_ospf_network,
4871 ip_ospf_network_cmd,
4872 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4873 "IP Information\n"
4874 "OSPF interface commands\n"
4875 "Network type\n"
4876 "Specify OSPF broadcast multi-access network\n"
4877 "Specify OSPF NBMA network\n"
4878 "Specify OSPF point-to-multipoint network\n"
4879 "Specify OSPF point-to-point network\n")
4880{
4881 struct interface *ifp = vty->index;
4882 int old_type = IF_DEF_PARAMS (ifp)->type;
4883 struct route_node *rn;
4884
4885 if (strncmp (argv[0], "b", 1) == 0)
4886 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4887 else if (strncmp (argv[0], "n", 1) == 0)
4888 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4889 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4890 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4891 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4892 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4893
4894 if (IF_DEF_PARAMS (ifp)->type == old_type)
4895 return CMD_SUCCESS;
4896
4897 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4898
4899 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4900 {
4901 struct ospf_interface *oi = rn->info;
4902
4903 if (!oi)
4904 continue;
4905
4906 oi->type = IF_DEF_PARAMS (ifp)->type;
4907
4908 if (oi->state > ISM_Down)
4909 {
4910 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4911 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4912 }
4913 }
4914
4915 return CMD_SUCCESS;
4916}
4917
4918ALIAS (ip_ospf_network,
4919 ospf_network_cmd,
4920 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4921 "OSPF interface commands\n"
4922 "Network type\n"
4923 "Specify OSPF broadcast multi-access network\n"
4924 "Specify OSPF NBMA network\n"
4925 "Specify OSPF point-to-multipoint network\n"
4926 "Specify OSPF point-to-point network\n")
4927
4928DEFUN (no_ip_ospf_network,
4929 no_ip_ospf_network_cmd,
4930 "no ip ospf network",
4931 NO_STR
4932 "IP Information\n"
4933 "OSPF interface commands\n"
4934 "Network type\n")
4935{
4936 struct interface *ifp = vty->index;
4937 int old_type = IF_DEF_PARAMS (ifp)->type;
4938 struct route_node *rn;
4939
ajsbc18d612004-12-15 15:07:19 +00004940 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00004941
4942 if (IF_DEF_PARAMS (ifp)->type == old_type)
4943 return CMD_SUCCESS;
4944
4945 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4946 {
4947 struct ospf_interface *oi = rn->info;
4948
4949 if (!oi)
4950 continue;
4951
4952 oi->type = IF_DEF_PARAMS (ifp)->type;
4953
4954 if (oi->state > ISM_Down)
4955 {
4956 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4957 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4958 }
4959 }
4960
4961 return CMD_SUCCESS;
4962}
4963
4964ALIAS (no_ip_ospf_network,
4965 no_ospf_network_cmd,
4966 "no ospf network",
4967 NO_STR
4968 "OSPF interface commands\n"
4969 "Network type\n")
4970
4971DEFUN (ip_ospf_priority,
4972 ip_ospf_priority_addr_cmd,
4973 "ip ospf priority <0-255> A.B.C.D",
4974 "IP Information\n"
4975 "OSPF interface commands\n"
4976 "Router priority\n"
4977 "Priority\n"
4978 "Address of interface")
4979{
4980 struct interface *ifp = vty->index;
4981 u_int32_t priority;
4982 struct route_node *rn;
4983 struct in_addr addr;
4984 int ret;
4985 struct ospf_if_params *params;
4986
4987 params = IF_DEF_PARAMS (ifp);
4988
4989 priority = strtol (argv[0], NULL, 10);
4990
4991 /* Router Priority range is <0-255>. */
4992 if (priority < 0 || priority > 255)
4993 {
4994 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4995 return CMD_WARNING;
4996 }
4997
4998 if (argc == 2)
4999 {
5000 ret = inet_aton(argv[1], &addr);
5001 if (!ret)
5002 {
5003 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5004 VTY_NEWLINE);
5005 return CMD_WARNING;
5006 }
5007
5008 params = ospf_get_if_params (ifp, addr);
5009 ospf_if_update_params (ifp, addr);
5010 }
5011
5012 SET_IF_PARAM (params, priority);
5013 params->priority = priority;
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
5023 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5024 {
5025 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5026 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5027 }
5028 }
5029
5030 return CMD_SUCCESS;
5031}
5032
5033ALIAS (ip_ospf_priority,
5034 ip_ospf_priority_cmd,
5035 "ip ospf priority <0-255>",
5036 "IP Information\n"
5037 "OSPF interface commands\n"
5038 "Router priority\n"
5039 "Priority\n")
5040
5041ALIAS (ip_ospf_priority,
5042 ospf_priority_cmd,
5043 "ospf priority <0-255>",
5044 "OSPF interface commands\n"
5045 "Router priority\n"
5046 "Priority\n")
5047
5048DEFUN (no_ip_ospf_priority,
5049 no_ip_ospf_priority_addr_cmd,
5050 "no ip ospf priority A.B.C.D",
5051 NO_STR
5052 "IP Information\n"
5053 "OSPF interface commands\n"
5054 "Router priority\n"
5055 "Address of interface")
5056{
5057 struct interface *ifp = vty->index;
5058 struct route_node *rn;
5059 struct in_addr addr;
5060 int ret;
5061 struct ospf_if_params *params;
5062
5063 ifp = vty->index;
5064 params = IF_DEF_PARAMS (ifp);
5065
5066 if (argc == 1)
5067 {
5068 ret = inet_aton(argv[0], &addr);
5069 if (!ret)
5070 {
5071 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5072 VTY_NEWLINE);
5073 return CMD_WARNING;
5074 }
5075
5076 params = ospf_lookup_if_params (ifp, addr);
5077 if (params == NULL)
5078 return CMD_SUCCESS;
5079 }
5080
5081 UNSET_IF_PARAM (params, priority);
5082 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5083
5084 if (params != IF_DEF_PARAMS (ifp))
5085 {
5086 ospf_free_if_params (ifp, addr);
5087 ospf_if_update_params (ifp, addr);
5088 }
5089
5090 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5091 {
5092 struct ospf_interface *oi = rn->info;
5093
5094 if (!oi)
5095 continue;
5096
5097
5098 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5099 {
5100 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5101 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5102 }
5103 }
5104
5105 return CMD_SUCCESS;
5106}
5107
5108ALIAS (no_ip_ospf_priority,
5109 no_ip_ospf_priority_cmd,
5110 "no ip ospf priority",
5111 NO_STR
5112 "IP Information\n"
5113 "OSPF interface commands\n"
5114 "Router priority\n")
5115
5116ALIAS (no_ip_ospf_priority,
5117 no_ospf_priority_cmd,
5118 "no ospf priority",
5119 NO_STR
5120 "OSPF interface commands\n"
5121 "Router priority\n")
5122
5123DEFUN (ip_ospf_retransmit_interval,
5124 ip_ospf_retransmit_interval_addr_cmd,
5125 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5126 "IP Information\n"
5127 "OSPF interface commands\n"
5128 "Time between retransmitting lost link state advertisements\n"
5129 "Seconds\n"
5130 "Address of interface")
5131{
5132 struct interface *ifp = vty->index;
5133 u_int32_t seconds;
5134 struct in_addr addr;
5135 int ret;
5136 struct ospf_if_params *params;
5137
5138 params = IF_DEF_PARAMS (ifp);
5139 seconds = strtol (argv[0], NULL, 10);
5140
5141 /* Retransmit Interval range is <3-65535>. */
5142 if (seconds < 3 || seconds > 65535)
5143 {
5144 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5145 return CMD_WARNING;
5146 }
5147
5148
5149 if (argc == 2)
5150 {
5151 ret = inet_aton(argv[1], &addr);
5152 if (!ret)
5153 {
5154 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5155 VTY_NEWLINE);
5156 return CMD_WARNING;
5157 }
5158
5159 params = ospf_get_if_params (ifp, addr);
5160 ospf_if_update_params (ifp, addr);
5161 }
5162
5163 SET_IF_PARAM (params, retransmit_interval);
5164 params->retransmit_interval = seconds;
5165
5166 return CMD_SUCCESS;
5167}
5168
5169ALIAS (ip_ospf_retransmit_interval,
5170 ip_ospf_retransmit_interval_cmd,
5171 "ip ospf retransmit-interval <3-65535>",
5172 "IP Information\n"
5173 "OSPF interface commands\n"
5174 "Time between retransmitting lost link state advertisements\n"
5175 "Seconds\n")
5176
5177ALIAS (ip_ospf_retransmit_interval,
5178 ospf_retransmit_interval_cmd,
5179 "ospf retransmit-interval <3-65535>",
5180 "OSPF interface commands\n"
5181 "Time between retransmitting lost link state advertisements\n"
5182 "Seconds\n")
5183
5184DEFUN (no_ip_ospf_retransmit_interval,
5185 no_ip_ospf_retransmit_interval_addr_cmd,
5186 "no ip ospf retransmit-interval A.B.C.D",
5187 NO_STR
5188 "IP Information\n"
5189 "OSPF interface commands\n"
5190 "Time between retransmitting lost link state advertisements\n"
5191 "Address of interface")
5192{
5193 struct interface *ifp = vty->index;
5194 struct in_addr addr;
5195 int ret;
5196 struct ospf_if_params *params;
5197
5198 ifp = vty->index;
5199 params = IF_DEF_PARAMS (ifp);
5200
5201 if (argc == 1)
5202 {
5203 ret = inet_aton(argv[0], &addr);
5204 if (!ret)
5205 {
5206 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5207 VTY_NEWLINE);
5208 return CMD_WARNING;
5209 }
5210
5211 params = ospf_lookup_if_params (ifp, addr);
5212 if (params == NULL)
5213 return CMD_SUCCESS;
5214 }
5215
5216 UNSET_IF_PARAM (params, retransmit_interval);
5217 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5218
5219 if (params != IF_DEF_PARAMS (ifp))
5220 {
5221 ospf_free_if_params (ifp, addr);
5222 ospf_if_update_params (ifp, addr);
5223 }
5224
5225 return CMD_SUCCESS;
5226}
5227
5228ALIAS (no_ip_ospf_retransmit_interval,
5229 no_ip_ospf_retransmit_interval_cmd,
5230 "no ip ospf retransmit-interval",
5231 NO_STR
5232 "IP Information\n"
5233 "OSPF interface commands\n"
5234 "Time between retransmitting lost link state advertisements\n")
5235
5236ALIAS (no_ip_ospf_retransmit_interval,
5237 no_ospf_retransmit_interval_cmd,
5238 "no ospf retransmit-interval",
5239 NO_STR
5240 "OSPF interface commands\n"
5241 "Time between retransmitting lost link state advertisements\n")
5242
5243DEFUN (ip_ospf_transmit_delay,
5244 ip_ospf_transmit_delay_addr_cmd,
5245 "ip ospf transmit-delay <1-65535> A.B.C.D",
5246 "IP Information\n"
5247 "OSPF interface commands\n"
5248 "Link state transmit delay\n"
5249 "Seconds\n"
5250 "Address of interface")
5251{
5252 struct interface *ifp = vty->index;
5253 u_int32_t seconds;
5254 struct in_addr addr;
5255 int ret;
5256 struct ospf_if_params *params;
5257
5258 params = IF_DEF_PARAMS (ifp);
5259 seconds = strtol (argv[0], NULL, 10);
5260
5261 /* Transmit Delay range is <1-65535>. */
5262 if (seconds < 1 || seconds > 65535)
5263 {
5264 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5265 return CMD_WARNING;
5266 }
5267
5268 if (argc == 2)
5269 {
5270 ret = inet_aton(argv[1], &addr);
5271 if (!ret)
5272 {
5273 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5274 VTY_NEWLINE);
5275 return CMD_WARNING;
5276 }
5277
5278 params = ospf_get_if_params (ifp, addr);
5279 ospf_if_update_params (ifp, addr);
5280 }
5281
5282 SET_IF_PARAM (params, transmit_delay);
5283 params->transmit_delay = seconds;
5284
5285 return CMD_SUCCESS;
5286}
5287
5288ALIAS (ip_ospf_transmit_delay,
5289 ip_ospf_transmit_delay_cmd,
5290 "ip ospf transmit-delay <1-65535>",
5291 "IP Information\n"
5292 "OSPF interface commands\n"
5293 "Link state transmit delay\n"
5294 "Seconds\n")
5295
5296ALIAS (ip_ospf_transmit_delay,
5297 ospf_transmit_delay_cmd,
5298 "ospf transmit-delay <1-65535>",
5299 "OSPF interface commands\n"
5300 "Link state transmit delay\n"
5301 "Seconds\n")
5302
5303DEFUN (no_ip_ospf_transmit_delay,
5304 no_ip_ospf_transmit_delay_addr_cmd,
5305 "no ip ospf transmit-delay A.B.C.D",
5306 NO_STR
5307 "IP Information\n"
5308 "OSPF interface commands\n"
5309 "Link state transmit delay\n"
5310 "Address of interface")
5311{
5312 struct interface *ifp = vty->index;
5313 struct in_addr addr;
5314 int ret;
5315 struct ospf_if_params *params;
5316
5317 ifp = vty->index;
5318 params = IF_DEF_PARAMS (ifp);
5319
5320 if (argc == 1)
5321 {
5322 ret = inet_aton(argv[0], &addr);
5323 if (!ret)
5324 {
5325 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5326 VTY_NEWLINE);
5327 return CMD_WARNING;
5328 }
5329
5330 params = ospf_lookup_if_params (ifp, addr);
5331 if (params == NULL)
5332 return CMD_SUCCESS;
5333 }
5334
5335 UNSET_IF_PARAM (params, transmit_delay);
5336 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5337
5338 if (params != IF_DEF_PARAMS (ifp))
5339 {
5340 ospf_free_if_params (ifp, addr);
5341 ospf_if_update_params (ifp, addr);
5342 }
5343
5344 return CMD_SUCCESS;
5345}
5346
5347ALIAS (no_ip_ospf_transmit_delay,
5348 no_ip_ospf_transmit_delay_cmd,
5349 "no ip ospf transmit-delay",
5350 NO_STR
5351 "IP Information\n"
5352 "OSPF interface commands\n"
5353 "Link state transmit delay\n")
5354
5355ALIAS (no_ip_ospf_transmit_delay,
5356 no_ospf_transmit_delay_cmd,
5357 "no ospf transmit-delay",
5358 NO_STR
5359 "OSPF interface commands\n"
5360 "Link state transmit delay\n")
5361
5362
5363DEFUN (ospf_redistribute_source_metric_type,
5364 ospf_redistribute_source_metric_type_routemap_cmd,
5365 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5366 "Redistribute information from another routing protocol\n"
5367 "Kernel routes\n"
5368 "Connected\n"
5369 "Static routes\n"
5370 "Routing Information Protocol (RIP)\n"
5371 "Border Gateway Protocol (BGP)\n"
5372 "Metric for redistributed routes\n"
5373 "OSPF default metric\n"
5374 "OSPF exterior metric type for redistributed routes\n"
5375 "Set OSPF External Type 1 metrics\n"
5376 "Set OSPF External Type 2 metrics\n"
5377 "Route map reference\n"
5378 "Pointer to route-map entries\n")
5379{
paul020709f2003-04-04 02:44:16 +00005380 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005381 int source;
5382 int type = -1;
5383 int metric = -1;
5384
5385 /* Get distribute source. */
5386 if (!str2distribute_source (argv[0], &source))
5387 return CMD_WARNING;
5388
5389 /* Get metric value. */
5390 if (argc >= 2)
5391 if (!str2metric (argv[1], &metric))
5392 return CMD_WARNING;
5393
5394 /* Get metric type. */
5395 if (argc >= 3)
5396 if (!str2metric_type (argv[2], &type))
5397 return CMD_WARNING;
5398
5399 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005400 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005401 else
paul020709f2003-04-04 02:44:16 +00005402 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005403
paul020709f2003-04-04 02:44:16 +00005404 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005405}
5406
5407ALIAS (ospf_redistribute_source_metric_type,
5408 ospf_redistribute_source_metric_type_cmd,
5409 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5410 "Redistribute information from another routing protocol\n"
5411 "Kernel routes\n"
5412 "Connected\n"
5413 "Static routes\n"
5414 "Routing Information Protocol (RIP)\n"
5415 "Border Gateway Protocol (BGP)\n"
5416 "Metric for redistributed routes\n"
5417 "OSPF default metric\n"
5418 "OSPF exterior metric type for redistributed routes\n"
5419 "Set OSPF External Type 1 metrics\n"
5420 "Set OSPF External Type 2 metrics\n")
5421
5422ALIAS (ospf_redistribute_source_metric_type,
5423 ospf_redistribute_source_metric_cmd,
5424 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5425 "Redistribute information from another routing protocol\n"
5426 "Kernel routes\n"
5427 "Connected\n"
5428 "Static routes\n"
5429 "Routing Information Protocol (RIP)\n"
5430 "Border Gateway Protocol (BGP)\n"
5431 "Metric for redistributed routes\n"
5432 "OSPF default metric\n")
5433
5434DEFUN (ospf_redistribute_source_type_metric,
5435 ospf_redistribute_source_type_metric_routemap_cmd,
5436 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5437 "Redistribute information from another routing protocol\n"
5438 "Kernel routes\n"
5439 "Connected\n"
5440 "Static routes\n"
5441 "Routing Information Protocol (RIP)\n"
5442 "Border Gateway Protocol (BGP)\n"
5443 "OSPF exterior metric type for redistributed routes\n"
5444 "Set OSPF External Type 1 metrics\n"
5445 "Set OSPF External Type 2 metrics\n"
5446 "Metric for redistributed routes\n"
5447 "OSPF default metric\n"
5448 "Route map reference\n"
5449 "Pointer to route-map entries\n")
5450{
paul020709f2003-04-04 02:44:16 +00005451 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005452 int source;
5453 int type = -1;
5454 int metric = -1;
5455
5456 /* Get distribute source. */
5457 if (!str2distribute_source (argv[0], &source))
5458 return CMD_WARNING;
5459
5460 /* Get metric value. */
5461 if (argc >= 2)
5462 if (!str2metric_type (argv[1], &type))
5463 return CMD_WARNING;
5464
5465 /* Get metric type. */
5466 if (argc >= 3)
5467 if (!str2metric (argv[2], &metric))
5468 return CMD_WARNING;
5469
5470 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005471 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005472 else
paul020709f2003-04-04 02:44:16 +00005473 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005474
paul020709f2003-04-04 02:44:16 +00005475 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005476}
5477
5478ALIAS (ospf_redistribute_source_type_metric,
5479 ospf_redistribute_source_type_metric_cmd,
5480 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5481 "Redistribute information from another routing protocol\n"
5482 "Kernel routes\n"
5483 "Connected\n"
5484 "Static routes\n"
5485 "Routing Information Protocol (RIP)\n"
5486 "Border Gateway Protocol (BGP)\n"
5487 "OSPF exterior metric type for redistributed routes\n"
5488 "Set OSPF External Type 1 metrics\n"
5489 "Set OSPF External Type 2 metrics\n"
5490 "Metric for redistributed routes\n"
5491 "OSPF default metric\n")
5492
5493ALIAS (ospf_redistribute_source_type_metric,
5494 ospf_redistribute_source_type_cmd,
5495 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5496 "Redistribute information from another routing protocol\n"
5497 "Kernel routes\n"
5498 "Connected\n"
5499 "Static routes\n"
5500 "Routing Information Protocol (RIP)\n"
5501 "Border Gateway Protocol (BGP)\n"
5502 "OSPF exterior metric type for redistributed routes\n"
5503 "Set OSPF External Type 1 metrics\n"
5504 "Set OSPF External Type 2 metrics\n")
5505
5506ALIAS (ospf_redistribute_source_type_metric,
5507 ospf_redistribute_source_cmd,
5508 "redistribute (kernel|connected|static|rip|bgp)",
5509 "Redistribute information from another routing protocol\n"
5510 "Kernel routes\n"
5511 "Connected\n"
5512 "Static routes\n"
5513 "Routing Information Protocol (RIP)\n"
5514 "Border Gateway Protocol (BGP)\n")
5515
5516DEFUN (ospf_redistribute_source_metric_routemap,
5517 ospf_redistribute_source_metric_routemap_cmd,
5518 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5519 "Redistribute information from another routing protocol\n"
5520 "Kernel routes\n"
5521 "Connected\n"
5522 "Static routes\n"
5523 "Routing Information Protocol (RIP)\n"
5524 "Border Gateway Protocol (BGP)\n"
5525 "Metric for redistributed routes\n"
5526 "OSPF default metric\n"
5527 "Route map reference\n"
5528 "Pointer to route-map entries\n")
5529{
paul020709f2003-04-04 02:44:16 +00005530 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005531 int source;
5532 int metric = -1;
5533
5534 /* Get distribute source. */
5535 if (!str2distribute_source (argv[0], &source))
5536 return CMD_WARNING;
5537
5538 /* Get metric value. */
5539 if (argc >= 2)
5540 if (!str2metric (argv[1], &metric))
5541 return CMD_WARNING;
5542
5543 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005544 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005545 else
paul020709f2003-04-04 02:44:16 +00005546 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005547
paul020709f2003-04-04 02:44:16 +00005548 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005549}
5550
5551DEFUN (ospf_redistribute_source_type_routemap,
5552 ospf_redistribute_source_type_routemap_cmd,
5553 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5554 "Redistribute information from another routing protocol\n"
5555 "Kernel routes\n"
5556 "Connected\n"
5557 "Static routes\n"
5558 "Routing Information Protocol (RIP)\n"
5559 "Border Gateway Protocol (BGP)\n"
5560 "OSPF exterior metric type for redistributed routes\n"
5561 "Set OSPF External Type 1 metrics\n"
5562 "Set OSPF External Type 2 metrics\n"
5563 "Route map reference\n"
5564 "Pointer to route-map entries\n")
5565{
paul020709f2003-04-04 02:44:16 +00005566 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005567 int source;
5568 int type = -1;
5569
5570 /* Get distribute source. */
5571 if (!str2distribute_source (argv[0], &source))
5572 return CMD_WARNING;
5573
5574 /* Get metric value. */
5575 if (argc >= 2)
5576 if (!str2metric_type (argv[1], &type))
5577 return CMD_WARNING;
5578
5579 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005580 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005581 else
paul020709f2003-04-04 02:44:16 +00005582 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005583
paul020709f2003-04-04 02:44:16 +00005584 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005585}
5586
5587DEFUN (ospf_redistribute_source_routemap,
5588 ospf_redistribute_source_routemap_cmd,
5589 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5590 "Redistribute information from another routing protocol\n"
5591 "Kernel routes\n"
5592 "Connected\n"
5593 "Static routes\n"
5594 "Routing Information Protocol (RIP)\n"
5595 "Border Gateway Protocol (BGP)\n"
5596 "Route map reference\n"
5597 "Pointer to route-map entries\n")
5598{
paul020709f2003-04-04 02:44:16 +00005599 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005600 int source;
5601
5602 /* Get distribute source. */
5603 if (!str2distribute_source (argv[0], &source))
5604 return CMD_WARNING;
5605
5606 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005607 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005608 else
paul020709f2003-04-04 02:44:16 +00005609 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005610
paul020709f2003-04-04 02:44:16 +00005611 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005612}
5613
5614DEFUN (no_ospf_redistribute_source,
5615 no_ospf_redistribute_source_cmd,
5616 "no redistribute (kernel|connected|static|rip|bgp)",
5617 NO_STR
5618 "Redistribute information from another routing protocol\n"
5619 "Kernel routes\n"
5620 "Connected\n"
5621 "Static routes\n"
5622 "Routing Information Protocol (RIP)\n"
5623 "Border Gateway Protocol (BGP)\n")
5624{
paul020709f2003-04-04 02:44:16 +00005625 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005626 int source;
5627
5628 if (!str2distribute_source (argv[0], &source))
5629 return CMD_WARNING;
5630
paul020709f2003-04-04 02:44:16 +00005631 ospf_routemap_unset (ospf, source);
5632 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005633}
5634
5635DEFUN (ospf_distribute_list_out,
5636 ospf_distribute_list_out_cmd,
5637 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5638 "Filter networks in routing updates\n"
5639 "Access-list name\n"
5640 OUT_STR
5641 "Kernel routes\n"
5642 "Connected\n"
5643 "Static routes\n"
5644 "Routing Information Protocol (RIP)\n"
5645 "Border Gateway Protocol (BGP)\n")
5646{
paul68980082003-03-25 05:07:42 +00005647 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005648 int source;
5649
5650 /* Get distribute source. */
5651 if (!str2distribute_source (argv[1], &source))
5652 return CMD_WARNING;
5653
paul68980082003-03-25 05:07:42 +00005654 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005655}
5656
5657DEFUN (no_ospf_distribute_list_out,
5658 no_ospf_distribute_list_out_cmd,
5659 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5660 NO_STR
5661 "Filter networks in routing updates\n"
5662 "Access-list name\n"
5663 OUT_STR
5664 "Kernel routes\n"
5665 "Connected\n"
5666 "Static routes\n"
5667 "Routing Information Protocol (RIP)\n"
5668 "Border Gateway Protocol (BGP)\n")
5669{
paul68980082003-03-25 05:07:42 +00005670 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005671 int source;
5672
5673 if (!str2distribute_source (argv[1], &source))
5674 return CMD_WARNING;
5675
paul68980082003-03-25 05:07:42 +00005676 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005677}
5678
5679/* Default information originate. */
5680DEFUN (ospf_default_information_originate_metric_type_routemap,
5681 ospf_default_information_originate_metric_type_routemap_cmd,
5682 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5683 "Control distribution of default information\n"
5684 "Distribute a default route\n"
5685 "OSPF default metric\n"
5686 "OSPF metric\n"
5687 "OSPF metric type for default routes\n"
5688 "Set OSPF External Type 1 metrics\n"
5689 "Set OSPF External Type 2 metrics\n"
5690 "Route map reference\n"
5691 "Pointer to route-map entries\n")
5692{
paul020709f2003-04-04 02:44:16 +00005693 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005694 int type = -1;
5695 int metric = -1;
5696
5697 /* Get metric value. */
5698 if (argc >= 1)
5699 if (!str2metric (argv[0], &metric))
5700 return CMD_WARNING;
5701
5702 /* Get metric type. */
5703 if (argc >= 2)
5704 if (!str2metric_type (argv[1], &type))
5705 return CMD_WARNING;
5706
5707 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005708 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005709 else
paul020709f2003-04-04 02:44:16 +00005710 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005711
paul020709f2003-04-04 02:44:16 +00005712 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5713 type, metric);
paul718e3742002-12-13 20:15:29 +00005714}
5715
5716ALIAS (ospf_default_information_originate_metric_type_routemap,
5717 ospf_default_information_originate_metric_type_cmd,
5718 "default-information originate metric <0-16777214> metric-type (1|2)",
5719 "Control distribution of default information\n"
5720 "Distribute a default route\n"
5721 "OSPF default metric\n"
5722 "OSPF metric\n"
5723 "OSPF metric type for default routes\n"
5724 "Set OSPF External Type 1 metrics\n"
5725 "Set OSPF External Type 2 metrics\n")
5726
5727ALIAS (ospf_default_information_originate_metric_type_routemap,
5728 ospf_default_information_originate_metric_cmd,
5729 "default-information originate metric <0-16777214>",
5730 "Control distribution of default information\n"
5731 "Distribute a default route\n"
5732 "OSPF default metric\n"
5733 "OSPF metric\n")
5734
5735ALIAS (ospf_default_information_originate_metric_type_routemap,
5736 ospf_default_information_originate_cmd,
5737 "default-information originate",
5738 "Control distribution of default information\n"
5739 "Distribute a default route\n")
5740
5741/* Default information originate. */
5742DEFUN (ospf_default_information_originate_metric_routemap,
5743 ospf_default_information_originate_metric_routemap_cmd,
5744 "default-information originate metric <0-16777214> route-map WORD",
5745 "Control distribution of default information\n"
5746 "Distribute a default route\n"
5747 "OSPF default metric\n"
5748 "OSPF metric\n"
5749 "Route map reference\n"
5750 "Pointer to route-map entries\n")
5751{
paul020709f2003-04-04 02:44:16 +00005752 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005753 int metric = -1;
5754
5755 /* Get metric value. */
5756 if (argc >= 1)
5757 if (!str2metric (argv[0], &metric))
5758 return CMD_WARNING;
5759
5760 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005761 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005762 else
paul020709f2003-04-04 02:44:16 +00005763 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005764
paul020709f2003-04-04 02:44:16 +00005765 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5766 -1, metric);
paul718e3742002-12-13 20:15:29 +00005767}
5768
5769/* Default information originate. */
5770DEFUN (ospf_default_information_originate_routemap,
5771 ospf_default_information_originate_routemap_cmd,
5772 "default-information originate route-map WORD",
5773 "Control distribution of default information\n"
5774 "Distribute a default route\n"
5775 "Route map reference\n"
5776 "Pointer to route-map entries\n")
5777{
paul020709f2003-04-04 02:44:16 +00005778 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005779
paul020709f2003-04-04 02:44:16 +00005780 if (argc == 1)
5781 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5782 else
5783 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5784
5785 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005786}
5787
5788DEFUN (ospf_default_information_originate_type_metric_routemap,
5789 ospf_default_information_originate_type_metric_routemap_cmd,
5790 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5791 "Control distribution of default information\n"
5792 "Distribute a default route\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 "OSPF default metric\n"
5797 "OSPF metric\n"
5798 "Route map reference\n"
5799 "Pointer to route-map entries\n")
5800{
paul020709f2003-04-04 02:44:16 +00005801 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005802 int type = -1;
5803 int metric = -1;
5804
5805 /* Get metric type. */
5806 if (argc >= 1)
5807 if (!str2metric_type (argv[0], &type))
5808 return CMD_WARNING;
5809
5810 /* Get metric value. */
5811 if (argc >= 2)
5812 if (!str2metric (argv[1], &metric))
5813 return CMD_WARNING;
5814
5815 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005816 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005817 else
paul020709f2003-04-04 02:44:16 +00005818 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005819
paul020709f2003-04-04 02:44:16 +00005820 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5821 type, metric);
paul718e3742002-12-13 20:15:29 +00005822}
5823
5824ALIAS (ospf_default_information_originate_type_metric_routemap,
5825 ospf_default_information_originate_type_metric_cmd,
5826 "default-information originate metric-type (1|2) metric <0-16777214>",
5827 "Control distribution of default information\n"
5828 "Distribute a default route\n"
5829 "OSPF metric type for default routes\n"
5830 "Set OSPF External Type 1 metrics\n"
5831 "Set OSPF External Type 2 metrics\n"
5832 "OSPF default metric\n"
5833 "OSPF metric\n")
5834
5835ALIAS (ospf_default_information_originate_type_metric_routemap,
5836 ospf_default_information_originate_type_cmd,
5837 "default-information originate metric-type (1|2)",
5838 "Control distribution of default information\n"
5839 "Distribute a default route\n"
5840 "OSPF metric type for default routes\n"
5841 "Set OSPF External Type 1 metrics\n"
5842 "Set OSPF External Type 2 metrics\n")
5843
5844DEFUN (ospf_default_information_originate_type_routemap,
5845 ospf_default_information_originate_type_routemap_cmd,
5846 "default-information originate metric-type (1|2) route-map WORD",
5847 "Control distribution of default information\n"
5848 "Distribute a default route\n"
5849 "OSPF metric type for default routes\n"
5850 "Set OSPF External Type 1 metrics\n"
5851 "Set OSPF External Type 2 metrics\n"
5852 "Route map reference\n"
5853 "Pointer to route-map entries\n")
5854{
paul020709f2003-04-04 02:44:16 +00005855 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005856 int type = -1;
5857
5858 /* Get metric type. */
5859 if (argc >= 1)
5860 if (!str2metric_type (argv[0], &type))
5861 return CMD_WARNING;
5862
5863 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005864 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005865 else
paul020709f2003-04-04 02:44:16 +00005866 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005867
paul020709f2003-04-04 02:44:16 +00005868 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5869 type, -1);
paul718e3742002-12-13 20:15:29 +00005870}
5871
5872DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5873 ospf_default_information_originate_always_metric_type_routemap_cmd,
5874 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5875 "Control distribution of default information\n"
5876 "Distribute a default route\n"
5877 "Always advertise default route\n"
5878 "OSPF default metric\n"
5879 "OSPF metric\n"
5880 "OSPF metric type for default routes\n"
5881 "Set OSPF External Type 1 metrics\n"
5882 "Set OSPF External Type 2 metrics\n"
5883 "Route map reference\n"
5884 "Pointer to route-map entries\n")
5885{
paul020709f2003-04-04 02:44:16 +00005886 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005887 int type = -1;
5888 int metric = -1;
5889
5890 /* Get metric value. */
5891 if (argc >= 1)
5892 if (!str2metric (argv[0], &metric))
5893 return CMD_WARNING;
5894
5895 /* Get metric type. */
5896 if (argc >= 2)
5897 if (!str2metric_type (argv[1], &type))
5898 return CMD_WARNING;
5899
5900 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005901 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005902 else
paul020709f2003-04-04 02:44:16 +00005903 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005904
paul020709f2003-04-04 02:44:16 +00005905 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005906 type, metric);
5907}
5908
5909ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5910 ospf_default_information_originate_always_metric_type_cmd,
5911 "default-information originate always metric <0-16777214> metric-type (1|2)",
5912 "Control distribution of default information\n"
5913 "Distribute a default route\n"
5914 "Always advertise default route\n"
5915 "OSPF default metric\n"
5916 "OSPF metric\n"
5917 "OSPF metric type for default routes\n"
5918 "Set OSPF External Type 1 metrics\n"
5919 "Set OSPF External Type 2 metrics\n")
5920
5921ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5922 ospf_default_information_originate_always_metric_cmd,
5923 "default-information originate always metric <0-16777214>",
5924 "Control distribution of default information\n"
5925 "Distribute a default route\n"
5926 "Always advertise default route\n"
5927 "OSPF default metric\n"
5928 "OSPF metric\n"
5929 "OSPF metric type for default routes\n")
5930
5931ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5932 ospf_default_information_originate_always_cmd,
5933 "default-information originate always",
5934 "Control distribution of default information\n"
5935 "Distribute a default route\n"
5936 "Always advertise default route\n")
5937
5938DEFUN (ospf_default_information_originate_always_metric_routemap,
5939 ospf_default_information_originate_always_metric_routemap_cmd,
5940 "default-information originate always metric <0-16777214> route-map WORD",
5941 "Control distribution of default information\n"
5942 "Distribute a default route\n"
5943 "Always advertise default route\n"
5944 "OSPF default metric\n"
5945 "OSPF metric\n"
5946 "Route map reference\n"
5947 "Pointer to route-map entries\n")
5948{
paul020709f2003-04-04 02:44:16 +00005949 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005950 int metric = -1;
5951
5952 /* Get metric value. */
5953 if (argc >= 1)
5954 if (!str2metric (argv[0], &metric))
5955 return CMD_WARNING;
5956
5957 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005958 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005959 else
paul020709f2003-04-04 02:44:16 +00005960 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005961
paul020709f2003-04-04 02:44:16 +00005962 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5963 -1, metric);
paul718e3742002-12-13 20:15:29 +00005964}
5965
5966DEFUN (ospf_default_information_originate_always_routemap,
5967 ospf_default_information_originate_always_routemap_cmd,
5968 "default-information originate always route-map WORD",
5969 "Control distribution of default information\n"
5970 "Distribute a default route\n"
5971 "Always advertise default route\n"
5972 "Route map reference\n"
5973 "Pointer to route-map entries\n")
5974{
paul020709f2003-04-04 02:44:16 +00005975 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005976
paul020709f2003-04-04 02:44:16 +00005977 if (argc == 1)
5978 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5979 else
5980 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5981
5982 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005983}
5984
5985DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5986 ospf_default_information_originate_always_type_metric_routemap_cmd,
5987 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5988 "Control distribution of default information\n"
5989 "Distribute a default route\n"
5990 "Always advertise default route\n"
5991 "OSPF metric type for default routes\n"
5992 "Set OSPF External Type 1 metrics\n"
5993 "Set OSPF External Type 2 metrics\n"
5994 "OSPF default metric\n"
5995 "OSPF metric\n"
5996 "Route map reference\n"
5997 "Pointer to route-map entries\n")
5998{
paul020709f2003-04-04 02:44:16 +00005999 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006000 int type = -1;
6001 int metric = -1;
6002
6003 /* Get metric type. */
6004 if (argc >= 1)
6005 if (!str2metric_type (argv[0], &type))
6006 return CMD_WARNING;
6007
6008 /* Get metric value. */
6009 if (argc >= 2)
6010 if (!str2metric (argv[1], &metric))
6011 return CMD_WARNING;
6012
6013 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006014 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006015 else
paul020709f2003-04-04 02:44:16 +00006016 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006017
paul020709f2003-04-04 02:44:16 +00006018 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006019 type, metric);
6020}
6021
6022ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6023 ospf_default_information_originate_always_type_metric_cmd,
6024 "default-information originate always metric-type (1|2) metric <0-16777214>",
6025 "Control distribution of default information\n"
6026 "Distribute a default route\n"
6027 "Always advertise default route\n"
6028 "OSPF metric type for default routes\n"
6029 "Set OSPF External Type 1 metrics\n"
6030 "Set OSPF External Type 2 metrics\n"
6031 "OSPF default metric\n"
6032 "OSPF metric\n")
6033
6034ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6035 ospf_default_information_originate_always_type_cmd,
6036 "default-information originate always metric-type (1|2)",
6037 "Control distribution of default information\n"
6038 "Distribute a default route\n"
6039 "Always advertise default route\n"
6040 "OSPF metric type for default routes\n"
6041 "Set OSPF External Type 1 metrics\n"
6042 "Set OSPF External Type 2 metrics\n")
6043
6044DEFUN (ospf_default_information_originate_always_type_routemap,
6045 ospf_default_information_originate_always_type_routemap_cmd,
6046 "default-information originate always metric-type (1|2) route-map WORD",
6047 "Control distribution of default information\n"
6048 "Distribute a default route\n"
6049 "Always advertise default route\n"
6050 "OSPF metric type for default routes\n"
6051 "Set OSPF External Type 1 metrics\n"
6052 "Set OSPF External Type 2 metrics\n"
6053 "Route map reference\n"
6054 "Pointer to route-map entries\n")
6055{
paul020709f2003-04-04 02:44:16 +00006056 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006057 int type = -1;
6058
6059 /* Get metric type. */
6060 if (argc >= 1)
6061 if (!str2metric_type (argv[0], &type))
6062 return CMD_WARNING;
6063
6064 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006065 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006066 else
paul020709f2003-04-04 02:44:16 +00006067 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006068
paul020709f2003-04-04 02:44:16 +00006069 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006070 type, -1);
6071}
6072
6073DEFUN (no_ospf_default_information_originate,
6074 no_ospf_default_information_originate_cmd,
6075 "no default-information originate",
6076 NO_STR
6077 "Control distribution of default information\n"
6078 "Distribute a default route\n")
6079{
paul68980082003-03-25 05:07:42 +00006080 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006081 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006082
6083 p.family = AF_INET;
6084 p.prefix.s_addr = 0;
6085 p.prefixlen = 0;
6086
ajs5339cfd2005-09-19 13:28:05 +00006087 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006088
6089 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6090 ospf_external_info_delete (DEFAULT_ROUTE, p);
6091 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6092 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6093 }
6094
paul020709f2003-04-04 02:44:16 +00006095 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6096 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006097}
6098
6099DEFUN (ospf_default_metric,
6100 ospf_default_metric_cmd,
6101 "default-metric <0-16777214>",
6102 "Set metric of redistributed routes\n"
6103 "Default metric\n")
6104{
paul68980082003-03-25 05:07:42 +00006105 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006106 int metric = -1;
6107
6108 if (!str2metric (argv[0], &metric))
6109 return CMD_WARNING;
6110
paul68980082003-03-25 05:07:42 +00006111 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006112
6113 return CMD_SUCCESS;
6114}
6115
6116DEFUN (no_ospf_default_metric,
6117 no_ospf_default_metric_cmd,
6118 "no default-metric",
6119 NO_STR
6120 "Set metric of redistributed routes\n")
6121{
paul68980082003-03-25 05:07:42 +00006122 struct ospf *ospf = vty->index;
6123
6124 ospf->default_metric = -1;
6125
paul718e3742002-12-13 20:15:29 +00006126 return CMD_SUCCESS;
6127}
6128
6129ALIAS (no_ospf_default_metric,
6130 no_ospf_default_metric_val_cmd,
6131 "no default-metric <0-16777214>",
6132 NO_STR
6133 "Set metric of redistributed routes\n"
6134 "Default metric\n")
6135
6136DEFUN (ospf_distance,
6137 ospf_distance_cmd,
6138 "distance <1-255>",
6139 "Define an administrative distance\n"
6140 "OSPF Administrative distance\n")
6141{
paul68980082003-03-25 05:07:42 +00006142 struct ospf *ospf = vty->index;
6143
6144 ospf->distance_all = atoi (argv[0]);
6145
paul718e3742002-12-13 20:15:29 +00006146 return CMD_SUCCESS;
6147}
6148
6149DEFUN (no_ospf_distance,
6150 no_ospf_distance_cmd,
6151 "no distance <1-255>",
6152 NO_STR
6153 "Define an administrative distance\n"
6154 "OSPF Administrative distance\n")
6155{
paul68980082003-03-25 05:07:42 +00006156 struct ospf *ospf = vty->index;
6157
6158 ospf->distance_all = 0;
6159
paul718e3742002-12-13 20:15:29 +00006160 return CMD_SUCCESS;
6161}
6162
6163DEFUN (no_ospf_distance_ospf,
6164 no_ospf_distance_ospf_cmd,
6165 "no distance ospf",
6166 NO_STR
6167 "Define an administrative distance\n"
6168 "OSPF Administrative distance\n"
6169 "OSPF Distance\n")
6170{
paul68980082003-03-25 05:07:42 +00006171 struct ospf *ospf = vty->index;
6172
6173 ospf->distance_intra = 0;
6174 ospf->distance_inter = 0;
6175 ospf->distance_external = 0;
6176
paul718e3742002-12-13 20:15:29 +00006177 return CMD_SUCCESS;
6178}
6179
6180DEFUN (ospf_distance_ospf_intra,
6181 ospf_distance_ospf_intra_cmd,
6182 "distance ospf intra-area <1-255>",
6183 "Define an administrative distance\n"
6184 "OSPF Administrative distance\n"
6185 "Intra-area routes\n"
6186 "Distance for intra-area routes\n")
6187{
paul68980082003-03-25 05:07:42 +00006188 struct ospf *ospf = vty->index;
6189
6190 ospf->distance_intra = atoi (argv[0]);
6191
paul718e3742002-12-13 20:15:29 +00006192 return CMD_SUCCESS;
6193}
6194
6195DEFUN (ospf_distance_ospf_intra_inter,
6196 ospf_distance_ospf_intra_inter_cmd,
6197 "distance ospf intra-area <1-255> inter-area <1-255>",
6198 "Define an administrative distance\n"
6199 "OSPF Administrative distance\n"
6200 "Intra-area routes\n"
6201 "Distance for intra-area routes\n"
6202 "Inter-area routes\n"
6203 "Distance for inter-area routes\n")
6204{
paul68980082003-03-25 05:07:42 +00006205 struct ospf *ospf = vty->index;
6206
6207 ospf->distance_intra = atoi (argv[0]);
6208 ospf->distance_inter = atoi (argv[1]);
6209
paul718e3742002-12-13 20:15:29 +00006210 return CMD_SUCCESS;
6211}
6212
6213DEFUN (ospf_distance_ospf_intra_external,
6214 ospf_distance_ospf_intra_external_cmd,
6215 "distance ospf intra-area <1-255> external <1-255>",
6216 "Define an administrative distance\n"
6217 "OSPF Administrative distance\n"
6218 "Intra-area routes\n"
6219 "Distance for intra-area routes\n"
6220 "External routes\n"
6221 "Distance for external routes\n")
6222{
paul68980082003-03-25 05:07:42 +00006223 struct ospf *ospf = vty->index;
6224
6225 ospf->distance_intra = atoi (argv[0]);
6226 ospf->distance_external = atoi (argv[1]);
6227
paul718e3742002-12-13 20:15:29 +00006228 return CMD_SUCCESS;
6229}
6230
6231DEFUN (ospf_distance_ospf_intra_inter_external,
6232 ospf_distance_ospf_intra_inter_external_cmd,
6233 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6234 "Define an administrative distance\n"
6235 "OSPF Administrative distance\n"
6236 "Intra-area routes\n"
6237 "Distance for intra-area routes\n"
6238 "Inter-area routes\n"
6239 "Distance for inter-area routes\n"
6240 "External routes\n"
6241 "Distance for external routes\n")
6242{
paul68980082003-03-25 05:07:42 +00006243 struct ospf *ospf = vty->index;
6244
6245 ospf->distance_intra = atoi (argv[0]);
6246 ospf->distance_inter = atoi (argv[1]);
6247 ospf->distance_external = atoi (argv[2]);
6248
paul718e3742002-12-13 20:15:29 +00006249 return CMD_SUCCESS;
6250}
6251
6252DEFUN (ospf_distance_ospf_intra_external_inter,
6253 ospf_distance_ospf_intra_external_inter_cmd,
6254 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6255 "Define an administrative distance\n"
6256 "OSPF Administrative distance\n"
6257 "Intra-area routes\n"
6258 "Distance for intra-area routes\n"
6259 "External routes\n"
6260 "Distance for external routes\n"
6261 "Inter-area routes\n"
6262 "Distance for inter-area routes\n")
6263{
paul68980082003-03-25 05:07:42 +00006264 struct ospf *ospf = vty->index;
6265
6266 ospf->distance_intra = atoi (argv[0]);
6267 ospf->distance_external = atoi (argv[1]);
6268 ospf->distance_inter = atoi (argv[2]);
6269
paul718e3742002-12-13 20:15:29 +00006270 return CMD_SUCCESS;
6271}
6272
6273DEFUN (ospf_distance_ospf_inter,
6274 ospf_distance_ospf_inter_cmd,
6275 "distance ospf inter-area <1-255>",
6276 "Define an administrative distance\n"
6277 "OSPF Administrative distance\n"
6278 "Inter-area routes\n"
6279 "Distance for inter-area routes\n")
6280{
paul68980082003-03-25 05:07:42 +00006281 struct ospf *ospf = vty->index;
6282
6283 ospf->distance_inter = atoi (argv[0]);
6284
paul718e3742002-12-13 20:15:29 +00006285 return CMD_SUCCESS;
6286}
6287
6288DEFUN (ospf_distance_ospf_inter_intra,
6289 ospf_distance_ospf_inter_intra_cmd,
6290 "distance ospf inter-area <1-255> intra-area <1-255>",
6291 "Define an administrative distance\n"
6292 "OSPF Administrative distance\n"
6293 "Inter-area routes\n"
6294 "Distance for inter-area routes\n"
6295 "Intra-area routes\n"
6296 "Distance for intra-area routes\n")
6297{
paul68980082003-03-25 05:07:42 +00006298 struct ospf *ospf = vty->index;
6299
6300 ospf->distance_inter = atoi (argv[0]);
6301 ospf->distance_intra = atoi (argv[1]);
6302
paul718e3742002-12-13 20:15:29 +00006303 return CMD_SUCCESS;
6304}
6305
6306DEFUN (ospf_distance_ospf_inter_external,
6307 ospf_distance_ospf_inter_external_cmd,
6308 "distance ospf inter-area <1-255> external <1-255>",
6309 "Define an administrative distance\n"
6310 "OSPF Administrative distance\n"
6311 "Inter-area routes\n"
6312 "Distance for inter-area routes\n"
6313 "External routes\n"
6314 "Distance for external routes\n")
6315{
paul68980082003-03-25 05:07:42 +00006316 struct ospf *ospf = vty->index;
6317
6318 ospf->distance_inter = atoi (argv[0]);
6319 ospf->distance_external = atoi (argv[1]);
6320
paul718e3742002-12-13 20:15:29 +00006321 return CMD_SUCCESS;
6322}
6323
6324DEFUN (ospf_distance_ospf_inter_intra_external,
6325 ospf_distance_ospf_inter_intra_external_cmd,
6326 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6327 "Define an administrative distance\n"
6328 "OSPF Administrative distance\n"
6329 "Inter-area routes\n"
6330 "Distance for inter-area routes\n"
6331 "Intra-area routes\n"
6332 "Distance for intra-area routes\n"
6333 "External routes\n"
6334 "Distance for external routes\n")
6335{
paul68980082003-03-25 05:07:42 +00006336 struct ospf *ospf = vty->index;
6337
6338 ospf->distance_inter = atoi (argv[0]);
6339 ospf->distance_intra = atoi (argv[1]);
6340 ospf->distance_external = atoi (argv[2]);
6341
paul718e3742002-12-13 20:15:29 +00006342 return CMD_SUCCESS;
6343}
6344
6345DEFUN (ospf_distance_ospf_inter_external_intra,
6346 ospf_distance_ospf_inter_external_intra_cmd,
6347 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6348 "Define an administrative distance\n"
6349 "OSPF Administrative distance\n"
6350 "Inter-area routes\n"
6351 "Distance for inter-area routes\n"
6352 "External routes\n"
6353 "Distance for external routes\n"
6354 "Intra-area routes\n"
6355 "Distance for intra-area routes\n")
6356{
paul68980082003-03-25 05:07:42 +00006357 struct ospf *ospf = vty->index;
6358
6359 ospf->distance_inter = atoi (argv[0]);
6360 ospf->distance_external = atoi (argv[1]);
6361 ospf->distance_intra = atoi (argv[2]);
6362
paul718e3742002-12-13 20:15:29 +00006363 return CMD_SUCCESS;
6364}
6365
6366DEFUN (ospf_distance_ospf_external,
6367 ospf_distance_ospf_external_cmd,
6368 "distance ospf external <1-255>",
6369 "Define an administrative distance\n"
6370 "OSPF Administrative distance\n"
6371 "External routes\n"
6372 "Distance for external routes\n")
6373{
paul68980082003-03-25 05:07:42 +00006374 struct ospf *ospf = vty->index;
6375
6376 ospf->distance_external = atoi (argv[0]);
6377
paul718e3742002-12-13 20:15:29 +00006378 return CMD_SUCCESS;
6379}
6380
6381DEFUN (ospf_distance_ospf_external_intra,
6382 ospf_distance_ospf_external_intra_cmd,
6383 "distance ospf external <1-255> intra-area <1-255>",
6384 "Define an administrative distance\n"
6385 "OSPF Administrative distance\n"
6386 "External routes\n"
6387 "Distance for external routes\n"
6388 "Intra-area routes\n"
6389 "Distance for intra-area routes\n")
6390{
paul68980082003-03-25 05:07:42 +00006391 struct ospf *ospf = vty->index;
6392
6393 ospf->distance_external = atoi (argv[0]);
6394 ospf->distance_intra = atoi (argv[1]);
6395
paul718e3742002-12-13 20:15:29 +00006396 return CMD_SUCCESS;
6397}
6398
6399DEFUN (ospf_distance_ospf_external_inter,
6400 ospf_distance_ospf_external_inter_cmd,
6401 "distance ospf external <1-255> inter-area <1-255>",
6402 "Define an administrative distance\n"
6403 "OSPF Administrative distance\n"
6404 "External routes\n"
6405 "Distance for external routes\n"
6406 "Inter-area routes\n"
6407 "Distance for inter-area routes\n")
6408{
paul68980082003-03-25 05:07:42 +00006409 struct ospf *ospf = vty->index;
6410
6411 ospf->distance_external = atoi (argv[0]);
6412 ospf->distance_inter = atoi (argv[1]);
6413
paul718e3742002-12-13 20:15:29 +00006414 return CMD_SUCCESS;
6415}
6416
6417DEFUN (ospf_distance_ospf_external_intra_inter,
6418 ospf_distance_ospf_external_intra_inter_cmd,
6419 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6420 "Define an administrative distance\n"
6421 "OSPF Administrative distance\n"
6422 "External routes\n"
6423 "Distance for external routes\n"
6424 "Intra-area routes\n"
6425 "Distance for intra-area routes\n"
6426 "Inter-area routes\n"
6427 "Distance for inter-area routes\n")
6428{
paul68980082003-03-25 05:07:42 +00006429 struct ospf *ospf = vty->index;
6430
6431 ospf->distance_external = atoi (argv[0]);
6432 ospf->distance_intra = atoi (argv[1]);
6433 ospf->distance_inter = atoi (argv[2]);
6434
paul718e3742002-12-13 20:15:29 +00006435 return CMD_SUCCESS;
6436}
6437
6438DEFUN (ospf_distance_ospf_external_inter_intra,
6439 ospf_distance_ospf_external_inter_intra_cmd,
6440 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6441 "Define an administrative distance\n"
6442 "OSPF Administrative distance\n"
6443 "External routes\n"
6444 "Distance for external routes\n"
6445 "Inter-area routes\n"
6446 "Distance for inter-area routes\n"
6447 "Intra-area routes\n"
6448 "Distance for intra-area routes\n")
6449{
paul68980082003-03-25 05:07:42 +00006450 struct ospf *ospf = vty->index;
6451
6452 ospf->distance_external = atoi (argv[0]);
6453 ospf->distance_inter = atoi (argv[1]);
6454 ospf->distance_intra = atoi (argv[2]);
6455
paul718e3742002-12-13 20:15:29 +00006456 return CMD_SUCCESS;
6457}
6458
6459DEFUN (ospf_distance_source,
6460 ospf_distance_source_cmd,
6461 "distance <1-255> A.B.C.D/M",
6462 "Administrative distance\n"
6463 "Distance value\n"
6464 "IP source prefix\n")
6465{
paul020709f2003-04-04 02:44:16 +00006466 struct ospf *ospf = vty->index;
6467
6468 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006469
paul718e3742002-12-13 20:15:29 +00006470 return CMD_SUCCESS;
6471}
6472
6473DEFUN (no_ospf_distance_source,
6474 no_ospf_distance_source_cmd,
6475 "no distance <1-255> A.B.C.D/M",
6476 NO_STR
6477 "Administrative distance\n"
6478 "Distance value\n"
6479 "IP source prefix\n")
6480{
paul020709f2003-04-04 02:44:16 +00006481 struct ospf *ospf = vty->index;
6482
6483 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6484
paul718e3742002-12-13 20:15:29 +00006485 return CMD_SUCCESS;
6486}
6487
6488DEFUN (ospf_distance_source_access_list,
6489 ospf_distance_source_access_list_cmd,
6490 "distance <1-255> A.B.C.D/M WORD",
6491 "Administrative distance\n"
6492 "Distance value\n"
6493 "IP source prefix\n"
6494 "Access list name\n")
6495{
paul020709f2003-04-04 02:44:16 +00006496 struct ospf *ospf = vty->index;
6497
6498 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6499
paul718e3742002-12-13 20:15:29 +00006500 return CMD_SUCCESS;
6501}
6502
6503DEFUN (no_ospf_distance_source_access_list,
6504 no_ospf_distance_source_access_list_cmd,
6505 "no distance <1-255> A.B.C.D/M WORD",
6506 NO_STR
6507 "Administrative distance\n"
6508 "Distance value\n"
6509 "IP source prefix\n"
6510 "Access list name\n")
6511{
paul020709f2003-04-04 02:44:16 +00006512 struct ospf *ospf = vty->index;
6513
6514 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6515
paul718e3742002-12-13 20:15:29 +00006516 return CMD_SUCCESS;
6517}
6518
vincentba682532005-09-29 13:52:57 +00006519DEFUN (ip_ospf_mtu_ignore,
6520 ip_ospf_mtu_ignore_addr_cmd,
6521 "ip ospf mtu-ignore A.B.C.D",
6522 "IP Information\n"
6523 "OSPF interface commands\n"
6524 "Disable mtu mismatch detection\n"
6525 "Address of interface")
6526{
6527 struct interface *ifp = vty->index;
6528 struct in_addr addr;
6529 int ret;
6530
6531 struct ospf_if_params *params;
6532 params = IF_DEF_PARAMS (ifp);
6533
6534 if (argc == 1)
6535 {
6536 ret = inet_aton(argv[0], &addr);
6537 if (!ret)
6538 {
6539 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6540 VTY_NEWLINE);
6541 return CMD_WARNING;
6542 }
6543 params = ospf_get_if_params (ifp, addr);
6544 ospf_if_update_params (ifp, addr);
6545 }
6546 params->mtu_ignore = 1;
6547 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6548 SET_IF_PARAM (params, mtu_ignore);
6549 else
6550 {
6551 UNSET_IF_PARAM (params, mtu_ignore);
6552 if (params != IF_DEF_PARAMS (ifp))
6553 {
6554 ospf_free_if_params (ifp, addr);
6555 ospf_if_update_params (ifp, addr);
6556 }
6557 }
6558 return CMD_SUCCESS;
6559}
6560
6561ALIAS (ip_ospf_mtu_ignore,
6562 ip_ospf_mtu_ignore_cmd,
6563 "ip ospf mtu-ignore",
6564 "IP Information\n"
6565 "OSPF interface commands\n"
6566 "Disable mtu mismatch detection\n")
6567
6568
6569DEFUN (no_ip_ospf_mtu_ignore,
6570 no_ip_ospf_mtu_ignore_addr_cmd,
6571 "no ip ospf mtu-ignore A.B.C.D",
6572 "IP Information\n"
6573 "OSPF interface commands\n"
6574 "Disable mtu mismatch detection\n"
6575 "Address of interface")
6576{
6577 struct interface *ifp = vty->index;
6578 struct in_addr addr;
6579 int ret;
6580
6581 struct ospf_if_params *params;
6582 params = IF_DEF_PARAMS (ifp);
6583
6584 if (argc == 1)
6585 {
6586 ret = inet_aton(argv[0], &addr);
6587 if (!ret)
6588 {
6589 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6590 VTY_NEWLINE);
6591 return CMD_WARNING;
6592 }
6593 params = ospf_get_if_params (ifp, addr);
6594 ospf_if_update_params (ifp, addr);
6595 }
6596 params->mtu_ignore = 0;
6597 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6598 SET_IF_PARAM (params, mtu_ignore);
6599 else
6600 {
6601 UNSET_IF_PARAM (params, mtu_ignore);
6602 if (params != IF_DEF_PARAMS (ifp))
6603 {
6604 ospf_free_if_params (ifp, addr);
6605 ospf_if_update_params (ifp, addr);
6606 }
6607 }
6608 return CMD_SUCCESS;
6609}
6610
6611ALIAS (no_ip_ospf_mtu_ignore,
6612 no_ip_ospf_mtu_ignore_cmd,
6613 "no ip ospf mtu-ignore",
6614 "IP Information\n"
6615 "OSPF interface commands\n"
6616 "Disable mtu mismatch detection\n")
6617
paul4dadc292005-05-06 21:37:42 +00006618static void
paul718e3742002-12-13 20:15:29 +00006619show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6620{
6621 struct route_node *rn;
6622 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006623 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006624 struct ospf_path *path;
6625
6626 vty_out (vty, "============ OSPF network routing table ============%s",
6627 VTY_NEWLINE);
6628
6629 for (rn = route_top (rt); rn; rn = route_next (rn))
6630 if ((or = rn->info) != NULL)
6631 {
6632 char buf1[19];
6633 snprintf (buf1, 19, "%s/%d",
6634 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6635
6636 switch (or->path_type)
6637 {
6638 case OSPF_PATH_INTER_AREA:
6639 if (or->type == OSPF_DESTINATION_NETWORK)
6640 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6641 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6642 else if (or->type == OSPF_DESTINATION_DISCARD)
6643 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6644 break;
6645 case OSPF_PATH_INTRA_AREA:
6646 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6647 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6648 break;
6649 default:
6650 break;
6651 }
6652
6653 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00006654 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00006655 {
hasso54bedb52005-08-17 13:31:47 +00006656 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00006657 {
6658 if (path->nexthop.s_addr == 0)
6659 vty_out (vty, "%24s directly attached to %s%s",
6660 "", path->oi->ifp->name, VTY_NEWLINE);
6661 else
6662 vty_out (vty, "%24s via %s, %s%s", "",
6663 inet_ntoa (path->nexthop), path->oi->ifp->name,
6664 VTY_NEWLINE);
6665 }
6666 }
paul718e3742002-12-13 20:15:29 +00006667 }
6668 vty_out (vty, "%s", VTY_NEWLINE);
6669}
6670
paul4dadc292005-05-06 21:37:42 +00006671static void
paul718e3742002-12-13 20:15:29 +00006672show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6673{
6674 struct route_node *rn;
6675 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006676 struct listnode *pnode;
6677 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006678 struct ospf_path *path;
6679
6680 vty_out (vty, "============ OSPF router routing table =============%s",
6681 VTY_NEWLINE);
6682 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6683 if (rn->info)
6684 {
6685 int flag = 0;
6686
6687 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6688
paul1eb8ef22005-04-07 07:30:20 +00006689 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
6690 {
6691 if (flag++)
6692 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006693
paul1eb8ef22005-04-07 07:30:20 +00006694 /* Show path. */
6695 vty_out (vty, "%s [%d] area: %s",
6696 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6697 or->cost, inet_ntoa (or->u.std.area_id));
6698 /* Show flags. */
6699 vty_out (vty, "%s%s%s",
6700 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6701 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6702 VTY_NEWLINE);
6703
6704 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
6705 {
hasso54bedb52005-08-17 13:31:47 +00006706 if (path->oi != NULL && ospf_if_exists(path->oi))
6707 {
6708 if (path->nexthop.s_addr == 0)
6709 vty_out (vty, "%24s directly attached to %s%s",
6710 "", path->oi->ifp->name, VTY_NEWLINE);
6711 else
6712 vty_out (vty, "%24s via %s, %s%s", "",
6713 inet_ntoa (path->nexthop),
6714 path->oi->ifp->name, VTY_NEWLINE);
6715 }
paul1eb8ef22005-04-07 07:30:20 +00006716 }
6717 }
paul718e3742002-12-13 20:15:29 +00006718 }
6719 vty_out (vty, "%s", VTY_NEWLINE);
6720}
6721
paul4dadc292005-05-06 21:37:42 +00006722static void
paul718e3742002-12-13 20:15:29 +00006723show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6724{
6725 struct route_node *rn;
6726 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00006727 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006728 struct ospf_path *path;
6729
6730 vty_out (vty, "============ OSPF external routing table ===========%s",
6731 VTY_NEWLINE);
6732 for (rn = route_top (rt); rn; rn = route_next (rn))
6733 if ((er = rn->info) != NULL)
6734 {
6735 char buf1[19];
6736 snprintf (buf1, 19, "%s/%d",
6737 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6738
6739 switch (er->path_type)
6740 {
6741 case OSPF_PATH_TYPE1_EXTERNAL:
6742 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6743 er->cost, er->u.ext.tag, VTY_NEWLINE);
6744 break;
6745 case OSPF_PATH_TYPE2_EXTERNAL:
6746 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6747 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6748 break;
6749 }
6750
paul1eb8ef22005-04-07 07:30:20 +00006751 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00006752 {
hasso54bedb52005-08-17 13:31:47 +00006753 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00006754 {
6755 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006756 vty_out (vty, "%24s directly attached to %s%s",
6757 "", path->oi->ifp->name, VTY_NEWLINE);
6758 else
6759 vty_out (vty, "%24s via %s, %s%s", "",
6760 inet_ntoa (path->nexthop), path->oi->ifp->name,
6761 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006762 }
6763 }
6764 }
6765 vty_out (vty, "%s", VTY_NEWLINE);
6766}
6767
paul718e3742002-12-13 20:15:29 +00006768DEFUN (show_ip_ospf_border_routers,
6769 show_ip_ospf_border_routers_cmd,
6770 "show ip ospf border-routers",
6771 SHOW_STR
6772 IP_STR
6773 "show all the ABR's and ASBR's\n"
6774 "for this area\n")
6775{
paul020709f2003-04-04 02:44:16 +00006776 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006777
paul020709f2003-04-04 02:44:16 +00006778 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006779 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006780 {
6781 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6782 return CMD_SUCCESS;
6783 }
6784
paul68980082003-03-25 05:07:42 +00006785 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006786 {
6787 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6788 return CMD_SUCCESS;
6789 }
6790
6791 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006792 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006793
6794 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006795 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006796
6797 return CMD_SUCCESS;
6798}
paul718e3742002-12-13 20:15:29 +00006799
6800DEFUN (show_ip_ospf_route,
6801 show_ip_ospf_route_cmd,
6802 "show ip ospf route",
6803 SHOW_STR
6804 IP_STR
6805 "OSPF information\n"
6806 "OSPF routing table\n")
6807{
paul020709f2003-04-04 02:44:16 +00006808 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006809
paul020709f2003-04-04 02:44:16 +00006810 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006811 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006812 {
6813 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6814 return CMD_SUCCESS;
6815 }
6816
paul68980082003-03-25 05:07:42 +00006817 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006818 {
6819 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6820 return CMD_SUCCESS;
6821 }
6822
6823 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006824 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006825
6826 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006827 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006828
6829 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006830 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006831
6832 return CMD_SUCCESS;
6833}
6834
6835
hassoeb1ce602004-10-08 08:17:22 +00006836const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006837{
6838 "unknown",
6839 "standard",
6840 "ibm",
6841 "cisco",
6842 "shortcut"
6843};
6844
hassoeb1ce602004-10-08 08:17:22 +00006845const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006846{
6847 "default",
6848 "enable",
6849 "disable"
6850};
6851
6852
paul4dadc292005-05-06 21:37:42 +00006853static void
paul718e3742002-12-13 20:15:29 +00006854area_id2str (char *buf, int length, struct ospf_area *area)
6855{
6856 memset (buf, 0, length);
6857
6858 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6859 strncpy (buf, inet_ntoa (area->area_id), length);
6860 else
6861 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6862}
6863
6864
hassoeb1ce602004-10-08 08:17:22 +00006865const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006866{
6867 "unknown", /* should never be used. */
6868 "point-to-point",
6869 "broadcast",
6870 "non-broadcast",
6871 "point-to-multipoint",
6872 "virtual-link", /* should never be used. */
6873 "loopback"
6874};
6875
6876/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00006877static int
paul718e3742002-12-13 20:15:29 +00006878config_write_interface (struct vty *vty)
6879{
hasso52dc7ee2004-09-23 19:18:23 +00006880 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006881 struct interface *ifp;
6882 struct crypt_key *ck;
6883 int write = 0;
6884 struct route_node *rn = NULL;
6885 struct ospf_if_params *params;
6886
paul1eb8ef22005-04-07 07:30:20 +00006887 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00006888 {
paul718e3742002-12-13 20:15:29 +00006889 if (memcmp (ifp->name, "VLINK", 5) == 0)
6890 continue;
6891
6892 vty_out (vty, "!%s", VTY_NEWLINE);
6893 vty_out (vty, "interface %s%s", ifp->name,
6894 VTY_NEWLINE);
6895 if (ifp->desc)
6896 vty_out (vty, " description %s%s", ifp->desc,
6897 VTY_NEWLINE);
6898
6899 write++;
6900
6901 params = IF_DEF_PARAMS (ifp);
6902
6903 do {
6904 /* Interface Network print. */
6905 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006906 params->type != OSPF_IFTYPE_LOOPBACK)
6907 {
ajsbc18d612004-12-15 15:07:19 +00006908 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006909 {
6910 vty_out (vty, " ip ospf network %s",
6911 ospf_int_type_str[params->type]);
6912 if (params != IF_DEF_PARAMS (ifp))
6913 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6914 vty_out (vty, "%s", VTY_NEWLINE);
6915 }
paul718e3742002-12-13 20:15:29 +00006916 }
6917
6918 /* OSPF interface authentication print */
6919 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6920 params->auth_type != OSPF_AUTH_NOTSET)
6921 {
hassoeb1ce602004-10-08 08:17:22 +00006922 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006923
6924 /* Translation tables are not that much help here due to syntax
6925 of the simple option */
6926 switch (params->auth_type)
6927 {
6928
6929 case OSPF_AUTH_NULL:
6930 auth_str = " null";
6931 break;
6932
6933 case OSPF_AUTH_SIMPLE:
6934 auth_str = "";
6935 break;
6936
6937 case OSPF_AUTH_CRYPTOGRAPHIC:
6938 auth_str = " message-digest";
6939 break;
6940
6941 default:
6942 auth_str = "";
6943 break;
6944 }
6945
6946 vty_out (vty, " ip ospf authentication%s", auth_str);
6947 if (params != IF_DEF_PARAMS (ifp))
6948 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6949 vty_out (vty, "%s", VTY_NEWLINE);
6950 }
6951
6952 /* Simple Authentication Password print. */
6953 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6954 params->auth_simple[0] != '\0')
6955 {
6956 vty_out (vty, " ip ospf authentication-key %s",
6957 params->auth_simple);
6958 if (params != IF_DEF_PARAMS (ifp))
6959 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6960 vty_out (vty, "%s", VTY_NEWLINE);
6961 }
6962
6963 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00006964 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00006965 {
paul718e3742002-12-13 20:15:29 +00006966 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6967 ck->key_id, ck->auth_key);
6968 if (params != IF_DEF_PARAMS (ifp))
6969 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6970 vty_out (vty, "%s", VTY_NEWLINE);
6971 }
6972
6973 /* Interface Output Cost print. */
6974 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6975 {
6976 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6977 if (params != IF_DEF_PARAMS (ifp))
6978 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6979 vty_out (vty, "%s", VTY_NEWLINE);
6980 }
6981
6982 /* Hello Interval print. */
6983 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6984 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6985 {
6986 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6987 if (params != IF_DEF_PARAMS (ifp))
6988 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6989 vty_out (vty, "%s", VTY_NEWLINE);
6990 }
6991
6992
6993 /* Router Dead Interval print. */
6994 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6995 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6996 {
6997 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6998 if (params != IF_DEF_PARAMS (ifp))
6999 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7000 vty_out (vty, "%s", VTY_NEWLINE);
7001 }
7002
7003 /* Router Priority print. */
7004 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7005 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7006 {
7007 vty_out (vty, " ip ospf priority %u", params->priority);
7008 if (params != IF_DEF_PARAMS (ifp))
7009 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7010 vty_out (vty, "%s", VTY_NEWLINE);
7011 }
7012
7013 /* Retransmit Interval print. */
7014 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7015 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7016 {
7017 vty_out (vty, " ip ospf retransmit-interval %u",
7018 params->retransmit_interval);
7019 if (params != IF_DEF_PARAMS (ifp))
7020 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7021 vty_out (vty, "%s", VTY_NEWLINE);
7022 }
7023
7024 /* Transmit Delay print. */
7025 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7026 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7027 {
7028 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7029 if (params != IF_DEF_PARAMS (ifp))
7030 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7031 vty_out (vty, "%s", VTY_NEWLINE);
7032 }
7033
vincentba682532005-09-29 13:52:57 +00007034 /* MTU ignore print. */
7035 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7036 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7037 {
7038 if (params->mtu_ignore == 0)
7039 vty_out (vty, " no ip ospf mtu-ignore");
7040 else
7041 vty_out (vty, " ip ospf mtu-ignore");
7042 if (params != IF_DEF_PARAMS (ifp))
7043 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7044 vty_out (vty, "%s", VTY_NEWLINE);
7045 }
7046
7047
paul718e3742002-12-13 20:15:29 +00007048 while (1)
7049 {
7050 if (rn == NULL)
7051 rn = route_top (IF_OIFS_PARAMS (ifp));
7052 else
7053 rn = route_next (rn);
7054
7055 if (rn == NULL)
7056 break;
7057 params = rn->info;
7058 if (params != NULL)
7059 break;
7060 }
7061 } while (rn);
7062
7063#ifdef HAVE_OPAQUE_LSA
7064 ospf_opaque_config_write_if (vty, ifp);
7065#endif /* HAVE_OPAQUE_LSA */
7066 }
7067
7068 return write;
7069}
7070
paul4dadc292005-05-06 21:37:42 +00007071static int
paul68980082003-03-25 05:07:42 +00007072config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007073{
7074 struct route_node *rn;
7075 u_char buf[INET_ADDRSTRLEN];
7076
7077 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007078 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007079 if (rn->info)
7080 {
7081 struct ospf_network *n = rn->info;
7082
7083 memset (buf, 0, INET_ADDRSTRLEN);
7084
7085 /* Create Area ID string by specified Area ID format. */
7086 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007087 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007088 else
hassoc9e52be2004-09-26 16:09:34 +00007089 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007090 (unsigned long int) ntohl (n->area_id.s_addr));
7091
7092 /* Network print. */
7093 vty_out (vty, " network %s/%d area %s%s",
7094 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7095 buf, VTY_NEWLINE);
7096 }
7097
7098 return 0;
7099}
7100
paul4dadc292005-05-06 21:37:42 +00007101static int
paul68980082003-03-25 05:07:42 +00007102config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007103{
hasso52dc7ee2004-09-23 19:18:23 +00007104 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007105 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007106 u_char buf[INET_ADDRSTRLEN];
7107
7108 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007109 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007110 {
paul718e3742002-12-13 20:15:29 +00007111 struct route_node *rn1;
7112
hassoc9e52be2004-09-26 16:09:34 +00007113 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007114
7115 if (area->auth_type != OSPF_AUTH_NULL)
7116 {
7117 if (area->auth_type == OSPF_AUTH_SIMPLE)
7118 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7119 else
7120 vty_out (vty, " area %s authentication message-digest%s",
7121 buf, VTY_NEWLINE);
7122 }
7123
7124 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7125 vty_out (vty, " area %s shortcut %s%s", buf,
7126 ospf_shortcut_mode_str[area->shortcut_configured],
7127 VTY_NEWLINE);
7128
7129 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007130 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007131 )
7132 {
paulb0a053b2003-06-22 09:04:47 +00007133 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007134 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007135 else if (area->external_routing == OSPF_AREA_NSSA)
7136 {
7137 vty_out (vty, " area %s nssa", buf);
7138 switch (area->NSSATranslatorRole)
7139 {
7140 case OSPF_NSSA_ROLE_NEVER:
7141 vty_out (vty, " translate-never");
7142 break;
7143 case OSPF_NSSA_ROLE_ALWAYS:
7144 vty_out (vty, " translate-always");
7145 break;
7146 case OSPF_NSSA_ROLE_CANDIDATE:
7147 default:
7148 vty_out (vty, " translate-candidate");
7149 }
7150 }
paul718e3742002-12-13 20:15:29 +00007151
7152 if (area->no_summary)
7153 vty_out (vty, " no-summary");
7154
7155 vty_out (vty, "%s", VTY_NEWLINE);
7156
7157 if (area->default_cost != 1)
7158 vty_out (vty, " area %s default-cost %d%s", buf,
7159 area->default_cost, VTY_NEWLINE);
7160 }
7161
7162 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7163 if (rn1->info)
7164 {
7165 struct ospf_area_range *range = rn1->info;
7166
7167 vty_out (vty, " area %s range %s/%d", buf,
7168 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7169
paul6c835672004-10-11 11:00:30 +00007170 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007171 vty_out (vty, " cost %d", range->cost_config);
7172
7173 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7174 vty_out (vty, " not-advertise");
7175
7176 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7177 vty_out (vty, " substitute %s/%d",
7178 inet_ntoa (range->subst_addr), range->subst_masklen);
7179
7180 vty_out (vty, "%s", VTY_NEWLINE);
7181 }
7182
7183 if (EXPORT_NAME (area))
7184 vty_out (vty, " area %s export-list %s%s", buf,
7185 EXPORT_NAME (area), VTY_NEWLINE);
7186
7187 if (IMPORT_NAME (area))
7188 vty_out (vty, " area %s import-list %s%s", buf,
7189 IMPORT_NAME (area), VTY_NEWLINE);
7190
7191 if (PREFIX_NAME_IN (area))
7192 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7193 PREFIX_NAME_IN (area), VTY_NEWLINE);
7194
7195 if (PREFIX_NAME_OUT (area))
7196 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7197 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7198 }
7199
7200 return 0;
7201}
7202
paul4dadc292005-05-06 21:37:42 +00007203static int
paul68980082003-03-25 05:07:42 +00007204config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007205{
7206 struct ospf_nbr_nbma *nbr_nbma;
7207 struct route_node *rn;
7208
7209 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007210 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007211 if ((nbr_nbma = rn->info))
7212 {
7213 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7214
7215 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7216 vty_out (vty, " priority %d", nbr_nbma->priority);
7217
7218 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7219 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7220
7221 vty_out (vty, "%s", VTY_NEWLINE);
7222 }
7223
7224 return 0;
7225}
7226
paul4dadc292005-05-06 21:37:42 +00007227static int
paul68980082003-03-25 05:07:42 +00007228config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007229{
hasso52dc7ee2004-09-23 19:18:23 +00007230 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007231 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007232 u_char buf[INET_ADDRSTRLEN];
7233
7234 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007235 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007236 {
hasso52dc7ee2004-09-23 19:18:23 +00007237 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007238 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007239 struct ospf_interface *oi;
7240
7241 if (vl_data != NULL)
7242 {
7243 memset (buf, 0, INET_ADDRSTRLEN);
7244
7245 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007246 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007247 else
hassoc9e52be2004-09-26 16:09:34 +00007248 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007249 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7250 oi = vl_data->vl_oi;
7251
7252 /* timers */
7253 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7254 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7255 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7256 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7257 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7258 buf,
7259 inet_ntoa (vl_data->vl_peer),
7260 OSPF_IF_PARAM (oi, v_hello),
7261 OSPF_IF_PARAM (oi, retransmit_interval),
7262 OSPF_IF_PARAM (oi, transmit_delay),
7263 OSPF_IF_PARAM (oi, v_wait),
7264 VTY_NEWLINE);
7265 else
7266 vty_out (vty, " area %s virtual-link %s%s", buf,
7267 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7268 /* Auth key */
7269 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7270 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7271 buf,
7272 inet_ntoa (vl_data->vl_peer),
7273 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7274 VTY_NEWLINE);
7275 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007276 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7277 n2, ck))
7278 vty_out (vty, " area %s virtual-link %s"
7279 " message-digest-key %d md5 %s%s",
7280 buf,
7281 inet_ntoa (vl_data->vl_peer),
7282 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007283
7284 }
7285 }
7286
7287 return 0;
7288}
7289
7290
hassoeb1ce602004-10-08 08:17:22 +00007291const char *distribute_str[] = { "system", "kernel", "connected", "static",
7292 "rip", "ripng", "ospf", "ospf6", "isis", "bgp"};
paul4dadc292005-05-06 21:37:42 +00007293static int
paul68980082003-03-25 05:07:42 +00007294config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007295{
7296 int type;
7297
7298 /* redistribute print. */
7299 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7300 if (type != zclient->redist_default && zclient->redist[type])
7301 {
7302 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007303 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007304 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007305
paul68980082003-03-25 05:07:42 +00007306 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007307 vty_out (vty, " metric-type 1");
7308
paul020709f2003-04-04 02:44:16 +00007309 if (ROUTEMAP_NAME (ospf, type))
7310 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007311
7312 vty_out (vty, "%s", VTY_NEWLINE);
7313 }
7314
7315 return 0;
7316}
7317
paul4dadc292005-05-06 21:37:42 +00007318static int
paul68980082003-03-25 05:07:42 +00007319config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007320{
paul68980082003-03-25 05:07:42 +00007321 if (ospf->default_metric != -1)
7322 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007323 VTY_NEWLINE);
7324 return 0;
7325}
7326
paul4dadc292005-05-06 21:37:42 +00007327static int
paul68980082003-03-25 05:07:42 +00007328config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007329{
7330 int type;
7331
paul68980082003-03-25 05:07:42 +00007332 if (ospf)
paul718e3742002-12-13 20:15:29 +00007333 {
7334 /* distribute-list print. */
7335 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007336 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007337 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007338 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007339 distribute_str[type], VTY_NEWLINE);
7340
7341 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007342 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007343 {
paul68980082003-03-25 05:07:42 +00007344 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007345 vty_out (vty, " default-information originate");
7346 else
7347 vty_out (vty, " default-information originate always");
7348
paul68980082003-03-25 05:07:42 +00007349 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007350 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007351 ospf->dmetric[DEFAULT_ROUTE].value);
7352 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007353 vty_out (vty, " metric-type 1");
7354
paul020709f2003-04-04 02:44:16 +00007355 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7356 vty_out (vty, " route-map %s",
7357 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007358
7359 vty_out (vty, "%s", VTY_NEWLINE);
7360 }
7361
7362 }
7363
7364 return 0;
7365}
7366
paul4dadc292005-05-06 21:37:42 +00007367static int
paul68980082003-03-25 05:07:42 +00007368config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007369{
7370 struct route_node *rn;
7371 struct ospf_distance *odistance;
7372
paul68980082003-03-25 05:07:42 +00007373 if (ospf->distance_all)
7374 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007375
paul68980082003-03-25 05:07:42 +00007376 if (ospf->distance_intra
7377 || ospf->distance_inter
7378 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007379 {
7380 vty_out (vty, " distance ospf");
7381
paul68980082003-03-25 05:07:42 +00007382 if (ospf->distance_intra)
7383 vty_out (vty, " intra-area %d", ospf->distance_intra);
7384 if (ospf->distance_inter)
7385 vty_out (vty, " inter-area %d", ospf->distance_inter);
7386 if (ospf->distance_external)
7387 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007388
7389 vty_out (vty, "%s", VTY_NEWLINE);
7390 }
7391
paul68980082003-03-25 05:07:42 +00007392 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007393 if ((odistance = rn->info) != NULL)
7394 {
7395 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7396 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7397 odistance->access_list ? odistance->access_list : "",
7398 VTY_NEWLINE);
7399 }
7400 return 0;
7401}
7402
7403/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007404static int
paul718e3742002-12-13 20:15:29 +00007405ospf_config_write (struct vty *vty)
7406{
paul020709f2003-04-04 02:44:16 +00007407 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007408 struct interface *ifp;
7409 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007410 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007411 int write = 0;
7412
paul020709f2003-04-04 02:44:16 +00007413 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007414 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007415 {
7416 /* `router ospf' print. */
7417 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7418
7419 write++;
7420
paul68980082003-03-25 05:07:42 +00007421 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007422 return write;
7423
7424 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007425 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007426 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007427 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007428
7429 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007430 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007431 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007432 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007433
7434 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007435 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007436 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7437
7438 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007439 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007440 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007441 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007442
7443 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007444 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7445 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007446 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007447 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007448
7449 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007450 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007451 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007452 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007453
7454 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007455 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007456
7457 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007458 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7459 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7460 vty_out (vty, " passive-interface %s%s",
7461 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007462
paul1eb8ef22005-04-07 07:30:20 +00007463 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7464 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7465 oi->params->passive_interface == OSPF_IF_PASSIVE)
7466 vty_out (vty, " passive-interface %s %s%s",
7467 oi->ifp->name,
7468 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007469
7470 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007471 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007472
7473 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007474 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007475
7476 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007477 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007478
7479 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007480 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007481
7482 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007483 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007484
7485 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007486 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007487
7488 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007489 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007490
7491#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007492 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007493#endif /* HAVE_OPAQUE_LSA */
7494 }
7495
7496 return write;
7497}
7498
7499void
paul4dadc292005-05-06 21:37:42 +00007500ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007501{
7502 /* "show ip ospf" commands. */
7503 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7504 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7505
7506 /* "show ip ospf database" commands. */
7507 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7508 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7509 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7510 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7511 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7512 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7513 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7514 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7515 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7516 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7517 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7518 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7519 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7520 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7521
7522 /* "show ip ospf interface" commands. */
7523 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7524 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7525
7526 /* "show ip ospf neighbor" commands. */
7527 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7528 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7529 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7530 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7531 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7532 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7533 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7534 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7535 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7536 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7537 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7538 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7539 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7540 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7541
7542 /* "show ip ospf route" commands. */
7543 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7544 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007545 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7546 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007547}
7548
7549
7550/* ospfd's interface node. */
7551struct cmd_node interface_node =
7552{
7553 INTERFACE_NODE,
7554 "%s(config-if)# ",
7555 1
7556};
7557
7558/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007559static void
7560ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007561{
7562 /* Install interface node. */
7563 install_node (&interface_node, config_write_interface);
7564
7565 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007566 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007567 install_default (INTERFACE_NODE);
7568
7569 /* "description" commands. */
7570 install_element (INTERFACE_NODE, &interface_desc_cmd);
7571 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7572
7573 /* "ip ospf authentication" commands. */
7574 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7575 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7576 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7577 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7578 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7579 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7580 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7581 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7582 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7583 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7584
7585 /* "ip ospf message-digest-key" commands. */
7586 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7587 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7588 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7589 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7590
7591 /* "ip ospf cost" commands. */
7592 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7593 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7594 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7595 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7596
vincentba682532005-09-29 13:52:57 +00007597 /* "ip ospf mtu-ignore" commands. */
7598 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7599 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7600 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7601 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7602
paul718e3742002-12-13 20:15:29 +00007603 /* "ip ospf dead-interval" commands. */
7604 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7605 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7606 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7607 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7608
7609 /* "ip ospf hello-interval" commands. */
7610 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7611 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7612 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7613 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7614
7615 /* "ip ospf network" commands. */
7616 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7617 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7618
7619 /* "ip ospf priority" commands. */
7620 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7621 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7622 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7623 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7624
7625 /* "ip ospf retransmit-interval" commands. */
7626 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7627 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7628 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7629 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7630
7631 /* "ip ospf transmit-delay" commands. */
7632 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7633 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7634 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7635 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7636
7637 /* These commands are compatibitliy for previous version. */
7638 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7639 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7640 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7641 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7642 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7643 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7644 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7645 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7646 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7647 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7648 install_element (INTERFACE_NODE, &ospf_network_cmd);
7649 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7650 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7651 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7652 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7653 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7654 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7655 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7656}
7657
7658/* Zebra node structure. */
7659struct cmd_node zebra_node =
7660{
7661 ZEBRA_NODE,
7662 "%s(config-router)#",
7663};
7664
paul4dadc292005-05-06 21:37:42 +00007665static void
7666ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00007667{
7668 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7669 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7670 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7671 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7672 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7673 install_element (OSPF_NODE,
7674 &ospf_redistribute_source_metric_type_routemap_cmd);
7675 install_element (OSPF_NODE,
7676 &ospf_redistribute_source_type_metric_routemap_cmd);
7677 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7678 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7679 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7680
7681 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7682
7683 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7684 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7685
7686 install_element (OSPF_NODE,
7687 &ospf_default_information_originate_metric_type_cmd);
7688 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7689 install_element (OSPF_NODE,
7690 &ospf_default_information_originate_type_metric_cmd);
7691 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7692 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7693 install_element (OSPF_NODE,
7694 &ospf_default_information_originate_always_metric_type_cmd);
7695 install_element (OSPF_NODE,
7696 &ospf_default_information_originate_always_metric_cmd);
7697 install_element (OSPF_NODE,
7698 &ospf_default_information_originate_always_cmd);
7699 install_element (OSPF_NODE,
7700 &ospf_default_information_originate_always_type_metric_cmd);
7701 install_element (OSPF_NODE,
7702 &ospf_default_information_originate_always_type_cmd);
7703
7704 install_element (OSPF_NODE,
7705 &ospf_default_information_originate_metric_type_routemap_cmd);
7706 install_element (OSPF_NODE,
7707 &ospf_default_information_originate_metric_routemap_cmd);
7708 install_element (OSPF_NODE,
7709 &ospf_default_information_originate_routemap_cmd);
7710 install_element (OSPF_NODE,
7711 &ospf_default_information_originate_type_metric_routemap_cmd);
7712 install_element (OSPF_NODE,
7713 &ospf_default_information_originate_type_routemap_cmd);
7714 install_element (OSPF_NODE,
7715 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7716 install_element (OSPF_NODE,
7717 &ospf_default_information_originate_always_metric_routemap_cmd);
7718 install_element (OSPF_NODE,
7719 &ospf_default_information_originate_always_routemap_cmd);
7720 install_element (OSPF_NODE,
7721 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7722 install_element (OSPF_NODE,
7723 &ospf_default_information_originate_always_type_routemap_cmd);
7724
7725 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7726
7727 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7728 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7729 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7730
7731 install_element (OSPF_NODE, &ospf_distance_cmd);
7732 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7733 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7734 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7735 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7736 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7737 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7738 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7739 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7740 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7741 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7742 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7743 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7744 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7745 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7746 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7747 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7748 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7749#if 0
7750 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7751 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7752 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7753 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7754#endif /* 0 */
7755}
7756
7757struct cmd_node ospf_node =
7758{
7759 OSPF_NODE,
7760 "%s(config-router)# ",
7761 1
7762};
7763
7764
7765/* Install OSPF related vty commands. */
7766void
paul4dadc292005-05-06 21:37:42 +00007767ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00007768{
7769 /* Install ospf top node. */
7770 install_node (&ospf_node, ospf_config_write);
7771
7772 /* "router ospf" commands. */
7773 install_element (CONFIG_NODE, &router_ospf_cmd);
7774 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7775
7776 install_default (OSPF_NODE);
7777
7778 /* "ospf router-id" commands. */
7779 install_element (OSPF_NODE, &ospf_router_id_cmd);
7780 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007781 install_element (OSPF_NODE, &router_ospf_id_cmd);
7782 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007783
7784 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007785 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7786 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7787 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7788 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007789
7790 /* "ospf abr-type" commands. */
7791 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7792 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7793
7794 /* "ospf rfc1583-compatible" commands. */
7795 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7796 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7797 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7798 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7799
7800 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007801 install_element (OSPF_NODE, &ospf_network_area_cmd);
7802 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007803
7804 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007805 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7806 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7807 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007808
7809 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007810 install_element (OSPF_NODE, &ospf_area_range_cmd);
7811 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7812 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7813 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7814 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7815 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7816 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7817 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7818 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7819 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7820 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007821
7822 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007823 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7824 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007825
paula2c62832003-04-23 17:01:31 +00007826 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7827 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007828
paula2c62832003-04-23 17:01:31 +00007829 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7830 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007831
paula2c62832003-04-23 17:01:31 +00007832 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7833 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007834
paula2c62832003-04-23 17:01:31 +00007835 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7836 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007837
paula2c62832003-04-23 17:01:31 +00007838 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7839 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7840 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007841
paula2c62832003-04-23 17:01:31 +00007842 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7843 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007844
paula2c62832003-04-23 17:01:31 +00007845 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7846 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007847
paula2c62832003-04-23 17:01:31 +00007848 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7849 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7850 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007851
paula2c62832003-04-23 17:01:31 +00007852 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7853 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7854 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007855
7856 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007857 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7858 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7859 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7860 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007861
paul718e3742002-12-13 20:15:29 +00007862 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007863 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7864 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7865 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7866 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7867 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7868 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007869
paula2c62832003-04-23 17:01:31 +00007870 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7871 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007872
paula2c62832003-04-23 17:01:31 +00007873 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7874 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007875
paula2c62832003-04-23 17:01:31 +00007876 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7877 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007878
paula2c62832003-04-23 17:01:31 +00007879 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7880 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007881
paula2c62832003-04-23 17:01:31 +00007882 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7883 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007884
paula2c62832003-04-23 17:01:31 +00007885 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7886 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007887
paula2c62832003-04-23 17:01:31 +00007888 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7889 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7890 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007891
paula2c62832003-04-23 17:01:31 +00007892 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7893 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007894
7895 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007896 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7897 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7898 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7899 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7900 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7901 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7902 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7903 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007904
7905 /* Init interface related vty commands. */
7906 ospf_vty_if_init ();
7907
7908 /* Init zebra related vty commands. */
7909 ospf_vty_zebra_init ();
7910}