blob: 461574ae8f8e3ab21c5d25908d4cd6ea2acd9067 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* OSPF VTY interface.
2 * Copyright (C) 2000 Toshiaki Takada
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22#include <zebra.h>
23
24#include "memory.h"
25#include "thread.h"
26#include "prefix.h"
27#include "table.h"
28#include "vty.h"
29#include "command.h"
30#include "plist.h"
31#include "log.h"
32#include "zclient.h"
33
34#include "ospfd/ospfd.h"
35#include "ospfd/ospf_asbr.h"
36#include "ospfd/ospf_lsa.h"
37#include "ospfd/ospf_lsdb.h"
38#include "ospfd/ospf_ism.h"
39#include "ospfd/ospf_interface.h"
40#include "ospfd/ospf_nsm.h"
41#include "ospfd/ospf_neighbor.h"
42#include "ospfd/ospf_flood.h"
43#include "ospfd/ospf_abr.h"
44#include "ospfd/ospf_spf.h"
45#include "ospfd/ospf_route.h"
46#include "ospfd/ospf_zebra.h"
47/*#include "ospfd/ospf_routemap.h" */
48#include "ospfd/ospf_vty.h"
49#include "ospfd/ospf_dump.h"
50
51
52static char *ospf_network_type_str[] =
53{
54 "Null",
55 "POINTOPOINT",
56 "BROADCAST",
57 "NBMA",
58 "POINTOMULTIPOINT",
59 "VIRTUALLINK",
60 "LOOPBACK"
61};
62
63
64/* Utility functions. */
65int
66ospf_str2area_id (char *str, struct in_addr *area_id, int *format)
67{
68 char *endptr = NULL;
69 unsigned long ret;
70
71 /* match "A.B.C.D". */
72 if (strchr (str, '.') != NULL)
73 {
74 ret = inet_aton (str, area_id);
75 if (!ret)
76 return -1;
77 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
78 }
79 /* match "<0-4294967295>". */
80 else
81 {
82 ret = strtoul (str, &endptr, 10);
83 if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE))
84 return -1;
85
86 area_id->s_addr = htonl (ret);
87 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
88 }
89
90 return 0;
91}
92
93
94int
95str2distribute_source (char *str, int *source)
96{
97 /* Sanity check. */
98 if (str == NULL)
99 return 0;
100
101 if (strncmp (str, "k", 1) == 0)
102 *source = ZEBRA_ROUTE_KERNEL;
103 else if (strncmp (str, "c", 1) == 0)
104 *source = ZEBRA_ROUTE_CONNECT;
105 else if (strncmp (str, "s", 1) == 0)
106 *source = ZEBRA_ROUTE_STATIC;
107 else if (strncmp (str, "r", 1) == 0)
108 *source = ZEBRA_ROUTE_RIP;
109 else if (strncmp (str, "b", 1) == 0)
110 *source = ZEBRA_ROUTE_BGP;
111 else
112 return 0;
113
114 return 1;
115}
116
117int
118str2metric (char *str, int *metric)
119{
120 /* Sanity check. */
121 if (str == NULL)
122 return 0;
123
124 *metric = strtol (str, NULL, 10);
125 if (*metric < 0 && *metric > 16777214)
126 {
127 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
128 return 0;
129 }
130
131 return 1;
132}
133
134int
135str2metric_type (char *str, int *metric_type)
136{
137 /* Sanity check. */
138 if (str == NULL)
139 return 0;
140
141 if (strncmp (str, "1", 1) == 0)
142 *metric_type = EXTERNAL_METRIC_TYPE_1;
143 else if (strncmp (str, "2", 1) == 0)
144 *metric_type = EXTERNAL_METRIC_TYPE_2;
145 else
146 return 0;
147
148 return 1;
149}
150
151int
152ospf_oi_count (struct interface *ifp)
153{
154 struct route_node *rn;
155 int i = 0;
156
157 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
158 if (rn->info)
159 i++;
160
161 return i;
162}
163
164
165DEFUN (router_ospf,
166 router_ospf_cmd,
167 "router ospf",
168 "Enable a routing process\n"
169 "Start OSPF configuration\n")
170{
171 vty->node = OSPF_NODE;
172 vty->index = ospf_get ();
173
174 return CMD_SUCCESS;
175}
176
177DEFUN (no_router_ospf,
178 no_router_ospf_cmd,
179 "no router ospf",
180 NO_STR
181 "Enable a routing process\n"
182 "Start OSPF configuration\n")
183{
paul020709f2003-04-04 02:44:16 +0000184 struct ospf *ospf;
185
186 ospf = ospf_lookup ();
187 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000188 {
paul020709f2003-04-04 02:44:16 +0000189 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000190 return CMD_WARNING;
191 }
192
paul020709f2003-04-04 02:44:16 +0000193 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000194
195 return CMD_SUCCESS;
196}
197
198DEFUN (ospf_router_id,
199 ospf_router_id_cmd,
200 "ospf router-id A.B.C.D",
201 "OSPF specific commands\n"
202 "router-id for the OSPF process\n"
203 "OSPF router-id in IP address format\n")
204{
paul68980082003-03-25 05:07:42 +0000205 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000206 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000207 int ret;
paul718e3742002-12-13 20:15:29 +0000208
209 ret = inet_aton (argv[0], &router_id);
210 if (!ret)
211 {
212 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
213 return CMD_WARNING;
214 }
215
paul68980082003-03-25 05:07:42 +0000216 ospf->router_id_static = router_id;
paul718e3742002-12-13 20:15:29 +0000217
paul68980082003-03-25 05:07:42 +0000218 if (ospf->t_router_id_update == NULL)
paul020709f2003-04-04 02:44:16 +0000219 OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer,
220 OSPF_ROUTER_ID_UPDATE_DELAY);
paul718e3742002-12-13 20:15:29 +0000221
222 return CMD_SUCCESS;
223}
224
225ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000226 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000227 "router-id A.B.C.D",
228 "router-id for the OSPF process\n"
229 "OSPF router-id in IP address format\n")
230
231DEFUN (no_ospf_router_id,
232 no_ospf_router_id_cmd,
233 "no ospf router-id",
234 NO_STR
235 "OSPF specific commands\n"
236 "router-id for the OSPF process\n")
237{
paul68980082003-03-25 05:07:42 +0000238 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000239
paul68980082003-03-25 05:07:42 +0000240 ospf->router_id_static.s_addr = 0;
241
242 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000243
244 return CMD_SUCCESS;
245}
246
247ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000248 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000249 "no router-id",
250 NO_STR
251 "router-id for the OSPF process\n")
252
paula2c62832003-04-23 17:01:31 +0000253DEFUN (ospf_passive_interface,
254 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000255 "passive-interface IFNAME A.B.C.D",
256 "Suppress routing updates on an interface\n"
257 "Interface's name\n")
258{
259 struct interface *ifp;
260 struct in_addr addr;
261 int ret;
262 struct ospf_if_params *params;
263
264 ifp = if_lookup_by_name (argv[0]);
265
266 if (ifp == NULL)
267 {
268 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
269 return CMD_WARNING;
270 }
271
272 params = IF_DEF_PARAMS (ifp);
273
274 if (argc == 2)
275 {
276 ret = inet_aton(argv[1], &addr);
277 if (!ret)
278 {
279 vty_out (vty, "Please specify interface address by A.B.C.D%s",
280 VTY_NEWLINE);
281 return CMD_WARNING;
282 }
283
284 params = ospf_get_if_params (ifp, addr);
285 ospf_if_update_params (ifp, addr);
286 }
287
288 SET_IF_PARAM (params, passive_interface);
289 params->passive_interface = OSPF_IF_PASSIVE;
290
291 return CMD_SUCCESS;
292}
293
paula2c62832003-04-23 17:01:31 +0000294ALIAS (ospf_passive_interface,
295 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000296 "passive-interface IFNAME",
297 "Suppress routing updates on an interface\n"
298 "Interface's name\n")
299
paula2c62832003-04-23 17:01:31 +0000300DEFUN (no_ospf_passive_interface,
301 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000302 "no passive-interface IFNAME A.B.C.D",
303 NO_STR
304 "Allow routing updates on an interface\n"
305 "Interface's name\n")
306{
307 struct interface *ifp;
308 struct in_addr addr;
309 struct ospf_if_params *params;
310 int ret;
311
312 ifp = if_lookup_by_name (argv[0]);
313
314 if (ifp == NULL)
315 {
316 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
317 return CMD_WARNING;
318 }
319
320 params = IF_DEF_PARAMS (ifp);
321
322 if (argc == 2)
323 {
324 ret = inet_aton(argv[1], &addr);
325 if (!ret)
326 {
327 vty_out (vty, "Please specify interface address by A.B.C.D%s",
328 VTY_NEWLINE);
329 return CMD_WARNING;
330 }
331
332 params = ospf_lookup_if_params (ifp, addr);
333 if (params == NULL)
334 return CMD_SUCCESS;
335 }
336
337 UNSET_IF_PARAM (params, passive_interface);
338 params->passive_interface = OSPF_IF_ACTIVE;
339
340 if (params != IF_DEF_PARAMS (ifp))
341 {
342 ospf_free_if_params (ifp, addr);
343 ospf_if_update_params (ifp, addr);
344 }
345
346 return CMD_SUCCESS;
347}
348
paula2c62832003-04-23 17:01:31 +0000349ALIAS (no_ospf_passive_interface,
350 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000351 "no passive-interface IFNAME",
352 NO_STR
353 "Allow routing updates on an interface\n"
354 "Interface's name\n")
355
paula2c62832003-04-23 17:01:31 +0000356DEFUN (ospf_network_area,
357 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000358 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
359 "Enable routing on an IP network\n"
360 "OSPF network prefix\n"
361 "Set the OSPF area ID\n"
362 "OSPF area ID in IP address format\n"
363 "OSPF area ID as a decimal value\n")
364{
365 struct ospf *ospf= vty->index;
366 struct prefix_ipv4 p;
367 struct in_addr area_id;
368 int ret, format;
369
370 /* Get network prefix and Area ID. */
371 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
372 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
373
374 ret = ospf_network_set (ospf, &p, area_id);
375 if (ret == 0)
376 {
377 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
378 return CMD_WARNING;
379 }
380
381 return CMD_SUCCESS;
382}
383
paula2c62832003-04-23 17:01:31 +0000384DEFUN (no_ospf_network_area,
385 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000386 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
387 NO_STR
388 "Enable routing on an IP network\n"
389 "OSPF network prefix\n"
390 "Set the OSPF area ID\n"
391 "OSPF area ID in IP address format\n"
392 "OSPF area ID as a decimal value\n")
393{
394 struct ospf *ospf = (struct ospf *) vty->index;
395 struct prefix_ipv4 p;
396 struct in_addr area_id;
397 int ret, format;
398
399 /* Get network prefix and Area ID. */
400 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
401 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
402
403 ret = ospf_network_unset (ospf, &p, area_id);
404 if (ret == 0)
405 {
406 vty_out (vty, "Can't find specified network area configuration.%s",
407 VTY_NEWLINE);
408 return CMD_WARNING;
409 }
410
411 return CMD_SUCCESS;
412}
413
414
paula2c62832003-04-23 17:01:31 +0000415DEFUN (ospf_area_range,
416 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000417 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
418 "OSPF area parameters\n"
419 "OSPF area ID in IP address format\n"
420 "OSPF area ID as a decimal value\n"
421 "Summarize routes matching address/mask (border routers only)\n"
422 "Area range prefix\n")
423{
424 struct ospf *ospf = vty->index;
425 struct prefix_ipv4 p;
426 struct in_addr area_id;
427 int format;
428 u_int32_t cost;
429
430 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
431 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
432
433 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
434 if (argc > 2)
435 {
436 VTY_GET_UINT32 ("range cost", cost, argv[2]);
437 ospf_area_range_cost_set (ospf, area_id, &p, cost);
438 }
439
440 return CMD_SUCCESS;
441}
442
paula2c62832003-04-23 17:01:31 +0000443ALIAS (ospf_area_range,
444 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000445 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
446 "OSPF area parameters\n"
447 "OSPF area ID in IP address format\n"
448 "OSPF area ID as a decimal value\n"
449 "OSPF area range for route advertise (default)\n"
450 "Area range prefix\n"
451 "Advertise this range (default)\n")
452
paula2c62832003-04-23 17:01:31 +0000453ALIAS (ospf_area_range,
454 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000455 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
456 "OSPF area parameters\n"
457 "OSPF area ID in IP address format\n"
458 "OSPF area ID as a decimal value\n"
459 "Summarize routes matching address/mask (border routers only)\n"
460 "Area range prefix\n"
461 "User specified metric for this range\n"
462 "Advertised metric for this range\n")
463
paula2c62832003-04-23 17:01:31 +0000464ALIAS (ospf_area_range,
465 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000466 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
467 "OSPF area parameters\n"
468 "OSPF area ID in IP address format\n"
469 "OSPF area ID as a decimal value\n"
470 "Summarize routes matching address/mask (border routers only)\n"
471 "Area range prefix\n"
472 "Advertise this range (default)\n"
473 "User specified metric for this range\n"
474 "Advertised metric for this range\n")
475
paula2c62832003-04-23 17:01:31 +0000476DEFUN (ospf_area_range_not_advertise,
477 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000478 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
479 "OSPF area parameters\n"
480 "OSPF area ID in IP address format\n"
481 "OSPF area ID as a decimal value\n"
482 "Summarize routes matching address/mask (border routers only)\n"
483 "Area range prefix\n"
484 "DoNotAdvertise this range\n")
485{
486 struct ospf *ospf = vty->index;
487 struct prefix_ipv4 p;
488 struct in_addr area_id;
489 int format;
490
491 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
492 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
493
494 ospf_area_range_set (ospf, area_id, &p, 0);
495
496 return CMD_SUCCESS;
497}
498
paula2c62832003-04-23 17:01:31 +0000499DEFUN (no_ospf_area_range,
500 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000501 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
502 NO_STR
503 "OSPF area parameters\n"
504 "OSPF area ID in IP address format\n"
505 "OSPF area ID as a decimal value\n"
506 "Summarize routes matching address/mask (border routers only)\n"
507 "Area range prefix\n")
508{
509 struct ospf *ospf = vty->index;
510 struct prefix_ipv4 p;
511 struct in_addr area_id;
512 int format;
513
514 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
515 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
516
517 ospf_area_range_unset (ospf, area_id, &p);
518
519 return CMD_SUCCESS;
520}
521
paula2c62832003-04-23 17:01:31 +0000522ALIAS (no_ospf_area_range,
523 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000524 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
525 NO_STR
526 "OSPF area parameters\n"
527 "OSPF area ID in IP address format\n"
528 "OSPF area ID as a decimal value\n"
529 "Summarize routes matching address/mask (border routers only)\n"
530 "Area range prefix\n"
531 "Advertise this range (default)\n"
532 "DoNotAdvertise this range\n")
533
paula2c62832003-04-23 17:01:31 +0000534ALIAS (no_ospf_area_range,
535 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000536 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
537 NO_STR
538 "OSPF area parameters\n"
539 "OSPF area ID in IP address format\n"
540 "OSPF area ID as a decimal value\n"
541 "Summarize routes matching address/mask (border routers only)\n"
542 "Area range prefix\n"
543 "User specified metric for this range\n"
544 "Advertised metric for this range\n")
545
paula2c62832003-04-23 17:01:31 +0000546ALIAS (no_ospf_area_range,
547 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000548 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
549 NO_STR
550 "OSPF area parameters\n"
551 "OSPF area ID in IP address format\n"
552 "OSPF area ID as a decimal value\n"
553 "Summarize routes matching address/mask (border routers only)\n"
554 "Area range prefix\n"
555 "Advertise this range (default)\n"
556 "User specified metric for this range\n"
557 "Advertised metric for this range\n")
558
paula2c62832003-04-23 17:01:31 +0000559DEFUN (ospf_area_range_substitute,
560 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000561 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
562 "OSPF area parameters\n"
563 "OSPF area ID in IP address format\n"
564 "OSPF area ID as a decimal value\n"
565 "Summarize routes matching address/mask (border routers only)\n"
566 "Area range prefix\n"
567 "Announce area range as another prefix\n"
568 "Network prefix to be announced instead of range\n")
569{
570 struct ospf *ospf = vty->index;
571 struct prefix_ipv4 p, s;
572 struct in_addr area_id;
573 int format;
574
575 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
576 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
577 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
578
579 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
580
581 return CMD_SUCCESS;
582}
583
paula2c62832003-04-23 17:01:31 +0000584DEFUN (no_ospf_area_range_substitute,
585 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000586 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
587 NO_STR
588 "OSPF area parameters\n"
589 "OSPF area ID in IP address format\n"
590 "OSPF area ID as a decimal value\n"
591 "Summarize routes matching address/mask (border routers only)\n"
592 "Area range prefix\n"
593 "Announce area range as another prefix\n"
594 "Network prefix to be announced instead of range\n")
595{
596 struct ospf *ospf = vty->index;
597 struct prefix_ipv4 p, s;
598 struct in_addr area_id;
599 int format;
600
601 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
602 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
603 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
604
605 ospf_area_range_substitute_unset (ospf, area_id, &p);
606
607 return CMD_SUCCESS;
608}
609
610
611/* Command Handler Logic in VLink stuff is delicate!!
612
613 ALTER AT YOUR OWN RISK!!!!
614
615 Various dummy values are used to represent 'NoChange' state for
616 VLink configuration NOT being changed by a VLink command, and
617 special syntax is used within the command strings so that the
618 typed in command verbs can be seen in the configuration command
619 bacckend handler. This is to drastically reduce the verbeage
620 required to coe up with a reasonably compatible Cisco VLink command
621
622 - Matthew Grant <grantma@anathoth.gen.nz>
623 Wed, 21 Feb 2001 15:13:52 +1300
624 */
625
626
627/* Configuration data for virtual links
628 */
629struct ospf_vl_config_data {
630 struct vty *vty; /* vty stuff */
631 struct in_addr area_id; /* area ID from command line */
632 int format; /* command line area ID format */
633 struct in_addr vl_peer; /* command line vl_peer */
634 int auth_type; /* Authehntication type, if given */
635 char *auth_key; /* simple password if present */
636 int crypto_key_id; /* Cryptographic key ID */
637 char *md5_key; /* MD5 authentication key */
638 int hello_interval; /* Obvious what these are... */
639 int retransmit_interval;
640 int transmit_delay;
641 int dead_interval;
642};
643
644void
645ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
646 struct vty *vty)
647{
648 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
649 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
650 vl_config->vty = vty;
651}
652
653struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000654ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000655{
656 struct ospf_area *area;
657 struct ospf_vl_data *vl_data;
658 struct vty *vty;
659 struct in_addr area_id;
660
661 vty = vl_config->vty;
662 area_id = vl_config->area_id;
663
664 if (area_id.s_addr == OSPF_AREA_BACKBONE)
665 {
666 vty_out (vty,
667 "Configuring VLs over the backbone is not allowed%s",
668 VTY_NEWLINE);
669 return NULL;
670 }
paul68980082003-03-25 05:07:42 +0000671 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000672
673 if (area->external_routing != OSPF_AREA_DEFAULT)
674 {
675 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
676 vty_out (vty, "Area %s is %s%s",
677 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000678 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000679 VTY_NEWLINE);
680 else
681 vty_out (vty, "Area %ld is %s%s",
682 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000683 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000684 VTY_NEWLINE);
685 return NULL;
686 }
687
688 if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)
689 {
690 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
691 if (vl_data->vl_oi == NULL)
692 {
paul68980082003-03-25 05:07:42 +0000693 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
694 ospf_vl_add (ospf, vl_data);
695 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000696 }
697 }
698 return vl_data;
699}
700
701
702int
703ospf_vl_set_security (struct ospf_vl_data *vl_data,
704 struct ospf_vl_config_data *vl_config)
705{
706 struct crypt_key *ck;
707 struct vty *vty;
708 struct interface *ifp = vl_data->vl_oi->ifp;
709
710 vty = vl_config->vty;
711
712 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
713 {
714 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
715 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
716 }
717
718 if (vl_config->auth_key)
719 {
720 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
721 strncpy (IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
722 OSPF_AUTH_SIMPLE_SIZE);
723 }
724 else if (vl_config->md5_key)
725 {
726 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
727 != NULL)
728 {
729 vty_out (vty, "OSPF: Key %d already exists%s",
730 vl_config->crypto_key_id, VTY_NEWLINE);
731 return CMD_WARNING;
732 }
733 ck = ospf_crypt_key_new ();
734 ck->key_id = vl_config->crypto_key_id;
735 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
736 strncpy (ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
737
738 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
739 }
740 else if (vl_config->crypto_key_id != 0)
741 {
742 /* Delete a key */
743
744 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
745 vl_config->crypto_key_id) == NULL)
746 {
747 vty_out (vty, "OSPF: Key %d does not exist%s",
748 vl_config->crypto_key_id, VTY_NEWLINE);
749 return CMD_WARNING;
750 }
751
752 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
753
754 }
755
756 return CMD_SUCCESS;
757}
758
759
760
761int
762ospf_vl_set_timers (struct ospf_vl_data *vl_data,
763 struct ospf_vl_config_data *vl_config)
764{
765 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
766 /* Virtual Link data initialised to defaults, so only set
767 if a value given */
768 if (vl_config->hello_interval)
769 {
770 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
771 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
772 }
773
774 if (vl_config->dead_interval)
775 {
776 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
777 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
778 }
779
780 if (vl_config->retransmit_interval)
781 {
782 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
783 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
784 }
785
786 if (vl_config->transmit_delay)
787 {
788 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
789 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
790 }
791
792 return CMD_SUCCESS;
793}
794
795
796
797/* The business end of all of the above */
798int
paul68980082003-03-25 05:07:42 +0000799ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000800{
801 struct ospf_vl_data *vl_data;
802 int ret;
803
paul68980082003-03-25 05:07:42 +0000804 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000805 if (!vl_data)
806 return CMD_WARNING;
807
808 /* Process this one first as it can have a fatal result, which can
809 only logically occur if the virtual link exists already
810 Thus a command error does not result in a change to the
811 running configuration such as unexpectedly altered timer
812 values etc.*/
813 ret = ospf_vl_set_security (vl_data, vl_config);
814 if (ret != CMD_SUCCESS)
815 return ret;
816
817 /* Set any time based parameters, these area already range checked */
818
819 ret = ospf_vl_set_timers (vl_data, vl_config);
820 if (ret != CMD_SUCCESS)
821 return ret;
822
823 return CMD_SUCCESS;
824
825}
826
827/* This stuff exists to make specifying all the alias commands A LOT simpler
828 */
829#define VLINK_HELPSTR_IPADDR \
830 "OSPF area parameters\n" \
831 "OSPF area ID in IP address format\n" \
832 "OSPF area ID as a decimal value\n" \
833 "Configure a virtual link\n" \
834 "Router ID of the remote ABR\n"
835
836#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
837 "Enable authentication on this virtual link\n" \
838 "dummy string \n"
839
840#define VLINK_HELPSTR_AUTHTYPE_ALL \
841 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
842 "Use null authentication\n" \
843 "Use message-digest authentication\n"
844
845#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
846 "Time between HELLO packets\n" \
847 "Time between retransmitting lost link state advertisements\n" \
848 "Link state transmit delay\n" \
849 "Interval after which a neighbor is declared dead\n"
850
851#define VLINK_HELPSTR_TIME_PARAM \
852 VLINK_HELPSTR_TIME_PARAM_NOSECS \
853 "Seconds\n"
854
855#define VLINK_HELPSTR_AUTH_SIMPLE \
856 "Authentication password (key)\n" \
857 "The OSPF password (key)"
858
859#define VLINK_HELPSTR_AUTH_MD5 \
860 "Message digest authentication password (key)\n" \
861 "dummy string \n" \
862 "Key ID\n" \
863 "Use MD5 algorithm\n" \
864 "The OSPF password (key)"
865
paula2c62832003-04-23 17:01:31 +0000866DEFUN (ospf_area_vlink,
867 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000868 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
869 VLINK_HELPSTR_IPADDR)
870{
paul68980082003-03-25 05:07:42 +0000871 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000872 struct ospf_vl_config_data vl_config;
873 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
874 char md5_key[OSPF_AUTH_MD5_SIZE+1];
875 int i;
876 int ret;
877
878 ospf_vl_config_data_init(&vl_config, vty);
879
880 /* Read off first 2 parameters and check them */
881 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
882 if (ret < 0)
883 {
884 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
885 return CMD_WARNING;
886 }
887
888 ret = inet_aton (argv[1], &vl_config.vl_peer);
889 if (! ret)
890 {
891 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
892 VTY_NEWLINE);
893 return CMD_WARNING;
894 }
895
896 if (argc <=2)
897 {
898 /* Thats all folks! - BUGS B. strikes again!!!*/
899
paul68980082003-03-25 05:07:42 +0000900 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000901 }
902
903 /* Deal with other parameters */
904 for (i=2; i < argc; i++)
905 {
906
907 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
908
909 switch (argv[i][0])
910 {
911
912 case 'a':
913 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
914 {
915 /* authentication-key - this option can occur anywhere on
916 command line. At start of command line
917 must check for authentication option. */
918 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
919 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
920 vl_config.auth_key = auth_key;
921 i++;
922 }
923 else if (strncmp (argv[i], "authentication", 14) == 0)
924 {
925 /* authentication - this option can only occur at start
926 of command line */
927 vl_config.auth_type = OSPF_AUTH_SIMPLE;
928 if ((i+1) < argc)
929 {
930 if (strncmp (argv[i+1], "n", 1) == 0)
931 {
932 /* "authentication null" */
933 vl_config.auth_type = OSPF_AUTH_NULL;
934 i++;
935 }
936 else if (strncmp (argv[i+1], "m", 1) == 0
937 && strcmp (argv[i+1], "message-digest-") != 0)
938 {
939 /* "authentication message-digest" */
940 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
941 i++;
942 }
943 }
944 }
945 break;
946
947 case 'm':
948 /* message-digest-key */
949 i++;
950 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
951 if (vl_config.crypto_key_id < 0)
952 return CMD_WARNING;
953 i++;
954 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
955 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
956 vl_config.md5_key = md5_key;
957 break;
958
959 case 'h':
960 /* Hello interval */
961 i++;
962 vl_config.hello_interval = strtol (argv[i], NULL, 10);
963 if (vl_config.hello_interval < 0)
964 return CMD_WARNING;
965 break;
966
967 case 'r':
968 /* Retransmit Interval */
969 i++;
970 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
971 if (vl_config.retransmit_interval < 0)
972 return CMD_WARNING;
973 break;
974
975 case 't':
976 /* Transmit Delay */
977 i++;
978 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
979 if (vl_config.transmit_delay < 0)
980 return CMD_WARNING;
981 break;
982
983 case 'd':
984 /* Dead Interval */
985 i++;
986 vl_config.dead_interval = strtol (argv[i], NULL, 10);
987 if (vl_config.dead_interval < 0)
988 return CMD_WARNING;
989 break;
990 }
991 }
992
993
994 /* Action configuration */
995
paul68980082003-03-25 05:07:42 +0000996 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000997
998}
999
paula2c62832003-04-23 17:01:31 +00001000DEFUN (no_ospf_area_vlink,
1001 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001002 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1003 NO_STR
1004 VLINK_HELPSTR_IPADDR)
1005{
paul68980082003-03-25 05:07:42 +00001006 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001007 struct ospf_area *area;
1008 struct ospf_vl_config_data vl_config;
1009 struct ospf_vl_data *vl_data = NULL;
1010 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1011 int i;
1012 int ret, format;
1013
1014 ospf_vl_config_data_init(&vl_config, vty);
1015
1016 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1017 if (ret < 0)
1018 {
1019 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1020 return CMD_WARNING;
1021 }
1022
paul68980082003-03-25 05:07:42 +00001023 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001024 if (!area)
1025 {
1026 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1027 return CMD_WARNING;
1028 }
1029
1030 ret = inet_aton (argv[1], &vl_config.vl_peer);
1031 if (! ret)
1032 {
1033 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1034 VTY_NEWLINE);
1035 return CMD_WARNING;
1036 }
1037
1038 if (argc <=2)
1039 {
1040 /* Basic VLink no command */
1041 /* Thats all folks! - BUGS B. strikes again!!!*/
1042 if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001043 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001044
paul68980082003-03-25 05:07:42 +00001045 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001046
1047 return CMD_SUCCESS;
1048 }
1049
1050 /* If we are down here, we are reseting parameters */
1051
1052 /* Deal with other parameters */
1053 for (i=2; i < argc; i++)
1054 {
paul718e3742002-12-13 20:15:29 +00001055 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1056
1057 switch (argv[i][0])
1058 {
1059
1060 case 'a':
1061 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1062 {
1063 /* authentication-key - this option can occur anywhere on
1064 command line. At start of command line
1065 must check for authentication option. */
1066 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1067 vl_config.auth_key = auth_key;
1068 }
1069 else if (strncmp (argv[i], "authentication", 14) == 0)
1070 {
1071 /* authentication - this option can only occur at start
1072 of command line */
1073 vl_config.auth_type = OSPF_AUTH_NOTSET;
1074 }
1075 break;
1076
1077 case 'm':
1078 /* message-digest-key */
1079 /* Delete one key */
1080 i++;
1081 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1082 if (vl_config.crypto_key_id < 0)
1083 return CMD_WARNING;
1084 vl_config.md5_key = NULL;
1085 break;
1086
1087 case 'h':
1088 /* Hello interval */
1089 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1090 break;
1091
1092 case 'r':
1093 /* Retransmit Interval */
1094 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1095 break;
1096
1097 case 't':
1098 /* Transmit Delay */
1099 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1100 break;
1101
1102 case 'd':
1103 /* Dead Interval */
1104 i++;
1105 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1106 break;
1107 }
1108 }
1109
1110
1111 /* Action configuration */
1112
paul68980082003-03-25 05:07:42 +00001113 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001114}
1115
paula2c62832003-04-23 17:01:31 +00001116ALIAS (ospf_area_vlink,
1117 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001118 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1119 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1120 VLINK_HELPSTR_IPADDR
1121 VLINK_HELPSTR_TIME_PARAM)
1122
paula2c62832003-04-23 17:01:31 +00001123ALIAS (no_ospf_area_vlink,
1124 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001125 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1126 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1127 NO_STR
1128 VLINK_HELPSTR_IPADDR
1129 VLINK_HELPSTR_TIME_PARAM)
1130
paula2c62832003-04-23 17:01:31 +00001131ALIAS (ospf_area_vlink,
1132 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001133 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1134 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1135 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1136 VLINK_HELPSTR_IPADDR
1137 VLINK_HELPSTR_TIME_PARAM
1138 VLINK_HELPSTR_TIME_PARAM)
1139
paula2c62832003-04-23 17:01:31 +00001140ALIAS (no_ospf_area_vlink,
1141 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001142 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1143 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1144 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1145 NO_STR
1146 VLINK_HELPSTR_IPADDR
1147 VLINK_HELPSTR_TIME_PARAM
1148 VLINK_HELPSTR_TIME_PARAM)
1149
paula2c62832003-04-23 17:01:31 +00001150ALIAS (ospf_area_vlink,
1151 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001152 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1153 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1154 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1155 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1156 VLINK_HELPSTR_IPADDR
1157 VLINK_HELPSTR_TIME_PARAM
1158 VLINK_HELPSTR_TIME_PARAM
1159 VLINK_HELPSTR_TIME_PARAM)
1160
paula2c62832003-04-23 17:01:31 +00001161ALIAS (no_ospf_area_vlink,
1162 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001163 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1164 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1165 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1166 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1167 NO_STR
1168 VLINK_HELPSTR_IPADDR
1169 VLINK_HELPSTR_TIME_PARAM
1170 VLINK_HELPSTR_TIME_PARAM
1171 VLINK_HELPSTR_TIME_PARAM)
1172
paula2c62832003-04-23 17:01:31 +00001173ALIAS (ospf_area_vlink,
1174 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001175 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1176 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1177 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1178 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1179 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1180 VLINK_HELPSTR_IPADDR
1181 VLINK_HELPSTR_TIME_PARAM
1182 VLINK_HELPSTR_TIME_PARAM
1183 VLINK_HELPSTR_TIME_PARAM
1184 VLINK_HELPSTR_TIME_PARAM)
1185
paula2c62832003-04-23 17:01:31 +00001186ALIAS (no_ospf_area_vlink,
1187 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001188 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1189 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1190 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1191 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1192 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1193 NO_STR
1194 VLINK_HELPSTR_IPADDR
1195 VLINK_HELPSTR_TIME_PARAM
1196 VLINK_HELPSTR_TIME_PARAM
1197 VLINK_HELPSTR_TIME_PARAM
1198 VLINK_HELPSTR_TIME_PARAM)
1199
paula2c62832003-04-23 17:01:31 +00001200ALIAS (ospf_area_vlink,
1201 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001202 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1203 "(authentication|) (message-digest|null)",
1204 VLINK_HELPSTR_IPADDR
1205 VLINK_HELPSTR_AUTHTYPE_ALL)
1206
paula2c62832003-04-23 17:01:31 +00001207ALIAS (ospf_area_vlink,
1208 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001209 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1210 "(authentication|)",
1211 VLINK_HELPSTR_IPADDR
1212 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1213
paula2c62832003-04-23 17:01:31 +00001214ALIAS (no_ospf_area_vlink,
1215 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001216 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1217 "(authentication|)",
1218 NO_STR
1219 VLINK_HELPSTR_IPADDR
1220 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1221
paula2c62832003-04-23 17:01:31 +00001222ALIAS (ospf_area_vlink,
1223 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001224 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1225 "(message-digest-key|) <1-255> md5 KEY",
1226 VLINK_HELPSTR_IPADDR
1227 VLINK_HELPSTR_AUTH_MD5)
1228
paula2c62832003-04-23 17:01:31 +00001229ALIAS (no_ospf_area_vlink,
1230 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001231 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1232 "(message-digest-key|) <1-255>",
1233 NO_STR
1234 VLINK_HELPSTR_IPADDR
1235 VLINK_HELPSTR_AUTH_MD5)
1236
paula2c62832003-04-23 17:01:31 +00001237ALIAS (ospf_area_vlink,
1238 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001239 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1240 "(authentication-key|) AUTH_KEY",
1241 VLINK_HELPSTR_IPADDR
1242 VLINK_HELPSTR_AUTH_SIMPLE)
1243
paula2c62832003-04-23 17:01:31 +00001244ALIAS (no_ospf_area_vlink,
1245 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001246 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1247 "(authentication-key|)",
1248 NO_STR
1249 VLINK_HELPSTR_IPADDR
1250 VLINK_HELPSTR_AUTH_SIMPLE)
1251
paula2c62832003-04-23 17:01:31 +00001252ALIAS (ospf_area_vlink,
1253 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001254 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1255 "(authentication|) (message-digest|null) "
1256 "(authentication-key|) AUTH_KEY",
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_AUTHTYPE_ALL
1259 VLINK_HELPSTR_AUTH_SIMPLE)
1260
paula2c62832003-04-23 17:01:31 +00001261ALIAS (ospf_area_vlink,
1262 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001263 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1264 "(authentication|) "
1265 "(authentication-key|) AUTH_KEY",
1266 VLINK_HELPSTR_IPADDR
1267 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1268 VLINK_HELPSTR_AUTH_SIMPLE)
1269
paula2c62832003-04-23 17:01:31 +00001270ALIAS (no_ospf_area_vlink,
1271 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001272 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1273 "(authentication|) "
1274 "(authentication-key|)",
1275 NO_STR
1276 VLINK_HELPSTR_IPADDR
1277 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1278 VLINK_HELPSTR_AUTH_SIMPLE)
1279
paula2c62832003-04-23 17:01:31 +00001280ALIAS (ospf_area_vlink,
1281 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001282 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1283 "(authentication|) (message-digest|null) "
1284 "(message-digest-key|) <1-255> md5 KEY",
1285 VLINK_HELPSTR_IPADDR
1286 VLINK_HELPSTR_AUTHTYPE_ALL
1287 VLINK_HELPSTR_AUTH_MD5)
1288
paula2c62832003-04-23 17:01:31 +00001289ALIAS (ospf_area_vlink,
1290 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001291 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1292 "(authentication|) "
1293 "(message-digest-key|) <1-255> md5 KEY",
1294 VLINK_HELPSTR_IPADDR
1295 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1296 VLINK_HELPSTR_AUTH_MD5)
1297
paula2c62832003-04-23 17:01:31 +00001298ALIAS (no_ospf_area_vlink,
1299 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001300 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1301 "(authentication|) "
1302 "(message-digest-key|)",
1303 NO_STR
1304 VLINK_HELPSTR_IPADDR
1305 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1306 VLINK_HELPSTR_AUTH_MD5)
1307
1308
paula2c62832003-04-23 17:01:31 +00001309DEFUN (ospf_area_shortcut,
1310 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001311 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1312 "OSPF area parameters\n"
1313 "OSPF area ID in IP address format\n"
1314 "OSPF area ID as a decimal value\n"
1315 "Configure the area's shortcutting mode\n"
1316 "Set default shortcutting behavior\n"
1317 "Enable shortcutting through the area\n"
1318 "Disable shortcutting through the area\n")
1319{
paul68980082003-03-25 05:07:42 +00001320 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001321 struct ospf_area *area;
1322 struct in_addr area_id;
1323 int mode;
1324 int format;
1325
1326 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1327
paul68980082003-03-25 05:07:42 +00001328 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001329
1330 if (strncmp (argv[1], "de", 2) == 0)
1331 mode = OSPF_SHORTCUT_DEFAULT;
1332 else if (strncmp (argv[1], "di", 2) == 0)
1333 mode = OSPF_SHORTCUT_DISABLE;
1334 else if (strncmp (argv[1], "e", 1) == 0)
1335 mode = OSPF_SHORTCUT_ENABLE;
1336 else
1337 return CMD_WARNING;
1338
paul68980082003-03-25 05:07:42 +00001339 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001340
paul68980082003-03-25 05:07:42 +00001341 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001342 vty_out (vty, "Shortcut area setting will take effect "
1343 "only when the router is configured as Shortcut ABR%s",
1344 VTY_NEWLINE);
1345
1346 return CMD_SUCCESS;
1347}
1348
paula2c62832003-04-23 17:01:31 +00001349DEFUN (no_ospf_area_shortcut,
1350 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001351 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1352 NO_STR
1353 "OSPF area parameters\n"
1354 "OSPF area ID in IP address format\n"
1355 "OSPF area ID as a decimal value\n"
1356 "Deconfigure the area's shortcutting mode\n"
1357 "Deconfigure enabled shortcutting through the area\n"
1358 "Deconfigure disabled shortcutting through the area\n")
1359{
paul68980082003-03-25 05:07:42 +00001360 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001361 struct ospf_area *area;
1362 struct in_addr area_id;
1363 int format;
1364
1365 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1366
paul68980082003-03-25 05:07:42 +00001367 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001368 if (!area)
1369 return CMD_SUCCESS;
1370
paul68980082003-03-25 05:07:42 +00001371 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001372
1373 return CMD_SUCCESS;
1374}
1375
1376
paula2c62832003-04-23 17:01:31 +00001377DEFUN (ospf_area_stub,
1378 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001379 "area (A.B.C.D|<0-4294967295>) stub",
1380 "OSPF area parameters\n"
1381 "OSPF area ID in IP address format\n"
1382 "OSPF area ID as a decimal value\n"
1383 "Configure OSPF area as stub\n")
1384{
1385 struct ospf *ospf = vty->index;
1386 struct in_addr area_id;
1387 int ret, format;
1388
1389 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1390
1391 ret = ospf_area_stub_set (ospf, area_id);
1392 if (ret == 0)
1393 {
1394 vty_out (vty, "First deconfigure all virtual link through this area%s",
1395 VTY_NEWLINE);
1396 return CMD_WARNING;
1397 }
1398
1399 ospf_area_no_summary_unset (ospf, area_id);
1400
1401 return CMD_SUCCESS;
1402}
1403
paula2c62832003-04-23 17:01:31 +00001404DEFUN (ospf_area_stub_no_summary,
1405 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001406 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1407 "OSPF stub parameters\n"
1408 "OSPF area ID in IP address format\n"
1409 "OSPF area ID as a decimal value\n"
1410 "Configure OSPF area as stub\n"
1411 "Do not inject inter-area routes into stub\n")
1412{
1413 struct ospf *ospf = vty->index;
1414 struct in_addr area_id;
1415 int ret, format;
1416
1417 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1418
1419 ret = ospf_area_stub_set (ospf, area_id);
1420 if (ret == 0)
1421 {
paulb0a053b2003-06-22 09:04:47 +00001422 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001423 VTY_NEWLINE);
1424 return CMD_WARNING;
1425 }
1426
1427 ospf_area_no_summary_set (ospf, area_id);
1428
1429 return CMD_SUCCESS;
1430}
1431
paula2c62832003-04-23 17:01:31 +00001432DEFUN (no_ospf_area_stub,
1433 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001434 "no area (A.B.C.D|<0-4294967295>) stub",
1435 NO_STR
1436 "OSPF area parameters\n"
1437 "OSPF area ID in IP address format\n"
1438 "OSPF area ID as a decimal value\n"
1439 "Configure OSPF area as stub\n")
1440{
1441 struct ospf *ospf = vty->index;
1442 struct in_addr area_id;
1443 int format;
1444
1445 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1446
1447 ospf_area_stub_unset (ospf, area_id);
1448 ospf_area_no_summary_unset (ospf, area_id);
1449
1450 return CMD_SUCCESS;
1451}
1452
paula2c62832003-04-23 17:01:31 +00001453DEFUN (no_ospf_area_stub_no_summary,
1454 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001455 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1456 NO_STR
1457 "OSPF area parameters\n"
1458 "OSPF area ID in IP address format\n"
1459 "OSPF area ID as a decimal value\n"
1460 "Configure OSPF area as stub\n"
1461 "Do not inject inter-area routes into area\n")
1462{
1463 struct ospf *ospf = vty->index;
1464 struct in_addr area_id;
1465 int format;
1466
1467 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1468 ospf_area_no_summary_unset (ospf, area_id);
1469
1470 return CMD_SUCCESS;
1471}
1472
paulb0a053b2003-06-22 09:04:47 +00001473int
1474ospf_area_nssa_cmd_handler (struct vty *vty, int argc, char **argv, int nosum)
paul718e3742002-12-13 20:15:29 +00001475{
1476 struct ospf *ospf = vty->index;
1477 struct in_addr area_id;
1478 int ret, format;
1479
1480 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1481
1482 ret = ospf_area_nssa_set (ospf, area_id);
1483 if (ret == 0)
1484 {
1485 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1486 VTY_NEWLINE);
1487 return CMD_WARNING;
1488 }
1489
1490 if (argc > 1)
1491 {
1492 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001493 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001494 OSPF_NSSA_ROLE_CANDIDATE);
1495 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001496 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001497 OSPF_NSSA_ROLE_NEVER);
1498 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001499 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001500 OSPF_NSSA_ROLE_ALWAYS);
1501 }
paulb0a053b2003-06-22 09:04:47 +00001502 else
1503 {
1504 ospf_area_nssa_translator_role_set (ospf, area_id,
1505 OSPF_NSSA_ROLE_CANDIDATE);
1506 }
paul718e3742002-12-13 20:15:29 +00001507
paulb0a053b2003-06-22 09:04:47 +00001508 if (nosum)
paul718e3742002-12-13 20:15:29 +00001509 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001510 else
1511 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001512
paulb0a053b2003-06-22 09:04:47 +00001513 ospf_schedule_abr_task (ospf);
1514
paul718e3742002-12-13 20:15:29 +00001515 return CMD_SUCCESS;
1516}
1517
paulb0a053b2003-06-22 09:04:47 +00001518DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001519 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001520 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001521 "OSPF area parameters\n"
1522 "OSPF area ID in IP address format\n"
1523 "OSPF area ID as a decimal value\n"
1524 "Configure OSPF area as nssa\n"
1525 "Configure NSSA-ABR for translate election (default)\n"
1526 "Configure NSSA-ABR to never translate\n"
1527 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001528 "Do not inject inter-area routes into nssa\n")
1529{
1530 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1531}
paul718e3742002-12-13 20:15:29 +00001532
paulb0a053b2003-06-22 09:04:47 +00001533DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001534 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001535 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1536 "OSPF area parameters\n"
1537 "OSPF area ID in IP address format\n"
1538 "OSPF area ID as a decimal value\n"
1539 "Configure OSPF area as nssa\n"
1540 "Configure NSSA-ABR for translate election (default)\n"
1541 "Configure NSSA-ABR to never translate\n"
1542 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001543{
1544 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1545}
1546
1547DEFUN (ospf_area_nssa,
1548 ospf_area_nssa_cmd,
1549 "area (A.B.C.D|<0-4294967295>) nssa",
1550 "OSPF area parameters\n"
1551 "OSPF area ID in IP address format\n"
1552 "OSPF area ID as a decimal value\n"
1553 "Configure OSPF area as nssa\n")
1554{
1555 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1556}
paul718e3742002-12-13 20:15:29 +00001557
paula2c62832003-04-23 17:01:31 +00001558DEFUN (ospf_area_nssa_no_summary,
1559 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001560 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1561 "OSPF area parameters\n"
1562 "OSPF area ID in IP address format\n"
1563 "OSPF area ID as a decimal value\n"
1564 "Configure OSPF area as nssa\n"
1565 "Do not inject inter-area routes into nssa\n")
1566{
paulb0a053b2003-06-22 09:04:47 +00001567 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001568}
1569
paula2c62832003-04-23 17:01:31 +00001570DEFUN (no_ospf_area_nssa,
1571 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001572 "no area (A.B.C.D|<0-4294967295>) nssa",
1573 NO_STR
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{
1579 struct ospf *ospf = vty->index;
1580 struct in_addr area_id;
1581 int format;
1582
1583 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1584
1585 ospf_area_nssa_unset (ospf, area_id);
1586 ospf_area_no_summary_unset (ospf, area_id);
1587
paulb0a053b2003-06-22 09:04:47 +00001588 ospf_schedule_abr_task (ospf);
1589
paul718e3742002-12-13 20:15:29 +00001590 return CMD_SUCCESS;
1591}
1592
paula2c62832003-04-23 17:01:31 +00001593DEFUN (no_ospf_area_nssa_no_summary,
1594 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001595 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1596 NO_STR
1597 "OSPF area parameters\n"
1598 "OSPF area ID in IP address format\n"
1599 "OSPF area ID as a decimal value\n"
1600 "Configure OSPF area as nssa\n"
1601 "Do not inject inter-area routes into nssa\n")
1602{
1603 struct ospf *ospf = vty->index;
1604 struct in_addr area_id;
1605 int format;
1606
1607 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1608 ospf_area_no_summary_unset (ospf, area_id);
1609
1610 return CMD_SUCCESS;
1611}
1612
paula2c62832003-04-23 17:01:31 +00001613DEFUN (ospf_area_default_cost,
1614 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001615 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1616 "OSPF area parameters\n"
1617 "OSPF area ID in IP address format\n"
1618 "OSPF area ID as a decimal value\n"
1619 "Set the summary-default cost of a NSSA or stub area\n"
1620 "Stub's advertised default summary cost\n")
1621{
paul68980082003-03-25 05:07:42 +00001622 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001623 struct ospf_area *area;
1624 struct in_addr area_id;
1625 u_int32_t cost;
1626 int format;
1627
1628 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1629 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1630
paul68980082003-03-25 05:07:42 +00001631 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001632
1633 if (area->external_routing == OSPF_AREA_DEFAULT)
1634 {
1635 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1636 return CMD_WARNING;
1637 }
1638
1639 area->default_cost = cost;
1640
1641 return CMD_SUCCESS;
1642}
1643
paula2c62832003-04-23 17:01:31 +00001644DEFUN (no_ospf_area_default_cost,
1645 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001646 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1647 NO_STR
1648 "OSPF area parameters\n"
1649 "OSPF area ID in IP address format\n"
1650 "OSPF area ID as a decimal value\n"
1651 "Set the summary-default cost of a NSSA or stub area\n"
1652 "Stub's advertised default summary cost\n")
1653{
paul68980082003-03-25 05:07:42 +00001654 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001655 struct ospf_area *area;
1656 struct in_addr area_id;
1657 u_int32_t cost;
1658 int format;
1659
1660 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1661 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1662
paul68980082003-03-25 05:07:42 +00001663 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001664 if (area == NULL)
1665 return CMD_SUCCESS;
1666
1667 if (area->external_routing == OSPF_AREA_DEFAULT)
1668 {
1669 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1670 return CMD_WARNING;
1671 }
1672
1673 area->default_cost = 1;
1674
paul68980082003-03-25 05:07:42 +00001675 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001676
1677 return CMD_SUCCESS;
1678}
1679
paula2c62832003-04-23 17:01:31 +00001680DEFUN (ospf_area_export_list,
1681 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001682 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1683 "OSPF area parameters\n"
1684 "OSPF area ID in IP address format\n"
1685 "OSPF area ID as a decimal value\n"
1686 "Set the filter for networks announced to other areas\n"
1687 "Name of the access-list\n")
1688{
paul68980082003-03-25 05:07:42 +00001689 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001690 struct ospf_area *area;
1691 struct in_addr area_id;
1692 int format;
1693
hasso52930762004-04-19 18:26:53 +00001694 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1695
paul68980082003-03-25 05:07:42 +00001696 area = ospf_area_get (ospf, area_id, format);
1697 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001698
1699 return CMD_SUCCESS;
1700}
1701
paula2c62832003-04-23 17:01:31 +00001702DEFUN (no_ospf_area_export_list,
1703 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001704 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1705 NO_STR
1706 "OSPF area parameters\n"
1707 "OSPF area ID in IP address format\n"
1708 "OSPF area ID as a decimal value\n"
1709 "Unset the filter for networks announced to other areas\n"
1710 "Name of the access-list\n")
1711{
paul68980082003-03-25 05:07:42 +00001712 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001713 struct ospf_area *area;
1714 struct in_addr area_id;
1715 int format;
1716
hasso52930762004-04-19 18:26:53 +00001717 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1718
paul68980082003-03-25 05:07:42 +00001719 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001720 if (area == NULL)
1721 return CMD_SUCCESS;
1722
paul68980082003-03-25 05:07:42 +00001723 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001724
1725 return CMD_SUCCESS;
1726}
1727
1728
paula2c62832003-04-23 17:01:31 +00001729DEFUN (ospf_area_import_list,
1730 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001731 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1732 "OSPF area parameters\n"
1733 "OSPF area ID in IP address format\n"
1734 "OSPF area ID as a decimal value\n"
1735 "Set the filter for networks from other areas announced to the specified one\n"
1736 "Name of the access-list\n")
1737{
paul68980082003-03-25 05:07:42 +00001738 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001739 struct ospf_area *area;
1740 struct in_addr area_id;
1741 int format;
1742
hasso52930762004-04-19 18:26:53 +00001743 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1744
paul68980082003-03-25 05:07:42 +00001745 area = ospf_area_get (ospf, area_id, format);
1746 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001747
1748 return CMD_SUCCESS;
1749}
1750
paula2c62832003-04-23 17:01:31 +00001751DEFUN (no_ospf_area_import_list,
1752 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001753 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1754 NO_STR
1755 "OSPF area parameters\n"
1756 "OSPF area ID in IP address format\n"
1757 "OSPF area ID as a decimal value\n"
1758 "Unset the filter for networks announced to other areas\n"
1759 "Name of the access-list\n")
1760{
paul68980082003-03-25 05:07:42 +00001761 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001762 struct ospf_area *area;
1763 struct in_addr area_id;
1764 int format;
1765
hasso52930762004-04-19 18:26:53 +00001766 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1767
paul68980082003-03-25 05:07:42 +00001768 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001769 if (area == NULL)
1770 return CMD_SUCCESS;
1771
paul68980082003-03-25 05:07:42 +00001772 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001773
1774 return CMD_SUCCESS;
1775}
1776
paula2c62832003-04-23 17:01:31 +00001777DEFUN (ospf_area_filter_list,
1778 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001779 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1780 "OSPF area parameters\n"
1781 "OSPF area ID in IP address format\n"
1782 "OSPF area ID as a decimal value\n"
1783 "Filter networks between OSPF areas\n"
1784 "Filter prefixes between OSPF areas\n"
1785 "Name of an IP prefix-list\n"
1786 "Filter networks sent to this area\n"
1787 "Filter networks sent from this area\n")
1788{
paul68980082003-03-25 05:07:42 +00001789 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001790 struct ospf_area *area;
1791 struct in_addr area_id;
1792 struct prefix_list *plist;
1793 int format;
1794
1795 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1796
paul68980082003-03-25 05:07:42 +00001797 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001798 plist = prefix_list_lookup (AFI_IP, argv[1]);
1799 if (strncmp (argv[2], "in", 2) == 0)
1800 {
1801 PREFIX_LIST_IN (area) = plist;
1802 if (PREFIX_NAME_IN (area))
1803 free (PREFIX_NAME_IN (area));
1804
1805 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001806 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001807 }
1808 else
1809 {
1810 PREFIX_LIST_OUT (area) = plist;
1811 if (PREFIX_NAME_OUT (area))
1812 free (PREFIX_NAME_OUT (area));
1813
1814 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001815 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001816 }
1817
1818 return CMD_SUCCESS;
1819}
1820
paula2c62832003-04-23 17:01:31 +00001821DEFUN (no_ospf_area_filter_list,
1822 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001823 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1824 NO_STR
1825 "OSPF area parameters\n"
1826 "OSPF area ID in IP address format\n"
1827 "OSPF area ID as a decimal value\n"
1828 "Filter networks between OSPF areas\n"
1829 "Filter prefixes between OSPF areas\n"
1830 "Name of an IP prefix-list\n"
1831 "Filter networks sent to this area\n"
1832 "Filter networks sent from this area\n")
1833{
paul68980082003-03-25 05:07:42 +00001834 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001835 struct ospf_area *area;
1836 struct in_addr area_id;
1837 struct prefix_list *plist;
1838 int format;
1839
1840 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1841
paul68980082003-03-25 05:07:42 +00001842 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001843 plist = prefix_list_lookup (AFI_IP, argv[1]);
1844 if (strncmp (argv[2], "in", 2) == 0)
1845 {
1846 if (PREFIX_NAME_IN (area))
1847 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1848 return CMD_SUCCESS;
1849
1850 PREFIX_LIST_IN (area) = NULL;
1851 if (PREFIX_NAME_IN (area))
1852 free (PREFIX_NAME_IN (area));
1853
1854 PREFIX_NAME_IN (area) = NULL;
1855
paul68980082003-03-25 05:07:42 +00001856 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001857 }
1858 else
1859 {
1860 if (PREFIX_NAME_OUT (area))
1861 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1862 return CMD_SUCCESS;
1863
1864 PREFIX_LIST_OUT (area) = NULL;
1865 if (PREFIX_NAME_OUT (area))
1866 free (PREFIX_NAME_OUT (area));
1867
1868 PREFIX_NAME_OUT (area) = NULL;
1869
paul68980082003-03-25 05:07:42 +00001870 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001871 }
1872
1873 return CMD_SUCCESS;
1874}
1875
1876
paula2c62832003-04-23 17:01:31 +00001877DEFUN (ospf_area_authentication_message_digest,
1878 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001879 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1880 "OSPF area parameters\n"
1881 "Enable authentication\n"
1882 "Use message-digest authentication\n")
1883{
paul68980082003-03-25 05:07:42 +00001884 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001885 struct ospf_area *area;
1886 struct in_addr area_id;
1887 int format;
1888
1889 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1890
paul68980082003-03-25 05:07:42 +00001891 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001892 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1893
1894 return CMD_SUCCESS;
1895}
1896
paula2c62832003-04-23 17:01:31 +00001897DEFUN (ospf_area_authentication,
1898 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001899 "area (A.B.C.D|<0-4294967295>) authentication",
1900 "OSPF area parameters\n"
1901 "OSPF area ID in IP address format\n"
1902 "OSPF area ID as a decimal value\n"
1903 "Enable authentication\n")
1904{
paul68980082003-03-25 05:07:42 +00001905 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001906 struct ospf_area *area;
1907 struct in_addr area_id;
1908 int format;
1909
1910 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1911
paul68980082003-03-25 05:07:42 +00001912 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001913 area->auth_type = OSPF_AUTH_SIMPLE;
1914
1915 return CMD_SUCCESS;
1916}
1917
paula2c62832003-04-23 17:01:31 +00001918DEFUN (no_ospf_area_authentication,
1919 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001920 "no area (A.B.C.D|<0-4294967295>) authentication",
1921 NO_STR
1922 "OSPF area parameters\n"
1923 "OSPF area ID in IP address format\n"
1924 "OSPF area ID as a decimal value\n"
1925 "Enable authentication\n")
1926{
paul68980082003-03-25 05:07:42 +00001927 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001928 struct ospf_area *area;
1929 struct in_addr area_id;
1930 int format;
1931
1932 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1933
paul68980082003-03-25 05:07:42 +00001934 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001935 if (area == NULL)
1936 return CMD_SUCCESS;
1937
1938 area->auth_type = OSPF_AUTH_NULL;
1939
paul68980082003-03-25 05:07:42 +00001940 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001941
1942 return CMD_SUCCESS;
1943}
1944
1945
1946DEFUN (ospf_abr_type,
1947 ospf_abr_type_cmd,
1948 "ospf abr-type (cisco|ibm|shortcut|standard)",
1949 "OSPF specific commands\n"
1950 "Set OSPF ABR type\n"
1951 "Alternative ABR, cisco implementation\n"
1952 "Alternative ABR, IBM implementation\n"
1953 "Shortcut ABR\n"
1954 "Standard behavior (RFC2328)\n")
1955{
paul68980082003-03-25 05:07:42 +00001956 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001957 u_char abr_type = OSPF_ABR_UNKNOWN;
1958
1959 if (strncmp (argv[0], "c", 1) == 0)
1960 abr_type = OSPF_ABR_CISCO;
1961 else if (strncmp (argv[0], "i", 1) == 0)
1962 abr_type = OSPF_ABR_IBM;
1963 else if (strncmp (argv[0], "sh", 2) == 0)
1964 abr_type = OSPF_ABR_SHORTCUT;
1965 else if (strncmp (argv[0], "st", 2) == 0)
1966 abr_type = OSPF_ABR_STAND;
1967 else
1968 return CMD_WARNING;
1969
1970 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00001971 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00001972 {
paul68980082003-03-25 05:07:42 +00001973 ospf->abr_type = abr_type;
1974 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001975 }
1976
1977 return CMD_SUCCESS;
1978}
1979
1980DEFUN (no_ospf_abr_type,
1981 no_ospf_abr_type_cmd,
1982 "no ospf abr-type (cisco|ibm|shortcut)",
1983 NO_STR
1984 "OSPF specific commands\n"
1985 "Set OSPF ABR type\n"
1986 "Alternative ABR, cisco implementation\n"
1987 "Alternative ABR, IBM implementation\n"
1988 "Shortcut ABR\n")
1989{
paul68980082003-03-25 05:07:42 +00001990 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001991 u_char abr_type = OSPF_ABR_UNKNOWN;
1992
1993 if (strncmp (argv[0], "c", 1) == 0)
1994 abr_type = OSPF_ABR_CISCO;
1995 else if (strncmp (argv[0], "i", 1) == 0)
1996 abr_type = OSPF_ABR_IBM;
1997 else if (strncmp (argv[0], "s", 1) == 0)
1998 abr_type = OSPF_ABR_SHORTCUT;
1999 else
2000 return CMD_WARNING;
2001
2002 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002003 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002004 {
paul68980082003-03-25 05:07:42 +00002005 ospf->abr_type = OSPF_ABR_STAND;
2006 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002007 }
2008
2009 return CMD_SUCCESS;
2010}
2011
2012DEFUN (ospf_compatible_rfc1583,
2013 ospf_compatible_rfc1583_cmd,
2014 "compatible rfc1583",
2015 "OSPF compatibility list\n"
2016 "compatible with RFC 1583\n")
2017{
2018 struct ospf *ospf = vty->index;
2019
2020 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2021 {
2022 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002023 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002024 }
2025 return CMD_SUCCESS;
2026}
2027
2028DEFUN (no_ospf_compatible_rfc1583,
2029 no_ospf_compatible_rfc1583_cmd,
2030 "no compatible rfc1583",
2031 NO_STR
2032 "OSPF compatibility list\n"
2033 "compatible with RFC 1583\n")
2034{
2035 struct ospf *ospf = vty->index;
2036
2037 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2038 {
2039 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002040 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002041 }
2042 return CMD_SUCCESS;
2043}
2044
2045ALIAS (ospf_compatible_rfc1583,
2046 ospf_rfc1583_flag_cmd,
2047 "ospf rfc1583compatibility",
2048 "OSPF specific commands\n"
2049 "Enable the RFC1583Compatibility flag\n")
2050
2051ALIAS (no_ospf_compatible_rfc1583,
2052 no_ospf_rfc1583_flag_cmd,
2053 "no ospf rfc1583compatibility",
2054 NO_STR
2055 "OSPF specific commands\n"
2056 "Disable the RFC1583Compatibility flag\n")
2057
paula2c62832003-04-23 17:01:31 +00002058DEFUN (ospf_timers_spf,
2059 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002060 "timers spf <0-4294967295> <0-4294967295>",
2061 "Adjust routing timers\n"
2062 "OSPF SPF timers\n"
2063 "Delay between receiving a change to SPF calculation\n"
2064 "Hold time between consecutive SPF calculations\n")
2065{
2066 struct ospf *ospf = vty->index;
2067 u_int32_t delay, hold;
2068
2069 VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]);
2070 VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]);
2071
2072 ospf_timers_spf_set (ospf, delay, hold);
2073
2074 return CMD_SUCCESS;
2075}
2076
paula2c62832003-04-23 17:01:31 +00002077DEFUN (no_ospf_timers_spf,
2078 no_ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002079 "no timers spf",
2080 NO_STR
2081 "Adjust routing timers\n"
2082 "OSPF SPF timers\n")
2083{
paul68980082003-03-25 05:07:42 +00002084 struct ospf *ospf = vty->index;
2085
2086 ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT;
2087 ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002088
2089 return CMD_SUCCESS;
2090}
2091
2092
paula2c62832003-04-23 17:01:31 +00002093DEFUN (ospf_neighbor,
2094 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002095 "neighbor A.B.C.D",
2096 NEIGHBOR_STR
2097 "Neighbor IP address\n")
2098{
2099 struct ospf *ospf = vty->index;
2100 struct in_addr nbr_addr;
2101 int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2102 int interval = OSPF_POLL_INTERVAL_DEFAULT;
2103
2104 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2105
2106 if (argc > 1)
2107 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2108
2109 if (argc > 2)
2110 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2111
2112 ospf_nbr_nbma_set (ospf, nbr_addr);
2113 if (argc > 1)
2114 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2115 if (argc > 2)
2116 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2117
2118 return CMD_SUCCESS;
2119}
2120
paula2c62832003-04-23 17:01:31 +00002121ALIAS (ospf_neighbor,
2122 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002123 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2124 NEIGHBOR_STR
2125 "Neighbor IP address\n"
2126 "Neighbor Priority\n"
2127 "Priority\n"
2128 "Dead Neighbor Polling interval\n"
2129 "Seconds\n")
2130
paula2c62832003-04-23 17:01:31 +00002131ALIAS (ospf_neighbor,
2132 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002133 "neighbor A.B.C.D priority <0-255>",
2134 NEIGHBOR_STR
2135 "Neighbor IP address\n"
2136 "Neighbor Priority\n"
2137 "Seconds\n")
2138
paula2c62832003-04-23 17:01:31 +00002139DEFUN (ospf_neighbor_poll_interval,
2140 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002141 "neighbor A.B.C.D poll-interval <1-65535>",
2142 NEIGHBOR_STR
2143 "Neighbor IP address\n"
2144 "Dead Neighbor Polling interval\n"
2145 "Seconds\n")
2146{
2147 struct ospf *ospf = vty->index;
2148 struct in_addr nbr_addr;
2149 int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2150 int interval = OSPF_POLL_INTERVAL_DEFAULT;
2151
2152 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2153
2154 if (argc > 1)
2155 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2156
2157 if (argc > 2)
2158 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2159
2160 ospf_nbr_nbma_set (ospf, nbr_addr);
2161 if (argc > 1)
2162 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2163 if (argc > 2)
2164 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2165
2166 return CMD_SUCCESS;
2167}
2168
paula2c62832003-04-23 17:01:31 +00002169ALIAS (ospf_neighbor_poll_interval,
2170 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002171 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2172 NEIGHBOR_STR
2173 "Neighbor address\n"
2174 "OSPF dead-router polling interval\n"
2175 "Seconds\n"
2176 "OSPF priority of non-broadcast neighbor\n"
2177 "Priority\n")
2178
paula2c62832003-04-23 17:01:31 +00002179DEFUN (no_ospf_neighbor,
2180 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002181 "no neighbor A.B.C.D",
2182 NO_STR
2183 NEIGHBOR_STR
2184 "Neighbor IP address\n")
2185{
2186 struct ospf *ospf = vty->index;
2187 struct in_addr nbr_addr;
2188 int ret;
2189
2190 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2191
2192 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2193
2194 return CMD_SUCCESS;
2195}
2196
paula2c62832003-04-23 17:01:31 +00002197ALIAS (no_ospf_neighbor,
2198 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002199 "no neighbor A.B.C.D priority <0-255>",
2200 NO_STR
2201 NEIGHBOR_STR
2202 "Neighbor IP address\n"
2203 "Neighbor Priority\n"
2204 "Priority\n")
2205
paula2c62832003-04-23 17:01:31 +00002206ALIAS (no_ospf_neighbor,
2207 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002208 "no neighbor A.B.C.D poll-interval <1-65535>",
2209 NO_STR
2210 NEIGHBOR_STR
2211 "Neighbor IP address\n"
2212 "Dead Neighbor Polling interval\n"
2213 "Seconds\n")
2214
paula2c62832003-04-23 17:01:31 +00002215ALIAS (no_ospf_neighbor,
2216 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002217 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2218 NO_STR
2219 NEIGHBOR_STR
2220 "Neighbor IP address\n"
2221 "Neighbor Priority\n"
2222 "Priority\n"
2223 "Dead Neighbor Polling interval\n"
2224 "Seconds\n")
2225
2226
paula2c62832003-04-23 17:01:31 +00002227DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002228 "refresh timer <10-1800>",
2229 "Adjust refresh parameters\n"
2230 "Set refresh timer\n"
2231 "Timer value in seconds\n")
2232{
2233 struct ospf *ospf = vty->index;
2234 int interval;
2235
2236 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2237 interval = (interval / 10) * 10;
2238
2239 ospf_timers_refresh_set (ospf, interval);
2240
2241 return CMD_SUCCESS;
2242}
2243
paula2c62832003-04-23 17:01:31 +00002244DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002245 "no refresh timer <10-1800>",
2246 "Adjust refresh parameters\n"
2247 "Unset refresh timer\n"
2248 "Timer value in seconds\n")
2249{
2250 struct ospf *ospf = vty->index;
2251 int interval;
2252
2253 if (argc == 1)
2254 {
2255 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2256
2257 if (ospf->lsa_refresh_interval != interval ||
2258 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2259 return CMD_SUCCESS;
2260 }
2261
2262 ospf_timers_refresh_unset (ospf);
2263
2264 return CMD_SUCCESS;
2265}
2266
paula2c62832003-04-23 17:01:31 +00002267ALIAS (no_ospf_refresh_timer,
2268 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002269 "no refresh timer",
2270 "Adjust refresh parameters\n"
2271 "Unset refresh timer\n")
2272
paula2c62832003-04-23 17:01:31 +00002273DEFUN (ospf_auto_cost_reference_bandwidth,
2274 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002275 "auto-cost reference-bandwidth <1-4294967>",
2276 "Calculate OSPF interface cost according to bandwidth\n"
2277 "Use reference bandwidth method to assign OSPF cost\n"
2278 "The reference bandwidth in terms of Mbits per second\n")
2279{
paul68980082003-03-25 05:07:42 +00002280 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002281 u_int32_t refbw;
2282 listnode node;
2283
2284 refbw = strtol (argv[0], NULL, 10);
2285 if (refbw < 1 || refbw > 4294967)
2286 {
2287 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2288 return CMD_WARNING;
2289 }
2290
2291 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002292 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002293 return CMD_SUCCESS;
2294
paul68980082003-03-25 05:07:42 +00002295 ospf->ref_bandwidth = refbw * 1000;
paul718e3742002-12-13 20:15:29 +00002296 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2297 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2298
paul020709f2003-04-04 02:44:16 +00002299 for (node = listhead (om->iflist); node; nextnode (node))
2300 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002301
2302 return CMD_SUCCESS;
2303}
2304
paula2c62832003-04-23 17:01:31 +00002305DEFUN (no_ospf_auto_cost_reference_bandwidth,
2306 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002307 "no auto-cost reference-bandwidth",
2308 NO_STR
2309 "Calculate OSPF interface cost according to bandwidth\n"
2310 "Use reference bandwidth method to assign OSPF cost\n")
2311{
paul68980082003-03-25 05:07:42 +00002312 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002313 listnode node;
2314
paul68980082003-03-25 05:07:42 +00002315 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002316 return CMD_SUCCESS;
2317
paul68980082003-03-25 05:07:42 +00002318 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002319 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2320 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2321
paul020709f2003-04-04 02:44:16 +00002322 for (node = listhead (om->iflist); node; nextnode (node))
2323 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002324
2325 return CMD_SUCCESS;
2326}
2327
paul718e3742002-12-13 20:15:29 +00002328char *ospf_abr_type_descr_str[] =
2329{
2330 "Unknown",
2331 "Standard (RFC2328)",
2332 "Alternative IBM",
2333 "Alternative Cisco",
2334 "Alternative Shortcut"
2335};
2336
2337char *ospf_shortcut_mode_descr_str[] =
2338{
2339 "Default",
2340 "Enabled",
2341 "Disabled"
2342};
2343
2344
2345
2346void
2347show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2348{
2349 /* Show Area ID. */
2350 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2351
2352 /* Show Area type/mode. */
2353 if (OSPF_IS_AREA_BACKBONE (area))
2354 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2355 else
2356 {
2357 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002358 vty_out (vty, " (Stub%s%s)",
2359 area->no_summary ? ", no summary" : "",
2360 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002361
paulb0a053b2003-06-22 09:04:47 +00002362 else if (area->external_routing == OSPF_AREA_NSSA)
2363 vty_out (vty, " (NSSA%s%s)",
2364 area->no_summary ? ", no summary" : "",
2365 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002366
2367 vty_out (vty, "%s", VTY_NEWLINE);
2368 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002369 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002370 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002371 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002372 }
2373
2374 /* Show number of interfaces. */
2375 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2376 "Active: %d%s", listcount (area->oiflist),
2377 area->act_ints, VTY_NEWLINE);
2378
paul718e3742002-12-13 20:15:29 +00002379 if (area->external_routing == OSPF_AREA_NSSA)
2380 {
2381 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 +00002382 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002383 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2384 VTY_NEWLINE);
2385 else if (area->NSSATranslatorState)
2386 {
2387 vty_out (vty, " We are an ABR and ");
2388 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2389 vty_out (vty, "the NSSA Elected Translator. %s",
2390 VTY_NEWLINE);
2391 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2392 vty_out (vty, "always an NSSA Translator. %s",
2393 VTY_NEWLINE);
2394 }
paul718e3742002-12-13 20:15:29 +00002395 else
paulb0a053b2003-06-22 09:04:47 +00002396 {
2397 vty_out (vty, " We are an ABR, but ");
2398 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2399 vty_out (vty, "not the NSSA Elected Translator. %s",
2400 VTY_NEWLINE);
2401 else
2402 vty_out (vty, "not the NSSA Elected Translator. %s",
2403 VTY_NEWLINE);
2404 }
paul718e3742002-12-13 20:15:29 +00002405 }
paul718e3742002-12-13 20:15:29 +00002406
2407 /* Show number of fully adjacent neighbors. */
2408 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002409 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002410
2411 /* Show authentication type. */
2412 vty_out (vty, " Area has ");
2413 if (area->auth_type == OSPF_AUTH_NULL)
2414 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2415 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2416 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2417 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2418 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2419
2420 if (!OSPF_IS_AREA_BACKBONE (area))
2421 vty_out (vty, " Number of full virtual adjacencies going through"
2422 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2423
2424 /* Show SPF calculation times. */
2425 vty_out (vty, " SPF algorithm executed %d times%s",
2426 area->spf_calculation, VTY_NEWLINE);
2427
2428 /* Show number of LSA. */
2429 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
2430
2431 vty_out (vty, "%s", VTY_NEWLINE);
2432}
2433
2434DEFUN (show_ip_ospf,
2435 show_ip_ospf_cmd,
2436 "show ip ospf",
2437 SHOW_STR
2438 IP_STR
2439 "OSPF information\n")
2440{
2441 listnode node;
2442 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002443 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002444
2445 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002446 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002447 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002448 {
2449 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2450 return CMD_SUCCESS;
2451 }
2452
2453 /* Show Router ID. */
2454 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002455 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002456 VTY_NEWLINE);
2457
2458 /* Show capability. */
2459 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2460 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2461 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002462 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002463 "enabled" : "disabled", VTY_NEWLINE);
2464#ifdef HAVE_OPAQUE_LSA
2465 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002466 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002467 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002468 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002469 " (origination blocked)" : "",
2470 VTY_NEWLINE);
2471#endif /* HAVE_OPAQUE_LSA */
2472
2473 /* Show SPF timers. */
2474 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
paul68980082003-03-25 05:07:42 +00002475 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002476
2477 /* Show refresh parameters. */
2478 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002479 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002480
2481 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002482 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002483 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002484 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002485
paul68980082003-03-25 05:07:42 +00002486 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002487 vty_out (vty, " This router is an ASBR "
2488 "(injecting external routing information)%s", VTY_NEWLINE);
2489
2490 /* Show Number of AS-external-LSAs. */
2491 vty_out (vty, " Number of external LSA %ld%s",
paul68980082003-03-25 05:07:42 +00002492 ospf_lsdb_count_all (ospf->lsdb), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002493
2494 /* Show number of areas attached. */
2495 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002496 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002497
2498 /* Show each area status. */
paul68980082003-03-25 05:07:42 +00002499 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002500 if ((area = getdata (node)) != NULL)
2501 show_ip_ospf_area (vty, area);
2502
2503 return CMD_SUCCESS;
2504}
2505
2506
2507void
paul68980082003-03-25 05:07:42 +00002508show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2509 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002510{
2511 struct ospf_neighbor *nbr;
2512 int oi_count;
2513 struct route_node *rn;
2514 char buf[9];
2515
2516 oi_count = ospf_oi_count (ifp);
2517
2518 /* Is interface up? */
paul2e3b2e42002-12-13 21:03:13 +00002519 if (if_is_operative (ifp)) {
2520 vty_out (vty, "%s is up%s", ifp->name, VTY_NEWLINE);
2521 } else
2522 {
2523 vty_out (vty, "%s is down%s", ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002524
2525
2526 if (oi_count == 0)
2527 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2528 else
2529 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2530 VTY_NEWLINE);
2531 return;
2532 }
2533
2534 /* Is interface OSPF enabled? */
2535 if (oi_count == 0)
2536 {
2537 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2538 return;
2539 }
2540
2541 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2542 {
2543 struct ospf_interface *oi = rn->info;
2544
2545 if (oi == NULL)
2546 continue;
2547
2548 /* Show OSPF interface information. */
2549 vty_out (vty, " Internet Address %s/%d,",
2550 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2551
2552 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2553 VTY_NEWLINE);
2554
2555 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002556 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002557 oi->output_cost, VTY_NEWLINE);
2558
2559 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2560 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2561 PRIORITY (oi), VTY_NEWLINE);
2562
2563 /* Show DR information. */
2564 if (DR (oi).s_addr == 0)
2565 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2566 else
2567 {
2568 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2569 if (nbr == NULL)
2570 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2571 else
2572 {
2573 vty_out (vty, " Designated Router (ID) %s,",
2574 inet_ntoa (nbr->router_id));
2575 vty_out (vty, " Interface Address %s%s",
2576 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2577 }
2578 }
2579
2580 /* Show BDR information. */
2581 if (BDR (oi).s_addr == 0)
2582 vty_out (vty, " No backup designated router on this network%s",
2583 VTY_NEWLINE);
2584 else
2585 {
2586 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2587 if (nbr == NULL)
2588 vty_out (vty, " No backup designated router on this network%s",
2589 VTY_NEWLINE);
2590 else
2591 {
2592 vty_out (vty, " Backup Designated Router (ID) %s,",
2593 inet_ntoa (nbr->router_id));
2594 vty_out (vty, " Interface Address %s%s",
2595 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2596 }
2597 }
2598 vty_out (vty, " Timer intervals configured,");
2599 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2600 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2601 OSPF_IF_PARAM (oi, v_wait),
2602 OSPF_IF_PARAM (oi, retransmit_interval),
2603 VTY_NEWLINE);
2604
2605 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2606 vty_out (vty, " Hello due in %s%s",
2607 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2608 else /* OSPF_IF_PASSIVE is set */
2609 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2610
2611 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002612 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002613 VTY_NEWLINE);
2614 }
2615}
2616
2617DEFUN (show_ip_ospf_interface,
2618 show_ip_ospf_interface_cmd,
2619 "show ip ospf interface [INTERFACE]",
2620 SHOW_STR
2621 IP_STR
2622 "OSPF information\n"
2623 "Interface information\n"
2624 "Interface name\n")
2625{
2626 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002627 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002628 listnode node;
2629
paul020709f2003-04-04 02:44:16 +00002630 ospf = ospf_lookup ();
2631
paul718e3742002-12-13 20:15:29 +00002632 /* Show All Interfaces. */
2633 if (argc == 0)
2634 for (node = listhead (iflist); node; nextnode (node))
paul68980082003-03-25 05:07:42 +00002635 show_ip_ospf_interface_sub (vty, ospf, node->data);
paul718e3742002-12-13 20:15:29 +00002636 /* Interface name is specified. */
2637 else
2638 {
2639 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2640 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2641 else
paul68980082003-03-25 05:07:42 +00002642 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002643 }
2644
2645 return CMD_SUCCESS;
2646}
2647
2648void
2649show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2650{
2651 struct route_node *rn;
2652 struct ospf_neighbor *nbr;
2653 char msgbuf[16];
2654 char timebuf[9];
2655
2656 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2657 if ((nbr = rn->info))
2658 /* Do not show myself. */
2659 if (nbr != oi->nbr_self)
2660 /* Down state is not shown. */
2661 if (nbr->state != NSM_Down)
2662 {
2663 ospf_nbr_state_message (nbr, msgbuf, 16);
2664
2665 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2666 vty_out (vty, "%-15s %3d %-15s %8s ",
2667 "-", nbr->priority,
2668 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2669 else
2670 vty_out (vty, "%-15s %3d %-15s %8s ",
2671 inet_ntoa (nbr->router_id), nbr->priority,
2672 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2673 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2674 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2675 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2676 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2677 VTY_NEWLINE);
2678 }
2679}
2680
2681DEFUN (show_ip_ospf_neighbor,
2682 show_ip_ospf_neighbor_cmd,
2683 "show ip ospf neighbor",
2684 SHOW_STR
2685 IP_STR
2686 "OSPF information\n"
2687 "Neighbor list\n")
2688{
paul020709f2003-04-04 02:44:16 +00002689 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002690 listnode node;
2691
paul020709f2003-04-04 02:44:16 +00002692 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002693 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002694 {
2695 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2696 return CMD_SUCCESS;
2697 }
2698
2699 /* Show All neighbors. */
2700 vty_out (vty, "%sNeighbor ID Pri State Dead "
2701 "Time Address Interface RXmtL "
2702 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2703
paul68980082003-03-25 05:07:42 +00002704 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul020709f2003-04-04 02:44:16 +00002705 show_ip_ospf_neighbor_sub (vty, getdata (node));
paul718e3742002-12-13 20:15:29 +00002706
2707 return CMD_SUCCESS;
2708}
2709
2710DEFUN (show_ip_ospf_neighbor_all,
2711 show_ip_ospf_neighbor_all_cmd,
2712 "show ip ospf neighbor all",
2713 SHOW_STR
2714 IP_STR
2715 "OSPF information\n"
2716 "Neighbor list\n"
2717 "include down status neighbor\n")
2718{
paul68980082003-03-25 05:07:42 +00002719 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002720 listnode node;
2721
paul68980082003-03-25 05:07:42 +00002722 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002723 {
2724 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2725 return CMD_SUCCESS;
2726 }
2727
2728 /* Show All neighbors. */
2729 vty_out (vty, "%sNeighbor ID Pri State Dead "
2730 "Time Address Interface RXmtL "
2731 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2732
paul68980082003-03-25 05:07:42 +00002733 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002734 {
2735 struct ospf_interface *oi = getdata (node);
2736 listnode nbr_node;
2737
2738 show_ip_ospf_neighbor_sub (vty, oi);
2739
2740 /* print Down neighbor status */
2741 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
2742 {
2743 struct ospf_nbr_nbma *nbr_nbma;
2744
2745 nbr_nbma = getdata (nbr_node);
2746
2747 if (nbr_nbma->nbr == NULL
2748 || nbr_nbma->nbr->state == NSM_Down)
2749 {
2750 vty_out (vty, "%-15s %3d %-15s %8s ",
2751 "-", nbr_nbma->priority, "Down", "-");
2752 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2753 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2754 0, 0, 0, VTY_NEWLINE);
2755 }
2756 }
2757 }
2758
2759 return CMD_SUCCESS;
2760}
2761
2762DEFUN (show_ip_ospf_neighbor_int,
2763 show_ip_ospf_neighbor_int_cmd,
2764 "show ip ospf neighbor A.B.C.D",
2765 SHOW_STR
2766 IP_STR
2767 "OSPF information\n"
2768 "Neighbor list\n"
2769 "Interface name\n")
2770{
paul020709f2003-04-04 02:44:16 +00002771 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002772 struct ospf_interface *oi;
2773 struct in_addr addr;
2774 int ret;
2775
paul718e3742002-12-13 20:15:29 +00002776 ret = inet_aton (argv[0], &addr);
2777 if (!ret)
2778 {
2779 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2780 VTY_NEWLINE);
2781 return CMD_WARNING;
2782 }
2783
paul020709f2003-04-04 02:44:16 +00002784 ospf = ospf_lookup ();
2785 if (ospf == NULL)
2786 {
2787 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2788 return CMD_SUCCESS;
2789 }
2790
paul68980082003-03-25 05:07:42 +00002791 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00002792 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2793 else
2794 {
2795 vty_out (vty, "%sNeighbor ID Pri State Dead "
2796 "Time Address Interface RXmtL "
2797 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2798 show_ip_ospf_neighbor_sub (vty, oi);
2799 }
2800
2801 return CMD_SUCCESS;
2802}
2803
2804void
2805show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2806 struct ospf_nbr_nbma *nbr_nbma)
2807{
2808 char timebuf[9];
2809
2810 /* Show neighbor ID. */
2811 vty_out (vty, " Neighbor %s,", "-");
2812
2813 /* Show interface address. */
2814 vty_out (vty, " interface address %s%s",
2815 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2816 /* Show Area ID. */
2817 vty_out (vty, " In the area %s via interface %s%s",
2818 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2819 /* Show neighbor priority and state. */
2820 vty_out (vty, " Neighbor priority is %d, State is %s,",
2821 nbr_nbma->priority, "Down");
2822 /* Show state changes. */
2823 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2824
2825 /* Show PollInterval */
2826 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2827
2828 /* Show poll-interval timer. */
2829 vty_out (vty, " Poll timer due in %s%s",
2830 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2831
2832 /* Show poll-interval timer thread. */
2833 vty_out (vty, " Thread Poll Timer %s%s",
2834 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2835}
2836
2837void
2838show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2839 struct ospf_neighbor *nbr)
2840{
2841 char timebuf[9];
2842
2843 /* Show neighbor ID. */
2844 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2845 vty_out (vty, " Neighbor %s,", "-");
2846 else
2847 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2848
2849 /* Show interface address. */
2850 vty_out (vty, " interface address %s%s",
2851 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2852 /* Show Area ID. */
2853 vty_out (vty, " In the area %s via interface %s%s",
2854 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2855 /* Show neighbor priority and state. */
2856 vty_out (vty, " Neighbor priority is %d, State is %s,",
2857 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2858 /* Show state changes. */
2859 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2860
2861 /* Show Designated Rotuer ID. */
2862 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2863 /* Show Backup Designated Rotuer ID. */
2864 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2865 /* Show options. */
2866 vty_out (vty, " Options %d %s%s", nbr->options,
2867 ospf_options_dump (nbr->options), VTY_NEWLINE);
2868 /* Show Router Dead interval timer. */
2869 vty_out (vty, " Dead timer due in %s%s",
2870 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2871 /* Show Database Summary list. */
2872 vty_out (vty, " Database Summary List %d%s",
2873 ospf_db_summary_count (nbr), VTY_NEWLINE);
2874 /* Show Link State Request list. */
2875 vty_out (vty, " Link State Request List %ld%s",
2876 ospf_ls_request_count (nbr), VTY_NEWLINE);
2877 /* Show Link State Retransmission list. */
2878 vty_out (vty, " Link State Retransmission List %ld%s",
2879 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2880 /* Show inactivity timer thread. */
2881 vty_out (vty, " Thread Inactivity Timer %s%s",
2882 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2883 /* Show Database Description retransmission thread. */
2884 vty_out (vty, " Thread Database Description Retransmision %s%s",
2885 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2886 /* Show Link State Request Retransmission thread. */
2887 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2888 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2889 /* Show Link State Update Retransmission thread. */
2890 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2891 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2892}
2893
2894DEFUN (show_ip_ospf_neighbor_id,
2895 show_ip_ospf_neighbor_id_cmd,
2896 "show ip ospf neighbor A.B.C.D",
2897 SHOW_STR
2898 IP_STR
2899 "OSPF information\n"
2900 "Neighbor list\n"
2901 "Neighbor ID\n")
2902{
paul020709f2003-04-04 02:44:16 +00002903 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002904 listnode node;
2905 struct ospf_neighbor *nbr;
2906 struct in_addr router_id;
2907 int ret;
2908
2909 ret = inet_aton (argv[0], &router_id);
2910 if (!ret)
2911 {
2912 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
2913 return CMD_WARNING;
2914 }
2915
paul020709f2003-04-04 02:44:16 +00002916 ospf = ospf_lookup ();
2917 if (ospf == NULL)
2918 {
2919 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2920 return CMD_SUCCESS;
2921 }
2922
paul68980082003-03-25 05:07:42 +00002923 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002924 {
2925 struct ospf_interface *oi = getdata (node);
2926
2927 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
2928 {
2929 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2930 return CMD_SUCCESS;
2931 }
2932 }
2933
2934 /* Nothing to show. */
2935 return CMD_SUCCESS;
2936}
2937
2938DEFUN (show_ip_ospf_neighbor_detail,
2939 show_ip_ospf_neighbor_detail_cmd,
2940 "show ip ospf neighbor detail",
2941 SHOW_STR
2942 IP_STR
2943 "OSPF information\n"
2944 "Neighbor list\n"
2945 "detail of all neighbors\n")
2946{
paul020709f2003-04-04 02:44:16 +00002947 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002948 listnode node;
2949
paul020709f2003-04-04 02:44:16 +00002950 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002951 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00002952 {
2953 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2954 return CMD_SUCCESS;
2955 }
paul718e3742002-12-13 20:15:29 +00002956
paul68980082003-03-25 05:07:42 +00002957 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002958 {
2959 struct ospf_interface *oi = getdata (node);
2960 struct route_node *rn;
2961 struct ospf_neighbor *nbr;
2962
2963 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2964 if ((nbr = rn->info))
2965 if (nbr != oi->nbr_self)
2966 if (nbr->state != NSM_Down)
2967 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2968 }
2969
2970 return CMD_SUCCESS;
2971}
2972
2973DEFUN (show_ip_ospf_neighbor_detail_all,
2974 show_ip_ospf_neighbor_detail_all_cmd,
2975 "show ip ospf neighbor detail all",
2976 SHOW_STR
2977 IP_STR
2978 "OSPF information\n"
2979 "Neighbor list\n"
2980 "detail of all neighbors\n"
2981 "include down status neighbor\n")
2982{
paul020709f2003-04-04 02:44:16 +00002983 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002984 listnode node;
2985
paul020709f2003-04-04 02:44:16 +00002986 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002987 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00002988 {
2989 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2990 return CMD_SUCCESS;
2991 }
paul718e3742002-12-13 20:15:29 +00002992
paul68980082003-03-25 05:07:42 +00002993 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002994 {
2995 struct ospf_interface *oi = getdata (node);
2996 struct route_node *rn;
2997 struct ospf_neighbor *nbr;
2998
2999 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3000 if ((nbr = rn->info))
3001 if (nbr != oi->nbr_self)
3002 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3003 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3004
3005 if (oi->type == OSPF_IFTYPE_NBMA)
3006 {
3007 listnode nd;
3008
3009 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
3010 {
3011 struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
3012 if (nbr_nbma->nbr == NULL
3013 || nbr_nbma->nbr->state == NSM_Down)
3014 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3015 }
3016 }
3017 }
3018
3019 return CMD_SUCCESS;
3020}
3021
3022DEFUN (show_ip_ospf_neighbor_int_detail,
3023 show_ip_ospf_neighbor_int_detail_cmd,
3024 "show ip ospf neighbor A.B.C.D detail",
3025 SHOW_STR
3026 IP_STR
3027 "OSPF information\n"
3028 "Neighbor list\n"
3029 "Interface address\n"
3030 "detail of all neighbors")
3031{
paul020709f2003-04-04 02:44:16 +00003032 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003033 struct ospf_interface *oi;
3034 struct in_addr addr;
3035 int ret;
3036
3037 ret = inet_aton (argv[0], &addr);
3038 if (!ret)
3039 {
3040 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3041 VTY_NEWLINE);
3042 return CMD_WARNING;
3043 }
3044
paul020709f2003-04-04 02:44:16 +00003045 ospf = ospf_lookup ();
3046 if (ospf == NULL)
3047 {
3048 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3049 return CMD_SUCCESS;
3050 }
paul68980082003-03-25 05:07:42 +00003051
paul020709f2003-04-04 02:44:16 +00003052 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00003053 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3054 else
3055 {
3056 struct route_node *rn;
3057 struct ospf_neighbor *nbr;
3058
3059 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3060 if ((nbr = rn->info))
3061 if (nbr != oi->nbr_self)
3062 if (nbr->state != NSM_Down)
3063 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3064 }
3065
3066 return CMD_SUCCESS;
3067}
3068
3069
3070/* Show functions */
3071int
paul020709f2003-04-04 02:44:16 +00003072show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003073{
paul718e3742002-12-13 20:15:29 +00003074 struct router_lsa *rl;
3075 struct summary_lsa *sl;
3076 struct as_external_lsa *asel;
3077 struct prefix_ipv4 p;
3078
3079 if (lsa != NULL)
3080 /* If self option is set, check LSA self flag. */
3081 if (self == 0 || IS_LSA_SELF (lsa))
3082 {
3083 /* LSA common part show. */
3084 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3085 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3086 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3087 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3088 /* LSA specific part show. */
3089 switch (lsa->data->type)
3090 {
3091 case OSPF_ROUTER_LSA:
3092 rl = (struct router_lsa *) lsa->data;
3093 vty_out (vty, " %-d", ntohs (rl->links));
3094 break;
3095 case OSPF_SUMMARY_LSA:
3096 sl = (struct summary_lsa *) lsa->data;
3097
3098 p.family = AF_INET;
3099 p.prefix = sl->header.id;
3100 p.prefixlen = ip_masklen (sl->mask);
3101 apply_mask_ipv4 (&p);
3102
3103 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3104 break;
3105 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003106 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003107 asel = (struct as_external_lsa *) lsa->data;
3108
3109 p.family = AF_INET;
3110 p.prefix = asel->header.id;
3111 p.prefixlen = ip_masklen (asel->mask);
3112 apply_mask_ipv4 (&p);
3113
3114 vty_out (vty, " %s %s/%d [0x%lx]",
3115 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3116 inet_ntoa (p.prefix), p.prefixlen,
3117 (u_long)ntohl (asel->e[0].route_tag));
3118 break;
3119 case OSPF_NETWORK_LSA:
3120 case OSPF_ASBR_SUMMARY_LSA:
3121#ifdef HAVE_OPAQUE_LSA
3122 case OSPF_OPAQUE_LINK_LSA:
3123 case OSPF_OPAQUE_AREA_LSA:
3124 case OSPF_OPAQUE_AS_LSA:
3125#endif /* HAVE_OPAQUE_LSA */
3126 default:
3127 break;
3128 }
3129 vty_out (vty, VTY_NEWLINE);
3130 }
3131
3132 return 0;
3133}
3134
3135char *show_database_desc[] =
3136{
3137 "unknown",
3138 "Router Link States",
3139 "Net Link States",
3140 "Summary Link States",
3141 "ASBR-Summary Link States",
3142 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003143 "Group Membership LSA",
3144 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003145#ifdef HAVE_OPAQUE_LSA
3146 "Type-8 LSA",
3147 "Link-Local Opaque-LSA",
3148 "Area-Local Opaque-LSA",
3149 "AS-external Opaque-LSA",
3150#endif /* HAVE_OPAQUE_LSA */
3151};
3152
3153#define SHOW_OSPF_COMMON_HEADER \
3154 "Link ID ADV Router Age Seq# CkSum"
3155
3156char *show_database_header[] =
3157{
3158 "",
3159 "Link ID ADV Router Age Seq# CkSum Link count",
3160 "Link ID ADV Router Age Seq# CkSum",
3161 "Link ID ADV Router Age Seq# CkSum Route",
3162 "Link ID ADV Router Age Seq# CkSum",
3163 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003164 " --- header for Group Member ----",
3165 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003166#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003167 " --- type-8 ---",
3168 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3169 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3170 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3171#endif /* HAVE_OPAQUE_LSA */
3172};
3173
paul4957f492003-06-27 01:28:45 +00003174char *show_lsa_flags[] =
3175{
3176 "Self-originated",
3177 "Checked",
3178 "Received",
3179 "Approved",
3180 "Discard",
paul4957f492003-06-27 01:28:45 +00003181 "Translated",
paul4957f492003-06-27 01:28:45 +00003182};
3183
paul718e3742002-12-13 20:15:29 +00003184void
3185show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3186{
3187 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003188
paul718e3742002-12-13 20:15:29 +00003189 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003190 vty_out (vty, " Options: 0x%-2x : %s%s",
3191 lsa->data->options,
3192 ospf_options_dump(lsa->data->options),
3193 VTY_NEWLINE);
3194 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003195 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003196 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3197 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003198
3199 if (lsa->data->type == OSPF_ROUTER_LSA)
3200 {
3201 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3202
3203 if (rlsa->flags)
3204 vty_out (vty, " :%s%s%s%s",
3205 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3206 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3207 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3208 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3209
3210 vty_out (vty, "%s", VTY_NEWLINE);
3211 }
3212 vty_out (vty, " LS Type: %s%s",
3213 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3214 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3215 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3216 vty_out (vty, " Advertising Router: %s%s",
3217 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3218 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3219 VTY_NEWLINE);
3220 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3221 VTY_NEWLINE);
3222 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3223}
3224
3225char *link_type_desc[] =
3226{
3227 "(null)",
3228 "another Router (point-to-point)",
3229 "a Transit Network",
3230 "Stub Network",
3231 "a Virtual Link",
3232};
3233
3234char *link_id_desc[] =
3235{
3236 "(null)",
3237 "Neighboring Router ID",
3238 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003239 "Net",
paul718e3742002-12-13 20:15:29 +00003240 "Neighboring Router ID",
3241};
3242
3243char *link_data_desc[] =
3244{
3245 "(null)",
3246 "Router Interface address",
3247 "Router Interface address",
3248 "Network Mask",
3249 "Router Interface address",
3250};
3251
3252/* Show router-LSA each Link information. */
3253void
3254show_ip_ospf_database_router_links (struct vty *vty,
3255 struct router_lsa *rl)
3256{
3257 int len, i, type;
3258
3259 len = ntohs (rl->header.length) - 4;
3260 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3261 {
3262 type = rl->link[i].type;
3263
3264 vty_out (vty, " Link connected to: %s%s",
3265 link_type_desc[type], VTY_NEWLINE);
3266 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3267 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3268 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3269 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3270 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3271 vty_out (vty, " TOS 0 Metric: %d%s",
3272 ntohs (rl->link[i].metric), VTY_NEWLINE);
3273 vty_out (vty, "%s", VTY_NEWLINE);
3274 }
3275}
3276
3277/* Show router-LSA detail information. */
3278int
3279show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3280{
3281 if (lsa != NULL)
3282 {
3283 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3284
3285 show_ip_ospf_database_header (vty, lsa);
3286
3287 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3288 VTY_NEWLINE, VTY_NEWLINE);
3289
3290 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003291 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003292 }
3293
3294 return 0;
3295}
3296
3297/* Show network-LSA detail information. */
3298int
3299show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3300{
3301 int length, i;
3302
3303 if (lsa != NULL)
3304 {
3305 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3306
3307 show_ip_ospf_database_header (vty, lsa);
3308
3309 vty_out (vty, " Network Mask: /%d%s",
3310 ip_masklen (nl->mask), VTY_NEWLINE);
3311
3312 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3313
3314 for (i = 0; length > 0; i++, length -= 4)
3315 vty_out (vty, " Attached Router: %s%s",
3316 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3317
3318 vty_out (vty, "%s", VTY_NEWLINE);
3319 }
3320
3321 return 0;
3322}
3323
3324/* Show summary-LSA detail information. */
3325int
3326show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3327{
3328 if (lsa != NULL)
3329 {
3330 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3331
3332 show_ip_ospf_database_header (vty, lsa);
3333
3334 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3335 VTY_NEWLINE);
3336 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3337 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003338 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003339 }
3340
3341 return 0;
3342}
3343
3344/* Show summary-ASBR-LSA detail information. */
3345int
3346show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3347{
3348 if (lsa != NULL)
3349 {
3350 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3351
3352 show_ip_ospf_database_header (vty, lsa);
3353
3354 vty_out (vty, " Network Mask: /%d%s",
3355 ip_masklen (sl->mask), VTY_NEWLINE);
3356 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3357 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003358 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003359 }
3360
3361 return 0;
3362}
3363
3364/* Show AS-external-LSA detail information. */
3365int
3366show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3367{
3368 if (lsa != NULL)
3369 {
3370 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3371
3372 show_ip_ospf_database_header (vty, lsa);
3373
3374 vty_out (vty, " Network Mask: /%d%s",
3375 ip_masklen (al->mask), VTY_NEWLINE);
3376 vty_out (vty, " Metric Type: %s%s",
3377 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3378 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3379 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3380 vty_out (vty, " Metric: %d%s",
3381 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3382 vty_out (vty, " Forward Address: %s%s",
3383 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3384
3385 vty_out (vty, " External Route Tag: %lu%s%s",
3386 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3387 }
3388
3389 return 0;
3390}
3391
paul718e3742002-12-13 20:15:29 +00003392int
3393show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3394{
3395 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3396
3397 /* show_ip_ospf_database_header (vty, lsa); */
3398
3399 zlog_info( " Network Mask: /%d%s",
3400 ip_masklen (al->mask), "\n");
3401 zlog_info( " Metric Type: %s%s",
3402 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3403 "2 (Larger than any link state path)" : "1", "\n");
3404 zlog_info( " TOS: 0%s", "\n");
3405 zlog_info( " Metric: %d%s",
3406 GET_METRIC (al->e[0].metric), "\n");
3407 zlog_info( " Forward Address: %s%s",
3408 inet_ntoa (al->e[0].fwd_addr), "\n");
3409
3410 zlog_info( " External Route Tag: %u%s%s",
3411 ntohl (al->e[0].route_tag), "\n", "\n");
3412
3413 return 0;
3414}
3415
3416/* Show AS-NSSA-LSA detail information. */
3417int
3418show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3419{
3420 if (lsa != NULL)
3421 {
3422 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3423
3424 show_ip_ospf_database_header (vty, lsa);
3425
3426 vty_out (vty, " Network Mask: /%d%s",
3427 ip_masklen (al->mask), VTY_NEWLINE);
3428 vty_out (vty, " Metric Type: %s%s",
3429 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3430 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3431 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3432 vty_out (vty, " Metric: %d%s",
3433 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3434 vty_out (vty, " NSSA: Forward Address: %s%s",
3435 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3436
3437 vty_out (vty, " External Route Tag: %u%s%s",
3438 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3439 }
3440
3441 return 0;
3442}
3443
paul718e3742002-12-13 20:15:29 +00003444int
3445show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3446{
3447 return 0;
3448}
3449
3450#ifdef HAVE_OPAQUE_LSA
3451int
3452show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3453{
3454 if (lsa != NULL)
3455 {
3456 show_ip_ospf_database_header (vty, lsa);
3457 show_opaque_info_detail (vty, lsa);
3458
3459 vty_out (vty, "%s", VTY_NEWLINE);
3460 }
3461 return 0;
3462}
3463#endif /* HAVE_OPAQUE_LSA */
3464
3465int (*show_function[])(struct vty *, struct ospf_lsa *) =
3466{
3467 NULL,
3468 show_router_lsa_detail,
3469 show_network_lsa_detail,
3470 show_summary_lsa_detail,
3471 show_summary_asbr_lsa_detail,
3472 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003473 show_func_dummy,
3474 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003475#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003476 NULL, /* type-8 */
3477 show_opaque_lsa_detail,
3478 show_opaque_lsa_detail,
3479 show_opaque_lsa_detail,
3480#endif /* HAVE_OPAQUE_LSA */
3481};
3482
3483void
3484show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3485 struct in_addr *adv_router)
3486{
3487 memset (lp, 0, sizeof (struct prefix_ls));
3488 lp->family = 0;
3489 if (id == NULL)
3490 lp->prefixlen = 0;
3491 else if (adv_router == NULL)
3492 {
3493 lp->prefixlen = 32;
3494 lp->id = *id;
3495 }
3496 else
3497 {
3498 lp->prefixlen = 64;
3499 lp->id = *id;
3500 lp->adv_router = *adv_router;
3501 }
3502}
3503
3504void
3505show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3506 struct in_addr *id, struct in_addr *adv_router)
3507{
3508 struct prefix_ls lp;
3509 struct route_node *rn, *start;
3510 struct ospf_lsa *lsa;
3511
3512 show_lsa_prefix_set (vty, &lp, id, adv_router);
3513 start = route_node_get (rt, (struct prefix *) &lp);
3514 if (start)
3515 {
3516 route_lock_node (start);
3517 for (rn = start; rn; rn = route_next_until (rn, start))
3518 if ((lsa = rn->info))
3519 {
paul718e3742002-12-13 20:15:29 +00003520 if (show_function[lsa->data->type] != NULL)
3521 show_function[lsa->data->type] (vty, lsa);
3522 }
3523 route_unlock_node (start);
3524 }
3525}
3526
3527/* Show detail LSA information
3528 -- if id is NULL then show all LSAs. */
3529void
paul020709f2003-04-04 02:44:16 +00003530show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003531 struct in_addr *id, struct in_addr *adv_router)
3532{
3533 listnode node;
3534
3535 switch (type)
3536 {
3537 case OSPF_AS_EXTERNAL_LSA:
3538#ifdef HAVE_OPAQUE_LSA
3539 case OSPF_OPAQUE_AS_LSA:
3540#endif /* HAVE_OPAQUE_LSA */
3541 vty_out (vty, " %s %s%s",
3542 show_database_desc[type],
3543 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003544 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003545 break;
3546 default:
paul68980082003-03-25 05:07:42 +00003547 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003548 {
3549 struct ospf_area *area = node->data;
3550 vty_out (vty, "%s %s (Area %s)%s%s",
3551 VTY_NEWLINE, show_database_desc[type],
3552 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3553 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3554 }
3555 break;
3556 }
3557}
3558
3559void
3560show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3561 struct in_addr *adv_router)
3562{
3563 struct route_node *rn;
3564 struct ospf_lsa *lsa;
3565
3566 for (rn = route_top (rt); rn; rn = route_next (rn))
3567 if ((lsa = rn->info))
3568 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3569 {
paul718e3742002-12-13 20:15:29 +00003570 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3571 continue;
paul718e3742002-12-13 20:15:29 +00003572 if (show_function[lsa->data->type] != NULL)
3573 show_function[lsa->data->type] (vty, lsa);
3574 }
3575}
3576
3577/* Show detail LSA information. */
3578void
paul020709f2003-04-04 02:44:16 +00003579show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003580 struct in_addr *adv_router)
3581{
3582 listnode node;
3583
3584 switch (type)
3585 {
3586 case OSPF_AS_EXTERNAL_LSA:
3587#ifdef HAVE_OPAQUE_LSA
3588 case OSPF_OPAQUE_AS_LSA:
3589#endif /* HAVE_OPAQUE_LSA */
3590 vty_out (vty, " %s %s%s",
3591 show_database_desc[type],
3592 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003593 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003594 adv_router);
3595 break;
3596 default:
paul68980082003-03-25 05:07:42 +00003597 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003598 {
3599 struct ospf_area *area = node->data;
3600 vty_out (vty, "%s %s (Area %s)%s%s",
3601 VTY_NEWLINE, show_database_desc[type],
3602 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3603 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3604 adv_router);
3605 }
3606 break;
3607 }
3608}
3609
3610void
paul020709f2003-04-04 02:44:16 +00003611show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003612{
paul020709f2003-04-04 02:44:16 +00003613 struct ospf_lsa *lsa;
3614 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00003615 listnode node;
3616 int type;
3617
paul68980082003-03-25 05:07:42 +00003618 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003619 {
3620 struct ospf_area *area = node->data;
3621 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3622 {
3623 switch (type)
3624 {
3625 case OSPF_AS_EXTERNAL_LSA:
3626#ifdef HAVE_OPAQUE_LSA
3627 case OSPF_OPAQUE_AS_LSA:
3628#endif /* HAVE_OPAQUE_LSA */
3629 continue;
3630 default:
3631 break;
3632 }
3633 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3634 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3635 {
3636 vty_out (vty, " %s (Area %s)%s%s",
3637 show_database_desc[type],
3638 ospf_area_desc_string (area),
3639 VTY_NEWLINE, VTY_NEWLINE);
3640 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3641
paul020709f2003-04-04 02:44:16 +00003642 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3643 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003644
3645 vty_out (vty, "%s", VTY_NEWLINE);
3646 }
3647 }
3648 }
3649
3650 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3651 {
3652 switch (type)
3653 {
3654 case OSPF_AS_EXTERNAL_LSA:
3655#ifdef HAVE_OPAQUE_LSA
3656 case OSPF_OPAQUE_AS_LSA:
3657#endif /* HAVE_OPAQUE_LSA */
3658 break;;
3659 default:
3660 continue;
3661 }
paul68980082003-03-25 05:07:42 +00003662 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3663 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003664 {
3665 vty_out (vty, " %s%s%s",
3666 show_database_desc[type],
3667 VTY_NEWLINE, VTY_NEWLINE);
3668 vty_out (vty, "%s%s", show_database_header[type],
3669 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003670
3671 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3672 show_lsa_summary (vty, lsa, self);
3673
paul718e3742002-12-13 20:15:29 +00003674 vty_out (vty, "%s", VTY_NEWLINE);
3675 }
3676 }
3677
3678 vty_out (vty, "%s", VTY_NEWLINE);
3679}
3680
3681void
paul020709f2003-04-04 02:44:16 +00003682show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003683{
3684 listnode node;
3685 struct ospf_lsa *lsa;
3686
3687 vty_out (vty, "%s MaxAge Link States:%s%s",
3688 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3689
paul68980082003-03-25 05:07:42 +00003690 for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003691 if ((lsa = node->data) != NULL)
3692 {
3693 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3694 vty_out (vty, "Link State ID: %s%s",
3695 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3696 vty_out (vty, "Advertising Router: %s%s",
3697 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3698 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3699 vty_out (vty, "%s", VTY_NEWLINE);
3700 }
3701}
3702
paul718e3742002-12-13 20:15:29 +00003703#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3704#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003705
3706#ifdef HAVE_OPAQUE_LSA
3707#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3708#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3709#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3710#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3711#else /* HAVE_OPAQUE_LSA */
3712#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3713#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3714#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3715#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3716#endif /* HAVE_OPAQUE_LSA */
3717
3718#define OSPF_LSA_TYPES_CMD_STR \
3719 "asbr-summary|external|network|router|summary" \
3720 OSPF_LSA_TYPE_NSSA_CMD_STR \
3721 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3722
3723#define OSPF_LSA_TYPES_DESC \
3724 "ASBR summary link states\n" \
3725 "External link states\n" \
3726 "Network link states\n" \
3727 "Router link states\n" \
3728 "Network summary link states\n" \
3729 OSPF_LSA_TYPE_NSSA_DESC \
3730 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3731 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3732 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3733
3734DEFUN (show_ip_ospf_database,
3735 show_ip_ospf_database_cmd,
3736 "show ip ospf database",
3737 SHOW_STR
3738 IP_STR
3739 "OSPF information\n"
3740 "Database summary\n")
3741{
paul020709f2003-04-04 02:44:16 +00003742 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003743 int type, ret;
3744 struct in_addr id, adv_router;
3745
paul020709f2003-04-04 02:44:16 +00003746 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003747 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003748 return CMD_SUCCESS;
3749
3750 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003751 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003752
3753 /* Show all LSA. */
3754 if (argc == 0)
3755 {
paul020709f2003-04-04 02:44:16 +00003756 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003757 return CMD_SUCCESS;
3758 }
3759
3760 /* Set database type to show. */
3761 if (strncmp (argv[0], "r", 1) == 0)
3762 type = OSPF_ROUTER_LSA;
3763 else if (strncmp (argv[0], "ne", 2) == 0)
3764 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003765 else if (strncmp (argv[0], "ns", 2) == 0)
3766 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003767 else if (strncmp (argv[0], "su", 2) == 0)
3768 type = OSPF_SUMMARY_LSA;
3769 else if (strncmp (argv[0], "a", 1) == 0)
3770 type = OSPF_ASBR_SUMMARY_LSA;
3771 else if (strncmp (argv[0], "e", 1) == 0)
3772 type = OSPF_AS_EXTERNAL_LSA;
3773 else if (strncmp (argv[0], "se", 2) == 0)
3774 {
paul020709f2003-04-04 02:44:16 +00003775 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003776 return CMD_SUCCESS;
3777 }
3778 else if (strncmp (argv[0], "m", 1) == 0)
3779 {
paul020709f2003-04-04 02:44:16 +00003780 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003781 return CMD_SUCCESS;
3782 }
3783#ifdef HAVE_OPAQUE_LSA
3784 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3785 type = OSPF_OPAQUE_LINK_LSA;
3786 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3787 type = OSPF_OPAQUE_AREA_LSA;
3788 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3789 type = OSPF_OPAQUE_AS_LSA;
3790#endif /* HAVE_OPAQUE_LSA */
3791 else
3792 return CMD_WARNING;
3793
3794 /* `show ip ospf database LSA'. */
3795 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003796 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003797 else if (argc >= 2)
3798 {
3799 ret = inet_aton (argv[1], &id);
3800 if (!ret)
3801 return CMD_WARNING;
3802
3803 /* `show ip ospf database LSA ID'. */
3804 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003805 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003806 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3807 else if (argc == 3)
3808 {
3809 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003810 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003811 else
3812 {
3813 ret = inet_aton (argv[2], &adv_router);
3814 if (!ret)
3815 return CMD_WARNING;
3816 }
paul020709f2003-04-04 02:44:16 +00003817 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003818 }
3819 }
3820
3821 return CMD_SUCCESS;
3822}
3823
3824ALIAS (show_ip_ospf_database,
3825 show_ip_ospf_database_type_cmd,
3826 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3827 SHOW_STR
3828 IP_STR
3829 "OSPF information\n"
3830 "Database summary\n"
3831 OSPF_LSA_TYPES_DESC
3832 "LSAs in MaxAge list\n"
3833 "Self-originated link states\n")
3834
3835ALIAS (show_ip_ospf_database,
3836 show_ip_ospf_database_type_id_cmd,
3837 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3838 SHOW_STR
3839 IP_STR
3840 "OSPF information\n"
3841 "Database summary\n"
3842 OSPF_LSA_TYPES_DESC
3843 "Link State ID (as an IP address)\n")
3844
3845ALIAS (show_ip_ospf_database,
3846 show_ip_ospf_database_type_id_adv_router_cmd,
3847 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3848 SHOW_STR
3849 IP_STR
3850 "OSPF information\n"
3851 "Database summary\n"
3852 OSPF_LSA_TYPES_DESC
3853 "Link State ID (as an IP address)\n"
3854 "Advertising Router link states\n"
3855 "Advertising Router (as an IP address)\n")
3856
3857ALIAS (show_ip_ospf_database,
3858 show_ip_ospf_database_type_id_self_cmd,
3859 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3860 SHOW_STR
3861 IP_STR
3862 "OSPF information\n"
3863 "Database summary\n"
3864 OSPF_LSA_TYPES_DESC
3865 "Link State ID (as an IP address)\n"
3866 "Self-originated link states\n"
3867 "\n")
3868
3869DEFUN (show_ip_ospf_database_type_adv_router,
3870 show_ip_ospf_database_type_adv_router_cmd,
3871 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3872 SHOW_STR
3873 IP_STR
3874 "OSPF information\n"
3875 "Database summary\n"
3876 OSPF_LSA_TYPES_DESC
3877 "Advertising Router link states\n"
3878 "Advertising Router (as an IP address)\n")
3879{
paul020709f2003-04-04 02:44:16 +00003880 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003881 int type, ret;
3882 struct in_addr adv_router;
3883
paul020709f2003-04-04 02:44:16 +00003884 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003885 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003886 return CMD_SUCCESS;
3887
3888 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003889 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003890
3891 if (argc != 2)
3892 return CMD_WARNING;
3893
3894 /* Set database type to show. */
3895 if (strncmp (argv[0], "r", 1) == 0)
3896 type = OSPF_ROUTER_LSA;
3897 else if (strncmp (argv[0], "ne", 2) == 0)
3898 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003899 else if (strncmp (argv[0], "ns", 2) == 0)
3900 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003901 else if (strncmp (argv[0], "s", 1) == 0)
3902 type = OSPF_SUMMARY_LSA;
3903 else if (strncmp (argv[0], "a", 1) == 0)
3904 type = OSPF_ASBR_SUMMARY_LSA;
3905 else if (strncmp (argv[0], "e", 1) == 0)
3906 type = OSPF_AS_EXTERNAL_LSA;
3907#ifdef HAVE_OPAQUE_LSA
3908 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3909 type = OSPF_OPAQUE_LINK_LSA;
3910 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3911 type = OSPF_OPAQUE_AREA_LSA;
3912 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3913 type = OSPF_OPAQUE_AS_LSA;
3914#endif /* HAVE_OPAQUE_LSA */
3915 else
3916 return CMD_WARNING;
3917
3918 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
3919 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003920 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003921 else
3922 {
3923 ret = inet_aton (argv[1], &adv_router);
3924 if (!ret)
3925 return CMD_WARNING;
3926 }
3927
paul020709f2003-04-04 02:44:16 +00003928 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00003929
3930 return CMD_SUCCESS;
3931}
3932
3933ALIAS (show_ip_ospf_database_type_adv_router,
3934 show_ip_ospf_database_type_self_cmd,
3935 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
3936 SHOW_STR
3937 IP_STR
3938 "OSPF information\n"
3939 "Database summary\n"
3940 OSPF_LSA_TYPES_DESC
3941 "Self-originated link states\n")
3942
3943
3944DEFUN (ip_ospf_authentication_args,
3945 ip_ospf_authentication_args_addr_cmd,
3946 "ip ospf authentication (null|message-digest) A.B.C.D",
3947 "IP Information\n"
3948 "OSPF interface commands\n"
3949 "Enable authentication on this interface\n"
3950 "Use null authentication\n"
3951 "Use message-digest authentication\n"
3952 "Address of interface")
3953{
3954 struct interface *ifp;
3955 struct in_addr addr;
3956 int ret;
3957 struct ospf_if_params *params;
3958
3959 ifp = vty->index;
3960 params = IF_DEF_PARAMS (ifp);
3961
3962 if (argc == 2)
3963 {
3964 ret = inet_aton(argv[1], &addr);
3965 if (!ret)
3966 {
3967 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3968 VTY_NEWLINE);
3969 return CMD_WARNING;
3970 }
3971
3972 params = ospf_get_if_params (ifp, addr);
3973 ospf_if_update_params (ifp, addr);
3974 }
3975
3976 /* Handle null authentication */
3977 if ( argv[0][0] == 'n' )
3978 {
3979 SET_IF_PARAM (params, auth_type);
3980 params->auth_type = OSPF_AUTH_NULL;
3981 return CMD_SUCCESS;
3982 }
3983
3984 /* Handle message-digest authentication */
3985 if ( argv[0][0] == 'm' )
3986 {
3987 SET_IF_PARAM (params, auth_type);
3988 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
3989 return CMD_SUCCESS;
3990 }
3991
3992 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
3993 return CMD_WARNING;
3994}
3995
3996ALIAS (ip_ospf_authentication_args,
3997 ip_ospf_authentication_args_cmd,
3998 "ip ospf authentication (null|message-digest)",
3999 "IP Information\n"
4000 "OSPF interface commands\n"
4001 "Enable authentication on this interface\n"
4002 "Use null authentication\n"
4003 "Use message-digest authentication\n")
4004
4005DEFUN (ip_ospf_authentication,
4006 ip_ospf_authentication_addr_cmd,
4007 "ip ospf authentication A.B.C.D",
4008 "IP Information\n"
4009 "OSPF interface commands\n"
4010 "Enable authentication on this interface\n"
4011 "Address of interface")
4012{
4013 struct interface *ifp;
4014 struct in_addr addr;
4015 int ret;
4016 struct ospf_if_params *params;
4017
4018 ifp = vty->index;
4019 params = IF_DEF_PARAMS (ifp);
4020
4021 if (argc == 1)
4022 {
4023 ret = inet_aton(argv[1], &addr);
4024 if (!ret)
4025 {
4026 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4027 VTY_NEWLINE);
4028 return CMD_WARNING;
4029 }
4030
4031 params = ospf_get_if_params (ifp, addr);
4032 ospf_if_update_params (ifp, addr);
4033 }
4034
4035 SET_IF_PARAM (params, auth_type);
4036 params->auth_type = OSPF_AUTH_SIMPLE;
4037
4038 return CMD_SUCCESS;
4039}
4040
4041ALIAS (ip_ospf_authentication,
4042 ip_ospf_authentication_cmd,
4043 "ip ospf authentication",
4044 "IP Information\n"
4045 "OSPF interface commands\n"
4046 "Enable authentication on this interface\n")
4047
4048DEFUN (no_ip_ospf_authentication,
4049 no_ip_ospf_authentication_addr_cmd,
4050 "no ip ospf authentication A.B.C.D",
4051 NO_STR
4052 "IP Information\n"
4053 "OSPF interface commands\n"
4054 "Enable authentication on this interface\n"
4055 "Address of interface")
4056{
4057 struct interface *ifp;
4058 struct in_addr addr;
4059 int ret;
4060 struct ospf_if_params *params;
4061
4062 ifp = vty->index;
4063 params = IF_DEF_PARAMS (ifp);
4064
4065 if (argc == 1)
4066 {
4067 ret = inet_aton(argv[1], &addr);
4068 if (!ret)
4069 {
4070 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4071 VTY_NEWLINE);
4072 return CMD_WARNING;
4073 }
4074
4075 params = ospf_lookup_if_params (ifp, addr);
4076 if (params == NULL)
4077 return CMD_SUCCESS;
4078 }
4079
4080 params->auth_type = OSPF_AUTH_NOTSET;
4081 UNSET_IF_PARAM (params, auth_type);
4082
4083 if (params != IF_DEF_PARAMS (ifp))
4084 {
4085 ospf_free_if_params (ifp, addr);
4086 ospf_if_update_params (ifp, addr);
4087 }
4088
4089 return CMD_SUCCESS;
4090}
4091
4092ALIAS (no_ip_ospf_authentication,
4093 no_ip_ospf_authentication_cmd,
4094 "no ip ospf authentication",
4095 NO_STR
4096 "IP Information\n"
4097 "OSPF interface commands\n"
4098 "Enable authentication on this interface\n")
4099
4100DEFUN (ip_ospf_authentication_key,
4101 ip_ospf_authentication_key_addr_cmd,
4102 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4103 "IP Information\n"
4104 "OSPF interface commands\n"
4105 "Authentication password (key)\n"
4106 "The OSPF password (key)\n"
4107 "Address of interface")
4108{
4109 struct interface *ifp;
4110 struct in_addr addr;
4111 int ret;
4112 struct ospf_if_params *params;
4113
4114 ifp = vty->index;
4115 params = IF_DEF_PARAMS (ifp);
4116
4117 if (argc == 2)
4118 {
4119 ret = inet_aton(argv[1], &addr);
4120 if (!ret)
4121 {
4122 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4123 VTY_NEWLINE);
4124 return CMD_WARNING;
4125 }
4126
4127 params = ospf_get_if_params (ifp, addr);
4128 ospf_if_update_params (ifp, addr);
4129 }
4130
4131
4132 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
4133 strncpy (params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
4134 SET_IF_PARAM (params, auth_simple);
4135
4136 return CMD_SUCCESS;
4137}
4138
4139ALIAS (ip_ospf_authentication_key,
4140 ip_ospf_authentication_key_cmd,
4141 "ip ospf authentication-key AUTH_KEY",
4142 "IP Information\n"
4143 "OSPF interface commands\n"
4144 "Authentication password (key)\n"
4145 "The OSPF password (key)")
4146
4147ALIAS (ip_ospf_authentication_key,
4148 ospf_authentication_key_cmd,
4149 "ospf authentication-key AUTH_KEY",
4150 "OSPF interface commands\n"
4151 "Authentication password (key)\n"
4152 "The OSPF password (key)")
4153
4154DEFUN (no_ip_ospf_authentication_key,
4155 no_ip_ospf_authentication_key_addr_cmd,
4156 "no ip ospf authentication-key A.B.C.D",
4157 NO_STR
4158 "IP Information\n"
4159 "OSPF interface commands\n"
4160 "Authentication password (key)\n"
4161 "Address of interface")
4162{
4163 struct interface *ifp;
4164 struct in_addr addr;
4165 int ret;
4166 struct ospf_if_params *params;
4167
4168 ifp = vty->index;
4169 params = IF_DEF_PARAMS (ifp);
4170
4171 if (argc == 2)
4172 {
4173 ret = inet_aton(argv[1], &addr);
4174 if (!ret)
4175 {
4176 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4177 VTY_NEWLINE);
4178 return CMD_WARNING;
4179 }
4180
4181 params = ospf_lookup_if_params (ifp, addr);
4182 if (params == NULL)
4183 return CMD_SUCCESS;
4184 }
4185
4186 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4187 UNSET_IF_PARAM (params, auth_simple);
4188
4189 if (params != IF_DEF_PARAMS (ifp))
4190 {
4191 ospf_free_if_params (ifp, addr);
4192 ospf_if_update_params (ifp, addr);
4193 }
4194
4195 return CMD_SUCCESS;
4196}
4197
4198ALIAS (no_ip_ospf_authentication_key,
4199 no_ip_ospf_authentication_key_cmd,
4200 "no ip ospf authentication-key",
4201 NO_STR
4202 "IP Information\n"
4203 "OSPF interface commands\n"
4204 "Authentication password (key)\n")
4205
4206ALIAS (no_ip_ospf_authentication_key,
4207 no_ospf_authentication_key_cmd,
4208 "no ospf authentication-key",
4209 NO_STR
4210 "OSPF interface commands\n"
4211 "Authentication password (key)\n")
4212
4213DEFUN (ip_ospf_message_digest_key,
4214 ip_ospf_message_digest_key_addr_cmd,
4215 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4216 "IP Information\n"
4217 "OSPF interface commands\n"
4218 "Message digest authentication password (key)\n"
4219 "Key ID\n"
4220 "Use MD5 algorithm\n"
4221 "The OSPF password (key)"
4222 "Address of interface")
4223{
4224 struct interface *ifp;
4225 struct crypt_key *ck;
4226 u_char key_id;
4227 struct in_addr addr;
4228 int ret;
4229 struct ospf_if_params *params;
4230
4231 ifp = vty->index;
4232 params = IF_DEF_PARAMS (ifp);
4233
4234 if (argc == 3)
4235 {
4236 ret = inet_aton(argv[2], &addr);
4237 if (!ret)
4238 {
4239 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4240 VTY_NEWLINE);
4241 return CMD_WARNING;
4242 }
4243
4244 params = ospf_get_if_params (ifp, addr);
4245 ospf_if_update_params (ifp, addr);
4246 }
4247
4248 key_id = strtol (argv[0], NULL, 10);
4249 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4250 {
4251 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4252 return CMD_WARNING;
4253 }
4254
4255 ck = ospf_crypt_key_new ();
4256 ck->key_id = (u_char) key_id;
4257 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
4258 strncpy (ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
4259
4260 ospf_crypt_key_add (params->auth_crypt, ck);
4261 SET_IF_PARAM (params, auth_crypt);
4262
4263 return CMD_SUCCESS;
4264}
4265
4266ALIAS (ip_ospf_message_digest_key,
4267 ip_ospf_message_digest_key_cmd,
4268 "ip ospf message-digest-key <1-255> md5 KEY",
4269 "IP Information\n"
4270 "OSPF interface commands\n"
4271 "Message digest authentication password (key)\n"
4272 "Key ID\n"
4273 "Use MD5 algorithm\n"
4274 "The OSPF password (key)")
4275
4276ALIAS (ip_ospf_message_digest_key,
4277 ospf_message_digest_key_cmd,
4278 "ospf message-digest-key <1-255> md5 KEY",
4279 "OSPF interface commands\n"
4280 "Message digest authentication password (key)\n"
4281 "Key ID\n"
4282 "Use MD5 algorithm\n"
4283 "The OSPF password (key)")
4284
4285DEFUN (no_ip_ospf_message_digest_key,
4286 no_ip_ospf_message_digest_key_addr_cmd,
4287 "no ip ospf message-digest-key <1-255> A.B.C.D",
4288 NO_STR
4289 "IP Information\n"
4290 "OSPF interface commands\n"
4291 "Message digest authentication password (key)\n"
4292 "Key ID\n"
4293 "Address of interface")
4294{
4295 struct interface *ifp;
4296 struct crypt_key *ck;
4297 int key_id;
4298 struct in_addr addr;
4299 int ret;
4300 struct ospf_if_params *params;
4301
4302 ifp = vty->index;
4303 params = IF_DEF_PARAMS (ifp);
4304
4305 if (argc == 2)
4306 {
4307 ret = inet_aton(argv[1], &addr);
4308 if (!ret)
4309 {
4310 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4311 VTY_NEWLINE);
4312 return CMD_WARNING;
4313 }
4314
4315 params = ospf_lookup_if_params (ifp, addr);
4316 if (params == NULL)
4317 return CMD_SUCCESS;
4318 }
4319
4320 key_id = strtol (argv[0], NULL, 10);
4321 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4322 if (ck == NULL)
4323 {
4324 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4325 return CMD_WARNING;
4326 }
4327
4328 ospf_crypt_key_delete (params->auth_crypt, key_id);
4329
4330 if (params != IF_DEF_PARAMS (ifp))
4331 {
4332 ospf_free_if_params (ifp, addr);
4333 ospf_if_update_params (ifp, addr);
4334 }
4335
4336 return CMD_SUCCESS;
4337}
4338
4339ALIAS (no_ip_ospf_message_digest_key,
4340 no_ip_ospf_message_digest_key_cmd,
4341 "no ip ospf message-digest-key <1-255>",
4342 NO_STR
4343 "IP Information\n"
4344 "OSPF interface commands\n"
4345 "Message digest authentication password (key)\n"
4346 "Key ID\n")
4347
4348ALIAS (no_ip_ospf_message_digest_key,
4349 no_ospf_message_digest_key_cmd,
4350 "no ospf message-digest-key <1-255>",
4351 NO_STR
4352 "OSPF interface commands\n"
4353 "Message digest authentication password (key)\n"
4354 "Key ID\n")
4355
4356DEFUN (ip_ospf_cost,
4357 ip_ospf_cost_addr_cmd,
4358 "ip ospf cost <1-65535> A.B.C.D",
4359 "IP Information\n"
4360 "OSPF interface commands\n"
4361 "Interface cost\n"
4362 "Cost\n"
4363 "Address of interface")
4364{
4365 struct interface *ifp = vty->index;
4366 u_int32_t cost;
4367 struct in_addr addr;
4368 int ret;
4369 struct ospf_if_params *params;
4370
4371 params = IF_DEF_PARAMS (ifp);
4372
4373 cost = strtol (argv[0], NULL, 10);
4374
4375 /* cost range is <1-65535>. */
4376 if (cost < 1 || cost > 65535)
4377 {
4378 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4379 return CMD_WARNING;
4380 }
4381
4382 if (argc == 2)
4383 {
4384 ret = inet_aton(argv[1], &addr);
4385 if (!ret)
4386 {
4387 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4388 VTY_NEWLINE);
4389 return CMD_WARNING;
4390 }
4391
4392 params = ospf_get_if_params (ifp, addr);
4393 ospf_if_update_params (ifp, addr);
4394 }
4395
4396 SET_IF_PARAM (params, output_cost_cmd);
4397 params->output_cost_cmd = cost;
4398
4399 ospf_if_recalculate_output_cost (ifp);
4400
4401 return CMD_SUCCESS;
4402}
4403
4404ALIAS (ip_ospf_cost,
4405 ip_ospf_cost_cmd,
4406 "ip ospf cost <1-65535>",
4407 "IP Information\n"
4408 "OSPF interface commands\n"
4409 "Interface cost\n"
4410 "Cost")
4411
4412ALIAS (ip_ospf_cost,
4413 ospf_cost_cmd,
4414 "ospf cost <1-65535>",
4415 "OSPF interface commands\n"
4416 "Interface cost\n"
4417 "Cost")
4418
4419DEFUN (no_ip_ospf_cost,
4420 no_ip_ospf_cost_addr_cmd,
4421 "no ip ospf cost A.B.C.D",
4422 NO_STR
4423 "IP Information\n"
4424 "OSPF interface commands\n"
4425 "Interface cost\n"
4426 "Address of interface")
4427{
4428 struct interface *ifp = vty->index;
4429 struct in_addr addr;
4430 int ret;
4431 struct ospf_if_params *params;
4432
4433 ifp = vty->index;
4434 params = IF_DEF_PARAMS (ifp);
4435
4436 if (argc == 1)
4437 {
4438 ret = inet_aton(argv[0], &addr);
4439 if (!ret)
4440 {
4441 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4442 VTY_NEWLINE);
4443 return CMD_WARNING;
4444 }
4445
4446 params = ospf_lookup_if_params (ifp, addr);
4447 if (params == NULL)
4448 return CMD_SUCCESS;
4449 }
4450
4451 UNSET_IF_PARAM (params, output_cost_cmd);
4452
4453 if (params != IF_DEF_PARAMS (ifp))
4454 {
4455 ospf_free_if_params (ifp, addr);
4456 ospf_if_update_params (ifp, addr);
4457 }
4458
4459 ospf_if_recalculate_output_cost (ifp);
4460
4461 return CMD_SUCCESS;
4462}
4463
4464ALIAS (no_ip_ospf_cost,
4465 no_ip_ospf_cost_cmd,
4466 "no ip ospf cost",
4467 NO_STR
4468 "IP Information\n"
4469 "OSPF interface commands\n"
4470 "Interface cost\n")
4471
4472ALIAS (no_ip_ospf_cost,
4473 no_ospf_cost_cmd,
4474 "no ospf cost",
4475 NO_STR
4476 "OSPF interface commands\n"
4477 "Interface cost\n")
4478
4479void
4480ospf_nbr_timer_update (struct ospf_interface *oi)
4481{
4482 struct route_node *rn;
4483 struct ospf_neighbor *nbr;
4484
4485 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4486 if ((nbr = rn->info))
4487 {
4488 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4489 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4490 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4491 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4492 }
4493}
4494
4495DEFUN (ip_ospf_dead_interval,
4496 ip_ospf_dead_interval_addr_cmd,
4497 "ip ospf dead-interval <1-65535> A.B.C.D",
4498 "IP Information\n"
4499 "OSPF interface commands\n"
4500 "Interval after which a neighbor is declared dead\n"
4501 "Seconds\n"
4502 "Address of interface")
4503{
4504 struct interface *ifp = vty->index;
4505 u_int32_t seconds;
4506 struct in_addr addr;
4507 int ret;
4508 struct ospf_if_params *params;
4509 struct ospf_interface *oi;
4510 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004511 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004512
paul020709f2003-04-04 02:44:16 +00004513 ospf = ospf_lookup ();
4514
paul718e3742002-12-13 20:15:29 +00004515 params = IF_DEF_PARAMS (ifp);
4516
4517 seconds = strtol (argv[0], NULL, 10);
4518
4519 /* dead_interval range is <1-65535>. */
4520 if (seconds < 1 || seconds > 65535)
4521 {
4522 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4523 return CMD_WARNING;
4524 }
4525
4526 if (argc == 2)
4527 {
4528 ret = inet_aton(argv[1], &addr);
4529 if (!ret)
4530 {
4531 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4532 VTY_NEWLINE);
4533 return CMD_WARNING;
4534 }
4535
4536 params = ospf_get_if_params (ifp, addr);
4537 ospf_if_update_params (ifp, addr);
4538 }
4539
4540 SET_IF_PARAM (params, v_wait);
4541 params->v_wait = seconds;
4542
4543 /* Update timer values in neighbor structure. */
4544 if (argc == 2)
4545 {
paul68980082003-03-25 05:07:42 +00004546 if (ospf)
4547 {
4548 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4549 if (oi)
4550 ospf_nbr_timer_update (oi);
4551 }
paul718e3742002-12-13 20:15:29 +00004552 }
4553 else
4554 {
4555 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4556 if ((oi = rn->info))
4557 ospf_nbr_timer_update (oi);
4558 }
4559
4560 return CMD_SUCCESS;
4561}
4562
4563ALIAS (ip_ospf_dead_interval,
4564 ip_ospf_dead_interval_cmd,
4565 "ip ospf dead-interval <1-65535>",
4566 "IP Information\n"
4567 "OSPF interface commands\n"
4568 "Interval after which a neighbor is declared dead\n"
4569 "Seconds\n")
4570
4571ALIAS (ip_ospf_dead_interval,
4572 ospf_dead_interval_cmd,
4573 "ospf dead-interval <1-65535>",
4574 "OSPF interface commands\n"
4575 "Interval after which a neighbor is declared dead\n"
4576 "Seconds\n")
4577
4578DEFUN (no_ip_ospf_dead_interval,
4579 no_ip_ospf_dead_interval_addr_cmd,
4580 "no ip ospf dead-interval A.B.C.D",
4581 NO_STR
4582 "IP Information\n"
4583 "OSPF interface commands\n"
4584 "Interval after which a neighbor is declared dead\n"
4585 "Address of interface")
4586{
4587 struct interface *ifp = vty->index;
4588 struct in_addr addr;
4589 int ret;
4590 struct ospf_if_params *params;
4591 struct ospf_interface *oi;
4592 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004593 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004594
paul020709f2003-04-04 02:44:16 +00004595 ospf = ospf_lookup ();
4596
paul718e3742002-12-13 20:15:29 +00004597 ifp = vty->index;
4598 params = IF_DEF_PARAMS (ifp);
4599
4600 if (argc == 1)
4601 {
4602 ret = inet_aton(argv[0], &addr);
4603 if (!ret)
4604 {
4605 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4606 VTY_NEWLINE);
4607 return CMD_WARNING;
4608 }
4609
4610 params = ospf_lookup_if_params (ifp, addr);
4611 if (params == NULL)
4612 return CMD_SUCCESS;
4613 }
4614
4615 UNSET_IF_PARAM (params, v_wait);
4616 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4617
4618 if (params != IF_DEF_PARAMS (ifp))
4619 {
4620 ospf_free_if_params (ifp, addr);
4621 ospf_if_update_params (ifp, addr);
4622 }
4623
4624 /* Update timer values in neighbor structure. */
4625 if (argc == 1)
4626 {
paul68980082003-03-25 05:07:42 +00004627 if (ospf)
4628 {
4629 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4630 if (oi)
4631 ospf_nbr_timer_update (oi);
4632 }
paul718e3742002-12-13 20:15:29 +00004633 }
4634 else
4635 {
4636 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4637 if ((oi = rn->info))
4638 ospf_nbr_timer_update (oi);
4639 }
4640
4641 return CMD_SUCCESS;
4642}
4643
4644ALIAS (no_ip_ospf_dead_interval,
4645 no_ip_ospf_dead_interval_cmd,
4646 "no ip ospf dead-interval",
4647 NO_STR
4648 "IP Information\n"
4649 "OSPF interface commands\n"
4650 "Interval after which a neighbor is declared dead\n")
4651
4652ALIAS (no_ip_ospf_dead_interval,
4653 no_ospf_dead_interval_cmd,
4654 "no ospf dead-interval",
4655 NO_STR
4656 "OSPF interface commands\n"
4657 "Interval after which a neighbor is declared dead\n")
4658
4659DEFUN (ip_ospf_hello_interval,
4660 ip_ospf_hello_interval_addr_cmd,
4661 "ip ospf hello-interval <1-65535> A.B.C.D",
4662 "IP Information\n"
4663 "OSPF interface commands\n"
4664 "Time between HELLO packets\n"
4665 "Seconds\n"
4666 "Address of interface")
4667{
4668 struct interface *ifp = vty->index;
4669 u_int32_t seconds;
4670 struct in_addr addr;
4671 int ret;
4672 struct ospf_if_params *params;
4673
4674 params = IF_DEF_PARAMS (ifp);
4675
4676 seconds = strtol (argv[0], NULL, 10);
4677
4678 /* HelloInterval range is <1-65535>. */
4679 if (seconds < 1 || seconds > 65535)
4680 {
4681 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4682 return CMD_WARNING;
4683 }
4684
4685 if (argc == 2)
4686 {
4687 ret = inet_aton(argv[1], &addr);
4688 if (!ret)
4689 {
4690 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4691 VTY_NEWLINE);
4692 return CMD_WARNING;
4693 }
4694
4695 params = ospf_get_if_params (ifp, addr);
4696 ospf_if_update_params (ifp, addr);
4697 }
4698
4699 SET_IF_PARAM (params, v_hello);
4700 params->v_hello = seconds;
4701
4702 return CMD_SUCCESS;
4703}
4704
4705ALIAS (ip_ospf_hello_interval,
4706 ip_ospf_hello_interval_cmd,
4707 "ip ospf hello-interval <1-65535>",
4708 "IP Information\n"
4709 "OSPF interface commands\n"
4710 "Time between HELLO packets\n"
4711 "Seconds\n")
4712
4713ALIAS (ip_ospf_hello_interval,
4714 ospf_hello_interval_cmd,
4715 "ospf hello-interval <1-65535>",
4716 "OSPF interface commands\n"
4717 "Time between HELLO packets\n"
4718 "Seconds\n")
4719
4720DEFUN (no_ip_ospf_hello_interval,
4721 no_ip_ospf_hello_interval_addr_cmd,
4722 "no ip ospf hello-interval A.B.C.D",
4723 NO_STR
4724 "IP Information\n"
4725 "OSPF interface commands\n"
4726 "Time between HELLO packets\n"
4727 "Address of interface")
4728{
4729 struct interface *ifp = vty->index;
4730 struct in_addr addr;
4731 int ret;
4732 struct ospf_if_params *params;
4733
4734 ifp = vty->index;
4735 params = IF_DEF_PARAMS (ifp);
4736
4737 if (argc == 1)
4738 {
4739 ret = inet_aton(argv[0], &addr);
4740 if (!ret)
4741 {
4742 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4743 VTY_NEWLINE);
4744 return CMD_WARNING;
4745 }
4746
4747 params = ospf_lookup_if_params (ifp, addr);
4748 if (params == NULL)
4749 return CMD_SUCCESS;
4750 }
4751
4752 UNSET_IF_PARAM (params, v_hello);
4753 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4754
4755 if (params != IF_DEF_PARAMS (ifp))
4756 {
4757 ospf_free_if_params (ifp, addr);
4758 ospf_if_update_params (ifp, addr);
4759 }
4760
4761 return CMD_SUCCESS;
4762}
4763
4764ALIAS (no_ip_ospf_hello_interval,
4765 no_ip_ospf_hello_interval_cmd,
4766 "no ip ospf hello-interval",
4767 NO_STR
4768 "IP Information\n"
4769 "OSPF interface commands\n"
4770 "Time between HELLO packets\n")
4771
4772ALIAS (no_ip_ospf_hello_interval,
4773 no_ospf_hello_interval_cmd,
4774 "no ospf hello-interval",
4775 NO_STR
4776 "OSPF interface commands\n"
4777 "Time between HELLO packets\n")
4778
4779DEFUN (ip_ospf_network,
4780 ip_ospf_network_cmd,
4781 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4782 "IP Information\n"
4783 "OSPF interface commands\n"
4784 "Network type\n"
4785 "Specify OSPF broadcast multi-access network\n"
4786 "Specify OSPF NBMA network\n"
4787 "Specify OSPF point-to-multipoint network\n"
4788 "Specify OSPF point-to-point network\n")
4789{
4790 struct interface *ifp = vty->index;
4791 int old_type = IF_DEF_PARAMS (ifp)->type;
4792 struct route_node *rn;
4793
4794 if (strncmp (argv[0], "b", 1) == 0)
4795 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4796 else if (strncmp (argv[0], "n", 1) == 0)
4797 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4798 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4799 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4800 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4801 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4802
4803 if (IF_DEF_PARAMS (ifp)->type == old_type)
4804 return CMD_SUCCESS;
4805
4806 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4807
4808 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4809 {
4810 struct ospf_interface *oi = rn->info;
4811
4812 if (!oi)
4813 continue;
4814
4815 oi->type = IF_DEF_PARAMS (ifp)->type;
4816
4817 if (oi->state > ISM_Down)
4818 {
4819 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4820 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4821 }
4822 }
4823
4824 return CMD_SUCCESS;
4825}
4826
4827ALIAS (ip_ospf_network,
4828 ospf_network_cmd,
4829 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4830 "OSPF interface commands\n"
4831 "Network type\n"
4832 "Specify OSPF broadcast multi-access network\n"
4833 "Specify OSPF NBMA network\n"
4834 "Specify OSPF point-to-multipoint network\n"
4835 "Specify OSPF point-to-point network\n")
4836
4837DEFUN (no_ip_ospf_network,
4838 no_ip_ospf_network_cmd,
4839 "no ip ospf network",
4840 NO_STR
4841 "IP Information\n"
4842 "OSPF interface commands\n"
4843 "Network type\n")
4844{
4845 struct interface *ifp = vty->index;
4846 int old_type = IF_DEF_PARAMS (ifp)->type;
4847 struct route_node *rn;
4848
4849 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4850
4851 if (IF_DEF_PARAMS (ifp)->type == old_type)
4852 return CMD_SUCCESS;
4853
4854 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4855 {
4856 struct ospf_interface *oi = rn->info;
4857
4858 if (!oi)
4859 continue;
4860
4861 oi->type = IF_DEF_PARAMS (ifp)->type;
4862
4863 if (oi->state > ISM_Down)
4864 {
4865 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4866 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4867 }
4868 }
4869
4870 return CMD_SUCCESS;
4871}
4872
4873ALIAS (no_ip_ospf_network,
4874 no_ospf_network_cmd,
4875 "no ospf network",
4876 NO_STR
4877 "OSPF interface commands\n"
4878 "Network type\n")
4879
4880DEFUN (ip_ospf_priority,
4881 ip_ospf_priority_addr_cmd,
4882 "ip ospf priority <0-255> A.B.C.D",
4883 "IP Information\n"
4884 "OSPF interface commands\n"
4885 "Router priority\n"
4886 "Priority\n"
4887 "Address of interface")
4888{
4889 struct interface *ifp = vty->index;
4890 u_int32_t priority;
4891 struct route_node *rn;
4892 struct in_addr addr;
4893 int ret;
4894 struct ospf_if_params *params;
4895
4896 params = IF_DEF_PARAMS (ifp);
4897
4898 priority = strtol (argv[0], NULL, 10);
4899
4900 /* Router Priority range is <0-255>. */
4901 if (priority < 0 || priority > 255)
4902 {
4903 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4904 return CMD_WARNING;
4905 }
4906
4907 if (argc == 2)
4908 {
4909 ret = inet_aton(argv[1], &addr);
4910 if (!ret)
4911 {
4912 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4913 VTY_NEWLINE);
4914 return CMD_WARNING;
4915 }
4916
4917 params = ospf_get_if_params (ifp, addr);
4918 ospf_if_update_params (ifp, addr);
4919 }
4920
4921 SET_IF_PARAM (params, priority);
4922 params->priority = priority;
4923
4924 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4925 {
4926 struct ospf_interface *oi = rn->info;
4927
4928 if (!oi)
4929 continue;
4930
4931
4932 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
4933 {
4934 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
4935 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
4936 }
4937 }
4938
4939 return CMD_SUCCESS;
4940}
4941
4942ALIAS (ip_ospf_priority,
4943 ip_ospf_priority_cmd,
4944 "ip ospf priority <0-255>",
4945 "IP Information\n"
4946 "OSPF interface commands\n"
4947 "Router priority\n"
4948 "Priority\n")
4949
4950ALIAS (ip_ospf_priority,
4951 ospf_priority_cmd,
4952 "ospf priority <0-255>",
4953 "OSPF interface commands\n"
4954 "Router priority\n"
4955 "Priority\n")
4956
4957DEFUN (no_ip_ospf_priority,
4958 no_ip_ospf_priority_addr_cmd,
4959 "no ip ospf priority A.B.C.D",
4960 NO_STR
4961 "IP Information\n"
4962 "OSPF interface commands\n"
4963 "Router priority\n"
4964 "Address of interface")
4965{
4966 struct interface *ifp = vty->index;
4967 struct route_node *rn;
4968 struct in_addr addr;
4969 int ret;
4970 struct ospf_if_params *params;
4971
4972 ifp = vty->index;
4973 params = IF_DEF_PARAMS (ifp);
4974
4975 if (argc == 1)
4976 {
4977 ret = inet_aton(argv[0], &addr);
4978 if (!ret)
4979 {
4980 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4981 VTY_NEWLINE);
4982 return CMD_WARNING;
4983 }
4984
4985 params = ospf_lookup_if_params (ifp, addr);
4986 if (params == NULL)
4987 return CMD_SUCCESS;
4988 }
4989
4990 UNSET_IF_PARAM (params, priority);
4991 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
4992
4993 if (params != IF_DEF_PARAMS (ifp))
4994 {
4995 ospf_free_if_params (ifp, addr);
4996 ospf_if_update_params (ifp, addr);
4997 }
4998
4999 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5000 {
5001 struct ospf_interface *oi = rn->info;
5002
5003 if (!oi)
5004 continue;
5005
5006
5007 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5008 {
5009 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5010 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5011 }
5012 }
5013
5014 return CMD_SUCCESS;
5015}
5016
5017ALIAS (no_ip_ospf_priority,
5018 no_ip_ospf_priority_cmd,
5019 "no ip ospf priority",
5020 NO_STR
5021 "IP Information\n"
5022 "OSPF interface commands\n"
5023 "Router priority\n")
5024
5025ALIAS (no_ip_ospf_priority,
5026 no_ospf_priority_cmd,
5027 "no ospf priority",
5028 NO_STR
5029 "OSPF interface commands\n"
5030 "Router priority\n")
5031
5032DEFUN (ip_ospf_retransmit_interval,
5033 ip_ospf_retransmit_interval_addr_cmd,
5034 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5035 "IP Information\n"
5036 "OSPF interface commands\n"
5037 "Time between retransmitting lost link state advertisements\n"
5038 "Seconds\n"
5039 "Address of interface")
5040{
5041 struct interface *ifp = vty->index;
5042 u_int32_t seconds;
5043 struct in_addr addr;
5044 int ret;
5045 struct ospf_if_params *params;
5046
5047 params = IF_DEF_PARAMS (ifp);
5048 seconds = strtol (argv[0], NULL, 10);
5049
5050 /* Retransmit Interval range is <3-65535>. */
5051 if (seconds < 3 || seconds > 65535)
5052 {
5053 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5054 return CMD_WARNING;
5055 }
5056
5057
5058 if (argc == 2)
5059 {
5060 ret = inet_aton(argv[1], &addr);
5061 if (!ret)
5062 {
5063 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5064 VTY_NEWLINE);
5065 return CMD_WARNING;
5066 }
5067
5068 params = ospf_get_if_params (ifp, addr);
5069 ospf_if_update_params (ifp, addr);
5070 }
5071
5072 SET_IF_PARAM (params, retransmit_interval);
5073 params->retransmit_interval = seconds;
5074
5075 return CMD_SUCCESS;
5076}
5077
5078ALIAS (ip_ospf_retransmit_interval,
5079 ip_ospf_retransmit_interval_cmd,
5080 "ip ospf retransmit-interval <3-65535>",
5081 "IP Information\n"
5082 "OSPF interface commands\n"
5083 "Time between retransmitting lost link state advertisements\n"
5084 "Seconds\n")
5085
5086ALIAS (ip_ospf_retransmit_interval,
5087 ospf_retransmit_interval_cmd,
5088 "ospf retransmit-interval <3-65535>",
5089 "OSPF interface commands\n"
5090 "Time between retransmitting lost link state advertisements\n"
5091 "Seconds\n")
5092
5093DEFUN (no_ip_ospf_retransmit_interval,
5094 no_ip_ospf_retransmit_interval_addr_cmd,
5095 "no ip ospf retransmit-interval A.B.C.D",
5096 NO_STR
5097 "IP Information\n"
5098 "OSPF interface commands\n"
5099 "Time between retransmitting lost link state advertisements\n"
5100 "Address of interface")
5101{
5102 struct interface *ifp = vty->index;
5103 struct in_addr addr;
5104 int ret;
5105 struct ospf_if_params *params;
5106
5107 ifp = vty->index;
5108 params = IF_DEF_PARAMS (ifp);
5109
5110 if (argc == 1)
5111 {
5112 ret = inet_aton(argv[0], &addr);
5113 if (!ret)
5114 {
5115 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5116 VTY_NEWLINE);
5117 return CMD_WARNING;
5118 }
5119
5120 params = ospf_lookup_if_params (ifp, addr);
5121 if (params == NULL)
5122 return CMD_SUCCESS;
5123 }
5124
5125 UNSET_IF_PARAM (params, retransmit_interval);
5126 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5127
5128 if (params != IF_DEF_PARAMS (ifp))
5129 {
5130 ospf_free_if_params (ifp, addr);
5131 ospf_if_update_params (ifp, addr);
5132 }
5133
5134 return CMD_SUCCESS;
5135}
5136
5137ALIAS (no_ip_ospf_retransmit_interval,
5138 no_ip_ospf_retransmit_interval_cmd,
5139 "no ip ospf retransmit-interval",
5140 NO_STR
5141 "IP Information\n"
5142 "OSPF interface commands\n"
5143 "Time between retransmitting lost link state advertisements\n")
5144
5145ALIAS (no_ip_ospf_retransmit_interval,
5146 no_ospf_retransmit_interval_cmd,
5147 "no ospf retransmit-interval",
5148 NO_STR
5149 "OSPF interface commands\n"
5150 "Time between retransmitting lost link state advertisements\n")
5151
5152DEFUN (ip_ospf_transmit_delay,
5153 ip_ospf_transmit_delay_addr_cmd,
5154 "ip ospf transmit-delay <1-65535> A.B.C.D",
5155 "IP Information\n"
5156 "OSPF interface commands\n"
5157 "Link state transmit delay\n"
5158 "Seconds\n"
5159 "Address of interface")
5160{
5161 struct interface *ifp = vty->index;
5162 u_int32_t seconds;
5163 struct in_addr addr;
5164 int ret;
5165 struct ospf_if_params *params;
5166
5167 params = IF_DEF_PARAMS (ifp);
5168 seconds = strtol (argv[0], NULL, 10);
5169
5170 /* Transmit Delay range is <1-65535>. */
5171 if (seconds < 1 || seconds > 65535)
5172 {
5173 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5174 return CMD_WARNING;
5175 }
5176
5177 if (argc == 2)
5178 {
5179 ret = inet_aton(argv[1], &addr);
5180 if (!ret)
5181 {
5182 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5183 VTY_NEWLINE);
5184 return CMD_WARNING;
5185 }
5186
5187 params = ospf_get_if_params (ifp, addr);
5188 ospf_if_update_params (ifp, addr);
5189 }
5190
5191 SET_IF_PARAM (params, transmit_delay);
5192 params->transmit_delay = seconds;
5193
5194 return CMD_SUCCESS;
5195}
5196
5197ALIAS (ip_ospf_transmit_delay,
5198 ip_ospf_transmit_delay_cmd,
5199 "ip ospf transmit-delay <1-65535>",
5200 "IP Information\n"
5201 "OSPF interface commands\n"
5202 "Link state transmit delay\n"
5203 "Seconds\n")
5204
5205ALIAS (ip_ospf_transmit_delay,
5206 ospf_transmit_delay_cmd,
5207 "ospf transmit-delay <1-65535>",
5208 "OSPF interface commands\n"
5209 "Link state transmit delay\n"
5210 "Seconds\n")
5211
5212DEFUN (no_ip_ospf_transmit_delay,
5213 no_ip_ospf_transmit_delay_addr_cmd,
5214 "no ip ospf transmit-delay A.B.C.D",
5215 NO_STR
5216 "IP Information\n"
5217 "OSPF interface commands\n"
5218 "Link state transmit delay\n"
5219 "Address of interface")
5220{
5221 struct interface *ifp = vty->index;
5222 struct in_addr addr;
5223 int ret;
5224 struct ospf_if_params *params;
5225
5226 ifp = vty->index;
5227 params = IF_DEF_PARAMS (ifp);
5228
5229 if (argc == 1)
5230 {
5231 ret = inet_aton(argv[0], &addr);
5232 if (!ret)
5233 {
5234 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5235 VTY_NEWLINE);
5236 return CMD_WARNING;
5237 }
5238
5239 params = ospf_lookup_if_params (ifp, addr);
5240 if (params == NULL)
5241 return CMD_SUCCESS;
5242 }
5243
5244 UNSET_IF_PARAM (params, transmit_delay);
5245 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5246
5247 if (params != IF_DEF_PARAMS (ifp))
5248 {
5249 ospf_free_if_params (ifp, addr);
5250 ospf_if_update_params (ifp, addr);
5251 }
5252
5253 return CMD_SUCCESS;
5254}
5255
5256ALIAS (no_ip_ospf_transmit_delay,
5257 no_ip_ospf_transmit_delay_cmd,
5258 "no ip ospf transmit-delay",
5259 NO_STR
5260 "IP Information\n"
5261 "OSPF interface commands\n"
5262 "Link state transmit delay\n")
5263
5264ALIAS (no_ip_ospf_transmit_delay,
5265 no_ospf_transmit_delay_cmd,
5266 "no ospf transmit-delay",
5267 NO_STR
5268 "OSPF interface commands\n"
5269 "Link state transmit delay\n")
5270
5271
5272DEFUN (ospf_redistribute_source_metric_type,
5273 ospf_redistribute_source_metric_type_routemap_cmd,
5274 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5275 "Redistribute information from another routing protocol\n"
5276 "Kernel routes\n"
5277 "Connected\n"
5278 "Static routes\n"
5279 "Routing Information Protocol (RIP)\n"
5280 "Border Gateway Protocol (BGP)\n"
5281 "Metric for redistributed routes\n"
5282 "OSPF default metric\n"
5283 "OSPF exterior metric type for redistributed routes\n"
5284 "Set OSPF External Type 1 metrics\n"
5285 "Set OSPF External Type 2 metrics\n"
5286 "Route map reference\n"
5287 "Pointer to route-map entries\n")
5288{
paul020709f2003-04-04 02:44:16 +00005289 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005290 int source;
5291 int type = -1;
5292 int metric = -1;
5293
5294 /* Get distribute source. */
5295 if (!str2distribute_source (argv[0], &source))
5296 return CMD_WARNING;
5297
5298 /* Get metric value. */
5299 if (argc >= 2)
5300 if (!str2metric (argv[1], &metric))
5301 return CMD_WARNING;
5302
5303 /* Get metric type. */
5304 if (argc >= 3)
5305 if (!str2metric_type (argv[2], &type))
5306 return CMD_WARNING;
5307
5308 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005309 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005310 else
paul020709f2003-04-04 02:44:16 +00005311 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005312
paul020709f2003-04-04 02:44:16 +00005313 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005314}
5315
5316ALIAS (ospf_redistribute_source_metric_type,
5317 ospf_redistribute_source_metric_type_cmd,
5318 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5319 "Redistribute information from another routing protocol\n"
5320 "Kernel routes\n"
5321 "Connected\n"
5322 "Static routes\n"
5323 "Routing Information Protocol (RIP)\n"
5324 "Border Gateway Protocol (BGP)\n"
5325 "Metric for redistributed routes\n"
5326 "OSPF default metric\n"
5327 "OSPF exterior metric type for redistributed routes\n"
5328 "Set OSPF External Type 1 metrics\n"
5329 "Set OSPF External Type 2 metrics\n")
5330
5331ALIAS (ospf_redistribute_source_metric_type,
5332 ospf_redistribute_source_metric_cmd,
5333 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5334 "Redistribute information from another routing protocol\n"
5335 "Kernel routes\n"
5336 "Connected\n"
5337 "Static routes\n"
5338 "Routing Information Protocol (RIP)\n"
5339 "Border Gateway Protocol (BGP)\n"
5340 "Metric for redistributed routes\n"
5341 "OSPF default metric\n")
5342
5343DEFUN (ospf_redistribute_source_type_metric,
5344 ospf_redistribute_source_type_metric_routemap_cmd,
5345 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5346 "Redistribute information from another routing protocol\n"
5347 "Kernel routes\n"
5348 "Connected\n"
5349 "Static routes\n"
5350 "Routing Information Protocol (RIP)\n"
5351 "Border Gateway Protocol (BGP)\n"
5352 "OSPF exterior metric type for redistributed routes\n"
5353 "Set OSPF External Type 1 metrics\n"
5354 "Set OSPF External Type 2 metrics\n"
5355 "Metric for redistributed routes\n"
5356 "OSPF default metric\n"
5357 "Route map reference\n"
5358 "Pointer to route-map entries\n")
5359{
paul020709f2003-04-04 02:44:16 +00005360 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005361 int source;
5362 int type = -1;
5363 int metric = -1;
5364
5365 /* Get distribute source. */
5366 if (!str2distribute_source (argv[0], &source))
5367 return CMD_WARNING;
5368
5369 /* Get metric value. */
5370 if (argc >= 2)
5371 if (!str2metric_type (argv[1], &type))
5372 return CMD_WARNING;
5373
5374 /* Get metric type. */
5375 if (argc >= 3)
5376 if (!str2metric (argv[2], &metric))
5377 return CMD_WARNING;
5378
5379 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005380 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005381 else
paul020709f2003-04-04 02:44:16 +00005382 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005383
paul020709f2003-04-04 02:44:16 +00005384 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005385}
5386
5387ALIAS (ospf_redistribute_source_type_metric,
5388 ospf_redistribute_source_type_metric_cmd,
5389 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5390 "Redistribute information from another routing protocol\n"
5391 "Kernel routes\n"
5392 "Connected\n"
5393 "Static routes\n"
5394 "Routing Information Protocol (RIP)\n"
5395 "Border Gateway Protocol (BGP)\n"
5396 "OSPF exterior metric type for redistributed routes\n"
5397 "Set OSPF External Type 1 metrics\n"
5398 "Set OSPF External Type 2 metrics\n"
5399 "Metric for redistributed routes\n"
5400 "OSPF default metric\n")
5401
5402ALIAS (ospf_redistribute_source_type_metric,
5403 ospf_redistribute_source_type_cmd,
5404 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5405 "Redistribute information from another routing protocol\n"
5406 "Kernel routes\n"
5407 "Connected\n"
5408 "Static routes\n"
5409 "Routing Information Protocol (RIP)\n"
5410 "Border Gateway Protocol (BGP)\n"
5411 "OSPF exterior metric type for redistributed routes\n"
5412 "Set OSPF External Type 1 metrics\n"
5413 "Set OSPF External Type 2 metrics\n")
5414
5415ALIAS (ospf_redistribute_source_type_metric,
5416 ospf_redistribute_source_cmd,
5417 "redistribute (kernel|connected|static|rip|bgp)",
5418 "Redistribute information from another routing protocol\n"
5419 "Kernel routes\n"
5420 "Connected\n"
5421 "Static routes\n"
5422 "Routing Information Protocol (RIP)\n"
5423 "Border Gateway Protocol (BGP)\n")
5424
5425DEFUN (ospf_redistribute_source_metric_routemap,
5426 ospf_redistribute_source_metric_routemap_cmd,
5427 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5428 "Redistribute information from another routing protocol\n"
5429 "Kernel routes\n"
5430 "Connected\n"
5431 "Static routes\n"
5432 "Routing Information Protocol (RIP)\n"
5433 "Border Gateway Protocol (BGP)\n"
5434 "Metric for redistributed routes\n"
5435 "OSPF default metric\n"
5436 "Route map reference\n"
5437 "Pointer to route-map entries\n")
5438{
paul020709f2003-04-04 02:44:16 +00005439 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005440 int source;
5441 int metric = -1;
5442
5443 /* Get distribute source. */
5444 if (!str2distribute_source (argv[0], &source))
5445 return CMD_WARNING;
5446
5447 /* Get metric value. */
5448 if (argc >= 2)
5449 if (!str2metric (argv[1], &metric))
5450 return CMD_WARNING;
5451
5452 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005453 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005454 else
paul020709f2003-04-04 02:44:16 +00005455 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005456
paul020709f2003-04-04 02:44:16 +00005457 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005458}
5459
5460DEFUN (ospf_redistribute_source_type_routemap,
5461 ospf_redistribute_source_type_routemap_cmd,
5462 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5463 "Redistribute information from another routing protocol\n"
5464 "Kernel routes\n"
5465 "Connected\n"
5466 "Static routes\n"
5467 "Routing Information Protocol (RIP)\n"
5468 "Border Gateway Protocol (BGP)\n"
5469 "OSPF exterior metric type for redistributed routes\n"
5470 "Set OSPF External Type 1 metrics\n"
5471 "Set OSPF External Type 2 metrics\n"
5472 "Route map reference\n"
5473 "Pointer to route-map entries\n")
5474{
paul020709f2003-04-04 02:44:16 +00005475 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005476 int source;
5477 int type = -1;
5478
5479 /* Get distribute source. */
5480 if (!str2distribute_source (argv[0], &source))
5481 return CMD_WARNING;
5482
5483 /* Get metric value. */
5484 if (argc >= 2)
5485 if (!str2metric_type (argv[1], &type))
5486 return CMD_WARNING;
5487
5488 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005489 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005490 else
paul020709f2003-04-04 02:44:16 +00005491 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005492
paul020709f2003-04-04 02:44:16 +00005493 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005494}
5495
5496DEFUN (ospf_redistribute_source_routemap,
5497 ospf_redistribute_source_routemap_cmd,
5498 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5499 "Redistribute information from another routing protocol\n"
5500 "Kernel routes\n"
5501 "Connected\n"
5502 "Static routes\n"
5503 "Routing Information Protocol (RIP)\n"
5504 "Border Gateway Protocol (BGP)\n"
5505 "Route map reference\n"
5506 "Pointer to route-map entries\n")
5507{
paul020709f2003-04-04 02:44:16 +00005508 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005509 int source;
5510
5511 /* Get distribute source. */
5512 if (!str2distribute_source (argv[0], &source))
5513 return CMD_WARNING;
5514
5515 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005516 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005517 else
paul020709f2003-04-04 02:44:16 +00005518 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005519
paul020709f2003-04-04 02:44:16 +00005520 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005521}
5522
5523DEFUN (no_ospf_redistribute_source,
5524 no_ospf_redistribute_source_cmd,
5525 "no redistribute (kernel|connected|static|rip|bgp)",
5526 NO_STR
5527 "Redistribute information from another routing protocol\n"
5528 "Kernel routes\n"
5529 "Connected\n"
5530 "Static routes\n"
5531 "Routing Information Protocol (RIP)\n"
5532 "Border Gateway Protocol (BGP)\n")
5533{
paul020709f2003-04-04 02:44:16 +00005534 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005535 int source;
5536
5537 if (!str2distribute_source (argv[0], &source))
5538 return CMD_WARNING;
5539
paul020709f2003-04-04 02:44:16 +00005540 ospf_routemap_unset (ospf, source);
5541 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005542}
5543
5544DEFUN (ospf_distribute_list_out,
5545 ospf_distribute_list_out_cmd,
5546 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5547 "Filter networks in routing updates\n"
5548 "Access-list name\n"
5549 OUT_STR
5550 "Kernel routes\n"
5551 "Connected\n"
5552 "Static routes\n"
5553 "Routing Information Protocol (RIP)\n"
5554 "Border Gateway Protocol (BGP)\n")
5555{
paul68980082003-03-25 05:07:42 +00005556 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005557 int source;
5558
5559 /* Get distribute source. */
5560 if (!str2distribute_source (argv[1], &source))
5561 return CMD_WARNING;
5562
paul68980082003-03-25 05:07:42 +00005563 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005564}
5565
5566DEFUN (no_ospf_distribute_list_out,
5567 no_ospf_distribute_list_out_cmd,
5568 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5569 NO_STR
5570 "Filter networks in routing updates\n"
5571 "Access-list name\n"
5572 OUT_STR
5573 "Kernel routes\n"
5574 "Connected\n"
5575 "Static routes\n"
5576 "Routing Information Protocol (RIP)\n"
5577 "Border Gateway Protocol (BGP)\n")
5578{
paul68980082003-03-25 05:07:42 +00005579 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005580 int source;
5581
5582 if (!str2distribute_source (argv[1], &source))
5583 return CMD_WARNING;
5584
paul68980082003-03-25 05:07:42 +00005585 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005586}
5587
5588/* Default information originate. */
5589DEFUN (ospf_default_information_originate_metric_type_routemap,
5590 ospf_default_information_originate_metric_type_routemap_cmd,
5591 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5592 "Control distribution of default information\n"
5593 "Distribute a default route\n"
5594 "OSPF default metric\n"
5595 "OSPF metric\n"
5596 "OSPF metric type for default routes\n"
5597 "Set OSPF External Type 1 metrics\n"
5598 "Set OSPF External Type 2 metrics\n"
5599 "Route map reference\n"
5600 "Pointer to route-map entries\n")
5601{
paul020709f2003-04-04 02:44:16 +00005602 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005603 int type = -1;
5604 int metric = -1;
5605
5606 /* Get metric value. */
5607 if (argc >= 1)
5608 if (!str2metric (argv[0], &metric))
5609 return CMD_WARNING;
5610
5611 /* Get metric type. */
5612 if (argc >= 2)
5613 if (!str2metric_type (argv[1], &type))
5614 return CMD_WARNING;
5615
5616 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005617 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005618 else
paul020709f2003-04-04 02:44:16 +00005619 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005620
paul020709f2003-04-04 02:44:16 +00005621 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5622 type, metric);
paul718e3742002-12-13 20:15:29 +00005623}
5624
5625ALIAS (ospf_default_information_originate_metric_type_routemap,
5626 ospf_default_information_originate_metric_type_cmd,
5627 "default-information originate metric <0-16777214> metric-type (1|2)",
5628 "Control distribution of default information\n"
5629 "Distribute a default route\n"
5630 "OSPF default metric\n"
5631 "OSPF metric\n"
5632 "OSPF metric type for default routes\n"
5633 "Set OSPF External Type 1 metrics\n"
5634 "Set OSPF External Type 2 metrics\n")
5635
5636ALIAS (ospf_default_information_originate_metric_type_routemap,
5637 ospf_default_information_originate_metric_cmd,
5638 "default-information originate metric <0-16777214>",
5639 "Control distribution of default information\n"
5640 "Distribute a default route\n"
5641 "OSPF default metric\n"
5642 "OSPF metric\n")
5643
5644ALIAS (ospf_default_information_originate_metric_type_routemap,
5645 ospf_default_information_originate_cmd,
5646 "default-information originate",
5647 "Control distribution of default information\n"
5648 "Distribute a default route\n")
5649
5650/* Default information originate. */
5651DEFUN (ospf_default_information_originate_metric_routemap,
5652 ospf_default_information_originate_metric_routemap_cmd,
5653 "default-information originate metric <0-16777214> route-map WORD",
5654 "Control distribution of default information\n"
5655 "Distribute a default route\n"
5656 "OSPF default metric\n"
5657 "OSPF metric\n"
5658 "Route map reference\n"
5659 "Pointer to route-map entries\n")
5660{
paul020709f2003-04-04 02:44:16 +00005661 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005662 int metric = -1;
5663
5664 /* Get metric value. */
5665 if (argc >= 1)
5666 if (!str2metric (argv[0], &metric))
5667 return CMD_WARNING;
5668
5669 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005670 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005671 else
paul020709f2003-04-04 02:44:16 +00005672 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005673
paul020709f2003-04-04 02:44:16 +00005674 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5675 -1, metric);
paul718e3742002-12-13 20:15:29 +00005676}
5677
5678/* Default information originate. */
5679DEFUN (ospf_default_information_originate_routemap,
5680 ospf_default_information_originate_routemap_cmd,
5681 "default-information originate route-map WORD",
5682 "Control distribution of default information\n"
5683 "Distribute a default route\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
paul020709f2003-04-04 02:44:16 +00005689 if (argc == 1)
5690 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5691 else
5692 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5693
5694 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005695}
5696
5697DEFUN (ospf_default_information_originate_type_metric_routemap,
5698 ospf_default_information_originate_type_metric_routemap_cmd,
5699 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5700 "Control distribution of default information\n"
5701 "Distribute a default route\n"
5702 "OSPF metric type for default routes\n"
5703 "Set OSPF External Type 1 metrics\n"
5704 "Set OSPF External Type 2 metrics\n"
5705 "OSPF default metric\n"
5706 "OSPF metric\n"
5707 "Route map reference\n"
5708 "Pointer to route-map entries\n")
5709{
paul020709f2003-04-04 02:44:16 +00005710 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005711 int type = -1;
5712 int metric = -1;
5713
5714 /* Get metric type. */
5715 if (argc >= 1)
5716 if (!str2metric_type (argv[0], &type))
5717 return CMD_WARNING;
5718
5719 /* Get metric value. */
5720 if (argc >= 2)
5721 if (!str2metric (argv[1], &metric))
5722 return CMD_WARNING;
5723
5724 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005725 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005726 else
paul020709f2003-04-04 02:44:16 +00005727 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005728
paul020709f2003-04-04 02:44:16 +00005729 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5730 type, metric);
paul718e3742002-12-13 20:15:29 +00005731}
5732
5733ALIAS (ospf_default_information_originate_type_metric_routemap,
5734 ospf_default_information_originate_type_metric_cmd,
5735 "default-information originate metric-type (1|2) metric <0-16777214>",
5736 "Control distribution of default information\n"
5737 "Distribute a default route\n"
5738 "OSPF metric type for default routes\n"
5739 "Set OSPF External Type 1 metrics\n"
5740 "Set OSPF External Type 2 metrics\n"
5741 "OSPF default metric\n"
5742 "OSPF metric\n")
5743
5744ALIAS (ospf_default_information_originate_type_metric_routemap,
5745 ospf_default_information_originate_type_cmd,
5746 "default-information originate metric-type (1|2)",
5747 "Control distribution of default information\n"
5748 "Distribute a default route\n"
5749 "OSPF metric type for default routes\n"
5750 "Set OSPF External Type 1 metrics\n"
5751 "Set OSPF External Type 2 metrics\n")
5752
5753DEFUN (ospf_default_information_originate_type_routemap,
5754 ospf_default_information_originate_type_routemap_cmd,
5755 "default-information originate metric-type (1|2) route-map WORD",
5756 "Control distribution of default information\n"
5757 "Distribute a default route\n"
5758 "OSPF metric type for default routes\n"
5759 "Set OSPF External Type 1 metrics\n"
5760 "Set OSPF External Type 2 metrics\n"
5761 "Route map reference\n"
5762 "Pointer to route-map entries\n")
5763{
paul020709f2003-04-04 02:44:16 +00005764 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005765 int type = -1;
5766
5767 /* Get metric type. */
5768 if (argc >= 1)
5769 if (!str2metric_type (argv[0], &type))
5770 return CMD_WARNING;
5771
5772 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005773 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005774 else
paul020709f2003-04-04 02:44:16 +00005775 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005776
paul020709f2003-04-04 02:44:16 +00005777 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5778 type, -1);
paul718e3742002-12-13 20:15:29 +00005779}
5780
5781DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5782 ospf_default_information_originate_always_metric_type_routemap_cmd,
5783 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5784 "Control distribution of default information\n"
5785 "Distribute a default route\n"
5786 "Always advertise default route\n"
5787 "OSPF default metric\n"
5788 "OSPF metric\n"
5789 "OSPF metric type for default routes\n"
5790 "Set OSPF External Type 1 metrics\n"
5791 "Set OSPF External Type 2 metrics\n"
5792 "Route map reference\n"
5793 "Pointer to route-map entries\n")
5794{
paul020709f2003-04-04 02:44:16 +00005795 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005796 int type = -1;
5797 int metric = -1;
5798
5799 /* Get metric value. */
5800 if (argc >= 1)
5801 if (!str2metric (argv[0], &metric))
5802 return CMD_WARNING;
5803
5804 /* Get metric type. */
5805 if (argc >= 2)
5806 if (!str2metric_type (argv[1], &type))
5807 return CMD_WARNING;
5808
5809 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005810 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005811 else
paul020709f2003-04-04 02:44:16 +00005812 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005813
paul020709f2003-04-04 02:44:16 +00005814 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005815 type, metric);
5816}
5817
5818ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5819 ospf_default_information_originate_always_metric_type_cmd,
5820 "default-information originate always metric <0-16777214> metric-type (1|2)",
5821 "Control distribution of default information\n"
5822 "Distribute a default route\n"
5823 "Always advertise default route\n"
5824 "OSPF default metric\n"
5825 "OSPF metric\n"
5826 "OSPF metric type for default routes\n"
5827 "Set OSPF External Type 1 metrics\n"
5828 "Set OSPF External Type 2 metrics\n")
5829
5830ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5831 ospf_default_information_originate_always_metric_cmd,
5832 "default-information originate always metric <0-16777214>",
5833 "Control distribution of default information\n"
5834 "Distribute a default route\n"
5835 "Always advertise default route\n"
5836 "OSPF default metric\n"
5837 "OSPF metric\n"
5838 "OSPF metric type for default routes\n")
5839
5840ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5841 ospf_default_information_originate_always_cmd,
5842 "default-information originate always",
5843 "Control distribution of default information\n"
5844 "Distribute a default route\n"
5845 "Always advertise default route\n")
5846
5847DEFUN (ospf_default_information_originate_always_metric_routemap,
5848 ospf_default_information_originate_always_metric_routemap_cmd,
5849 "default-information originate always metric <0-16777214> route-map WORD",
5850 "Control distribution of default information\n"
5851 "Distribute a default route\n"
5852 "Always advertise default route\n"
5853 "OSPF default metric\n"
5854 "OSPF metric\n"
5855 "Route map reference\n"
5856 "Pointer to route-map entries\n")
5857{
paul020709f2003-04-04 02:44:16 +00005858 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005859 int metric = -1;
5860
5861 /* Get metric value. */
5862 if (argc >= 1)
5863 if (!str2metric (argv[0], &metric))
5864 return CMD_WARNING;
5865
5866 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005867 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005868 else
paul020709f2003-04-04 02:44:16 +00005869 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005870
paul020709f2003-04-04 02:44:16 +00005871 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5872 -1, metric);
paul718e3742002-12-13 20:15:29 +00005873}
5874
5875DEFUN (ospf_default_information_originate_always_routemap,
5876 ospf_default_information_originate_always_routemap_cmd,
5877 "default-information originate always route-map WORD",
5878 "Control distribution of default information\n"
5879 "Distribute a default route\n"
5880 "Always advertise default route\n"
5881 "Route map reference\n"
5882 "Pointer to route-map entries\n")
5883{
paul020709f2003-04-04 02:44:16 +00005884 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005885
paul020709f2003-04-04 02:44:16 +00005886 if (argc == 1)
5887 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5888 else
5889 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5890
5891 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005892}
5893
5894DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5895 ospf_default_information_originate_always_type_metric_routemap_cmd,
5896 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5897 "Control distribution of default information\n"
5898 "Distribute a default route\n"
5899 "Always advertise default route\n"
5900 "OSPF metric type for default routes\n"
5901 "Set OSPF External Type 1 metrics\n"
5902 "Set OSPF External Type 2 metrics\n"
5903 "OSPF default metric\n"
5904 "OSPF metric\n"
5905 "Route map reference\n"
5906 "Pointer to route-map entries\n")
5907{
paul020709f2003-04-04 02:44:16 +00005908 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005909 int type = -1;
5910 int metric = -1;
5911
5912 /* Get metric type. */
5913 if (argc >= 1)
5914 if (!str2metric_type (argv[0], &type))
5915 return CMD_WARNING;
5916
5917 /* Get metric value. */
5918 if (argc >= 2)
5919 if (!str2metric (argv[1], &metric))
5920 return CMD_WARNING;
5921
5922 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005923 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005924 else
paul020709f2003-04-04 02:44:16 +00005925 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005926
paul020709f2003-04-04 02:44:16 +00005927 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005928 type, metric);
5929}
5930
5931ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5932 ospf_default_information_originate_always_type_metric_cmd,
5933 "default-information originate always metric-type (1|2) metric <0-16777214>",
5934 "Control distribution of default information\n"
5935 "Distribute a default route\n"
5936 "Always advertise default route\n"
5937 "OSPF metric type for default routes\n"
5938 "Set OSPF External Type 1 metrics\n"
5939 "Set OSPF External Type 2 metrics\n"
5940 "OSPF default metric\n"
5941 "OSPF metric\n")
5942
5943ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5944 ospf_default_information_originate_always_type_cmd,
5945 "default-information originate always metric-type (1|2)",
5946 "Control distribution of default information\n"
5947 "Distribute a default route\n"
5948 "Always advertise default route\n"
5949 "OSPF metric type for default routes\n"
5950 "Set OSPF External Type 1 metrics\n"
5951 "Set OSPF External Type 2 metrics\n")
5952
5953DEFUN (ospf_default_information_originate_always_type_routemap,
5954 ospf_default_information_originate_always_type_routemap_cmd,
5955 "default-information originate always metric-type (1|2) route-map WORD",
5956 "Control distribution of default information\n"
5957 "Distribute a default route\n"
5958 "Always advertise default route\n"
5959 "OSPF metric type for default routes\n"
5960 "Set OSPF External Type 1 metrics\n"
5961 "Set OSPF External Type 2 metrics\n"
5962 "Route map reference\n"
5963 "Pointer to route-map entries\n")
5964{
paul020709f2003-04-04 02:44:16 +00005965 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005966 int type = -1;
5967
5968 /* Get metric type. */
5969 if (argc >= 1)
5970 if (!str2metric_type (argv[0], &type))
5971 return CMD_WARNING;
5972
5973 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005974 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005975 else
paul020709f2003-04-04 02:44:16 +00005976 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005977
paul020709f2003-04-04 02:44:16 +00005978 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005979 type, -1);
5980}
5981
5982DEFUN (no_ospf_default_information_originate,
5983 no_ospf_default_information_originate_cmd,
5984 "no default-information originate",
5985 NO_STR
5986 "Control distribution of default information\n"
5987 "Distribute a default route\n")
5988{
paul68980082003-03-25 05:07:42 +00005989 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005990 struct prefix_ipv4 p;
5991 struct in_addr nexthop;
5992
5993 p.family = AF_INET;
5994 p.prefix.s_addr = 0;
5995 p.prefixlen = 0;
5996
paul68980082003-03-25 05:07:42 +00005997 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
paul718e3742002-12-13 20:15:29 +00005998
5999 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6000 ospf_external_info_delete (DEFAULT_ROUTE, p);
6001 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6002 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6003 }
6004
paul020709f2003-04-04 02:44:16 +00006005 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6006 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006007}
6008
6009DEFUN (ospf_default_metric,
6010 ospf_default_metric_cmd,
6011 "default-metric <0-16777214>",
6012 "Set metric of redistributed routes\n"
6013 "Default metric\n")
6014{
paul68980082003-03-25 05:07:42 +00006015 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006016 int metric = -1;
6017
6018 if (!str2metric (argv[0], &metric))
6019 return CMD_WARNING;
6020
paul68980082003-03-25 05:07:42 +00006021 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006022
6023 return CMD_SUCCESS;
6024}
6025
6026DEFUN (no_ospf_default_metric,
6027 no_ospf_default_metric_cmd,
6028 "no default-metric",
6029 NO_STR
6030 "Set metric of redistributed routes\n")
6031{
paul68980082003-03-25 05:07:42 +00006032 struct ospf *ospf = vty->index;
6033
6034 ospf->default_metric = -1;
6035
paul718e3742002-12-13 20:15:29 +00006036 return CMD_SUCCESS;
6037}
6038
6039ALIAS (no_ospf_default_metric,
6040 no_ospf_default_metric_val_cmd,
6041 "no default-metric <0-16777214>",
6042 NO_STR
6043 "Set metric of redistributed routes\n"
6044 "Default metric\n")
6045
6046DEFUN (ospf_distance,
6047 ospf_distance_cmd,
6048 "distance <1-255>",
6049 "Define an administrative distance\n"
6050 "OSPF Administrative distance\n")
6051{
paul68980082003-03-25 05:07:42 +00006052 struct ospf *ospf = vty->index;
6053
6054 ospf->distance_all = atoi (argv[0]);
6055
paul718e3742002-12-13 20:15:29 +00006056 return CMD_SUCCESS;
6057}
6058
6059DEFUN (no_ospf_distance,
6060 no_ospf_distance_cmd,
6061 "no distance <1-255>",
6062 NO_STR
6063 "Define an administrative distance\n"
6064 "OSPF Administrative distance\n")
6065{
paul68980082003-03-25 05:07:42 +00006066 struct ospf *ospf = vty->index;
6067
6068 ospf->distance_all = 0;
6069
paul718e3742002-12-13 20:15:29 +00006070 return CMD_SUCCESS;
6071}
6072
6073DEFUN (no_ospf_distance_ospf,
6074 no_ospf_distance_ospf_cmd,
6075 "no distance ospf",
6076 NO_STR
6077 "Define an administrative distance\n"
6078 "OSPF Administrative distance\n"
6079 "OSPF Distance\n")
6080{
paul68980082003-03-25 05:07:42 +00006081 struct ospf *ospf = vty->index;
6082
6083 ospf->distance_intra = 0;
6084 ospf->distance_inter = 0;
6085 ospf->distance_external = 0;
6086
paul718e3742002-12-13 20:15:29 +00006087 return CMD_SUCCESS;
6088}
6089
6090DEFUN (ospf_distance_ospf_intra,
6091 ospf_distance_ospf_intra_cmd,
6092 "distance ospf intra-area <1-255>",
6093 "Define an administrative distance\n"
6094 "OSPF Administrative distance\n"
6095 "Intra-area routes\n"
6096 "Distance for intra-area routes\n")
6097{
paul68980082003-03-25 05:07:42 +00006098 struct ospf *ospf = vty->index;
6099
6100 ospf->distance_intra = atoi (argv[0]);
6101
paul718e3742002-12-13 20:15:29 +00006102 return CMD_SUCCESS;
6103}
6104
6105DEFUN (ospf_distance_ospf_intra_inter,
6106 ospf_distance_ospf_intra_inter_cmd,
6107 "distance ospf intra-area <1-255> inter-area <1-255>",
6108 "Define an administrative distance\n"
6109 "OSPF Administrative distance\n"
6110 "Intra-area routes\n"
6111 "Distance for intra-area routes\n"
6112 "Inter-area routes\n"
6113 "Distance for inter-area routes\n")
6114{
paul68980082003-03-25 05:07:42 +00006115 struct ospf *ospf = vty->index;
6116
6117 ospf->distance_intra = atoi (argv[0]);
6118 ospf->distance_inter = atoi (argv[1]);
6119
paul718e3742002-12-13 20:15:29 +00006120 return CMD_SUCCESS;
6121}
6122
6123DEFUN (ospf_distance_ospf_intra_external,
6124 ospf_distance_ospf_intra_external_cmd,
6125 "distance ospf intra-area <1-255> external <1-255>",
6126 "Define an administrative distance\n"
6127 "OSPF Administrative distance\n"
6128 "Intra-area routes\n"
6129 "Distance for intra-area routes\n"
6130 "External routes\n"
6131 "Distance for external routes\n")
6132{
paul68980082003-03-25 05:07:42 +00006133 struct ospf *ospf = vty->index;
6134
6135 ospf->distance_intra = atoi (argv[0]);
6136 ospf->distance_external = atoi (argv[1]);
6137
paul718e3742002-12-13 20:15:29 +00006138 return CMD_SUCCESS;
6139}
6140
6141DEFUN (ospf_distance_ospf_intra_inter_external,
6142 ospf_distance_ospf_intra_inter_external_cmd,
6143 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6144 "Define an administrative distance\n"
6145 "OSPF Administrative distance\n"
6146 "Intra-area routes\n"
6147 "Distance for intra-area routes\n"
6148 "Inter-area routes\n"
6149 "Distance for inter-area routes\n"
6150 "External routes\n"
6151 "Distance for external routes\n")
6152{
paul68980082003-03-25 05:07:42 +00006153 struct ospf *ospf = vty->index;
6154
6155 ospf->distance_intra = atoi (argv[0]);
6156 ospf->distance_inter = atoi (argv[1]);
6157 ospf->distance_external = atoi (argv[2]);
6158
paul718e3742002-12-13 20:15:29 +00006159 return CMD_SUCCESS;
6160}
6161
6162DEFUN (ospf_distance_ospf_intra_external_inter,
6163 ospf_distance_ospf_intra_external_inter_cmd,
6164 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6165 "Define an administrative distance\n"
6166 "OSPF Administrative distance\n"
6167 "Intra-area routes\n"
6168 "Distance for intra-area routes\n"
6169 "External routes\n"
6170 "Distance for external routes\n"
6171 "Inter-area routes\n"
6172 "Distance for inter-area routes\n")
6173{
paul68980082003-03-25 05:07:42 +00006174 struct ospf *ospf = vty->index;
6175
6176 ospf->distance_intra = atoi (argv[0]);
6177 ospf->distance_external = atoi (argv[1]);
6178 ospf->distance_inter = atoi (argv[2]);
6179
paul718e3742002-12-13 20:15:29 +00006180 return CMD_SUCCESS;
6181}
6182
6183DEFUN (ospf_distance_ospf_inter,
6184 ospf_distance_ospf_inter_cmd,
6185 "distance ospf inter-area <1-255>",
6186 "Define an administrative distance\n"
6187 "OSPF Administrative distance\n"
6188 "Inter-area routes\n"
6189 "Distance for inter-area routes\n")
6190{
paul68980082003-03-25 05:07:42 +00006191 struct ospf *ospf = vty->index;
6192
6193 ospf->distance_inter = atoi (argv[0]);
6194
paul718e3742002-12-13 20:15:29 +00006195 return CMD_SUCCESS;
6196}
6197
6198DEFUN (ospf_distance_ospf_inter_intra,
6199 ospf_distance_ospf_inter_intra_cmd,
6200 "distance ospf inter-area <1-255> intra-area <1-255>",
6201 "Define an administrative distance\n"
6202 "OSPF Administrative distance\n"
6203 "Inter-area routes\n"
6204 "Distance for inter-area routes\n"
6205 "Intra-area routes\n"
6206 "Distance for intra-area routes\n")
6207{
paul68980082003-03-25 05:07:42 +00006208 struct ospf *ospf = vty->index;
6209
6210 ospf->distance_inter = atoi (argv[0]);
6211 ospf->distance_intra = atoi (argv[1]);
6212
paul718e3742002-12-13 20:15:29 +00006213 return CMD_SUCCESS;
6214}
6215
6216DEFUN (ospf_distance_ospf_inter_external,
6217 ospf_distance_ospf_inter_external_cmd,
6218 "distance ospf inter-area <1-255> external <1-255>",
6219 "Define an administrative distance\n"
6220 "OSPF Administrative distance\n"
6221 "Inter-area routes\n"
6222 "Distance for inter-area routes\n"
6223 "External routes\n"
6224 "Distance for external routes\n")
6225{
paul68980082003-03-25 05:07:42 +00006226 struct ospf *ospf = vty->index;
6227
6228 ospf->distance_inter = atoi (argv[0]);
6229 ospf->distance_external = atoi (argv[1]);
6230
paul718e3742002-12-13 20:15:29 +00006231 return CMD_SUCCESS;
6232}
6233
6234DEFUN (ospf_distance_ospf_inter_intra_external,
6235 ospf_distance_ospf_inter_intra_external_cmd,
6236 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6237 "Define an administrative distance\n"
6238 "OSPF Administrative distance\n"
6239 "Inter-area routes\n"
6240 "Distance for inter-area routes\n"
6241 "Intra-area routes\n"
6242 "Distance for intra-area routes\n"
6243 "External routes\n"
6244 "Distance for external routes\n")
6245{
paul68980082003-03-25 05:07:42 +00006246 struct ospf *ospf = vty->index;
6247
6248 ospf->distance_inter = atoi (argv[0]);
6249 ospf->distance_intra = atoi (argv[1]);
6250 ospf->distance_external = atoi (argv[2]);
6251
paul718e3742002-12-13 20:15:29 +00006252 return CMD_SUCCESS;
6253}
6254
6255DEFUN (ospf_distance_ospf_inter_external_intra,
6256 ospf_distance_ospf_inter_external_intra_cmd,
6257 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6258 "Define an administrative distance\n"
6259 "OSPF Administrative distance\n"
6260 "Inter-area routes\n"
6261 "Distance for inter-area routes\n"
6262 "External routes\n"
6263 "Distance for external routes\n"
6264 "Intra-area routes\n"
6265 "Distance for intra-area routes\n")
6266{
paul68980082003-03-25 05:07:42 +00006267 struct ospf *ospf = vty->index;
6268
6269 ospf->distance_inter = atoi (argv[0]);
6270 ospf->distance_external = atoi (argv[1]);
6271 ospf->distance_intra = atoi (argv[2]);
6272
paul718e3742002-12-13 20:15:29 +00006273 return CMD_SUCCESS;
6274}
6275
6276DEFUN (ospf_distance_ospf_external,
6277 ospf_distance_ospf_external_cmd,
6278 "distance ospf external <1-255>",
6279 "Define an administrative distance\n"
6280 "OSPF Administrative distance\n"
6281 "External routes\n"
6282 "Distance for external routes\n")
6283{
paul68980082003-03-25 05:07:42 +00006284 struct ospf *ospf = vty->index;
6285
6286 ospf->distance_external = atoi (argv[0]);
6287
paul718e3742002-12-13 20:15:29 +00006288 return CMD_SUCCESS;
6289}
6290
6291DEFUN (ospf_distance_ospf_external_intra,
6292 ospf_distance_ospf_external_intra_cmd,
6293 "distance ospf external <1-255> intra-area <1-255>",
6294 "Define an administrative distance\n"
6295 "OSPF Administrative distance\n"
6296 "External routes\n"
6297 "Distance for external routes\n"
6298 "Intra-area routes\n"
6299 "Distance for intra-area routes\n")
6300{
paul68980082003-03-25 05:07:42 +00006301 struct ospf *ospf = vty->index;
6302
6303 ospf->distance_external = atoi (argv[0]);
6304 ospf->distance_intra = atoi (argv[1]);
6305
paul718e3742002-12-13 20:15:29 +00006306 return CMD_SUCCESS;
6307}
6308
6309DEFUN (ospf_distance_ospf_external_inter,
6310 ospf_distance_ospf_external_inter_cmd,
6311 "distance ospf external <1-255> inter-area <1-255>",
6312 "Define an administrative distance\n"
6313 "OSPF Administrative distance\n"
6314 "External routes\n"
6315 "Distance for external routes\n"
6316 "Inter-area routes\n"
6317 "Distance for inter-area routes\n")
6318{
paul68980082003-03-25 05:07:42 +00006319 struct ospf *ospf = vty->index;
6320
6321 ospf->distance_external = atoi (argv[0]);
6322 ospf->distance_inter = atoi (argv[1]);
6323
paul718e3742002-12-13 20:15:29 +00006324 return CMD_SUCCESS;
6325}
6326
6327DEFUN (ospf_distance_ospf_external_intra_inter,
6328 ospf_distance_ospf_external_intra_inter_cmd,
6329 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6330 "Define an administrative distance\n"
6331 "OSPF Administrative distance\n"
6332 "External routes\n"
6333 "Distance for external routes\n"
6334 "Intra-area routes\n"
6335 "Distance for intra-area routes\n"
6336 "Inter-area routes\n"
6337 "Distance for inter-area routes\n")
6338{
paul68980082003-03-25 05:07:42 +00006339 struct ospf *ospf = vty->index;
6340
6341 ospf->distance_external = atoi (argv[0]);
6342 ospf->distance_intra = atoi (argv[1]);
6343 ospf->distance_inter = atoi (argv[2]);
6344
paul718e3742002-12-13 20:15:29 +00006345 return CMD_SUCCESS;
6346}
6347
6348DEFUN (ospf_distance_ospf_external_inter_intra,
6349 ospf_distance_ospf_external_inter_intra_cmd,
6350 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6351 "Define an administrative distance\n"
6352 "OSPF Administrative distance\n"
6353 "External routes\n"
6354 "Distance for external routes\n"
6355 "Inter-area routes\n"
6356 "Distance for inter-area routes\n"
6357 "Intra-area routes\n"
6358 "Distance for intra-area routes\n")
6359{
paul68980082003-03-25 05:07:42 +00006360 struct ospf *ospf = vty->index;
6361
6362 ospf->distance_external = atoi (argv[0]);
6363 ospf->distance_inter = atoi (argv[1]);
6364 ospf->distance_intra = atoi (argv[2]);
6365
paul718e3742002-12-13 20:15:29 +00006366 return CMD_SUCCESS;
6367}
6368
6369DEFUN (ospf_distance_source,
6370 ospf_distance_source_cmd,
6371 "distance <1-255> A.B.C.D/M",
6372 "Administrative distance\n"
6373 "Distance value\n"
6374 "IP source prefix\n")
6375{
paul020709f2003-04-04 02:44:16 +00006376 struct ospf *ospf = vty->index;
6377
6378 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006379
paul718e3742002-12-13 20:15:29 +00006380 return CMD_SUCCESS;
6381}
6382
6383DEFUN (no_ospf_distance_source,
6384 no_ospf_distance_source_cmd,
6385 "no distance <1-255> A.B.C.D/M",
6386 NO_STR
6387 "Administrative distance\n"
6388 "Distance value\n"
6389 "IP source prefix\n")
6390{
paul020709f2003-04-04 02:44:16 +00006391 struct ospf *ospf = vty->index;
6392
6393 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6394
paul718e3742002-12-13 20:15:29 +00006395 return CMD_SUCCESS;
6396}
6397
6398DEFUN (ospf_distance_source_access_list,
6399 ospf_distance_source_access_list_cmd,
6400 "distance <1-255> A.B.C.D/M WORD",
6401 "Administrative distance\n"
6402 "Distance value\n"
6403 "IP source prefix\n"
6404 "Access list name\n")
6405{
paul020709f2003-04-04 02:44:16 +00006406 struct ospf *ospf = vty->index;
6407
6408 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6409
paul718e3742002-12-13 20:15:29 +00006410 return CMD_SUCCESS;
6411}
6412
6413DEFUN (no_ospf_distance_source_access_list,
6414 no_ospf_distance_source_access_list_cmd,
6415 "no distance <1-255> A.B.C.D/M WORD",
6416 NO_STR
6417 "Administrative distance\n"
6418 "Distance value\n"
6419 "IP source prefix\n"
6420 "Access list name\n")
6421{
paul020709f2003-04-04 02:44:16 +00006422 struct ospf *ospf = vty->index;
6423
6424 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6425
paul718e3742002-12-13 20:15:29 +00006426 return CMD_SUCCESS;
6427}
6428
6429void
6430show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6431{
6432 struct route_node *rn;
6433 struct ospf_route *or;
6434 listnode pnode;
6435 struct ospf_path *path;
6436
6437 vty_out (vty, "============ OSPF network routing table ============%s",
6438 VTY_NEWLINE);
6439
6440 for (rn = route_top (rt); rn; rn = route_next (rn))
6441 if ((or = rn->info) != NULL)
6442 {
6443 char buf1[19];
6444 snprintf (buf1, 19, "%s/%d",
6445 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6446
6447 switch (or->path_type)
6448 {
6449 case OSPF_PATH_INTER_AREA:
6450 if (or->type == OSPF_DESTINATION_NETWORK)
6451 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6452 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6453 else if (or->type == OSPF_DESTINATION_DISCARD)
6454 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6455 break;
6456 case OSPF_PATH_INTRA_AREA:
6457 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6458 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6459 break;
6460 default:
6461 break;
6462 }
6463
6464 if (or->type == OSPF_DESTINATION_NETWORK)
paul96735ee2003-08-10 02:51:22 +00006465 LIST_LOOP (or->paths, path, pnode)
6466 {
6467 if (path->oi != NULL)
6468 {
6469 if (path->nexthop.s_addr == 0)
6470 vty_out (vty, "%24s directly attached to %s%s",
6471 "", path->oi->ifp->name, VTY_NEWLINE);
6472 else
6473 vty_out (vty, "%24s via %s, %s%s", "",
6474 inet_ntoa (path->nexthop), path->oi->ifp->name,
6475 VTY_NEWLINE);
6476 }
6477 }
paul718e3742002-12-13 20:15:29 +00006478 }
6479 vty_out (vty, "%s", VTY_NEWLINE);
6480}
6481
6482void
6483show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6484{
6485 struct route_node *rn;
6486 struct ospf_route *or;
6487 listnode pn, nn;
6488 struct ospf_path *path;
6489
6490 vty_out (vty, "============ OSPF router routing table =============%s",
6491 VTY_NEWLINE);
6492 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6493 if (rn->info)
6494 {
6495 int flag = 0;
6496
6497 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6498
6499 for (nn = listhead ((list) rn->info); nn; nextnode (nn))
6500 if ((or = getdata (nn)) != NULL)
6501 {
6502 if (flag++)
paulb0a053b2003-06-22 09:04:47 +00006503 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006504
6505 /* Show path. */
6506 vty_out (vty, "%s [%d] area: %s",
6507 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6508 or->cost, inet_ntoa (or->u.std.area_id));
6509 /* Show flags. */
6510 vty_out (vty, "%s%s%s",
6511 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6512 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6513 VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006514
6515 LIST_LOOP (or->paths, path, pn)
6516 {
6517 if (path->nexthop.s_addr == 0)
6518 vty_out (vty, "%24s directly attached to %s%s",
6519 "", path->oi->ifp->name, VTY_NEWLINE);
6520 else
6521 vty_out (vty, "%24s via %s, %s%s", "",
6522 inet_ntoa (path->nexthop), path->oi->ifp->name,
6523 VTY_NEWLINE);
6524 }
paul718e3742002-12-13 20:15:29 +00006525 }
6526 }
6527 vty_out (vty, "%s", VTY_NEWLINE);
6528}
6529
6530void
6531show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6532{
6533 struct route_node *rn;
6534 struct ospf_route *er;
6535 listnode pnode;
6536 struct ospf_path *path;
6537
6538 vty_out (vty, "============ OSPF external routing table ===========%s",
6539 VTY_NEWLINE);
6540 for (rn = route_top (rt); rn; rn = route_next (rn))
6541 if ((er = rn->info) != NULL)
6542 {
6543 char buf1[19];
6544 snprintf (buf1, 19, "%s/%d",
6545 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6546
6547 switch (er->path_type)
6548 {
6549 case OSPF_PATH_TYPE1_EXTERNAL:
6550 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6551 er->cost, er->u.ext.tag, VTY_NEWLINE);
6552 break;
6553 case OSPF_PATH_TYPE2_EXTERNAL:
6554 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6555 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6556 break;
6557 }
6558
paul96735ee2003-08-10 02:51:22 +00006559 LIST_LOOP (er->paths, path, pnode)
paul718e3742002-12-13 20:15:29 +00006560 {
paul718e3742002-12-13 20:15:29 +00006561 if (path->oi != NULL)
6562 {
6563 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006564 vty_out (vty, "%24s directly attached to %s%s",
6565 "", path->oi->ifp->name, VTY_NEWLINE);
6566 else
6567 vty_out (vty, "%24s via %s, %s%s", "",
6568 inet_ntoa (path->nexthop), path->oi->ifp->name,
6569 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006570 }
6571 }
6572 }
6573 vty_out (vty, "%s", VTY_NEWLINE);
6574}
6575
paul718e3742002-12-13 20:15:29 +00006576DEFUN (show_ip_ospf_border_routers,
6577 show_ip_ospf_border_routers_cmd,
6578 "show ip ospf border-routers",
6579 SHOW_STR
6580 IP_STR
6581 "show all the ABR's and ASBR's\n"
6582 "for this area\n")
6583{
paul020709f2003-04-04 02:44:16 +00006584 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006585
paul020709f2003-04-04 02:44:16 +00006586 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006587 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006588 {
6589 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6590 return CMD_SUCCESS;
6591 }
6592
paul68980082003-03-25 05:07:42 +00006593 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006594 {
6595 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6596 return CMD_SUCCESS;
6597 }
6598
6599 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006600 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006601
6602 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006603 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006604
6605 return CMD_SUCCESS;
6606}
paul718e3742002-12-13 20:15:29 +00006607
6608DEFUN (show_ip_ospf_route,
6609 show_ip_ospf_route_cmd,
6610 "show ip ospf route",
6611 SHOW_STR
6612 IP_STR
6613 "OSPF information\n"
6614 "OSPF routing table\n")
6615{
paul020709f2003-04-04 02:44:16 +00006616 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006617
paul020709f2003-04-04 02:44:16 +00006618 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006619 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006620 {
6621 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6622 return CMD_SUCCESS;
6623 }
6624
paul68980082003-03-25 05:07:42 +00006625 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006626 {
6627 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6628 return CMD_SUCCESS;
6629 }
6630
6631 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006632 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006633
6634 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006635 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006636
6637 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006638 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006639
6640 return CMD_SUCCESS;
6641}
6642
6643
6644char *ospf_abr_type_str[] =
6645{
6646 "unknown",
6647 "standard",
6648 "ibm",
6649 "cisco",
6650 "shortcut"
6651};
6652
6653char *ospf_shortcut_mode_str[] =
6654{
6655 "default",
6656 "enable",
6657 "disable"
6658};
6659
6660
6661void
6662area_id2str (char *buf, int length, struct ospf_area *area)
6663{
6664 memset (buf, 0, length);
6665
6666 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6667 strncpy (buf, inet_ntoa (area->area_id), length);
6668 else
6669 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6670}
6671
6672
6673char *ospf_int_type_str[] =
6674{
6675 "unknown", /* should never be used. */
6676 "point-to-point",
6677 "broadcast",
6678 "non-broadcast",
6679 "point-to-multipoint",
6680 "virtual-link", /* should never be used. */
6681 "loopback"
6682};
6683
6684/* Configuration write function for ospfd. */
6685int
6686config_write_interface (struct vty *vty)
6687{
6688 listnode n1, n2;
6689 struct interface *ifp;
6690 struct crypt_key *ck;
6691 int write = 0;
6692 struct route_node *rn = NULL;
6693 struct ospf_if_params *params;
6694
6695 for (n1 = listhead (iflist); n1; nextnode (n1))
6696 {
6697 ifp = getdata (n1);
6698
6699 if (memcmp (ifp->name, "VLINK", 5) == 0)
6700 continue;
6701
6702 vty_out (vty, "!%s", VTY_NEWLINE);
6703 vty_out (vty, "interface %s%s", ifp->name,
6704 VTY_NEWLINE);
6705 if (ifp->desc)
6706 vty_out (vty, " description %s%s", ifp->desc,
6707 VTY_NEWLINE);
6708
6709 write++;
6710
6711 params = IF_DEF_PARAMS (ifp);
6712
6713 do {
6714 /* Interface Network print. */
6715 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006716 params->type != OSPF_IFTYPE_LOOPBACK)
6717 {
hasso7b901432004-08-31 13:37:42 +00006718 if ((!if_is_broadcast(ifp)) &&
6719 (params->type != OSPF_IFTYPE_BROADCAST))
6720 {
6721 vty_out (vty, " ip ospf network %s",
6722 ospf_int_type_str[params->type]);
6723 if (params != IF_DEF_PARAMS (ifp))
6724 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6725 vty_out (vty, "%s", VTY_NEWLINE);
6726 }
paul718e3742002-12-13 20:15:29 +00006727 }
6728
6729 /* OSPF interface authentication print */
6730 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6731 params->auth_type != OSPF_AUTH_NOTSET)
6732 {
6733 char *auth_str;
6734
6735 /* Translation tables are not that much help here due to syntax
6736 of the simple option */
6737 switch (params->auth_type)
6738 {
6739
6740 case OSPF_AUTH_NULL:
6741 auth_str = " null";
6742 break;
6743
6744 case OSPF_AUTH_SIMPLE:
6745 auth_str = "";
6746 break;
6747
6748 case OSPF_AUTH_CRYPTOGRAPHIC:
6749 auth_str = " message-digest";
6750 break;
6751
6752 default:
6753 auth_str = "";
6754 break;
6755 }
6756
6757 vty_out (vty, " ip ospf authentication%s", auth_str);
6758 if (params != IF_DEF_PARAMS (ifp))
6759 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6760 vty_out (vty, "%s", VTY_NEWLINE);
6761 }
6762
6763 /* Simple Authentication Password print. */
6764 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6765 params->auth_simple[0] != '\0')
6766 {
6767 vty_out (vty, " ip ospf authentication-key %s",
6768 params->auth_simple);
6769 if (params != IF_DEF_PARAMS (ifp))
6770 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6771 vty_out (vty, "%s", VTY_NEWLINE);
6772 }
6773
6774 /* Cryptographic Authentication Key print. */
6775 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
6776 {
6777 ck = getdata (n2);
6778 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6779 ck->key_id, ck->auth_key);
6780 if (params != IF_DEF_PARAMS (ifp))
6781 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6782 vty_out (vty, "%s", VTY_NEWLINE);
6783 }
6784
6785 /* Interface Output Cost print. */
6786 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6787 {
6788 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6789 if (params != IF_DEF_PARAMS (ifp))
6790 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6791 vty_out (vty, "%s", VTY_NEWLINE);
6792 }
6793
6794 /* Hello Interval print. */
6795 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6796 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6797 {
6798 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6799 if (params != IF_DEF_PARAMS (ifp))
6800 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6801 vty_out (vty, "%s", VTY_NEWLINE);
6802 }
6803
6804
6805 /* Router Dead Interval print. */
6806 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6807 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6808 {
6809 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6810 if (params != IF_DEF_PARAMS (ifp))
6811 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6812 vty_out (vty, "%s", VTY_NEWLINE);
6813 }
6814
6815 /* Router Priority print. */
6816 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6817 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6818 {
6819 vty_out (vty, " ip ospf priority %u", params->priority);
6820 if (params != IF_DEF_PARAMS (ifp))
6821 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6822 vty_out (vty, "%s", VTY_NEWLINE);
6823 }
6824
6825 /* Retransmit Interval print. */
6826 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6827 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6828 {
6829 vty_out (vty, " ip ospf retransmit-interval %u",
6830 params->retransmit_interval);
6831 if (params != IF_DEF_PARAMS (ifp))
6832 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6833 vty_out (vty, "%s", VTY_NEWLINE);
6834 }
6835
6836 /* Transmit Delay print. */
6837 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6838 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6839 {
6840 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6841 if (params != IF_DEF_PARAMS (ifp))
6842 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6843 vty_out (vty, "%s", VTY_NEWLINE);
6844 }
6845
6846 while (1)
6847 {
6848 if (rn == NULL)
6849 rn = route_top (IF_OIFS_PARAMS (ifp));
6850 else
6851 rn = route_next (rn);
6852
6853 if (rn == NULL)
6854 break;
6855 params = rn->info;
6856 if (params != NULL)
6857 break;
6858 }
6859 } while (rn);
6860
6861#ifdef HAVE_OPAQUE_LSA
6862 ospf_opaque_config_write_if (vty, ifp);
6863#endif /* HAVE_OPAQUE_LSA */
6864 }
6865
6866 return write;
6867}
6868
6869int
paul68980082003-03-25 05:07:42 +00006870config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006871{
6872 struct route_node *rn;
6873 u_char buf[INET_ADDRSTRLEN];
6874
6875 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006876 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006877 if (rn->info)
6878 {
6879 struct ospf_network *n = rn->info;
6880
6881 memset (buf, 0, INET_ADDRSTRLEN);
6882
6883 /* Create Area ID string by specified Area ID format. */
6884 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6885 strncpy (buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
6886 else
6887 sprintf (buf, "%lu",
6888 (unsigned long int) ntohl (n->area_id.s_addr));
6889
6890 /* Network print. */
6891 vty_out (vty, " network %s/%d area %s%s",
6892 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6893 buf, VTY_NEWLINE);
6894 }
6895
6896 return 0;
6897}
6898
6899int
paul68980082003-03-25 05:07:42 +00006900config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006901{
6902 listnode node;
6903 u_char buf[INET_ADDRSTRLEN];
6904
6905 /* Area configuration print. */
paul68980082003-03-25 05:07:42 +00006906 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00006907 {
6908 struct ospf_area *area = getdata (node);
6909 struct route_node *rn1;
6910
6911 area_id2str (buf, INET_ADDRSTRLEN, area);
6912
6913 if (area->auth_type != OSPF_AUTH_NULL)
6914 {
6915 if (area->auth_type == OSPF_AUTH_SIMPLE)
6916 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6917 else
6918 vty_out (vty, " area %s authentication message-digest%s",
6919 buf, VTY_NEWLINE);
6920 }
6921
6922 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6923 vty_out (vty, " area %s shortcut %s%s", buf,
6924 ospf_shortcut_mode_str[area->shortcut_configured],
6925 VTY_NEWLINE);
6926
6927 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006928 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00006929 )
6930 {
paulb0a053b2003-06-22 09:04:47 +00006931 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006932 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00006933 else if (area->external_routing == OSPF_AREA_NSSA)
6934 {
6935 vty_out (vty, " area %s nssa", buf);
6936 switch (area->NSSATranslatorRole)
6937 {
6938 case OSPF_NSSA_ROLE_NEVER:
6939 vty_out (vty, " translate-never");
6940 break;
6941 case OSPF_NSSA_ROLE_ALWAYS:
6942 vty_out (vty, " translate-always");
6943 break;
6944 case OSPF_NSSA_ROLE_CANDIDATE:
6945 default:
6946 vty_out (vty, " translate-candidate");
6947 }
6948 }
paul718e3742002-12-13 20:15:29 +00006949
6950 if (area->no_summary)
6951 vty_out (vty, " no-summary");
6952
6953 vty_out (vty, "%s", VTY_NEWLINE);
6954
6955 if (area->default_cost != 1)
6956 vty_out (vty, " area %s default-cost %d%s", buf,
6957 area->default_cost, VTY_NEWLINE);
6958 }
6959
6960 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
6961 if (rn1->info)
6962 {
6963 struct ospf_area_range *range = rn1->info;
6964
6965 vty_out (vty, " area %s range %s/%d", buf,
6966 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
6967
6968 if (range->cost_config != -1)
6969 vty_out (vty, " cost %d", range->cost_config);
6970
6971 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
6972 vty_out (vty, " not-advertise");
6973
6974 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
6975 vty_out (vty, " substitute %s/%d",
6976 inet_ntoa (range->subst_addr), range->subst_masklen);
6977
6978 vty_out (vty, "%s", VTY_NEWLINE);
6979 }
6980
6981 if (EXPORT_NAME (area))
6982 vty_out (vty, " area %s export-list %s%s", buf,
6983 EXPORT_NAME (area), VTY_NEWLINE);
6984
6985 if (IMPORT_NAME (area))
6986 vty_out (vty, " area %s import-list %s%s", buf,
6987 IMPORT_NAME (area), VTY_NEWLINE);
6988
6989 if (PREFIX_NAME_IN (area))
6990 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
6991 PREFIX_NAME_IN (area), VTY_NEWLINE);
6992
6993 if (PREFIX_NAME_OUT (area))
6994 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
6995 PREFIX_NAME_OUT (area), VTY_NEWLINE);
6996 }
6997
6998 return 0;
6999}
7000
7001int
paul68980082003-03-25 05:07:42 +00007002config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007003{
7004 struct ospf_nbr_nbma *nbr_nbma;
7005 struct route_node *rn;
7006
7007 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007008 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007009 if ((nbr_nbma = rn->info))
7010 {
7011 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7012
7013 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7014 vty_out (vty, " priority %d", nbr_nbma->priority);
7015
7016 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7017 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7018
7019 vty_out (vty, "%s", VTY_NEWLINE);
7020 }
7021
7022 return 0;
7023}
7024
7025int
paul68980082003-03-25 05:07:42 +00007026config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007027{
7028 listnode node;
7029 u_char buf[INET_ADDRSTRLEN];
7030
7031 /* Virtual-Link print */
paul68980082003-03-25 05:07:42 +00007032 for (node = listhead (ospf->vlinks); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007033 {
7034 listnode n2;
7035 struct crypt_key *ck;
7036 struct ospf_vl_data *vl_data = getdata (node);
7037 struct ospf_interface *oi;
7038
7039 if (vl_data != NULL)
7040 {
7041 memset (buf, 0, INET_ADDRSTRLEN);
7042
7043 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7044 strncpy (buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
7045 else
7046 sprintf (buf, "%lu",
7047 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7048 oi = vl_data->vl_oi;
7049
7050 /* timers */
7051 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7052 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7053 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7054 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7055 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7056 buf,
7057 inet_ntoa (vl_data->vl_peer),
7058 OSPF_IF_PARAM (oi, v_hello),
7059 OSPF_IF_PARAM (oi, retransmit_interval),
7060 OSPF_IF_PARAM (oi, transmit_delay),
7061 OSPF_IF_PARAM (oi, v_wait),
7062 VTY_NEWLINE);
7063 else
7064 vty_out (vty, " area %s virtual-link %s%s", buf,
7065 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7066 /* Auth key */
7067 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7068 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7069 buf,
7070 inet_ntoa (vl_data->vl_peer),
7071 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7072 VTY_NEWLINE);
7073 /* md5 keys */
7074 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
7075 {
7076 ck = getdata (n2);
7077 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
7078 buf,
7079 inet_ntoa (vl_data->vl_peer),
7080 ck->key_id, ck->auth_key, VTY_NEWLINE);
7081 }
7082
7083 }
7084 }
7085
7086 return 0;
7087}
7088
7089
7090char *distribute_str[] = { "system", "kernel", "connected", "static", "rip",
hasso42ed9da2004-03-20 18:59:59 +00007091 "ripng", "ospf", "ospf6", "isis", "bgp"};
paul718e3742002-12-13 20:15:29 +00007092int
paul68980082003-03-25 05:07:42 +00007093config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007094{
7095 int type;
7096
7097 /* redistribute print. */
7098 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7099 if (type != zclient->redist_default && zclient->redist[type])
7100 {
7101 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007102 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007103 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007104
paul68980082003-03-25 05:07:42 +00007105 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007106 vty_out (vty, " metric-type 1");
7107
paul020709f2003-04-04 02:44:16 +00007108 if (ROUTEMAP_NAME (ospf, type))
7109 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007110
7111 vty_out (vty, "%s", VTY_NEWLINE);
7112 }
7113
7114 return 0;
7115}
7116
7117int
paul68980082003-03-25 05:07:42 +00007118config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007119{
paul68980082003-03-25 05:07:42 +00007120 if (ospf->default_metric != -1)
7121 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007122 VTY_NEWLINE);
7123 return 0;
7124}
7125
7126int
paul68980082003-03-25 05:07:42 +00007127config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007128{
7129 int type;
7130
paul68980082003-03-25 05:07:42 +00007131 if (ospf)
paul718e3742002-12-13 20:15:29 +00007132 {
7133 /* distribute-list print. */
7134 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007135 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007136 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007137 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007138 distribute_str[type], VTY_NEWLINE);
7139
7140 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007141 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007142 {
paul68980082003-03-25 05:07:42 +00007143 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007144 vty_out (vty, " default-information originate");
7145 else
7146 vty_out (vty, " default-information originate always");
7147
paul68980082003-03-25 05:07:42 +00007148 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007149 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007150 ospf->dmetric[DEFAULT_ROUTE].value);
7151 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007152 vty_out (vty, " metric-type 1");
7153
paul020709f2003-04-04 02:44:16 +00007154 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7155 vty_out (vty, " route-map %s",
7156 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007157
7158 vty_out (vty, "%s", VTY_NEWLINE);
7159 }
7160
7161 }
7162
7163 return 0;
7164}
7165
7166int
paul68980082003-03-25 05:07:42 +00007167config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007168{
7169 struct route_node *rn;
7170 struct ospf_distance *odistance;
7171
paul68980082003-03-25 05:07:42 +00007172 if (ospf->distance_all)
7173 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007174
paul68980082003-03-25 05:07:42 +00007175 if (ospf->distance_intra
7176 || ospf->distance_inter
7177 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007178 {
7179 vty_out (vty, " distance ospf");
7180
paul68980082003-03-25 05:07:42 +00007181 if (ospf->distance_intra)
7182 vty_out (vty, " intra-area %d", ospf->distance_intra);
7183 if (ospf->distance_inter)
7184 vty_out (vty, " inter-area %d", ospf->distance_inter);
7185 if (ospf->distance_external)
7186 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007187
7188 vty_out (vty, "%s", VTY_NEWLINE);
7189 }
7190
paul68980082003-03-25 05:07:42 +00007191 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007192 if ((odistance = rn->info) != NULL)
7193 {
7194 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7195 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7196 odistance->access_list ? odistance->access_list : "",
7197 VTY_NEWLINE);
7198 }
7199 return 0;
7200}
7201
7202/* OSPF configuration write function. */
7203int
7204ospf_config_write (struct vty *vty)
7205{
paul020709f2003-04-04 02:44:16 +00007206 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00007207 listnode node;
7208 int write = 0;
7209
paul020709f2003-04-04 02:44:16 +00007210 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007211 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007212 {
7213 /* `router ospf' print. */
7214 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7215
7216 write++;
7217
paul68980082003-03-25 05:07:42 +00007218 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007219 return write;
7220
7221 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007222 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007223 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007224 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007225
7226 /* ABR type print. */
paul68980082003-03-25 05:07:42 +00007227 if (ospf->abr_type != OSPF_ABR_STAND)
paul718e3742002-12-13 20:15:29 +00007228 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007229 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007230
7231 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007232 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007233 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7234
7235 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007236 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007237 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007238 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007239
7240 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007241 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7242 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007243 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007244 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007245
7246 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007247 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007248 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007249 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007250
7251 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007252 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007253
7254 /* passive-interface print. */
paul020709f2003-04-04 02:44:16 +00007255 for (node = listhead (om->iflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007256 {
7257 struct interface *ifp = getdata (node);
7258
7259 if (!ifp)
7260 continue;
7261 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7262 vty_out (vty, " passive-interface %s%s",
7263 ifp->name, VTY_NEWLINE);
7264 }
7265
paul68980082003-03-25 05:07:42 +00007266 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007267 {
7268 struct ospf_interface *oi = getdata (node);
7269
7270 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7271 oi->params->passive_interface == OSPF_IF_PASSIVE)
paul96735ee2003-08-10 02:51:22 +00007272 vty_out (vty, " passive-interface %s %s%s",
7273 oi->ifp->name,
paul5fdc1e52003-08-06 22:41:29 +00007274 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007275 }
7276
7277
7278 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007279 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007280
7281 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007282 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007283
7284 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007285 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007286
7287 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007288 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007289
7290 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007291 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007292
7293 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007294 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007295
7296 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007297 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007298
7299#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007300 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007301#endif /* HAVE_OPAQUE_LSA */
7302 }
7303
7304 return write;
7305}
7306
7307void
7308ospf_vty_show_init ()
7309{
7310 /* "show ip ospf" commands. */
7311 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7312 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7313
7314 /* "show ip ospf database" commands. */
7315 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7316 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7317 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7318 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7319 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7320 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7321 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7322 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7323 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7324 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7325 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7326 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7327 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7328 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7329
7330 /* "show ip ospf interface" commands. */
7331 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7332 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7333
7334 /* "show ip ospf neighbor" commands. */
7335 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7336 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7337 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7338 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7339 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7340 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7341 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7342 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7343 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7344 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7345 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7346 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7347 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7348 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7349
7350 /* "show ip ospf route" commands. */
7351 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7352 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007353 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7354 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007355}
7356
7357
7358/* ospfd's interface node. */
7359struct cmd_node interface_node =
7360{
7361 INTERFACE_NODE,
7362 "%s(config-if)# ",
7363 1
7364};
7365
7366/* Initialization of OSPF interface. */
7367void
7368ospf_vty_if_init ()
7369{
7370 /* Install interface node. */
7371 install_node (&interface_node, config_write_interface);
7372
7373 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007374 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007375 install_default (INTERFACE_NODE);
7376
7377 /* "description" commands. */
7378 install_element (INTERFACE_NODE, &interface_desc_cmd);
7379 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7380
7381 /* "ip ospf authentication" commands. */
7382 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7383 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7384 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7385 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7386 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7387 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7388 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7389 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7390 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7391 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7392
7393 /* "ip ospf message-digest-key" commands. */
7394 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7395 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7396 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7397 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7398
7399 /* "ip ospf cost" commands. */
7400 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7401 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7402 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7403 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7404
7405 /* "ip ospf dead-interval" commands. */
7406 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7407 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7408 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7409 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7410
7411 /* "ip ospf hello-interval" commands. */
7412 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7413 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7414 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7415 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7416
7417 /* "ip ospf network" commands. */
7418 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7419 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7420
7421 /* "ip ospf priority" commands. */
7422 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7423 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7424 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7425 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7426
7427 /* "ip ospf retransmit-interval" commands. */
7428 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7429 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7430 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7431 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7432
7433 /* "ip ospf transmit-delay" commands. */
7434 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7435 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7436 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7437 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7438
7439 /* These commands are compatibitliy for previous version. */
7440 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7441 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7442 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7443 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7444 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7445 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7446 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7447 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7448 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7449 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7450 install_element (INTERFACE_NODE, &ospf_network_cmd);
7451 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7452 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7453 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7454 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7455 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7456 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7457 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7458}
7459
7460/* Zebra node structure. */
7461struct cmd_node zebra_node =
7462{
7463 ZEBRA_NODE,
7464 "%s(config-router)#",
7465};
7466
7467void
7468ospf_vty_zebra_init ()
7469{
7470 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7471 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7472 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7473 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7474 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7475 install_element (OSPF_NODE,
7476 &ospf_redistribute_source_metric_type_routemap_cmd);
7477 install_element (OSPF_NODE,
7478 &ospf_redistribute_source_type_metric_routemap_cmd);
7479 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7480 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7481 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7482
7483 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7484
7485 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7486 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7487
7488 install_element (OSPF_NODE,
7489 &ospf_default_information_originate_metric_type_cmd);
7490 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7491 install_element (OSPF_NODE,
7492 &ospf_default_information_originate_type_metric_cmd);
7493 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7494 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7495 install_element (OSPF_NODE,
7496 &ospf_default_information_originate_always_metric_type_cmd);
7497 install_element (OSPF_NODE,
7498 &ospf_default_information_originate_always_metric_cmd);
7499 install_element (OSPF_NODE,
7500 &ospf_default_information_originate_always_cmd);
7501 install_element (OSPF_NODE,
7502 &ospf_default_information_originate_always_type_metric_cmd);
7503 install_element (OSPF_NODE,
7504 &ospf_default_information_originate_always_type_cmd);
7505
7506 install_element (OSPF_NODE,
7507 &ospf_default_information_originate_metric_type_routemap_cmd);
7508 install_element (OSPF_NODE,
7509 &ospf_default_information_originate_metric_routemap_cmd);
7510 install_element (OSPF_NODE,
7511 &ospf_default_information_originate_routemap_cmd);
7512 install_element (OSPF_NODE,
7513 &ospf_default_information_originate_type_metric_routemap_cmd);
7514 install_element (OSPF_NODE,
7515 &ospf_default_information_originate_type_routemap_cmd);
7516 install_element (OSPF_NODE,
7517 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7518 install_element (OSPF_NODE,
7519 &ospf_default_information_originate_always_metric_routemap_cmd);
7520 install_element (OSPF_NODE,
7521 &ospf_default_information_originate_always_routemap_cmd);
7522 install_element (OSPF_NODE,
7523 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7524 install_element (OSPF_NODE,
7525 &ospf_default_information_originate_always_type_routemap_cmd);
7526
7527 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7528
7529 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7530 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7531 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7532
7533 install_element (OSPF_NODE, &ospf_distance_cmd);
7534 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7535 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7536 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7537 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7538 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7539 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7540 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7541 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7542 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7543 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7544 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7545 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7546 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7547 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7548 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7549 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7550 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7551#if 0
7552 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7553 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7554 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7555 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7556#endif /* 0 */
7557}
7558
7559struct cmd_node ospf_node =
7560{
7561 OSPF_NODE,
7562 "%s(config-router)# ",
7563 1
7564};
7565
7566
7567/* Install OSPF related vty commands. */
7568void
7569ospf_vty_init ()
7570{
7571 /* Install ospf top node. */
7572 install_node (&ospf_node, ospf_config_write);
7573
7574 /* "router ospf" commands. */
7575 install_element (CONFIG_NODE, &router_ospf_cmd);
7576 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7577
7578 install_default (OSPF_NODE);
7579
7580 /* "ospf router-id" commands. */
7581 install_element (OSPF_NODE, &ospf_router_id_cmd);
7582 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007583 install_element (OSPF_NODE, &router_ospf_id_cmd);
7584 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007585
7586 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007587 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7588 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7589 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7590 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007591
7592 /* "ospf abr-type" commands. */
7593 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7594 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7595
7596 /* "ospf rfc1583-compatible" commands. */
7597 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7598 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7599 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7600 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7601
7602 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007603 install_element (OSPF_NODE, &ospf_network_area_cmd);
7604 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007605
7606 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007607 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7608 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7609 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007610
7611 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007612 install_element (OSPF_NODE, &ospf_area_range_cmd);
7613 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7614 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7615 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7616 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7617 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7618 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7619 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7620 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7621 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7622 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007623
7624 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007625 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7626 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007627
paula2c62832003-04-23 17:01:31 +00007628 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7629 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007630
paula2c62832003-04-23 17:01:31 +00007631 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7632 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007633
paula2c62832003-04-23 17:01:31 +00007634 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7635 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007636
paula2c62832003-04-23 17:01:31 +00007637 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7638 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007639
paula2c62832003-04-23 17:01:31 +00007640 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7641 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7642 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007643
paula2c62832003-04-23 17:01:31 +00007644 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7645 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007646
paula2c62832003-04-23 17:01:31 +00007647 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7648 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007649
paula2c62832003-04-23 17:01:31 +00007650 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7651 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7652 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007653
paula2c62832003-04-23 17:01:31 +00007654 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7655 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7656 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007657
7658 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007659 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7660 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7661 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7662 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007663
paul718e3742002-12-13 20:15:29 +00007664 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007665 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7666 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7667 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7668 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7669 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7670 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007671
paula2c62832003-04-23 17:01:31 +00007672 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7673 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007674
paula2c62832003-04-23 17:01:31 +00007675 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7676 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007677
paula2c62832003-04-23 17:01:31 +00007678 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7679 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007680
paula2c62832003-04-23 17:01:31 +00007681 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7682 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007683
paula2c62832003-04-23 17:01:31 +00007684 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7685 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007686
paula2c62832003-04-23 17:01:31 +00007687 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7688 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007689
paula2c62832003-04-23 17:01:31 +00007690 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7691 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7692 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007693
paula2c62832003-04-23 17:01:31 +00007694 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7695 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007696
7697 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007698 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7699 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7700 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7701 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7702 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7703 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7704 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7705 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007706
7707 /* Init interface related vty commands. */
7708 ospf_vty_if_init ();
7709
7710 /* Init zebra related vty commands. */
7711 ospf_vty_zebra_init ();
7712}