blob: 1d2550d3fd128c8ea87129caa987309dd3343b10 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* OSPF VTY interface.
2 * Copyright (C) 2000 Toshiaki Takada
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22#include <zebra.h>
23
24#include "memory.h"
25#include "thread.h"
26#include "prefix.h"
27#include "table.h"
28#include "vty.h"
29#include "command.h"
30#include "plist.h"
31#include "log.h"
32#include "zclient.h"
33
34#include "ospfd/ospfd.h"
35#include "ospfd/ospf_asbr.h"
36#include "ospfd/ospf_lsa.h"
37#include "ospfd/ospf_lsdb.h"
38#include "ospfd/ospf_ism.h"
39#include "ospfd/ospf_interface.h"
40#include "ospfd/ospf_nsm.h"
41#include "ospfd/ospf_neighbor.h"
42#include "ospfd/ospf_flood.h"
43#include "ospfd/ospf_abr.h"
44#include "ospfd/ospf_spf.h"
45#include "ospfd/ospf_route.h"
46#include "ospfd/ospf_zebra.h"
47/*#include "ospfd/ospf_routemap.h" */
48#include "ospfd/ospf_vty.h"
49#include "ospfd/ospf_dump.h"
50
51
hassoeb1ce602004-10-08 08:17:22 +000052const static char *ospf_network_type_str[] =
paul718e3742002-12-13 20:15:29 +000053{
54 "Null",
55 "POINTOPOINT",
56 "BROADCAST",
57 "NBMA",
58 "POINTOMULTIPOINT",
59 "VIRTUALLINK",
60 "LOOPBACK"
61};
62
63
64/* Utility functions. */
65int
paul6c835672004-10-11 11:00:30 +000066ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
paul718e3742002-12-13 20:15:29 +000067{
68 char *endptr = NULL;
69 unsigned long ret;
70
71 /* match "A.B.C.D". */
72 if (strchr (str, '.') != NULL)
73 {
74 ret = inet_aton (str, area_id);
75 if (!ret)
76 return -1;
77 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
78 }
79 /* match "<0-4294967295>". */
80 else
81 {
82 ret = strtoul (str, &endptr, 10);
83 if (*endptr != '\0' || (ret == ULONG_MAX && errno == ERANGE))
84 return -1;
85
86 area_id->s_addr = htonl (ret);
87 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
88 }
89
90 return 0;
91}
92
93
94int
paul6c835672004-10-11 11:00:30 +000095str2distribute_source (const char *str, int *source)
paul718e3742002-12-13 20:15:29 +000096{
97 /* Sanity check. */
98 if (str == NULL)
99 return 0;
100
101 if (strncmp (str, "k", 1) == 0)
102 *source = ZEBRA_ROUTE_KERNEL;
103 else if (strncmp (str, "c", 1) == 0)
104 *source = ZEBRA_ROUTE_CONNECT;
105 else if (strncmp (str, "s", 1) == 0)
106 *source = ZEBRA_ROUTE_STATIC;
107 else if (strncmp (str, "r", 1) == 0)
108 *source = ZEBRA_ROUTE_RIP;
109 else if (strncmp (str, "b", 1) == 0)
110 *source = ZEBRA_ROUTE_BGP;
111 else
112 return 0;
113
114 return 1;
115}
116
117int
paul6c835672004-10-11 11:00:30 +0000118str2metric (const char *str, int *metric)
paul718e3742002-12-13 20:15:29 +0000119{
120 /* Sanity check. */
121 if (str == NULL)
122 return 0;
123
124 *metric = strtol (str, NULL, 10);
125 if (*metric < 0 && *metric > 16777214)
126 {
127 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
128 return 0;
129 }
130
131 return 1;
132}
133
134int
paul6c835672004-10-11 11:00:30 +0000135str2metric_type (const char *str, int *metric_type)
paul718e3742002-12-13 20:15:29 +0000136{
137 /* Sanity check. */
138 if (str == NULL)
139 return 0;
140
141 if (strncmp (str, "1", 1) == 0)
142 *metric_type = EXTERNAL_METRIC_TYPE_1;
143 else if (strncmp (str, "2", 1) == 0)
144 *metric_type = EXTERNAL_METRIC_TYPE_2;
145 else
146 return 0;
147
148 return 1;
149}
150
151int
152ospf_oi_count (struct interface *ifp)
153{
154 struct route_node *rn;
155 int i = 0;
156
157 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
158 if (rn->info)
159 i++;
160
161 return i;
162}
163
164
165DEFUN (router_ospf,
166 router_ospf_cmd,
167 "router ospf",
168 "Enable a routing process\n"
169 "Start OSPF configuration\n")
170{
171 vty->node = OSPF_NODE;
172 vty->index = ospf_get ();
173
174 return CMD_SUCCESS;
175}
176
177DEFUN (no_router_ospf,
178 no_router_ospf_cmd,
179 "no router ospf",
180 NO_STR
181 "Enable a routing process\n"
182 "Start OSPF configuration\n")
183{
paul020709f2003-04-04 02:44:16 +0000184 struct ospf *ospf;
185
186 ospf = ospf_lookup ();
187 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000188 {
paul020709f2003-04-04 02:44:16 +0000189 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000190 return CMD_WARNING;
191 }
192
paul020709f2003-04-04 02:44:16 +0000193 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000194
195 return CMD_SUCCESS;
196}
197
198DEFUN (ospf_router_id,
199 ospf_router_id_cmd,
200 "ospf router-id A.B.C.D",
201 "OSPF specific commands\n"
202 "router-id for the OSPF process\n"
203 "OSPF router-id in IP address format\n")
204{
paul68980082003-03-25 05:07:42 +0000205 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000206 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000207 int ret;
paul718e3742002-12-13 20:15:29 +0000208
209 ret = inet_aton (argv[0], &router_id);
210 if (!ret)
211 {
212 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
213 return CMD_WARNING;
214 }
215
paul68980082003-03-25 05:07:42 +0000216 ospf->router_id_static = router_id;
paul718e3742002-12-13 20:15:29 +0000217
paul68980082003-03-25 05:07:42 +0000218 if (ospf->t_router_id_update == NULL)
paul020709f2003-04-04 02:44:16 +0000219 OSPF_TIMER_ON (ospf->t_router_id_update, ospf_router_id_update_timer,
220 OSPF_ROUTER_ID_UPDATE_DELAY);
paul718e3742002-12-13 20:15:29 +0000221
222 return CMD_SUCCESS;
223}
224
225ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000226 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000227 "router-id A.B.C.D",
228 "router-id for the OSPF process\n"
229 "OSPF router-id in IP address format\n")
230
231DEFUN (no_ospf_router_id,
232 no_ospf_router_id_cmd,
233 "no ospf router-id",
234 NO_STR
235 "OSPF specific commands\n"
236 "router-id for the OSPF process\n")
237{
paul68980082003-03-25 05:07:42 +0000238 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000239
paul68980082003-03-25 05:07:42 +0000240 ospf->router_id_static.s_addr = 0;
241
242 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000243
244 return CMD_SUCCESS;
245}
246
247ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000248 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000249 "no router-id",
250 NO_STR
251 "router-id for the OSPF process\n")
252
paula2c62832003-04-23 17:01:31 +0000253DEFUN (ospf_passive_interface,
254 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000255 "passive-interface IFNAME A.B.C.D",
256 "Suppress routing updates on an interface\n"
257 "Interface's name\n")
258{
259 struct interface *ifp;
260 struct in_addr addr;
261 int ret;
262 struct ospf_if_params *params;
ajsba6454e2005-02-08 15:37:30 +0000263 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000264
265 ifp = if_lookup_by_name (argv[0]);
266
267 if (ifp == NULL)
268 {
269 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
270 return CMD_WARNING;
271 }
272
273 params = IF_DEF_PARAMS (ifp);
274
275 if (argc == 2)
276 {
277 ret = inet_aton(argv[1], &addr);
278 if (!ret)
279 {
280 vty_out (vty, "Please specify interface address by A.B.C.D%s",
281 VTY_NEWLINE);
282 return CMD_WARNING;
283 }
284
285 params = ospf_get_if_params (ifp, addr);
286 ospf_if_update_params (ifp, addr);
287 }
288
289 SET_IF_PARAM (params, passive_interface);
290 params->passive_interface = OSPF_IF_PASSIVE;
ajsba6454e2005-02-08 15:37:30 +0000291
292 /* XXX We should call ospf_if_set_multicast on exactly those
293 * interfaces for which the passive property changed. It is too much
294 * work to determine this set, so we do this for every interface.
295 * This is safe and reasonable because ospf_if_set_multicast uses a
296 * record of joined groups to avoid systems calls if the desired
297 * memberships match the current memership.
298 */
299 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
300 {
301 struct ospf_interface *oi = rn->info;
302
303 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
304 ospf_if_set_multicast(oi);
305 }
306 /*
307 * XXX It is not clear what state transitions the interface needs to
308 * undergo when going from active to passive. Fixing this will
309 * require precise identification of interfaces having such a
310 * transition.
311 */
312
paul718e3742002-12-13 20:15:29 +0000313 return CMD_SUCCESS;
314}
315
paula2c62832003-04-23 17:01:31 +0000316ALIAS (ospf_passive_interface,
317 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000318 "passive-interface IFNAME",
319 "Suppress routing updates on an interface\n"
320 "Interface's name\n")
321
paula2c62832003-04-23 17:01:31 +0000322DEFUN (no_ospf_passive_interface,
323 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000324 "no passive-interface IFNAME A.B.C.D",
325 NO_STR
326 "Allow routing updates on an interface\n"
327 "Interface's name\n")
328{
329 struct interface *ifp;
330 struct in_addr addr;
331 struct ospf_if_params *params;
332 int ret;
ajsba6454e2005-02-08 15:37:30 +0000333 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +0000334
335 ifp = if_lookup_by_name (argv[0]);
336
337 if (ifp == NULL)
338 {
339 vty_out (vty, "Please specify an existing interface%s", VTY_NEWLINE);
340 return CMD_WARNING;
341 }
342
343 params = IF_DEF_PARAMS (ifp);
344
345 if (argc == 2)
346 {
347 ret = inet_aton(argv[1], &addr);
348 if (!ret)
349 {
350 vty_out (vty, "Please specify interface address by A.B.C.D%s",
351 VTY_NEWLINE);
352 return CMD_WARNING;
353 }
354
355 params = ospf_lookup_if_params (ifp, addr);
356 if (params == NULL)
357 return CMD_SUCCESS;
358 }
359
360 UNSET_IF_PARAM (params, passive_interface);
361 params->passive_interface = OSPF_IF_ACTIVE;
362
363 if (params != IF_DEF_PARAMS (ifp))
364 {
365 ospf_free_if_params (ifp, addr);
366 ospf_if_update_params (ifp, addr);
367 }
ajsba6454e2005-02-08 15:37:30 +0000368
369 /* XXX We should call ospf_if_set_multicast on exactly those
370 * interfaces for which the passive property changed. It is too much
371 * work to determine this set, so we do this for every interface.
372 * This is safe and reasonable because ospf_if_set_multicast uses a
373 * record of joined groups to avoid systems calls if the desired
374 * memberships match the current memership.
375 */
376 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
377 {
378 struct ospf_interface *oi = rn->info;
379
380 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
381 ospf_if_set_multicast(oi);
382 }
383
paul718e3742002-12-13 20:15:29 +0000384 return CMD_SUCCESS;
385}
386
paula2c62832003-04-23 17:01:31 +0000387ALIAS (no_ospf_passive_interface,
388 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000389 "no passive-interface IFNAME",
390 NO_STR
391 "Allow routing updates on an interface\n"
392 "Interface's name\n")
393
paula2c62832003-04-23 17:01:31 +0000394DEFUN (ospf_network_area,
395 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000396 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
397 "Enable routing on an IP network\n"
398 "OSPF network prefix\n"
399 "Set the OSPF area ID\n"
400 "OSPF area ID in IP address format\n"
401 "OSPF area ID as a decimal value\n")
402{
403 struct ospf *ospf= vty->index;
404 struct prefix_ipv4 p;
405 struct in_addr area_id;
406 int ret, format;
407
408 /* Get network prefix and Area ID. */
409 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
410 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
411
412 ret = ospf_network_set (ospf, &p, area_id);
413 if (ret == 0)
414 {
415 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
416 return CMD_WARNING;
417 }
418
419 return CMD_SUCCESS;
420}
421
paula2c62832003-04-23 17:01:31 +0000422DEFUN (no_ospf_network_area,
423 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000424 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
425 NO_STR
426 "Enable routing on an IP network\n"
427 "OSPF network prefix\n"
428 "Set the OSPF area ID\n"
429 "OSPF area ID in IP address format\n"
430 "OSPF area ID as a decimal value\n")
431{
432 struct ospf *ospf = (struct ospf *) vty->index;
433 struct prefix_ipv4 p;
434 struct in_addr area_id;
435 int ret, format;
436
437 /* Get network prefix and Area ID. */
438 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
439 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
440
441 ret = ospf_network_unset (ospf, &p, area_id);
442 if (ret == 0)
443 {
444 vty_out (vty, "Can't find specified network area configuration.%s",
445 VTY_NEWLINE);
446 return CMD_WARNING;
447 }
448
449 return CMD_SUCCESS;
450}
451
452
paula2c62832003-04-23 17:01:31 +0000453DEFUN (ospf_area_range,
454 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000455 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
456 "OSPF area parameters\n"
457 "OSPF area ID in IP address format\n"
458 "OSPF area ID as a decimal value\n"
459 "Summarize routes matching address/mask (border routers only)\n"
460 "Area range prefix\n")
461{
462 struct ospf *ospf = vty->index;
463 struct prefix_ipv4 p;
464 struct in_addr area_id;
465 int format;
466 u_int32_t cost;
467
468 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
469 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
470
471 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
472 if (argc > 2)
473 {
474 VTY_GET_UINT32 ("range cost", cost, argv[2]);
475 ospf_area_range_cost_set (ospf, area_id, &p, cost);
476 }
477
478 return CMD_SUCCESS;
479}
480
paula2c62832003-04-23 17:01:31 +0000481ALIAS (ospf_area_range,
482 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000483 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
484 "OSPF area parameters\n"
485 "OSPF area ID in IP address format\n"
486 "OSPF area ID as a decimal value\n"
487 "OSPF area range for route advertise (default)\n"
488 "Area range prefix\n"
489 "Advertise this range (default)\n")
490
paula2c62832003-04-23 17:01:31 +0000491ALIAS (ospf_area_range,
492 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000493 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
494 "OSPF area parameters\n"
495 "OSPF area ID in IP address format\n"
496 "OSPF area ID as a decimal value\n"
497 "Summarize routes matching address/mask (border routers only)\n"
498 "Area range prefix\n"
499 "User specified metric for this range\n"
500 "Advertised metric for this range\n")
501
paula2c62832003-04-23 17:01:31 +0000502ALIAS (ospf_area_range,
503 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000504 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
505 "OSPF area parameters\n"
506 "OSPF area ID in IP address format\n"
507 "OSPF area ID as a decimal value\n"
508 "Summarize routes matching address/mask (border routers only)\n"
509 "Area range prefix\n"
510 "Advertise this range (default)\n"
511 "User specified metric for this range\n"
512 "Advertised metric for this range\n")
513
paula2c62832003-04-23 17:01:31 +0000514DEFUN (ospf_area_range_not_advertise,
515 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000516 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
517 "OSPF area parameters\n"
518 "OSPF area ID in IP address format\n"
519 "OSPF area ID as a decimal value\n"
520 "Summarize routes matching address/mask (border routers only)\n"
521 "Area range prefix\n"
522 "DoNotAdvertise this range\n")
523{
524 struct ospf *ospf = vty->index;
525 struct prefix_ipv4 p;
526 struct in_addr area_id;
527 int format;
528
529 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
530 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
531
532 ospf_area_range_set (ospf, area_id, &p, 0);
533
534 return CMD_SUCCESS;
535}
536
paula2c62832003-04-23 17:01:31 +0000537DEFUN (no_ospf_area_range,
538 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000539 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
540 NO_STR
541 "OSPF area parameters\n"
542 "OSPF area ID in IP address format\n"
543 "OSPF area ID as a decimal value\n"
544 "Summarize routes matching address/mask (border routers only)\n"
545 "Area range prefix\n")
546{
547 struct ospf *ospf = vty->index;
548 struct prefix_ipv4 p;
549 struct in_addr area_id;
550 int format;
551
552 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
553 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
554
555 ospf_area_range_unset (ospf, area_id, &p);
556
557 return CMD_SUCCESS;
558}
559
paula2c62832003-04-23 17:01:31 +0000560ALIAS (no_ospf_area_range,
561 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000562 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
563 NO_STR
564 "OSPF area parameters\n"
565 "OSPF area ID in IP address format\n"
566 "OSPF area ID as a decimal value\n"
567 "Summarize routes matching address/mask (border routers only)\n"
568 "Area range prefix\n"
569 "Advertise this range (default)\n"
570 "DoNotAdvertise this range\n")
571
paula2c62832003-04-23 17:01:31 +0000572ALIAS (no_ospf_area_range,
573 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000574 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
575 NO_STR
576 "OSPF area parameters\n"
577 "OSPF area ID in IP address format\n"
578 "OSPF area ID as a decimal value\n"
579 "Summarize routes matching address/mask (border routers only)\n"
580 "Area range prefix\n"
581 "User specified metric for this range\n"
582 "Advertised metric for this range\n")
583
paula2c62832003-04-23 17:01:31 +0000584ALIAS (no_ospf_area_range,
585 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000586 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
587 NO_STR
588 "OSPF area parameters\n"
589 "OSPF area ID in IP address format\n"
590 "OSPF area ID as a decimal value\n"
591 "Summarize routes matching address/mask (border routers only)\n"
592 "Area range prefix\n"
593 "Advertise this range (default)\n"
594 "User specified metric for this range\n"
595 "Advertised metric for this range\n")
596
paula2c62832003-04-23 17:01:31 +0000597DEFUN (ospf_area_range_substitute,
598 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000599 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
600 "OSPF area parameters\n"
601 "OSPF area ID in IP address format\n"
602 "OSPF area ID as a decimal value\n"
603 "Summarize routes matching address/mask (border routers only)\n"
604 "Area range prefix\n"
605 "Announce area range as another prefix\n"
606 "Network prefix to be announced instead of range\n")
607{
608 struct ospf *ospf = vty->index;
609 struct prefix_ipv4 p, s;
610 struct in_addr area_id;
611 int format;
612
613 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
614 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
615 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
616
617 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
618
619 return CMD_SUCCESS;
620}
621
paula2c62832003-04-23 17:01:31 +0000622DEFUN (no_ospf_area_range_substitute,
623 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000624 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
625 NO_STR
626 "OSPF area parameters\n"
627 "OSPF area ID in IP address format\n"
628 "OSPF area ID as a decimal value\n"
629 "Summarize routes matching address/mask (border routers only)\n"
630 "Area range prefix\n"
631 "Announce area range as another prefix\n"
632 "Network prefix to be announced instead of range\n")
633{
634 struct ospf *ospf = vty->index;
635 struct prefix_ipv4 p, s;
636 struct in_addr area_id;
637 int format;
638
639 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
640 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
641 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
642
643 ospf_area_range_substitute_unset (ospf, area_id, &p);
644
645 return CMD_SUCCESS;
646}
647
648
649/* Command Handler Logic in VLink stuff is delicate!!
650
651 ALTER AT YOUR OWN RISK!!!!
652
653 Various dummy values are used to represent 'NoChange' state for
654 VLink configuration NOT being changed by a VLink command, and
655 special syntax is used within the command strings so that the
656 typed in command verbs can be seen in the configuration command
657 bacckend handler. This is to drastically reduce the verbeage
658 required to coe up with a reasonably compatible Cisco VLink command
659
660 - Matthew Grant <grantma@anathoth.gen.nz>
661 Wed, 21 Feb 2001 15:13:52 +1300
662 */
663
664
665/* Configuration data for virtual links
666 */
667struct ospf_vl_config_data {
668 struct vty *vty; /* vty stuff */
669 struct in_addr area_id; /* area ID from command line */
670 int format; /* command line area ID format */
671 struct in_addr vl_peer; /* command line vl_peer */
672 int auth_type; /* Authehntication type, if given */
673 char *auth_key; /* simple password if present */
674 int crypto_key_id; /* Cryptographic key ID */
675 char *md5_key; /* MD5 authentication key */
676 int hello_interval; /* Obvious what these are... */
677 int retransmit_interval;
678 int transmit_delay;
679 int dead_interval;
680};
681
682void
683ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
684 struct vty *vty)
685{
686 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
687 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
688 vl_config->vty = vty;
689}
690
691struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000692ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000693{
694 struct ospf_area *area;
695 struct ospf_vl_data *vl_data;
696 struct vty *vty;
697 struct in_addr area_id;
698
699 vty = vl_config->vty;
700 area_id = vl_config->area_id;
701
702 if (area_id.s_addr == OSPF_AREA_BACKBONE)
703 {
704 vty_out (vty,
705 "Configuring VLs over the backbone is not allowed%s",
706 VTY_NEWLINE);
707 return NULL;
708 }
paul68980082003-03-25 05:07:42 +0000709 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000710
711 if (area->external_routing != OSPF_AREA_DEFAULT)
712 {
713 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
714 vty_out (vty, "Area %s is %s%s",
715 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000716 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000717 VTY_NEWLINE);
718 else
719 vty_out (vty, "Area %ld is %s%s",
720 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000721 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000722 VTY_NEWLINE);
723 return NULL;
724 }
725
726 if ((vl_data = ospf_vl_lookup (area, vl_config->vl_peer)) == NULL)
727 {
728 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
729 if (vl_data->vl_oi == NULL)
730 {
paul68980082003-03-25 05:07:42 +0000731 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
732 ospf_vl_add (ospf, vl_data);
733 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +0000734 }
735 }
736 return vl_data;
737}
738
739
740int
741ospf_vl_set_security (struct ospf_vl_data *vl_data,
742 struct ospf_vl_config_data *vl_config)
743{
744 struct crypt_key *ck;
745 struct vty *vty;
746 struct interface *ifp = vl_data->vl_oi->ifp;
747
748 vty = vl_config->vty;
749
750 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
751 {
752 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
753 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
754 }
755
756 if (vl_config->auth_key)
757 {
758 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000759 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000760 OSPF_AUTH_SIMPLE_SIZE);
761 }
762 else if (vl_config->md5_key)
763 {
764 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
765 != NULL)
766 {
767 vty_out (vty, "OSPF: Key %d already exists%s",
768 vl_config->crypto_key_id, VTY_NEWLINE);
769 return CMD_WARNING;
770 }
771 ck = ospf_crypt_key_new ();
772 ck->key_id = vl_config->crypto_key_id;
773 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000774 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000775
776 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
777 }
778 else if (vl_config->crypto_key_id != 0)
779 {
780 /* Delete a key */
781
782 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
783 vl_config->crypto_key_id) == NULL)
784 {
785 vty_out (vty, "OSPF: Key %d does not exist%s",
786 vl_config->crypto_key_id, VTY_NEWLINE);
787 return CMD_WARNING;
788 }
789
790 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
791
792 }
793
794 return CMD_SUCCESS;
795}
796
797
798
799int
800ospf_vl_set_timers (struct ospf_vl_data *vl_data,
801 struct ospf_vl_config_data *vl_config)
802{
803 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
804 /* Virtual Link data initialised to defaults, so only set
805 if a value given */
806 if (vl_config->hello_interval)
807 {
808 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
809 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
810 }
811
812 if (vl_config->dead_interval)
813 {
814 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
815 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
816 }
817
818 if (vl_config->retransmit_interval)
819 {
820 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
821 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
822 }
823
824 if (vl_config->transmit_delay)
825 {
826 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
827 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
828 }
829
830 return CMD_SUCCESS;
831}
832
833
834
835/* The business end of all of the above */
836int
paul68980082003-03-25 05:07:42 +0000837ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000838{
839 struct ospf_vl_data *vl_data;
840 int ret;
841
paul68980082003-03-25 05:07:42 +0000842 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000843 if (!vl_data)
844 return CMD_WARNING;
845
846 /* Process this one first as it can have a fatal result, which can
847 only logically occur if the virtual link exists already
848 Thus a command error does not result in a change to the
849 running configuration such as unexpectedly altered timer
850 values etc.*/
851 ret = ospf_vl_set_security (vl_data, vl_config);
852 if (ret != CMD_SUCCESS)
853 return ret;
854
855 /* Set any time based parameters, these area already range checked */
856
857 ret = ospf_vl_set_timers (vl_data, vl_config);
858 if (ret != CMD_SUCCESS)
859 return ret;
860
861 return CMD_SUCCESS;
862
863}
864
865/* This stuff exists to make specifying all the alias commands A LOT simpler
866 */
867#define VLINK_HELPSTR_IPADDR \
868 "OSPF area parameters\n" \
869 "OSPF area ID in IP address format\n" \
870 "OSPF area ID as a decimal value\n" \
871 "Configure a virtual link\n" \
872 "Router ID of the remote ABR\n"
873
874#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
875 "Enable authentication on this virtual link\n" \
876 "dummy string \n"
877
878#define VLINK_HELPSTR_AUTHTYPE_ALL \
879 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
880 "Use null authentication\n" \
881 "Use message-digest authentication\n"
882
883#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
884 "Time between HELLO packets\n" \
885 "Time between retransmitting lost link state advertisements\n" \
886 "Link state transmit delay\n" \
887 "Interval after which a neighbor is declared dead\n"
888
889#define VLINK_HELPSTR_TIME_PARAM \
890 VLINK_HELPSTR_TIME_PARAM_NOSECS \
891 "Seconds\n"
892
893#define VLINK_HELPSTR_AUTH_SIMPLE \
894 "Authentication password (key)\n" \
895 "The OSPF password (key)"
896
897#define VLINK_HELPSTR_AUTH_MD5 \
898 "Message digest authentication password (key)\n" \
899 "dummy string \n" \
900 "Key ID\n" \
901 "Use MD5 algorithm\n" \
902 "The OSPF password (key)"
903
paula2c62832003-04-23 17:01:31 +0000904DEFUN (ospf_area_vlink,
905 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000906 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
907 VLINK_HELPSTR_IPADDR)
908{
paul68980082003-03-25 05:07:42 +0000909 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000910 struct ospf_vl_config_data vl_config;
911 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
912 char md5_key[OSPF_AUTH_MD5_SIZE+1];
913 int i;
914 int ret;
915
916 ospf_vl_config_data_init(&vl_config, vty);
917
918 /* Read off first 2 parameters and check them */
919 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
920 if (ret < 0)
921 {
922 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
923 return CMD_WARNING;
924 }
925
926 ret = inet_aton (argv[1], &vl_config.vl_peer);
927 if (! ret)
928 {
929 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
930 VTY_NEWLINE);
931 return CMD_WARNING;
932 }
933
934 if (argc <=2)
935 {
936 /* Thats all folks! - BUGS B. strikes again!!!*/
937
paul68980082003-03-25 05:07:42 +0000938 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +0000939 }
940
941 /* Deal with other parameters */
942 for (i=2; i < argc; i++)
943 {
944
945 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
946
947 switch (argv[i][0])
948 {
949
950 case 'a':
951 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
952 {
953 /* authentication-key - this option can occur anywhere on
954 command line. At start of command line
955 must check for authentication option. */
956 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
957 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
958 vl_config.auth_key = auth_key;
959 i++;
960 }
961 else if (strncmp (argv[i], "authentication", 14) == 0)
962 {
963 /* authentication - this option can only occur at start
964 of command line */
965 vl_config.auth_type = OSPF_AUTH_SIMPLE;
966 if ((i+1) < argc)
967 {
968 if (strncmp (argv[i+1], "n", 1) == 0)
969 {
970 /* "authentication null" */
971 vl_config.auth_type = OSPF_AUTH_NULL;
972 i++;
973 }
974 else if (strncmp (argv[i+1], "m", 1) == 0
975 && strcmp (argv[i+1], "message-digest-") != 0)
976 {
977 /* "authentication message-digest" */
978 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
979 i++;
980 }
981 }
982 }
983 break;
984
985 case 'm':
986 /* message-digest-key */
987 i++;
988 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
989 if (vl_config.crypto_key_id < 0)
990 return CMD_WARNING;
991 i++;
992 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
993 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
994 vl_config.md5_key = md5_key;
995 break;
996
997 case 'h':
998 /* Hello interval */
999 i++;
1000 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1001 if (vl_config.hello_interval < 0)
1002 return CMD_WARNING;
1003 break;
1004
1005 case 'r':
1006 /* Retransmit Interval */
1007 i++;
1008 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1009 if (vl_config.retransmit_interval < 0)
1010 return CMD_WARNING;
1011 break;
1012
1013 case 't':
1014 /* Transmit Delay */
1015 i++;
1016 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1017 if (vl_config.transmit_delay < 0)
1018 return CMD_WARNING;
1019 break;
1020
1021 case 'd':
1022 /* Dead Interval */
1023 i++;
1024 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1025 if (vl_config.dead_interval < 0)
1026 return CMD_WARNING;
1027 break;
1028 }
1029 }
1030
1031
1032 /* Action configuration */
1033
paul68980082003-03-25 05:07:42 +00001034 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001035
1036}
1037
paula2c62832003-04-23 17:01:31 +00001038DEFUN (no_ospf_area_vlink,
1039 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001040 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1041 NO_STR
1042 VLINK_HELPSTR_IPADDR)
1043{
paul68980082003-03-25 05:07:42 +00001044 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001045 struct ospf_area *area;
1046 struct ospf_vl_config_data vl_config;
1047 struct ospf_vl_data *vl_data = NULL;
1048 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1049 int i;
1050 int ret, format;
1051
1052 ospf_vl_config_data_init(&vl_config, vty);
1053
1054 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1055 if (ret < 0)
1056 {
1057 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1058 return CMD_WARNING;
1059 }
1060
paul68980082003-03-25 05:07:42 +00001061 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001062 if (!area)
1063 {
1064 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1065 return CMD_WARNING;
1066 }
1067
1068 ret = inet_aton (argv[1], &vl_config.vl_peer);
1069 if (! ret)
1070 {
1071 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1072 VTY_NEWLINE);
1073 return CMD_WARNING;
1074 }
1075
1076 if (argc <=2)
1077 {
1078 /* Basic VLink no command */
1079 /* Thats all folks! - BUGS B. strikes again!!!*/
1080 if ((vl_data = ospf_vl_lookup (area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001081 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001082
paul68980082003-03-25 05:07:42 +00001083 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001084
1085 return CMD_SUCCESS;
1086 }
1087
1088 /* If we are down here, we are reseting parameters */
1089
1090 /* Deal with other parameters */
1091 for (i=2; i < argc; i++)
1092 {
paul718e3742002-12-13 20:15:29 +00001093 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1094
1095 switch (argv[i][0])
1096 {
1097
1098 case 'a':
1099 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1100 {
1101 /* authentication-key - this option can occur anywhere on
1102 command line. At start of command line
1103 must check for authentication option. */
1104 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1105 vl_config.auth_key = auth_key;
1106 }
1107 else if (strncmp (argv[i], "authentication", 14) == 0)
1108 {
1109 /* authentication - this option can only occur at start
1110 of command line */
1111 vl_config.auth_type = OSPF_AUTH_NOTSET;
1112 }
1113 break;
1114
1115 case 'm':
1116 /* message-digest-key */
1117 /* Delete one key */
1118 i++;
1119 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1120 if (vl_config.crypto_key_id < 0)
1121 return CMD_WARNING;
1122 vl_config.md5_key = NULL;
1123 break;
1124
1125 case 'h':
1126 /* Hello interval */
1127 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1128 break;
1129
1130 case 'r':
1131 /* Retransmit Interval */
1132 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1133 break;
1134
1135 case 't':
1136 /* Transmit Delay */
1137 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1138 break;
1139
1140 case 'd':
1141 /* Dead Interval */
1142 i++;
1143 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1144 break;
1145 }
1146 }
1147
1148
1149 /* Action configuration */
1150
paul68980082003-03-25 05:07:42 +00001151 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001152}
1153
paula2c62832003-04-23 17:01:31 +00001154ALIAS (ospf_area_vlink,
1155 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001156 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1157 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1158 VLINK_HELPSTR_IPADDR
1159 VLINK_HELPSTR_TIME_PARAM)
1160
paula2c62832003-04-23 17:01:31 +00001161ALIAS (no_ospf_area_vlink,
1162 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001163 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1164 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1165 NO_STR
1166 VLINK_HELPSTR_IPADDR
1167 VLINK_HELPSTR_TIME_PARAM)
1168
paula2c62832003-04-23 17:01:31 +00001169ALIAS (ospf_area_vlink,
1170 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001171 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1172 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1173 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1174 VLINK_HELPSTR_IPADDR
1175 VLINK_HELPSTR_TIME_PARAM
1176 VLINK_HELPSTR_TIME_PARAM)
1177
paula2c62832003-04-23 17:01:31 +00001178ALIAS (no_ospf_area_vlink,
1179 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001180 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1181 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1182 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1183 NO_STR
1184 VLINK_HELPSTR_IPADDR
1185 VLINK_HELPSTR_TIME_PARAM
1186 VLINK_HELPSTR_TIME_PARAM)
1187
paula2c62832003-04-23 17:01:31 +00001188ALIAS (ospf_area_vlink,
1189 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001190 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1191 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1192 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1193 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1194 VLINK_HELPSTR_IPADDR
1195 VLINK_HELPSTR_TIME_PARAM
1196 VLINK_HELPSTR_TIME_PARAM
1197 VLINK_HELPSTR_TIME_PARAM)
1198
paula2c62832003-04-23 17:01:31 +00001199ALIAS (no_ospf_area_vlink,
1200 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001201 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1202 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1203 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1204 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1205 NO_STR
1206 VLINK_HELPSTR_IPADDR
1207 VLINK_HELPSTR_TIME_PARAM
1208 VLINK_HELPSTR_TIME_PARAM
1209 VLINK_HELPSTR_TIME_PARAM)
1210
paula2c62832003-04-23 17:01:31 +00001211ALIAS (ospf_area_vlink,
1212 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001213 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1214 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1215 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1216 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1217 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1218 VLINK_HELPSTR_IPADDR
1219 VLINK_HELPSTR_TIME_PARAM
1220 VLINK_HELPSTR_TIME_PARAM
1221 VLINK_HELPSTR_TIME_PARAM
1222 VLINK_HELPSTR_TIME_PARAM)
1223
paula2c62832003-04-23 17:01:31 +00001224ALIAS (no_ospf_area_vlink,
1225 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001226 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1227 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1228 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1229 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1230 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1231 NO_STR
1232 VLINK_HELPSTR_IPADDR
1233 VLINK_HELPSTR_TIME_PARAM
1234 VLINK_HELPSTR_TIME_PARAM
1235 VLINK_HELPSTR_TIME_PARAM
1236 VLINK_HELPSTR_TIME_PARAM)
1237
paula2c62832003-04-23 17:01:31 +00001238ALIAS (ospf_area_vlink,
1239 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001240 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1241 "(authentication|) (message-digest|null)",
1242 VLINK_HELPSTR_IPADDR
1243 VLINK_HELPSTR_AUTHTYPE_ALL)
1244
paula2c62832003-04-23 17:01:31 +00001245ALIAS (ospf_area_vlink,
1246 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001247 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1248 "(authentication|)",
1249 VLINK_HELPSTR_IPADDR
1250 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1251
paula2c62832003-04-23 17:01:31 +00001252ALIAS (no_ospf_area_vlink,
1253 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001254 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1255 "(authentication|)",
1256 NO_STR
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1259
paula2c62832003-04-23 17:01:31 +00001260ALIAS (ospf_area_vlink,
1261 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001262 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1263 "(message-digest-key|) <1-255> md5 KEY",
1264 VLINK_HELPSTR_IPADDR
1265 VLINK_HELPSTR_AUTH_MD5)
1266
paula2c62832003-04-23 17:01:31 +00001267ALIAS (no_ospf_area_vlink,
1268 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001269 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1270 "(message-digest-key|) <1-255>",
1271 NO_STR
1272 VLINK_HELPSTR_IPADDR
1273 VLINK_HELPSTR_AUTH_MD5)
1274
paula2c62832003-04-23 17:01:31 +00001275ALIAS (ospf_area_vlink,
1276 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001277 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1278 "(authentication-key|) AUTH_KEY",
1279 VLINK_HELPSTR_IPADDR
1280 VLINK_HELPSTR_AUTH_SIMPLE)
1281
paula2c62832003-04-23 17:01:31 +00001282ALIAS (no_ospf_area_vlink,
1283 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001284 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1285 "(authentication-key|)",
1286 NO_STR
1287 VLINK_HELPSTR_IPADDR
1288 VLINK_HELPSTR_AUTH_SIMPLE)
1289
paula2c62832003-04-23 17:01:31 +00001290ALIAS (ospf_area_vlink,
1291 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001292 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1293 "(authentication|) (message-digest|null) "
1294 "(authentication-key|) AUTH_KEY",
1295 VLINK_HELPSTR_IPADDR
1296 VLINK_HELPSTR_AUTHTYPE_ALL
1297 VLINK_HELPSTR_AUTH_SIMPLE)
1298
paula2c62832003-04-23 17:01:31 +00001299ALIAS (ospf_area_vlink,
1300 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001301 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1302 "(authentication|) "
1303 "(authentication-key|) AUTH_KEY",
1304 VLINK_HELPSTR_IPADDR
1305 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1306 VLINK_HELPSTR_AUTH_SIMPLE)
1307
paula2c62832003-04-23 17:01:31 +00001308ALIAS (no_ospf_area_vlink,
1309 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001310 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1311 "(authentication|) "
1312 "(authentication-key|)",
1313 NO_STR
1314 VLINK_HELPSTR_IPADDR
1315 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1316 VLINK_HELPSTR_AUTH_SIMPLE)
1317
paula2c62832003-04-23 17:01:31 +00001318ALIAS (ospf_area_vlink,
1319 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001320 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1321 "(authentication|) (message-digest|null) "
1322 "(message-digest-key|) <1-255> md5 KEY",
1323 VLINK_HELPSTR_IPADDR
1324 VLINK_HELPSTR_AUTHTYPE_ALL
1325 VLINK_HELPSTR_AUTH_MD5)
1326
paula2c62832003-04-23 17:01:31 +00001327ALIAS (ospf_area_vlink,
1328 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001329 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1330 "(authentication|) "
1331 "(message-digest-key|) <1-255> md5 KEY",
1332 VLINK_HELPSTR_IPADDR
1333 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1334 VLINK_HELPSTR_AUTH_MD5)
1335
paula2c62832003-04-23 17:01:31 +00001336ALIAS (no_ospf_area_vlink,
1337 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001338 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1339 "(authentication|) "
1340 "(message-digest-key|)",
1341 NO_STR
1342 VLINK_HELPSTR_IPADDR
1343 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1344 VLINK_HELPSTR_AUTH_MD5)
1345
1346
paula2c62832003-04-23 17:01:31 +00001347DEFUN (ospf_area_shortcut,
1348 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001349 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1350 "OSPF area parameters\n"
1351 "OSPF area ID in IP address format\n"
1352 "OSPF area ID as a decimal value\n"
1353 "Configure the area's shortcutting mode\n"
1354 "Set default shortcutting behavior\n"
1355 "Enable shortcutting through the area\n"
1356 "Disable shortcutting through the area\n")
1357{
paul68980082003-03-25 05:07:42 +00001358 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001359 struct ospf_area *area;
1360 struct in_addr area_id;
1361 int mode;
1362 int format;
1363
1364 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1365
paul68980082003-03-25 05:07:42 +00001366 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001367
1368 if (strncmp (argv[1], "de", 2) == 0)
1369 mode = OSPF_SHORTCUT_DEFAULT;
1370 else if (strncmp (argv[1], "di", 2) == 0)
1371 mode = OSPF_SHORTCUT_DISABLE;
1372 else if (strncmp (argv[1], "e", 1) == 0)
1373 mode = OSPF_SHORTCUT_ENABLE;
1374 else
1375 return CMD_WARNING;
1376
paul68980082003-03-25 05:07:42 +00001377 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001378
paul68980082003-03-25 05:07:42 +00001379 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001380 vty_out (vty, "Shortcut area setting will take effect "
1381 "only when the router is configured as Shortcut ABR%s",
1382 VTY_NEWLINE);
1383
1384 return CMD_SUCCESS;
1385}
1386
paula2c62832003-04-23 17:01:31 +00001387DEFUN (no_ospf_area_shortcut,
1388 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001389 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1390 NO_STR
1391 "OSPF area parameters\n"
1392 "OSPF area ID in IP address format\n"
1393 "OSPF area ID as a decimal value\n"
1394 "Deconfigure the area's shortcutting mode\n"
1395 "Deconfigure enabled shortcutting through the area\n"
1396 "Deconfigure disabled shortcutting through the area\n")
1397{
paul68980082003-03-25 05:07:42 +00001398 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001399 struct ospf_area *area;
1400 struct in_addr area_id;
1401 int format;
1402
1403 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1404
paul68980082003-03-25 05:07:42 +00001405 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001406 if (!area)
1407 return CMD_SUCCESS;
1408
paul68980082003-03-25 05:07:42 +00001409 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001410
1411 return CMD_SUCCESS;
1412}
1413
1414
paula2c62832003-04-23 17:01:31 +00001415DEFUN (ospf_area_stub,
1416 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001417 "area (A.B.C.D|<0-4294967295>) stub",
1418 "OSPF area parameters\n"
1419 "OSPF area ID in IP address format\n"
1420 "OSPF area ID as a decimal value\n"
1421 "Configure OSPF area as stub\n")
1422{
1423 struct ospf *ospf = vty->index;
1424 struct in_addr area_id;
1425 int ret, format;
1426
1427 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1428
1429 ret = ospf_area_stub_set (ospf, area_id);
1430 if (ret == 0)
1431 {
1432 vty_out (vty, "First deconfigure all virtual link through this area%s",
1433 VTY_NEWLINE);
1434 return CMD_WARNING;
1435 }
1436
1437 ospf_area_no_summary_unset (ospf, area_id);
1438
1439 return CMD_SUCCESS;
1440}
1441
paula2c62832003-04-23 17:01:31 +00001442DEFUN (ospf_area_stub_no_summary,
1443 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001444 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1445 "OSPF stub parameters\n"
1446 "OSPF area ID in IP address format\n"
1447 "OSPF area ID as a decimal value\n"
1448 "Configure OSPF area as stub\n"
1449 "Do not inject inter-area routes into stub\n")
1450{
1451 struct ospf *ospf = vty->index;
1452 struct in_addr area_id;
1453 int ret, format;
1454
1455 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1456
1457 ret = ospf_area_stub_set (ospf, area_id);
1458 if (ret == 0)
1459 {
paulb0a053b2003-06-22 09:04:47 +00001460 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001461 VTY_NEWLINE);
1462 return CMD_WARNING;
1463 }
1464
1465 ospf_area_no_summary_set (ospf, area_id);
1466
1467 return CMD_SUCCESS;
1468}
1469
paula2c62832003-04-23 17:01:31 +00001470DEFUN (no_ospf_area_stub,
1471 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001472 "no area (A.B.C.D|<0-4294967295>) stub",
1473 NO_STR
1474 "OSPF area parameters\n"
1475 "OSPF area ID in IP address format\n"
1476 "OSPF area ID as a decimal value\n"
1477 "Configure OSPF area as stub\n")
1478{
1479 struct ospf *ospf = vty->index;
1480 struct in_addr area_id;
1481 int format;
1482
1483 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1484
1485 ospf_area_stub_unset (ospf, area_id);
1486 ospf_area_no_summary_unset (ospf, area_id);
1487
1488 return CMD_SUCCESS;
1489}
1490
paula2c62832003-04-23 17:01:31 +00001491DEFUN (no_ospf_area_stub_no_summary,
1492 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001493 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1494 NO_STR
1495 "OSPF area parameters\n"
1496 "OSPF area ID in IP address format\n"
1497 "OSPF area ID as a decimal value\n"
1498 "Configure OSPF area as stub\n"
1499 "Do not inject inter-area routes into area\n")
1500{
1501 struct ospf *ospf = vty->index;
1502 struct in_addr area_id;
1503 int format;
1504
1505 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1506 ospf_area_no_summary_unset (ospf, area_id);
1507
1508 return CMD_SUCCESS;
1509}
1510
paulb0a053b2003-06-22 09:04:47 +00001511int
paul6c835672004-10-11 11:00:30 +00001512ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1513 int nosum)
paul718e3742002-12-13 20:15:29 +00001514{
1515 struct ospf *ospf = vty->index;
1516 struct in_addr area_id;
1517 int ret, format;
1518
1519 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1520
1521 ret = ospf_area_nssa_set (ospf, area_id);
1522 if (ret == 0)
1523 {
1524 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1525 VTY_NEWLINE);
1526 return CMD_WARNING;
1527 }
1528
1529 if (argc > 1)
1530 {
1531 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001532 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001533 OSPF_NSSA_ROLE_CANDIDATE);
1534 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001535 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001536 OSPF_NSSA_ROLE_NEVER);
1537 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001538 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001539 OSPF_NSSA_ROLE_ALWAYS);
1540 }
paulb0a053b2003-06-22 09:04:47 +00001541 else
1542 {
1543 ospf_area_nssa_translator_role_set (ospf, area_id,
1544 OSPF_NSSA_ROLE_CANDIDATE);
1545 }
paul718e3742002-12-13 20:15:29 +00001546
paulb0a053b2003-06-22 09:04:47 +00001547 if (nosum)
paul718e3742002-12-13 20:15:29 +00001548 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001549 else
1550 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001551
paulb0a053b2003-06-22 09:04:47 +00001552 ospf_schedule_abr_task (ospf);
1553
paul718e3742002-12-13 20:15:29 +00001554 return CMD_SUCCESS;
1555}
1556
paulb0a053b2003-06-22 09:04:47 +00001557DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001558 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001559 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001560 "OSPF area parameters\n"
1561 "OSPF area ID in IP address format\n"
1562 "OSPF area ID as a decimal value\n"
1563 "Configure OSPF area as nssa\n"
1564 "Configure NSSA-ABR for translate election (default)\n"
1565 "Configure NSSA-ABR to never translate\n"
1566 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001567 "Do not inject inter-area routes into nssa\n")
1568{
1569 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1570}
paul718e3742002-12-13 20:15:29 +00001571
paulb0a053b2003-06-22 09:04:47 +00001572DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001573 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001574 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1575 "OSPF area parameters\n"
1576 "OSPF area ID in IP address format\n"
1577 "OSPF area ID as a decimal value\n"
1578 "Configure OSPF area as nssa\n"
1579 "Configure NSSA-ABR for translate election (default)\n"
1580 "Configure NSSA-ABR to never translate\n"
1581 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001582{
1583 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1584}
1585
1586DEFUN (ospf_area_nssa,
1587 ospf_area_nssa_cmd,
1588 "area (A.B.C.D|<0-4294967295>) nssa",
1589 "OSPF area parameters\n"
1590 "OSPF area ID in IP address format\n"
1591 "OSPF area ID as a decimal value\n"
1592 "Configure OSPF area as nssa\n")
1593{
1594 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1595}
paul718e3742002-12-13 20:15:29 +00001596
paula2c62832003-04-23 17:01:31 +00001597DEFUN (ospf_area_nssa_no_summary,
1598 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001599 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1600 "OSPF area parameters\n"
1601 "OSPF area ID in IP address format\n"
1602 "OSPF area ID as a decimal value\n"
1603 "Configure OSPF area as nssa\n"
1604 "Do not inject inter-area routes into nssa\n")
1605{
paulb0a053b2003-06-22 09:04:47 +00001606 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001607}
1608
paula2c62832003-04-23 17:01:31 +00001609DEFUN (no_ospf_area_nssa,
1610 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001611 "no area (A.B.C.D|<0-4294967295>) nssa",
1612 NO_STR
1613 "OSPF area parameters\n"
1614 "OSPF area ID in IP address format\n"
1615 "OSPF area ID as a decimal value\n"
1616 "Configure OSPF area as nssa\n")
1617{
1618 struct ospf *ospf = vty->index;
1619 struct in_addr area_id;
1620 int format;
1621
1622 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1623
1624 ospf_area_nssa_unset (ospf, area_id);
1625 ospf_area_no_summary_unset (ospf, area_id);
1626
paulb0a053b2003-06-22 09:04:47 +00001627 ospf_schedule_abr_task (ospf);
1628
paul718e3742002-12-13 20:15:29 +00001629 return CMD_SUCCESS;
1630}
1631
paula2c62832003-04-23 17:01:31 +00001632DEFUN (no_ospf_area_nssa_no_summary,
1633 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001634 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1635 NO_STR
1636 "OSPF area parameters\n"
1637 "OSPF area ID in IP address format\n"
1638 "OSPF area ID as a decimal value\n"
1639 "Configure OSPF area as nssa\n"
1640 "Do not inject inter-area routes into nssa\n")
1641{
1642 struct ospf *ospf = vty->index;
1643 struct in_addr area_id;
1644 int format;
1645
1646 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1647 ospf_area_no_summary_unset (ospf, area_id);
1648
1649 return CMD_SUCCESS;
1650}
1651
paula2c62832003-04-23 17:01:31 +00001652DEFUN (ospf_area_default_cost,
1653 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001654 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1655 "OSPF area parameters\n"
1656 "OSPF area ID in IP address format\n"
1657 "OSPF area ID as a decimal value\n"
1658 "Set the summary-default cost of a NSSA or stub area\n"
1659 "Stub's advertised default summary cost\n")
1660{
paul68980082003-03-25 05:07:42 +00001661 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001662 struct ospf_area *area;
1663 struct in_addr area_id;
1664 u_int32_t cost;
1665 int format;
1666
1667 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1668 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1669
paul68980082003-03-25 05:07:42 +00001670 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001671
1672 if (area->external_routing == OSPF_AREA_DEFAULT)
1673 {
1674 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1675 return CMD_WARNING;
1676 }
1677
1678 area->default_cost = cost;
1679
1680 return CMD_SUCCESS;
1681}
1682
paula2c62832003-04-23 17:01:31 +00001683DEFUN (no_ospf_area_default_cost,
1684 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001685 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1686 NO_STR
1687 "OSPF area parameters\n"
1688 "OSPF area ID in IP address format\n"
1689 "OSPF area ID as a decimal value\n"
1690 "Set the summary-default cost of a NSSA or stub area\n"
1691 "Stub's advertised default summary cost\n")
1692{
paul68980082003-03-25 05:07:42 +00001693 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001694 struct ospf_area *area;
1695 struct in_addr area_id;
1696 u_int32_t cost;
1697 int format;
1698
1699 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1700 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1701
paul68980082003-03-25 05:07:42 +00001702 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001703 if (area == NULL)
1704 return CMD_SUCCESS;
1705
1706 if (area->external_routing == OSPF_AREA_DEFAULT)
1707 {
1708 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1709 return CMD_WARNING;
1710 }
1711
1712 area->default_cost = 1;
1713
paul68980082003-03-25 05:07:42 +00001714 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001715
1716 return CMD_SUCCESS;
1717}
1718
paula2c62832003-04-23 17:01:31 +00001719DEFUN (ospf_area_export_list,
1720 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001721 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1722 "OSPF area parameters\n"
1723 "OSPF area ID in IP address format\n"
1724 "OSPF area ID as a decimal value\n"
1725 "Set the filter for networks announced to other areas\n"
1726 "Name of the access-list\n")
1727{
paul68980082003-03-25 05:07:42 +00001728 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001729 struct ospf_area *area;
1730 struct in_addr area_id;
1731 int format;
1732
hasso52930762004-04-19 18:26:53 +00001733 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1734
paul68980082003-03-25 05:07:42 +00001735 area = ospf_area_get (ospf, area_id, format);
1736 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001737
1738 return CMD_SUCCESS;
1739}
1740
paula2c62832003-04-23 17:01:31 +00001741DEFUN (no_ospf_area_export_list,
1742 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001743 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1744 NO_STR
1745 "OSPF area parameters\n"
1746 "OSPF area ID in IP address format\n"
1747 "OSPF area ID as a decimal value\n"
1748 "Unset the filter for networks announced to other areas\n"
1749 "Name of the access-list\n")
1750{
paul68980082003-03-25 05:07:42 +00001751 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001752 struct ospf_area *area;
1753 struct in_addr area_id;
1754 int format;
1755
hasso52930762004-04-19 18:26:53 +00001756 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1757
paul68980082003-03-25 05:07:42 +00001758 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001759 if (area == NULL)
1760 return CMD_SUCCESS;
1761
paul68980082003-03-25 05:07:42 +00001762 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001763
1764 return CMD_SUCCESS;
1765}
1766
1767
paula2c62832003-04-23 17:01:31 +00001768DEFUN (ospf_area_import_list,
1769 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001770 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1771 "OSPF area parameters\n"
1772 "OSPF area ID in IP address format\n"
1773 "OSPF area ID as a decimal value\n"
1774 "Set the filter for networks from other areas announced to the specified one\n"
1775 "Name of the access-list\n")
1776{
paul68980082003-03-25 05:07:42 +00001777 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001778 struct ospf_area *area;
1779 struct in_addr area_id;
1780 int format;
1781
hasso52930762004-04-19 18:26:53 +00001782 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1783
paul68980082003-03-25 05:07:42 +00001784 area = ospf_area_get (ospf, area_id, format);
1785 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001786
1787 return CMD_SUCCESS;
1788}
1789
paula2c62832003-04-23 17:01:31 +00001790DEFUN (no_ospf_area_import_list,
1791 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001792 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1793 NO_STR
1794 "OSPF area parameters\n"
1795 "OSPF area ID in IP address format\n"
1796 "OSPF area ID as a decimal value\n"
1797 "Unset the filter for networks announced to other areas\n"
1798 "Name of the access-list\n")
1799{
paul68980082003-03-25 05:07:42 +00001800 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001801 struct ospf_area *area;
1802 struct in_addr area_id;
1803 int format;
1804
hasso52930762004-04-19 18:26:53 +00001805 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1806
paul68980082003-03-25 05:07:42 +00001807 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001808 if (area == NULL)
1809 return CMD_SUCCESS;
1810
paul68980082003-03-25 05:07:42 +00001811 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001812
1813 return CMD_SUCCESS;
1814}
1815
paula2c62832003-04-23 17:01:31 +00001816DEFUN (ospf_area_filter_list,
1817 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001818 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1819 "OSPF area parameters\n"
1820 "OSPF area ID in IP address format\n"
1821 "OSPF area ID as a decimal value\n"
1822 "Filter networks between OSPF areas\n"
1823 "Filter prefixes between OSPF areas\n"
1824 "Name of an IP prefix-list\n"
1825 "Filter networks sent to this area\n"
1826 "Filter networks sent from this area\n")
1827{
paul68980082003-03-25 05:07:42 +00001828 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001829 struct ospf_area *area;
1830 struct in_addr area_id;
1831 struct prefix_list *plist;
1832 int format;
1833
1834 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1835
paul68980082003-03-25 05:07:42 +00001836 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001837 plist = prefix_list_lookup (AFI_IP, argv[1]);
1838 if (strncmp (argv[2], "in", 2) == 0)
1839 {
1840 PREFIX_LIST_IN (area) = plist;
1841 if (PREFIX_NAME_IN (area))
1842 free (PREFIX_NAME_IN (area));
1843
1844 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001845 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001846 }
1847 else
1848 {
1849 PREFIX_LIST_OUT (area) = plist;
1850 if (PREFIX_NAME_OUT (area))
1851 free (PREFIX_NAME_OUT (area));
1852
1853 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001854 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001855 }
1856
1857 return CMD_SUCCESS;
1858}
1859
paula2c62832003-04-23 17:01:31 +00001860DEFUN (no_ospf_area_filter_list,
1861 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001862 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1863 NO_STR
1864 "OSPF area parameters\n"
1865 "OSPF area ID in IP address format\n"
1866 "OSPF area ID as a decimal value\n"
1867 "Filter networks between OSPF areas\n"
1868 "Filter prefixes between OSPF areas\n"
1869 "Name of an IP prefix-list\n"
1870 "Filter networks sent to this area\n"
1871 "Filter networks sent from this area\n")
1872{
paul68980082003-03-25 05:07:42 +00001873 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001874 struct ospf_area *area;
1875 struct in_addr area_id;
1876 struct prefix_list *plist;
1877 int format;
1878
1879 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1880
paul68980082003-03-25 05:07:42 +00001881 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001882 plist = prefix_list_lookup (AFI_IP, argv[1]);
1883 if (strncmp (argv[2], "in", 2) == 0)
1884 {
1885 if (PREFIX_NAME_IN (area))
1886 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1887 return CMD_SUCCESS;
1888
1889 PREFIX_LIST_IN (area) = NULL;
1890 if (PREFIX_NAME_IN (area))
1891 free (PREFIX_NAME_IN (area));
1892
1893 PREFIX_NAME_IN (area) = NULL;
1894
paul68980082003-03-25 05:07:42 +00001895 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001896 }
1897 else
1898 {
1899 if (PREFIX_NAME_OUT (area))
1900 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1901 return CMD_SUCCESS;
1902
1903 PREFIX_LIST_OUT (area) = NULL;
1904 if (PREFIX_NAME_OUT (area))
1905 free (PREFIX_NAME_OUT (area));
1906
1907 PREFIX_NAME_OUT (area) = NULL;
1908
paul68980082003-03-25 05:07:42 +00001909 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001910 }
1911
1912 return CMD_SUCCESS;
1913}
1914
1915
paula2c62832003-04-23 17:01:31 +00001916DEFUN (ospf_area_authentication_message_digest,
1917 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00001918 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1919 "OSPF area parameters\n"
1920 "Enable authentication\n"
1921 "Use message-digest authentication\n")
1922{
paul68980082003-03-25 05:07:42 +00001923 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001924 struct ospf_area *area;
1925 struct in_addr area_id;
1926 int format;
1927
1928 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1929
paul68980082003-03-25 05:07:42 +00001930 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001931 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1932
1933 return CMD_SUCCESS;
1934}
1935
paula2c62832003-04-23 17:01:31 +00001936DEFUN (ospf_area_authentication,
1937 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001938 "area (A.B.C.D|<0-4294967295>) authentication",
1939 "OSPF area parameters\n"
1940 "OSPF area ID in IP address format\n"
1941 "OSPF area ID as a decimal value\n"
1942 "Enable authentication\n")
1943{
paul68980082003-03-25 05:07:42 +00001944 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001945 struct ospf_area *area;
1946 struct in_addr area_id;
1947 int format;
1948
1949 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1950
paul68980082003-03-25 05:07:42 +00001951 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001952 area->auth_type = OSPF_AUTH_SIMPLE;
1953
1954 return CMD_SUCCESS;
1955}
1956
paula2c62832003-04-23 17:01:31 +00001957DEFUN (no_ospf_area_authentication,
1958 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00001959 "no area (A.B.C.D|<0-4294967295>) authentication",
1960 NO_STR
1961 "OSPF area parameters\n"
1962 "OSPF area ID in IP address format\n"
1963 "OSPF area ID as a decimal value\n"
1964 "Enable authentication\n")
1965{
paul68980082003-03-25 05:07:42 +00001966 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001967 struct ospf_area *area;
1968 struct in_addr area_id;
1969 int format;
1970
1971 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1972
paul68980082003-03-25 05:07:42 +00001973 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001974 if (area == NULL)
1975 return CMD_SUCCESS;
1976
1977 area->auth_type = OSPF_AUTH_NULL;
1978
paul68980082003-03-25 05:07:42 +00001979 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001980
1981 return CMD_SUCCESS;
1982}
1983
1984
1985DEFUN (ospf_abr_type,
1986 ospf_abr_type_cmd,
1987 "ospf abr-type (cisco|ibm|shortcut|standard)",
1988 "OSPF specific commands\n"
1989 "Set OSPF ABR type\n"
1990 "Alternative ABR, cisco implementation\n"
1991 "Alternative ABR, IBM implementation\n"
1992 "Shortcut ABR\n"
1993 "Standard behavior (RFC2328)\n")
1994{
paul68980082003-03-25 05:07:42 +00001995 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001996 u_char abr_type = OSPF_ABR_UNKNOWN;
1997
1998 if (strncmp (argv[0], "c", 1) == 0)
1999 abr_type = OSPF_ABR_CISCO;
2000 else if (strncmp (argv[0], "i", 1) == 0)
2001 abr_type = OSPF_ABR_IBM;
2002 else if (strncmp (argv[0], "sh", 2) == 0)
2003 abr_type = OSPF_ABR_SHORTCUT;
2004 else if (strncmp (argv[0], "st", 2) == 0)
2005 abr_type = OSPF_ABR_STAND;
2006 else
2007 return CMD_WARNING;
2008
2009 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002010 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002011 {
paul68980082003-03-25 05:07:42 +00002012 ospf->abr_type = abr_type;
2013 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002014 }
2015
2016 return CMD_SUCCESS;
2017}
2018
2019DEFUN (no_ospf_abr_type,
2020 no_ospf_abr_type_cmd,
2021 "no ospf abr-type (cisco|ibm|shortcut)",
2022 NO_STR
2023 "OSPF specific commands\n"
2024 "Set OSPF ABR type\n"
2025 "Alternative ABR, cisco implementation\n"
2026 "Alternative ABR, IBM implementation\n"
2027 "Shortcut ABR\n")
2028{
paul68980082003-03-25 05:07:42 +00002029 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002030 u_char abr_type = OSPF_ABR_UNKNOWN;
2031
2032 if (strncmp (argv[0], "c", 1) == 0)
2033 abr_type = OSPF_ABR_CISCO;
2034 else if (strncmp (argv[0], "i", 1) == 0)
2035 abr_type = OSPF_ABR_IBM;
2036 else if (strncmp (argv[0], "s", 1) == 0)
2037 abr_type = OSPF_ABR_SHORTCUT;
2038 else
2039 return CMD_WARNING;
2040
2041 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002042 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002043 {
paul68980082003-03-25 05:07:42 +00002044 ospf->abr_type = OSPF_ABR_STAND;
2045 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002046 }
2047
2048 return CMD_SUCCESS;
2049}
2050
2051DEFUN (ospf_compatible_rfc1583,
2052 ospf_compatible_rfc1583_cmd,
2053 "compatible rfc1583",
2054 "OSPF compatibility list\n"
2055 "compatible with RFC 1583\n")
2056{
2057 struct ospf *ospf = vty->index;
2058
2059 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2060 {
2061 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002062 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002063 }
2064 return CMD_SUCCESS;
2065}
2066
2067DEFUN (no_ospf_compatible_rfc1583,
2068 no_ospf_compatible_rfc1583_cmd,
2069 "no compatible rfc1583",
2070 NO_STR
2071 "OSPF compatibility list\n"
2072 "compatible with RFC 1583\n")
2073{
2074 struct ospf *ospf = vty->index;
2075
2076 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2077 {
2078 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
paul68980082003-03-25 05:07:42 +00002079 ospf_spf_calculate_schedule (ospf);
paul718e3742002-12-13 20:15:29 +00002080 }
2081 return CMD_SUCCESS;
2082}
2083
2084ALIAS (ospf_compatible_rfc1583,
2085 ospf_rfc1583_flag_cmd,
2086 "ospf rfc1583compatibility",
2087 "OSPF specific commands\n"
2088 "Enable the RFC1583Compatibility flag\n")
2089
2090ALIAS (no_ospf_compatible_rfc1583,
2091 no_ospf_rfc1583_flag_cmd,
2092 "no ospf rfc1583compatibility",
2093 NO_STR
2094 "OSPF specific commands\n"
2095 "Disable the RFC1583Compatibility flag\n")
2096
paula2c62832003-04-23 17:01:31 +00002097DEFUN (ospf_timers_spf,
2098 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002099 "timers spf <0-4294967295> <0-4294967295>",
2100 "Adjust routing timers\n"
2101 "OSPF SPF timers\n"
2102 "Delay between receiving a change to SPF calculation\n"
2103 "Hold time between consecutive SPF calculations\n")
2104{
2105 struct ospf *ospf = vty->index;
2106 u_int32_t delay, hold;
2107
2108 VTY_GET_UINT32 ("SPF delay timer", delay, argv[0]);
2109 VTY_GET_UINT32 ("SPF hold timer", hold, argv[1]);
2110
2111 ospf_timers_spf_set (ospf, delay, hold);
2112
2113 return CMD_SUCCESS;
2114}
2115
paula2c62832003-04-23 17:01:31 +00002116DEFUN (no_ospf_timers_spf,
2117 no_ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002118 "no timers spf",
2119 NO_STR
2120 "Adjust routing timers\n"
2121 "OSPF SPF timers\n")
2122{
paul68980082003-03-25 05:07:42 +00002123 struct ospf *ospf = vty->index;
2124
2125 ospf->spf_delay = OSPF_SPF_DELAY_DEFAULT;
2126 ospf->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002127
2128 return CMD_SUCCESS;
2129}
2130
2131
paula2c62832003-04-23 17:01:31 +00002132DEFUN (ospf_neighbor,
2133 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002134 "neighbor A.B.C.D",
2135 NEIGHBOR_STR
2136 "Neighbor IP address\n")
2137{
2138 struct ospf *ospf = vty->index;
2139 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002140 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2141 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002142
2143 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2144
2145 if (argc > 1)
2146 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2147
2148 if (argc > 2)
2149 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2150
2151 ospf_nbr_nbma_set (ospf, nbr_addr);
2152 if (argc > 1)
2153 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2154 if (argc > 2)
2155 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2156
2157 return CMD_SUCCESS;
2158}
2159
paula2c62832003-04-23 17:01:31 +00002160ALIAS (ospf_neighbor,
2161 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002162 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2163 NEIGHBOR_STR
2164 "Neighbor IP address\n"
2165 "Neighbor Priority\n"
2166 "Priority\n"
2167 "Dead Neighbor Polling interval\n"
2168 "Seconds\n")
2169
paula2c62832003-04-23 17:01:31 +00002170ALIAS (ospf_neighbor,
2171 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002172 "neighbor A.B.C.D priority <0-255>",
2173 NEIGHBOR_STR
2174 "Neighbor IP address\n"
2175 "Neighbor Priority\n"
2176 "Seconds\n")
2177
paula2c62832003-04-23 17:01:31 +00002178DEFUN (ospf_neighbor_poll_interval,
2179 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002180 "neighbor A.B.C.D poll-interval <1-65535>",
2181 NEIGHBOR_STR
2182 "Neighbor IP address\n"
2183 "Dead Neighbor Polling interval\n"
2184 "Seconds\n")
2185{
2186 struct ospf *ospf = vty->index;
2187 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002188 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2189 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002190
2191 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2192
2193 if (argc > 1)
2194 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2195
2196 if (argc > 2)
2197 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2198
2199 ospf_nbr_nbma_set (ospf, nbr_addr);
2200 if (argc > 1)
2201 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2202 if (argc > 2)
2203 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2204
2205 return CMD_SUCCESS;
2206}
2207
paula2c62832003-04-23 17:01:31 +00002208ALIAS (ospf_neighbor_poll_interval,
2209 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002210 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2211 NEIGHBOR_STR
2212 "Neighbor address\n"
2213 "OSPF dead-router polling interval\n"
2214 "Seconds\n"
2215 "OSPF priority of non-broadcast neighbor\n"
2216 "Priority\n")
2217
paula2c62832003-04-23 17:01:31 +00002218DEFUN (no_ospf_neighbor,
2219 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002220 "no neighbor A.B.C.D",
2221 NO_STR
2222 NEIGHBOR_STR
2223 "Neighbor IP address\n")
2224{
2225 struct ospf *ospf = vty->index;
2226 struct in_addr nbr_addr;
2227 int ret;
2228
2229 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2230
2231 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2232
2233 return CMD_SUCCESS;
2234}
2235
paula2c62832003-04-23 17:01:31 +00002236ALIAS (no_ospf_neighbor,
2237 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002238 "no neighbor A.B.C.D priority <0-255>",
2239 NO_STR
2240 NEIGHBOR_STR
2241 "Neighbor IP address\n"
2242 "Neighbor Priority\n"
2243 "Priority\n")
2244
paula2c62832003-04-23 17:01:31 +00002245ALIAS (no_ospf_neighbor,
2246 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002247 "no neighbor A.B.C.D poll-interval <1-65535>",
2248 NO_STR
2249 NEIGHBOR_STR
2250 "Neighbor IP address\n"
2251 "Dead Neighbor Polling interval\n"
2252 "Seconds\n")
2253
paula2c62832003-04-23 17:01:31 +00002254ALIAS (no_ospf_neighbor,
2255 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002256 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2257 NO_STR
2258 NEIGHBOR_STR
2259 "Neighbor IP address\n"
2260 "Neighbor Priority\n"
2261 "Priority\n"
2262 "Dead Neighbor Polling interval\n"
2263 "Seconds\n")
2264
2265
paula2c62832003-04-23 17:01:31 +00002266DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002267 "refresh timer <10-1800>",
2268 "Adjust refresh parameters\n"
2269 "Set refresh timer\n"
2270 "Timer value in seconds\n")
2271{
2272 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002273 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002274
2275 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2276 interval = (interval / 10) * 10;
2277
2278 ospf_timers_refresh_set (ospf, interval);
2279
2280 return CMD_SUCCESS;
2281}
2282
paula2c62832003-04-23 17:01:31 +00002283DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002284 "no refresh timer <10-1800>",
2285 "Adjust refresh parameters\n"
2286 "Unset refresh timer\n"
2287 "Timer value in seconds\n")
2288{
2289 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002290 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002291
2292 if (argc == 1)
2293 {
2294 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2295
2296 if (ospf->lsa_refresh_interval != interval ||
2297 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2298 return CMD_SUCCESS;
2299 }
2300
2301 ospf_timers_refresh_unset (ospf);
2302
2303 return CMD_SUCCESS;
2304}
2305
paula2c62832003-04-23 17:01:31 +00002306ALIAS (no_ospf_refresh_timer,
2307 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002308 "no refresh timer",
2309 "Adjust refresh parameters\n"
2310 "Unset refresh timer\n")
2311
paula2c62832003-04-23 17:01:31 +00002312DEFUN (ospf_auto_cost_reference_bandwidth,
2313 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002314 "auto-cost reference-bandwidth <1-4294967>",
2315 "Calculate OSPF interface cost according to bandwidth\n"
2316 "Use reference bandwidth method to assign OSPF cost\n"
2317 "The reference bandwidth in terms of Mbits per second\n")
2318{
paul68980082003-03-25 05:07:42 +00002319 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002320 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002321 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002322
2323 refbw = strtol (argv[0], NULL, 10);
2324 if (refbw < 1 || refbw > 4294967)
2325 {
2326 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2327 return CMD_WARNING;
2328 }
2329
2330 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002331 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002332 return CMD_SUCCESS;
2333
paul68980082003-03-25 05:07:42 +00002334 ospf->ref_bandwidth = refbw * 1000;
paul718e3742002-12-13 20:15:29 +00002335 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2336 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2337
paul020709f2003-04-04 02:44:16 +00002338 for (node = listhead (om->iflist); node; nextnode (node))
2339 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002340
2341 return CMD_SUCCESS;
2342}
2343
paula2c62832003-04-23 17:01:31 +00002344DEFUN (no_ospf_auto_cost_reference_bandwidth,
2345 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002346 "no auto-cost reference-bandwidth",
2347 NO_STR
2348 "Calculate OSPF interface cost according to bandwidth\n"
2349 "Use reference bandwidth method to assign OSPF cost\n")
2350{
paul68980082003-03-25 05:07:42 +00002351 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002352 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002353
paul68980082003-03-25 05:07:42 +00002354 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002355 return CMD_SUCCESS;
2356
paul68980082003-03-25 05:07:42 +00002357 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002358 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2359 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2360
paul020709f2003-04-04 02:44:16 +00002361 for (node = listhead (om->iflist); node; nextnode (node))
2362 ospf_if_recalculate_output_cost (getdata (node));
paul718e3742002-12-13 20:15:29 +00002363
2364 return CMD_SUCCESS;
2365}
2366
hassoeb1ce602004-10-08 08:17:22 +00002367const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002368{
2369 "Unknown",
2370 "Standard (RFC2328)",
2371 "Alternative IBM",
2372 "Alternative Cisco",
2373 "Alternative Shortcut"
2374};
2375
hassoeb1ce602004-10-08 08:17:22 +00002376const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002377{
2378 "Default",
2379 "Enabled",
2380 "Disabled"
2381};
2382
2383
2384
2385void
2386show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2387{
2388 /* Show Area ID. */
2389 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2390
2391 /* Show Area type/mode. */
2392 if (OSPF_IS_AREA_BACKBONE (area))
2393 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2394 else
2395 {
2396 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002397 vty_out (vty, " (Stub%s%s)",
2398 area->no_summary ? ", no summary" : "",
2399 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002400
paulb0a053b2003-06-22 09:04:47 +00002401 else if (area->external_routing == OSPF_AREA_NSSA)
2402 vty_out (vty, " (NSSA%s%s)",
2403 area->no_summary ? ", no summary" : "",
2404 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002405
2406 vty_out (vty, "%s", VTY_NEWLINE);
2407 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002408 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002409 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002410 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002411 }
2412
2413 /* Show number of interfaces. */
2414 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2415 "Active: %d%s", listcount (area->oiflist),
2416 area->act_ints, VTY_NEWLINE);
2417
paul718e3742002-12-13 20:15:29 +00002418 if (area->external_routing == OSPF_AREA_NSSA)
2419 {
2420 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00002421 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002422 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2423 VTY_NEWLINE);
2424 else if (area->NSSATranslatorState)
2425 {
2426 vty_out (vty, " We are an ABR and ");
2427 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2428 vty_out (vty, "the NSSA Elected Translator. %s",
2429 VTY_NEWLINE);
2430 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2431 vty_out (vty, "always an NSSA Translator. %s",
2432 VTY_NEWLINE);
2433 }
paul718e3742002-12-13 20:15:29 +00002434 else
paulb0a053b2003-06-22 09:04:47 +00002435 {
2436 vty_out (vty, " We are an ABR, but ");
2437 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2438 vty_out (vty, "not the NSSA Elected Translator. %s",
2439 VTY_NEWLINE);
2440 else
hassoc6b87812004-12-22 13:09:59 +00002441 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002442 VTY_NEWLINE);
2443 }
paul718e3742002-12-13 20:15:29 +00002444 }
paul718e3742002-12-13 20:15:29 +00002445
2446 /* Show number of fully adjacent neighbors. */
2447 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002448 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002449
2450 /* Show authentication type. */
2451 vty_out (vty, " Area has ");
2452 if (area->auth_type == OSPF_AUTH_NULL)
2453 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2454 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2455 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2456 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2457 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2458
2459 if (!OSPF_IS_AREA_BACKBONE (area))
2460 vty_out (vty, " Number of full virtual adjacencies going through"
2461 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2462
2463 /* Show SPF calculation times. */
2464 vty_out (vty, " SPF algorithm executed %d times%s",
2465 area->spf_calculation, VTY_NEWLINE);
2466
2467 /* Show number of LSA. */
2468 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002469 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2470 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2471 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2472 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2473 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2474 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2475 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2476 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2477 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2478 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2479 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2480 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2481 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2482 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2483 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2484#ifdef HAVE_OPAQUE_LSA
2485 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2486 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2487 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2488 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2489 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2490 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2491#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002492 vty_out (vty, "%s", VTY_NEWLINE);
2493}
2494
2495DEFUN (show_ip_ospf,
2496 show_ip_ospf_cmd,
2497 "show ip ospf",
2498 SHOW_STR
2499 IP_STR
2500 "OSPF information\n")
2501{
hasso52dc7ee2004-09-23 19:18:23 +00002502 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002503 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002504 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002505
2506 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002507 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002508 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002509 {
2510 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2511 return CMD_SUCCESS;
2512 }
2513
2514 /* Show Router ID. */
2515 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002516 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002517 VTY_NEWLINE);
2518
2519 /* Show capability. */
2520 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2521 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2522 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002523 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002524 "enabled" : "disabled", VTY_NEWLINE);
2525#ifdef HAVE_OPAQUE_LSA
2526 vty_out (vty, " OpaqueCapability flag is %s%s%s",
paul68980082003-03-25 05:07:42 +00002527 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002528 "enabled" : "disabled",
paul68980082003-03-25 05:07:42 +00002529 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
paul718e3742002-12-13 20:15:29 +00002530 " (origination blocked)" : "",
2531 VTY_NEWLINE);
2532#endif /* HAVE_OPAQUE_LSA */
2533
2534 /* Show SPF timers. */
2535 vty_out (vty, " SPF schedule delay %d secs, Hold time between two SPFs %d secs%s",
paul68980082003-03-25 05:07:42 +00002536 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002537
2538 /* Show refresh parameters. */
2539 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002540 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002541
2542 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002543 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002544 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002545 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002546
paul68980082003-03-25 05:07:42 +00002547 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002548 vty_out (vty, " This router is an ASBR "
2549 "(injecting external routing information)%s", VTY_NEWLINE);
2550
2551 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002552 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2553 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2554 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2555#ifdef HAVE_OPAQUE_LSA
2556 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2557 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2558 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2559#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002560 /* Show number of areas attached. */
2561 vty_out (vty, " Number of areas attached to this router: %d%s%s",
paul68980082003-03-25 05:07:42 +00002562 listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002563
2564 /* Show each area status. */
paul68980082003-03-25 05:07:42 +00002565 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002566 if ((area = getdata (node)) != NULL)
2567 show_ip_ospf_area (vty, area);
2568
2569 return CMD_SUCCESS;
2570}
2571
2572
ajsfd651fa2005-03-29 16:08:16 +00002573static void
paul68980082003-03-25 05:07:42 +00002574show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2575 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002576{
ajsfd651fa2005-03-29 16:08:16 +00002577 int is_up;
paul718e3742002-12-13 20:15:29 +00002578 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002579 struct route_node *rn;
2580 char buf[9];
2581
paul718e3742002-12-13 20:15:29 +00002582 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002583 vty_out (vty, "%s is %s%s", ifp->name,
2584 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
2585 vty_out (vty, " MTU %u bytes, BW %u Kbit%s",
2586 ifp->mtu, ifp->bandwidth, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002587
2588 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002589 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002590 {
2591 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2592 return;
2593 }
ajsfd651fa2005-03-29 16:08:16 +00002594 else if (!is_up)
2595 {
2596 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2597 VTY_NEWLINE);
2598 return;
2599 }
2600
paul718e3742002-12-13 20:15:29 +00002601 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2602 {
2603 struct ospf_interface *oi = rn->info;
2604
2605 if (oi == NULL)
2606 continue;
2607
2608 /* Show OSPF interface information. */
2609 vty_out (vty, " Internet Address %s/%d,",
2610 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2611
hasso3fb9cd62004-10-19 19:44:43 +00002612 if (oi->connected->destination)
2613 vty_out (vty, " %s %s,",
2614 ((ifp->flags & IFF_POINTOPOINT) ? "Peer" : "Broadcast"),
2615 inet_ntoa (oi->connected->destination->u.prefix4));
2616
paul718e3742002-12-13 20:15:29 +00002617 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2618 VTY_NEWLINE);
2619
2620 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002621 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002622 oi->output_cost, VTY_NEWLINE);
2623
2624 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2625 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2626 PRIORITY (oi), VTY_NEWLINE);
2627
2628 /* Show DR information. */
2629 if (DR (oi).s_addr == 0)
2630 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2631 else
2632 {
2633 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2634 if (nbr == NULL)
2635 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2636 else
2637 {
2638 vty_out (vty, " Designated Router (ID) %s,",
2639 inet_ntoa (nbr->router_id));
2640 vty_out (vty, " Interface Address %s%s",
2641 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2642 }
2643 }
2644
2645 /* Show BDR information. */
2646 if (BDR (oi).s_addr == 0)
2647 vty_out (vty, " No backup designated router on this network%s",
2648 VTY_NEWLINE);
2649 else
2650 {
2651 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2652 if (nbr == NULL)
2653 vty_out (vty, " No backup designated router on this network%s",
2654 VTY_NEWLINE);
2655 else
2656 {
2657 vty_out (vty, " Backup Designated Router (ID) %s,",
2658 inet_ntoa (nbr->router_id));
2659 vty_out (vty, " Interface Address %s%s",
2660 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2661 }
2662 }
ajsba6454e2005-02-08 15:37:30 +00002663
2664 vty_out (vty, " Multicast group memberships:");
2665 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_ALLROUTERS))
2666 vty_out (vty, " OSPFAllRouters");
2667 if (CHECK_FLAG(oi->multicast_memberships, MEMBER_DROUTERS))
2668 vty_out (vty, " OSPFDesignatedRouters");
2669 if (!CHECK_FLAG(oi->multicast_memberships,
2670 MEMBER_ALLROUTERS|MEMBER_DROUTERS))
2671 vty_out (vty, " <None>");
2672 vty_out (vty, "%s", VTY_NEWLINE);
2673
paul718e3742002-12-13 20:15:29 +00002674 vty_out (vty, " Timer intervals configured,");
2675 vty_out (vty, " Hello %d, Dead %d, Wait %d, Retransmit %d%s",
2676 OSPF_IF_PARAM (oi, v_hello), OSPF_IF_PARAM (oi, v_wait),
2677 OSPF_IF_PARAM (oi, v_wait),
2678 OSPF_IF_PARAM (oi, retransmit_interval),
2679 VTY_NEWLINE);
2680
2681 if (OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_ACTIVE)
2682 vty_out (vty, " Hello due in %s%s",
2683 ospf_timer_dump (oi->t_hello, buf, 9), VTY_NEWLINE);
2684 else /* OSPF_IF_PASSIVE is set */
2685 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2686
2687 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00002688 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00002689 VTY_NEWLINE);
2690 }
2691}
2692
2693DEFUN (show_ip_ospf_interface,
2694 show_ip_ospf_interface_cmd,
2695 "show ip ospf interface [INTERFACE]",
2696 SHOW_STR
2697 IP_STR
2698 "OSPF information\n"
2699 "Interface information\n"
2700 "Interface name\n")
2701{
2702 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00002703 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002704 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002705
paul020709f2003-04-04 02:44:16 +00002706 ospf = ospf_lookup ();
2707
paul718e3742002-12-13 20:15:29 +00002708 /* Show All Interfaces. */
2709 if (argc == 0)
2710 for (node = listhead (iflist); node; nextnode (node))
paul68980082003-03-25 05:07:42 +00002711 show_ip_ospf_interface_sub (vty, ospf, node->data);
paul718e3742002-12-13 20:15:29 +00002712 /* Interface name is specified. */
2713 else
2714 {
2715 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2716 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2717 else
paul68980082003-03-25 05:07:42 +00002718 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00002719 }
2720
2721 return CMD_SUCCESS;
2722}
2723
2724void
2725show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
2726{
2727 struct route_node *rn;
2728 struct ospf_neighbor *nbr;
2729 char msgbuf[16];
2730 char timebuf[9];
2731
2732 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2733 if ((nbr = rn->info))
2734 /* Do not show myself. */
2735 if (nbr != oi->nbr_self)
2736 /* Down state is not shown. */
2737 if (nbr->state != NSM_Down)
2738 {
2739 ospf_nbr_state_message (nbr, msgbuf, 16);
2740
2741 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2742 vty_out (vty, "%-15s %3d %-15s %8s ",
2743 "-", nbr->priority,
2744 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2745 else
2746 vty_out (vty, "%-15s %3d %-15s %8s ",
2747 inet_ntoa (nbr->router_id), nbr->priority,
2748 msgbuf, ospf_timer_dump (nbr->t_inactivity, timebuf, 9));
2749 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
2750 vty_out (vty, "%-15s %5ld %5ld %5d%s",
2751 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
2752 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
2753 VTY_NEWLINE);
2754 }
2755}
2756
2757DEFUN (show_ip_ospf_neighbor,
2758 show_ip_ospf_neighbor_cmd,
2759 "show ip ospf neighbor",
2760 SHOW_STR
2761 IP_STR
2762 "OSPF information\n"
2763 "Neighbor list\n")
2764{
paul020709f2003-04-04 02:44:16 +00002765 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002766 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002767
paul020709f2003-04-04 02:44:16 +00002768 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002769 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002770 {
2771 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2772 return CMD_SUCCESS;
2773 }
2774
2775 /* Show All neighbors. */
2776 vty_out (vty, "%sNeighbor ID Pri State Dead "
2777 "Time Address Interface RXmtL "
2778 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2779
paul68980082003-03-25 05:07:42 +00002780 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul020709f2003-04-04 02:44:16 +00002781 show_ip_ospf_neighbor_sub (vty, getdata (node));
paul718e3742002-12-13 20:15:29 +00002782
2783 return CMD_SUCCESS;
2784}
2785
2786DEFUN (show_ip_ospf_neighbor_all,
2787 show_ip_ospf_neighbor_all_cmd,
2788 "show ip ospf neighbor all",
2789 SHOW_STR
2790 IP_STR
2791 "OSPF information\n"
2792 "Neighbor list\n"
2793 "include down status neighbor\n")
2794{
paul68980082003-03-25 05:07:42 +00002795 struct ospf *ospf = vty->index;
hasso52dc7ee2004-09-23 19:18:23 +00002796 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002797
paul68980082003-03-25 05:07:42 +00002798 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002799 {
2800 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2801 return CMD_SUCCESS;
2802 }
2803
2804 /* Show All neighbors. */
2805 vty_out (vty, "%sNeighbor ID Pri State Dead "
2806 "Time Address Interface RXmtL "
2807 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2808
paul68980082003-03-25 05:07:42 +00002809 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00002810 {
2811 struct ospf_interface *oi = getdata (node);
hasso52dc7ee2004-09-23 19:18:23 +00002812 struct listnode *nbr_node;
paul718e3742002-12-13 20:15:29 +00002813
2814 show_ip_ospf_neighbor_sub (vty, oi);
2815
2816 /* print Down neighbor status */
2817 for (nbr_node = listhead (oi->nbr_nbma); nbr_node; nextnode (nbr_node))
2818 {
2819 struct ospf_nbr_nbma *nbr_nbma;
2820
2821 nbr_nbma = getdata (nbr_node);
2822
2823 if (nbr_nbma->nbr == NULL
2824 || nbr_nbma->nbr->state == NSM_Down)
2825 {
2826 vty_out (vty, "%-15s %3d %-15s %8s ",
2827 "-", nbr_nbma->priority, "Down", "-");
2828 vty_out (vty, "%-15s %-15s %5d %5d %5d%s",
2829 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
2830 0, 0, 0, VTY_NEWLINE);
2831 }
2832 }
2833 }
2834
2835 return CMD_SUCCESS;
2836}
2837
2838DEFUN (show_ip_ospf_neighbor_int,
2839 show_ip_ospf_neighbor_int_cmd,
2840 "show ip ospf neighbor A.B.C.D",
2841 SHOW_STR
2842 IP_STR
2843 "OSPF information\n"
2844 "Neighbor list\n"
2845 "Interface name\n")
2846{
paul020709f2003-04-04 02:44:16 +00002847 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00002848 struct ospf_interface *oi;
2849 struct in_addr addr;
2850 int ret;
2851
paul718e3742002-12-13 20:15:29 +00002852 ret = inet_aton (argv[0], &addr);
2853 if (!ret)
2854 {
2855 vty_out (vty, "Please specify interface address by A.B.C.D%s",
2856 VTY_NEWLINE);
2857 return CMD_WARNING;
2858 }
2859
paul020709f2003-04-04 02:44:16 +00002860 ospf = ospf_lookup ();
2861 if (ospf == NULL)
2862 {
2863 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2864 return CMD_SUCCESS;
2865 }
2866
paul68980082003-03-25 05:07:42 +00002867 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00002868 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
2869 else
2870 {
2871 vty_out (vty, "%sNeighbor ID Pri State Dead "
2872 "Time Address Interface RXmtL "
2873 "RqstL DBsmL%s", VTY_NEWLINE, VTY_NEWLINE);
2874 show_ip_ospf_neighbor_sub (vty, oi);
2875 }
2876
2877 return CMD_SUCCESS;
2878}
2879
2880void
2881show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
2882 struct ospf_nbr_nbma *nbr_nbma)
2883{
2884 char timebuf[9];
2885
2886 /* Show neighbor ID. */
2887 vty_out (vty, " Neighbor %s,", "-");
2888
2889 /* Show interface address. */
2890 vty_out (vty, " interface address %s%s",
2891 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
2892 /* Show Area ID. */
2893 vty_out (vty, " In the area %s via interface %s%s",
2894 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
2895 /* Show neighbor priority and state. */
2896 vty_out (vty, " Neighbor priority is %d, State is %s,",
2897 nbr_nbma->priority, "Down");
2898 /* Show state changes. */
2899 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
2900
2901 /* Show PollInterval */
2902 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
2903
2904 /* Show poll-interval timer. */
2905 vty_out (vty, " Poll timer due in %s%s",
2906 ospf_timer_dump (nbr_nbma->t_poll, timebuf, 9), VTY_NEWLINE);
2907
2908 /* Show poll-interval timer thread. */
2909 vty_out (vty, " Thread Poll Timer %s%s",
2910 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
2911}
2912
2913void
2914show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
2915 struct ospf_neighbor *nbr)
2916{
2917 char timebuf[9];
2918
2919 /* Show neighbor ID. */
2920 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
2921 vty_out (vty, " Neighbor %s,", "-");
2922 else
2923 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
2924
2925 /* Show interface address. */
2926 vty_out (vty, " interface address %s%s",
2927 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2928 /* Show Area ID. */
2929 vty_out (vty, " In the area %s via interface %s%s",
2930 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
2931 /* Show neighbor priority and state. */
2932 vty_out (vty, " Neighbor priority is %d, State is %s,",
2933 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
2934 /* Show state changes. */
2935 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
2936
2937 /* Show Designated Rotuer ID. */
2938 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
2939 /* Show Backup Designated Rotuer ID. */
2940 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
2941 /* Show options. */
2942 vty_out (vty, " Options %d %s%s", nbr->options,
2943 ospf_options_dump (nbr->options), VTY_NEWLINE);
2944 /* Show Router Dead interval timer. */
2945 vty_out (vty, " Dead timer due in %s%s",
2946 ospf_timer_dump (nbr->t_inactivity, timebuf, 9), VTY_NEWLINE);
2947 /* Show Database Summary list. */
2948 vty_out (vty, " Database Summary List %d%s",
2949 ospf_db_summary_count (nbr), VTY_NEWLINE);
2950 /* Show Link State Request list. */
2951 vty_out (vty, " Link State Request List %ld%s",
2952 ospf_ls_request_count (nbr), VTY_NEWLINE);
2953 /* Show Link State Retransmission list. */
2954 vty_out (vty, " Link State Retransmission List %ld%s",
2955 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
2956 /* Show inactivity timer thread. */
2957 vty_out (vty, " Thread Inactivity Timer %s%s",
2958 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
2959 /* Show Database Description retransmission thread. */
2960 vty_out (vty, " Thread Database Description Retransmision %s%s",
2961 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
2962 /* Show Link State Request Retransmission thread. */
2963 vty_out (vty, " Thread Link State Request Retransmission %s%s",
2964 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
2965 /* Show Link State Update Retransmission thread. */
2966 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
2967 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
2968}
2969
2970DEFUN (show_ip_ospf_neighbor_id,
2971 show_ip_ospf_neighbor_id_cmd,
2972 "show ip ospf neighbor A.B.C.D",
2973 SHOW_STR
2974 IP_STR
2975 "OSPF information\n"
2976 "Neighbor list\n"
2977 "Neighbor ID\n")
2978{
paul020709f2003-04-04 02:44:16 +00002979 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00002980 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00002981 struct ospf_neighbor *nbr;
2982 struct in_addr router_id;
2983 int ret;
2984
2985 ret = inet_aton (argv[0], &router_id);
2986 if (!ret)
2987 {
2988 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
2989 return CMD_WARNING;
2990 }
2991
paul020709f2003-04-04 02:44:16 +00002992 ospf = ospf_lookup ();
2993 if (ospf == NULL)
2994 {
2995 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2996 return CMD_SUCCESS;
2997 }
2998
paul68980082003-03-25 05:07:42 +00002999 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003000 {
3001 struct ospf_interface *oi = getdata (node);
3002
3003 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
3004 {
3005 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3006 return CMD_SUCCESS;
3007 }
3008 }
3009
3010 /* Nothing to show. */
3011 return CMD_SUCCESS;
3012}
3013
3014DEFUN (show_ip_ospf_neighbor_detail,
3015 show_ip_ospf_neighbor_detail_cmd,
3016 "show ip ospf neighbor detail",
3017 SHOW_STR
3018 IP_STR
3019 "OSPF information\n"
3020 "Neighbor list\n"
3021 "detail of all neighbors\n")
3022{
paul020709f2003-04-04 02:44:16 +00003023 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003024 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003025
paul020709f2003-04-04 02:44:16 +00003026 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003027 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003028 {
3029 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3030 return CMD_SUCCESS;
3031 }
paul718e3742002-12-13 20:15:29 +00003032
paul68980082003-03-25 05:07:42 +00003033 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003034 {
3035 struct ospf_interface *oi = getdata (node);
3036 struct route_node *rn;
3037 struct ospf_neighbor *nbr;
3038
3039 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3040 if ((nbr = rn->info))
3041 if (nbr != oi->nbr_self)
3042 if (nbr->state != NSM_Down)
3043 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3044 }
3045
3046 return CMD_SUCCESS;
3047}
3048
3049DEFUN (show_ip_ospf_neighbor_detail_all,
3050 show_ip_ospf_neighbor_detail_all_cmd,
3051 "show ip ospf neighbor detail all",
3052 SHOW_STR
3053 IP_STR
3054 "OSPF information\n"
3055 "Neighbor list\n"
3056 "detail of all neighbors\n"
3057 "include down status neighbor\n")
3058{
paul020709f2003-04-04 02:44:16 +00003059 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003060 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003061
paul020709f2003-04-04 02:44:16 +00003062 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003063 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003064 {
3065 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3066 return CMD_SUCCESS;
3067 }
paul718e3742002-12-13 20:15:29 +00003068
paul68980082003-03-25 05:07:42 +00003069 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003070 {
3071 struct ospf_interface *oi = getdata (node);
3072 struct route_node *rn;
3073 struct ospf_neighbor *nbr;
3074
3075 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3076 if ((nbr = rn->info))
3077 if (nbr != oi->nbr_self)
3078 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3079 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3080
3081 if (oi->type == OSPF_IFTYPE_NBMA)
3082 {
hasso52dc7ee2004-09-23 19:18:23 +00003083 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003084
3085 for (nd = listhead (oi->nbr_nbma); nd; nextnode (nd))
3086 {
3087 struct ospf_nbr_nbma *nbr_nbma = getdata (nd);
3088 if (nbr_nbma->nbr == NULL
3089 || nbr_nbma->nbr->state == NSM_Down)
3090 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
3091 }
3092 }
3093 }
3094
3095 return CMD_SUCCESS;
3096}
3097
3098DEFUN (show_ip_ospf_neighbor_int_detail,
3099 show_ip_ospf_neighbor_int_detail_cmd,
3100 "show ip ospf neighbor A.B.C.D detail",
3101 SHOW_STR
3102 IP_STR
3103 "OSPF information\n"
3104 "Neighbor list\n"
3105 "Interface address\n"
3106 "detail of all neighbors")
3107{
paul020709f2003-04-04 02:44:16 +00003108 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003109 struct ospf_interface *oi;
3110 struct in_addr addr;
3111 int ret;
3112
3113 ret = inet_aton (argv[0], &addr);
3114 if (!ret)
3115 {
3116 vty_out (vty, "Please specify interface address by A.B.C.D%s",
3117 VTY_NEWLINE);
3118 return CMD_WARNING;
3119 }
3120
paul020709f2003-04-04 02:44:16 +00003121 ospf = ospf_lookup ();
3122 if (ospf == NULL)
3123 {
3124 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3125 return CMD_SUCCESS;
3126 }
paul68980082003-03-25 05:07:42 +00003127
paul020709f2003-04-04 02:44:16 +00003128 if ((oi = ospf_if_is_configured (ospf, &addr)) == NULL)
paul718e3742002-12-13 20:15:29 +00003129 vty_out (vty, "No such interface address%s", VTY_NEWLINE);
3130 else
3131 {
3132 struct route_node *rn;
3133 struct ospf_neighbor *nbr;
3134
3135 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3136 if ((nbr = rn->info))
3137 if (nbr != oi->nbr_self)
3138 if (nbr->state != NSM_Down)
3139 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3140 }
3141
3142 return CMD_SUCCESS;
3143}
3144
3145
3146/* Show functions */
3147int
paul020709f2003-04-04 02:44:16 +00003148show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003149{
paul718e3742002-12-13 20:15:29 +00003150 struct router_lsa *rl;
3151 struct summary_lsa *sl;
3152 struct as_external_lsa *asel;
3153 struct prefix_ipv4 p;
3154
3155 if (lsa != NULL)
3156 /* If self option is set, check LSA self flag. */
3157 if (self == 0 || IS_LSA_SELF (lsa))
3158 {
3159 /* LSA common part show. */
3160 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3161 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3162 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3163 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3164 /* LSA specific part show. */
3165 switch (lsa->data->type)
3166 {
3167 case OSPF_ROUTER_LSA:
3168 rl = (struct router_lsa *) lsa->data;
3169 vty_out (vty, " %-d", ntohs (rl->links));
3170 break;
3171 case OSPF_SUMMARY_LSA:
3172 sl = (struct summary_lsa *) lsa->data;
3173
3174 p.family = AF_INET;
3175 p.prefix = sl->header.id;
3176 p.prefixlen = ip_masklen (sl->mask);
3177 apply_mask_ipv4 (&p);
3178
3179 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3180 break;
3181 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003182 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003183 asel = (struct as_external_lsa *) lsa->data;
3184
3185 p.family = AF_INET;
3186 p.prefix = asel->header.id;
3187 p.prefixlen = ip_masklen (asel->mask);
3188 apply_mask_ipv4 (&p);
3189
3190 vty_out (vty, " %s %s/%d [0x%lx]",
3191 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3192 inet_ntoa (p.prefix), p.prefixlen,
3193 (u_long)ntohl (asel->e[0].route_tag));
3194 break;
3195 case OSPF_NETWORK_LSA:
3196 case OSPF_ASBR_SUMMARY_LSA:
3197#ifdef HAVE_OPAQUE_LSA
3198 case OSPF_OPAQUE_LINK_LSA:
3199 case OSPF_OPAQUE_AREA_LSA:
3200 case OSPF_OPAQUE_AS_LSA:
3201#endif /* HAVE_OPAQUE_LSA */
3202 default:
3203 break;
3204 }
3205 vty_out (vty, VTY_NEWLINE);
3206 }
3207
3208 return 0;
3209}
3210
hassoeb1ce602004-10-08 08:17:22 +00003211const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003212{
3213 "unknown",
3214 "Router Link States",
3215 "Net Link States",
3216 "Summary Link States",
3217 "ASBR-Summary Link States",
3218 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003219 "Group Membership LSA",
3220 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003221#ifdef HAVE_OPAQUE_LSA
3222 "Type-8 LSA",
3223 "Link-Local Opaque-LSA",
3224 "Area-Local Opaque-LSA",
3225 "AS-external Opaque-LSA",
3226#endif /* HAVE_OPAQUE_LSA */
3227};
3228
3229#define SHOW_OSPF_COMMON_HEADER \
3230 "Link ID ADV Router Age Seq# CkSum"
3231
hassoeb1ce602004-10-08 08:17:22 +00003232const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003233{
3234 "",
3235 "Link ID ADV Router Age Seq# CkSum Link count",
3236 "Link ID ADV Router Age Seq# CkSum",
3237 "Link ID ADV Router Age Seq# CkSum Route",
3238 "Link ID ADV Router Age Seq# CkSum",
3239 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003240 " --- header for Group Member ----",
3241 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003242#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003243 " --- type-8 ---",
3244 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3245 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3246 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3247#endif /* HAVE_OPAQUE_LSA */
3248};
3249
hassoeb1ce602004-10-08 08:17:22 +00003250const char *show_lsa_flags[] =
paul4957f492003-06-27 01:28:45 +00003251{
3252 "Self-originated",
3253 "Checked",
3254 "Received",
3255 "Approved",
3256 "Discard",
paul4957f492003-06-27 01:28:45 +00003257 "Translated",
paul4957f492003-06-27 01:28:45 +00003258};
3259
paul718e3742002-12-13 20:15:29 +00003260void
3261show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3262{
3263 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003264
paul718e3742002-12-13 20:15:29 +00003265 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003266 vty_out (vty, " Options: 0x%-2x : %s%s",
3267 lsa->data->options,
3268 ospf_options_dump(lsa->data->options),
3269 VTY_NEWLINE);
3270 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003271 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003272 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3273 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003274
3275 if (lsa->data->type == OSPF_ROUTER_LSA)
3276 {
3277 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3278
3279 if (rlsa->flags)
3280 vty_out (vty, " :%s%s%s%s",
3281 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3282 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3283 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3284 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3285
3286 vty_out (vty, "%s", VTY_NEWLINE);
3287 }
3288 vty_out (vty, " LS Type: %s%s",
3289 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3290 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3291 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3292 vty_out (vty, " Advertising Router: %s%s",
3293 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3294 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3295 VTY_NEWLINE);
3296 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3297 VTY_NEWLINE);
3298 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3299}
3300
hassoeb1ce602004-10-08 08:17:22 +00003301const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003302{
3303 "(null)",
3304 "another Router (point-to-point)",
3305 "a Transit Network",
3306 "Stub Network",
3307 "a Virtual Link",
3308};
3309
hassoeb1ce602004-10-08 08:17:22 +00003310const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003311{
3312 "(null)",
3313 "Neighboring Router ID",
3314 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003315 "Net",
paul718e3742002-12-13 20:15:29 +00003316 "Neighboring Router ID",
3317};
3318
hassoeb1ce602004-10-08 08:17:22 +00003319const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003320{
3321 "(null)",
3322 "Router Interface address",
3323 "Router Interface address",
3324 "Network Mask",
3325 "Router Interface address",
3326};
3327
3328/* Show router-LSA each Link information. */
3329void
3330show_ip_ospf_database_router_links (struct vty *vty,
3331 struct router_lsa *rl)
3332{
3333 int len, i, type;
3334
3335 len = ntohs (rl->header.length) - 4;
3336 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3337 {
3338 type = rl->link[i].type;
3339
3340 vty_out (vty, " Link connected to: %s%s",
3341 link_type_desc[type], VTY_NEWLINE);
3342 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3343 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3344 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3345 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3346 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3347 vty_out (vty, " TOS 0 Metric: %d%s",
3348 ntohs (rl->link[i].metric), VTY_NEWLINE);
3349 vty_out (vty, "%s", VTY_NEWLINE);
3350 }
3351}
3352
3353/* Show router-LSA detail information. */
3354int
3355show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3356{
3357 if (lsa != NULL)
3358 {
3359 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3360
3361 show_ip_ospf_database_header (vty, lsa);
3362
3363 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3364 VTY_NEWLINE, VTY_NEWLINE);
3365
3366 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003367 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003368 }
3369
3370 return 0;
3371}
3372
3373/* Show network-LSA detail information. */
3374int
3375show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3376{
3377 int length, i;
3378
3379 if (lsa != NULL)
3380 {
3381 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3382
3383 show_ip_ospf_database_header (vty, lsa);
3384
3385 vty_out (vty, " Network Mask: /%d%s",
3386 ip_masklen (nl->mask), VTY_NEWLINE);
3387
3388 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3389
3390 for (i = 0; length > 0; i++, length -= 4)
3391 vty_out (vty, " Attached Router: %s%s",
3392 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3393
3394 vty_out (vty, "%s", VTY_NEWLINE);
3395 }
3396
3397 return 0;
3398}
3399
3400/* Show summary-LSA detail information. */
3401int
3402show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3403{
3404 if (lsa != NULL)
3405 {
3406 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3407
3408 show_ip_ospf_database_header (vty, lsa);
3409
3410 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3411 VTY_NEWLINE);
3412 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3413 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003414 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003415 }
3416
3417 return 0;
3418}
3419
3420/* Show summary-ASBR-LSA detail information. */
3421int
3422show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3423{
3424 if (lsa != NULL)
3425 {
3426 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3427
3428 show_ip_ospf_database_header (vty, lsa);
3429
3430 vty_out (vty, " Network Mask: /%d%s",
3431 ip_masklen (sl->mask), VTY_NEWLINE);
3432 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3433 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003434 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003435 }
3436
3437 return 0;
3438}
3439
3440/* Show AS-external-LSA detail information. */
3441int
3442show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3443{
3444 if (lsa != NULL)
3445 {
3446 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3447
3448 show_ip_ospf_database_header (vty, lsa);
3449
3450 vty_out (vty, " Network Mask: /%d%s",
3451 ip_masklen (al->mask), VTY_NEWLINE);
3452 vty_out (vty, " Metric Type: %s%s",
3453 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3454 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3455 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3456 vty_out (vty, " Metric: %d%s",
3457 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3458 vty_out (vty, " Forward Address: %s%s",
3459 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3460
3461 vty_out (vty, " External Route Tag: %lu%s%s",
3462 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3463 }
3464
3465 return 0;
3466}
3467
ajs2a42e282004-12-08 18:43:03 +00003468/* N.B. This function currently seems to be unused. */
paul718e3742002-12-13 20:15:29 +00003469int
3470show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3471{
3472 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3473
3474 /* show_ip_ospf_database_header (vty, lsa); */
3475
ajs2a42e282004-12-08 18:43:03 +00003476 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003477 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003478 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003479 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3480 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003481 zlog_debug( " TOS: 0%s", "\n");
3482 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003483 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003484 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003485 inet_ntoa (al->e[0].fwd_addr), "\n");
3486
ajs2a42e282004-12-08 18:43:03 +00003487 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003488 ntohl (al->e[0].route_tag), "\n", "\n");
3489
3490 return 0;
3491}
3492
3493/* Show AS-NSSA-LSA detail information. */
3494int
3495show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3496{
3497 if (lsa != NULL)
3498 {
3499 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3500
3501 show_ip_ospf_database_header (vty, lsa);
3502
3503 vty_out (vty, " Network Mask: /%d%s",
3504 ip_masklen (al->mask), VTY_NEWLINE);
3505 vty_out (vty, " Metric Type: %s%s",
3506 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3507 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3508 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3509 vty_out (vty, " Metric: %d%s",
3510 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3511 vty_out (vty, " NSSA: Forward Address: %s%s",
3512 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3513
3514 vty_out (vty, " External Route Tag: %u%s%s",
3515 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3516 }
3517
3518 return 0;
3519}
3520
paul718e3742002-12-13 20:15:29 +00003521int
3522show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3523{
3524 return 0;
3525}
3526
3527#ifdef HAVE_OPAQUE_LSA
3528int
3529show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3530{
3531 if (lsa != NULL)
3532 {
3533 show_ip_ospf_database_header (vty, lsa);
3534 show_opaque_info_detail (vty, lsa);
3535
3536 vty_out (vty, "%s", VTY_NEWLINE);
3537 }
3538 return 0;
3539}
3540#endif /* HAVE_OPAQUE_LSA */
3541
3542int (*show_function[])(struct vty *, struct ospf_lsa *) =
3543{
3544 NULL,
3545 show_router_lsa_detail,
3546 show_network_lsa_detail,
3547 show_summary_lsa_detail,
3548 show_summary_asbr_lsa_detail,
3549 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003550 show_func_dummy,
3551 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003552#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003553 NULL, /* type-8 */
3554 show_opaque_lsa_detail,
3555 show_opaque_lsa_detail,
3556 show_opaque_lsa_detail,
3557#endif /* HAVE_OPAQUE_LSA */
3558};
3559
3560void
3561show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3562 struct in_addr *adv_router)
3563{
3564 memset (lp, 0, sizeof (struct prefix_ls));
3565 lp->family = 0;
3566 if (id == NULL)
3567 lp->prefixlen = 0;
3568 else if (adv_router == NULL)
3569 {
3570 lp->prefixlen = 32;
3571 lp->id = *id;
3572 }
3573 else
3574 {
3575 lp->prefixlen = 64;
3576 lp->id = *id;
3577 lp->adv_router = *adv_router;
3578 }
3579}
3580
3581void
3582show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3583 struct in_addr *id, struct in_addr *adv_router)
3584{
3585 struct prefix_ls lp;
3586 struct route_node *rn, *start;
3587 struct ospf_lsa *lsa;
3588
3589 show_lsa_prefix_set (vty, &lp, id, adv_router);
3590 start = route_node_get (rt, (struct prefix *) &lp);
3591 if (start)
3592 {
3593 route_lock_node (start);
3594 for (rn = start; rn; rn = route_next_until (rn, start))
3595 if ((lsa = rn->info))
3596 {
paul718e3742002-12-13 20:15:29 +00003597 if (show_function[lsa->data->type] != NULL)
3598 show_function[lsa->data->type] (vty, lsa);
3599 }
3600 route_unlock_node (start);
3601 }
3602}
3603
3604/* Show detail LSA information
3605 -- if id is NULL then show all LSAs. */
3606void
paul020709f2003-04-04 02:44:16 +00003607show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003608 struct in_addr *id, struct in_addr *adv_router)
3609{
hasso52dc7ee2004-09-23 19:18:23 +00003610 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003611
3612 switch (type)
3613 {
3614 case OSPF_AS_EXTERNAL_LSA:
3615#ifdef HAVE_OPAQUE_LSA
3616 case OSPF_OPAQUE_AS_LSA:
3617#endif /* HAVE_OPAQUE_LSA */
3618 vty_out (vty, " %s %s%s",
3619 show_database_desc[type],
3620 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003621 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00003622 break;
3623 default:
paul68980082003-03-25 05:07:42 +00003624 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003625 {
3626 struct ospf_area *area = node->data;
3627 vty_out (vty, "%s %s (Area %s)%s%s",
3628 VTY_NEWLINE, show_database_desc[type],
3629 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3630 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3631 }
3632 break;
3633 }
3634}
3635
3636void
3637show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3638 struct in_addr *adv_router)
3639{
3640 struct route_node *rn;
3641 struct ospf_lsa *lsa;
3642
3643 for (rn = route_top (rt); rn; rn = route_next (rn))
3644 if ((lsa = rn->info))
3645 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3646 {
paul718e3742002-12-13 20:15:29 +00003647 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3648 continue;
paul718e3742002-12-13 20:15:29 +00003649 if (show_function[lsa->data->type] != NULL)
3650 show_function[lsa->data->type] (vty, lsa);
3651 }
3652}
3653
3654/* Show detail LSA information. */
3655void
paul020709f2003-04-04 02:44:16 +00003656show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00003657 struct in_addr *adv_router)
3658{
hasso52dc7ee2004-09-23 19:18:23 +00003659 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003660
3661 switch (type)
3662 {
3663 case OSPF_AS_EXTERNAL_LSA:
3664#ifdef HAVE_OPAQUE_LSA
3665 case OSPF_OPAQUE_AS_LSA:
3666#endif /* HAVE_OPAQUE_LSA */
3667 vty_out (vty, " %s %s%s",
3668 show_database_desc[type],
3669 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00003670 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00003671 adv_router);
3672 break;
3673 default:
paul68980082003-03-25 05:07:42 +00003674 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003675 {
3676 struct ospf_area *area = node->data;
3677 vty_out (vty, "%s %s (Area %s)%s%s",
3678 VTY_NEWLINE, show_database_desc[type],
3679 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3680 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3681 adv_router);
3682 }
3683 break;
3684 }
3685}
3686
3687void
paul020709f2003-04-04 02:44:16 +00003688show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00003689{
paul020709f2003-04-04 02:44:16 +00003690 struct ospf_lsa *lsa;
3691 struct route_node *rn;
hasso52dc7ee2004-09-23 19:18:23 +00003692 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003693 int type;
3694
paul68980082003-03-25 05:07:42 +00003695 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003696 {
3697 struct ospf_area *area = node->data;
3698 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3699 {
3700 switch (type)
3701 {
3702 case OSPF_AS_EXTERNAL_LSA:
3703#ifdef HAVE_OPAQUE_LSA
3704 case OSPF_OPAQUE_AS_LSA:
3705#endif /* HAVE_OPAQUE_LSA */
3706 continue;
3707 default:
3708 break;
3709 }
3710 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3711 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3712 {
3713 vty_out (vty, " %s (Area %s)%s%s",
3714 show_database_desc[type],
3715 ospf_area_desc_string (area),
3716 VTY_NEWLINE, VTY_NEWLINE);
3717 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3718
paul020709f2003-04-04 02:44:16 +00003719 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3720 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00003721
3722 vty_out (vty, "%s", VTY_NEWLINE);
3723 }
3724 }
3725 }
3726
3727 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3728 {
3729 switch (type)
3730 {
3731 case OSPF_AS_EXTERNAL_LSA:
3732#ifdef HAVE_OPAQUE_LSA
3733 case OSPF_OPAQUE_AS_LSA:
3734#endif /* HAVE_OPAQUE_LSA */
3735 break;;
3736 default:
3737 continue;
3738 }
paul68980082003-03-25 05:07:42 +00003739 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
3740 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00003741 {
3742 vty_out (vty, " %s%s%s",
3743 show_database_desc[type],
3744 VTY_NEWLINE, VTY_NEWLINE);
3745 vty_out (vty, "%s%s", show_database_header[type],
3746 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00003747
3748 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
3749 show_lsa_summary (vty, lsa, self);
3750
paul718e3742002-12-13 20:15:29 +00003751 vty_out (vty, "%s", VTY_NEWLINE);
3752 }
3753 }
3754
3755 vty_out (vty, "%s", VTY_NEWLINE);
3756}
3757
3758void
paul020709f2003-04-04 02:44:16 +00003759show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00003760{
hasso52dc7ee2004-09-23 19:18:23 +00003761 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003762 struct ospf_lsa *lsa;
3763
3764 vty_out (vty, "%s MaxAge Link States:%s%s",
3765 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
3766
paul68980082003-03-25 05:07:42 +00003767 for (node = listhead (ospf->maxage_lsa); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00003768 if ((lsa = node->data) != NULL)
3769 {
3770 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
3771 vty_out (vty, "Link State ID: %s%s",
3772 inet_ntoa (lsa->data->id), VTY_NEWLINE);
3773 vty_out (vty, "Advertising Router: %s%s",
3774 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3775 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
3776 vty_out (vty, "%s", VTY_NEWLINE);
3777 }
3778}
3779
paul718e3742002-12-13 20:15:29 +00003780#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
3781#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00003782
3783#ifdef HAVE_OPAQUE_LSA
3784#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
3785#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
3786#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
3787#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
3788#else /* HAVE_OPAQUE_LSA */
3789#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
3790#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
3791#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
3792#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
3793#endif /* HAVE_OPAQUE_LSA */
3794
3795#define OSPF_LSA_TYPES_CMD_STR \
3796 "asbr-summary|external|network|router|summary" \
3797 OSPF_LSA_TYPE_NSSA_CMD_STR \
3798 OSPF_LSA_TYPE_OPAQUE_CMD_STR
3799
3800#define OSPF_LSA_TYPES_DESC \
3801 "ASBR summary link states\n" \
3802 "External link states\n" \
3803 "Network link states\n" \
3804 "Router link states\n" \
3805 "Network summary link states\n" \
3806 OSPF_LSA_TYPE_NSSA_DESC \
3807 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
3808 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
3809 OSPF_LSA_TYPE_OPAQUE_AS_DESC
3810
3811DEFUN (show_ip_ospf_database,
3812 show_ip_ospf_database_cmd,
3813 "show ip ospf database",
3814 SHOW_STR
3815 IP_STR
3816 "OSPF information\n"
3817 "Database summary\n")
3818{
paul020709f2003-04-04 02:44:16 +00003819 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003820 int type, ret;
3821 struct in_addr id, adv_router;
3822
paul020709f2003-04-04 02:44:16 +00003823 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003824 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003825 return CMD_SUCCESS;
3826
3827 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003828 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003829
3830 /* Show all LSA. */
3831 if (argc == 0)
3832 {
paul020709f2003-04-04 02:44:16 +00003833 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00003834 return CMD_SUCCESS;
3835 }
3836
3837 /* Set database type to show. */
3838 if (strncmp (argv[0], "r", 1) == 0)
3839 type = OSPF_ROUTER_LSA;
3840 else if (strncmp (argv[0], "ne", 2) == 0)
3841 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003842 else if (strncmp (argv[0], "ns", 2) == 0)
3843 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003844 else if (strncmp (argv[0], "su", 2) == 0)
3845 type = OSPF_SUMMARY_LSA;
3846 else if (strncmp (argv[0], "a", 1) == 0)
3847 type = OSPF_ASBR_SUMMARY_LSA;
3848 else if (strncmp (argv[0], "e", 1) == 0)
3849 type = OSPF_AS_EXTERNAL_LSA;
3850 else if (strncmp (argv[0], "se", 2) == 0)
3851 {
paul020709f2003-04-04 02:44:16 +00003852 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00003853 return CMD_SUCCESS;
3854 }
3855 else if (strncmp (argv[0], "m", 1) == 0)
3856 {
paul020709f2003-04-04 02:44:16 +00003857 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00003858 return CMD_SUCCESS;
3859 }
3860#ifdef HAVE_OPAQUE_LSA
3861 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3862 type = OSPF_OPAQUE_LINK_LSA;
3863 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3864 type = OSPF_OPAQUE_AREA_LSA;
3865 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3866 type = OSPF_OPAQUE_AS_LSA;
3867#endif /* HAVE_OPAQUE_LSA */
3868 else
3869 return CMD_WARNING;
3870
3871 /* `show ip ospf database LSA'. */
3872 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00003873 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00003874 else if (argc >= 2)
3875 {
3876 ret = inet_aton (argv[1], &id);
3877 if (!ret)
3878 return CMD_WARNING;
3879
3880 /* `show ip ospf database LSA ID'. */
3881 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00003882 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00003883 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
3884 else if (argc == 3)
3885 {
3886 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003887 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003888 else
3889 {
3890 ret = inet_aton (argv[2], &adv_router);
3891 if (!ret)
3892 return CMD_WARNING;
3893 }
paul020709f2003-04-04 02:44:16 +00003894 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00003895 }
3896 }
3897
3898 return CMD_SUCCESS;
3899}
3900
3901ALIAS (show_ip_ospf_database,
3902 show_ip_ospf_database_type_cmd,
3903 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
3904 SHOW_STR
3905 IP_STR
3906 "OSPF information\n"
3907 "Database summary\n"
3908 OSPF_LSA_TYPES_DESC
3909 "LSAs in MaxAge list\n"
3910 "Self-originated link states\n")
3911
3912ALIAS (show_ip_ospf_database,
3913 show_ip_ospf_database_type_id_cmd,
3914 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
3915 SHOW_STR
3916 IP_STR
3917 "OSPF information\n"
3918 "Database summary\n"
3919 OSPF_LSA_TYPES_DESC
3920 "Link State ID (as an IP address)\n")
3921
3922ALIAS (show_ip_ospf_database,
3923 show_ip_ospf_database_type_id_adv_router_cmd,
3924 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
3925 SHOW_STR
3926 IP_STR
3927 "OSPF information\n"
3928 "Database summary\n"
3929 OSPF_LSA_TYPES_DESC
3930 "Link State ID (as an IP address)\n"
3931 "Advertising Router link states\n"
3932 "Advertising Router (as an IP address)\n")
3933
3934ALIAS (show_ip_ospf_database,
3935 show_ip_ospf_database_type_id_self_cmd,
3936 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
3937 SHOW_STR
3938 IP_STR
3939 "OSPF information\n"
3940 "Database summary\n"
3941 OSPF_LSA_TYPES_DESC
3942 "Link State ID (as an IP address)\n"
3943 "Self-originated link states\n"
3944 "\n")
3945
3946DEFUN (show_ip_ospf_database_type_adv_router,
3947 show_ip_ospf_database_type_adv_router_cmd,
3948 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
3949 SHOW_STR
3950 IP_STR
3951 "OSPF information\n"
3952 "Database summary\n"
3953 OSPF_LSA_TYPES_DESC
3954 "Advertising Router link states\n"
3955 "Advertising Router (as an IP address)\n")
3956{
paul020709f2003-04-04 02:44:16 +00003957 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003958 int type, ret;
3959 struct in_addr adv_router;
3960
paul020709f2003-04-04 02:44:16 +00003961 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003962 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003963 return CMD_SUCCESS;
3964
3965 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00003966 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003967
3968 if (argc != 2)
3969 return CMD_WARNING;
3970
3971 /* Set database type to show. */
3972 if (strncmp (argv[0], "r", 1) == 0)
3973 type = OSPF_ROUTER_LSA;
3974 else if (strncmp (argv[0], "ne", 2) == 0)
3975 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00003976 else if (strncmp (argv[0], "ns", 2) == 0)
3977 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00003978 else if (strncmp (argv[0], "s", 1) == 0)
3979 type = OSPF_SUMMARY_LSA;
3980 else if (strncmp (argv[0], "a", 1) == 0)
3981 type = OSPF_ASBR_SUMMARY_LSA;
3982 else if (strncmp (argv[0], "e", 1) == 0)
3983 type = OSPF_AS_EXTERNAL_LSA;
3984#ifdef HAVE_OPAQUE_LSA
3985 else if (strncmp (argv[0], "opaque-l", 8) == 0)
3986 type = OSPF_OPAQUE_LINK_LSA;
3987 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
3988 type = OSPF_OPAQUE_AREA_LSA;
3989 else if (strncmp (argv[0], "opaque-as", 9) == 0)
3990 type = OSPF_OPAQUE_AS_LSA;
3991#endif /* HAVE_OPAQUE_LSA */
3992 else
3993 return CMD_WARNING;
3994
3995 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
3996 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00003997 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00003998 else
3999 {
4000 ret = inet_aton (argv[1], &adv_router);
4001 if (!ret)
4002 return CMD_WARNING;
4003 }
4004
paul020709f2003-04-04 02:44:16 +00004005 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004006
4007 return CMD_SUCCESS;
4008}
4009
4010ALIAS (show_ip_ospf_database_type_adv_router,
4011 show_ip_ospf_database_type_self_cmd,
4012 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4013 SHOW_STR
4014 IP_STR
4015 "OSPF information\n"
4016 "Database summary\n"
4017 OSPF_LSA_TYPES_DESC
4018 "Self-originated link states\n")
4019
4020
4021DEFUN (ip_ospf_authentication_args,
4022 ip_ospf_authentication_args_addr_cmd,
4023 "ip ospf authentication (null|message-digest) A.B.C.D",
4024 "IP Information\n"
4025 "OSPF interface commands\n"
4026 "Enable authentication on this interface\n"
4027 "Use null authentication\n"
4028 "Use message-digest authentication\n"
4029 "Address of interface")
4030{
4031 struct interface *ifp;
4032 struct in_addr addr;
4033 int ret;
4034 struct ospf_if_params *params;
4035
4036 ifp = vty->index;
4037 params = IF_DEF_PARAMS (ifp);
4038
4039 if (argc == 2)
4040 {
4041 ret = inet_aton(argv[1], &addr);
4042 if (!ret)
4043 {
4044 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4045 VTY_NEWLINE);
4046 return CMD_WARNING;
4047 }
4048
4049 params = ospf_get_if_params (ifp, addr);
4050 ospf_if_update_params (ifp, addr);
4051 }
4052
4053 /* Handle null authentication */
4054 if ( argv[0][0] == 'n' )
4055 {
4056 SET_IF_PARAM (params, auth_type);
4057 params->auth_type = OSPF_AUTH_NULL;
4058 return CMD_SUCCESS;
4059 }
4060
4061 /* Handle message-digest authentication */
4062 if ( argv[0][0] == 'm' )
4063 {
4064 SET_IF_PARAM (params, auth_type);
4065 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4066 return CMD_SUCCESS;
4067 }
4068
4069 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4070 return CMD_WARNING;
4071}
4072
4073ALIAS (ip_ospf_authentication_args,
4074 ip_ospf_authentication_args_cmd,
4075 "ip ospf authentication (null|message-digest)",
4076 "IP Information\n"
4077 "OSPF interface commands\n"
4078 "Enable authentication on this interface\n"
4079 "Use null authentication\n"
4080 "Use message-digest authentication\n")
4081
4082DEFUN (ip_ospf_authentication,
4083 ip_ospf_authentication_addr_cmd,
4084 "ip ospf authentication A.B.C.D",
4085 "IP Information\n"
4086 "OSPF interface commands\n"
4087 "Enable authentication on this interface\n"
4088 "Address of interface")
4089{
4090 struct interface *ifp;
4091 struct in_addr addr;
4092 int ret;
4093 struct ospf_if_params *params;
4094
4095 ifp = vty->index;
4096 params = IF_DEF_PARAMS (ifp);
4097
4098 if (argc == 1)
4099 {
4100 ret = inet_aton(argv[1], &addr);
4101 if (!ret)
4102 {
4103 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4104 VTY_NEWLINE);
4105 return CMD_WARNING;
4106 }
4107
4108 params = ospf_get_if_params (ifp, addr);
4109 ospf_if_update_params (ifp, addr);
4110 }
4111
4112 SET_IF_PARAM (params, auth_type);
4113 params->auth_type = OSPF_AUTH_SIMPLE;
4114
4115 return CMD_SUCCESS;
4116}
4117
4118ALIAS (ip_ospf_authentication,
4119 ip_ospf_authentication_cmd,
4120 "ip ospf authentication",
4121 "IP Information\n"
4122 "OSPF interface commands\n"
4123 "Enable authentication on this interface\n")
4124
4125DEFUN (no_ip_ospf_authentication,
4126 no_ip_ospf_authentication_addr_cmd,
4127 "no ip ospf authentication A.B.C.D",
4128 NO_STR
4129 "IP Information\n"
4130 "OSPF interface commands\n"
4131 "Enable authentication on this interface\n"
4132 "Address of interface")
4133{
4134 struct interface *ifp;
4135 struct in_addr addr;
4136 int ret;
4137 struct ospf_if_params *params;
4138
4139 ifp = vty->index;
4140 params = IF_DEF_PARAMS (ifp);
4141
4142 if (argc == 1)
4143 {
4144 ret = inet_aton(argv[1], &addr);
4145 if (!ret)
4146 {
4147 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4148 VTY_NEWLINE);
4149 return CMD_WARNING;
4150 }
4151
4152 params = ospf_lookup_if_params (ifp, addr);
4153 if (params == NULL)
4154 return CMD_SUCCESS;
4155 }
4156
4157 params->auth_type = OSPF_AUTH_NOTSET;
4158 UNSET_IF_PARAM (params, auth_type);
4159
4160 if (params != IF_DEF_PARAMS (ifp))
4161 {
4162 ospf_free_if_params (ifp, addr);
4163 ospf_if_update_params (ifp, addr);
4164 }
4165
4166 return CMD_SUCCESS;
4167}
4168
4169ALIAS (no_ip_ospf_authentication,
4170 no_ip_ospf_authentication_cmd,
4171 "no ip ospf authentication",
4172 NO_STR
4173 "IP Information\n"
4174 "OSPF interface commands\n"
4175 "Enable authentication on this interface\n")
4176
4177DEFUN (ip_ospf_authentication_key,
4178 ip_ospf_authentication_key_addr_cmd,
4179 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4180 "IP Information\n"
4181 "OSPF interface commands\n"
4182 "Authentication password (key)\n"
4183 "The OSPF password (key)\n"
4184 "Address of interface")
4185{
4186 struct interface *ifp;
4187 struct in_addr addr;
4188 int ret;
4189 struct ospf_if_params *params;
4190
4191 ifp = vty->index;
4192 params = IF_DEF_PARAMS (ifp);
4193
4194 if (argc == 2)
4195 {
4196 ret = inet_aton(argv[1], &addr);
4197 if (!ret)
4198 {
4199 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4200 VTY_NEWLINE);
4201 return CMD_WARNING;
4202 }
4203
4204 params = ospf_get_if_params (ifp, addr);
4205 ospf_if_update_params (ifp, addr);
4206 }
4207
4208
4209 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004210 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004211 SET_IF_PARAM (params, auth_simple);
4212
4213 return CMD_SUCCESS;
4214}
4215
4216ALIAS (ip_ospf_authentication_key,
4217 ip_ospf_authentication_key_cmd,
4218 "ip ospf authentication-key AUTH_KEY",
4219 "IP Information\n"
4220 "OSPF interface commands\n"
4221 "Authentication password (key)\n"
4222 "The OSPF password (key)")
4223
4224ALIAS (ip_ospf_authentication_key,
4225 ospf_authentication_key_cmd,
4226 "ospf authentication-key AUTH_KEY",
4227 "OSPF interface commands\n"
4228 "Authentication password (key)\n"
4229 "The OSPF password (key)")
4230
4231DEFUN (no_ip_ospf_authentication_key,
4232 no_ip_ospf_authentication_key_addr_cmd,
4233 "no ip ospf authentication-key A.B.C.D",
4234 NO_STR
4235 "IP Information\n"
4236 "OSPF interface commands\n"
4237 "Authentication password (key)\n"
4238 "Address of interface")
4239{
4240 struct interface *ifp;
4241 struct in_addr addr;
4242 int ret;
4243 struct ospf_if_params *params;
4244
4245 ifp = vty->index;
4246 params = IF_DEF_PARAMS (ifp);
4247
4248 if (argc == 2)
4249 {
4250 ret = inet_aton(argv[1], &addr);
4251 if (!ret)
4252 {
4253 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4254 VTY_NEWLINE);
4255 return CMD_WARNING;
4256 }
4257
4258 params = ospf_lookup_if_params (ifp, addr);
4259 if (params == NULL)
4260 return CMD_SUCCESS;
4261 }
4262
4263 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4264 UNSET_IF_PARAM (params, auth_simple);
4265
4266 if (params != IF_DEF_PARAMS (ifp))
4267 {
4268 ospf_free_if_params (ifp, addr);
4269 ospf_if_update_params (ifp, addr);
4270 }
4271
4272 return CMD_SUCCESS;
4273}
4274
4275ALIAS (no_ip_ospf_authentication_key,
4276 no_ip_ospf_authentication_key_cmd,
4277 "no ip ospf authentication-key",
4278 NO_STR
4279 "IP Information\n"
4280 "OSPF interface commands\n"
4281 "Authentication password (key)\n")
4282
4283ALIAS (no_ip_ospf_authentication_key,
4284 no_ospf_authentication_key_cmd,
4285 "no ospf authentication-key",
4286 NO_STR
4287 "OSPF interface commands\n"
4288 "Authentication password (key)\n")
4289
4290DEFUN (ip_ospf_message_digest_key,
4291 ip_ospf_message_digest_key_addr_cmd,
4292 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4293 "IP Information\n"
4294 "OSPF interface commands\n"
4295 "Message digest authentication password (key)\n"
4296 "Key ID\n"
4297 "Use MD5 algorithm\n"
4298 "The OSPF password (key)"
4299 "Address of interface")
4300{
4301 struct interface *ifp;
4302 struct crypt_key *ck;
4303 u_char key_id;
4304 struct in_addr addr;
4305 int ret;
4306 struct ospf_if_params *params;
4307
4308 ifp = vty->index;
4309 params = IF_DEF_PARAMS (ifp);
4310
4311 if (argc == 3)
4312 {
4313 ret = inet_aton(argv[2], &addr);
4314 if (!ret)
4315 {
4316 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4317 VTY_NEWLINE);
4318 return CMD_WARNING;
4319 }
4320
4321 params = ospf_get_if_params (ifp, addr);
4322 ospf_if_update_params (ifp, addr);
4323 }
4324
4325 key_id = strtol (argv[0], NULL, 10);
4326 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4327 {
4328 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4329 return CMD_WARNING;
4330 }
4331
4332 ck = ospf_crypt_key_new ();
4333 ck->key_id = (u_char) key_id;
4334 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004335 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004336
4337 ospf_crypt_key_add (params->auth_crypt, ck);
4338 SET_IF_PARAM (params, auth_crypt);
4339
4340 return CMD_SUCCESS;
4341}
4342
4343ALIAS (ip_ospf_message_digest_key,
4344 ip_ospf_message_digest_key_cmd,
4345 "ip ospf message-digest-key <1-255> md5 KEY",
4346 "IP Information\n"
4347 "OSPF interface commands\n"
4348 "Message digest authentication password (key)\n"
4349 "Key ID\n"
4350 "Use MD5 algorithm\n"
4351 "The OSPF password (key)")
4352
4353ALIAS (ip_ospf_message_digest_key,
4354 ospf_message_digest_key_cmd,
4355 "ospf message-digest-key <1-255> md5 KEY",
4356 "OSPF interface commands\n"
4357 "Message digest authentication password (key)\n"
4358 "Key ID\n"
4359 "Use MD5 algorithm\n"
4360 "The OSPF password (key)")
4361
4362DEFUN (no_ip_ospf_message_digest_key,
4363 no_ip_ospf_message_digest_key_addr_cmd,
4364 "no ip ospf message-digest-key <1-255> A.B.C.D",
4365 NO_STR
4366 "IP Information\n"
4367 "OSPF interface commands\n"
4368 "Message digest authentication password (key)\n"
4369 "Key ID\n"
4370 "Address of interface")
4371{
4372 struct interface *ifp;
4373 struct crypt_key *ck;
4374 int key_id;
4375 struct in_addr addr;
4376 int ret;
4377 struct ospf_if_params *params;
4378
4379 ifp = vty->index;
4380 params = IF_DEF_PARAMS (ifp);
4381
4382 if (argc == 2)
4383 {
4384 ret = inet_aton(argv[1], &addr);
4385 if (!ret)
4386 {
4387 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4388 VTY_NEWLINE);
4389 return CMD_WARNING;
4390 }
4391
4392 params = ospf_lookup_if_params (ifp, addr);
4393 if (params == NULL)
4394 return CMD_SUCCESS;
4395 }
4396
4397 key_id = strtol (argv[0], NULL, 10);
4398 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4399 if (ck == NULL)
4400 {
4401 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4402 return CMD_WARNING;
4403 }
4404
4405 ospf_crypt_key_delete (params->auth_crypt, key_id);
4406
4407 if (params != IF_DEF_PARAMS (ifp))
4408 {
4409 ospf_free_if_params (ifp, addr);
4410 ospf_if_update_params (ifp, addr);
4411 }
4412
4413 return CMD_SUCCESS;
4414}
4415
4416ALIAS (no_ip_ospf_message_digest_key,
4417 no_ip_ospf_message_digest_key_cmd,
4418 "no ip ospf message-digest-key <1-255>",
4419 NO_STR
4420 "IP Information\n"
4421 "OSPF interface commands\n"
4422 "Message digest authentication password (key)\n"
4423 "Key ID\n")
4424
4425ALIAS (no_ip_ospf_message_digest_key,
4426 no_ospf_message_digest_key_cmd,
4427 "no ospf message-digest-key <1-255>",
4428 NO_STR
4429 "OSPF interface commands\n"
4430 "Message digest authentication password (key)\n"
4431 "Key ID\n")
4432
4433DEFUN (ip_ospf_cost,
4434 ip_ospf_cost_addr_cmd,
4435 "ip ospf cost <1-65535> A.B.C.D",
4436 "IP Information\n"
4437 "OSPF interface commands\n"
4438 "Interface cost\n"
4439 "Cost\n"
4440 "Address of interface")
4441{
4442 struct interface *ifp = vty->index;
4443 u_int32_t cost;
4444 struct in_addr addr;
4445 int ret;
4446 struct ospf_if_params *params;
4447
4448 params = IF_DEF_PARAMS (ifp);
4449
4450 cost = strtol (argv[0], NULL, 10);
4451
4452 /* cost range is <1-65535>. */
4453 if (cost < 1 || cost > 65535)
4454 {
4455 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4456 return CMD_WARNING;
4457 }
4458
4459 if (argc == 2)
4460 {
4461 ret = inet_aton(argv[1], &addr);
4462 if (!ret)
4463 {
4464 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4465 VTY_NEWLINE);
4466 return CMD_WARNING;
4467 }
4468
4469 params = ospf_get_if_params (ifp, addr);
4470 ospf_if_update_params (ifp, addr);
4471 }
4472
4473 SET_IF_PARAM (params, output_cost_cmd);
4474 params->output_cost_cmd = cost;
4475
4476 ospf_if_recalculate_output_cost (ifp);
4477
4478 return CMD_SUCCESS;
4479}
4480
4481ALIAS (ip_ospf_cost,
4482 ip_ospf_cost_cmd,
4483 "ip ospf cost <1-65535>",
4484 "IP Information\n"
4485 "OSPF interface commands\n"
4486 "Interface cost\n"
4487 "Cost")
4488
4489ALIAS (ip_ospf_cost,
4490 ospf_cost_cmd,
4491 "ospf cost <1-65535>",
4492 "OSPF interface commands\n"
4493 "Interface cost\n"
4494 "Cost")
4495
4496DEFUN (no_ip_ospf_cost,
4497 no_ip_ospf_cost_addr_cmd,
4498 "no ip ospf cost A.B.C.D",
4499 NO_STR
4500 "IP Information\n"
4501 "OSPF interface commands\n"
4502 "Interface cost\n"
4503 "Address of interface")
4504{
4505 struct interface *ifp = vty->index;
4506 struct in_addr addr;
4507 int ret;
4508 struct ospf_if_params *params;
4509
4510 ifp = vty->index;
4511 params = IF_DEF_PARAMS (ifp);
4512
4513 if (argc == 1)
4514 {
4515 ret = inet_aton(argv[0], &addr);
4516 if (!ret)
4517 {
4518 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4519 VTY_NEWLINE);
4520 return CMD_WARNING;
4521 }
4522
4523 params = ospf_lookup_if_params (ifp, addr);
4524 if (params == NULL)
4525 return CMD_SUCCESS;
4526 }
4527
4528 UNSET_IF_PARAM (params, output_cost_cmd);
4529
4530 if (params != IF_DEF_PARAMS (ifp))
4531 {
4532 ospf_free_if_params (ifp, addr);
4533 ospf_if_update_params (ifp, addr);
4534 }
4535
4536 ospf_if_recalculate_output_cost (ifp);
4537
4538 return CMD_SUCCESS;
4539}
4540
4541ALIAS (no_ip_ospf_cost,
4542 no_ip_ospf_cost_cmd,
4543 "no ip ospf cost",
4544 NO_STR
4545 "IP Information\n"
4546 "OSPF interface commands\n"
4547 "Interface cost\n")
4548
4549ALIAS (no_ip_ospf_cost,
4550 no_ospf_cost_cmd,
4551 "no ospf cost",
4552 NO_STR
4553 "OSPF interface commands\n"
4554 "Interface cost\n")
4555
4556void
4557ospf_nbr_timer_update (struct ospf_interface *oi)
4558{
4559 struct route_node *rn;
4560 struct ospf_neighbor *nbr;
4561
4562 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4563 if ((nbr = rn->info))
4564 {
4565 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4566 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4567 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4568 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4569 }
4570}
4571
4572DEFUN (ip_ospf_dead_interval,
4573 ip_ospf_dead_interval_addr_cmd,
4574 "ip ospf dead-interval <1-65535> A.B.C.D",
4575 "IP Information\n"
4576 "OSPF interface commands\n"
4577 "Interval after which a neighbor is declared dead\n"
4578 "Seconds\n"
4579 "Address of interface")
4580{
4581 struct interface *ifp = vty->index;
4582 u_int32_t seconds;
4583 struct in_addr addr;
4584 int ret;
4585 struct ospf_if_params *params;
4586 struct ospf_interface *oi;
4587 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004588 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004589
paul020709f2003-04-04 02:44:16 +00004590 ospf = ospf_lookup ();
4591
paul718e3742002-12-13 20:15:29 +00004592 params = IF_DEF_PARAMS (ifp);
4593
4594 seconds = strtol (argv[0], NULL, 10);
4595
4596 /* dead_interval range is <1-65535>. */
4597 if (seconds < 1 || seconds > 65535)
4598 {
4599 vty_out (vty, "Router Dead Interval is invalid%s", VTY_NEWLINE);
4600 return CMD_WARNING;
4601 }
4602
4603 if (argc == 2)
4604 {
4605 ret = inet_aton(argv[1], &addr);
4606 if (!ret)
4607 {
4608 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4609 VTY_NEWLINE);
4610 return CMD_WARNING;
4611 }
4612
4613 params = ospf_get_if_params (ifp, addr);
4614 ospf_if_update_params (ifp, addr);
4615 }
4616
4617 SET_IF_PARAM (params, v_wait);
4618 params->v_wait = seconds;
4619
4620 /* Update timer values in neighbor structure. */
4621 if (argc == 2)
4622 {
paul68980082003-03-25 05:07:42 +00004623 if (ospf)
4624 {
4625 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4626 if (oi)
4627 ospf_nbr_timer_update (oi);
4628 }
paul718e3742002-12-13 20:15:29 +00004629 }
4630 else
4631 {
4632 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4633 if ((oi = rn->info))
4634 ospf_nbr_timer_update (oi);
4635 }
4636
4637 return CMD_SUCCESS;
4638}
4639
4640ALIAS (ip_ospf_dead_interval,
4641 ip_ospf_dead_interval_cmd,
4642 "ip ospf dead-interval <1-65535>",
4643 "IP Information\n"
4644 "OSPF interface commands\n"
4645 "Interval after which a neighbor is declared dead\n"
4646 "Seconds\n")
4647
4648ALIAS (ip_ospf_dead_interval,
4649 ospf_dead_interval_cmd,
4650 "ospf dead-interval <1-65535>",
4651 "OSPF interface commands\n"
4652 "Interval after which a neighbor is declared dead\n"
4653 "Seconds\n")
4654
4655DEFUN (no_ip_ospf_dead_interval,
4656 no_ip_ospf_dead_interval_addr_cmd,
4657 "no ip ospf dead-interval A.B.C.D",
4658 NO_STR
4659 "IP Information\n"
4660 "OSPF interface commands\n"
4661 "Interval after which a neighbor is declared dead\n"
4662 "Address of interface")
4663{
4664 struct interface *ifp = vty->index;
4665 struct in_addr addr;
4666 int ret;
4667 struct ospf_if_params *params;
4668 struct ospf_interface *oi;
4669 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00004670 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004671
paul020709f2003-04-04 02:44:16 +00004672 ospf = ospf_lookup ();
4673
paul718e3742002-12-13 20:15:29 +00004674 ifp = vty->index;
4675 params = IF_DEF_PARAMS (ifp);
4676
4677 if (argc == 1)
4678 {
4679 ret = inet_aton(argv[0], &addr);
4680 if (!ret)
4681 {
4682 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4683 VTY_NEWLINE);
4684 return CMD_WARNING;
4685 }
4686
4687 params = ospf_lookup_if_params (ifp, addr);
4688 if (params == NULL)
4689 return CMD_SUCCESS;
4690 }
4691
4692 UNSET_IF_PARAM (params, v_wait);
4693 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4694
4695 if (params != IF_DEF_PARAMS (ifp))
4696 {
4697 ospf_free_if_params (ifp, addr);
4698 ospf_if_update_params (ifp, addr);
4699 }
4700
4701 /* Update timer values in neighbor structure. */
4702 if (argc == 1)
4703 {
paul68980082003-03-25 05:07:42 +00004704 if (ospf)
4705 {
4706 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
4707 if (oi)
4708 ospf_nbr_timer_update (oi);
4709 }
paul718e3742002-12-13 20:15:29 +00004710 }
4711 else
4712 {
4713 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4714 if ((oi = rn->info))
4715 ospf_nbr_timer_update (oi);
4716 }
4717
4718 return CMD_SUCCESS;
4719}
4720
4721ALIAS (no_ip_ospf_dead_interval,
4722 no_ip_ospf_dead_interval_cmd,
4723 "no ip ospf dead-interval",
4724 NO_STR
4725 "IP Information\n"
4726 "OSPF interface commands\n"
4727 "Interval after which a neighbor is declared dead\n")
4728
4729ALIAS (no_ip_ospf_dead_interval,
4730 no_ospf_dead_interval_cmd,
4731 "no ospf dead-interval",
4732 NO_STR
4733 "OSPF interface commands\n"
4734 "Interval after which a neighbor is declared dead\n")
4735
4736DEFUN (ip_ospf_hello_interval,
4737 ip_ospf_hello_interval_addr_cmd,
4738 "ip ospf hello-interval <1-65535> A.B.C.D",
4739 "IP Information\n"
4740 "OSPF interface commands\n"
4741 "Time between HELLO packets\n"
4742 "Seconds\n"
4743 "Address of interface")
4744{
4745 struct interface *ifp = vty->index;
4746 u_int32_t seconds;
4747 struct in_addr addr;
4748 int ret;
4749 struct ospf_if_params *params;
4750
4751 params = IF_DEF_PARAMS (ifp);
4752
4753 seconds = strtol (argv[0], NULL, 10);
4754
4755 /* HelloInterval range is <1-65535>. */
4756 if (seconds < 1 || seconds > 65535)
4757 {
4758 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
4759 return CMD_WARNING;
4760 }
4761
4762 if (argc == 2)
4763 {
4764 ret = inet_aton(argv[1], &addr);
4765 if (!ret)
4766 {
4767 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4768 VTY_NEWLINE);
4769 return CMD_WARNING;
4770 }
4771
4772 params = ospf_get_if_params (ifp, addr);
4773 ospf_if_update_params (ifp, addr);
4774 }
4775
4776 SET_IF_PARAM (params, v_hello);
4777 params->v_hello = seconds;
4778
4779 return CMD_SUCCESS;
4780}
4781
4782ALIAS (ip_ospf_hello_interval,
4783 ip_ospf_hello_interval_cmd,
4784 "ip ospf hello-interval <1-65535>",
4785 "IP Information\n"
4786 "OSPF interface commands\n"
4787 "Time between HELLO packets\n"
4788 "Seconds\n")
4789
4790ALIAS (ip_ospf_hello_interval,
4791 ospf_hello_interval_cmd,
4792 "ospf hello-interval <1-65535>",
4793 "OSPF interface commands\n"
4794 "Time between HELLO packets\n"
4795 "Seconds\n")
4796
4797DEFUN (no_ip_ospf_hello_interval,
4798 no_ip_ospf_hello_interval_addr_cmd,
4799 "no ip ospf hello-interval A.B.C.D",
4800 NO_STR
4801 "IP Information\n"
4802 "OSPF interface commands\n"
4803 "Time between HELLO packets\n"
4804 "Address of interface")
4805{
4806 struct interface *ifp = vty->index;
4807 struct in_addr addr;
4808 int ret;
4809 struct ospf_if_params *params;
4810
4811 ifp = vty->index;
4812 params = IF_DEF_PARAMS (ifp);
4813
4814 if (argc == 1)
4815 {
4816 ret = inet_aton(argv[0], &addr);
4817 if (!ret)
4818 {
4819 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4820 VTY_NEWLINE);
4821 return CMD_WARNING;
4822 }
4823
4824 params = ospf_lookup_if_params (ifp, addr);
4825 if (params == NULL)
4826 return CMD_SUCCESS;
4827 }
4828
4829 UNSET_IF_PARAM (params, v_hello);
4830 params->v_hello = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
4831
4832 if (params != IF_DEF_PARAMS (ifp))
4833 {
4834 ospf_free_if_params (ifp, addr);
4835 ospf_if_update_params (ifp, addr);
4836 }
4837
4838 return CMD_SUCCESS;
4839}
4840
4841ALIAS (no_ip_ospf_hello_interval,
4842 no_ip_ospf_hello_interval_cmd,
4843 "no ip ospf hello-interval",
4844 NO_STR
4845 "IP Information\n"
4846 "OSPF interface commands\n"
4847 "Time between HELLO packets\n")
4848
4849ALIAS (no_ip_ospf_hello_interval,
4850 no_ospf_hello_interval_cmd,
4851 "no ospf hello-interval",
4852 NO_STR
4853 "OSPF interface commands\n"
4854 "Time between HELLO packets\n")
4855
4856DEFUN (ip_ospf_network,
4857 ip_ospf_network_cmd,
4858 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4859 "IP Information\n"
4860 "OSPF interface commands\n"
4861 "Network type\n"
4862 "Specify OSPF broadcast multi-access network\n"
4863 "Specify OSPF NBMA network\n"
4864 "Specify OSPF point-to-multipoint network\n"
4865 "Specify OSPF point-to-point network\n")
4866{
4867 struct interface *ifp = vty->index;
4868 int old_type = IF_DEF_PARAMS (ifp)->type;
4869 struct route_node *rn;
4870
4871 if (strncmp (argv[0], "b", 1) == 0)
4872 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
4873 else if (strncmp (argv[0], "n", 1) == 0)
4874 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
4875 else if (strncmp (argv[0], "point-to-m", 10) == 0)
4876 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
4877 else if (strncmp (argv[0], "point-to-p", 10) == 0)
4878 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
4879
4880 if (IF_DEF_PARAMS (ifp)->type == old_type)
4881 return CMD_SUCCESS;
4882
4883 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
4884
4885 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4886 {
4887 struct ospf_interface *oi = rn->info;
4888
4889 if (!oi)
4890 continue;
4891
4892 oi->type = IF_DEF_PARAMS (ifp)->type;
4893
4894 if (oi->state > ISM_Down)
4895 {
4896 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4897 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4898 }
4899 }
4900
4901 return CMD_SUCCESS;
4902}
4903
4904ALIAS (ip_ospf_network,
4905 ospf_network_cmd,
4906 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
4907 "OSPF interface commands\n"
4908 "Network type\n"
4909 "Specify OSPF broadcast multi-access network\n"
4910 "Specify OSPF NBMA network\n"
4911 "Specify OSPF point-to-multipoint network\n"
4912 "Specify OSPF point-to-point network\n")
4913
4914DEFUN (no_ip_ospf_network,
4915 no_ip_ospf_network_cmd,
4916 "no ip ospf network",
4917 NO_STR
4918 "IP Information\n"
4919 "OSPF interface commands\n"
4920 "Network type\n")
4921{
4922 struct interface *ifp = vty->index;
4923 int old_type = IF_DEF_PARAMS (ifp)->type;
4924 struct route_node *rn;
4925
ajsbc18d612004-12-15 15:07:19 +00004926 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00004927
4928 if (IF_DEF_PARAMS (ifp)->type == old_type)
4929 return CMD_SUCCESS;
4930
4931 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4932 {
4933 struct ospf_interface *oi = rn->info;
4934
4935 if (!oi)
4936 continue;
4937
4938 oi->type = IF_DEF_PARAMS (ifp)->type;
4939
4940 if (oi->state > ISM_Down)
4941 {
4942 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
4943 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
4944 }
4945 }
4946
4947 return CMD_SUCCESS;
4948}
4949
4950ALIAS (no_ip_ospf_network,
4951 no_ospf_network_cmd,
4952 "no ospf network",
4953 NO_STR
4954 "OSPF interface commands\n"
4955 "Network type\n")
4956
4957DEFUN (ip_ospf_priority,
4958 ip_ospf_priority_addr_cmd,
4959 "ip ospf priority <0-255> A.B.C.D",
4960 "IP Information\n"
4961 "OSPF interface commands\n"
4962 "Router priority\n"
4963 "Priority\n"
4964 "Address of interface")
4965{
4966 struct interface *ifp = vty->index;
4967 u_int32_t priority;
4968 struct route_node *rn;
4969 struct in_addr addr;
4970 int ret;
4971 struct ospf_if_params *params;
4972
4973 params = IF_DEF_PARAMS (ifp);
4974
4975 priority = strtol (argv[0], NULL, 10);
4976
4977 /* Router Priority range is <0-255>. */
4978 if (priority < 0 || priority > 255)
4979 {
4980 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
4981 return CMD_WARNING;
4982 }
4983
4984 if (argc == 2)
4985 {
4986 ret = inet_aton(argv[1], &addr);
4987 if (!ret)
4988 {
4989 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4990 VTY_NEWLINE);
4991 return CMD_WARNING;
4992 }
4993
4994 params = ospf_get_if_params (ifp, addr);
4995 ospf_if_update_params (ifp, addr);
4996 }
4997
4998 SET_IF_PARAM (params, priority);
4999 params->priority = priority;
5000
5001 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5002 {
5003 struct ospf_interface *oi = rn->info;
5004
5005 if (!oi)
5006 continue;
5007
5008
5009 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5010 {
5011 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5012 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5013 }
5014 }
5015
5016 return CMD_SUCCESS;
5017}
5018
5019ALIAS (ip_ospf_priority,
5020 ip_ospf_priority_cmd,
5021 "ip ospf priority <0-255>",
5022 "IP Information\n"
5023 "OSPF interface commands\n"
5024 "Router priority\n"
5025 "Priority\n")
5026
5027ALIAS (ip_ospf_priority,
5028 ospf_priority_cmd,
5029 "ospf priority <0-255>",
5030 "OSPF interface commands\n"
5031 "Router priority\n"
5032 "Priority\n")
5033
5034DEFUN (no_ip_ospf_priority,
5035 no_ip_ospf_priority_addr_cmd,
5036 "no ip ospf priority A.B.C.D",
5037 NO_STR
5038 "IP Information\n"
5039 "OSPF interface commands\n"
5040 "Router priority\n"
5041 "Address of interface")
5042{
5043 struct interface *ifp = vty->index;
5044 struct route_node *rn;
5045 struct in_addr addr;
5046 int ret;
5047 struct ospf_if_params *params;
5048
5049 ifp = vty->index;
5050 params = IF_DEF_PARAMS (ifp);
5051
5052 if (argc == 1)
5053 {
5054 ret = inet_aton(argv[0], &addr);
5055 if (!ret)
5056 {
5057 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5058 VTY_NEWLINE);
5059 return CMD_WARNING;
5060 }
5061
5062 params = ospf_lookup_if_params (ifp, addr);
5063 if (params == NULL)
5064 return CMD_SUCCESS;
5065 }
5066
5067 UNSET_IF_PARAM (params, priority);
5068 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5069
5070 if (params != IF_DEF_PARAMS (ifp))
5071 {
5072 ospf_free_if_params (ifp, addr);
5073 ospf_if_update_params (ifp, addr);
5074 }
5075
5076 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5077 {
5078 struct ospf_interface *oi = rn->info;
5079
5080 if (!oi)
5081 continue;
5082
5083
5084 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5085 {
5086 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5087 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5088 }
5089 }
5090
5091 return CMD_SUCCESS;
5092}
5093
5094ALIAS (no_ip_ospf_priority,
5095 no_ip_ospf_priority_cmd,
5096 "no ip ospf priority",
5097 NO_STR
5098 "IP Information\n"
5099 "OSPF interface commands\n"
5100 "Router priority\n")
5101
5102ALIAS (no_ip_ospf_priority,
5103 no_ospf_priority_cmd,
5104 "no ospf priority",
5105 NO_STR
5106 "OSPF interface commands\n"
5107 "Router priority\n")
5108
5109DEFUN (ip_ospf_retransmit_interval,
5110 ip_ospf_retransmit_interval_addr_cmd,
5111 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5112 "IP Information\n"
5113 "OSPF interface commands\n"
5114 "Time between retransmitting lost link state advertisements\n"
5115 "Seconds\n"
5116 "Address of interface")
5117{
5118 struct interface *ifp = vty->index;
5119 u_int32_t seconds;
5120 struct in_addr addr;
5121 int ret;
5122 struct ospf_if_params *params;
5123
5124 params = IF_DEF_PARAMS (ifp);
5125 seconds = strtol (argv[0], NULL, 10);
5126
5127 /* Retransmit Interval range is <3-65535>. */
5128 if (seconds < 3 || seconds > 65535)
5129 {
5130 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5131 return CMD_WARNING;
5132 }
5133
5134
5135 if (argc == 2)
5136 {
5137 ret = inet_aton(argv[1], &addr);
5138 if (!ret)
5139 {
5140 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5141 VTY_NEWLINE);
5142 return CMD_WARNING;
5143 }
5144
5145 params = ospf_get_if_params (ifp, addr);
5146 ospf_if_update_params (ifp, addr);
5147 }
5148
5149 SET_IF_PARAM (params, retransmit_interval);
5150 params->retransmit_interval = seconds;
5151
5152 return CMD_SUCCESS;
5153}
5154
5155ALIAS (ip_ospf_retransmit_interval,
5156 ip_ospf_retransmit_interval_cmd,
5157 "ip ospf retransmit-interval <3-65535>",
5158 "IP Information\n"
5159 "OSPF interface commands\n"
5160 "Time between retransmitting lost link state advertisements\n"
5161 "Seconds\n")
5162
5163ALIAS (ip_ospf_retransmit_interval,
5164 ospf_retransmit_interval_cmd,
5165 "ospf retransmit-interval <3-65535>",
5166 "OSPF interface commands\n"
5167 "Time between retransmitting lost link state advertisements\n"
5168 "Seconds\n")
5169
5170DEFUN (no_ip_ospf_retransmit_interval,
5171 no_ip_ospf_retransmit_interval_addr_cmd,
5172 "no ip ospf retransmit-interval A.B.C.D",
5173 NO_STR
5174 "IP Information\n"
5175 "OSPF interface commands\n"
5176 "Time between retransmitting lost link state advertisements\n"
5177 "Address of interface")
5178{
5179 struct interface *ifp = vty->index;
5180 struct in_addr addr;
5181 int ret;
5182 struct ospf_if_params *params;
5183
5184 ifp = vty->index;
5185 params = IF_DEF_PARAMS (ifp);
5186
5187 if (argc == 1)
5188 {
5189 ret = inet_aton(argv[0], &addr);
5190 if (!ret)
5191 {
5192 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5193 VTY_NEWLINE);
5194 return CMD_WARNING;
5195 }
5196
5197 params = ospf_lookup_if_params (ifp, addr);
5198 if (params == NULL)
5199 return CMD_SUCCESS;
5200 }
5201
5202 UNSET_IF_PARAM (params, retransmit_interval);
5203 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5204
5205 if (params != IF_DEF_PARAMS (ifp))
5206 {
5207 ospf_free_if_params (ifp, addr);
5208 ospf_if_update_params (ifp, addr);
5209 }
5210
5211 return CMD_SUCCESS;
5212}
5213
5214ALIAS (no_ip_ospf_retransmit_interval,
5215 no_ip_ospf_retransmit_interval_cmd,
5216 "no ip ospf retransmit-interval",
5217 NO_STR
5218 "IP Information\n"
5219 "OSPF interface commands\n"
5220 "Time between retransmitting lost link state advertisements\n")
5221
5222ALIAS (no_ip_ospf_retransmit_interval,
5223 no_ospf_retransmit_interval_cmd,
5224 "no ospf retransmit-interval",
5225 NO_STR
5226 "OSPF interface commands\n"
5227 "Time between retransmitting lost link state advertisements\n")
5228
5229DEFUN (ip_ospf_transmit_delay,
5230 ip_ospf_transmit_delay_addr_cmd,
5231 "ip ospf transmit-delay <1-65535> A.B.C.D",
5232 "IP Information\n"
5233 "OSPF interface commands\n"
5234 "Link state transmit delay\n"
5235 "Seconds\n"
5236 "Address of interface")
5237{
5238 struct interface *ifp = vty->index;
5239 u_int32_t seconds;
5240 struct in_addr addr;
5241 int ret;
5242 struct ospf_if_params *params;
5243
5244 params = IF_DEF_PARAMS (ifp);
5245 seconds = strtol (argv[0], NULL, 10);
5246
5247 /* Transmit Delay range is <1-65535>. */
5248 if (seconds < 1 || seconds > 65535)
5249 {
5250 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5251 return CMD_WARNING;
5252 }
5253
5254 if (argc == 2)
5255 {
5256 ret = inet_aton(argv[1], &addr);
5257 if (!ret)
5258 {
5259 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5260 VTY_NEWLINE);
5261 return CMD_WARNING;
5262 }
5263
5264 params = ospf_get_if_params (ifp, addr);
5265 ospf_if_update_params (ifp, addr);
5266 }
5267
5268 SET_IF_PARAM (params, transmit_delay);
5269 params->transmit_delay = seconds;
5270
5271 return CMD_SUCCESS;
5272}
5273
5274ALIAS (ip_ospf_transmit_delay,
5275 ip_ospf_transmit_delay_cmd,
5276 "ip ospf transmit-delay <1-65535>",
5277 "IP Information\n"
5278 "OSPF interface commands\n"
5279 "Link state transmit delay\n"
5280 "Seconds\n")
5281
5282ALIAS (ip_ospf_transmit_delay,
5283 ospf_transmit_delay_cmd,
5284 "ospf transmit-delay <1-65535>",
5285 "OSPF interface commands\n"
5286 "Link state transmit delay\n"
5287 "Seconds\n")
5288
5289DEFUN (no_ip_ospf_transmit_delay,
5290 no_ip_ospf_transmit_delay_addr_cmd,
5291 "no ip ospf transmit-delay A.B.C.D",
5292 NO_STR
5293 "IP Information\n"
5294 "OSPF interface commands\n"
5295 "Link state transmit delay\n"
5296 "Address of interface")
5297{
5298 struct interface *ifp = vty->index;
5299 struct in_addr addr;
5300 int ret;
5301 struct ospf_if_params *params;
5302
5303 ifp = vty->index;
5304 params = IF_DEF_PARAMS (ifp);
5305
5306 if (argc == 1)
5307 {
5308 ret = inet_aton(argv[0], &addr);
5309 if (!ret)
5310 {
5311 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5312 VTY_NEWLINE);
5313 return CMD_WARNING;
5314 }
5315
5316 params = ospf_lookup_if_params (ifp, addr);
5317 if (params == NULL)
5318 return CMD_SUCCESS;
5319 }
5320
5321 UNSET_IF_PARAM (params, transmit_delay);
5322 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5323
5324 if (params != IF_DEF_PARAMS (ifp))
5325 {
5326 ospf_free_if_params (ifp, addr);
5327 ospf_if_update_params (ifp, addr);
5328 }
5329
5330 return CMD_SUCCESS;
5331}
5332
5333ALIAS (no_ip_ospf_transmit_delay,
5334 no_ip_ospf_transmit_delay_cmd,
5335 "no ip ospf transmit-delay",
5336 NO_STR
5337 "IP Information\n"
5338 "OSPF interface commands\n"
5339 "Link state transmit delay\n")
5340
5341ALIAS (no_ip_ospf_transmit_delay,
5342 no_ospf_transmit_delay_cmd,
5343 "no ospf transmit-delay",
5344 NO_STR
5345 "OSPF interface commands\n"
5346 "Link state transmit delay\n")
5347
5348
5349DEFUN (ospf_redistribute_source_metric_type,
5350 ospf_redistribute_source_metric_type_routemap_cmd,
5351 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2) route-map WORD",
5352 "Redistribute information from another routing protocol\n"
5353 "Kernel routes\n"
5354 "Connected\n"
5355 "Static routes\n"
5356 "Routing Information Protocol (RIP)\n"
5357 "Border Gateway Protocol (BGP)\n"
5358 "Metric for redistributed routes\n"
5359 "OSPF default metric\n"
5360 "OSPF exterior metric type for redistributed routes\n"
5361 "Set OSPF External Type 1 metrics\n"
5362 "Set OSPF External Type 2 metrics\n"
5363 "Route map reference\n"
5364 "Pointer to route-map entries\n")
5365{
paul020709f2003-04-04 02:44:16 +00005366 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005367 int source;
5368 int type = -1;
5369 int metric = -1;
5370
5371 /* Get distribute source. */
5372 if (!str2distribute_source (argv[0], &source))
5373 return CMD_WARNING;
5374
5375 /* Get metric value. */
5376 if (argc >= 2)
5377 if (!str2metric (argv[1], &metric))
5378 return CMD_WARNING;
5379
5380 /* Get metric type. */
5381 if (argc >= 3)
5382 if (!str2metric_type (argv[2], &type))
5383 return CMD_WARNING;
5384
5385 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005386 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005387 else
paul020709f2003-04-04 02:44:16 +00005388 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005389
paul020709f2003-04-04 02:44:16 +00005390 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005391}
5392
5393ALIAS (ospf_redistribute_source_metric_type,
5394 ospf_redistribute_source_metric_type_cmd,
5395 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> metric-type (1|2)",
5396 "Redistribute information from another routing protocol\n"
5397 "Kernel routes\n"
5398 "Connected\n"
5399 "Static routes\n"
5400 "Routing Information Protocol (RIP)\n"
5401 "Border Gateway Protocol (BGP)\n"
5402 "Metric for redistributed routes\n"
5403 "OSPF default metric\n"
5404 "OSPF exterior metric type for redistributed routes\n"
5405 "Set OSPF External Type 1 metrics\n"
5406 "Set OSPF External Type 2 metrics\n")
5407
5408ALIAS (ospf_redistribute_source_metric_type,
5409 ospf_redistribute_source_metric_cmd,
5410 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214>",
5411 "Redistribute information from another routing protocol\n"
5412 "Kernel routes\n"
5413 "Connected\n"
5414 "Static routes\n"
5415 "Routing Information Protocol (RIP)\n"
5416 "Border Gateway Protocol (BGP)\n"
5417 "Metric for redistributed routes\n"
5418 "OSPF default metric\n")
5419
5420DEFUN (ospf_redistribute_source_type_metric,
5421 ospf_redistribute_source_type_metric_routemap_cmd,
5422 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214> route-map WORD",
5423 "Redistribute information from another routing protocol\n"
5424 "Kernel routes\n"
5425 "Connected\n"
5426 "Static routes\n"
5427 "Routing Information Protocol (RIP)\n"
5428 "Border Gateway Protocol (BGP)\n"
5429 "OSPF exterior metric type for redistributed routes\n"
5430 "Set OSPF External Type 1 metrics\n"
5431 "Set OSPF External Type 2 metrics\n"
5432 "Metric for redistributed routes\n"
5433 "OSPF default metric\n"
5434 "Route map reference\n"
5435 "Pointer to route-map entries\n")
5436{
paul020709f2003-04-04 02:44:16 +00005437 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005438 int source;
5439 int type = -1;
5440 int metric = -1;
5441
5442 /* Get distribute source. */
5443 if (!str2distribute_source (argv[0], &source))
5444 return CMD_WARNING;
5445
5446 /* Get metric value. */
5447 if (argc >= 2)
5448 if (!str2metric_type (argv[1], &type))
5449 return CMD_WARNING;
5450
5451 /* Get metric type. */
5452 if (argc >= 3)
5453 if (!str2metric (argv[2], &metric))
5454 return CMD_WARNING;
5455
5456 if (argc == 4)
paul020709f2003-04-04 02:44:16 +00005457 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00005458 else
paul020709f2003-04-04 02:44:16 +00005459 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005460
paul020709f2003-04-04 02:44:16 +00005461 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00005462}
5463
5464ALIAS (ospf_redistribute_source_type_metric,
5465 ospf_redistribute_source_type_metric_cmd,
5466 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) metric <0-16777214>",
5467 "Redistribute information from another routing protocol\n"
5468 "Kernel routes\n"
5469 "Connected\n"
5470 "Static routes\n"
5471 "Routing Information Protocol (RIP)\n"
5472 "Border Gateway Protocol (BGP)\n"
5473 "OSPF exterior metric type for redistributed routes\n"
5474 "Set OSPF External Type 1 metrics\n"
5475 "Set OSPF External Type 2 metrics\n"
5476 "Metric for redistributed routes\n"
5477 "OSPF default metric\n")
5478
5479ALIAS (ospf_redistribute_source_type_metric,
5480 ospf_redistribute_source_type_cmd,
5481 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2)",
5482 "Redistribute information from another routing protocol\n"
5483 "Kernel routes\n"
5484 "Connected\n"
5485 "Static routes\n"
5486 "Routing Information Protocol (RIP)\n"
5487 "Border Gateway Protocol (BGP)\n"
5488 "OSPF exterior metric type for redistributed routes\n"
5489 "Set OSPF External Type 1 metrics\n"
5490 "Set OSPF External Type 2 metrics\n")
5491
5492ALIAS (ospf_redistribute_source_type_metric,
5493 ospf_redistribute_source_cmd,
5494 "redistribute (kernel|connected|static|rip|bgp)",
5495 "Redistribute information from another routing protocol\n"
5496 "Kernel routes\n"
5497 "Connected\n"
5498 "Static routes\n"
5499 "Routing Information Protocol (RIP)\n"
5500 "Border Gateway Protocol (BGP)\n")
5501
5502DEFUN (ospf_redistribute_source_metric_routemap,
5503 ospf_redistribute_source_metric_routemap_cmd,
5504 "redistribute (kernel|connected|static|rip|bgp) metric <0-16777214> route-map WORD",
5505 "Redistribute information from another routing protocol\n"
5506 "Kernel routes\n"
5507 "Connected\n"
5508 "Static routes\n"
5509 "Routing Information Protocol (RIP)\n"
5510 "Border Gateway Protocol (BGP)\n"
5511 "Metric for redistributed routes\n"
5512 "OSPF default metric\n"
5513 "Route map reference\n"
5514 "Pointer to route-map entries\n")
5515{
paul020709f2003-04-04 02:44:16 +00005516 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005517 int source;
5518 int metric = -1;
5519
5520 /* Get distribute source. */
5521 if (!str2distribute_source (argv[0], &source))
5522 return CMD_WARNING;
5523
5524 /* Get metric value. */
5525 if (argc >= 2)
5526 if (!str2metric (argv[1], &metric))
5527 return CMD_WARNING;
5528
5529 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005530 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005531 else
paul020709f2003-04-04 02:44:16 +00005532 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005533
paul020709f2003-04-04 02:44:16 +00005534 return ospf_redistribute_set (ospf, source, -1, metric);
paul718e3742002-12-13 20:15:29 +00005535}
5536
5537DEFUN (ospf_redistribute_source_type_routemap,
5538 ospf_redistribute_source_type_routemap_cmd,
5539 "redistribute (kernel|connected|static|rip|bgp) metric-type (1|2) route-map WORD",
5540 "Redistribute information from another routing protocol\n"
5541 "Kernel routes\n"
5542 "Connected\n"
5543 "Static routes\n"
5544 "Routing Information Protocol (RIP)\n"
5545 "Border Gateway Protocol (BGP)\n"
5546 "OSPF exterior metric type for redistributed routes\n"
5547 "Set OSPF External Type 1 metrics\n"
5548 "Set OSPF External Type 2 metrics\n"
5549 "Route map reference\n"
5550 "Pointer to route-map entries\n")
5551{
paul020709f2003-04-04 02:44:16 +00005552 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005553 int source;
5554 int type = -1;
5555
5556 /* Get distribute source. */
5557 if (!str2distribute_source (argv[0], &source))
5558 return CMD_WARNING;
5559
5560 /* Get metric value. */
5561 if (argc >= 2)
5562 if (!str2metric_type (argv[1], &type))
5563 return CMD_WARNING;
5564
5565 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005566 ospf_routemap_set (ospf, source, argv[2]);
paul718e3742002-12-13 20:15:29 +00005567 else
paul020709f2003-04-04 02:44:16 +00005568 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005569
paul020709f2003-04-04 02:44:16 +00005570 return ospf_redistribute_set (ospf, source, type, -1);
paul718e3742002-12-13 20:15:29 +00005571}
5572
5573DEFUN (ospf_redistribute_source_routemap,
5574 ospf_redistribute_source_routemap_cmd,
5575 "redistribute (kernel|connected|static|rip|bgp) route-map WORD",
5576 "Redistribute information from another routing protocol\n"
5577 "Kernel routes\n"
5578 "Connected\n"
5579 "Static routes\n"
5580 "Routing Information Protocol (RIP)\n"
5581 "Border Gateway Protocol (BGP)\n"
5582 "Route map reference\n"
5583 "Pointer to route-map entries\n")
5584{
paul020709f2003-04-04 02:44:16 +00005585 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005586 int source;
5587
5588 /* Get distribute source. */
5589 if (!str2distribute_source (argv[0], &source))
5590 return CMD_WARNING;
5591
5592 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005593 ospf_routemap_set (ospf, source, argv[1]);
paul718e3742002-12-13 20:15:29 +00005594 else
paul020709f2003-04-04 02:44:16 +00005595 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005596
paul020709f2003-04-04 02:44:16 +00005597 return ospf_redistribute_set (ospf, source, -1, -1);
paul718e3742002-12-13 20:15:29 +00005598}
5599
5600DEFUN (no_ospf_redistribute_source,
5601 no_ospf_redistribute_source_cmd,
5602 "no redistribute (kernel|connected|static|rip|bgp)",
5603 NO_STR
5604 "Redistribute information from another routing protocol\n"
5605 "Kernel routes\n"
5606 "Connected\n"
5607 "Static routes\n"
5608 "Routing Information Protocol (RIP)\n"
5609 "Border Gateway Protocol (BGP)\n")
5610{
paul020709f2003-04-04 02:44:16 +00005611 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005612 int source;
5613
5614 if (!str2distribute_source (argv[0], &source))
5615 return CMD_WARNING;
5616
paul020709f2003-04-04 02:44:16 +00005617 ospf_routemap_unset (ospf, source);
5618 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00005619}
5620
5621DEFUN (ospf_distribute_list_out,
5622 ospf_distribute_list_out_cmd,
5623 "distribute-list WORD out (kernel|connected|static|rip|bgp)",
5624 "Filter networks in routing updates\n"
5625 "Access-list name\n"
5626 OUT_STR
5627 "Kernel routes\n"
5628 "Connected\n"
5629 "Static routes\n"
5630 "Routing Information Protocol (RIP)\n"
5631 "Border Gateway Protocol (BGP)\n")
5632{
paul68980082003-03-25 05:07:42 +00005633 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005634 int source;
5635
5636 /* Get distribute source. */
5637 if (!str2distribute_source (argv[1], &source))
5638 return CMD_WARNING;
5639
paul68980082003-03-25 05:07:42 +00005640 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005641}
5642
5643DEFUN (no_ospf_distribute_list_out,
5644 no_ospf_distribute_list_out_cmd,
5645 "no distribute-list WORD out (kernel|connected|static|rip|bgp)",
5646 NO_STR
5647 "Filter networks in routing updates\n"
5648 "Access-list name\n"
5649 OUT_STR
5650 "Kernel routes\n"
5651 "Connected\n"
5652 "Static routes\n"
5653 "Routing Information Protocol (RIP)\n"
5654 "Border Gateway Protocol (BGP)\n")
5655{
paul68980082003-03-25 05:07:42 +00005656 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005657 int source;
5658
5659 if (!str2distribute_source (argv[1], &source))
5660 return CMD_WARNING;
5661
paul68980082003-03-25 05:07:42 +00005662 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00005663}
5664
5665/* Default information originate. */
5666DEFUN (ospf_default_information_originate_metric_type_routemap,
5667 ospf_default_information_originate_metric_type_routemap_cmd,
5668 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
5669 "Control distribution of default information\n"
5670 "Distribute a default route\n"
5671 "OSPF default metric\n"
5672 "OSPF metric\n"
5673 "OSPF metric type for default routes\n"
5674 "Set OSPF External Type 1 metrics\n"
5675 "Set OSPF External Type 2 metrics\n"
5676 "Route map reference\n"
5677 "Pointer to route-map entries\n")
5678{
paul020709f2003-04-04 02:44:16 +00005679 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005680 int type = -1;
5681 int metric = -1;
5682
5683 /* Get metric value. */
5684 if (argc >= 1)
5685 if (!str2metric (argv[0], &metric))
5686 return CMD_WARNING;
5687
5688 /* Get metric type. */
5689 if (argc >= 2)
5690 if (!str2metric_type (argv[1], &type))
5691 return CMD_WARNING;
5692
5693 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005694 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005695 else
paul020709f2003-04-04 02:44:16 +00005696 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005697
paul020709f2003-04-04 02:44:16 +00005698 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5699 type, metric);
paul718e3742002-12-13 20:15:29 +00005700}
5701
5702ALIAS (ospf_default_information_originate_metric_type_routemap,
5703 ospf_default_information_originate_metric_type_cmd,
5704 "default-information originate metric <0-16777214> metric-type (1|2)",
5705 "Control distribution of default information\n"
5706 "Distribute a default route\n"
5707 "OSPF default metric\n"
5708 "OSPF metric\n"
5709 "OSPF metric type for default routes\n"
5710 "Set OSPF External Type 1 metrics\n"
5711 "Set OSPF External Type 2 metrics\n")
5712
5713ALIAS (ospf_default_information_originate_metric_type_routemap,
5714 ospf_default_information_originate_metric_cmd,
5715 "default-information originate metric <0-16777214>",
5716 "Control distribution of default information\n"
5717 "Distribute a default route\n"
5718 "OSPF default metric\n"
5719 "OSPF metric\n")
5720
5721ALIAS (ospf_default_information_originate_metric_type_routemap,
5722 ospf_default_information_originate_cmd,
5723 "default-information originate",
5724 "Control distribution of default information\n"
5725 "Distribute a default route\n")
5726
5727/* Default information originate. */
5728DEFUN (ospf_default_information_originate_metric_routemap,
5729 ospf_default_information_originate_metric_routemap_cmd,
5730 "default-information originate metric <0-16777214> route-map WORD",
5731 "Control distribution of default information\n"
5732 "Distribute a default route\n"
5733 "OSPF default metric\n"
5734 "OSPF metric\n"
5735 "Route map reference\n"
5736 "Pointer to route-map entries\n")
5737{
paul020709f2003-04-04 02:44:16 +00005738 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005739 int metric = -1;
5740
5741 /* Get metric value. */
5742 if (argc >= 1)
5743 if (!str2metric (argv[0], &metric))
5744 return CMD_WARNING;
5745
5746 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005747 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005748 else
paul020709f2003-04-04 02:44:16 +00005749 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005750
paul020709f2003-04-04 02:44:16 +00005751 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5752 -1, metric);
paul718e3742002-12-13 20:15:29 +00005753}
5754
5755/* Default information originate. */
5756DEFUN (ospf_default_information_originate_routemap,
5757 ospf_default_information_originate_routemap_cmd,
5758 "default-information originate route-map WORD",
5759 "Control distribution of default information\n"
5760 "Distribute a default route\n"
5761 "Route map reference\n"
5762 "Pointer to route-map entries\n")
5763{
paul020709f2003-04-04 02:44:16 +00005764 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005765
paul020709f2003-04-04 02:44:16 +00005766 if (argc == 1)
5767 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5768 else
5769 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5770
5771 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
paul718e3742002-12-13 20:15:29 +00005772}
5773
5774DEFUN (ospf_default_information_originate_type_metric_routemap,
5775 ospf_default_information_originate_type_metric_routemap_cmd,
5776 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
5777 "Control distribution of default information\n"
5778 "Distribute a default route\n"
5779 "OSPF metric type for default routes\n"
5780 "Set OSPF External Type 1 metrics\n"
5781 "Set OSPF External Type 2 metrics\n"
5782 "OSPF default metric\n"
5783 "OSPF metric\n"
5784 "Route map reference\n"
5785 "Pointer to route-map entries\n")
5786{
paul020709f2003-04-04 02:44:16 +00005787 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005788 int type = -1;
5789 int metric = -1;
5790
5791 /* Get metric type. */
5792 if (argc >= 1)
5793 if (!str2metric_type (argv[0], &type))
5794 return CMD_WARNING;
5795
5796 /* Get metric value. */
5797 if (argc >= 2)
5798 if (!str2metric (argv[1], &metric))
5799 return CMD_WARNING;
5800
5801 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005802 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005803 else
paul020709f2003-04-04 02:44:16 +00005804 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005805
paul020709f2003-04-04 02:44:16 +00005806 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5807 type, metric);
paul718e3742002-12-13 20:15:29 +00005808}
5809
5810ALIAS (ospf_default_information_originate_type_metric_routemap,
5811 ospf_default_information_originate_type_metric_cmd,
5812 "default-information originate metric-type (1|2) metric <0-16777214>",
5813 "Control distribution of default information\n"
5814 "Distribute a default route\n"
5815 "OSPF metric type for default routes\n"
5816 "Set OSPF External Type 1 metrics\n"
5817 "Set OSPF External Type 2 metrics\n"
5818 "OSPF default metric\n"
5819 "OSPF metric\n")
5820
5821ALIAS (ospf_default_information_originate_type_metric_routemap,
5822 ospf_default_information_originate_type_cmd,
5823 "default-information originate metric-type (1|2)",
5824 "Control distribution of default information\n"
5825 "Distribute a default route\n"
5826 "OSPF metric type for default routes\n"
5827 "Set OSPF External Type 1 metrics\n"
5828 "Set OSPF External Type 2 metrics\n")
5829
5830DEFUN (ospf_default_information_originate_type_routemap,
5831 ospf_default_information_originate_type_routemap_cmd,
5832 "default-information originate metric-type (1|2) route-map WORD",
5833 "Control distribution of default information\n"
5834 "Distribute a default route\n"
5835 "OSPF metric type for default routes\n"
5836 "Set OSPF External Type 1 metrics\n"
5837 "Set OSPF External Type 2 metrics\n"
5838 "Route map reference\n"
5839 "Pointer to route-map entries\n")
5840{
paul020709f2003-04-04 02:44:16 +00005841 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005842 int type = -1;
5843
5844 /* Get metric type. */
5845 if (argc >= 1)
5846 if (!str2metric_type (argv[0], &type))
5847 return CMD_WARNING;
5848
5849 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005850 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005851 else
paul020709f2003-04-04 02:44:16 +00005852 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005853
paul020709f2003-04-04 02:44:16 +00005854 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
5855 type, -1);
paul718e3742002-12-13 20:15:29 +00005856}
5857
5858DEFUN (ospf_default_information_originate_always_metric_type_routemap,
5859 ospf_default_information_originate_always_metric_type_routemap_cmd,
5860 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
5861 "Control distribution of default information\n"
5862 "Distribute a default route\n"
5863 "Always advertise default route\n"
5864 "OSPF default metric\n"
5865 "OSPF metric\n"
5866 "OSPF metric type for default routes\n"
5867 "Set OSPF External Type 1 metrics\n"
5868 "Set OSPF External Type 2 metrics\n"
5869 "Route map reference\n"
5870 "Pointer to route-map entries\n")
5871{
paul020709f2003-04-04 02:44:16 +00005872 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005873 int type = -1;
5874 int metric = -1;
5875
5876 /* Get metric value. */
5877 if (argc >= 1)
5878 if (!str2metric (argv[0], &metric))
5879 return CMD_WARNING;
5880
5881 /* Get metric type. */
5882 if (argc >= 2)
5883 if (!str2metric_type (argv[1], &type))
5884 return CMD_WARNING;
5885
5886 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00005887 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00005888 else
paul020709f2003-04-04 02:44:16 +00005889 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005890
paul020709f2003-04-04 02:44:16 +00005891 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00005892 type, metric);
5893}
5894
5895ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5896 ospf_default_information_originate_always_metric_type_cmd,
5897 "default-information originate always metric <0-16777214> metric-type (1|2)",
5898 "Control distribution of default information\n"
5899 "Distribute a default route\n"
5900 "Always advertise default route\n"
5901 "OSPF default metric\n"
5902 "OSPF metric\n"
5903 "OSPF metric type for default routes\n"
5904 "Set OSPF External Type 1 metrics\n"
5905 "Set OSPF External Type 2 metrics\n")
5906
5907ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5908 ospf_default_information_originate_always_metric_cmd,
5909 "default-information originate always metric <0-16777214>",
5910 "Control distribution of default information\n"
5911 "Distribute a default route\n"
5912 "Always advertise default route\n"
5913 "OSPF default metric\n"
5914 "OSPF metric\n"
5915 "OSPF metric type for default routes\n")
5916
5917ALIAS (ospf_default_information_originate_always_metric_type_routemap,
5918 ospf_default_information_originate_always_cmd,
5919 "default-information originate always",
5920 "Control distribution of default information\n"
5921 "Distribute a default route\n"
5922 "Always advertise default route\n")
5923
5924DEFUN (ospf_default_information_originate_always_metric_routemap,
5925 ospf_default_information_originate_always_metric_routemap_cmd,
5926 "default-information originate always metric <0-16777214> route-map WORD",
5927 "Control distribution of default information\n"
5928 "Distribute a default route\n"
5929 "Always advertise default route\n"
5930 "OSPF default metric\n"
5931 "OSPF metric\n"
5932 "Route map reference\n"
5933 "Pointer to route-map entries\n")
5934{
paul020709f2003-04-04 02:44:16 +00005935 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005936 int metric = -1;
5937
5938 /* Get metric value. */
5939 if (argc >= 1)
5940 if (!str2metric (argv[0], &metric))
5941 return CMD_WARNING;
5942
5943 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00005944 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00005945 else
paul020709f2003-04-04 02:44:16 +00005946 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00005947
paul020709f2003-04-04 02:44:16 +00005948 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
5949 -1, metric);
paul718e3742002-12-13 20:15:29 +00005950}
5951
5952DEFUN (ospf_default_information_originate_always_routemap,
5953 ospf_default_information_originate_always_routemap_cmd,
5954 "default-information originate always route-map WORD",
5955 "Control distribution of default information\n"
5956 "Distribute a default route\n"
5957 "Always advertise default route\n"
5958 "Route map reference\n"
5959 "Pointer to route-map entries\n")
5960{
paul020709f2003-04-04 02:44:16 +00005961 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005962
paul020709f2003-04-04 02:44:16 +00005963 if (argc == 1)
5964 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
5965 else
5966 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
5967
5968 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
paul718e3742002-12-13 20:15:29 +00005969}
5970
5971DEFUN (ospf_default_information_originate_always_type_metric_routemap,
5972 ospf_default_information_originate_always_type_metric_routemap_cmd,
5973 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
5974 "Control distribution of default information\n"
5975 "Distribute a default route\n"
5976 "Always advertise default route\n"
5977 "OSPF metric type for default routes\n"
5978 "Set OSPF External Type 1 metrics\n"
5979 "Set OSPF External Type 2 metrics\n"
5980 "OSPF default metric\n"
5981 "OSPF metric\n"
5982 "Route map reference\n"
5983 "Pointer to route-map entries\n")
5984{
paul020709f2003-04-04 02:44:16 +00005985 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00005986 int type = -1;
5987 int metric = -1;
5988
5989 /* Get metric type. */
5990 if (argc >= 1)
5991 if (!str2metric_type (argv[0], &type))
5992 return CMD_WARNING;
5993
5994 /* Get metric value. */
5995 if (argc >= 2)
5996 if (!str2metric (argv[1], &metric))
5997 return CMD_WARNING;
5998
5999 if (argc == 3)
paul020709f2003-04-04 02:44:16 +00006000 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
paul718e3742002-12-13 20:15:29 +00006001 else
paul020709f2003-04-04 02:44:16 +00006002 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006003
paul020709f2003-04-04 02:44:16 +00006004 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006005 type, metric);
6006}
6007
6008ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6009 ospf_default_information_originate_always_type_metric_cmd,
6010 "default-information originate always metric-type (1|2) metric <0-16777214>",
6011 "Control distribution of default information\n"
6012 "Distribute a default route\n"
6013 "Always advertise default route\n"
6014 "OSPF metric type for default routes\n"
6015 "Set OSPF External Type 1 metrics\n"
6016 "Set OSPF External Type 2 metrics\n"
6017 "OSPF default metric\n"
6018 "OSPF metric\n")
6019
6020ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6021 ospf_default_information_originate_always_type_cmd,
6022 "default-information originate always metric-type (1|2)",
6023 "Control distribution of default information\n"
6024 "Distribute a default route\n"
6025 "Always advertise default route\n"
6026 "OSPF metric type for default routes\n"
6027 "Set OSPF External Type 1 metrics\n"
6028 "Set OSPF External Type 2 metrics\n")
6029
6030DEFUN (ospf_default_information_originate_always_type_routemap,
6031 ospf_default_information_originate_always_type_routemap_cmd,
6032 "default-information originate always metric-type (1|2) route-map WORD",
6033 "Control distribution of default information\n"
6034 "Distribute a default route\n"
6035 "Always advertise default route\n"
6036 "OSPF metric type for default routes\n"
6037 "Set OSPF External Type 1 metrics\n"
6038 "Set OSPF External Type 2 metrics\n"
6039 "Route map reference\n"
6040 "Pointer to route-map entries\n")
6041{
paul020709f2003-04-04 02:44:16 +00006042 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006043 int type = -1;
6044
6045 /* Get metric type. */
6046 if (argc >= 1)
6047 if (!str2metric_type (argv[0], &type))
6048 return CMD_WARNING;
6049
6050 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00006051 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
paul718e3742002-12-13 20:15:29 +00006052 else
paul020709f2003-04-04 02:44:16 +00006053 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006054
paul020709f2003-04-04 02:44:16 +00006055 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
paul718e3742002-12-13 20:15:29 +00006056 type, -1);
6057}
6058
6059DEFUN (no_ospf_default_information_originate,
6060 no_ospf_default_information_originate_cmd,
6061 "no default-information originate",
6062 NO_STR
6063 "Control distribution of default information\n"
6064 "Distribute a default route\n")
6065{
paul68980082003-03-25 05:07:42 +00006066 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006067 struct prefix_ipv4 p;
6068 struct in_addr nexthop;
6069
6070 p.family = AF_INET;
6071 p.prefix.s_addr = 0;
6072 p.prefixlen = 0;
6073
paul68980082003-03-25 05:07:42 +00006074 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0, nexthop);
paul718e3742002-12-13 20:15:29 +00006075
6076 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6077 ospf_external_info_delete (DEFAULT_ROUTE, p);
6078 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6079 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6080 }
6081
paul020709f2003-04-04 02:44:16 +00006082 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6083 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006084}
6085
6086DEFUN (ospf_default_metric,
6087 ospf_default_metric_cmd,
6088 "default-metric <0-16777214>",
6089 "Set metric of redistributed routes\n"
6090 "Default metric\n")
6091{
paul68980082003-03-25 05:07:42 +00006092 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006093 int metric = -1;
6094
6095 if (!str2metric (argv[0], &metric))
6096 return CMD_WARNING;
6097
paul68980082003-03-25 05:07:42 +00006098 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006099
6100 return CMD_SUCCESS;
6101}
6102
6103DEFUN (no_ospf_default_metric,
6104 no_ospf_default_metric_cmd,
6105 "no default-metric",
6106 NO_STR
6107 "Set metric of redistributed routes\n")
6108{
paul68980082003-03-25 05:07:42 +00006109 struct ospf *ospf = vty->index;
6110
6111 ospf->default_metric = -1;
6112
paul718e3742002-12-13 20:15:29 +00006113 return CMD_SUCCESS;
6114}
6115
6116ALIAS (no_ospf_default_metric,
6117 no_ospf_default_metric_val_cmd,
6118 "no default-metric <0-16777214>",
6119 NO_STR
6120 "Set metric of redistributed routes\n"
6121 "Default metric\n")
6122
6123DEFUN (ospf_distance,
6124 ospf_distance_cmd,
6125 "distance <1-255>",
6126 "Define an administrative distance\n"
6127 "OSPF Administrative distance\n")
6128{
paul68980082003-03-25 05:07:42 +00006129 struct ospf *ospf = vty->index;
6130
6131 ospf->distance_all = atoi (argv[0]);
6132
paul718e3742002-12-13 20:15:29 +00006133 return CMD_SUCCESS;
6134}
6135
6136DEFUN (no_ospf_distance,
6137 no_ospf_distance_cmd,
6138 "no distance <1-255>",
6139 NO_STR
6140 "Define an administrative distance\n"
6141 "OSPF Administrative distance\n")
6142{
paul68980082003-03-25 05:07:42 +00006143 struct ospf *ospf = vty->index;
6144
6145 ospf->distance_all = 0;
6146
paul718e3742002-12-13 20:15:29 +00006147 return CMD_SUCCESS;
6148}
6149
6150DEFUN (no_ospf_distance_ospf,
6151 no_ospf_distance_ospf_cmd,
6152 "no distance ospf",
6153 NO_STR
6154 "Define an administrative distance\n"
6155 "OSPF Administrative distance\n"
6156 "OSPF Distance\n")
6157{
paul68980082003-03-25 05:07:42 +00006158 struct ospf *ospf = vty->index;
6159
6160 ospf->distance_intra = 0;
6161 ospf->distance_inter = 0;
6162 ospf->distance_external = 0;
6163
paul718e3742002-12-13 20:15:29 +00006164 return CMD_SUCCESS;
6165}
6166
6167DEFUN (ospf_distance_ospf_intra,
6168 ospf_distance_ospf_intra_cmd,
6169 "distance ospf intra-area <1-255>",
6170 "Define an administrative distance\n"
6171 "OSPF Administrative distance\n"
6172 "Intra-area routes\n"
6173 "Distance for intra-area routes\n")
6174{
paul68980082003-03-25 05:07:42 +00006175 struct ospf *ospf = vty->index;
6176
6177 ospf->distance_intra = atoi (argv[0]);
6178
paul718e3742002-12-13 20:15:29 +00006179 return CMD_SUCCESS;
6180}
6181
6182DEFUN (ospf_distance_ospf_intra_inter,
6183 ospf_distance_ospf_intra_inter_cmd,
6184 "distance ospf intra-area <1-255> inter-area <1-255>",
6185 "Define an administrative distance\n"
6186 "OSPF Administrative distance\n"
6187 "Intra-area routes\n"
6188 "Distance for intra-area routes\n"
6189 "Inter-area routes\n"
6190 "Distance for inter-area routes\n")
6191{
paul68980082003-03-25 05:07:42 +00006192 struct ospf *ospf = vty->index;
6193
6194 ospf->distance_intra = atoi (argv[0]);
6195 ospf->distance_inter = atoi (argv[1]);
6196
paul718e3742002-12-13 20:15:29 +00006197 return CMD_SUCCESS;
6198}
6199
6200DEFUN (ospf_distance_ospf_intra_external,
6201 ospf_distance_ospf_intra_external_cmd,
6202 "distance ospf intra-area <1-255> external <1-255>",
6203 "Define an administrative distance\n"
6204 "OSPF Administrative distance\n"
6205 "Intra-area routes\n"
6206 "Distance for intra-area routes\n"
6207 "External routes\n"
6208 "Distance for external routes\n")
6209{
paul68980082003-03-25 05:07:42 +00006210 struct ospf *ospf = vty->index;
6211
6212 ospf->distance_intra = atoi (argv[0]);
6213 ospf->distance_external = atoi (argv[1]);
6214
paul718e3742002-12-13 20:15:29 +00006215 return CMD_SUCCESS;
6216}
6217
6218DEFUN (ospf_distance_ospf_intra_inter_external,
6219 ospf_distance_ospf_intra_inter_external_cmd,
6220 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6221 "Define an administrative distance\n"
6222 "OSPF Administrative distance\n"
6223 "Intra-area routes\n"
6224 "Distance for intra-area routes\n"
6225 "Inter-area routes\n"
6226 "Distance for inter-area routes\n"
6227 "External routes\n"
6228 "Distance for external routes\n")
6229{
paul68980082003-03-25 05:07:42 +00006230 struct ospf *ospf = vty->index;
6231
6232 ospf->distance_intra = atoi (argv[0]);
6233 ospf->distance_inter = atoi (argv[1]);
6234 ospf->distance_external = atoi (argv[2]);
6235
paul718e3742002-12-13 20:15:29 +00006236 return CMD_SUCCESS;
6237}
6238
6239DEFUN (ospf_distance_ospf_intra_external_inter,
6240 ospf_distance_ospf_intra_external_inter_cmd,
6241 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6242 "Define an administrative distance\n"
6243 "OSPF Administrative distance\n"
6244 "Intra-area routes\n"
6245 "Distance for intra-area routes\n"
6246 "External routes\n"
6247 "Distance for external routes\n"
6248 "Inter-area routes\n"
6249 "Distance for inter-area routes\n")
6250{
paul68980082003-03-25 05:07:42 +00006251 struct ospf *ospf = vty->index;
6252
6253 ospf->distance_intra = atoi (argv[0]);
6254 ospf->distance_external = atoi (argv[1]);
6255 ospf->distance_inter = atoi (argv[2]);
6256
paul718e3742002-12-13 20:15:29 +00006257 return CMD_SUCCESS;
6258}
6259
6260DEFUN (ospf_distance_ospf_inter,
6261 ospf_distance_ospf_inter_cmd,
6262 "distance ospf inter-area <1-255>",
6263 "Define an administrative distance\n"
6264 "OSPF Administrative distance\n"
6265 "Inter-area routes\n"
6266 "Distance for inter-area routes\n")
6267{
paul68980082003-03-25 05:07:42 +00006268 struct ospf *ospf = vty->index;
6269
6270 ospf->distance_inter = atoi (argv[0]);
6271
paul718e3742002-12-13 20:15:29 +00006272 return CMD_SUCCESS;
6273}
6274
6275DEFUN (ospf_distance_ospf_inter_intra,
6276 ospf_distance_ospf_inter_intra_cmd,
6277 "distance ospf inter-area <1-255> intra-area <1-255>",
6278 "Define an administrative distance\n"
6279 "OSPF Administrative distance\n"
6280 "Inter-area routes\n"
6281 "Distance for inter-area routes\n"
6282 "Intra-area routes\n"
6283 "Distance for intra-area routes\n")
6284{
paul68980082003-03-25 05:07:42 +00006285 struct ospf *ospf = vty->index;
6286
6287 ospf->distance_inter = atoi (argv[0]);
6288 ospf->distance_intra = atoi (argv[1]);
6289
paul718e3742002-12-13 20:15:29 +00006290 return CMD_SUCCESS;
6291}
6292
6293DEFUN (ospf_distance_ospf_inter_external,
6294 ospf_distance_ospf_inter_external_cmd,
6295 "distance ospf inter-area <1-255> external <1-255>",
6296 "Define an administrative distance\n"
6297 "OSPF Administrative distance\n"
6298 "Inter-area routes\n"
6299 "Distance for inter-area routes\n"
6300 "External routes\n"
6301 "Distance for external routes\n")
6302{
paul68980082003-03-25 05:07:42 +00006303 struct ospf *ospf = vty->index;
6304
6305 ospf->distance_inter = atoi (argv[0]);
6306 ospf->distance_external = atoi (argv[1]);
6307
paul718e3742002-12-13 20:15:29 +00006308 return CMD_SUCCESS;
6309}
6310
6311DEFUN (ospf_distance_ospf_inter_intra_external,
6312 ospf_distance_ospf_inter_intra_external_cmd,
6313 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6314 "Define an administrative distance\n"
6315 "OSPF Administrative distance\n"
6316 "Inter-area routes\n"
6317 "Distance for inter-area routes\n"
6318 "Intra-area routes\n"
6319 "Distance for intra-area routes\n"
6320 "External routes\n"
6321 "Distance for external routes\n")
6322{
paul68980082003-03-25 05:07:42 +00006323 struct ospf *ospf = vty->index;
6324
6325 ospf->distance_inter = atoi (argv[0]);
6326 ospf->distance_intra = atoi (argv[1]);
6327 ospf->distance_external = atoi (argv[2]);
6328
paul718e3742002-12-13 20:15:29 +00006329 return CMD_SUCCESS;
6330}
6331
6332DEFUN (ospf_distance_ospf_inter_external_intra,
6333 ospf_distance_ospf_inter_external_intra_cmd,
6334 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6335 "Define an administrative distance\n"
6336 "OSPF Administrative distance\n"
6337 "Inter-area routes\n"
6338 "Distance for inter-area routes\n"
6339 "External routes\n"
6340 "Distance for external routes\n"
6341 "Intra-area routes\n"
6342 "Distance for intra-area routes\n")
6343{
paul68980082003-03-25 05:07:42 +00006344 struct ospf *ospf = vty->index;
6345
6346 ospf->distance_inter = atoi (argv[0]);
6347 ospf->distance_external = atoi (argv[1]);
6348 ospf->distance_intra = atoi (argv[2]);
6349
paul718e3742002-12-13 20:15:29 +00006350 return CMD_SUCCESS;
6351}
6352
6353DEFUN (ospf_distance_ospf_external,
6354 ospf_distance_ospf_external_cmd,
6355 "distance ospf external <1-255>",
6356 "Define an administrative distance\n"
6357 "OSPF Administrative distance\n"
6358 "External routes\n"
6359 "Distance for external routes\n")
6360{
paul68980082003-03-25 05:07:42 +00006361 struct ospf *ospf = vty->index;
6362
6363 ospf->distance_external = atoi (argv[0]);
6364
paul718e3742002-12-13 20:15:29 +00006365 return CMD_SUCCESS;
6366}
6367
6368DEFUN (ospf_distance_ospf_external_intra,
6369 ospf_distance_ospf_external_intra_cmd,
6370 "distance ospf external <1-255> intra-area <1-255>",
6371 "Define an administrative distance\n"
6372 "OSPF Administrative distance\n"
6373 "External routes\n"
6374 "Distance for external routes\n"
6375 "Intra-area routes\n"
6376 "Distance for intra-area routes\n")
6377{
paul68980082003-03-25 05:07:42 +00006378 struct ospf *ospf = vty->index;
6379
6380 ospf->distance_external = atoi (argv[0]);
6381 ospf->distance_intra = atoi (argv[1]);
6382
paul718e3742002-12-13 20:15:29 +00006383 return CMD_SUCCESS;
6384}
6385
6386DEFUN (ospf_distance_ospf_external_inter,
6387 ospf_distance_ospf_external_inter_cmd,
6388 "distance ospf external <1-255> inter-area <1-255>",
6389 "Define an administrative distance\n"
6390 "OSPF Administrative distance\n"
6391 "External routes\n"
6392 "Distance for external routes\n"
6393 "Inter-area routes\n"
6394 "Distance for inter-area routes\n")
6395{
paul68980082003-03-25 05:07:42 +00006396 struct ospf *ospf = vty->index;
6397
6398 ospf->distance_external = atoi (argv[0]);
6399 ospf->distance_inter = atoi (argv[1]);
6400
paul718e3742002-12-13 20:15:29 +00006401 return CMD_SUCCESS;
6402}
6403
6404DEFUN (ospf_distance_ospf_external_intra_inter,
6405 ospf_distance_ospf_external_intra_inter_cmd,
6406 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6407 "Define an administrative distance\n"
6408 "OSPF Administrative distance\n"
6409 "External routes\n"
6410 "Distance for external routes\n"
6411 "Intra-area routes\n"
6412 "Distance for intra-area routes\n"
6413 "Inter-area routes\n"
6414 "Distance for inter-area routes\n")
6415{
paul68980082003-03-25 05:07:42 +00006416 struct ospf *ospf = vty->index;
6417
6418 ospf->distance_external = atoi (argv[0]);
6419 ospf->distance_intra = atoi (argv[1]);
6420 ospf->distance_inter = atoi (argv[2]);
6421
paul718e3742002-12-13 20:15:29 +00006422 return CMD_SUCCESS;
6423}
6424
6425DEFUN (ospf_distance_ospf_external_inter_intra,
6426 ospf_distance_ospf_external_inter_intra_cmd,
6427 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6428 "Define an administrative distance\n"
6429 "OSPF Administrative distance\n"
6430 "External routes\n"
6431 "Distance for external routes\n"
6432 "Inter-area routes\n"
6433 "Distance for inter-area routes\n"
6434 "Intra-area routes\n"
6435 "Distance for intra-area routes\n")
6436{
paul68980082003-03-25 05:07:42 +00006437 struct ospf *ospf = vty->index;
6438
6439 ospf->distance_external = atoi (argv[0]);
6440 ospf->distance_inter = atoi (argv[1]);
6441 ospf->distance_intra = atoi (argv[2]);
6442
paul718e3742002-12-13 20:15:29 +00006443 return CMD_SUCCESS;
6444}
6445
6446DEFUN (ospf_distance_source,
6447 ospf_distance_source_cmd,
6448 "distance <1-255> A.B.C.D/M",
6449 "Administrative distance\n"
6450 "Distance value\n"
6451 "IP source prefix\n")
6452{
paul020709f2003-04-04 02:44:16 +00006453 struct ospf *ospf = vty->index;
6454
6455 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006456
paul718e3742002-12-13 20:15:29 +00006457 return CMD_SUCCESS;
6458}
6459
6460DEFUN (no_ospf_distance_source,
6461 no_ospf_distance_source_cmd,
6462 "no distance <1-255> A.B.C.D/M",
6463 NO_STR
6464 "Administrative distance\n"
6465 "Distance value\n"
6466 "IP source prefix\n")
6467{
paul020709f2003-04-04 02:44:16 +00006468 struct ospf *ospf = vty->index;
6469
6470 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6471
paul718e3742002-12-13 20:15:29 +00006472 return CMD_SUCCESS;
6473}
6474
6475DEFUN (ospf_distance_source_access_list,
6476 ospf_distance_source_access_list_cmd,
6477 "distance <1-255> A.B.C.D/M WORD",
6478 "Administrative distance\n"
6479 "Distance value\n"
6480 "IP source prefix\n"
6481 "Access list name\n")
6482{
paul020709f2003-04-04 02:44:16 +00006483 struct ospf *ospf = vty->index;
6484
6485 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6486
paul718e3742002-12-13 20:15:29 +00006487 return CMD_SUCCESS;
6488}
6489
6490DEFUN (no_ospf_distance_source_access_list,
6491 no_ospf_distance_source_access_list_cmd,
6492 "no distance <1-255> A.B.C.D/M WORD",
6493 NO_STR
6494 "Administrative distance\n"
6495 "Distance value\n"
6496 "IP source prefix\n"
6497 "Access list name\n")
6498{
paul020709f2003-04-04 02:44:16 +00006499 struct ospf *ospf = vty->index;
6500
6501 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6502
paul718e3742002-12-13 20:15:29 +00006503 return CMD_SUCCESS;
6504}
6505
6506void
6507show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6508{
6509 struct route_node *rn;
6510 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006511 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006512 struct ospf_path *path;
6513
6514 vty_out (vty, "============ OSPF network routing table ============%s",
6515 VTY_NEWLINE);
6516
6517 for (rn = route_top (rt); rn; rn = route_next (rn))
6518 if ((or = rn->info) != NULL)
6519 {
6520 char buf1[19];
6521 snprintf (buf1, 19, "%s/%d",
6522 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6523
6524 switch (or->path_type)
6525 {
6526 case OSPF_PATH_INTER_AREA:
6527 if (or->type == OSPF_DESTINATION_NETWORK)
6528 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6529 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6530 else if (or->type == OSPF_DESTINATION_DISCARD)
6531 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6532 break;
6533 case OSPF_PATH_INTRA_AREA:
6534 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6535 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6536 break;
6537 default:
6538 break;
6539 }
6540
6541 if (or->type == OSPF_DESTINATION_NETWORK)
paul96735ee2003-08-10 02:51:22 +00006542 LIST_LOOP (or->paths, path, pnode)
6543 {
6544 if (path->oi != NULL)
6545 {
6546 if (path->nexthop.s_addr == 0)
6547 vty_out (vty, "%24s directly attached to %s%s",
6548 "", path->oi->ifp->name, VTY_NEWLINE);
6549 else
6550 vty_out (vty, "%24s via %s, %s%s", "",
6551 inet_ntoa (path->nexthop), path->oi->ifp->name,
6552 VTY_NEWLINE);
6553 }
6554 }
paul718e3742002-12-13 20:15:29 +00006555 }
6556 vty_out (vty, "%s", VTY_NEWLINE);
6557}
6558
6559void
6560show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6561{
6562 struct route_node *rn;
6563 struct ospf_route *or;
hasso52dc7ee2004-09-23 19:18:23 +00006564 struct listnode *pn, *nn;
paul718e3742002-12-13 20:15:29 +00006565 struct ospf_path *path;
6566
6567 vty_out (vty, "============ OSPF router routing table =============%s",
6568 VTY_NEWLINE);
6569 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6570 if (rn->info)
6571 {
6572 int flag = 0;
6573
6574 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6575
hasso52dc7ee2004-09-23 19:18:23 +00006576 for (nn = listhead ((struct list *) rn->info); nn; nextnode (nn))
paul718e3742002-12-13 20:15:29 +00006577 if ((or = getdata (nn)) != NULL)
6578 {
6579 if (flag++)
paulb0a053b2003-06-22 09:04:47 +00006580 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006581
6582 /* Show path. */
6583 vty_out (vty, "%s [%d] area: %s",
6584 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6585 or->cost, inet_ntoa (or->u.std.area_id));
6586 /* Show flags. */
6587 vty_out (vty, "%s%s%s",
6588 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6589 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6590 VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006591
6592 LIST_LOOP (or->paths, path, pn)
6593 {
6594 if (path->nexthop.s_addr == 0)
6595 vty_out (vty, "%24s directly attached to %s%s",
6596 "", path->oi->ifp->name, VTY_NEWLINE);
6597 else
6598 vty_out (vty, "%24s via %s, %s%s", "",
6599 inet_ntoa (path->nexthop), path->oi->ifp->name,
6600 VTY_NEWLINE);
6601 }
paul718e3742002-12-13 20:15:29 +00006602 }
6603 }
6604 vty_out (vty, "%s", VTY_NEWLINE);
6605}
6606
6607void
6608show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6609{
6610 struct route_node *rn;
6611 struct ospf_route *er;
hasso52dc7ee2004-09-23 19:18:23 +00006612 struct listnode *pnode;
paul718e3742002-12-13 20:15:29 +00006613 struct ospf_path *path;
6614
6615 vty_out (vty, "============ OSPF external routing table ===========%s",
6616 VTY_NEWLINE);
6617 for (rn = route_top (rt); rn; rn = route_next (rn))
6618 if ((er = rn->info) != NULL)
6619 {
6620 char buf1[19];
6621 snprintf (buf1, 19, "%s/%d",
6622 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6623
6624 switch (er->path_type)
6625 {
6626 case OSPF_PATH_TYPE1_EXTERNAL:
6627 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6628 er->cost, er->u.ext.tag, VTY_NEWLINE);
6629 break;
6630 case OSPF_PATH_TYPE2_EXTERNAL:
6631 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6632 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6633 break;
6634 }
6635
paul96735ee2003-08-10 02:51:22 +00006636 LIST_LOOP (er->paths, path, pnode)
paul718e3742002-12-13 20:15:29 +00006637 {
paul718e3742002-12-13 20:15:29 +00006638 if (path->oi != NULL)
6639 {
6640 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006641 vty_out (vty, "%24s directly attached to %s%s",
6642 "", path->oi->ifp->name, VTY_NEWLINE);
6643 else
6644 vty_out (vty, "%24s via %s, %s%s", "",
6645 inet_ntoa (path->nexthop), path->oi->ifp->name,
6646 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006647 }
6648 }
6649 }
6650 vty_out (vty, "%s", VTY_NEWLINE);
6651}
6652
paul718e3742002-12-13 20:15:29 +00006653DEFUN (show_ip_ospf_border_routers,
6654 show_ip_ospf_border_routers_cmd,
6655 "show ip ospf border-routers",
6656 SHOW_STR
6657 IP_STR
6658 "show all the ABR's and ASBR's\n"
6659 "for this area\n")
6660{
paul020709f2003-04-04 02:44:16 +00006661 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006662
paul020709f2003-04-04 02:44:16 +00006663 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006664 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006665 {
6666 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6667 return CMD_SUCCESS;
6668 }
6669
paul68980082003-03-25 05:07:42 +00006670 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006671 {
6672 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6673 return CMD_SUCCESS;
6674 }
6675
6676 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006677 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006678
6679 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006680 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006681
6682 return CMD_SUCCESS;
6683}
paul718e3742002-12-13 20:15:29 +00006684
6685DEFUN (show_ip_ospf_route,
6686 show_ip_ospf_route_cmd,
6687 "show ip ospf route",
6688 SHOW_STR
6689 IP_STR
6690 "OSPF information\n"
6691 "OSPF routing table\n")
6692{
paul020709f2003-04-04 02:44:16 +00006693 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006694
paul020709f2003-04-04 02:44:16 +00006695 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00006696 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00006697 {
6698 vty_out (vty, "OSPF is not enabled%s", VTY_NEWLINE);
6699 return CMD_SUCCESS;
6700 }
6701
paul68980082003-03-25 05:07:42 +00006702 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006703 {
6704 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6705 return CMD_SUCCESS;
6706 }
6707
6708 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006709 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006710
6711 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006712 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006713
6714 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006715 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006716
6717 return CMD_SUCCESS;
6718}
6719
6720
hassoeb1ce602004-10-08 08:17:22 +00006721const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006722{
6723 "unknown",
6724 "standard",
6725 "ibm",
6726 "cisco",
6727 "shortcut"
6728};
6729
hassoeb1ce602004-10-08 08:17:22 +00006730const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006731{
6732 "default",
6733 "enable",
6734 "disable"
6735};
6736
6737
6738void
6739area_id2str (char *buf, int length, struct ospf_area *area)
6740{
6741 memset (buf, 0, length);
6742
6743 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6744 strncpy (buf, inet_ntoa (area->area_id), length);
6745 else
6746 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6747}
6748
6749
hassoeb1ce602004-10-08 08:17:22 +00006750const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006751{
6752 "unknown", /* should never be used. */
6753 "point-to-point",
6754 "broadcast",
6755 "non-broadcast",
6756 "point-to-multipoint",
6757 "virtual-link", /* should never be used. */
6758 "loopback"
6759};
6760
6761/* Configuration write function for ospfd. */
6762int
6763config_write_interface (struct vty *vty)
6764{
hasso52dc7ee2004-09-23 19:18:23 +00006765 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006766 struct interface *ifp;
6767 struct crypt_key *ck;
6768 int write = 0;
6769 struct route_node *rn = NULL;
6770 struct ospf_if_params *params;
6771
6772 for (n1 = listhead (iflist); n1; nextnode (n1))
6773 {
6774 ifp = getdata (n1);
6775
6776 if (memcmp (ifp->name, "VLINK", 5) == 0)
6777 continue;
6778
6779 vty_out (vty, "!%s", VTY_NEWLINE);
6780 vty_out (vty, "interface %s%s", ifp->name,
6781 VTY_NEWLINE);
6782 if (ifp->desc)
6783 vty_out (vty, " description %s%s", ifp->desc,
6784 VTY_NEWLINE);
6785
6786 write++;
6787
6788 params = IF_DEF_PARAMS (ifp);
6789
6790 do {
6791 /* Interface Network print. */
6792 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006793 params->type != OSPF_IFTYPE_LOOPBACK)
6794 {
ajsbc18d612004-12-15 15:07:19 +00006795 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006796 {
6797 vty_out (vty, " ip ospf network %s",
6798 ospf_int_type_str[params->type]);
6799 if (params != IF_DEF_PARAMS (ifp))
6800 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6801 vty_out (vty, "%s", VTY_NEWLINE);
6802 }
paul718e3742002-12-13 20:15:29 +00006803 }
6804
6805 /* OSPF interface authentication print */
6806 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6807 params->auth_type != OSPF_AUTH_NOTSET)
6808 {
hassoeb1ce602004-10-08 08:17:22 +00006809 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006810
6811 /* Translation tables are not that much help here due to syntax
6812 of the simple option */
6813 switch (params->auth_type)
6814 {
6815
6816 case OSPF_AUTH_NULL:
6817 auth_str = " null";
6818 break;
6819
6820 case OSPF_AUTH_SIMPLE:
6821 auth_str = "";
6822 break;
6823
6824 case OSPF_AUTH_CRYPTOGRAPHIC:
6825 auth_str = " message-digest";
6826 break;
6827
6828 default:
6829 auth_str = "";
6830 break;
6831 }
6832
6833 vty_out (vty, " ip ospf authentication%s", auth_str);
6834 if (params != IF_DEF_PARAMS (ifp))
6835 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6836 vty_out (vty, "%s", VTY_NEWLINE);
6837 }
6838
6839 /* Simple Authentication Password print. */
6840 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6841 params->auth_simple[0] != '\0')
6842 {
6843 vty_out (vty, " ip ospf authentication-key %s",
6844 params->auth_simple);
6845 if (params != IF_DEF_PARAMS (ifp))
6846 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6847 vty_out (vty, "%s", VTY_NEWLINE);
6848 }
6849
6850 /* Cryptographic Authentication Key print. */
6851 for (n2 = listhead (params->auth_crypt); n2; nextnode (n2))
6852 {
6853 ck = getdata (n2);
6854 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6855 ck->key_id, ck->auth_key);
6856 if (params != IF_DEF_PARAMS (ifp))
6857 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6858 vty_out (vty, "%s", VTY_NEWLINE);
6859 }
6860
6861 /* Interface Output Cost print. */
6862 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6863 {
6864 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6865 if (params != IF_DEF_PARAMS (ifp))
6866 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6867 vty_out (vty, "%s", VTY_NEWLINE);
6868 }
6869
6870 /* Hello Interval print. */
6871 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6872 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6873 {
6874 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6875 if (params != IF_DEF_PARAMS (ifp))
6876 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6877 vty_out (vty, "%s", VTY_NEWLINE);
6878 }
6879
6880
6881 /* Router Dead Interval print. */
6882 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6883 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6884 {
6885 vty_out (vty, " ip ospf dead-interval %u", params->v_wait);
6886 if (params != IF_DEF_PARAMS (ifp))
6887 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6888 vty_out (vty, "%s", VTY_NEWLINE);
6889 }
6890
6891 /* Router Priority print. */
6892 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6893 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6894 {
6895 vty_out (vty, " ip ospf priority %u", params->priority);
6896 if (params != IF_DEF_PARAMS (ifp))
6897 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6898 vty_out (vty, "%s", VTY_NEWLINE);
6899 }
6900
6901 /* Retransmit Interval print. */
6902 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6903 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6904 {
6905 vty_out (vty, " ip ospf retransmit-interval %u",
6906 params->retransmit_interval);
6907 if (params != IF_DEF_PARAMS (ifp))
6908 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6909 vty_out (vty, "%s", VTY_NEWLINE);
6910 }
6911
6912 /* Transmit Delay print. */
6913 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6914 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6915 {
6916 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6917 if (params != IF_DEF_PARAMS (ifp))
6918 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6919 vty_out (vty, "%s", VTY_NEWLINE);
6920 }
6921
6922 while (1)
6923 {
6924 if (rn == NULL)
6925 rn = route_top (IF_OIFS_PARAMS (ifp));
6926 else
6927 rn = route_next (rn);
6928
6929 if (rn == NULL)
6930 break;
6931 params = rn->info;
6932 if (params != NULL)
6933 break;
6934 }
6935 } while (rn);
6936
6937#ifdef HAVE_OPAQUE_LSA
6938 ospf_opaque_config_write_if (vty, ifp);
6939#endif /* HAVE_OPAQUE_LSA */
6940 }
6941
6942 return write;
6943}
6944
6945int
paul68980082003-03-25 05:07:42 +00006946config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006947{
6948 struct route_node *rn;
6949 u_char buf[INET_ADDRSTRLEN];
6950
6951 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00006952 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00006953 if (rn->info)
6954 {
6955 struct ospf_network *n = rn->info;
6956
6957 memset (buf, 0, INET_ADDRSTRLEN);
6958
6959 /* Create Area ID string by specified Area ID format. */
6960 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00006961 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00006962 else
hassoc9e52be2004-09-26 16:09:34 +00006963 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00006964 (unsigned long int) ntohl (n->area_id.s_addr));
6965
6966 /* Network print. */
6967 vty_out (vty, " network %s/%d area %s%s",
6968 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
6969 buf, VTY_NEWLINE);
6970 }
6971
6972 return 0;
6973}
6974
6975int
paul68980082003-03-25 05:07:42 +00006976config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00006977{
hasso52dc7ee2004-09-23 19:18:23 +00006978 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006979 u_char buf[INET_ADDRSTRLEN];
6980
6981 /* Area configuration print. */
paul68980082003-03-25 05:07:42 +00006982 for (node = listhead (ospf->areas); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00006983 {
6984 struct ospf_area *area = getdata (node);
6985 struct route_node *rn1;
6986
hassoc9e52be2004-09-26 16:09:34 +00006987 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00006988
6989 if (area->auth_type != OSPF_AUTH_NULL)
6990 {
6991 if (area->auth_type == OSPF_AUTH_SIMPLE)
6992 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
6993 else
6994 vty_out (vty, " area %s authentication message-digest%s",
6995 buf, VTY_NEWLINE);
6996 }
6997
6998 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
6999 vty_out (vty, " area %s shortcut %s%s", buf,
7000 ospf_shortcut_mode_str[area->shortcut_configured],
7001 VTY_NEWLINE);
7002
7003 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007004 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007005 )
7006 {
paulb0a053b2003-06-22 09:04:47 +00007007 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007008 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007009 else if (area->external_routing == OSPF_AREA_NSSA)
7010 {
7011 vty_out (vty, " area %s nssa", buf);
7012 switch (area->NSSATranslatorRole)
7013 {
7014 case OSPF_NSSA_ROLE_NEVER:
7015 vty_out (vty, " translate-never");
7016 break;
7017 case OSPF_NSSA_ROLE_ALWAYS:
7018 vty_out (vty, " translate-always");
7019 break;
7020 case OSPF_NSSA_ROLE_CANDIDATE:
7021 default:
7022 vty_out (vty, " translate-candidate");
7023 }
7024 }
paul718e3742002-12-13 20:15:29 +00007025
7026 if (area->no_summary)
7027 vty_out (vty, " no-summary");
7028
7029 vty_out (vty, "%s", VTY_NEWLINE);
7030
7031 if (area->default_cost != 1)
7032 vty_out (vty, " area %s default-cost %d%s", buf,
7033 area->default_cost, VTY_NEWLINE);
7034 }
7035
7036 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7037 if (rn1->info)
7038 {
7039 struct ospf_area_range *range = rn1->info;
7040
7041 vty_out (vty, " area %s range %s/%d", buf,
7042 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7043
paul6c835672004-10-11 11:00:30 +00007044 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007045 vty_out (vty, " cost %d", range->cost_config);
7046
7047 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7048 vty_out (vty, " not-advertise");
7049
7050 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7051 vty_out (vty, " substitute %s/%d",
7052 inet_ntoa (range->subst_addr), range->subst_masklen);
7053
7054 vty_out (vty, "%s", VTY_NEWLINE);
7055 }
7056
7057 if (EXPORT_NAME (area))
7058 vty_out (vty, " area %s export-list %s%s", buf,
7059 EXPORT_NAME (area), VTY_NEWLINE);
7060
7061 if (IMPORT_NAME (area))
7062 vty_out (vty, " area %s import-list %s%s", buf,
7063 IMPORT_NAME (area), VTY_NEWLINE);
7064
7065 if (PREFIX_NAME_IN (area))
7066 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7067 PREFIX_NAME_IN (area), VTY_NEWLINE);
7068
7069 if (PREFIX_NAME_OUT (area))
7070 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7071 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7072 }
7073
7074 return 0;
7075}
7076
7077int
paul68980082003-03-25 05:07:42 +00007078config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007079{
7080 struct ospf_nbr_nbma *nbr_nbma;
7081 struct route_node *rn;
7082
7083 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007084 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007085 if ((nbr_nbma = rn->info))
7086 {
7087 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7088
7089 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7090 vty_out (vty, " priority %d", nbr_nbma->priority);
7091
7092 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7093 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7094
7095 vty_out (vty, "%s", VTY_NEWLINE);
7096 }
7097
7098 return 0;
7099}
7100
7101int
paul68980082003-03-25 05:07:42 +00007102config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007103{
hasso52dc7ee2004-09-23 19:18:23 +00007104 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007105 u_char buf[INET_ADDRSTRLEN];
7106
7107 /* Virtual-Link print */
paul68980082003-03-25 05:07:42 +00007108 for (node = listhead (ospf->vlinks); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007109 {
hasso52dc7ee2004-09-23 19:18:23 +00007110 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007111 struct crypt_key *ck;
7112 struct ospf_vl_data *vl_data = getdata (node);
7113 struct ospf_interface *oi;
7114
7115 if (vl_data != NULL)
7116 {
7117 memset (buf, 0, INET_ADDRSTRLEN);
7118
7119 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007120 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007121 else
hassoc9e52be2004-09-26 16:09:34 +00007122 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007123 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7124 oi = vl_data->vl_oi;
7125
7126 /* timers */
7127 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7128 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7129 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7130 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7131 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7132 buf,
7133 inet_ntoa (vl_data->vl_peer),
7134 OSPF_IF_PARAM (oi, v_hello),
7135 OSPF_IF_PARAM (oi, retransmit_interval),
7136 OSPF_IF_PARAM (oi, transmit_delay),
7137 OSPF_IF_PARAM (oi, v_wait),
7138 VTY_NEWLINE);
7139 else
7140 vty_out (vty, " area %s virtual-link %s%s", buf,
7141 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7142 /* Auth key */
7143 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7144 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7145 buf,
7146 inet_ntoa (vl_data->vl_peer),
7147 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7148 VTY_NEWLINE);
7149 /* md5 keys */
7150 for (n2 = listhead (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt); n2; nextnode (n2))
7151 {
7152 ck = getdata (n2);
7153 vty_out (vty, " area %s virtual-link %s message-digest-key %d md5 %s%s",
7154 buf,
7155 inet_ntoa (vl_data->vl_peer),
7156 ck->key_id, ck->auth_key, VTY_NEWLINE);
7157 }
7158
7159 }
7160 }
7161
7162 return 0;
7163}
7164
7165
hassoeb1ce602004-10-08 08:17:22 +00007166const char *distribute_str[] = { "system", "kernel", "connected", "static",
7167 "rip", "ripng", "ospf", "ospf6", "isis", "bgp"};
paul718e3742002-12-13 20:15:29 +00007168int
paul68980082003-03-25 05:07:42 +00007169config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007170{
7171 int type;
7172
7173 /* redistribute print. */
7174 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7175 if (type != zclient->redist_default && zclient->redist[type])
7176 {
7177 vty_out (vty, " redistribute %s", distribute_str[type]);
paul68980082003-03-25 05:07:42 +00007178 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007179 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007180
paul68980082003-03-25 05:07:42 +00007181 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007182 vty_out (vty, " metric-type 1");
7183
paul020709f2003-04-04 02:44:16 +00007184 if (ROUTEMAP_NAME (ospf, type))
7185 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007186
7187 vty_out (vty, "%s", VTY_NEWLINE);
7188 }
7189
7190 return 0;
7191}
7192
7193int
paul68980082003-03-25 05:07:42 +00007194config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007195{
paul68980082003-03-25 05:07:42 +00007196 if (ospf->default_metric != -1)
7197 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007198 VTY_NEWLINE);
7199 return 0;
7200}
7201
7202int
paul68980082003-03-25 05:07:42 +00007203config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007204{
7205 int type;
7206
paul68980082003-03-25 05:07:42 +00007207 if (ospf)
paul718e3742002-12-13 20:15:29 +00007208 {
7209 /* distribute-list print. */
7210 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
paul68980082003-03-25 05:07:42 +00007211 if (ospf->dlist[type].name)
paul718e3742002-12-13 20:15:29 +00007212 vty_out (vty, " distribute-list %s out %s%s",
paul68980082003-03-25 05:07:42 +00007213 ospf->dlist[type].name,
paul718e3742002-12-13 20:15:29 +00007214 distribute_str[type], VTY_NEWLINE);
7215
7216 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007217 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007218 {
paul68980082003-03-25 05:07:42 +00007219 if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
paul718e3742002-12-13 20:15:29 +00007220 vty_out (vty, " default-information originate");
7221 else
7222 vty_out (vty, " default-information originate always");
7223
paul68980082003-03-25 05:07:42 +00007224 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007225 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007226 ospf->dmetric[DEFAULT_ROUTE].value);
7227 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007228 vty_out (vty, " metric-type 1");
7229
paul020709f2003-04-04 02:44:16 +00007230 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7231 vty_out (vty, " route-map %s",
7232 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007233
7234 vty_out (vty, "%s", VTY_NEWLINE);
7235 }
7236
7237 }
7238
7239 return 0;
7240}
7241
7242int
paul68980082003-03-25 05:07:42 +00007243config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007244{
7245 struct route_node *rn;
7246 struct ospf_distance *odistance;
7247
paul68980082003-03-25 05:07:42 +00007248 if (ospf->distance_all)
7249 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007250
paul68980082003-03-25 05:07:42 +00007251 if (ospf->distance_intra
7252 || ospf->distance_inter
7253 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007254 {
7255 vty_out (vty, " distance ospf");
7256
paul68980082003-03-25 05:07:42 +00007257 if (ospf->distance_intra)
7258 vty_out (vty, " intra-area %d", ospf->distance_intra);
7259 if (ospf->distance_inter)
7260 vty_out (vty, " inter-area %d", ospf->distance_inter);
7261 if (ospf->distance_external)
7262 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007263
7264 vty_out (vty, "%s", VTY_NEWLINE);
7265 }
7266
paul68980082003-03-25 05:07:42 +00007267 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007268 if ((odistance = rn->info) != NULL)
7269 {
7270 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7271 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7272 odistance->access_list ? odistance->access_list : "",
7273 VTY_NEWLINE);
7274 }
7275 return 0;
7276}
7277
7278/* OSPF configuration write function. */
7279int
7280ospf_config_write (struct vty *vty)
7281{
paul020709f2003-04-04 02:44:16 +00007282 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00007283 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007284 int write = 0;
7285
paul020709f2003-04-04 02:44:16 +00007286 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007287 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007288 {
7289 /* `router ospf' print. */
7290 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7291
7292 write++;
7293
paul68980082003-03-25 05:07:42 +00007294 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007295 return write;
7296
7297 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007298 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007299 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007300 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007301
7302 /* ABR type print. */
paul68980082003-03-25 05:07:42 +00007303 if (ospf->abr_type != OSPF_ABR_STAND)
paul718e3742002-12-13 20:15:29 +00007304 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007305 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007306
7307 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007308 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007309 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7310
7311 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007312 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00007313 vty_out (vty, " auto-cost reference-bandwidth %d%s",
paul68980082003-03-25 05:07:42 +00007314 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007315
7316 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007317 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
7318 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007319 vty_out (vty, " timers spf %d %d%s",
paul68980082003-03-25 05:07:42 +00007320 ospf->spf_delay, ospf->spf_holdtime, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007321
7322 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007323 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007324 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007325 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007326
7327 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007328 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007329
7330 /* passive-interface print. */
paul020709f2003-04-04 02:44:16 +00007331 for (node = listhead (om->iflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007332 {
7333 struct interface *ifp = getdata (node);
7334
7335 if (!ifp)
7336 continue;
7337 if (IF_DEF_PARAMS (ifp)->passive_interface == OSPF_IF_PASSIVE)
7338 vty_out (vty, " passive-interface %s%s",
7339 ifp->name, VTY_NEWLINE);
7340 }
7341
paul68980082003-03-25 05:07:42 +00007342 for (node = listhead (ospf->oiflist); node; nextnode (node))
paul718e3742002-12-13 20:15:29 +00007343 {
7344 struct ospf_interface *oi = getdata (node);
7345
7346 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface) &&
7347 oi->params->passive_interface == OSPF_IF_PASSIVE)
paul96735ee2003-08-10 02:51:22 +00007348 vty_out (vty, " passive-interface %s %s%s",
7349 oi->ifp->name,
paul5fdc1e52003-08-06 22:41:29 +00007350 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007351 }
7352
7353
7354 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007355 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007356
7357 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007358 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007359
7360 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007361 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007362
7363 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007364 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007365
7366 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007367 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007368
7369 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007370 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007371
7372 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007373 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007374
7375#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007376 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007377#endif /* HAVE_OPAQUE_LSA */
7378 }
7379
7380 return write;
7381}
7382
7383void
7384ospf_vty_show_init ()
7385{
7386 /* "show ip ospf" commands. */
7387 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7388 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7389
7390 /* "show ip ospf database" commands. */
7391 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7392 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7393 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7394 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7395 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7396 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7397 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7398 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7399 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7400 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7401 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7402 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7403 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7404 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7405
7406 /* "show ip ospf interface" commands. */
7407 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7408 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7409
7410 /* "show ip ospf neighbor" commands. */
7411 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7412 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7413 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7414 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7415 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7416 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7417 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7418 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7419 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7420 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7421 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7422 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7423 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7424 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7425
7426 /* "show ip ospf route" commands. */
7427 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7428 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007429 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7430 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007431}
7432
7433
7434/* ospfd's interface node. */
7435struct cmd_node interface_node =
7436{
7437 INTERFACE_NODE,
7438 "%s(config-if)# ",
7439 1
7440};
7441
7442/* Initialization of OSPF interface. */
7443void
7444ospf_vty_if_init ()
7445{
7446 /* Install interface node. */
7447 install_node (&interface_node, config_write_interface);
7448
7449 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007450 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007451 install_default (INTERFACE_NODE);
7452
7453 /* "description" commands. */
7454 install_element (INTERFACE_NODE, &interface_desc_cmd);
7455 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7456
7457 /* "ip ospf authentication" commands. */
7458 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7459 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7460 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7461 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7462 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7463 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7464 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7465 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7466 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7467 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7468
7469 /* "ip ospf message-digest-key" commands. */
7470 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7471 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7472 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7473 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7474
7475 /* "ip ospf cost" commands. */
7476 install_element (INTERFACE_NODE, &ip_ospf_cost_addr_cmd);
7477 install_element (INTERFACE_NODE, &ip_ospf_cost_cmd);
7478 install_element (INTERFACE_NODE, &no_ip_ospf_cost_addr_cmd);
7479 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7480
7481 /* "ip ospf dead-interval" commands. */
7482 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7483 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
7484 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7485 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
7486
7487 /* "ip ospf hello-interval" commands. */
7488 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7489 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7490 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7491 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7492
7493 /* "ip ospf network" commands. */
7494 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7495 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7496
7497 /* "ip ospf priority" commands. */
7498 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7499 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7500 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7501 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7502
7503 /* "ip ospf retransmit-interval" commands. */
7504 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7505 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7506 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7507 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7508
7509 /* "ip ospf transmit-delay" commands. */
7510 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7511 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7512 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7513 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7514
7515 /* These commands are compatibitliy for previous version. */
7516 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7517 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7518 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7519 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
7520 install_element (INTERFACE_NODE, &ospf_cost_cmd);
7521 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
7522 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7523 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7524 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7525 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7526 install_element (INTERFACE_NODE, &ospf_network_cmd);
7527 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7528 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7529 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7530 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7531 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7532 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7533 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7534}
7535
7536/* Zebra node structure. */
7537struct cmd_node zebra_node =
7538{
7539 ZEBRA_NODE,
7540 "%s(config-router)#",
7541};
7542
7543void
7544ospf_vty_zebra_init ()
7545{
7546 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
7547 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
7548 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
7549 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
7550 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
7551 install_element (OSPF_NODE,
7552 &ospf_redistribute_source_metric_type_routemap_cmd);
7553 install_element (OSPF_NODE,
7554 &ospf_redistribute_source_type_metric_routemap_cmd);
7555 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
7556 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
7557 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
7558
7559 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7560
7561 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7562 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7563
7564 install_element (OSPF_NODE,
7565 &ospf_default_information_originate_metric_type_cmd);
7566 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
7567 install_element (OSPF_NODE,
7568 &ospf_default_information_originate_type_metric_cmd);
7569 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
7570 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
7571 install_element (OSPF_NODE,
7572 &ospf_default_information_originate_always_metric_type_cmd);
7573 install_element (OSPF_NODE,
7574 &ospf_default_information_originate_always_metric_cmd);
7575 install_element (OSPF_NODE,
7576 &ospf_default_information_originate_always_cmd);
7577 install_element (OSPF_NODE,
7578 &ospf_default_information_originate_always_type_metric_cmd);
7579 install_element (OSPF_NODE,
7580 &ospf_default_information_originate_always_type_cmd);
7581
7582 install_element (OSPF_NODE,
7583 &ospf_default_information_originate_metric_type_routemap_cmd);
7584 install_element (OSPF_NODE,
7585 &ospf_default_information_originate_metric_routemap_cmd);
7586 install_element (OSPF_NODE,
7587 &ospf_default_information_originate_routemap_cmd);
7588 install_element (OSPF_NODE,
7589 &ospf_default_information_originate_type_metric_routemap_cmd);
7590 install_element (OSPF_NODE,
7591 &ospf_default_information_originate_type_routemap_cmd);
7592 install_element (OSPF_NODE,
7593 &ospf_default_information_originate_always_metric_type_routemap_cmd);
7594 install_element (OSPF_NODE,
7595 &ospf_default_information_originate_always_metric_routemap_cmd);
7596 install_element (OSPF_NODE,
7597 &ospf_default_information_originate_always_routemap_cmd);
7598 install_element (OSPF_NODE,
7599 &ospf_default_information_originate_always_type_metric_routemap_cmd);
7600 install_element (OSPF_NODE,
7601 &ospf_default_information_originate_always_type_routemap_cmd);
7602
7603 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7604
7605 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7606 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7607 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7608
7609 install_element (OSPF_NODE, &ospf_distance_cmd);
7610 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7611 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
7612 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
7613 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
7614 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
7615 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
7616 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
7617 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
7618 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
7619 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
7620 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
7621 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
7622 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
7623 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
7624 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
7625 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
7626 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
7627#if 0
7628 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7629 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7630 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7631 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7632#endif /* 0 */
7633}
7634
7635struct cmd_node ospf_node =
7636{
7637 OSPF_NODE,
7638 "%s(config-router)# ",
7639 1
7640};
7641
7642
7643/* Install OSPF related vty commands. */
7644void
7645ospf_vty_init ()
7646{
7647 /* Install ospf top node. */
7648 install_node (&ospf_node, ospf_config_write);
7649
7650 /* "router ospf" commands. */
7651 install_element (CONFIG_NODE, &router_ospf_cmd);
7652 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7653
7654 install_default (OSPF_NODE);
7655
7656 /* "ospf router-id" commands. */
7657 install_element (OSPF_NODE, &ospf_router_id_cmd);
7658 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007659 install_element (OSPF_NODE, &router_ospf_id_cmd);
7660 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007661
7662 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007663 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7664 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7665 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7666 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007667
7668 /* "ospf abr-type" commands. */
7669 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7670 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7671
7672 /* "ospf rfc1583-compatible" commands. */
7673 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7674 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7675 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7676 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7677
7678 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007679 install_element (OSPF_NODE, &ospf_network_area_cmd);
7680 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007681
7682 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007683 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7684 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7685 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007686
7687 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007688 install_element (OSPF_NODE, &ospf_area_range_cmd);
7689 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7690 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7691 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7692 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7693 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7694 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7695 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7696 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7697 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7698 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007699
7700 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007701 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7702 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007703
paula2c62832003-04-23 17:01:31 +00007704 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7705 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007706
paula2c62832003-04-23 17:01:31 +00007707 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7708 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007709
paula2c62832003-04-23 17:01:31 +00007710 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7711 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007712
paula2c62832003-04-23 17:01:31 +00007713 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7714 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007715
paula2c62832003-04-23 17:01:31 +00007716 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7717 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7718 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007719
paula2c62832003-04-23 17:01:31 +00007720 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7721 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007722
paula2c62832003-04-23 17:01:31 +00007723 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7724 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007725
paula2c62832003-04-23 17:01:31 +00007726 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7727 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7728 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007729
paula2c62832003-04-23 17:01:31 +00007730 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7731 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7732 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007733
7734 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007735 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7736 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7737 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7738 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007739
paul718e3742002-12-13 20:15:29 +00007740 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007741 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7742 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7743 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7744 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7745 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7746 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007747
paula2c62832003-04-23 17:01:31 +00007748 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7749 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007750
paula2c62832003-04-23 17:01:31 +00007751 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7752 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007753
paula2c62832003-04-23 17:01:31 +00007754 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7755 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007756
paula2c62832003-04-23 17:01:31 +00007757 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7758 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007759
paula2c62832003-04-23 17:01:31 +00007760 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7761 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul718e3742002-12-13 20:15:29 +00007762
paula2c62832003-04-23 17:01:31 +00007763 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7764 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
paul718e3742002-12-13 20:15:29 +00007765
paula2c62832003-04-23 17:01:31 +00007766 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7767 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7768 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007769
paula2c62832003-04-23 17:01:31 +00007770 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7771 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007772
7773 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007774 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7775 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7776 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7777 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7778 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7779 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7780 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7781 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007782
7783 /* Init interface related vty commands. */
7784 ospf_vty_if_init ();
7785
7786 /* Init zebra related vty commands. */
7787 ospf_vty_zebra_init ();
7788}