blob: 45a19c0965ccef838409d8ff5e4eb72fd38c0b63 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* OSPF VTY interface.
vincentba682532005-09-29 13:52:57 +00002 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
paul718e3742002-12-13 20:15:29 +00003 * 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
David Lamparter6b0655a2014-06-04 06:53:35 +020052
Paul Jakma30a22312008-08-15 14:05:22 +010053static const char *ospf_network_type_str[] =
paul718e3742002-12-13 20:15:29 +000054{
55 "Null",
56 "POINTOPOINT",
57 "BROADCAST",
58 "NBMA",
59 "POINTOMULTIPOINT",
60 "VIRTUALLINK",
61 "LOOPBACK"
62};
63
David Lamparter6b0655a2014-06-04 06:53:35 +020064
paul718e3742002-12-13 20:15:29 +000065/* Utility functions. */
paul4dadc292005-05-06 21:37:42 +000066static int
paul6c835672004-10-11 11:00:30 +000067ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
paul718e3742002-12-13 20:15:29 +000068{
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 {
Ulrich Weber664711c2011-12-21 02:24:11 +040083 if (*str == '-')
84 return -1;
85 errno = 0;
paul718e3742002-12-13 20:15:29 +000086 ret = strtoul (str, &endptr, 10);
Ulrich Weber664711c2011-12-21 02:24:11 +040087 if (*endptr != '\0' || errno || ret > UINT32_MAX)
paul718e3742002-12-13 20:15:29 +000088 return -1;
89
90 area_id->s_addr = htonl (ret);
91 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
92 }
93
94 return 0;
95}
96
David Lamparter6b0655a2014-06-04 06:53:35 +020097
paul4dadc292005-05-06 21:37:42 +000098static int
paul6c835672004-10-11 11:00:30 +000099str2metric (const char *str, int *metric)
paul718e3742002-12-13 20:15:29 +0000100{
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
paul4dadc292005-05-06 21:37:42 +0000115static int
paul6c835672004-10-11 11:00:30 +0000116str2metric_type (const char *str, int *metric_type)
paul718e3742002-12-13 20:15:29 +0000117{
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
David Lamparter6b0655a2014-06-04 06:53:35 +0200145
paul718e3742002-12-13 20:15:29 +0000146DEFUN (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{
paul020709f2003-04-04 02:44:16 +0000165 struct ospf *ospf;
166
167 ospf = ospf_lookup ();
168 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +0000169 {
paul020709f2003-04-04 02:44:16 +0000170 vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +0000171 return CMD_WARNING;
172 }
173
paul020709f2003-04-04 02:44:16 +0000174 ospf_finish (ospf);
paul718e3742002-12-13 20:15:29 +0000175
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{
paul68980082003-03-25 05:07:42 +0000186 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000187 struct in_addr router_id;
paul68980082003-03-25 05:07:42 +0000188 int ret;
paul718e3742002-12-13 20:15:29 +0000189
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
paul68980082003-03-25 05:07:42 +0000197 ospf->router_id_static = router_id;
paulb29800a2005-11-20 14:50:45 +0000198
199 ospf_router_id_update (ospf);
200
paul718e3742002-12-13 20:15:29 +0000201 return CMD_SUCCESS;
202}
203
204ALIAS (ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000205 router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000206 "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{
paul68980082003-03-25 05:07:42 +0000217 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000218
paul68980082003-03-25 05:07:42 +0000219 ospf->router_id_static.s_addr = 0;
220
221 ospf_router_id_update (ospf);
paul718e3742002-12-13 20:15:29 +0000222
223 return CMD_SUCCESS;
224}
225
226ALIAS (no_ospf_router_id,
paula2c62832003-04-23 17:01:31 +0000227 no_router_ospf_id_cmd,
paul718e3742002-12-13 20:15:29 +0000228 "no router-id",
229 NO_STR
230 "router-id for the OSPF process\n")
231
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000232static void
Andrew J. Schorr43540882006-11-28 16:36:39 +0000233ospf_passive_interface_default (struct ospf *ospf, u_char newval)
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000234{
235 struct listnode *ln;
236 struct interface *ifp;
237 struct ospf_interface *oi;
238
Andrew J. Schorr43540882006-11-28 16:36:39 +0000239 ospf->passive_interface_default = newval;
240
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000241 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);
Andrew J. Schorr43540882006-11-28 16:36:39 +0000251 /* update multicast memberships */
252 ospf_if_set_multicast(oi);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000253 }
254}
255
256static void
Paul Jakmae1bcd472014-09-19 16:41:10 +0100257ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp,
258 struct ospf_if_params *params, u_char value,
259 struct in_addr addr)
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000260{
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 }
Paul Jakmae1bcd472014-09-19 16:41:10 +0100279}
280
281static void
282ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
283 struct ospf_if_params *params, u_char value)
284{
285 params->passive_interface = value;
286 if (params == IF_DEF_PARAMS (ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000287 {
288 if (value != ospf->passive_interface_default)
289 SET_IF_PARAM (params, passive_interface);
290 else
291 UNSET_IF_PARAM (params, passive_interface);
292 }
293}
294
Paul Jakma8a667cf2009-08-27 16:51:42 +0100295/* get the appropriate ospf parameters structure, checking if
296 * there's a valid interface address at the argi'th argv index
297 */
298enum {
299 VTY_SET = 0,
300 VTY_UNSET,
301};
302#define OSPF_VTY_GET_IF_PARAMS(ifp,params,argi,addr,set) \
303 (params) = IF_DEF_PARAMS ((ifp)); \
304 \
305 if (argc == (argi) + 1) \
306 { \
307 int ret = inet_aton(argv[(argi)], &(addr)); \
308 if (!ret) \
309 { \
310 vty_out (vty, "Please specify interface address by A.B.C.D%s", \
311 VTY_NEWLINE); \
312 return CMD_WARNING; \
313 } \
314 (params) = ospf_get_if_params ((ifp), (addr)); \
315 \
316 if (set) \
317 ospf_if_update_params ((ifp), (addr)); \
318 else if ((params) == NULL) \
319 return CMD_SUCCESS; \
320 }
321
322#define OSPF_VTY_PARAM_UNSET(params,var,ifp,addr) \
323 UNSET_IF_PARAM ((params), var); \
324 if ((params) != IF_DEF_PARAMS ((ifp))) \
325 { \
326 ospf_free_if_params ((ifp), (addr)); \
327 ospf_if_update_params ((ifp), (addr)); \
328 }
329
paula2c62832003-04-23 17:01:31 +0000330DEFUN (ospf_passive_interface,
331 ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000332 "passive-interface IFNAME A.B.C.D",
333 "Suppress routing updates on an interface\n"
334 "Interface's name\n")
335{
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000336 struct interface *ifp;
337 struct in_addr addr;
338 int ret;
339 struct ospf_if_params *params;
340 struct route_node *rn;
341 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000342
Andrew J. Schorr43540882006-11-28 16:36:39 +0000343 if (argc == 0)
344 {
345 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
346 return CMD_SUCCESS;
347 }
348
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000349 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000350
351 params = IF_DEF_PARAMS (ifp);
352
Andrew J. Schorr43540882006-11-28 16:36:39 +0000353 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000354 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000355 ret = inet_aton(argv[1], &addr);
356 if (!ret)
357 {
358 vty_out (vty, "Please specify interface address by A.B.C.D%s",
359 VTY_NEWLINE);
360 return CMD_WARNING;
361 }
paul718e3742002-12-13 20:15:29 +0000362
Andrew J. Schorr43540882006-11-28 16:36:39 +0000363 params = ospf_get_if_params (ifp, addr);
364 ospf_if_update_params (ifp, addr);
Paul Jakmae1bcd472014-09-19 16:41:10 +0100365 ospf_passive_interface_update_addr (ospf, ifp, params,
366 OSPF_IF_PASSIVE, addr);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000367 }
Paul Jakmae1bcd472014-09-19 16:41:10 +0100368
369 ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE);
Andrew J. Schorr43540882006-11-28 16:36:39 +0000370
ajsba6454e2005-02-08 15:37:30 +0000371 /* XXX We should call ospf_if_set_multicast on exactly those
372 * interfaces for which the passive property changed. It is too much
373 * work to determine this set, so we do this for every interface.
374 * This is safe and reasonable because ospf_if_set_multicast uses a
375 * record of joined groups to avoid systems calls if the desired
376 * memberships match the current memership.
377 */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000378
ajsba6454e2005-02-08 15:37:30 +0000379 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
380 {
381 struct ospf_interface *oi = rn->info;
382
383 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
Andrew J. Schorr43540882006-11-28 16:36:39 +0000384 ospf_if_set_multicast(oi);
ajsba6454e2005-02-08 15:37:30 +0000385 }
386 /*
387 * XXX It is not clear what state transitions the interface needs to
388 * undergo when going from active to passive. Fixing this will
389 * require precise identification of interfaces having such a
390 * transition.
391 */
392
paul718e3742002-12-13 20:15:29 +0000393 return CMD_SUCCESS;
394}
395
paula2c62832003-04-23 17:01:31 +0000396ALIAS (ospf_passive_interface,
397 ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000398 "passive-interface IFNAME",
399 "Suppress routing updates on an interface\n"
400 "Interface's name\n")
401
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000402ALIAS (ospf_passive_interface,
403 ospf_passive_interface_default_cmd,
404 "passive-interface default",
405 "Suppress routing updates on an interface\n"
406 "Suppress routing updates on interfaces by default\n")
407
paula2c62832003-04-23 17:01:31 +0000408DEFUN (no_ospf_passive_interface,
409 no_ospf_passive_interface_addr_cmd,
paul718e3742002-12-13 20:15:29 +0000410 "no passive-interface IFNAME A.B.C.D",
411 NO_STR
412 "Allow routing updates on an interface\n"
413 "Interface's name\n")
414{
415 struct interface *ifp;
416 struct in_addr addr;
417 struct ospf_if_params *params;
418 int ret;
ajsba6454e2005-02-08 15:37:30 +0000419 struct route_node *rn;
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000420 struct ospf *ospf = vty->index;
Andrew J. Schorr43540882006-11-28 16:36:39 +0000421
422 if (argc == 0)
423 {
424 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
425 return CMD_SUCCESS;
426 }
paul718e3742002-12-13 20:15:29 +0000427
Andrew J. Schorr6e72cb62006-06-18 00:45:48 +0000428 ifp = if_get_by_name (argv[0]);
paul718e3742002-12-13 20:15:29 +0000429
430 params = IF_DEF_PARAMS (ifp);
431
Andrew J. Schorr43540882006-11-28 16:36:39 +0000432 if (argc == 2)
paul718e3742002-12-13 20:15:29 +0000433 {
Andrew J. Schorr43540882006-11-28 16:36:39 +0000434 ret = inet_aton(argv[1], &addr);
435 if (!ret)
436 {
437 vty_out (vty, "Please specify interface address by A.B.C.D%s",
438 VTY_NEWLINE);
439 return CMD_WARNING;
440 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000441
Andrew J. Schorr43540882006-11-28 16:36:39 +0000442 params = ospf_lookup_if_params (ifp, addr);
443 if (params == NULL)
444 return CMD_SUCCESS;
Paul Jakmae1bcd472014-09-19 16:41:10 +0100445 ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE,
446 addr);
paul718e3742002-12-13 20:15:29 +0000447 }
Paul Jakmae1bcd472014-09-19 16:41:10 +0100448 ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE);
449
ajsba6454e2005-02-08 15:37:30 +0000450 /* XXX We should call ospf_if_set_multicast on exactly those
451 * interfaces for which the passive property changed. It is too much
452 * work to determine this set, so we do this for every interface.
453 * This is safe and reasonable because ospf_if_set_multicast uses a
454 * record of joined groups to avoid systems calls if the desired
455 * memberships match the current memership.
456 */
457 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
458 {
459 struct ospf_interface *oi = rn->info;
460
461 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
462 ospf_if_set_multicast(oi);
463 }
464
paul718e3742002-12-13 20:15:29 +0000465 return CMD_SUCCESS;
466}
467
paula2c62832003-04-23 17:01:31 +0000468ALIAS (no_ospf_passive_interface,
469 no_ospf_passive_interface_cmd,
paul718e3742002-12-13 20:15:29 +0000470 "no passive-interface IFNAME",
471 NO_STR
472 "Allow routing updates on an interface\n"
473 "Interface's name\n")
474
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000475ALIAS (no_ospf_passive_interface,
476 no_ospf_passive_interface_default_cmd,
477 "no passive-interface default",
478 NO_STR
479 "Allow routing updates on an interface\n"
480 "Allow routing updates on interfaces by default\n")
481
paula2c62832003-04-23 17:01:31 +0000482DEFUN (ospf_network_area,
483 ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000484 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
485 "Enable routing on an IP network\n"
486 "OSPF network prefix\n"
487 "Set the OSPF area ID\n"
488 "OSPF area ID in IP address format\n"
489 "OSPF area ID as a decimal value\n")
490{
Paul Jakma8a667cf2009-08-27 16:51:42 +0100491 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000492 struct prefix_ipv4 p;
493 struct in_addr area_id;
494 int ret, format;
495
496 /* Get network prefix and Area ID. */
497 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
498 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
499
500 ret = ospf_network_set (ospf, &p, area_id);
501 if (ret == 0)
502 {
503 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
504 return CMD_WARNING;
505 }
506
507 return CMD_SUCCESS;
508}
509
paula2c62832003-04-23 17:01:31 +0000510DEFUN (no_ospf_network_area,
511 no_ospf_network_area_cmd,
paul718e3742002-12-13 20:15:29 +0000512 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
513 NO_STR
514 "Enable routing on an IP network\n"
515 "OSPF network prefix\n"
516 "Set the OSPF area ID\n"
517 "OSPF area ID in IP address format\n"
518 "OSPF area ID as a decimal value\n")
519{
520 struct ospf *ospf = (struct ospf *) vty->index;
521 struct prefix_ipv4 p;
522 struct in_addr area_id;
523 int ret, format;
524
525 /* Get network prefix and Area ID. */
526 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
527 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
528
529 ret = ospf_network_unset (ospf, &p, area_id);
530 if (ret == 0)
531 {
532 vty_out (vty, "Can't find specified network area configuration.%s",
533 VTY_NEWLINE);
534 return CMD_WARNING;
535 }
536
537 return CMD_SUCCESS;
538}
539
David Lamparter6b0655a2014-06-04 06:53:35 +0200540
paula2c62832003-04-23 17:01:31 +0000541DEFUN (ospf_area_range,
542 ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000543 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
544 "OSPF area parameters\n"
545 "OSPF area ID in IP address format\n"
546 "OSPF area ID as a decimal value\n"
547 "Summarize routes matching address/mask (border routers only)\n"
548 "Area range prefix\n")
549{
550 struct ospf *ospf = vty->index;
551 struct prefix_ipv4 p;
552 struct in_addr area_id;
553 int format;
554 u_int32_t cost;
555
556 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
557 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
558
559 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
560 if (argc > 2)
561 {
paul4dadc292005-05-06 21:37:42 +0000562 VTY_GET_INTEGER ("range cost", cost, argv[2]);
paul718e3742002-12-13 20:15:29 +0000563 ospf_area_range_cost_set (ospf, area_id, &p, cost);
564 }
565
566 return CMD_SUCCESS;
567}
568
paula2c62832003-04-23 17:01:31 +0000569ALIAS (ospf_area_range,
570 ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000571 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
572 "OSPF area parameters\n"
573 "OSPF area ID in IP address format\n"
574 "OSPF area ID as a decimal value\n"
575 "OSPF area range for route advertise (default)\n"
576 "Area range prefix\n"
577 "Advertise this range (default)\n")
578
paula2c62832003-04-23 17:01:31 +0000579ALIAS (ospf_area_range,
580 ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000581 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
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 "User specified metric for this range\n"
588 "Advertised metric for this range\n")
589
paula2c62832003-04-23 17:01:31 +0000590ALIAS (ospf_area_range,
591 ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000592 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
593 "OSPF area parameters\n"
594 "OSPF area ID in IP address format\n"
595 "OSPF area ID as a decimal value\n"
596 "Summarize routes matching address/mask (border routers only)\n"
597 "Area range prefix\n"
598 "Advertise this range (default)\n"
599 "User specified metric for this range\n"
600 "Advertised metric for this range\n")
601
paula2c62832003-04-23 17:01:31 +0000602DEFUN (ospf_area_range_not_advertise,
603 ospf_area_range_not_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000604 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
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 "DoNotAdvertise this range\n")
611{
612 struct ospf *ospf = vty->index;
613 struct prefix_ipv4 p;
614 struct in_addr area_id;
615 int format;
616
617 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
618 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
619
620 ospf_area_range_set (ospf, area_id, &p, 0);
621
622 return CMD_SUCCESS;
623}
624
paula2c62832003-04-23 17:01:31 +0000625DEFUN (no_ospf_area_range,
626 no_ospf_area_range_cmd,
paul718e3742002-12-13 20:15:29 +0000627 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
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{
635 struct ospf *ospf = vty->index;
636 struct prefix_ipv4 p;
637 struct in_addr area_id;
638 int format;
639
640 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
641 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
642
643 ospf_area_range_unset (ospf, area_id, &p);
644
645 return CMD_SUCCESS;
646}
647
paula2c62832003-04-23 17:01:31 +0000648ALIAS (no_ospf_area_range,
649 no_ospf_area_range_advertise_cmd,
paul718e3742002-12-13 20:15:29 +0000650 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
651 NO_STR
652 "OSPF area parameters\n"
653 "OSPF area ID in IP address format\n"
654 "OSPF area ID as a decimal value\n"
655 "Summarize routes matching address/mask (border routers only)\n"
656 "Area range prefix\n"
657 "Advertise this range (default)\n"
658 "DoNotAdvertise this range\n")
659
paula2c62832003-04-23 17:01:31 +0000660ALIAS (no_ospf_area_range,
661 no_ospf_area_range_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000662 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
663 NO_STR
664 "OSPF area parameters\n"
665 "OSPF area ID in IP address format\n"
666 "OSPF area ID as a decimal value\n"
667 "Summarize routes matching address/mask (border routers only)\n"
668 "Area range prefix\n"
669 "User specified metric for this range\n"
670 "Advertised metric for this range\n")
671
paula2c62832003-04-23 17:01:31 +0000672ALIAS (no_ospf_area_range,
673 no_ospf_area_range_advertise_cost_cmd,
paul718e3742002-12-13 20:15:29 +0000674 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
675 NO_STR
676 "OSPF area parameters\n"
677 "OSPF area ID in IP address format\n"
678 "OSPF area ID as a decimal value\n"
679 "Summarize routes matching address/mask (border routers only)\n"
680 "Area range prefix\n"
681 "Advertise this range (default)\n"
682 "User specified metric for this range\n"
683 "Advertised metric for this range\n")
David Lamparter6b0655a2014-06-04 06:53:35 +0200684
paula2c62832003-04-23 17:01:31 +0000685DEFUN (ospf_area_range_substitute,
686 ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000687 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
688 "OSPF area parameters\n"
689 "OSPF area ID in IP address format\n"
690 "OSPF area ID as a decimal value\n"
691 "Summarize routes matching address/mask (border routers only)\n"
692 "Area range prefix\n"
693 "Announce area range as another prefix\n"
694 "Network prefix to be announced instead of range\n")
695{
696 struct ospf *ospf = vty->index;
697 struct prefix_ipv4 p, s;
698 struct in_addr area_id;
699 int format;
700
701 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
702 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
703 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
704
705 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
706
707 return CMD_SUCCESS;
708}
709
paula2c62832003-04-23 17:01:31 +0000710DEFUN (no_ospf_area_range_substitute,
711 no_ospf_area_range_substitute_cmd,
paul718e3742002-12-13 20:15:29 +0000712 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
713 NO_STR
714 "OSPF area parameters\n"
715 "OSPF area ID in IP address format\n"
716 "OSPF area ID as a decimal value\n"
717 "Summarize routes matching address/mask (border routers only)\n"
718 "Area range prefix\n"
719 "Announce area range as another prefix\n"
720 "Network prefix to be announced instead of range\n")
721{
722 struct ospf *ospf = vty->index;
723 struct prefix_ipv4 p, s;
724 struct in_addr area_id;
725 int format;
726
727 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
728 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
729 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
730
731 ospf_area_range_substitute_unset (ospf, area_id, &p);
732
733 return CMD_SUCCESS;
734}
735
David Lamparter6b0655a2014-06-04 06:53:35 +0200736
paul718e3742002-12-13 20:15:29 +0000737/* Command Handler Logic in VLink stuff is delicate!!
738
739 ALTER AT YOUR OWN RISK!!!!
740
741 Various dummy values are used to represent 'NoChange' state for
742 VLink configuration NOT being changed by a VLink command, and
743 special syntax is used within the command strings so that the
744 typed in command verbs can be seen in the configuration command
745 bacckend handler. This is to drastically reduce the verbeage
746 required to coe up with a reasonably compatible Cisco VLink command
747
748 - Matthew Grant <grantma@anathoth.gen.nz>
749 Wed, 21 Feb 2001 15:13:52 +1300
750 */
751
752
753/* Configuration data for virtual links
754 */
755struct ospf_vl_config_data {
756 struct vty *vty; /* vty stuff */
757 struct in_addr area_id; /* area ID from command line */
758 int format; /* command line area ID format */
759 struct in_addr vl_peer; /* command line vl_peer */
760 int auth_type; /* Authehntication type, if given */
761 char *auth_key; /* simple password if present */
762 int crypto_key_id; /* Cryptographic key ID */
763 char *md5_key; /* MD5 authentication key */
764 int hello_interval; /* Obvious what these are... */
765 int retransmit_interval;
766 int transmit_delay;
767 int dead_interval;
768};
769
paul4dadc292005-05-06 21:37:42 +0000770static void
paul718e3742002-12-13 20:15:29 +0000771ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
772 struct vty *vty)
773{
774 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
775 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
776 vl_config->vty = vty;
777}
778
paul4dadc292005-05-06 21:37:42 +0000779static struct ospf_vl_data *
paul68980082003-03-25 05:07:42 +0000780ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000781{
782 struct ospf_area *area;
783 struct ospf_vl_data *vl_data;
784 struct vty *vty;
785 struct in_addr area_id;
786
787 vty = vl_config->vty;
788 area_id = vl_config->area_id;
789
790 if (area_id.s_addr == OSPF_AREA_BACKBONE)
791 {
792 vty_out (vty,
793 "Configuring VLs over the backbone is not allowed%s",
794 VTY_NEWLINE);
795 return NULL;
796 }
paul68980082003-03-25 05:07:42 +0000797 area = ospf_area_get (ospf, area_id, vl_config->format);
paul718e3742002-12-13 20:15:29 +0000798
799 if (area->external_routing != OSPF_AREA_DEFAULT)
800 {
801 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
802 vty_out (vty, "Area %s is %s%s",
803 inet_ntoa (area_id),
paul718e3742002-12-13 20:15:29 +0000804 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000805 VTY_NEWLINE);
806 else
807 vty_out (vty, "Area %ld is %s%s",
808 (u_long)ntohl (area_id.s_addr),
paul718e3742002-12-13 20:15:29 +0000809 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
paul718e3742002-12-13 20:15:29 +0000810 VTY_NEWLINE);
811 return NULL;
812 }
813
Paul Jakma9c27ef92006-05-04 07:32:57 +0000814 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
paul718e3742002-12-13 20:15:29 +0000815 {
816 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
817 if (vl_data->vl_oi == NULL)
818 {
paul68980082003-03-25 05:07:42 +0000819 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
820 ospf_vl_add (ospf, vl_data);
Paul Jakmab6eef002014-10-09 14:19:51 +0100821 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
paul718e3742002-12-13 20:15:29 +0000822 }
823 }
824 return vl_data;
825}
826
827
paul4dadc292005-05-06 21:37:42 +0000828static int
paul718e3742002-12-13 20:15:29 +0000829ospf_vl_set_security (struct ospf_vl_data *vl_data,
830 struct ospf_vl_config_data *vl_config)
831{
832 struct crypt_key *ck;
833 struct vty *vty;
834 struct interface *ifp = vl_data->vl_oi->ifp;
835
836 vty = vl_config->vty;
837
838 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
839 {
840 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
841 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
842 }
843
844 if (vl_config->auth_key)
845 {
846 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000847 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
paul718e3742002-12-13 20:15:29 +0000848 OSPF_AUTH_SIMPLE_SIZE);
849 }
850 else if (vl_config->md5_key)
851 {
852 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
853 != NULL)
854 {
855 vty_out (vty, "OSPF: Key %d already exists%s",
856 vl_config->crypto_key_id, VTY_NEWLINE);
857 return CMD_WARNING;
858 }
859 ck = ospf_crypt_key_new ();
860 ck->key_id = vl_config->crypto_key_id;
861 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +0000862 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +0000863
864 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
865 }
866 else if (vl_config->crypto_key_id != 0)
867 {
868 /* Delete a key */
869
870 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
871 vl_config->crypto_key_id) == NULL)
872 {
873 vty_out (vty, "OSPF: Key %d does not exist%s",
874 vl_config->crypto_key_id, VTY_NEWLINE);
875 return CMD_WARNING;
876 }
877
878 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
879
880 }
881
882 return CMD_SUCCESS;
883}
884
paul4dadc292005-05-06 21:37:42 +0000885static int
paul718e3742002-12-13 20:15:29 +0000886ospf_vl_set_timers (struct ospf_vl_data *vl_data,
887 struct ospf_vl_config_data *vl_config)
888{
889 struct interface *ifp = ifp = vl_data->vl_oi->ifp;
890 /* Virtual Link data initialised to defaults, so only set
891 if a value given */
892 if (vl_config->hello_interval)
893 {
894 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
895 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
896 }
897
898 if (vl_config->dead_interval)
899 {
900 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
901 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
902 }
903
904 if (vl_config->retransmit_interval)
905 {
906 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
907 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
908 }
909
910 if (vl_config->transmit_delay)
911 {
912 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
913 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
914 }
915
916 return CMD_SUCCESS;
917}
918
919
920
921/* The business end of all of the above */
paul4dadc292005-05-06 21:37:42 +0000922static int
paul68980082003-03-25 05:07:42 +0000923ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
paul718e3742002-12-13 20:15:29 +0000924{
925 struct ospf_vl_data *vl_data;
926 int ret;
927
paul68980082003-03-25 05:07:42 +0000928 vl_data = ospf_find_vl_data (ospf, vl_config);
paul718e3742002-12-13 20:15:29 +0000929 if (!vl_data)
930 return CMD_WARNING;
931
932 /* Process this one first as it can have a fatal result, which can
933 only logically occur if the virtual link exists already
934 Thus a command error does not result in a change to the
935 running configuration such as unexpectedly altered timer
936 values etc.*/
937 ret = ospf_vl_set_security (vl_data, vl_config);
938 if (ret != CMD_SUCCESS)
939 return ret;
940
941 /* Set any time based parameters, these area already range checked */
942
943 ret = ospf_vl_set_timers (vl_data, vl_config);
944 if (ret != CMD_SUCCESS)
945 return ret;
946
947 return CMD_SUCCESS;
948
949}
950
951/* This stuff exists to make specifying all the alias commands A LOT simpler
952 */
953#define VLINK_HELPSTR_IPADDR \
954 "OSPF area parameters\n" \
955 "OSPF area ID in IP address format\n" \
956 "OSPF area ID as a decimal value\n" \
957 "Configure a virtual link\n" \
958 "Router ID of the remote ABR\n"
959
960#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
961 "Enable authentication on this virtual link\n" \
962 "dummy string \n"
963
964#define VLINK_HELPSTR_AUTHTYPE_ALL \
965 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
966 "Use null authentication\n" \
967 "Use message-digest authentication\n"
968
969#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
970 "Time between HELLO packets\n" \
971 "Time between retransmitting lost link state advertisements\n" \
972 "Link state transmit delay\n" \
973 "Interval after which a neighbor is declared dead\n"
974
975#define VLINK_HELPSTR_TIME_PARAM \
976 VLINK_HELPSTR_TIME_PARAM_NOSECS \
977 "Seconds\n"
978
979#define VLINK_HELPSTR_AUTH_SIMPLE \
980 "Authentication password (key)\n" \
981 "The OSPF password (key)"
982
983#define VLINK_HELPSTR_AUTH_MD5 \
984 "Message digest authentication password (key)\n" \
985 "dummy string \n" \
986 "Key ID\n" \
987 "Use MD5 algorithm\n" \
988 "The OSPF password (key)"
989
paula2c62832003-04-23 17:01:31 +0000990DEFUN (ospf_area_vlink,
991 ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +0000992 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
993 VLINK_HELPSTR_IPADDR)
994{
paul68980082003-03-25 05:07:42 +0000995 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +0000996 struct ospf_vl_config_data vl_config;
997 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
998 char md5_key[OSPF_AUTH_MD5_SIZE+1];
999 int i;
1000 int ret;
1001
1002 ospf_vl_config_data_init(&vl_config, vty);
1003
1004 /* Read off first 2 parameters and check them */
1005 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
1006 if (ret < 0)
1007 {
1008 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1009 return CMD_WARNING;
1010 }
1011
1012 ret = inet_aton (argv[1], &vl_config.vl_peer);
1013 if (! ret)
1014 {
1015 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1016 VTY_NEWLINE);
1017 return CMD_WARNING;
1018 }
1019
1020 if (argc <=2)
1021 {
1022 /* Thats all folks! - BUGS B. strikes again!!!*/
1023
paul68980082003-03-25 05:07:42 +00001024 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001025 }
1026
1027 /* Deal with other parameters */
1028 for (i=2; i < argc; i++)
1029 {
1030
1031 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1032
1033 switch (argv[i][0])
1034 {
1035
1036 case 'a':
1037 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1038 {
1039 /* authentication-key - this option can occur anywhere on
1040 command line. At start of command line
1041 must check for authentication option. */
1042 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1043 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
1044 vl_config.auth_key = auth_key;
1045 i++;
1046 }
1047 else if (strncmp (argv[i], "authentication", 14) == 0)
1048 {
1049 /* authentication - this option can only occur at start
1050 of command line */
1051 vl_config.auth_type = OSPF_AUTH_SIMPLE;
1052 if ((i+1) < argc)
1053 {
1054 if (strncmp (argv[i+1], "n", 1) == 0)
1055 {
1056 /* "authentication null" */
1057 vl_config.auth_type = OSPF_AUTH_NULL;
1058 i++;
1059 }
1060 else if (strncmp (argv[i+1], "m", 1) == 0
1061 && strcmp (argv[i+1], "message-digest-") != 0)
1062 {
1063 /* "authentication message-digest" */
1064 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1065 i++;
1066 }
1067 }
1068 }
1069 break;
1070
1071 case 'm':
1072 /* message-digest-key */
1073 i++;
1074 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1075 if (vl_config.crypto_key_id < 0)
1076 return CMD_WARNING;
1077 i++;
1078 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
1079 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
1080 vl_config.md5_key = md5_key;
1081 break;
1082
1083 case 'h':
1084 /* Hello interval */
1085 i++;
1086 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1087 if (vl_config.hello_interval < 0)
1088 return CMD_WARNING;
1089 break;
1090
1091 case 'r':
1092 /* Retransmit Interval */
1093 i++;
1094 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1095 if (vl_config.retransmit_interval < 0)
1096 return CMD_WARNING;
1097 break;
1098
1099 case 't':
1100 /* Transmit Delay */
1101 i++;
1102 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1103 if (vl_config.transmit_delay < 0)
1104 return CMD_WARNING;
1105 break;
1106
1107 case 'd':
1108 /* Dead Interval */
1109 i++;
1110 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1111 if (vl_config.dead_interval < 0)
1112 return CMD_WARNING;
1113 break;
1114 }
1115 }
1116
1117
1118 /* Action configuration */
1119
paul68980082003-03-25 05:07:42 +00001120 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001121
1122}
1123
paula2c62832003-04-23 17:01:31 +00001124DEFUN (no_ospf_area_vlink,
1125 no_ospf_area_vlink_cmd,
paul718e3742002-12-13 20:15:29 +00001126 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1127 NO_STR
1128 VLINK_HELPSTR_IPADDR)
1129{
paul68980082003-03-25 05:07:42 +00001130 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001131 struct ospf_area *area;
1132 struct ospf_vl_config_data vl_config;
1133 struct ospf_vl_data *vl_data = NULL;
1134 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1135 int i;
1136 int ret, format;
1137
1138 ospf_vl_config_data_init(&vl_config, vty);
1139
1140 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1141 if (ret < 0)
1142 {
1143 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1144 return CMD_WARNING;
1145 }
1146
paul68980082003-03-25 05:07:42 +00001147 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001148 if (!area)
1149 {
1150 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1151 return CMD_WARNING;
1152 }
1153
1154 ret = inet_aton (argv[1], &vl_config.vl_peer);
1155 if (! ret)
1156 {
1157 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1158 VTY_NEWLINE);
1159 return CMD_WARNING;
1160 }
1161
1162 if (argc <=2)
1163 {
1164 /* Basic VLink no command */
1165 /* Thats all folks! - BUGS B. strikes again!!!*/
Paul Jakma9c27ef92006-05-04 07:32:57 +00001166 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
paul68980082003-03-25 05:07:42 +00001167 ospf_vl_delete (ospf, vl_data);
paul718e3742002-12-13 20:15:29 +00001168
paul68980082003-03-25 05:07:42 +00001169 ospf_area_check_free (ospf, vl_config.area_id);
paul718e3742002-12-13 20:15:29 +00001170
1171 return CMD_SUCCESS;
1172 }
1173
1174 /* If we are down here, we are reseting parameters */
1175
1176 /* Deal with other parameters */
1177 for (i=2; i < argc; i++)
1178 {
paul718e3742002-12-13 20:15:29 +00001179 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1180
1181 switch (argv[i][0])
1182 {
1183
1184 case 'a':
1185 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1186 {
1187 /* authentication-key - this option can occur anywhere on
1188 command line. At start of command line
1189 must check for authentication option. */
1190 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1191 vl_config.auth_key = auth_key;
1192 }
1193 else if (strncmp (argv[i], "authentication", 14) == 0)
1194 {
1195 /* authentication - this option can only occur at start
1196 of command line */
1197 vl_config.auth_type = OSPF_AUTH_NOTSET;
1198 }
1199 break;
1200
1201 case 'm':
1202 /* message-digest-key */
1203 /* Delete one key */
1204 i++;
1205 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1206 if (vl_config.crypto_key_id < 0)
1207 return CMD_WARNING;
1208 vl_config.md5_key = NULL;
1209 break;
1210
1211 case 'h':
1212 /* Hello interval */
1213 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1214 break;
1215
1216 case 'r':
1217 /* Retransmit Interval */
1218 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1219 break;
1220
1221 case 't':
1222 /* Transmit Delay */
1223 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1224 break;
1225
1226 case 'd':
1227 /* Dead Interval */
1228 i++;
1229 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1230 break;
1231 }
1232 }
1233
1234
1235 /* Action configuration */
1236
paul68980082003-03-25 05:07:42 +00001237 return ospf_vl_set (ospf, &vl_config);
paul718e3742002-12-13 20:15:29 +00001238}
1239
paula2c62832003-04-23 17:01:31 +00001240ALIAS (ospf_area_vlink,
1241 ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001242 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1243 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1244 VLINK_HELPSTR_IPADDR
1245 VLINK_HELPSTR_TIME_PARAM)
1246
paula2c62832003-04-23 17:01:31 +00001247ALIAS (no_ospf_area_vlink,
1248 no_ospf_area_vlink_param1_cmd,
paul718e3742002-12-13 20:15:29 +00001249 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1250 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1251 NO_STR
1252 VLINK_HELPSTR_IPADDR
1253 VLINK_HELPSTR_TIME_PARAM)
1254
paula2c62832003-04-23 17:01:31 +00001255ALIAS (ospf_area_vlink,
1256 ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001257 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1258 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1259 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1260 VLINK_HELPSTR_IPADDR
1261 VLINK_HELPSTR_TIME_PARAM
1262 VLINK_HELPSTR_TIME_PARAM)
1263
paula2c62832003-04-23 17:01:31 +00001264ALIAS (no_ospf_area_vlink,
1265 no_ospf_area_vlink_param2_cmd,
paul718e3742002-12-13 20:15:29 +00001266 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1267 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1268 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1269 NO_STR
1270 VLINK_HELPSTR_IPADDR
1271 VLINK_HELPSTR_TIME_PARAM
1272 VLINK_HELPSTR_TIME_PARAM)
1273
paula2c62832003-04-23 17:01:31 +00001274ALIAS (ospf_area_vlink,
1275 ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001276 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1277 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1278 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1279 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1280 VLINK_HELPSTR_IPADDR
1281 VLINK_HELPSTR_TIME_PARAM
1282 VLINK_HELPSTR_TIME_PARAM
1283 VLINK_HELPSTR_TIME_PARAM)
1284
paula2c62832003-04-23 17:01:31 +00001285ALIAS (no_ospf_area_vlink,
1286 no_ospf_area_vlink_param3_cmd,
paul718e3742002-12-13 20:15:29 +00001287 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1288 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1289 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1290 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1291 NO_STR
1292 VLINK_HELPSTR_IPADDR
1293 VLINK_HELPSTR_TIME_PARAM
1294 VLINK_HELPSTR_TIME_PARAM
1295 VLINK_HELPSTR_TIME_PARAM)
1296
paula2c62832003-04-23 17:01:31 +00001297ALIAS (ospf_area_vlink,
1298 ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001299 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1300 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1301 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1302 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1303 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1304 VLINK_HELPSTR_IPADDR
1305 VLINK_HELPSTR_TIME_PARAM
1306 VLINK_HELPSTR_TIME_PARAM
1307 VLINK_HELPSTR_TIME_PARAM
1308 VLINK_HELPSTR_TIME_PARAM)
1309
paula2c62832003-04-23 17:01:31 +00001310ALIAS (no_ospf_area_vlink,
1311 no_ospf_area_vlink_param4_cmd,
paul718e3742002-12-13 20:15:29 +00001312 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1313 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1314 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1315 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
1316 "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
1317 NO_STR
1318 VLINK_HELPSTR_IPADDR
1319 VLINK_HELPSTR_TIME_PARAM
1320 VLINK_HELPSTR_TIME_PARAM
1321 VLINK_HELPSTR_TIME_PARAM
1322 VLINK_HELPSTR_TIME_PARAM)
1323
paula2c62832003-04-23 17:01:31 +00001324ALIAS (ospf_area_vlink,
1325 ospf_area_vlink_authtype_args_cmd,
paul718e3742002-12-13 20:15:29 +00001326 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1327 "(authentication|) (message-digest|null)",
1328 VLINK_HELPSTR_IPADDR
1329 VLINK_HELPSTR_AUTHTYPE_ALL)
1330
paula2c62832003-04-23 17:01:31 +00001331ALIAS (ospf_area_vlink,
1332 ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001333 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1334 "(authentication|)",
1335 VLINK_HELPSTR_IPADDR
1336 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1337
paula2c62832003-04-23 17:01:31 +00001338ALIAS (no_ospf_area_vlink,
1339 no_ospf_area_vlink_authtype_cmd,
paul718e3742002-12-13 20:15:29 +00001340 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1341 "(authentication|)",
1342 NO_STR
1343 VLINK_HELPSTR_IPADDR
1344 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1345
paula2c62832003-04-23 17:01:31 +00001346ALIAS (ospf_area_vlink,
1347 ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001348 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1349 "(message-digest-key|) <1-255> md5 KEY",
1350 VLINK_HELPSTR_IPADDR
1351 VLINK_HELPSTR_AUTH_MD5)
1352
paula2c62832003-04-23 17:01:31 +00001353ALIAS (no_ospf_area_vlink,
1354 no_ospf_area_vlink_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001355 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1356 "(message-digest-key|) <1-255>",
1357 NO_STR
1358 VLINK_HELPSTR_IPADDR
1359 VLINK_HELPSTR_AUTH_MD5)
1360
paula2c62832003-04-23 17:01:31 +00001361ALIAS (ospf_area_vlink,
1362 ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001363 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1364 "(authentication-key|) AUTH_KEY",
1365 VLINK_HELPSTR_IPADDR
1366 VLINK_HELPSTR_AUTH_SIMPLE)
1367
paula2c62832003-04-23 17:01:31 +00001368ALIAS (no_ospf_area_vlink,
1369 no_ospf_area_vlink_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001370 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1371 "(authentication-key|)",
1372 NO_STR
1373 VLINK_HELPSTR_IPADDR
1374 VLINK_HELPSTR_AUTH_SIMPLE)
1375
paula2c62832003-04-23 17:01:31 +00001376ALIAS (ospf_area_vlink,
1377 ospf_area_vlink_authtype_args_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001378 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1379 "(authentication|) (message-digest|null) "
1380 "(authentication-key|) AUTH_KEY",
1381 VLINK_HELPSTR_IPADDR
1382 VLINK_HELPSTR_AUTHTYPE_ALL
1383 VLINK_HELPSTR_AUTH_SIMPLE)
1384
paula2c62832003-04-23 17:01:31 +00001385ALIAS (ospf_area_vlink,
1386 ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001387 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1388 "(authentication|) "
1389 "(authentication-key|) AUTH_KEY",
1390 VLINK_HELPSTR_IPADDR
1391 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1392 VLINK_HELPSTR_AUTH_SIMPLE)
1393
paula2c62832003-04-23 17:01:31 +00001394ALIAS (no_ospf_area_vlink,
1395 no_ospf_area_vlink_authtype_authkey_cmd,
paul718e3742002-12-13 20:15:29 +00001396 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1397 "(authentication|) "
1398 "(authentication-key|)",
1399 NO_STR
1400 VLINK_HELPSTR_IPADDR
1401 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1402 VLINK_HELPSTR_AUTH_SIMPLE)
1403
paula2c62832003-04-23 17:01:31 +00001404ALIAS (ospf_area_vlink,
1405 ospf_area_vlink_authtype_args_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001406 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1407 "(authentication|) (message-digest|null) "
1408 "(message-digest-key|) <1-255> md5 KEY",
1409 VLINK_HELPSTR_IPADDR
1410 VLINK_HELPSTR_AUTHTYPE_ALL
1411 VLINK_HELPSTR_AUTH_MD5)
1412
paula2c62832003-04-23 17:01:31 +00001413ALIAS (ospf_area_vlink,
1414 ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001415 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1416 "(authentication|) "
1417 "(message-digest-key|) <1-255> md5 KEY",
1418 VLINK_HELPSTR_IPADDR
1419 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1420 VLINK_HELPSTR_AUTH_MD5)
1421
paula2c62832003-04-23 17:01:31 +00001422ALIAS (no_ospf_area_vlink,
1423 no_ospf_area_vlink_authtype_md5_cmd,
paul718e3742002-12-13 20:15:29 +00001424 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1425 "(authentication|) "
1426 "(message-digest-key|)",
1427 NO_STR
1428 VLINK_HELPSTR_IPADDR
1429 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1430 VLINK_HELPSTR_AUTH_MD5)
1431
David Lamparter6b0655a2014-06-04 06:53:35 +02001432
paula2c62832003-04-23 17:01:31 +00001433DEFUN (ospf_area_shortcut,
1434 ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001435 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1436 "OSPF area parameters\n"
1437 "OSPF area ID in IP address format\n"
1438 "OSPF area ID as a decimal value\n"
1439 "Configure the area's shortcutting mode\n"
1440 "Set default shortcutting behavior\n"
1441 "Enable shortcutting through the area\n"
1442 "Disable shortcutting through the area\n")
1443{
paul68980082003-03-25 05:07:42 +00001444 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001445 struct ospf_area *area;
1446 struct in_addr area_id;
1447 int mode;
1448 int format;
1449
1450 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1451
paul68980082003-03-25 05:07:42 +00001452 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001453
1454 if (strncmp (argv[1], "de", 2) == 0)
1455 mode = OSPF_SHORTCUT_DEFAULT;
1456 else if (strncmp (argv[1], "di", 2) == 0)
1457 mode = OSPF_SHORTCUT_DISABLE;
1458 else if (strncmp (argv[1], "e", 1) == 0)
1459 mode = OSPF_SHORTCUT_ENABLE;
1460 else
1461 return CMD_WARNING;
1462
paul68980082003-03-25 05:07:42 +00001463 ospf_area_shortcut_set (ospf, area, mode);
paul718e3742002-12-13 20:15:29 +00001464
paul68980082003-03-25 05:07:42 +00001465 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
paul718e3742002-12-13 20:15:29 +00001466 vty_out (vty, "Shortcut area setting will take effect "
1467 "only when the router is configured as Shortcut ABR%s",
1468 VTY_NEWLINE);
1469
1470 return CMD_SUCCESS;
1471}
1472
paula2c62832003-04-23 17:01:31 +00001473DEFUN (no_ospf_area_shortcut,
1474 no_ospf_area_shortcut_cmd,
paul718e3742002-12-13 20:15:29 +00001475 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1476 NO_STR
1477 "OSPF area parameters\n"
1478 "OSPF area ID in IP address format\n"
1479 "OSPF area ID as a decimal value\n"
1480 "Deconfigure the area's shortcutting mode\n"
1481 "Deconfigure enabled shortcutting through the area\n"
1482 "Deconfigure disabled shortcutting through the area\n")
1483{
paul68980082003-03-25 05:07:42 +00001484 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001485 struct ospf_area *area;
1486 struct in_addr area_id;
1487 int format;
1488
1489 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1490
paul68980082003-03-25 05:07:42 +00001491 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001492 if (!area)
1493 return CMD_SUCCESS;
1494
paul68980082003-03-25 05:07:42 +00001495 ospf_area_shortcut_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001496
1497 return CMD_SUCCESS;
1498}
1499
David Lamparter6b0655a2014-06-04 06:53:35 +02001500
paula2c62832003-04-23 17:01:31 +00001501DEFUN (ospf_area_stub,
1502 ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001503 "area (A.B.C.D|<0-4294967295>) stub",
1504 "OSPF area parameters\n"
1505 "OSPF area ID in IP address format\n"
1506 "OSPF area ID as a decimal value\n"
1507 "Configure OSPF area as stub\n")
1508{
1509 struct ospf *ospf = vty->index;
1510 struct in_addr area_id;
1511 int ret, format;
1512
1513 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1514
1515 ret = ospf_area_stub_set (ospf, area_id);
1516 if (ret == 0)
1517 {
1518 vty_out (vty, "First deconfigure all virtual link through this area%s",
1519 VTY_NEWLINE);
1520 return CMD_WARNING;
1521 }
1522
1523 ospf_area_no_summary_unset (ospf, area_id);
1524
1525 return CMD_SUCCESS;
1526}
1527
paula2c62832003-04-23 17:01:31 +00001528DEFUN (ospf_area_stub_no_summary,
1529 ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001530 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1531 "OSPF stub parameters\n"
1532 "OSPF area ID in IP address format\n"
1533 "OSPF area ID as a decimal value\n"
1534 "Configure OSPF area as stub\n"
1535 "Do not inject inter-area routes into stub\n")
1536{
1537 struct ospf *ospf = vty->index;
1538 struct in_addr area_id;
1539 int ret, format;
1540
1541 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1542
1543 ret = ospf_area_stub_set (ospf, area_id);
1544 if (ret == 0)
1545 {
paulb0a053b2003-06-22 09:04:47 +00001546 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
paul718e3742002-12-13 20:15:29 +00001547 VTY_NEWLINE);
1548 return CMD_WARNING;
1549 }
1550
1551 ospf_area_no_summary_set (ospf, area_id);
1552
1553 return CMD_SUCCESS;
1554}
1555
paula2c62832003-04-23 17:01:31 +00001556DEFUN (no_ospf_area_stub,
1557 no_ospf_area_stub_cmd,
paul718e3742002-12-13 20:15:29 +00001558 "no area (A.B.C.D|<0-4294967295>) stub",
1559 NO_STR
1560 "OSPF area parameters\n"
1561 "OSPF area ID in IP address format\n"
1562 "OSPF area ID as a decimal value\n"
1563 "Configure OSPF area as stub\n")
1564{
1565 struct ospf *ospf = vty->index;
1566 struct in_addr area_id;
1567 int format;
1568
1569 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1570
1571 ospf_area_stub_unset (ospf, area_id);
1572 ospf_area_no_summary_unset (ospf, area_id);
1573
1574 return CMD_SUCCESS;
1575}
1576
paula2c62832003-04-23 17:01:31 +00001577DEFUN (no_ospf_area_stub_no_summary,
1578 no_ospf_area_stub_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001579 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1580 NO_STR
1581 "OSPF area parameters\n"
1582 "OSPF area ID in IP address format\n"
1583 "OSPF area ID as a decimal value\n"
1584 "Configure OSPF area as stub\n"
1585 "Do not inject inter-area routes into area\n")
1586{
1587 struct ospf *ospf = vty->index;
1588 struct in_addr area_id;
1589 int format;
1590
1591 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1592 ospf_area_no_summary_unset (ospf, area_id);
1593
1594 return CMD_SUCCESS;
1595}
1596
paul4dadc292005-05-06 21:37:42 +00001597static int
paul6c835672004-10-11 11:00:30 +00001598ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1599 int nosum)
paul718e3742002-12-13 20:15:29 +00001600{
1601 struct ospf *ospf = vty->index;
1602 struct in_addr area_id;
1603 int ret, format;
1604
1605 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1606
1607 ret = ospf_area_nssa_set (ospf, area_id);
1608 if (ret == 0)
1609 {
1610 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1611 VTY_NEWLINE);
1612 return CMD_WARNING;
1613 }
1614
1615 if (argc > 1)
1616 {
1617 if (strncmp (argv[1], "translate-c", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001618 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001619 OSPF_NSSA_ROLE_CANDIDATE);
1620 else if (strncmp (argv[1], "translate-n", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001621 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001622 OSPF_NSSA_ROLE_NEVER);
1623 else if (strncmp (argv[1], "translate-a", 11) == 0)
paulb0a053b2003-06-22 09:04:47 +00001624 ospf_area_nssa_translator_role_set (ospf, area_id,
paul718e3742002-12-13 20:15:29 +00001625 OSPF_NSSA_ROLE_ALWAYS);
1626 }
paulb0a053b2003-06-22 09:04:47 +00001627 else
1628 {
1629 ospf_area_nssa_translator_role_set (ospf, area_id,
1630 OSPF_NSSA_ROLE_CANDIDATE);
1631 }
paul718e3742002-12-13 20:15:29 +00001632
paulb0a053b2003-06-22 09:04:47 +00001633 if (nosum)
paul718e3742002-12-13 20:15:29 +00001634 ospf_area_no_summary_set (ospf, area_id);
paulb0a053b2003-06-22 09:04:47 +00001635 else
1636 ospf_area_no_summary_unset (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001637
paulb0a053b2003-06-22 09:04:47 +00001638 ospf_schedule_abr_task (ospf);
1639
paul718e3742002-12-13 20:15:29 +00001640 return CMD_SUCCESS;
1641}
1642
paulb0a053b2003-06-22 09:04:47 +00001643DEFUN (ospf_area_nssa_translate_no_summary,
paula2c62832003-04-23 17:01:31 +00001644 ospf_area_nssa_translate_no_summary_cmd,
paulb0a053b2003-06-22 09:04:47 +00001645 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
paul718e3742002-12-13 20:15:29 +00001646 "OSPF area parameters\n"
1647 "OSPF area ID in IP address format\n"
1648 "OSPF area ID as a decimal value\n"
1649 "Configure OSPF area as nssa\n"
1650 "Configure NSSA-ABR for translate election (default)\n"
1651 "Configure NSSA-ABR to never translate\n"
1652 "Configure NSSA-ABR to always translate\n"
paulb0a053b2003-06-22 09:04:47 +00001653 "Do not inject inter-area routes into nssa\n")
1654{
1655 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1656}
paul718e3742002-12-13 20:15:29 +00001657
paulb0a053b2003-06-22 09:04:47 +00001658DEFUN (ospf_area_nssa_translate,
paula2c62832003-04-23 17:01:31 +00001659 ospf_area_nssa_translate_cmd,
paul718e3742002-12-13 20:15:29 +00001660 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1661 "OSPF area parameters\n"
1662 "OSPF area ID in IP address format\n"
1663 "OSPF area ID as a decimal value\n"
1664 "Configure OSPF area as nssa\n"
1665 "Configure NSSA-ABR for translate election (default)\n"
1666 "Configure NSSA-ABR to never translate\n"
1667 "Configure NSSA-ABR to always translate\n")
paulb0a053b2003-06-22 09:04:47 +00001668{
1669 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1670}
1671
1672DEFUN (ospf_area_nssa,
1673 ospf_area_nssa_cmd,
1674 "area (A.B.C.D|<0-4294967295>) nssa",
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{
1680 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1681}
paul718e3742002-12-13 20:15:29 +00001682
paula2c62832003-04-23 17:01:31 +00001683DEFUN (ospf_area_nssa_no_summary,
1684 ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001685 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1686 "OSPF area parameters\n"
1687 "OSPF area ID in IP address format\n"
1688 "OSPF area ID as a decimal value\n"
1689 "Configure OSPF area as nssa\n"
1690 "Do not inject inter-area routes into nssa\n")
1691{
paulb0a053b2003-06-22 09:04:47 +00001692 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
paul718e3742002-12-13 20:15:29 +00001693}
1694
paula2c62832003-04-23 17:01:31 +00001695DEFUN (no_ospf_area_nssa,
1696 no_ospf_area_nssa_cmd,
paul718e3742002-12-13 20:15:29 +00001697 "no area (A.B.C.D|<0-4294967295>) nssa",
1698 NO_STR
1699 "OSPF area parameters\n"
1700 "OSPF area ID in IP address format\n"
1701 "OSPF area ID as a decimal value\n"
1702 "Configure OSPF area as nssa\n")
1703{
1704 struct ospf *ospf = vty->index;
1705 struct in_addr area_id;
1706 int format;
1707
1708 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1709
1710 ospf_area_nssa_unset (ospf, area_id);
1711 ospf_area_no_summary_unset (ospf, area_id);
1712
paulb0a053b2003-06-22 09:04:47 +00001713 ospf_schedule_abr_task (ospf);
1714
paul718e3742002-12-13 20:15:29 +00001715 return CMD_SUCCESS;
1716}
1717
paula2c62832003-04-23 17:01:31 +00001718DEFUN (no_ospf_area_nssa_no_summary,
1719 no_ospf_area_nssa_no_summary_cmd,
paul718e3742002-12-13 20:15:29 +00001720 "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
1721 NO_STR
1722 "OSPF area parameters\n"
1723 "OSPF area ID in IP address format\n"
1724 "OSPF area ID as a decimal value\n"
1725 "Configure OSPF area as nssa\n"
1726 "Do not inject inter-area routes into nssa\n")
1727{
1728 struct ospf *ospf = vty->index;
1729 struct in_addr area_id;
1730 int format;
1731
1732 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1733 ospf_area_no_summary_unset (ospf, area_id);
1734
1735 return CMD_SUCCESS;
1736}
1737
paula2c62832003-04-23 17:01:31 +00001738DEFUN (ospf_area_default_cost,
1739 ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001740 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1741 "OSPF area parameters\n"
1742 "OSPF area ID in IP address format\n"
1743 "OSPF area ID as a decimal value\n"
1744 "Set the summary-default cost of a NSSA or stub area\n"
1745 "Stub's advertised default summary cost\n")
1746{
paul68980082003-03-25 05:07:42 +00001747 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001748 struct ospf_area *area;
1749 struct in_addr area_id;
1750 u_int32_t cost;
1751 int format;
vincentba682532005-09-29 13:52:57 +00001752 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001753
1754 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1755 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1756
paul68980082003-03-25 05:07:42 +00001757 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001758
1759 if (area->external_routing == OSPF_AREA_DEFAULT)
1760 {
1761 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1762 return CMD_WARNING;
1763 }
1764
1765 area->default_cost = cost;
1766
vincentba682532005-09-29 13:52:57 +00001767 p.family = AF_INET;
1768 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1769 p.prefixlen = 0;
1770 if (IS_DEBUG_OSPF_EVENT)
1771 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1772 "announcing 0.0.0.0/0 to area %s",
1773 inet_ntoa (area->area_id));
1774 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1775
paul718e3742002-12-13 20:15:29 +00001776 return CMD_SUCCESS;
1777}
1778
paula2c62832003-04-23 17:01:31 +00001779DEFUN (no_ospf_area_default_cost,
1780 no_ospf_area_default_cost_cmd,
paul718e3742002-12-13 20:15:29 +00001781 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1782 NO_STR
1783 "OSPF area parameters\n"
1784 "OSPF area ID in IP address format\n"
1785 "OSPF area ID as a decimal value\n"
1786 "Set the summary-default cost of a NSSA or stub area\n"
1787 "Stub's advertised default summary cost\n")
1788{
paul68980082003-03-25 05:07:42 +00001789 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001790 struct ospf_area *area;
1791 struct in_addr area_id;
paul718e3742002-12-13 20:15:29 +00001792 int format;
vincentba682532005-09-29 13:52:57 +00001793 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00001794
1795 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
Andrew Certain0798cee2012-12-04 13:43:42 -08001796 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
paul718e3742002-12-13 20:15:29 +00001797
paul68980082003-03-25 05:07:42 +00001798 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001799 if (area == NULL)
1800 return CMD_SUCCESS;
1801
1802 if (area->external_routing == OSPF_AREA_DEFAULT)
1803 {
1804 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1805 return CMD_WARNING;
1806 }
1807
1808 area->default_cost = 1;
1809
vincentba682532005-09-29 13:52:57 +00001810 p.family = AF_INET;
1811 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1812 p.prefixlen = 0;
1813 if (IS_DEBUG_OSPF_EVENT)
1814 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1815 "announcing 0.0.0.0/0 to area %s",
1816 inet_ntoa (area->area_id));
1817 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1818
1819
paul68980082003-03-25 05:07:42 +00001820 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001821
1822 return CMD_SUCCESS;
1823}
1824
paula2c62832003-04-23 17:01:31 +00001825DEFUN (ospf_area_export_list,
1826 ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001827 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1828 "OSPF area parameters\n"
1829 "OSPF area ID in IP address format\n"
1830 "OSPF area ID as a decimal value\n"
1831 "Set the filter for networks announced to other areas\n"
1832 "Name of the access-list\n")
1833{
paul68980082003-03-25 05:07:42 +00001834 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001835 struct ospf_area *area;
1836 struct in_addr area_id;
1837 int format;
1838
hasso52930762004-04-19 18:26:53 +00001839 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1840
paul68980082003-03-25 05:07:42 +00001841 area = ospf_area_get (ospf, area_id, format);
1842 ospf_area_export_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001843
1844 return CMD_SUCCESS;
1845}
1846
paula2c62832003-04-23 17:01:31 +00001847DEFUN (no_ospf_area_export_list,
1848 no_ospf_area_export_list_cmd,
paul718e3742002-12-13 20:15:29 +00001849 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1850 NO_STR
1851 "OSPF area parameters\n"
1852 "OSPF area ID in IP address format\n"
1853 "OSPF area ID as a decimal value\n"
1854 "Unset the filter for networks announced to other areas\n"
1855 "Name of the access-list\n")
1856{
paul68980082003-03-25 05:07:42 +00001857 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001858 struct ospf_area *area;
1859 struct in_addr area_id;
1860 int format;
1861
hasso52930762004-04-19 18:26:53 +00001862 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1863
paul68980082003-03-25 05:07:42 +00001864 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001865 if (area == NULL)
1866 return CMD_SUCCESS;
1867
paul68980082003-03-25 05:07:42 +00001868 ospf_area_export_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001869
1870 return CMD_SUCCESS;
1871}
1872
1873
paula2c62832003-04-23 17:01:31 +00001874DEFUN (ospf_area_import_list,
1875 ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001876 "area (A.B.C.D|<0-4294967295>) import-list NAME",
1877 "OSPF area parameters\n"
1878 "OSPF area ID in IP address format\n"
1879 "OSPF area ID as a decimal value\n"
1880 "Set the filter for networks from other areas announced to the specified one\n"
1881 "Name of the access-list\n")
1882{
paul68980082003-03-25 05:07:42 +00001883 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001884 struct ospf_area *area;
1885 struct in_addr area_id;
1886 int format;
1887
hasso52930762004-04-19 18:26:53 +00001888 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1889
paul68980082003-03-25 05:07:42 +00001890 area = ospf_area_get (ospf, area_id, format);
1891 ospf_area_import_list_set (ospf, area, argv[1]);
paul718e3742002-12-13 20:15:29 +00001892
1893 return CMD_SUCCESS;
1894}
1895
paula2c62832003-04-23 17:01:31 +00001896DEFUN (no_ospf_area_import_list,
1897 no_ospf_area_import_list_cmd,
paul718e3742002-12-13 20:15:29 +00001898 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
1899 NO_STR
1900 "OSPF area parameters\n"
1901 "OSPF area ID in IP address format\n"
1902 "OSPF area ID as a decimal value\n"
1903 "Unset the filter for networks announced to other areas\n"
1904 "Name of the access-list\n")
1905{
paul68980082003-03-25 05:07:42 +00001906 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001907 struct ospf_area *area;
1908 struct in_addr area_id;
1909 int format;
1910
hasso52930762004-04-19 18:26:53 +00001911 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1912
paul68980082003-03-25 05:07:42 +00001913 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00001914 if (area == NULL)
1915 return CMD_SUCCESS;
1916
paul68980082003-03-25 05:07:42 +00001917 ospf_area_import_list_unset (ospf, area);
paul718e3742002-12-13 20:15:29 +00001918
1919 return CMD_SUCCESS;
1920}
1921
paula2c62832003-04-23 17:01:31 +00001922DEFUN (ospf_area_filter_list,
1923 ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001924 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1925 "OSPF area parameters\n"
1926 "OSPF area ID in IP address format\n"
1927 "OSPF area ID as a decimal value\n"
1928 "Filter networks between OSPF areas\n"
1929 "Filter prefixes between OSPF areas\n"
1930 "Name of an IP prefix-list\n"
1931 "Filter networks sent to this area\n"
1932 "Filter networks sent from this area\n")
1933{
paul68980082003-03-25 05:07:42 +00001934 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001935 struct ospf_area *area;
1936 struct in_addr area_id;
1937 struct prefix_list *plist;
1938 int format;
1939
1940 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1941
paul68980082003-03-25 05:07:42 +00001942 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00001943 plist = prefix_list_lookup (AFI_IP, argv[1]);
1944 if (strncmp (argv[2], "in", 2) == 0)
1945 {
1946 PREFIX_LIST_IN (area) = plist;
1947 if (PREFIX_NAME_IN (area))
1948 free (PREFIX_NAME_IN (area));
1949
1950 PREFIX_NAME_IN (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001951 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001952 }
1953 else
1954 {
1955 PREFIX_LIST_OUT (area) = plist;
1956 if (PREFIX_NAME_OUT (area))
1957 free (PREFIX_NAME_OUT (area));
1958
1959 PREFIX_NAME_OUT (area) = strdup (argv[1]);
paul68980082003-03-25 05:07:42 +00001960 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00001961 }
1962
1963 return CMD_SUCCESS;
1964}
1965
paula2c62832003-04-23 17:01:31 +00001966DEFUN (no_ospf_area_filter_list,
1967 no_ospf_area_filter_list_cmd,
paul718e3742002-12-13 20:15:29 +00001968 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
1969 NO_STR
1970 "OSPF area parameters\n"
1971 "OSPF area ID in IP address format\n"
1972 "OSPF area ID as a decimal value\n"
1973 "Filter networks between OSPF areas\n"
1974 "Filter prefixes between OSPF areas\n"
1975 "Name of an IP prefix-list\n"
1976 "Filter networks sent to this area\n"
1977 "Filter networks sent from this area\n")
1978{
paul68980082003-03-25 05:07:42 +00001979 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00001980 struct ospf_area *area;
1981 struct in_addr area_id;
paul718e3742002-12-13 20:15:29 +00001982 int format;
1983
1984 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1985
Paul Jakma1a8ec2b2006-05-11 13:34:08 +00001986 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
1987 return CMD_SUCCESS;
1988
paul718e3742002-12-13 20:15:29 +00001989 if (strncmp (argv[2], "in", 2) == 0)
1990 {
1991 if (PREFIX_NAME_IN (area))
1992 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
1993 return CMD_SUCCESS;
1994
1995 PREFIX_LIST_IN (area) = NULL;
1996 if (PREFIX_NAME_IN (area))
1997 free (PREFIX_NAME_IN (area));
1998
1999 PREFIX_NAME_IN (area) = NULL;
2000
paul68980082003-03-25 05:07:42 +00002001 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002002 }
2003 else
2004 {
2005 if (PREFIX_NAME_OUT (area))
2006 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
2007 return CMD_SUCCESS;
2008
2009 PREFIX_LIST_OUT (area) = NULL;
2010 if (PREFIX_NAME_OUT (area))
2011 free (PREFIX_NAME_OUT (area));
2012
2013 PREFIX_NAME_OUT (area) = NULL;
2014
paul68980082003-03-25 05:07:42 +00002015 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002016 }
2017
2018 return CMD_SUCCESS;
2019}
2020
David Lamparter6b0655a2014-06-04 06:53:35 +02002021
paula2c62832003-04-23 17:01:31 +00002022DEFUN (ospf_area_authentication_message_digest,
2023 ospf_area_authentication_message_digest_cmd,
paul718e3742002-12-13 20:15:29 +00002024 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
2025 "OSPF area parameters\n"
Christian Franke2b005152013-09-30 12:27:49 +00002026 "OSPF area ID in IP address format\n"
2027 "OSPF area ID as a decimal value\n"
paul718e3742002-12-13 20:15:29 +00002028 "Enable authentication\n"
2029 "Use message-digest authentication\n")
2030{
paul68980082003-03-25 05:07:42 +00002031 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002032 struct ospf_area *area;
2033 struct in_addr area_id;
2034 int format;
2035
2036 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2037
paul68980082003-03-25 05:07:42 +00002038 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00002039 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
2040
2041 return CMD_SUCCESS;
2042}
2043
paula2c62832003-04-23 17:01:31 +00002044DEFUN (ospf_area_authentication,
2045 ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002046 "area (A.B.C.D|<0-4294967295>) authentication",
2047 "OSPF area parameters\n"
2048 "OSPF area ID in IP address format\n"
2049 "OSPF area ID as a decimal value\n"
2050 "Enable authentication\n")
2051{
paul68980082003-03-25 05:07:42 +00002052 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002053 struct ospf_area *area;
2054 struct in_addr area_id;
2055 int format;
2056
2057 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2058
paul68980082003-03-25 05:07:42 +00002059 area = ospf_area_get (ospf, area_id, format);
paul718e3742002-12-13 20:15:29 +00002060 area->auth_type = OSPF_AUTH_SIMPLE;
2061
2062 return CMD_SUCCESS;
2063}
2064
paula2c62832003-04-23 17:01:31 +00002065DEFUN (no_ospf_area_authentication,
2066 no_ospf_area_authentication_cmd,
paul718e3742002-12-13 20:15:29 +00002067 "no area (A.B.C.D|<0-4294967295>) authentication",
2068 NO_STR
2069 "OSPF area parameters\n"
2070 "OSPF area ID in IP address format\n"
2071 "OSPF area ID as a decimal value\n"
2072 "Enable authentication\n")
2073{
paul68980082003-03-25 05:07:42 +00002074 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002075 struct ospf_area *area;
2076 struct in_addr area_id;
2077 int format;
2078
2079 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2080
paul68980082003-03-25 05:07:42 +00002081 area = ospf_area_lookup_by_area_id (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002082 if (area == NULL)
2083 return CMD_SUCCESS;
2084
2085 area->auth_type = OSPF_AUTH_NULL;
2086
paul68980082003-03-25 05:07:42 +00002087 ospf_area_check_free (ospf, area_id);
paul718e3742002-12-13 20:15:29 +00002088
2089 return CMD_SUCCESS;
2090}
2091
David Lamparter6b0655a2014-06-04 06:53:35 +02002092
paul718e3742002-12-13 20:15:29 +00002093DEFUN (ospf_abr_type,
2094 ospf_abr_type_cmd,
2095 "ospf abr-type (cisco|ibm|shortcut|standard)",
2096 "OSPF specific commands\n"
2097 "Set OSPF ABR type\n"
2098 "Alternative ABR, cisco implementation\n"
2099 "Alternative ABR, IBM implementation\n"
2100 "Shortcut ABR\n"
2101 "Standard behavior (RFC2328)\n")
2102{
paul68980082003-03-25 05:07:42 +00002103 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002104 u_char abr_type = OSPF_ABR_UNKNOWN;
2105
2106 if (strncmp (argv[0], "c", 1) == 0)
2107 abr_type = OSPF_ABR_CISCO;
2108 else if (strncmp (argv[0], "i", 1) == 0)
2109 abr_type = OSPF_ABR_IBM;
2110 else if (strncmp (argv[0], "sh", 2) == 0)
2111 abr_type = OSPF_ABR_SHORTCUT;
2112 else if (strncmp (argv[0], "st", 2) == 0)
2113 abr_type = OSPF_ABR_STAND;
2114 else
2115 return CMD_WARNING;
2116
2117 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002118 if (ospf->abr_type != abr_type)
paul718e3742002-12-13 20:15:29 +00002119 {
paul68980082003-03-25 05:07:42 +00002120 ospf->abr_type = abr_type;
2121 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002122 }
2123
2124 return CMD_SUCCESS;
2125}
2126
2127DEFUN (no_ospf_abr_type,
2128 no_ospf_abr_type_cmd,
pauld57834f2005-07-12 20:04:22 +00002129 "no ospf abr-type (cisco|ibm|shortcut|standard)",
paul718e3742002-12-13 20:15:29 +00002130 NO_STR
2131 "OSPF specific commands\n"
2132 "Set OSPF ABR type\n"
2133 "Alternative ABR, cisco implementation\n"
2134 "Alternative ABR, IBM implementation\n"
2135 "Shortcut ABR\n")
2136{
paul68980082003-03-25 05:07:42 +00002137 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002138 u_char abr_type = OSPF_ABR_UNKNOWN;
2139
2140 if (strncmp (argv[0], "c", 1) == 0)
2141 abr_type = OSPF_ABR_CISCO;
2142 else if (strncmp (argv[0], "i", 1) == 0)
2143 abr_type = OSPF_ABR_IBM;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002144 else if (strncmp (argv[0], "sh", 2) == 0)
paul718e3742002-12-13 20:15:29 +00002145 abr_type = OSPF_ABR_SHORTCUT;
Francesco Dolcini04d23312009-06-02 18:20:09 +01002146 else if (strncmp (argv[0], "st", 2) == 0)
2147 abr_type = OSPF_ABR_STAND;
paul718e3742002-12-13 20:15:29 +00002148 else
2149 return CMD_WARNING;
2150
2151 /* If ABR type value is changed, schedule ABR task. */
paul68980082003-03-25 05:07:42 +00002152 if (ospf->abr_type == abr_type)
paul718e3742002-12-13 20:15:29 +00002153 {
pauld57834f2005-07-12 20:04:22 +00002154 ospf->abr_type = OSPF_ABR_DEFAULT;
paul68980082003-03-25 05:07:42 +00002155 ospf_schedule_abr_task (ospf);
paul718e3742002-12-13 20:15:29 +00002156 }
2157
2158 return CMD_SUCCESS;
2159}
2160
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002161DEFUN (ospf_log_adjacency_changes,
2162 ospf_log_adjacency_changes_cmd,
2163 "log-adjacency-changes",
2164 "Log changes in adjacency state\n")
2165{
2166 struct ospf *ospf = vty->index;
2167
2168 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2169 return CMD_SUCCESS;
2170}
2171
2172DEFUN (ospf_log_adjacency_changes_detail,
2173 ospf_log_adjacency_changes_detail_cmd,
2174 "log-adjacency-changes detail",
2175 "Log changes in adjacency state\n"
2176 "Log all state changes\n")
2177{
2178 struct ospf *ospf = vty->index;
2179
2180 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2181 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2182 return CMD_SUCCESS;
2183}
2184
2185DEFUN (no_ospf_log_adjacency_changes,
2186 no_ospf_log_adjacency_changes_cmd,
2187 "no log-adjacency-changes",
2188 NO_STR
2189 "Log changes in adjacency state\n")
2190{
2191 struct ospf *ospf = vty->index;
2192
2193 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2194 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2195 return CMD_SUCCESS;
2196}
2197
2198DEFUN (no_ospf_log_adjacency_changes_detail,
2199 no_ospf_log_adjacency_changes_detail_cmd,
2200 "no log-adjacency-changes detail",
2201 NO_STR
2202 "Log changes in adjacency state\n"
2203 "Log all state changes\n")
2204{
2205 struct ospf *ospf = vty->index;
2206
2207 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2208 return CMD_SUCCESS;
2209}
2210
paul718e3742002-12-13 20:15:29 +00002211DEFUN (ospf_compatible_rfc1583,
2212 ospf_compatible_rfc1583_cmd,
2213 "compatible rfc1583",
2214 "OSPF compatibility list\n"
2215 "compatible with RFC 1583\n")
2216{
2217 struct ospf *ospf = vty->index;
2218
2219 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2220 {
2221 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
Paul Jakmab6eef002014-10-09 14:19:51 +01002222 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
paul718e3742002-12-13 20:15:29 +00002223 }
2224 return CMD_SUCCESS;
2225}
2226
2227DEFUN (no_ospf_compatible_rfc1583,
2228 no_ospf_compatible_rfc1583_cmd,
2229 "no compatible rfc1583",
2230 NO_STR
2231 "OSPF compatibility list\n"
2232 "compatible with RFC 1583\n")
2233{
2234 struct ospf *ospf = vty->index;
2235
2236 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2237 {
2238 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
Paul Jakmab6eef002014-10-09 14:19:51 +01002239 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
paul718e3742002-12-13 20:15:29 +00002240 }
2241 return CMD_SUCCESS;
2242}
2243
2244ALIAS (ospf_compatible_rfc1583,
2245 ospf_rfc1583_flag_cmd,
2246 "ospf rfc1583compatibility",
2247 "OSPF specific commands\n"
2248 "Enable the RFC1583Compatibility flag\n")
2249
2250ALIAS (no_ospf_compatible_rfc1583,
2251 no_ospf_rfc1583_flag_cmd,
2252 "no ospf rfc1583compatibility",
2253 NO_STR
2254 "OSPF specific commands\n"
2255 "Disable the RFC1583Compatibility flag\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02002256
pauld24f6e22005-10-21 09:23:12 +00002257static int
2258ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2259 unsigned int hold,
2260 unsigned int max)
2261{
2262 struct ospf *ospf = vty->index;
2263
2264 ospf->spf_delay = delay;
2265 ospf->spf_holdtime = hold;
2266 ospf->spf_max_holdtime = max;
2267
2268 return CMD_SUCCESS;
2269}
paul718e3742002-12-13 20:15:29 +00002270
Michael Rossberg2ef762e2015-07-27 07:56:25 +02002271DEFUN (ospf_timers_min_ls_interval,
2272 ospf_timers_min_ls_interval_cmd,
2273 "timers throttle lsa all <0-5000>",
2274 "Adjust routing timers\n"
2275 "Throttling adaptive timer\n"
2276 "LSA delay between transmissions\n"
2277 NO_STR
2278 "Delay (msec) between sending LSAs\n")
2279{
2280 struct ospf *ospf = vty->index;
2281 unsigned int interval;
2282
2283 if (argc != 1)
2284 {
2285 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2286 return CMD_WARNING;
2287 }
2288
2289 VTY_GET_INTEGER ("LSA interval", interval, argv[0]);
2290
2291 ospf->min_ls_interval = interval;
2292
2293 return CMD_SUCCESS;
2294}
2295
2296DEFUN (no_ospf_timers_min_ls_interval,
2297 no_ospf_timers_min_ls_interval_cmd,
2298 "no timers throttle lsa all",
2299 NO_STR
2300 "Adjust routing timers\n"
2301 "Throttling adaptive timer\n"
2302 "LSA delay between transmissions\n")
2303{
2304 struct ospf *ospf = vty->index;
2305 ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL;
2306
2307 return CMD_SUCCESS;
2308}
2309
2310DEFUN (ospf_timers_min_ls_arrival,
2311 ospf_timers_min_ls_arrival_cmd,
2312 "timers lsa arrival <0-1000>",
2313 "Adjust routing timers\n"
2314 "Throttling link state advertisement delays\n"
2315 "OSPF minimum arrival interval delay\n"
2316 "Delay (msec) between accepted LSAs\n")
2317{
2318 struct ospf *ospf = vty->index;
2319 unsigned int arrival;
2320
2321 if (argc != 1)
2322 {
2323 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2324 return CMD_WARNING;
2325 }
2326
2327 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[0], 0, 1000);
2328
2329 ospf->min_ls_arrival = arrival;
2330
2331 return CMD_SUCCESS;
2332}
2333
2334DEFUN (no_ospf_timers_min_ls_arrival,
2335 no_ospf_timers_min_ls_arrival_cmd,
2336 "no timers lsa arrival",
2337 NO_STR
2338 "Adjust routing timers\n"
2339 "Throttling link state advertisement delays\n"
2340 "OSPF minimum arrival interval delay\n")
2341{
2342 struct ospf *ospf = vty->index;
2343 ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
2344
2345 return CMD_SUCCESS;
2346}
2347
pauld24f6e22005-10-21 09:23:12 +00002348DEFUN (ospf_timers_throttle_spf,
2349 ospf_timers_throttle_spf_cmd,
2350 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2351 "Adjust routing timers\n"
2352 "Throttling adaptive timer\n"
2353 "OSPF SPF timers\n"
2354 "Delay (msec) from first change received till SPF calculation\n"
2355 "Initial hold time (msec) between consecutive SPF calculations\n"
2356 "Maximum hold time (msec)\n")
2357{
2358 unsigned int delay, hold, max;
2359
2360 if (argc != 3)
2361 {
2362 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2363 return CMD_WARNING;
2364 }
2365
2366 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2367 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2368 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2369
2370 return ospf_timers_spf_set (vty, delay, hold, max);
2371}
2372
2373DEFUN_DEPRECATED (ospf_timers_spf,
paula2c62832003-04-23 17:01:31 +00002374 ospf_timers_spf_cmd,
paul718e3742002-12-13 20:15:29 +00002375 "timers spf <0-4294967295> <0-4294967295>",
2376 "Adjust routing timers\n"
2377 "OSPF SPF timers\n"
pauld24f6e22005-10-21 09:23:12 +00002378 "Delay (s) between receiving a change to SPF calculation\n"
2379 "Hold time (s) between consecutive SPF calculations\n")
paul718e3742002-12-13 20:15:29 +00002380{
pauld24f6e22005-10-21 09:23:12 +00002381 unsigned int delay, hold;
2382
2383 if (argc != 2)
2384 {
2385 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2386 return CMD_WARNING;
2387 }
2388
paul4dadc292005-05-06 21:37:42 +00002389 VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
2390 VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
pauld24f6e22005-10-21 09:23:12 +00002391
2392 /* truncate down the second values if they're greater than 600000ms */
2393 if (delay > (600000 / 1000))
2394 delay = 600000;
2395 else if (delay == 0)
2396 /* 0s delay was probably specified because of lack of ms resolution */
2397 delay = OSPF_SPF_DELAY_DEFAULT;
2398 if (hold > (600000 / 1000))
2399 hold = 600000;
2400
2401 return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
paul718e3742002-12-13 20:15:29 +00002402}
2403
pauld24f6e22005-10-21 09:23:12 +00002404DEFUN (no_ospf_timers_throttle_spf,
2405 no_ospf_timers_throttle_spf_cmd,
2406 "no timers throttle spf",
paul718e3742002-12-13 20:15:29 +00002407 NO_STR
2408 "Adjust routing timers\n"
pauld24f6e22005-10-21 09:23:12 +00002409 "Throttling adaptive timer\n"
paul718e3742002-12-13 20:15:29 +00002410 "OSPF SPF timers\n")
2411{
pauld24f6e22005-10-21 09:23:12 +00002412 return ospf_timers_spf_set (vty,
2413 OSPF_SPF_DELAY_DEFAULT,
2414 OSPF_SPF_HOLDTIME_DEFAULT,
2415 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
paul718e3742002-12-13 20:15:29 +00002416}
2417
pauld24f6e22005-10-21 09:23:12 +00002418ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
2419 no_ospf_timers_spf_cmd,
2420 "no timers spf",
2421 NO_STR
2422 "Adjust routing timers\n"
2423 "OSPF SPF timers\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02002424
paula2c62832003-04-23 17:01:31 +00002425DEFUN (ospf_neighbor,
2426 ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002427 "neighbor A.B.C.D",
2428 NEIGHBOR_STR
2429 "Neighbor IP address\n")
2430{
2431 struct ospf *ospf = vty->index;
2432 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002433 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2434 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002435
2436 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2437
2438 if (argc > 1)
2439 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2440
2441 if (argc > 2)
2442 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2443
2444 ospf_nbr_nbma_set (ospf, nbr_addr);
2445 if (argc > 1)
2446 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2447 if (argc > 2)
Andrew Certain1a61ad12012-12-04 12:50:23 -08002448 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
paul718e3742002-12-13 20:15:29 +00002449
2450 return CMD_SUCCESS;
2451}
2452
paula2c62832003-04-23 17:01:31 +00002453ALIAS (ospf_neighbor,
2454 ospf_neighbor_priority_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002455 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2456 NEIGHBOR_STR
2457 "Neighbor IP address\n"
2458 "Neighbor Priority\n"
2459 "Priority\n"
2460 "Dead Neighbor Polling interval\n"
2461 "Seconds\n")
2462
paula2c62832003-04-23 17:01:31 +00002463ALIAS (ospf_neighbor,
2464 ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002465 "neighbor A.B.C.D priority <0-255>",
2466 NEIGHBOR_STR
2467 "Neighbor IP address\n"
2468 "Neighbor Priority\n"
2469 "Seconds\n")
2470
paula2c62832003-04-23 17:01:31 +00002471DEFUN (ospf_neighbor_poll_interval,
2472 ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002473 "neighbor A.B.C.D poll-interval <1-65535>",
2474 NEIGHBOR_STR
2475 "Neighbor IP address\n"
2476 "Dead Neighbor Polling interval\n"
2477 "Seconds\n")
2478{
2479 struct ospf *ospf = vty->index;
2480 struct in_addr nbr_addr;
hassoeb1ce602004-10-08 08:17:22 +00002481 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2482 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00002483
2484 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2485
2486 if (argc > 1)
2487 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2488
2489 if (argc > 2)
2490 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2491
2492 ospf_nbr_nbma_set (ospf, nbr_addr);
2493 if (argc > 1)
2494 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2495 if (argc > 2)
2496 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2497
2498 return CMD_SUCCESS;
2499}
2500
paula2c62832003-04-23 17:01:31 +00002501ALIAS (ospf_neighbor_poll_interval,
2502 ospf_neighbor_poll_interval_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002503 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2504 NEIGHBOR_STR
2505 "Neighbor address\n"
2506 "OSPF dead-router polling interval\n"
2507 "Seconds\n"
2508 "OSPF priority of non-broadcast neighbor\n"
2509 "Priority\n")
2510
paula2c62832003-04-23 17:01:31 +00002511DEFUN (no_ospf_neighbor,
2512 no_ospf_neighbor_cmd,
paul718e3742002-12-13 20:15:29 +00002513 "no neighbor A.B.C.D",
2514 NO_STR
2515 NEIGHBOR_STR
2516 "Neighbor IP address\n")
2517{
2518 struct ospf *ospf = vty->index;
2519 struct in_addr nbr_addr;
paul718e3742002-12-13 20:15:29 +00002520
2521 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2522
Andrew Certain0798cee2012-12-04 13:43:42 -08002523 (void)ospf_nbr_nbma_unset (ospf, nbr_addr);
paul718e3742002-12-13 20:15:29 +00002524
2525 return CMD_SUCCESS;
2526}
2527
paula2c62832003-04-23 17:01:31 +00002528ALIAS (no_ospf_neighbor,
2529 no_ospf_neighbor_priority_cmd,
paul718e3742002-12-13 20:15:29 +00002530 "no neighbor A.B.C.D priority <0-255>",
2531 NO_STR
2532 NEIGHBOR_STR
2533 "Neighbor IP address\n"
2534 "Neighbor Priority\n"
2535 "Priority\n")
2536
paula2c62832003-04-23 17:01:31 +00002537ALIAS (no_ospf_neighbor,
2538 no_ospf_neighbor_poll_interval_cmd,
paul718e3742002-12-13 20:15:29 +00002539 "no neighbor A.B.C.D poll-interval <1-65535>",
2540 NO_STR
2541 NEIGHBOR_STR
2542 "Neighbor IP address\n"
2543 "Dead Neighbor Polling interval\n"
2544 "Seconds\n")
2545
paula2c62832003-04-23 17:01:31 +00002546ALIAS (no_ospf_neighbor,
2547 no_ospf_neighbor_priority_pollinterval_cmd,
paul718e3742002-12-13 20:15:29 +00002548 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2549 NO_STR
2550 NEIGHBOR_STR
2551 "Neighbor IP address\n"
2552 "Neighbor Priority\n"
2553 "Priority\n"
2554 "Dead Neighbor Polling interval\n"
2555 "Seconds\n")
2556
David Lamparter6b0655a2014-06-04 06:53:35 +02002557
paula2c62832003-04-23 17:01:31 +00002558DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002559 "refresh timer <10-1800>",
2560 "Adjust refresh parameters\n"
2561 "Set refresh timer\n"
2562 "Timer value in seconds\n")
2563{
2564 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002565 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002566
2567 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2568 interval = (interval / 10) * 10;
2569
2570 ospf_timers_refresh_set (ospf, interval);
2571
2572 return CMD_SUCCESS;
2573}
2574
paula2c62832003-04-23 17:01:31 +00002575DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
paul718e3742002-12-13 20:15:29 +00002576 "no refresh timer <10-1800>",
2577 "Adjust refresh parameters\n"
2578 "Unset refresh timer\n"
2579 "Timer value in seconds\n")
2580{
2581 struct ospf *ospf = vty->index;
hassoeb1ce602004-10-08 08:17:22 +00002582 unsigned int interval;
paul718e3742002-12-13 20:15:29 +00002583
2584 if (argc == 1)
2585 {
2586 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2587
2588 if (ospf->lsa_refresh_interval != interval ||
2589 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2590 return CMD_SUCCESS;
2591 }
2592
2593 ospf_timers_refresh_unset (ospf);
2594
2595 return CMD_SUCCESS;
2596}
2597
paula2c62832003-04-23 17:01:31 +00002598ALIAS (no_ospf_refresh_timer,
2599 no_ospf_refresh_timer_cmd,
paul718e3742002-12-13 20:15:29 +00002600 "no refresh timer",
2601 "Adjust refresh parameters\n"
2602 "Unset refresh timer\n")
2603
paula2c62832003-04-23 17:01:31 +00002604DEFUN (ospf_auto_cost_reference_bandwidth,
2605 ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002606 "auto-cost reference-bandwidth <1-4294967>",
2607 "Calculate OSPF interface cost according to bandwidth\n"
2608 "Use reference bandwidth method to assign OSPF cost\n"
2609 "The reference bandwidth in terms of Mbits per second\n")
2610{
paul68980082003-03-25 05:07:42 +00002611 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00002612 u_int32_t refbw;
hasso52dc7ee2004-09-23 19:18:23 +00002613 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00002614 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002615
2616 refbw = strtol (argv[0], NULL, 10);
2617 if (refbw < 1 || refbw > 4294967)
2618 {
2619 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2620 return CMD_WARNING;
2621 }
2622
2623 /* If reference bandwidth is changed. */
paul68980082003-03-25 05:07:42 +00002624 if ((refbw * 1000) == ospf->ref_bandwidth)
paul718e3742002-12-13 20:15:29 +00002625 return CMD_SUCCESS;
2626
paul68980082003-03-25 05:07:42 +00002627 ospf->ref_bandwidth = refbw * 1000;
paul1eb8ef22005-04-07 07:30:20 +00002628 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2629 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002630
2631 return CMD_SUCCESS;
2632}
2633
paula2c62832003-04-23 17:01:31 +00002634DEFUN (no_ospf_auto_cost_reference_bandwidth,
2635 no_ospf_auto_cost_reference_bandwidth_cmd,
paul718e3742002-12-13 20:15:29 +00002636 "no auto-cost reference-bandwidth",
2637 NO_STR
2638 "Calculate OSPF interface cost according to bandwidth\n"
2639 "Use reference bandwidth method to assign OSPF cost\n")
2640{
paul68980082003-03-25 05:07:42 +00002641 struct ospf *ospf = vty->index;
paul1eb8ef22005-04-07 07:30:20 +00002642 struct listnode *node, *nnode;
2643 struct interface *ifp;
paul718e3742002-12-13 20:15:29 +00002644
paul68980082003-03-25 05:07:42 +00002645 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
paul718e3742002-12-13 20:15:29 +00002646 return CMD_SUCCESS;
2647
paul68980082003-03-25 05:07:42 +00002648 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
paul718e3742002-12-13 20:15:29 +00002649 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2650 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2651
paul1eb8ef22005-04-07 07:30:20 +00002652 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2653 ospf_if_recalculate_output_cost (ifp);
paul718e3742002-12-13 20:15:29 +00002654
2655 return CMD_SUCCESS;
2656}
2657
hassoeb1ce602004-10-08 08:17:22 +00002658const char *ospf_abr_type_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002659{
2660 "Unknown",
2661 "Standard (RFC2328)",
2662 "Alternative IBM",
2663 "Alternative Cisco",
2664 "Alternative Shortcut"
2665};
2666
hassoeb1ce602004-10-08 08:17:22 +00002667const char *ospf_shortcut_mode_descr_str[] =
paul718e3742002-12-13 20:15:29 +00002668{
2669 "Default",
2670 "Enabled",
2671 "Disabled"
2672};
2673
2674
David Lamparter6b0655a2014-06-04 06:53:35 +02002675
paul4dadc292005-05-06 21:37:42 +00002676static void
paul718e3742002-12-13 20:15:29 +00002677show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
2678{
2679 /* Show Area ID. */
2680 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
2681
2682 /* Show Area type/mode. */
2683 if (OSPF_IS_AREA_BACKBONE (area))
2684 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
2685 else
2686 {
2687 if (area->external_routing == OSPF_AREA_STUB)
paulb0a053b2003-06-22 09:04:47 +00002688 vty_out (vty, " (Stub%s%s)",
2689 area->no_summary ? ", no summary" : "",
2690 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002691
paulb0a053b2003-06-22 09:04:47 +00002692 else if (area->external_routing == OSPF_AREA_NSSA)
2693 vty_out (vty, " (NSSA%s%s)",
2694 area->no_summary ? ", no summary" : "",
2695 area->shortcut_configured ? "; " : "");
paul718e3742002-12-13 20:15:29 +00002696
2697 vty_out (vty, "%s", VTY_NEWLINE);
2698 vty_out (vty, " Shortcutting mode: %s",
paulb0a053b2003-06-22 09:04:47 +00002699 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
paul718e3742002-12-13 20:15:29 +00002700 vty_out (vty, ", S-bit consensus: %s%s",
paulb0a053b2003-06-22 09:04:47 +00002701 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002702 }
2703
2704 /* Show number of interfaces. */
2705 vty_out (vty, " Number of interfaces in this area: Total: %d, "
2706 "Active: %d%s", listcount (area->oiflist),
2707 area->act_ints, VTY_NEWLINE);
2708
paul718e3742002-12-13 20:15:29 +00002709 if (area->external_routing == OSPF_AREA_NSSA)
2710 {
2711 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00002712 if (! IS_OSPF_ABR (area->ospf))
paulb0a053b2003-06-22 09:04:47 +00002713 vty_out (vty, " It is not ABR, therefore not Translator. %s",
2714 VTY_NEWLINE);
2715 else if (area->NSSATranslatorState)
2716 {
2717 vty_out (vty, " We are an ABR and ");
2718 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2719 vty_out (vty, "the NSSA Elected Translator. %s",
2720 VTY_NEWLINE);
2721 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
2722 vty_out (vty, "always an NSSA Translator. %s",
2723 VTY_NEWLINE);
2724 }
paul718e3742002-12-13 20:15:29 +00002725 else
paulb0a053b2003-06-22 09:04:47 +00002726 {
2727 vty_out (vty, " We are an ABR, but ");
2728 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
2729 vty_out (vty, "not the NSSA Elected Translator. %s",
2730 VTY_NEWLINE);
2731 else
hassoc6b87812004-12-22 13:09:59 +00002732 vty_out (vty, "never an NSSA Translator. %s",
paulb0a053b2003-06-22 09:04:47 +00002733 VTY_NEWLINE);
2734 }
paul718e3742002-12-13 20:15:29 +00002735 }
paul88d6cf32005-10-29 12:50:09 +00002736 /* Stub-router state for this area */
2737 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
2738 {
ajs649654a2005-11-16 20:17:52 +00002739 char timebuf[OSPF_TIME_DUMP_SIZE];
paul88d6cf32005-10-29 12:50:09 +00002740 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
2741 VTY_NEWLINE);
2742 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
2743 vty_out (vty, " Administratively activated (indefinitely)%s",
2744 VTY_NEWLINE);
2745 if (area->t_stub_router)
2746 vty_out (vty, " Active from startup, %s remaining%s",
2747 ospf_timer_dump (area->t_stub_router, timebuf,
2748 sizeof(timebuf)), VTY_NEWLINE);
2749 }
2750
paul718e3742002-12-13 20:15:29 +00002751 /* Show number of fully adjacent neighbors. */
2752 vty_out (vty, " Number of fully adjacent neighbors in this area:"
paulb0a053b2003-06-22 09:04:47 +00002753 " %d%s", area->full_nbrs, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002754
2755 /* Show authentication type. */
2756 vty_out (vty, " Area has ");
2757 if (area->auth_type == OSPF_AUTH_NULL)
2758 vty_out (vty, "no authentication%s", VTY_NEWLINE);
2759 else if (area->auth_type == OSPF_AUTH_SIMPLE)
2760 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
2761 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
2762 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
2763
2764 if (!OSPF_IS_AREA_BACKBONE (area))
2765 vty_out (vty, " Number of full virtual adjacencies going through"
2766 " this area: %d%s", area->full_vls, VTY_NEWLINE);
2767
2768 /* Show SPF calculation times. */
2769 vty_out (vty, " SPF algorithm executed %d times%s",
2770 area->spf_calculation, VTY_NEWLINE);
2771
2772 /* Show number of LSA. */
2773 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
hassofe71a972004-12-22 16:16:02 +00002774 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2775 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
2776 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
2777 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2778 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
2779 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
2780 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2781 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
2782 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
2783 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2784 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
2785 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
2786 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2787 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
2788 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
2789#ifdef HAVE_OPAQUE_LSA
2790 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2791 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
2792 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
2793 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2794 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
2795 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
2796#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002797 vty_out (vty, "%s", VTY_NEWLINE);
2798}
2799
2800DEFUN (show_ip_ospf,
2801 show_ip_ospf_cmd,
2802 "show ip ospf",
2803 SHOW_STR
2804 IP_STR
2805 "OSPF information\n")
2806{
paul1eb8ef22005-04-07 07:30:20 +00002807 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002808 struct ospf_area * area;
paul020709f2003-04-04 02:44:16 +00002809 struct ospf *ospf;
pauld24f6e22005-10-21 09:23:12 +00002810 struct timeval result;
ajs649654a2005-11-16 20:17:52 +00002811 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00002812
2813 /* Check OSPF is enable. */
paul020709f2003-04-04 02:44:16 +00002814 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00002815 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00002816 {
2817 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
2818 return CMD_SUCCESS;
2819 }
2820
2821 /* Show Router ID. */
2822 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
paul68980082003-03-25 05:07:42 +00002823 inet_ntoa (ospf->router_id),
paul718e3742002-12-13 20:15:29 +00002824 VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00002825
2826 /* Graceful shutdown */
paulc9c93d52005-11-26 13:31:11 +00002827 if (ospf->t_deferred_shutdown)
2828 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
2829 ospf_timer_dump (ospf->t_deferred_shutdown,
paul88d6cf32005-10-29 12:50:09 +00002830 timebuf, sizeof (timebuf)), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002831 /* Show capability. */
2832 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
2833 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
2834 vty_out (vty, " RFC1583Compatibility flag is %s%s",
paul68980082003-03-25 05:07:42 +00002835 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
paul718e3742002-12-13 20:15:29 +00002836 "enabled" : "disabled", VTY_NEWLINE);
2837#ifdef HAVE_OPAQUE_LSA
Paul Jakmae30677a2015-01-20 15:45:36 +00002838 vty_out (vty, " OpaqueCapability flag is %s%s",
paul68980082003-03-25 05:07:42 +00002839 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
paul718e3742002-12-13 20:15:29 +00002840 "enabled" : "disabled",
paul718e3742002-12-13 20:15:29 +00002841 VTY_NEWLINE);
2842#endif /* HAVE_OPAQUE_LSA */
paul88d6cf32005-10-29 12:50:09 +00002843
2844 /* Show stub-router configuration */
2845 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
2846 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2847 {
2848 vty_out (vty, " Stub router advertisement is configured%s",
2849 VTY_NEWLINE);
2850 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2851 vty_out (vty, " Enabled for %us after start-up%s",
2852 ospf->stub_router_startup_time, VTY_NEWLINE);
2853 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
2854 vty_out (vty, " Enabled for %us prior to full shutdown%s",
2855 ospf->stub_router_shutdown_time, VTY_NEWLINE);
2856 }
2857
paul718e3742002-12-13 20:15:29 +00002858 /* Show SPF timers. */
pauld24f6e22005-10-21 09:23:12 +00002859 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
2860 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
2861 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
2862 " Hold time multiplier is currently %d%s",
2863 ospf->spf_delay, VTY_NEWLINE,
2864 ospf->spf_holdtime, VTY_NEWLINE,
2865 ospf->spf_max_holdtime, VTY_NEWLINE,
2866 ospf->spf_hold_multiplier, VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002867 vty_out (vty, " SPF algorithm ");
2868 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
2869 {
Paul Jakma2518efd2006-08-27 06:49:29 +00002870 result = tv_sub (recent_relative_time (), ospf->ts_spf);
paulb8ad39d2005-10-23 15:23:05 +00002871 vty_out (vty, "last executed %s ago%s",
2872 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
2873 VTY_NEWLINE);
Dinesh G Dutt50f38b32014-09-30 12:53:28 -07002874 vty_out (vty, " Last SPF duration %s%s",
2875 ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)),
2876 VTY_NEWLINE);
paulb8ad39d2005-10-23 15:23:05 +00002877 }
2878 else
2879 vty_out (vty, "has not been run%s", VTY_NEWLINE);
pauld24f6e22005-10-21 09:23:12 +00002880 vty_out (vty, " SPF timer %s%s%s",
2881 (ospf->t_spf_calc ? "due in " : "is "),
2882 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
2883 VTY_NEWLINE);
2884
paul718e3742002-12-13 20:15:29 +00002885 /* Show refresh parameters. */
2886 vty_out (vty, " Refresh timer %d secs%s",
paul68980082003-03-25 05:07:42 +00002887 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002888
2889 /* Show ABR/ASBR flags. */
paul68980082003-03-25 05:07:42 +00002890 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
paul718e3742002-12-13 20:15:29 +00002891 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
paul68980082003-03-25 05:07:42 +00002892 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002893
paul68980082003-03-25 05:07:42 +00002894 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
paul718e3742002-12-13 20:15:29 +00002895 vty_out (vty, " This router is an ASBR "
2896 "(injecting external routing information)%s", VTY_NEWLINE);
2897
2898 /* Show Number of AS-external-LSAs. */
hassofe71a972004-12-22 16:16:02 +00002899 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
2900 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
2901 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
2902#ifdef HAVE_OPAQUE_LSA
2903 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
2904 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
2905 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
2906#endif /* HAVE_OPAQUE_LSA */
paul718e3742002-12-13 20:15:29 +00002907 /* Show number of areas attached. */
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00002908 vty_out (vty, " Number of areas attached to this router: %d%s",
2909 listcount (ospf->areas), VTY_NEWLINE);
2910
2911 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
2912 {
2913 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
2914 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
2915 else
2916 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
2917 }
2918
2919 vty_out (vty, "%s",VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002920
2921 /* Show each area status. */
paul1eb8ef22005-04-07 07:30:20 +00002922 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
2923 show_ip_ospf_area (vty, area);
paul718e3742002-12-13 20:15:29 +00002924
2925 return CMD_SUCCESS;
2926}
2927
David Lamparter6b0655a2014-06-04 06:53:35 +02002928
ajsfd651fa2005-03-29 16:08:16 +00002929static void
paul68980082003-03-25 05:07:42 +00002930show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
2931 struct interface *ifp)
paul718e3742002-12-13 20:15:29 +00002932{
ajsfd651fa2005-03-29 16:08:16 +00002933 int is_up;
paul718e3742002-12-13 20:15:29 +00002934 struct ospf_neighbor *nbr;
paul718e3742002-12-13 20:15:29 +00002935 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00002936
paul718e3742002-12-13 20:15:29 +00002937 /* Is interface up? */
ajsfd651fa2005-03-29 16:08:16 +00002938 vty_out (vty, "%s is %s%s", ifp->name,
2939 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
ajsd2fc8892005-04-02 18:38:43 +00002940 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
2941 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
2942 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00002943
2944 /* Is interface OSPF enabled? */
ajsfd651fa2005-03-29 16:08:16 +00002945 if (ospf_oi_count(ifp) == 0)
paul718e3742002-12-13 20:15:29 +00002946 {
2947 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
2948 return;
2949 }
ajsfd651fa2005-03-29 16:08:16 +00002950 else if (!is_up)
2951 {
2952 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
2953 VTY_NEWLINE);
2954 return;
2955 }
2956
paul718e3742002-12-13 20:15:29 +00002957 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
2958 {
2959 struct ospf_interface *oi = rn->info;
2960
2961 if (oi == NULL)
2962 continue;
2963
2964 /* Show OSPF interface information. */
2965 vty_out (vty, " Internet Address %s/%d,",
2966 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
2967
Paul Jakma9c27ef92006-05-04 07:32:57 +00002968 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
2969 {
2970 struct in_addr *dest;
2971 const char *dstr;
2972
Andrew J. Schorre4529632006-12-12 19:18:21 +00002973 if (CONNECTED_PEER(oi->connected)
2974 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
Paul Jakma9c27ef92006-05-04 07:32:57 +00002975 dstr = "Peer";
2976 else
2977 dstr = "Broadcast";
2978
2979 /* For Vlinks, showing the peer address is probably more
2980 * informative than the local interface that is being used
2981 */
2982 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
2983 dest = &oi->vl_data->peer_addr;
2984 else
2985 dest = &oi->connected->destination->u.prefix4;
2986
2987 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
2988 }
hasso3fb9cd62004-10-19 19:44:43 +00002989
paul718e3742002-12-13 20:15:29 +00002990 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
2991 VTY_NEWLINE);
2992
vincentba682532005-09-29 13:52:57 +00002993 vty_out (vty, " MTU mismatch detection:%s%s",
2994 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
2995
paul718e3742002-12-13 20:15:29 +00002996 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
paul68980082003-03-25 05:07:42 +00002997 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
paul718e3742002-12-13 20:15:29 +00002998 oi->output_cost, VTY_NEWLINE);
2999
3000 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
3001 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
3002 PRIORITY (oi), VTY_NEWLINE);
3003
3004 /* Show DR information. */
3005 if (DR (oi).s_addr == 0)
3006 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
3007 else
3008 {
3009 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
3010 if (nbr == NULL)
3011 vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
3012 else
3013 {
3014 vty_out (vty, " Designated Router (ID) %s,",
3015 inet_ntoa (nbr->router_id));
3016 vty_out (vty, " Interface Address %s%s",
3017 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3018 }
3019 }
3020
3021 /* Show BDR information. */
3022 if (BDR (oi).s_addr == 0)
3023 vty_out (vty, " No backup designated router on this network%s",
3024 VTY_NEWLINE);
3025 else
3026 {
3027 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
3028 if (nbr == NULL)
3029 vty_out (vty, " No backup designated router on this network%s",
3030 VTY_NEWLINE);
3031 else
3032 {
3033 vty_out (vty, " Backup Designated Router (ID) %s,",
3034 inet_ntoa (nbr->router_id));
3035 vty_out (vty, " Interface Address %s%s",
3036 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3037 }
3038 }
Paul Jakma7eb5b472009-10-13 16:13:13 +01003039
3040 /* Next network-LSA sequence number we'll use, if we're elected DR */
3041 if (oi->params && ntohl (oi->params->network_lsa_seqnum)
3042 != OSPF_INITIAL_SEQUENCE_NUMBER)
3043 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
3044 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
3045
ajsba6454e2005-02-08 15:37:30 +00003046 vty_out (vty, " Multicast group memberships:");
Paul Jakma429ac782006-06-15 18:40:49 +00003047 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
3048 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
3049 {
3050 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
3051 vty_out (vty, " OSPFAllRouters");
3052 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
3053 vty_out (vty, " OSPFDesignatedRouters");
3054 }
3055 else
ajsba6454e2005-02-08 15:37:30 +00003056 vty_out (vty, " <None>");
3057 vty_out (vty, "%s", VTY_NEWLINE);
3058
paul718e3742002-12-13 20:15:29 +00003059 vty_out (vty, " Timer intervals configured,");
paulf9ad9372005-10-21 00:45:17 +00003060 vty_out (vty, " Hello ");
3061 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
3062 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
3063 else
3064 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
3065 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
3066 OSPF_IF_PARAM (oi, v_wait),
paul718e3742002-12-13 20:15:29 +00003067 OSPF_IF_PARAM (oi, v_wait),
3068 OSPF_IF_PARAM (oi, retransmit_interval),
3069 VTY_NEWLINE);
3070
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00003071 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
paulf9ad9372005-10-21 00:45:17 +00003072 {
ajs649654a2005-11-16 20:17:52 +00003073 char timebuf[OSPF_TIME_DUMP_SIZE];
paulf9ad9372005-10-21 00:45:17 +00003074 vty_out (vty, " Hello due in %s%s",
ajs649654a2005-11-16 20:17:52 +00003075 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
paulf9ad9372005-10-21 00:45:17 +00003076 VTY_NEWLINE);
3077 }
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00003078 else /* passive-interface is set */
paul718e3742002-12-13 20:15:29 +00003079 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
3080
3081 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
paul68980082003-03-25 05:07:42 +00003082 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
paul718e3742002-12-13 20:15:29 +00003083 VTY_NEWLINE);
3084 }
3085}
3086
3087DEFUN (show_ip_ospf_interface,
3088 show_ip_ospf_interface_cmd,
3089 "show ip ospf interface [INTERFACE]",
3090 SHOW_STR
3091 IP_STR
3092 "OSPF information\n"
3093 "Interface information\n"
3094 "Interface name\n")
3095{
3096 struct interface *ifp;
paul020709f2003-04-04 02:44:16 +00003097 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003098 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003099
paul020709f2003-04-04 02:44:16 +00003100 ospf = ospf_lookup ();
Paul Jakmacac3b5c2006-05-11 13:31:11 +00003101 if (ospf == NULL)
3102 {
3103 vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
3104 return CMD_SUCCESS;
3105 }
paul020709f2003-04-04 02:44:16 +00003106
paul718e3742002-12-13 20:15:29 +00003107 /* Show All Interfaces. */
3108 if (argc == 0)
paul1eb8ef22005-04-07 07:30:20 +00003109 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
3110 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00003111 /* Interface name is specified. */
3112 else
3113 {
3114 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
3115 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
3116 else
paul68980082003-03-25 05:07:42 +00003117 show_ip_ospf_interface_sub (vty, ospf, ifp);
paul718e3742002-12-13 20:15:29 +00003118 }
3119
3120 return CMD_SUCCESS;
3121}
3122
paul4dadc292005-05-06 21:37:42 +00003123static void
pauld24f6e22005-10-21 09:23:12 +00003124show_ip_ospf_neighbour_header (struct vty *vty)
3125{
3126 vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3127 VTY_NEWLINE,
3128 "Neighbor ID", "Pri", "State", "Dead Time",
3129 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3130 VTY_NEWLINE);
3131}
3132
3133static void
paul718e3742002-12-13 20:15:29 +00003134show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
3135{
3136 struct route_node *rn;
3137 struct ospf_neighbor *nbr;
3138 char msgbuf[16];
ajs649654a2005-11-16 20:17:52 +00003139 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003140
3141 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3142 if ((nbr = rn->info))
3143 /* Do not show myself. */
3144 if (nbr != oi->nbr_self)
3145 /* Down state is not shown. */
3146 if (nbr->state != NSM_Down)
3147 {
3148 ospf_nbr_state_message (nbr, msgbuf, 16);
3149
3150 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
pauld24f6e22005-10-21 09:23:12 +00003151 vty_out (vty, "%-15s %3d %-15s ",
3152 "-", nbr->priority,
3153 msgbuf);
3154 else
3155 vty_out (vty, "%-15s %3d %-15s ",
3156 inet_ntoa (nbr->router_id), nbr->priority,
3157 msgbuf);
3158
3159 vty_out (vty, "%9s ",
3160 ospf_timer_dump (nbr->t_inactivity, timebuf,
3161 sizeof(timebuf)));
3162
paul718e3742002-12-13 20:15:29 +00003163 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
pauld24f6e22005-10-21 09:23:12 +00003164 vty_out (vty, "%-20s %5ld %5ld %5d%s",
paul718e3742002-12-13 20:15:29 +00003165 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
3166 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
3167 VTY_NEWLINE);
3168 }
3169}
3170
3171DEFUN (show_ip_ospf_neighbor,
3172 show_ip_ospf_neighbor_cmd,
3173 "show ip ospf neighbor",
3174 SHOW_STR
3175 IP_STR
3176 "OSPF information\n"
3177 "Neighbor list\n")
3178{
paul020709f2003-04-04 02:44:16 +00003179 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003180 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003181 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003182
paul020709f2003-04-04 02:44:16 +00003183 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003184 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003185 {
3186 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3187 return CMD_SUCCESS;
3188 }
3189
pauld24f6e22005-10-21 09:23:12 +00003190 show_ip_ospf_neighbour_header (vty);
paul718e3742002-12-13 20:15:29 +00003191
paul1eb8ef22005-04-07 07:30:20 +00003192 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3193 show_ip_ospf_neighbor_sub (vty, oi);
paul718e3742002-12-13 20:15:29 +00003194
3195 return CMD_SUCCESS;
3196}
3197
3198DEFUN (show_ip_ospf_neighbor_all,
3199 show_ip_ospf_neighbor_all_cmd,
3200 "show ip ospf neighbor all",
3201 SHOW_STR
3202 IP_STR
3203 "OSPF information\n"
3204 "Neighbor list\n"
3205 "include down status neighbor\n")
3206{
Joakim Tjernlund35f89142008-07-01 16:54:07 +02003207 struct ospf *ospf = ospf_lookup ();
hasso52dc7ee2004-09-23 19:18:23 +00003208 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003209 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003210
paul68980082003-03-25 05:07:42 +00003211 if (ospf == NULL)
paul718e3742002-12-13 20:15:29 +00003212 {
3213 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3214 return CMD_SUCCESS;
3215 }
pauld24f6e22005-10-21 09:23:12 +00003216
3217 show_ip_ospf_neighbour_header (vty);
3218
paul1eb8ef22005-04-07 07:30:20 +00003219 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003220 {
hasso52dc7ee2004-09-23 19:18:23 +00003221 struct listnode *nbr_node;
paul1eb8ef22005-04-07 07:30:20 +00003222 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003223
3224 show_ip_ospf_neighbor_sub (vty, oi);
3225
3226 /* print Down neighbor status */
paul1eb8ef22005-04-07 07:30:20 +00003227 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
paul718e3742002-12-13 20:15:29 +00003228 {
paul718e3742002-12-13 20:15:29 +00003229 if (nbr_nbma->nbr == NULL
3230 || nbr_nbma->nbr->state == NSM_Down)
3231 {
pauld24f6e22005-10-21 09:23:12 +00003232 vty_out (vty, "%-15s %3d %-15s %9s ",
paul718e3742002-12-13 20:15:29 +00003233 "-", nbr_nbma->priority, "Down", "-");
pauld24f6e22005-10-21 09:23:12 +00003234 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
paul718e3742002-12-13 20:15:29 +00003235 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
3236 0, 0, 0, VTY_NEWLINE);
3237 }
3238 }
3239 }
3240
3241 return CMD_SUCCESS;
3242}
3243
3244DEFUN (show_ip_ospf_neighbor_int,
3245 show_ip_ospf_neighbor_int_cmd,
hassobb5b7552005-08-21 20:01:15 +00003246 "show ip ospf neighbor IFNAME",
paul718e3742002-12-13 20:15:29 +00003247 SHOW_STR
3248 IP_STR
3249 "OSPF information\n"
3250 "Neighbor list\n"
3251 "Interface name\n")
3252{
paul020709f2003-04-04 02:44:16 +00003253 struct ospf *ospf;
hassobb5b7552005-08-21 20:01:15 +00003254 struct interface *ifp;
3255 struct route_node *rn;
3256
3257 ifp = if_lookup_by_name (argv[0]);
3258 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003259 {
hassobb5b7552005-08-21 20:01:15 +00003260 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003261 return CMD_WARNING;
3262 }
3263
paul020709f2003-04-04 02:44:16 +00003264 ospf = ospf_lookup ();
3265 if (ospf == NULL)
3266 {
3267 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3268 return CMD_SUCCESS;
3269 }
pauld24f6e22005-10-21 09:23:12 +00003270
3271 show_ip_ospf_neighbour_header (vty);
3272
hassobb5b7552005-08-21 20:01:15 +00003273 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00003274 {
hassobb5b7552005-08-21 20:01:15 +00003275 struct ospf_interface *oi = rn->info;
3276
3277 if (oi == NULL)
3278 continue;
3279
paul718e3742002-12-13 20:15:29 +00003280 show_ip_ospf_neighbor_sub (vty, oi);
3281 }
3282
3283 return CMD_SUCCESS;
3284}
3285
paul4dadc292005-05-06 21:37:42 +00003286static void
paul718e3742002-12-13 20:15:29 +00003287show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
3288 struct ospf_nbr_nbma *nbr_nbma)
3289{
ajs649654a2005-11-16 20:17:52 +00003290 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003291
3292 /* Show neighbor ID. */
3293 vty_out (vty, " Neighbor %s,", "-");
3294
3295 /* Show interface address. */
3296 vty_out (vty, " interface address %s%s",
3297 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
3298 /* Show Area ID. */
3299 vty_out (vty, " In the area %s via interface %s%s",
3300 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
3301 /* Show neighbor priority and state. */
3302 vty_out (vty, " Neighbor priority is %d, State is %s,",
3303 nbr_nbma->priority, "Down");
3304 /* Show state changes. */
3305 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
3306
3307 /* Show PollInterval */
3308 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
3309
3310 /* Show poll-interval timer. */
3311 vty_out (vty, " Poll timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003312 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
3313 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003314
3315 /* Show poll-interval timer thread. */
3316 vty_out (vty, " Thread Poll Timer %s%s",
3317 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
3318}
3319
paul4dadc292005-05-06 21:37:42 +00003320static void
paul718e3742002-12-13 20:15:29 +00003321show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3322 struct ospf_neighbor *nbr)
3323{
ajs649654a2005-11-16 20:17:52 +00003324 char timebuf[OSPF_TIME_DUMP_SIZE];
paul718e3742002-12-13 20:15:29 +00003325
3326 /* Show neighbor ID. */
3327 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
3328 vty_out (vty, " Neighbor %s,", "-");
3329 else
3330 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
3331
3332 /* Show interface address. */
3333 vty_out (vty, " interface address %s%s",
3334 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3335 /* Show Area ID. */
3336 vty_out (vty, " In the area %s via interface %s%s",
3337 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
3338 /* Show neighbor priority and state. */
3339 vty_out (vty, " Neighbor priority is %d, State is %s,",
3340 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
3341 /* Show state changes. */
3342 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
Paul Jakma3fed4162006-07-25 20:44:12 +00003343 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
Paul Jakma90c33172006-07-11 17:57:25 +00003344 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003345 struct timeval res
3346 = tv_sub (recent_relative_time (), nbr->ts_last_progress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003347 vty_out (vty, " Most recent state change statistics:%s",
3348 VTY_NEWLINE);
3349 vty_out (vty, " Progressive change %s ago%s",
Paul Jakma90c33172006-07-11 17:57:25 +00003350 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
Paul Jakma3fed4162006-07-25 20:44:12 +00003351 VTY_NEWLINE);
3352 }
3353 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
3354 {
Paul Jakma2518efd2006-08-27 06:49:29 +00003355 struct timeval res
3356 = tv_sub (recent_relative_time (), nbr->ts_last_regress);
Paul Jakma3fed4162006-07-25 20:44:12 +00003357 vty_out (vty, " Regressive change %s ago, due to %s%s",
3358 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
3359 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
Paul Jakma90c33172006-07-11 17:57:25 +00003360 VTY_NEWLINE);
3361 }
paul718e3742002-12-13 20:15:29 +00003362 /* Show Designated Rotuer ID. */
3363 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
3364 /* Show Backup Designated Rotuer ID. */
3365 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
3366 /* Show options. */
3367 vty_out (vty, " Options %d %s%s", nbr->options,
3368 ospf_options_dump (nbr->options), VTY_NEWLINE);
3369 /* Show Router Dead interval timer. */
3370 vty_out (vty, " Dead timer due in %s%s",
pauld24f6e22005-10-21 09:23:12 +00003371 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
3372 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003373 /* Show Database Summary list. */
3374 vty_out (vty, " Database Summary List %d%s",
3375 ospf_db_summary_count (nbr), VTY_NEWLINE);
3376 /* Show Link State Request list. */
3377 vty_out (vty, " Link State Request List %ld%s",
3378 ospf_ls_request_count (nbr), VTY_NEWLINE);
3379 /* Show Link State Retransmission list. */
3380 vty_out (vty, " Link State Retransmission List %ld%s",
3381 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
3382 /* Show inactivity timer thread. */
3383 vty_out (vty, " Thread Inactivity Timer %s%s",
3384 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
3385 /* Show Database Description retransmission thread. */
3386 vty_out (vty, " Thread Database Description Retransmision %s%s",
3387 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
3388 /* Show Link State Request Retransmission thread. */
3389 vty_out (vty, " Thread Link State Request Retransmission %s%s",
3390 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
3391 /* Show Link State Update Retransmission thread. */
3392 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
3393 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
3394}
3395
3396DEFUN (show_ip_ospf_neighbor_id,
3397 show_ip_ospf_neighbor_id_cmd,
3398 "show ip ospf neighbor A.B.C.D",
3399 SHOW_STR
3400 IP_STR
3401 "OSPF information\n"
3402 "Neighbor list\n"
3403 "Neighbor ID\n")
3404{
paul020709f2003-04-04 02:44:16 +00003405 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003406 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003407 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003408 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003409 struct in_addr router_id;
3410 int ret;
3411
3412 ret = inet_aton (argv[0], &router_id);
3413 if (!ret)
3414 {
3415 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
3416 return CMD_WARNING;
3417 }
3418
paul020709f2003-04-04 02:44:16 +00003419 ospf = ospf_lookup ();
3420 if (ospf == NULL)
3421 {
3422 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3423 return CMD_SUCCESS;
3424 }
3425
paul1eb8ef22005-04-07 07:30:20 +00003426 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3427 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
Andrew J. Schorr1c066bf2006-06-30 16:53:47 +00003428 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003429
paul718e3742002-12-13 20:15:29 +00003430 return CMD_SUCCESS;
3431}
3432
3433DEFUN (show_ip_ospf_neighbor_detail,
3434 show_ip_ospf_neighbor_detail_cmd,
3435 "show ip ospf neighbor detail",
3436 SHOW_STR
3437 IP_STR
3438 "OSPF information\n"
3439 "Neighbor list\n"
3440 "detail of all neighbors\n")
3441{
paul020709f2003-04-04 02:44:16 +00003442 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00003443 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00003444 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00003445
paul020709f2003-04-04 02:44:16 +00003446 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003447 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003448 {
3449 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3450 return CMD_SUCCESS;
3451 }
paul718e3742002-12-13 20:15:29 +00003452
paul1eb8ef22005-04-07 07:30:20 +00003453 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003454 {
paul718e3742002-12-13 20:15:29 +00003455 struct route_node *rn;
3456 struct ospf_neighbor *nbr;
3457
3458 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3459 if ((nbr = rn->info))
3460 if (nbr != oi->nbr_self)
3461 if (nbr->state != NSM_Down)
3462 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
3463 }
3464
3465 return CMD_SUCCESS;
3466}
3467
3468DEFUN (show_ip_ospf_neighbor_detail_all,
3469 show_ip_ospf_neighbor_detail_all_cmd,
3470 "show ip ospf neighbor detail all",
3471 SHOW_STR
3472 IP_STR
3473 "OSPF information\n"
3474 "Neighbor list\n"
3475 "detail of all neighbors\n"
3476 "include down status neighbor\n")
3477{
paul020709f2003-04-04 02:44:16 +00003478 struct ospf *ospf;
hasso52dc7ee2004-09-23 19:18:23 +00003479 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00003480 struct ospf_interface *oi;
paul718e3742002-12-13 20:15:29 +00003481
paul020709f2003-04-04 02:44:16 +00003482 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00003483 if (ospf == NULL)
paul020709f2003-04-04 02:44:16 +00003484 {
3485 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3486 return CMD_SUCCESS;
3487 }
paul718e3742002-12-13 20:15:29 +00003488
paul1eb8ef22005-04-07 07:30:20 +00003489 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
paul718e3742002-12-13 20:15:29 +00003490 {
paul718e3742002-12-13 20:15:29 +00003491 struct route_node *rn;
3492 struct ospf_neighbor *nbr;
paul1eb8ef22005-04-07 07:30:20 +00003493 struct ospf_nbr_nbma *nbr_nbma;
paul718e3742002-12-13 20:15:29 +00003494
3495 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3496 if ((nbr = rn->info))
3497 if (nbr != oi->nbr_self)
3498 if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
3499 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
3500
3501 if (oi->type == OSPF_IFTYPE_NBMA)
3502 {
hasso52dc7ee2004-09-23 19:18:23 +00003503 struct listnode *nd;
paul718e3742002-12-13 20:15:29 +00003504
paul1eb8ef22005-04-07 07:30:20 +00003505 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
3506 if (nbr_nbma->nbr == NULL
3507 || nbr_nbma->nbr->state == NSM_Down)
3508 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
paul718e3742002-12-13 20:15:29 +00003509 }
3510 }
3511
3512 return CMD_SUCCESS;
3513}
3514
3515DEFUN (show_ip_ospf_neighbor_int_detail,
3516 show_ip_ospf_neighbor_int_detail_cmd,
hassobb5b7552005-08-21 20:01:15 +00003517 "show ip ospf neighbor IFNAME detail",
paul718e3742002-12-13 20:15:29 +00003518 SHOW_STR
3519 IP_STR
3520 "OSPF information\n"
3521 "Neighbor list\n"
hassobb5b7552005-08-21 20:01:15 +00003522 "Interface name\n"
paul718e3742002-12-13 20:15:29 +00003523 "detail of all neighbors")
3524{
paul020709f2003-04-04 02:44:16 +00003525 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00003526 struct ospf_interface *oi;
hassobb5b7552005-08-21 20:01:15 +00003527 struct interface *ifp;
3528 struct route_node *rn, *nrn;
3529 struct ospf_neighbor *nbr;
3530
3531 ifp = if_lookup_by_name (argv[0]);
3532 if (!ifp)
paul718e3742002-12-13 20:15:29 +00003533 {
hassobb5b7552005-08-21 20:01:15 +00003534 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003535 return CMD_WARNING;
3536 }
3537
paul020709f2003-04-04 02:44:16 +00003538 ospf = ospf_lookup ();
3539 if (ospf == NULL)
3540 {
3541 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
3542 return CMD_SUCCESS;
3543 }
paul68980082003-03-25 05:07:42 +00003544
paul718e3742002-12-13 20:15:29 +00003545
hassobb5b7552005-08-21 20:01:15 +00003546 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3547 if ((oi = rn->info))
3548 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
3549 if ((nbr = nrn->info))
paul718e3742002-12-13 20:15:29 +00003550 if (nbr != oi->nbr_self)
3551 if (nbr->state != NSM_Down)
3552 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
paul718e3742002-12-13 20:15:29 +00003553
3554 return CMD_SUCCESS;
3555}
3556
David Lamparter6b0655a2014-06-04 06:53:35 +02003557
paul718e3742002-12-13 20:15:29 +00003558/* Show functions */
paul4dadc292005-05-06 21:37:42 +00003559static int
paul020709f2003-04-04 02:44:16 +00003560show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
paul718e3742002-12-13 20:15:29 +00003561{
paul718e3742002-12-13 20:15:29 +00003562 struct router_lsa *rl;
3563 struct summary_lsa *sl;
3564 struct as_external_lsa *asel;
3565 struct prefix_ipv4 p;
3566
3567 if (lsa != NULL)
3568 /* If self option is set, check LSA self flag. */
3569 if (self == 0 || IS_LSA_SELF (lsa))
3570 {
3571 /* LSA common part show. */
3572 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
3573 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
3574 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
3575 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
3576 /* LSA specific part show. */
3577 switch (lsa->data->type)
3578 {
3579 case OSPF_ROUTER_LSA:
3580 rl = (struct router_lsa *) lsa->data;
3581 vty_out (vty, " %-d", ntohs (rl->links));
3582 break;
3583 case OSPF_SUMMARY_LSA:
3584 sl = (struct summary_lsa *) lsa->data;
3585
3586 p.family = AF_INET;
3587 p.prefix = sl->header.id;
3588 p.prefixlen = ip_masklen (sl->mask);
3589 apply_mask_ipv4 (&p);
3590
3591 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
3592 break;
3593 case OSPF_AS_EXTERNAL_LSA:
paul551a8972003-05-18 15:22:55 +00003594 case OSPF_AS_NSSA_LSA:
paul718e3742002-12-13 20:15:29 +00003595 asel = (struct as_external_lsa *) lsa->data;
3596
3597 p.family = AF_INET;
3598 p.prefix = asel->header.id;
3599 p.prefixlen = ip_masklen (asel->mask);
3600 apply_mask_ipv4 (&p);
3601
3602 vty_out (vty, " %s %s/%d [0x%lx]",
3603 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
3604 inet_ntoa (p.prefix), p.prefixlen,
3605 (u_long)ntohl (asel->e[0].route_tag));
3606 break;
3607 case OSPF_NETWORK_LSA:
3608 case OSPF_ASBR_SUMMARY_LSA:
3609#ifdef HAVE_OPAQUE_LSA
3610 case OSPF_OPAQUE_LINK_LSA:
3611 case OSPF_OPAQUE_AREA_LSA:
3612 case OSPF_OPAQUE_AS_LSA:
3613#endif /* HAVE_OPAQUE_LSA */
3614 default:
3615 break;
3616 }
3617 vty_out (vty, VTY_NEWLINE);
3618 }
3619
3620 return 0;
3621}
3622
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003623static const char *show_database_desc[] =
paul718e3742002-12-13 20:15:29 +00003624{
3625 "unknown",
3626 "Router Link States",
3627 "Net Link States",
3628 "Summary Link States",
3629 "ASBR-Summary Link States",
3630 "AS External Link States",
paul718e3742002-12-13 20:15:29 +00003631 "Group Membership LSA",
3632 "NSSA-external Link States",
paul718e3742002-12-13 20:15:29 +00003633#ifdef HAVE_OPAQUE_LSA
3634 "Type-8 LSA",
3635 "Link-Local Opaque-LSA",
3636 "Area-Local Opaque-LSA",
3637 "AS-external Opaque-LSA",
3638#endif /* HAVE_OPAQUE_LSA */
3639};
3640
Stephen Hemminger8b6a15b2009-12-03 19:25:04 +03003641static const char *show_database_header[] =
paul718e3742002-12-13 20:15:29 +00003642{
3643 "",
3644 "Link ID ADV Router Age Seq# CkSum Link count",
3645 "Link ID ADV Router Age Seq# CkSum",
3646 "Link ID ADV Router Age Seq# CkSum Route",
3647 "Link ID ADV Router Age Seq# CkSum",
3648 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003649 " --- header for Group Member ----",
3650 "Link ID ADV Router Age Seq# CkSum Route",
paul718e3742002-12-13 20:15:29 +00003651#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003652 " --- type-8 ---",
3653 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3654 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3655 "Opaque-Type/Id ADV Router Age Seq# CkSum",
3656#endif /* HAVE_OPAQUE_LSA */
3657};
3658
paul4dadc292005-05-06 21:37:42 +00003659static void
paul718e3742002-12-13 20:15:29 +00003660show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
3661{
3662 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
paul4957f492003-06-27 01:28:45 +00003663
paul718e3742002-12-13 20:15:29 +00003664 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
paul4957f492003-06-27 01:28:45 +00003665 vty_out (vty, " Options: 0x%-2x : %s%s",
3666 lsa->data->options,
3667 ospf_options_dump(lsa->data->options),
3668 VTY_NEWLINE);
3669 vty_out (vty, " LS Flags: 0x%-2x %s%s",
paul9d526032003-06-30 22:46:14 +00003670 lsa->flags,
paul4957f492003-06-27 01:28:45 +00003671 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
3672 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003673
3674 if (lsa->data->type == OSPF_ROUTER_LSA)
3675 {
3676 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
3677
3678 if (rlsa->flags)
3679 vty_out (vty, " :%s%s%s%s",
3680 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
3681 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
3682 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
3683 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
3684
3685 vty_out (vty, "%s", VTY_NEWLINE);
3686 }
3687 vty_out (vty, " LS Type: %s%s",
3688 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
3689 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
3690 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
3691 vty_out (vty, " Advertising Router: %s%s",
3692 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
3693 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
3694 VTY_NEWLINE);
3695 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
3696 VTY_NEWLINE);
3697 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
3698}
3699
hassoeb1ce602004-10-08 08:17:22 +00003700const char *link_type_desc[] =
paul718e3742002-12-13 20:15:29 +00003701{
3702 "(null)",
3703 "another Router (point-to-point)",
3704 "a Transit Network",
3705 "Stub Network",
3706 "a Virtual Link",
3707};
3708
hassoeb1ce602004-10-08 08:17:22 +00003709const char *link_id_desc[] =
paul718e3742002-12-13 20:15:29 +00003710{
3711 "(null)",
3712 "Neighboring Router ID",
3713 "Designated Router address",
paul68980082003-03-25 05:07:42 +00003714 "Net",
paul718e3742002-12-13 20:15:29 +00003715 "Neighboring Router ID",
3716};
3717
hassoeb1ce602004-10-08 08:17:22 +00003718const char *link_data_desc[] =
paul718e3742002-12-13 20:15:29 +00003719{
3720 "(null)",
3721 "Router Interface address",
3722 "Router Interface address",
3723 "Network Mask",
3724 "Router Interface address",
3725};
3726
3727/* Show router-LSA each Link information. */
paul4dadc292005-05-06 21:37:42 +00003728static void
paul718e3742002-12-13 20:15:29 +00003729show_ip_ospf_database_router_links (struct vty *vty,
3730 struct router_lsa *rl)
3731{
Donald Sharp0bc874b2015-07-29 19:16:13 -04003732 int len, type;
3733 unsigned int i;
paul718e3742002-12-13 20:15:29 +00003734
3735 len = ntohs (rl->header.length) - 4;
3736 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
3737 {
3738 type = rl->link[i].type;
3739
3740 vty_out (vty, " Link connected to: %s%s",
3741 link_type_desc[type], VTY_NEWLINE);
3742 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
3743 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
3744 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
3745 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
3746 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
3747 vty_out (vty, " TOS 0 Metric: %d%s",
3748 ntohs (rl->link[i].metric), VTY_NEWLINE);
3749 vty_out (vty, "%s", VTY_NEWLINE);
3750 }
3751}
3752
3753/* Show router-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003754static int
paul718e3742002-12-13 20:15:29 +00003755show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3756{
3757 if (lsa != NULL)
3758 {
3759 struct router_lsa *rl = (struct router_lsa *) lsa->data;
3760
3761 show_ip_ospf_database_header (vty, lsa);
3762
3763 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
3764 VTY_NEWLINE, VTY_NEWLINE);
3765
3766 show_ip_ospf_database_router_links (vty, rl);
paulb0a053b2003-06-22 09:04:47 +00003767 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003768 }
3769
3770 return 0;
3771}
3772
3773/* Show network-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003774static int
paul718e3742002-12-13 20:15:29 +00003775show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3776{
3777 int length, i;
3778
3779 if (lsa != NULL)
3780 {
3781 struct network_lsa *nl = (struct network_lsa *) lsa->data;
3782
3783 show_ip_ospf_database_header (vty, lsa);
3784
3785 vty_out (vty, " Network Mask: /%d%s",
3786 ip_masklen (nl->mask), VTY_NEWLINE);
3787
3788 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
3789
3790 for (i = 0; length > 0; i++, length -= 4)
3791 vty_out (vty, " Attached Router: %s%s",
3792 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
3793
3794 vty_out (vty, "%s", VTY_NEWLINE);
3795 }
3796
3797 return 0;
3798}
3799
3800/* Show summary-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003801static int
paul718e3742002-12-13 20:15:29 +00003802show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3803{
3804 if (lsa != NULL)
3805 {
3806 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3807
3808 show_ip_ospf_database_header (vty, lsa);
3809
3810 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
3811 VTY_NEWLINE);
3812 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3813 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003814 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003815 }
3816
3817 return 0;
3818}
3819
3820/* Show summary-ASBR-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003821static int
paul718e3742002-12-13 20:15:29 +00003822show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3823{
3824 if (lsa != NULL)
3825 {
3826 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
3827
3828 show_ip_ospf_database_header (vty, lsa);
3829
3830 vty_out (vty, " Network Mask: /%d%s",
3831 ip_masklen (sl->mask), VTY_NEWLINE);
3832 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
3833 VTY_NEWLINE);
paulb0a053b2003-06-22 09:04:47 +00003834 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00003835 }
3836
3837 return 0;
3838}
3839
3840/* Show AS-external-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003841static int
paul718e3742002-12-13 20:15:29 +00003842show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3843{
3844 if (lsa != NULL)
3845 {
3846 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3847
3848 show_ip_ospf_database_header (vty, lsa);
3849
3850 vty_out (vty, " Network Mask: /%d%s",
3851 ip_masklen (al->mask), VTY_NEWLINE);
3852 vty_out (vty, " Metric Type: %s%s",
3853 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3854 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3855 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3856 vty_out (vty, " Metric: %d%s",
3857 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3858 vty_out (vty, " Forward Address: %s%s",
3859 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3860
3861 vty_out (vty, " External Route Tag: %lu%s%s",
3862 (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3863 }
3864
3865 return 0;
3866}
3867
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003868#if 0
paul4dadc292005-05-06 21:37:42 +00003869static int
paul718e3742002-12-13 20:15:29 +00003870show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
3871{
3872 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3873
3874 /* show_ip_ospf_database_header (vty, lsa); */
3875
ajs2a42e282004-12-08 18:43:03 +00003876 zlog_debug( " Network Mask: /%d%s",
paul718e3742002-12-13 20:15:29 +00003877 ip_masklen (al->mask), "\n");
ajs2a42e282004-12-08 18:43:03 +00003878 zlog_debug( " Metric Type: %s%s",
paul718e3742002-12-13 20:15:29 +00003879 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3880 "2 (Larger than any link state path)" : "1", "\n");
ajs2a42e282004-12-08 18:43:03 +00003881 zlog_debug( " TOS: 0%s", "\n");
3882 zlog_debug( " Metric: %d%s",
paul718e3742002-12-13 20:15:29 +00003883 GET_METRIC (al->e[0].metric), "\n");
ajs2a42e282004-12-08 18:43:03 +00003884 zlog_debug( " Forward Address: %s%s",
paul718e3742002-12-13 20:15:29 +00003885 inet_ntoa (al->e[0].fwd_addr), "\n");
3886
ajs2a42e282004-12-08 18:43:03 +00003887 zlog_debug( " External Route Tag: %u%s%s",
paul718e3742002-12-13 20:15:29 +00003888 ntohl (al->e[0].route_tag), "\n", "\n");
3889
3890 return 0;
3891}
Stephen Hemminger075e12f2011-12-06 23:54:17 +04003892#endif
paul718e3742002-12-13 20:15:29 +00003893
3894/* Show AS-NSSA-LSA detail information. */
paul4dadc292005-05-06 21:37:42 +00003895static int
paul718e3742002-12-13 20:15:29 +00003896show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3897{
3898 if (lsa != NULL)
3899 {
3900 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
3901
3902 show_ip_ospf_database_header (vty, lsa);
3903
3904 vty_out (vty, " Network Mask: /%d%s",
3905 ip_masklen (al->mask), VTY_NEWLINE);
3906 vty_out (vty, " Metric Type: %s%s",
3907 IS_EXTERNAL_METRIC (al->e[0].tos) ?
3908 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
3909 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
3910 vty_out (vty, " Metric: %d%s",
3911 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
3912 vty_out (vty, " NSSA: Forward Address: %s%s",
3913 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
3914
3915 vty_out (vty, " External Route Tag: %u%s%s",
3916 ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
3917 }
3918
3919 return 0;
3920}
3921
paul4dadc292005-05-06 21:37:42 +00003922static int
paul718e3742002-12-13 20:15:29 +00003923show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
3924{
3925 return 0;
3926}
3927
3928#ifdef HAVE_OPAQUE_LSA
paul4dadc292005-05-06 21:37:42 +00003929static int
paul718e3742002-12-13 20:15:29 +00003930show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
3931{
3932 if (lsa != NULL)
3933 {
3934 show_ip_ospf_database_header (vty, lsa);
3935 show_opaque_info_detail (vty, lsa);
3936
3937 vty_out (vty, "%s", VTY_NEWLINE);
3938 }
3939 return 0;
3940}
3941#endif /* HAVE_OPAQUE_LSA */
3942
3943int (*show_function[])(struct vty *, struct ospf_lsa *) =
3944{
3945 NULL,
3946 show_router_lsa_detail,
3947 show_network_lsa_detail,
3948 show_summary_lsa_detail,
3949 show_summary_asbr_lsa_detail,
3950 show_as_external_lsa_detail,
paul718e3742002-12-13 20:15:29 +00003951 show_func_dummy,
3952 show_as_nssa_lsa_detail, /* almost same as external */
paul718e3742002-12-13 20:15:29 +00003953#ifdef HAVE_OPAQUE_LSA
paul718e3742002-12-13 20:15:29 +00003954 NULL, /* type-8 */
3955 show_opaque_lsa_detail,
3956 show_opaque_lsa_detail,
3957 show_opaque_lsa_detail,
3958#endif /* HAVE_OPAQUE_LSA */
3959};
3960
paul4dadc292005-05-06 21:37:42 +00003961static void
paul718e3742002-12-13 20:15:29 +00003962show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
3963 struct in_addr *adv_router)
3964{
3965 memset (lp, 0, sizeof (struct prefix_ls));
3966 lp->family = 0;
3967 if (id == NULL)
3968 lp->prefixlen = 0;
3969 else if (adv_router == NULL)
3970 {
3971 lp->prefixlen = 32;
3972 lp->id = *id;
3973 }
3974 else
3975 {
3976 lp->prefixlen = 64;
3977 lp->id = *id;
3978 lp->adv_router = *adv_router;
3979 }
3980}
3981
paul4dadc292005-05-06 21:37:42 +00003982static void
paul718e3742002-12-13 20:15:29 +00003983show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
3984 struct in_addr *id, struct in_addr *adv_router)
3985{
3986 struct prefix_ls lp;
3987 struct route_node *rn, *start;
3988 struct ospf_lsa *lsa;
3989
3990 show_lsa_prefix_set (vty, &lp, id, adv_router);
3991 start = route_node_get (rt, (struct prefix *) &lp);
3992 if (start)
3993 {
3994 route_lock_node (start);
3995 for (rn = start; rn; rn = route_next_until (rn, start))
3996 if ((lsa = rn->info))
3997 {
paul718e3742002-12-13 20:15:29 +00003998 if (show_function[lsa->data->type] != NULL)
3999 show_function[lsa->data->type] (vty, lsa);
4000 }
4001 route_unlock_node (start);
4002 }
4003}
4004
4005/* Show detail LSA information
4006 -- if id is NULL then show all LSAs. */
paul4dadc292005-05-06 21:37:42 +00004007static void
paul020709f2003-04-04 02:44:16 +00004008show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00004009 struct in_addr *id, struct in_addr *adv_router)
4010{
hasso52dc7ee2004-09-23 19:18:23 +00004011 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00004012 struct ospf_area *area;
4013
paul718e3742002-12-13 20:15:29 +00004014 switch (type)
4015 {
4016 case OSPF_AS_EXTERNAL_LSA:
4017#ifdef HAVE_OPAQUE_LSA
4018 case OSPF_OPAQUE_AS_LSA:
4019#endif /* HAVE_OPAQUE_LSA */
4020 vty_out (vty, " %s %s%s",
4021 show_database_desc[type],
4022 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00004023 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
paul718e3742002-12-13 20:15:29 +00004024 break;
4025 default:
paul1eb8ef22005-04-07 07:30:20 +00004026 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00004027 {
paul718e3742002-12-13 20:15:29 +00004028 vty_out (vty, "%s %s (Area %s)%s%s",
4029 VTY_NEWLINE, show_database_desc[type],
4030 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
4031 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
4032 }
4033 break;
4034 }
4035}
4036
paul4dadc292005-05-06 21:37:42 +00004037static void
paul718e3742002-12-13 20:15:29 +00004038show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
4039 struct in_addr *adv_router)
4040{
4041 struct route_node *rn;
4042 struct ospf_lsa *lsa;
4043
4044 for (rn = route_top (rt); rn; rn = route_next (rn))
4045 if ((lsa = rn->info))
4046 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
4047 {
paul718e3742002-12-13 20:15:29 +00004048 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
4049 continue;
paul718e3742002-12-13 20:15:29 +00004050 if (show_function[lsa->data->type] != NULL)
4051 show_function[lsa->data->type] (vty, lsa);
4052 }
4053}
4054
4055/* Show detail LSA information. */
paul4dadc292005-05-06 21:37:42 +00004056static void
paul020709f2003-04-04 02:44:16 +00004057show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
paul718e3742002-12-13 20:15:29 +00004058 struct in_addr *adv_router)
4059{
hasso52dc7ee2004-09-23 19:18:23 +00004060 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00004061 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00004062
4063 switch (type)
4064 {
4065 case OSPF_AS_EXTERNAL_LSA:
4066#ifdef HAVE_OPAQUE_LSA
4067 case OSPF_OPAQUE_AS_LSA:
4068#endif /* HAVE_OPAQUE_LSA */
4069 vty_out (vty, " %s %s%s",
4070 show_database_desc[type],
4071 VTY_NEWLINE, VTY_NEWLINE);
paul68980082003-03-25 05:07:42 +00004072 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
paul718e3742002-12-13 20:15:29 +00004073 adv_router);
4074 break;
4075 default:
paul1eb8ef22005-04-07 07:30:20 +00004076 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00004077 {
paul718e3742002-12-13 20:15:29 +00004078 vty_out (vty, "%s %s (Area %s)%s%s",
4079 VTY_NEWLINE, show_database_desc[type],
4080 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
4081 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
4082 adv_router);
4083 }
4084 break;
4085 }
4086}
4087
paul4dadc292005-05-06 21:37:42 +00004088static void
paul020709f2003-04-04 02:44:16 +00004089show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
paul718e3742002-12-13 20:15:29 +00004090{
paul020709f2003-04-04 02:44:16 +00004091 struct ospf_lsa *lsa;
4092 struct route_node *rn;
paul1eb8ef22005-04-07 07:30:20 +00004093 struct ospf_area *area;
hasso52dc7ee2004-09-23 19:18:23 +00004094 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00004095 int type;
4096
paul1eb8ef22005-04-07 07:30:20 +00004097 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00004098 {
paul718e3742002-12-13 20:15:29 +00004099 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4100 {
4101 switch (type)
4102 {
4103 case OSPF_AS_EXTERNAL_LSA:
4104#ifdef HAVE_OPAQUE_LSA
4105 case OSPF_OPAQUE_AS_LSA:
4106#endif /* HAVE_OPAQUE_LSA */
4107 continue;
4108 default:
4109 break;
4110 }
4111 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
4112 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
4113 {
4114 vty_out (vty, " %s (Area %s)%s%s",
4115 show_database_desc[type],
4116 ospf_area_desc_string (area),
4117 VTY_NEWLINE, VTY_NEWLINE);
4118 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
4119
paul020709f2003-04-04 02:44:16 +00004120 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
4121 show_lsa_summary (vty, lsa, self);
paul718e3742002-12-13 20:15:29 +00004122
4123 vty_out (vty, "%s", VTY_NEWLINE);
4124 }
4125 }
4126 }
4127
4128 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
4129 {
4130 switch (type)
4131 {
4132 case OSPF_AS_EXTERNAL_LSA:
4133#ifdef HAVE_OPAQUE_LSA
4134 case OSPF_OPAQUE_AS_LSA:
4135#endif /* HAVE_OPAQUE_LSA */
paule8e19462006-01-19 20:16:55 +00004136 break;
paul718e3742002-12-13 20:15:29 +00004137 default:
4138 continue;
4139 }
paul68980082003-03-25 05:07:42 +00004140 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
4141 (!self && ospf_lsdb_count (ospf->lsdb, type)))
paul718e3742002-12-13 20:15:29 +00004142 {
4143 vty_out (vty, " %s%s%s",
4144 show_database_desc[type],
4145 VTY_NEWLINE, VTY_NEWLINE);
4146 vty_out (vty, "%s%s", show_database_header[type],
4147 VTY_NEWLINE);
paul020709f2003-04-04 02:44:16 +00004148
4149 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
4150 show_lsa_summary (vty, lsa, self);
4151
paul718e3742002-12-13 20:15:29 +00004152 vty_out (vty, "%s", VTY_NEWLINE);
4153 }
4154 }
4155
4156 vty_out (vty, "%s", VTY_NEWLINE);
4157}
4158
paul4dadc292005-05-06 21:37:42 +00004159static void
paul020709f2003-04-04 02:44:16 +00004160show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00004161{
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004162 struct route_node *rn;
paul718e3742002-12-13 20:15:29 +00004163
4164 vty_out (vty, "%s MaxAge Link States:%s%s",
4165 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
4166
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004167 for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
paul1eb8ef22005-04-07 07:30:20 +00004168 {
Dinesh Dutt91e6a0e2012-12-04 10:46:37 -08004169 struct ospf_lsa *lsa;
4170
4171 if ((lsa = rn->info) != NULL)
4172 {
4173 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
4174 vty_out (vty, "Link State ID: %s%s",
4175 inet_ntoa (lsa->data->id), VTY_NEWLINE);
4176 vty_out (vty, "Advertising Router: %s%s",
4177 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
4178 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
4179 vty_out (vty, "%s", VTY_NEWLINE);
4180 }
paul1eb8ef22005-04-07 07:30:20 +00004181 }
paul718e3742002-12-13 20:15:29 +00004182}
4183
paul718e3742002-12-13 20:15:29 +00004184#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
4185#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
paul718e3742002-12-13 20:15:29 +00004186
4187#ifdef HAVE_OPAQUE_LSA
4188#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
4189#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
4190#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
4191#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
4192#else /* HAVE_OPAQUE_LSA */
4193#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
4194#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
4195#define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
4196#define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
4197#endif /* HAVE_OPAQUE_LSA */
4198
4199#define OSPF_LSA_TYPES_CMD_STR \
4200 "asbr-summary|external|network|router|summary" \
4201 OSPF_LSA_TYPE_NSSA_CMD_STR \
4202 OSPF_LSA_TYPE_OPAQUE_CMD_STR
4203
4204#define OSPF_LSA_TYPES_DESC \
4205 "ASBR summary link states\n" \
4206 "External link states\n" \
4207 "Network link states\n" \
4208 "Router link states\n" \
4209 "Network summary link states\n" \
4210 OSPF_LSA_TYPE_NSSA_DESC \
4211 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
4212 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
4213 OSPF_LSA_TYPE_OPAQUE_AS_DESC
4214
4215DEFUN (show_ip_ospf_database,
4216 show_ip_ospf_database_cmd,
4217 "show ip ospf database",
4218 SHOW_STR
4219 IP_STR
4220 "OSPF information\n"
4221 "Database summary\n")
4222{
paul020709f2003-04-04 02:44:16 +00004223 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004224 int type, ret;
4225 struct in_addr id, adv_router;
4226
paul020709f2003-04-04 02:44:16 +00004227 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004228 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004229 {
4230 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4231 return CMD_SUCCESS;
4232 }
paul718e3742002-12-13 20:15:29 +00004233
4234 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004235 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004236
4237 /* Show all LSA. */
4238 if (argc == 0)
4239 {
paul020709f2003-04-04 02:44:16 +00004240 show_ip_ospf_database_summary (vty, ospf, 0);
paul718e3742002-12-13 20:15:29 +00004241 return CMD_SUCCESS;
4242 }
4243
4244 /* Set database type to show. */
4245 if (strncmp (argv[0], "r", 1) == 0)
4246 type = OSPF_ROUTER_LSA;
4247 else if (strncmp (argv[0], "ne", 2) == 0)
4248 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004249 else if (strncmp (argv[0], "ns", 2) == 0)
4250 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004251 else if (strncmp (argv[0], "su", 2) == 0)
4252 type = OSPF_SUMMARY_LSA;
4253 else if (strncmp (argv[0], "a", 1) == 0)
4254 type = OSPF_ASBR_SUMMARY_LSA;
4255 else if (strncmp (argv[0], "e", 1) == 0)
4256 type = OSPF_AS_EXTERNAL_LSA;
4257 else if (strncmp (argv[0], "se", 2) == 0)
4258 {
paul020709f2003-04-04 02:44:16 +00004259 show_ip_ospf_database_summary (vty, ospf, 1);
paul718e3742002-12-13 20:15:29 +00004260 return CMD_SUCCESS;
4261 }
4262 else if (strncmp (argv[0], "m", 1) == 0)
4263 {
paul020709f2003-04-04 02:44:16 +00004264 show_ip_ospf_database_maxage (vty, ospf);
paul718e3742002-12-13 20:15:29 +00004265 return CMD_SUCCESS;
4266 }
4267#ifdef HAVE_OPAQUE_LSA
4268 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4269 type = OSPF_OPAQUE_LINK_LSA;
4270 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4271 type = OSPF_OPAQUE_AREA_LSA;
4272 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4273 type = OSPF_OPAQUE_AS_LSA;
4274#endif /* HAVE_OPAQUE_LSA */
4275 else
4276 return CMD_WARNING;
4277
4278 /* `show ip ospf database LSA'. */
4279 if (argc == 1)
paul020709f2003-04-04 02:44:16 +00004280 show_lsa_detail (vty, ospf, type, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00004281 else if (argc >= 2)
4282 {
4283 ret = inet_aton (argv[1], &id);
4284 if (!ret)
4285 return CMD_WARNING;
4286
4287 /* `show ip ospf database LSA ID'. */
4288 if (argc == 2)
paul020709f2003-04-04 02:44:16 +00004289 show_lsa_detail (vty, ospf, type, &id, NULL);
paul718e3742002-12-13 20:15:29 +00004290 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
4291 else if (argc == 3)
4292 {
4293 if (strncmp (argv[2], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004294 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004295 else
4296 {
4297 ret = inet_aton (argv[2], &adv_router);
4298 if (!ret)
4299 return CMD_WARNING;
4300 }
paul020709f2003-04-04 02:44:16 +00004301 show_lsa_detail (vty, ospf, type, &id, &adv_router);
paul718e3742002-12-13 20:15:29 +00004302 }
4303 }
4304
4305 return CMD_SUCCESS;
4306}
4307
4308ALIAS (show_ip_ospf_database,
4309 show_ip_ospf_database_type_cmd,
4310 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
4311 SHOW_STR
4312 IP_STR
4313 "OSPF information\n"
4314 "Database summary\n"
4315 OSPF_LSA_TYPES_DESC
4316 "LSAs in MaxAge list\n"
4317 "Self-originated link states\n")
4318
4319ALIAS (show_ip_ospf_database,
4320 show_ip_ospf_database_type_id_cmd,
4321 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
4322 SHOW_STR
4323 IP_STR
4324 "OSPF information\n"
4325 "Database summary\n"
4326 OSPF_LSA_TYPES_DESC
4327 "Link State ID (as an IP address)\n")
4328
4329ALIAS (show_ip_ospf_database,
4330 show_ip_ospf_database_type_id_adv_router_cmd,
4331 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
4332 SHOW_STR
4333 IP_STR
4334 "OSPF information\n"
4335 "Database summary\n"
4336 OSPF_LSA_TYPES_DESC
4337 "Link State ID (as an IP address)\n"
4338 "Advertising Router link states\n"
4339 "Advertising Router (as an IP address)\n")
4340
4341ALIAS (show_ip_ospf_database,
4342 show_ip_ospf_database_type_id_self_cmd,
4343 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
4344 SHOW_STR
4345 IP_STR
4346 "OSPF information\n"
4347 "Database summary\n"
4348 OSPF_LSA_TYPES_DESC
4349 "Link State ID (as an IP address)\n"
4350 "Self-originated link states\n"
4351 "\n")
4352
4353DEFUN (show_ip_ospf_database_type_adv_router,
4354 show_ip_ospf_database_type_adv_router_cmd,
4355 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
4356 SHOW_STR
4357 IP_STR
4358 "OSPF information\n"
4359 "Database summary\n"
4360 OSPF_LSA_TYPES_DESC
4361 "Advertising Router link states\n"
4362 "Advertising Router (as an IP address)\n")
4363{
paul020709f2003-04-04 02:44:16 +00004364 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +00004365 int type, ret;
4366 struct in_addr adv_router;
4367
paul020709f2003-04-04 02:44:16 +00004368 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00004369 if (ospf == NULL)
Paul Jakmacac3b5c2006-05-11 13:31:11 +00004370 {
4371 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
4372 return CMD_SUCCESS;
4373 }
paul718e3742002-12-13 20:15:29 +00004374
4375 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
paul68980082003-03-25 05:07:42 +00004376 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004377
4378 if (argc != 2)
4379 return CMD_WARNING;
4380
4381 /* Set database type to show. */
4382 if (strncmp (argv[0], "r", 1) == 0)
4383 type = OSPF_ROUTER_LSA;
4384 else if (strncmp (argv[0], "ne", 2) == 0)
4385 type = OSPF_NETWORK_LSA;
paul718e3742002-12-13 20:15:29 +00004386 else if (strncmp (argv[0], "ns", 2) == 0)
4387 type = OSPF_AS_NSSA_LSA;
paul718e3742002-12-13 20:15:29 +00004388 else if (strncmp (argv[0], "s", 1) == 0)
4389 type = OSPF_SUMMARY_LSA;
4390 else if (strncmp (argv[0], "a", 1) == 0)
4391 type = OSPF_ASBR_SUMMARY_LSA;
4392 else if (strncmp (argv[0], "e", 1) == 0)
4393 type = OSPF_AS_EXTERNAL_LSA;
4394#ifdef HAVE_OPAQUE_LSA
4395 else if (strncmp (argv[0], "opaque-l", 8) == 0)
4396 type = OSPF_OPAQUE_LINK_LSA;
4397 else if (strncmp (argv[0], "opaque-ar", 9) == 0)
4398 type = OSPF_OPAQUE_AREA_LSA;
4399 else if (strncmp (argv[0], "opaque-as", 9) == 0)
4400 type = OSPF_OPAQUE_AS_LSA;
4401#endif /* HAVE_OPAQUE_LSA */
4402 else
4403 return CMD_WARNING;
4404
4405 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
4406 if (strncmp (argv[1], "s", 1) == 0)
paul68980082003-03-25 05:07:42 +00004407 adv_router = ospf->router_id;
paul718e3742002-12-13 20:15:29 +00004408 else
4409 {
4410 ret = inet_aton (argv[1], &adv_router);
4411 if (!ret)
4412 return CMD_WARNING;
4413 }
4414
paul020709f2003-04-04 02:44:16 +00004415 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
paul718e3742002-12-13 20:15:29 +00004416
4417 return CMD_SUCCESS;
4418}
4419
4420ALIAS (show_ip_ospf_database_type_adv_router,
4421 show_ip_ospf_database_type_self_cmd,
4422 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
4423 SHOW_STR
4424 IP_STR
4425 "OSPF information\n"
4426 "Database summary\n"
4427 OSPF_LSA_TYPES_DESC
4428 "Self-originated link states\n")
4429
David Lamparter6b0655a2014-06-04 06:53:35 +02004430
paul718e3742002-12-13 20:15:29 +00004431DEFUN (ip_ospf_authentication_args,
4432 ip_ospf_authentication_args_addr_cmd,
4433 "ip ospf authentication (null|message-digest) A.B.C.D",
4434 "IP Information\n"
4435 "OSPF interface commands\n"
4436 "Enable authentication on this interface\n"
4437 "Use null authentication\n"
4438 "Use message-digest authentication\n"
4439 "Address of interface")
4440{
4441 struct interface *ifp;
4442 struct in_addr addr;
4443 int ret;
4444 struct ospf_if_params *params;
4445
4446 ifp = vty->index;
4447 params = IF_DEF_PARAMS (ifp);
4448
4449 if (argc == 2)
4450 {
4451 ret = inet_aton(argv[1], &addr);
4452 if (!ret)
4453 {
4454 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4455 VTY_NEWLINE);
4456 return CMD_WARNING;
4457 }
4458
4459 params = ospf_get_if_params (ifp, addr);
4460 ospf_if_update_params (ifp, addr);
4461 }
4462
4463 /* Handle null authentication */
4464 if ( argv[0][0] == 'n' )
4465 {
4466 SET_IF_PARAM (params, auth_type);
4467 params->auth_type = OSPF_AUTH_NULL;
4468 return CMD_SUCCESS;
4469 }
4470
4471 /* Handle message-digest authentication */
4472 if ( argv[0][0] == 'm' )
4473 {
4474 SET_IF_PARAM (params, auth_type);
4475 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
4476 return CMD_SUCCESS;
4477 }
4478
4479 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
4480 return CMD_WARNING;
4481}
4482
4483ALIAS (ip_ospf_authentication_args,
4484 ip_ospf_authentication_args_cmd,
4485 "ip ospf authentication (null|message-digest)",
4486 "IP Information\n"
4487 "OSPF interface commands\n"
4488 "Enable authentication on this interface\n"
4489 "Use null authentication\n"
4490 "Use message-digest authentication\n")
4491
4492DEFUN (ip_ospf_authentication,
4493 ip_ospf_authentication_addr_cmd,
4494 "ip ospf authentication A.B.C.D",
4495 "IP Information\n"
4496 "OSPF interface commands\n"
4497 "Enable authentication on this interface\n"
4498 "Address of interface")
4499{
4500 struct interface *ifp;
4501 struct in_addr addr;
4502 int ret;
4503 struct ospf_if_params *params;
4504
4505 ifp = vty->index;
4506 params = IF_DEF_PARAMS (ifp);
4507
4508 if (argc == 1)
4509 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004510 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004511 if (!ret)
4512 {
4513 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4514 VTY_NEWLINE);
4515 return CMD_WARNING;
4516 }
4517
4518 params = ospf_get_if_params (ifp, addr);
4519 ospf_if_update_params (ifp, addr);
4520 }
4521
4522 SET_IF_PARAM (params, auth_type);
4523 params->auth_type = OSPF_AUTH_SIMPLE;
4524
4525 return CMD_SUCCESS;
4526}
4527
4528ALIAS (ip_ospf_authentication,
4529 ip_ospf_authentication_cmd,
4530 "ip ospf authentication",
4531 "IP Information\n"
4532 "OSPF interface commands\n"
4533 "Enable authentication on this interface\n")
4534
4535DEFUN (no_ip_ospf_authentication,
4536 no_ip_ospf_authentication_addr_cmd,
4537 "no ip ospf authentication A.B.C.D",
4538 NO_STR
4539 "IP Information\n"
4540 "OSPF interface commands\n"
4541 "Enable authentication on this interface\n"
4542 "Address of interface")
4543{
4544 struct interface *ifp;
4545 struct in_addr addr;
4546 int ret;
4547 struct ospf_if_params *params;
4548
4549 ifp = vty->index;
4550 params = IF_DEF_PARAMS (ifp);
4551
4552 if (argc == 1)
4553 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004554 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004555 if (!ret)
4556 {
4557 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4558 VTY_NEWLINE);
4559 return CMD_WARNING;
4560 }
4561
4562 params = ospf_lookup_if_params (ifp, addr);
4563 if (params == NULL)
4564 return CMD_SUCCESS;
4565 }
4566
4567 params->auth_type = OSPF_AUTH_NOTSET;
4568 UNSET_IF_PARAM (params, auth_type);
4569
4570 if (params != IF_DEF_PARAMS (ifp))
4571 {
4572 ospf_free_if_params (ifp, addr);
4573 ospf_if_update_params (ifp, addr);
4574 }
4575
4576 return CMD_SUCCESS;
4577}
4578
4579ALIAS (no_ip_ospf_authentication,
4580 no_ip_ospf_authentication_cmd,
4581 "no ip ospf authentication",
4582 NO_STR
4583 "IP Information\n"
4584 "OSPF interface commands\n"
4585 "Enable authentication on this interface\n")
4586
4587DEFUN (ip_ospf_authentication_key,
4588 ip_ospf_authentication_key_addr_cmd,
4589 "ip ospf authentication-key AUTH_KEY A.B.C.D",
4590 "IP Information\n"
4591 "OSPF interface commands\n"
4592 "Authentication password (key)\n"
4593 "The OSPF password (key)\n"
4594 "Address of interface")
4595{
4596 struct interface *ifp;
4597 struct in_addr addr;
4598 int ret;
4599 struct ospf_if_params *params;
4600
4601 ifp = vty->index;
4602 params = IF_DEF_PARAMS (ifp);
4603
4604 if (argc == 2)
4605 {
4606 ret = inet_aton(argv[1], &addr);
4607 if (!ret)
4608 {
4609 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4610 VTY_NEWLINE);
4611 return CMD_WARNING;
4612 }
4613
4614 params = ospf_get_if_params (ifp, addr);
4615 ospf_if_update_params (ifp, addr);
4616 }
4617
4618
4619 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
hassoc9e52be2004-09-26 16:09:34 +00004620 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
paul718e3742002-12-13 20:15:29 +00004621 SET_IF_PARAM (params, auth_simple);
4622
4623 return CMD_SUCCESS;
4624}
4625
4626ALIAS (ip_ospf_authentication_key,
4627 ip_ospf_authentication_key_cmd,
4628 "ip ospf authentication-key AUTH_KEY",
4629 "IP Information\n"
4630 "OSPF interface commands\n"
4631 "Authentication password (key)\n"
4632 "The OSPF password (key)")
4633
4634ALIAS (ip_ospf_authentication_key,
4635 ospf_authentication_key_cmd,
4636 "ospf authentication-key AUTH_KEY",
4637 "OSPF interface commands\n"
4638 "Authentication password (key)\n"
4639 "The OSPF password (key)")
4640
4641DEFUN (no_ip_ospf_authentication_key,
4642 no_ip_ospf_authentication_key_addr_cmd,
4643 "no ip ospf authentication-key A.B.C.D",
4644 NO_STR
4645 "IP Information\n"
4646 "OSPF interface commands\n"
4647 "Authentication password (key)\n"
4648 "Address of interface")
4649{
4650 struct interface *ifp;
4651 struct in_addr addr;
4652 int ret;
4653 struct ospf_if_params *params;
4654
4655 ifp = vty->index;
4656 params = IF_DEF_PARAMS (ifp);
4657
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004658 if (argc == 1)
paul718e3742002-12-13 20:15:29 +00004659 {
Paul Jakma5dcf71d2007-05-10 03:00:09 +00004660 ret = inet_aton(argv[0], &addr);
paul718e3742002-12-13 20:15:29 +00004661 if (!ret)
4662 {
4663 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4664 VTY_NEWLINE);
4665 return CMD_WARNING;
4666 }
4667
4668 params = ospf_lookup_if_params (ifp, addr);
4669 if (params == NULL)
4670 return CMD_SUCCESS;
4671 }
4672
4673 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
4674 UNSET_IF_PARAM (params, auth_simple);
4675
4676 if (params != IF_DEF_PARAMS (ifp))
4677 {
4678 ospf_free_if_params (ifp, addr);
4679 ospf_if_update_params (ifp, addr);
4680 }
4681
4682 return CMD_SUCCESS;
4683}
4684
4685ALIAS (no_ip_ospf_authentication_key,
4686 no_ip_ospf_authentication_key_cmd,
4687 "no ip ospf authentication-key",
4688 NO_STR
4689 "IP Information\n"
4690 "OSPF interface commands\n"
4691 "Authentication password (key)\n")
4692
4693ALIAS (no_ip_ospf_authentication_key,
4694 no_ospf_authentication_key_cmd,
4695 "no ospf authentication-key",
4696 NO_STR
4697 "OSPF interface commands\n"
4698 "Authentication password (key)\n")
4699
4700DEFUN (ip_ospf_message_digest_key,
4701 ip_ospf_message_digest_key_addr_cmd,
4702 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
4703 "IP Information\n"
4704 "OSPF interface commands\n"
4705 "Message digest authentication password (key)\n"
4706 "Key ID\n"
4707 "Use MD5 algorithm\n"
4708 "The OSPF password (key)"
4709 "Address of interface")
4710{
4711 struct interface *ifp;
4712 struct crypt_key *ck;
4713 u_char key_id;
4714 struct in_addr addr;
4715 int ret;
4716 struct ospf_if_params *params;
4717
4718 ifp = vty->index;
4719 params = IF_DEF_PARAMS (ifp);
4720
4721 if (argc == 3)
4722 {
4723 ret = inet_aton(argv[2], &addr);
4724 if (!ret)
4725 {
4726 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4727 VTY_NEWLINE);
4728 return CMD_WARNING;
4729 }
4730
4731 params = ospf_get_if_params (ifp, addr);
4732 ospf_if_update_params (ifp, addr);
4733 }
4734
4735 key_id = strtol (argv[0], NULL, 10);
4736 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
4737 {
4738 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
4739 return CMD_WARNING;
4740 }
4741
4742 ck = ospf_crypt_key_new ();
4743 ck->key_id = (u_char) key_id;
4744 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
hassoc9e52be2004-09-26 16:09:34 +00004745 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
paul718e3742002-12-13 20:15:29 +00004746
4747 ospf_crypt_key_add (params->auth_crypt, ck);
4748 SET_IF_PARAM (params, auth_crypt);
4749
4750 return CMD_SUCCESS;
4751}
4752
4753ALIAS (ip_ospf_message_digest_key,
4754 ip_ospf_message_digest_key_cmd,
4755 "ip ospf message-digest-key <1-255> md5 KEY",
4756 "IP Information\n"
4757 "OSPF interface commands\n"
4758 "Message digest authentication password (key)\n"
4759 "Key ID\n"
4760 "Use MD5 algorithm\n"
4761 "The OSPF password (key)")
4762
4763ALIAS (ip_ospf_message_digest_key,
4764 ospf_message_digest_key_cmd,
4765 "ospf message-digest-key <1-255> md5 KEY",
4766 "OSPF interface commands\n"
4767 "Message digest authentication password (key)\n"
4768 "Key ID\n"
4769 "Use MD5 algorithm\n"
4770 "The OSPF password (key)")
4771
4772DEFUN (no_ip_ospf_message_digest_key,
4773 no_ip_ospf_message_digest_key_addr_cmd,
4774 "no ip ospf message-digest-key <1-255> A.B.C.D",
4775 NO_STR
4776 "IP Information\n"
4777 "OSPF interface commands\n"
4778 "Message digest authentication password (key)\n"
4779 "Key ID\n"
4780 "Address of interface")
4781{
4782 struct interface *ifp;
4783 struct crypt_key *ck;
4784 int key_id;
4785 struct in_addr addr;
4786 int ret;
4787 struct ospf_if_params *params;
4788
4789 ifp = vty->index;
4790 params = IF_DEF_PARAMS (ifp);
4791
4792 if (argc == 2)
4793 {
4794 ret = inet_aton(argv[1], &addr);
4795 if (!ret)
4796 {
4797 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4798 VTY_NEWLINE);
4799 return CMD_WARNING;
4800 }
4801
4802 params = ospf_lookup_if_params (ifp, addr);
4803 if (params == NULL)
4804 return CMD_SUCCESS;
4805 }
4806
4807 key_id = strtol (argv[0], NULL, 10);
4808 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
4809 if (ck == NULL)
4810 {
4811 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
4812 return CMD_WARNING;
4813 }
4814
4815 ospf_crypt_key_delete (params->auth_crypt, key_id);
4816
4817 if (params != IF_DEF_PARAMS (ifp))
4818 {
4819 ospf_free_if_params (ifp, addr);
4820 ospf_if_update_params (ifp, addr);
4821 }
4822
4823 return CMD_SUCCESS;
4824}
4825
4826ALIAS (no_ip_ospf_message_digest_key,
4827 no_ip_ospf_message_digest_key_cmd,
4828 "no ip ospf message-digest-key <1-255>",
4829 NO_STR
4830 "IP Information\n"
4831 "OSPF interface commands\n"
4832 "Message digest authentication password (key)\n"
4833 "Key ID\n")
4834
4835ALIAS (no_ip_ospf_message_digest_key,
4836 no_ospf_message_digest_key_cmd,
4837 "no ospf message-digest-key <1-255>",
4838 NO_STR
4839 "OSPF interface commands\n"
4840 "Message digest authentication password (key)\n"
4841 "Key ID\n")
4842
4843DEFUN (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004844 ip_ospf_cost_u32_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004845 "ip ospf cost <1-65535> A.B.C.D",
4846 "IP Information\n"
4847 "OSPF interface commands\n"
4848 "Interface cost\n"
4849 "Cost\n"
4850 "Address of interface")
4851{
4852 struct interface *ifp = vty->index;
4853 u_int32_t cost;
4854 struct in_addr addr;
4855 int ret;
4856 struct ospf_if_params *params;
4857
4858 params = IF_DEF_PARAMS (ifp);
4859
4860 cost = strtol (argv[0], NULL, 10);
4861
4862 /* cost range is <1-65535>. */
4863 if (cost < 1 || cost > 65535)
4864 {
4865 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
4866 return CMD_WARNING;
4867 }
4868
4869 if (argc == 2)
4870 {
4871 ret = inet_aton(argv[1], &addr);
4872 if (!ret)
4873 {
4874 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4875 VTY_NEWLINE);
4876 return CMD_WARNING;
4877 }
4878
4879 params = ospf_get_if_params (ifp, addr);
4880 ospf_if_update_params (ifp, addr);
4881 }
4882
4883 SET_IF_PARAM (params, output_cost_cmd);
4884 params->output_cost_cmd = cost;
4885
4886 ospf_if_recalculate_output_cost (ifp);
4887
4888 return CMD_SUCCESS;
4889}
4890
4891ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004892 ip_ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004893 "ip ospf cost <1-65535>",
4894 "IP Information\n"
4895 "OSPF interface commands\n"
4896 "Interface cost\n"
4897 "Cost")
4898
4899ALIAS (ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004900 ospf_cost_u32_cmd,
paul718e3742002-12-13 20:15:29 +00004901 "ospf cost <1-65535>",
4902 "OSPF interface commands\n"
4903 "Interface cost\n"
4904 "Cost")
4905
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004906ALIAS (ip_ospf_cost,
4907 ospf_cost_u32_inet4_cmd,
4908 "ospf cost <1-65535> A.B.C.D",
4909 "OSPF interface commands\n"
4910 "Interface cost\n"
4911 "Cost\n"
4912 "Address of interface")
4913
paul718e3742002-12-13 20:15:29 +00004914DEFUN (no_ip_ospf_cost,
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004915 no_ip_ospf_cost_inet4_cmd,
paul718e3742002-12-13 20:15:29 +00004916 "no ip ospf cost A.B.C.D",
4917 NO_STR
4918 "IP Information\n"
4919 "OSPF interface commands\n"
4920 "Interface cost\n"
4921 "Address of interface")
4922{
4923 struct interface *ifp = vty->index;
4924 struct in_addr addr;
4925 int ret;
4926 struct ospf_if_params *params;
4927
4928 ifp = vty->index;
4929 params = IF_DEF_PARAMS (ifp);
4930
4931 if (argc == 1)
4932 {
4933 ret = inet_aton(argv[0], &addr);
4934 if (!ret)
4935 {
4936 vty_out (vty, "Please specify interface address by A.B.C.D%s",
4937 VTY_NEWLINE);
4938 return CMD_WARNING;
4939 }
4940
4941 params = ospf_lookup_if_params (ifp, addr);
4942 if (params == NULL)
4943 return CMD_SUCCESS;
4944 }
4945
4946 UNSET_IF_PARAM (params, output_cost_cmd);
4947
4948 if (params != IF_DEF_PARAMS (ifp))
4949 {
4950 ospf_free_if_params (ifp, addr);
4951 ospf_if_update_params (ifp, addr);
4952 }
4953
4954 ospf_if_recalculate_output_cost (ifp);
4955
4956 return CMD_SUCCESS;
4957}
4958
4959ALIAS (no_ip_ospf_cost,
4960 no_ip_ospf_cost_cmd,
4961 "no ip ospf cost",
4962 NO_STR
4963 "IP Information\n"
4964 "OSPF interface commands\n"
4965 "Interface cost\n")
4966
4967ALIAS (no_ip_ospf_cost,
4968 no_ospf_cost_cmd,
4969 "no ospf cost",
4970 NO_STR
4971 "OSPF interface commands\n"
4972 "Interface cost\n")
4973
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04004974ALIAS (no_ip_ospf_cost,
4975 no_ospf_cost_inet4_cmd,
4976 "no ospf cost A.B.C.D",
4977 NO_STR
4978 "OSPF interface commands\n"
4979 "Interface cost\n"
4980 "Address of interface")
4981
Denis Ovsienko827341b2009-09-28 19:34:59 +04004982DEFUN (no_ip_ospf_cost2,
4983 no_ip_ospf_cost_u32_cmd,
4984 "no ip ospf cost <1-65535>",
4985 NO_STR
4986 "IP Information\n"
4987 "OSPF interface commands\n"
4988 "Interface cost\n"
4989 "Cost")
4990{
4991 struct interface *ifp = vty->index;
4992 struct in_addr addr;
4993 u_int32_t cost;
4994 int ret;
4995 struct ospf_if_params *params;
4996
4997 ifp = vty->index;
4998 params = IF_DEF_PARAMS (ifp);
4999
5000 /* According to the semantics we are mimicking "no ip ospf cost N" is
5001 * always treated as "no ip ospf cost" regardless of the actual value
5002 * of N already configured for the interface. Thus the first argument
5003 * is always checked to be a number, but is ignored after that.
5004 */
5005 cost = strtol (argv[0], NULL, 10);
5006 if (cost < 1 || cost > 65535)
5007 {
5008 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
5009 return CMD_WARNING;
5010 }
5011
5012 if (argc == 2)
5013 {
5014 ret = inet_aton(argv[1], &addr);
5015 if (!ret)
5016 {
5017 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5018 VTY_NEWLINE);
5019 return CMD_WARNING;
5020 }
5021
5022 params = ospf_lookup_if_params (ifp, addr);
5023 if (params == NULL)
5024 return CMD_SUCCESS;
5025 }
5026
5027 UNSET_IF_PARAM (params, output_cost_cmd);
5028
5029 if (params != IF_DEF_PARAMS (ifp))
5030 {
5031 ospf_free_if_params (ifp, addr);
5032 ospf_if_update_params (ifp, addr);
5033 }
5034
5035 ospf_if_recalculate_output_cost (ifp);
5036
5037 return CMD_SUCCESS;
5038}
5039
5040ALIAS (no_ip_ospf_cost2,
5041 no_ospf_cost_u32_cmd,
5042 "no ospf cost <1-65535>",
5043 NO_STR
5044 "OSPF interface commands\n"
5045 "Interface cost\n"
5046 "Cost")
5047
5048ALIAS (no_ip_ospf_cost2,
5049 no_ip_ospf_cost_u32_inet4_cmd,
5050 "no ip ospf cost <1-65535> A.B.C.D",
5051 NO_STR
5052 "IP Information\n"
5053 "OSPF interface commands\n"
5054 "Interface cost\n"
5055 "Cost\n"
5056 "Address of interface")
5057
5058ALIAS (no_ip_ospf_cost2,
5059 no_ospf_cost_u32_inet4_cmd,
5060 "no ospf cost <1-65535> A.B.C.D",
5061 NO_STR
5062 "OSPF interface commands\n"
5063 "Interface cost\n"
5064 "Cost\n"
5065 "Address of interface")
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04005066
paul4dadc292005-05-06 21:37:42 +00005067static void
paul718e3742002-12-13 20:15:29 +00005068ospf_nbr_timer_update (struct ospf_interface *oi)
5069{
5070 struct route_node *rn;
5071 struct ospf_neighbor *nbr;
5072
5073 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
5074 if ((nbr = rn->info))
5075 {
5076 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
5077 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
5078 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
5079 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
5080 }
5081}
5082
paulf9ad9372005-10-21 00:45:17 +00005083static int
5084ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
5085 const char *nbr_str,
5086 const char *fast_hello_str)
paul718e3742002-12-13 20:15:29 +00005087{
5088 struct interface *ifp = vty->index;
5089 u_int32_t seconds;
paulf9ad9372005-10-21 00:45:17 +00005090 u_char hellomult;
paul718e3742002-12-13 20:15:29 +00005091 struct in_addr addr;
5092 int ret;
5093 struct ospf_if_params *params;
5094 struct ospf_interface *oi;
5095 struct route_node *rn;
5096
5097 params = IF_DEF_PARAMS (ifp);
paulf9ad9372005-10-21 00:45:17 +00005098
5099 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005100 {
paulf9ad9372005-10-21 00:45:17 +00005101 ret = inet_aton(nbr_str, &addr);
paul718e3742002-12-13 20:15:29 +00005102 if (!ret)
5103 {
5104 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5105 VTY_NEWLINE);
5106 return CMD_WARNING;
5107 }
5108
5109 params = ospf_get_if_params (ifp, addr);
5110 ospf_if_update_params (ifp, addr);
5111 }
5112
paulf9ad9372005-10-21 00:45:17 +00005113 if (interval_str)
5114 {
5115 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
5116 1, 65535);
5117
5118 /* reset fast_hello too, just to be sure */
5119 UNSET_IF_PARAM (params, fast_hello);
5120 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5121 }
5122 else if (fast_hello_str)
5123 {
5124 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
5125 1, 10);
5126 /* 1s dead-interval with sub-second hellos desired */
5127 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
5128 SET_IF_PARAM (params, fast_hello);
5129 params->fast_hello = hellomult;
5130 }
5131 else
5132 {
5133 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
5134 VTY_NEWLINE);
5135 return CMD_WARNING;
5136 }
5137
paul718e3742002-12-13 20:15:29 +00005138 SET_IF_PARAM (params, v_wait);
5139 params->v_wait = seconds;
5140
5141 /* Update timer values in neighbor structure. */
paulf9ad9372005-10-21 00:45:17 +00005142 if (nbr_str)
paul718e3742002-12-13 20:15:29 +00005143 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005144 struct ospf *ospf;
5145 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005146 {
5147 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5148 if (oi)
5149 ospf_nbr_timer_update (oi);
5150 }
paul718e3742002-12-13 20:15:29 +00005151 }
5152 else
5153 {
5154 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5155 if ((oi = rn->info))
5156 ospf_nbr_timer_update (oi);
5157 }
5158
5159 return CMD_SUCCESS;
5160}
5161
paulf9ad9372005-10-21 00:45:17 +00005162
5163DEFUN (ip_ospf_dead_interval,
5164 ip_ospf_dead_interval_addr_cmd,
5165 "ip ospf dead-interval <1-65535> A.B.C.D",
5166 "IP Information\n"
5167 "OSPF interface commands\n"
5168 "Interval after which a neighbor is declared dead\n"
5169 "Seconds\n"
5170 "Address of interface\n")
5171{
5172 if (argc == 2)
5173 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
5174 else
5175 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
5176}
5177
paul718e3742002-12-13 20:15:29 +00005178ALIAS (ip_ospf_dead_interval,
5179 ip_ospf_dead_interval_cmd,
5180 "ip ospf dead-interval <1-65535>",
5181 "IP Information\n"
5182 "OSPF interface commands\n"
5183 "Interval after which a neighbor is declared dead\n"
5184 "Seconds\n")
5185
5186ALIAS (ip_ospf_dead_interval,
5187 ospf_dead_interval_cmd,
5188 "ospf dead-interval <1-65535>",
5189 "OSPF interface commands\n"
5190 "Interval after which a neighbor is declared dead\n"
5191 "Seconds\n")
5192
paulf9ad9372005-10-21 00:45:17 +00005193DEFUN (ip_ospf_dead_interval_minimal,
5194 ip_ospf_dead_interval_minimal_addr_cmd,
5195 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
5196 "IP Information\n"
5197 "OSPF interface commands\n"
5198 "Interval after which a neighbor is declared dead\n"
5199 "Minimal 1s dead-interval with fast sub-second hellos\n"
5200 "Hello multiplier factor\n"
5201 "Number of Hellos to send each second\n"
5202 "Address of interface\n")
5203{
5204 if (argc == 2)
5205 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
5206 else
5207 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
5208}
5209
5210ALIAS (ip_ospf_dead_interval_minimal,
5211 ip_ospf_dead_interval_minimal_cmd,
5212 "ip ospf dead-interval minimal hello-multiplier <1-10>",
5213 "IP Information\n"
5214 "OSPF interface commands\n"
5215 "Interval after which a neighbor is declared dead\n"
5216 "Minimal 1s dead-interval with fast sub-second hellos\n"
5217 "Hello multiplier factor\n"
5218 "Number of Hellos to send each second\n")
5219
paul718e3742002-12-13 20:15:29 +00005220DEFUN (no_ip_ospf_dead_interval,
5221 no_ip_ospf_dead_interval_addr_cmd,
5222 "no ip ospf dead-interval A.B.C.D",
5223 NO_STR
5224 "IP Information\n"
5225 "OSPF interface commands\n"
5226 "Interval after which a neighbor is declared dead\n"
5227 "Address of interface")
5228{
5229 struct interface *ifp = vty->index;
5230 struct in_addr addr;
5231 int ret;
5232 struct ospf_if_params *params;
5233 struct ospf_interface *oi;
5234 struct route_node *rn;
paul020709f2003-04-04 02:44:16 +00005235
paul718e3742002-12-13 20:15:29 +00005236 ifp = vty->index;
5237 params = IF_DEF_PARAMS (ifp);
5238
5239 if (argc == 1)
5240 {
5241 ret = inet_aton(argv[0], &addr);
5242 if (!ret)
5243 {
5244 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5245 VTY_NEWLINE);
5246 return CMD_WARNING;
5247 }
5248
5249 params = ospf_lookup_if_params (ifp, addr);
5250 if (params == NULL)
5251 return CMD_SUCCESS;
5252 }
5253
5254 UNSET_IF_PARAM (params, v_wait);
5255 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
paulf9ad9372005-10-21 00:45:17 +00005256
5257 UNSET_IF_PARAM (params, fast_hello);
5258 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
5259
paul718e3742002-12-13 20:15:29 +00005260 if (params != IF_DEF_PARAMS (ifp))
5261 {
5262 ospf_free_if_params (ifp, addr);
5263 ospf_if_update_params (ifp, addr);
5264 }
5265
5266 /* Update timer values in neighbor structure. */
5267 if (argc == 1)
5268 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00005269 struct ospf *ospf;
5270
5271 if ((ospf = ospf_lookup()))
paul68980082003-03-25 05:07:42 +00005272 {
5273 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
5274 if (oi)
5275 ospf_nbr_timer_update (oi);
5276 }
paul718e3742002-12-13 20:15:29 +00005277 }
5278 else
5279 {
5280 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5281 if ((oi = rn->info))
5282 ospf_nbr_timer_update (oi);
5283 }
5284
5285 return CMD_SUCCESS;
5286}
5287
5288ALIAS (no_ip_ospf_dead_interval,
5289 no_ip_ospf_dead_interval_cmd,
5290 "no ip ospf dead-interval",
5291 NO_STR
5292 "IP Information\n"
5293 "OSPF interface commands\n"
5294 "Interval after which a neighbor is declared dead\n")
5295
5296ALIAS (no_ip_ospf_dead_interval,
5297 no_ospf_dead_interval_cmd,
5298 "no ospf dead-interval",
5299 NO_STR
5300 "OSPF interface commands\n"
5301 "Interval after which a neighbor is declared dead\n")
5302
5303DEFUN (ip_ospf_hello_interval,
5304 ip_ospf_hello_interval_addr_cmd,
5305 "ip ospf hello-interval <1-65535> A.B.C.D",
5306 "IP Information\n"
5307 "OSPF interface commands\n"
5308 "Time between HELLO packets\n"
5309 "Seconds\n"
5310 "Address of interface")
5311{
5312 struct interface *ifp = vty->index;
5313 u_int32_t seconds;
5314 struct in_addr addr;
5315 int ret;
5316 struct ospf_if_params *params;
5317
5318 params = IF_DEF_PARAMS (ifp);
5319
5320 seconds = strtol (argv[0], NULL, 10);
5321
5322 /* HelloInterval range is <1-65535>. */
5323 if (seconds < 1 || seconds > 65535)
5324 {
5325 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
5326 return CMD_WARNING;
5327 }
5328
5329 if (argc == 2)
5330 {
5331 ret = inet_aton(argv[1], &addr);
5332 if (!ret)
5333 {
5334 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5335 VTY_NEWLINE);
5336 return CMD_WARNING;
5337 }
5338
5339 params = ospf_get_if_params (ifp, addr);
5340 ospf_if_update_params (ifp, addr);
5341 }
5342
paulf9ad9372005-10-21 00:45:17 +00005343 SET_IF_PARAM (params, v_hello);
paul718e3742002-12-13 20:15:29 +00005344 params->v_hello = seconds;
5345
5346 return CMD_SUCCESS;
5347}
5348
5349ALIAS (ip_ospf_hello_interval,
5350 ip_ospf_hello_interval_cmd,
5351 "ip ospf hello-interval <1-65535>",
5352 "IP Information\n"
5353 "OSPF interface commands\n"
5354 "Time between HELLO packets\n"
5355 "Seconds\n")
5356
5357ALIAS (ip_ospf_hello_interval,
5358 ospf_hello_interval_cmd,
5359 "ospf hello-interval <1-65535>",
5360 "OSPF interface commands\n"
5361 "Time between HELLO packets\n"
5362 "Seconds\n")
5363
5364DEFUN (no_ip_ospf_hello_interval,
5365 no_ip_ospf_hello_interval_addr_cmd,
5366 "no ip ospf hello-interval A.B.C.D",
5367 NO_STR
5368 "IP Information\n"
5369 "OSPF interface commands\n"
5370 "Time between HELLO packets\n"
5371 "Address of interface")
5372{
5373 struct interface *ifp = vty->index;
5374 struct in_addr addr;
5375 int ret;
5376 struct ospf_if_params *params;
5377
5378 ifp = vty->index;
5379 params = IF_DEF_PARAMS (ifp);
5380
5381 if (argc == 1)
5382 {
5383 ret = inet_aton(argv[0], &addr);
5384 if (!ret)
5385 {
5386 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5387 VTY_NEWLINE);
5388 return CMD_WARNING;
5389 }
5390
5391 params = ospf_lookup_if_params (ifp, addr);
5392 if (params == NULL)
5393 return CMD_SUCCESS;
5394 }
5395
5396 UNSET_IF_PARAM (params, v_hello);
paulf9ad9372005-10-21 00:45:17 +00005397 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
paul718e3742002-12-13 20:15:29 +00005398
5399 if (params != IF_DEF_PARAMS (ifp))
5400 {
5401 ospf_free_if_params (ifp, addr);
5402 ospf_if_update_params (ifp, addr);
5403 }
5404
5405 return CMD_SUCCESS;
5406}
5407
5408ALIAS (no_ip_ospf_hello_interval,
5409 no_ip_ospf_hello_interval_cmd,
5410 "no ip ospf hello-interval",
5411 NO_STR
5412 "IP Information\n"
5413 "OSPF interface commands\n"
5414 "Time between HELLO packets\n")
5415
5416ALIAS (no_ip_ospf_hello_interval,
5417 no_ospf_hello_interval_cmd,
5418 "no ospf hello-interval",
5419 NO_STR
5420 "OSPF interface commands\n"
5421 "Time between HELLO packets\n")
5422
5423DEFUN (ip_ospf_network,
5424 ip_ospf_network_cmd,
5425 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5426 "IP Information\n"
5427 "OSPF interface commands\n"
5428 "Network type\n"
5429 "Specify OSPF broadcast multi-access network\n"
5430 "Specify OSPF NBMA network\n"
5431 "Specify OSPF point-to-multipoint network\n"
5432 "Specify OSPF point-to-point network\n")
5433{
5434 struct interface *ifp = vty->index;
5435 int old_type = IF_DEF_PARAMS (ifp)->type;
5436 struct route_node *rn;
Christian Franke4b4bda92013-07-11 07:56:29 +00005437
5438 if (old_type == OSPF_IFTYPE_LOOPBACK)
5439 {
5440 vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE);
5441 return CMD_WARNING;
5442 }
5443
paul718e3742002-12-13 20:15:29 +00005444 if (strncmp (argv[0], "b", 1) == 0)
5445 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
5446 else if (strncmp (argv[0], "n", 1) == 0)
5447 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
5448 else if (strncmp (argv[0], "point-to-m", 10) == 0)
5449 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
5450 else if (strncmp (argv[0], "point-to-p", 10) == 0)
5451 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
5452
5453 if (IF_DEF_PARAMS (ifp)->type == old_type)
5454 return CMD_SUCCESS;
5455
5456 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
5457
5458 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5459 {
5460 struct ospf_interface *oi = rn->info;
5461
5462 if (!oi)
5463 continue;
5464
5465 oi->type = IF_DEF_PARAMS (ifp)->type;
5466
5467 if (oi->state > ISM_Down)
5468 {
5469 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5470 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5471 }
5472 }
5473
5474 return CMD_SUCCESS;
5475}
5476
5477ALIAS (ip_ospf_network,
5478 ospf_network_cmd,
5479 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
5480 "OSPF interface commands\n"
5481 "Network type\n"
5482 "Specify OSPF broadcast multi-access network\n"
5483 "Specify OSPF NBMA network\n"
5484 "Specify OSPF point-to-multipoint network\n"
5485 "Specify OSPF point-to-point network\n")
5486
5487DEFUN (no_ip_ospf_network,
5488 no_ip_ospf_network_cmd,
5489 "no ip ospf network",
5490 NO_STR
5491 "IP Information\n"
5492 "OSPF interface commands\n"
5493 "Network type\n")
5494{
5495 struct interface *ifp = vty->index;
5496 int old_type = IF_DEF_PARAMS (ifp)->type;
5497 struct route_node *rn;
5498
ajsbc18d612004-12-15 15:07:19 +00005499 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
paul718e3742002-12-13 20:15:29 +00005500
5501 if (IF_DEF_PARAMS (ifp)->type == old_type)
5502 return CMD_SUCCESS;
5503
5504 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5505 {
5506 struct ospf_interface *oi = rn->info;
5507
5508 if (!oi)
5509 continue;
5510
5511 oi->type = IF_DEF_PARAMS (ifp)->type;
5512
5513 if (oi->state > ISM_Down)
5514 {
5515 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
5516 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
5517 }
5518 }
5519
5520 return CMD_SUCCESS;
5521}
5522
5523ALIAS (no_ip_ospf_network,
5524 no_ospf_network_cmd,
5525 "no ospf network",
5526 NO_STR
5527 "OSPF interface commands\n"
5528 "Network type\n")
5529
5530DEFUN (ip_ospf_priority,
5531 ip_ospf_priority_addr_cmd,
5532 "ip ospf priority <0-255> A.B.C.D",
5533 "IP Information\n"
5534 "OSPF interface commands\n"
5535 "Router priority\n"
5536 "Priority\n"
5537 "Address of interface")
5538{
5539 struct interface *ifp = vty->index;
Andrew Certain0798cee2012-12-04 13:43:42 -08005540 long priority;
paul718e3742002-12-13 20:15:29 +00005541 struct route_node *rn;
5542 struct in_addr addr;
5543 int ret;
5544 struct ospf_if_params *params;
5545
5546 params = IF_DEF_PARAMS (ifp);
5547
5548 priority = strtol (argv[0], NULL, 10);
5549
5550 /* Router Priority range is <0-255>. */
5551 if (priority < 0 || priority > 255)
5552 {
5553 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
5554 return CMD_WARNING;
5555 }
5556
5557 if (argc == 2)
5558 {
5559 ret = inet_aton(argv[1], &addr);
5560 if (!ret)
5561 {
5562 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5563 VTY_NEWLINE);
5564 return CMD_WARNING;
5565 }
5566
5567 params = ospf_get_if_params (ifp, addr);
5568 ospf_if_update_params (ifp, addr);
5569 }
5570
5571 SET_IF_PARAM (params, priority);
5572 params->priority = priority;
5573
5574 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5575 {
5576 struct ospf_interface *oi = rn->info;
5577
5578 if (!oi)
5579 continue;
5580
5581
5582 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5583 {
5584 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5585 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5586 }
5587 }
5588
5589 return CMD_SUCCESS;
5590}
5591
5592ALIAS (ip_ospf_priority,
5593 ip_ospf_priority_cmd,
5594 "ip ospf priority <0-255>",
5595 "IP Information\n"
5596 "OSPF interface commands\n"
5597 "Router priority\n"
5598 "Priority\n")
5599
5600ALIAS (ip_ospf_priority,
5601 ospf_priority_cmd,
5602 "ospf priority <0-255>",
5603 "OSPF interface commands\n"
5604 "Router priority\n"
5605 "Priority\n")
5606
5607DEFUN (no_ip_ospf_priority,
5608 no_ip_ospf_priority_addr_cmd,
5609 "no ip ospf priority A.B.C.D",
5610 NO_STR
5611 "IP Information\n"
5612 "OSPF interface commands\n"
5613 "Router priority\n"
5614 "Address of interface")
5615{
5616 struct interface *ifp = vty->index;
5617 struct route_node *rn;
5618 struct in_addr addr;
5619 int ret;
5620 struct ospf_if_params *params;
5621
5622 ifp = vty->index;
5623 params = IF_DEF_PARAMS (ifp);
5624
5625 if (argc == 1)
5626 {
5627 ret = inet_aton(argv[0], &addr);
5628 if (!ret)
5629 {
5630 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5631 VTY_NEWLINE);
5632 return CMD_WARNING;
5633 }
5634
5635 params = ospf_lookup_if_params (ifp, addr);
5636 if (params == NULL)
5637 return CMD_SUCCESS;
5638 }
5639
5640 UNSET_IF_PARAM (params, priority);
5641 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
5642
5643 if (params != IF_DEF_PARAMS (ifp))
5644 {
5645 ospf_free_if_params (ifp, addr);
5646 ospf_if_update_params (ifp, addr);
5647 }
5648
5649 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
5650 {
5651 struct ospf_interface *oi = rn->info;
5652
5653 if (!oi)
5654 continue;
5655
5656
5657 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
5658 {
5659 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
5660 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
5661 }
5662 }
5663
5664 return CMD_SUCCESS;
5665}
5666
5667ALIAS (no_ip_ospf_priority,
5668 no_ip_ospf_priority_cmd,
5669 "no ip ospf priority",
5670 NO_STR
5671 "IP Information\n"
5672 "OSPF interface commands\n"
5673 "Router priority\n")
5674
5675ALIAS (no_ip_ospf_priority,
5676 no_ospf_priority_cmd,
5677 "no ospf priority",
5678 NO_STR
5679 "OSPF interface commands\n"
5680 "Router priority\n")
5681
5682DEFUN (ip_ospf_retransmit_interval,
5683 ip_ospf_retransmit_interval_addr_cmd,
5684 "ip ospf retransmit-interval <3-65535> A.B.C.D",
5685 "IP Information\n"
5686 "OSPF interface commands\n"
5687 "Time between retransmitting lost link state advertisements\n"
5688 "Seconds\n"
5689 "Address of interface")
5690{
5691 struct interface *ifp = vty->index;
5692 u_int32_t seconds;
5693 struct in_addr addr;
5694 int ret;
5695 struct ospf_if_params *params;
5696
5697 params = IF_DEF_PARAMS (ifp);
5698 seconds = strtol (argv[0], NULL, 10);
5699
5700 /* Retransmit Interval range is <3-65535>. */
5701 if (seconds < 3 || seconds > 65535)
5702 {
5703 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
5704 return CMD_WARNING;
5705 }
5706
5707
5708 if (argc == 2)
5709 {
5710 ret = inet_aton(argv[1], &addr);
5711 if (!ret)
5712 {
5713 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5714 VTY_NEWLINE);
5715 return CMD_WARNING;
5716 }
5717
5718 params = ospf_get_if_params (ifp, addr);
5719 ospf_if_update_params (ifp, addr);
5720 }
5721
5722 SET_IF_PARAM (params, retransmit_interval);
5723 params->retransmit_interval = seconds;
5724
5725 return CMD_SUCCESS;
5726}
5727
5728ALIAS (ip_ospf_retransmit_interval,
5729 ip_ospf_retransmit_interval_cmd,
5730 "ip ospf retransmit-interval <3-65535>",
5731 "IP Information\n"
5732 "OSPF interface commands\n"
5733 "Time between retransmitting lost link state advertisements\n"
5734 "Seconds\n")
5735
5736ALIAS (ip_ospf_retransmit_interval,
5737 ospf_retransmit_interval_cmd,
5738 "ospf retransmit-interval <3-65535>",
5739 "OSPF interface commands\n"
5740 "Time between retransmitting lost link state advertisements\n"
5741 "Seconds\n")
5742
5743DEFUN (no_ip_ospf_retransmit_interval,
5744 no_ip_ospf_retransmit_interval_addr_cmd,
5745 "no ip ospf retransmit-interval A.B.C.D",
5746 NO_STR
5747 "IP Information\n"
5748 "OSPF interface commands\n"
5749 "Time between retransmitting lost link state advertisements\n"
5750 "Address of interface")
5751{
5752 struct interface *ifp = vty->index;
5753 struct in_addr addr;
5754 int ret;
5755 struct ospf_if_params *params;
5756
5757 ifp = vty->index;
5758 params = IF_DEF_PARAMS (ifp);
5759
5760 if (argc == 1)
5761 {
5762 ret = inet_aton(argv[0], &addr);
5763 if (!ret)
5764 {
5765 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5766 VTY_NEWLINE);
5767 return CMD_WARNING;
5768 }
5769
5770 params = ospf_lookup_if_params (ifp, addr);
5771 if (params == NULL)
5772 return CMD_SUCCESS;
5773 }
5774
5775 UNSET_IF_PARAM (params, retransmit_interval);
5776 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
5777
5778 if (params != IF_DEF_PARAMS (ifp))
5779 {
5780 ospf_free_if_params (ifp, addr);
5781 ospf_if_update_params (ifp, addr);
5782 }
5783
5784 return CMD_SUCCESS;
5785}
5786
5787ALIAS (no_ip_ospf_retransmit_interval,
5788 no_ip_ospf_retransmit_interval_cmd,
5789 "no ip ospf retransmit-interval",
5790 NO_STR
5791 "IP Information\n"
5792 "OSPF interface commands\n"
5793 "Time between retransmitting lost link state advertisements\n")
5794
5795ALIAS (no_ip_ospf_retransmit_interval,
5796 no_ospf_retransmit_interval_cmd,
5797 "no ospf retransmit-interval",
5798 NO_STR
5799 "OSPF interface commands\n"
5800 "Time between retransmitting lost link state advertisements\n")
5801
5802DEFUN (ip_ospf_transmit_delay,
5803 ip_ospf_transmit_delay_addr_cmd,
5804 "ip ospf transmit-delay <1-65535> A.B.C.D",
5805 "IP Information\n"
5806 "OSPF interface commands\n"
5807 "Link state transmit delay\n"
5808 "Seconds\n"
5809 "Address of interface")
5810{
5811 struct interface *ifp = vty->index;
5812 u_int32_t seconds;
5813 struct in_addr addr;
5814 int ret;
5815 struct ospf_if_params *params;
5816
5817 params = IF_DEF_PARAMS (ifp);
5818 seconds = strtol (argv[0], NULL, 10);
5819
5820 /* Transmit Delay range is <1-65535>. */
5821 if (seconds < 1 || seconds > 65535)
5822 {
5823 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
5824 return CMD_WARNING;
5825 }
5826
5827 if (argc == 2)
5828 {
5829 ret = inet_aton(argv[1], &addr);
5830 if (!ret)
5831 {
5832 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5833 VTY_NEWLINE);
5834 return CMD_WARNING;
5835 }
5836
5837 params = ospf_get_if_params (ifp, addr);
5838 ospf_if_update_params (ifp, addr);
5839 }
5840
5841 SET_IF_PARAM (params, transmit_delay);
5842 params->transmit_delay = seconds;
5843
5844 return CMD_SUCCESS;
5845}
5846
5847ALIAS (ip_ospf_transmit_delay,
5848 ip_ospf_transmit_delay_cmd,
5849 "ip ospf transmit-delay <1-65535>",
5850 "IP Information\n"
5851 "OSPF interface commands\n"
5852 "Link state transmit delay\n"
5853 "Seconds\n")
5854
5855ALIAS (ip_ospf_transmit_delay,
5856 ospf_transmit_delay_cmd,
5857 "ospf transmit-delay <1-65535>",
5858 "OSPF interface commands\n"
5859 "Link state transmit delay\n"
5860 "Seconds\n")
5861
5862DEFUN (no_ip_ospf_transmit_delay,
5863 no_ip_ospf_transmit_delay_addr_cmd,
5864 "no ip ospf transmit-delay A.B.C.D",
5865 NO_STR
5866 "IP Information\n"
5867 "OSPF interface commands\n"
5868 "Link state transmit delay\n"
5869 "Address of interface")
5870{
5871 struct interface *ifp = vty->index;
5872 struct in_addr addr;
5873 int ret;
5874 struct ospf_if_params *params;
5875
5876 ifp = vty->index;
5877 params = IF_DEF_PARAMS (ifp);
5878
5879 if (argc == 1)
5880 {
5881 ret = inet_aton(argv[0], &addr);
5882 if (!ret)
5883 {
5884 vty_out (vty, "Please specify interface address by A.B.C.D%s",
5885 VTY_NEWLINE);
5886 return CMD_WARNING;
5887 }
5888
5889 params = ospf_lookup_if_params (ifp, addr);
5890 if (params == NULL)
5891 return CMD_SUCCESS;
5892 }
5893
5894 UNSET_IF_PARAM (params, transmit_delay);
5895 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
5896
5897 if (params != IF_DEF_PARAMS (ifp))
5898 {
5899 ospf_free_if_params (ifp, addr);
5900 ospf_if_update_params (ifp, addr);
5901 }
5902
5903 return CMD_SUCCESS;
5904}
5905
5906ALIAS (no_ip_ospf_transmit_delay,
5907 no_ip_ospf_transmit_delay_cmd,
5908 "no ip ospf transmit-delay",
5909 NO_STR
5910 "IP Information\n"
5911 "OSPF interface commands\n"
5912 "Link state transmit delay\n")
5913
5914ALIAS (no_ip_ospf_transmit_delay,
5915 no_ospf_transmit_delay_cmd,
5916 "no ospf transmit-delay",
5917 NO_STR
5918 "OSPF interface commands\n"
5919 "Link state transmit delay\n")
5920
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005921DEFUN (ip_ospf_area,
5922 ip_ospf_area_cmd,
Paul Jakma8a667cf2009-08-27 16:51:42 +01005923 "ip ospf area (A.B.C.D|<0-4294967295>) [A.B.C.D]",
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005924 "IP Information\n"
5925 "OSPF interface commands\n"
5926 "Enable OSPF on this interface\n"
5927 "OSPF area ID in IP address format\n"
Paul Jakma8a667cf2009-08-27 16:51:42 +01005928 "OSPF area ID as a decimal value\n"
5929 "Address of interface\n")
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005930{
5931 struct interface *ifp = vty->index;
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005932 struct in_addr area_id;
Paul Jakma8a667cf2009-08-27 16:51:42 +01005933 struct in_addr addr;
5934 int format;
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005935 struct ospf_if_params *params;
5936
Paul Jakma8a667cf2009-08-27 16:51:42 +01005937 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005938
Paul Jakma8a667cf2009-08-27 16:51:42 +01005939 OSPF_VTY_GET_IF_PARAMS(ifp, params, 1, addr, VTY_SET);
5940
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005941 if (OSPF_IF_PARAM_CONFIGURED(params, if_area))
5942 {
Paul Jakma8a667cf2009-08-27 16:51:42 +01005943 vty_out (vty, "There is already an interface area statement.%s",
5944 VTY_NEWLINE);
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005945 return CMD_WARNING;
5946 }
5947 if (memcmp (ifp->name, "VLINK", 5) == 0)
5948 {
5949 vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE);
5950 return CMD_WARNING;
5951 }
Paul Jakma8a667cf2009-08-27 16:51:42 +01005952
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005953 SET_IF_PARAM (params, if_area);
5954 params->if_area = area_id;
Paul Jakma8a667cf2009-08-27 16:51:42 +01005955 ospf_interface_area_set (ifp);
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005956
5957 return CMD_SUCCESS;
5958}
5959
5960DEFUN (no_ip_ospf_area,
5961 no_ip_ospf_area_cmd,
Paul Jakma8a667cf2009-08-27 16:51:42 +01005962 "no ip ospf area [A.B.C.D]",
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005963 NO_STR
5964 "IP Information\n"
5965 "OSPF interface commands\n"
Paul Jakma8a667cf2009-08-27 16:51:42 +01005966 "Disable OSPF on this interface\n"
5967 "Address of interface\n")
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005968{
5969 struct interface *ifp = vty->index;
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005970 struct ospf_if_params *params;
Paul Jakma8a667cf2009-08-27 16:51:42 +01005971 struct in_addr addr;
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005972
Paul Jakma8a667cf2009-08-27 16:51:42 +01005973 OSPF_VTY_GET_IF_PARAMS(ifp, params, 0, addr, VTY_UNSET);
5974
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005975 if (!OSPF_IF_PARAM_CONFIGURED(params, if_area))
5976 return CMD_SUCCESS;
Paul Jakma8a667cf2009-08-27 16:51:42 +01005977
5978 OSPF_VTY_PARAM_UNSET(params, if_area, ifp, addr);
5979
5980 ospf_interface_area_unset (ifp);
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005981
Joakim Tjernlund738bce72009-08-07 13:48:15 +02005982 return CMD_SUCCESS;
5983}
5984
Christian Franke6f2a6702013-09-30 12:27:52 +00005985DEFUN (ospf_redistribute_source,
5986 ospf_redistribute_source_cmd,
5987 "redistribute " QUAGGA_REDIST_STR_OSPFD
5988 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
Paul Jakmad1c65c22006-06-27 08:01:43 +00005989 REDIST_STR
5990 QUAGGA_REDIST_HELP_STR_OSPFD
paul718e3742002-12-13 20:15:29 +00005991 "Metric for redistributed routes\n"
5992 "OSPF default metric\n"
5993 "OSPF exterior metric type for redistributed routes\n"
5994 "Set OSPF External Type 1 metrics\n"
5995 "Set OSPF External Type 2 metrics\n"
5996 "Route map reference\n"
5997 "Pointer to route-map entries\n")
5998{
paul020709f2003-04-04 02:44:16 +00005999 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006000 int source;
6001 int type = -1;
6002 int metric = -1;
6003
Christian Franke6f2a6702013-09-30 12:27:52 +00006004 if (argc < 4)
6005 return CMD_WARNING; /* should not happen */
6006
paul718e3742002-12-13 20:15:29 +00006007 /* Get distribute source. */
David Lampartere0ca5fd2009-09-16 01:52:42 +02006008 source = proto_redistnum(AFI_IP, argv[0]);
6009 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006010 return CMD_WARNING;
6011
6012 /* Get metric value. */
Christian Franke6f2a6702013-09-30 12:27:52 +00006013 if (argv[1] != NULL)
paul718e3742002-12-13 20:15:29 +00006014 if (!str2metric (argv[1], &metric))
6015 return CMD_WARNING;
6016
6017 /* Get metric type. */
Christian Franke6f2a6702013-09-30 12:27:52 +00006018 if (argv[2] != NULL)
paul718e3742002-12-13 20:15:29 +00006019 if (!str2metric_type (argv[2], &type))
6020 return CMD_WARNING;
6021
Christian Franke6f2a6702013-09-30 12:27:52 +00006022 if (argv[3] != NULL)
paul020709f2003-04-04 02:44:16 +00006023 ospf_routemap_set (ospf, source, argv[3]);
paul718e3742002-12-13 20:15:29 +00006024 else
paul020709f2003-04-04 02:44:16 +00006025 ospf_routemap_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006026
paul020709f2003-04-04 02:44:16 +00006027 return ospf_redistribute_set (ospf, source, type, metric);
paul718e3742002-12-13 20:15:29 +00006028}
6029
paul718e3742002-12-13 20:15:29 +00006030DEFUN (no_ospf_redistribute_source,
6031 no_ospf_redistribute_source_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006032 "no redistribute " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006033 NO_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006034 REDIST_STR
6035 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006036{
paul020709f2003-04-04 02:44:16 +00006037 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006038 int source;
6039
David Lampartere0ca5fd2009-09-16 01:52:42 +02006040 source = proto_redistnum(AFI_IP, argv[0]);
6041 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006042 return CMD_WARNING;
6043
paul020709f2003-04-04 02:44:16 +00006044 ospf_routemap_unset (ospf, source);
6045 return ospf_redistribute_unset (ospf, source);
paul718e3742002-12-13 20:15:29 +00006046}
6047
6048DEFUN (ospf_distribute_list_out,
6049 ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006050 "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006051 "Filter networks in routing updates\n"
6052 "Access-list name\n"
6053 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006054 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006055{
paul68980082003-03-25 05:07:42 +00006056 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006057 int source;
6058
6059 /* Get distribute source. */
Christian Frankebda3c322012-12-04 11:31:16 -08006060 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02006061 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006062 return CMD_WARNING;
6063
paul68980082003-03-25 05:07:42 +00006064 return ospf_distribute_list_out_set (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006065}
6066
6067DEFUN (no_ospf_distribute_list_out,
6068 no_ospf_distribute_list_out_cmd,
Paul Jakmad1c65c22006-06-27 08:01:43 +00006069 "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
paul718e3742002-12-13 20:15:29 +00006070 NO_STR
6071 "Filter networks in routing updates\n"
6072 "Access-list name\n"
6073 OUT_STR
Paul Jakmad1c65c22006-06-27 08:01:43 +00006074 QUAGGA_REDIST_HELP_STR_OSPFD)
paul718e3742002-12-13 20:15:29 +00006075{
paul68980082003-03-25 05:07:42 +00006076 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006077 int source;
6078
Christian Frankebda3c322012-12-04 11:31:16 -08006079 source = proto_redistnum(AFI_IP, argv[1]);
David Lampartere0ca5fd2009-09-16 01:52:42 +02006080 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
paul718e3742002-12-13 20:15:29 +00006081 return CMD_WARNING;
6082
paul68980082003-03-25 05:07:42 +00006083 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
paul718e3742002-12-13 20:15:29 +00006084}
6085
6086/* Default information originate. */
Christian Franke6f2a6702013-09-30 12:27:52 +00006087DEFUN (ospf_default_information_originate,
paul718e3742002-12-13 20:15:29 +00006088 ospf_default_information_originate_cmd,
Christian Franke6f2a6702013-09-30 12:27:52 +00006089 "default-information originate "
6090 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
paul718e3742002-12-13 20:15:29 +00006091 "Control distribution of default information\n"
6092 "Distribute a default route\n"
Christian Franke6f2a6702013-09-30 12:27:52 +00006093 "Always advertise default route\n"
paul718e3742002-12-13 20:15:29 +00006094 "OSPF default metric\n"
6095 "OSPF metric\n"
paul718e3742002-12-13 20:15:29 +00006096 "OSPF metric type for default routes\n"
6097 "Set OSPF External Type 1 metrics\n"
6098 "Set OSPF External Type 2 metrics\n"
paul718e3742002-12-13 20:15:29 +00006099 "Route map reference\n"
6100 "Pointer to route-map entries\n")
6101{
paul020709f2003-04-04 02:44:16 +00006102 struct ospf *ospf = vty->index;
Christian Franke6f2a6702013-09-30 12:27:52 +00006103 int default_originate = DEFAULT_ORIGINATE_ZEBRA;
paul718e3742002-12-13 20:15:29 +00006104 int type = -1;
6105 int metric = -1;
6106
Christian Franke6f2a6702013-09-30 12:27:52 +00006107 if (argc < 4)
6108 return CMD_WARNING; /* this should not happen */
6109
6110 /* Check whether "always" was specified */
6111 if (argv[0] != NULL)
6112 default_originate = DEFAULT_ORIGINATE_ALWAYS;
paul718e3742002-12-13 20:15:29 +00006113
6114 /* Get metric value. */
Christian Franke6f2a6702013-09-30 12:27:52 +00006115 if (argv[1] != NULL)
paul718e3742002-12-13 20:15:29 +00006116 if (!str2metric (argv[1], &metric))
6117 return CMD_WARNING;
6118
Christian Franke6f2a6702013-09-30 12:27:52 +00006119 /* Get metric type. */
6120 if (argv[2] != NULL)
6121 if (!str2metric_type (argv[2], &type))
6122 return CMD_WARNING;
6123
6124 if (argv[3] != NULL)
6125 ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]);
paul718e3742002-12-13 20:15:29 +00006126 else
paul020709f2003-04-04 02:44:16 +00006127 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
paul718e3742002-12-13 20:15:29 +00006128
Christian Franke6f2a6702013-09-30 12:27:52 +00006129 return ospf_redistribute_default_set (ospf, default_originate,
paul020709f2003-04-04 02:44:16 +00006130 type, metric);
paul718e3742002-12-13 20:15:29 +00006131}
6132
paul718e3742002-12-13 20:15:29 +00006133DEFUN (no_ospf_default_information_originate,
6134 no_ospf_default_information_originate_cmd,
6135 "no default-information originate",
6136 NO_STR
6137 "Control distribution of default information\n"
6138 "Distribute a default route\n")
6139{
paul68980082003-03-25 05:07:42 +00006140 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006141 struct prefix_ipv4 p;
paul718e3742002-12-13 20:15:29 +00006142
6143 p.family = AF_INET;
6144 p.prefix.s_addr = 0;
6145 p.prefixlen = 0;
6146
ajs5339cfd2005-09-19 13:28:05 +00006147 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
paul718e3742002-12-13 20:15:29 +00006148
6149 if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
6150 ospf_external_info_delete (DEFAULT_ROUTE, p);
6151 route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
6152 EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
6153 }
6154
paul020709f2003-04-04 02:44:16 +00006155 ospf_routemap_unset (ospf, DEFAULT_ROUTE);
6156 return ospf_redistribute_default_unset (ospf);
paul718e3742002-12-13 20:15:29 +00006157}
6158
6159DEFUN (ospf_default_metric,
6160 ospf_default_metric_cmd,
6161 "default-metric <0-16777214>",
6162 "Set metric of redistributed routes\n"
6163 "Default metric\n")
6164{
paul68980082003-03-25 05:07:42 +00006165 struct ospf *ospf = vty->index;
paul718e3742002-12-13 20:15:29 +00006166 int metric = -1;
6167
6168 if (!str2metric (argv[0], &metric))
6169 return CMD_WARNING;
6170
paul68980082003-03-25 05:07:42 +00006171 ospf->default_metric = metric;
paul718e3742002-12-13 20:15:29 +00006172
6173 return CMD_SUCCESS;
6174}
6175
6176DEFUN (no_ospf_default_metric,
6177 no_ospf_default_metric_cmd,
6178 "no default-metric",
6179 NO_STR
6180 "Set metric of redistributed routes\n")
6181{
paul68980082003-03-25 05:07:42 +00006182 struct ospf *ospf = vty->index;
6183
6184 ospf->default_metric = -1;
6185
paul718e3742002-12-13 20:15:29 +00006186 return CMD_SUCCESS;
6187}
6188
6189ALIAS (no_ospf_default_metric,
6190 no_ospf_default_metric_val_cmd,
6191 "no default-metric <0-16777214>",
6192 NO_STR
6193 "Set metric of redistributed routes\n"
6194 "Default metric\n")
6195
6196DEFUN (ospf_distance,
6197 ospf_distance_cmd,
6198 "distance <1-255>",
6199 "Define an administrative distance\n"
6200 "OSPF Administrative distance\n")
6201{
paul68980082003-03-25 05:07:42 +00006202 struct ospf *ospf = vty->index;
6203
6204 ospf->distance_all = atoi (argv[0]);
6205
paul718e3742002-12-13 20:15:29 +00006206 return CMD_SUCCESS;
6207}
6208
6209DEFUN (no_ospf_distance,
6210 no_ospf_distance_cmd,
6211 "no distance <1-255>",
6212 NO_STR
6213 "Define an administrative distance\n"
6214 "OSPF Administrative distance\n")
6215{
paul68980082003-03-25 05:07:42 +00006216 struct ospf *ospf = vty->index;
6217
6218 ospf->distance_all = 0;
6219
paul718e3742002-12-13 20:15:29 +00006220 return CMD_SUCCESS;
6221}
6222
6223DEFUN (no_ospf_distance_ospf,
6224 no_ospf_distance_ospf_cmd,
Christian Franke6f2a6702013-09-30 12:27:52 +00006225 "no distance ospf {intra-area|inter-area|external}",
paul718e3742002-12-13 20:15:29 +00006226 NO_STR
6227 "Define an administrative distance\n"
6228 "OSPF Administrative distance\n"
Christian Franke6f2a6702013-09-30 12:27:52 +00006229 "OSPF Distance\n"
6230 "Intra-area routes\n"
6231 "Inter-area routes\n"
6232 "External routes\n")
paul718e3742002-12-13 20:15:29 +00006233{
paul68980082003-03-25 05:07:42 +00006234 struct ospf *ospf = vty->index;
6235
Christian Franke6f2a6702013-09-30 12:27:52 +00006236 if (argc < 3)
6237 return CMD_WARNING;
6238
6239 if (argv[0] != NULL)
6240 ospf->distance_intra = 0;
6241
6242 if (argv[1] != NULL)
6243 ospf->distance_inter = 0;
6244
6245 if (argv[2] != NULL)
6246 ospf->distance_external = 0;
6247
6248 if (argv[0] || argv[1] || argv[2])
6249 return CMD_SUCCESS;
6250
6251 /* If no arguments are given, clear all distance information */
paul68980082003-03-25 05:07:42 +00006252 ospf->distance_intra = 0;
6253 ospf->distance_inter = 0;
6254 ospf->distance_external = 0;
6255
paul718e3742002-12-13 20:15:29 +00006256 return CMD_SUCCESS;
6257}
6258
Christian Franke6f2a6702013-09-30 12:27:52 +00006259DEFUN (ospf_distance_ospf,
6260 ospf_distance_ospf_cmd,
6261 "distance ospf "
6262 "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
paul718e3742002-12-13 20:15:29 +00006263 "Define an administrative distance\n"
6264 "OSPF Administrative distance\n"
6265 "Intra-area routes\n"
6266 "Distance for intra-area routes\n"
6267 "Inter-area routes\n"
6268 "Distance for inter-area routes\n"
6269 "External routes\n"
6270 "Distance for external routes\n")
6271{
paul68980082003-03-25 05:07:42 +00006272 struct ospf *ospf = vty->index;
6273
Christian Franke6f2a6702013-09-30 12:27:52 +00006274 if (argc < 3) /* should not happen */
6275 return CMD_WARNING;
paul68980082003-03-25 05:07:42 +00006276
Christian Franke6f2a6702013-09-30 12:27:52 +00006277 if (!argv[0] && !argv[1] && !argv[2])
6278 {
6279 vty_out(vty, "%% Command incomplete. (Arguments required)%s",
6280 VTY_NEWLINE);
6281 return CMD_WARNING;
6282 }
paul718e3742002-12-13 20:15:29 +00006283
Christian Franke6f2a6702013-09-30 12:27:52 +00006284 if (argv[0] != NULL)
6285 ospf->distance_intra = atoi(argv[0]);
paul68980082003-03-25 05:07:42 +00006286
Christian Franke6f2a6702013-09-30 12:27:52 +00006287 if (argv[1] != NULL)
6288 ospf->distance_inter = atoi(argv[1]);
paul68980082003-03-25 05:07:42 +00006289
Christian Franke6f2a6702013-09-30 12:27:52 +00006290 if (argv[2] != NULL)
6291 ospf->distance_external = atoi(argv[2]);
paul68980082003-03-25 05:07:42 +00006292
paul718e3742002-12-13 20:15:29 +00006293 return CMD_SUCCESS;
6294}
6295
6296DEFUN (ospf_distance_source,
6297 ospf_distance_source_cmd,
6298 "distance <1-255> A.B.C.D/M",
6299 "Administrative distance\n"
6300 "Distance value\n"
6301 "IP source prefix\n")
6302{
paul020709f2003-04-04 02:44:16 +00006303 struct ospf *ospf = vty->index;
6304
6305 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
paul68980082003-03-25 05:07:42 +00006306
paul718e3742002-12-13 20:15:29 +00006307 return CMD_SUCCESS;
6308}
6309
6310DEFUN (no_ospf_distance_source,
6311 no_ospf_distance_source_cmd,
6312 "no distance <1-255> A.B.C.D/M",
6313 NO_STR
6314 "Administrative distance\n"
6315 "Distance value\n"
6316 "IP source prefix\n")
6317{
paul020709f2003-04-04 02:44:16 +00006318 struct ospf *ospf = vty->index;
6319
6320 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
6321
paul718e3742002-12-13 20:15:29 +00006322 return CMD_SUCCESS;
6323}
6324
6325DEFUN (ospf_distance_source_access_list,
6326 ospf_distance_source_access_list_cmd,
6327 "distance <1-255> A.B.C.D/M WORD",
6328 "Administrative distance\n"
6329 "Distance value\n"
6330 "IP source prefix\n"
6331 "Access list name\n")
6332{
paul020709f2003-04-04 02:44:16 +00006333 struct ospf *ospf = vty->index;
6334
6335 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
6336
paul718e3742002-12-13 20:15:29 +00006337 return CMD_SUCCESS;
6338}
6339
6340DEFUN (no_ospf_distance_source_access_list,
6341 no_ospf_distance_source_access_list_cmd,
6342 "no distance <1-255> A.B.C.D/M WORD",
6343 NO_STR
6344 "Administrative distance\n"
6345 "Distance value\n"
6346 "IP source prefix\n"
6347 "Access list name\n")
6348{
paul020709f2003-04-04 02:44:16 +00006349 struct ospf *ospf = vty->index;
6350
6351 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
6352
paul718e3742002-12-13 20:15:29 +00006353 return CMD_SUCCESS;
6354}
6355
vincentba682532005-09-29 13:52:57 +00006356DEFUN (ip_ospf_mtu_ignore,
6357 ip_ospf_mtu_ignore_addr_cmd,
6358 "ip ospf mtu-ignore A.B.C.D",
6359 "IP Information\n"
6360 "OSPF interface commands\n"
6361 "Disable mtu mismatch detection\n"
6362 "Address of interface")
6363{
6364 struct interface *ifp = vty->index;
6365 struct in_addr addr;
6366 int ret;
6367
6368 struct ospf_if_params *params;
6369 params = IF_DEF_PARAMS (ifp);
6370
6371 if (argc == 1)
6372 {
6373 ret = inet_aton(argv[0], &addr);
6374 if (!ret)
6375 {
6376 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6377 VTY_NEWLINE);
6378 return CMD_WARNING;
6379 }
6380 params = ospf_get_if_params (ifp, addr);
6381 ospf_if_update_params (ifp, addr);
6382 }
6383 params->mtu_ignore = 1;
6384 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6385 SET_IF_PARAM (params, mtu_ignore);
6386 else
6387 {
6388 UNSET_IF_PARAM (params, mtu_ignore);
6389 if (params != IF_DEF_PARAMS (ifp))
6390 {
6391 ospf_free_if_params (ifp, addr);
6392 ospf_if_update_params (ifp, addr);
6393 }
6394 }
6395 return CMD_SUCCESS;
6396}
6397
6398ALIAS (ip_ospf_mtu_ignore,
6399 ip_ospf_mtu_ignore_cmd,
6400 "ip ospf mtu-ignore",
6401 "IP Information\n"
6402 "OSPF interface commands\n"
6403 "Disable mtu mismatch detection\n")
6404
6405
6406DEFUN (no_ip_ospf_mtu_ignore,
6407 no_ip_ospf_mtu_ignore_addr_cmd,
6408 "no ip ospf mtu-ignore A.B.C.D",
6409 "IP Information\n"
6410 "OSPF interface commands\n"
6411 "Disable mtu mismatch detection\n"
6412 "Address of interface")
6413{
6414 struct interface *ifp = vty->index;
6415 struct in_addr addr;
6416 int ret;
6417
6418 struct ospf_if_params *params;
6419 params = IF_DEF_PARAMS (ifp);
6420
6421 if (argc == 1)
6422 {
6423 ret = inet_aton(argv[0], &addr);
6424 if (!ret)
6425 {
6426 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6427 VTY_NEWLINE);
6428 return CMD_WARNING;
6429 }
6430 params = ospf_get_if_params (ifp, addr);
6431 ospf_if_update_params (ifp, addr);
6432 }
6433 params->mtu_ignore = 0;
6434 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
6435 SET_IF_PARAM (params, mtu_ignore);
6436 else
6437 {
6438 UNSET_IF_PARAM (params, mtu_ignore);
6439 if (params != IF_DEF_PARAMS (ifp))
6440 {
6441 ospf_free_if_params (ifp, addr);
6442 ospf_if_update_params (ifp, addr);
6443 }
6444 }
6445 return CMD_SUCCESS;
6446}
6447
6448ALIAS (no_ip_ospf_mtu_ignore,
6449 no_ip_ospf_mtu_ignore_cmd,
6450 "no ip ospf mtu-ignore",
6451 "IP Information\n"
6452 "OSPF interface commands\n"
6453 "Disable mtu mismatch detection\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02006454
paul88d6cf32005-10-29 12:50:09 +00006455DEFUN (ospf_max_metric_router_lsa_admin,
6456 ospf_max_metric_router_lsa_admin_cmd,
6457 "max-metric router-lsa administrative",
6458 "OSPF maximum / infinite-distance metric\n"
6459 "Advertise own Router-LSA with infinite distance (stub router)\n"
6460 "Administratively applied, for an indefinite period\n")
6461{
6462 struct listnode *ln;
6463 struct ospf_area *area;
6464 struct ospf *ospf = vty->index;
vincentba682532005-09-29 13:52:57 +00006465
paul88d6cf32005-10-29 12:50:09 +00006466 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6467 {
6468 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6469
6470 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
Paul Jakmac363d382010-01-24 22:42:13 +00006471 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006472 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08006473
6474 /* Allows for areas configured later to get the property */
6475 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
6476
paul88d6cf32005-10-29 12:50:09 +00006477 return CMD_SUCCESS;
6478}
6479
6480DEFUN (no_ospf_max_metric_router_lsa_admin,
6481 no_ospf_max_metric_router_lsa_admin_cmd,
6482 "no max-metric router-lsa administrative",
6483 NO_STR
6484 "OSPF maximum / infinite-distance metric\n"
6485 "Advertise own Router-LSA with infinite distance (stub router)\n"
6486 "Administratively applied, for an indefinite period\n")
6487{
6488 struct listnode *ln;
6489 struct ospf_area *area;
6490 struct ospf *ospf = vty->index;
6491
6492 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6493 {
6494 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
6495
6496 /* Don't trample on the start-up stub timer */
6497 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
6498 && !area->t_stub_router)
6499 {
6500 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00006501 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006502 }
6503 }
Ayan Banerjee4ba4fc82012-12-03 11:17:24 -08006504 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
paul88d6cf32005-10-29 12:50:09 +00006505 return CMD_SUCCESS;
6506}
6507
6508DEFUN (ospf_max_metric_router_lsa_startup,
6509 ospf_max_metric_router_lsa_startup_cmd,
6510 "max-metric router-lsa on-startup <5-86400>",
6511 "OSPF maximum / infinite-distance metric\n"
6512 "Advertise own Router-LSA with infinite distance (stub router)\n"
6513 "Automatically advertise stub Router-LSA on startup of OSPF\n"
6514 "Time (seconds) to advertise self as stub-router\n")
6515{
6516 unsigned int seconds;
6517 struct ospf *ospf = vty->index;
6518
6519 if (argc != 1)
6520 {
6521 vty_out (vty, "%% Must supply stub-router period");
6522 return CMD_WARNING;
6523 }
6524
6525 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
6526
6527 ospf->stub_router_startup_time = seconds;
6528
6529 return CMD_SUCCESS;
6530}
6531
6532DEFUN (no_ospf_max_metric_router_lsa_startup,
6533 no_ospf_max_metric_router_lsa_startup_cmd,
6534 "no max-metric router-lsa on-startup",
6535 NO_STR
6536 "OSPF maximum / infinite-distance metric\n"
6537 "Advertise own Router-LSA with infinite distance (stub router)\n"
6538 "Automatically advertise stub Router-LSA on startup of OSPF\n")
6539{
6540 struct listnode *ln;
6541 struct ospf_area *area;
6542 struct ospf *ospf = vty->index;
6543
6544 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6545
6546 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6547 {
6548 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
6549 OSPF_TIMER_OFF (area->t_stub_router);
6550
6551 /* Don't trample on admin stub routed */
6552 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6553 {
6554 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
Paul Jakmac363d382010-01-24 22:42:13 +00006555 ospf_router_lsa_update_area (area);
paul88d6cf32005-10-29 12:50:09 +00006556 }
6557 }
6558 return CMD_SUCCESS;
6559}
6560
6561DEFUN (ospf_max_metric_router_lsa_shutdown,
6562 ospf_max_metric_router_lsa_shutdown_cmd,
6563 "max-metric router-lsa on-shutdown <5-86400>",
6564 "OSPF maximum / infinite-distance metric\n"
6565 "Advertise own Router-LSA with infinite distance (stub router)\n"
6566 "Advertise stub-router prior to full shutdown of OSPF\n"
6567 "Time (seconds) to wait till full shutdown\n")
6568{
6569 unsigned int seconds;
6570 struct ospf *ospf = vty->index;
6571
6572 if (argc != 1)
6573 {
6574 vty_out (vty, "%% Must supply stub-router shutdown period");
6575 return CMD_WARNING;
6576 }
6577
6578 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
6579
6580 ospf->stub_router_shutdown_time = seconds;
6581
6582 return CMD_SUCCESS;
6583}
6584
6585DEFUN (no_ospf_max_metric_router_lsa_shutdown,
6586 no_ospf_max_metric_router_lsa_shutdown_cmd,
6587 "no max-metric router-lsa on-shutdown",
6588 NO_STR
6589 "OSPF maximum / infinite-distance metric\n"
6590 "Advertise own Router-LSA with infinite distance (stub router)\n"
6591 "Advertise stub-router prior to full shutdown of OSPF\n")
6592{
6593 struct ospf *ospf = vty->index;
6594
6595 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
6596
6597 return CMD_SUCCESS;
6598}
6599
6600static void
6601config_write_stub_router (struct vty *vty, struct ospf *ospf)
6602{
6603 struct listnode *ln;
6604 struct ospf_area *area;
6605
6606 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6607 vty_out (vty, " max-metric router-lsa on-startup %u%s",
6608 ospf->stub_router_startup_time, VTY_NEWLINE);
6609 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
6610 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
6611 ospf->stub_router_shutdown_time, VTY_NEWLINE);
6612 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
6613 {
6614 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
6615 {
6616 vty_out (vty, " max-metric router-lsa administrative%s",
6617 VTY_NEWLINE);
6618 break;
6619 }
6620 }
6621 return;
6622}
David Lamparter6b0655a2014-06-04 06:53:35 +02006623
paul4dadc292005-05-06 21:37:42 +00006624static void
paul718e3742002-12-13 20:15:29 +00006625show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
6626{
6627 struct route_node *rn;
6628 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006629 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006630 struct ospf_path *path;
6631
6632 vty_out (vty, "============ OSPF network routing table ============%s",
6633 VTY_NEWLINE);
6634
6635 for (rn = route_top (rt); rn; rn = route_next (rn))
6636 if ((or = rn->info) != NULL)
6637 {
6638 char buf1[19];
6639 snprintf (buf1, 19, "%s/%d",
6640 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6641
6642 switch (or->path_type)
6643 {
6644 case OSPF_PATH_INTER_AREA:
6645 if (or->type == OSPF_DESTINATION_NETWORK)
6646 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
6647 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6648 else if (or->type == OSPF_DESTINATION_DISCARD)
6649 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
6650 break;
6651 case OSPF_PATH_INTRA_AREA:
6652 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
6653 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
6654 break;
6655 default:
6656 break;
6657 }
6658
6659 if (or->type == OSPF_DESTINATION_NETWORK)
paul1eb8ef22005-04-07 07:30:20 +00006660 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
paul96735ee2003-08-10 02:51:22 +00006661 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006662 if (if_lookup_by_index(path->ifindex))
paul96735ee2003-08-10 02:51:22 +00006663 {
6664 if (path->nexthop.s_addr == 0)
6665 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006666 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006667 else
6668 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006669 inet_ntoa (path->nexthop),
6670 ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006671 }
6672 }
paul718e3742002-12-13 20:15:29 +00006673 }
6674 vty_out (vty, "%s", VTY_NEWLINE);
6675}
6676
paul4dadc292005-05-06 21:37:42 +00006677static void
paul718e3742002-12-13 20:15:29 +00006678show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
6679{
6680 struct route_node *rn;
6681 struct ospf_route *or;
paul1eb8ef22005-04-07 07:30:20 +00006682 struct listnode *pnode;
6683 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00006684 struct ospf_path *path;
6685
6686 vty_out (vty, "============ OSPF router routing table =============%s",
6687 VTY_NEWLINE);
6688 for (rn = route_top (rtrs); rn; rn = route_next (rn))
6689 if (rn->info)
6690 {
6691 int flag = 0;
6692
6693 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
6694
paul1eb8ef22005-04-07 07:30:20 +00006695 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
6696 {
6697 if (flag++)
6698 vty_out (vty, "%24s", "");
paul718e3742002-12-13 20:15:29 +00006699
paul1eb8ef22005-04-07 07:30:20 +00006700 /* Show path. */
6701 vty_out (vty, "%s [%d] area: %s",
6702 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
6703 or->cost, inet_ntoa (or->u.std.area_id));
6704 /* Show flags. */
6705 vty_out (vty, "%s%s%s",
6706 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
6707 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
6708 VTY_NEWLINE);
6709
6710 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
6711 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006712 if (if_lookup_by_index(path->ifindex))
hasso54bedb52005-08-17 13:31:47 +00006713 {
6714 if (path->nexthop.s_addr == 0)
6715 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006716 "", ifindex2ifname (path->ifindex),
6717 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00006718 else
6719 vty_out (vty, "%24s via %s, %s%s", "",
6720 inet_ntoa (path->nexthop),
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006721 ifindex2ifname (path->ifindex),
6722 VTY_NEWLINE);
hasso54bedb52005-08-17 13:31:47 +00006723 }
paul1eb8ef22005-04-07 07:30:20 +00006724 }
6725 }
paul718e3742002-12-13 20:15:29 +00006726 }
6727 vty_out (vty, "%s", VTY_NEWLINE);
6728}
6729
paul4dadc292005-05-06 21:37:42 +00006730static void
paul718e3742002-12-13 20:15:29 +00006731show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
6732{
6733 struct route_node *rn;
6734 struct ospf_route *er;
paul1eb8ef22005-04-07 07:30:20 +00006735 struct listnode *pnode, *pnnode;
paul718e3742002-12-13 20:15:29 +00006736 struct ospf_path *path;
6737
6738 vty_out (vty, "============ OSPF external routing table ===========%s",
6739 VTY_NEWLINE);
6740 for (rn = route_top (rt); rn; rn = route_next (rn))
6741 if ((er = rn->info) != NULL)
6742 {
6743 char buf1[19];
6744 snprintf (buf1, 19, "%s/%d",
6745 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
6746
6747 switch (er->path_type)
6748 {
6749 case OSPF_PATH_TYPE1_EXTERNAL:
6750 vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
6751 er->cost, er->u.ext.tag, VTY_NEWLINE);
6752 break;
6753 case OSPF_PATH_TYPE2_EXTERNAL:
6754 vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
6755 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
6756 break;
6757 }
6758
paul1eb8ef22005-04-07 07:30:20 +00006759 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
paul718e3742002-12-13 20:15:29 +00006760 {
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006761 if (if_lookup_by_index(path->ifindex))
paul718e3742002-12-13 20:15:29 +00006762 {
6763 if (path->nexthop.s_addr == 0)
paul96735ee2003-08-10 02:51:22 +00006764 vty_out (vty, "%24s directly attached to %s%s",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006765 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
paul96735ee2003-08-10 02:51:22 +00006766 else
6767 vty_out (vty, "%24s via %s, %s%s", "",
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +02006768 inet_ntoa (path->nexthop),
6769 ifindex2ifname (path->ifindex),
paul96735ee2003-08-10 02:51:22 +00006770 VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006771 }
6772 }
6773 }
6774 vty_out (vty, "%s", VTY_NEWLINE);
6775}
6776
paul718e3742002-12-13 20:15:29 +00006777DEFUN (show_ip_ospf_border_routers,
6778 show_ip_ospf_border_routers_cmd,
6779 "show ip ospf border-routers",
6780 SHOW_STR
6781 IP_STR
6782 "show all the ABR's and ASBR's\n"
6783 "for this area\n")
6784{
paul020709f2003-04-04 02:44:16 +00006785 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006786
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006787 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00006788 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006789 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006790 return CMD_SUCCESS;
6791 }
6792
paul68980082003-03-25 05:07:42 +00006793 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006794 {
6795 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6796 return CMD_SUCCESS;
6797 }
6798
6799 /* Show Network routes.
paul020709f2003-04-04 02:44:16 +00006800 show_ip_ospf_route_network (vty, ospf->new_table); */
paul718e3742002-12-13 20:15:29 +00006801
6802 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006803 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006804
6805 return CMD_SUCCESS;
6806}
paul718e3742002-12-13 20:15:29 +00006807
6808DEFUN (show_ip_ospf_route,
6809 show_ip_ospf_route_cmd,
6810 "show ip ospf route",
6811 SHOW_STR
6812 IP_STR
6813 "OSPF information\n"
6814 "OSPF routing table\n")
6815{
paul020709f2003-04-04 02:44:16 +00006816 struct ospf *ospf;
paul68980082003-03-25 05:07:42 +00006817
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006818 if ((ospf = ospf_lookup ()) == NULL)
paul718e3742002-12-13 20:15:29 +00006819 {
Paul Jakmacac3b5c2006-05-11 13:31:11 +00006820 vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006821 return CMD_SUCCESS;
6822 }
6823
paul68980082003-03-25 05:07:42 +00006824 if (ospf->new_table == NULL)
paul718e3742002-12-13 20:15:29 +00006825 {
6826 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
6827 return CMD_SUCCESS;
6828 }
6829
6830 /* Show Network routes. */
paul68980082003-03-25 05:07:42 +00006831 show_ip_ospf_route_network (vty, ospf->new_table);
paul718e3742002-12-13 20:15:29 +00006832
6833 /* Show Router routes. */
paul68980082003-03-25 05:07:42 +00006834 show_ip_ospf_route_router (vty, ospf->new_rtrs);
paul718e3742002-12-13 20:15:29 +00006835
6836 /* Show AS External routes. */
paul68980082003-03-25 05:07:42 +00006837 show_ip_ospf_route_external (vty, ospf->old_external_route);
paul718e3742002-12-13 20:15:29 +00006838
6839 return CMD_SUCCESS;
6840}
6841
David Lamparter6b0655a2014-06-04 06:53:35 +02006842
hassoeb1ce602004-10-08 08:17:22 +00006843const char *ospf_abr_type_str[] =
paul718e3742002-12-13 20:15:29 +00006844{
6845 "unknown",
6846 "standard",
6847 "ibm",
6848 "cisco",
6849 "shortcut"
6850};
6851
hassoeb1ce602004-10-08 08:17:22 +00006852const char *ospf_shortcut_mode_str[] =
paul718e3742002-12-13 20:15:29 +00006853{
6854 "default",
6855 "enable",
6856 "disable"
6857};
6858
6859
paul4dadc292005-05-06 21:37:42 +00006860static void
paul718e3742002-12-13 20:15:29 +00006861area_id2str (char *buf, int length, struct ospf_area *area)
6862{
6863 memset (buf, 0, length);
6864
6865 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
6866 strncpy (buf, inet_ntoa (area->area_id), length);
6867 else
6868 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
6869}
6870
David Lamparter6b0655a2014-06-04 06:53:35 +02006871
hassoeb1ce602004-10-08 08:17:22 +00006872const char *ospf_int_type_str[] =
paul718e3742002-12-13 20:15:29 +00006873{
6874 "unknown", /* should never be used. */
6875 "point-to-point",
6876 "broadcast",
6877 "non-broadcast",
6878 "point-to-multipoint",
6879 "virtual-link", /* should never be used. */
6880 "loopback"
6881};
6882
6883/* Configuration write function for ospfd. */
paul4dadc292005-05-06 21:37:42 +00006884static int
paul718e3742002-12-13 20:15:29 +00006885config_write_interface (struct vty *vty)
6886{
hasso52dc7ee2004-09-23 19:18:23 +00006887 struct listnode *n1, *n2;
paul718e3742002-12-13 20:15:29 +00006888 struct interface *ifp;
6889 struct crypt_key *ck;
6890 int write = 0;
6891 struct route_node *rn = NULL;
6892 struct ospf_if_params *params;
6893
paul1eb8ef22005-04-07 07:30:20 +00006894 for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
paul718e3742002-12-13 20:15:29 +00006895 {
paul718e3742002-12-13 20:15:29 +00006896 if (memcmp (ifp->name, "VLINK", 5) == 0)
6897 continue;
6898
6899 vty_out (vty, "!%s", VTY_NEWLINE);
6900 vty_out (vty, "interface %s%s", ifp->name,
6901 VTY_NEWLINE);
6902 if (ifp->desc)
6903 vty_out (vty, " description %s%s", ifp->desc,
6904 VTY_NEWLINE);
6905
6906 write++;
6907
6908 params = IF_DEF_PARAMS (ifp);
6909
6910 do {
6911 /* Interface Network print. */
6912 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
paul718e3742002-12-13 20:15:29 +00006913 params->type != OSPF_IFTYPE_LOOPBACK)
6914 {
ajsbc18d612004-12-15 15:07:19 +00006915 if (params->type != ospf_default_iftype(ifp))
hasso7b901432004-08-31 13:37:42 +00006916 {
6917 vty_out (vty, " ip ospf network %s",
6918 ospf_int_type_str[params->type]);
6919 if (params != IF_DEF_PARAMS (ifp))
6920 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6921 vty_out (vty, "%s", VTY_NEWLINE);
6922 }
paul718e3742002-12-13 20:15:29 +00006923 }
6924
6925 /* OSPF interface authentication print */
6926 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
6927 params->auth_type != OSPF_AUTH_NOTSET)
6928 {
hassoeb1ce602004-10-08 08:17:22 +00006929 const char *auth_str;
paul718e3742002-12-13 20:15:29 +00006930
6931 /* Translation tables are not that much help here due to syntax
6932 of the simple option */
6933 switch (params->auth_type)
6934 {
6935
6936 case OSPF_AUTH_NULL:
6937 auth_str = " null";
6938 break;
6939
6940 case OSPF_AUTH_SIMPLE:
6941 auth_str = "";
6942 break;
6943
6944 case OSPF_AUTH_CRYPTOGRAPHIC:
6945 auth_str = " message-digest";
6946 break;
6947
6948 default:
6949 auth_str = "";
6950 break;
6951 }
6952
6953 vty_out (vty, " ip ospf authentication%s", auth_str);
6954 if (params != IF_DEF_PARAMS (ifp))
6955 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6956 vty_out (vty, "%s", VTY_NEWLINE);
6957 }
6958
6959 /* Simple Authentication Password print. */
6960 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
6961 params->auth_simple[0] != '\0')
6962 {
6963 vty_out (vty, " ip ospf authentication-key %s",
6964 params->auth_simple);
6965 if (params != IF_DEF_PARAMS (ifp))
6966 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6967 vty_out (vty, "%s", VTY_NEWLINE);
6968 }
6969
6970 /* Cryptographic Authentication Key print. */
paul1eb8ef22005-04-07 07:30:20 +00006971 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
paul718e3742002-12-13 20:15:29 +00006972 {
paul718e3742002-12-13 20:15:29 +00006973 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
6974 ck->key_id, ck->auth_key);
6975 if (params != IF_DEF_PARAMS (ifp))
6976 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6977 vty_out (vty, "%s", VTY_NEWLINE);
6978 }
6979
6980 /* Interface Output Cost print. */
6981 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
6982 {
6983 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
6984 if (params != IF_DEF_PARAMS (ifp))
6985 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6986 vty_out (vty, "%s", VTY_NEWLINE);
6987 }
6988
6989 /* Hello Interval print. */
6990 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
6991 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
6992 {
6993 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
6994 if (params != IF_DEF_PARAMS (ifp))
6995 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
6996 vty_out (vty, "%s", VTY_NEWLINE);
6997 }
6998
6999
7000 /* Router Dead Interval print. */
7001 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
7002 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
7003 {
paulf9ad9372005-10-21 00:45:17 +00007004 vty_out (vty, " ip ospf dead-interval ");
7005
7006 /* fast hello ? */
7007 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
7008 vty_out (vty, "minimal hello-multiplier %d",
7009 params->fast_hello);
7010 else
7011 vty_out (vty, "%u", params->v_wait);
7012
paul718e3742002-12-13 20:15:29 +00007013 if (params != IF_DEF_PARAMS (ifp))
7014 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7015 vty_out (vty, "%s", VTY_NEWLINE);
7016 }
7017
7018 /* Router Priority print. */
7019 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
7020 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
7021 {
7022 vty_out (vty, " ip ospf priority %u", params->priority);
7023 if (params != IF_DEF_PARAMS (ifp))
7024 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7025 vty_out (vty, "%s", VTY_NEWLINE);
7026 }
7027
7028 /* Retransmit Interval print. */
7029 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
7030 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
7031 {
7032 vty_out (vty, " ip ospf retransmit-interval %u",
7033 params->retransmit_interval);
7034 if (params != IF_DEF_PARAMS (ifp))
7035 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7036 vty_out (vty, "%s", VTY_NEWLINE);
7037 }
7038
7039 /* Transmit Delay print. */
7040 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
7041 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
7042 {
7043 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
7044 if (params != IF_DEF_PARAMS (ifp))
7045 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7046 vty_out (vty, "%s", VTY_NEWLINE);
7047 }
7048
Joakim Tjernlund738bce72009-08-07 13:48:15 +02007049 /* Area print. */
7050 if (OSPF_IF_PARAM_CONFIGURED (params, if_area))
7051 {
Paul Jakma8a667cf2009-08-27 16:51:42 +01007052 vty_out (vty, " ip ospf area %s", inet_ntoa (params->if_area));
7053 if (params != IF_DEF_PARAMS (ifp))
7054 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7055 vty_out (vty, "%s", VTY_NEWLINE);
Joakim Tjernlund738bce72009-08-07 13:48:15 +02007056 }
7057
vincentba682532005-09-29 13:52:57 +00007058 /* MTU ignore print. */
7059 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
7060 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
7061 {
7062 if (params->mtu_ignore == 0)
7063 vty_out (vty, " no ip ospf mtu-ignore");
7064 else
7065 vty_out (vty, " ip ospf mtu-ignore");
7066 if (params != IF_DEF_PARAMS (ifp))
7067 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
7068 vty_out (vty, "%s", VTY_NEWLINE);
7069 }
7070
7071
paul718e3742002-12-13 20:15:29 +00007072 while (1)
7073 {
7074 if (rn == NULL)
7075 rn = route_top (IF_OIFS_PARAMS (ifp));
7076 else
7077 rn = route_next (rn);
7078
7079 if (rn == NULL)
7080 break;
7081 params = rn->info;
7082 if (params != NULL)
7083 break;
7084 }
7085 } while (rn);
7086
7087#ifdef HAVE_OPAQUE_LSA
7088 ospf_opaque_config_write_if (vty, ifp);
7089#endif /* HAVE_OPAQUE_LSA */
7090 }
7091
7092 return write;
7093}
7094
paul4dadc292005-05-06 21:37:42 +00007095static int
paul68980082003-03-25 05:07:42 +00007096config_write_network_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007097{
7098 struct route_node *rn;
7099 u_char buf[INET_ADDRSTRLEN];
7100
7101 /* `network area' print. */
paul68980082003-03-25 05:07:42 +00007102 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007103 if (rn->info)
7104 {
7105 struct ospf_network *n = rn->info;
7106
7107 memset (buf, 0, INET_ADDRSTRLEN);
7108
7109 /* Create Area ID string by specified Area ID format. */
7110 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007111 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007112 else
hassoc9e52be2004-09-26 16:09:34 +00007113 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007114 (unsigned long int) ntohl (n->area_id.s_addr));
7115
7116 /* Network print. */
7117 vty_out (vty, " network %s/%d area %s%s",
7118 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7119 buf, VTY_NEWLINE);
7120 }
7121
7122 return 0;
7123}
7124
paul4dadc292005-05-06 21:37:42 +00007125static int
paul68980082003-03-25 05:07:42 +00007126config_write_ospf_area (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007127{
hasso52dc7ee2004-09-23 19:18:23 +00007128 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007129 struct ospf_area *area;
paul718e3742002-12-13 20:15:29 +00007130 u_char buf[INET_ADDRSTRLEN];
7131
7132 /* Area configuration print. */
paul1eb8ef22005-04-07 07:30:20 +00007133 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
paul718e3742002-12-13 20:15:29 +00007134 {
paul718e3742002-12-13 20:15:29 +00007135 struct route_node *rn1;
7136
hassoc9e52be2004-09-26 16:09:34 +00007137 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
paul718e3742002-12-13 20:15:29 +00007138
7139 if (area->auth_type != OSPF_AUTH_NULL)
7140 {
7141 if (area->auth_type == OSPF_AUTH_SIMPLE)
7142 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
7143 else
7144 vty_out (vty, " area %s authentication message-digest%s",
7145 buf, VTY_NEWLINE);
7146 }
7147
7148 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
7149 vty_out (vty, " area %s shortcut %s%s", buf,
7150 ospf_shortcut_mode_str[area->shortcut_configured],
7151 VTY_NEWLINE);
7152
7153 if ((area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007154 || (area->external_routing == OSPF_AREA_NSSA)
paul718e3742002-12-13 20:15:29 +00007155 )
7156 {
paulb0a053b2003-06-22 09:04:47 +00007157 if (area->external_routing == OSPF_AREA_STUB)
paul718e3742002-12-13 20:15:29 +00007158 vty_out (vty, " area %s stub", buf);
paulb0a053b2003-06-22 09:04:47 +00007159 else if (area->external_routing == OSPF_AREA_NSSA)
7160 {
7161 vty_out (vty, " area %s nssa", buf);
7162 switch (area->NSSATranslatorRole)
7163 {
7164 case OSPF_NSSA_ROLE_NEVER:
7165 vty_out (vty, " translate-never");
7166 break;
7167 case OSPF_NSSA_ROLE_ALWAYS:
7168 vty_out (vty, " translate-always");
7169 break;
7170 case OSPF_NSSA_ROLE_CANDIDATE:
7171 default:
7172 vty_out (vty, " translate-candidate");
7173 }
7174 }
paul718e3742002-12-13 20:15:29 +00007175
7176 if (area->no_summary)
7177 vty_out (vty, " no-summary");
7178
7179 vty_out (vty, "%s", VTY_NEWLINE);
7180
7181 if (area->default_cost != 1)
7182 vty_out (vty, " area %s default-cost %d%s", buf,
7183 area->default_cost, VTY_NEWLINE);
7184 }
7185
7186 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
7187 if (rn1->info)
7188 {
7189 struct ospf_area_range *range = rn1->info;
7190
7191 vty_out (vty, " area %s range %s/%d", buf,
7192 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
7193
paul6c835672004-10-11 11:00:30 +00007194 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
paul718e3742002-12-13 20:15:29 +00007195 vty_out (vty, " cost %d", range->cost_config);
7196
7197 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
7198 vty_out (vty, " not-advertise");
7199
7200 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
7201 vty_out (vty, " substitute %s/%d",
7202 inet_ntoa (range->subst_addr), range->subst_masklen);
7203
7204 vty_out (vty, "%s", VTY_NEWLINE);
7205 }
7206
7207 if (EXPORT_NAME (area))
7208 vty_out (vty, " area %s export-list %s%s", buf,
7209 EXPORT_NAME (area), VTY_NEWLINE);
7210
7211 if (IMPORT_NAME (area))
7212 vty_out (vty, " area %s import-list %s%s", buf,
7213 IMPORT_NAME (area), VTY_NEWLINE);
7214
7215 if (PREFIX_NAME_IN (area))
7216 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
7217 PREFIX_NAME_IN (area), VTY_NEWLINE);
7218
7219 if (PREFIX_NAME_OUT (area))
7220 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
7221 PREFIX_NAME_OUT (area), VTY_NEWLINE);
7222 }
7223
7224 return 0;
7225}
7226
paul4dadc292005-05-06 21:37:42 +00007227static int
paul68980082003-03-25 05:07:42 +00007228config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007229{
7230 struct ospf_nbr_nbma *nbr_nbma;
7231 struct route_node *rn;
7232
7233 /* Static Neighbor configuration print. */
paul68980082003-03-25 05:07:42 +00007234 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007235 if ((nbr_nbma = rn->info))
7236 {
7237 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
7238
7239 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
7240 vty_out (vty, " priority %d", nbr_nbma->priority);
7241
7242 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
7243 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
7244
7245 vty_out (vty, "%s", VTY_NEWLINE);
7246 }
7247
7248 return 0;
7249}
7250
paul4dadc292005-05-06 21:37:42 +00007251static int
paul68980082003-03-25 05:07:42 +00007252config_write_virtual_link (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007253{
hasso52dc7ee2004-09-23 19:18:23 +00007254 struct listnode *node;
paul1eb8ef22005-04-07 07:30:20 +00007255 struct ospf_vl_data *vl_data;
paul718e3742002-12-13 20:15:29 +00007256 u_char buf[INET_ADDRSTRLEN];
7257
7258 /* Virtual-Link print */
paul1eb8ef22005-04-07 07:30:20 +00007259 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
paul718e3742002-12-13 20:15:29 +00007260 {
hasso52dc7ee2004-09-23 19:18:23 +00007261 struct listnode *n2;
paul718e3742002-12-13 20:15:29 +00007262 struct crypt_key *ck;
paul718e3742002-12-13 20:15:29 +00007263 struct ospf_interface *oi;
7264
7265 if (vl_data != NULL)
7266 {
7267 memset (buf, 0, INET_ADDRSTRLEN);
7268
7269 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
hassoc9e52be2004-09-26 16:09:34 +00007270 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
paul718e3742002-12-13 20:15:29 +00007271 else
hassoc9e52be2004-09-26 16:09:34 +00007272 sprintf ((char *) buf, "%lu",
paul718e3742002-12-13 20:15:29 +00007273 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
7274 oi = vl_data->vl_oi;
7275
7276 /* timers */
7277 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
7278 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
7279 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
7280 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
7281 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
7282 buf,
7283 inet_ntoa (vl_data->vl_peer),
7284 OSPF_IF_PARAM (oi, v_hello),
7285 OSPF_IF_PARAM (oi, retransmit_interval),
7286 OSPF_IF_PARAM (oi, transmit_delay),
7287 OSPF_IF_PARAM (oi, v_wait),
7288 VTY_NEWLINE);
7289 else
7290 vty_out (vty, " area %s virtual-link %s%s", buf,
7291 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
7292 /* Auth key */
7293 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
7294 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
7295 buf,
7296 inet_ntoa (vl_data->vl_peer),
7297 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
7298 VTY_NEWLINE);
7299 /* md5 keys */
paul1eb8ef22005-04-07 07:30:20 +00007300 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
7301 n2, ck))
7302 vty_out (vty, " area %s virtual-link %s"
7303 " message-digest-key %d md5 %s%s",
7304 buf,
7305 inet_ntoa (vl_data->vl_peer),
7306 ck->key_id, ck->auth_key, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007307
7308 }
7309 }
7310
7311 return 0;
7312}
7313
David Lamparter6b0655a2014-06-04 06:53:35 +02007314
paul4dadc292005-05-06 21:37:42 +00007315static int
paul68980082003-03-25 05:07:42 +00007316config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007317{
7318 int type;
7319
7320 /* redistribute print. */
7321 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Feng Luc99f3482014-10-16 09:52:36 +08007322 if (type != zclient->redist_default &&
7323 vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT))
paul718e3742002-12-13 20:15:29 +00007324 {
ajsf52d13c2005-10-01 17:38:06 +00007325 vty_out (vty, " redistribute %s", zebra_route_string(type));
paul68980082003-03-25 05:07:42 +00007326 if (ospf->dmetric[type].value >= 0)
paul020709f2003-04-04 02:44:16 +00007327 vty_out (vty, " metric %d", ospf->dmetric[type].value);
paul718e3742002-12-13 20:15:29 +00007328
paul68980082003-03-25 05:07:42 +00007329 if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007330 vty_out (vty, " metric-type 1");
7331
paul020709f2003-04-04 02:44:16 +00007332 if (ROUTEMAP_NAME (ospf, type))
7333 vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
paul718e3742002-12-13 20:15:29 +00007334
7335 vty_out (vty, "%s", VTY_NEWLINE);
7336 }
7337
7338 return 0;
7339}
7340
paul4dadc292005-05-06 21:37:42 +00007341static int
paul68980082003-03-25 05:07:42 +00007342config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007343{
paul68980082003-03-25 05:07:42 +00007344 if (ospf->default_metric != -1)
7345 vty_out (vty, " default-metric %d%s", ospf->default_metric,
paul718e3742002-12-13 20:15:29 +00007346 VTY_NEWLINE);
7347 return 0;
7348}
7349
paul4dadc292005-05-06 21:37:42 +00007350static int
paul68980082003-03-25 05:07:42 +00007351config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007352{
7353 int type;
7354
paul68980082003-03-25 05:07:42 +00007355 if (ospf)
paul718e3742002-12-13 20:15:29 +00007356 {
7357 /* distribute-list print. */
7358 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007359 if (DISTRIBUTE_NAME (ospf, type))
paul718e3742002-12-13 20:15:29 +00007360 vty_out (vty, " distribute-list %s out %s%s",
Denis Ovsienko171c9a92011-09-10 16:40:23 +04007361 DISTRIBUTE_NAME (ospf, type),
ajsf52d13c2005-10-01 17:38:06 +00007362 zebra_route_string(type), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007363
7364 /* default-information print. */
paul68980082003-03-25 05:07:42 +00007365 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
paul718e3742002-12-13 20:15:29 +00007366 {
paulc42c1772006-01-10 20:36:49 +00007367 vty_out (vty, " default-information originate");
7368 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
7369 vty_out (vty, " always");
paul718e3742002-12-13 20:15:29 +00007370
paul68980082003-03-25 05:07:42 +00007371 if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
paul718e3742002-12-13 20:15:29 +00007372 vty_out (vty, " metric %d",
paul68980082003-03-25 05:07:42 +00007373 ospf->dmetric[DEFAULT_ROUTE].value);
7374 if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
paul718e3742002-12-13 20:15:29 +00007375 vty_out (vty, " metric-type 1");
7376
paul020709f2003-04-04 02:44:16 +00007377 if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
7378 vty_out (vty, " route-map %s",
7379 ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
paul718e3742002-12-13 20:15:29 +00007380
7381 vty_out (vty, "%s", VTY_NEWLINE);
7382 }
7383
7384 }
7385
7386 return 0;
7387}
7388
paul4dadc292005-05-06 21:37:42 +00007389static int
paul68980082003-03-25 05:07:42 +00007390config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
paul718e3742002-12-13 20:15:29 +00007391{
7392 struct route_node *rn;
7393 struct ospf_distance *odistance;
7394
paul68980082003-03-25 05:07:42 +00007395 if (ospf->distance_all)
7396 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007397
paul68980082003-03-25 05:07:42 +00007398 if (ospf->distance_intra
7399 || ospf->distance_inter
7400 || ospf->distance_external)
paul718e3742002-12-13 20:15:29 +00007401 {
7402 vty_out (vty, " distance ospf");
7403
paul68980082003-03-25 05:07:42 +00007404 if (ospf->distance_intra)
7405 vty_out (vty, " intra-area %d", ospf->distance_intra);
7406 if (ospf->distance_inter)
7407 vty_out (vty, " inter-area %d", ospf->distance_inter);
7408 if (ospf->distance_external)
7409 vty_out (vty, " external %d", ospf->distance_external);
paul718e3742002-12-13 20:15:29 +00007410
7411 vty_out (vty, "%s", VTY_NEWLINE);
7412 }
7413
paul68980082003-03-25 05:07:42 +00007414 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
paul718e3742002-12-13 20:15:29 +00007415 if ((odistance = rn->info) != NULL)
7416 {
7417 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
7418 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
7419 odistance->access_list ? odistance->access_list : "",
7420 VTY_NEWLINE);
7421 }
7422 return 0;
7423}
7424
7425/* OSPF configuration write function. */
paul4dadc292005-05-06 21:37:42 +00007426static int
paul718e3742002-12-13 20:15:29 +00007427ospf_config_write (struct vty *vty)
7428{
paul020709f2003-04-04 02:44:16 +00007429 struct ospf *ospf;
paul1eb8ef22005-04-07 07:30:20 +00007430 struct interface *ifp;
7431 struct ospf_interface *oi;
hasso52dc7ee2004-09-23 19:18:23 +00007432 struct listnode *node;
paul718e3742002-12-13 20:15:29 +00007433 int write = 0;
7434
paul020709f2003-04-04 02:44:16 +00007435 ospf = ospf_lookup ();
paul68980082003-03-25 05:07:42 +00007436 if (ospf != NULL)
paul718e3742002-12-13 20:15:29 +00007437 {
7438 /* `router ospf' print. */
7439 vty_out (vty, "router ospf%s", VTY_NEWLINE);
7440
7441 write++;
7442
paul68980082003-03-25 05:07:42 +00007443 if (!ospf->networks)
paul718e3742002-12-13 20:15:29 +00007444 return write;
7445
7446 /* Router ID print. */
paul68980082003-03-25 05:07:42 +00007447 if (ospf->router_id_static.s_addr != 0)
paul718e3742002-12-13 20:15:29 +00007448 vty_out (vty, " ospf router-id %s%s",
paul68980082003-03-25 05:07:42 +00007449 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007450
7451 /* ABR type print. */
pauld57834f2005-07-12 20:04:22 +00007452 if (ospf->abr_type != OSPF_ABR_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007453 vty_out (vty, " ospf abr-type %s%s",
paul68980082003-03-25 05:07:42 +00007454 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007455
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007456 /* log-adjacency-changes flag print. */
7457 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
7458 {
7459 vty_out(vty, " log-adjacency-changes");
7460 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
7461 vty_out(vty, " detail");
7462 vty_out(vty, "%s", VTY_NEWLINE);
7463 }
7464
paul718e3742002-12-13 20:15:29 +00007465 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
paul68980082003-03-25 05:07:42 +00007466 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
paul718e3742002-12-13 20:15:29 +00007467 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
7468
7469 /* auto-cost reference-bandwidth configuration. */
paul68980082003-03-25 05:07:42 +00007470 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
paulf9ad9372005-10-21 00:45:17 +00007471 {
7472 vty_out (vty, "! Important: ensure reference bandwidth "
7473 "is consistent across all routers%s", VTY_NEWLINE);
7474 vty_out (vty, " auto-cost reference-bandwidth %d%s",
7475 ospf->ref_bandwidth / 1000, VTY_NEWLINE);
7476 }
paul718e3742002-12-13 20:15:29 +00007477
Michael Rossberg2ef762e2015-07-27 07:56:25 +02007478 /* LSA timers */
7479 if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL)
7480 vty_out (vty, " timers throttle lsa all %d%s",
7481 ospf->min_ls_interval, VTY_NEWLINE);
7482 if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL)
7483 vty_out (vty, " timers lsa arrival %d%s",
7484 ospf->min_ls_arrival, VTY_NEWLINE);
7485
paul718e3742002-12-13 20:15:29 +00007486 /* SPF timers print. */
paul68980082003-03-25 05:07:42 +00007487 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
paulea4ffc92005-10-21 20:04:41 +00007488 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
7489 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
7490 vty_out (vty, " timers throttle spf %d %d %d%s",
paul88d6cf32005-10-29 12:50:09 +00007491 ospf->spf_delay, ospf->spf_holdtime,
paulea4ffc92005-10-21 20:04:41 +00007492 ospf->spf_max_holdtime, VTY_NEWLINE);
paul88d6cf32005-10-29 12:50:09 +00007493
7494 /* Max-metric router-lsa print */
7495 config_write_stub_router (vty, ospf);
7496
paul718e3742002-12-13 20:15:29 +00007497 /* SPF refresh parameters print. */
paul68980082003-03-25 05:07:42 +00007498 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
paul718e3742002-12-13 20:15:29 +00007499 vty_out (vty, " refresh timer %d%s",
paul68980082003-03-25 05:07:42 +00007500 ospf->lsa_refresh_interval, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00007501
7502 /* Redistribute information print. */
paul68980082003-03-25 05:07:42 +00007503 config_write_ospf_redistribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007504
7505 /* passive-interface print. */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007506 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
7507 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
7508
paul1eb8ef22005-04-07 07:30:20 +00007509 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007510 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
7511 && IF_DEF_PARAMS (ifp)->passive_interface !=
7512 ospf->passive_interface_default)
7513 {
7514 vty_out (vty, " %spassive-interface %s%s",
7515 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
7516 ifp->name, VTY_NEWLINE);
7517 }
paul1eb8ef22005-04-07 07:30:20 +00007518 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007519 {
7520 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
7521 continue;
7522 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
7523 passive_interface))
7524 {
7525 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
7526 continue;
7527 }
7528 else if (oi->params->passive_interface == ospf->passive_interface_default)
7529 continue;
7530
7531 vty_out (vty, " %spassive-interface %s %s%s",
7532 oi->params->passive_interface ? "" : "no ",
paul1eb8ef22005-04-07 07:30:20 +00007533 oi->ifp->name,
7534 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007535 }
paul718e3742002-12-13 20:15:29 +00007536
7537 /* Network area print. */
paul68980082003-03-25 05:07:42 +00007538 config_write_network_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007539
7540 /* Area config print. */
paul68980082003-03-25 05:07:42 +00007541 config_write_ospf_area (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007542
7543 /* static neighbor print. */
paul68980082003-03-25 05:07:42 +00007544 config_write_ospf_nbr_nbma (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007545
7546 /* Virtual-Link print. */
paul68980082003-03-25 05:07:42 +00007547 config_write_virtual_link (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007548
7549 /* Default metric configuration. */
paul68980082003-03-25 05:07:42 +00007550 config_write_ospf_default_metric (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007551
7552 /* Distribute-list and default-information print. */
paul68980082003-03-25 05:07:42 +00007553 config_write_ospf_distribute (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007554
7555 /* Distance configuration. */
paul68980082003-03-25 05:07:42 +00007556 config_write_ospf_distance (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007557
7558#ifdef HAVE_OPAQUE_LSA
paul68980082003-03-25 05:07:42 +00007559 ospf_opaque_config_write_router (vty, ospf);
paul718e3742002-12-13 20:15:29 +00007560#endif /* HAVE_OPAQUE_LSA */
7561 }
7562
7563 return write;
7564}
7565
7566void
paul4dadc292005-05-06 21:37:42 +00007567ospf_vty_show_init (void)
paul718e3742002-12-13 20:15:29 +00007568{
7569 /* "show ip ospf" commands. */
7570 install_element (VIEW_NODE, &show_ip_ospf_cmd);
7571 install_element (ENABLE_NODE, &show_ip_ospf_cmd);
7572
7573 /* "show ip ospf database" commands. */
7574 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
7575 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
7576 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7577 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7578 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
7579 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
7580 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
7581 install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
7582 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
7583 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
7584 install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
7585 install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
7586 install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
7587 install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
7588
7589 /* "show ip ospf interface" commands. */
7590 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
7591 install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
7592
7593 /* "show ip ospf neighbor" commands. */
7594 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7595 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
7596 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
7597 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7598 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
7599 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
7600 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
7601 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
7602 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
7603 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
7604 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
7605 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
7606 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
7607 install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
7608
7609 /* "show ip ospf route" commands. */
7610 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
7611 install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
paul718e3742002-12-13 20:15:29 +00007612 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7613 install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
paul718e3742002-12-13 20:15:29 +00007614}
7615
David Lamparter6b0655a2014-06-04 06:53:35 +02007616
paul718e3742002-12-13 20:15:29 +00007617/* ospfd's interface node. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08007618static struct cmd_node interface_node =
paul718e3742002-12-13 20:15:29 +00007619{
7620 INTERFACE_NODE,
7621 "%s(config-if)# ",
7622 1
7623};
7624
7625/* Initialization of OSPF interface. */
paul4dadc292005-05-06 21:37:42 +00007626static void
7627ospf_vty_if_init (void)
paul718e3742002-12-13 20:15:29 +00007628{
7629 /* Install interface node. */
7630 install_node (&interface_node, config_write_interface);
7631
7632 install_element (CONFIG_NODE, &interface_cmd);
paul32d24632003-05-23 09:25:20 +00007633 install_element (CONFIG_NODE, &no_interface_cmd);
paul718e3742002-12-13 20:15:29 +00007634 install_default (INTERFACE_NODE);
7635
7636 /* "description" commands. */
7637 install_element (INTERFACE_NODE, &interface_desc_cmd);
7638 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
7639
7640 /* "ip ospf authentication" commands. */
7641 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
7642 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
7643 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
7644 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
7645 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
7646 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
7647 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
7648 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
7649 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
7650 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
7651
7652 /* "ip ospf message-digest-key" commands. */
7653 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
7654 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
7655 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
7656 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
7657
7658 /* "ip ospf cost" commands. */
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007659 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
7660 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04007661 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
7662 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007663 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007664 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
7665
vincentba682532005-09-29 13:52:57 +00007666 /* "ip ospf mtu-ignore" commands. */
7667 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
7668 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
7669 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
7670 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
7671
paul718e3742002-12-13 20:15:29 +00007672 /* "ip ospf dead-interval" commands. */
7673 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
7674 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007675 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
7676 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
paul718e3742002-12-13 20:15:29 +00007677 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
7678 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
paulf9ad9372005-10-21 00:45:17 +00007679
paul718e3742002-12-13 20:15:29 +00007680 /* "ip ospf hello-interval" commands. */
7681 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
7682 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
7683 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
7684 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
7685
7686 /* "ip ospf network" commands. */
7687 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
7688 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
7689
7690 /* "ip ospf priority" commands. */
7691 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
7692 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
7693 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
7694 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
7695
7696 /* "ip ospf retransmit-interval" commands. */
7697 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
7698 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
7699 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
7700 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
7701
7702 /* "ip ospf transmit-delay" commands. */
7703 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
7704 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
7705 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
7706 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
7707
Joakim Tjernlund738bce72009-08-07 13:48:15 +02007708 /* "ip ospf area" commands. */
7709 install_element (INTERFACE_NODE, &ip_ospf_area_cmd);
7710 install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd);
7711
paul718e3742002-12-13 20:15:29 +00007712 /* These commands are compatibitliy for previous version. */
7713 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
7714 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
7715 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
7716 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007717 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
7718 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007719 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
Denis Ovsienko827341b2009-09-28 19:34:59 +04007720 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
7721 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
Denis Ovsienko9eff36b2009-04-10 18:51:24 +04007722 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
paul718e3742002-12-13 20:15:29 +00007723 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
7724 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
7725 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
7726 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
7727 install_element (INTERFACE_NODE, &ospf_network_cmd);
7728 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
7729 install_element (INTERFACE_NODE, &ospf_priority_cmd);
7730 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
7731 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
7732 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
7733 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
7734 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
7735}
7736
paul4dadc292005-05-06 21:37:42 +00007737static void
7738ospf_vty_zebra_init (void)
paul718e3742002-12-13 20:15:29 +00007739{
paul718e3742002-12-13 20:15:29 +00007740 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
paul718e3742002-12-13 20:15:29 +00007741 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7742
7743 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
7744 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
7745
paul718e3742002-12-13 20:15:29 +00007746 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
paul718e3742002-12-13 20:15:29 +00007747 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
7748
7749 install_element (OSPF_NODE, &ospf_default_metric_cmd);
7750 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
7751 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
7752
7753 install_element (OSPF_NODE, &ospf_distance_cmd);
7754 install_element (OSPF_NODE, &no_ospf_distance_cmd);
7755 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
Christian Franke6f2a6702013-09-30 12:27:52 +00007756 install_element (OSPF_NODE, &ospf_distance_ospf_cmd);
paul718e3742002-12-13 20:15:29 +00007757#if 0
7758 install_element (OSPF_NODE, &ospf_distance_source_cmd);
7759 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
7760 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
7761 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
7762#endif /* 0 */
7763}
7764
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08007765static struct cmd_node ospf_node =
paul718e3742002-12-13 20:15:29 +00007766{
7767 OSPF_NODE,
7768 "%s(config-router)# ",
7769 1
7770};
7771
David Lamparter6b0655a2014-06-04 06:53:35 +02007772
paul718e3742002-12-13 20:15:29 +00007773/* Install OSPF related vty commands. */
7774void
paul4dadc292005-05-06 21:37:42 +00007775ospf_vty_init (void)
paul718e3742002-12-13 20:15:29 +00007776{
7777 /* Install ospf top node. */
7778 install_node (&ospf_node, ospf_config_write);
7779
7780 /* "router ospf" commands. */
7781 install_element (CONFIG_NODE, &router_ospf_cmd);
7782 install_element (CONFIG_NODE, &no_router_ospf_cmd);
7783
7784 install_default (OSPF_NODE);
7785
7786 /* "ospf router-id" commands. */
7787 install_element (OSPF_NODE, &ospf_router_id_cmd);
7788 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
paula2c62832003-04-23 17:01:31 +00007789 install_element (OSPF_NODE, &router_ospf_id_cmd);
7790 install_element (OSPF_NODE, &no_router_ospf_id_cmd);
paul718e3742002-12-13 20:15:29 +00007791
7792 /* "passive-interface" commands. */
paula2c62832003-04-23 17:01:31 +00007793 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
7794 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007795 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
paula2c62832003-04-23 17:01:31 +00007796 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
7797 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
Paul Jakma7ffa8fa2006-10-22 20:07:53 +00007798 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
paul718e3742002-12-13 20:15:29 +00007799
7800 /* "ospf abr-type" commands. */
7801 install_element (OSPF_NODE, &ospf_abr_type_cmd);
7802 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
7803
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +00007804 /* "ospf log-adjacency-changes" commands. */
7805 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
7806 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
7807 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
7808 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
7809
paul718e3742002-12-13 20:15:29 +00007810 /* "ospf rfc1583-compatible" commands. */
7811 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
7812 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
7813 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
7814 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
7815
7816 /* "network area" commands. */
paula2c62832003-04-23 17:01:31 +00007817 install_element (OSPF_NODE, &ospf_network_area_cmd);
7818 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
paul718e3742002-12-13 20:15:29 +00007819
7820 /* "area authentication" commands. */
paula2c62832003-04-23 17:01:31 +00007821 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
7822 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
7823 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
paul718e3742002-12-13 20:15:29 +00007824
7825 /* "area range" commands. */
paula2c62832003-04-23 17:01:31 +00007826 install_element (OSPF_NODE, &ospf_area_range_cmd);
7827 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
7828 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
7829 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
7830 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
7831 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
7832 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
7833 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
7834 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
7835 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
7836 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
paul718e3742002-12-13 20:15:29 +00007837
7838 /* "area virtual-link" commands. */
paula2c62832003-04-23 17:01:31 +00007839 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
7840 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
paul718e3742002-12-13 20:15:29 +00007841
paula2c62832003-04-23 17:01:31 +00007842 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
7843 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
paul718e3742002-12-13 20:15:29 +00007844
paula2c62832003-04-23 17:01:31 +00007845 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
7846 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
paul718e3742002-12-13 20:15:29 +00007847
paula2c62832003-04-23 17:01:31 +00007848 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
7849 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
paul718e3742002-12-13 20:15:29 +00007850
paula2c62832003-04-23 17:01:31 +00007851 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
7852 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
paul718e3742002-12-13 20:15:29 +00007853
paula2c62832003-04-23 17:01:31 +00007854 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
7855 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
7856 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
paul718e3742002-12-13 20:15:29 +00007857
paula2c62832003-04-23 17:01:31 +00007858 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
7859 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007860
paula2c62832003-04-23 17:01:31 +00007861 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
7862 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007863
paula2c62832003-04-23 17:01:31 +00007864 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
7865 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
7866 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
paul718e3742002-12-13 20:15:29 +00007867
paula2c62832003-04-23 17:01:31 +00007868 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
7869 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
7870 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
paul718e3742002-12-13 20:15:29 +00007871
7872 /* "area stub" commands. */
paula2c62832003-04-23 17:01:31 +00007873 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
7874 install_element (OSPF_NODE, &ospf_area_stub_cmd);
7875 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
7876 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
paul718e3742002-12-13 20:15:29 +00007877
paul718e3742002-12-13 20:15:29 +00007878 /* "area nssa" commands. */
paula2c62832003-04-23 17:01:31 +00007879 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
7880 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
7881 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
7882 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
7883 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
7884 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
paul718e3742002-12-13 20:15:29 +00007885
paula2c62832003-04-23 17:01:31 +00007886 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
7887 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
paul718e3742002-12-13 20:15:29 +00007888
paula2c62832003-04-23 17:01:31 +00007889 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
7890 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
paul718e3742002-12-13 20:15:29 +00007891
paula2c62832003-04-23 17:01:31 +00007892 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
7893 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
paul718e3742002-12-13 20:15:29 +00007894
paula2c62832003-04-23 17:01:31 +00007895 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
7896 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +00007897
paula2c62832003-04-23 17:01:31 +00007898 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
7899 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
paul88d6cf32005-10-29 12:50:09 +00007900
Michael Rossberg2ef762e2015-07-27 07:56:25 +02007901 /* LSA timer commands */
7902 install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd);
7903 install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd);
7904 install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd);
7905 install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd);
7906
paul88d6cf32005-10-29 12:50:09 +00007907 /* SPF timer commands */
paula2c62832003-04-23 17:01:31 +00007908 install_element (OSPF_NODE, &ospf_timers_spf_cmd);
7909 install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
pauld24f6e22005-10-21 09:23:12 +00007910 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
7911 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
7912
paul88d6cf32005-10-29 12:50:09 +00007913 /* refresh timer commands */
paula2c62832003-04-23 17:01:31 +00007914 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
7915 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
7916 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
paul718e3742002-12-13 20:15:29 +00007917
paul88d6cf32005-10-29 12:50:09 +00007918 /* max-metric commands */
7919 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
7920 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
7921 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
7922 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
7923 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
7924 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
7925
7926 /* reference bandwidth commands */
paula2c62832003-04-23 17:01:31 +00007927 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
7928 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
paul718e3742002-12-13 20:15:29 +00007929
7930 /* "neighbor" commands. */
paula2c62832003-04-23 17:01:31 +00007931 install_element (OSPF_NODE, &ospf_neighbor_cmd);
7932 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
7933 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
7934 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
7935 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
7936 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
7937 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
7938 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
paul718e3742002-12-13 20:15:29 +00007939
7940 /* Init interface related vty commands. */
7941 ospf_vty_if_init ();
7942
7943 /* Init zebra related vty commands. */
7944 ospf_vty_zebra_init ();
7945}