]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_vty.c
Unnumbered interface support.
[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
6b0655a2 52
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
6b0655a2 64
718e3744 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
6b0655a2 97
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
6b0655a2 145
718e3744 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
6b0655a2 493
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")
6b0655a2 637
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
6b0655a2 689
718e3744 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
6b0655a2 1385
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
6b0655a2 1453
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;
718e3744 1745 int format;
ba682537 1746 struct prefix_ipv4 p;
718e3744 1747
1748 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
0798cee3 1749 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
718e3744 1750
68980084 1751 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 1752 if (area == NULL)
1753 return CMD_SUCCESS;
1754
1755 if (area->external_routing == OSPF_AREA_DEFAULT)
1756 {
1757 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1758 return CMD_WARNING;
1759 }
1760
1761 area->default_cost = 1;
1762
ba682537 1763 p.family = AF_INET;
1764 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1765 p.prefixlen = 0;
1766 if (IS_DEBUG_OSPF_EVENT)
1767 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1768 "announcing 0.0.0.0/0 to area %s",
1769 inet_ntoa (area->area_id));
1770 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1771
1772
68980084 1773 ospf_area_check_free (ospf, area_id);
718e3744 1774
1775 return CMD_SUCCESS;
1776}
1777
a2c62831 1778DEFUN (ospf_area_export_list,
1779 ospf_area_export_list_cmd,
718e3744 1780 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1781 "OSPF area parameters\n"
1782 "OSPF area ID in IP address format\n"
1783 "OSPF area ID as a decimal value\n"
1784 "Set the filter for networks announced to other areas\n"
1785 "Name of the access-list\n")
1786{
68980084 1787 struct ospf *ospf = vty->index;
718e3744 1788 struct ospf_area *area;
1789 struct in_addr area_id;
1790 int format;
1791
52930766 1792 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1793
68980084 1794 area = ospf_area_get (ospf, area_id, format);
1795 ospf_area_export_list_set (ospf, area, argv[1]);
718e3744 1796
1797 return CMD_SUCCESS;
1798}
1799
a2c62831 1800DEFUN (no_ospf_area_export_list,
1801 no_ospf_area_export_list_cmd,
718e3744 1802 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1803 NO_STR
1804 "OSPF area parameters\n"
1805 "OSPF area ID in IP address format\n"
1806 "OSPF area ID as a decimal value\n"
1807 "Unset the filter for networks announced to other areas\n"
1808 "Name of the access-list\n")
1809{
68980084 1810 struct ospf *ospf = vty->index;
718e3744 1811 struct ospf_area *area;
1812 struct in_addr area_id;
1813 int format;
1814
52930766 1815 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1816
68980084 1817 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 1818 if (area == NULL)
1819 return CMD_SUCCESS;
1820
68980084 1821 ospf_area_export_list_unset (ospf, area);
718e3744 1822
1823 return CMD_SUCCESS;
1824}
1825
1826
a2c62831 1827DEFUN (ospf_area_import_list,
1828 ospf_area_import_list_cmd,
718e3744 1829 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1830 "OSPF area parameters\n"
1831 "OSPF area ID in IP address format\n"
1832 "OSPF area ID as a decimal value\n"
1833 "Set the filter for networks from other areas announced to the specified one\n"
1834 "Name of the access-list\n")
1835{
68980084 1836 struct ospf *ospf = vty->index;
718e3744 1837 struct ospf_area *area;
1838 struct in_addr area_id;
1839 int format;
1840
52930766 1841 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1842
68980084 1843 area = ospf_area_get (ospf, area_id, format);
1844 ospf_area_import_list_set (ospf, area, argv[1]);
718e3744 1845
1846 return CMD_SUCCESS;
1847}
1848
a2c62831 1849DEFUN (no_ospf_area_import_list,
1850 no_ospf_area_import_list_cmd,
718e3744 1851 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1852 NO_STR
1853 "OSPF area parameters\n"
1854 "OSPF area ID in IP address format\n"
1855 "OSPF area ID as a decimal value\n"
1856 "Unset the filter for networks announced to other areas\n"
1857 "Name of the access-list\n")
1858{
68980084 1859 struct ospf *ospf = vty->index;
718e3744 1860 struct ospf_area *area;
1861 struct in_addr area_id;
1862 int format;
1863
52930766 1864 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1865
68980084 1866 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 1867 if (area == NULL)
1868 return CMD_SUCCESS;
1869
68980084 1870 ospf_area_import_list_unset (ospf, area);
718e3744 1871
1872 return CMD_SUCCESS;
1873}
1874
a2c62831 1875DEFUN (ospf_area_filter_list,
1876 ospf_area_filter_list_cmd,
718e3744 1877 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1878 "OSPF area parameters\n"
1879 "OSPF area ID in IP address format\n"
1880 "OSPF area ID as a decimal value\n"
1881 "Filter networks between OSPF areas\n"
1882 "Filter prefixes between OSPF areas\n"
1883 "Name of an IP prefix-list\n"
1884 "Filter networks sent to this area\n"
1885 "Filter networks sent from this area\n")
1886{
68980084 1887 struct ospf *ospf = vty->index;
718e3744 1888 struct ospf_area *area;
1889 struct in_addr area_id;
1890 struct prefix_list *plist;
1891 int format;
1892
1893 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1894
68980084 1895 area = ospf_area_get (ospf, area_id, format);
718e3744 1896 plist = prefix_list_lookup (AFI_IP, argv[1]);
1897 if (strncmp (argv[2], "in", 2) == 0)
1898 {
1899 PREFIX_LIST_IN (area) = plist;
1900 if (PREFIX_NAME_IN (area))
1901 free (PREFIX_NAME_IN (area));
1902
1903 PREFIX_NAME_IN (area) = strdup (argv[1]);
68980084 1904 ospf_schedule_abr_task (ospf);
718e3744 1905 }
1906 else
1907 {
1908 PREFIX_LIST_OUT (area) = plist;
1909 if (PREFIX_NAME_OUT (area))
1910 free (PREFIX_NAME_OUT (area));
1911
1912 PREFIX_NAME_OUT (area) = strdup (argv[1]);
68980084 1913 ospf_schedule_abr_task (ospf);
718e3744 1914 }
1915
1916 return CMD_SUCCESS;
1917}
1918
a2c62831 1919DEFUN (no_ospf_area_filter_list,
1920 no_ospf_area_filter_list_cmd,
718e3744 1921 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1922 NO_STR
1923 "OSPF area parameters\n"
1924 "OSPF area ID in IP address format\n"
1925 "OSPF area ID as a decimal value\n"
1926 "Filter networks between OSPF areas\n"
1927 "Filter prefixes between OSPF areas\n"
1928 "Name of an IP prefix-list\n"
1929 "Filter networks sent to this area\n"
1930 "Filter networks sent from this area\n")
1931{
68980084 1932 struct ospf *ospf = vty->index;
718e3744 1933 struct ospf_area *area;
1934 struct in_addr area_id;
718e3744 1935 int format;
1936
1937 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1938
1a8ec2b9
PJ
1939 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1940 return CMD_SUCCESS;
1941
718e3744 1942 if (strncmp (argv[2], "in", 2) == 0)
1943 {
1944 if (PREFIX_NAME_IN (area))
1945 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1946 return CMD_SUCCESS;
1947
1948 PREFIX_LIST_IN (area) = NULL;
1949 if (PREFIX_NAME_IN (area))
1950 free (PREFIX_NAME_IN (area));
1951
1952 PREFIX_NAME_IN (area) = NULL;
1953
68980084 1954 ospf_schedule_abr_task (ospf);
718e3744 1955 }
1956 else
1957 {
1958 if (PREFIX_NAME_OUT (area))
1959 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
1960 return CMD_SUCCESS;
1961
1962 PREFIX_LIST_OUT (area) = NULL;
1963 if (PREFIX_NAME_OUT (area))
1964 free (PREFIX_NAME_OUT (area));
1965
1966 PREFIX_NAME_OUT (area) = NULL;
1967
68980084 1968 ospf_schedule_abr_task (ospf);
718e3744 1969 }
1970
1971 return CMD_SUCCESS;
1972}
1973
6b0655a2 1974
a2c62831 1975DEFUN (ospf_area_authentication_message_digest,
1976 ospf_area_authentication_message_digest_cmd,
718e3744 1977 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
1978 "OSPF area parameters\n"
2b00515a
CF
1979 "OSPF area ID in IP address format\n"
1980 "OSPF area ID as a decimal value\n"
718e3744 1981 "Enable authentication\n"
1982 "Use message-digest authentication\n")
1983{
68980084 1984 struct ospf *ospf = vty->index;
718e3744 1985 struct ospf_area *area;
1986 struct in_addr area_id;
1987 int format;
1988
1989 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1990
68980084 1991 area = ospf_area_get (ospf, area_id, format);
718e3744 1992 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1993
1994 return CMD_SUCCESS;
1995}
1996
a2c62831 1997DEFUN (ospf_area_authentication,
1998 ospf_area_authentication_cmd,
718e3744 1999 "area (A.B.C.D|<0-4294967295>) authentication",
2000 "OSPF area parameters\n"
2001 "OSPF area ID in IP address format\n"
2002 "OSPF area ID as a decimal value\n"
2003 "Enable authentication\n")
2004{
68980084 2005 struct ospf *ospf = vty->index;
718e3744 2006 struct ospf_area *area;
2007 struct in_addr area_id;
2008 int format;
2009
2010 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2011
68980084 2012 area = ospf_area_get (ospf, area_id, format);
718e3744 2013 area->auth_type = OSPF_AUTH_SIMPLE;
2014
2015 return CMD_SUCCESS;
2016}
2017
a2c62831 2018DEFUN (no_ospf_area_authentication,
2019 no_ospf_area_authentication_cmd,
718e3744 2020 "no area (A.B.C.D|<0-4294967295>) authentication",
2021 NO_STR
2022 "OSPF area parameters\n"
2023 "OSPF area ID in IP address format\n"
2024 "OSPF area ID as a decimal value\n"
2025 "Enable authentication\n")
2026{
68980084 2027 struct ospf *ospf = vty->index;
718e3744 2028 struct ospf_area *area;
2029 struct in_addr area_id;
2030 int format;
2031
2032 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2033
68980084 2034 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 2035 if (area == NULL)
2036 return CMD_SUCCESS;
2037
2038 area->auth_type = OSPF_AUTH_NULL;
2039
68980084 2040 ospf_area_check_free (ospf, area_id);
718e3744 2041
2042 return CMD_SUCCESS;
2043}
2044
6b0655a2 2045
718e3744 2046DEFUN (ospf_abr_type,
2047 ospf_abr_type_cmd,
2048 "ospf abr-type (cisco|ibm|shortcut|standard)",
2049 "OSPF specific commands\n"
2050 "Set OSPF ABR type\n"
2051 "Alternative ABR, cisco implementation\n"
2052 "Alternative ABR, IBM implementation\n"
2053 "Shortcut ABR\n"
2054 "Standard behavior (RFC2328)\n")
2055{
68980084 2056 struct ospf *ospf = vty->index;
718e3744 2057 u_char abr_type = OSPF_ABR_UNKNOWN;
2058
2059 if (strncmp (argv[0], "c", 1) == 0)
2060 abr_type = OSPF_ABR_CISCO;
2061 else if (strncmp (argv[0], "i", 1) == 0)
2062 abr_type = OSPF_ABR_IBM;
2063 else if (strncmp (argv[0], "sh", 2) == 0)
2064 abr_type = OSPF_ABR_SHORTCUT;
2065 else if (strncmp (argv[0], "st", 2) == 0)
2066 abr_type = OSPF_ABR_STAND;
2067 else
2068 return CMD_WARNING;
2069
2070 /* If ABR type value is changed, schedule ABR task. */
68980084 2071 if (ospf->abr_type != abr_type)
718e3744 2072 {
68980084 2073 ospf->abr_type = abr_type;
2074 ospf_schedule_abr_task (ospf);
718e3744 2075 }
2076
2077 return CMD_SUCCESS;
2078}
2079
2080DEFUN (no_ospf_abr_type,
2081 no_ospf_abr_type_cmd,
d57834f6 2082 "no ospf abr-type (cisco|ibm|shortcut|standard)",
718e3744 2083 NO_STR
2084 "OSPF specific commands\n"
2085 "Set OSPF ABR type\n"
2086 "Alternative ABR, cisco implementation\n"
2087 "Alternative ABR, IBM implementation\n"
2088 "Shortcut ABR\n")
2089{
68980084 2090 struct ospf *ospf = vty->index;
718e3744 2091 u_char abr_type = OSPF_ABR_UNKNOWN;
2092
2093 if (strncmp (argv[0], "c", 1) == 0)
2094 abr_type = OSPF_ABR_CISCO;
2095 else if (strncmp (argv[0], "i", 1) == 0)
2096 abr_type = OSPF_ABR_IBM;
04d23314 2097 else if (strncmp (argv[0], "sh", 2) == 0)
718e3744 2098 abr_type = OSPF_ABR_SHORTCUT;
04d23314
FD
2099 else if (strncmp (argv[0], "st", 2) == 0)
2100 abr_type = OSPF_ABR_STAND;
718e3744 2101 else
2102 return CMD_WARNING;
2103
2104 /* If ABR type value is changed, schedule ABR task. */
68980084 2105 if (ospf->abr_type == abr_type)
718e3744 2106 {
d57834f6 2107 ospf->abr_type = OSPF_ABR_DEFAULT;
68980084 2108 ospf_schedule_abr_task (ospf);
718e3744 2109 }
2110
2111 return CMD_SUCCESS;
2112}
2113
d7e60dd7
AS
2114DEFUN (ospf_log_adjacency_changes,
2115 ospf_log_adjacency_changes_cmd,
2116 "log-adjacency-changes",
2117 "Log changes in adjacency state\n")
2118{
2119 struct ospf *ospf = vty->index;
2120
2121 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2122 return CMD_SUCCESS;
2123}
2124
2125DEFUN (ospf_log_adjacency_changes_detail,
2126 ospf_log_adjacency_changes_detail_cmd,
2127 "log-adjacency-changes detail",
2128 "Log changes in adjacency state\n"
2129 "Log all state changes\n")
2130{
2131 struct ospf *ospf = vty->index;
2132
2133 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2134 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2135 return CMD_SUCCESS;
2136}
2137
2138DEFUN (no_ospf_log_adjacency_changes,
2139 no_ospf_log_adjacency_changes_cmd,
2140 "no log-adjacency-changes",
2141 NO_STR
2142 "Log changes in adjacency state\n")
2143{
2144 struct ospf *ospf = vty->index;
2145
2146 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2147 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2148 return CMD_SUCCESS;
2149}
2150
2151DEFUN (no_ospf_log_adjacency_changes_detail,
2152 no_ospf_log_adjacency_changes_detail_cmd,
2153 "no log-adjacency-changes detail",
2154 NO_STR
2155 "Log changes in adjacency state\n"
2156 "Log all state changes\n")
2157{
2158 struct ospf *ospf = vty->index;
2159
2160 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2161 return CMD_SUCCESS;
2162}
2163
718e3744 2164DEFUN (ospf_compatible_rfc1583,
2165 ospf_compatible_rfc1583_cmd,
2166 "compatible rfc1583",
2167 "OSPF compatibility list\n"
2168 "compatible with RFC 1583\n")
2169{
2170 struct ospf *ospf = vty->index;
2171
2172 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2173 {
2174 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
68980084 2175 ospf_spf_calculate_schedule (ospf);
718e3744 2176 }
2177 return CMD_SUCCESS;
2178}
2179
2180DEFUN (no_ospf_compatible_rfc1583,
2181 no_ospf_compatible_rfc1583_cmd,
2182 "no compatible rfc1583",
2183 NO_STR
2184 "OSPF compatibility list\n"
2185 "compatible with RFC 1583\n")
2186{
2187 struct ospf *ospf = vty->index;
2188
2189 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2190 {
2191 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
68980084 2192 ospf_spf_calculate_schedule (ospf);
718e3744 2193 }
2194 return CMD_SUCCESS;
2195}
2196
2197ALIAS (ospf_compatible_rfc1583,
2198 ospf_rfc1583_flag_cmd,
2199 "ospf rfc1583compatibility",
2200 "OSPF specific commands\n"
2201 "Enable the RFC1583Compatibility flag\n")
2202
2203ALIAS (no_ospf_compatible_rfc1583,
2204 no_ospf_rfc1583_flag_cmd,
2205 "no ospf rfc1583compatibility",
2206 NO_STR
2207 "OSPF specific commands\n"
2208 "Disable the RFC1583Compatibility flag\n")
6b0655a2 2209
d24f6e2a 2210static int
2211ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2212 unsigned int hold,
2213 unsigned int max)
2214{
2215 struct ospf *ospf = vty->index;
2216
2217 ospf->spf_delay = delay;
2218 ospf->spf_holdtime = hold;
2219 ospf->spf_max_holdtime = max;
2220
2221 return CMD_SUCCESS;
2222}
718e3744 2223
d24f6e2a 2224DEFUN (ospf_timers_throttle_spf,
2225 ospf_timers_throttle_spf_cmd,
2226 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2227 "Adjust routing timers\n"
2228 "Throttling adaptive timer\n"
2229 "OSPF SPF timers\n"
2230 "Delay (msec) from first change received till SPF calculation\n"
2231 "Initial hold time (msec) between consecutive SPF calculations\n"
2232 "Maximum hold time (msec)\n")
2233{
2234 unsigned int delay, hold, max;
2235
2236 if (argc != 3)
2237 {
2238 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2239 return CMD_WARNING;
2240 }
2241
2242 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2243 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2244 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2245
2246 return ospf_timers_spf_set (vty, delay, hold, max);
2247}
2248
2249DEFUN_DEPRECATED (ospf_timers_spf,
a2c62831 2250 ospf_timers_spf_cmd,
718e3744 2251 "timers spf <0-4294967295> <0-4294967295>",
2252 "Adjust routing timers\n"
2253 "OSPF SPF timers\n"
d24f6e2a 2254 "Delay (s) between receiving a change to SPF calculation\n"
2255 "Hold time (s) between consecutive SPF calculations\n")
718e3744 2256{
d24f6e2a 2257 unsigned int delay, hold;
2258
2259 if (argc != 2)
2260 {
2261 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2262 return CMD_WARNING;
2263 }
2264
4dadc291 2265 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2266 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
d24f6e2a 2267
2268 /* truncate down the second values if they're greater than 600000ms */
2269 if (delay > (600000 / 1000))
2270 delay = 600000;
2271 else if (delay == 0)
2272 /* 0s delay was probably specified because of lack of ms resolution */
2273 delay = OSPF_SPF_DELAY_DEFAULT;
2274 if (hold > (600000 / 1000))
2275 hold = 600000;
2276
2277 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
718e3744 2278}
2279
d24f6e2a 2280DEFUN (no_ospf_timers_throttle_spf,
2281 no_ospf_timers_throttle_spf_cmd,
2282 "no timers throttle spf",
718e3744 2283 NO_STR
2284 "Adjust routing timers\n"
d24f6e2a 2285 "Throttling adaptive timer\n"
718e3744 2286 "OSPF SPF timers\n")
2287{
d24f6e2a 2288 return ospf_timers_spf_set (vty,
2289 OSPF_SPF_DELAY_DEFAULT,
2290 OSPF_SPF_HOLDTIME_DEFAULT,
2291 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
718e3744 2292}
2293
d24f6e2a 2294ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2295 no_ospf_timers_spf_cmd,
2296 "no timers spf",
2297 NO_STR
2298 "Adjust routing timers\n"
2299 "OSPF SPF timers\n")
6b0655a2 2300
a2c62831 2301DEFUN (ospf_neighbor,
2302 ospf_neighbor_cmd,
718e3744 2303 "neighbor A.B.C.D",
2304 NEIGHBOR_STR
2305 "Neighbor IP address\n")
2306{
2307 struct ospf *ospf = vty->index;
2308 struct in_addr nbr_addr;
eb1ce605 2309 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2310 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
718e3744 2311
2312 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2313
2314 if (argc > 1)
2315 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2316
2317 if (argc > 2)
2318 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2319
2320 ospf_nbr_nbma_set (ospf, nbr_addr);
2321 if (argc > 1)
2322 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2323 if (argc > 2)
1a61ad10 2324 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
718e3744 2325
2326 return CMD_SUCCESS;
2327}
2328
a2c62831 2329ALIAS (ospf_neighbor,
2330 ospf_neighbor_priority_poll_interval_cmd,
718e3744 2331 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2332 NEIGHBOR_STR
2333 "Neighbor IP address\n"
2334 "Neighbor Priority\n"
2335 "Priority\n"
2336 "Dead Neighbor Polling interval\n"
2337 "Seconds\n")
2338
a2c62831 2339ALIAS (ospf_neighbor,
2340 ospf_neighbor_priority_cmd,
718e3744 2341 "neighbor A.B.C.D priority <0-255>",
2342 NEIGHBOR_STR
2343 "Neighbor IP address\n"
2344 "Neighbor Priority\n"
2345 "Seconds\n")
2346
a2c62831 2347DEFUN (ospf_neighbor_poll_interval,
2348 ospf_neighbor_poll_interval_cmd,
718e3744 2349 "neighbor A.B.C.D poll-interval <1-65535>",
2350 NEIGHBOR_STR
2351 "Neighbor IP address\n"
2352 "Dead Neighbor Polling interval\n"
2353 "Seconds\n")
2354{
2355 struct ospf *ospf = vty->index;
2356 struct in_addr nbr_addr;
eb1ce605 2357 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2358 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
718e3744 2359
2360 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2361
2362 if (argc > 1)
2363 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2364
2365 if (argc > 2)
2366 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2367
2368 ospf_nbr_nbma_set (ospf, nbr_addr);
2369 if (argc > 1)
2370 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2371 if (argc > 2)
2372 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2373
2374 return CMD_SUCCESS;
2375}
2376
a2c62831 2377ALIAS (ospf_neighbor_poll_interval,
2378 ospf_neighbor_poll_interval_priority_cmd,
718e3744 2379 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2380 NEIGHBOR_STR
2381 "Neighbor address\n"
2382 "OSPF dead-router polling interval\n"
2383 "Seconds\n"
2384 "OSPF priority of non-broadcast neighbor\n"
2385 "Priority\n")
2386
a2c62831 2387DEFUN (no_ospf_neighbor,
2388 no_ospf_neighbor_cmd,
718e3744 2389 "no neighbor A.B.C.D",
2390 NO_STR
2391 NEIGHBOR_STR
2392 "Neighbor IP address\n")
2393{
2394 struct ospf *ospf = vty->index;
2395 struct in_addr nbr_addr;
718e3744 2396
2397 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2398
0798cee3 2399 (void)ospf_nbr_nbma_unset (ospf, nbr_addr);
718e3744 2400
2401 return CMD_SUCCESS;
2402}
2403
a2c62831 2404ALIAS (no_ospf_neighbor,
2405 no_ospf_neighbor_priority_cmd,
718e3744 2406 "no neighbor A.B.C.D priority <0-255>",
2407 NO_STR
2408 NEIGHBOR_STR
2409 "Neighbor IP address\n"
2410 "Neighbor Priority\n"
2411 "Priority\n")
2412
a2c62831 2413ALIAS (no_ospf_neighbor,
2414 no_ospf_neighbor_poll_interval_cmd,
718e3744 2415 "no neighbor A.B.C.D poll-interval <1-65535>",
2416 NO_STR
2417 NEIGHBOR_STR
2418 "Neighbor IP address\n"
2419 "Dead Neighbor Polling interval\n"
2420 "Seconds\n")
2421
a2c62831 2422ALIAS (no_ospf_neighbor,
2423 no_ospf_neighbor_priority_pollinterval_cmd,
718e3744 2424 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2425 NO_STR
2426 NEIGHBOR_STR
2427 "Neighbor IP address\n"
2428 "Neighbor Priority\n"
2429 "Priority\n"
2430 "Dead Neighbor Polling interval\n"
2431 "Seconds\n")
2432
6b0655a2 2433
a2c62831 2434DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
718e3744 2435 "refresh timer <10-1800>",
2436 "Adjust refresh parameters\n"
2437 "Set refresh timer\n"
2438 "Timer value in seconds\n")
2439{
2440 struct ospf *ospf = vty->index;
eb1ce605 2441 unsigned int interval;
718e3744 2442
2443 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2444 interval = (interval / 10) * 10;
2445
2446 ospf_timers_refresh_set (ospf, interval);
2447
2448 return CMD_SUCCESS;
2449}
2450
a2c62831 2451DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
718e3744 2452 "no refresh timer <10-1800>",
2453 "Adjust refresh parameters\n"
2454 "Unset refresh timer\n"
2455 "Timer value in seconds\n")
2456{
2457 struct ospf *ospf = vty->index;
eb1ce605 2458 unsigned int interval;
718e3744 2459
2460 if (argc == 1)
2461 {
2462 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2463
2464 if (ospf->lsa_refresh_interval != interval ||
2465 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2466 return CMD_SUCCESS;
2467 }
2468
2469 ospf_timers_refresh_unset (ospf);
2470
2471 return CMD_SUCCESS;
2472}
2473
a2c62831 2474ALIAS (no_ospf_refresh_timer,
2475 no_ospf_refresh_timer_cmd,
718e3744 2476 "no refresh timer",
2477 "Adjust refresh parameters\n"
2478 "Unset refresh timer\n")
2479
a2c62831 2480DEFUN (ospf_auto_cost_reference_bandwidth,
2481 ospf_auto_cost_reference_bandwidth_cmd,
718e3744 2482 "auto-cost reference-bandwidth <1-4294967>",
2483 "Calculate OSPF interface cost according to bandwidth\n"
2484 "Use reference bandwidth method to assign OSPF cost\n"
2485 "The reference bandwidth in terms of Mbits per second\n")
2486{
68980084 2487 struct ospf *ospf = vty->index;
718e3744 2488 u_int32_t refbw;
52dc7ee6 2489 struct listnode *node;
1eb8ef25 2490 struct interface *ifp;
718e3744 2491
2492 refbw = strtol (argv[0], NULL, 10);
2493 if (refbw < 1 || refbw > 4294967)
2494 {
2495 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2496 return CMD_WARNING;
2497 }
2498
2499 /* If reference bandwidth is changed. */
68980084 2500 if ((refbw * 1000) == ospf->ref_bandwidth)
718e3744 2501 return CMD_SUCCESS;
2502
68980084 2503 ospf->ref_bandwidth = refbw * 1000;
1eb8ef25 2504 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2505 ospf_if_recalculate_output_cost (ifp);
718e3744 2506
2507 return CMD_SUCCESS;
2508}
2509
a2c62831 2510DEFUN (no_ospf_auto_cost_reference_bandwidth,
2511 no_ospf_auto_cost_reference_bandwidth_cmd,
718e3744 2512 "no auto-cost reference-bandwidth",
2513 NO_STR
2514 "Calculate OSPF interface cost according to bandwidth\n"
2515 "Use reference bandwidth method to assign OSPF cost\n")
2516{
68980084 2517 struct ospf *ospf = vty->index;
1eb8ef25 2518 struct listnode *node, *nnode;
2519 struct interface *ifp;
718e3744 2520
68980084 2521 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
718e3744 2522 return CMD_SUCCESS;
2523
68980084 2524 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
718e3744 2525 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2526 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2527
1eb8ef25 2528 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2529 ospf_if_recalculate_output_cost (ifp);
718e3744 2530
2531 return CMD_SUCCESS;
2532}
2533
2f8f370e
DS
2534DEFUN (ospf_write_multiplier,
2535 ospf_write_multiplier_cmd,
e8f45e82
DS
2536 "ospf write-multiplier <1-100>",
2537 "OSPF specific commands\n"
2538 "Write multiplier\n"
2539 "Maximum number of interface serviced per write\n")
2f8f370e
DS
2540{
2541 struct ospf *ospf = vty->index;
e8f45e82 2542 u_int32_t write_oi_count;
2f8f370e 2543
e8f45e82
DS
2544 write_oi_count = strtol (argv[0], NULL, 10);
2545 if (write_oi_count < 1 || write_oi_count > 100)
2f8f370e
DS
2546 {
2547 vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE);
2548 return CMD_WARNING;
2549 }
2550
e8f45e82 2551 ospf->write_oi_count = write_oi_count;
2f8f370e
DS
2552 return CMD_SUCCESS;
2553}
2554
e8f45e82
DS
2555ALIAS (ospf_write_multiplier,
2556 write_multiplier_cmd,
2557 "write-multiplier <1-100>",
2558 "Write multiplier\n"
2559 "Maximum number of interface serviced per write\n")
2560
2f8f370e
DS
2561DEFUN (no_ospf_write_multiplier,
2562 no_ospf_write_multiplier_cmd,
e8f45e82 2563 "no ospf write-multiplier",
2f8f370e 2564 NO_STR
e8f45e82
DS
2565 "OSPF specific commands\n"
2566 "Write multiplier\n")
2f8f370e
DS
2567{
2568 struct ospf *ospf = vty->index;
2569
e8f45e82 2570 ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
2f8f370e
DS
2571 return CMD_SUCCESS;
2572}
2573
e8f45e82
DS
2574ALIAS (no_ospf_write_multiplier,
2575 no_write_multiplier_cmd,
2576 "no write-multiplier",
2577 NO_STR
2578 "Write multiplier\n")
2579
eb1ce605 2580const char *ospf_abr_type_descr_str[] =
718e3744 2581{
2582 "Unknown",
2583 "Standard (RFC2328)",
2584 "Alternative IBM",
2585 "Alternative Cisco",
2586 "Alternative Shortcut"
2587};
2588
eb1ce605 2589const char *ospf_shortcut_mode_descr_str[] =
718e3744 2590{
2591 "Default",
2592 "Enabled",
2593 "Disabled"
2594};
2595
2596
6b0655a2 2597
4dadc291 2598static void
718e3744 2599show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2600{
2601 /* Show Area ID. */
2602 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2603
2604 /* Show Area type/mode. */
2605 if (OSPF_IS_AREA_BACKBONE (area))
2606 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2607 else
2608 {
2609 if (area->external_routing == OSPF_AREA_STUB)
b0a053be 2610 vty_out (vty, " (Stub%s%s)",
2611 area->no_summary ? ", no summary" : "",
2612 area->shortcut_configured ? "; " : "");
718e3744 2613
b0a053be 2614 else if (area->external_routing == OSPF_AREA_NSSA)
2615 vty_out (vty, " (NSSA%s%s)",
2616 area->no_summary ? ", no summary" : "",
2617 area->shortcut_configured ? "; " : "");
718e3744 2618
2619 vty_out (vty, "%s", VTY_NEWLINE);
2620 vty_out (vty, " Shortcutting mode: %s",
b0a053be 2621 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
718e3744 2622 vty_out (vty, ", S-bit consensus: %s%s",
b0a053be 2623 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
718e3744 2624 }
2625
2626 /* Show number of interfaces. */
2627 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2628 "Active: %d%s", listcount (area->oiflist),
2629 area->act_ints, VTY_NEWLINE);
2630
718e3744 2631 if (area->external_routing == OSPF_AREA_NSSA)
2632 {
2633 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 2634 if (! IS_OSPF_ABR (area->ospf))
b0a053be 2635 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2636 VTY_NEWLINE);
2637 else if (area->NSSATranslatorState)
2638 {
2639 vty_out (vty, " We are an ABR and ");
2640 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2641 vty_out (vty, "the NSSA Elected Translator. %s",
2642 VTY_NEWLINE);
2643 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2644 vty_out (vty, "always an NSSA Translator. %s",
2645 VTY_NEWLINE);
2646 }
718e3744 2647 else
b0a053be 2648 {
2649 vty_out (vty, " We are an ABR, but ");
2650 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2651 vty_out (vty, "not the NSSA Elected Translator. %s",
2652 VTY_NEWLINE);
2653 else
c6b87819 2654 vty_out (vty, "never an NSSA Translator. %s",
b0a053be 2655 VTY_NEWLINE);
2656 }
718e3744 2657 }
88d6cf37 2658 /* Stub-router state for this area */
2659 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2660 {
649654ab 2661 char timebuf[OSPF_TIME_DUMP_SIZE];
88d6cf37 2662 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2663 VTY_NEWLINE);
2664 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2665 vty_out (vty, " Administratively activated (indefinitely)%s",
2666 VTY_NEWLINE);
2667 if (area->t_stub_router)
2668 vty_out (vty, " Active from startup, %s remaining%s",
2669 ospf_timer_dump (area->t_stub_router, timebuf,
2670 sizeof(timebuf)), VTY_NEWLINE);
2671 }
2672
718e3744 2673 /* Show number of fully adjacent neighbors. */
2674 vty_out (vty, " Number of fully adjacent neighbors in this area:"
b0a053be 2675 " %d%s", area->full_nbrs, VTY_NEWLINE);
718e3744 2676
2677 /* Show authentication type. */
2678 vty_out (vty, " Area has ");
2679 if (area->auth_type == OSPF_AUTH_NULL)
2680 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2681 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2682 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2683 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2684 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2685
2686 if (!OSPF_IS_AREA_BACKBONE (area))
2687 vty_out (vty, " Number of full virtual adjacencies going through"
2688 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2689
2690 /* Show SPF calculation times. */
2691 vty_out (vty, " SPF algorithm executed %d times%s",
2692 area->spf_calculation, VTY_NEWLINE);
2693
2694 /* Show number of LSA. */
2695 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
fe71a97d 2696 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2697 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2698 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2699 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2700 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2701 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2702 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2703 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2704 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2705 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2706 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2707 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2708 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2709 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2710 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2711#ifdef HAVE_OPAQUE_LSA
2712 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2713 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2714 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2715 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2716 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2717 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2718#endif /* HAVE_OPAQUE_LSA */
718e3744 2719 vty_out (vty, "%s", VTY_NEWLINE);
2720}
2721
2722DEFUN (show_ip_ospf,
2723 show_ip_ospf_cmd,
2724 "show ip ospf",
2725 SHOW_STR
2726 IP_STR
2727 "OSPF information\n")
2728{
1eb8ef25 2729 struct listnode *node, *nnode;
718e3744 2730 struct ospf_area * area;
020709f9 2731 struct ospf *ospf;
d24f6e2a 2732 struct timeval result;
649654ab 2733 char timebuf[OSPF_TIME_DUMP_SIZE];
718e3744 2734
2735 /* Check OSPF is enable. */
020709f9 2736 ospf = ospf_lookup ();
68980084 2737 if (ospf == NULL)
718e3744 2738 {
2739 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2740 return CMD_SUCCESS;
2741 }
2742
2743 /* Show Router ID. */
2744 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
68980084 2745 inet_ntoa (ospf->router_id),
718e3744 2746 VTY_NEWLINE);
88d6cf37 2747
2748 /* Graceful shutdown */
c9c93d50 2749 if (ospf->t_deferred_shutdown)
2750 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2751 ospf_timer_dump (ospf->t_deferred_shutdown,
88d6cf37 2752 timebuf, sizeof (timebuf)), VTY_NEWLINE);
718e3744 2753 /* Show capability. */
2754 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2755 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2756 vty_out (vty, " RFC1583Compatibility flag is %s%s",
68980084 2757 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
718e3744 2758 "enabled" : "disabled", VTY_NEWLINE);
2759#ifdef HAVE_OPAQUE_LSA
2760 vty_out (vty, " OpaqueCapability flag is %s%s%s",
68980084 2761 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
718e3744 2762 "enabled" : "disabled",
68980084 2763 IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
718e3744 2764 " (origination blocked)" : "",
2765 VTY_NEWLINE);
2766#endif /* HAVE_OPAQUE_LSA */
88d6cf37 2767
2768 /* Show stub-router configuration */
2769 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2770 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2771 {
2772 vty_out (vty, " Stub router advertisement is configured%s",
2773 VTY_NEWLINE);
2774 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2775 vty_out (vty, " Enabled for %us after start-up%s",
2776 ospf->stub_router_startup_time, VTY_NEWLINE);
2777 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2778 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2779 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2780 }
2781
718e3744 2782 /* Show SPF timers. */
d24f6e2a 2783 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2784 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2785 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2786 " Hold time multiplier is currently %d%s",
2787 ospf->spf_delay, VTY_NEWLINE,
2788 ospf->spf_holdtime, VTY_NEWLINE,
2789 ospf->spf_max_holdtime, VTY_NEWLINE,
2790 ospf->spf_hold_multiplier, VTY_NEWLINE);
b8ad39d4 2791 vty_out (vty, " SPF algorithm ");
2792 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2793 {
2518efd1 2794 result = tv_sub (recent_relative_time (), ospf->ts_spf);
b8ad39d4 2795 vty_out (vty, "last executed %s ago%s",
2796 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2797 VTY_NEWLINE);
cf744958
DS
2798 vty_out (vty, " Last SPF duration %s%s",
2799 ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)),
2800 VTY_NEWLINE);
b8ad39d4 2801 }
2802 else
2803 vty_out (vty, "has not been run%s", VTY_NEWLINE);
d24f6e2a 2804 vty_out (vty, " SPF timer %s%s%s",
2805 (ospf->t_spf_calc ? "due in " : "is "),
2806 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2807 VTY_NEWLINE);
2808
2f8f370e
DS
2809 /* Show write multiplier values */
2810 vty_out (vty, " Write Multiplier set to %d %s",
e8f45e82 2811 ospf->write_oi_count, VTY_NEWLINE);
2f8f370e 2812
718e3744 2813 /* Show refresh parameters. */
2814 vty_out (vty, " Refresh timer %d secs%s",
68980084 2815 ospf->lsa_refresh_interval, VTY_NEWLINE);
718e3744 2816
2817 /* Show ABR/ASBR flags. */
68980084 2818 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
718e3744 2819 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
68980084 2820 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
718e3744 2821
68980084 2822 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
718e3744 2823 vty_out (vty, " This router is an ASBR "
2824 "(injecting external routing information)%s", VTY_NEWLINE);
2825
2826 /* Show Number of AS-external-LSAs. */
fe71a97d 2827 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2828 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2829 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2830#ifdef HAVE_OPAQUE_LSA
2831 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2832 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2833 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2834#endif /* HAVE_OPAQUE_LSA */
718e3744 2835 /* Show number of areas attached. */
d7e60dd7
AS
2836 vty_out (vty, " Number of areas attached to this router: %d%s",
2837 listcount (ospf->areas), VTY_NEWLINE);
2838
2839 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2840 {
2841 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2842 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2843 else
2844 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2845 }
2846
2847 vty_out (vty, "%s",VTY_NEWLINE);
718e3744 2848
2849 /* Show each area status. */
1eb8ef25 2850 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2851 show_ip_ospf_area (vty, area);
718e3744 2852
2853 return CMD_SUCCESS;
2854}
2855
6b0655a2 2856
fd651fa6 2857static void
68980084 2858show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2859 struct interface *ifp)
718e3744 2860{
fd651fa6 2861 int is_up;
718e3744 2862 struct ospf_neighbor *nbr;
718e3744 2863 struct route_node *rn;
718e3744 2864
718e3744 2865 /* Is interface up? */
fd651fa6 2866 vty_out (vty, "%s is %s%s", ifp->name,
2867 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
d2fc8896 2868 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2869 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2870 VTY_NEWLINE);
718e3744 2871
2872 /* Is interface OSPF enabled? */
fd651fa6 2873 if (ospf_oi_count(ifp) == 0)
718e3744 2874 {
2875 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2876 return;
2877 }
fd651fa6 2878 else if (!is_up)
2879 {
2880 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2881 VTY_NEWLINE);
2882 return;
2883 }
2884
718e3744 2885 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2886 {
2887 struct ospf_interface *oi = rn->info;
2888
2889 if (oi == NULL)
2890 continue;
2891
525c1839
DS
2892 if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED))
2893 {
2894 vty_out (vty, " This interface is UNNUMBERED,");
2895 }
2896 else
9c27ef9b 2897 {
525c1839
DS
2898 /* Show OSPF interface information. */
2899 vty_out (vty, " Internet Address %s/%d,",
2900 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2901
2902 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2903 {
2904 struct in_addr *dest;
2905 const char *dstr;
2906
2907 if (CONNECTED_PEER(oi->connected)
2908 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2909 dstr = "Peer";
2910 else
2911 dstr = "Broadcast";
2912
2913 /* For Vlinks, showing the peer address is probably more
2914 * informative than the local interface that is being used
2915 */
2916 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2917 dest = &oi->vl_data->peer_addr;
2918 else
2919 dest = &oi->connected->destination->u.prefix4;
2920
2921 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2922 }
9c27ef9b 2923 }
3fb9cd6e 2924
718e3744 2925 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2926 VTY_NEWLINE);
2927
ba682537 2928 vty_out (vty, " MTU mismatch detection:%s%s",
2929 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2930
718e3744 2931 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
68980084 2932 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
718e3744 2933 oi->output_cost, VTY_NEWLINE);
2934
2935 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
2936 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
2937 PRIORITY (oi), VTY_NEWLINE);
2938
2939 /* Show DR information. */
2940 if (DR (oi).s_addr == 0)
2941 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2942 else
2943 {
2944 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
2945 if (nbr == NULL)
2946 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
2947 else
2948 {
2949 vty_out (vty, " Designated Router (ID) %s,",
2950 inet_ntoa (nbr->router_id));
2951 vty_out (vty, " Interface Address %s%s",
2952 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2953 }
2954 }
2955
2956 /* Show BDR information. */
2957 if (BDR (oi).s_addr == 0)
2958 vty_out (vty, " No backup designated router on this network%s",
2959 VTY_NEWLINE);
2960 else
2961 {
2962 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
2963 if (nbr == NULL)
2964 vty_out (vty, " No backup designated router on this network%s",
2965 VTY_NEWLINE);
2966 else
2967 {
2968 vty_out (vty, " Backup Designated Router (ID) %s,",
2969 inet_ntoa (nbr->router_id));
2970 vty_out (vty, " Interface Address %s%s",
2971 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
2972 }
2973 }
525c1839 2974
7eb5b47e
PJ
2975 /* Next network-LSA sequence number we'll use, if we're elected DR */
2976 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
2977 != OSPF_INITIAL_SEQUENCE_NUMBER)
2978 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
2979 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
2980
ba6454ec 2981 vty_out (vty, " Multicast group memberships:");
429ac78c
PJ
2982 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
2983 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2984 {
2985 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
2986 vty_out (vty, " OSPFAllRouters");
2987 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
2988 vty_out (vty, " OSPFDesignatedRouters");
2989 }
2990 else
ba6454ec 2991 vty_out (vty, " <None>");
2992 vty_out (vty, "%s", VTY_NEWLINE);
2993
718e3744 2994 vty_out (vty, " Timer intervals configured,");
f9ad937f 2995 vty_out (vty, " Hello ");
2996 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
2997 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
2998 else
2999 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
3000 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
3001 OSPF_IF_PARAM (oi, v_wait),
718e3744 3002 OSPF_IF_PARAM (oi, v_wait),
3003 OSPF_IF_PARAM (oi, retransmit_interval),
3004 VTY_NEWLINE);
3005
7ffa8fa2 3006 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
f9ad937f 3007 {
649654ab 3008 char timebuf[OSPF_TIME_DUMP_SIZE];
f9ad937f 3009 vty_out (vty, " Hello due in %s%s",
649654ab 3010 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
f9ad937f 3011 VTY_NEWLINE);
3012 }
7ffa8fa2 3013 else /* passive-interface is set */
718e3744 3014 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
3015
3016 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
68980084 3017 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
718e3744 3018 VTY_NEWLINE);
3019 }
3020}
3021
3022DEFUN (show_ip_ospf_interface,
3023 show_ip_ospf_interface_cmd,
3024 "show ip ospf interface [INTERFACE]",
3025 SHOW_STR
3026 IP_STR
3027 "OSPF information\n"
3028 "Interface information\n"
3029 "Interface name\n")
3030{
3031 struct interface *ifp;
020709f9 3032 struct ospf *ospf;
52dc7ee6 3033 struct listnode *node;
718e3744 3034
020709f9 3035 ospf = ospf_lookup ();
cac3b5c4
PJ
3036 if (ospf == NULL)
3037 {
3038 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
3039 return CMD_SUCCESS;
3040 }
020709f9 3041
718e3744 3042 /* Show All Interfaces. */
3043 if (argc == 0)
1eb8ef25 3044 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
3045 show_ip_ospf_interface_sub (vty, ospf, ifp);
718e3744 3046 /* Interface name is specified. */
3047 else
3048 {
3049 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
3050 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
3051 else
68980084 3052 show_ip_ospf_interface_sub (vty, ospf, ifp);
718e3744 3053 }
3054
3055 return CMD_SUCCESS;
3056}
3057
d24f6e2a 3058static void
3059show_ip_ospf_neighbour_header (struct vty *vty)
3060{
3061 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3062 VTY_NEWLINE,
3063 "Neighbor ID", "Pri", "State", "Dead Time",
3064 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3065 VTY_NEWLINE);
3066}
3067
4dadc291 3068static void
718e3744 3069show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3070{
3071 struct route_node *rn;
3072 struct ospf_neighbor *nbr;
3073 char msgbuf[16];
649654ab 3074 char timebuf[OSPF_TIME_DUMP_SIZE];
718e3744 3075
3076 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3077 if ((nbr = rn->info))
3078 /* Do not show myself. */
3079 if (nbr != oi->nbr_self)
3080 /* Down state is not shown. */
3081 if (nbr->state != NSM_Down)
3082 {
3083 ospf_nbr_state_message (nbr, msgbuf, 16);
3084
3085 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
d24f6e2a 3086 vty_out (vty, "%-15s %3d %-15s ",
3087 "-", nbr->priority,
3088 msgbuf);
3089 else
3090 vty_out (vty, "%-15s %3d %-15s ",
3091 inet_ntoa (nbr->router_id), nbr->priority,
3092 msgbuf);
3093
3094 vty_out (vty, "%9s ",
3095 ospf_timer_dump (nbr->t_inactivity, timebuf,
3096 sizeof(timebuf)));
3097
718e3744 3098 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
d24f6e2a 3099 vty_out (vty, "%-20s %5ld %5ld %5d%s",
718e3744 3100 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3101 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3102 VTY_NEWLINE);
3103 }
3104}
3105
3106DEFUN (show_ip_ospf_neighbor,
3107 show_ip_ospf_neighbor_cmd,
3108 "show ip ospf neighbor",
3109 SHOW_STR
3110 IP_STR
3111 "OSPF information\n"
3112 "Neighbor list\n")
3113{
020709f9 3114 struct ospf *ospf;
1eb8ef25 3115 struct ospf_interface *oi;
52dc7ee6 3116 struct listnode *node;
718e3744 3117
020709f9 3118 ospf = ospf_lookup ();
68980084 3119 if (ospf == NULL)
718e3744 3120 {
3121 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3122 return CMD_SUCCESS;
3123 }
3124
d24f6e2a 3125 show_ip_ospf_neighbour_header (vty);
718e3744 3126
1eb8ef25 3127 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3128 show_ip_ospf_neighbor_sub (vty, oi);
718e3744 3129
3130 return CMD_SUCCESS;
3131}
3132
3133DEFUN (show_ip_ospf_neighbor_all,
3134 show_ip_ospf_neighbor_all_cmd,
3135 "show ip ospf neighbor all",
3136 SHOW_STR
3137 IP_STR
3138 "OSPF information\n"
3139 "Neighbor list\n"
3140 "include down status neighbor\n")
3141{
35f89140 3142 struct ospf *ospf = ospf_lookup ();
52dc7ee6 3143 struct listnode *node;
1eb8ef25 3144 struct ospf_interface *oi;
718e3744 3145
68980084 3146 if (ospf == NULL)
718e3744 3147 {
3148 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3149 return CMD_SUCCESS;
3150 }
d24f6e2a 3151
3152 show_ip_ospf_neighbour_header (vty);
3153
1eb8ef25 3154 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
718e3744 3155 {
52dc7ee6 3156 struct listnode *nbr_node;
1eb8ef25 3157 struct ospf_nbr_nbma *nbr_nbma;
718e3744 3158
3159 show_ip_ospf_neighbor_sub (vty, oi);
3160
3161 /* print Down neighbor status */
1eb8ef25 3162 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
718e3744 3163 {
718e3744 3164 if (nbr_nbma->nbr == NULL
3165 || nbr_nbma->nbr->state == NSM_Down)
3166 {
d24f6e2a 3167 vty_out (vty, "%-15s %3d %-15s %9s ",
718e3744 3168 "-", nbr_nbma->priority, "Down", "-");
d24f6e2a 3169 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
718e3744 3170 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3171 0, 0, 0, VTY_NEWLINE);
3172 }
3173 }
3174 }
3175
3176 return CMD_SUCCESS;
3177}
3178
3179DEFUN (show_ip_ospf_neighbor_int,
3180 show_ip_ospf_neighbor_int_cmd,
bb5b7552 3181 "show ip ospf neighbor IFNAME",
718e3744 3182 SHOW_STR
3183 IP_STR
3184 "OSPF information\n"
3185 "Neighbor list\n"
3186 "Interface name\n")
3187{
020709f9 3188 struct ospf *ospf;
bb5b7552 3189 struct interface *ifp;
3190 struct route_node *rn;
3191
3192 ifp = if_lookup_by_name (argv[0]);
3193 if (!ifp)
718e3744 3194 {
bb5b7552 3195 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
718e3744 3196 return CMD_WARNING;
3197 }
3198
020709f9 3199 ospf = ospf_lookup ();
3200 if (ospf == NULL)
3201 {
3202 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3203 return CMD_SUCCESS;
3204 }
d24f6e2a 3205
3206 show_ip_ospf_neighbour_header (vty);
3207
bb5b7552 3208 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
718e3744 3209 {
bb5b7552 3210 struct ospf_interface *oi = rn->info;
3211
3212 if (oi == NULL)
3213 continue;
3214
718e3744 3215 show_ip_ospf_neighbor_sub (vty, oi);
3216 }
3217
3218 return CMD_SUCCESS;
3219}
3220
4dadc291 3221static void
718e3744 3222show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3223 struct ospf_nbr_nbma *nbr_nbma)
3224{
649654ab 3225 char timebuf[OSPF_TIME_DUMP_SIZE];
718e3744 3226
3227 /* Show neighbor ID. */
3228 vty_out (vty, " Neighbor %s,", "-");
3229
3230 /* Show interface address. */
3231 vty_out (vty, " interface address %s%s",
3232 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3233 /* Show Area ID. */
3234 vty_out (vty, " In the area %s via interface %s%s",
3235 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3236 /* Show neighbor priority and state. */
3237 vty_out (vty, " Neighbor priority is %d, State is %s,",
3238 nbr_nbma->priority, "Down");
3239 /* Show state changes. */
3240 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3241
3242 /* Show PollInterval */
3243 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3244
3245 /* Show poll-interval timer. */
3246 vty_out (vty, " Poll timer due in %s%s",
d24f6e2a 3247 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3248 VTY_NEWLINE);
718e3744 3249
3250 /* Show poll-interval timer thread. */
3251 vty_out (vty, " Thread Poll Timer %s%s",
3252 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3253}
3254
4dadc291 3255static void
718e3744 3256show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3257 struct ospf_neighbor *nbr)
3258{
649654ab 3259 char timebuf[OSPF_TIME_DUMP_SIZE];
718e3744 3260
3261 /* Show neighbor ID. */
3262 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3263 vty_out (vty, " Neighbor %s,", "-");
3264 else
3265 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3266
3267 /* Show interface address. */
3268 vty_out (vty, " interface address %s%s",
3269 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3270 /* Show Area ID. */
3271 vty_out (vty, " In the area %s via interface %s%s",
3272 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3273 /* Show neighbor priority and state. */
3274 vty_out (vty, " Neighbor priority is %d, State is %s,",
3275 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3276 /* Show state changes. */
3277 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
3fed4160 3278 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
90c33177 3279 {
2518efd1
PJ
3280 struct timeval res
3281 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
3fed4160
PJ
3282 vty_out (vty, " Most recent state change statistics:%s",
3283 VTY_NEWLINE);
3284 vty_out (vty, " Progressive change %s ago%s",
3285 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3286 VTY_NEWLINE);
3287 }
3288 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3289 {
2518efd1
PJ
3290 struct timeval res
3291 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
3fed4160 3292 vty_out (vty, " Regressive change %s ago, due to %s%s",
90c33177 3293 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3fed4160 3294 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
90c33177
PJ
3295 VTY_NEWLINE);
3296 }
718e3744 3297 /* Show Designated Rotuer ID. */
3298 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3299 /* Show Backup Designated Rotuer ID. */
3300 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3301 /* Show options. */
3302 vty_out (vty, " Options %d %s%s", nbr->options,
3303 ospf_options_dump (nbr->options), VTY_NEWLINE);
3304 /* Show Router Dead interval timer. */
3305 vty_out (vty, " Dead timer due in %s%s",
d24f6e2a 3306 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3307 VTY_NEWLINE);
718e3744 3308 /* Show Database Summary list. */
3309 vty_out (vty, " Database Summary List %d%s",
3310 ospf_db_summary_count (nbr), VTY_NEWLINE);
3311 /* Show Link State Request list. */
3312 vty_out (vty, " Link State Request List %ld%s",
3313 ospf_ls_request_count (nbr), VTY_NEWLINE);
3314 /* Show Link State Retransmission list. */
3315 vty_out (vty, " Link State Retransmission List %ld%s",
3316 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3317 /* Show inactivity timer thread. */
3318 vty_out (vty, " Thread Inactivity Timer %s%s",
3319 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3320 /* Show Database Description retransmission thread. */
3321 vty_out (vty, " Thread Database Description Retransmision %s%s",
3322 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3323 /* Show Link State Request Retransmission thread. */
3324 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3325 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3326 /* Show Link State Update Retransmission thread. */
3327 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3328 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3329}
3330
3331DEFUN (show_ip_ospf_neighbor_id,
3332 show_ip_ospf_neighbor_id_cmd,
3333 "show ip ospf neighbor A.B.C.D",
3334 SHOW_STR
3335 IP_STR
3336 "OSPF information\n"
3337 "Neighbor list\n"
3338 "Neighbor ID\n")
3339{
020709f9 3340 struct ospf *ospf;
52dc7ee6 3341 struct listnode *node;
718e3744 3342 struct ospf_neighbor *nbr;
1eb8ef25 3343 struct ospf_interface *oi;
718e3744 3344 struct in_addr router_id;
3345 int ret;
3346
3347 ret = inet_aton (argv[0], &router_id);
3348 if (!ret)
3349 {
3350 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3351 return CMD_WARNING;
3352 }
3353
020709f9 3354 ospf = ospf_lookup ();
3355 if (ospf == NULL)
3356 {
3357 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3358 return CMD_SUCCESS;
3359 }
3360
1eb8ef25 3361 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3362 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
1c066bfe 3363 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
718e3744 3364
718e3744 3365 return CMD_SUCCESS;
3366}
3367
3368DEFUN (show_ip_ospf_neighbor_detail,
3369 show_ip_ospf_neighbor_detail_cmd,
3370 "show ip ospf neighbor detail",
3371 SHOW_STR
3372 IP_STR
3373 "OSPF information\n"
3374 "Neighbor list\n"
3375 "detail of all neighbors\n")
3376{
020709f9 3377 struct ospf *ospf;
1eb8ef25 3378 struct ospf_interface *oi;
52dc7ee6 3379 struct listnode *node;
718e3744 3380
020709f9 3381 ospf = ospf_lookup ();
68980084 3382 if (ospf == NULL)
020709f9 3383 {
3384 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3385 return CMD_SUCCESS;
3386 }
718e3744 3387
1eb8ef25 3388 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
718e3744 3389 {
718e3744 3390 struct route_node *rn;
3391 struct ospf_neighbor *nbr;
3392
3393 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3394 if ((nbr = rn->info))
3395 if (nbr != oi->nbr_self)
3396 if (nbr->state != NSM_Down)
3397 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3398 }
3399
3400 return CMD_SUCCESS;
3401}
3402
3403DEFUN (show_ip_ospf_neighbor_detail_all,
3404 show_ip_ospf_neighbor_detail_all_cmd,
3405 "show ip ospf neighbor detail all",
3406 SHOW_STR
3407 IP_STR
3408 "OSPF information\n"
3409 "Neighbor list\n"
3410 "detail of all neighbors\n"
3411 "include down status neighbor\n")
3412{
020709f9 3413 struct ospf *ospf;
52dc7ee6 3414 struct listnode *node;
1eb8ef25 3415 struct ospf_interface *oi;
718e3744 3416
020709f9 3417 ospf = ospf_lookup ();
68980084 3418 if (ospf == NULL)
020709f9 3419 {
3420 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3421 return CMD_SUCCESS;
3422 }
718e3744 3423
1eb8ef25 3424 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
718e3744 3425 {
718e3744 3426 struct route_node *rn;
3427 struct ospf_neighbor *nbr;
1eb8ef25 3428 struct ospf_nbr_nbma *nbr_nbma;
718e3744 3429
3430 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3431 if ((nbr = rn->info))
3432 if (nbr != oi->nbr_self)
3433 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3434 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3435
3436 if (oi->type == OSPF_IFTYPE_NBMA)
3437 {
52dc7ee6 3438 struct listnode *nd;
718e3744 3439
1eb8ef25 3440 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3441 if (nbr_nbma->nbr == NULL
3442 || nbr_nbma->nbr->state == NSM_Down)
3443 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
718e3744 3444 }
3445 }
3446
3447 return CMD_SUCCESS;
3448}
3449
3450DEFUN (show_ip_ospf_neighbor_int_detail,
3451 show_ip_ospf_neighbor_int_detail_cmd,
bb5b7552 3452 "show ip ospf neighbor IFNAME detail",
718e3744 3453 SHOW_STR
3454 IP_STR
3455 "OSPF information\n"
3456 "Neighbor list\n"
bb5b7552 3457 "Interface name\n"
718e3744 3458 "detail of all neighbors")
3459{
020709f9 3460 struct ospf *ospf;
718e3744 3461 struct ospf_interface *oi;
bb5b7552 3462 struct interface *ifp;
3463 struct route_node *rn, *nrn;
3464 struct ospf_neighbor *nbr;
3465
3466 ifp = if_lookup_by_name (argv[0]);
3467 if (!ifp)
718e3744 3468 {
bb5b7552 3469 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
718e3744 3470 return CMD_WARNING;
3471 }
3472
020709f9 3473 ospf = ospf_lookup ();
3474 if (ospf == NULL)
3475 {
3476 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3477 return CMD_SUCCESS;
3478 }
68980084 3479
718e3744 3480
bb5b7552 3481 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3482 if ((oi = rn->info))
3483 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3484 if ((nbr = nrn->info))
718e3744 3485 if (nbr != oi->nbr_self)
3486 if (nbr->state != NSM_Down)
3487 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
718e3744 3488
3489 return CMD_SUCCESS;
3490}
3491
6b0655a2 3492
718e3744 3493/* Show functions */
4dadc291 3494static int
020709f9 3495show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
718e3744 3496{
718e3744 3497 struct router_lsa *rl;
3498 struct summary_lsa *sl;
3499 struct as_external_lsa *asel;
3500 struct prefix_ipv4 p;
3501
3502 if (lsa != NULL)
3503 /* If self option is set, check LSA self flag. */
3504 if (self == 0 || IS_LSA_SELF (lsa))
3505 {
3506 /* LSA common part show. */
3507 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3508 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3509 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3510 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3511 /* LSA specific part show. */
3512 switch (lsa->data->type)
3513 {
3514 case OSPF_ROUTER_LSA:
3515 rl = (struct router_lsa *) lsa->data;
3516 vty_out (vty, " %-d", ntohs (rl->links));
3517 break;
3518 case OSPF_SUMMARY_LSA:
3519 sl = (struct summary_lsa *) lsa->data;
3520
3521 p.family = AF_INET;
3522 p.prefix = sl->header.id;
3523 p.prefixlen = ip_masklen (sl->mask);
3524 apply_mask_ipv4 (&p);
3525
3526 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3527 break;
3528 case OSPF_AS_EXTERNAL_LSA:
551a8979 3529 case OSPF_AS_NSSA_LSA:
718e3744 3530 asel = (struct as_external_lsa *) lsa->data;
3531
3532 p.family = AF_INET;
3533 p.prefix = asel->header.id;
3534 p.prefixlen = ip_masklen (asel->mask);
3535 apply_mask_ipv4 (&p);
3536
3537 vty_out (vty, " %s %s/%d [0x%lx]",
3538 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3539 inet_ntoa (p.prefix), p.prefixlen,
3540 (u_long)ntohl (asel->e[0].route_tag));
3541 break;
3542 case OSPF_NETWORK_LSA:
3543 case OSPF_ASBR_SUMMARY_LSA:
3544#ifdef HAVE_OPAQUE_LSA
3545 case OSPF_OPAQUE_LINK_LSA:
3546 case OSPF_OPAQUE_AREA_LSA:
3547 case OSPF_OPAQUE_AS_LSA:
3548#endif /* HAVE_OPAQUE_LSA */
3549 default:
3550 break;
3551 }
3552 vty_out (vty, VTY_NEWLINE);
3553 }
3554
3555 return 0;
3556}
3557
8b6a15b2 3558static const char *show_database_desc[] =
718e3744 3559{
3560 "unknown",
3561 "Router Link States",
3562 "Net Link States",
3563 "Summary Link States",
3564 "ASBR-Summary Link States",
3565 "AS External Link States",
718e3744 3566 "Group Membership LSA",
3567 "NSSA-external Link States",
718e3744 3568#ifdef HAVE_OPAQUE_LSA
3569 "Type-8 LSA",
3570 "Link-Local Opaque-LSA",
3571 "Area-Local Opaque-LSA",
3572 "AS-external Opaque-LSA",
3573#endif /* HAVE_OPAQUE_LSA */
3574};
3575
8b6a15b2 3576static const char *show_database_header[] =
718e3744 3577{
3578 "",
3579 "Link ID ADV Router Age Seq# CkSum Link count",
3580 "Link ID ADV Router Age Seq# CkSum",
3581 "Link ID ADV Router Age Seq# CkSum Route",
3582 "Link ID ADV Router Age Seq# CkSum",
3583 "Link ID ADV Router Age Seq# CkSum Route",
718e3744 3584 " --- header for Group Member ----",
3585 "Link ID ADV Router Age Seq# CkSum Route",
718e3744 3586#ifdef HAVE_OPAQUE_LSA
718e3744 3587 " --- type-8 ---",
3588 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3589 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3590 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3591#endif /* HAVE_OPAQUE_LSA */
3592};
3593
4dadc291 3594static void
718e3744 3595show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3596{
3597 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
4957f494 3598
718e3744 3599 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
4957f494 3600 vty_out (vty, " Options: 0x%-2x : %s%s",
3601 lsa->data->options,
3602 ospf_options_dump(lsa->data->options),
3603 VTY_NEWLINE);
3604 vty_out (vty, " LS Flags: 0x%-2x %s%s",
9d526037 3605 lsa->flags,
4957f494 3606 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3607 VTY_NEWLINE);
718e3744 3608
3609 if (lsa->data->type == OSPF_ROUTER_LSA)
3610 {
3611 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3612
3613 if (rlsa->flags)
3614 vty_out (vty, " :%s%s%s%s",
3615 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3616 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3617 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3618 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3619
3620 vty_out (vty, "%s", VTY_NEWLINE);
3621 }
3622 vty_out (vty, " LS Type: %s%s",
3623 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3624 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3625 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3626 vty_out (vty, " Advertising Router: %s%s",
3627 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3628 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3629 VTY_NEWLINE);
3630 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3631 VTY_NEWLINE);
3632 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3633}
3634
eb1ce605 3635const char *link_type_desc[] =
718e3744 3636{
3637 "(null)",
3638 "another Router (point-to-point)",
3639 "a Transit Network",
3640 "Stub Network",
3641 "a Virtual Link",
3642};
3643
eb1ce605 3644const char *link_id_desc[] =
718e3744 3645{
3646 "(null)",
3647 "Neighboring Router ID",
3648 "Designated Router address",
68980084 3649 "Net",
718e3744 3650 "Neighboring Router ID",
3651};
3652
eb1ce605 3653const char *link_data_desc[] =
718e3744 3654{
3655 "(null)",
3656 "Router Interface address",
3657 "Router Interface address",
3658 "Network Mask",
3659 "Router Interface address",
3660};
3661
3662/* Show router-LSA each Link information. */
4dadc291 3663static void
718e3744 3664show_ip_ospf_database_router_links (struct vty *vty,
3665 struct router_lsa *rl)
3666{
3667 int len, i, type;
3668
3669 len = ntohs (rl->header.length) - 4;
3670 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3671 {
3672 type = rl->link[i].type;
3673
3674 vty_out (vty, " Link connected to: %s%s",
3675 link_type_desc[type], VTY_NEWLINE);
3676 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3677 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3678 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3679 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3680 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3681 vty_out (vty, " TOS 0 Metric: %d%s",
3682 ntohs (rl->link[i].metric), VTY_NEWLINE);
3683 vty_out (vty, "%s", VTY_NEWLINE);
3684 }
3685}
3686
3687/* Show router-LSA detail information. */
4dadc291 3688static int
718e3744 3689show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3690{
3691 if (lsa != NULL)
3692 {
3693 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3694
3695 show_ip_ospf_database_header (vty, lsa);
3696
3697 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3698 VTY_NEWLINE, VTY_NEWLINE);
3699
3700 show_ip_ospf_database_router_links (vty, rl);
b0a053be 3701 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 3702 }
3703
3704 return 0;
3705}
3706
3707/* Show network-LSA detail information. */
4dadc291 3708static int
718e3744 3709show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3710{
3711 int length, i;
3712
3713 if (lsa != NULL)
3714 {
3715 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3716
3717 show_ip_ospf_database_header (vty, lsa);
3718
3719 vty_out (vty, " Network Mask: /%d%s",
3720 ip_masklen (nl->mask), VTY_NEWLINE);
3721
3722 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3723
3724 for (i = 0; length > 0; i++, length -= 4)
3725 vty_out (vty, " Attached Router: %s%s",
3726 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3727
3728 vty_out (vty, "%s", VTY_NEWLINE);
3729 }
3730
3731 return 0;
3732}
3733
3734/* Show summary-LSA detail information. */
4dadc291 3735static int
718e3744 3736show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3737{
3738 if (lsa != NULL)
3739 {
3740 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3741
3742 show_ip_ospf_database_header (vty, lsa);
3743
3744 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3745 VTY_NEWLINE);
3746 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3747 VTY_NEWLINE);
b0a053be 3748 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 3749 }
3750
3751 return 0;
3752}
3753
3754/* Show summary-ASBR-LSA detail information. */
4dadc291 3755static int
718e3744 3756show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3757{
3758 if (lsa != NULL)
3759 {
3760 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3761
3762 show_ip_ospf_database_header (vty, lsa);
3763
3764 vty_out (vty, " Network Mask: /%d%s",
3765 ip_masklen (sl->mask), VTY_NEWLINE);
3766 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3767 VTY_NEWLINE);
b0a053be 3768 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 3769 }
3770
3771 return 0;
3772}
3773
3774/* Show AS-external-LSA detail information. */
4dadc291 3775static int
718e3744 3776show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3777{
3778 if (lsa != NULL)
3779 {
3780 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3781
3782 show_ip_ospf_database_header (vty, lsa);
3783
3784 vty_out (vty, " Network Mask: /%d%s",
3785 ip_masklen (al->mask), VTY_NEWLINE);
3786 vty_out (vty, " Metric Type: %s%s",
3787 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3788 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3789 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3790 vty_out (vty, " Metric: %d%s",
3791 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3792 vty_out (vty, " Forward Address: %s%s",
3793 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3794
3795 vty_out (vty, " External Route Tag: %lu%s%s",
3796 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3797 }
3798
3799 return 0;
3800}
3801
075e12f5 3802#if 0
4dadc291 3803static int
718e3744 3804show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3805{
3806 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3807
3808 /* show_ip_ospf_database_header (vty, lsa); */
3809
2a42e285 3810 zlog_debug( " Network Mask: /%d%s",
718e3744 3811 ip_masklen (al->mask), "\n");
2a42e285 3812 zlog_debug( " Metric Type: %s%s",
718e3744 3813 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3814 "2 (Larger than any link state path)" : "1", "\n");
2a42e285 3815 zlog_debug( " TOS: 0%s", "\n");
3816 zlog_debug( " Metric: %d%s",
718e3744 3817 GET_METRIC (al->e[0].metric), "\n");
2a42e285 3818 zlog_debug( " Forward Address: %s%s",
718e3744 3819 inet_ntoa (al->e[0].fwd_addr), "\n");
3820
2a42e285 3821 zlog_debug( " External Route Tag: %u%s%s",
718e3744 3822 ntohl (al->e[0].route_tag), "\n", "\n");
3823
3824 return 0;
3825}
075e12f5 3826#endif
718e3744 3827
3828/* Show AS-NSSA-LSA detail information. */
4dadc291 3829static int
718e3744 3830show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3831{
3832 if (lsa != NULL)
3833 {
3834 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3835
3836 show_ip_ospf_database_header (vty, lsa);
3837
3838 vty_out (vty, " Network Mask: /%d%s",
3839 ip_masklen (al->mask), VTY_NEWLINE);
3840 vty_out (vty, " Metric Type: %s%s",
3841 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3842 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3843 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3844 vty_out (vty, " Metric: %d%s",
3845 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3846 vty_out (vty, " NSSA: Forward Address: %s%s",
3847 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3848
3849 vty_out (vty, " External Route Tag: %u%s%s",
3850 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3851 }
3852
3853 return 0;
3854}
3855
4dadc291 3856static int
718e3744 3857show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3858{
3859 return 0;
3860}
3861
3862#ifdef HAVE_OPAQUE_LSA
4dadc291 3863static int
718e3744 3864show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3865{
3866 if (lsa != NULL)
3867 {
3868 show_ip_ospf_database_header (vty, lsa);
3869 show_opaque_info_detail (vty, lsa);
3870
3871 vty_out (vty, "%s", VTY_NEWLINE);
3872 }
3873 return 0;
3874}
3875#endif /* HAVE_OPAQUE_LSA */
3876
3877int (*show_function[])(struct vty *, struct ospf_lsa *) =
3878{
3879 NULL,
3880 show_router_lsa_detail,
3881 show_network_lsa_detail,
3882 show_summary_lsa_detail,
3883 show_summary_asbr_lsa_detail,
3884 show_as_external_lsa_detail,
718e3744 3885 show_func_dummy,
3886 show_as_nssa_lsa_detail, /* almost same as external */
718e3744 3887#ifdef HAVE_OPAQUE_LSA
718e3744 3888 NULL, /* type-8 */
3889 show_opaque_lsa_detail,
3890 show_opaque_lsa_detail,
3891 show_opaque_lsa_detail,
3892#endif /* HAVE_OPAQUE_LSA */
3893};
3894
4dadc291 3895static void
718e3744 3896show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3897 struct in_addr *adv_router)
3898{
3899 memset (lp, 0, sizeof (struct prefix_ls));
3900 lp->family = 0;
3901 if (id == NULL)
3902 lp->prefixlen = 0;
3903 else if (adv_router == NULL)
3904 {
3905 lp->prefixlen = 32;
3906 lp->id = *id;
3907 }
3908 else
3909 {
3910 lp->prefixlen = 64;
3911 lp->id = *id;
3912 lp->adv_router = *adv_router;
3913 }
3914}
3915
4dadc291 3916static void
718e3744 3917show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3918 struct in_addr *id, struct in_addr *adv_router)
3919{
3920 struct prefix_ls lp;
3921 struct route_node *rn, *start;
3922 struct ospf_lsa *lsa;
3923
3924 show_lsa_prefix_set (vty, &lp, id, adv_router);
3925 start = route_node_get (rt, (struct prefix *) &lp);
3926 if (start)
3927 {
3928 route_lock_node (start);
3929 for (rn = start; rn; rn = route_next_until (rn, start))
3930 if ((lsa = rn->info))
3931 {
718e3744 3932 if (show_function[lsa->data->type] != NULL)
3933 show_function[lsa->data->type] (vty, lsa);
3934 }
3935 route_unlock_node (start);
3936 }
3937}
3938
3939/* Show detail LSA information
3940 -- if id is NULL then show all LSAs. */
4dadc291 3941static void
020709f9 3942show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
718e3744 3943 struct in_addr *id, struct in_addr *adv_router)
3944{
52dc7ee6 3945 struct listnode *node;
1eb8ef25 3946 struct ospf_area *area;
3947
718e3744 3948 switch (type)
3949 {
3950 case OSPF_AS_EXTERNAL_LSA:
3951#ifdef HAVE_OPAQUE_LSA
3952 case OSPF_OPAQUE_AS_LSA:
3953#endif /* HAVE_OPAQUE_LSA */
3954 vty_out (vty, " %s %s%s",
3955 show_database_desc[type],
3956 VTY_NEWLINE, VTY_NEWLINE);
68980084 3957 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
718e3744 3958 break;
3959 default:
1eb8ef25 3960 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 3961 {
718e3744 3962 vty_out (vty, "%s %s (Area %s)%s%s",
3963 VTY_NEWLINE, show_database_desc[type],
3964 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
3965 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
3966 }
3967 break;
3968 }
3969}
3970
4dadc291 3971static void
718e3744 3972show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
3973 struct in_addr *adv_router)
3974{
3975 struct route_node *rn;
3976 struct ospf_lsa *lsa;
3977
3978 for (rn = route_top (rt); rn; rn = route_next (rn))
3979 if ((lsa = rn->info))
3980 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
3981 {
718e3744 3982 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
3983 continue;
718e3744 3984 if (show_function[lsa->data->type] != NULL)
3985 show_function[lsa->data->type] (vty, lsa);
3986 }
3987}
3988
3989/* Show detail LSA information. */
4dadc291 3990static void
020709f9 3991show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
718e3744 3992 struct in_addr *adv_router)
3993{
52dc7ee6 3994 struct listnode *node;
1eb8ef25 3995 struct ospf_area *area;
718e3744 3996
3997 switch (type)
3998 {
3999 case OSPF_AS_EXTERNAL_LSA:
4000#ifdef HAVE_OPAQUE_LSA
4001 case OSPF_OPAQUE_AS_LSA:
4002#endif /* HAVE_OPAQUE_LSA */
4003 vty_out (vty, " %s %s%s",
4004 show_database_desc[type],
4005 VTY_NEWLINE, VTY_NEWLINE);
68980084 4006 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
718e3744 4007 adv_router);
4008 break;
4009 default:
1eb8ef25 4010 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 4011 {
718e3744 4012 vty_out (vty, "%s %s (Area %s)%s%s",
4013 VTY_NEWLINE, show_database_desc[type],
4014 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
4015 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
4016 adv_router);
4017 }
4018 break;
4019 }
4020}
4021
4dadc291 4022static void
020709f9 4023show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
718e3744 4024{
020709f9 4025 struct ospf_lsa *lsa;
4026 struct route_node *rn;
1eb8ef25 4027 struct ospf_area *area;
52dc7ee6 4028 struct listnode *node;
718e3744 4029 int type;
4030
1eb8ef25 4031 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 4032 {
718e3744 4033 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4034 {
4035 switch (type)
4036 {
4037 case OSPF_AS_EXTERNAL_LSA:
4038#ifdef HAVE_OPAQUE_LSA
4039 case OSPF_OPAQUE_AS_LSA:
4040#endif /* HAVE_OPAQUE_LSA */
4041 continue;
4042 default:
4043 break;
4044 }
4045 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
4046 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
4047 {
4048 vty_out (vty, " %s (Area %s)%s%s",
4049 show_database_desc[type],
4050 ospf_area_desc_string (area),
4051 VTY_NEWLINE, VTY_NEWLINE);
4052 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
4053
020709f9 4054 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
4055 show_lsa_summary (vty, lsa, self);
718e3744 4056
4057 vty_out (vty, "%s", VTY_NEWLINE);
4058 }
4059 }
4060 }
4061
4062 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4063 {
4064 switch (type)
4065 {
4066 case OSPF_AS_EXTERNAL_LSA:
4067#ifdef HAVE_OPAQUE_LSA
4068 case OSPF_OPAQUE_AS_LSA:
4069#endif /* HAVE_OPAQUE_LSA */
e8e1946e 4070 break;
718e3744 4071 default:
4072 continue;
4073 }
68980084 4074 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4075 (!self && ospf_lsdb_count (ospf->lsdb, type)))
718e3744 4076 {
4077 vty_out (vty, " %s%s%s",
4078 show_database_desc[type],
4079 VTY_NEWLINE, VTY_NEWLINE);
4080 vty_out (vty, "%s%s", show_database_header[type],
4081 VTY_NEWLINE);
020709f9 4082
4083 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4084 show_lsa_summary (vty, lsa, self);
4085
718e3744 4086 vty_out (vty, "%s", VTY_NEWLINE);
4087 }
4088 }
4089
4090 vty_out (vty, "%s", VTY_NEWLINE);
4091}
4092
4dadc291 4093static void
020709f9 4094show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
718e3744 4095{
91e6a0e5 4096 struct route_node *rn;
718e3744 4097 struct ospf_lsa *lsa;
4098
4099 vty_out (vty, "%s MaxAge Link States:%s%s",
4100 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4101
91e6a0e5 4102 for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
1eb8ef25 4103 {
91e6a0e5
DD
4104 struct ospf_lsa *lsa;
4105
4106 if ((lsa = rn->info) != NULL)
4107 {
4108 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4109 vty_out (vty, "Link State ID: %s%s",
4110 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4111 vty_out (vty, "Advertising Router: %s%s",
4112 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4113 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4114 vty_out (vty, "%s", VTY_NEWLINE);
4115 }
1eb8ef25 4116 }
718e3744 4117}
4118
718e3744 4119#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4120#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
718e3744 4121
4122#ifdef HAVE_OPAQUE_LSA
4123#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4124#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4125#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4126#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4127#else /* HAVE_OPAQUE_LSA */
4128#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4129#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4130#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4131#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4132#endif /* HAVE_OPAQUE_LSA */
4133
4134#define OSPF_LSA_TYPES_CMD_STR \
4135 "asbr-summary|external|network|router|summary" \
4136 OSPF_LSA_TYPE_NSSA_CMD_STR \
4137 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4138
4139#define OSPF_LSA_TYPES_DESC \
4140 "ASBR summary link states\n" \
4141 "External link states\n" \
4142 "Network link states\n" \
4143 "Router link states\n" \
4144 "Network summary link states\n" \
4145 OSPF_LSA_TYPE_NSSA_DESC \
4146 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4147 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4148 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4149
4150DEFUN (show_ip_ospf_database,
4151 show_ip_ospf_database_cmd,
4152 "show ip ospf database",
4153 SHOW_STR
4154 IP_STR
4155 "OSPF information\n"
4156 "Database summary\n")
4157{
020709f9 4158 struct ospf *ospf;
718e3744 4159 int type, ret;
4160 struct in_addr id, adv_router;
4161
020709f9 4162 ospf = ospf_lookup ();
68980084 4163 if (ospf == NULL)
cac3b5c4
PJ
4164 {
4165 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4166 return CMD_SUCCESS;
4167 }
718e3744 4168
4169 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
68980084 4170 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
718e3744 4171
4172 /* Show all LSA. */
4173 if (argc == 0)
4174 {
020709f9 4175 show_ip_ospf_database_summary (vty, ospf, 0);
718e3744 4176 return CMD_SUCCESS;
4177 }
4178
4179 /* Set database type to show. */
4180 if (strncmp (argv[0], "r", 1) == 0)
4181 type = OSPF_ROUTER_LSA;
4182 else if (strncmp (argv[0], "ne", 2) == 0)
4183 type = OSPF_NETWORK_LSA;
718e3744 4184 else if (strncmp (argv[0], "ns", 2) == 0)
4185 type = OSPF_AS_NSSA_LSA;
718e3744 4186 else if (strncmp (argv[0], "su", 2) == 0)
4187 type = OSPF_SUMMARY_LSA;
4188 else if (strncmp (argv[0], "a", 1) == 0)
4189 type = OSPF_ASBR_SUMMARY_LSA;
4190 else if (strncmp (argv[0], "e", 1) == 0)
4191 type = OSPF_AS_EXTERNAL_LSA;
4192 else if (strncmp (argv[0], "se", 2) == 0)
4193 {
020709f9 4194 show_ip_ospf_database_summary (vty, ospf, 1);
718e3744 4195 return CMD_SUCCESS;
4196 }
4197 else if (strncmp (argv[0], "m", 1) == 0)
4198 {
020709f9 4199 show_ip_ospf_database_maxage (vty, ospf);
718e3744 4200 return CMD_SUCCESS;
4201 }
4202#ifdef HAVE_OPAQUE_LSA
4203 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4204 type = OSPF_OPAQUE_LINK_LSA;
4205 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4206 type = OSPF_OPAQUE_AREA_LSA;
4207 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4208 type = OSPF_OPAQUE_AS_LSA;
4209#endif /* HAVE_OPAQUE_LSA */
4210 else
4211 return CMD_WARNING;
4212
4213 /* `show ip ospf database LSA'. */
4214 if (argc == 1)
020709f9 4215 show_lsa_detail (vty, ospf, type, NULL, NULL);
718e3744 4216 else if (argc >= 2)
4217 {
4218 ret = inet_aton (argv[1], &id);
4219 if (!ret)
4220 return CMD_WARNING;
4221
4222 /* `show ip ospf database LSA ID'. */
4223 if (argc == 2)
020709f9 4224 show_lsa_detail (vty, ospf, type, &id, NULL);
718e3744 4225 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4226 else if (argc == 3)
4227 {
4228 if (strncmp (argv[2], "s", 1) == 0)
68980084 4229 adv_router = ospf->router_id;
718e3744 4230 else
4231 {
4232 ret = inet_aton (argv[2], &adv_router);
4233 if (!ret)
4234 return CMD_WARNING;
4235 }
020709f9 4236 show_lsa_detail (vty, ospf, type, &id, &adv_router);
718e3744 4237 }
4238 }
4239
4240 return CMD_SUCCESS;
4241}
4242
4243ALIAS (show_ip_ospf_database,
4244 show_ip_ospf_database_type_cmd,
4245 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4246 SHOW_STR
4247 IP_STR
4248 "OSPF information\n"
4249 "Database summary\n"
4250 OSPF_LSA_TYPES_DESC
4251 "LSAs in MaxAge list\n"
4252 "Self-originated link states\n")
4253
4254ALIAS (show_ip_ospf_database,
4255 show_ip_ospf_database_type_id_cmd,
4256 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4257 SHOW_STR
4258 IP_STR
4259 "OSPF information\n"
4260 "Database summary\n"
4261 OSPF_LSA_TYPES_DESC
4262 "Link State ID (as an IP address)\n")
4263
4264ALIAS (show_ip_ospf_database,
4265 show_ip_ospf_database_type_id_adv_router_cmd,
4266 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4267 SHOW_STR
4268 IP_STR
4269 "OSPF information\n"
4270 "Database summary\n"
4271 OSPF_LSA_TYPES_DESC
4272 "Link State ID (as an IP address)\n"
4273 "Advertising Router link states\n"
4274 "Advertising Router (as an IP address)\n")
4275
4276ALIAS (show_ip_ospf_database,
4277 show_ip_ospf_database_type_id_self_cmd,
4278 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4279 SHOW_STR
4280 IP_STR
4281 "OSPF information\n"
4282 "Database summary\n"
4283 OSPF_LSA_TYPES_DESC
4284 "Link State ID (as an IP address)\n"
4285 "Self-originated link states\n"
4286 "\n")
4287
4288DEFUN (show_ip_ospf_database_type_adv_router,
4289 show_ip_ospf_database_type_adv_router_cmd,
4290 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4291 SHOW_STR
4292 IP_STR
4293 "OSPF information\n"
4294 "Database summary\n"
4295 OSPF_LSA_TYPES_DESC
4296 "Advertising Router link states\n"
4297 "Advertising Router (as an IP address)\n")
4298{
020709f9 4299 struct ospf *ospf;
718e3744 4300 int type, ret;
4301 struct in_addr adv_router;
4302
020709f9 4303 ospf = ospf_lookup ();
68980084 4304 if (ospf == NULL)
cac3b5c4
PJ
4305 {
4306 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4307 return CMD_SUCCESS;
4308 }
718e3744 4309
4310 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
68980084 4311 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
718e3744 4312
4313 if (argc != 2)
4314 return CMD_WARNING;
4315
4316 /* Set database type to show. */
4317 if (strncmp (argv[0], "r", 1) == 0)
4318 type = OSPF_ROUTER_LSA;
4319 else if (strncmp (argv[0], "ne", 2) == 0)
4320 type = OSPF_NETWORK_LSA;
718e3744 4321 else if (strncmp (argv[0], "ns", 2) == 0)
4322 type = OSPF_AS_NSSA_LSA;
718e3744 4323 else if (strncmp (argv[0], "s", 1) == 0)
4324 type = OSPF_SUMMARY_LSA;
4325 else if (strncmp (argv[0], "a", 1) == 0)
4326 type = OSPF_ASBR_SUMMARY_LSA;
4327 else if (strncmp (argv[0], "e", 1) == 0)
4328 type = OSPF_AS_EXTERNAL_LSA;
4329#ifdef HAVE_OPAQUE_LSA
4330 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4331 type = OSPF_OPAQUE_LINK_LSA;
4332 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4333 type = OSPF_OPAQUE_AREA_LSA;
4334 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4335 type = OSPF_OPAQUE_AS_LSA;
4336#endif /* HAVE_OPAQUE_LSA */
4337 else
4338 return CMD_WARNING;
4339
4340 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4341 if (strncmp (argv[1], "s", 1) == 0)
68980084 4342 adv_router = ospf->router_id;
718e3744 4343 else
4344 {
4345 ret = inet_aton (argv[1], &adv_router);
4346 if (!ret)
4347 return CMD_WARNING;
4348 }
4349
020709f9 4350 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
718e3744 4351
4352 return CMD_SUCCESS;
4353}
4354
4355ALIAS (show_ip_ospf_database_type_adv_router,
4356 show_ip_ospf_database_type_self_cmd,
4357 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4358 SHOW_STR
4359 IP_STR
4360 "OSPF information\n"
4361 "Database summary\n"
4362 OSPF_LSA_TYPES_DESC
4363 "Self-originated link states\n")
4364
6b0655a2 4365
718e3744 4366DEFUN (ip_ospf_authentication_args,
4367 ip_ospf_authentication_args_addr_cmd,
4368 "ip ospf authentication (null|message-digest) A.B.C.D",
4369 "IP Information\n"
4370 "OSPF interface commands\n"
4371 "Enable authentication on this interface\n"
4372 "Use null authentication\n"
4373 "Use message-digest authentication\n"
4374 "Address of interface")
4375{
4376 struct interface *ifp;
4377 struct in_addr addr;
4378 int ret;
4379 struct ospf_if_params *params;
4380
4381 ifp = vty->index;
4382 params = IF_DEF_PARAMS (ifp);
4383
4384 if (argc == 2)
4385 {
4386 ret = inet_aton(argv[1], &addr);
4387 if (!ret)
4388 {
4389 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4390 VTY_NEWLINE);
4391 return CMD_WARNING;
4392 }
4393
4394 params = ospf_get_if_params (ifp, addr);
4395 ospf_if_update_params (ifp, addr);
4396 }
4397
4398 /* Handle null authentication */
4399 if ( argv[0][0] == 'n' )
4400 {
4401 SET_IF_PARAM (params, auth_type);
4402 params->auth_type = OSPF_AUTH_NULL;
4403 return CMD_SUCCESS;
4404 }
4405
4406 /* Handle message-digest authentication */
4407 if ( argv[0][0] == 'm' )
4408 {
4409 SET_IF_PARAM (params, auth_type);
4410 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4411 return CMD_SUCCESS;
4412 }
4413
4414 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4415 return CMD_WARNING;
4416}
4417
4418ALIAS (ip_ospf_authentication_args,
4419 ip_ospf_authentication_args_cmd,
4420 "ip ospf authentication (null|message-digest)",
4421 "IP Information\n"
4422 "OSPF interface commands\n"
4423 "Enable authentication on this interface\n"
4424 "Use null authentication\n"
4425 "Use message-digest authentication\n")
4426
4427DEFUN (ip_ospf_authentication,
4428 ip_ospf_authentication_addr_cmd,
4429 "ip ospf authentication A.B.C.D",
4430 "IP Information\n"
4431 "OSPF interface commands\n"
4432 "Enable authentication on this interface\n"
4433 "Address of interface")
4434{
4435 struct interface *ifp;
4436 struct in_addr addr;
4437 int ret;
4438 struct ospf_if_params *params;
4439
4440 ifp = vty->index;
4441 params = IF_DEF_PARAMS (ifp);
4442
4443 if (argc == 1)
4444 {
5dcf71df 4445 ret = inet_aton(argv[0], &addr);
718e3744 4446 if (!ret)
4447 {
4448 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4449 VTY_NEWLINE);
4450 return CMD_WARNING;
4451 }
4452
4453 params = ospf_get_if_params (ifp, addr);
4454 ospf_if_update_params (ifp, addr);
4455 }
4456
4457 SET_IF_PARAM (params, auth_type);
4458 params->auth_type = OSPF_AUTH_SIMPLE;
4459
4460 return CMD_SUCCESS;
4461}
4462
4463ALIAS (ip_ospf_authentication,
4464 ip_ospf_authentication_cmd,
4465 "ip ospf authentication",
4466 "IP Information\n"
4467 "OSPF interface commands\n"
4468 "Enable authentication on this interface\n")
4469
4470DEFUN (no_ip_ospf_authentication,
4471 no_ip_ospf_authentication_addr_cmd,
4472 "no ip ospf authentication A.B.C.D",
4473 NO_STR
4474 "IP Information\n"
4475 "OSPF interface commands\n"
4476 "Enable authentication on this interface\n"
4477 "Address of interface")
4478{
4479 struct interface *ifp;
4480 struct in_addr addr;
4481 int ret;
4482 struct ospf_if_params *params;
4483
4484 ifp = vty->index;
4485 params = IF_DEF_PARAMS (ifp);
4486
4487 if (argc == 1)
4488 {
5dcf71df 4489 ret = inet_aton(argv[0], &addr);
718e3744 4490 if (!ret)
4491 {
4492 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4493 VTY_NEWLINE);
4494 return CMD_WARNING;
4495 }
4496
4497 params = ospf_lookup_if_params (ifp, addr);
4498 if (params == NULL)
4499 return CMD_SUCCESS;
4500 }
4501
4502 params->auth_type = OSPF_AUTH_NOTSET;
4503 UNSET_IF_PARAM (params, auth_type);
4504
4505 if (params != IF_DEF_PARAMS (ifp))
4506 {
4507 ospf_free_if_params (ifp, addr);
4508 ospf_if_update_params (ifp, addr);
4509 }
4510
4511 return CMD_SUCCESS;
4512}
4513
4514ALIAS (no_ip_ospf_authentication,
4515 no_ip_ospf_authentication_cmd,
4516 "no ip ospf authentication",
4517 NO_STR
4518 "IP Information\n"
4519 "OSPF interface commands\n"
4520 "Enable authentication on this interface\n")
4521
4522DEFUN (ip_ospf_authentication_key,
4523 ip_ospf_authentication_key_addr_cmd,
4524 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4525 "IP Information\n"
4526 "OSPF interface commands\n"
4527 "Authentication password (key)\n"
4528 "The OSPF password (key)\n"
4529 "Address of interface")
4530{
4531 struct interface *ifp;
4532 struct in_addr addr;
4533 int ret;
4534 struct ospf_if_params *params;
4535
4536 ifp = vty->index;
4537 params = IF_DEF_PARAMS (ifp);
4538
4539 if (argc == 2)
4540 {
4541 ret = inet_aton(argv[1], &addr);
4542 if (!ret)
4543 {
4544 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4545 VTY_NEWLINE);
4546 return CMD_WARNING;
4547 }
4548
4549 params = ospf_get_if_params (ifp, addr);
4550 ospf_if_update_params (ifp, addr);
4551 }
4552
4553
4554 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
c9e52be3 4555 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
718e3744 4556 SET_IF_PARAM (params, auth_simple);
4557
4558 return CMD_SUCCESS;
4559}
4560
4561ALIAS (ip_ospf_authentication_key,
4562 ip_ospf_authentication_key_cmd,
4563 "ip ospf authentication-key AUTH_KEY",
4564 "IP Information\n"
4565 "OSPF interface commands\n"
4566 "Authentication password (key)\n"
4567 "The OSPF password (key)")
4568
4569ALIAS (ip_ospf_authentication_key,
4570 ospf_authentication_key_cmd,
4571 "ospf authentication-key AUTH_KEY",
4572 "OSPF interface commands\n"
4573 "Authentication password (key)\n"
4574 "The OSPF password (key)")
4575
4576DEFUN (no_ip_ospf_authentication_key,
4577 no_ip_ospf_authentication_key_addr_cmd,
4578 "no ip ospf authentication-key A.B.C.D",
4579 NO_STR
4580 "IP Information\n"
4581 "OSPF interface commands\n"
4582 "Authentication password (key)\n"
4583 "Address of interface")
4584{
4585 struct interface *ifp;
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
5dcf71df 4593 if (argc == 1)
718e3744 4594 {
5dcf71df 4595 ret = inet_aton(argv[0], &addr);
718e3744 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_lookup_if_params (ifp, addr);
4604 if (params == NULL)
4605 return CMD_SUCCESS;
4606 }
4607
4608 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4609 UNSET_IF_PARAM (params, auth_simple);
4610
4611 if (params != IF_DEF_PARAMS (ifp))
4612 {
4613 ospf_free_if_params (ifp, addr);
4614 ospf_if_update_params (ifp, addr);
4615 }
4616
4617 return CMD_SUCCESS;
4618}
4619
4620ALIAS (no_ip_ospf_authentication_key,
4621 no_ip_ospf_authentication_key_cmd,
4622 "no ip ospf authentication-key",
4623 NO_STR
4624 "IP Information\n"
4625 "OSPF interface commands\n"
4626 "Authentication password (key)\n")
4627
4628ALIAS (no_ip_ospf_authentication_key,
4629 no_ospf_authentication_key_cmd,
4630 "no ospf authentication-key",
4631 NO_STR
4632 "OSPF interface commands\n"
4633 "Authentication password (key)\n")
4634
4635DEFUN (ip_ospf_message_digest_key,
4636 ip_ospf_message_digest_key_addr_cmd,
4637 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4638 "IP Information\n"
4639 "OSPF interface commands\n"
4640 "Message digest authentication password (key)\n"
4641 "Key ID\n"
4642 "Use MD5 algorithm\n"
4643 "The OSPF password (key)"
4644 "Address of interface")
4645{
4646 struct interface *ifp;
4647 struct crypt_key *ck;
4648 u_char key_id;
4649 struct in_addr addr;
4650 int ret;
4651 struct ospf_if_params *params;
4652
4653 ifp = vty->index;
4654 params = IF_DEF_PARAMS (ifp);
4655
4656 if (argc == 3)
4657 {
4658 ret = inet_aton(argv[2], &addr);
4659 if (!ret)
4660 {
4661 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4662 VTY_NEWLINE);
4663 return CMD_WARNING;
4664 }
4665
4666 params = ospf_get_if_params (ifp, addr);
4667 ospf_if_update_params (ifp, addr);
4668 }
4669
4670 key_id = strtol (argv[0], NULL, 10);
4671 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4672 {
4673 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4674 return CMD_WARNING;
4675 }
4676
4677 ck = ospf_crypt_key_new ();
4678 ck->key_id = (u_char) key_id;
4679 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
c9e52be3 4680 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
718e3744 4681
4682 ospf_crypt_key_add (params->auth_crypt, ck);
4683 SET_IF_PARAM (params, auth_crypt);
4684
4685 return CMD_SUCCESS;
4686}
4687
4688ALIAS (ip_ospf_message_digest_key,
4689 ip_ospf_message_digest_key_cmd,
4690 "ip ospf message-digest-key <1-255> md5 KEY",
4691 "IP Information\n"
4692 "OSPF interface commands\n"
4693 "Message digest authentication password (key)\n"
4694 "Key ID\n"
4695 "Use MD5 algorithm\n"
4696 "The OSPF password (key)")
4697
4698ALIAS (ip_ospf_message_digest_key,
4699 ospf_message_digest_key_cmd,
4700 "ospf message-digest-key <1-255> md5 KEY",
4701 "OSPF interface commands\n"
4702 "Message digest authentication password (key)\n"
4703 "Key ID\n"
4704 "Use MD5 algorithm\n"
4705 "The OSPF password (key)")
4706
4707DEFUN (no_ip_ospf_message_digest_key,
4708 no_ip_ospf_message_digest_key_addr_cmd,
4709 "no ip ospf message-digest-key <1-255> A.B.C.D",
4710 NO_STR
4711 "IP Information\n"
4712 "OSPF interface commands\n"
4713 "Message digest authentication password (key)\n"
4714 "Key ID\n"
4715 "Address of interface")
4716{
4717 struct interface *ifp;
4718 struct crypt_key *ck;
4719 int key_id;
4720 struct in_addr addr;
4721 int ret;
4722 struct ospf_if_params *params;
4723
4724 ifp = vty->index;
4725 params = IF_DEF_PARAMS (ifp);
4726
4727 if (argc == 2)
4728 {
4729 ret = inet_aton(argv[1], &addr);
4730 if (!ret)
4731 {
4732 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4733 VTY_NEWLINE);
4734 return CMD_WARNING;
4735 }
4736
4737 params = ospf_lookup_if_params (ifp, addr);
4738 if (params == NULL)
4739 return CMD_SUCCESS;
4740 }
4741
4742 key_id = strtol (argv[0], NULL, 10);
4743 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4744 if (ck == NULL)
4745 {
4746 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4747 return CMD_WARNING;
4748 }
4749
4750 ospf_crypt_key_delete (params->auth_crypt, key_id);
4751
4752 if (params != IF_DEF_PARAMS (ifp))
4753 {
4754 ospf_free_if_params (ifp, addr);
4755 ospf_if_update_params (ifp, addr);
4756 }
4757
4758 return CMD_SUCCESS;
4759}
4760
4761ALIAS (no_ip_ospf_message_digest_key,
4762 no_ip_ospf_message_digest_key_cmd,
4763 "no ip ospf message-digest-key <1-255>",
4764 NO_STR
4765 "IP Information\n"
4766 "OSPF interface commands\n"
4767 "Message digest authentication password (key)\n"
4768 "Key ID\n")
4769
4770ALIAS (no_ip_ospf_message_digest_key,
4771 no_ospf_message_digest_key_cmd,
4772 "no ospf message-digest-key <1-255>",
4773 NO_STR
4774 "OSPF interface commands\n"
4775 "Message digest authentication password (key)\n"
4776 "Key ID\n")
4777
4778DEFUN (ip_ospf_cost,
9eff36b3 4779 ip_ospf_cost_u32_inet4_cmd,
718e3744 4780 "ip ospf cost <1-65535> A.B.C.D",
4781 "IP Information\n"
4782 "OSPF interface commands\n"
4783 "Interface cost\n"
4784 "Cost\n"
4785 "Address of interface")
4786{
4787 struct interface *ifp = vty->index;
4788 u_int32_t cost;
4789 struct in_addr addr;
4790 int ret;
4791 struct ospf_if_params *params;
4792
4793 params = IF_DEF_PARAMS (ifp);
4794
4795 cost = strtol (argv[0], NULL, 10);
4796
4797 /* cost range is <1-65535>. */
4798 if (cost < 1 || cost > 65535)
4799 {
4800 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4801 return CMD_WARNING;
4802 }
4803
4804 if (argc == 2)
4805 {
4806 ret = inet_aton(argv[1], &addr);
4807 if (!ret)
4808 {
4809 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4810 VTY_NEWLINE);
4811 return CMD_WARNING;
4812 }
4813
4814 params = ospf_get_if_params (ifp, addr);
4815 ospf_if_update_params (ifp, addr);
4816 }
4817
4818 SET_IF_PARAM (params, output_cost_cmd);
4819 params->output_cost_cmd = cost;
4820
4821 ospf_if_recalculate_output_cost (ifp);
4822
4823 return CMD_SUCCESS;
4824}
4825
4826ALIAS (ip_ospf_cost,
9eff36b3 4827 ip_ospf_cost_u32_cmd,
718e3744 4828 "ip ospf cost <1-65535>",
4829 "IP Information\n"
4830 "OSPF interface commands\n"
4831 "Interface cost\n"
4832 "Cost")
4833
4834ALIAS (ip_ospf_cost,
9eff36b3 4835 ospf_cost_u32_cmd,
718e3744 4836 "ospf cost <1-65535>",
4837 "OSPF interface commands\n"
4838 "Interface cost\n"
4839 "Cost")
4840
9eff36b3
DO
4841ALIAS (ip_ospf_cost,
4842 ospf_cost_u32_inet4_cmd,
4843 "ospf cost <1-65535> A.B.C.D",
4844 "OSPF interface commands\n"
4845 "Interface cost\n"
4846 "Cost\n"
4847 "Address of interface")
4848
718e3744 4849DEFUN (no_ip_ospf_cost,
9eff36b3 4850 no_ip_ospf_cost_inet4_cmd,
718e3744 4851 "no ip ospf cost A.B.C.D",
4852 NO_STR
4853 "IP Information\n"
4854 "OSPF interface commands\n"
4855 "Interface cost\n"
4856 "Address of interface")
4857{
4858 struct interface *ifp = vty->index;
4859 struct in_addr addr;
4860 int ret;
4861 struct ospf_if_params *params;
4862
4863 ifp = vty->index;
4864 params = IF_DEF_PARAMS (ifp);
4865
4866 if (argc == 1)
4867 {
4868 ret = inet_aton(argv[0], &addr);
4869 if (!ret)
4870 {
4871 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4872 VTY_NEWLINE);
4873 return CMD_WARNING;
4874 }
4875
4876 params = ospf_lookup_if_params (ifp, addr);
4877 if (params == NULL)
4878 return CMD_SUCCESS;
4879 }
4880
4881 UNSET_IF_PARAM (params, output_cost_cmd);
4882
4883 if (params != IF_DEF_PARAMS (ifp))
4884 {
4885 ospf_free_if_params (ifp, addr);
4886 ospf_if_update_params (ifp, addr);
4887 }
4888
4889 ospf_if_recalculate_output_cost (ifp);
4890
4891 return CMD_SUCCESS;
4892}
4893
4894ALIAS (no_ip_ospf_cost,
4895 no_ip_ospf_cost_cmd,
4896 "no ip ospf cost",
4897 NO_STR
4898 "IP Information\n"
4899 "OSPF interface commands\n"
4900 "Interface cost\n")
4901
4902ALIAS (no_ip_ospf_cost,
4903 no_ospf_cost_cmd,
4904 "no ospf cost",
4905 NO_STR
4906 "OSPF interface commands\n"
4907 "Interface cost\n")
4908
9eff36b3
DO
4909ALIAS (no_ip_ospf_cost,
4910 no_ospf_cost_inet4_cmd,
4911 "no ospf cost A.B.C.D",
4912 NO_STR
4913 "OSPF interface commands\n"
4914 "Interface cost\n"
4915 "Address of interface")
4916
827341b7
DO
4917DEFUN (no_ip_ospf_cost2,
4918 no_ip_ospf_cost_u32_cmd,
4919 "no ip ospf cost <1-65535>",
4920 NO_STR
4921 "IP Information\n"
4922 "OSPF interface commands\n"
4923 "Interface cost\n"
4924 "Cost")
4925{
4926 struct interface *ifp = vty->index;
4927 struct in_addr addr;
4928 u_int32_t cost;
4929 int ret;
4930 struct ospf_if_params *params;
4931
4932 ifp = vty->index;
4933 params = IF_DEF_PARAMS (ifp);
4934
4935 /* According to the semantics we are mimicking "no ip ospf cost N" is
4936 * always treated as "no ip ospf cost" regardless of the actual value
4937 * of N already configured for the interface. Thus the first argument
4938 * is always checked to be a number, but is ignored after that.
4939 */
4940 cost = strtol (argv[0], NULL, 10);
4941 if (cost < 1 || cost > 65535)
4942 {
4943 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4944 return CMD_WARNING;
4945 }
4946
4947 if (argc == 2)
4948 {
4949 ret = inet_aton(argv[1], &addr);
4950 if (!ret)
4951 {
4952 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4953 VTY_NEWLINE);
4954 return CMD_WARNING;
4955 }
4956
4957 params = ospf_lookup_if_params (ifp, addr);
4958 if (params == NULL)
4959 return CMD_SUCCESS;
4960 }
4961
4962 UNSET_IF_PARAM (params, output_cost_cmd);
4963
4964 if (params != IF_DEF_PARAMS (ifp))
4965 {
4966 ospf_free_if_params (ifp, addr);
4967 ospf_if_update_params (ifp, addr);
4968 }
4969
4970 ospf_if_recalculate_output_cost (ifp);
4971
4972 return CMD_SUCCESS;
4973}
4974
4975ALIAS (no_ip_ospf_cost2,
4976 no_ospf_cost_u32_cmd,
4977 "no ospf cost <1-65535>",
4978 NO_STR
4979 "OSPF interface commands\n"
4980 "Interface cost\n"
4981 "Cost")
4982
4983ALIAS (no_ip_ospf_cost2,
4984 no_ip_ospf_cost_u32_inet4_cmd,
4985 "no ip ospf cost <1-65535> A.B.C.D",
4986 NO_STR
4987 "IP Information\n"
4988 "OSPF interface commands\n"
4989 "Interface cost\n"
4990 "Cost\n"
4991 "Address of interface")
4992
4993ALIAS (no_ip_ospf_cost2,
4994 no_ospf_cost_u32_inet4_cmd,
4995 "no ospf cost <1-65535> A.B.C.D",
4996 NO_STR
4997 "OSPF interface commands\n"
4998 "Interface cost\n"
4999 "Cost\n"
5000 "Address of interface")
9eff36b3 5001
4dadc291 5002static void
718e3744 5003ospf_nbr_timer_update (struct ospf_interface *oi)
5004{
5005 struct route_node *rn;
5006 struct ospf_neighbor *nbr;
5007
5008 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
5009 if ((nbr = rn->info))
5010 {
5011 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
5012 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
5013 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
5014 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
5015 }
5016}
5017
f9ad937f 5018static int
5019ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
5020 const char *nbr_str,
5021 const char *fast_hello_str)
718e3744 5022{
5023 struct interface *ifp = vty->index;
5024 u_int32_t seconds;
f9ad937f 5025 u_char hellomult;
718e3744 5026 struct in_addr addr;
5027 int ret;
5028 struct ospf_if_params *params;
5029 struct ospf_interface *oi;
5030 struct route_node *rn;
5031
5032 params = IF_DEF_PARAMS (ifp);
f9ad937f 5033
5034 if (nbr_str)
718e3744 5035 {
f9ad937f 5036 ret = inet_aton(nbr_str, &addr);
718e3744 5037 if (!ret)
5038 {
5039 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5040 VTY_NEWLINE);
5041 return CMD_WARNING;
5042 }
5043
5044 params = ospf_get_if_params (ifp, addr);
5045 ospf_if_update_params (ifp, addr);
5046 }
5047
f9ad937f 5048 if (interval_str)
5049 {
5050 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
5051 1, 65535);
5052
5053 /* reset fast_hello too, just to be sure */
5054 UNSET_IF_PARAM (params, fast_hello);
5055 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5056 }
5057 else if (fast_hello_str)
5058 {
5059 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
5060 1, 10);
5061 /* 1s dead-interval with sub-second hellos desired */
5062 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
5063 SET_IF_PARAM (params, fast_hello);
5064 params->fast_hello = hellomult;
5065 }
5066 else
5067 {
5068 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5069 VTY_NEWLINE);
5070 return CMD_WARNING;
5071 }
5072
718e3744 5073 SET_IF_PARAM (params, v_wait);
5074 params->v_wait = seconds;
5075
5076 /* Update timer values in neighbor structure. */
f9ad937f 5077 if (nbr_str)
718e3744 5078 {
cac3b5c4
PJ
5079 struct ospf *ospf;
5080 if ((ospf = ospf_lookup()))
68980084 5081 {
5082 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5083 if (oi)
5084 ospf_nbr_timer_update (oi);
5085 }
718e3744 5086 }
5087 else
5088 {
5089 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5090 if ((oi = rn->info))
5091 ospf_nbr_timer_update (oi);
5092 }
5093
5094 return CMD_SUCCESS;
5095}
5096
f9ad937f 5097
5098DEFUN (ip_ospf_dead_interval,
5099 ip_ospf_dead_interval_addr_cmd,
5100 "ip ospf dead-interval <1-65535> A.B.C.D",
5101 "IP Information\n"
5102 "OSPF interface commands\n"
5103 "Interval after which a neighbor is declared dead\n"
5104 "Seconds\n"
5105 "Address of interface\n")
5106{
5107 if (argc == 2)
5108 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5109 else
5110 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5111}
5112
718e3744 5113ALIAS (ip_ospf_dead_interval,
5114 ip_ospf_dead_interval_cmd,
5115 "ip ospf dead-interval <1-65535>",
5116 "IP Information\n"
5117 "OSPF interface commands\n"
5118 "Interval after which a neighbor is declared dead\n"
5119 "Seconds\n")
5120
5121ALIAS (ip_ospf_dead_interval,
5122 ospf_dead_interval_cmd,
5123 "ospf dead-interval <1-65535>",
5124 "OSPF interface commands\n"
5125 "Interval after which a neighbor is declared dead\n"
5126 "Seconds\n")
5127
f9ad937f 5128DEFUN (ip_ospf_dead_interval_minimal,
5129 ip_ospf_dead_interval_minimal_addr_cmd,
5130 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5131 "IP Information\n"
5132 "OSPF interface commands\n"
5133 "Interval after which a neighbor is declared dead\n"
5134 "Minimal 1s dead-interval with fast sub-second hellos\n"
5135 "Hello multiplier factor\n"
5136 "Number of Hellos to send each second\n"
5137 "Address of interface\n")
5138{
5139 if (argc == 2)
5140 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5141 else
5142 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5143}
5144
5145ALIAS (ip_ospf_dead_interval_minimal,
5146 ip_ospf_dead_interval_minimal_cmd,
5147 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5148 "IP Information\n"
5149 "OSPF interface commands\n"
5150 "Interval after which a neighbor is declared dead\n"
5151 "Minimal 1s dead-interval with fast sub-second hellos\n"
5152 "Hello multiplier factor\n"
5153 "Number of Hellos to send each second\n")
5154
718e3744 5155DEFUN (no_ip_ospf_dead_interval,
5156 no_ip_ospf_dead_interval_addr_cmd,
5157 "no ip ospf dead-interval A.B.C.D",
5158 NO_STR
5159 "IP Information\n"
5160 "OSPF interface commands\n"
5161 "Interval after which a neighbor is declared dead\n"
5162 "Address of interface")
5163{
5164 struct interface *ifp = vty->index;
5165 struct in_addr addr;
5166 int ret;
5167 struct ospf_if_params *params;
5168 struct ospf_interface *oi;
5169 struct route_node *rn;
020709f9 5170
718e3744 5171 ifp = vty->index;
5172 params = IF_DEF_PARAMS (ifp);
5173
5174 if (argc == 1)
5175 {
5176 ret = inet_aton(argv[0], &addr);
5177 if (!ret)
5178 {
5179 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5180 VTY_NEWLINE);
5181 return CMD_WARNING;
5182 }
5183
5184 params = ospf_lookup_if_params (ifp, addr);
5185 if (params == NULL)
5186 return CMD_SUCCESS;
5187 }
5188
5189 UNSET_IF_PARAM (params, v_wait);
5190 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
f9ad937f 5191
5192 UNSET_IF_PARAM (params, fast_hello);
5193 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5194
718e3744 5195 if (params != IF_DEF_PARAMS (ifp))
5196 {
5197 ospf_free_if_params (ifp, addr);
5198 ospf_if_update_params (ifp, addr);
5199 }
5200
5201 /* Update timer values in neighbor structure. */
5202 if (argc == 1)
5203 {
cac3b5c4
PJ
5204 struct ospf *ospf;
5205
5206 if ((ospf = ospf_lookup()))
68980084 5207 {
5208 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5209 if (oi)
5210 ospf_nbr_timer_update (oi);
5211 }
718e3744 5212 }
5213 else
5214 {
5215 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5216 if ((oi = rn->info))
5217 ospf_nbr_timer_update (oi);
5218 }
5219
5220 return CMD_SUCCESS;
5221}
5222
5223ALIAS (no_ip_ospf_dead_interval,
5224 no_ip_ospf_dead_interval_cmd,
5225 "no ip ospf dead-interval",
5226 NO_STR
5227 "IP Information\n"
5228 "OSPF interface commands\n"
5229 "Interval after which a neighbor is declared dead\n")
5230
5231ALIAS (no_ip_ospf_dead_interval,
5232 no_ospf_dead_interval_cmd,
5233 "no ospf dead-interval",
5234 NO_STR
5235 "OSPF interface commands\n"
5236 "Interval after which a neighbor is declared dead\n")
5237
5238DEFUN (ip_ospf_hello_interval,
5239 ip_ospf_hello_interval_addr_cmd,
5240 "ip ospf hello-interval <1-65535> A.B.C.D",
5241 "IP Information\n"
5242 "OSPF interface commands\n"
5243 "Time between HELLO packets\n"
5244 "Seconds\n"
5245 "Address of interface")
5246{
5247 struct interface *ifp = vty->index;
5248 u_int32_t seconds;
5249 struct in_addr addr;
5250 int ret;
5251 struct ospf_if_params *params;
5252
5253 params = IF_DEF_PARAMS (ifp);
5254
5255 seconds = strtol (argv[0], NULL, 10);
5256
5257 /* HelloInterval range is <1-65535>. */
5258 if (seconds < 1 || seconds > 65535)
5259 {
5260 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5261 return CMD_WARNING;
5262 }
5263
5264 if (argc == 2)
5265 {
5266 ret = inet_aton(argv[1], &addr);
5267 if (!ret)
5268 {
5269 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5270 VTY_NEWLINE);
5271 return CMD_WARNING;
5272 }
5273
5274 params = ospf_get_if_params (ifp, addr);
5275 ospf_if_update_params (ifp, addr);
5276 }
5277
f9ad937f 5278 SET_IF_PARAM (params, v_hello);
718e3744 5279 params->v_hello = seconds;
5280
5281 return CMD_SUCCESS;
5282}
5283
5284ALIAS (ip_ospf_hello_interval,
5285 ip_ospf_hello_interval_cmd,
5286 "ip ospf hello-interval <1-65535>",
5287 "IP Information\n"
5288 "OSPF interface commands\n"
5289 "Time between HELLO packets\n"
5290 "Seconds\n")
5291
5292ALIAS (ip_ospf_hello_interval,
5293 ospf_hello_interval_cmd,
5294 "ospf hello-interval <1-65535>",
5295 "OSPF interface commands\n"
5296 "Time between HELLO packets\n"
5297 "Seconds\n")
5298
5299DEFUN (no_ip_ospf_hello_interval,
5300 no_ip_ospf_hello_interval_addr_cmd,
5301 "no ip ospf hello-interval A.B.C.D",
5302 NO_STR
5303 "IP Information\n"
5304 "OSPF interface commands\n"
5305 "Time between HELLO packets\n"
5306 "Address of interface")
5307{
5308 struct interface *ifp = vty->index;
5309 struct in_addr addr;
5310 int ret;
5311 struct ospf_if_params *params;
5312
5313 ifp = vty->index;
5314 params = IF_DEF_PARAMS (ifp);
5315
5316 if (argc == 1)
5317 {
5318 ret = inet_aton(argv[0], &addr);
5319 if (!ret)
5320 {
5321 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5322 VTY_NEWLINE);
5323 return CMD_WARNING;
5324 }
5325
5326 params = ospf_lookup_if_params (ifp, addr);
5327 if (params == NULL)
5328 return CMD_SUCCESS;
5329 }
5330
5331 UNSET_IF_PARAM (params, v_hello);
f9ad937f 5332 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
718e3744 5333
5334 if (params != IF_DEF_PARAMS (ifp))
5335 {
5336 ospf_free_if_params (ifp, addr);
5337 ospf_if_update_params (ifp, addr);
5338 }
5339
5340 return CMD_SUCCESS;
5341}
5342
5343ALIAS (no_ip_ospf_hello_interval,
5344 no_ip_ospf_hello_interval_cmd,
5345 "no ip ospf hello-interval",
5346 NO_STR
5347 "IP Information\n"
5348 "OSPF interface commands\n"
5349 "Time between HELLO packets\n")
5350
5351ALIAS (no_ip_ospf_hello_interval,
5352 no_ospf_hello_interval_cmd,
5353 "no ospf hello-interval",
5354 NO_STR
5355 "OSPF interface commands\n"
5356 "Time between HELLO packets\n")
5357
5358DEFUN (ip_ospf_network,
5359 ip_ospf_network_cmd,
5360 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5361 "IP Information\n"
5362 "OSPF interface commands\n"
5363 "Network type\n"
5364 "Specify OSPF broadcast multi-access network\n"
5365 "Specify OSPF NBMA network\n"
5366 "Specify OSPF point-to-multipoint network\n"
5367 "Specify OSPF point-to-point network\n")
5368{
5369 struct interface *ifp = vty->index;
5370 int old_type = IF_DEF_PARAMS (ifp)->type;
5371 struct route_node *rn;
4b4bda9b
CF
5372
5373 if (old_type == OSPF_IFTYPE_LOOPBACK)
5374 {
5375 vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE);
5376 return CMD_WARNING;
5377 }
5378
718e3744 5379 if (strncmp (argv[0], "b", 1) == 0)
5380 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5381 else if (strncmp (argv[0], "n", 1) == 0)
5382 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5383 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5384 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5385 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5386 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5387
5388 if (IF_DEF_PARAMS (ifp)->type == old_type)
5389 return CMD_SUCCESS;
5390
5391 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5392
5393 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5394 {
5395 struct ospf_interface *oi = rn->info;
5396
5397 if (!oi)
5398 continue;
5399
5400 oi->type = IF_DEF_PARAMS (ifp)->type;
5401
5402 if (oi->state > ISM_Down)
5403 {
5404 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5405 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5406 }
5407 }
5408
5409 return CMD_SUCCESS;
5410}
5411
5412ALIAS (ip_ospf_network,
5413 ospf_network_cmd,
5414 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5415 "OSPF interface commands\n"
5416 "Network type\n"
5417 "Specify OSPF broadcast multi-access network\n"
5418 "Specify OSPF NBMA network\n"
5419 "Specify OSPF point-to-multipoint network\n"
5420 "Specify OSPF point-to-point network\n")
5421
5422DEFUN (no_ip_ospf_network,
5423 no_ip_ospf_network_cmd,
5424 "no ip ospf network",
5425 NO_STR
5426 "IP Information\n"
5427 "OSPF interface commands\n"
5428 "Network type\n")
5429{
5430 struct interface *ifp = vty->index;
5431 int old_type = IF_DEF_PARAMS (ifp)->type;
5432 struct route_node *rn;
5433
bc18d616 5434 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
718e3744 5435
5436 if (IF_DEF_PARAMS (ifp)->type == old_type)
5437 return CMD_SUCCESS;
5438
5439 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5440 {
5441 struct ospf_interface *oi = rn->info;
5442
5443 if (!oi)
5444 continue;
5445
5446 oi->type = IF_DEF_PARAMS (ifp)->type;
5447
5448 if (oi->state > ISM_Down)
5449 {
5450 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5451 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5452 }
5453 }
5454
5455 return CMD_SUCCESS;
5456}
5457
5458ALIAS (no_ip_ospf_network,
5459 no_ospf_network_cmd,
5460 "no ospf network",
5461 NO_STR
5462 "OSPF interface commands\n"
5463 "Network type\n")
5464
5465DEFUN (ip_ospf_priority,
5466 ip_ospf_priority_addr_cmd,
5467 "ip ospf priority <0-255> A.B.C.D",
5468 "IP Information\n"
5469 "OSPF interface commands\n"
5470 "Router priority\n"
5471 "Priority\n"
5472 "Address of interface")
5473{
5474 struct interface *ifp = vty->index;
0798cee3 5475 long priority;
718e3744 5476 struct route_node *rn;
5477 struct in_addr addr;
5478 int ret;
5479 struct ospf_if_params *params;
5480
5481 params = IF_DEF_PARAMS (ifp);
5482
5483 priority = strtol (argv[0], NULL, 10);
5484
5485 /* Router Priority range is <0-255>. */
5486 if (priority < 0 || priority > 255)
5487 {
5488 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5489 return CMD_WARNING;
5490 }
5491
5492 if (argc == 2)
5493 {
5494 ret = inet_aton(argv[1], &addr);
5495 if (!ret)
5496 {
5497 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5498 VTY_NEWLINE);
5499 return CMD_WARNING;
5500 }
5501
5502 params = ospf_get_if_params (ifp, addr);
5503 ospf_if_update_params (ifp, addr);
5504 }
5505
5506 SET_IF_PARAM (params, priority);
5507 params->priority = priority;
5508
5509 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5510 {
5511 struct ospf_interface *oi = rn->info;
5512
5513 if (!oi)
5514 continue;
5515
5516
5517 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5518 {
5519 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5520 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5521 }
5522 }
5523
5524 return CMD_SUCCESS;
5525}
5526
5527ALIAS (ip_ospf_priority,
5528 ip_ospf_priority_cmd,
5529 "ip ospf priority <0-255>",
5530 "IP Information\n"
5531 "OSPF interface commands\n"
5532 "Router priority\n"
5533 "Priority\n")
5534
5535ALIAS (ip_ospf_priority,
5536 ospf_priority_cmd,
5537 "ospf priority <0-255>",
5538 "OSPF interface commands\n"
5539 "Router priority\n"
5540 "Priority\n")
5541
5542DEFUN (no_ip_ospf_priority,
5543 no_ip_ospf_priority_addr_cmd,
5544 "no ip ospf priority A.B.C.D",
5545 NO_STR
5546 "IP Information\n"
5547 "OSPF interface commands\n"
5548 "Router priority\n"
5549 "Address of interface")
5550{
5551 struct interface *ifp = vty->index;
5552 struct route_node *rn;
5553 struct in_addr addr;
5554 int ret;
5555 struct ospf_if_params *params;
5556
5557 ifp = vty->index;
5558 params = IF_DEF_PARAMS (ifp);
5559
5560 if (argc == 1)
5561 {
5562 ret = inet_aton(argv[0], &addr);
5563 if (!ret)
5564 {
5565 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5566 VTY_NEWLINE);
5567 return CMD_WARNING;
5568 }
5569
5570 params = ospf_lookup_if_params (ifp, addr);
5571 if (params == NULL)
5572 return CMD_SUCCESS;
5573 }
5574
5575 UNSET_IF_PARAM (params, priority);
5576 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5577
5578 if (params != IF_DEF_PARAMS (ifp))
5579 {
5580 ospf_free_if_params (ifp, addr);
5581 ospf_if_update_params (ifp, addr);
5582 }
5583
5584 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5585 {
5586 struct ospf_interface *oi = rn->info;
5587
5588 if (!oi)
5589 continue;
5590
5591
5592 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5593 {
5594 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5595 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5596 }
5597 }
5598
5599 return CMD_SUCCESS;
5600}
5601
5602ALIAS (no_ip_ospf_priority,
5603 no_ip_ospf_priority_cmd,
5604 "no ip ospf priority",
5605 NO_STR
5606 "IP Information\n"
5607 "OSPF interface commands\n"
5608 "Router priority\n")
5609
5610ALIAS (no_ip_ospf_priority,
5611 no_ospf_priority_cmd,
5612 "no ospf priority",
5613 NO_STR
5614 "OSPF interface commands\n"
5615 "Router priority\n")
5616
d5a5c8f0
DS
5617DEFUN (ip_ospf_bfd,
5618 ip_ospf_bfd_cmd,
5619 "ip ospf bfd",
5620 "IP Information\n"
5621 "OSPF interface commands\n"
5622 "Respond to BFD session event\n")
5623{
5624 struct interface *ifp = vty->index;
5625 struct ospf_if_params *params;
5626
5627 params = IF_DEF_PARAMS (ifp);
5628 SET_IF_PARAM (params, bfd);
5629
5630 return CMD_SUCCESS;
5631}
5632
5633DEFUN (no_ip_ospf_bfd,
5634 no_ip_ospf_bfd_cmd,
5635 "no ip ospf bfd",
5636 NO_STR
5637 "IP Information\n"
5638 "OSPF interface commands\n"
5639 "Respond to BFD session event\n")
5640{
5641 struct interface *ifp = vty->index;
5642 struct ospf_if_params *params;
5643
5644 params = IF_DEF_PARAMS (ifp);
5645 UNSET_IF_PARAM (params, bfd);
5646
5647 return CMD_SUCCESS;
5648}
5649
5650
718e3744 5651DEFUN (ip_ospf_retransmit_interval,
5652 ip_ospf_retransmit_interval_addr_cmd,
5653 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5654 "IP Information\n"
5655 "OSPF interface commands\n"
5656 "Time between retransmitting lost link state advertisements\n"
5657 "Seconds\n"
5658 "Address of interface")
5659{
5660 struct interface *ifp = vty->index;
5661 u_int32_t seconds;
5662 struct in_addr addr;
5663 int ret;
5664 struct ospf_if_params *params;
5665
5666 params = IF_DEF_PARAMS (ifp);
5667 seconds = strtol (argv[0], NULL, 10);
5668
5669 /* Retransmit Interval range is <3-65535>. */
5670 if (seconds < 3 || seconds > 65535)
5671 {
5672 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5673 return CMD_WARNING;
5674 }
5675
5676
5677 if (argc == 2)
5678 {
5679 ret = inet_aton(argv[1], &addr);
5680 if (!ret)
5681 {
5682 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5683 VTY_NEWLINE);
5684 return CMD_WARNING;
5685 }
5686
5687 params = ospf_get_if_params (ifp, addr);
5688 ospf_if_update_params (ifp, addr);
5689 }
5690
5691 SET_IF_PARAM (params, retransmit_interval);
5692 params->retransmit_interval = seconds;
5693
5694 return CMD_SUCCESS;
5695}
5696
5697ALIAS (ip_ospf_retransmit_interval,
5698 ip_ospf_retransmit_interval_cmd,
5699 "ip ospf retransmit-interval <3-65535>",
5700 "IP Information\n"
5701 "OSPF interface commands\n"
5702 "Time between retransmitting lost link state advertisements\n"
5703 "Seconds\n")
5704
5705ALIAS (ip_ospf_retransmit_interval,
5706 ospf_retransmit_interval_cmd,
5707 "ospf retransmit-interval <3-65535>",
5708 "OSPF interface commands\n"
5709 "Time between retransmitting lost link state advertisements\n"
5710 "Seconds\n")
5711
5712DEFUN (no_ip_ospf_retransmit_interval,
5713 no_ip_ospf_retransmit_interval_addr_cmd,
5714 "no ip ospf retransmit-interval A.B.C.D",
5715 NO_STR
5716 "IP Information\n"
5717 "OSPF interface commands\n"
5718 "Time between retransmitting lost link state advertisements\n"
5719 "Address of interface")
5720{
5721 struct interface *ifp = vty->index;
5722 struct in_addr addr;
5723 int ret;
5724 struct ospf_if_params *params;
5725
5726 ifp = vty->index;
5727 params = IF_DEF_PARAMS (ifp);
5728
5729 if (argc == 1)
5730 {
5731 ret = inet_aton(argv[0], &addr);
5732 if (!ret)
5733 {
5734 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5735 VTY_NEWLINE);
5736 return CMD_WARNING;
5737 }
5738
5739 params = ospf_lookup_if_params (ifp, addr);
5740 if (params == NULL)
5741 return CMD_SUCCESS;
5742 }
5743
5744 UNSET_IF_PARAM (params, retransmit_interval);
5745 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5746
5747 if (params != IF_DEF_PARAMS (ifp))
5748 {
5749 ospf_free_if_params (ifp, addr);
5750 ospf_if_update_params (ifp, addr);
5751 }
5752
5753 return CMD_SUCCESS;
5754}
5755
5756ALIAS (no_ip_ospf_retransmit_interval,
5757 no_ip_ospf_retransmit_interval_cmd,
5758 "no ip ospf retransmit-interval",
5759 NO_STR
5760 "IP Information\n"
5761 "OSPF interface commands\n"
5762 "Time between retransmitting lost link state advertisements\n")
5763
5764ALIAS (no_ip_ospf_retransmit_interval,
5765 no_ospf_retransmit_interval_cmd,
5766 "no ospf retransmit-interval",
5767 NO_STR
5768 "OSPF interface commands\n"
5769 "Time between retransmitting lost link state advertisements\n")
5770
5771DEFUN (ip_ospf_transmit_delay,
5772 ip_ospf_transmit_delay_addr_cmd,
5773 "ip ospf transmit-delay <1-65535> A.B.C.D",
5774 "IP Information\n"
5775 "OSPF interface commands\n"
5776 "Link state transmit delay\n"
5777 "Seconds\n"
5778 "Address of interface")
5779{
5780 struct interface *ifp = vty->index;
5781 u_int32_t seconds;
5782 struct in_addr addr;
5783 int ret;
5784 struct ospf_if_params *params;
5785
5786 params = IF_DEF_PARAMS (ifp);
5787 seconds = strtol (argv[0], NULL, 10);
5788
5789 /* Transmit Delay range is <1-65535>. */
5790 if (seconds < 1 || seconds > 65535)
5791 {
5792 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5793 return CMD_WARNING;
5794 }
5795
5796 if (argc == 2)
5797 {
5798 ret = inet_aton(argv[1], &addr);
5799 if (!ret)
5800 {
5801 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5802 VTY_NEWLINE);
5803 return CMD_WARNING;
5804 }
5805
5806 params = ospf_get_if_params (ifp, addr);
5807 ospf_if_update_params (ifp, addr);
5808 }
5809
5810 SET_IF_PARAM (params, transmit_delay);
5811 params->transmit_delay = seconds;
5812
5813 return CMD_SUCCESS;
5814}
5815
5816ALIAS (ip_ospf_transmit_delay,
5817 ip_ospf_transmit_delay_cmd,
5818 "ip ospf transmit-delay <1-65535>",
5819 "IP Information\n"
5820 "OSPF interface commands\n"
5821 "Link state transmit delay\n"
5822 "Seconds\n")
5823
5824ALIAS (ip_ospf_transmit_delay,
5825 ospf_transmit_delay_cmd,
5826 "ospf transmit-delay <1-65535>",
5827 "OSPF interface commands\n"
5828 "Link state transmit delay\n"
5829 "Seconds\n")
5830
5831DEFUN (no_ip_ospf_transmit_delay,
5832 no_ip_ospf_transmit_delay_addr_cmd,
5833 "no ip ospf transmit-delay A.B.C.D",
5834 NO_STR
5835 "IP Information\n"
5836 "OSPF interface commands\n"
5837 "Link state transmit delay\n"
5838 "Address of interface")
5839{
5840 struct interface *ifp = vty->index;
5841 struct in_addr addr;
5842 int ret;
5843 struct ospf_if_params *params;
5844
5845 ifp = vty->index;
5846 params = IF_DEF_PARAMS (ifp);
5847
5848 if (argc == 1)
5849 {
5850 ret = inet_aton(argv[0], &addr);
5851 if (!ret)
5852 {
5853 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5854 VTY_NEWLINE);
5855 return CMD_WARNING;
5856 }
5857
5858 params = ospf_lookup_if_params (ifp, addr);
5859 if (params == NULL)
5860 return CMD_SUCCESS;
5861 }
5862
5863 UNSET_IF_PARAM (params, transmit_delay);
5864 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5865
5866 if (params != IF_DEF_PARAMS (ifp))
5867 {
5868 ospf_free_if_params (ifp, addr);
5869 ospf_if_update_params (ifp, addr);
5870 }
5871
5872 return CMD_SUCCESS;
5873}
5874
5875ALIAS (no_ip_ospf_transmit_delay,
5876 no_ip_ospf_transmit_delay_cmd,
5877 "no ip ospf transmit-delay",
5878 NO_STR
5879 "IP Information\n"
5880 "OSPF interface commands\n"
5881 "Link state transmit delay\n")
5882
5883ALIAS (no_ip_ospf_transmit_delay,
5884 no_ospf_transmit_delay_cmd,
5885 "no ospf transmit-delay",
5886 NO_STR
5887 "OSPF interface commands\n"
5888 "Link state transmit delay\n")
5889
6f2a6703
CF
5890DEFUN (ospf_redistribute_source,
5891 ospf_redistribute_source_cmd,
5892 "redistribute " QUAGGA_REDIST_STR_OSPFD
5893 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
d1c65c21
PJ
5894 REDIST_STR
5895 QUAGGA_REDIST_HELP_STR_OSPFD
718e3744 5896 "Metric for redistributed routes\n"
5897 "OSPF default metric\n"
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 "Route map reference\n"
5902 "Pointer to route-map entries\n")
5903{
020709f9 5904 struct ospf *ospf = vty->index;
718e3744 5905 int source;
5906 int type = -1;
5907 int metric = -1;
5908
6f2a6703
CF
5909 if (argc < 4)
5910 return CMD_WARNING; /* should not happen */
5911
718e3744 5912 /* Get distribute source. */
e0ca5fde
DL
5913 source = proto_redistnum(AFI_IP, argv[0]);
5914 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 5915 return CMD_WARNING;
5916
5917 /* Get metric value. */
6f2a6703 5918 if (argv[1] != NULL)
718e3744 5919 if (!str2metric (argv[1], &metric))
5920 return CMD_WARNING;
5921
5922 /* Get metric type. */
6f2a6703 5923 if (argv[2] != NULL)
718e3744 5924 if (!str2metric_type (argv[2], &type))
5925 return CMD_WARNING;
5926
6f2a6703 5927 if (argv[3] != NULL)
020709f9 5928 ospf_routemap_set (ospf, source, argv[3]);
718e3744 5929 else
020709f9 5930 ospf_routemap_unset (ospf, source);
718e3744 5931
020709f9 5932 return ospf_redistribute_set (ospf, source, type, metric);
718e3744 5933}
5934
718e3744 5935DEFUN (no_ospf_redistribute_source,
5936 no_ospf_redistribute_source_cmd,
d1c65c21 5937 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
718e3744 5938 NO_STR
d1c65c21
PJ
5939 REDIST_STR
5940 QUAGGA_REDIST_HELP_STR_OSPFD)
718e3744 5941{
020709f9 5942 struct ospf *ospf = vty->index;
718e3744 5943 int source;
5944
e0ca5fde
DL
5945 source = proto_redistnum(AFI_IP, argv[0]);
5946 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 5947 return CMD_WARNING;
5948
020709f9 5949 ospf_routemap_unset (ospf, source);
5950 return ospf_redistribute_unset (ospf, source);
718e3744 5951}
5952
5953DEFUN (ospf_distribute_list_out,
5954 ospf_distribute_list_out_cmd,
d1c65c21 5955 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
718e3744 5956 "Filter networks in routing updates\n"
6f2a6703
CF
5957 "Access-list name\n"
5958 OUT_STR
5959 QUAGGA_REDIST_HELP_STR_OSPFD)
718e3744 5960{
020709f9 5961 struct ospf *ospf = vty->index;
6f2a6703 5962 int source;
718e3744 5963
6f2a6703
CF
5964 /* Get distribute source. */
5965 source = proto_redistnum(AFI_IP, argv[1]);
5966 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5967 return CMD_WARNING;
718e3744 5968
6f2a6703 5969 return ospf_distribute_list_out_set (ospf, source, argv[0]);
718e3744 5970}
5971
6f2a6703
CF
5972DEFUN (no_ospf_distribute_list_out,
5973 no_ospf_distribute_list_out_cmd,
5974 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
5975 NO_STR
5976 "Filter networks in routing updates\n"
5977 "Access-list name\n"
5978 OUT_STR
5979 QUAGGA_REDIST_HELP_STR_OSPFD)
718e3744 5980{
020709f9 5981 struct ospf *ospf = vty->index;
6f2a6703 5982 int source;
020709f9 5983
6f2a6703
CF
5984 source = proto_redistnum(AFI_IP, argv[1]);
5985 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
5986 return CMD_WARNING;
718e3744 5987
6f2a6703 5988 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
718e3744 5989}
5990
6f2a6703
CF
5991/* Default information originate. */
5992DEFUN (ospf_default_information_originate,
5993 ospf_default_information_originate_cmd,
5994 "default-information originate "
5995 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
718e3744 5996 "Control distribution of default information\n"
5997 "Distribute a default route\n"
5998 "Always advertise default route\n"
6f2a6703
CF
5999 "OSPF default metric\n"
6000 "OSPF metric\n"
718e3744 6001 "OSPF metric type for default routes\n"
6002 "Set OSPF External Type 1 metrics\n"
6003 "Set OSPF External Type 2 metrics\n"
718e3744 6004 "Route map reference\n"
6005 "Pointer to route-map entries\n")
6006{
020709f9 6007 struct ospf *ospf = vty->index;
6f2a6703 6008 int default_originate = DEFAULT_ORIGINATE_ZEBRA;
718e3744 6009 int type = -1;
6010 int metric = -1;
6011
6f2a6703
CF
6012 if (argc < 4)
6013 return CMD_WARNING; /* this should not happen */
6014
6015 /* Check whether "always" was specified */
6016 if (argv[0] != NULL)
6017 default_originate = DEFAULT_ORIGINATE_ALWAYS;
718e3744 6018
6019 /* Get metric value. */
6f2a6703 6020 if (argv[1] != NULL)
718e3744 6021 if (!str2metric (argv[1], &metric))
6022 return CMD_WARNING;
6023
718e3744 6024 /* Get metric type. */
6f2a6703
CF
6025 if (argv[2] != NULL)
6026 if (!str2metric_type (argv[2], &type))
718e3744 6027 return CMD_WARNING;
6028
6f2a6703
CF
6029 if (argv[3] != NULL)
6030 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]);
718e3744 6031 else
020709f9 6032 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
718e3744 6033
6f2a6703
CF
6034 return ospf_redistribute_default_set (ospf, default_originate,
6035 type, metric);
718e3744 6036}
6037
6038DEFUN (no_ospf_default_information_originate,
6039 no_ospf_default_information_originate_cmd,
6040 "no default-information originate",
6041 NO_STR
6042 "Control distribution of default information\n"
6043 "Distribute a default route\n")
6044{
68980084 6045 struct ospf *ospf = vty->index;
718e3744 6046 struct prefix_ipv4 p;
718e3744 6047
6048 p.family = AF_INET;
6049 p.prefix.s_addr = 0;
6050 p.prefixlen = 0;
6051
5339cfdb 6052 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
718e3744 6053
6054 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6055 ospf_external_info_delete (DEFAULT_ROUTE, p);
6056 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6057 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6058 }
6059
020709f9 6060 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6061 return ospf_redistribute_default_unset (ospf);
718e3744 6062}
6063
6064DEFUN (ospf_default_metric,
6065 ospf_default_metric_cmd,
6066 "default-metric <0-16777214>",
6067 "Set metric of redistributed routes\n"
6068 "Default metric\n")
6069{
68980084 6070 struct ospf *ospf = vty->index;
718e3744 6071 int metric = -1;
6072
6073 if (!str2metric (argv[0], &metric))
6074 return CMD_WARNING;
6075
68980084 6076 ospf->default_metric = metric;
718e3744 6077
6078 return CMD_SUCCESS;
6079}
6080
6081DEFUN (no_ospf_default_metric,
6082 no_ospf_default_metric_cmd,
6083 "no default-metric",
6084 NO_STR
6085 "Set metric of redistributed routes\n")
6086{
68980084 6087 struct ospf *ospf = vty->index;
6088
6089 ospf->default_metric = -1;
6090
718e3744 6091 return CMD_SUCCESS;
6092}
6093
6094ALIAS (no_ospf_default_metric,
6095 no_ospf_default_metric_val_cmd,
6096 "no default-metric <0-16777214>",
6097 NO_STR
6098 "Set metric of redistributed routes\n"
6099 "Default metric\n")
6100
6101DEFUN (ospf_distance,
6102 ospf_distance_cmd,
6103 "distance <1-255>",
6104 "Define an administrative distance\n"
6105 "OSPF Administrative distance\n")
6106{
68980084 6107 struct ospf *ospf = vty->index;
6108
6109 ospf->distance_all = atoi (argv[0]);
6110
718e3744 6111 return CMD_SUCCESS;
6112}
6113
6114DEFUN (no_ospf_distance,
6115 no_ospf_distance_cmd,
6116 "no distance <1-255>",
6117 NO_STR
6118 "Define an administrative distance\n"
6119 "OSPF Administrative distance\n")
6120{
68980084 6121 struct ospf *ospf = vty->index;
6122
6123 ospf->distance_all = 0;
6124
718e3744 6125 return CMD_SUCCESS;
6126}
6127
6128DEFUN (no_ospf_distance_ospf,
6129 no_ospf_distance_ospf_cmd,
6f2a6703 6130 "no distance ospf {intra-area|inter-area|external}",
718e3744 6131 NO_STR
6132 "Define an administrative distance\n"
6133 "OSPF Administrative distance\n"
6f2a6703 6134 "OSPF Distance\n"
718e3744 6135 "Intra-area routes\n"
718e3744 6136 "Inter-area routes\n"
6f2a6703 6137 "External routes\n")
718e3744 6138{
68980084 6139 struct ospf *ospf = vty->index;
6140
6f2a6703
CF
6141 if (argc < 3)
6142 return CMD_WARNING;
718e3744 6143
6f2a6703
CF
6144 if (argv[0] != NULL)
6145 ospf->distance_intra = 0;
68980084 6146
6f2a6703
CF
6147 if (argv[1] != NULL)
6148 ospf->distance_inter = 0;
68980084 6149
6f2a6703
CF
6150 if (argv[2] != NULL)
6151 ospf->distance_external = 0;
718e3744 6152
6f2a6703
CF
6153 if (argv[0] || argv[1] || argv[2])
6154 return CMD_SUCCESS;
68980084 6155
6f2a6703
CF
6156 /* If no arguments are given, clear all distance information */
6157 ospf->distance_intra = 0;
6158 ospf->distance_inter = 0;
6159 ospf->distance_external = 0;
68980084 6160
718e3744 6161 return CMD_SUCCESS;
6162}
6163
6f2a6703
CF
6164DEFUN (ospf_distance_ospf,
6165 ospf_distance_ospf_cmd,
6166 "distance ospf "
6167 "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
718e3744 6168 "Define an administrative distance\n"
6169 "OSPF Administrative distance\n"
718e3744 6170 "Intra-area routes\n"
6171 "Distance for intra-area routes\n"
718e3744 6172 "Inter-area routes\n"
6173 "Distance for inter-area routes\n"
6174 "External routes\n"
718e3744 6175 "Distance for external routes\n")
6176{
68980084 6177 struct ospf *ospf = vty->index;
6178
6f2a6703
CF
6179 if (argc < 3) /* should not happen */
6180 return CMD_WARNING;
68980084 6181
6f2a6703
CF
6182 if (!argv[0] && !argv[1] && !argv[2])
6183 {
6184 vty_out(vty, "%% Command incomplete. (Arguments required)%s",
6185 VTY_NEWLINE);
6186 return CMD_WARNING;
6187 }
68980084 6188
6f2a6703
CF
6189 if (argv[0] != NULL)
6190 ospf->distance_intra = atoi(argv[0]);
718e3744 6191
6f2a6703
CF
6192 if (argv[1] != NULL)
6193 ospf->distance_inter = atoi(argv[1]);
68980084 6194
6f2a6703
CF
6195 if (argv[2] != NULL)
6196 ospf->distance_external = atoi(argv[2]);
68980084 6197
718e3744 6198 return CMD_SUCCESS;
6199}
6200
6201DEFUN (ospf_distance_source,
6202 ospf_distance_source_cmd,
6203 "distance <1-255> A.B.C.D/M",
6204 "Administrative distance\n"
6205 "Distance value\n"
6206 "IP source prefix\n")
6207{
020709f9 6208 struct ospf *ospf = vty->index;
6209
6210 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
68980084 6211
718e3744 6212 return CMD_SUCCESS;
6213}
6214
6215DEFUN (no_ospf_distance_source,
6216 no_ospf_distance_source_cmd,
6217 "no distance <1-255> A.B.C.D/M",
6218 NO_STR
6219 "Administrative distance\n"
6220 "Distance value\n"
6221 "IP source prefix\n")
6222{
020709f9 6223 struct ospf *ospf = vty->index;
6224
6225 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6226
718e3744 6227 return CMD_SUCCESS;
6228}
6229
6230DEFUN (ospf_distance_source_access_list,
6231 ospf_distance_source_access_list_cmd,
6232 "distance <1-255> A.B.C.D/M WORD",
6233 "Administrative distance\n"
6234 "Distance value\n"
6235 "IP source prefix\n"
6236 "Access list name\n")
6237{
020709f9 6238 struct ospf *ospf = vty->index;
6239
6240 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6241
718e3744 6242 return CMD_SUCCESS;
6243}
6244
6245DEFUN (no_ospf_distance_source_access_list,
6246 no_ospf_distance_source_access_list_cmd,
6247 "no distance <1-255> A.B.C.D/M WORD",
6248 NO_STR
6249 "Administrative distance\n"
6250 "Distance value\n"
6251 "IP source prefix\n"
6252 "Access list name\n")
6253{
020709f9 6254 struct ospf *ospf = vty->index;
6255
6256 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6257
718e3744 6258 return CMD_SUCCESS;
6259}
6260
ba682537 6261DEFUN (ip_ospf_mtu_ignore,
6262 ip_ospf_mtu_ignore_addr_cmd,
6263 "ip ospf mtu-ignore A.B.C.D",
6264 "IP Information\n"
6265 "OSPF interface commands\n"
6266 "Disable mtu mismatch detection\n"
6267 "Address of interface")
6268{
6269 struct interface *ifp = vty->index;
6270 struct in_addr addr;
6271 int ret;
6272
6273 struct ospf_if_params *params;
6274 params = IF_DEF_PARAMS (ifp);
6275
6276 if (argc == 1)
6277 {
6278 ret = inet_aton(argv[0], &addr);
6279 if (!ret)
6280 {
6281 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6282 VTY_NEWLINE);
6283 return CMD_WARNING;
6284 }
6285 params = ospf_get_if_params (ifp, addr);
6286 ospf_if_update_params (ifp, addr);
6287 }
6288 params->mtu_ignore = 1;
6289 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6290 SET_IF_PARAM (params, mtu_ignore);
6291 else
6292 {
6293 UNSET_IF_PARAM (params, mtu_ignore);
6294 if (params != IF_DEF_PARAMS (ifp))
6295 {
6296 ospf_free_if_params (ifp, addr);
6297 ospf_if_update_params (ifp, addr);
6298 }
6299 }
6300 return CMD_SUCCESS;
6301}
6302
6303ALIAS (ip_ospf_mtu_ignore,
6304 ip_ospf_mtu_ignore_cmd,
6305 "ip ospf mtu-ignore",
6306 "IP Information\n"
6307 "OSPF interface commands\n"
6308 "Disable mtu mismatch detection\n")
6309
6310
6311DEFUN (no_ip_ospf_mtu_ignore,
6312 no_ip_ospf_mtu_ignore_addr_cmd,
6313 "no ip ospf mtu-ignore A.B.C.D",
6314 "IP Information\n"
6315 "OSPF interface commands\n"
6316 "Disable mtu mismatch detection\n"
6317 "Address of interface")
6318{
6319 struct interface *ifp = vty->index;
6320 struct in_addr addr;
6321 int ret;
6322
6323 struct ospf_if_params *params;
6324 params = IF_DEF_PARAMS (ifp);
6325
6326 if (argc == 1)
6327 {
6328 ret = inet_aton(argv[0], &addr);
6329 if (!ret)
6330 {
6331 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6332 VTY_NEWLINE);
6333 return CMD_WARNING;
6334 }
6335 params = ospf_get_if_params (ifp, addr);
6336 ospf_if_update_params (ifp, addr);
6337 }
6338 params->mtu_ignore = 0;
6339 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6340 SET_IF_PARAM (params, mtu_ignore);
6341 else
6342 {
6343 UNSET_IF_PARAM (params, mtu_ignore);
6344 if (params != IF_DEF_PARAMS (ifp))
6345 {
6346 ospf_free_if_params (ifp, addr);
6347 ospf_if_update_params (ifp, addr);
6348 }
6349 }
6350 return CMD_SUCCESS;
6351}
6352
6353ALIAS (no_ip_ospf_mtu_ignore,
6354 no_ip_ospf_mtu_ignore_cmd,
6355 "no ip ospf mtu-ignore",
6356 "IP Information\n"
6357 "OSPF interface commands\n"
6358 "Disable mtu mismatch detection\n")
6b0655a2 6359
88d6cf37 6360DEFUN (ospf_max_metric_router_lsa_admin,
6361 ospf_max_metric_router_lsa_admin_cmd,
6362 "max-metric router-lsa administrative",
6363 "OSPF maximum / infinite-distance metric\n"
6364 "Advertise own Router-LSA with infinite distance (stub router)\n"
6365 "Administratively applied, for an indefinite period\n")
6366{
6367 struct listnode *ln;
6368 struct ospf_area *area;
6369 struct ospf *ospf = vty->index;
ba682537 6370
88d6cf37 6371 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6372 {
6373 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6374
6375 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
c363d386 6376 ospf_router_lsa_update_area (area);
88d6cf37 6377 }
4ba4fc85
AB
6378
6379 /* Allows for areas configured later to get the property */
6380 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
6381
88d6cf37 6382 return CMD_SUCCESS;
6383}
6384
6385DEFUN (no_ospf_max_metric_router_lsa_admin,
6386 no_ospf_max_metric_router_lsa_admin_cmd,
6387 "no max-metric router-lsa administrative",
6388 NO_STR
6389 "OSPF maximum / infinite-distance metric\n"
6390 "Advertise own Router-LSA with infinite distance (stub router)\n"
6391 "Administratively applied, for an indefinite period\n")
6392{
6393 struct listnode *ln;
6394 struct ospf_area *area;
6395 struct ospf *ospf = vty->index;
6396
6397 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6398 {
6399 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6400
6401 /* Don't trample on the start-up stub timer */
6402 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6403 && !area->t_stub_router)
6404 {
6405 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
c363d386 6406 ospf_router_lsa_update_area (area);
88d6cf37 6407 }
6408 }
4ba4fc85 6409 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
88d6cf37 6410 return CMD_SUCCESS;
6411}
6412
6413DEFUN (ospf_max_metric_router_lsa_startup,
6414 ospf_max_metric_router_lsa_startup_cmd,
6415 "max-metric router-lsa on-startup <5-86400>",
6416 "OSPF maximum / infinite-distance metric\n"
6417 "Advertise own Router-LSA with infinite distance (stub router)\n"
6418 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6419 "Time (seconds) to advertise self as stub-router\n")
6420{
6421 unsigned int seconds;
6422 struct ospf *ospf = vty->index;
6423
6424 if (argc != 1)
6425 {
6426 vty_out (vty, "%% Must supply stub-router period");
6427 return CMD_WARNING;
6428 }
6429
6430 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6431
6432 ospf->stub_router_startup_time = seconds;
6433
6434 return CMD_SUCCESS;
6435}
6436
6437DEFUN (no_ospf_max_metric_router_lsa_startup,
6438 no_ospf_max_metric_router_lsa_startup_cmd,
6439 "no max-metric router-lsa on-startup",
6440 NO_STR
6441 "OSPF maximum / infinite-distance metric\n"
6442 "Advertise own Router-LSA with infinite distance (stub router)\n"
6443 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6444{
6445 struct listnode *ln;
6446 struct ospf_area *area;
6447 struct ospf *ospf = vty->index;
6448
6449 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6450
6451 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6452 {
6453 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6454 OSPF_TIMER_OFF (area->t_stub_router);
6455
6456 /* Don't trample on admin stub routed */
6457 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6458 {
6459 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
c363d386 6460 ospf_router_lsa_update_area (area);
88d6cf37 6461 }
6462 }
6463 return CMD_SUCCESS;
6464}
6465
6466DEFUN (ospf_max_metric_router_lsa_shutdown,
6467 ospf_max_metric_router_lsa_shutdown_cmd,
6468 "max-metric router-lsa on-shutdown <5-86400>",
6469 "OSPF maximum / infinite-distance metric\n"
6470 "Advertise own Router-LSA with infinite distance (stub router)\n"
6471 "Advertise stub-router prior to full shutdown of OSPF\n"
6472 "Time (seconds) to wait till full shutdown\n")
6473{
6474 unsigned int seconds;
6475 struct ospf *ospf = vty->index;
6476
6477 if (argc != 1)
6478 {
6479 vty_out (vty, "%% Must supply stub-router shutdown period");
6480 return CMD_WARNING;
6481 }
6482
6483 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6484
6485 ospf->stub_router_shutdown_time = seconds;
6486
6487 return CMD_SUCCESS;
6488}
6489
6490DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6491 no_ospf_max_metric_router_lsa_shutdown_cmd,
6492 "no max-metric router-lsa on-shutdown",
6493 NO_STR
6494 "OSPF maximum / infinite-distance metric\n"
6495 "Advertise own Router-LSA with infinite distance (stub router)\n"
6496 "Advertise stub-router prior to full shutdown of OSPF\n")
6497{
6498 struct ospf *ospf = vty->index;
6499
6500 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6501
6502 return CMD_SUCCESS;
6503}
6504
6505static void
6506config_write_stub_router (struct vty *vty, struct ospf *ospf)
6507{
6508 struct listnode *ln;
6509 struct ospf_area *area;
6510
6511 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6512 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6513 ospf->stub_router_startup_time, VTY_NEWLINE);
6514 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6515 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6516 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6517 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6518 {
6519 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6520 {
6521 vty_out (vty, " max-metric router-lsa administrative%s",
6522 VTY_NEWLINE);
6523 break;
6524 }
6525 }
6526 return;
6527}
6b0655a2 6528
4dadc291 6529static void
718e3744 6530show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6531{
6532 struct route_node *rn;
6533 struct ospf_route *or;
1eb8ef25 6534 struct listnode *pnode, *pnnode;
718e3744 6535 struct ospf_path *path;
6536
6537 vty_out (vty, "============ OSPF network routing table ============%s",
6538 VTY_NEWLINE);
6539
6540 for (rn = route_top (rt); rn; rn = route_next (rn))
6541 if ((or = rn->info) != NULL)
6542 {
6543 char buf1[19];
6544 snprintf (buf1, 19, "%s/%d",
6545 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6546
6547 switch (or->path_type)
6548 {
6549 case OSPF_PATH_INTER_AREA:
6550 if (or->type == OSPF_DESTINATION_NETWORK)
6551 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6552 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6553 else if (or->type == OSPF_DESTINATION_DISCARD)
6554 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6555 break;
6556 case OSPF_PATH_INTRA_AREA:
6557 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6558 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6559 break;
6560 default:
6561 break;
6562 }
6563
6564 if (or->type == OSPF_DESTINATION_NETWORK)
1eb8ef25 6565 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
96735eea 6566 {
a8ba847f 6567 if (if_lookup_by_index(path->ifindex))
96735eea 6568 {
6569 if (path->nexthop.s_addr == 0)
6570 vty_out (vty, "%24s directly attached to %s%s",
a8ba847f 6571 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
96735eea 6572 else
6573 vty_out (vty, "%24s via %s, %s%s", "",
a8ba847f
JT
6574 inet_ntoa (path->nexthop),
6575 ifindex2ifname (path->ifindex), VTY_NEWLINE);
96735eea 6576 }
6577 }
718e3744 6578 }
6579 vty_out (vty, "%s", VTY_NEWLINE);
6580}
6581
4dadc291 6582static void
718e3744 6583show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6584{
6585 struct route_node *rn;
6586 struct ospf_route *or;
1eb8ef25 6587 struct listnode *pnode;
6588 struct listnode *node;
718e3744 6589 struct ospf_path *path;
6590
6591 vty_out (vty, "============ OSPF router routing table =============%s",
6592 VTY_NEWLINE);
6593 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6594 if (rn->info)
6595 {
6596 int flag = 0;
6597
6598 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6599
1eb8ef25 6600 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
6601 {
6602 if (flag++)
6603 vty_out (vty, "%24s", "");
6604
6605 /* Show path. */
6606 vty_out (vty, "%s [%d] area: %s",
6607 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6608 or->cost, inet_ntoa (or->u.std.area_id));
6609 /* Show flags. */
6610 vty_out (vty, "%s%s%s",
6611 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6612 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6613 VTY_NEWLINE);
6614
6615 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
6616 {
a8ba847f 6617 if (if_lookup_by_index(path->ifindex))
54bedb55 6618 {
6619 if (path->nexthop.s_addr == 0)
6620 vty_out (vty, "%24s directly attached to %s%s",
a8ba847f
JT
6621 "", ifindex2ifname (path->ifindex),
6622 VTY_NEWLINE);
54bedb55 6623 else
6624 vty_out (vty, "%24s via %s, %s%s", "",
6625 inet_ntoa (path->nexthop),
a8ba847f
JT
6626 ifindex2ifname (path->ifindex),
6627 VTY_NEWLINE);
54bedb55 6628 }
1eb8ef25 6629 }
6630 }
718e3744 6631 }
6632 vty_out (vty, "%s", VTY_NEWLINE);
6633}
6634
4dadc291 6635static void
718e3744 6636show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6637{
6638 struct route_node *rn;
6639 struct ospf_route *er;
1eb8ef25 6640 struct listnode *pnode, *pnnode;
718e3744 6641 struct ospf_path *path;
6642
6643 vty_out (vty, "============ OSPF external routing table ===========%s",
6644 VTY_NEWLINE);
6645 for (rn = route_top (rt); rn; rn = route_next (rn))
6646 if ((er = rn->info) != NULL)
6647 {
6648 char buf1[19];
6649 snprintf (buf1, 19, "%s/%d",
6650 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6651
6652 switch (er->path_type)
6653 {
6654 case OSPF_PATH_TYPE1_EXTERNAL:
6655 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6656 er->cost, er->u.ext.tag, VTY_NEWLINE);
6657 break;
6658 case OSPF_PATH_TYPE2_EXTERNAL:
6659 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6660 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6661 break;
6662 }
6663
1eb8ef25 6664 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
718e3744 6665 {
a8ba847f 6666 if (if_lookup_by_index(path->ifindex))
718e3744 6667 {
6668 if (path->nexthop.s_addr == 0)
96735eea 6669 vty_out (vty, "%24s directly attached to %s%s",
a8ba847f 6670 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
96735eea 6671 else
6672 vty_out (vty, "%24s via %s, %s%s", "",
a8ba847f
JT
6673 inet_ntoa (path->nexthop),
6674 ifindex2ifname (path->ifindex),
96735eea 6675 VTY_NEWLINE);
718e3744 6676 }
6677 }
6678 }
6679 vty_out (vty, "%s", VTY_NEWLINE);
6680}
6681
718e3744 6682DEFUN (show_ip_ospf_border_routers,
6683 show_ip_ospf_border_routers_cmd,
6684 "show ip ospf border-routers",
6685 SHOW_STR
6686 IP_STR
6687 "show all the ABR's and ASBR's\n"
6688 "for this area\n")
6689{
020709f9 6690 struct ospf *ospf;
68980084 6691
cac3b5c4 6692 if ((ospf = ospf_lookup ()) == NULL)
718e3744 6693 {
cac3b5c4 6694 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
718e3744 6695 return CMD_SUCCESS;
6696 }
6697
68980084 6698 if (ospf->new_table == NULL)
718e3744 6699 {
6700 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6701 return CMD_SUCCESS;
6702 }
6703
6704 /* Show Network routes.
020709f9 6705 show_ip_ospf_route_network (vty, ospf->new_table); */
718e3744 6706
6707 /* Show Router routes. */
68980084 6708 show_ip_ospf_route_router (vty, ospf->new_rtrs);
718e3744 6709
6710 return CMD_SUCCESS;
6711}
718e3744 6712
6713DEFUN (show_ip_ospf_route,
6714 show_ip_ospf_route_cmd,
6715 "show ip ospf route",
6716 SHOW_STR
6717 IP_STR
6718 "OSPF information\n"
6719 "OSPF routing table\n")
6720{
020709f9 6721 struct ospf *ospf;
68980084 6722
cac3b5c4 6723 if ((ospf = ospf_lookup ()) == NULL)
718e3744 6724 {
cac3b5c4 6725 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
718e3744 6726 return CMD_SUCCESS;
6727 }
6728
68980084 6729 if (ospf->new_table == NULL)
718e3744 6730 {
6731 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6732 return CMD_SUCCESS;
6733 }
6734
6735 /* Show Network routes. */
68980084 6736 show_ip_ospf_route_network (vty, ospf->new_table);
718e3744 6737
6738 /* Show Router routes. */
68980084 6739 show_ip_ospf_route_router (vty, ospf->new_rtrs);
718e3744 6740
6741 /* Show AS External routes. */
68980084 6742 show_ip_ospf_route_external (vty, ospf->old_external_route);
718e3744 6743
6744 return CMD_SUCCESS;
6745}
6746
6b0655a2 6747
eb1ce605 6748const char *ospf_abr_type_str[] =
718e3744 6749{
6750 "unknown",
6751 "standard",
6752 "ibm",
6753 "cisco",
6754 "shortcut"
6755};
6756
eb1ce605 6757const char *ospf_shortcut_mode_str[] =
718e3744 6758{
6759 "default",
6760 "enable",
6761 "disable"
6762};
6763
6764
4dadc291 6765static void
718e3744 6766area_id2str (char *buf, int length, struct ospf_area *area)
6767{
6768 memset (buf, 0, length);
6769
6770 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6771 strncpy (buf, inet_ntoa (area->area_id), length);
6772 else
6773 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6774}
6775
6b0655a2 6776
eb1ce605 6777const char *ospf_int_type_str[] =
718e3744 6778{
6779 "unknown", /* should never be used. */
6780 "point-to-point",
6781 "broadcast",
6782 "non-broadcast",
6783 "point-to-multipoint",
6784 "virtual-link", /* should never be used. */
6785 "loopback"
6786};
6787
6788/* Configuration write function for ospfd. */
4dadc291 6789static int
718e3744 6790config_write_interface (struct vty *vty)
6791{
52dc7ee6 6792 struct listnode *n1, *n2;
718e3744 6793 struct interface *ifp;
6794 struct crypt_key *ck;
6795 int write = 0;
6796 struct route_node *rn = NULL;
6797 struct ospf_if_params *params;
6798
1eb8ef25 6799 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
718e3744 6800 {
718e3744 6801 if (memcmp (ifp->name, "VLINK", 5) == 0)
6802 continue;
6803
6804 vty_out (vty, "!%s", VTY_NEWLINE);
6805 vty_out (vty, "interface %s%s", ifp->name,
6806 VTY_NEWLINE);
6807 if (ifp->desc)
6808 vty_out (vty, " description %s%s", ifp->desc,
6809 VTY_NEWLINE);
6810
6811 write++;
6812
6813 params = IF_DEF_PARAMS (ifp);
6814
6815 do {
6816 /* Interface Network print. */
6817 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
718e3744 6818 params->type != OSPF_IFTYPE_LOOPBACK)
6819 {
bc18d616 6820 if (params->type != ospf_default_iftype(ifp))
7b90143f 6821 {
6822 vty_out (vty, " ip ospf network %s",
6823 ospf_int_type_str[params->type]);
6824 if (params != IF_DEF_PARAMS (ifp))
6825 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6826 vty_out (vty, "%s", VTY_NEWLINE);
6827 }
718e3744 6828 }
6829
6830 /* OSPF interface authentication print */
6831 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6832 params->auth_type != OSPF_AUTH_NOTSET)
6833 {
eb1ce605 6834 const char *auth_str;
718e3744 6835
6836 /* Translation tables are not that much help here due to syntax
6837 of the simple option */
6838 switch (params->auth_type)
6839 {
6840
6841 case OSPF_AUTH_NULL:
6842 auth_str = " null";
6843 break;
6844
6845 case OSPF_AUTH_SIMPLE:
6846 auth_str = "";
6847 break;
6848
6849 case OSPF_AUTH_CRYPTOGRAPHIC:
6850 auth_str = " message-digest";
6851 break;
6852
6853 default:
6854 auth_str = "";
6855 break;
6856 }
6857
6858 vty_out (vty, " ip ospf authentication%s", auth_str);
6859 if (params != IF_DEF_PARAMS (ifp))
6860 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6861 vty_out (vty, "%s", VTY_NEWLINE);
6862 }
6863
6864 /* Simple Authentication Password print. */
6865 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6866 params->auth_simple[0] != '\0')
6867 {
6868 vty_out (vty, " ip ospf authentication-key %s",
6869 params->auth_simple);
6870 if (params != IF_DEF_PARAMS (ifp))
6871 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6872 vty_out (vty, "%s", VTY_NEWLINE);
6873 }
6874
6875 /* Cryptographic Authentication Key print. */
1eb8ef25 6876 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
718e3744 6877 {
718e3744 6878 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6879 ck->key_id, ck->auth_key);
6880 if (params != IF_DEF_PARAMS (ifp))
6881 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6882 vty_out (vty, "%s", VTY_NEWLINE);
6883 }
6884
6885 /* Interface Output Cost print. */
6886 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6887 {
6888 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6889 if (params != IF_DEF_PARAMS (ifp))
6890 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6891 vty_out (vty, "%s", VTY_NEWLINE);
6892 }
6893
6894 /* Hello Interval print. */
6895 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6896 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6897 {
6898 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6899 if (params != IF_DEF_PARAMS (ifp))
6900 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6901 vty_out (vty, "%s", VTY_NEWLINE);
6902 }
6903
6904
6905 /* Router Dead Interval print. */
6906 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
6907 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
6908 {
f9ad937f 6909 vty_out (vty, " ip ospf dead-interval ");
6910
6911 /* fast hello ? */
6912 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
6913 vty_out (vty, "minimal hello-multiplier %d",
6914 params->fast_hello);
6915 else
6916 vty_out (vty, "%u", params->v_wait);
6917
718e3744 6918 if (params != IF_DEF_PARAMS (ifp))
6919 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6920 vty_out (vty, "%s", VTY_NEWLINE);
6921 }
6922
6923 /* Router Priority print. */
6924 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
6925 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
6926 {
6927 vty_out (vty, " ip ospf priority %u", params->priority);
6928 if (params != IF_DEF_PARAMS (ifp))
6929 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6930 vty_out (vty, "%s", VTY_NEWLINE);
6931 }
6932
6933 /* Retransmit Interval print. */
6934 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
6935 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
6936 {
6937 vty_out (vty, " ip ospf retransmit-interval %u",
6938 params->retransmit_interval);
6939 if (params != IF_DEF_PARAMS (ifp))
6940 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6941 vty_out (vty, "%s", VTY_NEWLINE);
6942 }
6943
6944 /* Transmit Delay print. */
6945 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
6946 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
6947 {
6948 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
6949 if (params != IF_DEF_PARAMS (ifp))
6950 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6951 vty_out (vty, "%s", VTY_NEWLINE);
6952 }
6953
d5a5c8f0
DS
6954 /* bfd print. */
6955 if (OSPF_IF_PARAM_CONFIGURED (params, bfd))
6956 vty_out (vty, " ip ospf bfd%s", VTY_NEWLINE);
6957
ba682537 6958 /* MTU ignore print. */
6959 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
6960 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6961 {
6962 if (params->mtu_ignore == 0)
6963 vty_out (vty, " no ip ospf mtu-ignore");
6964 else
6965 vty_out (vty, " ip ospf mtu-ignore");
6966 if (params != IF_DEF_PARAMS (ifp))
6967 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6968 vty_out (vty, "%s", VTY_NEWLINE);
6969 }
6970
6971
718e3744 6972 while (1)
6973 {
6974 if (rn == NULL)
6975 rn = route_top (IF_OIFS_PARAMS (ifp));
6976 else
6977 rn = route_next (rn);
6978
6979 if (rn == NULL)
6980 break;
6981 params = rn->info;
6982 if (params != NULL)
6983 break;
6984 }
6985 } while (rn);
6986
6987#ifdef HAVE_OPAQUE_LSA
6988 ospf_opaque_config_write_if (vty, ifp);
6989#endif /* HAVE_OPAQUE_LSA */
6990 }
6991
6992 return write;
6993}
6994
4dadc291 6995static int
68980084 6996config_write_network_area (struct vty *vty, struct ospf *ospf)
718e3744 6997{
6998 struct route_node *rn;
6999 u_char buf[INET_ADDRSTRLEN];
7000
7001 /* `network area' print. */
68980084 7002 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
718e3744 7003 if (rn->info)
7004 {
7005 struct ospf_network *n = rn->info;
7006
7007 memset (buf, 0, INET_ADDRSTRLEN);
7008
7009 /* Create Area ID string by specified Area ID format. */
7010 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
c9e52be3 7011 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
718e3744 7012 else
c9e52be3 7013 sprintf ((char *) buf, "%lu",
718e3744 7014 (unsigned long int) ntohl (n->area_id.s_addr));
7015
7016 /* Network print. */
7017 vty_out (vty, " network %s/%d area %s%s",
7018 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7019 buf, VTY_NEWLINE);
7020 }
7021
7022 return 0;
7023}
7024
4dadc291 7025static int
68980084 7026config_write_ospf_area (struct vty *vty, struct ospf *ospf)
718e3744 7027{
52dc7ee6 7028 struct listnode *node;
1eb8ef25 7029 struct ospf_area *area;
718e3744 7030 u_char buf[INET_ADDRSTRLEN];
7031
7032 /* Area configuration print. */
1eb8ef25 7033 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 7034 {
718e3744 7035 struct route_node *rn1;
7036
c9e52be3 7037 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
718e3744 7038
7039 if (area->auth_type != OSPF_AUTH_NULL)
7040 {
7041 if (area->auth_type == OSPF_AUTH_SIMPLE)
7042 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7043 else
7044 vty_out (vty, " area %s authentication message-digest%s",
7045 buf, VTY_NEWLINE);
7046 }
7047
7048 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7049 vty_out (vty, " area %s shortcut %s%s", buf,
7050 ospf_shortcut_mode_str[area->shortcut_configured],
7051 VTY_NEWLINE);
7052
7053 if ((area->external_routing == OSPF_AREA_STUB)
718e3744 7054 || (area->external_routing == OSPF_AREA_NSSA)
718e3744 7055 )
7056 {
b0a053be 7057 if (area->external_routing == OSPF_AREA_STUB)
7058 vty_out (vty, " area %s stub", buf);
b0a053be 7059 else if (area->external_routing == OSPF_AREA_NSSA)
7060 {
7061 vty_out (vty, " area %s nssa", buf);
7062 switch (area->NSSATranslatorRole)
7063 {
7064 case OSPF_NSSA_ROLE_NEVER:
7065 vty_out (vty, " translate-never");
7066 break;
7067 case OSPF_NSSA_ROLE_ALWAYS:
7068 vty_out (vty, " translate-always");
7069 break;
7070 case OSPF_NSSA_ROLE_CANDIDATE:
7071 default:
7072 vty_out (vty, " translate-candidate");
7073 }
7074 }
718e3744 7075
7076 if (area->no_summary)
7077 vty_out (vty, " no-summary");
7078
7079 vty_out (vty, "%s", VTY_NEWLINE);
7080
7081 if (area->default_cost != 1)
7082 vty_out (vty, " area %s default-cost %d%s", buf,
7083 area->default_cost, VTY_NEWLINE);
7084 }
7085
7086 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7087 if (rn1->info)
7088 {
7089 struct ospf_area_range *range = rn1->info;
7090
7091 vty_out (vty, " area %s range %s/%d", buf,
7092 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7093
6c835671 7094 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
718e3744 7095 vty_out (vty, " cost %d", range->cost_config);
7096
7097 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7098 vty_out (vty, " not-advertise");
7099
7100 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7101 vty_out (vty, " substitute %s/%d",
7102 inet_ntoa (range->subst_addr), range->subst_masklen);
7103
7104 vty_out (vty, "%s", VTY_NEWLINE);
7105 }
7106
7107 if (EXPORT_NAME (area))
7108 vty_out (vty, " area %s export-list %s%s", buf,
7109 EXPORT_NAME (area), VTY_NEWLINE);
7110
7111 if (IMPORT_NAME (area))
7112 vty_out (vty, " area %s import-list %s%s", buf,
7113 IMPORT_NAME (area), VTY_NEWLINE);
7114
7115 if (PREFIX_NAME_IN (area))
7116 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7117 PREFIX_NAME_IN (area), VTY_NEWLINE);
7118
7119 if (PREFIX_NAME_OUT (area))
7120 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7121 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7122 }
7123
7124 return 0;
7125}
7126
4dadc291 7127static int
68980084 7128config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
718e3744 7129{
7130 struct ospf_nbr_nbma *nbr_nbma;
7131 struct route_node *rn;
7132
7133 /* Static Neighbor configuration print. */
68980084 7134 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
718e3744 7135 if ((nbr_nbma = rn->info))
7136 {
7137 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7138
7139 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7140 vty_out (vty, " priority %d", nbr_nbma->priority);
7141
7142 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7143 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7144
7145 vty_out (vty, "%s", VTY_NEWLINE);
7146 }
7147
7148 return 0;
7149}
7150
4dadc291 7151static int
68980084 7152config_write_virtual_link (struct vty *vty, struct ospf *ospf)
718e3744 7153{
52dc7ee6 7154 struct listnode *node;
1eb8ef25 7155 struct ospf_vl_data *vl_data;
718e3744 7156 u_char buf[INET_ADDRSTRLEN];
7157
7158 /* Virtual-Link print */
1eb8ef25 7159 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
718e3744 7160 {
52dc7ee6 7161 struct listnode *n2;
718e3744 7162 struct crypt_key *ck;
718e3744 7163 struct ospf_interface *oi;
7164
7165 if (vl_data != NULL)
7166 {
7167 memset (buf, 0, INET_ADDRSTRLEN);
7168
7169 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
c9e52be3 7170 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
718e3744 7171 else
c9e52be3 7172 sprintf ((char *) buf, "%lu",
718e3744 7173 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7174 oi = vl_data->vl_oi;
7175
7176 /* timers */
7177 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7178 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7179 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7180 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7181 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7182 buf,
7183 inet_ntoa (vl_data->vl_peer),
7184 OSPF_IF_PARAM (oi, v_hello),
7185 OSPF_IF_PARAM (oi, retransmit_interval),
7186 OSPF_IF_PARAM (oi, transmit_delay),
7187 OSPF_IF_PARAM (oi, v_wait),
7188 VTY_NEWLINE);
7189 else
7190 vty_out (vty, " area %s virtual-link %s%s", buf,
7191 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7192 /* Auth key */
7193 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7194 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7195 buf,
7196 inet_ntoa (vl_data->vl_peer),
7197 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7198 VTY_NEWLINE);
7199 /* md5 keys */
1eb8ef25 7200 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7201 n2, ck))
7202 vty_out (vty, " area %s virtual-link %s"
7203 " message-digest-key %d md5 %s%s",
7204 buf,
7205 inet_ntoa (vl_data->vl_peer),
7206 ck->key_id, ck->auth_key, VTY_NEWLINE);
718e3744 7207
7208 }
7209 }
7210
7211 return 0;
7212}
7213
6b0655a2 7214
4dadc291 7215static int
68980084 7216config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
718e3744 7217{
7218 int type;
7219
7220 /* redistribute print. */
7221 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7222 if (type != zclient->redist_default && zclient->redist[type])
7223 {
f52d13cb 7224 vty_out (vty, " redistribute %s", zebra_route_string(type));
68980084 7225 if (ospf->dmetric[type].value >= 0)
020709f9 7226 vty_out (vty, " metric %d", ospf->dmetric[type].value);
718e3744 7227
68980084 7228 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
718e3744 7229 vty_out (vty, " metric-type 1");
7230
020709f9 7231 if (ROUTEMAP_NAME (ospf, type))
7232 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
718e3744 7233
7234 vty_out (vty, "%s", VTY_NEWLINE);
7235 }
7236
7237 return 0;
7238}
7239
4dadc291 7240static int
68980084 7241config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
718e3744 7242{
68980084 7243 if (ospf->default_metric != -1)
7244 vty_out (vty, " default-metric %d%s", ospf->default_metric,
718e3744 7245 VTY_NEWLINE);
7246 return 0;
7247}
7248
4dadc291 7249static int
68980084 7250config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
718e3744 7251{
7252 int type;
7253
68980084 7254 if (ospf)
718e3744 7255 {
7256 /* distribute-list print. */
7257 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
171c9a99 7258 if (DISTRIBUTE_NAME (ospf, type))
718e3744 7259 vty_out (vty, " distribute-list %s out %s%s",
171c9a99 7260 DISTRIBUTE_NAME (ospf, type),
f52d13cb 7261 zebra_route_string(type), VTY_NEWLINE);
718e3744 7262
7263 /* default-information print. */
68980084 7264 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
718e3744 7265 {
c42c177d 7266 vty_out (vty, " default-information originate");
7267 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7268 vty_out (vty, " always");
718e3744 7269
68980084 7270 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
718e3744 7271 vty_out (vty, " metric %d",
68980084 7272 ospf->dmetric[DEFAULT_ROUTE].value);
7273 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
718e3744 7274 vty_out (vty, " metric-type 1");
7275
020709f9 7276 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7277 vty_out (vty, " route-map %s",
7278 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
718e3744 7279
7280 vty_out (vty, "%s", VTY_NEWLINE);
7281 }
7282
7283 }
7284
7285 return 0;
7286}
7287
4dadc291 7288static int
68980084 7289config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
718e3744 7290{
7291 struct route_node *rn;
7292 struct ospf_distance *odistance;
7293
68980084 7294 if (ospf->distance_all)
7295 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
718e3744 7296
68980084 7297 if (ospf->distance_intra
7298 || ospf->distance_inter
7299 || ospf->distance_external)
718e3744 7300 {
7301 vty_out (vty, " distance ospf");
7302
68980084 7303 if (ospf->distance_intra)
7304 vty_out (vty, " intra-area %d", ospf->distance_intra);
7305 if (ospf->distance_inter)
7306 vty_out (vty, " inter-area %d", ospf->distance_inter);
7307 if (ospf->distance_external)
7308 vty_out (vty, " external %d", ospf->distance_external);
718e3744 7309
7310 vty_out (vty, "%s", VTY_NEWLINE);
7311 }
7312
68980084 7313 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
718e3744 7314 if ((odistance = rn->info) != NULL)
7315 {
7316 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7317 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7318 odistance->access_list ? odistance->access_list : "",
7319 VTY_NEWLINE);
7320 }
7321 return 0;
7322}
7323
7324/* OSPF configuration write function. */
4dadc291 7325static int
718e3744 7326ospf_config_write (struct vty *vty)
7327{
020709f9 7328 struct ospf *ospf;
1eb8ef25 7329 struct interface *ifp;
7330 struct ospf_interface *oi;
52dc7ee6 7331 struct listnode *node;
718e3744 7332 int write = 0;
7333
020709f9 7334 ospf = ospf_lookup ();
68980084 7335 if (ospf != NULL)
718e3744 7336 {
7337 /* `router ospf' print. */
7338 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7339
7340 write++;
7341
68980084 7342 if (!ospf->networks)
718e3744 7343 return write;
7344
7345 /* Router ID print. */
68980084 7346 if (ospf->router_id_static.s_addr != 0)
718e3744 7347 vty_out (vty, " ospf router-id %s%s",
68980084 7348 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
718e3744 7349
7350 /* ABR type print. */
d57834f6 7351 if (ospf->abr_type != OSPF_ABR_DEFAULT)
718e3744 7352 vty_out (vty, " ospf abr-type %s%s",
68980084 7353 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
718e3744 7354
d7e60dd7
AS
7355 /* log-adjacency-changes flag print. */
7356 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7357 {
7358 vty_out(vty, " log-adjacency-changes");
7359 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7360 vty_out(vty, " detail");
7361 vty_out(vty, "%s", VTY_NEWLINE);
7362 }
7363
718e3744 7364 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
68980084 7365 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
718e3744 7366 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7367
7368 /* auto-cost reference-bandwidth configuration. */
68980084 7369 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
f9ad937f 7370 {
7371 vty_out (vty, "! Important: ensure reference bandwidth "
7372 "is consistent across all routers%s", VTY_NEWLINE);
7373 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7374 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7375 }
718e3744 7376
7377 /* SPF timers print. */
68980084 7378 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
ea4ffc90 7379 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7380 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7381 vty_out (vty, " timers throttle spf %d %d %d%s",
88d6cf37 7382 ospf->spf_delay, ospf->spf_holdtime,
ea4ffc90 7383 ospf->spf_max_holdtime, VTY_NEWLINE);
88d6cf37 7384
2f8f370e 7385 /* Write multiplier print. */
e8f45e82 7386 if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT)
2f8f370e 7387 vty_out (vty, " ospf write-multiplier %d%s",
e8f45e82 7388 ospf->write_oi_count, VTY_NEWLINE);
2f8f370e 7389
88d6cf37 7390 /* Max-metric router-lsa print */
7391 config_write_stub_router (vty, ospf);
7392
718e3744 7393 /* SPF refresh parameters print. */
68980084 7394 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
718e3744 7395 vty_out (vty, " refresh timer %d%s",
68980084 7396 ospf->lsa_refresh_interval, VTY_NEWLINE);
718e3744 7397
7398 /* Redistribute information print. */
68980084 7399 config_write_ospf_redistribute (vty, ospf);
718e3744 7400
7401 /* passive-interface print. */
7ffa8fa2
PJ
7402 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
7403 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
7404
1eb8ef25 7405 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7ffa8fa2
PJ
7406 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
7407 && IF_DEF_PARAMS (ifp)->passive_interface !=
7408 ospf->passive_interface_default)
7409 {
7410 vty_out (vty, " %spassive-interface %s%s",
7411 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
7412 ifp->name, VTY_NEWLINE);
7413 }
1eb8ef25 7414 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7ffa8fa2
PJ
7415 {
7416 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
7417 continue;
7418 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
7419 passive_interface))
7420 {
7421 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
7422 continue;
7423 }
7424 else if (oi->params->passive_interface == ospf->passive_interface_default)
7425 continue;
7426
7427 vty_out (vty, " %spassive-interface %s %s%s",
7428 oi->params->passive_interface ? "" : "no ",
1eb8ef25 7429 oi->ifp->name,
7430 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
7ffa8fa2 7431 }
718e3744 7432
7433 /* Network area print. */
68980084 7434 config_write_network_area (vty, ospf);
718e3744 7435
7436 /* Area config print. */
68980084 7437 config_write_ospf_area (vty, ospf);
718e3744 7438
7439 /* static neighbor print. */
68980084 7440 config_write_ospf_nbr_nbma (vty, ospf);
718e3744 7441
7442 /* Virtual-Link print. */
68980084 7443 config_write_virtual_link (vty, ospf);
718e3744 7444
7445 /* Default metric configuration. */
68980084 7446 config_write_ospf_default_metric (vty, ospf);
718e3744 7447
7448 /* Distribute-list and default-information print. */
68980084 7449 config_write_ospf_distribute (vty, ospf);
718e3744 7450
7451 /* Distance configuration. */
68980084 7452 config_write_ospf_distance (vty, ospf);
718e3744 7453
7454#ifdef HAVE_OPAQUE_LSA
68980084 7455 ospf_opaque_config_write_router (vty, ospf);
718e3744 7456#endif /* HAVE_OPAQUE_LSA */
7457 }
7458
7459 return write;
7460}
7461
7462void
4dadc291 7463ospf_vty_show_init (void)
718e3744 7464{
7465 /* "show ip ospf" commands. */
7466 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7467 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7468
7469 /* "show ip ospf database" commands. */
7470 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7471 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7472 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7473 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7474 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7475 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7476 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7477 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7478 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7479 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7480 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7481 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7482 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7483 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7484
7485 /* "show ip ospf interface" commands. */
7486 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7487 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7488
7489 /* "show ip ospf neighbor" commands. */
7490 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7491 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7492 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7493 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7494 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7495 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7496 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7497 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7498 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7499 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7500 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7501 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7502 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7503 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7504
7505 /* "show ip ospf route" commands. */
7506 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7507 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
718e3744 7508 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7509 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
718e3744 7510}
7511
6b0655a2 7512
718e3744 7513/* ospfd's interface node. */
7fc626de 7514static struct cmd_node interface_node =
718e3744 7515{
7516 INTERFACE_NODE,
7517 "%s(config-if)# ",
7518 1
7519};
7520
7521/* Initialization of OSPF interface. */
4dadc291 7522static void
7523ospf_vty_if_init (void)
718e3744 7524{
7525 /* Install interface node. */
7526 install_node (&interface_node, config_write_interface);
7527
7528 install_element (CONFIG_NODE, &interface_cmd);
32d2463c 7529 install_element (CONFIG_NODE, &no_interface_cmd);
718e3744 7530 install_default (INTERFACE_NODE);
7531
7532 /* "description" commands. */
7533 install_element (INTERFACE_NODE, &interface_desc_cmd);
7534 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7535
7536 /* "ip ospf authentication" commands. */
7537 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7538 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7539 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7540 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7541 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7542 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7543 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7544 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7545 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7546 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7547
7548 /* "ip ospf message-digest-key" commands. */
7549 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7550 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7551 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7552 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7553
7554 /* "ip ospf cost" commands. */
9eff36b3
DO
7555 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
7556 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
827341b7
DO
7557 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
7558 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
9eff36b3 7559 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
718e3744 7560 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7561
ba682537 7562 /* "ip ospf mtu-ignore" commands. */
7563 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7564 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7565 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7566 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7567
718e3744 7568 /* "ip ospf dead-interval" commands. */
7569 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7570 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
f9ad937f 7571 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7572 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
718e3744 7573 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7574 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
f9ad937f 7575
718e3744 7576 /* "ip ospf hello-interval" commands. */
7577 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7578 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7579 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7580 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7581
7582 /* "ip ospf network" commands. */
7583 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7584 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7585
7586 /* "ip ospf priority" commands. */
7587 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7588 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7589 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7590 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7591
7592 /* "ip ospf retransmit-interval" commands. */
7593 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7594 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7595 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7596 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7597
7598 /* "ip ospf transmit-delay" commands. */
7599 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7600 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7601 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7602 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7603
7604 /* These commands are compatibitliy for previous version. */
7605 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7606 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7607 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7608 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
9eff36b3
DO
7609 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
7610 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
718e3744 7611 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
827341b7
DO
7612 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
7613 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
9eff36b3 7614 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
718e3744 7615 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7616 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7617 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7618 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7619 install_element (INTERFACE_NODE, &ospf_network_cmd);
7620 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7621 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7622 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7623 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7624 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7625 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7626 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
d5a5c8f0
DS
7627 install_element (INTERFACE_NODE, &ip_ospf_bfd_cmd);
7628 install_element (INTERFACE_NODE, &no_ip_ospf_bfd_cmd);
718e3744 7629}
7630
4dadc291 7631static void
7632ospf_vty_zebra_init (void)
718e3744 7633{
718e3744 7634 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
718e3744 7635 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7636
7637 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7638 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7639
718e3744 7640 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
718e3744 7641 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7642
7643 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7644 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7645 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7646
7647 install_element (OSPF_NODE, &ospf_distance_cmd);
7648 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7649 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
6f2a6703 7650 install_element (OSPF_NODE, &ospf_distance_ospf_cmd);
718e3744 7651#if 0
7652 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7653 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7654 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7655 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7656#endif /* 0 */
7657}
7658
7fc626de 7659static struct cmd_node ospf_node =
718e3744 7660{
7661 OSPF_NODE,
7662 "%s(config-router)# ",
7663 1
7664};
7665
09f35f8c
DS
7666static void
7667ospf_interface_clear (struct interface *ifp)
7668{
7669 if (!if_is_operative (ifp)) return;
7670
7671 if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
7672 zlog (NULL, LOG_DEBUG, "ISM[%s]: clear by reset", ifp->name);
7673
7674 ospf_if_reset(ifp);
7675}
7676
7677DEFUN (clear_ip_ospf_interface,
7678 clear_ip_ospf_interface_cmd,
7679 "clear ip ospf interface [IFNAME]",
7680 CLEAR_STR
7681 IP_STR
7682 "OSPF information\n"
7683 "Interface information\n"
7684 "Interface name\n")
7685{
7686 struct interface *ifp;
7687 struct listnode *node;
7688
7689 if (argc == 0) /* Clear all the ospfv2 interfaces. */
7690 {
7691 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
7692 ospf_interface_clear(ifp);
7693 }
7694 else /* Interface name is specified. */
7695 {
7696 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
7697 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
7698 else
7699 ospf_interface_clear(ifp);
7700 }
7701
7702 return CMD_SUCCESS;
7703}
7704
7705void
7706ospf_vty_clear_init (void)
7707{
7708 install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd);
7709}
7710
6b0655a2 7711
718e3744 7712/* Install OSPF related vty commands. */
7713void
4dadc291 7714ospf_vty_init (void)
718e3744 7715{
7716 /* Install ospf top node. */
7717 install_node (&ospf_node, ospf_config_write);
7718
7719 /* "router ospf" commands. */
7720 install_element (CONFIG_NODE, &router_ospf_cmd);
7721 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7722
7723 install_default (OSPF_NODE);
7724
7725 /* "ospf router-id" commands. */
7726 install_element (OSPF_NODE, &ospf_router_id_cmd);
7727 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
a2c62831 7728 install_element (OSPF_NODE, &router_ospf_id_cmd);
7729 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
718e3744 7730
7731 /* "passive-interface" commands. */
a2c62831 7732 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7733 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7ffa8fa2 7734 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
a2c62831 7735 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7736 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
7ffa8fa2 7737 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
718e3744 7738
7739 /* "ospf abr-type" commands. */
7740 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7741 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7742
d7e60dd7
AS
7743 /* "ospf log-adjacency-changes" commands. */
7744 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
7745 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
7746 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
7747 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
7748
718e3744 7749 /* "ospf rfc1583-compatible" commands. */
7750 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7751 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7752 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7753 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7754
7755 /* "network area" commands. */
a2c62831 7756 install_element (OSPF_NODE, &ospf_network_area_cmd);
7757 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
718e3744 7758
7759 /* "area authentication" commands. */
a2c62831 7760 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7761 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7762 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
718e3744 7763
7764 /* "area range" commands. */
a2c62831 7765 install_element (OSPF_NODE, &ospf_area_range_cmd);
7766 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7767 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7768 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7769 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7770 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7771 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7772 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7773 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7774 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7775 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
718e3744 7776
7777 /* "area virtual-link" commands. */
a2c62831 7778 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7779 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
718e3744 7780
a2c62831 7781 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7782 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
718e3744 7783
a2c62831 7784 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7785 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
718e3744 7786
a2c62831 7787 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7788 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
718e3744 7789
a2c62831 7790 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7791 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
718e3744 7792
a2c62831 7793 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7794 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7795 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
718e3744 7796
a2c62831 7797 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7798 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
718e3744 7799
a2c62831 7800 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7801 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
718e3744 7802
a2c62831 7803 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7804 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7805 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
718e3744 7806
a2c62831 7807 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7808 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7809 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
718e3744 7810
7811 /* "area stub" commands. */
a2c62831 7812 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7813 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7814 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7815 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
718e3744 7816
718e3744 7817 /* "area nssa" commands. */
a2c62831 7818 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7819 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7820 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7821 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7822 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7823 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
718e3744 7824
a2c62831 7825 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7826 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
718e3744 7827
a2c62831 7828 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7829 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
718e3744 7830
a2c62831 7831 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7832 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
718e3744 7833
a2c62831 7834 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7835 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
718e3744 7836
a2c62831 7837 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7838 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
88d6cf37 7839
7840 /* SPF timer commands */
a2c62831 7841 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7842 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
d24f6e2a 7843 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
7844 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
7845
88d6cf37 7846 /* refresh timer commands */
a2c62831 7847 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7848 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7849 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
718e3744 7850
88d6cf37 7851 /* max-metric commands */
7852 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
7853 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
7854 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
7855 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
7856 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
7857 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
7858
7859 /* reference bandwidth commands */
a2c62831 7860 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7861 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
718e3744 7862
7863 /* "neighbor" commands. */
a2c62831 7864 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7865 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7866 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7867 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7868 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7869 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7870 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7871 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
718e3744 7872
2f8f370e
DS
7873 /* write multiplier commands */
7874 install_element (OSPF_NODE, &ospf_write_multiplier_cmd);
7875 install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd);
e8f45e82
DS
7876 install_element (OSPF_NODE, &write_multiplier_cmd);
7877 install_element (OSPF_NODE, &no_write_multiplier_cmd);
2f8f370e 7878
718e3744 7879 /* Init interface related vty commands. */
7880 ospf_vty_if_init ();
7881
7882 /* Init zebra related vty commands. */
7883 ospf_vty_zebra_init ();
7884}