]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_vty.c
Merge branch 'quagga' into google-bgp-multipath
[mirror_frr.git] / ospfd / ospf_vty.c
CommitLineData
718e3744 1/* OSPF VTY interface.
ba682537 2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
718e3744 3 * Copyright (C) 2000 Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23#include <zebra.h>
24
25#include "memory.h"
26#include "thread.h"
27#include "prefix.h"
28#include "table.h"
29#include "vty.h"
30#include "command.h"
31#include "plist.h"
32#include "log.h"
33#include "zclient.h"
34
35#include "ospfd/ospfd.h"
36#include "ospfd/ospf_asbr.h"
37#include "ospfd/ospf_lsa.h"
38#include "ospfd/ospf_lsdb.h"
39#include "ospfd/ospf_ism.h"
40#include "ospfd/ospf_interface.h"
41#include "ospfd/ospf_nsm.h"
42#include "ospfd/ospf_neighbor.h"
43#include "ospfd/ospf_flood.h"
44#include "ospfd/ospf_abr.h"
45#include "ospfd/ospf_spf.h"
46#include "ospfd/ospf_route.h"
47#include "ospfd/ospf_zebra.h"
48/*#include "ospfd/ospf_routemap.h" */
49#include "ospfd/ospf_vty.h"
50#include "ospfd/ospf_dump.h"
51
52\f
30a2231a 53static const char *ospf_network_type_str[] =
718e3744 54{
55 "Null",
56 "POINTOPOINT",
57 "BROADCAST",
58 "NBMA",
59 "POINTOMULTIPOINT",
60 "VIRTUALLINK",
61 "LOOPBACK"
62};
63
64\f
65/* Utility functions. */
4dadc291 66static int
6c835671 67ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
718e3744 68{
69 char *endptr = NULL;
70 unsigned long ret;
71
72 /* match "A.B.C.D". */
73 if (strchr (str, '.') != NULL)
74 {
75 ret = inet_aton (str, area_id);
76 if (!ret)
77 return -1;
78 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
79 }
80 /* match "<0-4294967295>". */
81 else
82 {
664711c1
UW
83 if (*str == '-')
84 return -1;
85 errno = 0;
718e3744 86 ret = strtoul (str, &endptr, 10);
664711c1 87 if (*endptr != '\0' || errno || ret > UINT32_MAX)
718e3744 88 return -1;
89
90 area_id->s_addr = htonl (ret);
91 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
92 }
93
94 return 0;
95}
96
97\f
4dadc291 98static int
6c835671 99str2metric (const char *str, int *metric)
718e3744 100{
101 /* Sanity check. */
102 if (str == NULL)
103 return 0;
104
105 *metric = strtol (str, NULL, 10);
106 if (*metric < 0 && *metric > 16777214)
107 {
108 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
109 return 0;
110 }
111
112 return 1;
113}
114
4dadc291 115static int
6c835671 116str2metric_type (const char *str, int *metric_type)
718e3744 117{
118 /* Sanity check. */
119 if (str == NULL)
120 return 0;
121
122 if (strncmp (str, "1", 1) == 0)
123 *metric_type = EXTERNAL_METRIC_TYPE_1;
124 else if (strncmp (str, "2", 1) == 0)
125 *metric_type = EXTERNAL_METRIC_TYPE_2;
126 else
127 return 0;
128
129 return 1;
130}
131
132int
133ospf_oi_count (struct interface *ifp)
134{
135 struct route_node *rn;
136 int i = 0;
137
138 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
139 if (rn->info)
140 i++;
141
142 return i;
143}
144
145\f
146DEFUN (router_ospf,
147 router_ospf_cmd,
148 "router ospf",
149 "Enable a routing process\n"
150 "Start OSPF configuration\n")
151{
152 vty->node = OSPF_NODE;
153 vty->index = ospf_get ();
154
155 return CMD_SUCCESS;
156}
157
158DEFUN (no_router_ospf,
159 no_router_ospf_cmd,
160 "no router ospf",
161 NO_STR
162 "Enable a routing process\n"
163 "Start OSPF configuration\n")
164{
020709f9 165 struct ospf *ospf;
166
167 ospf = ospf_lookup ();
168 if (ospf == NULL)
718e3744 169 {
020709f9 170 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
718e3744 171 return CMD_WARNING;
172 }
173
020709f9 174 ospf_finish (ospf);
718e3744 175
176 return CMD_SUCCESS;
177}
178
179DEFUN (ospf_router_id,
180 ospf_router_id_cmd,
181 "ospf router-id A.B.C.D",
182 "OSPF specific commands\n"
183 "router-id for the OSPF process\n"
184 "OSPF router-id in IP address format\n")
185{
68980084 186 struct ospf *ospf = vty->index;
718e3744 187 struct in_addr router_id;
68980084 188 int ret;
718e3744 189
190 ret = inet_aton (argv[0], &router_id);
191 if (!ret)
192 {
193 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
194 return CMD_WARNING;
195 }
196
68980084 197 ospf->router_id_static = router_id;
b29800a6 198
199 ospf_router_id_update (ospf);
200
718e3744 201 return CMD_SUCCESS;
202}
203
204ALIAS (ospf_router_id,
a2c62831 205 router_ospf_id_cmd,
718e3744 206 "router-id A.B.C.D",
207 "router-id for the OSPF process\n"
208 "OSPF router-id in IP address format\n")
209
210DEFUN (no_ospf_router_id,
211 no_ospf_router_id_cmd,
212 "no ospf router-id",
213 NO_STR
214 "OSPF specific commands\n"
215 "router-id for the OSPF process\n")
216{
68980084 217 struct ospf *ospf = vty->index;
218
219 ospf->router_id_static.s_addr = 0;
718e3744 220
68980084 221 ospf_router_id_update (ospf);
718e3744 222
223 return CMD_SUCCESS;
224}
225
226ALIAS (no_ospf_router_id,
a2c62831 227 no_router_ospf_id_cmd,
718e3744 228 "no router-id",
229 NO_STR
230 "router-id for the OSPF process\n")
231
7ffa8fa2 232static void
43540886 233ospf_passive_interface_default (struct ospf *ospf, u_char newval)
7ffa8fa2
PJ
234{
235 struct listnode *ln;
236 struct interface *ifp;
237 struct ospf_interface *oi;
238
43540886
AS
239 ospf->passive_interface_default = newval;
240
7ffa8fa2
PJ
241 for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp))
242 {
243 if (ifp &&
244 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
245 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface);
246 }
247 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi))
248 {
249 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
250 UNSET_IF_PARAM (oi->params, passive_interface);
43540886
AS
251 /* update multicast memberships */
252 ospf_if_set_multicast(oi);
7ffa8fa2
PJ
253 }
254}
255
256static void
257ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
258 struct in_addr addr,
259 struct ospf_if_params *params, u_char value)
260{
261 u_char dflt;
262
263 params->passive_interface = value;
264 if (params != IF_DEF_PARAMS (ifp))
265 {
266 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
267 dflt = IF_DEF_PARAMS (ifp)->passive_interface;
268 else
269 dflt = ospf->passive_interface_default;
270
271 if (value != dflt)
272 SET_IF_PARAM (params, passive_interface);
273 else
274 UNSET_IF_PARAM (params, passive_interface);
275
276 ospf_free_if_params (ifp, addr);
277 ospf_if_update_params (ifp, addr);
278 }
279 else
280 {
281 if (value != ospf->passive_interface_default)
282 SET_IF_PARAM (params, passive_interface);
283 else
284 UNSET_IF_PARAM (params, passive_interface);
285 }
286}
287
a2c62831 288DEFUN (ospf_passive_interface,
289 ospf_passive_interface_addr_cmd,
718e3744 290 "passive-interface IFNAME A.B.C.D",
291 "Suppress routing updates on an interface\n"
292 "Interface's name\n")
293{
7ffa8fa2
PJ
294 struct interface *ifp;
295 struct in_addr addr;
296 int ret;
297 struct ospf_if_params *params;
298 struct route_node *rn;
299 struct ospf *ospf = vty->index;
718e3744 300
43540886
AS
301 if (argc == 0)
302 {
303 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
304 return CMD_SUCCESS;
305 }
306
7ffa8fa2 307 ifp = if_get_by_name (argv[0]);
718e3744 308
309 params = IF_DEF_PARAMS (ifp);
310
43540886 311 if (argc == 2)
718e3744 312 {
43540886
AS
313 ret = inet_aton(argv[1], &addr);
314 if (!ret)
315 {
316 vty_out (vty, "Please specify interface address by A.B.C.D%s",
317 VTY_NEWLINE);
318 return CMD_WARNING;
319 }
320
321 params = ospf_get_if_params (ifp, addr);
322 ospf_if_update_params (ifp, addr);
7ffa8fa2 323 }
43540886
AS
324 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE);
325
ba6454ec 326 /* XXX We should call ospf_if_set_multicast on exactly those
327 * interfaces for which the passive property changed. It is too much
328 * work to determine this set, so we do this for every interface.
329 * This is safe and reasonable because ospf_if_set_multicast uses a
330 * record of joined groups to avoid systems calls if the desired
331 * memberships match the current memership.
332 */
7ffa8fa2 333
ba6454ec 334 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
335 {
336 struct ospf_interface *oi = rn->info;
337
338 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
43540886 339 ospf_if_set_multicast(oi);
ba6454ec 340 }
341 /*
342 * XXX It is not clear what state transitions the interface needs to
343 * undergo when going from active to passive. Fixing this will
344 * require precise identification of interfaces having such a
345 * transition.
346 */
347
718e3744 348 return CMD_SUCCESS;
349}
350
a2c62831 351ALIAS (ospf_passive_interface,
352 ospf_passive_interface_cmd,
718e3744 353 "passive-interface IFNAME",
354 "Suppress routing updates on an interface\n"
355 "Interface's name\n")
356
7ffa8fa2
PJ
357ALIAS (ospf_passive_interface,
358 ospf_passive_interface_default_cmd,
359 "passive-interface default",
360 "Suppress routing updates on an interface\n"
361 "Suppress routing updates on interfaces by default\n")
362
a2c62831 363DEFUN (no_ospf_passive_interface,
364 no_ospf_passive_interface_addr_cmd,
718e3744 365 "no passive-interface IFNAME A.B.C.D",
366 NO_STR
367 "Allow routing updates on an interface\n"
368 "Interface's name\n")
369{
370 struct interface *ifp;
371 struct in_addr addr;
372 struct ospf_if_params *params;
373 int ret;
ba6454ec 374 struct route_node *rn;
7ffa8fa2 375 struct ospf *ospf = vty->index;
43540886
AS
376
377 if (argc == 0)
378 {
379 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
380 return CMD_SUCCESS;
381 }
718e3744 382
6e72cb6a 383 ifp = if_get_by_name (argv[0]);
718e3744 384
385 params = IF_DEF_PARAMS (ifp);
386
43540886 387 if (argc == 2)
718e3744 388 {
43540886
AS
389 ret = inet_aton(argv[1], &addr);
390 if (!ret)
391 {
392 vty_out (vty, "Please specify interface address by A.B.C.D%s",
393 VTY_NEWLINE);
394 return CMD_WARNING;
395 }
396
397 params = ospf_lookup_if_params (ifp, addr);
398 if (params == NULL)
399 return CMD_SUCCESS;
718e3744 400 }
43540886 401 ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE);
ba6454ec 402
403 /* XXX We should call ospf_if_set_multicast on exactly those
404 * interfaces for which the passive property changed. It is too much
405 * work to determine this set, so we do this for every interface.
406 * This is safe and reasonable because ospf_if_set_multicast uses a
407 * record of joined groups to avoid systems calls if the desired
408 * memberships match the current memership.
409 */
410 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
411 {
412 struct ospf_interface *oi = rn->info;
413
414 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
415 ospf_if_set_multicast(oi);
416 }
417
718e3744 418 return CMD_SUCCESS;
419}
420
a2c62831 421ALIAS (no_ospf_passive_interface,
422 no_ospf_passive_interface_cmd,
718e3744 423 "no passive-interface IFNAME",
424 NO_STR
425 "Allow routing updates on an interface\n"
426 "Interface's name\n")
427
7ffa8fa2
PJ
428ALIAS (no_ospf_passive_interface,
429 no_ospf_passive_interface_default_cmd,
430 "no passive-interface default",
431 NO_STR
432 "Allow routing updates on an interface\n"
433 "Allow routing updates on interfaces by default\n")
434
a2c62831 435DEFUN (ospf_network_area,
436 ospf_network_area_cmd,
718e3744 437 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
438 "Enable routing on an IP network\n"
439 "OSPF network prefix\n"
440 "Set the OSPF area ID\n"
441 "OSPF area ID in IP address format\n"
442 "OSPF area ID as a decimal value\n")
443{
444 struct ospf *ospf= vty->index;
445 struct prefix_ipv4 p;
446 struct in_addr area_id;
447 int ret, format;
448
449 /* Get network prefix and Area ID. */
450 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
451 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
452
453 ret = ospf_network_set (ospf, &p, area_id);
454 if (ret == 0)
455 {
456 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
457 return CMD_WARNING;
458 }
459
460 return CMD_SUCCESS;
461}
462
a2c62831 463DEFUN (no_ospf_network_area,
464 no_ospf_network_area_cmd,
718e3744 465 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
466 NO_STR
467 "Enable routing on an IP network\n"
468 "OSPF network prefix\n"
469 "Set the OSPF area ID\n"
470 "OSPF area ID in IP address format\n"
471 "OSPF area ID as a decimal value\n")
472{
473 struct ospf *ospf = (struct ospf *) vty->index;
474 struct prefix_ipv4 p;
475 struct in_addr area_id;
476 int ret, format;
477
478 /* Get network prefix and Area ID. */
479 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
480 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
481
482 ret = ospf_network_unset (ospf, &p, area_id);
483 if (ret == 0)
484 {
485 vty_out (vty, "Can't find specified network area configuration.%s",
486 VTY_NEWLINE);
487 return CMD_WARNING;
488 }
489
490 return CMD_SUCCESS;
491}
492
493\f
a2c62831 494DEFUN (ospf_area_range,
495 ospf_area_range_cmd,
718e3744 496 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
497 "OSPF area parameters\n"
498 "OSPF area ID in IP address format\n"
499 "OSPF area ID as a decimal value\n"
500 "Summarize routes matching address/mask (border routers only)\n"
501 "Area range prefix\n")
502{
503 struct ospf *ospf = vty->index;
504 struct prefix_ipv4 p;
505 struct in_addr area_id;
506 int format;
507 u_int32_t cost;
508
509 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
510 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
511
512 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
513 if (argc > 2)
514 {
4dadc291 515 VTY_GET_INTEGER ("range cost", cost, argv[2]);
718e3744 516 ospf_area_range_cost_set (ospf, area_id, &p, cost);
517 }
518
519 return CMD_SUCCESS;
520}
521
a2c62831 522ALIAS (ospf_area_range,
523 ospf_area_range_advertise_cmd,
718e3744 524 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
525 "OSPF area parameters\n"
526 "OSPF area ID in IP address format\n"
527 "OSPF area ID as a decimal value\n"
528 "OSPF area range for route advertise (default)\n"
529 "Area range prefix\n"
530 "Advertise this range (default)\n")
531
a2c62831 532ALIAS (ospf_area_range,
533 ospf_area_range_cost_cmd,
718e3744 534 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
535 "OSPF area parameters\n"
536 "OSPF area ID in IP address format\n"
537 "OSPF area ID as a decimal value\n"
538 "Summarize routes matching address/mask (border routers only)\n"
539 "Area range prefix\n"
540 "User specified metric for this range\n"
541 "Advertised metric for this range\n")
542
a2c62831 543ALIAS (ospf_area_range,
544 ospf_area_range_advertise_cost_cmd,
718e3744 545 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
546 "OSPF area parameters\n"
547 "OSPF area ID in IP address format\n"
548 "OSPF area ID as a decimal value\n"
549 "Summarize routes matching address/mask (border routers only)\n"
550 "Area range prefix\n"
551 "Advertise this range (default)\n"
552 "User specified metric for this range\n"
553 "Advertised metric for this range\n")
554
a2c62831 555DEFUN (ospf_area_range_not_advertise,
556 ospf_area_range_not_advertise_cmd,
718e3744 557 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
558 "OSPF area parameters\n"
559 "OSPF area ID in IP address format\n"
560 "OSPF area ID as a decimal value\n"
561 "Summarize routes matching address/mask (border routers only)\n"
562 "Area range prefix\n"
563 "DoNotAdvertise this range\n")
564{
565 struct ospf *ospf = vty->index;
566 struct prefix_ipv4 p;
567 struct in_addr area_id;
568 int format;
569
570 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
571 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
572
573 ospf_area_range_set (ospf, area_id, &p, 0);
574
575 return CMD_SUCCESS;
576}
577
a2c62831 578DEFUN (no_ospf_area_range,
579 no_ospf_area_range_cmd,
718e3744 580 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
581 NO_STR
582 "OSPF area parameters\n"
583 "OSPF area ID in IP address format\n"
584 "OSPF area ID as a decimal value\n"
585 "Summarize routes matching address/mask (border routers only)\n"
586 "Area range prefix\n")
587{
588 struct ospf *ospf = vty->index;
589 struct prefix_ipv4 p;
590 struct in_addr area_id;
591 int format;
592
593 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
594 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
595
596 ospf_area_range_unset (ospf, area_id, &p);
597
598 return CMD_SUCCESS;
599}
600
a2c62831 601ALIAS (no_ospf_area_range,
602 no_ospf_area_range_advertise_cmd,
718e3744 603 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
604 NO_STR
605 "OSPF area parameters\n"
606 "OSPF area ID in IP address format\n"
607 "OSPF area ID as a decimal value\n"
608 "Summarize routes matching address/mask (border routers only)\n"
609 "Area range prefix\n"
610 "Advertise this range (default)\n"
611 "DoNotAdvertise this range\n")
612
a2c62831 613ALIAS (no_ospf_area_range,
614 no_ospf_area_range_cost_cmd,
718e3744 615 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
616 NO_STR
617 "OSPF area parameters\n"
618 "OSPF area ID in IP address format\n"
619 "OSPF area ID as a decimal value\n"
620 "Summarize routes matching address/mask (border routers only)\n"
621 "Area range prefix\n"
622 "User specified metric for this range\n"
623 "Advertised metric for this range\n")
624
a2c62831 625ALIAS (no_ospf_area_range,
626 no_ospf_area_range_advertise_cost_cmd,
718e3744 627 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
628 NO_STR
629 "OSPF area parameters\n"
630 "OSPF area ID in IP address format\n"
631 "OSPF area ID as a decimal value\n"
632 "Summarize routes matching address/mask (border routers only)\n"
633 "Area range prefix\n"
634 "Advertise this range (default)\n"
635 "User specified metric for this range\n"
636 "Advertised metric for this range\n")
637\f
a2c62831 638DEFUN (ospf_area_range_substitute,
639 ospf_area_range_substitute_cmd,
718e3744 640 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
641 "OSPF area parameters\n"
642 "OSPF area ID in IP address format\n"
643 "OSPF area ID as a decimal value\n"
644 "Summarize routes matching address/mask (border routers only)\n"
645 "Area range prefix\n"
646 "Announce area range as another prefix\n"
647 "Network prefix to be announced instead of range\n")
648{
649 struct ospf *ospf = vty->index;
650 struct prefix_ipv4 p, s;
651 struct in_addr area_id;
652 int format;
653
654 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
655 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
656 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
657
658 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
659
660 return CMD_SUCCESS;
661}
662
a2c62831 663DEFUN (no_ospf_area_range_substitute,
664 no_ospf_area_range_substitute_cmd,
718e3744 665 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
666 NO_STR
667 "OSPF area parameters\n"
668 "OSPF area ID in IP address format\n"
669 "OSPF area ID as a decimal value\n"
670 "Summarize routes matching address/mask (border routers only)\n"
671 "Area range prefix\n"
672 "Announce area range as another prefix\n"
673 "Network prefix to be announced instead of range\n")
674{
675 struct ospf *ospf = vty->index;
676 struct prefix_ipv4 p, s;
677 struct in_addr area_id;
678 int format;
679
680 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
681 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
682 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
683
684 ospf_area_range_substitute_unset (ospf, area_id, &p);
685
686 return CMD_SUCCESS;
687}
688
689\f
690/* Command Handler Logic in VLink stuff is delicate!!
691
692 ALTER AT YOUR OWN RISK!!!!
693
694 Various dummy values are used to represent 'NoChange' state for
695 VLink configuration NOT being changed by a VLink command, and
696 special syntax is used within the command strings so that the
697 typed in command verbs can be seen in the configuration command
698 bacckend handler. This is to drastically reduce the verbeage
699 required to coe up with a reasonably compatible Cisco VLink command
700
701 - Matthew Grant <grantma@anathoth.gen.nz>
702 Wed, 21 Feb 2001 15:13:52 +1300
703 */
704
705
706/* Configuration data for virtual links
707 */
708struct ospf_vl_config_data {
709 struct vty *vty; /* vty stuff */
710 struct in_addr area_id; /* area ID from command line */
711 int format; /* command line area ID format */
712 struct in_addr vl_peer; /* command line vl_peer */
713 int auth_type; /* Authehntication type, if given */
714 char *auth_key; /* simple password if present */
715 int crypto_key_id; /* Cryptographic key ID */
716 char *md5_key; /* MD5 authentication key */
717 int hello_interval; /* Obvious what these are... */
718 int retransmit_interval;
719 int transmit_delay;
720 int dead_interval;
721};
722
4dadc291 723static void
718e3744 724ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
725 struct vty *vty)
726{
727 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
728 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
729 vl_config->vty = vty;
730}
731
4dadc291 732static struct ospf_vl_data *
68980084 733ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
718e3744 734{
735 struct ospf_area *area;
736 struct ospf_vl_data *vl_data;
737 struct vty *vty;
738 struct in_addr area_id;
739
740 vty = vl_config->vty;
741 area_id = vl_config->area_id;
742
743 if (area_id.s_addr == OSPF_AREA_BACKBONE)
744 {
745 vty_out (vty,
746 "Configuring VLs over the backbone is not allowed%s",
747 VTY_NEWLINE);
748 return NULL;
749 }
68980084 750 area = ospf_area_get (ospf, area_id, vl_config->format);
718e3744 751
752 if (area->external_routing != OSPF_AREA_DEFAULT)
753 {
754 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
755 vty_out (vty, "Area %s is %s%s",
756 inet_ntoa (area_id),
718e3744 757 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
718e3744 758 VTY_NEWLINE);
759 else
760 vty_out (vty, "Area %ld is %s%s",
761 (u_long)ntohl (area_id.s_addr),
718e3744 762 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
718e3744 763 VTY_NEWLINE);
764 return NULL;
765 }
766
9c27ef9b 767 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
718e3744 768 {
769 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
770 if (vl_data->vl_oi == NULL)
771 {
68980084 772 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
773 ospf_vl_add (ospf, vl_data);
774 ospf_spf_calculate_schedule (ospf);
718e3744 775 }
776 }
777 return vl_data;
778}
779
780
4dadc291 781static int
718e3744 782ospf_vl_set_security (struct ospf_vl_data *vl_data,
783 struct ospf_vl_config_data *vl_config)
784{
785 struct crypt_key *ck;
786 struct vty *vty;
787 struct interface *ifp = vl_data->vl_oi->ifp;
788
789 vty = vl_config->vty;
790
791 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
792 {
793 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
794 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
795 }
796
797 if (vl_config->auth_key)
798 {
799 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
c9e52be3 800 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
718e3744 801 OSPF_AUTH_SIMPLE_SIZE);
802 }
803 else if (vl_config->md5_key)
804 {
805 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
806 != NULL)
807 {
808 vty_out (vty, "OSPF: Key %d already exists%s",
809 vl_config->crypto_key_id, VTY_NEWLINE);
810 return CMD_WARNING;
811 }
812 ck = ospf_crypt_key_new ();
813 ck->key_id = vl_config->crypto_key_id;
814 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
c9e52be3 815 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
718e3744 816
817 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
818 }
819 else if (vl_config->crypto_key_id != 0)
820 {
821 /* Delete a key */
822
823 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
824 vl_config->crypto_key_id) == NULL)
825 {
826 vty_out (vty, "OSPF: Key %d does not exist%s",
827 vl_config->crypto_key_id, VTY_NEWLINE);
828 return CMD_WARNING;
829 }
830
831 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
832
833 }
834
835 return CMD_SUCCESS;
836}
837
4dadc291 838static int
718e3744 839ospf_vl_set_timers (struct ospf_vl_data *vl_data,
840 struct ospf_vl_config_data *vl_config)
841{
842 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
843 /* Virtual Link data initialised to defaults, so only set
844 if a value given */
845 if (vl_config->hello_interval)
846 {
847 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
848 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
849 }
850
851 if (vl_config->dead_interval)
852 {
853 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
854 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
855 }
856
857 if (vl_config->retransmit_interval)
858 {
859 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
860 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
861 }
862
863 if (vl_config->transmit_delay)
864 {
865 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
866 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
867 }
868
869 return CMD_SUCCESS;
870}
871
872
873
874/* The business end of all of the above */
4dadc291 875static int
68980084 876ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
718e3744 877{
878 struct ospf_vl_data *vl_data;
879 int ret;
880
68980084 881 vl_data = ospf_find_vl_data (ospf, vl_config);
718e3744 882 if (!vl_data)
883 return CMD_WARNING;
884
885 /* Process this one first as it can have a fatal result, which can
886 only logically occur if the virtual link exists already
887 Thus a command error does not result in a change to the
888 running configuration such as unexpectedly altered timer
889 values etc.*/
890 ret = ospf_vl_set_security (vl_data, vl_config);
891 if (ret != CMD_SUCCESS)
892 return ret;
893
894 /* Set any time based parameters, these area already range checked */
895
896 ret = ospf_vl_set_timers (vl_data, vl_config);
897 if (ret != CMD_SUCCESS)
898 return ret;
899
900 return CMD_SUCCESS;
901
902}
903
904/* This stuff exists to make specifying all the alias commands A LOT simpler
905 */
906#define VLINK_HELPSTR_IPADDR \
907 "OSPF area parameters\n" \
908 "OSPF area ID in IP address format\n" \
909 "OSPF area ID as a decimal value\n" \
910 "Configure a virtual link\n" \
911 "Router ID of the remote ABR\n"
912
913#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
914 "Enable authentication on this virtual link\n" \
915 "dummy string \n"
916
917#define VLINK_HELPSTR_AUTHTYPE_ALL \
918 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
919 "Use null authentication\n" \
920 "Use message-digest authentication\n"
921
922#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
923 "Time between HELLO packets\n" \
924 "Time between retransmitting lost link state advertisements\n" \
925 "Link state transmit delay\n" \
926 "Interval after which a neighbor is declared dead\n"
927
928#define VLINK_HELPSTR_TIME_PARAM \
929 VLINK_HELPSTR_TIME_PARAM_NOSECS \
930 "Seconds\n"
931
932#define VLINK_HELPSTR_AUTH_SIMPLE \
933 "Authentication password (key)\n" \
934 "The OSPF password (key)"
935
936#define VLINK_HELPSTR_AUTH_MD5 \
937 "Message digest authentication password (key)\n" \
938 "dummy string \n" \
939 "Key ID\n" \
940 "Use MD5 algorithm\n" \
941 "The OSPF password (key)"
942
a2c62831 943DEFUN (ospf_area_vlink,
944 ospf_area_vlink_cmd,
718e3744 945 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
946 VLINK_HELPSTR_IPADDR)
947{
68980084 948 struct ospf *ospf = vty->index;
718e3744 949 struct ospf_vl_config_data vl_config;
950 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
951 char md5_key[OSPF_AUTH_MD5_SIZE+1];
952 int i;
953 int ret;
954
955 ospf_vl_config_data_init(&vl_config, vty);
956
957 /* Read off first 2 parameters and check them */
958 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
959 if (ret < 0)
960 {
961 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
962 return CMD_WARNING;
963 }
964
965 ret = inet_aton (argv[1], &vl_config.vl_peer);
966 if (! ret)
967 {
968 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
969 VTY_NEWLINE);
970 return CMD_WARNING;
971 }
972
973 if (argc <=2)
974 {
975 /* Thats all folks! - BUGS B. strikes again!!!*/
976
68980084 977 return ospf_vl_set (ospf, &vl_config);
718e3744 978 }
979
980 /* Deal with other parameters */
981 for (i=2; i < argc; i++)
982 {
983
984 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
985
986 switch (argv[i][0])
987 {
988
989 case 'a':
990 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
991 {
992 /* authentication-key - this option can occur anywhere on
993 command line. At start of command line
994 must check for authentication option. */
995 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
996 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
997 vl_config.auth_key = auth_key;
998 i++;
999 }
1000 else if (strncmp (argv[i], "authentication", 14) == 0)
1001 {
1002 /* authentication - this option can only occur at start
1003 of command line */
1004 vl_config.auth_type = OSPF_AUTH_SIMPLE;
1005 if ((i+1) < argc)
1006 {
1007 if (strncmp (argv[i+1], "n", 1) == 0)
1008 {
1009 /* "authentication null" */
1010 vl_config.auth_type = OSPF_AUTH_NULL;
1011 i++;
1012 }
1013 else if (strncmp (argv[i+1], "m", 1) == 0
1014 && strcmp (argv[i+1], "message-digest-") != 0)
1015 {
1016 /* "authentication message-digest" */
1017 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1018 i++;
1019 }
1020 }
1021 }
1022 break;
1023
1024 case 'm':
1025 /* message-digest-key */
1026 i++;
1027 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1028 if (vl_config.crypto_key_id < 0)
1029 return CMD_WARNING;
1030 i++;
1031 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
1032 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
1033 vl_config.md5_key = md5_key;
1034 break;
1035
1036 case 'h':
1037 /* Hello interval */
1038 i++;
1039 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1040 if (vl_config.hello_interval < 0)
1041 return CMD_WARNING;
1042 break;
1043
1044 case 'r':
1045 /* Retransmit Interval */
1046 i++;
1047 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1048 if (vl_config.retransmit_interval < 0)
1049 return CMD_WARNING;
1050 break;
1051
1052 case 't':
1053 /* Transmit Delay */
1054 i++;
1055 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1056 if (vl_config.transmit_delay < 0)
1057 return CMD_WARNING;
1058 break;
1059
1060 case 'd':
1061 /* Dead Interval */
1062 i++;
1063 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1064 if (vl_config.dead_interval < 0)
1065 return CMD_WARNING;
1066 break;
1067 }
1068 }
1069
1070
1071 /* Action configuration */
1072
68980084 1073 return ospf_vl_set (ospf, &vl_config);
718e3744 1074
1075}
1076
a2c62831 1077DEFUN (no_ospf_area_vlink,
1078 no_ospf_area_vlink_cmd,
718e3744 1079 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1080 NO_STR
1081 VLINK_HELPSTR_IPADDR)
1082{
68980084 1083 struct ospf *ospf = vty->index;
718e3744 1084 struct ospf_area *area;
1085 struct ospf_vl_config_data vl_config;
1086 struct ospf_vl_data *vl_data = NULL;
1087 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1088 int i;
1089 int ret, format;
1090
1091 ospf_vl_config_data_init(&vl_config, vty);
1092
1093 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1094 if (ret < 0)
1095 {
1096 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1097 return CMD_WARNING;
1098 }
1099
68980084 1100 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
718e3744 1101 if (!area)
1102 {
1103 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1104 return CMD_WARNING;
1105 }
1106
1107 ret = inet_aton (argv[1], &vl_config.vl_peer);
1108 if (! ret)
1109 {
1110 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1111 VTY_NEWLINE);
1112 return CMD_WARNING;
1113 }
1114
1115 if (argc <=2)
1116 {
1117 /* Basic VLink no command */
1118 /* Thats all folks! - BUGS B. strikes again!!!*/
9c27ef9b 1119 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
68980084 1120 ospf_vl_delete (ospf, vl_data);
718e3744 1121
68980084 1122 ospf_area_check_free (ospf, vl_config.area_id);
718e3744 1123
1124 return CMD_SUCCESS;
1125 }
1126
1127 /* If we are down here, we are reseting parameters */
1128
1129 /* Deal with other parameters */
1130 for (i=2; i < argc; i++)
1131 {
718e3744 1132 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1133
1134 switch (argv[i][0])
1135 {
1136
1137 case 'a':
1138 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1139 {
1140 /* authentication-key - this option can occur anywhere on
1141 command line. At start of command line
1142 must check for authentication option. */
1143 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1144 vl_config.auth_key = auth_key;
1145 }
1146 else if (strncmp (argv[i], "authentication", 14) == 0)
1147 {
1148 /* authentication - this option can only occur at start
1149 of command line */
1150 vl_config.auth_type = OSPF_AUTH_NOTSET;
1151 }
1152 break;
1153
1154 case 'm':
1155 /* message-digest-key */
1156 /* Delete one key */
1157 i++;
1158 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1159 if (vl_config.crypto_key_id < 0)
1160 return CMD_WARNING;
1161 vl_config.md5_key = NULL;
1162 break;
1163
1164 case 'h':
1165 /* Hello interval */
1166 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1167 break;
1168
1169 case 'r':
1170 /* Retransmit Interval */
1171 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1172 break;
1173
1174 case 't':
1175 /* Transmit Delay */
1176 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1177 break;
1178
1179 case 'd':
1180 /* Dead Interval */
1181 i++;
1182 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1183 break;
1184 }
1185 }
1186
1187
1188 /* Action configuration */
1189
68980084 1190 return ospf_vl_set (ospf, &vl_config);
718e3744 1191}
1192
a2c62831 1193ALIAS (ospf_area_vlink,
1194 ospf_area_vlink_param1_cmd,
718e3744 1195 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1196 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1197 VLINK_HELPSTR_IPADDR
1198 VLINK_HELPSTR_TIME_PARAM)
1199
a2c62831 1200ALIAS (no_ospf_area_vlink,
1201 no_ospf_area_vlink_param1_cmd,
718e3744 1202 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1203 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1204 NO_STR
1205 VLINK_HELPSTR_IPADDR
1206 VLINK_HELPSTR_TIME_PARAM)
1207
a2c62831 1208ALIAS (ospf_area_vlink,
1209 ospf_area_vlink_param2_cmd,
718e3744 1210 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1211 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1212 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1213 VLINK_HELPSTR_IPADDR
1214 VLINK_HELPSTR_TIME_PARAM
1215 VLINK_HELPSTR_TIME_PARAM)
1216
a2c62831 1217ALIAS (no_ospf_area_vlink,
1218 no_ospf_area_vlink_param2_cmd,
718e3744 1219 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1220 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1221 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1222 NO_STR
1223 VLINK_HELPSTR_IPADDR
1224 VLINK_HELPSTR_TIME_PARAM
1225 VLINK_HELPSTR_TIME_PARAM)
1226
a2c62831 1227ALIAS (ospf_area_vlink,
1228 ospf_area_vlink_param3_cmd,
718e3744 1229 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1230 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1231 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1232 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1233 VLINK_HELPSTR_IPADDR
1234 VLINK_HELPSTR_TIME_PARAM
1235 VLINK_HELPSTR_TIME_PARAM
1236 VLINK_HELPSTR_TIME_PARAM)
1237
a2c62831 1238ALIAS (no_ospf_area_vlink,
1239 no_ospf_area_vlink_param3_cmd,
718e3744 1240 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1241 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1242 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1243 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1244 NO_STR
1245 VLINK_HELPSTR_IPADDR
1246 VLINK_HELPSTR_TIME_PARAM
1247 VLINK_HELPSTR_TIME_PARAM
1248 VLINK_HELPSTR_TIME_PARAM)
1249
a2c62831 1250ALIAS (ospf_area_vlink,
1251 ospf_area_vlink_param4_cmd,
718e3744 1252 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1253 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1254 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1255 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1256 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1257 VLINK_HELPSTR_IPADDR
1258 VLINK_HELPSTR_TIME_PARAM
1259 VLINK_HELPSTR_TIME_PARAM
1260 VLINK_HELPSTR_TIME_PARAM
1261 VLINK_HELPSTR_TIME_PARAM)
1262
a2c62831 1263ALIAS (no_ospf_area_vlink,
1264 no_ospf_area_vlink_param4_cmd,
718e3744 1265 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1266 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1267 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1268 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1269 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1270 NO_STR
1271 VLINK_HELPSTR_IPADDR
1272 VLINK_HELPSTR_TIME_PARAM
1273 VLINK_HELPSTR_TIME_PARAM
1274 VLINK_HELPSTR_TIME_PARAM
1275 VLINK_HELPSTR_TIME_PARAM)
1276
a2c62831 1277ALIAS (ospf_area_vlink,
1278 ospf_area_vlink_authtype_args_cmd,
718e3744 1279 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1280 "(authentication|) (message-digest|null)",
1281 VLINK_HELPSTR_IPADDR
1282 VLINK_HELPSTR_AUTHTYPE_ALL)
1283
a2c62831 1284ALIAS (ospf_area_vlink,
1285 ospf_area_vlink_authtype_cmd,
718e3744 1286 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1287 "(authentication|)",
1288 VLINK_HELPSTR_IPADDR
1289 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1290
a2c62831 1291ALIAS (no_ospf_area_vlink,
1292 no_ospf_area_vlink_authtype_cmd,
718e3744 1293 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1294 "(authentication|)",
1295 NO_STR
1296 VLINK_HELPSTR_IPADDR
1297 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1298
a2c62831 1299ALIAS (ospf_area_vlink,
1300 ospf_area_vlink_md5_cmd,
718e3744 1301 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1302 "(message-digest-key|) <1-255> md5 KEY",
1303 VLINK_HELPSTR_IPADDR
1304 VLINK_HELPSTR_AUTH_MD5)
1305
a2c62831 1306ALIAS (no_ospf_area_vlink,
1307 no_ospf_area_vlink_md5_cmd,
718e3744 1308 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1309 "(message-digest-key|) <1-255>",
1310 NO_STR
1311 VLINK_HELPSTR_IPADDR
1312 VLINK_HELPSTR_AUTH_MD5)
1313
a2c62831 1314ALIAS (ospf_area_vlink,
1315 ospf_area_vlink_authkey_cmd,
718e3744 1316 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1317 "(authentication-key|) AUTH_KEY",
1318 VLINK_HELPSTR_IPADDR
1319 VLINK_HELPSTR_AUTH_SIMPLE)
1320
a2c62831 1321ALIAS (no_ospf_area_vlink,
1322 no_ospf_area_vlink_authkey_cmd,
718e3744 1323 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1324 "(authentication-key|)",
1325 NO_STR
1326 VLINK_HELPSTR_IPADDR
1327 VLINK_HELPSTR_AUTH_SIMPLE)
1328
a2c62831 1329ALIAS (ospf_area_vlink,
1330 ospf_area_vlink_authtype_args_authkey_cmd,
718e3744 1331 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1332 "(authentication|) (message-digest|null) "
1333 "(authentication-key|) AUTH_KEY",
1334 VLINK_HELPSTR_IPADDR
1335 VLINK_HELPSTR_AUTHTYPE_ALL
1336 VLINK_HELPSTR_AUTH_SIMPLE)
1337
a2c62831 1338ALIAS (ospf_area_vlink,
1339 ospf_area_vlink_authtype_authkey_cmd,
718e3744 1340 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1341 "(authentication|) "
1342 "(authentication-key|) AUTH_KEY",
1343 VLINK_HELPSTR_IPADDR
1344 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1345 VLINK_HELPSTR_AUTH_SIMPLE)
1346
a2c62831 1347ALIAS (no_ospf_area_vlink,
1348 no_ospf_area_vlink_authtype_authkey_cmd,
718e3744 1349 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1350 "(authentication|) "
1351 "(authentication-key|)",
1352 NO_STR
1353 VLINK_HELPSTR_IPADDR
1354 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1355 VLINK_HELPSTR_AUTH_SIMPLE)
1356
a2c62831 1357ALIAS (ospf_area_vlink,
1358 ospf_area_vlink_authtype_args_md5_cmd,
718e3744 1359 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1360 "(authentication|) (message-digest|null) "
1361 "(message-digest-key|) <1-255> md5 KEY",
1362 VLINK_HELPSTR_IPADDR
1363 VLINK_HELPSTR_AUTHTYPE_ALL
1364 VLINK_HELPSTR_AUTH_MD5)
1365
a2c62831 1366ALIAS (ospf_area_vlink,
1367 ospf_area_vlink_authtype_md5_cmd,
718e3744 1368 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1369 "(authentication|) "
1370 "(message-digest-key|) <1-255> md5 KEY",
1371 VLINK_HELPSTR_IPADDR
1372 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1373 VLINK_HELPSTR_AUTH_MD5)
1374
a2c62831 1375ALIAS (no_ospf_area_vlink,
1376 no_ospf_area_vlink_authtype_md5_cmd,
718e3744 1377 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1378 "(authentication|) "
1379 "(message-digest-key|)",
1380 NO_STR
1381 VLINK_HELPSTR_IPADDR
1382 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1383 VLINK_HELPSTR_AUTH_MD5)
1384
1385\f
a2c62831 1386DEFUN (ospf_area_shortcut,
1387 ospf_area_shortcut_cmd,
718e3744 1388 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1389 "OSPF area parameters\n"
1390 "OSPF area ID in IP address format\n"
1391 "OSPF area ID as a decimal value\n"
1392 "Configure the area's shortcutting mode\n"
1393 "Set default shortcutting behavior\n"
1394 "Enable shortcutting through the area\n"
1395 "Disable shortcutting through the area\n")
1396{
68980084 1397 struct ospf *ospf = vty->index;
718e3744 1398 struct ospf_area *area;
1399 struct in_addr area_id;
1400 int mode;
1401 int format;
1402
1403 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1404
68980084 1405 area = ospf_area_get (ospf, area_id, format);
718e3744 1406
1407 if (strncmp (argv[1], "de", 2) == 0)
1408 mode = OSPF_SHORTCUT_DEFAULT;
1409 else if (strncmp (argv[1], "di", 2) == 0)
1410 mode = OSPF_SHORTCUT_DISABLE;
1411 else if (strncmp (argv[1], "e", 1) == 0)
1412 mode = OSPF_SHORTCUT_ENABLE;
1413 else
1414 return CMD_WARNING;
1415
68980084 1416 ospf_area_shortcut_set (ospf, area, mode);
718e3744 1417
68980084 1418 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
718e3744 1419 vty_out (vty, "Shortcut area setting will take effect "
1420 "only when the router is configured as Shortcut ABR%s",
1421 VTY_NEWLINE);
1422
1423 return CMD_SUCCESS;
1424}
1425
a2c62831 1426DEFUN (no_ospf_area_shortcut,
1427 no_ospf_area_shortcut_cmd,
718e3744 1428 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1429 NO_STR
1430 "OSPF area parameters\n"
1431 "OSPF area ID in IP address format\n"
1432 "OSPF area ID as a decimal value\n"
1433 "Deconfigure the area's shortcutting mode\n"
1434 "Deconfigure enabled shortcutting through the area\n"
1435 "Deconfigure disabled shortcutting through the area\n")
1436{
68980084 1437 struct ospf *ospf = vty->index;
718e3744 1438 struct ospf_area *area;
1439 struct in_addr area_id;
1440 int format;
1441
1442 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1443
68980084 1444 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 1445 if (!area)
1446 return CMD_SUCCESS;
1447
68980084 1448 ospf_area_shortcut_unset (ospf, area);
718e3744 1449
1450 return CMD_SUCCESS;
1451}
1452
1453\f
a2c62831 1454DEFUN (ospf_area_stub,
1455 ospf_area_stub_cmd,
718e3744 1456 "area (A.B.C.D|<0-4294967295>) stub",
1457 "OSPF area parameters\n"
1458 "OSPF area ID in IP address format\n"
1459 "OSPF area ID as a decimal value\n"
1460 "Configure OSPF area as stub\n")
1461{
1462 struct ospf *ospf = vty->index;
1463 struct in_addr area_id;
1464 int ret, format;
1465
1466 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1467
1468 ret = ospf_area_stub_set (ospf, area_id);
1469 if (ret == 0)
1470 {
1471 vty_out (vty, "First deconfigure all virtual link through this area%s",
1472 VTY_NEWLINE);
1473 return CMD_WARNING;
1474 }
1475
1476 ospf_area_no_summary_unset (ospf, area_id);
1477
1478 return CMD_SUCCESS;
1479}
1480
a2c62831 1481DEFUN (ospf_area_stub_no_summary,
1482 ospf_area_stub_no_summary_cmd,
718e3744 1483 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1484 "OSPF stub parameters\n"
1485 "OSPF area ID in IP address format\n"
1486 "OSPF area ID as a decimal value\n"
1487 "Configure OSPF area as stub\n"
1488 "Do not inject inter-area routes into stub\n")
1489{
1490 struct ospf *ospf = vty->index;
1491 struct in_addr area_id;
1492 int ret, format;
1493
1494 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1495
1496 ret = ospf_area_stub_set (ospf, area_id);
1497 if (ret == 0)
1498 {
b0a053be 1499 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
718e3744 1500 VTY_NEWLINE);
1501 return CMD_WARNING;
1502 }
1503
1504 ospf_area_no_summary_set (ospf, area_id);
1505
1506 return CMD_SUCCESS;
1507}
1508
a2c62831 1509DEFUN (no_ospf_area_stub,
1510 no_ospf_area_stub_cmd,
718e3744 1511 "no area (A.B.C.D|<0-4294967295>) stub",
1512 NO_STR
1513 "OSPF area parameters\n"
1514 "OSPF area ID in IP address format\n"
1515 "OSPF area ID as a decimal value\n"
1516 "Configure OSPF area as stub\n")
1517{
1518 struct ospf *ospf = vty->index;
1519 struct in_addr area_id;
1520 int format;
1521
1522 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1523
1524 ospf_area_stub_unset (ospf, area_id);
1525 ospf_area_no_summary_unset (ospf, area_id);
1526
1527 return CMD_SUCCESS;
1528}
1529
a2c62831 1530DEFUN (no_ospf_area_stub_no_summary,
1531 no_ospf_area_stub_no_summary_cmd,
718e3744 1532 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1533 NO_STR
1534 "OSPF area parameters\n"
1535 "OSPF area ID in IP address format\n"
1536 "OSPF area ID as a decimal value\n"
1537 "Configure OSPF area as stub\n"
1538 "Do not inject inter-area routes into area\n")
1539{
1540 struct ospf *ospf = vty->index;
1541 struct in_addr area_id;
1542 int format;
1543
1544 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1545 ospf_area_no_summary_unset (ospf, area_id);
1546
1547 return CMD_SUCCESS;
1548}
1549
4dadc291 1550static int
6c835671 1551ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1552 int nosum)
718e3744 1553{
1554 struct ospf *ospf = vty->index;
1555 struct in_addr area_id;
1556 int ret, format;
1557
1558 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1559
1560 ret = ospf_area_nssa_set (ospf, area_id);
1561 if (ret == 0)
1562 {
1563 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1564 VTY_NEWLINE);
1565 return CMD_WARNING;
1566 }
1567
1568 if (argc > 1)
1569 {
1570 if (strncmp (argv[1], "translate-c", 11) == 0)
b0a053be 1571 ospf_area_nssa_translator_role_set (ospf, area_id,
718e3744 1572 OSPF_NSSA_ROLE_CANDIDATE);
1573 else if (strncmp (argv[1], "translate-n", 11) == 0)
b0a053be 1574 ospf_area_nssa_translator_role_set (ospf, area_id,
718e3744 1575 OSPF_NSSA_ROLE_NEVER);
1576 else if (strncmp (argv[1], "translate-a", 11) == 0)
b0a053be 1577 ospf_area_nssa_translator_role_set (ospf, area_id,
718e3744 1578 OSPF_NSSA_ROLE_ALWAYS);
1579 }
b0a053be 1580 else
1581 {
1582 ospf_area_nssa_translator_role_set (ospf, area_id,
1583 OSPF_NSSA_ROLE_CANDIDATE);
1584 }
718e3744 1585
b0a053be 1586 if (nosum)
718e3744 1587 ospf_area_no_summary_set (ospf, area_id);
b0a053be 1588 else
1589 ospf_area_no_summary_unset (ospf, area_id);
718e3744 1590
b0a053be 1591 ospf_schedule_abr_task (ospf);
1592
718e3744 1593 return CMD_SUCCESS;
1594}
1595
b0a053be 1596DEFUN (ospf_area_nssa_translate_no_summary,
a2c62831 1597 ospf_area_nssa_translate_no_summary_cmd,
b0a053be 1598 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
718e3744 1599 "OSPF area parameters\n"
1600 "OSPF area ID in IP address format\n"
1601 "OSPF area ID as a decimal value\n"
1602 "Configure OSPF area as nssa\n"
1603 "Configure NSSA-ABR for translate election (default)\n"
1604 "Configure NSSA-ABR to never translate\n"
1605 "Configure NSSA-ABR to always translate\n"
b0a053be 1606 "Do not inject inter-area routes into nssa\n")
1607{
1608 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1609}
718e3744 1610
b0a053be 1611DEFUN (ospf_area_nssa_translate,
a2c62831 1612 ospf_area_nssa_translate_cmd,
718e3744 1613 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1614 "OSPF area parameters\n"
1615 "OSPF area ID in IP address format\n"
1616 "OSPF area ID as a decimal value\n"
1617 "Configure OSPF area as nssa\n"
1618 "Configure NSSA-ABR for translate election (default)\n"
1619 "Configure NSSA-ABR to never translate\n"
1620 "Configure NSSA-ABR to always translate\n")
b0a053be 1621{
1622 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1623}
1624
1625DEFUN (ospf_area_nssa,
1626 ospf_area_nssa_cmd,
1627 "area (A.B.C.D|<0-4294967295>) nssa",
1628 "OSPF area parameters\n"
1629 "OSPF area ID in IP address format\n"
1630 "OSPF area ID as a decimal value\n"
1631 "Configure OSPF area as nssa\n")
1632{
1633 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1634}
718e3744 1635
a2c62831 1636DEFUN (ospf_area_nssa_no_summary,
1637 ospf_area_nssa_no_summary_cmd,
718e3744 1638 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1639 "OSPF area parameters\n"
1640 "OSPF area ID in IP address format\n"
1641 "OSPF area ID as a decimal value\n"
1642 "Configure OSPF area as nssa\n"
1643 "Do not inject inter-area routes into nssa\n")
1644{
b0a053be 1645 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
718e3744 1646}
1647
a2c62831 1648DEFUN (no_ospf_area_nssa,
1649 no_ospf_area_nssa_cmd,
718e3744 1650 "no area (A.B.C.D|<0-4294967295>) nssa",
1651 NO_STR
1652 "OSPF area parameters\n"
1653 "OSPF area ID in IP address format\n"
1654 "OSPF area ID as a decimal value\n"
1655 "Configure OSPF area as nssa\n")
1656{
1657 struct ospf *ospf = vty->index;
1658 struct in_addr area_id;
1659 int format;
1660
1661 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1662
1663 ospf_area_nssa_unset (ospf, area_id);
1664 ospf_area_no_summary_unset (ospf, area_id);
1665
b0a053be 1666 ospf_schedule_abr_task (ospf);
1667
718e3744 1668 return CMD_SUCCESS;
1669}
1670
a2c62831 1671DEFUN (no_ospf_area_nssa_no_summary,
1672 no_ospf_area_nssa_no_summary_cmd,
718e3744 1673 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1674 NO_STR
1675 "OSPF area parameters\n"
1676 "OSPF area ID in IP address format\n"
1677 "OSPF area ID as a decimal value\n"
1678 "Configure OSPF area as nssa\n"
1679 "Do not inject inter-area routes into nssa\n")
1680{
1681 struct ospf *ospf = vty->index;
1682 struct in_addr area_id;
1683 int format;
1684
1685 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1686 ospf_area_no_summary_unset (ospf, area_id);
1687
1688 return CMD_SUCCESS;
1689}
1690
a2c62831 1691DEFUN (ospf_area_default_cost,
1692 ospf_area_default_cost_cmd,
718e3744 1693 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1694 "OSPF area parameters\n"
1695 "OSPF area ID in IP address format\n"
1696 "OSPF area ID as a decimal value\n"
1697 "Set the summary-default cost of a NSSA or stub area\n"
1698 "Stub's advertised default summary cost\n")
1699{
68980084 1700 struct ospf *ospf = vty->index;
718e3744 1701 struct ospf_area *area;
1702 struct in_addr area_id;
1703 u_int32_t cost;
1704 int format;
ba682537 1705 struct prefix_ipv4 p;
718e3744 1706
1707 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1708 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1709
68980084 1710 area = ospf_area_get (ospf, area_id, format);
718e3744 1711
1712 if (area->external_routing == OSPF_AREA_DEFAULT)
1713 {
1714 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1715 return CMD_WARNING;
1716 }
1717
1718 area->default_cost = cost;
1719
ba682537 1720 p.family = AF_INET;
1721 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1722 p.prefixlen = 0;
1723 if (IS_DEBUG_OSPF_EVENT)
1724 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1725 "announcing 0.0.0.0/0 to area %s",
1726 inet_ntoa (area->area_id));
1727 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1728
718e3744 1729 return CMD_SUCCESS;
1730}
1731
a2c62831 1732DEFUN (no_ospf_area_default_cost,
1733 no_ospf_area_default_cost_cmd,
718e3744 1734 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1735 NO_STR
1736 "OSPF area parameters\n"
1737 "OSPF area ID in IP address format\n"
1738 "OSPF area ID as a decimal value\n"
1739 "Set the summary-default cost of a NSSA or stub area\n"
1740 "Stub's advertised default summary cost\n")
1741{
68980084 1742 struct ospf *ospf = vty->index;
718e3744 1743 struct ospf_area *area;
1744 struct in_addr area_id;
1745 u_int32_t cost;
1746 int format;
ba682537 1747 struct prefix_ipv4 p;
718e3744 1748
1749 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1750 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1751
68980084 1752 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 1753 if (area == NULL)
1754 return CMD_SUCCESS;
1755
1756 if (area->external_routing == OSPF_AREA_DEFAULT)
1757 {
1758 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1759 return CMD_WARNING;
1760 }
1761
1762 area->default_cost = 1;
1763
ba682537 1764 p.family = AF_INET;
1765 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1766 p.prefixlen = 0;
1767 if (IS_DEBUG_OSPF_EVENT)
1768 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1769 "announcing 0.0.0.0/0 to area %s",
1770 inet_ntoa (area->area_id));
1771 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1772
1773
68980084 1774 ospf_area_check_free (ospf, area_id);
718e3744 1775
1776 return CMD_SUCCESS;
1777}
1778
a2c62831 1779DEFUN (ospf_area_export_list,
1780 ospf_area_export_list_cmd,
718e3744 1781 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1782 "OSPF area parameters\n"
1783 "OSPF area ID in IP address format\n"
1784 "OSPF area ID as a decimal value\n"
1785 "Set the filter for networks announced to other areas\n"
1786 "Name of the access-list\n")
1787{
68980084 1788 struct ospf *ospf = vty->index;
718e3744 1789 struct ospf_area *area;
1790 struct in_addr area_id;
1791 int format;
1792
52930766 1793 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1794
68980084 1795 area = ospf_area_get (ospf, area_id, format);
1796 ospf_area_export_list_set (ospf, area, argv[1]);
718e3744 1797
1798 return CMD_SUCCESS;
1799}
1800
a2c62831 1801DEFUN (no_ospf_area_export_list,
1802 no_ospf_area_export_list_cmd,
718e3744 1803 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1804 NO_STR
1805 "OSPF area parameters\n"
1806 "OSPF area ID in IP address format\n"
1807 "OSPF area ID as a decimal value\n"
1808 "Unset the filter for networks announced to other areas\n"
1809 "Name of the access-list\n")
1810{
68980084 1811 struct ospf *ospf = vty->index;
718e3744 1812 struct ospf_area *area;
1813 struct in_addr area_id;
1814 int format;
1815
52930766 1816 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1817
68980084 1818 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 1819 if (area == NULL)
1820 return CMD_SUCCESS;
1821
68980084 1822 ospf_area_export_list_unset (ospf, area);
718e3744 1823
1824 return CMD_SUCCESS;
1825}
1826
1827
a2c62831 1828DEFUN (ospf_area_import_list,
1829 ospf_area_import_list_cmd,
718e3744 1830 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1831 "OSPF area parameters\n"
1832 "OSPF area ID in IP address format\n"
1833 "OSPF area ID as a decimal value\n"
1834 "Set the filter for networks from other areas announced to the specified one\n"
1835 "Name of the access-list\n")
1836{
68980084 1837 struct ospf *ospf = vty->index;
718e3744 1838 struct ospf_area *area;
1839 struct in_addr area_id;
1840 int format;
1841
52930766 1842 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1843
68980084 1844 area = ospf_area_get (ospf, area_id, format);
1845 ospf_area_import_list_set (ospf, area, argv[1]);
718e3744 1846
1847 return CMD_SUCCESS;
1848}
1849
a2c62831 1850DEFUN (no_ospf_area_import_list,
1851 no_ospf_area_import_list_cmd,
718e3744 1852 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1853 NO_STR
1854 "OSPF area parameters\n"
1855 "OSPF area ID in IP address format\n"
1856 "OSPF area ID as a decimal value\n"
1857 "Unset the filter for networks announced to other areas\n"
1858 "Name of the access-list\n")
1859{
68980084 1860 struct ospf *ospf = vty->index;
718e3744 1861 struct ospf_area *area;
1862 struct in_addr area_id;
1863 int format;
1864
52930766 1865 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1866
68980084 1867 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 1868 if (area == NULL)
1869 return CMD_SUCCESS;
1870
68980084 1871 ospf_area_import_list_unset (ospf, area);
718e3744 1872
1873 return CMD_SUCCESS;
1874}
1875
a2c62831 1876DEFUN (ospf_area_filter_list,
1877 ospf_area_filter_list_cmd,
718e3744 1878 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1879 "OSPF area parameters\n"
1880 "OSPF area ID in IP address format\n"
1881 "OSPF area ID as a decimal value\n"
1882 "Filter networks between OSPF areas\n"
1883 "Filter prefixes between OSPF areas\n"
1884 "Name of an IP prefix-list\n"
1885 "Filter networks sent to this area\n"
1886 "Filter networks sent from this area\n")
1887{
68980084 1888 struct ospf *ospf = vty->index;
718e3744 1889 struct ospf_area *area;
1890 struct in_addr area_id;
1891 struct prefix_list *plist;
1892 int format;
1893
1894 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1895
68980084 1896 area = ospf_area_get (ospf, area_id, format);
718e3744 1897 plist = prefix_list_lookup (AFI_IP, argv[1]);
1898 if (strncmp (argv[2], "in", 2) == 0)
1899 {
1900 PREFIX_LIST_IN (area) = plist;
1901 if (PREFIX_NAME_IN (area))
1902 free (PREFIX_NAME_IN (area));
1903
1904 PREFIX_NAME_IN (area) = strdup (argv[1]);
68980084 1905 ospf_schedule_abr_task (ospf);
718e3744 1906 }
1907 else
1908 {
1909 PREFIX_LIST_OUT (area) = plist;
1910 if (PREFIX_NAME_OUT (area))
1911 free (PREFIX_NAME_OUT (area));
1912
1913 PREFIX_NAME_OUT (area) = strdup (argv[1]);
68980084 1914 ospf_schedule_abr_task (ospf);
718e3744 1915 }
1916
1917 return CMD_SUCCESS;
1918}
1919
a2c62831 1920DEFUN (no_ospf_area_filter_list,
1921 no_ospf_area_filter_list_cmd,
718e3744 1922 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1923 NO_STR
1924 "OSPF area parameters\n"
1925 "OSPF area ID in IP address format\n"
1926 "OSPF area ID as a decimal value\n"
1927 "Filter networks between OSPF areas\n"
1928 "Filter prefixes between OSPF areas\n"
1929 "Name of an IP prefix-list\n"
1930 "Filter networks sent to this area\n"
1931 "Filter networks sent from this area\n")
1932{
68980084 1933 struct ospf *ospf = vty->index;
718e3744 1934 struct ospf_area *area;
1935 struct in_addr area_id;
1936 struct prefix_list *plist;
1937 int format;
1938
1939 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1940
1a8ec2b9
PJ
1941 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1942 return CMD_SUCCESS;
1943
718e3744 1944 plist = prefix_list_lookup (AFI_IP, argv[1]);
1945 if (strncmp (argv[2], "in", 2) == 0)
1946 {
1947 if (PREFIX_NAME_IN (area))
1948 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1949 return CMD_SUCCESS;
1950
1951 PREFIX_LIST_IN (area) = NULL;
1952 if (PREFIX_NAME_IN (area))
1953 free (PREFIX_NAME_IN (area));
1954
1955 PREFIX_NAME_IN (area) = NULL;
1956
68980084 1957 ospf_schedule_abr_task (ospf);
718e3744 1958 }
1959 else
1960 {
1961 if (PREFIX_NAME_OUT (area))
1962 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1963 return CMD_SUCCESS;
1964
1965 PREFIX_LIST_OUT (area) = NULL;
1966 if (PREFIX_NAME_OUT (area))
1967 free (PREFIX_NAME_OUT (area));
1968
1969 PREFIX_NAME_OUT (area) = NULL;
1970
68980084 1971 ospf_schedule_abr_task (ospf);
718e3744 1972 }
1973
1974 return CMD_SUCCESS;
1975}
1976
1977\f
a2c62831 1978DEFUN (ospf_area_authentication_message_digest,
1979 ospf_area_authentication_message_digest_cmd,
718e3744 1980 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1981 "OSPF area parameters\n"
1982 "Enable authentication\n"
1983 "Use message-digest authentication\n")
1984{
68980084 1985 struct ospf *ospf = vty->index;
718e3744 1986 struct ospf_area *area;
1987 struct in_addr area_id;
1988 int format;
1989
1990 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1991
68980084 1992 area = ospf_area_get (ospf, area_id, format);
718e3744 1993 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1994
1995 return CMD_SUCCESS;
1996}
1997
a2c62831 1998DEFUN (ospf_area_authentication,
1999 ospf_area_authentication_cmd,
718e3744 2000 "area (A.B.C.D|<0-4294967295>) authentication",
2001 "OSPF area parameters\n"
2002 "OSPF area ID in IP address format\n"
2003 "OSPF area ID as a decimal value\n"
2004 "Enable authentication\n")
2005{
68980084 2006 struct ospf *ospf = vty->index;
718e3744 2007 struct ospf_area *area;
2008 struct in_addr area_id;
2009 int format;
2010
2011 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2012
68980084 2013 area = ospf_area_get (ospf, area_id, format);
718e3744 2014 area->auth_type = OSPF_AUTH_SIMPLE;
2015
2016 return CMD_SUCCESS;
2017}
2018
a2c62831 2019DEFUN (no_ospf_area_authentication,
2020 no_ospf_area_authentication_cmd,
718e3744 2021 "no area (A.B.C.D|<0-4294967295>) authentication",
2022 NO_STR
2023 "OSPF area parameters\n"
2024 "OSPF area ID in IP address format\n"
2025 "OSPF area ID as a decimal value\n"
2026 "Enable authentication\n")
2027{
68980084 2028 struct ospf *ospf = vty->index;
718e3744 2029 struct ospf_area *area;
2030 struct in_addr area_id;
2031 int format;
2032
2033 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2034
68980084 2035 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 2036 if (area == NULL)
2037 return CMD_SUCCESS;
2038
2039 area->auth_type = OSPF_AUTH_NULL;
2040
68980084 2041 ospf_area_check_free (ospf, area_id);
718e3744 2042
2043 return CMD_SUCCESS;
2044}
2045
2046\f
2047DEFUN (ospf_abr_type,
2048 ospf_abr_type_cmd,
2049 "ospf abr-type (cisco|ibm|shortcut|standard)",
2050 "OSPF specific commands\n"
2051 "Set OSPF ABR type\n"
2052 "Alternative ABR, cisco implementation\n"
2053 "Alternative ABR, IBM implementation\n"
2054 "Shortcut ABR\n"
2055 "Standard behavior (RFC2328)\n")
2056{
68980084 2057 struct ospf *ospf = vty->index;
718e3744 2058 u_char abr_type = OSPF_ABR_UNKNOWN;
2059
2060 if (strncmp (argv[0], "c", 1) == 0)
2061 abr_type = OSPF_ABR_CISCO;
2062 else if (strncmp (argv[0], "i", 1) == 0)
2063 abr_type = OSPF_ABR_IBM;
2064 else if (strncmp (argv[0], "sh", 2) == 0)
2065 abr_type = OSPF_ABR_SHORTCUT;
2066 else if (strncmp (argv[0], "st", 2) == 0)
2067 abr_type = OSPF_ABR_STAND;
2068 else
2069 return CMD_WARNING;
2070
2071 /* If ABR type value is changed, schedule ABR task. */
68980084 2072 if (ospf->abr_type != abr_type)
718e3744 2073 {
68980084 2074 ospf->abr_type = abr_type;
2075 ospf_schedule_abr_task (ospf);
718e3744 2076 }
2077
2078 return CMD_SUCCESS;
2079}
2080
2081DEFUN (no_ospf_abr_type,
2082 no_ospf_abr_type_cmd,
d57834f6 2083 "no ospf abr-type (cisco|ibm|shortcut|standard)",
718e3744 2084 NO_STR
2085 "OSPF specific commands\n"
2086 "Set OSPF ABR type\n"
2087 "Alternative ABR, cisco implementation\n"
2088 "Alternative ABR, IBM implementation\n"
2089 "Shortcut ABR\n")
2090{
68980084 2091 struct ospf *ospf = vty->index;
718e3744 2092 u_char abr_type = OSPF_ABR_UNKNOWN;
2093
2094 if (strncmp (argv[0], "c", 1) == 0)
2095 abr_type = OSPF_ABR_CISCO;
2096 else if (strncmp (argv[0], "i", 1) == 0)
2097 abr_type = OSPF_ABR_IBM;
04d23314 2098 else if (strncmp (argv[0], "sh", 2) == 0)
718e3744 2099 abr_type = OSPF_ABR_SHORTCUT;
04d23314
FD
2100 else if (strncmp (argv[0], "st", 2) == 0)
2101 abr_type = OSPF_ABR_STAND;
718e3744 2102 else
2103 return CMD_WARNING;
2104
2105 /* If ABR type value is changed, schedule ABR task. */
68980084 2106 if (ospf->abr_type == abr_type)
718e3744 2107 {
d57834f6 2108 ospf->abr_type = OSPF_ABR_DEFAULT;
68980084 2109 ospf_schedule_abr_task (ospf);
718e3744 2110 }
2111
2112 return CMD_SUCCESS;
2113}
2114
d7e60dd7
AS
2115DEFUN (ospf_log_adjacency_changes,
2116 ospf_log_adjacency_changes_cmd,
2117 "log-adjacency-changes",
2118 "Log changes in adjacency state\n")
2119{
2120 struct ospf *ospf = vty->index;
2121
2122 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2123 return CMD_SUCCESS;
2124}
2125
2126DEFUN (ospf_log_adjacency_changes_detail,
2127 ospf_log_adjacency_changes_detail_cmd,
2128 "log-adjacency-changes detail",
2129 "Log changes in adjacency state\n"
2130 "Log all state changes\n")
2131{
2132 struct ospf *ospf = vty->index;
2133
2134 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2135 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2136 return CMD_SUCCESS;
2137}
2138
2139DEFUN (no_ospf_log_adjacency_changes,
2140 no_ospf_log_adjacency_changes_cmd,
2141 "no log-adjacency-changes",
2142 NO_STR
2143 "Log changes in adjacency state\n")
2144{
2145 struct ospf *ospf = vty->index;
2146
2147 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2148 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2149 return CMD_SUCCESS;
2150}
2151
2152DEFUN (no_ospf_log_adjacency_changes_detail,
2153 no_ospf_log_adjacency_changes_detail_cmd,
2154 "no log-adjacency-changes detail",
2155 NO_STR
2156 "Log changes in adjacency state\n"
2157 "Log all state changes\n")
2158{
2159 struct ospf *ospf = vty->index;
2160
2161 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2162 return CMD_SUCCESS;
2163}
2164
718e3744 2165DEFUN (ospf_compatible_rfc1583,
2166 ospf_compatible_rfc1583_cmd,
2167 "compatible rfc1583",
2168 "OSPF compatibility list\n"
2169 "compatible with RFC 1583\n")
2170{
2171 struct ospf *ospf = vty->index;
2172
2173 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2174 {
2175 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
68980084 2176 ospf_spf_calculate_schedule (ospf);
718e3744 2177 }
2178 return CMD_SUCCESS;
2179}
2180
2181DEFUN (no_ospf_compatible_rfc1583,
2182 no_ospf_compatible_rfc1583_cmd,
2183 "no compatible rfc1583",
2184 NO_STR
2185 "OSPF compatibility list\n"
2186 "compatible with RFC 1583\n")
2187{
2188 struct ospf *ospf = vty->index;
2189
2190 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2191 {
2192 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
68980084 2193 ospf_spf_calculate_schedule (ospf);
718e3744 2194 }
2195 return CMD_SUCCESS;
2196}
2197
2198ALIAS (ospf_compatible_rfc1583,
2199 ospf_rfc1583_flag_cmd,
2200 "ospf rfc1583compatibility",
2201 "OSPF specific commands\n"
2202 "Enable the RFC1583Compatibility flag\n")
2203
2204ALIAS (no_ospf_compatible_rfc1583,
2205 no_ospf_rfc1583_flag_cmd,
2206 "no ospf rfc1583compatibility",
2207 NO_STR
2208 "OSPF specific commands\n"
2209 "Disable the RFC1583Compatibility flag\n")
d24f6e2a 2210\f
2211static int
2212ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2213 unsigned int hold,
2214 unsigned int max)
2215{
2216 struct ospf *ospf = vty->index;
2217
2218 ospf->spf_delay = delay;
2219 ospf->spf_holdtime = hold;
2220 ospf->spf_max_holdtime = max;
2221
2222 return CMD_SUCCESS;
2223}
718e3744 2224
d24f6e2a 2225DEFUN (ospf_timers_throttle_spf,
2226 ospf_timers_throttle_spf_cmd,
2227 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2228 "Adjust routing timers\n"
2229 "Throttling adaptive timer\n"
2230 "OSPF SPF timers\n"
2231 "Delay (msec) from first change received till SPF calculation\n"
2232 "Initial hold time (msec) between consecutive SPF calculations\n"
2233 "Maximum hold time (msec)\n")
2234{
2235 unsigned int delay, hold, max;
2236
2237 if (argc != 3)
2238 {
2239 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2240 return CMD_WARNING;
2241 }
2242
2243 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2244 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2245 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2246
2247 return ospf_timers_spf_set (vty, delay, hold, max);
2248}
2249
2250DEFUN_DEPRECATED (ospf_timers_spf,
a2c62831 2251 ospf_timers_spf_cmd,
718e3744 2252 "timers spf <0-4294967295> <0-4294967295>",
2253 "Adjust routing timers\n"
2254 "OSPF SPF timers\n"
d24f6e2a 2255 "Delay (s) between receiving a change to SPF calculation\n"
2256 "Hold time (s) between consecutive SPF calculations\n")
718e3744 2257{
d24f6e2a 2258 unsigned int delay, hold;
2259
2260 if (argc != 2)
2261 {
2262 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2263 return CMD_WARNING;
2264 }
2265
4dadc291 2266 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2267 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
d24f6e2a 2268
2269 /* truncate down the second values if they're greater than 600000ms */
2270 if (delay > (600000 / 1000))
2271 delay = 600000;
2272 else if (delay == 0)
2273 /* 0s delay was probably specified because of lack of ms resolution */
2274 delay = OSPF_SPF_DELAY_DEFAULT;
2275 if (hold > (600000 / 1000))
2276 hold = 600000;
2277
2278 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
718e3744 2279}
2280
d24f6e2a 2281DEFUN (no_ospf_timers_throttle_spf,
2282 no_ospf_timers_throttle_spf_cmd,
2283 "no timers throttle spf",
718e3744 2284 NO_STR
2285 "Adjust routing timers\n"
d24f6e2a 2286 "Throttling adaptive timer\n"
718e3744 2287 "OSPF SPF timers\n")
2288{
d24f6e2a 2289 return ospf_timers_spf_set (vty,
2290 OSPF_SPF_DELAY_DEFAULT,
2291 OSPF_SPF_HOLDTIME_DEFAULT,
2292 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
718e3744 2293}
2294
d24f6e2a 2295ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2296 no_ospf_timers_spf_cmd,
2297 "no timers spf",
2298 NO_STR
2299 "Adjust routing timers\n"
2300 "OSPF SPF timers\n")
718e3744 2301\f
a2c62831 2302DEFUN (ospf_neighbor,
2303 ospf_neighbor_cmd,
718e3744 2304 "neighbor A.B.C.D",
2305 NEIGHBOR_STR
2306 "Neighbor IP address\n")
2307{
2308 struct ospf *ospf = vty->index;
2309 struct in_addr nbr_addr;
eb1ce605 2310 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2311 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
718e3744 2312
2313 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2314
2315 if (argc > 1)
2316 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2317
2318 if (argc > 2)
2319 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2320
2321 ospf_nbr_nbma_set (ospf, nbr_addr);
2322 if (argc > 1)
2323 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2324 if (argc > 2)
2325 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
2326
2327 return CMD_SUCCESS;
2328}
2329
a2c62831 2330ALIAS (ospf_neighbor,
2331 ospf_neighbor_priority_poll_interval_cmd,
718e3744 2332 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2333 NEIGHBOR_STR
2334 "Neighbor IP address\n"
2335 "Neighbor Priority\n"
2336 "Priority\n"
2337 "Dead Neighbor Polling interval\n"
2338 "Seconds\n")
2339
a2c62831 2340ALIAS (ospf_neighbor,
2341 ospf_neighbor_priority_cmd,
718e3744 2342 "neighbor A.B.C.D priority <0-255>",
2343 NEIGHBOR_STR
2344 "Neighbor IP address\n"
2345 "Neighbor Priority\n"
2346 "Seconds\n")
2347
a2c62831 2348DEFUN (ospf_neighbor_poll_interval,
2349 ospf_neighbor_poll_interval_cmd,
718e3744 2350 "neighbor A.B.C.D poll-interval <1-65535>",
2351 NEIGHBOR_STR
2352 "Neighbor IP address\n"
2353 "Dead Neighbor Polling interval\n"
2354 "Seconds\n")
2355{
2356 struct ospf *ospf = vty->index;
2357 struct in_addr nbr_addr;
eb1ce605 2358 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2359 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
718e3744 2360
2361 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2362
2363 if (argc > 1)
2364 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2365
2366 if (argc > 2)
2367 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2368
2369 ospf_nbr_nbma_set (ospf, nbr_addr);
2370 if (argc > 1)
2371 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2372 if (argc > 2)
2373 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2374
2375 return CMD_SUCCESS;
2376}
2377
a2c62831 2378ALIAS (ospf_neighbor_poll_interval,
2379 ospf_neighbor_poll_interval_priority_cmd,
718e3744 2380 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2381 NEIGHBOR_STR
2382 "Neighbor address\n"
2383 "OSPF dead-router polling interval\n"
2384 "Seconds\n"
2385 "OSPF priority of non-broadcast neighbor\n"
2386 "Priority\n")
2387
a2c62831 2388DEFUN (no_ospf_neighbor,
2389 no_ospf_neighbor_cmd,
718e3744 2390 "no neighbor A.B.C.D",
2391 NO_STR
2392 NEIGHBOR_STR
2393 "Neighbor IP address\n")
2394{
2395 struct ospf *ospf = vty->index;
2396 struct in_addr nbr_addr;
2397 int ret;
2398
2399 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2400
2401 ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
2402
2403 return CMD_SUCCESS;
2404}
2405
a2c62831 2406ALIAS (no_ospf_neighbor,
2407 no_ospf_neighbor_priority_cmd,
718e3744 2408 "no neighbor A.B.C.D priority <0-255>",
2409 NO_STR
2410 NEIGHBOR_STR
2411 "Neighbor IP address\n"
2412 "Neighbor Priority\n"
2413 "Priority\n")
2414
a2c62831 2415ALIAS (no_ospf_neighbor,
2416 no_ospf_neighbor_poll_interval_cmd,
718e3744 2417 "no neighbor A.B.C.D poll-interval <1-65535>",
2418 NO_STR
2419 NEIGHBOR_STR
2420 "Neighbor IP address\n"
2421 "Dead Neighbor Polling interval\n"
2422 "Seconds\n")
2423
a2c62831 2424ALIAS (no_ospf_neighbor,
2425 no_ospf_neighbor_priority_pollinterval_cmd,
718e3744 2426 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2427 NO_STR
2428 NEIGHBOR_STR
2429 "Neighbor IP address\n"
2430 "Neighbor Priority\n"
2431 "Priority\n"
2432 "Dead Neighbor Polling interval\n"
2433 "Seconds\n")
2434
2435\f
a2c62831 2436DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
718e3744 2437 "refresh timer <10-1800>",
2438 "Adjust refresh parameters\n"
2439 "Set refresh timer\n"
2440 "Timer value in seconds\n")
2441{
2442 struct ospf *ospf = vty->index;
eb1ce605 2443 unsigned int interval;
718e3744 2444
2445 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2446 interval = (interval / 10) * 10;
2447
2448 ospf_timers_refresh_set (ospf, interval);
2449
2450 return CMD_SUCCESS;
2451}
2452
a2c62831 2453DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
718e3744 2454 "no refresh timer <10-1800>",
2455 "Adjust refresh parameters\n"
2456 "Unset refresh timer\n"
2457 "Timer value in seconds\n")
2458{
2459 struct ospf *ospf = vty->index;
eb1ce605 2460 unsigned int interval;
718e3744 2461
2462 if (argc == 1)
2463 {
2464 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2465
2466 if (ospf->lsa_refresh_interval != interval ||
2467 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2468 return CMD_SUCCESS;
2469 }
2470
2471 ospf_timers_refresh_unset (ospf);
2472
2473 return CMD_SUCCESS;
2474}
2475
a2c62831 2476ALIAS (no_ospf_refresh_timer,
2477 no_ospf_refresh_timer_cmd,
718e3744 2478 "no refresh timer",
2479 "Adjust refresh parameters\n"
2480 "Unset refresh timer\n")
2481
a2c62831 2482DEFUN (ospf_auto_cost_reference_bandwidth,
2483 ospf_auto_cost_reference_bandwidth_cmd,
718e3744 2484 "auto-cost reference-bandwidth <1-4294967>",
2485 "Calculate OSPF interface cost according to bandwidth\n"
2486 "Use reference bandwidth method to assign OSPF cost\n"
2487 "The reference bandwidth in terms of Mbits per second\n")
2488{
68980084 2489 struct ospf *ospf = vty->index;
718e3744 2490 u_int32_t refbw;
52dc7ee6 2491 struct listnode *node;
1eb8ef25 2492 struct interface *ifp;
718e3744 2493
2494 refbw = strtol (argv[0], NULL, 10);
2495 if (refbw < 1 || refbw > 4294967)
2496 {
2497 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2498 return CMD_WARNING;
2499 }
2500
2501 /* If reference bandwidth is changed. */
68980084 2502 if ((refbw * 1000) == ospf->ref_bandwidth)
718e3744 2503 return CMD_SUCCESS;
2504
68980084 2505 ospf->ref_bandwidth = refbw * 1000;
1eb8ef25 2506 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2507 ospf_if_recalculate_output_cost (ifp);
718e3744 2508
2509 return CMD_SUCCESS;
2510}
2511
a2c62831 2512DEFUN (no_ospf_auto_cost_reference_bandwidth,
2513 no_ospf_auto_cost_reference_bandwidth_cmd,
718e3744 2514 "no auto-cost reference-bandwidth",
2515 NO_STR
2516 "Calculate OSPF interface cost according to bandwidth\n"
2517 "Use reference bandwidth method to assign OSPF cost\n")
2518{
68980084 2519 struct ospf *ospf = vty->index;
1eb8ef25 2520 struct listnode *node, *nnode;
2521 struct interface *ifp;
718e3744 2522
68980084 2523 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
718e3744 2524 return CMD_SUCCESS;
2525
68980084 2526 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
718e3744 2527 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2528 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2529
1eb8ef25 2530 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2531 ospf_if_recalculate_output_cost (ifp);
718e3744 2532
2533 return CMD_SUCCESS;
2534}
2535
eb1ce605 2536const char *ospf_abr_type_descr_str[] =
718e3744 2537{
2538 "Unknown",
2539 "Standard (RFC2328)",
2540 "Alternative IBM",
2541 "Alternative Cisco",
2542 "Alternative Shortcut"
2543};
2544
eb1ce605 2545const char *ospf_shortcut_mode_descr_str[] =
718e3744 2546{
2547 "Default",
2548 "Enabled",
2549 "Disabled"
2550};
2551
2552
2553\f
4dadc291 2554static void
718e3744 2555show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2556{
2557 /* Show Area ID. */
2558 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2559
2560 /* Show Area type/mode. */
2561 if (OSPF_IS_AREA_BACKBONE (area))
2562 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2563 else
2564 {
2565 if (area->external_routing == OSPF_AREA_STUB)
b0a053be 2566 vty_out (vty, " (Stub%s%s)",
2567 area->no_summary ? ", no summary" : "",
2568 area->shortcut_configured ? "; " : "");
718e3744 2569
b0a053be 2570 else if (area->external_routing == OSPF_AREA_NSSA)
2571 vty_out (vty, " (NSSA%s%s)",
2572 area->no_summary ? ", no summary" : "",
2573 area->shortcut_configured ? "; " : "");
718e3744 2574
2575 vty_out (vty, "%s", VTY_NEWLINE);
2576 vty_out (vty, " Shortcutting mode: %s",
b0a053be 2577 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
718e3744 2578 vty_out (vty, ", S-bit consensus: %s%s",
b0a053be 2579 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
718e3744 2580 }
2581
2582 /* Show number of interfaces. */
2583 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2584 "Active: %d%s", listcount (area->oiflist),
2585 area->act_ints, VTY_NEWLINE);
2586
718e3744 2587 if (area->external_routing == OSPF_AREA_NSSA)
2588 {
2589 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
020709f9 2590 if (! IS_OSPF_ABR (area->ospf))
b0a053be 2591 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2592 VTY_NEWLINE);
2593 else if (area->NSSATranslatorState)
2594 {
2595 vty_out (vty, " We are an ABR and ");
2596 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2597 vty_out (vty, "the NSSA Elected Translator. %s",
2598 VTY_NEWLINE);
2599 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2600 vty_out (vty, "always an NSSA Translator. %s",
2601 VTY_NEWLINE);
2602 }
718e3744 2603 else
b0a053be 2604 {
2605 vty_out (vty, " We are an ABR, but ");
2606 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2607 vty_out (vty, "not the NSSA Elected Translator. %s",
2608 VTY_NEWLINE);
2609 else
c6b87819 2610 vty_out (vty, "never an NSSA Translator. %s",
b0a053be 2611 VTY_NEWLINE);
2612 }
718e3744 2613 }
88d6cf37 2614 /* Stub-router state for this area */
2615 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2616 {
649654ab 2617 char timebuf[OSPF_TIME_DUMP_SIZE];
88d6cf37 2618 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2619 VTY_NEWLINE);
2620 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2621 vty_out (vty, " Administratively activated (indefinitely)%s",
2622 VTY_NEWLINE);
2623 if (area->t_stub_router)
2624 vty_out (vty, " Active from startup, %s remaining%s",
2625 ospf_timer_dump (area->t_stub_router, timebuf,
2626 sizeof(timebuf)), VTY_NEWLINE);
2627 }
2628
718e3744 2629 /* Show number of fully adjacent neighbors. */
2630 vty_out (vty, " Number of fully adjacent neighbors in this area:"
b0a053be 2631 " %d%s", area->full_nbrs, VTY_NEWLINE);
718e3744 2632
2633 /* Show authentication type. */
2634 vty_out (vty, " Area has ");
2635 if (area->auth_type == OSPF_AUTH_NULL)
2636 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2637 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2638 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2639 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2640 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2641
2642 if (!OSPF_IS_AREA_BACKBONE (area))
2643 vty_out (vty, " Number of full virtual adjacencies going through"
2644 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2645
2646 /* Show SPF calculation times. */
2647 vty_out (vty, " SPF algorithm executed %d times%s",
2648 area->spf_calculation, VTY_NEWLINE);
2649
2650 /* Show number of LSA. */
2651 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
fe71a97d 2652 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2653 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2654 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2655 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2656 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2657 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2658 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2659 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2660 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2661 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2662 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2663 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2664 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2665 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2666 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2667#ifdef HAVE_OPAQUE_LSA
2668 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2669 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2670 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2671 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2672 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2673 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2674#endif /* HAVE_OPAQUE_LSA */
718e3744 2675 vty_out (vty, "%s", VTY_NEWLINE);
2676}
2677
2678DEFUN (show_ip_ospf,
2679 show_ip_ospf_cmd,
2680 "show ip ospf",
2681 SHOW_STR
2682 IP_STR
2683 "OSPF information\n")
2684{
1eb8ef25 2685 struct listnode *node, *nnode;
718e3744 2686 struct ospf_area * area;
020709f9 2687 struct ospf *ospf;
d24f6e2a 2688 struct timeval result;
649654ab 2689 char timebuf[OSPF_TIME_DUMP_SIZE];
718e3744 2690
2691 /* Check OSPF is enable. */
020709f9 2692 ospf = ospf_lookup ();
68980084 2693 if (ospf == NULL)
718e3744 2694 {
2695 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2696 return CMD_SUCCESS;
2697 }
2698
2699 /* Show Router ID. */
2700 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
68980084 2701 inet_ntoa (ospf->router_id),
718e3744 2702 VTY_NEWLINE);
88d6cf37 2703
2704 /* Graceful shutdown */
c9c93d50 2705 if (ospf->t_deferred_shutdown)
2706 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2707 ospf_timer_dump (ospf->t_deferred_shutdown,
88d6cf37 2708 timebuf, sizeof (timebuf)), VTY_NEWLINE);
718e3744 2709 /* Show capability. */
2710 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2711 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2712 vty_out (vty, " RFC1583Compatibility flag is %s%s",
68980084 2713 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
718e3744 2714 "enabled" : "disabled", VTY_NEWLINE);
2715#ifdef HAVE_OPAQUE_LSA
2716 vty_out (vty, " OpaqueCapability flag is %s%s%s",
68980084 2717 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
718e3744 2718 "enabled" : "disabled",
68980084 2719 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
718e3744 2720 " (origination blocked)" : "",
2721 VTY_NEWLINE);
2722#endif /* HAVE_OPAQUE_LSA */
88d6cf37 2723
2724 /* Show stub-router configuration */
2725 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2726 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2727 {
2728 vty_out (vty, " Stub router advertisement is configured%s",
2729 VTY_NEWLINE);
2730 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2731 vty_out (vty, " Enabled for %us after start-up%s",
2732 ospf->stub_router_startup_time, VTY_NEWLINE);
2733 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2734 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2735 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2736 }
2737
718e3744 2738 /* Show SPF timers. */
d24f6e2a 2739 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2740 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2741 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2742 " Hold time multiplier is currently %d%s",
2743 ospf->spf_delay, VTY_NEWLINE,
2744 ospf->spf_holdtime, VTY_NEWLINE,
2745 ospf->spf_max_holdtime, VTY_NEWLINE,
2746 ospf->spf_hold_multiplier, VTY_NEWLINE);
b8ad39d4 2747 vty_out (vty, " SPF algorithm ");
2748 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2749 {
2518efd1 2750 result = tv_sub (recent_relative_time (), ospf->ts_spf);
b8ad39d4 2751 vty_out (vty, "last executed %s ago%s",
2752 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2753 VTY_NEWLINE);
2754 }
2755 else
2756 vty_out (vty, "has not been run%s", VTY_NEWLINE);
d24f6e2a 2757 vty_out (vty, " SPF timer %s%s%s",
2758 (ospf->t_spf_calc ? "due in " : "is "),
2759 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2760 VTY_NEWLINE);
2761
718e3744 2762 /* Show refresh parameters. */
2763 vty_out (vty, " Refresh timer %d secs%s",
68980084 2764 ospf->lsa_refresh_interval, VTY_NEWLINE);
718e3744 2765
2766 /* Show ABR/ASBR flags. */
68980084 2767 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
718e3744 2768 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
68980084 2769 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
718e3744 2770
68980084 2771 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
718e3744 2772 vty_out (vty, " This router is an ASBR "
2773 "(injecting external routing information)%s", VTY_NEWLINE);
2774
2775 /* Show Number of AS-external-LSAs. */
fe71a97d 2776 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2777 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2778 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2779#ifdef HAVE_OPAQUE_LSA
2780 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2781 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2782 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2783#endif /* HAVE_OPAQUE_LSA */
718e3744 2784 /* Show number of areas attached. */
d7e60dd7
AS
2785 vty_out (vty, " Number of areas attached to this router: %d%s",
2786 listcount (ospf->areas), VTY_NEWLINE);
2787
2788 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2789 {
2790 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2791 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2792 else
2793 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2794 }
2795
2796 vty_out (vty, "%s",VTY_NEWLINE);
718e3744 2797
2798 /* Show each area status. */
1eb8ef25 2799 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2800 show_ip_ospf_area (vty, area);
718e3744 2801
2802 return CMD_SUCCESS;
2803}
2804
2805\f
fd651fa6 2806static void
68980084 2807show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2808 struct interface *ifp)
718e3744 2809{
fd651fa6 2810 int is_up;
718e3744 2811 struct ospf_neighbor *nbr;
718e3744 2812 struct route_node *rn;
718e3744 2813
718e3744 2814 /* Is interface up? */
fd651fa6 2815 vty_out (vty, "%s is %s%s", ifp->name,
2816 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
d2fc8896 2817 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2818 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2819 VTY_NEWLINE);
718e3744 2820
2821 /* Is interface OSPF enabled? */
fd651fa6 2822 if (ospf_oi_count(ifp) == 0)
718e3744 2823 {
2824 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2825 return;
2826 }
fd651fa6 2827 else if (!is_up)
2828 {
2829 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2830 VTY_NEWLINE);
2831 return;
2832 }
2833
718e3744 2834 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2835 {
2836 struct ospf_interface *oi = rn->info;
2837
2838 if (oi == NULL)
2839 continue;
2840
2841 /* Show OSPF interface information. */
2842 vty_out (vty, " Internet Address %s/%d,",
2843 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2844
9c27ef9b
PJ
2845 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2846 {
2847 struct in_addr *dest;
2848 const char *dstr;
2849
e4529636
AS
2850 if (CONNECTED_PEER(oi->connected)
2851 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
9c27ef9b
PJ
2852 dstr = "Peer";
2853 else
2854 dstr = "Broadcast";
2855
2856 /* For Vlinks, showing the peer address is probably more
2857 * informative than the local interface that is being used
2858 */
2859 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2860 dest = &oi->vl_data->peer_addr;
2861 else
2862 dest = &oi->connected->destination->u.prefix4;
2863
2864 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2865 }
3fb9cd6e 2866
718e3744 2867 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2868 VTY_NEWLINE);
2869
ba682537 2870 vty_out (vty, " MTU mismatch detection:%s%s",
2871 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2872
718e3744 2873 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
68980084 2874 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
718e3744 2875 oi->output_cost, VTY_NEWLINE);
2876
2877 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2878 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2879 PRIORITY (oi), VTY_NEWLINE);
2880
2881 /* Show DR information. */
2882 if (DR (oi).s_addr == 0)
2883 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2884 else
2885 {
2886 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2887 if (nbr == NULL)
2888 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2889 else
2890 {
2891 vty_out (vty, " Designated Router (ID) %s,",
2892 inet_ntoa (nbr->router_id));
2893 vty_out (vty, " Interface Address %s%s",
2894 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2895 }
2896 }
2897
2898 /* Show BDR information. */
2899 if (BDR (oi).s_addr == 0)
2900 vty_out (vty, " No backup designated router on this network%s",
2901 VTY_NEWLINE);
2902 else
2903 {
2904 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2905 if (nbr == NULL)
2906 vty_out (vty, " No backup designated router on this network%s",
2907 VTY_NEWLINE);
2908 else
2909 {
2910 vty_out (vty, " Backup Designated Router (ID) %s,",
2911 inet_ntoa (nbr->router_id));
2912 vty_out (vty, " Interface Address %s%s",
2913 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2914 }
2915 }
7eb5b47e
PJ
2916
2917 /* Next network-LSA sequence number we'll use, if we're elected DR */
2918 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
2919 != OSPF_INITIAL_SEQUENCE_NUMBER)
2920 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
2921 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
2922
ba6454ec 2923 vty_out (vty, " Multicast group memberships:");
429ac78c
PJ
2924 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2925 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2926 {
2927 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2928 vty_out (vty, " OSPFAllRouters");
2929 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2930 vty_out (vty, " OSPFDesignatedRouters");
2931 }
2932 else
ba6454ec 2933 vty_out (vty, " <None>");
2934 vty_out (vty, "%s", VTY_NEWLINE);
2935
718e3744 2936 vty_out (vty, " Timer intervals configured,");
f9ad937f 2937 vty_out (vty, " Hello ");
2938 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2939 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2940 else
2941 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
2942 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
2943 OSPF_IF_PARAM (oi, v_wait),
718e3744 2944 OSPF_IF_PARAM (oi, v_wait),
2945 OSPF_IF_PARAM (oi, retransmit_interval),
2946 VTY_NEWLINE);
2947
7ffa8fa2 2948 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
f9ad937f 2949 {
649654ab 2950 char timebuf[OSPF_TIME_DUMP_SIZE];
f9ad937f 2951 vty_out (vty, " Hello due in %s%s",
649654ab 2952 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
f9ad937f 2953 VTY_NEWLINE);
2954 }
7ffa8fa2 2955 else /* passive-interface is set */
718e3744 2956 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
2957
2958 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
68980084 2959 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
718e3744 2960 VTY_NEWLINE);
2961 }
2962}
2963
2964DEFUN (show_ip_ospf_interface,
2965 show_ip_ospf_interface_cmd,
2966 "show ip ospf interface [INTERFACE]",
2967 SHOW_STR
2968 IP_STR
2969 "OSPF information\n"
2970 "Interface information\n"
2971 "Interface name\n")
2972{
2973 struct interface *ifp;
020709f9 2974 struct ospf *ospf;
52dc7ee6 2975 struct listnode *node;
718e3744 2976
020709f9 2977 ospf = ospf_lookup ();
cac3b5c4
PJ
2978 if (ospf == NULL)
2979 {
2980 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
2981 return CMD_SUCCESS;
2982 }
020709f9 2983
718e3744 2984 /* Show All Interfaces. */
2985 if (argc == 0)
1eb8ef25 2986 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
2987 show_ip_ospf_interface_sub (vty, ospf, ifp);
718e3744 2988 /* Interface name is specified. */
2989 else
2990 {
2991 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
2992 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
2993 else
68980084 2994 show_ip_ospf_interface_sub (vty, ospf, ifp);
718e3744 2995 }
2996
2997 return CMD_SUCCESS;
2998}
2999
d24f6e2a 3000static void
3001show_ip_ospf_neighbour_header (struct vty *vty)
3002{
3003 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3004 VTY_NEWLINE,
3005 "Neighbor ID", "Pri", "State", "Dead Time",
3006 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3007 VTY_NEWLINE);
3008}
3009
4dadc291 3010static void
718e3744 3011show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3012{
3013 struct route_node *rn;
3014 struct ospf_neighbor *nbr;
3015 char msgbuf[16];
649654ab 3016 char timebuf[OSPF_TIME_DUMP_SIZE];
718e3744 3017
3018 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3019 if ((nbr = rn->info))
3020 /* Do not show myself. */
3021 if (nbr != oi->nbr_self)
3022 /* Down state is not shown. */
3023 if (nbr->state != NSM_Down)
3024 {
3025 ospf_nbr_state_message (nbr, msgbuf, 16);
3026
3027 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
d24f6e2a 3028 vty_out (vty, "%-15s %3d %-15s ",
3029 "-", nbr->priority,
3030 msgbuf);
3031 else
3032 vty_out (vty, "%-15s %3d %-15s ",
3033 inet_ntoa (nbr->router_id), nbr->priority,
3034 msgbuf);
3035
3036 vty_out (vty, "%9s ",
3037 ospf_timer_dump (nbr->t_inactivity, timebuf,
3038 sizeof(timebuf)));
3039
718e3744 3040 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
d24f6e2a 3041 vty_out (vty, "%-20s %5ld %5ld %5d%s",
718e3744 3042 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3043 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3044 VTY_NEWLINE);
3045 }
3046}
3047
3048DEFUN (show_ip_ospf_neighbor,
3049 show_ip_ospf_neighbor_cmd,
3050 "show ip ospf neighbor",
3051 SHOW_STR
3052 IP_STR
3053 "OSPF information\n"
3054 "Neighbor list\n")
3055{
020709f9 3056 struct ospf *ospf;
1eb8ef25 3057 struct ospf_interface *oi;
52dc7ee6 3058 struct listnode *node;
718e3744 3059
020709f9 3060 ospf = ospf_lookup ();
68980084 3061 if (ospf == NULL)
718e3744 3062 {
3063 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3064 return CMD_SUCCESS;
3065 }
3066
d24f6e2a 3067 show_ip_ospf_neighbour_header (vty);
718e3744 3068
1eb8ef25 3069 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3070 show_ip_ospf_neighbor_sub (vty, oi);
718e3744 3071
3072 return CMD_SUCCESS;
3073}
3074
3075DEFUN (show_ip_ospf_neighbor_all,
3076 show_ip_ospf_neighbor_all_cmd,
3077 "show ip ospf neighbor all",
3078 SHOW_STR
3079 IP_STR
3080 "OSPF information\n"
3081 "Neighbor list\n"
3082 "include down status neighbor\n")
3083{
35f89140 3084 struct ospf *ospf = ospf_lookup ();
52dc7ee6 3085 struct listnode *node;
1eb8ef25 3086 struct ospf_interface *oi;
718e3744 3087
68980084 3088 if (ospf == NULL)
718e3744 3089 {
3090 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3091 return CMD_SUCCESS;
3092 }
d24f6e2a 3093
3094 show_ip_ospf_neighbour_header (vty);
3095
1eb8ef25 3096 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
718e3744 3097 {
52dc7ee6 3098 struct listnode *nbr_node;
1eb8ef25 3099 struct ospf_nbr_nbma *nbr_nbma;
718e3744 3100
3101 show_ip_ospf_neighbor_sub (vty, oi);
3102
3103 /* print Down neighbor status */
1eb8ef25 3104 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
718e3744 3105 {
718e3744 3106 if (nbr_nbma->nbr == NULL
3107 || nbr_nbma->nbr->state == NSM_Down)
3108 {
d24f6e2a 3109 vty_out (vty, "%-15s %3d %-15s %9s ",
718e3744 3110 "-", nbr_nbma->priority, "Down", "-");
d24f6e2a 3111 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
718e3744 3112 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3113 0, 0, 0, VTY_NEWLINE);
3114 }
3115 }
3116 }
3117
3118 return CMD_SUCCESS;
3119}
3120
3121DEFUN (show_ip_ospf_neighbor_int,
3122 show_ip_ospf_neighbor_int_cmd,
bb5b7552 3123 "show ip ospf neighbor IFNAME",
718e3744 3124 SHOW_STR
3125 IP_STR
3126 "OSPF information\n"
3127 "Neighbor list\n"
3128 "Interface name\n")
3129{
020709f9 3130 struct ospf *ospf;
bb5b7552 3131 struct interface *ifp;
3132 struct route_node *rn;
3133
3134 ifp = if_lookup_by_name (argv[0]);
3135 if (!ifp)
718e3744 3136 {
bb5b7552 3137 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
718e3744 3138 return CMD_WARNING;
3139 }
3140
020709f9 3141 ospf = ospf_lookup ();
3142 if (ospf == NULL)
3143 {
3144 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3145 return CMD_SUCCESS;
3146 }
d24f6e2a 3147
3148 show_ip_ospf_neighbour_header (vty);
3149
bb5b7552 3150 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
718e3744 3151 {
bb5b7552 3152 struct ospf_interface *oi = rn->info;
3153
3154 if (oi == NULL)
3155 continue;
3156
718e3744 3157 show_ip_ospf_neighbor_sub (vty, oi);
3158 }
3159
3160 return CMD_SUCCESS;
3161}
3162
4dadc291 3163static void
718e3744 3164show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3165 struct ospf_nbr_nbma *nbr_nbma)
3166{
649654ab 3167 char timebuf[OSPF_TIME_DUMP_SIZE];
718e3744 3168
3169 /* Show neighbor ID. */
3170 vty_out (vty, " Neighbor %s,", "-");
3171
3172 /* Show interface address. */
3173 vty_out (vty, " interface address %s%s",
3174 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3175 /* Show Area ID. */
3176 vty_out (vty, " In the area %s via interface %s%s",
3177 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3178 /* Show neighbor priority and state. */
3179 vty_out (vty, " Neighbor priority is %d, State is %s,",
3180 nbr_nbma->priority, "Down");
3181 /* Show state changes. */
3182 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3183
3184 /* Show PollInterval */
3185 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3186
3187 /* Show poll-interval timer. */
3188 vty_out (vty, " Poll timer due in %s%s",
d24f6e2a 3189 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3190 VTY_NEWLINE);
718e3744 3191
3192 /* Show poll-interval timer thread. */
3193 vty_out (vty, " Thread Poll Timer %s%s",
3194 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3195}
3196
4dadc291 3197static void
718e3744 3198show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3199 struct ospf_neighbor *nbr)
3200{
649654ab 3201 char timebuf[OSPF_TIME_DUMP_SIZE];
718e3744 3202
3203 /* Show neighbor ID. */
3204 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3205 vty_out (vty, " Neighbor %s,", "-");
3206 else
3207 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3208
3209 /* Show interface address. */
3210 vty_out (vty, " interface address %s%s",
3211 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3212 /* Show Area ID. */
3213 vty_out (vty, " In the area %s via interface %s%s",
3214 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3215 /* Show neighbor priority and state. */
3216 vty_out (vty, " Neighbor priority is %d, State is %s,",
3217 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3218 /* Show state changes. */
3219 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3fed4160 3220 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
90c33177 3221 {
2518efd1
PJ
3222 struct timeval res
3223 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
3fed4160
PJ
3224 vty_out (vty, " Most recent state change statistics:%s",
3225 VTY_NEWLINE);
3226 vty_out (vty, " Progressive change %s ago%s",
3227 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3228 VTY_NEWLINE);
3229 }
3230 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3231 {
2518efd1
PJ
3232 struct timeval res
3233 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
3fed4160 3234 vty_out (vty, " Regressive change %s ago, due to %s%s",
90c33177 3235 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3fed4160 3236 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
90c33177
PJ
3237 VTY_NEWLINE);
3238 }
718e3744 3239 /* Show Designated Rotuer ID. */
3240 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3241 /* Show Backup Designated Rotuer ID. */
3242 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3243 /* Show options. */
3244 vty_out (vty, " Options %d %s%s", nbr->options,
3245 ospf_options_dump (nbr->options), VTY_NEWLINE);
3246 /* Show Router Dead interval timer. */
3247 vty_out (vty, " Dead timer due in %s%s",
d24f6e2a 3248 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3249 VTY_NEWLINE);
718e3744 3250 /* Show Database Summary list. */
3251 vty_out (vty, " Database Summary List %d%s",
3252 ospf_db_summary_count (nbr), VTY_NEWLINE);
3253 /* Show Link State Request list. */
3254 vty_out (vty, " Link State Request List %ld%s",
3255 ospf_ls_request_count (nbr), VTY_NEWLINE);
3256 /* Show Link State Retransmission list. */
3257 vty_out (vty, " Link State Retransmission List %ld%s",
3258 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3259 /* Show inactivity timer thread. */
3260 vty_out (vty, " Thread Inactivity Timer %s%s",
3261 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3262 /* Show Database Description retransmission thread. */
3263 vty_out (vty, " Thread Database Description Retransmision %s%s",
3264 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3265 /* Show Link State Request Retransmission thread. */
3266 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3267 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3268 /* Show Link State Update Retransmission thread. */
3269 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3270 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3271}
3272
3273DEFUN (show_ip_ospf_neighbor_id,
3274 show_ip_ospf_neighbor_id_cmd,
3275 "show ip ospf neighbor A.B.C.D",
3276 SHOW_STR
3277 IP_STR
3278 "OSPF information\n"
3279 "Neighbor list\n"
3280 "Neighbor ID\n")
3281{
020709f9 3282 struct ospf *ospf;
52dc7ee6 3283 struct listnode *node;
718e3744 3284 struct ospf_neighbor *nbr;
1eb8ef25 3285 struct ospf_interface *oi;
718e3744 3286 struct in_addr router_id;
3287 int ret;
3288
3289 ret = inet_aton (argv[0], &router_id);
3290 if (!ret)
3291 {
3292 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3293 return CMD_WARNING;
3294 }
3295
020709f9 3296 ospf = ospf_lookup ();
3297 if (ospf == NULL)
3298 {
3299 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3300 return CMD_SUCCESS;
3301 }
3302
1eb8ef25 3303 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3304 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
1c066bfe 3305 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
718e3744 3306
718e3744 3307 return CMD_SUCCESS;
3308}
3309
3310DEFUN (show_ip_ospf_neighbor_detail,
3311 show_ip_ospf_neighbor_detail_cmd,
3312 "show ip ospf neighbor detail",
3313 SHOW_STR
3314 IP_STR
3315 "OSPF information\n"
3316 "Neighbor list\n"
3317 "detail of all neighbors\n")
3318{
020709f9 3319 struct ospf *ospf;
1eb8ef25 3320 struct ospf_interface *oi;
52dc7ee6 3321 struct listnode *node;
718e3744 3322
020709f9 3323 ospf = ospf_lookup ();
68980084 3324 if (ospf == NULL)
020709f9 3325 {
3326 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3327 return CMD_SUCCESS;
3328 }
718e3744 3329
1eb8ef25 3330 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
718e3744 3331 {
718e3744 3332 struct route_node *rn;
3333 struct ospf_neighbor *nbr;
3334
3335 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3336 if ((nbr = rn->info))
3337 if (nbr != oi->nbr_self)
3338 if (nbr->state != NSM_Down)
3339 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3340 }
3341
3342 return CMD_SUCCESS;
3343}
3344
3345DEFUN (show_ip_ospf_neighbor_detail_all,
3346 show_ip_ospf_neighbor_detail_all_cmd,
3347 "show ip ospf neighbor detail all",
3348 SHOW_STR
3349 IP_STR
3350 "OSPF information\n"
3351 "Neighbor list\n"
3352 "detail of all neighbors\n"
3353 "include down status neighbor\n")
3354{
020709f9 3355 struct ospf *ospf;
52dc7ee6 3356 struct listnode *node;
1eb8ef25 3357 struct ospf_interface *oi;
718e3744 3358
020709f9 3359 ospf = ospf_lookup ();
68980084 3360 if (ospf == NULL)
020709f9 3361 {
3362 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3363 return CMD_SUCCESS;
3364 }
718e3744 3365
1eb8ef25 3366 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
718e3744 3367 {
718e3744 3368 struct route_node *rn;
3369 struct ospf_neighbor *nbr;
1eb8ef25 3370 struct ospf_nbr_nbma *nbr_nbma;
718e3744 3371
3372 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3373 if ((nbr = rn->info))
3374 if (nbr != oi->nbr_self)
3375 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3376 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3377
3378 if (oi->type == OSPF_IFTYPE_NBMA)
3379 {
52dc7ee6 3380 struct listnode *nd;
718e3744 3381
1eb8ef25 3382 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3383 if (nbr_nbma->nbr == NULL
3384 || nbr_nbma->nbr->state == NSM_Down)
3385 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
718e3744 3386 }
3387 }
3388
3389 return CMD_SUCCESS;
3390}
3391
3392DEFUN (show_ip_ospf_neighbor_int_detail,
3393 show_ip_ospf_neighbor_int_detail_cmd,
bb5b7552 3394 "show ip ospf neighbor IFNAME detail",
718e3744 3395 SHOW_STR
3396 IP_STR
3397 "OSPF information\n"
3398 "Neighbor list\n"
bb5b7552 3399 "Interface name\n"
718e3744 3400 "detail of all neighbors")
3401{
020709f9 3402 struct ospf *ospf;
718e3744 3403 struct ospf_interface *oi;
bb5b7552 3404 struct interface *ifp;
3405 struct route_node *rn, *nrn;
3406 struct ospf_neighbor *nbr;
3407
3408 ifp = if_lookup_by_name (argv[0]);
3409 if (!ifp)
718e3744 3410 {
bb5b7552 3411 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
718e3744 3412 return CMD_WARNING;
3413 }
3414
020709f9 3415 ospf = ospf_lookup ();
3416 if (ospf == NULL)
3417 {
3418 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3419 return CMD_SUCCESS;
3420 }
68980084 3421
718e3744 3422
bb5b7552 3423 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3424 if ((oi = rn->info))
3425 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3426 if ((nbr = nrn->info))
718e3744 3427 if (nbr != oi->nbr_self)
3428 if (nbr->state != NSM_Down)
3429 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
718e3744 3430
3431 return CMD_SUCCESS;
3432}
3433
3434\f
3435/* Show functions */
4dadc291 3436static int
020709f9 3437show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
718e3744 3438{
718e3744 3439 struct router_lsa *rl;
3440 struct summary_lsa *sl;
3441 struct as_external_lsa *asel;
3442 struct prefix_ipv4 p;
3443
3444 if (lsa != NULL)
3445 /* If self option is set, check LSA self flag. */
3446 if (self == 0 || IS_LSA_SELF (lsa))
3447 {
3448 /* LSA common part show. */
3449 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3450 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3451 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3452 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3453 /* LSA specific part show. */
3454 switch (lsa->data->type)
3455 {
3456 case OSPF_ROUTER_LSA:
3457 rl = (struct router_lsa *) lsa->data;
3458 vty_out (vty, " %-d", ntohs (rl->links));
3459 break;
3460 case OSPF_SUMMARY_LSA:
3461 sl = (struct summary_lsa *) lsa->data;
3462
3463 p.family = AF_INET;
3464 p.prefix = sl->header.id;
3465 p.prefixlen = ip_masklen (sl->mask);
3466 apply_mask_ipv4 (&p);
3467
3468 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3469 break;
3470 case OSPF_AS_EXTERNAL_LSA:
551a8979 3471 case OSPF_AS_NSSA_LSA:
718e3744 3472 asel = (struct as_external_lsa *) lsa->data;
3473
3474 p.family = AF_INET;
3475 p.prefix = asel->header.id;
3476 p.prefixlen = ip_masklen (asel->mask);
3477 apply_mask_ipv4 (&p);
3478
3479 vty_out (vty, " %s %s/%d [0x%lx]",
3480 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3481 inet_ntoa (p.prefix), p.prefixlen,
3482 (u_long)ntohl (asel->e[0].route_tag));
3483 break;
3484 case OSPF_NETWORK_LSA:
3485 case OSPF_ASBR_SUMMARY_LSA:
3486#ifdef HAVE_OPAQUE_LSA
3487 case OSPF_OPAQUE_LINK_LSA:
3488 case OSPF_OPAQUE_AREA_LSA:
3489 case OSPF_OPAQUE_AS_LSA:
3490#endif /* HAVE_OPAQUE_LSA */
3491 default:
3492 break;
3493 }
3494 vty_out (vty, VTY_NEWLINE);
3495 }
3496
3497 return 0;
3498}
3499
8b6a15b2 3500static const char *show_database_desc[] =
718e3744 3501{
3502 "unknown",
3503 "Router Link States",
3504 "Net Link States",
3505 "Summary Link States",
3506 "ASBR-Summary Link States",
3507 "AS External Link States",
718e3744 3508 "Group Membership LSA",
3509 "NSSA-external Link States",
718e3744 3510#ifdef HAVE_OPAQUE_LSA
3511 "Type-8 LSA",
3512 "Link-Local Opaque-LSA",
3513 "Area-Local Opaque-LSA",
3514 "AS-external Opaque-LSA",
3515#endif /* HAVE_OPAQUE_LSA */
3516};
3517
8b6a15b2 3518static const char *show_database_header[] =
718e3744 3519{
3520 "",
3521 "Link ID ADV Router Age Seq# CkSum Link count",
3522 "Link ID ADV Router Age Seq# CkSum",
3523 "Link ID ADV Router Age Seq# CkSum Route",
3524 "Link ID ADV Router Age Seq# CkSum",
3525 "Link ID ADV Router Age Seq# CkSum Route",
718e3744 3526 " --- header for Group Member ----",
3527 "Link ID ADV Router Age Seq# CkSum Route",
718e3744 3528#ifdef HAVE_OPAQUE_LSA
718e3744 3529 " --- type-8 ---",
3530 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3531 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3532 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3533#endif /* HAVE_OPAQUE_LSA */
3534};
3535
4dadc291 3536static void
718e3744 3537show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3538{
3539 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
4957f494 3540
718e3744 3541 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
4957f494 3542 vty_out (vty, " Options: 0x%-2x : %s%s",
3543 lsa->data->options,
3544 ospf_options_dump(lsa->data->options),
3545 VTY_NEWLINE);
3546 vty_out (vty, " LS Flags: 0x%-2x %s%s",
9d526037 3547 lsa->flags,
4957f494 3548 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3549 VTY_NEWLINE);
718e3744 3550
3551 if (lsa->data->type == OSPF_ROUTER_LSA)
3552 {
3553 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3554
3555 if (rlsa->flags)
3556 vty_out (vty, " :%s%s%s%s",
3557 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3558 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3559 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3560 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3561
3562 vty_out (vty, "%s", VTY_NEWLINE);
3563 }
3564 vty_out (vty, " LS Type: %s%s",
3565 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3566 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3567 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3568 vty_out (vty, " Advertising Router: %s%s",
3569 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3570 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3571 VTY_NEWLINE);
3572 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3573 VTY_NEWLINE);
3574 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3575}
3576
eb1ce605 3577const char *link_type_desc[] =
718e3744 3578{
3579 "(null)",
3580 "another Router (point-to-point)",
3581 "a Transit Network",
3582 "Stub Network",
3583 "a Virtual Link",
3584};
3585
eb1ce605 3586const char *link_id_desc[] =
718e3744 3587{
3588 "(null)",
3589 "Neighboring Router ID",
3590 "Designated Router address",
68980084 3591 "Net",
718e3744 3592 "Neighboring Router ID",
3593};
3594
eb1ce605 3595const char *link_data_desc[] =
718e3744 3596{
3597 "(null)",
3598 "Router Interface address",
3599 "Router Interface address",
3600 "Network Mask",
3601 "Router Interface address",
3602};
3603
3604/* Show router-LSA each Link information. */
4dadc291 3605static void
718e3744 3606show_ip_ospf_database_router_links (struct vty *vty,
3607 struct router_lsa *rl)
3608{
3609 int len, i, type;
3610
3611 len = ntohs (rl->header.length) - 4;
3612 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3613 {
3614 type = rl->link[i].type;
3615
3616 vty_out (vty, " Link connected to: %s%s",
3617 link_type_desc[type], VTY_NEWLINE);
3618 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3619 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3620 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3621 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3622 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3623 vty_out (vty, " TOS 0 Metric: %d%s",
3624 ntohs (rl->link[i].metric), VTY_NEWLINE);
3625 vty_out (vty, "%s", VTY_NEWLINE);
3626 }
3627}
3628
3629/* Show router-LSA detail information. */
4dadc291 3630static int
718e3744 3631show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3632{
3633 if (lsa != NULL)
3634 {
3635 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3636
3637 show_ip_ospf_database_header (vty, lsa);
3638
3639 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3640 VTY_NEWLINE, VTY_NEWLINE);
3641
3642 show_ip_ospf_database_router_links (vty, rl);
b0a053be 3643 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 3644 }
3645
3646 return 0;
3647}
3648
3649/* Show network-LSA detail information. */
4dadc291 3650static int
718e3744 3651show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3652{
3653 int length, i;
3654
3655 if (lsa != NULL)
3656 {
3657 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3658
3659 show_ip_ospf_database_header (vty, lsa);
3660
3661 vty_out (vty, " Network Mask: /%d%s",
3662 ip_masklen (nl->mask), VTY_NEWLINE);
3663
3664 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3665
3666 for (i = 0; length > 0; i++, length -= 4)
3667 vty_out (vty, " Attached Router: %s%s",
3668 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3669
3670 vty_out (vty, "%s", VTY_NEWLINE);
3671 }
3672
3673 return 0;
3674}
3675
3676/* Show summary-LSA detail information. */
4dadc291 3677static int
718e3744 3678show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3679{
3680 if (lsa != NULL)
3681 {
3682 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3683
3684 show_ip_ospf_database_header (vty, lsa);
3685
3686 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3687 VTY_NEWLINE);
3688 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3689 VTY_NEWLINE);
b0a053be 3690 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 3691 }
3692
3693 return 0;
3694}
3695
3696/* Show summary-ASBR-LSA detail information. */
4dadc291 3697static int
718e3744 3698show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3699{
3700 if (lsa != NULL)
3701 {
3702 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3703
3704 show_ip_ospf_database_header (vty, lsa);
3705
3706 vty_out (vty, " Network Mask: /%d%s",
3707 ip_masklen (sl->mask), VTY_NEWLINE);
3708 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3709 VTY_NEWLINE);
b0a053be 3710 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 3711 }
3712
3713 return 0;
3714}
3715
3716/* Show AS-external-LSA detail information. */
4dadc291 3717static int
718e3744 3718show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3719{
3720 if (lsa != NULL)
3721 {
3722 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3723
3724 show_ip_ospf_database_header (vty, lsa);
3725
3726 vty_out (vty, " Network Mask: /%d%s",
3727 ip_masklen (al->mask), VTY_NEWLINE);
3728 vty_out (vty, " Metric Type: %s%s",
3729 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3730 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3731 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3732 vty_out (vty, " Metric: %d%s",
3733 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3734 vty_out (vty, " Forward Address: %s%s",
3735 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3736
3737 vty_out (vty, " External Route Tag: %lu%s%s",
3738 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3739 }
3740
3741 return 0;
3742}
3743
075e12f5 3744#if 0
4dadc291 3745static int
718e3744 3746show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3747{
3748 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3749
3750 /* show_ip_ospf_database_header (vty, lsa); */
3751
2a42e285 3752 zlog_debug( " Network Mask: /%d%s",
718e3744 3753 ip_masklen (al->mask), "\n");
2a42e285 3754 zlog_debug( " Metric Type: %s%s",
718e3744 3755 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3756 "2 (Larger than any link state path)" : "1", "\n");
2a42e285 3757 zlog_debug( " TOS: 0%s", "\n");
3758 zlog_debug( " Metric: %d%s",
718e3744 3759 GET_METRIC (al->e[0].metric), "\n");
2a42e285 3760 zlog_debug( " Forward Address: %s%s",
718e3744 3761 inet_ntoa (al->e[0].fwd_addr), "\n");
3762
2a42e285 3763 zlog_debug( " External Route Tag: %u%s%s",
718e3744 3764 ntohl (al->e[0].route_tag), "\n", "\n");
3765
3766 return 0;
3767}
075e12f5 3768#endif
718e3744 3769
3770/* Show AS-NSSA-LSA detail information. */
4dadc291 3771static int
718e3744 3772show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3773{
3774 if (lsa != NULL)
3775 {
3776 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3777
3778 show_ip_ospf_database_header (vty, lsa);
3779
3780 vty_out (vty, " Network Mask: /%d%s",
3781 ip_masklen (al->mask), VTY_NEWLINE);
3782 vty_out (vty, " Metric Type: %s%s",
3783 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3784 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3785 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3786 vty_out (vty, " Metric: %d%s",
3787 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3788 vty_out (vty, " NSSA: Forward Address: %s%s",
3789 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3790
3791 vty_out (vty, " External Route Tag: %u%s%s",
3792 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3793 }
3794
3795 return 0;
3796}
3797
4dadc291 3798static int
718e3744 3799show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3800{
3801 return 0;
3802}
3803
3804#ifdef HAVE_OPAQUE_LSA
4dadc291 3805static int
718e3744 3806show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3807{
3808 if (lsa != NULL)
3809 {
3810 show_ip_ospf_database_header (vty, lsa);
3811 show_opaque_info_detail (vty, lsa);
3812
3813 vty_out (vty, "%s", VTY_NEWLINE);
3814 }
3815 return 0;
3816}
3817#endif /* HAVE_OPAQUE_LSA */
3818
3819int (*show_function[])(struct vty *, struct ospf_lsa *) =
3820{
3821 NULL,
3822 show_router_lsa_detail,
3823 show_network_lsa_detail,
3824 show_summary_lsa_detail,
3825 show_summary_asbr_lsa_detail,
3826 show_as_external_lsa_detail,
718e3744 3827 show_func_dummy,
3828 show_as_nssa_lsa_detail, /* almost same as external */
718e3744 3829#ifdef HAVE_OPAQUE_LSA
718e3744 3830 NULL, /* type-8 */
3831 show_opaque_lsa_detail,
3832 show_opaque_lsa_detail,
3833 show_opaque_lsa_detail,
3834#endif /* HAVE_OPAQUE_LSA */
3835};
3836
4dadc291 3837static void
718e3744 3838show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3839 struct in_addr *adv_router)
3840{
3841 memset (lp, 0, sizeof (struct prefix_ls));
3842 lp->family = 0;
3843 if (id == NULL)
3844 lp->prefixlen = 0;
3845 else if (adv_router == NULL)
3846 {
3847 lp->prefixlen = 32;
3848 lp->id = *id;
3849 }
3850 else
3851 {
3852 lp->prefixlen = 64;
3853 lp->id = *id;
3854 lp->adv_router = *adv_router;
3855 }
3856}
3857
4dadc291 3858static void
718e3744 3859show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3860 struct in_addr *id, struct in_addr *adv_router)
3861{
3862 struct prefix_ls lp;
3863 struct route_node *rn, *start;
3864 struct ospf_lsa *lsa;
3865
3866 show_lsa_prefix_set (vty, &lp, id, adv_router);
3867 start = route_node_get (rt, (struct prefix *) &lp);
3868 if (start)
3869 {
3870 route_lock_node (start);
3871 for (rn = start; rn; rn = route_next_until (rn, start))
3872 if ((lsa = rn->info))
3873 {
718e3744 3874 if (show_function[lsa->data->type] != NULL)
3875 show_function[lsa->data->type] (vty, lsa);
3876 }
3877 route_unlock_node (start);
3878 }
3879}
3880
3881/* Show detail LSA information
3882 -- if id is NULL then show all LSAs. */
4dadc291 3883static void
020709f9 3884show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
718e3744 3885 struct in_addr *id, struct in_addr *adv_router)
3886{
52dc7ee6 3887 struct listnode *node;
1eb8ef25 3888 struct ospf_area *area;
3889
718e3744 3890 switch (type)
3891 {
3892 case OSPF_AS_EXTERNAL_LSA:
3893#ifdef HAVE_OPAQUE_LSA
3894 case OSPF_OPAQUE_AS_LSA:
3895#endif /* HAVE_OPAQUE_LSA */
3896 vty_out (vty, " %s %s%s",
3897 show_database_desc[type],
3898 VTY_NEWLINE, VTY_NEWLINE);
68980084 3899 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
718e3744 3900 break;
3901 default:
1eb8ef25 3902 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 3903 {
718e3744 3904 vty_out (vty, "%s %s (Area %s)%s%s",
3905 VTY_NEWLINE, show_database_desc[type],
3906 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3907 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3908 }
3909 break;
3910 }
3911}
3912
4dadc291 3913static void
718e3744 3914show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3915 struct in_addr *adv_router)
3916{
3917 struct route_node *rn;
3918 struct ospf_lsa *lsa;
3919
3920 for (rn = route_top (rt); rn; rn = route_next (rn))
3921 if ((lsa = rn->info))
3922 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3923 {
718e3744 3924 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3925 continue;
718e3744 3926 if (show_function[lsa->data->type] != NULL)
3927 show_function[lsa->data->type] (vty, lsa);
3928 }
3929}
3930
3931/* Show detail LSA information. */
4dadc291 3932static void
020709f9 3933show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
718e3744 3934 struct in_addr *adv_router)
3935{
52dc7ee6 3936 struct listnode *node;
1eb8ef25 3937 struct ospf_area *area;
718e3744 3938
3939 switch (type)
3940 {
3941 case OSPF_AS_EXTERNAL_LSA:
3942#ifdef HAVE_OPAQUE_LSA
3943 case OSPF_OPAQUE_AS_LSA:
3944#endif /* HAVE_OPAQUE_LSA */
3945 vty_out (vty, " %s %s%s",
3946 show_database_desc[type],
3947 VTY_NEWLINE, VTY_NEWLINE);
68980084 3948 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
718e3744 3949 adv_router);
3950 break;
3951 default:
1eb8ef25 3952 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 3953 {
718e3744 3954 vty_out (vty, "%s %s (Area %s)%s%s",
3955 VTY_NEWLINE, show_database_desc[type],
3956 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3957 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
3958 adv_router);
3959 }
3960 break;
3961 }
3962}
3963
4dadc291 3964static void
020709f9 3965show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
718e3744 3966{
020709f9 3967 struct ospf_lsa *lsa;
3968 struct route_node *rn;
1eb8ef25 3969 struct ospf_area *area;
52dc7ee6 3970 struct listnode *node;
718e3744 3971 int type;
3972
1eb8ef25 3973 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 3974 {
718e3744 3975 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
3976 {
3977 switch (type)
3978 {
3979 case OSPF_AS_EXTERNAL_LSA:
3980#ifdef HAVE_OPAQUE_LSA
3981 case OSPF_OPAQUE_AS_LSA:
3982#endif /* HAVE_OPAQUE_LSA */
3983 continue;
3984 default:
3985 break;
3986 }
3987 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
3988 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
3989 {
3990 vty_out (vty, " %s (Area %s)%s%s",
3991 show_database_desc[type],
3992 ospf_area_desc_string (area),
3993 VTY_NEWLINE, VTY_NEWLINE);
3994 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
3995
020709f9 3996 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
3997 show_lsa_summary (vty, lsa, self);
718e3744 3998
3999 vty_out (vty, "%s", VTY_NEWLINE);
4000 }
4001 }
4002 }
4003
4004 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4005 {
4006 switch (type)
4007 {
4008 case OSPF_AS_EXTERNAL_LSA:
4009#ifdef HAVE_OPAQUE_LSA
4010 case OSPF_OPAQUE_AS_LSA:
4011#endif /* HAVE_OPAQUE_LSA */
e8e1946e 4012 break;
718e3744 4013 default:
4014 continue;
4015 }
68980084 4016 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4017 (!self && ospf_lsdb_count (ospf->lsdb, type)))
718e3744 4018 {
4019 vty_out (vty, " %s%s%s",
4020 show_database_desc[type],
4021 VTY_NEWLINE, VTY_NEWLINE);
4022 vty_out (vty, "%s%s", show_database_header[type],
4023 VTY_NEWLINE);
020709f9 4024
4025 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4026 show_lsa_summary (vty, lsa, self);
4027
718e3744 4028 vty_out (vty, "%s", VTY_NEWLINE);
4029 }
4030 }
4031
4032 vty_out (vty, "%s", VTY_NEWLINE);
4033}
4034
4dadc291 4035static void
020709f9 4036show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
718e3744 4037{
52dc7ee6 4038 struct listnode *node;
718e3744 4039 struct ospf_lsa *lsa;
4040
4041 vty_out (vty, "%s MaxAge Link States:%s%s",
4042 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4043
1eb8ef25 4044 for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
4045 {
4046 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4047 vty_out (vty, "Link State ID: %s%s",
4048 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4049 vty_out (vty, "Advertising Router: %s%s",
4050 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4051 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4052 vty_out (vty, "%s", VTY_NEWLINE);
4053 }
718e3744 4054}
4055
718e3744 4056#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4057#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
718e3744 4058
4059#ifdef HAVE_OPAQUE_LSA
4060#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4061#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4062#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4063#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4064#else /* HAVE_OPAQUE_LSA */
4065#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4066#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4067#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4068#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4069#endif /* HAVE_OPAQUE_LSA */
4070
4071#define OSPF_LSA_TYPES_CMD_STR \
4072 "asbr-summary|external|network|router|summary" \
4073 OSPF_LSA_TYPE_NSSA_CMD_STR \
4074 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4075
4076#define OSPF_LSA_TYPES_DESC \
4077 "ASBR summary link states\n" \
4078 "External link states\n" \
4079 "Network link states\n" \
4080 "Router link states\n" \
4081 "Network summary link states\n" \
4082 OSPF_LSA_TYPE_NSSA_DESC \
4083 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4084 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4085 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4086
4087DEFUN (show_ip_ospf_database,
4088 show_ip_ospf_database_cmd,
4089 "show ip ospf database",
4090 SHOW_STR
4091 IP_STR
4092 "OSPF information\n"
4093 "Database summary\n")
4094{
020709f9 4095 struct ospf *ospf;
718e3744 4096 int type, ret;
4097 struct in_addr id, adv_router;
4098
020709f9 4099 ospf = ospf_lookup ();
68980084 4100 if (ospf == NULL)
cac3b5c4
PJ
4101 {
4102 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4103 return CMD_SUCCESS;
4104 }
718e3744 4105
4106 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
68980084 4107 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
718e3744 4108
4109 /* Show all LSA. */
4110 if (argc == 0)
4111 {
020709f9 4112 show_ip_ospf_database_summary (vty, ospf, 0);
718e3744 4113 return CMD_SUCCESS;
4114 }
4115
4116 /* Set database type to show. */
4117 if (strncmp (argv[0], "r", 1) == 0)
4118 type = OSPF_ROUTER_LSA;
4119 else if (strncmp (argv[0], "ne", 2) == 0)
4120 type = OSPF_NETWORK_LSA;
718e3744 4121 else if (strncmp (argv[0], "ns", 2) == 0)
4122 type = OSPF_AS_NSSA_LSA;
718e3744 4123 else if (strncmp (argv[0], "su", 2) == 0)
4124 type = OSPF_SUMMARY_LSA;
4125 else if (strncmp (argv[0], "a", 1) == 0)
4126 type = OSPF_ASBR_SUMMARY_LSA;
4127 else if (strncmp (argv[0], "e", 1) == 0)
4128 type = OSPF_AS_EXTERNAL_LSA;
4129 else if (strncmp (argv[0], "se", 2) == 0)
4130 {
020709f9 4131 show_ip_ospf_database_summary (vty, ospf, 1);
718e3744 4132 return CMD_SUCCESS;
4133 }
4134 else if (strncmp (argv[0], "m", 1) == 0)
4135 {
020709f9 4136 show_ip_ospf_database_maxage (vty, ospf);
718e3744 4137 return CMD_SUCCESS;
4138 }
4139#ifdef HAVE_OPAQUE_LSA
4140 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4141 type = OSPF_OPAQUE_LINK_LSA;
4142 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4143 type = OSPF_OPAQUE_AREA_LSA;
4144 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4145 type = OSPF_OPAQUE_AS_LSA;
4146#endif /* HAVE_OPAQUE_LSA */
4147 else
4148 return CMD_WARNING;
4149
4150 /* `show ip ospf database LSA'. */
4151 if (argc == 1)
020709f9 4152 show_lsa_detail (vty, ospf, type, NULL, NULL);
718e3744 4153 else if (argc >= 2)
4154 {
4155 ret = inet_aton (argv[1], &id);
4156 if (!ret)
4157 return CMD_WARNING;
4158
4159 /* `show ip ospf database LSA ID'. */
4160 if (argc == 2)
020709f9 4161 show_lsa_detail (vty, ospf, type, &id, NULL);
718e3744 4162 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4163 else if (argc == 3)
4164 {
4165 if (strncmp (argv[2], "s", 1) == 0)
68980084 4166 adv_router = ospf->router_id;
718e3744 4167 else
4168 {
4169 ret = inet_aton (argv[2], &adv_router);
4170 if (!ret)
4171 return CMD_WARNING;
4172 }
020709f9 4173 show_lsa_detail (vty, ospf, type, &id, &adv_router);
718e3744 4174 }
4175 }
4176
4177 return CMD_SUCCESS;
4178}
4179
4180ALIAS (show_ip_ospf_database,
4181 show_ip_ospf_database_type_cmd,
4182 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4183 SHOW_STR
4184 IP_STR
4185 "OSPF information\n"
4186 "Database summary\n"
4187 OSPF_LSA_TYPES_DESC
4188 "LSAs in MaxAge list\n"
4189 "Self-originated link states\n")
4190
4191ALIAS (show_ip_ospf_database,
4192 show_ip_ospf_database_type_id_cmd,
4193 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4194 SHOW_STR
4195 IP_STR
4196 "OSPF information\n"
4197 "Database summary\n"
4198 OSPF_LSA_TYPES_DESC
4199 "Link State ID (as an IP address)\n")
4200
4201ALIAS (show_ip_ospf_database,
4202 show_ip_ospf_database_type_id_adv_router_cmd,
4203 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4204 SHOW_STR
4205 IP_STR
4206 "OSPF information\n"
4207 "Database summary\n"
4208 OSPF_LSA_TYPES_DESC
4209 "Link State ID (as an IP address)\n"
4210 "Advertising Router link states\n"
4211 "Advertising Router (as an IP address)\n")
4212
4213ALIAS (show_ip_ospf_database,
4214 show_ip_ospf_database_type_id_self_cmd,
4215 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4216 SHOW_STR
4217 IP_STR
4218 "OSPF information\n"
4219 "Database summary\n"
4220 OSPF_LSA_TYPES_DESC
4221 "Link State ID (as an IP address)\n"
4222 "Self-originated link states\n"
4223 "\n")
4224
4225DEFUN (show_ip_ospf_database_type_adv_router,
4226 show_ip_ospf_database_type_adv_router_cmd,
4227 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4228 SHOW_STR
4229 IP_STR
4230 "OSPF information\n"
4231 "Database summary\n"
4232 OSPF_LSA_TYPES_DESC
4233 "Advertising Router link states\n"
4234 "Advertising Router (as an IP address)\n")
4235{
020709f9 4236 struct ospf *ospf;
718e3744 4237 int type, ret;
4238 struct in_addr adv_router;
4239
020709f9 4240 ospf = ospf_lookup ();
68980084 4241 if (ospf == NULL)
cac3b5c4
PJ
4242 {
4243 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4244 return CMD_SUCCESS;
4245 }
718e3744 4246
4247 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
68980084 4248 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
718e3744 4249
4250 if (argc != 2)
4251 return CMD_WARNING;
4252
4253 /* Set database type to show. */
4254 if (strncmp (argv[0], "r", 1) == 0)
4255 type = OSPF_ROUTER_LSA;
4256 else if (strncmp (argv[0], "ne", 2) == 0)
4257 type = OSPF_NETWORK_LSA;
718e3744 4258 else if (strncmp (argv[0], "ns", 2) == 0)
4259 type = OSPF_AS_NSSA_LSA;
718e3744 4260 else if (strncmp (argv[0], "s", 1) == 0)
4261 type = OSPF_SUMMARY_LSA;
4262 else if (strncmp (argv[0], "a", 1) == 0)
4263 type = OSPF_ASBR_SUMMARY_LSA;
4264 else if (strncmp (argv[0], "e", 1) == 0)
4265 type = OSPF_AS_EXTERNAL_LSA;
4266#ifdef HAVE_OPAQUE_LSA
4267 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4268 type = OSPF_OPAQUE_LINK_LSA;
4269 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4270 type = OSPF_OPAQUE_AREA_LSA;
4271 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4272 type = OSPF_OPAQUE_AS_LSA;
4273#endif /* HAVE_OPAQUE_LSA */
4274 else
4275 return CMD_WARNING;
4276
4277 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4278 if (strncmp (argv[1], "s", 1) == 0)
68980084 4279 adv_router = ospf->router_id;
718e3744 4280 else
4281 {
4282 ret = inet_aton (argv[1], &adv_router);
4283 if (!ret)
4284 return CMD_WARNING;
4285 }
4286
020709f9 4287 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
718e3744 4288
4289 return CMD_SUCCESS;
4290}
4291
4292ALIAS (show_ip_ospf_database_type_adv_router,
4293 show_ip_ospf_database_type_self_cmd,
4294 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4295 SHOW_STR
4296 IP_STR
4297 "OSPF information\n"
4298 "Database summary\n"
4299 OSPF_LSA_TYPES_DESC
4300 "Self-originated link states\n")
4301
4302\f
4303DEFUN (ip_ospf_authentication_args,
4304 ip_ospf_authentication_args_addr_cmd,
4305 "ip ospf authentication (null|message-digest) A.B.C.D",
4306 "IP Information\n"
4307 "OSPF interface commands\n"
4308 "Enable authentication on this interface\n"
4309 "Use null authentication\n"
4310 "Use message-digest authentication\n"
4311 "Address of interface")
4312{
4313 struct interface *ifp;
4314 struct in_addr addr;
4315 int ret;
4316 struct ospf_if_params *params;
4317
4318 ifp = vty->index;
4319 params = IF_DEF_PARAMS (ifp);
4320
4321 if (argc == 2)
4322 {
4323 ret = inet_aton(argv[1], &addr);
4324 if (!ret)
4325 {
4326 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4327 VTY_NEWLINE);
4328 return CMD_WARNING;
4329 }
4330
4331 params = ospf_get_if_params (ifp, addr);
4332 ospf_if_update_params (ifp, addr);
4333 }
4334
4335 /* Handle null authentication */
4336 if ( argv[0][0] == 'n' )
4337 {
4338 SET_IF_PARAM (params, auth_type);
4339 params->auth_type = OSPF_AUTH_NULL;
4340 return CMD_SUCCESS;
4341 }
4342
4343 /* Handle message-digest authentication */
4344 if ( argv[0][0] == 'm' )
4345 {
4346 SET_IF_PARAM (params, auth_type);
4347 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4348 return CMD_SUCCESS;
4349 }
4350
4351 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4352 return CMD_WARNING;
4353}
4354
4355ALIAS (ip_ospf_authentication_args,
4356 ip_ospf_authentication_args_cmd,
4357 "ip ospf authentication (null|message-digest)",
4358 "IP Information\n"
4359 "OSPF interface commands\n"
4360 "Enable authentication on this interface\n"
4361 "Use null authentication\n"
4362 "Use message-digest authentication\n")
4363
4364DEFUN (ip_ospf_authentication,
4365 ip_ospf_authentication_addr_cmd,
4366 "ip ospf authentication A.B.C.D",
4367 "IP Information\n"
4368 "OSPF interface commands\n"
4369 "Enable authentication on this interface\n"
4370 "Address of interface")
4371{
4372 struct interface *ifp;
4373 struct in_addr addr;
4374 int ret;
4375 struct ospf_if_params *params;
4376
4377 ifp = vty->index;
4378 params = IF_DEF_PARAMS (ifp);
4379
4380 if (argc == 1)
4381 {
5dcf71df 4382 ret = inet_aton(argv[0], &addr);
718e3744 4383 if (!ret)
4384 {
4385 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4386 VTY_NEWLINE);
4387 return CMD_WARNING;
4388 }
4389
4390 params = ospf_get_if_params (ifp, addr);
4391 ospf_if_update_params (ifp, addr);
4392 }
4393
4394 SET_IF_PARAM (params, auth_type);
4395 params->auth_type = OSPF_AUTH_SIMPLE;
4396
4397 return CMD_SUCCESS;
4398}
4399
4400ALIAS (ip_ospf_authentication,
4401 ip_ospf_authentication_cmd,
4402 "ip ospf authentication",
4403 "IP Information\n"
4404 "OSPF interface commands\n"
4405 "Enable authentication on this interface\n")
4406
4407DEFUN (no_ip_ospf_authentication,
4408 no_ip_ospf_authentication_addr_cmd,
4409 "no ip ospf authentication A.B.C.D",
4410 NO_STR
4411 "IP Information\n"
4412 "OSPF interface commands\n"
4413 "Enable authentication on this interface\n"
4414 "Address of interface")
4415{
4416 struct interface *ifp;
4417 struct in_addr addr;
4418 int ret;
4419 struct ospf_if_params *params;
4420
4421 ifp = vty->index;
4422 params = IF_DEF_PARAMS (ifp);
4423
4424 if (argc == 1)
4425 {
5dcf71df 4426 ret = inet_aton(argv[0], &addr);
718e3744 4427 if (!ret)
4428 {
4429 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4430 VTY_NEWLINE);
4431 return CMD_WARNING;
4432 }
4433
4434 params = ospf_lookup_if_params (ifp, addr);
4435 if (params == NULL)
4436 return CMD_SUCCESS;
4437 }
4438
4439 params->auth_type = OSPF_AUTH_NOTSET;
4440 UNSET_IF_PARAM (params, auth_type);
4441
4442 if (params != IF_DEF_PARAMS (ifp))
4443 {
4444 ospf_free_if_params (ifp, addr);
4445 ospf_if_update_params (ifp, addr);
4446 }
4447
4448 return CMD_SUCCESS;
4449}
4450
4451ALIAS (no_ip_ospf_authentication,
4452 no_ip_ospf_authentication_cmd,
4453 "no ip ospf authentication",
4454 NO_STR
4455 "IP Information\n"
4456 "OSPF interface commands\n"
4457 "Enable authentication on this interface\n")
4458
4459DEFUN (ip_ospf_authentication_key,
4460 ip_ospf_authentication_key_addr_cmd,
4461 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4462 "IP Information\n"
4463 "OSPF interface commands\n"
4464 "Authentication password (key)\n"
4465 "The OSPF password (key)\n"
4466 "Address of interface")
4467{
4468 struct interface *ifp;
4469 struct in_addr addr;
4470 int ret;
4471 struct ospf_if_params *params;
4472
4473 ifp = vty->index;
4474 params = IF_DEF_PARAMS (ifp);
4475
4476 if (argc == 2)
4477 {
4478 ret = inet_aton(argv[1], &addr);
4479 if (!ret)
4480 {
4481 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4482 VTY_NEWLINE);
4483 return CMD_WARNING;
4484 }
4485
4486 params = ospf_get_if_params (ifp, addr);
4487 ospf_if_update_params (ifp, addr);
4488 }
4489
4490
4491 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
c9e52be3 4492 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
718e3744 4493 SET_IF_PARAM (params, auth_simple);
4494
4495 return CMD_SUCCESS;
4496}
4497
4498ALIAS (ip_ospf_authentication_key,
4499 ip_ospf_authentication_key_cmd,
4500 "ip ospf authentication-key AUTH_KEY",
4501 "IP Information\n"
4502 "OSPF interface commands\n"
4503 "Authentication password (key)\n"
4504 "The OSPF password (key)")
4505
4506ALIAS (ip_ospf_authentication_key,
4507 ospf_authentication_key_cmd,
4508 "ospf authentication-key AUTH_KEY",
4509 "OSPF interface commands\n"
4510 "Authentication password (key)\n"
4511 "The OSPF password (key)")
4512
4513DEFUN (no_ip_ospf_authentication_key,
4514 no_ip_ospf_authentication_key_addr_cmd,
4515 "no ip ospf authentication-key A.B.C.D",
4516 NO_STR
4517 "IP Information\n"
4518 "OSPF interface commands\n"
4519 "Authentication password (key)\n"
4520 "Address of interface")
4521{
4522 struct interface *ifp;
4523 struct in_addr addr;
4524 int ret;
4525 struct ospf_if_params *params;
4526
4527 ifp = vty->index;
4528 params = IF_DEF_PARAMS (ifp);
4529
5dcf71df 4530 if (argc == 1)
718e3744 4531 {
5dcf71df 4532 ret = inet_aton(argv[0], &addr);
718e3744 4533 if (!ret)
4534 {
4535 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4536 VTY_NEWLINE);
4537 return CMD_WARNING;
4538 }
4539
4540 params = ospf_lookup_if_params (ifp, addr);
4541 if (params == NULL)
4542 return CMD_SUCCESS;
4543 }
4544
4545 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4546 UNSET_IF_PARAM (params, auth_simple);
4547
4548 if (params != IF_DEF_PARAMS (ifp))
4549 {
4550 ospf_free_if_params (ifp, addr);
4551 ospf_if_update_params (ifp, addr);
4552 }
4553
4554 return CMD_SUCCESS;
4555}
4556
4557ALIAS (no_ip_ospf_authentication_key,
4558 no_ip_ospf_authentication_key_cmd,
4559 "no ip ospf authentication-key",
4560 NO_STR
4561 "IP Information\n"
4562 "OSPF interface commands\n"
4563 "Authentication password (key)\n")
4564
4565ALIAS (no_ip_ospf_authentication_key,
4566 no_ospf_authentication_key_cmd,
4567 "no ospf authentication-key",
4568 NO_STR
4569 "OSPF interface commands\n"
4570 "Authentication password (key)\n")
4571
4572DEFUN (ip_ospf_message_digest_key,
4573 ip_ospf_message_digest_key_addr_cmd,
4574 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4575 "IP Information\n"
4576 "OSPF interface commands\n"
4577 "Message digest authentication password (key)\n"
4578 "Key ID\n"
4579 "Use MD5 algorithm\n"
4580 "The OSPF password (key)"
4581 "Address of interface")
4582{
4583 struct interface *ifp;
4584 struct crypt_key *ck;
4585 u_char key_id;
4586 struct in_addr addr;
4587 int ret;
4588 struct ospf_if_params *params;
4589
4590 ifp = vty->index;
4591 params = IF_DEF_PARAMS (ifp);
4592
4593 if (argc == 3)
4594 {
4595 ret = inet_aton(argv[2], &addr);
4596 if (!ret)
4597 {
4598 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4599 VTY_NEWLINE);
4600 return CMD_WARNING;
4601 }
4602
4603 params = ospf_get_if_params (ifp, addr);
4604 ospf_if_update_params (ifp, addr);
4605 }
4606
4607 key_id = strtol (argv[0], NULL, 10);
4608 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4609 {
4610 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4611 return CMD_WARNING;
4612 }
4613
4614 ck = ospf_crypt_key_new ();
4615 ck->key_id = (u_char) key_id;
4616 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
c9e52be3 4617 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
718e3744 4618
4619 ospf_crypt_key_add (params->auth_crypt, ck);
4620 SET_IF_PARAM (params, auth_crypt);
4621
4622 return CMD_SUCCESS;
4623}
4624
4625ALIAS (ip_ospf_message_digest_key,
4626 ip_ospf_message_digest_key_cmd,
4627 "ip ospf message-digest-key <1-255> md5 KEY",
4628 "IP Information\n"
4629 "OSPF interface commands\n"
4630 "Message digest authentication password (key)\n"
4631 "Key ID\n"
4632 "Use MD5 algorithm\n"
4633 "The OSPF password (key)")
4634
4635ALIAS (ip_ospf_message_digest_key,
4636 ospf_message_digest_key_cmd,
4637 "ospf message-digest-key <1-255> md5 KEY",
4638 "OSPF interface commands\n"
4639 "Message digest authentication password (key)\n"
4640 "Key ID\n"
4641 "Use MD5 algorithm\n"
4642 "The OSPF password (key)")
4643
4644DEFUN (no_ip_ospf_message_digest_key,
4645 no_ip_ospf_message_digest_key_addr_cmd,
4646 "no ip ospf message-digest-key <1-255> A.B.C.D",
4647 NO_STR
4648 "IP Information\n"
4649 "OSPF interface commands\n"
4650 "Message digest authentication password (key)\n"
4651 "Key ID\n"
4652 "Address of interface")
4653{
4654 struct interface *ifp;
4655 struct crypt_key *ck;
4656 int key_id;
4657 struct in_addr addr;
4658 int ret;
4659 struct ospf_if_params *params;
4660
4661 ifp = vty->index;
4662 params = IF_DEF_PARAMS (ifp);
4663
4664 if (argc == 2)
4665 {
4666 ret = inet_aton(argv[1], &addr);
4667 if (!ret)
4668 {
4669 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4670 VTY_NEWLINE);
4671 return CMD_WARNING;
4672 }
4673
4674 params = ospf_lookup_if_params (ifp, addr);
4675 if (params == NULL)
4676 return CMD_SUCCESS;
4677 }
4678
4679 key_id = strtol (argv[0], NULL, 10);
4680 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4681 if (ck == NULL)
4682 {
4683 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4684 return CMD_WARNING;
4685 }
4686
4687 ospf_crypt_key_delete (params->auth_crypt, key_id);
4688
4689 if (params != IF_DEF_PARAMS (ifp))
4690 {
4691 ospf_free_if_params (ifp, addr);
4692 ospf_if_update_params (ifp, addr);
4693 }
4694
4695 return CMD_SUCCESS;
4696}
4697
4698ALIAS (no_ip_ospf_message_digest_key,
4699 no_ip_ospf_message_digest_key_cmd,
4700 "no ip ospf message-digest-key <1-255>",
4701 NO_STR
4702 "IP Information\n"
4703 "OSPF interface commands\n"
4704 "Message digest authentication password (key)\n"
4705 "Key ID\n")
4706
4707ALIAS (no_ip_ospf_message_digest_key,
4708 no_ospf_message_digest_key_cmd,
4709 "no ospf message-digest-key <1-255>",
4710 NO_STR
4711 "OSPF interface commands\n"
4712 "Message digest authentication password (key)\n"
4713 "Key ID\n")
4714
4715DEFUN (ip_ospf_cost,
9eff36b3 4716 ip_ospf_cost_u32_inet4_cmd,
718e3744 4717 "ip ospf cost <1-65535> A.B.C.D",
4718 "IP Information\n"
4719 "OSPF interface commands\n"
4720 "Interface cost\n"
4721 "Cost\n"
4722 "Address of interface")
4723{
4724 struct interface *ifp = vty->index;
4725 u_int32_t cost;
4726 struct in_addr addr;
4727 int ret;
4728 struct ospf_if_params *params;
4729
4730 params = IF_DEF_PARAMS (ifp);
4731
4732 cost = strtol (argv[0], NULL, 10);
4733
4734 /* cost range is <1-65535>. */
4735 if (cost < 1 || cost > 65535)
4736 {
4737 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4738 return CMD_WARNING;
4739 }
4740
4741 if (argc == 2)
4742 {
4743 ret = inet_aton(argv[1], &addr);
4744 if (!ret)
4745 {
4746 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4747 VTY_NEWLINE);
4748 return CMD_WARNING;
4749 }
4750
4751 params = ospf_get_if_params (ifp, addr);
4752 ospf_if_update_params (ifp, addr);
4753 }
4754
4755 SET_IF_PARAM (params, output_cost_cmd);
4756 params->output_cost_cmd = cost;
4757
4758 ospf_if_recalculate_output_cost (ifp);
4759
4760 return CMD_SUCCESS;
4761}
4762
4763ALIAS (ip_ospf_cost,
9eff36b3 4764 ip_ospf_cost_u32_cmd,
718e3744 4765 "ip ospf cost <1-65535>",
4766 "IP Information\n"
4767 "OSPF interface commands\n"
4768 "Interface cost\n"
4769 "Cost")
4770
4771ALIAS (ip_ospf_cost,
9eff36b3 4772 ospf_cost_u32_cmd,
718e3744 4773 "ospf cost <1-65535>",
4774 "OSPF interface commands\n"
4775 "Interface cost\n"
4776 "Cost")
4777
9eff36b3
DO
4778ALIAS (ip_ospf_cost,
4779 ospf_cost_u32_inet4_cmd,
4780 "ospf cost <1-65535> A.B.C.D",
4781 "OSPF interface commands\n"
4782 "Interface cost\n"
4783 "Cost\n"
4784 "Address of interface")
4785
718e3744 4786DEFUN (no_ip_ospf_cost,
9eff36b3 4787 no_ip_ospf_cost_inet4_cmd,
718e3744 4788 "no ip ospf cost A.B.C.D",
4789 NO_STR
4790 "IP Information\n"
4791 "OSPF interface commands\n"
4792 "Interface cost\n"
4793 "Address of interface")
4794{
4795 struct interface *ifp = vty->index;
4796 struct in_addr addr;
4797 int ret;
4798 struct ospf_if_params *params;
4799
4800 ifp = vty->index;
4801 params = IF_DEF_PARAMS (ifp);
4802
4803 if (argc == 1)
4804 {
4805 ret = inet_aton(argv[0], &addr);
4806 if (!ret)
4807 {
4808 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4809 VTY_NEWLINE);
4810 return CMD_WARNING;
4811 }
4812
4813 params = ospf_lookup_if_params (ifp, addr);
4814 if (params == NULL)
4815 return CMD_SUCCESS;
4816 }
4817
4818 UNSET_IF_PARAM (params, output_cost_cmd);
4819
4820 if (params != IF_DEF_PARAMS (ifp))
4821 {
4822 ospf_free_if_params (ifp, addr);
4823 ospf_if_update_params (ifp, addr);
4824 }
4825
4826 ospf_if_recalculate_output_cost (ifp);
4827
4828 return CMD_SUCCESS;
4829}
4830
4831ALIAS (no_ip_ospf_cost,
4832 no_ip_ospf_cost_cmd,
4833 "no ip ospf cost",
4834 NO_STR
4835 "IP Information\n"
4836 "OSPF interface commands\n"
4837 "Interface cost\n")
4838
4839ALIAS (no_ip_ospf_cost,
4840 no_ospf_cost_cmd,
4841 "no ospf cost",
4842 NO_STR
4843 "OSPF interface commands\n"
4844 "Interface cost\n")
4845
9eff36b3
DO
4846ALIAS (no_ip_ospf_cost,
4847 no_ospf_cost_inet4_cmd,
4848 "no ospf cost A.B.C.D",
4849 NO_STR
4850 "OSPF interface commands\n"
4851 "Interface cost\n"
4852 "Address of interface")
4853
827341b7
DO
4854DEFUN (no_ip_ospf_cost2,
4855 no_ip_ospf_cost_u32_cmd,
4856 "no ip ospf cost <1-65535>",
4857 NO_STR
4858 "IP Information\n"
4859 "OSPF interface commands\n"
4860 "Interface cost\n"
4861 "Cost")
4862{
4863 struct interface *ifp = vty->index;
4864 struct in_addr addr;
4865 u_int32_t cost;
4866 int ret;
4867 struct ospf_if_params *params;
4868
4869 ifp = vty->index;
4870 params = IF_DEF_PARAMS (ifp);
4871
4872 /* According to the semantics we are mimicking "no ip ospf cost N" is
4873 * always treated as "no ip ospf cost" regardless of the actual value
4874 * of N already configured for the interface. Thus the first argument
4875 * is always checked to be a number, but is ignored after that.
4876 */
4877 cost = strtol (argv[0], NULL, 10);
4878 if (cost < 1 || cost > 65535)
4879 {
4880 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4881 return CMD_WARNING;
4882 }
4883
4884 if (argc == 2)
4885 {
4886 ret = inet_aton(argv[1], &addr);
4887 if (!ret)
4888 {
4889 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4890 VTY_NEWLINE);
4891 return CMD_WARNING;
4892 }
4893
4894 params = ospf_lookup_if_params (ifp, addr);
4895 if (params == NULL)
4896 return CMD_SUCCESS;
4897 }
4898
4899 UNSET_IF_PARAM (params, output_cost_cmd);
4900
4901 if (params != IF_DEF_PARAMS (ifp))
4902 {
4903 ospf_free_if_params (ifp, addr);
4904 ospf_if_update_params (ifp, addr);
4905 }
4906
4907 ospf_if_recalculate_output_cost (ifp);
4908
4909 return CMD_SUCCESS;
4910}
4911
4912ALIAS (no_ip_ospf_cost2,
4913 no_ospf_cost_u32_cmd,
4914 "no ospf cost <1-65535>",
4915 NO_STR
4916 "OSPF interface commands\n"
4917 "Interface cost\n"
4918 "Cost")
4919
4920ALIAS (no_ip_ospf_cost2,
4921 no_ip_ospf_cost_u32_inet4_cmd,
4922 "no ip ospf cost <1-65535> A.B.C.D",
4923 NO_STR
4924 "IP Information\n"
4925 "OSPF interface commands\n"
4926 "Interface cost\n"
4927 "Cost\n"
4928 "Address of interface")
4929
4930ALIAS (no_ip_ospf_cost2,
4931 no_ospf_cost_u32_inet4_cmd,
4932 "no ospf cost <1-65535> A.B.C.D",
4933 NO_STR
4934 "OSPF interface commands\n"
4935 "Interface cost\n"
4936 "Cost\n"
4937 "Address of interface")
9eff36b3 4938
4dadc291 4939static void
718e3744 4940ospf_nbr_timer_update (struct ospf_interface *oi)
4941{
4942 struct route_node *rn;
4943 struct ospf_neighbor *nbr;
4944
4945 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4946 if ((nbr = rn->info))
4947 {
4948 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
4949 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
4950 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
4951 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
4952 }
4953}
4954
f9ad937f 4955static int
4956ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
4957 const char *nbr_str,
4958 const char *fast_hello_str)
718e3744 4959{
4960 struct interface *ifp = vty->index;
4961 u_int32_t seconds;
f9ad937f 4962 u_char hellomult;
718e3744 4963 struct in_addr addr;
4964 int ret;
4965 struct ospf_if_params *params;
4966 struct ospf_interface *oi;
4967 struct route_node *rn;
4968
4969 params = IF_DEF_PARAMS (ifp);
f9ad937f 4970
4971 if (nbr_str)
718e3744 4972 {
f9ad937f 4973 ret = inet_aton(nbr_str, &addr);
718e3744 4974 if (!ret)
4975 {
4976 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4977 VTY_NEWLINE);
4978 return CMD_WARNING;
4979 }
4980
4981 params = ospf_get_if_params (ifp, addr);
4982 ospf_if_update_params (ifp, addr);
4983 }
4984
f9ad937f 4985 if (interval_str)
4986 {
4987 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
4988 1, 65535);
4989
4990 /* reset fast_hello too, just to be sure */
4991 UNSET_IF_PARAM (params, fast_hello);
4992 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
4993 }
4994 else if (fast_hello_str)
4995 {
4996 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
4997 1, 10);
4998 /* 1s dead-interval with sub-second hellos desired */
4999 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
5000 SET_IF_PARAM (params, fast_hello);
5001 params->fast_hello = hellomult;
5002 }
5003 else
5004 {
5005 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5006 VTY_NEWLINE);
5007 return CMD_WARNING;
5008 }
5009
718e3744 5010 SET_IF_PARAM (params, v_wait);
5011 params->v_wait = seconds;
5012
5013 /* Update timer values in neighbor structure. */
f9ad937f 5014 if (nbr_str)
718e3744 5015 {
cac3b5c4
PJ
5016 struct ospf *ospf;
5017 if ((ospf = ospf_lookup()))
68980084 5018 {
5019 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5020 if (oi)
5021 ospf_nbr_timer_update (oi);
5022 }
718e3744 5023 }
5024 else
5025 {
5026 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5027 if ((oi = rn->info))
5028 ospf_nbr_timer_update (oi);
5029 }
5030
5031 return CMD_SUCCESS;
5032}
5033
f9ad937f 5034
5035DEFUN (ip_ospf_dead_interval,
5036 ip_ospf_dead_interval_addr_cmd,
5037 "ip ospf dead-interval <1-65535> A.B.C.D",
5038 "IP Information\n"
5039 "OSPF interface commands\n"
5040 "Interval after which a neighbor is declared dead\n"
5041 "Seconds\n"
5042 "Address of interface\n")
5043{
5044 if (argc == 2)
5045 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5046 else
5047 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5048}
5049
718e3744 5050ALIAS (ip_ospf_dead_interval,
5051 ip_ospf_dead_interval_cmd,
5052 "ip ospf dead-interval <1-65535>",
5053 "IP Information\n"
5054 "OSPF interface commands\n"
5055 "Interval after which a neighbor is declared dead\n"
5056 "Seconds\n")
5057
5058ALIAS (ip_ospf_dead_interval,
5059 ospf_dead_interval_cmd,
5060 "ospf dead-interval <1-65535>",
5061 "OSPF interface commands\n"
5062 "Interval after which a neighbor is declared dead\n"
5063 "Seconds\n")
5064
f9ad937f 5065DEFUN (ip_ospf_dead_interval_minimal,
5066 ip_ospf_dead_interval_minimal_addr_cmd,
5067 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5068 "IP Information\n"
5069 "OSPF interface commands\n"
5070 "Interval after which a neighbor is declared dead\n"
5071 "Minimal 1s dead-interval with fast sub-second hellos\n"
5072 "Hello multiplier factor\n"
5073 "Number of Hellos to send each second\n"
5074 "Address of interface\n")
5075{
5076 if (argc == 2)
5077 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5078 else
5079 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5080}
5081
5082ALIAS (ip_ospf_dead_interval_minimal,
5083 ip_ospf_dead_interval_minimal_cmd,
5084 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5085 "IP Information\n"
5086 "OSPF interface commands\n"
5087 "Interval after which a neighbor is declared dead\n"
5088 "Minimal 1s dead-interval with fast sub-second hellos\n"
5089 "Hello multiplier factor\n"
5090 "Number of Hellos to send each second\n")
5091
718e3744 5092DEFUN (no_ip_ospf_dead_interval,
5093 no_ip_ospf_dead_interval_addr_cmd,
5094 "no ip ospf dead-interval A.B.C.D",
5095 NO_STR
5096 "IP Information\n"
5097 "OSPF interface commands\n"
5098 "Interval after which a neighbor is declared dead\n"
5099 "Address of interface")
5100{
5101 struct interface *ifp = vty->index;
5102 struct in_addr addr;
5103 int ret;
5104 struct ospf_if_params *params;
5105 struct ospf_interface *oi;
5106 struct route_node *rn;
020709f9 5107
718e3744 5108 ifp = vty->index;
5109 params = IF_DEF_PARAMS (ifp);
5110
5111 if (argc == 1)
5112 {
5113 ret = inet_aton(argv[0], &addr);
5114 if (!ret)
5115 {
5116 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5117 VTY_NEWLINE);
5118 return CMD_WARNING;
5119 }
5120
5121 params = ospf_lookup_if_params (ifp, addr);
5122 if (params == NULL)
5123 return CMD_SUCCESS;
5124 }
5125
5126 UNSET_IF_PARAM (params, v_wait);
5127 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
f9ad937f 5128
5129 UNSET_IF_PARAM (params, fast_hello);
5130 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5131
718e3744 5132 if (params != IF_DEF_PARAMS (ifp))
5133 {
5134 ospf_free_if_params (ifp, addr);
5135 ospf_if_update_params (ifp, addr);
5136 }
5137
5138 /* Update timer values in neighbor structure. */
5139 if (argc == 1)
5140 {
cac3b5c4
PJ
5141 struct ospf *ospf;
5142
5143 if ((ospf = ospf_lookup()))
68980084 5144 {
5145 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5146 if (oi)
5147 ospf_nbr_timer_update (oi);
5148 }
718e3744 5149 }
5150 else
5151 {
5152 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5153 if ((oi = rn->info))
5154 ospf_nbr_timer_update (oi);
5155 }
5156
5157 return CMD_SUCCESS;
5158}
5159
5160ALIAS (no_ip_ospf_dead_interval,
5161 no_ip_ospf_dead_interval_cmd,
5162 "no ip ospf dead-interval",
5163 NO_STR
5164 "IP Information\n"
5165 "OSPF interface commands\n"
5166 "Interval after which a neighbor is declared dead\n")
5167
5168ALIAS (no_ip_ospf_dead_interval,
5169 no_ospf_dead_interval_cmd,
5170 "no ospf dead-interval",
5171 NO_STR
5172 "OSPF interface commands\n"
5173 "Interval after which a neighbor is declared dead\n")
5174
5175DEFUN (ip_ospf_hello_interval,
5176 ip_ospf_hello_interval_addr_cmd,
5177 "ip ospf hello-interval <1-65535> A.B.C.D",
5178 "IP Information\n"
5179 "OSPF interface commands\n"
5180 "Time between HELLO packets\n"
5181 "Seconds\n"
5182 "Address of interface")
5183{
5184 struct interface *ifp = vty->index;
5185 u_int32_t seconds;
5186 struct in_addr addr;
5187 int ret;
5188 struct ospf_if_params *params;
5189
5190 params = IF_DEF_PARAMS (ifp);
5191
5192 seconds = strtol (argv[0], NULL, 10);
5193
5194 /* HelloInterval range is <1-65535>. */
5195 if (seconds < 1 || seconds > 65535)
5196 {
5197 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5198 return CMD_WARNING;
5199 }
5200
5201 if (argc == 2)
5202 {
5203 ret = inet_aton(argv[1], &addr);
5204 if (!ret)
5205 {
5206 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5207 VTY_NEWLINE);
5208 return CMD_WARNING;
5209 }
5210
5211 params = ospf_get_if_params (ifp, addr);
5212 ospf_if_update_params (ifp, addr);
5213 }
5214
f9ad937f 5215 SET_IF_PARAM (params, v_hello);
718e3744 5216 params->v_hello = seconds;
5217
5218 return CMD_SUCCESS;
5219}
5220
5221ALIAS (ip_ospf_hello_interval,
5222 ip_ospf_hello_interval_cmd,
5223 "ip ospf hello-interval <1-65535>",
5224 "IP Information\n"
5225 "OSPF interface commands\n"
5226 "Time between HELLO packets\n"
5227 "Seconds\n")
5228
5229ALIAS (ip_ospf_hello_interval,
5230 ospf_hello_interval_cmd,
5231 "ospf hello-interval <1-65535>",
5232 "OSPF interface commands\n"
5233 "Time between HELLO packets\n"
5234 "Seconds\n")
5235
5236DEFUN (no_ip_ospf_hello_interval,
5237 no_ip_ospf_hello_interval_addr_cmd,
5238 "no ip ospf hello-interval A.B.C.D",
5239 NO_STR
5240 "IP Information\n"
5241 "OSPF interface commands\n"
5242 "Time between HELLO packets\n"
5243 "Address of interface")
5244{
5245 struct interface *ifp = vty->index;
5246 struct in_addr addr;
5247 int ret;
5248 struct ospf_if_params *params;
5249
5250 ifp = vty->index;
5251 params = IF_DEF_PARAMS (ifp);
5252
5253 if (argc == 1)
5254 {
5255 ret = inet_aton(argv[0], &addr);
5256 if (!ret)
5257 {
5258 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5259 VTY_NEWLINE);
5260 return CMD_WARNING;
5261 }
5262
5263 params = ospf_lookup_if_params (ifp, addr);
5264 if (params == NULL)
5265 return CMD_SUCCESS;
5266 }
5267
5268 UNSET_IF_PARAM (params, v_hello);
f9ad937f 5269 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
718e3744 5270
5271 if (params != IF_DEF_PARAMS (ifp))
5272 {
5273 ospf_free_if_params (ifp, addr);
5274 ospf_if_update_params (ifp, addr);
5275 }
5276
5277 return CMD_SUCCESS;
5278}
5279
5280ALIAS (no_ip_ospf_hello_interval,
5281 no_ip_ospf_hello_interval_cmd,
5282 "no ip ospf hello-interval",
5283 NO_STR
5284 "IP Information\n"
5285 "OSPF interface commands\n"
5286 "Time between HELLO packets\n")
5287
5288ALIAS (no_ip_ospf_hello_interval,
5289 no_ospf_hello_interval_cmd,
5290 "no ospf hello-interval",
5291 NO_STR
5292 "OSPF interface commands\n"
5293 "Time between HELLO packets\n")
5294
5295DEFUN (ip_ospf_network,
5296 ip_ospf_network_cmd,
5297 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5298 "IP Information\n"
5299 "OSPF interface commands\n"
5300 "Network type\n"
5301 "Specify OSPF broadcast multi-access network\n"
5302 "Specify OSPF NBMA network\n"
5303 "Specify OSPF point-to-multipoint network\n"
5304 "Specify OSPF point-to-point network\n")
5305{
5306 struct interface *ifp = vty->index;
5307 int old_type = IF_DEF_PARAMS (ifp)->type;
5308 struct route_node *rn;
5309
5310 if (strncmp (argv[0], "b", 1) == 0)
5311 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5312 else if (strncmp (argv[0], "n", 1) == 0)
5313 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5314 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5315 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5316 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5317 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5318
5319 if (IF_DEF_PARAMS (ifp)->type == old_type)
5320 return CMD_SUCCESS;
5321
5322 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5323
5324 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5325 {
5326 struct ospf_interface *oi = rn->info;
5327
5328 if (!oi)
5329 continue;
5330
5331 oi->type = IF_DEF_PARAMS (ifp)->type;
5332
5333 if (oi->state > ISM_Down)
5334 {
5335 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5336 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5337 }
5338 }
5339
5340 return CMD_SUCCESS;
5341}
5342
5343ALIAS (ip_ospf_network,
5344 ospf_network_cmd,
5345 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5346 "OSPF interface commands\n"
5347 "Network type\n"
5348 "Specify OSPF broadcast multi-access network\n"
5349 "Specify OSPF NBMA network\n"
5350 "Specify OSPF point-to-multipoint network\n"
5351 "Specify OSPF point-to-point network\n")
5352
5353DEFUN (no_ip_ospf_network,
5354 no_ip_ospf_network_cmd,
5355 "no ip ospf network",
5356 NO_STR
5357 "IP Information\n"
5358 "OSPF interface commands\n"
5359 "Network type\n")
5360{
5361 struct interface *ifp = vty->index;
5362 int old_type = IF_DEF_PARAMS (ifp)->type;
5363 struct route_node *rn;
5364
bc18d616 5365 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
718e3744 5366
5367 if (IF_DEF_PARAMS (ifp)->type == old_type)
5368 return CMD_SUCCESS;
5369
5370 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5371 {
5372 struct ospf_interface *oi = rn->info;
5373
5374 if (!oi)
5375 continue;
5376
5377 oi->type = IF_DEF_PARAMS (ifp)->type;
5378
5379 if (oi->state > ISM_Down)
5380 {
5381 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5382 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5383 }
5384 }
5385
5386 return CMD_SUCCESS;
5387}
5388
5389ALIAS (no_ip_ospf_network,
5390 no_ospf_network_cmd,
5391 "no ospf network",
5392 NO_STR
5393 "OSPF interface commands\n"
5394 "Network type\n")
5395
5396DEFUN (ip_ospf_priority,
5397 ip_ospf_priority_addr_cmd,
5398 "ip ospf priority <0-255> A.B.C.D",
5399 "IP Information\n"
5400 "OSPF interface commands\n"
5401 "Router priority\n"
5402 "Priority\n"
5403 "Address of interface")
5404{
5405 struct interface *ifp = vty->index;
5406 u_int32_t priority;
5407 struct route_node *rn;
5408 struct in_addr addr;
5409 int ret;
5410 struct ospf_if_params *params;
5411
5412 params = IF_DEF_PARAMS (ifp);
5413
5414 priority = strtol (argv[0], NULL, 10);
5415
5416 /* Router Priority range is <0-255>. */
5417 if (priority < 0 || priority > 255)
5418 {
5419 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5420 return CMD_WARNING;
5421 }
5422
5423 if (argc == 2)
5424 {
5425 ret = inet_aton(argv[1], &addr);
5426 if (!ret)
5427 {
5428 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5429 VTY_NEWLINE);
5430 return CMD_WARNING;
5431 }
5432
5433 params = ospf_get_if_params (ifp, addr);
5434 ospf_if_update_params (ifp, addr);
5435 }
5436
5437 SET_IF_PARAM (params, priority);
5438 params->priority = priority;
5439
5440 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5441 {
5442 struct ospf_interface *oi = rn->info;
5443
5444 if (!oi)
5445 continue;
5446
5447
5448 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5449 {
5450 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5451 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5452 }
5453 }
5454
5455 return CMD_SUCCESS;
5456}
5457
5458ALIAS (ip_ospf_priority,
5459 ip_ospf_priority_cmd,
5460 "ip ospf priority <0-255>",
5461 "IP Information\n"
5462 "OSPF interface commands\n"
5463 "Router priority\n"
5464 "Priority\n")
5465
5466ALIAS (ip_ospf_priority,
5467 ospf_priority_cmd,
5468 "ospf priority <0-255>",
5469 "OSPF interface commands\n"
5470 "Router priority\n"
5471 "Priority\n")
5472
5473DEFUN (no_ip_ospf_priority,
5474 no_ip_ospf_priority_addr_cmd,
5475 "no ip ospf priority A.B.C.D",
5476 NO_STR
5477 "IP Information\n"
5478 "OSPF interface commands\n"
5479 "Router priority\n"
5480 "Address of interface")
5481{
5482 struct interface *ifp = vty->index;
5483 struct route_node *rn;
5484 struct in_addr addr;
5485 int ret;
5486 struct ospf_if_params *params;
5487
5488 ifp = vty->index;
5489 params = IF_DEF_PARAMS (ifp);
5490
5491 if (argc == 1)
5492 {
5493 ret = inet_aton(argv[0], &addr);
5494 if (!ret)
5495 {
5496 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5497 VTY_NEWLINE);
5498 return CMD_WARNING;
5499 }
5500
5501 params = ospf_lookup_if_params (ifp, addr);
5502 if (params == NULL)
5503 return CMD_SUCCESS;
5504 }
5505
5506 UNSET_IF_PARAM (params, priority);
5507 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5508
5509 if (params != IF_DEF_PARAMS (ifp))
5510 {
5511 ospf_free_if_params (ifp, addr);
5512 ospf_if_update_params (ifp, addr);
5513 }
5514
5515 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5516 {
5517 struct ospf_interface *oi = rn->info;
5518
5519 if (!oi)
5520 continue;
5521
5522
5523 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5524 {
5525 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5526 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5527 }
5528 }
5529
5530 return CMD_SUCCESS;
5531}
5532
5533ALIAS (no_ip_ospf_priority,
5534 no_ip_ospf_priority_cmd,
5535 "no ip ospf priority",
5536 NO_STR
5537 "IP Information\n"
5538 "OSPF interface commands\n"
5539 "Router priority\n")
5540
5541ALIAS (no_ip_ospf_priority,
5542 no_ospf_priority_cmd,
5543 "no ospf priority",
5544 NO_STR
5545 "OSPF interface commands\n"
5546 "Router priority\n")
5547
5548DEFUN (ip_ospf_retransmit_interval,
5549 ip_ospf_retransmit_interval_addr_cmd,
5550 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5551 "IP Information\n"
5552 "OSPF interface commands\n"
5553 "Time between retransmitting lost link state advertisements\n"
5554 "Seconds\n"
5555 "Address of interface")
5556{
5557 struct interface *ifp = vty->index;
5558 u_int32_t seconds;
5559 struct in_addr addr;
5560 int ret;
5561 struct ospf_if_params *params;
5562
5563 params = IF_DEF_PARAMS (ifp);
5564 seconds = strtol (argv[0], NULL, 10);
5565
5566 /* Retransmit Interval range is <3-65535>. */
5567 if (seconds < 3 || seconds > 65535)
5568 {
5569 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5570 return CMD_WARNING;
5571 }
5572
5573
5574 if (argc == 2)
5575 {
5576 ret = inet_aton(argv[1], &addr);
5577 if (!ret)
5578 {
5579 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5580 VTY_NEWLINE);
5581 return CMD_WARNING;
5582 }
5583
5584 params = ospf_get_if_params (ifp, addr);
5585 ospf_if_update_params (ifp, addr);
5586 }
5587
5588 SET_IF_PARAM (params, retransmit_interval);
5589 params->retransmit_interval = seconds;
5590
5591 return CMD_SUCCESS;
5592}
5593
5594ALIAS (ip_ospf_retransmit_interval,
5595 ip_ospf_retransmit_interval_cmd,
5596 "ip ospf retransmit-interval <3-65535>",
5597 "IP Information\n"
5598 "OSPF interface commands\n"
5599 "Time between retransmitting lost link state advertisements\n"
5600 "Seconds\n")
5601
5602ALIAS (ip_ospf_retransmit_interval,
5603 ospf_retransmit_interval_cmd,
5604 "ospf retransmit-interval <3-65535>",
5605 "OSPF interface commands\n"
5606 "Time between retransmitting lost link state advertisements\n"
5607 "Seconds\n")
5608
5609DEFUN (no_ip_ospf_retransmit_interval,
5610 no_ip_ospf_retransmit_interval_addr_cmd,
5611 "no ip ospf retransmit-interval A.B.C.D",
5612 NO_STR
5613 "IP Information\n"
5614 "OSPF interface commands\n"
5615 "Time between retransmitting lost link state advertisements\n"
5616 "Address of interface")
5617{
5618 struct interface *ifp = vty->index;
5619 struct in_addr addr;
5620 int ret;
5621 struct ospf_if_params *params;
5622
5623 ifp = vty->index;
5624 params = IF_DEF_PARAMS (ifp);
5625
5626 if (argc == 1)
5627 {
5628 ret = inet_aton(argv[0], &addr);
5629 if (!ret)
5630 {
5631 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5632 VTY_NEWLINE);
5633 return CMD_WARNING;
5634 }
5635
5636 params = ospf_lookup_if_params (ifp, addr);
5637 if (params == NULL)
5638 return CMD_SUCCESS;
5639 }
5640
5641 UNSET_IF_PARAM (params, retransmit_interval);
5642 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5643
5644 if (params != IF_DEF_PARAMS (ifp))
5645 {
5646 ospf_free_if_params (ifp, addr);
5647 ospf_if_update_params (ifp, addr);
5648 }
5649
5650 return CMD_SUCCESS;
5651}
5652
5653ALIAS (no_ip_ospf_retransmit_interval,
5654 no_ip_ospf_retransmit_interval_cmd,
5655 "no ip ospf retransmit-interval",
5656 NO_STR
5657 "IP Information\n"
5658 "OSPF interface commands\n"
5659 "Time between retransmitting lost link state advertisements\n")
5660
5661ALIAS (no_ip_ospf_retransmit_interval,
5662 no_ospf_retransmit_interval_cmd,
5663 "no ospf retransmit-interval",
5664 NO_STR
5665 "OSPF interface commands\n"
5666 "Time between retransmitting lost link state advertisements\n")
5667
5668DEFUN (ip_ospf_transmit_delay,
5669 ip_ospf_transmit_delay_addr_cmd,
5670 "ip ospf transmit-delay <1-65535> A.B.C.D",
5671 "IP Information\n"
5672 "OSPF interface commands\n"
5673 "Link state transmit delay\n"
5674 "Seconds\n"
5675 "Address of interface")
5676{
5677 struct interface *ifp = vty->index;
5678 u_int32_t seconds;
5679 struct in_addr addr;
5680 int ret;
5681 struct ospf_if_params *params;
5682
5683 params = IF_DEF_PARAMS (ifp);
5684 seconds = strtol (argv[0], NULL, 10);
5685
5686 /* Transmit Delay range is <1-65535>. */
5687 if (seconds < 1 || seconds > 65535)
5688 {
5689 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5690 return CMD_WARNING;
5691 }
5692
5693 if (argc == 2)
5694 {
5695 ret = inet_aton(argv[1], &addr);
5696 if (!ret)
5697 {
5698 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5699 VTY_NEWLINE);
5700 return CMD_WARNING;
5701 }
5702
5703 params = ospf_get_if_params (ifp, addr);
5704 ospf_if_update_params (ifp, addr);
5705 }
5706
5707 SET_IF_PARAM (params, transmit_delay);
5708 params->transmit_delay = seconds;
5709
5710 return CMD_SUCCESS;
5711}
5712
5713ALIAS (ip_ospf_transmit_delay,
5714 ip_ospf_transmit_delay_cmd,
5715 "ip ospf transmit-delay <1-65535>",
5716 "IP Information\n"
5717 "OSPF interface commands\n"
5718 "Link state transmit delay\n"
5719 "Seconds\n")
5720
5721ALIAS (ip_ospf_transmit_delay,
5722 ospf_transmit_delay_cmd,
5723 "ospf transmit-delay <1-65535>",
5724 "OSPF interface commands\n"
5725 "Link state transmit delay\n"
5726 "Seconds\n")
5727
5728DEFUN (no_ip_ospf_transmit_delay,
5729 no_ip_ospf_transmit_delay_addr_cmd,
5730 "no ip ospf transmit-delay A.B.C.D",
5731 NO_STR
5732 "IP Information\n"
5733 "OSPF interface commands\n"
5734 "Link state transmit delay\n"
5735 "Address of interface")
5736{
5737 struct interface *ifp = vty->index;
5738 struct in_addr addr;
5739 int ret;
5740 struct ospf_if_params *params;
5741
5742 ifp = vty->index;
5743 params = IF_DEF_PARAMS (ifp);
5744
5745 if (argc == 1)
5746 {
5747 ret = inet_aton(argv[0], &addr);
5748 if (!ret)
5749 {
5750 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5751 VTY_NEWLINE);
5752 return CMD_WARNING;
5753 }
5754
5755 params = ospf_lookup_if_params (ifp, addr);
5756 if (params == NULL)
5757 return CMD_SUCCESS;
5758 }
5759
5760 UNSET_IF_PARAM (params, transmit_delay);
5761 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5762
5763 if (params != IF_DEF_PARAMS (ifp))
5764 {
5765 ospf_free_if_params (ifp, addr);
5766 ospf_if_update_params (ifp, addr);
5767 }
5768
5769 return CMD_SUCCESS;
5770}
5771
5772ALIAS (no_ip_ospf_transmit_delay,
5773 no_ip_ospf_transmit_delay_cmd,
5774 "no ip ospf transmit-delay",
5775 NO_STR
5776 "IP Information\n"
5777 "OSPF interface commands\n"
5778 "Link state transmit delay\n")
5779
5780ALIAS (no_ip_ospf_transmit_delay,
5781 no_ospf_transmit_delay_cmd,
5782 "no ospf transmit-delay",
5783 NO_STR
5784 "OSPF interface commands\n"
5785 "Link state transmit delay\n")
5786
5787\f
5788DEFUN (ospf_redistribute_source_metric_type,
5789 ospf_redistribute_source_metric_type_routemap_cmd,
d1c65c21
PJ
5790 "redistribute " QUAGGA_REDIST_STR_OSPFD
5791 " metric <0-16777214> metric-type (1|2) route-map WORD",
5792 REDIST_STR
5793 QUAGGA_REDIST_HELP_STR_OSPFD
718e3744 5794 "Metric for redistributed routes\n"
5795 "OSPF default metric\n"
5796 "OSPF exterior metric type for redistributed routes\n"
5797 "Set OSPF External Type 1 metrics\n"
5798 "Set OSPF External Type 2 metrics\n"
5799 "Route map reference\n"
5800 "Pointer to route-map entries\n")
5801{
020709f9 5802 struct ospf *ospf = vty->index;
718e3744 5803 int source;
5804 int type = -1;
5805 int metric = -1;
5806
5807 /* Get distribute source. */
e0ca5fde
DL
5808 source = proto_redistnum(AFI_IP, argv[0]);
5809 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 5810 return CMD_WARNING;
5811
5812 /* Get metric value. */
5813 if (argc >= 2)
5814 if (!str2metric (argv[1], &metric))
5815 return CMD_WARNING;
5816
5817 /* Get metric type. */
5818 if (argc >= 3)
5819 if (!str2metric_type (argv[2], &type))
5820 return CMD_WARNING;
5821
5822 if (argc == 4)
020709f9 5823 ospf_routemap_set (ospf, source, argv[3]);
718e3744 5824 else
020709f9 5825 ospf_routemap_unset (ospf, source);
718e3744 5826
020709f9 5827 return ospf_redistribute_set (ospf, source, type, metric);
718e3744 5828}
5829
5830ALIAS (ospf_redistribute_source_metric_type,
5831 ospf_redistribute_source_metric_type_cmd,
d1c65c21
PJ
5832 "redistribute " QUAGGA_REDIST_STR_OSPFD
5833 " metric <0-16777214> metric-type (1|2)",
5834 REDIST_STR
5835 QUAGGA_REDIST_HELP_STR_OSPFD
718e3744 5836 "Metric for redistributed routes\n"
5837 "OSPF default metric\n"
5838 "OSPF exterior metric type for redistributed routes\n"
5839 "Set OSPF External Type 1 metrics\n"
5840 "Set OSPF External Type 2 metrics\n")
5841
5842ALIAS (ospf_redistribute_source_metric_type,
5843 ospf_redistribute_source_metric_cmd,
d1c65c21
PJ
5844 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric <0-16777214>",
5845 REDIST_STR
5846 QUAGGA_REDIST_HELP_STR_OSPFD
718e3744 5847 "Metric for redistributed routes\n"
5848 "OSPF default metric\n")
5849
5850DEFUN (ospf_redistribute_source_type_metric,
5851 ospf_redistribute_source_type_metric_routemap_cmd,
d1c65c21
PJ
5852 "redistribute " QUAGGA_REDIST_STR_OSPFD
5853 " metric-type (1|2) metric <0-16777214> route-map WORD",
5854 REDIST_STR
5855 QUAGGA_REDIST_HELP_STR_OSPFD
718e3744 5856 "OSPF exterior metric type for redistributed routes\n"
5857 "Set OSPF External Type 1 metrics\n"
5858 "Set OSPF External Type 2 metrics\n"
5859 "Metric for redistributed routes\n"
5860 "OSPF default metric\n"
5861 "Route map reference\n"
5862 "Pointer to route-map entries\n")
5863{
020709f9 5864 struct ospf *ospf = vty->index;
718e3744 5865 int source;
5866 int type = -1;
5867 int metric = -1;
5868
5869 /* Get distribute source. */
e0ca5fde
DL
5870 source = proto_redistnum(AFI_IP, argv[0]);
5871 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 5872 return CMD_WARNING;
5873
5874 /* Get metric value. */
5875 if (argc >= 2)
5876 if (!str2metric_type (argv[1], &type))
5877 return CMD_WARNING;
5878
5879 /* Get metric type. */
5880 if (argc >= 3)
5881 if (!str2metric (argv[2], &metric))
5882 return CMD_WARNING;
5883
5884 if (argc == 4)
020709f9 5885 ospf_routemap_set (ospf, source, argv[3]);
718e3744 5886 else
020709f9 5887 ospf_routemap_unset (ospf, source);
718e3744 5888
020709f9 5889 return ospf_redistribute_set (ospf, source, type, metric);
718e3744 5890}
5891
5892ALIAS (ospf_redistribute_source_type_metric,
5893 ospf_redistribute_source_type_metric_cmd,
d1c65c21
PJ
5894 "redistribute " QUAGGA_REDIST_STR_OSPFD
5895 " metric-type (1|2) metric <0-16777214>",
5896 REDIST_STR
5897 QUAGGA_REDIST_HELP_STR_OSPFD
718e3744 5898 "OSPF exterior metric type for redistributed routes\n"
5899 "Set OSPF External Type 1 metrics\n"
5900 "Set OSPF External Type 2 metrics\n"
5901 "Metric for redistributed routes\n"
5902 "OSPF default metric\n")
5903
5904ALIAS (ospf_redistribute_source_type_metric,
5905 ospf_redistribute_source_type_cmd,
d1c65c21
PJ
5906 "redistribute " QUAGGA_REDIST_STR_OSPFD " metric-type (1|2)",
5907 REDIST_STR
5908 QUAGGA_REDIST_HELP_STR_OSPFD
718e3744 5909 "OSPF exterior metric type for redistributed routes\n"
5910 "Set OSPF External Type 1 metrics\n"
5911 "Set OSPF External Type 2 metrics\n")
5912
5913ALIAS (ospf_redistribute_source_type_metric,
5914 ospf_redistribute_source_cmd,
d1c65c21
PJ
5915 "redistribute " QUAGGA_REDIST_STR_OSPFD,
5916 REDIST_STR
5917 QUAGGA_REDIST_HELP_STR_OSPFD)
718e3744 5918
5919DEFUN (ospf_redistribute_source_metric_routemap,
5920 ospf_redistribute_source_metric_routemap_cmd,
d1c65c21
PJ
5921 "redistribute " QUAGGA_REDIST_STR_OSPFD
5922 " metric <0-16777214> route-map WORD",
5923 REDIST_STR
5924 QUAGGA_REDIST_HELP_STR_OSPFD
718e3744 5925 "Metric for redistributed routes\n"
5926 "OSPF default metric\n"
5927 "Route map reference\n"
5928 "Pointer to route-map entries\n")
5929{
020709f9 5930 struct ospf *ospf = vty->index;
718e3744 5931 int source;
5932 int metric = -1;
5933
5934 /* Get distribute source. */
e0ca5fde
DL
5935 source = proto_redistnum(AFI_IP, argv[0]);
5936 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 5937 return CMD_WARNING;
5938
5939 /* Get metric value. */
5940 if (argc >= 2)
5941 if (!str2metric (argv[1], &metric))
5942 return CMD_WARNING;
5943
5944 if (argc == 3)
020709f9 5945 ospf_routemap_set (ospf, source, argv[2]);
718e3744 5946 else
020709f9 5947 ospf_routemap_unset (ospf, source);
718e3744 5948
020709f9 5949 return ospf_redistribute_set (ospf, source, -1, metric);
718e3744 5950}
5951
5952DEFUN (ospf_redistribute_source_type_routemap,
5953 ospf_redistribute_source_type_routemap_cmd,
d1c65c21
PJ
5954 "redistribute " QUAGGA_REDIST_STR_OSPFD
5955 " metric-type (1|2) route-map WORD",
5956 REDIST_STR
5957 QUAGGA_REDIST_HELP_STR_OSPFD
718e3744 5958 "OSPF exterior metric type for redistributed routes\n"
5959 "Set OSPF External Type 1 metrics\n"
5960 "Set OSPF External Type 2 metrics\n"
5961 "Route map reference\n"
5962 "Pointer to route-map entries\n")
5963{
020709f9 5964 struct ospf *ospf = vty->index;
718e3744 5965 int source;
5966 int type = -1;
5967
5968 /* Get distribute source. */
e0ca5fde
DL
5969 source = proto_redistnum(AFI_IP, argv[0]);
5970 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 5971 return CMD_WARNING;
5972
5973 /* Get metric value. */
5974 if (argc >= 2)
5975 if (!str2metric_type (argv[1], &type))
5976 return CMD_WARNING;
5977
5978 if (argc == 3)
020709f9 5979 ospf_routemap_set (ospf, source, argv[2]);
718e3744 5980 else
020709f9 5981 ospf_routemap_unset (ospf, source);
718e3744 5982
020709f9 5983 return ospf_redistribute_set (ospf, source, type, -1);
718e3744 5984}
5985
5986DEFUN (ospf_redistribute_source_routemap,
5987 ospf_redistribute_source_routemap_cmd,
d1c65c21
PJ
5988 "redistribute " QUAGGA_REDIST_STR_OSPFD " route-map WORD",
5989 REDIST_STR
5990 QUAGGA_REDIST_HELP_STR_OSPFD
718e3744 5991 "Route map reference\n"
5992 "Pointer to route-map entries\n")
5993{
020709f9 5994 struct ospf *ospf = vty->index;
718e3744 5995 int source;
5996
5997 /* Get distribute source. */
e0ca5fde
DL
5998 source = proto_redistnum(AFI_IP, argv[0]);
5999 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 6000 return CMD_WARNING;
6001
6002 if (argc == 2)
020709f9 6003 ospf_routemap_set (ospf, source, argv[1]);
718e3744 6004 else
020709f9 6005 ospf_routemap_unset (ospf, source);
718e3744 6006
020709f9 6007 return ospf_redistribute_set (ospf, source, -1, -1);
718e3744 6008}
6009
6010DEFUN (no_ospf_redistribute_source,
6011 no_ospf_redistribute_source_cmd,
d1c65c21 6012 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
718e3744 6013 NO_STR
d1c65c21
PJ
6014 REDIST_STR
6015 QUAGGA_REDIST_HELP_STR_OSPFD)
718e3744 6016{
020709f9 6017 struct ospf *ospf = vty->index;
718e3744 6018 int source;
6019
e0ca5fde
DL
6020 source = proto_redistnum(AFI_IP, argv[0]);
6021 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 6022 return CMD_WARNING;
6023
020709f9 6024 ospf_routemap_unset (ospf, source);
6025 return ospf_redistribute_unset (ospf, source);
718e3744 6026}
6027
6028DEFUN (ospf_distribute_list_out,
6029 ospf_distribute_list_out_cmd,
d1c65c21 6030 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
718e3744 6031 "Filter networks in routing updates\n"
6032 "Access-list name\n"
6033 OUT_STR
d1c65c21 6034 QUAGGA_REDIST_HELP_STR_OSPFD)
718e3744 6035{
68980084 6036 struct ospf *ospf = vty->index;
718e3744 6037 int source;
6038
6039 /* Get distribute source. */
e0ca5fde
DL
6040 source = proto_redistnum(AFI_IP, argv[0]);
6041 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 6042 return CMD_WARNING;
6043
68980084 6044 return ospf_distribute_list_out_set (ospf, source, argv[0]);
718e3744 6045}
6046
6047DEFUN (no_ospf_distribute_list_out,
6048 no_ospf_distribute_list_out_cmd,
d1c65c21 6049 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
718e3744 6050 NO_STR
6051 "Filter networks in routing updates\n"
6052 "Access-list name\n"
6053 OUT_STR
d1c65c21 6054 QUAGGA_REDIST_HELP_STR_OSPFD)
718e3744 6055{
68980084 6056 struct ospf *ospf = vty->index;
718e3744 6057 int source;
6058
e0ca5fde
DL
6059 source = proto_redistnum(AFI_IP, argv[0]);
6060 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 6061 return CMD_WARNING;
6062
68980084 6063 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
718e3744 6064}
6065
6066/* Default information originate. */
6067DEFUN (ospf_default_information_originate_metric_type_routemap,
6068 ospf_default_information_originate_metric_type_routemap_cmd,
6069 "default-information originate metric <0-16777214> metric-type (1|2) route-map WORD",
6070 "Control distribution of default information\n"
6071 "Distribute a default route\n"
6072 "OSPF default metric\n"
6073 "OSPF metric\n"
6074 "OSPF metric type for default routes\n"
6075 "Set OSPF External Type 1 metrics\n"
6076 "Set OSPF External Type 2 metrics\n"
6077 "Route map reference\n"
6078 "Pointer to route-map entries\n")
6079{
020709f9 6080 struct ospf *ospf = vty->index;
718e3744 6081 int type = -1;
6082 int metric = -1;
6083
6084 /* Get metric value. */
6085 if (argc >= 1)
6086 if (!str2metric (argv[0], &metric))
6087 return CMD_WARNING;
6088
6089 /* Get metric type. */
6090 if (argc >= 2)
6091 if (!str2metric_type (argv[1], &type))
6092 return CMD_WARNING;
6093
6094 if (argc == 3)
020709f9 6095 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
718e3744 6096 else
020709f9 6097 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
718e3744 6098
020709f9 6099 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6100 type, metric);
718e3744 6101}
6102
6103ALIAS (ospf_default_information_originate_metric_type_routemap,
6104 ospf_default_information_originate_metric_type_cmd,
6105 "default-information originate metric <0-16777214> metric-type (1|2)",
6106 "Control distribution of default information\n"
6107 "Distribute a default route\n"
6108 "OSPF default metric\n"
6109 "OSPF metric\n"
6110 "OSPF metric type for default routes\n"
6111 "Set OSPF External Type 1 metrics\n"
6112 "Set OSPF External Type 2 metrics\n")
6113
6114ALIAS (ospf_default_information_originate_metric_type_routemap,
6115 ospf_default_information_originate_metric_cmd,
6116 "default-information originate metric <0-16777214>",
6117 "Control distribution of default information\n"
6118 "Distribute a default route\n"
6119 "OSPF default metric\n"
6120 "OSPF metric\n")
6121
6122ALIAS (ospf_default_information_originate_metric_type_routemap,
6123 ospf_default_information_originate_cmd,
6124 "default-information originate",
6125 "Control distribution of default information\n"
6126 "Distribute a default route\n")
6127
6128/* Default information originate. */
6129DEFUN (ospf_default_information_originate_metric_routemap,
6130 ospf_default_information_originate_metric_routemap_cmd,
6131 "default-information originate metric <0-16777214> route-map WORD",
6132 "Control distribution of default information\n"
6133 "Distribute a default route\n"
6134 "OSPF default metric\n"
6135 "OSPF metric\n"
6136 "Route map reference\n"
6137 "Pointer to route-map entries\n")
6138{
020709f9 6139 struct ospf *ospf = vty->index;
718e3744 6140 int metric = -1;
6141
6142 /* Get metric value. */
6143 if (argc >= 1)
6144 if (!str2metric (argv[0], &metric))
6145 return CMD_WARNING;
6146
6147 if (argc == 2)
020709f9 6148 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
718e3744 6149 else
020709f9 6150 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
718e3744 6151
020709f9 6152 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6153 -1, metric);
718e3744 6154}
6155
6156/* Default information originate. */
6157DEFUN (ospf_default_information_originate_routemap,
6158 ospf_default_information_originate_routemap_cmd,
6159 "default-information originate route-map WORD",
6160 "Control distribution of default information\n"
6161 "Distribute a default route\n"
6162 "Route map reference\n"
6163 "Pointer to route-map entries\n")
6164{
020709f9 6165 struct ospf *ospf = vty->index;
6166
718e3744 6167 if (argc == 1)
020709f9 6168 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
718e3744 6169 else
020709f9 6170 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
718e3744 6171
020709f9 6172 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA, -1, -1);
718e3744 6173}
6174
6175DEFUN (ospf_default_information_originate_type_metric_routemap,
6176 ospf_default_information_originate_type_metric_routemap_cmd,
6177 "default-information originate metric-type (1|2) metric <0-16777214> route-map WORD",
6178 "Control distribution of default information\n"
6179 "Distribute a default route\n"
6180 "OSPF metric type for default routes\n"
6181 "Set OSPF External Type 1 metrics\n"
6182 "Set OSPF External Type 2 metrics\n"
6183 "OSPF default metric\n"
6184 "OSPF metric\n"
6185 "Route map reference\n"
6186 "Pointer to route-map entries\n")
6187{
020709f9 6188 struct ospf *ospf = vty->index;
718e3744 6189 int type = -1;
6190 int metric = -1;
6191
6192 /* Get metric type. */
6193 if (argc >= 1)
6194 if (!str2metric_type (argv[0], &type))
6195 return CMD_WARNING;
6196
6197 /* Get metric value. */
6198 if (argc >= 2)
6199 if (!str2metric (argv[1], &metric))
6200 return CMD_WARNING;
6201
6202 if (argc == 3)
020709f9 6203 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
718e3744 6204 else
020709f9 6205 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
718e3744 6206
020709f9 6207 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6208 type, metric);
718e3744 6209}
6210
6211ALIAS (ospf_default_information_originate_type_metric_routemap,
6212 ospf_default_information_originate_type_metric_cmd,
6213 "default-information originate metric-type (1|2) metric <0-16777214>",
6214 "Control distribution of default information\n"
6215 "Distribute a default route\n"
6216 "OSPF metric type for default routes\n"
6217 "Set OSPF External Type 1 metrics\n"
6218 "Set OSPF External Type 2 metrics\n"
6219 "OSPF default metric\n"
6220 "OSPF metric\n")
6221
6222ALIAS (ospf_default_information_originate_type_metric_routemap,
6223 ospf_default_information_originate_type_cmd,
6224 "default-information originate metric-type (1|2)",
6225 "Control distribution of default information\n"
6226 "Distribute a default route\n"
6227 "OSPF metric type for default routes\n"
6228 "Set OSPF External Type 1 metrics\n"
6229 "Set OSPF External Type 2 metrics\n")
6230
6231DEFUN (ospf_default_information_originate_type_routemap,
6232 ospf_default_information_originate_type_routemap_cmd,
6233 "default-information originate metric-type (1|2) route-map WORD",
6234 "Control distribution of default information\n"
6235 "Distribute a default route\n"
6236 "OSPF metric type for default routes\n"
6237 "Set OSPF External Type 1 metrics\n"
6238 "Set OSPF External Type 2 metrics\n"
6239 "Route map reference\n"
6240 "Pointer to route-map entries\n")
6241{
020709f9 6242 struct ospf *ospf = vty->index;
718e3744 6243 int type = -1;
6244
6245 /* Get metric type. */
6246 if (argc >= 1)
6247 if (!str2metric_type (argv[0], &type))
6248 return CMD_WARNING;
6249
6250 if (argc == 2)
020709f9 6251 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
718e3744 6252 else
020709f9 6253 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
718e3744 6254
020709f9 6255 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ZEBRA,
6256 type, -1);
718e3744 6257}
6258
6259DEFUN (ospf_default_information_originate_always_metric_type_routemap,
6260 ospf_default_information_originate_always_metric_type_routemap_cmd,
6261 "default-information originate always metric <0-16777214> metric-type (1|2) route-map WORD",
6262 "Control distribution of default information\n"
6263 "Distribute a default route\n"
6264 "Always advertise default route\n"
6265 "OSPF default metric\n"
6266 "OSPF metric\n"
6267 "OSPF metric type for default routes\n"
6268 "Set OSPF External Type 1 metrics\n"
6269 "Set OSPF External Type 2 metrics\n"
6270 "Route map reference\n"
6271 "Pointer to route-map entries\n")
6272{
020709f9 6273 struct ospf *ospf = vty->index;
718e3744 6274 int type = -1;
6275 int metric = -1;
6276
6277 /* Get metric value. */
6278 if (argc >= 1)
6279 if (!str2metric (argv[0], &metric))
6280 return CMD_WARNING;
6281
6282 /* Get metric type. */
6283 if (argc >= 2)
6284 if (!str2metric_type (argv[1], &type))
6285 return CMD_WARNING;
6286
6287 if (argc == 3)
020709f9 6288 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
718e3744 6289 else
020709f9 6290 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
718e3744 6291
020709f9 6292 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
718e3744 6293 type, metric);
6294}
6295
6296ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6297 ospf_default_information_originate_always_metric_type_cmd,
6298 "default-information originate always metric <0-16777214> metric-type (1|2)",
6299 "Control distribution of default information\n"
6300 "Distribute a default route\n"
6301 "Always advertise default route\n"
6302 "OSPF default metric\n"
6303 "OSPF metric\n"
6304 "OSPF metric type for default routes\n"
6305 "Set OSPF External Type 1 metrics\n"
6306 "Set OSPF External Type 2 metrics\n")
6307
6308ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6309 ospf_default_information_originate_always_metric_cmd,
6310 "default-information originate always metric <0-16777214>",
6311 "Control distribution of default information\n"
6312 "Distribute a default route\n"
6313 "Always advertise default route\n"
6314 "OSPF default metric\n"
6315 "OSPF metric\n"
6316 "OSPF metric type for default routes\n")
6317
6318ALIAS (ospf_default_information_originate_always_metric_type_routemap,
6319 ospf_default_information_originate_always_cmd,
6320 "default-information originate always",
6321 "Control distribution of default information\n"
6322 "Distribute a default route\n"
6323 "Always advertise default route\n")
6324
6325DEFUN (ospf_default_information_originate_always_metric_routemap,
6326 ospf_default_information_originate_always_metric_routemap_cmd,
6327 "default-information originate always metric <0-16777214> route-map WORD",
6328 "Control distribution of default information\n"
6329 "Distribute a default route\n"
6330 "Always advertise default route\n"
6331 "OSPF default metric\n"
6332 "OSPF metric\n"
6333 "Route map reference\n"
6334 "Pointer to route-map entries\n")
6335{
020709f9 6336 struct ospf *ospf = vty->index;
718e3744 6337 int metric = -1;
6338
6339 /* Get metric value. */
6340 if (argc >= 1)
6341 if (!str2metric (argv[0], &metric))
6342 return CMD_WARNING;
6343
6344 if (argc == 2)
020709f9 6345 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
718e3744 6346 else
020709f9 6347 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
718e3744 6348
020709f9 6349 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
6350 -1, metric);
718e3744 6351}
6352
6353DEFUN (ospf_default_information_originate_always_routemap,
6354 ospf_default_information_originate_always_routemap_cmd,
6355 "default-information originate always route-map WORD",
6356 "Control distribution of default information\n"
6357 "Distribute a default route\n"
6358 "Always advertise default route\n"
6359 "Route map reference\n"
6360 "Pointer to route-map entries\n")
6361{
020709f9 6362 struct ospf *ospf = vty->index;
6363
718e3744 6364 if (argc == 1)
020709f9 6365 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[0]);
718e3744 6366 else
020709f9 6367 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
718e3744 6368
020709f9 6369 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS, -1, -1);
718e3744 6370}
6371
6372DEFUN (ospf_default_information_originate_always_type_metric_routemap,
6373 ospf_default_information_originate_always_type_metric_routemap_cmd,
6374 "default-information originate always metric-type (1|2) metric <0-16777214> route-map WORD",
6375 "Control distribution of default information\n"
6376 "Distribute a default route\n"
6377 "Always advertise default route\n"
6378 "OSPF metric type for default routes\n"
6379 "Set OSPF External Type 1 metrics\n"
6380 "Set OSPF External Type 2 metrics\n"
6381 "OSPF default metric\n"
6382 "OSPF metric\n"
6383 "Route map reference\n"
6384 "Pointer to route-map entries\n")
6385{
020709f9 6386 struct ospf *ospf = vty->index;
718e3744 6387 int type = -1;
6388 int metric = -1;
6389
6390 /* Get metric type. */
6391 if (argc >= 1)
6392 if (!str2metric_type (argv[0], &type))
6393 return CMD_WARNING;
6394
6395 /* Get metric value. */
6396 if (argc >= 2)
6397 if (!str2metric (argv[1], &metric))
6398 return CMD_WARNING;
6399
6400 if (argc == 3)
020709f9 6401 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[2]);
718e3744 6402 else
020709f9 6403 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
718e3744 6404
020709f9 6405 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
718e3744 6406 type, metric);
6407}
6408
6409ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6410 ospf_default_information_originate_always_type_metric_cmd,
6411 "default-information originate always metric-type (1|2) metric <0-16777214>",
6412 "Control distribution of default information\n"
6413 "Distribute a default route\n"
6414 "Always advertise default route\n"
6415 "OSPF metric type for default routes\n"
6416 "Set OSPF External Type 1 metrics\n"
6417 "Set OSPF External Type 2 metrics\n"
6418 "OSPF default metric\n"
6419 "OSPF metric\n")
6420
6421ALIAS (ospf_default_information_originate_always_type_metric_routemap,
6422 ospf_default_information_originate_always_type_cmd,
6423 "default-information originate always metric-type (1|2)",
6424 "Control distribution of default information\n"
6425 "Distribute a default route\n"
6426 "Always advertise default route\n"
6427 "OSPF metric type for default routes\n"
6428 "Set OSPF External Type 1 metrics\n"
6429 "Set OSPF External Type 2 metrics\n")
6430
6431DEFUN (ospf_default_information_originate_always_type_routemap,
6432 ospf_default_information_originate_always_type_routemap_cmd,
6433 "default-information originate always metric-type (1|2) route-map WORD",
6434 "Control distribution of default information\n"
6435 "Distribute a default route\n"
6436 "Always advertise default route\n"
6437 "OSPF metric type for default routes\n"
6438 "Set OSPF External Type 1 metrics\n"
6439 "Set OSPF External Type 2 metrics\n"
6440 "Route map reference\n"
6441 "Pointer to route-map entries\n")
6442{
020709f9 6443 struct ospf *ospf = vty->index;
718e3744 6444 int type = -1;
6445
6446 /* Get metric type. */
6447 if (argc >= 1)
6448 if (!str2metric_type (argv[0], &type))
6449 return CMD_WARNING;
6450
6451 if (argc == 2)
020709f9 6452 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[1]);
718e3744 6453 else
020709f9 6454 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
718e3744 6455
020709f9 6456 return ospf_redistribute_default_set (ospf, DEFAULT_ORIGINATE_ALWAYS,
718e3744 6457 type, -1);
6458}
6459
6460DEFUN (no_ospf_default_information_originate,
6461 no_ospf_default_information_originate_cmd,
6462 "no default-information originate",
6463 NO_STR
6464 "Control distribution of default information\n"
6465 "Distribute a default route\n")
6466{
68980084 6467 struct ospf *ospf = vty->index;
718e3744 6468 struct prefix_ipv4 p;
718e3744 6469
6470 p.family = AF_INET;
6471 p.prefix.s_addr = 0;
6472 p.prefixlen = 0;
6473
5339cfdb 6474 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
718e3744 6475
6476 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6477 ospf_external_info_delete (DEFAULT_ROUTE, p);
6478 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6479 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6480 }
6481
020709f9 6482 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6483 return ospf_redistribute_default_unset (ospf);
718e3744 6484}
6485
6486DEFUN (ospf_default_metric,
6487 ospf_default_metric_cmd,
6488 "default-metric <0-16777214>",
6489 "Set metric of redistributed routes\n"
6490 "Default metric\n")
6491{
68980084 6492 struct ospf *ospf = vty->index;
718e3744 6493 int metric = -1;
6494
6495 if (!str2metric (argv[0], &metric))
6496 return CMD_WARNING;
6497
68980084 6498 ospf->default_metric = metric;
718e3744 6499
6500 return CMD_SUCCESS;
6501}
6502
6503DEFUN (no_ospf_default_metric,
6504 no_ospf_default_metric_cmd,
6505 "no default-metric",
6506 NO_STR
6507 "Set metric of redistributed routes\n")
6508{
68980084 6509 struct ospf *ospf = vty->index;
6510
6511 ospf->default_metric = -1;
6512
718e3744 6513 return CMD_SUCCESS;
6514}
6515
6516ALIAS (no_ospf_default_metric,
6517 no_ospf_default_metric_val_cmd,
6518 "no default-metric <0-16777214>",
6519 NO_STR
6520 "Set metric of redistributed routes\n"
6521 "Default metric\n")
6522
6523DEFUN (ospf_distance,
6524 ospf_distance_cmd,
6525 "distance <1-255>",
6526 "Define an administrative distance\n"
6527 "OSPF Administrative distance\n")
6528{
68980084 6529 struct ospf *ospf = vty->index;
6530
6531 ospf->distance_all = atoi (argv[0]);
6532
718e3744 6533 return CMD_SUCCESS;
6534}
6535
6536DEFUN (no_ospf_distance,
6537 no_ospf_distance_cmd,
6538 "no distance <1-255>",
6539 NO_STR
6540 "Define an administrative distance\n"
6541 "OSPF Administrative distance\n")
6542{
68980084 6543 struct ospf *ospf = vty->index;
6544
6545 ospf->distance_all = 0;
6546
718e3744 6547 return CMD_SUCCESS;
6548}
6549
6550DEFUN (no_ospf_distance_ospf,
6551 no_ospf_distance_ospf_cmd,
6552 "no distance ospf",
6553 NO_STR
6554 "Define an administrative distance\n"
6555 "OSPF Administrative distance\n"
6556 "OSPF Distance\n")
6557{
68980084 6558 struct ospf *ospf = vty->index;
6559
6560 ospf->distance_intra = 0;
6561 ospf->distance_inter = 0;
6562 ospf->distance_external = 0;
6563
718e3744 6564 return CMD_SUCCESS;
6565}
6566
6567DEFUN (ospf_distance_ospf_intra,
6568 ospf_distance_ospf_intra_cmd,
6569 "distance ospf intra-area <1-255>",
6570 "Define an administrative distance\n"
6571 "OSPF Administrative distance\n"
6572 "Intra-area routes\n"
6573 "Distance for intra-area routes\n")
6574{
68980084 6575 struct ospf *ospf = vty->index;
6576
6577 ospf->distance_intra = atoi (argv[0]);
6578
718e3744 6579 return CMD_SUCCESS;
6580}
6581
6582DEFUN (ospf_distance_ospf_intra_inter,
6583 ospf_distance_ospf_intra_inter_cmd,
6584 "distance ospf intra-area <1-255> inter-area <1-255>",
6585 "Define an administrative distance\n"
6586 "OSPF Administrative distance\n"
6587 "Intra-area routes\n"
6588 "Distance for intra-area routes\n"
6589 "Inter-area routes\n"
6590 "Distance for inter-area routes\n")
6591{
68980084 6592 struct ospf *ospf = vty->index;
6593
6594 ospf->distance_intra = atoi (argv[0]);
6595 ospf->distance_inter = atoi (argv[1]);
6596
718e3744 6597 return CMD_SUCCESS;
6598}
6599
6600DEFUN (ospf_distance_ospf_intra_external,
6601 ospf_distance_ospf_intra_external_cmd,
6602 "distance ospf intra-area <1-255> external <1-255>",
6603 "Define an administrative distance\n"
6604 "OSPF Administrative distance\n"
6605 "Intra-area routes\n"
6606 "Distance for intra-area routes\n"
6607 "External routes\n"
6608 "Distance for external routes\n")
6609{
68980084 6610 struct ospf *ospf = vty->index;
6611
6612 ospf->distance_intra = atoi (argv[0]);
6613 ospf->distance_external = atoi (argv[1]);
6614
718e3744 6615 return CMD_SUCCESS;
6616}
6617
6618DEFUN (ospf_distance_ospf_intra_inter_external,
6619 ospf_distance_ospf_intra_inter_external_cmd,
6620 "distance ospf intra-area <1-255> inter-area <1-255> external <1-255>",
6621 "Define an administrative distance\n"
6622 "OSPF Administrative distance\n"
6623 "Intra-area routes\n"
6624 "Distance for intra-area routes\n"
6625 "Inter-area routes\n"
6626 "Distance for inter-area routes\n"
6627 "External routes\n"
6628 "Distance for external routes\n")
6629{
68980084 6630 struct ospf *ospf = vty->index;
6631
6632 ospf->distance_intra = atoi (argv[0]);
6633 ospf->distance_inter = atoi (argv[1]);
6634 ospf->distance_external = atoi (argv[2]);
6635
718e3744 6636 return CMD_SUCCESS;
6637}
6638
6639DEFUN (ospf_distance_ospf_intra_external_inter,
6640 ospf_distance_ospf_intra_external_inter_cmd,
6641 "distance ospf intra-area <1-255> external <1-255> inter-area <1-255>",
6642 "Define an administrative distance\n"
6643 "OSPF Administrative distance\n"
6644 "Intra-area routes\n"
6645 "Distance for intra-area routes\n"
6646 "External routes\n"
6647 "Distance for external routes\n"
6648 "Inter-area routes\n"
6649 "Distance for inter-area routes\n")
6650{
68980084 6651 struct ospf *ospf = vty->index;
6652
6653 ospf->distance_intra = atoi (argv[0]);
6654 ospf->distance_external = atoi (argv[1]);
6655 ospf->distance_inter = atoi (argv[2]);
6656
718e3744 6657 return CMD_SUCCESS;
6658}
6659
6660DEFUN (ospf_distance_ospf_inter,
6661 ospf_distance_ospf_inter_cmd,
6662 "distance ospf inter-area <1-255>",
6663 "Define an administrative distance\n"
6664 "OSPF Administrative distance\n"
6665 "Inter-area routes\n"
6666 "Distance for inter-area routes\n")
6667{
68980084 6668 struct ospf *ospf = vty->index;
6669
6670 ospf->distance_inter = atoi (argv[0]);
6671
718e3744 6672 return CMD_SUCCESS;
6673}
6674
6675DEFUN (ospf_distance_ospf_inter_intra,
6676 ospf_distance_ospf_inter_intra_cmd,
6677 "distance ospf inter-area <1-255> intra-area <1-255>",
6678 "Define an administrative distance\n"
6679 "OSPF Administrative distance\n"
6680 "Inter-area routes\n"
6681 "Distance for inter-area routes\n"
6682 "Intra-area routes\n"
6683 "Distance for intra-area routes\n")
6684{
68980084 6685 struct ospf *ospf = vty->index;
6686
6687 ospf->distance_inter = atoi (argv[0]);
6688 ospf->distance_intra = atoi (argv[1]);
6689
718e3744 6690 return CMD_SUCCESS;
6691}
6692
6693DEFUN (ospf_distance_ospf_inter_external,
6694 ospf_distance_ospf_inter_external_cmd,
6695 "distance ospf inter-area <1-255> external <1-255>",
6696 "Define an administrative distance\n"
6697 "OSPF Administrative distance\n"
6698 "Inter-area routes\n"
6699 "Distance for inter-area routes\n"
6700 "External routes\n"
6701 "Distance for external routes\n")
6702{
68980084 6703 struct ospf *ospf = vty->index;
6704
6705 ospf->distance_inter = atoi (argv[0]);
6706 ospf->distance_external = atoi (argv[1]);
6707
718e3744 6708 return CMD_SUCCESS;
6709}
6710
6711DEFUN (ospf_distance_ospf_inter_intra_external,
6712 ospf_distance_ospf_inter_intra_external_cmd,
6713 "distance ospf inter-area <1-255> intra-area <1-255> external <1-255>",
6714 "Define an administrative distance\n"
6715 "OSPF Administrative distance\n"
6716 "Inter-area routes\n"
6717 "Distance for inter-area routes\n"
6718 "Intra-area routes\n"
6719 "Distance for intra-area routes\n"
6720 "External routes\n"
6721 "Distance for external routes\n")
6722{
68980084 6723 struct ospf *ospf = vty->index;
6724
6725 ospf->distance_inter = atoi (argv[0]);
6726 ospf->distance_intra = atoi (argv[1]);
6727 ospf->distance_external = atoi (argv[2]);
6728
718e3744 6729 return CMD_SUCCESS;
6730}
6731
6732DEFUN (ospf_distance_ospf_inter_external_intra,
6733 ospf_distance_ospf_inter_external_intra_cmd,
6734 "distance ospf inter-area <1-255> external <1-255> intra-area <1-255>",
6735 "Define an administrative distance\n"
6736 "OSPF Administrative distance\n"
6737 "Inter-area routes\n"
6738 "Distance for inter-area routes\n"
6739 "External routes\n"
6740 "Distance for external routes\n"
6741 "Intra-area routes\n"
6742 "Distance for intra-area routes\n")
6743{
68980084 6744 struct ospf *ospf = vty->index;
6745
6746 ospf->distance_inter = atoi (argv[0]);
6747 ospf->distance_external = atoi (argv[1]);
6748 ospf->distance_intra = atoi (argv[2]);
6749
718e3744 6750 return CMD_SUCCESS;
6751}
6752
6753DEFUN (ospf_distance_ospf_external,
6754 ospf_distance_ospf_external_cmd,
6755 "distance ospf external <1-255>",
6756 "Define an administrative distance\n"
6757 "OSPF Administrative distance\n"
6758 "External routes\n"
6759 "Distance for external routes\n")
6760{
68980084 6761 struct ospf *ospf = vty->index;
6762
6763 ospf->distance_external = atoi (argv[0]);
6764
718e3744 6765 return CMD_SUCCESS;
6766}
6767
6768DEFUN (ospf_distance_ospf_external_intra,
6769 ospf_distance_ospf_external_intra_cmd,
6770 "distance ospf external <1-255> intra-area <1-255>",
6771 "Define an administrative distance\n"
6772 "OSPF Administrative distance\n"
6773 "External routes\n"
6774 "Distance for external routes\n"
6775 "Intra-area routes\n"
6776 "Distance for intra-area routes\n")
6777{
68980084 6778 struct ospf *ospf = vty->index;
6779
6780 ospf->distance_external = atoi (argv[0]);
6781 ospf->distance_intra = atoi (argv[1]);
6782
718e3744 6783 return CMD_SUCCESS;
6784}
6785
6786DEFUN (ospf_distance_ospf_external_inter,
6787 ospf_distance_ospf_external_inter_cmd,
6788 "distance ospf external <1-255> inter-area <1-255>",
6789 "Define an administrative distance\n"
6790 "OSPF Administrative distance\n"
6791 "External routes\n"
6792 "Distance for external routes\n"
6793 "Inter-area routes\n"
6794 "Distance for inter-area routes\n")
6795{
68980084 6796 struct ospf *ospf = vty->index;
6797
6798 ospf->distance_external = atoi (argv[0]);
6799 ospf->distance_inter = atoi (argv[1]);
6800
718e3744 6801 return CMD_SUCCESS;
6802}
6803
6804DEFUN (ospf_distance_ospf_external_intra_inter,
6805 ospf_distance_ospf_external_intra_inter_cmd,
6806 "distance ospf external <1-255> intra-area <1-255> inter-area <1-255>",
6807 "Define an administrative distance\n"
6808 "OSPF Administrative distance\n"
6809 "External routes\n"
6810 "Distance for external routes\n"
6811 "Intra-area routes\n"
6812 "Distance for intra-area routes\n"
6813 "Inter-area routes\n"
6814 "Distance for inter-area routes\n")
6815{
68980084 6816 struct ospf *ospf = vty->index;
6817
6818 ospf->distance_external = atoi (argv[0]);
6819 ospf->distance_intra = atoi (argv[1]);
6820 ospf->distance_inter = atoi (argv[2]);
6821
718e3744 6822 return CMD_SUCCESS;
6823}
6824
6825DEFUN (ospf_distance_ospf_external_inter_intra,
6826 ospf_distance_ospf_external_inter_intra_cmd,
6827 "distance ospf external <1-255> inter-area <1-255> intra-area <1-255>",
6828 "Define an administrative distance\n"
6829 "OSPF Administrative distance\n"
6830 "External routes\n"
6831 "Distance for external routes\n"
6832 "Inter-area routes\n"
6833 "Distance for inter-area routes\n"
6834 "Intra-area routes\n"
6835 "Distance for intra-area routes\n")
6836{
68980084 6837 struct ospf *ospf = vty->index;
6838
6839 ospf->distance_external = atoi (argv[0]);
6840 ospf->distance_inter = atoi (argv[1]);
6841 ospf->distance_intra = atoi (argv[2]);
6842
718e3744 6843 return CMD_SUCCESS;
6844}
6845
6846DEFUN (ospf_distance_source,
6847 ospf_distance_source_cmd,
6848 "distance <1-255> A.B.C.D/M",
6849 "Administrative distance\n"
6850 "Distance value\n"
6851 "IP source prefix\n")
6852{
020709f9 6853 struct ospf *ospf = vty->index;
6854
6855 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
68980084 6856
718e3744 6857 return CMD_SUCCESS;
6858}
6859
6860DEFUN (no_ospf_distance_source,
6861 no_ospf_distance_source_cmd,
6862 "no distance <1-255> A.B.C.D/M",
6863 NO_STR
6864 "Administrative distance\n"
6865 "Distance value\n"
6866 "IP source prefix\n")
6867{
020709f9 6868 struct ospf *ospf = vty->index;
6869
6870 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6871
718e3744 6872 return CMD_SUCCESS;
6873}
6874
6875DEFUN (ospf_distance_source_access_list,
6876 ospf_distance_source_access_list_cmd,
6877 "distance <1-255> A.B.C.D/M WORD",
6878 "Administrative distance\n"
6879 "Distance value\n"
6880 "IP source prefix\n"
6881 "Access list name\n")
6882{
020709f9 6883 struct ospf *ospf = vty->index;
6884
6885 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6886
718e3744 6887 return CMD_SUCCESS;
6888}
6889
6890DEFUN (no_ospf_distance_source_access_list,
6891 no_ospf_distance_source_access_list_cmd,
6892 "no distance <1-255> A.B.C.D/M WORD",
6893 NO_STR
6894 "Administrative distance\n"
6895 "Distance value\n"
6896 "IP source prefix\n"
6897 "Access list name\n")
6898{
020709f9 6899 struct ospf *ospf = vty->index;
6900
6901 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6902
718e3744 6903 return CMD_SUCCESS;
6904}
6905
ba682537 6906DEFUN (ip_ospf_mtu_ignore,
6907 ip_ospf_mtu_ignore_addr_cmd,
6908 "ip ospf mtu-ignore A.B.C.D",
6909 "IP Information\n"
6910 "OSPF interface commands\n"
6911 "Disable mtu mismatch detection\n"
6912 "Address of interface")
6913{
6914 struct interface *ifp = vty->index;
6915 struct in_addr addr;
6916 int ret;
6917
6918 struct ospf_if_params *params;
6919 params = IF_DEF_PARAMS (ifp);
6920
6921 if (argc == 1)
6922 {
6923 ret = inet_aton(argv[0], &addr);
6924 if (!ret)
6925 {
6926 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6927 VTY_NEWLINE);
6928 return CMD_WARNING;
6929 }
6930 params = ospf_get_if_params (ifp, addr);
6931 ospf_if_update_params (ifp, addr);
6932 }
6933 params->mtu_ignore = 1;
6934 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6935 SET_IF_PARAM (params, mtu_ignore);
6936 else
6937 {
6938 UNSET_IF_PARAM (params, mtu_ignore);
6939 if (params != IF_DEF_PARAMS (ifp))
6940 {
6941 ospf_free_if_params (ifp, addr);
6942 ospf_if_update_params (ifp, addr);
6943 }
6944 }
6945 return CMD_SUCCESS;
6946}
6947
6948ALIAS (ip_ospf_mtu_ignore,
6949 ip_ospf_mtu_ignore_cmd,
6950 "ip ospf mtu-ignore",
6951 "IP Information\n"
6952 "OSPF interface commands\n"
6953 "Disable mtu mismatch detection\n")
6954
6955
6956DEFUN (no_ip_ospf_mtu_ignore,
6957 no_ip_ospf_mtu_ignore_addr_cmd,
6958 "no ip ospf mtu-ignore A.B.C.D",
6959 "IP Information\n"
6960 "OSPF interface commands\n"
6961 "Disable mtu mismatch detection\n"
6962 "Address of interface")
6963{
6964 struct interface *ifp = vty->index;
6965 struct in_addr addr;
6966 int ret;
6967
6968 struct ospf_if_params *params;
6969 params = IF_DEF_PARAMS (ifp);
6970
6971 if (argc == 1)
6972 {
6973 ret = inet_aton(argv[0], &addr);
6974 if (!ret)
6975 {
6976 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6977 VTY_NEWLINE);
6978 return CMD_WARNING;
6979 }
6980 params = ospf_get_if_params (ifp, addr);
6981 ospf_if_update_params (ifp, addr);
6982 }
6983 params->mtu_ignore = 0;
6984 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6985 SET_IF_PARAM (params, mtu_ignore);
6986 else
6987 {
6988 UNSET_IF_PARAM (params, mtu_ignore);
6989 if (params != IF_DEF_PARAMS (ifp))
6990 {
6991 ospf_free_if_params (ifp, addr);
6992 ospf_if_update_params (ifp, addr);
6993 }
6994 }
6995 return CMD_SUCCESS;
6996}
6997
6998ALIAS (no_ip_ospf_mtu_ignore,
6999 no_ip_ospf_mtu_ignore_cmd,
7000 "no ip ospf mtu-ignore",
7001 "IP Information\n"
7002 "OSPF interface commands\n"
7003 "Disable mtu mismatch detection\n")
88d6cf37 7004\f
7005DEFUN (ospf_max_metric_router_lsa_admin,
7006 ospf_max_metric_router_lsa_admin_cmd,
7007 "max-metric router-lsa administrative",
7008 "OSPF maximum / infinite-distance metric\n"
7009 "Advertise own Router-LSA with infinite distance (stub router)\n"
7010 "Administratively applied, for an indefinite period\n")
7011{
7012 struct listnode *ln;
7013 struct ospf_area *area;
7014 struct ospf *ospf = vty->index;
ba682537 7015
88d6cf37 7016 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7017 {
7018 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7019
7020 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
c363d386 7021 ospf_router_lsa_update_area (area);
88d6cf37 7022 }
7023 return CMD_SUCCESS;
7024}
7025
7026DEFUN (no_ospf_max_metric_router_lsa_admin,
7027 no_ospf_max_metric_router_lsa_admin_cmd,
7028 "no max-metric router-lsa administrative",
7029 NO_STR
7030 "OSPF maximum / infinite-distance metric\n"
7031 "Advertise own Router-LSA with infinite distance (stub router)\n"
7032 "Administratively applied, for an indefinite period\n")
7033{
7034 struct listnode *ln;
7035 struct ospf_area *area;
7036 struct ospf *ospf = vty->index;
7037
7038 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7039 {
7040 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
7041
7042 /* Don't trample on the start-up stub timer */
7043 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
7044 && !area->t_stub_router)
7045 {
7046 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
c363d386 7047 ospf_router_lsa_update_area (area);
88d6cf37 7048 }
7049 }
7050 return CMD_SUCCESS;
7051}
7052
7053DEFUN (ospf_max_metric_router_lsa_startup,
7054 ospf_max_metric_router_lsa_startup_cmd,
7055 "max-metric router-lsa on-startup <5-86400>",
7056 "OSPF maximum / infinite-distance metric\n"
7057 "Advertise own Router-LSA with infinite distance (stub router)\n"
7058 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7059 "Time (seconds) to advertise self as stub-router\n")
7060{
7061 unsigned int seconds;
7062 struct ospf *ospf = vty->index;
7063
7064 if (argc != 1)
7065 {
7066 vty_out (vty, "%% Must supply stub-router period");
7067 return CMD_WARNING;
7068 }
7069
7070 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
7071
7072 ospf->stub_router_startup_time = seconds;
7073
7074 return CMD_SUCCESS;
7075}
7076
7077DEFUN (no_ospf_max_metric_router_lsa_startup,
7078 no_ospf_max_metric_router_lsa_startup_cmd,
7079 "no max-metric router-lsa on-startup",
7080 NO_STR
7081 "OSPF maximum / infinite-distance metric\n"
7082 "Advertise own Router-LSA with infinite distance (stub router)\n"
7083 "Automatically advertise stub Router-LSA on startup of OSPF\n")
7084{
7085 struct listnode *ln;
7086 struct ospf_area *area;
7087 struct ospf *ospf = vty->index;
7088
7089 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7090
7091 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7092 {
7093 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
7094 OSPF_TIMER_OFF (area->t_stub_router);
7095
7096 /* Don't trample on admin stub routed */
7097 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7098 {
7099 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
c363d386 7100 ospf_router_lsa_update_area (area);
88d6cf37 7101 }
7102 }
7103 return CMD_SUCCESS;
7104}
7105
7106DEFUN (ospf_max_metric_router_lsa_shutdown,
7107 ospf_max_metric_router_lsa_shutdown_cmd,
7108 "max-metric router-lsa on-shutdown <5-86400>",
7109 "OSPF maximum / infinite-distance metric\n"
7110 "Advertise own Router-LSA with infinite distance (stub router)\n"
7111 "Advertise stub-router prior to full shutdown of OSPF\n"
7112 "Time (seconds) to wait till full shutdown\n")
7113{
7114 unsigned int seconds;
7115 struct ospf *ospf = vty->index;
7116
7117 if (argc != 1)
7118 {
7119 vty_out (vty, "%% Must supply stub-router shutdown period");
7120 return CMD_WARNING;
7121 }
7122
7123 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
7124
7125 ospf->stub_router_shutdown_time = seconds;
7126
7127 return CMD_SUCCESS;
7128}
7129
7130DEFUN (no_ospf_max_metric_router_lsa_shutdown,
7131 no_ospf_max_metric_router_lsa_shutdown_cmd,
7132 "no max-metric router-lsa on-shutdown",
7133 NO_STR
7134 "OSPF maximum / infinite-distance metric\n"
7135 "Advertise own Router-LSA with infinite distance (stub router)\n"
7136 "Advertise stub-router prior to full shutdown of OSPF\n")
7137{
7138 struct ospf *ospf = vty->index;
7139
7140 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
7141
7142 return CMD_SUCCESS;
7143}
7144
7145static void
7146config_write_stub_router (struct vty *vty, struct ospf *ospf)
7147{
7148 struct listnode *ln;
7149 struct ospf_area *area;
7150
7151 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7152 vty_out (vty, " max-metric router-lsa on-startup %u%s",
7153 ospf->stub_router_startup_time, VTY_NEWLINE);
7154 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
7155 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
7156 ospf->stub_router_shutdown_time, VTY_NEWLINE);
7157 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
7158 {
7159 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
7160 {
7161 vty_out (vty, " max-metric router-lsa administrative%s",
7162 VTY_NEWLINE);
7163 break;
7164 }
7165 }
7166 return;
7167}
7168\f
4dadc291 7169static void
718e3744 7170show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
7171{
7172 struct route_node *rn;
7173 struct ospf_route *or;
1eb8ef25 7174 struct listnode *pnode, *pnnode;
718e3744 7175 struct ospf_path *path;
7176
7177 vty_out (vty, "============ OSPF network routing table ============%s",
7178 VTY_NEWLINE);
7179
7180 for (rn = route_top (rt); rn; rn = route_next (rn))
7181 if ((or = rn->info) != NULL)
7182 {
7183 char buf1[19];
7184 snprintf (buf1, 19, "%s/%d",
7185 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7186
7187 switch (or->path_type)
7188 {
7189 case OSPF_PATH_INTER_AREA:
7190 if (or->type == OSPF_DESTINATION_NETWORK)
7191 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
7192 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7193 else if (or->type == OSPF_DESTINATION_DISCARD)
7194 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
7195 break;
7196 case OSPF_PATH_INTRA_AREA:
7197 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
7198 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
7199 break;
7200 default:
7201 break;
7202 }
7203
7204 if (or->type == OSPF_DESTINATION_NETWORK)
1eb8ef25 7205 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
96735eea 7206 {
a8ba847f 7207 if (if_lookup_by_index(path->ifindex))
96735eea 7208 {
7209 if (path->nexthop.s_addr == 0)
7210 vty_out (vty, "%24s directly attached to %s%s",
a8ba847f 7211 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
96735eea 7212 else
7213 vty_out (vty, "%24s via %s, %s%s", "",
a8ba847f
JT
7214 inet_ntoa (path->nexthop),
7215 ifindex2ifname (path->ifindex), VTY_NEWLINE);
96735eea 7216 }
7217 }
718e3744 7218 }
7219 vty_out (vty, "%s", VTY_NEWLINE);
7220}
7221
4dadc291 7222static void
718e3744 7223show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
7224{
7225 struct route_node *rn;
7226 struct ospf_route *or;
1eb8ef25 7227 struct listnode *pnode;
7228 struct listnode *node;
718e3744 7229 struct ospf_path *path;
7230
7231 vty_out (vty, "============ OSPF router routing table =============%s",
7232 VTY_NEWLINE);
7233 for (rn = route_top (rtrs); rn; rn = route_next (rn))
7234 if (rn->info)
7235 {
7236 int flag = 0;
7237
7238 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
7239
1eb8ef25 7240 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
7241 {
7242 if (flag++)
7243 vty_out (vty, "%24s", "");
7244
7245 /* Show path. */
7246 vty_out (vty, "%s [%d] area: %s",
7247 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
7248 or->cost, inet_ntoa (or->u.std.area_id));
7249 /* Show flags. */
7250 vty_out (vty, "%s%s%s",
7251 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
7252 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
7253 VTY_NEWLINE);
7254
7255 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
7256 {
a8ba847f 7257 if (if_lookup_by_index(path->ifindex))
54bedb55 7258 {
7259 if (path->nexthop.s_addr == 0)
7260 vty_out (vty, "%24s directly attached to %s%s",
a8ba847f
JT
7261 "", ifindex2ifname (path->ifindex),
7262 VTY_NEWLINE);
54bedb55 7263 else
7264 vty_out (vty, "%24s via %s, %s%s", "",
7265 inet_ntoa (path->nexthop),
a8ba847f
JT
7266 ifindex2ifname (path->ifindex),
7267 VTY_NEWLINE);
54bedb55 7268 }
1eb8ef25 7269 }
7270 }
718e3744 7271 }
7272 vty_out (vty, "%s", VTY_NEWLINE);
7273}
7274
4dadc291 7275static void
718e3744 7276show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
7277{
7278 struct route_node *rn;
7279 struct ospf_route *er;
1eb8ef25 7280 struct listnode *pnode, *pnnode;
718e3744 7281 struct ospf_path *path;
7282
7283 vty_out (vty, "============ OSPF external routing table ===========%s",
7284 VTY_NEWLINE);
7285 for (rn = route_top (rt); rn; rn = route_next (rn))
7286 if ((er = rn->info) != NULL)
7287 {
7288 char buf1[19];
7289 snprintf (buf1, 19, "%s/%d",
7290 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
7291
7292 switch (er->path_type)
7293 {
7294 case OSPF_PATH_TYPE1_EXTERNAL:
7295 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
7296 er->cost, er->u.ext.tag, VTY_NEWLINE);
7297 break;
7298 case OSPF_PATH_TYPE2_EXTERNAL:
7299 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
7300 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
7301 break;
7302 }
7303
1eb8ef25 7304 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
718e3744 7305 {
a8ba847f 7306 if (if_lookup_by_index(path->ifindex))
718e3744 7307 {
7308 if (path->nexthop.s_addr == 0)
96735eea 7309 vty_out (vty, "%24s directly attached to %s%s",
a8ba847f 7310 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
96735eea 7311 else
7312 vty_out (vty, "%24s via %s, %s%s", "",
a8ba847f
JT
7313 inet_ntoa (path->nexthop),
7314 ifindex2ifname (path->ifindex),
96735eea 7315 VTY_NEWLINE);
718e3744 7316 }
7317 }
7318 }
7319 vty_out (vty, "%s", VTY_NEWLINE);
7320}
7321
718e3744 7322DEFUN (show_ip_ospf_border_routers,
7323 show_ip_ospf_border_routers_cmd,
7324 "show ip ospf border-routers",
7325 SHOW_STR
7326 IP_STR
7327 "show all the ABR's and ASBR's\n"
7328 "for this area\n")
7329{
020709f9 7330 struct ospf *ospf;
68980084 7331
cac3b5c4 7332 if ((ospf = ospf_lookup ()) == NULL)
718e3744 7333 {
cac3b5c4 7334 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
718e3744 7335 return CMD_SUCCESS;
7336 }
7337
68980084 7338 if (ospf->new_table == NULL)
718e3744 7339 {
7340 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7341 return CMD_SUCCESS;
7342 }
7343
7344 /* Show Network routes.
020709f9 7345 show_ip_ospf_route_network (vty, ospf->new_table); */
718e3744 7346
7347 /* Show Router routes. */
68980084 7348 show_ip_ospf_route_router (vty, ospf->new_rtrs);
718e3744 7349
7350 return CMD_SUCCESS;
7351}
718e3744 7352
7353DEFUN (show_ip_ospf_route,
7354 show_ip_ospf_route_cmd,
7355 "show ip ospf route",
7356 SHOW_STR
7357 IP_STR
7358 "OSPF information\n"
7359 "OSPF routing table\n")
7360{
020709f9 7361 struct ospf *ospf;
68980084 7362
cac3b5c4 7363 if ((ospf = ospf_lookup ()) == NULL)
718e3744 7364 {
cac3b5c4 7365 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
718e3744 7366 return CMD_SUCCESS;
7367 }
7368
68980084 7369 if (ospf->new_table == NULL)
718e3744 7370 {
7371 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
7372 return CMD_SUCCESS;
7373 }
7374
7375 /* Show Network routes. */
68980084 7376 show_ip_ospf_route_network (vty, ospf->new_table);
718e3744 7377
7378 /* Show Router routes. */
68980084 7379 show_ip_ospf_route_router (vty, ospf->new_rtrs);
718e3744 7380
7381 /* Show AS External routes. */
68980084 7382 show_ip_ospf_route_external (vty, ospf->old_external_route);
718e3744 7383
7384 return CMD_SUCCESS;
7385}
7386
7387\f
eb1ce605 7388const char *ospf_abr_type_str[] =
718e3744 7389{
7390 "unknown",
7391 "standard",
7392 "ibm",
7393 "cisco",
7394 "shortcut"
7395};
7396
eb1ce605 7397const char *ospf_shortcut_mode_str[] =
718e3744 7398{
7399 "default",
7400 "enable",
7401 "disable"
7402};
7403
7404
4dadc291 7405static void
718e3744 7406area_id2str (char *buf, int length, struct ospf_area *area)
7407{
7408 memset (buf, 0, length);
7409
7410 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
7411 strncpy (buf, inet_ntoa (area->area_id), length);
7412 else
7413 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
7414}
7415
7416\f
eb1ce605 7417const char *ospf_int_type_str[] =
718e3744 7418{
7419 "unknown", /* should never be used. */
7420 "point-to-point",
7421 "broadcast",
7422 "non-broadcast",
7423 "point-to-multipoint",
7424 "virtual-link", /* should never be used. */
7425 "loopback"
7426};
7427
7428/* Configuration write function for ospfd. */
4dadc291 7429static int
718e3744 7430config_write_interface (struct vty *vty)
7431{
52dc7ee6 7432 struct listnode *n1, *n2;
718e3744 7433 struct interface *ifp;
7434 struct crypt_key *ck;
7435 int write = 0;
7436 struct route_node *rn = NULL;
7437 struct ospf_if_params *params;
7438
1eb8ef25 7439 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
718e3744 7440 {
718e3744 7441 if (memcmp (ifp->name, "VLINK", 5) == 0)
7442 continue;
7443
7444 vty_out (vty, "!%s", VTY_NEWLINE);
7445 vty_out (vty, "interface %s%s", ifp->name,
7446 VTY_NEWLINE);
7447 if (ifp->desc)
7448 vty_out (vty, " description %s%s", ifp->desc,
7449 VTY_NEWLINE);
7450
7451 write++;
7452
7453 params = IF_DEF_PARAMS (ifp);
7454
7455 do {
7456 /* Interface Network print. */
7457 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
718e3744 7458 params->type != OSPF_IFTYPE_LOOPBACK)
7459 {
bc18d616 7460 if (params->type != ospf_default_iftype(ifp))
7b90143f 7461 {
7462 vty_out (vty, " ip ospf network %s",
7463 ospf_int_type_str[params->type]);
7464 if (params != IF_DEF_PARAMS (ifp))
7465 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7466 vty_out (vty, "%s", VTY_NEWLINE);
7467 }
718e3744 7468 }
7469
7470 /* OSPF interface authentication print */
7471 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
7472 params->auth_type != OSPF_AUTH_NOTSET)
7473 {
eb1ce605 7474 const char *auth_str;
718e3744 7475
7476 /* Translation tables are not that much help here due to syntax
7477 of the simple option */
7478 switch (params->auth_type)
7479 {
7480
7481 case OSPF_AUTH_NULL:
7482 auth_str = " null";
7483 break;
7484
7485 case OSPF_AUTH_SIMPLE:
7486 auth_str = "";
7487 break;
7488
7489 case OSPF_AUTH_CRYPTOGRAPHIC:
7490 auth_str = " message-digest";
7491 break;
7492
7493 default:
7494 auth_str = "";
7495 break;
7496 }
7497
7498 vty_out (vty, " ip ospf authentication%s", auth_str);
7499 if (params != IF_DEF_PARAMS (ifp))
7500 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7501 vty_out (vty, "%s", VTY_NEWLINE);
7502 }
7503
7504 /* Simple Authentication Password print. */
7505 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
7506 params->auth_simple[0] != '\0')
7507 {
7508 vty_out (vty, " ip ospf authentication-key %s",
7509 params->auth_simple);
7510 if (params != IF_DEF_PARAMS (ifp))
7511 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7512 vty_out (vty, "%s", VTY_NEWLINE);
7513 }
7514
7515 /* Cryptographic Authentication Key print. */
1eb8ef25 7516 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
718e3744 7517 {
718e3744 7518 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7519 ck->key_id, ck->auth_key);
7520 if (params != IF_DEF_PARAMS (ifp))
7521 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7522 vty_out (vty, "%s", VTY_NEWLINE);
7523 }
7524
7525 /* Interface Output Cost print. */
7526 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
7527 {
7528 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
7529 if (params != IF_DEF_PARAMS (ifp))
7530 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7531 vty_out (vty, "%s", VTY_NEWLINE);
7532 }
7533
7534 /* Hello Interval print. */
7535 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
7536 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
7537 {
7538 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
7539 if (params != IF_DEF_PARAMS (ifp))
7540 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7541 vty_out (vty, "%s", VTY_NEWLINE);
7542 }
7543
7544
7545 /* Router Dead Interval print. */
7546 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7547 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7548 {
f9ad937f 7549 vty_out (vty, " ip ospf dead-interval ");
7550
7551 /* fast hello ? */
7552 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7553 vty_out (vty, "minimal hello-multiplier %d",
7554 params->fast_hello);
7555 else
7556 vty_out (vty, "%u", params->v_wait);
7557
718e3744 7558 if (params != IF_DEF_PARAMS (ifp))
7559 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7560 vty_out (vty, "%s", VTY_NEWLINE);
7561 }
7562
7563 /* Router Priority print. */
7564 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7565 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7566 {
7567 vty_out (vty, " ip ospf priority %u", params->priority);
7568 if (params != IF_DEF_PARAMS (ifp))
7569 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7570 vty_out (vty, "%s", VTY_NEWLINE);
7571 }
7572
7573 /* Retransmit Interval print. */
7574 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7575 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7576 {
7577 vty_out (vty, " ip ospf retransmit-interval %u",
7578 params->retransmit_interval);
7579 if (params != IF_DEF_PARAMS (ifp))
7580 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7581 vty_out (vty, "%s", VTY_NEWLINE);
7582 }
7583
7584 /* Transmit Delay print. */
7585 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7586 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7587 {
7588 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7589 if (params != IF_DEF_PARAMS (ifp))
7590 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7591 vty_out (vty, "%s", VTY_NEWLINE);
7592 }
7593
ba682537 7594 /* MTU ignore print. */
7595 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7596 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7597 {
7598 if (params->mtu_ignore == 0)
7599 vty_out (vty, " no ip ospf mtu-ignore");
7600 else
7601 vty_out (vty, " ip ospf mtu-ignore");
7602 if (params != IF_DEF_PARAMS (ifp))
7603 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7604 vty_out (vty, "%s", VTY_NEWLINE);
7605 }
7606
7607
718e3744 7608 while (1)
7609 {
7610 if (rn == NULL)
7611 rn = route_top (IF_OIFS_PARAMS (ifp));
7612 else
7613 rn = route_next (rn);
7614
7615 if (rn == NULL)
7616 break;
7617 params = rn->info;
7618 if (params != NULL)
7619 break;
7620 }
7621 } while (rn);
7622
7623#ifdef HAVE_OPAQUE_LSA
7624 ospf_opaque_config_write_if (vty, ifp);
7625#endif /* HAVE_OPAQUE_LSA */
7626 }
7627
7628 return write;
7629}
7630
4dadc291 7631static int
68980084 7632config_write_network_area (struct vty *vty, struct ospf *ospf)
718e3744 7633{
7634 struct route_node *rn;
7635 u_char buf[INET_ADDRSTRLEN];
7636
7637 /* `network area' print. */
68980084 7638 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
718e3744 7639 if (rn->info)
7640 {
7641 struct ospf_network *n = rn->info;
7642
7643 memset (buf, 0, INET_ADDRSTRLEN);
7644
7645 /* Create Area ID string by specified Area ID format. */
7646 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
c9e52be3 7647 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
718e3744 7648 else
c9e52be3 7649 sprintf ((char *) buf, "%lu",
718e3744 7650 (unsigned long int) ntohl (n->area_id.s_addr));
7651
7652 /* Network print. */
7653 vty_out (vty, " network %s/%d area %s%s",
7654 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7655 buf, VTY_NEWLINE);
7656 }
7657
7658 return 0;
7659}
7660
4dadc291 7661static int
68980084 7662config_write_ospf_area (struct vty *vty, struct ospf *ospf)
718e3744 7663{
52dc7ee6 7664 struct listnode *node;
1eb8ef25 7665 struct ospf_area *area;
718e3744 7666 u_char buf[INET_ADDRSTRLEN];
7667
7668 /* Area configuration print. */
1eb8ef25 7669 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 7670 {
718e3744 7671 struct route_node *rn1;
7672
c9e52be3 7673 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
718e3744 7674
7675 if (area->auth_type != OSPF_AUTH_NULL)
7676 {
7677 if (area->auth_type == OSPF_AUTH_SIMPLE)
7678 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7679 else
7680 vty_out (vty, " area %s authentication message-digest%s",
7681 buf, VTY_NEWLINE);
7682 }
7683
7684 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7685 vty_out (vty, " area %s shortcut %s%s", buf,
7686 ospf_shortcut_mode_str[area->shortcut_configured],
7687 VTY_NEWLINE);
7688
7689 if ((area->external_routing == OSPF_AREA_STUB)
718e3744 7690 || (area->external_routing == OSPF_AREA_NSSA)
718e3744 7691 )
7692 {
b0a053be 7693 if (area->external_routing == OSPF_AREA_STUB)
7694 vty_out (vty, " area %s stub", buf);
b0a053be 7695 else if (area->external_routing == OSPF_AREA_NSSA)
7696 {
7697 vty_out (vty, " area %s nssa", buf);
7698 switch (area->NSSATranslatorRole)
7699 {
7700 case OSPF_NSSA_ROLE_NEVER:
7701 vty_out (vty, " translate-never");
7702 break;
7703 case OSPF_NSSA_ROLE_ALWAYS:
7704 vty_out (vty, " translate-always");
7705 break;
7706 case OSPF_NSSA_ROLE_CANDIDATE:
7707 default:
7708 vty_out (vty, " translate-candidate");
7709 }
7710 }
718e3744 7711
7712 if (area->no_summary)
7713 vty_out (vty, " no-summary");
7714
7715 vty_out (vty, "%s", VTY_NEWLINE);
7716
7717 if (area->default_cost != 1)
7718 vty_out (vty, " area %s default-cost %d%s", buf,
7719 area->default_cost, VTY_NEWLINE);
7720 }
7721
7722 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7723 if (rn1->info)
7724 {
7725 struct ospf_area_range *range = rn1->info;
7726
7727 vty_out (vty, " area %s range %s/%d", buf,
7728 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7729
6c835671 7730 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
718e3744 7731 vty_out (vty, " cost %d", range->cost_config);
7732
7733 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7734 vty_out (vty, " not-advertise");
7735
7736 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7737 vty_out (vty, " substitute %s/%d",
7738 inet_ntoa (range->subst_addr), range->subst_masklen);
7739
7740 vty_out (vty, "%s", VTY_NEWLINE);
7741 }
7742
7743 if (EXPORT_NAME (area))
7744 vty_out (vty, " area %s export-list %s%s", buf,
7745 EXPORT_NAME (area), VTY_NEWLINE);
7746
7747 if (IMPORT_NAME (area))
7748 vty_out (vty, " area %s import-list %s%s", buf,
7749 IMPORT_NAME (area), VTY_NEWLINE);
7750
7751 if (PREFIX_NAME_IN (area))
7752 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7753 PREFIX_NAME_IN (area), VTY_NEWLINE);
7754
7755 if (PREFIX_NAME_OUT (area))
7756 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7757 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7758 }
7759
7760 return 0;
7761}
7762
4dadc291 7763static int
68980084 7764config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
718e3744 7765{
7766 struct ospf_nbr_nbma *nbr_nbma;
7767 struct route_node *rn;
7768
7769 /* Static Neighbor configuration print. */
68980084 7770 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
718e3744 7771 if ((nbr_nbma = rn->info))
7772 {
7773 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7774
7775 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7776 vty_out (vty, " priority %d", nbr_nbma->priority);
7777
7778 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7779 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7780
7781 vty_out (vty, "%s", VTY_NEWLINE);
7782 }
7783
7784 return 0;
7785}
7786
4dadc291 7787static int
68980084 7788config_write_virtual_link (struct vty *vty, struct ospf *ospf)
718e3744 7789{
52dc7ee6 7790 struct listnode *node;
1eb8ef25 7791 struct ospf_vl_data *vl_data;
718e3744 7792 u_char buf[INET_ADDRSTRLEN];
7793
7794 /* Virtual-Link print */
1eb8ef25 7795 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
718e3744 7796 {
52dc7ee6 7797 struct listnode *n2;
718e3744 7798 struct crypt_key *ck;
718e3744 7799 struct ospf_interface *oi;
7800
7801 if (vl_data != NULL)
7802 {
7803 memset (buf, 0, INET_ADDRSTRLEN);
7804
7805 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
c9e52be3 7806 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
718e3744 7807 else
c9e52be3 7808 sprintf ((char *) buf, "%lu",
718e3744 7809 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7810 oi = vl_data->vl_oi;
7811
7812 /* timers */
7813 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7814 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7815 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7816 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7817 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7818 buf,
7819 inet_ntoa (vl_data->vl_peer),
7820 OSPF_IF_PARAM (oi, v_hello),
7821 OSPF_IF_PARAM (oi, retransmit_interval),
7822 OSPF_IF_PARAM (oi, transmit_delay),
7823 OSPF_IF_PARAM (oi, v_wait),
7824 VTY_NEWLINE);
7825 else
7826 vty_out (vty, " area %s virtual-link %s%s", buf,
7827 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7828 /* Auth key */
7829 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7830 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7831 buf,
7832 inet_ntoa (vl_data->vl_peer),
7833 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7834 VTY_NEWLINE);
7835 /* md5 keys */
1eb8ef25 7836 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7837 n2, ck))
7838 vty_out (vty, " area %s virtual-link %s"
7839 " message-digest-key %d md5 %s%s",
7840 buf,
7841 inet_ntoa (vl_data->vl_peer),
7842 ck->key_id, ck->auth_key, VTY_NEWLINE);
718e3744 7843
7844 }
7845 }
7846
7847 return 0;
7848}
7849
7850\f
4dadc291 7851static int
68980084 7852config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
718e3744 7853{
7854 int type;
7855
7856 /* redistribute print. */
7857 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7858 if (type != zclient->redist_default && zclient->redist[type])
7859 {
f52d13cb 7860 vty_out (vty, " redistribute %s", zebra_route_string(type));
68980084 7861 if (ospf->dmetric[type].value >= 0)
020709f9 7862 vty_out (vty, " metric %d", ospf->dmetric[type].value);
718e3744 7863
68980084 7864 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
718e3744 7865 vty_out (vty, " metric-type 1");
7866
020709f9 7867 if (ROUTEMAP_NAME (ospf, type))
7868 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
718e3744 7869
7870 vty_out (vty, "%s", VTY_NEWLINE);
7871 }
7872
7873 return 0;
7874}
7875
4dadc291 7876static int
68980084 7877config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
718e3744 7878{
68980084 7879 if (ospf->default_metric != -1)
7880 vty_out (vty, " default-metric %d%s", ospf->default_metric,
718e3744 7881 VTY_NEWLINE);
7882 return 0;
7883}
7884
4dadc291 7885static int
68980084 7886config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
718e3744 7887{
7888 int type;
7889
68980084 7890 if (ospf)
718e3744 7891 {
7892 /* distribute-list print. */
7893 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
171c9a99 7894 if (DISTRIBUTE_NAME (ospf, type))
718e3744 7895 vty_out (vty, " distribute-list %s out %s%s",
171c9a99 7896 DISTRIBUTE_NAME (ospf, type),
f52d13cb 7897 zebra_route_string(type), VTY_NEWLINE);
718e3744 7898
7899 /* default-information print. */
68980084 7900 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
718e3744 7901 {
c42c177d 7902 vty_out (vty, " default-information originate");
7903 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7904 vty_out (vty, " always");
718e3744 7905
68980084 7906 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
718e3744 7907 vty_out (vty, " metric %d",
68980084 7908 ospf->dmetric[DEFAULT_ROUTE].value);
7909 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
718e3744 7910 vty_out (vty, " metric-type 1");
7911
020709f9 7912 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7913 vty_out (vty, " route-map %s",
7914 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
718e3744 7915
7916 vty_out (vty, "%s", VTY_NEWLINE);
7917 }
7918
7919 }
7920
7921 return 0;
7922}
7923
4dadc291 7924static int
68980084 7925config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
718e3744 7926{
7927 struct route_node *rn;
7928 struct ospf_distance *odistance;
7929
68980084 7930 if (ospf->distance_all)
7931 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
718e3744 7932
68980084 7933 if (ospf->distance_intra
7934 || ospf->distance_inter
7935 || ospf->distance_external)
718e3744 7936 {
7937 vty_out (vty, " distance ospf");
7938
68980084 7939 if (ospf->distance_intra)
7940 vty_out (vty, " intra-area %d", ospf->distance_intra);
7941 if (ospf->distance_inter)
7942 vty_out (vty, " inter-area %d", ospf->distance_inter);
7943 if (ospf->distance_external)
7944 vty_out (vty, " external %d", ospf->distance_external);
718e3744 7945
7946 vty_out (vty, "%s", VTY_NEWLINE);
7947 }
7948
68980084 7949 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
718e3744 7950 if ((odistance = rn->info) != NULL)
7951 {
7952 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7953 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7954 odistance->access_list ? odistance->access_list : "",
7955 VTY_NEWLINE);
7956 }
7957 return 0;
7958}
7959
7960/* OSPF configuration write function. */
4dadc291 7961static int
718e3744 7962ospf_config_write (struct vty *vty)
7963{
020709f9 7964 struct ospf *ospf;
1eb8ef25 7965 struct interface *ifp;
7966 struct ospf_interface *oi;
52dc7ee6 7967 struct listnode *node;
718e3744 7968 int write = 0;
7969
020709f9 7970 ospf = ospf_lookup ();
68980084 7971 if (ospf != NULL)
718e3744 7972 {
7973 /* `router ospf' print. */
7974 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7975
7976 write++;
7977
68980084 7978 if (!ospf->networks)
718e3744 7979 return write;
7980
7981 /* Router ID print. */
68980084 7982 if (ospf->router_id_static.s_addr != 0)
718e3744 7983 vty_out (vty, " ospf router-id %s%s",
68980084 7984 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
718e3744 7985
7986 /* ABR type print. */
d57834f6 7987 if (ospf->abr_type != OSPF_ABR_DEFAULT)
718e3744 7988 vty_out (vty, " ospf abr-type %s%s",
68980084 7989 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
718e3744 7990
d7e60dd7
AS
7991 /* log-adjacency-changes flag print. */
7992 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7993 {
7994 vty_out(vty, " log-adjacency-changes");
7995 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7996 vty_out(vty, " detail");
7997 vty_out(vty, "%s", VTY_NEWLINE);
7998 }
7999
718e3744 8000 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
68980084 8001 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
718e3744 8002 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
8003
8004 /* auto-cost reference-bandwidth configuration. */
68980084 8005 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
f9ad937f 8006 {
8007 vty_out (vty, "! Important: ensure reference bandwidth "
8008 "is consistent across all routers%s", VTY_NEWLINE);
8009 vty_out (vty, " auto-cost reference-bandwidth %d%s",
8010 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
8011 }
718e3744 8012
8013 /* SPF timers print. */
68980084 8014 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
ea4ffc90 8015 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
8016 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
8017 vty_out (vty, " timers throttle spf %d %d %d%s",
88d6cf37 8018 ospf->spf_delay, ospf->spf_holdtime,
ea4ffc90 8019 ospf->spf_max_holdtime, VTY_NEWLINE);
88d6cf37 8020
8021 /* Max-metric router-lsa print */
8022 config_write_stub_router (vty, ospf);
8023
718e3744 8024 /* SPF refresh parameters print. */
68980084 8025 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
718e3744 8026 vty_out (vty, " refresh timer %d%s",
68980084 8027 ospf->lsa_refresh_interval, VTY_NEWLINE);
718e3744 8028
8029 /* Redistribute information print. */
68980084 8030 config_write_ospf_redistribute (vty, ospf);
718e3744 8031
8032 /* passive-interface print. */
7ffa8fa2
PJ
8033 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
8034 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
8035
1eb8ef25 8036 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7ffa8fa2
PJ
8037 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
8038 && IF_DEF_PARAMS (ifp)->passive_interface !=
8039 ospf->passive_interface_default)
8040 {
8041 vty_out (vty, " %spassive-interface %s%s",
8042 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
8043 ifp->name, VTY_NEWLINE);
8044 }
1eb8ef25 8045 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7ffa8fa2
PJ
8046 {
8047 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
8048 continue;
8049 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
8050 passive_interface))
8051 {
8052 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
8053 continue;
8054 }
8055 else if (oi->params->passive_interface == ospf->passive_interface_default)
8056 continue;
8057
8058 vty_out (vty, " %spassive-interface %s %s%s",
8059 oi->params->passive_interface ? "" : "no ",
1eb8ef25 8060 oi->ifp->name,
8061 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
7ffa8fa2 8062 }
718e3744 8063
8064 /* Network area print. */
68980084 8065 config_write_network_area (vty, ospf);
718e3744 8066
8067 /* Area config print. */
68980084 8068 config_write_ospf_area (vty, ospf);
718e3744 8069
8070 /* static neighbor print. */
68980084 8071 config_write_ospf_nbr_nbma (vty, ospf);
718e3744 8072
8073 /* Virtual-Link print. */
68980084 8074 config_write_virtual_link (vty, ospf);
718e3744 8075
8076 /* Default metric configuration. */
68980084 8077 config_write_ospf_default_metric (vty, ospf);
718e3744 8078
8079 /* Distribute-list and default-information print. */
68980084 8080 config_write_ospf_distribute (vty, ospf);
718e3744 8081
8082 /* Distance configuration. */
68980084 8083 config_write_ospf_distance (vty, ospf);
718e3744 8084
8085#ifdef HAVE_OPAQUE_LSA
68980084 8086 ospf_opaque_config_write_router (vty, ospf);
718e3744 8087#endif /* HAVE_OPAQUE_LSA */
8088 }
8089
8090 return write;
8091}
8092
8093void
4dadc291 8094ospf_vty_show_init (void)
718e3744 8095{
8096 /* "show ip ospf" commands. */
8097 install_element (VIEW_NODE, &show_ip_ospf_cmd);
8098 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
8099
8100 /* "show ip ospf database" commands. */
8101 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
8102 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
8103 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8104 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8105 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
8106 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
8107 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
8108 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
8109 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
8110 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
8111 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
8112 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
8113 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
8114 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
8115
8116 /* "show ip ospf interface" commands. */
8117 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
8118 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
8119
8120 /* "show ip ospf neighbor" commands. */
8121 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8122 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
8123 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
8124 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8125 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
8126 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
8127 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
8128 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
8129 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
8130 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
8131 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
8132 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
8133 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
8134 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
8135
8136 /* "show ip ospf route" commands. */
8137 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
8138 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
718e3744 8139 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
8140 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
718e3744 8141}
8142
8143\f
8144/* ospfd's interface node. */
7fc626de 8145static struct cmd_node interface_node =
718e3744 8146{
8147 INTERFACE_NODE,
8148 "%s(config-if)# ",
8149 1
8150};
8151
8152/* Initialization of OSPF interface. */
4dadc291 8153static void
8154ospf_vty_if_init (void)
718e3744 8155{
8156 /* Install interface node. */
8157 install_node (&interface_node, config_write_interface);
8158
8159 install_element (CONFIG_NODE, &interface_cmd);
32d2463c 8160 install_element (CONFIG_NODE, &no_interface_cmd);
718e3744 8161 install_default (INTERFACE_NODE);
8162
8163 /* "description" commands. */
8164 install_element (INTERFACE_NODE, &interface_desc_cmd);
8165 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
8166
8167 /* "ip ospf authentication" commands. */
8168 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
8169 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
8170 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
8171 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
8172 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
8173 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
8174 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
8175 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
8176 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
8177 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
8178
8179 /* "ip ospf message-digest-key" commands. */
8180 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
8181 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
8182 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
8183 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
8184
8185 /* "ip ospf cost" commands. */
9eff36b3
DO
8186 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
8187 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
827341b7
DO
8188 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
8189 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
9eff36b3 8190 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
718e3744 8191 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
8192
ba682537 8193 /* "ip ospf mtu-ignore" commands. */
8194 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
8195 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
8196 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
8197 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
8198
718e3744 8199 /* "ip ospf dead-interval" commands. */
8200 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
8201 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
f9ad937f 8202 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
8203 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
718e3744 8204 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
8205 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
f9ad937f 8206
718e3744 8207 /* "ip ospf hello-interval" commands. */
8208 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
8209 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
8210 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
8211 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
8212
8213 /* "ip ospf network" commands. */
8214 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
8215 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
8216
8217 /* "ip ospf priority" commands. */
8218 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
8219 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
8220 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
8221 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
8222
8223 /* "ip ospf retransmit-interval" commands. */
8224 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
8225 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
8226 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
8227 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
8228
8229 /* "ip ospf transmit-delay" commands. */
8230 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
8231 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
8232 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
8233 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
8234
8235 /* These commands are compatibitliy for previous version. */
8236 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
8237 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
8238 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
8239 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
9eff36b3
DO
8240 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
8241 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
718e3744 8242 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
827341b7
DO
8243 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
8244 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
9eff36b3 8245 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
718e3744 8246 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
8247 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
8248 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
8249 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
8250 install_element (INTERFACE_NODE, &ospf_network_cmd);
8251 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
8252 install_element (INTERFACE_NODE, &ospf_priority_cmd);
8253 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
8254 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
8255 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
8256 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
8257 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
8258}
8259
4dadc291 8260static void
8261ospf_vty_zebra_init (void)
718e3744 8262{
8263 install_element (OSPF_NODE, &ospf_redistribute_source_type_metric_cmd);
8264 install_element (OSPF_NODE, &ospf_redistribute_source_metric_type_cmd);
8265 install_element (OSPF_NODE, &ospf_redistribute_source_type_cmd);
8266 install_element (OSPF_NODE, &ospf_redistribute_source_metric_cmd);
8267 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
8268 install_element (OSPF_NODE,
8269 &ospf_redistribute_source_metric_type_routemap_cmd);
8270 install_element (OSPF_NODE,
8271 &ospf_redistribute_source_type_metric_routemap_cmd);
8272 install_element (OSPF_NODE, &ospf_redistribute_source_metric_routemap_cmd);
8273 install_element (OSPF_NODE, &ospf_redistribute_source_type_routemap_cmd);
8274 install_element (OSPF_NODE, &ospf_redistribute_source_routemap_cmd);
8275
8276 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
8277
8278 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
8279 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
8280
8281 install_element (OSPF_NODE,
8282 &ospf_default_information_originate_metric_type_cmd);
8283 install_element (OSPF_NODE, &ospf_default_information_originate_metric_cmd);
8284 install_element (OSPF_NODE,
8285 &ospf_default_information_originate_type_metric_cmd);
8286 install_element (OSPF_NODE, &ospf_default_information_originate_type_cmd);
8287 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
8288 install_element (OSPF_NODE,
8289 &ospf_default_information_originate_always_metric_type_cmd);
8290 install_element (OSPF_NODE,
8291 &ospf_default_information_originate_always_metric_cmd);
8292 install_element (OSPF_NODE,
8293 &ospf_default_information_originate_always_cmd);
8294 install_element (OSPF_NODE,
8295 &ospf_default_information_originate_always_type_metric_cmd);
8296 install_element (OSPF_NODE,
8297 &ospf_default_information_originate_always_type_cmd);
8298
8299 install_element (OSPF_NODE,
8300 &ospf_default_information_originate_metric_type_routemap_cmd);
8301 install_element (OSPF_NODE,
8302 &ospf_default_information_originate_metric_routemap_cmd);
8303 install_element (OSPF_NODE,
8304 &ospf_default_information_originate_routemap_cmd);
8305 install_element (OSPF_NODE,
8306 &ospf_default_information_originate_type_metric_routemap_cmd);
8307 install_element (OSPF_NODE,
8308 &ospf_default_information_originate_type_routemap_cmd);
8309 install_element (OSPF_NODE,
8310 &ospf_default_information_originate_always_metric_type_routemap_cmd);
8311 install_element (OSPF_NODE,
8312 &ospf_default_information_originate_always_metric_routemap_cmd);
8313 install_element (OSPF_NODE,
8314 &ospf_default_information_originate_always_routemap_cmd);
8315 install_element (OSPF_NODE,
8316 &ospf_default_information_originate_always_type_metric_routemap_cmd);
8317 install_element (OSPF_NODE,
8318 &ospf_default_information_originate_always_type_routemap_cmd);
8319
8320 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
8321
8322 install_element (OSPF_NODE, &ospf_default_metric_cmd);
8323 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
8324 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
8325
8326 install_element (OSPF_NODE, &ospf_distance_cmd);
8327 install_element (OSPF_NODE, &no_ospf_distance_cmd);
8328 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
8329 install_element (OSPF_NODE, &ospf_distance_ospf_intra_cmd);
8330 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_cmd);
8331 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_cmd);
8332 install_element (OSPF_NODE, &ospf_distance_ospf_intra_inter_external_cmd);
8333 install_element (OSPF_NODE, &ospf_distance_ospf_intra_external_inter_cmd);
8334 install_element (OSPF_NODE, &ospf_distance_ospf_inter_cmd);
8335 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_cmd);
8336 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_cmd);
8337 install_element (OSPF_NODE, &ospf_distance_ospf_inter_intra_external_cmd);
8338 install_element (OSPF_NODE, &ospf_distance_ospf_inter_external_intra_cmd);
8339 install_element (OSPF_NODE, &ospf_distance_ospf_external_cmd);
8340 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_cmd);
8341 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_cmd);
8342 install_element (OSPF_NODE, &ospf_distance_ospf_external_intra_inter_cmd);
8343 install_element (OSPF_NODE, &ospf_distance_ospf_external_inter_intra_cmd);
8344#if 0
8345 install_element (OSPF_NODE, &ospf_distance_source_cmd);
8346 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
8347 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
8348 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
8349#endif /* 0 */
8350}
8351
7fc626de 8352static struct cmd_node ospf_node =
718e3744 8353{
8354 OSPF_NODE,
8355 "%s(config-router)# ",
8356 1
8357};
8358
8359\f
8360/* Install OSPF related vty commands. */
8361void
4dadc291 8362ospf_vty_init (void)
718e3744 8363{
8364 /* Install ospf top node. */
8365 install_node (&ospf_node, ospf_config_write);
8366
8367 /* "router ospf" commands. */
8368 install_element (CONFIG_NODE, &router_ospf_cmd);
8369 install_element (CONFIG_NODE, &no_router_ospf_cmd);
8370
8371 install_default (OSPF_NODE);
8372
8373 /* "ospf router-id" commands. */
8374 install_element (OSPF_NODE, &ospf_router_id_cmd);
8375 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
a2c62831 8376 install_element (OSPF_NODE, &router_ospf_id_cmd);
8377 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
718e3744 8378
8379 /* "passive-interface" commands. */
a2c62831 8380 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
8381 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7ffa8fa2 8382 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
a2c62831 8383 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
8384 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
7ffa8fa2 8385 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
718e3744 8386
8387 /* "ospf abr-type" commands. */
8388 install_element (OSPF_NODE, &ospf_abr_type_cmd);
8389 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
8390
d7e60dd7
AS
8391 /* "ospf log-adjacency-changes" commands. */
8392 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
8393 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
8394 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
8395 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
8396
718e3744 8397 /* "ospf rfc1583-compatible" commands. */
8398 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
8399 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
8400 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
8401 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
8402
8403 /* "network area" commands. */
a2c62831 8404 install_element (OSPF_NODE, &ospf_network_area_cmd);
8405 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
718e3744 8406
8407 /* "area authentication" commands. */
a2c62831 8408 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
8409 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
8410 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
718e3744 8411
8412 /* "area range" commands. */
a2c62831 8413 install_element (OSPF_NODE, &ospf_area_range_cmd);
8414 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
8415 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
8416 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
8417 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
8418 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
8419 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
8420 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
8421 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
8422 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
8423 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
718e3744 8424
8425 /* "area virtual-link" commands. */
a2c62831 8426 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
8427 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
718e3744 8428
a2c62831 8429 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
8430 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
718e3744 8431
a2c62831 8432 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
8433 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
718e3744 8434
a2c62831 8435 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
8436 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
718e3744 8437
a2c62831 8438 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
8439 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
718e3744 8440
a2c62831 8441 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
8442 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
8443 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
718e3744 8444
a2c62831 8445 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
8446 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
718e3744 8447
a2c62831 8448 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
8449 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
718e3744 8450
a2c62831 8451 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
8452 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
8453 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
718e3744 8454
a2c62831 8455 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
8456 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
8457 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
718e3744 8458
8459 /* "area stub" commands. */
a2c62831 8460 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
8461 install_element (OSPF_NODE, &ospf_area_stub_cmd);
8462 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
8463 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
718e3744 8464
718e3744 8465 /* "area nssa" commands. */
a2c62831 8466 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
8467 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
8468 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
8469 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
8470 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
8471 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
718e3744 8472
a2c62831 8473 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
8474 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
718e3744 8475
a2c62831 8476 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
8477 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
718e3744 8478
a2c62831 8479 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
8480 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
718e3744 8481
a2c62831 8482 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
8483 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
718e3744 8484
a2c62831 8485 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
8486 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
88d6cf37 8487
8488 /* SPF timer commands */
a2c62831 8489 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
8490 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
d24f6e2a 8491 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
8492 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
8493
88d6cf37 8494 /* refresh timer commands */
a2c62831 8495 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
8496 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
8497 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
718e3744 8498
88d6cf37 8499 /* max-metric commands */
8500 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
8501 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
8502 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
8503 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
8504 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
8505 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
8506
8507 /* reference bandwidth commands */
a2c62831 8508 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
8509 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
718e3744 8510
8511 /* "neighbor" commands. */
a2c62831 8512 install_element (OSPF_NODE, &ospf_neighbor_cmd);
8513 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
8514 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
8515 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
8516 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
8517 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
8518 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
8519 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
718e3744 8520
8521 /* Init interface related vty commands. */
8522 ospf_vty_if_init ();
8523
8524 /* Init zebra related vty commands. */
8525 ospf_vty_zebra_init ();
8526}