blob: e3f8f1b2eb79edcae4080f40ccc831130f5545f2 [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
2573void
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{
2577 struct ospf_neighbor *nbr;
2578 int oi_count;
2579 struct route_node *rn;
2580 char buf[9];
2581
2582 oi_count = ospf_oi_count (ifp);
2583
2584 /* Is interface up? */
paul2e3b2e42002-12-13 21:03:13 +00002585 if (if_is_operative (ifp)) {
2586 vty_out (vty, "%s is up%s", ifp->name, VTY_NEWLINE);
2587 } else
2588 {
2589 vty_out (vty, "%s is down%s", ifp->name, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002590
2591
2592 if (oi_count == 0)
2593 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2594 else
2595 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2596 VTY_NEWLINE);
2597 return;
2598 }
2599
2600 /* Is interface OSPF enabled? */
2601 if (oi_count == 0)
2602 {
2603 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2604 return;
2605 }
2606
2607 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2608 {
2609 struct ospf_interface *oi = rn->info;
2610
2611 if (oi == NULL)
2612 continue;
2613
2614 /* Show OSPF interface information. */
2615 vty_out (vty, " Internet Address %s/%d,",
2616 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2617
hasso3fb9cd62004-10-19 19:44:43 +00002618 if (oi->connected->destination)
2619 vty_out (vty, " %s %s,",
2620 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2621 inet_ntoa (oi->connected->destination->u.prefix4));
2622
paul718e3742002-12-13 20:15:29 +00002623 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2624 VTY_NEWLINE);
2625
2626 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002627 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002628 oi->output_cost, VTY_NEWLINE);
2629
2630 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2631 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2632 PRIORITY (oi), VTY_NEWLINE);
2633
2634 /* Show DR information. */
2635 if (DR (oi).s_addr == 0)
2636 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2637 else
2638 {
2639 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2640 if (nbr == NULL)
2641 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2642 else
2643 {
2644 vty_out (vty, " Designated Router (ID) %s,",
2645 inet_ntoa (nbr->router_id));
2646 vty_out (vty, " Interface Address %s%s",
2647 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2648 }
2649 }
2650
2651 /* Show BDR information. */
2652 if (BDR (oi).s_addr == 0)
2653 vty_out (vty, " No backup designated router on this network%s",
2654 VTY_NEWLINE);
2655 else
2656 {
2657 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2658 if (nbr == NULL)
2659 vty_out (vty, " No backup designated router on this network%s",
2660 VTY_NEWLINE);
2661 else
2662 {
2663 vty_out (vty, " Backup Designated Router (ID) %s,",
2664 inet_ntoa (nbr->router_id));
2665 vty_out (vty, " Interface Address %s%s",
2666 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2667 }
2668 }
ajsba6454e2005-02-08 15:37:30 +00002669
2670 vty_out (vty, " Multicast group memberships:");
2671 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2672 vty_out (vty, " OSPFAllRouters");
2673 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2674 vty_out (vty, " OSPFDesignatedRouters");
2675 if (!CHECK_FLAG(oi->multicast_memberships,
2676 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2677 vty_out (vty, " <None>");
2678 vty_out (vty, "%s", VTY_NEWLINE);
2679
paul718e3742002-12-13 20:15:29 +00002680 vty_out (vty, " Timer intervals configured,");
2681 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2682 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2683 OSPF_IF_PARAM (oi, v_wait),
2684 OSPF_IF_PARAM (oi, retransmit_interval),
2685 VTY_NEWLINE);
2686
2687 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2688 vty_out (vty, " Hello due in %s%s",
2689 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2690 else /* OSPF_IF_PASSIVE is set */
2691 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2692
2693 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002694 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002695 VTY_NEWLINE);
2696 }
2697}
2698
2699DEFUN (show_ip_ospf_interface,
2700 show_ip_ospf_interface_cmd,
2701 "show ip ospf interface [INTERFACE]",
2702 SHOW_STR
2703 IP_STR
2704 "OSPF information\n"
2705 "Interface information\n"
2706 "Interface name\n")
2707{
2708 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002709 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002710 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002711
paul020709f2003-04-04 02:44:16 +00002712 ospf = ospf_lookup ();
2713
paul718e3742002-12-13 20:15:29 +00002714 /* Show All Interfaces. */
2715 if (argc == 0)
2716 for (node = listhead (iflist); node; nextnode (node))
paul68980082003-03-25 05:07:42 +00002717 show_ip_ospf_interface_sub (vty, ospf, node->data);
paul718e3742002-12-13 20:15:29 +00002718 /* Interface name is specified. */
2719 else
2720 {
2721 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2722 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2723 else
paul68980082003-03-25 05:07:42 +00002724 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002725 }
2726
2727 return CMD_SUCCESS;
2728}
2729
2730void
2731show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2732{
2733 struct route_node *rn;
2734 struct ospf_neighbor *nbr;
2735 char msgbuf[16];
2736 char timebuf[9];
2737
2738 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2739 if ((nbr = rn->info))
2740 /* Do not show myself. */
2741 if (nbr != oi->nbr_self)
2742 /* Down state is not shown. */
2743 if (nbr->state != NSM_Down)
2744 {
2745 ospf_nbr_state_message (nbr, msgbuf, 16);
2746
2747 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2748 vty_out (vty, "%-15s %3d %-15s %8s ",
2749 "-", nbr->priority,
2750 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2751 else
2752 vty_out (vty, "%-15s %3d %-15s %8s ",
2753 inet_ntoa (nbr->router_id), nbr->priority,
2754 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2755 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2756 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2757 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2758 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2759 VTY_NEWLINE);
2760 }
2761}
2762
2763DEFUN (show_ip_ospf_neighbor,
2764 show_ip_ospf_neighbor_cmd,
2765 "show ip ospf neighbor",
2766 SHOW_STR
2767 IP_STR
2768 "OSPF information\n"
2769 "Neighbor list\n")
2770{
paul020709f2003-04-04 02:44:16 +00002771 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002772 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002773
paul020709f2003-04-04 02:44:16 +00002774 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002775 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002776 {
2777 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2778 return CMD_SUCCESS;
2779 }
2780
2781 /* Show All neighbors. */
2782 vty_out (vty, "%sNeighbor ID Pri State Dead "
2783 "Time Address Interface RXmtL "
2784 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2785
paul68980082003-03-25 05:07:42 +00002786 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul020709f2003-04-04 02:44:16 +00002787 show_ip_ospf_neighbor_sub (vty, getdata (node));
paul718e3742002-12-13 20:15:29 +00002788
2789 return CMD_SUCCESS;
2790}
2791
2792DEFUN (show_ip_ospf_neighbor_all,
2793 show_ip_ospf_neighbor_all_cmd,
2794 "show ip ospf neighbor all",
2795 SHOW_STR
2796 IP_STR
2797 "OSPF information\n"
2798 "Neighbor list\n"
2799 "include down status neighbor\n")
2800{
paul68980082003-03-25 05:07:42 +00002801 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002802 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002803
paul68980082003-03-25 05:07:42 +00002804 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002805 {
2806 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2807 return CMD_SUCCESS;
2808 }
2809
2810 /* Show All neighbors. */
2811 vty_out (vty, "%sNeighbor ID Pri State Dead "
2812 "Time Address Interface RXmtL "
2813 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2814
paul68980082003-03-25 05:07:42 +00002815 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002816 {
2817 struct ospf_interface *oi = getdata (node);
hasso52dc7ee2004-09-23 19:18:23 +00002818 struct listnode *nbr_node;
paul718e3742002-12-13 20:15:29 +00002819
2820 show_ip_ospf_neighbor_sub (vty, oi);
2821
2822 /* print Down neighbor status */
2823 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
2824 {
2825 struct ospf_nbr_nbma *nbr_nbma;
2826
2827 nbr_nbma = getdata (nbr_node);
2828
2829 if (nbr_nbma->nbr == NULL
2830 || nbr_nbma->nbr->state == NSM_Down)
2831 {
2832 vty_out (vty, "%-15s %3d %-15s %8s ",
2833 "-", nbr_nbma->priority, "Down", "-");
2834 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2835 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2836 0, 0, 0, VTY_NEWLINE);
2837 }
2838 }
2839 }
2840
2841 return CMD_SUCCESS;
2842}
2843
2844DEFUN (show_ip_ospf_neighbor_int,
2845 show_ip_ospf_neighbor_int_cmd,
2846 "show ip ospf neighbor A.B.C.D",
2847 SHOW_STR
2848 IP_STR
2849 "OSPF information\n"
2850 "Neighbor list\n"
2851 "Interface name\n")
2852{
paul020709f2003-04-04 02:44:16 +00002853 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002854 struct ospf_interface *oi;
2855 struct in_addr addr;
2856 int ret;
2857
paul718e3742002-12-13 20:15:29 +00002858 ret = inet_aton (argv[0], &addr);
2859 if (!ret)
2860 {
2861 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2862 VTY_NEWLINE);
2863 return CMD_WARNING;
2864 }
2865
paul020709f2003-04-04 02:44:16 +00002866 ospf = ospf_lookup ();
2867 if (ospf == NULL)
2868 {
2869 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2870 return CMD_SUCCESS;
2871 }
2872
paul68980082003-03-25 05:07:42 +00002873 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00002874 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2875 else
2876 {
2877 vty_out (vty, "%sNeighbor ID Pri State Dead "
2878 "Time Address Interface RXmtL "
2879 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2880 show_ip_ospf_neighbor_sub (vty, oi);
2881 }
2882
2883 return CMD_SUCCESS;
2884}
2885
2886void
2887show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2888 struct ospf_nbr_nbma *nbr_nbma)
2889{
2890 char timebuf[9];
2891
2892 /* Show neighbor ID. */
2893 vty_out (vty, " Neighbor %s,", "-");
2894
2895 /* Show interface address. */
2896 vty_out (vty, " interface address %s%s",
2897 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2898 /* Show Area ID. */
2899 vty_out (vty, " In the area %s via interface %s%s",
2900 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2901 /* Show neighbor priority and state. */
2902 vty_out (vty, " Neighbor priority is %d, State is %s,",
2903 nbr_nbma->priority, "Down");
2904 /* Show state changes. */
2905 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2906
2907 /* Show PollInterval */
2908 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2909
2910 /* Show poll-interval timer. */
2911 vty_out (vty, " Poll timer due in %s%s",
2912 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2913
2914 /* Show poll-interval timer thread. */
2915 vty_out (vty, " Thread Poll Timer %s%s",
2916 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2917}
2918
2919void
2920show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2921 struct ospf_neighbor *nbr)
2922{
2923 char timebuf[9];
2924
2925 /* Show neighbor ID. */
2926 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2927 vty_out (vty, " Neighbor %s,", "-");
2928 else
2929 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2930
2931 /* Show interface address. */
2932 vty_out (vty, " interface address %s%s",
2933 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2934 /* Show Area ID. */
2935 vty_out (vty, " In the area %s via interface %s%s",
2936 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2937 /* Show neighbor priority and state. */
2938 vty_out (vty, " Neighbor priority is %d, State is %s,",
2939 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2940 /* Show state changes. */
2941 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2942
2943 /* Show Designated Rotuer ID. */
2944 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2945 /* Show Backup Designated Rotuer ID. */
2946 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2947 /* Show options. */
2948 vty_out (vty, " Options %d %s%s", nbr->options,
2949 ospf_options_dump (nbr->options), VTY_NEWLINE);
2950 /* Show Router Dead interval timer. */
2951 vty_out (vty, " Dead timer due in %s%s",
2952 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2953 /* Show Database Summary list. */
2954 vty_out (vty, " Database Summary List %d%s",
2955 ospf_db_summary_count (nbr), VTY_NEWLINE);
2956 /* Show Link State Request list. */
2957 vty_out (vty, " Link State Request List %ld%s",
2958 ospf_ls_request_count (nbr), VTY_NEWLINE);
2959 /* Show Link State Retransmission list. */
2960 vty_out (vty, " Link State Retransmission List %ld%s",
2961 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2962 /* Show inactivity timer thread. */
2963 vty_out (vty, " Thread Inactivity Timer %s%s",
2964 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2965 /* Show Database Description retransmission thread. */
2966 vty_out (vty, " Thread Database Description Retransmision %s%s",
2967 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2968 /* Show Link State Request Retransmission thread. */
2969 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2970 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2971 /* Show Link State Update Retransmission thread. */
2972 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2973 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2974}
2975
2976DEFUN (show_ip_ospf_neighbor_id,
2977 show_ip_ospf_neighbor_id_cmd,
2978 "show ip ospf neighbor A.B.C.D",
2979 SHOW_STR
2980 IP_STR
2981 "OSPF information\n"
2982 "Neighbor list\n"
2983 "Neighbor ID\n")
2984{
paul020709f2003-04-04 02:44:16 +00002985 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002986 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002987 struct ospf_neighbor *nbr;
2988 struct in_addr router_id;
2989 int ret;
2990
2991 ret = inet_aton (argv[0], &router_id);
2992 if (!ret)
2993 {
2994 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
2995 return CMD_WARNING;
2996 }
2997
paul020709f2003-04-04 02:44:16 +00002998 ospf = ospf_lookup ();
2999 if (ospf == NULL)
3000 {
3001 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3002 return CMD_SUCCESS;
3003 }
3004
paul68980082003-03-25 05:07:42 +00003005 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003006 {
3007 struct ospf_interface *oi = getdata (node);
3008
3009 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3010 {
3011 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3012 return CMD_SUCCESS;
3013 }
3014 }
3015
3016 /* Nothing to show. */
3017 return CMD_SUCCESS;
3018}
3019
3020DEFUN (show_ip_ospf_neighbor_detail,
3021 show_ip_ospf_neighbor_detail_cmd,
3022 "show ip ospf neighbor detail",
3023 SHOW_STR
3024 IP_STR
3025 "OSPF information\n"
3026 "Neighbor list\n"
3027 "detail of all neighbors\n")
3028{
paul020709f2003-04-04 02:44:16 +00003029 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003030 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003031
paul020709f2003-04-04 02:44:16 +00003032 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003033 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003034 {
3035 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3036 return CMD_SUCCESS;
3037 }
paul718e3742002-12-13 20:15:29 +00003038
paul68980082003-03-25 05:07:42 +00003039 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003040 {
3041 struct ospf_interface *oi = getdata (node);
3042 struct route_node *rn;
3043 struct ospf_neighbor *nbr;
3044
3045 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3046 if ((nbr = rn->info))
3047 if (nbr != oi->nbr_self)
3048 if (nbr->state != NSM_Down)
3049 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3050 }
3051
3052 return CMD_SUCCESS;
3053}
3054
3055DEFUN (show_ip_ospf_neighbor_detail_all,
3056 show_ip_ospf_neighbor_detail_all_cmd,
3057 "show ip ospf neighbor detail all",
3058 SHOW_STR
3059 IP_STR
3060 "OSPF information\n"
3061 "Neighbor list\n"
3062 "detail of all neighbors\n"
3063 "include down status neighbor\n")
3064{
paul020709f2003-04-04 02:44:16 +00003065 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003066 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003067
paul020709f2003-04-04 02:44:16 +00003068 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003069 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003070 {
3071 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3072 return CMD_SUCCESS;
3073 }
paul718e3742002-12-13 20:15:29 +00003074
paul68980082003-03-25 05:07:42 +00003075 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003076 {
3077 struct ospf_interface *oi = getdata (node);
3078 struct route_node *rn;
3079 struct ospf_neighbor *nbr;
3080
3081 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3082 if ((nbr = rn->info))
3083 if (nbr != oi->nbr_self)
3084 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3085 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3086
3087 if (oi->type == OSPF_IFTYPE_NBMA)
3088 {
hasso52dc7ee2004-09-23 19:18:23 +00003089 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003090
3091 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
3092 {
3093 struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
3094 if (nbr_nbma->nbr == NULL
3095 || nbr_nbma->nbr->state == NSM_Down)
3096 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3097 }
3098 }
3099 }
3100
3101 return CMD_SUCCESS;
3102}
3103
3104DEFUN (show_ip_ospf_neighbor_int_detail,
3105 show_ip_ospf_neighbor_int_detail_cmd,
3106 "show ip ospf neighbor A.B.C.D detail",
3107 SHOW_STR
3108 IP_STR
3109 "OSPF information\n"
3110 "Neighbor list\n"
3111 "Interface address\n"
3112 "detail of all neighbors")
3113{
paul020709f2003-04-04 02:44:16 +00003114 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003115 struct ospf_interface *oi;
3116 struct in_addr addr;
3117 int ret;
3118
3119 ret = inet_aton (argv[0], &addr);
3120 if (!ret)
3121 {
3122 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3123 VTY_NEWLINE);
3124 return CMD_WARNING;
3125 }
3126
paul020709f2003-04-04 02:44:16 +00003127 ospf = ospf_lookup ();
3128 if (ospf == NULL)
3129 {
3130 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3131 return CMD_SUCCESS;
3132 }
paul68980082003-03-25 05:07:42 +00003133
paul020709f2003-04-04 02:44:16 +00003134 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00003135 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3136 else
3137 {
3138 struct route_node *rn;
3139 struct ospf_neighbor *nbr;
3140
3141 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3142 if ((nbr = rn->info))
3143 if (nbr != oi->nbr_self)
3144 if (nbr->state != NSM_Down)
3145 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3146 }
3147
3148 return CMD_SUCCESS;
3149}
3150
3151
3152/* Show functions */
3153int
paul020709f2003-04-04 02:44:16 +00003154show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003155{
paul718e3742002-12-13 20:15:29 +00003156 struct router_lsa *rl;
3157 struct summary_lsa *sl;
3158 struct as_external_lsa *asel;
3159 struct prefix_ipv4 p;
3160
3161 if (lsa != NULL)
3162 /* If self option is set, check LSA self flag. */
3163 if (self == 0 || IS_LSA_SELF (lsa))
3164 {
3165 /* LSA common part show. */
3166 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3167 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3168 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3169 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3170 /* LSA specific part show. */
3171 switch (lsa->data->type)
3172 {
3173 case OSPF_ROUTER_LSA:
3174 rl = (struct router_lsa *) lsa->data;
3175 vty_out (vty, " %-d", ntohs (rl->links));
3176 break;
3177 case OSPF_SUMMARY_LSA:
3178 sl = (struct summary_lsa *) lsa->data;
3179
3180 p.family = AF_INET;
3181 p.prefix = sl->header.id;
3182 p.prefixlen = ip_masklen (sl->mask);
3183 apply_mask_ipv4 (&p);
3184
3185 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3186 break;
3187 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003188 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003189 asel = (struct as_external_lsa *) lsa->data;
3190
3191 p.family = AF_INET;
3192 p.prefix = asel->header.id;
3193 p.prefixlen = ip_masklen (asel->mask);
3194 apply_mask_ipv4 (&p);
3195
3196 vty_out (vty, " %s %s/%d [0x%lx]",
3197 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3198 inet_ntoa (p.prefix), p.prefixlen,
3199 (u_long)ntohl (asel->e[0].route_tag));
3200 break;
3201 case OSPF_NETWORK_LSA:
3202 case OSPF_ASBR_SUMMARY_LSA:
3203#ifdef HAVE_OPAQUE_LSA
3204 case OSPF_OPAQUE_LINK_LSA:
3205 case OSPF_OPAQUE_AREA_LSA:
3206 case OSPF_OPAQUE_AS_LSA:
3207#endif /* HAVE_OPAQUE_LSA */
3208 default:
3209 break;
3210 }
3211 vty_out (vty, VTY_NEWLINE);
3212 }
3213
3214 return 0;
3215}
3216
hassoeb1ce602004-10-08 08:17:22 +00003217const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003218{
3219 "unknown",
3220 "Router Link States",
3221 "Net Link States",
3222 "Summary Link States",
3223 "ASBR-Summary Link States",
3224 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003225 "Group Membership LSA",
3226 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003227#ifdef HAVE_OPAQUE_LSA
3228 "Type-8 LSA",
3229 "Link-Local Opaque-LSA",
3230 "Area-Local Opaque-LSA",
3231 "AS-external Opaque-LSA",
3232#endif /* HAVE_OPAQUE_LSA */
3233};
3234
3235#define SHOW_OSPF_COMMON_HEADER \
3236 "Link ID ADV Router Age Seq# CkSum"
3237
hassoeb1ce602004-10-08 08:17:22 +00003238const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003239{
3240 "",
3241 "Link ID ADV Router Age Seq# CkSum Link count",
3242 "Link ID ADV Router Age Seq# CkSum",
3243 "Link ID ADV Router Age Seq# CkSum Route",
3244 "Link ID ADV Router Age Seq# CkSum",
3245 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003246 " --- header for Group Member ----",
3247 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003248#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003249 " --- type-8 ---",
3250 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3251 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3252 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3253#endif /* HAVE_OPAQUE_LSA */
3254};
3255
hassoeb1ce602004-10-08 08:17:22 +00003256const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003257{
3258 "Self-originated",
3259 "Checked",
3260 "Received",
3261 "Approved",
3262 "Discard",
paul4957f492003-06-27 01:28:45 +00003263 "Translated",
paul4957f492003-06-27 01:28:45 +00003264};
3265
paul718e3742002-12-13 20:15:29 +00003266void
3267show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3268{
3269 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003270
paul718e3742002-12-13 20:15:29 +00003271 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003272 vty_out (vty, " Options: 0x%-2x : %s%s",
3273 lsa->data->options,
3274 ospf_options_dump(lsa->data->options),
3275 VTY_NEWLINE);
3276 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003277 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003278 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3279 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003280
3281 if (lsa->data->type == OSPF_ROUTER_LSA)
3282 {
3283 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3284
3285 if (rlsa->flags)
3286 vty_out (vty, " :%s%s%s%s",
3287 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3288 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3289 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3290 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3291
3292 vty_out (vty, "%s", VTY_NEWLINE);
3293 }
3294 vty_out (vty, " LS Type: %s%s",
3295 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3296 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3297 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3298 vty_out (vty, " Advertising Router: %s%s",
3299 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3300 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3301 VTY_NEWLINE);
3302 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3303 VTY_NEWLINE);
3304 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3305}
3306
hassoeb1ce602004-10-08 08:17:22 +00003307const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003308{
3309 "(null)",
3310 "another Router (point-to-point)",
3311 "a Transit Network",
3312 "Stub Network",
3313 "a Virtual Link",
3314};
3315
hassoeb1ce602004-10-08 08:17:22 +00003316const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003317{
3318 "(null)",
3319 "Neighboring Router ID",
3320 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003321 "Net",
paul718e3742002-12-13 20:15:29 +00003322 "Neighboring Router ID",
3323};
3324
hassoeb1ce602004-10-08 08:17:22 +00003325const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003326{
3327 "(null)",
3328 "Router Interface address",
3329 "Router Interface address",
3330 "Network Mask",
3331 "Router Interface address",
3332};
3333
3334/* Show router-LSA each Link information. */
3335void
3336show_ip_ospf_database_router_links (struct vty *vty,
3337 struct router_lsa *rl)
3338{
3339 int len, i, type;
3340
3341 len = ntohs (rl->header.length) - 4;
3342 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3343 {
3344 type = rl->link[i].type;
3345
3346 vty_out (vty, " Link connected to: %s%s",
3347 link_type_desc[type], VTY_NEWLINE);
3348 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3349 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3350 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3351 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3352 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3353 vty_out (vty, " TOS 0 Metric: %d%s",
3354 ntohs (rl->link[i].metric), VTY_NEWLINE);
3355 vty_out (vty, "%s", VTY_NEWLINE);
3356 }
3357}
3358
3359/* Show router-LSA detail information. */
3360int
3361show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3362{
3363 if (lsa != NULL)
3364 {
3365 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3366
3367 show_ip_ospf_database_header (vty, lsa);
3368
3369 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3370 VTY_NEWLINE, VTY_NEWLINE);
3371
3372 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003373 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003374 }
3375
3376 return 0;
3377}
3378
3379/* Show network-LSA detail information. */
3380int
3381show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3382{
3383 int length, i;
3384
3385 if (lsa != NULL)
3386 {
3387 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3388
3389 show_ip_ospf_database_header (vty, lsa);
3390
3391 vty_out (vty, " Network Mask: /%d%s",
3392 ip_masklen (nl->mask), VTY_NEWLINE);
3393
3394 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3395
3396 for (i = 0; length > 0; i++, length -= 4)
3397 vty_out (vty, " Attached Router: %s%s",
3398 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3399
3400 vty_out (vty, "%s", VTY_NEWLINE);
3401 }
3402
3403 return 0;
3404}
3405
3406/* Show summary-LSA detail information. */
3407int
3408show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3409{
3410 if (lsa != NULL)
3411 {
3412 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3413
3414 show_ip_ospf_database_header (vty, lsa);
3415
3416 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3417 VTY_NEWLINE);
3418 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3419 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003420 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003421 }
3422
3423 return 0;
3424}
3425
3426/* Show summary-ASBR-LSA detail information. */
3427int
3428show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3429{
3430 if (lsa != NULL)
3431 {
3432 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3433
3434 show_ip_ospf_database_header (vty, lsa);
3435
3436 vty_out (vty, " Network Mask: /%d%s",
3437 ip_masklen (sl->mask), VTY_NEWLINE);
3438 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3439 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003440 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003441 }
3442
3443 return 0;
3444}
3445
3446/* Show AS-external-LSA detail information. */
3447int
3448show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3449{
3450 if (lsa != NULL)
3451 {
3452 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3453
3454 show_ip_ospf_database_header (vty, lsa);
3455
3456 vty_out (vty, " Network Mask: /%d%s",
3457 ip_masklen (al->mask), VTY_NEWLINE);
3458 vty_out (vty, " Metric Type: %s%s",
3459 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3460 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3461 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3462 vty_out (vty, " Metric: %d%s",
3463 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3464 vty_out (vty, " Forward Address: %s%s",
3465 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3466
3467 vty_out (vty, " External Route Tag: %lu%s%s",
3468 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3469 }
3470
3471 return 0;
3472}
3473
ajs2a42e282004-12-08 18:43:03 +00003474/* N.B. This function currently seems to be unused. */
paul718e3742002-12-13 20:15:29 +00003475int
3476show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3477{
3478 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3479
3480 /* show_ip_ospf_database_header (vty, lsa); */
3481
ajs2a42e282004-12-08 18:43:03 +00003482 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003483 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003484 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003485 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3486 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003487 zlog_debug( " TOS: 0%s", "\n");
3488 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003489 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003490 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003491 inet_ntoa (al->e[0].fwd_addr), "\n");
3492
ajs2a42e282004-12-08 18:43:03 +00003493 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003494 ntohl (al->e[0].route_tag), "\n", "\n");
3495
3496 return 0;
3497}
3498
3499/* Show AS-NSSA-LSA detail information. */
3500int
3501show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3502{
3503 if (lsa != NULL)
3504 {
3505 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3506
3507 show_ip_ospf_database_header (vty, lsa);
3508
3509 vty_out (vty, " Network Mask: /%d%s",
3510 ip_masklen (al->mask), VTY_NEWLINE);
3511 vty_out (vty, " Metric Type: %s%s",
3512 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3513 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3514 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3515 vty_out (vty, " Metric: %d%s",
3516 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3517 vty_out (vty, " NSSA: Forward Address: %s%s",
3518 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3519
3520 vty_out (vty, " External Route Tag: %u%s%s",
3521 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3522 }
3523
3524 return 0;
3525}
3526
paul718e3742002-12-13 20:15:29 +00003527int
3528show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3529{
3530 return 0;
3531}
3532
3533#ifdef HAVE_OPAQUE_LSA
3534int
3535show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3536{
3537 if (lsa != NULL)
3538 {
3539 show_ip_ospf_database_header (vty, lsa);
3540 show_opaque_info_detail (vty, lsa);
3541
3542 vty_out (vty, "%s", VTY_NEWLINE);
3543 }
3544 return 0;
3545}
3546#endif /* HAVE_OPAQUE_LSA */
3547
3548int (*show_function[])(struct vty *, struct ospf_lsa *) =
3549{
3550 NULL,
3551 show_router_lsa_detail,
3552 show_network_lsa_detail,
3553 show_summary_lsa_detail,
3554 show_summary_asbr_lsa_detail,
3555 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003556 show_func_dummy,
3557 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003558#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003559 NULL, /* type-8 */
3560 show_opaque_lsa_detail,
3561 show_opaque_lsa_detail,
3562 show_opaque_lsa_detail,
3563#endif /* HAVE_OPAQUE_LSA */
3564};
3565
3566void
3567show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3568 struct in_addr *adv_router)
3569{
3570 memset (lp, 0, sizeof (struct prefix_ls));
3571 lp->family = 0;
3572 if (id == NULL)
3573 lp->prefixlen = 0;
3574 else if (adv_router == NULL)
3575 {
3576 lp->prefixlen = 32;
3577 lp->id = *id;
3578 }
3579 else
3580 {
3581 lp->prefixlen = 64;
3582 lp->id = *id;
3583 lp->adv_router = *adv_router;
3584 }
3585}
3586
3587void
3588show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3589 struct in_addr *id, struct in_addr *adv_router)
3590{
3591 struct prefix_ls lp;
3592 struct route_node *rn, *start;
3593 struct ospf_lsa *lsa;
3594
3595 show_lsa_prefix_set (vty, &lp, id, adv_router);
3596 start = route_node_get (rt, (struct prefix *) &lp);
3597 if (start)
3598 {
3599 route_lock_node (start);
3600 for (rn = start; rn; rn = route_next_until (rn, start))
3601 if ((lsa = rn->info))
3602 {
paul718e3742002-12-13 20:15:29 +00003603 if (show_function[lsa->data->type] != NULL)
3604 show_function[lsa->data->type] (vty, lsa);
3605 }
3606 route_unlock_node (start);
3607 }
3608}
3609
3610/* Show detail LSA information
3611 -- if id is NULL then show all LSAs. */
3612void
paul020709f2003-04-04 02:44:16 +00003613show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003614 struct in_addr *id, struct in_addr *adv_router)
3615{
hasso52dc7ee2004-09-23 19:18:23 +00003616 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003617
3618 switch (type)
3619 {
3620 case OSPF_AS_EXTERNAL_LSA:
3621#ifdef HAVE_OPAQUE_LSA
3622 case OSPF_OPAQUE_AS_LSA:
3623#endif /* HAVE_OPAQUE_LSA */
3624 vty_out (vty, " %s %s%s",
3625 show_database_desc[type],
3626 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003627 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003628 break;
3629 default:
paul68980082003-03-25 05:07:42 +00003630 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003631 {
3632 struct ospf_area *area = node->data;
3633 vty_out (vty, "%s %s (Area %s)%s%s",
3634 VTY_NEWLINE, show_database_desc[type],
3635 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3636 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3637 }
3638 break;
3639 }
3640}
3641
3642void
3643show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3644 struct in_addr *adv_router)
3645{
3646 struct route_node *rn;
3647 struct ospf_lsa *lsa;
3648
3649 for (rn = route_top (rt); rn; rn = route_next (rn))
3650 if ((lsa = rn->info))
3651 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3652 {
paul718e3742002-12-13 20:15:29 +00003653 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3654 continue;
paul718e3742002-12-13 20:15:29 +00003655 if (show_function[lsa->data->type] != NULL)
3656 show_function[lsa->data->type] (vty, lsa);
3657 }
3658}
3659
3660/* Show detail LSA information. */
3661void
paul020709f2003-04-04 02:44:16 +00003662show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003663 struct in_addr *adv_router)
3664{
hasso52dc7ee2004-09-23 19:18:23 +00003665 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003666
3667 switch (type)
3668 {
3669 case OSPF_AS_EXTERNAL_LSA:
3670#ifdef HAVE_OPAQUE_LSA
3671 case OSPF_OPAQUE_AS_LSA:
3672#endif /* HAVE_OPAQUE_LSA */
3673 vty_out (vty, " %s %s%s",
3674 show_database_desc[type],
3675 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003676 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003677 adv_router);
3678 break;
3679 default:
paul68980082003-03-25 05:07:42 +00003680 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003681 {
3682 struct ospf_area *area = node->data;
3683 vty_out (vty, "%s %s (Area %s)%s%s",
3684 VTY_NEWLINE, show_database_desc[type],
3685 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3686 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3687 adv_router);
3688 }
3689 break;
3690 }
3691}
3692
3693void
paul020709f2003-04-04 02:44:16 +00003694show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003695{
paul020709f2003-04-04 02:44:16 +00003696 struct ospf_lsa *lsa;
3697 struct route_node *rn;
hasso52dc7ee2004-09-23 19:18:23 +00003698 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003699 int type;
3700
paul68980082003-03-25 05:07:42 +00003701 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003702 {
3703 struct ospf_area *area = node->data;
3704 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3705 {
3706 switch (type)
3707 {
3708 case OSPF_AS_EXTERNAL_LSA:
3709#ifdef HAVE_OPAQUE_LSA
3710 case OSPF_OPAQUE_AS_LSA:
3711#endif /* HAVE_OPAQUE_LSA */
3712 continue;
3713 default:
3714 break;
3715 }
3716 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3717 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3718 {
3719 vty_out (vty, " %s (Area %s)%s%s",
3720 show_database_desc[type],
3721 ospf_area_desc_string (area),
3722 VTY_NEWLINE, VTY_NEWLINE);
3723 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3724
paul020709f2003-04-04 02:44:16 +00003725 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3726 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003727
3728 vty_out (vty, "%s", VTY_NEWLINE);
3729 }
3730 }
3731 }
3732
3733 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3734 {
3735 switch (type)
3736 {
3737 case OSPF_AS_EXTERNAL_LSA:
3738#ifdef HAVE_OPAQUE_LSA
3739 case OSPF_OPAQUE_AS_LSA:
3740#endif /* HAVE_OPAQUE_LSA */
3741 break;;
3742 default:
3743 continue;
3744 }
paul68980082003-03-25 05:07:42 +00003745 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3746 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003747 {
3748 vty_out (vty, " %s%s%s",
3749 show_database_desc[type],
3750 VTY_NEWLINE, VTY_NEWLINE);
3751 vty_out (vty, "%s%s", show_database_header[type],
3752 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003753
3754 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3755 show_lsa_summary (vty, lsa, self);
3756
paul718e3742002-12-13 20:15:29 +00003757 vty_out (vty, "%s", VTY_NEWLINE);
3758 }
3759 }
3760
3761 vty_out (vty, "%s", VTY_NEWLINE);
3762}
3763
3764void
paul020709f2003-04-04 02:44:16 +00003765show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003766{
hasso52dc7ee2004-09-23 19:18:23 +00003767 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003768 struct ospf_lsa *lsa;
3769
3770 vty_out (vty, "%s MaxAge Link States:%s%s",
3771 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3772
paul68980082003-03-25 05:07:42 +00003773 for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003774 if ((lsa = node->data) != NULL)
3775 {
3776 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3777 vty_out (vty, "Link State ID: %s%s",
3778 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3779 vty_out (vty, "Advertising Router: %s%s",
3780 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3781 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3782 vty_out (vty, "%s", VTY_NEWLINE);
3783 }
3784}
3785
paul718e3742002-12-13 20:15:29 +00003786#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3787#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003788
3789#ifdef HAVE_OPAQUE_LSA
3790#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3791#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3792#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3793#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3794#else /* HAVE_OPAQUE_LSA */
3795#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3796#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3797#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3798#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3799#endif /* HAVE_OPAQUE_LSA */
3800
3801#define OSPF_LSA_TYPES_CMD_STR \
3802 "asbr-summary|external|network|router|summary" \
3803 OSPF_LSA_TYPE_NSSA_CMD_STR \
3804 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3805
3806#define OSPF_LSA_TYPES_DESC \
3807 "ASBR summary link states\n" \
3808 "External link states\n" \
3809 "Network link states\n" \
3810 "Router link states\n" \
3811 "Network summary link states\n" \
3812 OSPF_LSA_TYPE_NSSA_DESC \
3813 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3814 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3815 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3816
3817DEFUN (show_ip_ospf_database,
3818 show_ip_ospf_database_cmd,
3819 "show ip ospf database",
3820 SHOW_STR
3821 IP_STR
3822 "OSPF information\n"
3823 "Database summary\n")
3824{
paul020709f2003-04-04 02:44:16 +00003825 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003826 int type, ret;
3827 struct in_addr id, adv_router;
3828
paul020709f2003-04-04 02:44:16 +00003829 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003830 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003831 return CMD_SUCCESS;
3832
3833 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003834 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003835
3836 /* Show all LSA. */
3837 if (argc == 0)
3838 {
paul020709f2003-04-04 02:44:16 +00003839 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003840 return CMD_SUCCESS;
3841 }
3842
3843 /* Set database type to show. */
3844 if (strncmp (argv[0], "r", 1) == 0)
3845 type = OSPF_ROUTER_LSA;
3846 else if (strncmp (argv[0], "ne", 2) == 0)
3847 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003848 else if (strncmp (argv[0], "ns", 2) == 0)
3849 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003850 else if (strncmp (argv[0], "su", 2) == 0)
3851 type = OSPF_SUMMARY_LSA;
3852 else if (strncmp (argv[0], "a", 1) == 0)
3853 type = OSPF_ASBR_SUMMARY_LSA;
3854 else if (strncmp (argv[0], "e", 1) == 0)
3855 type = OSPF_AS_EXTERNAL_LSA;
3856 else if (strncmp (argv[0], "se", 2) == 0)
3857 {
paul020709f2003-04-04 02:44:16 +00003858 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003859 return CMD_SUCCESS;
3860 }
3861 else if (strncmp (argv[0], "m", 1) == 0)
3862 {
paul020709f2003-04-04 02:44:16 +00003863 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003864 return CMD_SUCCESS;
3865 }
3866#ifdef HAVE_OPAQUE_LSA
3867 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3868 type = OSPF_OPAQUE_LINK_LSA;
3869 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3870 type = OSPF_OPAQUE_AREA_LSA;
3871 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3872 type = OSPF_OPAQUE_AS_LSA;
3873#endif /* HAVE_OPAQUE_LSA */
3874 else
3875 return CMD_WARNING;
3876
3877 /* `show ip ospf database LSA'. */
3878 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003879 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003880 else if (argc >= 2)
3881 {
3882 ret = inet_aton (argv[1], &id);
3883 if (!ret)
3884 return CMD_WARNING;
3885
3886 /* `show ip ospf database LSA ID'. */
3887 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003888 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003889 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3890 else if (argc == 3)
3891 {
3892 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003893 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003894 else
3895 {
3896 ret = inet_aton (argv[2], &adv_router);
3897 if (!ret)
3898 return CMD_WARNING;
3899 }
paul020709f2003-04-04 02:44:16 +00003900 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003901 }
3902 }
3903
3904 return CMD_SUCCESS;
3905}
3906
3907ALIAS (show_ip_ospf_database,
3908 show_ip_ospf_database_type_cmd,
3909 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3910 SHOW_STR
3911 IP_STR
3912 "OSPF information\n"
3913 "Database summary\n"
3914 OSPF_LSA_TYPES_DESC
3915 "LSAs in MaxAge list\n"
3916 "Self-originated link states\n")
3917
3918ALIAS (show_ip_ospf_database,
3919 show_ip_ospf_database_type_id_cmd,
3920 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3921 SHOW_STR
3922 IP_STR
3923 "OSPF information\n"
3924 "Database summary\n"
3925 OSPF_LSA_TYPES_DESC
3926 "Link State ID (as an IP address)\n")
3927
3928ALIAS (show_ip_ospf_database,
3929 show_ip_ospf_database_type_id_adv_router_cmd,
3930 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3931 SHOW_STR
3932 IP_STR
3933 "OSPF information\n"
3934 "Database summary\n"
3935 OSPF_LSA_TYPES_DESC
3936 "Link State ID (as an IP address)\n"
3937 "Advertising Router link states\n"
3938 "Advertising Router (as an IP address)\n")
3939
3940ALIAS (show_ip_ospf_database,
3941 show_ip_ospf_database_type_id_self_cmd,
3942 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3943 SHOW_STR
3944 IP_STR
3945 "OSPF information\n"
3946 "Database summary\n"
3947 OSPF_LSA_TYPES_DESC
3948 "Link State ID (as an IP address)\n"
3949 "Self-originated link states\n"
3950 "\n")
3951
3952DEFUN (show_ip_ospf_database_type_adv_router,
3953 show_ip_ospf_database_type_adv_router_cmd,
3954 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3955 SHOW_STR
3956 IP_STR
3957 "OSPF information\n"
3958 "Database summary\n"
3959 OSPF_LSA_TYPES_DESC
3960 "Advertising Router link states\n"
3961 "Advertising Router (as an IP address)\n")
3962{
paul020709f2003-04-04 02:44:16 +00003963 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003964 int type, ret;
3965 struct in_addr adv_router;
3966
paul020709f2003-04-04 02:44:16 +00003967 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003968 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003969 return CMD_SUCCESS;
3970
3971 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003972 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003973
3974 if (argc != 2)
3975 return CMD_WARNING;
3976
3977 /* Set database type to show. */
3978 if (strncmp (argv[0], "r", 1) == 0)
3979 type = OSPF_ROUTER_LSA;
3980 else if (strncmp (argv[0], "ne", 2) == 0)
3981 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003982 else if (strncmp (argv[0], "ns", 2) == 0)
3983 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003984 else if (strncmp (argv[0], "s", 1) == 0)
3985 type = OSPF_SUMMARY_LSA;
3986 else if (strncmp (argv[0], "a", 1) == 0)
3987 type = OSPF_ASBR_SUMMARY_LSA;
3988 else if (strncmp (argv[0], "e", 1) == 0)
3989 type = OSPF_AS_EXTERNAL_LSA;
3990#ifdef HAVE_OPAQUE_LSA
3991 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3992 type = OSPF_OPAQUE_LINK_LSA;
3993 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3994 type = OSPF_OPAQUE_AREA_LSA;
3995 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3996 type = OSPF_OPAQUE_AS_LSA;
3997#endif /* HAVE_OPAQUE_LSA */
3998 else
3999 return CMD_WARNING;
4000
4001 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4002 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004003 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004004 else
4005 {
4006 ret = inet_aton (argv[1], &adv_router);
4007 if (!ret)
4008 return CMD_WARNING;
4009 }
4010
paul020709f2003-04-04 02:44:16 +00004011 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004012
4013 return CMD_SUCCESS;
4014}
4015
4016ALIAS (show_ip_ospf_database_type_adv_router,
4017 show_ip_ospf_database_type_self_cmd,
4018 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4019 SHOW_STR
4020 IP_STR
4021 "OSPF information\n"
4022 "Database summary\n"
4023 OSPF_LSA_TYPES_DESC
4024 "Self-originated link states\n")
4025
4026
4027DEFUN (ip_ospf_authentication_args,
4028 ip_ospf_authentication_args_addr_cmd,
4029 "ip ospf authentication (null|message-digest) A.B.C.D",
4030 "IP Information\n"
4031 "OSPF interface commands\n"
4032 "Enable authentication on this interface\n"
4033 "Use null authentication\n"
4034 "Use message-digest authentication\n"
4035 "Address of interface")
4036{
4037 struct interface *ifp;
4038 struct in_addr addr;
4039 int ret;
4040 struct ospf_if_params *params;
4041
4042 ifp = vty->index;
4043 params = IF_DEF_PARAMS (ifp);
4044
4045 if (argc == 2)
4046 {
4047 ret = inet_aton(argv[1], &addr);
4048 if (!ret)
4049 {
4050 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4051 VTY_NEWLINE);
4052 return CMD_WARNING;
4053 }
4054
4055 params = ospf_get_if_params (ifp, addr);
4056 ospf_if_update_params (ifp, addr);
4057 }
4058
4059 /* Handle null authentication */
4060 if ( argv[0][0] == 'n' )
4061 {
4062 SET_IF_PARAM (params, auth_type);
4063 params->auth_type = OSPF_AUTH_NULL;
4064 return CMD_SUCCESS;
4065 }
4066
4067 /* Handle message-digest authentication */
4068 if ( argv[0][0] == 'm' )
4069 {
4070 SET_IF_PARAM (params, auth_type);
4071 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4072 return CMD_SUCCESS;
4073 }
4074
4075 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4076 return CMD_WARNING;
4077}
4078
4079ALIAS (ip_ospf_authentication_args,
4080 ip_ospf_authentication_args_cmd,
4081 "ip ospf authentication (null|message-digest)",
4082 "IP Information\n"
4083 "OSPF interface commands\n"
4084 "Enable authentication on this interface\n"
4085 "Use null authentication\n"
4086 "Use message-digest authentication\n")
4087
4088DEFUN (ip_ospf_authentication,
4089 ip_ospf_authentication_addr_cmd,
4090 "ip ospf authentication A.B.C.D",
4091 "IP Information\n"
4092 "OSPF interface commands\n"
4093 "Enable authentication on this interface\n"
4094 "Address of interface")
4095{
4096 struct interface *ifp;
4097 struct in_addr addr;
4098 int ret;
4099 struct ospf_if_params *params;
4100
4101 ifp = vty->index;
4102 params = IF_DEF_PARAMS (ifp);
4103
4104 if (argc == 1)
4105 {
4106 ret = inet_aton(argv[1], &addr);
4107 if (!ret)
4108 {
4109 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4110 VTY_NEWLINE);
4111 return CMD_WARNING;
4112 }
4113
4114 params = ospf_get_if_params (ifp, addr);
4115 ospf_if_update_params (ifp, addr);
4116 }
4117
4118 SET_IF_PARAM (params, auth_type);
4119 params->auth_type = OSPF_AUTH_SIMPLE;
4120
4121 return CMD_SUCCESS;
4122}
4123
4124ALIAS (ip_ospf_authentication,
4125 ip_ospf_authentication_cmd,
4126 "ip ospf authentication",
4127 "IP Information\n"
4128 "OSPF interface commands\n"
4129 "Enable authentication on this interface\n")
4130
4131DEFUN (no_ip_ospf_authentication,
4132 no_ip_ospf_authentication_addr_cmd,
4133 "no ip ospf authentication A.B.C.D",
4134 NO_STR
4135 "IP Information\n"
4136 "OSPF interface commands\n"
4137 "Enable authentication on this interface\n"
4138 "Address of interface")
4139{
4140 struct interface *ifp;
4141 struct in_addr addr;
4142 int ret;
4143 struct ospf_if_params *params;
4144
4145 ifp = vty->index;
4146 params = IF_DEF_PARAMS (ifp);
4147
4148 if (argc == 1)
4149 {
4150 ret = inet_aton(argv[1], &addr);
4151 if (!ret)
4152 {
4153 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4154 VTY_NEWLINE);
4155 return CMD_WARNING;
4156 }
4157
4158 params = ospf_lookup_if_params (ifp, addr);
4159 if (params == NULL)
4160 return CMD_SUCCESS;
4161 }
4162
4163 params->auth_type = OSPF_AUTH_NOTSET;
4164 UNSET_IF_PARAM (params, auth_type);
4165
4166 if (params != IF_DEF_PARAMS (ifp))
4167 {
4168 ospf_free_if_params (ifp, addr);
4169 ospf_if_update_params (ifp, addr);
4170 }
4171
4172 return CMD_SUCCESS;
4173}
4174
4175ALIAS (no_ip_ospf_authentication,
4176 no_ip_ospf_authentication_cmd,
4177 "no ip ospf authentication",
4178 NO_STR
4179 "IP Information\n"
4180 "OSPF interface commands\n"
4181 "Enable authentication on this interface\n")
4182
4183DEFUN (ip_ospf_authentication_key,
4184 ip_ospf_authentication_key_addr_cmd,
4185 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4186 "IP Information\n"
4187 "OSPF interface commands\n"
4188 "Authentication password (key)\n"
4189 "The OSPF password (key)\n"
4190 "Address of interface")
4191{
4192 struct interface *ifp;
4193 struct in_addr addr;
4194 int ret;
4195 struct ospf_if_params *params;
4196
4197 ifp = vty->index;
4198 params = IF_DEF_PARAMS (ifp);
4199
4200 if (argc == 2)
4201 {
4202 ret = inet_aton(argv[1], &addr);
4203 if (!ret)
4204 {
4205 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4206 VTY_NEWLINE);
4207 return CMD_WARNING;
4208 }
4209
4210 params = ospf_get_if_params (ifp, addr);
4211 ospf_if_update_params (ifp, addr);
4212 }
4213
4214
4215 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004216 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004217 SET_IF_PARAM (params, auth_simple);
4218
4219 return CMD_SUCCESS;
4220}
4221
4222ALIAS (ip_ospf_authentication_key,
4223 ip_ospf_authentication_key_cmd,
4224 "ip ospf authentication-key AUTH_KEY",
4225 "IP Information\n"
4226 "OSPF interface commands\n"
4227 "Authentication password (key)\n"
4228 "The OSPF password (key)")
4229
4230ALIAS (ip_ospf_authentication_key,
4231 ospf_authentication_key_cmd,
4232 "ospf authentication-key AUTH_KEY",
4233 "OSPF interface commands\n"
4234 "Authentication password (key)\n"
4235 "The OSPF password (key)")
4236
4237DEFUN (no_ip_ospf_authentication_key,
4238 no_ip_ospf_authentication_key_addr_cmd,
4239 "no ip ospf authentication-key A.B.C.D",
4240 NO_STR
4241 "IP Information\n"
4242 "OSPF interface commands\n"
4243 "Authentication password (key)\n"
4244 "Address of interface")
4245{
4246 struct interface *ifp;
4247 struct in_addr addr;
4248 int ret;
4249 struct ospf_if_params *params;
4250
4251 ifp = vty->index;
4252 params = IF_DEF_PARAMS (ifp);
4253
4254 if (argc == 2)
4255 {
4256 ret = inet_aton(argv[1], &addr);
4257 if (!ret)
4258 {
4259 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4260 VTY_NEWLINE);
4261 return CMD_WARNING;
4262 }
4263
4264 params = ospf_lookup_if_params (ifp, addr);
4265 if (params == NULL)
4266 return CMD_SUCCESS;
4267 }
4268
4269 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4270 UNSET_IF_PARAM (params, auth_simple);
4271
4272 if (params != IF_DEF_PARAMS (ifp))
4273 {
4274 ospf_free_if_params (ifp, addr);
4275 ospf_if_update_params (ifp, addr);
4276 }
4277
4278 return CMD_SUCCESS;
4279}
4280
4281ALIAS (no_ip_ospf_authentication_key,
4282 no_ip_ospf_authentication_key_cmd,
4283 "no ip ospf authentication-key",
4284 NO_STR
4285 "IP Information\n"
4286 "OSPF interface commands\n"
4287 "Authentication password (key)\n")
4288
4289ALIAS (no_ip_ospf_authentication_key,
4290 no_ospf_authentication_key_cmd,
4291 "no ospf authentication-key",
4292 NO_STR
4293 "OSPF interface commands\n"
4294 "Authentication password (key)\n")
4295
4296DEFUN (ip_ospf_message_digest_key,
4297 ip_ospf_message_digest_key_addr_cmd,
4298 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4299 "IP Information\n"
4300 "OSPF interface commands\n"
4301 "Message digest authentication password (key)\n"
4302 "Key ID\n"
4303 "Use MD5 algorithm\n"
4304 "The OSPF password (key)"
4305 "Address of interface")
4306{
4307 struct interface *ifp;
4308 struct crypt_key *ck;
4309 u_char key_id;
4310 struct in_addr addr;
4311 int ret;
4312 struct ospf_if_params *params;
4313
4314 ifp = vty->index;
4315 params = IF_DEF_PARAMS (ifp);
4316
4317 if (argc == 3)
4318 {
4319 ret = inet_aton(argv[2], &addr);
4320 if (!ret)
4321 {
4322 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4323 VTY_NEWLINE);
4324 return CMD_WARNING;
4325 }
4326
4327 params = ospf_get_if_params (ifp, addr);
4328 ospf_if_update_params (ifp, addr);
4329 }
4330
4331 key_id = strtol (argv[0], NULL, 10);
4332 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4333 {
4334 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4335 return CMD_WARNING;
4336 }
4337
4338 ck = ospf_crypt_key_new ();
4339 ck->key_id = (u_char) key_id;
4340 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004341 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004342
4343 ospf_crypt_key_add (params->auth_crypt, ck);
4344 SET_IF_PARAM (params, auth_crypt);
4345
4346 return CMD_SUCCESS;
4347}
4348
4349ALIAS (ip_ospf_message_digest_key,
4350 ip_ospf_message_digest_key_cmd,
4351 "ip ospf message-digest-key <1-255> md5 KEY",
4352 "IP Information\n"
4353 "OSPF interface commands\n"
4354 "Message digest authentication password (key)\n"
4355 "Key ID\n"
4356 "Use MD5 algorithm\n"
4357 "The OSPF password (key)")
4358
4359ALIAS (ip_ospf_message_digest_key,
4360 ospf_message_digest_key_cmd,
4361 "ospf message-digest-key <1-255> md5 KEY",
4362 "OSPF interface commands\n"
4363 "Message digest authentication password (key)\n"
4364 "Key ID\n"
4365 "Use MD5 algorithm\n"
4366 "The OSPF password (key)")
4367
4368DEFUN (no_ip_ospf_message_digest_key,
4369 no_ip_ospf_message_digest_key_addr_cmd,
4370 "no ip ospf message-digest-key <1-255> A.B.C.D",
4371 NO_STR
4372 "IP Information\n"
4373 "OSPF interface commands\n"
4374 "Message digest authentication password (key)\n"
4375 "Key ID\n"
4376 "Address of interface")
4377{
4378 struct interface *ifp;
4379 struct crypt_key *ck;
4380 int key_id;
4381 struct in_addr addr;
4382 int ret;
4383 struct ospf_if_params *params;
4384
4385 ifp = vty->index;
4386 params = IF_DEF_PARAMS (ifp);
4387
4388 if (argc == 2)
4389 {
4390 ret = inet_aton(argv[1], &addr);
4391 if (!ret)
4392 {
4393 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4394 VTY_NEWLINE);
4395 return CMD_WARNING;
4396 }
4397
4398 params = ospf_lookup_if_params (ifp, addr);
4399 if (params == NULL)
4400 return CMD_SUCCESS;
4401 }
4402
4403 key_id = strtol (argv[0], NULL, 10);
4404 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4405 if (ck == NULL)
4406 {
4407 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4408 return CMD_WARNING;
4409 }
4410
4411 ospf_crypt_key_delete (params->auth_crypt, key_id);
4412
4413 if (params != IF_DEF_PARAMS (ifp))
4414 {
4415 ospf_free_if_params (ifp, addr);
4416 ospf_if_update_params (ifp, addr);
4417 }
4418
4419 return CMD_SUCCESS;
4420}
4421
4422ALIAS (no_ip_ospf_message_digest_key,
4423 no_ip_ospf_message_digest_key_cmd,
4424 "no ip ospf message-digest-key <1-255>",
4425 NO_STR
4426 "IP Information\n"
4427 "OSPF interface commands\n"
4428 "Message digest authentication password (key)\n"
4429 "Key ID\n")
4430
4431ALIAS (no_ip_ospf_message_digest_key,
4432 no_ospf_message_digest_key_cmd,
4433 "no ospf message-digest-key <1-255>",
4434 NO_STR
4435 "OSPF interface commands\n"
4436 "Message digest authentication password (key)\n"
4437 "Key ID\n")
4438
4439DEFUN (ip_ospf_cost,
4440 ip_ospf_cost_addr_cmd,
4441 "ip ospf cost <1-65535> A.B.C.D",
4442 "IP Information\n"
4443 "OSPF interface commands\n"
4444 "Interface cost\n"
4445 "Cost\n"
4446 "Address of interface")
4447{
4448 struct interface *ifp = vty->index;
4449 u_int32_t cost;
4450 struct in_addr addr;
4451 int ret;
4452 struct ospf_if_params *params;
4453
4454 params = IF_DEF_PARAMS (ifp);
4455
4456 cost = strtol (argv[0], NULL, 10);
4457
4458 /* cost range is <1-65535>. */
4459 if (cost < 1 || cost > 65535)
4460 {
4461 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4462 return CMD_WARNING;
4463 }
4464
4465 if (argc == 2)
4466 {
4467 ret = inet_aton(argv[1], &addr);
4468 if (!ret)
4469 {
4470 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4471 VTY_NEWLINE);
4472 return CMD_WARNING;
4473 }
4474
4475 params = ospf_get_if_params (ifp, addr);
4476 ospf_if_update_params (ifp, addr);
4477 }
4478
4479 SET_IF_PARAM (params, output_cost_cmd);
4480 params->output_cost_cmd = cost;
4481
4482 ospf_if_recalculate_output_cost (ifp);
4483
4484 return CMD_SUCCESS;
4485}
4486
4487ALIAS (ip_ospf_cost,
4488 ip_ospf_cost_cmd,
4489 "ip ospf cost <1-65535>",
4490 "IP Information\n"
4491 "OSPF interface commands\n"
4492 "Interface cost\n"
4493 "Cost")
4494
4495ALIAS (ip_ospf_cost,
4496 ospf_cost_cmd,
4497 "ospf cost <1-65535>",
4498 "OSPF interface commands\n"
4499 "Interface cost\n"
4500 "Cost")
4501
4502DEFUN (no_ip_ospf_cost,
4503 no_ip_ospf_cost_addr_cmd,
4504 "no ip ospf cost A.B.C.D",
4505 NO_STR
4506 "IP Information\n"
4507 "OSPF interface commands\n"
4508 "Interface cost\n"
4509 "Address of interface")
4510{
4511 struct interface *ifp = vty->index;
4512 struct in_addr addr;
4513 int ret;
4514 struct ospf_if_params *params;
4515
4516 ifp = vty->index;
4517 params = IF_DEF_PARAMS (ifp);
4518
4519 if (argc == 1)
4520 {
4521 ret = inet_aton(argv[0], &addr);
4522 if (!ret)
4523 {
4524 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4525 VTY_NEWLINE);
4526 return CMD_WARNING;
4527 }
4528
4529 params = ospf_lookup_if_params (ifp, addr);
4530 if (params == NULL)
4531 return CMD_SUCCESS;
4532 }
4533
4534 UNSET_IF_PARAM (params, output_cost_cmd);
4535
4536 if (params != IF_DEF_PARAMS (ifp))
4537 {
4538 ospf_free_if_params (ifp, addr);
4539 ospf_if_update_params (ifp, addr);
4540 }
4541
4542 ospf_if_recalculate_output_cost (ifp);
4543
4544 return CMD_SUCCESS;
4545}
4546
4547ALIAS (no_ip_ospf_cost,
4548 no_ip_ospf_cost_cmd,
4549 "no ip ospf cost",
4550 NO_STR
4551 "IP Information\n"
4552 "OSPF interface commands\n"
4553 "Interface cost\n")
4554
4555ALIAS (no_ip_ospf_cost,
4556 no_ospf_cost_cmd,
4557 "no ospf cost",
4558 NO_STR
4559 "OSPF interface commands\n"
4560 "Interface cost\n")
4561
4562void
4563ospf_nbr_timer_update (struct ospf_interface *oi)
4564{
4565 struct route_node *rn;
4566 struct ospf_neighbor *nbr;
4567
4568 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4569 if ((nbr = rn->info))
4570 {
4571 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4572 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4573 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4574 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4575 }
4576}
4577
4578DEFUN (ip_ospf_dead_interval,
4579 ip_ospf_dead_interval_addr_cmd,
4580 "ip ospf dead-interval <1-65535> A.B.C.D",
4581 "IP Information\n"
4582 "OSPF interface commands\n"
4583 "Interval after which a neighbor is declared dead\n"
4584 "Seconds\n"
4585 "Address of interface")
4586{
4587 struct interface *ifp = vty->index;
4588 u_int32_t seconds;
4589 struct in_addr addr;
4590 int ret;
4591 struct ospf_if_params *params;
4592 struct ospf_interface *oi;
4593 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004594 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004595
paul020709f2003-04-04 02:44:16 +00004596 ospf = ospf_lookup ();
4597
paul718e3742002-12-13 20:15:29 +00004598 params = IF_DEF_PARAMS (ifp);
4599
4600 seconds = strtol (argv[0], NULL, 10);
4601
4602 /* dead_interval range is <1-65535>. */
4603 if (seconds < 1 || seconds > 65535)
4604 {
4605 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4606 return CMD_WARNING;
4607 }
4608
4609 if (argc == 2)
4610 {
4611 ret = inet_aton(argv[1], &addr);
4612 if (!ret)
4613 {
4614 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4615 VTY_NEWLINE);
4616 return CMD_WARNING;
4617 }
4618
4619 params = ospf_get_if_params (ifp, addr);
4620 ospf_if_update_params (ifp, addr);
4621 }
4622
4623 SET_IF_PARAM (params, v_wait);
4624 params->v_wait = seconds;
4625
4626 /* Update timer values in neighbor structure. */
4627 if (argc == 2)
4628 {
paul68980082003-03-25 05:07:42 +00004629 if (ospf)
4630 {
4631 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4632 if (oi)
4633 ospf_nbr_timer_update (oi);
4634 }
paul718e3742002-12-13 20:15:29 +00004635 }
4636 else
4637 {
4638 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4639 if ((oi = rn->info))
4640 ospf_nbr_timer_update (oi);
4641 }
4642
4643 return CMD_SUCCESS;
4644}
4645
4646ALIAS (ip_ospf_dead_interval,
4647 ip_ospf_dead_interval_cmd,
4648 "ip ospf dead-interval <1-65535>",
4649 "IP Information\n"
4650 "OSPF interface commands\n"
4651 "Interval after which a neighbor is declared dead\n"
4652 "Seconds\n")
4653
4654ALIAS (ip_ospf_dead_interval,
4655 ospf_dead_interval_cmd,
4656 "ospf dead-interval <1-65535>",
4657 "OSPF interface commands\n"
4658 "Interval after which a neighbor is declared dead\n"
4659 "Seconds\n")
4660
4661DEFUN (no_ip_ospf_dead_interval,
4662 no_ip_ospf_dead_interval_addr_cmd,
4663 "no ip ospf dead-interval A.B.C.D",
4664 NO_STR
4665 "IP Information\n"
4666 "OSPF interface commands\n"
4667 "Interval after which a neighbor is declared dead\n"
4668 "Address of interface")
4669{
4670 struct interface *ifp = vty->index;
4671 struct in_addr addr;
4672 int ret;
4673 struct ospf_if_params *params;
4674 struct ospf_interface *oi;
4675 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004676 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004677
paul020709f2003-04-04 02:44:16 +00004678 ospf = ospf_lookup ();
4679
paul718e3742002-12-13 20:15:29 +00004680 ifp = vty->index;
4681 params = IF_DEF_PARAMS (ifp);
4682
4683 if (argc == 1)
4684 {
4685 ret = inet_aton(argv[0], &addr);
4686 if (!ret)
4687 {
4688 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4689 VTY_NEWLINE);
4690 return CMD_WARNING;
4691 }
4692
4693 params = ospf_lookup_if_params (ifp, addr);
4694 if (params == NULL)
4695 return CMD_SUCCESS;
4696 }
4697
4698 UNSET_IF_PARAM (params, v_wait);
4699 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4700
4701 if (params != IF_DEF_PARAMS (ifp))
4702 {
4703 ospf_free_if_params (ifp, addr);
4704 ospf_if_update_params (ifp, addr);
4705 }
4706
4707 /* Update timer values in neighbor structure. */
4708 if (argc == 1)
4709 {
paul68980082003-03-25 05:07:42 +00004710 if (ospf)
4711 {
4712 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4713 if (oi)
4714 ospf_nbr_timer_update (oi);
4715 }
paul718e3742002-12-13 20:15:29 +00004716 }
4717 else
4718 {
4719 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4720 if ((oi = rn->info))
4721 ospf_nbr_timer_update (oi);
4722 }
4723
4724 return CMD_SUCCESS;
4725}
4726
4727ALIAS (no_ip_ospf_dead_interval,
4728 no_ip_ospf_dead_interval_cmd,
4729 "no ip ospf dead-interval",
4730 NO_STR
4731 "IP Information\n"
4732 "OSPF interface commands\n"
4733 "Interval after which a neighbor is declared dead\n")
4734
4735ALIAS (no_ip_ospf_dead_interval,
4736 no_ospf_dead_interval_cmd,
4737 "no ospf dead-interval",
4738 NO_STR
4739 "OSPF interface commands\n"
4740 "Interval after which a neighbor is declared dead\n")
4741
4742DEFUN (ip_ospf_hello_interval,
4743 ip_ospf_hello_interval_addr_cmd,
4744 "ip ospf hello-interval <1-65535> A.B.C.D",
4745 "IP Information\n"
4746 "OSPF interface commands\n"
4747 "Time between HELLO packets\n"
4748 "Seconds\n"
4749 "Address of interface")
4750{
4751 struct interface *ifp = vty->index;
4752 u_int32_t seconds;
4753 struct in_addr addr;
4754 int ret;
4755 struct ospf_if_params *params;
4756
4757 params = IF_DEF_PARAMS (ifp);
4758
4759 seconds = strtol (argv[0], NULL, 10);
4760
4761 /* HelloInterval range is <1-65535>. */
4762 if (seconds < 1 || seconds > 65535)
4763 {
4764 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4765 return CMD_WARNING;
4766 }
4767
4768 if (argc == 2)
4769 {
4770 ret = inet_aton(argv[1], &addr);
4771 if (!ret)
4772 {
4773 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4774 VTY_NEWLINE);
4775 return CMD_WARNING;
4776 }
4777
4778 params = ospf_get_if_params (ifp, addr);
4779 ospf_if_update_params (ifp, addr);
4780 }
4781
4782 SET_IF_PARAM (params, v_hello);
4783 params->v_hello = seconds;
4784
4785 return CMD_SUCCESS;
4786}
4787
4788ALIAS (ip_ospf_hello_interval,
4789 ip_ospf_hello_interval_cmd,
4790 "ip ospf hello-interval <1-65535>",
4791 "IP Information\n"
4792 "OSPF interface commands\n"
4793 "Time between HELLO packets\n"
4794 "Seconds\n")
4795
4796ALIAS (ip_ospf_hello_interval,
4797 ospf_hello_interval_cmd,
4798 "ospf hello-interval <1-65535>",
4799 "OSPF interface commands\n"
4800 "Time between HELLO packets\n"
4801 "Seconds\n")
4802
4803DEFUN (no_ip_ospf_hello_interval,
4804 no_ip_ospf_hello_interval_addr_cmd,
4805 "no ip ospf hello-interval A.B.C.D",
4806 NO_STR
4807 "IP Information\n"
4808 "OSPF interface commands\n"
4809 "Time between HELLO packets\n"
4810 "Address of interface")
4811{
4812 struct interface *ifp = vty->index;
4813 struct in_addr addr;
4814 int ret;
4815 struct ospf_if_params *params;
4816
4817 ifp = vty->index;
4818 params = IF_DEF_PARAMS (ifp);
4819
4820 if (argc == 1)
4821 {
4822 ret = inet_aton(argv[0], &addr);
4823 if (!ret)
4824 {
4825 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4826 VTY_NEWLINE);
4827 return CMD_WARNING;
4828 }
4829
4830 params = ospf_lookup_if_params (ifp, addr);
4831 if (params == NULL)
4832 return CMD_SUCCESS;
4833 }
4834
4835 UNSET_IF_PARAM (params, v_hello);
4836 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4837
4838 if (params != IF_DEF_PARAMS (ifp))
4839 {
4840 ospf_free_if_params (ifp, addr);
4841 ospf_if_update_params (ifp, addr);
4842 }
4843
4844 return CMD_SUCCESS;
4845}
4846
4847ALIAS (no_ip_ospf_hello_interval,
4848 no_ip_ospf_hello_interval_cmd,
4849 "no ip ospf hello-interval",
4850 NO_STR
4851 "IP Information\n"
4852 "OSPF interface commands\n"
4853 "Time between HELLO packets\n")
4854
4855ALIAS (no_ip_ospf_hello_interval,
4856 no_ospf_hello_interval_cmd,
4857 "no ospf hello-interval",
4858 NO_STR
4859 "OSPF interface commands\n"
4860 "Time between HELLO packets\n")
4861
4862DEFUN (ip_ospf_network,
4863 ip_ospf_network_cmd,
4864 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4865 "IP Information\n"
4866 "OSPF interface commands\n"
4867 "Network type\n"
4868 "Specify OSPF broadcast multi-access network\n"
4869 "Specify OSPF NBMA network\n"
4870 "Specify OSPF point-to-multipoint network\n"
4871 "Specify OSPF point-to-point network\n")
4872{
4873 struct interface *ifp = vty->index;
4874 int old_type = IF_DEF_PARAMS (ifp)->type;
4875 struct route_node *rn;
4876
4877 if (strncmp (argv[0], "b", 1) == 0)
4878 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4879 else if (strncmp (argv[0], "n", 1) == 0)
4880 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4881 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4882 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4883 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4884 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4885
4886 if (IF_DEF_PARAMS (ifp)->type == old_type)
4887 return CMD_SUCCESS;
4888
4889 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4890
4891 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4892 {
4893 struct ospf_interface *oi = rn->info;
4894
4895 if (!oi)
4896 continue;
4897
4898 oi->type = IF_DEF_PARAMS (ifp)->type;
4899
4900 if (oi->state > ISM_Down)
4901 {
4902 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4903 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4904 }
4905 }
4906
4907 return CMD_SUCCESS;
4908}
4909
4910ALIAS (ip_ospf_network,
4911 ospf_network_cmd,
4912 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4913 "OSPF interface commands\n"
4914 "Network type\n"
4915 "Specify OSPF broadcast multi-access network\n"
4916 "Specify OSPF NBMA network\n"
4917 "Specify OSPF point-to-multipoint network\n"
4918 "Specify OSPF point-to-point network\n")
4919
4920DEFUN (no_ip_ospf_network,
4921 no_ip_ospf_network_cmd,
4922 "no ip ospf network",
4923 NO_STR
4924 "IP Information\n"
4925 "OSPF interface commands\n"
4926 "Network type\n")
4927{
4928 struct interface *ifp = vty->index;
4929 int old_type = IF_DEF_PARAMS (ifp)->type;
4930 struct route_node *rn;
4931
ajsbc18d612004-12-15 15:07:19 +00004932 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00004933
4934 if (IF_DEF_PARAMS (ifp)->type == old_type)
4935 return CMD_SUCCESS;
4936
4937 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4938 {
4939 struct ospf_interface *oi = rn->info;
4940
4941 if (!oi)
4942 continue;
4943
4944 oi->type = IF_DEF_PARAMS (ifp)->type;
4945
4946 if (oi->state > ISM_Down)
4947 {
4948 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4949 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4950 }
4951 }
4952
4953 return CMD_SUCCESS;
4954}
4955
4956ALIAS (no_ip_ospf_network,
4957 no_ospf_network_cmd,
4958 "no ospf network",
4959 NO_STR
4960 "OSPF interface commands\n"
4961 "Network type\n")
4962
4963DEFUN (ip_ospf_priority,
4964 ip_ospf_priority_addr_cmd,
4965 "ip ospf priority <0-255> A.B.C.D",
4966 "IP Information\n"
4967 "OSPF interface commands\n"
4968 "Router priority\n"
4969 "Priority\n"
4970 "Address of interface")
4971{
4972 struct interface *ifp = vty->index;
4973 u_int32_t priority;
4974 struct route_node *rn;
4975 struct in_addr addr;
4976 int ret;
4977 struct ospf_if_params *params;
4978
4979 params = IF_DEF_PARAMS (ifp);
4980
4981 priority = strtol (argv[0], NULL, 10);
4982
4983 /* Router Priority range is <0-255>. */
4984 if (priority < 0 || priority > 255)
4985 {
4986 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4987 return CMD_WARNING;
4988 }
4989
4990 if (argc == 2)
4991 {
4992 ret = inet_aton(argv[1], &addr);
4993 if (!ret)
4994 {
4995 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4996 VTY_NEWLINE);
4997 return CMD_WARNING;
4998 }
4999
5000 params = ospf_get_if_params (ifp, addr);
5001 ospf_if_update_params (ifp, addr);
5002 }
5003
5004 SET_IF_PARAM (params, priority);
5005 params->priority = priority;
5006
5007 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5008 {
5009 struct ospf_interface *oi = rn->info;
5010
5011 if (!oi)
5012 continue;
5013
5014
5015 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5016 {
5017 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5018 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5019 }
5020 }
5021
5022 return CMD_SUCCESS;
5023}
5024
5025ALIAS (ip_ospf_priority,
5026 ip_ospf_priority_cmd,
5027 "ip ospf priority <0-255>",
5028 "IP Information\n"
5029 "OSPF interface commands\n"
5030 "Router priority\n"
5031 "Priority\n")
5032
5033ALIAS (ip_ospf_priority,
5034 ospf_priority_cmd,
5035 "ospf priority <0-255>",
5036 "OSPF interface commands\n"
5037 "Router priority\n"
5038 "Priority\n")
5039
5040DEFUN (no_ip_ospf_priority,
5041 no_ip_ospf_priority_addr_cmd,
5042 "no ip ospf priority A.B.C.D",
5043 NO_STR
5044 "IP Information\n"
5045 "OSPF interface commands\n"
5046 "Router priority\n"
5047 "Address of interface")
5048{
5049 struct interface *ifp = vty->index;
5050 struct route_node *rn;
5051 struct in_addr addr;
5052 int ret;
5053 struct ospf_if_params *params;
5054
5055 ifp = vty->index;
5056 params = IF_DEF_PARAMS (ifp);
5057
5058 if (argc == 1)
5059 {
5060 ret = inet_aton(argv[0], &addr);
5061 if (!ret)
5062 {
5063 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5064 VTY_NEWLINE);
5065 return CMD_WARNING;
5066 }
5067
5068 params = ospf_lookup_if_params (ifp, addr);
5069 if (params == NULL)
5070 return CMD_SUCCESS;
5071 }
5072
5073 UNSET_IF_PARAM (params, priority);
5074 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5075
5076 if (params != IF_DEF_PARAMS (ifp))
5077 {
5078 ospf_free_if_params (ifp, addr);
5079 ospf_if_update_params (ifp, addr);
5080 }
5081
5082 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5083 {
5084 struct ospf_interface *oi = rn->info;
5085
5086 if (!oi)
5087 continue;
5088
5089
5090 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5091 {
5092 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5093 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5094 }
5095 }
5096
5097 return CMD_SUCCESS;
5098}
5099
5100ALIAS (no_ip_ospf_priority,
5101 no_ip_ospf_priority_cmd,
5102 "no ip ospf priority",
5103 NO_STR
5104 "IP Information\n"
5105 "OSPF interface commands\n"
5106 "Router priority\n")
5107
5108ALIAS (no_ip_ospf_priority,
5109 no_ospf_priority_cmd,
5110 "no ospf priority",
5111 NO_STR
5112 "OSPF interface commands\n"
5113 "Router priority\n")
5114
5115DEFUN (ip_ospf_retransmit_interval,
5116 ip_ospf_retransmit_interval_addr_cmd,
5117 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5118 "IP Information\n"
5119 "OSPF interface commands\n"
5120 "Time between retransmitting lost link state advertisements\n"
5121 "Seconds\n"
5122 "Address of interface")
5123{
5124 struct interface *ifp = vty->index;
5125 u_int32_t seconds;
5126 struct in_addr addr;
5127 int ret;
5128 struct ospf_if_params *params;
5129
5130 params = IF_DEF_PARAMS (ifp);
5131 seconds = strtol (argv[0], NULL, 10);
5132
5133 /* Retransmit Interval range is <3-65535>. */
5134 if (seconds < 3 || seconds > 65535)
5135 {
5136 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5137 return CMD_WARNING;
5138 }
5139
5140
5141 if (argc == 2)
5142 {
5143 ret = inet_aton(argv[1], &addr);
5144 if (!ret)
5145 {
5146 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5147 VTY_NEWLINE);
5148 return CMD_WARNING;
5149 }
5150
5151 params = ospf_get_if_params (ifp, addr);
5152 ospf_if_update_params (ifp, addr);
5153 }
5154
5155 SET_IF_PARAM (params, retransmit_interval);
5156 params->retransmit_interval = seconds;
5157
5158 return CMD_SUCCESS;
5159}
5160
5161ALIAS (ip_ospf_retransmit_interval,
5162 ip_ospf_retransmit_interval_cmd,
5163 "ip ospf retransmit-interval <3-65535>",
5164 "IP Information\n"
5165 "OSPF interface commands\n"
5166 "Time between retransmitting lost link state advertisements\n"
5167 "Seconds\n")
5168
5169ALIAS (ip_ospf_retransmit_interval,
5170 ospf_retransmit_interval_cmd,
5171 "ospf retransmit-interval <3-65535>",
5172 "OSPF interface commands\n"
5173 "Time between retransmitting lost link state advertisements\n"
5174 "Seconds\n")
5175
5176DEFUN (no_ip_ospf_retransmit_interval,
5177 no_ip_ospf_retransmit_interval_addr_cmd,
5178 "no ip ospf retransmit-interval A.B.C.D",
5179 NO_STR
5180 "IP Information\n"
5181 "OSPF interface commands\n"
5182 "Time between retransmitting lost link state advertisements\n"
5183 "Address of interface")
5184{
5185 struct interface *ifp = vty->index;
5186 struct in_addr addr;
5187 int ret;
5188 struct ospf_if_params *params;
5189
5190 ifp = vty->index;
5191 params = IF_DEF_PARAMS (ifp);
5192
5193 if (argc == 1)
5194 {
5195 ret = inet_aton(argv[0], &addr);
5196 if (!ret)
5197 {
5198 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5199 VTY_NEWLINE);
5200 return CMD_WARNING;
5201 }
5202
5203 params = ospf_lookup_if_params (ifp, addr);
5204 if (params == NULL)
5205 return CMD_SUCCESS;
5206 }
5207
5208 UNSET_IF_PARAM (params, retransmit_interval);
5209 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5210
5211 if (params != IF_DEF_PARAMS (ifp))
5212 {
5213 ospf_free_if_params (ifp, addr);
5214 ospf_if_update_params (ifp, addr);
5215 }
5216
5217 return CMD_SUCCESS;
5218}
5219
5220ALIAS (no_ip_ospf_retransmit_interval,
5221 no_ip_ospf_retransmit_interval_cmd,
5222 "no ip ospf retransmit-interval",
5223 NO_STR
5224 "IP Information\n"
5225 "OSPF interface commands\n"
5226 "Time between retransmitting lost link state advertisements\n")
5227
5228ALIAS (no_ip_ospf_retransmit_interval,
5229 no_ospf_retransmit_interval_cmd,
5230 "no ospf retransmit-interval",
5231 NO_STR
5232 "OSPF interface commands\n"
5233 "Time between retransmitting lost link state advertisements\n")
5234
5235DEFUN (ip_ospf_transmit_delay,
5236 ip_ospf_transmit_delay_addr_cmd,
5237 "ip ospf transmit-delay <1-65535> A.B.C.D",
5238 "IP Information\n"
5239 "OSPF interface commands\n"
5240 "Link state transmit delay\n"
5241 "Seconds\n"
5242 "Address of interface")
5243{
5244 struct interface *ifp = vty->index;
5245 u_int32_t seconds;
5246 struct in_addr addr;
5247 int ret;
5248 struct ospf_if_params *params;
5249
5250 params = IF_DEF_PARAMS (ifp);
5251 seconds = strtol (argv[0], NULL, 10);
5252
5253 /* Transmit Delay range is <1-65535>. */
5254 if (seconds < 1 || seconds > 65535)
5255 {
5256 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5257 return CMD_WARNING;
5258 }
5259
5260 if (argc == 2)
5261 {
5262 ret = inet_aton(argv[1], &addr);
5263 if (!ret)
5264 {
5265 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5266 VTY_NEWLINE);
5267 return CMD_WARNING;
5268 }
5269
5270 params = ospf_get_if_params (ifp, addr);
5271 ospf_if_update_params (ifp, addr);
5272 }
5273
5274 SET_IF_PARAM (params, transmit_delay);
5275 params->transmit_delay = seconds;
5276
5277 return CMD_SUCCESS;
5278}
5279
5280ALIAS (ip_ospf_transmit_delay,
5281 ip_ospf_transmit_delay_cmd,
5282 "ip ospf transmit-delay <1-65535>",
5283 "IP Information\n"
5284 "OSPF interface commands\n"
5285 "Link state transmit delay\n"
5286 "Seconds\n")
5287
5288ALIAS (ip_ospf_transmit_delay,
5289 ospf_transmit_delay_cmd,
5290 "ospf transmit-delay <1-65535>",
5291 "OSPF interface commands\n"
5292 "Link state transmit delay\n"
5293 "Seconds\n")
5294
5295DEFUN (no_ip_ospf_transmit_delay,
5296 no_ip_ospf_transmit_delay_addr_cmd,
5297 "no ip ospf transmit-delay A.B.C.D",
5298 NO_STR
5299 "IP Information\n"
5300 "OSPF interface commands\n"
5301 "Link state transmit delay\n"
5302 "Address of interface")
5303{
5304 struct interface *ifp = vty->index;
5305 struct in_addr addr;
5306 int ret;
5307 struct ospf_if_params *params;
5308
5309 ifp = vty->index;
5310 params = IF_DEF_PARAMS (ifp);
5311
5312 if (argc == 1)
5313 {
5314 ret = inet_aton(argv[0], &addr);
5315 if (!ret)
5316 {
5317 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5318 VTY_NEWLINE);
5319 return CMD_WARNING;
5320 }
5321
5322 params = ospf_lookup_if_params (ifp, addr);
5323 if (params == NULL)
5324 return CMD_SUCCESS;
5325 }
5326
5327 UNSET_IF_PARAM (params, transmit_delay);
5328 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5329
5330 if (params != IF_DEF_PARAMS (ifp))
5331 {
5332 ospf_free_if_params (ifp, addr);
5333 ospf_if_update_params (ifp, addr);
5334 }
5335
5336 return CMD_SUCCESS;
5337}
5338
5339ALIAS (no_ip_ospf_transmit_delay,
5340 no_ip_ospf_transmit_delay_cmd,
5341 "no ip ospf transmit-delay",
5342 NO_STR
5343 "IP Information\n"
5344 "OSPF interface commands\n"
5345 "Link state transmit delay\n")
5346
5347ALIAS (no_ip_ospf_transmit_delay,
5348 no_ospf_transmit_delay_cmd,
5349 "no ospf transmit-delay",
5350 NO_STR
5351 "OSPF interface commands\n"
5352 "Link state transmit delay\n")
5353
5354
5355DEFUN (ospf_redistribute_source_metric_type,
5356 ospf_redistribute_source_metric_type_routemap_cmd,
5357 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5358 "Redistribute information from another routing protocol\n"
5359 "Kernel routes\n"
5360 "Connected\n"
5361 "Static routes\n"
5362 "Routing Information Protocol (RIP)\n"
5363 "Border Gateway Protocol (BGP)\n"
5364 "Metric for redistributed routes\n"
5365 "OSPF default metric\n"
5366 "OSPF exterior metric type for redistributed routes\n"
5367 "Set OSPF External Type 1 metrics\n"
5368 "Set OSPF External Type 2 metrics\n"
5369 "Route map reference\n"
5370 "Pointer to route-map entries\n")
5371{
paul020709f2003-04-04 02:44:16 +00005372 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005373 int source;
5374 int type = -1;
5375 int metric = -1;
5376
5377 /* Get distribute source. */
5378 if (!str2distribute_source (argv[0], &source))
5379 return CMD_WARNING;
5380
5381 /* Get metric value. */
5382 if (argc >= 2)
5383 if (!str2metric (argv[1], &metric))
5384 return CMD_WARNING;
5385
5386 /* Get metric type. */
5387 if (argc >= 3)
5388 if (!str2metric_type (argv[2], &type))
5389 return CMD_WARNING;
5390
5391 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005392 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005393 else
paul020709f2003-04-04 02:44:16 +00005394 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005395
paul020709f2003-04-04 02:44:16 +00005396 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005397}
5398
5399ALIAS (ospf_redistribute_source_metric_type,
5400 ospf_redistribute_source_metric_type_cmd,
5401 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5402 "Redistribute information from another routing protocol\n"
5403 "Kernel routes\n"
5404 "Connected\n"
5405 "Static routes\n"
5406 "Routing Information Protocol (RIP)\n"
5407 "Border Gateway Protocol (BGP)\n"
5408 "Metric for redistributed routes\n"
5409 "OSPF default metric\n"
5410 "OSPF exterior metric type for redistributed routes\n"
5411 "Set OSPF External Type 1 metrics\n"
5412 "Set OSPF External Type 2 metrics\n")
5413
5414ALIAS (ospf_redistribute_source_metric_type,
5415 ospf_redistribute_source_metric_cmd,
5416 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5417 "Redistribute information from another routing protocol\n"
5418 "Kernel routes\n"
5419 "Connected\n"
5420 "Static routes\n"
5421 "Routing Information Protocol (RIP)\n"
5422 "Border Gateway Protocol (BGP)\n"
5423 "Metric for redistributed routes\n"
5424 "OSPF default metric\n")
5425
5426DEFUN (ospf_redistribute_source_type_metric,
5427 ospf_redistribute_source_type_metric_routemap_cmd,
5428 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5429 "Redistribute information from another routing protocol\n"
5430 "Kernel routes\n"
5431 "Connected\n"
5432 "Static routes\n"
5433 "Routing Information Protocol (RIP)\n"
5434 "Border Gateway Protocol (BGP)\n"
5435 "OSPF exterior metric type for redistributed routes\n"
5436 "Set OSPF External Type 1 metrics\n"
5437 "Set OSPF External Type 2 metrics\n"
5438 "Metric for redistributed routes\n"
5439 "OSPF default metric\n"
5440 "Route map reference\n"
5441 "Pointer to route-map entries\n")
5442{
paul020709f2003-04-04 02:44:16 +00005443 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005444 int source;
5445 int type = -1;
5446 int metric = -1;
5447
5448 /* Get distribute source. */
5449 if (!str2distribute_source (argv[0], &source))
5450 return CMD_WARNING;
5451
5452 /* Get metric value. */
5453 if (argc >= 2)
5454 if (!str2metric_type (argv[1], &type))
5455 return CMD_WARNING;
5456
5457 /* Get metric type. */
5458 if (argc >= 3)
5459 if (!str2metric (argv[2], &metric))
5460 return CMD_WARNING;
5461
5462 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005463 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005464 else
paul020709f2003-04-04 02:44:16 +00005465 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005466
paul020709f2003-04-04 02:44:16 +00005467 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005468}
5469
5470ALIAS (ospf_redistribute_source_type_metric,
5471 ospf_redistribute_source_type_metric_cmd,
5472 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5473 "Redistribute information from another routing protocol\n"
5474 "Kernel routes\n"
5475 "Connected\n"
5476 "Static routes\n"
5477 "Routing Information Protocol (RIP)\n"
5478 "Border Gateway Protocol (BGP)\n"
5479 "OSPF exterior metric type for redistributed routes\n"
5480 "Set OSPF External Type 1 metrics\n"
5481 "Set OSPF External Type 2 metrics\n"
5482 "Metric for redistributed routes\n"
5483 "OSPF default metric\n")
5484
5485ALIAS (ospf_redistribute_source_type_metric,
5486 ospf_redistribute_source_type_cmd,
5487 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5488 "Redistribute information from another routing protocol\n"
5489 "Kernel routes\n"
5490 "Connected\n"
5491 "Static routes\n"
5492 "Routing Information Protocol (RIP)\n"
5493 "Border Gateway Protocol (BGP)\n"
5494 "OSPF exterior metric type for redistributed routes\n"
5495 "Set OSPF External Type 1 metrics\n"
5496 "Set OSPF External Type 2 metrics\n")
5497
5498ALIAS (ospf_redistribute_source_type_metric,
5499 ospf_redistribute_source_cmd,
5500 "redistribute (kernel|connected|static|rip|bgp)",
5501 "Redistribute information from another routing protocol\n"
5502 "Kernel routes\n"
5503 "Connected\n"
5504 "Static routes\n"
5505 "Routing Information Protocol (RIP)\n"
5506 "Border Gateway Protocol (BGP)\n")
5507
5508DEFUN (ospf_redistribute_source_metric_routemap,
5509 ospf_redistribute_source_metric_routemap_cmd,
5510 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5511 "Redistribute information from another routing protocol\n"
5512 "Kernel routes\n"
5513 "Connected\n"
5514 "Static routes\n"
5515 "Routing Information Protocol (RIP)\n"
5516 "Border Gateway Protocol (BGP)\n"
5517 "Metric for redistributed routes\n"
5518 "OSPF default metric\n"
5519 "Route map reference\n"
5520 "Pointer to route-map entries\n")
5521{
paul020709f2003-04-04 02:44:16 +00005522 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005523 int source;
5524 int metric = -1;
5525
5526 /* Get distribute source. */
5527 if (!str2distribute_source (argv[0], &source))
5528 return CMD_WARNING;
5529
5530 /* Get metric value. */
5531 if (argc >= 2)
5532 if (!str2metric (argv[1], &metric))
5533 return CMD_WARNING;
5534
5535 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005536 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005537 else
paul020709f2003-04-04 02:44:16 +00005538 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005539
paul020709f2003-04-04 02:44:16 +00005540 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005541}
5542
5543DEFUN (ospf_redistribute_source_type_routemap,
5544 ospf_redistribute_source_type_routemap_cmd,
5545 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5546 "Redistribute information from another routing protocol\n"
5547 "Kernel routes\n"
5548 "Connected\n"
5549 "Static routes\n"
5550 "Routing Information Protocol (RIP)\n"
5551 "Border Gateway Protocol (BGP)\n"
5552 "OSPF exterior metric type for redistributed routes\n"
5553 "Set OSPF External Type 1 metrics\n"
5554 "Set OSPF External Type 2 metrics\n"
5555 "Route map reference\n"
5556 "Pointer to route-map entries\n")
5557{
paul020709f2003-04-04 02:44:16 +00005558 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005559 int source;
5560 int type = -1;
5561
5562 /* Get distribute source. */
5563 if (!str2distribute_source (argv[0], &source))
5564 return CMD_WARNING;
5565
5566 /* Get metric value. */
5567 if (argc >= 2)
5568 if (!str2metric_type (argv[1], &type))
5569 return CMD_WARNING;
5570
5571 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005572 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005573 else
paul020709f2003-04-04 02:44:16 +00005574 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005575
paul020709f2003-04-04 02:44:16 +00005576 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005577}
5578
5579DEFUN (ospf_redistribute_source_routemap,
5580 ospf_redistribute_source_routemap_cmd,
5581 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5582 "Redistribute information from another routing protocol\n"
5583 "Kernel routes\n"
5584 "Connected\n"
5585 "Static routes\n"
5586 "Routing Information Protocol (RIP)\n"
5587 "Border Gateway Protocol (BGP)\n"
5588 "Route map reference\n"
5589 "Pointer to route-map entries\n")
5590{
paul020709f2003-04-04 02:44:16 +00005591 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005592 int source;
5593
5594 /* Get distribute source. */
5595 if (!str2distribute_source (argv[0], &source))
5596 return CMD_WARNING;
5597
5598 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005599 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005600 else
paul020709f2003-04-04 02:44:16 +00005601 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005602
paul020709f2003-04-04 02:44:16 +00005603 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005604}
5605
5606DEFUN (no_ospf_redistribute_source,
5607 no_ospf_redistribute_source_cmd,
5608 "no redistribute (kernel|connected|static|rip|bgp)",
5609 NO_STR
5610 "Redistribute information from another routing protocol\n"
5611 "Kernel routes\n"
5612 "Connected\n"
5613 "Static routes\n"
5614 "Routing Information Protocol (RIP)\n"
5615 "Border Gateway Protocol (BGP)\n")
5616{
paul020709f2003-04-04 02:44:16 +00005617 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005618 int source;
5619
5620 if (!str2distribute_source (argv[0], &source))
5621 return CMD_WARNING;
5622
paul020709f2003-04-04 02:44:16 +00005623 ospf_routemap_unset (ospf, source);
5624 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005625}
5626
5627DEFUN (ospf_distribute_list_out,
5628 ospf_distribute_list_out_cmd,
5629 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5630 "Filter networks in routing updates\n"
5631 "Access-list name\n"
5632 OUT_STR
5633 "Kernel routes\n"
5634 "Connected\n"
5635 "Static routes\n"
5636 "Routing Information Protocol (RIP)\n"
5637 "Border Gateway Protocol (BGP)\n")
5638{
paul68980082003-03-25 05:07:42 +00005639 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005640 int source;
5641
5642 /* Get distribute source. */
5643 if (!str2distribute_source (argv[1], &source))
5644 return CMD_WARNING;
5645
paul68980082003-03-25 05:07:42 +00005646 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005647}
5648
5649DEFUN (no_ospf_distribute_list_out,
5650 no_ospf_distribute_list_out_cmd,
5651 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5652 NO_STR
5653 "Filter networks in routing updates\n"
5654 "Access-list name\n"
5655 OUT_STR
5656 "Kernel routes\n"
5657 "Connected\n"
5658 "Static routes\n"
5659 "Routing Information Protocol (RIP)\n"
5660 "Border Gateway Protocol (BGP)\n")
5661{
paul68980082003-03-25 05:07:42 +00005662 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005663 int source;
5664
5665 if (!str2distribute_source (argv[1], &source))
5666 return CMD_WARNING;
5667
paul68980082003-03-25 05:07:42 +00005668 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005669}
5670
5671/* Default information originate. */
5672DEFUN (ospf_default_information_originate_metric_type_routemap,
5673 ospf_default_information_originate_metric_type_routemap_cmd,
5674 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5675 "Control distribution of default information\n"
5676 "Distribute a default route\n"
5677 "OSPF default metric\n"
5678 "OSPF metric\n"
5679 "OSPF metric type for default routes\n"
5680 "Set OSPF External Type 1 metrics\n"
5681 "Set OSPF External Type 2 metrics\n"
5682 "Route map reference\n"
5683 "Pointer to route-map entries\n")
5684{
paul020709f2003-04-04 02:44:16 +00005685 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005686 int type = -1;
5687 int metric = -1;
5688
5689 /* Get metric value. */
5690 if (argc >= 1)
5691 if (!str2metric (argv[0], &metric))
5692 return CMD_WARNING;
5693
5694 /* Get metric type. */
5695 if (argc >= 2)
5696 if (!str2metric_type (argv[1], &type))
5697 return CMD_WARNING;
5698
5699 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005700 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005701 else
paul020709f2003-04-04 02:44:16 +00005702 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005703
paul020709f2003-04-04 02:44:16 +00005704 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5705 type, metric);
paul718e3742002-12-13 20:15:29 +00005706}
5707
5708ALIAS (ospf_default_information_originate_metric_type_routemap,
5709 ospf_default_information_originate_metric_type_cmd,
5710 "default-information originate metric <0-16777214> metric-type (1|2)",
5711 "Control distribution of default information\n"
5712 "Distribute a default route\n"
5713 "OSPF default metric\n"
5714 "OSPF metric\n"
5715 "OSPF metric type for default routes\n"
5716 "Set OSPF External Type 1 metrics\n"
5717 "Set OSPF External Type 2 metrics\n")
5718
5719ALIAS (ospf_default_information_originate_metric_type_routemap,
5720 ospf_default_information_originate_metric_cmd,
5721 "default-information originate metric <0-16777214>",
5722 "Control distribution of default information\n"
5723 "Distribute a default route\n"
5724 "OSPF default metric\n"
5725 "OSPF metric\n")
5726
5727ALIAS (ospf_default_information_originate_metric_type_routemap,
5728 ospf_default_information_originate_cmd,
5729 "default-information originate",
5730 "Control distribution of default information\n"
5731 "Distribute a default route\n")
5732
5733/* Default information originate. */
5734DEFUN (ospf_default_information_originate_metric_routemap,
5735 ospf_default_information_originate_metric_routemap_cmd,
5736 "default-information originate metric <0-16777214> route-map WORD",
5737 "Control distribution of default information\n"
5738 "Distribute a default route\n"
5739 "OSPF default metric\n"
5740 "OSPF metric\n"
5741 "Route map reference\n"
5742 "Pointer to route-map entries\n")
5743{
paul020709f2003-04-04 02:44:16 +00005744 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005745 int metric = -1;
5746
5747 /* Get metric value. */
5748 if (argc >= 1)
5749 if (!str2metric (argv[0], &metric))
5750 return CMD_WARNING;
5751
5752 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005753 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005754 else
paul020709f2003-04-04 02:44:16 +00005755 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005756
paul020709f2003-04-04 02:44:16 +00005757 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5758 -1, metric);
paul718e3742002-12-13 20:15:29 +00005759}
5760
5761/* Default information originate. */
5762DEFUN (ospf_default_information_originate_routemap,
5763 ospf_default_information_originate_routemap_cmd,
5764 "default-information originate route-map WORD",
5765 "Control distribution of default information\n"
5766 "Distribute a default route\n"
5767 "Route map reference\n"
5768 "Pointer to route-map entries\n")
5769{
paul020709f2003-04-04 02:44:16 +00005770 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005771
paul020709f2003-04-04 02:44:16 +00005772 if (argc == 1)
5773 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5774 else
5775 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5776
5777 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005778}
5779
5780DEFUN (ospf_default_information_originate_type_metric_routemap,
5781 ospf_default_information_originate_type_metric_routemap_cmd,
5782 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5783 "Control distribution of default information\n"
5784 "Distribute a default route\n"
5785 "OSPF metric type for default routes\n"
5786 "Set OSPF External Type 1 metrics\n"
5787 "Set OSPF External Type 2 metrics\n"
5788 "OSPF default metric\n"
5789 "OSPF metric\n"
5790 "Route map reference\n"
5791 "Pointer to route-map entries\n")
5792{
paul020709f2003-04-04 02:44:16 +00005793 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005794 int type = -1;
5795 int metric = -1;
5796
5797 /* Get metric type. */
5798 if (argc >= 1)
5799 if (!str2metric_type (argv[0], &type))
5800 return CMD_WARNING;
5801
5802 /* Get metric value. */
5803 if (argc >= 2)
5804 if (!str2metric (argv[1], &metric))
5805 return CMD_WARNING;
5806
5807 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005808 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005809 else
paul020709f2003-04-04 02:44:16 +00005810 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005811
paul020709f2003-04-04 02:44:16 +00005812 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5813 type, metric);
paul718e3742002-12-13 20:15:29 +00005814}
5815
5816ALIAS (ospf_default_information_originate_type_metric_routemap,
5817 ospf_default_information_originate_type_metric_cmd,
5818 "default-information originate metric-type (1|2) metric <0-16777214>",
5819 "Control distribution of default information\n"
5820 "Distribute a default route\n"
5821 "OSPF metric type for default routes\n"
5822 "Set OSPF External Type 1 metrics\n"
5823 "Set OSPF External Type 2 metrics\n"
5824 "OSPF default metric\n"
5825 "OSPF metric\n")
5826
5827ALIAS (ospf_default_information_originate_type_metric_routemap,
5828 ospf_default_information_originate_type_cmd,
5829 "default-information originate metric-type (1|2)",
5830 "Control distribution of default information\n"
5831 "Distribute a default route\n"
5832 "OSPF metric type for default routes\n"
5833 "Set OSPF External Type 1 metrics\n"
5834 "Set OSPF External Type 2 metrics\n")
5835
5836DEFUN (ospf_default_information_originate_type_routemap,
5837 ospf_default_information_originate_type_routemap_cmd,
5838 "default-information originate metric-type (1|2) route-map WORD",
5839 "Control distribution of default information\n"
5840 "Distribute a default route\n"
5841 "OSPF metric type for default routes\n"
5842 "Set OSPF External Type 1 metrics\n"
5843 "Set OSPF External Type 2 metrics\n"
5844 "Route map reference\n"
5845 "Pointer to route-map entries\n")
5846{
paul020709f2003-04-04 02:44:16 +00005847 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005848 int type = -1;
5849
5850 /* Get metric type. */
5851 if (argc >= 1)
5852 if (!str2metric_type (argv[0], &type))
5853 return CMD_WARNING;
5854
5855 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005856 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005857 else
paul020709f2003-04-04 02:44:16 +00005858 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005859
paul020709f2003-04-04 02:44:16 +00005860 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5861 type, -1);
paul718e3742002-12-13 20:15:29 +00005862}
5863
5864DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5865 ospf_default_information_originate_always_metric_type_routemap_cmd,
5866 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5867 "Control distribution of default information\n"
5868 "Distribute a default route\n"
5869 "Always advertise default route\n"
5870 "OSPF default metric\n"
5871 "OSPF metric\n"
5872 "OSPF metric type for default routes\n"
5873 "Set OSPF External Type 1 metrics\n"
5874 "Set OSPF External Type 2 metrics\n"
5875 "Route map reference\n"
5876 "Pointer to route-map entries\n")
5877{
paul020709f2003-04-04 02:44:16 +00005878 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005879 int type = -1;
5880 int metric = -1;
5881
5882 /* Get metric value. */
5883 if (argc >= 1)
5884 if (!str2metric (argv[0], &metric))
5885 return CMD_WARNING;
5886
5887 /* Get metric type. */
5888 if (argc >= 2)
5889 if (!str2metric_type (argv[1], &type))
5890 return CMD_WARNING;
5891
5892 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005893 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005894 else
paul020709f2003-04-04 02:44:16 +00005895 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005896
paul020709f2003-04-04 02:44:16 +00005897 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005898 type, metric);
5899}
5900
5901ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5902 ospf_default_information_originate_always_metric_type_cmd,
5903 "default-information originate always metric <0-16777214> metric-type (1|2)",
5904 "Control distribution of default information\n"
5905 "Distribute a default route\n"
5906 "Always advertise default route\n"
5907 "OSPF default metric\n"
5908 "OSPF metric\n"
5909 "OSPF metric type for default routes\n"
5910 "Set OSPF External Type 1 metrics\n"
5911 "Set OSPF External Type 2 metrics\n")
5912
5913ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5914 ospf_default_information_originate_always_metric_cmd,
5915 "default-information originate always metric <0-16777214>",
5916 "Control distribution of default information\n"
5917 "Distribute a default route\n"
5918 "Always advertise default route\n"
5919 "OSPF default metric\n"
5920 "OSPF metric\n"
5921 "OSPF metric type for default routes\n")
5922
5923ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5924 ospf_default_information_originate_always_cmd,
5925 "default-information originate always",
5926 "Control distribution of default information\n"
5927 "Distribute a default route\n"
5928 "Always advertise default route\n")
5929
5930DEFUN (ospf_default_information_originate_always_metric_routemap,
5931 ospf_default_information_originate_always_metric_routemap_cmd,
5932 "default-information originate always metric <0-16777214> route-map WORD",
5933 "Control distribution of default information\n"
5934 "Distribute a default route\n"
5935 "Always advertise default route\n"
5936 "OSPF default metric\n"
5937 "OSPF metric\n"
5938 "Route map reference\n"
5939 "Pointer to route-map entries\n")
5940{
paul020709f2003-04-04 02:44:16 +00005941 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005942 int metric = -1;
5943
5944 /* Get metric value. */
5945 if (argc >= 1)
5946 if (!str2metric (argv[0], &metric))
5947 return CMD_WARNING;
5948
5949 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005950 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005951 else
paul020709f2003-04-04 02:44:16 +00005952 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005953
paul020709f2003-04-04 02:44:16 +00005954 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5955 -1, metric);
paul718e3742002-12-13 20:15:29 +00005956}
5957
5958DEFUN (ospf_default_information_originate_always_routemap,
5959 ospf_default_information_originate_always_routemap_cmd,
5960 "default-information originate always route-map WORD",
5961 "Control distribution of default information\n"
5962 "Distribute a default route\n"
5963 "Always advertise default route\n"
5964 "Route map reference\n"
5965 "Pointer to route-map entries\n")
5966{
paul020709f2003-04-04 02:44:16 +00005967 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005968
paul020709f2003-04-04 02:44:16 +00005969 if (argc == 1)
5970 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5971 else
5972 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5973
5974 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005975}
5976
5977DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5978 ospf_default_information_originate_always_type_metric_routemap_cmd,
5979 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5980 "Control distribution of default information\n"
5981 "Distribute a default route\n"
5982 "Always advertise default route\n"
5983 "OSPF metric type for default routes\n"
5984 "Set OSPF External Type 1 metrics\n"
5985 "Set OSPF External Type 2 metrics\n"
5986 "OSPF default metric\n"
5987 "OSPF metric\n"
5988 "Route map reference\n"
5989 "Pointer to route-map entries\n")
5990{
paul020709f2003-04-04 02:44:16 +00005991 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005992 int type = -1;
5993 int metric = -1;
5994
5995 /* Get metric type. */
5996 if (argc >= 1)
5997 if (!str2metric_type (argv[0], &type))
5998 return CMD_WARNING;
5999
6000 /* Get metric value. */
6001 if (argc >= 2)
6002 if (!str2metric (argv[1], &metric))
6003 return CMD_WARNING;
6004
6005 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006006 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006007 else
paul020709f2003-04-04 02:44:16 +00006008 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006009
paul020709f2003-04-04 02:44:16 +00006010 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006011 type, metric);
6012}
6013
6014ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6015 ospf_default_information_originate_always_type_metric_cmd,
6016 "default-information originate always metric-type (1|2) metric <0-16777214>",
6017 "Control distribution of default information\n"
6018 "Distribute a default route\n"
6019 "Always advertise default route\n"
6020 "OSPF metric type for default routes\n"
6021 "Set OSPF External Type 1 metrics\n"
6022 "Set OSPF External Type 2 metrics\n"
6023 "OSPF default metric\n"
6024 "OSPF metric\n")
6025
6026ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6027 ospf_default_information_originate_always_type_cmd,
6028 "default-information originate always metric-type (1|2)",
6029 "Control distribution of default information\n"
6030 "Distribute a default route\n"
6031 "Always advertise default route\n"
6032 "OSPF metric type for default routes\n"
6033 "Set OSPF External Type 1 metrics\n"
6034 "Set OSPF External Type 2 metrics\n")
6035
6036DEFUN (ospf_default_information_originate_always_type_routemap,
6037 ospf_default_information_originate_always_type_routemap_cmd,
6038 "default-information originate always metric-type (1|2) route-map WORD",
6039 "Control distribution of default information\n"
6040 "Distribute a default route\n"
6041 "Always advertise default route\n"
6042 "OSPF metric type for default routes\n"
6043 "Set OSPF External Type 1 metrics\n"
6044 "Set OSPF External Type 2 metrics\n"
6045 "Route map reference\n"
6046 "Pointer to route-map entries\n")
6047{
paul020709f2003-04-04 02:44:16 +00006048 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006049 int type = -1;
6050
6051 /* Get metric type. */
6052 if (argc >= 1)
6053 if (!str2metric_type (argv[0], &type))
6054 return CMD_WARNING;
6055
6056 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006057 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006058 else
paul020709f2003-04-04 02:44:16 +00006059 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006060
paul020709f2003-04-04 02:44:16 +00006061 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006062 type, -1);
6063}
6064
6065DEFUN (no_ospf_default_information_originate,
6066 no_ospf_default_information_originate_cmd,
6067 "no default-information originate",
6068 NO_STR
6069 "Control distribution of default information\n"
6070 "Distribute a default route\n")
6071{
paul68980082003-03-25 05:07:42 +00006072 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006073 struct prefix_ipv4 p;
6074 struct in_addr nexthop;
6075
6076 p.family = AF_INET;
6077 p.prefix.s_addr = 0;
6078 p.prefixlen = 0;
6079
paul68980082003-03-25 05:07:42 +00006080 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
paul718e3742002-12-13 20:15:29 +00006081
6082 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6083 ospf_external_info_delete (DEFAULT_ROUTE, p);
6084 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6085 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6086 }
6087
paul020709f2003-04-04 02:44:16 +00006088 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6089 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006090}
6091
6092DEFUN (ospf_default_metric,
6093 ospf_default_metric_cmd,
6094 "default-metric <0-16777214>",
6095 "Set metric of redistributed routes\n"
6096 "Default metric\n")
6097{
paul68980082003-03-25 05:07:42 +00006098 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006099 int metric = -1;
6100
6101 if (!str2metric (argv[0], &metric))
6102 return CMD_WARNING;
6103
paul68980082003-03-25 05:07:42 +00006104 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006105
6106 return CMD_SUCCESS;
6107}
6108
6109DEFUN (no_ospf_default_metric,
6110 no_ospf_default_metric_cmd,
6111 "no default-metric",
6112 NO_STR
6113 "Set metric of redistributed routes\n")
6114{
paul68980082003-03-25 05:07:42 +00006115 struct ospf *ospf = vty->index;
6116
6117 ospf->default_metric = -1;
6118
paul718e3742002-12-13 20:15:29 +00006119 return CMD_SUCCESS;
6120}
6121
6122ALIAS (no_ospf_default_metric,
6123 no_ospf_default_metric_val_cmd,
6124 "no default-metric <0-16777214>",
6125 NO_STR
6126 "Set metric of redistributed routes\n"
6127 "Default metric\n")
6128
6129DEFUN (ospf_distance,
6130 ospf_distance_cmd,
6131 "distance <1-255>",
6132 "Define an administrative distance\n"
6133 "OSPF Administrative distance\n")
6134{
paul68980082003-03-25 05:07:42 +00006135 struct ospf *ospf = vty->index;
6136
6137 ospf->distance_all = atoi (argv[0]);
6138
paul718e3742002-12-13 20:15:29 +00006139 return CMD_SUCCESS;
6140}
6141
6142DEFUN (no_ospf_distance,
6143 no_ospf_distance_cmd,
6144 "no distance <1-255>",
6145 NO_STR
6146 "Define an administrative distance\n"
6147 "OSPF Administrative distance\n")
6148{
paul68980082003-03-25 05:07:42 +00006149 struct ospf *ospf = vty->index;
6150
6151 ospf->distance_all = 0;
6152
paul718e3742002-12-13 20:15:29 +00006153 return CMD_SUCCESS;
6154}
6155
6156DEFUN (no_ospf_distance_ospf,
6157 no_ospf_distance_ospf_cmd,
6158 "no distance ospf",
6159 NO_STR
6160 "Define an administrative distance\n"
6161 "OSPF Administrative distance\n"
6162 "OSPF Distance\n")
6163{
paul68980082003-03-25 05:07:42 +00006164 struct ospf *ospf = vty->index;
6165
6166 ospf->distance_intra = 0;
6167 ospf->distance_inter = 0;
6168 ospf->distance_external = 0;
6169
paul718e3742002-12-13 20:15:29 +00006170 return CMD_SUCCESS;
6171}
6172
6173DEFUN (ospf_distance_ospf_intra,
6174 ospf_distance_ospf_intra_cmd,
6175 "distance ospf intra-area <1-255>",
6176 "Define an administrative distance\n"
6177 "OSPF Administrative distance\n"
6178 "Intra-area routes\n"
6179 "Distance for intra-area routes\n")
6180{
paul68980082003-03-25 05:07:42 +00006181 struct ospf *ospf = vty->index;
6182
6183 ospf->distance_intra = atoi (argv[0]);
6184
paul718e3742002-12-13 20:15:29 +00006185 return CMD_SUCCESS;
6186}
6187
6188DEFUN (ospf_distance_ospf_intra_inter,
6189 ospf_distance_ospf_intra_inter_cmd,
6190 "distance ospf intra-area <1-255> inter-area <1-255>",
6191 "Define an administrative distance\n"
6192 "OSPF Administrative distance\n"
6193 "Intra-area routes\n"
6194 "Distance for intra-area routes\n"
6195 "Inter-area routes\n"
6196 "Distance for inter-area routes\n")
6197{
paul68980082003-03-25 05:07:42 +00006198 struct ospf *ospf = vty->index;
6199
6200 ospf->distance_intra = atoi (argv[0]);
6201 ospf->distance_inter = atoi (argv[1]);
6202
paul718e3742002-12-13 20:15:29 +00006203 return CMD_SUCCESS;
6204}
6205
6206DEFUN (ospf_distance_ospf_intra_external,
6207 ospf_distance_ospf_intra_external_cmd,
6208 "distance ospf intra-area <1-255> external <1-255>",
6209 "Define an administrative distance\n"
6210 "OSPF Administrative distance\n"
6211 "Intra-area routes\n"
6212 "Distance for intra-area routes\n"
6213 "External routes\n"
6214 "Distance for external routes\n")
6215{
paul68980082003-03-25 05:07:42 +00006216 struct ospf *ospf = vty->index;
6217
6218 ospf->distance_intra = atoi (argv[0]);
6219 ospf->distance_external = atoi (argv[1]);
6220
paul718e3742002-12-13 20:15:29 +00006221 return CMD_SUCCESS;
6222}
6223
6224DEFUN (ospf_distance_ospf_intra_inter_external,
6225 ospf_distance_ospf_intra_inter_external_cmd,
6226 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6227 "Define an administrative distance\n"
6228 "OSPF Administrative distance\n"
6229 "Intra-area routes\n"
6230 "Distance for intra-area routes\n"
6231 "Inter-area routes\n"
6232 "Distance for inter-area routes\n"
6233 "External routes\n"
6234 "Distance for external routes\n")
6235{
paul68980082003-03-25 05:07:42 +00006236 struct ospf *ospf = vty->index;
6237
6238 ospf->distance_intra = atoi (argv[0]);
6239 ospf->distance_inter = atoi (argv[1]);
6240 ospf->distance_external = atoi (argv[2]);
6241
paul718e3742002-12-13 20:15:29 +00006242 return CMD_SUCCESS;
6243}
6244
6245DEFUN (ospf_distance_ospf_intra_external_inter,
6246 ospf_distance_ospf_intra_external_inter_cmd,
6247 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6248 "Define an administrative distance\n"
6249 "OSPF Administrative distance\n"
6250 "Intra-area routes\n"
6251 "Distance for intra-area routes\n"
6252 "External routes\n"
6253 "Distance for external routes\n"
6254 "Inter-area routes\n"
6255 "Distance for inter-area routes\n")
6256{
paul68980082003-03-25 05:07:42 +00006257 struct ospf *ospf = vty->index;
6258
6259 ospf->distance_intra = atoi (argv[0]);
6260 ospf->distance_external = atoi (argv[1]);
6261 ospf->distance_inter = atoi (argv[2]);
6262
paul718e3742002-12-13 20:15:29 +00006263 return CMD_SUCCESS;
6264}
6265
6266DEFUN (ospf_distance_ospf_inter,
6267 ospf_distance_ospf_inter_cmd,
6268 "distance ospf inter-area <1-255>",
6269 "Define an administrative distance\n"
6270 "OSPF Administrative distance\n"
6271 "Inter-area routes\n"
6272 "Distance for inter-area routes\n")
6273{
paul68980082003-03-25 05:07:42 +00006274 struct ospf *ospf = vty->index;
6275
6276 ospf->distance_inter = atoi (argv[0]);
6277
paul718e3742002-12-13 20:15:29 +00006278 return CMD_SUCCESS;
6279}
6280
6281DEFUN (ospf_distance_ospf_inter_intra,
6282 ospf_distance_ospf_inter_intra_cmd,
6283 "distance ospf inter-area <1-255> intra-area <1-255>",
6284 "Define an administrative distance\n"
6285 "OSPF Administrative distance\n"
6286 "Inter-area routes\n"
6287 "Distance for inter-area routes\n"
6288 "Intra-area routes\n"
6289 "Distance for intra-area routes\n")
6290{
paul68980082003-03-25 05:07:42 +00006291 struct ospf *ospf = vty->index;
6292
6293 ospf->distance_inter = atoi (argv[0]);
6294 ospf->distance_intra = atoi (argv[1]);
6295
paul718e3742002-12-13 20:15:29 +00006296 return CMD_SUCCESS;
6297}
6298
6299DEFUN (ospf_distance_ospf_inter_external,
6300 ospf_distance_ospf_inter_external_cmd,
6301 "distance ospf inter-area <1-255> external <1-255>",
6302 "Define an administrative distance\n"
6303 "OSPF Administrative distance\n"
6304 "Inter-area routes\n"
6305 "Distance for inter-area routes\n"
6306 "External routes\n"
6307 "Distance for external routes\n")
6308{
paul68980082003-03-25 05:07:42 +00006309 struct ospf *ospf = vty->index;
6310
6311 ospf->distance_inter = atoi (argv[0]);
6312 ospf->distance_external = atoi (argv[1]);
6313
paul718e3742002-12-13 20:15:29 +00006314 return CMD_SUCCESS;
6315}
6316
6317DEFUN (ospf_distance_ospf_inter_intra_external,
6318 ospf_distance_ospf_inter_intra_external_cmd,
6319 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6320 "Define an administrative distance\n"
6321 "OSPF Administrative distance\n"
6322 "Inter-area routes\n"
6323 "Distance for inter-area routes\n"
6324 "Intra-area routes\n"
6325 "Distance for intra-area routes\n"
6326 "External routes\n"
6327 "Distance for external routes\n")
6328{
paul68980082003-03-25 05:07:42 +00006329 struct ospf *ospf = vty->index;
6330
6331 ospf->distance_inter = atoi (argv[0]);
6332 ospf->distance_intra = atoi (argv[1]);
6333 ospf->distance_external = atoi (argv[2]);
6334
paul718e3742002-12-13 20:15:29 +00006335 return CMD_SUCCESS;
6336}
6337
6338DEFUN (ospf_distance_ospf_inter_external_intra,
6339 ospf_distance_ospf_inter_external_intra_cmd,
6340 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6341 "Define an administrative distance\n"
6342 "OSPF Administrative distance\n"
6343 "Inter-area routes\n"
6344 "Distance for inter-area routes\n"
6345 "External routes\n"
6346 "Distance for external routes\n"
6347 "Intra-area routes\n"
6348 "Distance for intra-area routes\n")
6349{
paul68980082003-03-25 05:07:42 +00006350 struct ospf *ospf = vty->index;
6351
6352 ospf->distance_inter = atoi (argv[0]);
6353 ospf->distance_external = atoi (argv[1]);
6354 ospf->distance_intra = atoi (argv[2]);
6355
paul718e3742002-12-13 20:15:29 +00006356 return CMD_SUCCESS;
6357}
6358
6359DEFUN (ospf_distance_ospf_external,
6360 ospf_distance_ospf_external_cmd,
6361 "distance ospf external <1-255>",
6362 "Define an administrative distance\n"
6363 "OSPF Administrative distance\n"
6364 "External routes\n"
6365 "Distance for external routes\n")
6366{
paul68980082003-03-25 05:07:42 +00006367 struct ospf *ospf = vty->index;
6368
6369 ospf->distance_external = atoi (argv[0]);
6370
paul718e3742002-12-13 20:15:29 +00006371 return CMD_SUCCESS;
6372}
6373
6374DEFUN (ospf_distance_ospf_external_intra,
6375 ospf_distance_ospf_external_intra_cmd,
6376 "distance ospf external <1-255> intra-area <1-255>",
6377 "Define an administrative distance\n"
6378 "OSPF Administrative distance\n"
6379 "External routes\n"
6380 "Distance for external routes\n"
6381 "Intra-area routes\n"
6382 "Distance for intra-area routes\n")
6383{
paul68980082003-03-25 05:07:42 +00006384 struct ospf *ospf = vty->index;
6385
6386 ospf->distance_external = atoi (argv[0]);
6387 ospf->distance_intra = atoi (argv[1]);
6388
paul718e3742002-12-13 20:15:29 +00006389 return CMD_SUCCESS;
6390}
6391
6392DEFUN (ospf_distance_ospf_external_inter,
6393 ospf_distance_ospf_external_inter_cmd,
6394 "distance ospf external <1-255> inter-area <1-255>",
6395 "Define an administrative distance\n"
6396 "OSPF Administrative distance\n"
6397 "External routes\n"
6398 "Distance for external routes\n"
6399 "Inter-area routes\n"
6400 "Distance for inter-area routes\n")
6401{
paul68980082003-03-25 05:07:42 +00006402 struct ospf *ospf = vty->index;
6403
6404 ospf->distance_external = atoi (argv[0]);
6405 ospf->distance_inter = atoi (argv[1]);
6406
paul718e3742002-12-13 20:15:29 +00006407 return CMD_SUCCESS;
6408}
6409
6410DEFUN (ospf_distance_ospf_external_intra_inter,
6411 ospf_distance_ospf_external_intra_inter_cmd,
6412 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6413 "Define an administrative distance\n"
6414 "OSPF Administrative distance\n"
6415 "External routes\n"
6416 "Distance for external routes\n"
6417 "Intra-area routes\n"
6418 "Distance for intra-area routes\n"
6419 "Inter-area routes\n"
6420 "Distance for inter-area routes\n")
6421{
paul68980082003-03-25 05:07:42 +00006422 struct ospf *ospf = vty->index;
6423
6424 ospf->distance_external = atoi (argv[0]);
6425 ospf->distance_intra = atoi (argv[1]);
6426 ospf->distance_inter = atoi (argv[2]);
6427
paul718e3742002-12-13 20:15:29 +00006428 return CMD_SUCCESS;
6429}
6430
6431DEFUN (ospf_distance_ospf_external_inter_intra,
6432 ospf_distance_ospf_external_inter_intra_cmd,
6433 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6434 "Define an administrative distance\n"
6435 "OSPF Administrative distance\n"
6436 "External routes\n"
6437 "Distance for external routes\n"
6438 "Inter-area routes\n"
6439 "Distance for inter-area routes\n"
6440 "Intra-area routes\n"
6441 "Distance for intra-area routes\n")
6442{
paul68980082003-03-25 05:07:42 +00006443 struct ospf *ospf = vty->index;
6444
6445 ospf->distance_external = atoi (argv[0]);
6446 ospf->distance_inter = atoi (argv[1]);
6447 ospf->distance_intra = atoi (argv[2]);
6448
paul718e3742002-12-13 20:15:29 +00006449 return CMD_SUCCESS;
6450}
6451
6452DEFUN (ospf_distance_source,
6453 ospf_distance_source_cmd,
6454 "distance <1-255> A.B.C.D/M",
6455 "Administrative distance\n"
6456 "Distance value\n"
6457 "IP source prefix\n")
6458{
paul020709f2003-04-04 02:44:16 +00006459 struct ospf *ospf = vty->index;
6460
6461 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006462
paul718e3742002-12-13 20:15:29 +00006463 return CMD_SUCCESS;
6464}
6465
6466DEFUN (no_ospf_distance_source,
6467 no_ospf_distance_source_cmd,
6468 "no distance <1-255> A.B.C.D/M",
6469 NO_STR
6470 "Administrative distance\n"
6471 "Distance value\n"
6472 "IP source prefix\n")
6473{
paul020709f2003-04-04 02:44:16 +00006474 struct ospf *ospf = vty->index;
6475
6476 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6477
paul718e3742002-12-13 20:15:29 +00006478 return CMD_SUCCESS;
6479}
6480
6481DEFUN (ospf_distance_source_access_list,
6482 ospf_distance_source_access_list_cmd,
6483 "distance <1-255> A.B.C.D/M WORD",
6484 "Administrative distance\n"
6485 "Distance value\n"
6486 "IP source prefix\n"
6487 "Access list name\n")
6488{
paul020709f2003-04-04 02:44:16 +00006489 struct ospf *ospf = vty->index;
6490
6491 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6492
paul718e3742002-12-13 20:15:29 +00006493 return CMD_SUCCESS;
6494}
6495
6496DEFUN (no_ospf_distance_source_access_list,
6497 no_ospf_distance_source_access_list_cmd,
6498 "no distance <1-255> A.B.C.D/M WORD",
6499 NO_STR
6500 "Administrative distance\n"
6501 "Distance value\n"
6502 "IP source prefix\n"
6503 "Access list name\n")
6504{
paul020709f2003-04-04 02:44:16 +00006505 struct ospf *ospf = vty->index;
6506
6507 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6508
paul718e3742002-12-13 20:15:29 +00006509 return CMD_SUCCESS;
6510}
6511
6512void
6513show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6514{
6515 struct route_node *rn;
6516 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006517 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006518 struct ospf_path *path;
6519
6520 vty_out (vty, "============ OSPF network routing table ============%s",
6521 VTY_NEWLINE);
6522
6523 for (rn = route_top (rt); rn; rn = route_next (rn))
6524 if ((or = rn->info) != NULL)
6525 {
6526 char buf1[19];
6527 snprintf (buf1, 19, "%s/%d",
6528 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6529
6530 switch (or->path_type)
6531 {
6532 case OSPF_PATH_INTER_AREA:
6533 if (or->type == OSPF_DESTINATION_NETWORK)
6534 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6535 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6536 else if (or->type == OSPF_DESTINATION_DISCARD)
6537 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6538 break;
6539 case OSPF_PATH_INTRA_AREA:
6540 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6541 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6542 break;
6543 default:
6544 break;
6545 }
6546
6547 if (or->type == OSPF_DESTINATION_NETWORK)
paul96735ee2003-08-10 02:51:22 +00006548 LIST_LOOP (or->paths, path, pnode)
6549 {
6550 if (path->oi != NULL)
6551 {
6552 if (path->nexthop.s_addr == 0)
6553 vty_out (vty, "%24s directly attached to %s%s",
6554 "", path->oi->ifp->name, VTY_NEWLINE);
6555 else
6556 vty_out (vty, "%24s via %s, %s%s", "",
6557 inet_ntoa (path->nexthop), path->oi->ifp->name,
6558 VTY_NEWLINE);
6559 }
6560 }
paul718e3742002-12-13 20:15:29 +00006561 }
6562 vty_out (vty, "%s", VTY_NEWLINE);
6563}
6564
6565void
6566show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6567{
6568 struct route_node *rn;
6569 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006570 struct listnode *pn, *nn;
paul718e3742002-12-13 20:15:29 +00006571 struct ospf_path *path;
6572
6573 vty_out (vty, "============ OSPF router routing table =============%s",
6574 VTY_NEWLINE);
6575 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6576 if (rn->info)
6577 {
6578 int flag = 0;
6579
6580 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6581
hasso52dc7ee2004-09-23 19:18:23 +00006582 for (nn = listhead ((struct list *) rn->info); nn; nextnode (nn))
paul718e3742002-12-13 20:15:29 +00006583 if ((or = getdata (nn)) != NULL)
6584 {
6585 if (flag++)
paulb0a053b2003-06-22 09:04:47 +00006586 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006587
6588 /* Show path. */
6589 vty_out (vty, "%s [%d] area: %s",
6590 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6591 or->cost, inet_ntoa (or->u.std.area_id));
6592 /* Show flags. */
6593 vty_out (vty, "%s%s%s",
6594 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6595 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6596 VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006597
6598 LIST_LOOP (or->paths, path, pn)
6599 {
6600 if (path->nexthop.s_addr == 0)
6601 vty_out (vty, "%24s directly attached to %s%s",
6602 "", path->oi->ifp->name, VTY_NEWLINE);
6603 else
6604 vty_out (vty, "%24s via %s, %s%s", "",
6605 inet_ntoa (path->nexthop), path->oi->ifp->name,
6606 VTY_NEWLINE);
6607 }
paul718e3742002-12-13 20:15:29 +00006608 }
6609 }
6610 vty_out (vty, "%s", VTY_NEWLINE);
6611}
6612
6613void
6614show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6615{
6616 struct route_node *rn;
6617 struct ospf_route *er;
hasso52dc7ee2004-09-23 19:18:23 +00006618 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006619 struct ospf_path *path;
6620
6621 vty_out (vty, "============ OSPF external routing table ===========%s",
6622 VTY_NEWLINE);
6623 for (rn = route_top (rt); rn; rn = route_next (rn))
6624 if ((er = rn->info) != NULL)
6625 {
6626 char buf1[19];
6627 snprintf (buf1, 19, "%s/%d",
6628 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6629
6630 switch (er->path_type)
6631 {
6632 case OSPF_PATH_TYPE1_EXTERNAL:
6633 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6634 er->cost, er->u.ext.tag, VTY_NEWLINE);
6635 break;
6636 case OSPF_PATH_TYPE2_EXTERNAL:
6637 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6638 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6639 break;
6640 }
6641
paul96735ee2003-08-10 02:51:22 +00006642 LIST_LOOP (er->paths, path, pnode)
paul718e3742002-12-13 20:15:29 +00006643 {
paul718e3742002-12-13 20:15:29 +00006644 if (path->oi != NULL)
6645 {
6646 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006647 vty_out (vty, "%24s directly attached to %s%s",
6648 "", path->oi->ifp->name, VTY_NEWLINE);
6649 else
6650 vty_out (vty, "%24s via %s, %s%s", "",
6651 inet_ntoa (path->nexthop), path->oi->ifp->name,
6652 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006653 }
6654 }
6655 }
6656 vty_out (vty, "%s", VTY_NEWLINE);
6657}
6658
paul718e3742002-12-13 20:15:29 +00006659DEFUN (show_ip_ospf_border_routers,
6660 show_ip_ospf_border_routers_cmd,
6661 "show ip ospf border-routers",
6662 SHOW_STR
6663 IP_STR
6664 "show all the ABR's and ASBR's\n"
6665 "for this area\n")
6666{
paul020709f2003-04-04 02:44:16 +00006667 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006668
paul020709f2003-04-04 02:44:16 +00006669 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006670 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006671 {
6672 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6673 return CMD_SUCCESS;
6674 }
6675
paul68980082003-03-25 05:07:42 +00006676 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006677 {
6678 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6679 return CMD_SUCCESS;
6680 }
6681
6682 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006683 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006684
6685 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006686 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006687
6688 return CMD_SUCCESS;
6689}
paul718e3742002-12-13 20:15:29 +00006690
6691DEFUN (show_ip_ospf_route,
6692 show_ip_ospf_route_cmd,
6693 "show ip ospf route",
6694 SHOW_STR
6695 IP_STR
6696 "OSPF information\n"
6697 "OSPF routing table\n")
6698{
paul020709f2003-04-04 02:44:16 +00006699 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006700
paul020709f2003-04-04 02:44:16 +00006701 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006702 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006703 {
6704 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6705 return CMD_SUCCESS;
6706 }
6707
paul68980082003-03-25 05:07:42 +00006708 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006709 {
6710 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6711 return CMD_SUCCESS;
6712 }
6713
6714 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006715 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006716
6717 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006718 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006719
6720 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006721 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006722
6723 return CMD_SUCCESS;
6724}
6725
6726
hassoeb1ce602004-10-08 08:17:22 +00006727const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006728{
6729 "unknown",
6730 "standard",
6731 "ibm",
6732 "cisco",
6733 "shortcut"
6734};
6735
hassoeb1ce602004-10-08 08:17:22 +00006736const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006737{
6738 "default",
6739 "enable",
6740 "disable"
6741};
6742
6743
6744void
6745area_id2str (char *buf, int length, struct ospf_area *area)
6746{
6747 memset (buf, 0, length);
6748
6749 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6750 strncpy (buf, inet_ntoa (area->area_id), length);
6751 else
6752 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6753}
6754
6755
hassoeb1ce602004-10-08 08:17:22 +00006756const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006757{
6758 "unknown", /* should never be used. */
6759 "point-to-point",
6760 "broadcast",
6761 "non-broadcast",
6762 "point-to-multipoint",
6763 "virtual-link", /* should never be used. */
6764 "loopback"
6765};
6766
6767/* Configuration write function for ospfd. */
6768int
6769config_write_interface (struct vty *vty)
6770{
hasso52dc7ee2004-09-23 19:18:23 +00006771 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006772 struct interface *ifp;
6773 struct crypt_key *ck;
6774 int write = 0;
6775 struct route_node *rn = NULL;
6776 struct ospf_if_params *params;
6777
6778 for (n1 = listhead (iflist); n1; nextnode (n1))
6779 {
6780 ifp = getdata (n1);
6781
6782 if (memcmp (ifp->name, "VLINK", 5) == 0)
6783 continue;
6784
6785 vty_out (vty, "!%s", VTY_NEWLINE);
6786 vty_out (vty, "interface %s%s", ifp->name,
6787 VTY_NEWLINE);
6788 if (ifp->desc)
6789 vty_out (vty, " description %s%s", ifp->desc,
6790 VTY_NEWLINE);
6791
6792 write++;
6793
6794 params = IF_DEF_PARAMS (ifp);
6795
6796 do {
6797 /* Interface Network print. */
6798 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006799 params->type != OSPF_IFTYPE_LOOPBACK)
6800 {
ajsbc18d612004-12-15 15:07:19 +00006801 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006802 {
6803 vty_out (vty, " ip ospf network %s",
6804 ospf_int_type_str[params->type]);
6805 if (params != IF_DEF_PARAMS (ifp))
6806 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6807 vty_out (vty, "%s", VTY_NEWLINE);
6808 }
paul718e3742002-12-13 20:15:29 +00006809 }
6810
6811 /* OSPF interface authentication print */
6812 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6813 params->auth_type != OSPF_AUTH_NOTSET)
6814 {
hassoeb1ce602004-10-08 08:17:22 +00006815 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006816
6817 /* Translation tables are not that much help here due to syntax
6818 of the simple option */
6819 switch (params->auth_type)
6820 {
6821
6822 case OSPF_AUTH_NULL:
6823 auth_str = " null";
6824 break;
6825
6826 case OSPF_AUTH_SIMPLE:
6827 auth_str = "";
6828 break;
6829
6830 case OSPF_AUTH_CRYPTOGRAPHIC:
6831 auth_str = " message-digest";
6832 break;
6833
6834 default:
6835 auth_str = "";
6836 break;
6837 }
6838
6839 vty_out (vty, " ip ospf authentication%s", auth_str);
6840 if (params != IF_DEF_PARAMS (ifp))
6841 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6842 vty_out (vty, "%s", VTY_NEWLINE);
6843 }
6844
6845 /* Simple Authentication Password print. */
6846 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6847 params->auth_simple[0] != '\0')
6848 {
6849 vty_out (vty, " ip ospf authentication-key %s",
6850 params->auth_simple);
6851 if (params != IF_DEF_PARAMS (ifp))
6852 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6853 vty_out (vty, "%s", VTY_NEWLINE);
6854 }
6855
6856 /* Cryptographic Authentication Key print. */
6857 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
6858 {
6859 ck = getdata (n2);
6860 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6861 ck->key_id, ck->auth_key);
6862 if (params != IF_DEF_PARAMS (ifp))
6863 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6864 vty_out (vty, "%s", VTY_NEWLINE);
6865 }
6866
6867 /* Interface Output Cost print. */
6868 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6869 {
6870 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6871 if (params != IF_DEF_PARAMS (ifp))
6872 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6873 vty_out (vty, "%s", VTY_NEWLINE);
6874 }
6875
6876 /* Hello Interval print. */
6877 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6878 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6879 {
6880 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6881 if (params != IF_DEF_PARAMS (ifp))
6882 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6883 vty_out (vty, "%s", VTY_NEWLINE);
6884 }
6885
6886
6887 /* Router Dead Interval print. */
6888 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6889 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6890 {
6891 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6892 if (params != IF_DEF_PARAMS (ifp))
6893 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6894 vty_out (vty, "%s", VTY_NEWLINE);
6895 }
6896
6897 /* Router Priority print. */
6898 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6899 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6900 {
6901 vty_out (vty, " ip ospf priority %u", params->priority);
6902 if (params != IF_DEF_PARAMS (ifp))
6903 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6904 vty_out (vty, "%s", VTY_NEWLINE);
6905 }
6906
6907 /* Retransmit Interval print. */
6908 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6909 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6910 {
6911 vty_out (vty, " ip ospf retransmit-interval %u",
6912 params->retransmit_interval);
6913 if (params != IF_DEF_PARAMS (ifp))
6914 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6915 vty_out (vty, "%s", VTY_NEWLINE);
6916 }
6917
6918 /* Transmit Delay print. */
6919 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6920 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6921 {
6922 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6923 if (params != IF_DEF_PARAMS (ifp))
6924 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6925 vty_out (vty, "%s", VTY_NEWLINE);
6926 }
6927
6928 while (1)
6929 {
6930 if (rn == NULL)
6931 rn = route_top (IF_OIFS_PARAMS (ifp));
6932 else
6933 rn = route_next (rn);
6934
6935 if (rn == NULL)
6936 break;
6937 params = rn->info;
6938 if (params != NULL)
6939 break;
6940 }
6941 } while (rn);
6942
6943#ifdef HAVE_OPAQUE_LSA
6944 ospf_opaque_config_write_if (vty, ifp);
6945#endif /* HAVE_OPAQUE_LSA */
6946 }
6947
6948 return write;
6949}
6950
6951int
paul68980082003-03-25 05:07:42 +00006952config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006953{
6954 struct route_node *rn;
6955 u_char buf[INET_ADDRSTRLEN];
6956
6957 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006958 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006959 if (rn->info)
6960 {
6961 struct ospf_network *n = rn->info;
6962
6963 memset (buf, 0, INET_ADDRSTRLEN);
6964
6965 /* Create Area ID string by specified Area ID format. */
6966 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00006967 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00006968 else
hassoc9e52be2004-09-26 16:09:34 +00006969 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00006970 (unsigned long int) ntohl (n->area_id.s_addr));
6971
6972 /* Network print. */
6973 vty_out (vty, " network %s/%d area %s%s",
6974 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6975 buf, VTY_NEWLINE);
6976 }
6977
6978 return 0;
6979}
6980
6981int
paul68980082003-03-25 05:07:42 +00006982config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006983{
hasso52dc7ee2004-09-23 19:18:23 +00006984 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006985 u_char buf[INET_ADDRSTRLEN];
6986
6987 /* Area configuration print. */
paul68980082003-03-25 05:07:42 +00006988 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00006989 {
6990 struct ospf_area *area = getdata (node);
6991 struct route_node *rn1;
6992
hassoc9e52be2004-09-26 16:09:34 +00006993 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00006994
6995 if (area->auth_type != OSPF_AUTH_NULL)
6996 {
6997 if (area->auth_type == OSPF_AUTH_SIMPLE)
6998 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6999 else
7000 vty_out (vty, " area %s authentication message-digest%s",
7001 buf, VTY_NEWLINE);
7002 }
7003
7004 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7005 vty_out (vty, " area %s shortcut %s%s", buf,
7006 ospf_shortcut_mode_str[area->shortcut_configured],
7007 VTY_NEWLINE);
7008
7009 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007010 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007011 )
7012 {
paulb0a053b2003-06-22 09:04:47 +00007013 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007014 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007015 else if (area->external_routing == OSPF_AREA_NSSA)
7016 {
7017 vty_out (vty, " area %s nssa", buf);
7018 switch (area->NSSATranslatorRole)
7019 {
7020 case OSPF_NSSA_ROLE_NEVER:
7021 vty_out (vty, " translate-never");
7022 break;
7023 case OSPF_NSSA_ROLE_ALWAYS:
7024 vty_out (vty, " translate-always");
7025 break;
7026 case OSPF_NSSA_ROLE_CANDIDATE:
7027 default:
7028 vty_out (vty, " translate-candidate");
7029 }
7030 }
paul718e3742002-12-13 20:15:29 +00007031
7032 if (area->no_summary)
7033 vty_out (vty, " no-summary");
7034
7035 vty_out (vty, "%s", VTY_NEWLINE);
7036
7037 if (area->default_cost != 1)
7038 vty_out (vty, " area %s default-cost %d%s", buf,
7039 area->default_cost, VTY_NEWLINE);
7040 }
7041
7042 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7043 if (rn1->info)
7044 {
7045 struct ospf_area_range *range = rn1->info;
7046
7047 vty_out (vty, " area %s range %s/%d", buf,
7048 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7049
paul6c835672004-10-11 11:00:30 +00007050 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007051 vty_out (vty, " cost %d", range->cost_config);
7052
7053 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7054 vty_out (vty, " not-advertise");
7055
7056 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7057 vty_out (vty, " substitute %s/%d",
7058 inet_ntoa (range->subst_addr), range->subst_masklen);
7059
7060 vty_out (vty, "%s", VTY_NEWLINE);
7061 }
7062
7063 if (EXPORT_NAME (area))
7064 vty_out (vty, " area %s export-list %s%s", buf,
7065 EXPORT_NAME (area), VTY_NEWLINE);
7066
7067 if (IMPORT_NAME (area))
7068 vty_out (vty, " area %s import-list %s%s", buf,
7069 IMPORT_NAME (area), VTY_NEWLINE);
7070
7071 if (PREFIX_NAME_IN (area))
7072 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7073 PREFIX_NAME_IN (area), VTY_NEWLINE);
7074
7075 if (PREFIX_NAME_OUT (area))
7076 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7077 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7078 }
7079
7080 return 0;
7081}
7082
7083int
paul68980082003-03-25 05:07:42 +00007084config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007085{
7086 struct ospf_nbr_nbma *nbr_nbma;
7087 struct route_node *rn;
7088
7089 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007090 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007091 if ((nbr_nbma = rn->info))
7092 {
7093 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7094
7095 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7096 vty_out (vty, " priority %d", nbr_nbma->priority);
7097
7098 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7099 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7100
7101 vty_out (vty, "%s", VTY_NEWLINE);
7102 }
7103
7104 return 0;
7105}
7106
7107int
paul68980082003-03-25 05:07:42 +00007108config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007109{
hasso52dc7ee2004-09-23 19:18:23 +00007110 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007111 u_char buf[INET_ADDRSTRLEN];
7112
7113 /* Virtual-Link print */
paul68980082003-03-25 05:07:42 +00007114 for (node = listhead (ospf->vlinks); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007115 {
hasso52dc7ee2004-09-23 19:18:23 +00007116 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007117 struct crypt_key *ck;
7118 struct ospf_vl_data *vl_data = getdata (node);
7119 struct ospf_interface *oi;
7120
7121 if (vl_data != NULL)
7122 {
7123 memset (buf, 0, INET_ADDRSTRLEN);
7124
7125 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007126 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007127 else
hassoc9e52be2004-09-26 16:09:34 +00007128 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007129 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7130 oi = vl_data->vl_oi;
7131
7132 /* timers */
7133 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7134 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7135 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7136 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7137 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7138 buf,
7139 inet_ntoa (vl_data->vl_peer),
7140 OSPF_IF_PARAM (oi, v_hello),
7141 OSPF_IF_PARAM (oi, retransmit_interval),
7142 OSPF_IF_PARAM (oi, transmit_delay),
7143 OSPF_IF_PARAM (oi, v_wait),
7144 VTY_NEWLINE);
7145 else
7146 vty_out (vty, " area %s virtual-link %s%s", buf,
7147 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7148 /* Auth key */
7149 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7150 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7151 buf,
7152 inet_ntoa (vl_data->vl_peer),
7153 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7154 VTY_NEWLINE);
7155 /* md5 keys */
7156 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
7157 {
7158 ck = getdata (n2);
7159 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
7160 buf,
7161 inet_ntoa (vl_data->vl_peer),
7162 ck->key_id, ck->auth_key, VTY_NEWLINE);
7163 }
7164
7165 }
7166 }
7167
7168 return 0;
7169}
7170
7171
hassoeb1ce602004-10-08 08:17:22 +00007172const char *distribute_str[] = { "system", "kernel", "connected", "static",
7173 "rip", "ripng", "ospf", "ospf6", "isis", "bgp"};
paul718e3742002-12-13 20:15:29 +00007174int
paul68980082003-03-25 05:07:42 +00007175config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007176{
7177 int type;
7178
7179 /* redistribute print. */
7180 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7181 if (type != zclient->redist_default && zclient->redist[type])
7182 {
7183 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007184 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007185 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007186
paul68980082003-03-25 05:07:42 +00007187 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007188 vty_out (vty, " metric-type 1");
7189
paul020709f2003-04-04 02:44:16 +00007190 if (ROUTEMAP_NAME (ospf, type))
7191 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007192
7193 vty_out (vty, "%s", VTY_NEWLINE);
7194 }
7195
7196 return 0;
7197}
7198
7199int
paul68980082003-03-25 05:07:42 +00007200config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007201{
paul68980082003-03-25 05:07:42 +00007202 if (ospf->default_metric != -1)
7203 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007204 VTY_NEWLINE);
7205 return 0;
7206}
7207
7208int
paul68980082003-03-25 05:07:42 +00007209config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007210{
7211 int type;
7212
paul68980082003-03-25 05:07:42 +00007213 if (ospf)
paul718e3742002-12-13 20:15:29 +00007214 {
7215 /* distribute-list print. */
7216 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007217 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007218 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007219 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007220 distribute_str[type], VTY_NEWLINE);
7221
7222 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007223 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007224 {
paul68980082003-03-25 05:07:42 +00007225 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007226 vty_out (vty, " default-information originate");
7227 else
7228 vty_out (vty, " default-information originate always");
7229
paul68980082003-03-25 05:07:42 +00007230 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007231 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007232 ospf->dmetric[DEFAULT_ROUTE].value);
7233 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007234 vty_out (vty, " metric-type 1");
7235
paul020709f2003-04-04 02:44:16 +00007236 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7237 vty_out (vty, " route-map %s",
7238 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007239
7240 vty_out (vty, "%s", VTY_NEWLINE);
7241 }
7242
7243 }
7244
7245 return 0;
7246}
7247
7248int
paul68980082003-03-25 05:07:42 +00007249config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007250{
7251 struct route_node *rn;
7252 struct ospf_distance *odistance;
7253
paul68980082003-03-25 05:07:42 +00007254 if (ospf->distance_all)
7255 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007256
paul68980082003-03-25 05:07:42 +00007257 if (ospf->distance_intra
7258 || ospf->distance_inter
7259 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007260 {
7261 vty_out (vty, " distance ospf");
7262
paul68980082003-03-25 05:07:42 +00007263 if (ospf->distance_intra)
7264 vty_out (vty, " intra-area %d", ospf->distance_intra);
7265 if (ospf->distance_inter)
7266 vty_out (vty, " inter-area %d", ospf->distance_inter);
7267 if (ospf->distance_external)
7268 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007269
7270 vty_out (vty, "%s", VTY_NEWLINE);
7271 }
7272
paul68980082003-03-25 05:07:42 +00007273 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007274 if ((odistance = rn->info) != NULL)
7275 {
7276 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7277 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7278 odistance->access_list ? odistance->access_list : "",
7279 VTY_NEWLINE);
7280 }
7281 return 0;
7282}
7283
7284/* OSPF configuration write function. */
7285int
7286ospf_config_write (struct vty *vty)
7287{
paul020709f2003-04-04 02:44:16 +00007288 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00007289 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007290 int write = 0;
7291
paul020709f2003-04-04 02:44:16 +00007292 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007293 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007294 {
7295 /* `router ospf' print. */
7296 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7297
7298 write++;
7299
paul68980082003-03-25 05:07:42 +00007300 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007301 return write;
7302
7303 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007304 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007305 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007306 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007307
7308 /* ABR type print. */
paul68980082003-03-25 05:07:42 +00007309 if (ospf->abr_type != OSPF_ABR_STAND)
paul718e3742002-12-13 20:15:29 +00007310 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007311 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007312
7313 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007314 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007315 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7316
7317 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007318 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007319 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007320 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007321
7322 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007323 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7324 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007325 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007326 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007327
7328 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007329 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007330 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007331 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007332
7333 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007334 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007335
7336 /* passive-interface print. */
paul020709f2003-04-04 02:44:16 +00007337 for (node = listhead (om->iflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007338 {
7339 struct interface *ifp = getdata (node);
7340
7341 if (!ifp)
7342 continue;
7343 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7344 vty_out (vty, " passive-interface %s%s",
7345 ifp->name, VTY_NEWLINE);
7346 }
7347
paul68980082003-03-25 05:07:42 +00007348 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007349 {
7350 struct ospf_interface *oi = getdata (node);
7351
7352 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7353 oi->params->passive_interface == OSPF_IF_PASSIVE)
paul96735ee2003-08-10 02:51:22 +00007354 vty_out (vty, " passive-interface %s %s%s",
7355 oi->ifp->name,
paul5fdc1e52003-08-06 22:41:29 +00007356 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007357 }
7358
7359
7360 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007361 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007362
7363 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007364 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007365
7366 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007367 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007368
7369 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007370 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007371
7372 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007373 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007374
7375 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007376 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007377
7378 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007379 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007380
7381#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007382 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007383#endif /* HAVE_OPAQUE_LSA */
7384 }
7385
7386 return write;
7387}
7388
7389void
7390ospf_vty_show_init ()
7391{
7392 /* "show ip ospf" commands. */
7393 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7394 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7395
7396 /* "show ip ospf database" commands. */
7397 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7398 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7399 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7400 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7401 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7402 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7403 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7404 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7405 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7406 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7407 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7408 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7409 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7410 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7411
7412 /* "show ip ospf interface" commands. */
7413 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7414 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7415
7416 /* "show ip ospf neighbor" commands. */
7417 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7418 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7419 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7420 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7421 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7422 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7423 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7424 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7425 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7426 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7427 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7428 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7429 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7430 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7431
7432 /* "show ip ospf route" commands. */
7433 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7434 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007435 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7436 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007437}
7438
7439
7440/* ospfd's interface node. */
7441struct cmd_node interface_node =
7442{
7443 INTERFACE_NODE,
7444 "%s(config-if)# ",
7445 1
7446};
7447
7448/* Initialization of OSPF interface. */
7449void
7450ospf_vty_if_init ()
7451{
7452 /* Install interface node. */
7453 install_node (&interface_node, config_write_interface);
7454
7455 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007456 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007457 install_default (INTERFACE_NODE);
7458
7459 /* "description" commands. */
7460 install_element (INTERFACE_NODE, &interface_desc_cmd);
7461 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7462
7463 /* "ip ospf authentication" commands. */
7464 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7465 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7466 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7467 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7468 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7469 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7470 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7471 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7472 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7473 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7474
7475 /* "ip ospf message-digest-key" commands. */
7476 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7477 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7478 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7479 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7480
7481 /* "ip ospf cost" commands. */
7482 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7483 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7484 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7485 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7486
7487 /* "ip ospf dead-interval" commands. */
7488 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7489 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7490 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7491 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7492
7493 /* "ip ospf hello-interval" commands. */
7494 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7495 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7496 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7497 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7498
7499 /* "ip ospf network" commands. */
7500 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7501 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7502
7503 /* "ip ospf priority" commands. */
7504 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7505 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7506 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7507 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7508
7509 /* "ip ospf retransmit-interval" commands. */
7510 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7511 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7512 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7513 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7514
7515 /* "ip ospf transmit-delay" commands. */
7516 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7517 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7518 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7519 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7520
7521 /* These commands are compatibitliy for previous version. */
7522 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7523 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7524 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7525 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7526 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7527 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7528 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7529 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7530 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7531 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7532 install_element (INTERFACE_NODE, &ospf_network_cmd);
7533 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7534 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7535 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7536 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7537 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7538 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7539 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7540}
7541
7542/* Zebra node structure. */
7543struct cmd_node zebra_node =
7544{
7545 ZEBRA_NODE,
7546 "%s(config-router)#",
7547};
7548
7549void
7550ospf_vty_zebra_init ()
7551{
7552 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7553 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7554 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7555 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7556 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7557 install_element (OSPF_NODE,
7558 &ospf_redistribute_source_metric_type_routemap_cmd);
7559 install_element (OSPF_NODE,
7560 &ospf_redistribute_source_type_metric_routemap_cmd);
7561 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7562 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7563 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7564
7565 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7566
7567 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7568 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7569
7570 install_element (OSPF_NODE,
7571 &ospf_default_information_originate_metric_type_cmd);
7572 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7573 install_element (OSPF_NODE,
7574 &ospf_default_information_originate_type_metric_cmd);
7575 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7576 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7577 install_element (OSPF_NODE,
7578 &ospf_default_information_originate_always_metric_type_cmd);
7579 install_element (OSPF_NODE,
7580 &ospf_default_information_originate_always_metric_cmd);
7581 install_element (OSPF_NODE,
7582 &ospf_default_information_originate_always_cmd);
7583 install_element (OSPF_NODE,
7584 &ospf_default_information_originate_always_type_metric_cmd);
7585 install_element (OSPF_NODE,
7586 &ospf_default_information_originate_always_type_cmd);
7587
7588 install_element (OSPF_NODE,
7589 &ospf_default_information_originate_metric_type_routemap_cmd);
7590 install_element (OSPF_NODE,
7591 &ospf_default_information_originate_metric_routemap_cmd);
7592 install_element (OSPF_NODE,
7593 &ospf_default_information_originate_routemap_cmd);
7594 install_element (OSPF_NODE,
7595 &ospf_default_information_originate_type_metric_routemap_cmd);
7596 install_element (OSPF_NODE,
7597 &ospf_default_information_originate_type_routemap_cmd);
7598 install_element (OSPF_NODE,
7599 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7600 install_element (OSPF_NODE,
7601 &ospf_default_information_originate_always_metric_routemap_cmd);
7602 install_element (OSPF_NODE,
7603 &ospf_default_information_originate_always_routemap_cmd);
7604 install_element (OSPF_NODE,
7605 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7606 install_element (OSPF_NODE,
7607 &ospf_default_information_originate_always_type_routemap_cmd);
7608
7609 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7610
7611 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7612 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7613 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7614
7615 install_element (OSPF_NODE, &ospf_distance_cmd);
7616 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7617 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7618 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7619 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7620 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7621 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7622 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7623 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7624 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7625 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7626 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7627 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7628 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7629 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7630 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7631 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7632 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7633#if 0
7634 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7635 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7636 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7637 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7638#endif /* 0 */
7639}
7640
7641struct cmd_node ospf_node =
7642{
7643 OSPF_NODE,
7644 "%s(config-router)# ",
7645 1
7646};
7647
7648
7649/* Install OSPF related vty commands. */
7650void
7651ospf_vty_init ()
7652{
7653 /* Install ospf top node. */
7654 install_node (&ospf_node, ospf_config_write);
7655
7656 /* "router ospf" commands. */
7657 install_element (CONFIG_NODE, &router_ospf_cmd);
7658 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7659
7660 install_default (OSPF_NODE);
7661
7662 /* "ospf router-id" commands. */
7663 install_element (OSPF_NODE, &ospf_router_id_cmd);
7664 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007665 install_element (OSPF_NODE, &router_ospf_id_cmd);
7666 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007667
7668 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007669 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7670 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7671 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7672 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007673
7674 /* "ospf abr-type" commands. */
7675 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7676 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7677
7678 /* "ospf rfc1583-compatible" commands. */
7679 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7680 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7681 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7682 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7683
7684 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007685 install_element (OSPF_NODE, &ospf_network_area_cmd);
7686 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007687
7688 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007689 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7690 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7691 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007692
7693 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007694 install_element (OSPF_NODE, &ospf_area_range_cmd);
7695 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7696 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7697 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7698 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7699 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7700 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7701 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7702 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7703 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7704 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007705
7706 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007707 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7708 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007709
paula2c62832003-04-23 17:01:31 +00007710 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7711 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007712
paula2c62832003-04-23 17:01:31 +00007713 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7714 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007715
paula2c62832003-04-23 17:01:31 +00007716 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7717 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007718
paula2c62832003-04-23 17:01:31 +00007719 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7720 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007721
paula2c62832003-04-23 17:01:31 +00007722 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7723 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7724 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007725
paula2c62832003-04-23 17:01:31 +00007726 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7727 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007728
paula2c62832003-04-23 17:01:31 +00007729 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7730 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007731
paula2c62832003-04-23 17:01:31 +00007732 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7733 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7734 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007735
paula2c62832003-04-23 17:01:31 +00007736 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7737 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7738 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007739
7740 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007741 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7742 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7743 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7744 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007745
paul718e3742002-12-13 20:15:29 +00007746 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007747 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7748 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7749 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7750 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7751 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7752 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007753
paula2c62832003-04-23 17:01:31 +00007754 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7755 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007756
paula2c62832003-04-23 17:01:31 +00007757 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7758 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007759
paula2c62832003-04-23 17:01:31 +00007760 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7761 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007762
paula2c62832003-04-23 17:01:31 +00007763 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7764 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007765
paula2c62832003-04-23 17:01:31 +00007766 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7767 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007768
paula2c62832003-04-23 17:01:31 +00007769 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7770 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007771
paula2c62832003-04-23 17:01:31 +00007772 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7773 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7774 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007775
paula2c62832003-04-23 17:01:31 +00007776 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7777 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007778
7779 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007780 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7781 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7782 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7783 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7784 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7785 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7786 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7787 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007788
7789 /* Init interface related vty commands. */
7790 ospf_vty_if_init ();
7791
7792 /* Init zebra related vty commands. */
7793 ospf_vty_zebra_init ();
7794}