blob: e56027be5a07841a0b2e7a4d0959c1c58e7ab40c [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* OSPF VTY interface.
vincentba682532005-09-29 13:52:57 +00002 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
paul718e3742002-12-13 20:15:29 +00003 * Copyright (C) 2000 Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23#include <zebra.h>
24
25#include "memory.h"
26#include "thread.h"
27#include "prefix.h"
28#include "table.h"
29#include "vty.h"
30#include "command.h"
31#include "plist.h"
32#include "log.h"
33#include "zclient.h"
34
35#include "ospfd/ospfd.h"
36#include "ospfd/ospf_asbr.h"
37#include "ospfd/ospf_lsa.h"
38#include "ospfd/ospf_lsdb.h"
39#include "ospfd/ospf_ism.h"
40#include "ospfd/ospf_interface.h"
41#include "ospfd/ospf_nsm.h"
42#include "ospfd/ospf_neighbor.h"
43#include "ospfd/ospf_flood.h"
44#include "ospfd/ospf_abr.h"
45#include "ospfd/ospf_spf.h"
46#include "ospfd/ospf_route.h"
47#include "ospfd/ospf_zebra.h"
48/*#include "ospfd/ospf_routemap.h" */
49#include "ospfd/ospf_vty.h"
50#include "ospfd/ospf_dump.h"
51
52
hassoeb1ce602004-10-08 08:17:22 +000053const static char *ospf_network_type_str[] =
paul718e3742002-12-13 20:15:29 +000054{
55 "Null",
56 "POINTOPOINT",
57 "BROADCAST",
58 "NBMA",
59 "POINTOMULTIPOINT",
60 "VIRTUALLINK",
61 "LOOPBACK"
62};
63
64
65/* Utility functions. */
paul4dadc292005-05-06 21:37:42 +000066static int
paul6c835672004-10-11 11:00:30 +000067ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
paul718e3742002-12-13 20:15:29 +000068{
69 char *endptr = NULL;
70 unsigned long ret;
71
72 /* match "A.B.C.D". */
73 if (strchr (str, '.') != NULL)
74 {
75 ret = inet_aton (str, area_id);
76 if (!ret)
77 return -1;
78 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
79 }
80 /* match "<0-4294967295>". */
81 else
82 {
83 ret = strtoul (str, &endptr, 10);
84 if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE))
85 return -1;
86
87 area_id->s_addr = htonl (ret);
88 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
89 }
90
91 return 0;
92}
93
94
paul4dadc292005-05-06 21:37:42 +000095static int
paul6c835672004-10-11 11:00:30 +000096str2distribute_source (const char *str, int *source)
paul718e3742002-12-13 20:15:29 +000097{
98 /* Sanity check. */
99 if (str == NULL)
100 return 0;
101
102 if (strncmp (str, "k", 1) == 0)
103 *source = ZEBRA_ROUTE_KERNEL;
104 else if (strncmp (str, "c", 1) == 0)
105 *source = ZEBRA_ROUTE_CONNECT;
106 else if (strncmp (str, "s", 1) == 0)
107 *source = ZEBRA_ROUTE_STATIC;
108 else if (strncmp (str, "r", 1) == 0)
109 *source = ZEBRA_ROUTE_RIP;
110 else if (strncmp (str, "b", 1) == 0)
111 *source = ZEBRA_ROUTE_BGP;
112 else
113 return 0;
114
115 return 1;
116}
117
paul4dadc292005-05-06 21:37:42 +0000118static int
paul6c835672004-10-11 11:00:30 +0000119str2metric (const char *str, int *metric)
paul718e3742002-12-13 20:15:29 +0000120{
121 /* Sanity check. */
122 if (str == NULL)
123 return 0;
124
125 *metric = strtol (str, NULL, 10);
126 if (*metric < 0 && *metric > 16777214)
127 {
128 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
129 return 0;
130 }
131
132 return 1;
133}
134
paul4dadc292005-05-06 21:37:42 +0000135static int
paul6c835672004-10-11 11:00:30 +0000136str2metric_type (const char *str, int *metric_type)
paul718e3742002-12-13 20:15:29 +0000137{
138 /* Sanity check. */
139 if (str == NULL)
140 return 0;
141
142 if (strncmp (str, "1", 1) == 0)
143 *metric_type = EXTERNAL_METRIC_TYPE_1;
144 else if (strncmp (str, "2", 1) == 0)
145 *metric_type = EXTERNAL_METRIC_TYPE_2;
146 else
147 return 0;
148
149 return 1;
150}
151
152int
153ospf_oi_count (struct interface *ifp)
154{
155 struct route_node *rn;
156 int i = 0;
157
158 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
159 if (rn->info)
160 i++;
161
162 return i;
163}
164
165
166DEFUN (router_ospf,
167 router_ospf_cmd,
168 "router ospf",
169 "Enable a routing process\n"
170 "Start OSPF configuration\n")
171{
172 vty->node = OSPF_NODE;
173 vty->index = ospf_get ();
174
175 return CMD_SUCCESS;
176}
177
178DEFUN (no_router_ospf,
179 no_router_ospf_cmd,
180 "no router ospf",
181 NO_STR
182 "Enable a routing process\n"
183 "Start OSPF configuration\n")
184{
paul020709f2003-04-04 02:44:16 +0000185 struct ospf *ospf;
186
187 ospf = ospf_lookup ();
188 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000189 {
paul020709f2003-04-04 02:44:16 +0000190 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000191 return CMD_WARNING;
192 }
193
paul020709f2003-04-04 02:44:16 +0000194 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000195
196 return CMD_SUCCESS;
197}
198
199DEFUN (ospf_router_id,
200 ospf_router_id_cmd,
201 "ospf router-id A.B.C.D",
202 "OSPF specific commands\n"
203 "router-id for the OSPF process\n"
204 "OSPF router-id in IP address format\n")
205{
paul68980082003-03-25 05:07:42 +0000206 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000207 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000208 int ret;
paul718e3742002-12-13 20:15:29 +0000209
210 ret = inet_aton (argv[0], &router_id);
211 if (!ret)
212 {
213 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
214 return CMD_WARNING;
215 }
216
paul68980082003-03-25 05:07:42 +0000217 ospf->router_id_static = router_id;
paul718e3742002-12-13 20:15:29 +0000218
paul68980082003-03-25 05:07:42 +0000219 if (ospf->t_router_id_update == NULL)
paul020709f2003-04-04 02:44:16 +0000220 OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer,
221 OSPF_ROUTER_ID_UPDATE_DELAY);
paul718e3742002-12-13 20:15:29 +0000222
223 return CMD_SUCCESS;
224}
225
226ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000227 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000228 "router-id A.B.C.D",
229 "router-id for the OSPF process\n"
230 "OSPF router-id in IP address format\n")
231
232DEFUN (no_ospf_router_id,
233 no_ospf_router_id_cmd,
234 "no ospf router-id",
235 NO_STR
236 "OSPF specific commands\n"
237 "router-id for the OSPF process\n")
238{
paul68980082003-03-25 05:07:42 +0000239 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000240
paul68980082003-03-25 05:07:42 +0000241 ospf->router_id_static.s_addr = 0;
242
243 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000244
245 return CMD_SUCCESS;
246}
247
248ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000249 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000250 "no router-id",
251 NO_STR
252 "router-id for the OSPF process\n")
253
paula2c62832003-04-23 17:01:31 +0000254DEFUN (ospf_passive_interface,
255 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000256 "passive-interface IFNAME A.B.C.D",
257 "Suppress routing updates on an interface\n"
258 "Interface's name\n")
259{
260 struct interface *ifp;
261 struct in_addr addr;
262 int ret;
263 struct ospf_if_params *params;
ajsba6454e2005-02-08 15:37:30 +0000264 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000265
266 ifp = if_lookup_by_name (argv[0]);
267
268 if (ifp == NULL)
269 {
270 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
271 return CMD_WARNING;
272 }
273
274 params = IF_DEF_PARAMS (ifp);
275
276 if (argc == 2)
277 {
278 ret = inet_aton(argv[1], &addr);
279 if (!ret)
280 {
281 vty_out (vty, "Please specify interface address by A.B.C.D%s",
282 VTY_NEWLINE);
283 return CMD_WARNING;
284 }
285
286 params = ospf_get_if_params (ifp, addr);
287 ospf_if_update_params (ifp, addr);
288 }
289
290 SET_IF_PARAM (params, passive_interface);
291 params->passive_interface = OSPF_IF_PASSIVE;
ajsba6454e2005-02-08 15:37:30 +0000292
293 /* XXX We should call ospf_if_set_multicast on exactly those
294 * interfaces for which the passive property changed. It is too much
295 * work to determine this set, so we do this for every interface.
296 * This is safe and reasonable because ospf_if_set_multicast uses a
297 * record of joined groups to avoid systems calls if the desired
298 * memberships match the current memership.
299 */
300 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
301 {
302 struct ospf_interface *oi = rn->info;
303
304 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
305 ospf_if_set_multicast(oi);
306 }
307 /*
308 * XXX It is not clear what state transitions the interface needs to
309 * undergo when going from active to passive. Fixing this will
310 * require precise identification of interfaces having such a
311 * transition.
312 */
313
paul718e3742002-12-13 20:15:29 +0000314 return CMD_SUCCESS;
315}
316
paula2c62832003-04-23 17:01:31 +0000317ALIAS (ospf_passive_interface,
318 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000319 "passive-interface IFNAME",
320 "Suppress routing updates on an interface\n"
321 "Interface's name\n")
322
paula2c62832003-04-23 17:01:31 +0000323DEFUN (no_ospf_passive_interface,
324 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000325 "no passive-interface IFNAME A.B.C.D",
326 NO_STR
327 "Allow routing updates on an interface\n"
328 "Interface's name\n")
329{
330 struct interface *ifp;
331 struct in_addr addr;
332 struct ospf_if_params *params;
333 int ret;
ajsba6454e2005-02-08 15:37:30 +0000334 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000335
336 ifp = if_lookup_by_name (argv[0]);
337
338 if (ifp == NULL)
339 {
340 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
341 return CMD_WARNING;
342 }
343
344 params = IF_DEF_PARAMS (ifp);
345
346 if (argc == 2)
347 {
348 ret = inet_aton(argv[1], &addr);
349 if (!ret)
350 {
351 vty_out (vty, "Please specify interface address by A.B.C.D%s",
352 VTY_NEWLINE);
353 return CMD_WARNING;
354 }
355
356 params = ospf_lookup_if_params (ifp, addr);
357 if (params == NULL)
358 return CMD_SUCCESS;
359 }
360
361 UNSET_IF_PARAM (params, passive_interface);
362 params->passive_interface = OSPF_IF_ACTIVE;
363
364 if (params != IF_DEF_PARAMS (ifp))
365 {
366 ospf_free_if_params (ifp, addr);
367 ospf_if_update_params (ifp, addr);
368 }
ajsba6454e2005-02-08 15:37:30 +0000369
370 /* XXX We should call ospf_if_set_multicast on exactly those
371 * interfaces for which the passive property changed. It is too much
372 * work to determine this set, so we do this for every interface.
373 * This is safe and reasonable because ospf_if_set_multicast uses a
374 * record of joined groups to avoid systems calls if the desired
375 * memberships match the current memership.
376 */
377 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
378 {
379 struct ospf_interface *oi = rn->info;
380
381 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
382 ospf_if_set_multicast(oi);
383 }
384
paul718e3742002-12-13 20:15:29 +0000385 return CMD_SUCCESS;
386}
387
paula2c62832003-04-23 17:01:31 +0000388ALIAS (no_ospf_passive_interface,
389 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000390 "no passive-interface IFNAME",
391 NO_STR
392 "Allow routing updates on an interface\n"
393 "Interface's name\n")
394
paula2c62832003-04-23 17:01:31 +0000395DEFUN (ospf_network_area,
396 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000397 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
398 "Enable routing on an IP network\n"
399 "OSPF network prefix\n"
400 "Set the OSPF area ID\n"
401 "OSPF area ID in IP address format\n"
402 "OSPF area ID as a decimal value\n")
403{
404 struct ospf *ospf= vty->index;
405 struct prefix_ipv4 p;
406 struct in_addr area_id;
407 int ret, format;
408
409 /* Get network prefix and Area ID. */
410 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
411 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
412
413 ret = ospf_network_set (ospf, &p, area_id);
414 if (ret == 0)
415 {
416 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
417 return CMD_WARNING;
418 }
419
420 return CMD_SUCCESS;
421}
422
paula2c62832003-04-23 17:01:31 +0000423DEFUN (no_ospf_network_area,
424 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000425 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
426 NO_STR
427 "Enable routing on an IP network\n"
428 "OSPF network prefix\n"
429 "Set the OSPF area ID\n"
430 "OSPF area ID in IP address format\n"
431 "OSPF area ID as a decimal value\n")
432{
433 struct ospf *ospf = (struct ospf *) vty->index;
434 struct prefix_ipv4 p;
435 struct in_addr area_id;
436 int ret, format;
437
438 /* Get network prefix and Area ID. */
439 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
440 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
441
442 ret = ospf_network_unset (ospf, &p, area_id);
443 if (ret == 0)
444 {
445 vty_out (vty, "Can't find specified network area configuration.%s",
446 VTY_NEWLINE);
447 return CMD_WARNING;
448 }
449
450 return CMD_SUCCESS;
451}
452
453
paula2c62832003-04-23 17:01:31 +0000454DEFUN (ospf_area_range,
455 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000456 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
457 "OSPF area parameters\n"
458 "OSPF area ID in IP address format\n"
459 "OSPF area ID as a decimal value\n"
460 "Summarize routes matching address/mask (border routers only)\n"
461 "Area range prefix\n")
462{
463 struct ospf *ospf = vty->index;
464 struct prefix_ipv4 p;
465 struct in_addr area_id;
466 int format;
467 u_int32_t cost;
468
469 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
470 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
471
472 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
473 if (argc > 2)
474 {
paul4dadc292005-05-06 21:37:42 +0000475 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000476 ospf_area_range_cost_set (ospf, area_id, &p, cost);
477 }
478
479 return CMD_SUCCESS;
480}
481
paula2c62832003-04-23 17:01:31 +0000482ALIAS (ospf_area_range,
483 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000484 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
485 "OSPF area parameters\n"
486 "OSPF area ID in IP address format\n"
487 "OSPF area ID as a decimal value\n"
488 "OSPF area range for route advertise (default)\n"
489 "Area range prefix\n"
490 "Advertise this range (default)\n")
491
paula2c62832003-04-23 17:01:31 +0000492ALIAS (ospf_area_range,
493 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000494 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
495 "OSPF area parameters\n"
496 "OSPF area ID in IP address format\n"
497 "OSPF area ID as a decimal value\n"
498 "Summarize routes matching address/mask (border routers only)\n"
499 "Area range prefix\n"
500 "User specified metric for this range\n"
501 "Advertised metric for this range\n")
502
paula2c62832003-04-23 17:01:31 +0000503ALIAS (ospf_area_range,
504 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000505 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
506 "OSPF area parameters\n"
507 "OSPF area ID in IP address format\n"
508 "OSPF area ID as a decimal value\n"
509 "Summarize routes matching address/mask (border routers only)\n"
510 "Area range prefix\n"
511 "Advertise this range (default)\n"
512 "User specified metric for this range\n"
513 "Advertised metric for this range\n")
514
paula2c62832003-04-23 17:01:31 +0000515DEFUN (ospf_area_range_not_advertise,
516 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000517 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
518 "OSPF area parameters\n"
519 "OSPF area ID in IP address format\n"
520 "OSPF area ID as a decimal value\n"
521 "Summarize routes matching address/mask (border routers only)\n"
522 "Area range prefix\n"
523 "DoNotAdvertise this range\n")
524{
525 struct ospf *ospf = vty->index;
526 struct prefix_ipv4 p;
527 struct in_addr area_id;
528 int format;
529
530 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
531 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
532
533 ospf_area_range_set (ospf, area_id, &p, 0);
534
535 return CMD_SUCCESS;
536}
537
paula2c62832003-04-23 17:01:31 +0000538DEFUN (no_ospf_area_range,
539 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000540 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
541 NO_STR
542 "OSPF area parameters\n"
543 "OSPF area ID in IP address format\n"
544 "OSPF area ID as a decimal value\n"
545 "Summarize routes matching address/mask (border routers only)\n"
546 "Area range prefix\n")
547{
548 struct ospf *ospf = vty->index;
549 struct prefix_ipv4 p;
550 struct in_addr area_id;
551 int format;
552
553 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
554 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
555
556 ospf_area_range_unset (ospf, area_id, &p);
557
558 return CMD_SUCCESS;
559}
560
paula2c62832003-04-23 17:01:31 +0000561ALIAS (no_ospf_area_range,
562 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000563 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
564 NO_STR
565 "OSPF area parameters\n"
566 "OSPF area ID in IP address format\n"
567 "OSPF area ID as a decimal value\n"
568 "Summarize routes matching address/mask (border routers only)\n"
569 "Area range prefix\n"
570 "Advertise this range (default)\n"
571 "DoNotAdvertise this range\n")
572
paula2c62832003-04-23 17:01:31 +0000573ALIAS (no_ospf_area_range,
574 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000575 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
576 NO_STR
577 "OSPF area parameters\n"
578 "OSPF area ID in IP address format\n"
579 "OSPF area ID as a decimal value\n"
580 "Summarize routes matching address/mask (border routers only)\n"
581 "Area range prefix\n"
582 "User specified metric for this range\n"
583 "Advertised metric for this range\n")
584
paula2c62832003-04-23 17:01:31 +0000585ALIAS (no_ospf_area_range,
586 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000587 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
588 NO_STR
589 "OSPF area parameters\n"
590 "OSPF area ID in IP address format\n"
591 "OSPF area ID as a decimal value\n"
592 "Summarize routes matching address/mask (border routers only)\n"
593 "Area range prefix\n"
594 "Advertise this range (default)\n"
595 "User specified metric for this range\n"
596 "Advertised metric for this range\n")
597
paula2c62832003-04-23 17:01:31 +0000598DEFUN (ospf_area_range_substitute,
599 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000600 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
601 "OSPF area parameters\n"
602 "OSPF area ID in IP address format\n"
603 "OSPF area ID as a decimal value\n"
604 "Summarize routes matching address/mask (border routers only)\n"
605 "Area range prefix\n"
606 "Announce area range as another prefix\n"
607 "Network prefix to be announced instead of range\n")
608{
609 struct ospf *ospf = vty->index;
610 struct prefix_ipv4 p, s;
611 struct in_addr area_id;
612 int format;
613
614 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
615 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
616 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
617
618 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
619
620 return CMD_SUCCESS;
621}
622
paula2c62832003-04-23 17:01:31 +0000623DEFUN (no_ospf_area_range_substitute,
624 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000625 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
626 NO_STR
627 "OSPF area parameters\n"
628 "OSPF area ID in IP address format\n"
629 "OSPF area ID as a decimal value\n"
630 "Summarize routes matching address/mask (border routers only)\n"
631 "Area range prefix\n"
632 "Announce area range as another prefix\n"
633 "Network prefix to be announced instead of range\n")
634{
635 struct ospf *ospf = vty->index;
636 struct prefix_ipv4 p, s;
637 struct in_addr area_id;
638 int format;
639
640 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
641 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
642 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
643
644 ospf_area_range_substitute_unset (ospf, area_id, &p);
645
646 return CMD_SUCCESS;
647}
648
649
650/* Command Handler Logic in VLink stuff is delicate!!
651
652 ALTER AT YOUR OWN RISK!!!!
653
654 Various dummy values are used to represent 'NoChange' state for
655 VLink configuration NOT being changed by a VLink command, and
656 special syntax is used within the command strings so that the
657 typed in command verbs can be seen in the configuration command
658 bacckend handler. This is to drastically reduce the verbeage
659 required to coe up with a reasonably compatible Cisco VLink command
660
661 - Matthew Grant <grantma@anathoth.gen.nz>
662 Wed, 21 Feb 2001 15:13:52 +1300
663 */
664
665
666/* Configuration data for virtual links
667 */
668struct ospf_vl_config_data {
669 struct vty *vty; /* vty stuff */
670 struct in_addr area_id; /* area ID from command line */
671 int format; /* command line area ID format */
672 struct in_addr vl_peer; /* command line vl_peer */
673 int auth_type; /* Authehntication type, if given */
674 char *auth_key; /* simple password if present */
675 int crypto_key_id; /* Cryptographic key ID */
676 char *md5_key; /* MD5 authentication key */
677 int hello_interval; /* Obvious what these are... */
678 int retransmit_interval;
679 int transmit_delay;
680 int dead_interval;
681};
682
paul4dadc292005-05-06 21:37:42 +0000683static void
paul718e3742002-12-13 20:15:29 +0000684ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
685 struct vty *vty)
686{
687 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
688 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
689 vl_config->vty = vty;
690}
691
paul4dadc292005-05-06 21:37:42 +0000692static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000693ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000694{
695 struct ospf_area *area;
696 struct ospf_vl_data *vl_data;
697 struct vty *vty;
698 struct in_addr area_id;
699
700 vty = vl_config->vty;
701 area_id = vl_config->area_id;
702
703 if (area_id.s_addr == OSPF_AREA_BACKBONE)
704 {
705 vty_out (vty,
706 "Configuring VLs over the backbone is not allowed%s",
707 VTY_NEWLINE);
708 return NULL;
709 }
paul68980082003-03-25 05:07:42 +0000710 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000711
712 if (area->external_routing != OSPF_AREA_DEFAULT)
713 {
714 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
715 vty_out (vty, "Area %s is %s%s",
716 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000717 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000718 VTY_NEWLINE);
719 else
720 vty_out (vty, "Area %ld is %s%s",
721 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000722 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000723 VTY_NEWLINE);
724 return NULL;
725 }
726
727 if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)
728 {
729 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
730 if (vl_data->vl_oi == NULL)
731 {
paul68980082003-03-25 05:07:42 +0000732 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
733 ospf_vl_add (ospf, vl_data);
734 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000735 }
736 }
737 return vl_data;
738}
739
740
paul4dadc292005-05-06 21:37:42 +0000741static int
paul718e3742002-12-13 20:15:29 +0000742ospf_vl_set_security (struct ospf_vl_data *vl_data,
743 struct ospf_vl_config_data *vl_config)
744{
745 struct crypt_key *ck;
746 struct vty *vty;
747 struct interface *ifp = vl_data->vl_oi->ifp;
748
749 vty = vl_config->vty;
750
751 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
752 {
753 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
754 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
755 }
756
757 if (vl_config->auth_key)
758 {
759 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000760 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000761 OSPF_AUTH_SIMPLE_SIZE);
762 }
763 else if (vl_config->md5_key)
764 {
765 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
766 != NULL)
767 {
768 vty_out (vty, "OSPF: Key %d already exists%s",
769 vl_config->crypto_key_id, VTY_NEWLINE);
770 return CMD_WARNING;
771 }
772 ck = ospf_crypt_key_new ();
773 ck->key_id = vl_config->crypto_key_id;
774 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000775 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000776
777 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
778 }
779 else if (vl_config->crypto_key_id != 0)
780 {
781 /* Delete a key */
782
783 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
784 vl_config->crypto_key_id) == NULL)
785 {
786 vty_out (vty, "OSPF: Key %d does not exist%s",
787 vl_config->crypto_key_id, VTY_NEWLINE);
788 return CMD_WARNING;
789 }
790
791 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
792
793 }
794
795 return CMD_SUCCESS;
796}
797
paul4dadc292005-05-06 21:37:42 +0000798static int
paul718e3742002-12-13 20:15:29 +0000799ospf_vl_set_timers (struct ospf_vl_data *vl_data,
800 struct ospf_vl_config_data *vl_config)
801{
802 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
803 /* Virtual Link data initialised to defaults, so only set
804 if a value given */
805 if (vl_config->hello_interval)
806 {
807 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
808 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
809 }
810
811 if (vl_config->dead_interval)
812 {
813 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
814 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
815 }
816
817 if (vl_config->retransmit_interval)
818 {
819 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
820 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
821 }
822
823 if (vl_config->transmit_delay)
824 {
825 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
826 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
827 }
828
829 return CMD_SUCCESS;
830}
831
832
833
834/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000835static int
paul68980082003-03-25 05:07:42 +0000836ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000837{
838 struct ospf_vl_data *vl_data;
839 int ret;
840
paul68980082003-03-25 05:07:42 +0000841 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000842 if (!vl_data)
843 return CMD_WARNING;
844
845 /* Process this one first as it can have a fatal result, which can
846 only logically occur if the virtual link exists already
847 Thus a command error does not result in a change to the
848 running configuration such as unexpectedly altered timer
849 values etc.*/
850 ret = ospf_vl_set_security (vl_data, vl_config);
851 if (ret != CMD_SUCCESS)
852 return ret;
853
854 /* Set any time based parameters, these area already range checked */
855
856 ret = ospf_vl_set_timers (vl_data, vl_config);
857 if (ret != CMD_SUCCESS)
858 return ret;
859
860 return CMD_SUCCESS;
861
862}
863
864/* This stuff exists to make specifying all the alias commands A LOT simpler
865 */
866#define VLINK_HELPSTR_IPADDR \
867 "OSPF area parameters\n" \
868 "OSPF area ID in IP address format\n" \
869 "OSPF area ID as a decimal value\n" \
870 "Configure a virtual link\n" \
871 "Router ID of the remote ABR\n"
872
873#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
874 "Enable authentication on this virtual link\n" \
875 "dummy string \n"
876
877#define VLINK_HELPSTR_AUTHTYPE_ALL \
878 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
879 "Use null authentication\n" \
880 "Use message-digest authentication\n"
881
882#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
883 "Time between HELLO packets\n" \
884 "Time between retransmitting lost link state advertisements\n" \
885 "Link state transmit delay\n" \
886 "Interval after which a neighbor is declared dead\n"
887
888#define VLINK_HELPSTR_TIME_PARAM \
889 VLINK_HELPSTR_TIME_PARAM_NOSECS \
890 "Seconds\n"
891
892#define VLINK_HELPSTR_AUTH_SIMPLE \
893 "Authentication password (key)\n" \
894 "The OSPF password (key)"
895
896#define VLINK_HELPSTR_AUTH_MD5 \
897 "Message digest authentication password (key)\n" \
898 "dummy string \n" \
899 "Key ID\n" \
900 "Use MD5 algorithm\n" \
901 "The OSPF password (key)"
902
paula2c62832003-04-23 17:01:31 +0000903DEFUN (ospf_area_vlink,
904 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000905 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
906 VLINK_HELPSTR_IPADDR)
907{
paul68980082003-03-25 05:07:42 +0000908 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000909 struct ospf_vl_config_data vl_config;
910 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
911 char md5_key[OSPF_AUTH_MD5_SIZE+1];
912 int i;
913 int ret;
914
915 ospf_vl_config_data_init(&vl_config, vty);
916
917 /* Read off first 2 parameters and check them */
918 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
919 if (ret < 0)
920 {
921 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
922 return CMD_WARNING;
923 }
924
925 ret = inet_aton (argv[1], &vl_config.vl_peer);
926 if (! ret)
927 {
928 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
929 VTY_NEWLINE);
930 return CMD_WARNING;
931 }
932
933 if (argc <=2)
934 {
935 /* Thats all folks! - BUGS B. strikes again!!!*/
936
paul68980082003-03-25 05:07:42 +0000937 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000938 }
939
940 /* Deal with other parameters */
941 for (i=2; i < argc; i++)
942 {
943
944 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
945
946 switch (argv[i][0])
947 {
948
949 case 'a':
950 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
951 {
952 /* authentication-key - this option can occur anywhere on
953 command line. At start of command line
954 must check for authentication option. */
955 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
956 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
957 vl_config.auth_key = auth_key;
958 i++;
959 }
960 else if (strncmp (argv[i], "authentication", 14) == 0)
961 {
962 /* authentication - this option can only occur at start
963 of command line */
964 vl_config.auth_type = OSPF_AUTH_SIMPLE;
965 if ((i+1) < argc)
966 {
967 if (strncmp (argv[i+1], "n", 1) == 0)
968 {
969 /* "authentication null" */
970 vl_config.auth_type = OSPF_AUTH_NULL;
971 i++;
972 }
973 else if (strncmp (argv[i+1], "m", 1) == 0
974 && strcmp (argv[i+1], "message-digest-") != 0)
975 {
976 /* "authentication message-digest" */
977 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
978 i++;
979 }
980 }
981 }
982 break;
983
984 case 'm':
985 /* message-digest-key */
986 i++;
987 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
988 if (vl_config.crypto_key_id < 0)
989 return CMD_WARNING;
990 i++;
991 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
992 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
993 vl_config.md5_key = md5_key;
994 break;
995
996 case 'h':
997 /* Hello interval */
998 i++;
999 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1000 if (vl_config.hello_interval < 0)
1001 return CMD_WARNING;
1002 break;
1003
1004 case 'r':
1005 /* Retransmit Interval */
1006 i++;
1007 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1008 if (vl_config.retransmit_interval < 0)
1009 return CMD_WARNING;
1010 break;
1011
1012 case 't':
1013 /* Transmit Delay */
1014 i++;
1015 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1016 if (vl_config.transmit_delay < 0)
1017 return CMD_WARNING;
1018 break;
1019
1020 case 'd':
1021 /* Dead Interval */
1022 i++;
1023 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1024 if (vl_config.dead_interval < 0)
1025 return CMD_WARNING;
1026 break;
1027 }
1028 }
1029
1030
1031 /* Action configuration */
1032
paul68980082003-03-25 05:07:42 +00001033 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001034
1035}
1036
paula2c62832003-04-23 17:01:31 +00001037DEFUN (no_ospf_area_vlink,
1038 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001039 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1040 NO_STR
1041 VLINK_HELPSTR_IPADDR)
1042{
paul68980082003-03-25 05:07:42 +00001043 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001044 struct ospf_area *area;
1045 struct ospf_vl_config_data vl_config;
1046 struct ospf_vl_data *vl_data = NULL;
1047 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1048 int i;
1049 int ret, format;
1050
1051 ospf_vl_config_data_init(&vl_config, vty);
1052
1053 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1054 if (ret < 0)
1055 {
1056 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1057 return CMD_WARNING;
1058 }
1059
paul68980082003-03-25 05:07:42 +00001060 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001061 if (!area)
1062 {
1063 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1064 return CMD_WARNING;
1065 }
1066
1067 ret = inet_aton (argv[1], &vl_config.vl_peer);
1068 if (! ret)
1069 {
1070 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1071 VTY_NEWLINE);
1072 return CMD_WARNING;
1073 }
1074
1075 if (argc <=2)
1076 {
1077 /* Basic VLink no command */
1078 /* Thats all folks! - BUGS B. strikes again!!!*/
1079 if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001080 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001081
paul68980082003-03-25 05:07:42 +00001082 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001083
1084 return CMD_SUCCESS;
1085 }
1086
1087 /* If we are down here, we are reseting parameters */
1088
1089 /* Deal with other parameters */
1090 for (i=2; i < argc; i++)
1091 {
paul718e3742002-12-13 20:15:29 +00001092 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1093
1094 switch (argv[i][0])
1095 {
1096
1097 case 'a':
1098 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1099 {
1100 /* authentication-key - this option can occur anywhere on
1101 command line. At start of command line
1102 must check for authentication option. */
1103 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1104 vl_config.auth_key = auth_key;
1105 }
1106 else if (strncmp (argv[i], "authentication", 14) == 0)
1107 {
1108 /* authentication - this option can only occur at start
1109 of command line */
1110 vl_config.auth_type = OSPF_AUTH_NOTSET;
1111 }
1112 break;
1113
1114 case 'm':
1115 /* message-digest-key */
1116 /* Delete one key */
1117 i++;
1118 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1119 if (vl_config.crypto_key_id < 0)
1120 return CMD_WARNING;
1121 vl_config.md5_key = NULL;
1122 break;
1123
1124 case 'h':
1125 /* Hello interval */
1126 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1127 break;
1128
1129 case 'r':
1130 /* Retransmit Interval */
1131 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1132 break;
1133
1134 case 't':
1135 /* Transmit Delay */
1136 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1137 break;
1138
1139 case 'd':
1140 /* Dead Interval */
1141 i++;
1142 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1143 break;
1144 }
1145 }
1146
1147
1148 /* Action configuration */
1149
paul68980082003-03-25 05:07:42 +00001150 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001151}
1152
paula2c62832003-04-23 17:01:31 +00001153ALIAS (ospf_area_vlink,
1154 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001155 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1156 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1157 VLINK_HELPSTR_IPADDR
1158 VLINK_HELPSTR_TIME_PARAM)
1159
paula2c62832003-04-23 17:01:31 +00001160ALIAS (no_ospf_area_vlink,
1161 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001162 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1163 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1164 NO_STR
1165 VLINK_HELPSTR_IPADDR
1166 VLINK_HELPSTR_TIME_PARAM)
1167
paula2c62832003-04-23 17:01:31 +00001168ALIAS (ospf_area_vlink,
1169 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001170 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1171 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1172 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1173 VLINK_HELPSTR_IPADDR
1174 VLINK_HELPSTR_TIME_PARAM
1175 VLINK_HELPSTR_TIME_PARAM)
1176
paula2c62832003-04-23 17:01:31 +00001177ALIAS (no_ospf_area_vlink,
1178 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001179 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1180 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1181 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1182 NO_STR
1183 VLINK_HELPSTR_IPADDR
1184 VLINK_HELPSTR_TIME_PARAM
1185 VLINK_HELPSTR_TIME_PARAM)
1186
paula2c62832003-04-23 17:01:31 +00001187ALIAS (ospf_area_vlink,
1188 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001189 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1190 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1191 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1192 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1193 VLINK_HELPSTR_IPADDR
1194 VLINK_HELPSTR_TIME_PARAM
1195 VLINK_HELPSTR_TIME_PARAM
1196 VLINK_HELPSTR_TIME_PARAM)
1197
paula2c62832003-04-23 17:01:31 +00001198ALIAS (no_ospf_area_vlink,
1199 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001200 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1201 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1202 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1203 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1204 NO_STR
1205 VLINK_HELPSTR_IPADDR
1206 VLINK_HELPSTR_TIME_PARAM
1207 VLINK_HELPSTR_TIME_PARAM
1208 VLINK_HELPSTR_TIME_PARAM)
1209
paula2c62832003-04-23 17:01:31 +00001210ALIAS (ospf_area_vlink,
1211 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001212 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1213 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1214 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1215 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1216 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1217 VLINK_HELPSTR_IPADDR
1218 VLINK_HELPSTR_TIME_PARAM
1219 VLINK_HELPSTR_TIME_PARAM
1220 VLINK_HELPSTR_TIME_PARAM
1221 VLINK_HELPSTR_TIME_PARAM)
1222
paula2c62832003-04-23 17:01:31 +00001223ALIAS (no_ospf_area_vlink,
1224 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001225 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1226 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1227 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1228 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1229 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1230 NO_STR
1231 VLINK_HELPSTR_IPADDR
1232 VLINK_HELPSTR_TIME_PARAM
1233 VLINK_HELPSTR_TIME_PARAM
1234 VLINK_HELPSTR_TIME_PARAM
1235 VLINK_HELPSTR_TIME_PARAM)
1236
paula2c62832003-04-23 17:01:31 +00001237ALIAS (ospf_area_vlink,
1238 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001239 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1240 "(authentication|) (message-digest|null)",
1241 VLINK_HELPSTR_IPADDR
1242 VLINK_HELPSTR_AUTHTYPE_ALL)
1243
paula2c62832003-04-23 17:01:31 +00001244ALIAS (ospf_area_vlink,
1245 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001246 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1247 "(authentication|)",
1248 VLINK_HELPSTR_IPADDR
1249 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1250
paula2c62832003-04-23 17:01:31 +00001251ALIAS (no_ospf_area_vlink,
1252 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001253 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1254 "(authentication|)",
1255 NO_STR
1256 VLINK_HELPSTR_IPADDR
1257 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1258
paula2c62832003-04-23 17:01:31 +00001259ALIAS (ospf_area_vlink,
1260 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001261 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1262 "(message-digest-key|) <1-255> md5 KEY",
1263 VLINK_HELPSTR_IPADDR
1264 VLINK_HELPSTR_AUTH_MD5)
1265
paula2c62832003-04-23 17:01:31 +00001266ALIAS (no_ospf_area_vlink,
1267 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001268 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1269 "(message-digest-key|) <1-255>",
1270 NO_STR
1271 VLINK_HELPSTR_IPADDR
1272 VLINK_HELPSTR_AUTH_MD5)
1273
paula2c62832003-04-23 17:01:31 +00001274ALIAS (ospf_area_vlink,
1275 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001276 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1277 "(authentication-key|) AUTH_KEY",
1278 VLINK_HELPSTR_IPADDR
1279 VLINK_HELPSTR_AUTH_SIMPLE)
1280
paula2c62832003-04-23 17:01:31 +00001281ALIAS (no_ospf_area_vlink,
1282 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001283 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1284 "(authentication-key|)",
1285 NO_STR
1286 VLINK_HELPSTR_IPADDR
1287 VLINK_HELPSTR_AUTH_SIMPLE)
1288
paula2c62832003-04-23 17:01:31 +00001289ALIAS (ospf_area_vlink,
1290 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001291 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1292 "(authentication|) (message-digest|null) "
1293 "(authentication-key|) AUTH_KEY",
1294 VLINK_HELPSTR_IPADDR
1295 VLINK_HELPSTR_AUTHTYPE_ALL
1296 VLINK_HELPSTR_AUTH_SIMPLE)
1297
paula2c62832003-04-23 17:01:31 +00001298ALIAS (ospf_area_vlink,
1299 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001300 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1301 "(authentication|) "
1302 "(authentication-key|) AUTH_KEY",
1303 VLINK_HELPSTR_IPADDR
1304 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1305 VLINK_HELPSTR_AUTH_SIMPLE)
1306
paula2c62832003-04-23 17:01:31 +00001307ALIAS (no_ospf_area_vlink,
1308 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001309 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1310 "(authentication|) "
1311 "(authentication-key|)",
1312 NO_STR
1313 VLINK_HELPSTR_IPADDR
1314 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1315 VLINK_HELPSTR_AUTH_SIMPLE)
1316
paula2c62832003-04-23 17:01:31 +00001317ALIAS (ospf_area_vlink,
1318 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001319 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1320 "(authentication|) (message-digest|null) "
1321 "(message-digest-key|) <1-255> md5 KEY",
1322 VLINK_HELPSTR_IPADDR
1323 VLINK_HELPSTR_AUTHTYPE_ALL
1324 VLINK_HELPSTR_AUTH_MD5)
1325
paula2c62832003-04-23 17:01:31 +00001326ALIAS (ospf_area_vlink,
1327 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001328 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1329 "(authentication|) "
1330 "(message-digest-key|) <1-255> md5 KEY",
1331 VLINK_HELPSTR_IPADDR
1332 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1333 VLINK_HELPSTR_AUTH_MD5)
1334
paula2c62832003-04-23 17:01:31 +00001335ALIAS (no_ospf_area_vlink,
1336 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001337 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1338 "(authentication|) "
1339 "(message-digest-key|)",
1340 NO_STR
1341 VLINK_HELPSTR_IPADDR
1342 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1343 VLINK_HELPSTR_AUTH_MD5)
1344
1345
paula2c62832003-04-23 17:01:31 +00001346DEFUN (ospf_area_shortcut,
1347 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001348 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1349 "OSPF area parameters\n"
1350 "OSPF area ID in IP address format\n"
1351 "OSPF area ID as a decimal value\n"
1352 "Configure the area's shortcutting mode\n"
1353 "Set default shortcutting behavior\n"
1354 "Enable shortcutting through the area\n"
1355 "Disable shortcutting through the area\n")
1356{
paul68980082003-03-25 05:07:42 +00001357 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001358 struct ospf_area *area;
1359 struct in_addr area_id;
1360 int mode;
1361 int format;
1362
1363 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1364
paul68980082003-03-25 05:07:42 +00001365 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001366
1367 if (strncmp (argv[1], "de", 2) == 0)
1368 mode = OSPF_SHORTCUT_DEFAULT;
1369 else if (strncmp (argv[1], "di", 2) == 0)
1370 mode = OSPF_SHORTCUT_DISABLE;
1371 else if (strncmp (argv[1], "e", 1) == 0)
1372 mode = OSPF_SHORTCUT_ENABLE;
1373 else
1374 return CMD_WARNING;
1375
paul68980082003-03-25 05:07:42 +00001376 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001377
paul68980082003-03-25 05:07:42 +00001378 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001379 vty_out (vty, "Shortcut area setting will take effect "
1380 "only when the router is configured as Shortcut ABR%s",
1381 VTY_NEWLINE);
1382
1383 return CMD_SUCCESS;
1384}
1385
paula2c62832003-04-23 17:01:31 +00001386DEFUN (no_ospf_area_shortcut,
1387 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001388 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1389 NO_STR
1390 "OSPF area parameters\n"
1391 "OSPF area ID in IP address format\n"
1392 "OSPF area ID as a decimal value\n"
1393 "Deconfigure the area's shortcutting mode\n"
1394 "Deconfigure enabled shortcutting through the area\n"
1395 "Deconfigure disabled shortcutting through the area\n")
1396{
paul68980082003-03-25 05:07:42 +00001397 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001398 struct ospf_area *area;
1399 struct in_addr area_id;
1400 int format;
1401
1402 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1403
paul68980082003-03-25 05:07:42 +00001404 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001405 if (!area)
1406 return CMD_SUCCESS;
1407
paul68980082003-03-25 05:07:42 +00001408 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001409
1410 return CMD_SUCCESS;
1411}
1412
1413
paula2c62832003-04-23 17:01:31 +00001414DEFUN (ospf_area_stub,
1415 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001416 "area (A.B.C.D|<0-4294967295>) stub",
1417 "OSPF area parameters\n"
1418 "OSPF area ID in IP address format\n"
1419 "OSPF area ID as a decimal value\n"
1420 "Configure OSPF area as stub\n")
1421{
1422 struct ospf *ospf = vty->index;
1423 struct in_addr area_id;
1424 int ret, format;
1425
1426 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1427
1428 ret = ospf_area_stub_set (ospf, area_id);
1429 if (ret == 0)
1430 {
1431 vty_out (vty, "First deconfigure all virtual link through this area%s",
1432 VTY_NEWLINE);
1433 return CMD_WARNING;
1434 }
1435
1436 ospf_area_no_summary_unset (ospf, area_id);
1437
1438 return CMD_SUCCESS;
1439}
1440
paula2c62832003-04-23 17:01:31 +00001441DEFUN (ospf_area_stub_no_summary,
1442 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001443 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1444 "OSPF stub parameters\n"
1445 "OSPF area ID in IP address format\n"
1446 "OSPF area ID as a decimal value\n"
1447 "Configure OSPF area as stub\n"
1448 "Do not inject inter-area routes into stub\n")
1449{
1450 struct ospf *ospf = vty->index;
1451 struct in_addr area_id;
1452 int ret, format;
1453
1454 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1455
1456 ret = ospf_area_stub_set (ospf, area_id);
1457 if (ret == 0)
1458 {
paulb0a053b2003-06-22 09:04:47 +00001459 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001460 VTY_NEWLINE);
1461 return CMD_WARNING;
1462 }
1463
1464 ospf_area_no_summary_set (ospf, area_id);
1465
1466 return CMD_SUCCESS;
1467}
1468
paula2c62832003-04-23 17:01:31 +00001469DEFUN (no_ospf_area_stub,
1470 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001471 "no area (A.B.C.D|<0-4294967295>) stub",
1472 NO_STR
1473 "OSPF area parameters\n"
1474 "OSPF area ID in IP address format\n"
1475 "OSPF area ID as a decimal value\n"
1476 "Configure OSPF area as stub\n")
1477{
1478 struct ospf *ospf = vty->index;
1479 struct in_addr area_id;
1480 int format;
1481
1482 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1483
1484 ospf_area_stub_unset (ospf, area_id);
1485 ospf_area_no_summary_unset (ospf, area_id);
1486
1487 return CMD_SUCCESS;
1488}
1489
paula2c62832003-04-23 17:01:31 +00001490DEFUN (no_ospf_area_stub_no_summary,
1491 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001492 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1493 NO_STR
1494 "OSPF area parameters\n"
1495 "OSPF area ID in IP address format\n"
1496 "OSPF area ID as a decimal value\n"
1497 "Configure OSPF area as stub\n"
1498 "Do not inject inter-area routes into area\n")
1499{
1500 struct ospf *ospf = vty->index;
1501 struct in_addr area_id;
1502 int format;
1503
1504 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1505 ospf_area_no_summary_unset (ospf, area_id);
1506
1507 return CMD_SUCCESS;
1508}
1509
paul4dadc292005-05-06 21:37:42 +00001510static int
paul6c835672004-10-11 11:00:30 +00001511ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1512 int nosum)
paul718e3742002-12-13 20:15:29 +00001513{
1514 struct ospf *ospf = vty->index;
1515 struct in_addr area_id;
1516 int ret, format;
1517
1518 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1519
1520 ret = ospf_area_nssa_set (ospf, area_id);
1521 if (ret == 0)
1522 {
1523 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1524 VTY_NEWLINE);
1525 return CMD_WARNING;
1526 }
1527
1528 if (argc > 1)
1529 {
1530 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001531 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001532 OSPF_NSSA_ROLE_CANDIDATE);
1533 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001534 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001535 OSPF_NSSA_ROLE_NEVER);
1536 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001537 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001538 OSPF_NSSA_ROLE_ALWAYS);
1539 }
paulb0a053b2003-06-22 09:04:47 +00001540 else
1541 {
1542 ospf_area_nssa_translator_role_set (ospf, area_id,
1543 OSPF_NSSA_ROLE_CANDIDATE);
1544 }
paul718e3742002-12-13 20:15:29 +00001545
paulb0a053b2003-06-22 09:04:47 +00001546 if (nosum)
paul718e3742002-12-13 20:15:29 +00001547 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001548 else
1549 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001550
paulb0a053b2003-06-22 09:04:47 +00001551 ospf_schedule_abr_task (ospf);
1552
paul718e3742002-12-13 20:15:29 +00001553 return CMD_SUCCESS;
1554}
1555
paulb0a053b2003-06-22 09:04:47 +00001556DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001557 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001558 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001559 "OSPF area parameters\n"
1560 "OSPF area ID in IP address format\n"
1561 "OSPF area ID as a decimal value\n"
1562 "Configure OSPF area as nssa\n"
1563 "Configure NSSA-ABR for translate election (default)\n"
1564 "Configure NSSA-ABR to never translate\n"
1565 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001566 "Do not inject inter-area routes into nssa\n")
1567{
1568 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1569}
paul718e3742002-12-13 20:15:29 +00001570
paulb0a053b2003-06-22 09:04:47 +00001571DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001572 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001573 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1574 "OSPF area parameters\n"
1575 "OSPF area ID in IP address format\n"
1576 "OSPF area ID as a decimal value\n"
1577 "Configure OSPF area as nssa\n"
1578 "Configure NSSA-ABR for translate election (default)\n"
1579 "Configure NSSA-ABR to never translate\n"
1580 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001581{
1582 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1583}
1584
1585DEFUN (ospf_area_nssa,
1586 ospf_area_nssa_cmd,
1587 "area (A.B.C.D|<0-4294967295>) nssa",
1588 "OSPF area parameters\n"
1589 "OSPF area ID in IP address format\n"
1590 "OSPF area ID as a decimal value\n"
1591 "Configure OSPF area as nssa\n")
1592{
1593 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1594}
paul718e3742002-12-13 20:15:29 +00001595
paula2c62832003-04-23 17:01:31 +00001596DEFUN (ospf_area_nssa_no_summary,
1597 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001598 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1599 "OSPF area parameters\n"
1600 "OSPF area ID in IP address format\n"
1601 "OSPF area ID as a decimal value\n"
1602 "Configure OSPF area as nssa\n"
1603 "Do not inject inter-area routes into nssa\n")
1604{
paulb0a053b2003-06-22 09:04:47 +00001605 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001606}
1607
paula2c62832003-04-23 17:01:31 +00001608DEFUN (no_ospf_area_nssa,
1609 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001610 "no area (A.B.C.D|<0-4294967295>) nssa",
1611 NO_STR
1612 "OSPF area parameters\n"
1613 "OSPF area ID in IP address format\n"
1614 "OSPF area ID as a decimal value\n"
1615 "Configure OSPF area as nssa\n")
1616{
1617 struct ospf *ospf = vty->index;
1618 struct in_addr area_id;
1619 int format;
1620
1621 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1622
1623 ospf_area_nssa_unset (ospf, area_id);
1624 ospf_area_no_summary_unset (ospf, area_id);
1625
paulb0a053b2003-06-22 09:04:47 +00001626 ospf_schedule_abr_task (ospf);
1627
paul718e3742002-12-13 20:15:29 +00001628 return CMD_SUCCESS;
1629}
1630
paula2c62832003-04-23 17:01:31 +00001631DEFUN (no_ospf_area_nssa_no_summary,
1632 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001633 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1634 NO_STR
1635 "OSPF area parameters\n"
1636 "OSPF area ID in IP address format\n"
1637 "OSPF area ID as a decimal value\n"
1638 "Configure OSPF area as nssa\n"
1639 "Do not inject inter-area routes into nssa\n")
1640{
1641 struct ospf *ospf = vty->index;
1642 struct in_addr area_id;
1643 int format;
1644
1645 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1646 ospf_area_no_summary_unset (ospf, area_id);
1647
1648 return CMD_SUCCESS;
1649}
1650
paula2c62832003-04-23 17:01:31 +00001651DEFUN (ospf_area_default_cost,
1652 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001653 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1654 "OSPF area parameters\n"
1655 "OSPF area ID in IP address format\n"
1656 "OSPF area ID as a decimal value\n"
1657 "Set the summary-default cost of a NSSA or stub area\n"
1658 "Stub's advertised default summary cost\n")
1659{
paul68980082003-03-25 05:07:42 +00001660 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001661 struct ospf_area *area;
1662 struct in_addr area_id;
1663 u_int32_t cost;
1664 int format;
vincentba682532005-09-29 13:52:57 +00001665 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001666
1667 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1668 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1669
paul68980082003-03-25 05:07:42 +00001670 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001671
1672 if (area->external_routing == OSPF_AREA_DEFAULT)
1673 {
1674 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1675 return CMD_WARNING;
1676 }
1677
1678 area->default_cost = cost;
1679
vincentba682532005-09-29 13:52:57 +00001680 p.family = AF_INET;
1681 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1682 p.prefixlen = 0;
1683 if (IS_DEBUG_OSPF_EVENT)
1684 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1685 "announcing 0.0.0.0/0 to area %s",
1686 inet_ntoa (area->area_id));
1687 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1688
paul718e3742002-12-13 20:15:29 +00001689 return CMD_SUCCESS;
1690}
1691
paula2c62832003-04-23 17:01:31 +00001692DEFUN (no_ospf_area_default_cost,
1693 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001694 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1695 NO_STR
1696 "OSPF area parameters\n"
1697 "OSPF area ID in IP address format\n"
1698 "OSPF area ID as a decimal value\n"
1699 "Set the summary-default cost of a NSSA or stub area\n"
1700 "Stub's advertised default summary cost\n")
1701{
paul68980082003-03-25 05:07:42 +00001702 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001703 struct ospf_area *area;
1704 struct in_addr area_id;
1705 u_int32_t cost;
1706 int format;
vincentba682532005-09-29 13:52:57 +00001707 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001708
1709 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1710 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1711
paul68980082003-03-25 05:07:42 +00001712 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001713 if (area == NULL)
1714 return CMD_SUCCESS;
1715
1716 if (area->external_routing == OSPF_AREA_DEFAULT)
1717 {
1718 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1719 return CMD_WARNING;
1720 }
1721
1722 area->default_cost = 1;
1723
vincentba682532005-09-29 13:52:57 +00001724 p.family = AF_INET;
1725 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1726 p.prefixlen = 0;
1727 if (IS_DEBUG_OSPF_EVENT)
1728 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1729 "announcing 0.0.0.0/0 to area %s",
1730 inet_ntoa (area->area_id));
1731 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1732
1733
paul68980082003-03-25 05:07:42 +00001734 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001735
1736 return CMD_SUCCESS;
1737}
1738
paula2c62832003-04-23 17:01:31 +00001739DEFUN (ospf_area_export_list,
1740 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001741 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1742 "OSPF area parameters\n"
1743 "OSPF area ID in IP address format\n"
1744 "OSPF area ID as a decimal value\n"
1745 "Set the filter for networks announced to other areas\n"
1746 "Name of the access-list\n")
1747{
paul68980082003-03-25 05:07:42 +00001748 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001749 struct ospf_area *area;
1750 struct in_addr area_id;
1751 int format;
1752
hasso52930762004-04-19 18:26:53 +00001753 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1754
paul68980082003-03-25 05:07:42 +00001755 area = ospf_area_get (ospf, area_id, format);
1756 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001757
1758 return CMD_SUCCESS;
1759}
1760
paula2c62832003-04-23 17:01:31 +00001761DEFUN (no_ospf_area_export_list,
1762 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001763 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1764 NO_STR
1765 "OSPF area parameters\n"
1766 "OSPF area ID in IP address format\n"
1767 "OSPF area ID as a decimal value\n"
1768 "Unset the filter for networks announced to other areas\n"
1769 "Name of the access-list\n")
1770{
paul68980082003-03-25 05:07:42 +00001771 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001772 struct ospf_area *area;
1773 struct in_addr area_id;
1774 int format;
1775
hasso52930762004-04-19 18:26:53 +00001776 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1777
paul68980082003-03-25 05:07:42 +00001778 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001779 if (area == NULL)
1780 return CMD_SUCCESS;
1781
paul68980082003-03-25 05:07:42 +00001782 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001783
1784 return CMD_SUCCESS;
1785}
1786
1787
paula2c62832003-04-23 17:01:31 +00001788DEFUN (ospf_area_import_list,
1789 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001790 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1791 "OSPF area parameters\n"
1792 "OSPF area ID in IP address format\n"
1793 "OSPF area ID as a decimal value\n"
1794 "Set the filter for networks from other areas announced to the specified one\n"
1795 "Name of the access-list\n")
1796{
paul68980082003-03-25 05:07:42 +00001797 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001798 struct ospf_area *area;
1799 struct in_addr area_id;
1800 int format;
1801
hasso52930762004-04-19 18:26:53 +00001802 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1803
paul68980082003-03-25 05:07:42 +00001804 area = ospf_area_get (ospf, area_id, format);
1805 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001806
1807 return CMD_SUCCESS;
1808}
1809
paula2c62832003-04-23 17:01:31 +00001810DEFUN (no_ospf_area_import_list,
1811 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001812 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1813 NO_STR
1814 "OSPF area parameters\n"
1815 "OSPF area ID in IP address format\n"
1816 "OSPF area ID as a decimal value\n"
1817 "Unset the filter for networks announced to other areas\n"
1818 "Name of the access-list\n")
1819{
paul68980082003-03-25 05:07:42 +00001820 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001821 struct ospf_area *area;
1822 struct in_addr area_id;
1823 int format;
1824
hasso52930762004-04-19 18:26:53 +00001825 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1826
paul68980082003-03-25 05:07:42 +00001827 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001828 if (area == NULL)
1829 return CMD_SUCCESS;
1830
paul68980082003-03-25 05:07:42 +00001831 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001832
1833 return CMD_SUCCESS;
1834}
1835
paula2c62832003-04-23 17:01:31 +00001836DEFUN (ospf_area_filter_list,
1837 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001838 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1839 "OSPF area parameters\n"
1840 "OSPF area ID in IP address format\n"
1841 "OSPF area ID as a decimal value\n"
1842 "Filter networks between OSPF areas\n"
1843 "Filter prefixes between OSPF areas\n"
1844 "Name of an IP prefix-list\n"
1845 "Filter networks sent to this area\n"
1846 "Filter networks sent from this area\n")
1847{
paul68980082003-03-25 05:07:42 +00001848 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001849 struct ospf_area *area;
1850 struct in_addr area_id;
1851 struct prefix_list *plist;
1852 int format;
1853
1854 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1855
paul68980082003-03-25 05:07:42 +00001856 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001857 plist = prefix_list_lookup (AFI_IP, argv[1]);
1858 if (strncmp (argv[2], "in", 2) == 0)
1859 {
1860 PREFIX_LIST_IN (area) = plist;
1861 if (PREFIX_NAME_IN (area))
1862 free (PREFIX_NAME_IN (area));
1863
1864 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001865 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001866 }
1867 else
1868 {
1869 PREFIX_LIST_OUT (area) = plist;
1870 if (PREFIX_NAME_OUT (area))
1871 free (PREFIX_NAME_OUT (area));
1872
1873 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001874 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001875 }
1876
1877 return CMD_SUCCESS;
1878}
1879
paula2c62832003-04-23 17:01:31 +00001880DEFUN (no_ospf_area_filter_list,
1881 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001882 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1883 NO_STR
1884 "OSPF area parameters\n"
1885 "OSPF area ID in IP address format\n"
1886 "OSPF area ID as a decimal value\n"
1887 "Filter networks between OSPF areas\n"
1888 "Filter prefixes between OSPF areas\n"
1889 "Name of an IP prefix-list\n"
1890 "Filter networks sent to this area\n"
1891 "Filter networks sent from this area\n")
1892{
paul68980082003-03-25 05:07:42 +00001893 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001894 struct ospf_area *area;
1895 struct in_addr area_id;
1896 struct prefix_list *plist;
1897 int format;
1898
1899 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1900
paul68980082003-03-25 05:07:42 +00001901 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001902 plist = prefix_list_lookup (AFI_IP, argv[1]);
1903 if (strncmp (argv[2], "in", 2) == 0)
1904 {
1905 if (PREFIX_NAME_IN (area))
1906 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1907 return CMD_SUCCESS;
1908
1909 PREFIX_LIST_IN (area) = NULL;
1910 if (PREFIX_NAME_IN (area))
1911 free (PREFIX_NAME_IN (area));
1912
1913 PREFIX_NAME_IN (area) = NULL;
1914
paul68980082003-03-25 05:07:42 +00001915 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001916 }
1917 else
1918 {
1919 if (PREFIX_NAME_OUT (area))
1920 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1921 return CMD_SUCCESS;
1922
1923 PREFIX_LIST_OUT (area) = NULL;
1924 if (PREFIX_NAME_OUT (area))
1925 free (PREFIX_NAME_OUT (area));
1926
1927 PREFIX_NAME_OUT (area) = NULL;
1928
paul68980082003-03-25 05:07:42 +00001929 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001930 }
1931
1932 return CMD_SUCCESS;
1933}
1934
1935
paula2c62832003-04-23 17:01:31 +00001936DEFUN (ospf_area_authentication_message_digest,
1937 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001938 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1939 "OSPF area parameters\n"
1940 "Enable authentication\n"
1941 "Use message-digest authentication\n")
1942{
paul68980082003-03-25 05:07:42 +00001943 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001944 struct ospf_area *area;
1945 struct in_addr area_id;
1946 int format;
1947
1948 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1949
paul68980082003-03-25 05:07:42 +00001950 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001951 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1952
1953 return CMD_SUCCESS;
1954}
1955
paula2c62832003-04-23 17:01:31 +00001956DEFUN (ospf_area_authentication,
1957 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001958 "area (A.B.C.D|<0-4294967295>) authentication",
1959 "OSPF area parameters\n"
1960 "OSPF area ID in IP address format\n"
1961 "OSPF area ID as a decimal value\n"
1962 "Enable authentication\n")
1963{
paul68980082003-03-25 05:07:42 +00001964 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001965 struct ospf_area *area;
1966 struct in_addr area_id;
1967 int format;
1968
1969 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1970
paul68980082003-03-25 05:07:42 +00001971 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001972 area->auth_type = OSPF_AUTH_SIMPLE;
1973
1974 return CMD_SUCCESS;
1975}
1976
paula2c62832003-04-23 17:01:31 +00001977DEFUN (no_ospf_area_authentication,
1978 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001979 "no area (A.B.C.D|<0-4294967295>) authentication",
1980 NO_STR
1981 "OSPF area parameters\n"
1982 "OSPF area ID in IP address format\n"
1983 "OSPF area ID as a decimal value\n"
1984 "Enable authentication\n")
1985{
paul68980082003-03-25 05:07:42 +00001986 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001987 struct ospf_area *area;
1988 struct in_addr area_id;
1989 int format;
1990
1991 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1992
paul68980082003-03-25 05:07:42 +00001993 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001994 if (area == NULL)
1995 return CMD_SUCCESS;
1996
1997 area->auth_type = OSPF_AUTH_NULL;
1998
paul68980082003-03-25 05:07:42 +00001999 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002000
2001 return CMD_SUCCESS;
2002}
2003
2004
2005DEFUN (ospf_abr_type,
2006 ospf_abr_type_cmd,
2007 "ospf abr-type (cisco|ibm|shortcut|standard)",
2008 "OSPF specific commands\n"
2009 "Set OSPF ABR type\n"
2010 "Alternative ABR, cisco implementation\n"
2011 "Alternative ABR, IBM implementation\n"
2012 "Shortcut ABR\n"
2013 "Standard behavior (RFC2328)\n")
2014{
paul68980082003-03-25 05:07:42 +00002015 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002016 u_char abr_type = OSPF_ABR_UNKNOWN;
2017
2018 if (strncmp (argv[0], "c", 1) == 0)
2019 abr_type = OSPF_ABR_CISCO;
2020 else if (strncmp (argv[0], "i", 1) == 0)
2021 abr_type = OSPF_ABR_IBM;
2022 else if (strncmp (argv[0], "sh", 2) == 0)
2023 abr_type = OSPF_ABR_SHORTCUT;
2024 else if (strncmp (argv[0], "st", 2) == 0)
2025 abr_type = OSPF_ABR_STAND;
2026 else
2027 return CMD_WARNING;
2028
2029 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002030 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002031 {
paul68980082003-03-25 05:07:42 +00002032 ospf->abr_type = abr_type;
2033 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002034 }
2035
2036 return CMD_SUCCESS;
2037}
2038
2039DEFUN (no_ospf_abr_type,
2040 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002041 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002042 NO_STR
2043 "OSPF specific commands\n"
2044 "Set OSPF ABR type\n"
2045 "Alternative ABR, cisco implementation\n"
2046 "Alternative ABR, IBM implementation\n"
2047 "Shortcut ABR\n")
2048{
paul68980082003-03-25 05:07:42 +00002049 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002050 u_char abr_type = OSPF_ABR_UNKNOWN;
2051
2052 if (strncmp (argv[0], "c", 1) == 0)
2053 abr_type = OSPF_ABR_CISCO;
2054 else if (strncmp (argv[0], "i", 1) == 0)
2055 abr_type = OSPF_ABR_IBM;
2056 else if (strncmp (argv[0], "s", 1) == 0)
2057 abr_type = OSPF_ABR_SHORTCUT;
2058 else
2059 return CMD_WARNING;
2060
2061 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002062 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002063 {
pauld57834f2005-07-12 20:04:22 +00002064 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002065 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002066 }
2067
2068 return CMD_SUCCESS;
2069}
2070
2071DEFUN (ospf_compatible_rfc1583,
2072 ospf_compatible_rfc1583_cmd,
2073 "compatible rfc1583",
2074 "OSPF compatibility list\n"
2075 "compatible with RFC 1583\n")
2076{
2077 struct ospf *ospf = vty->index;
2078
2079 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2080 {
2081 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002082 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002083 }
2084 return CMD_SUCCESS;
2085}
2086
2087DEFUN (no_ospf_compatible_rfc1583,
2088 no_ospf_compatible_rfc1583_cmd,
2089 "no compatible rfc1583",
2090 NO_STR
2091 "OSPF compatibility list\n"
2092 "compatible with RFC 1583\n")
2093{
2094 struct ospf *ospf = vty->index;
2095
2096 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2097 {
2098 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002099 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002100 }
2101 return CMD_SUCCESS;
2102}
2103
2104ALIAS (ospf_compatible_rfc1583,
2105 ospf_rfc1583_flag_cmd,
2106 "ospf rfc1583compatibility",
2107 "OSPF specific commands\n"
2108 "Enable the RFC1583Compatibility flag\n")
2109
2110ALIAS (no_ospf_compatible_rfc1583,
2111 no_ospf_rfc1583_flag_cmd,
2112 "no ospf rfc1583compatibility",
2113 NO_STR
2114 "OSPF specific commands\n"
2115 "Disable the RFC1583Compatibility flag\n")
pauld24f6e22005-10-21 09:23:12 +00002116
2117static int
2118ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2119 unsigned int hold,
2120 unsigned int max)
2121{
2122 struct ospf *ospf = vty->index;
2123
2124 ospf->spf_delay = delay;
2125 ospf->spf_holdtime = hold;
2126 ospf->spf_max_holdtime = max;
2127
2128 return CMD_SUCCESS;
2129}
paul718e3742002-12-13 20:15:29 +00002130
pauld24f6e22005-10-21 09:23:12 +00002131DEFUN (ospf_timers_throttle_spf,
2132 ospf_timers_throttle_spf_cmd,
2133 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2134 "Adjust routing timers\n"
2135 "Throttling adaptive timer\n"
2136 "OSPF SPF timers\n"
2137 "Delay (msec) from first change received till SPF calculation\n"
2138 "Initial hold time (msec) between consecutive SPF calculations\n"
2139 "Maximum hold time (msec)\n")
2140{
2141 unsigned int delay, hold, max;
2142
2143 if (argc != 3)
2144 {
2145 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2146 return CMD_WARNING;
2147 }
2148
2149 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2150 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2151 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2152
2153 return ospf_timers_spf_set (vty, delay, hold, max);
2154}
2155
2156DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002157 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002158 "timers spf <0-4294967295> <0-4294967295>",
2159 "Adjust routing timers\n"
2160 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002161 "Delay (s) between receiving a change to SPF calculation\n"
2162 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002163{
pauld24f6e22005-10-21 09:23:12 +00002164 unsigned int delay, hold;
2165
2166 if (argc != 2)
2167 {
2168 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2169 return CMD_WARNING;
2170 }
2171
paul4dadc292005-05-06 21:37:42 +00002172 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2173 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002174
2175 /* truncate down the second values if they're greater than 600000ms */
2176 if (delay > (600000 / 1000))
2177 delay = 600000;
2178 else if (delay == 0)
2179 /* 0s delay was probably specified because of lack of ms resolution */
2180 delay = OSPF_SPF_DELAY_DEFAULT;
2181 if (hold > (600000 / 1000))
2182 hold = 600000;
2183
2184 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002185}
2186
pauld24f6e22005-10-21 09:23:12 +00002187DEFUN (no_ospf_timers_throttle_spf,
2188 no_ospf_timers_throttle_spf_cmd,
2189 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002190 NO_STR
2191 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002192 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002193 "OSPF SPF timers\n")
2194{
pauld24f6e22005-10-21 09:23:12 +00002195 return ospf_timers_spf_set (vty,
2196 OSPF_SPF_DELAY_DEFAULT,
2197 OSPF_SPF_HOLDTIME_DEFAULT,
2198 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002199}
2200
pauld24f6e22005-10-21 09:23:12 +00002201ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2202 no_ospf_timers_spf_cmd,
2203 "no timers spf",
2204 NO_STR
2205 "Adjust routing timers\n"
2206 "OSPF SPF timers\n")
paul718e3742002-12-13 20:15:29 +00002207
paula2c62832003-04-23 17:01:31 +00002208DEFUN (ospf_neighbor,
2209 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002210 "neighbor A.B.C.D",
2211 NEIGHBOR_STR
2212 "Neighbor IP address\n")
2213{
2214 struct ospf *ospf = vty->index;
2215 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002216 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2217 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002218
2219 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2220
2221 if (argc > 1)
2222 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2223
2224 if (argc > 2)
2225 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2226
2227 ospf_nbr_nbma_set (ospf, nbr_addr);
2228 if (argc > 1)
2229 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2230 if (argc > 2)
2231 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2232
2233 return CMD_SUCCESS;
2234}
2235
paula2c62832003-04-23 17:01:31 +00002236ALIAS (ospf_neighbor,
2237 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002238 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2239 NEIGHBOR_STR
2240 "Neighbor IP address\n"
2241 "Neighbor Priority\n"
2242 "Priority\n"
2243 "Dead Neighbor Polling interval\n"
2244 "Seconds\n")
2245
paula2c62832003-04-23 17:01:31 +00002246ALIAS (ospf_neighbor,
2247 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002248 "neighbor A.B.C.D priority <0-255>",
2249 NEIGHBOR_STR
2250 "Neighbor IP address\n"
2251 "Neighbor Priority\n"
2252 "Seconds\n")
2253
paula2c62832003-04-23 17:01:31 +00002254DEFUN (ospf_neighbor_poll_interval,
2255 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002256 "neighbor A.B.C.D poll-interval <1-65535>",
2257 NEIGHBOR_STR
2258 "Neighbor IP address\n"
2259 "Dead Neighbor Polling interval\n"
2260 "Seconds\n")
2261{
2262 struct ospf *ospf = vty->index;
2263 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002264 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2265 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002266
2267 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2268
2269 if (argc > 1)
2270 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2271
2272 if (argc > 2)
2273 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2274
2275 ospf_nbr_nbma_set (ospf, nbr_addr);
2276 if (argc > 1)
2277 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2278 if (argc > 2)
2279 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2280
2281 return CMD_SUCCESS;
2282}
2283
paula2c62832003-04-23 17:01:31 +00002284ALIAS (ospf_neighbor_poll_interval,
2285 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002286 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2287 NEIGHBOR_STR
2288 "Neighbor address\n"
2289 "OSPF dead-router polling interval\n"
2290 "Seconds\n"
2291 "OSPF priority of non-broadcast neighbor\n"
2292 "Priority\n")
2293
paula2c62832003-04-23 17:01:31 +00002294DEFUN (no_ospf_neighbor,
2295 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002296 "no neighbor A.B.C.D",
2297 NO_STR
2298 NEIGHBOR_STR
2299 "Neighbor IP address\n")
2300{
2301 struct ospf *ospf = vty->index;
2302 struct in_addr nbr_addr;
2303 int ret;
2304
2305 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2306
2307 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2308
2309 return CMD_SUCCESS;
2310}
2311
paula2c62832003-04-23 17:01:31 +00002312ALIAS (no_ospf_neighbor,
2313 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002314 "no neighbor A.B.C.D priority <0-255>",
2315 NO_STR
2316 NEIGHBOR_STR
2317 "Neighbor IP address\n"
2318 "Neighbor Priority\n"
2319 "Priority\n")
2320
paula2c62832003-04-23 17:01:31 +00002321ALIAS (no_ospf_neighbor,
2322 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002323 "no neighbor A.B.C.D poll-interval <1-65535>",
2324 NO_STR
2325 NEIGHBOR_STR
2326 "Neighbor IP address\n"
2327 "Dead Neighbor Polling interval\n"
2328 "Seconds\n")
2329
paula2c62832003-04-23 17:01:31 +00002330ALIAS (no_ospf_neighbor,
2331 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002332 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2333 NO_STR
2334 NEIGHBOR_STR
2335 "Neighbor IP address\n"
2336 "Neighbor Priority\n"
2337 "Priority\n"
2338 "Dead Neighbor Polling interval\n"
2339 "Seconds\n")
2340
2341
paula2c62832003-04-23 17:01:31 +00002342DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002343 "refresh timer <10-1800>",
2344 "Adjust refresh parameters\n"
2345 "Set refresh timer\n"
2346 "Timer value in seconds\n")
2347{
2348 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002349 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002350
2351 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2352 interval = (interval / 10) * 10;
2353
2354 ospf_timers_refresh_set (ospf, interval);
2355
2356 return CMD_SUCCESS;
2357}
2358
paula2c62832003-04-23 17:01:31 +00002359DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002360 "no refresh timer <10-1800>",
2361 "Adjust refresh parameters\n"
2362 "Unset refresh timer\n"
2363 "Timer value in seconds\n")
2364{
2365 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002366 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002367
2368 if (argc == 1)
2369 {
2370 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2371
2372 if (ospf->lsa_refresh_interval != interval ||
2373 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2374 return CMD_SUCCESS;
2375 }
2376
2377 ospf_timers_refresh_unset (ospf);
2378
2379 return CMD_SUCCESS;
2380}
2381
paula2c62832003-04-23 17:01:31 +00002382ALIAS (no_ospf_refresh_timer,
2383 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002384 "no refresh timer",
2385 "Adjust refresh parameters\n"
2386 "Unset refresh timer\n")
2387
paula2c62832003-04-23 17:01:31 +00002388DEFUN (ospf_auto_cost_reference_bandwidth,
2389 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002390 "auto-cost reference-bandwidth <1-4294967>",
2391 "Calculate OSPF interface cost according to bandwidth\n"
2392 "Use reference bandwidth method to assign OSPF cost\n"
2393 "The reference bandwidth in terms of Mbits per second\n")
2394{
paul68980082003-03-25 05:07:42 +00002395 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002396 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002397 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002398 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002399
2400 refbw = strtol (argv[0], NULL, 10);
2401 if (refbw < 1 || refbw > 4294967)
2402 {
2403 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2404 return CMD_WARNING;
2405 }
2406
2407 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002408 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002409 return CMD_SUCCESS;
2410
paul68980082003-03-25 05:07:42 +00002411 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002412 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2413 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002414
2415 return CMD_SUCCESS;
2416}
2417
paula2c62832003-04-23 17:01:31 +00002418DEFUN (no_ospf_auto_cost_reference_bandwidth,
2419 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002420 "no auto-cost reference-bandwidth",
2421 NO_STR
2422 "Calculate OSPF interface cost according to bandwidth\n"
2423 "Use reference bandwidth method to assign OSPF cost\n")
2424{
paul68980082003-03-25 05:07:42 +00002425 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002426 struct listnode *node, *nnode;
2427 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002428
paul68980082003-03-25 05:07:42 +00002429 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002430 return CMD_SUCCESS;
2431
paul68980082003-03-25 05:07:42 +00002432 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002433 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2434 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2435
paul1eb8ef22005-04-07 07:30:20 +00002436 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2437 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002438
2439 return CMD_SUCCESS;
2440}
2441
hassoeb1ce602004-10-08 08:17:22 +00002442const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002443{
2444 "Unknown",
2445 "Standard (RFC2328)",
2446 "Alternative IBM",
2447 "Alternative Cisco",
2448 "Alternative Shortcut"
2449};
2450
hassoeb1ce602004-10-08 08:17:22 +00002451const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002452{
2453 "Default",
2454 "Enabled",
2455 "Disabled"
2456};
2457
2458
2459
paul4dadc292005-05-06 21:37:42 +00002460static void
paul718e3742002-12-13 20:15:29 +00002461show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2462{
2463 /* Show Area ID. */
2464 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2465
2466 /* Show Area type/mode. */
2467 if (OSPF_IS_AREA_BACKBONE (area))
2468 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2469 else
2470 {
2471 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002472 vty_out (vty, " (Stub%s%s)",
2473 area->no_summary ? ", no summary" : "",
2474 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002475
paulb0a053b2003-06-22 09:04:47 +00002476 else if (area->external_routing == OSPF_AREA_NSSA)
2477 vty_out (vty, " (NSSA%s%s)",
2478 area->no_summary ? ", no summary" : "",
2479 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002480
2481 vty_out (vty, "%s", VTY_NEWLINE);
2482 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002483 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002484 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002485 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002486 }
2487
2488 /* Show number of interfaces. */
2489 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2490 "Active: %d%s", listcount (area->oiflist),
2491 area->act_ints, VTY_NEWLINE);
2492
paul718e3742002-12-13 20:15:29 +00002493 if (area->external_routing == OSPF_AREA_NSSA)
2494 {
2495 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00002496 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002497 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2498 VTY_NEWLINE);
2499 else if (area->NSSATranslatorState)
2500 {
2501 vty_out (vty, " We are an ABR and ");
2502 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2503 vty_out (vty, "the NSSA Elected Translator. %s",
2504 VTY_NEWLINE);
2505 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2506 vty_out (vty, "always an NSSA Translator. %s",
2507 VTY_NEWLINE);
2508 }
paul718e3742002-12-13 20:15:29 +00002509 else
paulb0a053b2003-06-22 09:04:47 +00002510 {
2511 vty_out (vty, " We are an ABR, but ");
2512 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2513 vty_out (vty, "not the NSSA Elected Translator. %s",
2514 VTY_NEWLINE);
2515 else
hassoc6b87812004-12-22 13:09:59 +00002516 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002517 VTY_NEWLINE);
2518 }
paul718e3742002-12-13 20:15:29 +00002519 }
paul718e3742002-12-13 20:15:29 +00002520
2521 /* Show number of fully adjacent neighbors. */
2522 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002523 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002524
2525 /* Show authentication type. */
2526 vty_out (vty, " Area has ");
2527 if (area->auth_type == OSPF_AUTH_NULL)
2528 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2529 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2530 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2531 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2532 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2533
2534 if (!OSPF_IS_AREA_BACKBONE (area))
2535 vty_out (vty, " Number of full virtual adjacencies going through"
2536 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2537
2538 /* Show SPF calculation times. */
2539 vty_out (vty, " SPF algorithm executed %d times%s",
2540 area->spf_calculation, VTY_NEWLINE);
2541
2542 /* Show number of LSA. */
2543 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002544 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2545 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2546 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2547 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2548 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2549 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2550 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2551 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2552 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2553 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2554 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2555 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2556 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2557 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2558 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2559#ifdef HAVE_OPAQUE_LSA
2560 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2561 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2562 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2563 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2564 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2565 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2566#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002567 vty_out (vty, "%s", VTY_NEWLINE);
2568}
2569
2570DEFUN (show_ip_ospf,
2571 show_ip_ospf_cmd,
2572 "show ip ospf",
2573 SHOW_STR
2574 IP_STR
2575 "OSPF information\n")
2576{
paul1eb8ef22005-04-07 07:30:20 +00002577 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002578 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002579 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002580 struct timeval result;
2581 char timebuf[13]; /* XX:XX:XX.XXX(nul) */
paul718e3742002-12-13 20:15:29 +00002582
2583 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002584 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002585 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002586 {
2587 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2588 return CMD_SUCCESS;
2589 }
2590
2591 /* Show Router ID. */
2592 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002593 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002594 VTY_NEWLINE);
2595
2596 /* Show capability. */
2597 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2598 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2599 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002600 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002601 "enabled" : "disabled", VTY_NEWLINE);
2602#ifdef HAVE_OPAQUE_LSA
2603 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002604 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002605 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002606 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002607 " (origination blocked)" : "",
2608 VTY_NEWLINE);
2609#endif /* HAVE_OPAQUE_LSA */
2610
2611 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002612 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2613 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2614 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2615 " Hold time multiplier is currently %d%s",
2616 ospf->spf_delay, VTY_NEWLINE,
2617 ospf->spf_holdtime, VTY_NEWLINE,
2618 ospf->spf_max_holdtime, VTY_NEWLINE,
2619 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002620 vty_out (vty, " SPF algorithm ");
2621 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2622 {
2623 timersub (&recent_time, &ospf->ts_spf, &result);
2624 vty_out (vty, "last executed %s ago%s",
2625 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2626 VTY_NEWLINE);
2627 }
2628 else
2629 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002630 vty_out (vty, " SPF timer %s%s%s",
2631 (ospf->t_spf_calc ? "due in " : "is "),
2632 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2633 VTY_NEWLINE);
2634
paul718e3742002-12-13 20:15:29 +00002635 /* Show refresh parameters. */
2636 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002637 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002638
2639 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002640 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002641 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002642 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002643
paul68980082003-03-25 05:07:42 +00002644 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002645 vty_out (vty, " This router is an ASBR "
2646 "(injecting external routing information)%s", VTY_NEWLINE);
2647
2648 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002649 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2650 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2651 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2652#ifdef HAVE_OPAQUE_LSA
2653 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2654 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2655 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2656#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002657 /* Show number of areas attached. */
2658 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002659 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002660
2661 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002662 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2663 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002664
2665 return CMD_SUCCESS;
2666}
2667
2668
ajsfd651fa2005-03-29 16:08:16 +00002669static void
paul68980082003-03-25 05:07:42 +00002670show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2671 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002672{
ajsfd651fa2005-03-29 16:08:16 +00002673 int is_up;
paul718e3742002-12-13 20:15:29 +00002674 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002675 struct route_node *rn;
2676 char buf[9];
2677
paul718e3742002-12-13 20:15:29 +00002678 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002679 vty_out (vty, "%s is %s%s", ifp->name,
2680 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002681 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2682 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2683 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002684
2685 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002686 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002687 {
2688 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2689 return;
2690 }
ajsfd651fa2005-03-29 16:08:16 +00002691 else if (!is_up)
2692 {
2693 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2694 VTY_NEWLINE);
2695 return;
2696 }
2697
paul718e3742002-12-13 20:15:29 +00002698 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2699 {
2700 struct ospf_interface *oi = rn->info;
2701
2702 if (oi == NULL)
2703 continue;
2704
2705 /* Show OSPF interface information. */
2706 vty_out (vty, " Internet Address %s/%d,",
2707 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2708
hasso3fb9cd62004-10-19 19:44:43 +00002709 if (oi->connected->destination)
2710 vty_out (vty, " %s %s,",
2711 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2712 inet_ntoa (oi->connected->destination->u.prefix4));
2713
paul718e3742002-12-13 20:15:29 +00002714 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2715 VTY_NEWLINE);
2716
vincentba682532005-09-29 13:52:57 +00002717 vty_out (vty, " MTU mismatch detection:%s%s",
2718 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2719
paul718e3742002-12-13 20:15:29 +00002720 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002721 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002722 oi->output_cost, VTY_NEWLINE);
2723
2724 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2725 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2726 PRIORITY (oi), VTY_NEWLINE);
2727
2728 /* Show DR information. */
2729 if (DR (oi).s_addr == 0)
2730 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2731 else
2732 {
2733 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2734 if (nbr == NULL)
2735 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2736 else
2737 {
2738 vty_out (vty, " Designated Router (ID) %s,",
2739 inet_ntoa (nbr->router_id));
2740 vty_out (vty, " Interface Address %s%s",
2741 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2742 }
2743 }
2744
2745 /* Show BDR information. */
2746 if (BDR (oi).s_addr == 0)
2747 vty_out (vty, " No backup designated router on this network%s",
2748 VTY_NEWLINE);
2749 else
2750 {
2751 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2752 if (nbr == NULL)
2753 vty_out (vty, " No backup designated router on this network%s",
2754 VTY_NEWLINE);
2755 else
2756 {
2757 vty_out (vty, " Backup Designated Router (ID) %s,",
2758 inet_ntoa (nbr->router_id));
2759 vty_out (vty, " Interface Address %s%s",
2760 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2761 }
2762 }
ajsba6454e2005-02-08 15:37:30 +00002763
2764 vty_out (vty, " Multicast group memberships:");
2765 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2766 vty_out (vty, " OSPFAllRouters");
2767 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2768 vty_out (vty, " OSPFDesignatedRouters");
2769 if (!CHECK_FLAG(oi->multicast_memberships,
2770 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2771 vty_out (vty, " <None>");
2772 vty_out (vty, "%s", VTY_NEWLINE);
2773
paul718e3742002-12-13 20:15:29 +00002774 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00002775 vty_out (vty, " Hello ");
2776 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2777 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2778 else
2779 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2780 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2781 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00002782 OSPF_IF_PARAM (oi, v_wait),
2783 OSPF_IF_PARAM (oi, retransmit_interval),
2784 VTY_NEWLINE);
2785
2786 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00002787 {
2788 int timer_slen = 9; /* length of "hh:mm:ss(nul)" */
2789
2790 /* for fast hello we also want to see the .XXXX ms part */
2791 if (OSPF_IF_PARAM (oi, fast_hello))
2792 timer_slen += 5;
2793
2794 vty_out (vty, " Hello due in %s%s",
2795 ospf_timer_dump (oi->t_hello, buf, timer_slen),
2796 VTY_NEWLINE);
2797 }
paul718e3742002-12-13 20:15:29 +00002798 else /* OSPF_IF_PASSIVE is set */
2799 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2800
2801 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002802 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002803 VTY_NEWLINE);
2804 }
2805}
2806
2807DEFUN (show_ip_ospf_interface,
2808 show_ip_ospf_interface_cmd,
2809 "show ip ospf interface [INTERFACE]",
2810 SHOW_STR
2811 IP_STR
2812 "OSPF information\n"
2813 "Interface information\n"
2814 "Interface name\n")
2815{
2816 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002817 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002818 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002819
paul020709f2003-04-04 02:44:16 +00002820 ospf = ospf_lookup ();
2821
paul718e3742002-12-13 20:15:29 +00002822 /* Show All Interfaces. */
2823 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002824 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2825 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002826 /* Interface name is specified. */
2827 else
2828 {
2829 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2830 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2831 else
paul68980082003-03-25 05:07:42 +00002832 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002833 }
2834
2835 return CMD_SUCCESS;
2836}
2837
paul4dadc292005-05-06 21:37:42 +00002838static void
pauld24f6e22005-10-21 09:23:12 +00002839show_ip_ospf_neighbour_header (struct vty *vty)
2840{
2841 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
2842 VTY_NEWLINE,
2843 "Neighbor ID", "Pri", "State", "Dead Time",
2844 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
2845 VTY_NEWLINE);
2846}
2847
2848static void
paul718e3742002-12-13 20:15:29 +00002849show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2850{
2851 struct route_node *rn;
2852 struct ospf_neighbor *nbr;
2853 char msgbuf[16];
pauld24f6e22005-10-21 09:23:12 +00002854 char timebuf[14];
paul718e3742002-12-13 20:15:29 +00002855
2856 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2857 if ((nbr = rn->info))
2858 /* Do not show myself. */
2859 if (nbr != oi->nbr_self)
2860 /* Down state is not shown. */
2861 if (nbr->state != NSM_Down)
2862 {
2863 ospf_nbr_state_message (nbr, msgbuf, 16);
2864
2865 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00002866 vty_out (vty, "%-15s %3d %-15s ",
2867 "-", nbr->priority,
2868 msgbuf);
2869 else
2870 vty_out (vty, "%-15s %3d %-15s ",
2871 inet_ntoa (nbr->router_id), nbr->priority,
2872 msgbuf);
2873
2874 vty_out (vty, "%9s ",
2875 ospf_timer_dump (nbr->t_inactivity, timebuf,
2876 sizeof(timebuf)));
2877
paul718e3742002-12-13 20:15:29 +00002878 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00002879 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00002880 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2881 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2882 VTY_NEWLINE);
2883 }
2884}
2885
2886DEFUN (show_ip_ospf_neighbor,
2887 show_ip_ospf_neighbor_cmd,
2888 "show ip ospf neighbor",
2889 SHOW_STR
2890 IP_STR
2891 "OSPF information\n"
2892 "Neighbor list\n")
2893{
paul020709f2003-04-04 02:44:16 +00002894 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002895 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002896 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002897
paul020709f2003-04-04 02:44:16 +00002898 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002899 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002900 {
2901 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2902 return CMD_SUCCESS;
2903 }
2904
pauld24f6e22005-10-21 09:23:12 +00002905 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00002906
paul1eb8ef22005-04-07 07:30:20 +00002907 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
2908 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00002909
2910 return CMD_SUCCESS;
2911}
2912
2913DEFUN (show_ip_ospf_neighbor_all,
2914 show_ip_ospf_neighbor_all_cmd,
2915 "show ip ospf neighbor all",
2916 SHOW_STR
2917 IP_STR
2918 "OSPF information\n"
2919 "Neighbor list\n"
2920 "include down status neighbor\n")
2921{
paul68980082003-03-25 05:07:42 +00002922 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002923 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002924 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002925
paul68980082003-03-25 05:07:42 +00002926 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002927 {
2928 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2929 return CMD_SUCCESS;
2930 }
pauld24f6e22005-10-21 09:23:12 +00002931
2932 show_ip_ospf_neighbour_header (vty);
2933
paul1eb8ef22005-04-07 07:30:20 +00002934 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00002935 {
hasso52dc7ee2004-09-23 19:18:23 +00002936 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00002937 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00002938
2939 show_ip_ospf_neighbor_sub (vty, oi);
2940
2941 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00002942 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00002943 {
paul718e3742002-12-13 20:15:29 +00002944 if (nbr_nbma->nbr == NULL
2945 || nbr_nbma->nbr->state == NSM_Down)
2946 {
pauld24f6e22005-10-21 09:23:12 +00002947 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00002948 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00002949 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00002950 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2951 0, 0, 0, VTY_NEWLINE);
2952 }
2953 }
2954 }
2955
2956 return CMD_SUCCESS;
2957}
2958
2959DEFUN (show_ip_ospf_neighbor_int,
2960 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00002961 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00002962 SHOW_STR
2963 IP_STR
2964 "OSPF information\n"
2965 "Neighbor list\n"
2966 "Interface name\n")
2967{
paul020709f2003-04-04 02:44:16 +00002968 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00002969 struct interface *ifp;
2970 struct route_node *rn;
2971
2972 ifp = if_lookup_by_name (argv[0]);
2973 if (!ifp)
paul718e3742002-12-13 20:15:29 +00002974 {
hassobb5b7552005-08-21 20:01:15 +00002975 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002976 return CMD_WARNING;
2977 }
2978
paul020709f2003-04-04 02:44:16 +00002979 ospf = ospf_lookup ();
2980 if (ospf == NULL)
2981 {
2982 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2983 return CMD_SUCCESS;
2984 }
pauld24f6e22005-10-21 09:23:12 +00002985
2986 show_ip_ospf_neighbour_header (vty);
2987
hassobb5b7552005-08-21 20:01:15 +00002988 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00002989 {
hassobb5b7552005-08-21 20:01:15 +00002990 struct ospf_interface *oi = rn->info;
2991
2992 if (oi == NULL)
2993 continue;
2994
paul718e3742002-12-13 20:15:29 +00002995 show_ip_ospf_neighbor_sub (vty, oi);
2996 }
2997
2998 return CMD_SUCCESS;
2999}
3000
paul4dadc292005-05-06 21:37:42 +00003001static void
paul718e3742002-12-13 20:15:29 +00003002show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3003 struct ospf_nbr_nbma *nbr_nbma)
3004{
3005 char timebuf[9];
3006
3007 /* Show neighbor ID. */
3008 vty_out (vty, " Neighbor %s,", "-");
3009
3010 /* Show interface address. */
3011 vty_out (vty, " interface address %s%s",
3012 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3013 /* Show Area ID. */
3014 vty_out (vty, " In the area %s via interface %s%s",
3015 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3016 /* Show neighbor priority and state. */
3017 vty_out (vty, " Neighbor priority is %d, State is %s,",
3018 nbr_nbma->priority, "Down");
3019 /* Show state changes. */
3020 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3021
3022 /* Show PollInterval */
3023 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3024
3025 /* Show poll-interval timer. */
3026 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003027 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3028 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003029
3030 /* Show poll-interval timer thread. */
3031 vty_out (vty, " Thread Poll Timer %s%s",
3032 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3033}
3034
paul4dadc292005-05-06 21:37:42 +00003035static void
paul718e3742002-12-13 20:15:29 +00003036show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3037 struct ospf_neighbor *nbr)
3038{
3039 char timebuf[9];
3040
3041 /* Show neighbor ID. */
3042 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3043 vty_out (vty, " Neighbor %s,", "-");
3044 else
3045 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3046
3047 /* Show interface address. */
3048 vty_out (vty, " interface address %s%s",
3049 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3050 /* Show Area ID. */
3051 vty_out (vty, " In the area %s via interface %s%s",
3052 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3053 /* Show neighbor priority and state. */
3054 vty_out (vty, " Neighbor priority is %d, State is %s,",
3055 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3056 /* Show state changes. */
3057 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3058
3059 /* Show Designated Rotuer ID. */
3060 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3061 /* Show Backup Designated Rotuer ID. */
3062 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3063 /* Show options. */
3064 vty_out (vty, " Options %d %s%s", nbr->options,
3065 ospf_options_dump (nbr->options), VTY_NEWLINE);
3066 /* Show Router Dead interval timer. */
3067 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003068 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3069 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003070 /* Show Database Summary list. */
3071 vty_out (vty, " Database Summary List %d%s",
3072 ospf_db_summary_count (nbr), VTY_NEWLINE);
3073 /* Show Link State Request list. */
3074 vty_out (vty, " Link State Request List %ld%s",
3075 ospf_ls_request_count (nbr), VTY_NEWLINE);
3076 /* Show Link State Retransmission list. */
3077 vty_out (vty, " Link State Retransmission List %ld%s",
3078 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3079 /* Show inactivity timer thread. */
3080 vty_out (vty, " Thread Inactivity Timer %s%s",
3081 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3082 /* Show Database Description retransmission thread. */
3083 vty_out (vty, " Thread Database Description Retransmision %s%s",
3084 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3085 /* Show Link State Request Retransmission thread. */
3086 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3087 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3088 /* Show Link State Update Retransmission thread. */
3089 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3090 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3091}
3092
3093DEFUN (show_ip_ospf_neighbor_id,
3094 show_ip_ospf_neighbor_id_cmd,
3095 "show ip ospf neighbor A.B.C.D",
3096 SHOW_STR
3097 IP_STR
3098 "OSPF information\n"
3099 "Neighbor list\n"
3100 "Neighbor ID\n")
3101{
paul020709f2003-04-04 02:44:16 +00003102 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003103 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003104 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003105 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003106 struct in_addr router_id;
3107 int ret;
3108
3109 ret = inet_aton (argv[0], &router_id);
3110 if (!ret)
3111 {
3112 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3113 return CMD_WARNING;
3114 }
3115
paul020709f2003-04-04 02:44:16 +00003116 ospf = ospf_lookup ();
3117 if (ospf == NULL)
3118 {
3119 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3120 return CMD_SUCCESS;
3121 }
3122
paul1eb8ef22005-04-07 07:30:20 +00003123 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3124 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3125 {
3126 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3127 return CMD_SUCCESS;
3128 }
paul718e3742002-12-13 20:15:29 +00003129
3130 /* Nothing to show. */
3131 return CMD_SUCCESS;
3132}
3133
3134DEFUN (show_ip_ospf_neighbor_detail,
3135 show_ip_ospf_neighbor_detail_cmd,
3136 "show ip ospf neighbor detail",
3137 SHOW_STR
3138 IP_STR
3139 "OSPF information\n"
3140 "Neighbor list\n"
3141 "detail of all neighbors\n")
3142{
paul020709f2003-04-04 02:44:16 +00003143 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003144 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003145 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003146
paul020709f2003-04-04 02:44:16 +00003147 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003148 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003149 {
3150 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3151 return CMD_SUCCESS;
3152 }
paul718e3742002-12-13 20:15:29 +00003153
paul1eb8ef22005-04-07 07:30:20 +00003154 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003155 {
paul718e3742002-12-13 20:15:29 +00003156 struct route_node *rn;
3157 struct ospf_neighbor *nbr;
3158
3159 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3160 if ((nbr = rn->info))
3161 if (nbr != oi->nbr_self)
3162 if (nbr->state != NSM_Down)
3163 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3164 }
3165
3166 return CMD_SUCCESS;
3167}
3168
3169DEFUN (show_ip_ospf_neighbor_detail_all,
3170 show_ip_ospf_neighbor_detail_all_cmd,
3171 "show ip ospf neighbor detail all",
3172 SHOW_STR
3173 IP_STR
3174 "OSPF information\n"
3175 "Neighbor list\n"
3176 "detail of all neighbors\n"
3177 "include down status neighbor\n")
3178{
paul020709f2003-04-04 02:44:16 +00003179 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003180 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003181 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003182
paul020709f2003-04-04 02:44:16 +00003183 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003184 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003185 {
3186 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3187 return CMD_SUCCESS;
3188 }
paul718e3742002-12-13 20:15:29 +00003189
paul1eb8ef22005-04-07 07:30:20 +00003190 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003191 {
paul718e3742002-12-13 20:15:29 +00003192 struct route_node *rn;
3193 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003194 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003195
3196 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3197 if ((nbr = rn->info))
3198 if (nbr != oi->nbr_self)
3199 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3200 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3201
3202 if (oi->type == OSPF_IFTYPE_NBMA)
3203 {
hasso52dc7ee2004-09-23 19:18:23 +00003204 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003205
paul1eb8ef22005-04-07 07:30:20 +00003206 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3207 if (nbr_nbma->nbr == NULL
3208 || nbr_nbma->nbr->state == NSM_Down)
3209 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003210 }
3211 }
3212
3213 return CMD_SUCCESS;
3214}
3215
3216DEFUN (show_ip_ospf_neighbor_int_detail,
3217 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003218 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003219 SHOW_STR
3220 IP_STR
3221 "OSPF information\n"
3222 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003223 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003224 "detail of all neighbors")
3225{
paul020709f2003-04-04 02:44:16 +00003226 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003227 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003228 struct interface *ifp;
3229 struct route_node *rn, *nrn;
3230 struct ospf_neighbor *nbr;
3231
3232 ifp = if_lookup_by_name (argv[0]);
3233 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003234 {
hassobb5b7552005-08-21 20:01:15 +00003235 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003236 return CMD_WARNING;
3237 }
3238
paul020709f2003-04-04 02:44:16 +00003239 ospf = ospf_lookup ();
3240 if (ospf == NULL)
3241 {
3242 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3243 return CMD_SUCCESS;
3244 }
paul68980082003-03-25 05:07:42 +00003245
paul718e3742002-12-13 20:15:29 +00003246
hassobb5b7552005-08-21 20:01:15 +00003247 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3248 if ((oi = rn->info))
3249 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3250 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003251 if (nbr != oi->nbr_self)
3252 if (nbr->state != NSM_Down)
3253 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003254
3255 return CMD_SUCCESS;
3256}
3257
3258
3259/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003260static int
paul020709f2003-04-04 02:44:16 +00003261show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003262{
paul718e3742002-12-13 20:15:29 +00003263 struct router_lsa *rl;
3264 struct summary_lsa *sl;
3265 struct as_external_lsa *asel;
3266 struct prefix_ipv4 p;
3267
3268 if (lsa != NULL)
3269 /* If self option is set, check LSA self flag. */
3270 if (self == 0 || IS_LSA_SELF (lsa))
3271 {
3272 /* LSA common part show. */
3273 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3274 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3275 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3276 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3277 /* LSA specific part show. */
3278 switch (lsa->data->type)
3279 {
3280 case OSPF_ROUTER_LSA:
3281 rl = (struct router_lsa *) lsa->data;
3282 vty_out (vty, " %-d", ntohs (rl->links));
3283 break;
3284 case OSPF_SUMMARY_LSA:
3285 sl = (struct summary_lsa *) lsa->data;
3286
3287 p.family = AF_INET;
3288 p.prefix = sl->header.id;
3289 p.prefixlen = ip_masklen (sl->mask);
3290 apply_mask_ipv4 (&p);
3291
3292 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3293 break;
3294 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003295 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003296 asel = (struct as_external_lsa *) lsa->data;
3297
3298 p.family = AF_INET;
3299 p.prefix = asel->header.id;
3300 p.prefixlen = ip_masklen (asel->mask);
3301 apply_mask_ipv4 (&p);
3302
3303 vty_out (vty, " %s %s/%d [0x%lx]",
3304 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3305 inet_ntoa (p.prefix), p.prefixlen,
3306 (u_long)ntohl (asel->e[0].route_tag));
3307 break;
3308 case OSPF_NETWORK_LSA:
3309 case OSPF_ASBR_SUMMARY_LSA:
3310#ifdef HAVE_OPAQUE_LSA
3311 case OSPF_OPAQUE_LINK_LSA:
3312 case OSPF_OPAQUE_AREA_LSA:
3313 case OSPF_OPAQUE_AS_LSA:
3314#endif /* HAVE_OPAQUE_LSA */
3315 default:
3316 break;
3317 }
3318 vty_out (vty, VTY_NEWLINE);
3319 }
3320
3321 return 0;
3322}
3323
hassoeb1ce602004-10-08 08:17:22 +00003324const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003325{
3326 "unknown",
3327 "Router Link States",
3328 "Net Link States",
3329 "Summary Link States",
3330 "ASBR-Summary Link States",
3331 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003332 "Group Membership LSA",
3333 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003334#ifdef HAVE_OPAQUE_LSA
3335 "Type-8 LSA",
3336 "Link-Local Opaque-LSA",
3337 "Area-Local Opaque-LSA",
3338 "AS-external Opaque-LSA",
3339#endif /* HAVE_OPAQUE_LSA */
3340};
3341
3342#define SHOW_OSPF_COMMON_HEADER \
3343 "Link ID ADV Router Age Seq# CkSum"
3344
hassoeb1ce602004-10-08 08:17:22 +00003345const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003346{
3347 "",
3348 "Link ID ADV Router Age Seq# CkSum Link count",
3349 "Link ID ADV Router Age Seq# CkSum",
3350 "Link ID ADV Router Age Seq# CkSum Route",
3351 "Link ID ADV Router Age Seq# CkSum",
3352 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003353 " --- header for Group Member ----",
3354 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003355#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003356 " --- type-8 ---",
3357 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3358 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3359 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3360#endif /* HAVE_OPAQUE_LSA */
3361};
3362
hassoeb1ce602004-10-08 08:17:22 +00003363const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003364{
3365 "Self-originated",
3366 "Checked",
3367 "Received",
3368 "Approved",
3369 "Discard",
paul4957f492003-06-27 01:28:45 +00003370 "Translated",
paul4957f492003-06-27 01:28:45 +00003371};
3372
paul4dadc292005-05-06 21:37:42 +00003373static void
paul718e3742002-12-13 20:15:29 +00003374show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3375{
3376 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003377
paul718e3742002-12-13 20:15:29 +00003378 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003379 vty_out (vty, " Options: 0x%-2x : %s%s",
3380 lsa->data->options,
3381 ospf_options_dump(lsa->data->options),
3382 VTY_NEWLINE);
3383 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003384 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003385 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3386 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003387
3388 if (lsa->data->type == OSPF_ROUTER_LSA)
3389 {
3390 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3391
3392 if (rlsa->flags)
3393 vty_out (vty, " :%s%s%s%s",
3394 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3395 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3396 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3397 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3398
3399 vty_out (vty, "%s", VTY_NEWLINE);
3400 }
3401 vty_out (vty, " LS Type: %s%s",
3402 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3403 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3404 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3405 vty_out (vty, " Advertising Router: %s%s",
3406 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3407 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3408 VTY_NEWLINE);
3409 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3410 VTY_NEWLINE);
3411 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3412}
3413
hassoeb1ce602004-10-08 08:17:22 +00003414const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003415{
3416 "(null)",
3417 "another Router (point-to-point)",
3418 "a Transit Network",
3419 "Stub Network",
3420 "a Virtual Link",
3421};
3422
hassoeb1ce602004-10-08 08:17:22 +00003423const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003424{
3425 "(null)",
3426 "Neighboring Router ID",
3427 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003428 "Net",
paul718e3742002-12-13 20:15:29 +00003429 "Neighboring Router ID",
3430};
3431
hassoeb1ce602004-10-08 08:17:22 +00003432const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003433{
3434 "(null)",
3435 "Router Interface address",
3436 "Router Interface address",
3437 "Network Mask",
3438 "Router Interface address",
3439};
3440
3441/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003442static void
paul718e3742002-12-13 20:15:29 +00003443show_ip_ospf_database_router_links (struct vty *vty,
3444 struct router_lsa *rl)
3445{
3446 int len, i, type;
3447
3448 len = ntohs (rl->header.length) - 4;
3449 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3450 {
3451 type = rl->link[i].type;
3452
3453 vty_out (vty, " Link connected to: %s%s",
3454 link_type_desc[type], VTY_NEWLINE);
3455 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3456 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3457 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3458 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3459 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3460 vty_out (vty, " TOS 0 Metric: %d%s",
3461 ntohs (rl->link[i].metric), VTY_NEWLINE);
3462 vty_out (vty, "%s", VTY_NEWLINE);
3463 }
3464}
3465
3466/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003467static int
paul718e3742002-12-13 20:15:29 +00003468show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3469{
3470 if (lsa != NULL)
3471 {
3472 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3473
3474 show_ip_ospf_database_header (vty, lsa);
3475
3476 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3477 VTY_NEWLINE, VTY_NEWLINE);
3478
3479 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003480 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003481 }
3482
3483 return 0;
3484}
3485
3486/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003487static int
paul718e3742002-12-13 20:15:29 +00003488show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3489{
3490 int length, i;
3491
3492 if (lsa != NULL)
3493 {
3494 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3495
3496 show_ip_ospf_database_header (vty, lsa);
3497
3498 vty_out (vty, " Network Mask: /%d%s",
3499 ip_masklen (nl->mask), VTY_NEWLINE);
3500
3501 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3502
3503 for (i = 0; length > 0; i++, length -= 4)
3504 vty_out (vty, " Attached Router: %s%s",
3505 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3506
3507 vty_out (vty, "%s", VTY_NEWLINE);
3508 }
3509
3510 return 0;
3511}
3512
3513/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003514static int
paul718e3742002-12-13 20:15:29 +00003515show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3516{
3517 if (lsa != NULL)
3518 {
3519 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3520
3521 show_ip_ospf_database_header (vty, lsa);
3522
3523 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3524 VTY_NEWLINE);
3525 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3526 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003527 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003528 }
3529
3530 return 0;
3531}
3532
3533/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003534static int
paul718e3742002-12-13 20:15:29 +00003535show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3536{
3537 if (lsa != NULL)
3538 {
3539 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3540
3541 show_ip_ospf_database_header (vty, lsa);
3542
3543 vty_out (vty, " Network Mask: /%d%s",
3544 ip_masklen (sl->mask), VTY_NEWLINE);
3545 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3546 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003547 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003548 }
3549
3550 return 0;
3551}
3552
3553/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003554static int
paul718e3742002-12-13 20:15:29 +00003555show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3556{
3557 if (lsa != NULL)
3558 {
3559 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3560
3561 show_ip_ospf_database_header (vty, lsa);
3562
3563 vty_out (vty, " Network Mask: /%d%s",
3564 ip_masklen (al->mask), VTY_NEWLINE);
3565 vty_out (vty, " Metric Type: %s%s",
3566 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3567 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3568 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3569 vty_out (vty, " Metric: %d%s",
3570 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3571 vty_out (vty, " Forward Address: %s%s",
3572 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3573
3574 vty_out (vty, " External Route Tag: %lu%s%s",
3575 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3576 }
3577
3578 return 0;
3579}
3580
ajs2a42e282004-12-08 18:43:03 +00003581/* N.B. This function currently seems to be unused. */
paul4dadc292005-05-06 21:37:42 +00003582static int
paul718e3742002-12-13 20:15:29 +00003583show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3584{
3585 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3586
3587 /* show_ip_ospf_database_header (vty, lsa); */
3588
ajs2a42e282004-12-08 18:43:03 +00003589 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003590 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003591 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003592 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3593 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003594 zlog_debug( " TOS: 0%s", "\n");
3595 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003596 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003597 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003598 inet_ntoa (al->e[0].fwd_addr), "\n");
3599
ajs2a42e282004-12-08 18:43:03 +00003600 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003601 ntohl (al->e[0].route_tag), "\n", "\n");
3602
3603 return 0;
3604}
3605
3606/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003607static int
paul718e3742002-12-13 20:15:29 +00003608show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3609{
3610 if (lsa != NULL)
3611 {
3612 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3613
3614 show_ip_ospf_database_header (vty, lsa);
3615
3616 vty_out (vty, " Network Mask: /%d%s",
3617 ip_masklen (al->mask), VTY_NEWLINE);
3618 vty_out (vty, " Metric Type: %s%s",
3619 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3620 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3621 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3622 vty_out (vty, " Metric: %d%s",
3623 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3624 vty_out (vty, " NSSA: Forward Address: %s%s",
3625 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3626
3627 vty_out (vty, " External Route Tag: %u%s%s",
3628 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3629 }
3630
3631 return 0;
3632}
3633
paul4dadc292005-05-06 21:37:42 +00003634static int
paul718e3742002-12-13 20:15:29 +00003635show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3636{
3637 return 0;
3638}
3639
3640#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003641static int
paul718e3742002-12-13 20:15:29 +00003642show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3643{
3644 if (lsa != NULL)
3645 {
3646 show_ip_ospf_database_header (vty, lsa);
3647 show_opaque_info_detail (vty, lsa);
3648
3649 vty_out (vty, "%s", VTY_NEWLINE);
3650 }
3651 return 0;
3652}
3653#endif /* HAVE_OPAQUE_LSA */
3654
3655int (*show_function[])(struct vty *, struct ospf_lsa *) =
3656{
3657 NULL,
3658 show_router_lsa_detail,
3659 show_network_lsa_detail,
3660 show_summary_lsa_detail,
3661 show_summary_asbr_lsa_detail,
3662 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003663 show_func_dummy,
3664 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003665#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003666 NULL, /* type-8 */
3667 show_opaque_lsa_detail,
3668 show_opaque_lsa_detail,
3669 show_opaque_lsa_detail,
3670#endif /* HAVE_OPAQUE_LSA */
3671};
3672
paul4dadc292005-05-06 21:37:42 +00003673static void
paul718e3742002-12-13 20:15:29 +00003674show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3675 struct in_addr *adv_router)
3676{
3677 memset (lp, 0, sizeof (struct prefix_ls));
3678 lp->family = 0;
3679 if (id == NULL)
3680 lp->prefixlen = 0;
3681 else if (adv_router == NULL)
3682 {
3683 lp->prefixlen = 32;
3684 lp->id = *id;
3685 }
3686 else
3687 {
3688 lp->prefixlen = 64;
3689 lp->id = *id;
3690 lp->adv_router = *adv_router;
3691 }
3692}
3693
paul4dadc292005-05-06 21:37:42 +00003694static void
paul718e3742002-12-13 20:15:29 +00003695show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3696 struct in_addr *id, struct in_addr *adv_router)
3697{
3698 struct prefix_ls lp;
3699 struct route_node *rn, *start;
3700 struct ospf_lsa *lsa;
3701
3702 show_lsa_prefix_set (vty, &lp, id, adv_router);
3703 start = route_node_get (rt, (struct prefix *) &lp);
3704 if (start)
3705 {
3706 route_lock_node (start);
3707 for (rn = start; rn; rn = route_next_until (rn, start))
3708 if ((lsa = rn->info))
3709 {
paul718e3742002-12-13 20:15:29 +00003710 if (show_function[lsa->data->type] != NULL)
3711 show_function[lsa->data->type] (vty, lsa);
3712 }
3713 route_unlock_node (start);
3714 }
3715}
3716
3717/* Show detail LSA information
3718 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00003719static void
paul020709f2003-04-04 02:44:16 +00003720show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003721 struct in_addr *id, struct in_addr *adv_router)
3722{
hasso52dc7ee2004-09-23 19:18:23 +00003723 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003724 struct ospf_area *area;
3725
paul718e3742002-12-13 20:15:29 +00003726 switch (type)
3727 {
3728 case OSPF_AS_EXTERNAL_LSA:
3729#ifdef HAVE_OPAQUE_LSA
3730 case OSPF_OPAQUE_AS_LSA:
3731#endif /* HAVE_OPAQUE_LSA */
3732 vty_out (vty, " %s %s%s",
3733 show_database_desc[type],
3734 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003735 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003736 break;
3737 default:
paul1eb8ef22005-04-07 07:30:20 +00003738 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003739 {
paul718e3742002-12-13 20:15:29 +00003740 vty_out (vty, "%s %s (Area %s)%s%s",
3741 VTY_NEWLINE, show_database_desc[type],
3742 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3743 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3744 }
3745 break;
3746 }
3747}
3748
paul4dadc292005-05-06 21:37:42 +00003749static void
paul718e3742002-12-13 20:15:29 +00003750show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3751 struct in_addr *adv_router)
3752{
3753 struct route_node *rn;
3754 struct ospf_lsa *lsa;
3755
3756 for (rn = route_top (rt); rn; rn = route_next (rn))
3757 if ((lsa = rn->info))
3758 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3759 {
paul718e3742002-12-13 20:15:29 +00003760 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3761 continue;
paul718e3742002-12-13 20:15:29 +00003762 if (show_function[lsa->data->type] != NULL)
3763 show_function[lsa->data->type] (vty, lsa);
3764 }
3765}
3766
3767/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00003768static void
paul020709f2003-04-04 02:44:16 +00003769show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003770 struct in_addr *adv_router)
3771{
hasso52dc7ee2004-09-23 19:18:23 +00003772 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003773 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003774
3775 switch (type)
3776 {
3777 case OSPF_AS_EXTERNAL_LSA:
3778#ifdef HAVE_OPAQUE_LSA
3779 case OSPF_OPAQUE_AS_LSA:
3780#endif /* HAVE_OPAQUE_LSA */
3781 vty_out (vty, " %s %s%s",
3782 show_database_desc[type],
3783 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003784 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003785 adv_router);
3786 break;
3787 default:
paul1eb8ef22005-04-07 07:30:20 +00003788 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003789 {
paul718e3742002-12-13 20:15:29 +00003790 vty_out (vty, "%s %s (Area %s)%s%s",
3791 VTY_NEWLINE, show_database_desc[type],
3792 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3793 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3794 adv_router);
3795 }
3796 break;
3797 }
3798}
3799
paul4dadc292005-05-06 21:37:42 +00003800static void
paul020709f2003-04-04 02:44:16 +00003801show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003802{
paul020709f2003-04-04 02:44:16 +00003803 struct ospf_lsa *lsa;
3804 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003805 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003806 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003807 int type;
3808
paul1eb8ef22005-04-07 07:30:20 +00003809 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003810 {
paul718e3742002-12-13 20:15:29 +00003811 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3812 {
3813 switch (type)
3814 {
3815 case OSPF_AS_EXTERNAL_LSA:
3816#ifdef HAVE_OPAQUE_LSA
3817 case OSPF_OPAQUE_AS_LSA:
3818#endif /* HAVE_OPAQUE_LSA */
3819 continue;
3820 default:
3821 break;
3822 }
3823 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3824 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3825 {
3826 vty_out (vty, " %s (Area %s)%s%s",
3827 show_database_desc[type],
3828 ospf_area_desc_string (area),
3829 VTY_NEWLINE, VTY_NEWLINE);
3830 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3831
paul020709f2003-04-04 02:44:16 +00003832 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3833 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003834
3835 vty_out (vty, "%s", VTY_NEWLINE);
3836 }
3837 }
3838 }
3839
3840 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3841 {
3842 switch (type)
3843 {
3844 case OSPF_AS_EXTERNAL_LSA:
3845#ifdef HAVE_OPAQUE_LSA
3846 case OSPF_OPAQUE_AS_LSA:
3847#endif /* HAVE_OPAQUE_LSA */
3848 break;;
3849 default:
3850 continue;
3851 }
paul68980082003-03-25 05:07:42 +00003852 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3853 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003854 {
3855 vty_out (vty, " %s%s%s",
3856 show_database_desc[type],
3857 VTY_NEWLINE, VTY_NEWLINE);
3858 vty_out (vty, "%s%s", show_database_header[type],
3859 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003860
3861 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3862 show_lsa_summary (vty, lsa, self);
3863
paul718e3742002-12-13 20:15:29 +00003864 vty_out (vty, "%s", VTY_NEWLINE);
3865 }
3866 }
3867
3868 vty_out (vty, "%s", VTY_NEWLINE);
3869}
3870
paul4dadc292005-05-06 21:37:42 +00003871static void
paul020709f2003-04-04 02:44:16 +00003872show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003873{
hasso52dc7ee2004-09-23 19:18:23 +00003874 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003875 struct ospf_lsa *lsa;
3876
3877 vty_out (vty, "%s MaxAge Link States:%s%s",
3878 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3879
paul1eb8ef22005-04-07 07:30:20 +00003880 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3881 {
3882 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3883 vty_out (vty, "Link State ID: %s%s",
3884 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3885 vty_out (vty, "Advertising Router: %s%s",
3886 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3887 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3888 vty_out (vty, "%s", VTY_NEWLINE);
3889 }
paul718e3742002-12-13 20:15:29 +00003890}
3891
paul718e3742002-12-13 20:15:29 +00003892#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3893#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003894
3895#ifdef HAVE_OPAQUE_LSA
3896#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3897#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3898#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3899#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3900#else /* HAVE_OPAQUE_LSA */
3901#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3902#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3903#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3904#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3905#endif /* HAVE_OPAQUE_LSA */
3906
3907#define OSPF_LSA_TYPES_CMD_STR \
3908 "asbr-summary|external|network|router|summary" \
3909 OSPF_LSA_TYPE_NSSA_CMD_STR \
3910 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3911
3912#define OSPF_LSA_TYPES_DESC \
3913 "ASBR summary link states\n" \
3914 "External link states\n" \
3915 "Network link states\n" \
3916 "Router link states\n" \
3917 "Network summary link states\n" \
3918 OSPF_LSA_TYPE_NSSA_DESC \
3919 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3920 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3921 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3922
3923DEFUN (show_ip_ospf_database,
3924 show_ip_ospf_database_cmd,
3925 "show ip ospf database",
3926 SHOW_STR
3927 IP_STR
3928 "OSPF information\n"
3929 "Database summary\n")
3930{
paul020709f2003-04-04 02:44:16 +00003931 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003932 int type, ret;
3933 struct in_addr id, adv_router;
3934
paul020709f2003-04-04 02:44:16 +00003935 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003936 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003937 return CMD_SUCCESS;
3938
3939 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003940 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003941
3942 /* Show all LSA. */
3943 if (argc == 0)
3944 {
paul020709f2003-04-04 02:44:16 +00003945 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003946 return CMD_SUCCESS;
3947 }
3948
3949 /* Set database type to show. */
3950 if (strncmp (argv[0], "r", 1) == 0)
3951 type = OSPF_ROUTER_LSA;
3952 else if (strncmp (argv[0], "ne", 2) == 0)
3953 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003954 else if (strncmp (argv[0], "ns", 2) == 0)
3955 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003956 else if (strncmp (argv[0], "su", 2) == 0)
3957 type = OSPF_SUMMARY_LSA;
3958 else if (strncmp (argv[0], "a", 1) == 0)
3959 type = OSPF_ASBR_SUMMARY_LSA;
3960 else if (strncmp (argv[0], "e", 1) == 0)
3961 type = OSPF_AS_EXTERNAL_LSA;
3962 else if (strncmp (argv[0], "se", 2) == 0)
3963 {
paul020709f2003-04-04 02:44:16 +00003964 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003965 return CMD_SUCCESS;
3966 }
3967 else if (strncmp (argv[0], "m", 1) == 0)
3968 {
paul020709f2003-04-04 02:44:16 +00003969 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003970 return CMD_SUCCESS;
3971 }
3972#ifdef HAVE_OPAQUE_LSA
3973 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3974 type = OSPF_OPAQUE_LINK_LSA;
3975 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3976 type = OSPF_OPAQUE_AREA_LSA;
3977 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3978 type = OSPF_OPAQUE_AS_LSA;
3979#endif /* HAVE_OPAQUE_LSA */
3980 else
3981 return CMD_WARNING;
3982
3983 /* `show ip ospf database LSA'. */
3984 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003985 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003986 else if (argc >= 2)
3987 {
3988 ret = inet_aton (argv[1], &id);
3989 if (!ret)
3990 return CMD_WARNING;
3991
3992 /* `show ip ospf database LSA ID'. */
3993 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003994 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003995 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3996 else if (argc == 3)
3997 {
3998 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003999 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004000 else
4001 {
4002 ret = inet_aton (argv[2], &adv_router);
4003 if (!ret)
4004 return CMD_WARNING;
4005 }
paul020709f2003-04-04 02:44:16 +00004006 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004007 }
4008 }
4009
4010 return CMD_SUCCESS;
4011}
4012
4013ALIAS (show_ip_ospf_database,
4014 show_ip_ospf_database_type_cmd,
4015 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4016 SHOW_STR
4017 IP_STR
4018 "OSPF information\n"
4019 "Database summary\n"
4020 OSPF_LSA_TYPES_DESC
4021 "LSAs in MaxAge list\n"
4022 "Self-originated link states\n")
4023
4024ALIAS (show_ip_ospf_database,
4025 show_ip_ospf_database_type_id_cmd,
4026 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4027 SHOW_STR
4028 IP_STR
4029 "OSPF information\n"
4030 "Database summary\n"
4031 OSPF_LSA_TYPES_DESC
4032 "Link State ID (as an IP address)\n")
4033
4034ALIAS (show_ip_ospf_database,
4035 show_ip_ospf_database_type_id_adv_router_cmd,
4036 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4037 SHOW_STR
4038 IP_STR
4039 "OSPF information\n"
4040 "Database summary\n"
4041 OSPF_LSA_TYPES_DESC
4042 "Link State ID (as an IP address)\n"
4043 "Advertising Router link states\n"
4044 "Advertising Router (as an IP address)\n")
4045
4046ALIAS (show_ip_ospf_database,
4047 show_ip_ospf_database_type_id_self_cmd,
4048 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4049 SHOW_STR
4050 IP_STR
4051 "OSPF information\n"
4052 "Database summary\n"
4053 OSPF_LSA_TYPES_DESC
4054 "Link State ID (as an IP address)\n"
4055 "Self-originated link states\n"
4056 "\n")
4057
4058DEFUN (show_ip_ospf_database_type_adv_router,
4059 show_ip_ospf_database_type_adv_router_cmd,
4060 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4061 SHOW_STR
4062 IP_STR
4063 "OSPF information\n"
4064 "Database summary\n"
4065 OSPF_LSA_TYPES_DESC
4066 "Advertising Router link states\n"
4067 "Advertising Router (as an IP address)\n")
4068{
paul020709f2003-04-04 02:44:16 +00004069 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004070 int type, ret;
4071 struct in_addr adv_router;
4072
paul020709f2003-04-04 02:44:16 +00004073 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004074 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00004075 return CMD_SUCCESS;
4076
4077 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004078 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004079
4080 if (argc != 2)
4081 return CMD_WARNING;
4082
4083 /* Set database type to show. */
4084 if (strncmp (argv[0], "r", 1) == 0)
4085 type = OSPF_ROUTER_LSA;
4086 else if (strncmp (argv[0], "ne", 2) == 0)
4087 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004088 else if (strncmp (argv[0], "ns", 2) == 0)
4089 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004090 else if (strncmp (argv[0], "s", 1) == 0)
4091 type = OSPF_SUMMARY_LSA;
4092 else if (strncmp (argv[0], "a", 1) == 0)
4093 type = OSPF_ASBR_SUMMARY_LSA;
4094 else if (strncmp (argv[0], "e", 1) == 0)
4095 type = OSPF_AS_EXTERNAL_LSA;
4096#ifdef HAVE_OPAQUE_LSA
4097 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4098 type = OSPF_OPAQUE_LINK_LSA;
4099 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4100 type = OSPF_OPAQUE_AREA_LSA;
4101 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4102 type = OSPF_OPAQUE_AS_LSA;
4103#endif /* HAVE_OPAQUE_LSA */
4104 else
4105 return CMD_WARNING;
4106
4107 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4108 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004109 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004110 else
4111 {
4112 ret = inet_aton (argv[1], &adv_router);
4113 if (!ret)
4114 return CMD_WARNING;
4115 }
4116
paul020709f2003-04-04 02:44:16 +00004117 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004118
4119 return CMD_SUCCESS;
4120}
4121
4122ALIAS (show_ip_ospf_database_type_adv_router,
4123 show_ip_ospf_database_type_self_cmd,
4124 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4125 SHOW_STR
4126 IP_STR
4127 "OSPF information\n"
4128 "Database summary\n"
4129 OSPF_LSA_TYPES_DESC
4130 "Self-originated link states\n")
4131
4132
4133DEFUN (ip_ospf_authentication_args,
4134 ip_ospf_authentication_args_addr_cmd,
4135 "ip ospf authentication (null|message-digest) A.B.C.D",
4136 "IP Information\n"
4137 "OSPF interface commands\n"
4138 "Enable authentication on this interface\n"
4139 "Use null authentication\n"
4140 "Use message-digest authentication\n"
4141 "Address of interface")
4142{
4143 struct interface *ifp;
4144 struct in_addr addr;
4145 int ret;
4146 struct ospf_if_params *params;
4147
4148 ifp = vty->index;
4149 params = IF_DEF_PARAMS (ifp);
4150
4151 if (argc == 2)
4152 {
4153 ret = inet_aton(argv[1], &addr);
4154 if (!ret)
4155 {
4156 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4157 VTY_NEWLINE);
4158 return CMD_WARNING;
4159 }
4160
4161 params = ospf_get_if_params (ifp, addr);
4162 ospf_if_update_params (ifp, addr);
4163 }
4164
4165 /* Handle null authentication */
4166 if ( argv[0][0] == 'n' )
4167 {
4168 SET_IF_PARAM (params, auth_type);
4169 params->auth_type = OSPF_AUTH_NULL;
4170 return CMD_SUCCESS;
4171 }
4172
4173 /* Handle message-digest authentication */
4174 if ( argv[0][0] == 'm' )
4175 {
4176 SET_IF_PARAM (params, auth_type);
4177 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4178 return CMD_SUCCESS;
4179 }
4180
4181 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4182 return CMD_WARNING;
4183}
4184
4185ALIAS (ip_ospf_authentication_args,
4186 ip_ospf_authentication_args_cmd,
4187 "ip ospf authentication (null|message-digest)",
4188 "IP Information\n"
4189 "OSPF interface commands\n"
4190 "Enable authentication on this interface\n"
4191 "Use null authentication\n"
4192 "Use message-digest authentication\n")
4193
4194DEFUN (ip_ospf_authentication,
4195 ip_ospf_authentication_addr_cmd,
4196 "ip ospf authentication A.B.C.D",
4197 "IP Information\n"
4198 "OSPF interface commands\n"
4199 "Enable authentication on this interface\n"
4200 "Address of interface")
4201{
4202 struct interface *ifp;
4203 struct in_addr addr;
4204 int ret;
4205 struct ospf_if_params *params;
4206
4207 ifp = vty->index;
4208 params = IF_DEF_PARAMS (ifp);
4209
4210 if (argc == 1)
4211 {
4212 ret = inet_aton(argv[1], &addr);
4213 if (!ret)
4214 {
4215 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4216 VTY_NEWLINE);
4217 return CMD_WARNING;
4218 }
4219
4220 params = ospf_get_if_params (ifp, addr);
4221 ospf_if_update_params (ifp, addr);
4222 }
4223
4224 SET_IF_PARAM (params, auth_type);
4225 params->auth_type = OSPF_AUTH_SIMPLE;
4226
4227 return CMD_SUCCESS;
4228}
4229
4230ALIAS (ip_ospf_authentication,
4231 ip_ospf_authentication_cmd,
4232 "ip ospf authentication",
4233 "IP Information\n"
4234 "OSPF interface commands\n"
4235 "Enable authentication on this interface\n")
4236
4237DEFUN (no_ip_ospf_authentication,
4238 no_ip_ospf_authentication_addr_cmd,
4239 "no ip ospf authentication A.B.C.D",
4240 NO_STR
4241 "IP Information\n"
4242 "OSPF interface commands\n"
4243 "Enable authentication on this interface\n"
4244 "Address of interface")
4245{
4246 struct interface *ifp;
4247 struct in_addr addr;
4248 int ret;
4249 struct ospf_if_params *params;
4250
4251 ifp = vty->index;
4252 params = IF_DEF_PARAMS (ifp);
4253
4254 if (argc == 1)
4255 {
4256 ret = inet_aton(argv[1], &addr);
4257 if (!ret)
4258 {
4259 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4260 VTY_NEWLINE);
4261 return CMD_WARNING;
4262 }
4263
4264 params = ospf_lookup_if_params (ifp, addr);
4265 if (params == NULL)
4266 return CMD_SUCCESS;
4267 }
4268
4269 params->auth_type = OSPF_AUTH_NOTSET;
4270 UNSET_IF_PARAM (params, auth_type);
4271
4272 if (params != IF_DEF_PARAMS (ifp))
4273 {
4274 ospf_free_if_params (ifp, addr);
4275 ospf_if_update_params (ifp, addr);
4276 }
4277
4278 return CMD_SUCCESS;
4279}
4280
4281ALIAS (no_ip_ospf_authentication,
4282 no_ip_ospf_authentication_cmd,
4283 "no ip ospf authentication",
4284 NO_STR
4285 "IP Information\n"
4286 "OSPF interface commands\n"
4287 "Enable authentication on this interface\n")
4288
4289DEFUN (ip_ospf_authentication_key,
4290 ip_ospf_authentication_key_addr_cmd,
4291 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4292 "IP Information\n"
4293 "OSPF interface commands\n"
4294 "Authentication password (key)\n"
4295 "The OSPF password (key)\n"
4296 "Address of interface")
4297{
4298 struct interface *ifp;
4299 struct in_addr addr;
4300 int ret;
4301 struct ospf_if_params *params;
4302
4303 ifp = vty->index;
4304 params = IF_DEF_PARAMS (ifp);
4305
4306 if (argc == 2)
4307 {
4308 ret = inet_aton(argv[1], &addr);
4309 if (!ret)
4310 {
4311 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4312 VTY_NEWLINE);
4313 return CMD_WARNING;
4314 }
4315
4316 params = ospf_get_if_params (ifp, addr);
4317 ospf_if_update_params (ifp, addr);
4318 }
4319
4320
4321 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004322 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004323 SET_IF_PARAM (params, auth_simple);
4324
4325 return CMD_SUCCESS;
4326}
4327
4328ALIAS (ip_ospf_authentication_key,
4329 ip_ospf_authentication_key_cmd,
4330 "ip ospf authentication-key AUTH_KEY",
4331 "IP Information\n"
4332 "OSPF interface commands\n"
4333 "Authentication password (key)\n"
4334 "The OSPF password (key)")
4335
4336ALIAS (ip_ospf_authentication_key,
4337 ospf_authentication_key_cmd,
4338 "ospf authentication-key AUTH_KEY",
4339 "OSPF interface commands\n"
4340 "Authentication password (key)\n"
4341 "The OSPF password (key)")
4342
4343DEFUN (no_ip_ospf_authentication_key,
4344 no_ip_ospf_authentication_key_addr_cmd,
4345 "no ip ospf authentication-key A.B.C.D",
4346 NO_STR
4347 "IP Information\n"
4348 "OSPF interface commands\n"
4349 "Authentication password (key)\n"
4350 "Address of interface")
4351{
4352 struct interface *ifp;
4353 struct in_addr addr;
4354 int ret;
4355 struct ospf_if_params *params;
4356
4357 ifp = vty->index;
4358 params = IF_DEF_PARAMS (ifp);
4359
4360 if (argc == 2)
4361 {
4362 ret = inet_aton(argv[1], &addr);
4363 if (!ret)
4364 {
4365 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4366 VTY_NEWLINE);
4367 return CMD_WARNING;
4368 }
4369
4370 params = ospf_lookup_if_params (ifp, addr);
4371 if (params == NULL)
4372 return CMD_SUCCESS;
4373 }
4374
4375 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4376 UNSET_IF_PARAM (params, auth_simple);
4377
4378 if (params != IF_DEF_PARAMS (ifp))
4379 {
4380 ospf_free_if_params (ifp, addr);
4381 ospf_if_update_params (ifp, addr);
4382 }
4383
4384 return CMD_SUCCESS;
4385}
4386
4387ALIAS (no_ip_ospf_authentication_key,
4388 no_ip_ospf_authentication_key_cmd,
4389 "no ip ospf authentication-key",
4390 NO_STR
4391 "IP Information\n"
4392 "OSPF interface commands\n"
4393 "Authentication password (key)\n")
4394
4395ALIAS (no_ip_ospf_authentication_key,
4396 no_ospf_authentication_key_cmd,
4397 "no ospf authentication-key",
4398 NO_STR
4399 "OSPF interface commands\n"
4400 "Authentication password (key)\n")
4401
4402DEFUN (ip_ospf_message_digest_key,
4403 ip_ospf_message_digest_key_addr_cmd,
4404 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4405 "IP Information\n"
4406 "OSPF interface commands\n"
4407 "Message digest authentication password (key)\n"
4408 "Key ID\n"
4409 "Use MD5 algorithm\n"
4410 "The OSPF password (key)"
4411 "Address of interface")
4412{
4413 struct interface *ifp;
4414 struct crypt_key *ck;
4415 u_char key_id;
4416 struct in_addr addr;
4417 int ret;
4418 struct ospf_if_params *params;
4419
4420 ifp = vty->index;
4421 params = IF_DEF_PARAMS (ifp);
4422
4423 if (argc == 3)
4424 {
4425 ret = inet_aton(argv[2], &addr);
4426 if (!ret)
4427 {
4428 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4429 VTY_NEWLINE);
4430 return CMD_WARNING;
4431 }
4432
4433 params = ospf_get_if_params (ifp, addr);
4434 ospf_if_update_params (ifp, addr);
4435 }
4436
4437 key_id = strtol (argv[0], NULL, 10);
4438 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4439 {
4440 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4441 return CMD_WARNING;
4442 }
4443
4444 ck = ospf_crypt_key_new ();
4445 ck->key_id = (u_char) key_id;
4446 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004447 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004448
4449 ospf_crypt_key_add (params->auth_crypt, ck);
4450 SET_IF_PARAM (params, auth_crypt);
4451
4452 return CMD_SUCCESS;
4453}
4454
4455ALIAS (ip_ospf_message_digest_key,
4456 ip_ospf_message_digest_key_cmd,
4457 "ip ospf message-digest-key <1-255> md5 KEY",
4458 "IP Information\n"
4459 "OSPF interface commands\n"
4460 "Message digest authentication password (key)\n"
4461 "Key ID\n"
4462 "Use MD5 algorithm\n"
4463 "The OSPF password (key)")
4464
4465ALIAS (ip_ospf_message_digest_key,
4466 ospf_message_digest_key_cmd,
4467 "ospf message-digest-key <1-255> md5 KEY",
4468 "OSPF interface commands\n"
4469 "Message digest authentication password (key)\n"
4470 "Key ID\n"
4471 "Use MD5 algorithm\n"
4472 "The OSPF password (key)")
4473
4474DEFUN (no_ip_ospf_message_digest_key,
4475 no_ip_ospf_message_digest_key_addr_cmd,
4476 "no ip ospf message-digest-key <1-255> A.B.C.D",
4477 NO_STR
4478 "IP Information\n"
4479 "OSPF interface commands\n"
4480 "Message digest authentication password (key)\n"
4481 "Key ID\n"
4482 "Address of interface")
4483{
4484 struct interface *ifp;
4485 struct crypt_key *ck;
4486 int key_id;
4487 struct in_addr addr;
4488 int ret;
4489 struct ospf_if_params *params;
4490
4491 ifp = vty->index;
4492 params = IF_DEF_PARAMS (ifp);
4493
4494 if (argc == 2)
4495 {
4496 ret = inet_aton(argv[1], &addr);
4497 if (!ret)
4498 {
4499 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4500 VTY_NEWLINE);
4501 return CMD_WARNING;
4502 }
4503
4504 params = ospf_lookup_if_params (ifp, addr);
4505 if (params == NULL)
4506 return CMD_SUCCESS;
4507 }
4508
4509 key_id = strtol (argv[0], NULL, 10);
4510 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4511 if (ck == NULL)
4512 {
4513 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4514 return CMD_WARNING;
4515 }
4516
4517 ospf_crypt_key_delete (params->auth_crypt, key_id);
4518
4519 if (params != IF_DEF_PARAMS (ifp))
4520 {
4521 ospf_free_if_params (ifp, addr);
4522 ospf_if_update_params (ifp, addr);
4523 }
4524
4525 return CMD_SUCCESS;
4526}
4527
4528ALIAS (no_ip_ospf_message_digest_key,
4529 no_ip_ospf_message_digest_key_cmd,
4530 "no ip ospf message-digest-key <1-255>",
4531 NO_STR
4532 "IP Information\n"
4533 "OSPF interface commands\n"
4534 "Message digest authentication password (key)\n"
4535 "Key ID\n")
4536
4537ALIAS (no_ip_ospf_message_digest_key,
4538 no_ospf_message_digest_key_cmd,
4539 "no ospf message-digest-key <1-255>",
4540 NO_STR
4541 "OSPF interface commands\n"
4542 "Message digest authentication password (key)\n"
4543 "Key ID\n")
4544
4545DEFUN (ip_ospf_cost,
4546 ip_ospf_cost_addr_cmd,
4547 "ip ospf cost <1-65535> A.B.C.D",
4548 "IP Information\n"
4549 "OSPF interface commands\n"
4550 "Interface cost\n"
4551 "Cost\n"
4552 "Address of interface")
4553{
4554 struct interface *ifp = vty->index;
4555 u_int32_t cost;
4556 struct in_addr addr;
4557 int ret;
4558 struct ospf_if_params *params;
4559
4560 params = IF_DEF_PARAMS (ifp);
4561
4562 cost = strtol (argv[0], NULL, 10);
4563
4564 /* cost range is <1-65535>. */
4565 if (cost < 1 || cost > 65535)
4566 {
4567 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4568 return CMD_WARNING;
4569 }
4570
4571 if (argc == 2)
4572 {
4573 ret = inet_aton(argv[1], &addr);
4574 if (!ret)
4575 {
4576 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4577 VTY_NEWLINE);
4578 return CMD_WARNING;
4579 }
4580
4581 params = ospf_get_if_params (ifp, addr);
4582 ospf_if_update_params (ifp, addr);
4583 }
4584
4585 SET_IF_PARAM (params, output_cost_cmd);
4586 params->output_cost_cmd = cost;
4587
4588 ospf_if_recalculate_output_cost (ifp);
4589
4590 return CMD_SUCCESS;
4591}
4592
4593ALIAS (ip_ospf_cost,
4594 ip_ospf_cost_cmd,
4595 "ip ospf cost <1-65535>",
4596 "IP Information\n"
4597 "OSPF interface commands\n"
4598 "Interface cost\n"
4599 "Cost")
4600
4601ALIAS (ip_ospf_cost,
4602 ospf_cost_cmd,
4603 "ospf cost <1-65535>",
4604 "OSPF interface commands\n"
4605 "Interface cost\n"
4606 "Cost")
4607
4608DEFUN (no_ip_ospf_cost,
4609 no_ip_ospf_cost_addr_cmd,
4610 "no ip ospf cost A.B.C.D",
4611 NO_STR
4612 "IP Information\n"
4613 "OSPF interface commands\n"
4614 "Interface cost\n"
4615 "Address of interface")
4616{
4617 struct interface *ifp = vty->index;
4618 struct in_addr addr;
4619 int ret;
4620 struct ospf_if_params *params;
4621
4622 ifp = vty->index;
4623 params = IF_DEF_PARAMS (ifp);
4624
4625 if (argc == 1)
4626 {
4627 ret = inet_aton(argv[0], &addr);
4628 if (!ret)
4629 {
4630 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4631 VTY_NEWLINE);
4632 return CMD_WARNING;
4633 }
4634
4635 params = ospf_lookup_if_params (ifp, addr);
4636 if (params == NULL)
4637 return CMD_SUCCESS;
4638 }
4639
4640 UNSET_IF_PARAM (params, output_cost_cmd);
4641
4642 if (params != IF_DEF_PARAMS (ifp))
4643 {
4644 ospf_free_if_params (ifp, addr);
4645 ospf_if_update_params (ifp, addr);
4646 }
4647
4648 ospf_if_recalculate_output_cost (ifp);
4649
4650 return CMD_SUCCESS;
4651}
4652
4653ALIAS (no_ip_ospf_cost,
4654 no_ip_ospf_cost_cmd,
4655 "no ip ospf cost",
4656 NO_STR
4657 "IP Information\n"
4658 "OSPF interface commands\n"
4659 "Interface cost\n")
4660
4661ALIAS (no_ip_ospf_cost,
4662 no_ospf_cost_cmd,
4663 "no ospf cost",
4664 NO_STR
4665 "OSPF interface commands\n"
4666 "Interface cost\n")
4667
paul4dadc292005-05-06 21:37:42 +00004668static void
paul718e3742002-12-13 20:15:29 +00004669ospf_nbr_timer_update (struct ospf_interface *oi)
4670{
4671 struct route_node *rn;
4672 struct ospf_neighbor *nbr;
4673
4674 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4675 if ((nbr = rn->info))
4676 {
4677 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4678 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4679 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4680 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4681 }
4682}
4683
paulf9ad9372005-10-21 00:45:17 +00004684static int
4685ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4686 const char *nbr_str,
4687 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00004688{
4689 struct interface *ifp = vty->index;
4690 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00004691 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00004692 struct in_addr addr;
4693 int ret;
4694 struct ospf_if_params *params;
4695 struct ospf_interface *oi;
4696 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004697 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004698
paul020709f2003-04-04 02:44:16 +00004699 ospf = ospf_lookup ();
4700
paul718e3742002-12-13 20:15:29 +00004701 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00004702
4703 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004704 {
paulf9ad9372005-10-21 00:45:17 +00004705 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00004706 if (!ret)
4707 {
4708 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4709 VTY_NEWLINE);
4710 return CMD_WARNING;
4711 }
4712
4713 params = ospf_get_if_params (ifp, addr);
4714 ospf_if_update_params (ifp, addr);
4715 }
4716
paulf9ad9372005-10-21 00:45:17 +00004717 if (interval_str)
4718 {
4719 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4720 1, 65535);
4721
4722 /* reset fast_hello too, just to be sure */
4723 UNSET_IF_PARAM (params, fast_hello);
4724 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4725 }
4726 else if (fast_hello_str)
4727 {
4728 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4729 1, 10);
4730 /* 1s dead-interval with sub-second hellos desired */
4731 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
4732 SET_IF_PARAM (params, fast_hello);
4733 params->fast_hello = hellomult;
4734 }
4735 else
4736 {
4737 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
4738 VTY_NEWLINE);
4739 return CMD_WARNING;
4740 }
4741
paul718e3742002-12-13 20:15:29 +00004742 SET_IF_PARAM (params, v_wait);
4743 params->v_wait = seconds;
4744
4745 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00004746 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00004747 {
paul68980082003-03-25 05:07:42 +00004748 if (ospf)
4749 {
4750 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4751 if (oi)
4752 ospf_nbr_timer_update (oi);
4753 }
paul718e3742002-12-13 20:15:29 +00004754 }
4755 else
4756 {
4757 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4758 if ((oi = rn->info))
4759 ospf_nbr_timer_update (oi);
4760 }
4761
4762 return CMD_SUCCESS;
4763}
4764
paulf9ad9372005-10-21 00:45:17 +00004765
4766DEFUN (ip_ospf_dead_interval,
4767 ip_ospf_dead_interval_addr_cmd,
4768 "ip ospf dead-interval <1-65535> A.B.C.D",
4769 "IP Information\n"
4770 "OSPF interface commands\n"
4771 "Interval after which a neighbor is declared dead\n"
4772 "Seconds\n"
4773 "Address of interface\n")
4774{
4775 if (argc == 2)
4776 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
4777 else
4778 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
4779}
4780
paul718e3742002-12-13 20:15:29 +00004781ALIAS (ip_ospf_dead_interval,
4782 ip_ospf_dead_interval_cmd,
4783 "ip ospf dead-interval <1-65535>",
4784 "IP Information\n"
4785 "OSPF interface commands\n"
4786 "Interval after which a neighbor is declared dead\n"
4787 "Seconds\n")
4788
4789ALIAS (ip_ospf_dead_interval,
4790 ospf_dead_interval_cmd,
4791 "ospf dead-interval <1-65535>",
4792 "OSPF interface commands\n"
4793 "Interval after which a neighbor is declared dead\n"
4794 "Seconds\n")
4795
paulf9ad9372005-10-21 00:45:17 +00004796DEFUN (ip_ospf_dead_interval_minimal,
4797 ip_ospf_dead_interval_minimal_addr_cmd,
4798 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
4799 "IP Information\n"
4800 "OSPF interface commands\n"
4801 "Interval after which a neighbor is declared dead\n"
4802 "Minimal 1s dead-interval with fast sub-second hellos\n"
4803 "Hello multiplier factor\n"
4804 "Number of Hellos to send each second\n"
4805 "Address of interface\n")
4806{
4807 if (argc == 2)
4808 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
4809 else
4810 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
4811}
4812
4813ALIAS (ip_ospf_dead_interval_minimal,
4814 ip_ospf_dead_interval_minimal_cmd,
4815 "ip ospf dead-interval minimal hello-multiplier <1-10>",
4816 "IP Information\n"
4817 "OSPF interface commands\n"
4818 "Interval after which a neighbor is declared dead\n"
4819 "Minimal 1s dead-interval with fast sub-second hellos\n"
4820 "Hello multiplier factor\n"
4821 "Number of Hellos to send each second\n")
4822
paul718e3742002-12-13 20:15:29 +00004823DEFUN (no_ip_ospf_dead_interval,
4824 no_ip_ospf_dead_interval_addr_cmd,
4825 "no ip ospf dead-interval A.B.C.D",
4826 NO_STR
4827 "IP Information\n"
4828 "OSPF interface commands\n"
4829 "Interval after which a neighbor is declared dead\n"
4830 "Address of interface")
4831{
4832 struct interface *ifp = vty->index;
4833 struct in_addr addr;
4834 int ret;
4835 struct ospf_if_params *params;
4836 struct ospf_interface *oi;
4837 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004838 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004839
paul020709f2003-04-04 02:44:16 +00004840 ospf = ospf_lookup ();
4841
paul718e3742002-12-13 20:15:29 +00004842 ifp = vty->index;
4843 params = IF_DEF_PARAMS (ifp);
4844
4845 if (argc == 1)
4846 {
4847 ret = inet_aton(argv[0], &addr);
4848 if (!ret)
4849 {
4850 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4851 VTY_NEWLINE);
4852 return CMD_WARNING;
4853 }
4854
4855 params = ospf_lookup_if_params (ifp, addr);
4856 if (params == NULL)
4857 return CMD_SUCCESS;
4858 }
4859
4860 UNSET_IF_PARAM (params, v_wait);
4861 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00004862
4863 UNSET_IF_PARAM (params, fast_hello);
4864 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4865
paul718e3742002-12-13 20:15:29 +00004866 if (params != IF_DEF_PARAMS (ifp))
4867 {
4868 ospf_free_if_params (ifp, addr);
4869 ospf_if_update_params (ifp, addr);
4870 }
4871
4872 /* Update timer values in neighbor structure. */
4873 if (argc == 1)
4874 {
paul68980082003-03-25 05:07:42 +00004875 if (ospf)
4876 {
4877 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4878 if (oi)
4879 ospf_nbr_timer_update (oi);
4880 }
paul718e3742002-12-13 20:15:29 +00004881 }
4882 else
4883 {
4884 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4885 if ((oi = rn->info))
4886 ospf_nbr_timer_update (oi);
4887 }
4888
4889 return CMD_SUCCESS;
4890}
4891
4892ALIAS (no_ip_ospf_dead_interval,
4893 no_ip_ospf_dead_interval_cmd,
4894 "no ip ospf dead-interval",
4895 NO_STR
4896 "IP Information\n"
4897 "OSPF interface commands\n"
4898 "Interval after which a neighbor is declared dead\n")
4899
4900ALIAS (no_ip_ospf_dead_interval,
4901 no_ospf_dead_interval_cmd,
4902 "no ospf dead-interval",
4903 NO_STR
4904 "OSPF interface commands\n"
4905 "Interval after which a neighbor is declared dead\n")
4906
4907DEFUN (ip_ospf_hello_interval,
4908 ip_ospf_hello_interval_addr_cmd,
4909 "ip ospf hello-interval <1-65535> A.B.C.D",
4910 "IP Information\n"
4911 "OSPF interface commands\n"
4912 "Time between HELLO packets\n"
4913 "Seconds\n"
4914 "Address of interface")
4915{
4916 struct interface *ifp = vty->index;
4917 u_int32_t seconds;
4918 struct in_addr addr;
4919 int ret;
4920 struct ospf_if_params *params;
4921
4922 params = IF_DEF_PARAMS (ifp);
4923
4924 seconds = strtol (argv[0], NULL, 10);
4925
4926 /* HelloInterval range is <1-65535>. */
4927 if (seconds < 1 || seconds > 65535)
4928 {
4929 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4930 return CMD_WARNING;
4931 }
4932
4933 if (argc == 2)
4934 {
4935 ret = inet_aton(argv[1], &addr);
4936 if (!ret)
4937 {
4938 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4939 VTY_NEWLINE);
4940 return CMD_WARNING;
4941 }
4942
4943 params = ospf_get_if_params (ifp, addr);
4944 ospf_if_update_params (ifp, addr);
4945 }
4946
paulf9ad9372005-10-21 00:45:17 +00004947 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00004948 params->v_hello = seconds;
4949
4950 return CMD_SUCCESS;
4951}
4952
4953ALIAS (ip_ospf_hello_interval,
4954 ip_ospf_hello_interval_cmd,
4955 "ip ospf hello-interval <1-65535>",
4956 "IP Information\n"
4957 "OSPF interface commands\n"
4958 "Time between HELLO packets\n"
4959 "Seconds\n")
4960
4961ALIAS (ip_ospf_hello_interval,
4962 ospf_hello_interval_cmd,
4963 "ospf hello-interval <1-65535>",
4964 "OSPF interface commands\n"
4965 "Time between HELLO packets\n"
4966 "Seconds\n")
4967
4968DEFUN (no_ip_ospf_hello_interval,
4969 no_ip_ospf_hello_interval_addr_cmd,
4970 "no ip ospf hello-interval A.B.C.D",
4971 NO_STR
4972 "IP Information\n"
4973 "OSPF interface commands\n"
4974 "Time between HELLO packets\n"
4975 "Address of interface")
4976{
4977 struct interface *ifp = vty->index;
4978 struct in_addr addr;
4979 int ret;
4980 struct ospf_if_params *params;
4981
4982 ifp = vty->index;
4983 params = IF_DEF_PARAMS (ifp);
4984
4985 if (argc == 1)
4986 {
4987 ret = inet_aton(argv[0], &addr);
4988 if (!ret)
4989 {
4990 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4991 VTY_NEWLINE);
4992 return CMD_WARNING;
4993 }
4994
4995 params = ospf_lookup_if_params (ifp, addr);
4996 if (params == NULL)
4997 return CMD_SUCCESS;
4998 }
4999
5000 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005001 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005002
5003 if (params != IF_DEF_PARAMS (ifp))
5004 {
5005 ospf_free_if_params (ifp, addr);
5006 ospf_if_update_params (ifp, addr);
5007 }
5008
5009 return CMD_SUCCESS;
5010}
5011
5012ALIAS (no_ip_ospf_hello_interval,
5013 no_ip_ospf_hello_interval_cmd,
5014 "no ip ospf hello-interval",
5015 NO_STR
5016 "IP Information\n"
5017 "OSPF interface commands\n"
5018 "Time between HELLO packets\n")
5019
5020ALIAS (no_ip_ospf_hello_interval,
5021 no_ospf_hello_interval_cmd,
5022 "no ospf hello-interval",
5023 NO_STR
5024 "OSPF interface commands\n"
5025 "Time between HELLO packets\n")
5026
5027DEFUN (ip_ospf_network,
5028 ip_ospf_network_cmd,
5029 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5030 "IP Information\n"
5031 "OSPF interface commands\n"
5032 "Network type\n"
5033 "Specify OSPF broadcast multi-access network\n"
5034 "Specify OSPF NBMA network\n"
5035 "Specify OSPF point-to-multipoint network\n"
5036 "Specify OSPF point-to-point network\n")
5037{
5038 struct interface *ifp = vty->index;
5039 int old_type = IF_DEF_PARAMS (ifp)->type;
5040 struct route_node *rn;
5041
5042 if (strncmp (argv[0], "b", 1) == 0)
5043 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5044 else if (strncmp (argv[0], "n", 1) == 0)
5045 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5046 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5047 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5048 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5049 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5050
5051 if (IF_DEF_PARAMS (ifp)->type == old_type)
5052 return CMD_SUCCESS;
5053
5054 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5055
5056 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5057 {
5058 struct ospf_interface *oi = rn->info;
5059
5060 if (!oi)
5061 continue;
5062
5063 oi->type = IF_DEF_PARAMS (ifp)->type;
5064
5065 if (oi->state > ISM_Down)
5066 {
5067 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5068 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5069 }
5070 }
5071
5072 return CMD_SUCCESS;
5073}
5074
5075ALIAS (ip_ospf_network,
5076 ospf_network_cmd,
5077 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5078 "OSPF interface commands\n"
5079 "Network type\n"
5080 "Specify OSPF broadcast multi-access network\n"
5081 "Specify OSPF NBMA network\n"
5082 "Specify OSPF point-to-multipoint network\n"
5083 "Specify OSPF point-to-point network\n")
5084
5085DEFUN (no_ip_ospf_network,
5086 no_ip_ospf_network_cmd,
5087 "no ip ospf network",
5088 NO_STR
5089 "IP Information\n"
5090 "OSPF interface commands\n"
5091 "Network type\n")
5092{
5093 struct interface *ifp = vty->index;
5094 int old_type = IF_DEF_PARAMS (ifp)->type;
5095 struct route_node *rn;
5096
ajsbc18d612004-12-15 15:07:19 +00005097 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005098
5099 if (IF_DEF_PARAMS (ifp)->type == old_type)
5100 return CMD_SUCCESS;
5101
5102 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5103 {
5104 struct ospf_interface *oi = rn->info;
5105
5106 if (!oi)
5107 continue;
5108
5109 oi->type = IF_DEF_PARAMS (ifp)->type;
5110
5111 if (oi->state > ISM_Down)
5112 {
5113 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5114 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5115 }
5116 }
5117
5118 return CMD_SUCCESS;
5119}
5120
5121ALIAS (no_ip_ospf_network,
5122 no_ospf_network_cmd,
5123 "no ospf network",
5124 NO_STR
5125 "OSPF interface commands\n"
5126 "Network type\n")
5127
5128DEFUN (ip_ospf_priority,
5129 ip_ospf_priority_addr_cmd,
5130 "ip ospf priority <0-255> A.B.C.D",
5131 "IP Information\n"
5132 "OSPF interface commands\n"
5133 "Router priority\n"
5134 "Priority\n"
5135 "Address of interface")
5136{
5137 struct interface *ifp = vty->index;
5138 u_int32_t priority;
5139 struct route_node *rn;
5140 struct in_addr addr;
5141 int ret;
5142 struct ospf_if_params *params;
5143
5144 params = IF_DEF_PARAMS (ifp);
5145
5146 priority = strtol (argv[0], NULL, 10);
5147
5148 /* Router Priority range is <0-255>. */
5149 if (priority < 0 || priority > 255)
5150 {
5151 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5152 return CMD_WARNING;
5153 }
5154
5155 if (argc == 2)
5156 {
5157 ret = inet_aton(argv[1], &addr);
5158 if (!ret)
5159 {
5160 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5161 VTY_NEWLINE);
5162 return CMD_WARNING;
5163 }
5164
5165 params = ospf_get_if_params (ifp, addr);
5166 ospf_if_update_params (ifp, addr);
5167 }
5168
5169 SET_IF_PARAM (params, priority);
5170 params->priority = priority;
5171
5172 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5173 {
5174 struct ospf_interface *oi = rn->info;
5175
5176 if (!oi)
5177 continue;
5178
5179
5180 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5181 {
5182 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5183 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5184 }
5185 }
5186
5187 return CMD_SUCCESS;
5188}
5189
5190ALIAS (ip_ospf_priority,
5191 ip_ospf_priority_cmd,
5192 "ip ospf priority <0-255>",
5193 "IP Information\n"
5194 "OSPF interface commands\n"
5195 "Router priority\n"
5196 "Priority\n")
5197
5198ALIAS (ip_ospf_priority,
5199 ospf_priority_cmd,
5200 "ospf priority <0-255>",
5201 "OSPF interface commands\n"
5202 "Router priority\n"
5203 "Priority\n")
5204
5205DEFUN (no_ip_ospf_priority,
5206 no_ip_ospf_priority_addr_cmd,
5207 "no ip ospf priority A.B.C.D",
5208 NO_STR
5209 "IP Information\n"
5210 "OSPF interface commands\n"
5211 "Router priority\n"
5212 "Address of interface")
5213{
5214 struct interface *ifp = vty->index;
5215 struct route_node *rn;
5216 struct in_addr addr;
5217 int ret;
5218 struct ospf_if_params *params;
5219
5220 ifp = vty->index;
5221 params = IF_DEF_PARAMS (ifp);
5222
5223 if (argc == 1)
5224 {
5225 ret = inet_aton(argv[0], &addr);
5226 if (!ret)
5227 {
5228 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5229 VTY_NEWLINE);
5230 return CMD_WARNING;
5231 }
5232
5233 params = ospf_lookup_if_params (ifp, addr);
5234 if (params == NULL)
5235 return CMD_SUCCESS;
5236 }
5237
5238 UNSET_IF_PARAM (params, priority);
5239 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5240
5241 if (params != IF_DEF_PARAMS (ifp))
5242 {
5243 ospf_free_if_params (ifp, addr);
5244 ospf_if_update_params (ifp, addr);
5245 }
5246
5247 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5248 {
5249 struct ospf_interface *oi = rn->info;
5250
5251 if (!oi)
5252 continue;
5253
5254
5255 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5256 {
5257 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5258 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5259 }
5260 }
5261
5262 return CMD_SUCCESS;
5263}
5264
5265ALIAS (no_ip_ospf_priority,
5266 no_ip_ospf_priority_cmd,
5267 "no ip ospf priority",
5268 NO_STR
5269 "IP Information\n"
5270 "OSPF interface commands\n"
5271 "Router priority\n")
5272
5273ALIAS (no_ip_ospf_priority,
5274 no_ospf_priority_cmd,
5275 "no ospf priority",
5276 NO_STR
5277 "OSPF interface commands\n"
5278 "Router priority\n")
5279
5280DEFUN (ip_ospf_retransmit_interval,
5281 ip_ospf_retransmit_interval_addr_cmd,
5282 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5283 "IP Information\n"
5284 "OSPF interface commands\n"
5285 "Time between retransmitting lost link state advertisements\n"
5286 "Seconds\n"
5287 "Address of interface")
5288{
5289 struct interface *ifp = vty->index;
5290 u_int32_t seconds;
5291 struct in_addr addr;
5292 int ret;
5293 struct ospf_if_params *params;
5294
5295 params = IF_DEF_PARAMS (ifp);
5296 seconds = strtol (argv[0], NULL, 10);
5297
5298 /* Retransmit Interval range is <3-65535>. */
5299 if (seconds < 3 || seconds > 65535)
5300 {
5301 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5302 return CMD_WARNING;
5303 }
5304
5305
5306 if (argc == 2)
5307 {
5308 ret = inet_aton(argv[1], &addr);
5309 if (!ret)
5310 {
5311 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5312 VTY_NEWLINE);
5313 return CMD_WARNING;
5314 }
5315
5316 params = ospf_get_if_params (ifp, addr);
5317 ospf_if_update_params (ifp, addr);
5318 }
5319
5320 SET_IF_PARAM (params, retransmit_interval);
5321 params->retransmit_interval = seconds;
5322
5323 return CMD_SUCCESS;
5324}
5325
5326ALIAS (ip_ospf_retransmit_interval,
5327 ip_ospf_retransmit_interval_cmd,
5328 "ip ospf retransmit-interval <3-65535>",
5329 "IP Information\n"
5330 "OSPF interface commands\n"
5331 "Time between retransmitting lost link state advertisements\n"
5332 "Seconds\n")
5333
5334ALIAS (ip_ospf_retransmit_interval,
5335 ospf_retransmit_interval_cmd,
5336 "ospf retransmit-interval <3-65535>",
5337 "OSPF interface commands\n"
5338 "Time between retransmitting lost link state advertisements\n"
5339 "Seconds\n")
5340
5341DEFUN (no_ip_ospf_retransmit_interval,
5342 no_ip_ospf_retransmit_interval_addr_cmd,
5343 "no ip ospf retransmit-interval A.B.C.D",
5344 NO_STR
5345 "IP Information\n"
5346 "OSPF interface commands\n"
5347 "Time between retransmitting lost link state advertisements\n"
5348 "Address of interface")
5349{
5350 struct interface *ifp = vty->index;
5351 struct in_addr addr;
5352 int ret;
5353 struct ospf_if_params *params;
5354
5355 ifp = vty->index;
5356 params = IF_DEF_PARAMS (ifp);
5357
5358 if (argc == 1)
5359 {
5360 ret = inet_aton(argv[0], &addr);
5361 if (!ret)
5362 {
5363 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5364 VTY_NEWLINE);
5365 return CMD_WARNING;
5366 }
5367
5368 params = ospf_lookup_if_params (ifp, addr);
5369 if (params == NULL)
5370 return CMD_SUCCESS;
5371 }
5372
5373 UNSET_IF_PARAM (params, retransmit_interval);
5374 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5375
5376 if (params != IF_DEF_PARAMS (ifp))
5377 {
5378 ospf_free_if_params (ifp, addr);
5379 ospf_if_update_params (ifp, addr);
5380 }
5381
5382 return CMD_SUCCESS;
5383}
5384
5385ALIAS (no_ip_ospf_retransmit_interval,
5386 no_ip_ospf_retransmit_interval_cmd,
5387 "no ip ospf retransmit-interval",
5388 NO_STR
5389 "IP Information\n"
5390 "OSPF interface commands\n"
5391 "Time between retransmitting lost link state advertisements\n")
5392
5393ALIAS (no_ip_ospf_retransmit_interval,
5394 no_ospf_retransmit_interval_cmd,
5395 "no ospf retransmit-interval",
5396 NO_STR
5397 "OSPF interface commands\n"
5398 "Time between retransmitting lost link state advertisements\n")
5399
5400DEFUN (ip_ospf_transmit_delay,
5401 ip_ospf_transmit_delay_addr_cmd,
5402 "ip ospf transmit-delay <1-65535> A.B.C.D",
5403 "IP Information\n"
5404 "OSPF interface commands\n"
5405 "Link state transmit delay\n"
5406 "Seconds\n"
5407 "Address of interface")
5408{
5409 struct interface *ifp = vty->index;
5410 u_int32_t seconds;
5411 struct in_addr addr;
5412 int ret;
5413 struct ospf_if_params *params;
5414
5415 params = IF_DEF_PARAMS (ifp);
5416 seconds = strtol (argv[0], NULL, 10);
5417
5418 /* Transmit Delay range is <1-65535>. */
5419 if (seconds < 1 || seconds > 65535)
5420 {
5421 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5422 return CMD_WARNING;
5423 }
5424
5425 if (argc == 2)
5426 {
5427 ret = inet_aton(argv[1], &addr);
5428 if (!ret)
5429 {
5430 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5431 VTY_NEWLINE);
5432 return CMD_WARNING;
5433 }
5434
5435 params = ospf_get_if_params (ifp, addr);
5436 ospf_if_update_params (ifp, addr);
5437 }
5438
5439 SET_IF_PARAM (params, transmit_delay);
5440 params->transmit_delay = seconds;
5441
5442 return CMD_SUCCESS;
5443}
5444
5445ALIAS (ip_ospf_transmit_delay,
5446 ip_ospf_transmit_delay_cmd,
5447 "ip ospf transmit-delay <1-65535>",
5448 "IP Information\n"
5449 "OSPF interface commands\n"
5450 "Link state transmit delay\n"
5451 "Seconds\n")
5452
5453ALIAS (ip_ospf_transmit_delay,
5454 ospf_transmit_delay_cmd,
5455 "ospf transmit-delay <1-65535>",
5456 "OSPF interface commands\n"
5457 "Link state transmit delay\n"
5458 "Seconds\n")
5459
5460DEFUN (no_ip_ospf_transmit_delay,
5461 no_ip_ospf_transmit_delay_addr_cmd,
5462 "no ip ospf transmit-delay A.B.C.D",
5463 NO_STR
5464 "IP Information\n"
5465 "OSPF interface commands\n"
5466 "Link state transmit delay\n"
5467 "Address of interface")
5468{
5469 struct interface *ifp = vty->index;
5470 struct in_addr addr;
5471 int ret;
5472 struct ospf_if_params *params;
5473
5474 ifp = vty->index;
5475 params = IF_DEF_PARAMS (ifp);
5476
5477 if (argc == 1)
5478 {
5479 ret = inet_aton(argv[0], &addr);
5480 if (!ret)
5481 {
5482 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5483 VTY_NEWLINE);
5484 return CMD_WARNING;
5485 }
5486
5487 params = ospf_lookup_if_params (ifp, addr);
5488 if (params == NULL)
5489 return CMD_SUCCESS;
5490 }
5491
5492 UNSET_IF_PARAM (params, transmit_delay);
5493 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5494
5495 if (params != IF_DEF_PARAMS (ifp))
5496 {
5497 ospf_free_if_params (ifp, addr);
5498 ospf_if_update_params (ifp, addr);
5499 }
5500
5501 return CMD_SUCCESS;
5502}
5503
5504ALIAS (no_ip_ospf_transmit_delay,
5505 no_ip_ospf_transmit_delay_cmd,
5506 "no ip ospf transmit-delay",
5507 NO_STR
5508 "IP Information\n"
5509 "OSPF interface commands\n"
5510 "Link state transmit delay\n")
5511
5512ALIAS (no_ip_ospf_transmit_delay,
5513 no_ospf_transmit_delay_cmd,
5514 "no ospf transmit-delay",
5515 NO_STR
5516 "OSPF interface commands\n"
5517 "Link state transmit delay\n")
5518
5519
5520DEFUN (ospf_redistribute_source_metric_type,
5521 ospf_redistribute_source_metric_type_routemap_cmd,
5522 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5523 "Redistribute information from another routing protocol\n"
5524 "Kernel routes\n"
5525 "Connected\n"
5526 "Static routes\n"
5527 "Routing Information Protocol (RIP)\n"
5528 "Border Gateway Protocol (BGP)\n"
5529 "Metric for redistributed routes\n"
5530 "OSPF default metric\n"
5531 "OSPF exterior metric type for redistributed routes\n"
5532 "Set OSPF External Type 1 metrics\n"
5533 "Set OSPF External Type 2 metrics\n"
5534 "Route map reference\n"
5535 "Pointer to route-map entries\n")
5536{
paul020709f2003-04-04 02:44:16 +00005537 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005538 int source;
5539 int type = -1;
5540 int metric = -1;
5541
5542 /* Get distribute source. */
5543 if (!str2distribute_source (argv[0], &source))
5544 return CMD_WARNING;
5545
5546 /* Get metric value. */
5547 if (argc >= 2)
5548 if (!str2metric (argv[1], &metric))
5549 return CMD_WARNING;
5550
5551 /* Get metric type. */
5552 if (argc >= 3)
5553 if (!str2metric_type (argv[2], &type))
5554 return CMD_WARNING;
5555
5556 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005557 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005558 else
paul020709f2003-04-04 02:44:16 +00005559 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005560
paul020709f2003-04-04 02:44:16 +00005561 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005562}
5563
5564ALIAS (ospf_redistribute_source_metric_type,
5565 ospf_redistribute_source_metric_type_cmd,
5566 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5567 "Redistribute information from another routing protocol\n"
5568 "Kernel routes\n"
5569 "Connected\n"
5570 "Static routes\n"
5571 "Routing Information Protocol (RIP)\n"
5572 "Border Gateway Protocol (BGP)\n"
5573 "Metric for redistributed routes\n"
5574 "OSPF default metric\n"
5575 "OSPF exterior metric type for redistributed routes\n"
5576 "Set OSPF External Type 1 metrics\n"
5577 "Set OSPF External Type 2 metrics\n")
5578
5579ALIAS (ospf_redistribute_source_metric_type,
5580 ospf_redistribute_source_metric_cmd,
5581 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5582 "Redistribute information from another routing protocol\n"
5583 "Kernel routes\n"
5584 "Connected\n"
5585 "Static routes\n"
5586 "Routing Information Protocol (RIP)\n"
5587 "Border Gateway Protocol (BGP)\n"
5588 "Metric for redistributed routes\n"
5589 "OSPF default metric\n")
5590
5591DEFUN (ospf_redistribute_source_type_metric,
5592 ospf_redistribute_source_type_metric_routemap_cmd,
5593 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5594 "Redistribute information from another routing protocol\n"
5595 "Kernel routes\n"
5596 "Connected\n"
5597 "Static routes\n"
5598 "Routing Information Protocol (RIP)\n"
5599 "Border Gateway Protocol (BGP)\n"
5600 "OSPF exterior metric type for redistributed routes\n"
5601 "Set OSPF External Type 1 metrics\n"
5602 "Set OSPF External Type 2 metrics\n"
5603 "Metric for redistributed routes\n"
5604 "OSPF default metric\n"
5605 "Route map reference\n"
5606 "Pointer to route-map entries\n")
5607{
paul020709f2003-04-04 02:44:16 +00005608 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005609 int source;
5610 int type = -1;
5611 int metric = -1;
5612
5613 /* Get distribute source. */
5614 if (!str2distribute_source (argv[0], &source))
5615 return CMD_WARNING;
5616
5617 /* Get metric value. */
5618 if (argc >= 2)
5619 if (!str2metric_type (argv[1], &type))
5620 return CMD_WARNING;
5621
5622 /* Get metric type. */
5623 if (argc >= 3)
5624 if (!str2metric (argv[2], &metric))
5625 return CMD_WARNING;
5626
5627 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005628 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005629 else
paul020709f2003-04-04 02:44:16 +00005630 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005631
paul020709f2003-04-04 02:44:16 +00005632 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005633}
5634
5635ALIAS (ospf_redistribute_source_type_metric,
5636 ospf_redistribute_source_type_metric_cmd,
5637 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5638 "Redistribute information from another routing protocol\n"
5639 "Kernel routes\n"
5640 "Connected\n"
5641 "Static routes\n"
5642 "Routing Information Protocol (RIP)\n"
5643 "Border Gateway Protocol (BGP)\n"
5644 "OSPF exterior metric type for redistributed routes\n"
5645 "Set OSPF External Type 1 metrics\n"
5646 "Set OSPF External Type 2 metrics\n"
5647 "Metric for redistributed routes\n"
5648 "OSPF default metric\n")
5649
5650ALIAS (ospf_redistribute_source_type_metric,
5651 ospf_redistribute_source_type_cmd,
5652 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5653 "Redistribute information from another routing protocol\n"
5654 "Kernel routes\n"
5655 "Connected\n"
5656 "Static routes\n"
5657 "Routing Information Protocol (RIP)\n"
5658 "Border Gateway Protocol (BGP)\n"
5659 "OSPF exterior metric type for redistributed routes\n"
5660 "Set OSPF External Type 1 metrics\n"
5661 "Set OSPF External Type 2 metrics\n")
5662
5663ALIAS (ospf_redistribute_source_type_metric,
5664 ospf_redistribute_source_cmd,
5665 "redistribute (kernel|connected|static|rip|bgp)",
5666 "Redistribute information from another routing protocol\n"
5667 "Kernel routes\n"
5668 "Connected\n"
5669 "Static routes\n"
5670 "Routing Information Protocol (RIP)\n"
5671 "Border Gateway Protocol (BGP)\n")
5672
5673DEFUN (ospf_redistribute_source_metric_routemap,
5674 ospf_redistribute_source_metric_routemap_cmd,
5675 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5676 "Redistribute information from another routing protocol\n"
5677 "Kernel routes\n"
5678 "Connected\n"
5679 "Static routes\n"
5680 "Routing Information Protocol (RIP)\n"
5681 "Border Gateway Protocol (BGP)\n"
5682 "Metric for redistributed routes\n"
5683 "OSPF default metric\n"
5684 "Route map reference\n"
5685 "Pointer to route-map entries\n")
5686{
paul020709f2003-04-04 02:44:16 +00005687 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005688 int source;
5689 int metric = -1;
5690
5691 /* Get distribute source. */
5692 if (!str2distribute_source (argv[0], &source))
5693 return CMD_WARNING;
5694
5695 /* Get metric value. */
5696 if (argc >= 2)
5697 if (!str2metric (argv[1], &metric))
5698 return CMD_WARNING;
5699
5700 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005701 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005702 else
paul020709f2003-04-04 02:44:16 +00005703 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005704
paul020709f2003-04-04 02:44:16 +00005705 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005706}
5707
5708DEFUN (ospf_redistribute_source_type_routemap,
5709 ospf_redistribute_source_type_routemap_cmd,
5710 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5711 "Redistribute information from another routing protocol\n"
5712 "Kernel routes\n"
5713 "Connected\n"
5714 "Static routes\n"
5715 "Routing Information Protocol (RIP)\n"
5716 "Border Gateway Protocol (BGP)\n"
5717 "OSPF exterior metric type for redistributed routes\n"
5718 "Set OSPF External Type 1 metrics\n"
5719 "Set OSPF External Type 2 metrics\n"
5720 "Route map reference\n"
5721 "Pointer to route-map entries\n")
5722{
paul020709f2003-04-04 02:44:16 +00005723 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005724 int source;
5725 int type = -1;
5726
5727 /* Get distribute source. */
5728 if (!str2distribute_source (argv[0], &source))
5729 return CMD_WARNING;
5730
5731 /* Get metric value. */
5732 if (argc >= 2)
5733 if (!str2metric_type (argv[1], &type))
5734 return CMD_WARNING;
5735
5736 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005737 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005738 else
paul020709f2003-04-04 02:44:16 +00005739 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005740
paul020709f2003-04-04 02:44:16 +00005741 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005742}
5743
5744DEFUN (ospf_redistribute_source_routemap,
5745 ospf_redistribute_source_routemap_cmd,
5746 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5747 "Redistribute information from another routing protocol\n"
5748 "Kernel routes\n"
5749 "Connected\n"
5750 "Static routes\n"
5751 "Routing Information Protocol (RIP)\n"
5752 "Border Gateway Protocol (BGP)\n"
5753 "Route map reference\n"
5754 "Pointer to route-map entries\n")
5755{
paul020709f2003-04-04 02:44:16 +00005756 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005757 int source;
5758
5759 /* Get distribute source. */
5760 if (!str2distribute_source (argv[0], &source))
5761 return CMD_WARNING;
5762
5763 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005764 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005765 else
paul020709f2003-04-04 02:44:16 +00005766 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005767
paul020709f2003-04-04 02:44:16 +00005768 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005769}
5770
5771DEFUN (no_ospf_redistribute_source,
5772 no_ospf_redistribute_source_cmd,
5773 "no redistribute (kernel|connected|static|rip|bgp)",
5774 NO_STR
5775 "Redistribute information from another routing protocol\n"
5776 "Kernel routes\n"
5777 "Connected\n"
5778 "Static routes\n"
5779 "Routing Information Protocol (RIP)\n"
5780 "Border Gateway Protocol (BGP)\n")
5781{
paul020709f2003-04-04 02:44:16 +00005782 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005783 int source;
5784
5785 if (!str2distribute_source (argv[0], &source))
5786 return CMD_WARNING;
5787
paul020709f2003-04-04 02:44:16 +00005788 ospf_routemap_unset (ospf, source);
5789 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005790}
5791
5792DEFUN (ospf_distribute_list_out,
5793 ospf_distribute_list_out_cmd,
5794 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5795 "Filter networks in routing updates\n"
5796 "Access-list name\n"
5797 OUT_STR
5798 "Kernel routes\n"
5799 "Connected\n"
5800 "Static routes\n"
5801 "Routing Information Protocol (RIP)\n"
5802 "Border Gateway Protocol (BGP)\n")
5803{
paul68980082003-03-25 05:07:42 +00005804 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005805 int source;
5806
5807 /* Get distribute source. */
5808 if (!str2distribute_source (argv[1], &source))
5809 return CMD_WARNING;
5810
paul68980082003-03-25 05:07:42 +00005811 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005812}
5813
5814DEFUN (no_ospf_distribute_list_out,
5815 no_ospf_distribute_list_out_cmd,
5816 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5817 NO_STR
5818 "Filter networks in routing updates\n"
5819 "Access-list name\n"
5820 OUT_STR
5821 "Kernel routes\n"
5822 "Connected\n"
5823 "Static routes\n"
5824 "Routing Information Protocol (RIP)\n"
5825 "Border Gateway Protocol (BGP)\n")
5826{
paul68980082003-03-25 05:07:42 +00005827 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005828 int source;
5829
5830 if (!str2distribute_source (argv[1], &source))
5831 return CMD_WARNING;
5832
paul68980082003-03-25 05:07:42 +00005833 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005834}
5835
5836/* Default information originate. */
5837DEFUN (ospf_default_information_originate_metric_type_routemap,
5838 ospf_default_information_originate_metric_type_routemap_cmd,
5839 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5840 "Control distribution of default information\n"
5841 "Distribute a default route\n"
5842 "OSPF default metric\n"
5843 "OSPF metric\n"
5844 "OSPF metric type for default routes\n"
5845 "Set OSPF External Type 1 metrics\n"
5846 "Set OSPF External Type 2 metrics\n"
5847 "Route map reference\n"
5848 "Pointer to route-map entries\n")
5849{
paul020709f2003-04-04 02:44:16 +00005850 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005851 int type = -1;
5852 int metric = -1;
5853
5854 /* Get metric value. */
5855 if (argc >= 1)
5856 if (!str2metric (argv[0], &metric))
5857 return CMD_WARNING;
5858
5859 /* Get metric type. */
5860 if (argc >= 2)
5861 if (!str2metric_type (argv[1], &type))
5862 return CMD_WARNING;
5863
5864 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005865 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005866 else
paul020709f2003-04-04 02:44:16 +00005867 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005868
paul020709f2003-04-04 02:44:16 +00005869 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5870 type, metric);
paul718e3742002-12-13 20:15:29 +00005871}
5872
5873ALIAS (ospf_default_information_originate_metric_type_routemap,
5874 ospf_default_information_originate_metric_type_cmd,
5875 "default-information originate metric <0-16777214> metric-type (1|2)",
5876 "Control distribution of default information\n"
5877 "Distribute a 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
5884ALIAS (ospf_default_information_originate_metric_type_routemap,
5885 ospf_default_information_originate_metric_cmd,
5886 "default-information originate metric <0-16777214>",
5887 "Control distribution of default information\n"
5888 "Distribute a default route\n"
5889 "OSPF default metric\n"
5890 "OSPF metric\n")
5891
5892ALIAS (ospf_default_information_originate_metric_type_routemap,
5893 ospf_default_information_originate_cmd,
5894 "default-information originate",
5895 "Control distribution of default information\n"
5896 "Distribute a default route\n")
5897
5898/* Default information originate. */
5899DEFUN (ospf_default_information_originate_metric_routemap,
5900 ospf_default_information_originate_metric_routemap_cmd,
5901 "default-information originate metric <0-16777214> route-map WORD",
5902 "Control distribution of default information\n"
5903 "Distribute a default route\n"
5904 "OSPF default metric\n"
5905 "OSPF metric\n"
5906 "Route map reference\n"
5907 "Pointer to route-map entries\n")
5908{
paul020709f2003-04-04 02:44:16 +00005909 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005910 int metric = -1;
5911
5912 /* Get metric value. */
5913 if (argc >= 1)
5914 if (!str2metric (argv[0], &metric))
5915 return CMD_WARNING;
5916
5917 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005918 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005919 else
paul020709f2003-04-04 02:44:16 +00005920 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005921
paul020709f2003-04-04 02:44:16 +00005922 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5923 -1, metric);
paul718e3742002-12-13 20:15:29 +00005924}
5925
5926/* Default information originate. */
5927DEFUN (ospf_default_information_originate_routemap,
5928 ospf_default_information_originate_routemap_cmd,
5929 "default-information originate route-map WORD",
5930 "Control distribution of default information\n"
5931 "Distribute a default route\n"
5932 "Route map reference\n"
5933 "Pointer to route-map entries\n")
5934{
paul020709f2003-04-04 02:44:16 +00005935 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005936
paul020709f2003-04-04 02:44:16 +00005937 if (argc == 1)
5938 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5939 else
5940 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5941
5942 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005943}
5944
5945DEFUN (ospf_default_information_originate_type_metric_routemap,
5946 ospf_default_information_originate_type_metric_routemap_cmd,
5947 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5948 "Control distribution of default information\n"
5949 "Distribute a default route\n"
5950 "OSPF metric type for default routes\n"
5951 "Set OSPF External Type 1 metrics\n"
5952 "Set OSPF External Type 2 metrics\n"
5953 "OSPF default metric\n"
5954 "OSPF metric\n"
5955 "Route map reference\n"
5956 "Pointer to route-map entries\n")
5957{
paul020709f2003-04-04 02:44:16 +00005958 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005959 int type = -1;
5960 int metric = -1;
5961
5962 /* Get metric type. */
5963 if (argc >= 1)
5964 if (!str2metric_type (argv[0], &type))
5965 return CMD_WARNING;
5966
5967 /* Get metric value. */
5968 if (argc >= 2)
5969 if (!str2metric (argv[1], &metric))
5970 return CMD_WARNING;
5971
5972 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005973 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005974 else
paul020709f2003-04-04 02:44:16 +00005975 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005976
paul020709f2003-04-04 02:44:16 +00005977 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5978 type, metric);
paul718e3742002-12-13 20:15:29 +00005979}
5980
5981ALIAS (ospf_default_information_originate_type_metric_routemap,
5982 ospf_default_information_originate_type_metric_cmd,
5983 "default-information originate metric-type (1|2) metric <0-16777214>",
5984 "Control distribution of default information\n"
5985 "Distribute a default route\n"
5986 "OSPF metric type for default routes\n"
5987 "Set OSPF External Type 1 metrics\n"
5988 "Set OSPF External Type 2 metrics\n"
5989 "OSPF default metric\n"
5990 "OSPF metric\n")
5991
5992ALIAS (ospf_default_information_originate_type_metric_routemap,
5993 ospf_default_information_originate_type_cmd,
5994 "default-information originate metric-type (1|2)",
5995 "Control distribution of default information\n"
5996 "Distribute a default route\n"
5997 "OSPF metric type for default routes\n"
5998 "Set OSPF External Type 1 metrics\n"
5999 "Set OSPF External Type 2 metrics\n")
6000
6001DEFUN (ospf_default_information_originate_type_routemap,
6002 ospf_default_information_originate_type_routemap_cmd,
6003 "default-information originate metric-type (1|2) route-map WORD",
6004 "Control distribution of default information\n"
6005 "Distribute a default route\n"
6006 "OSPF metric type for default routes\n"
6007 "Set OSPF External Type 1 metrics\n"
6008 "Set OSPF External Type 2 metrics\n"
6009 "Route map reference\n"
6010 "Pointer to route-map entries\n")
6011{
paul020709f2003-04-04 02:44:16 +00006012 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006013 int type = -1;
6014
6015 /* Get metric type. */
6016 if (argc >= 1)
6017 if (!str2metric_type (argv[0], &type))
6018 return CMD_WARNING;
6019
6020 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006021 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006022 else
paul020709f2003-04-04 02:44:16 +00006023 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006024
paul020709f2003-04-04 02:44:16 +00006025 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6026 type, -1);
paul718e3742002-12-13 20:15:29 +00006027}
6028
6029DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6030 ospf_default_information_originate_always_metric_type_routemap_cmd,
6031 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6032 "Control distribution of default information\n"
6033 "Distribute a default route\n"
6034 "Always advertise default route\n"
6035 "OSPF default metric\n"
6036 "OSPF metric\n"
6037 "OSPF metric type for default routes\n"
6038 "Set OSPF External Type 1 metrics\n"
6039 "Set OSPF External Type 2 metrics\n"
6040 "Route map reference\n"
6041 "Pointer to route-map entries\n")
6042{
paul020709f2003-04-04 02:44:16 +00006043 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006044 int type = -1;
6045 int metric = -1;
6046
6047 /* Get metric value. */
6048 if (argc >= 1)
6049 if (!str2metric (argv[0], &metric))
6050 return CMD_WARNING;
6051
6052 /* Get metric type. */
6053 if (argc >= 2)
6054 if (!str2metric_type (argv[1], &type))
6055 return CMD_WARNING;
6056
6057 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006058 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006059 else
paul020709f2003-04-04 02:44:16 +00006060 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006061
paul020709f2003-04-04 02:44:16 +00006062 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006063 type, metric);
6064}
6065
6066ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6067 ospf_default_information_originate_always_metric_type_cmd,
6068 "default-information originate always metric <0-16777214> metric-type (1|2)",
6069 "Control distribution of default information\n"
6070 "Distribute a default route\n"
6071 "Always advertise default route\n"
6072 "OSPF default metric\n"
6073 "OSPF metric\n"
6074 "OSPF metric type for default routes\n"
6075 "Set OSPF External Type 1 metrics\n"
6076 "Set OSPF External Type 2 metrics\n")
6077
6078ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6079 ospf_default_information_originate_always_metric_cmd,
6080 "default-information originate always metric <0-16777214>",
6081 "Control distribution of default information\n"
6082 "Distribute a default route\n"
6083 "Always advertise default route\n"
6084 "OSPF default metric\n"
6085 "OSPF metric\n"
6086 "OSPF metric type for default routes\n")
6087
6088ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6089 ospf_default_information_originate_always_cmd,
6090 "default-information originate always",
6091 "Control distribution of default information\n"
6092 "Distribute a default route\n"
6093 "Always advertise default route\n")
6094
6095DEFUN (ospf_default_information_originate_always_metric_routemap,
6096 ospf_default_information_originate_always_metric_routemap_cmd,
6097 "default-information originate always metric <0-16777214> route-map WORD",
6098 "Control distribution of default information\n"
6099 "Distribute a default route\n"
6100 "Always advertise default route\n"
6101 "OSPF default metric\n"
6102 "OSPF metric\n"
6103 "Route map reference\n"
6104 "Pointer to route-map entries\n")
6105{
paul020709f2003-04-04 02:44:16 +00006106 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006107 int metric = -1;
6108
6109 /* Get metric value. */
6110 if (argc >= 1)
6111 if (!str2metric (argv[0], &metric))
6112 return CMD_WARNING;
6113
6114 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006115 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006116 else
paul020709f2003-04-04 02:44:16 +00006117 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006118
paul020709f2003-04-04 02:44:16 +00006119 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6120 -1, metric);
paul718e3742002-12-13 20:15:29 +00006121}
6122
6123DEFUN (ospf_default_information_originate_always_routemap,
6124 ospf_default_information_originate_always_routemap_cmd,
6125 "default-information originate always route-map WORD",
6126 "Control distribution of default information\n"
6127 "Distribute a default route\n"
6128 "Always advertise default route\n"
6129 "Route map reference\n"
6130 "Pointer to route-map entries\n")
6131{
paul020709f2003-04-04 02:44:16 +00006132 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006133
paul020709f2003-04-04 02:44:16 +00006134 if (argc == 1)
6135 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
6136 else
6137 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6138
6139 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00006140}
6141
6142DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6143 ospf_default_information_originate_always_type_metric_routemap_cmd,
6144 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6145 "Control distribution of default information\n"
6146 "Distribute a default route\n"
6147 "Always advertise default route\n"
6148 "OSPF metric type for default routes\n"
6149 "Set OSPF External Type 1 metrics\n"
6150 "Set OSPF External Type 2 metrics\n"
6151 "OSPF default metric\n"
6152 "OSPF metric\n"
6153 "Route map reference\n"
6154 "Pointer to route-map entries\n")
6155{
paul020709f2003-04-04 02:44:16 +00006156 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006157 int type = -1;
6158 int metric = -1;
6159
6160 /* Get metric type. */
6161 if (argc >= 1)
6162 if (!str2metric_type (argv[0], &type))
6163 return CMD_WARNING;
6164
6165 /* Get metric value. */
6166 if (argc >= 2)
6167 if (!str2metric (argv[1], &metric))
6168 return CMD_WARNING;
6169
6170 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006171 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006172 else
paul020709f2003-04-04 02:44:16 +00006173 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006174
paul020709f2003-04-04 02:44:16 +00006175 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006176 type, metric);
6177}
6178
6179ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6180 ospf_default_information_originate_always_type_metric_cmd,
6181 "default-information originate always metric-type (1|2) metric <0-16777214>",
6182 "Control distribution of default information\n"
6183 "Distribute a default route\n"
6184 "Always advertise default route\n"
6185 "OSPF metric type for default routes\n"
6186 "Set OSPF External Type 1 metrics\n"
6187 "Set OSPF External Type 2 metrics\n"
6188 "OSPF default metric\n"
6189 "OSPF metric\n")
6190
6191ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6192 ospf_default_information_originate_always_type_cmd,
6193 "default-information originate always metric-type (1|2)",
6194 "Control distribution of default information\n"
6195 "Distribute a default route\n"
6196 "Always advertise default route\n"
6197 "OSPF metric type for default routes\n"
6198 "Set OSPF External Type 1 metrics\n"
6199 "Set OSPF External Type 2 metrics\n")
6200
6201DEFUN (ospf_default_information_originate_always_type_routemap,
6202 ospf_default_information_originate_always_type_routemap_cmd,
6203 "default-information originate always metric-type (1|2) route-map WORD",
6204 "Control distribution of default information\n"
6205 "Distribute a default route\n"
6206 "Always advertise default route\n"
6207 "OSPF metric type for default routes\n"
6208 "Set OSPF External Type 1 metrics\n"
6209 "Set OSPF External Type 2 metrics\n"
6210 "Route map reference\n"
6211 "Pointer to route-map entries\n")
6212{
paul020709f2003-04-04 02:44:16 +00006213 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006214 int type = -1;
6215
6216 /* Get metric type. */
6217 if (argc >= 1)
6218 if (!str2metric_type (argv[0], &type))
6219 return CMD_WARNING;
6220
6221 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006222 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006223 else
paul020709f2003-04-04 02:44:16 +00006224 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006225
paul020709f2003-04-04 02:44:16 +00006226 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006227 type, -1);
6228}
6229
6230DEFUN (no_ospf_default_information_originate,
6231 no_ospf_default_information_originate_cmd,
6232 "no default-information originate",
6233 NO_STR
6234 "Control distribution of default information\n"
6235 "Distribute a default route\n")
6236{
paul68980082003-03-25 05:07:42 +00006237 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006238 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006239
6240 p.family = AF_INET;
6241 p.prefix.s_addr = 0;
6242 p.prefixlen = 0;
6243
ajs5339cfd2005-09-19 13:28:05 +00006244 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006245
6246 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6247 ospf_external_info_delete (DEFAULT_ROUTE, p);
6248 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6249 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6250 }
6251
paul020709f2003-04-04 02:44:16 +00006252 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6253 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006254}
6255
6256DEFUN (ospf_default_metric,
6257 ospf_default_metric_cmd,
6258 "default-metric <0-16777214>",
6259 "Set metric of redistributed routes\n"
6260 "Default metric\n")
6261{
paul68980082003-03-25 05:07:42 +00006262 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006263 int metric = -1;
6264
6265 if (!str2metric (argv[0], &metric))
6266 return CMD_WARNING;
6267
paul68980082003-03-25 05:07:42 +00006268 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006269
6270 return CMD_SUCCESS;
6271}
6272
6273DEFUN (no_ospf_default_metric,
6274 no_ospf_default_metric_cmd,
6275 "no default-metric",
6276 NO_STR
6277 "Set metric of redistributed routes\n")
6278{
paul68980082003-03-25 05:07:42 +00006279 struct ospf *ospf = vty->index;
6280
6281 ospf->default_metric = -1;
6282
paul718e3742002-12-13 20:15:29 +00006283 return CMD_SUCCESS;
6284}
6285
6286ALIAS (no_ospf_default_metric,
6287 no_ospf_default_metric_val_cmd,
6288 "no default-metric <0-16777214>",
6289 NO_STR
6290 "Set metric of redistributed routes\n"
6291 "Default metric\n")
6292
6293DEFUN (ospf_distance,
6294 ospf_distance_cmd,
6295 "distance <1-255>",
6296 "Define an administrative distance\n"
6297 "OSPF Administrative distance\n")
6298{
paul68980082003-03-25 05:07:42 +00006299 struct ospf *ospf = vty->index;
6300
6301 ospf->distance_all = atoi (argv[0]);
6302
paul718e3742002-12-13 20:15:29 +00006303 return CMD_SUCCESS;
6304}
6305
6306DEFUN (no_ospf_distance,
6307 no_ospf_distance_cmd,
6308 "no distance <1-255>",
6309 NO_STR
6310 "Define an administrative distance\n"
6311 "OSPF Administrative distance\n")
6312{
paul68980082003-03-25 05:07:42 +00006313 struct ospf *ospf = vty->index;
6314
6315 ospf->distance_all = 0;
6316
paul718e3742002-12-13 20:15:29 +00006317 return CMD_SUCCESS;
6318}
6319
6320DEFUN (no_ospf_distance_ospf,
6321 no_ospf_distance_ospf_cmd,
6322 "no distance ospf",
6323 NO_STR
6324 "Define an administrative distance\n"
6325 "OSPF Administrative distance\n"
6326 "OSPF Distance\n")
6327{
paul68980082003-03-25 05:07:42 +00006328 struct ospf *ospf = vty->index;
6329
6330 ospf->distance_intra = 0;
6331 ospf->distance_inter = 0;
6332 ospf->distance_external = 0;
6333
paul718e3742002-12-13 20:15:29 +00006334 return CMD_SUCCESS;
6335}
6336
6337DEFUN (ospf_distance_ospf_intra,
6338 ospf_distance_ospf_intra_cmd,
6339 "distance ospf intra-area <1-255>",
6340 "Define an administrative distance\n"
6341 "OSPF Administrative distance\n"
6342 "Intra-area routes\n"
6343 "Distance for intra-area routes\n")
6344{
paul68980082003-03-25 05:07:42 +00006345 struct ospf *ospf = vty->index;
6346
6347 ospf->distance_intra = atoi (argv[0]);
6348
paul718e3742002-12-13 20:15:29 +00006349 return CMD_SUCCESS;
6350}
6351
6352DEFUN (ospf_distance_ospf_intra_inter,
6353 ospf_distance_ospf_intra_inter_cmd,
6354 "distance ospf intra-area <1-255> inter-area <1-255>",
6355 "Define an administrative distance\n"
6356 "OSPF Administrative distance\n"
6357 "Intra-area routes\n"
6358 "Distance for intra-area routes\n"
6359 "Inter-area routes\n"
6360 "Distance for inter-area routes\n")
6361{
paul68980082003-03-25 05:07:42 +00006362 struct ospf *ospf = vty->index;
6363
6364 ospf->distance_intra = atoi (argv[0]);
6365 ospf->distance_inter = atoi (argv[1]);
6366
paul718e3742002-12-13 20:15:29 +00006367 return CMD_SUCCESS;
6368}
6369
6370DEFUN (ospf_distance_ospf_intra_external,
6371 ospf_distance_ospf_intra_external_cmd,
6372 "distance ospf intra-area <1-255> external <1-255>",
6373 "Define an administrative distance\n"
6374 "OSPF Administrative distance\n"
6375 "Intra-area routes\n"
6376 "Distance for intra-area routes\n"
6377 "External routes\n"
6378 "Distance for external routes\n")
6379{
paul68980082003-03-25 05:07:42 +00006380 struct ospf *ospf = vty->index;
6381
6382 ospf->distance_intra = atoi (argv[0]);
6383 ospf->distance_external = atoi (argv[1]);
6384
paul718e3742002-12-13 20:15:29 +00006385 return CMD_SUCCESS;
6386}
6387
6388DEFUN (ospf_distance_ospf_intra_inter_external,
6389 ospf_distance_ospf_intra_inter_external_cmd,
6390 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6391 "Define an administrative distance\n"
6392 "OSPF Administrative distance\n"
6393 "Intra-area routes\n"
6394 "Distance for intra-area routes\n"
6395 "Inter-area routes\n"
6396 "Distance for inter-area routes\n"
6397 "External routes\n"
6398 "Distance for external routes\n")
6399{
paul68980082003-03-25 05:07:42 +00006400 struct ospf *ospf = vty->index;
6401
6402 ospf->distance_intra = atoi (argv[0]);
6403 ospf->distance_inter = atoi (argv[1]);
6404 ospf->distance_external = atoi (argv[2]);
6405
paul718e3742002-12-13 20:15:29 +00006406 return CMD_SUCCESS;
6407}
6408
6409DEFUN (ospf_distance_ospf_intra_external_inter,
6410 ospf_distance_ospf_intra_external_inter_cmd,
6411 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6412 "Define an administrative distance\n"
6413 "OSPF Administrative distance\n"
6414 "Intra-area routes\n"
6415 "Distance for intra-area routes\n"
6416 "External routes\n"
6417 "Distance for external routes\n"
6418 "Inter-area routes\n"
6419 "Distance for inter-area routes\n")
6420{
paul68980082003-03-25 05:07:42 +00006421 struct ospf *ospf = vty->index;
6422
6423 ospf->distance_intra = atoi (argv[0]);
6424 ospf->distance_external = atoi (argv[1]);
6425 ospf->distance_inter = atoi (argv[2]);
6426
paul718e3742002-12-13 20:15:29 +00006427 return CMD_SUCCESS;
6428}
6429
6430DEFUN (ospf_distance_ospf_inter,
6431 ospf_distance_ospf_inter_cmd,
6432 "distance ospf inter-area <1-255>",
6433 "Define an administrative distance\n"
6434 "OSPF Administrative distance\n"
6435 "Inter-area routes\n"
6436 "Distance for inter-area routes\n")
6437{
paul68980082003-03-25 05:07:42 +00006438 struct ospf *ospf = vty->index;
6439
6440 ospf->distance_inter = atoi (argv[0]);
6441
paul718e3742002-12-13 20:15:29 +00006442 return CMD_SUCCESS;
6443}
6444
6445DEFUN (ospf_distance_ospf_inter_intra,
6446 ospf_distance_ospf_inter_intra_cmd,
6447 "distance ospf inter-area <1-255> intra-area <1-255>",
6448 "Define an administrative distance\n"
6449 "OSPF Administrative distance\n"
6450 "Inter-area routes\n"
6451 "Distance for inter-area routes\n"
6452 "Intra-area routes\n"
6453 "Distance for intra-area routes\n")
6454{
paul68980082003-03-25 05:07:42 +00006455 struct ospf *ospf = vty->index;
6456
6457 ospf->distance_inter = atoi (argv[0]);
6458 ospf->distance_intra = atoi (argv[1]);
6459
paul718e3742002-12-13 20:15:29 +00006460 return CMD_SUCCESS;
6461}
6462
6463DEFUN (ospf_distance_ospf_inter_external,
6464 ospf_distance_ospf_inter_external_cmd,
6465 "distance ospf inter-area <1-255> external <1-255>",
6466 "Define an administrative distance\n"
6467 "OSPF Administrative distance\n"
6468 "Inter-area routes\n"
6469 "Distance for inter-area routes\n"
6470 "External routes\n"
6471 "Distance for external routes\n")
6472{
paul68980082003-03-25 05:07:42 +00006473 struct ospf *ospf = vty->index;
6474
6475 ospf->distance_inter = atoi (argv[0]);
6476 ospf->distance_external = atoi (argv[1]);
6477
paul718e3742002-12-13 20:15:29 +00006478 return CMD_SUCCESS;
6479}
6480
6481DEFUN (ospf_distance_ospf_inter_intra_external,
6482 ospf_distance_ospf_inter_intra_external_cmd,
6483 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6484 "Define an administrative distance\n"
6485 "OSPF Administrative distance\n"
6486 "Inter-area routes\n"
6487 "Distance for inter-area routes\n"
6488 "Intra-area routes\n"
6489 "Distance for intra-area routes\n"
6490 "External routes\n"
6491 "Distance for external routes\n")
6492{
paul68980082003-03-25 05:07:42 +00006493 struct ospf *ospf = vty->index;
6494
6495 ospf->distance_inter = atoi (argv[0]);
6496 ospf->distance_intra = atoi (argv[1]);
6497 ospf->distance_external = atoi (argv[2]);
6498
paul718e3742002-12-13 20:15:29 +00006499 return CMD_SUCCESS;
6500}
6501
6502DEFUN (ospf_distance_ospf_inter_external_intra,
6503 ospf_distance_ospf_inter_external_intra_cmd,
6504 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6505 "Define an administrative distance\n"
6506 "OSPF Administrative distance\n"
6507 "Inter-area routes\n"
6508 "Distance for inter-area routes\n"
6509 "External routes\n"
6510 "Distance for external routes\n"
6511 "Intra-area routes\n"
6512 "Distance for intra-area routes\n")
6513{
paul68980082003-03-25 05:07:42 +00006514 struct ospf *ospf = vty->index;
6515
6516 ospf->distance_inter = atoi (argv[0]);
6517 ospf->distance_external = atoi (argv[1]);
6518 ospf->distance_intra = atoi (argv[2]);
6519
paul718e3742002-12-13 20:15:29 +00006520 return CMD_SUCCESS;
6521}
6522
6523DEFUN (ospf_distance_ospf_external,
6524 ospf_distance_ospf_external_cmd,
6525 "distance ospf external <1-255>",
6526 "Define an administrative distance\n"
6527 "OSPF Administrative distance\n"
6528 "External routes\n"
6529 "Distance for external routes\n")
6530{
paul68980082003-03-25 05:07:42 +00006531 struct ospf *ospf = vty->index;
6532
6533 ospf->distance_external = atoi (argv[0]);
6534
paul718e3742002-12-13 20:15:29 +00006535 return CMD_SUCCESS;
6536}
6537
6538DEFUN (ospf_distance_ospf_external_intra,
6539 ospf_distance_ospf_external_intra_cmd,
6540 "distance ospf external <1-255> intra-area <1-255>",
6541 "Define an administrative distance\n"
6542 "OSPF Administrative distance\n"
6543 "External routes\n"
6544 "Distance for external routes\n"
6545 "Intra-area routes\n"
6546 "Distance for intra-area routes\n")
6547{
paul68980082003-03-25 05:07:42 +00006548 struct ospf *ospf = vty->index;
6549
6550 ospf->distance_external = atoi (argv[0]);
6551 ospf->distance_intra = atoi (argv[1]);
6552
paul718e3742002-12-13 20:15:29 +00006553 return CMD_SUCCESS;
6554}
6555
6556DEFUN (ospf_distance_ospf_external_inter,
6557 ospf_distance_ospf_external_inter_cmd,
6558 "distance ospf external <1-255> inter-area <1-255>",
6559 "Define an administrative distance\n"
6560 "OSPF Administrative distance\n"
6561 "External routes\n"
6562 "Distance for external routes\n"
6563 "Inter-area routes\n"
6564 "Distance for inter-area routes\n")
6565{
paul68980082003-03-25 05:07:42 +00006566 struct ospf *ospf = vty->index;
6567
6568 ospf->distance_external = atoi (argv[0]);
6569 ospf->distance_inter = atoi (argv[1]);
6570
paul718e3742002-12-13 20:15:29 +00006571 return CMD_SUCCESS;
6572}
6573
6574DEFUN (ospf_distance_ospf_external_intra_inter,
6575 ospf_distance_ospf_external_intra_inter_cmd,
6576 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6577 "Define an administrative distance\n"
6578 "OSPF Administrative distance\n"
6579 "External routes\n"
6580 "Distance for external routes\n"
6581 "Intra-area routes\n"
6582 "Distance for intra-area routes\n"
6583 "Inter-area routes\n"
6584 "Distance for inter-area routes\n")
6585{
paul68980082003-03-25 05:07:42 +00006586 struct ospf *ospf = vty->index;
6587
6588 ospf->distance_external = atoi (argv[0]);
6589 ospf->distance_intra = atoi (argv[1]);
6590 ospf->distance_inter = atoi (argv[2]);
6591
paul718e3742002-12-13 20:15:29 +00006592 return CMD_SUCCESS;
6593}
6594
6595DEFUN (ospf_distance_ospf_external_inter_intra,
6596 ospf_distance_ospf_external_inter_intra_cmd,
6597 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6598 "Define an administrative distance\n"
6599 "OSPF Administrative distance\n"
6600 "External routes\n"
6601 "Distance for external routes\n"
6602 "Inter-area routes\n"
6603 "Distance for inter-area routes\n"
6604 "Intra-area routes\n"
6605 "Distance for intra-area routes\n")
6606{
paul68980082003-03-25 05:07:42 +00006607 struct ospf *ospf = vty->index;
6608
6609 ospf->distance_external = atoi (argv[0]);
6610 ospf->distance_inter = atoi (argv[1]);
6611 ospf->distance_intra = atoi (argv[2]);
6612
paul718e3742002-12-13 20:15:29 +00006613 return CMD_SUCCESS;
6614}
6615
6616DEFUN (ospf_distance_source,
6617 ospf_distance_source_cmd,
6618 "distance <1-255> A.B.C.D/M",
6619 "Administrative distance\n"
6620 "Distance value\n"
6621 "IP source prefix\n")
6622{
paul020709f2003-04-04 02:44:16 +00006623 struct ospf *ospf = vty->index;
6624
6625 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006626
paul718e3742002-12-13 20:15:29 +00006627 return CMD_SUCCESS;
6628}
6629
6630DEFUN (no_ospf_distance_source,
6631 no_ospf_distance_source_cmd,
6632 "no distance <1-255> A.B.C.D/M",
6633 NO_STR
6634 "Administrative distance\n"
6635 "Distance value\n"
6636 "IP source prefix\n")
6637{
paul020709f2003-04-04 02:44:16 +00006638 struct ospf *ospf = vty->index;
6639
6640 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6641
paul718e3742002-12-13 20:15:29 +00006642 return CMD_SUCCESS;
6643}
6644
6645DEFUN (ospf_distance_source_access_list,
6646 ospf_distance_source_access_list_cmd,
6647 "distance <1-255> A.B.C.D/M WORD",
6648 "Administrative distance\n"
6649 "Distance value\n"
6650 "IP source prefix\n"
6651 "Access list name\n")
6652{
paul020709f2003-04-04 02:44:16 +00006653 struct ospf *ospf = vty->index;
6654
6655 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6656
paul718e3742002-12-13 20:15:29 +00006657 return CMD_SUCCESS;
6658}
6659
6660DEFUN (no_ospf_distance_source_access_list,
6661 no_ospf_distance_source_access_list_cmd,
6662 "no distance <1-255> A.B.C.D/M WORD",
6663 NO_STR
6664 "Administrative distance\n"
6665 "Distance value\n"
6666 "IP source prefix\n"
6667 "Access list name\n")
6668{
paul020709f2003-04-04 02:44:16 +00006669 struct ospf *ospf = vty->index;
6670
6671 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6672
paul718e3742002-12-13 20:15:29 +00006673 return CMD_SUCCESS;
6674}
6675
vincentba682532005-09-29 13:52:57 +00006676DEFUN (ip_ospf_mtu_ignore,
6677 ip_ospf_mtu_ignore_addr_cmd,
6678 "ip ospf mtu-ignore A.B.C.D",
6679 "IP Information\n"
6680 "OSPF interface commands\n"
6681 "Disable mtu mismatch detection\n"
6682 "Address of interface")
6683{
6684 struct interface *ifp = vty->index;
6685 struct in_addr addr;
6686 int ret;
6687
6688 struct ospf_if_params *params;
6689 params = IF_DEF_PARAMS (ifp);
6690
6691 if (argc == 1)
6692 {
6693 ret = inet_aton(argv[0], &addr);
6694 if (!ret)
6695 {
6696 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6697 VTY_NEWLINE);
6698 return CMD_WARNING;
6699 }
6700 params = ospf_get_if_params (ifp, addr);
6701 ospf_if_update_params (ifp, addr);
6702 }
6703 params->mtu_ignore = 1;
6704 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6705 SET_IF_PARAM (params, mtu_ignore);
6706 else
6707 {
6708 UNSET_IF_PARAM (params, mtu_ignore);
6709 if (params != IF_DEF_PARAMS (ifp))
6710 {
6711 ospf_free_if_params (ifp, addr);
6712 ospf_if_update_params (ifp, addr);
6713 }
6714 }
6715 return CMD_SUCCESS;
6716}
6717
6718ALIAS (ip_ospf_mtu_ignore,
6719 ip_ospf_mtu_ignore_cmd,
6720 "ip ospf mtu-ignore",
6721 "IP Information\n"
6722 "OSPF interface commands\n"
6723 "Disable mtu mismatch detection\n")
6724
6725
6726DEFUN (no_ip_ospf_mtu_ignore,
6727 no_ip_ospf_mtu_ignore_addr_cmd,
6728 "no ip ospf mtu-ignore A.B.C.D",
6729 "IP Information\n"
6730 "OSPF interface commands\n"
6731 "Disable mtu mismatch detection\n"
6732 "Address of interface")
6733{
6734 struct interface *ifp = vty->index;
6735 struct in_addr addr;
6736 int ret;
6737
6738 struct ospf_if_params *params;
6739 params = IF_DEF_PARAMS (ifp);
6740
6741 if (argc == 1)
6742 {
6743 ret = inet_aton(argv[0], &addr);
6744 if (!ret)
6745 {
6746 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6747 VTY_NEWLINE);
6748 return CMD_WARNING;
6749 }
6750 params = ospf_get_if_params (ifp, addr);
6751 ospf_if_update_params (ifp, addr);
6752 }
6753 params->mtu_ignore = 0;
6754 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6755 SET_IF_PARAM (params, mtu_ignore);
6756 else
6757 {
6758 UNSET_IF_PARAM (params, mtu_ignore);
6759 if (params != IF_DEF_PARAMS (ifp))
6760 {
6761 ospf_free_if_params (ifp, addr);
6762 ospf_if_update_params (ifp, addr);
6763 }
6764 }
6765 return CMD_SUCCESS;
6766}
6767
6768ALIAS (no_ip_ospf_mtu_ignore,
6769 no_ip_ospf_mtu_ignore_cmd,
6770 "no ip ospf mtu-ignore",
6771 "IP Information\n"
6772 "OSPF interface commands\n"
6773 "Disable mtu mismatch detection\n")
6774
paul4dadc292005-05-06 21:37:42 +00006775static void
paul718e3742002-12-13 20:15:29 +00006776show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6777{
6778 struct route_node *rn;
6779 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006780 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006781 struct ospf_path *path;
6782
6783 vty_out (vty, "============ OSPF network routing table ============%s",
6784 VTY_NEWLINE);
6785
6786 for (rn = route_top (rt); rn; rn = route_next (rn))
6787 if ((or = rn->info) != NULL)
6788 {
6789 char buf1[19];
6790 snprintf (buf1, 19, "%s/%d",
6791 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6792
6793 switch (or->path_type)
6794 {
6795 case OSPF_PATH_INTER_AREA:
6796 if (or->type == OSPF_DESTINATION_NETWORK)
6797 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6798 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6799 else if (or->type == OSPF_DESTINATION_DISCARD)
6800 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6801 break;
6802 case OSPF_PATH_INTRA_AREA:
6803 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6804 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6805 break;
6806 default:
6807 break;
6808 }
6809
6810 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00006811 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00006812 {
hasso54bedb52005-08-17 13:31:47 +00006813 if (path->oi != NULL && ospf_if_exists(path->oi))
paul96735ee2003-08-10 02:51:22 +00006814 {
6815 if (path->nexthop.s_addr == 0)
6816 vty_out (vty, "%24s directly attached to %s%s",
6817 "", path->oi->ifp->name, VTY_NEWLINE);
6818 else
6819 vty_out (vty, "%24s via %s, %s%s", "",
6820 inet_ntoa (path->nexthop), path->oi->ifp->name,
6821 VTY_NEWLINE);
6822 }
6823 }
paul718e3742002-12-13 20:15:29 +00006824 }
6825 vty_out (vty, "%s", VTY_NEWLINE);
6826}
6827
paul4dadc292005-05-06 21:37:42 +00006828static void
paul718e3742002-12-13 20:15:29 +00006829show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6830{
6831 struct route_node *rn;
6832 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006833 struct listnode *pnode;
6834 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006835 struct ospf_path *path;
6836
6837 vty_out (vty, "============ OSPF router routing table =============%s",
6838 VTY_NEWLINE);
6839 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6840 if (rn->info)
6841 {
6842 int flag = 0;
6843
6844 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6845
paul1eb8ef22005-04-07 07:30:20 +00006846 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
6847 {
6848 if (flag++)
6849 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006850
paul1eb8ef22005-04-07 07:30:20 +00006851 /* Show path. */
6852 vty_out (vty, "%s [%d] area: %s",
6853 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6854 or->cost, inet_ntoa (or->u.std.area_id));
6855 /* Show flags. */
6856 vty_out (vty, "%s%s%s",
6857 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6858 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6859 VTY_NEWLINE);
6860
6861 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
6862 {
hasso54bedb52005-08-17 13:31:47 +00006863 if (path->oi != NULL && ospf_if_exists(path->oi))
6864 {
6865 if (path->nexthop.s_addr == 0)
6866 vty_out (vty, "%24s directly attached to %s%s",
6867 "", path->oi->ifp->name, VTY_NEWLINE);
6868 else
6869 vty_out (vty, "%24s via %s, %s%s", "",
6870 inet_ntoa (path->nexthop),
6871 path->oi->ifp->name, VTY_NEWLINE);
6872 }
paul1eb8ef22005-04-07 07:30:20 +00006873 }
6874 }
paul718e3742002-12-13 20:15:29 +00006875 }
6876 vty_out (vty, "%s", VTY_NEWLINE);
6877}
6878
paul4dadc292005-05-06 21:37:42 +00006879static void
paul718e3742002-12-13 20:15:29 +00006880show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6881{
6882 struct route_node *rn;
6883 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00006884 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006885 struct ospf_path *path;
6886
6887 vty_out (vty, "============ OSPF external routing table ===========%s",
6888 VTY_NEWLINE);
6889 for (rn = route_top (rt); rn; rn = route_next (rn))
6890 if ((er = rn->info) != NULL)
6891 {
6892 char buf1[19];
6893 snprintf (buf1, 19, "%s/%d",
6894 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6895
6896 switch (er->path_type)
6897 {
6898 case OSPF_PATH_TYPE1_EXTERNAL:
6899 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6900 er->cost, er->u.ext.tag, VTY_NEWLINE);
6901 break;
6902 case OSPF_PATH_TYPE2_EXTERNAL:
6903 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6904 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6905 break;
6906 }
6907
paul1eb8ef22005-04-07 07:30:20 +00006908 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00006909 {
hasso54bedb52005-08-17 13:31:47 +00006910 if (path->oi != NULL && ospf_if_exists(path->oi))
paul718e3742002-12-13 20:15:29 +00006911 {
6912 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006913 vty_out (vty, "%24s directly attached to %s%s",
6914 "", path->oi->ifp->name, VTY_NEWLINE);
6915 else
6916 vty_out (vty, "%24s via %s, %s%s", "",
6917 inet_ntoa (path->nexthop), path->oi->ifp->name,
6918 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006919 }
6920 }
6921 }
6922 vty_out (vty, "%s", VTY_NEWLINE);
6923}
6924
paul718e3742002-12-13 20:15:29 +00006925DEFUN (show_ip_ospf_border_routers,
6926 show_ip_ospf_border_routers_cmd,
6927 "show ip ospf border-routers",
6928 SHOW_STR
6929 IP_STR
6930 "show all the ABR's and ASBR's\n"
6931 "for this area\n")
6932{
paul020709f2003-04-04 02:44:16 +00006933 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006934
paul020709f2003-04-04 02:44:16 +00006935 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006936 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006937 {
6938 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6939 return CMD_SUCCESS;
6940 }
6941
paul68980082003-03-25 05:07:42 +00006942 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006943 {
6944 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6945 return CMD_SUCCESS;
6946 }
6947
6948 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006949 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006950
6951 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006952 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006953
6954 return CMD_SUCCESS;
6955}
paul718e3742002-12-13 20:15:29 +00006956
6957DEFUN (show_ip_ospf_route,
6958 show_ip_ospf_route_cmd,
6959 "show ip ospf route",
6960 SHOW_STR
6961 IP_STR
6962 "OSPF information\n"
6963 "OSPF routing table\n")
6964{
paul020709f2003-04-04 02:44:16 +00006965 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006966
paul020709f2003-04-04 02:44:16 +00006967 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006968 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006969 {
6970 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6971 return CMD_SUCCESS;
6972 }
6973
paul68980082003-03-25 05:07:42 +00006974 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006975 {
6976 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6977 return CMD_SUCCESS;
6978 }
6979
6980 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006981 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006982
6983 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006984 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006985
6986 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006987 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006988
6989 return CMD_SUCCESS;
6990}
6991
6992
hassoeb1ce602004-10-08 08:17:22 +00006993const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006994{
6995 "unknown",
6996 "standard",
6997 "ibm",
6998 "cisco",
6999 "shortcut"
7000};
7001
hassoeb1ce602004-10-08 08:17:22 +00007002const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00007003{
7004 "default",
7005 "enable",
7006 "disable"
7007};
7008
7009
paul4dadc292005-05-06 21:37:42 +00007010static void
paul718e3742002-12-13 20:15:29 +00007011area_id2str (char *buf, int length, struct ospf_area *area)
7012{
7013 memset (buf, 0, length);
7014
7015 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7016 strncpy (buf, inet_ntoa (area->area_id), length);
7017 else
7018 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7019}
7020
7021
hassoeb1ce602004-10-08 08:17:22 +00007022const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00007023{
7024 "unknown", /* should never be used. */
7025 "point-to-point",
7026 "broadcast",
7027 "non-broadcast",
7028 "point-to-multipoint",
7029 "virtual-link", /* should never be used. */
7030 "loopback"
7031};
7032
7033/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00007034static int
paul718e3742002-12-13 20:15:29 +00007035config_write_interface (struct vty *vty)
7036{
hasso52dc7ee2004-09-23 19:18:23 +00007037 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00007038 struct interface *ifp;
7039 struct crypt_key *ck;
7040 int write = 0;
7041 struct route_node *rn = NULL;
7042 struct ospf_if_params *params;
7043
paul1eb8ef22005-04-07 07:30:20 +00007044 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00007045 {
paul718e3742002-12-13 20:15:29 +00007046 if (memcmp (ifp->name, "VLINK", 5) == 0)
7047 continue;
7048
7049 vty_out (vty, "!%s", VTY_NEWLINE);
7050 vty_out (vty, "interface %s%s", ifp->name,
7051 VTY_NEWLINE);
7052 if (ifp->desc)
7053 vty_out (vty, " description %s%s", ifp->desc,
7054 VTY_NEWLINE);
7055
7056 write++;
7057
7058 params = IF_DEF_PARAMS (ifp);
7059
7060 do {
7061 /* Interface Network print. */
7062 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00007063 params->type != OSPF_IFTYPE_LOOPBACK)
7064 {
ajsbc18d612004-12-15 15:07:19 +00007065 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00007066 {
7067 vty_out (vty, " ip ospf network %s",
7068 ospf_int_type_str[params->type]);
7069 if (params != IF_DEF_PARAMS (ifp))
7070 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7071 vty_out (vty, "%s", VTY_NEWLINE);
7072 }
paul718e3742002-12-13 20:15:29 +00007073 }
7074
7075 /* OSPF interface authentication print */
7076 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7077 params->auth_type != OSPF_AUTH_NOTSET)
7078 {
hassoeb1ce602004-10-08 08:17:22 +00007079 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00007080
7081 /* Translation tables are not that much help here due to syntax
7082 of the simple option */
7083 switch (params->auth_type)
7084 {
7085
7086 case OSPF_AUTH_NULL:
7087 auth_str = " null";
7088 break;
7089
7090 case OSPF_AUTH_SIMPLE:
7091 auth_str = "";
7092 break;
7093
7094 case OSPF_AUTH_CRYPTOGRAPHIC:
7095 auth_str = " message-digest";
7096 break;
7097
7098 default:
7099 auth_str = "";
7100 break;
7101 }
7102
7103 vty_out (vty, " ip ospf authentication%s", auth_str);
7104 if (params != IF_DEF_PARAMS (ifp))
7105 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7106 vty_out (vty, "%s", VTY_NEWLINE);
7107 }
7108
7109 /* Simple Authentication Password print. */
7110 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7111 params->auth_simple[0] != '\0')
7112 {
7113 vty_out (vty, " ip ospf authentication-key %s",
7114 params->auth_simple);
7115 if (params != IF_DEF_PARAMS (ifp))
7116 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7117 vty_out (vty, "%s", VTY_NEWLINE);
7118 }
7119
7120 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00007121 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00007122 {
paul718e3742002-12-13 20:15:29 +00007123 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7124 ck->key_id, ck->auth_key);
7125 if (params != IF_DEF_PARAMS (ifp))
7126 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7127 vty_out (vty, "%s", VTY_NEWLINE);
7128 }
7129
7130 /* Interface Output Cost print. */
7131 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7132 {
7133 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7134 if (params != IF_DEF_PARAMS (ifp))
7135 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7136 vty_out (vty, "%s", VTY_NEWLINE);
7137 }
7138
7139 /* Hello Interval print. */
7140 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7141 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7142 {
7143 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7144 if (params != IF_DEF_PARAMS (ifp))
7145 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7146 vty_out (vty, "%s", VTY_NEWLINE);
7147 }
7148
7149
7150 /* Router Dead Interval print. */
7151 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7152 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7153 {
paulf9ad9372005-10-21 00:45:17 +00007154 vty_out (vty, " ip ospf dead-interval ");
7155
7156 /* fast hello ? */
7157 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7158 vty_out (vty, "minimal hello-multiplier %d",
7159 params->fast_hello);
7160 else
7161 vty_out (vty, "%u", params->v_wait);
7162
paul718e3742002-12-13 20:15:29 +00007163 if (params != IF_DEF_PARAMS (ifp))
7164 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7165 vty_out (vty, "%s", VTY_NEWLINE);
7166 }
7167
7168 /* Router Priority print. */
7169 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7170 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7171 {
7172 vty_out (vty, " ip ospf priority %u", params->priority);
7173 if (params != IF_DEF_PARAMS (ifp))
7174 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7175 vty_out (vty, "%s", VTY_NEWLINE);
7176 }
7177
7178 /* Retransmit Interval print. */
7179 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7180 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7181 {
7182 vty_out (vty, " ip ospf retransmit-interval %u",
7183 params->retransmit_interval);
7184 if (params != IF_DEF_PARAMS (ifp))
7185 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7186 vty_out (vty, "%s", VTY_NEWLINE);
7187 }
7188
7189 /* Transmit Delay print. */
7190 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7191 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7192 {
7193 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7194 if (params != IF_DEF_PARAMS (ifp))
7195 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7196 vty_out (vty, "%s", VTY_NEWLINE);
7197 }
7198
vincentba682532005-09-29 13:52:57 +00007199 /* MTU ignore print. */
7200 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7201 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7202 {
7203 if (params->mtu_ignore == 0)
7204 vty_out (vty, " no ip ospf mtu-ignore");
7205 else
7206 vty_out (vty, " ip ospf mtu-ignore");
7207 if (params != IF_DEF_PARAMS (ifp))
7208 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7209 vty_out (vty, "%s", VTY_NEWLINE);
7210 }
7211
7212
paul718e3742002-12-13 20:15:29 +00007213 while (1)
7214 {
7215 if (rn == NULL)
7216 rn = route_top (IF_OIFS_PARAMS (ifp));
7217 else
7218 rn = route_next (rn);
7219
7220 if (rn == NULL)
7221 break;
7222 params = rn->info;
7223 if (params != NULL)
7224 break;
7225 }
7226 } while (rn);
7227
7228#ifdef HAVE_OPAQUE_LSA
7229 ospf_opaque_config_write_if (vty, ifp);
7230#endif /* HAVE_OPAQUE_LSA */
7231 }
7232
7233 return write;
7234}
7235
paul4dadc292005-05-06 21:37:42 +00007236static int
paul68980082003-03-25 05:07:42 +00007237config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007238{
7239 struct route_node *rn;
7240 u_char buf[INET_ADDRSTRLEN];
7241
7242 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007243 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007244 if (rn->info)
7245 {
7246 struct ospf_network *n = rn->info;
7247
7248 memset (buf, 0, INET_ADDRSTRLEN);
7249
7250 /* Create Area ID string by specified Area ID format. */
7251 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007252 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007253 else
hassoc9e52be2004-09-26 16:09:34 +00007254 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007255 (unsigned long int) ntohl (n->area_id.s_addr));
7256
7257 /* Network print. */
7258 vty_out (vty, " network %s/%d area %s%s",
7259 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7260 buf, VTY_NEWLINE);
7261 }
7262
7263 return 0;
7264}
7265
paul4dadc292005-05-06 21:37:42 +00007266static int
paul68980082003-03-25 05:07:42 +00007267config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007268{
hasso52dc7ee2004-09-23 19:18:23 +00007269 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007270 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007271 u_char buf[INET_ADDRSTRLEN];
7272
7273 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007274 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007275 {
paul718e3742002-12-13 20:15:29 +00007276 struct route_node *rn1;
7277
hassoc9e52be2004-09-26 16:09:34 +00007278 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007279
7280 if (area->auth_type != OSPF_AUTH_NULL)
7281 {
7282 if (area->auth_type == OSPF_AUTH_SIMPLE)
7283 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7284 else
7285 vty_out (vty, " area %s authentication message-digest%s",
7286 buf, VTY_NEWLINE);
7287 }
7288
7289 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7290 vty_out (vty, " area %s shortcut %s%s", buf,
7291 ospf_shortcut_mode_str[area->shortcut_configured],
7292 VTY_NEWLINE);
7293
7294 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007295 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007296 )
7297 {
paulb0a053b2003-06-22 09:04:47 +00007298 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007299 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007300 else if (area->external_routing == OSPF_AREA_NSSA)
7301 {
7302 vty_out (vty, " area %s nssa", buf);
7303 switch (area->NSSATranslatorRole)
7304 {
7305 case OSPF_NSSA_ROLE_NEVER:
7306 vty_out (vty, " translate-never");
7307 break;
7308 case OSPF_NSSA_ROLE_ALWAYS:
7309 vty_out (vty, " translate-always");
7310 break;
7311 case OSPF_NSSA_ROLE_CANDIDATE:
7312 default:
7313 vty_out (vty, " translate-candidate");
7314 }
7315 }
paul718e3742002-12-13 20:15:29 +00007316
7317 if (area->no_summary)
7318 vty_out (vty, " no-summary");
7319
7320 vty_out (vty, "%s", VTY_NEWLINE);
7321
7322 if (area->default_cost != 1)
7323 vty_out (vty, " area %s default-cost %d%s", buf,
7324 area->default_cost, VTY_NEWLINE);
7325 }
7326
7327 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7328 if (rn1->info)
7329 {
7330 struct ospf_area_range *range = rn1->info;
7331
7332 vty_out (vty, " area %s range %s/%d", buf,
7333 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7334
paul6c835672004-10-11 11:00:30 +00007335 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007336 vty_out (vty, " cost %d", range->cost_config);
7337
7338 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7339 vty_out (vty, " not-advertise");
7340
7341 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7342 vty_out (vty, " substitute %s/%d",
7343 inet_ntoa (range->subst_addr), range->subst_masklen);
7344
7345 vty_out (vty, "%s", VTY_NEWLINE);
7346 }
7347
7348 if (EXPORT_NAME (area))
7349 vty_out (vty, " area %s export-list %s%s", buf,
7350 EXPORT_NAME (area), VTY_NEWLINE);
7351
7352 if (IMPORT_NAME (area))
7353 vty_out (vty, " area %s import-list %s%s", buf,
7354 IMPORT_NAME (area), VTY_NEWLINE);
7355
7356 if (PREFIX_NAME_IN (area))
7357 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7358 PREFIX_NAME_IN (area), VTY_NEWLINE);
7359
7360 if (PREFIX_NAME_OUT (area))
7361 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7362 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7363 }
7364
7365 return 0;
7366}
7367
paul4dadc292005-05-06 21:37:42 +00007368static int
paul68980082003-03-25 05:07:42 +00007369config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007370{
7371 struct ospf_nbr_nbma *nbr_nbma;
7372 struct route_node *rn;
7373
7374 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007375 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007376 if ((nbr_nbma = rn->info))
7377 {
7378 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7379
7380 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7381 vty_out (vty, " priority %d", nbr_nbma->priority);
7382
7383 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7384 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7385
7386 vty_out (vty, "%s", VTY_NEWLINE);
7387 }
7388
7389 return 0;
7390}
7391
paul4dadc292005-05-06 21:37:42 +00007392static int
paul68980082003-03-25 05:07:42 +00007393config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007394{
hasso52dc7ee2004-09-23 19:18:23 +00007395 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007396 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007397 u_char buf[INET_ADDRSTRLEN];
7398
7399 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007400 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007401 {
hasso52dc7ee2004-09-23 19:18:23 +00007402 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007403 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007404 struct ospf_interface *oi;
7405
7406 if (vl_data != NULL)
7407 {
7408 memset (buf, 0, INET_ADDRSTRLEN);
7409
7410 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007411 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007412 else
hassoc9e52be2004-09-26 16:09:34 +00007413 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007414 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7415 oi = vl_data->vl_oi;
7416
7417 /* timers */
7418 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7419 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7420 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7421 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7422 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7423 buf,
7424 inet_ntoa (vl_data->vl_peer),
7425 OSPF_IF_PARAM (oi, v_hello),
7426 OSPF_IF_PARAM (oi, retransmit_interval),
7427 OSPF_IF_PARAM (oi, transmit_delay),
7428 OSPF_IF_PARAM (oi, v_wait),
7429 VTY_NEWLINE);
7430 else
7431 vty_out (vty, " area %s virtual-link %s%s", buf,
7432 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7433 /* Auth key */
7434 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7435 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7436 buf,
7437 inet_ntoa (vl_data->vl_peer),
7438 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7439 VTY_NEWLINE);
7440 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007441 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7442 n2, ck))
7443 vty_out (vty, " area %s virtual-link %s"
7444 " message-digest-key %d md5 %s%s",
7445 buf,
7446 inet_ntoa (vl_data->vl_peer),
7447 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007448
7449 }
7450 }
7451
7452 return 0;
7453}
7454
7455
paul4dadc292005-05-06 21:37:42 +00007456static int
paul68980082003-03-25 05:07:42 +00007457config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007458{
7459 int type;
7460
7461 /* redistribute print. */
7462 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7463 if (type != zclient->redist_default && zclient->redist[type])
7464 {
ajsf52d13c2005-10-01 17:38:06 +00007465 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007466 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007467 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007468
paul68980082003-03-25 05:07:42 +00007469 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007470 vty_out (vty, " metric-type 1");
7471
paul020709f2003-04-04 02:44:16 +00007472 if (ROUTEMAP_NAME (ospf, type))
7473 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007474
7475 vty_out (vty, "%s", VTY_NEWLINE);
7476 }
7477
7478 return 0;
7479}
7480
paul4dadc292005-05-06 21:37:42 +00007481static int
paul68980082003-03-25 05:07:42 +00007482config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007483{
paul68980082003-03-25 05:07:42 +00007484 if (ospf->default_metric != -1)
7485 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007486 VTY_NEWLINE);
7487 return 0;
7488}
7489
paul4dadc292005-05-06 21:37:42 +00007490static int
paul68980082003-03-25 05:07:42 +00007491config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007492{
7493 int type;
7494
paul68980082003-03-25 05:07:42 +00007495 if (ospf)
paul718e3742002-12-13 20:15:29 +00007496 {
7497 /* distribute-list print. */
7498 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007499 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007500 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007501 ospf->dlist[type].name,
ajsf52d13c2005-10-01 17:38:06 +00007502 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007503
7504 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007505 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007506 {
paul68980082003-03-25 05:07:42 +00007507 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007508 vty_out (vty, " default-information originate");
7509 else
7510 vty_out (vty, " default-information originate always");
7511
paul68980082003-03-25 05:07:42 +00007512 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007513 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007514 ospf->dmetric[DEFAULT_ROUTE].value);
7515 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007516 vty_out (vty, " metric-type 1");
7517
paul020709f2003-04-04 02:44:16 +00007518 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7519 vty_out (vty, " route-map %s",
7520 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007521
7522 vty_out (vty, "%s", VTY_NEWLINE);
7523 }
7524
7525 }
7526
7527 return 0;
7528}
7529
paul4dadc292005-05-06 21:37:42 +00007530static int
paul68980082003-03-25 05:07:42 +00007531config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007532{
7533 struct route_node *rn;
7534 struct ospf_distance *odistance;
7535
paul68980082003-03-25 05:07:42 +00007536 if (ospf->distance_all)
7537 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007538
paul68980082003-03-25 05:07:42 +00007539 if (ospf->distance_intra
7540 || ospf->distance_inter
7541 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007542 {
7543 vty_out (vty, " distance ospf");
7544
paul68980082003-03-25 05:07:42 +00007545 if (ospf->distance_intra)
7546 vty_out (vty, " intra-area %d", ospf->distance_intra);
7547 if (ospf->distance_inter)
7548 vty_out (vty, " inter-area %d", ospf->distance_inter);
7549 if (ospf->distance_external)
7550 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007551
7552 vty_out (vty, "%s", VTY_NEWLINE);
7553 }
7554
paul68980082003-03-25 05:07:42 +00007555 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007556 if ((odistance = rn->info) != NULL)
7557 {
7558 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7559 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7560 odistance->access_list ? odistance->access_list : "",
7561 VTY_NEWLINE);
7562 }
7563 return 0;
7564}
7565
7566/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007567static int
paul718e3742002-12-13 20:15:29 +00007568ospf_config_write (struct vty *vty)
7569{
paul020709f2003-04-04 02:44:16 +00007570 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007571 struct interface *ifp;
7572 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007573 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007574 int write = 0;
7575
paul020709f2003-04-04 02:44:16 +00007576 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007577 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007578 {
7579 /* `router ospf' print. */
7580 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7581
7582 write++;
7583
paul68980082003-03-25 05:07:42 +00007584 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007585 return write;
7586
7587 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007588 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007589 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007590 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007591
7592 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007593 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007594 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007595 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007596
7597 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007598 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007599 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7600
7601 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007602 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007603 {
7604 vty_out (vty, "! Important: ensure reference bandwidth "
7605 "is consistent across all routers%s", VTY_NEWLINE);
7606 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7607 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7608 }
paul718e3742002-12-13 20:15:29 +00007609
7610 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007611 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007612 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7613 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7614 vty_out (vty, " timers throttle spf %d %d %d%s",
7615 ospf->spf_delay, ospf->spf_holdtime,
7616 ospf->spf_max_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007617
7618 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007619 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007620 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007621 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007622
7623 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007624 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007625
7626 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007627 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7628 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7629 vty_out (vty, " passive-interface %s%s",
7630 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007631
paul1eb8ef22005-04-07 07:30:20 +00007632 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7633 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7634 oi->params->passive_interface == OSPF_IF_PASSIVE)
7635 vty_out (vty, " passive-interface %s %s%s",
7636 oi->ifp->name,
7637 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007638
7639 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007640 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007641
7642 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007643 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007644
7645 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007646 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007647
7648 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007649 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007650
7651 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007652 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007653
7654 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007655 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007656
7657 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007658 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007659
7660#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007661 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007662#endif /* HAVE_OPAQUE_LSA */
7663 }
7664
7665 return write;
7666}
7667
7668void
paul4dadc292005-05-06 21:37:42 +00007669ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007670{
7671 /* "show ip ospf" commands. */
7672 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7673 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7674
7675 /* "show ip ospf database" commands. */
7676 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7677 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7678 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7679 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7680 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7681 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7682 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7683 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7684 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7685 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7686 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7687 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7688 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7689 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7690
7691 /* "show ip ospf interface" commands. */
7692 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7693 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7694
7695 /* "show ip ospf neighbor" commands. */
7696 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7697 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7698 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7699 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7700 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7701 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7702 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7703 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7704 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7705 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7706 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7707 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7708 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7709 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7710
7711 /* "show ip ospf route" commands. */
7712 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7713 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007714 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7715 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007716}
7717
7718
7719/* ospfd's interface node. */
7720struct cmd_node interface_node =
7721{
7722 INTERFACE_NODE,
7723 "%s(config-if)# ",
7724 1
7725};
7726
7727/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007728static void
7729ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007730{
7731 /* Install interface node. */
7732 install_node (&interface_node, config_write_interface);
7733
7734 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007735 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007736 install_default (INTERFACE_NODE);
7737
7738 /* "description" commands. */
7739 install_element (INTERFACE_NODE, &interface_desc_cmd);
7740 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7741
7742 /* "ip ospf authentication" commands. */
7743 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7744 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7745 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7746 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7747 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7748 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7749 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7750 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7751 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7752 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7753
7754 /* "ip ospf message-digest-key" commands. */
7755 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7756 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7757 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7758 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7759
7760 /* "ip ospf cost" commands. */
7761 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7762 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7763 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7764 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7765
vincentba682532005-09-29 13:52:57 +00007766 /* "ip ospf mtu-ignore" commands. */
7767 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7768 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7769 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7770 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7771
paul718e3742002-12-13 20:15:29 +00007772 /* "ip ospf dead-interval" commands. */
7773 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7774 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007775 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7776 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007777 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7778 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007779
paul718e3742002-12-13 20:15:29 +00007780 /* "ip ospf hello-interval" commands. */
7781 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7782 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7783 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7784 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7785
7786 /* "ip ospf network" commands. */
7787 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7788 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7789
7790 /* "ip ospf priority" commands. */
7791 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7792 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7793 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7794 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7795
7796 /* "ip ospf retransmit-interval" commands. */
7797 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7798 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7799 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7800 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7801
7802 /* "ip ospf transmit-delay" commands. */
7803 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7804 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7805 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7806 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7807
7808 /* These commands are compatibitliy for previous version. */
7809 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7810 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7811 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7812 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7813 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7814 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7815 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7816 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7817 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7818 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7819 install_element (INTERFACE_NODE, &ospf_network_cmd);
7820 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7821 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7822 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7823 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7824 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7825 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7826 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7827}
7828
7829/* Zebra node structure. */
7830struct cmd_node zebra_node =
7831{
7832 ZEBRA_NODE,
7833 "%s(config-router)#",
7834};
7835
paul4dadc292005-05-06 21:37:42 +00007836static void
7837ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00007838{
7839 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7840 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7841 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7842 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7843 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7844 install_element (OSPF_NODE,
7845 &ospf_redistribute_source_metric_type_routemap_cmd);
7846 install_element (OSPF_NODE,
7847 &ospf_redistribute_source_type_metric_routemap_cmd);
7848 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7849 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7850 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7851
7852 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7853
7854 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7855 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7856
7857 install_element (OSPF_NODE,
7858 &ospf_default_information_originate_metric_type_cmd);
7859 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7860 install_element (OSPF_NODE,
7861 &ospf_default_information_originate_type_metric_cmd);
7862 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7863 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7864 install_element (OSPF_NODE,
7865 &ospf_default_information_originate_always_metric_type_cmd);
7866 install_element (OSPF_NODE,
7867 &ospf_default_information_originate_always_metric_cmd);
7868 install_element (OSPF_NODE,
7869 &ospf_default_information_originate_always_cmd);
7870 install_element (OSPF_NODE,
7871 &ospf_default_information_originate_always_type_metric_cmd);
7872 install_element (OSPF_NODE,
7873 &ospf_default_information_originate_always_type_cmd);
7874
7875 install_element (OSPF_NODE,
7876 &ospf_default_information_originate_metric_type_routemap_cmd);
7877 install_element (OSPF_NODE,
7878 &ospf_default_information_originate_metric_routemap_cmd);
7879 install_element (OSPF_NODE,
7880 &ospf_default_information_originate_routemap_cmd);
7881 install_element (OSPF_NODE,
7882 &ospf_default_information_originate_type_metric_routemap_cmd);
7883 install_element (OSPF_NODE,
7884 &ospf_default_information_originate_type_routemap_cmd);
7885 install_element (OSPF_NODE,
7886 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7887 install_element (OSPF_NODE,
7888 &ospf_default_information_originate_always_metric_routemap_cmd);
7889 install_element (OSPF_NODE,
7890 &ospf_default_information_originate_always_routemap_cmd);
7891 install_element (OSPF_NODE,
7892 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7893 install_element (OSPF_NODE,
7894 &ospf_default_information_originate_always_type_routemap_cmd);
7895
7896 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7897
7898 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7899 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7900 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7901
7902 install_element (OSPF_NODE, &ospf_distance_cmd);
7903 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7904 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7905 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7906 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7907 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7908 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7909 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7910 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7911 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7912 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7913 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7914 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7915 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7916 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7917 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7918 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7919 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7920#if 0
7921 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7922 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7923 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7924 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7925#endif /* 0 */
7926}
7927
7928struct cmd_node ospf_node =
7929{
7930 OSPF_NODE,
7931 "%s(config-router)# ",
7932 1
7933};
7934
7935
7936/* Install OSPF related vty commands. */
7937void
paul4dadc292005-05-06 21:37:42 +00007938ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00007939{
7940 /* Install ospf top node. */
7941 install_node (&ospf_node, ospf_config_write);
7942
7943 /* "router ospf" commands. */
7944 install_element (CONFIG_NODE, &router_ospf_cmd);
7945 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7946
7947 install_default (OSPF_NODE);
7948
7949 /* "ospf router-id" commands. */
7950 install_element (OSPF_NODE, &ospf_router_id_cmd);
7951 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007952 install_element (OSPF_NODE, &router_ospf_id_cmd);
7953 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007954
7955 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007956 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7957 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7958 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7959 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007960
7961 /* "ospf abr-type" commands. */
7962 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7963 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7964
7965 /* "ospf rfc1583-compatible" commands. */
7966 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7967 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7968 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7969 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7970
7971 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007972 install_element (OSPF_NODE, &ospf_network_area_cmd);
7973 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007974
7975 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007976 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7977 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7978 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007979
7980 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007981 install_element (OSPF_NODE, &ospf_area_range_cmd);
7982 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7983 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7984 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7985 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7986 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7987 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7988 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7989 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7990 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7991 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007992
7993 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007994 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7995 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007996
paula2c62832003-04-23 17:01:31 +00007997 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7998 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007999
paula2c62832003-04-23 17:01:31 +00008000 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8001 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00008002
paula2c62832003-04-23 17:01:31 +00008003 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8004 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00008005
paula2c62832003-04-23 17:01:31 +00008006 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8007 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00008008
paula2c62832003-04-23 17:01:31 +00008009 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8010 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8011 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00008012
paula2c62832003-04-23 17:01:31 +00008013 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8014 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008015
paula2c62832003-04-23 17:01:31 +00008016 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8017 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008018
paula2c62832003-04-23 17:01:31 +00008019 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8020 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8021 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00008022
paula2c62832003-04-23 17:01:31 +00008023 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8024 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8025 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00008026
8027 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00008028 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8029 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8030 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8031 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00008032
paul718e3742002-12-13 20:15:29 +00008033 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00008034 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8035 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8036 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8037 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8038 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8039 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00008040
paula2c62832003-04-23 17:01:31 +00008041 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8042 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00008043
paula2c62832003-04-23 17:01:31 +00008044 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8045 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00008046
paula2c62832003-04-23 17:01:31 +00008047 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8048 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00008049
paula2c62832003-04-23 17:01:31 +00008050 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8051 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00008052
paula2c62832003-04-23 17:01:31 +00008053 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8054 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00008055
paula2c62832003-04-23 17:01:31 +00008056 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8057 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00008058 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8059 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8060
paula2c62832003-04-23 17:01:31 +00008061 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8062 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8063 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00008064
paula2c62832003-04-23 17:01:31 +00008065 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8066 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00008067
8068 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00008069 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8070 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8071 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8072 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8073 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8074 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8075 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8076 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00008077
8078 /* Init interface related vty commands. */
8079 ospf_vty_if_init ();
8080
8081 /* Init zebra related vty commands. */
8082 ospf_vty_zebra_init ();
8083}