blob: 55b33150c174ff0e81bf8b27f74d94e7d623bf33 [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;
ajsba6454e2005-02-08 15:37:30 +0000263 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000264
265 ifp = if_lookup_by_name (argv[0]);
266
267 if (ifp == NULL)
268 {
269 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
270 return CMD_WARNING;
271 }
272
273 params = IF_DEF_PARAMS (ifp);
274
275 if (argc == 2)
276 {
277 ret = inet_aton(argv[1], &addr);
278 if (!ret)
279 {
280 vty_out (vty, "Please specify interface address by A.B.C.D%s",
281 VTY_NEWLINE);
282 return CMD_WARNING;
283 }
284
285 params = ospf_get_if_params (ifp, addr);
286 ospf_if_update_params (ifp, addr);
287 }
288
289 SET_IF_PARAM (params, passive_interface);
290 params->passive_interface = OSPF_IF_PASSIVE;
ajsba6454e2005-02-08 15:37:30 +0000291
292 /* XXX We should call ospf_if_set_multicast on exactly those
293 * interfaces for which the passive property changed. It is too much
294 * work to determine this set, so we do this for every interface.
295 * This is safe and reasonable because ospf_if_set_multicast uses a
296 * record of joined groups to avoid systems calls if the desired
297 * memberships match the current memership.
298 */
299 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
300 {
301 struct ospf_interface *oi = rn->info;
302
303 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
304 ospf_if_set_multicast(oi);
305 }
306 /*
307 * XXX It is not clear what state transitions the interface needs to
308 * undergo when going from active to passive. Fixing this will
309 * require precise identification of interfaces having such a
310 * transition.
311 */
312
paul718e3742002-12-13 20:15:29 +0000313 return CMD_SUCCESS;
314}
315
paula2c62832003-04-23 17:01:31 +0000316ALIAS (ospf_passive_interface,
317 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000318 "passive-interface IFNAME",
319 "Suppress routing updates on an interface\n"
320 "Interface's name\n")
321
paula2c62832003-04-23 17:01:31 +0000322DEFUN (no_ospf_passive_interface,
323 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000324 "no passive-interface IFNAME A.B.C.D",
325 NO_STR
326 "Allow routing updates on an interface\n"
327 "Interface's name\n")
328{
329 struct interface *ifp;
330 struct in_addr addr;
331 struct ospf_if_params *params;
332 int ret;
ajsba6454e2005-02-08 15:37:30 +0000333 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000334
335 ifp = if_lookup_by_name (argv[0]);
336
337 if (ifp == NULL)
338 {
339 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
340 return CMD_WARNING;
341 }
342
343 params = IF_DEF_PARAMS (ifp);
344
345 if (argc == 2)
346 {
347 ret = inet_aton(argv[1], &addr);
348 if (!ret)
349 {
350 vty_out (vty, "Please specify interface address by A.B.C.D%s",
351 VTY_NEWLINE);
352 return CMD_WARNING;
353 }
354
355 params = ospf_lookup_if_params (ifp, addr);
356 if (params == NULL)
357 return CMD_SUCCESS;
358 }
359
360 UNSET_IF_PARAM (params, passive_interface);
361 params->passive_interface = OSPF_IF_ACTIVE;
362
363 if (params != IF_DEF_PARAMS (ifp))
364 {
365 ospf_free_if_params (ifp, addr);
366 ospf_if_update_params (ifp, addr);
367 }
ajsba6454e2005-02-08 15:37:30 +0000368
369 /* XXX We should call ospf_if_set_multicast on exactly those
370 * interfaces for which the passive property changed. It is too much
371 * work to determine this set, so we do this for every interface.
372 * This is safe and reasonable because ospf_if_set_multicast uses a
373 * record of joined groups to avoid systems calls if the desired
374 * memberships match the current memership.
375 */
376 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
377 {
378 struct ospf_interface *oi = rn->info;
379
380 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
381 ospf_if_set_multicast(oi);
382 }
383
paul718e3742002-12-13 20:15:29 +0000384 return CMD_SUCCESS;
385}
386
paula2c62832003-04-23 17:01:31 +0000387ALIAS (no_ospf_passive_interface,
388 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000389 "no passive-interface IFNAME",
390 NO_STR
391 "Allow routing updates on an interface\n"
392 "Interface's name\n")
393
paula2c62832003-04-23 17:01:31 +0000394DEFUN (ospf_network_area,
395 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000396 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
397 "Enable routing on an IP network\n"
398 "OSPF network prefix\n"
399 "Set the OSPF area ID\n"
400 "OSPF area ID in IP address format\n"
401 "OSPF area ID as a decimal value\n")
402{
403 struct ospf *ospf= vty->index;
404 struct prefix_ipv4 p;
405 struct in_addr area_id;
406 int ret, format;
407
408 /* Get network prefix and Area ID. */
409 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
410 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
411
412 ret = ospf_network_set (ospf, &p, area_id);
413 if (ret == 0)
414 {
415 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
416 return CMD_WARNING;
417 }
418
419 return CMD_SUCCESS;
420}
421
paula2c62832003-04-23 17:01:31 +0000422DEFUN (no_ospf_network_area,
423 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000424 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
425 NO_STR
426 "Enable routing on an IP network\n"
427 "OSPF network prefix\n"
428 "Set the OSPF area ID\n"
429 "OSPF area ID in IP address format\n"
430 "OSPF area ID as a decimal value\n")
431{
432 struct ospf *ospf = (struct ospf *) vty->index;
433 struct prefix_ipv4 p;
434 struct in_addr area_id;
435 int ret, format;
436
437 /* Get network prefix and Area ID. */
438 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
439 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
440
441 ret = ospf_network_unset (ospf, &p, area_id);
442 if (ret == 0)
443 {
444 vty_out (vty, "Can't find specified network area configuration.%s",
445 VTY_NEWLINE);
446 return CMD_WARNING;
447 }
448
449 return CMD_SUCCESS;
450}
451
452
paula2c62832003-04-23 17:01:31 +0000453DEFUN (ospf_area_range,
454 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000455 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
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{
462 struct ospf *ospf = vty->index;
463 struct prefix_ipv4 p;
464 struct in_addr area_id;
465 int format;
466 u_int32_t cost;
467
468 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
469 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
470
471 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
472 if (argc > 2)
473 {
474 VTY_GET_UINT32 ("range cost", cost, argv[2]);
475 ospf_area_range_cost_set (ospf, area_id, &p, cost);
476 }
477
478 return CMD_SUCCESS;
479}
480
paula2c62832003-04-23 17:01:31 +0000481ALIAS (ospf_area_range,
482 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000483 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
484 "OSPF area parameters\n"
485 "OSPF area ID in IP address format\n"
486 "OSPF area ID as a decimal value\n"
487 "OSPF area range for route advertise (default)\n"
488 "Area range prefix\n"
489 "Advertise this range (default)\n")
490
paula2c62832003-04-23 17:01:31 +0000491ALIAS (ospf_area_range,
492 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000493 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
494 "OSPF area parameters\n"
495 "OSPF area ID in IP address format\n"
496 "OSPF area ID as a decimal value\n"
497 "Summarize routes matching address/mask (border routers only)\n"
498 "Area range prefix\n"
499 "User specified metric for this range\n"
500 "Advertised metric for this range\n")
501
paula2c62832003-04-23 17:01:31 +0000502ALIAS (ospf_area_range,
503 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000504 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
505 "OSPF area parameters\n"
506 "OSPF area ID in IP address format\n"
507 "OSPF area ID as a decimal value\n"
508 "Summarize routes matching address/mask (border routers only)\n"
509 "Area range prefix\n"
510 "Advertise this range (default)\n"
511 "User specified metric for this range\n"
512 "Advertised metric for this range\n")
513
paula2c62832003-04-23 17:01:31 +0000514DEFUN (ospf_area_range_not_advertise,
515 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000516 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
517 "OSPF area parameters\n"
518 "OSPF area ID in IP address format\n"
519 "OSPF area ID as a decimal value\n"
520 "Summarize routes matching address/mask (border routers only)\n"
521 "Area range prefix\n"
522 "DoNotAdvertise this range\n")
523{
524 struct ospf *ospf = vty->index;
525 struct prefix_ipv4 p;
526 struct in_addr area_id;
527 int format;
528
529 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
530 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
531
532 ospf_area_range_set (ospf, area_id, &p, 0);
533
534 return CMD_SUCCESS;
535}
536
paula2c62832003-04-23 17:01:31 +0000537DEFUN (no_ospf_area_range,
538 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000539 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
540 NO_STR
541 "OSPF area parameters\n"
542 "OSPF area ID in IP address format\n"
543 "OSPF area ID as a decimal value\n"
544 "Summarize routes matching address/mask (border routers only)\n"
545 "Area range prefix\n")
546{
547 struct ospf *ospf = vty->index;
548 struct prefix_ipv4 p;
549 struct in_addr area_id;
550 int format;
551
552 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
553 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
554
555 ospf_area_range_unset (ospf, area_id, &p);
556
557 return CMD_SUCCESS;
558}
559
paula2c62832003-04-23 17:01:31 +0000560ALIAS (no_ospf_area_range,
561 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000562 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
563 NO_STR
564 "OSPF area parameters\n"
565 "OSPF area ID in IP address format\n"
566 "OSPF area ID as a decimal value\n"
567 "Summarize routes matching address/mask (border routers only)\n"
568 "Area range prefix\n"
569 "Advertise this range (default)\n"
570 "DoNotAdvertise this range\n")
571
paula2c62832003-04-23 17:01:31 +0000572ALIAS (no_ospf_area_range,
573 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000574 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
575 NO_STR
576 "OSPF area parameters\n"
577 "OSPF area ID in IP address format\n"
578 "OSPF area ID as a decimal value\n"
579 "Summarize routes matching address/mask (border routers only)\n"
580 "Area range prefix\n"
581 "User specified metric for this range\n"
582 "Advertised metric for this range\n")
583
paula2c62832003-04-23 17:01:31 +0000584ALIAS (no_ospf_area_range,
585 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000586 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
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 "Advertise this range (default)\n"
594 "User specified metric for this range\n"
595 "Advertised metric for this range\n")
596
paula2c62832003-04-23 17:01:31 +0000597DEFUN (ospf_area_range_substitute,
598 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000599 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
600 "OSPF area parameters\n"
601 "OSPF area ID in IP address format\n"
602 "OSPF area ID as a decimal value\n"
603 "Summarize routes matching address/mask (border routers only)\n"
604 "Area range prefix\n"
605 "Announce area range as another prefix\n"
606 "Network prefix to be announced instead of range\n")
607{
608 struct ospf *ospf = vty->index;
609 struct prefix_ipv4 p, s;
610 struct in_addr area_id;
611 int format;
612
613 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
614 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
615 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
616
617 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
618
619 return CMD_SUCCESS;
620}
621
paula2c62832003-04-23 17:01:31 +0000622DEFUN (no_ospf_area_range_substitute,
623 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000624 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
625 NO_STR
626 "OSPF area parameters\n"
627 "OSPF area ID in IP address format\n"
628 "OSPF area ID as a decimal value\n"
629 "Summarize routes matching address/mask (border routers only)\n"
630 "Area range prefix\n"
631 "Announce area range as another prefix\n"
632 "Network prefix to be announced instead of range\n")
633{
634 struct ospf *ospf = vty->index;
635 struct prefix_ipv4 p, s;
636 struct in_addr area_id;
637 int format;
638
639 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
640 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
641 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
642
643 ospf_area_range_substitute_unset (ospf, area_id, &p);
644
645 return CMD_SUCCESS;
646}
647
648
649/* Command Handler Logic in VLink stuff is delicate!!
650
651 ALTER AT YOUR OWN RISK!!!!
652
653 Various dummy values are used to represent 'NoChange' state for
654 VLink configuration NOT being changed by a VLink command, and
655 special syntax is used within the command strings so that the
656 typed in command verbs can be seen in the configuration command
657 bacckend handler. This is to drastically reduce the verbeage
658 required to coe up with a reasonably compatible Cisco VLink command
659
660 - Matthew Grant <grantma@anathoth.gen.nz>
661 Wed, 21 Feb 2001 15:13:52 +1300
662 */
663
664
665/* Configuration data for virtual links
666 */
667struct ospf_vl_config_data {
668 struct vty *vty; /* vty stuff */
669 struct in_addr area_id; /* area ID from command line */
670 int format; /* command line area ID format */
671 struct in_addr vl_peer; /* command line vl_peer */
672 int auth_type; /* Authehntication type, if given */
673 char *auth_key; /* simple password if present */
674 int crypto_key_id; /* Cryptographic key ID */
675 char *md5_key; /* MD5 authentication key */
676 int hello_interval; /* Obvious what these are... */
677 int retransmit_interval;
678 int transmit_delay;
679 int dead_interval;
680};
681
682void
683ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
684 struct vty *vty)
685{
686 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
687 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
688 vl_config->vty = vty;
689}
690
691struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000692ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000693{
694 struct ospf_area *area;
695 struct ospf_vl_data *vl_data;
696 struct vty *vty;
697 struct in_addr area_id;
698
699 vty = vl_config->vty;
700 area_id = vl_config->area_id;
701
702 if (area_id.s_addr == OSPF_AREA_BACKBONE)
703 {
704 vty_out (vty,
705 "Configuring VLs over the backbone is not allowed%s",
706 VTY_NEWLINE);
707 return NULL;
708 }
paul68980082003-03-25 05:07:42 +0000709 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000710
711 if (area->external_routing != OSPF_AREA_DEFAULT)
712 {
713 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
714 vty_out (vty, "Area %s is %s%s",
715 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000716 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000717 VTY_NEWLINE);
718 else
719 vty_out (vty, "Area %ld is %s%s",
720 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000721 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000722 VTY_NEWLINE);
723 return NULL;
724 }
725
726 if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)
727 {
728 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
729 if (vl_data->vl_oi == NULL)
730 {
paul68980082003-03-25 05:07:42 +0000731 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
732 ospf_vl_add (ospf, vl_data);
733 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000734 }
735 }
736 return vl_data;
737}
738
739
740int
741ospf_vl_set_security (struct ospf_vl_data *vl_data,
742 struct ospf_vl_config_data *vl_config)
743{
744 struct crypt_key *ck;
745 struct vty *vty;
746 struct interface *ifp = vl_data->vl_oi->ifp;
747
748 vty = vl_config->vty;
749
750 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
751 {
752 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
753 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
754 }
755
756 if (vl_config->auth_key)
757 {
758 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000759 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000760 OSPF_AUTH_SIMPLE_SIZE);
761 }
762 else if (vl_config->md5_key)
763 {
764 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
765 != NULL)
766 {
767 vty_out (vty, "OSPF: Key %d already exists%s",
768 vl_config->crypto_key_id, VTY_NEWLINE);
769 return CMD_WARNING;
770 }
771 ck = ospf_crypt_key_new ();
772 ck->key_id = vl_config->crypto_key_id;
773 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000774 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000775
776 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
777 }
778 else if (vl_config->crypto_key_id != 0)
779 {
780 /* Delete a key */
781
782 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
783 vl_config->crypto_key_id) == NULL)
784 {
785 vty_out (vty, "OSPF: Key %d does not exist%s",
786 vl_config->crypto_key_id, VTY_NEWLINE);
787 return CMD_WARNING;
788 }
789
790 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
791
792 }
793
794 return CMD_SUCCESS;
795}
796
797
798
799int
800ospf_vl_set_timers (struct ospf_vl_data *vl_data,
801 struct ospf_vl_config_data *vl_config)
802{
803 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
804 /* Virtual Link data initialised to defaults, so only set
805 if a value given */
806 if (vl_config->hello_interval)
807 {
808 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
809 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
810 }
811
812 if (vl_config->dead_interval)
813 {
814 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
815 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
816 }
817
818 if (vl_config->retransmit_interval)
819 {
820 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
821 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
822 }
823
824 if (vl_config->transmit_delay)
825 {
826 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
827 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
828 }
829
830 return CMD_SUCCESS;
831}
832
833
834
835/* The business end of all of the above */
836int
paul68980082003-03-25 05:07:42 +0000837ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000838{
839 struct ospf_vl_data *vl_data;
840 int ret;
841
paul68980082003-03-25 05:07:42 +0000842 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000843 if (!vl_data)
844 return CMD_WARNING;
845
846 /* Process this one first as it can have a fatal result, which can
847 only logically occur if the virtual link exists already
848 Thus a command error does not result in a change to the
849 running configuration such as unexpectedly altered timer
850 values etc.*/
851 ret = ospf_vl_set_security (vl_data, vl_config);
852 if (ret != CMD_SUCCESS)
853 return ret;
854
855 /* Set any time based parameters, these area already range checked */
856
857 ret = ospf_vl_set_timers (vl_data, vl_config);
858 if (ret != CMD_SUCCESS)
859 return ret;
860
861 return CMD_SUCCESS;
862
863}
864
865/* This stuff exists to make specifying all the alias commands A LOT simpler
866 */
867#define VLINK_HELPSTR_IPADDR \
868 "OSPF area parameters\n" \
869 "OSPF area ID in IP address format\n" \
870 "OSPF area ID as a decimal value\n" \
871 "Configure a virtual link\n" \
872 "Router ID of the remote ABR\n"
873
874#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
875 "Enable authentication on this virtual link\n" \
876 "dummy string \n"
877
878#define VLINK_HELPSTR_AUTHTYPE_ALL \
879 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
880 "Use null authentication\n" \
881 "Use message-digest authentication\n"
882
883#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
884 "Time between HELLO packets\n" \
885 "Time between retransmitting lost link state advertisements\n" \
886 "Link state transmit delay\n" \
887 "Interval after which a neighbor is declared dead\n"
888
889#define VLINK_HELPSTR_TIME_PARAM \
890 VLINK_HELPSTR_TIME_PARAM_NOSECS \
891 "Seconds\n"
892
893#define VLINK_HELPSTR_AUTH_SIMPLE \
894 "Authentication password (key)\n" \
895 "The OSPF password (key)"
896
897#define VLINK_HELPSTR_AUTH_MD5 \
898 "Message digest authentication password (key)\n" \
899 "dummy string \n" \
900 "Key ID\n" \
901 "Use MD5 algorithm\n" \
902 "The OSPF password (key)"
903
paula2c62832003-04-23 17:01:31 +0000904DEFUN (ospf_area_vlink,
905 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000906 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
907 VLINK_HELPSTR_IPADDR)
908{
paul68980082003-03-25 05:07:42 +0000909 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000910 struct ospf_vl_config_data vl_config;
911 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
912 char md5_key[OSPF_AUTH_MD5_SIZE+1];
913 int i;
914 int ret;
915
916 ospf_vl_config_data_init(&vl_config, vty);
917
918 /* Read off first 2 parameters and check them */
919 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
920 if (ret < 0)
921 {
922 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
923 return CMD_WARNING;
924 }
925
926 ret = inet_aton (argv[1], &vl_config.vl_peer);
927 if (! ret)
928 {
929 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
930 VTY_NEWLINE);
931 return CMD_WARNING;
932 }
933
934 if (argc <=2)
935 {
936 /* Thats all folks! - BUGS B. strikes again!!!*/
937
paul68980082003-03-25 05:07:42 +0000938 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000939 }
940
941 /* Deal with other parameters */
942 for (i=2; i < argc; i++)
943 {
944
945 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
946
947 switch (argv[i][0])
948 {
949
950 case 'a':
951 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
952 {
953 /* authentication-key - this option can occur anywhere on
954 command line. At start of command line
955 must check for authentication option. */
956 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
957 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
958 vl_config.auth_key = auth_key;
959 i++;
960 }
961 else if (strncmp (argv[i], "authentication", 14) == 0)
962 {
963 /* authentication - this option can only occur at start
964 of command line */
965 vl_config.auth_type = OSPF_AUTH_SIMPLE;
966 if ((i+1) < argc)
967 {
968 if (strncmp (argv[i+1], "n", 1) == 0)
969 {
970 /* "authentication null" */
971 vl_config.auth_type = OSPF_AUTH_NULL;
972 i++;
973 }
974 else if (strncmp (argv[i+1], "m", 1) == 0
975 && strcmp (argv[i+1], "message-digest-") != 0)
976 {
977 /* "authentication message-digest" */
978 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
979 i++;
980 }
981 }
982 }
983 break;
984
985 case 'm':
986 /* message-digest-key */
987 i++;
988 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
989 if (vl_config.crypto_key_id < 0)
990 return CMD_WARNING;
991 i++;
992 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
993 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
994 vl_config.md5_key = md5_key;
995 break;
996
997 case 'h':
998 /* Hello interval */
999 i++;
1000 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1001 if (vl_config.hello_interval < 0)
1002 return CMD_WARNING;
1003 break;
1004
1005 case 'r':
1006 /* Retransmit Interval */
1007 i++;
1008 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1009 if (vl_config.retransmit_interval < 0)
1010 return CMD_WARNING;
1011 break;
1012
1013 case 't':
1014 /* Transmit Delay */
1015 i++;
1016 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1017 if (vl_config.transmit_delay < 0)
1018 return CMD_WARNING;
1019 break;
1020
1021 case 'd':
1022 /* Dead Interval */
1023 i++;
1024 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1025 if (vl_config.dead_interval < 0)
1026 return CMD_WARNING;
1027 break;
1028 }
1029 }
1030
1031
1032 /* Action configuration */
1033
paul68980082003-03-25 05:07:42 +00001034 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001035
1036}
1037
paula2c62832003-04-23 17:01:31 +00001038DEFUN (no_ospf_area_vlink,
1039 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001040 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1041 NO_STR
1042 VLINK_HELPSTR_IPADDR)
1043{
paul68980082003-03-25 05:07:42 +00001044 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001045 struct ospf_area *area;
1046 struct ospf_vl_config_data vl_config;
1047 struct ospf_vl_data *vl_data = NULL;
1048 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1049 int i;
1050 int ret, format;
1051
1052 ospf_vl_config_data_init(&vl_config, vty);
1053
1054 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1055 if (ret < 0)
1056 {
1057 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1058 return CMD_WARNING;
1059 }
1060
paul68980082003-03-25 05:07:42 +00001061 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001062 if (!area)
1063 {
1064 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1065 return CMD_WARNING;
1066 }
1067
1068 ret = inet_aton (argv[1], &vl_config.vl_peer);
1069 if (! ret)
1070 {
1071 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1072 VTY_NEWLINE);
1073 return CMD_WARNING;
1074 }
1075
1076 if (argc <=2)
1077 {
1078 /* Basic VLink no command */
1079 /* Thats all folks! - BUGS B. strikes again!!!*/
1080 if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001081 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001082
paul68980082003-03-25 05:07:42 +00001083 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001084
1085 return CMD_SUCCESS;
1086 }
1087
1088 /* If we are down here, we are reseting parameters */
1089
1090 /* Deal with other parameters */
1091 for (i=2; i < argc; i++)
1092 {
paul718e3742002-12-13 20:15:29 +00001093 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1094
1095 switch (argv[i][0])
1096 {
1097
1098 case 'a':
1099 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1100 {
1101 /* authentication-key - this option can occur anywhere on
1102 command line. At start of command line
1103 must check for authentication option. */
1104 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1105 vl_config.auth_key = auth_key;
1106 }
1107 else if (strncmp (argv[i], "authentication", 14) == 0)
1108 {
1109 /* authentication - this option can only occur at start
1110 of command line */
1111 vl_config.auth_type = OSPF_AUTH_NOTSET;
1112 }
1113 break;
1114
1115 case 'm':
1116 /* message-digest-key */
1117 /* Delete one key */
1118 i++;
1119 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1120 if (vl_config.crypto_key_id < 0)
1121 return CMD_WARNING;
1122 vl_config.md5_key = NULL;
1123 break;
1124
1125 case 'h':
1126 /* Hello interval */
1127 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1128 break;
1129
1130 case 'r':
1131 /* Retransmit Interval */
1132 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1133 break;
1134
1135 case 't':
1136 /* Transmit Delay */
1137 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1138 break;
1139
1140 case 'd':
1141 /* Dead Interval */
1142 i++;
1143 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1144 break;
1145 }
1146 }
1147
1148
1149 /* Action configuration */
1150
paul68980082003-03-25 05:07:42 +00001151 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001152}
1153
paula2c62832003-04-23 17:01:31 +00001154ALIAS (ospf_area_vlink,
1155 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001156 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1157 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1158 VLINK_HELPSTR_IPADDR
1159 VLINK_HELPSTR_TIME_PARAM)
1160
paula2c62832003-04-23 17:01:31 +00001161ALIAS (no_ospf_area_vlink,
1162 no_ospf_area_vlink_param1_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 NO_STR
1166 VLINK_HELPSTR_IPADDR
1167 VLINK_HELPSTR_TIME_PARAM)
1168
paula2c62832003-04-23 17:01:31 +00001169ALIAS (ospf_area_vlink,
1170 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001171 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1172 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1173 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1174 VLINK_HELPSTR_IPADDR
1175 VLINK_HELPSTR_TIME_PARAM
1176 VLINK_HELPSTR_TIME_PARAM)
1177
paula2c62832003-04-23 17:01:31 +00001178ALIAS (no_ospf_area_vlink,
1179 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001180 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1181 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1182 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1183 NO_STR
1184 VLINK_HELPSTR_IPADDR
1185 VLINK_HELPSTR_TIME_PARAM
1186 VLINK_HELPSTR_TIME_PARAM)
1187
paula2c62832003-04-23 17:01:31 +00001188ALIAS (ospf_area_vlink,
1189 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001190 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1191 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1192 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1193 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1194 VLINK_HELPSTR_IPADDR
1195 VLINK_HELPSTR_TIME_PARAM
1196 VLINK_HELPSTR_TIME_PARAM
1197 VLINK_HELPSTR_TIME_PARAM)
1198
paula2c62832003-04-23 17:01:31 +00001199ALIAS (no_ospf_area_vlink,
1200 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001201 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1202 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1203 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1204 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1205 NO_STR
1206 VLINK_HELPSTR_IPADDR
1207 VLINK_HELPSTR_TIME_PARAM
1208 VLINK_HELPSTR_TIME_PARAM
1209 VLINK_HELPSTR_TIME_PARAM)
1210
paula2c62832003-04-23 17:01:31 +00001211ALIAS (ospf_area_vlink,
1212 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001213 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1214 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1215 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1216 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1217 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1218 VLINK_HELPSTR_IPADDR
1219 VLINK_HELPSTR_TIME_PARAM
1220 VLINK_HELPSTR_TIME_PARAM
1221 VLINK_HELPSTR_TIME_PARAM
1222 VLINK_HELPSTR_TIME_PARAM)
1223
paula2c62832003-04-23 17:01:31 +00001224ALIAS (no_ospf_area_vlink,
1225 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001226 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1227 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1228 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1229 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1230 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1231 NO_STR
1232 VLINK_HELPSTR_IPADDR
1233 VLINK_HELPSTR_TIME_PARAM
1234 VLINK_HELPSTR_TIME_PARAM
1235 VLINK_HELPSTR_TIME_PARAM
1236 VLINK_HELPSTR_TIME_PARAM)
1237
paula2c62832003-04-23 17:01:31 +00001238ALIAS (ospf_area_vlink,
1239 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001240 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1241 "(authentication|) (message-digest|null)",
1242 VLINK_HELPSTR_IPADDR
1243 VLINK_HELPSTR_AUTHTYPE_ALL)
1244
paula2c62832003-04-23 17:01:31 +00001245ALIAS (ospf_area_vlink,
1246 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001247 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1248 "(authentication|)",
1249 VLINK_HELPSTR_IPADDR
1250 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1251
paula2c62832003-04-23 17:01:31 +00001252ALIAS (no_ospf_area_vlink,
1253 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001254 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1255 "(authentication|)",
1256 NO_STR
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1259
paula2c62832003-04-23 17:01:31 +00001260ALIAS (ospf_area_vlink,
1261 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001262 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1263 "(message-digest-key|) <1-255> md5 KEY",
1264 VLINK_HELPSTR_IPADDR
1265 VLINK_HELPSTR_AUTH_MD5)
1266
paula2c62832003-04-23 17:01:31 +00001267ALIAS (no_ospf_area_vlink,
1268 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001269 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1270 "(message-digest-key|) <1-255>",
1271 NO_STR
1272 VLINK_HELPSTR_IPADDR
1273 VLINK_HELPSTR_AUTH_MD5)
1274
paula2c62832003-04-23 17:01:31 +00001275ALIAS (ospf_area_vlink,
1276 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001277 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1278 "(authentication-key|) AUTH_KEY",
1279 VLINK_HELPSTR_IPADDR
1280 VLINK_HELPSTR_AUTH_SIMPLE)
1281
paula2c62832003-04-23 17:01:31 +00001282ALIAS (no_ospf_area_vlink,
1283 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001284 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1285 "(authentication-key|)",
1286 NO_STR
1287 VLINK_HELPSTR_IPADDR
1288 VLINK_HELPSTR_AUTH_SIMPLE)
1289
paula2c62832003-04-23 17:01:31 +00001290ALIAS (ospf_area_vlink,
1291 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001292 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1293 "(authentication|) (message-digest|null) "
1294 "(authentication-key|) AUTH_KEY",
1295 VLINK_HELPSTR_IPADDR
1296 VLINK_HELPSTR_AUTHTYPE_ALL
1297 VLINK_HELPSTR_AUTH_SIMPLE)
1298
paula2c62832003-04-23 17:01:31 +00001299ALIAS (ospf_area_vlink,
1300 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001301 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1302 "(authentication|) "
1303 "(authentication-key|) AUTH_KEY",
1304 VLINK_HELPSTR_IPADDR
1305 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1306 VLINK_HELPSTR_AUTH_SIMPLE)
1307
paula2c62832003-04-23 17:01:31 +00001308ALIAS (no_ospf_area_vlink,
1309 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001310 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1311 "(authentication|) "
1312 "(authentication-key|)",
1313 NO_STR
1314 VLINK_HELPSTR_IPADDR
1315 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1316 VLINK_HELPSTR_AUTH_SIMPLE)
1317
paula2c62832003-04-23 17:01:31 +00001318ALIAS (ospf_area_vlink,
1319 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001320 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1321 "(authentication|) (message-digest|null) "
1322 "(message-digest-key|) <1-255> md5 KEY",
1323 VLINK_HELPSTR_IPADDR
1324 VLINK_HELPSTR_AUTHTYPE_ALL
1325 VLINK_HELPSTR_AUTH_MD5)
1326
paula2c62832003-04-23 17:01:31 +00001327ALIAS (ospf_area_vlink,
1328 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001329 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1330 "(authentication|) "
1331 "(message-digest-key|) <1-255> md5 KEY",
1332 VLINK_HELPSTR_IPADDR
1333 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1334 VLINK_HELPSTR_AUTH_MD5)
1335
paula2c62832003-04-23 17:01:31 +00001336ALIAS (no_ospf_area_vlink,
1337 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001338 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1339 "(authentication|) "
1340 "(message-digest-key|)",
1341 NO_STR
1342 VLINK_HELPSTR_IPADDR
1343 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1344 VLINK_HELPSTR_AUTH_MD5)
1345
1346
paula2c62832003-04-23 17:01:31 +00001347DEFUN (ospf_area_shortcut,
1348 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001349 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1350 "OSPF area parameters\n"
1351 "OSPF area ID in IP address format\n"
1352 "OSPF area ID as a decimal value\n"
1353 "Configure the area's shortcutting mode\n"
1354 "Set default shortcutting behavior\n"
1355 "Enable shortcutting through the area\n"
1356 "Disable shortcutting through the area\n")
1357{
paul68980082003-03-25 05:07:42 +00001358 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001359 struct ospf_area *area;
1360 struct in_addr area_id;
1361 int mode;
1362 int format;
1363
1364 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1365
paul68980082003-03-25 05:07:42 +00001366 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001367
1368 if (strncmp (argv[1], "de", 2) == 0)
1369 mode = OSPF_SHORTCUT_DEFAULT;
1370 else if (strncmp (argv[1], "di", 2) == 0)
1371 mode = OSPF_SHORTCUT_DISABLE;
1372 else if (strncmp (argv[1], "e", 1) == 0)
1373 mode = OSPF_SHORTCUT_ENABLE;
1374 else
1375 return CMD_WARNING;
1376
paul68980082003-03-25 05:07:42 +00001377 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001378
paul68980082003-03-25 05:07:42 +00001379 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001380 vty_out (vty, "Shortcut area setting will take effect "
1381 "only when the router is configured as Shortcut ABR%s",
1382 VTY_NEWLINE);
1383
1384 return CMD_SUCCESS;
1385}
1386
paula2c62832003-04-23 17:01:31 +00001387DEFUN (no_ospf_area_shortcut,
1388 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001389 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1390 NO_STR
1391 "OSPF area parameters\n"
1392 "OSPF area ID in IP address format\n"
1393 "OSPF area ID as a decimal value\n"
1394 "Deconfigure the area's shortcutting mode\n"
1395 "Deconfigure enabled shortcutting through the area\n"
1396 "Deconfigure disabled shortcutting through the area\n")
1397{
paul68980082003-03-25 05:07:42 +00001398 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001399 struct ospf_area *area;
1400 struct in_addr area_id;
1401 int format;
1402
1403 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1404
paul68980082003-03-25 05:07:42 +00001405 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001406 if (!area)
1407 return CMD_SUCCESS;
1408
paul68980082003-03-25 05:07:42 +00001409 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001410
1411 return CMD_SUCCESS;
1412}
1413
1414
paula2c62832003-04-23 17:01:31 +00001415DEFUN (ospf_area_stub,
1416 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001417 "area (A.B.C.D|<0-4294967295>) stub",
1418 "OSPF area parameters\n"
1419 "OSPF area ID in IP address format\n"
1420 "OSPF area ID as a decimal value\n"
1421 "Configure OSPF area as stub\n")
1422{
1423 struct ospf *ospf = vty->index;
1424 struct in_addr area_id;
1425 int ret, format;
1426
1427 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1428
1429 ret = ospf_area_stub_set (ospf, area_id);
1430 if (ret == 0)
1431 {
1432 vty_out (vty, "First deconfigure all virtual link through this area%s",
1433 VTY_NEWLINE);
1434 return CMD_WARNING;
1435 }
1436
1437 ospf_area_no_summary_unset (ospf, area_id);
1438
1439 return CMD_SUCCESS;
1440}
1441
paula2c62832003-04-23 17:01:31 +00001442DEFUN (ospf_area_stub_no_summary,
1443 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001444 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1445 "OSPF stub parameters\n"
1446 "OSPF area ID in IP address format\n"
1447 "OSPF area ID as a decimal value\n"
1448 "Configure OSPF area as stub\n"
1449 "Do not inject inter-area routes into stub\n")
1450{
1451 struct ospf *ospf = vty->index;
1452 struct in_addr area_id;
1453 int ret, format;
1454
1455 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1456
1457 ret = ospf_area_stub_set (ospf, area_id);
1458 if (ret == 0)
1459 {
paulb0a053b2003-06-22 09:04:47 +00001460 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001461 VTY_NEWLINE);
1462 return CMD_WARNING;
1463 }
1464
1465 ospf_area_no_summary_set (ospf, area_id);
1466
1467 return CMD_SUCCESS;
1468}
1469
paula2c62832003-04-23 17:01:31 +00001470DEFUN (no_ospf_area_stub,
1471 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001472 "no area (A.B.C.D|<0-4294967295>) stub",
1473 NO_STR
1474 "OSPF area parameters\n"
1475 "OSPF area ID in IP address format\n"
1476 "OSPF area ID as a decimal value\n"
1477 "Configure OSPF area as stub\n")
1478{
1479 struct ospf *ospf = vty->index;
1480 struct in_addr area_id;
1481 int format;
1482
1483 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1484
1485 ospf_area_stub_unset (ospf, area_id);
1486 ospf_area_no_summary_unset (ospf, area_id);
1487
1488 return CMD_SUCCESS;
1489}
1490
paula2c62832003-04-23 17:01:31 +00001491DEFUN (no_ospf_area_stub_no_summary,
1492 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001493 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1494 NO_STR
1495 "OSPF area parameters\n"
1496 "OSPF area ID in IP address format\n"
1497 "OSPF area ID as a decimal value\n"
1498 "Configure OSPF area as stub\n"
1499 "Do not inject inter-area routes into area\n")
1500{
1501 struct ospf *ospf = vty->index;
1502 struct in_addr area_id;
1503 int format;
1504
1505 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1506 ospf_area_no_summary_unset (ospf, area_id);
1507
1508 return CMD_SUCCESS;
1509}
1510
paulb0a053b2003-06-22 09:04:47 +00001511int
paul6c835672004-10-11 11:00:30 +00001512ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1513 int nosum)
paul718e3742002-12-13 20:15:29 +00001514{
1515 struct ospf *ospf = vty->index;
1516 struct in_addr area_id;
1517 int ret, format;
1518
1519 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1520
1521 ret = ospf_area_nssa_set (ospf, area_id);
1522 if (ret == 0)
1523 {
1524 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1525 VTY_NEWLINE);
1526 return CMD_WARNING;
1527 }
1528
1529 if (argc > 1)
1530 {
1531 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001532 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001533 OSPF_NSSA_ROLE_CANDIDATE);
1534 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001535 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001536 OSPF_NSSA_ROLE_NEVER);
1537 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001538 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001539 OSPF_NSSA_ROLE_ALWAYS);
1540 }
paulb0a053b2003-06-22 09:04:47 +00001541 else
1542 {
1543 ospf_area_nssa_translator_role_set (ospf, area_id,
1544 OSPF_NSSA_ROLE_CANDIDATE);
1545 }
paul718e3742002-12-13 20:15:29 +00001546
paulb0a053b2003-06-22 09:04:47 +00001547 if (nosum)
paul718e3742002-12-13 20:15:29 +00001548 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001549 else
1550 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001551
paulb0a053b2003-06-22 09:04:47 +00001552 ospf_schedule_abr_task (ospf);
1553
paul718e3742002-12-13 20:15:29 +00001554 return CMD_SUCCESS;
1555}
1556
paulb0a053b2003-06-22 09:04:47 +00001557DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001558 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001559 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001560 "OSPF area parameters\n"
1561 "OSPF area ID in IP address format\n"
1562 "OSPF area ID as a decimal value\n"
1563 "Configure OSPF area as nssa\n"
1564 "Configure NSSA-ABR for translate election (default)\n"
1565 "Configure NSSA-ABR to never translate\n"
1566 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001567 "Do not inject inter-area routes into nssa\n")
1568{
1569 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1570}
paul718e3742002-12-13 20:15:29 +00001571
paulb0a053b2003-06-22 09:04:47 +00001572DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001573 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001574 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
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 "Configure NSSA-ABR for translate election (default)\n"
1580 "Configure NSSA-ABR to never translate\n"
1581 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001582{
1583 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1584}
1585
1586DEFUN (ospf_area_nssa,
1587 ospf_area_nssa_cmd,
1588 "area (A.B.C.D|<0-4294967295>) nssa",
1589 "OSPF area parameters\n"
1590 "OSPF area ID in IP address format\n"
1591 "OSPF area ID as a decimal value\n"
1592 "Configure OSPF area as nssa\n")
1593{
1594 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1595}
paul718e3742002-12-13 20:15:29 +00001596
paula2c62832003-04-23 17:01:31 +00001597DEFUN (ospf_area_nssa_no_summary,
1598 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001599 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1600 "OSPF area parameters\n"
1601 "OSPF area ID in IP address format\n"
1602 "OSPF area ID as a decimal value\n"
1603 "Configure OSPF area as nssa\n"
1604 "Do not inject inter-area routes into nssa\n")
1605{
paulb0a053b2003-06-22 09:04:47 +00001606 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001607}
1608
paula2c62832003-04-23 17:01:31 +00001609DEFUN (no_ospf_area_nssa,
1610 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001611 "no area (A.B.C.D|<0-4294967295>) nssa",
1612 NO_STR
1613 "OSPF area parameters\n"
1614 "OSPF area ID in IP address format\n"
1615 "OSPF area ID as a decimal value\n"
1616 "Configure OSPF area as nssa\n")
1617{
1618 struct ospf *ospf = vty->index;
1619 struct in_addr area_id;
1620 int format;
1621
1622 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1623
1624 ospf_area_nssa_unset (ospf, area_id);
1625 ospf_area_no_summary_unset (ospf, area_id);
1626
paulb0a053b2003-06-22 09:04:47 +00001627 ospf_schedule_abr_task (ospf);
1628
paul718e3742002-12-13 20:15:29 +00001629 return CMD_SUCCESS;
1630}
1631
paula2c62832003-04-23 17:01:31 +00001632DEFUN (no_ospf_area_nssa_no_summary,
1633 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001634 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1635 NO_STR
1636 "OSPF area parameters\n"
1637 "OSPF area ID in IP address format\n"
1638 "OSPF area ID as a decimal value\n"
1639 "Configure OSPF area as nssa\n"
1640 "Do not inject inter-area routes into nssa\n")
1641{
1642 struct ospf *ospf = vty->index;
1643 struct in_addr area_id;
1644 int format;
1645
1646 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1647 ospf_area_no_summary_unset (ospf, area_id);
1648
1649 return CMD_SUCCESS;
1650}
1651
paula2c62832003-04-23 17:01:31 +00001652DEFUN (ospf_area_default_cost,
1653 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001654 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1655 "OSPF area parameters\n"
1656 "OSPF area ID in IP address format\n"
1657 "OSPF area ID as a decimal value\n"
1658 "Set the summary-default cost of a NSSA or stub area\n"
1659 "Stub's advertised default summary cost\n")
1660{
paul68980082003-03-25 05:07:42 +00001661 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001662 struct ospf_area *area;
1663 struct in_addr area_id;
1664 u_int32_t cost;
1665 int format;
1666
1667 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1668 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1669
paul68980082003-03-25 05:07:42 +00001670 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001671
1672 if (area->external_routing == OSPF_AREA_DEFAULT)
1673 {
1674 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1675 return CMD_WARNING;
1676 }
1677
1678 area->default_cost = cost;
1679
1680 return CMD_SUCCESS;
1681}
1682
paula2c62832003-04-23 17:01:31 +00001683DEFUN (no_ospf_area_default_cost,
1684 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001685 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1686 NO_STR
1687 "OSPF area parameters\n"
1688 "OSPF area ID in IP address format\n"
1689 "OSPF area ID as a decimal value\n"
1690 "Set the summary-default cost of a NSSA or stub area\n"
1691 "Stub's advertised default summary cost\n")
1692{
paul68980082003-03-25 05:07:42 +00001693 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001694 struct ospf_area *area;
1695 struct in_addr area_id;
1696 u_int32_t cost;
1697 int format;
1698
1699 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1700 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1701
paul68980082003-03-25 05:07:42 +00001702 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001703 if (area == NULL)
1704 return CMD_SUCCESS;
1705
1706 if (area->external_routing == OSPF_AREA_DEFAULT)
1707 {
1708 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1709 return CMD_WARNING;
1710 }
1711
1712 area->default_cost = 1;
1713
paul68980082003-03-25 05:07:42 +00001714 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001715
1716 return CMD_SUCCESS;
1717}
1718
paula2c62832003-04-23 17:01:31 +00001719DEFUN (ospf_area_export_list,
1720 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001721 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1722 "OSPF area parameters\n"
1723 "OSPF area ID in IP address format\n"
1724 "OSPF area ID as a decimal value\n"
1725 "Set the filter for networks announced to other areas\n"
1726 "Name of the access-list\n")
1727{
paul68980082003-03-25 05:07:42 +00001728 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001729 struct ospf_area *area;
1730 struct in_addr area_id;
1731 int format;
1732
hasso52930762004-04-19 18:26:53 +00001733 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1734
paul68980082003-03-25 05:07:42 +00001735 area = ospf_area_get (ospf, area_id, format);
1736 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001737
1738 return CMD_SUCCESS;
1739}
1740
paula2c62832003-04-23 17:01:31 +00001741DEFUN (no_ospf_area_export_list,
1742 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001743 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1744 NO_STR
1745 "OSPF area parameters\n"
1746 "OSPF area ID in IP address format\n"
1747 "OSPF area ID as a decimal value\n"
1748 "Unset the filter for networks announced to other areas\n"
1749 "Name of the access-list\n")
1750{
paul68980082003-03-25 05:07:42 +00001751 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001752 struct ospf_area *area;
1753 struct in_addr area_id;
1754 int format;
1755
hasso52930762004-04-19 18:26:53 +00001756 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1757
paul68980082003-03-25 05:07:42 +00001758 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001759 if (area == NULL)
1760 return CMD_SUCCESS;
1761
paul68980082003-03-25 05:07:42 +00001762 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001763
1764 return CMD_SUCCESS;
1765}
1766
1767
paula2c62832003-04-23 17:01:31 +00001768DEFUN (ospf_area_import_list,
1769 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001770 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1771 "OSPF area parameters\n"
1772 "OSPF area ID in IP address format\n"
1773 "OSPF area ID as a decimal value\n"
1774 "Set the filter for networks from other areas announced to the specified one\n"
1775 "Name of the access-list\n")
1776{
paul68980082003-03-25 05:07:42 +00001777 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001778 struct ospf_area *area;
1779 struct in_addr area_id;
1780 int format;
1781
hasso52930762004-04-19 18:26:53 +00001782 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1783
paul68980082003-03-25 05:07:42 +00001784 area = ospf_area_get (ospf, area_id, format);
1785 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001786
1787 return CMD_SUCCESS;
1788}
1789
paula2c62832003-04-23 17:01:31 +00001790DEFUN (no_ospf_area_import_list,
1791 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001792 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1793 NO_STR
1794 "OSPF area parameters\n"
1795 "OSPF area ID in IP address format\n"
1796 "OSPF area ID as a decimal value\n"
1797 "Unset the filter for networks announced to other areas\n"
1798 "Name of the access-list\n")
1799{
paul68980082003-03-25 05:07:42 +00001800 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001801 struct ospf_area *area;
1802 struct in_addr area_id;
1803 int format;
1804
hasso52930762004-04-19 18:26:53 +00001805 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1806
paul68980082003-03-25 05:07:42 +00001807 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001808 if (area == NULL)
1809 return CMD_SUCCESS;
1810
paul68980082003-03-25 05:07:42 +00001811 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001812
1813 return CMD_SUCCESS;
1814}
1815
paula2c62832003-04-23 17:01:31 +00001816DEFUN (ospf_area_filter_list,
1817 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001818 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1819 "OSPF area parameters\n"
1820 "OSPF area ID in IP address format\n"
1821 "OSPF area ID as a decimal value\n"
1822 "Filter networks between OSPF areas\n"
1823 "Filter prefixes between OSPF areas\n"
1824 "Name of an IP prefix-list\n"
1825 "Filter networks sent to this area\n"
1826 "Filter networks sent from this area\n")
1827{
paul68980082003-03-25 05:07:42 +00001828 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001829 struct ospf_area *area;
1830 struct in_addr area_id;
1831 struct prefix_list *plist;
1832 int format;
1833
1834 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1835
paul68980082003-03-25 05:07:42 +00001836 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001837 plist = prefix_list_lookup (AFI_IP, argv[1]);
1838 if (strncmp (argv[2], "in", 2) == 0)
1839 {
1840 PREFIX_LIST_IN (area) = plist;
1841 if (PREFIX_NAME_IN (area))
1842 free (PREFIX_NAME_IN (area));
1843
1844 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001845 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001846 }
1847 else
1848 {
1849 PREFIX_LIST_OUT (area) = plist;
1850 if (PREFIX_NAME_OUT (area))
1851 free (PREFIX_NAME_OUT (area));
1852
1853 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001854 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001855 }
1856
1857 return CMD_SUCCESS;
1858}
1859
paula2c62832003-04-23 17:01:31 +00001860DEFUN (no_ospf_area_filter_list,
1861 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001862 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1863 NO_STR
1864 "OSPF area parameters\n"
1865 "OSPF area ID in IP address format\n"
1866 "OSPF area ID as a decimal value\n"
1867 "Filter networks between OSPF areas\n"
1868 "Filter prefixes between OSPF areas\n"
1869 "Name of an IP prefix-list\n"
1870 "Filter networks sent to this area\n"
1871 "Filter networks sent from this area\n")
1872{
paul68980082003-03-25 05:07:42 +00001873 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001874 struct ospf_area *area;
1875 struct in_addr area_id;
1876 struct prefix_list *plist;
1877 int format;
1878
1879 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1880
paul68980082003-03-25 05:07:42 +00001881 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001882 plist = prefix_list_lookup (AFI_IP, argv[1]);
1883 if (strncmp (argv[2], "in", 2) == 0)
1884 {
1885 if (PREFIX_NAME_IN (area))
1886 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1887 return CMD_SUCCESS;
1888
1889 PREFIX_LIST_IN (area) = NULL;
1890 if (PREFIX_NAME_IN (area))
1891 free (PREFIX_NAME_IN (area));
1892
1893 PREFIX_NAME_IN (area) = NULL;
1894
paul68980082003-03-25 05:07:42 +00001895 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001896 }
1897 else
1898 {
1899 if (PREFIX_NAME_OUT (area))
1900 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1901 return CMD_SUCCESS;
1902
1903 PREFIX_LIST_OUT (area) = NULL;
1904 if (PREFIX_NAME_OUT (area))
1905 free (PREFIX_NAME_OUT (area));
1906
1907 PREFIX_NAME_OUT (area) = NULL;
1908
paul68980082003-03-25 05:07:42 +00001909 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001910 }
1911
1912 return CMD_SUCCESS;
1913}
1914
1915
paula2c62832003-04-23 17:01:31 +00001916DEFUN (ospf_area_authentication_message_digest,
1917 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001918 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1919 "OSPF area parameters\n"
1920 "Enable authentication\n"
1921 "Use message-digest authentication\n")
1922{
paul68980082003-03-25 05:07:42 +00001923 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001924 struct ospf_area *area;
1925 struct in_addr area_id;
1926 int format;
1927
1928 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1929
paul68980082003-03-25 05:07:42 +00001930 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001931 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1932
1933 return CMD_SUCCESS;
1934}
1935
paula2c62832003-04-23 17:01:31 +00001936DEFUN (ospf_area_authentication,
1937 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001938 "area (A.B.C.D|<0-4294967295>) authentication",
1939 "OSPF area parameters\n"
1940 "OSPF area ID in IP address format\n"
1941 "OSPF area ID as a decimal value\n"
1942 "Enable authentication\n")
1943{
paul68980082003-03-25 05:07:42 +00001944 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001945 struct ospf_area *area;
1946 struct in_addr area_id;
1947 int format;
1948
1949 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1950
paul68980082003-03-25 05:07:42 +00001951 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001952 area->auth_type = OSPF_AUTH_SIMPLE;
1953
1954 return CMD_SUCCESS;
1955}
1956
paula2c62832003-04-23 17:01:31 +00001957DEFUN (no_ospf_area_authentication,
1958 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001959 "no area (A.B.C.D|<0-4294967295>) authentication",
1960 NO_STR
1961 "OSPF area parameters\n"
1962 "OSPF area ID in IP address format\n"
1963 "OSPF area ID as a decimal value\n"
1964 "Enable authentication\n")
1965{
paul68980082003-03-25 05:07:42 +00001966 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001967 struct ospf_area *area;
1968 struct in_addr area_id;
1969 int format;
1970
1971 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1972
paul68980082003-03-25 05:07:42 +00001973 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001974 if (area == NULL)
1975 return CMD_SUCCESS;
1976
1977 area->auth_type = OSPF_AUTH_NULL;
1978
paul68980082003-03-25 05:07:42 +00001979 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001980
1981 return CMD_SUCCESS;
1982}
1983
1984
1985DEFUN (ospf_abr_type,
1986 ospf_abr_type_cmd,
1987 "ospf abr-type (cisco|ibm|shortcut|standard)",
1988 "OSPF specific commands\n"
1989 "Set OSPF ABR type\n"
1990 "Alternative ABR, cisco implementation\n"
1991 "Alternative ABR, IBM implementation\n"
1992 "Shortcut ABR\n"
1993 "Standard behavior (RFC2328)\n")
1994{
paul68980082003-03-25 05:07:42 +00001995 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001996 u_char abr_type = OSPF_ABR_UNKNOWN;
1997
1998 if (strncmp (argv[0], "c", 1) == 0)
1999 abr_type = OSPF_ABR_CISCO;
2000 else if (strncmp (argv[0], "i", 1) == 0)
2001 abr_type = OSPF_ABR_IBM;
2002 else if (strncmp (argv[0], "sh", 2) == 0)
2003 abr_type = OSPF_ABR_SHORTCUT;
2004 else if (strncmp (argv[0], "st", 2) == 0)
2005 abr_type = OSPF_ABR_STAND;
2006 else
2007 return CMD_WARNING;
2008
2009 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002010 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002011 {
paul68980082003-03-25 05:07:42 +00002012 ospf->abr_type = abr_type;
2013 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002014 }
2015
2016 return CMD_SUCCESS;
2017}
2018
2019DEFUN (no_ospf_abr_type,
2020 no_ospf_abr_type_cmd,
2021 "no ospf abr-type (cisco|ibm|shortcut)",
2022 NO_STR
2023 "OSPF specific commands\n"
2024 "Set OSPF ABR type\n"
2025 "Alternative ABR, cisco implementation\n"
2026 "Alternative ABR, IBM implementation\n"
2027 "Shortcut ABR\n")
2028{
paul68980082003-03-25 05:07:42 +00002029 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002030 u_char abr_type = OSPF_ABR_UNKNOWN;
2031
2032 if (strncmp (argv[0], "c", 1) == 0)
2033 abr_type = OSPF_ABR_CISCO;
2034 else if (strncmp (argv[0], "i", 1) == 0)
2035 abr_type = OSPF_ABR_IBM;
2036 else if (strncmp (argv[0], "s", 1) == 0)
2037 abr_type = OSPF_ABR_SHORTCUT;
2038 else
2039 return CMD_WARNING;
2040
2041 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002042 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002043 {
paul68980082003-03-25 05:07:42 +00002044 ospf->abr_type = OSPF_ABR_STAND;
2045 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002046 }
2047
2048 return CMD_SUCCESS;
2049}
2050
2051DEFUN (ospf_compatible_rfc1583,
2052 ospf_compatible_rfc1583_cmd,
2053 "compatible rfc1583",
2054 "OSPF compatibility list\n"
2055 "compatible with RFC 1583\n")
2056{
2057 struct ospf *ospf = vty->index;
2058
2059 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2060 {
2061 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002062 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002063 }
2064 return CMD_SUCCESS;
2065}
2066
2067DEFUN (no_ospf_compatible_rfc1583,
2068 no_ospf_compatible_rfc1583_cmd,
2069 "no compatible rfc1583",
2070 NO_STR
2071 "OSPF compatibility list\n"
2072 "compatible with RFC 1583\n")
2073{
2074 struct ospf *ospf = vty->index;
2075
2076 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2077 {
2078 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002079 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002080 }
2081 return CMD_SUCCESS;
2082}
2083
2084ALIAS (ospf_compatible_rfc1583,
2085 ospf_rfc1583_flag_cmd,
2086 "ospf rfc1583compatibility",
2087 "OSPF specific commands\n"
2088 "Enable the RFC1583Compatibility flag\n")
2089
2090ALIAS (no_ospf_compatible_rfc1583,
2091 no_ospf_rfc1583_flag_cmd,
2092 "no ospf rfc1583compatibility",
2093 NO_STR
2094 "OSPF specific commands\n"
2095 "Disable the RFC1583Compatibility flag\n")
2096
paula2c62832003-04-23 17:01:31 +00002097DEFUN (ospf_timers_spf,
2098 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002099 "timers spf <0-4294967295> <0-4294967295>",
2100 "Adjust routing timers\n"
2101 "OSPF SPF timers\n"
2102 "Delay between receiving a change to SPF calculation\n"
2103 "Hold time between consecutive SPF calculations\n")
2104{
2105 struct ospf *ospf = vty->index;
2106 u_int32_t delay, hold;
2107
2108 VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]);
2109 VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]);
2110
2111 ospf_timers_spf_set (ospf, delay, hold);
2112
2113 return CMD_SUCCESS;
2114}
2115
paula2c62832003-04-23 17:01:31 +00002116DEFUN (no_ospf_timers_spf,
2117 no_ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002118 "no timers spf",
2119 NO_STR
2120 "Adjust routing timers\n"
2121 "OSPF SPF timers\n")
2122{
paul68980082003-03-25 05:07:42 +00002123 struct ospf *ospf = vty->index;
2124
2125 ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT;
2126 ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002127
2128 return CMD_SUCCESS;
2129}
2130
2131
paula2c62832003-04-23 17:01:31 +00002132DEFUN (ospf_neighbor,
2133 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002134 "neighbor A.B.C.D",
2135 NEIGHBOR_STR
2136 "Neighbor IP address\n")
2137{
2138 struct ospf *ospf = vty->index;
2139 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002140 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2141 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002142
2143 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2144
2145 if (argc > 1)
2146 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2147
2148 if (argc > 2)
2149 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2150
2151 ospf_nbr_nbma_set (ospf, nbr_addr);
2152 if (argc > 1)
2153 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2154 if (argc > 2)
2155 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2156
2157 return CMD_SUCCESS;
2158}
2159
paula2c62832003-04-23 17:01:31 +00002160ALIAS (ospf_neighbor,
2161 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002162 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2163 NEIGHBOR_STR
2164 "Neighbor IP address\n"
2165 "Neighbor Priority\n"
2166 "Priority\n"
2167 "Dead Neighbor Polling interval\n"
2168 "Seconds\n")
2169
paula2c62832003-04-23 17:01:31 +00002170ALIAS (ospf_neighbor,
2171 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002172 "neighbor A.B.C.D priority <0-255>",
2173 NEIGHBOR_STR
2174 "Neighbor IP address\n"
2175 "Neighbor Priority\n"
2176 "Seconds\n")
2177
paula2c62832003-04-23 17:01:31 +00002178DEFUN (ospf_neighbor_poll_interval,
2179 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002180 "neighbor A.B.C.D poll-interval <1-65535>",
2181 NEIGHBOR_STR
2182 "Neighbor IP address\n"
2183 "Dead Neighbor Polling interval\n"
2184 "Seconds\n")
2185{
2186 struct ospf *ospf = vty->index;
2187 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002188 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2189 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002190
2191 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2192
2193 if (argc > 1)
2194 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2195
2196 if (argc > 2)
2197 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2198
2199 ospf_nbr_nbma_set (ospf, nbr_addr);
2200 if (argc > 1)
2201 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2202 if (argc > 2)
2203 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2204
2205 return CMD_SUCCESS;
2206}
2207
paula2c62832003-04-23 17:01:31 +00002208ALIAS (ospf_neighbor_poll_interval,
2209 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002210 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2211 NEIGHBOR_STR
2212 "Neighbor address\n"
2213 "OSPF dead-router polling interval\n"
2214 "Seconds\n"
2215 "OSPF priority of non-broadcast neighbor\n"
2216 "Priority\n")
2217
paula2c62832003-04-23 17:01:31 +00002218DEFUN (no_ospf_neighbor,
2219 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002220 "no neighbor A.B.C.D",
2221 NO_STR
2222 NEIGHBOR_STR
2223 "Neighbor IP address\n")
2224{
2225 struct ospf *ospf = vty->index;
2226 struct in_addr nbr_addr;
2227 int ret;
2228
2229 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2230
2231 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2232
2233 return CMD_SUCCESS;
2234}
2235
paula2c62832003-04-23 17:01:31 +00002236ALIAS (no_ospf_neighbor,
2237 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002238 "no neighbor A.B.C.D priority <0-255>",
2239 NO_STR
2240 NEIGHBOR_STR
2241 "Neighbor IP address\n"
2242 "Neighbor Priority\n"
2243 "Priority\n")
2244
paula2c62832003-04-23 17:01:31 +00002245ALIAS (no_ospf_neighbor,
2246 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002247 "no neighbor A.B.C.D poll-interval <1-65535>",
2248 NO_STR
2249 NEIGHBOR_STR
2250 "Neighbor IP address\n"
2251 "Dead Neighbor Polling interval\n"
2252 "Seconds\n")
2253
paula2c62832003-04-23 17:01:31 +00002254ALIAS (no_ospf_neighbor,
2255 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002256 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2257 NO_STR
2258 NEIGHBOR_STR
2259 "Neighbor IP address\n"
2260 "Neighbor Priority\n"
2261 "Priority\n"
2262 "Dead Neighbor Polling interval\n"
2263 "Seconds\n")
2264
2265
paula2c62832003-04-23 17:01:31 +00002266DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002267 "refresh timer <10-1800>",
2268 "Adjust refresh parameters\n"
2269 "Set refresh timer\n"
2270 "Timer value in seconds\n")
2271{
2272 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002273 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002274
2275 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2276 interval = (interval / 10) * 10;
2277
2278 ospf_timers_refresh_set (ospf, interval);
2279
2280 return CMD_SUCCESS;
2281}
2282
paula2c62832003-04-23 17:01:31 +00002283DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002284 "no refresh timer <10-1800>",
2285 "Adjust refresh parameters\n"
2286 "Unset refresh timer\n"
2287 "Timer value in seconds\n")
2288{
2289 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002290 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002291
2292 if (argc == 1)
2293 {
2294 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2295
2296 if (ospf->lsa_refresh_interval != interval ||
2297 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2298 return CMD_SUCCESS;
2299 }
2300
2301 ospf_timers_refresh_unset (ospf);
2302
2303 return CMD_SUCCESS;
2304}
2305
paula2c62832003-04-23 17:01:31 +00002306ALIAS (no_ospf_refresh_timer,
2307 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002308 "no refresh timer",
2309 "Adjust refresh parameters\n"
2310 "Unset refresh timer\n")
2311
paula2c62832003-04-23 17:01:31 +00002312DEFUN (ospf_auto_cost_reference_bandwidth,
2313 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002314 "auto-cost reference-bandwidth <1-4294967>",
2315 "Calculate OSPF interface cost according to bandwidth\n"
2316 "Use reference bandwidth method to assign OSPF cost\n"
2317 "The reference bandwidth in terms of Mbits per second\n")
2318{
paul68980082003-03-25 05:07:42 +00002319 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002320 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002321 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002322 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002323
2324 refbw = strtol (argv[0], NULL, 10);
2325 if (refbw < 1 || refbw > 4294967)
2326 {
2327 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2328 return CMD_WARNING;
2329 }
2330
2331 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002332 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002333 return CMD_SUCCESS;
2334
paul68980082003-03-25 05:07:42 +00002335 ospf->ref_bandwidth = refbw * 1000;
paul718e3742002-12-13 20:15:29 +00002336 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2337 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2338
paul1eb8ef22005-04-07 07:30:20 +00002339 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2340 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002341
2342 return CMD_SUCCESS;
2343}
2344
paula2c62832003-04-23 17:01:31 +00002345DEFUN (no_ospf_auto_cost_reference_bandwidth,
2346 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002347 "no auto-cost reference-bandwidth",
2348 NO_STR
2349 "Calculate OSPF interface cost according to bandwidth\n"
2350 "Use reference bandwidth method to assign OSPF cost\n")
2351{
paul68980082003-03-25 05:07:42 +00002352 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002353 struct listnode *node, *nnode;
2354 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002355
paul68980082003-03-25 05:07:42 +00002356 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002357 return CMD_SUCCESS;
2358
paul68980082003-03-25 05:07:42 +00002359 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002360 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2361 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2362
paul1eb8ef22005-04-07 07:30:20 +00002363 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2364 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002365
2366 return CMD_SUCCESS;
2367}
2368
hassoeb1ce602004-10-08 08:17:22 +00002369const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002370{
2371 "Unknown",
2372 "Standard (RFC2328)",
2373 "Alternative IBM",
2374 "Alternative Cisco",
2375 "Alternative Shortcut"
2376};
2377
hassoeb1ce602004-10-08 08:17:22 +00002378const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002379{
2380 "Default",
2381 "Enabled",
2382 "Disabled"
2383};
2384
2385
2386
2387void
2388show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2389{
2390 /* Show Area ID. */
2391 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2392
2393 /* Show Area type/mode. */
2394 if (OSPF_IS_AREA_BACKBONE (area))
2395 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2396 else
2397 {
2398 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002399 vty_out (vty, " (Stub%s%s)",
2400 area->no_summary ? ", no summary" : "",
2401 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002402
paulb0a053b2003-06-22 09:04:47 +00002403 else if (area->external_routing == OSPF_AREA_NSSA)
2404 vty_out (vty, " (NSSA%s%s)",
2405 area->no_summary ? ", no summary" : "",
2406 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002407
2408 vty_out (vty, "%s", VTY_NEWLINE);
2409 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002410 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002411 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002412 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002413 }
2414
2415 /* Show number of interfaces. */
2416 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2417 "Active: %d%s", listcount (area->oiflist),
2418 area->act_ints, VTY_NEWLINE);
2419
paul718e3742002-12-13 20:15:29 +00002420 if (area->external_routing == OSPF_AREA_NSSA)
2421 {
2422 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 +00002423 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002424 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2425 VTY_NEWLINE);
2426 else if (area->NSSATranslatorState)
2427 {
2428 vty_out (vty, " We are an ABR and ");
2429 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2430 vty_out (vty, "the NSSA Elected Translator. %s",
2431 VTY_NEWLINE);
2432 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2433 vty_out (vty, "always an NSSA Translator. %s",
2434 VTY_NEWLINE);
2435 }
paul718e3742002-12-13 20:15:29 +00002436 else
paulb0a053b2003-06-22 09:04:47 +00002437 {
2438 vty_out (vty, " We are an ABR, but ");
2439 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2440 vty_out (vty, "not the NSSA Elected Translator. %s",
2441 VTY_NEWLINE);
2442 else
hassoc6b87812004-12-22 13:09:59 +00002443 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002444 VTY_NEWLINE);
2445 }
paul718e3742002-12-13 20:15:29 +00002446 }
paul718e3742002-12-13 20:15:29 +00002447
2448 /* Show number of fully adjacent neighbors. */
2449 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002450 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002451
2452 /* Show authentication type. */
2453 vty_out (vty, " Area has ");
2454 if (area->auth_type == OSPF_AUTH_NULL)
2455 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2456 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2457 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2458 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2459 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2460
2461 if (!OSPF_IS_AREA_BACKBONE (area))
2462 vty_out (vty, " Number of full virtual adjacencies going through"
2463 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2464
2465 /* Show SPF calculation times. */
2466 vty_out (vty, " SPF algorithm executed %d times%s",
2467 area->spf_calculation, VTY_NEWLINE);
2468
2469 /* Show number of LSA. */
2470 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002471 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2472 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2473 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2474 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2475 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2476 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2477 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2478 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2479 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2480 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2481 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2482 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2483 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2484 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2485 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2486#ifdef HAVE_OPAQUE_LSA
2487 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2488 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2489 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2490 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2491 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2492 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2493#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002494 vty_out (vty, "%s", VTY_NEWLINE);
2495}
2496
2497DEFUN (show_ip_ospf,
2498 show_ip_ospf_cmd,
2499 "show ip ospf",
2500 SHOW_STR
2501 IP_STR
2502 "OSPF information\n")
2503{
paul1eb8ef22005-04-07 07:30:20 +00002504 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002505 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002506 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002507
2508 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002509 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002510 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002511 {
2512 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2513 return CMD_SUCCESS;
2514 }
2515
2516 /* Show Router ID. */
2517 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002518 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002519 VTY_NEWLINE);
2520
2521 /* Show capability. */
2522 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2523 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2524 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002525 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002526 "enabled" : "disabled", VTY_NEWLINE);
2527#ifdef HAVE_OPAQUE_LSA
2528 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002529 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002530 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002531 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002532 " (origination blocked)" : "",
2533 VTY_NEWLINE);
2534#endif /* HAVE_OPAQUE_LSA */
2535
2536 /* Show SPF timers. */
2537 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
paul68980082003-03-25 05:07:42 +00002538 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002539
2540 /* Show refresh parameters. */
2541 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002542 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002543
2544 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002545 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002546 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002547 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002548
paul68980082003-03-25 05:07:42 +00002549 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002550 vty_out (vty, " This router is an ASBR "
2551 "(injecting external routing information)%s", VTY_NEWLINE);
2552
2553 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002554 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2555 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2556 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2557#ifdef HAVE_OPAQUE_LSA
2558 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2559 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2560 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2561#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002562 /* Show number of areas attached. */
2563 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002564 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002565
2566 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002567 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2568 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002569
2570 return CMD_SUCCESS;
2571}
2572
2573
ajsfd651fa2005-03-29 16:08:16 +00002574static void
paul68980082003-03-25 05:07:42 +00002575show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2576 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002577{
ajsfd651fa2005-03-29 16:08:16 +00002578 int is_up;
paul718e3742002-12-13 20:15:29 +00002579 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002580 struct route_node *rn;
2581 char buf[9];
2582
paul718e3742002-12-13 20:15:29 +00002583 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002584 vty_out (vty, "%s is %s%s", ifp->name,
2585 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002586 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2587 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2588 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002589
2590 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002591 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002592 {
2593 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2594 return;
2595 }
ajsfd651fa2005-03-29 16:08:16 +00002596 else if (!is_up)
2597 {
2598 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2599 VTY_NEWLINE);
2600 return;
2601 }
2602
paul718e3742002-12-13 20:15:29 +00002603 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2604 {
2605 struct ospf_interface *oi = rn->info;
2606
2607 if (oi == NULL)
2608 continue;
2609
2610 /* Show OSPF interface information. */
2611 vty_out (vty, " Internet Address %s/%d,",
2612 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2613
hasso3fb9cd62004-10-19 19:44:43 +00002614 if (oi->connected->destination)
2615 vty_out (vty, " %s %s,",
2616 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2617 inet_ntoa (oi->connected->destination->u.prefix4));
2618
paul718e3742002-12-13 20:15:29 +00002619 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2620 VTY_NEWLINE);
2621
2622 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002623 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002624 oi->output_cost, VTY_NEWLINE);
2625
2626 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2627 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2628 PRIORITY (oi), VTY_NEWLINE);
2629
2630 /* Show DR information. */
2631 if (DR (oi).s_addr == 0)
2632 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2633 else
2634 {
2635 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2636 if (nbr == NULL)
2637 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2638 else
2639 {
2640 vty_out (vty, " Designated Router (ID) %s,",
2641 inet_ntoa (nbr->router_id));
2642 vty_out (vty, " Interface Address %s%s",
2643 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2644 }
2645 }
2646
2647 /* Show BDR information. */
2648 if (BDR (oi).s_addr == 0)
2649 vty_out (vty, " No backup designated router on this network%s",
2650 VTY_NEWLINE);
2651 else
2652 {
2653 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2654 if (nbr == NULL)
2655 vty_out (vty, " No backup designated router on this network%s",
2656 VTY_NEWLINE);
2657 else
2658 {
2659 vty_out (vty, " Backup Designated Router (ID) %s,",
2660 inet_ntoa (nbr->router_id));
2661 vty_out (vty, " Interface Address %s%s",
2662 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2663 }
2664 }
ajsba6454e2005-02-08 15:37:30 +00002665
2666 vty_out (vty, " Multicast group memberships:");
2667 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2668 vty_out (vty, " OSPFAllRouters");
2669 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2670 vty_out (vty, " OSPFDesignatedRouters");
2671 if (!CHECK_FLAG(oi->multicast_memberships,
2672 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2673 vty_out (vty, " <None>");
2674 vty_out (vty, "%s", VTY_NEWLINE);
2675
paul718e3742002-12-13 20:15:29 +00002676 vty_out (vty, " Timer intervals configured,");
2677 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2678 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2679 OSPF_IF_PARAM (oi, v_wait),
2680 OSPF_IF_PARAM (oi, retransmit_interval),
2681 VTY_NEWLINE);
2682
2683 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2684 vty_out (vty, " Hello due in %s%s",
2685 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2686 else /* OSPF_IF_PASSIVE is set */
2687 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2688
2689 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002690 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002691 VTY_NEWLINE);
2692 }
2693}
2694
2695DEFUN (show_ip_ospf_interface,
2696 show_ip_ospf_interface_cmd,
2697 "show ip ospf interface [INTERFACE]",
2698 SHOW_STR
2699 IP_STR
2700 "OSPF information\n"
2701 "Interface information\n"
2702 "Interface name\n")
2703{
2704 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002705 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002706 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002707
paul020709f2003-04-04 02:44:16 +00002708 ospf = ospf_lookup ();
2709
paul718e3742002-12-13 20:15:29 +00002710 /* Show All Interfaces. */
2711 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00002712 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2713 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002714 /* Interface name is specified. */
2715 else
2716 {
2717 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2718 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2719 else
paul68980082003-03-25 05:07:42 +00002720 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002721 }
2722
2723 return CMD_SUCCESS;
2724}
2725
2726void
2727show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2728{
2729 struct route_node *rn;
2730 struct ospf_neighbor *nbr;
2731 char msgbuf[16];
2732 char timebuf[9];
2733
2734 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2735 if ((nbr = rn->info))
2736 /* Do not show myself. */
2737 if (nbr != oi->nbr_self)
2738 /* Down state is not shown. */
2739 if (nbr->state != NSM_Down)
2740 {
2741 ospf_nbr_state_message (nbr, msgbuf, 16);
2742
2743 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2744 vty_out (vty, "%-15s %3d %-15s %8s ",
2745 "-", nbr->priority,
2746 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2747 else
2748 vty_out (vty, "%-15s %3d %-15s %8s ",
2749 inet_ntoa (nbr->router_id), nbr->priority,
2750 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2751 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2752 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2753 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2754 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2755 VTY_NEWLINE);
2756 }
2757}
2758
2759DEFUN (show_ip_ospf_neighbor,
2760 show_ip_ospf_neighbor_cmd,
2761 "show ip ospf neighbor",
2762 SHOW_STR
2763 IP_STR
2764 "OSPF information\n"
2765 "Neighbor list\n")
2766{
paul020709f2003-04-04 02:44:16 +00002767 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00002768 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00002769 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002770
paul020709f2003-04-04 02:44:16 +00002771 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002772 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002773 {
2774 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2775 return CMD_SUCCESS;
2776 }
2777
2778 /* Show All neighbors. */
2779 vty_out (vty, "%sNeighbor ID Pri State Dead "
2780 "Time Address Interface RXmtL "
2781 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2782
paul1eb8ef22005-04-07 07:30:20 +00002783 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
2784 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00002785
2786 return CMD_SUCCESS;
2787}
2788
2789DEFUN (show_ip_ospf_neighbor_all,
2790 show_ip_ospf_neighbor_all_cmd,
2791 "show ip ospf neighbor all",
2792 SHOW_STR
2793 IP_STR
2794 "OSPF information\n"
2795 "Neighbor list\n"
2796 "include down status neighbor\n")
2797{
paul68980082003-03-25 05:07:42 +00002798 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002799 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002800 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002801
paul68980082003-03-25 05:07:42 +00002802 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002803 {
2804 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2805 return CMD_SUCCESS;
2806 }
2807
2808 /* Show All neighbors. */
2809 vty_out (vty, "%sNeighbor ID Pri State Dead "
2810 "Time Address Interface RXmtL "
2811 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2812
paul1eb8ef22005-04-07 07:30:20 +00002813 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00002814 {
hasso52dc7ee2004-09-23 19:18:23 +00002815 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00002816 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00002817
2818 show_ip_ospf_neighbor_sub (vty, oi);
2819
2820 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00002821 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00002822 {
paul718e3742002-12-13 20:15:29 +00002823 if (nbr_nbma->nbr == NULL
2824 || nbr_nbma->nbr->state == NSM_Down)
2825 {
2826 vty_out (vty, "%-15s %3d %-15s %8s ",
2827 "-", nbr_nbma->priority, "Down", "-");
2828 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2829 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2830 0, 0, 0, VTY_NEWLINE);
2831 }
2832 }
2833 }
2834
2835 return CMD_SUCCESS;
2836}
2837
2838DEFUN (show_ip_ospf_neighbor_int,
2839 show_ip_ospf_neighbor_int_cmd,
2840 "show ip ospf neighbor A.B.C.D",
2841 SHOW_STR
2842 IP_STR
2843 "OSPF information\n"
2844 "Neighbor list\n"
2845 "Interface name\n")
2846{
paul020709f2003-04-04 02:44:16 +00002847 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002848 struct ospf_interface *oi;
2849 struct in_addr addr;
2850 int ret;
2851
paul718e3742002-12-13 20:15:29 +00002852 ret = inet_aton (argv[0], &addr);
2853 if (!ret)
2854 {
2855 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2856 VTY_NEWLINE);
2857 return CMD_WARNING;
2858 }
2859
paul020709f2003-04-04 02:44:16 +00002860 ospf = ospf_lookup ();
2861 if (ospf == NULL)
2862 {
2863 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2864 return CMD_SUCCESS;
2865 }
2866
paul68980082003-03-25 05:07:42 +00002867 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00002868 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2869 else
2870 {
2871 vty_out (vty, "%sNeighbor ID Pri State Dead "
2872 "Time Address Interface RXmtL "
2873 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2874 show_ip_ospf_neighbor_sub (vty, oi);
2875 }
2876
2877 return CMD_SUCCESS;
2878}
2879
2880void
2881show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2882 struct ospf_nbr_nbma *nbr_nbma)
2883{
2884 char timebuf[9];
2885
2886 /* Show neighbor ID. */
2887 vty_out (vty, " Neighbor %s,", "-");
2888
2889 /* Show interface address. */
2890 vty_out (vty, " interface address %s%s",
2891 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2892 /* Show Area ID. */
2893 vty_out (vty, " In the area %s via interface %s%s",
2894 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2895 /* Show neighbor priority and state. */
2896 vty_out (vty, " Neighbor priority is %d, State is %s,",
2897 nbr_nbma->priority, "Down");
2898 /* Show state changes. */
2899 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2900
2901 /* Show PollInterval */
2902 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2903
2904 /* Show poll-interval timer. */
2905 vty_out (vty, " Poll timer due in %s%s",
2906 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2907
2908 /* Show poll-interval timer thread. */
2909 vty_out (vty, " Thread Poll Timer %s%s",
2910 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2911}
2912
2913void
2914show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2915 struct ospf_neighbor *nbr)
2916{
2917 char timebuf[9];
2918
2919 /* Show neighbor ID. */
2920 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2921 vty_out (vty, " Neighbor %s,", "-");
2922 else
2923 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2924
2925 /* Show interface address. */
2926 vty_out (vty, " interface address %s%s",
2927 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2928 /* Show Area ID. */
2929 vty_out (vty, " In the area %s via interface %s%s",
2930 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2931 /* Show neighbor priority and state. */
2932 vty_out (vty, " Neighbor priority is %d, State is %s,",
2933 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2934 /* Show state changes. */
2935 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2936
2937 /* Show Designated Rotuer ID. */
2938 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2939 /* Show Backup Designated Rotuer ID. */
2940 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2941 /* Show options. */
2942 vty_out (vty, " Options %d %s%s", nbr->options,
2943 ospf_options_dump (nbr->options), VTY_NEWLINE);
2944 /* Show Router Dead interval timer. */
2945 vty_out (vty, " Dead timer due in %s%s",
2946 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2947 /* Show Database Summary list. */
2948 vty_out (vty, " Database Summary List %d%s",
2949 ospf_db_summary_count (nbr), VTY_NEWLINE);
2950 /* Show Link State Request list. */
2951 vty_out (vty, " Link State Request List %ld%s",
2952 ospf_ls_request_count (nbr), VTY_NEWLINE);
2953 /* Show Link State Retransmission list. */
2954 vty_out (vty, " Link State Retransmission List %ld%s",
2955 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2956 /* Show inactivity timer thread. */
2957 vty_out (vty, " Thread Inactivity Timer %s%s",
2958 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2959 /* Show Database Description retransmission thread. */
2960 vty_out (vty, " Thread Database Description Retransmision %s%s",
2961 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2962 /* Show Link State Request Retransmission thread. */
2963 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2964 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2965 /* Show Link State Update Retransmission thread. */
2966 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2967 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2968}
2969
2970DEFUN (show_ip_ospf_neighbor_id,
2971 show_ip_ospf_neighbor_id_cmd,
2972 "show ip ospf neighbor A.B.C.D",
2973 SHOW_STR
2974 IP_STR
2975 "OSPF information\n"
2976 "Neighbor list\n"
2977 "Neighbor ID\n")
2978{
paul020709f2003-04-04 02:44:16 +00002979 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002980 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002981 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00002982 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00002983 struct in_addr router_id;
2984 int ret;
2985
2986 ret = inet_aton (argv[0], &router_id);
2987 if (!ret)
2988 {
2989 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
2990 return CMD_WARNING;
2991 }
2992
paul020709f2003-04-04 02:44:16 +00002993 ospf = ospf_lookup ();
2994 if (ospf == NULL)
2995 {
2996 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2997 return CMD_SUCCESS;
2998 }
2999
paul1eb8ef22005-04-07 07:30:20 +00003000 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3001 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3002 {
3003 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3004 return CMD_SUCCESS;
3005 }
paul718e3742002-12-13 20:15:29 +00003006
3007 /* Nothing to show. */
3008 return CMD_SUCCESS;
3009}
3010
3011DEFUN (show_ip_ospf_neighbor_detail,
3012 show_ip_ospf_neighbor_detail_cmd,
3013 "show ip ospf neighbor detail",
3014 SHOW_STR
3015 IP_STR
3016 "OSPF information\n"
3017 "Neighbor list\n"
3018 "detail of all neighbors\n")
3019{
paul020709f2003-04-04 02:44:16 +00003020 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003021 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003022 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003023
paul020709f2003-04-04 02:44:16 +00003024 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003025 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003026 {
3027 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3028 return CMD_SUCCESS;
3029 }
paul718e3742002-12-13 20:15:29 +00003030
paul1eb8ef22005-04-07 07:30:20 +00003031 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003032 {
paul718e3742002-12-13 20:15:29 +00003033 struct route_node *rn;
3034 struct ospf_neighbor *nbr;
3035
3036 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3037 if ((nbr = rn->info))
3038 if (nbr != oi->nbr_self)
3039 if (nbr->state != NSM_Down)
3040 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3041 }
3042
3043 return CMD_SUCCESS;
3044}
3045
3046DEFUN (show_ip_ospf_neighbor_detail_all,
3047 show_ip_ospf_neighbor_detail_all_cmd,
3048 "show ip ospf neighbor detail all",
3049 SHOW_STR
3050 IP_STR
3051 "OSPF information\n"
3052 "Neighbor list\n"
3053 "detail of all neighbors\n"
3054 "include down status neighbor\n")
3055{
paul020709f2003-04-04 02:44:16 +00003056 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003057 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003058 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003059
paul020709f2003-04-04 02:44:16 +00003060 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003061 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003062 {
3063 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3064 return CMD_SUCCESS;
3065 }
paul718e3742002-12-13 20:15:29 +00003066
paul1eb8ef22005-04-07 07:30:20 +00003067 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003068 {
paul718e3742002-12-13 20:15:29 +00003069 struct route_node *rn;
3070 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003071 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003072
3073 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3074 if ((nbr = rn->info))
3075 if (nbr != oi->nbr_self)
3076 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3077 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3078
3079 if (oi->type == OSPF_IFTYPE_NBMA)
3080 {
hasso52dc7ee2004-09-23 19:18:23 +00003081 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003082
paul1eb8ef22005-04-07 07:30:20 +00003083 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3084 if (nbr_nbma->nbr == NULL
3085 || nbr_nbma->nbr->state == NSM_Down)
3086 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003087 }
3088 }
3089
3090 return CMD_SUCCESS;
3091}
3092
3093DEFUN (show_ip_ospf_neighbor_int_detail,
3094 show_ip_ospf_neighbor_int_detail_cmd,
3095 "show ip ospf neighbor A.B.C.D detail",
3096 SHOW_STR
3097 IP_STR
3098 "OSPF information\n"
3099 "Neighbor list\n"
3100 "Interface address\n"
3101 "detail of all neighbors")
3102{
paul020709f2003-04-04 02:44:16 +00003103 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003104 struct ospf_interface *oi;
3105 struct in_addr addr;
3106 int ret;
3107
3108 ret = inet_aton (argv[0], &addr);
3109 if (!ret)
3110 {
3111 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3112 VTY_NEWLINE);
3113 return CMD_WARNING;
3114 }
3115
paul020709f2003-04-04 02:44:16 +00003116 ospf = ospf_lookup ();
3117 if (ospf == NULL)
3118 {
3119 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3120 return CMD_SUCCESS;
3121 }
paul68980082003-03-25 05:07:42 +00003122
paul020709f2003-04-04 02:44:16 +00003123 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00003124 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3125 else
3126 {
3127 struct route_node *rn;
3128 struct ospf_neighbor *nbr;
3129
3130 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3131 if ((nbr = rn->info))
3132 if (nbr != oi->nbr_self)
3133 if (nbr->state != NSM_Down)
3134 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3135 }
3136
3137 return CMD_SUCCESS;
3138}
3139
3140
3141/* Show functions */
3142int
paul020709f2003-04-04 02:44:16 +00003143show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003144{
paul718e3742002-12-13 20:15:29 +00003145 struct router_lsa *rl;
3146 struct summary_lsa *sl;
3147 struct as_external_lsa *asel;
3148 struct prefix_ipv4 p;
3149
3150 if (lsa != NULL)
3151 /* If self option is set, check LSA self flag. */
3152 if (self == 0 || IS_LSA_SELF (lsa))
3153 {
3154 /* LSA common part show. */
3155 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3156 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3157 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3158 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3159 /* LSA specific part show. */
3160 switch (lsa->data->type)
3161 {
3162 case OSPF_ROUTER_LSA:
3163 rl = (struct router_lsa *) lsa->data;
3164 vty_out (vty, " %-d", ntohs (rl->links));
3165 break;
3166 case OSPF_SUMMARY_LSA:
3167 sl = (struct summary_lsa *) lsa->data;
3168
3169 p.family = AF_INET;
3170 p.prefix = sl->header.id;
3171 p.prefixlen = ip_masklen (sl->mask);
3172 apply_mask_ipv4 (&p);
3173
3174 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3175 break;
3176 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003177 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003178 asel = (struct as_external_lsa *) lsa->data;
3179
3180 p.family = AF_INET;
3181 p.prefix = asel->header.id;
3182 p.prefixlen = ip_masklen (asel->mask);
3183 apply_mask_ipv4 (&p);
3184
3185 vty_out (vty, " %s %s/%d [0x%lx]",
3186 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3187 inet_ntoa (p.prefix), p.prefixlen,
3188 (u_long)ntohl (asel->e[0].route_tag));
3189 break;
3190 case OSPF_NETWORK_LSA:
3191 case OSPF_ASBR_SUMMARY_LSA:
3192#ifdef HAVE_OPAQUE_LSA
3193 case OSPF_OPAQUE_LINK_LSA:
3194 case OSPF_OPAQUE_AREA_LSA:
3195 case OSPF_OPAQUE_AS_LSA:
3196#endif /* HAVE_OPAQUE_LSA */
3197 default:
3198 break;
3199 }
3200 vty_out (vty, VTY_NEWLINE);
3201 }
3202
3203 return 0;
3204}
3205
hassoeb1ce602004-10-08 08:17:22 +00003206const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003207{
3208 "unknown",
3209 "Router Link States",
3210 "Net Link States",
3211 "Summary Link States",
3212 "ASBR-Summary Link States",
3213 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003214 "Group Membership LSA",
3215 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003216#ifdef HAVE_OPAQUE_LSA
3217 "Type-8 LSA",
3218 "Link-Local Opaque-LSA",
3219 "Area-Local Opaque-LSA",
3220 "AS-external Opaque-LSA",
3221#endif /* HAVE_OPAQUE_LSA */
3222};
3223
3224#define SHOW_OSPF_COMMON_HEADER \
3225 "Link ID ADV Router Age Seq# CkSum"
3226
hassoeb1ce602004-10-08 08:17:22 +00003227const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003228{
3229 "",
3230 "Link ID ADV Router Age Seq# CkSum Link count",
3231 "Link ID ADV Router Age Seq# CkSum",
3232 "Link ID ADV Router Age Seq# CkSum Route",
3233 "Link ID ADV Router Age Seq# CkSum",
3234 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003235 " --- header for Group Member ----",
3236 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003237#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003238 " --- type-8 ---",
3239 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3240 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3241 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3242#endif /* HAVE_OPAQUE_LSA */
3243};
3244
hassoeb1ce602004-10-08 08:17:22 +00003245const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003246{
3247 "Self-originated",
3248 "Checked",
3249 "Received",
3250 "Approved",
3251 "Discard",
paul4957f492003-06-27 01:28:45 +00003252 "Translated",
paul4957f492003-06-27 01:28:45 +00003253};
3254
paul718e3742002-12-13 20:15:29 +00003255void
3256show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3257{
3258 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003259
paul718e3742002-12-13 20:15:29 +00003260 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003261 vty_out (vty, " Options: 0x%-2x : %s%s",
3262 lsa->data->options,
3263 ospf_options_dump(lsa->data->options),
3264 VTY_NEWLINE);
3265 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003266 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003267 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3268 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003269
3270 if (lsa->data->type == OSPF_ROUTER_LSA)
3271 {
3272 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3273
3274 if (rlsa->flags)
3275 vty_out (vty, " :%s%s%s%s",
3276 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3277 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3278 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3279 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3280
3281 vty_out (vty, "%s", VTY_NEWLINE);
3282 }
3283 vty_out (vty, " LS Type: %s%s",
3284 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3285 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3286 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3287 vty_out (vty, " Advertising Router: %s%s",
3288 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3289 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3290 VTY_NEWLINE);
3291 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3292 VTY_NEWLINE);
3293 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3294}
3295
hassoeb1ce602004-10-08 08:17:22 +00003296const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003297{
3298 "(null)",
3299 "another Router (point-to-point)",
3300 "a Transit Network",
3301 "Stub Network",
3302 "a Virtual Link",
3303};
3304
hassoeb1ce602004-10-08 08:17:22 +00003305const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003306{
3307 "(null)",
3308 "Neighboring Router ID",
3309 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003310 "Net",
paul718e3742002-12-13 20:15:29 +00003311 "Neighboring Router ID",
3312};
3313
hassoeb1ce602004-10-08 08:17:22 +00003314const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003315{
3316 "(null)",
3317 "Router Interface address",
3318 "Router Interface address",
3319 "Network Mask",
3320 "Router Interface address",
3321};
3322
3323/* Show router-LSA each Link information. */
3324void
3325show_ip_ospf_database_router_links (struct vty *vty,
3326 struct router_lsa *rl)
3327{
3328 int len, i, type;
3329
3330 len = ntohs (rl->header.length) - 4;
3331 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3332 {
3333 type = rl->link[i].type;
3334
3335 vty_out (vty, " Link connected to: %s%s",
3336 link_type_desc[type], VTY_NEWLINE);
3337 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3338 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3339 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3340 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3341 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3342 vty_out (vty, " TOS 0 Metric: %d%s",
3343 ntohs (rl->link[i].metric), VTY_NEWLINE);
3344 vty_out (vty, "%s", VTY_NEWLINE);
3345 }
3346}
3347
3348/* Show router-LSA detail information. */
3349int
3350show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3351{
3352 if (lsa != NULL)
3353 {
3354 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3355
3356 show_ip_ospf_database_header (vty, lsa);
3357
3358 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3359 VTY_NEWLINE, VTY_NEWLINE);
3360
3361 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003362 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003363 }
3364
3365 return 0;
3366}
3367
3368/* Show network-LSA detail information. */
3369int
3370show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3371{
3372 int length, i;
3373
3374 if (lsa != NULL)
3375 {
3376 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3377
3378 show_ip_ospf_database_header (vty, lsa);
3379
3380 vty_out (vty, " Network Mask: /%d%s",
3381 ip_masklen (nl->mask), VTY_NEWLINE);
3382
3383 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3384
3385 for (i = 0; length > 0; i++, length -= 4)
3386 vty_out (vty, " Attached Router: %s%s",
3387 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3388
3389 vty_out (vty, "%s", VTY_NEWLINE);
3390 }
3391
3392 return 0;
3393}
3394
3395/* Show summary-LSA detail information. */
3396int
3397show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3398{
3399 if (lsa != NULL)
3400 {
3401 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3402
3403 show_ip_ospf_database_header (vty, lsa);
3404
3405 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3406 VTY_NEWLINE);
3407 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3408 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003409 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003410 }
3411
3412 return 0;
3413}
3414
3415/* Show summary-ASBR-LSA detail information. */
3416int
3417show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3418{
3419 if (lsa != NULL)
3420 {
3421 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3422
3423 show_ip_ospf_database_header (vty, lsa);
3424
3425 vty_out (vty, " Network Mask: /%d%s",
3426 ip_masklen (sl->mask), VTY_NEWLINE);
3427 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3428 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003429 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003430 }
3431
3432 return 0;
3433}
3434
3435/* Show AS-external-LSA detail information. */
3436int
3437show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3438{
3439 if (lsa != NULL)
3440 {
3441 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3442
3443 show_ip_ospf_database_header (vty, lsa);
3444
3445 vty_out (vty, " Network Mask: /%d%s",
3446 ip_masklen (al->mask), VTY_NEWLINE);
3447 vty_out (vty, " Metric Type: %s%s",
3448 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3449 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3450 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3451 vty_out (vty, " Metric: %d%s",
3452 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3453 vty_out (vty, " Forward Address: %s%s",
3454 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3455
3456 vty_out (vty, " External Route Tag: %lu%s%s",
3457 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3458 }
3459
3460 return 0;
3461}
3462
ajs2a42e282004-12-08 18:43:03 +00003463/* N.B. This function currently seems to be unused. */
paul718e3742002-12-13 20:15:29 +00003464int
3465show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3466{
3467 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3468
3469 /* show_ip_ospf_database_header (vty, lsa); */
3470
ajs2a42e282004-12-08 18:43:03 +00003471 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003472 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003473 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003474 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3475 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003476 zlog_debug( " TOS: 0%s", "\n");
3477 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003478 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003479 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003480 inet_ntoa (al->e[0].fwd_addr), "\n");
3481
ajs2a42e282004-12-08 18:43:03 +00003482 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003483 ntohl (al->e[0].route_tag), "\n", "\n");
3484
3485 return 0;
3486}
3487
3488/* Show AS-NSSA-LSA detail information. */
3489int
3490show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3491{
3492 if (lsa != NULL)
3493 {
3494 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3495
3496 show_ip_ospf_database_header (vty, lsa);
3497
3498 vty_out (vty, " Network Mask: /%d%s",
3499 ip_masklen (al->mask), VTY_NEWLINE);
3500 vty_out (vty, " Metric Type: %s%s",
3501 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3502 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3503 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3504 vty_out (vty, " Metric: %d%s",
3505 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3506 vty_out (vty, " NSSA: Forward Address: %s%s",
3507 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3508
3509 vty_out (vty, " External Route Tag: %u%s%s",
3510 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3511 }
3512
3513 return 0;
3514}
3515
paul718e3742002-12-13 20:15:29 +00003516int
3517show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3518{
3519 return 0;
3520}
3521
3522#ifdef HAVE_OPAQUE_LSA
3523int
3524show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3525{
3526 if (lsa != NULL)
3527 {
3528 show_ip_ospf_database_header (vty, lsa);
3529 show_opaque_info_detail (vty, lsa);
3530
3531 vty_out (vty, "%s", VTY_NEWLINE);
3532 }
3533 return 0;
3534}
3535#endif /* HAVE_OPAQUE_LSA */
3536
3537int (*show_function[])(struct vty *, struct ospf_lsa *) =
3538{
3539 NULL,
3540 show_router_lsa_detail,
3541 show_network_lsa_detail,
3542 show_summary_lsa_detail,
3543 show_summary_asbr_lsa_detail,
3544 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003545 show_func_dummy,
3546 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003547#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003548 NULL, /* type-8 */
3549 show_opaque_lsa_detail,
3550 show_opaque_lsa_detail,
3551 show_opaque_lsa_detail,
3552#endif /* HAVE_OPAQUE_LSA */
3553};
3554
3555void
3556show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3557 struct in_addr *adv_router)
3558{
3559 memset (lp, 0, sizeof (struct prefix_ls));
3560 lp->family = 0;
3561 if (id == NULL)
3562 lp->prefixlen = 0;
3563 else if (adv_router == NULL)
3564 {
3565 lp->prefixlen = 32;
3566 lp->id = *id;
3567 }
3568 else
3569 {
3570 lp->prefixlen = 64;
3571 lp->id = *id;
3572 lp->adv_router = *adv_router;
3573 }
3574}
3575
3576void
3577show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3578 struct in_addr *id, struct in_addr *adv_router)
3579{
3580 struct prefix_ls lp;
3581 struct route_node *rn, *start;
3582 struct ospf_lsa *lsa;
3583
3584 show_lsa_prefix_set (vty, &lp, id, adv_router);
3585 start = route_node_get (rt, (struct prefix *) &lp);
3586 if (start)
3587 {
3588 route_lock_node (start);
3589 for (rn = start; rn; rn = route_next_until (rn, start))
3590 if ((lsa = rn->info))
3591 {
paul718e3742002-12-13 20:15:29 +00003592 if (show_function[lsa->data->type] != NULL)
3593 show_function[lsa->data->type] (vty, lsa);
3594 }
3595 route_unlock_node (start);
3596 }
3597}
3598
3599/* Show detail LSA information
3600 -- if id is NULL then show all LSAs. */
3601void
paul020709f2003-04-04 02:44:16 +00003602show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003603 struct in_addr *id, struct in_addr *adv_router)
3604{
hasso52dc7ee2004-09-23 19:18:23 +00003605 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003606 struct ospf_area *area;
3607
paul718e3742002-12-13 20:15:29 +00003608 switch (type)
3609 {
3610 case OSPF_AS_EXTERNAL_LSA:
3611#ifdef HAVE_OPAQUE_LSA
3612 case OSPF_OPAQUE_AS_LSA:
3613#endif /* HAVE_OPAQUE_LSA */
3614 vty_out (vty, " %s %s%s",
3615 show_database_desc[type],
3616 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003617 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003618 break;
3619 default:
paul1eb8ef22005-04-07 07:30:20 +00003620 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003621 {
paul718e3742002-12-13 20:15:29 +00003622 vty_out (vty, "%s %s (Area %s)%s%s",
3623 VTY_NEWLINE, show_database_desc[type],
3624 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3625 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3626 }
3627 break;
3628 }
3629}
3630
3631void
3632show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3633 struct in_addr *adv_router)
3634{
3635 struct route_node *rn;
3636 struct ospf_lsa *lsa;
3637
3638 for (rn = route_top (rt); rn; rn = route_next (rn))
3639 if ((lsa = rn->info))
3640 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3641 {
paul718e3742002-12-13 20:15:29 +00003642 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3643 continue;
paul718e3742002-12-13 20:15:29 +00003644 if (show_function[lsa->data->type] != NULL)
3645 show_function[lsa->data->type] (vty, lsa);
3646 }
3647}
3648
3649/* Show detail LSA information. */
3650void
paul020709f2003-04-04 02:44:16 +00003651show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003652 struct in_addr *adv_router)
3653{
hasso52dc7ee2004-09-23 19:18:23 +00003654 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003655 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00003656
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 vty_out (vty, " %s %s%s",
3664 show_database_desc[type],
3665 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003666 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003667 adv_router);
3668 break;
3669 default:
paul1eb8ef22005-04-07 07:30:20 +00003670 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003671 {
paul718e3742002-12-13 20:15:29 +00003672 vty_out (vty, "%s %s (Area %s)%s%s",
3673 VTY_NEWLINE, show_database_desc[type],
3674 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3675 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3676 adv_router);
3677 }
3678 break;
3679 }
3680}
3681
3682void
paul020709f2003-04-04 02:44:16 +00003683show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003684{
paul020709f2003-04-04 02:44:16 +00003685 struct ospf_lsa *lsa;
3686 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00003687 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00003688 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003689 int type;
3690
paul1eb8ef22005-04-07 07:30:20 +00003691 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00003692 {
paul718e3742002-12-13 20:15:29 +00003693 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3694 {
3695 switch (type)
3696 {
3697 case OSPF_AS_EXTERNAL_LSA:
3698#ifdef HAVE_OPAQUE_LSA
3699 case OSPF_OPAQUE_AS_LSA:
3700#endif /* HAVE_OPAQUE_LSA */
3701 continue;
3702 default:
3703 break;
3704 }
3705 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3706 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3707 {
3708 vty_out (vty, " %s (Area %s)%s%s",
3709 show_database_desc[type],
3710 ospf_area_desc_string (area),
3711 VTY_NEWLINE, VTY_NEWLINE);
3712 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3713
paul020709f2003-04-04 02:44:16 +00003714 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3715 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003716
3717 vty_out (vty, "%s", VTY_NEWLINE);
3718 }
3719 }
3720 }
3721
3722 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3723 {
3724 switch (type)
3725 {
3726 case OSPF_AS_EXTERNAL_LSA:
3727#ifdef HAVE_OPAQUE_LSA
3728 case OSPF_OPAQUE_AS_LSA:
3729#endif /* HAVE_OPAQUE_LSA */
3730 break;;
3731 default:
3732 continue;
3733 }
paul68980082003-03-25 05:07:42 +00003734 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3735 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003736 {
3737 vty_out (vty, " %s%s%s",
3738 show_database_desc[type],
3739 VTY_NEWLINE, VTY_NEWLINE);
3740 vty_out (vty, "%s%s", show_database_header[type],
3741 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003742
3743 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3744 show_lsa_summary (vty, lsa, self);
3745
paul718e3742002-12-13 20:15:29 +00003746 vty_out (vty, "%s", VTY_NEWLINE);
3747 }
3748 }
3749
3750 vty_out (vty, "%s", VTY_NEWLINE);
3751}
3752
3753void
paul020709f2003-04-04 02:44:16 +00003754show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003755{
hasso52dc7ee2004-09-23 19:18:23 +00003756 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003757 struct ospf_lsa *lsa;
3758
3759 vty_out (vty, "%s MaxAge Link States:%s%s",
3760 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3761
paul1eb8ef22005-04-07 07:30:20 +00003762 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
3763 {
3764 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3765 vty_out (vty, "Link State ID: %s%s",
3766 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3767 vty_out (vty, "Advertising Router: %s%s",
3768 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3769 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3770 vty_out (vty, "%s", VTY_NEWLINE);
3771 }
paul718e3742002-12-13 20:15:29 +00003772}
3773
paul718e3742002-12-13 20:15:29 +00003774#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3775#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003776
3777#ifdef HAVE_OPAQUE_LSA
3778#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3779#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3780#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3781#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3782#else /* HAVE_OPAQUE_LSA */
3783#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3784#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3785#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3786#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3787#endif /* HAVE_OPAQUE_LSA */
3788
3789#define OSPF_LSA_TYPES_CMD_STR \
3790 "asbr-summary|external|network|router|summary" \
3791 OSPF_LSA_TYPE_NSSA_CMD_STR \
3792 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3793
3794#define OSPF_LSA_TYPES_DESC \
3795 "ASBR summary link states\n" \
3796 "External link states\n" \
3797 "Network link states\n" \
3798 "Router link states\n" \
3799 "Network summary link states\n" \
3800 OSPF_LSA_TYPE_NSSA_DESC \
3801 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3802 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3803 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3804
3805DEFUN (show_ip_ospf_database,
3806 show_ip_ospf_database_cmd,
3807 "show ip ospf database",
3808 SHOW_STR
3809 IP_STR
3810 "OSPF information\n"
3811 "Database summary\n")
3812{
paul020709f2003-04-04 02:44:16 +00003813 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003814 int type, ret;
3815 struct in_addr id, adv_router;
3816
paul020709f2003-04-04 02:44:16 +00003817 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003818 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003819 return CMD_SUCCESS;
3820
3821 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003822 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003823
3824 /* Show all LSA. */
3825 if (argc == 0)
3826 {
paul020709f2003-04-04 02:44:16 +00003827 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003828 return CMD_SUCCESS;
3829 }
3830
3831 /* Set database type to show. */
3832 if (strncmp (argv[0], "r", 1) == 0)
3833 type = OSPF_ROUTER_LSA;
3834 else if (strncmp (argv[0], "ne", 2) == 0)
3835 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003836 else if (strncmp (argv[0], "ns", 2) == 0)
3837 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003838 else if (strncmp (argv[0], "su", 2) == 0)
3839 type = OSPF_SUMMARY_LSA;
3840 else if (strncmp (argv[0], "a", 1) == 0)
3841 type = OSPF_ASBR_SUMMARY_LSA;
3842 else if (strncmp (argv[0], "e", 1) == 0)
3843 type = OSPF_AS_EXTERNAL_LSA;
3844 else if (strncmp (argv[0], "se", 2) == 0)
3845 {
paul020709f2003-04-04 02:44:16 +00003846 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003847 return CMD_SUCCESS;
3848 }
3849 else if (strncmp (argv[0], "m", 1) == 0)
3850 {
paul020709f2003-04-04 02:44:16 +00003851 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003852 return CMD_SUCCESS;
3853 }
3854#ifdef HAVE_OPAQUE_LSA
3855 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3856 type = OSPF_OPAQUE_LINK_LSA;
3857 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3858 type = OSPF_OPAQUE_AREA_LSA;
3859 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3860 type = OSPF_OPAQUE_AS_LSA;
3861#endif /* HAVE_OPAQUE_LSA */
3862 else
3863 return CMD_WARNING;
3864
3865 /* `show ip ospf database LSA'. */
3866 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003867 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003868 else if (argc >= 2)
3869 {
3870 ret = inet_aton (argv[1], &id);
3871 if (!ret)
3872 return CMD_WARNING;
3873
3874 /* `show ip ospf database LSA ID'. */
3875 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003876 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003877 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3878 else if (argc == 3)
3879 {
3880 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003881 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003882 else
3883 {
3884 ret = inet_aton (argv[2], &adv_router);
3885 if (!ret)
3886 return CMD_WARNING;
3887 }
paul020709f2003-04-04 02:44:16 +00003888 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003889 }
3890 }
3891
3892 return CMD_SUCCESS;
3893}
3894
3895ALIAS (show_ip_ospf_database,
3896 show_ip_ospf_database_type_cmd,
3897 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3898 SHOW_STR
3899 IP_STR
3900 "OSPF information\n"
3901 "Database summary\n"
3902 OSPF_LSA_TYPES_DESC
3903 "LSAs in MaxAge list\n"
3904 "Self-originated link states\n")
3905
3906ALIAS (show_ip_ospf_database,
3907 show_ip_ospf_database_type_id_cmd,
3908 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3909 SHOW_STR
3910 IP_STR
3911 "OSPF information\n"
3912 "Database summary\n"
3913 OSPF_LSA_TYPES_DESC
3914 "Link State ID (as an IP address)\n")
3915
3916ALIAS (show_ip_ospf_database,
3917 show_ip_ospf_database_type_id_adv_router_cmd,
3918 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3919 SHOW_STR
3920 IP_STR
3921 "OSPF information\n"
3922 "Database summary\n"
3923 OSPF_LSA_TYPES_DESC
3924 "Link State ID (as an IP address)\n"
3925 "Advertising Router link states\n"
3926 "Advertising Router (as an IP address)\n")
3927
3928ALIAS (show_ip_ospf_database,
3929 show_ip_ospf_database_type_id_self_cmd,
3930 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3931 SHOW_STR
3932 IP_STR
3933 "OSPF information\n"
3934 "Database summary\n"
3935 OSPF_LSA_TYPES_DESC
3936 "Link State ID (as an IP address)\n"
3937 "Self-originated link states\n"
3938 "\n")
3939
3940DEFUN (show_ip_ospf_database_type_adv_router,
3941 show_ip_ospf_database_type_adv_router_cmd,
3942 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3943 SHOW_STR
3944 IP_STR
3945 "OSPF information\n"
3946 "Database summary\n"
3947 OSPF_LSA_TYPES_DESC
3948 "Advertising Router link states\n"
3949 "Advertising Router (as an IP address)\n")
3950{
paul020709f2003-04-04 02:44:16 +00003951 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003952 int type, ret;
3953 struct in_addr adv_router;
3954
paul020709f2003-04-04 02:44:16 +00003955 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003956 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003957 return CMD_SUCCESS;
3958
3959 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003960 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003961
3962 if (argc != 2)
3963 return CMD_WARNING;
3964
3965 /* Set database type to show. */
3966 if (strncmp (argv[0], "r", 1) == 0)
3967 type = OSPF_ROUTER_LSA;
3968 else if (strncmp (argv[0], "ne", 2) == 0)
3969 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003970 else if (strncmp (argv[0], "ns", 2) == 0)
3971 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003972 else if (strncmp (argv[0], "s", 1) == 0)
3973 type = OSPF_SUMMARY_LSA;
3974 else if (strncmp (argv[0], "a", 1) == 0)
3975 type = OSPF_ASBR_SUMMARY_LSA;
3976 else if (strncmp (argv[0], "e", 1) == 0)
3977 type = OSPF_AS_EXTERNAL_LSA;
3978#ifdef HAVE_OPAQUE_LSA
3979 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3980 type = OSPF_OPAQUE_LINK_LSA;
3981 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3982 type = OSPF_OPAQUE_AREA_LSA;
3983 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3984 type = OSPF_OPAQUE_AS_LSA;
3985#endif /* HAVE_OPAQUE_LSA */
3986 else
3987 return CMD_WARNING;
3988
3989 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
3990 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003991 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003992 else
3993 {
3994 ret = inet_aton (argv[1], &adv_router);
3995 if (!ret)
3996 return CMD_WARNING;
3997 }
3998
paul020709f2003-04-04 02:44:16 +00003999 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004000
4001 return CMD_SUCCESS;
4002}
4003
4004ALIAS (show_ip_ospf_database_type_adv_router,
4005 show_ip_ospf_database_type_self_cmd,
4006 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4007 SHOW_STR
4008 IP_STR
4009 "OSPF information\n"
4010 "Database summary\n"
4011 OSPF_LSA_TYPES_DESC
4012 "Self-originated link states\n")
4013
4014
4015DEFUN (ip_ospf_authentication_args,
4016 ip_ospf_authentication_args_addr_cmd,
4017 "ip ospf authentication (null|message-digest) A.B.C.D",
4018 "IP Information\n"
4019 "OSPF interface commands\n"
4020 "Enable authentication on this interface\n"
4021 "Use null authentication\n"
4022 "Use message-digest authentication\n"
4023 "Address of interface")
4024{
4025 struct interface *ifp;
4026 struct in_addr addr;
4027 int ret;
4028 struct ospf_if_params *params;
4029
4030 ifp = vty->index;
4031 params = IF_DEF_PARAMS (ifp);
4032
4033 if (argc == 2)
4034 {
4035 ret = inet_aton(argv[1], &addr);
4036 if (!ret)
4037 {
4038 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4039 VTY_NEWLINE);
4040 return CMD_WARNING;
4041 }
4042
4043 params = ospf_get_if_params (ifp, addr);
4044 ospf_if_update_params (ifp, addr);
4045 }
4046
4047 /* Handle null authentication */
4048 if ( argv[0][0] == 'n' )
4049 {
4050 SET_IF_PARAM (params, auth_type);
4051 params->auth_type = OSPF_AUTH_NULL;
4052 return CMD_SUCCESS;
4053 }
4054
4055 /* Handle message-digest authentication */
4056 if ( argv[0][0] == 'm' )
4057 {
4058 SET_IF_PARAM (params, auth_type);
4059 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4060 return CMD_SUCCESS;
4061 }
4062
4063 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4064 return CMD_WARNING;
4065}
4066
4067ALIAS (ip_ospf_authentication_args,
4068 ip_ospf_authentication_args_cmd,
4069 "ip ospf authentication (null|message-digest)",
4070 "IP Information\n"
4071 "OSPF interface commands\n"
4072 "Enable authentication on this interface\n"
4073 "Use null authentication\n"
4074 "Use message-digest authentication\n")
4075
4076DEFUN (ip_ospf_authentication,
4077 ip_ospf_authentication_addr_cmd,
4078 "ip ospf authentication A.B.C.D",
4079 "IP Information\n"
4080 "OSPF interface commands\n"
4081 "Enable authentication on this interface\n"
4082 "Address of interface")
4083{
4084 struct interface *ifp;
4085 struct in_addr addr;
4086 int ret;
4087 struct ospf_if_params *params;
4088
4089 ifp = vty->index;
4090 params = IF_DEF_PARAMS (ifp);
4091
4092 if (argc == 1)
4093 {
4094 ret = inet_aton(argv[1], &addr);
4095 if (!ret)
4096 {
4097 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4098 VTY_NEWLINE);
4099 return CMD_WARNING;
4100 }
4101
4102 params = ospf_get_if_params (ifp, addr);
4103 ospf_if_update_params (ifp, addr);
4104 }
4105
4106 SET_IF_PARAM (params, auth_type);
4107 params->auth_type = OSPF_AUTH_SIMPLE;
4108
4109 return CMD_SUCCESS;
4110}
4111
4112ALIAS (ip_ospf_authentication,
4113 ip_ospf_authentication_cmd,
4114 "ip ospf authentication",
4115 "IP Information\n"
4116 "OSPF interface commands\n"
4117 "Enable authentication on this interface\n")
4118
4119DEFUN (no_ip_ospf_authentication,
4120 no_ip_ospf_authentication_addr_cmd,
4121 "no ip ospf authentication A.B.C.D",
4122 NO_STR
4123 "IP Information\n"
4124 "OSPF interface commands\n"
4125 "Enable authentication on this interface\n"
4126 "Address of interface")
4127{
4128 struct interface *ifp;
4129 struct in_addr addr;
4130 int ret;
4131 struct ospf_if_params *params;
4132
4133 ifp = vty->index;
4134 params = IF_DEF_PARAMS (ifp);
4135
4136 if (argc == 1)
4137 {
4138 ret = inet_aton(argv[1], &addr);
4139 if (!ret)
4140 {
4141 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4142 VTY_NEWLINE);
4143 return CMD_WARNING;
4144 }
4145
4146 params = ospf_lookup_if_params (ifp, addr);
4147 if (params == NULL)
4148 return CMD_SUCCESS;
4149 }
4150
4151 params->auth_type = OSPF_AUTH_NOTSET;
4152 UNSET_IF_PARAM (params, auth_type);
4153
4154 if (params != IF_DEF_PARAMS (ifp))
4155 {
4156 ospf_free_if_params (ifp, addr);
4157 ospf_if_update_params (ifp, addr);
4158 }
4159
4160 return CMD_SUCCESS;
4161}
4162
4163ALIAS (no_ip_ospf_authentication,
4164 no_ip_ospf_authentication_cmd,
4165 "no ip ospf authentication",
4166 NO_STR
4167 "IP Information\n"
4168 "OSPF interface commands\n"
4169 "Enable authentication on this interface\n")
4170
4171DEFUN (ip_ospf_authentication_key,
4172 ip_ospf_authentication_key_addr_cmd,
4173 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4174 "IP Information\n"
4175 "OSPF interface commands\n"
4176 "Authentication password (key)\n"
4177 "The OSPF password (key)\n"
4178 "Address of interface")
4179{
4180 struct interface *ifp;
4181 struct in_addr addr;
4182 int ret;
4183 struct ospf_if_params *params;
4184
4185 ifp = vty->index;
4186 params = IF_DEF_PARAMS (ifp);
4187
4188 if (argc == 2)
4189 {
4190 ret = inet_aton(argv[1], &addr);
4191 if (!ret)
4192 {
4193 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4194 VTY_NEWLINE);
4195 return CMD_WARNING;
4196 }
4197
4198 params = ospf_get_if_params (ifp, addr);
4199 ospf_if_update_params (ifp, addr);
4200 }
4201
4202
4203 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004204 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004205 SET_IF_PARAM (params, auth_simple);
4206
4207 return CMD_SUCCESS;
4208}
4209
4210ALIAS (ip_ospf_authentication_key,
4211 ip_ospf_authentication_key_cmd,
4212 "ip ospf authentication-key AUTH_KEY",
4213 "IP Information\n"
4214 "OSPF interface commands\n"
4215 "Authentication password (key)\n"
4216 "The OSPF password (key)")
4217
4218ALIAS (ip_ospf_authentication_key,
4219 ospf_authentication_key_cmd,
4220 "ospf authentication-key AUTH_KEY",
4221 "OSPF interface commands\n"
4222 "Authentication password (key)\n"
4223 "The OSPF password (key)")
4224
4225DEFUN (no_ip_ospf_authentication_key,
4226 no_ip_ospf_authentication_key_addr_cmd,
4227 "no ip ospf authentication-key A.B.C.D",
4228 NO_STR
4229 "IP Information\n"
4230 "OSPF interface commands\n"
4231 "Authentication password (key)\n"
4232 "Address of interface")
4233{
4234 struct interface *ifp;
4235 struct in_addr addr;
4236 int ret;
4237 struct ospf_if_params *params;
4238
4239 ifp = vty->index;
4240 params = IF_DEF_PARAMS (ifp);
4241
4242 if (argc == 2)
4243 {
4244 ret = inet_aton(argv[1], &addr);
4245 if (!ret)
4246 {
4247 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4248 VTY_NEWLINE);
4249 return CMD_WARNING;
4250 }
4251
4252 params = ospf_lookup_if_params (ifp, addr);
4253 if (params == NULL)
4254 return CMD_SUCCESS;
4255 }
4256
4257 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4258 UNSET_IF_PARAM (params, auth_simple);
4259
4260 if (params != IF_DEF_PARAMS (ifp))
4261 {
4262 ospf_free_if_params (ifp, addr);
4263 ospf_if_update_params (ifp, addr);
4264 }
4265
4266 return CMD_SUCCESS;
4267}
4268
4269ALIAS (no_ip_ospf_authentication_key,
4270 no_ip_ospf_authentication_key_cmd,
4271 "no ip ospf authentication-key",
4272 NO_STR
4273 "IP Information\n"
4274 "OSPF interface commands\n"
4275 "Authentication password (key)\n")
4276
4277ALIAS (no_ip_ospf_authentication_key,
4278 no_ospf_authentication_key_cmd,
4279 "no ospf authentication-key",
4280 NO_STR
4281 "OSPF interface commands\n"
4282 "Authentication password (key)\n")
4283
4284DEFUN (ip_ospf_message_digest_key,
4285 ip_ospf_message_digest_key_addr_cmd,
4286 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4287 "IP Information\n"
4288 "OSPF interface commands\n"
4289 "Message digest authentication password (key)\n"
4290 "Key ID\n"
4291 "Use MD5 algorithm\n"
4292 "The OSPF password (key)"
4293 "Address of interface")
4294{
4295 struct interface *ifp;
4296 struct crypt_key *ck;
4297 u_char key_id;
4298 struct in_addr addr;
4299 int ret;
4300 struct ospf_if_params *params;
4301
4302 ifp = vty->index;
4303 params = IF_DEF_PARAMS (ifp);
4304
4305 if (argc == 3)
4306 {
4307 ret = inet_aton(argv[2], &addr);
4308 if (!ret)
4309 {
4310 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4311 VTY_NEWLINE);
4312 return CMD_WARNING;
4313 }
4314
4315 params = ospf_get_if_params (ifp, addr);
4316 ospf_if_update_params (ifp, addr);
4317 }
4318
4319 key_id = strtol (argv[0], NULL, 10);
4320 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4321 {
4322 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4323 return CMD_WARNING;
4324 }
4325
4326 ck = ospf_crypt_key_new ();
4327 ck->key_id = (u_char) key_id;
4328 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004329 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004330
4331 ospf_crypt_key_add (params->auth_crypt, ck);
4332 SET_IF_PARAM (params, auth_crypt);
4333
4334 return CMD_SUCCESS;
4335}
4336
4337ALIAS (ip_ospf_message_digest_key,
4338 ip_ospf_message_digest_key_cmd,
4339 "ip ospf message-digest-key <1-255> md5 KEY",
4340 "IP Information\n"
4341 "OSPF interface commands\n"
4342 "Message digest authentication password (key)\n"
4343 "Key ID\n"
4344 "Use MD5 algorithm\n"
4345 "The OSPF password (key)")
4346
4347ALIAS (ip_ospf_message_digest_key,
4348 ospf_message_digest_key_cmd,
4349 "ospf message-digest-key <1-255> md5 KEY",
4350 "OSPF interface commands\n"
4351 "Message digest authentication password (key)\n"
4352 "Key ID\n"
4353 "Use MD5 algorithm\n"
4354 "The OSPF password (key)")
4355
4356DEFUN (no_ip_ospf_message_digest_key,
4357 no_ip_ospf_message_digest_key_addr_cmd,
4358 "no ip ospf message-digest-key <1-255> A.B.C.D",
4359 NO_STR
4360 "IP Information\n"
4361 "OSPF interface commands\n"
4362 "Message digest authentication password (key)\n"
4363 "Key ID\n"
4364 "Address of interface")
4365{
4366 struct interface *ifp;
4367 struct crypt_key *ck;
4368 int key_id;
4369 struct in_addr addr;
4370 int ret;
4371 struct ospf_if_params *params;
4372
4373 ifp = vty->index;
4374 params = IF_DEF_PARAMS (ifp);
4375
4376 if (argc == 2)
4377 {
4378 ret = inet_aton(argv[1], &addr);
4379 if (!ret)
4380 {
4381 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4382 VTY_NEWLINE);
4383 return CMD_WARNING;
4384 }
4385
4386 params = ospf_lookup_if_params (ifp, addr);
4387 if (params == NULL)
4388 return CMD_SUCCESS;
4389 }
4390
4391 key_id = strtol (argv[0], NULL, 10);
4392 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4393 if (ck == NULL)
4394 {
4395 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4396 return CMD_WARNING;
4397 }
4398
4399 ospf_crypt_key_delete (params->auth_crypt, key_id);
4400
4401 if (params != IF_DEF_PARAMS (ifp))
4402 {
4403 ospf_free_if_params (ifp, addr);
4404 ospf_if_update_params (ifp, addr);
4405 }
4406
4407 return CMD_SUCCESS;
4408}
4409
4410ALIAS (no_ip_ospf_message_digest_key,
4411 no_ip_ospf_message_digest_key_cmd,
4412 "no ip ospf message-digest-key <1-255>",
4413 NO_STR
4414 "IP Information\n"
4415 "OSPF interface commands\n"
4416 "Message digest authentication password (key)\n"
4417 "Key ID\n")
4418
4419ALIAS (no_ip_ospf_message_digest_key,
4420 no_ospf_message_digest_key_cmd,
4421 "no ospf message-digest-key <1-255>",
4422 NO_STR
4423 "OSPF interface commands\n"
4424 "Message digest authentication password (key)\n"
4425 "Key ID\n")
4426
4427DEFUN (ip_ospf_cost,
4428 ip_ospf_cost_addr_cmd,
4429 "ip ospf cost <1-65535> A.B.C.D",
4430 "IP Information\n"
4431 "OSPF interface commands\n"
4432 "Interface cost\n"
4433 "Cost\n"
4434 "Address of interface")
4435{
4436 struct interface *ifp = vty->index;
4437 u_int32_t cost;
4438 struct in_addr addr;
4439 int ret;
4440 struct ospf_if_params *params;
4441
4442 params = IF_DEF_PARAMS (ifp);
4443
4444 cost = strtol (argv[0], NULL, 10);
4445
4446 /* cost range is <1-65535>. */
4447 if (cost < 1 || cost > 65535)
4448 {
4449 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4450 return CMD_WARNING;
4451 }
4452
4453 if (argc == 2)
4454 {
4455 ret = inet_aton(argv[1], &addr);
4456 if (!ret)
4457 {
4458 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4459 VTY_NEWLINE);
4460 return CMD_WARNING;
4461 }
4462
4463 params = ospf_get_if_params (ifp, addr);
4464 ospf_if_update_params (ifp, addr);
4465 }
4466
4467 SET_IF_PARAM (params, output_cost_cmd);
4468 params->output_cost_cmd = cost;
4469
4470 ospf_if_recalculate_output_cost (ifp);
4471
4472 return CMD_SUCCESS;
4473}
4474
4475ALIAS (ip_ospf_cost,
4476 ip_ospf_cost_cmd,
4477 "ip ospf cost <1-65535>",
4478 "IP Information\n"
4479 "OSPF interface commands\n"
4480 "Interface cost\n"
4481 "Cost")
4482
4483ALIAS (ip_ospf_cost,
4484 ospf_cost_cmd,
4485 "ospf cost <1-65535>",
4486 "OSPF interface commands\n"
4487 "Interface cost\n"
4488 "Cost")
4489
4490DEFUN (no_ip_ospf_cost,
4491 no_ip_ospf_cost_addr_cmd,
4492 "no ip ospf cost A.B.C.D",
4493 NO_STR
4494 "IP Information\n"
4495 "OSPF interface commands\n"
4496 "Interface cost\n"
4497 "Address of interface")
4498{
4499 struct interface *ifp = vty->index;
4500 struct in_addr addr;
4501 int ret;
4502 struct ospf_if_params *params;
4503
4504 ifp = vty->index;
4505 params = IF_DEF_PARAMS (ifp);
4506
4507 if (argc == 1)
4508 {
4509 ret = inet_aton(argv[0], &addr);
4510 if (!ret)
4511 {
4512 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4513 VTY_NEWLINE);
4514 return CMD_WARNING;
4515 }
4516
4517 params = ospf_lookup_if_params (ifp, addr);
4518 if (params == NULL)
4519 return CMD_SUCCESS;
4520 }
4521
4522 UNSET_IF_PARAM (params, output_cost_cmd);
4523
4524 if (params != IF_DEF_PARAMS (ifp))
4525 {
4526 ospf_free_if_params (ifp, addr);
4527 ospf_if_update_params (ifp, addr);
4528 }
4529
4530 ospf_if_recalculate_output_cost (ifp);
4531
4532 return CMD_SUCCESS;
4533}
4534
4535ALIAS (no_ip_ospf_cost,
4536 no_ip_ospf_cost_cmd,
4537 "no ip ospf cost",
4538 NO_STR
4539 "IP Information\n"
4540 "OSPF interface commands\n"
4541 "Interface cost\n")
4542
4543ALIAS (no_ip_ospf_cost,
4544 no_ospf_cost_cmd,
4545 "no ospf cost",
4546 NO_STR
4547 "OSPF interface commands\n"
4548 "Interface cost\n")
4549
4550void
4551ospf_nbr_timer_update (struct ospf_interface *oi)
4552{
4553 struct route_node *rn;
4554 struct ospf_neighbor *nbr;
4555
4556 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4557 if ((nbr = rn->info))
4558 {
4559 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4560 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4561 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4562 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4563 }
4564}
4565
4566DEFUN (ip_ospf_dead_interval,
4567 ip_ospf_dead_interval_addr_cmd,
4568 "ip ospf dead-interval <1-65535> A.B.C.D",
4569 "IP Information\n"
4570 "OSPF interface commands\n"
4571 "Interval after which a neighbor is declared dead\n"
4572 "Seconds\n"
4573 "Address of interface")
4574{
4575 struct interface *ifp = vty->index;
4576 u_int32_t seconds;
4577 struct in_addr addr;
4578 int ret;
4579 struct ospf_if_params *params;
4580 struct ospf_interface *oi;
4581 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004582 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004583
paul020709f2003-04-04 02:44:16 +00004584 ospf = ospf_lookup ();
4585
paul718e3742002-12-13 20:15:29 +00004586 params = IF_DEF_PARAMS (ifp);
4587
4588 seconds = strtol (argv[0], NULL, 10);
4589
4590 /* dead_interval range is <1-65535>. */
4591 if (seconds < 1 || seconds > 65535)
4592 {
4593 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4594 return CMD_WARNING;
4595 }
4596
4597 if (argc == 2)
4598 {
4599 ret = inet_aton(argv[1], &addr);
4600 if (!ret)
4601 {
4602 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4603 VTY_NEWLINE);
4604 return CMD_WARNING;
4605 }
4606
4607 params = ospf_get_if_params (ifp, addr);
4608 ospf_if_update_params (ifp, addr);
4609 }
4610
4611 SET_IF_PARAM (params, v_wait);
4612 params->v_wait = seconds;
4613
4614 /* Update timer values in neighbor structure. */
4615 if (argc == 2)
4616 {
paul68980082003-03-25 05:07:42 +00004617 if (ospf)
4618 {
4619 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4620 if (oi)
4621 ospf_nbr_timer_update (oi);
4622 }
paul718e3742002-12-13 20:15:29 +00004623 }
4624 else
4625 {
4626 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4627 if ((oi = rn->info))
4628 ospf_nbr_timer_update (oi);
4629 }
4630
4631 return CMD_SUCCESS;
4632}
4633
4634ALIAS (ip_ospf_dead_interval,
4635 ip_ospf_dead_interval_cmd,
4636 "ip ospf dead-interval <1-65535>",
4637 "IP Information\n"
4638 "OSPF interface commands\n"
4639 "Interval after which a neighbor is declared dead\n"
4640 "Seconds\n")
4641
4642ALIAS (ip_ospf_dead_interval,
4643 ospf_dead_interval_cmd,
4644 "ospf dead-interval <1-65535>",
4645 "OSPF interface commands\n"
4646 "Interval after which a neighbor is declared dead\n"
4647 "Seconds\n")
4648
4649DEFUN (no_ip_ospf_dead_interval,
4650 no_ip_ospf_dead_interval_addr_cmd,
4651 "no ip ospf dead-interval A.B.C.D",
4652 NO_STR
4653 "IP Information\n"
4654 "OSPF interface commands\n"
4655 "Interval after which a neighbor is declared dead\n"
4656 "Address of interface")
4657{
4658 struct interface *ifp = vty->index;
4659 struct in_addr addr;
4660 int ret;
4661 struct ospf_if_params *params;
4662 struct ospf_interface *oi;
4663 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004664 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004665
paul020709f2003-04-04 02:44:16 +00004666 ospf = ospf_lookup ();
4667
paul718e3742002-12-13 20:15:29 +00004668 ifp = vty->index;
4669 params = IF_DEF_PARAMS (ifp);
4670
4671 if (argc == 1)
4672 {
4673 ret = inet_aton(argv[0], &addr);
4674 if (!ret)
4675 {
4676 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4677 VTY_NEWLINE);
4678 return CMD_WARNING;
4679 }
4680
4681 params = ospf_lookup_if_params (ifp, addr);
4682 if (params == NULL)
4683 return CMD_SUCCESS;
4684 }
4685
4686 UNSET_IF_PARAM (params, v_wait);
4687 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4688
4689 if (params != IF_DEF_PARAMS (ifp))
4690 {
4691 ospf_free_if_params (ifp, addr);
4692 ospf_if_update_params (ifp, addr);
4693 }
4694
4695 /* Update timer values in neighbor structure. */
4696 if (argc == 1)
4697 {
paul68980082003-03-25 05:07:42 +00004698 if (ospf)
4699 {
4700 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4701 if (oi)
4702 ospf_nbr_timer_update (oi);
4703 }
paul718e3742002-12-13 20:15:29 +00004704 }
4705 else
4706 {
4707 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4708 if ((oi = rn->info))
4709 ospf_nbr_timer_update (oi);
4710 }
4711
4712 return CMD_SUCCESS;
4713}
4714
4715ALIAS (no_ip_ospf_dead_interval,
4716 no_ip_ospf_dead_interval_cmd,
4717 "no ip ospf dead-interval",
4718 NO_STR
4719 "IP Information\n"
4720 "OSPF interface commands\n"
4721 "Interval after which a neighbor is declared dead\n")
4722
4723ALIAS (no_ip_ospf_dead_interval,
4724 no_ospf_dead_interval_cmd,
4725 "no ospf dead-interval",
4726 NO_STR
4727 "OSPF interface commands\n"
4728 "Interval after which a neighbor is declared dead\n")
4729
4730DEFUN (ip_ospf_hello_interval,
4731 ip_ospf_hello_interval_addr_cmd,
4732 "ip ospf hello-interval <1-65535> A.B.C.D",
4733 "IP Information\n"
4734 "OSPF interface commands\n"
4735 "Time between HELLO packets\n"
4736 "Seconds\n"
4737 "Address of interface")
4738{
4739 struct interface *ifp = vty->index;
4740 u_int32_t seconds;
4741 struct in_addr addr;
4742 int ret;
4743 struct ospf_if_params *params;
4744
4745 params = IF_DEF_PARAMS (ifp);
4746
4747 seconds = strtol (argv[0], NULL, 10);
4748
4749 /* HelloInterval range is <1-65535>. */
4750 if (seconds < 1 || seconds > 65535)
4751 {
4752 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4753 return CMD_WARNING;
4754 }
4755
4756 if (argc == 2)
4757 {
4758 ret = inet_aton(argv[1], &addr);
4759 if (!ret)
4760 {
4761 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4762 VTY_NEWLINE);
4763 return CMD_WARNING;
4764 }
4765
4766 params = ospf_get_if_params (ifp, addr);
4767 ospf_if_update_params (ifp, addr);
4768 }
4769
4770 SET_IF_PARAM (params, v_hello);
4771 params->v_hello = seconds;
4772
4773 return CMD_SUCCESS;
4774}
4775
4776ALIAS (ip_ospf_hello_interval,
4777 ip_ospf_hello_interval_cmd,
4778 "ip ospf hello-interval <1-65535>",
4779 "IP Information\n"
4780 "OSPF interface commands\n"
4781 "Time between HELLO packets\n"
4782 "Seconds\n")
4783
4784ALIAS (ip_ospf_hello_interval,
4785 ospf_hello_interval_cmd,
4786 "ospf hello-interval <1-65535>",
4787 "OSPF interface commands\n"
4788 "Time between HELLO packets\n"
4789 "Seconds\n")
4790
4791DEFUN (no_ip_ospf_hello_interval,
4792 no_ip_ospf_hello_interval_addr_cmd,
4793 "no ip ospf hello-interval A.B.C.D",
4794 NO_STR
4795 "IP Information\n"
4796 "OSPF interface commands\n"
4797 "Time between HELLO packets\n"
4798 "Address of interface")
4799{
4800 struct interface *ifp = vty->index;
4801 struct in_addr addr;
4802 int ret;
4803 struct ospf_if_params *params;
4804
4805 ifp = vty->index;
4806 params = IF_DEF_PARAMS (ifp);
4807
4808 if (argc == 1)
4809 {
4810 ret = inet_aton(argv[0], &addr);
4811 if (!ret)
4812 {
4813 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4814 VTY_NEWLINE);
4815 return CMD_WARNING;
4816 }
4817
4818 params = ospf_lookup_if_params (ifp, addr);
4819 if (params == NULL)
4820 return CMD_SUCCESS;
4821 }
4822
4823 UNSET_IF_PARAM (params, v_hello);
4824 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4825
4826 if (params != IF_DEF_PARAMS (ifp))
4827 {
4828 ospf_free_if_params (ifp, addr);
4829 ospf_if_update_params (ifp, addr);
4830 }
4831
4832 return CMD_SUCCESS;
4833}
4834
4835ALIAS (no_ip_ospf_hello_interval,
4836 no_ip_ospf_hello_interval_cmd,
4837 "no ip ospf hello-interval",
4838 NO_STR
4839 "IP Information\n"
4840 "OSPF interface commands\n"
4841 "Time between HELLO packets\n")
4842
4843ALIAS (no_ip_ospf_hello_interval,
4844 no_ospf_hello_interval_cmd,
4845 "no ospf hello-interval",
4846 NO_STR
4847 "OSPF interface commands\n"
4848 "Time between HELLO packets\n")
4849
4850DEFUN (ip_ospf_network,
4851 ip_ospf_network_cmd,
4852 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4853 "IP Information\n"
4854 "OSPF interface commands\n"
4855 "Network type\n"
4856 "Specify OSPF broadcast multi-access network\n"
4857 "Specify OSPF NBMA network\n"
4858 "Specify OSPF point-to-multipoint network\n"
4859 "Specify OSPF point-to-point network\n")
4860{
4861 struct interface *ifp = vty->index;
4862 int old_type = IF_DEF_PARAMS (ifp)->type;
4863 struct route_node *rn;
4864
4865 if (strncmp (argv[0], "b", 1) == 0)
4866 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4867 else if (strncmp (argv[0], "n", 1) == 0)
4868 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4869 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4870 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4871 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4872 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4873
4874 if (IF_DEF_PARAMS (ifp)->type == old_type)
4875 return CMD_SUCCESS;
4876
4877 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4878
4879 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4880 {
4881 struct ospf_interface *oi = rn->info;
4882
4883 if (!oi)
4884 continue;
4885
4886 oi->type = IF_DEF_PARAMS (ifp)->type;
4887
4888 if (oi->state > ISM_Down)
4889 {
4890 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4891 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4892 }
4893 }
4894
4895 return CMD_SUCCESS;
4896}
4897
4898ALIAS (ip_ospf_network,
4899 ospf_network_cmd,
4900 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4901 "OSPF interface commands\n"
4902 "Network type\n"
4903 "Specify OSPF broadcast multi-access network\n"
4904 "Specify OSPF NBMA network\n"
4905 "Specify OSPF point-to-multipoint network\n"
4906 "Specify OSPF point-to-point network\n")
4907
4908DEFUN (no_ip_ospf_network,
4909 no_ip_ospf_network_cmd,
4910 "no ip ospf network",
4911 NO_STR
4912 "IP Information\n"
4913 "OSPF interface commands\n"
4914 "Network type\n")
4915{
4916 struct interface *ifp = vty->index;
4917 int old_type = IF_DEF_PARAMS (ifp)->type;
4918 struct route_node *rn;
4919
ajsbc18d612004-12-15 15:07:19 +00004920 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00004921
4922 if (IF_DEF_PARAMS (ifp)->type == old_type)
4923 return CMD_SUCCESS;
4924
4925 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4926 {
4927 struct ospf_interface *oi = rn->info;
4928
4929 if (!oi)
4930 continue;
4931
4932 oi->type = IF_DEF_PARAMS (ifp)->type;
4933
4934 if (oi->state > ISM_Down)
4935 {
4936 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4937 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4938 }
4939 }
4940
4941 return CMD_SUCCESS;
4942}
4943
4944ALIAS (no_ip_ospf_network,
4945 no_ospf_network_cmd,
4946 "no ospf network",
4947 NO_STR
4948 "OSPF interface commands\n"
4949 "Network type\n")
4950
4951DEFUN (ip_ospf_priority,
4952 ip_ospf_priority_addr_cmd,
4953 "ip ospf priority <0-255> A.B.C.D",
4954 "IP Information\n"
4955 "OSPF interface commands\n"
4956 "Router priority\n"
4957 "Priority\n"
4958 "Address of interface")
4959{
4960 struct interface *ifp = vty->index;
4961 u_int32_t priority;
4962 struct route_node *rn;
4963 struct in_addr addr;
4964 int ret;
4965 struct ospf_if_params *params;
4966
4967 params = IF_DEF_PARAMS (ifp);
4968
4969 priority = strtol (argv[0], NULL, 10);
4970
4971 /* Router Priority range is <0-255>. */
4972 if (priority < 0 || priority > 255)
4973 {
4974 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4975 return CMD_WARNING;
4976 }
4977
4978 if (argc == 2)
4979 {
4980 ret = inet_aton(argv[1], &addr);
4981 if (!ret)
4982 {
4983 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4984 VTY_NEWLINE);
4985 return CMD_WARNING;
4986 }
4987
4988 params = ospf_get_if_params (ifp, addr);
4989 ospf_if_update_params (ifp, addr);
4990 }
4991
4992 SET_IF_PARAM (params, priority);
4993 params->priority = priority;
4994
4995 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4996 {
4997 struct ospf_interface *oi = rn->info;
4998
4999 if (!oi)
5000 continue;
5001
5002
5003 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5004 {
5005 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5006 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5007 }
5008 }
5009
5010 return CMD_SUCCESS;
5011}
5012
5013ALIAS (ip_ospf_priority,
5014 ip_ospf_priority_cmd,
5015 "ip ospf priority <0-255>",
5016 "IP Information\n"
5017 "OSPF interface commands\n"
5018 "Router priority\n"
5019 "Priority\n")
5020
5021ALIAS (ip_ospf_priority,
5022 ospf_priority_cmd,
5023 "ospf priority <0-255>",
5024 "OSPF interface commands\n"
5025 "Router priority\n"
5026 "Priority\n")
5027
5028DEFUN (no_ip_ospf_priority,
5029 no_ip_ospf_priority_addr_cmd,
5030 "no ip ospf priority A.B.C.D",
5031 NO_STR
5032 "IP Information\n"
5033 "OSPF interface commands\n"
5034 "Router priority\n"
5035 "Address of interface")
5036{
5037 struct interface *ifp = vty->index;
5038 struct route_node *rn;
5039 struct in_addr addr;
5040 int ret;
5041 struct ospf_if_params *params;
5042
5043 ifp = vty->index;
5044 params = IF_DEF_PARAMS (ifp);
5045
5046 if (argc == 1)
5047 {
5048 ret = inet_aton(argv[0], &addr);
5049 if (!ret)
5050 {
5051 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5052 VTY_NEWLINE);
5053 return CMD_WARNING;
5054 }
5055
5056 params = ospf_lookup_if_params (ifp, addr);
5057 if (params == NULL)
5058 return CMD_SUCCESS;
5059 }
5060
5061 UNSET_IF_PARAM (params, priority);
5062 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5063
5064 if (params != IF_DEF_PARAMS (ifp))
5065 {
5066 ospf_free_if_params (ifp, addr);
5067 ospf_if_update_params (ifp, addr);
5068 }
5069
5070 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5071 {
5072 struct ospf_interface *oi = rn->info;
5073
5074 if (!oi)
5075 continue;
5076
5077
5078 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5079 {
5080 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5081 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5082 }
5083 }
5084
5085 return CMD_SUCCESS;
5086}
5087
5088ALIAS (no_ip_ospf_priority,
5089 no_ip_ospf_priority_cmd,
5090 "no ip ospf priority",
5091 NO_STR
5092 "IP Information\n"
5093 "OSPF interface commands\n"
5094 "Router priority\n")
5095
5096ALIAS (no_ip_ospf_priority,
5097 no_ospf_priority_cmd,
5098 "no ospf priority",
5099 NO_STR
5100 "OSPF interface commands\n"
5101 "Router priority\n")
5102
5103DEFUN (ip_ospf_retransmit_interval,
5104 ip_ospf_retransmit_interval_addr_cmd,
5105 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5106 "IP Information\n"
5107 "OSPF interface commands\n"
5108 "Time between retransmitting lost link state advertisements\n"
5109 "Seconds\n"
5110 "Address of interface")
5111{
5112 struct interface *ifp = vty->index;
5113 u_int32_t seconds;
5114 struct in_addr addr;
5115 int ret;
5116 struct ospf_if_params *params;
5117
5118 params = IF_DEF_PARAMS (ifp);
5119 seconds = strtol (argv[0], NULL, 10);
5120
5121 /* Retransmit Interval range is <3-65535>. */
5122 if (seconds < 3 || seconds > 65535)
5123 {
5124 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5125 return CMD_WARNING;
5126 }
5127
5128
5129 if (argc == 2)
5130 {
5131 ret = inet_aton(argv[1], &addr);
5132 if (!ret)
5133 {
5134 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5135 VTY_NEWLINE);
5136 return CMD_WARNING;
5137 }
5138
5139 params = ospf_get_if_params (ifp, addr);
5140 ospf_if_update_params (ifp, addr);
5141 }
5142
5143 SET_IF_PARAM (params, retransmit_interval);
5144 params->retransmit_interval = seconds;
5145
5146 return CMD_SUCCESS;
5147}
5148
5149ALIAS (ip_ospf_retransmit_interval,
5150 ip_ospf_retransmit_interval_cmd,
5151 "ip ospf retransmit-interval <3-65535>",
5152 "IP Information\n"
5153 "OSPF interface commands\n"
5154 "Time between retransmitting lost link state advertisements\n"
5155 "Seconds\n")
5156
5157ALIAS (ip_ospf_retransmit_interval,
5158 ospf_retransmit_interval_cmd,
5159 "ospf retransmit-interval <3-65535>",
5160 "OSPF interface commands\n"
5161 "Time between retransmitting lost link state advertisements\n"
5162 "Seconds\n")
5163
5164DEFUN (no_ip_ospf_retransmit_interval,
5165 no_ip_ospf_retransmit_interval_addr_cmd,
5166 "no ip ospf retransmit-interval A.B.C.D",
5167 NO_STR
5168 "IP Information\n"
5169 "OSPF interface commands\n"
5170 "Time between retransmitting lost link state advertisements\n"
5171 "Address of interface")
5172{
5173 struct interface *ifp = vty->index;
5174 struct in_addr addr;
5175 int ret;
5176 struct ospf_if_params *params;
5177
5178 ifp = vty->index;
5179 params = IF_DEF_PARAMS (ifp);
5180
5181 if (argc == 1)
5182 {
5183 ret = inet_aton(argv[0], &addr);
5184 if (!ret)
5185 {
5186 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5187 VTY_NEWLINE);
5188 return CMD_WARNING;
5189 }
5190
5191 params = ospf_lookup_if_params (ifp, addr);
5192 if (params == NULL)
5193 return CMD_SUCCESS;
5194 }
5195
5196 UNSET_IF_PARAM (params, retransmit_interval);
5197 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5198
5199 if (params != IF_DEF_PARAMS (ifp))
5200 {
5201 ospf_free_if_params (ifp, addr);
5202 ospf_if_update_params (ifp, addr);
5203 }
5204
5205 return CMD_SUCCESS;
5206}
5207
5208ALIAS (no_ip_ospf_retransmit_interval,
5209 no_ip_ospf_retransmit_interval_cmd,
5210 "no ip ospf retransmit-interval",
5211 NO_STR
5212 "IP Information\n"
5213 "OSPF interface commands\n"
5214 "Time between retransmitting lost link state advertisements\n")
5215
5216ALIAS (no_ip_ospf_retransmit_interval,
5217 no_ospf_retransmit_interval_cmd,
5218 "no ospf retransmit-interval",
5219 NO_STR
5220 "OSPF interface commands\n"
5221 "Time between retransmitting lost link state advertisements\n")
5222
5223DEFUN (ip_ospf_transmit_delay,
5224 ip_ospf_transmit_delay_addr_cmd,
5225 "ip ospf transmit-delay <1-65535> A.B.C.D",
5226 "IP Information\n"
5227 "OSPF interface commands\n"
5228 "Link state transmit delay\n"
5229 "Seconds\n"
5230 "Address of interface")
5231{
5232 struct interface *ifp = vty->index;
5233 u_int32_t seconds;
5234 struct in_addr addr;
5235 int ret;
5236 struct ospf_if_params *params;
5237
5238 params = IF_DEF_PARAMS (ifp);
5239 seconds = strtol (argv[0], NULL, 10);
5240
5241 /* Transmit Delay range is <1-65535>. */
5242 if (seconds < 1 || seconds > 65535)
5243 {
5244 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5245 return CMD_WARNING;
5246 }
5247
5248 if (argc == 2)
5249 {
5250 ret = inet_aton(argv[1], &addr);
5251 if (!ret)
5252 {
5253 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5254 VTY_NEWLINE);
5255 return CMD_WARNING;
5256 }
5257
5258 params = ospf_get_if_params (ifp, addr);
5259 ospf_if_update_params (ifp, addr);
5260 }
5261
5262 SET_IF_PARAM (params, transmit_delay);
5263 params->transmit_delay = seconds;
5264
5265 return CMD_SUCCESS;
5266}
5267
5268ALIAS (ip_ospf_transmit_delay,
5269 ip_ospf_transmit_delay_cmd,
5270 "ip ospf transmit-delay <1-65535>",
5271 "IP Information\n"
5272 "OSPF interface commands\n"
5273 "Link state transmit delay\n"
5274 "Seconds\n")
5275
5276ALIAS (ip_ospf_transmit_delay,
5277 ospf_transmit_delay_cmd,
5278 "ospf transmit-delay <1-65535>",
5279 "OSPF interface commands\n"
5280 "Link state transmit delay\n"
5281 "Seconds\n")
5282
5283DEFUN (no_ip_ospf_transmit_delay,
5284 no_ip_ospf_transmit_delay_addr_cmd,
5285 "no ip ospf transmit-delay A.B.C.D",
5286 NO_STR
5287 "IP Information\n"
5288 "OSPF interface commands\n"
5289 "Link state transmit delay\n"
5290 "Address of interface")
5291{
5292 struct interface *ifp = vty->index;
5293 struct in_addr addr;
5294 int ret;
5295 struct ospf_if_params *params;
5296
5297 ifp = vty->index;
5298 params = IF_DEF_PARAMS (ifp);
5299
5300 if (argc == 1)
5301 {
5302 ret = inet_aton(argv[0], &addr);
5303 if (!ret)
5304 {
5305 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5306 VTY_NEWLINE);
5307 return CMD_WARNING;
5308 }
5309
5310 params = ospf_lookup_if_params (ifp, addr);
5311 if (params == NULL)
5312 return CMD_SUCCESS;
5313 }
5314
5315 UNSET_IF_PARAM (params, transmit_delay);
5316 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5317
5318 if (params != IF_DEF_PARAMS (ifp))
5319 {
5320 ospf_free_if_params (ifp, addr);
5321 ospf_if_update_params (ifp, addr);
5322 }
5323
5324 return CMD_SUCCESS;
5325}
5326
5327ALIAS (no_ip_ospf_transmit_delay,
5328 no_ip_ospf_transmit_delay_cmd,
5329 "no ip ospf transmit-delay",
5330 NO_STR
5331 "IP Information\n"
5332 "OSPF interface commands\n"
5333 "Link state transmit delay\n")
5334
5335ALIAS (no_ip_ospf_transmit_delay,
5336 no_ospf_transmit_delay_cmd,
5337 "no ospf transmit-delay",
5338 NO_STR
5339 "OSPF interface commands\n"
5340 "Link state transmit delay\n")
5341
5342
5343DEFUN (ospf_redistribute_source_metric_type,
5344 ospf_redistribute_source_metric_type_routemap_cmd,
5345 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5346 "Redistribute information from another routing protocol\n"
5347 "Kernel routes\n"
5348 "Connected\n"
5349 "Static routes\n"
5350 "Routing Information Protocol (RIP)\n"
5351 "Border Gateway Protocol (BGP)\n"
5352 "Metric for redistributed routes\n"
5353 "OSPF default metric\n"
5354 "OSPF exterior metric type for redistributed routes\n"
5355 "Set OSPF External Type 1 metrics\n"
5356 "Set OSPF External Type 2 metrics\n"
5357 "Route map reference\n"
5358 "Pointer to route-map entries\n")
5359{
paul020709f2003-04-04 02:44:16 +00005360 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005361 int source;
5362 int type = -1;
5363 int metric = -1;
5364
5365 /* Get distribute source. */
5366 if (!str2distribute_source (argv[0], &source))
5367 return CMD_WARNING;
5368
5369 /* Get metric value. */
5370 if (argc >= 2)
5371 if (!str2metric (argv[1], &metric))
5372 return CMD_WARNING;
5373
5374 /* Get metric type. */
5375 if (argc >= 3)
5376 if (!str2metric_type (argv[2], &type))
5377 return CMD_WARNING;
5378
5379 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005380 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005381 else
paul020709f2003-04-04 02:44:16 +00005382 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005383
paul020709f2003-04-04 02:44:16 +00005384 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005385}
5386
5387ALIAS (ospf_redistribute_source_metric_type,
5388 ospf_redistribute_source_metric_type_cmd,
5389 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5390 "Redistribute information from another routing protocol\n"
5391 "Kernel routes\n"
5392 "Connected\n"
5393 "Static routes\n"
5394 "Routing Information Protocol (RIP)\n"
5395 "Border Gateway Protocol (BGP)\n"
5396 "Metric for redistributed routes\n"
5397 "OSPF default metric\n"
5398 "OSPF exterior metric type for redistributed routes\n"
5399 "Set OSPF External Type 1 metrics\n"
5400 "Set OSPF External Type 2 metrics\n")
5401
5402ALIAS (ospf_redistribute_source_metric_type,
5403 ospf_redistribute_source_metric_cmd,
5404 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5405 "Redistribute information from another routing protocol\n"
5406 "Kernel routes\n"
5407 "Connected\n"
5408 "Static routes\n"
5409 "Routing Information Protocol (RIP)\n"
5410 "Border Gateway Protocol (BGP)\n"
5411 "Metric for redistributed routes\n"
5412 "OSPF default metric\n")
5413
5414DEFUN (ospf_redistribute_source_type_metric,
5415 ospf_redistribute_source_type_metric_routemap_cmd,
5416 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5417 "Redistribute information from another routing protocol\n"
5418 "Kernel routes\n"
5419 "Connected\n"
5420 "Static routes\n"
5421 "Routing Information Protocol (RIP)\n"
5422 "Border Gateway Protocol (BGP)\n"
5423 "OSPF exterior metric type for redistributed routes\n"
5424 "Set OSPF External Type 1 metrics\n"
5425 "Set OSPF External Type 2 metrics\n"
5426 "Metric for redistributed routes\n"
5427 "OSPF default metric\n"
5428 "Route map reference\n"
5429 "Pointer to route-map entries\n")
5430{
paul020709f2003-04-04 02:44:16 +00005431 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005432 int source;
5433 int type = -1;
5434 int metric = -1;
5435
5436 /* Get distribute source. */
5437 if (!str2distribute_source (argv[0], &source))
5438 return CMD_WARNING;
5439
5440 /* Get metric value. */
5441 if (argc >= 2)
5442 if (!str2metric_type (argv[1], &type))
5443 return CMD_WARNING;
5444
5445 /* Get metric type. */
5446 if (argc >= 3)
5447 if (!str2metric (argv[2], &metric))
5448 return CMD_WARNING;
5449
5450 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005451 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005452 else
paul020709f2003-04-04 02:44:16 +00005453 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005454
paul020709f2003-04-04 02:44:16 +00005455 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005456}
5457
5458ALIAS (ospf_redistribute_source_type_metric,
5459 ospf_redistribute_source_type_metric_cmd,
5460 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5461 "Redistribute information from another routing protocol\n"
5462 "Kernel routes\n"
5463 "Connected\n"
5464 "Static routes\n"
5465 "Routing Information Protocol (RIP)\n"
5466 "Border Gateway Protocol (BGP)\n"
5467 "OSPF exterior metric type for redistributed routes\n"
5468 "Set OSPF External Type 1 metrics\n"
5469 "Set OSPF External Type 2 metrics\n"
5470 "Metric for redistributed routes\n"
5471 "OSPF default metric\n")
5472
5473ALIAS (ospf_redistribute_source_type_metric,
5474 ospf_redistribute_source_type_cmd,
5475 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5476 "Redistribute information from another routing protocol\n"
5477 "Kernel routes\n"
5478 "Connected\n"
5479 "Static routes\n"
5480 "Routing Information Protocol (RIP)\n"
5481 "Border Gateway Protocol (BGP)\n"
5482 "OSPF exterior metric type for redistributed routes\n"
5483 "Set OSPF External Type 1 metrics\n"
5484 "Set OSPF External Type 2 metrics\n")
5485
5486ALIAS (ospf_redistribute_source_type_metric,
5487 ospf_redistribute_source_cmd,
5488 "redistribute (kernel|connected|static|rip|bgp)",
5489 "Redistribute information from another routing protocol\n"
5490 "Kernel routes\n"
5491 "Connected\n"
5492 "Static routes\n"
5493 "Routing Information Protocol (RIP)\n"
5494 "Border Gateway Protocol (BGP)\n")
5495
5496DEFUN (ospf_redistribute_source_metric_routemap,
5497 ospf_redistribute_source_metric_routemap_cmd,
5498 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5499 "Redistribute information from another routing protocol\n"
5500 "Kernel routes\n"
5501 "Connected\n"
5502 "Static routes\n"
5503 "Routing Information Protocol (RIP)\n"
5504 "Border Gateway Protocol (BGP)\n"
5505 "Metric for redistributed routes\n"
5506 "OSPF default metric\n"
5507 "Route map reference\n"
5508 "Pointer to route-map entries\n")
5509{
paul020709f2003-04-04 02:44:16 +00005510 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005511 int source;
5512 int metric = -1;
5513
5514 /* Get distribute source. */
5515 if (!str2distribute_source (argv[0], &source))
5516 return CMD_WARNING;
5517
5518 /* Get metric value. */
5519 if (argc >= 2)
5520 if (!str2metric (argv[1], &metric))
5521 return CMD_WARNING;
5522
5523 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005524 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005525 else
paul020709f2003-04-04 02:44:16 +00005526 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005527
paul020709f2003-04-04 02:44:16 +00005528 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005529}
5530
5531DEFUN (ospf_redistribute_source_type_routemap,
5532 ospf_redistribute_source_type_routemap_cmd,
5533 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5534 "Redistribute information from another routing protocol\n"
5535 "Kernel routes\n"
5536 "Connected\n"
5537 "Static routes\n"
5538 "Routing Information Protocol (RIP)\n"
5539 "Border Gateway Protocol (BGP)\n"
5540 "OSPF exterior metric type for redistributed routes\n"
5541 "Set OSPF External Type 1 metrics\n"
5542 "Set OSPF External Type 2 metrics\n"
5543 "Route map reference\n"
5544 "Pointer to route-map entries\n")
5545{
paul020709f2003-04-04 02:44:16 +00005546 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005547 int source;
5548 int type = -1;
5549
5550 /* Get distribute source. */
5551 if (!str2distribute_source (argv[0], &source))
5552 return CMD_WARNING;
5553
5554 /* Get metric value. */
5555 if (argc >= 2)
5556 if (!str2metric_type (argv[1], &type))
5557 return CMD_WARNING;
5558
5559 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005560 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005561 else
paul020709f2003-04-04 02:44:16 +00005562 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005563
paul020709f2003-04-04 02:44:16 +00005564 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005565}
5566
5567DEFUN (ospf_redistribute_source_routemap,
5568 ospf_redistribute_source_routemap_cmd,
5569 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5570 "Redistribute information from another routing protocol\n"
5571 "Kernel routes\n"
5572 "Connected\n"
5573 "Static routes\n"
5574 "Routing Information Protocol (RIP)\n"
5575 "Border Gateway Protocol (BGP)\n"
5576 "Route map reference\n"
5577 "Pointer to route-map entries\n")
5578{
paul020709f2003-04-04 02:44:16 +00005579 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005580 int source;
5581
5582 /* Get distribute source. */
5583 if (!str2distribute_source (argv[0], &source))
5584 return CMD_WARNING;
5585
5586 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005587 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005588 else
paul020709f2003-04-04 02:44:16 +00005589 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005590
paul020709f2003-04-04 02:44:16 +00005591 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005592}
5593
5594DEFUN (no_ospf_redistribute_source,
5595 no_ospf_redistribute_source_cmd,
5596 "no redistribute (kernel|connected|static|rip|bgp)",
5597 NO_STR
5598 "Redistribute information from another routing protocol\n"
5599 "Kernel routes\n"
5600 "Connected\n"
5601 "Static routes\n"
5602 "Routing Information Protocol (RIP)\n"
5603 "Border Gateway Protocol (BGP)\n")
5604{
paul020709f2003-04-04 02:44:16 +00005605 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005606 int source;
5607
5608 if (!str2distribute_source (argv[0], &source))
5609 return CMD_WARNING;
5610
paul020709f2003-04-04 02:44:16 +00005611 ospf_routemap_unset (ospf, source);
5612 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005613}
5614
5615DEFUN (ospf_distribute_list_out,
5616 ospf_distribute_list_out_cmd,
5617 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5618 "Filter networks in routing updates\n"
5619 "Access-list name\n"
5620 OUT_STR
5621 "Kernel routes\n"
5622 "Connected\n"
5623 "Static routes\n"
5624 "Routing Information Protocol (RIP)\n"
5625 "Border Gateway Protocol (BGP)\n")
5626{
paul68980082003-03-25 05:07:42 +00005627 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005628 int source;
5629
5630 /* Get distribute source. */
5631 if (!str2distribute_source (argv[1], &source))
5632 return CMD_WARNING;
5633
paul68980082003-03-25 05:07:42 +00005634 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005635}
5636
5637DEFUN (no_ospf_distribute_list_out,
5638 no_ospf_distribute_list_out_cmd,
5639 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5640 NO_STR
5641 "Filter networks in routing updates\n"
5642 "Access-list name\n"
5643 OUT_STR
5644 "Kernel routes\n"
5645 "Connected\n"
5646 "Static routes\n"
5647 "Routing Information Protocol (RIP)\n"
5648 "Border Gateway Protocol (BGP)\n")
5649{
paul68980082003-03-25 05:07:42 +00005650 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005651 int source;
5652
5653 if (!str2distribute_source (argv[1], &source))
5654 return CMD_WARNING;
5655
paul68980082003-03-25 05:07:42 +00005656 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005657}
5658
5659/* Default information originate. */
5660DEFUN (ospf_default_information_originate_metric_type_routemap,
5661 ospf_default_information_originate_metric_type_routemap_cmd,
5662 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5663 "Control distribution of default information\n"
5664 "Distribute a default route\n"
5665 "OSPF default metric\n"
5666 "OSPF metric\n"
5667 "OSPF metric type for default routes\n"
5668 "Set OSPF External Type 1 metrics\n"
5669 "Set OSPF External Type 2 metrics\n"
5670 "Route map reference\n"
5671 "Pointer to route-map entries\n")
5672{
paul020709f2003-04-04 02:44:16 +00005673 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005674 int type = -1;
5675 int metric = -1;
5676
5677 /* Get metric value. */
5678 if (argc >= 1)
5679 if (!str2metric (argv[0], &metric))
5680 return CMD_WARNING;
5681
5682 /* Get metric type. */
5683 if (argc >= 2)
5684 if (!str2metric_type (argv[1], &type))
5685 return CMD_WARNING;
5686
5687 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005688 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005689 else
paul020709f2003-04-04 02:44:16 +00005690 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005691
paul020709f2003-04-04 02:44:16 +00005692 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5693 type, metric);
paul718e3742002-12-13 20:15:29 +00005694}
5695
5696ALIAS (ospf_default_information_originate_metric_type_routemap,
5697 ospf_default_information_originate_metric_type_cmd,
5698 "default-information originate metric <0-16777214> metric-type (1|2)",
5699 "Control distribution of default information\n"
5700 "Distribute a default route\n"
5701 "OSPF default metric\n"
5702 "OSPF metric\n"
5703 "OSPF metric type for default routes\n"
5704 "Set OSPF External Type 1 metrics\n"
5705 "Set OSPF External Type 2 metrics\n")
5706
5707ALIAS (ospf_default_information_originate_metric_type_routemap,
5708 ospf_default_information_originate_metric_cmd,
5709 "default-information originate metric <0-16777214>",
5710 "Control distribution of default information\n"
5711 "Distribute a default route\n"
5712 "OSPF default metric\n"
5713 "OSPF metric\n")
5714
5715ALIAS (ospf_default_information_originate_metric_type_routemap,
5716 ospf_default_information_originate_cmd,
5717 "default-information originate",
5718 "Control distribution of default information\n"
5719 "Distribute a default route\n")
5720
5721/* Default information originate. */
5722DEFUN (ospf_default_information_originate_metric_routemap,
5723 ospf_default_information_originate_metric_routemap_cmd,
5724 "default-information originate metric <0-16777214> route-map WORD",
5725 "Control distribution of default information\n"
5726 "Distribute a default route\n"
5727 "OSPF default metric\n"
5728 "OSPF metric\n"
5729 "Route map reference\n"
5730 "Pointer to route-map entries\n")
5731{
paul020709f2003-04-04 02:44:16 +00005732 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005733 int metric = -1;
5734
5735 /* Get metric value. */
5736 if (argc >= 1)
5737 if (!str2metric (argv[0], &metric))
5738 return CMD_WARNING;
5739
5740 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005741 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005742 else
paul020709f2003-04-04 02:44:16 +00005743 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005744
paul020709f2003-04-04 02:44:16 +00005745 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5746 -1, metric);
paul718e3742002-12-13 20:15:29 +00005747}
5748
5749/* Default information originate. */
5750DEFUN (ospf_default_information_originate_routemap,
5751 ospf_default_information_originate_routemap_cmd,
5752 "default-information originate route-map WORD",
5753 "Control distribution of default information\n"
5754 "Distribute a default route\n"
5755 "Route map reference\n"
5756 "Pointer to route-map entries\n")
5757{
paul020709f2003-04-04 02:44:16 +00005758 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005759
paul020709f2003-04-04 02:44:16 +00005760 if (argc == 1)
5761 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5762 else
5763 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5764
5765 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005766}
5767
5768DEFUN (ospf_default_information_originate_type_metric_routemap,
5769 ospf_default_information_originate_type_metric_routemap_cmd,
5770 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5771 "Control distribution of default information\n"
5772 "Distribute a default route\n"
5773 "OSPF metric type for default routes\n"
5774 "Set OSPF External Type 1 metrics\n"
5775 "Set OSPF External Type 2 metrics\n"
5776 "OSPF default metric\n"
5777 "OSPF metric\n"
5778 "Route map reference\n"
5779 "Pointer to route-map entries\n")
5780{
paul020709f2003-04-04 02:44:16 +00005781 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005782 int type = -1;
5783 int metric = -1;
5784
5785 /* Get metric type. */
5786 if (argc >= 1)
5787 if (!str2metric_type (argv[0], &type))
5788 return CMD_WARNING;
5789
5790 /* Get metric value. */
5791 if (argc >= 2)
5792 if (!str2metric (argv[1], &metric))
5793 return CMD_WARNING;
5794
5795 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005796 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005797 else
paul020709f2003-04-04 02:44:16 +00005798 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005799
paul020709f2003-04-04 02:44:16 +00005800 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5801 type, metric);
paul718e3742002-12-13 20:15:29 +00005802}
5803
5804ALIAS (ospf_default_information_originate_type_metric_routemap,
5805 ospf_default_information_originate_type_metric_cmd,
5806 "default-information originate metric-type (1|2) metric <0-16777214>",
5807 "Control distribution of default information\n"
5808 "Distribute a default route\n"
5809 "OSPF metric type for default routes\n"
5810 "Set OSPF External Type 1 metrics\n"
5811 "Set OSPF External Type 2 metrics\n"
5812 "OSPF default metric\n"
5813 "OSPF metric\n")
5814
5815ALIAS (ospf_default_information_originate_type_metric_routemap,
5816 ospf_default_information_originate_type_cmd,
5817 "default-information originate metric-type (1|2)",
5818 "Control distribution of default information\n"
5819 "Distribute a default route\n"
5820 "OSPF metric type for default routes\n"
5821 "Set OSPF External Type 1 metrics\n"
5822 "Set OSPF External Type 2 metrics\n")
5823
5824DEFUN (ospf_default_information_originate_type_routemap,
5825 ospf_default_information_originate_type_routemap_cmd,
5826 "default-information originate metric-type (1|2) route-map WORD",
5827 "Control distribution of default information\n"
5828 "Distribute a default route\n"
5829 "OSPF metric type for default routes\n"
5830 "Set OSPF External Type 1 metrics\n"
5831 "Set OSPF External Type 2 metrics\n"
5832 "Route map reference\n"
5833 "Pointer to route-map entries\n")
5834{
paul020709f2003-04-04 02:44:16 +00005835 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005836 int type = -1;
5837
5838 /* Get metric type. */
5839 if (argc >= 1)
5840 if (!str2metric_type (argv[0], &type))
5841 return CMD_WARNING;
5842
5843 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005844 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
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_ZEBRA,
5849 type, -1);
paul718e3742002-12-13 20:15:29 +00005850}
5851
5852DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5853 ospf_default_information_originate_always_metric_type_routemap_cmd,
5854 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
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 "Route map reference\n"
5864 "Pointer to route-map entries\n")
5865{
paul020709f2003-04-04 02:44:16 +00005866 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005867 int type = -1;
5868 int metric = -1;
5869
5870 /* Get metric value. */
5871 if (argc >= 1)
5872 if (!str2metric (argv[0], &metric))
5873 return CMD_WARNING;
5874
5875 /* Get metric type. */
5876 if (argc >= 2)
5877 if (!str2metric_type (argv[1], &type))
5878 return CMD_WARNING;
5879
5880 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005881 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005882 else
paul020709f2003-04-04 02:44:16 +00005883 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005884
paul020709f2003-04-04 02:44:16 +00005885 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005886 type, metric);
5887}
5888
5889ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5890 ospf_default_information_originate_always_metric_type_cmd,
5891 "default-information originate always metric <0-16777214> metric-type (1|2)",
5892 "Control distribution of default information\n"
5893 "Distribute a default route\n"
5894 "Always advertise default route\n"
5895 "OSPF default metric\n"
5896 "OSPF metric\n"
5897 "OSPF metric type for default routes\n"
5898 "Set OSPF External Type 1 metrics\n"
5899 "Set OSPF External Type 2 metrics\n")
5900
5901ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5902 ospf_default_information_originate_always_metric_cmd,
5903 "default-information originate always metric <0-16777214>",
5904 "Control distribution of default information\n"
5905 "Distribute a default route\n"
5906 "Always advertise default route\n"
5907 "OSPF default metric\n"
5908 "OSPF metric\n"
5909 "OSPF metric type for default routes\n")
5910
5911ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5912 ospf_default_information_originate_always_cmd,
5913 "default-information originate always",
5914 "Control distribution of default information\n"
5915 "Distribute a default route\n"
5916 "Always advertise default route\n")
5917
5918DEFUN (ospf_default_information_originate_always_metric_routemap,
5919 ospf_default_information_originate_always_metric_routemap_cmd,
5920 "default-information originate always metric <0-16777214> route-map WORD",
5921 "Control distribution of default information\n"
5922 "Distribute a default route\n"
5923 "Always advertise default route\n"
5924 "OSPF default metric\n"
5925 "OSPF metric\n"
5926 "Route map reference\n"
5927 "Pointer to route-map entries\n")
5928{
paul020709f2003-04-04 02:44:16 +00005929 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005930 int metric = -1;
5931
5932 /* Get metric value. */
5933 if (argc >= 1)
5934 if (!str2metric (argv[0], &metric))
5935 return CMD_WARNING;
5936
5937 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005938 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005939 else
paul020709f2003-04-04 02:44:16 +00005940 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005941
paul020709f2003-04-04 02:44:16 +00005942 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5943 -1, metric);
paul718e3742002-12-13 20:15:29 +00005944}
5945
5946DEFUN (ospf_default_information_originate_always_routemap,
5947 ospf_default_information_originate_always_routemap_cmd,
5948 "default-information originate always route-map WORD",
5949 "Control distribution of default information\n"
5950 "Distribute a default route\n"
5951 "Always advertise default route\n"
5952 "Route map reference\n"
5953 "Pointer to route-map entries\n")
5954{
paul020709f2003-04-04 02:44:16 +00005955 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005956
paul020709f2003-04-04 02:44:16 +00005957 if (argc == 1)
5958 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5959 else
5960 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5961
5962 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005963}
5964
5965DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5966 ospf_default_information_originate_always_type_metric_routemap_cmd,
5967 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
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 "Route map reference\n"
5977 "Pointer to route-map entries\n")
5978{
paul020709f2003-04-04 02:44:16 +00005979 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005980 int type = -1;
5981 int metric = -1;
5982
5983 /* Get metric type. */
5984 if (argc >= 1)
5985 if (!str2metric_type (argv[0], &type))
5986 return CMD_WARNING;
5987
5988 /* Get metric value. */
5989 if (argc >= 2)
5990 if (!str2metric (argv[1], &metric))
5991 return CMD_WARNING;
5992
5993 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005994 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005995 else
paul020709f2003-04-04 02:44:16 +00005996 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005997
paul020709f2003-04-04 02:44:16 +00005998 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005999 type, metric);
6000}
6001
6002ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6003 ospf_default_information_originate_always_type_metric_cmd,
6004 "default-information originate always metric-type (1|2) metric <0-16777214>",
6005 "Control distribution of default information\n"
6006 "Distribute a default route\n"
6007 "Always advertise default route\n"
6008 "OSPF metric type for default routes\n"
6009 "Set OSPF External Type 1 metrics\n"
6010 "Set OSPF External Type 2 metrics\n"
6011 "OSPF default metric\n"
6012 "OSPF metric\n")
6013
6014ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6015 ospf_default_information_originate_always_type_cmd,
6016 "default-information originate always metric-type (1|2)",
6017 "Control distribution of default information\n"
6018 "Distribute a default route\n"
6019 "Always advertise default route\n"
6020 "OSPF metric type for default routes\n"
6021 "Set OSPF External Type 1 metrics\n"
6022 "Set OSPF External Type 2 metrics\n")
6023
6024DEFUN (ospf_default_information_originate_always_type_routemap,
6025 ospf_default_information_originate_always_type_routemap_cmd,
6026 "default-information originate always metric-type (1|2) route-map WORD",
6027 "Control distribution of default information\n"
6028 "Distribute a default route\n"
6029 "Always advertise default route\n"
6030 "OSPF metric type for default routes\n"
6031 "Set OSPF External Type 1 metrics\n"
6032 "Set OSPF External Type 2 metrics\n"
6033 "Route map reference\n"
6034 "Pointer to route-map entries\n")
6035{
paul020709f2003-04-04 02:44:16 +00006036 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006037 int type = -1;
6038
6039 /* Get metric type. */
6040 if (argc >= 1)
6041 if (!str2metric_type (argv[0], &type))
6042 return CMD_WARNING;
6043
6044 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006045 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006046 else
paul020709f2003-04-04 02:44:16 +00006047 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006048
paul020709f2003-04-04 02:44:16 +00006049 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006050 type, -1);
6051}
6052
6053DEFUN (no_ospf_default_information_originate,
6054 no_ospf_default_information_originate_cmd,
6055 "no default-information originate",
6056 NO_STR
6057 "Control distribution of default information\n"
6058 "Distribute a default route\n")
6059{
paul68980082003-03-25 05:07:42 +00006060 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006061 struct prefix_ipv4 p;
6062 struct in_addr nexthop;
6063
6064 p.family = AF_INET;
6065 p.prefix.s_addr = 0;
6066 p.prefixlen = 0;
6067
paul68980082003-03-25 05:07:42 +00006068 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
paul718e3742002-12-13 20:15:29 +00006069
6070 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6071 ospf_external_info_delete (DEFAULT_ROUTE, p);
6072 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6073 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6074 }
6075
paul020709f2003-04-04 02:44:16 +00006076 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6077 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006078}
6079
6080DEFUN (ospf_default_metric,
6081 ospf_default_metric_cmd,
6082 "default-metric <0-16777214>",
6083 "Set metric of redistributed routes\n"
6084 "Default metric\n")
6085{
paul68980082003-03-25 05:07:42 +00006086 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006087 int metric = -1;
6088
6089 if (!str2metric (argv[0], &metric))
6090 return CMD_WARNING;
6091
paul68980082003-03-25 05:07:42 +00006092 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006093
6094 return CMD_SUCCESS;
6095}
6096
6097DEFUN (no_ospf_default_metric,
6098 no_ospf_default_metric_cmd,
6099 "no default-metric",
6100 NO_STR
6101 "Set metric of redistributed routes\n")
6102{
paul68980082003-03-25 05:07:42 +00006103 struct ospf *ospf = vty->index;
6104
6105 ospf->default_metric = -1;
6106
paul718e3742002-12-13 20:15:29 +00006107 return CMD_SUCCESS;
6108}
6109
6110ALIAS (no_ospf_default_metric,
6111 no_ospf_default_metric_val_cmd,
6112 "no default-metric <0-16777214>",
6113 NO_STR
6114 "Set metric of redistributed routes\n"
6115 "Default metric\n")
6116
6117DEFUN (ospf_distance,
6118 ospf_distance_cmd,
6119 "distance <1-255>",
6120 "Define an administrative distance\n"
6121 "OSPF Administrative distance\n")
6122{
paul68980082003-03-25 05:07:42 +00006123 struct ospf *ospf = vty->index;
6124
6125 ospf->distance_all = atoi (argv[0]);
6126
paul718e3742002-12-13 20:15:29 +00006127 return CMD_SUCCESS;
6128}
6129
6130DEFUN (no_ospf_distance,
6131 no_ospf_distance_cmd,
6132 "no distance <1-255>",
6133 NO_STR
6134 "Define an administrative distance\n"
6135 "OSPF Administrative distance\n")
6136{
paul68980082003-03-25 05:07:42 +00006137 struct ospf *ospf = vty->index;
6138
6139 ospf->distance_all = 0;
6140
paul718e3742002-12-13 20:15:29 +00006141 return CMD_SUCCESS;
6142}
6143
6144DEFUN (no_ospf_distance_ospf,
6145 no_ospf_distance_ospf_cmd,
6146 "no distance ospf",
6147 NO_STR
6148 "Define an administrative distance\n"
6149 "OSPF Administrative distance\n"
6150 "OSPF Distance\n")
6151{
paul68980082003-03-25 05:07:42 +00006152 struct ospf *ospf = vty->index;
6153
6154 ospf->distance_intra = 0;
6155 ospf->distance_inter = 0;
6156 ospf->distance_external = 0;
6157
paul718e3742002-12-13 20:15:29 +00006158 return CMD_SUCCESS;
6159}
6160
6161DEFUN (ospf_distance_ospf_intra,
6162 ospf_distance_ospf_intra_cmd,
6163 "distance ospf intra-area <1-255>",
6164 "Define an administrative distance\n"
6165 "OSPF Administrative distance\n"
6166 "Intra-area routes\n"
6167 "Distance for intra-area routes\n")
6168{
paul68980082003-03-25 05:07:42 +00006169 struct ospf *ospf = vty->index;
6170
6171 ospf->distance_intra = atoi (argv[0]);
6172
paul718e3742002-12-13 20:15:29 +00006173 return CMD_SUCCESS;
6174}
6175
6176DEFUN (ospf_distance_ospf_intra_inter,
6177 ospf_distance_ospf_intra_inter_cmd,
6178 "distance ospf intra-area <1-255> inter-area <1-255>",
6179 "Define an administrative distance\n"
6180 "OSPF Administrative distance\n"
6181 "Intra-area routes\n"
6182 "Distance for intra-area routes\n"
6183 "Inter-area routes\n"
6184 "Distance for inter-area routes\n")
6185{
paul68980082003-03-25 05:07:42 +00006186 struct ospf *ospf = vty->index;
6187
6188 ospf->distance_intra = atoi (argv[0]);
6189 ospf->distance_inter = atoi (argv[1]);
6190
paul718e3742002-12-13 20:15:29 +00006191 return CMD_SUCCESS;
6192}
6193
6194DEFUN (ospf_distance_ospf_intra_external,
6195 ospf_distance_ospf_intra_external_cmd,
6196 "distance ospf intra-area <1-255> external <1-255>",
6197 "Define an administrative distance\n"
6198 "OSPF Administrative distance\n"
6199 "Intra-area routes\n"
6200 "Distance for intra-area routes\n"
6201 "External routes\n"
6202 "Distance for external routes\n")
6203{
paul68980082003-03-25 05:07:42 +00006204 struct ospf *ospf = vty->index;
6205
6206 ospf->distance_intra = atoi (argv[0]);
6207 ospf->distance_external = atoi (argv[1]);
6208
paul718e3742002-12-13 20:15:29 +00006209 return CMD_SUCCESS;
6210}
6211
6212DEFUN (ospf_distance_ospf_intra_inter_external,
6213 ospf_distance_ospf_intra_inter_external_cmd,
6214 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6215 "Define an administrative distance\n"
6216 "OSPF Administrative distance\n"
6217 "Intra-area routes\n"
6218 "Distance for intra-area routes\n"
6219 "Inter-area routes\n"
6220 "Distance for inter-area routes\n"
6221 "External routes\n"
6222 "Distance for external routes\n")
6223{
paul68980082003-03-25 05:07:42 +00006224 struct ospf *ospf = vty->index;
6225
6226 ospf->distance_intra = atoi (argv[0]);
6227 ospf->distance_inter = atoi (argv[1]);
6228 ospf->distance_external = atoi (argv[2]);
6229
paul718e3742002-12-13 20:15:29 +00006230 return CMD_SUCCESS;
6231}
6232
6233DEFUN (ospf_distance_ospf_intra_external_inter,
6234 ospf_distance_ospf_intra_external_inter_cmd,
6235 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6236 "Define an administrative distance\n"
6237 "OSPF Administrative distance\n"
6238 "Intra-area routes\n"
6239 "Distance for intra-area routes\n"
6240 "External routes\n"
6241 "Distance for external routes\n"
6242 "Inter-area routes\n"
6243 "Distance for inter-area routes\n")
6244{
paul68980082003-03-25 05:07:42 +00006245 struct ospf *ospf = vty->index;
6246
6247 ospf->distance_intra = atoi (argv[0]);
6248 ospf->distance_external = atoi (argv[1]);
6249 ospf->distance_inter = atoi (argv[2]);
6250
paul718e3742002-12-13 20:15:29 +00006251 return CMD_SUCCESS;
6252}
6253
6254DEFUN (ospf_distance_ospf_inter,
6255 ospf_distance_ospf_inter_cmd,
6256 "distance ospf inter-area <1-255>",
6257 "Define an administrative distance\n"
6258 "OSPF Administrative distance\n"
6259 "Inter-area routes\n"
6260 "Distance for inter-area routes\n")
6261{
paul68980082003-03-25 05:07:42 +00006262 struct ospf *ospf = vty->index;
6263
6264 ospf->distance_inter = atoi (argv[0]);
6265
paul718e3742002-12-13 20:15:29 +00006266 return CMD_SUCCESS;
6267}
6268
6269DEFUN (ospf_distance_ospf_inter_intra,
6270 ospf_distance_ospf_inter_intra_cmd,
6271 "distance ospf inter-area <1-255> intra-area <1-255>",
6272 "Define an administrative distance\n"
6273 "OSPF Administrative distance\n"
6274 "Inter-area routes\n"
6275 "Distance for inter-area routes\n"
6276 "Intra-area routes\n"
6277 "Distance for intra-area routes\n")
6278{
paul68980082003-03-25 05:07:42 +00006279 struct ospf *ospf = vty->index;
6280
6281 ospf->distance_inter = atoi (argv[0]);
6282 ospf->distance_intra = atoi (argv[1]);
6283
paul718e3742002-12-13 20:15:29 +00006284 return CMD_SUCCESS;
6285}
6286
6287DEFUN (ospf_distance_ospf_inter_external,
6288 ospf_distance_ospf_inter_external_cmd,
6289 "distance ospf inter-area <1-255> external <1-255>",
6290 "Define an administrative distance\n"
6291 "OSPF Administrative distance\n"
6292 "Inter-area routes\n"
6293 "Distance for inter-area routes\n"
6294 "External routes\n"
6295 "Distance for external routes\n")
6296{
paul68980082003-03-25 05:07:42 +00006297 struct ospf *ospf = vty->index;
6298
6299 ospf->distance_inter = atoi (argv[0]);
6300 ospf->distance_external = atoi (argv[1]);
6301
paul718e3742002-12-13 20:15:29 +00006302 return CMD_SUCCESS;
6303}
6304
6305DEFUN (ospf_distance_ospf_inter_intra_external,
6306 ospf_distance_ospf_inter_intra_external_cmd,
6307 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6308 "Define an administrative distance\n"
6309 "OSPF Administrative distance\n"
6310 "Inter-area routes\n"
6311 "Distance for inter-area routes\n"
6312 "Intra-area routes\n"
6313 "Distance for intra-area routes\n"
6314 "External routes\n"
6315 "Distance for external routes\n")
6316{
paul68980082003-03-25 05:07:42 +00006317 struct ospf *ospf = vty->index;
6318
6319 ospf->distance_inter = atoi (argv[0]);
6320 ospf->distance_intra = atoi (argv[1]);
6321 ospf->distance_external = atoi (argv[2]);
6322
paul718e3742002-12-13 20:15:29 +00006323 return CMD_SUCCESS;
6324}
6325
6326DEFUN (ospf_distance_ospf_inter_external_intra,
6327 ospf_distance_ospf_inter_external_intra_cmd,
6328 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6329 "Define an administrative distance\n"
6330 "OSPF Administrative distance\n"
6331 "Inter-area routes\n"
6332 "Distance for inter-area routes\n"
6333 "External routes\n"
6334 "Distance for external routes\n"
6335 "Intra-area routes\n"
6336 "Distance for intra-area routes\n")
6337{
paul68980082003-03-25 05:07:42 +00006338 struct ospf *ospf = vty->index;
6339
6340 ospf->distance_inter = atoi (argv[0]);
6341 ospf->distance_external = atoi (argv[1]);
6342 ospf->distance_intra = atoi (argv[2]);
6343
paul718e3742002-12-13 20:15:29 +00006344 return CMD_SUCCESS;
6345}
6346
6347DEFUN (ospf_distance_ospf_external,
6348 ospf_distance_ospf_external_cmd,
6349 "distance ospf external <1-255>",
6350 "Define an administrative distance\n"
6351 "OSPF Administrative distance\n"
6352 "External routes\n"
6353 "Distance for external routes\n")
6354{
paul68980082003-03-25 05:07:42 +00006355 struct ospf *ospf = vty->index;
6356
6357 ospf->distance_external = atoi (argv[0]);
6358
paul718e3742002-12-13 20:15:29 +00006359 return CMD_SUCCESS;
6360}
6361
6362DEFUN (ospf_distance_ospf_external_intra,
6363 ospf_distance_ospf_external_intra_cmd,
6364 "distance ospf external <1-255> intra-area <1-255>",
6365 "Define an administrative distance\n"
6366 "OSPF Administrative distance\n"
6367 "External routes\n"
6368 "Distance for external routes\n"
6369 "Intra-area routes\n"
6370 "Distance for intra-area routes\n")
6371{
paul68980082003-03-25 05:07:42 +00006372 struct ospf *ospf = vty->index;
6373
6374 ospf->distance_external = atoi (argv[0]);
6375 ospf->distance_intra = atoi (argv[1]);
6376
paul718e3742002-12-13 20:15:29 +00006377 return CMD_SUCCESS;
6378}
6379
6380DEFUN (ospf_distance_ospf_external_inter,
6381 ospf_distance_ospf_external_inter_cmd,
6382 "distance ospf external <1-255> inter-area <1-255>",
6383 "Define an administrative distance\n"
6384 "OSPF Administrative distance\n"
6385 "External routes\n"
6386 "Distance for external routes\n"
6387 "Inter-area routes\n"
6388 "Distance for inter-area routes\n")
6389{
paul68980082003-03-25 05:07:42 +00006390 struct ospf *ospf = vty->index;
6391
6392 ospf->distance_external = atoi (argv[0]);
6393 ospf->distance_inter = atoi (argv[1]);
6394
paul718e3742002-12-13 20:15:29 +00006395 return CMD_SUCCESS;
6396}
6397
6398DEFUN (ospf_distance_ospf_external_intra_inter,
6399 ospf_distance_ospf_external_intra_inter_cmd,
6400 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6401 "Define an administrative distance\n"
6402 "OSPF Administrative distance\n"
6403 "External routes\n"
6404 "Distance for external routes\n"
6405 "Intra-area routes\n"
6406 "Distance for intra-area routes\n"
6407 "Inter-area routes\n"
6408 "Distance for inter-area routes\n")
6409{
paul68980082003-03-25 05:07:42 +00006410 struct ospf *ospf = vty->index;
6411
6412 ospf->distance_external = atoi (argv[0]);
6413 ospf->distance_intra = atoi (argv[1]);
6414 ospf->distance_inter = atoi (argv[2]);
6415
paul718e3742002-12-13 20:15:29 +00006416 return CMD_SUCCESS;
6417}
6418
6419DEFUN (ospf_distance_ospf_external_inter_intra,
6420 ospf_distance_ospf_external_inter_intra_cmd,
6421 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6422 "Define an administrative distance\n"
6423 "OSPF Administrative distance\n"
6424 "External routes\n"
6425 "Distance for external routes\n"
6426 "Inter-area routes\n"
6427 "Distance for inter-area routes\n"
6428 "Intra-area routes\n"
6429 "Distance for intra-area routes\n")
6430{
paul68980082003-03-25 05:07:42 +00006431 struct ospf *ospf = vty->index;
6432
6433 ospf->distance_external = atoi (argv[0]);
6434 ospf->distance_inter = atoi (argv[1]);
6435 ospf->distance_intra = atoi (argv[2]);
6436
paul718e3742002-12-13 20:15:29 +00006437 return CMD_SUCCESS;
6438}
6439
6440DEFUN (ospf_distance_source,
6441 ospf_distance_source_cmd,
6442 "distance <1-255> A.B.C.D/M",
6443 "Administrative distance\n"
6444 "Distance value\n"
6445 "IP source prefix\n")
6446{
paul020709f2003-04-04 02:44:16 +00006447 struct ospf *ospf = vty->index;
6448
6449 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006450
paul718e3742002-12-13 20:15:29 +00006451 return CMD_SUCCESS;
6452}
6453
6454DEFUN (no_ospf_distance_source,
6455 no_ospf_distance_source_cmd,
6456 "no distance <1-255> A.B.C.D/M",
6457 NO_STR
6458 "Administrative distance\n"
6459 "Distance value\n"
6460 "IP source prefix\n")
6461{
paul020709f2003-04-04 02:44:16 +00006462 struct ospf *ospf = vty->index;
6463
6464 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6465
paul718e3742002-12-13 20:15:29 +00006466 return CMD_SUCCESS;
6467}
6468
6469DEFUN (ospf_distance_source_access_list,
6470 ospf_distance_source_access_list_cmd,
6471 "distance <1-255> A.B.C.D/M WORD",
6472 "Administrative distance\n"
6473 "Distance value\n"
6474 "IP source prefix\n"
6475 "Access list name\n")
6476{
paul020709f2003-04-04 02:44:16 +00006477 struct ospf *ospf = vty->index;
6478
6479 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6480
paul718e3742002-12-13 20:15:29 +00006481 return CMD_SUCCESS;
6482}
6483
6484DEFUN (no_ospf_distance_source_access_list,
6485 no_ospf_distance_source_access_list_cmd,
6486 "no distance <1-255> A.B.C.D/M WORD",
6487 NO_STR
6488 "Administrative distance\n"
6489 "Distance value\n"
6490 "IP source prefix\n"
6491 "Access list name\n")
6492{
paul020709f2003-04-04 02:44:16 +00006493 struct ospf *ospf = vty->index;
6494
6495 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6496
paul718e3742002-12-13 20:15:29 +00006497 return CMD_SUCCESS;
6498}
6499
6500void
6501show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6502{
6503 struct route_node *rn;
6504 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006505 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006506 struct ospf_path *path;
6507
6508 vty_out (vty, "============ OSPF network routing table ============%s",
6509 VTY_NEWLINE);
6510
6511 for (rn = route_top (rt); rn; rn = route_next (rn))
6512 if ((or = rn->info) != NULL)
6513 {
6514 char buf1[19];
6515 snprintf (buf1, 19, "%s/%d",
6516 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6517
6518 switch (or->path_type)
6519 {
6520 case OSPF_PATH_INTER_AREA:
6521 if (or->type == OSPF_DESTINATION_NETWORK)
6522 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6523 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6524 else if (or->type == OSPF_DESTINATION_DISCARD)
6525 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6526 break;
6527 case OSPF_PATH_INTRA_AREA:
6528 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6529 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6530 break;
6531 default:
6532 break;
6533 }
6534
6535 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00006536 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00006537 {
6538 if (path->oi != NULL)
6539 {
6540 if (path->nexthop.s_addr == 0)
6541 vty_out (vty, "%24s directly attached to %s%s",
6542 "", path->oi->ifp->name, VTY_NEWLINE);
6543 else
6544 vty_out (vty, "%24s via %s, %s%s", "",
6545 inet_ntoa (path->nexthop), path->oi->ifp->name,
6546 VTY_NEWLINE);
6547 }
6548 }
paul718e3742002-12-13 20:15:29 +00006549 }
6550 vty_out (vty, "%s", VTY_NEWLINE);
6551}
6552
6553void
6554show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6555{
6556 struct route_node *rn;
6557 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006558 struct listnode *pnode;
6559 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006560 struct ospf_path *path;
6561
6562 vty_out (vty, "============ OSPF router routing table =============%s",
6563 VTY_NEWLINE);
6564 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6565 if (rn->info)
6566 {
6567 int flag = 0;
6568
6569 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6570
paul1eb8ef22005-04-07 07:30:20 +00006571 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
6572 {
6573 if (flag++)
6574 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006575
paul1eb8ef22005-04-07 07:30:20 +00006576 /* Show path. */
6577 vty_out (vty, "%s [%d] area: %s",
6578 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6579 or->cost, inet_ntoa (or->u.std.area_id));
6580 /* Show flags. */
6581 vty_out (vty, "%s%s%s",
6582 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6583 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6584 VTY_NEWLINE);
6585
6586 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
6587 {
6588 if (path->nexthop.s_addr == 0)
6589 vty_out (vty, "%24s directly attached to %s%s",
6590 "", path->oi->ifp->name, VTY_NEWLINE);
6591 else
6592 vty_out (vty, "%24s via %s, %s%s", "",
6593 inet_ntoa (path->nexthop), path->oi->ifp->name,
6594 VTY_NEWLINE);
6595 }
6596 }
paul718e3742002-12-13 20:15:29 +00006597 }
6598 vty_out (vty, "%s", VTY_NEWLINE);
6599}
6600
6601void
6602show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6603{
6604 struct route_node *rn;
6605 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00006606 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006607 struct ospf_path *path;
6608
6609 vty_out (vty, "============ OSPF external routing table ===========%s",
6610 VTY_NEWLINE);
6611 for (rn = route_top (rt); rn; rn = route_next (rn))
6612 if ((er = rn->info) != NULL)
6613 {
6614 char buf1[19];
6615 snprintf (buf1, 19, "%s/%d",
6616 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6617
6618 switch (er->path_type)
6619 {
6620 case OSPF_PATH_TYPE1_EXTERNAL:
6621 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6622 er->cost, er->u.ext.tag, VTY_NEWLINE);
6623 break;
6624 case OSPF_PATH_TYPE2_EXTERNAL:
6625 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6626 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6627 break;
6628 }
6629
paul1eb8ef22005-04-07 07:30:20 +00006630 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00006631 {
paul718e3742002-12-13 20:15:29 +00006632 if (path->oi != NULL)
6633 {
6634 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006635 vty_out (vty, "%24s directly attached to %s%s",
6636 "", path->oi->ifp->name, VTY_NEWLINE);
6637 else
6638 vty_out (vty, "%24s via %s, %s%s", "",
6639 inet_ntoa (path->nexthop), path->oi->ifp->name,
6640 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006641 }
6642 }
6643 }
6644 vty_out (vty, "%s", VTY_NEWLINE);
6645}
6646
paul718e3742002-12-13 20:15:29 +00006647DEFUN (show_ip_ospf_border_routers,
6648 show_ip_ospf_border_routers_cmd,
6649 "show ip ospf border-routers",
6650 SHOW_STR
6651 IP_STR
6652 "show all the ABR's and ASBR's\n"
6653 "for this area\n")
6654{
paul020709f2003-04-04 02:44:16 +00006655 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006656
paul020709f2003-04-04 02:44:16 +00006657 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006658 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006659 {
6660 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6661 return CMD_SUCCESS;
6662 }
6663
paul68980082003-03-25 05:07:42 +00006664 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006665 {
6666 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6667 return CMD_SUCCESS;
6668 }
6669
6670 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006671 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006672
6673 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006674 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006675
6676 return CMD_SUCCESS;
6677}
paul718e3742002-12-13 20:15:29 +00006678
6679DEFUN (show_ip_ospf_route,
6680 show_ip_ospf_route_cmd,
6681 "show ip ospf route",
6682 SHOW_STR
6683 IP_STR
6684 "OSPF information\n"
6685 "OSPF routing table\n")
6686{
paul020709f2003-04-04 02:44:16 +00006687 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006688
paul020709f2003-04-04 02:44:16 +00006689 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006690 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006691 {
6692 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6693 return CMD_SUCCESS;
6694 }
6695
paul68980082003-03-25 05:07:42 +00006696 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006697 {
6698 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6699 return CMD_SUCCESS;
6700 }
6701
6702 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006703 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006704
6705 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006706 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006707
6708 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006709 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006710
6711 return CMD_SUCCESS;
6712}
6713
6714
hassoeb1ce602004-10-08 08:17:22 +00006715const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006716{
6717 "unknown",
6718 "standard",
6719 "ibm",
6720 "cisco",
6721 "shortcut"
6722};
6723
hassoeb1ce602004-10-08 08:17:22 +00006724const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006725{
6726 "default",
6727 "enable",
6728 "disable"
6729};
6730
6731
6732void
6733area_id2str (char *buf, int length, struct ospf_area *area)
6734{
6735 memset (buf, 0, length);
6736
6737 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6738 strncpy (buf, inet_ntoa (area->area_id), length);
6739 else
6740 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6741}
6742
6743
hassoeb1ce602004-10-08 08:17:22 +00006744const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006745{
6746 "unknown", /* should never be used. */
6747 "point-to-point",
6748 "broadcast",
6749 "non-broadcast",
6750 "point-to-multipoint",
6751 "virtual-link", /* should never be used. */
6752 "loopback"
6753};
6754
6755/* Configuration write function for ospfd. */
6756int
6757config_write_interface (struct vty *vty)
6758{
hasso52dc7ee2004-09-23 19:18:23 +00006759 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006760 struct interface *ifp;
6761 struct crypt_key *ck;
6762 int write = 0;
6763 struct route_node *rn = NULL;
6764 struct ospf_if_params *params;
6765
paul1eb8ef22005-04-07 07:30:20 +00006766 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00006767 {
paul718e3742002-12-13 20:15:29 +00006768 if (memcmp (ifp->name, "VLINK", 5) == 0)
6769 continue;
6770
6771 vty_out (vty, "!%s", VTY_NEWLINE);
6772 vty_out (vty, "interface %s%s", ifp->name,
6773 VTY_NEWLINE);
6774 if (ifp->desc)
6775 vty_out (vty, " description %s%s", ifp->desc,
6776 VTY_NEWLINE);
6777
6778 write++;
6779
6780 params = IF_DEF_PARAMS (ifp);
6781
6782 do {
6783 /* Interface Network print. */
6784 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006785 params->type != OSPF_IFTYPE_LOOPBACK)
6786 {
ajsbc18d612004-12-15 15:07:19 +00006787 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006788 {
6789 vty_out (vty, " ip ospf network %s",
6790 ospf_int_type_str[params->type]);
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 }
paul718e3742002-12-13 20:15:29 +00006795 }
6796
6797 /* OSPF interface authentication print */
6798 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6799 params->auth_type != OSPF_AUTH_NOTSET)
6800 {
hassoeb1ce602004-10-08 08:17:22 +00006801 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006802
6803 /* Translation tables are not that much help here due to syntax
6804 of the simple option */
6805 switch (params->auth_type)
6806 {
6807
6808 case OSPF_AUTH_NULL:
6809 auth_str = " null";
6810 break;
6811
6812 case OSPF_AUTH_SIMPLE:
6813 auth_str = "";
6814 break;
6815
6816 case OSPF_AUTH_CRYPTOGRAPHIC:
6817 auth_str = " message-digest";
6818 break;
6819
6820 default:
6821 auth_str = "";
6822 break;
6823 }
6824
6825 vty_out (vty, " ip ospf authentication%s", auth_str);
6826 if (params != IF_DEF_PARAMS (ifp))
6827 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6828 vty_out (vty, "%s", VTY_NEWLINE);
6829 }
6830
6831 /* Simple Authentication Password print. */
6832 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6833 params->auth_simple[0] != '\0')
6834 {
6835 vty_out (vty, " ip ospf authentication-key %s",
6836 params->auth_simple);
6837 if (params != IF_DEF_PARAMS (ifp))
6838 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6839 vty_out (vty, "%s", VTY_NEWLINE);
6840 }
6841
6842 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00006843 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00006844 {
paul718e3742002-12-13 20:15:29 +00006845 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6846 ck->key_id, ck->auth_key);
6847 if (params != IF_DEF_PARAMS (ifp))
6848 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6849 vty_out (vty, "%s", VTY_NEWLINE);
6850 }
6851
6852 /* Interface Output Cost print. */
6853 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6854 {
6855 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6856 if (params != IF_DEF_PARAMS (ifp))
6857 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6858 vty_out (vty, "%s", VTY_NEWLINE);
6859 }
6860
6861 /* Hello Interval print. */
6862 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6863 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6864 {
6865 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6866 if (params != IF_DEF_PARAMS (ifp))
6867 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6868 vty_out (vty, "%s", VTY_NEWLINE);
6869 }
6870
6871
6872 /* Router Dead Interval print. */
6873 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6874 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6875 {
6876 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6877 if (params != IF_DEF_PARAMS (ifp))
6878 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6879 vty_out (vty, "%s", VTY_NEWLINE);
6880 }
6881
6882 /* Router Priority print. */
6883 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6884 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6885 {
6886 vty_out (vty, " ip ospf priority %u", params->priority);
6887 if (params != IF_DEF_PARAMS (ifp))
6888 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6889 vty_out (vty, "%s", VTY_NEWLINE);
6890 }
6891
6892 /* Retransmit Interval print. */
6893 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6894 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6895 {
6896 vty_out (vty, " ip ospf retransmit-interval %u",
6897 params->retransmit_interval);
6898 if (params != IF_DEF_PARAMS (ifp))
6899 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6900 vty_out (vty, "%s", VTY_NEWLINE);
6901 }
6902
6903 /* Transmit Delay print. */
6904 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6905 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6906 {
6907 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6908 if (params != IF_DEF_PARAMS (ifp))
6909 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6910 vty_out (vty, "%s", VTY_NEWLINE);
6911 }
6912
6913 while (1)
6914 {
6915 if (rn == NULL)
6916 rn = route_top (IF_OIFS_PARAMS (ifp));
6917 else
6918 rn = route_next (rn);
6919
6920 if (rn == NULL)
6921 break;
6922 params = rn->info;
6923 if (params != NULL)
6924 break;
6925 }
6926 } while (rn);
6927
6928#ifdef HAVE_OPAQUE_LSA
6929 ospf_opaque_config_write_if (vty, ifp);
6930#endif /* HAVE_OPAQUE_LSA */
6931 }
6932
6933 return write;
6934}
6935
6936int
paul68980082003-03-25 05:07:42 +00006937config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006938{
6939 struct route_node *rn;
6940 u_char buf[INET_ADDRSTRLEN];
6941
6942 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006943 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006944 if (rn->info)
6945 {
6946 struct ospf_network *n = rn->info;
6947
6948 memset (buf, 0, INET_ADDRSTRLEN);
6949
6950 /* Create Area ID string by specified Area ID format. */
6951 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00006952 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00006953 else
hassoc9e52be2004-09-26 16:09:34 +00006954 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00006955 (unsigned long int) ntohl (n->area_id.s_addr));
6956
6957 /* Network print. */
6958 vty_out (vty, " network %s/%d area %s%s",
6959 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6960 buf, VTY_NEWLINE);
6961 }
6962
6963 return 0;
6964}
6965
6966int
paul68980082003-03-25 05:07:42 +00006967config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006968{
hasso52dc7ee2004-09-23 19:18:23 +00006969 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00006970 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00006971 u_char buf[INET_ADDRSTRLEN];
6972
6973 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00006974 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00006975 {
paul718e3742002-12-13 20:15:29 +00006976 struct route_node *rn1;
6977
hassoc9e52be2004-09-26 16:09:34 +00006978 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00006979
6980 if (area->auth_type != OSPF_AUTH_NULL)
6981 {
6982 if (area->auth_type == OSPF_AUTH_SIMPLE)
6983 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6984 else
6985 vty_out (vty, " area %s authentication message-digest%s",
6986 buf, VTY_NEWLINE);
6987 }
6988
6989 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6990 vty_out (vty, " area %s shortcut %s%s", buf,
6991 ospf_shortcut_mode_str[area->shortcut_configured],
6992 VTY_NEWLINE);
6993
6994 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006995 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00006996 )
6997 {
paulb0a053b2003-06-22 09:04:47 +00006998 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00006999 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007000 else if (area->external_routing == OSPF_AREA_NSSA)
7001 {
7002 vty_out (vty, " area %s nssa", buf);
7003 switch (area->NSSATranslatorRole)
7004 {
7005 case OSPF_NSSA_ROLE_NEVER:
7006 vty_out (vty, " translate-never");
7007 break;
7008 case OSPF_NSSA_ROLE_ALWAYS:
7009 vty_out (vty, " translate-always");
7010 break;
7011 case OSPF_NSSA_ROLE_CANDIDATE:
7012 default:
7013 vty_out (vty, " translate-candidate");
7014 }
7015 }
paul718e3742002-12-13 20:15:29 +00007016
7017 if (area->no_summary)
7018 vty_out (vty, " no-summary");
7019
7020 vty_out (vty, "%s", VTY_NEWLINE);
7021
7022 if (area->default_cost != 1)
7023 vty_out (vty, " area %s default-cost %d%s", buf,
7024 area->default_cost, VTY_NEWLINE);
7025 }
7026
7027 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7028 if (rn1->info)
7029 {
7030 struct ospf_area_range *range = rn1->info;
7031
7032 vty_out (vty, " area %s range %s/%d", buf,
7033 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7034
paul6c835672004-10-11 11:00:30 +00007035 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007036 vty_out (vty, " cost %d", range->cost_config);
7037
7038 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7039 vty_out (vty, " not-advertise");
7040
7041 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7042 vty_out (vty, " substitute %s/%d",
7043 inet_ntoa (range->subst_addr), range->subst_masklen);
7044
7045 vty_out (vty, "%s", VTY_NEWLINE);
7046 }
7047
7048 if (EXPORT_NAME (area))
7049 vty_out (vty, " area %s export-list %s%s", buf,
7050 EXPORT_NAME (area), VTY_NEWLINE);
7051
7052 if (IMPORT_NAME (area))
7053 vty_out (vty, " area %s import-list %s%s", buf,
7054 IMPORT_NAME (area), VTY_NEWLINE);
7055
7056 if (PREFIX_NAME_IN (area))
7057 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7058 PREFIX_NAME_IN (area), VTY_NEWLINE);
7059
7060 if (PREFIX_NAME_OUT (area))
7061 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7062 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7063 }
7064
7065 return 0;
7066}
7067
7068int
paul68980082003-03-25 05:07:42 +00007069config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007070{
7071 struct ospf_nbr_nbma *nbr_nbma;
7072 struct route_node *rn;
7073
7074 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007075 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007076 if ((nbr_nbma = rn->info))
7077 {
7078 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7079
7080 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7081 vty_out (vty, " priority %d", nbr_nbma->priority);
7082
7083 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7084 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7085
7086 vty_out (vty, "%s", VTY_NEWLINE);
7087 }
7088
7089 return 0;
7090}
7091
7092int
paul68980082003-03-25 05:07:42 +00007093config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007094{
hasso52dc7ee2004-09-23 19:18:23 +00007095 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007096 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007097 u_char buf[INET_ADDRSTRLEN];
7098
7099 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007100 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007101 {
hasso52dc7ee2004-09-23 19:18:23 +00007102 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007103 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007104 struct ospf_interface *oi;
7105
7106 if (vl_data != NULL)
7107 {
7108 memset (buf, 0, INET_ADDRSTRLEN);
7109
7110 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007111 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007112 else
hassoc9e52be2004-09-26 16:09:34 +00007113 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007114 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7115 oi = vl_data->vl_oi;
7116
7117 /* timers */
7118 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7119 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7120 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7121 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7122 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7123 buf,
7124 inet_ntoa (vl_data->vl_peer),
7125 OSPF_IF_PARAM (oi, v_hello),
7126 OSPF_IF_PARAM (oi, retransmit_interval),
7127 OSPF_IF_PARAM (oi, transmit_delay),
7128 OSPF_IF_PARAM (oi, v_wait),
7129 VTY_NEWLINE);
7130 else
7131 vty_out (vty, " area %s virtual-link %s%s", buf,
7132 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7133 /* Auth key */
7134 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7135 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7136 buf,
7137 inet_ntoa (vl_data->vl_peer),
7138 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7139 VTY_NEWLINE);
7140 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007141 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7142 n2, ck))
7143 vty_out (vty, " area %s virtual-link %s"
7144 " message-digest-key %d md5 %s%s",
7145 buf,
7146 inet_ntoa (vl_data->vl_peer),
7147 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007148
7149 }
7150 }
7151
7152 return 0;
7153}
7154
7155
hassoeb1ce602004-10-08 08:17:22 +00007156const char *distribute_str[] = { "system", "kernel", "connected", "static",
7157 "rip", "ripng", "ospf", "ospf6", "isis", "bgp"};
paul718e3742002-12-13 20:15:29 +00007158int
paul68980082003-03-25 05:07:42 +00007159config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007160{
7161 int type;
7162
7163 /* redistribute print. */
7164 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7165 if (type != zclient->redist_default && zclient->redist[type])
7166 {
7167 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007168 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007169 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007170
paul68980082003-03-25 05:07:42 +00007171 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007172 vty_out (vty, " metric-type 1");
7173
paul020709f2003-04-04 02:44:16 +00007174 if (ROUTEMAP_NAME (ospf, type))
7175 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007176
7177 vty_out (vty, "%s", VTY_NEWLINE);
7178 }
7179
7180 return 0;
7181}
7182
7183int
paul68980082003-03-25 05:07:42 +00007184config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007185{
paul68980082003-03-25 05:07:42 +00007186 if (ospf->default_metric != -1)
7187 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007188 VTY_NEWLINE);
7189 return 0;
7190}
7191
7192int
paul68980082003-03-25 05:07:42 +00007193config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007194{
7195 int type;
7196
paul68980082003-03-25 05:07:42 +00007197 if (ospf)
paul718e3742002-12-13 20:15:29 +00007198 {
7199 /* distribute-list print. */
7200 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007201 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007202 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007203 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007204 distribute_str[type], VTY_NEWLINE);
7205
7206 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007207 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007208 {
paul68980082003-03-25 05:07:42 +00007209 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007210 vty_out (vty, " default-information originate");
7211 else
7212 vty_out (vty, " default-information originate always");
7213
paul68980082003-03-25 05:07:42 +00007214 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007215 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007216 ospf->dmetric[DEFAULT_ROUTE].value);
7217 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007218 vty_out (vty, " metric-type 1");
7219
paul020709f2003-04-04 02:44:16 +00007220 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7221 vty_out (vty, " route-map %s",
7222 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007223
7224 vty_out (vty, "%s", VTY_NEWLINE);
7225 }
7226
7227 }
7228
7229 return 0;
7230}
7231
7232int
paul68980082003-03-25 05:07:42 +00007233config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007234{
7235 struct route_node *rn;
7236 struct ospf_distance *odistance;
7237
paul68980082003-03-25 05:07:42 +00007238 if (ospf->distance_all)
7239 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007240
paul68980082003-03-25 05:07:42 +00007241 if (ospf->distance_intra
7242 || ospf->distance_inter
7243 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007244 {
7245 vty_out (vty, " distance ospf");
7246
paul68980082003-03-25 05:07:42 +00007247 if (ospf->distance_intra)
7248 vty_out (vty, " intra-area %d", ospf->distance_intra);
7249 if (ospf->distance_inter)
7250 vty_out (vty, " inter-area %d", ospf->distance_inter);
7251 if (ospf->distance_external)
7252 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007253
7254 vty_out (vty, "%s", VTY_NEWLINE);
7255 }
7256
paul68980082003-03-25 05:07:42 +00007257 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007258 if ((odistance = rn->info) != NULL)
7259 {
7260 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7261 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7262 odistance->access_list ? odistance->access_list : "",
7263 VTY_NEWLINE);
7264 }
7265 return 0;
7266}
7267
7268/* OSPF configuration write function. */
7269int
7270ospf_config_write (struct vty *vty)
7271{
paul020709f2003-04-04 02:44:16 +00007272 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007273 struct interface *ifp;
7274 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007275 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007276 int write = 0;
7277
paul020709f2003-04-04 02:44:16 +00007278 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007279 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007280 {
7281 /* `router ospf' print. */
7282 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7283
7284 write++;
7285
paul68980082003-03-25 05:07:42 +00007286 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007287 return write;
7288
7289 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007290 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007291 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007292 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007293
7294 /* ABR type print. */
paul68980082003-03-25 05:07:42 +00007295 if (ospf->abr_type != OSPF_ABR_STAND)
paul718e3742002-12-13 20:15:29 +00007296 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007297 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007298
7299 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007300 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007301 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7302
7303 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007304 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007305 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007306 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007307
7308 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007309 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7310 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007311 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007312 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007313
7314 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007315 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007316 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007317 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007318
7319 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007320 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007321
7322 /* passive-interface print. */
paul1eb8ef22005-04-07 07:30:20 +00007323 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7324 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7325 vty_out (vty, " passive-interface %s%s",
7326 ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007327
paul1eb8ef22005-04-07 07:30:20 +00007328 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7329 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7330 oi->params->passive_interface == OSPF_IF_PASSIVE)
7331 vty_out (vty, " passive-interface %s %s%s",
7332 oi->ifp->name,
7333 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007334
7335 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007336 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007337
7338 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007339 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007340
7341 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007342 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007343
7344 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007345 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007346
7347 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007348 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007349
7350 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007351 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007352
7353 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007354 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007355
7356#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007357 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007358#endif /* HAVE_OPAQUE_LSA */
7359 }
7360
7361 return write;
7362}
7363
7364void
7365ospf_vty_show_init ()
7366{
7367 /* "show ip ospf" commands. */
7368 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7369 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7370
7371 /* "show ip ospf database" commands. */
7372 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7373 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7374 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7375 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7376 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7377 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7378 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7379 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7380 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7381 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7382 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7383 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7384 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7385 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7386
7387 /* "show ip ospf interface" commands. */
7388 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7389 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7390
7391 /* "show ip ospf neighbor" commands. */
7392 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7393 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7394 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7395 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7396 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7397 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7398 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7399 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7400 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7401 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7402 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7403 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7404 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7405 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7406
7407 /* "show ip ospf route" commands. */
7408 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7409 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007410 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7411 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007412}
7413
7414
7415/* ospfd's interface node. */
7416struct cmd_node interface_node =
7417{
7418 INTERFACE_NODE,
7419 "%s(config-if)# ",
7420 1
7421};
7422
7423/* Initialization of OSPF interface. */
7424void
7425ospf_vty_if_init ()
7426{
7427 /* Install interface node. */
7428 install_node (&interface_node, config_write_interface);
7429
7430 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007431 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007432 install_default (INTERFACE_NODE);
7433
7434 /* "description" commands. */
7435 install_element (INTERFACE_NODE, &interface_desc_cmd);
7436 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7437
7438 /* "ip ospf authentication" commands. */
7439 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7440 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7441 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7442 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7443 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7444 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7445 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7446 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7447 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7448 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7449
7450 /* "ip ospf message-digest-key" commands. */
7451 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7452 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7453 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7454 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7455
7456 /* "ip ospf cost" commands. */
7457 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7458 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7459 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7460 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7461
7462 /* "ip ospf dead-interval" commands. */
7463 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7464 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7465 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7466 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7467
7468 /* "ip ospf hello-interval" commands. */
7469 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7470 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7471 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7472 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7473
7474 /* "ip ospf network" commands. */
7475 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7476 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7477
7478 /* "ip ospf priority" commands. */
7479 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7480 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7481 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7482 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7483
7484 /* "ip ospf retransmit-interval" commands. */
7485 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7486 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7487 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7488 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7489
7490 /* "ip ospf transmit-delay" commands. */
7491 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7492 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7493 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7494 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7495
7496 /* These commands are compatibitliy for previous version. */
7497 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7498 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7499 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7500 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7501 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7502 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7503 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7504 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7505 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7506 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7507 install_element (INTERFACE_NODE, &ospf_network_cmd);
7508 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7509 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7510 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7511 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7512 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7513 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7514 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7515}
7516
7517/* Zebra node structure. */
7518struct cmd_node zebra_node =
7519{
7520 ZEBRA_NODE,
7521 "%s(config-router)#",
7522};
7523
7524void
7525ospf_vty_zebra_init ()
7526{
7527 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7528 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7529 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7530 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7531 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7532 install_element (OSPF_NODE,
7533 &ospf_redistribute_source_metric_type_routemap_cmd);
7534 install_element (OSPF_NODE,
7535 &ospf_redistribute_source_type_metric_routemap_cmd);
7536 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7537 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7538 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7539
7540 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7541
7542 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7543 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7544
7545 install_element (OSPF_NODE,
7546 &ospf_default_information_originate_metric_type_cmd);
7547 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7548 install_element (OSPF_NODE,
7549 &ospf_default_information_originate_type_metric_cmd);
7550 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7551 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7552 install_element (OSPF_NODE,
7553 &ospf_default_information_originate_always_metric_type_cmd);
7554 install_element (OSPF_NODE,
7555 &ospf_default_information_originate_always_metric_cmd);
7556 install_element (OSPF_NODE,
7557 &ospf_default_information_originate_always_cmd);
7558 install_element (OSPF_NODE,
7559 &ospf_default_information_originate_always_type_metric_cmd);
7560 install_element (OSPF_NODE,
7561 &ospf_default_information_originate_always_type_cmd);
7562
7563 install_element (OSPF_NODE,
7564 &ospf_default_information_originate_metric_type_routemap_cmd);
7565 install_element (OSPF_NODE,
7566 &ospf_default_information_originate_metric_routemap_cmd);
7567 install_element (OSPF_NODE,
7568 &ospf_default_information_originate_routemap_cmd);
7569 install_element (OSPF_NODE,
7570 &ospf_default_information_originate_type_metric_routemap_cmd);
7571 install_element (OSPF_NODE,
7572 &ospf_default_information_originate_type_routemap_cmd);
7573 install_element (OSPF_NODE,
7574 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7575 install_element (OSPF_NODE,
7576 &ospf_default_information_originate_always_metric_routemap_cmd);
7577 install_element (OSPF_NODE,
7578 &ospf_default_information_originate_always_routemap_cmd);
7579 install_element (OSPF_NODE,
7580 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7581 install_element (OSPF_NODE,
7582 &ospf_default_information_originate_always_type_routemap_cmd);
7583
7584 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7585
7586 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7587 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7588 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7589
7590 install_element (OSPF_NODE, &ospf_distance_cmd);
7591 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7592 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7593 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7594 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7595 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7596 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7597 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7598 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7599 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7600 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7601 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7602 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7603 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7604 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7605 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7606 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7607 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7608#if 0
7609 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7610 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7611 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7612 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7613#endif /* 0 */
7614}
7615
7616struct cmd_node ospf_node =
7617{
7618 OSPF_NODE,
7619 "%s(config-router)# ",
7620 1
7621};
7622
7623
7624/* Install OSPF related vty commands. */
7625void
7626ospf_vty_init ()
7627{
7628 /* Install ospf top node. */
7629 install_node (&ospf_node, ospf_config_write);
7630
7631 /* "router ospf" commands. */
7632 install_element (CONFIG_NODE, &router_ospf_cmd);
7633 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7634
7635 install_default (OSPF_NODE);
7636
7637 /* "ospf router-id" commands. */
7638 install_element (OSPF_NODE, &ospf_router_id_cmd);
7639 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007640 install_element (OSPF_NODE, &router_ospf_id_cmd);
7641 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007642
7643 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007644 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7645 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7646 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7647 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007648
7649 /* "ospf abr-type" commands. */
7650 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7651 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7652
7653 /* "ospf rfc1583-compatible" commands. */
7654 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7655 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7656 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7657 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7658
7659 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007660 install_element (OSPF_NODE, &ospf_network_area_cmd);
7661 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007662
7663 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007664 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7665 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7666 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007667
7668 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007669 install_element (OSPF_NODE, &ospf_area_range_cmd);
7670 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7671 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7672 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7673 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7674 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7675 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7676 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7677 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7678 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7679 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007680
7681 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007682 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7683 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007684
paula2c62832003-04-23 17:01:31 +00007685 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7686 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007687
paula2c62832003-04-23 17:01:31 +00007688 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7689 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007690
paula2c62832003-04-23 17:01:31 +00007691 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7692 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007693
paula2c62832003-04-23 17:01:31 +00007694 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7695 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007696
paula2c62832003-04-23 17:01:31 +00007697 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7698 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7699 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007700
paula2c62832003-04-23 17:01:31 +00007701 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7702 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007703
paula2c62832003-04-23 17:01:31 +00007704 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7705 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007706
paula2c62832003-04-23 17:01:31 +00007707 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7708 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7709 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007710
paula2c62832003-04-23 17:01:31 +00007711 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7712 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7713 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007714
7715 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007716 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7717 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7718 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7719 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007720
paul718e3742002-12-13 20:15:29 +00007721 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007722 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7723 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7724 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7725 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7726 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7727 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007728
paula2c62832003-04-23 17:01:31 +00007729 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7730 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007731
paula2c62832003-04-23 17:01:31 +00007732 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7733 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007734
paula2c62832003-04-23 17:01:31 +00007735 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7736 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007737
paula2c62832003-04-23 17:01:31 +00007738 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7739 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007740
paula2c62832003-04-23 17:01:31 +00007741 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7742 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007743
paula2c62832003-04-23 17:01:31 +00007744 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7745 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007746
paula2c62832003-04-23 17:01:31 +00007747 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7748 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7749 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007750
paula2c62832003-04-23 17:01:31 +00007751 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7752 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007753
7754 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007755 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7756 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7757 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7758 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7759 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7760 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7761 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7762 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007763
7764 /* Init interface related vty commands. */
7765 ospf_vty_if_init ();
7766
7767 /* Init zebra related vty commands. */
7768 ospf_vty_zebra_init ();
7769}