blob: 0ecb6fb48a30f1ce19dd845f7be55d8c1697f3c3 [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
hassoeb1ce602004-10-08 08:17:22 +000052const static char *ospf_network_type_str[] =
paul718e3742002-12-13 20:15:29 +000053{
54 "Null",
55 "POINTOPOINT",
56 "BROADCAST",
57 "NBMA",
58 "POINTOMULTIPOINT",
59 "VIRTUALLINK",
60 "LOOPBACK"
61};
62
63
64/* Utility functions. */
65int
paul6c835672004-10-11 11:00:30 +000066ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
paul718e3742002-12-13 20:15:29 +000067{
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
paul6c835672004-10-11 11:00:30 +000095str2distribute_source (const char *str, int *source)
paul718e3742002-12-13 20:15:29 +000096{
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
paul6c835672004-10-11 11:00:30 +0000118str2metric (const char *str, int *metric)
paul718e3742002-12-13 20:15:29 +0000119{
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
paul6c835672004-10-11 11:00:30 +0000135str2metric_type (const char *str, int *metric_type)
paul718e3742002-12-13 20:15:29 +0000136{
137 /* Sanity check. */
138 if (str == NULL)
139 return 0;
140
141 if (strncmp (str, "1", 1) == 0)
142 *metric_type = EXTERNAL_METRIC_TYPE_1;
143 else if (strncmp (str, "2", 1) == 0)
144 *metric_type = EXTERNAL_METRIC_TYPE_2;
145 else
146 return 0;
147
148 return 1;
149}
150
151int
152ospf_oi_count (struct interface *ifp)
153{
154 struct route_node *rn;
155 int i = 0;
156
157 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
158 if (rn->info)
159 i++;
160
161 return i;
162}
163
164
165DEFUN (router_ospf,
166 router_ospf_cmd,
167 "router ospf",
168 "Enable a routing process\n"
169 "Start OSPF configuration\n")
170{
171 vty->node = OSPF_NODE;
172 vty->index = ospf_get ();
173
174 return CMD_SUCCESS;
175}
176
177DEFUN (no_router_ospf,
178 no_router_ospf_cmd,
179 "no router ospf",
180 NO_STR
181 "Enable a routing process\n"
182 "Start OSPF configuration\n")
183{
paul020709f2003-04-04 02:44:16 +0000184 struct ospf *ospf;
185
186 ospf = ospf_lookup ();
187 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000188 {
paul020709f2003-04-04 02:44:16 +0000189 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000190 return CMD_WARNING;
191 }
192
paul020709f2003-04-04 02:44:16 +0000193 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000194
195 return CMD_SUCCESS;
196}
197
198DEFUN (ospf_router_id,
199 ospf_router_id_cmd,
200 "ospf router-id A.B.C.D",
201 "OSPF specific commands\n"
202 "router-id for the OSPF process\n"
203 "OSPF router-id in IP address format\n")
204{
paul68980082003-03-25 05:07:42 +0000205 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000206 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000207 int ret;
paul718e3742002-12-13 20:15:29 +0000208
209 ret = inet_aton (argv[0], &router_id);
210 if (!ret)
211 {
212 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
213 return CMD_WARNING;
214 }
215
paul68980082003-03-25 05:07:42 +0000216 ospf->router_id_static = router_id;
paul718e3742002-12-13 20:15:29 +0000217
paul68980082003-03-25 05:07:42 +0000218 if (ospf->t_router_id_update == NULL)
paul020709f2003-04-04 02:44:16 +0000219 OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer,
220 OSPF_ROUTER_ID_UPDATE_DELAY);
paul718e3742002-12-13 20:15:29 +0000221
222 return CMD_SUCCESS;
223}
224
225ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000226 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000227 "router-id A.B.C.D",
228 "router-id for the OSPF process\n"
229 "OSPF router-id in IP address format\n")
230
231DEFUN (no_ospf_router_id,
232 no_ospf_router_id_cmd,
233 "no ospf router-id",
234 NO_STR
235 "OSPF specific commands\n"
236 "router-id for the OSPF process\n")
237{
paul68980082003-03-25 05:07:42 +0000238 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000239
paul68980082003-03-25 05:07:42 +0000240 ospf->router_id_static.s_addr = 0;
241
242 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000243
244 return CMD_SUCCESS;
245}
246
247ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000248 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000249 "no router-id",
250 NO_STR
251 "router-id for the OSPF process\n")
252
paula2c62832003-04-23 17:01:31 +0000253DEFUN (ospf_passive_interface,
254 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000255 "passive-interface IFNAME A.B.C.D",
256 "Suppress routing updates on an interface\n"
257 "Interface's name\n")
258{
259 struct interface *ifp;
260 struct in_addr addr;
261 int ret;
262 struct ospf_if_params *params;
263
264 ifp = if_lookup_by_name (argv[0]);
265
266 if (ifp == NULL)
267 {
268 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
269 return CMD_WARNING;
270 }
271
272 params = IF_DEF_PARAMS (ifp);
273
274 if (argc == 2)
275 {
276 ret = inet_aton(argv[1], &addr);
277 if (!ret)
278 {
279 vty_out (vty, "Please specify interface address by A.B.C.D%s",
280 VTY_NEWLINE);
281 return CMD_WARNING;
282 }
283
284 params = ospf_get_if_params (ifp, addr);
285 ospf_if_update_params (ifp, addr);
286 }
287
288 SET_IF_PARAM (params, passive_interface);
289 params->passive_interface = OSPF_IF_PASSIVE;
290
291 return CMD_SUCCESS;
292}
293
paula2c62832003-04-23 17:01:31 +0000294ALIAS (ospf_passive_interface,
295 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000296 "passive-interface IFNAME",
297 "Suppress routing updates on an interface\n"
298 "Interface's name\n")
299
paula2c62832003-04-23 17:01:31 +0000300DEFUN (no_ospf_passive_interface,
301 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000302 "no passive-interface IFNAME A.B.C.D",
303 NO_STR
304 "Allow routing updates on an interface\n"
305 "Interface's name\n")
306{
307 struct interface *ifp;
308 struct in_addr addr;
309 struct ospf_if_params *params;
310 int ret;
311
312 ifp = if_lookup_by_name (argv[0]);
313
314 if (ifp == NULL)
315 {
316 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
317 return CMD_WARNING;
318 }
319
320 params = IF_DEF_PARAMS (ifp);
321
322 if (argc == 2)
323 {
324 ret = inet_aton(argv[1], &addr);
325 if (!ret)
326 {
327 vty_out (vty, "Please specify interface address by A.B.C.D%s",
328 VTY_NEWLINE);
329 return CMD_WARNING;
330 }
331
332 params = ospf_lookup_if_params (ifp, addr);
333 if (params == NULL)
334 return CMD_SUCCESS;
335 }
336
337 UNSET_IF_PARAM (params, passive_interface);
338 params->passive_interface = OSPF_IF_ACTIVE;
339
340 if (params != IF_DEF_PARAMS (ifp))
341 {
342 ospf_free_if_params (ifp, addr);
343 ospf_if_update_params (ifp, addr);
344 }
345
346 return CMD_SUCCESS;
347}
348
paula2c62832003-04-23 17:01:31 +0000349ALIAS (no_ospf_passive_interface,
350 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000351 "no passive-interface IFNAME",
352 NO_STR
353 "Allow routing updates on an interface\n"
354 "Interface's name\n")
355
paula2c62832003-04-23 17:01:31 +0000356DEFUN (ospf_network_area,
357 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000358 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
359 "Enable routing on an IP network\n"
360 "OSPF network prefix\n"
361 "Set the OSPF area ID\n"
362 "OSPF area ID in IP address format\n"
363 "OSPF area ID as a decimal value\n")
364{
365 struct ospf *ospf= vty->index;
366 struct prefix_ipv4 p;
367 struct in_addr area_id;
368 int ret, format;
369
370 /* Get network prefix and Area ID. */
371 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
372 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
373
374 ret = ospf_network_set (ospf, &p, area_id);
375 if (ret == 0)
376 {
377 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
378 return CMD_WARNING;
379 }
380
381 return CMD_SUCCESS;
382}
383
paula2c62832003-04-23 17:01:31 +0000384DEFUN (no_ospf_network_area,
385 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000386 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
387 NO_STR
388 "Enable routing on an IP network\n"
389 "OSPF network prefix\n"
390 "Set the OSPF area ID\n"
391 "OSPF area ID in IP address format\n"
392 "OSPF area ID as a decimal value\n")
393{
394 struct ospf *ospf = (struct ospf *) vty->index;
395 struct prefix_ipv4 p;
396 struct in_addr area_id;
397 int ret, format;
398
399 /* Get network prefix and Area ID. */
400 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
401 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
402
403 ret = ospf_network_unset (ospf, &p, area_id);
404 if (ret == 0)
405 {
406 vty_out (vty, "Can't find specified network area configuration.%s",
407 VTY_NEWLINE);
408 return CMD_WARNING;
409 }
410
411 return CMD_SUCCESS;
412}
413
414
paula2c62832003-04-23 17:01:31 +0000415DEFUN (ospf_area_range,
416 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000417 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
418 "OSPF area parameters\n"
419 "OSPF area ID in IP address format\n"
420 "OSPF area ID as a decimal value\n"
421 "Summarize routes matching address/mask (border routers only)\n"
422 "Area range prefix\n")
423{
424 struct ospf *ospf = vty->index;
425 struct prefix_ipv4 p;
426 struct in_addr area_id;
427 int format;
428 u_int32_t cost;
429
430 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
431 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
432
433 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
434 if (argc > 2)
435 {
436 VTY_GET_UINT32 ("range cost", cost, argv[2]);
437 ospf_area_range_cost_set (ospf, area_id, &p, cost);
438 }
439
440 return CMD_SUCCESS;
441}
442
paula2c62832003-04-23 17:01:31 +0000443ALIAS (ospf_area_range,
444 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000445 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
446 "OSPF area parameters\n"
447 "OSPF area ID in IP address format\n"
448 "OSPF area ID as a decimal value\n"
449 "OSPF area range for route advertise (default)\n"
450 "Area range prefix\n"
451 "Advertise this range (default)\n")
452
paula2c62832003-04-23 17:01:31 +0000453ALIAS (ospf_area_range,
454 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000455 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
456 "OSPF area parameters\n"
457 "OSPF area ID in IP address format\n"
458 "OSPF area ID as a decimal value\n"
459 "Summarize routes matching address/mask (border routers only)\n"
460 "Area range prefix\n"
461 "User specified metric for this range\n"
462 "Advertised metric for this range\n")
463
paula2c62832003-04-23 17:01:31 +0000464ALIAS (ospf_area_range,
465 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000466 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
467 "OSPF area parameters\n"
468 "OSPF area ID in IP address format\n"
469 "OSPF area ID as a decimal value\n"
470 "Summarize routes matching address/mask (border routers only)\n"
471 "Area range prefix\n"
472 "Advertise this range (default)\n"
473 "User specified metric for this range\n"
474 "Advertised metric for this range\n")
475
paula2c62832003-04-23 17:01:31 +0000476DEFUN (ospf_area_range_not_advertise,
477 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000478 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
479 "OSPF area parameters\n"
480 "OSPF area ID in IP address format\n"
481 "OSPF area ID as a decimal value\n"
482 "Summarize routes matching address/mask (border routers only)\n"
483 "Area range prefix\n"
484 "DoNotAdvertise this range\n")
485{
486 struct ospf *ospf = vty->index;
487 struct prefix_ipv4 p;
488 struct in_addr area_id;
489 int format;
490
491 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
492 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
493
494 ospf_area_range_set (ospf, area_id, &p, 0);
495
496 return CMD_SUCCESS;
497}
498
paula2c62832003-04-23 17:01:31 +0000499DEFUN (no_ospf_area_range,
500 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000501 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
502 NO_STR
503 "OSPF area parameters\n"
504 "OSPF area ID in IP address format\n"
505 "OSPF area ID as a decimal value\n"
506 "Summarize routes matching address/mask (border routers only)\n"
507 "Area range prefix\n")
508{
509 struct ospf *ospf = vty->index;
510 struct prefix_ipv4 p;
511 struct in_addr area_id;
512 int format;
513
514 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
515 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
516
517 ospf_area_range_unset (ospf, area_id, &p);
518
519 return CMD_SUCCESS;
520}
521
paula2c62832003-04-23 17:01:31 +0000522ALIAS (no_ospf_area_range,
523 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000524 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
525 NO_STR
526 "OSPF area parameters\n"
527 "OSPF area ID in IP address format\n"
528 "OSPF area ID as a decimal value\n"
529 "Summarize routes matching address/mask (border routers only)\n"
530 "Area range prefix\n"
531 "Advertise this range (default)\n"
532 "DoNotAdvertise this range\n")
533
paula2c62832003-04-23 17:01:31 +0000534ALIAS (no_ospf_area_range,
535 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000536 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
537 NO_STR
538 "OSPF area parameters\n"
539 "OSPF area ID in IP address format\n"
540 "OSPF area ID as a decimal value\n"
541 "Summarize routes matching address/mask (border routers only)\n"
542 "Area range prefix\n"
543 "User specified metric for this range\n"
544 "Advertised metric for this range\n")
545
paula2c62832003-04-23 17:01:31 +0000546ALIAS (no_ospf_area_range,
547 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000548 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
549 NO_STR
550 "OSPF area parameters\n"
551 "OSPF area ID in IP address format\n"
552 "OSPF area ID as a decimal value\n"
553 "Summarize routes matching address/mask (border routers only)\n"
554 "Area range prefix\n"
555 "Advertise this range (default)\n"
556 "User specified metric for this range\n"
557 "Advertised metric for this range\n")
558
paula2c62832003-04-23 17:01:31 +0000559DEFUN (ospf_area_range_substitute,
560 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000561 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
562 "OSPF area parameters\n"
563 "OSPF area ID in IP address format\n"
564 "OSPF area ID as a decimal value\n"
565 "Summarize routes matching address/mask (border routers only)\n"
566 "Area range prefix\n"
567 "Announce area range as another prefix\n"
568 "Network prefix to be announced instead of range\n")
569{
570 struct ospf *ospf = vty->index;
571 struct prefix_ipv4 p, s;
572 struct in_addr area_id;
573 int format;
574
575 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
576 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
577 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
578
579 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
580
581 return CMD_SUCCESS;
582}
583
paula2c62832003-04-23 17:01:31 +0000584DEFUN (no_ospf_area_range_substitute,
585 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000586 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
587 NO_STR
588 "OSPF area parameters\n"
589 "OSPF area ID in IP address format\n"
590 "OSPF area ID as a decimal value\n"
591 "Summarize routes matching address/mask (border routers only)\n"
592 "Area range prefix\n"
593 "Announce area range as another prefix\n"
594 "Network prefix to be announced instead of range\n")
595{
596 struct ospf *ospf = vty->index;
597 struct prefix_ipv4 p, s;
598 struct in_addr area_id;
599 int format;
600
601 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
602 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
603 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
604
605 ospf_area_range_substitute_unset (ospf, area_id, &p);
606
607 return CMD_SUCCESS;
608}
609
610
611/* Command Handler Logic in VLink stuff is delicate!!
612
613 ALTER AT YOUR OWN RISK!!!!
614
615 Various dummy values are used to represent 'NoChange' state for
616 VLink configuration NOT being changed by a VLink command, and
617 special syntax is used within the command strings so that the
618 typed in command verbs can be seen in the configuration command
619 bacckend handler. This is to drastically reduce the verbeage
620 required to coe up with a reasonably compatible Cisco VLink command
621
622 - Matthew Grant <grantma@anathoth.gen.nz>
623 Wed, 21 Feb 2001 15:13:52 +1300
624 */
625
626
627/* Configuration data for virtual links
628 */
629struct ospf_vl_config_data {
630 struct vty *vty; /* vty stuff */
631 struct in_addr area_id; /* area ID from command line */
632 int format; /* command line area ID format */
633 struct in_addr vl_peer; /* command line vl_peer */
634 int auth_type; /* Authehntication type, if given */
635 char *auth_key; /* simple password if present */
636 int crypto_key_id; /* Cryptographic key ID */
637 char *md5_key; /* MD5 authentication key */
638 int hello_interval; /* Obvious what these are... */
639 int retransmit_interval;
640 int transmit_delay;
641 int dead_interval;
642};
643
644void
645ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
646 struct vty *vty)
647{
648 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
649 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
650 vl_config->vty = vty;
651}
652
653struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000654ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000655{
656 struct ospf_area *area;
657 struct ospf_vl_data *vl_data;
658 struct vty *vty;
659 struct in_addr area_id;
660
661 vty = vl_config->vty;
662 area_id = vl_config->area_id;
663
664 if (area_id.s_addr == OSPF_AREA_BACKBONE)
665 {
666 vty_out (vty,
667 "Configuring VLs over the backbone is not allowed%s",
668 VTY_NEWLINE);
669 return NULL;
670 }
paul68980082003-03-25 05:07:42 +0000671 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000672
673 if (area->external_routing != OSPF_AREA_DEFAULT)
674 {
675 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
676 vty_out (vty, "Area %s is %s%s",
677 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000678 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000679 VTY_NEWLINE);
680 else
681 vty_out (vty, "Area %ld is %s%s",
682 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000683 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000684 VTY_NEWLINE);
685 return NULL;
686 }
687
688 if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)
689 {
690 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
691 if (vl_data->vl_oi == NULL)
692 {
paul68980082003-03-25 05:07:42 +0000693 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
694 ospf_vl_add (ospf, vl_data);
695 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000696 }
697 }
698 return vl_data;
699}
700
701
702int
703ospf_vl_set_security (struct ospf_vl_data *vl_data,
704 struct ospf_vl_config_data *vl_config)
705{
706 struct crypt_key *ck;
707 struct vty *vty;
708 struct interface *ifp = vl_data->vl_oi->ifp;
709
710 vty = vl_config->vty;
711
712 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
713 {
714 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
715 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
716 }
717
718 if (vl_config->auth_key)
719 {
720 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000721 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000722 OSPF_AUTH_SIMPLE_SIZE);
723 }
724 else if (vl_config->md5_key)
725 {
726 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
727 != NULL)
728 {
729 vty_out (vty, "OSPF: Key %d already exists%s",
730 vl_config->crypto_key_id, VTY_NEWLINE);
731 return CMD_WARNING;
732 }
733 ck = ospf_crypt_key_new ();
734 ck->key_id = vl_config->crypto_key_id;
735 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000736 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000737
738 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
739 }
740 else if (vl_config->crypto_key_id != 0)
741 {
742 /* Delete a key */
743
744 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
745 vl_config->crypto_key_id) == NULL)
746 {
747 vty_out (vty, "OSPF: Key %d does not exist%s",
748 vl_config->crypto_key_id, VTY_NEWLINE);
749 return CMD_WARNING;
750 }
751
752 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
753
754 }
755
756 return CMD_SUCCESS;
757}
758
759
760
761int
762ospf_vl_set_timers (struct ospf_vl_data *vl_data,
763 struct ospf_vl_config_data *vl_config)
764{
765 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
766 /* Virtual Link data initialised to defaults, so only set
767 if a value given */
768 if (vl_config->hello_interval)
769 {
770 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
771 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
772 }
773
774 if (vl_config->dead_interval)
775 {
776 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
777 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
778 }
779
780 if (vl_config->retransmit_interval)
781 {
782 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
783 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
784 }
785
786 if (vl_config->transmit_delay)
787 {
788 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
789 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
790 }
791
792 return CMD_SUCCESS;
793}
794
795
796
797/* The business end of all of the above */
798int
paul68980082003-03-25 05:07:42 +0000799ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000800{
801 struct ospf_vl_data *vl_data;
802 int ret;
803
paul68980082003-03-25 05:07:42 +0000804 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000805 if (!vl_data)
806 return CMD_WARNING;
807
808 /* Process this one first as it can have a fatal result, which can
809 only logically occur if the virtual link exists already
810 Thus a command error does not result in a change to the
811 running configuration such as unexpectedly altered timer
812 values etc.*/
813 ret = ospf_vl_set_security (vl_data, vl_config);
814 if (ret != CMD_SUCCESS)
815 return ret;
816
817 /* Set any time based parameters, these area already range checked */
818
819 ret = ospf_vl_set_timers (vl_data, vl_config);
820 if (ret != CMD_SUCCESS)
821 return ret;
822
823 return CMD_SUCCESS;
824
825}
826
827/* This stuff exists to make specifying all the alias commands A LOT simpler
828 */
829#define VLINK_HELPSTR_IPADDR \
830 "OSPF area parameters\n" \
831 "OSPF area ID in IP address format\n" \
832 "OSPF area ID as a decimal value\n" \
833 "Configure a virtual link\n" \
834 "Router ID of the remote ABR\n"
835
836#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
837 "Enable authentication on this virtual link\n" \
838 "dummy string \n"
839
840#define VLINK_HELPSTR_AUTHTYPE_ALL \
841 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
842 "Use null authentication\n" \
843 "Use message-digest authentication\n"
844
845#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
846 "Time between HELLO packets\n" \
847 "Time between retransmitting lost link state advertisements\n" \
848 "Link state transmit delay\n" \
849 "Interval after which a neighbor is declared dead\n"
850
851#define VLINK_HELPSTR_TIME_PARAM \
852 VLINK_HELPSTR_TIME_PARAM_NOSECS \
853 "Seconds\n"
854
855#define VLINK_HELPSTR_AUTH_SIMPLE \
856 "Authentication password (key)\n" \
857 "The OSPF password (key)"
858
859#define VLINK_HELPSTR_AUTH_MD5 \
860 "Message digest authentication password (key)\n" \
861 "dummy string \n" \
862 "Key ID\n" \
863 "Use MD5 algorithm\n" \
864 "The OSPF password (key)"
865
paula2c62832003-04-23 17:01:31 +0000866DEFUN (ospf_area_vlink,
867 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000868 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
869 VLINK_HELPSTR_IPADDR)
870{
paul68980082003-03-25 05:07:42 +0000871 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000872 struct ospf_vl_config_data vl_config;
873 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
874 char md5_key[OSPF_AUTH_MD5_SIZE+1];
875 int i;
876 int ret;
877
878 ospf_vl_config_data_init(&vl_config, vty);
879
880 /* Read off first 2 parameters and check them */
881 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
882 if (ret < 0)
883 {
884 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
885 return CMD_WARNING;
886 }
887
888 ret = inet_aton (argv[1], &vl_config.vl_peer);
889 if (! ret)
890 {
891 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
892 VTY_NEWLINE);
893 return CMD_WARNING;
894 }
895
896 if (argc <=2)
897 {
898 /* Thats all folks! - BUGS B. strikes again!!!*/
899
paul68980082003-03-25 05:07:42 +0000900 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000901 }
902
903 /* Deal with other parameters */
904 for (i=2; i < argc; i++)
905 {
906
907 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
908
909 switch (argv[i][0])
910 {
911
912 case 'a':
913 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
914 {
915 /* authentication-key - this option can occur anywhere on
916 command line. At start of command line
917 must check for authentication option. */
918 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
919 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
920 vl_config.auth_key = auth_key;
921 i++;
922 }
923 else if (strncmp (argv[i], "authentication", 14) == 0)
924 {
925 /* authentication - this option can only occur at start
926 of command line */
927 vl_config.auth_type = OSPF_AUTH_SIMPLE;
928 if ((i+1) < argc)
929 {
930 if (strncmp (argv[i+1], "n", 1) == 0)
931 {
932 /* "authentication null" */
933 vl_config.auth_type = OSPF_AUTH_NULL;
934 i++;
935 }
936 else if (strncmp (argv[i+1], "m", 1) == 0
937 && strcmp (argv[i+1], "message-digest-") != 0)
938 {
939 /* "authentication message-digest" */
940 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
941 i++;
942 }
943 }
944 }
945 break;
946
947 case 'm':
948 /* message-digest-key */
949 i++;
950 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
951 if (vl_config.crypto_key_id < 0)
952 return CMD_WARNING;
953 i++;
954 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
955 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
956 vl_config.md5_key = md5_key;
957 break;
958
959 case 'h':
960 /* Hello interval */
961 i++;
962 vl_config.hello_interval = strtol (argv[i], NULL, 10);
963 if (vl_config.hello_interval < 0)
964 return CMD_WARNING;
965 break;
966
967 case 'r':
968 /* Retransmit Interval */
969 i++;
970 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
971 if (vl_config.retransmit_interval < 0)
972 return CMD_WARNING;
973 break;
974
975 case 't':
976 /* Transmit Delay */
977 i++;
978 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
979 if (vl_config.transmit_delay < 0)
980 return CMD_WARNING;
981 break;
982
983 case 'd':
984 /* Dead Interval */
985 i++;
986 vl_config.dead_interval = strtol (argv[i], NULL, 10);
987 if (vl_config.dead_interval < 0)
988 return CMD_WARNING;
989 break;
990 }
991 }
992
993
994 /* Action configuration */
995
paul68980082003-03-25 05:07:42 +0000996 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000997
998}
999
paula2c62832003-04-23 17:01:31 +00001000DEFUN (no_ospf_area_vlink,
1001 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001002 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1003 NO_STR
1004 VLINK_HELPSTR_IPADDR)
1005{
paul68980082003-03-25 05:07:42 +00001006 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001007 struct ospf_area *area;
1008 struct ospf_vl_config_data vl_config;
1009 struct ospf_vl_data *vl_data = NULL;
1010 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1011 int i;
1012 int ret, format;
1013
1014 ospf_vl_config_data_init(&vl_config, vty);
1015
1016 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1017 if (ret < 0)
1018 {
1019 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1020 return CMD_WARNING;
1021 }
1022
paul68980082003-03-25 05:07:42 +00001023 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001024 if (!area)
1025 {
1026 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1027 return CMD_WARNING;
1028 }
1029
1030 ret = inet_aton (argv[1], &vl_config.vl_peer);
1031 if (! ret)
1032 {
1033 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1034 VTY_NEWLINE);
1035 return CMD_WARNING;
1036 }
1037
1038 if (argc <=2)
1039 {
1040 /* Basic VLink no command */
1041 /* Thats all folks! - BUGS B. strikes again!!!*/
1042 if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001043 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001044
paul68980082003-03-25 05:07:42 +00001045 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001046
1047 return CMD_SUCCESS;
1048 }
1049
1050 /* If we are down here, we are reseting parameters */
1051
1052 /* Deal with other parameters */
1053 for (i=2; i < argc; i++)
1054 {
paul718e3742002-12-13 20:15:29 +00001055 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1056
1057 switch (argv[i][0])
1058 {
1059
1060 case 'a':
1061 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1062 {
1063 /* authentication-key - this option can occur anywhere on
1064 command line. At start of command line
1065 must check for authentication option. */
1066 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1067 vl_config.auth_key = auth_key;
1068 }
1069 else if (strncmp (argv[i], "authentication", 14) == 0)
1070 {
1071 /* authentication - this option can only occur at start
1072 of command line */
1073 vl_config.auth_type = OSPF_AUTH_NOTSET;
1074 }
1075 break;
1076
1077 case 'm':
1078 /* message-digest-key */
1079 /* Delete one key */
1080 i++;
1081 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1082 if (vl_config.crypto_key_id < 0)
1083 return CMD_WARNING;
1084 vl_config.md5_key = NULL;
1085 break;
1086
1087 case 'h':
1088 /* Hello interval */
1089 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1090 break;
1091
1092 case 'r':
1093 /* Retransmit Interval */
1094 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1095 break;
1096
1097 case 't':
1098 /* Transmit Delay */
1099 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1100 break;
1101
1102 case 'd':
1103 /* Dead Interval */
1104 i++;
1105 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1106 break;
1107 }
1108 }
1109
1110
1111 /* Action configuration */
1112
paul68980082003-03-25 05:07:42 +00001113 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001114}
1115
paula2c62832003-04-23 17:01:31 +00001116ALIAS (ospf_area_vlink,
1117 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001118 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1119 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1120 VLINK_HELPSTR_IPADDR
1121 VLINK_HELPSTR_TIME_PARAM)
1122
paula2c62832003-04-23 17:01:31 +00001123ALIAS (no_ospf_area_vlink,
1124 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001125 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1126 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1127 NO_STR
1128 VLINK_HELPSTR_IPADDR
1129 VLINK_HELPSTR_TIME_PARAM)
1130
paula2c62832003-04-23 17:01:31 +00001131ALIAS (ospf_area_vlink,
1132 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001133 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1134 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1135 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1136 VLINK_HELPSTR_IPADDR
1137 VLINK_HELPSTR_TIME_PARAM
1138 VLINK_HELPSTR_TIME_PARAM)
1139
paula2c62832003-04-23 17:01:31 +00001140ALIAS (no_ospf_area_vlink,
1141 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001142 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1143 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1144 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1145 NO_STR
1146 VLINK_HELPSTR_IPADDR
1147 VLINK_HELPSTR_TIME_PARAM
1148 VLINK_HELPSTR_TIME_PARAM)
1149
paula2c62832003-04-23 17:01:31 +00001150ALIAS (ospf_area_vlink,
1151 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001152 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1153 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1154 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1155 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1156 VLINK_HELPSTR_IPADDR
1157 VLINK_HELPSTR_TIME_PARAM
1158 VLINK_HELPSTR_TIME_PARAM
1159 VLINK_HELPSTR_TIME_PARAM)
1160
paula2c62832003-04-23 17:01:31 +00001161ALIAS (no_ospf_area_vlink,
1162 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001163 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1164 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1165 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1166 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1167 NO_STR
1168 VLINK_HELPSTR_IPADDR
1169 VLINK_HELPSTR_TIME_PARAM
1170 VLINK_HELPSTR_TIME_PARAM
1171 VLINK_HELPSTR_TIME_PARAM)
1172
paula2c62832003-04-23 17:01:31 +00001173ALIAS (ospf_area_vlink,
1174 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001175 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1176 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1177 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1178 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1179 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1180 VLINK_HELPSTR_IPADDR
1181 VLINK_HELPSTR_TIME_PARAM
1182 VLINK_HELPSTR_TIME_PARAM
1183 VLINK_HELPSTR_TIME_PARAM
1184 VLINK_HELPSTR_TIME_PARAM)
1185
paula2c62832003-04-23 17:01:31 +00001186ALIAS (no_ospf_area_vlink,
1187 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001188 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1189 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1190 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1191 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1192 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1193 NO_STR
1194 VLINK_HELPSTR_IPADDR
1195 VLINK_HELPSTR_TIME_PARAM
1196 VLINK_HELPSTR_TIME_PARAM
1197 VLINK_HELPSTR_TIME_PARAM
1198 VLINK_HELPSTR_TIME_PARAM)
1199
paula2c62832003-04-23 17:01:31 +00001200ALIAS (ospf_area_vlink,
1201 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001202 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1203 "(authentication|) (message-digest|null)",
1204 VLINK_HELPSTR_IPADDR
1205 VLINK_HELPSTR_AUTHTYPE_ALL)
1206
paula2c62832003-04-23 17:01:31 +00001207ALIAS (ospf_area_vlink,
1208 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001209 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1210 "(authentication|)",
1211 VLINK_HELPSTR_IPADDR
1212 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1213
paula2c62832003-04-23 17:01:31 +00001214ALIAS (no_ospf_area_vlink,
1215 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001216 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1217 "(authentication|)",
1218 NO_STR
1219 VLINK_HELPSTR_IPADDR
1220 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1221
paula2c62832003-04-23 17:01:31 +00001222ALIAS (ospf_area_vlink,
1223 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001224 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1225 "(message-digest-key|) <1-255> md5 KEY",
1226 VLINK_HELPSTR_IPADDR
1227 VLINK_HELPSTR_AUTH_MD5)
1228
paula2c62832003-04-23 17:01:31 +00001229ALIAS (no_ospf_area_vlink,
1230 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001231 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1232 "(message-digest-key|) <1-255>",
1233 NO_STR
1234 VLINK_HELPSTR_IPADDR
1235 VLINK_HELPSTR_AUTH_MD5)
1236
paula2c62832003-04-23 17:01:31 +00001237ALIAS (ospf_area_vlink,
1238 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001239 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1240 "(authentication-key|) AUTH_KEY",
1241 VLINK_HELPSTR_IPADDR
1242 VLINK_HELPSTR_AUTH_SIMPLE)
1243
paula2c62832003-04-23 17:01:31 +00001244ALIAS (no_ospf_area_vlink,
1245 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001246 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1247 "(authentication-key|)",
1248 NO_STR
1249 VLINK_HELPSTR_IPADDR
1250 VLINK_HELPSTR_AUTH_SIMPLE)
1251
paula2c62832003-04-23 17:01:31 +00001252ALIAS (ospf_area_vlink,
1253 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001254 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1255 "(authentication|) (message-digest|null) "
1256 "(authentication-key|) AUTH_KEY",
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_AUTHTYPE_ALL
1259 VLINK_HELPSTR_AUTH_SIMPLE)
1260
paula2c62832003-04-23 17:01:31 +00001261ALIAS (ospf_area_vlink,
1262 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001263 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1264 "(authentication|) "
1265 "(authentication-key|) AUTH_KEY",
1266 VLINK_HELPSTR_IPADDR
1267 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1268 VLINK_HELPSTR_AUTH_SIMPLE)
1269
paula2c62832003-04-23 17:01:31 +00001270ALIAS (no_ospf_area_vlink,
1271 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001272 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1273 "(authentication|) "
1274 "(authentication-key|)",
1275 NO_STR
1276 VLINK_HELPSTR_IPADDR
1277 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1278 VLINK_HELPSTR_AUTH_SIMPLE)
1279
paula2c62832003-04-23 17:01:31 +00001280ALIAS (ospf_area_vlink,
1281 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001282 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1283 "(authentication|) (message-digest|null) "
1284 "(message-digest-key|) <1-255> md5 KEY",
1285 VLINK_HELPSTR_IPADDR
1286 VLINK_HELPSTR_AUTHTYPE_ALL
1287 VLINK_HELPSTR_AUTH_MD5)
1288
paula2c62832003-04-23 17:01:31 +00001289ALIAS (ospf_area_vlink,
1290 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001291 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1292 "(authentication|) "
1293 "(message-digest-key|) <1-255> md5 KEY",
1294 VLINK_HELPSTR_IPADDR
1295 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1296 VLINK_HELPSTR_AUTH_MD5)
1297
paula2c62832003-04-23 17:01:31 +00001298ALIAS (no_ospf_area_vlink,
1299 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001300 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1301 "(authentication|) "
1302 "(message-digest-key|)",
1303 NO_STR
1304 VLINK_HELPSTR_IPADDR
1305 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1306 VLINK_HELPSTR_AUTH_MD5)
1307
1308
paula2c62832003-04-23 17:01:31 +00001309DEFUN (ospf_area_shortcut,
1310 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001311 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1312 "OSPF area parameters\n"
1313 "OSPF area ID in IP address format\n"
1314 "OSPF area ID as a decimal value\n"
1315 "Configure the area's shortcutting mode\n"
1316 "Set default shortcutting behavior\n"
1317 "Enable shortcutting through the area\n"
1318 "Disable shortcutting through the area\n")
1319{
paul68980082003-03-25 05:07:42 +00001320 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001321 struct ospf_area *area;
1322 struct in_addr area_id;
1323 int mode;
1324 int format;
1325
1326 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1327
paul68980082003-03-25 05:07:42 +00001328 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001329
1330 if (strncmp (argv[1], "de", 2) == 0)
1331 mode = OSPF_SHORTCUT_DEFAULT;
1332 else if (strncmp (argv[1], "di", 2) == 0)
1333 mode = OSPF_SHORTCUT_DISABLE;
1334 else if (strncmp (argv[1], "e", 1) == 0)
1335 mode = OSPF_SHORTCUT_ENABLE;
1336 else
1337 return CMD_WARNING;
1338
paul68980082003-03-25 05:07:42 +00001339 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001340
paul68980082003-03-25 05:07:42 +00001341 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001342 vty_out (vty, "Shortcut area setting will take effect "
1343 "only when the router is configured as Shortcut ABR%s",
1344 VTY_NEWLINE);
1345
1346 return CMD_SUCCESS;
1347}
1348
paula2c62832003-04-23 17:01:31 +00001349DEFUN (no_ospf_area_shortcut,
1350 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001351 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1352 NO_STR
1353 "OSPF area parameters\n"
1354 "OSPF area ID in IP address format\n"
1355 "OSPF area ID as a decimal value\n"
1356 "Deconfigure the area's shortcutting mode\n"
1357 "Deconfigure enabled shortcutting through the area\n"
1358 "Deconfigure disabled shortcutting through the area\n")
1359{
paul68980082003-03-25 05:07:42 +00001360 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001361 struct ospf_area *area;
1362 struct in_addr area_id;
1363 int format;
1364
1365 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1366
paul68980082003-03-25 05:07:42 +00001367 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001368 if (!area)
1369 return CMD_SUCCESS;
1370
paul68980082003-03-25 05:07:42 +00001371 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001372
1373 return CMD_SUCCESS;
1374}
1375
1376
paula2c62832003-04-23 17:01:31 +00001377DEFUN (ospf_area_stub,
1378 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001379 "area (A.B.C.D|<0-4294967295>) stub",
1380 "OSPF area parameters\n"
1381 "OSPF area ID in IP address format\n"
1382 "OSPF area ID as a decimal value\n"
1383 "Configure OSPF area as stub\n")
1384{
1385 struct ospf *ospf = vty->index;
1386 struct in_addr area_id;
1387 int ret, format;
1388
1389 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1390
1391 ret = ospf_area_stub_set (ospf, area_id);
1392 if (ret == 0)
1393 {
1394 vty_out (vty, "First deconfigure all virtual link through this area%s",
1395 VTY_NEWLINE);
1396 return CMD_WARNING;
1397 }
1398
1399 ospf_area_no_summary_unset (ospf, area_id);
1400
1401 return CMD_SUCCESS;
1402}
1403
paula2c62832003-04-23 17:01:31 +00001404DEFUN (ospf_area_stub_no_summary,
1405 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001406 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1407 "OSPF stub parameters\n"
1408 "OSPF area ID in IP address format\n"
1409 "OSPF area ID as a decimal value\n"
1410 "Configure OSPF area as stub\n"
1411 "Do not inject inter-area routes into stub\n")
1412{
1413 struct ospf *ospf = vty->index;
1414 struct in_addr area_id;
1415 int ret, format;
1416
1417 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1418
1419 ret = ospf_area_stub_set (ospf, area_id);
1420 if (ret == 0)
1421 {
paulb0a053b2003-06-22 09:04:47 +00001422 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001423 VTY_NEWLINE);
1424 return CMD_WARNING;
1425 }
1426
1427 ospf_area_no_summary_set (ospf, area_id);
1428
1429 return CMD_SUCCESS;
1430}
1431
paula2c62832003-04-23 17:01:31 +00001432DEFUN (no_ospf_area_stub,
1433 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001434 "no area (A.B.C.D|<0-4294967295>) stub",
1435 NO_STR
1436 "OSPF area parameters\n"
1437 "OSPF area ID in IP address format\n"
1438 "OSPF area ID as a decimal value\n"
1439 "Configure OSPF area as stub\n")
1440{
1441 struct ospf *ospf = vty->index;
1442 struct in_addr area_id;
1443 int format;
1444
1445 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1446
1447 ospf_area_stub_unset (ospf, area_id);
1448 ospf_area_no_summary_unset (ospf, area_id);
1449
1450 return CMD_SUCCESS;
1451}
1452
paula2c62832003-04-23 17:01:31 +00001453DEFUN (no_ospf_area_stub_no_summary,
1454 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001455 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1456 NO_STR
1457 "OSPF area parameters\n"
1458 "OSPF area ID in IP address format\n"
1459 "OSPF area ID as a decimal value\n"
1460 "Configure OSPF area as stub\n"
1461 "Do not inject inter-area routes into area\n")
1462{
1463 struct ospf *ospf = vty->index;
1464 struct in_addr area_id;
1465 int format;
1466
1467 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1468 ospf_area_no_summary_unset (ospf, area_id);
1469
1470 return CMD_SUCCESS;
1471}
1472
paulb0a053b2003-06-22 09:04:47 +00001473int
paul6c835672004-10-11 11:00:30 +00001474ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1475 int nosum)
paul718e3742002-12-13 20:15:29 +00001476{
1477 struct ospf *ospf = vty->index;
1478 struct in_addr area_id;
1479 int ret, format;
1480
1481 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1482
1483 ret = ospf_area_nssa_set (ospf, area_id);
1484 if (ret == 0)
1485 {
1486 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1487 VTY_NEWLINE);
1488 return CMD_WARNING;
1489 }
1490
1491 if (argc > 1)
1492 {
1493 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001494 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001495 OSPF_NSSA_ROLE_CANDIDATE);
1496 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001497 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001498 OSPF_NSSA_ROLE_NEVER);
1499 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001500 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001501 OSPF_NSSA_ROLE_ALWAYS);
1502 }
paulb0a053b2003-06-22 09:04:47 +00001503 else
1504 {
1505 ospf_area_nssa_translator_role_set (ospf, area_id,
1506 OSPF_NSSA_ROLE_CANDIDATE);
1507 }
paul718e3742002-12-13 20:15:29 +00001508
paulb0a053b2003-06-22 09:04:47 +00001509 if (nosum)
paul718e3742002-12-13 20:15:29 +00001510 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001511 else
1512 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001513
paulb0a053b2003-06-22 09:04:47 +00001514 ospf_schedule_abr_task (ospf);
1515
paul718e3742002-12-13 20:15:29 +00001516 return CMD_SUCCESS;
1517}
1518
paulb0a053b2003-06-22 09:04:47 +00001519DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001520 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001521 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001522 "OSPF area parameters\n"
1523 "OSPF area ID in IP address format\n"
1524 "OSPF area ID as a decimal value\n"
1525 "Configure OSPF area as nssa\n"
1526 "Configure NSSA-ABR for translate election (default)\n"
1527 "Configure NSSA-ABR to never translate\n"
1528 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001529 "Do not inject inter-area routes into nssa\n")
1530{
1531 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1532}
paul718e3742002-12-13 20:15:29 +00001533
paulb0a053b2003-06-22 09:04:47 +00001534DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001535 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001536 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1537 "OSPF area parameters\n"
1538 "OSPF area ID in IP address format\n"
1539 "OSPF area ID as a decimal value\n"
1540 "Configure OSPF area as nssa\n"
1541 "Configure NSSA-ABR for translate election (default)\n"
1542 "Configure NSSA-ABR to never translate\n"
1543 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001544{
1545 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1546}
1547
1548DEFUN (ospf_area_nssa,
1549 ospf_area_nssa_cmd,
1550 "area (A.B.C.D|<0-4294967295>) nssa",
1551 "OSPF area parameters\n"
1552 "OSPF area ID in IP address format\n"
1553 "OSPF area ID as a decimal value\n"
1554 "Configure OSPF area as nssa\n")
1555{
1556 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1557}
paul718e3742002-12-13 20:15:29 +00001558
paula2c62832003-04-23 17:01:31 +00001559DEFUN (ospf_area_nssa_no_summary,
1560 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001561 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1562 "OSPF area parameters\n"
1563 "OSPF area ID in IP address format\n"
1564 "OSPF area ID as a decimal value\n"
1565 "Configure OSPF area as nssa\n"
1566 "Do not inject inter-area routes into nssa\n")
1567{
paulb0a053b2003-06-22 09:04:47 +00001568 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001569}
1570
paula2c62832003-04-23 17:01:31 +00001571DEFUN (no_ospf_area_nssa,
1572 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001573 "no area (A.B.C.D|<0-4294967295>) nssa",
1574 NO_STR
1575 "OSPF area parameters\n"
1576 "OSPF area ID in IP address format\n"
1577 "OSPF area ID as a decimal value\n"
1578 "Configure OSPF area as nssa\n")
1579{
1580 struct ospf *ospf = vty->index;
1581 struct in_addr area_id;
1582 int format;
1583
1584 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1585
1586 ospf_area_nssa_unset (ospf, area_id);
1587 ospf_area_no_summary_unset (ospf, area_id);
1588
paulb0a053b2003-06-22 09:04:47 +00001589 ospf_schedule_abr_task (ospf);
1590
paul718e3742002-12-13 20:15:29 +00001591 return CMD_SUCCESS;
1592}
1593
paula2c62832003-04-23 17:01:31 +00001594DEFUN (no_ospf_area_nssa_no_summary,
1595 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001596 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1597 NO_STR
1598 "OSPF area parameters\n"
1599 "OSPF area ID in IP address format\n"
1600 "OSPF area ID as a decimal value\n"
1601 "Configure OSPF area as nssa\n"
1602 "Do not inject inter-area routes into nssa\n")
1603{
1604 struct ospf *ospf = vty->index;
1605 struct in_addr area_id;
1606 int format;
1607
1608 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1609 ospf_area_no_summary_unset (ospf, area_id);
1610
1611 return CMD_SUCCESS;
1612}
1613
paula2c62832003-04-23 17:01:31 +00001614DEFUN (ospf_area_default_cost,
1615 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001616 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1617 "OSPF area parameters\n"
1618 "OSPF area ID in IP address format\n"
1619 "OSPF area ID as a decimal value\n"
1620 "Set the summary-default cost of a NSSA or stub area\n"
1621 "Stub's advertised default summary cost\n")
1622{
paul68980082003-03-25 05:07:42 +00001623 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001624 struct ospf_area *area;
1625 struct in_addr area_id;
1626 u_int32_t cost;
1627 int format;
1628
1629 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1630 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1631
paul68980082003-03-25 05:07:42 +00001632 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001633
1634 if (area->external_routing == OSPF_AREA_DEFAULT)
1635 {
1636 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1637 return CMD_WARNING;
1638 }
1639
1640 area->default_cost = cost;
1641
1642 return CMD_SUCCESS;
1643}
1644
paula2c62832003-04-23 17:01:31 +00001645DEFUN (no_ospf_area_default_cost,
1646 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001647 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1648 NO_STR
1649 "OSPF area parameters\n"
1650 "OSPF area ID in IP address format\n"
1651 "OSPF area ID as a decimal value\n"
1652 "Set the summary-default cost of a NSSA or stub area\n"
1653 "Stub's advertised default summary cost\n")
1654{
paul68980082003-03-25 05:07:42 +00001655 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001656 struct ospf_area *area;
1657 struct in_addr area_id;
1658 u_int32_t cost;
1659 int format;
1660
1661 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1662 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1663
paul68980082003-03-25 05:07:42 +00001664 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001665 if (area == NULL)
1666 return CMD_SUCCESS;
1667
1668 if (area->external_routing == OSPF_AREA_DEFAULT)
1669 {
1670 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1671 return CMD_WARNING;
1672 }
1673
1674 area->default_cost = 1;
1675
paul68980082003-03-25 05:07:42 +00001676 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001677
1678 return CMD_SUCCESS;
1679}
1680
paula2c62832003-04-23 17:01:31 +00001681DEFUN (ospf_area_export_list,
1682 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001683 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1684 "OSPF area parameters\n"
1685 "OSPF area ID in IP address format\n"
1686 "OSPF area ID as a decimal value\n"
1687 "Set the filter for networks announced to other areas\n"
1688 "Name of the access-list\n")
1689{
paul68980082003-03-25 05:07:42 +00001690 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001691 struct ospf_area *area;
1692 struct in_addr area_id;
1693 int format;
1694
hasso52930762004-04-19 18:26:53 +00001695 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1696
paul68980082003-03-25 05:07:42 +00001697 area = ospf_area_get (ospf, area_id, format);
1698 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001699
1700 return CMD_SUCCESS;
1701}
1702
paula2c62832003-04-23 17:01:31 +00001703DEFUN (no_ospf_area_export_list,
1704 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001705 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1706 NO_STR
1707 "OSPF area parameters\n"
1708 "OSPF area ID in IP address format\n"
1709 "OSPF area ID as a decimal value\n"
1710 "Unset the filter for networks announced to other areas\n"
1711 "Name of the access-list\n")
1712{
paul68980082003-03-25 05:07:42 +00001713 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001714 struct ospf_area *area;
1715 struct in_addr area_id;
1716 int format;
1717
hasso52930762004-04-19 18:26:53 +00001718 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1719
paul68980082003-03-25 05:07:42 +00001720 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001721 if (area == NULL)
1722 return CMD_SUCCESS;
1723
paul68980082003-03-25 05:07:42 +00001724 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001725
1726 return CMD_SUCCESS;
1727}
1728
1729
paula2c62832003-04-23 17:01:31 +00001730DEFUN (ospf_area_import_list,
1731 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001732 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1733 "OSPF area parameters\n"
1734 "OSPF area ID in IP address format\n"
1735 "OSPF area ID as a decimal value\n"
1736 "Set the filter for networks from other areas announced to the specified one\n"
1737 "Name of the access-list\n")
1738{
paul68980082003-03-25 05:07:42 +00001739 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001740 struct ospf_area *area;
1741 struct in_addr area_id;
1742 int format;
1743
hasso52930762004-04-19 18:26:53 +00001744 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1745
paul68980082003-03-25 05:07:42 +00001746 area = ospf_area_get (ospf, area_id, format);
1747 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001748
1749 return CMD_SUCCESS;
1750}
1751
paula2c62832003-04-23 17:01:31 +00001752DEFUN (no_ospf_area_import_list,
1753 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001754 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1755 NO_STR
1756 "OSPF area parameters\n"
1757 "OSPF area ID in IP address format\n"
1758 "OSPF area ID as a decimal value\n"
1759 "Unset the filter for networks announced to other areas\n"
1760 "Name of the access-list\n")
1761{
paul68980082003-03-25 05:07:42 +00001762 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001763 struct ospf_area *area;
1764 struct in_addr area_id;
1765 int format;
1766
hasso52930762004-04-19 18:26:53 +00001767 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1768
paul68980082003-03-25 05:07:42 +00001769 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001770 if (area == NULL)
1771 return CMD_SUCCESS;
1772
paul68980082003-03-25 05:07:42 +00001773 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001774
1775 return CMD_SUCCESS;
1776}
1777
paula2c62832003-04-23 17:01:31 +00001778DEFUN (ospf_area_filter_list,
1779 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001780 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1781 "OSPF area parameters\n"
1782 "OSPF area ID in IP address format\n"
1783 "OSPF area ID as a decimal value\n"
1784 "Filter networks between OSPF areas\n"
1785 "Filter prefixes between OSPF areas\n"
1786 "Name of an IP prefix-list\n"
1787 "Filter networks sent to this area\n"
1788 "Filter networks sent from this area\n")
1789{
paul68980082003-03-25 05:07:42 +00001790 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001791 struct ospf_area *area;
1792 struct in_addr area_id;
1793 struct prefix_list *plist;
1794 int format;
1795
1796 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1797
paul68980082003-03-25 05:07:42 +00001798 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001799 plist = prefix_list_lookup (AFI_IP, argv[1]);
1800 if (strncmp (argv[2], "in", 2) == 0)
1801 {
1802 PREFIX_LIST_IN (area) = plist;
1803 if (PREFIX_NAME_IN (area))
1804 free (PREFIX_NAME_IN (area));
1805
1806 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001807 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001808 }
1809 else
1810 {
1811 PREFIX_LIST_OUT (area) = plist;
1812 if (PREFIX_NAME_OUT (area))
1813 free (PREFIX_NAME_OUT (area));
1814
1815 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001816 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001817 }
1818
1819 return CMD_SUCCESS;
1820}
1821
paula2c62832003-04-23 17:01:31 +00001822DEFUN (no_ospf_area_filter_list,
1823 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001824 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1825 NO_STR
1826 "OSPF area parameters\n"
1827 "OSPF area ID in IP address format\n"
1828 "OSPF area ID as a decimal value\n"
1829 "Filter networks between OSPF areas\n"
1830 "Filter prefixes between OSPF areas\n"
1831 "Name of an IP prefix-list\n"
1832 "Filter networks sent to this area\n"
1833 "Filter networks sent from this area\n")
1834{
paul68980082003-03-25 05:07:42 +00001835 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001836 struct ospf_area *area;
1837 struct in_addr area_id;
1838 struct prefix_list *plist;
1839 int format;
1840
1841 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1842
paul68980082003-03-25 05:07:42 +00001843 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001844 plist = prefix_list_lookup (AFI_IP, argv[1]);
1845 if (strncmp (argv[2], "in", 2) == 0)
1846 {
1847 if (PREFIX_NAME_IN (area))
1848 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1849 return CMD_SUCCESS;
1850
1851 PREFIX_LIST_IN (area) = NULL;
1852 if (PREFIX_NAME_IN (area))
1853 free (PREFIX_NAME_IN (area));
1854
1855 PREFIX_NAME_IN (area) = NULL;
1856
paul68980082003-03-25 05:07:42 +00001857 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001858 }
1859 else
1860 {
1861 if (PREFIX_NAME_OUT (area))
1862 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1863 return CMD_SUCCESS;
1864
1865 PREFIX_LIST_OUT (area) = NULL;
1866 if (PREFIX_NAME_OUT (area))
1867 free (PREFIX_NAME_OUT (area));
1868
1869 PREFIX_NAME_OUT (area) = NULL;
1870
paul68980082003-03-25 05:07:42 +00001871 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001872 }
1873
1874 return CMD_SUCCESS;
1875}
1876
1877
paula2c62832003-04-23 17:01:31 +00001878DEFUN (ospf_area_authentication_message_digest,
1879 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001880 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1881 "OSPF area parameters\n"
1882 "Enable authentication\n"
1883 "Use message-digest authentication\n")
1884{
paul68980082003-03-25 05:07:42 +00001885 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001886 struct ospf_area *area;
1887 struct in_addr area_id;
1888 int format;
1889
1890 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1891
paul68980082003-03-25 05:07:42 +00001892 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001893 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1894
1895 return CMD_SUCCESS;
1896}
1897
paula2c62832003-04-23 17:01:31 +00001898DEFUN (ospf_area_authentication,
1899 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001900 "area (A.B.C.D|<0-4294967295>) authentication",
1901 "OSPF area parameters\n"
1902 "OSPF area ID in IP address format\n"
1903 "OSPF area ID as a decimal value\n"
1904 "Enable authentication\n")
1905{
paul68980082003-03-25 05:07:42 +00001906 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001907 struct ospf_area *area;
1908 struct in_addr area_id;
1909 int format;
1910
1911 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1912
paul68980082003-03-25 05:07:42 +00001913 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001914 area->auth_type = OSPF_AUTH_SIMPLE;
1915
1916 return CMD_SUCCESS;
1917}
1918
paula2c62832003-04-23 17:01:31 +00001919DEFUN (no_ospf_area_authentication,
1920 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001921 "no area (A.B.C.D|<0-4294967295>) authentication",
1922 NO_STR
1923 "OSPF area parameters\n"
1924 "OSPF area ID in IP address format\n"
1925 "OSPF area ID as a decimal value\n"
1926 "Enable authentication\n")
1927{
paul68980082003-03-25 05:07:42 +00001928 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001929 struct ospf_area *area;
1930 struct in_addr area_id;
1931 int format;
1932
1933 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1934
paul68980082003-03-25 05:07:42 +00001935 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001936 if (area == NULL)
1937 return CMD_SUCCESS;
1938
1939 area->auth_type = OSPF_AUTH_NULL;
1940
paul68980082003-03-25 05:07:42 +00001941 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001942
1943 return CMD_SUCCESS;
1944}
1945
1946
1947DEFUN (ospf_abr_type,
1948 ospf_abr_type_cmd,
1949 "ospf abr-type (cisco|ibm|shortcut|standard)",
1950 "OSPF specific commands\n"
1951 "Set OSPF ABR type\n"
1952 "Alternative ABR, cisco implementation\n"
1953 "Alternative ABR, IBM implementation\n"
1954 "Shortcut ABR\n"
1955 "Standard behavior (RFC2328)\n")
1956{
paul68980082003-03-25 05:07:42 +00001957 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001958 u_char abr_type = OSPF_ABR_UNKNOWN;
1959
1960 if (strncmp (argv[0], "c", 1) == 0)
1961 abr_type = OSPF_ABR_CISCO;
1962 else if (strncmp (argv[0], "i", 1) == 0)
1963 abr_type = OSPF_ABR_IBM;
1964 else if (strncmp (argv[0], "sh", 2) == 0)
1965 abr_type = OSPF_ABR_SHORTCUT;
1966 else if (strncmp (argv[0], "st", 2) == 0)
1967 abr_type = OSPF_ABR_STAND;
1968 else
1969 return CMD_WARNING;
1970
1971 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00001972 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00001973 {
paul68980082003-03-25 05:07:42 +00001974 ospf->abr_type = abr_type;
1975 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001976 }
1977
1978 return CMD_SUCCESS;
1979}
1980
1981DEFUN (no_ospf_abr_type,
1982 no_ospf_abr_type_cmd,
1983 "no ospf abr-type (cisco|ibm|shortcut)",
1984 NO_STR
1985 "OSPF specific commands\n"
1986 "Set OSPF ABR type\n"
1987 "Alternative ABR, cisco implementation\n"
1988 "Alternative ABR, IBM implementation\n"
1989 "Shortcut ABR\n")
1990{
paul68980082003-03-25 05:07:42 +00001991 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001992 u_char abr_type = OSPF_ABR_UNKNOWN;
1993
1994 if (strncmp (argv[0], "c", 1) == 0)
1995 abr_type = OSPF_ABR_CISCO;
1996 else if (strncmp (argv[0], "i", 1) == 0)
1997 abr_type = OSPF_ABR_IBM;
1998 else if (strncmp (argv[0], "s", 1) == 0)
1999 abr_type = OSPF_ABR_SHORTCUT;
2000 else
2001 return CMD_WARNING;
2002
2003 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002004 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002005 {
paul68980082003-03-25 05:07:42 +00002006 ospf->abr_type = OSPF_ABR_STAND;
2007 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002008 }
2009
2010 return CMD_SUCCESS;
2011}
2012
2013DEFUN (ospf_compatible_rfc1583,
2014 ospf_compatible_rfc1583_cmd,
2015 "compatible rfc1583",
2016 "OSPF compatibility list\n"
2017 "compatible with RFC 1583\n")
2018{
2019 struct ospf *ospf = vty->index;
2020
2021 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2022 {
2023 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002024 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002025 }
2026 return CMD_SUCCESS;
2027}
2028
2029DEFUN (no_ospf_compatible_rfc1583,
2030 no_ospf_compatible_rfc1583_cmd,
2031 "no compatible rfc1583",
2032 NO_STR
2033 "OSPF compatibility list\n"
2034 "compatible with RFC 1583\n")
2035{
2036 struct ospf *ospf = vty->index;
2037
2038 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2039 {
2040 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002041 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002042 }
2043 return CMD_SUCCESS;
2044}
2045
2046ALIAS (ospf_compatible_rfc1583,
2047 ospf_rfc1583_flag_cmd,
2048 "ospf rfc1583compatibility",
2049 "OSPF specific commands\n"
2050 "Enable the RFC1583Compatibility flag\n")
2051
2052ALIAS (no_ospf_compatible_rfc1583,
2053 no_ospf_rfc1583_flag_cmd,
2054 "no ospf rfc1583compatibility",
2055 NO_STR
2056 "OSPF specific commands\n"
2057 "Disable the RFC1583Compatibility flag\n")
2058
paula2c62832003-04-23 17:01:31 +00002059DEFUN (ospf_timers_spf,
2060 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002061 "timers spf <0-4294967295> <0-4294967295>",
2062 "Adjust routing timers\n"
2063 "OSPF SPF timers\n"
2064 "Delay between receiving a change to SPF calculation\n"
2065 "Hold time between consecutive SPF calculations\n")
2066{
2067 struct ospf *ospf = vty->index;
2068 u_int32_t delay, hold;
2069
2070 VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]);
2071 VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]);
2072
2073 ospf_timers_spf_set (ospf, delay, hold);
2074
2075 return CMD_SUCCESS;
2076}
2077
paula2c62832003-04-23 17:01:31 +00002078DEFUN (no_ospf_timers_spf,
2079 no_ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002080 "no timers spf",
2081 NO_STR
2082 "Adjust routing timers\n"
2083 "OSPF SPF timers\n")
2084{
paul68980082003-03-25 05:07:42 +00002085 struct ospf *ospf = vty->index;
2086
2087 ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT;
2088 ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002089
2090 return CMD_SUCCESS;
2091}
2092
2093
paula2c62832003-04-23 17:01:31 +00002094DEFUN (ospf_neighbor,
2095 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002096 "neighbor A.B.C.D",
2097 NEIGHBOR_STR
2098 "Neighbor IP address\n")
2099{
2100 struct ospf *ospf = vty->index;
2101 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002102 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2103 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002104
2105 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2106
2107 if (argc > 1)
2108 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2109
2110 if (argc > 2)
2111 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2112
2113 ospf_nbr_nbma_set (ospf, nbr_addr);
2114 if (argc > 1)
2115 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2116 if (argc > 2)
2117 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2118
2119 return CMD_SUCCESS;
2120}
2121
paula2c62832003-04-23 17:01:31 +00002122ALIAS (ospf_neighbor,
2123 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002124 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2125 NEIGHBOR_STR
2126 "Neighbor IP address\n"
2127 "Neighbor Priority\n"
2128 "Priority\n"
2129 "Dead Neighbor Polling interval\n"
2130 "Seconds\n")
2131
paula2c62832003-04-23 17:01:31 +00002132ALIAS (ospf_neighbor,
2133 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002134 "neighbor A.B.C.D priority <0-255>",
2135 NEIGHBOR_STR
2136 "Neighbor IP address\n"
2137 "Neighbor Priority\n"
2138 "Seconds\n")
2139
paula2c62832003-04-23 17:01:31 +00002140DEFUN (ospf_neighbor_poll_interval,
2141 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002142 "neighbor A.B.C.D poll-interval <1-65535>",
2143 NEIGHBOR_STR
2144 "Neighbor IP address\n"
2145 "Dead Neighbor Polling interval\n"
2146 "Seconds\n")
2147{
2148 struct ospf *ospf = vty->index;
2149 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002150 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2151 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002152
2153 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2154
2155 if (argc > 1)
2156 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2157
2158 if (argc > 2)
2159 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2160
2161 ospf_nbr_nbma_set (ospf, nbr_addr);
2162 if (argc > 1)
2163 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2164 if (argc > 2)
2165 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2166
2167 return CMD_SUCCESS;
2168}
2169
paula2c62832003-04-23 17:01:31 +00002170ALIAS (ospf_neighbor_poll_interval,
2171 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002172 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2173 NEIGHBOR_STR
2174 "Neighbor address\n"
2175 "OSPF dead-router polling interval\n"
2176 "Seconds\n"
2177 "OSPF priority of non-broadcast neighbor\n"
2178 "Priority\n")
2179
paula2c62832003-04-23 17:01:31 +00002180DEFUN (no_ospf_neighbor,
2181 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002182 "no neighbor A.B.C.D",
2183 NO_STR
2184 NEIGHBOR_STR
2185 "Neighbor IP address\n")
2186{
2187 struct ospf *ospf = vty->index;
2188 struct in_addr nbr_addr;
2189 int ret;
2190
2191 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2192
2193 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2194
2195 return CMD_SUCCESS;
2196}
2197
paula2c62832003-04-23 17:01:31 +00002198ALIAS (no_ospf_neighbor,
2199 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002200 "no neighbor A.B.C.D priority <0-255>",
2201 NO_STR
2202 NEIGHBOR_STR
2203 "Neighbor IP address\n"
2204 "Neighbor Priority\n"
2205 "Priority\n")
2206
paula2c62832003-04-23 17:01:31 +00002207ALIAS (no_ospf_neighbor,
2208 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002209 "no neighbor A.B.C.D poll-interval <1-65535>",
2210 NO_STR
2211 NEIGHBOR_STR
2212 "Neighbor IP address\n"
2213 "Dead Neighbor Polling interval\n"
2214 "Seconds\n")
2215
paula2c62832003-04-23 17:01:31 +00002216ALIAS (no_ospf_neighbor,
2217 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002218 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2219 NO_STR
2220 NEIGHBOR_STR
2221 "Neighbor IP address\n"
2222 "Neighbor Priority\n"
2223 "Priority\n"
2224 "Dead Neighbor Polling interval\n"
2225 "Seconds\n")
2226
2227
paula2c62832003-04-23 17:01:31 +00002228DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002229 "refresh timer <10-1800>",
2230 "Adjust refresh parameters\n"
2231 "Set refresh timer\n"
2232 "Timer value in seconds\n")
2233{
2234 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002235 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002236
2237 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2238 interval = (interval / 10) * 10;
2239
2240 ospf_timers_refresh_set (ospf, interval);
2241
2242 return CMD_SUCCESS;
2243}
2244
paula2c62832003-04-23 17:01:31 +00002245DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002246 "no refresh timer <10-1800>",
2247 "Adjust refresh parameters\n"
2248 "Unset refresh timer\n"
2249 "Timer value in seconds\n")
2250{
2251 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002252 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002253
2254 if (argc == 1)
2255 {
2256 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2257
2258 if (ospf->lsa_refresh_interval != interval ||
2259 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2260 return CMD_SUCCESS;
2261 }
2262
2263 ospf_timers_refresh_unset (ospf);
2264
2265 return CMD_SUCCESS;
2266}
2267
paula2c62832003-04-23 17:01:31 +00002268ALIAS (no_ospf_refresh_timer,
2269 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002270 "no refresh timer",
2271 "Adjust refresh parameters\n"
2272 "Unset refresh timer\n")
2273
paula2c62832003-04-23 17:01:31 +00002274DEFUN (ospf_auto_cost_reference_bandwidth,
2275 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002276 "auto-cost reference-bandwidth <1-4294967>",
2277 "Calculate OSPF interface cost according to bandwidth\n"
2278 "Use reference bandwidth method to assign OSPF cost\n"
2279 "The reference bandwidth in terms of Mbits per second\n")
2280{
paul68980082003-03-25 05:07:42 +00002281 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002282 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002283 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002284
2285 refbw = strtol (argv[0], NULL, 10);
2286 if (refbw < 1 || refbw > 4294967)
2287 {
2288 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2289 return CMD_WARNING;
2290 }
2291
2292 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002293 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002294 return CMD_SUCCESS;
2295
paul68980082003-03-25 05:07:42 +00002296 ospf->ref_bandwidth = refbw * 1000;
paul718e3742002-12-13 20:15:29 +00002297 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2298 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2299
paul020709f2003-04-04 02:44:16 +00002300 for (node = listhead (om->iflist); node; nextnode (node))
2301 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002302
2303 return CMD_SUCCESS;
2304}
2305
paula2c62832003-04-23 17:01:31 +00002306DEFUN (no_ospf_auto_cost_reference_bandwidth,
2307 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002308 "no auto-cost reference-bandwidth",
2309 NO_STR
2310 "Calculate OSPF interface cost according to bandwidth\n"
2311 "Use reference bandwidth method to assign OSPF cost\n")
2312{
paul68980082003-03-25 05:07:42 +00002313 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002314 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002315
paul68980082003-03-25 05:07:42 +00002316 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002317 return CMD_SUCCESS;
2318
paul68980082003-03-25 05:07:42 +00002319 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002320 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2321 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2322
paul020709f2003-04-04 02:44:16 +00002323 for (node = listhead (om->iflist); node; nextnode (node))
2324 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002325
2326 return CMD_SUCCESS;
2327}
2328
hassoeb1ce602004-10-08 08:17:22 +00002329const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002330{
2331 "Unknown",
2332 "Standard (RFC2328)",
2333 "Alternative IBM",
2334 "Alternative Cisco",
2335 "Alternative Shortcut"
2336};
2337
hassoeb1ce602004-10-08 08:17:22 +00002338const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002339{
2340 "Default",
2341 "Enabled",
2342 "Disabled"
2343};
2344
2345
2346
2347void
2348show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2349{
2350 /* Show Area ID. */
2351 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2352
2353 /* Show Area type/mode. */
2354 if (OSPF_IS_AREA_BACKBONE (area))
2355 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2356 else
2357 {
2358 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002359 vty_out (vty, " (Stub%s%s)",
2360 area->no_summary ? ", no summary" : "",
2361 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002362
paulb0a053b2003-06-22 09:04:47 +00002363 else if (area->external_routing == OSPF_AREA_NSSA)
2364 vty_out (vty, " (NSSA%s%s)",
2365 area->no_summary ? ", no summary" : "",
2366 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002367
2368 vty_out (vty, "%s", VTY_NEWLINE);
2369 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002370 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002371 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002372 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002373 }
2374
2375 /* Show number of interfaces. */
2376 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2377 "Active: %d%s", listcount (area->oiflist),
2378 area->act_ints, VTY_NEWLINE);
2379
paul718e3742002-12-13 20:15:29 +00002380 if (area->external_routing == OSPF_AREA_NSSA)
2381 {
2382 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 +00002383 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002384 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2385 VTY_NEWLINE);
2386 else if (area->NSSATranslatorState)
2387 {
2388 vty_out (vty, " We are an ABR and ");
2389 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2390 vty_out (vty, "the NSSA Elected Translator. %s",
2391 VTY_NEWLINE);
2392 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2393 vty_out (vty, "always an NSSA Translator. %s",
2394 VTY_NEWLINE);
2395 }
paul718e3742002-12-13 20:15:29 +00002396 else
paulb0a053b2003-06-22 09:04:47 +00002397 {
2398 vty_out (vty, " We are an ABR, but ");
2399 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2400 vty_out (vty, "not the NSSA Elected Translator. %s",
2401 VTY_NEWLINE);
2402 else
2403 vty_out (vty, "not the NSSA Elected Translator. %s",
2404 VTY_NEWLINE);
2405 }
paul718e3742002-12-13 20:15:29 +00002406 }
paul718e3742002-12-13 20:15:29 +00002407
2408 /* Show number of fully adjacent neighbors. */
2409 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002410 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002411
2412 /* Show authentication type. */
2413 vty_out (vty, " Area has ");
2414 if (area->auth_type == OSPF_AUTH_NULL)
2415 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2416 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2417 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2418 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2419 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2420
2421 if (!OSPF_IS_AREA_BACKBONE (area))
2422 vty_out (vty, " Number of full virtual adjacencies going through"
2423 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2424
2425 /* Show SPF calculation times. */
2426 vty_out (vty, " SPF algorithm executed %d times%s",
2427 area->spf_calculation, VTY_NEWLINE);
2428
2429 /* Show number of LSA. */
2430 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
2431
2432 vty_out (vty, "%s", VTY_NEWLINE);
2433}
2434
2435DEFUN (show_ip_ospf,
2436 show_ip_ospf_cmd,
2437 "show ip ospf",
2438 SHOW_STR
2439 IP_STR
2440 "OSPF information\n")
2441{
hasso52dc7ee2004-09-23 19:18:23 +00002442 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002443 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002444 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002445
2446 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002447 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002448 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002449 {
2450 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2451 return CMD_SUCCESS;
2452 }
2453
2454 /* Show Router ID. */
2455 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002456 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002457 VTY_NEWLINE);
2458
2459 /* Show capability. */
2460 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2461 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2462 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002463 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002464 "enabled" : "disabled", VTY_NEWLINE);
2465#ifdef HAVE_OPAQUE_LSA
2466 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002467 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002468 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002469 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002470 " (origination blocked)" : "",
2471 VTY_NEWLINE);
2472#endif /* HAVE_OPAQUE_LSA */
2473
2474 /* Show SPF timers. */
2475 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
paul68980082003-03-25 05:07:42 +00002476 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002477
2478 /* Show refresh parameters. */
2479 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002480 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002481
2482 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002483 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002484 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002485 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002486
paul68980082003-03-25 05:07:42 +00002487 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002488 vty_out (vty, " This router is an ASBR "
2489 "(injecting external routing information)%s", VTY_NEWLINE);
2490
2491 /* Show Number of AS-external-LSAs. */
2492 vty_out (vty, " Number of external LSA %ld%s",
paul68980082003-03-25 05:07:42 +00002493 ospf_lsdb_count_all (ospf->lsdb), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002494
2495 /* Show number of areas attached. */
2496 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002497 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002498
2499 /* Show each area status. */
paul68980082003-03-25 05:07:42 +00002500 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002501 if ((area = getdata (node)) != NULL)
2502 show_ip_ospf_area (vty, area);
2503
2504 return CMD_SUCCESS;
2505}
2506
2507
2508void
paul68980082003-03-25 05:07:42 +00002509show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2510 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002511{
2512 struct ospf_neighbor *nbr;
2513 int oi_count;
2514 struct route_node *rn;
2515 char buf[9];
2516
2517 oi_count = ospf_oi_count (ifp);
2518
2519 /* Is interface up? */
paul2e3b2e42002-12-13 21:03:13 +00002520 if (if_is_operative (ifp)) {
2521 vty_out (vty, "%s is up%s", ifp->name, VTY_NEWLINE);
2522 } else
2523 {
2524 vty_out (vty, "%s is down%s", ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002525
2526
2527 if (oi_count == 0)
2528 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2529 else
2530 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2531 VTY_NEWLINE);
2532 return;
2533 }
2534
2535 /* Is interface OSPF enabled? */
2536 if (oi_count == 0)
2537 {
2538 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2539 return;
2540 }
2541
2542 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2543 {
2544 struct ospf_interface *oi = rn->info;
2545
2546 if (oi == NULL)
2547 continue;
2548
2549 /* Show OSPF interface information. */
2550 vty_out (vty, " Internet Address %s/%d,",
2551 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2552
2553 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2554 VTY_NEWLINE);
2555
2556 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002557 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002558 oi->output_cost, VTY_NEWLINE);
2559
2560 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2561 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2562 PRIORITY (oi), VTY_NEWLINE);
2563
2564 /* Show DR information. */
2565 if (DR (oi).s_addr == 0)
2566 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2567 else
2568 {
2569 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2570 if (nbr == NULL)
2571 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2572 else
2573 {
2574 vty_out (vty, " Designated Router (ID) %s,",
2575 inet_ntoa (nbr->router_id));
2576 vty_out (vty, " Interface Address %s%s",
2577 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2578 }
2579 }
2580
2581 /* Show BDR information. */
2582 if (BDR (oi).s_addr == 0)
2583 vty_out (vty, " No backup designated router on this network%s",
2584 VTY_NEWLINE);
2585 else
2586 {
2587 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2588 if (nbr == NULL)
2589 vty_out (vty, " No backup designated router on this network%s",
2590 VTY_NEWLINE);
2591 else
2592 {
2593 vty_out (vty, " Backup Designated Router (ID) %s,",
2594 inet_ntoa (nbr->router_id));
2595 vty_out (vty, " Interface Address %s%s",
2596 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2597 }
2598 }
2599 vty_out (vty, " Timer intervals configured,");
2600 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2601 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2602 OSPF_IF_PARAM (oi, v_wait),
2603 OSPF_IF_PARAM (oi, retransmit_interval),
2604 VTY_NEWLINE);
2605
2606 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2607 vty_out (vty, " Hello due in %s%s",
2608 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2609 else /* OSPF_IF_PASSIVE is set */
2610 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2611
2612 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002613 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002614 VTY_NEWLINE);
2615 }
2616}
2617
2618DEFUN (show_ip_ospf_interface,
2619 show_ip_ospf_interface_cmd,
2620 "show ip ospf interface [INTERFACE]",
2621 SHOW_STR
2622 IP_STR
2623 "OSPF information\n"
2624 "Interface information\n"
2625 "Interface name\n")
2626{
2627 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002628 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002629 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002630
paul020709f2003-04-04 02:44:16 +00002631 ospf = ospf_lookup ();
2632
paul718e3742002-12-13 20:15:29 +00002633 /* Show All Interfaces. */
2634 if (argc == 0)
2635 for (node = listhead (iflist); node; nextnode (node))
paul68980082003-03-25 05:07:42 +00002636 show_ip_ospf_interface_sub (vty, ospf, node->data);
paul718e3742002-12-13 20:15:29 +00002637 /* Interface name is specified. */
2638 else
2639 {
2640 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2641 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2642 else
paul68980082003-03-25 05:07:42 +00002643 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002644 }
2645
2646 return CMD_SUCCESS;
2647}
2648
2649void
2650show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2651{
2652 struct route_node *rn;
2653 struct ospf_neighbor *nbr;
2654 char msgbuf[16];
2655 char timebuf[9];
2656
2657 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2658 if ((nbr = rn->info))
2659 /* Do not show myself. */
2660 if (nbr != oi->nbr_self)
2661 /* Down state is not shown. */
2662 if (nbr->state != NSM_Down)
2663 {
2664 ospf_nbr_state_message (nbr, msgbuf, 16);
2665
2666 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2667 vty_out (vty, "%-15s %3d %-15s %8s ",
2668 "-", nbr->priority,
2669 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2670 else
2671 vty_out (vty, "%-15s %3d %-15s %8s ",
2672 inet_ntoa (nbr->router_id), nbr->priority,
2673 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2674 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2675 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2676 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2677 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2678 VTY_NEWLINE);
2679 }
2680}
2681
2682DEFUN (show_ip_ospf_neighbor,
2683 show_ip_ospf_neighbor_cmd,
2684 "show ip ospf neighbor",
2685 SHOW_STR
2686 IP_STR
2687 "OSPF information\n"
2688 "Neighbor list\n")
2689{
paul020709f2003-04-04 02:44:16 +00002690 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002691 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002692
paul020709f2003-04-04 02:44:16 +00002693 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002694 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002695 {
2696 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2697 return CMD_SUCCESS;
2698 }
2699
2700 /* Show All neighbors. */
2701 vty_out (vty, "%sNeighbor ID Pri State Dead "
2702 "Time Address Interface RXmtL "
2703 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2704
paul68980082003-03-25 05:07:42 +00002705 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul020709f2003-04-04 02:44:16 +00002706 show_ip_ospf_neighbor_sub (vty, getdata (node));
paul718e3742002-12-13 20:15:29 +00002707
2708 return CMD_SUCCESS;
2709}
2710
2711DEFUN (show_ip_ospf_neighbor_all,
2712 show_ip_ospf_neighbor_all_cmd,
2713 "show ip ospf neighbor all",
2714 SHOW_STR
2715 IP_STR
2716 "OSPF information\n"
2717 "Neighbor list\n"
2718 "include down status neighbor\n")
2719{
paul68980082003-03-25 05:07:42 +00002720 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002721 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002722
paul68980082003-03-25 05:07:42 +00002723 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002724 {
2725 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2726 return CMD_SUCCESS;
2727 }
2728
2729 /* Show All neighbors. */
2730 vty_out (vty, "%sNeighbor ID Pri State Dead "
2731 "Time Address Interface RXmtL "
2732 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2733
paul68980082003-03-25 05:07:42 +00002734 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002735 {
2736 struct ospf_interface *oi = getdata (node);
hasso52dc7ee2004-09-23 19:18:23 +00002737 struct listnode *nbr_node;
paul718e3742002-12-13 20:15:29 +00002738
2739 show_ip_ospf_neighbor_sub (vty, oi);
2740
2741 /* print Down neighbor status */
2742 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
2743 {
2744 struct ospf_nbr_nbma *nbr_nbma;
2745
2746 nbr_nbma = getdata (nbr_node);
2747
2748 if (nbr_nbma->nbr == NULL
2749 || nbr_nbma->nbr->state == NSM_Down)
2750 {
2751 vty_out (vty, "%-15s %3d %-15s %8s ",
2752 "-", nbr_nbma->priority, "Down", "-");
2753 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2754 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2755 0, 0, 0, VTY_NEWLINE);
2756 }
2757 }
2758 }
2759
2760 return CMD_SUCCESS;
2761}
2762
2763DEFUN (show_ip_ospf_neighbor_int,
2764 show_ip_ospf_neighbor_int_cmd,
2765 "show ip ospf neighbor A.B.C.D",
2766 SHOW_STR
2767 IP_STR
2768 "OSPF information\n"
2769 "Neighbor list\n"
2770 "Interface name\n")
2771{
paul020709f2003-04-04 02:44:16 +00002772 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002773 struct ospf_interface *oi;
2774 struct in_addr addr;
2775 int ret;
2776
paul718e3742002-12-13 20:15:29 +00002777 ret = inet_aton (argv[0], &addr);
2778 if (!ret)
2779 {
2780 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2781 VTY_NEWLINE);
2782 return CMD_WARNING;
2783 }
2784
paul020709f2003-04-04 02:44:16 +00002785 ospf = ospf_lookup ();
2786 if (ospf == NULL)
2787 {
2788 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2789 return CMD_SUCCESS;
2790 }
2791
paul68980082003-03-25 05:07:42 +00002792 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00002793 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2794 else
2795 {
2796 vty_out (vty, "%sNeighbor ID Pri State Dead "
2797 "Time Address Interface RXmtL "
2798 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2799 show_ip_ospf_neighbor_sub (vty, oi);
2800 }
2801
2802 return CMD_SUCCESS;
2803}
2804
2805void
2806show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2807 struct ospf_nbr_nbma *nbr_nbma)
2808{
2809 char timebuf[9];
2810
2811 /* Show neighbor ID. */
2812 vty_out (vty, " Neighbor %s,", "-");
2813
2814 /* Show interface address. */
2815 vty_out (vty, " interface address %s%s",
2816 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2817 /* Show Area ID. */
2818 vty_out (vty, " In the area %s via interface %s%s",
2819 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2820 /* Show neighbor priority and state. */
2821 vty_out (vty, " Neighbor priority is %d, State is %s,",
2822 nbr_nbma->priority, "Down");
2823 /* Show state changes. */
2824 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2825
2826 /* Show PollInterval */
2827 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2828
2829 /* Show poll-interval timer. */
2830 vty_out (vty, " Poll timer due in %s%s",
2831 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2832
2833 /* Show poll-interval timer thread. */
2834 vty_out (vty, " Thread Poll Timer %s%s",
2835 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2836}
2837
2838void
2839show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2840 struct ospf_neighbor *nbr)
2841{
2842 char timebuf[9];
2843
2844 /* Show neighbor ID. */
2845 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2846 vty_out (vty, " Neighbor %s,", "-");
2847 else
2848 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2849
2850 /* Show interface address. */
2851 vty_out (vty, " interface address %s%s",
2852 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2853 /* Show Area ID. */
2854 vty_out (vty, " In the area %s via interface %s%s",
2855 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2856 /* Show neighbor priority and state. */
2857 vty_out (vty, " Neighbor priority is %d, State is %s,",
2858 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2859 /* Show state changes. */
2860 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2861
2862 /* Show Designated Rotuer ID. */
2863 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2864 /* Show Backup Designated Rotuer ID. */
2865 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2866 /* Show options. */
2867 vty_out (vty, " Options %d %s%s", nbr->options,
2868 ospf_options_dump (nbr->options), VTY_NEWLINE);
2869 /* Show Router Dead interval timer. */
2870 vty_out (vty, " Dead timer due in %s%s",
2871 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2872 /* Show Database Summary list. */
2873 vty_out (vty, " Database Summary List %d%s",
2874 ospf_db_summary_count (nbr), VTY_NEWLINE);
2875 /* Show Link State Request list. */
2876 vty_out (vty, " Link State Request List %ld%s",
2877 ospf_ls_request_count (nbr), VTY_NEWLINE);
2878 /* Show Link State Retransmission list. */
2879 vty_out (vty, " Link State Retransmission List %ld%s",
2880 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2881 /* Show inactivity timer thread. */
2882 vty_out (vty, " Thread Inactivity Timer %s%s",
2883 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2884 /* Show Database Description retransmission thread. */
2885 vty_out (vty, " Thread Database Description Retransmision %s%s",
2886 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2887 /* Show Link State Request Retransmission thread. */
2888 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2889 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2890 /* Show Link State Update Retransmission thread. */
2891 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2892 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2893}
2894
2895DEFUN (show_ip_ospf_neighbor_id,
2896 show_ip_ospf_neighbor_id_cmd,
2897 "show ip ospf neighbor A.B.C.D",
2898 SHOW_STR
2899 IP_STR
2900 "OSPF information\n"
2901 "Neighbor list\n"
2902 "Neighbor ID\n")
2903{
paul020709f2003-04-04 02:44:16 +00002904 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002905 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002906 struct ospf_neighbor *nbr;
2907 struct in_addr router_id;
2908 int ret;
2909
2910 ret = inet_aton (argv[0], &router_id);
2911 if (!ret)
2912 {
2913 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
2914 return CMD_WARNING;
2915 }
2916
paul020709f2003-04-04 02:44:16 +00002917 ospf = ospf_lookup ();
2918 if (ospf == NULL)
2919 {
2920 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2921 return CMD_SUCCESS;
2922 }
2923
paul68980082003-03-25 05:07:42 +00002924 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002925 {
2926 struct ospf_interface *oi = getdata (node);
2927
2928 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
2929 {
2930 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2931 return CMD_SUCCESS;
2932 }
2933 }
2934
2935 /* Nothing to show. */
2936 return CMD_SUCCESS;
2937}
2938
2939DEFUN (show_ip_ospf_neighbor_detail,
2940 show_ip_ospf_neighbor_detail_cmd,
2941 "show ip ospf neighbor detail",
2942 SHOW_STR
2943 IP_STR
2944 "OSPF information\n"
2945 "Neighbor list\n"
2946 "detail of all neighbors\n")
2947{
paul020709f2003-04-04 02:44:16 +00002948 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002949 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002950
paul020709f2003-04-04 02:44:16 +00002951 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002952 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00002953 {
2954 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2955 return CMD_SUCCESS;
2956 }
paul718e3742002-12-13 20:15:29 +00002957
paul68980082003-03-25 05:07:42 +00002958 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002959 {
2960 struct ospf_interface *oi = getdata (node);
2961 struct route_node *rn;
2962 struct ospf_neighbor *nbr;
2963
2964 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2965 if ((nbr = rn->info))
2966 if (nbr != oi->nbr_self)
2967 if (nbr->state != NSM_Down)
2968 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2969 }
2970
2971 return CMD_SUCCESS;
2972}
2973
2974DEFUN (show_ip_ospf_neighbor_detail_all,
2975 show_ip_ospf_neighbor_detail_all_cmd,
2976 "show ip ospf neighbor detail all",
2977 SHOW_STR
2978 IP_STR
2979 "OSPF information\n"
2980 "Neighbor list\n"
2981 "detail of all neighbors\n"
2982 "include down status neighbor\n")
2983{
paul020709f2003-04-04 02:44:16 +00002984 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002985 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002986
paul020709f2003-04-04 02:44:16 +00002987 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002988 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00002989 {
2990 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2991 return CMD_SUCCESS;
2992 }
paul718e3742002-12-13 20:15:29 +00002993
paul68980082003-03-25 05:07:42 +00002994 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002995 {
2996 struct ospf_interface *oi = getdata (node);
2997 struct route_node *rn;
2998 struct ospf_neighbor *nbr;
2999
3000 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3001 if ((nbr = rn->info))
3002 if (nbr != oi->nbr_self)
3003 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3004 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3005
3006 if (oi->type == OSPF_IFTYPE_NBMA)
3007 {
hasso52dc7ee2004-09-23 19:18:23 +00003008 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003009
3010 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
3011 {
3012 struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
3013 if (nbr_nbma->nbr == NULL
3014 || nbr_nbma->nbr->state == NSM_Down)
3015 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3016 }
3017 }
3018 }
3019
3020 return CMD_SUCCESS;
3021}
3022
3023DEFUN (show_ip_ospf_neighbor_int_detail,
3024 show_ip_ospf_neighbor_int_detail_cmd,
3025 "show ip ospf neighbor A.B.C.D detail",
3026 SHOW_STR
3027 IP_STR
3028 "OSPF information\n"
3029 "Neighbor list\n"
3030 "Interface address\n"
3031 "detail of all neighbors")
3032{
paul020709f2003-04-04 02:44:16 +00003033 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003034 struct ospf_interface *oi;
3035 struct in_addr addr;
3036 int ret;
3037
3038 ret = inet_aton (argv[0], &addr);
3039 if (!ret)
3040 {
3041 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3042 VTY_NEWLINE);
3043 return CMD_WARNING;
3044 }
3045
paul020709f2003-04-04 02:44:16 +00003046 ospf = ospf_lookup ();
3047 if (ospf == NULL)
3048 {
3049 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3050 return CMD_SUCCESS;
3051 }
paul68980082003-03-25 05:07:42 +00003052
paul020709f2003-04-04 02:44:16 +00003053 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00003054 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3055 else
3056 {
3057 struct route_node *rn;
3058 struct ospf_neighbor *nbr;
3059
3060 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3061 if ((nbr = rn->info))
3062 if (nbr != oi->nbr_self)
3063 if (nbr->state != NSM_Down)
3064 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3065 }
3066
3067 return CMD_SUCCESS;
3068}
3069
3070
3071/* Show functions */
3072int
paul020709f2003-04-04 02:44:16 +00003073show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003074{
paul718e3742002-12-13 20:15:29 +00003075 struct router_lsa *rl;
3076 struct summary_lsa *sl;
3077 struct as_external_lsa *asel;
3078 struct prefix_ipv4 p;
3079
3080 if (lsa != NULL)
3081 /* If self option is set, check LSA self flag. */
3082 if (self == 0 || IS_LSA_SELF (lsa))
3083 {
3084 /* LSA common part show. */
3085 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3086 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3087 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3088 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3089 /* LSA specific part show. */
3090 switch (lsa->data->type)
3091 {
3092 case OSPF_ROUTER_LSA:
3093 rl = (struct router_lsa *) lsa->data;
3094 vty_out (vty, " %-d", ntohs (rl->links));
3095 break;
3096 case OSPF_SUMMARY_LSA:
3097 sl = (struct summary_lsa *) lsa->data;
3098
3099 p.family = AF_INET;
3100 p.prefix = sl->header.id;
3101 p.prefixlen = ip_masklen (sl->mask);
3102 apply_mask_ipv4 (&p);
3103
3104 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3105 break;
3106 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003107 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003108 asel = (struct as_external_lsa *) lsa->data;
3109
3110 p.family = AF_INET;
3111 p.prefix = asel->header.id;
3112 p.prefixlen = ip_masklen (asel->mask);
3113 apply_mask_ipv4 (&p);
3114
3115 vty_out (vty, " %s %s/%d [0x%lx]",
3116 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3117 inet_ntoa (p.prefix), p.prefixlen,
3118 (u_long)ntohl (asel->e[0].route_tag));
3119 break;
3120 case OSPF_NETWORK_LSA:
3121 case OSPF_ASBR_SUMMARY_LSA:
3122#ifdef HAVE_OPAQUE_LSA
3123 case OSPF_OPAQUE_LINK_LSA:
3124 case OSPF_OPAQUE_AREA_LSA:
3125 case OSPF_OPAQUE_AS_LSA:
3126#endif /* HAVE_OPAQUE_LSA */
3127 default:
3128 break;
3129 }
3130 vty_out (vty, VTY_NEWLINE);
3131 }
3132
3133 return 0;
3134}
3135
hassoeb1ce602004-10-08 08:17:22 +00003136const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003137{
3138 "unknown",
3139 "Router Link States",
3140 "Net Link States",
3141 "Summary Link States",
3142 "ASBR-Summary Link States",
3143 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003144 "Group Membership LSA",
3145 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003146#ifdef HAVE_OPAQUE_LSA
3147 "Type-8 LSA",
3148 "Link-Local Opaque-LSA",
3149 "Area-Local Opaque-LSA",
3150 "AS-external Opaque-LSA",
3151#endif /* HAVE_OPAQUE_LSA */
3152};
3153
3154#define SHOW_OSPF_COMMON_HEADER \
3155 "Link ID ADV Router Age Seq# CkSum"
3156
hassoeb1ce602004-10-08 08:17:22 +00003157const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003158{
3159 "",
3160 "Link ID ADV Router Age Seq# CkSum Link count",
3161 "Link ID ADV Router Age Seq# CkSum",
3162 "Link ID ADV Router Age Seq# CkSum Route",
3163 "Link ID ADV Router Age Seq# CkSum",
3164 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003165 " --- header for Group Member ----",
3166 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003167#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003168 " --- type-8 ---",
3169 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3170 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3171 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3172#endif /* HAVE_OPAQUE_LSA */
3173};
3174
hassoeb1ce602004-10-08 08:17:22 +00003175const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003176{
3177 "Self-originated",
3178 "Checked",
3179 "Received",
3180 "Approved",
3181 "Discard",
paul4957f492003-06-27 01:28:45 +00003182 "Translated",
paul4957f492003-06-27 01:28:45 +00003183};
3184
paul718e3742002-12-13 20:15:29 +00003185void
3186show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3187{
3188 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003189
paul718e3742002-12-13 20:15:29 +00003190 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003191 vty_out (vty, " Options: 0x%-2x : %s%s",
3192 lsa->data->options,
3193 ospf_options_dump(lsa->data->options),
3194 VTY_NEWLINE);
3195 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003196 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003197 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3198 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003199
3200 if (lsa->data->type == OSPF_ROUTER_LSA)
3201 {
3202 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3203
3204 if (rlsa->flags)
3205 vty_out (vty, " :%s%s%s%s",
3206 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3207 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3208 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3209 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3210
3211 vty_out (vty, "%s", VTY_NEWLINE);
3212 }
3213 vty_out (vty, " LS Type: %s%s",
3214 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3215 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3216 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3217 vty_out (vty, " Advertising Router: %s%s",
3218 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3219 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3220 VTY_NEWLINE);
3221 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3222 VTY_NEWLINE);
3223 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3224}
3225
hassoeb1ce602004-10-08 08:17:22 +00003226const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003227{
3228 "(null)",
3229 "another Router (point-to-point)",
3230 "a Transit Network",
3231 "Stub Network",
3232 "a Virtual Link",
3233};
3234
hassoeb1ce602004-10-08 08:17:22 +00003235const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003236{
3237 "(null)",
3238 "Neighboring Router ID",
3239 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003240 "Net",
paul718e3742002-12-13 20:15:29 +00003241 "Neighboring Router ID",
3242};
3243
hassoeb1ce602004-10-08 08:17:22 +00003244const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003245{
3246 "(null)",
3247 "Router Interface address",
3248 "Router Interface address",
3249 "Network Mask",
3250 "Router Interface address",
3251};
3252
3253/* Show router-LSA each Link information. */
3254void
3255show_ip_ospf_database_router_links (struct vty *vty,
3256 struct router_lsa *rl)
3257{
3258 int len, i, type;
3259
3260 len = ntohs (rl->header.length) - 4;
3261 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3262 {
3263 type = rl->link[i].type;
3264
3265 vty_out (vty, " Link connected to: %s%s",
3266 link_type_desc[type], VTY_NEWLINE);
3267 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3268 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3269 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3270 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3271 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3272 vty_out (vty, " TOS 0 Metric: %d%s",
3273 ntohs (rl->link[i].metric), VTY_NEWLINE);
3274 vty_out (vty, "%s", VTY_NEWLINE);
3275 }
3276}
3277
3278/* Show router-LSA detail information. */
3279int
3280show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3281{
3282 if (lsa != NULL)
3283 {
3284 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3285
3286 show_ip_ospf_database_header (vty, lsa);
3287
3288 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3289 VTY_NEWLINE, VTY_NEWLINE);
3290
3291 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003292 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003293 }
3294
3295 return 0;
3296}
3297
3298/* Show network-LSA detail information. */
3299int
3300show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3301{
3302 int length, i;
3303
3304 if (lsa != NULL)
3305 {
3306 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3307
3308 show_ip_ospf_database_header (vty, lsa);
3309
3310 vty_out (vty, " Network Mask: /%d%s",
3311 ip_masklen (nl->mask), VTY_NEWLINE);
3312
3313 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3314
3315 for (i = 0; length > 0; i++, length -= 4)
3316 vty_out (vty, " Attached Router: %s%s",
3317 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3318
3319 vty_out (vty, "%s", VTY_NEWLINE);
3320 }
3321
3322 return 0;
3323}
3324
3325/* Show summary-LSA detail information. */
3326int
3327show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3328{
3329 if (lsa != NULL)
3330 {
3331 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3332
3333 show_ip_ospf_database_header (vty, lsa);
3334
3335 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3336 VTY_NEWLINE);
3337 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3338 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003339 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003340 }
3341
3342 return 0;
3343}
3344
3345/* Show summary-ASBR-LSA detail information. */
3346int
3347show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3348{
3349 if (lsa != NULL)
3350 {
3351 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3352
3353 show_ip_ospf_database_header (vty, lsa);
3354
3355 vty_out (vty, " Network Mask: /%d%s",
3356 ip_masklen (sl->mask), VTY_NEWLINE);
3357 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3358 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003359 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003360 }
3361
3362 return 0;
3363}
3364
3365/* Show AS-external-LSA detail information. */
3366int
3367show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3368{
3369 if (lsa != NULL)
3370 {
3371 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3372
3373 show_ip_ospf_database_header (vty, lsa);
3374
3375 vty_out (vty, " Network Mask: /%d%s",
3376 ip_masklen (al->mask), VTY_NEWLINE);
3377 vty_out (vty, " Metric Type: %s%s",
3378 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3379 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3380 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3381 vty_out (vty, " Metric: %d%s",
3382 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3383 vty_out (vty, " Forward Address: %s%s",
3384 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3385
3386 vty_out (vty, " External Route Tag: %lu%s%s",
3387 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3388 }
3389
3390 return 0;
3391}
3392
paul718e3742002-12-13 20:15:29 +00003393int
3394show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3395{
3396 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3397
3398 /* show_ip_ospf_database_header (vty, lsa); */
3399
3400 zlog_info( " Network Mask: /%d%s",
3401 ip_masklen (al->mask), "\n");
3402 zlog_info( " Metric Type: %s%s",
3403 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3404 "2 (Larger than any link state path)" : "1", "\n");
3405 zlog_info( " TOS: 0%s", "\n");
3406 zlog_info( " Metric: %d%s",
3407 GET_METRIC (al->e[0].metric), "\n");
3408 zlog_info( " Forward Address: %s%s",
3409 inet_ntoa (al->e[0].fwd_addr), "\n");
3410
3411 zlog_info( " External Route Tag: %u%s%s",
3412 ntohl (al->e[0].route_tag), "\n", "\n");
3413
3414 return 0;
3415}
3416
3417/* Show AS-NSSA-LSA detail information. */
3418int
3419show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3420{
3421 if (lsa != NULL)
3422 {
3423 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3424
3425 show_ip_ospf_database_header (vty, lsa);
3426
3427 vty_out (vty, " Network Mask: /%d%s",
3428 ip_masklen (al->mask), VTY_NEWLINE);
3429 vty_out (vty, " Metric Type: %s%s",
3430 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3431 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3432 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3433 vty_out (vty, " Metric: %d%s",
3434 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3435 vty_out (vty, " NSSA: Forward Address: %s%s",
3436 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3437
3438 vty_out (vty, " External Route Tag: %u%s%s",
3439 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3440 }
3441
3442 return 0;
3443}
3444
paul718e3742002-12-13 20:15:29 +00003445int
3446show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3447{
3448 return 0;
3449}
3450
3451#ifdef HAVE_OPAQUE_LSA
3452int
3453show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3454{
3455 if (lsa != NULL)
3456 {
3457 show_ip_ospf_database_header (vty, lsa);
3458 show_opaque_info_detail (vty, lsa);
3459
3460 vty_out (vty, "%s", VTY_NEWLINE);
3461 }
3462 return 0;
3463}
3464#endif /* HAVE_OPAQUE_LSA */
3465
3466int (*show_function[])(struct vty *, struct ospf_lsa *) =
3467{
3468 NULL,
3469 show_router_lsa_detail,
3470 show_network_lsa_detail,
3471 show_summary_lsa_detail,
3472 show_summary_asbr_lsa_detail,
3473 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003474 show_func_dummy,
3475 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003476#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003477 NULL, /* type-8 */
3478 show_opaque_lsa_detail,
3479 show_opaque_lsa_detail,
3480 show_opaque_lsa_detail,
3481#endif /* HAVE_OPAQUE_LSA */
3482};
3483
3484void
3485show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3486 struct in_addr *adv_router)
3487{
3488 memset (lp, 0, sizeof (struct prefix_ls));
3489 lp->family = 0;
3490 if (id == NULL)
3491 lp->prefixlen = 0;
3492 else if (adv_router == NULL)
3493 {
3494 lp->prefixlen = 32;
3495 lp->id = *id;
3496 }
3497 else
3498 {
3499 lp->prefixlen = 64;
3500 lp->id = *id;
3501 lp->adv_router = *adv_router;
3502 }
3503}
3504
3505void
3506show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3507 struct in_addr *id, struct in_addr *adv_router)
3508{
3509 struct prefix_ls lp;
3510 struct route_node *rn, *start;
3511 struct ospf_lsa *lsa;
3512
3513 show_lsa_prefix_set (vty, &lp, id, adv_router);
3514 start = route_node_get (rt, (struct prefix *) &lp);
3515 if (start)
3516 {
3517 route_lock_node (start);
3518 for (rn = start; rn; rn = route_next_until (rn, start))
3519 if ((lsa = rn->info))
3520 {
paul718e3742002-12-13 20:15:29 +00003521 if (show_function[lsa->data->type] != NULL)
3522 show_function[lsa->data->type] (vty, lsa);
3523 }
3524 route_unlock_node (start);
3525 }
3526}
3527
3528/* Show detail LSA information
3529 -- if id is NULL then show all LSAs. */
3530void
paul020709f2003-04-04 02:44:16 +00003531show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003532 struct in_addr *id, struct in_addr *adv_router)
3533{
hasso52dc7ee2004-09-23 19:18:23 +00003534 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003535
3536 switch (type)
3537 {
3538 case OSPF_AS_EXTERNAL_LSA:
3539#ifdef HAVE_OPAQUE_LSA
3540 case OSPF_OPAQUE_AS_LSA:
3541#endif /* HAVE_OPAQUE_LSA */
3542 vty_out (vty, " %s %s%s",
3543 show_database_desc[type],
3544 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003545 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003546 break;
3547 default:
paul68980082003-03-25 05:07:42 +00003548 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003549 {
3550 struct ospf_area *area = node->data;
3551 vty_out (vty, "%s %s (Area %s)%s%s",
3552 VTY_NEWLINE, show_database_desc[type],
3553 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3554 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3555 }
3556 break;
3557 }
3558}
3559
3560void
3561show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3562 struct in_addr *adv_router)
3563{
3564 struct route_node *rn;
3565 struct ospf_lsa *lsa;
3566
3567 for (rn = route_top (rt); rn; rn = route_next (rn))
3568 if ((lsa = rn->info))
3569 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3570 {
paul718e3742002-12-13 20:15:29 +00003571 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3572 continue;
paul718e3742002-12-13 20:15:29 +00003573 if (show_function[lsa->data->type] != NULL)
3574 show_function[lsa->data->type] (vty, lsa);
3575 }
3576}
3577
3578/* Show detail LSA information. */
3579void
paul020709f2003-04-04 02:44:16 +00003580show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003581 struct in_addr *adv_router)
3582{
hasso52dc7ee2004-09-23 19:18:23 +00003583 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003584
3585 switch (type)
3586 {
3587 case OSPF_AS_EXTERNAL_LSA:
3588#ifdef HAVE_OPAQUE_LSA
3589 case OSPF_OPAQUE_AS_LSA:
3590#endif /* HAVE_OPAQUE_LSA */
3591 vty_out (vty, " %s %s%s",
3592 show_database_desc[type],
3593 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003594 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003595 adv_router);
3596 break;
3597 default:
paul68980082003-03-25 05:07:42 +00003598 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003599 {
3600 struct ospf_area *area = node->data;
3601 vty_out (vty, "%s %s (Area %s)%s%s",
3602 VTY_NEWLINE, show_database_desc[type],
3603 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3604 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3605 adv_router);
3606 }
3607 break;
3608 }
3609}
3610
3611void
paul020709f2003-04-04 02:44:16 +00003612show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003613{
paul020709f2003-04-04 02:44:16 +00003614 struct ospf_lsa *lsa;
3615 struct route_node *rn;
hasso52dc7ee2004-09-23 19:18:23 +00003616 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003617 int type;
3618
paul68980082003-03-25 05:07:42 +00003619 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003620 {
3621 struct ospf_area *area = node->data;
3622 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3623 {
3624 switch (type)
3625 {
3626 case OSPF_AS_EXTERNAL_LSA:
3627#ifdef HAVE_OPAQUE_LSA
3628 case OSPF_OPAQUE_AS_LSA:
3629#endif /* HAVE_OPAQUE_LSA */
3630 continue;
3631 default:
3632 break;
3633 }
3634 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3635 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3636 {
3637 vty_out (vty, " %s (Area %s)%s%s",
3638 show_database_desc[type],
3639 ospf_area_desc_string (area),
3640 VTY_NEWLINE, VTY_NEWLINE);
3641 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3642
paul020709f2003-04-04 02:44:16 +00003643 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3644 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003645
3646 vty_out (vty, "%s", VTY_NEWLINE);
3647 }
3648 }
3649 }
3650
3651 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3652 {
3653 switch (type)
3654 {
3655 case OSPF_AS_EXTERNAL_LSA:
3656#ifdef HAVE_OPAQUE_LSA
3657 case OSPF_OPAQUE_AS_LSA:
3658#endif /* HAVE_OPAQUE_LSA */
3659 break;;
3660 default:
3661 continue;
3662 }
paul68980082003-03-25 05:07:42 +00003663 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3664 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003665 {
3666 vty_out (vty, " %s%s%s",
3667 show_database_desc[type],
3668 VTY_NEWLINE, VTY_NEWLINE);
3669 vty_out (vty, "%s%s", show_database_header[type],
3670 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003671
3672 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3673 show_lsa_summary (vty, lsa, self);
3674
paul718e3742002-12-13 20:15:29 +00003675 vty_out (vty, "%s", VTY_NEWLINE);
3676 }
3677 }
3678
3679 vty_out (vty, "%s", VTY_NEWLINE);
3680}
3681
3682void
paul020709f2003-04-04 02:44:16 +00003683show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003684{
hasso52dc7ee2004-09-23 19:18:23 +00003685 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003686 struct ospf_lsa *lsa;
3687
3688 vty_out (vty, "%s MaxAge Link States:%s%s",
3689 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3690
paul68980082003-03-25 05:07:42 +00003691 for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003692 if ((lsa = node->data) != NULL)
3693 {
3694 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3695 vty_out (vty, "Link State ID: %s%s",
3696 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3697 vty_out (vty, "Advertising Router: %s%s",
3698 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3699 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3700 vty_out (vty, "%s", VTY_NEWLINE);
3701 }
3702}
3703
paul718e3742002-12-13 20:15:29 +00003704#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3705#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003706
3707#ifdef HAVE_OPAQUE_LSA
3708#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3709#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3710#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3711#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3712#else /* HAVE_OPAQUE_LSA */
3713#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3714#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3715#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3716#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3717#endif /* HAVE_OPAQUE_LSA */
3718
3719#define OSPF_LSA_TYPES_CMD_STR \
3720 "asbr-summary|external|network|router|summary" \
3721 OSPF_LSA_TYPE_NSSA_CMD_STR \
3722 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3723
3724#define OSPF_LSA_TYPES_DESC \
3725 "ASBR summary link states\n" \
3726 "External link states\n" \
3727 "Network link states\n" \
3728 "Router link states\n" \
3729 "Network summary link states\n" \
3730 OSPF_LSA_TYPE_NSSA_DESC \
3731 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3732 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3733 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3734
3735DEFUN (show_ip_ospf_database,
3736 show_ip_ospf_database_cmd,
3737 "show ip ospf database",
3738 SHOW_STR
3739 IP_STR
3740 "OSPF information\n"
3741 "Database summary\n")
3742{
paul020709f2003-04-04 02:44:16 +00003743 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003744 int type, ret;
3745 struct in_addr id, adv_router;
3746
paul020709f2003-04-04 02:44:16 +00003747 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003748 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003749 return CMD_SUCCESS;
3750
3751 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003752 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003753
3754 /* Show all LSA. */
3755 if (argc == 0)
3756 {
paul020709f2003-04-04 02:44:16 +00003757 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003758 return CMD_SUCCESS;
3759 }
3760
3761 /* Set database type to show. */
3762 if (strncmp (argv[0], "r", 1) == 0)
3763 type = OSPF_ROUTER_LSA;
3764 else if (strncmp (argv[0], "ne", 2) == 0)
3765 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003766 else if (strncmp (argv[0], "ns", 2) == 0)
3767 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003768 else if (strncmp (argv[0], "su", 2) == 0)
3769 type = OSPF_SUMMARY_LSA;
3770 else if (strncmp (argv[0], "a", 1) == 0)
3771 type = OSPF_ASBR_SUMMARY_LSA;
3772 else if (strncmp (argv[0], "e", 1) == 0)
3773 type = OSPF_AS_EXTERNAL_LSA;
3774 else if (strncmp (argv[0], "se", 2) == 0)
3775 {
paul020709f2003-04-04 02:44:16 +00003776 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003777 return CMD_SUCCESS;
3778 }
3779 else if (strncmp (argv[0], "m", 1) == 0)
3780 {
paul020709f2003-04-04 02:44:16 +00003781 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003782 return CMD_SUCCESS;
3783 }
3784#ifdef HAVE_OPAQUE_LSA
3785 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3786 type = OSPF_OPAQUE_LINK_LSA;
3787 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3788 type = OSPF_OPAQUE_AREA_LSA;
3789 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3790 type = OSPF_OPAQUE_AS_LSA;
3791#endif /* HAVE_OPAQUE_LSA */
3792 else
3793 return CMD_WARNING;
3794
3795 /* `show ip ospf database LSA'. */
3796 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003797 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003798 else if (argc >= 2)
3799 {
3800 ret = inet_aton (argv[1], &id);
3801 if (!ret)
3802 return CMD_WARNING;
3803
3804 /* `show ip ospf database LSA ID'. */
3805 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003806 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003807 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3808 else if (argc == 3)
3809 {
3810 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003811 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003812 else
3813 {
3814 ret = inet_aton (argv[2], &adv_router);
3815 if (!ret)
3816 return CMD_WARNING;
3817 }
paul020709f2003-04-04 02:44:16 +00003818 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003819 }
3820 }
3821
3822 return CMD_SUCCESS;
3823}
3824
3825ALIAS (show_ip_ospf_database,
3826 show_ip_ospf_database_type_cmd,
3827 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3828 SHOW_STR
3829 IP_STR
3830 "OSPF information\n"
3831 "Database summary\n"
3832 OSPF_LSA_TYPES_DESC
3833 "LSAs in MaxAge list\n"
3834 "Self-originated link states\n")
3835
3836ALIAS (show_ip_ospf_database,
3837 show_ip_ospf_database_type_id_cmd,
3838 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3839 SHOW_STR
3840 IP_STR
3841 "OSPF information\n"
3842 "Database summary\n"
3843 OSPF_LSA_TYPES_DESC
3844 "Link State ID (as an IP address)\n")
3845
3846ALIAS (show_ip_ospf_database,
3847 show_ip_ospf_database_type_id_adv_router_cmd,
3848 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3849 SHOW_STR
3850 IP_STR
3851 "OSPF information\n"
3852 "Database summary\n"
3853 OSPF_LSA_TYPES_DESC
3854 "Link State ID (as an IP address)\n"
3855 "Advertising Router link states\n"
3856 "Advertising Router (as an IP address)\n")
3857
3858ALIAS (show_ip_ospf_database,
3859 show_ip_ospf_database_type_id_self_cmd,
3860 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3861 SHOW_STR
3862 IP_STR
3863 "OSPF information\n"
3864 "Database summary\n"
3865 OSPF_LSA_TYPES_DESC
3866 "Link State ID (as an IP address)\n"
3867 "Self-originated link states\n"
3868 "\n")
3869
3870DEFUN (show_ip_ospf_database_type_adv_router,
3871 show_ip_ospf_database_type_adv_router_cmd,
3872 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3873 SHOW_STR
3874 IP_STR
3875 "OSPF information\n"
3876 "Database summary\n"
3877 OSPF_LSA_TYPES_DESC
3878 "Advertising Router link states\n"
3879 "Advertising Router (as an IP address)\n")
3880{
paul020709f2003-04-04 02:44:16 +00003881 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003882 int type, ret;
3883 struct in_addr adv_router;
3884
paul020709f2003-04-04 02:44:16 +00003885 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003886 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003887 return CMD_SUCCESS;
3888
3889 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003890 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003891
3892 if (argc != 2)
3893 return CMD_WARNING;
3894
3895 /* Set database type to show. */
3896 if (strncmp (argv[0], "r", 1) == 0)
3897 type = OSPF_ROUTER_LSA;
3898 else if (strncmp (argv[0], "ne", 2) == 0)
3899 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003900 else if (strncmp (argv[0], "ns", 2) == 0)
3901 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003902 else if (strncmp (argv[0], "s", 1) == 0)
3903 type = OSPF_SUMMARY_LSA;
3904 else if (strncmp (argv[0], "a", 1) == 0)
3905 type = OSPF_ASBR_SUMMARY_LSA;
3906 else if (strncmp (argv[0], "e", 1) == 0)
3907 type = OSPF_AS_EXTERNAL_LSA;
3908#ifdef HAVE_OPAQUE_LSA
3909 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3910 type = OSPF_OPAQUE_LINK_LSA;
3911 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3912 type = OSPF_OPAQUE_AREA_LSA;
3913 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3914 type = OSPF_OPAQUE_AS_LSA;
3915#endif /* HAVE_OPAQUE_LSA */
3916 else
3917 return CMD_WARNING;
3918
3919 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
3920 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003921 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003922 else
3923 {
3924 ret = inet_aton (argv[1], &adv_router);
3925 if (!ret)
3926 return CMD_WARNING;
3927 }
3928
paul020709f2003-04-04 02:44:16 +00003929 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00003930
3931 return CMD_SUCCESS;
3932}
3933
3934ALIAS (show_ip_ospf_database_type_adv_router,
3935 show_ip_ospf_database_type_self_cmd,
3936 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
3937 SHOW_STR
3938 IP_STR
3939 "OSPF information\n"
3940 "Database summary\n"
3941 OSPF_LSA_TYPES_DESC
3942 "Self-originated link states\n")
3943
3944
3945DEFUN (ip_ospf_authentication_args,
3946 ip_ospf_authentication_args_addr_cmd,
3947 "ip ospf authentication (null|message-digest) A.B.C.D",
3948 "IP Information\n"
3949 "OSPF interface commands\n"
3950 "Enable authentication on this interface\n"
3951 "Use null authentication\n"
3952 "Use message-digest authentication\n"
3953 "Address of interface")
3954{
3955 struct interface *ifp;
3956 struct in_addr addr;
3957 int ret;
3958 struct ospf_if_params *params;
3959
3960 ifp = vty->index;
3961 params = IF_DEF_PARAMS (ifp);
3962
3963 if (argc == 2)
3964 {
3965 ret = inet_aton(argv[1], &addr);
3966 if (!ret)
3967 {
3968 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3969 VTY_NEWLINE);
3970 return CMD_WARNING;
3971 }
3972
3973 params = ospf_get_if_params (ifp, addr);
3974 ospf_if_update_params (ifp, addr);
3975 }
3976
3977 /* Handle null authentication */
3978 if ( argv[0][0] == 'n' )
3979 {
3980 SET_IF_PARAM (params, auth_type);
3981 params->auth_type = OSPF_AUTH_NULL;
3982 return CMD_SUCCESS;
3983 }
3984
3985 /* Handle message-digest authentication */
3986 if ( argv[0][0] == 'm' )
3987 {
3988 SET_IF_PARAM (params, auth_type);
3989 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
3990 return CMD_SUCCESS;
3991 }
3992
3993 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
3994 return CMD_WARNING;
3995}
3996
3997ALIAS (ip_ospf_authentication_args,
3998 ip_ospf_authentication_args_cmd,
3999 "ip ospf authentication (null|message-digest)",
4000 "IP Information\n"
4001 "OSPF interface commands\n"
4002 "Enable authentication on this interface\n"
4003 "Use null authentication\n"
4004 "Use message-digest authentication\n")
4005
4006DEFUN (ip_ospf_authentication,
4007 ip_ospf_authentication_addr_cmd,
4008 "ip ospf authentication A.B.C.D",
4009 "IP Information\n"
4010 "OSPF interface commands\n"
4011 "Enable authentication on this interface\n"
4012 "Address of interface")
4013{
4014 struct interface *ifp;
4015 struct in_addr addr;
4016 int ret;
4017 struct ospf_if_params *params;
4018
4019 ifp = vty->index;
4020 params = IF_DEF_PARAMS (ifp);
4021
4022 if (argc == 1)
4023 {
4024 ret = inet_aton(argv[1], &addr);
4025 if (!ret)
4026 {
4027 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4028 VTY_NEWLINE);
4029 return CMD_WARNING;
4030 }
4031
4032 params = ospf_get_if_params (ifp, addr);
4033 ospf_if_update_params (ifp, addr);
4034 }
4035
4036 SET_IF_PARAM (params, auth_type);
4037 params->auth_type = OSPF_AUTH_SIMPLE;
4038
4039 return CMD_SUCCESS;
4040}
4041
4042ALIAS (ip_ospf_authentication,
4043 ip_ospf_authentication_cmd,
4044 "ip ospf authentication",
4045 "IP Information\n"
4046 "OSPF interface commands\n"
4047 "Enable authentication on this interface\n")
4048
4049DEFUN (no_ip_ospf_authentication,
4050 no_ip_ospf_authentication_addr_cmd,
4051 "no ip ospf authentication A.B.C.D",
4052 NO_STR
4053 "IP Information\n"
4054 "OSPF interface commands\n"
4055 "Enable authentication on this interface\n"
4056 "Address of interface")
4057{
4058 struct interface *ifp;
4059 struct in_addr addr;
4060 int ret;
4061 struct ospf_if_params *params;
4062
4063 ifp = vty->index;
4064 params = IF_DEF_PARAMS (ifp);
4065
4066 if (argc == 1)
4067 {
4068 ret = inet_aton(argv[1], &addr);
4069 if (!ret)
4070 {
4071 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4072 VTY_NEWLINE);
4073 return CMD_WARNING;
4074 }
4075
4076 params = ospf_lookup_if_params (ifp, addr);
4077 if (params == NULL)
4078 return CMD_SUCCESS;
4079 }
4080
4081 params->auth_type = OSPF_AUTH_NOTSET;
4082 UNSET_IF_PARAM (params, auth_type);
4083
4084 if (params != IF_DEF_PARAMS (ifp))
4085 {
4086 ospf_free_if_params (ifp, addr);
4087 ospf_if_update_params (ifp, addr);
4088 }
4089
4090 return CMD_SUCCESS;
4091}
4092
4093ALIAS (no_ip_ospf_authentication,
4094 no_ip_ospf_authentication_cmd,
4095 "no ip ospf authentication",
4096 NO_STR
4097 "IP Information\n"
4098 "OSPF interface commands\n"
4099 "Enable authentication on this interface\n")
4100
4101DEFUN (ip_ospf_authentication_key,
4102 ip_ospf_authentication_key_addr_cmd,
4103 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4104 "IP Information\n"
4105 "OSPF interface commands\n"
4106 "Authentication password (key)\n"
4107 "The OSPF password (key)\n"
4108 "Address of interface")
4109{
4110 struct interface *ifp;
4111 struct in_addr addr;
4112 int ret;
4113 struct ospf_if_params *params;
4114
4115 ifp = vty->index;
4116 params = IF_DEF_PARAMS (ifp);
4117
4118 if (argc == 2)
4119 {
4120 ret = inet_aton(argv[1], &addr);
4121 if (!ret)
4122 {
4123 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4124 VTY_NEWLINE);
4125 return CMD_WARNING;
4126 }
4127
4128 params = ospf_get_if_params (ifp, addr);
4129 ospf_if_update_params (ifp, addr);
4130 }
4131
4132
4133 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004134 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004135 SET_IF_PARAM (params, auth_simple);
4136
4137 return CMD_SUCCESS;
4138}
4139
4140ALIAS (ip_ospf_authentication_key,
4141 ip_ospf_authentication_key_cmd,
4142 "ip ospf authentication-key AUTH_KEY",
4143 "IP Information\n"
4144 "OSPF interface commands\n"
4145 "Authentication password (key)\n"
4146 "The OSPF password (key)")
4147
4148ALIAS (ip_ospf_authentication_key,
4149 ospf_authentication_key_cmd,
4150 "ospf authentication-key AUTH_KEY",
4151 "OSPF interface commands\n"
4152 "Authentication password (key)\n"
4153 "The OSPF password (key)")
4154
4155DEFUN (no_ip_ospf_authentication_key,
4156 no_ip_ospf_authentication_key_addr_cmd,
4157 "no ip ospf authentication-key A.B.C.D",
4158 NO_STR
4159 "IP Information\n"
4160 "OSPF interface commands\n"
4161 "Authentication password (key)\n"
4162 "Address of interface")
4163{
4164 struct interface *ifp;
4165 struct in_addr addr;
4166 int ret;
4167 struct ospf_if_params *params;
4168
4169 ifp = vty->index;
4170 params = IF_DEF_PARAMS (ifp);
4171
4172 if (argc == 2)
4173 {
4174 ret = inet_aton(argv[1], &addr);
4175 if (!ret)
4176 {
4177 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4178 VTY_NEWLINE);
4179 return CMD_WARNING;
4180 }
4181
4182 params = ospf_lookup_if_params (ifp, addr);
4183 if (params == NULL)
4184 return CMD_SUCCESS;
4185 }
4186
4187 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4188 UNSET_IF_PARAM (params, auth_simple);
4189
4190 if (params != IF_DEF_PARAMS (ifp))
4191 {
4192 ospf_free_if_params (ifp, addr);
4193 ospf_if_update_params (ifp, addr);
4194 }
4195
4196 return CMD_SUCCESS;
4197}
4198
4199ALIAS (no_ip_ospf_authentication_key,
4200 no_ip_ospf_authentication_key_cmd,
4201 "no ip ospf authentication-key",
4202 NO_STR
4203 "IP Information\n"
4204 "OSPF interface commands\n"
4205 "Authentication password (key)\n")
4206
4207ALIAS (no_ip_ospf_authentication_key,
4208 no_ospf_authentication_key_cmd,
4209 "no ospf authentication-key",
4210 NO_STR
4211 "OSPF interface commands\n"
4212 "Authentication password (key)\n")
4213
4214DEFUN (ip_ospf_message_digest_key,
4215 ip_ospf_message_digest_key_addr_cmd,
4216 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4217 "IP Information\n"
4218 "OSPF interface commands\n"
4219 "Message digest authentication password (key)\n"
4220 "Key ID\n"
4221 "Use MD5 algorithm\n"
4222 "The OSPF password (key)"
4223 "Address of interface")
4224{
4225 struct interface *ifp;
4226 struct crypt_key *ck;
4227 u_char key_id;
4228 struct in_addr addr;
4229 int ret;
4230 struct ospf_if_params *params;
4231
4232 ifp = vty->index;
4233 params = IF_DEF_PARAMS (ifp);
4234
4235 if (argc == 3)
4236 {
4237 ret = inet_aton(argv[2], &addr);
4238 if (!ret)
4239 {
4240 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4241 VTY_NEWLINE);
4242 return CMD_WARNING;
4243 }
4244
4245 params = ospf_get_if_params (ifp, addr);
4246 ospf_if_update_params (ifp, addr);
4247 }
4248
4249 key_id = strtol (argv[0], NULL, 10);
4250 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4251 {
4252 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4253 return CMD_WARNING;
4254 }
4255
4256 ck = ospf_crypt_key_new ();
4257 ck->key_id = (u_char) key_id;
4258 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004259 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004260
4261 ospf_crypt_key_add (params->auth_crypt, ck);
4262 SET_IF_PARAM (params, auth_crypt);
4263
4264 return CMD_SUCCESS;
4265}
4266
4267ALIAS (ip_ospf_message_digest_key,
4268 ip_ospf_message_digest_key_cmd,
4269 "ip ospf message-digest-key <1-255> md5 KEY",
4270 "IP Information\n"
4271 "OSPF interface commands\n"
4272 "Message digest authentication password (key)\n"
4273 "Key ID\n"
4274 "Use MD5 algorithm\n"
4275 "The OSPF password (key)")
4276
4277ALIAS (ip_ospf_message_digest_key,
4278 ospf_message_digest_key_cmd,
4279 "ospf message-digest-key <1-255> md5 KEY",
4280 "OSPF interface commands\n"
4281 "Message digest authentication password (key)\n"
4282 "Key ID\n"
4283 "Use MD5 algorithm\n"
4284 "The OSPF password (key)")
4285
4286DEFUN (no_ip_ospf_message_digest_key,
4287 no_ip_ospf_message_digest_key_addr_cmd,
4288 "no ip ospf message-digest-key <1-255> A.B.C.D",
4289 NO_STR
4290 "IP Information\n"
4291 "OSPF interface commands\n"
4292 "Message digest authentication password (key)\n"
4293 "Key ID\n"
4294 "Address of interface")
4295{
4296 struct interface *ifp;
4297 struct crypt_key *ck;
4298 int key_id;
4299 struct in_addr addr;
4300 int ret;
4301 struct ospf_if_params *params;
4302
4303 ifp = vty->index;
4304 params = IF_DEF_PARAMS (ifp);
4305
4306 if (argc == 2)
4307 {
4308 ret = inet_aton(argv[1], &addr);
4309 if (!ret)
4310 {
4311 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4312 VTY_NEWLINE);
4313 return CMD_WARNING;
4314 }
4315
4316 params = ospf_lookup_if_params (ifp, addr);
4317 if (params == NULL)
4318 return CMD_SUCCESS;
4319 }
4320
4321 key_id = strtol (argv[0], NULL, 10);
4322 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4323 if (ck == NULL)
4324 {
4325 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4326 return CMD_WARNING;
4327 }
4328
4329 ospf_crypt_key_delete (params->auth_crypt, key_id);
4330
4331 if (params != IF_DEF_PARAMS (ifp))
4332 {
4333 ospf_free_if_params (ifp, addr);
4334 ospf_if_update_params (ifp, addr);
4335 }
4336
4337 return CMD_SUCCESS;
4338}
4339
4340ALIAS (no_ip_ospf_message_digest_key,
4341 no_ip_ospf_message_digest_key_cmd,
4342 "no ip ospf message-digest-key <1-255>",
4343 NO_STR
4344 "IP Information\n"
4345 "OSPF interface commands\n"
4346 "Message digest authentication password (key)\n"
4347 "Key ID\n")
4348
4349ALIAS (no_ip_ospf_message_digest_key,
4350 no_ospf_message_digest_key_cmd,
4351 "no ospf message-digest-key <1-255>",
4352 NO_STR
4353 "OSPF interface commands\n"
4354 "Message digest authentication password (key)\n"
4355 "Key ID\n")
4356
4357DEFUN (ip_ospf_cost,
4358 ip_ospf_cost_addr_cmd,
4359 "ip ospf cost <1-65535> A.B.C.D",
4360 "IP Information\n"
4361 "OSPF interface commands\n"
4362 "Interface cost\n"
4363 "Cost\n"
4364 "Address of interface")
4365{
4366 struct interface *ifp = vty->index;
4367 u_int32_t cost;
4368 struct in_addr addr;
4369 int ret;
4370 struct ospf_if_params *params;
4371
4372 params = IF_DEF_PARAMS (ifp);
4373
4374 cost = strtol (argv[0], NULL, 10);
4375
4376 /* cost range is <1-65535>. */
4377 if (cost < 1 || cost > 65535)
4378 {
4379 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4380 return CMD_WARNING;
4381 }
4382
4383 if (argc == 2)
4384 {
4385 ret = inet_aton(argv[1], &addr);
4386 if (!ret)
4387 {
4388 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4389 VTY_NEWLINE);
4390 return CMD_WARNING;
4391 }
4392
4393 params = ospf_get_if_params (ifp, addr);
4394 ospf_if_update_params (ifp, addr);
4395 }
4396
4397 SET_IF_PARAM (params, output_cost_cmd);
4398 params->output_cost_cmd = cost;
4399
4400 ospf_if_recalculate_output_cost (ifp);
4401
4402 return CMD_SUCCESS;
4403}
4404
4405ALIAS (ip_ospf_cost,
4406 ip_ospf_cost_cmd,
4407 "ip ospf cost <1-65535>",
4408 "IP Information\n"
4409 "OSPF interface commands\n"
4410 "Interface cost\n"
4411 "Cost")
4412
4413ALIAS (ip_ospf_cost,
4414 ospf_cost_cmd,
4415 "ospf cost <1-65535>",
4416 "OSPF interface commands\n"
4417 "Interface cost\n"
4418 "Cost")
4419
4420DEFUN (no_ip_ospf_cost,
4421 no_ip_ospf_cost_addr_cmd,
4422 "no ip ospf cost A.B.C.D",
4423 NO_STR
4424 "IP Information\n"
4425 "OSPF interface commands\n"
4426 "Interface cost\n"
4427 "Address of interface")
4428{
4429 struct interface *ifp = vty->index;
4430 struct in_addr addr;
4431 int ret;
4432 struct ospf_if_params *params;
4433
4434 ifp = vty->index;
4435 params = IF_DEF_PARAMS (ifp);
4436
4437 if (argc == 1)
4438 {
4439 ret = inet_aton(argv[0], &addr);
4440 if (!ret)
4441 {
4442 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4443 VTY_NEWLINE);
4444 return CMD_WARNING;
4445 }
4446
4447 params = ospf_lookup_if_params (ifp, addr);
4448 if (params == NULL)
4449 return CMD_SUCCESS;
4450 }
4451
4452 UNSET_IF_PARAM (params, output_cost_cmd);
4453
4454 if (params != IF_DEF_PARAMS (ifp))
4455 {
4456 ospf_free_if_params (ifp, addr);
4457 ospf_if_update_params (ifp, addr);
4458 }
4459
4460 ospf_if_recalculate_output_cost (ifp);
4461
4462 return CMD_SUCCESS;
4463}
4464
4465ALIAS (no_ip_ospf_cost,
4466 no_ip_ospf_cost_cmd,
4467 "no ip ospf cost",
4468 NO_STR
4469 "IP Information\n"
4470 "OSPF interface commands\n"
4471 "Interface cost\n")
4472
4473ALIAS (no_ip_ospf_cost,
4474 no_ospf_cost_cmd,
4475 "no ospf cost",
4476 NO_STR
4477 "OSPF interface commands\n"
4478 "Interface cost\n")
4479
4480void
4481ospf_nbr_timer_update (struct ospf_interface *oi)
4482{
4483 struct route_node *rn;
4484 struct ospf_neighbor *nbr;
4485
4486 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4487 if ((nbr = rn->info))
4488 {
4489 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4490 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4491 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4492 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4493 }
4494}
4495
4496DEFUN (ip_ospf_dead_interval,
4497 ip_ospf_dead_interval_addr_cmd,
4498 "ip ospf dead-interval <1-65535> A.B.C.D",
4499 "IP Information\n"
4500 "OSPF interface commands\n"
4501 "Interval after which a neighbor is declared dead\n"
4502 "Seconds\n"
4503 "Address of interface")
4504{
4505 struct interface *ifp = vty->index;
4506 u_int32_t seconds;
4507 struct in_addr addr;
4508 int ret;
4509 struct ospf_if_params *params;
4510 struct ospf_interface *oi;
4511 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004512 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004513
paul020709f2003-04-04 02:44:16 +00004514 ospf = ospf_lookup ();
4515
paul718e3742002-12-13 20:15:29 +00004516 params = IF_DEF_PARAMS (ifp);
4517
4518 seconds = strtol (argv[0], NULL, 10);
4519
4520 /* dead_interval range is <1-65535>. */
4521 if (seconds < 1 || seconds > 65535)
4522 {
4523 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4524 return CMD_WARNING;
4525 }
4526
4527 if (argc == 2)
4528 {
4529 ret = inet_aton(argv[1], &addr);
4530 if (!ret)
4531 {
4532 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4533 VTY_NEWLINE);
4534 return CMD_WARNING;
4535 }
4536
4537 params = ospf_get_if_params (ifp, addr);
4538 ospf_if_update_params (ifp, addr);
4539 }
4540
4541 SET_IF_PARAM (params, v_wait);
4542 params->v_wait = seconds;
4543
4544 /* Update timer values in neighbor structure. */
4545 if (argc == 2)
4546 {
paul68980082003-03-25 05:07:42 +00004547 if (ospf)
4548 {
4549 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4550 if (oi)
4551 ospf_nbr_timer_update (oi);
4552 }
paul718e3742002-12-13 20:15:29 +00004553 }
4554 else
4555 {
4556 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4557 if ((oi = rn->info))
4558 ospf_nbr_timer_update (oi);
4559 }
4560
4561 return CMD_SUCCESS;
4562}
4563
4564ALIAS (ip_ospf_dead_interval,
4565 ip_ospf_dead_interval_cmd,
4566 "ip ospf dead-interval <1-65535>",
4567 "IP Information\n"
4568 "OSPF interface commands\n"
4569 "Interval after which a neighbor is declared dead\n"
4570 "Seconds\n")
4571
4572ALIAS (ip_ospf_dead_interval,
4573 ospf_dead_interval_cmd,
4574 "ospf dead-interval <1-65535>",
4575 "OSPF interface commands\n"
4576 "Interval after which a neighbor is declared dead\n"
4577 "Seconds\n")
4578
4579DEFUN (no_ip_ospf_dead_interval,
4580 no_ip_ospf_dead_interval_addr_cmd,
4581 "no ip ospf dead-interval A.B.C.D",
4582 NO_STR
4583 "IP Information\n"
4584 "OSPF interface commands\n"
4585 "Interval after which a neighbor is declared dead\n"
4586 "Address of interface")
4587{
4588 struct interface *ifp = vty->index;
4589 struct in_addr addr;
4590 int ret;
4591 struct ospf_if_params *params;
4592 struct ospf_interface *oi;
4593 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004594 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004595
paul020709f2003-04-04 02:44:16 +00004596 ospf = ospf_lookup ();
4597
paul718e3742002-12-13 20:15:29 +00004598 ifp = vty->index;
4599 params = IF_DEF_PARAMS (ifp);
4600
4601 if (argc == 1)
4602 {
4603 ret = inet_aton(argv[0], &addr);
4604 if (!ret)
4605 {
4606 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4607 VTY_NEWLINE);
4608 return CMD_WARNING;
4609 }
4610
4611 params = ospf_lookup_if_params (ifp, addr);
4612 if (params == NULL)
4613 return CMD_SUCCESS;
4614 }
4615
4616 UNSET_IF_PARAM (params, v_wait);
4617 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4618
4619 if (params != IF_DEF_PARAMS (ifp))
4620 {
4621 ospf_free_if_params (ifp, addr);
4622 ospf_if_update_params (ifp, addr);
4623 }
4624
4625 /* Update timer values in neighbor structure. */
4626 if (argc == 1)
4627 {
paul68980082003-03-25 05:07:42 +00004628 if (ospf)
4629 {
4630 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4631 if (oi)
4632 ospf_nbr_timer_update (oi);
4633 }
paul718e3742002-12-13 20:15:29 +00004634 }
4635 else
4636 {
4637 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4638 if ((oi = rn->info))
4639 ospf_nbr_timer_update (oi);
4640 }
4641
4642 return CMD_SUCCESS;
4643}
4644
4645ALIAS (no_ip_ospf_dead_interval,
4646 no_ip_ospf_dead_interval_cmd,
4647 "no ip ospf dead-interval",
4648 NO_STR
4649 "IP Information\n"
4650 "OSPF interface commands\n"
4651 "Interval after which a neighbor is declared dead\n")
4652
4653ALIAS (no_ip_ospf_dead_interval,
4654 no_ospf_dead_interval_cmd,
4655 "no ospf dead-interval",
4656 NO_STR
4657 "OSPF interface commands\n"
4658 "Interval after which a neighbor is declared dead\n")
4659
4660DEFUN (ip_ospf_hello_interval,
4661 ip_ospf_hello_interval_addr_cmd,
4662 "ip ospf hello-interval <1-65535> A.B.C.D",
4663 "IP Information\n"
4664 "OSPF interface commands\n"
4665 "Time between HELLO packets\n"
4666 "Seconds\n"
4667 "Address of interface")
4668{
4669 struct interface *ifp = vty->index;
4670 u_int32_t seconds;
4671 struct in_addr addr;
4672 int ret;
4673 struct ospf_if_params *params;
4674
4675 params = IF_DEF_PARAMS (ifp);
4676
4677 seconds = strtol (argv[0], NULL, 10);
4678
4679 /* HelloInterval range is <1-65535>. */
4680 if (seconds < 1 || seconds > 65535)
4681 {
4682 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4683 return CMD_WARNING;
4684 }
4685
4686 if (argc == 2)
4687 {
4688 ret = inet_aton(argv[1], &addr);
4689 if (!ret)
4690 {
4691 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4692 VTY_NEWLINE);
4693 return CMD_WARNING;
4694 }
4695
4696 params = ospf_get_if_params (ifp, addr);
4697 ospf_if_update_params (ifp, addr);
4698 }
4699
4700 SET_IF_PARAM (params, v_hello);
4701 params->v_hello = seconds;
4702
4703 return CMD_SUCCESS;
4704}
4705
4706ALIAS (ip_ospf_hello_interval,
4707 ip_ospf_hello_interval_cmd,
4708 "ip ospf hello-interval <1-65535>",
4709 "IP Information\n"
4710 "OSPF interface commands\n"
4711 "Time between HELLO packets\n"
4712 "Seconds\n")
4713
4714ALIAS (ip_ospf_hello_interval,
4715 ospf_hello_interval_cmd,
4716 "ospf hello-interval <1-65535>",
4717 "OSPF interface commands\n"
4718 "Time between HELLO packets\n"
4719 "Seconds\n")
4720
4721DEFUN (no_ip_ospf_hello_interval,
4722 no_ip_ospf_hello_interval_addr_cmd,
4723 "no ip ospf hello-interval A.B.C.D",
4724 NO_STR
4725 "IP Information\n"
4726 "OSPF interface commands\n"
4727 "Time between HELLO packets\n"
4728 "Address of interface")
4729{
4730 struct interface *ifp = vty->index;
4731 struct in_addr addr;
4732 int ret;
4733 struct ospf_if_params *params;
4734
4735 ifp = vty->index;
4736 params = IF_DEF_PARAMS (ifp);
4737
4738 if (argc == 1)
4739 {
4740 ret = inet_aton(argv[0], &addr);
4741 if (!ret)
4742 {
4743 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4744 VTY_NEWLINE);
4745 return CMD_WARNING;
4746 }
4747
4748 params = ospf_lookup_if_params (ifp, addr);
4749 if (params == NULL)
4750 return CMD_SUCCESS;
4751 }
4752
4753 UNSET_IF_PARAM (params, v_hello);
4754 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4755
4756 if (params != IF_DEF_PARAMS (ifp))
4757 {
4758 ospf_free_if_params (ifp, addr);
4759 ospf_if_update_params (ifp, addr);
4760 }
4761
4762 return CMD_SUCCESS;
4763}
4764
4765ALIAS (no_ip_ospf_hello_interval,
4766 no_ip_ospf_hello_interval_cmd,
4767 "no ip ospf hello-interval",
4768 NO_STR
4769 "IP Information\n"
4770 "OSPF interface commands\n"
4771 "Time between HELLO packets\n")
4772
4773ALIAS (no_ip_ospf_hello_interval,
4774 no_ospf_hello_interval_cmd,
4775 "no ospf hello-interval",
4776 NO_STR
4777 "OSPF interface commands\n"
4778 "Time between HELLO packets\n")
4779
4780DEFUN (ip_ospf_network,
4781 ip_ospf_network_cmd,
4782 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4783 "IP Information\n"
4784 "OSPF interface commands\n"
4785 "Network type\n"
4786 "Specify OSPF broadcast multi-access network\n"
4787 "Specify OSPF NBMA network\n"
4788 "Specify OSPF point-to-multipoint network\n"
4789 "Specify OSPF point-to-point network\n")
4790{
4791 struct interface *ifp = vty->index;
4792 int old_type = IF_DEF_PARAMS (ifp)->type;
4793 struct route_node *rn;
4794
4795 if (strncmp (argv[0], "b", 1) == 0)
4796 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4797 else if (strncmp (argv[0], "n", 1) == 0)
4798 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4799 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4800 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4801 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4802 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4803
4804 if (IF_DEF_PARAMS (ifp)->type == old_type)
4805 return CMD_SUCCESS;
4806
4807 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4808
4809 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4810 {
4811 struct ospf_interface *oi = rn->info;
4812
4813 if (!oi)
4814 continue;
4815
4816 oi->type = IF_DEF_PARAMS (ifp)->type;
4817
4818 if (oi->state > ISM_Down)
4819 {
4820 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4821 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4822 }
4823 }
4824
4825 return CMD_SUCCESS;
4826}
4827
4828ALIAS (ip_ospf_network,
4829 ospf_network_cmd,
4830 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4831 "OSPF interface commands\n"
4832 "Network type\n"
4833 "Specify OSPF broadcast multi-access network\n"
4834 "Specify OSPF NBMA network\n"
4835 "Specify OSPF point-to-multipoint network\n"
4836 "Specify OSPF point-to-point network\n")
4837
4838DEFUN (no_ip_ospf_network,
4839 no_ip_ospf_network_cmd,
4840 "no ip ospf network",
4841 NO_STR
4842 "IP Information\n"
4843 "OSPF interface commands\n"
4844 "Network type\n")
4845{
4846 struct interface *ifp = vty->index;
4847 int old_type = IF_DEF_PARAMS (ifp)->type;
4848 struct route_node *rn;
4849
4850 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4851
4852 if (IF_DEF_PARAMS (ifp)->type == old_type)
4853 return CMD_SUCCESS;
4854
4855 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4856 {
4857 struct ospf_interface *oi = rn->info;
4858
4859 if (!oi)
4860 continue;
4861
4862 oi->type = IF_DEF_PARAMS (ifp)->type;
4863
4864 if (oi->state > ISM_Down)
4865 {
4866 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4867 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4868 }
4869 }
4870
4871 return CMD_SUCCESS;
4872}
4873
4874ALIAS (no_ip_ospf_network,
4875 no_ospf_network_cmd,
4876 "no ospf network",
4877 NO_STR
4878 "OSPF interface commands\n"
4879 "Network type\n")
4880
4881DEFUN (ip_ospf_priority,
4882 ip_ospf_priority_addr_cmd,
4883 "ip ospf priority <0-255> A.B.C.D",
4884 "IP Information\n"
4885 "OSPF interface commands\n"
4886 "Router priority\n"
4887 "Priority\n"
4888 "Address of interface")
4889{
4890 struct interface *ifp = vty->index;
4891 u_int32_t priority;
4892 struct route_node *rn;
4893 struct in_addr addr;
4894 int ret;
4895 struct ospf_if_params *params;
4896
4897 params = IF_DEF_PARAMS (ifp);
4898
4899 priority = strtol (argv[0], NULL, 10);
4900
4901 /* Router Priority range is <0-255>. */
4902 if (priority < 0 || priority > 255)
4903 {
4904 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4905 return CMD_WARNING;
4906 }
4907
4908 if (argc == 2)
4909 {
4910 ret = inet_aton(argv[1], &addr);
4911 if (!ret)
4912 {
4913 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4914 VTY_NEWLINE);
4915 return CMD_WARNING;
4916 }
4917
4918 params = ospf_get_if_params (ifp, addr);
4919 ospf_if_update_params (ifp, addr);
4920 }
4921
4922 SET_IF_PARAM (params, priority);
4923 params->priority = priority;
4924
4925 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4926 {
4927 struct ospf_interface *oi = rn->info;
4928
4929 if (!oi)
4930 continue;
4931
4932
4933 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
4934 {
4935 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
4936 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
4937 }
4938 }
4939
4940 return CMD_SUCCESS;
4941}
4942
4943ALIAS (ip_ospf_priority,
4944 ip_ospf_priority_cmd,
4945 "ip ospf priority <0-255>",
4946 "IP Information\n"
4947 "OSPF interface commands\n"
4948 "Router priority\n"
4949 "Priority\n")
4950
4951ALIAS (ip_ospf_priority,
4952 ospf_priority_cmd,
4953 "ospf priority <0-255>",
4954 "OSPF interface commands\n"
4955 "Router priority\n"
4956 "Priority\n")
4957
4958DEFUN (no_ip_ospf_priority,
4959 no_ip_ospf_priority_addr_cmd,
4960 "no ip ospf priority A.B.C.D",
4961 NO_STR
4962 "IP Information\n"
4963 "OSPF interface commands\n"
4964 "Router priority\n"
4965 "Address of interface")
4966{
4967 struct interface *ifp = vty->index;
4968 struct route_node *rn;
4969 struct in_addr addr;
4970 int ret;
4971 struct ospf_if_params *params;
4972
4973 ifp = vty->index;
4974 params = IF_DEF_PARAMS (ifp);
4975
4976 if (argc == 1)
4977 {
4978 ret = inet_aton(argv[0], &addr);
4979 if (!ret)
4980 {
4981 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4982 VTY_NEWLINE);
4983 return CMD_WARNING;
4984 }
4985
4986 params = ospf_lookup_if_params (ifp, addr);
4987 if (params == NULL)
4988 return CMD_SUCCESS;
4989 }
4990
4991 UNSET_IF_PARAM (params, priority);
4992 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
4993
4994 if (params != IF_DEF_PARAMS (ifp))
4995 {
4996 ospf_free_if_params (ifp, addr);
4997 ospf_if_update_params (ifp, addr);
4998 }
4999
5000 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5001 {
5002 struct ospf_interface *oi = rn->info;
5003
5004 if (!oi)
5005 continue;
5006
5007
5008 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5009 {
5010 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5011 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5012 }
5013 }
5014
5015 return CMD_SUCCESS;
5016}
5017
5018ALIAS (no_ip_ospf_priority,
5019 no_ip_ospf_priority_cmd,
5020 "no ip ospf priority",
5021 NO_STR
5022 "IP Information\n"
5023 "OSPF interface commands\n"
5024 "Router priority\n")
5025
5026ALIAS (no_ip_ospf_priority,
5027 no_ospf_priority_cmd,
5028 "no ospf priority",
5029 NO_STR
5030 "OSPF interface commands\n"
5031 "Router priority\n")
5032
5033DEFUN (ip_ospf_retransmit_interval,
5034 ip_ospf_retransmit_interval_addr_cmd,
5035 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5036 "IP Information\n"
5037 "OSPF interface commands\n"
5038 "Time between retransmitting lost link state advertisements\n"
5039 "Seconds\n"
5040 "Address of interface")
5041{
5042 struct interface *ifp = vty->index;
5043 u_int32_t seconds;
5044 struct in_addr addr;
5045 int ret;
5046 struct ospf_if_params *params;
5047
5048 params = IF_DEF_PARAMS (ifp);
5049 seconds = strtol (argv[0], NULL, 10);
5050
5051 /* Retransmit Interval range is <3-65535>. */
5052 if (seconds < 3 || seconds > 65535)
5053 {
5054 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5055 return CMD_WARNING;
5056 }
5057
5058
5059 if (argc == 2)
5060 {
5061 ret = inet_aton(argv[1], &addr);
5062 if (!ret)
5063 {
5064 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5065 VTY_NEWLINE);
5066 return CMD_WARNING;
5067 }
5068
5069 params = ospf_get_if_params (ifp, addr);
5070 ospf_if_update_params (ifp, addr);
5071 }
5072
5073 SET_IF_PARAM (params, retransmit_interval);
5074 params->retransmit_interval = seconds;
5075
5076 return CMD_SUCCESS;
5077}
5078
5079ALIAS (ip_ospf_retransmit_interval,
5080 ip_ospf_retransmit_interval_cmd,
5081 "ip ospf retransmit-interval <3-65535>",
5082 "IP Information\n"
5083 "OSPF interface commands\n"
5084 "Time between retransmitting lost link state advertisements\n"
5085 "Seconds\n")
5086
5087ALIAS (ip_ospf_retransmit_interval,
5088 ospf_retransmit_interval_cmd,
5089 "ospf retransmit-interval <3-65535>",
5090 "OSPF interface commands\n"
5091 "Time between retransmitting lost link state advertisements\n"
5092 "Seconds\n")
5093
5094DEFUN (no_ip_ospf_retransmit_interval,
5095 no_ip_ospf_retransmit_interval_addr_cmd,
5096 "no ip ospf retransmit-interval A.B.C.D",
5097 NO_STR
5098 "IP Information\n"
5099 "OSPF interface commands\n"
5100 "Time between retransmitting lost link state advertisements\n"
5101 "Address of interface")
5102{
5103 struct interface *ifp = vty->index;
5104 struct in_addr addr;
5105 int ret;
5106 struct ospf_if_params *params;
5107
5108 ifp = vty->index;
5109 params = IF_DEF_PARAMS (ifp);
5110
5111 if (argc == 1)
5112 {
5113 ret = inet_aton(argv[0], &addr);
5114 if (!ret)
5115 {
5116 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5117 VTY_NEWLINE);
5118 return CMD_WARNING;
5119 }
5120
5121 params = ospf_lookup_if_params (ifp, addr);
5122 if (params == NULL)
5123 return CMD_SUCCESS;
5124 }
5125
5126 UNSET_IF_PARAM (params, retransmit_interval);
5127 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5128
5129 if (params != IF_DEF_PARAMS (ifp))
5130 {
5131 ospf_free_if_params (ifp, addr);
5132 ospf_if_update_params (ifp, addr);
5133 }
5134
5135 return CMD_SUCCESS;
5136}
5137
5138ALIAS (no_ip_ospf_retransmit_interval,
5139 no_ip_ospf_retransmit_interval_cmd,
5140 "no ip ospf retransmit-interval",
5141 NO_STR
5142 "IP Information\n"
5143 "OSPF interface commands\n"
5144 "Time between retransmitting lost link state advertisements\n")
5145
5146ALIAS (no_ip_ospf_retransmit_interval,
5147 no_ospf_retransmit_interval_cmd,
5148 "no ospf retransmit-interval",
5149 NO_STR
5150 "OSPF interface commands\n"
5151 "Time between retransmitting lost link state advertisements\n")
5152
5153DEFUN (ip_ospf_transmit_delay,
5154 ip_ospf_transmit_delay_addr_cmd,
5155 "ip ospf transmit-delay <1-65535> A.B.C.D",
5156 "IP Information\n"
5157 "OSPF interface commands\n"
5158 "Link state transmit delay\n"
5159 "Seconds\n"
5160 "Address of interface")
5161{
5162 struct interface *ifp = vty->index;
5163 u_int32_t seconds;
5164 struct in_addr addr;
5165 int ret;
5166 struct ospf_if_params *params;
5167
5168 params = IF_DEF_PARAMS (ifp);
5169 seconds = strtol (argv[0], NULL, 10);
5170
5171 /* Transmit Delay range is <1-65535>. */
5172 if (seconds < 1 || seconds > 65535)
5173 {
5174 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5175 return CMD_WARNING;
5176 }
5177
5178 if (argc == 2)
5179 {
5180 ret = inet_aton(argv[1], &addr);
5181 if (!ret)
5182 {
5183 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5184 VTY_NEWLINE);
5185 return CMD_WARNING;
5186 }
5187
5188 params = ospf_get_if_params (ifp, addr);
5189 ospf_if_update_params (ifp, addr);
5190 }
5191
5192 SET_IF_PARAM (params, transmit_delay);
5193 params->transmit_delay = seconds;
5194
5195 return CMD_SUCCESS;
5196}
5197
5198ALIAS (ip_ospf_transmit_delay,
5199 ip_ospf_transmit_delay_cmd,
5200 "ip ospf transmit-delay <1-65535>",
5201 "IP Information\n"
5202 "OSPF interface commands\n"
5203 "Link state transmit delay\n"
5204 "Seconds\n")
5205
5206ALIAS (ip_ospf_transmit_delay,
5207 ospf_transmit_delay_cmd,
5208 "ospf transmit-delay <1-65535>",
5209 "OSPF interface commands\n"
5210 "Link state transmit delay\n"
5211 "Seconds\n")
5212
5213DEFUN (no_ip_ospf_transmit_delay,
5214 no_ip_ospf_transmit_delay_addr_cmd,
5215 "no ip ospf transmit-delay A.B.C.D",
5216 NO_STR
5217 "IP Information\n"
5218 "OSPF interface commands\n"
5219 "Link state transmit delay\n"
5220 "Address of interface")
5221{
5222 struct interface *ifp = vty->index;
5223 struct in_addr addr;
5224 int ret;
5225 struct ospf_if_params *params;
5226
5227 ifp = vty->index;
5228 params = IF_DEF_PARAMS (ifp);
5229
5230 if (argc == 1)
5231 {
5232 ret = inet_aton(argv[0], &addr);
5233 if (!ret)
5234 {
5235 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5236 VTY_NEWLINE);
5237 return CMD_WARNING;
5238 }
5239
5240 params = ospf_lookup_if_params (ifp, addr);
5241 if (params == NULL)
5242 return CMD_SUCCESS;
5243 }
5244
5245 UNSET_IF_PARAM (params, transmit_delay);
5246 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5247
5248 if (params != IF_DEF_PARAMS (ifp))
5249 {
5250 ospf_free_if_params (ifp, addr);
5251 ospf_if_update_params (ifp, addr);
5252 }
5253
5254 return CMD_SUCCESS;
5255}
5256
5257ALIAS (no_ip_ospf_transmit_delay,
5258 no_ip_ospf_transmit_delay_cmd,
5259 "no ip ospf transmit-delay",
5260 NO_STR
5261 "IP Information\n"
5262 "OSPF interface commands\n"
5263 "Link state transmit delay\n")
5264
5265ALIAS (no_ip_ospf_transmit_delay,
5266 no_ospf_transmit_delay_cmd,
5267 "no ospf transmit-delay",
5268 NO_STR
5269 "OSPF interface commands\n"
5270 "Link state transmit delay\n")
5271
5272
5273DEFUN (ospf_redistribute_source_metric_type,
5274 ospf_redistribute_source_metric_type_routemap_cmd,
5275 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5276 "Redistribute information from another routing protocol\n"
5277 "Kernel routes\n"
5278 "Connected\n"
5279 "Static routes\n"
5280 "Routing Information Protocol (RIP)\n"
5281 "Border Gateway Protocol (BGP)\n"
5282 "Metric for redistributed routes\n"
5283 "OSPF default metric\n"
5284 "OSPF exterior metric type for redistributed routes\n"
5285 "Set OSPF External Type 1 metrics\n"
5286 "Set OSPF External Type 2 metrics\n"
5287 "Route map reference\n"
5288 "Pointer to route-map entries\n")
5289{
paul020709f2003-04-04 02:44:16 +00005290 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005291 int source;
5292 int type = -1;
5293 int metric = -1;
5294
5295 /* Get distribute source. */
5296 if (!str2distribute_source (argv[0], &source))
5297 return CMD_WARNING;
5298
5299 /* Get metric value. */
5300 if (argc >= 2)
5301 if (!str2metric (argv[1], &metric))
5302 return CMD_WARNING;
5303
5304 /* Get metric type. */
5305 if (argc >= 3)
5306 if (!str2metric_type (argv[2], &type))
5307 return CMD_WARNING;
5308
5309 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005310 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005311 else
paul020709f2003-04-04 02:44:16 +00005312 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005313
paul020709f2003-04-04 02:44:16 +00005314 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005315}
5316
5317ALIAS (ospf_redistribute_source_metric_type,
5318 ospf_redistribute_source_metric_type_cmd,
5319 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5320 "Redistribute information from another routing protocol\n"
5321 "Kernel routes\n"
5322 "Connected\n"
5323 "Static routes\n"
5324 "Routing Information Protocol (RIP)\n"
5325 "Border Gateway Protocol (BGP)\n"
5326 "Metric for redistributed routes\n"
5327 "OSPF default metric\n"
5328 "OSPF exterior metric type for redistributed routes\n"
5329 "Set OSPF External Type 1 metrics\n"
5330 "Set OSPF External Type 2 metrics\n")
5331
5332ALIAS (ospf_redistribute_source_metric_type,
5333 ospf_redistribute_source_metric_cmd,
5334 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5335 "Redistribute information from another routing protocol\n"
5336 "Kernel routes\n"
5337 "Connected\n"
5338 "Static routes\n"
5339 "Routing Information Protocol (RIP)\n"
5340 "Border Gateway Protocol (BGP)\n"
5341 "Metric for redistributed routes\n"
5342 "OSPF default metric\n")
5343
5344DEFUN (ospf_redistribute_source_type_metric,
5345 ospf_redistribute_source_type_metric_routemap_cmd,
5346 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5347 "Redistribute information from another routing protocol\n"
5348 "Kernel routes\n"
5349 "Connected\n"
5350 "Static routes\n"
5351 "Routing Information Protocol (RIP)\n"
5352 "Border Gateway Protocol (BGP)\n"
5353 "OSPF exterior metric type for redistributed routes\n"
5354 "Set OSPF External Type 1 metrics\n"
5355 "Set OSPF External Type 2 metrics\n"
5356 "Metric for redistributed routes\n"
5357 "OSPF default metric\n"
5358 "Route map reference\n"
5359 "Pointer to route-map entries\n")
5360{
paul020709f2003-04-04 02:44:16 +00005361 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005362 int source;
5363 int type = -1;
5364 int metric = -1;
5365
5366 /* Get distribute source. */
5367 if (!str2distribute_source (argv[0], &source))
5368 return CMD_WARNING;
5369
5370 /* Get metric value. */
5371 if (argc >= 2)
5372 if (!str2metric_type (argv[1], &type))
5373 return CMD_WARNING;
5374
5375 /* Get metric type. */
5376 if (argc >= 3)
5377 if (!str2metric (argv[2], &metric))
5378 return CMD_WARNING;
5379
5380 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005381 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005382 else
paul020709f2003-04-04 02:44:16 +00005383 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005384
paul020709f2003-04-04 02:44:16 +00005385 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005386}
5387
5388ALIAS (ospf_redistribute_source_type_metric,
5389 ospf_redistribute_source_type_metric_cmd,
5390 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5391 "Redistribute information from another routing protocol\n"
5392 "Kernel routes\n"
5393 "Connected\n"
5394 "Static routes\n"
5395 "Routing Information Protocol (RIP)\n"
5396 "Border Gateway Protocol (BGP)\n"
5397 "OSPF exterior metric type for redistributed routes\n"
5398 "Set OSPF External Type 1 metrics\n"
5399 "Set OSPF External Type 2 metrics\n"
5400 "Metric for redistributed routes\n"
5401 "OSPF default metric\n")
5402
5403ALIAS (ospf_redistribute_source_type_metric,
5404 ospf_redistribute_source_type_cmd,
5405 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5406 "Redistribute information from another routing protocol\n"
5407 "Kernel routes\n"
5408 "Connected\n"
5409 "Static routes\n"
5410 "Routing Information Protocol (RIP)\n"
5411 "Border Gateway Protocol (BGP)\n"
5412 "OSPF exterior metric type for redistributed routes\n"
5413 "Set OSPF External Type 1 metrics\n"
5414 "Set OSPF External Type 2 metrics\n")
5415
5416ALIAS (ospf_redistribute_source_type_metric,
5417 ospf_redistribute_source_cmd,
5418 "redistribute (kernel|connected|static|rip|bgp)",
5419 "Redistribute information from another routing protocol\n"
5420 "Kernel routes\n"
5421 "Connected\n"
5422 "Static routes\n"
5423 "Routing Information Protocol (RIP)\n"
5424 "Border Gateway Protocol (BGP)\n")
5425
5426DEFUN (ospf_redistribute_source_metric_routemap,
5427 ospf_redistribute_source_metric_routemap_cmd,
5428 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5429 "Redistribute information from another routing protocol\n"
5430 "Kernel routes\n"
5431 "Connected\n"
5432 "Static routes\n"
5433 "Routing Information Protocol (RIP)\n"
5434 "Border Gateway Protocol (BGP)\n"
5435 "Metric for redistributed routes\n"
5436 "OSPF default metric\n"
5437 "Route map reference\n"
5438 "Pointer to route-map entries\n")
5439{
paul020709f2003-04-04 02:44:16 +00005440 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005441 int source;
5442 int metric = -1;
5443
5444 /* Get distribute source. */
5445 if (!str2distribute_source (argv[0], &source))
5446 return CMD_WARNING;
5447
5448 /* Get metric value. */
5449 if (argc >= 2)
5450 if (!str2metric (argv[1], &metric))
5451 return CMD_WARNING;
5452
5453 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005454 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005455 else
paul020709f2003-04-04 02:44:16 +00005456 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005457
paul020709f2003-04-04 02:44:16 +00005458 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005459}
5460
5461DEFUN (ospf_redistribute_source_type_routemap,
5462 ospf_redistribute_source_type_routemap_cmd,
5463 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5464 "Redistribute information from another routing protocol\n"
5465 "Kernel routes\n"
5466 "Connected\n"
5467 "Static routes\n"
5468 "Routing Information Protocol (RIP)\n"
5469 "Border Gateway Protocol (BGP)\n"
5470 "OSPF exterior metric type for redistributed routes\n"
5471 "Set OSPF External Type 1 metrics\n"
5472 "Set OSPF External Type 2 metrics\n"
5473 "Route map reference\n"
5474 "Pointer to route-map entries\n")
5475{
paul020709f2003-04-04 02:44:16 +00005476 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005477 int source;
5478 int type = -1;
5479
5480 /* Get distribute source. */
5481 if (!str2distribute_source (argv[0], &source))
5482 return CMD_WARNING;
5483
5484 /* Get metric value. */
5485 if (argc >= 2)
5486 if (!str2metric_type (argv[1], &type))
5487 return CMD_WARNING;
5488
5489 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005490 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005491 else
paul020709f2003-04-04 02:44:16 +00005492 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005493
paul020709f2003-04-04 02:44:16 +00005494 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005495}
5496
5497DEFUN (ospf_redistribute_source_routemap,
5498 ospf_redistribute_source_routemap_cmd,
5499 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5500 "Redistribute information from another routing protocol\n"
5501 "Kernel routes\n"
5502 "Connected\n"
5503 "Static routes\n"
5504 "Routing Information Protocol (RIP)\n"
5505 "Border Gateway Protocol (BGP)\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
5512 /* Get distribute source. */
5513 if (!str2distribute_source (argv[0], &source))
5514 return CMD_WARNING;
5515
5516 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005517 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005518 else
paul020709f2003-04-04 02:44:16 +00005519 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005520
paul020709f2003-04-04 02:44:16 +00005521 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005522}
5523
5524DEFUN (no_ospf_redistribute_source,
5525 no_ospf_redistribute_source_cmd,
5526 "no redistribute (kernel|connected|static|rip|bgp)",
5527 NO_STR
5528 "Redistribute information from another routing protocol\n"
5529 "Kernel routes\n"
5530 "Connected\n"
5531 "Static routes\n"
5532 "Routing Information Protocol (RIP)\n"
5533 "Border Gateway Protocol (BGP)\n")
5534{
paul020709f2003-04-04 02:44:16 +00005535 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005536 int source;
5537
5538 if (!str2distribute_source (argv[0], &source))
5539 return CMD_WARNING;
5540
paul020709f2003-04-04 02:44:16 +00005541 ospf_routemap_unset (ospf, source);
5542 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005543}
5544
5545DEFUN (ospf_distribute_list_out,
5546 ospf_distribute_list_out_cmd,
5547 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5548 "Filter networks in routing updates\n"
5549 "Access-list name\n"
5550 OUT_STR
5551 "Kernel routes\n"
5552 "Connected\n"
5553 "Static routes\n"
5554 "Routing Information Protocol (RIP)\n"
5555 "Border Gateway Protocol (BGP)\n")
5556{
paul68980082003-03-25 05:07:42 +00005557 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005558 int source;
5559
5560 /* Get distribute source. */
5561 if (!str2distribute_source (argv[1], &source))
5562 return CMD_WARNING;
5563
paul68980082003-03-25 05:07:42 +00005564 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005565}
5566
5567DEFUN (no_ospf_distribute_list_out,
5568 no_ospf_distribute_list_out_cmd,
5569 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5570 NO_STR
5571 "Filter networks in routing updates\n"
5572 "Access-list name\n"
5573 OUT_STR
5574 "Kernel routes\n"
5575 "Connected\n"
5576 "Static routes\n"
5577 "Routing Information Protocol (RIP)\n"
5578 "Border Gateway Protocol (BGP)\n")
5579{
paul68980082003-03-25 05:07:42 +00005580 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005581 int source;
5582
5583 if (!str2distribute_source (argv[1], &source))
5584 return CMD_WARNING;
5585
paul68980082003-03-25 05:07:42 +00005586 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005587}
5588
5589/* Default information originate. */
5590DEFUN (ospf_default_information_originate_metric_type_routemap,
5591 ospf_default_information_originate_metric_type_routemap_cmd,
5592 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5593 "Control distribution of default information\n"
5594 "Distribute a default route\n"
5595 "OSPF default metric\n"
5596 "OSPF metric\n"
5597 "OSPF metric type for default routes\n"
5598 "Set OSPF External Type 1 metrics\n"
5599 "Set OSPF External Type 2 metrics\n"
5600 "Route map reference\n"
5601 "Pointer to route-map entries\n")
5602{
paul020709f2003-04-04 02:44:16 +00005603 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005604 int type = -1;
5605 int metric = -1;
5606
5607 /* Get metric value. */
5608 if (argc >= 1)
5609 if (!str2metric (argv[0], &metric))
5610 return CMD_WARNING;
5611
5612 /* Get metric type. */
5613 if (argc >= 2)
5614 if (!str2metric_type (argv[1], &type))
5615 return CMD_WARNING;
5616
5617 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005618 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005619 else
paul020709f2003-04-04 02:44:16 +00005620 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005621
paul020709f2003-04-04 02:44:16 +00005622 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5623 type, metric);
paul718e3742002-12-13 20:15:29 +00005624}
5625
5626ALIAS (ospf_default_information_originate_metric_type_routemap,
5627 ospf_default_information_originate_metric_type_cmd,
5628 "default-information originate metric <0-16777214> metric-type (1|2)",
5629 "Control distribution of default information\n"
5630 "Distribute a default route\n"
5631 "OSPF default metric\n"
5632 "OSPF metric\n"
5633 "OSPF metric type for default routes\n"
5634 "Set OSPF External Type 1 metrics\n"
5635 "Set OSPF External Type 2 metrics\n")
5636
5637ALIAS (ospf_default_information_originate_metric_type_routemap,
5638 ospf_default_information_originate_metric_cmd,
5639 "default-information originate metric <0-16777214>",
5640 "Control distribution of default information\n"
5641 "Distribute a default route\n"
5642 "OSPF default metric\n"
5643 "OSPF metric\n")
5644
5645ALIAS (ospf_default_information_originate_metric_type_routemap,
5646 ospf_default_information_originate_cmd,
5647 "default-information originate",
5648 "Control distribution of default information\n"
5649 "Distribute a default route\n")
5650
5651/* Default information originate. */
5652DEFUN (ospf_default_information_originate_metric_routemap,
5653 ospf_default_information_originate_metric_routemap_cmd,
5654 "default-information originate metric <0-16777214> route-map WORD",
5655 "Control distribution of default information\n"
5656 "Distribute a default route\n"
5657 "OSPF default metric\n"
5658 "OSPF metric\n"
5659 "Route map reference\n"
5660 "Pointer to route-map entries\n")
5661{
paul020709f2003-04-04 02:44:16 +00005662 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005663 int metric = -1;
5664
5665 /* Get metric value. */
5666 if (argc >= 1)
5667 if (!str2metric (argv[0], &metric))
5668 return CMD_WARNING;
5669
5670 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005671 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005672 else
paul020709f2003-04-04 02:44:16 +00005673 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005674
paul020709f2003-04-04 02:44:16 +00005675 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5676 -1, metric);
paul718e3742002-12-13 20:15:29 +00005677}
5678
5679/* Default information originate. */
5680DEFUN (ospf_default_information_originate_routemap,
5681 ospf_default_information_originate_routemap_cmd,
5682 "default-information originate route-map WORD",
5683 "Control distribution of default information\n"
5684 "Distribute a default route\n"
5685 "Route map reference\n"
5686 "Pointer to route-map entries\n")
5687{
paul020709f2003-04-04 02:44:16 +00005688 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005689
paul020709f2003-04-04 02:44:16 +00005690 if (argc == 1)
5691 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5692 else
5693 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5694
5695 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005696}
5697
5698DEFUN (ospf_default_information_originate_type_metric_routemap,
5699 ospf_default_information_originate_type_metric_routemap_cmd,
5700 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5701 "Control distribution of default information\n"
5702 "Distribute a default route\n"
5703 "OSPF metric type for default routes\n"
5704 "Set OSPF External Type 1 metrics\n"
5705 "Set OSPF External Type 2 metrics\n"
5706 "OSPF default metric\n"
5707 "OSPF metric\n"
5708 "Route map reference\n"
5709 "Pointer to route-map entries\n")
5710{
paul020709f2003-04-04 02:44:16 +00005711 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005712 int type = -1;
5713 int metric = -1;
5714
5715 /* Get metric type. */
5716 if (argc >= 1)
5717 if (!str2metric_type (argv[0], &type))
5718 return CMD_WARNING;
5719
5720 /* Get metric value. */
5721 if (argc >= 2)
5722 if (!str2metric (argv[1], &metric))
5723 return CMD_WARNING;
5724
5725 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005726 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005727 else
paul020709f2003-04-04 02:44:16 +00005728 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005729
paul020709f2003-04-04 02:44:16 +00005730 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5731 type, metric);
paul718e3742002-12-13 20:15:29 +00005732}
5733
5734ALIAS (ospf_default_information_originate_type_metric_routemap,
5735 ospf_default_information_originate_type_metric_cmd,
5736 "default-information originate metric-type (1|2) metric <0-16777214>",
5737 "Control distribution of default information\n"
5738 "Distribute a default route\n"
5739 "OSPF metric type for default routes\n"
5740 "Set OSPF External Type 1 metrics\n"
5741 "Set OSPF External Type 2 metrics\n"
5742 "OSPF default metric\n"
5743 "OSPF metric\n")
5744
5745ALIAS (ospf_default_information_originate_type_metric_routemap,
5746 ospf_default_information_originate_type_cmd,
5747 "default-information originate metric-type (1|2)",
5748 "Control distribution of default information\n"
5749 "Distribute a default route\n"
5750 "OSPF metric type for default routes\n"
5751 "Set OSPF External Type 1 metrics\n"
5752 "Set OSPF External Type 2 metrics\n")
5753
5754DEFUN (ospf_default_information_originate_type_routemap,
5755 ospf_default_information_originate_type_routemap_cmd,
5756 "default-information originate metric-type (1|2) route-map WORD",
5757 "Control distribution of default information\n"
5758 "Distribute a default route\n"
5759 "OSPF metric type for default routes\n"
5760 "Set OSPF External Type 1 metrics\n"
5761 "Set OSPF External Type 2 metrics\n"
5762 "Route map reference\n"
5763 "Pointer to route-map entries\n")
5764{
paul020709f2003-04-04 02:44:16 +00005765 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005766 int type = -1;
5767
5768 /* Get metric type. */
5769 if (argc >= 1)
5770 if (!str2metric_type (argv[0], &type))
5771 return CMD_WARNING;
5772
5773 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005774 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005775 else
paul020709f2003-04-04 02:44:16 +00005776 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005777
paul020709f2003-04-04 02:44:16 +00005778 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5779 type, -1);
paul718e3742002-12-13 20:15:29 +00005780}
5781
5782DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5783 ospf_default_information_originate_always_metric_type_routemap_cmd,
5784 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5785 "Control distribution of default information\n"
5786 "Distribute a default route\n"
5787 "Always advertise default route\n"
5788 "OSPF default metric\n"
5789 "OSPF metric\n"
5790 "OSPF metric type for default routes\n"
5791 "Set OSPF External Type 1 metrics\n"
5792 "Set OSPF External Type 2 metrics\n"
5793 "Route map reference\n"
5794 "Pointer to route-map entries\n")
5795{
paul020709f2003-04-04 02:44:16 +00005796 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005797 int type = -1;
5798 int metric = -1;
5799
5800 /* Get metric value. */
5801 if (argc >= 1)
5802 if (!str2metric (argv[0], &metric))
5803 return CMD_WARNING;
5804
5805 /* Get metric type. */
5806 if (argc >= 2)
5807 if (!str2metric_type (argv[1], &type))
5808 return CMD_WARNING;
5809
5810 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005811 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005812 else
paul020709f2003-04-04 02:44:16 +00005813 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005814
paul020709f2003-04-04 02:44:16 +00005815 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005816 type, metric);
5817}
5818
5819ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5820 ospf_default_information_originate_always_metric_type_cmd,
5821 "default-information originate always metric <0-16777214> metric-type (1|2)",
5822 "Control distribution of default information\n"
5823 "Distribute a default route\n"
5824 "Always advertise default route\n"
5825 "OSPF default metric\n"
5826 "OSPF metric\n"
5827 "OSPF metric type for default routes\n"
5828 "Set OSPF External Type 1 metrics\n"
5829 "Set OSPF External Type 2 metrics\n")
5830
5831ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5832 ospf_default_information_originate_always_metric_cmd,
5833 "default-information originate always metric <0-16777214>",
5834 "Control distribution of default information\n"
5835 "Distribute a default route\n"
5836 "Always advertise default route\n"
5837 "OSPF default metric\n"
5838 "OSPF metric\n"
5839 "OSPF metric type for default routes\n")
5840
5841ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5842 ospf_default_information_originate_always_cmd,
5843 "default-information originate always",
5844 "Control distribution of default information\n"
5845 "Distribute a default route\n"
5846 "Always advertise default route\n")
5847
5848DEFUN (ospf_default_information_originate_always_metric_routemap,
5849 ospf_default_information_originate_always_metric_routemap_cmd,
5850 "default-information originate always metric <0-16777214> route-map WORD",
5851 "Control distribution of default information\n"
5852 "Distribute a default route\n"
5853 "Always advertise default route\n"
5854 "OSPF default metric\n"
5855 "OSPF metric\n"
5856 "Route map reference\n"
5857 "Pointer to route-map entries\n")
5858{
paul020709f2003-04-04 02:44:16 +00005859 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005860 int metric = -1;
5861
5862 /* Get metric value. */
5863 if (argc >= 1)
5864 if (!str2metric (argv[0], &metric))
5865 return CMD_WARNING;
5866
5867 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005868 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005869 else
paul020709f2003-04-04 02:44:16 +00005870 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005871
paul020709f2003-04-04 02:44:16 +00005872 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5873 -1, metric);
paul718e3742002-12-13 20:15:29 +00005874}
5875
5876DEFUN (ospf_default_information_originate_always_routemap,
5877 ospf_default_information_originate_always_routemap_cmd,
5878 "default-information originate always route-map WORD",
5879 "Control distribution of default information\n"
5880 "Distribute a default route\n"
5881 "Always advertise default route\n"
5882 "Route map reference\n"
5883 "Pointer to route-map entries\n")
5884{
paul020709f2003-04-04 02:44:16 +00005885 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005886
paul020709f2003-04-04 02:44:16 +00005887 if (argc == 1)
5888 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5889 else
5890 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5891
5892 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005893}
5894
5895DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5896 ospf_default_information_originate_always_type_metric_routemap_cmd,
5897 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5898 "Control distribution of default information\n"
5899 "Distribute a default route\n"
5900 "Always advertise default route\n"
5901 "OSPF metric type for default routes\n"
5902 "Set OSPF External Type 1 metrics\n"
5903 "Set OSPF External Type 2 metrics\n"
5904 "OSPF default metric\n"
5905 "OSPF metric\n"
5906 "Route map reference\n"
5907 "Pointer to route-map entries\n")
5908{
paul020709f2003-04-04 02:44:16 +00005909 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005910 int type = -1;
5911 int metric = -1;
5912
5913 /* Get metric type. */
5914 if (argc >= 1)
5915 if (!str2metric_type (argv[0], &type))
5916 return CMD_WARNING;
5917
5918 /* Get metric value. */
5919 if (argc >= 2)
5920 if (!str2metric (argv[1], &metric))
5921 return CMD_WARNING;
5922
5923 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005924 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005925 else
paul020709f2003-04-04 02:44:16 +00005926 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005927
paul020709f2003-04-04 02:44:16 +00005928 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005929 type, metric);
5930}
5931
5932ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5933 ospf_default_information_originate_always_type_metric_cmd,
5934 "default-information originate always metric-type (1|2) metric <0-16777214>",
5935 "Control distribution of default information\n"
5936 "Distribute a default route\n"
5937 "Always advertise default route\n"
5938 "OSPF metric type for default routes\n"
5939 "Set OSPF External Type 1 metrics\n"
5940 "Set OSPF External Type 2 metrics\n"
5941 "OSPF default metric\n"
5942 "OSPF metric\n")
5943
5944ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5945 ospf_default_information_originate_always_type_cmd,
5946 "default-information originate always metric-type (1|2)",
5947 "Control distribution of default information\n"
5948 "Distribute a default route\n"
5949 "Always advertise default route\n"
5950 "OSPF metric type for default routes\n"
5951 "Set OSPF External Type 1 metrics\n"
5952 "Set OSPF External Type 2 metrics\n")
5953
5954DEFUN (ospf_default_information_originate_always_type_routemap,
5955 ospf_default_information_originate_always_type_routemap_cmd,
5956 "default-information originate always metric-type (1|2) route-map WORD",
5957 "Control distribution of default information\n"
5958 "Distribute a default route\n"
5959 "Always advertise default route\n"
5960 "OSPF metric type for default routes\n"
5961 "Set OSPF External Type 1 metrics\n"
5962 "Set OSPF External Type 2 metrics\n"
5963 "Route map reference\n"
5964 "Pointer to route-map entries\n")
5965{
paul020709f2003-04-04 02:44:16 +00005966 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005967 int type = -1;
5968
5969 /* Get metric type. */
5970 if (argc >= 1)
5971 if (!str2metric_type (argv[0], &type))
5972 return CMD_WARNING;
5973
5974 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005975 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005976 else
paul020709f2003-04-04 02:44:16 +00005977 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005978
paul020709f2003-04-04 02:44:16 +00005979 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005980 type, -1);
5981}
5982
5983DEFUN (no_ospf_default_information_originate,
5984 no_ospf_default_information_originate_cmd,
5985 "no default-information originate",
5986 NO_STR
5987 "Control distribution of default information\n"
5988 "Distribute a default route\n")
5989{
paul68980082003-03-25 05:07:42 +00005990 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005991 struct prefix_ipv4 p;
5992 struct in_addr nexthop;
5993
5994 p.family = AF_INET;
5995 p.prefix.s_addr = 0;
5996 p.prefixlen = 0;
5997
paul68980082003-03-25 05:07:42 +00005998 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
paul718e3742002-12-13 20:15:29 +00005999
6000 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6001 ospf_external_info_delete (DEFAULT_ROUTE, p);
6002 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6003 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6004 }
6005
paul020709f2003-04-04 02:44:16 +00006006 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6007 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006008}
6009
6010DEFUN (ospf_default_metric,
6011 ospf_default_metric_cmd,
6012 "default-metric <0-16777214>",
6013 "Set metric of redistributed routes\n"
6014 "Default metric\n")
6015{
paul68980082003-03-25 05:07:42 +00006016 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006017 int metric = -1;
6018
6019 if (!str2metric (argv[0], &metric))
6020 return CMD_WARNING;
6021
paul68980082003-03-25 05:07:42 +00006022 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006023
6024 return CMD_SUCCESS;
6025}
6026
6027DEFUN (no_ospf_default_metric,
6028 no_ospf_default_metric_cmd,
6029 "no default-metric",
6030 NO_STR
6031 "Set metric of redistributed routes\n")
6032{
paul68980082003-03-25 05:07:42 +00006033 struct ospf *ospf = vty->index;
6034
6035 ospf->default_metric = -1;
6036
paul718e3742002-12-13 20:15:29 +00006037 return CMD_SUCCESS;
6038}
6039
6040ALIAS (no_ospf_default_metric,
6041 no_ospf_default_metric_val_cmd,
6042 "no default-metric <0-16777214>",
6043 NO_STR
6044 "Set metric of redistributed routes\n"
6045 "Default metric\n")
6046
6047DEFUN (ospf_distance,
6048 ospf_distance_cmd,
6049 "distance <1-255>",
6050 "Define an administrative distance\n"
6051 "OSPF Administrative distance\n")
6052{
paul68980082003-03-25 05:07:42 +00006053 struct ospf *ospf = vty->index;
6054
6055 ospf->distance_all = atoi (argv[0]);
6056
paul718e3742002-12-13 20:15:29 +00006057 return CMD_SUCCESS;
6058}
6059
6060DEFUN (no_ospf_distance,
6061 no_ospf_distance_cmd,
6062 "no distance <1-255>",
6063 NO_STR
6064 "Define an administrative distance\n"
6065 "OSPF Administrative distance\n")
6066{
paul68980082003-03-25 05:07:42 +00006067 struct ospf *ospf = vty->index;
6068
6069 ospf->distance_all = 0;
6070
paul718e3742002-12-13 20:15:29 +00006071 return CMD_SUCCESS;
6072}
6073
6074DEFUN (no_ospf_distance_ospf,
6075 no_ospf_distance_ospf_cmd,
6076 "no distance ospf",
6077 NO_STR
6078 "Define an administrative distance\n"
6079 "OSPF Administrative distance\n"
6080 "OSPF Distance\n")
6081{
paul68980082003-03-25 05:07:42 +00006082 struct ospf *ospf = vty->index;
6083
6084 ospf->distance_intra = 0;
6085 ospf->distance_inter = 0;
6086 ospf->distance_external = 0;
6087
paul718e3742002-12-13 20:15:29 +00006088 return CMD_SUCCESS;
6089}
6090
6091DEFUN (ospf_distance_ospf_intra,
6092 ospf_distance_ospf_intra_cmd,
6093 "distance ospf intra-area <1-255>",
6094 "Define an administrative distance\n"
6095 "OSPF Administrative distance\n"
6096 "Intra-area routes\n"
6097 "Distance for intra-area routes\n")
6098{
paul68980082003-03-25 05:07:42 +00006099 struct ospf *ospf = vty->index;
6100
6101 ospf->distance_intra = atoi (argv[0]);
6102
paul718e3742002-12-13 20:15:29 +00006103 return CMD_SUCCESS;
6104}
6105
6106DEFUN (ospf_distance_ospf_intra_inter,
6107 ospf_distance_ospf_intra_inter_cmd,
6108 "distance ospf intra-area <1-255> inter-area <1-255>",
6109 "Define an administrative distance\n"
6110 "OSPF Administrative distance\n"
6111 "Intra-area routes\n"
6112 "Distance for intra-area routes\n"
6113 "Inter-area routes\n"
6114 "Distance for inter-area routes\n")
6115{
paul68980082003-03-25 05:07:42 +00006116 struct ospf *ospf = vty->index;
6117
6118 ospf->distance_intra = atoi (argv[0]);
6119 ospf->distance_inter = atoi (argv[1]);
6120
paul718e3742002-12-13 20:15:29 +00006121 return CMD_SUCCESS;
6122}
6123
6124DEFUN (ospf_distance_ospf_intra_external,
6125 ospf_distance_ospf_intra_external_cmd,
6126 "distance ospf intra-area <1-255> external <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 "External routes\n"
6132 "Distance for external routes\n")
6133{
paul68980082003-03-25 05:07:42 +00006134 struct ospf *ospf = vty->index;
6135
6136 ospf->distance_intra = atoi (argv[0]);
6137 ospf->distance_external = atoi (argv[1]);
6138
paul718e3742002-12-13 20:15:29 +00006139 return CMD_SUCCESS;
6140}
6141
6142DEFUN (ospf_distance_ospf_intra_inter_external,
6143 ospf_distance_ospf_intra_inter_external_cmd,
6144 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6145 "Define an administrative distance\n"
6146 "OSPF Administrative distance\n"
6147 "Intra-area routes\n"
6148 "Distance for intra-area routes\n"
6149 "Inter-area routes\n"
6150 "Distance for inter-area routes\n"
6151 "External routes\n"
6152 "Distance for external routes\n")
6153{
paul68980082003-03-25 05:07:42 +00006154 struct ospf *ospf = vty->index;
6155
6156 ospf->distance_intra = atoi (argv[0]);
6157 ospf->distance_inter = atoi (argv[1]);
6158 ospf->distance_external = atoi (argv[2]);
6159
paul718e3742002-12-13 20:15:29 +00006160 return CMD_SUCCESS;
6161}
6162
6163DEFUN (ospf_distance_ospf_intra_external_inter,
6164 ospf_distance_ospf_intra_external_inter_cmd,
6165 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6166 "Define an administrative distance\n"
6167 "OSPF Administrative distance\n"
6168 "Intra-area routes\n"
6169 "Distance for intra-area routes\n"
6170 "External routes\n"
6171 "Distance for external routes\n"
6172 "Inter-area routes\n"
6173 "Distance for inter-area routes\n")
6174{
paul68980082003-03-25 05:07:42 +00006175 struct ospf *ospf = vty->index;
6176
6177 ospf->distance_intra = atoi (argv[0]);
6178 ospf->distance_external = atoi (argv[1]);
6179 ospf->distance_inter = atoi (argv[2]);
6180
paul718e3742002-12-13 20:15:29 +00006181 return CMD_SUCCESS;
6182}
6183
6184DEFUN (ospf_distance_ospf_inter,
6185 ospf_distance_ospf_inter_cmd,
6186 "distance ospf inter-area <1-255>",
6187 "Define an administrative distance\n"
6188 "OSPF Administrative distance\n"
6189 "Inter-area routes\n"
6190 "Distance for inter-area routes\n")
6191{
paul68980082003-03-25 05:07:42 +00006192 struct ospf *ospf = vty->index;
6193
6194 ospf->distance_inter = atoi (argv[0]);
6195
paul718e3742002-12-13 20:15:29 +00006196 return CMD_SUCCESS;
6197}
6198
6199DEFUN (ospf_distance_ospf_inter_intra,
6200 ospf_distance_ospf_inter_intra_cmd,
6201 "distance ospf inter-area <1-255> intra-area <1-255>",
6202 "Define an administrative distance\n"
6203 "OSPF Administrative distance\n"
6204 "Inter-area routes\n"
6205 "Distance for inter-area routes\n"
6206 "Intra-area routes\n"
6207 "Distance for intra-area routes\n")
6208{
paul68980082003-03-25 05:07:42 +00006209 struct ospf *ospf = vty->index;
6210
6211 ospf->distance_inter = atoi (argv[0]);
6212 ospf->distance_intra = atoi (argv[1]);
6213
paul718e3742002-12-13 20:15:29 +00006214 return CMD_SUCCESS;
6215}
6216
6217DEFUN (ospf_distance_ospf_inter_external,
6218 ospf_distance_ospf_inter_external_cmd,
6219 "distance ospf inter-area <1-255> external <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 "External routes\n"
6225 "Distance for external routes\n")
6226{
paul68980082003-03-25 05:07:42 +00006227 struct ospf *ospf = vty->index;
6228
6229 ospf->distance_inter = atoi (argv[0]);
6230 ospf->distance_external = atoi (argv[1]);
6231
paul718e3742002-12-13 20:15:29 +00006232 return CMD_SUCCESS;
6233}
6234
6235DEFUN (ospf_distance_ospf_inter_intra_external,
6236 ospf_distance_ospf_inter_intra_external_cmd,
6237 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6238 "Define an administrative distance\n"
6239 "OSPF Administrative distance\n"
6240 "Inter-area routes\n"
6241 "Distance for inter-area routes\n"
6242 "Intra-area routes\n"
6243 "Distance for intra-area routes\n"
6244 "External routes\n"
6245 "Distance for external routes\n")
6246{
paul68980082003-03-25 05:07:42 +00006247 struct ospf *ospf = vty->index;
6248
6249 ospf->distance_inter = atoi (argv[0]);
6250 ospf->distance_intra = atoi (argv[1]);
6251 ospf->distance_external = atoi (argv[2]);
6252
paul718e3742002-12-13 20:15:29 +00006253 return CMD_SUCCESS;
6254}
6255
6256DEFUN (ospf_distance_ospf_inter_external_intra,
6257 ospf_distance_ospf_inter_external_intra_cmd,
6258 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6259 "Define an administrative distance\n"
6260 "OSPF Administrative distance\n"
6261 "Inter-area routes\n"
6262 "Distance for inter-area routes\n"
6263 "External routes\n"
6264 "Distance for external routes\n"
6265 "Intra-area routes\n"
6266 "Distance for intra-area routes\n")
6267{
paul68980082003-03-25 05:07:42 +00006268 struct ospf *ospf = vty->index;
6269
6270 ospf->distance_inter = atoi (argv[0]);
6271 ospf->distance_external = atoi (argv[1]);
6272 ospf->distance_intra = atoi (argv[2]);
6273
paul718e3742002-12-13 20:15:29 +00006274 return CMD_SUCCESS;
6275}
6276
6277DEFUN (ospf_distance_ospf_external,
6278 ospf_distance_ospf_external_cmd,
6279 "distance ospf external <1-255>",
6280 "Define an administrative distance\n"
6281 "OSPF Administrative distance\n"
6282 "External routes\n"
6283 "Distance for external routes\n")
6284{
paul68980082003-03-25 05:07:42 +00006285 struct ospf *ospf = vty->index;
6286
6287 ospf->distance_external = atoi (argv[0]);
6288
paul718e3742002-12-13 20:15:29 +00006289 return CMD_SUCCESS;
6290}
6291
6292DEFUN (ospf_distance_ospf_external_intra,
6293 ospf_distance_ospf_external_intra_cmd,
6294 "distance ospf external <1-255> intra-area <1-255>",
6295 "Define an administrative distance\n"
6296 "OSPF Administrative distance\n"
6297 "External routes\n"
6298 "Distance for external routes\n"
6299 "Intra-area routes\n"
6300 "Distance for intra-area routes\n")
6301{
paul68980082003-03-25 05:07:42 +00006302 struct ospf *ospf = vty->index;
6303
6304 ospf->distance_external = atoi (argv[0]);
6305 ospf->distance_intra = atoi (argv[1]);
6306
paul718e3742002-12-13 20:15:29 +00006307 return CMD_SUCCESS;
6308}
6309
6310DEFUN (ospf_distance_ospf_external_inter,
6311 ospf_distance_ospf_external_inter_cmd,
6312 "distance ospf external <1-255> inter-area <1-255>",
6313 "Define an administrative distance\n"
6314 "OSPF Administrative distance\n"
6315 "External routes\n"
6316 "Distance for external routes\n"
6317 "Inter-area routes\n"
6318 "Distance for inter-area routes\n")
6319{
paul68980082003-03-25 05:07:42 +00006320 struct ospf *ospf = vty->index;
6321
6322 ospf->distance_external = atoi (argv[0]);
6323 ospf->distance_inter = atoi (argv[1]);
6324
paul718e3742002-12-13 20:15:29 +00006325 return CMD_SUCCESS;
6326}
6327
6328DEFUN (ospf_distance_ospf_external_intra_inter,
6329 ospf_distance_ospf_external_intra_inter_cmd,
6330 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6331 "Define an administrative distance\n"
6332 "OSPF Administrative distance\n"
6333 "External routes\n"
6334 "Distance for external routes\n"
6335 "Intra-area routes\n"
6336 "Distance for intra-area routes\n"
6337 "Inter-area routes\n"
6338 "Distance for inter-area routes\n")
6339{
paul68980082003-03-25 05:07:42 +00006340 struct ospf *ospf = vty->index;
6341
6342 ospf->distance_external = atoi (argv[0]);
6343 ospf->distance_intra = atoi (argv[1]);
6344 ospf->distance_inter = atoi (argv[2]);
6345
paul718e3742002-12-13 20:15:29 +00006346 return CMD_SUCCESS;
6347}
6348
6349DEFUN (ospf_distance_ospf_external_inter_intra,
6350 ospf_distance_ospf_external_inter_intra_cmd,
6351 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6352 "Define an administrative distance\n"
6353 "OSPF Administrative distance\n"
6354 "External routes\n"
6355 "Distance for external routes\n"
6356 "Inter-area routes\n"
6357 "Distance for inter-area routes\n"
6358 "Intra-area routes\n"
6359 "Distance for intra-area routes\n")
6360{
paul68980082003-03-25 05:07:42 +00006361 struct ospf *ospf = vty->index;
6362
6363 ospf->distance_external = atoi (argv[0]);
6364 ospf->distance_inter = atoi (argv[1]);
6365 ospf->distance_intra = atoi (argv[2]);
6366
paul718e3742002-12-13 20:15:29 +00006367 return CMD_SUCCESS;
6368}
6369
6370DEFUN (ospf_distance_source,
6371 ospf_distance_source_cmd,
6372 "distance <1-255> A.B.C.D/M",
6373 "Administrative distance\n"
6374 "Distance value\n"
6375 "IP source prefix\n")
6376{
paul020709f2003-04-04 02:44:16 +00006377 struct ospf *ospf = vty->index;
6378
6379 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006380
paul718e3742002-12-13 20:15:29 +00006381 return CMD_SUCCESS;
6382}
6383
6384DEFUN (no_ospf_distance_source,
6385 no_ospf_distance_source_cmd,
6386 "no distance <1-255> A.B.C.D/M",
6387 NO_STR
6388 "Administrative distance\n"
6389 "Distance value\n"
6390 "IP source prefix\n")
6391{
paul020709f2003-04-04 02:44:16 +00006392 struct ospf *ospf = vty->index;
6393
6394 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6395
paul718e3742002-12-13 20:15:29 +00006396 return CMD_SUCCESS;
6397}
6398
6399DEFUN (ospf_distance_source_access_list,
6400 ospf_distance_source_access_list_cmd,
6401 "distance <1-255> A.B.C.D/M WORD",
6402 "Administrative distance\n"
6403 "Distance value\n"
6404 "IP source prefix\n"
6405 "Access list name\n")
6406{
paul020709f2003-04-04 02:44:16 +00006407 struct ospf *ospf = vty->index;
6408
6409 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6410
paul718e3742002-12-13 20:15:29 +00006411 return CMD_SUCCESS;
6412}
6413
6414DEFUN (no_ospf_distance_source_access_list,
6415 no_ospf_distance_source_access_list_cmd,
6416 "no distance <1-255> A.B.C.D/M WORD",
6417 NO_STR
6418 "Administrative distance\n"
6419 "Distance value\n"
6420 "IP source prefix\n"
6421 "Access list name\n")
6422{
paul020709f2003-04-04 02:44:16 +00006423 struct ospf *ospf = vty->index;
6424
6425 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6426
paul718e3742002-12-13 20:15:29 +00006427 return CMD_SUCCESS;
6428}
6429
6430void
6431show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6432{
6433 struct route_node *rn;
6434 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006435 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006436 struct ospf_path *path;
6437
6438 vty_out (vty, "============ OSPF network routing table ============%s",
6439 VTY_NEWLINE);
6440
6441 for (rn = route_top (rt); rn; rn = route_next (rn))
6442 if ((or = rn->info) != NULL)
6443 {
6444 char buf1[19];
6445 snprintf (buf1, 19, "%s/%d",
6446 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6447
6448 switch (or->path_type)
6449 {
6450 case OSPF_PATH_INTER_AREA:
6451 if (or->type == OSPF_DESTINATION_NETWORK)
6452 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6453 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6454 else if (or->type == OSPF_DESTINATION_DISCARD)
6455 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6456 break;
6457 case OSPF_PATH_INTRA_AREA:
6458 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6459 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6460 break;
6461 default:
6462 break;
6463 }
6464
6465 if (or->type == OSPF_DESTINATION_NETWORK)
paul96735ee2003-08-10 02:51:22 +00006466 LIST_LOOP (or->paths, path, pnode)
6467 {
6468 if (path->oi != NULL)
6469 {
6470 if (path->nexthop.s_addr == 0)
6471 vty_out (vty, "%24s directly attached to %s%s",
6472 "", path->oi->ifp->name, VTY_NEWLINE);
6473 else
6474 vty_out (vty, "%24s via %s, %s%s", "",
6475 inet_ntoa (path->nexthop), path->oi->ifp->name,
6476 VTY_NEWLINE);
6477 }
6478 }
paul718e3742002-12-13 20:15:29 +00006479 }
6480 vty_out (vty, "%s", VTY_NEWLINE);
6481}
6482
6483void
6484show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6485{
6486 struct route_node *rn;
6487 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006488 struct listnode *pn, *nn;
paul718e3742002-12-13 20:15:29 +00006489 struct ospf_path *path;
6490
6491 vty_out (vty, "============ OSPF router routing table =============%s",
6492 VTY_NEWLINE);
6493 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6494 if (rn->info)
6495 {
6496 int flag = 0;
6497
6498 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6499
hasso52dc7ee2004-09-23 19:18:23 +00006500 for (nn = listhead ((struct list *) rn->info); nn; nextnode (nn))
paul718e3742002-12-13 20:15:29 +00006501 if ((or = getdata (nn)) != NULL)
6502 {
6503 if (flag++)
paulb0a053b2003-06-22 09:04:47 +00006504 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006505
6506 /* Show path. */
6507 vty_out (vty, "%s [%d] area: %s",
6508 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6509 or->cost, inet_ntoa (or->u.std.area_id));
6510 /* Show flags. */
6511 vty_out (vty, "%s%s%s",
6512 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6513 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6514 VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006515
6516 LIST_LOOP (or->paths, path, pn)
6517 {
6518 if (path->nexthop.s_addr == 0)
6519 vty_out (vty, "%24s directly attached to %s%s",
6520 "", path->oi->ifp->name, VTY_NEWLINE);
6521 else
6522 vty_out (vty, "%24s via %s, %s%s", "",
6523 inet_ntoa (path->nexthop), path->oi->ifp->name,
6524 VTY_NEWLINE);
6525 }
paul718e3742002-12-13 20:15:29 +00006526 }
6527 }
6528 vty_out (vty, "%s", VTY_NEWLINE);
6529}
6530
6531void
6532show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6533{
6534 struct route_node *rn;
6535 struct ospf_route *er;
hasso52dc7ee2004-09-23 19:18:23 +00006536 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006537 struct ospf_path *path;
6538
6539 vty_out (vty, "============ OSPF external routing table ===========%s",
6540 VTY_NEWLINE);
6541 for (rn = route_top (rt); rn; rn = route_next (rn))
6542 if ((er = rn->info) != NULL)
6543 {
6544 char buf1[19];
6545 snprintf (buf1, 19, "%s/%d",
6546 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6547
6548 switch (er->path_type)
6549 {
6550 case OSPF_PATH_TYPE1_EXTERNAL:
6551 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6552 er->cost, er->u.ext.tag, VTY_NEWLINE);
6553 break;
6554 case OSPF_PATH_TYPE2_EXTERNAL:
6555 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6556 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6557 break;
6558 }
6559
paul96735ee2003-08-10 02:51:22 +00006560 LIST_LOOP (er->paths, path, pnode)
paul718e3742002-12-13 20:15:29 +00006561 {
paul718e3742002-12-13 20:15:29 +00006562 if (path->oi != NULL)
6563 {
6564 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006565 vty_out (vty, "%24s directly attached to %s%s",
6566 "", path->oi->ifp->name, VTY_NEWLINE);
6567 else
6568 vty_out (vty, "%24s via %s, %s%s", "",
6569 inet_ntoa (path->nexthop), path->oi->ifp->name,
6570 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006571 }
6572 }
6573 }
6574 vty_out (vty, "%s", VTY_NEWLINE);
6575}
6576
paul718e3742002-12-13 20:15:29 +00006577DEFUN (show_ip_ospf_border_routers,
6578 show_ip_ospf_border_routers_cmd,
6579 "show ip ospf border-routers",
6580 SHOW_STR
6581 IP_STR
6582 "show all the ABR's and ASBR's\n"
6583 "for this area\n")
6584{
paul020709f2003-04-04 02:44:16 +00006585 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006586
paul020709f2003-04-04 02:44:16 +00006587 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006588 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006589 {
6590 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6591 return CMD_SUCCESS;
6592 }
6593
paul68980082003-03-25 05:07:42 +00006594 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006595 {
6596 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6597 return CMD_SUCCESS;
6598 }
6599
6600 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006601 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006602
6603 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006604 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006605
6606 return CMD_SUCCESS;
6607}
paul718e3742002-12-13 20:15:29 +00006608
6609DEFUN (show_ip_ospf_route,
6610 show_ip_ospf_route_cmd,
6611 "show ip ospf route",
6612 SHOW_STR
6613 IP_STR
6614 "OSPF information\n"
6615 "OSPF routing table\n")
6616{
paul020709f2003-04-04 02:44:16 +00006617 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006618
paul020709f2003-04-04 02:44:16 +00006619 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006620 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006621 {
6622 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6623 return CMD_SUCCESS;
6624 }
6625
paul68980082003-03-25 05:07:42 +00006626 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006627 {
6628 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6629 return CMD_SUCCESS;
6630 }
6631
6632 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006633 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006634
6635 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006636 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006637
6638 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006639 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006640
6641 return CMD_SUCCESS;
6642}
6643
6644
hassoeb1ce602004-10-08 08:17:22 +00006645const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006646{
6647 "unknown",
6648 "standard",
6649 "ibm",
6650 "cisco",
6651 "shortcut"
6652};
6653
hassoeb1ce602004-10-08 08:17:22 +00006654const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006655{
6656 "default",
6657 "enable",
6658 "disable"
6659};
6660
6661
6662void
6663area_id2str (char *buf, int length, struct ospf_area *area)
6664{
6665 memset (buf, 0, length);
6666
6667 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6668 strncpy (buf, inet_ntoa (area->area_id), length);
6669 else
6670 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6671}
6672
6673
hassoeb1ce602004-10-08 08:17:22 +00006674const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006675{
6676 "unknown", /* should never be used. */
6677 "point-to-point",
6678 "broadcast",
6679 "non-broadcast",
6680 "point-to-multipoint",
6681 "virtual-link", /* should never be used. */
6682 "loopback"
6683};
6684
6685/* Configuration write function for ospfd. */
6686int
6687config_write_interface (struct vty *vty)
6688{
hasso52dc7ee2004-09-23 19:18:23 +00006689 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006690 struct interface *ifp;
6691 struct crypt_key *ck;
6692 int write = 0;
6693 struct route_node *rn = NULL;
6694 struct ospf_if_params *params;
6695
6696 for (n1 = listhead (iflist); n1; nextnode (n1))
6697 {
6698 ifp = getdata (n1);
6699
6700 if (memcmp (ifp->name, "VLINK", 5) == 0)
6701 continue;
6702
6703 vty_out (vty, "!%s", VTY_NEWLINE);
6704 vty_out (vty, "interface %s%s", ifp->name,
6705 VTY_NEWLINE);
6706 if (ifp->desc)
6707 vty_out (vty, " description %s%s", ifp->desc,
6708 VTY_NEWLINE);
6709
6710 write++;
6711
6712 params = IF_DEF_PARAMS (ifp);
6713
6714 do {
6715 /* Interface Network print. */
6716 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006717 params->type != OSPF_IFTYPE_LOOPBACK)
6718 {
hasso7b901432004-08-31 13:37:42 +00006719 if ((!if_is_broadcast(ifp)) &&
6720 (params->type != OSPF_IFTYPE_BROADCAST))
6721 {
6722 vty_out (vty, " ip ospf network %s",
6723 ospf_int_type_str[params->type]);
6724 if (params != IF_DEF_PARAMS (ifp))
6725 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6726 vty_out (vty, "%s", VTY_NEWLINE);
6727 }
paul718e3742002-12-13 20:15:29 +00006728 }
6729
6730 /* OSPF interface authentication print */
6731 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6732 params->auth_type != OSPF_AUTH_NOTSET)
6733 {
hassoeb1ce602004-10-08 08:17:22 +00006734 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006735
6736 /* Translation tables are not that much help here due to syntax
6737 of the simple option */
6738 switch (params->auth_type)
6739 {
6740
6741 case OSPF_AUTH_NULL:
6742 auth_str = " null";
6743 break;
6744
6745 case OSPF_AUTH_SIMPLE:
6746 auth_str = "";
6747 break;
6748
6749 case OSPF_AUTH_CRYPTOGRAPHIC:
6750 auth_str = " message-digest";
6751 break;
6752
6753 default:
6754 auth_str = "";
6755 break;
6756 }
6757
6758 vty_out (vty, " ip ospf authentication%s", auth_str);
6759 if (params != IF_DEF_PARAMS (ifp))
6760 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6761 vty_out (vty, "%s", VTY_NEWLINE);
6762 }
6763
6764 /* Simple Authentication Password print. */
6765 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6766 params->auth_simple[0] != '\0')
6767 {
6768 vty_out (vty, " ip ospf authentication-key %s",
6769 params->auth_simple);
6770 if (params != IF_DEF_PARAMS (ifp))
6771 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6772 vty_out (vty, "%s", VTY_NEWLINE);
6773 }
6774
6775 /* Cryptographic Authentication Key print. */
6776 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
6777 {
6778 ck = getdata (n2);
6779 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6780 ck->key_id, ck->auth_key);
6781 if (params != IF_DEF_PARAMS (ifp))
6782 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6783 vty_out (vty, "%s", VTY_NEWLINE);
6784 }
6785
6786 /* Interface Output Cost print. */
6787 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6788 {
6789 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6790 if (params != IF_DEF_PARAMS (ifp))
6791 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6792 vty_out (vty, "%s", VTY_NEWLINE);
6793 }
6794
6795 /* Hello Interval print. */
6796 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6797 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6798 {
6799 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6800 if (params != IF_DEF_PARAMS (ifp))
6801 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6802 vty_out (vty, "%s", VTY_NEWLINE);
6803 }
6804
6805
6806 /* Router Dead Interval print. */
6807 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6808 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6809 {
6810 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6811 if (params != IF_DEF_PARAMS (ifp))
6812 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6813 vty_out (vty, "%s", VTY_NEWLINE);
6814 }
6815
6816 /* Router Priority print. */
6817 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6818 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6819 {
6820 vty_out (vty, " ip ospf priority %u", params->priority);
6821 if (params != IF_DEF_PARAMS (ifp))
6822 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6823 vty_out (vty, "%s", VTY_NEWLINE);
6824 }
6825
6826 /* Retransmit Interval print. */
6827 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6828 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6829 {
6830 vty_out (vty, " ip ospf retransmit-interval %u",
6831 params->retransmit_interval);
6832 if (params != IF_DEF_PARAMS (ifp))
6833 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6834 vty_out (vty, "%s", VTY_NEWLINE);
6835 }
6836
6837 /* Transmit Delay print. */
6838 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6839 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6840 {
6841 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6842 if (params != IF_DEF_PARAMS (ifp))
6843 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6844 vty_out (vty, "%s", VTY_NEWLINE);
6845 }
6846
6847 while (1)
6848 {
6849 if (rn == NULL)
6850 rn = route_top (IF_OIFS_PARAMS (ifp));
6851 else
6852 rn = route_next (rn);
6853
6854 if (rn == NULL)
6855 break;
6856 params = rn->info;
6857 if (params != NULL)
6858 break;
6859 }
6860 } while (rn);
6861
6862#ifdef HAVE_OPAQUE_LSA
6863 ospf_opaque_config_write_if (vty, ifp);
6864#endif /* HAVE_OPAQUE_LSA */
6865 }
6866
6867 return write;
6868}
6869
6870int
paul68980082003-03-25 05:07:42 +00006871config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006872{
6873 struct route_node *rn;
6874 u_char buf[INET_ADDRSTRLEN];
6875
6876 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006877 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006878 if (rn->info)
6879 {
6880 struct ospf_network *n = rn->info;
6881
6882 memset (buf, 0, INET_ADDRSTRLEN);
6883
6884 /* Create Area ID string by specified Area ID format. */
6885 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00006886 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00006887 else
hassoc9e52be2004-09-26 16:09:34 +00006888 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00006889 (unsigned long int) ntohl (n->area_id.s_addr));
6890
6891 /* Network print. */
6892 vty_out (vty, " network %s/%d area %s%s",
6893 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6894 buf, VTY_NEWLINE);
6895 }
6896
6897 return 0;
6898}
6899
6900int
paul68980082003-03-25 05:07:42 +00006901config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006902{
hasso52dc7ee2004-09-23 19:18:23 +00006903 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006904 u_char buf[INET_ADDRSTRLEN];
6905
6906 /* Area configuration print. */
paul68980082003-03-25 05:07:42 +00006907 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00006908 {
6909 struct ospf_area *area = getdata (node);
6910 struct route_node *rn1;
6911
hassoc9e52be2004-09-26 16:09:34 +00006912 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00006913
6914 if (area->auth_type != OSPF_AUTH_NULL)
6915 {
6916 if (area->auth_type == OSPF_AUTH_SIMPLE)
6917 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6918 else
6919 vty_out (vty, " area %s authentication message-digest%s",
6920 buf, VTY_NEWLINE);
6921 }
6922
6923 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6924 vty_out (vty, " area %s shortcut %s%s", buf,
6925 ospf_shortcut_mode_str[area->shortcut_configured],
6926 VTY_NEWLINE);
6927
6928 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006929 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00006930 )
6931 {
paulb0a053b2003-06-22 09:04:47 +00006932 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006933 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00006934 else if (area->external_routing == OSPF_AREA_NSSA)
6935 {
6936 vty_out (vty, " area %s nssa", buf);
6937 switch (area->NSSATranslatorRole)
6938 {
6939 case OSPF_NSSA_ROLE_NEVER:
6940 vty_out (vty, " translate-never");
6941 break;
6942 case OSPF_NSSA_ROLE_ALWAYS:
6943 vty_out (vty, " translate-always");
6944 break;
6945 case OSPF_NSSA_ROLE_CANDIDATE:
6946 default:
6947 vty_out (vty, " translate-candidate");
6948 }
6949 }
paul718e3742002-12-13 20:15:29 +00006950
6951 if (area->no_summary)
6952 vty_out (vty, " no-summary");
6953
6954 vty_out (vty, "%s", VTY_NEWLINE);
6955
6956 if (area->default_cost != 1)
6957 vty_out (vty, " area %s default-cost %d%s", buf,
6958 area->default_cost, VTY_NEWLINE);
6959 }
6960
6961 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
6962 if (rn1->info)
6963 {
6964 struct ospf_area_range *range = rn1->info;
6965
6966 vty_out (vty, " area %s range %s/%d", buf,
6967 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
6968
paul6c835672004-10-11 11:00:30 +00006969 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00006970 vty_out (vty, " cost %d", range->cost_config);
6971
6972 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
6973 vty_out (vty, " not-advertise");
6974
6975 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
6976 vty_out (vty, " substitute %s/%d",
6977 inet_ntoa (range->subst_addr), range->subst_masklen);
6978
6979 vty_out (vty, "%s", VTY_NEWLINE);
6980 }
6981
6982 if (EXPORT_NAME (area))
6983 vty_out (vty, " area %s export-list %s%s", buf,
6984 EXPORT_NAME (area), VTY_NEWLINE);
6985
6986 if (IMPORT_NAME (area))
6987 vty_out (vty, " area %s import-list %s%s", buf,
6988 IMPORT_NAME (area), VTY_NEWLINE);
6989
6990 if (PREFIX_NAME_IN (area))
6991 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
6992 PREFIX_NAME_IN (area), VTY_NEWLINE);
6993
6994 if (PREFIX_NAME_OUT (area))
6995 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
6996 PREFIX_NAME_OUT (area), VTY_NEWLINE);
6997 }
6998
6999 return 0;
7000}
7001
7002int
paul68980082003-03-25 05:07:42 +00007003config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007004{
7005 struct ospf_nbr_nbma *nbr_nbma;
7006 struct route_node *rn;
7007
7008 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007009 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007010 if ((nbr_nbma = rn->info))
7011 {
7012 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7013
7014 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7015 vty_out (vty, " priority %d", nbr_nbma->priority);
7016
7017 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7018 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7019
7020 vty_out (vty, "%s", VTY_NEWLINE);
7021 }
7022
7023 return 0;
7024}
7025
7026int
paul68980082003-03-25 05:07:42 +00007027config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007028{
hasso52dc7ee2004-09-23 19:18:23 +00007029 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007030 u_char buf[INET_ADDRSTRLEN];
7031
7032 /* Virtual-Link print */
paul68980082003-03-25 05:07:42 +00007033 for (node = listhead (ospf->vlinks); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007034 {
hasso52dc7ee2004-09-23 19:18:23 +00007035 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007036 struct crypt_key *ck;
7037 struct ospf_vl_data *vl_data = getdata (node);
7038 struct ospf_interface *oi;
7039
7040 if (vl_data != NULL)
7041 {
7042 memset (buf, 0, INET_ADDRSTRLEN);
7043
7044 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007045 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007046 else
hassoc9e52be2004-09-26 16:09:34 +00007047 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007048 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7049 oi = vl_data->vl_oi;
7050
7051 /* timers */
7052 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7053 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7054 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7055 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7056 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7057 buf,
7058 inet_ntoa (vl_data->vl_peer),
7059 OSPF_IF_PARAM (oi, v_hello),
7060 OSPF_IF_PARAM (oi, retransmit_interval),
7061 OSPF_IF_PARAM (oi, transmit_delay),
7062 OSPF_IF_PARAM (oi, v_wait),
7063 VTY_NEWLINE);
7064 else
7065 vty_out (vty, " area %s virtual-link %s%s", buf,
7066 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7067 /* Auth key */
7068 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7069 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7070 buf,
7071 inet_ntoa (vl_data->vl_peer),
7072 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7073 VTY_NEWLINE);
7074 /* md5 keys */
7075 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
7076 {
7077 ck = getdata (n2);
7078 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
7079 buf,
7080 inet_ntoa (vl_data->vl_peer),
7081 ck->key_id, ck->auth_key, VTY_NEWLINE);
7082 }
7083
7084 }
7085 }
7086
7087 return 0;
7088}
7089
7090
hassoeb1ce602004-10-08 08:17:22 +00007091const char *distribute_str[] = { "system", "kernel", "connected", "static",
7092 "rip", "ripng", "ospf", "ospf6", "isis", "bgp"};
paul718e3742002-12-13 20:15:29 +00007093int
paul68980082003-03-25 05:07:42 +00007094config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007095{
7096 int type;
7097
7098 /* redistribute print. */
7099 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7100 if (type != zclient->redist_default && zclient->redist[type])
7101 {
7102 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007103 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007104 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007105
paul68980082003-03-25 05:07:42 +00007106 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007107 vty_out (vty, " metric-type 1");
7108
paul020709f2003-04-04 02:44:16 +00007109 if (ROUTEMAP_NAME (ospf, type))
7110 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007111
7112 vty_out (vty, "%s", VTY_NEWLINE);
7113 }
7114
7115 return 0;
7116}
7117
7118int
paul68980082003-03-25 05:07:42 +00007119config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007120{
paul68980082003-03-25 05:07:42 +00007121 if (ospf->default_metric != -1)
7122 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007123 VTY_NEWLINE);
7124 return 0;
7125}
7126
7127int
paul68980082003-03-25 05:07:42 +00007128config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007129{
7130 int type;
7131
paul68980082003-03-25 05:07:42 +00007132 if (ospf)
paul718e3742002-12-13 20:15:29 +00007133 {
7134 /* distribute-list print. */
7135 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007136 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007137 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007138 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007139 distribute_str[type], VTY_NEWLINE);
7140
7141 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007142 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007143 {
paul68980082003-03-25 05:07:42 +00007144 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007145 vty_out (vty, " default-information originate");
7146 else
7147 vty_out (vty, " default-information originate always");
7148
paul68980082003-03-25 05:07:42 +00007149 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007150 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007151 ospf->dmetric[DEFAULT_ROUTE].value);
7152 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007153 vty_out (vty, " metric-type 1");
7154
paul020709f2003-04-04 02:44:16 +00007155 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7156 vty_out (vty, " route-map %s",
7157 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007158
7159 vty_out (vty, "%s", VTY_NEWLINE);
7160 }
7161
7162 }
7163
7164 return 0;
7165}
7166
7167int
paul68980082003-03-25 05:07:42 +00007168config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007169{
7170 struct route_node *rn;
7171 struct ospf_distance *odistance;
7172
paul68980082003-03-25 05:07:42 +00007173 if (ospf->distance_all)
7174 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007175
paul68980082003-03-25 05:07:42 +00007176 if (ospf->distance_intra
7177 || ospf->distance_inter
7178 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007179 {
7180 vty_out (vty, " distance ospf");
7181
paul68980082003-03-25 05:07:42 +00007182 if (ospf->distance_intra)
7183 vty_out (vty, " intra-area %d", ospf->distance_intra);
7184 if (ospf->distance_inter)
7185 vty_out (vty, " inter-area %d", ospf->distance_inter);
7186 if (ospf->distance_external)
7187 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007188
7189 vty_out (vty, "%s", VTY_NEWLINE);
7190 }
7191
paul68980082003-03-25 05:07:42 +00007192 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007193 if ((odistance = rn->info) != NULL)
7194 {
7195 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7196 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7197 odistance->access_list ? odistance->access_list : "",
7198 VTY_NEWLINE);
7199 }
7200 return 0;
7201}
7202
7203/* OSPF configuration write function. */
7204int
7205ospf_config_write (struct vty *vty)
7206{
paul020709f2003-04-04 02:44:16 +00007207 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00007208 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007209 int write = 0;
7210
paul020709f2003-04-04 02:44:16 +00007211 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007212 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007213 {
7214 /* `router ospf' print. */
7215 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7216
7217 write++;
7218
paul68980082003-03-25 05:07:42 +00007219 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007220 return write;
7221
7222 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007223 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007224 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007225 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007226
7227 /* ABR type print. */
paul68980082003-03-25 05:07:42 +00007228 if (ospf->abr_type != OSPF_ABR_STAND)
paul718e3742002-12-13 20:15:29 +00007229 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007230 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007231
7232 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007233 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007234 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7235
7236 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007237 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007238 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007239 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007240
7241 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007242 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7243 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007244 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007245 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007246
7247 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007248 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007249 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007250 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007251
7252 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007253 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007254
7255 /* passive-interface print. */
paul020709f2003-04-04 02:44:16 +00007256 for (node = listhead (om->iflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007257 {
7258 struct interface *ifp = getdata (node);
7259
7260 if (!ifp)
7261 continue;
7262 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7263 vty_out (vty, " passive-interface %s%s",
7264 ifp->name, VTY_NEWLINE);
7265 }
7266
paul68980082003-03-25 05:07:42 +00007267 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007268 {
7269 struct ospf_interface *oi = getdata (node);
7270
7271 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7272 oi->params->passive_interface == OSPF_IF_PASSIVE)
paul96735ee2003-08-10 02:51:22 +00007273 vty_out (vty, " passive-interface %s %s%s",
7274 oi->ifp->name,
paul5fdc1e52003-08-06 22:41:29 +00007275 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007276 }
7277
7278
7279 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007280 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007281
7282 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007283 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007284
7285 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007286 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007287
7288 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007289 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007290
7291 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007292 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007293
7294 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007295 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007296
7297 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007298 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007299
7300#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007301 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007302#endif /* HAVE_OPAQUE_LSA */
7303 }
7304
7305 return write;
7306}
7307
7308void
7309ospf_vty_show_init ()
7310{
7311 /* "show ip ospf" commands. */
7312 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7313 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7314
7315 /* "show ip ospf database" commands. */
7316 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7317 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7318 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7319 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7320 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7321 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7322 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7323 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7324 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7325 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7326 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7327 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7328 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7329 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7330
7331 /* "show ip ospf interface" commands. */
7332 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7333 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7334
7335 /* "show ip ospf neighbor" commands. */
7336 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7337 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7338 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7339 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7340 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7341 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7342 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7343 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7344 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7345 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7346 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7347 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7348 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7349 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7350
7351 /* "show ip ospf route" commands. */
7352 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7353 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007354 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7355 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007356}
7357
7358
7359/* ospfd's interface node. */
7360struct cmd_node interface_node =
7361{
7362 INTERFACE_NODE,
7363 "%s(config-if)# ",
7364 1
7365};
7366
7367/* Initialization of OSPF interface. */
7368void
7369ospf_vty_if_init ()
7370{
7371 /* Install interface node. */
7372 install_node (&interface_node, config_write_interface);
7373
7374 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007375 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007376 install_default (INTERFACE_NODE);
7377
7378 /* "description" commands. */
7379 install_element (INTERFACE_NODE, &interface_desc_cmd);
7380 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7381
7382 /* "ip ospf authentication" commands. */
7383 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7384 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7385 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7386 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7387 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7388 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7389 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7390 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7391 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7392 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7393
7394 /* "ip ospf message-digest-key" commands. */
7395 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7396 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7397 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7398 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7399
7400 /* "ip ospf cost" commands. */
7401 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7402 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7403 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7404 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7405
7406 /* "ip ospf dead-interval" commands. */
7407 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7408 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7409 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7410 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7411
7412 /* "ip ospf hello-interval" commands. */
7413 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7414 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7415 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7416 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7417
7418 /* "ip ospf network" commands. */
7419 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7420 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7421
7422 /* "ip ospf priority" commands. */
7423 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7424 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7425 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7426 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7427
7428 /* "ip ospf retransmit-interval" commands. */
7429 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7430 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7431 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7432 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7433
7434 /* "ip ospf transmit-delay" commands. */
7435 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7436 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7437 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7438 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7439
7440 /* These commands are compatibitliy for previous version. */
7441 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7442 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7443 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7444 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7445 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7446 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7447 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7448 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7449 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7450 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7451 install_element (INTERFACE_NODE, &ospf_network_cmd);
7452 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7453 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7454 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7455 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7456 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7457 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7458 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7459}
7460
7461/* Zebra node structure. */
7462struct cmd_node zebra_node =
7463{
7464 ZEBRA_NODE,
7465 "%s(config-router)#",
7466};
7467
7468void
7469ospf_vty_zebra_init ()
7470{
7471 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7472 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7473 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7474 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7475 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7476 install_element (OSPF_NODE,
7477 &ospf_redistribute_source_metric_type_routemap_cmd);
7478 install_element (OSPF_NODE,
7479 &ospf_redistribute_source_type_metric_routemap_cmd);
7480 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7481 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7482 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7483
7484 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7485
7486 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7487 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7488
7489 install_element (OSPF_NODE,
7490 &ospf_default_information_originate_metric_type_cmd);
7491 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7492 install_element (OSPF_NODE,
7493 &ospf_default_information_originate_type_metric_cmd);
7494 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7495 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7496 install_element (OSPF_NODE,
7497 &ospf_default_information_originate_always_metric_type_cmd);
7498 install_element (OSPF_NODE,
7499 &ospf_default_information_originate_always_metric_cmd);
7500 install_element (OSPF_NODE,
7501 &ospf_default_information_originate_always_cmd);
7502 install_element (OSPF_NODE,
7503 &ospf_default_information_originate_always_type_metric_cmd);
7504 install_element (OSPF_NODE,
7505 &ospf_default_information_originate_always_type_cmd);
7506
7507 install_element (OSPF_NODE,
7508 &ospf_default_information_originate_metric_type_routemap_cmd);
7509 install_element (OSPF_NODE,
7510 &ospf_default_information_originate_metric_routemap_cmd);
7511 install_element (OSPF_NODE,
7512 &ospf_default_information_originate_routemap_cmd);
7513 install_element (OSPF_NODE,
7514 &ospf_default_information_originate_type_metric_routemap_cmd);
7515 install_element (OSPF_NODE,
7516 &ospf_default_information_originate_type_routemap_cmd);
7517 install_element (OSPF_NODE,
7518 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7519 install_element (OSPF_NODE,
7520 &ospf_default_information_originate_always_metric_routemap_cmd);
7521 install_element (OSPF_NODE,
7522 &ospf_default_information_originate_always_routemap_cmd);
7523 install_element (OSPF_NODE,
7524 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7525 install_element (OSPF_NODE,
7526 &ospf_default_information_originate_always_type_routemap_cmd);
7527
7528 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7529
7530 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7531 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7532 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7533
7534 install_element (OSPF_NODE, &ospf_distance_cmd);
7535 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7536 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7537 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7538 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7539 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7540 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7541 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7542 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7543 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7544 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7545 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7546 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7547 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7548 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7549 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7550 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7551 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7552#if 0
7553 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7554 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7555 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7556 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7557#endif /* 0 */
7558}
7559
7560struct cmd_node ospf_node =
7561{
7562 OSPF_NODE,
7563 "%s(config-router)# ",
7564 1
7565};
7566
7567
7568/* Install OSPF related vty commands. */
7569void
7570ospf_vty_init ()
7571{
7572 /* Install ospf top node. */
7573 install_node (&ospf_node, ospf_config_write);
7574
7575 /* "router ospf" commands. */
7576 install_element (CONFIG_NODE, &router_ospf_cmd);
7577 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7578
7579 install_default (OSPF_NODE);
7580
7581 /* "ospf router-id" commands. */
7582 install_element (OSPF_NODE, &ospf_router_id_cmd);
7583 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007584 install_element (OSPF_NODE, &router_ospf_id_cmd);
7585 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007586
7587 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007588 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7589 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7590 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7591 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007592
7593 /* "ospf abr-type" commands. */
7594 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7595 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7596
7597 /* "ospf rfc1583-compatible" commands. */
7598 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7599 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7600 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7601 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7602
7603 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007604 install_element (OSPF_NODE, &ospf_network_area_cmd);
7605 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007606
7607 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007608 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7609 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7610 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007611
7612 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007613 install_element (OSPF_NODE, &ospf_area_range_cmd);
7614 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7615 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7616 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7617 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7618 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7619 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7620 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7621 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7622 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7623 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007624
7625 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007626 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7627 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007628
paula2c62832003-04-23 17:01:31 +00007629 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7630 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007631
paula2c62832003-04-23 17:01:31 +00007632 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7633 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007634
paula2c62832003-04-23 17:01:31 +00007635 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7636 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007637
paula2c62832003-04-23 17:01:31 +00007638 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7639 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007640
paula2c62832003-04-23 17:01:31 +00007641 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7642 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7643 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007644
paula2c62832003-04-23 17:01:31 +00007645 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7646 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007647
paula2c62832003-04-23 17:01:31 +00007648 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7649 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007650
paula2c62832003-04-23 17:01:31 +00007651 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7652 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7653 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007654
paula2c62832003-04-23 17:01:31 +00007655 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7656 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7657 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007658
7659 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007660 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7661 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7662 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7663 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007664
paul718e3742002-12-13 20:15:29 +00007665 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007666 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7667 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7668 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7669 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7670 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7671 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007672
paula2c62832003-04-23 17:01:31 +00007673 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7674 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007675
paula2c62832003-04-23 17:01:31 +00007676 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7677 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007678
paula2c62832003-04-23 17:01:31 +00007679 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7680 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007681
paula2c62832003-04-23 17:01:31 +00007682 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7683 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007684
paula2c62832003-04-23 17:01:31 +00007685 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7686 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007687
paula2c62832003-04-23 17:01:31 +00007688 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7689 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007690
paula2c62832003-04-23 17:01:31 +00007691 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7692 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7693 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007694
paula2c62832003-04-23 17:01:31 +00007695 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7696 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007697
7698 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007699 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7700 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7701 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7702 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7703 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7704 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7705 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7706 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007707
7708 /* Init interface related vty commands. */
7709 ospf_vty_if_init ();
7710
7711 /* Init zebra related vty commands. */
7712 ospf_vty_zebra_init ();
7713}