blob: 264e4414100192de0df20ad8c3020522f71e3da5 [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
hassoc6b87812004-12-22 13:09:59 +00002403 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002404 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
hasso3fb9cd62004-10-19 19:44:43 +00002553 if (oi->connected->destination)
2554 vty_out (vty, " %s %s,",
2555 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2556 inet_ntoa (oi->connected->destination->u.prefix4));
2557
paul718e3742002-12-13 20:15:29 +00002558 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2559 VTY_NEWLINE);
2560
2561 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002562 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002563 oi->output_cost, VTY_NEWLINE);
2564
2565 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2566 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2567 PRIORITY (oi), VTY_NEWLINE);
2568
2569 /* Show DR information. */
2570 if (DR (oi).s_addr == 0)
2571 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2572 else
2573 {
2574 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2575 if (nbr == NULL)
2576 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2577 else
2578 {
2579 vty_out (vty, " Designated Router (ID) %s,",
2580 inet_ntoa (nbr->router_id));
2581 vty_out (vty, " Interface Address %s%s",
2582 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2583 }
2584 }
2585
2586 /* Show BDR information. */
2587 if (BDR (oi).s_addr == 0)
2588 vty_out (vty, " No backup designated router on this network%s",
2589 VTY_NEWLINE);
2590 else
2591 {
2592 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2593 if (nbr == NULL)
2594 vty_out (vty, " No backup designated router on this network%s",
2595 VTY_NEWLINE);
2596 else
2597 {
2598 vty_out (vty, " Backup Designated Router (ID) %s,",
2599 inet_ntoa (nbr->router_id));
2600 vty_out (vty, " Interface Address %s%s",
2601 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2602 }
2603 }
2604 vty_out (vty, " Timer intervals configured,");
2605 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2606 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2607 OSPF_IF_PARAM (oi, v_wait),
2608 OSPF_IF_PARAM (oi, retransmit_interval),
2609 VTY_NEWLINE);
2610
2611 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2612 vty_out (vty, " Hello due in %s%s",
2613 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2614 else /* OSPF_IF_PASSIVE is set */
2615 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2616
2617 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002618 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002619 VTY_NEWLINE);
2620 }
2621}
2622
2623DEFUN (show_ip_ospf_interface,
2624 show_ip_ospf_interface_cmd,
2625 "show ip ospf interface [INTERFACE]",
2626 SHOW_STR
2627 IP_STR
2628 "OSPF information\n"
2629 "Interface information\n"
2630 "Interface name\n")
2631{
2632 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002633 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002634 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002635
paul020709f2003-04-04 02:44:16 +00002636 ospf = ospf_lookup ();
2637
paul718e3742002-12-13 20:15:29 +00002638 /* Show All Interfaces. */
2639 if (argc == 0)
2640 for (node = listhead (iflist); node; nextnode (node))
paul68980082003-03-25 05:07:42 +00002641 show_ip_ospf_interface_sub (vty, ospf, node->data);
paul718e3742002-12-13 20:15:29 +00002642 /* Interface name is specified. */
2643 else
2644 {
2645 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2646 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2647 else
paul68980082003-03-25 05:07:42 +00002648 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002649 }
2650
2651 return CMD_SUCCESS;
2652}
2653
2654void
2655show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2656{
2657 struct route_node *rn;
2658 struct ospf_neighbor *nbr;
2659 char msgbuf[16];
2660 char timebuf[9];
2661
2662 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2663 if ((nbr = rn->info))
2664 /* Do not show myself. */
2665 if (nbr != oi->nbr_self)
2666 /* Down state is not shown. */
2667 if (nbr->state != NSM_Down)
2668 {
2669 ospf_nbr_state_message (nbr, msgbuf, 16);
2670
2671 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2672 vty_out (vty, "%-15s %3d %-15s %8s ",
2673 "-", nbr->priority,
2674 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2675 else
2676 vty_out (vty, "%-15s %3d %-15s %8s ",
2677 inet_ntoa (nbr->router_id), nbr->priority,
2678 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2679 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2680 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2681 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2682 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2683 VTY_NEWLINE);
2684 }
2685}
2686
2687DEFUN (show_ip_ospf_neighbor,
2688 show_ip_ospf_neighbor_cmd,
2689 "show ip ospf neighbor",
2690 SHOW_STR
2691 IP_STR
2692 "OSPF information\n"
2693 "Neighbor list\n")
2694{
paul020709f2003-04-04 02:44:16 +00002695 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002696 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002697
paul020709f2003-04-04 02:44:16 +00002698 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002699 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002700 {
2701 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2702 return CMD_SUCCESS;
2703 }
2704
2705 /* Show All neighbors. */
2706 vty_out (vty, "%sNeighbor ID Pri State Dead "
2707 "Time Address Interface RXmtL "
2708 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2709
paul68980082003-03-25 05:07:42 +00002710 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul020709f2003-04-04 02:44:16 +00002711 show_ip_ospf_neighbor_sub (vty, getdata (node));
paul718e3742002-12-13 20:15:29 +00002712
2713 return CMD_SUCCESS;
2714}
2715
2716DEFUN (show_ip_ospf_neighbor_all,
2717 show_ip_ospf_neighbor_all_cmd,
2718 "show ip ospf neighbor all",
2719 SHOW_STR
2720 IP_STR
2721 "OSPF information\n"
2722 "Neighbor list\n"
2723 "include down status neighbor\n")
2724{
paul68980082003-03-25 05:07:42 +00002725 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002726 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002727
paul68980082003-03-25 05:07:42 +00002728 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002729 {
2730 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2731 return CMD_SUCCESS;
2732 }
2733
2734 /* Show All neighbors. */
2735 vty_out (vty, "%sNeighbor ID Pri State Dead "
2736 "Time Address Interface RXmtL "
2737 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2738
paul68980082003-03-25 05:07:42 +00002739 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002740 {
2741 struct ospf_interface *oi = getdata (node);
hasso52dc7ee2004-09-23 19:18:23 +00002742 struct listnode *nbr_node;
paul718e3742002-12-13 20:15:29 +00002743
2744 show_ip_ospf_neighbor_sub (vty, oi);
2745
2746 /* print Down neighbor status */
2747 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
2748 {
2749 struct ospf_nbr_nbma *nbr_nbma;
2750
2751 nbr_nbma = getdata (nbr_node);
2752
2753 if (nbr_nbma->nbr == NULL
2754 || nbr_nbma->nbr->state == NSM_Down)
2755 {
2756 vty_out (vty, "%-15s %3d %-15s %8s ",
2757 "-", nbr_nbma->priority, "Down", "-");
2758 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2759 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2760 0, 0, 0, VTY_NEWLINE);
2761 }
2762 }
2763 }
2764
2765 return CMD_SUCCESS;
2766}
2767
2768DEFUN (show_ip_ospf_neighbor_int,
2769 show_ip_ospf_neighbor_int_cmd,
2770 "show ip ospf neighbor A.B.C.D",
2771 SHOW_STR
2772 IP_STR
2773 "OSPF information\n"
2774 "Neighbor list\n"
2775 "Interface name\n")
2776{
paul020709f2003-04-04 02:44:16 +00002777 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002778 struct ospf_interface *oi;
2779 struct in_addr addr;
2780 int ret;
2781
paul718e3742002-12-13 20:15:29 +00002782 ret = inet_aton (argv[0], &addr);
2783 if (!ret)
2784 {
2785 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2786 VTY_NEWLINE);
2787 return CMD_WARNING;
2788 }
2789
paul020709f2003-04-04 02:44:16 +00002790 ospf = ospf_lookup ();
2791 if (ospf == NULL)
2792 {
2793 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2794 return CMD_SUCCESS;
2795 }
2796
paul68980082003-03-25 05:07:42 +00002797 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00002798 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2799 else
2800 {
2801 vty_out (vty, "%sNeighbor ID Pri State Dead "
2802 "Time Address Interface RXmtL "
2803 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2804 show_ip_ospf_neighbor_sub (vty, oi);
2805 }
2806
2807 return CMD_SUCCESS;
2808}
2809
2810void
2811show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2812 struct ospf_nbr_nbma *nbr_nbma)
2813{
2814 char timebuf[9];
2815
2816 /* Show neighbor ID. */
2817 vty_out (vty, " Neighbor %s,", "-");
2818
2819 /* Show interface address. */
2820 vty_out (vty, " interface address %s%s",
2821 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2822 /* Show Area ID. */
2823 vty_out (vty, " In the area %s via interface %s%s",
2824 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2825 /* Show neighbor priority and state. */
2826 vty_out (vty, " Neighbor priority is %d, State is %s,",
2827 nbr_nbma->priority, "Down");
2828 /* Show state changes. */
2829 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2830
2831 /* Show PollInterval */
2832 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2833
2834 /* Show poll-interval timer. */
2835 vty_out (vty, " Poll timer due in %s%s",
2836 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2837
2838 /* Show poll-interval timer thread. */
2839 vty_out (vty, " Thread Poll Timer %s%s",
2840 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2841}
2842
2843void
2844show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2845 struct ospf_neighbor *nbr)
2846{
2847 char timebuf[9];
2848
2849 /* Show neighbor ID. */
2850 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2851 vty_out (vty, " Neighbor %s,", "-");
2852 else
2853 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2854
2855 /* Show interface address. */
2856 vty_out (vty, " interface address %s%s",
2857 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2858 /* Show Area ID. */
2859 vty_out (vty, " In the area %s via interface %s%s",
2860 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2861 /* Show neighbor priority and state. */
2862 vty_out (vty, " Neighbor priority is %d, State is %s,",
2863 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2864 /* Show state changes. */
2865 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2866
2867 /* Show Designated Rotuer ID. */
2868 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2869 /* Show Backup Designated Rotuer ID. */
2870 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2871 /* Show options. */
2872 vty_out (vty, " Options %d %s%s", nbr->options,
2873 ospf_options_dump (nbr->options), VTY_NEWLINE);
2874 /* Show Router Dead interval timer. */
2875 vty_out (vty, " Dead timer due in %s%s",
2876 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2877 /* Show Database Summary list. */
2878 vty_out (vty, " Database Summary List %d%s",
2879 ospf_db_summary_count (nbr), VTY_NEWLINE);
2880 /* Show Link State Request list. */
2881 vty_out (vty, " Link State Request List %ld%s",
2882 ospf_ls_request_count (nbr), VTY_NEWLINE);
2883 /* Show Link State Retransmission list. */
2884 vty_out (vty, " Link State Retransmission List %ld%s",
2885 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2886 /* Show inactivity timer thread. */
2887 vty_out (vty, " Thread Inactivity Timer %s%s",
2888 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2889 /* Show Database Description retransmission thread. */
2890 vty_out (vty, " Thread Database Description Retransmision %s%s",
2891 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2892 /* Show Link State Request Retransmission thread. */
2893 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2894 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2895 /* Show Link State Update Retransmission thread. */
2896 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2897 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2898}
2899
2900DEFUN (show_ip_ospf_neighbor_id,
2901 show_ip_ospf_neighbor_id_cmd,
2902 "show ip ospf neighbor A.B.C.D",
2903 SHOW_STR
2904 IP_STR
2905 "OSPF information\n"
2906 "Neighbor list\n"
2907 "Neighbor ID\n")
2908{
paul020709f2003-04-04 02:44:16 +00002909 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002910 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002911 struct ospf_neighbor *nbr;
2912 struct in_addr router_id;
2913 int ret;
2914
2915 ret = inet_aton (argv[0], &router_id);
2916 if (!ret)
2917 {
2918 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
2919 return CMD_WARNING;
2920 }
2921
paul020709f2003-04-04 02:44:16 +00002922 ospf = ospf_lookup ();
2923 if (ospf == NULL)
2924 {
2925 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2926 return CMD_SUCCESS;
2927 }
2928
paul68980082003-03-25 05:07:42 +00002929 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002930 {
2931 struct ospf_interface *oi = getdata (node);
2932
2933 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
2934 {
2935 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2936 return CMD_SUCCESS;
2937 }
2938 }
2939
2940 /* Nothing to show. */
2941 return CMD_SUCCESS;
2942}
2943
2944DEFUN (show_ip_ospf_neighbor_detail,
2945 show_ip_ospf_neighbor_detail_cmd,
2946 "show ip ospf neighbor detail",
2947 SHOW_STR
2948 IP_STR
2949 "OSPF information\n"
2950 "Neighbor list\n"
2951 "detail of all neighbors\n")
2952{
paul020709f2003-04-04 02:44:16 +00002953 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002954 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002955
paul020709f2003-04-04 02:44:16 +00002956 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002957 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00002958 {
2959 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2960 return CMD_SUCCESS;
2961 }
paul718e3742002-12-13 20:15:29 +00002962
paul68980082003-03-25 05:07:42 +00002963 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002964 {
2965 struct ospf_interface *oi = getdata (node);
2966 struct route_node *rn;
2967 struct ospf_neighbor *nbr;
2968
2969 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2970 if ((nbr = rn->info))
2971 if (nbr != oi->nbr_self)
2972 if (nbr->state != NSM_Down)
2973 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2974 }
2975
2976 return CMD_SUCCESS;
2977}
2978
2979DEFUN (show_ip_ospf_neighbor_detail_all,
2980 show_ip_ospf_neighbor_detail_all_cmd,
2981 "show ip ospf neighbor detail all",
2982 SHOW_STR
2983 IP_STR
2984 "OSPF information\n"
2985 "Neighbor list\n"
2986 "detail of all neighbors\n"
2987 "include down status neighbor\n")
2988{
paul020709f2003-04-04 02:44:16 +00002989 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002990 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002991
paul020709f2003-04-04 02:44:16 +00002992 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002993 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00002994 {
2995 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2996 return CMD_SUCCESS;
2997 }
paul718e3742002-12-13 20:15:29 +00002998
paul68980082003-03-25 05:07:42 +00002999 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003000 {
3001 struct ospf_interface *oi = getdata (node);
3002 struct route_node *rn;
3003 struct ospf_neighbor *nbr;
3004
3005 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3006 if ((nbr = rn->info))
3007 if (nbr != oi->nbr_self)
3008 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3009 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3010
3011 if (oi->type == OSPF_IFTYPE_NBMA)
3012 {
hasso52dc7ee2004-09-23 19:18:23 +00003013 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003014
3015 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
3016 {
3017 struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
3018 if (nbr_nbma->nbr == NULL
3019 || nbr_nbma->nbr->state == NSM_Down)
3020 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3021 }
3022 }
3023 }
3024
3025 return CMD_SUCCESS;
3026}
3027
3028DEFUN (show_ip_ospf_neighbor_int_detail,
3029 show_ip_ospf_neighbor_int_detail_cmd,
3030 "show ip ospf neighbor A.B.C.D detail",
3031 SHOW_STR
3032 IP_STR
3033 "OSPF information\n"
3034 "Neighbor list\n"
3035 "Interface address\n"
3036 "detail of all neighbors")
3037{
paul020709f2003-04-04 02:44:16 +00003038 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003039 struct ospf_interface *oi;
3040 struct in_addr addr;
3041 int ret;
3042
3043 ret = inet_aton (argv[0], &addr);
3044 if (!ret)
3045 {
3046 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3047 VTY_NEWLINE);
3048 return CMD_WARNING;
3049 }
3050
paul020709f2003-04-04 02:44:16 +00003051 ospf = ospf_lookup ();
3052 if (ospf == NULL)
3053 {
3054 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3055 return CMD_SUCCESS;
3056 }
paul68980082003-03-25 05:07:42 +00003057
paul020709f2003-04-04 02:44:16 +00003058 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00003059 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3060 else
3061 {
3062 struct route_node *rn;
3063 struct ospf_neighbor *nbr;
3064
3065 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3066 if ((nbr = rn->info))
3067 if (nbr != oi->nbr_self)
3068 if (nbr->state != NSM_Down)
3069 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3070 }
3071
3072 return CMD_SUCCESS;
3073}
3074
3075
3076/* Show functions */
3077int
paul020709f2003-04-04 02:44:16 +00003078show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003079{
paul718e3742002-12-13 20:15:29 +00003080 struct router_lsa *rl;
3081 struct summary_lsa *sl;
3082 struct as_external_lsa *asel;
3083 struct prefix_ipv4 p;
3084
3085 if (lsa != NULL)
3086 /* If self option is set, check LSA self flag. */
3087 if (self == 0 || IS_LSA_SELF (lsa))
3088 {
3089 /* LSA common part show. */
3090 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3091 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3092 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3093 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3094 /* LSA specific part show. */
3095 switch (lsa->data->type)
3096 {
3097 case OSPF_ROUTER_LSA:
3098 rl = (struct router_lsa *) lsa->data;
3099 vty_out (vty, " %-d", ntohs (rl->links));
3100 break;
3101 case OSPF_SUMMARY_LSA:
3102 sl = (struct summary_lsa *) lsa->data;
3103
3104 p.family = AF_INET;
3105 p.prefix = sl->header.id;
3106 p.prefixlen = ip_masklen (sl->mask);
3107 apply_mask_ipv4 (&p);
3108
3109 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3110 break;
3111 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003112 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003113 asel = (struct as_external_lsa *) lsa->data;
3114
3115 p.family = AF_INET;
3116 p.prefix = asel->header.id;
3117 p.prefixlen = ip_masklen (asel->mask);
3118 apply_mask_ipv4 (&p);
3119
3120 vty_out (vty, " %s %s/%d [0x%lx]",
3121 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3122 inet_ntoa (p.prefix), p.prefixlen,
3123 (u_long)ntohl (asel->e[0].route_tag));
3124 break;
3125 case OSPF_NETWORK_LSA:
3126 case OSPF_ASBR_SUMMARY_LSA:
3127#ifdef HAVE_OPAQUE_LSA
3128 case OSPF_OPAQUE_LINK_LSA:
3129 case OSPF_OPAQUE_AREA_LSA:
3130 case OSPF_OPAQUE_AS_LSA:
3131#endif /* HAVE_OPAQUE_LSA */
3132 default:
3133 break;
3134 }
3135 vty_out (vty, VTY_NEWLINE);
3136 }
3137
3138 return 0;
3139}
3140
hassoeb1ce602004-10-08 08:17:22 +00003141const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003142{
3143 "unknown",
3144 "Router Link States",
3145 "Net Link States",
3146 "Summary Link States",
3147 "ASBR-Summary Link States",
3148 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003149 "Group Membership LSA",
3150 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003151#ifdef HAVE_OPAQUE_LSA
3152 "Type-8 LSA",
3153 "Link-Local Opaque-LSA",
3154 "Area-Local Opaque-LSA",
3155 "AS-external Opaque-LSA",
3156#endif /* HAVE_OPAQUE_LSA */
3157};
3158
3159#define SHOW_OSPF_COMMON_HEADER \
3160 "Link ID ADV Router Age Seq# CkSum"
3161
hassoeb1ce602004-10-08 08:17:22 +00003162const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003163{
3164 "",
3165 "Link ID ADV Router Age Seq# CkSum Link count",
3166 "Link ID ADV Router Age Seq# CkSum",
3167 "Link ID ADV Router Age Seq# CkSum Route",
3168 "Link ID ADV Router Age Seq# CkSum",
3169 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003170 " --- header for Group Member ----",
3171 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003172#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003173 " --- type-8 ---",
3174 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3175 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3176 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3177#endif /* HAVE_OPAQUE_LSA */
3178};
3179
hassoeb1ce602004-10-08 08:17:22 +00003180const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003181{
3182 "Self-originated",
3183 "Checked",
3184 "Received",
3185 "Approved",
3186 "Discard",
paul4957f492003-06-27 01:28:45 +00003187 "Translated",
paul4957f492003-06-27 01:28:45 +00003188};
3189
paul718e3742002-12-13 20:15:29 +00003190void
3191show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3192{
3193 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003194
paul718e3742002-12-13 20:15:29 +00003195 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003196 vty_out (vty, " Options: 0x%-2x : %s%s",
3197 lsa->data->options,
3198 ospf_options_dump(lsa->data->options),
3199 VTY_NEWLINE);
3200 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003201 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003202 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3203 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003204
3205 if (lsa->data->type == OSPF_ROUTER_LSA)
3206 {
3207 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3208
3209 if (rlsa->flags)
3210 vty_out (vty, " :%s%s%s%s",
3211 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3212 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3213 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3214 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3215
3216 vty_out (vty, "%s", VTY_NEWLINE);
3217 }
3218 vty_out (vty, " LS Type: %s%s",
3219 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3220 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3221 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3222 vty_out (vty, " Advertising Router: %s%s",
3223 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3224 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3225 VTY_NEWLINE);
3226 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3227 VTY_NEWLINE);
3228 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3229}
3230
hassoeb1ce602004-10-08 08:17:22 +00003231const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003232{
3233 "(null)",
3234 "another Router (point-to-point)",
3235 "a Transit Network",
3236 "Stub Network",
3237 "a Virtual Link",
3238};
3239
hassoeb1ce602004-10-08 08:17:22 +00003240const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003241{
3242 "(null)",
3243 "Neighboring Router ID",
3244 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003245 "Net",
paul718e3742002-12-13 20:15:29 +00003246 "Neighboring Router ID",
3247};
3248
hassoeb1ce602004-10-08 08:17:22 +00003249const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003250{
3251 "(null)",
3252 "Router Interface address",
3253 "Router Interface address",
3254 "Network Mask",
3255 "Router Interface address",
3256};
3257
3258/* Show router-LSA each Link information. */
3259void
3260show_ip_ospf_database_router_links (struct vty *vty,
3261 struct router_lsa *rl)
3262{
3263 int len, i, type;
3264
3265 len = ntohs (rl->header.length) - 4;
3266 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3267 {
3268 type = rl->link[i].type;
3269
3270 vty_out (vty, " Link connected to: %s%s",
3271 link_type_desc[type], VTY_NEWLINE);
3272 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3273 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3274 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3275 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3276 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3277 vty_out (vty, " TOS 0 Metric: %d%s",
3278 ntohs (rl->link[i].metric), VTY_NEWLINE);
3279 vty_out (vty, "%s", VTY_NEWLINE);
3280 }
3281}
3282
3283/* Show router-LSA detail information. */
3284int
3285show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3286{
3287 if (lsa != NULL)
3288 {
3289 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3290
3291 show_ip_ospf_database_header (vty, lsa);
3292
3293 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3294 VTY_NEWLINE, VTY_NEWLINE);
3295
3296 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003297 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003298 }
3299
3300 return 0;
3301}
3302
3303/* Show network-LSA detail information. */
3304int
3305show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3306{
3307 int length, i;
3308
3309 if (lsa != NULL)
3310 {
3311 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3312
3313 show_ip_ospf_database_header (vty, lsa);
3314
3315 vty_out (vty, " Network Mask: /%d%s",
3316 ip_masklen (nl->mask), VTY_NEWLINE);
3317
3318 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3319
3320 for (i = 0; length > 0; i++, length -= 4)
3321 vty_out (vty, " Attached Router: %s%s",
3322 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3323
3324 vty_out (vty, "%s", VTY_NEWLINE);
3325 }
3326
3327 return 0;
3328}
3329
3330/* Show summary-LSA detail information. */
3331int
3332show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3333{
3334 if (lsa != NULL)
3335 {
3336 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3337
3338 show_ip_ospf_database_header (vty, lsa);
3339
3340 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3341 VTY_NEWLINE);
3342 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3343 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003344 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003345 }
3346
3347 return 0;
3348}
3349
3350/* Show summary-ASBR-LSA detail information. */
3351int
3352show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3353{
3354 if (lsa != NULL)
3355 {
3356 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3357
3358 show_ip_ospf_database_header (vty, lsa);
3359
3360 vty_out (vty, " Network Mask: /%d%s",
3361 ip_masklen (sl->mask), VTY_NEWLINE);
3362 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3363 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003364 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003365 }
3366
3367 return 0;
3368}
3369
3370/* Show AS-external-LSA detail information. */
3371int
3372show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3373{
3374 if (lsa != NULL)
3375 {
3376 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3377
3378 show_ip_ospf_database_header (vty, lsa);
3379
3380 vty_out (vty, " Network Mask: /%d%s",
3381 ip_masklen (al->mask), VTY_NEWLINE);
3382 vty_out (vty, " Metric Type: %s%s",
3383 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3384 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3385 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3386 vty_out (vty, " Metric: %d%s",
3387 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3388 vty_out (vty, " Forward Address: %s%s",
3389 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3390
3391 vty_out (vty, " External Route Tag: %lu%s%s",
3392 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3393 }
3394
3395 return 0;
3396}
3397
ajs2a42e282004-12-08 18:43:03 +00003398/* N.B. This function currently seems to be unused. */
paul718e3742002-12-13 20:15:29 +00003399int
3400show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3401{
3402 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3403
3404 /* show_ip_ospf_database_header (vty, lsa); */
3405
ajs2a42e282004-12-08 18:43:03 +00003406 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003407 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003408 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003409 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3410 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003411 zlog_debug( " TOS: 0%s", "\n");
3412 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003413 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003414 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003415 inet_ntoa (al->e[0].fwd_addr), "\n");
3416
ajs2a42e282004-12-08 18:43:03 +00003417 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003418 ntohl (al->e[0].route_tag), "\n", "\n");
3419
3420 return 0;
3421}
3422
3423/* Show AS-NSSA-LSA detail information. */
3424int
3425show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3426{
3427 if (lsa != NULL)
3428 {
3429 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3430
3431 show_ip_ospf_database_header (vty, lsa);
3432
3433 vty_out (vty, " Network Mask: /%d%s",
3434 ip_masklen (al->mask), VTY_NEWLINE);
3435 vty_out (vty, " Metric Type: %s%s",
3436 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3437 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3438 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3439 vty_out (vty, " Metric: %d%s",
3440 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3441 vty_out (vty, " NSSA: Forward Address: %s%s",
3442 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3443
3444 vty_out (vty, " External Route Tag: %u%s%s",
3445 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3446 }
3447
3448 return 0;
3449}
3450
paul718e3742002-12-13 20:15:29 +00003451int
3452show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3453{
3454 return 0;
3455}
3456
3457#ifdef HAVE_OPAQUE_LSA
3458int
3459show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3460{
3461 if (lsa != NULL)
3462 {
3463 show_ip_ospf_database_header (vty, lsa);
3464 show_opaque_info_detail (vty, lsa);
3465
3466 vty_out (vty, "%s", VTY_NEWLINE);
3467 }
3468 return 0;
3469}
3470#endif /* HAVE_OPAQUE_LSA */
3471
3472int (*show_function[])(struct vty *, struct ospf_lsa *) =
3473{
3474 NULL,
3475 show_router_lsa_detail,
3476 show_network_lsa_detail,
3477 show_summary_lsa_detail,
3478 show_summary_asbr_lsa_detail,
3479 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003480 show_func_dummy,
3481 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003482#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003483 NULL, /* type-8 */
3484 show_opaque_lsa_detail,
3485 show_opaque_lsa_detail,
3486 show_opaque_lsa_detail,
3487#endif /* HAVE_OPAQUE_LSA */
3488};
3489
3490void
3491show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3492 struct in_addr *adv_router)
3493{
3494 memset (lp, 0, sizeof (struct prefix_ls));
3495 lp->family = 0;
3496 if (id == NULL)
3497 lp->prefixlen = 0;
3498 else if (adv_router == NULL)
3499 {
3500 lp->prefixlen = 32;
3501 lp->id = *id;
3502 }
3503 else
3504 {
3505 lp->prefixlen = 64;
3506 lp->id = *id;
3507 lp->adv_router = *adv_router;
3508 }
3509}
3510
3511void
3512show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3513 struct in_addr *id, struct in_addr *adv_router)
3514{
3515 struct prefix_ls lp;
3516 struct route_node *rn, *start;
3517 struct ospf_lsa *lsa;
3518
3519 show_lsa_prefix_set (vty, &lp, id, adv_router);
3520 start = route_node_get (rt, (struct prefix *) &lp);
3521 if (start)
3522 {
3523 route_lock_node (start);
3524 for (rn = start; rn; rn = route_next_until (rn, start))
3525 if ((lsa = rn->info))
3526 {
paul718e3742002-12-13 20:15:29 +00003527 if (show_function[lsa->data->type] != NULL)
3528 show_function[lsa->data->type] (vty, lsa);
3529 }
3530 route_unlock_node (start);
3531 }
3532}
3533
3534/* Show detail LSA information
3535 -- if id is NULL then show all LSAs. */
3536void
paul020709f2003-04-04 02:44:16 +00003537show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003538 struct in_addr *id, struct in_addr *adv_router)
3539{
hasso52dc7ee2004-09-23 19:18:23 +00003540 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003541
3542 switch (type)
3543 {
3544 case OSPF_AS_EXTERNAL_LSA:
3545#ifdef HAVE_OPAQUE_LSA
3546 case OSPF_OPAQUE_AS_LSA:
3547#endif /* HAVE_OPAQUE_LSA */
3548 vty_out (vty, " %s %s%s",
3549 show_database_desc[type],
3550 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003551 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003552 break;
3553 default:
paul68980082003-03-25 05:07:42 +00003554 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003555 {
3556 struct ospf_area *area = node->data;
3557 vty_out (vty, "%s %s (Area %s)%s%s",
3558 VTY_NEWLINE, show_database_desc[type],
3559 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3560 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3561 }
3562 break;
3563 }
3564}
3565
3566void
3567show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3568 struct in_addr *adv_router)
3569{
3570 struct route_node *rn;
3571 struct ospf_lsa *lsa;
3572
3573 for (rn = route_top (rt); rn; rn = route_next (rn))
3574 if ((lsa = rn->info))
3575 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3576 {
paul718e3742002-12-13 20:15:29 +00003577 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3578 continue;
paul718e3742002-12-13 20:15:29 +00003579 if (show_function[lsa->data->type] != NULL)
3580 show_function[lsa->data->type] (vty, lsa);
3581 }
3582}
3583
3584/* Show detail LSA information. */
3585void
paul020709f2003-04-04 02:44:16 +00003586show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003587 struct in_addr *adv_router)
3588{
hasso52dc7ee2004-09-23 19:18:23 +00003589 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003590
3591 switch (type)
3592 {
3593 case OSPF_AS_EXTERNAL_LSA:
3594#ifdef HAVE_OPAQUE_LSA
3595 case OSPF_OPAQUE_AS_LSA:
3596#endif /* HAVE_OPAQUE_LSA */
3597 vty_out (vty, " %s %s%s",
3598 show_database_desc[type],
3599 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003600 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003601 adv_router);
3602 break;
3603 default:
paul68980082003-03-25 05:07:42 +00003604 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003605 {
3606 struct ospf_area *area = node->data;
3607 vty_out (vty, "%s %s (Area %s)%s%s",
3608 VTY_NEWLINE, show_database_desc[type],
3609 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3610 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3611 adv_router);
3612 }
3613 break;
3614 }
3615}
3616
3617void
paul020709f2003-04-04 02:44:16 +00003618show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003619{
paul020709f2003-04-04 02:44:16 +00003620 struct ospf_lsa *lsa;
3621 struct route_node *rn;
hasso52dc7ee2004-09-23 19:18:23 +00003622 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003623 int type;
3624
paul68980082003-03-25 05:07:42 +00003625 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003626 {
3627 struct ospf_area *area = node->data;
3628 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3629 {
3630 switch (type)
3631 {
3632 case OSPF_AS_EXTERNAL_LSA:
3633#ifdef HAVE_OPAQUE_LSA
3634 case OSPF_OPAQUE_AS_LSA:
3635#endif /* HAVE_OPAQUE_LSA */
3636 continue;
3637 default:
3638 break;
3639 }
3640 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3641 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3642 {
3643 vty_out (vty, " %s (Area %s)%s%s",
3644 show_database_desc[type],
3645 ospf_area_desc_string (area),
3646 VTY_NEWLINE, VTY_NEWLINE);
3647 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3648
paul020709f2003-04-04 02:44:16 +00003649 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3650 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003651
3652 vty_out (vty, "%s", VTY_NEWLINE);
3653 }
3654 }
3655 }
3656
3657 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3658 {
3659 switch (type)
3660 {
3661 case OSPF_AS_EXTERNAL_LSA:
3662#ifdef HAVE_OPAQUE_LSA
3663 case OSPF_OPAQUE_AS_LSA:
3664#endif /* HAVE_OPAQUE_LSA */
3665 break;;
3666 default:
3667 continue;
3668 }
paul68980082003-03-25 05:07:42 +00003669 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3670 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003671 {
3672 vty_out (vty, " %s%s%s",
3673 show_database_desc[type],
3674 VTY_NEWLINE, VTY_NEWLINE);
3675 vty_out (vty, "%s%s", show_database_header[type],
3676 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003677
3678 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3679 show_lsa_summary (vty, lsa, self);
3680
paul718e3742002-12-13 20:15:29 +00003681 vty_out (vty, "%s", VTY_NEWLINE);
3682 }
3683 }
3684
3685 vty_out (vty, "%s", VTY_NEWLINE);
3686}
3687
3688void
paul020709f2003-04-04 02:44:16 +00003689show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003690{
hasso52dc7ee2004-09-23 19:18:23 +00003691 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003692 struct ospf_lsa *lsa;
3693
3694 vty_out (vty, "%s MaxAge Link States:%s%s",
3695 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3696
paul68980082003-03-25 05:07:42 +00003697 for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003698 if ((lsa = node->data) != NULL)
3699 {
3700 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3701 vty_out (vty, "Link State ID: %s%s",
3702 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3703 vty_out (vty, "Advertising Router: %s%s",
3704 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3705 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3706 vty_out (vty, "%s", VTY_NEWLINE);
3707 }
3708}
3709
paul718e3742002-12-13 20:15:29 +00003710#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3711#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003712
3713#ifdef HAVE_OPAQUE_LSA
3714#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3715#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3716#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3717#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3718#else /* HAVE_OPAQUE_LSA */
3719#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3720#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3721#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3722#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3723#endif /* HAVE_OPAQUE_LSA */
3724
3725#define OSPF_LSA_TYPES_CMD_STR \
3726 "asbr-summary|external|network|router|summary" \
3727 OSPF_LSA_TYPE_NSSA_CMD_STR \
3728 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3729
3730#define OSPF_LSA_TYPES_DESC \
3731 "ASBR summary link states\n" \
3732 "External link states\n" \
3733 "Network link states\n" \
3734 "Router link states\n" \
3735 "Network summary link states\n" \
3736 OSPF_LSA_TYPE_NSSA_DESC \
3737 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3738 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3739 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3740
3741DEFUN (show_ip_ospf_database,
3742 show_ip_ospf_database_cmd,
3743 "show ip ospf database",
3744 SHOW_STR
3745 IP_STR
3746 "OSPF information\n"
3747 "Database summary\n")
3748{
paul020709f2003-04-04 02:44:16 +00003749 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003750 int type, ret;
3751 struct in_addr id, adv_router;
3752
paul020709f2003-04-04 02:44:16 +00003753 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003754 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003755 return CMD_SUCCESS;
3756
3757 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003758 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003759
3760 /* Show all LSA. */
3761 if (argc == 0)
3762 {
paul020709f2003-04-04 02:44:16 +00003763 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003764 return CMD_SUCCESS;
3765 }
3766
3767 /* Set database type to show. */
3768 if (strncmp (argv[0], "r", 1) == 0)
3769 type = OSPF_ROUTER_LSA;
3770 else if (strncmp (argv[0], "ne", 2) == 0)
3771 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003772 else if (strncmp (argv[0], "ns", 2) == 0)
3773 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003774 else if (strncmp (argv[0], "su", 2) == 0)
3775 type = OSPF_SUMMARY_LSA;
3776 else if (strncmp (argv[0], "a", 1) == 0)
3777 type = OSPF_ASBR_SUMMARY_LSA;
3778 else if (strncmp (argv[0], "e", 1) == 0)
3779 type = OSPF_AS_EXTERNAL_LSA;
3780 else if (strncmp (argv[0], "se", 2) == 0)
3781 {
paul020709f2003-04-04 02:44:16 +00003782 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003783 return CMD_SUCCESS;
3784 }
3785 else if (strncmp (argv[0], "m", 1) == 0)
3786 {
paul020709f2003-04-04 02:44:16 +00003787 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003788 return CMD_SUCCESS;
3789 }
3790#ifdef HAVE_OPAQUE_LSA
3791 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3792 type = OSPF_OPAQUE_LINK_LSA;
3793 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3794 type = OSPF_OPAQUE_AREA_LSA;
3795 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3796 type = OSPF_OPAQUE_AS_LSA;
3797#endif /* HAVE_OPAQUE_LSA */
3798 else
3799 return CMD_WARNING;
3800
3801 /* `show ip ospf database LSA'. */
3802 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003803 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003804 else if (argc >= 2)
3805 {
3806 ret = inet_aton (argv[1], &id);
3807 if (!ret)
3808 return CMD_WARNING;
3809
3810 /* `show ip ospf database LSA ID'. */
3811 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003812 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003813 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3814 else if (argc == 3)
3815 {
3816 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003817 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003818 else
3819 {
3820 ret = inet_aton (argv[2], &adv_router);
3821 if (!ret)
3822 return CMD_WARNING;
3823 }
paul020709f2003-04-04 02:44:16 +00003824 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003825 }
3826 }
3827
3828 return CMD_SUCCESS;
3829}
3830
3831ALIAS (show_ip_ospf_database,
3832 show_ip_ospf_database_type_cmd,
3833 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3834 SHOW_STR
3835 IP_STR
3836 "OSPF information\n"
3837 "Database summary\n"
3838 OSPF_LSA_TYPES_DESC
3839 "LSAs in MaxAge list\n"
3840 "Self-originated link states\n")
3841
3842ALIAS (show_ip_ospf_database,
3843 show_ip_ospf_database_type_id_cmd,
3844 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3845 SHOW_STR
3846 IP_STR
3847 "OSPF information\n"
3848 "Database summary\n"
3849 OSPF_LSA_TYPES_DESC
3850 "Link State ID (as an IP address)\n")
3851
3852ALIAS (show_ip_ospf_database,
3853 show_ip_ospf_database_type_id_adv_router_cmd,
3854 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3855 SHOW_STR
3856 IP_STR
3857 "OSPF information\n"
3858 "Database summary\n"
3859 OSPF_LSA_TYPES_DESC
3860 "Link State ID (as an IP address)\n"
3861 "Advertising Router link states\n"
3862 "Advertising Router (as an IP address)\n")
3863
3864ALIAS (show_ip_ospf_database,
3865 show_ip_ospf_database_type_id_self_cmd,
3866 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3867 SHOW_STR
3868 IP_STR
3869 "OSPF information\n"
3870 "Database summary\n"
3871 OSPF_LSA_TYPES_DESC
3872 "Link State ID (as an IP address)\n"
3873 "Self-originated link states\n"
3874 "\n")
3875
3876DEFUN (show_ip_ospf_database_type_adv_router,
3877 show_ip_ospf_database_type_adv_router_cmd,
3878 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3879 SHOW_STR
3880 IP_STR
3881 "OSPF information\n"
3882 "Database summary\n"
3883 OSPF_LSA_TYPES_DESC
3884 "Advertising Router link states\n"
3885 "Advertising Router (as an IP address)\n")
3886{
paul020709f2003-04-04 02:44:16 +00003887 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003888 int type, ret;
3889 struct in_addr adv_router;
3890
paul020709f2003-04-04 02:44:16 +00003891 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003892 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003893 return CMD_SUCCESS;
3894
3895 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003896 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003897
3898 if (argc != 2)
3899 return CMD_WARNING;
3900
3901 /* Set database type to show. */
3902 if (strncmp (argv[0], "r", 1) == 0)
3903 type = OSPF_ROUTER_LSA;
3904 else if (strncmp (argv[0], "ne", 2) == 0)
3905 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003906 else if (strncmp (argv[0], "ns", 2) == 0)
3907 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003908 else if (strncmp (argv[0], "s", 1) == 0)
3909 type = OSPF_SUMMARY_LSA;
3910 else if (strncmp (argv[0], "a", 1) == 0)
3911 type = OSPF_ASBR_SUMMARY_LSA;
3912 else if (strncmp (argv[0], "e", 1) == 0)
3913 type = OSPF_AS_EXTERNAL_LSA;
3914#ifdef HAVE_OPAQUE_LSA
3915 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3916 type = OSPF_OPAQUE_LINK_LSA;
3917 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3918 type = OSPF_OPAQUE_AREA_LSA;
3919 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3920 type = OSPF_OPAQUE_AS_LSA;
3921#endif /* HAVE_OPAQUE_LSA */
3922 else
3923 return CMD_WARNING;
3924
3925 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
3926 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003927 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003928 else
3929 {
3930 ret = inet_aton (argv[1], &adv_router);
3931 if (!ret)
3932 return CMD_WARNING;
3933 }
3934
paul020709f2003-04-04 02:44:16 +00003935 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00003936
3937 return CMD_SUCCESS;
3938}
3939
3940ALIAS (show_ip_ospf_database_type_adv_router,
3941 show_ip_ospf_database_type_self_cmd,
3942 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
3943 SHOW_STR
3944 IP_STR
3945 "OSPF information\n"
3946 "Database summary\n"
3947 OSPF_LSA_TYPES_DESC
3948 "Self-originated link states\n")
3949
3950
3951DEFUN (ip_ospf_authentication_args,
3952 ip_ospf_authentication_args_addr_cmd,
3953 "ip ospf authentication (null|message-digest) A.B.C.D",
3954 "IP Information\n"
3955 "OSPF interface commands\n"
3956 "Enable authentication on this interface\n"
3957 "Use null authentication\n"
3958 "Use message-digest authentication\n"
3959 "Address of interface")
3960{
3961 struct interface *ifp;
3962 struct in_addr addr;
3963 int ret;
3964 struct ospf_if_params *params;
3965
3966 ifp = vty->index;
3967 params = IF_DEF_PARAMS (ifp);
3968
3969 if (argc == 2)
3970 {
3971 ret = inet_aton(argv[1], &addr);
3972 if (!ret)
3973 {
3974 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3975 VTY_NEWLINE);
3976 return CMD_WARNING;
3977 }
3978
3979 params = ospf_get_if_params (ifp, addr);
3980 ospf_if_update_params (ifp, addr);
3981 }
3982
3983 /* Handle null authentication */
3984 if ( argv[0][0] == 'n' )
3985 {
3986 SET_IF_PARAM (params, auth_type);
3987 params->auth_type = OSPF_AUTH_NULL;
3988 return CMD_SUCCESS;
3989 }
3990
3991 /* Handle message-digest authentication */
3992 if ( argv[0][0] == 'm' )
3993 {
3994 SET_IF_PARAM (params, auth_type);
3995 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
3996 return CMD_SUCCESS;
3997 }
3998
3999 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4000 return CMD_WARNING;
4001}
4002
4003ALIAS (ip_ospf_authentication_args,
4004 ip_ospf_authentication_args_cmd,
4005 "ip ospf authentication (null|message-digest)",
4006 "IP Information\n"
4007 "OSPF interface commands\n"
4008 "Enable authentication on this interface\n"
4009 "Use null authentication\n"
4010 "Use message-digest authentication\n")
4011
4012DEFUN (ip_ospf_authentication,
4013 ip_ospf_authentication_addr_cmd,
4014 "ip ospf authentication A.B.C.D",
4015 "IP Information\n"
4016 "OSPF interface commands\n"
4017 "Enable authentication on this interface\n"
4018 "Address of interface")
4019{
4020 struct interface *ifp;
4021 struct in_addr addr;
4022 int ret;
4023 struct ospf_if_params *params;
4024
4025 ifp = vty->index;
4026 params = IF_DEF_PARAMS (ifp);
4027
4028 if (argc == 1)
4029 {
4030 ret = inet_aton(argv[1], &addr);
4031 if (!ret)
4032 {
4033 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4034 VTY_NEWLINE);
4035 return CMD_WARNING;
4036 }
4037
4038 params = ospf_get_if_params (ifp, addr);
4039 ospf_if_update_params (ifp, addr);
4040 }
4041
4042 SET_IF_PARAM (params, auth_type);
4043 params->auth_type = OSPF_AUTH_SIMPLE;
4044
4045 return CMD_SUCCESS;
4046}
4047
4048ALIAS (ip_ospf_authentication,
4049 ip_ospf_authentication_cmd,
4050 "ip ospf authentication",
4051 "IP Information\n"
4052 "OSPF interface commands\n"
4053 "Enable authentication on this interface\n")
4054
4055DEFUN (no_ip_ospf_authentication,
4056 no_ip_ospf_authentication_addr_cmd,
4057 "no ip ospf authentication A.B.C.D",
4058 NO_STR
4059 "IP Information\n"
4060 "OSPF interface commands\n"
4061 "Enable authentication on this interface\n"
4062 "Address of interface")
4063{
4064 struct interface *ifp;
4065 struct in_addr addr;
4066 int ret;
4067 struct ospf_if_params *params;
4068
4069 ifp = vty->index;
4070 params = IF_DEF_PARAMS (ifp);
4071
4072 if (argc == 1)
4073 {
4074 ret = inet_aton(argv[1], &addr);
4075 if (!ret)
4076 {
4077 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4078 VTY_NEWLINE);
4079 return CMD_WARNING;
4080 }
4081
4082 params = ospf_lookup_if_params (ifp, addr);
4083 if (params == NULL)
4084 return CMD_SUCCESS;
4085 }
4086
4087 params->auth_type = OSPF_AUTH_NOTSET;
4088 UNSET_IF_PARAM (params, auth_type);
4089
4090 if (params != IF_DEF_PARAMS (ifp))
4091 {
4092 ospf_free_if_params (ifp, addr);
4093 ospf_if_update_params (ifp, addr);
4094 }
4095
4096 return CMD_SUCCESS;
4097}
4098
4099ALIAS (no_ip_ospf_authentication,
4100 no_ip_ospf_authentication_cmd,
4101 "no ip ospf authentication",
4102 NO_STR
4103 "IP Information\n"
4104 "OSPF interface commands\n"
4105 "Enable authentication on this interface\n")
4106
4107DEFUN (ip_ospf_authentication_key,
4108 ip_ospf_authentication_key_addr_cmd,
4109 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4110 "IP Information\n"
4111 "OSPF interface commands\n"
4112 "Authentication password (key)\n"
4113 "The OSPF password (key)\n"
4114 "Address of interface")
4115{
4116 struct interface *ifp;
4117 struct in_addr addr;
4118 int ret;
4119 struct ospf_if_params *params;
4120
4121 ifp = vty->index;
4122 params = IF_DEF_PARAMS (ifp);
4123
4124 if (argc == 2)
4125 {
4126 ret = inet_aton(argv[1], &addr);
4127 if (!ret)
4128 {
4129 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4130 VTY_NEWLINE);
4131 return CMD_WARNING;
4132 }
4133
4134 params = ospf_get_if_params (ifp, addr);
4135 ospf_if_update_params (ifp, addr);
4136 }
4137
4138
4139 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004140 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004141 SET_IF_PARAM (params, auth_simple);
4142
4143 return CMD_SUCCESS;
4144}
4145
4146ALIAS (ip_ospf_authentication_key,
4147 ip_ospf_authentication_key_cmd,
4148 "ip ospf authentication-key AUTH_KEY",
4149 "IP Information\n"
4150 "OSPF interface commands\n"
4151 "Authentication password (key)\n"
4152 "The OSPF password (key)")
4153
4154ALIAS (ip_ospf_authentication_key,
4155 ospf_authentication_key_cmd,
4156 "ospf authentication-key AUTH_KEY",
4157 "OSPF interface commands\n"
4158 "Authentication password (key)\n"
4159 "The OSPF password (key)")
4160
4161DEFUN (no_ip_ospf_authentication_key,
4162 no_ip_ospf_authentication_key_addr_cmd,
4163 "no ip ospf authentication-key A.B.C.D",
4164 NO_STR
4165 "IP Information\n"
4166 "OSPF interface commands\n"
4167 "Authentication password (key)\n"
4168 "Address of interface")
4169{
4170 struct interface *ifp;
4171 struct in_addr addr;
4172 int ret;
4173 struct ospf_if_params *params;
4174
4175 ifp = vty->index;
4176 params = IF_DEF_PARAMS (ifp);
4177
4178 if (argc == 2)
4179 {
4180 ret = inet_aton(argv[1], &addr);
4181 if (!ret)
4182 {
4183 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4184 VTY_NEWLINE);
4185 return CMD_WARNING;
4186 }
4187
4188 params = ospf_lookup_if_params (ifp, addr);
4189 if (params == NULL)
4190 return CMD_SUCCESS;
4191 }
4192
4193 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4194 UNSET_IF_PARAM (params, auth_simple);
4195
4196 if (params != IF_DEF_PARAMS (ifp))
4197 {
4198 ospf_free_if_params (ifp, addr);
4199 ospf_if_update_params (ifp, addr);
4200 }
4201
4202 return CMD_SUCCESS;
4203}
4204
4205ALIAS (no_ip_ospf_authentication_key,
4206 no_ip_ospf_authentication_key_cmd,
4207 "no ip ospf authentication-key",
4208 NO_STR
4209 "IP Information\n"
4210 "OSPF interface commands\n"
4211 "Authentication password (key)\n")
4212
4213ALIAS (no_ip_ospf_authentication_key,
4214 no_ospf_authentication_key_cmd,
4215 "no ospf authentication-key",
4216 NO_STR
4217 "OSPF interface commands\n"
4218 "Authentication password (key)\n")
4219
4220DEFUN (ip_ospf_message_digest_key,
4221 ip_ospf_message_digest_key_addr_cmd,
4222 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4223 "IP Information\n"
4224 "OSPF interface commands\n"
4225 "Message digest authentication password (key)\n"
4226 "Key ID\n"
4227 "Use MD5 algorithm\n"
4228 "The OSPF password (key)"
4229 "Address of interface")
4230{
4231 struct interface *ifp;
4232 struct crypt_key *ck;
4233 u_char key_id;
4234 struct in_addr addr;
4235 int ret;
4236 struct ospf_if_params *params;
4237
4238 ifp = vty->index;
4239 params = IF_DEF_PARAMS (ifp);
4240
4241 if (argc == 3)
4242 {
4243 ret = inet_aton(argv[2], &addr);
4244 if (!ret)
4245 {
4246 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4247 VTY_NEWLINE);
4248 return CMD_WARNING;
4249 }
4250
4251 params = ospf_get_if_params (ifp, addr);
4252 ospf_if_update_params (ifp, addr);
4253 }
4254
4255 key_id = strtol (argv[0], NULL, 10);
4256 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4257 {
4258 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4259 return CMD_WARNING;
4260 }
4261
4262 ck = ospf_crypt_key_new ();
4263 ck->key_id = (u_char) key_id;
4264 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004265 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004266
4267 ospf_crypt_key_add (params->auth_crypt, ck);
4268 SET_IF_PARAM (params, auth_crypt);
4269
4270 return CMD_SUCCESS;
4271}
4272
4273ALIAS (ip_ospf_message_digest_key,
4274 ip_ospf_message_digest_key_cmd,
4275 "ip ospf message-digest-key <1-255> md5 KEY",
4276 "IP Information\n"
4277 "OSPF interface commands\n"
4278 "Message digest authentication password (key)\n"
4279 "Key ID\n"
4280 "Use MD5 algorithm\n"
4281 "The OSPF password (key)")
4282
4283ALIAS (ip_ospf_message_digest_key,
4284 ospf_message_digest_key_cmd,
4285 "ospf message-digest-key <1-255> md5 KEY",
4286 "OSPF interface commands\n"
4287 "Message digest authentication password (key)\n"
4288 "Key ID\n"
4289 "Use MD5 algorithm\n"
4290 "The OSPF password (key)")
4291
4292DEFUN (no_ip_ospf_message_digest_key,
4293 no_ip_ospf_message_digest_key_addr_cmd,
4294 "no ip ospf message-digest-key <1-255> A.B.C.D",
4295 NO_STR
4296 "IP Information\n"
4297 "OSPF interface commands\n"
4298 "Message digest authentication password (key)\n"
4299 "Key ID\n"
4300 "Address of interface")
4301{
4302 struct interface *ifp;
4303 struct crypt_key *ck;
4304 int key_id;
4305 struct in_addr addr;
4306 int ret;
4307 struct ospf_if_params *params;
4308
4309 ifp = vty->index;
4310 params = IF_DEF_PARAMS (ifp);
4311
4312 if (argc == 2)
4313 {
4314 ret = inet_aton(argv[1], &addr);
4315 if (!ret)
4316 {
4317 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4318 VTY_NEWLINE);
4319 return CMD_WARNING;
4320 }
4321
4322 params = ospf_lookup_if_params (ifp, addr);
4323 if (params == NULL)
4324 return CMD_SUCCESS;
4325 }
4326
4327 key_id = strtol (argv[0], NULL, 10);
4328 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4329 if (ck == NULL)
4330 {
4331 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4332 return CMD_WARNING;
4333 }
4334
4335 ospf_crypt_key_delete (params->auth_crypt, key_id);
4336
4337 if (params != IF_DEF_PARAMS (ifp))
4338 {
4339 ospf_free_if_params (ifp, addr);
4340 ospf_if_update_params (ifp, addr);
4341 }
4342
4343 return CMD_SUCCESS;
4344}
4345
4346ALIAS (no_ip_ospf_message_digest_key,
4347 no_ip_ospf_message_digest_key_cmd,
4348 "no ip ospf message-digest-key <1-255>",
4349 NO_STR
4350 "IP Information\n"
4351 "OSPF interface commands\n"
4352 "Message digest authentication password (key)\n"
4353 "Key ID\n")
4354
4355ALIAS (no_ip_ospf_message_digest_key,
4356 no_ospf_message_digest_key_cmd,
4357 "no ospf message-digest-key <1-255>",
4358 NO_STR
4359 "OSPF interface commands\n"
4360 "Message digest authentication password (key)\n"
4361 "Key ID\n")
4362
4363DEFUN (ip_ospf_cost,
4364 ip_ospf_cost_addr_cmd,
4365 "ip ospf cost <1-65535> A.B.C.D",
4366 "IP Information\n"
4367 "OSPF interface commands\n"
4368 "Interface cost\n"
4369 "Cost\n"
4370 "Address of interface")
4371{
4372 struct interface *ifp = vty->index;
4373 u_int32_t cost;
4374 struct in_addr addr;
4375 int ret;
4376 struct ospf_if_params *params;
4377
4378 params = IF_DEF_PARAMS (ifp);
4379
4380 cost = strtol (argv[0], NULL, 10);
4381
4382 /* cost range is <1-65535>. */
4383 if (cost < 1 || cost > 65535)
4384 {
4385 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4386 return CMD_WARNING;
4387 }
4388
4389 if (argc == 2)
4390 {
4391 ret = inet_aton(argv[1], &addr);
4392 if (!ret)
4393 {
4394 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4395 VTY_NEWLINE);
4396 return CMD_WARNING;
4397 }
4398
4399 params = ospf_get_if_params (ifp, addr);
4400 ospf_if_update_params (ifp, addr);
4401 }
4402
4403 SET_IF_PARAM (params, output_cost_cmd);
4404 params->output_cost_cmd = cost;
4405
4406 ospf_if_recalculate_output_cost (ifp);
4407
4408 return CMD_SUCCESS;
4409}
4410
4411ALIAS (ip_ospf_cost,
4412 ip_ospf_cost_cmd,
4413 "ip ospf cost <1-65535>",
4414 "IP Information\n"
4415 "OSPF interface commands\n"
4416 "Interface cost\n"
4417 "Cost")
4418
4419ALIAS (ip_ospf_cost,
4420 ospf_cost_cmd,
4421 "ospf cost <1-65535>",
4422 "OSPF interface commands\n"
4423 "Interface cost\n"
4424 "Cost")
4425
4426DEFUN (no_ip_ospf_cost,
4427 no_ip_ospf_cost_addr_cmd,
4428 "no ip ospf cost A.B.C.D",
4429 NO_STR
4430 "IP Information\n"
4431 "OSPF interface commands\n"
4432 "Interface cost\n"
4433 "Address of interface")
4434{
4435 struct interface *ifp = vty->index;
4436 struct in_addr addr;
4437 int ret;
4438 struct ospf_if_params *params;
4439
4440 ifp = vty->index;
4441 params = IF_DEF_PARAMS (ifp);
4442
4443 if (argc == 1)
4444 {
4445 ret = inet_aton(argv[0], &addr);
4446 if (!ret)
4447 {
4448 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4449 VTY_NEWLINE);
4450 return CMD_WARNING;
4451 }
4452
4453 params = ospf_lookup_if_params (ifp, addr);
4454 if (params == NULL)
4455 return CMD_SUCCESS;
4456 }
4457
4458 UNSET_IF_PARAM (params, output_cost_cmd);
4459
4460 if (params != IF_DEF_PARAMS (ifp))
4461 {
4462 ospf_free_if_params (ifp, addr);
4463 ospf_if_update_params (ifp, addr);
4464 }
4465
4466 ospf_if_recalculate_output_cost (ifp);
4467
4468 return CMD_SUCCESS;
4469}
4470
4471ALIAS (no_ip_ospf_cost,
4472 no_ip_ospf_cost_cmd,
4473 "no ip ospf cost",
4474 NO_STR
4475 "IP Information\n"
4476 "OSPF interface commands\n"
4477 "Interface cost\n")
4478
4479ALIAS (no_ip_ospf_cost,
4480 no_ospf_cost_cmd,
4481 "no ospf cost",
4482 NO_STR
4483 "OSPF interface commands\n"
4484 "Interface cost\n")
4485
4486void
4487ospf_nbr_timer_update (struct ospf_interface *oi)
4488{
4489 struct route_node *rn;
4490 struct ospf_neighbor *nbr;
4491
4492 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4493 if ((nbr = rn->info))
4494 {
4495 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4496 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4497 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4498 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4499 }
4500}
4501
4502DEFUN (ip_ospf_dead_interval,
4503 ip_ospf_dead_interval_addr_cmd,
4504 "ip ospf dead-interval <1-65535> A.B.C.D",
4505 "IP Information\n"
4506 "OSPF interface commands\n"
4507 "Interval after which a neighbor is declared dead\n"
4508 "Seconds\n"
4509 "Address of interface")
4510{
4511 struct interface *ifp = vty->index;
4512 u_int32_t seconds;
4513 struct in_addr addr;
4514 int ret;
4515 struct ospf_if_params *params;
4516 struct ospf_interface *oi;
4517 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004518 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004519
paul020709f2003-04-04 02:44:16 +00004520 ospf = ospf_lookup ();
4521
paul718e3742002-12-13 20:15:29 +00004522 params = IF_DEF_PARAMS (ifp);
4523
4524 seconds = strtol (argv[0], NULL, 10);
4525
4526 /* dead_interval range is <1-65535>. */
4527 if (seconds < 1 || seconds > 65535)
4528 {
4529 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4530 return CMD_WARNING;
4531 }
4532
4533 if (argc == 2)
4534 {
4535 ret = inet_aton(argv[1], &addr);
4536 if (!ret)
4537 {
4538 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4539 VTY_NEWLINE);
4540 return CMD_WARNING;
4541 }
4542
4543 params = ospf_get_if_params (ifp, addr);
4544 ospf_if_update_params (ifp, addr);
4545 }
4546
4547 SET_IF_PARAM (params, v_wait);
4548 params->v_wait = seconds;
4549
4550 /* Update timer values in neighbor structure. */
4551 if (argc == 2)
4552 {
paul68980082003-03-25 05:07:42 +00004553 if (ospf)
4554 {
4555 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4556 if (oi)
4557 ospf_nbr_timer_update (oi);
4558 }
paul718e3742002-12-13 20:15:29 +00004559 }
4560 else
4561 {
4562 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4563 if ((oi = rn->info))
4564 ospf_nbr_timer_update (oi);
4565 }
4566
4567 return CMD_SUCCESS;
4568}
4569
4570ALIAS (ip_ospf_dead_interval,
4571 ip_ospf_dead_interval_cmd,
4572 "ip ospf dead-interval <1-65535>",
4573 "IP Information\n"
4574 "OSPF interface commands\n"
4575 "Interval after which a neighbor is declared dead\n"
4576 "Seconds\n")
4577
4578ALIAS (ip_ospf_dead_interval,
4579 ospf_dead_interval_cmd,
4580 "ospf dead-interval <1-65535>",
4581 "OSPF interface commands\n"
4582 "Interval after which a neighbor is declared dead\n"
4583 "Seconds\n")
4584
4585DEFUN (no_ip_ospf_dead_interval,
4586 no_ip_ospf_dead_interval_addr_cmd,
4587 "no ip ospf dead-interval A.B.C.D",
4588 NO_STR
4589 "IP Information\n"
4590 "OSPF interface commands\n"
4591 "Interval after which a neighbor is declared dead\n"
4592 "Address of interface")
4593{
4594 struct interface *ifp = vty->index;
4595 struct in_addr addr;
4596 int ret;
4597 struct ospf_if_params *params;
4598 struct ospf_interface *oi;
4599 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004600 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004601
paul020709f2003-04-04 02:44:16 +00004602 ospf = ospf_lookup ();
4603
paul718e3742002-12-13 20:15:29 +00004604 ifp = vty->index;
4605 params = IF_DEF_PARAMS (ifp);
4606
4607 if (argc == 1)
4608 {
4609 ret = inet_aton(argv[0], &addr);
4610 if (!ret)
4611 {
4612 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4613 VTY_NEWLINE);
4614 return CMD_WARNING;
4615 }
4616
4617 params = ospf_lookup_if_params (ifp, addr);
4618 if (params == NULL)
4619 return CMD_SUCCESS;
4620 }
4621
4622 UNSET_IF_PARAM (params, v_wait);
4623 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4624
4625 if (params != IF_DEF_PARAMS (ifp))
4626 {
4627 ospf_free_if_params (ifp, addr);
4628 ospf_if_update_params (ifp, addr);
4629 }
4630
4631 /* Update timer values in neighbor structure. */
4632 if (argc == 1)
4633 {
paul68980082003-03-25 05:07:42 +00004634 if (ospf)
4635 {
4636 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4637 if (oi)
4638 ospf_nbr_timer_update (oi);
4639 }
paul718e3742002-12-13 20:15:29 +00004640 }
4641 else
4642 {
4643 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4644 if ((oi = rn->info))
4645 ospf_nbr_timer_update (oi);
4646 }
4647
4648 return CMD_SUCCESS;
4649}
4650
4651ALIAS (no_ip_ospf_dead_interval,
4652 no_ip_ospf_dead_interval_cmd,
4653 "no ip ospf dead-interval",
4654 NO_STR
4655 "IP Information\n"
4656 "OSPF interface commands\n"
4657 "Interval after which a neighbor is declared dead\n")
4658
4659ALIAS (no_ip_ospf_dead_interval,
4660 no_ospf_dead_interval_cmd,
4661 "no ospf dead-interval",
4662 NO_STR
4663 "OSPF interface commands\n"
4664 "Interval after which a neighbor is declared dead\n")
4665
4666DEFUN (ip_ospf_hello_interval,
4667 ip_ospf_hello_interval_addr_cmd,
4668 "ip ospf hello-interval <1-65535> A.B.C.D",
4669 "IP Information\n"
4670 "OSPF interface commands\n"
4671 "Time between HELLO packets\n"
4672 "Seconds\n"
4673 "Address of interface")
4674{
4675 struct interface *ifp = vty->index;
4676 u_int32_t seconds;
4677 struct in_addr addr;
4678 int ret;
4679 struct ospf_if_params *params;
4680
4681 params = IF_DEF_PARAMS (ifp);
4682
4683 seconds = strtol (argv[0], NULL, 10);
4684
4685 /* HelloInterval range is <1-65535>. */
4686 if (seconds < 1 || seconds > 65535)
4687 {
4688 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4689 return CMD_WARNING;
4690 }
4691
4692 if (argc == 2)
4693 {
4694 ret = inet_aton(argv[1], &addr);
4695 if (!ret)
4696 {
4697 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4698 VTY_NEWLINE);
4699 return CMD_WARNING;
4700 }
4701
4702 params = ospf_get_if_params (ifp, addr);
4703 ospf_if_update_params (ifp, addr);
4704 }
4705
4706 SET_IF_PARAM (params, v_hello);
4707 params->v_hello = seconds;
4708
4709 return CMD_SUCCESS;
4710}
4711
4712ALIAS (ip_ospf_hello_interval,
4713 ip_ospf_hello_interval_cmd,
4714 "ip ospf hello-interval <1-65535>",
4715 "IP Information\n"
4716 "OSPF interface commands\n"
4717 "Time between HELLO packets\n"
4718 "Seconds\n")
4719
4720ALIAS (ip_ospf_hello_interval,
4721 ospf_hello_interval_cmd,
4722 "ospf hello-interval <1-65535>",
4723 "OSPF interface commands\n"
4724 "Time between HELLO packets\n"
4725 "Seconds\n")
4726
4727DEFUN (no_ip_ospf_hello_interval,
4728 no_ip_ospf_hello_interval_addr_cmd,
4729 "no ip ospf hello-interval A.B.C.D",
4730 NO_STR
4731 "IP Information\n"
4732 "OSPF interface commands\n"
4733 "Time between HELLO packets\n"
4734 "Address of interface")
4735{
4736 struct interface *ifp = vty->index;
4737 struct in_addr addr;
4738 int ret;
4739 struct ospf_if_params *params;
4740
4741 ifp = vty->index;
4742 params = IF_DEF_PARAMS (ifp);
4743
4744 if (argc == 1)
4745 {
4746 ret = inet_aton(argv[0], &addr);
4747 if (!ret)
4748 {
4749 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4750 VTY_NEWLINE);
4751 return CMD_WARNING;
4752 }
4753
4754 params = ospf_lookup_if_params (ifp, addr);
4755 if (params == NULL)
4756 return CMD_SUCCESS;
4757 }
4758
4759 UNSET_IF_PARAM (params, v_hello);
4760 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4761
4762 if (params != IF_DEF_PARAMS (ifp))
4763 {
4764 ospf_free_if_params (ifp, addr);
4765 ospf_if_update_params (ifp, addr);
4766 }
4767
4768 return CMD_SUCCESS;
4769}
4770
4771ALIAS (no_ip_ospf_hello_interval,
4772 no_ip_ospf_hello_interval_cmd,
4773 "no ip ospf hello-interval",
4774 NO_STR
4775 "IP Information\n"
4776 "OSPF interface commands\n"
4777 "Time between HELLO packets\n")
4778
4779ALIAS (no_ip_ospf_hello_interval,
4780 no_ospf_hello_interval_cmd,
4781 "no ospf hello-interval",
4782 NO_STR
4783 "OSPF interface commands\n"
4784 "Time between HELLO packets\n")
4785
4786DEFUN (ip_ospf_network,
4787 ip_ospf_network_cmd,
4788 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4789 "IP Information\n"
4790 "OSPF interface commands\n"
4791 "Network type\n"
4792 "Specify OSPF broadcast multi-access network\n"
4793 "Specify OSPF NBMA network\n"
4794 "Specify OSPF point-to-multipoint network\n"
4795 "Specify OSPF point-to-point network\n")
4796{
4797 struct interface *ifp = vty->index;
4798 int old_type = IF_DEF_PARAMS (ifp)->type;
4799 struct route_node *rn;
4800
4801 if (strncmp (argv[0], "b", 1) == 0)
4802 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4803 else if (strncmp (argv[0], "n", 1) == 0)
4804 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4805 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4806 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4807 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4808 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4809
4810 if (IF_DEF_PARAMS (ifp)->type == old_type)
4811 return CMD_SUCCESS;
4812
4813 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4814
4815 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4816 {
4817 struct ospf_interface *oi = rn->info;
4818
4819 if (!oi)
4820 continue;
4821
4822 oi->type = IF_DEF_PARAMS (ifp)->type;
4823
4824 if (oi->state > ISM_Down)
4825 {
4826 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4827 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4828 }
4829 }
4830
4831 return CMD_SUCCESS;
4832}
4833
4834ALIAS (ip_ospf_network,
4835 ospf_network_cmd,
4836 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4837 "OSPF interface commands\n"
4838 "Network type\n"
4839 "Specify OSPF broadcast multi-access network\n"
4840 "Specify OSPF NBMA network\n"
4841 "Specify OSPF point-to-multipoint network\n"
4842 "Specify OSPF point-to-point network\n")
4843
4844DEFUN (no_ip_ospf_network,
4845 no_ip_ospf_network_cmd,
4846 "no ip ospf network",
4847 NO_STR
4848 "IP Information\n"
4849 "OSPF interface commands\n"
4850 "Network type\n")
4851{
4852 struct interface *ifp = vty->index;
4853 int old_type = IF_DEF_PARAMS (ifp)->type;
4854 struct route_node *rn;
4855
ajsbc18d612004-12-15 15:07:19 +00004856 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00004857
4858 if (IF_DEF_PARAMS (ifp)->type == old_type)
4859 return CMD_SUCCESS;
4860
4861 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4862 {
4863 struct ospf_interface *oi = rn->info;
4864
4865 if (!oi)
4866 continue;
4867
4868 oi->type = IF_DEF_PARAMS (ifp)->type;
4869
4870 if (oi->state > ISM_Down)
4871 {
4872 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4873 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4874 }
4875 }
4876
4877 return CMD_SUCCESS;
4878}
4879
4880ALIAS (no_ip_ospf_network,
4881 no_ospf_network_cmd,
4882 "no ospf network",
4883 NO_STR
4884 "OSPF interface commands\n"
4885 "Network type\n")
4886
4887DEFUN (ip_ospf_priority,
4888 ip_ospf_priority_addr_cmd,
4889 "ip ospf priority <0-255> A.B.C.D",
4890 "IP Information\n"
4891 "OSPF interface commands\n"
4892 "Router priority\n"
4893 "Priority\n"
4894 "Address of interface")
4895{
4896 struct interface *ifp = vty->index;
4897 u_int32_t priority;
4898 struct route_node *rn;
4899 struct in_addr addr;
4900 int ret;
4901 struct ospf_if_params *params;
4902
4903 params = IF_DEF_PARAMS (ifp);
4904
4905 priority = strtol (argv[0], NULL, 10);
4906
4907 /* Router Priority range is <0-255>. */
4908 if (priority < 0 || priority > 255)
4909 {
4910 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4911 return CMD_WARNING;
4912 }
4913
4914 if (argc == 2)
4915 {
4916 ret = inet_aton(argv[1], &addr);
4917 if (!ret)
4918 {
4919 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4920 VTY_NEWLINE);
4921 return CMD_WARNING;
4922 }
4923
4924 params = ospf_get_if_params (ifp, addr);
4925 ospf_if_update_params (ifp, addr);
4926 }
4927
4928 SET_IF_PARAM (params, priority);
4929 params->priority = priority;
4930
4931 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4932 {
4933 struct ospf_interface *oi = rn->info;
4934
4935 if (!oi)
4936 continue;
4937
4938
4939 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
4940 {
4941 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
4942 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
4943 }
4944 }
4945
4946 return CMD_SUCCESS;
4947}
4948
4949ALIAS (ip_ospf_priority,
4950 ip_ospf_priority_cmd,
4951 "ip ospf priority <0-255>",
4952 "IP Information\n"
4953 "OSPF interface commands\n"
4954 "Router priority\n"
4955 "Priority\n")
4956
4957ALIAS (ip_ospf_priority,
4958 ospf_priority_cmd,
4959 "ospf priority <0-255>",
4960 "OSPF interface commands\n"
4961 "Router priority\n"
4962 "Priority\n")
4963
4964DEFUN (no_ip_ospf_priority,
4965 no_ip_ospf_priority_addr_cmd,
4966 "no ip ospf priority A.B.C.D",
4967 NO_STR
4968 "IP Information\n"
4969 "OSPF interface commands\n"
4970 "Router priority\n"
4971 "Address of interface")
4972{
4973 struct interface *ifp = vty->index;
4974 struct route_node *rn;
4975 struct in_addr addr;
4976 int ret;
4977 struct ospf_if_params *params;
4978
4979 ifp = vty->index;
4980 params = IF_DEF_PARAMS (ifp);
4981
4982 if (argc == 1)
4983 {
4984 ret = inet_aton(argv[0], &addr);
4985 if (!ret)
4986 {
4987 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4988 VTY_NEWLINE);
4989 return CMD_WARNING;
4990 }
4991
4992 params = ospf_lookup_if_params (ifp, addr);
4993 if (params == NULL)
4994 return CMD_SUCCESS;
4995 }
4996
4997 UNSET_IF_PARAM (params, priority);
4998 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
4999
5000 if (params != IF_DEF_PARAMS (ifp))
5001 {
5002 ospf_free_if_params (ifp, addr);
5003 ospf_if_update_params (ifp, addr);
5004 }
5005
5006 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5007 {
5008 struct ospf_interface *oi = rn->info;
5009
5010 if (!oi)
5011 continue;
5012
5013
5014 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5015 {
5016 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5017 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5018 }
5019 }
5020
5021 return CMD_SUCCESS;
5022}
5023
5024ALIAS (no_ip_ospf_priority,
5025 no_ip_ospf_priority_cmd,
5026 "no ip ospf priority",
5027 NO_STR
5028 "IP Information\n"
5029 "OSPF interface commands\n"
5030 "Router priority\n")
5031
5032ALIAS (no_ip_ospf_priority,
5033 no_ospf_priority_cmd,
5034 "no ospf priority",
5035 NO_STR
5036 "OSPF interface commands\n"
5037 "Router priority\n")
5038
5039DEFUN (ip_ospf_retransmit_interval,
5040 ip_ospf_retransmit_interval_addr_cmd,
5041 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5042 "IP Information\n"
5043 "OSPF interface commands\n"
5044 "Time between retransmitting lost link state advertisements\n"
5045 "Seconds\n"
5046 "Address of interface")
5047{
5048 struct interface *ifp = vty->index;
5049 u_int32_t seconds;
5050 struct in_addr addr;
5051 int ret;
5052 struct ospf_if_params *params;
5053
5054 params = IF_DEF_PARAMS (ifp);
5055 seconds = strtol (argv[0], NULL, 10);
5056
5057 /* Retransmit Interval range is <3-65535>. */
5058 if (seconds < 3 || seconds > 65535)
5059 {
5060 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5061 return CMD_WARNING;
5062 }
5063
5064
5065 if (argc == 2)
5066 {
5067 ret = inet_aton(argv[1], &addr);
5068 if (!ret)
5069 {
5070 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5071 VTY_NEWLINE);
5072 return CMD_WARNING;
5073 }
5074
5075 params = ospf_get_if_params (ifp, addr);
5076 ospf_if_update_params (ifp, addr);
5077 }
5078
5079 SET_IF_PARAM (params, retransmit_interval);
5080 params->retransmit_interval = seconds;
5081
5082 return CMD_SUCCESS;
5083}
5084
5085ALIAS (ip_ospf_retransmit_interval,
5086 ip_ospf_retransmit_interval_cmd,
5087 "ip ospf retransmit-interval <3-65535>",
5088 "IP Information\n"
5089 "OSPF interface commands\n"
5090 "Time between retransmitting lost link state advertisements\n"
5091 "Seconds\n")
5092
5093ALIAS (ip_ospf_retransmit_interval,
5094 ospf_retransmit_interval_cmd,
5095 "ospf retransmit-interval <3-65535>",
5096 "OSPF interface commands\n"
5097 "Time between retransmitting lost link state advertisements\n"
5098 "Seconds\n")
5099
5100DEFUN (no_ip_ospf_retransmit_interval,
5101 no_ip_ospf_retransmit_interval_addr_cmd,
5102 "no ip ospf retransmit-interval A.B.C.D",
5103 NO_STR
5104 "IP Information\n"
5105 "OSPF interface commands\n"
5106 "Time between retransmitting lost link state advertisements\n"
5107 "Address of interface")
5108{
5109 struct interface *ifp = vty->index;
5110 struct in_addr addr;
5111 int ret;
5112 struct ospf_if_params *params;
5113
5114 ifp = vty->index;
5115 params = IF_DEF_PARAMS (ifp);
5116
5117 if (argc == 1)
5118 {
5119 ret = inet_aton(argv[0], &addr);
5120 if (!ret)
5121 {
5122 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5123 VTY_NEWLINE);
5124 return CMD_WARNING;
5125 }
5126
5127 params = ospf_lookup_if_params (ifp, addr);
5128 if (params == NULL)
5129 return CMD_SUCCESS;
5130 }
5131
5132 UNSET_IF_PARAM (params, retransmit_interval);
5133 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5134
5135 if (params != IF_DEF_PARAMS (ifp))
5136 {
5137 ospf_free_if_params (ifp, addr);
5138 ospf_if_update_params (ifp, addr);
5139 }
5140
5141 return CMD_SUCCESS;
5142}
5143
5144ALIAS (no_ip_ospf_retransmit_interval,
5145 no_ip_ospf_retransmit_interval_cmd,
5146 "no ip ospf retransmit-interval",
5147 NO_STR
5148 "IP Information\n"
5149 "OSPF interface commands\n"
5150 "Time between retransmitting lost link state advertisements\n")
5151
5152ALIAS (no_ip_ospf_retransmit_interval,
5153 no_ospf_retransmit_interval_cmd,
5154 "no ospf retransmit-interval",
5155 NO_STR
5156 "OSPF interface commands\n"
5157 "Time between retransmitting lost link state advertisements\n")
5158
5159DEFUN (ip_ospf_transmit_delay,
5160 ip_ospf_transmit_delay_addr_cmd,
5161 "ip ospf transmit-delay <1-65535> A.B.C.D",
5162 "IP Information\n"
5163 "OSPF interface commands\n"
5164 "Link state transmit delay\n"
5165 "Seconds\n"
5166 "Address of interface")
5167{
5168 struct interface *ifp = vty->index;
5169 u_int32_t seconds;
5170 struct in_addr addr;
5171 int ret;
5172 struct ospf_if_params *params;
5173
5174 params = IF_DEF_PARAMS (ifp);
5175 seconds = strtol (argv[0], NULL, 10);
5176
5177 /* Transmit Delay range is <1-65535>. */
5178 if (seconds < 1 || seconds > 65535)
5179 {
5180 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5181 return CMD_WARNING;
5182 }
5183
5184 if (argc == 2)
5185 {
5186 ret = inet_aton(argv[1], &addr);
5187 if (!ret)
5188 {
5189 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5190 VTY_NEWLINE);
5191 return CMD_WARNING;
5192 }
5193
5194 params = ospf_get_if_params (ifp, addr);
5195 ospf_if_update_params (ifp, addr);
5196 }
5197
5198 SET_IF_PARAM (params, transmit_delay);
5199 params->transmit_delay = seconds;
5200
5201 return CMD_SUCCESS;
5202}
5203
5204ALIAS (ip_ospf_transmit_delay,
5205 ip_ospf_transmit_delay_cmd,
5206 "ip ospf transmit-delay <1-65535>",
5207 "IP Information\n"
5208 "OSPF interface commands\n"
5209 "Link state transmit delay\n"
5210 "Seconds\n")
5211
5212ALIAS (ip_ospf_transmit_delay,
5213 ospf_transmit_delay_cmd,
5214 "ospf transmit-delay <1-65535>",
5215 "OSPF interface commands\n"
5216 "Link state transmit delay\n"
5217 "Seconds\n")
5218
5219DEFUN (no_ip_ospf_transmit_delay,
5220 no_ip_ospf_transmit_delay_addr_cmd,
5221 "no ip ospf transmit-delay A.B.C.D",
5222 NO_STR
5223 "IP Information\n"
5224 "OSPF interface commands\n"
5225 "Link state transmit delay\n"
5226 "Address of interface")
5227{
5228 struct interface *ifp = vty->index;
5229 struct in_addr addr;
5230 int ret;
5231 struct ospf_if_params *params;
5232
5233 ifp = vty->index;
5234 params = IF_DEF_PARAMS (ifp);
5235
5236 if (argc == 1)
5237 {
5238 ret = inet_aton(argv[0], &addr);
5239 if (!ret)
5240 {
5241 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5242 VTY_NEWLINE);
5243 return CMD_WARNING;
5244 }
5245
5246 params = ospf_lookup_if_params (ifp, addr);
5247 if (params == NULL)
5248 return CMD_SUCCESS;
5249 }
5250
5251 UNSET_IF_PARAM (params, transmit_delay);
5252 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5253
5254 if (params != IF_DEF_PARAMS (ifp))
5255 {
5256 ospf_free_if_params (ifp, addr);
5257 ospf_if_update_params (ifp, addr);
5258 }
5259
5260 return CMD_SUCCESS;
5261}
5262
5263ALIAS (no_ip_ospf_transmit_delay,
5264 no_ip_ospf_transmit_delay_cmd,
5265 "no ip ospf transmit-delay",
5266 NO_STR
5267 "IP Information\n"
5268 "OSPF interface commands\n"
5269 "Link state transmit delay\n")
5270
5271ALIAS (no_ip_ospf_transmit_delay,
5272 no_ospf_transmit_delay_cmd,
5273 "no ospf transmit-delay",
5274 NO_STR
5275 "OSPF interface commands\n"
5276 "Link state transmit delay\n")
5277
5278
5279DEFUN (ospf_redistribute_source_metric_type,
5280 ospf_redistribute_source_metric_type_routemap_cmd,
5281 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5282 "Redistribute information from another routing protocol\n"
5283 "Kernel routes\n"
5284 "Connected\n"
5285 "Static routes\n"
5286 "Routing Information Protocol (RIP)\n"
5287 "Border Gateway Protocol (BGP)\n"
5288 "Metric for redistributed routes\n"
5289 "OSPF default metric\n"
5290 "OSPF exterior metric type for redistributed routes\n"
5291 "Set OSPF External Type 1 metrics\n"
5292 "Set OSPF External Type 2 metrics\n"
5293 "Route map reference\n"
5294 "Pointer to route-map entries\n")
5295{
paul020709f2003-04-04 02:44:16 +00005296 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005297 int source;
5298 int type = -1;
5299 int metric = -1;
5300
5301 /* Get distribute source. */
5302 if (!str2distribute_source (argv[0], &source))
5303 return CMD_WARNING;
5304
5305 /* Get metric value. */
5306 if (argc >= 2)
5307 if (!str2metric (argv[1], &metric))
5308 return CMD_WARNING;
5309
5310 /* Get metric type. */
5311 if (argc >= 3)
5312 if (!str2metric_type (argv[2], &type))
5313 return CMD_WARNING;
5314
5315 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005316 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005317 else
paul020709f2003-04-04 02:44:16 +00005318 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005319
paul020709f2003-04-04 02:44:16 +00005320 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005321}
5322
5323ALIAS (ospf_redistribute_source_metric_type,
5324 ospf_redistribute_source_metric_type_cmd,
5325 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5326 "Redistribute information from another routing protocol\n"
5327 "Kernel routes\n"
5328 "Connected\n"
5329 "Static routes\n"
5330 "Routing Information Protocol (RIP)\n"
5331 "Border Gateway Protocol (BGP)\n"
5332 "Metric for redistributed routes\n"
5333 "OSPF default metric\n"
5334 "OSPF exterior metric type for redistributed routes\n"
5335 "Set OSPF External Type 1 metrics\n"
5336 "Set OSPF External Type 2 metrics\n")
5337
5338ALIAS (ospf_redistribute_source_metric_type,
5339 ospf_redistribute_source_metric_cmd,
5340 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5341 "Redistribute information from another routing protocol\n"
5342 "Kernel routes\n"
5343 "Connected\n"
5344 "Static routes\n"
5345 "Routing Information Protocol (RIP)\n"
5346 "Border Gateway Protocol (BGP)\n"
5347 "Metric for redistributed routes\n"
5348 "OSPF default metric\n")
5349
5350DEFUN (ospf_redistribute_source_type_metric,
5351 ospf_redistribute_source_type_metric_routemap_cmd,
5352 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5353 "Redistribute information from another routing protocol\n"
5354 "Kernel routes\n"
5355 "Connected\n"
5356 "Static routes\n"
5357 "Routing Information Protocol (RIP)\n"
5358 "Border Gateway Protocol (BGP)\n"
5359 "OSPF exterior metric type for redistributed routes\n"
5360 "Set OSPF External Type 1 metrics\n"
5361 "Set OSPF External Type 2 metrics\n"
5362 "Metric for redistributed routes\n"
5363 "OSPF default metric\n"
5364 "Route map reference\n"
5365 "Pointer to route-map entries\n")
5366{
paul020709f2003-04-04 02:44:16 +00005367 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005368 int source;
5369 int type = -1;
5370 int metric = -1;
5371
5372 /* Get distribute source. */
5373 if (!str2distribute_source (argv[0], &source))
5374 return CMD_WARNING;
5375
5376 /* Get metric value. */
5377 if (argc >= 2)
5378 if (!str2metric_type (argv[1], &type))
5379 return CMD_WARNING;
5380
5381 /* Get metric type. */
5382 if (argc >= 3)
5383 if (!str2metric (argv[2], &metric))
5384 return CMD_WARNING;
5385
5386 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005387 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005388 else
paul020709f2003-04-04 02:44:16 +00005389 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005390
paul020709f2003-04-04 02:44:16 +00005391 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005392}
5393
5394ALIAS (ospf_redistribute_source_type_metric,
5395 ospf_redistribute_source_type_metric_cmd,
5396 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5397 "Redistribute information from another routing protocol\n"
5398 "Kernel routes\n"
5399 "Connected\n"
5400 "Static routes\n"
5401 "Routing Information Protocol (RIP)\n"
5402 "Border Gateway Protocol (BGP)\n"
5403 "OSPF exterior metric type for redistributed routes\n"
5404 "Set OSPF External Type 1 metrics\n"
5405 "Set OSPF External Type 2 metrics\n"
5406 "Metric for redistributed routes\n"
5407 "OSPF default metric\n")
5408
5409ALIAS (ospf_redistribute_source_type_metric,
5410 ospf_redistribute_source_type_cmd,
5411 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5412 "Redistribute information from another routing protocol\n"
5413 "Kernel routes\n"
5414 "Connected\n"
5415 "Static routes\n"
5416 "Routing Information Protocol (RIP)\n"
5417 "Border Gateway Protocol (BGP)\n"
5418 "OSPF exterior metric type for redistributed routes\n"
5419 "Set OSPF External Type 1 metrics\n"
5420 "Set OSPF External Type 2 metrics\n")
5421
5422ALIAS (ospf_redistribute_source_type_metric,
5423 ospf_redistribute_source_cmd,
5424 "redistribute (kernel|connected|static|rip|bgp)",
5425 "Redistribute information from another routing protocol\n"
5426 "Kernel routes\n"
5427 "Connected\n"
5428 "Static routes\n"
5429 "Routing Information Protocol (RIP)\n"
5430 "Border Gateway Protocol (BGP)\n")
5431
5432DEFUN (ospf_redistribute_source_metric_routemap,
5433 ospf_redistribute_source_metric_routemap_cmd,
5434 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5435 "Redistribute information from another routing protocol\n"
5436 "Kernel routes\n"
5437 "Connected\n"
5438 "Static routes\n"
5439 "Routing Information Protocol (RIP)\n"
5440 "Border Gateway Protocol (BGP)\n"
5441 "Metric for redistributed routes\n"
5442 "OSPF default metric\n"
5443 "Route map reference\n"
5444 "Pointer to route-map entries\n")
5445{
paul020709f2003-04-04 02:44:16 +00005446 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005447 int source;
5448 int metric = -1;
5449
5450 /* Get distribute source. */
5451 if (!str2distribute_source (argv[0], &source))
5452 return CMD_WARNING;
5453
5454 /* Get metric value. */
5455 if (argc >= 2)
5456 if (!str2metric (argv[1], &metric))
5457 return CMD_WARNING;
5458
5459 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005460 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005461 else
paul020709f2003-04-04 02:44:16 +00005462 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005463
paul020709f2003-04-04 02:44:16 +00005464 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005465}
5466
5467DEFUN (ospf_redistribute_source_type_routemap,
5468 ospf_redistribute_source_type_routemap_cmd,
5469 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5470 "Redistribute information from another routing protocol\n"
5471 "Kernel routes\n"
5472 "Connected\n"
5473 "Static routes\n"
5474 "Routing Information Protocol (RIP)\n"
5475 "Border Gateway Protocol (BGP)\n"
5476 "OSPF exterior metric type for redistributed routes\n"
5477 "Set OSPF External Type 1 metrics\n"
5478 "Set OSPF External Type 2 metrics\n"
5479 "Route map reference\n"
5480 "Pointer to route-map entries\n")
5481{
paul020709f2003-04-04 02:44:16 +00005482 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005483 int source;
5484 int type = -1;
5485
5486 /* Get distribute source. */
5487 if (!str2distribute_source (argv[0], &source))
5488 return CMD_WARNING;
5489
5490 /* Get metric value. */
5491 if (argc >= 2)
5492 if (!str2metric_type (argv[1], &type))
5493 return CMD_WARNING;
5494
5495 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005496 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005497 else
paul020709f2003-04-04 02:44:16 +00005498 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005499
paul020709f2003-04-04 02:44:16 +00005500 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005501}
5502
5503DEFUN (ospf_redistribute_source_routemap,
5504 ospf_redistribute_source_routemap_cmd,
5505 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5506 "Redistribute information from another routing protocol\n"
5507 "Kernel routes\n"
5508 "Connected\n"
5509 "Static routes\n"
5510 "Routing Information Protocol (RIP)\n"
5511 "Border Gateway Protocol (BGP)\n"
5512 "Route map reference\n"
5513 "Pointer to route-map entries\n")
5514{
paul020709f2003-04-04 02:44:16 +00005515 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005516 int source;
5517
5518 /* Get distribute source. */
5519 if (!str2distribute_source (argv[0], &source))
5520 return CMD_WARNING;
5521
5522 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005523 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005524 else
paul020709f2003-04-04 02:44:16 +00005525 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005526
paul020709f2003-04-04 02:44:16 +00005527 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005528}
5529
5530DEFUN (no_ospf_redistribute_source,
5531 no_ospf_redistribute_source_cmd,
5532 "no redistribute (kernel|connected|static|rip|bgp)",
5533 NO_STR
5534 "Redistribute information from another routing protocol\n"
5535 "Kernel routes\n"
5536 "Connected\n"
5537 "Static routes\n"
5538 "Routing Information Protocol (RIP)\n"
5539 "Border Gateway Protocol (BGP)\n")
5540{
paul020709f2003-04-04 02:44:16 +00005541 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005542 int source;
5543
5544 if (!str2distribute_source (argv[0], &source))
5545 return CMD_WARNING;
5546
paul020709f2003-04-04 02:44:16 +00005547 ospf_routemap_unset (ospf, source);
5548 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005549}
5550
5551DEFUN (ospf_distribute_list_out,
5552 ospf_distribute_list_out_cmd,
5553 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5554 "Filter networks in routing updates\n"
5555 "Access-list name\n"
5556 OUT_STR
5557 "Kernel routes\n"
5558 "Connected\n"
5559 "Static routes\n"
5560 "Routing Information Protocol (RIP)\n"
5561 "Border Gateway Protocol (BGP)\n")
5562{
paul68980082003-03-25 05:07:42 +00005563 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005564 int source;
5565
5566 /* Get distribute source. */
5567 if (!str2distribute_source (argv[1], &source))
5568 return CMD_WARNING;
5569
paul68980082003-03-25 05:07:42 +00005570 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005571}
5572
5573DEFUN (no_ospf_distribute_list_out,
5574 no_ospf_distribute_list_out_cmd,
5575 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5576 NO_STR
5577 "Filter networks in routing updates\n"
5578 "Access-list name\n"
5579 OUT_STR
5580 "Kernel routes\n"
5581 "Connected\n"
5582 "Static routes\n"
5583 "Routing Information Protocol (RIP)\n"
5584 "Border Gateway Protocol (BGP)\n")
5585{
paul68980082003-03-25 05:07:42 +00005586 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005587 int source;
5588
5589 if (!str2distribute_source (argv[1], &source))
5590 return CMD_WARNING;
5591
paul68980082003-03-25 05:07:42 +00005592 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005593}
5594
5595/* Default information originate. */
5596DEFUN (ospf_default_information_originate_metric_type_routemap,
5597 ospf_default_information_originate_metric_type_routemap_cmd,
5598 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5599 "Control distribution of default information\n"
5600 "Distribute a default route\n"
5601 "OSPF default metric\n"
5602 "OSPF metric\n"
5603 "OSPF metric type for default routes\n"
5604 "Set OSPF External Type 1 metrics\n"
5605 "Set OSPF External Type 2 metrics\n"
5606 "Route map reference\n"
5607 "Pointer to route-map entries\n")
5608{
paul020709f2003-04-04 02:44:16 +00005609 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005610 int type = -1;
5611 int metric = -1;
5612
5613 /* Get metric value. */
5614 if (argc >= 1)
5615 if (!str2metric (argv[0], &metric))
5616 return CMD_WARNING;
5617
5618 /* Get metric type. */
5619 if (argc >= 2)
5620 if (!str2metric_type (argv[1], &type))
5621 return CMD_WARNING;
5622
5623 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005624 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005625 else
paul020709f2003-04-04 02:44:16 +00005626 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005627
paul020709f2003-04-04 02:44:16 +00005628 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5629 type, metric);
paul718e3742002-12-13 20:15:29 +00005630}
5631
5632ALIAS (ospf_default_information_originate_metric_type_routemap,
5633 ospf_default_information_originate_metric_type_cmd,
5634 "default-information originate metric <0-16777214> metric-type (1|2)",
5635 "Control distribution of default information\n"
5636 "Distribute a default route\n"
5637 "OSPF default metric\n"
5638 "OSPF metric\n"
5639 "OSPF metric type for default routes\n"
5640 "Set OSPF External Type 1 metrics\n"
5641 "Set OSPF External Type 2 metrics\n")
5642
5643ALIAS (ospf_default_information_originate_metric_type_routemap,
5644 ospf_default_information_originate_metric_cmd,
5645 "default-information originate metric <0-16777214>",
5646 "Control distribution of default information\n"
5647 "Distribute a default route\n"
5648 "OSPF default metric\n"
5649 "OSPF metric\n")
5650
5651ALIAS (ospf_default_information_originate_metric_type_routemap,
5652 ospf_default_information_originate_cmd,
5653 "default-information originate",
5654 "Control distribution of default information\n"
5655 "Distribute a default route\n")
5656
5657/* Default information originate. */
5658DEFUN (ospf_default_information_originate_metric_routemap,
5659 ospf_default_information_originate_metric_routemap_cmd,
5660 "default-information originate metric <0-16777214> route-map WORD",
5661 "Control distribution of default information\n"
5662 "Distribute a default route\n"
5663 "OSPF default metric\n"
5664 "OSPF metric\n"
5665 "Route map reference\n"
5666 "Pointer to route-map entries\n")
5667{
paul020709f2003-04-04 02:44:16 +00005668 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005669 int metric = -1;
5670
5671 /* Get metric value. */
5672 if (argc >= 1)
5673 if (!str2metric (argv[0], &metric))
5674 return CMD_WARNING;
5675
5676 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005677 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005678 else
paul020709f2003-04-04 02:44:16 +00005679 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005680
paul020709f2003-04-04 02:44:16 +00005681 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5682 -1, metric);
paul718e3742002-12-13 20:15:29 +00005683}
5684
5685/* Default information originate. */
5686DEFUN (ospf_default_information_originate_routemap,
5687 ospf_default_information_originate_routemap_cmd,
5688 "default-information originate route-map WORD",
5689 "Control distribution of default information\n"
5690 "Distribute a default route\n"
5691 "Route map reference\n"
5692 "Pointer to route-map entries\n")
5693{
paul020709f2003-04-04 02:44:16 +00005694 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005695
paul020709f2003-04-04 02:44:16 +00005696 if (argc == 1)
5697 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5698 else
5699 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5700
5701 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005702}
5703
5704DEFUN (ospf_default_information_originate_type_metric_routemap,
5705 ospf_default_information_originate_type_metric_routemap_cmd,
5706 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5707 "Control distribution of default information\n"
5708 "Distribute a default route\n"
5709 "OSPF metric type for default routes\n"
5710 "Set OSPF External Type 1 metrics\n"
5711 "Set OSPF External Type 2 metrics\n"
5712 "OSPF default metric\n"
5713 "OSPF metric\n"
5714 "Route map reference\n"
5715 "Pointer to route-map entries\n")
5716{
paul020709f2003-04-04 02:44:16 +00005717 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005718 int type = -1;
5719 int metric = -1;
5720
5721 /* Get metric type. */
5722 if (argc >= 1)
5723 if (!str2metric_type (argv[0], &type))
5724 return CMD_WARNING;
5725
5726 /* Get metric value. */
5727 if (argc >= 2)
5728 if (!str2metric (argv[1], &metric))
5729 return CMD_WARNING;
5730
5731 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005732 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005733 else
paul020709f2003-04-04 02:44:16 +00005734 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005735
paul020709f2003-04-04 02:44:16 +00005736 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5737 type, metric);
paul718e3742002-12-13 20:15:29 +00005738}
5739
5740ALIAS (ospf_default_information_originate_type_metric_routemap,
5741 ospf_default_information_originate_type_metric_cmd,
5742 "default-information originate metric-type (1|2) metric <0-16777214>",
5743 "Control distribution of default information\n"
5744 "Distribute a default route\n"
5745 "OSPF metric type for default routes\n"
5746 "Set OSPF External Type 1 metrics\n"
5747 "Set OSPF External Type 2 metrics\n"
5748 "OSPF default metric\n"
5749 "OSPF metric\n")
5750
5751ALIAS (ospf_default_information_originate_type_metric_routemap,
5752 ospf_default_information_originate_type_cmd,
5753 "default-information originate metric-type (1|2)",
5754 "Control distribution of default information\n"
5755 "Distribute a default route\n"
5756 "OSPF metric type for default routes\n"
5757 "Set OSPF External Type 1 metrics\n"
5758 "Set OSPF External Type 2 metrics\n")
5759
5760DEFUN (ospf_default_information_originate_type_routemap,
5761 ospf_default_information_originate_type_routemap_cmd,
5762 "default-information originate metric-type (1|2) route-map WORD",
5763 "Control distribution of default information\n"
5764 "Distribute a default route\n"
5765 "OSPF metric type for default routes\n"
5766 "Set OSPF External Type 1 metrics\n"
5767 "Set OSPF External Type 2 metrics\n"
5768 "Route map reference\n"
5769 "Pointer to route-map entries\n")
5770{
paul020709f2003-04-04 02:44:16 +00005771 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005772 int type = -1;
5773
5774 /* Get metric type. */
5775 if (argc >= 1)
5776 if (!str2metric_type (argv[0], &type))
5777 return CMD_WARNING;
5778
5779 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005780 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005781 else
paul020709f2003-04-04 02:44:16 +00005782 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005783
paul020709f2003-04-04 02:44:16 +00005784 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5785 type, -1);
paul718e3742002-12-13 20:15:29 +00005786}
5787
5788DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5789 ospf_default_information_originate_always_metric_type_routemap_cmd,
5790 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5791 "Control distribution of default information\n"
5792 "Distribute a default route\n"
5793 "Always advertise default route\n"
5794 "OSPF default metric\n"
5795 "OSPF metric\n"
5796 "OSPF metric type for default routes\n"
5797 "Set OSPF External Type 1 metrics\n"
5798 "Set OSPF External Type 2 metrics\n"
5799 "Route map reference\n"
5800 "Pointer to route-map entries\n")
5801{
paul020709f2003-04-04 02:44:16 +00005802 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005803 int type = -1;
5804 int metric = -1;
5805
5806 /* Get metric value. */
5807 if (argc >= 1)
5808 if (!str2metric (argv[0], &metric))
5809 return CMD_WARNING;
5810
5811 /* Get metric type. */
5812 if (argc >= 2)
5813 if (!str2metric_type (argv[1], &type))
5814 return CMD_WARNING;
5815
5816 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005817 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005818 else
paul020709f2003-04-04 02:44:16 +00005819 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005820
paul020709f2003-04-04 02:44:16 +00005821 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005822 type, metric);
5823}
5824
5825ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5826 ospf_default_information_originate_always_metric_type_cmd,
5827 "default-information originate always metric <0-16777214> metric-type (1|2)",
5828 "Control distribution of default information\n"
5829 "Distribute a default route\n"
5830 "Always advertise default route\n"
5831 "OSPF default metric\n"
5832 "OSPF metric\n"
5833 "OSPF metric type for default routes\n"
5834 "Set OSPF External Type 1 metrics\n"
5835 "Set OSPF External Type 2 metrics\n")
5836
5837ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5838 ospf_default_information_originate_always_metric_cmd,
5839 "default-information originate always metric <0-16777214>",
5840 "Control distribution of default information\n"
5841 "Distribute a default route\n"
5842 "Always advertise default route\n"
5843 "OSPF default metric\n"
5844 "OSPF metric\n"
5845 "OSPF metric type for default routes\n")
5846
5847ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5848 ospf_default_information_originate_always_cmd,
5849 "default-information originate always",
5850 "Control distribution of default information\n"
5851 "Distribute a default route\n"
5852 "Always advertise default route\n")
5853
5854DEFUN (ospf_default_information_originate_always_metric_routemap,
5855 ospf_default_information_originate_always_metric_routemap_cmd,
5856 "default-information originate always metric <0-16777214> route-map WORD",
5857 "Control distribution of default information\n"
5858 "Distribute a default route\n"
5859 "Always advertise default route\n"
5860 "OSPF default metric\n"
5861 "OSPF metric\n"
5862 "Route map reference\n"
5863 "Pointer to route-map entries\n")
5864{
paul020709f2003-04-04 02:44:16 +00005865 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005866 int metric = -1;
5867
5868 /* Get metric value. */
5869 if (argc >= 1)
5870 if (!str2metric (argv[0], &metric))
5871 return CMD_WARNING;
5872
5873 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005874 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005875 else
paul020709f2003-04-04 02:44:16 +00005876 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005877
paul020709f2003-04-04 02:44:16 +00005878 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5879 -1, metric);
paul718e3742002-12-13 20:15:29 +00005880}
5881
5882DEFUN (ospf_default_information_originate_always_routemap,
5883 ospf_default_information_originate_always_routemap_cmd,
5884 "default-information originate always route-map WORD",
5885 "Control distribution of default information\n"
5886 "Distribute a default route\n"
5887 "Always advertise default route\n"
5888 "Route map reference\n"
5889 "Pointer to route-map entries\n")
5890{
paul020709f2003-04-04 02:44:16 +00005891 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005892
paul020709f2003-04-04 02:44:16 +00005893 if (argc == 1)
5894 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5895 else
5896 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5897
5898 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005899}
5900
5901DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5902 ospf_default_information_originate_always_type_metric_routemap_cmd,
5903 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5904 "Control distribution of default information\n"
5905 "Distribute a default route\n"
5906 "Always advertise default route\n"
5907 "OSPF metric type for default routes\n"
5908 "Set OSPF External Type 1 metrics\n"
5909 "Set OSPF External Type 2 metrics\n"
5910 "OSPF default metric\n"
5911 "OSPF metric\n"
5912 "Route map reference\n"
5913 "Pointer to route-map entries\n")
5914{
paul020709f2003-04-04 02:44:16 +00005915 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005916 int type = -1;
5917 int metric = -1;
5918
5919 /* Get metric type. */
5920 if (argc >= 1)
5921 if (!str2metric_type (argv[0], &type))
5922 return CMD_WARNING;
5923
5924 /* Get metric value. */
5925 if (argc >= 2)
5926 if (!str2metric (argv[1], &metric))
5927 return CMD_WARNING;
5928
5929 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005930 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005931 else
paul020709f2003-04-04 02:44:16 +00005932 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005933
paul020709f2003-04-04 02:44:16 +00005934 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005935 type, metric);
5936}
5937
5938ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5939 ospf_default_information_originate_always_type_metric_cmd,
5940 "default-information originate always metric-type (1|2) metric <0-16777214>",
5941 "Control distribution of default information\n"
5942 "Distribute a default route\n"
5943 "Always advertise default route\n"
5944 "OSPF metric type for default routes\n"
5945 "Set OSPF External Type 1 metrics\n"
5946 "Set OSPF External Type 2 metrics\n"
5947 "OSPF default metric\n"
5948 "OSPF metric\n")
5949
5950ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5951 ospf_default_information_originate_always_type_cmd,
5952 "default-information originate always metric-type (1|2)",
5953 "Control distribution of default information\n"
5954 "Distribute a default route\n"
5955 "Always advertise default route\n"
5956 "OSPF metric type for default routes\n"
5957 "Set OSPF External Type 1 metrics\n"
5958 "Set OSPF External Type 2 metrics\n")
5959
5960DEFUN (ospf_default_information_originate_always_type_routemap,
5961 ospf_default_information_originate_always_type_routemap_cmd,
5962 "default-information originate always metric-type (1|2) route-map WORD",
5963 "Control distribution of default information\n"
5964 "Distribute a default route\n"
5965 "Always advertise default route\n"
5966 "OSPF metric type for default routes\n"
5967 "Set OSPF External Type 1 metrics\n"
5968 "Set OSPF External Type 2 metrics\n"
5969 "Route map reference\n"
5970 "Pointer to route-map entries\n")
5971{
paul020709f2003-04-04 02:44:16 +00005972 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005973 int type = -1;
5974
5975 /* Get metric type. */
5976 if (argc >= 1)
5977 if (!str2metric_type (argv[0], &type))
5978 return CMD_WARNING;
5979
5980 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005981 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005982 else
paul020709f2003-04-04 02:44:16 +00005983 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005984
paul020709f2003-04-04 02:44:16 +00005985 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005986 type, -1);
5987}
5988
5989DEFUN (no_ospf_default_information_originate,
5990 no_ospf_default_information_originate_cmd,
5991 "no default-information originate",
5992 NO_STR
5993 "Control distribution of default information\n"
5994 "Distribute a default route\n")
5995{
paul68980082003-03-25 05:07:42 +00005996 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005997 struct prefix_ipv4 p;
5998 struct in_addr nexthop;
5999
6000 p.family = AF_INET;
6001 p.prefix.s_addr = 0;
6002 p.prefixlen = 0;
6003
paul68980082003-03-25 05:07:42 +00006004 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
paul718e3742002-12-13 20:15:29 +00006005
6006 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6007 ospf_external_info_delete (DEFAULT_ROUTE, p);
6008 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6009 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6010 }
6011
paul020709f2003-04-04 02:44:16 +00006012 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6013 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006014}
6015
6016DEFUN (ospf_default_metric,
6017 ospf_default_metric_cmd,
6018 "default-metric <0-16777214>",
6019 "Set metric of redistributed routes\n"
6020 "Default metric\n")
6021{
paul68980082003-03-25 05:07:42 +00006022 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006023 int metric = -1;
6024
6025 if (!str2metric (argv[0], &metric))
6026 return CMD_WARNING;
6027
paul68980082003-03-25 05:07:42 +00006028 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006029
6030 return CMD_SUCCESS;
6031}
6032
6033DEFUN (no_ospf_default_metric,
6034 no_ospf_default_metric_cmd,
6035 "no default-metric",
6036 NO_STR
6037 "Set metric of redistributed routes\n")
6038{
paul68980082003-03-25 05:07:42 +00006039 struct ospf *ospf = vty->index;
6040
6041 ospf->default_metric = -1;
6042
paul718e3742002-12-13 20:15:29 +00006043 return CMD_SUCCESS;
6044}
6045
6046ALIAS (no_ospf_default_metric,
6047 no_ospf_default_metric_val_cmd,
6048 "no default-metric <0-16777214>",
6049 NO_STR
6050 "Set metric of redistributed routes\n"
6051 "Default metric\n")
6052
6053DEFUN (ospf_distance,
6054 ospf_distance_cmd,
6055 "distance <1-255>",
6056 "Define an administrative distance\n"
6057 "OSPF Administrative distance\n")
6058{
paul68980082003-03-25 05:07:42 +00006059 struct ospf *ospf = vty->index;
6060
6061 ospf->distance_all = atoi (argv[0]);
6062
paul718e3742002-12-13 20:15:29 +00006063 return CMD_SUCCESS;
6064}
6065
6066DEFUN (no_ospf_distance,
6067 no_ospf_distance_cmd,
6068 "no distance <1-255>",
6069 NO_STR
6070 "Define an administrative distance\n"
6071 "OSPF Administrative distance\n")
6072{
paul68980082003-03-25 05:07:42 +00006073 struct ospf *ospf = vty->index;
6074
6075 ospf->distance_all = 0;
6076
paul718e3742002-12-13 20:15:29 +00006077 return CMD_SUCCESS;
6078}
6079
6080DEFUN (no_ospf_distance_ospf,
6081 no_ospf_distance_ospf_cmd,
6082 "no distance ospf",
6083 NO_STR
6084 "Define an administrative distance\n"
6085 "OSPF Administrative distance\n"
6086 "OSPF Distance\n")
6087{
paul68980082003-03-25 05:07:42 +00006088 struct ospf *ospf = vty->index;
6089
6090 ospf->distance_intra = 0;
6091 ospf->distance_inter = 0;
6092 ospf->distance_external = 0;
6093
paul718e3742002-12-13 20:15:29 +00006094 return CMD_SUCCESS;
6095}
6096
6097DEFUN (ospf_distance_ospf_intra,
6098 ospf_distance_ospf_intra_cmd,
6099 "distance ospf intra-area <1-255>",
6100 "Define an administrative distance\n"
6101 "OSPF Administrative distance\n"
6102 "Intra-area routes\n"
6103 "Distance for intra-area routes\n")
6104{
paul68980082003-03-25 05:07:42 +00006105 struct ospf *ospf = vty->index;
6106
6107 ospf->distance_intra = atoi (argv[0]);
6108
paul718e3742002-12-13 20:15:29 +00006109 return CMD_SUCCESS;
6110}
6111
6112DEFUN (ospf_distance_ospf_intra_inter,
6113 ospf_distance_ospf_intra_inter_cmd,
6114 "distance ospf intra-area <1-255> inter-area <1-255>",
6115 "Define an administrative distance\n"
6116 "OSPF Administrative distance\n"
6117 "Intra-area routes\n"
6118 "Distance for intra-area routes\n"
6119 "Inter-area routes\n"
6120 "Distance for inter-area routes\n")
6121{
paul68980082003-03-25 05:07:42 +00006122 struct ospf *ospf = vty->index;
6123
6124 ospf->distance_intra = atoi (argv[0]);
6125 ospf->distance_inter = atoi (argv[1]);
6126
paul718e3742002-12-13 20:15:29 +00006127 return CMD_SUCCESS;
6128}
6129
6130DEFUN (ospf_distance_ospf_intra_external,
6131 ospf_distance_ospf_intra_external_cmd,
6132 "distance ospf intra-area <1-255> external <1-255>",
6133 "Define an administrative distance\n"
6134 "OSPF Administrative distance\n"
6135 "Intra-area routes\n"
6136 "Distance for intra-area routes\n"
6137 "External routes\n"
6138 "Distance for external routes\n")
6139{
paul68980082003-03-25 05:07:42 +00006140 struct ospf *ospf = vty->index;
6141
6142 ospf->distance_intra = atoi (argv[0]);
6143 ospf->distance_external = atoi (argv[1]);
6144
paul718e3742002-12-13 20:15:29 +00006145 return CMD_SUCCESS;
6146}
6147
6148DEFUN (ospf_distance_ospf_intra_inter_external,
6149 ospf_distance_ospf_intra_inter_external_cmd,
6150 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6151 "Define an administrative distance\n"
6152 "OSPF Administrative distance\n"
6153 "Intra-area routes\n"
6154 "Distance for intra-area routes\n"
6155 "Inter-area routes\n"
6156 "Distance for inter-area routes\n"
6157 "External routes\n"
6158 "Distance for external routes\n")
6159{
paul68980082003-03-25 05:07:42 +00006160 struct ospf *ospf = vty->index;
6161
6162 ospf->distance_intra = atoi (argv[0]);
6163 ospf->distance_inter = atoi (argv[1]);
6164 ospf->distance_external = atoi (argv[2]);
6165
paul718e3742002-12-13 20:15:29 +00006166 return CMD_SUCCESS;
6167}
6168
6169DEFUN (ospf_distance_ospf_intra_external_inter,
6170 ospf_distance_ospf_intra_external_inter_cmd,
6171 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6172 "Define an administrative distance\n"
6173 "OSPF Administrative distance\n"
6174 "Intra-area routes\n"
6175 "Distance for intra-area routes\n"
6176 "External routes\n"
6177 "Distance for external routes\n"
6178 "Inter-area routes\n"
6179 "Distance for inter-area routes\n")
6180{
paul68980082003-03-25 05:07:42 +00006181 struct ospf *ospf = vty->index;
6182
6183 ospf->distance_intra = atoi (argv[0]);
6184 ospf->distance_external = atoi (argv[1]);
6185 ospf->distance_inter = atoi (argv[2]);
6186
paul718e3742002-12-13 20:15:29 +00006187 return CMD_SUCCESS;
6188}
6189
6190DEFUN (ospf_distance_ospf_inter,
6191 ospf_distance_ospf_inter_cmd,
6192 "distance ospf inter-area <1-255>",
6193 "Define an administrative distance\n"
6194 "OSPF Administrative distance\n"
6195 "Inter-area routes\n"
6196 "Distance for inter-area routes\n")
6197{
paul68980082003-03-25 05:07:42 +00006198 struct ospf *ospf = vty->index;
6199
6200 ospf->distance_inter = atoi (argv[0]);
6201
paul718e3742002-12-13 20:15:29 +00006202 return CMD_SUCCESS;
6203}
6204
6205DEFUN (ospf_distance_ospf_inter_intra,
6206 ospf_distance_ospf_inter_intra_cmd,
6207 "distance ospf inter-area <1-255> intra-area <1-255>",
6208 "Define an administrative distance\n"
6209 "OSPF Administrative distance\n"
6210 "Inter-area routes\n"
6211 "Distance for inter-area routes\n"
6212 "Intra-area routes\n"
6213 "Distance for intra-area routes\n")
6214{
paul68980082003-03-25 05:07:42 +00006215 struct ospf *ospf = vty->index;
6216
6217 ospf->distance_inter = atoi (argv[0]);
6218 ospf->distance_intra = atoi (argv[1]);
6219
paul718e3742002-12-13 20:15:29 +00006220 return CMD_SUCCESS;
6221}
6222
6223DEFUN (ospf_distance_ospf_inter_external,
6224 ospf_distance_ospf_inter_external_cmd,
6225 "distance ospf inter-area <1-255> external <1-255>",
6226 "Define an administrative distance\n"
6227 "OSPF Administrative distance\n"
6228 "Inter-area routes\n"
6229 "Distance for inter-area routes\n"
6230 "External routes\n"
6231 "Distance for external routes\n")
6232{
paul68980082003-03-25 05:07:42 +00006233 struct ospf *ospf = vty->index;
6234
6235 ospf->distance_inter = atoi (argv[0]);
6236 ospf->distance_external = atoi (argv[1]);
6237
paul718e3742002-12-13 20:15:29 +00006238 return CMD_SUCCESS;
6239}
6240
6241DEFUN (ospf_distance_ospf_inter_intra_external,
6242 ospf_distance_ospf_inter_intra_external_cmd,
6243 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6244 "Define an administrative distance\n"
6245 "OSPF Administrative distance\n"
6246 "Inter-area routes\n"
6247 "Distance for inter-area routes\n"
6248 "Intra-area routes\n"
6249 "Distance for intra-area routes\n"
6250 "External routes\n"
6251 "Distance for external routes\n")
6252{
paul68980082003-03-25 05:07:42 +00006253 struct ospf *ospf = vty->index;
6254
6255 ospf->distance_inter = atoi (argv[0]);
6256 ospf->distance_intra = atoi (argv[1]);
6257 ospf->distance_external = atoi (argv[2]);
6258
paul718e3742002-12-13 20:15:29 +00006259 return CMD_SUCCESS;
6260}
6261
6262DEFUN (ospf_distance_ospf_inter_external_intra,
6263 ospf_distance_ospf_inter_external_intra_cmd,
6264 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6265 "Define an administrative distance\n"
6266 "OSPF Administrative distance\n"
6267 "Inter-area routes\n"
6268 "Distance for inter-area routes\n"
6269 "External routes\n"
6270 "Distance for external routes\n"
6271 "Intra-area routes\n"
6272 "Distance for intra-area routes\n")
6273{
paul68980082003-03-25 05:07:42 +00006274 struct ospf *ospf = vty->index;
6275
6276 ospf->distance_inter = atoi (argv[0]);
6277 ospf->distance_external = atoi (argv[1]);
6278 ospf->distance_intra = atoi (argv[2]);
6279
paul718e3742002-12-13 20:15:29 +00006280 return CMD_SUCCESS;
6281}
6282
6283DEFUN (ospf_distance_ospf_external,
6284 ospf_distance_ospf_external_cmd,
6285 "distance ospf external <1-255>",
6286 "Define an administrative distance\n"
6287 "OSPF Administrative distance\n"
6288 "External routes\n"
6289 "Distance for external routes\n")
6290{
paul68980082003-03-25 05:07:42 +00006291 struct ospf *ospf = vty->index;
6292
6293 ospf->distance_external = atoi (argv[0]);
6294
paul718e3742002-12-13 20:15:29 +00006295 return CMD_SUCCESS;
6296}
6297
6298DEFUN (ospf_distance_ospf_external_intra,
6299 ospf_distance_ospf_external_intra_cmd,
6300 "distance ospf external <1-255> intra-area <1-255>",
6301 "Define an administrative distance\n"
6302 "OSPF Administrative distance\n"
6303 "External routes\n"
6304 "Distance for external routes\n"
6305 "Intra-area routes\n"
6306 "Distance for intra-area routes\n")
6307{
paul68980082003-03-25 05:07:42 +00006308 struct ospf *ospf = vty->index;
6309
6310 ospf->distance_external = atoi (argv[0]);
6311 ospf->distance_intra = atoi (argv[1]);
6312
paul718e3742002-12-13 20:15:29 +00006313 return CMD_SUCCESS;
6314}
6315
6316DEFUN (ospf_distance_ospf_external_inter,
6317 ospf_distance_ospf_external_inter_cmd,
6318 "distance ospf external <1-255> inter-area <1-255>",
6319 "Define an administrative distance\n"
6320 "OSPF Administrative distance\n"
6321 "External routes\n"
6322 "Distance for external routes\n"
6323 "Inter-area routes\n"
6324 "Distance for inter-area routes\n")
6325{
paul68980082003-03-25 05:07:42 +00006326 struct ospf *ospf = vty->index;
6327
6328 ospf->distance_external = atoi (argv[0]);
6329 ospf->distance_inter = atoi (argv[1]);
6330
paul718e3742002-12-13 20:15:29 +00006331 return CMD_SUCCESS;
6332}
6333
6334DEFUN (ospf_distance_ospf_external_intra_inter,
6335 ospf_distance_ospf_external_intra_inter_cmd,
6336 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6337 "Define an administrative distance\n"
6338 "OSPF Administrative distance\n"
6339 "External routes\n"
6340 "Distance for external routes\n"
6341 "Intra-area routes\n"
6342 "Distance for intra-area routes\n"
6343 "Inter-area routes\n"
6344 "Distance for inter-area routes\n")
6345{
paul68980082003-03-25 05:07:42 +00006346 struct ospf *ospf = vty->index;
6347
6348 ospf->distance_external = atoi (argv[0]);
6349 ospf->distance_intra = atoi (argv[1]);
6350 ospf->distance_inter = atoi (argv[2]);
6351
paul718e3742002-12-13 20:15:29 +00006352 return CMD_SUCCESS;
6353}
6354
6355DEFUN (ospf_distance_ospf_external_inter_intra,
6356 ospf_distance_ospf_external_inter_intra_cmd,
6357 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6358 "Define an administrative distance\n"
6359 "OSPF Administrative distance\n"
6360 "External routes\n"
6361 "Distance for external routes\n"
6362 "Inter-area routes\n"
6363 "Distance for inter-area routes\n"
6364 "Intra-area routes\n"
6365 "Distance for intra-area routes\n")
6366{
paul68980082003-03-25 05:07:42 +00006367 struct ospf *ospf = vty->index;
6368
6369 ospf->distance_external = atoi (argv[0]);
6370 ospf->distance_inter = atoi (argv[1]);
6371 ospf->distance_intra = atoi (argv[2]);
6372
paul718e3742002-12-13 20:15:29 +00006373 return CMD_SUCCESS;
6374}
6375
6376DEFUN (ospf_distance_source,
6377 ospf_distance_source_cmd,
6378 "distance <1-255> A.B.C.D/M",
6379 "Administrative distance\n"
6380 "Distance value\n"
6381 "IP source prefix\n")
6382{
paul020709f2003-04-04 02:44:16 +00006383 struct ospf *ospf = vty->index;
6384
6385 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006386
paul718e3742002-12-13 20:15:29 +00006387 return CMD_SUCCESS;
6388}
6389
6390DEFUN (no_ospf_distance_source,
6391 no_ospf_distance_source_cmd,
6392 "no distance <1-255> A.B.C.D/M",
6393 NO_STR
6394 "Administrative distance\n"
6395 "Distance value\n"
6396 "IP source prefix\n")
6397{
paul020709f2003-04-04 02:44:16 +00006398 struct ospf *ospf = vty->index;
6399
6400 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6401
paul718e3742002-12-13 20:15:29 +00006402 return CMD_SUCCESS;
6403}
6404
6405DEFUN (ospf_distance_source_access_list,
6406 ospf_distance_source_access_list_cmd,
6407 "distance <1-255> A.B.C.D/M WORD",
6408 "Administrative distance\n"
6409 "Distance value\n"
6410 "IP source prefix\n"
6411 "Access list name\n")
6412{
paul020709f2003-04-04 02:44:16 +00006413 struct ospf *ospf = vty->index;
6414
6415 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6416
paul718e3742002-12-13 20:15:29 +00006417 return CMD_SUCCESS;
6418}
6419
6420DEFUN (no_ospf_distance_source_access_list,
6421 no_ospf_distance_source_access_list_cmd,
6422 "no distance <1-255> A.B.C.D/M WORD",
6423 NO_STR
6424 "Administrative distance\n"
6425 "Distance value\n"
6426 "IP source prefix\n"
6427 "Access list name\n")
6428{
paul020709f2003-04-04 02:44:16 +00006429 struct ospf *ospf = vty->index;
6430
6431 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6432
paul718e3742002-12-13 20:15:29 +00006433 return CMD_SUCCESS;
6434}
6435
6436void
6437show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6438{
6439 struct route_node *rn;
6440 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006441 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006442 struct ospf_path *path;
6443
6444 vty_out (vty, "============ OSPF network routing table ============%s",
6445 VTY_NEWLINE);
6446
6447 for (rn = route_top (rt); rn; rn = route_next (rn))
6448 if ((or = rn->info) != NULL)
6449 {
6450 char buf1[19];
6451 snprintf (buf1, 19, "%s/%d",
6452 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6453
6454 switch (or->path_type)
6455 {
6456 case OSPF_PATH_INTER_AREA:
6457 if (or->type == OSPF_DESTINATION_NETWORK)
6458 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6459 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6460 else if (or->type == OSPF_DESTINATION_DISCARD)
6461 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6462 break;
6463 case OSPF_PATH_INTRA_AREA:
6464 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6465 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6466 break;
6467 default:
6468 break;
6469 }
6470
6471 if (or->type == OSPF_DESTINATION_NETWORK)
paul96735ee2003-08-10 02:51:22 +00006472 LIST_LOOP (or->paths, path, pnode)
6473 {
6474 if (path->oi != NULL)
6475 {
6476 if (path->nexthop.s_addr == 0)
6477 vty_out (vty, "%24s directly attached to %s%s",
6478 "", path->oi->ifp->name, VTY_NEWLINE);
6479 else
6480 vty_out (vty, "%24s via %s, %s%s", "",
6481 inet_ntoa (path->nexthop), path->oi->ifp->name,
6482 VTY_NEWLINE);
6483 }
6484 }
paul718e3742002-12-13 20:15:29 +00006485 }
6486 vty_out (vty, "%s", VTY_NEWLINE);
6487}
6488
6489void
6490show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6491{
6492 struct route_node *rn;
6493 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006494 struct listnode *pn, *nn;
paul718e3742002-12-13 20:15:29 +00006495 struct ospf_path *path;
6496
6497 vty_out (vty, "============ OSPF router routing table =============%s",
6498 VTY_NEWLINE);
6499 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6500 if (rn->info)
6501 {
6502 int flag = 0;
6503
6504 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6505
hasso52dc7ee2004-09-23 19:18:23 +00006506 for (nn = listhead ((struct list *) rn->info); nn; nextnode (nn))
paul718e3742002-12-13 20:15:29 +00006507 if ((or = getdata (nn)) != NULL)
6508 {
6509 if (flag++)
paulb0a053b2003-06-22 09:04:47 +00006510 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006511
6512 /* Show path. */
6513 vty_out (vty, "%s [%d] area: %s",
6514 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6515 or->cost, inet_ntoa (or->u.std.area_id));
6516 /* Show flags. */
6517 vty_out (vty, "%s%s%s",
6518 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6519 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6520 VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006521
6522 LIST_LOOP (or->paths, path, pn)
6523 {
6524 if (path->nexthop.s_addr == 0)
6525 vty_out (vty, "%24s directly attached to %s%s",
6526 "", path->oi->ifp->name, VTY_NEWLINE);
6527 else
6528 vty_out (vty, "%24s via %s, %s%s", "",
6529 inet_ntoa (path->nexthop), path->oi->ifp->name,
6530 VTY_NEWLINE);
6531 }
paul718e3742002-12-13 20:15:29 +00006532 }
6533 }
6534 vty_out (vty, "%s", VTY_NEWLINE);
6535}
6536
6537void
6538show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6539{
6540 struct route_node *rn;
6541 struct ospf_route *er;
hasso52dc7ee2004-09-23 19:18:23 +00006542 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006543 struct ospf_path *path;
6544
6545 vty_out (vty, "============ OSPF external routing table ===========%s",
6546 VTY_NEWLINE);
6547 for (rn = route_top (rt); rn; rn = route_next (rn))
6548 if ((er = rn->info) != NULL)
6549 {
6550 char buf1[19];
6551 snprintf (buf1, 19, "%s/%d",
6552 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6553
6554 switch (er->path_type)
6555 {
6556 case OSPF_PATH_TYPE1_EXTERNAL:
6557 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6558 er->cost, er->u.ext.tag, VTY_NEWLINE);
6559 break;
6560 case OSPF_PATH_TYPE2_EXTERNAL:
6561 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6562 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6563 break;
6564 }
6565
paul96735ee2003-08-10 02:51:22 +00006566 LIST_LOOP (er->paths, path, pnode)
paul718e3742002-12-13 20:15:29 +00006567 {
paul718e3742002-12-13 20:15:29 +00006568 if (path->oi != NULL)
6569 {
6570 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006571 vty_out (vty, "%24s directly attached to %s%s",
6572 "", path->oi->ifp->name, VTY_NEWLINE);
6573 else
6574 vty_out (vty, "%24s via %s, %s%s", "",
6575 inet_ntoa (path->nexthop), path->oi->ifp->name,
6576 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006577 }
6578 }
6579 }
6580 vty_out (vty, "%s", VTY_NEWLINE);
6581}
6582
paul718e3742002-12-13 20:15:29 +00006583DEFUN (show_ip_ospf_border_routers,
6584 show_ip_ospf_border_routers_cmd,
6585 "show ip ospf border-routers",
6586 SHOW_STR
6587 IP_STR
6588 "show all the ABR's and ASBR's\n"
6589 "for this area\n")
6590{
paul020709f2003-04-04 02:44:16 +00006591 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006592
paul020709f2003-04-04 02:44:16 +00006593 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006594 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006595 {
6596 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6597 return CMD_SUCCESS;
6598 }
6599
paul68980082003-03-25 05:07:42 +00006600 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006601 {
6602 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6603 return CMD_SUCCESS;
6604 }
6605
6606 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006607 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006608
6609 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006610 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006611
6612 return CMD_SUCCESS;
6613}
paul718e3742002-12-13 20:15:29 +00006614
6615DEFUN (show_ip_ospf_route,
6616 show_ip_ospf_route_cmd,
6617 "show ip ospf route",
6618 SHOW_STR
6619 IP_STR
6620 "OSPF information\n"
6621 "OSPF routing table\n")
6622{
paul020709f2003-04-04 02:44:16 +00006623 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006624
paul020709f2003-04-04 02:44:16 +00006625 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006626 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006627 {
6628 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6629 return CMD_SUCCESS;
6630 }
6631
paul68980082003-03-25 05:07:42 +00006632 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006633 {
6634 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6635 return CMD_SUCCESS;
6636 }
6637
6638 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006639 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006640
6641 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006642 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006643
6644 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006645 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006646
6647 return CMD_SUCCESS;
6648}
6649
6650
hassoeb1ce602004-10-08 08:17:22 +00006651const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006652{
6653 "unknown",
6654 "standard",
6655 "ibm",
6656 "cisco",
6657 "shortcut"
6658};
6659
hassoeb1ce602004-10-08 08:17:22 +00006660const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006661{
6662 "default",
6663 "enable",
6664 "disable"
6665};
6666
6667
6668void
6669area_id2str (char *buf, int length, struct ospf_area *area)
6670{
6671 memset (buf, 0, length);
6672
6673 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6674 strncpy (buf, inet_ntoa (area->area_id), length);
6675 else
6676 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6677}
6678
6679
hassoeb1ce602004-10-08 08:17:22 +00006680const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006681{
6682 "unknown", /* should never be used. */
6683 "point-to-point",
6684 "broadcast",
6685 "non-broadcast",
6686 "point-to-multipoint",
6687 "virtual-link", /* should never be used. */
6688 "loopback"
6689};
6690
6691/* Configuration write function for ospfd. */
6692int
6693config_write_interface (struct vty *vty)
6694{
hasso52dc7ee2004-09-23 19:18:23 +00006695 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006696 struct interface *ifp;
6697 struct crypt_key *ck;
6698 int write = 0;
6699 struct route_node *rn = NULL;
6700 struct ospf_if_params *params;
6701
6702 for (n1 = listhead (iflist); n1; nextnode (n1))
6703 {
6704 ifp = getdata (n1);
6705
6706 if (memcmp (ifp->name, "VLINK", 5) == 0)
6707 continue;
6708
6709 vty_out (vty, "!%s", VTY_NEWLINE);
6710 vty_out (vty, "interface %s%s", ifp->name,
6711 VTY_NEWLINE);
6712 if (ifp->desc)
6713 vty_out (vty, " description %s%s", ifp->desc,
6714 VTY_NEWLINE);
6715
6716 write++;
6717
6718 params = IF_DEF_PARAMS (ifp);
6719
6720 do {
6721 /* Interface Network print. */
6722 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006723 params->type != OSPF_IFTYPE_LOOPBACK)
6724 {
ajsbc18d612004-12-15 15:07:19 +00006725 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006726 {
6727 vty_out (vty, " ip ospf network %s",
6728 ospf_int_type_str[params->type]);
6729 if (params != IF_DEF_PARAMS (ifp))
6730 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6731 vty_out (vty, "%s", VTY_NEWLINE);
6732 }
paul718e3742002-12-13 20:15:29 +00006733 }
6734
6735 /* OSPF interface authentication print */
6736 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6737 params->auth_type != OSPF_AUTH_NOTSET)
6738 {
hassoeb1ce602004-10-08 08:17:22 +00006739 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006740
6741 /* Translation tables are not that much help here due to syntax
6742 of the simple option */
6743 switch (params->auth_type)
6744 {
6745
6746 case OSPF_AUTH_NULL:
6747 auth_str = " null";
6748 break;
6749
6750 case OSPF_AUTH_SIMPLE:
6751 auth_str = "";
6752 break;
6753
6754 case OSPF_AUTH_CRYPTOGRAPHIC:
6755 auth_str = " message-digest";
6756 break;
6757
6758 default:
6759 auth_str = "";
6760 break;
6761 }
6762
6763 vty_out (vty, " ip ospf authentication%s", auth_str);
6764 if (params != IF_DEF_PARAMS (ifp))
6765 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6766 vty_out (vty, "%s", VTY_NEWLINE);
6767 }
6768
6769 /* Simple Authentication Password print. */
6770 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6771 params->auth_simple[0] != '\0')
6772 {
6773 vty_out (vty, " ip ospf authentication-key %s",
6774 params->auth_simple);
6775 if (params != IF_DEF_PARAMS (ifp))
6776 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6777 vty_out (vty, "%s", VTY_NEWLINE);
6778 }
6779
6780 /* Cryptographic Authentication Key print. */
6781 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
6782 {
6783 ck = getdata (n2);
6784 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6785 ck->key_id, ck->auth_key);
6786 if (params != IF_DEF_PARAMS (ifp))
6787 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6788 vty_out (vty, "%s", VTY_NEWLINE);
6789 }
6790
6791 /* Interface Output Cost print. */
6792 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6793 {
6794 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6795 if (params != IF_DEF_PARAMS (ifp))
6796 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6797 vty_out (vty, "%s", VTY_NEWLINE);
6798 }
6799
6800 /* Hello Interval print. */
6801 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6802 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6803 {
6804 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6805 if (params != IF_DEF_PARAMS (ifp))
6806 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6807 vty_out (vty, "%s", VTY_NEWLINE);
6808 }
6809
6810
6811 /* Router Dead Interval print. */
6812 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6813 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6814 {
6815 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6816 if (params != IF_DEF_PARAMS (ifp))
6817 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6818 vty_out (vty, "%s", VTY_NEWLINE);
6819 }
6820
6821 /* Router Priority print. */
6822 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6823 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6824 {
6825 vty_out (vty, " ip ospf priority %u", params->priority);
6826 if (params != IF_DEF_PARAMS (ifp))
6827 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6828 vty_out (vty, "%s", VTY_NEWLINE);
6829 }
6830
6831 /* Retransmit Interval print. */
6832 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6833 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6834 {
6835 vty_out (vty, " ip ospf retransmit-interval %u",
6836 params->retransmit_interval);
6837 if (params != IF_DEF_PARAMS (ifp))
6838 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6839 vty_out (vty, "%s", VTY_NEWLINE);
6840 }
6841
6842 /* Transmit Delay print. */
6843 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6844 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6845 {
6846 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6847 if (params != IF_DEF_PARAMS (ifp))
6848 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6849 vty_out (vty, "%s", VTY_NEWLINE);
6850 }
6851
6852 while (1)
6853 {
6854 if (rn == NULL)
6855 rn = route_top (IF_OIFS_PARAMS (ifp));
6856 else
6857 rn = route_next (rn);
6858
6859 if (rn == NULL)
6860 break;
6861 params = rn->info;
6862 if (params != NULL)
6863 break;
6864 }
6865 } while (rn);
6866
6867#ifdef HAVE_OPAQUE_LSA
6868 ospf_opaque_config_write_if (vty, ifp);
6869#endif /* HAVE_OPAQUE_LSA */
6870 }
6871
6872 return write;
6873}
6874
6875int
paul68980082003-03-25 05:07:42 +00006876config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006877{
6878 struct route_node *rn;
6879 u_char buf[INET_ADDRSTRLEN];
6880
6881 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006882 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006883 if (rn->info)
6884 {
6885 struct ospf_network *n = rn->info;
6886
6887 memset (buf, 0, INET_ADDRSTRLEN);
6888
6889 /* Create Area ID string by specified Area ID format. */
6890 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00006891 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00006892 else
hassoc9e52be2004-09-26 16:09:34 +00006893 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00006894 (unsigned long int) ntohl (n->area_id.s_addr));
6895
6896 /* Network print. */
6897 vty_out (vty, " network %s/%d area %s%s",
6898 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6899 buf, VTY_NEWLINE);
6900 }
6901
6902 return 0;
6903}
6904
6905int
paul68980082003-03-25 05:07:42 +00006906config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006907{
hasso52dc7ee2004-09-23 19:18:23 +00006908 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006909 u_char buf[INET_ADDRSTRLEN];
6910
6911 /* Area configuration print. */
paul68980082003-03-25 05:07:42 +00006912 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00006913 {
6914 struct ospf_area *area = getdata (node);
6915 struct route_node *rn1;
6916
hassoc9e52be2004-09-26 16:09:34 +00006917 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00006918
6919 if (area->auth_type != OSPF_AUTH_NULL)
6920 {
6921 if (area->auth_type == OSPF_AUTH_SIMPLE)
6922 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6923 else
6924 vty_out (vty, " area %s authentication message-digest%s",
6925 buf, VTY_NEWLINE);
6926 }
6927
6928 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6929 vty_out (vty, " area %s shortcut %s%s", buf,
6930 ospf_shortcut_mode_str[area->shortcut_configured],
6931 VTY_NEWLINE);
6932
6933 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006934 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00006935 )
6936 {
paulb0a053b2003-06-22 09:04:47 +00006937 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006938 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00006939 else if (area->external_routing == OSPF_AREA_NSSA)
6940 {
6941 vty_out (vty, " area %s nssa", buf);
6942 switch (area->NSSATranslatorRole)
6943 {
6944 case OSPF_NSSA_ROLE_NEVER:
6945 vty_out (vty, " translate-never");
6946 break;
6947 case OSPF_NSSA_ROLE_ALWAYS:
6948 vty_out (vty, " translate-always");
6949 break;
6950 case OSPF_NSSA_ROLE_CANDIDATE:
6951 default:
6952 vty_out (vty, " translate-candidate");
6953 }
6954 }
paul718e3742002-12-13 20:15:29 +00006955
6956 if (area->no_summary)
6957 vty_out (vty, " no-summary");
6958
6959 vty_out (vty, "%s", VTY_NEWLINE);
6960
6961 if (area->default_cost != 1)
6962 vty_out (vty, " area %s default-cost %d%s", buf,
6963 area->default_cost, VTY_NEWLINE);
6964 }
6965
6966 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
6967 if (rn1->info)
6968 {
6969 struct ospf_area_range *range = rn1->info;
6970
6971 vty_out (vty, " area %s range %s/%d", buf,
6972 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
6973
paul6c835672004-10-11 11:00:30 +00006974 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00006975 vty_out (vty, " cost %d", range->cost_config);
6976
6977 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
6978 vty_out (vty, " not-advertise");
6979
6980 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
6981 vty_out (vty, " substitute %s/%d",
6982 inet_ntoa (range->subst_addr), range->subst_masklen);
6983
6984 vty_out (vty, "%s", VTY_NEWLINE);
6985 }
6986
6987 if (EXPORT_NAME (area))
6988 vty_out (vty, " area %s export-list %s%s", buf,
6989 EXPORT_NAME (area), VTY_NEWLINE);
6990
6991 if (IMPORT_NAME (area))
6992 vty_out (vty, " area %s import-list %s%s", buf,
6993 IMPORT_NAME (area), VTY_NEWLINE);
6994
6995 if (PREFIX_NAME_IN (area))
6996 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
6997 PREFIX_NAME_IN (area), VTY_NEWLINE);
6998
6999 if (PREFIX_NAME_OUT (area))
7000 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7001 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7002 }
7003
7004 return 0;
7005}
7006
7007int
paul68980082003-03-25 05:07:42 +00007008config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007009{
7010 struct ospf_nbr_nbma *nbr_nbma;
7011 struct route_node *rn;
7012
7013 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007014 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007015 if ((nbr_nbma = rn->info))
7016 {
7017 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7018
7019 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7020 vty_out (vty, " priority %d", nbr_nbma->priority);
7021
7022 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7023 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7024
7025 vty_out (vty, "%s", VTY_NEWLINE);
7026 }
7027
7028 return 0;
7029}
7030
7031int
paul68980082003-03-25 05:07:42 +00007032config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007033{
hasso52dc7ee2004-09-23 19:18:23 +00007034 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007035 u_char buf[INET_ADDRSTRLEN];
7036
7037 /* Virtual-Link print */
paul68980082003-03-25 05:07:42 +00007038 for (node = listhead (ospf->vlinks); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007039 {
hasso52dc7ee2004-09-23 19:18:23 +00007040 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007041 struct crypt_key *ck;
7042 struct ospf_vl_data *vl_data = getdata (node);
7043 struct ospf_interface *oi;
7044
7045 if (vl_data != NULL)
7046 {
7047 memset (buf, 0, INET_ADDRSTRLEN);
7048
7049 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007050 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007051 else
hassoc9e52be2004-09-26 16:09:34 +00007052 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007053 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7054 oi = vl_data->vl_oi;
7055
7056 /* timers */
7057 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7058 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7059 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7060 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7061 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7062 buf,
7063 inet_ntoa (vl_data->vl_peer),
7064 OSPF_IF_PARAM (oi, v_hello),
7065 OSPF_IF_PARAM (oi, retransmit_interval),
7066 OSPF_IF_PARAM (oi, transmit_delay),
7067 OSPF_IF_PARAM (oi, v_wait),
7068 VTY_NEWLINE);
7069 else
7070 vty_out (vty, " area %s virtual-link %s%s", buf,
7071 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7072 /* Auth key */
7073 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7074 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7075 buf,
7076 inet_ntoa (vl_data->vl_peer),
7077 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7078 VTY_NEWLINE);
7079 /* md5 keys */
7080 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
7081 {
7082 ck = getdata (n2);
7083 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
7084 buf,
7085 inet_ntoa (vl_data->vl_peer),
7086 ck->key_id, ck->auth_key, VTY_NEWLINE);
7087 }
7088
7089 }
7090 }
7091
7092 return 0;
7093}
7094
7095
hassoeb1ce602004-10-08 08:17:22 +00007096const char *distribute_str[] = { "system", "kernel", "connected", "static",
7097 "rip", "ripng", "ospf", "ospf6", "isis", "bgp"};
paul718e3742002-12-13 20:15:29 +00007098int
paul68980082003-03-25 05:07:42 +00007099config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007100{
7101 int type;
7102
7103 /* redistribute print. */
7104 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7105 if (type != zclient->redist_default && zclient->redist[type])
7106 {
7107 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007108 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007109 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007110
paul68980082003-03-25 05:07:42 +00007111 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007112 vty_out (vty, " metric-type 1");
7113
paul020709f2003-04-04 02:44:16 +00007114 if (ROUTEMAP_NAME (ospf, type))
7115 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007116
7117 vty_out (vty, "%s", VTY_NEWLINE);
7118 }
7119
7120 return 0;
7121}
7122
7123int
paul68980082003-03-25 05:07:42 +00007124config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007125{
paul68980082003-03-25 05:07:42 +00007126 if (ospf->default_metric != -1)
7127 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007128 VTY_NEWLINE);
7129 return 0;
7130}
7131
7132int
paul68980082003-03-25 05:07:42 +00007133config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007134{
7135 int type;
7136
paul68980082003-03-25 05:07:42 +00007137 if (ospf)
paul718e3742002-12-13 20:15:29 +00007138 {
7139 /* distribute-list print. */
7140 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007141 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007142 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007143 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007144 distribute_str[type], VTY_NEWLINE);
7145
7146 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007147 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007148 {
paul68980082003-03-25 05:07:42 +00007149 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007150 vty_out (vty, " default-information originate");
7151 else
7152 vty_out (vty, " default-information originate always");
7153
paul68980082003-03-25 05:07:42 +00007154 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007155 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007156 ospf->dmetric[DEFAULT_ROUTE].value);
7157 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007158 vty_out (vty, " metric-type 1");
7159
paul020709f2003-04-04 02:44:16 +00007160 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7161 vty_out (vty, " route-map %s",
7162 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007163
7164 vty_out (vty, "%s", VTY_NEWLINE);
7165 }
7166
7167 }
7168
7169 return 0;
7170}
7171
7172int
paul68980082003-03-25 05:07:42 +00007173config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007174{
7175 struct route_node *rn;
7176 struct ospf_distance *odistance;
7177
paul68980082003-03-25 05:07:42 +00007178 if (ospf->distance_all)
7179 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007180
paul68980082003-03-25 05:07:42 +00007181 if (ospf->distance_intra
7182 || ospf->distance_inter
7183 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007184 {
7185 vty_out (vty, " distance ospf");
7186
paul68980082003-03-25 05:07:42 +00007187 if (ospf->distance_intra)
7188 vty_out (vty, " intra-area %d", ospf->distance_intra);
7189 if (ospf->distance_inter)
7190 vty_out (vty, " inter-area %d", ospf->distance_inter);
7191 if (ospf->distance_external)
7192 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007193
7194 vty_out (vty, "%s", VTY_NEWLINE);
7195 }
7196
paul68980082003-03-25 05:07:42 +00007197 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007198 if ((odistance = rn->info) != NULL)
7199 {
7200 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7201 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7202 odistance->access_list ? odistance->access_list : "",
7203 VTY_NEWLINE);
7204 }
7205 return 0;
7206}
7207
7208/* OSPF configuration write function. */
7209int
7210ospf_config_write (struct vty *vty)
7211{
paul020709f2003-04-04 02:44:16 +00007212 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00007213 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007214 int write = 0;
7215
paul020709f2003-04-04 02:44:16 +00007216 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007217 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007218 {
7219 /* `router ospf' print. */
7220 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7221
7222 write++;
7223
paul68980082003-03-25 05:07:42 +00007224 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007225 return write;
7226
7227 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007228 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007229 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007230 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007231
7232 /* ABR type print. */
paul68980082003-03-25 05:07:42 +00007233 if (ospf->abr_type != OSPF_ABR_STAND)
paul718e3742002-12-13 20:15:29 +00007234 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007235 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007236
7237 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007238 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007239 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7240
7241 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007242 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007243 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007244 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007245
7246 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007247 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7248 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007249 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007250 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007251
7252 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007253 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007254 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007255 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007256
7257 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007258 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007259
7260 /* passive-interface print. */
paul020709f2003-04-04 02:44:16 +00007261 for (node = listhead (om->iflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007262 {
7263 struct interface *ifp = getdata (node);
7264
7265 if (!ifp)
7266 continue;
7267 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7268 vty_out (vty, " passive-interface %s%s",
7269 ifp->name, VTY_NEWLINE);
7270 }
7271
paul68980082003-03-25 05:07:42 +00007272 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007273 {
7274 struct ospf_interface *oi = getdata (node);
7275
7276 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7277 oi->params->passive_interface == OSPF_IF_PASSIVE)
paul96735ee2003-08-10 02:51:22 +00007278 vty_out (vty, " passive-interface %s %s%s",
7279 oi->ifp->name,
paul5fdc1e52003-08-06 22:41:29 +00007280 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007281 }
7282
7283
7284 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007285 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007286
7287 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007288 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007289
7290 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007291 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007292
7293 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007294 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007295
7296 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007297 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007298
7299 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007300 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007301
7302 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007303 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007304
7305#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007306 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007307#endif /* HAVE_OPAQUE_LSA */
7308 }
7309
7310 return write;
7311}
7312
7313void
7314ospf_vty_show_init ()
7315{
7316 /* "show ip ospf" commands. */
7317 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7318 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7319
7320 /* "show ip ospf database" commands. */
7321 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7322 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7323 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7324 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7325 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7326 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7327 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7328 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7329 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7330 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7331 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7332 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7333 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7334 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7335
7336 /* "show ip ospf interface" commands. */
7337 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7338 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7339
7340 /* "show ip ospf neighbor" commands. */
7341 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7342 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7343 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7344 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7345 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7346 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7347 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7348 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7349 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7350 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7351 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7352 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7353 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7354 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7355
7356 /* "show ip ospf route" commands. */
7357 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7358 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007359 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7360 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007361}
7362
7363
7364/* ospfd's interface node. */
7365struct cmd_node interface_node =
7366{
7367 INTERFACE_NODE,
7368 "%s(config-if)# ",
7369 1
7370};
7371
7372/* Initialization of OSPF interface. */
7373void
7374ospf_vty_if_init ()
7375{
7376 /* Install interface node. */
7377 install_node (&interface_node, config_write_interface);
7378
7379 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007380 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007381 install_default (INTERFACE_NODE);
7382
7383 /* "description" commands. */
7384 install_element (INTERFACE_NODE, &interface_desc_cmd);
7385 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7386
7387 /* "ip ospf authentication" commands. */
7388 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7389 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7390 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7391 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7392 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7393 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7394 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7395 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7396 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7397 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7398
7399 /* "ip ospf message-digest-key" commands. */
7400 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7401 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7402 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7403 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7404
7405 /* "ip ospf cost" commands. */
7406 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7407 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7408 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7409 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7410
7411 /* "ip ospf dead-interval" commands. */
7412 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7413 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7414 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7415 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7416
7417 /* "ip ospf hello-interval" commands. */
7418 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7419 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7420 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7421 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7422
7423 /* "ip ospf network" commands. */
7424 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7425 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7426
7427 /* "ip ospf priority" commands. */
7428 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7429 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7430 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7431 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7432
7433 /* "ip ospf retransmit-interval" commands. */
7434 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7435 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7436 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7437 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7438
7439 /* "ip ospf transmit-delay" commands. */
7440 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7441 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7442 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7443 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7444
7445 /* These commands are compatibitliy for previous version. */
7446 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7447 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7448 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7449 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7450 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7451 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7452 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7453 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7454 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7455 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7456 install_element (INTERFACE_NODE, &ospf_network_cmd);
7457 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7458 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7459 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7460 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7461 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7462 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7463 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7464}
7465
7466/* Zebra node structure. */
7467struct cmd_node zebra_node =
7468{
7469 ZEBRA_NODE,
7470 "%s(config-router)#",
7471};
7472
7473void
7474ospf_vty_zebra_init ()
7475{
7476 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7477 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7478 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7479 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7480 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7481 install_element (OSPF_NODE,
7482 &ospf_redistribute_source_metric_type_routemap_cmd);
7483 install_element (OSPF_NODE,
7484 &ospf_redistribute_source_type_metric_routemap_cmd);
7485 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7486 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7487 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7488
7489 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7490
7491 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7492 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7493
7494 install_element (OSPF_NODE,
7495 &ospf_default_information_originate_metric_type_cmd);
7496 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7497 install_element (OSPF_NODE,
7498 &ospf_default_information_originate_type_metric_cmd);
7499 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7500 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7501 install_element (OSPF_NODE,
7502 &ospf_default_information_originate_always_metric_type_cmd);
7503 install_element (OSPF_NODE,
7504 &ospf_default_information_originate_always_metric_cmd);
7505 install_element (OSPF_NODE,
7506 &ospf_default_information_originate_always_cmd);
7507 install_element (OSPF_NODE,
7508 &ospf_default_information_originate_always_type_metric_cmd);
7509 install_element (OSPF_NODE,
7510 &ospf_default_information_originate_always_type_cmd);
7511
7512 install_element (OSPF_NODE,
7513 &ospf_default_information_originate_metric_type_routemap_cmd);
7514 install_element (OSPF_NODE,
7515 &ospf_default_information_originate_metric_routemap_cmd);
7516 install_element (OSPF_NODE,
7517 &ospf_default_information_originate_routemap_cmd);
7518 install_element (OSPF_NODE,
7519 &ospf_default_information_originate_type_metric_routemap_cmd);
7520 install_element (OSPF_NODE,
7521 &ospf_default_information_originate_type_routemap_cmd);
7522 install_element (OSPF_NODE,
7523 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7524 install_element (OSPF_NODE,
7525 &ospf_default_information_originate_always_metric_routemap_cmd);
7526 install_element (OSPF_NODE,
7527 &ospf_default_information_originate_always_routemap_cmd);
7528 install_element (OSPF_NODE,
7529 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7530 install_element (OSPF_NODE,
7531 &ospf_default_information_originate_always_type_routemap_cmd);
7532
7533 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7534
7535 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7536 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7537 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7538
7539 install_element (OSPF_NODE, &ospf_distance_cmd);
7540 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7541 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7542 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7543 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7544 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7545 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7546 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7547 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7548 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7549 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7550 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7551 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7552 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7553 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7554 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7555 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7556 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7557#if 0
7558 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7559 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7560 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7561 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7562#endif /* 0 */
7563}
7564
7565struct cmd_node ospf_node =
7566{
7567 OSPF_NODE,
7568 "%s(config-router)# ",
7569 1
7570};
7571
7572
7573/* Install OSPF related vty commands. */
7574void
7575ospf_vty_init ()
7576{
7577 /* Install ospf top node. */
7578 install_node (&ospf_node, ospf_config_write);
7579
7580 /* "router ospf" commands. */
7581 install_element (CONFIG_NODE, &router_ospf_cmd);
7582 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7583
7584 install_default (OSPF_NODE);
7585
7586 /* "ospf router-id" commands. */
7587 install_element (OSPF_NODE, &ospf_router_id_cmd);
7588 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007589 install_element (OSPF_NODE, &router_ospf_id_cmd);
7590 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007591
7592 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007593 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7594 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7595 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7596 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007597
7598 /* "ospf abr-type" commands. */
7599 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7600 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7601
7602 /* "ospf rfc1583-compatible" commands. */
7603 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7604 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7605 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7606 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7607
7608 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007609 install_element (OSPF_NODE, &ospf_network_area_cmd);
7610 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007611
7612 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007613 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7614 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7615 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007616
7617 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007618 install_element (OSPF_NODE, &ospf_area_range_cmd);
7619 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7620 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7621 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7622 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7623 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7624 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7625 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7626 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7627 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7628 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007629
7630 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007631 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7632 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007633
paula2c62832003-04-23 17:01:31 +00007634 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7635 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007636
paula2c62832003-04-23 17:01:31 +00007637 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7638 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007639
paula2c62832003-04-23 17:01:31 +00007640 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7641 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007642
paula2c62832003-04-23 17:01:31 +00007643 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7644 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007645
paula2c62832003-04-23 17:01:31 +00007646 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7647 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7648 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007649
paula2c62832003-04-23 17:01:31 +00007650 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7651 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007652
paula2c62832003-04-23 17:01:31 +00007653 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7654 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007655
paula2c62832003-04-23 17:01:31 +00007656 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7657 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7658 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007659
paula2c62832003-04-23 17:01:31 +00007660 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7661 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7662 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007663
7664 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007665 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7666 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7667 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7668 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007669
paul718e3742002-12-13 20:15:29 +00007670 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007671 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7672 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7673 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7674 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7675 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7676 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007677
paula2c62832003-04-23 17:01:31 +00007678 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7679 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007680
paula2c62832003-04-23 17:01:31 +00007681 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7682 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007683
paula2c62832003-04-23 17:01:31 +00007684 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7685 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007686
paula2c62832003-04-23 17:01:31 +00007687 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7688 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007689
paula2c62832003-04-23 17:01:31 +00007690 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7691 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007692
paula2c62832003-04-23 17:01:31 +00007693 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7694 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007695
paula2c62832003-04-23 17:01:31 +00007696 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7697 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7698 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007699
paula2c62832003-04-23 17:01:31 +00007700 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7701 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007702
7703 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007704 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7705 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7706 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7707 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7708 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7709 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7710 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7711 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007712
7713 /* Init interface related vty commands. */
7714 ospf_vty_if_init ();
7715
7716 /* Init zebra related vty commands. */
7717 ospf_vty_zebra_init ();
7718}