blob: d02214dd7dfbbb1e57722789eb049fff47c4e440 [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),
678#ifdef HAVE_NSSA
679 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
680#else
681 "stub",
682#endif /* HAVE_NSSA */
683 VTY_NEWLINE);
684 else
685 vty_out (vty, "Area %ld is %s%s",
686 (u_long)ntohl (area_id.s_addr),
687#ifdef HAVE_NSSA
688 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
689#else
690 "stub",
691#endif /* HAVE_NSSA */
692 VTY_NEWLINE);
693 return NULL;
694 }
695
696 if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)
697 {
698 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
699 if (vl_data->vl_oi == NULL)
700 {
paul68980082003-03-25 05:07:42 +0000701 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
702 ospf_vl_add (ospf, vl_data);
703 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000704 }
705 }
706 return vl_data;
707}
708
709
710int
711ospf_vl_set_security (struct ospf_vl_data *vl_data,
712 struct ospf_vl_config_data *vl_config)
713{
714 struct crypt_key *ck;
715 struct vty *vty;
716 struct interface *ifp = vl_data->vl_oi->ifp;
717
718 vty = vl_config->vty;
719
720 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
721 {
722 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
723 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
724 }
725
726 if (vl_config->auth_key)
727 {
728 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
729 strncpy (IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
730 OSPF_AUTH_SIMPLE_SIZE);
731 }
732 else if (vl_config->md5_key)
733 {
734 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
735 != NULL)
736 {
737 vty_out (vty, "OSPF: Key %d already exists%s",
738 vl_config->crypto_key_id, VTY_NEWLINE);
739 return CMD_WARNING;
740 }
741 ck = ospf_crypt_key_new ();
742 ck->key_id = vl_config->crypto_key_id;
743 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
744 strncpy (ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
745
746 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
747 }
748 else if (vl_config->crypto_key_id != 0)
749 {
750 /* Delete a key */
751
752 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
753 vl_config->crypto_key_id) == NULL)
754 {
755 vty_out (vty, "OSPF: Key %d does not exist%s",
756 vl_config->crypto_key_id, VTY_NEWLINE);
757 return CMD_WARNING;
758 }
759
760 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
761
762 }
763
764 return CMD_SUCCESS;
765}
766
767
768
769int
770ospf_vl_set_timers (struct ospf_vl_data *vl_data,
771 struct ospf_vl_config_data *vl_config)
772{
773 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
774 /* Virtual Link data initialised to defaults, so only set
775 if a value given */
776 if (vl_config->hello_interval)
777 {
778 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
779 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
780 }
781
782 if (vl_config->dead_interval)
783 {
784 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
785 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
786 }
787
788 if (vl_config->retransmit_interval)
789 {
790 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
791 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
792 }
793
794 if (vl_config->transmit_delay)
795 {
796 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
797 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
798 }
799
800 return CMD_SUCCESS;
801}
802
803
804
805/* The business end of all of the above */
806int
paul68980082003-03-25 05:07:42 +0000807ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000808{
809 struct ospf_vl_data *vl_data;
810 int ret;
811
paul68980082003-03-25 05:07:42 +0000812 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000813 if (!vl_data)
814 return CMD_WARNING;
815
816 /* Process this one first as it can have a fatal result, which can
817 only logically occur if the virtual link exists already
818 Thus a command error does not result in a change to the
819 running configuration such as unexpectedly altered timer
820 values etc.*/
821 ret = ospf_vl_set_security (vl_data, vl_config);
822 if (ret != CMD_SUCCESS)
823 return ret;
824
825 /* Set any time based parameters, these area already range checked */
826
827 ret = ospf_vl_set_timers (vl_data, vl_config);
828 if (ret != CMD_SUCCESS)
829 return ret;
830
831 return CMD_SUCCESS;
832
833}
834
835/* This stuff exists to make specifying all the alias commands A LOT simpler
836 */
837#define VLINK_HELPSTR_IPADDR \
838 "OSPF area parameters\n" \
839 "OSPF area ID in IP address format\n" \
840 "OSPF area ID as a decimal value\n" \
841 "Configure a virtual link\n" \
842 "Router ID of the remote ABR\n"
843
844#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
845 "Enable authentication on this virtual link\n" \
846 "dummy string \n"
847
848#define VLINK_HELPSTR_AUTHTYPE_ALL \
849 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
850 "Use null authentication\n" \
851 "Use message-digest authentication\n"
852
853#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
854 "Time between HELLO packets\n" \
855 "Time between retransmitting lost link state advertisements\n" \
856 "Link state transmit delay\n" \
857 "Interval after which a neighbor is declared dead\n"
858
859#define VLINK_HELPSTR_TIME_PARAM \
860 VLINK_HELPSTR_TIME_PARAM_NOSECS \
861 "Seconds\n"
862
863#define VLINK_HELPSTR_AUTH_SIMPLE \
864 "Authentication password (key)\n" \
865 "The OSPF password (key)"
866
867#define VLINK_HELPSTR_AUTH_MD5 \
868 "Message digest authentication password (key)\n" \
869 "dummy string \n" \
870 "Key ID\n" \
871 "Use MD5 algorithm\n" \
872 "The OSPF password (key)"
873
paula2c62832003-04-23 17:01:31 +0000874DEFUN (ospf_area_vlink,
875 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000876 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
877 VLINK_HELPSTR_IPADDR)
878{
paul68980082003-03-25 05:07:42 +0000879 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000880 struct ospf_vl_config_data vl_config;
881 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
882 char md5_key[OSPF_AUTH_MD5_SIZE+1];
883 int i;
884 int ret;
885
886 ospf_vl_config_data_init(&vl_config, vty);
887
888 /* Read off first 2 parameters and check them */
889 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
890 if (ret < 0)
891 {
892 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
893 return CMD_WARNING;
894 }
895
896 ret = inet_aton (argv[1], &vl_config.vl_peer);
897 if (! ret)
898 {
899 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
900 VTY_NEWLINE);
901 return CMD_WARNING;
902 }
903
904 if (argc <=2)
905 {
906 /* Thats all folks! - BUGS B. strikes again!!!*/
907
paul68980082003-03-25 05:07:42 +0000908 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000909 }
910
911 /* Deal with other parameters */
912 for (i=2; i < argc; i++)
913 {
914
915 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
916
917 switch (argv[i][0])
918 {
919
920 case 'a':
921 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
922 {
923 /* authentication-key - this option can occur anywhere on
924 command line. At start of command line
925 must check for authentication option. */
926 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
927 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
928 vl_config.auth_key = auth_key;
929 i++;
930 }
931 else if (strncmp (argv[i], "authentication", 14) == 0)
932 {
933 /* authentication - this option can only occur at start
934 of command line */
935 vl_config.auth_type = OSPF_AUTH_SIMPLE;
936 if ((i+1) < argc)
937 {
938 if (strncmp (argv[i+1], "n", 1) == 0)
939 {
940 /* "authentication null" */
941 vl_config.auth_type = OSPF_AUTH_NULL;
942 i++;
943 }
944 else if (strncmp (argv[i+1], "m", 1) == 0
945 && strcmp (argv[i+1], "message-digest-") != 0)
946 {
947 /* "authentication message-digest" */
948 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
949 i++;
950 }
951 }
952 }
953 break;
954
955 case 'm':
956 /* message-digest-key */
957 i++;
958 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
959 if (vl_config.crypto_key_id < 0)
960 return CMD_WARNING;
961 i++;
962 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
963 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
964 vl_config.md5_key = md5_key;
965 break;
966
967 case 'h':
968 /* Hello interval */
969 i++;
970 vl_config.hello_interval = strtol (argv[i], NULL, 10);
971 if (vl_config.hello_interval < 0)
972 return CMD_WARNING;
973 break;
974
975 case 'r':
976 /* Retransmit Interval */
977 i++;
978 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
979 if (vl_config.retransmit_interval < 0)
980 return CMD_WARNING;
981 break;
982
983 case 't':
984 /* Transmit Delay */
985 i++;
986 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
987 if (vl_config.transmit_delay < 0)
988 return CMD_WARNING;
989 break;
990
991 case 'd':
992 /* Dead Interval */
993 i++;
994 vl_config.dead_interval = strtol (argv[i], NULL, 10);
995 if (vl_config.dead_interval < 0)
996 return CMD_WARNING;
997 break;
998 }
999 }
1000
1001
1002 /* Action configuration */
1003
paul68980082003-03-25 05:07:42 +00001004 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001005
1006}
1007
paula2c62832003-04-23 17:01:31 +00001008DEFUN (no_ospf_area_vlink,
1009 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001010 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1011 NO_STR
1012 VLINK_HELPSTR_IPADDR)
1013{
paul68980082003-03-25 05:07:42 +00001014 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001015 struct ospf_area *area;
1016 struct ospf_vl_config_data vl_config;
1017 struct ospf_vl_data *vl_data = NULL;
1018 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1019 int i;
1020 int ret, format;
1021
1022 ospf_vl_config_data_init(&vl_config, vty);
1023
1024 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1025 if (ret < 0)
1026 {
1027 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1028 return CMD_WARNING;
1029 }
1030
paul68980082003-03-25 05:07:42 +00001031 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001032 if (!area)
1033 {
1034 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1035 return CMD_WARNING;
1036 }
1037
1038 ret = inet_aton (argv[1], &vl_config.vl_peer);
1039 if (! ret)
1040 {
1041 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1042 VTY_NEWLINE);
1043 return CMD_WARNING;
1044 }
1045
1046 if (argc <=2)
1047 {
1048 /* Basic VLink no command */
1049 /* Thats all folks! - BUGS B. strikes again!!!*/
1050 if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001051 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001052
paul68980082003-03-25 05:07:42 +00001053 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001054
1055 return CMD_SUCCESS;
1056 }
1057
1058 /* If we are down here, we are reseting parameters */
1059
1060 /* Deal with other parameters */
1061 for (i=2; i < argc; i++)
1062 {
paul718e3742002-12-13 20:15:29 +00001063 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1064
1065 switch (argv[i][0])
1066 {
1067
1068 case 'a':
1069 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1070 {
1071 /* authentication-key - this option can occur anywhere on
1072 command line. At start of command line
1073 must check for authentication option. */
1074 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1075 vl_config.auth_key = auth_key;
1076 }
1077 else if (strncmp (argv[i], "authentication", 14) == 0)
1078 {
1079 /* authentication - this option can only occur at start
1080 of command line */
1081 vl_config.auth_type = OSPF_AUTH_NOTSET;
1082 }
1083 break;
1084
1085 case 'm':
1086 /* message-digest-key */
1087 /* Delete one key */
1088 i++;
1089 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1090 if (vl_config.crypto_key_id < 0)
1091 return CMD_WARNING;
1092 vl_config.md5_key = NULL;
1093 break;
1094
1095 case 'h':
1096 /* Hello interval */
1097 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1098 break;
1099
1100 case 'r':
1101 /* Retransmit Interval */
1102 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1103 break;
1104
1105 case 't':
1106 /* Transmit Delay */
1107 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1108 break;
1109
1110 case 'd':
1111 /* Dead Interval */
1112 i++;
1113 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1114 break;
1115 }
1116 }
1117
1118
1119 /* Action configuration */
1120
paul68980082003-03-25 05:07:42 +00001121 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001122}
1123
paula2c62832003-04-23 17:01:31 +00001124ALIAS (ospf_area_vlink,
1125 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001126 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1127 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1128 VLINK_HELPSTR_IPADDR
1129 VLINK_HELPSTR_TIME_PARAM)
1130
paula2c62832003-04-23 17:01:31 +00001131ALIAS (no_ospf_area_vlink,
1132 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001133 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1134 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1135 NO_STR
1136 VLINK_HELPSTR_IPADDR
1137 VLINK_HELPSTR_TIME_PARAM)
1138
paula2c62832003-04-23 17:01:31 +00001139ALIAS (ospf_area_vlink,
1140 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001141 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1142 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1143 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1144 VLINK_HELPSTR_IPADDR
1145 VLINK_HELPSTR_TIME_PARAM
1146 VLINK_HELPSTR_TIME_PARAM)
1147
paula2c62832003-04-23 17:01:31 +00001148ALIAS (no_ospf_area_vlink,
1149 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001150 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1151 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1152 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1153 NO_STR
1154 VLINK_HELPSTR_IPADDR
1155 VLINK_HELPSTR_TIME_PARAM
1156 VLINK_HELPSTR_TIME_PARAM)
1157
paula2c62832003-04-23 17:01:31 +00001158ALIAS (ospf_area_vlink,
1159 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001160 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1161 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1162 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1163 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1164 VLINK_HELPSTR_IPADDR
1165 VLINK_HELPSTR_TIME_PARAM
1166 VLINK_HELPSTR_TIME_PARAM
1167 VLINK_HELPSTR_TIME_PARAM)
1168
paula2c62832003-04-23 17:01:31 +00001169ALIAS (no_ospf_area_vlink,
1170 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001171 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1172 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1173 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1174 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1175 NO_STR
1176 VLINK_HELPSTR_IPADDR
1177 VLINK_HELPSTR_TIME_PARAM
1178 VLINK_HELPSTR_TIME_PARAM
1179 VLINK_HELPSTR_TIME_PARAM)
1180
paula2c62832003-04-23 17:01:31 +00001181ALIAS (ospf_area_vlink,
1182 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001183 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1184 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1185 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1186 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1187 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1188 VLINK_HELPSTR_IPADDR
1189 VLINK_HELPSTR_TIME_PARAM
1190 VLINK_HELPSTR_TIME_PARAM
1191 VLINK_HELPSTR_TIME_PARAM
1192 VLINK_HELPSTR_TIME_PARAM)
1193
paula2c62832003-04-23 17:01:31 +00001194ALIAS (no_ospf_area_vlink,
1195 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001196 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1197 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1198 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1199 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1200 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1201 NO_STR
1202 VLINK_HELPSTR_IPADDR
1203 VLINK_HELPSTR_TIME_PARAM
1204 VLINK_HELPSTR_TIME_PARAM
1205 VLINK_HELPSTR_TIME_PARAM
1206 VLINK_HELPSTR_TIME_PARAM)
1207
paula2c62832003-04-23 17:01:31 +00001208ALIAS (ospf_area_vlink,
1209 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001210 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1211 "(authentication|) (message-digest|null)",
1212 VLINK_HELPSTR_IPADDR
1213 VLINK_HELPSTR_AUTHTYPE_ALL)
1214
paula2c62832003-04-23 17:01:31 +00001215ALIAS (ospf_area_vlink,
1216 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001217 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1218 "(authentication|)",
1219 VLINK_HELPSTR_IPADDR
1220 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1221
paula2c62832003-04-23 17:01:31 +00001222ALIAS (no_ospf_area_vlink,
1223 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001224 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1225 "(authentication|)",
1226 NO_STR
1227 VLINK_HELPSTR_IPADDR
1228 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1229
paula2c62832003-04-23 17:01:31 +00001230ALIAS (ospf_area_vlink,
1231 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001232 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1233 "(message-digest-key|) <1-255> md5 KEY",
1234 VLINK_HELPSTR_IPADDR
1235 VLINK_HELPSTR_AUTH_MD5)
1236
paula2c62832003-04-23 17:01:31 +00001237ALIAS (no_ospf_area_vlink,
1238 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001239 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1240 "(message-digest-key|) <1-255>",
1241 NO_STR
1242 VLINK_HELPSTR_IPADDR
1243 VLINK_HELPSTR_AUTH_MD5)
1244
paula2c62832003-04-23 17:01:31 +00001245ALIAS (ospf_area_vlink,
1246 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001247 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1248 "(authentication-key|) AUTH_KEY",
1249 VLINK_HELPSTR_IPADDR
1250 VLINK_HELPSTR_AUTH_SIMPLE)
1251
paula2c62832003-04-23 17:01:31 +00001252ALIAS (no_ospf_area_vlink,
1253 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001254 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1255 "(authentication-key|)",
1256 NO_STR
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_AUTH_SIMPLE)
1259
paula2c62832003-04-23 17:01:31 +00001260ALIAS (ospf_area_vlink,
1261 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001262 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1263 "(authentication|) (message-digest|null) "
1264 "(authentication-key|) AUTH_KEY",
1265 VLINK_HELPSTR_IPADDR
1266 VLINK_HELPSTR_AUTHTYPE_ALL
1267 VLINK_HELPSTR_AUTH_SIMPLE)
1268
paula2c62832003-04-23 17:01:31 +00001269ALIAS (ospf_area_vlink,
1270 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001271 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1272 "(authentication|) "
1273 "(authentication-key|) AUTH_KEY",
1274 VLINK_HELPSTR_IPADDR
1275 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1276 VLINK_HELPSTR_AUTH_SIMPLE)
1277
paula2c62832003-04-23 17:01:31 +00001278ALIAS (no_ospf_area_vlink,
1279 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001280 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1281 "(authentication|) "
1282 "(authentication-key|)",
1283 NO_STR
1284 VLINK_HELPSTR_IPADDR
1285 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1286 VLINK_HELPSTR_AUTH_SIMPLE)
1287
paula2c62832003-04-23 17:01:31 +00001288ALIAS (ospf_area_vlink,
1289 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001290 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1291 "(authentication|) (message-digest|null) "
1292 "(message-digest-key|) <1-255> md5 KEY",
1293 VLINK_HELPSTR_IPADDR
1294 VLINK_HELPSTR_AUTHTYPE_ALL
1295 VLINK_HELPSTR_AUTH_MD5)
1296
paula2c62832003-04-23 17:01:31 +00001297ALIAS (ospf_area_vlink,
1298 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001299 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1300 "(authentication|) "
1301 "(message-digest-key|) <1-255> md5 KEY",
1302 VLINK_HELPSTR_IPADDR
1303 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1304 VLINK_HELPSTR_AUTH_MD5)
1305
paula2c62832003-04-23 17:01:31 +00001306ALIAS (no_ospf_area_vlink,
1307 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001308 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1309 "(authentication|) "
1310 "(message-digest-key|)",
1311 NO_STR
1312 VLINK_HELPSTR_IPADDR
1313 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1314 VLINK_HELPSTR_AUTH_MD5)
1315
1316
paula2c62832003-04-23 17:01:31 +00001317DEFUN (ospf_area_shortcut,
1318 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001319 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1320 "OSPF area parameters\n"
1321 "OSPF area ID in IP address format\n"
1322 "OSPF area ID as a decimal value\n"
1323 "Configure the area's shortcutting mode\n"
1324 "Set default shortcutting behavior\n"
1325 "Enable shortcutting through the area\n"
1326 "Disable shortcutting through the area\n")
1327{
paul68980082003-03-25 05:07:42 +00001328 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001329 struct ospf_area *area;
1330 struct in_addr area_id;
1331 int mode;
1332 int format;
1333
1334 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1335
paul68980082003-03-25 05:07:42 +00001336 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001337
1338 if (strncmp (argv[1], "de", 2) == 0)
1339 mode = OSPF_SHORTCUT_DEFAULT;
1340 else if (strncmp (argv[1], "di", 2) == 0)
1341 mode = OSPF_SHORTCUT_DISABLE;
1342 else if (strncmp (argv[1], "e", 1) == 0)
1343 mode = OSPF_SHORTCUT_ENABLE;
1344 else
1345 return CMD_WARNING;
1346
paul68980082003-03-25 05:07:42 +00001347 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001348
paul68980082003-03-25 05:07:42 +00001349 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001350 vty_out (vty, "Shortcut area setting will take effect "
1351 "only when the router is configured as Shortcut ABR%s",
1352 VTY_NEWLINE);
1353
1354 return CMD_SUCCESS;
1355}
1356
paula2c62832003-04-23 17:01:31 +00001357DEFUN (no_ospf_area_shortcut,
1358 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001359 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1360 NO_STR
1361 "OSPF area parameters\n"
1362 "OSPF area ID in IP address format\n"
1363 "OSPF area ID as a decimal value\n"
1364 "Deconfigure the area's shortcutting mode\n"
1365 "Deconfigure enabled shortcutting through the area\n"
1366 "Deconfigure disabled shortcutting through the area\n")
1367{
paul68980082003-03-25 05:07:42 +00001368 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001369 struct ospf_area *area;
1370 struct in_addr area_id;
1371 int format;
1372
1373 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1374
paul68980082003-03-25 05:07:42 +00001375 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001376 if (!area)
1377 return CMD_SUCCESS;
1378
paul68980082003-03-25 05:07:42 +00001379 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001380
1381 return CMD_SUCCESS;
1382}
1383
1384
paula2c62832003-04-23 17:01:31 +00001385DEFUN (ospf_area_stub,
1386 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001387 "area (A.B.C.D|<0-4294967295>) stub",
1388 "OSPF area parameters\n"
1389 "OSPF area ID in IP address format\n"
1390 "OSPF area ID as a decimal value\n"
1391 "Configure OSPF area as stub\n")
1392{
1393 struct ospf *ospf = vty->index;
1394 struct in_addr area_id;
1395 int ret, format;
1396
1397 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1398
1399 ret = ospf_area_stub_set (ospf, area_id);
1400 if (ret == 0)
1401 {
1402 vty_out (vty, "First deconfigure all virtual link through this area%s",
1403 VTY_NEWLINE);
1404 return CMD_WARNING;
1405 }
1406
1407 ospf_area_no_summary_unset (ospf, area_id);
1408
1409 return CMD_SUCCESS;
1410}
1411
paula2c62832003-04-23 17:01:31 +00001412DEFUN (ospf_area_stub_no_summary,
1413 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001414 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1415 "OSPF stub parameters\n"
1416 "OSPF area ID in IP address format\n"
1417 "OSPF area ID as a decimal value\n"
1418 "Configure OSPF area as stub\n"
1419 "Do not inject inter-area routes into stub\n")
1420{
1421 struct ospf *ospf = vty->index;
1422 struct in_addr area_id;
1423 int ret, format;
1424
1425 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1426
1427 ret = ospf_area_stub_set (ospf, area_id);
1428 if (ret == 0)
1429 {
paulb0a053b2003-06-22 09:04:47 +00001430 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001431 VTY_NEWLINE);
1432 return CMD_WARNING;
1433 }
1434
1435 ospf_area_no_summary_set (ospf, area_id);
1436
1437 return CMD_SUCCESS;
1438}
1439
paula2c62832003-04-23 17:01:31 +00001440DEFUN (no_ospf_area_stub,
1441 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001442 "no area (A.B.C.D|<0-4294967295>) stub",
1443 NO_STR
1444 "OSPF area parameters\n"
1445 "OSPF area ID in IP address format\n"
1446 "OSPF area ID as a decimal value\n"
1447 "Configure OSPF area as stub\n")
1448{
1449 struct ospf *ospf = vty->index;
1450 struct in_addr area_id;
1451 int format;
1452
1453 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1454
1455 ospf_area_stub_unset (ospf, area_id);
1456 ospf_area_no_summary_unset (ospf, area_id);
1457
1458 return CMD_SUCCESS;
1459}
1460
paula2c62832003-04-23 17:01:31 +00001461DEFUN (no_ospf_area_stub_no_summary,
1462 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001463 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1464 NO_STR
1465 "OSPF area parameters\n"
1466 "OSPF area ID in IP address format\n"
1467 "OSPF area ID as a decimal value\n"
1468 "Configure OSPF area as stub\n"
1469 "Do not inject inter-area routes into area\n")
1470{
1471 struct ospf *ospf = vty->index;
1472 struct in_addr area_id;
1473 int format;
1474
1475 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1476 ospf_area_no_summary_unset (ospf, area_id);
1477
1478 return CMD_SUCCESS;
1479}
1480
1481#ifdef HAVE_NSSA
paulb0a053b2003-06-22 09:04:47 +00001482int
1483ospf_area_nssa_cmd_handler (struct vty *vty, int argc, char **argv, int nosum)
paul718e3742002-12-13 20:15:29 +00001484{
1485 struct ospf *ospf = vty->index;
1486 struct in_addr area_id;
1487 int ret, format;
1488
1489 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1490
1491 ret = ospf_area_nssa_set (ospf, area_id);
1492 if (ret == 0)
1493 {
1494 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1495 VTY_NEWLINE);
1496 return CMD_WARNING;
1497 }
1498
1499 if (argc > 1)
1500 {
1501 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001502 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001503 OSPF_NSSA_ROLE_CANDIDATE);
1504 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001505 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001506 OSPF_NSSA_ROLE_NEVER);
1507 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001508 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001509 OSPF_NSSA_ROLE_ALWAYS);
1510 }
paulb0a053b2003-06-22 09:04:47 +00001511 else
1512 {
1513 ospf_area_nssa_translator_role_set (ospf, area_id,
1514 OSPF_NSSA_ROLE_CANDIDATE);
1515 }
paul718e3742002-12-13 20:15:29 +00001516
paulb0a053b2003-06-22 09:04:47 +00001517 if (nosum)
paul718e3742002-12-13 20:15:29 +00001518 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001519 else
1520 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001521
paulb0a053b2003-06-22 09:04:47 +00001522 ospf_schedule_abr_task (ospf);
1523
paul718e3742002-12-13 20:15:29 +00001524 return CMD_SUCCESS;
1525}
1526
paulb0a053b2003-06-22 09:04:47 +00001527DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001528 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001529 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001530 "OSPF area parameters\n"
1531 "OSPF area ID in IP address format\n"
1532 "OSPF area ID as a decimal value\n"
1533 "Configure OSPF area as nssa\n"
1534 "Configure NSSA-ABR for translate election (default)\n"
1535 "Configure NSSA-ABR to never translate\n"
1536 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001537 "Do not inject inter-area routes into nssa\n")
1538{
1539 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1540}
paul718e3742002-12-13 20:15:29 +00001541
paulb0a053b2003-06-22 09:04:47 +00001542DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001543 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001544 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1545 "OSPF area parameters\n"
1546 "OSPF area ID in IP address format\n"
1547 "OSPF area ID as a decimal value\n"
1548 "Configure OSPF area as nssa\n"
1549 "Configure NSSA-ABR for translate election (default)\n"
1550 "Configure NSSA-ABR to never translate\n"
1551 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001552{
1553 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1554}
1555
1556DEFUN (ospf_area_nssa,
1557 ospf_area_nssa_cmd,
1558 "area (A.B.C.D|<0-4294967295>) nssa",
1559 "OSPF area parameters\n"
1560 "OSPF area ID in IP address format\n"
1561 "OSPF area ID as a decimal value\n"
1562 "Configure OSPF area as nssa\n")
1563{
1564 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1565}
paul718e3742002-12-13 20:15:29 +00001566
paula2c62832003-04-23 17:01:31 +00001567DEFUN (ospf_area_nssa_no_summary,
1568 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001569 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1570 "OSPF area parameters\n"
1571 "OSPF area ID in IP address format\n"
1572 "OSPF area ID as a decimal value\n"
1573 "Configure OSPF area as nssa\n"
1574 "Do not inject inter-area routes into nssa\n")
1575{
paulb0a053b2003-06-22 09:04:47 +00001576 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001577}
1578
paula2c62832003-04-23 17:01:31 +00001579DEFUN (no_ospf_area_nssa,
1580 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001581 "no area (A.B.C.D|<0-4294967295>) nssa",
1582 NO_STR
1583 "OSPF area parameters\n"
1584 "OSPF area ID in IP address format\n"
1585 "OSPF area ID as a decimal value\n"
1586 "Configure OSPF area as nssa\n")
1587{
1588 struct ospf *ospf = vty->index;
1589 struct in_addr area_id;
1590 int format;
1591
1592 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1593
1594 ospf_area_nssa_unset (ospf, area_id);
1595 ospf_area_no_summary_unset (ospf, area_id);
1596
paulb0a053b2003-06-22 09:04:47 +00001597 ospf_schedule_abr_task (ospf);
1598
paul718e3742002-12-13 20:15:29 +00001599 return CMD_SUCCESS;
1600}
1601
paula2c62832003-04-23 17:01:31 +00001602DEFUN (no_ospf_area_nssa_no_summary,
1603 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001604 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1605 NO_STR
1606 "OSPF area parameters\n"
1607 "OSPF area ID in IP address format\n"
1608 "OSPF area ID as a decimal value\n"
1609 "Configure OSPF area as nssa\n"
1610 "Do not inject inter-area routes into nssa\n")
1611{
1612 struct ospf *ospf = vty->index;
1613 struct in_addr area_id;
1614 int format;
1615
1616 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1617 ospf_area_no_summary_unset (ospf, area_id);
1618
1619 return CMD_SUCCESS;
1620}
1621
1622#endif /* HAVE_NSSA */
1623
paula2c62832003-04-23 17:01:31 +00001624DEFUN (ospf_area_default_cost,
1625 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001626 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1627 "OSPF area parameters\n"
1628 "OSPF area ID in IP address format\n"
1629 "OSPF area ID as a decimal value\n"
1630 "Set the summary-default cost of a NSSA or stub area\n"
1631 "Stub's advertised default summary cost\n")
1632{
paul68980082003-03-25 05:07:42 +00001633 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001634 struct ospf_area *area;
1635 struct in_addr area_id;
1636 u_int32_t cost;
1637 int format;
1638
1639 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1640 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1641
paul68980082003-03-25 05:07:42 +00001642 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001643
1644 if (area->external_routing == OSPF_AREA_DEFAULT)
1645 {
1646 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1647 return CMD_WARNING;
1648 }
1649
1650 area->default_cost = cost;
1651
1652 return CMD_SUCCESS;
1653}
1654
paula2c62832003-04-23 17:01:31 +00001655DEFUN (no_ospf_area_default_cost,
1656 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001657 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1658 NO_STR
1659 "OSPF area parameters\n"
1660 "OSPF area ID in IP address format\n"
1661 "OSPF area ID as a decimal value\n"
1662 "Set the summary-default cost of a NSSA or stub area\n"
1663 "Stub's advertised default summary cost\n")
1664{
paul68980082003-03-25 05:07:42 +00001665 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001666 struct ospf_area *area;
1667 struct in_addr area_id;
1668 u_int32_t cost;
1669 int format;
1670
1671 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1672 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1673
paul68980082003-03-25 05:07:42 +00001674 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001675 if (area == NULL)
1676 return CMD_SUCCESS;
1677
1678 if (area->external_routing == OSPF_AREA_DEFAULT)
1679 {
1680 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1681 return CMD_WARNING;
1682 }
1683
1684 area->default_cost = 1;
1685
paul68980082003-03-25 05:07:42 +00001686 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001687
1688 return CMD_SUCCESS;
1689}
1690
paula2c62832003-04-23 17:01:31 +00001691DEFUN (ospf_area_export_list,
1692 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001693 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1694 "OSPF area parameters\n"
1695 "OSPF area ID in IP address format\n"
1696 "OSPF area ID as a decimal value\n"
1697 "Set the filter for networks announced to other areas\n"
1698 "Name of the access-list\n")
1699{
paul68980082003-03-25 05:07:42 +00001700 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001701 struct ospf_area *area;
1702 struct in_addr area_id;
1703 int format;
1704
1705 VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]);
1706
paul68980082003-03-25 05:07:42 +00001707 area = ospf_area_get (ospf, area_id, format);
1708 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001709
1710 return CMD_SUCCESS;
1711}
1712
paula2c62832003-04-23 17:01:31 +00001713DEFUN (no_ospf_area_export_list,
1714 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001715 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1716 NO_STR
1717 "OSPF area parameters\n"
1718 "OSPF area ID in IP address format\n"
1719 "OSPF area ID as a decimal value\n"
1720 "Unset the filter for networks announced to other areas\n"
1721 "Name of the access-list\n")
1722{
paul68980082003-03-25 05:07:42 +00001723 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001724 struct ospf_area *area;
1725 struct in_addr area_id;
1726 int format;
1727
1728 VTY_GET_OSPF_AREA_ID_NO_BB ("export-list", area_id, format, argv[0]);
1729
paul68980082003-03-25 05:07:42 +00001730 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001731 if (area == NULL)
1732 return CMD_SUCCESS;
1733
paul68980082003-03-25 05:07:42 +00001734 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001735
1736 return CMD_SUCCESS;
1737}
1738
1739
paula2c62832003-04-23 17:01:31 +00001740DEFUN (ospf_area_import_list,
1741 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001742 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1743 "OSPF area parameters\n"
1744 "OSPF area ID in IP address format\n"
1745 "OSPF area ID as a decimal value\n"
1746 "Set the filter for networks from other areas announced to the specified one\n"
1747 "Name of the access-list\n")
1748{
paul68980082003-03-25 05:07:42 +00001749 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001750 struct ospf_area *area;
1751 struct in_addr area_id;
1752 int format;
1753
1754 VTY_GET_OSPF_AREA_ID_NO_BB ("import-list", area_id, format, argv[0]);
1755
paul68980082003-03-25 05:07:42 +00001756 area = ospf_area_get (ospf, area_id, format);
1757 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001758
1759 return CMD_SUCCESS;
1760}
1761
paula2c62832003-04-23 17:01:31 +00001762DEFUN (no_ospf_area_import_list,
1763 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001764 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1765 NO_STR
1766 "OSPF area parameters\n"
1767 "OSPF area ID in IP address format\n"
1768 "OSPF area ID as a decimal value\n"
1769 "Unset the filter for networks announced to other areas\n"
1770 "Name of the access-list\n")
1771{
paul68980082003-03-25 05:07:42 +00001772 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001773 struct ospf_area *area;
1774 struct in_addr area_id;
1775 int format;
1776
1777 VTY_GET_OSPF_AREA_ID_NO_BB ("import-list", area_id, format, argv[0]);
paul68980082003-03-25 05:07:42 +00001778 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001779 if (area == NULL)
1780 return CMD_SUCCESS;
1781
paul68980082003-03-25 05:07:42 +00001782 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001783
1784 return CMD_SUCCESS;
1785}
1786
paula2c62832003-04-23 17:01:31 +00001787DEFUN (ospf_area_filter_list,
1788 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001789 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1790 "OSPF area parameters\n"
1791 "OSPF area ID in IP address format\n"
1792 "OSPF area ID as a decimal value\n"
1793 "Filter networks between OSPF areas\n"
1794 "Filter prefixes between OSPF areas\n"
1795 "Name of an IP prefix-list\n"
1796 "Filter networks sent to this area\n"
1797 "Filter networks sent from this area\n")
1798{
paul68980082003-03-25 05:07:42 +00001799 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001800 struct ospf_area *area;
1801 struct in_addr area_id;
1802 struct prefix_list *plist;
1803 int format;
1804
1805 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1806
paul68980082003-03-25 05:07:42 +00001807 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001808 plist = prefix_list_lookup (AFI_IP, argv[1]);
1809 if (strncmp (argv[2], "in", 2) == 0)
1810 {
1811 PREFIX_LIST_IN (area) = plist;
1812 if (PREFIX_NAME_IN (area))
1813 free (PREFIX_NAME_IN (area));
1814
1815 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001816 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001817 }
1818 else
1819 {
1820 PREFIX_LIST_OUT (area) = plist;
1821 if (PREFIX_NAME_OUT (area))
1822 free (PREFIX_NAME_OUT (area));
1823
1824 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001825 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001826 }
1827
1828 return CMD_SUCCESS;
1829}
1830
paula2c62832003-04-23 17:01:31 +00001831DEFUN (no_ospf_area_filter_list,
1832 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001833 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1834 NO_STR
1835 "OSPF area parameters\n"
1836 "OSPF area ID in IP address format\n"
1837 "OSPF area ID as a decimal value\n"
1838 "Filter networks between OSPF areas\n"
1839 "Filter prefixes between OSPF areas\n"
1840 "Name of an IP prefix-list\n"
1841 "Filter networks sent to this area\n"
1842 "Filter networks sent from this area\n")
1843{
paul68980082003-03-25 05:07:42 +00001844 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001845 struct ospf_area *area;
1846 struct in_addr area_id;
1847 struct prefix_list *plist;
1848 int format;
1849
1850 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1851
paul68980082003-03-25 05:07:42 +00001852 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001853 plist = prefix_list_lookup (AFI_IP, argv[1]);
1854 if (strncmp (argv[2], "in", 2) == 0)
1855 {
1856 if (PREFIX_NAME_IN (area))
1857 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1858 return CMD_SUCCESS;
1859
1860 PREFIX_LIST_IN (area) = NULL;
1861 if (PREFIX_NAME_IN (area))
1862 free (PREFIX_NAME_IN (area));
1863
1864 PREFIX_NAME_IN (area) = NULL;
1865
paul68980082003-03-25 05:07:42 +00001866 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001867 }
1868 else
1869 {
1870 if (PREFIX_NAME_OUT (area))
1871 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1872 return CMD_SUCCESS;
1873
1874 PREFIX_LIST_OUT (area) = NULL;
1875 if (PREFIX_NAME_OUT (area))
1876 free (PREFIX_NAME_OUT (area));
1877
1878 PREFIX_NAME_OUT (area) = NULL;
1879
paul68980082003-03-25 05:07:42 +00001880 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001881 }
1882
1883 return CMD_SUCCESS;
1884}
1885
1886
paula2c62832003-04-23 17:01:31 +00001887DEFUN (ospf_area_authentication_message_digest,
1888 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001889 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1890 "OSPF area parameters\n"
1891 "Enable authentication\n"
1892 "Use message-digest authentication\n")
1893{
paul68980082003-03-25 05:07:42 +00001894 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001895 struct ospf_area *area;
1896 struct in_addr area_id;
1897 int format;
1898
1899 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1900
paul68980082003-03-25 05:07:42 +00001901 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001902 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1903
1904 return CMD_SUCCESS;
1905}
1906
paula2c62832003-04-23 17:01:31 +00001907DEFUN (ospf_area_authentication,
1908 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001909 "area (A.B.C.D|<0-4294967295>) authentication",
1910 "OSPF area parameters\n"
1911 "OSPF area ID in IP address format\n"
1912 "OSPF area ID as a decimal value\n"
1913 "Enable authentication\n")
1914{
paul68980082003-03-25 05:07:42 +00001915 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001916 struct ospf_area *area;
1917 struct in_addr area_id;
1918 int format;
1919
1920 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1921
paul68980082003-03-25 05:07:42 +00001922 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001923 area->auth_type = OSPF_AUTH_SIMPLE;
1924
1925 return CMD_SUCCESS;
1926}
1927
paula2c62832003-04-23 17:01:31 +00001928DEFUN (no_ospf_area_authentication,
1929 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001930 "no area (A.B.C.D|<0-4294967295>) authentication",
1931 NO_STR
1932 "OSPF area parameters\n"
1933 "OSPF area ID in IP address format\n"
1934 "OSPF area ID as a decimal value\n"
1935 "Enable authentication\n")
1936{
paul68980082003-03-25 05:07:42 +00001937 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001938 struct ospf_area *area;
1939 struct in_addr area_id;
1940 int format;
1941
1942 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1943
paul68980082003-03-25 05:07:42 +00001944 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001945 if (area == NULL)
1946 return CMD_SUCCESS;
1947
1948 area->auth_type = OSPF_AUTH_NULL;
1949
paul68980082003-03-25 05:07:42 +00001950 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001951
1952 return CMD_SUCCESS;
1953}
1954
1955
1956DEFUN (ospf_abr_type,
1957 ospf_abr_type_cmd,
1958 "ospf abr-type (cisco|ibm|shortcut|standard)",
1959 "OSPF specific commands\n"
1960 "Set OSPF ABR type\n"
1961 "Alternative ABR, cisco implementation\n"
1962 "Alternative ABR, IBM implementation\n"
1963 "Shortcut ABR\n"
1964 "Standard behavior (RFC2328)\n")
1965{
paul68980082003-03-25 05:07:42 +00001966 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001967 u_char abr_type = OSPF_ABR_UNKNOWN;
1968
1969 if (strncmp (argv[0], "c", 1) == 0)
1970 abr_type = OSPF_ABR_CISCO;
1971 else if (strncmp (argv[0], "i", 1) == 0)
1972 abr_type = OSPF_ABR_IBM;
1973 else if (strncmp (argv[0], "sh", 2) == 0)
1974 abr_type = OSPF_ABR_SHORTCUT;
1975 else if (strncmp (argv[0], "st", 2) == 0)
1976 abr_type = OSPF_ABR_STAND;
1977 else
1978 return CMD_WARNING;
1979
1980 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00001981 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00001982 {
paul68980082003-03-25 05:07:42 +00001983 ospf->abr_type = abr_type;
1984 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001985 }
1986
1987 return CMD_SUCCESS;
1988}
1989
1990DEFUN (no_ospf_abr_type,
1991 no_ospf_abr_type_cmd,
1992 "no ospf abr-type (cisco|ibm|shortcut)",
1993 NO_STR
1994 "OSPF specific commands\n"
1995 "Set OSPF ABR type\n"
1996 "Alternative ABR, cisco implementation\n"
1997 "Alternative ABR, IBM implementation\n"
1998 "Shortcut ABR\n")
1999{
paul68980082003-03-25 05:07:42 +00002000 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002001 u_char abr_type = OSPF_ABR_UNKNOWN;
2002
2003 if (strncmp (argv[0], "c", 1) == 0)
2004 abr_type = OSPF_ABR_CISCO;
2005 else if (strncmp (argv[0], "i", 1) == 0)
2006 abr_type = OSPF_ABR_IBM;
2007 else if (strncmp (argv[0], "s", 1) == 0)
2008 abr_type = OSPF_ABR_SHORTCUT;
2009 else
2010 return CMD_WARNING;
2011
2012 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002013 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002014 {
paul68980082003-03-25 05:07:42 +00002015 ospf->abr_type = OSPF_ABR_STAND;
2016 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002017 }
2018
2019 return CMD_SUCCESS;
2020}
2021
2022DEFUN (ospf_compatible_rfc1583,
2023 ospf_compatible_rfc1583_cmd,
2024 "compatible rfc1583",
2025 "OSPF compatibility list\n"
2026 "compatible with RFC 1583\n")
2027{
2028 struct ospf *ospf = vty->index;
2029
2030 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2031 {
2032 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002033 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002034 }
2035 return CMD_SUCCESS;
2036}
2037
2038DEFUN (no_ospf_compatible_rfc1583,
2039 no_ospf_compatible_rfc1583_cmd,
2040 "no compatible rfc1583",
2041 NO_STR
2042 "OSPF compatibility list\n"
2043 "compatible with RFC 1583\n")
2044{
2045 struct ospf *ospf = vty->index;
2046
2047 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2048 {
2049 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002050 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002051 }
2052 return CMD_SUCCESS;
2053}
2054
2055ALIAS (ospf_compatible_rfc1583,
2056 ospf_rfc1583_flag_cmd,
2057 "ospf rfc1583compatibility",
2058 "OSPF specific commands\n"
2059 "Enable the RFC1583Compatibility flag\n")
2060
2061ALIAS (no_ospf_compatible_rfc1583,
2062 no_ospf_rfc1583_flag_cmd,
2063 "no ospf rfc1583compatibility",
2064 NO_STR
2065 "OSPF specific commands\n"
2066 "Disable the RFC1583Compatibility flag\n")
2067
paula2c62832003-04-23 17:01:31 +00002068DEFUN (ospf_timers_spf,
2069 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002070 "timers spf <0-4294967295> <0-4294967295>",
2071 "Adjust routing timers\n"
2072 "OSPF SPF timers\n"
2073 "Delay between receiving a change to SPF calculation\n"
2074 "Hold time between consecutive SPF calculations\n")
2075{
2076 struct ospf *ospf = vty->index;
2077 u_int32_t delay, hold;
2078
2079 VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]);
2080 VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]);
2081
2082 ospf_timers_spf_set (ospf, delay, hold);
2083
2084 return CMD_SUCCESS;
2085}
2086
paula2c62832003-04-23 17:01:31 +00002087DEFUN (no_ospf_timers_spf,
2088 no_ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002089 "no timers spf",
2090 NO_STR
2091 "Adjust routing timers\n"
2092 "OSPF SPF timers\n")
2093{
paul68980082003-03-25 05:07:42 +00002094 struct ospf *ospf = vty->index;
2095
2096 ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT;
2097 ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002098
2099 return CMD_SUCCESS;
2100}
2101
2102
paula2c62832003-04-23 17:01:31 +00002103DEFUN (ospf_neighbor,
2104 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002105 "neighbor A.B.C.D",
2106 NEIGHBOR_STR
2107 "Neighbor IP address\n")
2108{
2109 struct ospf *ospf = vty->index;
2110 struct in_addr nbr_addr;
2111 int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2112 int interval = OSPF_POLL_INTERVAL_DEFAULT;
2113
2114 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2115
2116 if (argc > 1)
2117 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2118
2119 if (argc > 2)
2120 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2121
2122 ospf_nbr_nbma_set (ospf, nbr_addr);
2123 if (argc > 1)
2124 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2125 if (argc > 2)
2126 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2127
2128 return CMD_SUCCESS;
2129}
2130
paula2c62832003-04-23 17:01:31 +00002131ALIAS (ospf_neighbor,
2132 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002133 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2134 NEIGHBOR_STR
2135 "Neighbor IP address\n"
2136 "Neighbor Priority\n"
2137 "Priority\n"
2138 "Dead Neighbor Polling interval\n"
2139 "Seconds\n")
2140
paula2c62832003-04-23 17:01:31 +00002141ALIAS (ospf_neighbor,
2142 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002143 "neighbor A.B.C.D priority <0-255>",
2144 NEIGHBOR_STR
2145 "Neighbor IP address\n"
2146 "Neighbor Priority\n"
2147 "Seconds\n")
2148
paula2c62832003-04-23 17:01:31 +00002149DEFUN (ospf_neighbor_poll_interval,
2150 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002151 "neighbor A.B.C.D poll-interval <1-65535>",
2152 NEIGHBOR_STR
2153 "Neighbor IP address\n"
2154 "Dead Neighbor Polling interval\n"
2155 "Seconds\n")
2156{
2157 struct ospf *ospf = vty->index;
2158 struct in_addr nbr_addr;
2159 int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2160 int interval = OSPF_POLL_INTERVAL_DEFAULT;
2161
2162 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2163
2164 if (argc > 1)
2165 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2166
2167 if (argc > 2)
2168 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2169
2170 ospf_nbr_nbma_set (ospf, nbr_addr);
2171 if (argc > 1)
2172 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2173 if (argc > 2)
2174 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2175
2176 return CMD_SUCCESS;
2177}
2178
paula2c62832003-04-23 17:01:31 +00002179ALIAS (ospf_neighbor_poll_interval,
2180 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002181 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2182 NEIGHBOR_STR
2183 "Neighbor address\n"
2184 "OSPF dead-router polling interval\n"
2185 "Seconds\n"
2186 "OSPF priority of non-broadcast neighbor\n"
2187 "Priority\n")
2188
paula2c62832003-04-23 17:01:31 +00002189DEFUN (no_ospf_neighbor,
2190 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002191 "no neighbor A.B.C.D",
2192 NO_STR
2193 NEIGHBOR_STR
2194 "Neighbor IP address\n")
2195{
2196 struct ospf *ospf = vty->index;
2197 struct in_addr nbr_addr;
2198 int ret;
2199
2200 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2201
2202 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2203
2204 return CMD_SUCCESS;
2205}
2206
paula2c62832003-04-23 17:01:31 +00002207ALIAS (no_ospf_neighbor,
2208 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002209 "no neighbor A.B.C.D priority <0-255>",
2210 NO_STR
2211 NEIGHBOR_STR
2212 "Neighbor IP address\n"
2213 "Neighbor Priority\n"
2214 "Priority\n")
2215
paula2c62832003-04-23 17:01:31 +00002216ALIAS (no_ospf_neighbor,
2217 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002218 "no neighbor A.B.C.D poll-interval <1-65535>",
2219 NO_STR
2220 NEIGHBOR_STR
2221 "Neighbor IP address\n"
2222 "Dead Neighbor Polling interval\n"
2223 "Seconds\n")
2224
paula2c62832003-04-23 17:01:31 +00002225ALIAS (no_ospf_neighbor,
2226 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002227 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2228 NO_STR
2229 NEIGHBOR_STR
2230 "Neighbor IP address\n"
2231 "Neighbor Priority\n"
2232 "Priority\n"
2233 "Dead Neighbor Polling interval\n"
2234 "Seconds\n")
2235
2236
paula2c62832003-04-23 17:01:31 +00002237DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002238 "refresh timer <10-1800>",
2239 "Adjust refresh parameters\n"
2240 "Set refresh timer\n"
2241 "Timer value in seconds\n")
2242{
2243 struct ospf *ospf = vty->index;
2244 int interval;
2245
2246 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2247 interval = (interval / 10) * 10;
2248
2249 ospf_timers_refresh_set (ospf, interval);
2250
2251 return CMD_SUCCESS;
2252}
2253
paula2c62832003-04-23 17:01:31 +00002254DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002255 "no refresh timer <10-1800>",
2256 "Adjust refresh parameters\n"
2257 "Unset refresh timer\n"
2258 "Timer value in seconds\n")
2259{
2260 struct ospf *ospf = vty->index;
2261 int interval;
2262
2263 if (argc == 1)
2264 {
2265 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2266
2267 if (ospf->lsa_refresh_interval != interval ||
2268 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2269 return CMD_SUCCESS;
2270 }
2271
2272 ospf_timers_refresh_unset (ospf);
2273
2274 return CMD_SUCCESS;
2275}
2276
paula2c62832003-04-23 17:01:31 +00002277ALIAS (no_ospf_refresh_timer,
2278 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002279 "no refresh timer",
2280 "Adjust refresh parameters\n"
2281 "Unset refresh timer\n")
2282
paula2c62832003-04-23 17:01:31 +00002283DEFUN (ospf_auto_cost_reference_bandwidth,
2284 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002285 "auto-cost reference-bandwidth <1-4294967>",
2286 "Calculate OSPF interface cost according to bandwidth\n"
2287 "Use reference bandwidth method to assign OSPF cost\n"
2288 "The reference bandwidth in terms of Mbits per second\n")
2289{
paul68980082003-03-25 05:07:42 +00002290 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002291 u_int32_t refbw;
2292 listnode node;
2293
2294 refbw = strtol (argv[0], NULL, 10);
2295 if (refbw < 1 || refbw > 4294967)
2296 {
2297 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2298 return CMD_WARNING;
2299 }
2300
2301 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002302 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002303 return CMD_SUCCESS;
2304
paul68980082003-03-25 05:07:42 +00002305 ospf->ref_bandwidth = refbw * 1000;
paul718e3742002-12-13 20:15:29 +00002306 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2307 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2308
paul020709f2003-04-04 02:44:16 +00002309 for (node = listhead (om->iflist); node; nextnode (node))
2310 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002311
2312 return CMD_SUCCESS;
2313}
2314
paula2c62832003-04-23 17:01:31 +00002315DEFUN (no_ospf_auto_cost_reference_bandwidth,
2316 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002317 "no auto-cost reference-bandwidth",
2318 NO_STR
2319 "Calculate OSPF interface cost according to bandwidth\n"
2320 "Use reference bandwidth method to assign OSPF cost\n")
2321{
paul68980082003-03-25 05:07:42 +00002322 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002323 listnode node;
2324
paul68980082003-03-25 05:07:42 +00002325 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002326 return CMD_SUCCESS;
2327
paul68980082003-03-25 05:07:42 +00002328 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002329 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2330 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2331
paul020709f2003-04-04 02:44:16 +00002332 for (node = listhead (om->iflist); node; nextnode (node))
2333 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002334
2335 return CMD_SUCCESS;
2336}
2337
paul718e3742002-12-13 20:15:29 +00002338char *ospf_abr_type_descr_str[] =
2339{
2340 "Unknown",
2341 "Standard (RFC2328)",
2342 "Alternative IBM",
2343 "Alternative Cisco",
2344 "Alternative Shortcut"
2345};
2346
2347char *ospf_shortcut_mode_descr_str[] =
2348{
2349 "Default",
2350 "Enabled",
2351 "Disabled"
2352};
2353
2354
2355
2356void
2357show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2358{
2359 /* Show Area ID. */
2360 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2361
2362 /* Show Area type/mode. */
2363 if (OSPF_IS_AREA_BACKBONE (area))
2364 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2365 else
2366 {
2367 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002368 vty_out (vty, " (Stub%s%s)",
2369 area->no_summary ? ", no summary" : "",
2370 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002371
2372#ifdef HAVE_NSSA
2373
paulb0a053b2003-06-22 09:04:47 +00002374 else if (area->external_routing == OSPF_AREA_NSSA)
2375 vty_out (vty, " (NSSA%s%s)",
2376 area->no_summary ? ", no summary" : "",
2377 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002378#endif /* HAVE_NSSA */
2379
2380 vty_out (vty, "%s", VTY_NEWLINE);
2381 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002382 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002383 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002384 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002385 }
2386
2387 /* Show number of interfaces. */
2388 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2389 "Active: %d%s", listcount (area->oiflist),
2390 area->act_ints, VTY_NEWLINE);
2391
2392#ifdef HAVE_NSSA
2393 if (area->external_routing == OSPF_AREA_NSSA)
2394 {
2395 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 +00002396 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002397 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2398 VTY_NEWLINE);
2399 else if (area->NSSATranslatorState)
2400 {
2401 vty_out (vty, " We are an ABR and ");
2402 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2403 vty_out (vty, "the NSSA Elected Translator. %s",
2404 VTY_NEWLINE);
2405 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2406 vty_out (vty, "always an NSSA Translator. %s",
2407 VTY_NEWLINE);
2408 }
paul718e3742002-12-13 20:15:29 +00002409 else
paulb0a053b2003-06-22 09:04:47 +00002410 {
2411 vty_out (vty, " We are an ABR, but ");
2412 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2413 vty_out (vty, "not the NSSA Elected Translator. %s",
2414 VTY_NEWLINE);
2415 else
2416 vty_out (vty, "not the NSSA Elected Translator. %s",
2417 VTY_NEWLINE);
2418 }
paul718e3742002-12-13 20:15:29 +00002419 }
2420#endif /* HAVE_NSSA */
2421
2422 /* Show number of fully adjacent neighbors. */
2423 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002424 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002425
2426 /* Show authentication type. */
2427 vty_out (vty, " Area has ");
2428 if (area->auth_type == OSPF_AUTH_NULL)
2429 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2430 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2431 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2432 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2433 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2434
2435 if (!OSPF_IS_AREA_BACKBONE (area))
2436 vty_out (vty, " Number of full virtual adjacencies going through"
2437 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2438
2439 /* Show SPF calculation times. */
2440 vty_out (vty, " SPF algorithm executed %d times%s",
2441 area->spf_calculation, VTY_NEWLINE);
2442
2443 /* Show number of LSA. */
2444 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
2445
2446 vty_out (vty, "%s", VTY_NEWLINE);
2447}
2448
2449DEFUN (show_ip_ospf,
2450 show_ip_ospf_cmd,
2451 "show ip ospf",
2452 SHOW_STR
2453 IP_STR
2454 "OSPF information\n")
2455{
2456 listnode node;
2457 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002458 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002459
2460 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002461 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002462 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002463 {
2464 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2465 return CMD_SUCCESS;
2466 }
2467
2468 /* Show Router ID. */
2469 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002470 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002471 VTY_NEWLINE);
2472
2473 /* Show capability. */
2474 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2475 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2476 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002477 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002478 "enabled" : "disabled", VTY_NEWLINE);
2479#ifdef HAVE_OPAQUE_LSA
2480 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002481 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002482 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002483 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002484 " (origination blocked)" : "",
2485 VTY_NEWLINE);
2486#endif /* HAVE_OPAQUE_LSA */
2487
2488 /* Show SPF timers. */
2489 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
paul68980082003-03-25 05:07:42 +00002490 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002491
2492 /* Show refresh parameters. */
2493 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002494 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002495
2496 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002497 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002498 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002499 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002500
paul68980082003-03-25 05:07:42 +00002501 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002502 vty_out (vty, " This router is an ASBR "
2503 "(injecting external routing information)%s", VTY_NEWLINE);
2504
2505 /* Show Number of AS-external-LSAs. */
2506 vty_out (vty, " Number of external LSA %ld%s",
paul68980082003-03-25 05:07:42 +00002507 ospf_lsdb_count_all (ospf->lsdb), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002508
2509 /* Show number of areas attached. */
2510 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002511 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002512
2513 /* Show each area status. */
paul68980082003-03-25 05:07:42 +00002514 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002515 if ((area = getdata (node)) != NULL)
2516 show_ip_ospf_area (vty, area);
2517
2518 return CMD_SUCCESS;
2519}
2520
2521
2522void
paul68980082003-03-25 05:07:42 +00002523show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2524 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002525{
2526 struct ospf_neighbor *nbr;
2527 int oi_count;
2528 struct route_node *rn;
2529 char buf[9];
2530
2531 oi_count = ospf_oi_count (ifp);
2532
2533 /* Is interface up? */
paul2e3b2e42002-12-13 21:03:13 +00002534 if (if_is_operative (ifp)) {
2535 vty_out (vty, "%s is up%s", ifp->name, VTY_NEWLINE);
2536 } else
2537 {
2538 vty_out (vty, "%s is down%s", ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002539
2540
2541 if (oi_count == 0)
2542 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2543 else
2544 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2545 VTY_NEWLINE);
2546 return;
2547 }
2548
2549 /* Is interface OSPF enabled? */
2550 if (oi_count == 0)
2551 {
2552 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2553 return;
2554 }
2555
2556 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2557 {
2558 struct ospf_interface *oi = rn->info;
2559
2560 if (oi == NULL)
2561 continue;
2562
2563 /* Show OSPF interface information. */
2564 vty_out (vty, " Internet Address %s/%d,",
2565 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2566
2567 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2568 VTY_NEWLINE);
2569
2570 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002571 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002572 oi->output_cost, VTY_NEWLINE);
2573
2574 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2575 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2576 PRIORITY (oi), VTY_NEWLINE);
2577
2578 /* Show DR information. */
2579 if (DR (oi).s_addr == 0)
2580 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2581 else
2582 {
2583 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2584 if (nbr == NULL)
2585 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2586 else
2587 {
2588 vty_out (vty, " Designated Router (ID) %s,",
2589 inet_ntoa (nbr->router_id));
2590 vty_out (vty, " Interface Address %s%s",
2591 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2592 }
2593 }
2594
2595 /* Show BDR information. */
2596 if (BDR (oi).s_addr == 0)
2597 vty_out (vty, " No backup designated router on this network%s",
2598 VTY_NEWLINE);
2599 else
2600 {
2601 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2602 if (nbr == NULL)
2603 vty_out (vty, " No backup designated router on this network%s",
2604 VTY_NEWLINE);
2605 else
2606 {
2607 vty_out (vty, " Backup Designated Router (ID) %s,",
2608 inet_ntoa (nbr->router_id));
2609 vty_out (vty, " Interface Address %s%s",
2610 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2611 }
2612 }
2613 vty_out (vty, " Timer intervals configured,");
2614 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2615 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2616 OSPF_IF_PARAM (oi, v_wait),
2617 OSPF_IF_PARAM (oi, retransmit_interval),
2618 VTY_NEWLINE);
2619
2620 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2621 vty_out (vty, " Hello due in %s%s",
2622 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2623 else /* OSPF_IF_PASSIVE is set */
2624 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2625
2626 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002627 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002628 VTY_NEWLINE);
2629 }
2630}
2631
2632DEFUN (show_ip_ospf_interface,
2633 show_ip_ospf_interface_cmd,
2634 "show ip ospf interface [INTERFACE]",
2635 SHOW_STR
2636 IP_STR
2637 "OSPF information\n"
2638 "Interface information\n"
2639 "Interface name\n")
2640{
2641 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002642 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002643 listnode node;
2644
paul020709f2003-04-04 02:44:16 +00002645 ospf = ospf_lookup ();
2646
paul718e3742002-12-13 20:15:29 +00002647 /* Show All Interfaces. */
2648 if (argc == 0)
2649 for (node = listhead (iflist); node; nextnode (node))
paul68980082003-03-25 05:07:42 +00002650 show_ip_ospf_interface_sub (vty, ospf, node->data);
paul718e3742002-12-13 20:15:29 +00002651 /* Interface name is specified. */
2652 else
2653 {
2654 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2655 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2656 else
paul68980082003-03-25 05:07:42 +00002657 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002658 }
2659
2660 return CMD_SUCCESS;
2661}
2662
2663void
2664show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2665{
2666 struct route_node *rn;
2667 struct ospf_neighbor *nbr;
2668 char msgbuf[16];
2669 char timebuf[9];
2670
2671 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2672 if ((nbr = rn->info))
2673 /* Do not show myself. */
2674 if (nbr != oi->nbr_self)
2675 /* Down state is not shown. */
2676 if (nbr->state != NSM_Down)
2677 {
2678 ospf_nbr_state_message (nbr, msgbuf, 16);
2679
2680 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2681 vty_out (vty, "%-15s %3d %-15s %8s ",
2682 "-", nbr->priority,
2683 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2684 else
2685 vty_out (vty, "%-15s %3d %-15s %8s ",
2686 inet_ntoa (nbr->router_id), nbr->priority,
2687 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2688 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2689 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2690 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2691 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2692 VTY_NEWLINE);
2693 }
2694}
2695
2696DEFUN (show_ip_ospf_neighbor,
2697 show_ip_ospf_neighbor_cmd,
2698 "show ip ospf neighbor",
2699 SHOW_STR
2700 IP_STR
2701 "OSPF information\n"
2702 "Neighbor list\n")
2703{
paul020709f2003-04-04 02:44:16 +00002704 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002705 listnode node;
2706
paul020709f2003-04-04 02:44:16 +00002707 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002708 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002709 {
2710 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2711 return CMD_SUCCESS;
2712 }
2713
2714 /* Show All neighbors. */
2715 vty_out (vty, "%sNeighbor ID Pri State Dead "
2716 "Time Address Interface RXmtL "
2717 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2718
paul68980082003-03-25 05:07:42 +00002719 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul020709f2003-04-04 02:44:16 +00002720 show_ip_ospf_neighbor_sub (vty, getdata (node));
paul718e3742002-12-13 20:15:29 +00002721
2722 return CMD_SUCCESS;
2723}
2724
2725DEFUN (show_ip_ospf_neighbor_all,
2726 show_ip_ospf_neighbor_all_cmd,
2727 "show ip ospf neighbor all",
2728 SHOW_STR
2729 IP_STR
2730 "OSPF information\n"
2731 "Neighbor list\n"
2732 "include down status neighbor\n")
2733{
paul68980082003-03-25 05:07:42 +00002734 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002735 listnode node;
2736
paul68980082003-03-25 05:07:42 +00002737 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002738 {
2739 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2740 return CMD_SUCCESS;
2741 }
2742
2743 /* Show All neighbors. */
2744 vty_out (vty, "%sNeighbor ID Pri State Dead "
2745 "Time Address Interface RXmtL "
2746 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2747
paul68980082003-03-25 05:07:42 +00002748 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002749 {
2750 struct ospf_interface *oi = getdata (node);
2751 listnode nbr_node;
2752
2753 show_ip_ospf_neighbor_sub (vty, oi);
2754
2755 /* print Down neighbor status */
2756 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
2757 {
2758 struct ospf_nbr_nbma *nbr_nbma;
2759
2760 nbr_nbma = getdata (nbr_node);
2761
2762 if (nbr_nbma->nbr == NULL
2763 || nbr_nbma->nbr->state == NSM_Down)
2764 {
2765 vty_out (vty, "%-15s %3d %-15s %8s ",
2766 "-", nbr_nbma->priority, "Down", "-");
2767 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2768 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2769 0, 0, 0, VTY_NEWLINE);
2770 }
2771 }
2772 }
2773
2774 return CMD_SUCCESS;
2775}
2776
2777DEFUN (show_ip_ospf_neighbor_int,
2778 show_ip_ospf_neighbor_int_cmd,
2779 "show ip ospf neighbor A.B.C.D",
2780 SHOW_STR
2781 IP_STR
2782 "OSPF information\n"
2783 "Neighbor list\n"
2784 "Interface name\n")
2785{
paul020709f2003-04-04 02:44:16 +00002786 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002787 struct ospf_interface *oi;
2788 struct in_addr addr;
2789 int ret;
2790
paul718e3742002-12-13 20:15:29 +00002791 ret = inet_aton (argv[0], &addr);
2792 if (!ret)
2793 {
2794 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2795 VTY_NEWLINE);
2796 return CMD_WARNING;
2797 }
2798
paul020709f2003-04-04 02:44:16 +00002799 ospf = ospf_lookup ();
2800 if (ospf == NULL)
2801 {
2802 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2803 return CMD_SUCCESS;
2804 }
2805
paul68980082003-03-25 05:07:42 +00002806 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00002807 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2808 else
2809 {
2810 vty_out (vty, "%sNeighbor ID Pri State Dead "
2811 "Time Address Interface RXmtL "
2812 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2813 show_ip_ospf_neighbor_sub (vty, oi);
2814 }
2815
2816 return CMD_SUCCESS;
2817}
2818
2819void
2820show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2821 struct ospf_nbr_nbma *nbr_nbma)
2822{
2823 char timebuf[9];
2824
2825 /* Show neighbor ID. */
2826 vty_out (vty, " Neighbor %s,", "-");
2827
2828 /* Show interface address. */
2829 vty_out (vty, " interface address %s%s",
2830 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2831 /* Show Area ID. */
2832 vty_out (vty, " In the area %s via interface %s%s",
2833 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2834 /* Show neighbor priority and state. */
2835 vty_out (vty, " Neighbor priority is %d, State is %s,",
2836 nbr_nbma->priority, "Down");
2837 /* Show state changes. */
2838 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2839
2840 /* Show PollInterval */
2841 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2842
2843 /* Show poll-interval timer. */
2844 vty_out (vty, " Poll timer due in %s%s",
2845 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2846
2847 /* Show poll-interval timer thread. */
2848 vty_out (vty, " Thread Poll Timer %s%s",
2849 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2850}
2851
2852void
2853show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2854 struct ospf_neighbor *nbr)
2855{
2856 char timebuf[9];
2857
2858 /* Show neighbor ID. */
2859 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2860 vty_out (vty, " Neighbor %s,", "-");
2861 else
2862 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2863
2864 /* Show interface address. */
2865 vty_out (vty, " interface address %s%s",
2866 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2867 /* Show Area ID. */
2868 vty_out (vty, " In the area %s via interface %s%s",
2869 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2870 /* Show neighbor priority and state. */
2871 vty_out (vty, " Neighbor priority is %d, State is %s,",
2872 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2873 /* Show state changes. */
2874 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2875
2876 /* Show Designated Rotuer ID. */
2877 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2878 /* Show Backup Designated Rotuer ID. */
2879 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2880 /* Show options. */
2881 vty_out (vty, " Options %d %s%s", nbr->options,
2882 ospf_options_dump (nbr->options), VTY_NEWLINE);
2883 /* Show Router Dead interval timer. */
2884 vty_out (vty, " Dead timer due in %s%s",
2885 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2886 /* Show Database Summary list. */
2887 vty_out (vty, " Database Summary List %d%s",
2888 ospf_db_summary_count (nbr), VTY_NEWLINE);
2889 /* Show Link State Request list. */
2890 vty_out (vty, " Link State Request List %ld%s",
2891 ospf_ls_request_count (nbr), VTY_NEWLINE);
2892 /* Show Link State Retransmission list. */
2893 vty_out (vty, " Link State Retransmission List %ld%s",
2894 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2895 /* Show inactivity timer thread. */
2896 vty_out (vty, " Thread Inactivity Timer %s%s",
2897 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2898 /* Show Database Description retransmission thread. */
2899 vty_out (vty, " Thread Database Description Retransmision %s%s",
2900 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2901 /* Show Link State Request Retransmission thread. */
2902 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2903 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2904 /* Show Link State Update Retransmission thread. */
2905 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2906 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2907}
2908
2909DEFUN (show_ip_ospf_neighbor_id,
2910 show_ip_ospf_neighbor_id_cmd,
2911 "show ip ospf neighbor A.B.C.D",
2912 SHOW_STR
2913 IP_STR
2914 "OSPF information\n"
2915 "Neighbor list\n"
2916 "Neighbor ID\n")
2917{
paul020709f2003-04-04 02:44:16 +00002918 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002919 listnode node;
2920 struct ospf_neighbor *nbr;
2921 struct in_addr router_id;
2922 int ret;
2923
2924 ret = inet_aton (argv[0], &router_id);
2925 if (!ret)
2926 {
2927 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
2928 return CMD_WARNING;
2929 }
2930
paul020709f2003-04-04 02:44:16 +00002931 ospf = ospf_lookup ();
2932 if (ospf == NULL)
2933 {
2934 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2935 return CMD_SUCCESS;
2936 }
2937
paul68980082003-03-25 05:07:42 +00002938 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002939 {
2940 struct ospf_interface *oi = getdata (node);
2941
2942 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
2943 {
2944 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2945 return CMD_SUCCESS;
2946 }
2947 }
2948
2949 /* Nothing to show. */
2950 return CMD_SUCCESS;
2951}
2952
2953DEFUN (show_ip_ospf_neighbor_detail,
2954 show_ip_ospf_neighbor_detail_cmd,
2955 "show ip ospf neighbor detail",
2956 SHOW_STR
2957 IP_STR
2958 "OSPF information\n"
2959 "Neighbor list\n"
2960 "detail of all neighbors\n")
2961{
paul020709f2003-04-04 02:44:16 +00002962 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002963 listnode node;
2964
paul020709f2003-04-04 02:44:16 +00002965 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002966 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00002967 {
2968 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2969 return CMD_SUCCESS;
2970 }
paul718e3742002-12-13 20:15:29 +00002971
paul68980082003-03-25 05:07:42 +00002972 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002973 {
2974 struct ospf_interface *oi = getdata (node);
2975 struct route_node *rn;
2976 struct ospf_neighbor *nbr;
2977
2978 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2979 if ((nbr = rn->info))
2980 if (nbr != oi->nbr_self)
2981 if (nbr->state != NSM_Down)
2982 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2983 }
2984
2985 return CMD_SUCCESS;
2986}
2987
2988DEFUN (show_ip_ospf_neighbor_detail_all,
2989 show_ip_ospf_neighbor_detail_all_cmd,
2990 "show ip ospf neighbor detail all",
2991 SHOW_STR
2992 IP_STR
2993 "OSPF information\n"
2994 "Neighbor list\n"
2995 "detail of all neighbors\n"
2996 "include down status neighbor\n")
2997{
paul020709f2003-04-04 02:44:16 +00002998 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002999 listnode node;
3000
paul020709f2003-04-04 02:44:16 +00003001 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003002 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003003 {
3004 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3005 return CMD_SUCCESS;
3006 }
paul718e3742002-12-13 20:15:29 +00003007
paul68980082003-03-25 05:07:42 +00003008 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003009 {
3010 struct ospf_interface *oi = getdata (node);
3011 struct route_node *rn;
3012 struct ospf_neighbor *nbr;
3013
3014 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3015 if ((nbr = rn->info))
3016 if (nbr != oi->nbr_self)
3017 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3018 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3019
3020 if (oi->type == OSPF_IFTYPE_NBMA)
3021 {
3022 listnode nd;
3023
3024 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
3025 {
3026 struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
3027 if (nbr_nbma->nbr == NULL
3028 || nbr_nbma->nbr->state == NSM_Down)
3029 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3030 }
3031 }
3032 }
3033
3034 return CMD_SUCCESS;
3035}
3036
3037DEFUN (show_ip_ospf_neighbor_int_detail,
3038 show_ip_ospf_neighbor_int_detail_cmd,
3039 "show ip ospf neighbor A.B.C.D detail",
3040 SHOW_STR
3041 IP_STR
3042 "OSPF information\n"
3043 "Neighbor list\n"
3044 "Interface address\n"
3045 "detail of all neighbors")
3046{
paul020709f2003-04-04 02:44:16 +00003047 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003048 struct ospf_interface *oi;
3049 struct in_addr addr;
3050 int ret;
3051
3052 ret = inet_aton (argv[0], &addr);
3053 if (!ret)
3054 {
3055 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3056 VTY_NEWLINE);
3057 return CMD_WARNING;
3058 }
3059
paul020709f2003-04-04 02:44:16 +00003060 ospf = ospf_lookup ();
3061 if (ospf == NULL)
3062 {
3063 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3064 return CMD_SUCCESS;
3065 }
paul68980082003-03-25 05:07:42 +00003066
paul020709f2003-04-04 02:44:16 +00003067 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00003068 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3069 else
3070 {
3071 struct route_node *rn;
3072 struct ospf_neighbor *nbr;
3073
3074 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3075 if ((nbr = rn->info))
3076 if (nbr != oi->nbr_self)
3077 if (nbr->state != NSM_Down)
3078 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3079 }
3080
3081 return CMD_SUCCESS;
3082}
3083
3084
3085/* Show functions */
3086int
paul020709f2003-04-04 02:44:16 +00003087show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003088{
paul718e3742002-12-13 20:15:29 +00003089 struct router_lsa *rl;
3090 struct summary_lsa *sl;
3091 struct as_external_lsa *asel;
3092 struct prefix_ipv4 p;
3093
3094 if (lsa != NULL)
3095 /* If self option is set, check LSA self flag. */
3096 if (self == 0 || IS_LSA_SELF (lsa))
3097 {
3098 /* LSA common part show. */
3099 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3100 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3101 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3102 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3103 /* LSA specific part show. */
3104 switch (lsa->data->type)
3105 {
3106 case OSPF_ROUTER_LSA:
3107 rl = (struct router_lsa *) lsa->data;
3108 vty_out (vty, " %-d", ntohs (rl->links));
3109 break;
3110 case OSPF_SUMMARY_LSA:
3111 sl = (struct summary_lsa *) lsa->data;
3112
3113 p.family = AF_INET;
3114 p.prefix = sl->header.id;
3115 p.prefixlen = ip_masklen (sl->mask);
3116 apply_mask_ipv4 (&p);
3117
3118 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3119 break;
3120 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003121#ifdef HAVE_NSSA
3122 case OSPF_AS_NSSA_LSA:
3123#endif /* HAVE_NSSA */
paul718e3742002-12-13 20:15:29 +00003124 asel = (struct as_external_lsa *) lsa->data;
3125
3126 p.family = AF_INET;
3127 p.prefix = asel->header.id;
3128 p.prefixlen = ip_masklen (asel->mask);
3129 apply_mask_ipv4 (&p);
3130
3131 vty_out (vty, " %s %s/%d [0x%lx]",
3132 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3133 inet_ntoa (p.prefix), p.prefixlen,
3134 (u_long)ntohl (asel->e[0].route_tag));
3135 break;
3136 case OSPF_NETWORK_LSA:
3137 case OSPF_ASBR_SUMMARY_LSA:
3138#ifdef HAVE_OPAQUE_LSA
3139 case OSPF_OPAQUE_LINK_LSA:
3140 case OSPF_OPAQUE_AREA_LSA:
3141 case OSPF_OPAQUE_AS_LSA:
3142#endif /* HAVE_OPAQUE_LSA */
3143 default:
3144 break;
3145 }
3146 vty_out (vty, VTY_NEWLINE);
3147 }
3148
3149 return 0;
3150}
3151
3152char *show_database_desc[] =
3153{
3154 "unknown",
3155 "Router Link States",
3156 "Net Link States",
3157 "Summary Link States",
3158 "ASBR-Summary Link States",
3159 "AS External Link States",
3160#if defined (HAVE_NSSA) || defined (HAVE_OPAQUE_LSA)
3161 "Group Membership LSA",
3162 "NSSA-external Link States",
3163#endif /* HAVE_NSSA */
3164#ifdef HAVE_OPAQUE_LSA
3165 "Type-8 LSA",
3166 "Link-Local Opaque-LSA",
3167 "Area-Local Opaque-LSA",
3168 "AS-external Opaque-LSA",
3169#endif /* HAVE_OPAQUE_LSA */
3170};
3171
3172#define SHOW_OSPF_COMMON_HEADER \
3173 "Link ID ADV Router Age Seq# CkSum"
3174
3175char *show_database_header[] =
3176{
3177 "",
3178 "Link ID ADV Router Age Seq# CkSum Link count",
3179 "Link ID ADV Router Age Seq# CkSum",
3180 "Link ID ADV Router Age Seq# CkSum Route",
3181 "Link ID ADV Router Age Seq# CkSum",
3182 "Link ID ADV Router Age Seq# CkSum Route",
3183#ifdef HAVE_NSSA
3184 " --- header for Group Member ----",
3185 "Link ID ADV Router Age Seq# CkSum Route",
3186#endif /* HAVE_NSSA */
3187#ifdef HAVE_OPAQUE_LSA
3188#ifndef HAVE_NSSA
3189 " --- type-6 ---",
3190 " --- type-7 ---",
3191#endif /* HAVE_NSSA */
3192 " --- type-8 ---",
3193 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3194 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3195 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3196#endif /* HAVE_OPAQUE_LSA */
3197};
3198
3199void
3200show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3201{
3202 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
3203
3204 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
3205 vty_out (vty, " Options: %d%s", lsa->data->options, VTY_NEWLINE);
3206
3207 if (lsa->data->type == OSPF_ROUTER_LSA)
3208 {
3209 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3210
3211 if (rlsa->flags)
3212 vty_out (vty, " :%s%s%s%s",
3213 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3214 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3215 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3216 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3217
3218 vty_out (vty, "%s", VTY_NEWLINE);
3219 }
3220 vty_out (vty, " LS Type: %s%s",
3221 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3222 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3223 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3224 vty_out (vty, " Advertising Router: %s%s",
3225 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3226 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3227 VTY_NEWLINE);
3228 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3229 VTY_NEWLINE);
3230 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3231}
3232
3233char *link_type_desc[] =
3234{
3235 "(null)",
3236 "another Router (point-to-point)",
3237 "a Transit Network",
3238 "Stub Network",
3239 "a Virtual Link",
3240};
3241
3242char *link_id_desc[] =
3243{
3244 "(null)",
3245 "Neighboring Router ID",
3246 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003247 "Net",
paul718e3742002-12-13 20:15:29 +00003248 "Neighboring Router ID",
3249};
3250
3251char *link_data_desc[] =
3252{
3253 "(null)",
3254 "Router Interface address",
3255 "Router Interface address",
3256 "Network Mask",
3257 "Router Interface address",
3258};
3259
3260/* Show router-LSA each Link information. */
3261void
3262show_ip_ospf_database_router_links (struct vty *vty,
3263 struct router_lsa *rl)
3264{
3265 int len, i, type;
3266
3267 len = ntohs (rl->header.length) - 4;
3268 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3269 {
3270 type = rl->link[i].type;
3271
3272 vty_out (vty, " Link connected to: %s%s",
3273 link_type_desc[type], VTY_NEWLINE);
3274 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3275 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3276 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3277 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3278 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3279 vty_out (vty, " TOS 0 Metric: %d%s",
3280 ntohs (rl->link[i].metric), VTY_NEWLINE);
3281 vty_out (vty, "%s", VTY_NEWLINE);
3282 }
3283}
3284
3285/* Show router-LSA detail information. */
3286int
3287show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3288{
3289 if (lsa != NULL)
3290 {
3291 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3292
3293 show_ip_ospf_database_header (vty, lsa);
3294
3295 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3296 VTY_NEWLINE, VTY_NEWLINE);
3297
3298 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003299 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003300 }
3301
3302 return 0;
3303}
3304
3305/* Show network-LSA detail information. */
3306int
3307show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3308{
3309 int length, i;
3310
3311 if (lsa != NULL)
3312 {
3313 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3314
3315 show_ip_ospf_database_header (vty, lsa);
3316
3317 vty_out (vty, " Network Mask: /%d%s",
3318 ip_masklen (nl->mask), VTY_NEWLINE);
3319
3320 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3321
3322 for (i = 0; length > 0; i++, length -= 4)
3323 vty_out (vty, " Attached Router: %s%s",
3324 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3325
3326 vty_out (vty, "%s", VTY_NEWLINE);
3327 }
3328
3329 return 0;
3330}
3331
3332/* Show summary-LSA detail information. */
3333int
3334show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3335{
3336 if (lsa != NULL)
3337 {
3338 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3339
3340 show_ip_ospf_database_header (vty, lsa);
3341
3342 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3343 VTY_NEWLINE);
3344 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3345 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003346 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003347 }
3348
3349 return 0;
3350}
3351
3352/* Show summary-ASBR-LSA detail information. */
3353int
3354show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3355{
3356 if (lsa != NULL)
3357 {
3358 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3359
3360 show_ip_ospf_database_header (vty, lsa);
3361
3362 vty_out (vty, " Network Mask: /%d%s",
3363 ip_masklen (sl->mask), VTY_NEWLINE);
3364 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3365 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003366 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003367 }
3368
3369 return 0;
3370}
3371
3372/* Show AS-external-LSA detail information. */
3373int
3374show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3375{
3376 if (lsa != NULL)
3377 {
3378 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3379
3380 show_ip_ospf_database_header (vty, lsa);
3381
3382 vty_out (vty, " Network Mask: /%d%s",
3383 ip_masklen (al->mask), VTY_NEWLINE);
3384 vty_out (vty, " Metric Type: %s%s",
3385 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3386 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3387 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3388 vty_out (vty, " Metric: %d%s",
3389 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3390 vty_out (vty, " Forward Address: %s%s",
3391 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3392
3393 vty_out (vty, " External Route Tag: %lu%s%s",
3394 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3395 }
3396
3397 return 0;
3398}
3399
3400#ifdef HAVE_NSSA
3401int
3402show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3403{
3404 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3405
3406 /* show_ip_ospf_database_header (vty, lsa); */
3407
3408 zlog_info( " Network Mask: /%d%s",
3409 ip_masklen (al->mask), "\n");
3410 zlog_info( " Metric Type: %s%s",
3411 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3412 "2 (Larger than any link state path)" : "1", "\n");
3413 zlog_info( " TOS: 0%s", "\n");
3414 zlog_info( " Metric: %d%s",
3415 GET_METRIC (al->e[0].metric), "\n");
3416 zlog_info( " Forward Address: %s%s",
3417 inet_ntoa (al->e[0].fwd_addr), "\n");
3418
3419 zlog_info( " External Route Tag: %u%s%s",
3420 ntohl (al->e[0].route_tag), "\n", "\n");
3421
3422 return 0;
3423}
3424
3425/* Show AS-NSSA-LSA detail information. */
3426int
3427show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3428{
3429 if (lsa != NULL)
3430 {
3431 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3432
3433 show_ip_ospf_database_header (vty, lsa);
3434
3435 vty_out (vty, " Network Mask: /%d%s",
3436 ip_masklen (al->mask), VTY_NEWLINE);
3437 vty_out (vty, " Metric Type: %s%s",
3438 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3439 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3440 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3441 vty_out (vty, " Metric: %d%s",
3442 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3443 vty_out (vty, " NSSA: Forward Address: %s%s",
3444 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3445
3446 vty_out (vty, " External Route Tag: %u%s%s",
3447 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3448 }
3449
3450 return 0;
3451}
3452
3453#endif /* HAVE_NSSA */
3454
3455int
3456show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3457{
3458 return 0;
3459}
3460
3461#ifdef HAVE_OPAQUE_LSA
3462int
3463show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3464{
3465 if (lsa != NULL)
3466 {
3467 show_ip_ospf_database_header (vty, lsa);
3468 show_opaque_info_detail (vty, lsa);
3469
3470 vty_out (vty, "%s", VTY_NEWLINE);
3471 }
3472 return 0;
3473}
3474#endif /* HAVE_OPAQUE_LSA */
3475
3476int (*show_function[])(struct vty *, struct ospf_lsa *) =
3477{
3478 NULL,
3479 show_router_lsa_detail,
3480 show_network_lsa_detail,
3481 show_summary_lsa_detail,
3482 show_summary_asbr_lsa_detail,
3483 show_as_external_lsa_detail,
3484#ifdef HAVE_NSSA
3485 show_func_dummy,
3486 show_as_nssa_lsa_detail, /* almost same as external */
3487#endif /* HAVE_NSSA */
3488#ifdef HAVE_OPAQUE_LSA
3489#ifndef HAVE_NSSA
3490 show_func_dummy,
3491 show_func_dummy,
3492#endif /* HAVE_NSSA */
3493 NULL, /* type-8 */
3494 show_opaque_lsa_detail,
3495 show_opaque_lsa_detail,
3496 show_opaque_lsa_detail,
3497#endif /* HAVE_OPAQUE_LSA */
3498};
3499
3500void
3501show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3502 struct in_addr *adv_router)
3503{
3504 memset (lp, 0, sizeof (struct prefix_ls));
3505 lp->family = 0;
3506 if (id == NULL)
3507 lp->prefixlen = 0;
3508 else if (adv_router == NULL)
3509 {
3510 lp->prefixlen = 32;
3511 lp->id = *id;
3512 }
3513 else
3514 {
3515 lp->prefixlen = 64;
3516 lp->id = *id;
3517 lp->adv_router = *adv_router;
3518 }
3519}
3520
3521void
3522show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3523 struct in_addr *id, struct in_addr *adv_router)
3524{
3525 struct prefix_ls lp;
3526 struct route_node *rn, *start;
3527 struct ospf_lsa *lsa;
3528
3529 show_lsa_prefix_set (vty, &lp, id, adv_router);
3530 start = route_node_get (rt, (struct prefix *) &lp);
3531 if (start)
3532 {
3533 route_lock_node (start);
3534 for (rn = start; rn; rn = route_next_until (rn, start))
3535 if ((lsa = rn->info))
3536 {
3537#ifdef HAVE_NSSA
3538 /* Stay away from any Local Translated Type-7 LSAs */
3539 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3540 continue;
3541#endif /* HAVE_NSSA */
3542
3543 if (show_function[lsa->data->type] != NULL)
3544 show_function[lsa->data->type] (vty, lsa);
3545 }
3546 route_unlock_node (start);
3547 }
3548}
3549
3550/* Show detail LSA information
3551 -- if id is NULL then show all LSAs. */
3552void
paul020709f2003-04-04 02:44:16 +00003553show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003554 struct in_addr *id, struct in_addr *adv_router)
3555{
3556 listnode node;
3557
3558 switch (type)
3559 {
3560 case OSPF_AS_EXTERNAL_LSA:
3561#ifdef HAVE_OPAQUE_LSA
3562 case OSPF_OPAQUE_AS_LSA:
3563#endif /* HAVE_OPAQUE_LSA */
3564 vty_out (vty, " %s %s%s",
3565 show_database_desc[type],
3566 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003567 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003568 break;
3569 default:
paul68980082003-03-25 05:07:42 +00003570 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003571 {
3572 struct ospf_area *area = node->data;
3573 vty_out (vty, "%s %s (Area %s)%s%s",
3574 VTY_NEWLINE, show_database_desc[type],
3575 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3576 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3577 }
3578 break;
3579 }
3580}
3581
3582void
3583show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3584 struct in_addr *adv_router)
3585{
3586 struct route_node *rn;
3587 struct ospf_lsa *lsa;
3588
3589 for (rn = route_top (rt); rn; rn = route_next (rn))
3590 if ((lsa = rn->info))
3591 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3592 {
3593#ifdef HAVE_NSSA
3594 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3595 continue;
3596#endif /* HAVE_NSSA */
3597 if (show_function[lsa->data->type] != NULL)
3598 show_function[lsa->data->type] (vty, lsa);
3599 }
3600}
3601
3602/* Show detail LSA information. */
3603void
paul020709f2003-04-04 02:44:16 +00003604show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003605 struct in_addr *adv_router)
3606{
3607 listnode node;
3608
3609 switch (type)
3610 {
3611 case OSPF_AS_EXTERNAL_LSA:
3612#ifdef HAVE_OPAQUE_LSA
3613 case OSPF_OPAQUE_AS_LSA:
3614#endif /* HAVE_OPAQUE_LSA */
3615 vty_out (vty, " %s %s%s",
3616 show_database_desc[type],
3617 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003618 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003619 adv_router);
3620 break;
3621 default:
paul68980082003-03-25 05:07:42 +00003622 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003623 {
3624 struct ospf_area *area = node->data;
3625 vty_out (vty, "%s %s (Area %s)%s%s",
3626 VTY_NEWLINE, show_database_desc[type],
3627 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3628 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3629 adv_router);
3630 }
3631 break;
3632 }
3633}
3634
3635void
paul020709f2003-04-04 02:44:16 +00003636show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003637{
paul020709f2003-04-04 02:44:16 +00003638 struct ospf_lsa *lsa;
3639 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00003640 listnode node;
3641 int type;
3642
paul68980082003-03-25 05:07:42 +00003643 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003644 {
3645 struct ospf_area *area = node->data;
3646 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3647 {
3648 switch (type)
3649 {
3650 case OSPF_AS_EXTERNAL_LSA:
3651#ifdef HAVE_OPAQUE_LSA
3652 case OSPF_OPAQUE_AS_LSA:
3653#endif /* HAVE_OPAQUE_LSA */
3654 continue;
3655 default:
3656 break;
3657 }
3658 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3659 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3660 {
3661 vty_out (vty, " %s (Area %s)%s%s",
3662 show_database_desc[type],
3663 ospf_area_desc_string (area),
3664 VTY_NEWLINE, VTY_NEWLINE);
3665 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3666
paul020709f2003-04-04 02:44:16 +00003667 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3668 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003669
3670 vty_out (vty, "%s", VTY_NEWLINE);
3671 }
3672 }
3673 }
3674
3675 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3676 {
3677 switch (type)
3678 {
3679 case OSPF_AS_EXTERNAL_LSA:
3680#ifdef HAVE_OPAQUE_LSA
3681 case OSPF_OPAQUE_AS_LSA:
3682#endif /* HAVE_OPAQUE_LSA */
3683 break;;
3684 default:
3685 continue;
3686 }
paul68980082003-03-25 05:07:42 +00003687 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3688 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003689 {
3690 vty_out (vty, " %s%s%s",
3691 show_database_desc[type],
3692 VTY_NEWLINE, VTY_NEWLINE);
3693 vty_out (vty, "%s%s", show_database_header[type],
3694 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003695
3696 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3697 show_lsa_summary (vty, lsa, self);
3698
paul718e3742002-12-13 20:15:29 +00003699 vty_out (vty, "%s", VTY_NEWLINE);
3700 }
3701 }
3702
3703 vty_out (vty, "%s", VTY_NEWLINE);
3704}
3705
3706void
paul020709f2003-04-04 02:44:16 +00003707show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003708{
3709 listnode node;
3710 struct ospf_lsa *lsa;
3711
3712 vty_out (vty, "%s MaxAge Link States:%s%s",
3713 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3714
paul68980082003-03-25 05:07:42 +00003715 for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003716 if ((lsa = node->data) != NULL)
3717 {
3718 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3719 vty_out (vty, "Link State ID: %s%s",
3720 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3721 vty_out (vty, "Advertising Router: %s%s",
3722 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3723 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3724 vty_out (vty, "%s", VTY_NEWLINE);
3725 }
3726}
3727
3728#ifdef HAVE_NSSA
3729#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3730#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
3731#else /* HAVE_NSSA */
3732#define OSPF_LSA_TYPE_NSSA_DESC ""
3733#define OSPF_LSA_TYPE_NSSA_CMD_STR ""
3734#endif /* HAVE_NSSA */
3735
3736#ifdef HAVE_OPAQUE_LSA
3737#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3738#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3739#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3740#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3741#else /* HAVE_OPAQUE_LSA */
3742#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3743#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3744#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3745#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3746#endif /* HAVE_OPAQUE_LSA */
3747
3748#define OSPF_LSA_TYPES_CMD_STR \
3749 "asbr-summary|external|network|router|summary" \
3750 OSPF_LSA_TYPE_NSSA_CMD_STR \
3751 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3752
3753#define OSPF_LSA_TYPES_DESC \
3754 "ASBR summary link states\n" \
3755 "External link states\n" \
3756 "Network link states\n" \
3757 "Router link states\n" \
3758 "Network summary link states\n" \
3759 OSPF_LSA_TYPE_NSSA_DESC \
3760 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3761 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3762 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3763
3764DEFUN (show_ip_ospf_database,
3765 show_ip_ospf_database_cmd,
3766 "show ip ospf database",
3767 SHOW_STR
3768 IP_STR
3769 "OSPF information\n"
3770 "Database summary\n")
3771{
paul020709f2003-04-04 02:44:16 +00003772 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003773 int type, ret;
3774 struct in_addr id, adv_router;
3775
paul020709f2003-04-04 02:44:16 +00003776 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003777 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003778 return CMD_SUCCESS;
3779
3780 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003781 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003782
3783 /* Show all LSA. */
3784 if (argc == 0)
3785 {
paul020709f2003-04-04 02:44:16 +00003786 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003787 return CMD_SUCCESS;
3788 }
3789
3790 /* Set database type to show. */
3791 if (strncmp (argv[0], "r", 1) == 0)
3792 type = OSPF_ROUTER_LSA;
3793 else if (strncmp (argv[0], "ne", 2) == 0)
3794 type = OSPF_NETWORK_LSA;
3795#ifdef HAVE_NSSA
3796 else if (strncmp (argv[0], "ns", 2) == 0)
3797 type = OSPF_AS_NSSA_LSA;
3798#endif /* HAVE_NSSA */
3799 else if (strncmp (argv[0], "su", 2) == 0)
3800 type = OSPF_SUMMARY_LSA;
3801 else if (strncmp (argv[0], "a", 1) == 0)
3802 type = OSPF_ASBR_SUMMARY_LSA;
3803 else if (strncmp (argv[0], "e", 1) == 0)
3804 type = OSPF_AS_EXTERNAL_LSA;
3805 else if (strncmp (argv[0], "se", 2) == 0)
3806 {
paul020709f2003-04-04 02:44:16 +00003807 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003808 return CMD_SUCCESS;
3809 }
3810 else if (strncmp (argv[0], "m", 1) == 0)
3811 {
paul020709f2003-04-04 02:44:16 +00003812 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003813 return CMD_SUCCESS;
3814 }
3815#ifdef HAVE_OPAQUE_LSA
3816 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3817 type = OSPF_OPAQUE_LINK_LSA;
3818 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3819 type = OSPF_OPAQUE_AREA_LSA;
3820 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3821 type = OSPF_OPAQUE_AS_LSA;
3822#endif /* HAVE_OPAQUE_LSA */
3823 else
3824 return CMD_WARNING;
3825
3826 /* `show ip ospf database LSA'. */
3827 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003828 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003829 else if (argc >= 2)
3830 {
3831 ret = inet_aton (argv[1], &id);
3832 if (!ret)
3833 return CMD_WARNING;
3834
3835 /* `show ip ospf database LSA ID'. */
3836 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003837 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003838 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3839 else if (argc == 3)
3840 {
3841 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003842 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003843 else
3844 {
3845 ret = inet_aton (argv[2], &adv_router);
3846 if (!ret)
3847 return CMD_WARNING;
3848 }
paul020709f2003-04-04 02:44:16 +00003849 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003850 }
3851 }
3852
3853 return CMD_SUCCESS;
3854}
3855
3856ALIAS (show_ip_ospf_database,
3857 show_ip_ospf_database_type_cmd,
3858 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3859 SHOW_STR
3860 IP_STR
3861 "OSPF information\n"
3862 "Database summary\n"
3863 OSPF_LSA_TYPES_DESC
3864 "LSAs in MaxAge list\n"
3865 "Self-originated link states\n")
3866
3867ALIAS (show_ip_ospf_database,
3868 show_ip_ospf_database_type_id_cmd,
3869 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3870 SHOW_STR
3871 IP_STR
3872 "OSPF information\n"
3873 "Database summary\n"
3874 OSPF_LSA_TYPES_DESC
3875 "Link State ID (as an IP address)\n")
3876
3877ALIAS (show_ip_ospf_database,
3878 show_ip_ospf_database_type_id_adv_router_cmd,
3879 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3880 SHOW_STR
3881 IP_STR
3882 "OSPF information\n"
3883 "Database summary\n"
3884 OSPF_LSA_TYPES_DESC
3885 "Link State ID (as an IP address)\n"
3886 "Advertising Router link states\n"
3887 "Advertising Router (as an IP address)\n")
3888
3889ALIAS (show_ip_ospf_database,
3890 show_ip_ospf_database_type_id_self_cmd,
3891 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3892 SHOW_STR
3893 IP_STR
3894 "OSPF information\n"
3895 "Database summary\n"
3896 OSPF_LSA_TYPES_DESC
3897 "Link State ID (as an IP address)\n"
3898 "Self-originated link states\n"
3899 "\n")
3900
3901DEFUN (show_ip_ospf_database_type_adv_router,
3902 show_ip_ospf_database_type_adv_router_cmd,
3903 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3904 SHOW_STR
3905 IP_STR
3906 "OSPF information\n"
3907 "Database summary\n"
3908 OSPF_LSA_TYPES_DESC
3909 "Advertising Router link states\n"
3910 "Advertising Router (as an IP address)\n")
3911{
paul020709f2003-04-04 02:44:16 +00003912 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003913 int type, ret;
3914 struct in_addr adv_router;
3915
paul020709f2003-04-04 02:44:16 +00003916 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003917 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003918 return CMD_SUCCESS;
3919
3920 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003921 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003922
3923 if (argc != 2)
3924 return CMD_WARNING;
3925
3926 /* Set database type to show. */
3927 if (strncmp (argv[0], "r", 1) == 0)
3928 type = OSPF_ROUTER_LSA;
3929 else if (strncmp (argv[0], "ne", 2) == 0)
3930 type = OSPF_NETWORK_LSA;
3931#ifdef HAVE_NSSA
3932 else if (strncmp (argv[0], "ns", 2) == 0)
3933 type = OSPF_AS_NSSA_LSA;
3934#endif /* HAVE_NSSA */
3935 else if (strncmp (argv[0], "s", 1) == 0)
3936 type = OSPF_SUMMARY_LSA;
3937 else if (strncmp (argv[0], "a", 1) == 0)
3938 type = OSPF_ASBR_SUMMARY_LSA;
3939 else if (strncmp (argv[0], "e", 1) == 0)
3940 type = OSPF_AS_EXTERNAL_LSA;
3941#ifdef HAVE_OPAQUE_LSA
3942 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3943 type = OSPF_OPAQUE_LINK_LSA;
3944 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3945 type = OSPF_OPAQUE_AREA_LSA;
3946 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3947 type = OSPF_OPAQUE_AS_LSA;
3948#endif /* HAVE_OPAQUE_LSA */
3949 else
3950 return CMD_WARNING;
3951
3952 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
3953 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003954 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003955 else
3956 {
3957 ret = inet_aton (argv[1], &adv_router);
3958 if (!ret)
3959 return CMD_WARNING;
3960 }
3961
paul020709f2003-04-04 02:44:16 +00003962 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00003963
3964 return CMD_SUCCESS;
3965}
3966
3967ALIAS (show_ip_ospf_database_type_adv_router,
3968 show_ip_ospf_database_type_self_cmd,
3969 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
3970 SHOW_STR
3971 IP_STR
3972 "OSPF information\n"
3973 "Database summary\n"
3974 OSPF_LSA_TYPES_DESC
3975 "Self-originated link states\n")
3976
3977
3978DEFUN (ip_ospf_authentication_args,
3979 ip_ospf_authentication_args_addr_cmd,
3980 "ip ospf authentication (null|message-digest) A.B.C.D",
3981 "IP Information\n"
3982 "OSPF interface commands\n"
3983 "Enable authentication on this interface\n"
3984 "Use null authentication\n"
3985 "Use message-digest authentication\n"
3986 "Address of interface")
3987{
3988 struct interface *ifp;
3989 struct in_addr addr;
3990 int ret;
3991 struct ospf_if_params *params;
3992
3993 ifp = vty->index;
3994 params = IF_DEF_PARAMS (ifp);
3995
3996 if (argc == 2)
3997 {
3998 ret = inet_aton(argv[1], &addr);
3999 if (!ret)
4000 {
4001 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4002 VTY_NEWLINE);
4003 return CMD_WARNING;
4004 }
4005
4006 params = ospf_get_if_params (ifp, addr);
4007 ospf_if_update_params (ifp, addr);
4008 }
4009
4010 /* Handle null authentication */
4011 if ( argv[0][0] == 'n' )
4012 {
4013 SET_IF_PARAM (params, auth_type);
4014 params->auth_type = OSPF_AUTH_NULL;
4015 return CMD_SUCCESS;
4016 }
4017
4018 /* Handle message-digest authentication */
4019 if ( argv[0][0] == 'm' )
4020 {
4021 SET_IF_PARAM (params, auth_type);
4022 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4023 return CMD_SUCCESS;
4024 }
4025
4026 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4027 return CMD_WARNING;
4028}
4029
4030ALIAS (ip_ospf_authentication_args,
4031 ip_ospf_authentication_args_cmd,
4032 "ip ospf authentication (null|message-digest)",
4033 "IP Information\n"
4034 "OSPF interface commands\n"
4035 "Enable authentication on this interface\n"
4036 "Use null authentication\n"
4037 "Use message-digest authentication\n")
4038
4039DEFUN (ip_ospf_authentication,
4040 ip_ospf_authentication_addr_cmd,
4041 "ip ospf authentication A.B.C.D",
4042 "IP Information\n"
4043 "OSPF interface commands\n"
4044 "Enable authentication on this interface\n"
4045 "Address of interface")
4046{
4047 struct interface *ifp;
4048 struct in_addr addr;
4049 int ret;
4050 struct ospf_if_params *params;
4051
4052 ifp = vty->index;
4053 params = IF_DEF_PARAMS (ifp);
4054
4055 if (argc == 1)
4056 {
4057 ret = inet_aton(argv[1], &addr);
4058 if (!ret)
4059 {
4060 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4061 VTY_NEWLINE);
4062 return CMD_WARNING;
4063 }
4064
4065 params = ospf_get_if_params (ifp, addr);
4066 ospf_if_update_params (ifp, addr);
4067 }
4068
4069 SET_IF_PARAM (params, auth_type);
4070 params->auth_type = OSPF_AUTH_SIMPLE;
4071
4072 return CMD_SUCCESS;
4073}
4074
4075ALIAS (ip_ospf_authentication,
4076 ip_ospf_authentication_cmd,
4077 "ip ospf authentication",
4078 "IP Information\n"
4079 "OSPF interface commands\n"
4080 "Enable authentication on this interface\n")
4081
4082DEFUN (no_ip_ospf_authentication,
4083 no_ip_ospf_authentication_addr_cmd,
4084 "no ip ospf authentication A.B.C.D",
4085 NO_STR
4086 "IP Information\n"
4087 "OSPF interface commands\n"
4088 "Enable authentication on this interface\n"
4089 "Address of interface")
4090{
4091 struct interface *ifp;
4092 struct in_addr addr;
4093 int ret;
4094 struct ospf_if_params *params;
4095
4096 ifp = vty->index;
4097 params = IF_DEF_PARAMS (ifp);
4098
4099 if (argc == 1)
4100 {
4101 ret = inet_aton(argv[1], &addr);
4102 if (!ret)
4103 {
4104 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4105 VTY_NEWLINE);
4106 return CMD_WARNING;
4107 }
4108
4109 params = ospf_lookup_if_params (ifp, addr);
4110 if (params == NULL)
4111 return CMD_SUCCESS;
4112 }
4113
4114 params->auth_type = OSPF_AUTH_NOTSET;
4115 UNSET_IF_PARAM (params, auth_type);
4116
4117 if (params != IF_DEF_PARAMS (ifp))
4118 {
4119 ospf_free_if_params (ifp, addr);
4120 ospf_if_update_params (ifp, addr);
4121 }
4122
4123 return CMD_SUCCESS;
4124}
4125
4126ALIAS (no_ip_ospf_authentication,
4127 no_ip_ospf_authentication_cmd,
4128 "no ip ospf authentication",
4129 NO_STR
4130 "IP Information\n"
4131 "OSPF interface commands\n"
4132 "Enable authentication on this interface\n")
4133
4134DEFUN (ip_ospf_authentication_key,
4135 ip_ospf_authentication_key_addr_cmd,
4136 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4137 "IP Information\n"
4138 "OSPF interface commands\n"
4139 "Authentication password (key)\n"
4140 "The OSPF password (key)\n"
4141 "Address of interface")
4142{
4143 struct interface *ifp;
4144 struct in_addr addr;
4145 int ret;
4146 struct ospf_if_params *params;
4147
4148 ifp = vty->index;
4149 params = IF_DEF_PARAMS (ifp);
4150
4151 if (argc == 2)
4152 {
4153 ret = inet_aton(argv[1], &addr);
4154 if (!ret)
4155 {
4156 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4157 VTY_NEWLINE);
4158 return CMD_WARNING;
4159 }
4160
4161 params = ospf_get_if_params (ifp, addr);
4162 ospf_if_update_params (ifp, addr);
4163 }
4164
4165
4166 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
4167 strncpy (params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
4168 SET_IF_PARAM (params, auth_simple);
4169
4170 return CMD_SUCCESS;
4171}
4172
4173ALIAS (ip_ospf_authentication_key,
4174 ip_ospf_authentication_key_cmd,
4175 "ip ospf authentication-key AUTH_KEY",
4176 "IP Information\n"
4177 "OSPF interface commands\n"
4178 "Authentication password (key)\n"
4179 "The OSPF password (key)")
4180
4181ALIAS (ip_ospf_authentication_key,
4182 ospf_authentication_key_cmd,
4183 "ospf authentication-key AUTH_KEY",
4184 "OSPF interface commands\n"
4185 "Authentication password (key)\n"
4186 "The OSPF password (key)")
4187
4188DEFUN (no_ip_ospf_authentication_key,
4189 no_ip_ospf_authentication_key_addr_cmd,
4190 "no ip ospf authentication-key A.B.C.D",
4191 NO_STR
4192 "IP Information\n"
4193 "OSPF interface commands\n"
4194 "Authentication password (key)\n"
4195 "Address of interface")
4196{
4197 struct interface *ifp;
4198 struct in_addr addr;
4199 int ret;
4200 struct ospf_if_params *params;
4201
4202 ifp = vty->index;
4203 params = IF_DEF_PARAMS (ifp);
4204
4205 if (argc == 2)
4206 {
4207 ret = inet_aton(argv[1], &addr);
4208 if (!ret)
4209 {
4210 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4211 VTY_NEWLINE);
4212 return CMD_WARNING;
4213 }
4214
4215 params = ospf_lookup_if_params (ifp, addr);
4216 if (params == NULL)
4217 return CMD_SUCCESS;
4218 }
4219
4220 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4221 UNSET_IF_PARAM (params, auth_simple);
4222
4223 if (params != IF_DEF_PARAMS (ifp))
4224 {
4225 ospf_free_if_params (ifp, addr);
4226 ospf_if_update_params (ifp, addr);
4227 }
4228
4229 return CMD_SUCCESS;
4230}
4231
4232ALIAS (no_ip_ospf_authentication_key,
4233 no_ip_ospf_authentication_key_cmd,
4234 "no ip ospf authentication-key",
4235 NO_STR
4236 "IP Information\n"
4237 "OSPF interface commands\n"
4238 "Authentication password (key)\n")
4239
4240ALIAS (no_ip_ospf_authentication_key,
4241 no_ospf_authentication_key_cmd,
4242 "no ospf authentication-key",
4243 NO_STR
4244 "OSPF interface commands\n"
4245 "Authentication password (key)\n")
4246
4247DEFUN (ip_ospf_message_digest_key,
4248 ip_ospf_message_digest_key_addr_cmd,
4249 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4250 "IP Information\n"
4251 "OSPF interface commands\n"
4252 "Message digest authentication password (key)\n"
4253 "Key ID\n"
4254 "Use MD5 algorithm\n"
4255 "The OSPF password (key)"
4256 "Address of interface")
4257{
4258 struct interface *ifp;
4259 struct crypt_key *ck;
4260 u_char key_id;
4261 struct in_addr addr;
4262 int ret;
4263 struct ospf_if_params *params;
4264
4265 ifp = vty->index;
4266 params = IF_DEF_PARAMS (ifp);
4267
4268 if (argc == 3)
4269 {
4270 ret = inet_aton(argv[2], &addr);
4271 if (!ret)
4272 {
4273 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4274 VTY_NEWLINE);
4275 return CMD_WARNING;
4276 }
4277
4278 params = ospf_get_if_params (ifp, addr);
4279 ospf_if_update_params (ifp, addr);
4280 }
4281
4282 key_id = strtol (argv[0], NULL, 10);
4283 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4284 {
4285 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4286 return CMD_WARNING;
4287 }
4288
4289 ck = ospf_crypt_key_new ();
4290 ck->key_id = (u_char) key_id;
4291 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
4292 strncpy (ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
4293
4294 ospf_crypt_key_add (params->auth_crypt, ck);
4295 SET_IF_PARAM (params, auth_crypt);
4296
4297 return CMD_SUCCESS;
4298}
4299
4300ALIAS (ip_ospf_message_digest_key,
4301 ip_ospf_message_digest_key_cmd,
4302 "ip ospf message-digest-key <1-255> md5 KEY",
4303 "IP Information\n"
4304 "OSPF interface commands\n"
4305 "Message digest authentication password (key)\n"
4306 "Key ID\n"
4307 "Use MD5 algorithm\n"
4308 "The OSPF password (key)")
4309
4310ALIAS (ip_ospf_message_digest_key,
4311 ospf_message_digest_key_cmd,
4312 "ospf message-digest-key <1-255> md5 KEY",
4313 "OSPF interface commands\n"
4314 "Message digest authentication password (key)\n"
4315 "Key ID\n"
4316 "Use MD5 algorithm\n"
4317 "The OSPF password (key)")
4318
4319DEFUN (no_ip_ospf_message_digest_key,
4320 no_ip_ospf_message_digest_key_addr_cmd,
4321 "no ip ospf message-digest-key <1-255> A.B.C.D",
4322 NO_STR
4323 "IP Information\n"
4324 "OSPF interface commands\n"
4325 "Message digest authentication password (key)\n"
4326 "Key ID\n"
4327 "Address of interface")
4328{
4329 struct interface *ifp;
4330 struct crypt_key *ck;
4331 int key_id;
4332 struct in_addr addr;
4333 int ret;
4334 struct ospf_if_params *params;
4335
4336 ifp = vty->index;
4337 params = IF_DEF_PARAMS (ifp);
4338
4339 if (argc == 2)
4340 {
4341 ret = inet_aton(argv[1], &addr);
4342 if (!ret)
4343 {
4344 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4345 VTY_NEWLINE);
4346 return CMD_WARNING;
4347 }
4348
4349 params = ospf_lookup_if_params (ifp, addr);
4350 if (params == NULL)
4351 return CMD_SUCCESS;
4352 }
4353
4354 key_id = strtol (argv[0], NULL, 10);
4355 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4356 if (ck == NULL)
4357 {
4358 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4359 return CMD_WARNING;
4360 }
4361
4362 ospf_crypt_key_delete (params->auth_crypt, key_id);
4363
4364 if (params != IF_DEF_PARAMS (ifp))
4365 {
4366 ospf_free_if_params (ifp, addr);
4367 ospf_if_update_params (ifp, addr);
4368 }
4369
4370 return CMD_SUCCESS;
4371}
4372
4373ALIAS (no_ip_ospf_message_digest_key,
4374 no_ip_ospf_message_digest_key_cmd,
4375 "no ip ospf message-digest-key <1-255>",
4376 NO_STR
4377 "IP Information\n"
4378 "OSPF interface commands\n"
4379 "Message digest authentication password (key)\n"
4380 "Key ID\n")
4381
4382ALIAS (no_ip_ospf_message_digest_key,
4383 no_ospf_message_digest_key_cmd,
4384 "no ospf message-digest-key <1-255>",
4385 NO_STR
4386 "OSPF interface commands\n"
4387 "Message digest authentication password (key)\n"
4388 "Key ID\n")
4389
4390DEFUN (ip_ospf_cost,
4391 ip_ospf_cost_addr_cmd,
4392 "ip ospf cost <1-65535> A.B.C.D",
4393 "IP Information\n"
4394 "OSPF interface commands\n"
4395 "Interface cost\n"
4396 "Cost\n"
4397 "Address of interface")
4398{
4399 struct interface *ifp = vty->index;
4400 u_int32_t cost;
4401 struct in_addr addr;
4402 int ret;
4403 struct ospf_if_params *params;
4404
4405 params = IF_DEF_PARAMS (ifp);
4406
4407 cost = strtol (argv[0], NULL, 10);
4408
4409 /* cost range is <1-65535>. */
4410 if (cost < 1 || cost > 65535)
4411 {
4412 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4413 return CMD_WARNING;
4414 }
4415
4416 if (argc == 2)
4417 {
4418 ret = inet_aton(argv[1], &addr);
4419 if (!ret)
4420 {
4421 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4422 VTY_NEWLINE);
4423 return CMD_WARNING;
4424 }
4425
4426 params = ospf_get_if_params (ifp, addr);
4427 ospf_if_update_params (ifp, addr);
4428 }
4429
4430 SET_IF_PARAM (params, output_cost_cmd);
4431 params->output_cost_cmd = cost;
4432
4433 ospf_if_recalculate_output_cost (ifp);
4434
4435 return CMD_SUCCESS;
4436}
4437
4438ALIAS (ip_ospf_cost,
4439 ip_ospf_cost_cmd,
4440 "ip ospf cost <1-65535>",
4441 "IP Information\n"
4442 "OSPF interface commands\n"
4443 "Interface cost\n"
4444 "Cost")
4445
4446ALIAS (ip_ospf_cost,
4447 ospf_cost_cmd,
4448 "ospf cost <1-65535>",
4449 "OSPF interface commands\n"
4450 "Interface cost\n"
4451 "Cost")
4452
4453DEFUN (no_ip_ospf_cost,
4454 no_ip_ospf_cost_addr_cmd,
4455 "no ip ospf cost A.B.C.D",
4456 NO_STR
4457 "IP Information\n"
4458 "OSPF interface commands\n"
4459 "Interface cost\n"
4460 "Address of interface")
4461{
4462 struct interface *ifp = vty->index;
4463 struct in_addr addr;
4464 int ret;
4465 struct ospf_if_params *params;
4466
4467 ifp = vty->index;
4468 params = IF_DEF_PARAMS (ifp);
4469
4470 if (argc == 1)
4471 {
4472 ret = inet_aton(argv[0], &addr);
4473 if (!ret)
4474 {
4475 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4476 VTY_NEWLINE);
4477 return CMD_WARNING;
4478 }
4479
4480 params = ospf_lookup_if_params (ifp, addr);
4481 if (params == NULL)
4482 return CMD_SUCCESS;
4483 }
4484
4485 UNSET_IF_PARAM (params, output_cost_cmd);
4486
4487 if (params != IF_DEF_PARAMS (ifp))
4488 {
4489 ospf_free_if_params (ifp, addr);
4490 ospf_if_update_params (ifp, addr);
4491 }
4492
4493 ospf_if_recalculate_output_cost (ifp);
4494
4495 return CMD_SUCCESS;
4496}
4497
4498ALIAS (no_ip_ospf_cost,
4499 no_ip_ospf_cost_cmd,
4500 "no ip ospf cost",
4501 NO_STR
4502 "IP Information\n"
4503 "OSPF interface commands\n"
4504 "Interface cost\n")
4505
4506ALIAS (no_ip_ospf_cost,
4507 no_ospf_cost_cmd,
4508 "no ospf cost",
4509 NO_STR
4510 "OSPF interface commands\n"
4511 "Interface cost\n")
4512
4513void
4514ospf_nbr_timer_update (struct ospf_interface *oi)
4515{
4516 struct route_node *rn;
4517 struct ospf_neighbor *nbr;
4518
4519 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4520 if ((nbr = rn->info))
4521 {
4522 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4523 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4524 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4525 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4526 }
4527}
4528
4529DEFUN (ip_ospf_dead_interval,
4530 ip_ospf_dead_interval_addr_cmd,
4531 "ip ospf dead-interval <1-65535> A.B.C.D",
4532 "IP Information\n"
4533 "OSPF interface commands\n"
4534 "Interval after which a neighbor is declared dead\n"
4535 "Seconds\n"
4536 "Address of interface")
4537{
4538 struct interface *ifp = vty->index;
4539 u_int32_t seconds;
4540 struct in_addr addr;
4541 int ret;
4542 struct ospf_if_params *params;
4543 struct ospf_interface *oi;
4544 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004545 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004546
paul020709f2003-04-04 02:44:16 +00004547 ospf = ospf_lookup ();
4548
paul718e3742002-12-13 20:15:29 +00004549 params = IF_DEF_PARAMS (ifp);
4550
4551 seconds = strtol (argv[0], NULL, 10);
4552
4553 /* dead_interval range is <1-65535>. */
4554 if (seconds < 1 || seconds > 65535)
4555 {
4556 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4557 return CMD_WARNING;
4558 }
4559
4560 if (argc == 2)
4561 {
4562 ret = inet_aton(argv[1], &addr);
4563 if (!ret)
4564 {
4565 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4566 VTY_NEWLINE);
4567 return CMD_WARNING;
4568 }
4569
4570 params = ospf_get_if_params (ifp, addr);
4571 ospf_if_update_params (ifp, addr);
4572 }
4573
4574 SET_IF_PARAM (params, v_wait);
4575 params->v_wait = seconds;
4576
4577 /* Update timer values in neighbor structure. */
4578 if (argc == 2)
4579 {
paul68980082003-03-25 05:07:42 +00004580 if (ospf)
4581 {
4582 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4583 if (oi)
4584 ospf_nbr_timer_update (oi);
4585 }
paul718e3742002-12-13 20:15:29 +00004586 }
4587 else
4588 {
4589 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4590 if ((oi = rn->info))
4591 ospf_nbr_timer_update (oi);
4592 }
4593
4594 return CMD_SUCCESS;
4595}
4596
4597ALIAS (ip_ospf_dead_interval,
4598 ip_ospf_dead_interval_cmd,
4599 "ip ospf dead-interval <1-65535>",
4600 "IP Information\n"
4601 "OSPF interface commands\n"
4602 "Interval after which a neighbor is declared dead\n"
4603 "Seconds\n")
4604
4605ALIAS (ip_ospf_dead_interval,
4606 ospf_dead_interval_cmd,
4607 "ospf dead-interval <1-65535>",
4608 "OSPF interface commands\n"
4609 "Interval after which a neighbor is declared dead\n"
4610 "Seconds\n")
4611
4612DEFUN (no_ip_ospf_dead_interval,
4613 no_ip_ospf_dead_interval_addr_cmd,
4614 "no ip ospf dead-interval A.B.C.D",
4615 NO_STR
4616 "IP Information\n"
4617 "OSPF interface commands\n"
4618 "Interval after which a neighbor is declared dead\n"
4619 "Address of interface")
4620{
4621 struct interface *ifp = vty->index;
4622 struct in_addr addr;
4623 int ret;
4624 struct ospf_if_params *params;
4625 struct ospf_interface *oi;
4626 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004627 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004628
paul020709f2003-04-04 02:44:16 +00004629 ospf = ospf_lookup ();
4630
paul718e3742002-12-13 20:15:29 +00004631 ifp = vty->index;
4632 params = IF_DEF_PARAMS (ifp);
4633
4634 if (argc == 1)
4635 {
4636 ret = inet_aton(argv[0], &addr);
4637 if (!ret)
4638 {
4639 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4640 VTY_NEWLINE);
4641 return CMD_WARNING;
4642 }
4643
4644 params = ospf_lookup_if_params (ifp, addr);
4645 if (params == NULL)
4646 return CMD_SUCCESS;
4647 }
4648
4649 UNSET_IF_PARAM (params, v_wait);
4650 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4651
4652 if (params != IF_DEF_PARAMS (ifp))
4653 {
4654 ospf_free_if_params (ifp, addr);
4655 ospf_if_update_params (ifp, addr);
4656 }
4657
4658 /* Update timer values in neighbor structure. */
4659 if (argc == 1)
4660 {
paul68980082003-03-25 05:07:42 +00004661 if (ospf)
4662 {
4663 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4664 if (oi)
4665 ospf_nbr_timer_update (oi);
4666 }
paul718e3742002-12-13 20:15:29 +00004667 }
4668 else
4669 {
4670 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4671 if ((oi = rn->info))
4672 ospf_nbr_timer_update (oi);
4673 }
4674
4675 return CMD_SUCCESS;
4676}
4677
4678ALIAS (no_ip_ospf_dead_interval,
4679 no_ip_ospf_dead_interval_cmd,
4680 "no ip ospf dead-interval",
4681 NO_STR
4682 "IP Information\n"
4683 "OSPF interface commands\n"
4684 "Interval after which a neighbor is declared dead\n")
4685
4686ALIAS (no_ip_ospf_dead_interval,
4687 no_ospf_dead_interval_cmd,
4688 "no ospf dead-interval",
4689 NO_STR
4690 "OSPF interface commands\n"
4691 "Interval after which a neighbor is declared dead\n")
4692
4693DEFUN (ip_ospf_hello_interval,
4694 ip_ospf_hello_interval_addr_cmd,
4695 "ip ospf hello-interval <1-65535> A.B.C.D",
4696 "IP Information\n"
4697 "OSPF interface commands\n"
4698 "Time between HELLO packets\n"
4699 "Seconds\n"
4700 "Address of interface")
4701{
4702 struct interface *ifp = vty->index;
4703 u_int32_t seconds;
4704 struct in_addr addr;
4705 int ret;
4706 struct ospf_if_params *params;
4707
4708 params = IF_DEF_PARAMS (ifp);
4709
4710 seconds = strtol (argv[0], NULL, 10);
4711
4712 /* HelloInterval range is <1-65535>. */
4713 if (seconds < 1 || seconds > 65535)
4714 {
4715 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4716 return CMD_WARNING;
4717 }
4718
4719 if (argc == 2)
4720 {
4721 ret = inet_aton(argv[1], &addr);
4722 if (!ret)
4723 {
4724 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4725 VTY_NEWLINE);
4726 return CMD_WARNING;
4727 }
4728
4729 params = ospf_get_if_params (ifp, addr);
4730 ospf_if_update_params (ifp, addr);
4731 }
4732
4733 SET_IF_PARAM (params, v_hello);
4734 params->v_hello = seconds;
4735
4736 return CMD_SUCCESS;
4737}
4738
4739ALIAS (ip_ospf_hello_interval,
4740 ip_ospf_hello_interval_cmd,
4741 "ip ospf hello-interval <1-65535>",
4742 "IP Information\n"
4743 "OSPF interface commands\n"
4744 "Time between HELLO packets\n"
4745 "Seconds\n")
4746
4747ALIAS (ip_ospf_hello_interval,
4748 ospf_hello_interval_cmd,
4749 "ospf hello-interval <1-65535>",
4750 "OSPF interface commands\n"
4751 "Time between HELLO packets\n"
4752 "Seconds\n")
4753
4754DEFUN (no_ip_ospf_hello_interval,
4755 no_ip_ospf_hello_interval_addr_cmd,
4756 "no ip ospf hello-interval A.B.C.D",
4757 NO_STR
4758 "IP Information\n"
4759 "OSPF interface commands\n"
4760 "Time between HELLO packets\n"
4761 "Address of interface")
4762{
4763 struct interface *ifp = vty->index;
4764 struct in_addr addr;
4765 int ret;
4766 struct ospf_if_params *params;
4767
4768 ifp = vty->index;
4769 params = IF_DEF_PARAMS (ifp);
4770
4771 if (argc == 1)
4772 {
4773 ret = inet_aton(argv[0], &addr);
4774 if (!ret)
4775 {
4776 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4777 VTY_NEWLINE);
4778 return CMD_WARNING;
4779 }
4780
4781 params = ospf_lookup_if_params (ifp, addr);
4782 if (params == NULL)
4783 return CMD_SUCCESS;
4784 }
4785
4786 UNSET_IF_PARAM (params, v_hello);
4787 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4788
4789 if (params != IF_DEF_PARAMS (ifp))
4790 {
4791 ospf_free_if_params (ifp, addr);
4792 ospf_if_update_params (ifp, addr);
4793 }
4794
4795 return CMD_SUCCESS;
4796}
4797
4798ALIAS (no_ip_ospf_hello_interval,
4799 no_ip_ospf_hello_interval_cmd,
4800 "no ip ospf hello-interval",
4801 NO_STR
4802 "IP Information\n"
4803 "OSPF interface commands\n"
4804 "Time between HELLO packets\n")
4805
4806ALIAS (no_ip_ospf_hello_interval,
4807 no_ospf_hello_interval_cmd,
4808 "no ospf hello-interval",
4809 NO_STR
4810 "OSPF interface commands\n"
4811 "Time between HELLO packets\n")
4812
4813DEFUN (ip_ospf_network,
4814 ip_ospf_network_cmd,
4815 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4816 "IP Information\n"
4817 "OSPF interface commands\n"
4818 "Network type\n"
4819 "Specify OSPF broadcast multi-access network\n"
4820 "Specify OSPF NBMA network\n"
4821 "Specify OSPF point-to-multipoint network\n"
4822 "Specify OSPF point-to-point network\n")
4823{
4824 struct interface *ifp = vty->index;
4825 int old_type = IF_DEF_PARAMS (ifp)->type;
4826 struct route_node *rn;
4827
4828 if (strncmp (argv[0], "b", 1) == 0)
4829 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4830 else if (strncmp (argv[0], "n", 1) == 0)
4831 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4832 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4833 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4834 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4835 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4836
4837 if (IF_DEF_PARAMS (ifp)->type == old_type)
4838 return CMD_SUCCESS;
4839
4840 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4841
4842 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4843 {
4844 struct ospf_interface *oi = rn->info;
4845
4846 if (!oi)
4847 continue;
4848
4849 oi->type = IF_DEF_PARAMS (ifp)->type;
4850
4851 if (oi->state > ISM_Down)
4852 {
4853 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4854 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4855 }
4856 }
4857
4858 return CMD_SUCCESS;
4859}
4860
4861ALIAS (ip_ospf_network,
4862 ospf_network_cmd,
4863 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4864 "OSPF interface commands\n"
4865 "Network type\n"
4866 "Specify OSPF broadcast multi-access network\n"
4867 "Specify OSPF NBMA network\n"
4868 "Specify OSPF point-to-multipoint network\n"
4869 "Specify OSPF point-to-point network\n")
4870
4871DEFUN (no_ip_ospf_network,
4872 no_ip_ospf_network_cmd,
4873 "no ip ospf network",
4874 NO_STR
4875 "IP Information\n"
4876 "OSPF interface commands\n"
4877 "Network type\n")
4878{
4879 struct interface *ifp = vty->index;
4880 int old_type = IF_DEF_PARAMS (ifp)->type;
4881 struct route_node *rn;
4882
4883 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4884
4885 if (IF_DEF_PARAMS (ifp)->type == old_type)
4886 return CMD_SUCCESS;
4887
4888 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4889 {
4890 struct ospf_interface *oi = rn->info;
4891
4892 if (!oi)
4893 continue;
4894
4895 oi->type = IF_DEF_PARAMS (ifp)->type;
4896
4897 if (oi->state > ISM_Down)
4898 {
4899 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4900 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4901 }
4902 }
4903
4904 return CMD_SUCCESS;
4905}
4906
4907ALIAS (no_ip_ospf_network,
4908 no_ospf_network_cmd,
4909 "no ospf network",
4910 NO_STR
4911 "OSPF interface commands\n"
4912 "Network type\n")
4913
4914DEFUN (ip_ospf_priority,
4915 ip_ospf_priority_addr_cmd,
4916 "ip ospf priority <0-255> A.B.C.D",
4917 "IP Information\n"
4918 "OSPF interface commands\n"
4919 "Router priority\n"
4920 "Priority\n"
4921 "Address of interface")
4922{
4923 struct interface *ifp = vty->index;
4924 u_int32_t priority;
4925 struct route_node *rn;
4926 struct in_addr addr;
4927 int ret;
4928 struct ospf_if_params *params;
4929
4930 params = IF_DEF_PARAMS (ifp);
4931
4932 priority = strtol (argv[0], NULL, 10);
4933
4934 /* Router Priority range is <0-255>. */
4935 if (priority < 0 || priority > 255)
4936 {
4937 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4938 return CMD_WARNING;
4939 }
4940
4941 if (argc == 2)
4942 {
4943 ret = inet_aton(argv[1], &addr);
4944 if (!ret)
4945 {
4946 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4947 VTY_NEWLINE);
4948 return CMD_WARNING;
4949 }
4950
4951 params = ospf_get_if_params (ifp, addr);
4952 ospf_if_update_params (ifp, addr);
4953 }
4954
4955 SET_IF_PARAM (params, priority);
4956 params->priority = priority;
4957
4958 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4959 {
4960 struct ospf_interface *oi = rn->info;
4961
4962 if (!oi)
4963 continue;
4964
4965
4966 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
4967 {
4968 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
4969 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
4970 }
4971 }
4972
4973 return CMD_SUCCESS;
4974}
4975
4976ALIAS (ip_ospf_priority,
4977 ip_ospf_priority_cmd,
4978 "ip ospf priority <0-255>",
4979 "IP Information\n"
4980 "OSPF interface commands\n"
4981 "Router priority\n"
4982 "Priority\n")
4983
4984ALIAS (ip_ospf_priority,
4985 ospf_priority_cmd,
4986 "ospf priority <0-255>",
4987 "OSPF interface commands\n"
4988 "Router priority\n"
4989 "Priority\n")
4990
4991DEFUN (no_ip_ospf_priority,
4992 no_ip_ospf_priority_addr_cmd,
4993 "no ip ospf priority A.B.C.D",
4994 NO_STR
4995 "IP Information\n"
4996 "OSPF interface commands\n"
4997 "Router priority\n"
4998 "Address of interface")
4999{
5000 struct interface *ifp = vty->index;
5001 struct route_node *rn;
5002 struct in_addr addr;
5003 int ret;
5004 struct ospf_if_params *params;
5005
5006 ifp = vty->index;
5007 params = IF_DEF_PARAMS (ifp);
5008
5009 if (argc == 1)
5010 {
5011 ret = inet_aton(argv[0], &addr);
5012 if (!ret)
5013 {
5014 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5015 VTY_NEWLINE);
5016 return CMD_WARNING;
5017 }
5018
5019 params = ospf_lookup_if_params (ifp, addr);
5020 if (params == NULL)
5021 return CMD_SUCCESS;
5022 }
5023
5024 UNSET_IF_PARAM (params, priority);
5025 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5026
5027 if (params != IF_DEF_PARAMS (ifp))
5028 {
5029 ospf_free_if_params (ifp, addr);
5030 ospf_if_update_params (ifp, addr);
5031 }
5032
5033 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5034 {
5035 struct ospf_interface *oi = rn->info;
5036
5037 if (!oi)
5038 continue;
5039
5040
5041 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5042 {
5043 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5044 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5045 }
5046 }
5047
5048 return CMD_SUCCESS;
5049}
5050
5051ALIAS (no_ip_ospf_priority,
5052 no_ip_ospf_priority_cmd,
5053 "no ip ospf priority",
5054 NO_STR
5055 "IP Information\n"
5056 "OSPF interface commands\n"
5057 "Router priority\n")
5058
5059ALIAS (no_ip_ospf_priority,
5060 no_ospf_priority_cmd,
5061 "no ospf priority",
5062 NO_STR
5063 "OSPF interface commands\n"
5064 "Router priority\n")
5065
5066DEFUN (ip_ospf_retransmit_interval,
5067 ip_ospf_retransmit_interval_addr_cmd,
5068 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5069 "IP Information\n"
5070 "OSPF interface commands\n"
5071 "Time between retransmitting lost link state advertisements\n"
5072 "Seconds\n"
5073 "Address of interface")
5074{
5075 struct interface *ifp = vty->index;
5076 u_int32_t seconds;
5077 struct in_addr addr;
5078 int ret;
5079 struct ospf_if_params *params;
5080
5081 params = IF_DEF_PARAMS (ifp);
5082 seconds = strtol (argv[0], NULL, 10);
5083
5084 /* Retransmit Interval range is <3-65535>. */
5085 if (seconds < 3 || seconds > 65535)
5086 {
5087 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5088 return CMD_WARNING;
5089 }
5090
5091
5092 if (argc == 2)
5093 {
5094 ret = inet_aton(argv[1], &addr);
5095 if (!ret)
5096 {
5097 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5098 VTY_NEWLINE);
5099 return CMD_WARNING;
5100 }
5101
5102 params = ospf_get_if_params (ifp, addr);
5103 ospf_if_update_params (ifp, addr);
5104 }
5105
5106 SET_IF_PARAM (params, retransmit_interval);
5107 params->retransmit_interval = seconds;
5108
5109 return CMD_SUCCESS;
5110}
5111
5112ALIAS (ip_ospf_retransmit_interval,
5113 ip_ospf_retransmit_interval_cmd,
5114 "ip ospf retransmit-interval <3-65535>",
5115 "IP Information\n"
5116 "OSPF interface commands\n"
5117 "Time between retransmitting lost link state advertisements\n"
5118 "Seconds\n")
5119
5120ALIAS (ip_ospf_retransmit_interval,
5121 ospf_retransmit_interval_cmd,
5122 "ospf retransmit-interval <3-65535>",
5123 "OSPF interface commands\n"
5124 "Time between retransmitting lost link state advertisements\n"
5125 "Seconds\n")
5126
5127DEFUN (no_ip_ospf_retransmit_interval,
5128 no_ip_ospf_retransmit_interval_addr_cmd,
5129 "no ip ospf retransmit-interval A.B.C.D",
5130 NO_STR
5131 "IP Information\n"
5132 "OSPF interface commands\n"
5133 "Time between retransmitting lost link state advertisements\n"
5134 "Address of interface")
5135{
5136 struct interface *ifp = vty->index;
5137 struct in_addr addr;
5138 int ret;
5139 struct ospf_if_params *params;
5140
5141 ifp = vty->index;
5142 params = IF_DEF_PARAMS (ifp);
5143
5144 if (argc == 1)
5145 {
5146 ret = inet_aton(argv[0], &addr);
5147 if (!ret)
5148 {
5149 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5150 VTY_NEWLINE);
5151 return CMD_WARNING;
5152 }
5153
5154 params = ospf_lookup_if_params (ifp, addr);
5155 if (params == NULL)
5156 return CMD_SUCCESS;
5157 }
5158
5159 UNSET_IF_PARAM (params, retransmit_interval);
5160 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5161
5162 if (params != IF_DEF_PARAMS (ifp))
5163 {
5164 ospf_free_if_params (ifp, addr);
5165 ospf_if_update_params (ifp, addr);
5166 }
5167
5168 return CMD_SUCCESS;
5169}
5170
5171ALIAS (no_ip_ospf_retransmit_interval,
5172 no_ip_ospf_retransmit_interval_cmd,
5173 "no ip ospf retransmit-interval",
5174 NO_STR
5175 "IP Information\n"
5176 "OSPF interface commands\n"
5177 "Time between retransmitting lost link state advertisements\n")
5178
5179ALIAS (no_ip_ospf_retransmit_interval,
5180 no_ospf_retransmit_interval_cmd,
5181 "no ospf retransmit-interval",
5182 NO_STR
5183 "OSPF interface commands\n"
5184 "Time between retransmitting lost link state advertisements\n")
5185
5186DEFUN (ip_ospf_transmit_delay,
5187 ip_ospf_transmit_delay_addr_cmd,
5188 "ip ospf transmit-delay <1-65535> A.B.C.D",
5189 "IP Information\n"
5190 "OSPF interface commands\n"
5191 "Link state transmit delay\n"
5192 "Seconds\n"
5193 "Address of interface")
5194{
5195 struct interface *ifp = vty->index;
5196 u_int32_t seconds;
5197 struct in_addr addr;
5198 int ret;
5199 struct ospf_if_params *params;
5200
5201 params = IF_DEF_PARAMS (ifp);
5202 seconds = strtol (argv[0], NULL, 10);
5203
5204 /* Transmit Delay range is <1-65535>. */
5205 if (seconds < 1 || seconds > 65535)
5206 {
5207 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5208 return CMD_WARNING;
5209 }
5210
5211 if (argc == 2)
5212 {
5213 ret = inet_aton(argv[1], &addr);
5214 if (!ret)
5215 {
5216 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5217 VTY_NEWLINE);
5218 return CMD_WARNING;
5219 }
5220
5221 params = ospf_get_if_params (ifp, addr);
5222 ospf_if_update_params (ifp, addr);
5223 }
5224
5225 SET_IF_PARAM (params, transmit_delay);
5226 params->transmit_delay = seconds;
5227
5228 return CMD_SUCCESS;
5229}
5230
5231ALIAS (ip_ospf_transmit_delay,
5232 ip_ospf_transmit_delay_cmd,
5233 "ip ospf transmit-delay <1-65535>",
5234 "IP Information\n"
5235 "OSPF interface commands\n"
5236 "Link state transmit delay\n"
5237 "Seconds\n")
5238
5239ALIAS (ip_ospf_transmit_delay,
5240 ospf_transmit_delay_cmd,
5241 "ospf transmit-delay <1-65535>",
5242 "OSPF interface commands\n"
5243 "Link state transmit delay\n"
5244 "Seconds\n")
5245
5246DEFUN (no_ip_ospf_transmit_delay,
5247 no_ip_ospf_transmit_delay_addr_cmd,
5248 "no ip ospf transmit-delay A.B.C.D",
5249 NO_STR
5250 "IP Information\n"
5251 "OSPF interface commands\n"
5252 "Link state transmit delay\n"
5253 "Address of interface")
5254{
5255 struct interface *ifp = vty->index;
5256 struct in_addr addr;
5257 int ret;
5258 struct ospf_if_params *params;
5259
5260 ifp = vty->index;
5261 params = IF_DEF_PARAMS (ifp);
5262
5263 if (argc == 1)
5264 {
5265 ret = inet_aton(argv[0], &addr);
5266 if (!ret)
5267 {
5268 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5269 VTY_NEWLINE);
5270 return CMD_WARNING;
5271 }
5272
5273 params = ospf_lookup_if_params (ifp, addr);
5274 if (params == NULL)
5275 return CMD_SUCCESS;
5276 }
5277
5278 UNSET_IF_PARAM (params, transmit_delay);
5279 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5280
5281 if (params != IF_DEF_PARAMS (ifp))
5282 {
5283 ospf_free_if_params (ifp, addr);
5284 ospf_if_update_params (ifp, addr);
5285 }
5286
5287 return CMD_SUCCESS;
5288}
5289
5290ALIAS (no_ip_ospf_transmit_delay,
5291 no_ip_ospf_transmit_delay_cmd,
5292 "no ip ospf transmit-delay",
5293 NO_STR
5294 "IP Information\n"
5295 "OSPF interface commands\n"
5296 "Link state transmit delay\n")
5297
5298ALIAS (no_ip_ospf_transmit_delay,
5299 no_ospf_transmit_delay_cmd,
5300 "no ospf transmit-delay",
5301 NO_STR
5302 "OSPF interface commands\n"
5303 "Link state transmit delay\n")
5304
5305
5306DEFUN (ospf_redistribute_source_metric_type,
5307 ospf_redistribute_source_metric_type_routemap_cmd,
5308 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5309 "Redistribute information from another routing protocol\n"
5310 "Kernel routes\n"
5311 "Connected\n"
5312 "Static routes\n"
5313 "Routing Information Protocol (RIP)\n"
5314 "Border Gateway Protocol (BGP)\n"
5315 "Metric for redistributed routes\n"
5316 "OSPF default metric\n"
5317 "OSPF exterior metric type for redistributed routes\n"
5318 "Set OSPF External Type 1 metrics\n"
5319 "Set OSPF External Type 2 metrics\n"
5320 "Route map reference\n"
5321 "Pointer to route-map entries\n")
5322{
paul020709f2003-04-04 02:44:16 +00005323 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005324 int source;
5325 int type = -1;
5326 int metric = -1;
5327
5328 /* Get distribute source. */
5329 if (!str2distribute_source (argv[0], &source))
5330 return CMD_WARNING;
5331
5332 /* Get metric value. */
5333 if (argc >= 2)
5334 if (!str2metric (argv[1], &metric))
5335 return CMD_WARNING;
5336
5337 /* Get metric type. */
5338 if (argc >= 3)
5339 if (!str2metric_type (argv[2], &type))
5340 return CMD_WARNING;
5341
5342 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005343 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005344 else
paul020709f2003-04-04 02:44:16 +00005345 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005346
paul020709f2003-04-04 02:44:16 +00005347 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005348}
5349
5350ALIAS (ospf_redistribute_source_metric_type,
5351 ospf_redistribute_source_metric_type_cmd,
5352 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5353 "Redistribute information from another routing protocol\n"
5354 "Kernel routes\n"
5355 "Connected\n"
5356 "Static routes\n"
5357 "Routing Information Protocol (RIP)\n"
5358 "Border Gateway Protocol (BGP)\n"
5359 "Metric for redistributed routes\n"
5360 "OSPF default metric\n"
5361 "OSPF exterior metric type for redistributed routes\n"
5362 "Set OSPF External Type 1 metrics\n"
5363 "Set OSPF External Type 2 metrics\n")
5364
5365ALIAS (ospf_redistribute_source_metric_type,
5366 ospf_redistribute_source_metric_cmd,
5367 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5368 "Redistribute information from another routing protocol\n"
5369 "Kernel routes\n"
5370 "Connected\n"
5371 "Static routes\n"
5372 "Routing Information Protocol (RIP)\n"
5373 "Border Gateway Protocol (BGP)\n"
5374 "Metric for redistributed routes\n"
5375 "OSPF default metric\n")
5376
5377DEFUN (ospf_redistribute_source_type_metric,
5378 ospf_redistribute_source_type_metric_routemap_cmd,
5379 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5380 "Redistribute information from another routing protocol\n"
5381 "Kernel routes\n"
5382 "Connected\n"
5383 "Static routes\n"
5384 "Routing Information Protocol (RIP)\n"
5385 "Border Gateway Protocol (BGP)\n"
5386 "OSPF exterior metric type for redistributed routes\n"
5387 "Set OSPF External Type 1 metrics\n"
5388 "Set OSPF External Type 2 metrics\n"
5389 "Metric for redistributed routes\n"
5390 "OSPF default metric\n"
5391 "Route map reference\n"
5392 "Pointer to route-map entries\n")
5393{
paul020709f2003-04-04 02:44:16 +00005394 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005395 int source;
5396 int type = -1;
5397 int metric = -1;
5398
5399 /* Get distribute source. */
5400 if (!str2distribute_source (argv[0], &source))
5401 return CMD_WARNING;
5402
5403 /* Get metric value. */
5404 if (argc >= 2)
5405 if (!str2metric_type (argv[1], &type))
5406 return CMD_WARNING;
5407
5408 /* Get metric type. */
5409 if (argc >= 3)
5410 if (!str2metric (argv[2], &metric))
5411 return CMD_WARNING;
5412
5413 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005414 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005415 else
paul020709f2003-04-04 02:44:16 +00005416 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005417
paul020709f2003-04-04 02:44:16 +00005418 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005419}
5420
5421ALIAS (ospf_redistribute_source_type_metric,
5422 ospf_redistribute_source_type_metric_cmd,
5423 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5424 "Redistribute information from another routing protocol\n"
5425 "Kernel routes\n"
5426 "Connected\n"
5427 "Static routes\n"
5428 "Routing Information Protocol (RIP)\n"
5429 "Border Gateway Protocol (BGP)\n"
5430 "OSPF exterior metric type for redistributed routes\n"
5431 "Set OSPF External Type 1 metrics\n"
5432 "Set OSPF External Type 2 metrics\n"
5433 "Metric for redistributed routes\n"
5434 "OSPF default metric\n")
5435
5436ALIAS (ospf_redistribute_source_type_metric,
5437 ospf_redistribute_source_type_cmd,
5438 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5439 "Redistribute information from another routing protocol\n"
5440 "Kernel routes\n"
5441 "Connected\n"
5442 "Static routes\n"
5443 "Routing Information Protocol (RIP)\n"
5444 "Border Gateway Protocol (BGP)\n"
5445 "OSPF exterior metric type for redistributed routes\n"
5446 "Set OSPF External Type 1 metrics\n"
5447 "Set OSPF External Type 2 metrics\n")
5448
5449ALIAS (ospf_redistribute_source_type_metric,
5450 ospf_redistribute_source_cmd,
5451 "redistribute (kernel|connected|static|rip|bgp)",
5452 "Redistribute information from another routing protocol\n"
5453 "Kernel routes\n"
5454 "Connected\n"
5455 "Static routes\n"
5456 "Routing Information Protocol (RIP)\n"
5457 "Border Gateway Protocol (BGP)\n")
5458
5459DEFUN (ospf_redistribute_source_metric_routemap,
5460 ospf_redistribute_source_metric_routemap_cmd,
5461 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5462 "Redistribute information from another routing protocol\n"
5463 "Kernel routes\n"
5464 "Connected\n"
5465 "Static routes\n"
5466 "Routing Information Protocol (RIP)\n"
5467 "Border Gateway Protocol (BGP)\n"
5468 "Metric for redistributed routes\n"
5469 "OSPF default metric\n"
5470 "Route map reference\n"
5471 "Pointer to route-map entries\n")
5472{
paul020709f2003-04-04 02:44:16 +00005473 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005474 int source;
5475 int metric = -1;
5476
5477 /* Get distribute source. */
5478 if (!str2distribute_source (argv[0], &source))
5479 return CMD_WARNING;
5480
5481 /* Get metric value. */
5482 if (argc >= 2)
5483 if (!str2metric (argv[1], &metric))
5484 return CMD_WARNING;
5485
5486 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005487 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005488 else
paul020709f2003-04-04 02:44:16 +00005489 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005490
paul020709f2003-04-04 02:44:16 +00005491 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005492}
5493
5494DEFUN (ospf_redistribute_source_type_routemap,
5495 ospf_redistribute_source_type_routemap_cmd,
5496 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5497 "Redistribute information from another routing protocol\n"
5498 "Kernel routes\n"
5499 "Connected\n"
5500 "Static routes\n"
5501 "Routing Information Protocol (RIP)\n"
5502 "Border Gateway Protocol (BGP)\n"
5503 "OSPF exterior metric type for redistributed routes\n"
5504 "Set OSPF External Type 1 metrics\n"
5505 "Set OSPF External Type 2 metrics\n"
5506 "Route map reference\n"
5507 "Pointer to route-map entries\n")
5508{
paul020709f2003-04-04 02:44:16 +00005509 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005510 int source;
5511 int type = -1;
5512
5513 /* Get distribute source. */
5514 if (!str2distribute_source (argv[0], &source))
5515 return CMD_WARNING;
5516
5517 /* Get metric value. */
5518 if (argc >= 2)
5519 if (!str2metric_type (argv[1], &type))
5520 return CMD_WARNING;
5521
5522 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005523 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005524 else
paul020709f2003-04-04 02:44:16 +00005525 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005526
paul020709f2003-04-04 02:44:16 +00005527 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005528}
5529
5530DEFUN (ospf_redistribute_source_routemap,
5531 ospf_redistribute_source_routemap_cmd,
5532 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5533 "Redistribute information from another routing protocol\n"
5534 "Kernel routes\n"
5535 "Connected\n"
5536 "Static routes\n"
5537 "Routing Information Protocol (RIP)\n"
5538 "Border Gateway Protocol (BGP)\n"
5539 "Route map reference\n"
5540 "Pointer to route-map entries\n")
5541{
paul020709f2003-04-04 02:44:16 +00005542 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005543 int source;
5544
5545 /* Get distribute source. */
5546 if (!str2distribute_source (argv[0], &source))
5547 return CMD_WARNING;
5548
5549 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005550 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005551 else
paul020709f2003-04-04 02:44:16 +00005552 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005553
paul020709f2003-04-04 02:44:16 +00005554 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005555}
5556
5557DEFUN (no_ospf_redistribute_source,
5558 no_ospf_redistribute_source_cmd,
5559 "no redistribute (kernel|connected|static|rip|bgp)",
5560 NO_STR
5561 "Redistribute information from another routing protocol\n"
5562 "Kernel routes\n"
5563 "Connected\n"
5564 "Static routes\n"
5565 "Routing Information Protocol (RIP)\n"
5566 "Border Gateway Protocol (BGP)\n")
5567{
paul020709f2003-04-04 02:44:16 +00005568 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005569 int source;
5570
5571 if (!str2distribute_source (argv[0], &source))
5572 return CMD_WARNING;
5573
paul020709f2003-04-04 02:44:16 +00005574 ospf_routemap_unset (ospf, source);
5575 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005576}
5577
5578DEFUN (ospf_distribute_list_out,
5579 ospf_distribute_list_out_cmd,
5580 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5581 "Filter networks in routing updates\n"
5582 "Access-list name\n"
5583 OUT_STR
5584 "Kernel routes\n"
5585 "Connected\n"
5586 "Static routes\n"
5587 "Routing Information Protocol (RIP)\n"
5588 "Border Gateway Protocol (BGP)\n")
5589{
paul68980082003-03-25 05:07:42 +00005590 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005591 int source;
5592
5593 /* Get distribute source. */
5594 if (!str2distribute_source (argv[1], &source))
5595 return CMD_WARNING;
5596
paul68980082003-03-25 05:07:42 +00005597 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005598}
5599
5600DEFUN (no_ospf_distribute_list_out,
5601 no_ospf_distribute_list_out_cmd,
5602 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5603 NO_STR
5604 "Filter networks in routing updates\n"
5605 "Access-list name\n"
5606 OUT_STR
5607 "Kernel routes\n"
5608 "Connected\n"
5609 "Static routes\n"
5610 "Routing Information Protocol (RIP)\n"
5611 "Border Gateway Protocol (BGP)\n")
5612{
paul68980082003-03-25 05:07:42 +00005613 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005614 int source;
5615
5616 if (!str2distribute_source (argv[1], &source))
5617 return CMD_WARNING;
5618
paul68980082003-03-25 05:07:42 +00005619 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005620}
5621
5622/* Default information originate. */
5623DEFUN (ospf_default_information_originate_metric_type_routemap,
5624 ospf_default_information_originate_metric_type_routemap_cmd,
5625 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5626 "Control distribution of default information\n"
5627 "Distribute a default route\n"
5628 "OSPF default metric\n"
5629 "OSPF metric\n"
5630 "OSPF metric type for default routes\n"
5631 "Set OSPF External Type 1 metrics\n"
5632 "Set OSPF External Type 2 metrics\n"
5633 "Route map reference\n"
5634 "Pointer to route-map entries\n")
5635{
paul020709f2003-04-04 02:44:16 +00005636 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005637 int type = -1;
5638 int metric = -1;
5639
5640 /* Get metric value. */
5641 if (argc >= 1)
5642 if (!str2metric (argv[0], &metric))
5643 return CMD_WARNING;
5644
5645 /* Get metric type. */
5646 if (argc >= 2)
5647 if (!str2metric_type (argv[1], &type))
5648 return CMD_WARNING;
5649
5650 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005651 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005652 else
paul020709f2003-04-04 02:44:16 +00005653 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005654
paul020709f2003-04-04 02:44:16 +00005655 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5656 type, metric);
paul718e3742002-12-13 20:15:29 +00005657}
5658
5659ALIAS (ospf_default_information_originate_metric_type_routemap,
5660 ospf_default_information_originate_metric_type_cmd,
5661 "default-information originate metric <0-16777214> metric-type (1|2)",
5662 "Control distribution of default information\n"
5663 "Distribute a default route\n"
5664 "OSPF default metric\n"
5665 "OSPF metric\n"
5666 "OSPF metric type for default routes\n"
5667 "Set OSPF External Type 1 metrics\n"
5668 "Set OSPF External Type 2 metrics\n")
5669
5670ALIAS (ospf_default_information_originate_metric_type_routemap,
5671 ospf_default_information_originate_metric_cmd,
5672 "default-information originate metric <0-16777214>",
5673 "Control distribution of default information\n"
5674 "Distribute a default route\n"
5675 "OSPF default metric\n"
5676 "OSPF metric\n")
5677
5678ALIAS (ospf_default_information_originate_metric_type_routemap,
5679 ospf_default_information_originate_cmd,
5680 "default-information originate",
5681 "Control distribution of default information\n"
5682 "Distribute a default route\n")
5683
5684/* Default information originate. */
5685DEFUN (ospf_default_information_originate_metric_routemap,
5686 ospf_default_information_originate_metric_routemap_cmd,
5687 "default-information originate metric <0-16777214> route-map WORD",
5688 "Control distribution of default information\n"
5689 "Distribute a default route\n"
5690 "OSPF default metric\n"
5691 "OSPF metric\n"
5692 "Route map reference\n"
5693 "Pointer to route-map entries\n")
5694{
paul020709f2003-04-04 02:44:16 +00005695 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005696 int metric = -1;
5697
5698 /* Get metric value. */
5699 if (argc >= 1)
5700 if (!str2metric (argv[0], &metric))
5701 return CMD_WARNING;
5702
5703 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005704 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005705 else
paul020709f2003-04-04 02:44:16 +00005706 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005707
paul020709f2003-04-04 02:44:16 +00005708 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5709 -1, metric);
paul718e3742002-12-13 20:15:29 +00005710}
5711
5712/* Default information originate. */
5713DEFUN (ospf_default_information_originate_routemap,
5714 ospf_default_information_originate_routemap_cmd,
5715 "default-information originate route-map WORD",
5716 "Control distribution of default information\n"
5717 "Distribute a default route\n"
5718 "Route map reference\n"
5719 "Pointer to route-map entries\n")
5720{
paul020709f2003-04-04 02:44:16 +00005721 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005722
paul020709f2003-04-04 02:44:16 +00005723 if (argc == 1)
5724 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5725 else
5726 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5727
5728 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005729}
5730
5731DEFUN (ospf_default_information_originate_type_metric_routemap,
5732 ospf_default_information_originate_type_metric_routemap_cmd,
5733 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5734 "Control distribution of default information\n"
5735 "Distribute a default route\n"
5736 "OSPF metric type for default routes\n"
5737 "Set OSPF External Type 1 metrics\n"
5738 "Set OSPF External Type 2 metrics\n"
5739 "OSPF default metric\n"
5740 "OSPF metric\n"
5741 "Route map reference\n"
5742 "Pointer to route-map entries\n")
5743{
paul020709f2003-04-04 02:44:16 +00005744 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005745 int type = -1;
5746 int metric = -1;
5747
5748 /* Get metric type. */
5749 if (argc >= 1)
5750 if (!str2metric_type (argv[0], &type))
5751 return CMD_WARNING;
5752
5753 /* Get metric value. */
5754 if (argc >= 2)
5755 if (!str2metric (argv[1], &metric))
5756 return CMD_WARNING;
5757
5758 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005759 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005760 else
paul020709f2003-04-04 02:44:16 +00005761 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005762
paul020709f2003-04-04 02:44:16 +00005763 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5764 type, metric);
paul718e3742002-12-13 20:15:29 +00005765}
5766
5767ALIAS (ospf_default_information_originate_type_metric_routemap,
5768 ospf_default_information_originate_type_metric_cmd,
5769 "default-information originate metric-type (1|2) metric <0-16777214>",
5770 "Control distribution of default information\n"
5771 "Distribute a default route\n"
5772 "OSPF metric type for default routes\n"
5773 "Set OSPF External Type 1 metrics\n"
5774 "Set OSPF External Type 2 metrics\n"
5775 "OSPF default metric\n"
5776 "OSPF metric\n")
5777
5778ALIAS (ospf_default_information_originate_type_metric_routemap,
5779 ospf_default_information_originate_type_cmd,
5780 "default-information originate metric-type (1|2)",
5781 "Control distribution of default information\n"
5782 "Distribute a default route\n"
5783 "OSPF metric type for default routes\n"
5784 "Set OSPF External Type 1 metrics\n"
5785 "Set OSPF External Type 2 metrics\n")
5786
5787DEFUN (ospf_default_information_originate_type_routemap,
5788 ospf_default_information_originate_type_routemap_cmd,
5789 "default-information originate metric-type (1|2) route-map WORD",
5790 "Control distribution of default information\n"
5791 "Distribute a default route\n"
5792 "OSPF metric type for default routes\n"
5793 "Set OSPF External Type 1 metrics\n"
5794 "Set OSPF External Type 2 metrics\n"
5795 "Route map reference\n"
5796 "Pointer to route-map entries\n")
5797{
paul020709f2003-04-04 02:44:16 +00005798 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005799 int type = -1;
5800
5801 /* Get metric type. */
5802 if (argc >= 1)
5803 if (!str2metric_type (argv[0], &type))
5804 return CMD_WARNING;
5805
5806 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005807 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005808 else
paul020709f2003-04-04 02:44:16 +00005809 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005810
paul020709f2003-04-04 02:44:16 +00005811 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5812 type, -1);
paul718e3742002-12-13 20:15:29 +00005813}
5814
5815DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5816 ospf_default_information_originate_always_metric_type_routemap_cmd,
5817 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5818 "Control distribution of default information\n"
5819 "Distribute a default route\n"
5820 "Always advertise default route\n"
5821 "OSPF default metric\n"
5822 "OSPF metric\n"
5823 "OSPF metric type for default routes\n"
5824 "Set OSPF External Type 1 metrics\n"
5825 "Set OSPF External Type 2 metrics\n"
5826 "Route map reference\n"
5827 "Pointer to route-map entries\n")
5828{
paul020709f2003-04-04 02:44:16 +00005829 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005830 int type = -1;
5831 int metric = -1;
5832
5833 /* Get metric value. */
5834 if (argc >= 1)
5835 if (!str2metric (argv[0], &metric))
5836 return CMD_WARNING;
5837
5838 /* Get metric type. */
5839 if (argc >= 2)
5840 if (!str2metric_type (argv[1], &type))
5841 return CMD_WARNING;
5842
5843 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005844 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005845 else
paul020709f2003-04-04 02:44:16 +00005846 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005847
paul020709f2003-04-04 02:44:16 +00005848 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005849 type, metric);
5850}
5851
5852ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5853 ospf_default_information_originate_always_metric_type_cmd,
5854 "default-information originate always metric <0-16777214> metric-type (1|2)",
5855 "Control distribution of default information\n"
5856 "Distribute a default route\n"
5857 "Always advertise default route\n"
5858 "OSPF default metric\n"
5859 "OSPF metric\n"
5860 "OSPF metric type for default routes\n"
5861 "Set OSPF External Type 1 metrics\n"
5862 "Set OSPF External Type 2 metrics\n")
5863
5864ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5865 ospf_default_information_originate_always_metric_cmd,
5866 "default-information originate always metric <0-16777214>",
5867 "Control distribution of default information\n"
5868 "Distribute a default route\n"
5869 "Always advertise default route\n"
5870 "OSPF default metric\n"
5871 "OSPF metric\n"
5872 "OSPF metric type for default routes\n")
5873
5874ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5875 ospf_default_information_originate_always_cmd,
5876 "default-information originate always",
5877 "Control distribution of default information\n"
5878 "Distribute a default route\n"
5879 "Always advertise default route\n")
5880
5881DEFUN (ospf_default_information_originate_always_metric_routemap,
5882 ospf_default_information_originate_always_metric_routemap_cmd,
5883 "default-information originate always metric <0-16777214> route-map WORD",
5884 "Control distribution of default information\n"
5885 "Distribute a default route\n"
5886 "Always advertise default route\n"
5887 "OSPF default metric\n"
5888 "OSPF metric\n"
5889 "Route map reference\n"
5890 "Pointer to route-map entries\n")
5891{
paul020709f2003-04-04 02:44:16 +00005892 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005893 int metric = -1;
5894
5895 /* Get metric value. */
5896 if (argc >= 1)
5897 if (!str2metric (argv[0], &metric))
5898 return CMD_WARNING;
5899
5900 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005901 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005902 else
paul020709f2003-04-04 02:44:16 +00005903 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005904
paul020709f2003-04-04 02:44:16 +00005905 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5906 -1, metric);
paul718e3742002-12-13 20:15:29 +00005907}
5908
5909DEFUN (ospf_default_information_originate_always_routemap,
5910 ospf_default_information_originate_always_routemap_cmd,
5911 "default-information originate always route-map WORD",
5912 "Control distribution of default information\n"
5913 "Distribute a default route\n"
5914 "Always advertise default route\n"
5915 "Route map reference\n"
5916 "Pointer to route-map entries\n")
5917{
paul020709f2003-04-04 02:44:16 +00005918 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005919
paul020709f2003-04-04 02:44:16 +00005920 if (argc == 1)
5921 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5922 else
5923 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5924
5925 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005926}
5927
5928DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5929 ospf_default_information_originate_always_type_metric_routemap_cmd,
5930 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5931 "Control distribution of default information\n"
5932 "Distribute a default route\n"
5933 "Always advertise default route\n"
5934 "OSPF metric type for default routes\n"
5935 "Set OSPF External Type 1 metrics\n"
5936 "Set OSPF External Type 2 metrics\n"
5937 "OSPF default metric\n"
5938 "OSPF metric\n"
5939 "Route map reference\n"
5940 "Pointer to route-map entries\n")
5941{
paul020709f2003-04-04 02:44:16 +00005942 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005943 int type = -1;
5944 int metric = -1;
5945
5946 /* Get metric type. */
5947 if (argc >= 1)
5948 if (!str2metric_type (argv[0], &type))
5949 return CMD_WARNING;
5950
5951 /* Get metric value. */
5952 if (argc >= 2)
5953 if (!str2metric (argv[1], &metric))
5954 return CMD_WARNING;
5955
5956 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005957 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005958 else
paul020709f2003-04-04 02:44:16 +00005959 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005960
paul020709f2003-04-04 02:44:16 +00005961 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005962 type, metric);
5963}
5964
5965ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5966 ospf_default_information_originate_always_type_metric_cmd,
5967 "default-information originate always metric-type (1|2) metric <0-16777214>",
5968 "Control distribution of default information\n"
5969 "Distribute a default route\n"
5970 "Always advertise default route\n"
5971 "OSPF metric type for default routes\n"
5972 "Set OSPF External Type 1 metrics\n"
5973 "Set OSPF External Type 2 metrics\n"
5974 "OSPF default metric\n"
5975 "OSPF metric\n")
5976
5977ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5978 ospf_default_information_originate_always_type_cmd,
5979 "default-information originate always metric-type (1|2)",
5980 "Control distribution of default information\n"
5981 "Distribute a default route\n"
5982 "Always advertise default route\n"
5983 "OSPF metric type for default routes\n"
5984 "Set OSPF External Type 1 metrics\n"
5985 "Set OSPF External Type 2 metrics\n")
5986
5987DEFUN (ospf_default_information_originate_always_type_routemap,
5988 ospf_default_information_originate_always_type_routemap_cmd,
5989 "default-information originate always metric-type (1|2) route-map WORD",
5990 "Control distribution of default information\n"
5991 "Distribute a default route\n"
5992 "Always advertise default route\n"
5993 "OSPF metric type for default routes\n"
5994 "Set OSPF External Type 1 metrics\n"
5995 "Set OSPF External Type 2 metrics\n"
5996 "Route map reference\n"
5997 "Pointer to route-map entries\n")
5998{
paul020709f2003-04-04 02:44:16 +00005999 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006000 int type = -1;
6001
6002 /* Get metric type. */
6003 if (argc >= 1)
6004 if (!str2metric_type (argv[0], &type))
6005 return CMD_WARNING;
6006
6007 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006008 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006009 else
paul020709f2003-04-04 02:44:16 +00006010 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006011
paul020709f2003-04-04 02:44:16 +00006012 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006013 type, -1);
6014}
6015
6016DEFUN (no_ospf_default_information_originate,
6017 no_ospf_default_information_originate_cmd,
6018 "no default-information originate",
6019 NO_STR
6020 "Control distribution of default information\n"
6021 "Distribute a default route\n")
6022{
paul68980082003-03-25 05:07:42 +00006023 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006024 struct prefix_ipv4 p;
6025 struct in_addr nexthop;
6026
6027 p.family = AF_INET;
6028 p.prefix.s_addr = 0;
6029 p.prefixlen = 0;
6030
paul68980082003-03-25 05:07:42 +00006031 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
paul718e3742002-12-13 20:15:29 +00006032
6033 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6034 ospf_external_info_delete (DEFAULT_ROUTE, p);
6035 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6036 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6037 }
6038
paul020709f2003-04-04 02:44:16 +00006039 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6040 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006041}
6042
6043DEFUN (ospf_default_metric,
6044 ospf_default_metric_cmd,
6045 "default-metric <0-16777214>",
6046 "Set metric of redistributed routes\n"
6047 "Default metric\n")
6048{
paul68980082003-03-25 05:07:42 +00006049 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006050 int metric = -1;
6051
6052 if (!str2metric (argv[0], &metric))
6053 return CMD_WARNING;
6054
paul68980082003-03-25 05:07:42 +00006055 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006056
6057 return CMD_SUCCESS;
6058}
6059
6060DEFUN (no_ospf_default_metric,
6061 no_ospf_default_metric_cmd,
6062 "no default-metric",
6063 NO_STR
6064 "Set metric of redistributed routes\n")
6065{
paul68980082003-03-25 05:07:42 +00006066 struct ospf *ospf = vty->index;
6067
6068 ospf->default_metric = -1;
6069
paul718e3742002-12-13 20:15:29 +00006070 return CMD_SUCCESS;
6071}
6072
6073ALIAS (no_ospf_default_metric,
6074 no_ospf_default_metric_val_cmd,
6075 "no default-metric <0-16777214>",
6076 NO_STR
6077 "Set metric of redistributed routes\n"
6078 "Default metric\n")
6079
6080DEFUN (ospf_distance,
6081 ospf_distance_cmd,
6082 "distance <1-255>",
6083 "Define an administrative distance\n"
6084 "OSPF Administrative distance\n")
6085{
paul68980082003-03-25 05:07:42 +00006086 struct ospf *ospf = vty->index;
6087
6088 ospf->distance_all = atoi (argv[0]);
6089
paul718e3742002-12-13 20:15:29 +00006090 return CMD_SUCCESS;
6091}
6092
6093DEFUN (no_ospf_distance,
6094 no_ospf_distance_cmd,
6095 "no distance <1-255>",
6096 NO_STR
6097 "Define an administrative distance\n"
6098 "OSPF Administrative distance\n")
6099{
paul68980082003-03-25 05:07:42 +00006100 struct ospf *ospf = vty->index;
6101
6102 ospf->distance_all = 0;
6103
paul718e3742002-12-13 20:15:29 +00006104 return CMD_SUCCESS;
6105}
6106
6107DEFUN (no_ospf_distance_ospf,
6108 no_ospf_distance_ospf_cmd,
6109 "no distance ospf",
6110 NO_STR
6111 "Define an administrative distance\n"
6112 "OSPF Administrative distance\n"
6113 "OSPF Distance\n")
6114{
paul68980082003-03-25 05:07:42 +00006115 struct ospf *ospf = vty->index;
6116
6117 ospf->distance_intra = 0;
6118 ospf->distance_inter = 0;
6119 ospf->distance_external = 0;
6120
paul718e3742002-12-13 20:15:29 +00006121 return CMD_SUCCESS;
6122}
6123
6124DEFUN (ospf_distance_ospf_intra,
6125 ospf_distance_ospf_intra_cmd,
6126 "distance ospf intra-area <1-255>",
6127 "Define an administrative distance\n"
6128 "OSPF Administrative distance\n"
6129 "Intra-area routes\n"
6130 "Distance for intra-area routes\n")
6131{
paul68980082003-03-25 05:07:42 +00006132 struct ospf *ospf = vty->index;
6133
6134 ospf->distance_intra = atoi (argv[0]);
6135
paul718e3742002-12-13 20:15:29 +00006136 return CMD_SUCCESS;
6137}
6138
6139DEFUN (ospf_distance_ospf_intra_inter,
6140 ospf_distance_ospf_intra_inter_cmd,
6141 "distance ospf intra-area <1-255> inter-area <1-255>",
6142 "Define an administrative distance\n"
6143 "OSPF Administrative distance\n"
6144 "Intra-area routes\n"
6145 "Distance for intra-area routes\n"
6146 "Inter-area routes\n"
6147 "Distance for inter-area routes\n")
6148{
paul68980082003-03-25 05:07:42 +00006149 struct ospf *ospf = vty->index;
6150
6151 ospf->distance_intra = atoi (argv[0]);
6152 ospf->distance_inter = atoi (argv[1]);
6153
paul718e3742002-12-13 20:15:29 +00006154 return CMD_SUCCESS;
6155}
6156
6157DEFUN (ospf_distance_ospf_intra_external,
6158 ospf_distance_ospf_intra_external_cmd,
6159 "distance ospf intra-area <1-255> external <1-255>",
6160 "Define an administrative distance\n"
6161 "OSPF Administrative distance\n"
6162 "Intra-area routes\n"
6163 "Distance for intra-area routes\n"
6164 "External routes\n"
6165 "Distance for external routes\n")
6166{
paul68980082003-03-25 05:07:42 +00006167 struct ospf *ospf = vty->index;
6168
6169 ospf->distance_intra = atoi (argv[0]);
6170 ospf->distance_external = atoi (argv[1]);
6171
paul718e3742002-12-13 20:15:29 +00006172 return CMD_SUCCESS;
6173}
6174
6175DEFUN (ospf_distance_ospf_intra_inter_external,
6176 ospf_distance_ospf_intra_inter_external_cmd,
6177 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6178 "Define an administrative distance\n"
6179 "OSPF Administrative distance\n"
6180 "Intra-area routes\n"
6181 "Distance for intra-area routes\n"
6182 "Inter-area routes\n"
6183 "Distance for inter-area routes\n"
6184 "External routes\n"
6185 "Distance for external routes\n")
6186{
paul68980082003-03-25 05:07:42 +00006187 struct ospf *ospf = vty->index;
6188
6189 ospf->distance_intra = atoi (argv[0]);
6190 ospf->distance_inter = atoi (argv[1]);
6191 ospf->distance_external = atoi (argv[2]);
6192
paul718e3742002-12-13 20:15:29 +00006193 return CMD_SUCCESS;
6194}
6195
6196DEFUN (ospf_distance_ospf_intra_external_inter,
6197 ospf_distance_ospf_intra_external_inter_cmd,
6198 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6199 "Define an administrative distance\n"
6200 "OSPF Administrative distance\n"
6201 "Intra-area routes\n"
6202 "Distance for intra-area routes\n"
6203 "External routes\n"
6204 "Distance for external routes\n"
6205 "Inter-area routes\n"
6206 "Distance for inter-area routes\n")
6207{
paul68980082003-03-25 05:07:42 +00006208 struct ospf *ospf = vty->index;
6209
6210 ospf->distance_intra = atoi (argv[0]);
6211 ospf->distance_external = atoi (argv[1]);
6212 ospf->distance_inter = atoi (argv[2]);
6213
paul718e3742002-12-13 20:15:29 +00006214 return CMD_SUCCESS;
6215}
6216
6217DEFUN (ospf_distance_ospf_inter,
6218 ospf_distance_ospf_inter_cmd,
6219 "distance ospf inter-area <1-255>",
6220 "Define an administrative distance\n"
6221 "OSPF Administrative distance\n"
6222 "Inter-area routes\n"
6223 "Distance for inter-area routes\n")
6224{
paul68980082003-03-25 05:07:42 +00006225 struct ospf *ospf = vty->index;
6226
6227 ospf->distance_inter = atoi (argv[0]);
6228
paul718e3742002-12-13 20:15:29 +00006229 return CMD_SUCCESS;
6230}
6231
6232DEFUN (ospf_distance_ospf_inter_intra,
6233 ospf_distance_ospf_inter_intra_cmd,
6234 "distance ospf inter-area <1-255> intra-area <1-255>",
6235 "Define an administrative distance\n"
6236 "OSPF Administrative distance\n"
6237 "Inter-area routes\n"
6238 "Distance for inter-area routes\n"
6239 "Intra-area routes\n"
6240 "Distance for intra-area routes\n")
6241{
paul68980082003-03-25 05:07:42 +00006242 struct ospf *ospf = vty->index;
6243
6244 ospf->distance_inter = atoi (argv[0]);
6245 ospf->distance_intra = atoi (argv[1]);
6246
paul718e3742002-12-13 20:15:29 +00006247 return CMD_SUCCESS;
6248}
6249
6250DEFUN (ospf_distance_ospf_inter_external,
6251 ospf_distance_ospf_inter_external_cmd,
6252 "distance ospf inter-area <1-255> external <1-255>",
6253 "Define an administrative distance\n"
6254 "OSPF Administrative distance\n"
6255 "Inter-area routes\n"
6256 "Distance for inter-area routes\n"
6257 "External routes\n"
6258 "Distance for external routes\n")
6259{
paul68980082003-03-25 05:07:42 +00006260 struct ospf *ospf = vty->index;
6261
6262 ospf->distance_inter = atoi (argv[0]);
6263 ospf->distance_external = atoi (argv[1]);
6264
paul718e3742002-12-13 20:15:29 +00006265 return CMD_SUCCESS;
6266}
6267
6268DEFUN (ospf_distance_ospf_inter_intra_external,
6269 ospf_distance_ospf_inter_intra_external_cmd,
6270 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6271 "Define an administrative distance\n"
6272 "OSPF Administrative distance\n"
6273 "Inter-area routes\n"
6274 "Distance for inter-area routes\n"
6275 "Intra-area routes\n"
6276 "Distance for intra-area routes\n"
6277 "External routes\n"
6278 "Distance for external routes\n")
6279{
paul68980082003-03-25 05:07:42 +00006280 struct ospf *ospf = vty->index;
6281
6282 ospf->distance_inter = atoi (argv[0]);
6283 ospf->distance_intra = atoi (argv[1]);
6284 ospf->distance_external = atoi (argv[2]);
6285
paul718e3742002-12-13 20:15:29 +00006286 return CMD_SUCCESS;
6287}
6288
6289DEFUN (ospf_distance_ospf_inter_external_intra,
6290 ospf_distance_ospf_inter_external_intra_cmd,
6291 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6292 "Define an administrative distance\n"
6293 "OSPF Administrative distance\n"
6294 "Inter-area routes\n"
6295 "Distance for inter-area routes\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_inter = atoi (argv[0]);
6304 ospf->distance_external = atoi (argv[1]);
6305 ospf->distance_intra = atoi (argv[2]);
6306
paul718e3742002-12-13 20:15:29 +00006307 return CMD_SUCCESS;
6308}
6309
6310DEFUN (ospf_distance_ospf_external,
6311 ospf_distance_ospf_external_cmd,
6312 "distance ospf external <1-255>",
6313 "Define an administrative distance\n"
6314 "OSPF Administrative distance\n"
6315 "External routes\n"
6316 "Distance for external routes\n")
6317{
paul68980082003-03-25 05:07:42 +00006318 struct ospf *ospf = vty->index;
6319
6320 ospf->distance_external = atoi (argv[0]);
6321
paul718e3742002-12-13 20:15:29 +00006322 return CMD_SUCCESS;
6323}
6324
6325DEFUN (ospf_distance_ospf_external_intra,
6326 ospf_distance_ospf_external_intra_cmd,
6327 "distance ospf external <1-255> intra-area <1-255>",
6328 "Define an administrative distance\n"
6329 "OSPF Administrative distance\n"
6330 "External routes\n"
6331 "Distance for external routes\n"
6332 "Intra-area routes\n"
6333 "Distance for intra-area routes\n")
6334{
paul68980082003-03-25 05:07:42 +00006335 struct ospf *ospf = vty->index;
6336
6337 ospf->distance_external = atoi (argv[0]);
6338 ospf->distance_intra = atoi (argv[1]);
6339
paul718e3742002-12-13 20:15:29 +00006340 return CMD_SUCCESS;
6341}
6342
6343DEFUN (ospf_distance_ospf_external_inter,
6344 ospf_distance_ospf_external_inter_cmd,
6345 "distance ospf external <1-255> inter-area <1-255>",
6346 "Define an administrative distance\n"
6347 "OSPF Administrative distance\n"
6348 "External routes\n"
6349 "Distance for external routes\n"
6350 "Inter-area routes\n"
6351 "Distance for inter-area routes\n")
6352{
paul68980082003-03-25 05:07:42 +00006353 struct ospf *ospf = vty->index;
6354
6355 ospf->distance_external = atoi (argv[0]);
6356 ospf->distance_inter = atoi (argv[1]);
6357
paul718e3742002-12-13 20:15:29 +00006358 return CMD_SUCCESS;
6359}
6360
6361DEFUN (ospf_distance_ospf_external_intra_inter,
6362 ospf_distance_ospf_external_intra_inter_cmd,
6363 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6364 "Define an administrative distance\n"
6365 "OSPF Administrative distance\n"
6366 "External routes\n"
6367 "Distance for external routes\n"
6368 "Intra-area routes\n"
6369 "Distance for intra-area routes\n"
6370 "Inter-area routes\n"
6371 "Distance for inter-area routes\n")
6372{
paul68980082003-03-25 05:07:42 +00006373 struct ospf *ospf = vty->index;
6374
6375 ospf->distance_external = atoi (argv[0]);
6376 ospf->distance_intra = atoi (argv[1]);
6377 ospf->distance_inter = atoi (argv[2]);
6378
paul718e3742002-12-13 20:15:29 +00006379 return CMD_SUCCESS;
6380}
6381
6382DEFUN (ospf_distance_ospf_external_inter_intra,
6383 ospf_distance_ospf_external_inter_intra_cmd,
6384 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6385 "Define an administrative distance\n"
6386 "OSPF Administrative distance\n"
6387 "External routes\n"
6388 "Distance for external routes\n"
6389 "Inter-area routes\n"
6390 "Distance for inter-area routes\n"
6391 "Intra-area routes\n"
6392 "Distance for intra-area routes\n")
6393{
paul68980082003-03-25 05:07:42 +00006394 struct ospf *ospf = vty->index;
6395
6396 ospf->distance_external = atoi (argv[0]);
6397 ospf->distance_inter = atoi (argv[1]);
6398 ospf->distance_intra = atoi (argv[2]);
6399
paul718e3742002-12-13 20:15:29 +00006400 return CMD_SUCCESS;
6401}
6402
6403DEFUN (ospf_distance_source,
6404 ospf_distance_source_cmd,
6405 "distance <1-255> A.B.C.D/M",
6406 "Administrative distance\n"
6407 "Distance value\n"
6408 "IP source prefix\n")
6409{
paul020709f2003-04-04 02:44:16 +00006410 struct ospf *ospf = vty->index;
6411
6412 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006413
paul718e3742002-12-13 20:15:29 +00006414 return CMD_SUCCESS;
6415}
6416
6417DEFUN (no_ospf_distance_source,
6418 no_ospf_distance_source_cmd,
6419 "no distance <1-255> A.B.C.D/M",
6420 NO_STR
6421 "Administrative distance\n"
6422 "Distance value\n"
6423 "IP source prefix\n")
6424{
paul020709f2003-04-04 02:44:16 +00006425 struct ospf *ospf = vty->index;
6426
6427 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6428
paul718e3742002-12-13 20:15:29 +00006429 return CMD_SUCCESS;
6430}
6431
6432DEFUN (ospf_distance_source_access_list,
6433 ospf_distance_source_access_list_cmd,
6434 "distance <1-255> A.B.C.D/M WORD",
6435 "Administrative distance\n"
6436 "Distance value\n"
6437 "IP source prefix\n"
6438 "Access list name\n")
6439{
paul020709f2003-04-04 02:44:16 +00006440 struct ospf *ospf = vty->index;
6441
6442 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6443
paul718e3742002-12-13 20:15:29 +00006444 return CMD_SUCCESS;
6445}
6446
6447DEFUN (no_ospf_distance_source_access_list,
6448 no_ospf_distance_source_access_list_cmd,
6449 "no distance <1-255> A.B.C.D/M WORD",
6450 NO_STR
6451 "Administrative distance\n"
6452 "Distance value\n"
6453 "IP source prefix\n"
6454 "Access list name\n")
6455{
paul020709f2003-04-04 02:44:16 +00006456 struct ospf *ospf = vty->index;
6457
6458 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6459
paul718e3742002-12-13 20:15:29 +00006460 return CMD_SUCCESS;
6461}
6462
6463void
6464show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6465{
6466 struct route_node *rn;
6467 struct ospf_route *or;
6468 listnode pnode;
6469 struct ospf_path *path;
6470
6471 vty_out (vty, "============ OSPF network routing table ============%s",
6472 VTY_NEWLINE);
6473
6474 for (rn = route_top (rt); rn; rn = route_next (rn))
6475 if ((or = rn->info) != NULL)
6476 {
6477 char buf1[19];
6478 snprintf (buf1, 19, "%s/%d",
6479 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6480
6481 switch (or->path_type)
6482 {
6483 case OSPF_PATH_INTER_AREA:
6484 if (or->type == OSPF_DESTINATION_NETWORK)
6485 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6486 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6487 else if (or->type == OSPF_DESTINATION_DISCARD)
6488 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6489 break;
6490 case OSPF_PATH_INTRA_AREA:
6491 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6492 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6493 break;
6494 default:
6495 break;
6496 }
6497
6498 if (or->type == OSPF_DESTINATION_NETWORK)
6499 for (pnode = listhead (or->path); pnode; nextnode (pnode))
6500 {
6501 path = getdata (pnode);
6502 if (path->oi != NULL)
6503 {
6504 if (path->nexthop.s_addr == 0)
6505 vty_out (vty, "%24s directly attached to %s%s",
6506 "", path->oi->ifp->name, VTY_NEWLINE);
6507 else
6508 vty_out (vty, "%24s via %s, %s%s", "",
6509 inet_ntoa (path->nexthop), path->oi->ifp->name,
6510 VTY_NEWLINE);
6511 }
6512 }
6513 }
6514 vty_out (vty, "%s", VTY_NEWLINE);
6515}
6516
6517void
6518show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6519{
6520 struct route_node *rn;
6521 struct ospf_route *or;
6522 listnode pn, nn;
6523 struct ospf_path *path;
6524
6525 vty_out (vty, "============ OSPF router routing table =============%s",
6526 VTY_NEWLINE);
6527 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6528 if (rn->info)
6529 {
6530 int flag = 0;
6531
6532 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6533
6534 for (nn = listhead ((list) rn->info); nn; nextnode (nn))
6535 if ((or = getdata (nn)) != NULL)
6536 {
6537 if (flag++)
paulb0a053b2003-06-22 09:04:47 +00006538 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006539
6540 /* Show path. */
6541 vty_out (vty, "%s [%d] area: %s",
6542 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6543 or->cost, inet_ntoa (or->u.std.area_id));
6544 /* Show flags. */
6545 vty_out (vty, "%s%s%s",
6546 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6547 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6548 VTY_NEWLINE);
6549
6550 for (pn = listhead (or->path); pn; nextnode (pn))
6551 {
6552 path = getdata (pn);
6553 if (path->nexthop.s_addr == 0)
6554 vty_out (vty, "%24s directly attached to %s%s",
6555 "", path->oi->ifp->name, VTY_NEWLINE);
6556 else
6557 vty_out (vty, "%24s via %s, %s%s", "",
6558 inet_ntoa (path->nexthop), path->oi->ifp->name,
6559 VTY_NEWLINE);
6560 }
6561 }
6562 }
6563 vty_out (vty, "%s", VTY_NEWLINE);
6564}
6565
6566void
6567show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6568{
6569 struct route_node *rn;
6570 struct ospf_route *er;
6571 listnode pnode;
6572 struct ospf_path *path;
6573
6574 vty_out (vty, "============ OSPF external routing table ===========%s",
6575 VTY_NEWLINE);
6576 for (rn = route_top (rt); rn; rn = route_next (rn))
6577 if ((er = rn->info) != NULL)
6578 {
6579 char buf1[19];
6580 snprintf (buf1, 19, "%s/%d",
6581 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6582
6583 switch (er->path_type)
6584 {
6585 case OSPF_PATH_TYPE1_EXTERNAL:
6586 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6587 er->cost, er->u.ext.tag, VTY_NEWLINE);
6588 break;
6589 case OSPF_PATH_TYPE2_EXTERNAL:
6590 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6591 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6592 break;
6593 }
6594
6595 for (pnode = listhead (er->path); pnode; nextnode (pnode))
6596 {
6597 path = getdata (pnode);
6598 if (path->oi != NULL)
6599 {
6600 if (path->nexthop.s_addr == 0)
6601 vty_out (vty, "%24s directly attached to %s%s",
6602 "", path->oi->ifp->name, VTY_NEWLINE);
6603 else
6604 vty_out (vty, "%24s via %s, %s%s", "",
6605 inet_ntoa (path->nexthop), path->oi->ifp->name,
6606 VTY_NEWLINE);
6607 }
6608 }
6609 }
6610 vty_out (vty, "%s", VTY_NEWLINE);
6611}
6612
6613#ifdef HAVE_NSSA
6614DEFUN (show_ip_ospf_border_routers,
6615 show_ip_ospf_border_routers_cmd,
6616 "show ip ospf border-routers",
6617 SHOW_STR
6618 IP_STR
6619 "show all the ABR's and ASBR's\n"
6620 "for this area\n")
6621{
paul020709f2003-04-04 02:44:16 +00006622 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006623
paul020709f2003-04-04 02:44:16 +00006624 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006625 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006626 {
6627 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6628 return CMD_SUCCESS;
6629 }
6630
paul68980082003-03-25 05:07:42 +00006631 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006632 {
6633 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6634 return CMD_SUCCESS;
6635 }
6636
6637 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006638 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006639
6640 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006641 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006642
6643 return CMD_SUCCESS;
6644}
6645#endif /* HAVE_NSSA */
6646
6647DEFUN (show_ip_ospf_route,
6648 show_ip_ospf_route_cmd,
6649 "show ip ospf route",
6650 SHOW_STR
6651 IP_STR
6652 "OSPF information\n"
6653 "OSPF routing table\n")
6654{
paul020709f2003-04-04 02:44:16 +00006655 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006656
paul020709f2003-04-04 02:44:16 +00006657 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006658 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006659 {
6660 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6661 return CMD_SUCCESS;
6662 }
6663
paul68980082003-03-25 05:07:42 +00006664 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006665 {
6666 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6667 return CMD_SUCCESS;
6668 }
6669
6670 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006671 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006672
6673 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006674 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006675
6676 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006677 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006678
6679 return CMD_SUCCESS;
6680}
6681
6682
6683char *ospf_abr_type_str[] =
6684{
6685 "unknown",
6686 "standard",
6687 "ibm",
6688 "cisco",
6689 "shortcut"
6690};
6691
6692char *ospf_shortcut_mode_str[] =
6693{
6694 "default",
6695 "enable",
6696 "disable"
6697};
6698
6699
6700void
6701area_id2str (char *buf, int length, struct ospf_area *area)
6702{
6703 memset (buf, 0, length);
6704
6705 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6706 strncpy (buf, inet_ntoa (area->area_id), length);
6707 else
6708 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6709}
6710
6711
6712char *ospf_int_type_str[] =
6713{
6714 "unknown", /* should never be used. */
6715 "point-to-point",
6716 "broadcast",
6717 "non-broadcast",
6718 "point-to-multipoint",
6719 "virtual-link", /* should never be used. */
6720 "loopback"
6721};
6722
6723/* Configuration write function for ospfd. */
6724int
6725config_write_interface (struct vty *vty)
6726{
6727 listnode n1, n2;
6728 struct interface *ifp;
6729 struct crypt_key *ck;
6730 int write = 0;
6731 struct route_node *rn = NULL;
6732 struct ospf_if_params *params;
6733
6734 for (n1 = listhead (iflist); n1; nextnode (n1))
6735 {
6736 ifp = getdata (n1);
6737
6738 if (memcmp (ifp->name, "VLINK", 5) == 0)
6739 continue;
6740
6741 vty_out (vty, "!%s", VTY_NEWLINE);
6742 vty_out (vty, "interface %s%s", ifp->name,
6743 VTY_NEWLINE);
6744 if (ifp->desc)
6745 vty_out (vty, " description %s%s", ifp->desc,
6746 VTY_NEWLINE);
6747
6748 write++;
6749
6750 params = IF_DEF_PARAMS (ifp);
6751
6752 do {
6753 /* Interface Network print. */
6754 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
6755 params->type != OSPF_IFTYPE_BROADCAST &&
6756 params->type != OSPF_IFTYPE_LOOPBACK)
6757 {
6758 vty_out (vty, " ip ospf network %s",
6759 ospf_int_type_str[params->type]);
6760 if (params != IF_DEF_PARAMS (ifp))
6761 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6762 vty_out (vty, "%s", VTY_NEWLINE);
6763 }
6764
6765 /* OSPF interface authentication print */
6766 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6767 params->auth_type != OSPF_AUTH_NOTSET)
6768 {
6769 char *auth_str;
6770
6771 /* Translation tables are not that much help here due to syntax
6772 of the simple option */
6773 switch (params->auth_type)
6774 {
6775
6776 case OSPF_AUTH_NULL:
6777 auth_str = " null";
6778 break;
6779
6780 case OSPF_AUTH_SIMPLE:
6781 auth_str = "";
6782 break;
6783
6784 case OSPF_AUTH_CRYPTOGRAPHIC:
6785 auth_str = " message-digest";
6786 break;
6787
6788 default:
6789 auth_str = "";
6790 break;
6791 }
6792
6793 vty_out (vty, " ip ospf authentication%s", auth_str);
6794 if (params != IF_DEF_PARAMS (ifp))
6795 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6796 vty_out (vty, "%s", VTY_NEWLINE);
6797 }
6798
6799 /* Simple Authentication Password print. */
6800 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6801 params->auth_simple[0] != '\0')
6802 {
6803 vty_out (vty, " ip ospf authentication-key %s",
6804 params->auth_simple);
6805 if (params != IF_DEF_PARAMS (ifp))
6806 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6807 vty_out (vty, "%s", VTY_NEWLINE);
6808 }
6809
6810 /* Cryptographic Authentication Key print. */
6811 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
6812 {
6813 ck = getdata (n2);
6814 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6815 ck->key_id, ck->auth_key);
6816 if (params != IF_DEF_PARAMS (ifp))
6817 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6818 vty_out (vty, "%s", VTY_NEWLINE);
6819 }
6820
6821 /* Interface Output Cost print. */
6822 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6823 {
6824 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6825 if (params != IF_DEF_PARAMS (ifp))
6826 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6827 vty_out (vty, "%s", VTY_NEWLINE);
6828 }
6829
6830 /* Hello Interval print. */
6831 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6832 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6833 {
6834 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6835 if (params != IF_DEF_PARAMS (ifp))
6836 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6837 vty_out (vty, "%s", VTY_NEWLINE);
6838 }
6839
6840
6841 /* Router Dead Interval print. */
6842 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6843 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6844 {
6845 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6846 if (params != IF_DEF_PARAMS (ifp))
6847 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6848 vty_out (vty, "%s", VTY_NEWLINE);
6849 }
6850
6851 /* Router Priority print. */
6852 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6853 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6854 {
6855 vty_out (vty, " ip ospf priority %u", params->priority);
6856 if (params != IF_DEF_PARAMS (ifp))
6857 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6858 vty_out (vty, "%s", VTY_NEWLINE);
6859 }
6860
6861 /* Retransmit Interval print. */
6862 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6863 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6864 {
6865 vty_out (vty, " ip ospf retransmit-interval %u",
6866 params->retransmit_interval);
6867 if (params != IF_DEF_PARAMS (ifp))
6868 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6869 vty_out (vty, "%s", VTY_NEWLINE);
6870 }
6871
6872 /* Transmit Delay print. */
6873 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6874 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6875 {
6876 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6877 if (params != IF_DEF_PARAMS (ifp))
6878 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6879 vty_out (vty, "%s", VTY_NEWLINE);
6880 }
6881
6882 while (1)
6883 {
6884 if (rn == NULL)
6885 rn = route_top (IF_OIFS_PARAMS (ifp));
6886 else
6887 rn = route_next (rn);
6888
6889 if (rn == NULL)
6890 break;
6891 params = rn->info;
6892 if (params != NULL)
6893 break;
6894 }
6895 } while (rn);
6896
6897#ifdef HAVE_OPAQUE_LSA
6898 ospf_opaque_config_write_if (vty, ifp);
6899#endif /* HAVE_OPAQUE_LSA */
6900 }
6901
6902 return write;
6903}
6904
6905int
paul68980082003-03-25 05:07:42 +00006906config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006907{
6908 struct route_node *rn;
6909 u_char buf[INET_ADDRSTRLEN];
6910
6911 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006912 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006913 if (rn->info)
6914 {
6915 struct ospf_network *n = rn->info;
6916
6917 memset (buf, 0, INET_ADDRSTRLEN);
6918
6919 /* Create Area ID string by specified Area ID format. */
6920 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6921 strncpy (buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
6922 else
6923 sprintf (buf, "%lu",
6924 (unsigned long int) ntohl (n->area_id.s_addr));
6925
6926 /* Network print. */
6927 vty_out (vty, " network %s/%d area %s%s",
6928 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6929 buf, VTY_NEWLINE);
6930 }
6931
6932 return 0;
6933}
6934
6935int
paul68980082003-03-25 05:07:42 +00006936config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006937{
6938 listnode node;
6939 u_char buf[INET_ADDRSTRLEN];
6940
6941 /* Area configuration print. */
paul68980082003-03-25 05:07:42 +00006942 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00006943 {
6944 struct ospf_area *area = getdata (node);
6945 struct route_node *rn1;
6946
6947 area_id2str (buf, INET_ADDRSTRLEN, area);
6948
6949 if (area->auth_type != OSPF_AUTH_NULL)
6950 {
6951 if (area->auth_type == OSPF_AUTH_SIMPLE)
6952 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6953 else
6954 vty_out (vty, " area %s authentication message-digest%s",
6955 buf, VTY_NEWLINE);
6956 }
6957
6958 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6959 vty_out (vty, " area %s shortcut %s%s", buf,
6960 ospf_shortcut_mode_str[area->shortcut_configured],
6961 VTY_NEWLINE);
6962
6963 if ((area->external_routing == OSPF_AREA_STUB)
6964#ifdef HAVE_NSSA
6965 || (area->external_routing == OSPF_AREA_NSSA)
6966#endif /* HAVE_NSSA */
6967 )
6968 {
paulb0a053b2003-06-22 09:04:47 +00006969 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006970 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00006971#ifdef HAVE_NSSA
6972 else if (area->external_routing == OSPF_AREA_NSSA)
6973 {
6974 vty_out (vty, " area %s nssa", buf);
6975 switch (area->NSSATranslatorRole)
6976 {
6977 case OSPF_NSSA_ROLE_NEVER:
6978 vty_out (vty, " translate-never");
6979 break;
6980 case OSPF_NSSA_ROLE_ALWAYS:
6981 vty_out (vty, " translate-always");
6982 break;
6983 case OSPF_NSSA_ROLE_CANDIDATE:
6984 default:
6985 vty_out (vty, " translate-candidate");
6986 }
6987 }
6988#endif /* HAVE_NSSA */
paul718e3742002-12-13 20:15:29 +00006989
6990 if (area->no_summary)
6991 vty_out (vty, " no-summary");
6992
6993 vty_out (vty, "%s", VTY_NEWLINE);
6994
6995 if (area->default_cost != 1)
6996 vty_out (vty, " area %s default-cost %d%s", buf,
6997 area->default_cost, VTY_NEWLINE);
6998 }
6999
7000 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7001 if (rn1->info)
7002 {
7003 struct ospf_area_range *range = rn1->info;
7004
7005 vty_out (vty, " area %s range %s/%d", buf,
7006 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7007
7008 if (range->cost_config != -1)
7009 vty_out (vty, " cost %d", range->cost_config);
7010
7011 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7012 vty_out (vty, " not-advertise");
7013
7014 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7015 vty_out (vty, " substitute %s/%d",
7016 inet_ntoa (range->subst_addr), range->subst_masklen);
7017
7018 vty_out (vty, "%s", VTY_NEWLINE);
7019 }
7020
7021 if (EXPORT_NAME (area))
7022 vty_out (vty, " area %s export-list %s%s", buf,
7023 EXPORT_NAME (area), VTY_NEWLINE);
7024
7025 if (IMPORT_NAME (area))
7026 vty_out (vty, " area %s import-list %s%s", buf,
7027 IMPORT_NAME (area), VTY_NEWLINE);
7028
7029 if (PREFIX_NAME_IN (area))
7030 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7031 PREFIX_NAME_IN (area), VTY_NEWLINE);
7032
7033 if (PREFIX_NAME_OUT (area))
7034 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7035 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7036 }
7037
7038 return 0;
7039}
7040
7041int
paul68980082003-03-25 05:07:42 +00007042config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007043{
7044 struct ospf_nbr_nbma *nbr_nbma;
7045 struct route_node *rn;
7046
7047 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007048 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007049 if ((nbr_nbma = rn->info))
7050 {
7051 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7052
7053 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7054 vty_out (vty, " priority %d", nbr_nbma->priority);
7055
7056 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7057 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7058
7059 vty_out (vty, "%s", VTY_NEWLINE);
7060 }
7061
7062 return 0;
7063}
7064
7065int
paul68980082003-03-25 05:07:42 +00007066config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007067{
7068 listnode node;
7069 u_char buf[INET_ADDRSTRLEN];
7070
7071 /* Virtual-Link print */
paul68980082003-03-25 05:07:42 +00007072 for (node = listhead (ospf->vlinks); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007073 {
7074 listnode n2;
7075 struct crypt_key *ck;
7076 struct ospf_vl_data *vl_data = getdata (node);
7077 struct ospf_interface *oi;
7078
7079 if (vl_data != NULL)
7080 {
7081 memset (buf, 0, INET_ADDRSTRLEN);
7082
7083 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7084 strncpy (buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
7085 else
7086 sprintf (buf, "%lu",
7087 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7088 oi = vl_data->vl_oi;
7089
7090 /* timers */
7091 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7092 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7093 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7094 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7095 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7096 buf,
7097 inet_ntoa (vl_data->vl_peer),
7098 OSPF_IF_PARAM (oi, v_hello),
7099 OSPF_IF_PARAM (oi, retransmit_interval),
7100 OSPF_IF_PARAM (oi, transmit_delay),
7101 OSPF_IF_PARAM (oi, v_wait),
7102 VTY_NEWLINE);
7103 else
7104 vty_out (vty, " area %s virtual-link %s%s", buf,
7105 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7106 /* Auth key */
7107 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7108 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7109 buf,
7110 inet_ntoa (vl_data->vl_peer),
7111 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7112 VTY_NEWLINE);
7113 /* md5 keys */
7114 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
7115 {
7116 ck = getdata (n2);
7117 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
7118 buf,
7119 inet_ntoa (vl_data->vl_peer),
7120 ck->key_id, ck->auth_key, VTY_NEWLINE);
7121 }
7122
7123 }
7124 }
7125
7126 return 0;
7127}
7128
7129
7130char *distribute_str[] = { "system", "kernel", "connected", "static", "rip",
7131 "ripng", "ospf", "ospf6", "bgp"};
7132int
paul68980082003-03-25 05:07:42 +00007133config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007134{
7135 int type;
7136
7137 /* redistribute print. */
7138 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7139 if (type != zclient->redist_default && zclient->redist[type])
7140 {
7141 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007142 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007143 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007144
paul68980082003-03-25 05:07:42 +00007145 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007146 vty_out (vty, " metric-type 1");
7147
paul020709f2003-04-04 02:44:16 +00007148 if (ROUTEMAP_NAME (ospf, type))
7149 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007150
7151 vty_out (vty, "%s", VTY_NEWLINE);
7152 }
7153
7154 return 0;
7155}
7156
7157int
paul68980082003-03-25 05:07:42 +00007158config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007159{
paul68980082003-03-25 05:07:42 +00007160 if (ospf->default_metric != -1)
7161 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007162 VTY_NEWLINE);
7163 return 0;
7164}
7165
7166int
paul68980082003-03-25 05:07:42 +00007167config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007168{
7169 int type;
7170
paul68980082003-03-25 05:07:42 +00007171 if (ospf)
paul718e3742002-12-13 20:15:29 +00007172 {
7173 /* distribute-list print. */
7174 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007175 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007176 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007177 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007178 distribute_str[type], VTY_NEWLINE);
7179
7180 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007181 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007182 {
paul68980082003-03-25 05:07:42 +00007183 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007184 vty_out (vty, " default-information originate");
7185 else
7186 vty_out (vty, " default-information originate always");
7187
paul68980082003-03-25 05:07:42 +00007188 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007189 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007190 ospf->dmetric[DEFAULT_ROUTE].value);
7191 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007192 vty_out (vty, " metric-type 1");
7193
paul020709f2003-04-04 02:44:16 +00007194 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7195 vty_out (vty, " route-map %s",
7196 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007197
7198 vty_out (vty, "%s", VTY_NEWLINE);
7199 }
7200
7201 }
7202
7203 return 0;
7204}
7205
7206int
paul68980082003-03-25 05:07:42 +00007207config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007208{
7209 struct route_node *rn;
7210 struct ospf_distance *odistance;
7211
paul68980082003-03-25 05:07:42 +00007212 if (ospf->distance_all)
7213 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007214
paul68980082003-03-25 05:07:42 +00007215 if (ospf->distance_intra
7216 || ospf->distance_inter
7217 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007218 {
7219 vty_out (vty, " distance ospf");
7220
paul68980082003-03-25 05:07:42 +00007221 if (ospf->distance_intra)
7222 vty_out (vty, " intra-area %d", ospf->distance_intra);
7223 if (ospf->distance_inter)
7224 vty_out (vty, " inter-area %d", ospf->distance_inter);
7225 if (ospf->distance_external)
7226 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007227
7228 vty_out (vty, "%s", VTY_NEWLINE);
7229 }
7230
paul68980082003-03-25 05:07:42 +00007231 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007232 if ((odistance = rn->info) != NULL)
7233 {
7234 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7235 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7236 odistance->access_list ? odistance->access_list : "",
7237 VTY_NEWLINE);
7238 }
7239 return 0;
7240}
7241
7242/* OSPF configuration write function. */
7243int
7244ospf_config_write (struct vty *vty)
7245{
paul020709f2003-04-04 02:44:16 +00007246 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00007247 listnode node;
7248 int write = 0;
7249
paul020709f2003-04-04 02:44:16 +00007250 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007251 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007252 {
7253 /* `router ospf' print. */
7254 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7255
7256 write++;
7257
paul68980082003-03-25 05:07:42 +00007258 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007259 return write;
7260
7261 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007262 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007263 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007264 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007265
7266 /* ABR type print. */
paul68980082003-03-25 05:07:42 +00007267 if (ospf->abr_type != OSPF_ABR_STAND)
paul718e3742002-12-13 20:15:29 +00007268 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007269 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007270
7271 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007272 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007273 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7274
7275 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007276 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007277 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007278 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007279
7280 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007281 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7282 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007283 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007284 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007285
7286 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007287 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007288 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007289 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007290
7291 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007292 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007293
7294 /* passive-interface print. */
paul020709f2003-04-04 02:44:16 +00007295 for (node = listhead (om->iflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007296 {
7297 struct interface *ifp = getdata (node);
7298
7299 if (!ifp)
7300 continue;
7301 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7302 vty_out (vty, " passive-interface %s%s",
7303 ifp->name, VTY_NEWLINE);
7304 }
7305
paul68980082003-03-25 05:07:42 +00007306 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007307 {
7308 struct ospf_interface *oi = getdata (node);
7309
7310 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7311 oi->params->passive_interface == OSPF_IF_PASSIVE)
7312 vty_out (vty, " passive-interface %s%s",
7313 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
7314 }
7315
7316
7317 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007318 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007319
7320 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007321 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007322
7323 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007324 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007325
7326 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007327 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007328
7329 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007330 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007331
7332 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007333 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007334
7335 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007336 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007337
7338#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007339 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007340#endif /* HAVE_OPAQUE_LSA */
7341 }
7342
7343 return write;
7344}
7345
7346void
7347ospf_vty_show_init ()
7348{
7349 /* "show ip ospf" commands. */
7350 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7351 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7352
7353 /* "show ip ospf database" commands. */
7354 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7355 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7356 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7357 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7358 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7359 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7360 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7361 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7362 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7363 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7364 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7365 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7366 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7367 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7368
7369 /* "show ip ospf interface" commands. */
7370 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7371 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7372
7373 /* "show ip ospf neighbor" commands. */
7374 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7375 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7376 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7377 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7378 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7379 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7380 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7381 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7382 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7383 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7384 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7385 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7386 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7387 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7388
7389 /* "show ip ospf route" commands. */
7390 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7391 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
7392#ifdef HAVE_NSSA
7393 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7394 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
7395#endif /* HAVE_NSSA */
7396}
7397
7398
7399/* ospfd's interface node. */
7400struct cmd_node interface_node =
7401{
7402 INTERFACE_NODE,
7403 "%s(config-if)# ",
7404 1
7405};
7406
7407/* Initialization of OSPF interface. */
7408void
7409ospf_vty_if_init ()
7410{
7411 /* Install interface node. */
7412 install_node (&interface_node, config_write_interface);
7413
7414 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007415 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007416 install_default (INTERFACE_NODE);
7417
7418 /* "description" commands. */
7419 install_element (INTERFACE_NODE, &interface_desc_cmd);
7420 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7421
7422 /* "ip ospf authentication" commands. */
7423 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7424 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7425 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7426 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7427 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7428 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7429 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7430 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7431 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7432 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7433
7434 /* "ip ospf message-digest-key" commands. */
7435 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7436 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7437 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7438 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7439
7440 /* "ip ospf cost" commands. */
7441 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7442 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7443 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7444 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7445
7446 /* "ip ospf dead-interval" commands. */
7447 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7448 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7449 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7450 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7451
7452 /* "ip ospf hello-interval" commands. */
7453 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7454 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7455 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7456 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7457
7458 /* "ip ospf network" commands. */
7459 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7460 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7461
7462 /* "ip ospf priority" commands. */
7463 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7464 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7465 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7466 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7467
7468 /* "ip ospf retransmit-interval" commands. */
7469 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7470 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7471 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7472 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7473
7474 /* "ip ospf transmit-delay" commands. */
7475 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7476 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7477 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7478 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7479
7480 /* These commands are compatibitliy for previous version. */
7481 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7482 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7483 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7484 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7485 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7486 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7487 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7488 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7489 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7490 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7491 install_element (INTERFACE_NODE, &ospf_network_cmd);
7492 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7493 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7494 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7495 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7496 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7497 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7498 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7499}
7500
7501/* Zebra node structure. */
7502struct cmd_node zebra_node =
7503{
7504 ZEBRA_NODE,
7505 "%s(config-router)#",
7506};
7507
7508void
7509ospf_vty_zebra_init ()
7510{
7511 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7512 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7513 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7514 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7515 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7516 install_element (OSPF_NODE,
7517 &ospf_redistribute_source_metric_type_routemap_cmd);
7518 install_element (OSPF_NODE,
7519 &ospf_redistribute_source_type_metric_routemap_cmd);
7520 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7521 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7522 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7523
7524 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7525
7526 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7527 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7528
7529 install_element (OSPF_NODE,
7530 &ospf_default_information_originate_metric_type_cmd);
7531 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7532 install_element (OSPF_NODE,
7533 &ospf_default_information_originate_type_metric_cmd);
7534 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7535 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7536 install_element (OSPF_NODE,
7537 &ospf_default_information_originate_always_metric_type_cmd);
7538 install_element (OSPF_NODE,
7539 &ospf_default_information_originate_always_metric_cmd);
7540 install_element (OSPF_NODE,
7541 &ospf_default_information_originate_always_cmd);
7542 install_element (OSPF_NODE,
7543 &ospf_default_information_originate_always_type_metric_cmd);
7544 install_element (OSPF_NODE,
7545 &ospf_default_information_originate_always_type_cmd);
7546
7547 install_element (OSPF_NODE,
7548 &ospf_default_information_originate_metric_type_routemap_cmd);
7549 install_element (OSPF_NODE,
7550 &ospf_default_information_originate_metric_routemap_cmd);
7551 install_element (OSPF_NODE,
7552 &ospf_default_information_originate_routemap_cmd);
7553 install_element (OSPF_NODE,
7554 &ospf_default_information_originate_type_metric_routemap_cmd);
7555 install_element (OSPF_NODE,
7556 &ospf_default_information_originate_type_routemap_cmd);
7557 install_element (OSPF_NODE,
7558 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7559 install_element (OSPF_NODE,
7560 &ospf_default_information_originate_always_metric_routemap_cmd);
7561 install_element (OSPF_NODE,
7562 &ospf_default_information_originate_always_routemap_cmd);
7563 install_element (OSPF_NODE,
7564 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7565 install_element (OSPF_NODE,
7566 &ospf_default_information_originate_always_type_routemap_cmd);
7567
7568 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7569
7570 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7571 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7572 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7573
7574 install_element (OSPF_NODE, &ospf_distance_cmd);
7575 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7576 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7577 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7578 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7579 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7580 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7581 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7582 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7583 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7584 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7585 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7586 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7587 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7588 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7589 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7590 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7591 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7592#if 0
7593 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7594 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7595 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7596 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7597#endif /* 0 */
7598}
7599
7600struct cmd_node ospf_node =
7601{
7602 OSPF_NODE,
7603 "%s(config-router)# ",
7604 1
7605};
7606
7607
7608/* Install OSPF related vty commands. */
7609void
7610ospf_vty_init ()
7611{
7612 /* Install ospf top node. */
7613 install_node (&ospf_node, ospf_config_write);
7614
7615 /* "router ospf" commands. */
7616 install_element (CONFIG_NODE, &router_ospf_cmd);
7617 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7618
7619 install_default (OSPF_NODE);
7620
7621 /* "ospf router-id" commands. */
7622 install_element (OSPF_NODE, &ospf_router_id_cmd);
7623 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007624 install_element (OSPF_NODE, &router_ospf_id_cmd);
7625 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007626
7627 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007628 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7629 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7630 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7631 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007632
7633 /* "ospf abr-type" commands. */
7634 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7635 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7636
7637 /* "ospf rfc1583-compatible" commands. */
7638 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7639 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7640 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7641 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7642
7643 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007644 install_element (OSPF_NODE, &ospf_network_area_cmd);
7645 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007646
7647 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007648 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7649 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7650 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007651
7652 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007653 install_element (OSPF_NODE, &ospf_area_range_cmd);
7654 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7655 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7656 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7657 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7658 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7659 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7660 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7661 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7662 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7663 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007664
7665 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007666 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7667 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007668
paula2c62832003-04-23 17:01:31 +00007669 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7670 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007671
paula2c62832003-04-23 17:01:31 +00007672 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7673 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007674
paula2c62832003-04-23 17:01:31 +00007675 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7676 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007677
paula2c62832003-04-23 17:01:31 +00007678 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7679 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007680
paula2c62832003-04-23 17:01:31 +00007681 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7682 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7683 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007684
paula2c62832003-04-23 17:01:31 +00007685 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7686 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007687
paula2c62832003-04-23 17:01:31 +00007688 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7689 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007690
paula2c62832003-04-23 17:01:31 +00007691 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7692 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7693 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007694
paula2c62832003-04-23 17:01:31 +00007695 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7696 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7697 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007698
7699 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007700 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7701 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7702 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7703 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007704
7705#ifdef HAVE_NSSA
7706 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007707 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7708 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7709 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7710 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7711 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7712 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007713#endif /* HAVE_NSSA */
7714
paula2c62832003-04-23 17:01:31 +00007715 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7716 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007717
paula2c62832003-04-23 17:01:31 +00007718 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7719 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007720
paula2c62832003-04-23 17:01:31 +00007721 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7722 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007723
paula2c62832003-04-23 17:01:31 +00007724 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7725 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007726
paula2c62832003-04-23 17:01:31 +00007727 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7728 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007729
paula2c62832003-04-23 17:01:31 +00007730 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7731 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007732
paula2c62832003-04-23 17:01:31 +00007733 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7734 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7735 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007736
paula2c62832003-04-23 17:01:31 +00007737 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7738 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007739
7740 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007741 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7742 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7743 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7744 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7745 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7746 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7747 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7748 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007749
7750 /* Init interface related vty commands. */
7751 ospf_vty_if_init ();
7752
7753 /* Init zebra related vty commands. */
7754 ospf_vty_zebra_init ();
7755}