blob: b4c12ffbd49a56c53546d3f5df406a56f5846c8d [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);
hassofe71a972004-12-22 16:16:02 +00002431 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2432 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2433 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2434 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2435 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2436 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2437 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2438 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2439 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2440 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2441 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2442 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2443 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2444 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2445 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2446#ifdef HAVE_OPAQUE_LSA
2447 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2448 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2449 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2450 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2451 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2452 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2453#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002454 vty_out (vty, "%s", VTY_NEWLINE);
2455}
2456
2457DEFUN (show_ip_ospf,
2458 show_ip_ospf_cmd,
2459 "show ip ospf",
2460 SHOW_STR
2461 IP_STR
2462 "OSPF information\n")
2463{
hasso52dc7ee2004-09-23 19:18:23 +00002464 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002465 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002466 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002467
2468 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002469 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002470 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002471 {
2472 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2473 return CMD_SUCCESS;
2474 }
2475
2476 /* Show Router ID. */
2477 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002478 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002479 VTY_NEWLINE);
2480
2481 /* Show capability. */
2482 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2483 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2484 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002485 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002486 "enabled" : "disabled", VTY_NEWLINE);
2487#ifdef HAVE_OPAQUE_LSA
2488 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002489 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002490 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002491 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002492 " (origination blocked)" : "",
2493 VTY_NEWLINE);
2494#endif /* HAVE_OPAQUE_LSA */
2495
2496 /* Show SPF timers. */
2497 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
paul68980082003-03-25 05:07:42 +00002498 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002499
2500 /* Show refresh parameters. */
2501 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002502 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002503
2504 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002505 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002506 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002507 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002508
paul68980082003-03-25 05:07:42 +00002509 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002510 vty_out (vty, " This router is an ASBR "
2511 "(injecting external routing information)%s", VTY_NEWLINE);
2512
2513 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002514 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2515 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2516 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2517#ifdef HAVE_OPAQUE_LSA
2518 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2519 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2520 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2521#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002522 /* Show number of areas attached. */
2523 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002524 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002525
2526 /* Show each area status. */
paul68980082003-03-25 05:07:42 +00002527 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002528 if ((area = getdata (node)) != NULL)
2529 show_ip_ospf_area (vty, area);
2530
2531 return CMD_SUCCESS;
2532}
2533
2534
2535void
paul68980082003-03-25 05:07:42 +00002536show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2537 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002538{
2539 struct ospf_neighbor *nbr;
2540 int oi_count;
2541 struct route_node *rn;
2542 char buf[9];
2543
2544 oi_count = ospf_oi_count (ifp);
2545
2546 /* Is interface up? */
paul2e3b2e42002-12-13 21:03:13 +00002547 if (if_is_operative (ifp)) {
2548 vty_out (vty, "%s is up%s", ifp->name, VTY_NEWLINE);
2549 } else
2550 {
2551 vty_out (vty, "%s is down%s", ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002552
2553
2554 if (oi_count == 0)
2555 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2556 else
2557 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2558 VTY_NEWLINE);
2559 return;
2560 }
2561
2562 /* Is interface OSPF enabled? */
2563 if (oi_count == 0)
2564 {
2565 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2566 return;
2567 }
2568
2569 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2570 {
2571 struct ospf_interface *oi = rn->info;
2572
2573 if (oi == NULL)
2574 continue;
2575
2576 /* Show OSPF interface information. */
2577 vty_out (vty, " Internet Address %s/%d,",
2578 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2579
hasso3fb9cd62004-10-19 19:44:43 +00002580 if (oi->connected->destination)
2581 vty_out (vty, " %s %s,",
2582 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2583 inet_ntoa (oi->connected->destination->u.prefix4));
2584
paul718e3742002-12-13 20:15:29 +00002585 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2586 VTY_NEWLINE);
2587
2588 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002589 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002590 oi->output_cost, VTY_NEWLINE);
2591
2592 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2593 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2594 PRIORITY (oi), VTY_NEWLINE);
2595
2596 /* Show DR information. */
2597 if (DR (oi).s_addr == 0)
2598 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2599 else
2600 {
2601 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2602 if (nbr == NULL)
2603 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2604 else
2605 {
2606 vty_out (vty, " Designated Router (ID) %s,",
2607 inet_ntoa (nbr->router_id));
2608 vty_out (vty, " Interface Address %s%s",
2609 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2610 }
2611 }
2612
2613 /* Show BDR information. */
2614 if (BDR (oi).s_addr == 0)
2615 vty_out (vty, " No backup designated router on this network%s",
2616 VTY_NEWLINE);
2617 else
2618 {
2619 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2620 if (nbr == NULL)
2621 vty_out (vty, " No backup designated router on this network%s",
2622 VTY_NEWLINE);
2623 else
2624 {
2625 vty_out (vty, " Backup Designated Router (ID) %s,",
2626 inet_ntoa (nbr->router_id));
2627 vty_out (vty, " Interface Address %s%s",
2628 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2629 }
2630 }
2631 vty_out (vty, " Timer intervals configured,");
2632 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2633 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2634 OSPF_IF_PARAM (oi, v_wait),
2635 OSPF_IF_PARAM (oi, retransmit_interval),
2636 VTY_NEWLINE);
2637
2638 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2639 vty_out (vty, " Hello due in %s%s",
2640 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2641 else /* OSPF_IF_PASSIVE is set */
2642 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2643
2644 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002645 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002646 VTY_NEWLINE);
2647 }
2648}
2649
2650DEFUN (show_ip_ospf_interface,
2651 show_ip_ospf_interface_cmd,
2652 "show ip ospf interface [INTERFACE]",
2653 SHOW_STR
2654 IP_STR
2655 "OSPF information\n"
2656 "Interface information\n"
2657 "Interface name\n")
2658{
2659 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002660 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002661 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002662
paul020709f2003-04-04 02:44:16 +00002663 ospf = ospf_lookup ();
2664
paul718e3742002-12-13 20:15:29 +00002665 /* Show All Interfaces. */
2666 if (argc == 0)
2667 for (node = listhead (iflist); node; nextnode (node))
paul68980082003-03-25 05:07:42 +00002668 show_ip_ospf_interface_sub (vty, ospf, node->data);
paul718e3742002-12-13 20:15:29 +00002669 /* Interface name is specified. */
2670 else
2671 {
2672 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2673 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2674 else
paul68980082003-03-25 05:07:42 +00002675 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002676 }
2677
2678 return CMD_SUCCESS;
2679}
2680
2681void
2682show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2683{
2684 struct route_node *rn;
2685 struct ospf_neighbor *nbr;
2686 char msgbuf[16];
2687 char timebuf[9];
2688
2689 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2690 if ((nbr = rn->info))
2691 /* Do not show myself. */
2692 if (nbr != oi->nbr_self)
2693 /* Down state is not shown. */
2694 if (nbr->state != NSM_Down)
2695 {
2696 ospf_nbr_state_message (nbr, msgbuf, 16);
2697
2698 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2699 vty_out (vty, "%-15s %3d %-15s %8s ",
2700 "-", nbr->priority,
2701 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2702 else
2703 vty_out (vty, "%-15s %3d %-15s %8s ",
2704 inet_ntoa (nbr->router_id), nbr->priority,
2705 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2706 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2707 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2708 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2709 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2710 VTY_NEWLINE);
2711 }
2712}
2713
2714DEFUN (show_ip_ospf_neighbor,
2715 show_ip_ospf_neighbor_cmd,
2716 "show ip ospf neighbor",
2717 SHOW_STR
2718 IP_STR
2719 "OSPF information\n"
2720 "Neighbor list\n")
2721{
paul020709f2003-04-04 02:44:16 +00002722 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002723 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002724
paul020709f2003-04-04 02:44:16 +00002725 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002726 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002727 {
2728 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2729 return CMD_SUCCESS;
2730 }
2731
2732 /* Show All neighbors. */
2733 vty_out (vty, "%sNeighbor ID Pri State Dead "
2734 "Time Address Interface RXmtL "
2735 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2736
paul68980082003-03-25 05:07:42 +00002737 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul020709f2003-04-04 02:44:16 +00002738 show_ip_ospf_neighbor_sub (vty, getdata (node));
paul718e3742002-12-13 20:15:29 +00002739
2740 return CMD_SUCCESS;
2741}
2742
2743DEFUN (show_ip_ospf_neighbor_all,
2744 show_ip_ospf_neighbor_all_cmd,
2745 "show ip ospf neighbor all",
2746 SHOW_STR
2747 IP_STR
2748 "OSPF information\n"
2749 "Neighbor list\n"
2750 "include down status neighbor\n")
2751{
paul68980082003-03-25 05:07:42 +00002752 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002753 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002754
paul68980082003-03-25 05:07:42 +00002755 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002756 {
2757 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2758 return CMD_SUCCESS;
2759 }
2760
2761 /* Show All neighbors. */
2762 vty_out (vty, "%sNeighbor ID Pri State Dead "
2763 "Time Address Interface RXmtL "
2764 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2765
paul68980082003-03-25 05:07:42 +00002766 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002767 {
2768 struct ospf_interface *oi = getdata (node);
hasso52dc7ee2004-09-23 19:18:23 +00002769 struct listnode *nbr_node;
paul718e3742002-12-13 20:15:29 +00002770
2771 show_ip_ospf_neighbor_sub (vty, oi);
2772
2773 /* print Down neighbor status */
2774 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
2775 {
2776 struct ospf_nbr_nbma *nbr_nbma;
2777
2778 nbr_nbma = getdata (nbr_node);
2779
2780 if (nbr_nbma->nbr == NULL
2781 || nbr_nbma->nbr->state == NSM_Down)
2782 {
2783 vty_out (vty, "%-15s %3d %-15s %8s ",
2784 "-", nbr_nbma->priority, "Down", "-");
2785 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2786 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2787 0, 0, 0, VTY_NEWLINE);
2788 }
2789 }
2790 }
2791
2792 return CMD_SUCCESS;
2793}
2794
2795DEFUN (show_ip_ospf_neighbor_int,
2796 show_ip_ospf_neighbor_int_cmd,
2797 "show ip ospf neighbor A.B.C.D",
2798 SHOW_STR
2799 IP_STR
2800 "OSPF information\n"
2801 "Neighbor list\n"
2802 "Interface name\n")
2803{
paul020709f2003-04-04 02:44:16 +00002804 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002805 struct ospf_interface *oi;
2806 struct in_addr addr;
2807 int ret;
2808
paul718e3742002-12-13 20:15:29 +00002809 ret = inet_aton (argv[0], &addr);
2810 if (!ret)
2811 {
2812 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2813 VTY_NEWLINE);
2814 return CMD_WARNING;
2815 }
2816
paul020709f2003-04-04 02:44:16 +00002817 ospf = ospf_lookup ();
2818 if (ospf == NULL)
2819 {
2820 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2821 return CMD_SUCCESS;
2822 }
2823
paul68980082003-03-25 05:07:42 +00002824 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00002825 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2826 else
2827 {
2828 vty_out (vty, "%sNeighbor ID Pri State Dead "
2829 "Time Address Interface RXmtL "
2830 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2831 show_ip_ospf_neighbor_sub (vty, oi);
2832 }
2833
2834 return CMD_SUCCESS;
2835}
2836
2837void
2838show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2839 struct ospf_nbr_nbma *nbr_nbma)
2840{
2841 char timebuf[9];
2842
2843 /* Show neighbor ID. */
2844 vty_out (vty, " Neighbor %s,", "-");
2845
2846 /* Show interface address. */
2847 vty_out (vty, " interface address %s%s",
2848 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2849 /* Show Area ID. */
2850 vty_out (vty, " In the area %s via interface %s%s",
2851 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2852 /* Show neighbor priority and state. */
2853 vty_out (vty, " Neighbor priority is %d, State is %s,",
2854 nbr_nbma->priority, "Down");
2855 /* Show state changes. */
2856 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2857
2858 /* Show PollInterval */
2859 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2860
2861 /* Show poll-interval timer. */
2862 vty_out (vty, " Poll timer due in %s%s",
2863 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2864
2865 /* Show poll-interval timer thread. */
2866 vty_out (vty, " Thread Poll Timer %s%s",
2867 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2868}
2869
2870void
2871show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2872 struct ospf_neighbor *nbr)
2873{
2874 char timebuf[9];
2875
2876 /* Show neighbor ID. */
2877 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2878 vty_out (vty, " Neighbor %s,", "-");
2879 else
2880 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2881
2882 /* Show interface address. */
2883 vty_out (vty, " interface address %s%s",
2884 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2885 /* Show Area ID. */
2886 vty_out (vty, " In the area %s via interface %s%s",
2887 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2888 /* Show neighbor priority and state. */
2889 vty_out (vty, " Neighbor priority is %d, State is %s,",
2890 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2891 /* Show state changes. */
2892 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2893
2894 /* Show Designated Rotuer ID. */
2895 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2896 /* Show Backup Designated Rotuer ID. */
2897 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2898 /* Show options. */
2899 vty_out (vty, " Options %d %s%s", nbr->options,
2900 ospf_options_dump (nbr->options), VTY_NEWLINE);
2901 /* Show Router Dead interval timer. */
2902 vty_out (vty, " Dead timer due in %s%s",
2903 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2904 /* Show Database Summary list. */
2905 vty_out (vty, " Database Summary List %d%s",
2906 ospf_db_summary_count (nbr), VTY_NEWLINE);
2907 /* Show Link State Request list. */
2908 vty_out (vty, " Link State Request List %ld%s",
2909 ospf_ls_request_count (nbr), VTY_NEWLINE);
2910 /* Show Link State Retransmission list. */
2911 vty_out (vty, " Link State Retransmission List %ld%s",
2912 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2913 /* Show inactivity timer thread. */
2914 vty_out (vty, " Thread Inactivity Timer %s%s",
2915 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2916 /* Show Database Description retransmission thread. */
2917 vty_out (vty, " Thread Database Description Retransmision %s%s",
2918 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2919 /* Show Link State Request Retransmission thread. */
2920 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2921 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2922 /* Show Link State Update Retransmission thread. */
2923 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2924 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2925}
2926
2927DEFUN (show_ip_ospf_neighbor_id,
2928 show_ip_ospf_neighbor_id_cmd,
2929 "show ip ospf neighbor A.B.C.D",
2930 SHOW_STR
2931 IP_STR
2932 "OSPF information\n"
2933 "Neighbor list\n"
2934 "Neighbor ID\n")
2935{
paul020709f2003-04-04 02:44:16 +00002936 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002937 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002938 struct ospf_neighbor *nbr;
2939 struct in_addr router_id;
2940 int ret;
2941
2942 ret = inet_aton (argv[0], &router_id);
2943 if (!ret)
2944 {
2945 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
2946 return CMD_WARNING;
2947 }
2948
paul020709f2003-04-04 02:44:16 +00002949 ospf = ospf_lookup ();
2950 if (ospf == NULL)
2951 {
2952 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2953 return CMD_SUCCESS;
2954 }
2955
paul68980082003-03-25 05:07:42 +00002956 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002957 {
2958 struct ospf_interface *oi = getdata (node);
2959
2960 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
2961 {
2962 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
2963 return CMD_SUCCESS;
2964 }
2965 }
2966
2967 /* Nothing to show. */
2968 return CMD_SUCCESS;
2969}
2970
2971DEFUN (show_ip_ospf_neighbor_detail,
2972 show_ip_ospf_neighbor_detail_cmd,
2973 "show ip ospf neighbor detail",
2974 SHOW_STR
2975 IP_STR
2976 "OSPF information\n"
2977 "Neighbor list\n"
2978 "detail of all neighbors\n")
2979{
paul020709f2003-04-04 02:44:16 +00002980 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002981 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002982
paul020709f2003-04-04 02:44:16 +00002983 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002984 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00002985 {
2986 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2987 return CMD_SUCCESS;
2988 }
paul718e3742002-12-13 20:15:29 +00002989
paul68980082003-03-25 05:07:42 +00002990 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002991 {
2992 struct ospf_interface *oi = getdata (node);
2993 struct route_node *rn;
2994 struct ospf_neighbor *nbr;
2995
2996 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2997 if ((nbr = rn->info))
2998 if (nbr != oi->nbr_self)
2999 if (nbr->state != NSM_Down)
3000 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3001 }
3002
3003 return CMD_SUCCESS;
3004}
3005
3006DEFUN (show_ip_ospf_neighbor_detail_all,
3007 show_ip_ospf_neighbor_detail_all_cmd,
3008 "show ip ospf neighbor detail all",
3009 SHOW_STR
3010 IP_STR
3011 "OSPF information\n"
3012 "Neighbor list\n"
3013 "detail of all neighbors\n"
3014 "include down status neighbor\n")
3015{
paul020709f2003-04-04 02:44:16 +00003016 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003017 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003018
paul020709f2003-04-04 02:44:16 +00003019 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003020 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003021 {
3022 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3023 return CMD_SUCCESS;
3024 }
paul718e3742002-12-13 20:15:29 +00003025
paul68980082003-03-25 05:07:42 +00003026 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003027 {
3028 struct ospf_interface *oi = getdata (node);
3029 struct route_node *rn;
3030 struct ospf_neighbor *nbr;
3031
3032 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3033 if ((nbr = rn->info))
3034 if (nbr != oi->nbr_self)
3035 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3036 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3037
3038 if (oi->type == OSPF_IFTYPE_NBMA)
3039 {
hasso52dc7ee2004-09-23 19:18:23 +00003040 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003041
3042 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
3043 {
3044 struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
3045 if (nbr_nbma->nbr == NULL
3046 || nbr_nbma->nbr->state == NSM_Down)
3047 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3048 }
3049 }
3050 }
3051
3052 return CMD_SUCCESS;
3053}
3054
3055DEFUN (show_ip_ospf_neighbor_int_detail,
3056 show_ip_ospf_neighbor_int_detail_cmd,
3057 "show ip ospf neighbor A.B.C.D detail",
3058 SHOW_STR
3059 IP_STR
3060 "OSPF information\n"
3061 "Neighbor list\n"
3062 "Interface address\n"
3063 "detail of all neighbors")
3064{
paul020709f2003-04-04 02:44:16 +00003065 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003066 struct ospf_interface *oi;
3067 struct in_addr addr;
3068 int ret;
3069
3070 ret = inet_aton (argv[0], &addr);
3071 if (!ret)
3072 {
3073 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3074 VTY_NEWLINE);
3075 return CMD_WARNING;
3076 }
3077
paul020709f2003-04-04 02:44:16 +00003078 ospf = ospf_lookup ();
3079 if (ospf == NULL)
3080 {
3081 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3082 return CMD_SUCCESS;
3083 }
paul68980082003-03-25 05:07:42 +00003084
paul020709f2003-04-04 02:44:16 +00003085 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00003086 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3087 else
3088 {
3089 struct route_node *rn;
3090 struct ospf_neighbor *nbr;
3091
3092 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3093 if ((nbr = rn->info))
3094 if (nbr != oi->nbr_self)
3095 if (nbr->state != NSM_Down)
3096 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3097 }
3098
3099 return CMD_SUCCESS;
3100}
3101
3102
3103/* Show functions */
3104int
paul020709f2003-04-04 02:44:16 +00003105show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003106{
paul718e3742002-12-13 20:15:29 +00003107 struct router_lsa *rl;
3108 struct summary_lsa *sl;
3109 struct as_external_lsa *asel;
3110 struct prefix_ipv4 p;
3111
3112 if (lsa != NULL)
3113 /* If self option is set, check LSA self flag. */
3114 if (self == 0 || IS_LSA_SELF (lsa))
3115 {
3116 /* LSA common part show. */
3117 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3118 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3119 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3120 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3121 /* LSA specific part show. */
3122 switch (lsa->data->type)
3123 {
3124 case OSPF_ROUTER_LSA:
3125 rl = (struct router_lsa *) lsa->data;
3126 vty_out (vty, " %-d", ntohs (rl->links));
3127 break;
3128 case OSPF_SUMMARY_LSA:
3129 sl = (struct summary_lsa *) lsa->data;
3130
3131 p.family = AF_INET;
3132 p.prefix = sl->header.id;
3133 p.prefixlen = ip_masklen (sl->mask);
3134 apply_mask_ipv4 (&p);
3135
3136 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3137 break;
3138 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003139 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003140 asel = (struct as_external_lsa *) lsa->data;
3141
3142 p.family = AF_INET;
3143 p.prefix = asel->header.id;
3144 p.prefixlen = ip_masklen (asel->mask);
3145 apply_mask_ipv4 (&p);
3146
3147 vty_out (vty, " %s %s/%d [0x%lx]",
3148 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3149 inet_ntoa (p.prefix), p.prefixlen,
3150 (u_long)ntohl (asel->e[0].route_tag));
3151 break;
3152 case OSPF_NETWORK_LSA:
3153 case OSPF_ASBR_SUMMARY_LSA:
3154#ifdef HAVE_OPAQUE_LSA
3155 case OSPF_OPAQUE_LINK_LSA:
3156 case OSPF_OPAQUE_AREA_LSA:
3157 case OSPF_OPAQUE_AS_LSA:
3158#endif /* HAVE_OPAQUE_LSA */
3159 default:
3160 break;
3161 }
3162 vty_out (vty, VTY_NEWLINE);
3163 }
3164
3165 return 0;
3166}
3167
hassoeb1ce602004-10-08 08:17:22 +00003168const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003169{
3170 "unknown",
3171 "Router Link States",
3172 "Net Link States",
3173 "Summary Link States",
3174 "ASBR-Summary Link States",
3175 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003176 "Group Membership LSA",
3177 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003178#ifdef HAVE_OPAQUE_LSA
3179 "Type-8 LSA",
3180 "Link-Local Opaque-LSA",
3181 "Area-Local Opaque-LSA",
3182 "AS-external Opaque-LSA",
3183#endif /* HAVE_OPAQUE_LSA */
3184};
3185
3186#define SHOW_OSPF_COMMON_HEADER \
3187 "Link ID ADV Router Age Seq# CkSum"
3188
hassoeb1ce602004-10-08 08:17:22 +00003189const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003190{
3191 "",
3192 "Link ID ADV Router Age Seq# CkSum Link count",
3193 "Link ID ADV Router Age Seq# CkSum",
3194 "Link ID ADV Router Age Seq# CkSum Route",
3195 "Link ID ADV Router Age Seq# CkSum",
3196 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003197 " --- header for Group Member ----",
3198 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003199#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003200 " --- type-8 ---",
3201 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3202 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3203 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3204#endif /* HAVE_OPAQUE_LSA */
3205};
3206
hassoeb1ce602004-10-08 08:17:22 +00003207const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003208{
3209 "Self-originated",
3210 "Checked",
3211 "Received",
3212 "Approved",
3213 "Discard",
paul4957f492003-06-27 01:28:45 +00003214 "Translated",
paul4957f492003-06-27 01:28:45 +00003215};
3216
paul718e3742002-12-13 20:15:29 +00003217void
3218show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3219{
3220 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003221
paul718e3742002-12-13 20:15:29 +00003222 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003223 vty_out (vty, " Options: 0x%-2x : %s%s",
3224 lsa->data->options,
3225 ospf_options_dump(lsa->data->options),
3226 VTY_NEWLINE);
3227 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003228 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003229 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3230 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003231
3232 if (lsa->data->type == OSPF_ROUTER_LSA)
3233 {
3234 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3235
3236 if (rlsa->flags)
3237 vty_out (vty, " :%s%s%s%s",
3238 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3239 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3240 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3241 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3242
3243 vty_out (vty, "%s", VTY_NEWLINE);
3244 }
3245 vty_out (vty, " LS Type: %s%s",
3246 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3247 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3248 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3249 vty_out (vty, " Advertising Router: %s%s",
3250 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3251 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3252 VTY_NEWLINE);
3253 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3254 VTY_NEWLINE);
3255 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3256}
3257
hassoeb1ce602004-10-08 08:17:22 +00003258const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003259{
3260 "(null)",
3261 "another Router (point-to-point)",
3262 "a Transit Network",
3263 "Stub Network",
3264 "a Virtual Link",
3265};
3266
hassoeb1ce602004-10-08 08:17:22 +00003267const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003268{
3269 "(null)",
3270 "Neighboring Router ID",
3271 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003272 "Net",
paul718e3742002-12-13 20:15:29 +00003273 "Neighboring Router ID",
3274};
3275
hassoeb1ce602004-10-08 08:17:22 +00003276const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003277{
3278 "(null)",
3279 "Router Interface address",
3280 "Router Interface address",
3281 "Network Mask",
3282 "Router Interface address",
3283};
3284
3285/* Show router-LSA each Link information. */
3286void
3287show_ip_ospf_database_router_links (struct vty *vty,
3288 struct router_lsa *rl)
3289{
3290 int len, i, type;
3291
3292 len = ntohs (rl->header.length) - 4;
3293 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3294 {
3295 type = rl->link[i].type;
3296
3297 vty_out (vty, " Link connected to: %s%s",
3298 link_type_desc[type], VTY_NEWLINE);
3299 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3300 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3301 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3302 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3303 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3304 vty_out (vty, " TOS 0 Metric: %d%s",
3305 ntohs (rl->link[i].metric), VTY_NEWLINE);
3306 vty_out (vty, "%s", VTY_NEWLINE);
3307 }
3308}
3309
3310/* Show router-LSA detail information. */
3311int
3312show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3313{
3314 if (lsa != NULL)
3315 {
3316 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3317
3318 show_ip_ospf_database_header (vty, lsa);
3319
3320 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3321 VTY_NEWLINE, VTY_NEWLINE);
3322
3323 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003324 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003325 }
3326
3327 return 0;
3328}
3329
3330/* Show network-LSA detail information. */
3331int
3332show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3333{
3334 int length, i;
3335
3336 if (lsa != NULL)
3337 {
3338 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3339
3340 show_ip_ospf_database_header (vty, lsa);
3341
3342 vty_out (vty, " Network Mask: /%d%s",
3343 ip_masklen (nl->mask), VTY_NEWLINE);
3344
3345 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3346
3347 for (i = 0; length > 0; i++, length -= 4)
3348 vty_out (vty, " Attached Router: %s%s",
3349 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3350
3351 vty_out (vty, "%s", VTY_NEWLINE);
3352 }
3353
3354 return 0;
3355}
3356
3357/* Show summary-LSA detail information. */
3358int
3359show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3360{
3361 if (lsa != NULL)
3362 {
3363 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3364
3365 show_ip_ospf_database_header (vty, lsa);
3366
3367 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3368 VTY_NEWLINE);
3369 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3370 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003371 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003372 }
3373
3374 return 0;
3375}
3376
3377/* Show summary-ASBR-LSA detail information. */
3378int
3379show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3380{
3381 if (lsa != NULL)
3382 {
3383 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3384
3385 show_ip_ospf_database_header (vty, lsa);
3386
3387 vty_out (vty, " Network Mask: /%d%s",
3388 ip_masklen (sl->mask), VTY_NEWLINE);
3389 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3390 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003391 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003392 }
3393
3394 return 0;
3395}
3396
3397/* Show AS-external-LSA detail information. */
3398int
3399show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3400{
3401 if (lsa != NULL)
3402 {
3403 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3404
3405 show_ip_ospf_database_header (vty, lsa);
3406
3407 vty_out (vty, " Network Mask: /%d%s",
3408 ip_masklen (al->mask), VTY_NEWLINE);
3409 vty_out (vty, " Metric Type: %s%s",
3410 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3411 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3412 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3413 vty_out (vty, " Metric: %d%s",
3414 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3415 vty_out (vty, " Forward Address: %s%s",
3416 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3417
3418 vty_out (vty, " External Route Tag: %lu%s%s",
3419 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3420 }
3421
3422 return 0;
3423}
3424
ajs2a42e282004-12-08 18:43:03 +00003425/* N.B. This function currently seems to be unused. */
paul718e3742002-12-13 20:15:29 +00003426int
3427show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3428{
3429 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3430
3431 /* show_ip_ospf_database_header (vty, lsa); */
3432
ajs2a42e282004-12-08 18:43:03 +00003433 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003434 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003435 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003436 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3437 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003438 zlog_debug( " TOS: 0%s", "\n");
3439 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003440 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003441 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003442 inet_ntoa (al->e[0].fwd_addr), "\n");
3443
ajs2a42e282004-12-08 18:43:03 +00003444 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003445 ntohl (al->e[0].route_tag), "\n", "\n");
3446
3447 return 0;
3448}
3449
3450/* Show AS-NSSA-LSA detail information. */
3451int
3452show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3453{
3454 if (lsa != NULL)
3455 {
3456 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3457
3458 show_ip_ospf_database_header (vty, lsa);
3459
3460 vty_out (vty, " Network Mask: /%d%s",
3461 ip_masklen (al->mask), VTY_NEWLINE);
3462 vty_out (vty, " Metric Type: %s%s",
3463 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3464 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3465 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3466 vty_out (vty, " Metric: %d%s",
3467 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3468 vty_out (vty, " NSSA: Forward Address: %s%s",
3469 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3470
3471 vty_out (vty, " External Route Tag: %u%s%s",
3472 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3473 }
3474
3475 return 0;
3476}
3477
paul718e3742002-12-13 20:15:29 +00003478int
3479show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3480{
3481 return 0;
3482}
3483
3484#ifdef HAVE_OPAQUE_LSA
3485int
3486show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3487{
3488 if (lsa != NULL)
3489 {
3490 show_ip_ospf_database_header (vty, lsa);
3491 show_opaque_info_detail (vty, lsa);
3492
3493 vty_out (vty, "%s", VTY_NEWLINE);
3494 }
3495 return 0;
3496}
3497#endif /* HAVE_OPAQUE_LSA */
3498
3499int (*show_function[])(struct vty *, struct ospf_lsa *) =
3500{
3501 NULL,
3502 show_router_lsa_detail,
3503 show_network_lsa_detail,
3504 show_summary_lsa_detail,
3505 show_summary_asbr_lsa_detail,
3506 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003507 show_func_dummy,
3508 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003509#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003510 NULL, /* type-8 */
3511 show_opaque_lsa_detail,
3512 show_opaque_lsa_detail,
3513 show_opaque_lsa_detail,
3514#endif /* HAVE_OPAQUE_LSA */
3515};
3516
3517void
3518show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3519 struct in_addr *adv_router)
3520{
3521 memset (lp, 0, sizeof (struct prefix_ls));
3522 lp->family = 0;
3523 if (id == NULL)
3524 lp->prefixlen = 0;
3525 else if (adv_router == NULL)
3526 {
3527 lp->prefixlen = 32;
3528 lp->id = *id;
3529 }
3530 else
3531 {
3532 lp->prefixlen = 64;
3533 lp->id = *id;
3534 lp->adv_router = *adv_router;
3535 }
3536}
3537
3538void
3539show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3540 struct in_addr *id, struct in_addr *adv_router)
3541{
3542 struct prefix_ls lp;
3543 struct route_node *rn, *start;
3544 struct ospf_lsa *lsa;
3545
3546 show_lsa_prefix_set (vty, &lp, id, adv_router);
3547 start = route_node_get (rt, (struct prefix *) &lp);
3548 if (start)
3549 {
3550 route_lock_node (start);
3551 for (rn = start; rn; rn = route_next_until (rn, start))
3552 if ((lsa = rn->info))
3553 {
paul718e3742002-12-13 20:15:29 +00003554 if (show_function[lsa->data->type] != NULL)
3555 show_function[lsa->data->type] (vty, lsa);
3556 }
3557 route_unlock_node (start);
3558 }
3559}
3560
3561/* Show detail LSA information
3562 -- if id is NULL then show all LSAs. */
3563void
paul020709f2003-04-04 02:44:16 +00003564show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003565 struct in_addr *id, struct in_addr *adv_router)
3566{
hasso52dc7ee2004-09-23 19:18:23 +00003567 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003568
3569 switch (type)
3570 {
3571 case OSPF_AS_EXTERNAL_LSA:
3572#ifdef HAVE_OPAQUE_LSA
3573 case OSPF_OPAQUE_AS_LSA:
3574#endif /* HAVE_OPAQUE_LSA */
3575 vty_out (vty, " %s %s%s",
3576 show_database_desc[type],
3577 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003578 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003579 break;
3580 default:
paul68980082003-03-25 05:07:42 +00003581 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003582 {
3583 struct ospf_area *area = node->data;
3584 vty_out (vty, "%s %s (Area %s)%s%s",
3585 VTY_NEWLINE, show_database_desc[type],
3586 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3587 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3588 }
3589 break;
3590 }
3591}
3592
3593void
3594show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3595 struct in_addr *adv_router)
3596{
3597 struct route_node *rn;
3598 struct ospf_lsa *lsa;
3599
3600 for (rn = route_top (rt); rn; rn = route_next (rn))
3601 if ((lsa = rn->info))
3602 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3603 {
paul718e3742002-12-13 20:15:29 +00003604 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3605 continue;
paul718e3742002-12-13 20:15:29 +00003606 if (show_function[lsa->data->type] != NULL)
3607 show_function[lsa->data->type] (vty, lsa);
3608 }
3609}
3610
3611/* Show detail LSA information. */
3612void
paul020709f2003-04-04 02:44:16 +00003613show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003614 struct in_addr *adv_router)
3615{
hasso52dc7ee2004-09-23 19:18:23 +00003616 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003617
3618 switch (type)
3619 {
3620 case OSPF_AS_EXTERNAL_LSA:
3621#ifdef HAVE_OPAQUE_LSA
3622 case OSPF_OPAQUE_AS_LSA:
3623#endif /* HAVE_OPAQUE_LSA */
3624 vty_out (vty, " %s %s%s",
3625 show_database_desc[type],
3626 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003627 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003628 adv_router);
3629 break;
3630 default:
paul68980082003-03-25 05:07:42 +00003631 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003632 {
3633 struct ospf_area *area = node->data;
3634 vty_out (vty, "%s %s (Area %s)%s%s",
3635 VTY_NEWLINE, show_database_desc[type],
3636 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3637 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3638 adv_router);
3639 }
3640 break;
3641 }
3642}
3643
3644void
paul020709f2003-04-04 02:44:16 +00003645show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003646{
paul020709f2003-04-04 02:44:16 +00003647 struct ospf_lsa *lsa;
3648 struct route_node *rn;
hasso52dc7ee2004-09-23 19:18:23 +00003649 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003650 int type;
3651
paul68980082003-03-25 05:07:42 +00003652 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003653 {
3654 struct ospf_area *area = node->data;
3655 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3656 {
3657 switch (type)
3658 {
3659 case OSPF_AS_EXTERNAL_LSA:
3660#ifdef HAVE_OPAQUE_LSA
3661 case OSPF_OPAQUE_AS_LSA:
3662#endif /* HAVE_OPAQUE_LSA */
3663 continue;
3664 default:
3665 break;
3666 }
3667 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3668 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3669 {
3670 vty_out (vty, " %s (Area %s)%s%s",
3671 show_database_desc[type],
3672 ospf_area_desc_string (area),
3673 VTY_NEWLINE, VTY_NEWLINE);
3674 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3675
paul020709f2003-04-04 02:44:16 +00003676 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3677 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003678
3679 vty_out (vty, "%s", VTY_NEWLINE);
3680 }
3681 }
3682 }
3683
3684 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3685 {
3686 switch (type)
3687 {
3688 case OSPF_AS_EXTERNAL_LSA:
3689#ifdef HAVE_OPAQUE_LSA
3690 case OSPF_OPAQUE_AS_LSA:
3691#endif /* HAVE_OPAQUE_LSA */
3692 break;;
3693 default:
3694 continue;
3695 }
paul68980082003-03-25 05:07:42 +00003696 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3697 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003698 {
3699 vty_out (vty, " %s%s%s",
3700 show_database_desc[type],
3701 VTY_NEWLINE, VTY_NEWLINE);
3702 vty_out (vty, "%s%s", show_database_header[type],
3703 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003704
3705 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3706 show_lsa_summary (vty, lsa, self);
3707
paul718e3742002-12-13 20:15:29 +00003708 vty_out (vty, "%s", VTY_NEWLINE);
3709 }
3710 }
3711
3712 vty_out (vty, "%s", VTY_NEWLINE);
3713}
3714
3715void
paul020709f2003-04-04 02:44:16 +00003716show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003717{
hasso52dc7ee2004-09-23 19:18:23 +00003718 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003719 struct ospf_lsa *lsa;
3720
3721 vty_out (vty, "%s MaxAge Link States:%s%s",
3722 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3723
paul68980082003-03-25 05:07:42 +00003724 for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003725 if ((lsa = node->data) != NULL)
3726 {
3727 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3728 vty_out (vty, "Link State ID: %s%s",
3729 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3730 vty_out (vty, "Advertising Router: %s%s",
3731 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3732 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3733 vty_out (vty, "%s", VTY_NEWLINE);
3734 }
3735}
3736
paul718e3742002-12-13 20:15:29 +00003737#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3738#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003739
3740#ifdef HAVE_OPAQUE_LSA
3741#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3742#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3743#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3744#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3745#else /* HAVE_OPAQUE_LSA */
3746#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3747#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3748#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3749#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3750#endif /* HAVE_OPAQUE_LSA */
3751
3752#define OSPF_LSA_TYPES_CMD_STR \
3753 "asbr-summary|external|network|router|summary" \
3754 OSPF_LSA_TYPE_NSSA_CMD_STR \
3755 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3756
3757#define OSPF_LSA_TYPES_DESC \
3758 "ASBR summary link states\n" \
3759 "External link states\n" \
3760 "Network link states\n" \
3761 "Router link states\n" \
3762 "Network summary link states\n" \
3763 OSPF_LSA_TYPE_NSSA_DESC \
3764 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3765 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3766 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3767
3768DEFUN (show_ip_ospf_database,
3769 show_ip_ospf_database_cmd,
3770 "show ip ospf database",
3771 SHOW_STR
3772 IP_STR
3773 "OSPF information\n"
3774 "Database summary\n")
3775{
paul020709f2003-04-04 02:44:16 +00003776 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003777 int type, ret;
3778 struct in_addr id, adv_router;
3779
paul020709f2003-04-04 02:44:16 +00003780 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003781 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003782 return CMD_SUCCESS;
3783
3784 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003785 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003786
3787 /* Show all LSA. */
3788 if (argc == 0)
3789 {
paul020709f2003-04-04 02:44:16 +00003790 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003791 return CMD_SUCCESS;
3792 }
3793
3794 /* Set database type to show. */
3795 if (strncmp (argv[0], "r", 1) == 0)
3796 type = OSPF_ROUTER_LSA;
3797 else if (strncmp (argv[0], "ne", 2) == 0)
3798 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003799 else if (strncmp (argv[0], "ns", 2) == 0)
3800 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003801 else if (strncmp (argv[0], "su", 2) == 0)
3802 type = OSPF_SUMMARY_LSA;
3803 else if (strncmp (argv[0], "a", 1) == 0)
3804 type = OSPF_ASBR_SUMMARY_LSA;
3805 else if (strncmp (argv[0], "e", 1) == 0)
3806 type = OSPF_AS_EXTERNAL_LSA;
3807 else if (strncmp (argv[0], "se", 2) == 0)
3808 {
paul020709f2003-04-04 02:44:16 +00003809 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003810 return CMD_SUCCESS;
3811 }
3812 else if (strncmp (argv[0], "m", 1) == 0)
3813 {
paul020709f2003-04-04 02:44:16 +00003814 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003815 return CMD_SUCCESS;
3816 }
3817#ifdef HAVE_OPAQUE_LSA
3818 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3819 type = OSPF_OPAQUE_LINK_LSA;
3820 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3821 type = OSPF_OPAQUE_AREA_LSA;
3822 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3823 type = OSPF_OPAQUE_AS_LSA;
3824#endif /* HAVE_OPAQUE_LSA */
3825 else
3826 return CMD_WARNING;
3827
3828 /* `show ip ospf database LSA'. */
3829 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003830 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003831 else if (argc >= 2)
3832 {
3833 ret = inet_aton (argv[1], &id);
3834 if (!ret)
3835 return CMD_WARNING;
3836
3837 /* `show ip ospf database LSA ID'. */
3838 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003839 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003840 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3841 else if (argc == 3)
3842 {
3843 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003844 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003845 else
3846 {
3847 ret = inet_aton (argv[2], &adv_router);
3848 if (!ret)
3849 return CMD_WARNING;
3850 }
paul020709f2003-04-04 02:44:16 +00003851 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003852 }
3853 }
3854
3855 return CMD_SUCCESS;
3856}
3857
3858ALIAS (show_ip_ospf_database,
3859 show_ip_ospf_database_type_cmd,
3860 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3861 SHOW_STR
3862 IP_STR
3863 "OSPF information\n"
3864 "Database summary\n"
3865 OSPF_LSA_TYPES_DESC
3866 "LSAs in MaxAge list\n"
3867 "Self-originated link states\n")
3868
3869ALIAS (show_ip_ospf_database,
3870 show_ip_ospf_database_type_id_cmd,
3871 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3872 SHOW_STR
3873 IP_STR
3874 "OSPF information\n"
3875 "Database summary\n"
3876 OSPF_LSA_TYPES_DESC
3877 "Link State ID (as an IP address)\n")
3878
3879ALIAS (show_ip_ospf_database,
3880 show_ip_ospf_database_type_id_adv_router_cmd,
3881 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3882 SHOW_STR
3883 IP_STR
3884 "OSPF information\n"
3885 "Database summary\n"
3886 OSPF_LSA_TYPES_DESC
3887 "Link State ID (as an IP address)\n"
3888 "Advertising Router link states\n"
3889 "Advertising Router (as an IP address)\n")
3890
3891ALIAS (show_ip_ospf_database,
3892 show_ip_ospf_database_type_id_self_cmd,
3893 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3894 SHOW_STR
3895 IP_STR
3896 "OSPF information\n"
3897 "Database summary\n"
3898 OSPF_LSA_TYPES_DESC
3899 "Link State ID (as an IP address)\n"
3900 "Self-originated link states\n"
3901 "\n")
3902
3903DEFUN (show_ip_ospf_database_type_adv_router,
3904 show_ip_ospf_database_type_adv_router_cmd,
3905 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3906 SHOW_STR
3907 IP_STR
3908 "OSPF information\n"
3909 "Database summary\n"
3910 OSPF_LSA_TYPES_DESC
3911 "Advertising Router link states\n"
3912 "Advertising Router (as an IP address)\n")
3913{
paul020709f2003-04-04 02:44:16 +00003914 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003915 int type, ret;
3916 struct in_addr adv_router;
3917
paul020709f2003-04-04 02:44:16 +00003918 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003919 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003920 return CMD_SUCCESS;
3921
3922 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003923 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003924
3925 if (argc != 2)
3926 return CMD_WARNING;
3927
3928 /* Set database type to show. */
3929 if (strncmp (argv[0], "r", 1) == 0)
3930 type = OSPF_ROUTER_LSA;
3931 else if (strncmp (argv[0], "ne", 2) == 0)
3932 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003933 else if (strncmp (argv[0], "ns", 2) == 0)
3934 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003935 else if (strncmp (argv[0], "s", 1) == 0)
3936 type = OSPF_SUMMARY_LSA;
3937 else if (strncmp (argv[0], "a", 1) == 0)
3938 type = OSPF_ASBR_SUMMARY_LSA;
3939 else if (strncmp (argv[0], "e", 1) == 0)
3940 type = OSPF_AS_EXTERNAL_LSA;
3941#ifdef HAVE_OPAQUE_LSA
3942 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3943 type = OSPF_OPAQUE_LINK_LSA;
3944 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3945 type = OSPF_OPAQUE_AREA_LSA;
3946 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3947 type = OSPF_OPAQUE_AS_LSA;
3948#endif /* HAVE_OPAQUE_LSA */
3949 else
3950 return CMD_WARNING;
3951
3952 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
3953 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003954 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003955 else
3956 {
3957 ret = inet_aton (argv[1], &adv_router);
3958 if (!ret)
3959 return CMD_WARNING;
3960 }
3961
paul020709f2003-04-04 02:44:16 +00003962 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00003963
3964 return CMD_SUCCESS;
3965}
3966
3967ALIAS (show_ip_ospf_database_type_adv_router,
3968 show_ip_ospf_database_type_self_cmd,
3969 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
3970 SHOW_STR
3971 IP_STR
3972 "OSPF information\n"
3973 "Database summary\n"
3974 OSPF_LSA_TYPES_DESC
3975 "Self-originated link states\n")
3976
3977
3978DEFUN (ip_ospf_authentication_args,
3979 ip_ospf_authentication_args_addr_cmd,
3980 "ip ospf authentication (null|message-digest) A.B.C.D",
3981 "IP Information\n"
3982 "OSPF interface commands\n"
3983 "Enable authentication on this interface\n"
3984 "Use null authentication\n"
3985 "Use message-digest authentication\n"
3986 "Address of interface")
3987{
3988 struct interface *ifp;
3989 struct in_addr addr;
3990 int ret;
3991 struct ospf_if_params *params;
3992
3993 ifp = vty->index;
3994 params = IF_DEF_PARAMS (ifp);
3995
3996 if (argc == 2)
3997 {
3998 ret = inet_aton(argv[1], &addr);
3999 if (!ret)
4000 {
4001 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4002 VTY_NEWLINE);
4003 return CMD_WARNING;
4004 }
4005
4006 params = ospf_get_if_params (ifp, addr);
4007 ospf_if_update_params (ifp, addr);
4008 }
4009
4010 /* Handle null authentication */
4011 if ( argv[0][0] == 'n' )
4012 {
4013 SET_IF_PARAM (params, auth_type);
4014 params->auth_type = OSPF_AUTH_NULL;
4015 return CMD_SUCCESS;
4016 }
4017
4018 /* Handle message-digest authentication */
4019 if ( argv[0][0] == 'm' )
4020 {
4021 SET_IF_PARAM (params, auth_type);
4022 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4023 return CMD_SUCCESS;
4024 }
4025
4026 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4027 return CMD_WARNING;
4028}
4029
4030ALIAS (ip_ospf_authentication_args,
4031 ip_ospf_authentication_args_cmd,
4032 "ip ospf authentication (null|message-digest)",
4033 "IP Information\n"
4034 "OSPF interface commands\n"
4035 "Enable authentication on this interface\n"
4036 "Use null authentication\n"
4037 "Use message-digest authentication\n")
4038
4039DEFUN (ip_ospf_authentication,
4040 ip_ospf_authentication_addr_cmd,
4041 "ip ospf authentication A.B.C.D",
4042 "IP Information\n"
4043 "OSPF interface commands\n"
4044 "Enable authentication on this interface\n"
4045 "Address of interface")
4046{
4047 struct interface *ifp;
4048 struct in_addr addr;
4049 int ret;
4050 struct ospf_if_params *params;
4051
4052 ifp = vty->index;
4053 params = IF_DEF_PARAMS (ifp);
4054
4055 if (argc == 1)
4056 {
4057 ret = inet_aton(argv[1], &addr);
4058 if (!ret)
4059 {
4060 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4061 VTY_NEWLINE);
4062 return CMD_WARNING;
4063 }
4064
4065 params = ospf_get_if_params (ifp, addr);
4066 ospf_if_update_params (ifp, addr);
4067 }
4068
4069 SET_IF_PARAM (params, auth_type);
4070 params->auth_type = OSPF_AUTH_SIMPLE;
4071
4072 return CMD_SUCCESS;
4073}
4074
4075ALIAS (ip_ospf_authentication,
4076 ip_ospf_authentication_cmd,
4077 "ip ospf authentication",
4078 "IP Information\n"
4079 "OSPF interface commands\n"
4080 "Enable authentication on this interface\n")
4081
4082DEFUN (no_ip_ospf_authentication,
4083 no_ip_ospf_authentication_addr_cmd,
4084 "no ip ospf authentication A.B.C.D",
4085 NO_STR
4086 "IP Information\n"
4087 "OSPF interface commands\n"
4088 "Enable authentication on this interface\n"
4089 "Address of interface")
4090{
4091 struct interface *ifp;
4092 struct in_addr addr;
4093 int ret;
4094 struct ospf_if_params *params;
4095
4096 ifp = vty->index;
4097 params = IF_DEF_PARAMS (ifp);
4098
4099 if (argc == 1)
4100 {
4101 ret = inet_aton(argv[1], &addr);
4102 if (!ret)
4103 {
4104 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4105 VTY_NEWLINE);
4106 return CMD_WARNING;
4107 }
4108
4109 params = ospf_lookup_if_params (ifp, addr);
4110 if (params == NULL)
4111 return CMD_SUCCESS;
4112 }
4113
4114 params->auth_type = OSPF_AUTH_NOTSET;
4115 UNSET_IF_PARAM (params, auth_type);
4116
4117 if (params != IF_DEF_PARAMS (ifp))
4118 {
4119 ospf_free_if_params (ifp, addr);
4120 ospf_if_update_params (ifp, addr);
4121 }
4122
4123 return CMD_SUCCESS;
4124}
4125
4126ALIAS (no_ip_ospf_authentication,
4127 no_ip_ospf_authentication_cmd,
4128 "no ip ospf authentication",
4129 NO_STR
4130 "IP Information\n"
4131 "OSPF interface commands\n"
4132 "Enable authentication on this interface\n")
4133
4134DEFUN (ip_ospf_authentication_key,
4135 ip_ospf_authentication_key_addr_cmd,
4136 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4137 "IP Information\n"
4138 "OSPF interface commands\n"
4139 "Authentication password (key)\n"
4140 "The OSPF password (key)\n"
4141 "Address of interface")
4142{
4143 struct interface *ifp;
4144 struct in_addr addr;
4145 int ret;
4146 struct ospf_if_params *params;
4147
4148 ifp = vty->index;
4149 params = IF_DEF_PARAMS (ifp);
4150
4151 if (argc == 2)
4152 {
4153 ret = inet_aton(argv[1], &addr);
4154 if (!ret)
4155 {
4156 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4157 VTY_NEWLINE);
4158 return CMD_WARNING;
4159 }
4160
4161 params = ospf_get_if_params (ifp, addr);
4162 ospf_if_update_params (ifp, addr);
4163 }
4164
4165
4166 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004167 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004168 SET_IF_PARAM (params, auth_simple);
4169
4170 return CMD_SUCCESS;
4171}
4172
4173ALIAS (ip_ospf_authentication_key,
4174 ip_ospf_authentication_key_cmd,
4175 "ip ospf authentication-key AUTH_KEY",
4176 "IP Information\n"
4177 "OSPF interface commands\n"
4178 "Authentication password (key)\n"
4179 "The OSPF password (key)")
4180
4181ALIAS (ip_ospf_authentication_key,
4182 ospf_authentication_key_cmd,
4183 "ospf authentication-key AUTH_KEY",
4184 "OSPF interface commands\n"
4185 "Authentication password (key)\n"
4186 "The OSPF password (key)")
4187
4188DEFUN (no_ip_ospf_authentication_key,
4189 no_ip_ospf_authentication_key_addr_cmd,
4190 "no ip ospf authentication-key A.B.C.D",
4191 NO_STR
4192 "IP Information\n"
4193 "OSPF interface commands\n"
4194 "Authentication password (key)\n"
4195 "Address of interface")
4196{
4197 struct interface *ifp;
4198 struct in_addr addr;
4199 int ret;
4200 struct ospf_if_params *params;
4201
4202 ifp = vty->index;
4203 params = IF_DEF_PARAMS (ifp);
4204
4205 if (argc == 2)
4206 {
4207 ret = inet_aton(argv[1], &addr);
4208 if (!ret)
4209 {
4210 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4211 VTY_NEWLINE);
4212 return CMD_WARNING;
4213 }
4214
4215 params = ospf_lookup_if_params (ifp, addr);
4216 if (params == NULL)
4217 return CMD_SUCCESS;
4218 }
4219
4220 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4221 UNSET_IF_PARAM (params, auth_simple);
4222
4223 if (params != IF_DEF_PARAMS (ifp))
4224 {
4225 ospf_free_if_params (ifp, addr);
4226 ospf_if_update_params (ifp, addr);
4227 }
4228
4229 return CMD_SUCCESS;
4230}
4231
4232ALIAS (no_ip_ospf_authentication_key,
4233 no_ip_ospf_authentication_key_cmd,
4234 "no ip ospf authentication-key",
4235 NO_STR
4236 "IP Information\n"
4237 "OSPF interface commands\n"
4238 "Authentication password (key)\n")
4239
4240ALIAS (no_ip_ospf_authentication_key,
4241 no_ospf_authentication_key_cmd,
4242 "no ospf authentication-key",
4243 NO_STR
4244 "OSPF interface commands\n"
4245 "Authentication password (key)\n")
4246
4247DEFUN (ip_ospf_message_digest_key,
4248 ip_ospf_message_digest_key_addr_cmd,
4249 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4250 "IP Information\n"
4251 "OSPF interface commands\n"
4252 "Message digest authentication password (key)\n"
4253 "Key ID\n"
4254 "Use MD5 algorithm\n"
4255 "The OSPF password (key)"
4256 "Address of interface")
4257{
4258 struct interface *ifp;
4259 struct crypt_key *ck;
4260 u_char key_id;
4261 struct in_addr addr;
4262 int ret;
4263 struct ospf_if_params *params;
4264
4265 ifp = vty->index;
4266 params = IF_DEF_PARAMS (ifp);
4267
4268 if (argc == 3)
4269 {
4270 ret = inet_aton(argv[2], &addr);
4271 if (!ret)
4272 {
4273 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4274 VTY_NEWLINE);
4275 return CMD_WARNING;
4276 }
4277
4278 params = ospf_get_if_params (ifp, addr);
4279 ospf_if_update_params (ifp, addr);
4280 }
4281
4282 key_id = strtol (argv[0], NULL, 10);
4283 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4284 {
4285 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4286 return CMD_WARNING;
4287 }
4288
4289 ck = ospf_crypt_key_new ();
4290 ck->key_id = (u_char) key_id;
4291 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004292 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004293
4294 ospf_crypt_key_add (params->auth_crypt, ck);
4295 SET_IF_PARAM (params, auth_crypt);
4296
4297 return CMD_SUCCESS;
4298}
4299
4300ALIAS (ip_ospf_message_digest_key,
4301 ip_ospf_message_digest_key_cmd,
4302 "ip ospf message-digest-key <1-255> md5 KEY",
4303 "IP Information\n"
4304 "OSPF interface commands\n"
4305 "Message digest authentication password (key)\n"
4306 "Key ID\n"
4307 "Use MD5 algorithm\n"
4308 "The OSPF password (key)")
4309
4310ALIAS (ip_ospf_message_digest_key,
4311 ospf_message_digest_key_cmd,
4312 "ospf message-digest-key <1-255> md5 KEY",
4313 "OSPF interface commands\n"
4314 "Message digest authentication password (key)\n"
4315 "Key ID\n"
4316 "Use MD5 algorithm\n"
4317 "The OSPF password (key)")
4318
4319DEFUN (no_ip_ospf_message_digest_key,
4320 no_ip_ospf_message_digest_key_addr_cmd,
4321 "no ip ospf message-digest-key <1-255> A.B.C.D",
4322 NO_STR
4323 "IP Information\n"
4324 "OSPF interface commands\n"
4325 "Message digest authentication password (key)\n"
4326 "Key ID\n"
4327 "Address of interface")
4328{
4329 struct interface *ifp;
4330 struct crypt_key *ck;
4331 int key_id;
4332 struct in_addr addr;
4333 int ret;
4334 struct ospf_if_params *params;
4335
4336 ifp = vty->index;
4337 params = IF_DEF_PARAMS (ifp);
4338
4339 if (argc == 2)
4340 {
4341 ret = inet_aton(argv[1], &addr);
4342 if (!ret)
4343 {
4344 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4345 VTY_NEWLINE);
4346 return CMD_WARNING;
4347 }
4348
4349 params = ospf_lookup_if_params (ifp, addr);
4350 if (params == NULL)
4351 return CMD_SUCCESS;
4352 }
4353
4354 key_id = strtol (argv[0], NULL, 10);
4355 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4356 if (ck == NULL)
4357 {
4358 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4359 return CMD_WARNING;
4360 }
4361
4362 ospf_crypt_key_delete (params->auth_crypt, key_id);
4363
4364 if (params != IF_DEF_PARAMS (ifp))
4365 {
4366 ospf_free_if_params (ifp, addr);
4367 ospf_if_update_params (ifp, addr);
4368 }
4369
4370 return CMD_SUCCESS;
4371}
4372
4373ALIAS (no_ip_ospf_message_digest_key,
4374 no_ip_ospf_message_digest_key_cmd,
4375 "no ip ospf message-digest-key <1-255>",
4376 NO_STR
4377 "IP Information\n"
4378 "OSPF interface commands\n"
4379 "Message digest authentication password (key)\n"
4380 "Key ID\n")
4381
4382ALIAS (no_ip_ospf_message_digest_key,
4383 no_ospf_message_digest_key_cmd,
4384 "no ospf message-digest-key <1-255>",
4385 NO_STR
4386 "OSPF interface commands\n"
4387 "Message digest authentication password (key)\n"
4388 "Key ID\n")
4389
4390DEFUN (ip_ospf_cost,
4391 ip_ospf_cost_addr_cmd,
4392 "ip ospf cost <1-65535> A.B.C.D",
4393 "IP Information\n"
4394 "OSPF interface commands\n"
4395 "Interface cost\n"
4396 "Cost\n"
4397 "Address of interface")
4398{
4399 struct interface *ifp = vty->index;
4400 u_int32_t cost;
4401 struct in_addr addr;
4402 int ret;
4403 struct ospf_if_params *params;
4404
4405 params = IF_DEF_PARAMS (ifp);
4406
4407 cost = strtol (argv[0], NULL, 10);
4408
4409 /* cost range is <1-65535>. */
4410 if (cost < 1 || cost > 65535)
4411 {
4412 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4413 return CMD_WARNING;
4414 }
4415
4416 if (argc == 2)
4417 {
4418 ret = inet_aton(argv[1], &addr);
4419 if (!ret)
4420 {
4421 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4422 VTY_NEWLINE);
4423 return CMD_WARNING;
4424 }
4425
4426 params = ospf_get_if_params (ifp, addr);
4427 ospf_if_update_params (ifp, addr);
4428 }
4429
4430 SET_IF_PARAM (params, output_cost_cmd);
4431 params->output_cost_cmd = cost;
4432
4433 ospf_if_recalculate_output_cost (ifp);
4434
4435 return CMD_SUCCESS;
4436}
4437
4438ALIAS (ip_ospf_cost,
4439 ip_ospf_cost_cmd,
4440 "ip ospf cost <1-65535>",
4441 "IP Information\n"
4442 "OSPF interface commands\n"
4443 "Interface cost\n"
4444 "Cost")
4445
4446ALIAS (ip_ospf_cost,
4447 ospf_cost_cmd,
4448 "ospf cost <1-65535>",
4449 "OSPF interface commands\n"
4450 "Interface cost\n"
4451 "Cost")
4452
4453DEFUN (no_ip_ospf_cost,
4454 no_ip_ospf_cost_addr_cmd,
4455 "no ip ospf cost A.B.C.D",
4456 NO_STR
4457 "IP Information\n"
4458 "OSPF interface commands\n"
4459 "Interface cost\n"
4460 "Address of interface")
4461{
4462 struct interface *ifp = vty->index;
4463 struct in_addr addr;
4464 int ret;
4465 struct ospf_if_params *params;
4466
4467 ifp = vty->index;
4468 params = IF_DEF_PARAMS (ifp);
4469
4470 if (argc == 1)
4471 {
4472 ret = inet_aton(argv[0], &addr);
4473 if (!ret)
4474 {
4475 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4476 VTY_NEWLINE);
4477 return CMD_WARNING;
4478 }
4479
4480 params = ospf_lookup_if_params (ifp, addr);
4481 if (params == NULL)
4482 return CMD_SUCCESS;
4483 }
4484
4485 UNSET_IF_PARAM (params, output_cost_cmd);
4486
4487 if (params != IF_DEF_PARAMS (ifp))
4488 {
4489 ospf_free_if_params (ifp, addr);
4490 ospf_if_update_params (ifp, addr);
4491 }
4492
4493 ospf_if_recalculate_output_cost (ifp);
4494
4495 return CMD_SUCCESS;
4496}
4497
4498ALIAS (no_ip_ospf_cost,
4499 no_ip_ospf_cost_cmd,
4500 "no ip ospf cost",
4501 NO_STR
4502 "IP Information\n"
4503 "OSPF interface commands\n"
4504 "Interface cost\n")
4505
4506ALIAS (no_ip_ospf_cost,
4507 no_ospf_cost_cmd,
4508 "no ospf cost",
4509 NO_STR
4510 "OSPF interface commands\n"
4511 "Interface cost\n")
4512
4513void
4514ospf_nbr_timer_update (struct ospf_interface *oi)
4515{
4516 struct route_node *rn;
4517 struct ospf_neighbor *nbr;
4518
4519 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4520 if ((nbr = rn->info))
4521 {
4522 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4523 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4524 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4525 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4526 }
4527}
4528
4529DEFUN (ip_ospf_dead_interval,
4530 ip_ospf_dead_interval_addr_cmd,
4531 "ip ospf dead-interval <1-65535> A.B.C.D",
4532 "IP Information\n"
4533 "OSPF interface commands\n"
4534 "Interval after which a neighbor is declared dead\n"
4535 "Seconds\n"
4536 "Address of interface")
4537{
4538 struct interface *ifp = vty->index;
4539 u_int32_t seconds;
4540 struct in_addr addr;
4541 int ret;
4542 struct ospf_if_params *params;
4543 struct ospf_interface *oi;
4544 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004545 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004546
paul020709f2003-04-04 02:44:16 +00004547 ospf = ospf_lookup ();
4548
paul718e3742002-12-13 20:15:29 +00004549 params = IF_DEF_PARAMS (ifp);
4550
4551 seconds = strtol (argv[0], NULL, 10);
4552
4553 /* dead_interval range is <1-65535>. */
4554 if (seconds < 1 || seconds > 65535)
4555 {
4556 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4557 return CMD_WARNING;
4558 }
4559
4560 if (argc == 2)
4561 {
4562 ret = inet_aton(argv[1], &addr);
4563 if (!ret)
4564 {
4565 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4566 VTY_NEWLINE);
4567 return CMD_WARNING;
4568 }
4569
4570 params = ospf_get_if_params (ifp, addr);
4571 ospf_if_update_params (ifp, addr);
4572 }
4573
4574 SET_IF_PARAM (params, v_wait);
4575 params->v_wait = seconds;
4576
4577 /* Update timer values in neighbor structure. */
4578 if (argc == 2)
4579 {
paul68980082003-03-25 05:07:42 +00004580 if (ospf)
4581 {
4582 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4583 if (oi)
4584 ospf_nbr_timer_update (oi);
4585 }
paul718e3742002-12-13 20:15:29 +00004586 }
4587 else
4588 {
4589 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4590 if ((oi = rn->info))
4591 ospf_nbr_timer_update (oi);
4592 }
4593
4594 return CMD_SUCCESS;
4595}
4596
4597ALIAS (ip_ospf_dead_interval,
4598 ip_ospf_dead_interval_cmd,
4599 "ip ospf dead-interval <1-65535>",
4600 "IP Information\n"
4601 "OSPF interface commands\n"
4602 "Interval after which a neighbor is declared dead\n"
4603 "Seconds\n")
4604
4605ALIAS (ip_ospf_dead_interval,
4606 ospf_dead_interval_cmd,
4607 "ospf dead-interval <1-65535>",
4608 "OSPF interface commands\n"
4609 "Interval after which a neighbor is declared dead\n"
4610 "Seconds\n")
4611
4612DEFUN (no_ip_ospf_dead_interval,
4613 no_ip_ospf_dead_interval_addr_cmd,
4614 "no ip ospf dead-interval A.B.C.D",
4615 NO_STR
4616 "IP Information\n"
4617 "OSPF interface commands\n"
4618 "Interval after which a neighbor is declared dead\n"
4619 "Address of interface")
4620{
4621 struct interface *ifp = vty->index;
4622 struct in_addr addr;
4623 int ret;
4624 struct ospf_if_params *params;
4625 struct ospf_interface *oi;
4626 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004627 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004628
paul020709f2003-04-04 02:44:16 +00004629 ospf = ospf_lookup ();
4630
paul718e3742002-12-13 20:15:29 +00004631 ifp = vty->index;
4632 params = IF_DEF_PARAMS (ifp);
4633
4634 if (argc == 1)
4635 {
4636 ret = inet_aton(argv[0], &addr);
4637 if (!ret)
4638 {
4639 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4640 VTY_NEWLINE);
4641 return CMD_WARNING;
4642 }
4643
4644 params = ospf_lookup_if_params (ifp, addr);
4645 if (params == NULL)
4646 return CMD_SUCCESS;
4647 }
4648
4649 UNSET_IF_PARAM (params, v_wait);
4650 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4651
4652 if (params != IF_DEF_PARAMS (ifp))
4653 {
4654 ospf_free_if_params (ifp, addr);
4655 ospf_if_update_params (ifp, addr);
4656 }
4657
4658 /* Update timer values in neighbor structure. */
4659 if (argc == 1)
4660 {
paul68980082003-03-25 05:07:42 +00004661 if (ospf)
4662 {
4663 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4664 if (oi)
4665 ospf_nbr_timer_update (oi);
4666 }
paul718e3742002-12-13 20:15:29 +00004667 }
4668 else
4669 {
4670 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4671 if ((oi = rn->info))
4672 ospf_nbr_timer_update (oi);
4673 }
4674
4675 return CMD_SUCCESS;
4676}
4677
4678ALIAS (no_ip_ospf_dead_interval,
4679 no_ip_ospf_dead_interval_cmd,
4680 "no ip ospf dead-interval",
4681 NO_STR
4682 "IP Information\n"
4683 "OSPF interface commands\n"
4684 "Interval after which a neighbor is declared dead\n")
4685
4686ALIAS (no_ip_ospf_dead_interval,
4687 no_ospf_dead_interval_cmd,
4688 "no ospf dead-interval",
4689 NO_STR
4690 "OSPF interface commands\n"
4691 "Interval after which a neighbor is declared dead\n")
4692
4693DEFUN (ip_ospf_hello_interval,
4694 ip_ospf_hello_interval_addr_cmd,
4695 "ip ospf hello-interval <1-65535> A.B.C.D",
4696 "IP Information\n"
4697 "OSPF interface commands\n"
4698 "Time between HELLO packets\n"
4699 "Seconds\n"
4700 "Address of interface")
4701{
4702 struct interface *ifp = vty->index;
4703 u_int32_t seconds;
4704 struct in_addr addr;
4705 int ret;
4706 struct ospf_if_params *params;
4707
4708 params = IF_DEF_PARAMS (ifp);
4709
4710 seconds = strtol (argv[0], NULL, 10);
4711
4712 /* HelloInterval range is <1-65535>. */
4713 if (seconds < 1 || seconds > 65535)
4714 {
4715 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4716 return CMD_WARNING;
4717 }
4718
4719 if (argc == 2)
4720 {
4721 ret = inet_aton(argv[1], &addr);
4722 if (!ret)
4723 {
4724 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4725 VTY_NEWLINE);
4726 return CMD_WARNING;
4727 }
4728
4729 params = ospf_get_if_params (ifp, addr);
4730 ospf_if_update_params (ifp, addr);
4731 }
4732
4733 SET_IF_PARAM (params, v_hello);
4734 params->v_hello = seconds;
4735
4736 return CMD_SUCCESS;
4737}
4738
4739ALIAS (ip_ospf_hello_interval,
4740 ip_ospf_hello_interval_cmd,
4741 "ip ospf hello-interval <1-65535>",
4742 "IP Information\n"
4743 "OSPF interface commands\n"
4744 "Time between HELLO packets\n"
4745 "Seconds\n")
4746
4747ALIAS (ip_ospf_hello_interval,
4748 ospf_hello_interval_cmd,
4749 "ospf hello-interval <1-65535>",
4750 "OSPF interface commands\n"
4751 "Time between HELLO packets\n"
4752 "Seconds\n")
4753
4754DEFUN (no_ip_ospf_hello_interval,
4755 no_ip_ospf_hello_interval_addr_cmd,
4756 "no ip ospf hello-interval A.B.C.D",
4757 NO_STR
4758 "IP Information\n"
4759 "OSPF interface commands\n"
4760 "Time between HELLO packets\n"
4761 "Address of interface")
4762{
4763 struct interface *ifp = vty->index;
4764 struct in_addr addr;
4765 int ret;
4766 struct ospf_if_params *params;
4767
4768 ifp = vty->index;
4769 params = IF_DEF_PARAMS (ifp);
4770
4771 if (argc == 1)
4772 {
4773 ret = inet_aton(argv[0], &addr);
4774 if (!ret)
4775 {
4776 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4777 VTY_NEWLINE);
4778 return CMD_WARNING;
4779 }
4780
4781 params = ospf_lookup_if_params (ifp, addr);
4782 if (params == NULL)
4783 return CMD_SUCCESS;
4784 }
4785
4786 UNSET_IF_PARAM (params, v_hello);
4787 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4788
4789 if (params != IF_DEF_PARAMS (ifp))
4790 {
4791 ospf_free_if_params (ifp, addr);
4792 ospf_if_update_params (ifp, addr);
4793 }
4794
4795 return CMD_SUCCESS;
4796}
4797
4798ALIAS (no_ip_ospf_hello_interval,
4799 no_ip_ospf_hello_interval_cmd,
4800 "no ip ospf hello-interval",
4801 NO_STR
4802 "IP Information\n"
4803 "OSPF interface commands\n"
4804 "Time between HELLO packets\n")
4805
4806ALIAS (no_ip_ospf_hello_interval,
4807 no_ospf_hello_interval_cmd,
4808 "no ospf hello-interval",
4809 NO_STR
4810 "OSPF interface commands\n"
4811 "Time between HELLO packets\n")
4812
4813DEFUN (ip_ospf_network,
4814 ip_ospf_network_cmd,
4815 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4816 "IP Information\n"
4817 "OSPF interface commands\n"
4818 "Network type\n"
4819 "Specify OSPF broadcast multi-access network\n"
4820 "Specify OSPF NBMA network\n"
4821 "Specify OSPF point-to-multipoint network\n"
4822 "Specify OSPF point-to-point network\n")
4823{
4824 struct interface *ifp = vty->index;
4825 int old_type = IF_DEF_PARAMS (ifp)->type;
4826 struct route_node *rn;
4827
4828 if (strncmp (argv[0], "b", 1) == 0)
4829 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4830 else if (strncmp (argv[0], "n", 1) == 0)
4831 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4832 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4833 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4834 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4835 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4836
4837 if (IF_DEF_PARAMS (ifp)->type == old_type)
4838 return CMD_SUCCESS;
4839
4840 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4841
4842 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4843 {
4844 struct ospf_interface *oi = rn->info;
4845
4846 if (!oi)
4847 continue;
4848
4849 oi->type = IF_DEF_PARAMS (ifp)->type;
4850
4851 if (oi->state > ISM_Down)
4852 {
4853 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4854 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4855 }
4856 }
4857
4858 return CMD_SUCCESS;
4859}
4860
4861ALIAS (ip_ospf_network,
4862 ospf_network_cmd,
4863 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4864 "OSPF interface commands\n"
4865 "Network type\n"
4866 "Specify OSPF broadcast multi-access network\n"
4867 "Specify OSPF NBMA network\n"
4868 "Specify OSPF point-to-multipoint network\n"
4869 "Specify OSPF point-to-point network\n")
4870
4871DEFUN (no_ip_ospf_network,
4872 no_ip_ospf_network_cmd,
4873 "no ip ospf network",
4874 NO_STR
4875 "IP Information\n"
4876 "OSPF interface commands\n"
4877 "Network type\n")
4878{
4879 struct interface *ifp = vty->index;
4880 int old_type = IF_DEF_PARAMS (ifp)->type;
4881 struct route_node *rn;
4882
ajsbc18d612004-12-15 15:07:19 +00004883 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00004884
4885 if (IF_DEF_PARAMS (ifp)->type == old_type)
4886 return CMD_SUCCESS;
4887
4888 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4889 {
4890 struct ospf_interface *oi = rn->info;
4891
4892 if (!oi)
4893 continue;
4894
4895 oi->type = IF_DEF_PARAMS (ifp)->type;
4896
4897 if (oi->state > ISM_Down)
4898 {
4899 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4900 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4901 }
4902 }
4903
4904 return CMD_SUCCESS;
4905}
4906
4907ALIAS (no_ip_ospf_network,
4908 no_ospf_network_cmd,
4909 "no ospf network",
4910 NO_STR
4911 "OSPF interface commands\n"
4912 "Network type\n")
4913
4914DEFUN (ip_ospf_priority,
4915 ip_ospf_priority_addr_cmd,
4916 "ip ospf priority <0-255> A.B.C.D",
4917 "IP Information\n"
4918 "OSPF interface commands\n"
4919 "Router priority\n"
4920 "Priority\n"
4921 "Address of interface")
4922{
4923 struct interface *ifp = vty->index;
4924 u_int32_t priority;
4925 struct route_node *rn;
4926 struct in_addr addr;
4927 int ret;
4928 struct ospf_if_params *params;
4929
4930 params = IF_DEF_PARAMS (ifp);
4931
4932 priority = strtol (argv[0], NULL, 10);
4933
4934 /* Router Priority range is <0-255>. */
4935 if (priority < 0 || priority > 255)
4936 {
4937 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4938 return CMD_WARNING;
4939 }
4940
4941 if (argc == 2)
4942 {
4943 ret = inet_aton(argv[1], &addr);
4944 if (!ret)
4945 {
4946 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4947 VTY_NEWLINE);
4948 return CMD_WARNING;
4949 }
4950
4951 params = ospf_get_if_params (ifp, addr);
4952 ospf_if_update_params (ifp, addr);
4953 }
4954
4955 SET_IF_PARAM (params, priority);
4956 params->priority = priority;
4957
4958 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4959 {
4960 struct ospf_interface *oi = rn->info;
4961
4962 if (!oi)
4963 continue;
4964
4965
4966 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
4967 {
4968 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
4969 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
4970 }
4971 }
4972
4973 return CMD_SUCCESS;
4974}
4975
4976ALIAS (ip_ospf_priority,
4977 ip_ospf_priority_cmd,
4978 "ip ospf priority <0-255>",
4979 "IP Information\n"
4980 "OSPF interface commands\n"
4981 "Router priority\n"
4982 "Priority\n")
4983
4984ALIAS (ip_ospf_priority,
4985 ospf_priority_cmd,
4986 "ospf priority <0-255>",
4987 "OSPF interface commands\n"
4988 "Router priority\n"
4989 "Priority\n")
4990
4991DEFUN (no_ip_ospf_priority,
4992 no_ip_ospf_priority_addr_cmd,
4993 "no ip ospf priority A.B.C.D",
4994 NO_STR
4995 "IP Information\n"
4996 "OSPF interface commands\n"
4997 "Router priority\n"
4998 "Address of interface")
4999{
5000 struct interface *ifp = vty->index;
5001 struct route_node *rn;
5002 struct in_addr addr;
5003 int ret;
5004 struct ospf_if_params *params;
5005
5006 ifp = vty->index;
5007 params = IF_DEF_PARAMS (ifp);
5008
5009 if (argc == 1)
5010 {
5011 ret = inet_aton(argv[0], &addr);
5012 if (!ret)
5013 {
5014 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5015 VTY_NEWLINE);
5016 return CMD_WARNING;
5017 }
5018
5019 params = ospf_lookup_if_params (ifp, addr);
5020 if (params == NULL)
5021 return CMD_SUCCESS;
5022 }
5023
5024 UNSET_IF_PARAM (params, priority);
5025 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5026
5027 if (params != IF_DEF_PARAMS (ifp))
5028 {
5029 ospf_free_if_params (ifp, addr);
5030 ospf_if_update_params (ifp, addr);
5031 }
5032
5033 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5034 {
5035 struct ospf_interface *oi = rn->info;
5036
5037 if (!oi)
5038 continue;
5039
5040
5041 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5042 {
5043 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5044 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5045 }
5046 }
5047
5048 return CMD_SUCCESS;
5049}
5050
5051ALIAS (no_ip_ospf_priority,
5052 no_ip_ospf_priority_cmd,
5053 "no ip ospf priority",
5054 NO_STR
5055 "IP Information\n"
5056 "OSPF interface commands\n"
5057 "Router priority\n")
5058
5059ALIAS (no_ip_ospf_priority,
5060 no_ospf_priority_cmd,
5061 "no ospf priority",
5062 NO_STR
5063 "OSPF interface commands\n"
5064 "Router priority\n")
5065
5066DEFUN (ip_ospf_retransmit_interval,
5067 ip_ospf_retransmit_interval_addr_cmd,
5068 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5069 "IP Information\n"
5070 "OSPF interface commands\n"
5071 "Time between retransmitting lost link state advertisements\n"
5072 "Seconds\n"
5073 "Address of interface")
5074{
5075 struct interface *ifp = vty->index;
5076 u_int32_t seconds;
5077 struct in_addr addr;
5078 int ret;
5079 struct ospf_if_params *params;
5080
5081 params = IF_DEF_PARAMS (ifp);
5082 seconds = strtol (argv[0], NULL, 10);
5083
5084 /* Retransmit Interval range is <3-65535>. */
5085 if (seconds < 3 || seconds > 65535)
5086 {
5087 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5088 return CMD_WARNING;
5089 }
5090
5091
5092 if (argc == 2)
5093 {
5094 ret = inet_aton(argv[1], &addr);
5095 if (!ret)
5096 {
5097 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5098 VTY_NEWLINE);
5099 return CMD_WARNING;
5100 }
5101
5102 params = ospf_get_if_params (ifp, addr);
5103 ospf_if_update_params (ifp, addr);
5104 }
5105
5106 SET_IF_PARAM (params, retransmit_interval);
5107 params->retransmit_interval = seconds;
5108
5109 return CMD_SUCCESS;
5110}
5111
5112ALIAS (ip_ospf_retransmit_interval,
5113 ip_ospf_retransmit_interval_cmd,
5114 "ip ospf retransmit-interval <3-65535>",
5115 "IP Information\n"
5116 "OSPF interface commands\n"
5117 "Time between retransmitting lost link state advertisements\n"
5118 "Seconds\n")
5119
5120ALIAS (ip_ospf_retransmit_interval,
5121 ospf_retransmit_interval_cmd,
5122 "ospf retransmit-interval <3-65535>",
5123 "OSPF interface commands\n"
5124 "Time between retransmitting lost link state advertisements\n"
5125 "Seconds\n")
5126
5127DEFUN (no_ip_ospf_retransmit_interval,
5128 no_ip_ospf_retransmit_interval_addr_cmd,
5129 "no ip ospf retransmit-interval A.B.C.D",
5130 NO_STR
5131 "IP Information\n"
5132 "OSPF interface commands\n"
5133 "Time between retransmitting lost link state advertisements\n"
5134 "Address of interface")
5135{
5136 struct interface *ifp = vty->index;
5137 struct in_addr addr;
5138 int ret;
5139 struct ospf_if_params *params;
5140
5141 ifp = vty->index;
5142 params = IF_DEF_PARAMS (ifp);
5143
5144 if (argc == 1)
5145 {
5146 ret = inet_aton(argv[0], &addr);
5147 if (!ret)
5148 {
5149 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5150 VTY_NEWLINE);
5151 return CMD_WARNING;
5152 }
5153
5154 params = ospf_lookup_if_params (ifp, addr);
5155 if (params == NULL)
5156 return CMD_SUCCESS;
5157 }
5158
5159 UNSET_IF_PARAM (params, retransmit_interval);
5160 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5161
5162 if (params != IF_DEF_PARAMS (ifp))
5163 {
5164 ospf_free_if_params (ifp, addr);
5165 ospf_if_update_params (ifp, addr);
5166 }
5167
5168 return CMD_SUCCESS;
5169}
5170
5171ALIAS (no_ip_ospf_retransmit_interval,
5172 no_ip_ospf_retransmit_interval_cmd,
5173 "no ip ospf retransmit-interval",
5174 NO_STR
5175 "IP Information\n"
5176 "OSPF interface commands\n"
5177 "Time between retransmitting lost link state advertisements\n")
5178
5179ALIAS (no_ip_ospf_retransmit_interval,
5180 no_ospf_retransmit_interval_cmd,
5181 "no ospf retransmit-interval",
5182 NO_STR
5183 "OSPF interface commands\n"
5184 "Time between retransmitting lost link state advertisements\n")
5185
5186DEFUN (ip_ospf_transmit_delay,
5187 ip_ospf_transmit_delay_addr_cmd,
5188 "ip ospf transmit-delay <1-65535> A.B.C.D",
5189 "IP Information\n"
5190 "OSPF interface commands\n"
5191 "Link state transmit delay\n"
5192 "Seconds\n"
5193 "Address of interface")
5194{
5195 struct interface *ifp = vty->index;
5196 u_int32_t seconds;
5197 struct in_addr addr;
5198 int ret;
5199 struct ospf_if_params *params;
5200
5201 params = IF_DEF_PARAMS (ifp);
5202 seconds = strtol (argv[0], NULL, 10);
5203
5204 /* Transmit Delay range is <1-65535>. */
5205 if (seconds < 1 || seconds > 65535)
5206 {
5207 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5208 return CMD_WARNING;
5209 }
5210
5211 if (argc == 2)
5212 {
5213 ret = inet_aton(argv[1], &addr);
5214 if (!ret)
5215 {
5216 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5217 VTY_NEWLINE);
5218 return CMD_WARNING;
5219 }
5220
5221 params = ospf_get_if_params (ifp, addr);
5222 ospf_if_update_params (ifp, addr);
5223 }
5224
5225 SET_IF_PARAM (params, transmit_delay);
5226 params->transmit_delay = seconds;
5227
5228 return CMD_SUCCESS;
5229}
5230
5231ALIAS (ip_ospf_transmit_delay,
5232 ip_ospf_transmit_delay_cmd,
5233 "ip ospf transmit-delay <1-65535>",
5234 "IP Information\n"
5235 "OSPF interface commands\n"
5236 "Link state transmit delay\n"
5237 "Seconds\n")
5238
5239ALIAS (ip_ospf_transmit_delay,
5240 ospf_transmit_delay_cmd,
5241 "ospf transmit-delay <1-65535>",
5242 "OSPF interface commands\n"
5243 "Link state transmit delay\n"
5244 "Seconds\n")
5245
5246DEFUN (no_ip_ospf_transmit_delay,
5247 no_ip_ospf_transmit_delay_addr_cmd,
5248 "no ip ospf transmit-delay A.B.C.D",
5249 NO_STR
5250 "IP Information\n"
5251 "OSPF interface commands\n"
5252 "Link state transmit delay\n"
5253 "Address of interface")
5254{
5255 struct interface *ifp = vty->index;
5256 struct in_addr addr;
5257 int ret;
5258 struct ospf_if_params *params;
5259
5260 ifp = vty->index;
5261 params = IF_DEF_PARAMS (ifp);
5262
5263 if (argc == 1)
5264 {
5265 ret = inet_aton(argv[0], &addr);
5266 if (!ret)
5267 {
5268 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5269 VTY_NEWLINE);
5270 return CMD_WARNING;
5271 }
5272
5273 params = ospf_lookup_if_params (ifp, addr);
5274 if (params == NULL)
5275 return CMD_SUCCESS;
5276 }
5277
5278 UNSET_IF_PARAM (params, transmit_delay);
5279 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5280
5281 if (params != IF_DEF_PARAMS (ifp))
5282 {
5283 ospf_free_if_params (ifp, addr);
5284 ospf_if_update_params (ifp, addr);
5285 }
5286
5287 return CMD_SUCCESS;
5288}
5289
5290ALIAS (no_ip_ospf_transmit_delay,
5291 no_ip_ospf_transmit_delay_cmd,
5292 "no ip ospf transmit-delay",
5293 NO_STR
5294 "IP Information\n"
5295 "OSPF interface commands\n"
5296 "Link state transmit delay\n")
5297
5298ALIAS (no_ip_ospf_transmit_delay,
5299 no_ospf_transmit_delay_cmd,
5300 "no ospf transmit-delay",
5301 NO_STR
5302 "OSPF interface commands\n"
5303 "Link state transmit delay\n")
5304
5305
5306DEFUN (ospf_redistribute_source_metric_type,
5307 ospf_redistribute_source_metric_type_routemap_cmd,
5308 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5309 "Redistribute information from another routing protocol\n"
5310 "Kernel routes\n"
5311 "Connected\n"
5312 "Static routes\n"
5313 "Routing Information Protocol (RIP)\n"
5314 "Border Gateway Protocol (BGP)\n"
5315 "Metric for redistributed routes\n"
5316 "OSPF default metric\n"
5317 "OSPF exterior metric type for redistributed routes\n"
5318 "Set OSPF External Type 1 metrics\n"
5319 "Set OSPF External Type 2 metrics\n"
5320 "Route map reference\n"
5321 "Pointer to route-map entries\n")
5322{
paul020709f2003-04-04 02:44:16 +00005323 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005324 int source;
5325 int type = -1;
5326 int metric = -1;
5327
5328 /* Get distribute source. */
5329 if (!str2distribute_source (argv[0], &source))
5330 return CMD_WARNING;
5331
5332 /* Get metric value. */
5333 if (argc >= 2)
5334 if (!str2metric (argv[1], &metric))
5335 return CMD_WARNING;
5336
5337 /* Get metric type. */
5338 if (argc >= 3)
5339 if (!str2metric_type (argv[2], &type))
5340 return CMD_WARNING;
5341
5342 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005343 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005344 else
paul020709f2003-04-04 02:44:16 +00005345 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005346
paul020709f2003-04-04 02:44:16 +00005347 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005348}
5349
5350ALIAS (ospf_redistribute_source_metric_type,
5351 ospf_redistribute_source_metric_type_cmd,
5352 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5353 "Redistribute information from another routing protocol\n"
5354 "Kernel routes\n"
5355 "Connected\n"
5356 "Static routes\n"
5357 "Routing Information Protocol (RIP)\n"
5358 "Border Gateway Protocol (BGP)\n"
5359 "Metric for redistributed routes\n"
5360 "OSPF default metric\n"
5361 "OSPF exterior metric type for redistributed routes\n"
5362 "Set OSPF External Type 1 metrics\n"
5363 "Set OSPF External Type 2 metrics\n")
5364
5365ALIAS (ospf_redistribute_source_metric_type,
5366 ospf_redistribute_source_metric_cmd,
5367 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5368 "Redistribute information from another routing protocol\n"
5369 "Kernel routes\n"
5370 "Connected\n"
5371 "Static routes\n"
5372 "Routing Information Protocol (RIP)\n"
5373 "Border Gateway Protocol (BGP)\n"
5374 "Metric for redistributed routes\n"
5375 "OSPF default metric\n")
5376
5377DEFUN (ospf_redistribute_source_type_metric,
5378 ospf_redistribute_source_type_metric_routemap_cmd,
5379 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5380 "Redistribute information from another routing protocol\n"
5381 "Kernel routes\n"
5382 "Connected\n"
5383 "Static routes\n"
5384 "Routing Information Protocol (RIP)\n"
5385 "Border Gateway Protocol (BGP)\n"
5386 "OSPF exterior metric type for redistributed routes\n"
5387 "Set OSPF External Type 1 metrics\n"
5388 "Set OSPF External Type 2 metrics\n"
5389 "Metric for redistributed routes\n"
5390 "OSPF default metric\n"
5391 "Route map reference\n"
5392 "Pointer to route-map entries\n")
5393{
paul020709f2003-04-04 02:44:16 +00005394 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005395 int source;
5396 int type = -1;
5397 int metric = -1;
5398
5399 /* Get distribute source. */
5400 if (!str2distribute_source (argv[0], &source))
5401 return CMD_WARNING;
5402
5403 /* Get metric value. */
5404 if (argc >= 2)
5405 if (!str2metric_type (argv[1], &type))
5406 return CMD_WARNING;
5407
5408 /* Get metric type. */
5409 if (argc >= 3)
5410 if (!str2metric (argv[2], &metric))
5411 return CMD_WARNING;
5412
5413 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005414 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005415 else
paul020709f2003-04-04 02:44:16 +00005416 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005417
paul020709f2003-04-04 02:44:16 +00005418 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005419}
5420
5421ALIAS (ospf_redistribute_source_type_metric,
5422 ospf_redistribute_source_type_metric_cmd,
5423 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5424 "Redistribute information from another routing protocol\n"
5425 "Kernel routes\n"
5426 "Connected\n"
5427 "Static routes\n"
5428 "Routing Information Protocol (RIP)\n"
5429 "Border Gateway Protocol (BGP)\n"
5430 "OSPF exterior metric type for redistributed routes\n"
5431 "Set OSPF External Type 1 metrics\n"
5432 "Set OSPF External Type 2 metrics\n"
5433 "Metric for redistributed routes\n"
5434 "OSPF default metric\n")
5435
5436ALIAS (ospf_redistribute_source_type_metric,
5437 ospf_redistribute_source_type_cmd,
5438 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5439 "Redistribute information from another routing protocol\n"
5440 "Kernel routes\n"
5441 "Connected\n"
5442 "Static routes\n"
5443 "Routing Information Protocol (RIP)\n"
5444 "Border Gateway Protocol (BGP)\n"
5445 "OSPF exterior metric type for redistributed routes\n"
5446 "Set OSPF External Type 1 metrics\n"
5447 "Set OSPF External Type 2 metrics\n")
5448
5449ALIAS (ospf_redistribute_source_type_metric,
5450 ospf_redistribute_source_cmd,
5451 "redistribute (kernel|connected|static|rip|bgp)",
5452 "Redistribute information from another routing protocol\n"
5453 "Kernel routes\n"
5454 "Connected\n"
5455 "Static routes\n"
5456 "Routing Information Protocol (RIP)\n"
5457 "Border Gateway Protocol (BGP)\n")
5458
5459DEFUN (ospf_redistribute_source_metric_routemap,
5460 ospf_redistribute_source_metric_routemap_cmd,
5461 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5462 "Redistribute information from another routing protocol\n"
5463 "Kernel routes\n"
5464 "Connected\n"
5465 "Static routes\n"
5466 "Routing Information Protocol (RIP)\n"
5467 "Border Gateway Protocol (BGP)\n"
5468 "Metric for redistributed routes\n"
5469 "OSPF default metric\n"
5470 "Route map reference\n"
5471 "Pointer to route-map entries\n")
5472{
paul020709f2003-04-04 02:44:16 +00005473 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005474 int source;
5475 int metric = -1;
5476
5477 /* Get distribute source. */
5478 if (!str2distribute_source (argv[0], &source))
5479 return CMD_WARNING;
5480
5481 /* Get metric value. */
5482 if (argc >= 2)
5483 if (!str2metric (argv[1], &metric))
5484 return CMD_WARNING;
5485
5486 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005487 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005488 else
paul020709f2003-04-04 02:44:16 +00005489 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005490
paul020709f2003-04-04 02:44:16 +00005491 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005492}
5493
5494DEFUN (ospf_redistribute_source_type_routemap,
5495 ospf_redistribute_source_type_routemap_cmd,
5496 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5497 "Redistribute information from another routing protocol\n"
5498 "Kernel routes\n"
5499 "Connected\n"
5500 "Static routes\n"
5501 "Routing Information Protocol (RIP)\n"
5502 "Border Gateway Protocol (BGP)\n"
5503 "OSPF exterior metric type for redistributed routes\n"
5504 "Set OSPF External Type 1 metrics\n"
5505 "Set OSPF External Type 2 metrics\n"
5506 "Route map reference\n"
5507 "Pointer to route-map entries\n")
5508{
paul020709f2003-04-04 02:44:16 +00005509 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005510 int source;
5511 int type = -1;
5512
5513 /* Get distribute source. */
5514 if (!str2distribute_source (argv[0], &source))
5515 return CMD_WARNING;
5516
5517 /* Get metric value. */
5518 if (argc >= 2)
5519 if (!str2metric_type (argv[1], &type))
5520 return CMD_WARNING;
5521
5522 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005523 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005524 else
paul020709f2003-04-04 02:44:16 +00005525 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005526
paul020709f2003-04-04 02:44:16 +00005527 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005528}
5529
5530DEFUN (ospf_redistribute_source_routemap,
5531 ospf_redistribute_source_routemap_cmd,
5532 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5533 "Redistribute information from another routing protocol\n"
5534 "Kernel routes\n"
5535 "Connected\n"
5536 "Static routes\n"
5537 "Routing Information Protocol (RIP)\n"
5538 "Border Gateway Protocol (BGP)\n"
5539 "Route map reference\n"
5540 "Pointer to route-map entries\n")
5541{
paul020709f2003-04-04 02:44:16 +00005542 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005543 int source;
5544
5545 /* Get distribute source. */
5546 if (!str2distribute_source (argv[0], &source))
5547 return CMD_WARNING;
5548
5549 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005550 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005551 else
paul020709f2003-04-04 02:44:16 +00005552 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005553
paul020709f2003-04-04 02:44:16 +00005554 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005555}
5556
5557DEFUN (no_ospf_redistribute_source,
5558 no_ospf_redistribute_source_cmd,
5559 "no redistribute (kernel|connected|static|rip|bgp)",
5560 NO_STR
5561 "Redistribute information from another routing protocol\n"
5562 "Kernel routes\n"
5563 "Connected\n"
5564 "Static routes\n"
5565 "Routing Information Protocol (RIP)\n"
5566 "Border Gateway Protocol (BGP)\n")
5567{
paul020709f2003-04-04 02:44:16 +00005568 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005569 int source;
5570
5571 if (!str2distribute_source (argv[0], &source))
5572 return CMD_WARNING;
5573
paul020709f2003-04-04 02:44:16 +00005574 ospf_routemap_unset (ospf, source);
5575 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005576}
5577
5578DEFUN (ospf_distribute_list_out,
5579 ospf_distribute_list_out_cmd,
5580 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5581 "Filter networks in routing updates\n"
5582 "Access-list name\n"
5583 OUT_STR
5584 "Kernel routes\n"
5585 "Connected\n"
5586 "Static routes\n"
5587 "Routing Information Protocol (RIP)\n"
5588 "Border Gateway Protocol (BGP)\n")
5589{
paul68980082003-03-25 05:07:42 +00005590 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005591 int source;
5592
5593 /* Get distribute source. */
5594 if (!str2distribute_source (argv[1], &source))
5595 return CMD_WARNING;
5596
paul68980082003-03-25 05:07:42 +00005597 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005598}
5599
5600DEFUN (no_ospf_distribute_list_out,
5601 no_ospf_distribute_list_out_cmd,
5602 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5603 NO_STR
5604 "Filter networks in routing updates\n"
5605 "Access-list name\n"
5606 OUT_STR
5607 "Kernel routes\n"
5608 "Connected\n"
5609 "Static routes\n"
5610 "Routing Information Protocol (RIP)\n"
5611 "Border Gateway Protocol (BGP)\n")
5612{
paul68980082003-03-25 05:07:42 +00005613 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005614 int source;
5615
5616 if (!str2distribute_source (argv[1], &source))
5617 return CMD_WARNING;
5618
paul68980082003-03-25 05:07:42 +00005619 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005620}
5621
5622/* Default information originate. */
5623DEFUN (ospf_default_information_originate_metric_type_routemap,
5624 ospf_default_information_originate_metric_type_routemap_cmd,
5625 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5626 "Control distribution of default information\n"
5627 "Distribute a default route\n"
5628 "OSPF default metric\n"
5629 "OSPF metric\n"
5630 "OSPF metric type for default routes\n"
5631 "Set OSPF External Type 1 metrics\n"
5632 "Set OSPF External Type 2 metrics\n"
5633 "Route map reference\n"
5634 "Pointer to route-map entries\n")
5635{
paul020709f2003-04-04 02:44:16 +00005636 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005637 int type = -1;
5638 int metric = -1;
5639
5640 /* Get metric value. */
5641 if (argc >= 1)
5642 if (!str2metric (argv[0], &metric))
5643 return CMD_WARNING;
5644
5645 /* Get metric type. */
5646 if (argc >= 2)
5647 if (!str2metric_type (argv[1], &type))
5648 return CMD_WARNING;
5649
5650 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005651 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005652 else
paul020709f2003-04-04 02:44:16 +00005653 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005654
paul020709f2003-04-04 02:44:16 +00005655 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5656 type, metric);
paul718e3742002-12-13 20:15:29 +00005657}
5658
5659ALIAS (ospf_default_information_originate_metric_type_routemap,
5660 ospf_default_information_originate_metric_type_cmd,
5661 "default-information originate metric <0-16777214> metric-type (1|2)",
5662 "Control distribution of default information\n"
5663 "Distribute a default route\n"
5664 "OSPF default metric\n"
5665 "OSPF metric\n"
5666 "OSPF metric type for default routes\n"
5667 "Set OSPF External Type 1 metrics\n"
5668 "Set OSPF External Type 2 metrics\n")
5669
5670ALIAS (ospf_default_information_originate_metric_type_routemap,
5671 ospf_default_information_originate_metric_cmd,
5672 "default-information originate metric <0-16777214>",
5673 "Control distribution of default information\n"
5674 "Distribute a default route\n"
5675 "OSPF default metric\n"
5676 "OSPF metric\n")
5677
5678ALIAS (ospf_default_information_originate_metric_type_routemap,
5679 ospf_default_information_originate_cmd,
5680 "default-information originate",
5681 "Control distribution of default information\n"
5682 "Distribute a default route\n")
5683
5684/* Default information originate. */
5685DEFUN (ospf_default_information_originate_metric_routemap,
5686 ospf_default_information_originate_metric_routemap_cmd,
5687 "default-information originate metric <0-16777214> route-map WORD",
5688 "Control distribution of default information\n"
5689 "Distribute a default route\n"
5690 "OSPF default metric\n"
5691 "OSPF metric\n"
5692 "Route map reference\n"
5693 "Pointer to route-map entries\n")
5694{
paul020709f2003-04-04 02:44:16 +00005695 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005696 int metric = -1;
5697
5698 /* Get metric value. */
5699 if (argc >= 1)
5700 if (!str2metric (argv[0], &metric))
5701 return CMD_WARNING;
5702
5703 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005704 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005705 else
paul020709f2003-04-04 02:44:16 +00005706 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005707
paul020709f2003-04-04 02:44:16 +00005708 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5709 -1, metric);
paul718e3742002-12-13 20:15:29 +00005710}
5711
5712/* Default information originate. */
5713DEFUN (ospf_default_information_originate_routemap,
5714 ospf_default_information_originate_routemap_cmd,
5715 "default-information originate route-map WORD",
5716 "Control distribution of default information\n"
5717 "Distribute a default route\n"
5718 "Route map reference\n"
5719 "Pointer to route-map entries\n")
5720{
paul020709f2003-04-04 02:44:16 +00005721 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005722
paul020709f2003-04-04 02:44:16 +00005723 if (argc == 1)
5724 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5725 else
5726 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5727
5728 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005729}
5730
5731DEFUN (ospf_default_information_originate_type_metric_routemap,
5732 ospf_default_information_originate_type_metric_routemap_cmd,
5733 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5734 "Control distribution of default information\n"
5735 "Distribute a default route\n"
5736 "OSPF metric type for default routes\n"
5737 "Set OSPF External Type 1 metrics\n"
5738 "Set OSPF External Type 2 metrics\n"
5739 "OSPF default metric\n"
5740 "OSPF metric\n"
5741 "Route map reference\n"
5742 "Pointer to route-map entries\n")
5743{
paul020709f2003-04-04 02:44:16 +00005744 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005745 int type = -1;
5746 int metric = -1;
5747
5748 /* Get metric type. */
5749 if (argc >= 1)
5750 if (!str2metric_type (argv[0], &type))
5751 return CMD_WARNING;
5752
5753 /* Get metric value. */
5754 if (argc >= 2)
5755 if (!str2metric (argv[1], &metric))
5756 return CMD_WARNING;
5757
5758 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005759 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005760 else
paul020709f2003-04-04 02:44:16 +00005761 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005762
paul020709f2003-04-04 02:44:16 +00005763 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5764 type, metric);
paul718e3742002-12-13 20:15:29 +00005765}
5766
5767ALIAS (ospf_default_information_originate_type_metric_routemap,
5768 ospf_default_information_originate_type_metric_cmd,
5769 "default-information originate metric-type (1|2) metric <0-16777214>",
5770 "Control distribution of default information\n"
5771 "Distribute a default route\n"
5772 "OSPF metric type for default routes\n"
5773 "Set OSPF External Type 1 metrics\n"
5774 "Set OSPF External Type 2 metrics\n"
5775 "OSPF default metric\n"
5776 "OSPF metric\n")
5777
5778ALIAS (ospf_default_information_originate_type_metric_routemap,
5779 ospf_default_information_originate_type_cmd,
5780 "default-information originate metric-type (1|2)",
5781 "Control distribution of default information\n"
5782 "Distribute a default route\n"
5783 "OSPF metric type for default routes\n"
5784 "Set OSPF External Type 1 metrics\n"
5785 "Set OSPF External Type 2 metrics\n")
5786
5787DEFUN (ospf_default_information_originate_type_routemap,
5788 ospf_default_information_originate_type_routemap_cmd,
5789 "default-information originate metric-type (1|2) route-map WORD",
5790 "Control distribution of default information\n"
5791 "Distribute a default route\n"
5792 "OSPF metric type for default routes\n"
5793 "Set OSPF External Type 1 metrics\n"
5794 "Set OSPF External Type 2 metrics\n"
5795 "Route map reference\n"
5796 "Pointer to route-map entries\n")
5797{
paul020709f2003-04-04 02:44:16 +00005798 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005799 int type = -1;
5800
5801 /* Get metric type. */
5802 if (argc >= 1)
5803 if (!str2metric_type (argv[0], &type))
5804 return CMD_WARNING;
5805
5806 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005807 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005808 else
paul020709f2003-04-04 02:44:16 +00005809 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005810
paul020709f2003-04-04 02:44:16 +00005811 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5812 type, -1);
paul718e3742002-12-13 20:15:29 +00005813}
5814
5815DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5816 ospf_default_information_originate_always_metric_type_routemap_cmd,
5817 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5818 "Control distribution of default information\n"
5819 "Distribute a default route\n"
5820 "Always advertise default route\n"
5821 "OSPF default metric\n"
5822 "OSPF metric\n"
5823 "OSPF metric type for default routes\n"
5824 "Set OSPF External Type 1 metrics\n"
5825 "Set OSPF External Type 2 metrics\n"
5826 "Route map reference\n"
5827 "Pointer to route-map entries\n")
5828{
paul020709f2003-04-04 02:44:16 +00005829 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005830 int type = -1;
5831 int metric = -1;
5832
5833 /* Get metric value. */
5834 if (argc >= 1)
5835 if (!str2metric (argv[0], &metric))
5836 return CMD_WARNING;
5837
5838 /* Get metric type. */
5839 if (argc >= 2)
5840 if (!str2metric_type (argv[1], &type))
5841 return CMD_WARNING;
5842
5843 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005844 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005845 else
paul020709f2003-04-04 02:44:16 +00005846 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005847
paul020709f2003-04-04 02:44:16 +00005848 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005849 type, metric);
5850}
5851
5852ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5853 ospf_default_information_originate_always_metric_type_cmd,
5854 "default-information originate always metric <0-16777214> metric-type (1|2)",
5855 "Control distribution of default information\n"
5856 "Distribute a default route\n"
5857 "Always advertise default route\n"
5858 "OSPF default metric\n"
5859 "OSPF metric\n"
5860 "OSPF metric type for default routes\n"
5861 "Set OSPF External Type 1 metrics\n"
5862 "Set OSPF External Type 2 metrics\n")
5863
5864ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5865 ospf_default_information_originate_always_metric_cmd,
5866 "default-information originate always metric <0-16777214>",
5867 "Control distribution of default information\n"
5868 "Distribute a default route\n"
5869 "Always advertise default route\n"
5870 "OSPF default metric\n"
5871 "OSPF metric\n"
5872 "OSPF metric type for default routes\n")
5873
5874ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5875 ospf_default_information_originate_always_cmd,
5876 "default-information originate always",
5877 "Control distribution of default information\n"
5878 "Distribute a default route\n"
5879 "Always advertise default route\n")
5880
5881DEFUN (ospf_default_information_originate_always_metric_routemap,
5882 ospf_default_information_originate_always_metric_routemap_cmd,
5883 "default-information originate always metric <0-16777214> route-map WORD",
5884 "Control distribution of default information\n"
5885 "Distribute a default route\n"
5886 "Always advertise default route\n"
5887 "OSPF default metric\n"
5888 "OSPF metric\n"
5889 "Route map reference\n"
5890 "Pointer to route-map entries\n")
5891{
paul020709f2003-04-04 02:44:16 +00005892 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005893 int metric = -1;
5894
5895 /* Get metric value. */
5896 if (argc >= 1)
5897 if (!str2metric (argv[0], &metric))
5898 return CMD_WARNING;
5899
5900 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005901 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005902 else
paul020709f2003-04-04 02:44:16 +00005903 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005904
paul020709f2003-04-04 02:44:16 +00005905 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5906 -1, metric);
paul718e3742002-12-13 20:15:29 +00005907}
5908
5909DEFUN (ospf_default_information_originate_always_routemap,
5910 ospf_default_information_originate_always_routemap_cmd,
5911 "default-information originate always route-map WORD",
5912 "Control distribution of default information\n"
5913 "Distribute a default route\n"
5914 "Always advertise default route\n"
5915 "Route map reference\n"
5916 "Pointer to route-map entries\n")
5917{
paul020709f2003-04-04 02:44:16 +00005918 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005919
paul020709f2003-04-04 02:44:16 +00005920 if (argc == 1)
5921 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5922 else
5923 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5924
5925 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005926}
5927
5928DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5929 ospf_default_information_originate_always_type_metric_routemap_cmd,
5930 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5931 "Control distribution of default information\n"
5932 "Distribute a default route\n"
5933 "Always advertise default route\n"
5934 "OSPF metric type for default routes\n"
5935 "Set OSPF External Type 1 metrics\n"
5936 "Set OSPF External Type 2 metrics\n"
5937 "OSPF default metric\n"
5938 "OSPF metric\n"
5939 "Route map reference\n"
5940 "Pointer to route-map entries\n")
5941{
paul020709f2003-04-04 02:44:16 +00005942 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005943 int type = -1;
5944 int metric = -1;
5945
5946 /* Get metric type. */
5947 if (argc >= 1)
5948 if (!str2metric_type (argv[0], &type))
5949 return CMD_WARNING;
5950
5951 /* Get metric value. */
5952 if (argc >= 2)
5953 if (!str2metric (argv[1], &metric))
5954 return CMD_WARNING;
5955
5956 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005957 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005958 else
paul020709f2003-04-04 02:44:16 +00005959 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005960
paul020709f2003-04-04 02:44:16 +00005961 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005962 type, metric);
5963}
5964
5965ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5966 ospf_default_information_originate_always_type_metric_cmd,
5967 "default-information originate always metric-type (1|2) metric <0-16777214>",
5968 "Control distribution of default information\n"
5969 "Distribute a default route\n"
5970 "Always advertise default route\n"
5971 "OSPF metric type for default routes\n"
5972 "Set OSPF External Type 1 metrics\n"
5973 "Set OSPF External Type 2 metrics\n"
5974 "OSPF default metric\n"
5975 "OSPF metric\n")
5976
5977ALIAS (ospf_default_information_originate_always_type_metric_routemap,
5978 ospf_default_information_originate_always_type_cmd,
5979 "default-information originate always metric-type (1|2)",
5980 "Control distribution of default information\n"
5981 "Distribute a default route\n"
5982 "Always advertise default route\n"
5983 "OSPF metric type for default routes\n"
5984 "Set OSPF External Type 1 metrics\n"
5985 "Set OSPF External Type 2 metrics\n")
5986
5987DEFUN (ospf_default_information_originate_always_type_routemap,
5988 ospf_default_information_originate_always_type_routemap_cmd,
5989 "default-information originate always metric-type (1|2) route-map WORD",
5990 "Control distribution of default information\n"
5991 "Distribute a default route\n"
5992 "Always advertise default route\n"
5993 "OSPF metric type for default routes\n"
5994 "Set OSPF External Type 1 metrics\n"
5995 "Set OSPF External Type 2 metrics\n"
5996 "Route map reference\n"
5997 "Pointer to route-map entries\n")
5998{
paul020709f2003-04-04 02:44:16 +00005999 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006000 int type = -1;
6001
6002 /* Get metric type. */
6003 if (argc >= 1)
6004 if (!str2metric_type (argv[0], &type))
6005 return CMD_WARNING;
6006
6007 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006008 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006009 else
paul020709f2003-04-04 02:44:16 +00006010 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006011
paul020709f2003-04-04 02:44:16 +00006012 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006013 type, -1);
6014}
6015
6016DEFUN (no_ospf_default_information_originate,
6017 no_ospf_default_information_originate_cmd,
6018 "no default-information originate",
6019 NO_STR
6020 "Control distribution of default information\n"
6021 "Distribute a default route\n")
6022{
paul68980082003-03-25 05:07:42 +00006023 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006024 struct prefix_ipv4 p;
6025 struct in_addr nexthop;
6026
6027 p.family = AF_INET;
6028 p.prefix.s_addr = 0;
6029 p.prefixlen = 0;
6030
paul68980082003-03-25 05:07:42 +00006031 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
paul718e3742002-12-13 20:15:29 +00006032
6033 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6034 ospf_external_info_delete (DEFAULT_ROUTE, p);
6035 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6036 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6037 }
6038
paul020709f2003-04-04 02:44:16 +00006039 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6040 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006041}
6042
6043DEFUN (ospf_default_metric,
6044 ospf_default_metric_cmd,
6045 "default-metric <0-16777214>",
6046 "Set metric of redistributed routes\n"
6047 "Default metric\n")
6048{
paul68980082003-03-25 05:07:42 +00006049 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006050 int metric = -1;
6051
6052 if (!str2metric (argv[0], &metric))
6053 return CMD_WARNING;
6054
paul68980082003-03-25 05:07:42 +00006055 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006056
6057 return CMD_SUCCESS;
6058}
6059
6060DEFUN (no_ospf_default_metric,
6061 no_ospf_default_metric_cmd,
6062 "no default-metric",
6063 NO_STR
6064 "Set metric of redistributed routes\n")
6065{
paul68980082003-03-25 05:07:42 +00006066 struct ospf *ospf = vty->index;
6067
6068 ospf->default_metric = -1;
6069
paul718e3742002-12-13 20:15:29 +00006070 return CMD_SUCCESS;
6071}
6072
6073ALIAS (no_ospf_default_metric,
6074 no_ospf_default_metric_val_cmd,
6075 "no default-metric <0-16777214>",
6076 NO_STR
6077 "Set metric of redistributed routes\n"
6078 "Default metric\n")
6079
6080DEFUN (ospf_distance,
6081 ospf_distance_cmd,
6082 "distance <1-255>",
6083 "Define an administrative distance\n"
6084 "OSPF Administrative distance\n")
6085{
paul68980082003-03-25 05:07:42 +00006086 struct ospf *ospf = vty->index;
6087
6088 ospf->distance_all = atoi (argv[0]);
6089
paul718e3742002-12-13 20:15:29 +00006090 return CMD_SUCCESS;
6091}
6092
6093DEFUN (no_ospf_distance,
6094 no_ospf_distance_cmd,
6095 "no distance <1-255>",
6096 NO_STR
6097 "Define an administrative distance\n"
6098 "OSPF Administrative distance\n")
6099{
paul68980082003-03-25 05:07:42 +00006100 struct ospf *ospf = vty->index;
6101
6102 ospf->distance_all = 0;
6103
paul718e3742002-12-13 20:15:29 +00006104 return CMD_SUCCESS;
6105}
6106
6107DEFUN (no_ospf_distance_ospf,
6108 no_ospf_distance_ospf_cmd,
6109 "no distance ospf",
6110 NO_STR
6111 "Define an administrative distance\n"
6112 "OSPF Administrative distance\n"
6113 "OSPF Distance\n")
6114{
paul68980082003-03-25 05:07:42 +00006115 struct ospf *ospf = vty->index;
6116
6117 ospf->distance_intra = 0;
6118 ospf->distance_inter = 0;
6119 ospf->distance_external = 0;
6120
paul718e3742002-12-13 20:15:29 +00006121 return CMD_SUCCESS;
6122}
6123
6124DEFUN (ospf_distance_ospf_intra,
6125 ospf_distance_ospf_intra_cmd,
6126 "distance ospf intra-area <1-255>",
6127 "Define an administrative distance\n"
6128 "OSPF Administrative distance\n"
6129 "Intra-area routes\n"
6130 "Distance for intra-area routes\n")
6131{
paul68980082003-03-25 05:07:42 +00006132 struct ospf *ospf = vty->index;
6133
6134 ospf->distance_intra = atoi (argv[0]);
6135
paul718e3742002-12-13 20:15:29 +00006136 return CMD_SUCCESS;
6137}
6138
6139DEFUN (ospf_distance_ospf_intra_inter,
6140 ospf_distance_ospf_intra_inter_cmd,
6141 "distance ospf intra-area <1-255> inter-area <1-255>",
6142 "Define an administrative distance\n"
6143 "OSPF Administrative distance\n"
6144 "Intra-area routes\n"
6145 "Distance for intra-area routes\n"
6146 "Inter-area routes\n"
6147 "Distance for inter-area routes\n")
6148{
paul68980082003-03-25 05:07:42 +00006149 struct ospf *ospf = vty->index;
6150
6151 ospf->distance_intra = atoi (argv[0]);
6152 ospf->distance_inter = atoi (argv[1]);
6153
paul718e3742002-12-13 20:15:29 +00006154 return CMD_SUCCESS;
6155}
6156
6157DEFUN (ospf_distance_ospf_intra_external,
6158 ospf_distance_ospf_intra_external_cmd,
6159 "distance ospf intra-area <1-255> external <1-255>",
6160 "Define an administrative distance\n"
6161 "OSPF Administrative distance\n"
6162 "Intra-area routes\n"
6163 "Distance for intra-area routes\n"
6164 "External routes\n"
6165 "Distance for external routes\n")
6166{
paul68980082003-03-25 05:07:42 +00006167 struct ospf *ospf = vty->index;
6168
6169 ospf->distance_intra = atoi (argv[0]);
6170 ospf->distance_external = atoi (argv[1]);
6171
paul718e3742002-12-13 20:15:29 +00006172 return CMD_SUCCESS;
6173}
6174
6175DEFUN (ospf_distance_ospf_intra_inter_external,
6176 ospf_distance_ospf_intra_inter_external_cmd,
6177 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6178 "Define an administrative distance\n"
6179 "OSPF Administrative distance\n"
6180 "Intra-area routes\n"
6181 "Distance for intra-area routes\n"
6182 "Inter-area routes\n"
6183 "Distance for inter-area routes\n"
6184 "External routes\n"
6185 "Distance for external routes\n")
6186{
paul68980082003-03-25 05:07:42 +00006187 struct ospf *ospf = vty->index;
6188
6189 ospf->distance_intra = atoi (argv[0]);
6190 ospf->distance_inter = atoi (argv[1]);
6191 ospf->distance_external = atoi (argv[2]);
6192
paul718e3742002-12-13 20:15:29 +00006193 return CMD_SUCCESS;
6194}
6195
6196DEFUN (ospf_distance_ospf_intra_external_inter,
6197 ospf_distance_ospf_intra_external_inter_cmd,
6198 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6199 "Define an administrative distance\n"
6200 "OSPF Administrative distance\n"
6201 "Intra-area routes\n"
6202 "Distance for intra-area routes\n"
6203 "External routes\n"
6204 "Distance for external routes\n"
6205 "Inter-area routes\n"
6206 "Distance for inter-area routes\n")
6207{
paul68980082003-03-25 05:07:42 +00006208 struct ospf *ospf = vty->index;
6209
6210 ospf->distance_intra = atoi (argv[0]);
6211 ospf->distance_external = atoi (argv[1]);
6212 ospf->distance_inter = atoi (argv[2]);
6213
paul718e3742002-12-13 20:15:29 +00006214 return CMD_SUCCESS;
6215}
6216
6217DEFUN (ospf_distance_ospf_inter,
6218 ospf_distance_ospf_inter_cmd,
6219 "distance ospf inter-area <1-255>",
6220 "Define an administrative distance\n"
6221 "OSPF Administrative distance\n"
6222 "Inter-area routes\n"
6223 "Distance for inter-area routes\n")
6224{
paul68980082003-03-25 05:07:42 +00006225 struct ospf *ospf = vty->index;
6226
6227 ospf->distance_inter = atoi (argv[0]);
6228
paul718e3742002-12-13 20:15:29 +00006229 return CMD_SUCCESS;
6230}
6231
6232DEFUN (ospf_distance_ospf_inter_intra,
6233 ospf_distance_ospf_inter_intra_cmd,
6234 "distance ospf inter-area <1-255> intra-area <1-255>",
6235 "Define an administrative distance\n"
6236 "OSPF Administrative distance\n"
6237 "Inter-area routes\n"
6238 "Distance for inter-area routes\n"
6239 "Intra-area routes\n"
6240 "Distance for intra-area routes\n")
6241{
paul68980082003-03-25 05:07:42 +00006242 struct ospf *ospf = vty->index;
6243
6244 ospf->distance_inter = atoi (argv[0]);
6245 ospf->distance_intra = atoi (argv[1]);
6246
paul718e3742002-12-13 20:15:29 +00006247 return CMD_SUCCESS;
6248}
6249
6250DEFUN (ospf_distance_ospf_inter_external,
6251 ospf_distance_ospf_inter_external_cmd,
6252 "distance ospf inter-area <1-255> external <1-255>",
6253 "Define an administrative distance\n"
6254 "OSPF Administrative distance\n"
6255 "Inter-area routes\n"
6256 "Distance for inter-area routes\n"
6257 "External routes\n"
6258 "Distance for external routes\n")
6259{
paul68980082003-03-25 05:07:42 +00006260 struct ospf *ospf = vty->index;
6261
6262 ospf->distance_inter = atoi (argv[0]);
6263 ospf->distance_external = atoi (argv[1]);
6264
paul718e3742002-12-13 20:15:29 +00006265 return CMD_SUCCESS;
6266}
6267
6268DEFUN (ospf_distance_ospf_inter_intra_external,
6269 ospf_distance_ospf_inter_intra_external_cmd,
6270 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6271 "Define an administrative distance\n"
6272 "OSPF Administrative distance\n"
6273 "Inter-area routes\n"
6274 "Distance for inter-area routes\n"
6275 "Intra-area routes\n"
6276 "Distance for intra-area routes\n"
6277 "External routes\n"
6278 "Distance for external routes\n")
6279{
paul68980082003-03-25 05:07:42 +00006280 struct ospf *ospf = vty->index;
6281
6282 ospf->distance_inter = atoi (argv[0]);
6283 ospf->distance_intra = atoi (argv[1]);
6284 ospf->distance_external = atoi (argv[2]);
6285
paul718e3742002-12-13 20:15:29 +00006286 return CMD_SUCCESS;
6287}
6288
6289DEFUN (ospf_distance_ospf_inter_external_intra,
6290 ospf_distance_ospf_inter_external_intra_cmd,
6291 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6292 "Define an administrative distance\n"
6293 "OSPF Administrative distance\n"
6294 "Inter-area routes\n"
6295 "Distance for inter-area routes\n"
6296 "External routes\n"
6297 "Distance for external routes\n"
6298 "Intra-area routes\n"
6299 "Distance for intra-area routes\n")
6300{
paul68980082003-03-25 05:07:42 +00006301 struct ospf *ospf = vty->index;
6302
6303 ospf->distance_inter = atoi (argv[0]);
6304 ospf->distance_external = atoi (argv[1]);
6305 ospf->distance_intra = atoi (argv[2]);
6306
paul718e3742002-12-13 20:15:29 +00006307 return CMD_SUCCESS;
6308}
6309
6310DEFUN (ospf_distance_ospf_external,
6311 ospf_distance_ospf_external_cmd,
6312 "distance ospf external <1-255>",
6313 "Define an administrative distance\n"
6314 "OSPF Administrative distance\n"
6315 "External routes\n"
6316 "Distance for external routes\n")
6317{
paul68980082003-03-25 05:07:42 +00006318 struct ospf *ospf = vty->index;
6319
6320 ospf->distance_external = atoi (argv[0]);
6321
paul718e3742002-12-13 20:15:29 +00006322 return CMD_SUCCESS;
6323}
6324
6325DEFUN (ospf_distance_ospf_external_intra,
6326 ospf_distance_ospf_external_intra_cmd,
6327 "distance ospf external <1-255> intra-area <1-255>",
6328 "Define an administrative distance\n"
6329 "OSPF Administrative distance\n"
6330 "External routes\n"
6331 "Distance for external routes\n"
6332 "Intra-area routes\n"
6333 "Distance for intra-area routes\n")
6334{
paul68980082003-03-25 05:07:42 +00006335 struct ospf *ospf = vty->index;
6336
6337 ospf->distance_external = atoi (argv[0]);
6338 ospf->distance_intra = atoi (argv[1]);
6339
paul718e3742002-12-13 20:15:29 +00006340 return CMD_SUCCESS;
6341}
6342
6343DEFUN (ospf_distance_ospf_external_inter,
6344 ospf_distance_ospf_external_inter_cmd,
6345 "distance ospf external <1-255> inter-area <1-255>",
6346 "Define an administrative distance\n"
6347 "OSPF Administrative distance\n"
6348 "External routes\n"
6349 "Distance for external routes\n"
6350 "Inter-area routes\n"
6351 "Distance for inter-area routes\n")
6352{
paul68980082003-03-25 05:07:42 +00006353 struct ospf *ospf = vty->index;
6354
6355 ospf->distance_external = atoi (argv[0]);
6356 ospf->distance_inter = atoi (argv[1]);
6357
paul718e3742002-12-13 20:15:29 +00006358 return CMD_SUCCESS;
6359}
6360
6361DEFUN (ospf_distance_ospf_external_intra_inter,
6362 ospf_distance_ospf_external_intra_inter_cmd,
6363 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6364 "Define an administrative distance\n"
6365 "OSPF Administrative distance\n"
6366 "External routes\n"
6367 "Distance for external routes\n"
6368 "Intra-area routes\n"
6369 "Distance for intra-area routes\n"
6370 "Inter-area routes\n"
6371 "Distance for inter-area routes\n")
6372{
paul68980082003-03-25 05:07:42 +00006373 struct ospf *ospf = vty->index;
6374
6375 ospf->distance_external = atoi (argv[0]);
6376 ospf->distance_intra = atoi (argv[1]);
6377 ospf->distance_inter = atoi (argv[2]);
6378
paul718e3742002-12-13 20:15:29 +00006379 return CMD_SUCCESS;
6380}
6381
6382DEFUN (ospf_distance_ospf_external_inter_intra,
6383 ospf_distance_ospf_external_inter_intra_cmd,
6384 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6385 "Define an administrative distance\n"
6386 "OSPF Administrative distance\n"
6387 "External routes\n"
6388 "Distance for external routes\n"
6389 "Inter-area routes\n"
6390 "Distance for inter-area routes\n"
6391 "Intra-area routes\n"
6392 "Distance for intra-area routes\n")
6393{
paul68980082003-03-25 05:07:42 +00006394 struct ospf *ospf = vty->index;
6395
6396 ospf->distance_external = atoi (argv[0]);
6397 ospf->distance_inter = atoi (argv[1]);
6398 ospf->distance_intra = atoi (argv[2]);
6399
paul718e3742002-12-13 20:15:29 +00006400 return CMD_SUCCESS;
6401}
6402
6403DEFUN (ospf_distance_source,
6404 ospf_distance_source_cmd,
6405 "distance <1-255> A.B.C.D/M",
6406 "Administrative distance\n"
6407 "Distance value\n"
6408 "IP source prefix\n")
6409{
paul020709f2003-04-04 02:44:16 +00006410 struct ospf *ospf = vty->index;
6411
6412 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006413
paul718e3742002-12-13 20:15:29 +00006414 return CMD_SUCCESS;
6415}
6416
6417DEFUN (no_ospf_distance_source,
6418 no_ospf_distance_source_cmd,
6419 "no distance <1-255> A.B.C.D/M",
6420 NO_STR
6421 "Administrative distance\n"
6422 "Distance value\n"
6423 "IP source prefix\n")
6424{
paul020709f2003-04-04 02:44:16 +00006425 struct ospf *ospf = vty->index;
6426
6427 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6428
paul718e3742002-12-13 20:15:29 +00006429 return CMD_SUCCESS;
6430}
6431
6432DEFUN (ospf_distance_source_access_list,
6433 ospf_distance_source_access_list_cmd,
6434 "distance <1-255> A.B.C.D/M WORD",
6435 "Administrative distance\n"
6436 "Distance value\n"
6437 "IP source prefix\n"
6438 "Access list name\n")
6439{
paul020709f2003-04-04 02:44:16 +00006440 struct ospf *ospf = vty->index;
6441
6442 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6443
paul718e3742002-12-13 20:15:29 +00006444 return CMD_SUCCESS;
6445}
6446
6447DEFUN (no_ospf_distance_source_access_list,
6448 no_ospf_distance_source_access_list_cmd,
6449 "no distance <1-255> A.B.C.D/M WORD",
6450 NO_STR
6451 "Administrative distance\n"
6452 "Distance value\n"
6453 "IP source prefix\n"
6454 "Access list name\n")
6455{
paul020709f2003-04-04 02:44:16 +00006456 struct ospf *ospf = vty->index;
6457
6458 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6459
paul718e3742002-12-13 20:15:29 +00006460 return CMD_SUCCESS;
6461}
6462
6463void
6464show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6465{
6466 struct route_node *rn;
6467 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006468 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006469 struct ospf_path *path;
6470
6471 vty_out (vty, "============ OSPF network routing table ============%s",
6472 VTY_NEWLINE);
6473
6474 for (rn = route_top (rt); rn; rn = route_next (rn))
6475 if ((or = rn->info) != NULL)
6476 {
6477 char buf1[19];
6478 snprintf (buf1, 19, "%s/%d",
6479 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6480
6481 switch (or->path_type)
6482 {
6483 case OSPF_PATH_INTER_AREA:
6484 if (or->type == OSPF_DESTINATION_NETWORK)
6485 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6486 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6487 else if (or->type == OSPF_DESTINATION_DISCARD)
6488 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6489 break;
6490 case OSPF_PATH_INTRA_AREA:
6491 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6492 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6493 break;
6494 default:
6495 break;
6496 }
6497
6498 if (or->type == OSPF_DESTINATION_NETWORK)
paul96735ee2003-08-10 02:51:22 +00006499 LIST_LOOP (or->paths, path, pnode)
6500 {
6501 if (path->oi != NULL)
6502 {
6503 if (path->nexthop.s_addr == 0)
6504 vty_out (vty, "%24s directly attached to %s%s",
6505 "", path->oi->ifp->name, VTY_NEWLINE);
6506 else
6507 vty_out (vty, "%24s via %s, %s%s", "",
6508 inet_ntoa (path->nexthop), path->oi->ifp->name,
6509 VTY_NEWLINE);
6510 }
6511 }
paul718e3742002-12-13 20:15:29 +00006512 }
6513 vty_out (vty, "%s", VTY_NEWLINE);
6514}
6515
6516void
6517show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6518{
6519 struct route_node *rn;
6520 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006521 struct listnode *pn, *nn;
paul718e3742002-12-13 20:15:29 +00006522 struct ospf_path *path;
6523
6524 vty_out (vty, "============ OSPF router routing table =============%s",
6525 VTY_NEWLINE);
6526 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6527 if (rn->info)
6528 {
6529 int flag = 0;
6530
6531 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6532
hasso52dc7ee2004-09-23 19:18:23 +00006533 for (nn = listhead ((struct list *) rn->info); nn; nextnode (nn))
paul718e3742002-12-13 20:15:29 +00006534 if ((or = getdata (nn)) != NULL)
6535 {
6536 if (flag++)
paulb0a053b2003-06-22 09:04:47 +00006537 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006538
6539 /* Show path. */
6540 vty_out (vty, "%s [%d] area: %s",
6541 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6542 or->cost, inet_ntoa (or->u.std.area_id));
6543 /* Show flags. */
6544 vty_out (vty, "%s%s%s",
6545 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6546 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6547 VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006548
6549 LIST_LOOP (or->paths, path, pn)
6550 {
6551 if (path->nexthop.s_addr == 0)
6552 vty_out (vty, "%24s directly attached to %s%s",
6553 "", path->oi->ifp->name, VTY_NEWLINE);
6554 else
6555 vty_out (vty, "%24s via %s, %s%s", "",
6556 inet_ntoa (path->nexthop), path->oi->ifp->name,
6557 VTY_NEWLINE);
6558 }
paul718e3742002-12-13 20:15:29 +00006559 }
6560 }
6561 vty_out (vty, "%s", VTY_NEWLINE);
6562}
6563
6564void
6565show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6566{
6567 struct route_node *rn;
6568 struct ospf_route *er;
hasso52dc7ee2004-09-23 19:18:23 +00006569 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006570 struct ospf_path *path;
6571
6572 vty_out (vty, "============ OSPF external routing table ===========%s",
6573 VTY_NEWLINE);
6574 for (rn = route_top (rt); rn; rn = route_next (rn))
6575 if ((er = rn->info) != NULL)
6576 {
6577 char buf1[19];
6578 snprintf (buf1, 19, "%s/%d",
6579 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6580
6581 switch (er->path_type)
6582 {
6583 case OSPF_PATH_TYPE1_EXTERNAL:
6584 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6585 er->cost, er->u.ext.tag, VTY_NEWLINE);
6586 break;
6587 case OSPF_PATH_TYPE2_EXTERNAL:
6588 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6589 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6590 break;
6591 }
6592
paul96735ee2003-08-10 02:51:22 +00006593 LIST_LOOP (er->paths, path, pnode)
paul718e3742002-12-13 20:15:29 +00006594 {
paul718e3742002-12-13 20:15:29 +00006595 if (path->oi != NULL)
6596 {
6597 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006598 vty_out (vty, "%24s directly attached to %s%s",
6599 "", path->oi->ifp->name, VTY_NEWLINE);
6600 else
6601 vty_out (vty, "%24s via %s, %s%s", "",
6602 inet_ntoa (path->nexthop), path->oi->ifp->name,
6603 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006604 }
6605 }
6606 }
6607 vty_out (vty, "%s", VTY_NEWLINE);
6608}
6609
paul718e3742002-12-13 20:15:29 +00006610DEFUN (show_ip_ospf_border_routers,
6611 show_ip_ospf_border_routers_cmd,
6612 "show ip ospf border-routers",
6613 SHOW_STR
6614 IP_STR
6615 "show all the ABR's and ASBR's\n"
6616 "for this area\n")
6617{
paul020709f2003-04-04 02:44:16 +00006618 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006619
paul020709f2003-04-04 02:44:16 +00006620 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006621 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006622 {
6623 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6624 return CMD_SUCCESS;
6625 }
6626
paul68980082003-03-25 05:07:42 +00006627 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006628 {
6629 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6630 return CMD_SUCCESS;
6631 }
6632
6633 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006634 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006635
6636 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006637 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006638
6639 return CMD_SUCCESS;
6640}
paul718e3742002-12-13 20:15:29 +00006641
6642DEFUN (show_ip_ospf_route,
6643 show_ip_ospf_route_cmd,
6644 "show ip ospf route",
6645 SHOW_STR
6646 IP_STR
6647 "OSPF information\n"
6648 "OSPF routing table\n")
6649{
paul020709f2003-04-04 02:44:16 +00006650 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006651
paul020709f2003-04-04 02:44:16 +00006652 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006653 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006654 {
6655 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6656 return CMD_SUCCESS;
6657 }
6658
paul68980082003-03-25 05:07:42 +00006659 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006660 {
6661 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6662 return CMD_SUCCESS;
6663 }
6664
6665 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006666 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006667
6668 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006669 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006670
6671 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006672 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006673
6674 return CMD_SUCCESS;
6675}
6676
6677
hassoeb1ce602004-10-08 08:17:22 +00006678const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006679{
6680 "unknown",
6681 "standard",
6682 "ibm",
6683 "cisco",
6684 "shortcut"
6685};
6686
hassoeb1ce602004-10-08 08:17:22 +00006687const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006688{
6689 "default",
6690 "enable",
6691 "disable"
6692};
6693
6694
6695void
6696area_id2str (char *buf, int length, struct ospf_area *area)
6697{
6698 memset (buf, 0, length);
6699
6700 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6701 strncpy (buf, inet_ntoa (area->area_id), length);
6702 else
6703 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6704}
6705
6706
hassoeb1ce602004-10-08 08:17:22 +00006707const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006708{
6709 "unknown", /* should never be used. */
6710 "point-to-point",
6711 "broadcast",
6712 "non-broadcast",
6713 "point-to-multipoint",
6714 "virtual-link", /* should never be used. */
6715 "loopback"
6716};
6717
6718/* Configuration write function for ospfd. */
6719int
6720config_write_interface (struct vty *vty)
6721{
hasso52dc7ee2004-09-23 19:18:23 +00006722 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006723 struct interface *ifp;
6724 struct crypt_key *ck;
6725 int write = 0;
6726 struct route_node *rn = NULL;
6727 struct ospf_if_params *params;
6728
6729 for (n1 = listhead (iflist); n1; nextnode (n1))
6730 {
6731 ifp = getdata (n1);
6732
6733 if (memcmp (ifp->name, "VLINK", 5) == 0)
6734 continue;
6735
6736 vty_out (vty, "!%s", VTY_NEWLINE);
6737 vty_out (vty, "interface %s%s", ifp->name,
6738 VTY_NEWLINE);
6739 if (ifp->desc)
6740 vty_out (vty, " description %s%s", ifp->desc,
6741 VTY_NEWLINE);
6742
6743 write++;
6744
6745 params = IF_DEF_PARAMS (ifp);
6746
6747 do {
6748 /* Interface Network print. */
6749 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006750 params->type != OSPF_IFTYPE_LOOPBACK)
6751 {
ajsbc18d612004-12-15 15:07:19 +00006752 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006753 {
6754 vty_out (vty, " ip ospf network %s",
6755 ospf_int_type_str[params->type]);
6756 if (params != IF_DEF_PARAMS (ifp))
6757 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6758 vty_out (vty, "%s", VTY_NEWLINE);
6759 }
paul718e3742002-12-13 20:15:29 +00006760 }
6761
6762 /* OSPF interface authentication print */
6763 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6764 params->auth_type != OSPF_AUTH_NOTSET)
6765 {
hassoeb1ce602004-10-08 08:17:22 +00006766 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006767
6768 /* Translation tables are not that much help here due to syntax
6769 of the simple option */
6770 switch (params->auth_type)
6771 {
6772
6773 case OSPF_AUTH_NULL:
6774 auth_str = " null";
6775 break;
6776
6777 case OSPF_AUTH_SIMPLE:
6778 auth_str = "";
6779 break;
6780
6781 case OSPF_AUTH_CRYPTOGRAPHIC:
6782 auth_str = " message-digest";
6783 break;
6784
6785 default:
6786 auth_str = "";
6787 break;
6788 }
6789
6790 vty_out (vty, " ip ospf authentication%s", auth_str);
6791 if (params != IF_DEF_PARAMS (ifp))
6792 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6793 vty_out (vty, "%s", VTY_NEWLINE);
6794 }
6795
6796 /* Simple Authentication Password print. */
6797 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6798 params->auth_simple[0] != '\0')
6799 {
6800 vty_out (vty, " ip ospf authentication-key %s",
6801 params->auth_simple);
6802 if (params != IF_DEF_PARAMS (ifp))
6803 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6804 vty_out (vty, "%s", VTY_NEWLINE);
6805 }
6806
6807 /* Cryptographic Authentication Key print. */
6808 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
6809 {
6810 ck = getdata (n2);
6811 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6812 ck->key_id, ck->auth_key);
6813 if (params != IF_DEF_PARAMS (ifp))
6814 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6815 vty_out (vty, "%s", VTY_NEWLINE);
6816 }
6817
6818 /* Interface Output Cost print. */
6819 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6820 {
6821 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6822 if (params != IF_DEF_PARAMS (ifp))
6823 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6824 vty_out (vty, "%s", VTY_NEWLINE);
6825 }
6826
6827 /* Hello Interval print. */
6828 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6829 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6830 {
6831 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6832 if (params != IF_DEF_PARAMS (ifp))
6833 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6834 vty_out (vty, "%s", VTY_NEWLINE);
6835 }
6836
6837
6838 /* Router Dead Interval print. */
6839 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6840 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6841 {
6842 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6843 if (params != IF_DEF_PARAMS (ifp))
6844 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6845 vty_out (vty, "%s", VTY_NEWLINE);
6846 }
6847
6848 /* Router Priority print. */
6849 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6850 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6851 {
6852 vty_out (vty, " ip ospf priority %u", params->priority);
6853 if (params != IF_DEF_PARAMS (ifp))
6854 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6855 vty_out (vty, "%s", VTY_NEWLINE);
6856 }
6857
6858 /* Retransmit Interval print. */
6859 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6860 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6861 {
6862 vty_out (vty, " ip ospf retransmit-interval %u",
6863 params->retransmit_interval);
6864 if (params != IF_DEF_PARAMS (ifp))
6865 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6866 vty_out (vty, "%s", VTY_NEWLINE);
6867 }
6868
6869 /* Transmit Delay print. */
6870 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6871 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6872 {
6873 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6874 if (params != IF_DEF_PARAMS (ifp))
6875 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6876 vty_out (vty, "%s", VTY_NEWLINE);
6877 }
6878
6879 while (1)
6880 {
6881 if (rn == NULL)
6882 rn = route_top (IF_OIFS_PARAMS (ifp));
6883 else
6884 rn = route_next (rn);
6885
6886 if (rn == NULL)
6887 break;
6888 params = rn->info;
6889 if (params != NULL)
6890 break;
6891 }
6892 } while (rn);
6893
6894#ifdef HAVE_OPAQUE_LSA
6895 ospf_opaque_config_write_if (vty, ifp);
6896#endif /* HAVE_OPAQUE_LSA */
6897 }
6898
6899 return write;
6900}
6901
6902int
paul68980082003-03-25 05:07:42 +00006903config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006904{
6905 struct route_node *rn;
6906 u_char buf[INET_ADDRSTRLEN];
6907
6908 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006909 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006910 if (rn->info)
6911 {
6912 struct ospf_network *n = rn->info;
6913
6914 memset (buf, 0, INET_ADDRSTRLEN);
6915
6916 /* Create Area ID string by specified Area ID format. */
6917 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00006918 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00006919 else
hassoc9e52be2004-09-26 16:09:34 +00006920 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00006921 (unsigned long int) ntohl (n->area_id.s_addr));
6922
6923 /* Network print. */
6924 vty_out (vty, " network %s/%d area %s%s",
6925 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6926 buf, VTY_NEWLINE);
6927 }
6928
6929 return 0;
6930}
6931
6932int
paul68980082003-03-25 05:07:42 +00006933config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006934{
hasso52dc7ee2004-09-23 19:18:23 +00006935 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006936 u_char buf[INET_ADDRSTRLEN];
6937
6938 /* Area configuration print. */
paul68980082003-03-25 05:07:42 +00006939 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00006940 {
6941 struct ospf_area *area = getdata (node);
6942 struct route_node *rn1;
6943
hassoc9e52be2004-09-26 16:09:34 +00006944 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00006945
6946 if (area->auth_type != OSPF_AUTH_NULL)
6947 {
6948 if (area->auth_type == OSPF_AUTH_SIMPLE)
6949 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6950 else
6951 vty_out (vty, " area %s authentication message-digest%s",
6952 buf, VTY_NEWLINE);
6953 }
6954
6955 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6956 vty_out (vty, " area %s shortcut %s%s", buf,
6957 ospf_shortcut_mode_str[area->shortcut_configured],
6958 VTY_NEWLINE);
6959
6960 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006961 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00006962 )
6963 {
paulb0a053b2003-06-22 09:04:47 +00006964 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006965 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00006966 else if (area->external_routing == OSPF_AREA_NSSA)
6967 {
6968 vty_out (vty, " area %s nssa", buf);
6969 switch (area->NSSATranslatorRole)
6970 {
6971 case OSPF_NSSA_ROLE_NEVER:
6972 vty_out (vty, " translate-never");
6973 break;
6974 case OSPF_NSSA_ROLE_ALWAYS:
6975 vty_out (vty, " translate-always");
6976 break;
6977 case OSPF_NSSA_ROLE_CANDIDATE:
6978 default:
6979 vty_out (vty, " translate-candidate");
6980 }
6981 }
paul718e3742002-12-13 20:15:29 +00006982
6983 if (area->no_summary)
6984 vty_out (vty, " no-summary");
6985
6986 vty_out (vty, "%s", VTY_NEWLINE);
6987
6988 if (area->default_cost != 1)
6989 vty_out (vty, " area %s default-cost %d%s", buf,
6990 area->default_cost, VTY_NEWLINE);
6991 }
6992
6993 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
6994 if (rn1->info)
6995 {
6996 struct ospf_area_range *range = rn1->info;
6997
6998 vty_out (vty, " area %s range %s/%d", buf,
6999 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7000
paul6c835672004-10-11 11:00:30 +00007001 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007002 vty_out (vty, " cost %d", range->cost_config);
7003
7004 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7005 vty_out (vty, " not-advertise");
7006
7007 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7008 vty_out (vty, " substitute %s/%d",
7009 inet_ntoa (range->subst_addr), range->subst_masklen);
7010
7011 vty_out (vty, "%s", VTY_NEWLINE);
7012 }
7013
7014 if (EXPORT_NAME (area))
7015 vty_out (vty, " area %s export-list %s%s", buf,
7016 EXPORT_NAME (area), VTY_NEWLINE);
7017
7018 if (IMPORT_NAME (area))
7019 vty_out (vty, " area %s import-list %s%s", buf,
7020 IMPORT_NAME (area), VTY_NEWLINE);
7021
7022 if (PREFIX_NAME_IN (area))
7023 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7024 PREFIX_NAME_IN (area), VTY_NEWLINE);
7025
7026 if (PREFIX_NAME_OUT (area))
7027 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7028 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7029 }
7030
7031 return 0;
7032}
7033
7034int
paul68980082003-03-25 05:07:42 +00007035config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007036{
7037 struct ospf_nbr_nbma *nbr_nbma;
7038 struct route_node *rn;
7039
7040 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007041 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007042 if ((nbr_nbma = rn->info))
7043 {
7044 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7045
7046 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7047 vty_out (vty, " priority %d", nbr_nbma->priority);
7048
7049 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7050 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7051
7052 vty_out (vty, "%s", VTY_NEWLINE);
7053 }
7054
7055 return 0;
7056}
7057
7058int
paul68980082003-03-25 05:07:42 +00007059config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007060{
hasso52dc7ee2004-09-23 19:18:23 +00007061 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007062 u_char buf[INET_ADDRSTRLEN];
7063
7064 /* Virtual-Link print */
paul68980082003-03-25 05:07:42 +00007065 for (node = listhead (ospf->vlinks); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007066 {
hasso52dc7ee2004-09-23 19:18:23 +00007067 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007068 struct crypt_key *ck;
7069 struct ospf_vl_data *vl_data = getdata (node);
7070 struct ospf_interface *oi;
7071
7072 if (vl_data != NULL)
7073 {
7074 memset (buf, 0, INET_ADDRSTRLEN);
7075
7076 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007077 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007078 else
hassoc9e52be2004-09-26 16:09:34 +00007079 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007080 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7081 oi = vl_data->vl_oi;
7082
7083 /* timers */
7084 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7085 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7086 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7087 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7088 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7089 buf,
7090 inet_ntoa (vl_data->vl_peer),
7091 OSPF_IF_PARAM (oi, v_hello),
7092 OSPF_IF_PARAM (oi, retransmit_interval),
7093 OSPF_IF_PARAM (oi, transmit_delay),
7094 OSPF_IF_PARAM (oi, v_wait),
7095 VTY_NEWLINE);
7096 else
7097 vty_out (vty, " area %s virtual-link %s%s", buf,
7098 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7099 /* Auth key */
7100 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7101 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7102 buf,
7103 inet_ntoa (vl_data->vl_peer),
7104 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7105 VTY_NEWLINE);
7106 /* md5 keys */
7107 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
7108 {
7109 ck = getdata (n2);
7110 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
7111 buf,
7112 inet_ntoa (vl_data->vl_peer),
7113 ck->key_id, ck->auth_key, VTY_NEWLINE);
7114 }
7115
7116 }
7117 }
7118
7119 return 0;
7120}
7121
7122
hassoeb1ce602004-10-08 08:17:22 +00007123const char *distribute_str[] = { "system", "kernel", "connected", "static",
7124 "rip", "ripng", "ospf", "ospf6", "isis", "bgp"};
paul718e3742002-12-13 20:15:29 +00007125int
paul68980082003-03-25 05:07:42 +00007126config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007127{
7128 int type;
7129
7130 /* redistribute print. */
7131 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7132 if (type != zclient->redist_default && zclient->redist[type])
7133 {
7134 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007135 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007136 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007137
paul68980082003-03-25 05:07:42 +00007138 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007139 vty_out (vty, " metric-type 1");
7140
paul020709f2003-04-04 02:44:16 +00007141 if (ROUTEMAP_NAME (ospf, type))
7142 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007143
7144 vty_out (vty, "%s", VTY_NEWLINE);
7145 }
7146
7147 return 0;
7148}
7149
7150int
paul68980082003-03-25 05:07:42 +00007151config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007152{
paul68980082003-03-25 05:07:42 +00007153 if (ospf->default_metric != -1)
7154 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007155 VTY_NEWLINE);
7156 return 0;
7157}
7158
7159int
paul68980082003-03-25 05:07:42 +00007160config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007161{
7162 int type;
7163
paul68980082003-03-25 05:07:42 +00007164 if (ospf)
paul718e3742002-12-13 20:15:29 +00007165 {
7166 /* distribute-list print. */
7167 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007168 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007169 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007170 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007171 distribute_str[type], VTY_NEWLINE);
7172
7173 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007174 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007175 {
paul68980082003-03-25 05:07:42 +00007176 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007177 vty_out (vty, " default-information originate");
7178 else
7179 vty_out (vty, " default-information originate always");
7180
paul68980082003-03-25 05:07:42 +00007181 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007182 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007183 ospf->dmetric[DEFAULT_ROUTE].value);
7184 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007185 vty_out (vty, " metric-type 1");
7186
paul020709f2003-04-04 02:44:16 +00007187 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7188 vty_out (vty, " route-map %s",
7189 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007190
7191 vty_out (vty, "%s", VTY_NEWLINE);
7192 }
7193
7194 }
7195
7196 return 0;
7197}
7198
7199int
paul68980082003-03-25 05:07:42 +00007200config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007201{
7202 struct route_node *rn;
7203 struct ospf_distance *odistance;
7204
paul68980082003-03-25 05:07:42 +00007205 if (ospf->distance_all)
7206 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007207
paul68980082003-03-25 05:07:42 +00007208 if (ospf->distance_intra
7209 || ospf->distance_inter
7210 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007211 {
7212 vty_out (vty, " distance ospf");
7213
paul68980082003-03-25 05:07:42 +00007214 if (ospf->distance_intra)
7215 vty_out (vty, " intra-area %d", ospf->distance_intra);
7216 if (ospf->distance_inter)
7217 vty_out (vty, " inter-area %d", ospf->distance_inter);
7218 if (ospf->distance_external)
7219 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007220
7221 vty_out (vty, "%s", VTY_NEWLINE);
7222 }
7223
paul68980082003-03-25 05:07:42 +00007224 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007225 if ((odistance = rn->info) != NULL)
7226 {
7227 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7228 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7229 odistance->access_list ? odistance->access_list : "",
7230 VTY_NEWLINE);
7231 }
7232 return 0;
7233}
7234
7235/* OSPF configuration write function. */
7236int
7237ospf_config_write (struct vty *vty)
7238{
paul020709f2003-04-04 02:44:16 +00007239 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00007240 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007241 int write = 0;
7242
paul020709f2003-04-04 02:44:16 +00007243 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007244 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007245 {
7246 /* `router ospf' print. */
7247 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7248
7249 write++;
7250
paul68980082003-03-25 05:07:42 +00007251 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007252 return write;
7253
7254 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007255 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007256 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007257 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007258
7259 /* ABR type print. */
paul68980082003-03-25 05:07:42 +00007260 if (ospf->abr_type != OSPF_ABR_STAND)
paul718e3742002-12-13 20:15:29 +00007261 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007262 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007263
7264 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007265 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007266 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7267
7268 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007269 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007270 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007271 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007272
7273 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007274 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7275 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007276 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007277 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007278
7279 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007280 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007281 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007282 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007283
7284 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007285 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007286
7287 /* passive-interface print. */
paul020709f2003-04-04 02:44:16 +00007288 for (node = listhead (om->iflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007289 {
7290 struct interface *ifp = getdata (node);
7291
7292 if (!ifp)
7293 continue;
7294 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7295 vty_out (vty, " passive-interface %s%s",
7296 ifp->name, VTY_NEWLINE);
7297 }
7298
paul68980082003-03-25 05:07:42 +00007299 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007300 {
7301 struct ospf_interface *oi = getdata (node);
7302
7303 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7304 oi->params->passive_interface == OSPF_IF_PASSIVE)
paul96735ee2003-08-10 02:51:22 +00007305 vty_out (vty, " passive-interface %s %s%s",
7306 oi->ifp->name,
paul5fdc1e52003-08-06 22:41:29 +00007307 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007308 }
7309
7310
7311 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007312 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007313
7314 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007315 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007316
7317 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007318 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007319
7320 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007321 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007322
7323 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007324 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007325
7326 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007327 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007328
7329 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007330 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007331
7332#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007333 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007334#endif /* HAVE_OPAQUE_LSA */
7335 }
7336
7337 return write;
7338}
7339
7340void
7341ospf_vty_show_init ()
7342{
7343 /* "show ip ospf" commands. */
7344 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7345 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7346
7347 /* "show ip ospf database" commands. */
7348 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7349 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7350 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7351 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7352 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7353 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7354 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7355 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7356 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7357 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7358 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7359 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7360 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7361 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7362
7363 /* "show ip ospf interface" commands. */
7364 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7365 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7366
7367 /* "show ip ospf neighbor" commands. */
7368 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7369 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7370 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7371 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7372 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7373 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7374 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7375 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7376 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7377 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7378 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7379 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7380 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7381 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7382
7383 /* "show ip ospf route" commands. */
7384 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7385 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007386 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7387 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007388}
7389
7390
7391/* ospfd's interface node. */
7392struct cmd_node interface_node =
7393{
7394 INTERFACE_NODE,
7395 "%s(config-if)# ",
7396 1
7397};
7398
7399/* Initialization of OSPF interface. */
7400void
7401ospf_vty_if_init ()
7402{
7403 /* Install interface node. */
7404 install_node (&interface_node, config_write_interface);
7405
7406 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007407 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007408 install_default (INTERFACE_NODE);
7409
7410 /* "description" commands. */
7411 install_element (INTERFACE_NODE, &interface_desc_cmd);
7412 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7413
7414 /* "ip ospf authentication" commands. */
7415 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7416 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7417 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7418 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7419 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7420 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7421 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7422 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7423 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7424 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7425
7426 /* "ip ospf message-digest-key" commands. */
7427 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7428 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7429 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7430 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7431
7432 /* "ip ospf cost" commands. */
7433 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7434 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7435 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7436 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7437
7438 /* "ip ospf dead-interval" commands. */
7439 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7440 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7441 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7442 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7443
7444 /* "ip ospf hello-interval" commands. */
7445 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7446 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7447 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7448 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7449
7450 /* "ip ospf network" commands. */
7451 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7452 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7453
7454 /* "ip ospf priority" commands. */
7455 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7456 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7457 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7458 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7459
7460 /* "ip ospf retransmit-interval" commands. */
7461 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7462 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7463 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7464 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7465
7466 /* "ip ospf transmit-delay" commands. */
7467 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7468 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7469 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7470 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7471
7472 /* These commands are compatibitliy for previous version. */
7473 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7474 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7475 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7476 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7477 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7478 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7479 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7480 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7481 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7482 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7483 install_element (INTERFACE_NODE, &ospf_network_cmd);
7484 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7485 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7486 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7487 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7488 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7489 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7490 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7491}
7492
7493/* Zebra node structure. */
7494struct cmd_node zebra_node =
7495{
7496 ZEBRA_NODE,
7497 "%s(config-router)#",
7498};
7499
7500void
7501ospf_vty_zebra_init ()
7502{
7503 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7504 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7505 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7506 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7507 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7508 install_element (OSPF_NODE,
7509 &ospf_redistribute_source_metric_type_routemap_cmd);
7510 install_element (OSPF_NODE,
7511 &ospf_redistribute_source_type_metric_routemap_cmd);
7512 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7513 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7514 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7515
7516 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7517
7518 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7519 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7520
7521 install_element (OSPF_NODE,
7522 &ospf_default_information_originate_metric_type_cmd);
7523 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7524 install_element (OSPF_NODE,
7525 &ospf_default_information_originate_type_metric_cmd);
7526 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7527 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7528 install_element (OSPF_NODE,
7529 &ospf_default_information_originate_always_metric_type_cmd);
7530 install_element (OSPF_NODE,
7531 &ospf_default_information_originate_always_metric_cmd);
7532 install_element (OSPF_NODE,
7533 &ospf_default_information_originate_always_cmd);
7534 install_element (OSPF_NODE,
7535 &ospf_default_information_originate_always_type_metric_cmd);
7536 install_element (OSPF_NODE,
7537 &ospf_default_information_originate_always_type_cmd);
7538
7539 install_element (OSPF_NODE,
7540 &ospf_default_information_originate_metric_type_routemap_cmd);
7541 install_element (OSPF_NODE,
7542 &ospf_default_information_originate_metric_routemap_cmd);
7543 install_element (OSPF_NODE,
7544 &ospf_default_information_originate_routemap_cmd);
7545 install_element (OSPF_NODE,
7546 &ospf_default_information_originate_type_metric_routemap_cmd);
7547 install_element (OSPF_NODE,
7548 &ospf_default_information_originate_type_routemap_cmd);
7549 install_element (OSPF_NODE,
7550 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7551 install_element (OSPF_NODE,
7552 &ospf_default_information_originate_always_metric_routemap_cmd);
7553 install_element (OSPF_NODE,
7554 &ospf_default_information_originate_always_routemap_cmd);
7555 install_element (OSPF_NODE,
7556 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7557 install_element (OSPF_NODE,
7558 &ospf_default_information_originate_always_type_routemap_cmd);
7559
7560 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7561
7562 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7563 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7564 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7565
7566 install_element (OSPF_NODE, &ospf_distance_cmd);
7567 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7568 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7569 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7570 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7571 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7572 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7573 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7574 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7575 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7576 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7577 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7578 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7579 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7580 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7581 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7582 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7583 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7584#if 0
7585 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7586 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7587 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7588 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7589#endif /* 0 */
7590}
7591
7592struct cmd_node ospf_node =
7593{
7594 OSPF_NODE,
7595 "%s(config-router)# ",
7596 1
7597};
7598
7599
7600/* Install OSPF related vty commands. */
7601void
7602ospf_vty_init ()
7603{
7604 /* Install ospf top node. */
7605 install_node (&ospf_node, ospf_config_write);
7606
7607 /* "router ospf" commands. */
7608 install_element (CONFIG_NODE, &router_ospf_cmd);
7609 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7610
7611 install_default (OSPF_NODE);
7612
7613 /* "ospf router-id" commands. */
7614 install_element (OSPF_NODE, &ospf_router_id_cmd);
7615 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007616 install_element (OSPF_NODE, &router_ospf_id_cmd);
7617 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007618
7619 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007620 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7621 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7622 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7623 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007624
7625 /* "ospf abr-type" commands. */
7626 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7627 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7628
7629 /* "ospf rfc1583-compatible" commands. */
7630 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7631 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7632 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7633 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7634
7635 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007636 install_element (OSPF_NODE, &ospf_network_area_cmd);
7637 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007638
7639 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007640 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7641 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7642 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007643
7644 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007645 install_element (OSPF_NODE, &ospf_area_range_cmd);
7646 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7647 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7648 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7649 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7650 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7651 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7652 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7653 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7654 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7655 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007656
7657 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007658 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7659 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007660
paula2c62832003-04-23 17:01:31 +00007661 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7662 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007663
paula2c62832003-04-23 17:01:31 +00007664 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7665 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007666
paula2c62832003-04-23 17:01:31 +00007667 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7668 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007669
paula2c62832003-04-23 17:01:31 +00007670 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7671 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007672
paula2c62832003-04-23 17:01:31 +00007673 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7674 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7675 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007676
paula2c62832003-04-23 17:01:31 +00007677 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7678 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007679
paula2c62832003-04-23 17:01:31 +00007680 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7681 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007682
paula2c62832003-04-23 17:01:31 +00007683 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7684 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7685 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007686
paula2c62832003-04-23 17:01:31 +00007687 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7688 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7689 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007690
7691 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007692 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7693 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7694 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7695 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007696
paul718e3742002-12-13 20:15:29 +00007697 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007698 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7699 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7700 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7701 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7702 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7703 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007704
paula2c62832003-04-23 17:01:31 +00007705 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7706 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007707
paula2c62832003-04-23 17:01:31 +00007708 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7709 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007710
paula2c62832003-04-23 17:01:31 +00007711 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7712 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007713
paula2c62832003-04-23 17:01:31 +00007714 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7715 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007716
paula2c62832003-04-23 17:01:31 +00007717 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7718 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007719
paula2c62832003-04-23 17:01:31 +00007720 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7721 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007722
paula2c62832003-04-23 17:01:31 +00007723 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7724 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7725 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007726
paula2c62832003-04-23 17:01:31 +00007727 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7728 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007729
7730 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007731 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7732 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7733 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7734 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7735 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7736 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7737 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7738 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007739
7740 /* Init interface related vty commands. */
7741 ospf_vty_if_init ();
7742
7743 /* Init zebra related vty commands. */
7744 ospf_vty_zebra_init ();
7745}