blob: c0e1f6cea9951e4b6c7d429e82f8ffbf6991a9de [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;
paul718e3742002-12-13 20:15:29 +00002322
2323 refbw = strtol (argv[0], NULL, 10);
2324 if (refbw < 1 || refbw > 4294967)
2325 {
2326 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2327 return CMD_WARNING;
2328 }
2329
2330 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002331 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002332 return CMD_SUCCESS;
2333
paul68980082003-03-25 05:07:42 +00002334 ospf->ref_bandwidth = refbw * 1000;
paul718e3742002-12-13 20:15:29 +00002335 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2336 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2337
paul020709f2003-04-04 02:44:16 +00002338 for (node = listhead (om->iflist); node; nextnode (node))
2339 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002340
2341 return CMD_SUCCESS;
2342}
2343
paula2c62832003-04-23 17:01:31 +00002344DEFUN (no_ospf_auto_cost_reference_bandwidth,
2345 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002346 "no auto-cost reference-bandwidth",
2347 NO_STR
2348 "Calculate OSPF interface cost according to bandwidth\n"
2349 "Use reference bandwidth method to assign OSPF cost\n")
2350{
paul68980082003-03-25 05:07:42 +00002351 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002352 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002353
paul68980082003-03-25 05:07:42 +00002354 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002355 return CMD_SUCCESS;
2356
paul68980082003-03-25 05:07:42 +00002357 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002358 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2359 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2360
paul020709f2003-04-04 02:44:16 +00002361 for (node = listhead (om->iflist); node; nextnode (node))
2362 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002363
2364 return CMD_SUCCESS;
2365}
2366
hassoeb1ce602004-10-08 08:17:22 +00002367const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002368{
2369 "Unknown",
2370 "Standard (RFC2328)",
2371 "Alternative IBM",
2372 "Alternative Cisco",
2373 "Alternative Shortcut"
2374};
2375
hassoeb1ce602004-10-08 08:17:22 +00002376const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002377{
2378 "Default",
2379 "Enabled",
2380 "Disabled"
2381};
2382
2383
2384
2385void
2386show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2387{
2388 /* Show Area ID. */
2389 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2390
2391 /* Show Area type/mode. */
2392 if (OSPF_IS_AREA_BACKBONE (area))
2393 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2394 else
2395 {
2396 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002397 vty_out (vty, " (Stub%s%s)",
2398 area->no_summary ? ", no summary" : "",
2399 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002400
paulb0a053b2003-06-22 09:04:47 +00002401 else if (area->external_routing == OSPF_AREA_NSSA)
2402 vty_out (vty, " (NSSA%s%s)",
2403 area->no_summary ? ", no summary" : "",
2404 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002405
2406 vty_out (vty, "%s", VTY_NEWLINE);
2407 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002408 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002409 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002410 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002411 }
2412
2413 /* Show number of interfaces. */
2414 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2415 "Active: %d%s", listcount (area->oiflist),
2416 area->act_ints, VTY_NEWLINE);
2417
paul718e3742002-12-13 20:15:29 +00002418 if (area->external_routing == OSPF_AREA_NSSA)
2419 {
2420 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 +00002421 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002422 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2423 VTY_NEWLINE);
2424 else if (area->NSSATranslatorState)
2425 {
2426 vty_out (vty, " We are an ABR and ");
2427 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2428 vty_out (vty, "the NSSA Elected Translator. %s",
2429 VTY_NEWLINE);
2430 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2431 vty_out (vty, "always an NSSA Translator. %s",
2432 VTY_NEWLINE);
2433 }
paul718e3742002-12-13 20:15:29 +00002434 else
paulb0a053b2003-06-22 09:04:47 +00002435 {
2436 vty_out (vty, " We are an ABR, but ");
2437 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2438 vty_out (vty, "not the NSSA Elected Translator. %s",
2439 VTY_NEWLINE);
2440 else
hassoc6b87812004-12-22 13:09:59 +00002441 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002442 VTY_NEWLINE);
2443 }
paul718e3742002-12-13 20:15:29 +00002444 }
paul718e3742002-12-13 20:15:29 +00002445
2446 /* Show number of fully adjacent neighbors. */
2447 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002448 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002449
2450 /* Show authentication type. */
2451 vty_out (vty, " Area has ");
2452 if (area->auth_type == OSPF_AUTH_NULL)
2453 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2454 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2455 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2456 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2457 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2458
2459 if (!OSPF_IS_AREA_BACKBONE (area))
2460 vty_out (vty, " Number of full virtual adjacencies going through"
2461 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2462
2463 /* Show SPF calculation times. */
2464 vty_out (vty, " SPF algorithm executed %d times%s",
2465 area->spf_calculation, VTY_NEWLINE);
2466
2467 /* Show number of LSA. */
2468 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002469 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2470 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2471 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2472 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2473 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2474 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2475 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2476 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2477 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2478 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2479 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2480 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2481 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2482 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2483 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2484#ifdef HAVE_OPAQUE_LSA
2485 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2486 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2487 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2488 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2489 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2490 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2491#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002492 vty_out (vty, "%s", VTY_NEWLINE);
2493}
2494
2495DEFUN (show_ip_ospf,
2496 show_ip_ospf_cmd,
2497 "show ip ospf",
2498 SHOW_STR
2499 IP_STR
2500 "OSPF information\n")
2501{
hasso52dc7ee2004-09-23 19:18:23 +00002502 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002503 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002504 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002505
2506 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002507 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002508 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002509 {
2510 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2511 return CMD_SUCCESS;
2512 }
2513
2514 /* Show Router ID. */
2515 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002516 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002517 VTY_NEWLINE);
2518
2519 /* Show capability. */
2520 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2521 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2522 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002523 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002524 "enabled" : "disabled", VTY_NEWLINE);
2525#ifdef HAVE_OPAQUE_LSA
2526 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002527 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002528 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002529 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002530 " (origination blocked)" : "",
2531 VTY_NEWLINE);
2532#endif /* HAVE_OPAQUE_LSA */
2533
2534 /* Show SPF timers. */
2535 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
paul68980082003-03-25 05:07:42 +00002536 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002537
2538 /* Show refresh parameters. */
2539 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002540 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002541
2542 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002543 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002544 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002545 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002546
paul68980082003-03-25 05:07:42 +00002547 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002548 vty_out (vty, " This router is an ASBR "
2549 "(injecting external routing information)%s", VTY_NEWLINE);
2550
2551 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002552 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2553 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2554 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2555#ifdef HAVE_OPAQUE_LSA
2556 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2557 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2558 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2559#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002560 /* Show number of areas attached. */
2561 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002562 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002563
2564 /* Show each area status. */
paul68980082003-03-25 05:07:42 +00002565 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002566 if ((area = getdata (node)) != NULL)
2567 show_ip_ospf_area (vty, area);
2568
2569 return CMD_SUCCESS;
2570}
2571
2572
ajsfd651fa2005-03-29 16:08:16 +00002573static void
paul68980082003-03-25 05:07:42 +00002574show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2575 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002576{
ajsfd651fa2005-03-29 16:08:16 +00002577 int is_up;
paul718e3742002-12-13 20:15:29 +00002578 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002579 struct route_node *rn;
2580 char buf[9];
2581
paul718e3742002-12-13 20:15:29 +00002582 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002583 vty_out (vty, "%s is %s%s", ifp->name,
2584 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002585 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2586 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2587 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002588
2589 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002590 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002591 {
2592 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2593 return;
2594 }
ajsfd651fa2005-03-29 16:08:16 +00002595 else if (!is_up)
2596 {
2597 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2598 VTY_NEWLINE);
2599 return;
2600 }
2601
paul718e3742002-12-13 20:15:29 +00002602 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2603 {
2604 struct ospf_interface *oi = rn->info;
2605
2606 if (oi == NULL)
2607 continue;
2608
2609 /* Show OSPF interface information. */
2610 vty_out (vty, " Internet Address %s/%d,",
2611 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2612
hasso3fb9cd62004-10-19 19:44:43 +00002613 if (oi->connected->destination)
2614 vty_out (vty, " %s %s,",
2615 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2616 inet_ntoa (oi->connected->destination->u.prefix4));
2617
paul718e3742002-12-13 20:15:29 +00002618 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2619 VTY_NEWLINE);
2620
2621 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002622 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002623 oi->output_cost, VTY_NEWLINE);
2624
2625 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2626 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2627 PRIORITY (oi), VTY_NEWLINE);
2628
2629 /* Show DR information. */
2630 if (DR (oi).s_addr == 0)
2631 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2632 else
2633 {
2634 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2635 if (nbr == NULL)
2636 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2637 else
2638 {
2639 vty_out (vty, " Designated Router (ID) %s,",
2640 inet_ntoa (nbr->router_id));
2641 vty_out (vty, " Interface Address %s%s",
2642 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2643 }
2644 }
2645
2646 /* Show BDR information. */
2647 if (BDR (oi).s_addr == 0)
2648 vty_out (vty, " No backup designated router on this network%s",
2649 VTY_NEWLINE);
2650 else
2651 {
2652 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2653 if (nbr == NULL)
2654 vty_out (vty, " No backup designated router on this network%s",
2655 VTY_NEWLINE);
2656 else
2657 {
2658 vty_out (vty, " Backup Designated Router (ID) %s,",
2659 inet_ntoa (nbr->router_id));
2660 vty_out (vty, " Interface Address %s%s",
2661 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2662 }
2663 }
ajsba6454e2005-02-08 15:37:30 +00002664
2665 vty_out (vty, " Multicast group memberships:");
2666 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2667 vty_out (vty, " OSPFAllRouters");
2668 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2669 vty_out (vty, " OSPFDesignatedRouters");
2670 if (!CHECK_FLAG(oi->multicast_memberships,
2671 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2672 vty_out (vty, " <None>");
2673 vty_out (vty, "%s", VTY_NEWLINE);
2674
paul718e3742002-12-13 20:15:29 +00002675 vty_out (vty, " Timer intervals configured,");
2676 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2677 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2678 OSPF_IF_PARAM (oi, v_wait),
2679 OSPF_IF_PARAM (oi, retransmit_interval),
2680 VTY_NEWLINE);
2681
2682 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2683 vty_out (vty, " Hello due in %s%s",
2684 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2685 else /* OSPF_IF_PASSIVE is set */
2686 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2687
2688 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002689 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002690 VTY_NEWLINE);
2691 }
2692}
2693
2694DEFUN (show_ip_ospf_interface,
2695 show_ip_ospf_interface_cmd,
2696 "show ip ospf interface [INTERFACE]",
2697 SHOW_STR
2698 IP_STR
2699 "OSPF information\n"
2700 "Interface information\n"
2701 "Interface name\n")
2702{
2703 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002704 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002705 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002706
paul020709f2003-04-04 02:44:16 +00002707 ospf = ospf_lookup ();
2708
paul718e3742002-12-13 20:15:29 +00002709 /* Show All Interfaces. */
2710 if (argc == 0)
2711 for (node = listhead (iflist); node; nextnode (node))
paul68980082003-03-25 05:07:42 +00002712 show_ip_ospf_interface_sub (vty, ospf, node->data);
paul718e3742002-12-13 20:15:29 +00002713 /* Interface name is specified. */
2714 else
2715 {
2716 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2717 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2718 else
paul68980082003-03-25 05:07:42 +00002719 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002720 }
2721
2722 return CMD_SUCCESS;
2723}
2724
2725void
2726show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2727{
2728 struct route_node *rn;
2729 struct ospf_neighbor *nbr;
2730 char msgbuf[16];
2731 char timebuf[9];
2732
2733 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2734 if ((nbr = rn->info))
2735 /* Do not show myself. */
2736 if (nbr != oi->nbr_self)
2737 /* Down state is not shown. */
2738 if (nbr->state != NSM_Down)
2739 {
2740 ospf_nbr_state_message (nbr, msgbuf, 16);
2741
2742 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2743 vty_out (vty, "%-15s %3d %-15s %8s ",
2744 "-", nbr->priority,
2745 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2746 else
2747 vty_out (vty, "%-15s %3d %-15s %8s ",
2748 inet_ntoa (nbr->router_id), nbr->priority,
2749 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2750 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2751 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2752 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2753 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2754 VTY_NEWLINE);
2755 }
2756}
2757
2758DEFUN (show_ip_ospf_neighbor,
2759 show_ip_ospf_neighbor_cmd,
2760 "show ip ospf neighbor",
2761 SHOW_STR
2762 IP_STR
2763 "OSPF information\n"
2764 "Neighbor list\n")
2765{
paul020709f2003-04-04 02:44:16 +00002766 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002767 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002768
paul020709f2003-04-04 02:44:16 +00002769 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002770 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002771 {
2772 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2773 return CMD_SUCCESS;
2774 }
2775
2776 /* Show All neighbors. */
2777 vty_out (vty, "%sNeighbor ID Pri State Dead "
2778 "Time Address Interface RXmtL "
2779 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2780
paul68980082003-03-25 05:07:42 +00002781 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul020709f2003-04-04 02:44:16 +00002782 show_ip_ospf_neighbor_sub (vty, getdata (node));
paul718e3742002-12-13 20:15:29 +00002783
2784 return CMD_SUCCESS;
2785}
2786
2787DEFUN (show_ip_ospf_neighbor_all,
2788 show_ip_ospf_neighbor_all_cmd,
2789 "show ip ospf neighbor all",
2790 SHOW_STR
2791 IP_STR
2792 "OSPF information\n"
2793 "Neighbor list\n"
2794 "include down status neighbor\n")
2795{
paul68980082003-03-25 05:07:42 +00002796 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002797 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002798
paul68980082003-03-25 05:07:42 +00002799 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002800 {
2801 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2802 return CMD_SUCCESS;
2803 }
2804
2805 /* Show All neighbors. */
2806 vty_out (vty, "%sNeighbor ID Pri State Dead "
2807 "Time Address Interface RXmtL "
2808 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2809
paul68980082003-03-25 05:07:42 +00002810 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002811 {
2812 struct ospf_interface *oi = getdata (node);
hasso52dc7ee2004-09-23 19:18:23 +00002813 struct listnode *nbr_node;
paul718e3742002-12-13 20:15:29 +00002814
2815 show_ip_ospf_neighbor_sub (vty, oi);
2816
2817 /* print Down neighbor status */
2818 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
2819 {
2820 struct ospf_nbr_nbma *nbr_nbma;
2821
2822 nbr_nbma = getdata (nbr_node);
2823
2824 if (nbr_nbma->nbr == NULL
2825 || nbr_nbma->nbr->state == NSM_Down)
2826 {
2827 vty_out (vty, "%-15s %3d %-15s %8s ",
2828 "-", nbr_nbma->priority, "Down", "-");
2829 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2830 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2831 0, 0, 0, VTY_NEWLINE);
2832 }
2833 }
2834 }
2835
2836 return CMD_SUCCESS;
2837}
2838
2839DEFUN (show_ip_ospf_neighbor_int,
2840 show_ip_ospf_neighbor_int_cmd,
2841 "show ip ospf neighbor A.B.C.D",
2842 SHOW_STR
2843 IP_STR
2844 "OSPF information\n"
2845 "Neighbor list\n"
2846 "Interface name\n")
2847{
paul020709f2003-04-04 02:44:16 +00002848 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002849 struct ospf_interface *oi;
2850 struct in_addr addr;
2851 int ret;
2852
paul718e3742002-12-13 20:15:29 +00002853 ret = inet_aton (argv[0], &addr);
2854 if (!ret)
2855 {
2856 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2857 VTY_NEWLINE);
2858 return CMD_WARNING;
2859 }
2860
paul020709f2003-04-04 02:44:16 +00002861 ospf = ospf_lookup ();
2862 if (ospf == NULL)
2863 {
2864 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2865 return CMD_SUCCESS;
2866 }
2867
paul68980082003-03-25 05:07:42 +00002868 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00002869 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2870 else
2871 {
2872 vty_out (vty, "%sNeighbor ID Pri State Dead "
2873 "Time Address Interface RXmtL "
2874 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2875 show_ip_ospf_neighbor_sub (vty, oi);
2876 }
2877
2878 return CMD_SUCCESS;
2879}
2880
2881void
2882show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2883 struct ospf_nbr_nbma *nbr_nbma)
2884{
2885 char timebuf[9];
2886
2887 /* Show neighbor ID. */
2888 vty_out (vty, " Neighbor %s,", "-");
2889
2890 /* Show interface address. */
2891 vty_out (vty, " interface address %s%s",
2892 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2893 /* Show Area ID. */
2894 vty_out (vty, " In the area %s via interface %s%s",
2895 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2896 /* Show neighbor priority and state. */
2897 vty_out (vty, " Neighbor priority is %d, State is %s,",
2898 nbr_nbma->priority, "Down");
2899 /* Show state changes. */
2900 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2901
2902 /* Show PollInterval */
2903 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2904
2905 /* Show poll-interval timer. */
2906 vty_out (vty, " Poll timer due in %s%s",
2907 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2908
2909 /* Show poll-interval timer thread. */
2910 vty_out (vty, " Thread Poll Timer %s%s",
2911 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2912}
2913
2914void
2915show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2916 struct ospf_neighbor *nbr)
2917{
2918 char timebuf[9];
2919
2920 /* Show neighbor ID. */
2921 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2922 vty_out (vty, " Neighbor %s,", "-");
2923 else
2924 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2925
2926 /* Show interface address. */
2927 vty_out (vty, " interface address %s%s",
2928 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2929 /* Show Area ID. */
2930 vty_out (vty, " In the area %s via interface %s%s",
2931 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2932 /* Show neighbor priority and state. */
2933 vty_out (vty, " Neighbor priority is %d, State is %s,",
2934 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2935 /* Show state changes. */
2936 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2937
2938 /* Show Designated Rotuer ID. */
2939 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2940 /* Show Backup Designated Rotuer ID. */
2941 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2942 /* Show options. */
2943 vty_out (vty, " Options %d %s%s", nbr->options,
2944 ospf_options_dump (nbr->options), VTY_NEWLINE);
2945 /* Show Router Dead interval timer. */
2946 vty_out (vty, " Dead timer due in %s%s",
2947 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2948 /* Show Database Summary list. */
2949 vty_out (vty, " Database Summary List %d%s",
2950 ospf_db_summary_count (nbr), VTY_NEWLINE);
2951 /* Show Link State Request list. */
2952 vty_out (vty, " Link State Request List %ld%s",
2953 ospf_ls_request_count (nbr), VTY_NEWLINE);
2954 /* Show Link State Retransmission list. */
2955 vty_out (vty, " Link State Retransmission List %ld%s",
2956 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2957 /* Show inactivity timer thread. */
2958 vty_out (vty, " Thread Inactivity Timer %s%s",
2959 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2960 /* Show Database Description retransmission thread. */
2961 vty_out (vty, " Thread Database Description Retransmision %s%s",
2962 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2963 /* Show Link State Request Retransmission thread. */
2964 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2965 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2966 /* Show Link State Update Retransmission thread. */
2967 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2968 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2969}
2970
2971DEFUN (show_ip_ospf_neighbor_id,
2972 show_ip_ospf_neighbor_id_cmd,
2973 "show ip ospf neighbor A.B.C.D",
2974 SHOW_STR
2975 IP_STR
2976 "OSPF information\n"
2977 "Neighbor list\n"
2978 "Neighbor ID\n")
2979{
paul020709f2003-04-04 02:44:16 +00002980 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002981 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002982 struct ospf_neighbor *nbr;
2983 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
paul68980082003-03-25 05:07:42 +00003000 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003001 {
3002 struct ospf_interface *oi = getdata (node);
3003
3004 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3005 {
3006 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3007 return CMD_SUCCESS;
3008 }
3009 }
3010
3011 /* Nothing to show. */
3012 return CMD_SUCCESS;
3013}
3014
3015DEFUN (show_ip_ospf_neighbor_detail,
3016 show_ip_ospf_neighbor_detail_cmd,
3017 "show ip ospf neighbor detail",
3018 SHOW_STR
3019 IP_STR
3020 "OSPF information\n"
3021 "Neighbor list\n"
3022 "detail of all neighbors\n")
3023{
paul020709f2003-04-04 02:44:16 +00003024 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003025 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003026
paul020709f2003-04-04 02:44:16 +00003027 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003028 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003029 {
3030 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3031 return CMD_SUCCESS;
3032 }
paul718e3742002-12-13 20:15:29 +00003033
paul68980082003-03-25 05:07:42 +00003034 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003035 {
3036 struct ospf_interface *oi = getdata (node);
3037 struct route_node *rn;
3038 struct ospf_neighbor *nbr;
3039
3040 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3041 if ((nbr = rn->info))
3042 if (nbr != oi->nbr_self)
3043 if (nbr->state != NSM_Down)
3044 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3045 }
3046
3047 return CMD_SUCCESS;
3048}
3049
3050DEFUN (show_ip_ospf_neighbor_detail_all,
3051 show_ip_ospf_neighbor_detail_all_cmd,
3052 "show ip ospf neighbor detail all",
3053 SHOW_STR
3054 IP_STR
3055 "OSPF information\n"
3056 "Neighbor list\n"
3057 "detail of all neighbors\n"
3058 "include down status neighbor\n")
3059{
paul020709f2003-04-04 02:44:16 +00003060 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003061 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003062
paul020709f2003-04-04 02:44:16 +00003063 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003064 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003065 {
3066 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3067 return CMD_SUCCESS;
3068 }
paul718e3742002-12-13 20:15:29 +00003069
paul68980082003-03-25 05:07:42 +00003070 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003071 {
3072 struct ospf_interface *oi = getdata (node);
3073 struct route_node *rn;
3074 struct ospf_neighbor *nbr;
3075
3076 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3077 if ((nbr = rn->info))
3078 if (nbr != oi->nbr_self)
3079 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3080 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3081
3082 if (oi->type == OSPF_IFTYPE_NBMA)
3083 {
hasso52dc7ee2004-09-23 19:18:23 +00003084 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003085
3086 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
3087 {
3088 struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
3089 if (nbr_nbma->nbr == NULL
3090 || nbr_nbma->nbr->state == NSM_Down)
3091 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3092 }
3093 }
3094 }
3095
3096 return CMD_SUCCESS;
3097}
3098
3099DEFUN (show_ip_ospf_neighbor_int_detail,
3100 show_ip_ospf_neighbor_int_detail_cmd,
3101 "show ip ospf neighbor A.B.C.D detail",
3102 SHOW_STR
3103 IP_STR
3104 "OSPF information\n"
3105 "Neighbor list\n"
3106 "Interface address\n"
3107 "detail of all neighbors")
3108{
paul020709f2003-04-04 02:44:16 +00003109 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003110 struct ospf_interface *oi;
3111 struct in_addr addr;
3112 int ret;
3113
3114 ret = inet_aton (argv[0], &addr);
3115 if (!ret)
3116 {
3117 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3118 VTY_NEWLINE);
3119 return CMD_WARNING;
3120 }
3121
paul020709f2003-04-04 02:44:16 +00003122 ospf = ospf_lookup ();
3123 if (ospf == NULL)
3124 {
3125 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3126 return CMD_SUCCESS;
3127 }
paul68980082003-03-25 05:07:42 +00003128
paul020709f2003-04-04 02:44:16 +00003129 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00003130 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3131 else
3132 {
3133 struct route_node *rn;
3134 struct ospf_neighbor *nbr;
3135
3136 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3137 if ((nbr = rn->info))
3138 if (nbr != oi->nbr_self)
3139 if (nbr->state != NSM_Down)
3140 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3141 }
3142
3143 return CMD_SUCCESS;
3144}
3145
3146
3147/* Show functions */
3148int
paul020709f2003-04-04 02:44:16 +00003149show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003150{
paul718e3742002-12-13 20:15:29 +00003151 struct router_lsa *rl;
3152 struct summary_lsa *sl;
3153 struct as_external_lsa *asel;
3154 struct prefix_ipv4 p;
3155
3156 if (lsa != NULL)
3157 /* If self option is set, check LSA self flag. */
3158 if (self == 0 || IS_LSA_SELF (lsa))
3159 {
3160 /* LSA common part show. */
3161 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3162 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3163 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3164 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3165 /* LSA specific part show. */
3166 switch (lsa->data->type)
3167 {
3168 case OSPF_ROUTER_LSA:
3169 rl = (struct router_lsa *) lsa->data;
3170 vty_out (vty, " %-d", ntohs (rl->links));
3171 break;
3172 case OSPF_SUMMARY_LSA:
3173 sl = (struct summary_lsa *) lsa->data;
3174
3175 p.family = AF_INET;
3176 p.prefix = sl->header.id;
3177 p.prefixlen = ip_masklen (sl->mask);
3178 apply_mask_ipv4 (&p);
3179
3180 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3181 break;
3182 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003183 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003184 asel = (struct as_external_lsa *) lsa->data;
3185
3186 p.family = AF_INET;
3187 p.prefix = asel->header.id;
3188 p.prefixlen = ip_masklen (asel->mask);
3189 apply_mask_ipv4 (&p);
3190
3191 vty_out (vty, " %s %s/%d [0x%lx]",
3192 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3193 inet_ntoa (p.prefix), p.prefixlen,
3194 (u_long)ntohl (asel->e[0].route_tag));
3195 break;
3196 case OSPF_NETWORK_LSA:
3197 case OSPF_ASBR_SUMMARY_LSA:
3198#ifdef HAVE_OPAQUE_LSA
3199 case OSPF_OPAQUE_LINK_LSA:
3200 case OSPF_OPAQUE_AREA_LSA:
3201 case OSPF_OPAQUE_AS_LSA:
3202#endif /* HAVE_OPAQUE_LSA */
3203 default:
3204 break;
3205 }
3206 vty_out (vty, VTY_NEWLINE);
3207 }
3208
3209 return 0;
3210}
3211
hassoeb1ce602004-10-08 08:17:22 +00003212const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003213{
3214 "unknown",
3215 "Router Link States",
3216 "Net Link States",
3217 "Summary Link States",
3218 "ASBR-Summary Link States",
3219 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003220 "Group Membership LSA",
3221 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003222#ifdef HAVE_OPAQUE_LSA
3223 "Type-8 LSA",
3224 "Link-Local Opaque-LSA",
3225 "Area-Local Opaque-LSA",
3226 "AS-external Opaque-LSA",
3227#endif /* HAVE_OPAQUE_LSA */
3228};
3229
3230#define SHOW_OSPF_COMMON_HEADER \
3231 "Link ID ADV Router Age Seq# CkSum"
3232
hassoeb1ce602004-10-08 08:17:22 +00003233const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003234{
3235 "",
3236 "Link ID ADV Router Age Seq# CkSum Link count",
3237 "Link ID ADV Router Age Seq# CkSum",
3238 "Link ID ADV Router Age Seq# CkSum Route",
3239 "Link ID ADV Router Age Seq# CkSum",
3240 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003241 " --- header for Group Member ----",
3242 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003243#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003244 " --- type-8 ---",
3245 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3246 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3247 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3248#endif /* HAVE_OPAQUE_LSA */
3249};
3250
hassoeb1ce602004-10-08 08:17:22 +00003251const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003252{
3253 "Self-originated",
3254 "Checked",
3255 "Received",
3256 "Approved",
3257 "Discard",
paul4957f492003-06-27 01:28:45 +00003258 "Translated",
paul4957f492003-06-27 01:28:45 +00003259};
3260
paul718e3742002-12-13 20:15:29 +00003261void
3262show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3263{
3264 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003265
paul718e3742002-12-13 20:15:29 +00003266 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003267 vty_out (vty, " Options: 0x%-2x : %s%s",
3268 lsa->data->options,
3269 ospf_options_dump(lsa->data->options),
3270 VTY_NEWLINE);
3271 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003272 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003273 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3274 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003275
3276 if (lsa->data->type == OSPF_ROUTER_LSA)
3277 {
3278 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3279
3280 if (rlsa->flags)
3281 vty_out (vty, " :%s%s%s%s",
3282 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3283 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3284 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3285 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3286
3287 vty_out (vty, "%s", VTY_NEWLINE);
3288 }
3289 vty_out (vty, " LS Type: %s%s",
3290 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3291 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3292 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3293 vty_out (vty, " Advertising Router: %s%s",
3294 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3295 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3296 VTY_NEWLINE);
3297 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3298 VTY_NEWLINE);
3299 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3300}
3301
hassoeb1ce602004-10-08 08:17:22 +00003302const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003303{
3304 "(null)",
3305 "another Router (point-to-point)",
3306 "a Transit Network",
3307 "Stub Network",
3308 "a Virtual Link",
3309};
3310
hassoeb1ce602004-10-08 08:17:22 +00003311const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003312{
3313 "(null)",
3314 "Neighboring Router ID",
3315 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003316 "Net",
paul718e3742002-12-13 20:15:29 +00003317 "Neighboring Router ID",
3318};
3319
hassoeb1ce602004-10-08 08:17:22 +00003320const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003321{
3322 "(null)",
3323 "Router Interface address",
3324 "Router Interface address",
3325 "Network Mask",
3326 "Router Interface address",
3327};
3328
3329/* Show router-LSA each Link information. */
3330void
3331show_ip_ospf_database_router_links (struct vty *vty,
3332 struct router_lsa *rl)
3333{
3334 int len, i, type;
3335
3336 len = ntohs (rl->header.length) - 4;
3337 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3338 {
3339 type = rl->link[i].type;
3340
3341 vty_out (vty, " Link connected to: %s%s",
3342 link_type_desc[type], VTY_NEWLINE);
3343 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3344 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3345 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3346 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3347 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3348 vty_out (vty, " TOS 0 Metric: %d%s",
3349 ntohs (rl->link[i].metric), VTY_NEWLINE);
3350 vty_out (vty, "%s", VTY_NEWLINE);
3351 }
3352}
3353
3354/* Show router-LSA detail information. */
3355int
3356show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3357{
3358 if (lsa != NULL)
3359 {
3360 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3361
3362 show_ip_ospf_database_header (vty, lsa);
3363
3364 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3365 VTY_NEWLINE, VTY_NEWLINE);
3366
3367 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003368 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003369 }
3370
3371 return 0;
3372}
3373
3374/* Show network-LSA detail information. */
3375int
3376show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3377{
3378 int length, i;
3379
3380 if (lsa != NULL)
3381 {
3382 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3383
3384 show_ip_ospf_database_header (vty, lsa);
3385
3386 vty_out (vty, " Network Mask: /%d%s",
3387 ip_masklen (nl->mask), VTY_NEWLINE);
3388
3389 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3390
3391 for (i = 0; length > 0; i++, length -= 4)
3392 vty_out (vty, " Attached Router: %s%s",
3393 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3394
3395 vty_out (vty, "%s", VTY_NEWLINE);
3396 }
3397
3398 return 0;
3399}
3400
3401/* Show summary-LSA detail information. */
3402int
3403show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3404{
3405 if (lsa != NULL)
3406 {
3407 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3408
3409 show_ip_ospf_database_header (vty, lsa);
3410
3411 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3412 VTY_NEWLINE);
3413 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3414 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003415 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003416 }
3417
3418 return 0;
3419}
3420
3421/* Show summary-ASBR-LSA detail information. */
3422int
3423show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3424{
3425 if (lsa != NULL)
3426 {
3427 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3428
3429 show_ip_ospf_database_header (vty, lsa);
3430
3431 vty_out (vty, " Network Mask: /%d%s",
3432 ip_masklen (sl->mask), VTY_NEWLINE);
3433 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3434 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003435 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003436 }
3437
3438 return 0;
3439}
3440
3441/* Show AS-external-LSA detail information. */
3442int
3443show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3444{
3445 if (lsa != NULL)
3446 {
3447 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3448
3449 show_ip_ospf_database_header (vty, lsa);
3450
3451 vty_out (vty, " Network Mask: /%d%s",
3452 ip_masklen (al->mask), VTY_NEWLINE);
3453 vty_out (vty, " Metric Type: %s%s",
3454 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3455 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3456 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3457 vty_out (vty, " Metric: %d%s",
3458 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3459 vty_out (vty, " Forward Address: %s%s",
3460 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3461
3462 vty_out (vty, " External Route Tag: %lu%s%s",
3463 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3464 }
3465
3466 return 0;
3467}
3468
ajs2a42e282004-12-08 18:43:03 +00003469/* N.B. This function currently seems to be unused. */
paul718e3742002-12-13 20:15:29 +00003470int
3471show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3472{
3473 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3474
3475 /* show_ip_ospf_database_header (vty, lsa); */
3476
ajs2a42e282004-12-08 18:43:03 +00003477 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003478 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003479 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003480 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3481 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003482 zlog_debug( " TOS: 0%s", "\n");
3483 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003484 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003485 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003486 inet_ntoa (al->e[0].fwd_addr), "\n");
3487
ajs2a42e282004-12-08 18:43:03 +00003488 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003489 ntohl (al->e[0].route_tag), "\n", "\n");
3490
3491 return 0;
3492}
3493
3494/* Show AS-NSSA-LSA detail information. */
3495int
3496show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3497{
3498 if (lsa != NULL)
3499 {
3500 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3501
3502 show_ip_ospf_database_header (vty, lsa);
3503
3504 vty_out (vty, " Network Mask: /%d%s",
3505 ip_masklen (al->mask), VTY_NEWLINE);
3506 vty_out (vty, " Metric Type: %s%s",
3507 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3508 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3509 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3510 vty_out (vty, " Metric: %d%s",
3511 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3512 vty_out (vty, " NSSA: Forward Address: %s%s",
3513 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3514
3515 vty_out (vty, " External Route Tag: %u%s%s",
3516 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3517 }
3518
3519 return 0;
3520}
3521
paul718e3742002-12-13 20:15:29 +00003522int
3523show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3524{
3525 return 0;
3526}
3527
3528#ifdef HAVE_OPAQUE_LSA
3529int
3530show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3531{
3532 if (lsa != NULL)
3533 {
3534 show_ip_ospf_database_header (vty, lsa);
3535 show_opaque_info_detail (vty, lsa);
3536
3537 vty_out (vty, "%s", VTY_NEWLINE);
3538 }
3539 return 0;
3540}
3541#endif /* HAVE_OPAQUE_LSA */
3542
3543int (*show_function[])(struct vty *, struct ospf_lsa *) =
3544{
3545 NULL,
3546 show_router_lsa_detail,
3547 show_network_lsa_detail,
3548 show_summary_lsa_detail,
3549 show_summary_asbr_lsa_detail,
3550 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003551 show_func_dummy,
3552 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003553#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003554 NULL, /* type-8 */
3555 show_opaque_lsa_detail,
3556 show_opaque_lsa_detail,
3557 show_opaque_lsa_detail,
3558#endif /* HAVE_OPAQUE_LSA */
3559};
3560
3561void
3562show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3563 struct in_addr *adv_router)
3564{
3565 memset (lp, 0, sizeof (struct prefix_ls));
3566 lp->family = 0;
3567 if (id == NULL)
3568 lp->prefixlen = 0;
3569 else if (adv_router == NULL)
3570 {
3571 lp->prefixlen = 32;
3572 lp->id = *id;
3573 }
3574 else
3575 {
3576 lp->prefixlen = 64;
3577 lp->id = *id;
3578 lp->adv_router = *adv_router;
3579 }
3580}
3581
3582void
3583show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3584 struct in_addr *id, struct in_addr *adv_router)
3585{
3586 struct prefix_ls lp;
3587 struct route_node *rn, *start;
3588 struct ospf_lsa *lsa;
3589
3590 show_lsa_prefix_set (vty, &lp, id, adv_router);
3591 start = route_node_get (rt, (struct prefix *) &lp);
3592 if (start)
3593 {
3594 route_lock_node (start);
3595 for (rn = start; rn; rn = route_next_until (rn, start))
3596 if ((lsa = rn->info))
3597 {
paul718e3742002-12-13 20:15:29 +00003598 if (show_function[lsa->data->type] != NULL)
3599 show_function[lsa->data->type] (vty, lsa);
3600 }
3601 route_unlock_node (start);
3602 }
3603}
3604
3605/* Show detail LSA information
3606 -- if id is NULL then show all LSAs. */
3607void
paul020709f2003-04-04 02:44:16 +00003608show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003609 struct in_addr *id, struct in_addr *adv_router)
3610{
hasso52dc7ee2004-09-23 19:18:23 +00003611 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003612
3613 switch (type)
3614 {
3615 case OSPF_AS_EXTERNAL_LSA:
3616#ifdef HAVE_OPAQUE_LSA
3617 case OSPF_OPAQUE_AS_LSA:
3618#endif /* HAVE_OPAQUE_LSA */
3619 vty_out (vty, " %s %s%s",
3620 show_database_desc[type],
3621 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003622 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003623 break;
3624 default:
paul68980082003-03-25 05:07:42 +00003625 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003626 {
3627 struct ospf_area *area = node->data;
3628 vty_out (vty, "%s %s (Area %s)%s%s",
3629 VTY_NEWLINE, show_database_desc[type],
3630 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3631 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3632 }
3633 break;
3634 }
3635}
3636
3637void
3638show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3639 struct in_addr *adv_router)
3640{
3641 struct route_node *rn;
3642 struct ospf_lsa *lsa;
3643
3644 for (rn = route_top (rt); rn; rn = route_next (rn))
3645 if ((lsa = rn->info))
3646 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3647 {
paul718e3742002-12-13 20:15:29 +00003648 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3649 continue;
paul718e3742002-12-13 20:15:29 +00003650 if (show_function[lsa->data->type] != NULL)
3651 show_function[lsa->data->type] (vty, lsa);
3652 }
3653}
3654
3655/* Show detail LSA information. */
3656void
paul020709f2003-04-04 02:44:16 +00003657show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003658 struct in_addr *adv_router)
3659{
hasso52dc7ee2004-09-23 19:18:23 +00003660 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003661
3662 switch (type)
3663 {
3664 case OSPF_AS_EXTERNAL_LSA:
3665#ifdef HAVE_OPAQUE_LSA
3666 case OSPF_OPAQUE_AS_LSA:
3667#endif /* HAVE_OPAQUE_LSA */
3668 vty_out (vty, " %s %s%s",
3669 show_database_desc[type],
3670 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003671 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003672 adv_router);
3673 break;
3674 default:
paul68980082003-03-25 05:07:42 +00003675 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003676 {
3677 struct ospf_area *area = node->data;
3678 vty_out (vty, "%s %s (Area %s)%s%s",
3679 VTY_NEWLINE, show_database_desc[type],
3680 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3681 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3682 adv_router);
3683 }
3684 break;
3685 }
3686}
3687
3688void
paul020709f2003-04-04 02:44:16 +00003689show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003690{
paul020709f2003-04-04 02:44:16 +00003691 struct ospf_lsa *lsa;
3692 struct route_node *rn;
hasso52dc7ee2004-09-23 19:18:23 +00003693 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003694 int type;
3695
paul68980082003-03-25 05:07:42 +00003696 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003697 {
3698 struct ospf_area *area = node->data;
3699 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3700 {
3701 switch (type)
3702 {
3703 case OSPF_AS_EXTERNAL_LSA:
3704#ifdef HAVE_OPAQUE_LSA
3705 case OSPF_OPAQUE_AS_LSA:
3706#endif /* HAVE_OPAQUE_LSA */
3707 continue;
3708 default:
3709 break;
3710 }
3711 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3712 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3713 {
3714 vty_out (vty, " %s (Area %s)%s%s",
3715 show_database_desc[type],
3716 ospf_area_desc_string (area),
3717 VTY_NEWLINE, VTY_NEWLINE);
3718 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3719
paul020709f2003-04-04 02:44:16 +00003720 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3721 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003722
3723 vty_out (vty, "%s", VTY_NEWLINE);
3724 }
3725 }
3726 }
3727
3728 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3729 {
3730 switch (type)
3731 {
3732 case OSPF_AS_EXTERNAL_LSA:
3733#ifdef HAVE_OPAQUE_LSA
3734 case OSPF_OPAQUE_AS_LSA:
3735#endif /* HAVE_OPAQUE_LSA */
3736 break;;
3737 default:
3738 continue;
3739 }
paul68980082003-03-25 05:07:42 +00003740 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3741 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003742 {
3743 vty_out (vty, " %s%s%s",
3744 show_database_desc[type],
3745 VTY_NEWLINE, VTY_NEWLINE);
3746 vty_out (vty, "%s%s", show_database_header[type],
3747 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003748
3749 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3750 show_lsa_summary (vty, lsa, self);
3751
paul718e3742002-12-13 20:15:29 +00003752 vty_out (vty, "%s", VTY_NEWLINE);
3753 }
3754 }
3755
3756 vty_out (vty, "%s", VTY_NEWLINE);
3757}
3758
3759void
paul020709f2003-04-04 02:44:16 +00003760show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003761{
hasso52dc7ee2004-09-23 19:18:23 +00003762 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003763 struct ospf_lsa *lsa;
3764
3765 vty_out (vty, "%s MaxAge Link States:%s%s",
3766 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3767
paul68980082003-03-25 05:07:42 +00003768 for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003769 if ((lsa = node->data) != NULL)
3770 {
3771 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3772 vty_out (vty, "Link State ID: %s%s",
3773 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3774 vty_out (vty, "Advertising Router: %s%s",
3775 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3776 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3777 vty_out (vty, "%s", VTY_NEWLINE);
3778 }
3779}
3780
paul718e3742002-12-13 20:15:29 +00003781#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3782#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003783
3784#ifdef HAVE_OPAQUE_LSA
3785#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3786#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3787#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3788#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3789#else /* HAVE_OPAQUE_LSA */
3790#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3791#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3792#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3793#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3794#endif /* HAVE_OPAQUE_LSA */
3795
3796#define OSPF_LSA_TYPES_CMD_STR \
3797 "asbr-summary|external|network|router|summary" \
3798 OSPF_LSA_TYPE_NSSA_CMD_STR \
3799 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3800
3801#define OSPF_LSA_TYPES_DESC \
3802 "ASBR summary link states\n" \
3803 "External link states\n" \
3804 "Network link states\n" \
3805 "Router link states\n" \
3806 "Network summary link states\n" \
3807 OSPF_LSA_TYPE_NSSA_DESC \
3808 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3809 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3810 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3811
3812DEFUN (show_ip_ospf_database,
3813 show_ip_ospf_database_cmd,
3814 "show ip ospf database",
3815 SHOW_STR
3816 IP_STR
3817 "OSPF information\n"
3818 "Database summary\n")
3819{
paul020709f2003-04-04 02:44:16 +00003820 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003821 int type, ret;
3822 struct in_addr id, adv_router;
3823
paul020709f2003-04-04 02:44:16 +00003824 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003825 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003826 return CMD_SUCCESS;
3827
3828 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003829 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003830
3831 /* Show all LSA. */
3832 if (argc == 0)
3833 {
paul020709f2003-04-04 02:44:16 +00003834 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003835 return CMD_SUCCESS;
3836 }
3837
3838 /* Set database type to show. */
3839 if (strncmp (argv[0], "r", 1) == 0)
3840 type = OSPF_ROUTER_LSA;
3841 else if (strncmp (argv[0], "ne", 2) == 0)
3842 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003843 else if (strncmp (argv[0], "ns", 2) == 0)
3844 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003845 else if (strncmp (argv[0], "su", 2) == 0)
3846 type = OSPF_SUMMARY_LSA;
3847 else if (strncmp (argv[0], "a", 1) == 0)
3848 type = OSPF_ASBR_SUMMARY_LSA;
3849 else if (strncmp (argv[0], "e", 1) == 0)
3850 type = OSPF_AS_EXTERNAL_LSA;
3851 else if (strncmp (argv[0], "se", 2) == 0)
3852 {
paul020709f2003-04-04 02:44:16 +00003853 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003854 return CMD_SUCCESS;
3855 }
3856 else if (strncmp (argv[0], "m", 1) == 0)
3857 {
paul020709f2003-04-04 02:44:16 +00003858 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003859 return CMD_SUCCESS;
3860 }
3861#ifdef HAVE_OPAQUE_LSA
3862 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3863 type = OSPF_OPAQUE_LINK_LSA;
3864 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3865 type = OSPF_OPAQUE_AREA_LSA;
3866 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3867 type = OSPF_OPAQUE_AS_LSA;
3868#endif /* HAVE_OPAQUE_LSA */
3869 else
3870 return CMD_WARNING;
3871
3872 /* `show ip ospf database LSA'. */
3873 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003874 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003875 else if (argc >= 2)
3876 {
3877 ret = inet_aton (argv[1], &id);
3878 if (!ret)
3879 return CMD_WARNING;
3880
3881 /* `show ip ospf database LSA ID'. */
3882 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003883 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003884 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3885 else if (argc == 3)
3886 {
3887 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003888 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003889 else
3890 {
3891 ret = inet_aton (argv[2], &adv_router);
3892 if (!ret)
3893 return CMD_WARNING;
3894 }
paul020709f2003-04-04 02:44:16 +00003895 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003896 }
3897 }
3898
3899 return CMD_SUCCESS;
3900}
3901
3902ALIAS (show_ip_ospf_database,
3903 show_ip_ospf_database_type_cmd,
3904 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3905 SHOW_STR
3906 IP_STR
3907 "OSPF information\n"
3908 "Database summary\n"
3909 OSPF_LSA_TYPES_DESC
3910 "LSAs in MaxAge list\n"
3911 "Self-originated link states\n")
3912
3913ALIAS (show_ip_ospf_database,
3914 show_ip_ospf_database_type_id_cmd,
3915 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3916 SHOW_STR
3917 IP_STR
3918 "OSPF information\n"
3919 "Database summary\n"
3920 OSPF_LSA_TYPES_DESC
3921 "Link State ID (as an IP address)\n")
3922
3923ALIAS (show_ip_ospf_database,
3924 show_ip_ospf_database_type_id_adv_router_cmd,
3925 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3926 SHOW_STR
3927 IP_STR
3928 "OSPF information\n"
3929 "Database summary\n"
3930 OSPF_LSA_TYPES_DESC
3931 "Link State ID (as an IP address)\n"
3932 "Advertising Router link states\n"
3933 "Advertising Router (as an IP address)\n")
3934
3935ALIAS (show_ip_ospf_database,
3936 show_ip_ospf_database_type_id_self_cmd,
3937 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3938 SHOW_STR
3939 IP_STR
3940 "OSPF information\n"
3941 "Database summary\n"
3942 OSPF_LSA_TYPES_DESC
3943 "Link State ID (as an IP address)\n"
3944 "Self-originated link states\n"
3945 "\n")
3946
3947DEFUN (show_ip_ospf_database_type_adv_router,
3948 show_ip_ospf_database_type_adv_router_cmd,
3949 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3950 SHOW_STR
3951 IP_STR
3952 "OSPF information\n"
3953 "Database summary\n"
3954 OSPF_LSA_TYPES_DESC
3955 "Advertising Router link states\n"
3956 "Advertising Router (as an IP address)\n")
3957{
paul020709f2003-04-04 02:44:16 +00003958 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003959 int type, ret;
3960 struct in_addr adv_router;
3961
paul020709f2003-04-04 02:44:16 +00003962 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003963 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003964 return CMD_SUCCESS;
3965
3966 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003967 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003968
3969 if (argc != 2)
3970 return CMD_WARNING;
3971
3972 /* Set database type to show. */
3973 if (strncmp (argv[0], "r", 1) == 0)
3974 type = OSPF_ROUTER_LSA;
3975 else if (strncmp (argv[0], "ne", 2) == 0)
3976 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003977 else if (strncmp (argv[0], "ns", 2) == 0)
3978 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003979 else if (strncmp (argv[0], "s", 1) == 0)
3980 type = OSPF_SUMMARY_LSA;
3981 else if (strncmp (argv[0], "a", 1) == 0)
3982 type = OSPF_ASBR_SUMMARY_LSA;
3983 else if (strncmp (argv[0], "e", 1) == 0)
3984 type = OSPF_AS_EXTERNAL_LSA;
3985#ifdef HAVE_OPAQUE_LSA
3986 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3987 type = OSPF_OPAQUE_LINK_LSA;
3988 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3989 type = OSPF_OPAQUE_AREA_LSA;
3990 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3991 type = OSPF_OPAQUE_AS_LSA;
3992#endif /* HAVE_OPAQUE_LSA */
3993 else
3994 return CMD_WARNING;
3995
3996 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
3997 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003998 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003999 else
4000 {
4001 ret = inet_aton (argv[1], &adv_router);
4002 if (!ret)
4003 return CMD_WARNING;
4004 }
4005
paul020709f2003-04-04 02:44:16 +00004006 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004007
4008 return CMD_SUCCESS;
4009}
4010
4011ALIAS (show_ip_ospf_database_type_adv_router,
4012 show_ip_ospf_database_type_self_cmd,
4013 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4014 SHOW_STR
4015 IP_STR
4016 "OSPF information\n"
4017 "Database summary\n"
4018 OSPF_LSA_TYPES_DESC
4019 "Self-originated link states\n")
4020
4021
4022DEFUN (ip_ospf_authentication_args,
4023 ip_ospf_authentication_args_addr_cmd,
4024 "ip ospf authentication (null|message-digest) A.B.C.D",
4025 "IP Information\n"
4026 "OSPF interface commands\n"
4027 "Enable authentication on this interface\n"
4028 "Use null authentication\n"
4029 "Use message-digest authentication\n"
4030 "Address of interface")
4031{
4032 struct interface *ifp;
4033 struct in_addr addr;
4034 int ret;
4035 struct ospf_if_params *params;
4036
4037 ifp = vty->index;
4038 params = IF_DEF_PARAMS (ifp);
4039
4040 if (argc == 2)
4041 {
4042 ret = inet_aton(argv[1], &addr);
4043 if (!ret)
4044 {
4045 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4046 VTY_NEWLINE);
4047 return CMD_WARNING;
4048 }
4049
4050 params = ospf_get_if_params (ifp, addr);
4051 ospf_if_update_params (ifp, addr);
4052 }
4053
4054 /* Handle null authentication */
4055 if ( argv[0][0] == 'n' )
4056 {
4057 SET_IF_PARAM (params, auth_type);
4058 params->auth_type = OSPF_AUTH_NULL;
4059 return CMD_SUCCESS;
4060 }
4061
4062 /* Handle message-digest authentication */
4063 if ( argv[0][0] == 'm' )
4064 {
4065 SET_IF_PARAM (params, auth_type);
4066 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4067 return CMD_SUCCESS;
4068 }
4069
4070 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4071 return CMD_WARNING;
4072}
4073
4074ALIAS (ip_ospf_authentication_args,
4075 ip_ospf_authentication_args_cmd,
4076 "ip ospf authentication (null|message-digest)",
4077 "IP Information\n"
4078 "OSPF interface commands\n"
4079 "Enable authentication on this interface\n"
4080 "Use null authentication\n"
4081 "Use message-digest authentication\n")
4082
4083DEFUN (ip_ospf_authentication,
4084 ip_ospf_authentication_addr_cmd,
4085 "ip ospf authentication A.B.C.D",
4086 "IP Information\n"
4087 "OSPF interface commands\n"
4088 "Enable authentication on this interface\n"
4089 "Address of interface")
4090{
4091 struct interface *ifp;
4092 struct in_addr addr;
4093 int ret;
4094 struct ospf_if_params *params;
4095
4096 ifp = vty->index;
4097 params = IF_DEF_PARAMS (ifp);
4098
4099 if (argc == 1)
4100 {
4101 ret = inet_aton(argv[1], &addr);
4102 if (!ret)
4103 {
4104 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4105 VTY_NEWLINE);
4106 return CMD_WARNING;
4107 }
4108
4109 params = ospf_get_if_params (ifp, addr);
4110 ospf_if_update_params (ifp, addr);
4111 }
4112
4113 SET_IF_PARAM (params, auth_type);
4114 params->auth_type = OSPF_AUTH_SIMPLE;
4115
4116 return CMD_SUCCESS;
4117}
4118
4119ALIAS (ip_ospf_authentication,
4120 ip_ospf_authentication_cmd,
4121 "ip ospf authentication",
4122 "IP Information\n"
4123 "OSPF interface commands\n"
4124 "Enable authentication on this interface\n")
4125
4126DEFUN (no_ip_ospf_authentication,
4127 no_ip_ospf_authentication_addr_cmd,
4128 "no ip ospf authentication A.B.C.D",
4129 NO_STR
4130 "IP Information\n"
4131 "OSPF interface commands\n"
4132 "Enable authentication on this interface\n"
4133 "Address of interface")
4134{
4135 struct interface *ifp;
4136 struct in_addr addr;
4137 int ret;
4138 struct ospf_if_params *params;
4139
4140 ifp = vty->index;
4141 params = IF_DEF_PARAMS (ifp);
4142
4143 if (argc == 1)
4144 {
4145 ret = inet_aton(argv[1], &addr);
4146 if (!ret)
4147 {
4148 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4149 VTY_NEWLINE);
4150 return CMD_WARNING;
4151 }
4152
4153 params = ospf_lookup_if_params (ifp, addr);
4154 if (params == NULL)
4155 return CMD_SUCCESS;
4156 }
4157
4158 params->auth_type = OSPF_AUTH_NOTSET;
4159 UNSET_IF_PARAM (params, auth_type);
4160
4161 if (params != IF_DEF_PARAMS (ifp))
4162 {
4163 ospf_free_if_params (ifp, addr);
4164 ospf_if_update_params (ifp, addr);
4165 }
4166
4167 return CMD_SUCCESS;
4168}
4169
4170ALIAS (no_ip_ospf_authentication,
4171 no_ip_ospf_authentication_cmd,
4172 "no ip ospf authentication",
4173 NO_STR
4174 "IP Information\n"
4175 "OSPF interface commands\n"
4176 "Enable authentication on this interface\n")
4177
4178DEFUN (ip_ospf_authentication_key,
4179 ip_ospf_authentication_key_addr_cmd,
4180 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4181 "IP Information\n"
4182 "OSPF interface commands\n"
4183 "Authentication password (key)\n"
4184 "The OSPF password (key)\n"
4185 "Address of interface")
4186{
4187 struct interface *ifp;
4188 struct in_addr addr;
4189 int ret;
4190 struct ospf_if_params *params;
4191
4192 ifp = vty->index;
4193 params = IF_DEF_PARAMS (ifp);
4194
4195 if (argc == 2)
4196 {
4197 ret = inet_aton(argv[1], &addr);
4198 if (!ret)
4199 {
4200 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4201 VTY_NEWLINE);
4202 return CMD_WARNING;
4203 }
4204
4205 params = ospf_get_if_params (ifp, addr);
4206 ospf_if_update_params (ifp, addr);
4207 }
4208
4209
4210 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004211 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004212 SET_IF_PARAM (params, auth_simple);
4213
4214 return CMD_SUCCESS;
4215}
4216
4217ALIAS (ip_ospf_authentication_key,
4218 ip_ospf_authentication_key_cmd,
4219 "ip ospf authentication-key AUTH_KEY",
4220 "IP Information\n"
4221 "OSPF interface commands\n"
4222 "Authentication password (key)\n"
4223 "The OSPF password (key)")
4224
4225ALIAS (ip_ospf_authentication_key,
4226 ospf_authentication_key_cmd,
4227 "ospf authentication-key AUTH_KEY",
4228 "OSPF interface commands\n"
4229 "Authentication password (key)\n"
4230 "The OSPF password (key)")
4231
4232DEFUN (no_ip_ospf_authentication_key,
4233 no_ip_ospf_authentication_key_addr_cmd,
4234 "no ip ospf authentication-key A.B.C.D",
4235 NO_STR
4236 "IP Information\n"
4237 "OSPF interface commands\n"
4238 "Authentication password (key)\n"
4239 "Address of interface")
4240{
4241 struct interface *ifp;
4242 struct in_addr addr;
4243 int ret;
4244 struct ospf_if_params *params;
4245
4246 ifp = vty->index;
4247 params = IF_DEF_PARAMS (ifp);
4248
4249 if (argc == 2)
4250 {
4251 ret = inet_aton(argv[1], &addr);
4252 if (!ret)
4253 {
4254 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4255 VTY_NEWLINE);
4256 return CMD_WARNING;
4257 }
4258
4259 params = ospf_lookup_if_params (ifp, addr);
4260 if (params == NULL)
4261 return CMD_SUCCESS;
4262 }
4263
4264 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4265 UNSET_IF_PARAM (params, auth_simple);
4266
4267 if (params != IF_DEF_PARAMS (ifp))
4268 {
4269 ospf_free_if_params (ifp, addr);
4270 ospf_if_update_params (ifp, addr);
4271 }
4272
4273 return CMD_SUCCESS;
4274}
4275
4276ALIAS (no_ip_ospf_authentication_key,
4277 no_ip_ospf_authentication_key_cmd,
4278 "no ip ospf authentication-key",
4279 NO_STR
4280 "IP Information\n"
4281 "OSPF interface commands\n"
4282 "Authentication password (key)\n")
4283
4284ALIAS (no_ip_ospf_authentication_key,
4285 no_ospf_authentication_key_cmd,
4286 "no ospf authentication-key",
4287 NO_STR
4288 "OSPF interface commands\n"
4289 "Authentication password (key)\n")
4290
4291DEFUN (ip_ospf_message_digest_key,
4292 ip_ospf_message_digest_key_addr_cmd,
4293 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4294 "IP Information\n"
4295 "OSPF interface commands\n"
4296 "Message digest authentication password (key)\n"
4297 "Key ID\n"
4298 "Use MD5 algorithm\n"
4299 "The OSPF password (key)"
4300 "Address of interface")
4301{
4302 struct interface *ifp;
4303 struct crypt_key *ck;
4304 u_char key_id;
4305 struct in_addr addr;
4306 int ret;
4307 struct ospf_if_params *params;
4308
4309 ifp = vty->index;
4310 params = IF_DEF_PARAMS (ifp);
4311
4312 if (argc == 3)
4313 {
4314 ret = inet_aton(argv[2], &addr);
4315 if (!ret)
4316 {
4317 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4318 VTY_NEWLINE);
4319 return CMD_WARNING;
4320 }
4321
4322 params = ospf_get_if_params (ifp, addr);
4323 ospf_if_update_params (ifp, addr);
4324 }
4325
4326 key_id = strtol (argv[0], NULL, 10);
4327 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4328 {
4329 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4330 return CMD_WARNING;
4331 }
4332
4333 ck = ospf_crypt_key_new ();
4334 ck->key_id = (u_char) key_id;
4335 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004336 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004337
4338 ospf_crypt_key_add (params->auth_crypt, ck);
4339 SET_IF_PARAM (params, auth_crypt);
4340
4341 return CMD_SUCCESS;
4342}
4343
4344ALIAS (ip_ospf_message_digest_key,
4345 ip_ospf_message_digest_key_cmd,
4346 "ip ospf message-digest-key <1-255> md5 KEY",
4347 "IP Information\n"
4348 "OSPF interface commands\n"
4349 "Message digest authentication password (key)\n"
4350 "Key ID\n"
4351 "Use MD5 algorithm\n"
4352 "The OSPF password (key)")
4353
4354ALIAS (ip_ospf_message_digest_key,
4355 ospf_message_digest_key_cmd,
4356 "ospf message-digest-key <1-255> md5 KEY",
4357 "OSPF interface commands\n"
4358 "Message digest authentication password (key)\n"
4359 "Key ID\n"
4360 "Use MD5 algorithm\n"
4361 "The OSPF password (key)")
4362
4363DEFUN (no_ip_ospf_message_digest_key,
4364 no_ip_ospf_message_digest_key_addr_cmd,
4365 "no ip ospf message-digest-key <1-255> A.B.C.D",
4366 NO_STR
4367 "IP Information\n"
4368 "OSPF interface commands\n"
4369 "Message digest authentication password (key)\n"
4370 "Key ID\n"
4371 "Address of interface")
4372{
4373 struct interface *ifp;
4374 struct crypt_key *ck;
4375 int key_id;
4376 struct in_addr addr;
4377 int ret;
4378 struct ospf_if_params *params;
4379
4380 ifp = vty->index;
4381 params = IF_DEF_PARAMS (ifp);
4382
4383 if (argc == 2)
4384 {
4385 ret = inet_aton(argv[1], &addr);
4386 if (!ret)
4387 {
4388 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4389 VTY_NEWLINE);
4390 return CMD_WARNING;
4391 }
4392
4393 params = ospf_lookup_if_params (ifp, addr);
4394 if (params == NULL)
4395 return CMD_SUCCESS;
4396 }
4397
4398 key_id = strtol (argv[0], NULL, 10);
4399 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4400 if (ck == NULL)
4401 {
4402 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4403 return CMD_WARNING;
4404 }
4405
4406 ospf_crypt_key_delete (params->auth_crypt, key_id);
4407
4408 if (params != IF_DEF_PARAMS (ifp))
4409 {
4410 ospf_free_if_params (ifp, addr);
4411 ospf_if_update_params (ifp, addr);
4412 }
4413
4414 return CMD_SUCCESS;
4415}
4416
4417ALIAS (no_ip_ospf_message_digest_key,
4418 no_ip_ospf_message_digest_key_cmd,
4419 "no ip ospf message-digest-key <1-255>",
4420 NO_STR
4421 "IP Information\n"
4422 "OSPF interface commands\n"
4423 "Message digest authentication password (key)\n"
4424 "Key ID\n")
4425
4426ALIAS (no_ip_ospf_message_digest_key,
4427 no_ospf_message_digest_key_cmd,
4428 "no ospf message-digest-key <1-255>",
4429 NO_STR
4430 "OSPF interface commands\n"
4431 "Message digest authentication password (key)\n"
4432 "Key ID\n")
4433
4434DEFUN (ip_ospf_cost,
4435 ip_ospf_cost_addr_cmd,
4436 "ip ospf cost <1-65535> A.B.C.D",
4437 "IP Information\n"
4438 "OSPF interface commands\n"
4439 "Interface cost\n"
4440 "Cost\n"
4441 "Address of interface")
4442{
4443 struct interface *ifp = vty->index;
4444 u_int32_t cost;
4445 struct in_addr addr;
4446 int ret;
4447 struct ospf_if_params *params;
4448
4449 params = IF_DEF_PARAMS (ifp);
4450
4451 cost = strtol (argv[0], NULL, 10);
4452
4453 /* cost range is <1-65535>. */
4454 if (cost < 1 || cost > 65535)
4455 {
4456 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4457 return CMD_WARNING;
4458 }
4459
4460 if (argc == 2)
4461 {
4462 ret = inet_aton(argv[1], &addr);
4463 if (!ret)
4464 {
4465 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4466 VTY_NEWLINE);
4467 return CMD_WARNING;
4468 }
4469
4470 params = ospf_get_if_params (ifp, addr);
4471 ospf_if_update_params (ifp, addr);
4472 }
4473
4474 SET_IF_PARAM (params, output_cost_cmd);
4475 params->output_cost_cmd = cost;
4476
4477 ospf_if_recalculate_output_cost (ifp);
4478
4479 return CMD_SUCCESS;
4480}
4481
4482ALIAS (ip_ospf_cost,
4483 ip_ospf_cost_cmd,
4484 "ip ospf cost <1-65535>",
4485 "IP Information\n"
4486 "OSPF interface commands\n"
4487 "Interface cost\n"
4488 "Cost")
4489
4490ALIAS (ip_ospf_cost,
4491 ospf_cost_cmd,
4492 "ospf cost <1-65535>",
4493 "OSPF interface commands\n"
4494 "Interface cost\n"
4495 "Cost")
4496
4497DEFUN (no_ip_ospf_cost,
4498 no_ip_ospf_cost_addr_cmd,
4499 "no ip ospf cost A.B.C.D",
4500 NO_STR
4501 "IP Information\n"
4502 "OSPF interface commands\n"
4503 "Interface cost\n"
4504 "Address of interface")
4505{
4506 struct interface *ifp = vty->index;
4507 struct in_addr addr;
4508 int ret;
4509 struct ospf_if_params *params;
4510
4511 ifp = vty->index;
4512 params = IF_DEF_PARAMS (ifp);
4513
4514 if (argc == 1)
4515 {
4516 ret = inet_aton(argv[0], &addr);
4517 if (!ret)
4518 {
4519 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4520 VTY_NEWLINE);
4521 return CMD_WARNING;
4522 }
4523
4524 params = ospf_lookup_if_params (ifp, addr);
4525 if (params == NULL)
4526 return CMD_SUCCESS;
4527 }
4528
4529 UNSET_IF_PARAM (params, output_cost_cmd);
4530
4531 if (params != IF_DEF_PARAMS (ifp))
4532 {
4533 ospf_free_if_params (ifp, addr);
4534 ospf_if_update_params (ifp, addr);
4535 }
4536
4537 ospf_if_recalculate_output_cost (ifp);
4538
4539 return CMD_SUCCESS;
4540}
4541
4542ALIAS (no_ip_ospf_cost,
4543 no_ip_ospf_cost_cmd,
4544 "no ip ospf cost",
4545 NO_STR
4546 "IP Information\n"
4547 "OSPF interface commands\n"
4548 "Interface cost\n")
4549
4550ALIAS (no_ip_ospf_cost,
4551 no_ospf_cost_cmd,
4552 "no ospf cost",
4553 NO_STR
4554 "OSPF interface commands\n"
4555 "Interface cost\n")
4556
4557void
4558ospf_nbr_timer_update (struct ospf_interface *oi)
4559{
4560 struct route_node *rn;
4561 struct ospf_neighbor *nbr;
4562
4563 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4564 if ((nbr = rn->info))
4565 {
4566 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4567 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4568 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4569 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4570 }
4571}
4572
4573DEFUN (ip_ospf_dead_interval,
4574 ip_ospf_dead_interval_addr_cmd,
4575 "ip ospf dead-interval <1-65535> A.B.C.D",
4576 "IP Information\n"
4577 "OSPF interface commands\n"
4578 "Interval after which a neighbor is declared dead\n"
4579 "Seconds\n"
4580 "Address of interface")
4581{
4582 struct interface *ifp = vty->index;
4583 u_int32_t seconds;
4584 struct in_addr addr;
4585 int ret;
4586 struct ospf_if_params *params;
4587 struct ospf_interface *oi;
4588 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004589 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004590
paul020709f2003-04-04 02:44:16 +00004591 ospf = ospf_lookup ();
4592
paul718e3742002-12-13 20:15:29 +00004593 params = IF_DEF_PARAMS (ifp);
4594
4595 seconds = strtol (argv[0], NULL, 10);
4596
4597 /* dead_interval range is <1-65535>. */
4598 if (seconds < 1 || seconds > 65535)
4599 {
4600 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4601 return CMD_WARNING;
4602 }
4603
4604 if (argc == 2)
4605 {
4606 ret = inet_aton(argv[1], &addr);
4607 if (!ret)
4608 {
4609 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4610 VTY_NEWLINE);
4611 return CMD_WARNING;
4612 }
4613
4614 params = ospf_get_if_params (ifp, addr);
4615 ospf_if_update_params (ifp, addr);
4616 }
4617
4618 SET_IF_PARAM (params, v_wait);
4619 params->v_wait = seconds;
4620
4621 /* Update timer values in neighbor structure. */
4622 if (argc == 2)
4623 {
paul68980082003-03-25 05:07:42 +00004624 if (ospf)
4625 {
4626 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4627 if (oi)
4628 ospf_nbr_timer_update (oi);
4629 }
paul718e3742002-12-13 20:15:29 +00004630 }
4631 else
4632 {
4633 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4634 if ((oi = rn->info))
4635 ospf_nbr_timer_update (oi);
4636 }
4637
4638 return CMD_SUCCESS;
4639}
4640
4641ALIAS (ip_ospf_dead_interval,
4642 ip_ospf_dead_interval_cmd,
4643 "ip ospf dead-interval <1-65535>",
4644 "IP Information\n"
4645 "OSPF interface commands\n"
4646 "Interval after which a neighbor is declared dead\n"
4647 "Seconds\n")
4648
4649ALIAS (ip_ospf_dead_interval,
4650 ospf_dead_interval_cmd,
4651 "ospf dead-interval <1-65535>",
4652 "OSPF interface commands\n"
4653 "Interval after which a neighbor is declared dead\n"
4654 "Seconds\n")
4655
4656DEFUN (no_ip_ospf_dead_interval,
4657 no_ip_ospf_dead_interval_addr_cmd,
4658 "no ip ospf dead-interval A.B.C.D",
4659 NO_STR
4660 "IP Information\n"
4661 "OSPF interface commands\n"
4662 "Interval after which a neighbor is declared dead\n"
4663 "Address of interface")
4664{
4665 struct interface *ifp = vty->index;
4666 struct in_addr addr;
4667 int ret;
4668 struct ospf_if_params *params;
4669 struct ospf_interface *oi;
4670 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004671 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004672
paul020709f2003-04-04 02:44:16 +00004673 ospf = ospf_lookup ();
4674
paul718e3742002-12-13 20:15:29 +00004675 ifp = vty->index;
4676 params = IF_DEF_PARAMS (ifp);
4677
4678 if (argc == 1)
4679 {
4680 ret = inet_aton(argv[0], &addr);
4681 if (!ret)
4682 {
4683 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4684 VTY_NEWLINE);
4685 return CMD_WARNING;
4686 }
4687
4688 params = ospf_lookup_if_params (ifp, addr);
4689 if (params == NULL)
4690 return CMD_SUCCESS;
4691 }
4692
4693 UNSET_IF_PARAM (params, v_wait);
4694 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4695
4696 if (params != IF_DEF_PARAMS (ifp))
4697 {
4698 ospf_free_if_params (ifp, addr);
4699 ospf_if_update_params (ifp, addr);
4700 }
4701
4702 /* Update timer values in neighbor structure. */
4703 if (argc == 1)
4704 {
paul68980082003-03-25 05:07:42 +00004705 if (ospf)
4706 {
4707 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4708 if (oi)
4709 ospf_nbr_timer_update (oi);
4710 }
paul718e3742002-12-13 20:15:29 +00004711 }
4712 else
4713 {
4714 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4715 if ((oi = rn->info))
4716 ospf_nbr_timer_update (oi);
4717 }
4718
4719 return CMD_SUCCESS;
4720}
4721
4722ALIAS (no_ip_ospf_dead_interval,
4723 no_ip_ospf_dead_interval_cmd,
4724 "no ip ospf dead-interval",
4725 NO_STR
4726 "IP Information\n"
4727 "OSPF interface commands\n"
4728 "Interval after which a neighbor is declared dead\n")
4729
4730ALIAS (no_ip_ospf_dead_interval,
4731 no_ospf_dead_interval_cmd,
4732 "no ospf dead-interval",
4733 NO_STR
4734 "OSPF interface commands\n"
4735 "Interval after which a neighbor is declared dead\n")
4736
4737DEFUN (ip_ospf_hello_interval,
4738 ip_ospf_hello_interval_addr_cmd,
4739 "ip ospf hello-interval <1-65535> A.B.C.D",
4740 "IP Information\n"
4741 "OSPF interface commands\n"
4742 "Time between HELLO packets\n"
4743 "Seconds\n"
4744 "Address of interface")
4745{
4746 struct interface *ifp = vty->index;
4747 u_int32_t seconds;
4748 struct in_addr addr;
4749 int ret;
4750 struct ospf_if_params *params;
4751
4752 params = IF_DEF_PARAMS (ifp);
4753
4754 seconds = strtol (argv[0], NULL, 10);
4755
4756 /* HelloInterval range is <1-65535>. */
4757 if (seconds < 1 || seconds > 65535)
4758 {
4759 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4760 return CMD_WARNING;
4761 }
4762
4763 if (argc == 2)
4764 {
4765 ret = inet_aton(argv[1], &addr);
4766 if (!ret)
4767 {
4768 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4769 VTY_NEWLINE);
4770 return CMD_WARNING;
4771 }
4772
4773 params = ospf_get_if_params (ifp, addr);
4774 ospf_if_update_params (ifp, addr);
4775 }
4776
4777 SET_IF_PARAM (params, v_hello);
4778 params->v_hello = seconds;
4779
4780 return CMD_SUCCESS;
4781}
4782
4783ALIAS (ip_ospf_hello_interval,
4784 ip_ospf_hello_interval_cmd,
4785 "ip ospf hello-interval <1-65535>",
4786 "IP Information\n"
4787 "OSPF interface commands\n"
4788 "Time between HELLO packets\n"
4789 "Seconds\n")
4790
4791ALIAS (ip_ospf_hello_interval,
4792 ospf_hello_interval_cmd,
4793 "ospf hello-interval <1-65535>",
4794 "OSPF interface commands\n"
4795 "Time between HELLO packets\n"
4796 "Seconds\n")
4797
4798DEFUN (no_ip_ospf_hello_interval,
4799 no_ip_ospf_hello_interval_addr_cmd,
4800 "no ip ospf hello-interval A.B.C.D",
4801 NO_STR
4802 "IP Information\n"
4803 "OSPF interface commands\n"
4804 "Time between HELLO packets\n"
4805 "Address of interface")
4806{
4807 struct interface *ifp = vty->index;
4808 struct in_addr addr;
4809 int ret;
4810 struct ospf_if_params *params;
4811
4812 ifp = vty->index;
4813 params = IF_DEF_PARAMS (ifp);
4814
4815 if (argc == 1)
4816 {
4817 ret = inet_aton(argv[0], &addr);
4818 if (!ret)
4819 {
4820 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4821 VTY_NEWLINE);
4822 return CMD_WARNING;
4823 }
4824
4825 params = ospf_lookup_if_params (ifp, addr);
4826 if (params == NULL)
4827 return CMD_SUCCESS;
4828 }
4829
4830 UNSET_IF_PARAM (params, v_hello);
4831 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4832
4833 if (params != IF_DEF_PARAMS (ifp))
4834 {
4835 ospf_free_if_params (ifp, addr);
4836 ospf_if_update_params (ifp, addr);
4837 }
4838
4839 return CMD_SUCCESS;
4840}
4841
4842ALIAS (no_ip_ospf_hello_interval,
4843 no_ip_ospf_hello_interval_cmd,
4844 "no ip ospf hello-interval",
4845 NO_STR
4846 "IP Information\n"
4847 "OSPF interface commands\n"
4848 "Time between HELLO packets\n")
4849
4850ALIAS (no_ip_ospf_hello_interval,
4851 no_ospf_hello_interval_cmd,
4852 "no ospf hello-interval",
4853 NO_STR
4854 "OSPF interface commands\n"
4855 "Time between HELLO packets\n")
4856
4857DEFUN (ip_ospf_network,
4858 ip_ospf_network_cmd,
4859 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4860 "IP Information\n"
4861 "OSPF interface commands\n"
4862 "Network type\n"
4863 "Specify OSPF broadcast multi-access network\n"
4864 "Specify OSPF NBMA network\n"
4865 "Specify OSPF point-to-multipoint network\n"
4866 "Specify OSPF point-to-point network\n")
4867{
4868 struct interface *ifp = vty->index;
4869 int old_type = IF_DEF_PARAMS (ifp)->type;
4870 struct route_node *rn;
4871
4872 if (strncmp (argv[0], "b", 1) == 0)
4873 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4874 else if (strncmp (argv[0], "n", 1) == 0)
4875 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4876 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4877 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4878 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4879 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4880
4881 if (IF_DEF_PARAMS (ifp)->type == old_type)
4882 return CMD_SUCCESS;
4883
4884 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4885
4886 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4887 {
4888 struct ospf_interface *oi = rn->info;
4889
4890 if (!oi)
4891 continue;
4892
4893 oi->type = IF_DEF_PARAMS (ifp)->type;
4894
4895 if (oi->state > ISM_Down)
4896 {
4897 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4898 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4899 }
4900 }
4901
4902 return CMD_SUCCESS;
4903}
4904
4905ALIAS (ip_ospf_network,
4906 ospf_network_cmd,
4907 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4908 "OSPF interface commands\n"
4909 "Network type\n"
4910 "Specify OSPF broadcast multi-access network\n"
4911 "Specify OSPF NBMA network\n"
4912 "Specify OSPF point-to-multipoint network\n"
4913 "Specify OSPF point-to-point network\n")
4914
4915DEFUN (no_ip_ospf_network,
4916 no_ip_ospf_network_cmd,
4917 "no ip ospf network",
4918 NO_STR
4919 "IP Information\n"
4920 "OSPF interface commands\n"
4921 "Network type\n")
4922{
4923 struct interface *ifp = vty->index;
4924 int old_type = IF_DEF_PARAMS (ifp)->type;
4925 struct route_node *rn;
4926
ajsbc18d612004-12-15 15:07:19 +00004927 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00004928
4929 if (IF_DEF_PARAMS (ifp)->type == old_type)
4930 return CMD_SUCCESS;
4931
4932 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4933 {
4934 struct ospf_interface *oi = rn->info;
4935
4936 if (!oi)
4937 continue;
4938
4939 oi->type = IF_DEF_PARAMS (ifp)->type;
4940
4941 if (oi->state > ISM_Down)
4942 {
4943 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4944 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4945 }
4946 }
4947
4948 return CMD_SUCCESS;
4949}
4950
4951ALIAS (no_ip_ospf_network,
4952 no_ospf_network_cmd,
4953 "no ospf network",
4954 NO_STR
4955 "OSPF interface commands\n"
4956 "Network type\n")
4957
4958DEFUN (ip_ospf_priority,
4959 ip_ospf_priority_addr_cmd,
4960 "ip ospf priority <0-255> A.B.C.D",
4961 "IP Information\n"
4962 "OSPF interface commands\n"
4963 "Router priority\n"
4964 "Priority\n"
4965 "Address of interface")
4966{
4967 struct interface *ifp = vty->index;
4968 u_int32_t priority;
4969 struct route_node *rn;
4970 struct in_addr addr;
4971 int ret;
4972 struct ospf_if_params *params;
4973
4974 params = IF_DEF_PARAMS (ifp);
4975
4976 priority = strtol (argv[0], NULL, 10);
4977
4978 /* Router Priority range is <0-255>. */
4979 if (priority < 0 || priority > 255)
4980 {
4981 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4982 return CMD_WARNING;
4983 }
4984
4985 if (argc == 2)
4986 {
4987 ret = inet_aton(argv[1], &addr);
4988 if (!ret)
4989 {
4990 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4991 VTY_NEWLINE);
4992 return CMD_WARNING;
4993 }
4994
4995 params = ospf_get_if_params (ifp, addr);
4996 ospf_if_update_params (ifp, addr);
4997 }
4998
4999 SET_IF_PARAM (params, priority);
5000 params->priority = priority;
5001
5002 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5003 {
5004 struct ospf_interface *oi = rn->info;
5005
5006 if (!oi)
5007 continue;
5008
5009
5010 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5011 {
5012 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5013 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5014 }
5015 }
5016
5017 return CMD_SUCCESS;
5018}
5019
5020ALIAS (ip_ospf_priority,
5021 ip_ospf_priority_cmd,
5022 "ip ospf priority <0-255>",
5023 "IP Information\n"
5024 "OSPF interface commands\n"
5025 "Router priority\n"
5026 "Priority\n")
5027
5028ALIAS (ip_ospf_priority,
5029 ospf_priority_cmd,
5030 "ospf priority <0-255>",
5031 "OSPF interface commands\n"
5032 "Router priority\n"
5033 "Priority\n")
5034
5035DEFUN (no_ip_ospf_priority,
5036 no_ip_ospf_priority_addr_cmd,
5037 "no ip ospf priority A.B.C.D",
5038 NO_STR
5039 "IP Information\n"
5040 "OSPF interface commands\n"
5041 "Router priority\n"
5042 "Address of interface")
5043{
5044 struct interface *ifp = vty->index;
5045 struct route_node *rn;
5046 struct in_addr addr;
5047 int ret;
5048 struct ospf_if_params *params;
5049
5050 ifp = vty->index;
5051 params = IF_DEF_PARAMS (ifp);
5052
5053 if (argc == 1)
5054 {
5055 ret = inet_aton(argv[0], &addr);
5056 if (!ret)
5057 {
5058 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5059 VTY_NEWLINE);
5060 return CMD_WARNING;
5061 }
5062
5063 params = ospf_lookup_if_params (ifp, addr);
5064 if (params == NULL)
5065 return CMD_SUCCESS;
5066 }
5067
5068 UNSET_IF_PARAM (params, priority);
5069 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5070
5071 if (params != IF_DEF_PARAMS (ifp))
5072 {
5073 ospf_free_if_params (ifp, addr);
5074 ospf_if_update_params (ifp, addr);
5075 }
5076
5077 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5078 {
5079 struct ospf_interface *oi = rn->info;
5080
5081 if (!oi)
5082 continue;
5083
5084
5085 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5086 {
5087 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5088 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5089 }
5090 }
5091
5092 return CMD_SUCCESS;
5093}
5094
5095ALIAS (no_ip_ospf_priority,
5096 no_ip_ospf_priority_cmd,
5097 "no ip ospf priority",
5098 NO_STR
5099 "IP Information\n"
5100 "OSPF interface commands\n"
5101 "Router priority\n")
5102
5103ALIAS (no_ip_ospf_priority,
5104 no_ospf_priority_cmd,
5105 "no ospf priority",
5106 NO_STR
5107 "OSPF interface commands\n"
5108 "Router priority\n")
5109
5110DEFUN (ip_ospf_retransmit_interval,
5111 ip_ospf_retransmit_interval_addr_cmd,
5112 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5113 "IP Information\n"
5114 "OSPF interface commands\n"
5115 "Time between retransmitting lost link state advertisements\n"
5116 "Seconds\n"
5117 "Address of interface")
5118{
5119 struct interface *ifp = vty->index;
5120 u_int32_t seconds;
5121 struct in_addr addr;
5122 int ret;
5123 struct ospf_if_params *params;
5124
5125 params = IF_DEF_PARAMS (ifp);
5126 seconds = strtol (argv[0], NULL, 10);
5127
5128 /* Retransmit Interval range is <3-65535>. */
5129 if (seconds < 3 || seconds > 65535)
5130 {
5131 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5132 return CMD_WARNING;
5133 }
5134
5135
5136 if (argc == 2)
5137 {
5138 ret = inet_aton(argv[1], &addr);
5139 if (!ret)
5140 {
5141 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5142 VTY_NEWLINE);
5143 return CMD_WARNING;
5144 }
5145
5146 params = ospf_get_if_params (ifp, addr);
5147 ospf_if_update_params (ifp, addr);
5148 }
5149
5150 SET_IF_PARAM (params, retransmit_interval);
5151 params->retransmit_interval = seconds;
5152
5153 return CMD_SUCCESS;
5154}
5155
5156ALIAS (ip_ospf_retransmit_interval,
5157 ip_ospf_retransmit_interval_cmd,
5158 "ip ospf retransmit-interval <3-65535>",
5159 "IP Information\n"
5160 "OSPF interface commands\n"
5161 "Time between retransmitting lost link state advertisements\n"
5162 "Seconds\n")
5163
5164ALIAS (ip_ospf_retransmit_interval,
5165 ospf_retransmit_interval_cmd,
5166 "ospf retransmit-interval <3-65535>",
5167 "OSPF interface commands\n"
5168 "Time between retransmitting lost link state advertisements\n"
5169 "Seconds\n")
5170
5171DEFUN (no_ip_ospf_retransmit_interval,
5172 no_ip_ospf_retransmit_interval_addr_cmd,
5173 "no ip ospf retransmit-interval A.B.C.D",
5174 NO_STR
5175 "IP Information\n"
5176 "OSPF interface commands\n"
5177 "Time between retransmitting lost link state advertisements\n"
5178 "Address of interface")
5179{
5180 struct interface *ifp = vty->index;
5181 struct in_addr addr;
5182 int ret;
5183 struct ospf_if_params *params;
5184
5185 ifp = vty->index;
5186 params = IF_DEF_PARAMS (ifp);
5187
5188 if (argc == 1)
5189 {
5190 ret = inet_aton(argv[0], &addr);
5191 if (!ret)
5192 {
5193 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5194 VTY_NEWLINE);
5195 return CMD_WARNING;
5196 }
5197
5198 params = ospf_lookup_if_params (ifp, addr);
5199 if (params == NULL)
5200 return CMD_SUCCESS;
5201 }
5202
5203 UNSET_IF_PARAM (params, retransmit_interval);
5204 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5205
5206 if (params != IF_DEF_PARAMS (ifp))
5207 {
5208 ospf_free_if_params (ifp, addr);
5209 ospf_if_update_params (ifp, addr);
5210 }
5211
5212 return CMD_SUCCESS;
5213}
5214
5215ALIAS (no_ip_ospf_retransmit_interval,
5216 no_ip_ospf_retransmit_interval_cmd,
5217 "no ip ospf retransmit-interval",
5218 NO_STR
5219 "IP Information\n"
5220 "OSPF interface commands\n"
5221 "Time between retransmitting lost link state advertisements\n")
5222
5223ALIAS (no_ip_ospf_retransmit_interval,
5224 no_ospf_retransmit_interval_cmd,
5225 "no ospf retransmit-interval",
5226 NO_STR
5227 "OSPF interface commands\n"
5228 "Time between retransmitting lost link state advertisements\n")
5229
5230DEFUN (ip_ospf_transmit_delay,
5231 ip_ospf_transmit_delay_addr_cmd,
5232 "ip ospf transmit-delay <1-65535> A.B.C.D",
5233 "IP Information\n"
5234 "OSPF interface commands\n"
5235 "Link state transmit delay\n"
5236 "Seconds\n"
5237 "Address of interface")
5238{
5239 struct interface *ifp = vty->index;
5240 u_int32_t seconds;
5241 struct in_addr addr;
5242 int ret;
5243 struct ospf_if_params *params;
5244
5245 params = IF_DEF_PARAMS (ifp);
5246 seconds = strtol (argv[0], NULL, 10);
5247
5248 /* Transmit Delay range is <1-65535>. */
5249 if (seconds < 1 || seconds > 65535)
5250 {
5251 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5252 return CMD_WARNING;
5253 }
5254
5255 if (argc == 2)
5256 {
5257 ret = inet_aton(argv[1], &addr);
5258 if (!ret)
5259 {
5260 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5261 VTY_NEWLINE);
5262 return CMD_WARNING;
5263 }
5264
5265 params = ospf_get_if_params (ifp, addr);
5266 ospf_if_update_params (ifp, addr);
5267 }
5268
5269 SET_IF_PARAM (params, transmit_delay);
5270 params->transmit_delay = seconds;
5271
5272 return CMD_SUCCESS;
5273}
5274
5275ALIAS (ip_ospf_transmit_delay,
5276 ip_ospf_transmit_delay_cmd,
5277 "ip ospf transmit-delay <1-65535>",
5278 "IP Information\n"
5279 "OSPF interface commands\n"
5280 "Link state transmit delay\n"
5281 "Seconds\n")
5282
5283ALIAS (ip_ospf_transmit_delay,
5284 ospf_transmit_delay_cmd,
5285 "ospf transmit-delay <1-65535>",
5286 "OSPF interface commands\n"
5287 "Link state transmit delay\n"
5288 "Seconds\n")
5289
5290DEFUN (no_ip_ospf_transmit_delay,
5291 no_ip_ospf_transmit_delay_addr_cmd,
5292 "no ip ospf transmit-delay A.B.C.D",
5293 NO_STR
5294 "IP Information\n"
5295 "OSPF interface commands\n"
5296 "Link state transmit delay\n"
5297 "Address of interface")
5298{
5299 struct interface *ifp = vty->index;
5300 struct in_addr addr;
5301 int ret;
5302 struct ospf_if_params *params;
5303
5304 ifp = vty->index;
5305 params = IF_DEF_PARAMS (ifp);
5306
5307 if (argc == 1)
5308 {
5309 ret = inet_aton(argv[0], &addr);
5310 if (!ret)
5311 {
5312 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5313 VTY_NEWLINE);
5314 return CMD_WARNING;
5315 }
5316
5317 params = ospf_lookup_if_params (ifp, addr);
5318 if (params == NULL)
5319 return CMD_SUCCESS;
5320 }
5321
5322 UNSET_IF_PARAM (params, transmit_delay);
5323 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5324
5325 if (params != IF_DEF_PARAMS (ifp))
5326 {
5327 ospf_free_if_params (ifp, addr);
5328 ospf_if_update_params (ifp, addr);
5329 }
5330
5331 return CMD_SUCCESS;
5332}
5333
5334ALIAS (no_ip_ospf_transmit_delay,
5335 no_ip_ospf_transmit_delay_cmd,
5336 "no ip ospf transmit-delay",
5337 NO_STR
5338 "IP Information\n"
5339 "OSPF interface commands\n"
5340 "Link state transmit delay\n")
5341
5342ALIAS (no_ip_ospf_transmit_delay,
5343 no_ospf_transmit_delay_cmd,
5344 "no ospf transmit-delay",
5345 NO_STR
5346 "OSPF interface commands\n"
5347 "Link state transmit delay\n")
5348
5349
5350DEFUN (ospf_redistribute_source_metric_type,
5351 ospf_redistribute_source_metric_type_routemap_cmd,
5352 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5353 "Redistribute information from another routing protocol\n"
5354 "Kernel routes\n"
5355 "Connected\n"
5356 "Static routes\n"
5357 "Routing Information Protocol (RIP)\n"
5358 "Border Gateway Protocol (BGP)\n"
5359 "Metric for redistributed routes\n"
5360 "OSPF default metric\n"
5361 "OSPF exterior metric type for redistributed routes\n"
5362 "Set OSPF External Type 1 metrics\n"
5363 "Set OSPF External Type 2 metrics\n"
5364 "Route map reference\n"
5365 "Pointer to route-map entries\n")
5366{
paul020709f2003-04-04 02:44:16 +00005367 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005368 int source;
5369 int type = -1;
5370 int metric = -1;
5371
5372 /* Get distribute source. */
5373 if (!str2distribute_source (argv[0], &source))
5374 return CMD_WARNING;
5375
5376 /* Get metric value. */
5377 if (argc >= 2)
5378 if (!str2metric (argv[1], &metric))
5379 return CMD_WARNING;
5380
5381 /* Get metric type. */
5382 if (argc >= 3)
5383 if (!str2metric_type (argv[2], &type))
5384 return CMD_WARNING;
5385
5386 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005387 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005388 else
paul020709f2003-04-04 02:44:16 +00005389 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005390
paul020709f2003-04-04 02:44:16 +00005391 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005392}
5393
5394ALIAS (ospf_redistribute_source_metric_type,
5395 ospf_redistribute_source_metric_type_cmd,
5396 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5397 "Redistribute information from another routing protocol\n"
5398 "Kernel routes\n"
5399 "Connected\n"
5400 "Static routes\n"
5401 "Routing Information Protocol (RIP)\n"
5402 "Border Gateway Protocol (BGP)\n"
5403 "Metric for redistributed routes\n"
5404 "OSPF default metric\n"
5405 "OSPF exterior metric type for redistributed routes\n"
5406 "Set OSPF External Type 1 metrics\n"
5407 "Set OSPF External Type 2 metrics\n")
5408
5409ALIAS (ospf_redistribute_source_metric_type,
5410 ospf_redistribute_source_metric_cmd,
5411 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5412 "Redistribute information from another routing protocol\n"
5413 "Kernel routes\n"
5414 "Connected\n"
5415 "Static routes\n"
5416 "Routing Information Protocol (RIP)\n"
5417 "Border Gateway Protocol (BGP)\n"
5418 "Metric for redistributed routes\n"
5419 "OSPF default metric\n")
5420
5421DEFUN (ospf_redistribute_source_type_metric,
5422 ospf_redistribute_source_type_metric_routemap_cmd,
5423 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5424 "Redistribute information from another routing protocol\n"
5425 "Kernel routes\n"
5426 "Connected\n"
5427 "Static routes\n"
5428 "Routing Information Protocol (RIP)\n"
5429 "Border Gateway Protocol (BGP)\n"
5430 "OSPF exterior metric type for redistributed routes\n"
5431 "Set OSPF External Type 1 metrics\n"
5432 "Set OSPF External Type 2 metrics\n"
5433 "Metric for redistributed routes\n"
5434 "OSPF default metric\n"
5435 "Route map reference\n"
5436 "Pointer to route-map entries\n")
5437{
paul020709f2003-04-04 02:44:16 +00005438 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005439 int source;
5440 int type = -1;
5441 int metric = -1;
5442
5443 /* Get distribute source. */
5444 if (!str2distribute_source (argv[0], &source))
5445 return CMD_WARNING;
5446
5447 /* Get metric value. */
5448 if (argc >= 2)
5449 if (!str2metric_type (argv[1], &type))
5450 return CMD_WARNING;
5451
5452 /* Get metric type. */
5453 if (argc >= 3)
5454 if (!str2metric (argv[2], &metric))
5455 return CMD_WARNING;
5456
5457 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005458 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005459 else
paul020709f2003-04-04 02:44:16 +00005460 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005461
paul020709f2003-04-04 02:44:16 +00005462 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005463}
5464
5465ALIAS (ospf_redistribute_source_type_metric,
5466 ospf_redistribute_source_type_metric_cmd,
5467 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5468 "Redistribute information from another routing protocol\n"
5469 "Kernel routes\n"
5470 "Connected\n"
5471 "Static routes\n"
5472 "Routing Information Protocol (RIP)\n"
5473 "Border Gateway Protocol (BGP)\n"
5474 "OSPF exterior metric type for redistributed routes\n"
5475 "Set OSPF External Type 1 metrics\n"
5476 "Set OSPF External Type 2 metrics\n"
5477 "Metric for redistributed routes\n"
5478 "OSPF default metric\n")
5479
5480ALIAS (ospf_redistribute_source_type_metric,
5481 ospf_redistribute_source_type_cmd,
5482 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5483 "Redistribute information from another routing protocol\n"
5484 "Kernel routes\n"
5485 "Connected\n"
5486 "Static routes\n"
5487 "Routing Information Protocol (RIP)\n"
5488 "Border Gateway Protocol (BGP)\n"
5489 "OSPF exterior metric type for redistributed routes\n"
5490 "Set OSPF External Type 1 metrics\n"
5491 "Set OSPF External Type 2 metrics\n")
5492
5493ALIAS (ospf_redistribute_source_type_metric,
5494 ospf_redistribute_source_cmd,
5495 "redistribute (kernel|connected|static|rip|bgp)",
5496 "Redistribute information from another routing protocol\n"
5497 "Kernel routes\n"
5498 "Connected\n"
5499 "Static routes\n"
5500 "Routing Information Protocol (RIP)\n"
5501 "Border Gateway Protocol (BGP)\n")
5502
5503DEFUN (ospf_redistribute_source_metric_routemap,
5504 ospf_redistribute_source_metric_routemap_cmd,
5505 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5506 "Redistribute information from another routing protocol\n"
5507 "Kernel routes\n"
5508 "Connected\n"
5509 "Static routes\n"
5510 "Routing Information Protocol (RIP)\n"
5511 "Border Gateway Protocol (BGP)\n"
5512 "Metric for redistributed routes\n"
5513 "OSPF default metric\n"
5514 "Route map reference\n"
5515 "Pointer to route-map entries\n")
5516{
paul020709f2003-04-04 02:44:16 +00005517 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005518 int source;
5519 int metric = -1;
5520
5521 /* Get distribute source. */
5522 if (!str2distribute_source (argv[0], &source))
5523 return CMD_WARNING;
5524
5525 /* Get metric value. */
5526 if (argc >= 2)
5527 if (!str2metric (argv[1], &metric))
5528 return CMD_WARNING;
5529
5530 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005531 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005532 else
paul020709f2003-04-04 02:44:16 +00005533 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005534
paul020709f2003-04-04 02:44:16 +00005535 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005536}
5537
5538DEFUN (ospf_redistribute_source_type_routemap,
5539 ospf_redistribute_source_type_routemap_cmd,
5540 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5541 "Redistribute information from another routing protocol\n"
5542 "Kernel routes\n"
5543 "Connected\n"
5544 "Static routes\n"
5545 "Routing Information Protocol (RIP)\n"
5546 "Border Gateway Protocol (BGP)\n"
5547 "OSPF exterior metric type for redistributed routes\n"
5548 "Set OSPF External Type 1 metrics\n"
5549 "Set OSPF External Type 2 metrics\n"
5550 "Route map reference\n"
5551 "Pointer to route-map entries\n")
5552{
paul020709f2003-04-04 02:44:16 +00005553 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005554 int source;
5555 int type = -1;
5556
5557 /* Get distribute source. */
5558 if (!str2distribute_source (argv[0], &source))
5559 return CMD_WARNING;
5560
5561 /* Get metric value. */
5562 if (argc >= 2)
5563 if (!str2metric_type (argv[1], &type))
5564 return CMD_WARNING;
5565
5566 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005567 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005568 else
paul020709f2003-04-04 02:44:16 +00005569 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005570
paul020709f2003-04-04 02:44:16 +00005571 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005572}
5573
5574DEFUN (ospf_redistribute_source_routemap,
5575 ospf_redistribute_source_routemap_cmd,
5576 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5577 "Redistribute information from another routing protocol\n"
5578 "Kernel routes\n"
5579 "Connected\n"
5580 "Static routes\n"
5581 "Routing Information Protocol (RIP)\n"
5582 "Border Gateway Protocol (BGP)\n"
5583 "Route map reference\n"
5584 "Pointer to route-map entries\n")
5585{
paul020709f2003-04-04 02:44:16 +00005586 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005587 int source;
5588
5589 /* Get distribute source. */
5590 if (!str2distribute_source (argv[0], &source))
5591 return CMD_WARNING;
5592
5593 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005594 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005595 else
paul020709f2003-04-04 02:44:16 +00005596 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005597
paul020709f2003-04-04 02:44:16 +00005598 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005599}
5600
5601DEFUN (no_ospf_redistribute_source,
5602 no_ospf_redistribute_source_cmd,
5603 "no redistribute (kernel|connected|static|rip|bgp)",
5604 NO_STR
5605 "Redistribute information from another routing protocol\n"
5606 "Kernel routes\n"
5607 "Connected\n"
5608 "Static routes\n"
5609 "Routing Information Protocol (RIP)\n"
5610 "Border Gateway Protocol (BGP)\n")
5611{
paul020709f2003-04-04 02:44:16 +00005612 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005613 int source;
5614
5615 if (!str2distribute_source (argv[0], &source))
5616 return CMD_WARNING;
5617
paul020709f2003-04-04 02:44:16 +00005618 ospf_routemap_unset (ospf, source);
5619 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005620}
5621
5622DEFUN (ospf_distribute_list_out,
5623 ospf_distribute_list_out_cmd,
5624 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5625 "Filter networks in routing updates\n"
5626 "Access-list name\n"
5627 OUT_STR
5628 "Kernel routes\n"
5629 "Connected\n"
5630 "Static routes\n"
5631 "Routing Information Protocol (RIP)\n"
5632 "Border Gateway Protocol (BGP)\n")
5633{
paul68980082003-03-25 05:07:42 +00005634 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005635 int source;
5636
5637 /* Get distribute source. */
5638 if (!str2distribute_source (argv[1], &source))
5639 return CMD_WARNING;
5640
paul68980082003-03-25 05:07:42 +00005641 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005642}
5643
5644DEFUN (no_ospf_distribute_list_out,
5645 no_ospf_distribute_list_out_cmd,
5646 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5647 NO_STR
5648 "Filter networks in routing updates\n"
5649 "Access-list name\n"
5650 OUT_STR
5651 "Kernel routes\n"
5652 "Connected\n"
5653 "Static routes\n"
5654 "Routing Information Protocol (RIP)\n"
5655 "Border Gateway Protocol (BGP)\n")
5656{
paul68980082003-03-25 05:07:42 +00005657 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005658 int source;
5659
5660 if (!str2distribute_source (argv[1], &source))
5661 return CMD_WARNING;
5662
paul68980082003-03-25 05:07:42 +00005663 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005664}
5665
5666/* Default information originate. */
5667DEFUN (ospf_default_information_originate_metric_type_routemap,
5668 ospf_default_information_originate_metric_type_routemap_cmd,
5669 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5670 "Control distribution of default information\n"
5671 "Distribute a default route\n"
5672 "OSPF default metric\n"
5673 "OSPF metric\n"
5674 "OSPF metric type for default routes\n"
5675 "Set OSPF External Type 1 metrics\n"
5676 "Set OSPF External Type 2 metrics\n"
5677 "Route map reference\n"
5678 "Pointer to route-map entries\n")
5679{
paul020709f2003-04-04 02:44:16 +00005680 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005681 int type = -1;
5682 int metric = -1;
5683
5684 /* Get metric value. */
5685 if (argc >= 1)
5686 if (!str2metric (argv[0], &metric))
5687 return CMD_WARNING;
5688
5689 /* Get metric type. */
5690 if (argc >= 2)
5691 if (!str2metric_type (argv[1], &type))
5692 return CMD_WARNING;
5693
5694 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005695 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005696 else
paul020709f2003-04-04 02:44:16 +00005697 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005698
paul020709f2003-04-04 02:44:16 +00005699 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5700 type, metric);
paul718e3742002-12-13 20:15:29 +00005701}
5702
5703ALIAS (ospf_default_information_originate_metric_type_routemap,
5704 ospf_default_information_originate_metric_type_cmd,
5705 "default-information originate metric <0-16777214> metric-type (1|2)",
5706 "Control distribution of default information\n"
5707 "Distribute a default route\n"
5708 "OSPF default metric\n"
5709 "OSPF metric\n"
5710 "OSPF metric type for default routes\n"
5711 "Set OSPF External Type 1 metrics\n"
5712 "Set OSPF External Type 2 metrics\n")
5713
5714ALIAS (ospf_default_information_originate_metric_type_routemap,
5715 ospf_default_information_originate_metric_cmd,
5716 "default-information originate metric <0-16777214>",
5717 "Control distribution of default information\n"
5718 "Distribute a default route\n"
5719 "OSPF default metric\n"
5720 "OSPF metric\n")
5721
5722ALIAS (ospf_default_information_originate_metric_type_routemap,
5723 ospf_default_information_originate_cmd,
5724 "default-information originate",
5725 "Control distribution of default information\n"
5726 "Distribute a default route\n")
5727
5728/* Default information originate. */
5729DEFUN (ospf_default_information_originate_metric_routemap,
5730 ospf_default_information_originate_metric_routemap_cmd,
5731 "default-information originate metric <0-16777214> route-map WORD",
5732 "Control distribution of default information\n"
5733 "Distribute a default route\n"
5734 "OSPF default metric\n"
5735 "OSPF metric\n"
5736 "Route map reference\n"
5737 "Pointer to route-map entries\n")
5738{
paul020709f2003-04-04 02:44:16 +00005739 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005740 int metric = -1;
5741
5742 /* Get metric value. */
5743 if (argc >= 1)
5744 if (!str2metric (argv[0], &metric))
5745 return CMD_WARNING;
5746
5747 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005748 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005749 else
paul020709f2003-04-04 02:44:16 +00005750 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005751
paul020709f2003-04-04 02:44:16 +00005752 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5753 -1, metric);
paul718e3742002-12-13 20:15:29 +00005754}
5755
5756/* Default information originate. */
5757DEFUN (ospf_default_information_originate_routemap,
5758 ospf_default_information_originate_routemap_cmd,
5759 "default-information originate route-map WORD",
5760 "Control distribution of default information\n"
5761 "Distribute a default route\n"
5762 "Route map reference\n"
5763 "Pointer to route-map entries\n")
5764{
paul020709f2003-04-04 02:44:16 +00005765 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005766
paul020709f2003-04-04 02:44:16 +00005767 if (argc == 1)
5768 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5769 else
5770 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5771
5772 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005773}
5774
5775DEFUN (ospf_default_information_originate_type_metric_routemap,
5776 ospf_default_information_originate_type_metric_routemap_cmd,
5777 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5778 "Control distribution of default information\n"
5779 "Distribute a default route\n"
5780 "OSPF metric type for default routes\n"
5781 "Set OSPF External Type 1 metrics\n"
5782 "Set OSPF External Type 2 metrics\n"
5783 "OSPF default metric\n"
5784 "OSPF metric\n"
5785 "Route map reference\n"
5786 "Pointer to route-map entries\n")
5787{
paul020709f2003-04-04 02:44:16 +00005788 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005789 int type = -1;
5790 int metric = -1;
5791
5792 /* Get metric type. */
5793 if (argc >= 1)
5794 if (!str2metric_type (argv[0], &type))
5795 return CMD_WARNING;
5796
5797 /* Get metric value. */
5798 if (argc >= 2)
5799 if (!str2metric (argv[1], &metric))
5800 return CMD_WARNING;
5801
5802 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005803 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005804 else
paul020709f2003-04-04 02:44:16 +00005805 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005806
paul020709f2003-04-04 02:44:16 +00005807 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5808 type, metric);
paul718e3742002-12-13 20:15:29 +00005809}
5810
5811ALIAS (ospf_default_information_originate_type_metric_routemap,
5812 ospf_default_information_originate_type_metric_cmd,
5813 "default-information originate metric-type (1|2) metric <0-16777214>",
5814 "Control distribution of default information\n"
5815 "Distribute a default route\n"
5816 "OSPF metric type for default routes\n"
5817 "Set OSPF External Type 1 metrics\n"
5818 "Set OSPF External Type 2 metrics\n"
5819 "OSPF default metric\n"
5820 "OSPF metric\n")
5821
5822ALIAS (ospf_default_information_originate_type_metric_routemap,
5823 ospf_default_information_originate_type_cmd,
5824 "default-information originate metric-type (1|2)",
5825 "Control distribution of default information\n"
5826 "Distribute a default route\n"
5827 "OSPF metric type for default routes\n"
5828 "Set OSPF External Type 1 metrics\n"
5829 "Set OSPF External Type 2 metrics\n")
5830
5831DEFUN (ospf_default_information_originate_type_routemap,
5832 ospf_default_information_originate_type_routemap_cmd,
5833 "default-information originate metric-type (1|2) route-map WORD",
5834 "Control distribution of default information\n"
5835 "Distribute a default route\n"
5836 "OSPF metric type for default routes\n"
5837 "Set OSPF External Type 1 metrics\n"
5838 "Set OSPF External Type 2 metrics\n"
5839 "Route map reference\n"
5840 "Pointer to route-map entries\n")
5841{
paul020709f2003-04-04 02:44:16 +00005842 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005843 int type = -1;
5844
5845 /* Get metric type. */
5846 if (argc >= 1)
5847 if (!str2metric_type (argv[0], &type))
5848 return CMD_WARNING;
5849
5850 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005851 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005852 else
paul020709f2003-04-04 02:44:16 +00005853 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005854
paul020709f2003-04-04 02:44:16 +00005855 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5856 type, -1);
paul718e3742002-12-13 20:15:29 +00005857}
5858
5859DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5860 ospf_default_information_originate_always_metric_type_routemap_cmd,
5861 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5862 "Control distribution of default information\n"
5863 "Distribute a default route\n"
5864 "Always advertise default route\n"
5865 "OSPF default metric\n"
5866 "OSPF metric\n"
5867 "OSPF metric type for default routes\n"
5868 "Set OSPF External Type 1 metrics\n"
5869 "Set OSPF External Type 2 metrics\n"
5870 "Route map reference\n"
5871 "Pointer to route-map entries\n")
5872{
paul020709f2003-04-04 02:44:16 +00005873 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005874 int type = -1;
5875 int metric = -1;
5876
5877 /* Get metric value. */
5878 if (argc >= 1)
5879 if (!str2metric (argv[0], &metric))
5880 return CMD_WARNING;
5881
5882 /* Get metric type. */
5883 if (argc >= 2)
5884 if (!str2metric_type (argv[1], &type))
5885 return CMD_WARNING;
5886
5887 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005888 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005889 else
paul020709f2003-04-04 02:44:16 +00005890 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005891
paul020709f2003-04-04 02:44:16 +00005892 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005893 type, metric);
5894}
5895
5896ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5897 ospf_default_information_originate_always_metric_type_cmd,
5898 "default-information originate always metric <0-16777214> metric-type (1|2)",
5899 "Control distribution of default information\n"
5900 "Distribute a default route\n"
5901 "Always advertise default route\n"
5902 "OSPF default metric\n"
5903 "OSPF metric\n"
5904 "OSPF metric type for default routes\n"
5905 "Set OSPF External Type 1 metrics\n"
5906 "Set OSPF External Type 2 metrics\n")
5907
5908ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5909 ospf_default_information_originate_always_metric_cmd,
5910 "default-information originate always metric <0-16777214>",
5911 "Control distribution of default information\n"
5912 "Distribute a default route\n"
5913 "Always advertise default route\n"
5914 "OSPF default metric\n"
5915 "OSPF metric\n"
5916 "OSPF metric type for default routes\n")
5917
5918ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5919 ospf_default_information_originate_always_cmd,
5920 "default-information originate always",
5921 "Control distribution of default information\n"
5922 "Distribute a default route\n"
5923 "Always advertise default route\n")
5924
5925DEFUN (ospf_default_information_originate_always_metric_routemap,
5926 ospf_default_information_originate_always_metric_routemap_cmd,
5927 "default-information originate always metric <0-16777214> route-map WORD",
5928 "Control distribution of default information\n"
5929 "Distribute a default route\n"
5930 "Always advertise default route\n"
5931 "OSPF default metric\n"
5932 "OSPF metric\n"
5933 "Route map reference\n"
5934 "Pointer to route-map entries\n")
5935{
paul020709f2003-04-04 02:44:16 +00005936 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005937 int metric = -1;
5938
5939 /* Get metric value. */
5940 if (argc >= 1)
5941 if (!str2metric (argv[0], &metric))
5942 return CMD_WARNING;
5943
5944 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005945 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005946 else
paul020709f2003-04-04 02:44:16 +00005947 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005948
paul020709f2003-04-04 02:44:16 +00005949 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5950 -1, metric);
paul718e3742002-12-13 20:15:29 +00005951}
5952
5953DEFUN (ospf_default_information_originate_always_routemap,
5954 ospf_default_information_originate_always_routemap_cmd,
5955 "default-information originate always route-map WORD",
5956 "Control distribution of default information\n"
5957 "Distribute a default route\n"
5958 "Always advertise default route\n"
5959 "Route map reference\n"
5960 "Pointer to route-map entries\n")
5961{
paul020709f2003-04-04 02:44:16 +00005962 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005963
paul020709f2003-04-04 02:44:16 +00005964 if (argc == 1)
5965 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5966 else
5967 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5968
5969 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005970}
5971
5972DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5973 ospf_default_information_originate_always_type_metric_routemap_cmd,
5974 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5975 "Control distribution of default information\n"
5976 "Distribute a default route\n"
5977 "Always advertise default route\n"
5978 "OSPF metric type for default routes\n"
5979 "Set OSPF External Type 1 metrics\n"
5980 "Set OSPF External Type 2 metrics\n"
5981 "OSPF default metric\n"
5982 "OSPF metric\n"
5983 "Route map reference\n"
5984 "Pointer to route-map entries\n")
5985{
paul020709f2003-04-04 02:44:16 +00005986 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005987 int type = -1;
5988 int metric = -1;
5989
5990 /* Get metric type. */
5991 if (argc >= 1)
5992 if (!str2metric_type (argv[0], &type))
5993 return CMD_WARNING;
5994
5995 /* Get metric value. */
5996 if (argc >= 2)
5997 if (!str2metric (argv[1], &metric))
5998 return CMD_WARNING;
5999
6000 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006001 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006002 else
paul020709f2003-04-04 02:44:16 +00006003 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006004
paul020709f2003-04-04 02:44:16 +00006005 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006006 type, metric);
6007}
6008
6009ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6010 ospf_default_information_originate_always_type_metric_cmd,
6011 "default-information originate always metric-type (1|2) metric <0-16777214>",
6012 "Control distribution of default information\n"
6013 "Distribute a default route\n"
6014 "Always advertise default route\n"
6015 "OSPF metric type for default routes\n"
6016 "Set OSPF External Type 1 metrics\n"
6017 "Set OSPF External Type 2 metrics\n"
6018 "OSPF default metric\n"
6019 "OSPF metric\n")
6020
6021ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6022 ospf_default_information_originate_always_type_cmd,
6023 "default-information originate always metric-type (1|2)",
6024 "Control distribution of default information\n"
6025 "Distribute a default route\n"
6026 "Always advertise default route\n"
6027 "OSPF metric type for default routes\n"
6028 "Set OSPF External Type 1 metrics\n"
6029 "Set OSPF External Type 2 metrics\n")
6030
6031DEFUN (ospf_default_information_originate_always_type_routemap,
6032 ospf_default_information_originate_always_type_routemap_cmd,
6033 "default-information originate always metric-type (1|2) route-map WORD",
6034 "Control distribution of default information\n"
6035 "Distribute a default route\n"
6036 "Always advertise default route\n"
6037 "OSPF metric type for default routes\n"
6038 "Set OSPF External Type 1 metrics\n"
6039 "Set OSPF External Type 2 metrics\n"
6040 "Route map reference\n"
6041 "Pointer to route-map entries\n")
6042{
paul020709f2003-04-04 02:44:16 +00006043 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006044 int type = -1;
6045
6046 /* Get metric type. */
6047 if (argc >= 1)
6048 if (!str2metric_type (argv[0], &type))
6049 return CMD_WARNING;
6050
6051 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006052 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006053 else
paul020709f2003-04-04 02:44:16 +00006054 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006055
paul020709f2003-04-04 02:44:16 +00006056 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006057 type, -1);
6058}
6059
6060DEFUN (no_ospf_default_information_originate,
6061 no_ospf_default_information_originate_cmd,
6062 "no default-information originate",
6063 NO_STR
6064 "Control distribution of default information\n"
6065 "Distribute a default route\n")
6066{
paul68980082003-03-25 05:07:42 +00006067 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006068 struct prefix_ipv4 p;
6069 struct in_addr nexthop;
6070
6071 p.family = AF_INET;
6072 p.prefix.s_addr = 0;
6073 p.prefixlen = 0;
6074
paul68980082003-03-25 05:07:42 +00006075 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
paul718e3742002-12-13 20:15:29 +00006076
6077 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6078 ospf_external_info_delete (DEFAULT_ROUTE, p);
6079 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6080 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6081 }
6082
paul020709f2003-04-04 02:44:16 +00006083 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6084 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006085}
6086
6087DEFUN (ospf_default_metric,
6088 ospf_default_metric_cmd,
6089 "default-metric <0-16777214>",
6090 "Set metric of redistributed routes\n"
6091 "Default metric\n")
6092{
paul68980082003-03-25 05:07:42 +00006093 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006094 int metric = -1;
6095
6096 if (!str2metric (argv[0], &metric))
6097 return CMD_WARNING;
6098
paul68980082003-03-25 05:07:42 +00006099 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006100
6101 return CMD_SUCCESS;
6102}
6103
6104DEFUN (no_ospf_default_metric,
6105 no_ospf_default_metric_cmd,
6106 "no default-metric",
6107 NO_STR
6108 "Set metric of redistributed routes\n")
6109{
paul68980082003-03-25 05:07:42 +00006110 struct ospf *ospf = vty->index;
6111
6112 ospf->default_metric = -1;
6113
paul718e3742002-12-13 20:15:29 +00006114 return CMD_SUCCESS;
6115}
6116
6117ALIAS (no_ospf_default_metric,
6118 no_ospf_default_metric_val_cmd,
6119 "no default-metric <0-16777214>",
6120 NO_STR
6121 "Set metric of redistributed routes\n"
6122 "Default metric\n")
6123
6124DEFUN (ospf_distance,
6125 ospf_distance_cmd,
6126 "distance <1-255>",
6127 "Define an administrative distance\n"
6128 "OSPF Administrative distance\n")
6129{
paul68980082003-03-25 05:07:42 +00006130 struct ospf *ospf = vty->index;
6131
6132 ospf->distance_all = atoi (argv[0]);
6133
paul718e3742002-12-13 20:15:29 +00006134 return CMD_SUCCESS;
6135}
6136
6137DEFUN (no_ospf_distance,
6138 no_ospf_distance_cmd,
6139 "no distance <1-255>",
6140 NO_STR
6141 "Define an administrative distance\n"
6142 "OSPF Administrative distance\n")
6143{
paul68980082003-03-25 05:07:42 +00006144 struct ospf *ospf = vty->index;
6145
6146 ospf->distance_all = 0;
6147
paul718e3742002-12-13 20:15:29 +00006148 return CMD_SUCCESS;
6149}
6150
6151DEFUN (no_ospf_distance_ospf,
6152 no_ospf_distance_ospf_cmd,
6153 "no distance ospf",
6154 NO_STR
6155 "Define an administrative distance\n"
6156 "OSPF Administrative distance\n"
6157 "OSPF Distance\n")
6158{
paul68980082003-03-25 05:07:42 +00006159 struct ospf *ospf = vty->index;
6160
6161 ospf->distance_intra = 0;
6162 ospf->distance_inter = 0;
6163 ospf->distance_external = 0;
6164
paul718e3742002-12-13 20:15:29 +00006165 return CMD_SUCCESS;
6166}
6167
6168DEFUN (ospf_distance_ospf_intra,
6169 ospf_distance_ospf_intra_cmd,
6170 "distance ospf intra-area <1-255>",
6171 "Define an administrative distance\n"
6172 "OSPF Administrative distance\n"
6173 "Intra-area routes\n"
6174 "Distance for intra-area routes\n")
6175{
paul68980082003-03-25 05:07:42 +00006176 struct ospf *ospf = vty->index;
6177
6178 ospf->distance_intra = atoi (argv[0]);
6179
paul718e3742002-12-13 20:15:29 +00006180 return CMD_SUCCESS;
6181}
6182
6183DEFUN (ospf_distance_ospf_intra_inter,
6184 ospf_distance_ospf_intra_inter_cmd,
6185 "distance ospf intra-area <1-255> inter-area <1-255>",
6186 "Define an administrative distance\n"
6187 "OSPF Administrative distance\n"
6188 "Intra-area routes\n"
6189 "Distance for intra-area routes\n"
6190 "Inter-area routes\n"
6191 "Distance for inter-area routes\n")
6192{
paul68980082003-03-25 05:07:42 +00006193 struct ospf *ospf = vty->index;
6194
6195 ospf->distance_intra = atoi (argv[0]);
6196 ospf->distance_inter = atoi (argv[1]);
6197
paul718e3742002-12-13 20:15:29 +00006198 return CMD_SUCCESS;
6199}
6200
6201DEFUN (ospf_distance_ospf_intra_external,
6202 ospf_distance_ospf_intra_external_cmd,
6203 "distance ospf intra-area <1-255> external <1-255>",
6204 "Define an administrative distance\n"
6205 "OSPF Administrative distance\n"
6206 "Intra-area routes\n"
6207 "Distance for intra-area routes\n"
6208 "External routes\n"
6209 "Distance for external routes\n")
6210{
paul68980082003-03-25 05:07:42 +00006211 struct ospf *ospf = vty->index;
6212
6213 ospf->distance_intra = atoi (argv[0]);
6214 ospf->distance_external = atoi (argv[1]);
6215
paul718e3742002-12-13 20:15:29 +00006216 return CMD_SUCCESS;
6217}
6218
6219DEFUN (ospf_distance_ospf_intra_inter_external,
6220 ospf_distance_ospf_intra_inter_external_cmd,
6221 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6222 "Define an administrative distance\n"
6223 "OSPF Administrative distance\n"
6224 "Intra-area routes\n"
6225 "Distance for intra-area routes\n"
6226 "Inter-area routes\n"
6227 "Distance for inter-area routes\n"
6228 "External routes\n"
6229 "Distance for external routes\n")
6230{
paul68980082003-03-25 05:07:42 +00006231 struct ospf *ospf = vty->index;
6232
6233 ospf->distance_intra = atoi (argv[0]);
6234 ospf->distance_inter = atoi (argv[1]);
6235 ospf->distance_external = atoi (argv[2]);
6236
paul718e3742002-12-13 20:15:29 +00006237 return CMD_SUCCESS;
6238}
6239
6240DEFUN (ospf_distance_ospf_intra_external_inter,
6241 ospf_distance_ospf_intra_external_inter_cmd,
6242 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6243 "Define an administrative distance\n"
6244 "OSPF Administrative distance\n"
6245 "Intra-area routes\n"
6246 "Distance for intra-area routes\n"
6247 "External routes\n"
6248 "Distance for external routes\n"
6249 "Inter-area routes\n"
6250 "Distance for inter-area routes\n")
6251{
paul68980082003-03-25 05:07:42 +00006252 struct ospf *ospf = vty->index;
6253
6254 ospf->distance_intra = atoi (argv[0]);
6255 ospf->distance_external = atoi (argv[1]);
6256 ospf->distance_inter = atoi (argv[2]);
6257
paul718e3742002-12-13 20:15:29 +00006258 return CMD_SUCCESS;
6259}
6260
6261DEFUN (ospf_distance_ospf_inter,
6262 ospf_distance_ospf_inter_cmd,
6263 "distance ospf inter-area <1-255>",
6264 "Define an administrative distance\n"
6265 "OSPF Administrative distance\n"
6266 "Inter-area routes\n"
6267 "Distance for inter-area routes\n")
6268{
paul68980082003-03-25 05:07:42 +00006269 struct ospf *ospf = vty->index;
6270
6271 ospf->distance_inter = atoi (argv[0]);
6272
paul718e3742002-12-13 20:15:29 +00006273 return CMD_SUCCESS;
6274}
6275
6276DEFUN (ospf_distance_ospf_inter_intra,
6277 ospf_distance_ospf_inter_intra_cmd,
6278 "distance ospf inter-area <1-255> intra-area <1-255>",
6279 "Define an administrative distance\n"
6280 "OSPF Administrative distance\n"
6281 "Inter-area routes\n"
6282 "Distance for inter-area routes\n"
6283 "Intra-area routes\n"
6284 "Distance for intra-area routes\n")
6285{
paul68980082003-03-25 05:07:42 +00006286 struct ospf *ospf = vty->index;
6287
6288 ospf->distance_inter = atoi (argv[0]);
6289 ospf->distance_intra = atoi (argv[1]);
6290
paul718e3742002-12-13 20:15:29 +00006291 return CMD_SUCCESS;
6292}
6293
6294DEFUN (ospf_distance_ospf_inter_external,
6295 ospf_distance_ospf_inter_external_cmd,
6296 "distance ospf inter-area <1-255> external <1-255>",
6297 "Define an administrative distance\n"
6298 "OSPF Administrative distance\n"
6299 "Inter-area routes\n"
6300 "Distance for inter-area routes\n"
6301 "External routes\n"
6302 "Distance for external routes\n")
6303{
paul68980082003-03-25 05:07:42 +00006304 struct ospf *ospf = vty->index;
6305
6306 ospf->distance_inter = atoi (argv[0]);
6307 ospf->distance_external = atoi (argv[1]);
6308
paul718e3742002-12-13 20:15:29 +00006309 return CMD_SUCCESS;
6310}
6311
6312DEFUN (ospf_distance_ospf_inter_intra_external,
6313 ospf_distance_ospf_inter_intra_external_cmd,
6314 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6315 "Define an administrative distance\n"
6316 "OSPF Administrative distance\n"
6317 "Inter-area routes\n"
6318 "Distance for inter-area routes\n"
6319 "Intra-area routes\n"
6320 "Distance for intra-area routes\n"
6321 "External routes\n"
6322 "Distance for external routes\n")
6323{
paul68980082003-03-25 05:07:42 +00006324 struct ospf *ospf = vty->index;
6325
6326 ospf->distance_inter = atoi (argv[0]);
6327 ospf->distance_intra = atoi (argv[1]);
6328 ospf->distance_external = atoi (argv[2]);
6329
paul718e3742002-12-13 20:15:29 +00006330 return CMD_SUCCESS;
6331}
6332
6333DEFUN (ospf_distance_ospf_inter_external_intra,
6334 ospf_distance_ospf_inter_external_intra_cmd,
6335 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6336 "Define an administrative distance\n"
6337 "OSPF Administrative distance\n"
6338 "Inter-area routes\n"
6339 "Distance for inter-area routes\n"
6340 "External routes\n"
6341 "Distance for external routes\n"
6342 "Intra-area routes\n"
6343 "Distance for intra-area routes\n")
6344{
paul68980082003-03-25 05:07:42 +00006345 struct ospf *ospf = vty->index;
6346
6347 ospf->distance_inter = atoi (argv[0]);
6348 ospf->distance_external = atoi (argv[1]);
6349 ospf->distance_intra = atoi (argv[2]);
6350
paul718e3742002-12-13 20:15:29 +00006351 return CMD_SUCCESS;
6352}
6353
6354DEFUN (ospf_distance_ospf_external,
6355 ospf_distance_ospf_external_cmd,
6356 "distance ospf external <1-255>",
6357 "Define an administrative distance\n"
6358 "OSPF Administrative distance\n"
6359 "External routes\n"
6360 "Distance for external routes\n")
6361{
paul68980082003-03-25 05:07:42 +00006362 struct ospf *ospf = vty->index;
6363
6364 ospf->distance_external = atoi (argv[0]);
6365
paul718e3742002-12-13 20:15:29 +00006366 return CMD_SUCCESS;
6367}
6368
6369DEFUN (ospf_distance_ospf_external_intra,
6370 ospf_distance_ospf_external_intra_cmd,
6371 "distance ospf external <1-255> intra-area <1-255>",
6372 "Define an administrative distance\n"
6373 "OSPF Administrative distance\n"
6374 "External routes\n"
6375 "Distance for external routes\n"
6376 "Intra-area routes\n"
6377 "Distance for intra-area routes\n")
6378{
paul68980082003-03-25 05:07:42 +00006379 struct ospf *ospf = vty->index;
6380
6381 ospf->distance_external = atoi (argv[0]);
6382 ospf->distance_intra = atoi (argv[1]);
6383
paul718e3742002-12-13 20:15:29 +00006384 return CMD_SUCCESS;
6385}
6386
6387DEFUN (ospf_distance_ospf_external_inter,
6388 ospf_distance_ospf_external_inter_cmd,
6389 "distance ospf external <1-255> inter-area <1-255>",
6390 "Define an administrative distance\n"
6391 "OSPF Administrative distance\n"
6392 "External routes\n"
6393 "Distance for external routes\n"
6394 "Inter-area routes\n"
6395 "Distance for inter-area routes\n")
6396{
paul68980082003-03-25 05:07:42 +00006397 struct ospf *ospf = vty->index;
6398
6399 ospf->distance_external = atoi (argv[0]);
6400 ospf->distance_inter = atoi (argv[1]);
6401
paul718e3742002-12-13 20:15:29 +00006402 return CMD_SUCCESS;
6403}
6404
6405DEFUN (ospf_distance_ospf_external_intra_inter,
6406 ospf_distance_ospf_external_intra_inter_cmd,
6407 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6408 "Define an administrative distance\n"
6409 "OSPF Administrative distance\n"
6410 "External routes\n"
6411 "Distance for external routes\n"
6412 "Intra-area routes\n"
6413 "Distance for intra-area routes\n"
6414 "Inter-area routes\n"
6415 "Distance for inter-area routes\n")
6416{
paul68980082003-03-25 05:07:42 +00006417 struct ospf *ospf = vty->index;
6418
6419 ospf->distance_external = atoi (argv[0]);
6420 ospf->distance_intra = atoi (argv[1]);
6421 ospf->distance_inter = atoi (argv[2]);
6422
paul718e3742002-12-13 20:15:29 +00006423 return CMD_SUCCESS;
6424}
6425
6426DEFUN (ospf_distance_ospf_external_inter_intra,
6427 ospf_distance_ospf_external_inter_intra_cmd,
6428 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6429 "Define an administrative distance\n"
6430 "OSPF Administrative distance\n"
6431 "External routes\n"
6432 "Distance for external routes\n"
6433 "Inter-area routes\n"
6434 "Distance for inter-area routes\n"
6435 "Intra-area routes\n"
6436 "Distance for intra-area routes\n")
6437{
paul68980082003-03-25 05:07:42 +00006438 struct ospf *ospf = vty->index;
6439
6440 ospf->distance_external = atoi (argv[0]);
6441 ospf->distance_inter = atoi (argv[1]);
6442 ospf->distance_intra = atoi (argv[2]);
6443
paul718e3742002-12-13 20:15:29 +00006444 return CMD_SUCCESS;
6445}
6446
6447DEFUN (ospf_distance_source,
6448 ospf_distance_source_cmd,
6449 "distance <1-255> A.B.C.D/M",
6450 "Administrative distance\n"
6451 "Distance value\n"
6452 "IP source prefix\n")
6453{
paul020709f2003-04-04 02:44:16 +00006454 struct ospf *ospf = vty->index;
6455
6456 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006457
paul718e3742002-12-13 20:15:29 +00006458 return CMD_SUCCESS;
6459}
6460
6461DEFUN (no_ospf_distance_source,
6462 no_ospf_distance_source_cmd,
6463 "no distance <1-255> A.B.C.D/M",
6464 NO_STR
6465 "Administrative distance\n"
6466 "Distance value\n"
6467 "IP source prefix\n")
6468{
paul020709f2003-04-04 02:44:16 +00006469 struct ospf *ospf = vty->index;
6470
6471 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6472
paul718e3742002-12-13 20:15:29 +00006473 return CMD_SUCCESS;
6474}
6475
6476DEFUN (ospf_distance_source_access_list,
6477 ospf_distance_source_access_list_cmd,
6478 "distance <1-255> A.B.C.D/M WORD",
6479 "Administrative distance\n"
6480 "Distance value\n"
6481 "IP source prefix\n"
6482 "Access list name\n")
6483{
paul020709f2003-04-04 02:44:16 +00006484 struct ospf *ospf = vty->index;
6485
6486 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6487
paul718e3742002-12-13 20:15:29 +00006488 return CMD_SUCCESS;
6489}
6490
6491DEFUN (no_ospf_distance_source_access_list,
6492 no_ospf_distance_source_access_list_cmd,
6493 "no distance <1-255> A.B.C.D/M WORD",
6494 NO_STR
6495 "Administrative distance\n"
6496 "Distance value\n"
6497 "IP source prefix\n"
6498 "Access list name\n")
6499{
paul020709f2003-04-04 02:44:16 +00006500 struct ospf *ospf = vty->index;
6501
6502 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6503
paul718e3742002-12-13 20:15:29 +00006504 return CMD_SUCCESS;
6505}
6506
6507void
6508show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6509{
6510 struct route_node *rn;
6511 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006512 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006513 struct ospf_path *path;
6514
6515 vty_out (vty, "============ OSPF network routing table ============%s",
6516 VTY_NEWLINE);
6517
6518 for (rn = route_top (rt); rn; rn = route_next (rn))
6519 if ((or = rn->info) != NULL)
6520 {
6521 char buf1[19];
6522 snprintf (buf1, 19, "%s/%d",
6523 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6524
6525 switch (or->path_type)
6526 {
6527 case OSPF_PATH_INTER_AREA:
6528 if (or->type == OSPF_DESTINATION_NETWORK)
6529 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6530 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6531 else if (or->type == OSPF_DESTINATION_DISCARD)
6532 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6533 break;
6534 case OSPF_PATH_INTRA_AREA:
6535 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6536 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6537 break;
6538 default:
6539 break;
6540 }
6541
6542 if (or->type == OSPF_DESTINATION_NETWORK)
paul96735ee2003-08-10 02:51:22 +00006543 LIST_LOOP (or->paths, path, pnode)
6544 {
6545 if (path->oi != NULL)
6546 {
6547 if (path->nexthop.s_addr == 0)
6548 vty_out (vty, "%24s directly attached to %s%s",
6549 "", path->oi->ifp->name, VTY_NEWLINE);
6550 else
6551 vty_out (vty, "%24s via %s, %s%s", "",
6552 inet_ntoa (path->nexthop), path->oi->ifp->name,
6553 VTY_NEWLINE);
6554 }
6555 }
paul718e3742002-12-13 20:15:29 +00006556 }
6557 vty_out (vty, "%s", VTY_NEWLINE);
6558}
6559
6560void
6561show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6562{
6563 struct route_node *rn;
6564 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006565 struct listnode *pn, *nn;
paul718e3742002-12-13 20:15:29 +00006566 struct ospf_path *path;
6567
6568 vty_out (vty, "============ OSPF router routing table =============%s",
6569 VTY_NEWLINE);
6570 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6571 if (rn->info)
6572 {
6573 int flag = 0;
6574
6575 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6576
hasso52dc7ee2004-09-23 19:18:23 +00006577 for (nn = listhead ((struct list *) rn->info); nn; nextnode (nn))
paul718e3742002-12-13 20:15:29 +00006578 if ((or = getdata (nn)) != NULL)
6579 {
6580 if (flag++)
paulb0a053b2003-06-22 09:04:47 +00006581 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006582
6583 /* Show path. */
6584 vty_out (vty, "%s [%d] area: %s",
6585 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6586 or->cost, inet_ntoa (or->u.std.area_id));
6587 /* Show flags. */
6588 vty_out (vty, "%s%s%s",
6589 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6590 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6591 VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006592
6593 LIST_LOOP (or->paths, path, pn)
6594 {
6595 if (path->nexthop.s_addr == 0)
6596 vty_out (vty, "%24s directly attached to %s%s",
6597 "", path->oi->ifp->name, VTY_NEWLINE);
6598 else
6599 vty_out (vty, "%24s via %s, %s%s", "",
6600 inet_ntoa (path->nexthop), path->oi->ifp->name,
6601 VTY_NEWLINE);
6602 }
paul718e3742002-12-13 20:15:29 +00006603 }
6604 }
6605 vty_out (vty, "%s", VTY_NEWLINE);
6606}
6607
6608void
6609show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6610{
6611 struct route_node *rn;
6612 struct ospf_route *er;
hasso52dc7ee2004-09-23 19:18:23 +00006613 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006614 struct ospf_path *path;
6615
6616 vty_out (vty, "============ OSPF external routing table ===========%s",
6617 VTY_NEWLINE);
6618 for (rn = route_top (rt); rn; rn = route_next (rn))
6619 if ((er = rn->info) != NULL)
6620 {
6621 char buf1[19];
6622 snprintf (buf1, 19, "%s/%d",
6623 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6624
6625 switch (er->path_type)
6626 {
6627 case OSPF_PATH_TYPE1_EXTERNAL:
6628 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6629 er->cost, er->u.ext.tag, VTY_NEWLINE);
6630 break;
6631 case OSPF_PATH_TYPE2_EXTERNAL:
6632 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6633 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6634 break;
6635 }
6636
paul96735ee2003-08-10 02:51:22 +00006637 LIST_LOOP (er->paths, path, pnode)
paul718e3742002-12-13 20:15:29 +00006638 {
paul718e3742002-12-13 20:15:29 +00006639 if (path->oi != NULL)
6640 {
6641 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006642 vty_out (vty, "%24s directly attached to %s%s",
6643 "", path->oi->ifp->name, VTY_NEWLINE);
6644 else
6645 vty_out (vty, "%24s via %s, %s%s", "",
6646 inet_ntoa (path->nexthop), path->oi->ifp->name,
6647 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006648 }
6649 }
6650 }
6651 vty_out (vty, "%s", VTY_NEWLINE);
6652}
6653
paul718e3742002-12-13 20:15:29 +00006654DEFUN (show_ip_ospf_border_routers,
6655 show_ip_ospf_border_routers_cmd,
6656 "show ip ospf border-routers",
6657 SHOW_STR
6658 IP_STR
6659 "show all the ABR's and ASBR's\n"
6660 "for this area\n")
6661{
paul020709f2003-04-04 02:44:16 +00006662 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006663
paul020709f2003-04-04 02:44:16 +00006664 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006665 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006666 {
6667 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6668 return CMD_SUCCESS;
6669 }
6670
paul68980082003-03-25 05:07:42 +00006671 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006672 {
6673 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6674 return CMD_SUCCESS;
6675 }
6676
6677 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006678 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006679
6680 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006681 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006682
6683 return CMD_SUCCESS;
6684}
paul718e3742002-12-13 20:15:29 +00006685
6686DEFUN (show_ip_ospf_route,
6687 show_ip_ospf_route_cmd,
6688 "show ip ospf route",
6689 SHOW_STR
6690 IP_STR
6691 "OSPF information\n"
6692 "OSPF routing table\n")
6693{
paul020709f2003-04-04 02:44:16 +00006694 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006695
paul020709f2003-04-04 02:44:16 +00006696 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006697 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006698 {
6699 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6700 return CMD_SUCCESS;
6701 }
6702
paul68980082003-03-25 05:07:42 +00006703 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006704 {
6705 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6706 return CMD_SUCCESS;
6707 }
6708
6709 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006710 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006711
6712 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006713 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006714
6715 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006716 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006717
6718 return CMD_SUCCESS;
6719}
6720
6721
hassoeb1ce602004-10-08 08:17:22 +00006722const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006723{
6724 "unknown",
6725 "standard",
6726 "ibm",
6727 "cisco",
6728 "shortcut"
6729};
6730
hassoeb1ce602004-10-08 08:17:22 +00006731const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006732{
6733 "default",
6734 "enable",
6735 "disable"
6736};
6737
6738
6739void
6740area_id2str (char *buf, int length, struct ospf_area *area)
6741{
6742 memset (buf, 0, length);
6743
6744 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6745 strncpy (buf, inet_ntoa (area->area_id), length);
6746 else
6747 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6748}
6749
6750
hassoeb1ce602004-10-08 08:17:22 +00006751const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006752{
6753 "unknown", /* should never be used. */
6754 "point-to-point",
6755 "broadcast",
6756 "non-broadcast",
6757 "point-to-multipoint",
6758 "virtual-link", /* should never be used. */
6759 "loopback"
6760};
6761
6762/* Configuration write function for ospfd. */
6763int
6764config_write_interface (struct vty *vty)
6765{
hasso52dc7ee2004-09-23 19:18:23 +00006766 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006767 struct interface *ifp;
6768 struct crypt_key *ck;
6769 int write = 0;
6770 struct route_node *rn = NULL;
6771 struct ospf_if_params *params;
6772
6773 for (n1 = listhead (iflist); n1; nextnode (n1))
6774 {
6775 ifp = getdata (n1);
6776
6777 if (memcmp (ifp->name, "VLINK", 5) == 0)
6778 continue;
6779
6780 vty_out (vty, "!%s", VTY_NEWLINE);
6781 vty_out (vty, "interface %s%s", ifp->name,
6782 VTY_NEWLINE);
6783 if (ifp->desc)
6784 vty_out (vty, " description %s%s", ifp->desc,
6785 VTY_NEWLINE);
6786
6787 write++;
6788
6789 params = IF_DEF_PARAMS (ifp);
6790
6791 do {
6792 /* Interface Network print. */
6793 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006794 params->type != OSPF_IFTYPE_LOOPBACK)
6795 {
ajsbc18d612004-12-15 15:07:19 +00006796 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006797 {
6798 vty_out (vty, " ip ospf network %s",
6799 ospf_int_type_str[params->type]);
6800 if (params != IF_DEF_PARAMS (ifp))
6801 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6802 vty_out (vty, "%s", VTY_NEWLINE);
6803 }
paul718e3742002-12-13 20:15:29 +00006804 }
6805
6806 /* OSPF interface authentication print */
6807 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6808 params->auth_type != OSPF_AUTH_NOTSET)
6809 {
hassoeb1ce602004-10-08 08:17:22 +00006810 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006811
6812 /* Translation tables are not that much help here due to syntax
6813 of the simple option */
6814 switch (params->auth_type)
6815 {
6816
6817 case OSPF_AUTH_NULL:
6818 auth_str = " null";
6819 break;
6820
6821 case OSPF_AUTH_SIMPLE:
6822 auth_str = "";
6823 break;
6824
6825 case OSPF_AUTH_CRYPTOGRAPHIC:
6826 auth_str = " message-digest";
6827 break;
6828
6829 default:
6830 auth_str = "";
6831 break;
6832 }
6833
6834 vty_out (vty, " ip ospf authentication%s", auth_str);
6835 if (params != IF_DEF_PARAMS (ifp))
6836 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6837 vty_out (vty, "%s", VTY_NEWLINE);
6838 }
6839
6840 /* Simple Authentication Password print. */
6841 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6842 params->auth_simple[0] != '\0')
6843 {
6844 vty_out (vty, " ip ospf authentication-key %s",
6845 params->auth_simple);
6846 if (params != IF_DEF_PARAMS (ifp))
6847 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6848 vty_out (vty, "%s", VTY_NEWLINE);
6849 }
6850
6851 /* Cryptographic Authentication Key print. */
6852 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
6853 {
6854 ck = getdata (n2);
6855 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6856 ck->key_id, ck->auth_key);
6857 if (params != IF_DEF_PARAMS (ifp))
6858 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6859 vty_out (vty, "%s", VTY_NEWLINE);
6860 }
6861
6862 /* Interface Output Cost print. */
6863 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6864 {
6865 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
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 /* Hello Interval print. */
6872 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6873 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6874 {
6875 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6876 if (params != IF_DEF_PARAMS (ifp))
6877 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6878 vty_out (vty, "%s", VTY_NEWLINE);
6879 }
6880
6881
6882 /* Router Dead Interval print. */
6883 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6884 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6885 {
6886 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
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 /* Router Priority print. */
6893 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6894 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6895 {
6896 vty_out (vty, " ip ospf priority %u", params->priority);
6897 if (params != IF_DEF_PARAMS (ifp))
6898 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6899 vty_out (vty, "%s", VTY_NEWLINE);
6900 }
6901
6902 /* Retransmit Interval print. */
6903 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6904 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6905 {
6906 vty_out (vty, " ip ospf retransmit-interval %u",
6907 params->retransmit_interval);
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 /* Transmit Delay print. */
6914 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6915 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6916 {
6917 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6918 if (params != IF_DEF_PARAMS (ifp))
6919 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6920 vty_out (vty, "%s", VTY_NEWLINE);
6921 }
6922
6923 while (1)
6924 {
6925 if (rn == NULL)
6926 rn = route_top (IF_OIFS_PARAMS (ifp));
6927 else
6928 rn = route_next (rn);
6929
6930 if (rn == NULL)
6931 break;
6932 params = rn->info;
6933 if (params != NULL)
6934 break;
6935 }
6936 } while (rn);
6937
6938#ifdef HAVE_OPAQUE_LSA
6939 ospf_opaque_config_write_if (vty, ifp);
6940#endif /* HAVE_OPAQUE_LSA */
6941 }
6942
6943 return write;
6944}
6945
6946int
paul68980082003-03-25 05:07:42 +00006947config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006948{
6949 struct route_node *rn;
6950 u_char buf[INET_ADDRSTRLEN];
6951
6952 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006953 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006954 if (rn->info)
6955 {
6956 struct ospf_network *n = rn->info;
6957
6958 memset (buf, 0, INET_ADDRSTRLEN);
6959
6960 /* Create Area ID string by specified Area ID format. */
6961 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00006962 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00006963 else
hassoc9e52be2004-09-26 16:09:34 +00006964 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00006965 (unsigned long int) ntohl (n->area_id.s_addr));
6966
6967 /* Network print. */
6968 vty_out (vty, " network %s/%d area %s%s",
6969 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6970 buf, VTY_NEWLINE);
6971 }
6972
6973 return 0;
6974}
6975
6976int
paul68980082003-03-25 05:07:42 +00006977config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006978{
hasso52dc7ee2004-09-23 19:18:23 +00006979 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006980 u_char buf[INET_ADDRSTRLEN];
6981
6982 /* Area configuration print. */
paul68980082003-03-25 05:07:42 +00006983 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00006984 {
6985 struct ospf_area *area = getdata (node);
6986 struct route_node *rn1;
6987
hassoc9e52be2004-09-26 16:09:34 +00006988 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00006989
6990 if (area->auth_type != OSPF_AUTH_NULL)
6991 {
6992 if (area->auth_type == OSPF_AUTH_SIMPLE)
6993 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6994 else
6995 vty_out (vty, " area %s authentication message-digest%s",
6996 buf, VTY_NEWLINE);
6997 }
6998
6999 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7000 vty_out (vty, " area %s shortcut %s%s", buf,
7001 ospf_shortcut_mode_str[area->shortcut_configured],
7002 VTY_NEWLINE);
7003
7004 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007005 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007006 )
7007 {
paulb0a053b2003-06-22 09:04:47 +00007008 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007009 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007010 else if (area->external_routing == OSPF_AREA_NSSA)
7011 {
7012 vty_out (vty, " area %s nssa", buf);
7013 switch (area->NSSATranslatorRole)
7014 {
7015 case OSPF_NSSA_ROLE_NEVER:
7016 vty_out (vty, " translate-never");
7017 break;
7018 case OSPF_NSSA_ROLE_ALWAYS:
7019 vty_out (vty, " translate-always");
7020 break;
7021 case OSPF_NSSA_ROLE_CANDIDATE:
7022 default:
7023 vty_out (vty, " translate-candidate");
7024 }
7025 }
paul718e3742002-12-13 20:15:29 +00007026
7027 if (area->no_summary)
7028 vty_out (vty, " no-summary");
7029
7030 vty_out (vty, "%s", VTY_NEWLINE);
7031
7032 if (area->default_cost != 1)
7033 vty_out (vty, " area %s default-cost %d%s", buf,
7034 area->default_cost, VTY_NEWLINE);
7035 }
7036
7037 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7038 if (rn1->info)
7039 {
7040 struct ospf_area_range *range = rn1->info;
7041
7042 vty_out (vty, " area %s range %s/%d", buf,
7043 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7044
paul6c835672004-10-11 11:00:30 +00007045 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007046 vty_out (vty, " cost %d", range->cost_config);
7047
7048 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7049 vty_out (vty, " not-advertise");
7050
7051 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7052 vty_out (vty, " substitute %s/%d",
7053 inet_ntoa (range->subst_addr), range->subst_masklen);
7054
7055 vty_out (vty, "%s", VTY_NEWLINE);
7056 }
7057
7058 if (EXPORT_NAME (area))
7059 vty_out (vty, " area %s export-list %s%s", buf,
7060 EXPORT_NAME (area), VTY_NEWLINE);
7061
7062 if (IMPORT_NAME (area))
7063 vty_out (vty, " area %s import-list %s%s", buf,
7064 IMPORT_NAME (area), VTY_NEWLINE);
7065
7066 if (PREFIX_NAME_IN (area))
7067 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7068 PREFIX_NAME_IN (area), VTY_NEWLINE);
7069
7070 if (PREFIX_NAME_OUT (area))
7071 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7072 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7073 }
7074
7075 return 0;
7076}
7077
7078int
paul68980082003-03-25 05:07:42 +00007079config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007080{
7081 struct ospf_nbr_nbma *nbr_nbma;
7082 struct route_node *rn;
7083
7084 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007085 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007086 if ((nbr_nbma = rn->info))
7087 {
7088 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7089
7090 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7091 vty_out (vty, " priority %d", nbr_nbma->priority);
7092
7093 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7094 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7095
7096 vty_out (vty, "%s", VTY_NEWLINE);
7097 }
7098
7099 return 0;
7100}
7101
7102int
paul68980082003-03-25 05:07:42 +00007103config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007104{
hasso52dc7ee2004-09-23 19:18:23 +00007105 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007106 u_char buf[INET_ADDRSTRLEN];
7107
7108 /* Virtual-Link print */
paul68980082003-03-25 05:07:42 +00007109 for (node = listhead (ospf->vlinks); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007110 {
hasso52dc7ee2004-09-23 19:18:23 +00007111 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007112 struct crypt_key *ck;
7113 struct ospf_vl_data *vl_data = getdata (node);
7114 struct ospf_interface *oi;
7115
7116 if (vl_data != NULL)
7117 {
7118 memset (buf, 0, INET_ADDRSTRLEN);
7119
7120 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007121 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007122 else
hassoc9e52be2004-09-26 16:09:34 +00007123 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007124 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7125 oi = vl_data->vl_oi;
7126
7127 /* timers */
7128 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7129 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7130 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7131 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7132 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7133 buf,
7134 inet_ntoa (vl_data->vl_peer),
7135 OSPF_IF_PARAM (oi, v_hello),
7136 OSPF_IF_PARAM (oi, retransmit_interval),
7137 OSPF_IF_PARAM (oi, transmit_delay),
7138 OSPF_IF_PARAM (oi, v_wait),
7139 VTY_NEWLINE);
7140 else
7141 vty_out (vty, " area %s virtual-link %s%s", buf,
7142 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7143 /* Auth key */
7144 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7145 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7146 buf,
7147 inet_ntoa (vl_data->vl_peer),
7148 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7149 VTY_NEWLINE);
7150 /* md5 keys */
7151 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
7152 {
7153 ck = getdata (n2);
7154 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
7155 buf,
7156 inet_ntoa (vl_data->vl_peer),
7157 ck->key_id, ck->auth_key, VTY_NEWLINE);
7158 }
7159
7160 }
7161 }
7162
7163 return 0;
7164}
7165
7166
hassoeb1ce602004-10-08 08:17:22 +00007167const char *distribute_str[] = { "system", "kernel", "connected", "static",
7168 "rip", "ripng", "ospf", "ospf6", "isis", "bgp"};
paul718e3742002-12-13 20:15:29 +00007169int
paul68980082003-03-25 05:07:42 +00007170config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007171{
7172 int type;
7173
7174 /* redistribute print. */
7175 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7176 if (type != zclient->redist_default && zclient->redist[type])
7177 {
7178 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007179 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007180 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007181
paul68980082003-03-25 05:07:42 +00007182 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007183 vty_out (vty, " metric-type 1");
7184
paul020709f2003-04-04 02:44:16 +00007185 if (ROUTEMAP_NAME (ospf, type))
7186 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007187
7188 vty_out (vty, "%s", VTY_NEWLINE);
7189 }
7190
7191 return 0;
7192}
7193
7194int
paul68980082003-03-25 05:07:42 +00007195config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007196{
paul68980082003-03-25 05:07:42 +00007197 if (ospf->default_metric != -1)
7198 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007199 VTY_NEWLINE);
7200 return 0;
7201}
7202
7203int
paul68980082003-03-25 05:07:42 +00007204config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007205{
7206 int type;
7207
paul68980082003-03-25 05:07:42 +00007208 if (ospf)
paul718e3742002-12-13 20:15:29 +00007209 {
7210 /* distribute-list print. */
7211 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007212 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007213 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007214 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007215 distribute_str[type], VTY_NEWLINE);
7216
7217 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007218 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007219 {
paul68980082003-03-25 05:07:42 +00007220 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007221 vty_out (vty, " default-information originate");
7222 else
7223 vty_out (vty, " default-information originate always");
7224
paul68980082003-03-25 05:07:42 +00007225 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007226 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007227 ospf->dmetric[DEFAULT_ROUTE].value);
7228 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007229 vty_out (vty, " metric-type 1");
7230
paul020709f2003-04-04 02:44:16 +00007231 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7232 vty_out (vty, " route-map %s",
7233 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007234
7235 vty_out (vty, "%s", VTY_NEWLINE);
7236 }
7237
7238 }
7239
7240 return 0;
7241}
7242
7243int
paul68980082003-03-25 05:07:42 +00007244config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007245{
7246 struct route_node *rn;
7247 struct ospf_distance *odistance;
7248
paul68980082003-03-25 05:07:42 +00007249 if (ospf->distance_all)
7250 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007251
paul68980082003-03-25 05:07:42 +00007252 if (ospf->distance_intra
7253 || ospf->distance_inter
7254 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007255 {
7256 vty_out (vty, " distance ospf");
7257
paul68980082003-03-25 05:07:42 +00007258 if (ospf->distance_intra)
7259 vty_out (vty, " intra-area %d", ospf->distance_intra);
7260 if (ospf->distance_inter)
7261 vty_out (vty, " inter-area %d", ospf->distance_inter);
7262 if (ospf->distance_external)
7263 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007264
7265 vty_out (vty, "%s", VTY_NEWLINE);
7266 }
7267
paul68980082003-03-25 05:07:42 +00007268 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007269 if ((odistance = rn->info) != NULL)
7270 {
7271 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7272 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7273 odistance->access_list ? odistance->access_list : "",
7274 VTY_NEWLINE);
7275 }
7276 return 0;
7277}
7278
7279/* OSPF configuration write function. */
7280int
7281ospf_config_write (struct vty *vty)
7282{
paul020709f2003-04-04 02:44:16 +00007283 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00007284 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007285 int write = 0;
7286
paul020709f2003-04-04 02:44:16 +00007287 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007288 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007289 {
7290 /* `router ospf' print. */
7291 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7292
7293 write++;
7294
paul68980082003-03-25 05:07:42 +00007295 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007296 return write;
7297
7298 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007299 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007300 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007301 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007302
7303 /* ABR type print. */
paul68980082003-03-25 05:07:42 +00007304 if (ospf->abr_type != OSPF_ABR_STAND)
paul718e3742002-12-13 20:15:29 +00007305 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007306 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007307
7308 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007309 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007310 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7311
7312 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007313 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007314 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007315 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007316
7317 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007318 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7319 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007320 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007321 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007322
7323 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007324 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007325 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007326 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007327
7328 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007329 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007330
7331 /* passive-interface print. */
paul020709f2003-04-04 02:44:16 +00007332 for (node = listhead (om->iflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007333 {
7334 struct interface *ifp = getdata (node);
7335
7336 if (!ifp)
7337 continue;
7338 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7339 vty_out (vty, " passive-interface %s%s",
7340 ifp->name, VTY_NEWLINE);
7341 }
7342
paul68980082003-03-25 05:07:42 +00007343 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007344 {
7345 struct ospf_interface *oi = getdata (node);
7346
7347 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7348 oi->params->passive_interface == OSPF_IF_PASSIVE)
paul96735ee2003-08-10 02:51:22 +00007349 vty_out (vty, " passive-interface %s %s%s",
7350 oi->ifp->name,
paul5fdc1e52003-08-06 22:41:29 +00007351 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007352 }
7353
7354
7355 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007356 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007357
7358 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007359 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007360
7361 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007362 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007363
7364 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007365 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007366
7367 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007368 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007369
7370 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007371 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007372
7373 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007374 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007375
7376#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007377 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007378#endif /* HAVE_OPAQUE_LSA */
7379 }
7380
7381 return write;
7382}
7383
7384void
7385ospf_vty_show_init ()
7386{
7387 /* "show ip ospf" commands. */
7388 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7389 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7390
7391 /* "show ip ospf database" commands. */
7392 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7393 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7394 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7395 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7396 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7397 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7398 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7399 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7400 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7401 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7402 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7403 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7404 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7405 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7406
7407 /* "show ip ospf interface" commands. */
7408 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7409 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7410
7411 /* "show ip ospf neighbor" commands. */
7412 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7413 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7414 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7415 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7416 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7417 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7418 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7419 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7420 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7421 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7422 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7423 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7424 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7425 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7426
7427 /* "show ip ospf route" commands. */
7428 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7429 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007430 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7431 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007432}
7433
7434
7435/* ospfd's interface node. */
7436struct cmd_node interface_node =
7437{
7438 INTERFACE_NODE,
7439 "%s(config-if)# ",
7440 1
7441};
7442
7443/* Initialization of OSPF interface. */
7444void
7445ospf_vty_if_init ()
7446{
7447 /* Install interface node. */
7448 install_node (&interface_node, config_write_interface);
7449
7450 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007451 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007452 install_default (INTERFACE_NODE);
7453
7454 /* "description" commands. */
7455 install_element (INTERFACE_NODE, &interface_desc_cmd);
7456 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7457
7458 /* "ip ospf authentication" commands. */
7459 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7460 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7461 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7462 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7463 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7464 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7465 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7466 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7467 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7468 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7469
7470 /* "ip ospf message-digest-key" commands. */
7471 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7472 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7473 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7474 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7475
7476 /* "ip ospf cost" commands. */
7477 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7478 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7479 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7480 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7481
7482 /* "ip ospf dead-interval" commands. */
7483 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7484 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7485 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7486 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7487
7488 /* "ip ospf hello-interval" commands. */
7489 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7490 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7491 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7492 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7493
7494 /* "ip ospf network" commands. */
7495 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7496 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7497
7498 /* "ip ospf priority" commands. */
7499 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7500 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7501 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7502 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7503
7504 /* "ip ospf retransmit-interval" commands. */
7505 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7506 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7507 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7508 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7509
7510 /* "ip ospf transmit-delay" commands. */
7511 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7512 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7513 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7514 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7515
7516 /* These commands are compatibitliy for previous version. */
7517 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7518 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7519 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7520 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7521 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7522 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7523 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7524 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7525 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7526 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7527 install_element (INTERFACE_NODE, &ospf_network_cmd);
7528 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7529 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7530 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7531 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7532 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7533 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7534 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7535}
7536
7537/* Zebra node structure. */
7538struct cmd_node zebra_node =
7539{
7540 ZEBRA_NODE,
7541 "%s(config-router)#",
7542};
7543
7544void
7545ospf_vty_zebra_init ()
7546{
7547 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7548 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7549 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7550 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7551 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7552 install_element (OSPF_NODE,
7553 &ospf_redistribute_source_metric_type_routemap_cmd);
7554 install_element (OSPF_NODE,
7555 &ospf_redistribute_source_type_metric_routemap_cmd);
7556 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7557 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7558 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7559
7560 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7561
7562 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7563 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7564
7565 install_element (OSPF_NODE,
7566 &ospf_default_information_originate_metric_type_cmd);
7567 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7568 install_element (OSPF_NODE,
7569 &ospf_default_information_originate_type_metric_cmd);
7570 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7571 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7572 install_element (OSPF_NODE,
7573 &ospf_default_information_originate_always_metric_type_cmd);
7574 install_element (OSPF_NODE,
7575 &ospf_default_information_originate_always_metric_cmd);
7576 install_element (OSPF_NODE,
7577 &ospf_default_information_originate_always_cmd);
7578 install_element (OSPF_NODE,
7579 &ospf_default_information_originate_always_type_metric_cmd);
7580 install_element (OSPF_NODE,
7581 &ospf_default_information_originate_always_type_cmd);
7582
7583 install_element (OSPF_NODE,
7584 &ospf_default_information_originate_metric_type_routemap_cmd);
7585 install_element (OSPF_NODE,
7586 &ospf_default_information_originate_metric_routemap_cmd);
7587 install_element (OSPF_NODE,
7588 &ospf_default_information_originate_routemap_cmd);
7589 install_element (OSPF_NODE,
7590 &ospf_default_information_originate_type_metric_routemap_cmd);
7591 install_element (OSPF_NODE,
7592 &ospf_default_information_originate_type_routemap_cmd);
7593 install_element (OSPF_NODE,
7594 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7595 install_element (OSPF_NODE,
7596 &ospf_default_information_originate_always_metric_routemap_cmd);
7597 install_element (OSPF_NODE,
7598 &ospf_default_information_originate_always_routemap_cmd);
7599 install_element (OSPF_NODE,
7600 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7601 install_element (OSPF_NODE,
7602 &ospf_default_information_originate_always_type_routemap_cmd);
7603
7604 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7605
7606 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7607 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7608 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7609
7610 install_element (OSPF_NODE, &ospf_distance_cmd);
7611 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7612 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7613 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7614 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7615 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7616 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7617 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7618 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7619 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7620 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7621 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7622 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7623 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7624 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7625 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7626 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7627 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7628#if 0
7629 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7630 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7631 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7632 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7633#endif /* 0 */
7634}
7635
7636struct cmd_node ospf_node =
7637{
7638 OSPF_NODE,
7639 "%s(config-router)# ",
7640 1
7641};
7642
7643
7644/* Install OSPF related vty commands. */
7645void
7646ospf_vty_init ()
7647{
7648 /* Install ospf top node. */
7649 install_node (&ospf_node, ospf_config_write);
7650
7651 /* "router ospf" commands. */
7652 install_element (CONFIG_NODE, &router_ospf_cmd);
7653 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7654
7655 install_default (OSPF_NODE);
7656
7657 /* "ospf router-id" commands. */
7658 install_element (OSPF_NODE, &ospf_router_id_cmd);
7659 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007660 install_element (OSPF_NODE, &router_ospf_id_cmd);
7661 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007662
7663 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007664 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7665 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7666 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7667 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007668
7669 /* "ospf abr-type" commands. */
7670 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7671 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7672
7673 /* "ospf rfc1583-compatible" commands. */
7674 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7675 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7676 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7677 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7678
7679 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007680 install_element (OSPF_NODE, &ospf_network_area_cmd);
7681 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007682
7683 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007684 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7685 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7686 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007687
7688 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007689 install_element (OSPF_NODE, &ospf_area_range_cmd);
7690 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7691 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7692 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7693 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7694 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7695 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7696 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7697 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7698 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7699 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007700
7701 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007702 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7703 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007704
paula2c62832003-04-23 17:01:31 +00007705 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7706 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007707
paula2c62832003-04-23 17:01:31 +00007708 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7709 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007710
paula2c62832003-04-23 17:01:31 +00007711 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7712 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007713
paula2c62832003-04-23 17:01:31 +00007714 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7715 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007716
paula2c62832003-04-23 17:01:31 +00007717 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7718 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7719 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007720
paula2c62832003-04-23 17:01:31 +00007721 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7722 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007723
paula2c62832003-04-23 17:01:31 +00007724 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7725 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007726
paula2c62832003-04-23 17:01:31 +00007727 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7728 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7729 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007730
paula2c62832003-04-23 17:01:31 +00007731 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7732 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7733 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007734
7735 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007736 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7737 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7738 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7739 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007740
paul718e3742002-12-13 20:15:29 +00007741 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007742 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7743 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7744 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7745 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7746 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7747 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007748
paula2c62832003-04-23 17:01:31 +00007749 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7750 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007751
paula2c62832003-04-23 17:01:31 +00007752 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7753 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007754
paula2c62832003-04-23 17:01:31 +00007755 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7756 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007757
paula2c62832003-04-23 17:01:31 +00007758 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7759 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007760
paula2c62832003-04-23 17:01:31 +00007761 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7762 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007763
paula2c62832003-04-23 17:01:31 +00007764 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7765 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007766
paula2c62832003-04-23 17:01:31 +00007767 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7768 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7769 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007770
paula2c62832003-04-23 17:01:31 +00007771 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7772 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007773
7774 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007775 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7776 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7777 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7778 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7779 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7780 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7781 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7782 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007783
7784 /* Init interface related vty commands. */
7785 ospf_vty_if_init ();
7786
7787 /* Init zebra related vty commands. */
7788 ospf_vty_zebra_init ();
7789}